Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 142837
b: refs/heads/master
c: 9090589
h: refs/heads/master
i:
  142835: 2e6aa76
v: v3
  • Loading branch information
Shaohua Li authored and Len Brown committed Apr 7, 2009
1 parent 38a265b commit b3f3f62
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 74 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 13614e37e94da4606a300ee6fe25c8c4a19ee670
refs/heads/master: 9090589d87506c578ea1523ffd7ae7fd9424fb28
13 changes: 4 additions & 9 deletions trunk/drivers/acpi/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,25 +343,21 @@ acpi_system_write_alarm(struct file *file,
}
#endif /* HAVE_ACPI_LEGACY_ALARM */

extern struct list_head acpi_wakeup_device_list;
extern spinlock_t acpi_device_lock;

static int
acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
{
struct list_head *node, *next;

seq_printf(seq, "Device\tS-state\t Status Sysfs node\n");

spin_lock(&acpi_device_lock);
mutex_lock(&acpi_device_lock);
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev =
container_of(node, struct acpi_device, wakeup_list);
struct device *ldev;

if (!dev->wakeup.flags.valid)
continue;
spin_unlock(&acpi_device_lock);

ldev = acpi_get_physical_device(dev->handle);
seq_printf(seq, "%s\t S%d\t%c%-8s ",
Expand All @@ -376,9 +372,8 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
seq_printf(seq, "\n");
put_device(ldev);

spin_lock(&acpi_device_lock);
}
spin_unlock(&acpi_device_lock);
mutex_unlock(&acpi_device_lock);
return 0;
}

Expand Down Expand Up @@ -409,7 +404,7 @@ acpi_system_write_wakeup_device(struct file *file,
strbuf[len] = '\0';
sscanf(strbuf, "%s", str);

spin_lock(&acpi_device_lock);
mutex_lock(&acpi_device_lock);
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev =
container_of(node, struct acpi_device, wakeup_list);
Expand Down Expand Up @@ -446,7 +441,7 @@ acpi_system_write_wakeup_device(struct file *file,
}
}
}
spin_unlock(&acpi_device_lock);
mutex_unlock(&acpi_device_lock);
return count;
}

Expand Down
14 changes: 7 additions & 7 deletions trunk/drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern struct acpi_device *acpi_root;

static LIST_HEAD(acpi_device_list);
static LIST_HEAD(acpi_bus_id_list);
DEFINE_SPINLOCK(acpi_device_lock);
DEFINE_MUTEX(acpi_device_lock);
LIST_HEAD(acpi_wakeup_device_list);

struct acpi_device_bus_id{
Expand Down Expand Up @@ -500,7 +500,7 @@ static int acpi_device_register(struct acpi_device *device,
return -ENOMEM;
}

spin_lock(&acpi_device_lock);
mutex_lock(&acpi_device_lock);
/*
* Find suitable bus_id and instance number in acpi_bus_id_list
* If failed, create one and link it into acpi_bus_id_list
Expand Down Expand Up @@ -528,7 +528,7 @@ static int acpi_device_register(struct acpi_device *device,
list_add_tail(&device->g_list, &acpi_device_list);
if (device->wakeup.flags.valid)
list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list);
spin_unlock(&acpi_device_lock);
mutex_unlock(&acpi_device_lock);

if (device->parent)
device->dev.parent = &parent->dev;
Expand All @@ -549,28 +549,28 @@ static int acpi_device_register(struct acpi_device *device,
device->removal_type = ACPI_BUS_REMOVAL_NORMAL;
return 0;
end:
spin_lock(&acpi_device_lock);
mutex_lock(&acpi_device_lock);
if (device->parent) {
list_del(&device->node);
list_del(&device->g_list);
} else
list_del(&device->g_list);
list_del(&device->wakeup_list);
spin_unlock(&acpi_device_lock);
mutex_unlock(&acpi_device_lock);
return result;
}

static void acpi_device_unregister(struct acpi_device *device, int type)
{
spin_lock(&acpi_device_lock);
mutex_lock(&acpi_device_lock);
if (device->parent) {
list_del(&device->node);
list_del(&device->g_list);
} else
list_del(&device->g_list);

list_del(&device->wakeup_list);
spin_unlock(&acpi_device_lock);
mutex_unlock(&acpi_device_lock);

acpi_detach_data(device->handle, acpi_bus_data_handler);

Expand Down
3 changes: 3 additions & 0 deletions trunk/drivers/acpi/sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ extern int acpi_suspend (u32 state);
extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
extern void acpi_enable_wakeup_device(u8 sleep_state);
extern void acpi_disable_wakeup_device(u8 sleep_state);

extern struct list_head acpi_wakeup_device_list;
extern struct mutex acpi_device_lock;
41 changes: 7 additions & 34 deletions trunk/drivers/acpi/thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ struct acpi_thermal {
struct acpi_handle_list devices;
struct thermal_zone_device *thermal_zone;
int tz_enabled;
int kelvin_offset;
struct mutex lock;
};

Expand Down Expand Up @@ -582,7 +581,7 @@ static void acpi_thermal_check(void *data)
}

/* sys I/F for generic thermal sysfs support */
#define KELVIN_TO_MILLICELSIUS(t, off) (((t) - (off)) * 100)
#define KELVIN_TO_MILLICELSIUS(t) (t * 100 - 273200)

static int thermal_get_temp(struct thermal_zone_device *thermal,
unsigned long *temp)
Expand All @@ -597,7 +596,7 @@ static int thermal_get_temp(struct thermal_zone_device *thermal,
if (result)
return result;

*temp = KELVIN_TO_MILLICELSIUS(tz->temperature, tz->kelvin_offset);
*temp = KELVIN_TO_MILLICELSIUS(tz->temperature);
return 0;
}

Expand Down Expand Up @@ -703,8 +702,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
if (tz->trips.critical.flags.valid) {
if (!trip) {
*temp = KELVIN_TO_MILLICELSIUS(
tz->trips.critical.temperature,
tz->kelvin_offset);
tz->trips.critical.temperature);
return 0;
}
trip--;
Expand All @@ -713,8 +711,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
if (tz->trips.hot.flags.valid) {
if (!trip) {
*temp = KELVIN_TO_MILLICELSIUS(
tz->trips.hot.temperature,
tz->kelvin_offset);
tz->trips.hot.temperature);
return 0;
}
trip--;
Expand All @@ -723,8 +720,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
if (tz->trips.passive.flags.valid) {
if (!trip) {
*temp = KELVIN_TO_MILLICELSIUS(
tz->trips.passive.temperature,
tz->kelvin_offset);
tz->trips.passive.temperature);
return 0;
}
trip--;
Expand All @@ -734,8 +730,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
tz->trips.active[i].flags.valid; i++) {
if (!trip) {
*temp = KELVIN_TO_MILLICELSIUS(
tz->trips.active[i].temperature,
tz->kelvin_offset);
tz->trips.active[i].temperature);
return 0;
}
trip--;
Expand All @@ -750,8 +745,7 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal,

if (tz->trips.critical.flags.valid) {
*temperature = KELVIN_TO_MILLICELSIUS(
tz->trips.critical.temperature,
tz->kelvin_offset);
tz->trips.critical.temperature);
return 0;
} else
return -EINVAL;
Expand Down Expand Up @@ -1340,25 +1334,6 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz)
return 0;
}

/*
* The exact offset between Kelvin and degree Celsius is 273.15. However ACPI
* handles temperature values with a single decimal place. As a consequence,
* some implementations use an offset of 273.1 and others use an offset of
* 273.2. Try to find out which one is being used, to present the most
* accurate and visually appealing number.
*
* The heuristic below should work for all ACPI thermal zones which have a
* critical trip point with a value being a multiple of 0.5 degree Celsius.
*/
static void acpi_thermal_guess_offset(struct acpi_thermal *tz)
{
if (tz->trips.critical.flags.valid &&
(tz->trips.critical.temperature % 5) == 1)
tz->kelvin_offset = 2731;
else
tz->kelvin_offset = 2732;
}

static int acpi_thermal_add(struct acpi_device *device)
{
int result = 0;
Expand All @@ -1385,8 +1360,6 @@ static int acpi_thermal_add(struct acpi_device *device)
if (result)
goto free_memory;

acpi_thermal_guess_offset(tz);

result = acpi_thermal_register_thermal_zone(tz);
if (result)
goto free_memory;
Expand Down
30 changes: 7 additions & 23 deletions trunk/drivers/acpi/wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
#include "internal.h"
#include "sleep.h"

/*
* We didn't lock acpi_device_lock in the file, because it invokes oops in
* suspend/resume and isn't really required as this is called in S-state. At
* that time, there is no device hotplug
**/
#define _COMPONENT ACPI_SYSTEM_COMPONENT
ACPI_MODULE_NAME("wakeup_devices")

extern struct list_head acpi_wakeup_device_list;
extern spinlock_t acpi_device_lock;

/**
* acpi_enable_wakeup_device_prep - prepare wakeup devices
* @sleep_state: ACPI state
Expand All @@ -29,7 +31,6 @@ void acpi_enable_wakeup_device_prep(u8 sleep_state)
{
struct list_head *node, *next;

spin_lock(&acpi_device_lock);
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev = container_of(node,
struct acpi_device,
Expand All @@ -40,11 +41,8 @@ void acpi_enable_wakeup_device_prep(u8 sleep_state)
(sleep_state > (u32) dev->wakeup.sleep_state))
continue;

spin_unlock(&acpi_device_lock);
acpi_enable_wakeup_device_power(dev, sleep_state);
spin_lock(&acpi_device_lock);
}
spin_unlock(&acpi_device_lock);
}

/**
Expand All @@ -60,7 +58,6 @@ void acpi_enable_wakeup_device(u8 sleep_state)
* Caution: this routine must be invoked when interrupt is disabled
* Refer ACPI2.0: P212
*/
spin_lock(&acpi_device_lock);
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev =
container_of(node, struct acpi_device, wakeup_list);
Expand All @@ -74,22 +71,17 @@ void acpi_enable_wakeup_device(u8 sleep_state)
if ((!dev->wakeup.state.enabled && !dev->wakeup.flags.prepared)
|| sleep_state > (u32) dev->wakeup.sleep_state) {
if (dev->wakeup.flags.run_wake) {
spin_unlock(&acpi_device_lock);
/* set_gpe_type will disable GPE, leave it like that */
acpi_set_gpe_type(dev->wakeup.gpe_device,
dev->wakeup.gpe_number,
ACPI_GPE_TYPE_RUNTIME);
spin_lock(&acpi_device_lock);
}
continue;
}
spin_unlock(&acpi_device_lock);
if (!dev->wakeup.flags.run_wake)
acpi_enable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number);
spin_lock(&acpi_device_lock);
}
spin_unlock(&acpi_device_lock);
}

/**
Expand All @@ -101,7 +93,6 @@ void acpi_disable_wakeup_device(u8 sleep_state)
{
struct list_head *node, *next;

spin_lock(&acpi_device_lock);
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev =
container_of(node, struct acpi_device, wakeup_list);
Expand All @@ -112,19 +103,16 @@ void acpi_disable_wakeup_device(u8 sleep_state)
if ((!dev->wakeup.state.enabled && !dev->wakeup.flags.prepared)
|| sleep_state > (u32) dev->wakeup.sleep_state) {
if (dev->wakeup.flags.run_wake) {
spin_unlock(&acpi_device_lock);
acpi_set_gpe_type(dev->wakeup.gpe_device,
dev->wakeup.gpe_number,
ACPI_GPE_TYPE_WAKE_RUN);
/* Re-enable it, since set_gpe_type will disable it */
acpi_enable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number);
spin_lock(&acpi_device_lock);
}
continue;
}

spin_unlock(&acpi_device_lock);
acpi_disable_wakeup_device_power(dev);
/* Never disable run-wake GPE */
if (!dev->wakeup.flags.run_wake) {
Expand All @@ -133,32 +121,28 @@ void acpi_disable_wakeup_device(u8 sleep_state)
acpi_clear_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_NOT_ISR);
}
spin_lock(&acpi_device_lock);
}
spin_unlock(&acpi_device_lock);
}

int __init acpi_wakeup_device_init(void)
{
struct list_head *node, *next;

spin_lock(&acpi_device_lock);
mutex_lock(&acpi_device_lock);
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev = container_of(node,
struct acpi_device,
wakeup_list);
/* In case user doesn't load button driver */
if (!dev->wakeup.flags.run_wake || dev->wakeup.state.enabled)
continue;
spin_unlock(&acpi_device_lock);
acpi_set_gpe_type(dev->wakeup.gpe_device,
dev->wakeup.gpe_number,
ACPI_GPE_TYPE_WAKE_RUN);
acpi_enable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number);
dev->wakeup.state.enabled = 1;
spin_lock(&acpi_device_lock);
}
spin_unlock(&acpi_device_lock);
mutex_unlock(&acpi_device_lock);
return 0;
}

0 comments on commit b3f3f62

Please sign in to comment.