xref: /titanic_51/usr/src/cmd/hal/hald/solaris/devinfo_ieee1394.c (revision a563a037ee1e9e7c39304f3775eb7327ab86b914)
1 /***************************************************************************
2  *
3  * devinfo_ieee1394.c : IEEE 1394/FireWire devices
4  *
5  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
6  * Use is subject to license terms.
7  *
8  * Licensed under the Academic Free License version 2.1
9  *
10  **************************************************************************/
11 
12 #pragma ident	"%Z%%M%	%I%	%E% SMI"
13 
14 #ifdef HAVE_CONFIG_H
15 #  include <config.h>
16 #endif
17 
18 #include <stdio.h>
19 #include <string.h>
20 #include <libdevinfo.h>
21 #include <sys/types.h>
22 #include <sys/mkdev.h>
23 #include <sys/stat.h>
24 
25 #include "../osspec.h"
26 #include "../logger.h"
27 #include "../hald.h"
28 #include "../hald_dbus.h"
29 #include "../device_info.h"
30 #include "../util.h"
31 #include "../ids.h"
32 #include "hotplug.h"
33 #include "devinfo.h"
34 #include "devinfo_ieee1394.h"
35 
36 HalDevice *devinfo_ieee1394_add(HalDevice *parent, di_node_t node, char *devfs_path, char *device_type);
37 static HalDevice *devinfo_scsa1394_add(HalDevice *d, di_node_t node, gchar *devfs_path);
38 
39 DevinfoDevHandler devinfo_ieee1394_handler = {
40         devinfo_ieee1394_add,
41 	NULL,
42 	NULL,
43 	NULL,
44 	NULL,
45         NULL
46 };
47 
48 HalDevice *
49 devinfo_ieee1394_add(HalDevice *parent, di_node_t node, char *devfs_path, char *device_type)
50 {
51 	HalDevice *d = NULL;
52 	char	*compat;
53 	char	*driver_name;
54 
55 	/*
56 	 * we distinguish 1394 devices by compatible name
57 	 * starting with 'firewire'
58 	 */
59 	if ((di_compatible_names (node, &compat) < 1) ||
60 	    (strncmp (compat, "firewire", sizeof ("firewire") - 1) != 0)) {
61 		return (NULL);
62 	}
63 
64 	if ((driver_name = di_driver_name (node)) == NULL) {
65 		return (NULL);
66 	}
67 
68 	if (strcmp (driver_name, "scsa1394") == 0) {
69 		d = devinfo_scsa1394_add (parent, node, devfs_path);
70 	}
71 
72 	return (d);
73 }
74 
75 static HalDevice *
76 devinfo_scsa1394_add(HalDevice *parent, di_node_t node, gchar *devfs_path)
77 {
78 	HalDevice *d = NULL;
79 
80 	d = hal_device_new ();
81 
82 	devinfo_set_default_properties (d, parent, node, devfs_path);
83 	hal_device_property_set_string (d, "info.subsystem", "ieee1394");
84 	hal_device_property_set_string (d, "info.product", "FireWire SBP-2 device");
85 
86 	devinfo_add_enqueue (d, devfs_path, &devinfo_ieee1394_handler);
87 
88 	return (d);
89 }
90 
91