mirror of
https://github.com/torvalds/linux.git
synced 2024-11-08 05:01:48 +00:00
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
This commit is contained in:
commit
0f0c8aa0d0
@ -236,7 +236,7 @@ static int create_power_saving_task(void)
|
||||
ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread,
|
||||
(void *)(unsigned long)ps_tsk_num,
|
||||
"acpi_pad/%d", ps_tsk_num);
|
||||
rc = IS_ERR(ps_tsks[ps_tsk_num]) ? PTR_ERR(ps_tsks[ps_tsk_num]) : 0;
|
||||
rc = PTR_RET(ps_tsks[ps_tsk_num]);
|
||||
if (!rc)
|
||||
ps_tsk_num++;
|
||||
else
|
||||
|
@ -146,7 +146,7 @@ struct acpi_battery {
|
||||
|
||||
#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat)
|
||||
|
||||
inline int acpi_battery_present(struct acpi_battery *battery)
|
||||
static inline int acpi_battery_present(struct acpi_battery *battery)
|
||||
{
|
||||
return battery->device->status.battery_present;
|
||||
}
|
||||
|
@ -288,13 +288,12 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
|
||||
}
|
||||
out_success:
|
||||
context->ret.length = out_obj->buffer.length;
|
||||
context->ret.pointer = kmalloc(context->ret.length, GFP_KERNEL);
|
||||
context->ret.pointer = kmemdup(out_obj->buffer.pointer,
|
||||
context->ret.length, GFP_KERNEL);
|
||||
if (!context->ret.pointer) {
|
||||
status = AE_NO_MEMORY;
|
||||
goto out_kfree;
|
||||
}
|
||||
memcpy(context->ret.pointer, out_obj->buffer.pointer,
|
||||
context->ret.length);
|
||||
status = AE_OK;
|
||||
|
||||
out_kfree:
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <linux/slab.h>
|
||||
#include <acpi/acpi_bus.h>
|
||||
#include <acpi/acpi_drivers.h>
|
||||
#include <acpi/button.h>
|
||||
|
||||
#define PREFIX "ACPI: "
|
||||
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#define PREFIX "ACPI: "
|
||||
|
||||
#define _COMPONENT ACPI_CONTAINER_COMPONENT
|
||||
|
@ -174,9 +174,13 @@ static int acpi_fan_add(struct acpi_device *device)
|
||||
|
||||
static int acpi_fan_remove(struct acpi_device *device)
|
||||
{
|
||||
struct thermal_cooling_device *cdev = acpi_driver_data(device);
|
||||
struct thermal_cooling_device *cdev;
|
||||
|
||||
if (!device || !cdev)
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
cdev = acpi_driver_data(device);
|
||||
if (!cdev)
|
||||
return -EINVAL;
|
||||
|
||||
sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
|
||||
|
@ -1555,7 +1555,7 @@ int acpi_check_resource_conflict(const struct resource *res)
|
||||
else
|
||||
space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY;
|
||||
|
||||
length = res->end - res->start + 1;
|
||||
length = resource_size(res);
|
||||
if (acpi_enforce_resources != ENFORCE_RESOURCES_NO)
|
||||
warn = 1;
|
||||
clash = acpi_check_address_range(space_id, res->start, length, warn);
|
||||
|
@ -201,8 +201,8 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root,
|
||||
*control &= OSC_PCI_CONTROL_MASKS;
|
||||
capbuf[OSC_CONTROL_TYPE] = *control | root->osc_control_set;
|
||||
} else {
|
||||
/* Run _OSC query for all possible controls. */
|
||||
capbuf[OSC_CONTROL_TYPE] = OSC_PCI_CONTROL_MASKS;
|
||||
/* Run _OSC query only with existing controls. */
|
||||
capbuf[OSC_CONTROL_TYPE] = root->osc_control_set;
|
||||
}
|
||||
|
||||
status = acpi_pci_run_osc(root->device->handle, capbuf, &result);
|
||||
|
@ -218,9 +218,13 @@ processor_get_max_state(struct thermal_cooling_device *cdev,
|
||||
unsigned long *state)
|
||||
{
|
||||
struct acpi_device *device = cdev->devdata;
|
||||
struct acpi_processor *pr = acpi_driver_data(device);
|
||||
struct acpi_processor *pr;
|
||||
|
||||
if (!device || !pr)
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
pr = acpi_driver_data(device);
|
||||
if (!pr)
|
||||
return -EINVAL;
|
||||
|
||||
*state = acpi_processor_max_state(pr);
|
||||
@ -232,9 +236,13 @@ processor_get_cur_state(struct thermal_cooling_device *cdev,
|
||||
unsigned long *cur_state)
|
||||
{
|
||||
struct acpi_device *device = cdev->devdata;
|
||||
struct acpi_processor *pr = acpi_driver_data(device);
|
||||
struct acpi_processor *pr;
|
||||
|
||||
if (!device || !pr)
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
pr = acpi_driver_data(device);
|
||||
if (!pr)
|
||||
return -EINVAL;
|
||||
|
||||
*cur_state = cpufreq_get_cur_state(pr->id);
|
||||
@ -248,11 +256,15 @@ processor_set_cur_state(struct thermal_cooling_device *cdev,
|
||||
unsigned long state)
|
||||
{
|
||||
struct acpi_device *device = cdev->devdata;
|
||||
struct acpi_processor *pr = acpi_driver_data(device);
|
||||
struct acpi_processor *pr;
|
||||
int result = 0;
|
||||
int max_pstate;
|
||||
|
||||
if (!device || !pr)
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
pr = acpi_driver_data(device);
|
||||
if (!pr)
|
||||
return -EINVAL;
|
||||
|
||||
max_pstate = cpufreq_get_max_state(pr->id);
|
||||
|
@ -211,9 +211,10 @@ err_ret:
|
||||
*/
|
||||
void acpi_processor_throttling_init(void)
|
||||
{
|
||||
if (acpi_processor_update_tsd_coord())
|
||||
if (acpi_processor_update_tsd_coord()) {
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
||||
"Assume no T-state coordination\n"));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ static int acpi_video_device_lcd_set_level(struct acpi_video_device *device,
|
||||
int level);
|
||||
static int acpi_video_device_lcd_get_level_current(
|
||||
struct acpi_video_device *device,
|
||||
unsigned long long *level, int init);
|
||||
unsigned long long *level, bool raw);
|
||||
static int acpi_video_get_next_level(struct acpi_video_device *device,
|
||||
u32 level_current, u32 event);
|
||||
static int acpi_video_switch_brightness(struct acpi_video_device *device,
|
||||
@ -236,7 +236,7 @@ static int acpi_video_get_brightness(struct backlight_device *bd)
|
||||
struct acpi_video_device *vd =
|
||||
(struct acpi_video_device *)bl_get_data(bd);
|
||||
|
||||
if (acpi_video_device_lcd_get_level_current(vd, &cur_level, 0))
|
||||
if (acpi_video_device_lcd_get_level_current(vd, &cur_level, false))
|
||||
return -EINVAL;
|
||||
for (i = 2; i < vd->brightness->count; i++) {
|
||||
if (vd->brightness->levels[i] == cur_level)
|
||||
@ -281,7 +281,7 @@ static int video_get_cur_state(struct thermal_cooling_device *cooling_dev, unsig
|
||||
unsigned long long level;
|
||||
int offset;
|
||||
|
||||
if (acpi_video_device_lcd_get_level_current(video, &level, 0))
|
||||
if (acpi_video_device_lcd_get_level_current(video, &level, false))
|
||||
return -EINVAL;
|
||||
for (offset = 2; offset < video->brightness->count; offset++)
|
||||
if (level == video->brightness->levels[offset]) {
|
||||
@ -447,12 +447,45 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
|
||||
DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13 - 2000 Notebook PC"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.callback = video_ignore_initial_backlight,
|
||||
.ident = "HP Pavilion dm4",
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
|
||||
DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dm4 Notebook PC"),
|
||||
},
|
||||
},
|
||||
{}
|
||||
};
|
||||
|
||||
static unsigned long long
|
||||
acpi_video_bqc_value_to_level(struct acpi_video_device *device,
|
||||
unsigned long long bqc_value)
|
||||
{
|
||||
unsigned long long level;
|
||||
|
||||
if (device->brightness->flags._BQC_use_index) {
|
||||
/*
|
||||
* _BQC returns an index that doesn't account for
|
||||
* the first 2 items with special meaning, so we need
|
||||
* to compensate for that by offsetting ourselves
|
||||
*/
|
||||
if (device->brightness->flags._BCL_reversed)
|
||||
bqc_value = device->brightness->count - 3 - bqc_value;
|
||||
|
||||
level = device->brightness->levels[bqc_value + 2];
|
||||
} else {
|
||||
level = bqc_value;
|
||||
}
|
||||
|
||||
level += bqc_offset_aml_bug_workaround;
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
|
||||
unsigned long long *level, int init)
|
||||
unsigned long long *level, bool raw)
|
||||
{
|
||||
acpi_status status = AE_OK;
|
||||
int i;
|
||||
@ -463,29 +496,30 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
|
||||
status = acpi_evaluate_integer(device->dev->handle, buf,
|
||||
NULL, level);
|
||||
if (ACPI_SUCCESS(status)) {
|
||||
if (device->brightness->flags._BQC_use_index) {
|
||||
if (device->brightness->flags._BCL_reversed)
|
||||
*level = device->brightness->count
|
||||
- 3 - (*level);
|
||||
*level = device->brightness->levels[*level + 2];
|
||||
|
||||
if (raw) {
|
||||
/*
|
||||
* Caller has indicated he wants the raw
|
||||
* value returned by _BQC, so don't furtherly
|
||||
* mess with the value.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
*level += bqc_offset_aml_bug_workaround;
|
||||
|
||||
*level = acpi_video_bqc_value_to_level(device, *level);
|
||||
|
||||
for (i = 2; i < device->brightness->count; i++)
|
||||
if (device->brightness->levels[i] == *level) {
|
||||
device->brightness->curr = *level;
|
||||
return 0;
|
||||
}
|
||||
if (!init) {
|
||||
/*
|
||||
* BQC returned an invalid level.
|
||||
* Stop using it.
|
||||
*/
|
||||
ACPI_WARNING((AE_INFO,
|
||||
"%s returned an invalid level",
|
||||
buf));
|
||||
device->cap._BQC = device->cap._BCQ = 0;
|
||||
}
|
||||
/*
|
||||
* BQC returned an invalid level.
|
||||
* Stop using it.
|
||||
*/
|
||||
ACPI_WARNING((AE_INFO,
|
||||
"%s returned an invalid level",
|
||||
buf));
|
||||
device->cap._BQC = device->cap._BCQ = 0;
|
||||
} else {
|
||||
/* Fixme:
|
||||
* should we return an error or ignore this failure?
|
||||
@ -703,7 +737,8 @@ acpi_video_init_brightness(struct acpi_video_device *device)
|
||||
if (!device->cap._BQC)
|
||||
goto set_level;
|
||||
|
||||
result = acpi_video_device_lcd_get_level_current(device, &level_old, 1);
|
||||
result = acpi_video_device_lcd_get_level_current(device,
|
||||
&level_old, true);
|
||||
if (result)
|
||||
goto out_free_levels;
|
||||
|
||||
@ -714,31 +749,27 @@ acpi_video_init_brightness(struct acpi_video_device *device)
|
||||
if (result)
|
||||
goto out_free_levels;
|
||||
|
||||
result = acpi_video_device_lcd_get_level_current(device, &level, 0);
|
||||
result = acpi_video_device_lcd_get_level_current(device, &level, true);
|
||||
if (result)
|
||||
goto out_free_levels;
|
||||
|
||||
br->flags._BQC_use_index = (level == max_level ? 0 : 1);
|
||||
|
||||
if (!br->flags._BQC_use_index) {
|
||||
if (use_bios_initial_backlight) {
|
||||
level = acpi_video_bqc_value_to_level(device, level_old);
|
||||
/*
|
||||
* Set the backlight to the initial state.
|
||||
* On some buggy laptops, _BQC returns an uninitialized value
|
||||
* when invoked for the first time, i.e. level_old is invalid.
|
||||
* set the backlight to max_level in this case
|
||||
* On some buggy laptops, _BQC returns an uninitialized
|
||||
* value when invoked for the first time, i.e.
|
||||
* level_old is invalid (no matter whether it's a level
|
||||
* or an index). Set the backlight to max_level in this case.
|
||||
*/
|
||||
if (use_bios_initial_backlight) {
|
||||
for (i = 2; i < br->count; i++)
|
||||
if (level_old == br->levels[i])
|
||||
level = level_old;
|
||||
}
|
||||
goto set_level;
|
||||
for (i = 2; i < br->count; i++)
|
||||
if (level_old == br->levels[i])
|
||||
break;
|
||||
if (i == br->count)
|
||||
level = max_level;
|
||||
}
|
||||
|
||||
if (br->flags._BCL_reversed)
|
||||
level_old = (br->count - 1) - level_old;
|
||||
level = br->levels[level_old];
|
||||
|
||||
set_level:
|
||||
result = acpi_video_device_lcd_set_level(device, level);
|
||||
if (result)
|
||||
@ -1268,7 +1299,8 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event)
|
||||
goto out;
|
||||
|
||||
result = acpi_video_device_lcd_get_level_current(device,
|
||||
&level_current, 0);
|
||||
&level_current,
|
||||
false);
|
||||
if (result)
|
||||
goto out;
|
||||
|
||||
|
@ -95,7 +95,6 @@ int acpi_pci_link_free_irq(acpi_handle handle);
|
||||
struct pci_bus;
|
||||
|
||||
struct pci_dev *acpi_get_pci_dev(acpi_handle);
|
||||
int acpi_pci_bind_root(struct acpi_device *device);
|
||||
|
||||
/* Arch-defined function to add a bus to the system */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user