Patch from Matthew Garrett (Ubuntu) that adds support to memorystick bus in hal, introduced in Linux 2.6.25 diff -p -up hal-0.5.11rc2/hald/linux/device.c.orig hal-0.5.11rc2/hald/linux/device.c --- hal-0.5.11rc2/hald/linux/device.c.orig 2008-03-17 17:25:13.000000000 -0400 +++ hal-0.5.11rc2/hald/linux/device.c 2008-04-30 16:23:28.000000000 -0400 @@ -1488,6 +1488,51 @@ tape_compute_udi (HalDevice *d) /*--------------------------------------------------------------------------------------------------------------*/ + +static HalDevice * +memstick_host_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path) +{ + HalDevice *d; + gint host_num; + const gchar *last_elem; + + d = NULL; + + if (parent_dev == NULL || parent_path == NULL) { + goto out; + } + + d = hal_device_new (); + hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path); + + hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev)); + + hal_device_property_set_string (d, "info.category", "memstick_host"); + hal_device_add_capability (d, "memstick_host"); + + hal_device_property_set_string (d, "info.product", "Memory Stick Host Adapter"); + + last_elem = hal_util_get_last_element (sysfs_path); + sscanf (last_elem, "memstick%d", &host_num); + hal_device_property_set_int (d, "memstick_host.host", host_num); + +out: + return d; +} + +static gboolean +memstick_host_compute_udi (HalDevice *d) +{ + gchar udi[256]; + + hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi), + "%s_memstick_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 HalDevice * mmc_host_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path) { @@ -2297,6 +2342,49 @@ scsi_compute_udi (HalDevice *d) } +static HalDevice * +memstick_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path) +{ + HalDevice *d; + const gchar *bus_id; + + if (parent_dev == NULL) { + d = NULL; + goto out; + } + + d = hal_device_new (); + hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path); + hal_device_property_set_string (d, "info.subsystem", "memstick"); + hal_device_property_set_string (d, "info.bus", "memstick"); + hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev)); + + hal_util_set_driver (d, "info.linux.driver", sysfs_path); + + bus_id = hal_util_get_last_element (sysfs_path); + + hal_util_set_string_from_file (d, "info.product", sysfs_path, "attr_modelname"); + hal_util_set_string_from_file (d, "memstick.class", sysfs_path, "class"); + hal_util_set_string_from_file (d, "memstick.category", sysfs_path, "category"); + +out: + return d; +} + +static gboolean +memstick_compute_udi (HalDevice *d) +{ + gchar udi[256]; + + hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi), + "%s_memstick_card", + 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 HalDevice * @@ -3927,6 +4015,16 @@ static DevHandler dev_handler_mmc_host = .remove = dev_remove }; +static DevHandler dev_handler_memstick_host = +{ + .subsystem = "memstick_host", + .add = memstick_host_add, + .get_prober = NULL, + .post_probing = NULL, + .compute_udi = memstick_host_compute_udi, + .remove = dev_remove +}; + static DevHandler dev_handler_pci = { .subsystem = "pci", .add = pci_add, @@ -3998,6 +4096,13 @@ static DevHandler dev_handler_sdio = { .remove = dev_remove }; +static DevHandler dev_handler_memstick = { + .subsystem = "memstick", + .add = memstick_add, + .compute_udi = memstick_compute_udi, + .remove = dev_remove +}; + static DevHandler dev_handler_ieee1394 = { .subsystem = "ieee1394", .add = ieee1394_add, @@ -4114,6 +4219,7 @@ static DevHandler *dev_handlers[] = { &dev_handler_pcmcia, &dev_handler_scsi, &dev_handler_mmc, + &dev_handler_memstick, &dev_handler_sdio, &dev_handler_ieee1394, &dev_handler_xen, @@ -4134,6 +4240,7 @@ static DevHandler *dev_handlers[] = { &dev_handler_tape, &dev_handler_tape390, &dev_handler_mmc_host, + &dev_handler_memstick_host, &dev_handler_backlight, &dev_handler_firewire, &dev_handler_power_supply, diff -p -up hal-0.5.11rc2/hald/linux/blockdev.c.orig hal-0.5.11rc2/hald/linux/blockdev.c --- hal-0.5.11rc2/hald/linux/blockdev.c.orig 2008-03-17 17:25:13.000000000 -0400 +++ hal-0.5.11rc2/hald/linux/blockdev.c 2008-04-30 16:28:19.000000000 -0400 @@ -1180,6 +1180,12 @@ hotplug_event_begin_add_blockdev (const is_hotpluggable = TRUE; hal_device_property_set_string (d, "storage.bus", "mmc"); break; + } else if (strcmp (bus, "memstick") == 0) { + physdev = d_it; + physdev_udi = udi_it; + is_hotpluggable = TRUE; + hal_device_property_set_string (d, "storage.bus", "memstick"); + break; } else if (strcmp (bus, "ccw") == 0) { physdev = d_it; physdev_udi = udi_it; @@ -1323,6 +1329,8 @@ hotplug_event_begin_add_blockdev (const } else if (strcmp (parent_bus, "mmc") == 0) { hal_device_property_set_string (d, "storage.drive_type", "sd_mmc"); + } else if (strcmp (parent_bus, "memstick") == 0) { + hal_device_property_set_string (d, "storage.drive_type", "memstick"); } else if (strcmp (parent_bus, "vio") == 0) { char buf[256]; const gchar *prop;