xref: /illumos-gate/usr/src/cmd/hal/hald/solaris/devinfo_ieee1394.c (revision 7a6d80f1660abd4755c68cbd094d4a914681d26e)
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 #ifdef HAVE_CONFIG_H
13 #  include <config.h>
14 #endif
15 
16 #include <stdio.h>
17 #include <string.h>
18 #include <libdevinfo.h>
19 #include <sys/types.h>
20 #include <sys/mkdev.h>
21 #include <sys/stat.h>
22 
23 #include "../osspec.h"
24 #include "../logger.h"
25 #include "../hald.h"
26 #include "../hald_dbus.h"
27 #include "../device_info.h"
28 #include "../util.h"
29 #include "../ids.h"
30 #include "hotplug.h"
31 #include "devinfo.h"
32 #include "devinfo_ieee1394.h"
33 
34 HalDevice *devinfo_ieee1394_add(HalDevice *parent, di_node_t node, char *devfs_path, char *device_type);
35 static HalDevice *devinfo_scsa1394_add(HalDevice *d, di_node_t node, gchar *devfs_path);
36 
37 DevinfoDevHandler devinfo_ieee1394_handler = {
38         devinfo_ieee1394_add,
39 	NULL,
40 	NULL,
41 	NULL,
42 	NULL,
43         NULL
44 };
45 
46 HalDevice *
47 devinfo_ieee1394_add(HalDevice *parent, di_node_t node, char *devfs_path, char *device_type)
48 {
49 	HalDevice *d = NULL;
50 	char	*compat;
51 	char	*driver_name;
52 
53 	/*
54 	 * we distinguish 1394 devices by compatible name
55 	 * starting with 'firewire'
56 	 */
57 	if ((di_compatible_names (node, &compat) < 1) ||
58 	    (strncmp (compat, "firewire", sizeof ("firewire") - 1) != 0)) {
59 		return (NULL);
60 	}
61 
62 	if ((driver_name = di_driver_name (node)) == NULL) {
63 		return (NULL);
64 	}
65 
66 	if (strcmp (driver_name, "scsa1394") == 0) {
67 		d = devinfo_scsa1394_add (parent, node, devfs_path);
68 	}
69 
70 	return (d);
71 }
72 
73 static HalDevice *
74 devinfo_scsa1394_add(HalDevice *parent, di_node_t node, gchar *devfs_path)
75 {
76 	HalDevice *d = NULL;
77 
78 	d = hal_device_new ();
79 
80 	devinfo_set_default_properties (d, parent, node, devfs_path);
81 	hal_device_property_set_string (d, "info.subsystem", "ieee1394");
82 	hal_device_property_set_string (d, "info.product", "FireWire SBP-2 device");
83 
84 	devinfo_add_enqueue (d, devfs_path, &devinfo_ieee1394_handler);
85 
86 	return (d);
87 }
88 
89