From: Kristen Accardi * added dock uevents. Because this requires an acpi_device struct, if no acpi_device struct exists, the dock_event() will create one via acpi_bus_add() first. Signed-off-by: Andrew Morton --- drivers/acpi/dock.c | 66 +++++++++++++++++++++++++++++------------- 1 files changed, 47 insertions(+), 19 deletions(-) diff -puN drivers/acpi/dock.c~acpi-dock-driver-v4 drivers/acpi/dock.c --- devel/drivers/acpi/dock.c~acpi-dock-driver-v4 2006-05-12 08:26:51.000000000 -0700 +++ devel-akpm/drivers/acpi/dock.c 2006-05-12 08:27:07.000000000 -0700 @@ -58,6 +58,8 @@ struct dock_dependent_device { }; #define DOCK_DOCKING 0x00000001 +#define DOCK_EVENT KOBJ_DOCK +#define UNDOCK_EVENT KOBJ_UNDOCK static struct dock_station *dock_station; @@ -238,6 +240,34 @@ static void hotplug_dock_devices(struct spin_unlock(&ds->hp_lock); } + +static void dock_event(struct dock_station *ds, u32 event, int num) +{ + struct acpi_device *device; + struct acpi_device *parent_device; + acpi_handle parent; + int ret; + + if (acpi_bus_get_device(ds->handle, &device)) { + /* + * no device created for this object, + * so we should create one. + */ + acpi_get_parent(ds->handle, &parent); + if (acpi_bus_get_device(parent, &parent_device)) + parent_device = NULL; + + ret = acpi_bus_add(&device, parent_device, ds->handle, + ACPI_BUS_TYPE_DEVICE); + if (ret) { + pr_debug("error adding bus, %x\n", + -ret_val); + return; + } + } + kobject_uevent(&device->kobj, num); +} + /** * eject_dock - respond to a dock eject request * @ds: the dock station @@ -276,7 +306,7 @@ static void eject_dock(struct dock_stati * * Execute the _DCK method in response to an acpi event */ -static acpi_status handle_dock(struct dock_station *ds, int dock) +static void handle_dock(struct dock_station *ds, int dock) { acpi_status status; struct acpi_object_list arg_list; @@ -300,8 +330,6 @@ static acpi_status handle_dock(struct do pr_debug("%s: failed to execute _DCK\n", obj->string.pointer); kfree(buffer.pointer); kfree(name_buffer.pointer); - - return status; } static inline void dock(struct dock_station *ds) @@ -423,7 +451,7 @@ void unregister_hotplug_dock_device(acpi EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); /** - * acpi_dock_notify - act upon an acpi dock notification + * dock_notify - act upon an acpi dock notification * @handle: the dock station handle * @event: the acpi event * @data: our driver data struct @@ -434,7 +462,7 @@ EXPORT_SYMBOL_GPL(unregister_hotplug_doc * check to make sure the dock device is still present, then undock * and hotremove all the devices that may need removing. */ -static void acpi_dock_notify(acpi_handle handle, u32 event, void *data) +static void dock_notify(acpi_handle handle, u32 event, void *data) { struct dock_station *ds = (struct dock_station *)data; @@ -451,7 +479,7 @@ static void acpi_dock_notify(acpi_handle event, NULL); hotplug_dock_devices(ds, event); complete_dock(ds); - /* TBD - generate an event */ + dock_event(ds, event, DOCK_EVENT); } break; case ACPI_NOTIFY_DEVICE_CHECK: @@ -470,7 +498,7 @@ static void acpi_dock_notify(acpi_handle * event prior to actually doing the undock * so that the device struct still exists. */ - /* TBD - generate an event */ + dock_event(ds, event, UNDOCK_EVENT); hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST); undock(ds); eject_dock(ds); @@ -516,13 +544,13 @@ find_dock_devices(acpi_handle handle, u3 } /** - * acpi_dock_add - add a new dock station + * dock_add - add a new dock station * @handle: the dock station handle * * allocated and initialize a new dock station device. Find all devices * that are on the dock station, and register for dock event notifications. */ -static int acpi_dock_add(acpi_handle handle) +static int dock_add(acpi_handle handle) { int ret; acpi_status status; @@ -555,7 +583,7 @@ static int acpi_dock_add(acpi_handle han /* register for dock events */ status = acpi_install_notify_handler(dock_station->handle, ACPI_SYSTEM_NOTIFY, - acpi_dock_notify, dock_station); + dock_notify, dock_station); if (ACPI_FAILURE(status)) { printk(KERN_ERR PREFIX "Error installing notify handler\n"); @@ -574,9 +602,9 @@ dock_add_err: } /** - * acpi_dock_remove - free up resources related to the dock station + * dock_remove - free up resources related to the dock station */ -static int acpi_dock_remove(void) +static int dock_remove(void) { struct dock_dependent_device *dd, *tmp; acpi_status status; @@ -592,7 +620,7 @@ static int acpi_dock_remove(void) /* remove dock notify handler */ status = acpi_remove_notify_handler(dock_station->handle, ACPI_SYSTEM_NOTIFY, - acpi_dock_notify); + dock_notify); if (ACPI_FAILURE(status)) printk(KERN_ERR "Error removing notify handler\n"); @@ -617,7 +645,7 @@ find_dock(acpi_handle handle, u32 lvl, v acpi_status status = AE_OK; if (is_dock(handle)) { - if (acpi_dock_add(handle) >= 0) { + if (dock_add(handle) >= 0) { (*count)++; status = AE_CTRL_TERMINATE; } @@ -625,7 +653,7 @@ find_dock(acpi_handle handle, u32 lvl, v return status; } -static int __init acpi_dock_init(void) +static int __init dock_init(void) { int num = 0; @@ -641,10 +669,10 @@ static int __init acpi_dock_init(void) return 0; } -static void __exit acpi_dock_exit(void) +static void __exit dock_exit(void) { - acpi_dock_remove(); + dock_remove(); } -module_init(acpi_dock_init); -module_exit(acpi_dock_exit); +module_init(dock_init); +module_exit(dock_exit); _