device_sysfs.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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. /* Avoid unnecessarily loading modules for non present devices. */
  125. if (!acpi_device_is_present(acpi_dev))
  126. return 0;
  127. /*
  128. * Since we skip ACPI_DT_NAMESPACE_HID from the modalias below, 0 should
  129. * be returned if ACPI_DT_NAMESPACE_HID is the only ACPI/PNP ID in the
  130. * device's list.
  131. */
  132. count = 0;
  133. list_for_each_entry(id, &acpi_dev->pnp.ids, list)
  134. if (strcmp(id->id, ACPI_DT_NAMESPACE_HID))
  135. count++;
  136. if (!count)
  137. return 0;
  138. len = snprintf(modalias, size, "acpi:");
  139. if (len <= 0)
  140. return len;
  141. size -= len;
  142. list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
  143. if (!strcmp(id->id, ACPI_DT_NAMESPACE_HID))
  144. continue;
  145. count = snprintf(&modalias[len], size, "%s:", id->id);
  146. if (count < 0)
  147. return -EINVAL;
  148. if (count >= size)
  149. return -ENOMEM;
  150. len += count;
  151. size -= count;
  152. }
  153. modalias[len] = '\0';
  154. return len;
  155. }
  156. /**
  157. * create_of_modalias - Creates DT compatible string for modalias and uevent
  158. * @acpi_dev: ACPI device object.
  159. * @modalias: Buffer to print into.
  160. * @size: Size of the buffer.
  161. *
  162. * Expose DT compatible modalias as of:NnameTCcompatible. This function should
  163. * only be called for devices having ACPI_DT_NAMESPACE_HID in their list of
  164. * ACPI/PNP IDs.
  165. */
  166. static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,
  167. int size)
  168. {
  169. struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
  170. const union acpi_object *of_compatible, *obj;
  171. int len, count;
  172. int i, nval;
  173. char *c;
  174. acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
  175. /* DT strings are all in lower case */
  176. for (c = buf.pointer; *c != '\0'; c++)
  177. *c = tolower(*c);
  178. len = snprintf(modalias, size, "of:N%sT", (char *)buf.pointer);
  179. ACPI_FREE(buf.pointer);
  180. if (len <= 0)
  181. return len;
  182. of_compatible = acpi_dev->data.of_compatible;
  183. if (of_compatible->type == ACPI_TYPE_PACKAGE) {
  184. nval = of_compatible->package.count;
  185. obj = of_compatible->package.elements;
  186. } else { /* Must be ACPI_TYPE_STRING. */
  187. nval = 1;
  188. obj = of_compatible;
  189. }
  190. for (i = 0; i < nval; i++, obj++) {
  191. count = snprintf(&modalias[len], size, "C%s",
  192. obj->string.pointer);
  193. if (count < 0)
  194. return -EINVAL;
  195. if (count >= size)
  196. return -ENOMEM;
  197. len += count;
  198. size -= count;
  199. }
  200. modalias[len] = '\0';
  201. return len;
  202. }
  203. int __acpi_device_uevent_modalias(struct acpi_device *adev,
  204. struct kobj_uevent_env *env)
  205. {
  206. int len;
  207. if (!adev)
  208. return -ENODEV;
  209. if (list_empty(&adev->pnp.ids))
  210. return 0;
  211. if (add_uevent_var(env, "MODALIAS="))
  212. return -ENOMEM;
  213. len = create_pnp_modalias(adev, &env->buf[env->buflen - 1],
  214. sizeof(env->buf) - env->buflen);
  215. if (len < 0)
  216. return len;
  217. env->buflen += len;
  218. if (!adev->data.of_compatible)
  219. return 0;
  220. if (len > 0 && add_uevent_var(env, "MODALIAS="))
  221. return -ENOMEM;
  222. len = create_of_modalias(adev, &env->buf[env->buflen - 1],
  223. sizeof(env->buf) - env->buflen);
  224. if (len < 0)
  225. return len;
  226. env->buflen += len;
  227. return 0;
  228. }
  229. /**
  230. * acpi_device_uevent_modalias - uevent modalias for ACPI-enumerated devices.
  231. *
  232. * Create the uevent modalias field for ACPI-enumerated devices.
  233. *
  234. * Because other buses do not support ACPI HIDs & CIDs, e.g. for a device with
  235. * hid:IBM0001 and cid:ACPI0001 you get: "acpi:IBM0001:ACPI0001".
  236. */
  237. int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
  238. {
  239. return __acpi_device_uevent_modalias(acpi_companion_match(dev), env);
  240. }
  241. EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
  242. static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
  243. {
  244. int len, count;
  245. if (!adev)
  246. return -ENODEV;
  247. if (list_empty(&adev->pnp.ids))
  248. return 0;
  249. len = create_pnp_modalias(adev, buf, size - 1);
  250. if (len < 0) {
  251. return len;
  252. } else if (len > 0) {
  253. buf[len++] = '\n';
  254. size -= len;
  255. }
  256. if (!adev->data.of_compatible)
  257. return len;
  258. count = create_of_modalias(adev, buf + len, size - 1);
  259. if (count < 0) {
  260. return count;
  261. } else if (count > 0) {
  262. len += count;
  263. buf[len++] = '\n';
  264. }
  265. return len;
  266. }
  267. /**
  268. * acpi_device_modalias - modalias sysfs attribute for ACPI-enumerated devices.
  269. *
  270. * Create the modalias sysfs attribute for ACPI-enumerated devices.
  271. *
  272. * Because other buses do not support ACPI HIDs & CIDs, e.g. for a device with
  273. * hid:IBM0001 and cid:ACPI0001 you get: "acpi:IBM0001:ACPI0001".
  274. */
  275. int acpi_device_modalias(struct device *dev, char *buf, int size)
  276. {
  277. return __acpi_device_modalias(acpi_companion_match(dev), buf, size);
  278. }
  279. EXPORT_SYMBOL_GPL(acpi_device_modalias);
  280. static ssize_t
  281. acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
  282. {
  283. return __acpi_device_modalias(to_acpi_device(dev), buf, 1024);
  284. }
  285. static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
  286. static ssize_t real_power_state_show(struct device *dev,
  287. struct device_attribute *attr, char *buf)
  288. {
  289. struct acpi_device *adev = to_acpi_device(dev);
  290. int state;
  291. int ret;
  292. ret = acpi_device_get_power(adev, &state);
  293. if (ret)
  294. return ret;
  295. return sprintf(buf, "%s\n", acpi_power_state_string(state));
  296. }
  297. static DEVICE_ATTR(real_power_state, 0444, real_power_state_show, NULL);
  298. static ssize_t power_state_show(struct device *dev,
  299. struct device_attribute *attr, char *buf)
  300. {
  301. struct acpi_device *adev = to_acpi_device(dev);
  302. return sprintf(buf, "%s\n", acpi_power_state_string(adev->power.state));
  303. }
  304. static DEVICE_ATTR(power_state, 0444, power_state_show, NULL);
  305. static ssize_t
  306. acpi_eject_store(struct device *d, struct device_attribute *attr,
  307. const char *buf, size_t count)
  308. {
  309. struct acpi_device *acpi_device = to_acpi_device(d);
  310. acpi_object_type not_used;
  311. acpi_status status;
  312. if (!count || buf[0] != '1')
  313. return -EINVAL;
  314. if ((!acpi_device->handler || !acpi_device->handler->hotplug.enabled)
  315. && !acpi_device->driver)
  316. return -ENODEV;
  317. status = acpi_get_type(acpi_device->handle, &not_used);
  318. if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable)
  319. return -ENODEV;
  320. get_device(&acpi_device->dev);
  321. status = acpi_hotplug_schedule(acpi_device, ACPI_OST_EC_OSPM_EJECT);
  322. if (ACPI_SUCCESS(status))
  323. return count;
  324. put_device(&acpi_device->dev);
  325. acpi_evaluate_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
  326. ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL);
  327. return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN;
  328. }
  329. static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
  330. static ssize_t
  331. acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf)
  332. {
  333. struct acpi_device *acpi_dev = to_acpi_device(dev);
  334. return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev));
  335. }
  336. static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
  337. static ssize_t acpi_device_uid_show(struct device *dev,
  338. struct device_attribute *attr, char *buf)
  339. {
  340. struct acpi_device *acpi_dev = to_acpi_device(dev);
  341. return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
  342. }
  343. static DEVICE_ATTR(uid, 0444, acpi_device_uid_show, NULL);
  344. static ssize_t acpi_device_adr_show(struct device *dev,
  345. struct device_attribute *attr, char *buf)
  346. {
  347. struct acpi_device *acpi_dev = to_acpi_device(dev);
  348. return sprintf(buf, "0x%08x\n",
  349. (unsigned int)(acpi_dev->pnp.bus_address));
  350. }
  351. static DEVICE_ATTR(adr, 0444, acpi_device_adr_show, NULL);
  352. static ssize_t acpi_device_path_show(struct device *dev,
  353. struct device_attribute *attr, char *buf)
  354. {
  355. struct acpi_device *acpi_dev = to_acpi_device(dev);
  356. return acpi_object_path(acpi_dev->handle, buf);
  357. }
  358. static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL);
  359. /* sysfs file that shows description text from the ACPI _STR method */
  360. static ssize_t description_show(struct device *dev,
  361. struct device_attribute *attr,
  362. char *buf) {
  363. struct acpi_device *acpi_dev = to_acpi_device(dev);
  364. int result;
  365. if (acpi_dev->pnp.str_obj == NULL)
  366. return 0;
  367. /*
  368. * The _STR object contains a Unicode identifier for a device.
  369. * We need to convert to utf-8 so it can be displayed.
  370. */
  371. result = utf16s_to_utf8s(
  372. (wchar_t *)acpi_dev->pnp.str_obj->buffer.pointer,
  373. acpi_dev->pnp.str_obj->buffer.length,
  374. UTF16_LITTLE_ENDIAN, buf,
  375. PAGE_SIZE);
  376. buf[result++] = '\n';
  377. return result;
  378. }
  379. static DEVICE_ATTR(description, 0444, description_show, NULL);
  380. static ssize_t
  381. acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
  382. char *buf) {
  383. struct acpi_device *acpi_dev = to_acpi_device(dev);
  384. acpi_status status;
  385. unsigned long long sun;
  386. status = acpi_evaluate_integer(acpi_dev->handle, "_SUN", NULL, &sun);
  387. if (ACPI_FAILURE(status))
  388. return -EIO;
  389. return sprintf(buf, "%llu\n", sun);
  390. }
  391. static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
  392. static ssize_t
  393. acpi_device_hrv_show(struct device *dev, struct device_attribute *attr,
  394. char *buf) {
  395. struct acpi_device *acpi_dev = to_acpi_device(dev);
  396. acpi_status status;
  397. unsigned long long hrv;
  398. status = acpi_evaluate_integer(acpi_dev->handle, "_HRV", NULL, &hrv);
  399. if (ACPI_FAILURE(status))
  400. return -EIO;
  401. return sprintf(buf, "%llu\n", hrv);
  402. }
  403. static DEVICE_ATTR(hrv, 0444, acpi_device_hrv_show, NULL);
  404. static ssize_t status_show(struct device *dev, struct device_attribute *attr,
  405. char *buf) {
  406. struct acpi_device *acpi_dev = to_acpi_device(dev);
  407. acpi_status status;
  408. unsigned long long sta;
  409. status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta);
  410. if (ACPI_FAILURE(status))
  411. return -EIO;
  412. return sprintf(buf, "%llu\n", sta);
  413. }
  414. static DEVICE_ATTR_RO(status);
  415. /**
  416. * acpi_device_setup_files - Create sysfs attributes of an ACPI device.
  417. * @dev: ACPI device object.
  418. */
  419. int acpi_device_setup_files(struct acpi_device *dev)
  420. {
  421. struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
  422. acpi_status status;
  423. int result = 0;
  424. /*
  425. * Devices gotten from FADT don't have a "path" attribute
  426. */
  427. if (dev->handle) {
  428. result = device_create_file(&dev->dev, &dev_attr_path);
  429. if (result)
  430. goto end;
  431. }
  432. if (!list_empty(&dev->pnp.ids)) {
  433. result = device_create_file(&dev->dev, &dev_attr_hid);
  434. if (result)
  435. goto end;
  436. result = device_create_file(&dev->dev, &dev_attr_modalias);
  437. if (result)
  438. goto end;
  439. }
  440. /*
  441. * If device has _STR, 'description' file is created
  442. */
  443. if (acpi_has_method(dev->handle, "_STR")) {
  444. status = acpi_evaluate_object(dev->handle, "_STR",
  445. NULL, &buffer);
  446. if (ACPI_FAILURE(status))
  447. buffer.pointer = NULL;
  448. dev->pnp.str_obj = buffer.pointer;
  449. result = device_create_file(&dev->dev, &dev_attr_description);
  450. if (result)
  451. goto end;
  452. }
  453. if (dev->pnp.type.bus_address)
  454. result = device_create_file(&dev->dev, &dev_attr_adr);
  455. if (dev->pnp.unique_id)
  456. result = device_create_file(&dev->dev, &dev_attr_uid);
  457. if (acpi_has_method(dev->handle, "_SUN")) {
  458. result = device_create_file(&dev->dev, &dev_attr_sun);
  459. if (result)
  460. goto end;
  461. }
  462. if (acpi_has_method(dev->handle, "_HRV")) {
  463. result = device_create_file(&dev->dev, &dev_attr_hrv);
  464. if (result)
  465. goto end;
  466. }
  467. if (acpi_has_method(dev->handle, "_STA")) {
  468. result = device_create_file(&dev->dev, &dev_attr_status);
  469. if (result)
  470. goto end;
  471. }
  472. /*
  473. * If device has _EJ0, 'eject' file is created that is used to trigger
  474. * hot-removal function from userland.
  475. */
  476. if (acpi_has_method(dev->handle, "_EJ0")) {
  477. result = device_create_file(&dev->dev, &dev_attr_eject);
  478. if (result)
  479. return result;
  480. }
  481. if (dev->flags.power_manageable) {
  482. result = device_create_file(&dev->dev, &dev_attr_power_state);
  483. if (result)
  484. return result;
  485. if (dev->power.flags.power_resources)
  486. result = device_create_file(&dev->dev,
  487. &dev_attr_real_power_state);
  488. }
  489. acpi_expose_nondev_subnodes(&dev->dev.kobj, &dev->data);
  490. end:
  491. return result;
  492. }
  493. /**
  494. * acpi_device_remove_files - Remove sysfs attributes of an ACPI device.
  495. * @dev: ACPI device object.
  496. */
  497. void acpi_device_remove_files(struct acpi_device *dev)
  498. {
  499. acpi_hide_nondev_subnodes(&dev->data);
  500. if (dev->flags.power_manageable) {
  501. device_remove_file(&dev->dev, &dev_attr_power_state);
  502. if (dev->power.flags.power_resources)
  503. device_remove_file(&dev->dev,
  504. &dev_attr_real_power_state);
  505. }
  506. /*
  507. * If device has _STR, remove 'description' file
  508. */
  509. if (acpi_has_method(dev->handle, "_STR")) {
  510. kfree(dev->pnp.str_obj);
  511. device_remove_file(&dev->dev, &dev_attr_description);
  512. }
  513. /*
  514. * If device has _EJ0, remove 'eject' file.
  515. */
  516. if (acpi_has_method(dev->handle, "_EJ0"))
  517. device_remove_file(&dev->dev, &dev_attr_eject);
  518. if (acpi_has_method(dev->handle, "_SUN"))
  519. device_remove_file(&dev->dev, &dev_attr_sun);
  520. if (acpi_has_method(dev->handle, "_HRV"))
  521. device_remove_file(&dev->dev, &dev_attr_hrv);
  522. if (dev->pnp.unique_id)
  523. device_remove_file(&dev->dev, &dev_attr_uid);
  524. if (dev->pnp.type.bus_address)
  525. device_remove_file(&dev->dev, &dev_attr_adr);
  526. device_remove_file(&dev->dev, &dev_attr_modalias);
  527. device_remove_file(&dev->dev, &dev_attr_hid);
  528. if (acpi_has_method(dev->handle, "_STA"))
  529. device_remove_file(&dev->dev, &dev_attr_status);
  530. if (dev->handle)
  531. device_remove_file(&dev->dev, &dev_attr_path);
  532. }