dock.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /*
  2. * dock.c - ACPI dock station driver
  3. *
  4. * Copyright (C) 2006, 2014, Intel Corp.
  5. * Author: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
  6. * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  7. *
  8. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or (at
  13. * your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License along
  21. * with this program; if not, write to the Free Software Foundation, Inc.,
  22. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  23. *
  24. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  25. */
  26. #include <linux/kernel.h>
  27. #include <linux/module.h>
  28. #include <linux/slab.h>
  29. #include <linux/init.h>
  30. #include <linux/types.h>
  31. #include <linux/notifier.h>
  32. #include <linux/platform_device.h>
  33. #include <linux/jiffies.h>
  34. #include <linux/stddef.h>
  35. #include <linux/acpi.h>
  36. #include "internal.h"
  37. #define ACPI_DOCK_DRIVER_DESCRIPTION "ACPI Dock Station Driver"
  38. ACPI_MODULE_NAME("dock");
  39. MODULE_AUTHOR("Kristen Carlson Accardi");
  40. MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_DESCRIPTION);
  41. MODULE_LICENSE("GPL");
  42. static bool immediate_undock = 1;
  43. module_param(immediate_undock, bool, 0644);
  44. MODULE_PARM_DESC(immediate_undock, "1 (default) will cause the driver to "
  45. "undock immediately when the undock button is pressed, 0 will cause"
  46. " the driver to wait for userspace to write the undock sysfs file "
  47. " before undocking");
  48. struct dock_station {
  49. acpi_handle handle;
  50. unsigned long last_dock_time;
  51. u32 flags;
  52. struct list_head dependent_devices;
  53. struct list_head sibling;
  54. struct platform_device *dock_device;
  55. };
  56. static LIST_HEAD(dock_stations);
  57. static int dock_station_count;
  58. struct dock_dependent_device {
  59. struct list_head list;
  60. struct acpi_device *adev;
  61. };
  62. #define DOCK_DOCKING 0x00000001
  63. #define DOCK_UNDOCKING 0x00000002
  64. #define DOCK_IS_DOCK 0x00000010
  65. #define DOCK_IS_ATA 0x00000020
  66. #define DOCK_IS_BAT 0x00000040
  67. #define DOCK_EVENT 3
  68. #define UNDOCK_EVENT 2
  69. enum dock_callback_type {
  70. DOCK_CALL_HANDLER,
  71. DOCK_CALL_FIXUP,
  72. DOCK_CALL_UEVENT,
  73. };
  74. /*****************************************************************************
  75. * Dock Dependent device functions *
  76. *****************************************************************************/
  77. /**
  78. * add_dock_dependent_device - associate a device with the dock station
  79. * @ds: Dock station.
  80. * @adev: Dependent ACPI device object.
  81. *
  82. * Add the dependent device to the dock's dependent device list.
  83. */
  84. static int add_dock_dependent_device(struct dock_station *ds,
  85. struct acpi_device *adev)
  86. {
  87. struct dock_dependent_device *dd;
  88. dd = kzalloc(sizeof(*dd), GFP_KERNEL);
  89. if (!dd)
  90. return -ENOMEM;
  91. dd->adev = adev;
  92. INIT_LIST_HEAD(&dd->list);
  93. list_add_tail(&dd->list, &ds->dependent_devices);
  94. return 0;
  95. }
  96. static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event,
  97. enum dock_callback_type cb_type)
  98. {
  99. struct acpi_device *adev = dd->adev;
  100. acpi_lock_hp_context();
  101. if (!adev->hp)
  102. goto out;
  103. if (cb_type == DOCK_CALL_FIXUP) {
  104. void (*fixup)(struct acpi_device *);
  105. fixup = adev->hp->fixup;
  106. if (fixup) {
  107. acpi_unlock_hp_context();
  108. fixup(adev);
  109. return;
  110. }
  111. } else if (cb_type == DOCK_CALL_UEVENT) {
  112. void (*uevent)(struct acpi_device *, u32);
  113. uevent = adev->hp->uevent;
  114. if (uevent) {
  115. acpi_unlock_hp_context();
  116. uevent(adev, event);
  117. return;
  118. }
  119. } else {
  120. int (*notify)(struct acpi_device *, u32);
  121. notify = adev->hp->notify;
  122. if (notify) {
  123. acpi_unlock_hp_context();
  124. notify(adev, event);
  125. return;
  126. }
  127. }
  128. out:
  129. acpi_unlock_hp_context();
  130. }
  131. static struct dock_station *find_dock_station(acpi_handle handle)
  132. {
  133. struct dock_station *ds;
  134. list_for_each_entry(ds, &dock_stations, sibling)
  135. if (ds->handle == handle)
  136. return ds;
  137. return NULL;
  138. }
  139. /**
  140. * find_dock_dependent_device - get a device dependent on this dock
  141. * @ds: the dock station
  142. * @adev: ACPI device object to find.
  143. *
  144. * iterate over the dependent device list for this dock. If the
  145. * dependent device matches the handle, return.
  146. */
  147. static struct dock_dependent_device *
  148. find_dock_dependent_device(struct dock_station *ds, struct acpi_device *adev)
  149. {
  150. struct dock_dependent_device *dd;
  151. list_for_each_entry(dd, &ds->dependent_devices, list)
  152. if (adev == dd->adev)
  153. return dd;
  154. return NULL;
  155. }
  156. void register_dock_dependent_device(struct acpi_device *adev,
  157. acpi_handle dshandle)
  158. {
  159. struct dock_station *ds = find_dock_station(dshandle);
  160. if (ds && !find_dock_dependent_device(ds, adev))
  161. add_dock_dependent_device(ds, adev);
  162. }
  163. /*****************************************************************************
  164. * Dock functions *
  165. *****************************************************************************/
  166. /**
  167. * is_dock_device - see if a device is on a dock station
  168. * @adev: ACPI device object to check.
  169. *
  170. * If this device is either the dock station itself,
  171. * or is a device dependent on the dock station, then it
  172. * is a dock device
  173. */
  174. int is_dock_device(struct acpi_device *adev)
  175. {
  176. struct dock_station *dock_station;
  177. if (!dock_station_count)
  178. return 0;
  179. if (acpi_dock_match(adev->handle))
  180. return 1;
  181. list_for_each_entry(dock_station, &dock_stations, sibling)
  182. if (find_dock_dependent_device(dock_station, adev))
  183. return 1;
  184. return 0;
  185. }
  186. EXPORT_SYMBOL_GPL(is_dock_device);
  187. /**
  188. * dock_present - see if the dock station is present.
  189. * @ds: the dock station
  190. *
  191. * execute the _STA method. note that present does not
  192. * imply that we are docked.
  193. */
  194. static int dock_present(struct dock_station *ds)
  195. {
  196. unsigned long long sta;
  197. acpi_status status;
  198. if (ds) {
  199. status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta);
  200. if (ACPI_SUCCESS(status) && sta)
  201. return 1;
  202. }
  203. return 0;
  204. }
  205. /**
  206. * hot_remove_dock_devices - Remove dock station devices.
  207. * @ds: Dock station.
  208. */
  209. static void hot_remove_dock_devices(struct dock_station *ds)
  210. {
  211. struct dock_dependent_device *dd;
  212. /*
  213. * Walk the list in reverse order so that devices that have been added
  214. * last are removed first (in case there are some indirect dependencies
  215. * between them).
  216. */
  217. list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
  218. dock_hotplug_event(dd, ACPI_NOTIFY_EJECT_REQUEST, false);
  219. list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
  220. acpi_bus_trim(dd->adev);
  221. }
  222. /**
  223. * hotplug_dock_devices - Insert devices on a dock station.
  224. * @ds: the dock station
  225. * @event: either bus check or device check request
  226. *
  227. * Some devices on the dock station need to have drivers called
  228. * to perform hotplug operations after a dock event has occurred.
  229. * Traverse the list of dock devices that have registered a
  230. * hotplug handler, and call the handler.
  231. */
  232. static void hotplug_dock_devices(struct dock_station *ds, u32 event)
  233. {
  234. struct dock_dependent_device *dd;
  235. /* Call driver specific post-dock fixups. */
  236. list_for_each_entry(dd, &ds->dependent_devices, list)
  237. dock_hotplug_event(dd, event, DOCK_CALL_FIXUP);
  238. /* Call driver specific hotplug functions. */
  239. list_for_each_entry(dd, &ds->dependent_devices, list)
  240. dock_hotplug_event(dd, event, DOCK_CALL_HANDLER);
  241. /*
  242. * Check if all devices have been enumerated already. If not, run
  243. * acpi_bus_scan() for them and that will cause scan handlers to be
  244. * attached to device objects or acpi_drivers to be stopped/started if
  245. * they are present.
  246. */
  247. list_for_each_entry(dd, &ds->dependent_devices, list) {
  248. struct acpi_device *adev = dd->adev;
  249. if (!acpi_device_enumerated(adev)) {
  250. int ret = acpi_bus_scan(adev->handle);
  251. if (ret)
  252. dev_dbg(&adev->dev, "scan error %d\n", -ret);
  253. }
  254. }
  255. }
  256. static void dock_event(struct dock_station *ds, u32 event, int num)
  257. {
  258. struct device *dev = &ds->dock_device->dev;
  259. char event_string[13];
  260. char *envp[] = { event_string, NULL };
  261. struct dock_dependent_device *dd;
  262. if (num == UNDOCK_EVENT)
  263. sprintf(event_string, "EVENT=undock");
  264. else
  265. sprintf(event_string, "EVENT=dock");
  266. /*
  267. * Indicate that the status of the dock station has
  268. * changed.
  269. */
  270. if (num == DOCK_EVENT)
  271. kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
  272. list_for_each_entry(dd, &ds->dependent_devices, list)
  273. dock_hotplug_event(dd, event, DOCK_CALL_UEVENT);
  274. if (num != DOCK_EVENT)
  275. kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
  276. }
  277. /**
  278. * handle_dock - handle a dock event
  279. * @ds: the dock station
  280. * @dock: to dock, or undock - that is the question
  281. *
  282. * Execute the _DCK method in response to an acpi event
  283. */
  284. static void handle_dock(struct dock_station *ds, int dock)
  285. {
  286. acpi_status status;
  287. struct acpi_object_list arg_list;
  288. union acpi_object arg;
  289. unsigned long long value;
  290. acpi_handle_info(ds->handle, "%s\n", dock ? "docking" : "undocking");
  291. /* _DCK method has one argument */
  292. arg_list.count = 1;
  293. arg_list.pointer = &arg;
  294. arg.type = ACPI_TYPE_INTEGER;
  295. arg.integer.value = dock;
  296. status = acpi_evaluate_integer(ds->handle, "_DCK", &arg_list, &value);
  297. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
  298. acpi_handle_err(ds->handle, "Failed to execute _DCK (0x%x)\n",
  299. status);
  300. }
  301. static inline void dock(struct dock_station *ds)
  302. {
  303. handle_dock(ds, 1);
  304. }
  305. static inline void undock(struct dock_station *ds)
  306. {
  307. handle_dock(ds, 0);
  308. }
  309. static inline void begin_dock(struct dock_station *ds)
  310. {
  311. ds->flags |= DOCK_DOCKING;
  312. }
  313. static inline void complete_dock(struct dock_station *ds)
  314. {
  315. ds->flags &= ~(DOCK_DOCKING);
  316. ds->last_dock_time = jiffies;
  317. }
  318. static inline void begin_undock(struct dock_station *ds)
  319. {
  320. ds->flags |= DOCK_UNDOCKING;
  321. }
  322. static inline void complete_undock(struct dock_station *ds)
  323. {
  324. ds->flags &= ~(DOCK_UNDOCKING);
  325. }
  326. /**
  327. * dock_in_progress - see if we are in the middle of handling a dock event
  328. * @ds: the dock station
  329. *
  330. * Sometimes while docking, false dock events can be sent to the driver
  331. * because good connections aren't made or some other reason. Ignore these
  332. * if we are in the middle of doing something.
  333. */
  334. static int dock_in_progress(struct dock_station *ds)
  335. {
  336. if ((ds->flags & DOCK_DOCKING) ||
  337. time_before(jiffies, (ds->last_dock_time + HZ)))
  338. return 1;
  339. return 0;
  340. }
  341. /**
  342. * handle_eject_request - handle an undock request checking for error conditions
  343. *
  344. * Check to make sure the dock device is still present, then undock and
  345. * hotremove all the devices that may need removing.
  346. */
  347. static int handle_eject_request(struct dock_station *ds, u32 event)
  348. {
  349. if (dock_in_progress(ds))
  350. return -EBUSY;
  351. /*
  352. * here we need to generate the undock
  353. * event prior to actually doing the undock
  354. * so that the device struct still exists.
  355. * Also, even send the dock event if the
  356. * device is not present anymore
  357. */
  358. dock_event(ds, event, UNDOCK_EVENT);
  359. hot_remove_dock_devices(ds);
  360. undock(ds);
  361. acpi_evaluate_lck(ds->handle, 0);
  362. acpi_evaluate_ej0(ds->handle);
  363. if (dock_present(ds)) {
  364. acpi_handle_err(ds->handle, "Unable to undock!\n");
  365. return -EBUSY;
  366. }
  367. complete_undock(ds);
  368. return 0;
  369. }
  370. /**
  371. * dock_notify - Handle ACPI dock notification.
  372. * @adev: Dock station's ACPI device object.
  373. * @event: Event code.
  374. *
  375. * If we are notified to dock, then check to see if the dock is
  376. * present and then dock. Notify all drivers of the dock event,
  377. * and then hotplug and devices that may need hotplugging.
  378. */
  379. int dock_notify(struct acpi_device *adev, u32 event)
  380. {
  381. acpi_handle handle = adev->handle;
  382. struct dock_station *ds = find_dock_station(handle);
  383. int surprise_removal = 0;
  384. if (!ds)
  385. return -ENODEV;
  386. /*
  387. * According to acpi spec 3.0a, if a DEVICE_CHECK notification
  388. * is sent and _DCK is present, it is assumed to mean an undock
  389. * request.
  390. */
  391. if ((ds->flags & DOCK_IS_DOCK) && event == ACPI_NOTIFY_DEVICE_CHECK)
  392. event = ACPI_NOTIFY_EJECT_REQUEST;
  393. /*
  394. * dock station: BUS_CHECK - docked or surprise removal
  395. * DEVICE_CHECK - undocked
  396. * other device: BUS_CHECK/DEVICE_CHECK - added or surprise removal
  397. *
  398. * To simplify event handling, dock dependent device handler always
  399. * get ACPI_NOTIFY_BUS_CHECK/ACPI_NOTIFY_DEVICE_CHECK for add and
  400. * ACPI_NOTIFY_EJECT_REQUEST for removal
  401. */
  402. switch (event) {
  403. case ACPI_NOTIFY_BUS_CHECK:
  404. case ACPI_NOTIFY_DEVICE_CHECK:
  405. if (!dock_in_progress(ds) && !acpi_device_enumerated(adev)) {
  406. begin_dock(ds);
  407. dock(ds);
  408. if (!dock_present(ds)) {
  409. acpi_handle_err(handle, "Unable to dock!\n");
  410. complete_dock(ds);
  411. break;
  412. }
  413. hotplug_dock_devices(ds, event);
  414. complete_dock(ds);
  415. dock_event(ds, event, DOCK_EVENT);
  416. acpi_evaluate_lck(ds->handle, 1);
  417. acpi_update_all_gpes();
  418. break;
  419. }
  420. if (dock_present(ds) || dock_in_progress(ds))
  421. break;
  422. /* This is a surprise removal */
  423. surprise_removal = 1;
  424. event = ACPI_NOTIFY_EJECT_REQUEST;
  425. /* Fall back */
  426. case ACPI_NOTIFY_EJECT_REQUEST:
  427. begin_undock(ds);
  428. if ((immediate_undock && !(ds->flags & DOCK_IS_ATA))
  429. || surprise_removal)
  430. handle_eject_request(ds, event);
  431. else
  432. dock_event(ds, event, UNDOCK_EVENT);
  433. break;
  434. }
  435. return 0;
  436. }
  437. /*
  438. * show_docked - read method for "docked" file in sysfs
  439. */
  440. static ssize_t show_docked(struct device *dev,
  441. struct device_attribute *attr, char *buf)
  442. {
  443. struct dock_station *dock_station = dev->platform_data;
  444. struct acpi_device *adev = NULL;
  445. acpi_bus_get_device(dock_station->handle, &adev);
  446. return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
  447. }
  448. static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
  449. /*
  450. * show_flags - read method for flags file in sysfs
  451. */
  452. static ssize_t show_flags(struct device *dev,
  453. struct device_attribute *attr, char *buf)
  454. {
  455. struct dock_station *dock_station = dev->platform_data;
  456. return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
  457. }
  458. static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
  459. /*
  460. * write_undock - write method for "undock" file in sysfs
  461. */
  462. static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
  463. const char *buf, size_t count)
  464. {
  465. int ret;
  466. struct dock_station *dock_station = dev->platform_data;
  467. if (!count)
  468. return -EINVAL;
  469. acpi_scan_lock_acquire();
  470. begin_undock(dock_station);
  471. ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
  472. acpi_scan_lock_release();
  473. return ret ? ret: count;
  474. }
  475. static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
  476. /*
  477. * show_dock_uid - read method for "uid" file in sysfs
  478. */
  479. static ssize_t show_dock_uid(struct device *dev,
  480. struct device_attribute *attr, char *buf)
  481. {
  482. unsigned long long lbuf;
  483. struct dock_station *dock_station = dev->platform_data;
  484. acpi_status status = acpi_evaluate_integer(dock_station->handle,
  485. "_UID", NULL, &lbuf);
  486. if (ACPI_FAILURE(status))
  487. return 0;
  488. return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
  489. }
  490. static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
  491. static ssize_t show_dock_type(struct device *dev,
  492. struct device_attribute *attr, char *buf)
  493. {
  494. struct dock_station *dock_station = dev->platform_data;
  495. char *type;
  496. if (dock_station->flags & DOCK_IS_DOCK)
  497. type = "dock_station";
  498. else if (dock_station->flags & DOCK_IS_ATA)
  499. type = "ata_bay";
  500. else if (dock_station->flags & DOCK_IS_BAT)
  501. type = "battery_bay";
  502. else
  503. type = "unknown";
  504. return snprintf(buf, PAGE_SIZE, "%s\n", type);
  505. }
  506. static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
  507. static struct attribute *dock_attributes[] = {
  508. &dev_attr_docked.attr,
  509. &dev_attr_flags.attr,
  510. &dev_attr_undock.attr,
  511. &dev_attr_uid.attr,
  512. &dev_attr_type.attr,
  513. NULL
  514. };
  515. static struct attribute_group dock_attribute_group = {
  516. .attrs = dock_attributes
  517. };
  518. /**
  519. * acpi_dock_add - Add a new dock station
  520. * @adev: Dock station ACPI device object.
  521. *
  522. * allocated and initialize a new dock station device.
  523. */
  524. void acpi_dock_add(struct acpi_device *adev)
  525. {
  526. struct dock_station *dock_station, ds = { NULL, };
  527. struct platform_device_info pdevinfo;
  528. acpi_handle handle = adev->handle;
  529. struct platform_device *dd;
  530. int ret;
  531. memset(&pdevinfo, 0, sizeof(pdevinfo));
  532. pdevinfo.name = "dock";
  533. pdevinfo.id = dock_station_count;
  534. pdevinfo.fwnode = acpi_fwnode_handle(adev);
  535. pdevinfo.data = &ds;
  536. pdevinfo.size_data = sizeof(ds);
  537. dd = platform_device_register_full(&pdevinfo);
  538. if (IS_ERR(dd))
  539. return;
  540. dock_station = dd->dev.platform_data;
  541. dock_station->handle = handle;
  542. dock_station->dock_device = dd;
  543. dock_station->last_dock_time = jiffies - HZ;
  544. INIT_LIST_HEAD(&dock_station->sibling);
  545. INIT_LIST_HEAD(&dock_station->dependent_devices);
  546. /* we want the dock device to send uevents */
  547. dev_set_uevent_suppress(&dd->dev, 0);
  548. if (acpi_dock_match(handle))
  549. dock_station->flags |= DOCK_IS_DOCK;
  550. if (acpi_ata_match(handle))
  551. dock_station->flags |= DOCK_IS_ATA;
  552. if (acpi_device_is_battery(adev))
  553. dock_station->flags |= DOCK_IS_BAT;
  554. ret = sysfs_create_group(&dd->dev.kobj, &dock_attribute_group);
  555. if (ret)
  556. goto err_unregister;
  557. /* add the dock station as a device dependent on itself */
  558. ret = add_dock_dependent_device(dock_station, adev);
  559. if (ret)
  560. goto err_rmgroup;
  561. dock_station_count++;
  562. list_add(&dock_station->sibling, &dock_stations);
  563. adev->flags.is_dock_station = true;
  564. dev_info(&adev->dev, "ACPI dock station (docks/bays count: %d)\n",
  565. dock_station_count);
  566. return;
  567. err_rmgroup:
  568. sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group);
  569. err_unregister:
  570. platform_device_unregister(dd);
  571. acpi_handle_err(handle, "%s encountered error %d\n", __func__, ret);
  572. }