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);
133 if (WARN_ON(dd->hp_context)) {
138 dd->hp_context = context;
139 dd->hp_release = release;
143 mutex_unlock(&hotplug_lock);
148 * dock_release_hotplug - Decrement hotplug reference counter of dock device.
149 * @dd: Dock-dependent device.
151 * Decrement the reference counter of @dd and if 0, detach its hotplug
152 * operations from it, reset its context pointer and run the optional release
153 * routine if present.
155 static void dock_release_hotplug(struct dock_dependent_device *dd)
157 mutex_lock(&hotplug_lock);
158 if (dd->hp_context && !--dd->hp_refcount) {
159 void (*release)(void *) = dd->hp_release;
160 void *context = dd->hp_context;
163 dd->hp_context = NULL;
164 dd->hp_release = NULL;
168 mutex_unlock(&hotplug_lock);
171 static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event,
174 acpi_notify_handler cb = NULL;
177 mutex_lock(&hotplug_lock);
179 if (dd->hp_context) {
183 cb = uevent ? dd->hp_ops->uevent : dd->hp_ops->handler;
186 mutex_unlock(&hotplug_lock);
192 cb(dd->handle, event, dd->hp_context);
194 dock_release_hotplug(dd);
198 * find_dock_dependent_device - get a device dependent on this dock
199 * @ds: the dock station
200 * @handle: the acpi_handle of the device we want
202 * iterate over the dependent device list for this dock. If the
203 * dependent device matches the handle, return.
205 static struct dock_dependent_device *
206 find_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
208 struct dock_dependent_device *dd;
210 list_for_each_entry(dd, &ds->dependent_devices, list)
211 if (handle == dd->handle)
217 /*****************************************************************************
219 *****************************************************************************/
220 static int __init is_battery(acpi_handle handle)
222 struct acpi_device_info *info;
225 if (!ACPI_SUCCESS(acpi_get_object_info(handle, &info)))
227 if (!(info->valid & ACPI_VALID_HID))
230 ret = !strcmp("PNP0C0A", info->hardware_id.string);
236 /* Check whether ACPI object is an ejectable battery or disk bay */
237 static bool __init is_ejectable_bay(acpi_handle handle)
239 if (acpi_has_method(handle, "_EJ0") && is_battery(handle))
242 return acpi_bay_match(handle);
246 * is_dock_device - see if a device is on a dock station
247 * @handle: acpi handle of the device
249 * If this device is either the dock station itself,
250 * or is a device dependent on the dock station, then it
253 int is_dock_device(acpi_handle handle)
255 struct dock_station *dock_station;
257 if (!dock_station_count)
260 if (acpi_dock_match(handle))
263 list_for_each_entry(dock_station, &dock_stations, sibling)
264 if (find_dock_dependent_device(dock_station, handle))
269 EXPORT_SYMBOL_GPL(is_dock_device);
272 * dock_present - see if the dock station is present.
273 * @ds: the dock station
275 * execute the _STA method. note that present does not
276 * imply that we are docked.
278 static int dock_present(struct dock_station *ds)
280 unsigned long long sta;
284 status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta);
285 if (ACPI_SUCCESS(status) && sta)
292 * dock_create_acpi_device - add new devices to acpi
293 * @handle - handle of the device to add
295 * This function will create a new acpi_device for the given
296 * handle if one does not exist already. This should cause
297 * acpi to scan for drivers for the given devices, and call
298 * matching driver's add routine.
300 static void dock_create_acpi_device(acpi_handle handle)
302 struct acpi_device *device;
305 if (acpi_bus_get_device(handle, &device)) {
307 * no device created for this object,
308 * so we should create one.
310 ret = acpi_bus_scan(handle);
312 pr_debug("error adding bus, %x\n", -ret);
317 * dock_remove_acpi_device - remove the acpi_device struct from acpi
318 * @handle - the handle of the device to remove
320 * Tell acpi to remove the acpi_device. This should cause any loaded
321 * driver to have it's remove routine called.
323 static void dock_remove_acpi_device(acpi_handle handle)
325 struct acpi_device *device;
327 if (!acpi_bus_get_device(handle, &device))
328 acpi_bus_trim(device);
332 * hot_remove_dock_devices - Remove dock station devices.
335 static void hot_remove_dock_devices(struct dock_station *ds)
337 struct dock_dependent_device *dd;
340 * Walk the list in reverse order so that devices that have been added
341 * last are removed first (in case there are some indirect dependencies
344 list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
345 dock_hotplug_event(dd, ACPI_NOTIFY_EJECT_REQUEST, false);
347 list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
348 dock_remove_acpi_device(dd->handle);
352 * hotplug_dock_devices - Insert devices on a dock station.
353 * @ds: the dock station
354 * @event: either bus check or device check request
356 * Some devices on the dock station need to have drivers called
357 * to perform hotplug operations after a dock event has occurred.
358 * Traverse the list of dock devices that have registered a
359 * hotplug handler, and call the handler.
361 static void hotplug_dock_devices(struct dock_station *ds, u32 event)
363 struct dock_dependent_device *dd;
365 /* Call driver specific hotplug functions. */
366 list_for_each_entry(dd, &ds->dependent_devices, list)
367 dock_hotplug_event(dd, event, false);
370 * Now make sure that an acpi_device is created for each dependent
371 * device. That will cause scan handlers to be attached to device
372 * objects or acpi_drivers to be stopped/started if they are present.
374 list_for_each_entry(dd, &ds->dependent_devices, list)
375 dock_create_acpi_device(dd->handle);
378 static void dock_event(struct dock_station *ds, u32 event, int num)
380 struct device *dev = &ds->dock_device->dev;
381 char event_string[13];
382 char *envp[] = { event_string, NULL };
383 struct dock_dependent_device *dd;
385 if (num == UNDOCK_EVENT)
386 sprintf(event_string, "EVENT=undock");
388 sprintf(event_string, "EVENT=dock");
391 * Indicate that the status of the dock station has
394 if (num == DOCK_EVENT)
395 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
397 list_for_each_entry(dd, &ds->dependent_devices, list)
398 dock_hotplug_event(dd, event, true);
400 if (num != DOCK_EVENT)
401 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
405 * handle_dock - handle a dock event
406 * @ds: the dock station
407 * @dock: to dock, or undock - that is the question
409 * Execute the _DCK method in response to an acpi event
411 static void handle_dock(struct dock_station *ds, int dock)
414 struct acpi_object_list arg_list;
415 union acpi_object arg;
416 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
418 acpi_handle_info(ds->handle, "%s\n", dock ? "docking" : "undocking");
420 /* _DCK method has one argument */
422 arg_list.pointer = &arg;
423 arg.type = ACPI_TYPE_INTEGER;
424 arg.integer.value = dock;
425 status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer);
426 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
427 acpi_handle_err(ds->handle, "Failed to execute _DCK (0x%x)\n",
430 kfree(buffer.pointer);
433 static inline void dock(struct dock_station *ds)
438 static inline void undock(struct dock_station *ds)
443 static inline void begin_dock(struct dock_station *ds)
445 ds->flags |= DOCK_DOCKING;
448 static inline void complete_dock(struct dock_station *ds)
450 ds->flags &= ~(DOCK_DOCKING);
451 ds->last_dock_time = jiffies;
454 static inline void begin_undock(struct dock_station *ds)
456 ds->flags |= DOCK_UNDOCKING;
459 static inline void complete_undock(struct dock_station *ds)
461 ds->flags &= ~(DOCK_UNDOCKING);
465 * dock_in_progress - see if we are in the middle of handling a dock event
466 * @ds: the dock station
468 * Sometimes while docking, false dock events can be sent to the driver
469 * because good connections aren't made or some other reason. Ignore these
470 * if we are in the middle of doing something.
472 static int dock_in_progress(struct dock_station *ds)
474 if ((ds->flags & DOCK_DOCKING) ||
475 time_before(jiffies, (ds->last_dock_time + HZ)))
481 * register_dock_notifier - add yourself to the dock notifier list
482 * @nb: the callers notifier block
484 * If a driver wishes to be notified about dock events, they can
485 * use this function to put a notifier block on the dock notifier list.
486 * this notifier call chain will be called after a dock event, but
487 * before hotplugging any new devices.
489 int register_dock_notifier(struct notifier_block *nb)
491 if (!dock_station_count)
494 return atomic_notifier_chain_register(&dock_notifier_list, nb);
496 EXPORT_SYMBOL_GPL(register_dock_notifier);
499 * unregister_dock_notifier - remove yourself from the dock notifier list
500 * @nb: the callers notifier block
502 void unregister_dock_notifier(struct notifier_block *nb)
504 if (!dock_station_count)
507 atomic_notifier_chain_unregister(&dock_notifier_list, nb);
509 EXPORT_SYMBOL_GPL(unregister_dock_notifier);
512 * register_hotplug_dock_device - register a hotplug function
513 * @handle: the handle of the device
514 * @ops: handlers to call after docking
515 * @context: device specific data
516 * @init: Optional initialization routine to run after registration
517 * @release: Optional release routine to run on unregistration
519 * If a driver would like to perform a hotplug operation after a dock
520 * event, they can register an acpi_notifiy_handler to be called by
521 * the dock driver after _DCK is executed.
523 int register_hotplug_dock_device(acpi_handle handle,
524 const struct acpi_dock_ops *ops, void *context,
525 void (*init)(void *), void (*release)(void *))
527 struct dock_dependent_device *dd;
528 struct dock_station *dock_station;
531 if (WARN_ON(!context))
534 if (!dock_station_count)
538 * make sure this handle is for a device dependent on the dock,
539 * this would include the dock station itself
541 list_for_each_entry(dock_station, &dock_stations, sibling) {
543 * An ATA bay can be in a dock and itself can be ejected
544 * separately, so there are two 'dock stations' which need the
547 dd = find_dock_dependent_device(dock_station, handle);
548 if (dd && !dock_init_hotplug(dd, ops, context, init, release))
554 EXPORT_SYMBOL_GPL(register_hotplug_dock_device);
557 * unregister_hotplug_dock_device - remove yourself from the hotplug list
558 * @handle: the acpi handle of the device
560 void unregister_hotplug_dock_device(acpi_handle handle)
562 struct dock_dependent_device *dd;
563 struct dock_station *dock_station;
565 if (!dock_station_count)
568 list_for_each_entry(dock_station, &dock_stations, sibling) {
569 dd = find_dock_dependent_device(dock_station, handle);
571 dock_release_hotplug(dd);
574 EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device);
577 * handle_eject_request - handle an undock request checking for error conditions
579 * Check to make sure the dock device is still present, then undock and
580 * hotremove all the devices that may need removing.
582 static int handle_eject_request(struct dock_station *ds, u32 event)
584 if (dock_in_progress(ds))
588 * here we need to generate the undock
589 * event prior to actually doing the undock
590 * so that the device struct still exists.
591 * Also, even send the dock event if the
592 * device is not present anymore
594 dock_event(ds, event, UNDOCK_EVENT);
596 hot_remove_dock_devices(ds);
598 acpi_evaluate_lck(ds->handle, 0);
599 acpi_evaluate_ej0(ds->handle);
600 if (dock_present(ds)) {
601 acpi_handle_err(ds->handle, "Unable to undock!\n");
609 * dock_notify - act upon an acpi dock notification
610 * @handle: the dock station handle
611 * @event: the acpi event
612 * @data: our driver data struct
614 * If we are notified to dock, then check to see if the dock is
615 * present and then dock. Notify all drivers of the dock event,
616 * and then hotplug and devices that may need hotplugging.
618 static void dock_notify(acpi_handle handle, u32 event, void *data)
620 struct dock_station *ds = data;
621 struct acpi_device *tmp;
622 int surprise_removal = 0;
625 * According to acpi spec 3.0a, if a DEVICE_CHECK notification
626 * is sent and _DCK is present, it is assumed to mean an undock
629 if ((ds->flags & DOCK_IS_DOCK) && event == ACPI_NOTIFY_DEVICE_CHECK)
630 event = ACPI_NOTIFY_EJECT_REQUEST;
633 * dock station: BUS_CHECK - docked or surprise removal
634 * DEVICE_CHECK - undocked
635 * other device: BUS_CHECK/DEVICE_CHECK - added or surprise removal
637 * To simplify event handling, dock dependent device handler always
638 * get ACPI_NOTIFY_BUS_CHECK/ACPI_NOTIFY_DEVICE_CHECK for add and
639 * ACPI_NOTIFY_EJECT_REQUEST for removal
642 case ACPI_NOTIFY_BUS_CHECK:
643 case ACPI_NOTIFY_DEVICE_CHECK:
644 if (!dock_in_progress(ds) && acpi_bus_get_device(ds->handle,
648 if (!dock_present(ds)) {
649 acpi_handle_err(handle, "Unable to dock!\n");
653 atomic_notifier_call_chain(&dock_notifier_list,
655 hotplug_dock_devices(ds, event);
657 dock_event(ds, event, DOCK_EVENT);
658 acpi_evaluate_lck(ds->handle, 1);
659 acpi_update_all_gpes();
662 if (dock_present(ds) || dock_in_progress(ds))
664 /* This is a surprise removal */
665 surprise_removal = 1;
666 event = ACPI_NOTIFY_EJECT_REQUEST;
668 case ACPI_NOTIFY_EJECT_REQUEST:
670 if ((immediate_undock && !(ds->flags & DOCK_IS_ATA))
672 handle_eject_request(ds, event);
674 dock_event(ds, event, UNDOCK_EVENT);
677 acpi_handle_err(handle, "Unknown dock event %d\n", event);
684 struct dock_station *ds;
687 static void acpi_dock_deferred_cb(void *context)
689 struct dock_data *data = context;
691 acpi_scan_lock_acquire();
692 dock_notify(data->handle, data->event, data->ds);
693 acpi_scan_lock_release();
697 static int acpi_dock_notifier_call(struct notifier_block *this,
698 unsigned long event, void *data)
700 struct dock_station *dock_station;
701 acpi_handle handle = data;
703 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK
704 && event != ACPI_NOTIFY_EJECT_REQUEST)
707 acpi_scan_lock_acquire();
709 list_for_each_entry(dock_station, &dock_stations, sibling) {
710 if (dock_station->handle == handle) {
711 struct dock_data *dd;
714 dd = kmalloc(sizeof(*dd), GFP_KERNEL);
720 dd->ds = dock_station;
721 status = acpi_os_hotplug_execute(acpi_dock_deferred_cb,
723 if (ACPI_FAILURE(status))
730 acpi_scan_lock_release();
734 static struct notifier_block dock_acpi_notifier = {
735 .notifier_call = acpi_dock_notifier_call,
739 * find_dock_devices - find devices on the dock station
740 * @handle: the handle of the device we are examining
742 * @context: the dock station private data
745 * This function is called by acpi_walk_namespace. It will
746 * check to see if an object has an _EJD method. If it does, then it
747 * will see if it is dependent on the dock station.
749 static acpi_status __init find_dock_devices(acpi_handle handle, u32 lvl,
750 void *context, void **rv)
752 struct dock_station *ds = context;
753 acpi_handle ejd = NULL;
755 acpi_bus_get_ejd(handle, &ejd);
756 if (ejd == ds->handle)
757 add_dock_dependent_device(ds, handle);
763 * show_docked - read method for "docked" file in sysfs
765 static ssize_t show_docked(struct device *dev,
766 struct device_attribute *attr, char *buf)
768 struct acpi_device *tmp;
770 struct dock_station *dock_station = dev->platform_data;
772 if (!acpi_bus_get_device(dock_station->handle, &tmp))
773 return snprintf(buf, PAGE_SIZE, "1\n");
774 return snprintf(buf, PAGE_SIZE, "0\n");
776 static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
779 * show_flags - read method for flags file in sysfs
781 static ssize_t show_flags(struct device *dev,
782 struct device_attribute *attr, char *buf)
784 struct dock_station *dock_station = dev->platform_data;
785 return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
788 static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
791 * write_undock - write method for "undock" file in sysfs
793 static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
794 const char *buf, size_t count)
797 struct dock_station *dock_station = dev->platform_data;
802 acpi_scan_lock_acquire();
803 begin_undock(dock_station);
804 ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
805 acpi_scan_lock_release();
806 return ret ? ret: count;
808 static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
811 * show_dock_uid - read method for "uid" file in sysfs
813 static ssize_t show_dock_uid(struct device *dev,
814 struct device_attribute *attr, char *buf)
816 unsigned long long lbuf;
817 struct dock_station *dock_station = dev->platform_data;
818 acpi_status status = acpi_evaluate_integer(dock_station->handle,
819 "_UID", NULL, &lbuf);
820 if (ACPI_FAILURE(status))
823 return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
825 static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
827 static ssize_t show_dock_type(struct device *dev,
828 struct device_attribute *attr, char *buf)
830 struct dock_station *dock_station = dev->platform_data;
833 if (dock_station->flags & DOCK_IS_DOCK)
834 type = "dock_station";
835 else if (dock_station->flags & DOCK_IS_ATA)
837 else if (dock_station->flags & DOCK_IS_BAT)
838 type = "battery_bay";
842 return snprintf(buf, PAGE_SIZE, "%s\n", type);
844 static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
846 static struct attribute *dock_attributes[] = {
847 &dev_attr_docked.attr,
848 &dev_attr_flags.attr,
849 &dev_attr_undock.attr,
855 static struct attribute_group dock_attribute_group = {
856 .attrs = dock_attributes
860 * dock_add - add a new dock station
861 * @handle: the dock station handle
863 * allocated and initialize a new dock station device. Find all devices
864 * that are on the dock station, and register for dock event notifications.
866 static int __init dock_add(acpi_handle handle)
869 struct dock_station ds, *dock_station;
870 struct platform_device *dd;
872 id = dock_station_count;
873 memset(&ds, 0, sizeof(ds));
874 dd = platform_device_register_data(NULL, "dock", id, &ds, sizeof(ds));
878 dock_station = dd->dev.platform_data;
880 dock_station->handle = handle;
881 dock_station->dock_device = dd;
882 dock_station->last_dock_time = jiffies - HZ;
884 INIT_LIST_HEAD(&dock_station->sibling);
885 INIT_LIST_HEAD(&dock_station->dependent_devices);
887 /* we want the dock device to send uevents */
888 dev_set_uevent_suppress(&dd->dev, 0);
890 if (acpi_dock_match(handle))
891 dock_station->flags |= DOCK_IS_DOCK;
892 if (acpi_ata_match(handle))
893 dock_station->flags |= DOCK_IS_ATA;
894 if (is_battery(handle))
895 dock_station->flags |= DOCK_IS_BAT;
897 ret = sysfs_create_group(&dd->dev.kobj, &dock_attribute_group);
901 /* Find dependent devices */
902 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
903 ACPI_UINT32_MAX, find_dock_devices, NULL,
906 /* add the dock station as a device dependent on itself */
907 ret = add_dock_dependent_device(dock_station, handle);
911 dock_station_count++;
912 list_add(&dock_station->sibling, &dock_stations);
916 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group);
918 platform_device_unregister(dd);
919 acpi_handle_err(handle, "%s encountered error %d\n", __func__, ret);
924 * find_dock_and_bay - look for dock stations and bays
925 * @handle: acpi handle of a device
930 * This is called by acpi_walk_namespace to look for dock stations and bays.
932 static __init acpi_status
933 find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
935 if (acpi_dock_match(handle) || is_ejectable_bay(handle))
941 void __init acpi_dock_init(void)
946 /* look for dock stations and bays */
947 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
948 ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL);
950 if (!dock_station_count) {
951 pr_info(PREFIX "No dock devices found.\n");
955 ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
956 register_acpi_bus_notifier(&dock_acpi_notifier);
957 pr_info(PREFIX "%s: %d docks/bays found\n",
958 ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count);