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 * hotplug_dock_devices - insert or remove devices on the dock station
341 * @ds: the dock station
342 * @event: either bus check or eject request
344 * Some devices on the dock station need to have drivers called
345 * to perform hotplug operations after a dock event has occurred.
346 * Traverse the list of dock devices that have registered a
347 * hotplug handler, and call the handler.
349 static void hotplug_dock_devices(struct dock_station *ds, u32 event)
351 struct dock_dependent_device *dd;
354 * First call driver specific hotplug functions
356 list_for_each_entry(dd, &ds->dependent_devices, list)
357 dock_hotplug_event(dd, event, false);
360 * Now make sure that an acpi_device is created for each
361 * dependent device, or removed if this is an eject request.
362 * This will cause acpi_drivers to be stopped/started if they
365 list_for_each_entry(dd, &ds->dependent_devices, list) {
366 if (event == ACPI_NOTIFY_EJECT_REQUEST)
367 dock_remove_acpi_device(dd->handle);
369 dock_create_acpi_device(dd->handle);
373 static void dock_event(struct dock_station *ds, u32 event, int num)
375 struct device *dev = &ds->dock_device->dev;
376 char event_string[13];
377 char *envp[] = { event_string, NULL };
378 struct dock_dependent_device *dd;
380 if (num == UNDOCK_EVENT)
381 sprintf(event_string, "EVENT=undock");
383 sprintf(event_string, "EVENT=dock");
386 * Indicate that the status of the dock station has
389 if (num == DOCK_EVENT)
390 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
392 list_for_each_entry(dd, &ds->dependent_devices, list)
393 dock_hotplug_event(dd, event, true);
395 if (num != DOCK_EVENT)
396 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
400 * handle_dock - handle a dock event
401 * @ds: the dock station
402 * @dock: to dock, or undock - that is the question
404 * Execute the _DCK method in response to an acpi event
406 static void handle_dock(struct dock_station *ds, int dock)
409 struct acpi_object_list arg_list;
410 union acpi_object arg;
411 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
413 acpi_handle_info(ds->handle, "%s\n", dock ? "docking" : "undocking");
415 /* _DCK method has one argument */
417 arg_list.pointer = &arg;
418 arg.type = ACPI_TYPE_INTEGER;
419 arg.integer.value = dock;
420 status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer);
421 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
422 acpi_handle_err(ds->handle, "Failed to execute _DCK (0x%x)\n",
425 kfree(buffer.pointer);
428 static inline void dock(struct dock_station *ds)
433 static inline void undock(struct dock_station *ds)
438 static inline void begin_dock(struct dock_station *ds)
440 ds->flags |= DOCK_DOCKING;
443 static inline void complete_dock(struct dock_station *ds)
445 ds->flags &= ~(DOCK_DOCKING);
446 ds->last_dock_time = jiffies;
449 static inline void begin_undock(struct dock_station *ds)
451 ds->flags |= DOCK_UNDOCKING;
454 static inline void complete_undock(struct dock_station *ds)
456 ds->flags &= ~(DOCK_UNDOCKING);
460 * dock_in_progress - see if we are in the middle of handling a dock event
461 * @ds: the dock station
463 * Sometimes while docking, false dock events can be sent to the driver
464 * because good connections aren't made or some other reason. Ignore these
465 * if we are in the middle of doing something.
467 static int dock_in_progress(struct dock_station *ds)
469 if ((ds->flags & DOCK_DOCKING) ||
470 time_before(jiffies, (ds->last_dock_time + HZ)))
476 * register_dock_notifier - add yourself to the dock notifier list
477 * @nb: the callers notifier block
479 * If a driver wishes to be notified about dock events, they can
480 * use this function to put a notifier block on the dock notifier list.
481 * this notifier call chain will be called after a dock event, but
482 * before hotplugging any new devices.
484 int register_dock_notifier(struct notifier_block *nb)
486 if (!dock_station_count)
489 return atomic_notifier_chain_register(&dock_notifier_list, nb);
491 EXPORT_SYMBOL_GPL(register_dock_notifier);
494 * unregister_dock_notifier - remove yourself from the dock notifier list
495 * @nb: the callers notifier block
497 void unregister_dock_notifier(struct notifier_block *nb)
499 if (!dock_station_count)
502 atomic_notifier_chain_unregister(&dock_notifier_list, nb);
504 EXPORT_SYMBOL_GPL(unregister_dock_notifier);
507 * register_hotplug_dock_device - register a hotplug function
508 * @handle: the handle of the device
509 * @ops: handlers to call after docking
510 * @context: device specific data
511 * @init: Optional initialization routine to run after registration
512 * @release: Optional release routine to run on unregistration
514 * If a driver would like to perform a hotplug operation after a dock
515 * event, they can register an acpi_notifiy_handler to be called by
516 * the dock driver after _DCK is executed.
518 int register_hotplug_dock_device(acpi_handle handle,
519 const struct acpi_dock_ops *ops, void *context,
520 void (*init)(void *), void (*release)(void *))
522 struct dock_dependent_device *dd;
523 struct dock_station *dock_station;
526 if (WARN_ON(!context))
529 if (!dock_station_count)
533 * make sure this handle is for a device dependent on the dock,
534 * this would include the dock station itself
536 list_for_each_entry(dock_station, &dock_stations, sibling) {
538 * An ATA bay can be in a dock and itself can be ejected
539 * separately, so there are two 'dock stations' which need the
542 dd = find_dock_dependent_device(dock_station, handle);
543 if (dd && !dock_init_hotplug(dd, ops, context, init, release))
549 EXPORT_SYMBOL_GPL(register_hotplug_dock_device);
552 * unregister_hotplug_dock_device - remove yourself from the hotplug list
553 * @handle: the acpi handle of the device
555 void unregister_hotplug_dock_device(acpi_handle handle)
557 struct dock_dependent_device *dd;
558 struct dock_station *dock_station;
560 if (!dock_station_count)
563 list_for_each_entry(dock_station, &dock_stations, sibling) {
564 dd = find_dock_dependent_device(dock_station, handle);
566 dock_release_hotplug(dd);
569 EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device);
572 * handle_eject_request - handle an undock request checking for error conditions
574 * Check to make sure the dock device is still present, then undock and
575 * hotremove all the devices that may need removing.
577 static int handle_eject_request(struct dock_station *ds, u32 event)
579 if (dock_in_progress(ds))
583 * here we need to generate the undock
584 * event prior to actually doing the undock
585 * so that the device struct still exists.
586 * Also, even send the dock event if the
587 * device is not present anymore
589 dock_event(ds, event, UNDOCK_EVENT);
591 hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST);
593 acpi_evaluate_lck(ds->handle, 0);
594 acpi_evaluate_ej0(ds->handle);
595 if (dock_present(ds)) {
596 acpi_handle_err(ds->handle, "Unable to undock!\n");
604 * dock_notify - act upon an acpi dock notification
605 * @handle: the dock station handle
606 * @event: the acpi event
607 * @data: our driver data struct
609 * If we are notified to dock, then check to see if the dock is
610 * present and then dock. Notify all drivers of the dock event,
611 * and then hotplug and devices that may need hotplugging.
613 static void dock_notify(acpi_handle handle, u32 event, void *data)
615 struct dock_station *ds = data;
616 struct acpi_device *tmp;
617 int surprise_removal = 0;
620 * According to acpi spec 3.0a, if a DEVICE_CHECK notification
621 * is sent and _DCK is present, it is assumed to mean an undock
624 if ((ds->flags & DOCK_IS_DOCK) && event == ACPI_NOTIFY_DEVICE_CHECK)
625 event = ACPI_NOTIFY_EJECT_REQUEST;
628 * dock station: BUS_CHECK - docked or surprise removal
629 * DEVICE_CHECK - undocked
630 * other device: BUS_CHECK/DEVICE_CHECK - added or surprise removal
632 * To simplify event handling, dock dependent device handler always
633 * get ACPI_NOTIFY_BUS_CHECK/ACPI_NOTIFY_DEVICE_CHECK for add and
634 * ACPI_NOTIFY_EJECT_REQUEST for removal
637 case ACPI_NOTIFY_BUS_CHECK:
638 case ACPI_NOTIFY_DEVICE_CHECK:
639 if (!dock_in_progress(ds) && acpi_bus_get_device(ds->handle,
643 if (!dock_present(ds)) {
644 acpi_handle_err(handle, "Unable to dock!\n");
648 atomic_notifier_call_chain(&dock_notifier_list,
650 hotplug_dock_devices(ds, event);
652 dock_event(ds, event, DOCK_EVENT);
653 acpi_evaluate_lck(ds->handle, 1);
654 acpi_update_all_gpes();
657 if (dock_present(ds) || dock_in_progress(ds))
659 /* This is a surprise removal */
660 surprise_removal = 1;
661 event = ACPI_NOTIFY_EJECT_REQUEST;
663 case ACPI_NOTIFY_EJECT_REQUEST:
665 if ((immediate_undock && !(ds->flags & DOCK_IS_ATA))
667 handle_eject_request(ds, event);
669 dock_event(ds, event, UNDOCK_EVENT);
672 acpi_handle_err(handle, "Unknown dock event %d\n", event);
679 struct dock_station *ds;
682 static void acpi_dock_deferred_cb(void *context)
684 struct dock_data *data = context;
686 acpi_scan_lock_acquire();
687 dock_notify(data->handle, data->event, data->ds);
688 acpi_scan_lock_release();
692 static int acpi_dock_notifier_call(struct notifier_block *this,
693 unsigned long event, void *data)
695 struct dock_station *dock_station;
696 acpi_handle handle = data;
698 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK
699 && event != ACPI_NOTIFY_EJECT_REQUEST)
702 acpi_scan_lock_acquire();
704 list_for_each_entry(dock_station, &dock_stations, sibling) {
705 if (dock_station->handle == handle) {
706 struct dock_data *dd;
709 dd = kmalloc(sizeof(*dd), GFP_KERNEL);
715 dd->ds = dock_station;
716 status = acpi_os_hotplug_execute(acpi_dock_deferred_cb,
718 if (ACPI_FAILURE(status))
725 acpi_scan_lock_release();
729 static struct notifier_block dock_acpi_notifier = {
730 .notifier_call = acpi_dock_notifier_call,
734 * find_dock_devices - find devices on the dock station
735 * @handle: the handle of the device we are examining
737 * @context: the dock station private data
740 * This function is called by acpi_walk_namespace. It will
741 * check to see if an object has an _EJD method. If it does, then it
742 * will see if it is dependent on the dock station.
744 static acpi_status __init find_dock_devices(acpi_handle handle, u32 lvl,
745 void *context, void **rv)
747 struct dock_station *ds = context;
748 acpi_handle ejd = NULL;
750 acpi_bus_get_ejd(handle, &ejd);
751 if (ejd == ds->handle)
752 add_dock_dependent_device(ds, handle);
758 * show_docked - read method for "docked" file in sysfs
760 static ssize_t show_docked(struct device *dev,
761 struct device_attribute *attr, char *buf)
763 struct acpi_device *tmp;
765 struct dock_station *dock_station = dev->platform_data;
767 if (!acpi_bus_get_device(dock_station->handle, &tmp))
768 return snprintf(buf, PAGE_SIZE, "1\n");
769 return snprintf(buf, PAGE_SIZE, "0\n");
771 static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
774 * show_flags - read method for flags file in sysfs
776 static ssize_t show_flags(struct device *dev,
777 struct device_attribute *attr, char *buf)
779 struct dock_station *dock_station = dev->platform_data;
780 return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
783 static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
786 * write_undock - write method for "undock" file in sysfs
788 static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
789 const char *buf, size_t count)
792 struct dock_station *dock_station = dev->platform_data;
797 acpi_scan_lock_acquire();
798 begin_undock(dock_station);
799 ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
800 acpi_scan_lock_release();
801 return ret ? ret: count;
803 static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
806 * show_dock_uid - read method for "uid" file in sysfs
808 static ssize_t show_dock_uid(struct device *dev,
809 struct device_attribute *attr, char *buf)
811 unsigned long long lbuf;
812 struct dock_station *dock_station = dev->platform_data;
813 acpi_status status = acpi_evaluate_integer(dock_station->handle,
814 "_UID", NULL, &lbuf);
815 if (ACPI_FAILURE(status))
818 return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
820 static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
822 static ssize_t show_dock_type(struct device *dev,
823 struct device_attribute *attr, char *buf)
825 struct dock_station *dock_station = dev->platform_data;
828 if (dock_station->flags & DOCK_IS_DOCK)
829 type = "dock_station";
830 else if (dock_station->flags & DOCK_IS_ATA)
832 else if (dock_station->flags & DOCK_IS_BAT)
833 type = "battery_bay";
837 return snprintf(buf, PAGE_SIZE, "%s\n", type);
839 static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
841 static struct attribute *dock_attributes[] = {
842 &dev_attr_docked.attr,
843 &dev_attr_flags.attr,
844 &dev_attr_undock.attr,
850 static struct attribute_group dock_attribute_group = {
851 .attrs = dock_attributes
855 * dock_add - add a new dock station
856 * @handle: the dock station handle
858 * allocated and initialize a new dock station device. Find all devices
859 * that are on the dock station, and register for dock event notifications.
861 static int __init dock_add(acpi_handle handle)
864 struct dock_station ds, *dock_station;
865 struct platform_device *dd;
867 id = dock_station_count;
868 memset(&ds, 0, sizeof(ds));
869 dd = platform_device_register_data(NULL, "dock", id, &ds, sizeof(ds));
873 dock_station = dd->dev.platform_data;
875 dock_station->handle = handle;
876 dock_station->dock_device = dd;
877 dock_station->last_dock_time = jiffies - HZ;
879 INIT_LIST_HEAD(&dock_station->sibling);
880 INIT_LIST_HEAD(&dock_station->dependent_devices);
882 /* we want the dock device to send uevents */
883 dev_set_uevent_suppress(&dd->dev, 0);
885 if (acpi_dock_match(handle))
886 dock_station->flags |= DOCK_IS_DOCK;
887 if (acpi_ata_match(handle))
888 dock_station->flags |= DOCK_IS_ATA;
889 if (is_battery(handle))
890 dock_station->flags |= DOCK_IS_BAT;
892 ret = sysfs_create_group(&dd->dev.kobj, &dock_attribute_group);
896 /* Find dependent devices */
897 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
898 ACPI_UINT32_MAX, find_dock_devices, NULL,
901 /* add the dock station as a device dependent on itself */
902 ret = add_dock_dependent_device(dock_station, handle);
906 dock_station_count++;
907 list_add(&dock_station->sibling, &dock_stations);
911 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group);
913 platform_device_unregister(dd);
914 acpi_handle_err(handle, "%s encountered error %d\n", __func__, ret);
919 * find_dock_and_bay - look for dock stations and bays
920 * @handle: acpi handle of a device
925 * This is called by acpi_walk_namespace to look for dock stations and bays.
927 static __init acpi_status
928 find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
930 if (acpi_dock_match(handle) || is_ejectable_bay(handle))
936 void __init acpi_dock_init(void)
941 /* look for dock stations and bays */
942 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
943 ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL);
945 if (!dock_station_count) {
946 pr_info(PREFIX "No dock devices found.\n");
950 ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
951 register_acpi_bus_notifier(&dock_acpi_notifier);
952 pr_info(PREFIX "%s: %d docks/bays found\n",
953 ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count);