hal/hald/linux2 classdev.c,1.30,1.31

David Zeuthen david at freedesktop.org
Sun Aug 21 18:13:59 PDT 2005


Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv19471/hald/linux2

Modified Files:
	classdev.c 
Log Message:
2005-08-21  David Zeuthen  <davidz at redhat.com>

        As of Linux 2.6.14, the kernel will export a mmc_host class for
        MMC- devices. This patch teaches hal about this. Patch from Pierre
        Ossman <drzeus-list at drzeus.cx>.

        * hald/linux2/classdev.c (mmc_host_add): New function
        (mmc_host_compute_udi): New function



Index: classdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/classdev.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- classdev.c	5 Aug 2005 10:57:21 -0000	1.30
+++ classdev.c	22 Aug 2005 01:13:57 -0000	1.31
@@ -848,6 +848,53 @@
 
 /*--------------------------------------------------------------------------------------------------------------*/
 
+static HalDevice *
+mmc_host_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *physdev, const gchar *sysfs_path_in_devices)
+{
+	HalDevice *d;
+	gint host_num;
+	const gchar *last_elem;
+
+	d = NULL;
+
+	if (physdev == NULL || sysfs_path_in_devices == NULL) {
+		goto out;
+	}
+
+	d = hal_device_new ();
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	hal_device_property_set_string (d, "linux.sysfs_path_device", sysfs_path_in_devices);
+
+	hal_device_property_set_string (d, "info.parent", physdev->udi);
+
+	hal_device_property_set_string (d, "info.category", "mmc_host");
+	hal_device_add_capability (d, "mmc_host");
+
+	hal_device_property_set_string (d, "info.product", "MMC/SD Host Adapter");
+
+	last_elem = hal_util_get_last_element (sysfs_path);
+	sscanf (last_elem, "mmc%d", &host_num);
+	hal_device_property_set_int (d, "mmc_host.host", host_num);
+
+out:
+	return d;
+}
+
+static gboolean
+mmc_host_compute_udi (HalDevice *d)
+{
+	gchar udi[256];
+
+	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "%s_mmc_host",
+			      hal_device_property_get_string (d, "info.parent"));
+	hal_device_set_udi (d, udi);
+	hal_device_property_set_string (d, "info.udi", udi);
+	return TRUE;
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
 static gboolean
 classdev_remove (HalDevice *d)
 {
@@ -961,6 +1008,16 @@
 	.remove       = classdev_remove
 };
 
+static ClassDevHandler classdev_handler_mmc_host =
+{
+	.subsystem    = "mmc_host",
+	.add          = mmc_host_add,
+	.get_prober   = NULL,
+	.post_probing = NULL,
+	.compute_udi  = mmc_host_compute_udi,
+	.remove       = classdev_remove
+};
+
 static ClassDevHandler *classdev_handlers[] = {
 	&classdev_handler_input,
 	&classdev_handler_bluetooth,
@@ -971,6 +1028,7 @@
 	&classdev_handler_serial,
 	&classdev_handler_tape,
 	&classdev_handler_tape390,
+	&classdev_handler_mmc_host,
 	NULL
 };
 




More information about the hal-commit mailing list