aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c1
-rw-r--r--drivers/acpi/battery.c38
-rw-r--r--drivers/acpi/button.c4
-rw-r--r--drivers/acpi/scan.c37
-rw-r--r--drivers/pnp/base.h5
-rw-r--r--drivers/pnp/core.c3
-rw-r--r--drivers/pnp/driver.c2
-rw-r--r--drivers/pnp/pnpacpi/core.c2
-rw-r--r--include/acpi/acpi_bus.h2
9 files changed, 68 insertions, 26 deletions
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
index cd8da247dda1..a2baafb2fe6d 100644
--- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -701,6 +701,7 @@ static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
701 per_cpu(acfreq_data, policy->cpu) = NULL; 701 per_cpu(acfreq_data, policy->cpu) = NULL;
702 acpi_processor_unregister_performance(data->acpi_data, 702 acpi_processor_unregister_performance(data->acpi_data,
703 policy->cpu); 703 policy->cpu);
704 kfree(data->freq_table);
704 kfree(data); 705 kfree(data);
705 } 706 }
706 707
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 7b8787b490f6..0b2707ee094b 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -95,6 +95,7 @@ enum {
95 * due to bad math. 95 * due to bad math.
96 */ 96 */
97 ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, 97 ACPI_BATTERY_QUIRK_SIGNED16_CURRENT,
98 ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY,
98}; 99};
99 100
100struct acpi_battery { 101struct acpi_battery {
@@ -405,6 +406,8 @@ static int acpi_battery_get_info(struct acpi_battery *battery)
405 result = extract_package(battery, buffer.pointer, 406 result = extract_package(battery, buffer.pointer,
406 info_offsets, ARRAY_SIZE(info_offsets)); 407 info_offsets, ARRAY_SIZE(info_offsets));
407 kfree(buffer.pointer); 408 kfree(buffer.pointer);
409 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags))
410 battery->full_charge_capacity = battery->design_capacity;
408 return result; 411 return result;
409} 412}
410 413
@@ -441,6 +444,10 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
441 battery->rate_now != -1) 444 battery->rate_now != -1)
442 battery->rate_now = abs((s16)battery->rate_now); 445 battery->rate_now = abs((s16)battery->rate_now);
443 446
447 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
448 && battery->capacity_now >= 0 && battery->capacity_now <= 100)
449 battery->capacity_now = (battery->capacity_now *
450 battery->full_charge_capacity) / 100;
444 return result; 451 return result;
445} 452}
446 453
@@ -552,6 +559,33 @@ static void acpi_battery_quirks(struct acpi_battery *battery)
552 } 559 }
553} 560}
554 561
562/*
563 * According to the ACPI spec, some kinds of primary batteries can
564 * report percentage battery remaining capacity directly to OS.
565 * In this case, it reports the Last Full Charged Capacity == 100
566 * and BatteryPresentRate == 0xFFFFFFFF.
567 *
568 * Now we found some battery reports percentage remaining capacity
569 * even if it's rechargeable.
570 * https://bugzilla.kernel.org/show_bug.cgi?id=15979
571 *
572 * Handle this correctly so that they won't break userspace.
573 */
574static void acpi_battery_quirks2(struct acpi_battery *battery)
575{
576 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags))
577 return ;
578
579 if (battery->full_charge_capacity == 100 &&
580 battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN &&
581 battery->capacity_now >=0 && battery->capacity_now <= 100) {
582 set_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags);
583 battery->full_charge_capacity = battery->design_capacity;
584 battery->capacity_now = (battery->capacity_now *
585 battery->full_charge_capacity) / 100;
586 }
587}
588
555static int acpi_battery_update(struct acpi_battery *battery) 589static int acpi_battery_update(struct acpi_battery *battery)
556{ 590{
557 int result, old_present = acpi_battery_present(battery); 591 int result, old_present = acpi_battery_present(battery);
@@ -573,7 +607,9 @@ static int acpi_battery_update(struct acpi_battery *battery)
573 } 607 }
574 if (!battery->bat.dev) 608 if (!battery->bat.dev)
575 sysfs_add_battery(battery); 609 sysfs_add_battery(battery);
576 return acpi_battery_get_state(battery); 610 result = acpi_battery_get_state(battery);
611 acpi_battery_quirks2(battery);
612 return result;
577} 613}
578 614
579/* -------------------------------------------------------------------------- 615/* --------------------------------------------------------------------------
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 1575a9b51f1d..71ef9cd0735f 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -338,7 +338,8 @@ static int acpi_button_add(struct acpi_device *device)
338{ 338{
339 struct acpi_button *button; 339 struct acpi_button *button;
340 struct input_dev *input; 340 struct input_dev *input;
341 char *hid, *name, *class; 341 const char *hid = acpi_device_hid(device);
342 char *name, *class;
342 int error; 343 int error;
343 344
344 button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL); 345 button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL);
@@ -353,7 +354,6 @@ static int acpi_button_add(struct acpi_device *device)
353 goto err_free_button; 354 goto err_free_button;
354 } 355 }
355 356
356 hid = acpi_device_hid(device);
357 name = acpi_device_name(device); 357 name = acpi_device_name(device);
358 class = acpi_device_class(device); 358 class = acpi_device_class(device);
359 359
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index b23825ecfa37..6155eeb2e89a 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -26,6 +26,8 @@ extern struct acpi_device *acpi_root;
26 26
27#define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent) 27#define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent)
28 28
29static const char *dummy_hid = "device";
30
29static LIST_HEAD(acpi_device_list); 31static LIST_HEAD(acpi_device_list);
30static LIST_HEAD(acpi_bus_id_list); 32static LIST_HEAD(acpi_bus_id_list);
31DEFINE_MUTEX(acpi_device_lock); 33DEFINE_MUTEX(acpi_device_lock);
@@ -49,6 +51,9 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
49 int count; 51 int count;
50 struct acpi_hardware_id *id; 52 struct acpi_hardware_id *id;
51 53
54 if (list_empty(&acpi_dev->pnp.ids))
55 return 0;
56
52 len = snprintf(modalias, size, "acpi:"); 57 len = snprintf(modalias, size, "acpi:");
53 size -= len; 58 size -= len;
54 59
@@ -202,13 +207,15 @@ static int acpi_device_setup_files(struct acpi_device *dev)
202 goto end; 207 goto end;
203 } 208 }
204 209
205 result = device_create_file(&dev->dev, &dev_attr_hid); 210 if (!list_empty(&dev->pnp.ids)) {
206 if (result) 211 result = device_create_file(&dev->dev, &dev_attr_hid);
207 goto end; 212 if (result)
213 goto end;
208 214
209 result = device_create_file(&dev->dev, &dev_attr_modalias); 215 result = device_create_file(&dev->dev, &dev_attr_modalias);
210 if (result) 216 if (result)
211 goto end; 217 goto end;
218 }
212 219
213 /* 220 /*
214 * If device has _EJ0, 'eject' file is created that is used to trigger 221 * If device has _EJ0, 'eject' file is created that is used to trigger
@@ -316,6 +323,9 @@ static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
316 struct acpi_device *acpi_dev = to_acpi_device(dev); 323 struct acpi_device *acpi_dev = to_acpi_device(dev);
317 int len; 324 int len;
318 325
326 if (list_empty(&acpi_dev->pnp.ids))
327 return 0;
328
319 if (add_uevent_var(env, "MODALIAS=")) 329 if (add_uevent_var(env, "MODALIAS="))
320 return -ENOMEM; 330 return -ENOMEM;
321 len = create_modalias(acpi_dev, &env->buf[env->buflen - 1], 331 len = create_modalias(acpi_dev, &env->buf[env->buflen - 1],
@@ -1010,10 +1020,13 @@ static int acpi_dock_match(struct acpi_device *device)
1010 return acpi_get_handle(device->handle, "_DCK", &tmp); 1020 return acpi_get_handle(device->handle, "_DCK", &tmp);
1011} 1021}
1012 1022
1013char *acpi_device_hid(struct acpi_device *device) 1023const char *acpi_device_hid(struct acpi_device *device)
1014{ 1024{
1015 struct acpi_hardware_id *hid; 1025 struct acpi_hardware_id *hid;
1016 1026
1027 if (list_empty(&device->pnp.ids))
1028 return dummy_hid;
1029
1017 hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list); 1030 hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list);
1018 return hid->id; 1031 return hid->id;
1019} 1032}
@@ -1142,16 +1155,6 @@ static void acpi_device_set_id(struct acpi_device *device)
1142 acpi_add_id(device, ACPI_BUTTON_HID_SLEEPF); 1155 acpi_add_id(device, ACPI_BUTTON_HID_SLEEPF);
1143 break; 1156 break;
1144 } 1157 }
1145
1146 /*
1147 * We build acpi_devices for some objects that don't have _HID or _CID,
1148 * e.g., PCI bridges and slots. Drivers can't bind to these objects,
1149 * but we do use them indirectly by traversing the acpi_device tree.
1150 * This generic ID isn't useful for driver binding, but it provides
1151 * the useful property that "every acpi_device has an ID."
1152 */
1153 if (list_empty(&device->pnp.ids))
1154 acpi_add_id(device, "device");
1155} 1158}
1156 1159
1157static int acpi_device_set_context(struct acpi_device *device) 1160static int acpi_device_set_context(struct acpi_device *device)
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index 0bab84ebb15d..19bc73695475 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -12,11 +12,12 @@ void pnp_unregister_protocol(struct pnp_protocol *protocol);
12 12
13#define PNP_EISA_ID_MASK 0x7fffffff 13#define PNP_EISA_ID_MASK 0x7fffffff
14void pnp_eisa_id_to_string(u32 id, char *str); 14void pnp_eisa_id_to_string(u32 id, char *str);
15struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *, int id, char *pnpid); 15struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *, int id,
16 const char *pnpid);
16struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid); 17struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid);
17 18
18int pnp_add_device(struct pnp_dev *dev); 19int pnp_add_device(struct pnp_dev *dev);
19struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id); 20struct pnp_id *pnp_add_id(struct pnp_dev *dev, const char *id);
20 21
21int pnp_add_card(struct pnp_card *card); 22int pnp_add_card(struct pnp_card *card);
22void pnp_remove_card(struct pnp_card *card); 23void pnp_remove_card(struct pnp_card *card);
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index 88b3cde52596..c79ee1ded68d 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -124,7 +124,8 @@ static void pnp_release_device(struct device *dmdev)
124 kfree(dev); 124 kfree(dev);
125} 125}
126 126
127struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid) 127struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id,
128 const char *pnpid)
128{ 129{
129 struct pnp_dev *dev; 130 struct pnp_dev *dev;
130 struct pnp_id *dev_id; 131 struct pnp_id *dev_id;
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index cd11b113494f..d1dbb9df53fa 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -236,7 +236,7 @@ void pnp_unregister_driver(struct pnp_driver *drv)
236 * @dev: pointer to the desired device 236 * @dev: pointer to the desired device
237 * @id: pointer to an EISA id string 237 * @id: pointer to an EISA id string
238 */ 238 */
239struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id) 239struct pnp_id *pnp_add_id(struct pnp_dev *dev, const char *id)
240{ 240{
241 struct pnp_id *dev_id, *ptr; 241 struct pnp_id *dev_id, *ptr;
242 242
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index dc4e32e031e9..4aafcf89b03b 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -59,7 +59,7 @@ static inline int __init is_exclusive_device(struct acpi_device *dev)
59#define TEST_ALPHA(c) \ 59#define TEST_ALPHA(c) \
60 if (!('@' <= (c) || (c) <= 'Z')) \ 60 if (!('@' <= (c) || (c) <= 'Z')) \
61 return 0 61 return 0
62static int __init ispnpidacpi(char *id) 62static int __init ispnpidacpi(const char *id)
63{ 63{
64 TEST_ALPHA(id[0]); 64 TEST_ALPHA(id[0]);
65 TEST_ALPHA(id[1]); 65 TEST_ALPHA(id[1]);
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 4de84ce3a927..a47bb908ddcd 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -184,7 +184,7 @@ struct acpi_device_pnp {
184 184
185#define acpi_device_bid(d) ((d)->pnp.bus_id) 185#define acpi_device_bid(d) ((d)->pnp.bus_id)
186#define acpi_device_adr(d) ((d)->pnp.bus_address) 186#define acpi_device_adr(d) ((d)->pnp.bus_address)
187char *acpi_device_hid(struct acpi_device *device); 187const char *acpi_device_hid(struct acpi_device *device);
188#define acpi_device_name(d) ((d)->pnp.device_name) 188#define acpi_device_name(d) ((d)->pnp.device_name)
189#define acpi_device_class(d) ((d)->pnp.device_class) 189#define acpi_device_class(d) ((d)->pnp.device_class)
190 190