From: Kristen Accardi 1. Fix build problem so that acpiphp can be built without CONFIG_ACPI_DOCK 2. remove all acpi debug messages 3. change exported APIs to not use ACPI-CA isms 4. remove return values from unregister functions 5. Handle ACPI_DEVICE_CHECK properly. When this is sent on an object with _DCK, this should be treated as an undock request. 6. Remove bus_event generation, as this is causing problems on some systems. I will add this back in after I figure out what was wrong with it. Signed-off-by: Kristen Carlson Accardi Signed-off-by: Andrew Morton --- drivers/acpi/dock.c | 68 ++++++++++++++++------------------ include/acpi/acpi_drivers.h | 14 +++++-- 2 files changed, 44 insertions(+), 38 deletions(-) diff -puN drivers/acpi/dock.c~acpi-dock-driver-v3 drivers/acpi/dock.c --- devel/drivers/acpi/dock.c~acpi-dock-driver-v3 2006-04-28 23:56:56.000000000 -0700 +++ devel-akpm/drivers/acpi/dock.c 2006-04-28 23:56:56.000000000 -0700 @@ -30,9 +30,7 @@ #include #include -#define ACPI_DOCK_COMPONENT 0x10000000 #define ACPI_DOCK_DRIVER_NAME "ACPI Dock Station Driver" -#define _COMPONENT ACPI_DOCK_COMPONENT ACPI_MODULE_NAME("dock") MODULE_AUTHOR("Kristen Carlson Accardi"); @@ -251,11 +249,15 @@ static void eject_dock(struct dock_stati { struct acpi_object_list arg_list; union acpi_object arg; - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; - union acpi_object *obj; + acpi_status status; + acpi_handle tmp; - acpi_get_name(ds->handle, ACPI_FULL_PATHNAME, &buffer); - obj = buffer.pointer; + /* all dock devices should have _EJ0, but check anyway */ + status = acpi_get_handle(ds->handle, "_EJ0", &tmp); + if (ACPI_FAILURE(status)) { + pr_debug("No _EJ0 support for dock device\n"); + return; + } arg_list.count = 1; arg_list.pointer = &arg; @@ -263,12 +265,8 @@ static void eject_dock(struct dock_stati arg.integer.value = 1; if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0", - &arg_list, NULL)) - || dock_present(ds)) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "%s: failed to eject dock!\n", - obj->string.pointer)); - - kfree(buffer.pointer); + &arg_list, NULL))) + pr_debug("Failed to evaluate _EJ0!\n"); } /** @@ -299,8 +297,7 @@ static acpi_status handle_dock(struct do arg.integer.value = dock; status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer); if (ACPI_FAILURE(status)) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "%s: failed to execute _DCK\n", - obj->string.pointer)); + pr_debug("%s: failed to execute _DCK\n", obj->string.pointer); kfree(buffer.pointer); kfree(name_buffer.pointer); @@ -364,9 +361,9 @@ EXPORT_SYMBOL_GPL(register_dock_notifier * unregister_dock_notifier - remove yourself from the dock notifier list * @nb: the callers notifier block */ -int unregister_dock_notifier(struct notifier_block *nb) +void unregister_dock_notifier(struct notifier_block *nb) { - return atomic_notifier_chain_unregister(&dock_notifier_list, nb); + atomic_notifier_chain_unregister(&dock_notifier_list, nb); } EXPORT_SYMBOL_GPL(unregister_dock_notifier); @@ -381,14 +378,14 @@ EXPORT_SYMBOL_GPL(unregister_dock_notifi * event, they can register an acpi_notifiy_handler to be called by * the dock driver after _DCK is executed. */ -acpi_status +int register_hotplug_dock_device(acpi_handle handle, acpi_notify_handler handler, void *context) { struct dock_dependent_device *dd; if (!dock_station) - return AE_ERROR; + return -ENODEV; /* * make sure this handle is for a device dependent on the dock, @@ -399,10 +396,10 @@ register_hotplug_dock_device(acpi_handle dd->handler = handler; dd->context = context; dock_add_hotplug_device(dock_station, dd); - return AE_OK; + return 0; } - return AE_ERROR; + return -EINVAL; } EXPORT_SYMBOL_GPL(register_hotplug_dock_device); @@ -411,17 +408,16 @@ EXPORT_SYMBOL_GPL(register_hotplug_dock_ * unregister_hotplug_dock_device - remove yourself from the hotplug list * @handle: the acpi handle of the device */ -acpi_status unregister_hotplug_dock_device(acpi_handle handle) +void unregister_hotplug_dock_device(acpi_handle handle) { struct dock_dependent_device *dd; if (!dock_station) - return AE_ERROR; + return; dd = find_dock_dependent_device(dock_station, handle); if (dd) dock_del_hotplug_device(dock_station, dd); - return AE_OK; } EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); @@ -441,11 +437,9 @@ EXPORT_SYMBOL_GPL(unregister_hotplug_doc static void acpi_dock_notify(acpi_handle handle, u32 event, void *data) { struct dock_station *ds = (struct dock_station *)data; - struct acpi_device *device; switch (event) { case ACPI_NOTIFY_BUS_CHECK: - case ACPI_NOTIFY_DEVICE_CHECK: if (!dock_in_progress(ds) && dock_present(ds)) { begin_dock(ds); dock(ds); @@ -457,10 +451,18 @@ static void acpi_dock_notify(acpi_handle event, NULL); hotplug_dock_devices(ds, event); complete_dock(ds); - if (acpi_bus_get_device(ds->handle, &device)) - acpi_bus_generate_event(device, event, 0); + /* TBD - generate an event */ } break; + case ACPI_NOTIFY_DEVICE_CHECK: + /* + * According to acpi spec 3.0a, if a DEVICE_CHECK notification + * is sent and _DCK is present, it is assumed to mean an + * undock request. This notify routine will only be called + * for objects defining _DCK, so we will fall through to eject + * request here. However, we will pass an eject request through + * to the driver who wish to hotplug. + */ case ACPI_NOTIFY_EJECT_REQUEST: if (!dock_in_progress(ds) && dock_present(ds)) { /* @@ -468,10 +470,8 @@ static void acpi_dock_notify(acpi_handle * event prior to actually doing the undock * so that the device struct still exists. */ - if (acpi_bus_get_device(ds->handle, &device)) - acpi_bus_generate_event(device, event, 0); - - hotplug_dock_devices(ds, event); + /* TBD - generate an event */ + hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST); undock(ds); eject_dock(ds); if (dock_present(ds)) @@ -558,8 +558,7 @@ static int acpi_dock_add(acpi_handle han acpi_dock_notify, dock_station); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); + printk(KERN_ERR PREFIX "Error installing notify handler\n"); ret = -ENODEV; goto dock_add_err; } @@ -595,8 +594,7 @@ static int acpi_dock_remove(void) ACPI_SYSTEM_NOTIFY, acpi_dock_notify); if (ACPI_FAILURE(status)) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); + printk(KERN_ERR "Error removing notify handler\n"); /* free dock station memory */ kfree(dock_station); diff -puN include/acpi/acpi_drivers.h~acpi-dock-driver-v3 include/acpi/acpi_drivers.h --- devel/include/acpi/acpi_drivers.h~acpi-dock-driver-v3 2006-04-28 23:56:56.000000000 -0700 +++ devel-akpm/include/acpi/acpi_drivers.h 2006-04-28 23:56:56.000000000 -0700 @@ -113,10 +113,18 @@ extern int acpi_specific_hotkey_enabled; /*-------------------------------------------------------------------------- Dock Station -------------------------------------------------------------------------- */ +#if defined(CONFIG_ACPI_DOCK) || defined(CONFIG_ACPI_DOCK_MODULE) extern int is_dock_device(acpi_handle handle); extern int register_dock_notifier(struct notifier_block *nb); -extern int unregister_dock_notifier(struct notifier_block *nb); -extern acpi_status register_hotplug_dock_device(acpi_handle handle, +extern void unregister_dock_notifier(struct notifier_block *nb); +extern int register_hotplug_dock_device(acpi_handle handle, acpi_notify_handler handler, void *context); -extern acpi_status unregister_hotplug_dock_device(acpi_handle handle); +extern void unregister_hotplug_dock_device(acpi_handle handle); +#else +#define is_dock_device(h) (0) +#define register_dock_notifier(nb) (-ENODEV) +#define unregister_dock_notifier(nb) do { } while(0) +#define register_hotplug_dock_device(h1, h2, c) (-ENODEV) +#define unregister_hotplug_dock_device(h) do { } while(0) +#endif #endif /*__ACPI_DRIVERS_H__*/ _