Merge tag 'vfs-6.9.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[linux-2.6-block.git] / drivers / acpi / device_sysfs.c
CommitLineData
1802d0be 1// SPDX-License-Identifier: GPL-2.0-only
c2efefb3
RW
2/*
3 * drivers/acpi/device_sysfs.c - ACPI device sysfs attributes and modalias.
4 *
5 * Copyright (C) 2015, Intel Corp.
6 * Author: Mika Westerberg <mika.westerberg@linux.intel.com>
7 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
8 *
9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 *
c2efefb3
RW
11 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 */
13
14#include <linux/acpi.h>
15#include <linux/device.h>
16#include <linux/export.h>
17#include <linux/nls.h>
18
19#include "internal.h"
20
263b4c1a
RW
21static ssize_t acpi_object_path(acpi_handle handle, char *buf)
22{
23 struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL};
24 int result;
25
26 result = acpi_get_name(handle, ACPI_FULL_PATHNAME, &path);
27 if (result)
28 return result;
29
a508d954 30 result = sprintf(buf, "%s\n", (char *)path.pointer);
263b4c1a
RW
31 kfree(path.pointer);
32 return result;
33}
34
35struct acpi_data_node_attr {
36 struct attribute attr;
37 ssize_t (*show)(struct acpi_data_node *, char *);
38 ssize_t (*store)(struct acpi_data_node *, const char *, size_t count);
39};
40
41#define DATA_NODE_ATTR(_name) \
42 static struct acpi_data_node_attr data_node_##_name = \
43 __ATTR(_name, 0444, data_node_show_##_name, NULL)
44
45static ssize_t data_node_show_path(struct acpi_data_node *dn, char *buf)
46{
99db5ff7 47 return dn->handle ? acpi_object_path(dn->handle, buf) : 0;
263b4c1a
RW
48}
49
50DATA_NODE_ATTR(path);
51
52static struct attribute *acpi_data_node_default_attrs[] = {
53 &data_node_path.attr,
54 NULL
55};
17f18417 56ATTRIBUTE_GROUPS(acpi_data_node_default);
263b4c1a
RW
57
58#define to_data_node(k) container_of(k, struct acpi_data_node, kobj)
59#define to_attr(a) container_of(a, struct acpi_data_node_attr, attr)
60
61static ssize_t acpi_data_node_attr_show(struct kobject *kobj,
62 struct attribute *attr, char *buf)
63{
64 struct acpi_data_node *dn = to_data_node(kobj);
65 struct acpi_data_node_attr *dn_attr = to_attr(attr);
66
67 return dn_attr->show ? dn_attr->show(dn, buf) : -ENXIO;
68}
69
70static const struct sysfs_ops acpi_data_node_sysfs_ops = {
71 .show = acpi_data_node_attr_show,
72};
73
74static void acpi_data_node_release(struct kobject *kobj)
75{
76 struct acpi_data_node *dn = to_data_node(kobj);
d0fb66e9 77
263b4c1a
RW
78 complete(&dn->kobj_done);
79}
80
a527b011 81static const struct kobj_type acpi_data_node_ktype = {
263b4c1a 82 .sysfs_ops = &acpi_data_node_sysfs_ops,
17f18417 83 .default_groups = acpi_data_node_default_groups,
263b4c1a
RW
84 .release = acpi_data_node_release,
85};
86
87static void acpi_expose_nondev_subnodes(struct kobject *kobj,
88 struct acpi_device_data *data)
89{
90 struct list_head *list = &data->subnodes;
91 struct acpi_data_node *dn;
92
93 if (list_empty(list))
94 return;
95
96 list_for_each_entry(dn, list, sibling) {
97 int ret;
98
99 init_completion(&dn->kobj_done);
100 ret = kobject_init_and_add(&dn->kobj, &acpi_data_node_ktype,
9db22d92 101 kobj, "%s", dn->name);
99db5ff7 102 if (!ret)
263b4c1a 103 acpi_expose_nondev_subnodes(&dn->kobj, &dn->data);
99db5ff7
RW
104 else if (dn->handle)
105 acpi_handle_err(dn->handle, "Failed to expose (%d)\n", ret);
263b4c1a
RW
106 }
107}
108
109static void acpi_hide_nondev_subnodes(struct acpi_device_data *data)
110{
111 struct list_head *list = &data->subnodes;
112 struct acpi_data_node *dn;
113
114 if (list_empty(list))
115 return;
116
117 list_for_each_entry_reverse(dn, list, sibling) {
118 acpi_hide_nondev_subnodes(&dn->data);
119 kobject_put(&dn->kobj);
120 }
121}
122
c2efefb3
RW
123/**
124 * create_pnp_modalias - Create hid/cid(s) string for modalias and uevent
125 * @acpi_dev: ACPI device object.
126 * @modalias: Buffer to print into.
127 * @size: Size of the buffer.
128 *
129 * Creates hid/cid(s) string needed for modalias and uevent
130 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get:
131 * char *modalias: "acpi:IBM0001:ACPI0001"
132 * Return: 0: no _HID and no _CID
133 * -EINVAL: output error
134 * -ENOMEM: output is truncated
d0fb66e9 135 */
162736b0 136static int create_pnp_modalias(const struct acpi_device *acpi_dev, char *modalias,
c2efefb3
RW
137 int size)
138{
139 int len;
140 int count;
141 struct acpi_hardware_id *id;
142
10809bb9
HG
143 /* Avoid unnecessarily loading modules for non present devices. */
144 if (!acpi_device_is_present(acpi_dev))
145 return 0;
146
c2efefb3
RW
147 /*
148 * Since we skip ACPI_DT_NAMESPACE_HID from the modalias below, 0 should
149 * be returned if ACPI_DT_NAMESPACE_HID is the only ACPI/PNP ID in the
150 * device's list.
151 */
152 count = 0;
153 list_for_each_entry(id, &acpi_dev->pnp.ids, list)
154 if (strcmp(id->id, ACPI_DT_NAMESPACE_HID))
155 count++;
156
157 if (!count)
158 return 0;
159
160 len = snprintf(modalias, size, "acpi:");
48cf49d3
CJ
161 if (len >= size)
162 return -ENOMEM;
c2efefb3
RW
163
164 size -= len;
165
166 list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
167 if (!strcmp(id->id, ACPI_DT_NAMESPACE_HID))
168 continue;
169
170 count = snprintf(&modalias[len], size, "%s:", id->id);
c2efefb3
RW
171
172 if (count >= size)
173 return -ENOMEM;
174
175 len += count;
176 size -= count;
177 }
bc8f7abe 178
c2efefb3
RW
179 return len;
180}
181
182/**
183 * create_of_modalias - Creates DT compatible string for modalias and uevent
184 * @acpi_dev: ACPI device object.
185 * @modalias: Buffer to print into.
186 * @size: Size of the buffer.
187 *
188 * Expose DT compatible modalias as of:NnameTCcompatible. This function should
189 * only be called for devices having ACPI_DT_NAMESPACE_HID in their list of
190 * ACPI/PNP IDs.
191 */
162736b0 192static int create_of_modalias(const struct acpi_device *acpi_dev, char *modalias,
c2efefb3
RW
193 int size)
194{
195 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
196 const union acpi_object *of_compatible, *obj;
f16eb8a4 197 acpi_status status;
c2efefb3
RW
198 int len, count;
199 int i, nval;
200 char *c;
201
f16eb8a4
AS
202 status = acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
203 if (ACPI_FAILURE(status))
204 return -ENODEV;
205
c2efefb3
RW
206 /* DT strings are all in lower case */
207 for (c = buf.pointer; *c != '\0'; c++)
208 *c = tolower(*c);
209
210 len = snprintf(modalias, size, "of:N%sT", (char *)buf.pointer);
211 ACPI_FREE(buf.pointer);
212
48cf49d3
CJ
213 if (len >= size)
214 return -ENOMEM;
215
216 size -= len;
c2efefb3
RW
217
218 of_compatible = acpi_dev->data.of_compatible;
219 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
220 nval = of_compatible->package.count;
221 obj = of_compatible->package.elements;
222 } else { /* Must be ACPI_TYPE_STRING. */
223 nval = 1;
224 obj = of_compatible;
225 }
226 for (i = 0; i < nval; i++, obj++) {
227 count = snprintf(&modalias[len], size, "C%s",
228 obj->string.pointer);
c2efefb3
RW
229
230 if (count >= size)
231 return -ENOMEM;
232
233 len += count;
234 size -= count;
235 }
bc8f7abe 236
c2efefb3
RW
237 return len;
238}
239
162736b0 240int __acpi_device_uevent_modalias(const struct acpi_device *adev,
c2efefb3
RW
241 struct kobj_uevent_env *env)
242{
243 int len;
244
245 if (!adev)
246 return -ENODEV;
247
248 if (list_empty(&adev->pnp.ids))
249 return 0;
250
251 if (add_uevent_var(env, "MODALIAS="))
252 return -ENOMEM;
253
36af2d5c
KHF
254 if (adev->data.of_compatible)
255 len = create_of_modalias(adev, &env->buf[env->buflen - 1],
256 sizeof(env->buf) - env->buflen);
257 else
258 len = create_pnp_modalias(adev, &env->buf[env->buflen - 1],
259 sizeof(env->buf) - env->buflen);
c2efefb3
RW
260 if (len < 0)
261 return len;
262
263 env->buflen += len;
264
265 return 0;
266}
267
268/**
269 * acpi_device_uevent_modalias - uevent modalias for ACPI-enumerated devices.
6f2f92c6
BL
270 * @dev: Struct device to get ACPI device node.
271 * @env: Environment variables of the kobject uevent.
c2efefb3
RW
272 *
273 * Create the uevent modalias field for ACPI-enumerated devices.
274 *
275 * Because other buses do not support ACPI HIDs & CIDs, e.g. for a device with
276 * hid:IBM0001 and cid:ACPI0001 you get: "acpi:IBM0001:ACPI0001".
277 */
162736b0 278int acpi_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env)
c2efefb3
RW
279{
280 return __acpi_device_uevent_modalias(acpi_companion_match(dev), env);
281}
282EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
283
86fca926 284static int __acpi_device_modalias(const struct acpi_device *adev, char *buf, int size)
c2efefb3
RW
285{
286 int len, count;
287
288 if (!adev)
289 return -ENODEV;
290
291 if (list_empty(&adev->pnp.ids))
292 return 0;
293
294 len = create_pnp_modalias(adev, buf, size - 1);
295 if (len < 0) {
296 return len;
297 } else if (len > 0) {
298 buf[len++] = '\n';
299 size -= len;
300 }
301 if (!adev->data.of_compatible)
302 return len;
303
304 count = create_of_modalias(adev, buf + len, size - 1);
305 if (count < 0) {
306 return count;
307 } else if (count > 0) {
308 len += count;
309 buf[len++] = '\n';
310 }
311
312 return len;
313}
314
315/**
316 * acpi_device_modalias - modalias sysfs attribute for ACPI-enumerated devices.
6f2f92c6
BL
317 * @dev: Struct device to get ACPI device node.
318 * @buf: The buffer to save pnp_modalias and of_modalias.
319 * @size: Size of buffer.
c2efefb3
RW
320 *
321 * Create the modalias sysfs attribute for ACPI-enumerated devices.
322 *
323 * Because other buses do not support ACPI HIDs & CIDs, e.g. for a device with
324 * hid:IBM0001 and cid:ACPI0001 you get: "acpi:IBM0001:ACPI0001".
325 */
326int acpi_device_modalias(struct device *dev, char *buf, int size)
327{
328 return __acpi_device_modalias(acpi_companion_match(dev), buf, size);
329}
330EXPORT_SYMBOL_GPL(acpi_device_modalias);
331
332static ssize_t
0f39ee83 333modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
a508d954 334{
c2efefb3
RW
335 return __acpi_device_modalias(to_acpi_device(dev), buf, 1024);
336}
0f39ee83 337static DEVICE_ATTR_RO(modalias);
c2efefb3
RW
338
339static ssize_t real_power_state_show(struct device *dev,
340 struct device_attribute *attr, char *buf)
341{
342 struct acpi_device *adev = to_acpi_device(dev);
343 int state;
344 int ret;
345
346 ret = acpi_device_get_power(adev, &state);
347 if (ret)
348 return ret;
349
350 return sprintf(buf, "%s\n", acpi_power_state_string(state));
351}
352
c828a892 353static DEVICE_ATTR_RO(real_power_state);
c2efefb3
RW
354
355static ssize_t power_state_show(struct device *dev,
356 struct device_attribute *attr, char *buf)
357{
358 struct acpi_device *adev = to_acpi_device(dev);
359
360 return sprintf(buf, "%s\n", acpi_power_state_string(adev->power.state));
361}
362
c828a892 363static DEVICE_ATTR_RO(power_state);
c2efefb3
RW
364
365static ssize_t
0f39ee83
DR
366eject_store(struct device *d, struct device_attribute *attr,
367 const char *buf, size_t count)
c2efefb3
RW
368{
369 struct acpi_device *acpi_device = to_acpi_device(d);
370 acpi_object_type not_used;
371 acpi_status status;
372
373 if (!count || buf[0] != '1')
374 return -EINVAL;
375
376 if ((!acpi_device->handler || !acpi_device->handler->hotplug.enabled)
d6fb6ee1 377 && !d->driver)
c2efefb3
RW
378 return -ENODEV;
379
380 status = acpi_get_type(acpi_device->handle, &not_used);
381 if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable)
382 return -ENODEV;
383
4cbaba4e 384 acpi_dev_get(acpi_device);
c2efefb3
RW
385 status = acpi_hotplug_schedule(acpi_device, ACPI_OST_EC_OSPM_EJECT);
386 if (ACPI_SUCCESS(status))
387 return count;
388
4cbaba4e 389 acpi_dev_put(acpi_device);
c2efefb3
RW
390 acpi_evaluate_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
391 ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL);
392 return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN;
393}
394
0f39ee83 395static DEVICE_ATTR_WO(eject);
c2efefb3
RW
396
397static ssize_t
0f39ee83 398hid_show(struct device *dev, struct device_attribute *attr, char *buf)
a508d954 399{
c2efefb3
RW
400 struct acpi_device *acpi_dev = to_acpi_device(dev);
401
402 return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev));
403}
0f39ee83 404static DEVICE_ATTR_RO(hid);
c2efefb3 405
0f39ee83
DR
406static ssize_t uid_show(struct device *dev,
407 struct device_attribute *attr, char *buf)
c2efefb3
RW
408{
409 struct acpi_device *acpi_dev = to_acpi_device(dev);
410
5f70fd18 411 return sprintf(buf, "%s\n", acpi_device_uid(acpi_dev));
c2efefb3 412}
0f39ee83 413static DEVICE_ATTR_RO(uid);
c2efefb3 414
0f39ee83
DR
415static ssize_t adr_show(struct device *dev,
416 struct device_attribute *attr, char *buf)
c2efefb3
RW
417{
418 struct acpi_device *acpi_dev = to_acpi_device(dev);
419
ca6f998c
PLB
420 if (acpi_dev->pnp.bus_address > U32_MAX)
421 return sprintf(buf, "0x%016llx\n", acpi_dev->pnp.bus_address);
422 else
423 return sprintf(buf, "0x%08llx\n", acpi_dev->pnp.bus_address);
c2efefb3 424}
0f39ee83 425static DEVICE_ATTR_RO(adr);
c2efefb3 426
0f39ee83
DR
427static ssize_t path_show(struct device *dev,
428 struct device_attribute *attr, char *buf)
263b4c1a 429{
c2efefb3 430 struct acpi_device *acpi_dev = to_acpi_device(dev);
c2efefb3 431
263b4c1a 432 return acpi_object_path(acpi_dev->handle, buf);
c2efefb3 433}
0f39ee83 434static DEVICE_ATTR_RO(path);
c2efefb3
RW
435
436/* sysfs file that shows description text from the ACPI _STR method */
437static ssize_t description_show(struct device *dev,
438 struct device_attribute *attr,
d0fb66e9
XT
439 char *buf)
440{
c2efefb3
RW
441 struct acpi_device *acpi_dev = to_acpi_device(dev);
442 int result;
443
444 if (acpi_dev->pnp.str_obj == NULL)
445 return 0;
446
447 /*
448 * The _STR object contains a Unicode identifier for a device.
449 * We need to convert to utf-8 so it can be displayed.
450 */
451 result = utf16s_to_utf8s(
452 (wchar_t *)acpi_dev->pnp.str_obj->buffer.pointer,
453 acpi_dev->pnp.str_obj->buffer.length,
454 UTF16_LITTLE_ENDIAN, buf,
888be606 455 PAGE_SIZE - 1);
c2efefb3
RW
456
457 buf[result++] = '\n';
458
459 return result;
460}
c828a892 461static DEVICE_ATTR_RO(description);
c2efefb3
RW
462
463static ssize_t
0f39ee83 464sun_show(struct device *dev, struct device_attribute *attr,
d0fb66e9
XT
465 char *buf)
466{
c2efefb3
RW
467 struct acpi_device *acpi_dev = to_acpi_device(dev);
468 acpi_status status;
469 unsigned long long sun;
470
471 status = acpi_evaluate_integer(acpi_dev->handle, "_SUN", NULL, &sun);
472 if (ACPI_FAILURE(status))
6c024409 473 return -EIO;
c2efefb3
RW
474
475 return sprintf(buf, "%llu\n", sun);
476}
0f39ee83 477static DEVICE_ATTR_RO(sun);
c2efefb3 478
6283f97d 479static ssize_t
0f39ee83 480hrv_show(struct device *dev, struct device_attribute *attr,
d0fb66e9
XT
481 char *buf)
482{
6283f97d
BD
483 struct acpi_device *acpi_dev = to_acpi_device(dev);
484 acpi_status status;
485 unsigned long long hrv;
486
487 status = acpi_evaluate_integer(acpi_dev->handle, "_HRV", NULL, &hrv);
488 if (ACPI_FAILURE(status))
489 return -EIO;
490
491 return sprintf(buf, "%llu\n", hrv);
492}
0f39ee83 493static DEVICE_ATTR_RO(hrv);
6283f97d 494
c2efefb3 495static ssize_t status_show(struct device *dev, struct device_attribute *attr,
d0fb66e9
XT
496 char *buf)
497{
c2efefb3
RW
498 struct acpi_device *acpi_dev = to_acpi_device(dev);
499 acpi_status status;
500 unsigned long long sta;
501
502 status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta);
503 if (ACPI_FAILURE(status))
6c024409 504 return -EIO;
c2efefb3
RW
505
506 return sprintf(buf, "%llu\n", sta);
507}
508static DEVICE_ATTR_RO(status);
509
510/**
511 * acpi_device_setup_files - Create sysfs attributes of an ACPI device.
512 * @dev: ACPI device object.
513 */
514int acpi_device_setup_files(struct acpi_device *dev)
515{
516 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
517 acpi_status status;
518 int result = 0;
519
520 /*
521 * Devices gotten from FADT don't have a "path" attribute
522 */
523 if (dev->handle) {
524 result = device_create_file(&dev->dev, &dev_attr_path);
525 if (result)
526 goto end;
527 }
528
529 if (!list_empty(&dev->pnp.ids)) {
530 result = device_create_file(&dev->dev, &dev_attr_hid);
531 if (result)
532 goto end;
533
534 result = device_create_file(&dev->dev, &dev_attr_modalias);
535 if (result)
536 goto end;
537 }
538
539 /*
540 * If device has _STR, 'description' file is created
541 */
542 if (acpi_has_method(dev->handle, "_STR")) {
543 status = acpi_evaluate_object(dev->handle, "_STR",
544 NULL, &buffer);
545 if (ACPI_FAILURE(status))
546 buffer.pointer = NULL;
547 dev->pnp.str_obj = buffer.pointer;
548 result = device_create_file(&dev->dev, &dev_attr_description);
549 if (result)
550 goto end;
551 }
552
553 if (dev->pnp.type.bus_address)
554 result = device_create_file(&dev->dev, &dev_attr_adr);
5f70fd18 555 if (acpi_device_uid(dev))
c2efefb3
RW
556 result = device_create_file(&dev->dev, &dev_attr_uid);
557
558 if (acpi_has_method(dev->handle, "_SUN")) {
559 result = device_create_file(&dev->dev, &dev_attr_sun);
560 if (result)
561 goto end;
562 }
563
6283f97d
BD
564 if (acpi_has_method(dev->handle, "_HRV")) {
565 result = device_create_file(&dev->dev, &dev_attr_hrv);
566 if (result)
567 goto end;
568 }
569
c2efefb3
RW
570 if (acpi_has_method(dev->handle, "_STA")) {
571 result = device_create_file(&dev->dev, &dev_attr_status);
572 if (result)
573 goto end;
574 }
575
a508d954
BD
576 /*
577 * If device has _EJ0, 'eject' file is created that is used to trigger
578 * hot-removal function from userland.
579 */
c2efefb3
RW
580 if (acpi_has_method(dev->handle, "_EJ0")) {
581 result = device_create_file(&dev->dev, &dev_attr_eject);
582 if (result)
583 return result;
584 }
585
586 if (dev->flags.power_manageable) {
587 result = device_create_file(&dev->dev, &dev_attr_power_state);
588 if (result)
589 return result;
590
591 if (dev->power.flags.power_resources)
592 result = device_create_file(&dev->dev,
593 &dev_attr_real_power_state);
594 }
595
263b4c1a
RW
596 acpi_expose_nondev_subnodes(&dev->dev.kobj, &dev->data);
597
c2efefb3
RW
598end:
599 return result;
600}
601
602/**
603 * acpi_device_remove_files - Remove sysfs attributes of an ACPI device.
604 * @dev: ACPI device object.
605 */
606void acpi_device_remove_files(struct acpi_device *dev)
607{
263b4c1a
RW
608 acpi_hide_nondev_subnodes(&dev->data);
609
c2efefb3
RW
610 if (dev->flags.power_manageable) {
611 device_remove_file(&dev->dev, &dev_attr_power_state);
612 if (dev->power.flags.power_resources)
613 device_remove_file(&dev->dev,
614 &dev_attr_real_power_state);
615 }
616
617 /*
618 * If device has _STR, remove 'description' file
619 */
620 if (acpi_has_method(dev->handle, "_STR")) {
621 kfree(dev->pnp.str_obj);
622 device_remove_file(&dev->dev, &dev_attr_description);
623 }
624 /*
625 * If device has _EJ0, remove 'eject' file.
626 */
627 if (acpi_has_method(dev->handle, "_EJ0"))
628 device_remove_file(&dev->dev, &dev_attr_eject);
629
630 if (acpi_has_method(dev->handle, "_SUN"))
631 device_remove_file(&dev->dev, &dev_attr_sun);
632
6283f97d
BD
633 if (acpi_has_method(dev->handle, "_HRV"))
634 device_remove_file(&dev->dev, &dev_attr_hrv);
635
5f70fd18 636 if (acpi_device_uid(dev))
c2efefb3
RW
637 device_remove_file(&dev->dev, &dev_attr_uid);
638 if (dev->pnp.type.bus_address)
639 device_remove_file(&dev->dev, &dev_attr_adr);
640 device_remove_file(&dev->dev, &dev_attr_modalias);
641 device_remove_file(&dev->dev, &dev_attr_hid);
642 if (acpi_has_method(dev->handle, "_STA"))
643 device_remove_file(&dev->dev, &dev_attr_status);
644 if (dev->handle)
645 device_remove_file(&dev->dev, &dev_attr_path);
646}