summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <hughsient@gmail.com>2005-09-28 16:35:05 +0000
committerRichard Hughes <hughsient@gmail.com>2005-09-28 16:35:05 +0000
commitd24651ef660a8423abf49c12691ef1def0af9267 (patch)
tree7bb451baa18f7387c8f1def7038a1b08c6d6d3fb
parenta61b2e6130e032afa957c791de2597e94692ed96 (diff)
New functionality, to add support to devices connected to the platform bus.
Also add mmc hotplugging fix.
-rw-r--r--hald/linux2/blockdev.c46
-rw-r--r--hald/linux2/classdev.c14
-rw-r--r--hald/linux2/physdev.c54
3 files changed, 81 insertions, 33 deletions
diff --git a/hald/linux2/blockdev.c b/hald/linux2/blockdev.c
index c69d94a1..c1e92745 100644
--- a/hald/linux2/blockdev.c
+++ b/hald/linux2/blockdev.c
@@ -571,36 +571,28 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
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 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
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 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
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 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
} 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) {
diff --git a/hald/linux2/classdev.c b/hald/linux2/classdev.c
index 07e01bd3..7bc9016a 100644
--- a/hald/linux2/classdev.c
+++ b/hald/linux2/classdev.c
@@ -770,16 +770,16 @@ serial_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *physde
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 @@ static ClassDevHandler classdev_handler_serial =
{
.subsystem = "tty",
.add = serial_add,
- .get_prober = NULL,
+ .get_prober = serial_get_prober,
.post_probing = NULL,
.compute_udi = serial_compute_udi,
.remove = classdev_remove
diff --git a/hald/linux2/physdev.c b/hald/linux2/physdev.c
index 041293aa..a1be01fa 100644
--- a/hald/linux2/physdev.c
+++ b/hald/linux2/physdev.c
@@ -484,6 +484,52 @@ pnp_compute_udi (HalDevice *d)
/*--------------------------------------------------------------------------------------------------------------*/
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 @@ static PhysDevHandler physdev_handler_pnp = {
.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 @@ static PhysDevHandler *phys_handlers[] = {
&physdev_handler_usb,
&physdev_handler_ide,
&physdev_handler_pnp,
+ &physdev_handler_platform,
&physdev_handler_serio,
&physdev_handler_pcmcia,
&physdev_handler_scsi,