aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-04-08 06:31:56 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-04-08 06:31:56 -0400
commit0f0c8aa0d0562954cdfa135efb827067de7ba855 (patch)
treef1825e060e5b51374ee79388b47be662c9a0b297 /drivers/acpi
parent077f893bd942b23d8e27c90f8f60018ce21010a0 (diff)
parent545d6e189a41c94c11f55045a771118eccc9d9eb (diff)
Merge branch 'acpi-assorted' into linux-next
* acpi-assorted: PCI / ACPI: Don't query OSC support with all possible controls ACPI / processor_thermal: avoid null pointer deference error ACPI / fan: avoid null pointer deference error ACPI / video: Fix applying indexed initial brightness value. ACPI / video: Make logic a little easier to understand. ACPI / video: Fix brightness control initialization for some laptops. ACPI: Use resource_size() in osl.c ACPI / acpi_pad: Used PTR_RET ACPI: suppress compiler warning in container.c ACPI: suppress compiler warning in battery.c ACPI: suppress compiler warnings in processor_throttling.c ACPI: suppress compiler warnings in button.c ACPI: replace kmalloc+memcpy with kmemdup ACPI: Remove acpi_pci_bind_root() definition ACPI video: ignore BIOS backlight value for HP dm4
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpi_pad.c2
-rw-r--r--drivers/acpi/battery.c2
-rw-r--r--drivers/acpi/bus.c5
-rw-r--r--drivers/acpi/button.c1
-rw-r--r--drivers/acpi/container.c2
-rw-r--r--drivers/acpi/fan.c8
-rw-r--r--drivers/acpi/osl.c2
-rw-r--r--drivers/acpi/pci_root.c4
-rw-r--r--drivers/acpi/processor_thermal.c24
-rw-r--r--drivers/acpi/processor_throttling.c3
-rw-r--r--drivers/acpi/video.c110
11 files changed, 107 insertions, 56 deletions
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 31de1043eea0..27bb6a91de5f 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -236,7 +236,7 @@ static int create_power_saving_task(void)
236 ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread, 236 ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread,
237 (void *)(unsigned long)ps_tsk_num, 237 (void *)(unsigned long)ps_tsk_num,
238 "acpi_pad/%d", ps_tsk_num); 238 "acpi_pad/%d", ps_tsk_num);
239 rc = IS_ERR(ps_tsks[ps_tsk_num]) ? PTR_ERR(ps_tsks[ps_tsk_num]) : 0; 239 rc = PTR_RET(ps_tsks[ps_tsk_num]);
240 if (!rc) 240 if (!rc)
241 ps_tsk_num++; 241 ps_tsk_num++;
242 else 242 else
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index c5cd5b5513e6..0cc384b72943 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -146,7 +146,7 @@ struct acpi_battery {
146 146
147#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat) 147#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat)
148 148
149inline int acpi_battery_present(struct acpi_battery *battery) 149static inline int acpi_battery_present(struct acpi_battery *battery)
150{ 150{
151 return battery->device->status.battery_present; 151 return battery->device->status.battery_present;
152} 152}
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 01708a165368..292de3cab9cc 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -288,13 +288,12 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
288 } 288 }
289out_success: 289out_success:
290 context->ret.length = out_obj->buffer.length; 290 context->ret.length = out_obj->buffer.length;
291 context->ret.pointer = kmalloc(context->ret.length, GFP_KERNEL); 291 context->ret.pointer = kmemdup(out_obj->buffer.pointer,
292 context->ret.length, GFP_KERNEL);
292 if (!context->ret.pointer) { 293 if (!context->ret.pointer) {
293 status = AE_NO_MEMORY; 294 status = AE_NO_MEMORY;
294 goto out_kfree; 295 goto out_kfree;
295 } 296 }
296 memcpy(context->ret.pointer, out_obj->buffer.pointer,
297 context->ret.length);
298 status = AE_OK; 297 status = AE_OK;
299 298
300out_kfree: 299out_kfree:
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 86c7d5445c38..92a659aa6396 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -33,6 +33,7 @@
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <acpi/acpi_bus.h> 34#include <acpi/acpi_bus.h>
35#include <acpi/acpi_drivers.h> 35#include <acpi/acpi_drivers.h>
36#include <acpi/button.h>
36 37
37#define PREFIX "ACPI: " 38#define PREFIX "ACPI: "
38 39
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index f9f8a08827fa..e23151667655 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -30,6 +30,8 @@
30 30
31#include "internal.h" 31#include "internal.h"
32 32
33#include "internal.h"
34
33#define PREFIX "ACPI: " 35#define PREFIX "ACPI: "
34 36
35#define _COMPONENT ACPI_CONTAINER_COMPONENT 37#define _COMPONENT ACPI_CONTAINER_COMPONENT
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index f815da82c765..8d1c0105e113 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -174,9 +174,13 @@ static int acpi_fan_add(struct acpi_device *device)
174 174
175static int acpi_fan_remove(struct acpi_device *device) 175static int acpi_fan_remove(struct acpi_device *device)
176{ 176{
177 struct thermal_cooling_device *cdev = acpi_driver_data(device); 177 struct thermal_cooling_device *cdev;
178
179 if (!device)
180 return -EINVAL;
178 181
179 if (!device || !cdev) 182 cdev = acpi_driver_data(device);
183 if (!cdev)
180 return -EINVAL; 184 return -EINVAL;
181 185
182 sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); 186 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 586e7e993d3d..4d31748faca3 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -1555,7 +1555,7 @@ int acpi_check_resource_conflict(const struct resource *res)
1555 else 1555 else
1556 space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY; 1556 space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY;
1557 1557
1558 length = res->end - res->start + 1; 1558 length = resource_size(res);
1559 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) 1559 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO)
1560 warn = 1; 1560 warn = 1;
1561 clash = acpi_check_address_range(space_id, res->start, length, warn); 1561 clash = acpi_check_address_range(space_id, res->start, length, warn);
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 6ae5e440436e..4241b8d844eb 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -201,8 +201,8 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root,
201 *control &= OSC_PCI_CONTROL_MASKS; 201 *control &= OSC_PCI_CONTROL_MASKS;
202 capbuf[OSC_CONTROL_TYPE] = *control | root->osc_control_set; 202 capbuf[OSC_CONTROL_TYPE] = *control | root->osc_control_set;
203 } else { 203 } else {
204 /* Run _OSC query for all possible controls. */ 204 /* Run _OSC query only with existing controls. */
205 capbuf[OSC_CONTROL_TYPE] = OSC_PCI_CONTROL_MASKS; 205 capbuf[OSC_CONTROL_TYPE] = root->osc_control_set;
206 } 206 }
207 207
208 status = acpi_pci_run_osc(root->device->handle, capbuf, &result); 208 status = acpi_pci_run_osc(root->device->handle, capbuf, &result);
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 641b5450a0db..e8e652710e65 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -218,9 +218,13 @@ processor_get_max_state(struct thermal_cooling_device *cdev,
218 unsigned long *state) 218 unsigned long *state)
219{ 219{
220 struct acpi_device *device = cdev->devdata; 220 struct acpi_device *device = cdev->devdata;
221 struct acpi_processor *pr = acpi_driver_data(device); 221 struct acpi_processor *pr;
222 222
223 if (!device || !pr) 223 if (!device)
224 return -EINVAL;
225
226 pr = acpi_driver_data(device);
227 if (!pr)
224 return -EINVAL; 228 return -EINVAL;
225 229
226 *state = acpi_processor_max_state(pr); 230 *state = acpi_processor_max_state(pr);
@@ -232,9 +236,13 @@ processor_get_cur_state(struct thermal_cooling_device *cdev,
232 unsigned long *cur_state) 236 unsigned long *cur_state)
233{ 237{
234 struct acpi_device *device = cdev->devdata; 238 struct acpi_device *device = cdev->devdata;
235 struct acpi_processor *pr = acpi_driver_data(device); 239 struct acpi_processor *pr;
236 240
237 if (!device || !pr) 241 if (!device)
242 return -EINVAL;
243
244 pr = acpi_driver_data(device);
245 if (!pr)
238 return -EINVAL; 246 return -EINVAL;
239 247
240 *cur_state = cpufreq_get_cur_state(pr->id); 248 *cur_state = cpufreq_get_cur_state(pr->id);
@@ -248,11 +256,15 @@ processor_set_cur_state(struct thermal_cooling_device *cdev,
248 unsigned long state) 256 unsigned long state)
249{ 257{
250 struct acpi_device *device = cdev->devdata; 258 struct acpi_device *device = cdev->devdata;
251 struct acpi_processor *pr = acpi_driver_data(device); 259 struct acpi_processor *pr;
252 int result = 0; 260 int result = 0;
253 int max_pstate; 261 int max_pstate;
254 262
255 if (!device || !pr) 263 if (!device)
264 return -EINVAL;
265
266 pr = acpi_driver_data(device);
267 if (!pr)
256 return -EINVAL; 268 return -EINVAL;
257 269
258 max_pstate = cpufreq_get_max_state(pr->id); 270 max_pstate = cpufreq_get_max_state(pr->id);
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 1d02b7b5ade0..e7dd2c1fee79 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -211,9 +211,10 @@ err_ret:
211 */ 211 */
212void acpi_processor_throttling_init(void) 212void acpi_processor_throttling_init(void)
213{ 213{
214 if (acpi_processor_update_tsd_coord()) 214 if (acpi_processor_update_tsd_coord()) {
215 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 215 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
216 "Assume no T-state coordination\n")); 216 "Assume no T-state coordination\n"));
217 }
217 218
218 return; 219 return;
219} 220}
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 313f959413dc..3cdd0471bc63 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -222,7 +222,7 @@ static int acpi_video_device_lcd_set_level(struct acpi_video_device *device,
222 int level); 222 int level);
223static int acpi_video_device_lcd_get_level_current( 223static int acpi_video_device_lcd_get_level_current(
224 struct acpi_video_device *device, 224 struct acpi_video_device *device,
225 unsigned long long *level, int init); 225 unsigned long long *level, bool raw);
226static int acpi_video_get_next_level(struct acpi_video_device *device, 226static int acpi_video_get_next_level(struct acpi_video_device *device,
227 u32 level_current, u32 event); 227 u32 level_current, u32 event);
228static int acpi_video_switch_brightness(struct acpi_video_device *device, 228static int acpi_video_switch_brightness(struct acpi_video_device *device,
@@ -236,7 +236,7 @@ static int acpi_video_get_brightness(struct backlight_device *bd)
236 struct acpi_video_device *vd = 236 struct acpi_video_device *vd =
237 (struct acpi_video_device *)bl_get_data(bd); 237 (struct acpi_video_device *)bl_get_data(bd);
238 238
239 if (acpi_video_device_lcd_get_level_current(vd, &cur_level, 0)) 239 if (acpi_video_device_lcd_get_level_current(vd, &cur_level, false))
240 return -EINVAL; 240 return -EINVAL;
241 for (i = 2; i < vd->brightness->count; i++) { 241 for (i = 2; i < vd->brightness->count; i++) {
242 if (vd->brightness->levels[i] == cur_level) 242 if (vd->brightness->levels[i] == cur_level)
@@ -281,7 +281,7 @@ static int video_get_cur_state(struct thermal_cooling_device *cooling_dev, unsig
281 unsigned long long level; 281 unsigned long long level;
282 int offset; 282 int offset;
283 283
284 if (acpi_video_device_lcd_get_level_current(video, &level, 0)) 284 if (acpi_video_device_lcd_get_level_current(video, &level, false))
285 return -EINVAL; 285 return -EINVAL;
286 for (offset = 2; offset < video->brightness->count; offset++) 286 for (offset = 2; offset < video->brightness->count; offset++)
287 if (level == video->brightness->levels[offset]) { 287 if (level == video->brightness->levels[offset]) {
@@ -447,12 +447,45 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
447 DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13 - 2000 Notebook PC"), 447 DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13 - 2000 Notebook PC"),
448 }, 448 },
449 }, 449 },
450 {
451 .callback = video_ignore_initial_backlight,
452 .ident = "HP Pavilion dm4",
453 .matches = {
454 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
455 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dm4 Notebook PC"),
456 },
457 },
450 {} 458 {}
451}; 459};
452 460
461static unsigned long long
462acpi_video_bqc_value_to_level(struct acpi_video_device *device,
463 unsigned long long bqc_value)
464{
465 unsigned long long level;
466
467 if (device->brightness->flags._BQC_use_index) {
468 /*
469 * _BQC returns an index that doesn't account for
470 * the first 2 items with special meaning, so we need
471 * to compensate for that by offsetting ourselves
472 */
473 if (device->brightness->flags._BCL_reversed)
474 bqc_value = device->brightness->count - 3 - bqc_value;
475
476 level = device->brightness->levels[bqc_value + 2];
477 } else {
478 level = bqc_value;
479 }
480
481 level += bqc_offset_aml_bug_workaround;
482
483 return level;
484}
485
453static int 486static int
454acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, 487acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
455 unsigned long long *level, int init) 488 unsigned long long *level, bool raw)
456{ 489{
457 acpi_status status = AE_OK; 490 acpi_status status = AE_OK;
458 int i; 491 int i;
@@ -463,29 +496,30 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
463 status = acpi_evaluate_integer(device->dev->handle, buf, 496 status = acpi_evaluate_integer(device->dev->handle, buf,
464 NULL, level); 497 NULL, level);
465 if (ACPI_SUCCESS(status)) { 498 if (ACPI_SUCCESS(status)) {
466 if (device->brightness->flags._BQC_use_index) { 499 if (raw) {
467 if (device->brightness->flags._BCL_reversed) 500 /*
468 *level = device->brightness->count 501 * Caller has indicated he wants the raw
469 - 3 - (*level); 502 * value returned by _BQC, so don't furtherly
470 *level = device->brightness->levels[*level + 2]; 503 * mess with the value.
471 504 */
505 return 0;
472 } 506 }
473 *level += bqc_offset_aml_bug_workaround; 507
508 *level = acpi_video_bqc_value_to_level(device, *level);
509
474 for (i = 2; i < device->brightness->count; i++) 510 for (i = 2; i < device->brightness->count; i++)
475 if (device->brightness->levels[i] == *level) { 511 if (device->brightness->levels[i] == *level) {
476 device->brightness->curr = *level; 512 device->brightness->curr = *level;
477 return 0; 513 return 0;
478 } 514 }
479 if (!init) { 515 /*
480 /* 516 * BQC returned an invalid level.
481 * BQC returned an invalid level. 517 * Stop using it.
482 * Stop using it. 518 */
483 */ 519 ACPI_WARNING((AE_INFO,
484 ACPI_WARNING((AE_INFO, 520 "%s returned an invalid level",
485 "%s returned an invalid level", 521 buf));
486 buf)); 522 device->cap._BQC = device->cap._BCQ = 0;
487 device->cap._BQC = device->cap._BCQ = 0;
488 }
489 } else { 523 } else {
490 /* Fixme: 524 /* Fixme:
491 * should we return an error or ignore this failure? 525 * should we return an error or ignore this failure?
@@ -703,7 +737,8 @@ acpi_video_init_brightness(struct acpi_video_device *device)
703 if (!device->cap._BQC) 737 if (!device->cap._BQC)
704 goto set_level; 738 goto set_level;
705 739
706 result = acpi_video_device_lcd_get_level_current(device, &level_old, 1); 740 result = acpi_video_device_lcd_get_level_current(device,
741 &level_old, true);
707 if (result) 742 if (result)
708 goto out_free_levels; 743 goto out_free_levels;
709 744
@@ -714,31 +749,27 @@ acpi_video_init_brightness(struct acpi_video_device *device)
714 if (result) 749 if (result)
715 goto out_free_levels; 750 goto out_free_levels;
716 751
717 result = acpi_video_device_lcd_get_level_current(device, &level, 0); 752 result = acpi_video_device_lcd_get_level_current(device, &level, true);
718 if (result) 753 if (result)
719 goto out_free_levels; 754 goto out_free_levels;
720 755
721 br->flags._BQC_use_index = (level == max_level ? 0 : 1); 756 br->flags._BQC_use_index = (level == max_level ? 0 : 1);
722 757
723 if (!br->flags._BQC_use_index) { 758 if (use_bios_initial_backlight) {
759 level = acpi_video_bqc_value_to_level(device, level_old);
724 /* 760 /*
725 * Set the backlight to the initial state. 761 * On some buggy laptops, _BQC returns an uninitialized
726 * On some buggy laptops, _BQC returns an uninitialized value 762 * value when invoked for the first time, i.e.
727 * when invoked for the first time, i.e. level_old is invalid. 763 * level_old is invalid (no matter whether it's a level
728 * set the backlight to max_level in this case 764 * or an index). Set the backlight to max_level in this case.
729 */ 765 */
730 if (use_bios_initial_backlight) { 766 for (i = 2; i < br->count; i++)
731 for (i = 2; i < br->count; i++) 767 if (level_old == br->levels[i])
732 if (level_old == br->levels[i]) 768 break;
733 level = level_old; 769 if (i == br->count)
734 } 770 level = max_level;
735 goto set_level;
736 } 771 }
737 772
738 if (br->flags._BCL_reversed)
739 level_old = (br->count - 1) - level_old;
740 level = br->levels[level_old];
741
742set_level: 773set_level:
743 result = acpi_video_device_lcd_set_level(device, level); 774 result = acpi_video_device_lcd_set_level(device, level);
744 if (result) 775 if (result)
@@ -1268,7 +1299,8 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event)
1268 goto out; 1299 goto out;
1269 1300
1270 result = acpi_video_device_lcd_get_level_current(device, 1301 result = acpi_video_device_lcd_get_level_current(device,
1271 &level_current, 0); 1302 &level_current,
1303 false);
1272 if (result) 1304 if (result)
1273 goto out; 1305 goto out;
1274 1306