device_sysfs.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /*
  2. * drivers/acpi/device_sysfs.c - ACPI device sysfs attributes and modalias.
  3. *
  4. * Copyright (C) 2015, Intel Corp.
  5. * Author: Mika Westerberg <mika.westerberg@linux.intel.com>
  6. * Author: 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 version 2 as published
  12. * by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  20. */
  21. #include <linux/acpi.h>
  22. #include <linux/device.h>
  23. #include <linux/export.h>
  24. #include <linux/nls.h>
  25. #include "internal.h"
  26. static ssize_t acpi_object_path(acpi_handle handle, char *buf)
  27. {
  28. struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL};
  29. int result;
  30. result = acpi_get_name(handle, ACPI_FULL_PATHNAME, &path);
  31. if (result)
  32. return result;
  33. result = sprintf(buf, "%s\n", (char *)path.pointer);
  34. kfree(path.pointer);
  35. return result;
  36. }
  37. struct acpi_data_node_attr {
  38. struct attribute attr;
  39. ssize_t (*show)(struct acpi_data_node *, char *);
  40. ssize_t (*store)(struct acpi_data_node *, const char *, size_t count);
  41. };
  42. #define DATA_NODE_ATTR(_name) \
  43. static struct acpi_data_node_attr data_node_##_name = \
  44. __ATTR(_name, 0444, data_node_show_##_name, NULL)
  45. static ssize_t data_node_show_path(struct acpi_data_node *dn, char *buf)
  46. {
  47. return acpi_object_path(dn->handle, buf);
  48. }
  49. DATA_NODE_ATTR(path);
  50. static struct attribute *acpi_data_node_default_attrs[] = {
  51. &data_node_path.attr,
  52. NULL
  53. };
  54. #define to_data_node(k) container_of(k, struct acpi_data_node, kobj)
  55. #define to_attr(a) container_of(a, struct acpi_data_node_attr, attr)
  56. static ssize_t acpi_data_node_attr_show(struct kobject *kobj,
  57. struct attribute *attr, char *buf)
  58. {
  59. struct acpi_data_node *dn = to_data_node(kobj);
  60. struct acpi_data_node_attr *dn_attr = to_attr(attr);
  61. return dn_attr->show ? dn_attr->show(dn, buf) : -ENXIO;
  62. }
  63. static const struct sysfs_ops acpi_data_node_sysfs_ops = {
  64. .show = acpi_data_node_attr_show,
  65. };
  66. static void acpi_data_node_release(struct kobject *kobj)
  67. {
  68. struct acpi_data_node *dn = to_data_node(kobj);
  69. complete(&dn->kobj_done);
  70. }
  71. static struct kobj_type acpi_data_node_ktype = {
  72. .sysfs_ops = &acpi_data_node_sysfs_ops,
  73. .default_attrs = acpi_data_node_default_attrs,
  74. .release = acpi_data_node_release,
  75. };
  76. static void acpi_expose_nondev_subnodes(struct kobject *kobj,
  77. struct acpi_device_data *data)
  78. {
  79. struct list_head *list = &data->subnodes;
  80. struct acpi_data_node *dn;
  81. if (list_empty(list))
  82. return;
  83. list_for_each_entry(dn, list, sibling) {
  84. int ret;
  85. init_completion(&dn->kobj_done);
  86. ret = kobject_init_and_add(&dn->kobj, &acpi_data_node_ktype,
  87. kobj, "%s", dn->name);
  88. if (ret)
  89. acpi_handle_err(dn->handle, "Failed to expose (%d)\n", ret);
  90. else
  91. acpi_expose_nondev_subnodes(&dn->kobj, &dn->data);
  92. }
  93. }
  94. static void acpi_hide_nondev_subnodes(struct acpi_device_data *data)
  95. {
  96. struct list_head *list = &data->subnodes;
  97. struct acpi_data_node *dn;
  98. if (list_empty(list))
  99. return;
  100. list_for_each_entry_reverse(dn, list, sibling) {
  101. acpi_hide_nondev_subnodes(&dn->data);
  102. kobject_put(&dn->kobj);
  103. }
  104. }
  105. /**
  106. * create_pnp_modalias - Create hid/cid(s) string for modalias and uevent
  107. * @acpi_dev: ACPI device object.
  108. * @modalias: Buffer to print into.
  109. * @size: Size of the buffer.
  110. *
  111. * Creates hid/cid(s) string needed for modalias and uevent
  112. * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get:
  113. * char *modalias: "acpi:IBM0001:ACPI0001"
  114. * Return: 0: no _HID and no _CID
  115. * -EINVAL: output error
  116. * -ENOMEM: output is truncated
  117. */
  118. static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
  119. int size)
  120. {
  121. int len;
  122. int count;
  123. struct acpi_hardware_id *id;
  124. /*
  125. * Since we skip ACPI_DT_NAMESPACE_HID from the modalias below, 0 should
  126. * be returned if ACPI_DT_NAMESPACE_HID is the only ACPI/PNP ID in the
  127. * device's list.
  128. */
  129. count = 0;
  130. list_for_each_entry(id, &acpi_dev->pnp.ids, list)
  131. if (strcmp(id->id, ACPI_DT_NAMESPACE_HID))
  132. count++;
  133. if (!count)
  134. return 0;
  135. len = snprintf(modalias, size, "acpi:");
  136. if (len <= 0)
  137. return len;
  138. size -= len;
  139. list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
  140. if (!strcmp(id->id, ACPI_DT_NAMESPACE_HID))
  141. continue;
  142. count = snprintf(&modalias[len], size, "%s:", id->id);
  143. if (count < 0)
  144. return -EINVAL;
  145. if (count >= size)
  146. return -ENOMEM;
  147. len += count;
  148. size -= count;
  149. }
  150. modalias[len] = '\0';
  151. return len;
  152. }
  153. /**
  154. * create_of_modalias - Creates DT compatible string for modalias and uevent
  155. * @acpi_dev: ACPI device object.
  156. * @modalias: Buffer to print into.
  157. * @size: Size of the buffer.
  158. *
  159. * Expose DT compatible modalias as of:NnameTCcompatible. This function should
  160. * only be called for devices having ACPI_DT_NAMESPACE_HID in their list of
  161. * ACPI/PNP IDs.
  162. */
  163. static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,
  164. int size)
  165. {
  166. struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
  167. const union acpi_object *of_compatible, *obj;
  168. int len, count;
  169. int i, nval;
  170. char *c;
  171. acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
  172. /* DT strings are all in lower case */
  173. for (c = buf.pointer; *c != '\0'; c++)
  174. *c = tolower(*c);
  175. len = snprintf(modalias, size, "of:N%sT", (char *)buf.pointer);
  176. ACPI_FREE(buf.pointer);
  177. if (len <= 0)
  178. return len;
  179. of_compatible = acpi_dev->data.of_compatible;
  180. if (of_compatible->type == ACPI_TYPE_PACKAGE) {
  181. nval = of_compatible->package.count;
  182. obj = of_compatible->package.elements;
  183. } else { /* Must be ACPI_TYPE_STRING. */
  184. nval = 1;
  185. obj = of_compatible;
  186. }
  187. for (i = 0; i < nval; i++, obj++) {
  188. count = snprintf(&modalias[len], size, "C%s",
  189. obj->string.pointer);
  190. if (count < 0)
  191. return -EINVAL;
  192. if (count >= size)
  193. return -ENOMEM;
  194. len += count;
  195. size -= count;
  196. }
  197. modalias[len] = '\0';
  198. return len;
  199. }
  200. int __acpi_device_uevent_modalias(struct acpi_device *adev,
  201. struct kobj_uevent_env *env)
  202. {
  203. int len;
  204. if (!adev)
  205. return -ENODEV;
  206. if (list_empty(&adev->pnp.ids))
  207. return 0;
  208. if (add_uevent_var(env, "MODALIAS="))
  209. return -ENOMEM;
  210. len = create_pnp_modalias(adev, &env->buf[env->buflen - 1],
  211. sizeof(env->buf) - env->buflen);
  212. if (len < 0)
  213. return len;
  214. env->buflen += len;
  215. if (!adev->data.of_compatible)
  216. return 0;
  217. if (len > 0 && add_uevent_var(env, "MODALIAS="))
  218. return -ENOMEM;
  219. len = create_of_modalias(adev, &env->buf[env->buflen - 1],
  220. sizeof(env->buf) - env->buflen);
  221. if (len < 0)
  222. return len;
  223. env->buflen += len;
  224. return 0;
  225. }
  226. /**
  227. * acpi_device_uevent_modalias - uevent modalias for ACPI-enumerated devices.
  228. *
  229. * Create the uevent modalias field for ACPI-enumerated devices.
  230. *
  231. * Because other buses do not support ACPI HIDs & CIDs, e.g. for a device with
  232. * hid:IBM0001 and cid:ACPI0001 you get: "acpi:IBM0001:ACPI0001".
  233. */
  234. int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
  235. {
  236. return __acpi_device_uevent_modalias(acpi_companion_match(dev), env);
  237. }
  238. EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
  239. static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
  240. {
  241. int len, count;
  242. if (!adev)
  243. return -ENODEV;
  244. if (list_empty(&adev->pnp.ids))
  245. return 0;
  246. len = create_pnp_modalias(adev, buf, size - 1);
  247. if (len < 0) {
  248. return len;
  249. } else if (len > 0) {
  250. buf[len++] = '\n';
  251. size -= len;
  252. }
  253. if (!adev->data.of_compatible)
  254. return len;
  255. count = create_of_modalias(adev, buf + len, size - 1);
  256. if (count < 0) {
  257. return count;
  258. } else if (count > 0) {
  259. len += count;
  260. buf[len++] = '\n';
  261. }
  262. return len;
  263. }
  264. /**
  265. * acpi_device_modalias - modalias sysfs attribute for ACPI-enumerated devices.
  266. *
  267. * Create the modalias sysfs attribute for ACPI-enumerated devices.
  268. *
  269. * Because other buses do not support ACPI HIDs & CIDs, e.g. for a device with
  270. * hid:IBM0001 and cid:ACPI0001 you get: "acpi:IBM0001:ACPI0001".
  271. */
  272. int acpi_device_modalias(struct device *dev, char *buf, int size)
  273. {
  274. return __acpi_device_modalias(acpi_companion_match(dev), buf, size);
  275. }
  276. EXPORT_SYMBOL_GPL(acpi_device_modalias);
  277. static ssize_t
  278. acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
  279. {
  280. return __acpi_device_modalias(to_acpi_device(dev), buf, 1024);
  281. }
  282. static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
  283. static ssize_t real_power_state_show(struct device *dev,
  284. struct device_attribute *attr, char *buf)
  285. {
  286. struct acpi_device *adev = to_acpi_device(dev);
  287. int state;
  288. int ret;
  289. ret = acpi_device_get_power(adev, &state);
  290. if (ret)
  291. return ret;
  292. return sprintf(buf, "%s\n", acpi_power_state_string(state));
  293. }
  294. static DEVICE_ATTR(real_power_state, 0444, real_power_state_show, NULL);
  295. static ssize_t power_state_show(struct device *dev,
  296. struct device_attribute *attr, char *buf)
  297. {
  298. struct acpi_device *adev = to_acpi_device(dev);
  299. return sprintf(buf, "%s\n", acpi_power_state_string(adev->power.state));
  300. }
  301. static DEVICE_ATTR(power_state, 0444, power_state_show, NULL);
  302. static ssize_t
  303. acpi_eject_store(struct device *d, struct device_attribute *attr,
  304. const char *buf, size_t count)
  305. {
  306. struct acpi_device *acpi_device = to_acpi_device(d);
  307. acpi_object_type not_used;
  308. acpi_status status;
  309. if (!count || buf[0] != '1')
  310. return -EINVAL;
  311. if ((!acpi_device->handler || !acpi_device->handler->hotplug.enabled)
  312. && !acpi_device->driver)
  313. return -ENODEV;
  314. status = acpi_get_type(acpi_device->handle, &not_used);
  315. if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable)
  316. return -ENODEV;
  317. get_device(&acpi_device->dev);
  318. status = acpi_hotplug_schedule(acpi_device, ACPI_OST_EC_OSPM_EJECT);
  319. if (ACPI_SUCCESS(status))
  320. return count;
  321. put_device(&acpi_device->dev);
  322. acpi_evaluate_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
  323. ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL);
  324. return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN;
  325. }
  326. static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
  327. static ssize_t
  328. acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf)
  329. {
  330. struct acpi_device *acpi_dev = to_acpi_device(dev);
  331. return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev));
  332. }
  333. static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
  334. static ssize_t acpi_device_uid_show(struct device *dev,
  335. struct device_attribute *attr, char *buf)
  336. {
  337. struct acpi_device *acpi_dev = to_acpi_device(dev);
  338. return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
  339. }
  340. static DEVICE_ATTR(uid, 0444, acpi_device_uid_show, NULL);
  341. static ssize_t acpi_device_adr_show(struct device *dev,
  342. struct device_attribute *attr, char *buf)
  343. {
  344. struct acpi_device *acpi_dev = to_acpi_device(dev);
  345. return sprintf(buf, "0x%08x\n",
  346. (unsigned int)(acpi_dev->pnp.bus_address));
  347. }
  348. static DEVICE_ATTR(adr, 0444, acpi_device_adr_show, NULL);
  349. static ssize_t acpi_device_path_show(struct device *dev,
  350. struct device_attribute *attr, char *buf)
  351. {
  352. struct acpi_device *acpi_dev = to_acpi_device(dev);
  353. return acpi_object_path(acpi_dev->handle, buf);
  354. }
  355. static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL);
  356. /* sysfs file that shows description text from the ACPI _STR method */
  357. static ssize_t description_show(struct device *dev,
  358. struct device_attribute *attr,
  359. char *buf) {
  360. struct acpi_device *acpi_dev = to_acpi_device(dev);
  361. int result;
  362. if (acpi_dev->pnp.str_obj == NULL)
  363. return 0;
  364. /*
  365. * The _STR object contains a Unicode identifier for a device.
  366. * We need to convert to utf-8 so it can be displayed.
  367. */
  368. result = utf16s_to_utf8s(
  369. (wchar_t *)acpi_dev->pnp.str_obj->buffer.pointer,
  370. acpi_dev->pnp.str_obj->buffer.length,
  371. UTF16_LITTLE_ENDIAN, buf,
  372. PAGE_SIZE);
  373. buf[result++] = '\n';
  374. return result;
  375. }
  376. static DEVICE_ATTR(description, 0444, description_show, NULL);
  377. static ssize_t
  378. acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
  379. char *buf) {
  380. struct acpi_device *acpi_dev = to_acpi_device(dev);
  381. acpi_status status;
  382. unsigned long long sun;
  383. status = acpi_evaluate_integer(acpi_dev->handle, "_SUN", NULL, &sun);
  384. if (ACPI_FAILURE(status))
  385. return -EIO;
  386. return sprintf(buf, "%llu\n", sun);
  387. }
  388. static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
  389. static ssize_t
  390. acpi_device_hrv_show(struct device *dev, struct device_attribute *attr,
  391. char *buf) {
  392. struct acpi_device *acpi_dev = to_acpi_device(dev);
  393. acpi_status status;
  394. unsigned long long hrv;
  395. status = acpi_evaluate_integer(acpi_dev->handle, "_HRV", NULL, &hrv);
  396. if (ACPI_FAILURE(status))
  397. return -EIO;
  398. return sprintf(buf, "%llu\n", hrv);
  399. }
  400. static DEVICE_ATTR(hrv, 0444, acpi_device_hrv_show, NULL);
  401. static ssize_t status_show(struct device *dev, struct device_attribute *attr,
  402. char *buf) {
  403. struct acpi_device *acpi_dev = to_acpi_device(dev);
  404. acpi_status status;
  405. unsigned long long sta;
  406. status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta);
  407. if (ACPI_FAILURE(status))
  408. return -EIO;
  409. return sprintf(buf, "%llu\n", sta);
  410. }
  411. static DEVICE_ATTR_RO(status);
  412. /**
  413. * acpi_device_setup_files - Create sysfs attributes of an ACPI device.
  414. * @dev: ACPI device object.
  415. */
  416. int acpi_device_setup_files(struct acpi_device *dev)
  417. {
  418. struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
  419. acpi_status status;
  420. int result = 0;
  421. /*
  422. * Devices gotten from FADT don't have a "path" attribute
  423. */
  424. if (dev->handle) {
  425. result = device_create_file(&dev->dev, &dev_attr_path);
  426. if (result)
  427. goto end;
  428. }
  429. if (!list_empty(&dev->pnp.ids)) {
  430. result = device_create_file(&dev->dev, &dev_attr_hid);
  431. if (result)
  432. goto end;
  433. result = device_create_file(&dev->dev, &dev_attr_modalias);
  434. if (result)
  435. goto end;
  436. }
  437. /*
  438. * If device has _STR, 'description' file is created
  439. */
  440. if (acpi_has_method(dev->handle, "_STR")) {
  441. status = acpi_evaluate_object(dev->handle, "_STR",
  442. NULL, &buffer);
  443. if (ACPI_FAILURE(status))
  444. buffer.pointer = NULL;
  445. dev->pnp.str_obj = buffer.pointer;
  446. result = device_create_file(&dev->dev, &dev_attr_description);
  447. if (result)
  448. goto end;
  449. }
  450. if (dev->pnp.type.bus_address)
  451. result = device_create_file(&dev->dev, &dev_attr_adr);
  452. if (dev->pnp.unique_id)
  453. result = device_create_file(&dev->dev, &dev_attr_uid);
  454. if (acpi_has_method(dev->handle, "_SUN")) {
  455. result = device_create_file(&dev->dev, &dev_attr_sun);
  456. if (result)
  457. goto end;
  458. }
  459. if (acpi_has_method(dev->handle, "_HRV")) {
  460. result = device_create_file(&dev->dev, &dev_attr_hrv);
  461. if (result)
  462. goto end;
  463. }
  464. if (acpi_has_method(dev->handle, "_STA")) {
  465. result = device_create_file(&dev->dev, &dev_attr_status);
  466. if (result)
  467. goto end;
  468. }
  469. /*
  470. * If device has _EJ0, 'eject' file is created that is used to trigger
  471. * hot-removal function from userland.
  472. */
  473. if (acpi_has_method(dev->handle, "_EJ0")) {
  474. result = device_create_file(&dev->dev, &dev_attr_eject);
  475. if (result)
  476. return result;
  477. }
  478. if (dev->flags.power_manageable) {
  479. result = device_create_file(&dev->dev, &dev_attr_power_state);
  480. if (result)
  481. return result;
  482. if (dev->power.flags.power_resources)
  483. result = device_create_file(&dev->dev,
  484. &dev_attr_real_power_state);
  485. }
  486. acpi_expose_nondev_subnodes(&dev->dev.kobj, &dev->data);
  487. end:
  488. return result;
  489. }
  490. /**
  491. * acpi_device_remove_files - Remove sysfs attributes of an ACPI device.
  492. * @dev: ACPI device object.
  493. */
  494. void acpi_device_remove_files(struct acpi_device *dev)
  495. {
  496. acpi_hide_nondev_subnodes(&dev->data);
  497. if (dev->flags.power_manageable) {
  498. device_remove_file(&dev->dev, &dev_attr_power_state);
  499. if (dev->power.flags.power_resources)
  500. device_remove_file(&dev->dev,
  501. &dev_attr_real_power_state);
  502. }
  503. /*
  504. * If device has _STR, remove 'description' file
  505. */
  506. if (acpi_has_method(dev->handle, "_STR")) {
  507. kfree(dev->pnp.str_obj);
  508. device_remove_file(&dev->dev, &dev_attr_description);
  509. }
  510. /*
  511. * If device has _EJ0, remove 'eject' file.
  512. */
  513. if (acpi_has_method(dev->handle, "_EJ0"))
  514. device_remove_file(&dev->dev, &dev_attr_eject);
  515. if (acpi_has_method(dev->handle, "_SUN"))
  516. device_remove_file(&dev->dev, &dev_attr_sun);
  517. if (acpi_has_method(dev->handle, "_HRV"))
  518. device_remove_file(&dev->dev, &dev_attr_hrv);
  519. if (dev->pnp.unique_id)
  520. device_remove_file(&dev->dev, &dev_attr_uid);
  521. if (dev->pnp.type.bus_address)
  522. device_remove_file(&dev->dev, &dev_attr_adr);
  523. device_remove_file(&dev->dev, &dev_attr_modalias);
  524. device_remove_file(&dev->dev, &dev_attr_hid);
  525. if (acpi_has_method(dev->handle, "_STA"))
  526. device_remove_file(&dev->dev, &dev_attr_status);
  527. if (dev->handle)
  528. device_remove_file(&dev->dev, &dev_attr_path);
  529. }