hal/hald/linux2 blockdev.c, 1.24, 1.25 classdev.c, 1.33,
1.34 physdev.c, 1.21, 1.22
Richard Hughes
hughsient at freedesktop.org
Wed Sep 28 09:35:07 PDT 2005
Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv11803
Modified Files:
blockdev.c classdev.c physdev.c
Log Message:
New functionality, to add support to devices connected to the platform bus. Also add mmc hotplugging fix.
Index: blockdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/blockdev.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- blockdev.c 27 Sep 2005 09:42:12 -0000 1.24
+++ blockdev.c 28 Sep 2005 16:35:05 -0000 1.25
@@ -571,36 +571,28 @@
d = hal_device_new ();
- /* lip service for PC floppy drives */
- if (parent == NULL && sscanf (hal_util_get_last_element (sysfs_path), "fd%d", &floppy_num) == 1) {
- ;
- } else {
- floppy_num = -1;
-
- if (parent == NULL) {
- const gchar *luks_uuid = blockdev_get_luks_uuid (device_file);
- if (luks_uuid != NULL) {
- is_partition = TRUE;
- parent = blockdev_get_luks_parent (luks_uuid, d);
- }
+ if (parent == NULL) {
+ const gchar *luks_uuid = blockdev_get_luks_uuid (device_file);
+ if (luks_uuid != NULL) {
+ is_partition = TRUE;
+ parent = blockdev_get_luks_parent (luks_uuid, d);
}
+ }
- if (parent == NULL) {
- HAL_INFO (("Ignoring hotplug event - no parent"));
- goto error;
- }
+ if (parent == NULL) {
+ HAL_INFO (("Ignoring hotplug event - no parent"));
+ goto error;
+ }
- if (!is_fakevolume && hal_device_property_get_bool (parent, "storage.no_partitions_hint")) {
- HAL_INFO (("Ignoring blockdev since not a fakevolume and parent has "
- "storage.no_partitions_hint==TRUE"));
- goto error;
- }
+ if (!is_fakevolume && hal_device_property_get_bool (parent, "storage.no_partitions_hint")) {
+ HAL_INFO (("Ignoring blockdev since not a fakevolume and parent has "
+ "storage.no_partitions_hint==TRUE"));
+ goto error;
}
hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
hal_device_property_set_string (d, "linux.sysfs_path_device", sysfs_path);
- if (parent != NULL)
- hal_device_property_set_string (d, "info.parent", parent->udi);
+ hal_device_property_set_string (d, "info.parent", parent->udi);
hal_device_property_set_int (d, "linux.hotplug_type", HOTPLUG_EVENT_SYSFS_BLOCK);
hal_device_property_set_string (d, "block.device", device_file);
@@ -614,7 +606,9 @@
hal_device_property_set_int (d, "block.minor", minor);
hal_device_property_set_bool (d, "block.is_volume", is_partition);
- if (floppy_num >= 0) {
+ if (hal_device_has_property(parent, "info.bus") &&
+ (strcmp(hal_device_property_get_string(parent, "info.bus"), "platform") == 0) &&
+ (sscanf(hal_device_property_get_string(parent, "platform.id"), "floppy.%d", &floppy_num) == 1)) {
/* for now, just cheat here for floppy drives */
HAL_INFO (("doing floppy drive hack for floppy %d", floppy_num));
@@ -628,8 +622,7 @@
hal_device_property_set_string (d, "info.vendor", "");
hal_device_property_set_string (d, "info.product", "PC Floppy Drive");
hal_device_property_set_string (d, "storage.drive_type", "floppy");
- hal_device_property_set_string (d, "storage.physical_device", "/org/freedesktop/Hal/devices/computer");
- hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
+ hal_device_property_set_string (d, "storage.physical_device", parent->udi);
hal_device_property_set_bool (d, "storage.removable", TRUE);
hal_device_property_set_bool (d, "storage.hotpluggable", FALSE);
hal_device_property_set_bool (d, "storage.requires_eject", FALSE);
@@ -731,6 +724,7 @@
} else if (strcmp (bus, "mmc") == 0) {
physdev = d_it;
physdev_udi = udi_it;
+ is_hotpluggable = TRUE;
hal_device_property_set_string (d, "storage.bus", "mmc");
break;
} else if (strcmp (bus, "ccw") == 0) {
Index: classdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/classdev.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- classdev.c 27 Sep 2005 09:42:12 -0000 1.33
+++ classdev.c 28 Sep 2005 16:35:05 -0000 1.34
@@ -770,16 +770,16 @@
hal_device_property_set_string (d, "info.product", "Serial Port");
}
- /* TODO: run prober to see if there actually is a physical
- * serial port if possible (on my T41, the kernel
- * exports ttyS0 but there is no real port on the
- * laptop; only on the docking station)
- */
-
out:
return d;
}
+static const gchar *
+serial_get_prober (HalDevice *d)
+{
+ return "hald-probe-serial";
+}
+
static gboolean
serial_compute_udi (HalDevice *d)
{
@@ -982,7 +982,7 @@
{
.subsystem = "tty",
.add = serial_add,
- .get_prober = NULL,
+ .get_prober = serial_get_prober,
.post_probing = NULL,
.compute_udi = serial_compute_udi,
.remove = classdev_remove
Index: physdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/physdev.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- physdev.c 27 Sep 2005 09:42:13 -0000 1.21
+++ physdev.c 28 Sep 2005 16:35:05 -0000 1.22
@@ -484,6 +484,52 @@
/*--------------------------------------------------------------------------------------------------------------*/
static HalDevice *
+platform_add (const gchar *sysfs_path, HalDevice *parent)
+{
+ HalDevice *d;
+ const gchar *dev_id;
+ gchar buf[64];
+
+ 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);
+ hal_device_property_set_string (d, "info.bus", "platform");
+ if (parent != NULL) {
+ hal_device_property_set_string (d, "info.parent", parent->udi);
+ } else {
+ hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
+ }
+
+ hal_util_set_driver (d, "info.linux.driver", sysfs_path);
+
+ dev_id = hal_util_get_last_element (sysfs_path);
+
+ hal_device_property_set_string (d, "platform.id", dev_id);
+
+ g_snprintf (buf, sizeof (buf), "Platform Device (%s)", hal_device_property_get_string (d, "platform.id"));
+ hal_device_property_set_string (d, "info.product", buf);
+
+ return d;
+}
+
+static gboolean
+platform_compute_udi (HalDevice *d)
+{
+ gchar udi[256];
+
+ hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+ "/org/freedesktop/Hal/devices/platform_%s",
+ hal_device_property_get_string (d, "platform.id"));
+ hal_device_set_udi (d, udi);
+ hal_device_property_set_string (d, "info.udi", udi);
+
+ return TRUE;
+
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static HalDevice *
serio_add (const gchar *sysfs_path, HalDevice *parent)
{
HalDevice *d;
@@ -1244,6 +1290,13 @@
.remove = physdev_remove
};
+static PhysDevHandler physdev_handler_platform = {
+ .subsystem = "platform",
+ .add = platform_add,
+ .compute_udi = platform_compute_udi,
+ .remove = physdev_remove
+};
+
static PhysDevHandler physdev_handler_serio = {
.subsystem = "serio",
.add = serio_add,
@@ -1307,6 +1360,7 @@
&physdev_handler_usb,
&physdev_handler_ide,
&physdev_handler_pnp,
+ &physdev_handler_platform,
&physdev_handler_serio,
&physdev_handler_pcmcia,
&physdev_handler_scsi,
More information about the hal-commit
mailing list