diff options
author | Ingo Molnar <mingo@kernel.org> | 2014-05-22 04:28:56 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-05-22 04:28:56 -0400 |
commit | 65c2ce70046c779974af8b5dfc25a0df489089b5 (patch) | |
tree | b16f152eb62b71cf5a1edc51da865b357c989922 /drivers/acpi | |
parent | 842514849a616e9b61acad65771c7afe01e651f9 (diff) | |
parent | 4b660a7f5c8099d88d1a43d8ae138965112592c7 (diff) |
Merge tag 'v3.15-rc6' into sched/core, to pick up the latest fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/Kconfig | 17 | ||||
-rw-r--r-- | drivers/acpi/Makefile | 1 | ||||
-rw-r--r-- | drivers/acpi/ac.c | 117 | ||||
-rw-r--r-- | drivers/acpi/acpi_platform.c | 1 | ||||
-rw-r--r-- | drivers/acpi/acpi_processor.c | 8 | ||||
-rw-r--r-- | drivers/acpi/acpica/acglobal.h | 4 | ||||
-rw-r--r-- | drivers/acpi/acpica/exfield.c | 104 | ||||
-rw-r--r-- | drivers/acpi/acpica/tbutils.c | 7 | ||||
-rw-r--r-- | drivers/acpi/battery.c | 329 | ||||
-rw-r--r-- | drivers/acpi/blacklist.c | 21 | ||||
-rw-r--r-- | drivers/acpi/bus.c | 5 | ||||
-rw-r--r-- | drivers/acpi/cm_sbs.c | 105 | ||||
-rw-r--r-- | drivers/acpi/ec.c | 21 | ||||
-rw-r--r-- | drivers/acpi/video.c | 16 |
14 files changed, 664 insertions, 92 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index ab686b310100..a34a22841002 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -47,6 +47,23 @@ config ACPI_SLEEP | |||
47 | depends on SUSPEND || HIBERNATION | 47 | depends on SUSPEND || HIBERNATION |
48 | default y | 48 | default y |
49 | 49 | ||
50 | config ACPI_PROCFS_POWER | ||
51 | bool "Deprecated power /proc/acpi directories" | ||
52 | depends on PROC_FS | ||
53 | help | ||
54 | For backwards compatibility, this option allows | ||
55 | deprecated power /proc/acpi/ directories to exist, even when | ||
56 | they have been replaced by functions in /sys. | ||
57 | The deprecated directories (and their replacements) include: | ||
58 | /proc/acpi/battery/* (/sys/class/power_supply/*) | ||
59 | /proc/acpi/ac_adapter/* (sys/class/power_supply/*) | ||
60 | This option has no effect on /proc/acpi/ directories | ||
61 | and functions, which do not yet exist in /sys | ||
62 | This option, together with the proc directories, will be | ||
63 | deleted in the future. | ||
64 | |||
65 | Say N to delete power /proc/acpi/ directories that have moved to /sys/ | ||
66 | |||
50 | config ACPI_EC_DEBUGFS | 67 | config ACPI_EC_DEBUGFS |
51 | tristate "EC read/write access through /sys/kernel/debug/ec" | 68 | tristate "EC read/write access through /sys/kernel/debug/ec" |
52 | default n | 69 | default n |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 0331f91d56e6..bce34afadcd0 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -47,6 +47,7 @@ acpi-y += sysfs.o | |||
47 | acpi-$(CONFIG_X86) += acpi_cmos_rtc.o | 47 | acpi-$(CONFIG_X86) += acpi_cmos_rtc.o |
48 | acpi-$(CONFIG_DEBUG_FS) += debugfs.o | 48 | acpi-$(CONFIG_DEBUG_FS) += debugfs.o |
49 | acpi-$(CONFIG_ACPI_NUMA) += numa.o | 49 | acpi-$(CONFIG_ACPI_NUMA) += numa.o |
50 | acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o | ||
50 | ifdef CONFIG_ACPI_VIDEO | 51 | ifdef CONFIG_ACPI_VIDEO |
51 | acpi-y += video_detect.o | 52 | acpi-y += video_detect.o |
52 | endif | 53 | endif |
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 2c01c1da29ce..c67f6f5ad611 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -52,11 +52,39 @@ MODULE_AUTHOR("Paul Diefenbaugh"); | |||
52 | MODULE_DESCRIPTION("ACPI AC Adapter Driver"); | 52 | MODULE_DESCRIPTION("ACPI AC Adapter Driver"); |
53 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
54 | 54 | ||
55 | static int acpi_ac_add(struct acpi_device *device); | ||
56 | static int acpi_ac_remove(struct acpi_device *device); | ||
57 | static void acpi_ac_notify(struct acpi_device *device, u32 event); | ||
58 | |||
59 | static const struct acpi_device_id ac_device_ids[] = { | ||
60 | {"ACPI0003", 0}, | ||
61 | {"", 0}, | ||
62 | }; | ||
63 | MODULE_DEVICE_TABLE(acpi, ac_device_ids); | ||
64 | |||
65 | #ifdef CONFIG_PM_SLEEP | ||
66 | static int acpi_ac_resume(struct device *dev); | ||
67 | #endif | ||
68 | static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume); | ||
69 | |||
55 | static int ac_sleep_before_get_state_ms; | 70 | static int ac_sleep_before_get_state_ms; |
56 | 71 | ||
72 | static struct acpi_driver acpi_ac_driver = { | ||
73 | .name = "ac", | ||
74 | .class = ACPI_AC_CLASS, | ||
75 | .ids = ac_device_ids, | ||
76 | .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, | ||
77 | .ops = { | ||
78 | .add = acpi_ac_add, | ||
79 | .remove = acpi_ac_remove, | ||
80 | .notify = acpi_ac_notify, | ||
81 | }, | ||
82 | .drv.pm = &acpi_ac_pm, | ||
83 | }; | ||
84 | |||
57 | struct acpi_ac { | 85 | struct acpi_ac { |
58 | struct power_supply charger; | 86 | struct power_supply charger; |
59 | struct platform_device *pdev; | 87 | struct acpi_device * device; |
60 | unsigned long long state; | 88 | unsigned long long state; |
61 | struct notifier_block battery_nb; | 89 | struct notifier_block battery_nb; |
62 | }; | 90 | }; |
@@ -69,10 +97,12 @@ struct acpi_ac { | |||
69 | 97 | ||
70 | static int acpi_ac_get_state(struct acpi_ac *ac) | 98 | static int acpi_ac_get_state(struct acpi_ac *ac) |
71 | { | 99 | { |
72 | acpi_status status; | 100 | acpi_status status = AE_OK; |
73 | acpi_handle handle = ACPI_HANDLE(&ac->pdev->dev); | 101 | |
102 | if (!ac) | ||
103 | return -EINVAL; | ||
74 | 104 | ||
75 | status = acpi_evaluate_integer(handle, "_PSR", NULL, | 105 | status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL, |
76 | &ac->state); | 106 | &ac->state); |
77 | if (ACPI_FAILURE(status)) { | 107 | if (ACPI_FAILURE(status)) { |
78 | ACPI_EXCEPTION((AE_INFO, status, | 108 | ACPI_EXCEPTION((AE_INFO, status, |
@@ -117,10 +147,9 @@ static enum power_supply_property ac_props[] = { | |||
117 | Driver Model | 147 | Driver Model |
118 | -------------------------------------------------------------------------- */ | 148 | -------------------------------------------------------------------------- */ |
119 | 149 | ||
120 | static void acpi_ac_notify_handler(acpi_handle handle, u32 event, void *data) | 150 | static void acpi_ac_notify(struct acpi_device *device, u32 event) |
121 | { | 151 | { |
122 | struct acpi_ac *ac = data; | 152 | struct acpi_ac *ac = acpi_driver_data(device); |
123 | struct acpi_device *adev; | ||
124 | 153 | ||
125 | if (!ac) | 154 | if (!ac) |
126 | return; | 155 | return; |
@@ -143,11 +172,10 @@ static void acpi_ac_notify_handler(acpi_handle handle, u32 event, void *data) | |||
143 | msleep(ac_sleep_before_get_state_ms); | 172 | msleep(ac_sleep_before_get_state_ms); |
144 | 173 | ||
145 | acpi_ac_get_state(ac); | 174 | acpi_ac_get_state(ac); |
146 | adev = ACPI_COMPANION(&ac->pdev->dev); | 175 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
147 | acpi_bus_generate_netlink_event(adev->pnp.device_class, | 176 | dev_name(&device->dev), event, |
148 | dev_name(&ac->pdev->dev), | 177 | (u32) ac->state); |
149 | event, (u32) ac->state); | 178 | acpi_notifier_call_chain(device, event, (u32) ac->state); |
150 | acpi_notifier_call_chain(adev, event, (u32) ac->state); | ||
151 | kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); | 179 | kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); |
152 | } | 180 | } |
153 | 181 | ||
@@ -192,49 +220,39 @@ static struct dmi_system_id ac_dmi_table[] = { | |||
192 | {}, | 220 | {}, |
193 | }; | 221 | }; |
194 | 222 | ||
195 | static int acpi_ac_probe(struct platform_device *pdev) | 223 | static int acpi_ac_add(struct acpi_device *device) |
196 | { | 224 | { |
197 | int result = 0; | 225 | int result = 0; |
198 | struct acpi_ac *ac = NULL; | 226 | struct acpi_ac *ac = NULL; |
199 | struct acpi_device *adev; | ||
200 | 227 | ||
201 | if (!pdev) | ||
202 | return -EINVAL; | ||
203 | 228 | ||
204 | adev = ACPI_COMPANION(&pdev->dev); | 229 | if (!device) |
205 | if (!adev) | 230 | return -EINVAL; |
206 | return -ENODEV; | ||
207 | 231 | ||
208 | ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL); | 232 | ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL); |
209 | if (!ac) | 233 | if (!ac) |
210 | return -ENOMEM; | 234 | return -ENOMEM; |
211 | 235 | ||
212 | strcpy(acpi_device_name(adev), ACPI_AC_DEVICE_NAME); | 236 | ac->device = device; |
213 | strcpy(acpi_device_class(adev), ACPI_AC_CLASS); | 237 | strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME); |
214 | ac->pdev = pdev; | 238 | strcpy(acpi_device_class(device), ACPI_AC_CLASS); |
215 | platform_set_drvdata(pdev, ac); | 239 | device->driver_data = ac; |
216 | 240 | ||
217 | result = acpi_ac_get_state(ac); | 241 | result = acpi_ac_get_state(ac); |
218 | if (result) | 242 | if (result) |
219 | goto end; | 243 | goto end; |
220 | 244 | ||
221 | ac->charger.name = acpi_device_bid(adev); | 245 | ac->charger.name = acpi_device_bid(device); |
222 | ac->charger.type = POWER_SUPPLY_TYPE_MAINS; | 246 | ac->charger.type = POWER_SUPPLY_TYPE_MAINS; |
223 | ac->charger.properties = ac_props; | 247 | ac->charger.properties = ac_props; |
224 | ac->charger.num_properties = ARRAY_SIZE(ac_props); | 248 | ac->charger.num_properties = ARRAY_SIZE(ac_props); |
225 | ac->charger.get_property = get_ac_property; | 249 | ac->charger.get_property = get_ac_property; |
226 | result = power_supply_register(&pdev->dev, &ac->charger); | 250 | result = power_supply_register(&ac->device->dev, &ac->charger); |
227 | if (result) | 251 | if (result) |
228 | goto end; | 252 | goto end; |
229 | 253 | ||
230 | result = acpi_install_notify_handler(ACPI_HANDLE(&pdev->dev), | ||
231 | ACPI_ALL_NOTIFY, acpi_ac_notify_handler, ac); | ||
232 | if (result) { | ||
233 | power_supply_unregister(&ac->charger); | ||
234 | goto end; | ||
235 | } | ||
236 | printk(KERN_INFO PREFIX "%s [%s] (%s)\n", | 254 | printk(KERN_INFO PREFIX "%s [%s] (%s)\n", |
237 | acpi_device_name(adev), acpi_device_bid(adev), | 255 | acpi_device_name(device), acpi_device_bid(device), |
238 | ac->state ? "on-line" : "off-line"); | 256 | ac->state ? "on-line" : "off-line"); |
239 | 257 | ||
240 | ac->battery_nb.notifier_call = acpi_ac_battery_notify; | 258 | ac->battery_nb.notifier_call = acpi_ac_battery_notify; |
@@ -256,7 +274,7 @@ static int acpi_ac_resume(struct device *dev) | |||
256 | if (!dev) | 274 | if (!dev) |
257 | return -EINVAL; | 275 | return -EINVAL; |
258 | 276 | ||
259 | ac = platform_get_drvdata(to_platform_device(dev)); | 277 | ac = acpi_driver_data(to_acpi_device(dev)); |
260 | if (!ac) | 278 | if (!ac) |
261 | return -EINVAL; | 279 | return -EINVAL; |
262 | 280 | ||
@@ -270,19 +288,17 @@ static int acpi_ac_resume(struct device *dev) | |||
270 | #else | 288 | #else |
271 | #define acpi_ac_resume NULL | 289 | #define acpi_ac_resume NULL |
272 | #endif | 290 | #endif |
273 | static SIMPLE_DEV_PM_OPS(acpi_ac_pm_ops, NULL, acpi_ac_resume); | ||
274 | 291 | ||
275 | static int acpi_ac_remove(struct platform_device *pdev) | 292 | static int acpi_ac_remove(struct acpi_device *device) |
276 | { | 293 | { |
277 | struct acpi_ac *ac; | 294 | struct acpi_ac *ac = NULL; |
295 | |||
278 | 296 | ||
279 | if (!pdev) | 297 | if (!device || !acpi_driver_data(device)) |
280 | return -EINVAL; | 298 | return -EINVAL; |
281 | 299 | ||
282 | acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev), | 300 | ac = acpi_driver_data(device); |
283 | ACPI_ALL_NOTIFY, acpi_ac_notify_handler); | ||
284 | 301 | ||
285 | ac = platform_get_drvdata(pdev); | ||
286 | if (ac->charger.dev) | 302 | if (ac->charger.dev) |
287 | power_supply_unregister(&ac->charger); | 303 | power_supply_unregister(&ac->charger); |
288 | unregister_acpi_notifier(&ac->battery_nb); | 304 | unregister_acpi_notifier(&ac->battery_nb); |
@@ -292,23 +308,6 @@ static int acpi_ac_remove(struct platform_device *pdev) | |||
292 | return 0; | 308 | return 0; |
293 | } | 309 | } |
294 | 310 | ||
295 | static const struct acpi_device_id acpi_ac_match[] = { | ||
296 | { "ACPI0003", 0 }, | ||
297 | { } | ||
298 | }; | ||
299 | MODULE_DEVICE_TABLE(acpi, acpi_ac_match); | ||
300 | |||
301 | static struct platform_driver acpi_ac_driver = { | ||
302 | .probe = acpi_ac_probe, | ||
303 | .remove = acpi_ac_remove, | ||
304 | .driver = { | ||
305 | .name = "acpi-ac", | ||
306 | .owner = THIS_MODULE, | ||
307 | .pm = &acpi_ac_pm_ops, | ||
308 | .acpi_match_table = ACPI_PTR(acpi_ac_match), | ||
309 | }, | ||
310 | }; | ||
311 | |||
312 | static int __init acpi_ac_init(void) | 311 | static int __init acpi_ac_init(void) |
313 | { | 312 | { |
314 | int result; | 313 | int result; |
@@ -316,7 +315,7 @@ static int __init acpi_ac_init(void) | |||
316 | if (acpi_disabled) | 315 | if (acpi_disabled) |
317 | return -ENODEV; | 316 | return -ENODEV; |
318 | 317 | ||
319 | result = platform_driver_register(&acpi_ac_driver); | 318 | result = acpi_bus_register_driver(&acpi_ac_driver); |
320 | if (result < 0) | 319 | if (result < 0) |
321 | return -ENODEV; | 320 | return -ENODEV; |
322 | 321 | ||
@@ -325,7 +324,7 @@ static int __init acpi_ac_init(void) | |||
325 | 324 | ||
326 | static void __exit acpi_ac_exit(void) | 325 | static void __exit acpi_ac_exit(void) |
327 | { | 326 | { |
328 | platform_driver_unregister(&acpi_ac_driver); | 327 | acpi_bus_unregister_driver(&acpi_ac_driver); |
329 | } | 328 | } |
330 | module_init(acpi_ac_init); | 329 | module_init(acpi_ac_init); |
331 | module_exit(acpi_ac_exit); | 330 | module_exit(acpi_ac_exit); |
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index dbfe49e5fd63..1d4950388fa1 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c | |||
@@ -29,7 +29,6 @@ ACPI_MODULE_NAME("platform"); | |||
29 | static const struct acpi_device_id acpi_platform_device_ids[] = { | 29 | static const struct acpi_device_id acpi_platform_device_ids[] = { |
30 | 30 | ||
31 | { "PNP0D40" }, | 31 | { "PNP0D40" }, |
32 | { "ACPI0003" }, | ||
33 | { "VPC2004" }, | 32 | { "VPC2004" }, |
34 | { "BCM4752" }, | 33 | { "BCM4752" }, |
35 | 34 | ||
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index c29c2c3ec0ad..52c81c49cc7d 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c | |||
@@ -170,6 +170,9 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) | |||
170 | acpi_status status; | 170 | acpi_status status; |
171 | int ret; | 171 | int ret; |
172 | 172 | ||
173 | if (pr->apic_id == -1) | ||
174 | return -ENODEV; | ||
175 | |||
173 | status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); | 176 | status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); |
174 | if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT)) | 177 | if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT)) |
175 | return -ENODEV; | 178 | return -ENODEV; |
@@ -260,10 +263,8 @@ static int acpi_processor_get_info(struct acpi_device *device) | |||
260 | } | 263 | } |
261 | 264 | ||
262 | apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id); | 265 | apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id); |
263 | if (apic_id < 0) { | 266 | if (apic_id < 0) |
264 | acpi_handle_debug(pr->handle, "failed to get CPU APIC ID.\n"); | 267 | acpi_handle_debug(pr->handle, "failed to get CPU APIC ID.\n"); |
265 | return -ENODEV; | ||
266 | } | ||
267 | pr->apic_id = apic_id; | 268 | pr->apic_id = apic_id; |
268 | 269 | ||
269 | cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id); | 270 | cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id); |
@@ -404,7 +405,6 @@ static int acpi_processor_add(struct acpi_device *device, | |||
404 | goto err; | 405 | goto err; |
405 | 406 | ||
406 | pr->dev = dev; | 407 | pr->dev = dev; |
407 | dev->offline = pr->flags.need_hotplug_init; | ||
408 | 408 | ||
409 | /* Trigger the processor driver's .probe() if present. */ | 409 | /* Trigger the processor driver's .probe() if present. */ |
410 | if (device_attach(dev) >= 0) | 410 | if (device_attach(dev) >= 0) |
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index 49bbc71fad54..a08a448068dd 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h | |||
@@ -141,9 +141,9 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_do_not_use_xsdt, FALSE); | |||
141 | * address. Although ACPICA adheres to the ACPI specification which | 141 | * address. Although ACPICA adheres to the ACPI specification which |
142 | * requires the use of the corresponding 64-bit address if it is non-zero, | 142 | * requires the use of the corresponding 64-bit address if it is non-zero, |
143 | * some machines have been found to have a corrupted non-zero 64-bit | 143 | * some machines have been found to have a corrupted non-zero 64-bit |
144 | * address. Default is FALSE, do not favor the 32-bit addresses. | 144 | * address. Default is TRUE, favor the 32-bit addresses. |
145 | */ | 145 | */ |
146 | ACPI_INIT_GLOBAL(u8, acpi_gbl_use32_bit_fadt_addresses, FALSE); | 146 | ACPI_INIT_GLOBAL(u8, acpi_gbl_use32_bit_fadt_addresses, TRUE); |
147 | 147 | ||
148 | /* | 148 | /* |
149 | * Optionally truncate I/O addresses to 16 bits. Provides compatibility | 149 | * Optionally truncate I/O addresses to 16 bits. Provides compatibility |
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c index 68d97441432c..12878e1982f7 100644 --- a/drivers/acpi/acpica/exfield.c +++ b/drivers/acpi/acpica/exfield.c | |||
@@ -45,10 +45,71 @@ | |||
45 | #include "accommon.h" | 45 | #include "accommon.h" |
46 | #include "acdispat.h" | 46 | #include "acdispat.h" |
47 | #include "acinterp.h" | 47 | #include "acinterp.h" |
48 | #include "amlcode.h" | ||
48 | 49 | ||
49 | #define _COMPONENT ACPI_EXECUTER | 50 | #define _COMPONENT ACPI_EXECUTER |
50 | ACPI_MODULE_NAME("exfield") | 51 | ACPI_MODULE_NAME("exfield") |
51 | 52 | ||
53 | /* Local prototypes */ | ||
54 | static u32 | ||
55 | acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length); | ||
56 | |||
57 | /******************************************************************************* | ||
58 | * | ||
59 | * FUNCTION: acpi_get_serial_access_bytes | ||
60 | * | ||
61 | * PARAMETERS: accessor_type - The type of the protocol indicated by region | ||
62 | * field access attributes | ||
63 | * access_length - The access length of the region field | ||
64 | * | ||
65 | * RETURN: Decoded access length | ||
66 | * | ||
67 | * DESCRIPTION: This routine returns the length of the generic_serial_bus | ||
68 | * protocol bytes | ||
69 | * | ||
70 | ******************************************************************************/ | ||
71 | |||
72 | static u32 | ||
73 | acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length) | ||
74 | { | ||
75 | u32 length; | ||
76 | |||
77 | switch (accessor_type) { | ||
78 | case AML_FIELD_ATTRIB_QUICK: | ||
79 | |||
80 | length = 0; | ||
81 | break; | ||
82 | |||
83 | case AML_FIELD_ATTRIB_SEND_RCV: | ||
84 | case AML_FIELD_ATTRIB_BYTE: | ||
85 | |||
86 | length = 1; | ||
87 | break; | ||
88 | |||
89 | case AML_FIELD_ATTRIB_WORD: | ||
90 | case AML_FIELD_ATTRIB_WORD_CALL: | ||
91 | |||
92 | length = 2; | ||
93 | break; | ||
94 | |||
95 | case AML_FIELD_ATTRIB_MULTIBYTE: | ||
96 | case AML_FIELD_ATTRIB_RAW_BYTES: | ||
97 | case AML_FIELD_ATTRIB_RAW_PROCESS: | ||
98 | |||
99 | length = access_length; | ||
100 | break; | ||
101 | |||
102 | case AML_FIELD_ATTRIB_BLOCK: | ||
103 | case AML_FIELD_ATTRIB_BLOCK_CALL: | ||
104 | default: | ||
105 | |||
106 | length = ACPI_GSBUS_BUFFER_SIZE; | ||
107 | break; | ||
108 | } | ||
109 | |||
110 | return (length); | ||
111 | } | ||
112 | |||
52 | /******************************************************************************* | 113 | /******************************************************************************* |
53 | * | 114 | * |
54 | * FUNCTION: acpi_ex_read_data_from_field | 115 | * FUNCTION: acpi_ex_read_data_from_field |
@@ -63,8 +124,9 @@ ACPI_MODULE_NAME("exfield") | |||
63 | * Buffer, depending on the size of the field. | 124 | * Buffer, depending on the size of the field. |
64 | * | 125 | * |
65 | ******************************************************************************/ | 126 | ******************************************************************************/ |
127 | |||
66 | acpi_status | 128 | acpi_status |
67 | acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, | 129 | acpi_ex_read_data_from_field(struct acpi_walk_state * walk_state, |
68 | union acpi_operand_object *obj_desc, | 130 | union acpi_operand_object *obj_desc, |
69 | union acpi_operand_object **ret_buffer_desc) | 131 | union acpi_operand_object **ret_buffer_desc) |
70 | { | 132 | { |
@@ -73,6 +135,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, | |||
73 | acpi_size length; | 135 | acpi_size length; |
74 | void *buffer; | 136 | void *buffer; |
75 | u32 function; | 137 | u32 function; |
138 | u16 accessor_type; | ||
76 | 139 | ||
77 | ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc); | 140 | ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc); |
78 | 141 | ||
@@ -116,9 +179,22 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, | |||
116 | ACPI_READ | (obj_desc->field.attribute << 16); | 179 | ACPI_READ | (obj_desc->field.attribute << 16); |
117 | } else if (obj_desc->field.region_obj->region.space_id == | 180 | } else if (obj_desc->field.region_obj->region.space_id == |
118 | ACPI_ADR_SPACE_GSBUS) { | 181 | ACPI_ADR_SPACE_GSBUS) { |
119 | length = ACPI_GSBUS_BUFFER_SIZE; | 182 | accessor_type = obj_desc->field.attribute; |
120 | function = | 183 | length = acpi_ex_get_serial_access_length(accessor_type, |
121 | ACPI_READ | (obj_desc->field.attribute << 16); | 184 | obj_desc-> |
185 | field. | ||
186 | access_length); | ||
187 | |||
188 | /* | ||
189 | * Add additional 2 bytes for modeled generic_serial_bus data buffer: | ||
190 | * typedef struct { | ||
191 | * BYTEStatus; // Byte 0 of the data buffer | ||
192 | * BYTELength; // Byte 1 of the data buffer | ||
193 | * BYTE[x-1]Data; // Bytes 2-x of the arbitrary length data buffer, | ||
194 | * } | ||
195 | */ | ||
196 | length += 2; | ||
197 | function = ACPI_READ | (accessor_type << 16); | ||
122 | } else { /* IPMI */ | 198 | } else { /* IPMI */ |
123 | 199 | ||
124 | length = ACPI_IPMI_BUFFER_SIZE; | 200 | length = ACPI_IPMI_BUFFER_SIZE; |
@@ -231,6 +307,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, | |||
231 | void *buffer; | 307 | void *buffer; |
232 | union acpi_operand_object *buffer_desc; | 308 | union acpi_operand_object *buffer_desc; |
233 | u32 function; | 309 | u32 function; |
310 | u16 accessor_type; | ||
234 | 311 | ||
235 | ACPI_FUNCTION_TRACE_PTR(ex_write_data_to_field, obj_desc); | 312 | ACPI_FUNCTION_TRACE_PTR(ex_write_data_to_field, obj_desc); |
236 | 313 | ||
@@ -284,9 +361,22 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, | |||
284 | ACPI_WRITE | (obj_desc->field.attribute << 16); | 361 | ACPI_WRITE | (obj_desc->field.attribute << 16); |
285 | } else if (obj_desc->field.region_obj->region.space_id == | 362 | } else if (obj_desc->field.region_obj->region.space_id == |
286 | ACPI_ADR_SPACE_GSBUS) { | 363 | ACPI_ADR_SPACE_GSBUS) { |
287 | length = ACPI_GSBUS_BUFFER_SIZE; | 364 | accessor_type = obj_desc->field.attribute; |
288 | function = | 365 | length = acpi_ex_get_serial_access_length(accessor_type, |
289 | ACPI_WRITE | (obj_desc->field.attribute << 16); | 366 | obj_desc-> |
367 | field. | ||
368 | access_length); | ||
369 | |||
370 | /* | ||
371 | * Add additional 2 bytes for modeled generic_serial_bus data buffer: | ||
372 | * typedef struct { | ||
373 | * BYTEStatus; // Byte 0 of the data buffer | ||
374 | * BYTELength; // Byte 1 of the data buffer | ||
375 | * BYTE[x-1]Data; // Bytes 2-x of the arbitrary length data buffer, | ||
376 | * } | ||
377 | */ | ||
378 | length += 2; | ||
379 | function = ACPI_WRITE | (accessor_type << 16); | ||
290 | } else { /* IPMI */ | 380 | } else { /* IPMI */ |
291 | 381 | ||
292 | length = ACPI_IPMI_BUFFER_SIZE; | 382 | length = ACPI_IPMI_BUFFER_SIZE; |
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c index a4702eee91a8..9fb85f38de90 100644 --- a/drivers/acpi/acpica/tbutils.c +++ b/drivers/acpi/acpica/tbutils.c | |||
@@ -461,6 +461,7 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address) | |||
461 | u32 table_count; | 461 | u32 table_count; |
462 | struct acpi_table_header *table; | 462 | struct acpi_table_header *table; |
463 | acpi_physical_address address; | 463 | acpi_physical_address address; |
464 | acpi_physical_address rsdt_address; | ||
464 | u32 length; | 465 | u32 length; |
465 | u8 *table_entry; | 466 | u8 *table_entry; |
466 | acpi_status status; | 467 | acpi_status status; |
@@ -488,11 +489,14 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address) | |||
488 | * as per the ACPI specification. | 489 | * as per the ACPI specification. |
489 | */ | 490 | */ |
490 | address = (acpi_physical_address) rsdp->xsdt_physical_address; | 491 | address = (acpi_physical_address) rsdp->xsdt_physical_address; |
492 | rsdt_address = | ||
493 | (acpi_physical_address) rsdp->rsdt_physical_address; | ||
491 | table_entry_size = ACPI_XSDT_ENTRY_SIZE; | 494 | table_entry_size = ACPI_XSDT_ENTRY_SIZE; |
492 | } else { | 495 | } else { |
493 | /* Root table is an RSDT (32-bit physical addresses) */ | 496 | /* Root table is an RSDT (32-bit physical addresses) */ |
494 | 497 | ||
495 | address = (acpi_physical_address) rsdp->rsdt_physical_address; | 498 | address = (acpi_physical_address) rsdp->rsdt_physical_address; |
499 | rsdt_address = address; | ||
496 | table_entry_size = ACPI_RSDT_ENTRY_SIZE; | 500 | table_entry_size = ACPI_RSDT_ENTRY_SIZE; |
497 | } | 501 | } |
498 | 502 | ||
@@ -515,8 +519,7 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address) | |||
515 | 519 | ||
516 | /* Fall back to the RSDT */ | 520 | /* Fall back to the RSDT */ |
517 | 521 | ||
518 | address = | 522 | address = rsdt_address; |
519 | (acpi_physical_address) rsdp->rsdt_physical_address; | ||
520 | table_entry_size = ACPI_RSDT_ENTRY_SIZE; | 523 | table_entry_size = ACPI_RSDT_ENTRY_SIZE; |
521 | } | 524 | } |
522 | } | 525 | } |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 9a2c63b20050..6e7b2a12860d 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -36,6 +36,12 @@ | |||
36 | #include <linux/suspend.h> | 36 | #include <linux/suspend.h> |
37 | #include <asm/unaligned.h> | 37 | #include <asm/unaligned.h> |
38 | 38 | ||
39 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
40 | #include <linux/proc_fs.h> | ||
41 | #include <linux/seq_file.h> | ||
42 | #include <asm/uaccess.h> | ||
43 | #endif | ||
44 | |||
39 | #include <linux/acpi.h> | 45 | #include <linux/acpi.h> |
40 | #include <linux/power_supply.h> | 46 | #include <linux/power_supply.h> |
41 | 47 | ||
@@ -64,6 +70,19 @@ static unsigned int cache_time = 1000; | |||
64 | module_param(cache_time, uint, 0644); | 70 | module_param(cache_time, uint, 0644); |
65 | MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); | 71 | MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); |
66 | 72 | ||
73 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
74 | extern struct proc_dir_entry *acpi_lock_battery_dir(void); | ||
75 | extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); | ||
76 | |||
77 | enum acpi_battery_files { | ||
78 | info_tag = 0, | ||
79 | state_tag, | ||
80 | alarm_tag, | ||
81 | ACPI_BATTERY_NUMFILES, | ||
82 | }; | ||
83 | |||
84 | #endif | ||
85 | |||
67 | static const struct acpi_device_id battery_device_ids[] = { | 86 | static const struct acpi_device_id battery_device_ids[] = { |
68 | {"PNP0C0A", 0}, | 87 | {"PNP0C0A", 0}, |
69 | {"", 0}, | 88 | {"", 0}, |
@@ -299,6 +318,14 @@ static enum power_supply_property energy_battery_props[] = { | |||
299 | POWER_SUPPLY_PROP_SERIAL_NUMBER, | 318 | POWER_SUPPLY_PROP_SERIAL_NUMBER, |
300 | }; | 319 | }; |
301 | 320 | ||
321 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
322 | inline char *acpi_battery_units(struct acpi_battery *battery) | ||
323 | { | ||
324 | return (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA) ? | ||
325 | "mA" : "mW"; | ||
326 | } | ||
327 | #endif | ||
328 | |||
302 | /* -------------------------------------------------------------------------- | 329 | /* -------------------------------------------------------------------------- |
303 | Battery Management | 330 | Battery Management |
304 | -------------------------------------------------------------------------- */ | 331 | -------------------------------------------------------------------------- */ |
@@ -717,6 +744,279 @@ static void acpi_battery_refresh(struct acpi_battery *battery) | |||
717 | } | 744 | } |
718 | 745 | ||
719 | /* -------------------------------------------------------------------------- | 746 | /* -------------------------------------------------------------------------- |
747 | FS Interface (/proc) | ||
748 | -------------------------------------------------------------------------- */ | ||
749 | |||
750 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
751 | static struct proc_dir_entry *acpi_battery_dir; | ||
752 | |||
753 | static int acpi_battery_print_info(struct seq_file *seq, int result) | ||
754 | { | ||
755 | struct acpi_battery *battery = seq->private; | ||
756 | |||
757 | if (result) | ||
758 | goto end; | ||
759 | |||
760 | seq_printf(seq, "present: %s\n", | ||
761 | acpi_battery_present(battery) ? "yes" : "no"); | ||
762 | if (!acpi_battery_present(battery)) | ||
763 | goto end; | ||
764 | if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN) | ||
765 | seq_printf(seq, "design capacity: unknown\n"); | ||
766 | else | ||
767 | seq_printf(seq, "design capacity: %d %sh\n", | ||
768 | battery->design_capacity, | ||
769 | acpi_battery_units(battery)); | ||
770 | |||
771 | if (battery->full_charge_capacity == ACPI_BATTERY_VALUE_UNKNOWN) | ||
772 | seq_printf(seq, "last full capacity: unknown\n"); | ||
773 | else | ||
774 | seq_printf(seq, "last full capacity: %d %sh\n", | ||
775 | battery->full_charge_capacity, | ||
776 | acpi_battery_units(battery)); | ||
777 | |||
778 | seq_printf(seq, "battery technology: %srechargeable\n", | ||
779 | (!battery->technology)?"non-":""); | ||
780 | |||
781 | if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN) | ||
782 | seq_printf(seq, "design voltage: unknown\n"); | ||
783 | else | ||
784 | seq_printf(seq, "design voltage: %d mV\n", | ||
785 | battery->design_voltage); | ||
786 | seq_printf(seq, "design capacity warning: %d %sh\n", | ||
787 | battery->design_capacity_warning, | ||
788 | acpi_battery_units(battery)); | ||
789 | seq_printf(seq, "design capacity low: %d %sh\n", | ||
790 | battery->design_capacity_low, | ||
791 | acpi_battery_units(battery)); | ||
792 | seq_printf(seq, "cycle count: %i\n", battery->cycle_count); | ||
793 | seq_printf(seq, "capacity granularity 1: %d %sh\n", | ||
794 | battery->capacity_granularity_1, | ||
795 | acpi_battery_units(battery)); | ||
796 | seq_printf(seq, "capacity granularity 2: %d %sh\n", | ||
797 | battery->capacity_granularity_2, | ||
798 | acpi_battery_units(battery)); | ||
799 | seq_printf(seq, "model number: %s\n", battery->model_number); | ||
800 | seq_printf(seq, "serial number: %s\n", battery->serial_number); | ||
801 | seq_printf(seq, "battery type: %s\n", battery->type); | ||
802 | seq_printf(seq, "OEM info: %s\n", battery->oem_info); | ||
803 | end: | ||
804 | if (result) | ||
805 | seq_printf(seq, "ERROR: Unable to read battery info\n"); | ||
806 | return result; | ||
807 | } | ||
808 | |||
809 | static int acpi_battery_print_state(struct seq_file *seq, int result) | ||
810 | { | ||
811 | struct acpi_battery *battery = seq->private; | ||
812 | |||
813 | if (result) | ||
814 | goto end; | ||
815 | |||
816 | seq_printf(seq, "present: %s\n", | ||
817 | acpi_battery_present(battery) ? "yes" : "no"); | ||
818 | if (!acpi_battery_present(battery)) | ||
819 | goto end; | ||
820 | |||
821 | seq_printf(seq, "capacity state: %s\n", | ||
822 | (battery->state & 0x04) ? "critical" : "ok"); | ||
823 | if ((battery->state & 0x01) && (battery->state & 0x02)) | ||
824 | seq_printf(seq, | ||
825 | "charging state: charging/discharging\n"); | ||
826 | else if (battery->state & 0x01) | ||
827 | seq_printf(seq, "charging state: discharging\n"); | ||
828 | else if (battery->state & 0x02) | ||
829 | seq_printf(seq, "charging state: charging\n"); | ||
830 | else | ||
831 | seq_printf(seq, "charging state: charged\n"); | ||
832 | |||
833 | if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN) | ||
834 | seq_printf(seq, "present rate: unknown\n"); | ||
835 | else | ||
836 | seq_printf(seq, "present rate: %d %s\n", | ||
837 | battery->rate_now, acpi_battery_units(battery)); | ||
838 | |||
839 | if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN) | ||
840 | seq_printf(seq, "remaining capacity: unknown\n"); | ||
841 | else | ||
842 | seq_printf(seq, "remaining capacity: %d %sh\n", | ||
843 | battery->capacity_now, acpi_battery_units(battery)); | ||
844 | if (battery->voltage_now == ACPI_BATTERY_VALUE_UNKNOWN) | ||
845 | seq_printf(seq, "present voltage: unknown\n"); | ||
846 | else | ||
847 | seq_printf(seq, "present voltage: %d mV\n", | ||
848 | battery->voltage_now); | ||
849 | end: | ||
850 | if (result) | ||
851 | seq_printf(seq, "ERROR: Unable to read battery state\n"); | ||
852 | |||
853 | return result; | ||
854 | } | ||
855 | |||
856 | static int acpi_battery_print_alarm(struct seq_file *seq, int result) | ||
857 | { | ||
858 | struct acpi_battery *battery = seq->private; | ||
859 | |||
860 | if (result) | ||
861 | goto end; | ||
862 | |||
863 | if (!acpi_battery_present(battery)) { | ||
864 | seq_printf(seq, "present: no\n"); | ||
865 | goto end; | ||
866 | } | ||
867 | seq_printf(seq, "alarm: "); | ||
868 | if (!battery->alarm) | ||
869 | seq_printf(seq, "unsupported\n"); | ||
870 | else | ||
871 | seq_printf(seq, "%u %sh\n", battery->alarm, | ||
872 | acpi_battery_units(battery)); | ||
873 | end: | ||
874 | if (result) | ||
875 | seq_printf(seq, "ERROR: Unable to read battery alarm\n"); | ||
876 | return result; | ||
877 | } | ||
878 | |||
879 | static ssize_t acpi_battery_write_alarm(struct file *file, | ||
880 | const char __user * buffer, | ||
881 | size_t count, loff_t * ppos) | ||
882 | { | ||
883 | int result = 0; | ||
884 | char alarm_string[12] = { '\0' }; | ||
885 | struct seq_file *m = file->private_data; | ||
886 | struct acpi_battery *battery = m->private; | ||
887 | |||
888 | if (!battery || (count > sizeof(alarm_string) - 1)) | ||
889 | return -EINVAL; | ||
890 | if (!acpi_battery_present(battery)) { | ||
891 | result = -ENODEV; | ||
892 | goto end; | ||
893 | } | ||
894 | if (copy_from_user(alarm_string, buffer, count)) { | ||
895 | result = -EFAULT; | ||
896 | goto end; | ||
897 | } | ||
898 | alarm_string[count] = '\0'; | ||
899 | battery->alarm = simple_strtol(alarm_string, NULL, 0); | ||
900 | result = acpi_battery_set_alarm(battery); | ||
901 | end: | ||
902 | if (!result) | ||
903 | return count; | ||
904 | return result; | ||
905 | } | ||
906 | |||
907 | typedef int(*print_func)(struct seq_file *seq, int result); | ||
908 | |||
909 | static print_func acpi_print_funcs[ACPI_BATTERY_NUMFILES] = { | ||
910 | acpi_battery_print_info, | ||
911 | acpi_battery_print_state, | ||
912 | acpi_battery_print_alarm, | ||
913 | }; | ||
914 | |||
915 | static int acpi_battery_read(int fid, struct seq_file *seq) | ||
916 | { | ||
917 | struct acpi_battery *battery = seq->private; | ||
918 | int result = acpi_battery_update(battery); | ||
919 | return acpi_print_funcs[fid](seq, result); | ||
920 | } | ||
921 | |||
922 | #define DECLARE_FILE_FUNCTIONS(_name) \ | ||
923 | static int acpi_battery_read_##_name(struct seq_file *seq, void *offset) \ | ||
924 | { \ | ||
925 | return acpi_battery_read(_name##_tag, seq); \ | ||
926 | } \ | ||
927 | static int acpi_battery_##_name##_open_fs(struct inode *inode, struct file *file) \ | ||
928 | { \ | ||
929 | return single_open(file, acpi_battery_read_##_name, PDE_DATA(inode)); \ | ||
930 | } | ||
931 | |||
932 | DECLARE_FILE_FUNCTIONS(info); | ||
933 | DECLARE_FILE_FUNCTIONS(state); | ||
934 | DECLARE_FILE_FUNCTIONS(alarm); | ||
935 | |||
936 | #undef DECLARE_FILE_FUNCTIONS | ||
937 | |||
938 | #define FILE_DESCRIPTION_RO(_name) \ | ||
939 | { \ | ||
940 | .name = __stringify(_name), \ | ||
941 | .mode = S_IRUGO, \ | ||
942 | .ops = { \ | ||
943 | .open = acpi_battery_##_name##_open_fs, \ | ||
944 | .read = seq_read, \ | ||
945 | .llseek = seq_lseek, \ | ||
946 | .release = single_release, \ | ||
947 | .owner = THIS_MODULE, \ | ||
948 | }, \ | ||
949 | } | ||
950 | |||
951 | #define FILE_DESCRIPTION_RW(_name) \ | ||
952 | { \ | ||
953 | .name = __stringify(_name), \ | ||
954 | .mode = S_IFREG | S_IRUGO | S_IWUSR, \ | ||
955 | .ops = { \ | ||
956 | .open = acpi_battery_##_name##_open_fs, \ | ||
957 | .read = seq_read, \ | ||
958 | .llseek = seq_lseek, \ | ||
959 | .write = acpi_battery_write_##_name, \ | ||
960 | .release = single_release, \ | ||
961 | .owner = THIS_MODULE, \ | ||
962 | }, \ | ||
963 | } | ||
964 | |||
965 | static const struct battery_file { | ||
966 | struct file_operations ops; | ||
967 | umode_t mode; | ||
968 | const char *name; | ||
969 | } acpi_battery_file[] = { | ||
970 | FILE_DESCRIPTION_RO(info), | ||
971 | FILE_DESCRIPTION_RO(state), | ||
972 | FILE_DESCRIPTION_RW(alarm), | ||
973 | }; | ||
974 | |||
975 | #undef FILE_DESCRIPTION_RO | ||
976 | #undef FILE_DESCRIPTION_RW | ||
977 | |||
978 | static int acpi_battery_add_fs(struct acpi_device *device) | ||
979 | { | ||
980 | struct proc_dir_entry *entry = NULL; | ||
981 | int i; | ||
982 | |||
983 | printk(KERN_WARNING PREFIX "Deprecated procfs I/F for battery is loaded," | ||
984 | " please retry with CONFIG_ACPI_PROCFS_POWER cleared\n"); | ||
985 | if (!acpi_device_dir(device)) { | ||
986 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), | ||
987 | acpi_battery_dir); | ||
988 | if (!acpi_device_dir(device)) | ||
989 | return -ENODEV; | ||
990 | } | ||
991 | |||
992 | for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) { | ||
993 | entry = proc_create_data(acpi_battery_file[i].name, | ||
994 | acpi_battery_file[i].mode, | ||
995 | acpi_device_dir(device), | ||
996 | &acpi_battery_file[i].ops, | ||
997 | acpi_driver_data(device)); | ||
998 | if (!entry) | ||
999 | return -ENODEV; | ||
1000 | } | ||
1001 | return 0; | ||
1002 | } | ||
1003 | |||
1004 | static void acpi_battery_remove_fs(struct acpi_device *device) | ||
1005 | { | ||
1006 | int i; | ||
1007 | if (!acpi_device_dir(device)) | ||
1008 | return; | ||
1009 | for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) | ||
1010 | remove_proc_entry(acpi_battery_file[i].name, | ||
1011 | acpi_device_dir(device)); | ||
1012 | |||
1013 | remove_proc_entry(acpi_device_bid(device), acpi_battery_dir); | ||
1014 | acpi_device_dir(device) = NULL; | ||
1015 | } | ||
1016 | |||
1017 | #endif | ||
1018 | |||
1019 | /* -------------------------------------------------------------------------- | ||
720 | Driver Interface | 1020 | Driver Interface |
721 | -------------------------------------------------------------------------- */ | 1021 | -------------------------------------------------------------------------- */ |
722 | 1022 | ||
@@ -790,6 +1090,15 @@ static int acpi_battery_add(struct acpi_device *device) | |||
790 | result = acpi_battery_update(battery); | 1090 | result = acpi_battery_update(battery); |
791 | if (result) | 1091 | if (result) |
792 | goto fail; | 1092 | goto fail; |
1093 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
1094 | result = acpi_battery_add_fs(device); | ||
1095 | #endif | ||
1096 | if (result) { | ||
1097 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
1098 | acpi_battery_remove_fs(device); | ||
1099 | #endif | ||
1100 | goto fail; | ||
1101 | } | ||
793 | 1102 | ||
794 | printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", | 1103 | printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", |
795 | ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), | 1104 | ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), |
@@ -816,6 +1125,9 @@ static int acpi_battery_remove(struct acpi_device *device) | |||
816 | return -EINVAL; | 1125 | return -EINVAL; |
817 | battery = acpi_driver_data(device); | 1126 | battery = acpi_driver_data(device); |
818 | unregister_pm_notifier(&battery->pm_nb); | 1127 | unregister_pm_notifier(&battery->pm_nb); |
1128 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
1129 | acpi_battery_remove_fs(device); | ||
1130 | #endif | ||
819 | sysfs_remove_battery(battery); | 1131 | sysfs_remove_battery(battery); |
820 | mutex_destroy(&battery->lock); | 1132 | mutex_destroy(&battery->lock); |
821 | mutex_destroy(&battery->sysfs_lock); | 1133 | mutex_destroy(&battery->sysfs_lock); |
@@ -866,7 +1178,19 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie) | |||
866 | 1178 | ||
867 | if (dmi_check_system(bat_dmi_table)) | 1179 | if (dmi_check_system(bat_dmi_table)) |
868 | battery_bix_broken_package = 1; | 1180 | battery_bix_broken_package = 1; |
869 | acpi_bus_register_driver(&acpi_battery_driver); | 1181 | |
1182 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
1183 | acpi_battery_dir = acpi_lock_battery_dir(); | ||
1184 | if (!acpi_battery_dir) | ||
1185 | return; | ||
1186 | #endif | ||
1187 | if (acpi_bus_register_driver(&acpi_battery_driver) < 0) { | ||
1188 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
1189 | acpi_unlock_battery_dir(acpi_battery_dir); | ||
1190 | #endif | ||
1191 | return; | ||
1192 | } | ||
1193 | return; | ||
870 | } | 1194 | } |
871 | 1195 | ||
872 | static int __init acpi_battery_init(void) | 1196 | static int __init acpi_battery_init(void) |
@@ -878,6 +1202,9 @@ static int __init acpi_battery_init(void) | |||
878 | static void __exit acpi_battery_exit(void) | 1202 | static void __exit acpi_battery_exit(void) |
879 | { | 1203 | { |
880 | acpi_bus_unregister_driver(&acpi_battery_driver); | 1204 | acpi_bus_unregister_driver(&acpi_battery_driver); |
1205 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
1206 | acpi_unlock_battery_dir(acpi_battery_dir); | ||
1207 | #endif | ||
881 | } | 1208 | } |
882 | 1209 | ||
883 | module_init(acpi_battery_init); | 1210 | module_init(acpi_battery_init); |
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index afec4526c48a..3d8413d02a97 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c | |||
@@ -314,6 +314,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
314 | DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"), | 314 | DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"), |
315 | }, | 315 | }, |
316 | }, | 316 | }, |
317 | { | ||
318 | .callback = dmi_disable_osi_win8, | ||
319 | .ident = "Dell Inspiron 7737", | ||
320 | .matches = { | ||
321 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
322 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7737"), | ||
323 | }, | ||
324 | }, | ||
317 | 325 | ||
318 | /* | 326 | /* |
319 | * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. | 327 | * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. |
@@ -374,6 +382,19 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
374 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T500"), | 382 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T500"), |
375 | }, | 383 | }, |
376 | }, | 384 | }, |
385 | /* | ||
386 | * Without this this EEEpc exports a non working WMI interface, with | ||
387 | * this it exports a working "good old" eeepc_laptop interface, fixing | ||
388 | * both brightness control, and rfkill not working. | ||
389 | */ | ||
390 | { | ||
391 | .callback = dmi_enable_osi_linux, | ||
392 | .ident = "Asus EEE PC 1015PX", | ||
393 | .matches = { | ||
394 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."), | ||
395 | DMI_MATCH(DMI_PRODUCT_NAME, "1015PX"), | ||
396 | }, | ||
397 | }, | ||
377 | {} | 398 | {} |
378 | }; | 399 | }; |
379 | 400 | ||
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index e7e5844c87d0..cf925c4f36b7 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -380,9 +380,8 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) | |||
380 | break; | 380 | break; |
381 | 381 | ||
382 | default: | 382 | default: |
383 | acpi_handle_warn(handle, "Unsupported event type 0x%x\n", type); | 383 | acpi_handle_debug(handle, "Unknown event type 0x%x\n", type); |
384 | ost_code = ACPI_OST_SC_UNRECOGNIZED_NOTIFY; | 384 | break; |
385 | goto err; | ||
386 | } | 385 | } |
387 | 386 | ||
388 | adev = acpi_bus_get_acpi_device(handle); | 387 | adev = acpi_bus_get_acpi_device(handle); |
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c new file mode 100644 index 000000000000..6c9ee68e46fb --- /dev/null +++ b/drivers/acpi/cm_sbs.c | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or (at | ||
7 | * your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
17 | * | ||
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/acpi.h> | ||
25 | #include <linux/types.h> | ||
26 | #include <linux/proc_fs.h> | ||
27 | #include <linux/seq_file.h> | ||
28 | #include <acpi/acpi_bus.h> | ||
29 | #include <acpi/acpi_drivers.h> | ||
30 | |||
31 | #define PREFIX "ACPI: " | ||
32 | |||
33 | ACPI_MODULE_NAME("cm_sbs"); | ||
34 | #define ACPI_AC_CLASS "ac_adapter" | ||
35 | #define ACPI_BATTERY_CLASS "battery" | ||
36 | #define _COMPONENT ACPI_SBS_COMPONENT | ||
37 | static struct proc_dir_entry *acpi_ac_dir; | ||
38 | static struct proc_dir_entry *acpi_battery_dir; | ||
39 | |||
40 | static DEFINE_MUTEX(cm_sbs_mutex); | ||
41 | |||
42 | static int lock_ac_dir_cnt; | ||
43 | static int lock_battery_dir_cnt; | ||
44 | |||
45 | struct proc_dir_entry *acpi_lock_ac_dir(void) | ||
46 | { | ||
47 | mutex_lock(&cm_sbs_mutex); | ||
48 | if (!acpi_ac_dir) | ||
49 | acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir); | ||
50 | if (acpi_ac_dir) { | ||
51 | lock_ac_dir_cnt++; | ||
52 | } else { | ||
53 | printk(KERN_ERR PREFIX | ||
54 | "Cannot create %s\n", ACPI_AC_CLASS); | ||
55 | } | ||
56 | mutex_unlock(&cm_sbs_mutex); | ||
57 | return acpi_ac_dir; | ||
58 | } | ||
59 | EXPORT_SYMBOL(acpi_lock_ac_dir); | ||
60 | |||
61 | void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir_param) | ||
62 | { | ||
63 | mutex_lock(&cm_sbs_mutex); | ||
64 | if (acpi_ac_dir_param) | ||
65 | lock_ac_dir_cnt--; | ||
66 | if (lock_ac_dir_cnt == 0 && acpi_ac_dir_param && acpi_ac_dir) { | ||
67 | remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); | ||
68 | acpi_ac_dir = NULL; | ||
69 | } | ||
70 | mutex_unlock(&cm_sbs_mutex); | ||
71 | } | ||
72 | EXPORT_SYMBOL(acpi_unlock_ac_dir); | ||
73 | |||
74 | struct proc_dir_entry *acpi_lock_battery_dir(void) | ||
75 | { | ||
76 | mutex_lock(&cm_sbs_mutex); | ||
77 | if (!acpi_battery_dir) { | ||
78 | acpi_battery_dir = | ||
79 | proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir); | ||
80 | } | ||
81 | if (acpi_battery_dir) { | ||
82 | lock_battery_dir_cnt++; | ||
83 | } else { | ||
84 | printk(KERN_ERR PREFIX | ||
85 | "Cannot create %s\n", ACPI_BATTERY_CLASS); | ||
86 | } | ||
87 | mutex_unlock(&cm_sbs_mutex); | ||
88 | return acpi_battery_dir; | ||
89 | } | ||
90 | EXPORT_SYMBOL(acpi_lock_battery_dir); | ||
91 | |||
92 | void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param) | ||
93 | { | ||
94 | mutex_lock(&cm_sbs_mutex); | ||
95 | if (acpi_battery_dir_param) | ||
96 | lock_battery_dir_cnt--; | ||
97 | if (lock_battery_dir_cnt == 0 && acpi_battery_dir_param | ||
98 | && acpi_battery_dir) { | ||
99 | remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); | ||
100 | acpi_battery_dir = NULL; | ||
101 | } | ||
102 | mutex_unlock(&cm_sbs_mutex); | ||
103 | return; | ||
104 | } | ||
105 | EXPORT_SYMBOL(acpi_unlock_battery_dir); | ||
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index d7d32c28829b..ad11ba4a412d 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -206,13 +206,13 @@ unlock: | |||
206 | spin_unlock_irqrestore(&ec->lock, flags); | 206 | spin_unlock_irqrestore(&ec->lock, flags); |
207 | } | 207 | } |
208 | 208 | ||
209 | static int acpi_ec_sync_query(struct acpi_ec *ec); | 209 | static int acpi_ec_sync_query(struct acpi_ec *ec, u8 *data); |
210 | 210 | ||
211 | static int ec_check_sci_sync(struct acpi_ec *ec, u8 state) | 211 | static int ec_check_sci_sync(struct acpi_ec *ec, u8 state) |
212 | { | 212 | { |
213 | if (state & ACPI_EC_FLAG_SCI) { | 213 | if (state & ACPI_EC_FLAG_SCI) { |
214 | if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) | 214 | if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) |
215 | return acpi_ec_sync_query(ec); | 215 | return acpi_ec_sync_query(ec, NULL); |
216 | } | 216 | } |
217 | return 0; | 217 | return 0; |
218 | } | 218 | } |
@@ -443,10 +443,8 @@ acpi_handle ec_get_handle(void) | |||
443 | 443 | ||
444 | EXPORT_SYMBOL(ec_get_handle); | 444 | EXPORT_SYMBOL(ec_get_handle); |
445 | 445 | ||
446 | static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 *data); | ||
447 | |||
448 | /* | 446 | /* |
449 | * Clears stale _Q events that might have accumulated in the EC. | 447 | * Process _Q events that might have accumulated in the EC. |
450 | * Run with locked ec mutex. | 448 | * Run with locked ec mutex. |
451 | */ | 449 | */ |
452 | static void acpi_ec_clear(struct acpi_ec *ec) | 450 | static void acpi_ec_clear(struct acpi_ec *ec) |
@@ -455,7 +453,7 @@ static void acpi_ec_clear(struct acpi_ec *ec) | |||
455 | u8 value = 0; | 453 | u8 value = 0; |
456 | 454 | ||
457 | for (i = 0; i < ACPI_EC_CLEAR_MAX; i++) { | 455 | for (i = 0; i < ACPI_EC_CLEAR_MAX; i++) { |
458 | status = acpi_ec_query_unlocked(ec, &value); | 456 | status = acpi_ec_sync_query(ec, &value); |
459 | if (status || !value) | 457 | if (status || !value) |
460 | break; | 458 | break; |
461 | } | 459 | } |
@@ -582,13 +580,18 @@ static void acpi_ec_run(void *cxt) | |||
582 | kfree(handler); | 580 | kfree(handler); |
583 | } | 581 | } |
584 | 582 | ||
585 | static int acpi_ec_sync_query(struct acpi_ec *ec) | 583 | static int acpi_ec_sync_query(struct acpi_ec *ec, u8 *data) |
586 | { | 584 | { |
587 | u8 value = 0; | 585 | u8 value = 0; |
588 | int status; | 586 | int status; |
589 | struct acpi_ec_query_handler *handler, *copy; | 587 | struct acpi_ec_query_handler *handler, *copy; |
590 | if ((status = acpi_ec_query_unlocked(ec, &value))) | 588 | |
589 | status = acpi_ec_query_unlocked(ec, &value); | ||
590 | if (data) | ||
591 | *data = value; | ||
592 | if (status) | ||
591 | return status; | 593 | return status; |
594 | |||
592 | list_for_each_entry(handler, &ec->list, node) { | 595 | list_for_each_entry(handler, &ec->list, node) { |
593 | if (value == handler->query_bit) { | 596 | if (value == handler->query_bit) { |
594 | /* have custom handler for this bit */ | 597 | /* have custom handler for this bit */ |
@@ -612,7 +615,7 @@ static void acpi_ec_gpe_query(void *ec_cxt) | |||
612 | if (!ec) | 615 | if (!ec) |
613 | return; | 616 | return; |
614 | mutex_lock(&ec->mutex); | 617 | mutex_lock(&ec->mutex); |
615 | acpi_ec_sync_query(ec); | 618 | acpi_ec_sync_query(ec, NULL); |
616 | mutex_unlock(&ec->mutex); | 619 | mutex_unlock(&ec->mutex); |
617 | } | 620 | } |
618 | 621 | ||
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 8b6990e417ec..f8bc5a755dda 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -457,10 +457,10 @@ static struct dmi_system_id video_dmi_table[] __initdata = { | |||
457 | }, | 457 | }, |
458 | { | 458 | { |
459 | .callback = video_set_use_native_backlight, | 459 | .callback = video_set_use_native_backlight, |
460 | .ident = "ThinkPad T430s", | 460 | .ident = "ThinkPad T430 and T430s", |
461 | .matches = { | 461 | .matches = { |
462 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | 462 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
463 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T430s"), | 463 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T430"), |
464 | }, | 464 | }, |
465 | }, | 465 | }, |
466 | { | 466 | { |
@@ -472,7 +472,7 @@ static struct dmi_system_id video_dmi_table[] __initdata = { | |||
472 | }, | 472 | }, |
473 | }, | 473 | }, |
474 | { | 474 | { |
475 | .callback = video_set_use_native_backlight, | 475 | .callback = video_set_use_native_backlight, |
476 | .ident = "ThinkPad X1 Carbon", | 476 | .ident = "ThinkPad X1 Carbon", |
477 | .matches = { | 477 | .matches = { |
478 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | 478 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
@@ -500,7 +500,7 @@ static struct dmi_system_id video_dmi_table[] __initdata = { | |||
500 | .ident = "Dell Inspiron 7520", | 500 | .ident = "Dell Inspiron 7520", |
501 | .matches = { | 501 | .matches = { |
502 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | 502 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
503 | DMI_MATCH(DMI_PRODUCT_VERSION, "Inspiron 7520"), | 503 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7520"), |
504 | }, | 504 | }, |
505 | }, | 505 | }, |
506 | { | 506 | { |
@@ -513,6 +513,14 @@ static struct dmi_system_id video_dmi_table[] __initdata = { | |||
513 | }, | 513 | }, |
514 | { | 514 | { |
515 | .callback = video_set_use_native_backlight, | 515 | .callback = video_set_use_native_backlight, |
516 | .ident = "Acer Aspire 5742G", | ||
517 | .matches = { | ||
518 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | ||
519 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5742G"), | ||
520 | }, | ||
521 | }, | ||
522 | { | ||
523 | .callback = video_set_use_native_backlight, | ||
516 | .ident = "Acer Aspire V5-431", | 524 | .ident = "Acer Aspire V5-431", |
517 | .matches = { | 525 | .matches = { |
518 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | 526 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |