]>
Commit | Line | Data |
---|---|---|
bf9ffb20 GKH |
1 | From a383b68d9fe9864c4d3b86f67ad6488f58136435 Mon Sep 17 00:00:00 2001 |
2 | From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> | |
3 | Date: Wed, 3 Sep 2014 13:39:13 +0900 | |
4 | Subject: ACPI / scan: not cache _SUN value in struct acpi_device_pnp | |
5 | ||
6 | From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> | |
7 | ||
8 | commit a383b68d9fe9864c4d3b86f67ad6488f58136435 upstream. | |
9 | ||
10 | The _SUN device indentification object is not guaranteed to return | |
11 | the same value every time it is executed, so we should not cache its | |
12 | return value, but rather execute it every time as needed. If it is | |
13 | cached, an incorrect stale value may be used in some situations. | |
14 | ||
15 | This issue was exposed by commit 202317a573b2 (ACPI / scan: Add | |
16 | acpi_device objects for all device nodes in the namespace). Fix it | |
17 | by avoiding to cache the return value of _SUN. | |
18 | ||
19 | Fixes: 202317a573b2 (ACPI / scan: Add acpi_device objects for all device nodes in the namespace) | |
20 | Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> | |
21 | [ rjw: Changelog ] | |
22 | Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | |
23 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
24 | ||
25 | --- | |
26 | drivers/acpi/scan.c | 15 ++++++++------- | |
27 | include/acpi/acpi_bus.h | 1 - | |
28 | 2 files changed, 8 insertions(+), 8 deletions(-) | |
29 | ||
30 | --- a/drivers/acpi/scan.c | |
31 | +++ b/drivers/acpi/scan.c | |
32 | @@ -665,8 +665,14 @@ static ssize_t | |
33 | acpi_device_sun_show(struct device *dev, struct device_attribute *attr, | |
34 | char *buf) { | |
35 | struct acpi_device *acpi_dev = to_acpi_device(dev); | |
36 | + acpi_status status; | |
37 | + unsigned long long sun; | |
38 | + | |
39 | + status = acpi_evaluate_integer(acpi_dev->handle, "_SUN", NULL, &sun); | |
40 | + if (ACPI_FAILURE(status)) | |
41 | + return -ENODEV; | |
42 | ||
43 | - return sprintf(buf, "%lu\n", acpi_dev->pnp.sun); | |
44 | + return sprintf(buf, "%llu\n", sun); | |
45 | } | |
46 | static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); | |
47 | ||
48 | @@ -688,7 +694,6 @@ static int acpi_device_setup_files(struc | |
49 | { | |
50 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | |
51 | acpi_status status; | |
52 | - unsigned long long sun; | |
53 | int result = 0; | |
54 | ||
55 | /* | |
56 | @@ -729,14 +734,10 @@ static int acpi_device_setup_files(struc | |
57 | if (dev->pnp.unique_id) | |
58 | result = device_create_file(&dev->dev, &dev_attr_uid); | |
59 | ||
60 | - status = acpi_evaluate_integer(dev->handle, "_SUN", NULL, &sun); | |
61 | - if (ACPI_SUCCESS(status)) { | |
62 | - dev->pnp.sun = (unsigned long)sun; | |
63 | + if (acpi_has_method(dev->handle, "_SUN")) { | |
64 | result = device_create_file(&dev->dev, &dev_attr_sun); | |
65 | if (result) | |
66 | goto end; | |
67 | - } else { | |
68 | - dev->pnp.sun = (unsigned long)-1; | |
69 | } | |
70 | ||
71 | if (acpi_has_method(dev->handle, "_STA")) { | |
72 | --- a/include/acpi/acpi_bus.h | |
73 | +++ b/include/acpi/acpi_bus.h | |
74 | @@ -246,7 +246,6 @@ struct acpi_device_pnp { | |
75 | acpi_device_name device_name; /* Driver-determined */ | |
76 | acpi_device_class device_class; /* " */ | |
77 | union acpi_object *str_obj; /* unicode string for _STR method */ | |
78 | - unsigned long sun; /* _SUN */ | |
79 | }; | |
80 | ||
81 | #define acpi_device_bid(d) ((d)->pnp.bus_id) |