2 * dock.c - ACPI dock station driver
4 * Copyright (C) 2006 Kristen Carlson Accardi <kristen.c.accardi@intel.com>
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/slab.h>
28 #include <linux/init.h>
29 #include <linux/types.h>
30 #include <linux/notifier.h>
31 #include <linux/platform_device.h>
32 #include <linux/jiffies.h>
33 #include <linux/stddef.h>
34 #include <linux/acpi.h>
35 #include <acpi/acpi_bus.h>
36 #include <acpi/acpi_drivers.h>
38 #define PREFIX "ACPI: "
40 #define ACPI_DOCK_DRIVER_DESCRIPTION "ACPI Dock Station Driver"
42 ACPI_MODULE_NAME("dock");
43 MODULE_AUTHOR("Kristen Carlson Accardi");
44 MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_DESCRIPTION);
45 MODULE_LICENSE("GPL");
47 static bool immediate_undock = 1;
48 module_param(immediate_undock, bool, 0644);
49 MODULE_PARM_DESC(immediate_undock, "1 (default) will cause the driver to "
50 "undock immediately when the undock button is pressed, 0 will cause"
51 " the driver to wait for userspace to write the undock sysfs file "
54 static struct atomic_notifier_head dock_notifier_list;
56 static const struct acpi_device_id dock_device_ids[] = {
60 MODULE_DEVICE_TABLE(acpi, dock_device_ids);
64 unsigned long last_dock_time;
66 struct list_head dependent_devices;
68 struct list_head sibling;
69 struct platform_device *dock_device;
71 static LIST_HEAD(dock_stations);
72 static int dock_station_count;
73 static DEFINE_MUTEX(hotplug_lock);
75 struct dock_dependent_device {
76 struct list_head list;
78 const struct acpi_dock_ops *hp_ops;
80 unsigned int hp_refcount;
81 void (*hp_release)(void *);
84 #define DOCK_DOCKING 0x00000001
85 #define DOCK_UNDOCKING 0x00000002
86 #define DOCK_IS_DOCK 0x00000010
87 #define DOCK_IS_ATA 0x00000020
88 #define DOCK_IS_BAT 0x00000040
90 #define UNDOCK_EVENT 2
92 /*****************************************************************************
93 * Dock Dependent device functions *
94 *****************************************************************************/
96 * add_dock_dependent_device - associate a device with the dock station
97 * @ds: The dock station
98 * @handle: handle of the dependent device
100 * Add the dependent device to the dock's dependent device list.
103 add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
105 struct dock_dependent_device *dd;
107 dd = kzalloc(sizeof(*dd), GFP_KERNEL);
112 INIT_LIST_HEAD(&dd->list);
113 list_add_tail(&dd->list, &ds->dependent_devices);
118 static void remove_dock_dependent_devices(struct dock_station *ds)
120 struct dock_dependent_device *dd, *aux;
122 list_for_each_entry_safe(dd, aux, &ds->dependent_devices, list) {
129 * dock_init_hotplug - Initialize a hotplug device on a docking station.
130 * @dd: Dock-dependent device.
131 * @ops: Dock operations to attach to the dependent device.
132 * @context: Data to pass to the @ops callbacks and @release.
133 * @init: Optional initialization routine to run after setting up context.
134 * @release: Optional release routine to run on removal.
136 static int dock_init_hotplug(struct dock_dependent_device *dd,
137 const struct acpi_dock_ops *ops, void *context,
138 void (*init)(void *), void (*release)(void *))
142 mutex_lock(&hotplug_lock);
143 if (WARN_ON(dd->hp_context)) {
148 dd->hp_context = context;
149 dd->hp_release = release;
153 mutex_unlock(&hotplug_lock);
158 * dock_release_hotplug - Decrement hotplug reference counter of dock device.
159 * @dd: Dock-dependent device.
161 * Decrement the reference counter of @dd and if 0, detach its hotplug
162 * operations from it, reset its context pointer and run the optional release
163 * routine if present.
165 static void dock_release_hotplug(struct dock_dependent_device *dd)
167 mutex_lock(&hotplug_lock);
168 if (dd->hp_context && !--dd->hp_refcount) {
169 void (*release)(void *) = dd->hp_release;
170 void *context = dd->hp_context;
173 dd->hp_context = NULL;
174 dd->hp_release = NULL;
178 mutex_unlock(&hotplug_lock);
181 static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event,
184 acpi_notify_handler cb = NULL;
187 mutex_lock(&hotplug_lock);
189 if (dd->hp_context) {
193 cb = uevent ? dd->hp_ops->uevent : dd->hp_ops->handler;
196 mutex_unlock(&hotplug_lock);
202 cb(dd->handle, event, dd->hp_context);
204 dock_release_hotplug(dd);
208 * find_dock_dependent_device - get a device dependent on this dock
209 * @ds: the dock station
210 * @handle: the acpi_handle of the device we want
212 * iterate over the dependent device list for this dock. If the
213 * dependent device matches the handle, return.
215 static struct dock_dependent_device *
216 find_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
218 struct dock_dependent_device *dd;
220 list_for_each_entry(dd, &ds->dependent_devices, list)
221 if (handle == dd->handle)
227 /*****************************************************************************
229 *****************************************************************************/
230 static int __init is_battery(acpi_handle handle)
232 struct acpi_device_info *info;
235 if (!ACPI_SUCCESS(acpi_get_object_info(handle, &info)))
237 if (!(info->valid & ACPI_VALID_HID))
240 ret = !strcmp("PNP0C0A", info->hardware_id.string);
246 /* Check whether ACPI object is an ejectable battery or disk bay */
247 static bool __init is_ejectable_bay(acpi_handle handle)
249 if (acpi_has_method(handle, "_EJ0") && is_battery(handle))
252 return acpi_bay_match(handle);
256 * is_dock_device - see if a device is on a dock station
257 * @handle: acpi handle of the device
259 * If this device is either the dock station itself,
260 * or is a device dependent on the dock station, then it
263 int is_dock_device(acpi_handle handle)
265 struct dock_station *dock_station;
267 if (!dock_station_count)
270 if (acpi_dock_match(handle))
273 list_for_each_entry(dock_station, &dock_stations, sibling)
274 if (find_dock_dependent_device(dock_station, handle))
279 EXPORT_SYMBOL_GPL(is_dock_device);
282 * dock_present - see if the dock station is present.
283 * @ds: the dock station
285 * execute the _STA method. note that present does not
286 * imply that we are docked.
288 static int dock_present(struct dock_station *ds)
290 unsigned long long sta;
294 status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta);
295 if (ACPI_SUCCESS(status) && sta)
302 * dock_create_acpi_device - add new devices to acpi
303 * @handle - handle of the device to add
305 * This function will create a new acpi_device for the given
306 * handle if one does not exist already. This should cause
307 * acpi to scan for drivers for the given devices, and call
308 * matching driver's add routine.
310 static void dock_create_acpi_device(acpi_handle handle)
312 struct acpi_device *device;
315 if (acpi_bus_get_device(handle, &device)) {
317 * no device created for this object,
318 * so we should create one.
320 ret = acpi_bus_scan(handle);
322 pr_debug("error adding bus, %x\n", -ret);
327 * dock_remove_acpi_device - remove the acpi_device struct from acpi
328 * @handle - the handle of the device to remove
330 * Tell acpi to remove the acpi_device. This should cause any loaded
331 * driver to have it's remove routine called.
333 static void dock_remove_acpi_device(acpi_handle handle)
335 struct acpi_device *device;
337 if (!acpi_bus_get_device(handle, &device))
338 acpi_bus_trim(device);
342 * hot_remove_dock_devices - Remove dock station devices.
345 static void hot_remove_dock_devices(struct dock_station *ds)
347 struct dock_dependent_device *dd;
350 * Walk the list in reverse order so that devices that have been added
351 * last are removed first (in case there are some indirect dependencies
354 list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
355 dock_hotplug_event(dd, ACPI_NOTIFY_EJECT_REQUEST, false);
357 list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
358 dock_remove_acpi_device(dd->handle);
362 * hotplug_dock_devices - Insert devices on a dock station.
363 * @ds: the dock station
364 * @event: either bus check or device check request
366 * Some devices on the dock station need to have drivers called
367 * to perform hotplug operations after a dock event has occurred.
368 * Traverse the list of dock devices that have registered a
369 * hotplug handler, and call the handler.
371 static void hotplug_dock_devices(struct dock_station *ds, u32 event)
373 struct dock_dependent_device *dd;
375 /* Call driver specific hotplug functions. */
376 list_for_each_entry(dd, &ds->dependent_devices, list)
377 dock_hotplug_event(dd, event, false);
380 * Now make sure that an acpi_device is created for each dependent
381 * device. That will cause scan handlers to be attached to device
382 * objects or acpi_drivers to be stopped/started if they are present.
384 list_for_each_entry(dd, &ds->dependent_devices, list)
385 dock_create_acpi_device(dd->handle);
388 static void dock_event(struct dock_station *ds, u32 event, int num)
390 struct device *dev = &ds->dock_device->dev;
391 char event_string[13];
392 char *envp[] = { event_string, NULL };
393 struct dock_dependent_device *dd;
395 if (num == UNDOCK_EVENT)
396 sprintf(event_string, "EVENT=undock");
398 sprintf(event_string, "EVENT=dock");
401 * Indicate that the status of the dock station has
404 if (num == DOCK_EVENT)
405 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
407 list_for_each_entry(dd, &ds->dependent_devices, list)
408 dock_hotplug_event(dd, event, true);
410 if (num != DOCK_EVENT)
411 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
415 * handle_dock - handle a dock event
416 * @ds: the dock station
417 * @dock: to dock, or undock - that is the question
419 * Execute the _DCK method in response to an acpi event
421 static void handle_dock(struct dock_station *ds, int dock)
424 struct acpi_object_list arg_list;
425 union acpi_object arg;
426 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
428 acpi_handle_info(ds->handle, "%s\n", dock ? "docking" : "undocking");
430 /* _DCK method has one argument */
432 arg_list.pointer = &arg;
433 arg.type = ACPI_TYPE_INTEGER;
434 arg.integer.value = dock;
435 status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer);
436 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
437 acpi_handle_err(ds->handle, "Failed to execute _DCK (0x%x)\n",
440 kfree(buffer.pointer);
443 static inline void dock(struct dock_station *ds)
448 static inline void undock(struct dock_station *ds)
453 static inline void begin_dock(struct dock_station *ds)
455 ds->flags |= DOCK_DOCKING;
458 static inline void complete_dock(struct dock_station *ds)
460 ds->flags &= ~(DOCK_DOCKING);
461 ds->last_dock_time = jiffies;
464 static inline void begin_undock(struct dock_station *ds)
466 ds->flags |= DOCK_UNDOCKING;
469 static inline void complete_undock(struct dock_station *ds)
471 ds->flags &= ~(DOCK_UNDOCKING);
475 * dock_in_progress - see if we are in the middle of handling a dock event
476 * @ds: the dock station
478 * Sometimes while docking, false dock events can be sent to the driver
479 * because good connections aren't made or some other reason. Ignore these
480 * if we are in the middle of doing something.
482 static int dock_in_progress(struct dock_station *ds)
484 if ((ds->flags & DOCK_DOCKING) ||
485 time_before(jiffies, (ds->last_dock_time + HZ)))
491 * register_dock_notifier - add yourself to the dock notifier list
492 * @nb: the callers notifier block
494 * If a driver wishes to be notified about dock events, they can
495 * use this function to put a notifier block on the dock notifier list.
496 * this notifier call chain will be called after a dock event, but
497 * before hotplugging any new devices.
499 int register_dock_notifier(struct notifier_block *nb)
501 if (!dock_station_count)
504 return atomic_notifier_chain_register(&dock_notifier_list, nb);
506 EXPORT_SYMBOL_GPL(register_dock_notifier);
509 * unregister_dock_notifier - remove yourself from the dock notifier list
510 * @nb: the callers notifier block
512 void unregister_dock_notifier(struct notifier_block *nb)
514 if (!dock_station_count)
517 atomic_notifier_chain_unregister(&dock_notifier_list, nb);
519 EXPORT_SYMBOL_GPL(unregister_dock_notifier);
522 * register_hotplug_dock_device - register a hotplug function
523 * @handle: the handle of the device
524 * @ops: handlers to call after docking
525 * @context: device specific data
526 * @init: Optional initialization routine to run after registration
527 * @release: Optional release routine to run on unregistration
529 * If a driver would like to perform a hotplug operation after a dock
530 * event, they can register an acpi_notifiy_handler to be called by
531 * the dock driver after _DCK is executed.
533 int register_hotplug_dock_device(acpi_handle handle,
534 const struct acpi_dock_ops *ops, void *context,
535 void (*init)(void *), void (*release)(void *))
537 struct dock_dependent_device *dd;
538 struct dock_station *dock_station;
541 if (WARN_ON(!context))
544 if (!dock_station_count)
548 * make sure this handle is for a device dependent on the dock,
549 * this would include the dock station itself
551 list_for_each_entry(dock_station, &dock_stations, sibling) {
553 * An ATA bay can be in a dock and itself can be ejected
554 * separately, so there are two 'dock stations' which need the
557 dd = find_dock_dependent_device(dock_station, handle);
558 if (dd && !dock_init_hotplug(dd, ops, context, init, release))
564 EXPORT_SYMBOL_GPL(register_hotplug_dock_device);
567 * unregister_hotplug_dock_device - remove yourself from the hotplug list
568 * @handle: the acpi handle of the device
570 void unregister_hotplug_dock_device(acpi_handle handle)
572 struct dock_dependent_device *dd;
573 struct dock_station *dock_station;
575 if (!dock_station_count)
578 list_for_each_entry(dock_station, &dock_stations, sibling) {
579 dd = find_dock_dependent_device(dock_station, handle);
581 dock_release_hotplug(dd);
584 EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device);
587 * handle_eject_request - handle an undock request checking for error conditions
589 * Check to make sure the dock device is still present, then undock and
590 * hotremove all the devices that may need removing.
592 static int handle_eject_request(struct dock_station *ds, u32 event)
594 if (dock_in_progress(ds))
598 * here we need to generate the undock
599 * event prior to actually doing the undock
600 * so that the device struct still exists.
601 * Also, even send the dock event if the
602 * device is not present anymore
604 dock_event(ds, event, UNDOCK_EVENT);
606 hot_remove_dock_devices(ds);
608 acpi_evaluate_lck(ds->handle, 0);
609 acpi_evaluate_ej0(ds->handle);
610 if (dock_present(ds)) {
611 acpi_handle_err(ds->handle, "Unable to undock!\n");
619 * dock_notify - act upon an acpi dock notification
621 * @event: the acpi event
623 * If we are notified to dock, then check to see if the dock is
624 * present and then dock. Notify all drivers of the dock event,
625 * and then hotplug and devices that may need hotplugging.
627 static void dock_notify(struct dock_station *ds, u32 event)
629 acpi_handle handle = ds->handle;
630 struct acpi_device *ad;
631 int surprise_removal = 0;
634 * According to acpi spec 3.0a, if a DEVICE_CHECK notification
635 * is sent and _DCK is present, it is assumed to mean an undock
638 if ((ds->flags & DOCK_IS_DOCK) && event == ACPI_NOTIFY_DEVICE_CHECK)
639 event = ACPI_NOTIFY_EJECT_REQUEST;
642 * dock station: BUS_CHECK - docked or surprise removal
643 * DEVICE_CHECK - undocked
644 * other device: BUS_CHECK/DEVICE_CHECK - added or surprise removal
646 * To simplify event handling, dock dependent device handler always
647 * get ACPI_NOTIFY_BUS_CHECK/ACPI_NOTIFY_DEVICE_CHECK for add and
648 * ACPI_NOTIFY_EJECT_REQUEST for removal
651 case ACPI_NOTIFY_BUS_CHECK:
652 case ACPI_NOTIFY_DEVICE_CHECK:
653 if (!dock_in_progress(ds) && acpi_bus_get_device(handle, &ad)) {
656 if (!dock_present(ds)) {
657 acpi_handle_err(handle, "Unable to dock!\n");
661 atomic_notifier_call_chain(&dock_notifier_list,
663 hotplug_dock_devices(ds, event);
665 dock_event(ds, event, DOCK_EVENT);
666 acpi_evaluate_lck(ds->handle, 1);
667 acpi_update_all_gpes();
670 if (dock_present(ds) || dock_in_progress(ds))
672 /* This is a surprise removal */
673 surprise_removal = 1;
674 event = ACPI_NOTIFY_EJECT_REQUEST;
676 case ACPI_NOTIFY_EJECT_REQUEST:
678 if ((immediate_undock && !(ds->flags & DOCK_IS_ATA))
680 handle_eject_request(ds, event);
682 dock_event(ds, event, UNDOCK_EVENT);
685 acpi_handle_err(handle, "Unknown dock event %d\n", event);
690 struct dock_station *ds;
694 static void acpi_dock_deferred_cb(void *context)
696 struct dock_data *data = context;
698 acpi_scan_lock_acquire();
699 dock_notify(data->ds, data->event);
700 acpi_scan_lock_release();
704 static void dock_notify_handler(acpi_handle handle, u32 event, void *data)
706 struct dock_data *dd;
708 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK
709 && event != ACPI_NOTIFY_EJECT_REQUEST)
712 dd = kmalloc(sizeof(*dd), GFP_KERNEL);
718 status = acpi_os_hotplug_execute(acpi_dock_deferred_cb, dd);
719 if (ACPI_FAILURE(status))
725 * find_dock_devices - find devices on the dock station
726 * @handle: the handle of the device we are examining
728 * @context: the dock station private data
731 * This function is called by acpi_walk_namespace. It will
732 * check to see if an object has an _EJD method. If it does, then it
733 * will see if it is dependent on the dock station.
735 static acpi_status __init find_dock_devices(acpi_handle handle, u32 lvl,
736 void *context, void **rv)
738 struct dock_station *ds = context;
739 acpi_handle ejd = NULL;
741 acpi_bus_get_ejd(handle, &ejd);
742 if (ejd == ds->handle)
743 add_dock_dependent_device(ds, handle);
749 * show_docked - read method for "docked" file in sysfs
751 static ssize_t show_docked(struct device *dev,
752 struct device_attribute *attr, char *buf)
754 struct acpi_device *tmp;
756 struct dock_station *dock_station = dev->platform_data;
758 if (!acpi_bus_get_device(dock_station->handle, &tmp))
759 return snprintf(buf, PAGE_SIZE, "1\n");
760 return snprintf(buf, PAGE_SIZE, "0\n");
762 static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
765 * show_flags - read method for flags file in sysfs
767 static ssize_t show_flags(struct device *dev,
768 struct device_attribute *attr, char *buf)
770 struct dock_station *dock_station = dev->platform_data;
771 return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
774 static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
777 * write_undock - write method for "undock" file in sysfs
779 static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
780 const char *buf, size_t count)
783 struct dock_station *dock_station = dev->platform_data;
788 acpi_scan_lock_acquire();
789 begin_undock(dock_station);
790 ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
791 acpi_scan_lock_release();
792 return ret ? ret: count;
794 static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
797 * show_dock_uid - read method for "uid" file in sysfs
799 static ssize_t show_dock_uid(struct device *dev,
800 struct device_attribute *attr, char *buf)
802 unsigned long long lbuf;
803 struct dock_station *dock_station = dev->platform_data;
804 acpi_status status = acpi_evaluate_integer(dock_station->handle,
805 "_UID", NULL, &lbuf);
806 if (ACPI_FAILURE(status))
809 return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
811 static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
813 static ssize_t show_dock_type(struct device *dev,
814 struct device_attribute *attr, char *buf)
816 struct dock_station *dock_station = dev->platform_data;
819 if (dock_station->flags & DOCK_IS_DOCK)
820 type = "dock_station";
821 else if (dock_station->flags & DOCK_IS_ATA)
823 else if (dock_station->flags & DOCK_IS_BAT)
824 type = "battery_bay";
828 return snprintf(buf, PAGE_SIZE, "%s\n", type);
830 static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
832 static struct attribute *dock_attributes[] = {
833 &dev_attr_docked.attr,
834 &dev_attr_flags.attr,
835 &dev_attr_undock.attr,
841 static struct attribute_group dock_attribute_group = {
842 .attrs = dock_attributes
846 * dock_add - add a new dock station
847 * @handle: the dock station handle
849 * allocated and initialize a new dock station device. Find all devices
850 * that are on the dock station, and register for dock event notifications.
852 static int __init dock_add(acpi_handle handle)
855 struct dock_station ds, *dock_station;
856 struct platform_device *dd;
859 id = dock_station_count;
860 memset(&ds, 0, sizeof(ds));
861 dd = platform_device_register_data(NULL, "dock", id, &ds, sizeof(ds));
865 dock_station = dd->dev.platform_data;
867 dock_station->handle = handle;
868 dock_station->dock_device = dd;
869 dock_station->last_dock_time = jiffies - HZ;
871 INIT_LIST_HEAD(&dock_station->sibling);
872 INIT_LIST_HEAD(&dock_station->dependent_devices);
874 /* we want the dock device to send uevents */
875 dev_set_uevent_suppress(&dd->dev, 0);
877 if (acpi_dock_match(handle))
878 dock_station->flags |= DOCK_IS_DOCK;
879 if (acpi_ata_match(handle))
880 dock_station->flags |= DOCK_IS_ATA;
881 if (is_battery(handle))
882 dock_station->flags |= DOCK_IS_BAT;
884 ret = sysfs_create_group(&dd->dev.kobj, &dock_attribute_group);
888 /* Find dependent devices */
889 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
890 ACPI_UINT32_MAX, find_dock_devices, NULL,
893 /* add the dock station as a device dependent on itself */
894 ret = add_dock_dependent_device(dock_station, handle);
898 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
899 dock_notify_handler, dock_station);
900 if (ACPI_FAILURE(status))
903 dock_station_count++;
904 list_add(&dock_station->sibling, &dock_stations);
908 remove_dock_dependent_devices(dock_station);
909 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group);
911 platform_device_unregister(dd);
912 acpi_handle_err(handle, "%s encountered error %d\n", __func__, ret);
917 * find_dock_and_bay - look for dock stations and bays
918 * @handle: acpi handle of a device
923 * This is called by acpi_walk_namespace to look for dock stations and bays.
925 static __init acpi_status
926 find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
928 if (acpi_dock_match(handle) || is_ejectable_bay(handle))
934 void __init acpi_dock_init(void)
939 /* look for dock stations and bays */
940 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
941 ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL);
943 if (!dock_station_count) {
944 pr_info(PREFIX "No dock devices found.\n");
948 ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
949 pr_info(PREFIX "%s: %d docks/bays found\n",
950 ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count);