dock.c 17 KB

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