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);
119 * dock_init_hotplug - Initialize a hotplug device on a docking station.
120 * @dd: Dock-dependent device.
121 * @ops: Dock operations to attach to the dependent device.
122 * @context: Data to pass to the @ops callbacks and @release.
123 * @init: Optional initialization routine to run after setting up context.
124 * @release: Optional release routine to run on removal.
126 static int dock_init_hotplug(struct dock_dependent_device *dd,
127 const struct acpi_dock_ops *ops, void *context,
128 void (*init)(void *), void (*release)(void *))
132 mutex_lock(&hotplug_lock);
134 if (dd->hp_context) {
139 dd->hp_context = context;
140 dd->hp_release = release;
143 if (!WARN_ON(ret) && init)
146 mutex_unlock(&hotplug_lock);
151 * dock_release_hotplug - Decrement hotplug reference counter of dock device.
152 * @dd: Dock-dependent device.
154 * Decrement the reference counter of @dd and if 0, detach its hotplug
155 * operations from it, reset its context pointer and run the optional release
156 * routine if present.
158 static void dock_release_hotplug(struct dock_dependent_device *dd)
160 void (*release)(void *) = NULL;
161 void *context = NULL;
163 mutex_lock(&hotplug_lock);
165 if (dd->hp_context && !--dd->hp_refcount) {
167 context = dd->hp_context;
168 dd->hp_context = NULL;
169 release = dd->hp_release;
170 dd->hp_release = NULL;
173 if (release && context)
176 mutex_unlock(&hotplug_lock);
179 static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event,
182 acpi_notify_handler cb = NULL;
185 mutex_lock(&hotplug_lock);
187 if (dd->hp_context) {
191 cb = uevent ? dd->hp_ops->uevent : dd->hp_ops->handler;
194 mutex_unlock(&hotplug_lock);
200 cb(dd->handle, event, dd->hp_context);
202 dock_release_hotplug(dd);
206 * find_dock_dependent_device - get a device dependent on this dock
207 * @ds: the dock station
208 * @handle: the acpi_handle of the device we want
210 * iterate over the dependent device list for this dock. If the
211 * dependent device matches the handle, return.
213 static struct dock_dependent_device *
214 find_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
216 struct dock_dependent_device *dd;
218 list_for_each_entry(dd, &ds->dependent_devices, list)
219 if (handle == dd->handle)
225 /*****************************************************************************
227 *****************************************************************************/
228 static int __init is_battery(acpi_handle handle)
230 struct acpi_device_info *info;
233 if (!ACPI_SUCCESS(acpi_get_object_info(handle, &info)))
235 if (!(info->valid & ACPI_VALID_HID))
238 ret = !strcmp("PNP0C0A", info->hardware_id.string);
244 /* Check whether ACPI object is an ejectable battery or disk bay */
245 static bool __init is_ejectable_bay(acpi_handle handle)
247 if (acpi_has_method(handle, "_EJ0") && is_battery(handle))
250 return acpi_bay_match(handle);
254 * is_dock_device - see if a device is on a dock station
255 * @handle: acpi handle of the device
257 * If this device is either the dock station itself,
258 * or is a device dependent on the dock station, then it
261 int is_dock_device(acpi_handle handle)
263 struct dock_station *dock_station;
265 if (!dock_station_count)
268 if (acpi_dock_match(handle))
271 list_for_each_entry(dock_station, &dock_stations, sibling)
272 if (find_dock_dependent_device(dock_station, handle))
277 EXPORT_SYMBOL_GPL(is_dock_device);
280 * dock_present - see if the dock station is present.
281 * @ds: the dock station
283 * execute the _STA method. note that present does not
284 * imply that we are docked.
286 static int dock_present(struct dock_station *ds)
288 unsigned long long sta;
292 status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta);
293 if (ACPI_SUCCESS(status) && sta)
300 * dock_create_acpi_device - add new devices to acpi
301 * @handle - handle of the device to add
303 * This function will create a new acpi_device for the given
304 * handle if one does not exist already. This should cause
305 * acpi to scan for drivers for the given devices, and call
306 * matching driver's add routine.
308 static void dock_create_acpi_device(acpi_handle handle)
310 struct acpi_device *device;
313 if (acpi_bus_get_device(handle, &device)) {
315 * no device created for this object,
316 * so we should create one.
318 ret = acpi_bus_scan(handle);
320 pr_debug("error adding bus, %x\n", -ret);
325 * dock_remove_acpi_device - remove the acpi_device struct from acpi
326 * @handle - the handle of the device to remove
328 * Tell acpi to remove the acpi_device. This should cause any loaded
329 * driver to have it's remove routine called.
331 static void dock_remove_acpi_device(acpi_handle handle)
333 struct acpi_device *device;
335 if (!acpi_bus_get_device(handle, &device))
336 acpi_bus_trim(device);
340 * hot_remove_dock_devices - Remove dock station devices.
343 static void hot_remove_dock_devices(struct dock_station *ds)
345 struct dock_dependent_device *dd;
348 * Walk the list in reverse order so that devices that have been added
349 * last are removed first (in case there are some indirect dependencies
352 list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
353 dock_hotplug_event(dd, ACPI_NOTIFY_EJECT_REQUEST, false);
355 list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
356 dock_remove_acpi_device(dd->handle);
360 * hotplug_dock_devices - Insert devices on a dock station.
361 * @ds: the dock station
362 * @event: either bus check or device check request
364 * Some devices on the dock station need to have drivers called
365 * to perform hotplug operations after a dock event has occurred.
366 * Traverse the list of dock devices that have registered a
367 * hotplug handler, and call the handler.
369 static void hotplug_dock_devices(struct dock_station *ds, u32 event)
371 struct dock_dependent_device *dd;
373 /* Call driver specific hotplug functions. */
374 list_for_each_entry(dd, &ds->dependent_devices, list)
375 dock_hotplug_event(dd, event, false);
378 * Now make sure that an acpi_device is created for each dependent
379 * device. That will cause scan handlers to be attached to device
380 * objects or acpi_drivers to be stopped/started if they are present.
382 list_for_each_entry(dd, &ds->dependent_devices, list)
383 dock_create_acpi_device(dd->handle);
386 static void dock_event(struct dock_station *ds, u32 event, int num)
388 struct device *dev = &ds->dock_device->dev;
389 char event_string[13];
390 char *envp[] = { event_string, NULL };
391 struct dock_dependent_device *dd;
393 if (num == UNDOCK_EVENT)
394 sprintf(event_string, "EVENT=undock");
396 sprintf(event_string, "EVENT=dock");
399 * Indicate that the status of the dock station has
402 if (num == DOCK_EVENT)
403 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
405 list_for_each_entry(dd, &ds->dependent_devices, list)
406 dock_hotplug_event(dd, event, true);
408 if (num != DOCK_EVENT)
409 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
413 * handle_dock - handle a dock event
414 * @ds: the dock station
415 * @dock: to dock, or undock - that is the question
417 * Execute the _DCK method in response to an acpi event
419 static void handle_dock(struct dock_station *ds, int dock)
422 struct acpi_object_list arg_list;
423 union acpi_object arg;
424 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
426 acpi_handle_info(ds->handle, "%s\n", dock ? "docking" : "undocking");
428 /* _DCK method has one argument */
430 arg_list.pointer = &arg;
431 arg.type = ACPI_TYPE_INTEGER;
432 arg.integer.value = dock;
433 status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer);
434 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
435 acpi_handle_err(ds->handle, "Failed to execute _DCK (0x%x)\n",
438 kfree(buffer.pointer);
441 static inline void dock(struct dock_station *ds)
446 static inline void undock(struct dock_station *ds)
451 static inline void begin_dock(struct dock_station *ds)
453 ds->flags |= DOCK_DOCKING;
456 static inline void complete_dock(struct dock_station *ds)
458 ds->flags &= ~(DOCK_DOCKING);
459 ds->last_dock_time = jiffies;
462 static inline void begin_undock(struct dock_station *ds)
464 ds->flags |= DOCK_UNDOCKING;
467 static inline void complete_undock(struct dock_station *ds)
469 ds->flags &= ~(DOCK_UNDOCKING);
473 * dock_in_progress - see if we are in the middle of handling a dock event
474 * @ds: the dock station
476 * Sometimes while docking, false dock events can be sent to the driver
477 * because good connections aren't made or some other reason. Ignore these
478 * if we are in the middle of doing something.
480 static int dock_in_progress(struct dock_station *ds)
482 if ((ds->flags & DOCK_DOCKING) ||
483 time_before(jiffies, (ds->last_dock_time + HZ)))
489 * register_dock_notifier - add yourself to the dock notifier list
490 * @nb: the callers notifier block
492 * If a driver wishes to be notified about dock events, they can
493 * use this function to put a notifier block on the dock notifier list.
494 * this notifier call chain will be called after a dock event, but
495 * before hotplugging any new devices.
497 int register_dock_notifier(struct notifier_block *nb)
499 if (!dock_station_count)
502 return atomic_notifier_chain_register(&dock_notifier_list, nb);
504 EXPORT_SYMBOL_GPL(register_dock_notifier);
507 * unregister_dock_notifier - remove yourself from the dock notifier list
508 * @nb: the callers notifier block
510 void unregister_dock_notifier(struct notifier_block *nb)
512 if (!dock_station_count)
515 atomic_notifier_chain_unregister(&dock_notifier_list, nb);
517 EXPORT_SYMBOL_GPL(unregister_dock_notifier);
520 * register_hotplug_dock_device - register a hotplug function
521 * @handle: the handle of the device
522 * @ops: handlers to call after docking
523 * @context: device specific data
524 * @init: Optional initialization routine to run after registration
525 * @release: Optional release routine to run on unregistration
527 * If a driver would like to perform a hotplug operation after a dock
528 * event, they can register an acpi_notifiy_handler to be called by
529 * the dock driver after _DCK is executed.
531 int register_hotplug_dock_device(acpi_handle handle,
532 const struct acpi_dock_ops *ops, void *context,
533 void (*init)(void *), void (*release)(void *))
535 struct dock_dependent_device *dd;
536 struct dock_station *dock_station;
539 if (WARN_ON(!context))
542 if (!dock_station_count)
546 * make sure this handle is for a device dependent on the dock,
547 * this would include the dock station itself
549 list_for_each_entry(dock_station, &dock_stations, sibling) {
551 * An ATA bay can be in a dock and itself can be ejected
552 * separately, so there are two 'dock stations' which need the
555 dd = find_dock_dependent_device(dock_station, handle);
556 if (dd && !dock_init_hotplug(dd, ops, context, init, release))
562 EXPORT_SYMBOL_GPL(register_hotplug_dock_device);
565 * unregister_hotplug_dock_device - remove yourself from the hotplug list
566 * @handle: the acpi handle of the device
568 void unregister_hotplug_dock_device(acpi_handle handle)
570 struct dock_dependent_device *dd;
571 struct dock_station *dock_station;
573 if (!dock_station_count)
576 list_for_each_entry(dock_station, &dock_stations, sibling) {
577 dd = find_dock_dependent_device(dock_station, handle);
579 dock_release_hotplug(dd);
582 EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device);
585 * handle_eject_request - handle an undock request checking for error conditions
587 * Check to make sure the dock device is still present, then undock and
588 * hotremove all the devices that may need removing.
590 static int handle_eject_request(struct dock_station *ds, u32 event)
592 if (dock_in_progress(ds))
596 * here we need to generate the undock
597 * event prior to actually doing the undock
598 * so that the device struct still exists.
599 * Also, even send the dock event if the
600 * device is not present anymore
602 dock_event(ds, event, UNDOCK_EVENT);
604 hot_remove_dock_devices(ds);
606 acpi_evaluate_lck(ds->handle, 0);
607 acpi_evaluate_ej0(ds->handle);
608 if (dock_present(ds)) {
609 acpi_handle_err(ds->handle, "Unable to undock!\n");
617 * dock_notify - act upon an acpi dock notification
618 * @handle: the dock station handle
619 * @event: the acpi event
620 * @data: our driver data struct
622 * If we are notified to dock, then check to see if the dock is
623 * present and then dock. Notify all drivers of the dock event,
624 * and then hotplug and devices that may need hotplugging.
626 static void dock_notify(acpi_handle handle, u32 event, void *data)
628 struct dock_station *ds = data;
629 struct acpi_device *tmp;
630 int surprise_removal = 0;
633 * According to acpi spec 3.0a, if a DEVICE_CHECK notification
634 * is sent and _DCK is present, it is assumed to mean an undock
637 if ((ds->flags & DOCK_IS_DOCK) && event == ACPI_NOTIFY_DEVICE_CHECK)
638 event = ACPI_NOTIFY_EJECT_REQUEST;
641 * dock station: BUS_CHECK - docked or surprise removal
642 * DEVICE_CHECK - undocked
643 * other device: BUS_CHECK/DEVICE_CHECK - added or surprise removal
645 * To simplify event handling, dock dependent device handler always
646 * get ACPI_NOTIFY_BUS_CHECK/ACPI_NOTIFY_DEVICE_CHECK for add and
647 * ACPI_NOTIFY_EJECT_REQUEST for removal
650 case ACPI_NOTIFY_BUS_CHECK:
651 case ACPI_NOTIFY_DEVICE_CHECK:
652 if (!dock_in_progress(ds) && acpi_bus_get_device(ds->handle,
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);
692 struct dock_station *ds;
695 static void acpi_dock_deferred_cb(void *context)
697 struct dock_data *data = context;
699 acpi_scan_lock_acquire();
700 dock_notify(data->handle, data->event, data->ds);
701 acpi_scan_lock_release();
705 static int acpi_dock_notifier_call(struct notifier_block *this,
706 unsigned long event, void *data)
708 struct dock_station *dock_station;
709 acpi_handle handle = data;
711 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK
712 && event != ACPI_NOTIFY_EJECT_REQUEST)
715 acpi_scan_lock_acquire();
717 list_for_each_entry(dock_station, &dock_stations, sibling) {
718 if (dock_station->handle == handle) {
719 struct dock_data *dd;
722 dd = kmalloc(sizeof(*dd), GFP_KERNEL);
728 dd->ds = dock_station;
729 status = acpi_os_hotplug_execute(acpi_dock_deferred_cb,
731 if (ACPI_FAILURE(status))
738 acpi_scan_lock_release();
742 static struct notifier_block dock_acpi_notifier = {
743 .notifier_call = acpi_dock_notifier_call,
747 * find_dock_devices - find devices on the dock station
748 * @handle: the handle of the device we are examining
750 * @context: the dock station private data
753 * This function is called by acpi_walk_namespace. It will
754 * check to see if an object has an _EJD method. If it does, then it
755 * will see if it is dependent on the dock station.
757 static acpi_status __init find_dock_devices(acpi_handle handle, u32 lvl,
758 void *context, void **rv)
760 struct dock_station *ds = context;
761 acpi_handle ejd = NULL;
763 acpi_bus_get_ejd(handle, &ejd);
764 if (ejd == ds->handle)
765 add_dock_dependent_device(ds, handle);
771 * show_docked - read method for "docked" file in sysfs
773 static ssize_t show_docked(struct device *dev,
774 struct device_attribute *attr, char *buf)
776 struct acpi_device *tmp;
778 struct dock_station *dock_station = dev->platform_data;
780 if (!acpi_bus_get_device(dock_station->handle, &tmp))
781 return snprintf(buf, PAGE_SIZE, "1\n");
782 return snprintf(buf, PAGE_SIZE, "0\n");
784 static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
787 * show_flags - read method for flags file in sysfs
789 static ssize_t show_flags(struct device *dev,
790 struct device_attribute *attr, char *buf)
792 struct dock_station *dock_station = dev->platform_data;
793 return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
796 static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
799 * write_undock - write method for "undock" file in sysfs
801 static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
802 const char *buf, size_t count)
805 struct dock_station *dock_station = dev->platform_data;
810 acpi_scan_lock_acquire();
811 begin_undock(dock_station);
812 ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
813 acpi_scan_lock_release();
814 return ret ? ret: count;
816 static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
819 * show_dock_uid - read method for "uid" file in sysfs
821 static ssize_t show_dock_uid(struct device *dev,
822 struct device_attribute *attr, char *buf)
824 unsigned long long lbuf;
825 struct dock_station *dock_station = dev->platform_data;
826 acpi_status status = acpi_evaluate_integer(dock_station->handle,
827 "_UID", NULL, &lbuf);
828 if (ACPI_FAILURE(status))
831 return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
833 static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
835 static ssize_t show_dock_type(struct device *dev,
836 struct device_attribute *attr, char *buf)
838 struct dock_station *dock_station = dev->platform_data;
841 if (dock_station->flags & DOCK_IS_DOCK)
842 type = "dock_station";
843 else if (dock_station->flags & DOCK_IS_ATA)
845 else if (dock_station->flags & DOCK_IS_BAT)
846 type = "battery_bay";
850 return snprintf(buf, PAGE_SIZE, "%s\n", type);
852 static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
854 static struct attribute *dock_attributes[] = {
855 &dev_attr_docked.attr,
856 &dev_attr_flags.attr,
857 &dev_attr_undock.attr,
863 static struct attribute_group dock_attribute_group = {
864 .attrs = dock_attributes
868 * dock_add - add a new dock station
869 * @handle: the dock station handle
871 * allocated and initialize a new dock station device. Find all devices
872 * that are on the dock station, and register for dock event notifications.
874 static int __init dock_add(acpi_handle handle)
877 struct dock_station ds, *dock_station;
878 struct platform_device *dd;
880 id = dock_station_count;
881 memset(&ds, 0, sizeof(ds));
882 dd = platform_device_register_data(NULL, "dock", id, &ds, sizeof(ds));
886 dock_station = dd->dev.platform_data;
888 dock_station->handle = handle;
889 dock_station->dock_device = dd;
890 dock_station->last_dock_time = jiffies - HZ;
892 INIT_LIST_HEAD(&dock_station->sibling);
893 INIT_LIST_HEAD(&dock_station->dependent_devices);
895 /* we want the dock device to send uevents */
896 dev_set_uevent_suppress(&dd->dev, 0);
898 if (acpi_dock_match(handle))
899 dock_station->flags |= DOCK_IS_DOCK;
900 if (acpi_ata_match(handle))
901 dock_station->flags |= DOCK_IS_ATA;
902 if (is_battery(handle))
903 dock_station->flags |= DOCK_IS_BAT;
905 ret = sysfs_create_group(&dd->dev.kobj, &dock_attribute_group);
909 /* Find dependent devices */
910 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
911 ACPI_UINT32_MAX, find_dock_devices, NULL,
914 /* add the dock station as a device dependent on itself */
915 ret = add_dock_dependent_device(dock_station, handle);
919 dock_station_count++;
920 list_add(&dock_station->sibling, &dock_stations);
924 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group);
926 platform_device_unregister(dd);
927 acpi_handle_err(handle, "%s encountered error %d\n", __func__, ret);
932 * find_dock_and_bay - look for dock stations and bays
933 * @handle: acpi handle of a device
938 * This is called by acpi_walk_namespace to look for dock stations and bays.
940 static __init acpi_status
941 find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
943 if (acpi_dock_match(handle) || is_ejectable_bay(handle))
949 void __init acpi_dock_init(void)
954 /* look for dock stations and bays */
955 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
956 ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL);
958 if (!dock_station_count) {
959 pr_info(PREFIX "No dock devices found.\n");
963 ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
964 register_acpi_bus_notifier(&dock_acpi_notifier);
965 pr_info(PREFIX "%s: %d docks/bays found\n",
966 ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count);