Commit 18ed1c05 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (68 commits)
  ACPI: replace kmalloc+memset with kzalloc
  ACPI: Add support for acpi_load_table/acpi_unload_table_id
  fbdev: update after backlight argument change
  ACPI: video: Add dev argument for backlight_device_register
  ACPI: Implement acpi_video_get_next_level()
  ACPI: Kconfig - depend on PM rather than selecting it
  ACPI: fix NULL check in drivers/acpi/osl.c
  ACPI: make drivers/acpi/ec.c:ec_ecdt static
  ACPI: prevent processor module from loading on failures
  ACPI: fix single linked list manipulation
  ACPI: ibm_acpi: allow clean removal
  ACPI: fix git automerge failure
  ACPI: ibm_acpi: respond to workqueue update
  ACPI: dock: add uevent to indicate change in device status
  ACPI: ec: Lindent once again
  ACPI: ec: Change #define to enums there possible.
  ACPI: ec: Style changes.
  ACPI: ec: Acquire Global Lock under EC mutex.
  ACPI: ec: Drop udelay() from poll mode. Loop by reading status field instead.
  ACPI: ec: Rename gpe_bit to gpe
  ...
parents dab6df63 36bcbec7
...@@ -398,25 +398,67 @@ Temperature sensors -- /proc/acpi/ibm/thermal ...@@ -398,25 +398,67 @@ Temperature sensors -- /proc/acpi/ibm/thermal
Most ThinkPads include six or more separate temperature sensors but Most ThinkPads include six or more separate temperature sensors but
only expose the CPU temperature through the standard ACPI methods. only expose the CPU temperature through the standard ACPI methods.
This feature shows readings from up to eight different sensors. Some This feature shows readings from up to eight different sensors on older
readings may not be valid, e.g. may show large negative values. For ThinkPads, and it has experimental support for up to sixteen different
example, on the X40, a typical output may be: sensors on newer ThinkPads. Readings from sensors that are not available
return -128.
No commands can be written to this file.
EXPERIMENTAL: The 16-sensors feature is marked EXPERIMENTAL because the
implementation directly accesses hardware registers and may not work as
expected. USE WITH CAUTION! To use this feature, you need to supply the
experimental=1 parameter when loading the module. When EXPERIMENTAL
mode is enabled, reading the first 8 sensors on newer ThinkPads will
also use an new experimental thermal sensor access mode.
For example, on the X40, a typical output may be:
temperatures: 42 42 45 41 36 -128 33 -128 temperatures: 42 42 45 41 36 -128 33 -128
Thomas Gruber took his R51 apart and traced all six active sensors in EXPERIMENTAL: On the T43/p, a typical output may be:
his laptop (the location of sensors may vary on other models): temperatures: 48 48 36 52 38 -128 31 -128 48 52 48 -128 -128 -128 -128 -128
The mapping of thermal sensors to physical locations varies depending on
system-board model (and thus, on ThinkPad model).
http://thinkwiki.org/wiki/Thermal_Sensors is a public wiki page that
tries to track down these locations for various models.
Most (newer?) models seem to follow this pattern:
1: CPU 1: CPU
2: Mini PCI Module 2: (depends on model)
3: HDD 3: (depends on model)
4: GPU 4: GPU
5: Battery 5: Main battery: main sensor
6: N/A 6: Bay battery: main sensor
7: Battery 7: Main battery: secondary sensor
8: N/A 8: Bay battery: secondary sensor
9-15: (depends on model)
For the R51 (source: Thomas Gruber):
2: Mini-PCI
3: Internal HDD
For the T43, T43/p (source: Shmidoax/Thinkwiki.org)
http://thinkwiki.org/wiki/Thermal_Sensors#ThinkPad_T43.2C_T43p
2: System board, left side (near PCMCIA slot), reported as HDAPS temp
3: PCMCIA slot
9: MCH (northbridge) to DRAM Bus
10: ICH (southbridge), under Mini-PCI card, under touchpad
11: Power regulator, underside of system board, below F2 key
The A31 has a very atypical layout for the thermal sensors
(source: Milos Popovic, http://thinkwiki.org/wiki/Thermal_Sensors#ThinkPad_A31)
1: CPU
2: Main Battery: main sensor
3: Power Converter
4: Bay Battery: main sensor
5: MCH (northbridge)
6: PCMCIA/ambient
7: Main Battery: secondary sensor
8: Bay Battery: secondary sensor
No commands can be written to this file.
EXPERIMENTAL: Embedded controller register dump -- /proc/acpi/ibm/ecdump EXPERIMENTAL: Embedded controller register dump -- /proc/acpi/ibm/ecdump
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -529,27 +571,57 @@ directly accesses hardware registers and may not work as expected. USE ...@@ -529,27 +571,57 @@ directly accesses hardware registers and may not work as expected. USE
WITH CAUTION! To use this feature, you need to supply the WITH CAUTION! To use this feature, you need to supply the
experimental=1 parameter when loading the module. experimental=1 parameter when loading the module.
This feature attempts to show the current fan speed. The speed is read This feature attempts to show the current fan speed, control mode and
directly from the hardware registers of the embedded controller. This other fan data that might be available. The speed is read directly
is known to work on later R, T and X series ThinkPads but may show a from the hardware registers of the embedded controller. This is known
bogus value on other models. to work on later R, T and X series ThinkPads but may show a bogus
value on other models.
Most ThinkPad fans work in "levels". Level 0 stops the fan. The higher
the level, the higher the fan speed, although adjacent levels often map
to the same fan speed. 7 is the highest level, where the fan reaches
the maximum recommended speed. Level "auto" means the EC changes the
fan level according to some internal algorithm, usually based on
readings from the thermal sensors. Level "disengaged" means the EC
disables the speed-locked closed-loop fan control, and drives the fan as
fast as it can go, which might exceed hardware limits, so use this level
with caution.
The fan usually ramps up or down slowly from one speed to another,
and it is normal for the EC to take several seconds to react to fan
commands.
The fan may be enabled or disabled with the following commands: The fan may be enabled or disabled with the following commands:
echo enable >/proc/acpi/ibm/fan echo enable >/proc/acpi/ibm/fan
echo disable >/proc/acpi/ibm/fan echo disable >/proc/acpi/ibm/fan
Placing a fan on level 0 is the same as disabling it. Enabling a fan
will try to place it in a safe level if it is too slow or disabled.
WARNING WARNING WARNING: do not leave the fan disabled unless you are WARNING WARNING WARNING: do not leave the fan disabled unless you are
monitoring the temperature sensor readings and you are ready to enable monitoring all of the temperature sensor readings and you are ready to
it if necessary to avoid overheating. enable it if necessary to avoid overheating.
The fan only runs if it's enabled *and* the various temperature An enabled fan in level "auto" may stop spinning if the EC decides the
sensors which control it read high enough. On the X40, this seems to ThinkPad is cool enough and doesn't need the extra airflow. This is
depend on the CPU and HDD temperatures. Specifically, the fan is normal, and the EC will spin the fan up if the varios thermal readings
turned on when either the CPU temperature climbs to 56 degrees or the rise too much.
HDD temperature climbs to 46 degrees. The fan is turned off when the
CPU temperature drops to 49 degrees and the HDD temperature drops to On the X40, this seems to depend on the CPU and HDD temperatures.
41 degrees. These thresholds cannot currently be controlled. Specifically, the fan is turned on when either the CPU temperature
climbs to 56 degrees or the HDD temperature climbs to 46 degrees. The
fan is turned off when the CPU temperature drops to 49 degrees and the
HDD temperature drops to 41 degrees. These thresholds cannot
currently be controlled.
The fan level can be controlled with the command:
echo 'level <level>' > /proc/acpi/ibm/thermal
Where <level> is an integer from 0 to 7, or one of the words "auto"
or "disengaged" (without the quotes). Not all ThinkPads support the
"auto" and "disengaged" levels.
On the X31 and X40 (and ONLY on those models), the fan speed can be On the X31 and X40 (and ONLY on those models), the fan speed can be
controlled to a certain degree. Once the fan is running, it can be controlled to a certain degree. Once the fan is running, it can be
...@@ -562,12 +634,9 @@ about 3700 to about 7350. Values outside this range either do not have ...@@ -562,12 +634,9 @@ about 3700 to about 7350. Values outside this range either do not have
any effect or the fan speed eventually settles somewhere in that any effect or the fan speed eventually settles somewhere in that
range. The fan cannot be stopped or started with this command. range. The fan cannot be stopped or started with this command.
On the 570, temperature readings are not available through this The ThinkPad's ACPI DSDT code will reprogram the fan on its own when
feature and the fan control works a little differently. The fan speed certain conditions are met. It will override any fan programming done
is reported in levels from 0 (off) to 7 (max) and can be controlled through ibm-acpi.
with the following command:
echo 'level <level>' > /proc/acpi/ibm/thermal
EXPERIMENTAL: WAN -- /proc/acpi/ibm/wan EXPERIMENTAL: WAN -- /proc/acpi/ibm/wan
--------------------------------------- ---------------------------------------
...@@ -601,6 +670,26 @@ example: ...@@ -601,6 +670,26 @@ example:
modprobe ibm_acpi hotkey=enable,0xffff video=auto_disable modprobe ibm_acpi hotkey=enable,0xffff video=auto_disable
The ibm-acpi kernel driver can be programmed to revert the fan level
to a safe setting if userspace does not issue one of the fan commands:
"enable", "disable", "level" or "watchdog" within a configurable
ammount of time. To do this, use the "watchdog" command.
echo 'watchdog <interval>' > /proc/acpi/ibm/fan
Interval is the ammount of time in seconds to wait for one of the
above mentioned fan commands before reseting the fan level to a safe
one. If set to zero, the watchdog is disabled (default). When the
watchdog timer runs out, it does the exact equivalent of the "enable"
fan command.
Note that the watchdog timer stops after it enables the fan. It will
be rearmed again automatically (using the same interval) when one of
the above mentioned fan commands is received. The fan watchdog is,
therefore, not suitable to protect against fan mode changes made
through means other than the "enable", "disable", and "level" fan
commands.
Example Configuration Example Configuration
--------------------- ---------------------
......
...@@ -1400,6 +1400,15 @@ W: http://www.ia64-linux.org/ ...@@ -1400,6 +1400,15 @@ W: http://www.ia64-linux.org/
T: git kernel.org:/pub/scm/linux/kernel/git/aegl/linux-2.6.git T: git kernel.org:/pub/scm/linux/kernel/git/aegl/linux-2.6.git
S: Maintained S: Maintained
IBM ACPI EXTRAS DRIVER
P: Henrique de Moraes Holschuh
M: ibm-acpi@hmh.eng.br
L: ibm-acpi-devel@lists.sourceforge.net
W: http://ibm-acpi.sourceforge.net
W: http://thinkwiki.org/wiki/Ibm-acpi
T: git repo.or.cz/linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git
S: Maintained
SN-IA64 (Itanium) SUB-PLATFORM SN-IA64 (Itanium) SUB-PLATFORM
P: Jes Sorensen P: Jes Sorensen
M: jes@sgi.com M: jes@sgi.com
......
...@@ -1327,3 +1327,25 @@ static int __init setup_acpi_sci(char *s) ...@@ -1327,3 +1327,25 @@ static int __init setup_acpi_sci(char *s)
return 0; return 0;
} }
early_param("acpi_sci", setup_acpi_sci); early_param("acpi_sci", setup_acpi_sci);
int __acpi_acquire_global_lock(unsigned int *lock)
{
unsigned int old, new, val;
do {
old = *lock;
new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
val = cmpxchg(lock, old, new);
} while (unlikely (val != old));
return (new < 3) ? -1 : 0;
}
int __acpi_release_global_lock(unsigned int *lock)
{
unsigned int old, new, val;
do {
old = *lock;
new = old & ~0x3;
val = cmpxchg(lock, old, new);
} while (unlikely (val != old));
return old & 0x1;
}
...@@ -276,12 +276,10 @@ acpi_cpufreq_cpu_init ( ...@@ -276,12 +276,10 @@ acpi_cpufreq_cpu_init (
dprintk("acpi_cpufreq_cpu_init\n"); dprintk("acpi_cpufreq_cpu_init\n");
data = kmalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL); data = kzalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL);
if (!data) if (!data)
return (-ENOMEM); return (-ENOMEM);
memset(data, 0, sizeof(struct cpufreq_acpi_io));
acpi_io_data[cpu] = data; acpi_io_data[cpu] = data;
result = acpi_processor_register_performance(&data->acpi_data, cpu); result = acpi_processor_register_performance(&data->acpi_data, cpu);
......
...@@ -11,7 +11,7 @@ config ACPI ...@@ -11,7 +11,7 @@ config ACPI
bool "ACPI Support" bool "ACPI Support"
depends on IA64 || X86 depends on IA64 || X86
depends on PCI depends on PCI
select PM depends on PM
default y default y
---help--- ---help---
Advanced Configuration and Power Interface (ACPI) support for Advanced Configuration and Power Interface (ACPI) support for
...@@ -97,6 +97,7 @@ config ACPI_BATTERY ...@@ -97,6 +97,7 @@ config ACPI_BATTERY
config ACPI_BUTTON config ACPI_BUTTON
tristate "Button" tristate "Button"
depends on INPUT
default y default y
help help
This driver handles events on the power, sleep and lid buttons. This driver handles events on the power, sleep and lid buttons.
...@@ -172,6 +173,7 @@ config ACPI_NUMA ...@@ -172,6 +173,7 @@ config ACPI_NUMA
config ACPI_ASUS config ACPI_ASUS
tristate "ASUS/Medion Laptop Extras" tristate "ASUS/Medion Laptop Extras"
depends on X86 depends on X86
select BACKLIGHT_CLASS_DEVICE
---help--- ---help---
This driver provides support for extra features of ACPI-compatible This driver provides support for extra features of ACPI-compatible
ASUS laptops. As some of Medion laptops are made by ASUS, it may also ASUS laptops. As some of Medion laptops are made by ASUS, it may also
...@@ -200,6 +202,7 @@ config ACPI_ASUS ...@@ -200,6 +202,7 @@ config ACPI_ASUS
config ACPI_IBM config ACPI_IBM
tristate "IBM ThinkPad Laptop Extras" tristate "IBM ThinkPad Laptop Extras"
depends on X86 depends on X86
select BACKLIGHT_CLASS_DEVICE
---help--- ---help---
This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds
support for Fn-Fx key combinations, Bluetooth control, video support for Fn-Fx key combinations, Bluetooth control, video
...@@ -222,9 +225,21 @@ config ACPI_IBM_DOCK ...@@ -222,9 +225,21 @@ config ACPI_IBM_DOCK
If you are not sure, say N here. If you are not sure, say N here.
config ACPI_IBM_BAY
bool "Legacy Removable Bay Support"
depends on ACPI_IBM
depends on ACPI_BAY=n
default n
---help---
Allows the ibm_acpi driver to handle removable bays.
This support is obsoleted by CONFIG_ACPI_BAY.
If you are not sure, say N here.
config ACPI_TOSHIBA config ACPI_TOSHIBA
tristate "Toshiba Laptop Extras" tristate "Toshiba Laptop Extras"
depends on X86 depends on X86
select BACKLIGHT_CLASS_DEVICE
---help--- ---help---
This driver adds support for access to certain system settings This driver adds support for access to certain system settings
on "legacy free" Toshiba laptops. These laptops can be recognized by on "legacy free" Toshiba laptops. These laptops can be recognized by
......
...@@ -109,7 +109,7 @@ static struct proc_dir_entry *acpi_ac_dir; ...@@ -109,7 +109,7 @@ static struct proc_dir_entry *acpi_ac_dir;
static int acpi_ac_seq_show(struct seq_file *seq, void *offset) static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
{ {
struct acpi_ac *ac = (struct acpi_ac *)seq->private; struct acpi_ac *ac = seq->private;
if (!ac) if (!ac)
...@@ -187,7 +187,7 @@ static int acpi_ac_remove_fs(struct acpi_device *device) ...@@ -187,7 +187,7 @@ static int acpi_ac_remove_fs(struct acpi_device *device)
static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
{ {
struct acpi_ac *ac = (struct acpi_ac *)data; struct acpi_ac *ac = data;
struct acpi_device *device = NULL; struct acpi_device *device = NULL;
...@@ -221,10 +221,9 @@ static int acpi_ac_add(struct acpi_device *device) ...@@ -221,10 +221,9 @@ static int acpi_ac_add(struct acpi_device *device)
if (!device) if (!device)
return -EINVAL; return -EINVAL;
ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL); ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL);
if (!ac) if (!ac)
return -ENOMEM; return -ENOMEM;
memset(ac, 0, sizeof(struct acpi_ac));
ac->device = device; ac->device = device;
strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME); strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME);
...@@ -269,7 +268,7 @@ static int acpi_ac_remove(struct acpi_device *device, int type) ...@@ -269,7 +268,7 @@ static int acpi_ac_remove(struct acpi_device *device, int type)
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
ac = (struct acpi_ac *)acpi_driver_data(device); ac = acpi_driver_data(device);
status = acpi_remove_notify_handler(device->handle, status = acpi_remove_notify_handler(device->handle,
ACPI_ALL_NOTIFY, acpi_ac_notify); ACPI_ALL_NOTIFY, acpi_ac_notify);
......
...@@ -395,10 +395,9 @@ static int acpi_memory_device_add(struct acpi_device *device) ...@@ -395,10 +395,9 @@ static int acpi_memory_device_add(struct acpi_device *device)
if (!device) if (!device)
return -EINVAL; return -EINVAL;
mem_device = kmalloc(sizeof(struct acpi_memory_device), GFP_KERNEL); mem_device = kzalloc(sizeof(struct acpi_memory_device), GFP_KERNEL);
if (!mem_device) if (!mem_device)
return -ENOMEM; return -ENOMEM;
memset(mem_device, 0, sizeof(struct acpi_memory_device));
INIT_LIST_HEAD(&mem_device->res_list); INIT_LIST_HEAD(&mem_device->res_list);
mem_device->device = device; mem_device->device = device;
...@@ -429,7 +428,7 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type) ...@@ -429,7 +428,7 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type)
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
mem_device = (struct acpi_memory_device *)acpi_driver_data(device); mem_device = acpi_driver_data(device);
kfree(mem_device); kfree(mem_device);
return 0; return 0;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/backlight.h>
#include <acpi/acpi_drivers.h> #include <acpi/acpi_drivers.h>
#include <acpi/acpi_bus.h> #include <acpi/acpi_bus.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -402,6 +403,8 @@ static struct model_data model_conf[END_MODEL] = { ...@@ -402,6 +403,8 @@ static struct model_data model_conf[END_MODEL] = {
/* procdir we use */ /* procdir we use */
static struct proc_dir_entry *asus_proc_dir; static struct proc_dir_entry *asus_proc_dir;
static struct backlight_device *asus_backlight_device;
/* /*
* This header is made available to allow proper configuration given model, * This header is made available to allow proper configuration given model,
* revision number , ... this info cannot go in struct asus_hotk because it is * revision number , ... this info cannot go in struct asus_hotk because it is
...@@ -779,7 +782,7 @@ proc_write_lcd(struct file *file, const char __user * buffer, ...@@ -779,7 +782,7 @@ proc_write_lcd(struct file *file, const char __user * buffer,
return rv; return rv;
} }
static int read_brightness(void) static int read_brightness(struct backlight_device *bd)
{ {
int value; int value;
...@@ -801,9 +804,10 @@ static int read_brightness(void) ...@@ -801,9 +804,10 @@ static int read_brightness(void)
/* /*
* Change the brightness level * Change the brightness level
*/ */
static void set_brightness(int value) static int set_brightness(int value)
{ {
acpi_status status = 0; acpi_status status = 0;
int ret = 0;
/* SPLV laptop */ /* SPLV laptop */
if (hotk->methods->brightness_set) { if (hotk->methods->brightness_set) {
...@@ -811,11 +815,12 @@ static void set_brightness(int value) ...@@ -811,11 +815,12 @@ static void set_brightness(int value)
value, NULL)) value, NULL))
printk(KERN_WARNING printk(KERN_WARNING
"Asus ACPI: Error changing brightness\n"); "Asus ACPI: Error changing brightness\n");
return; ret = -EIO;
goto out;
} }
/* No SPLV method if we are here, act as appropriate */ /* No SPLV method if we are here, act as appropriate */
value -= read_brightness(); value -= read_brightness(NULL);
while (value != 0) { while (value != 0) {
status = acpi_evaluate_object(NULL, (value > 0) ? status = acpi_evaluate_object(NULL, (value > 0) ?
hotk->methods->brightness_up : hotk->methods->brightness_up :
...@@ -825,15 +830,22 @@ static void set_brightness(int value) ...@@ -825,15 +830,22 @@ static void set_brightness(int value)
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
printk(KERN_WARNING printk(KERN_WARNING
"Asus ACPI: Error changing brightness\n"); "Asus ACPI: Error changing brightness\n");
ret = -EIO;
} }
return; out:
return ret;
}
static int set_brightness_status(struct backlight_device *bd)
{
return set_brightness(bd->props->brightness);
} }
static int static int
proc_read_brn(char *page, char **start, off_t off, int count, int *eof, proc_read_brn(char *page, char **start, off_t off, int count, int *eof,
void *data) void *data)
{ {
return sprintf(page, "%d\n", read_brightness()); return sprintf(page, "%d\n", read_brightness(NULL));
} }
static int static int
...@@ -1134,7 +1146,7 @@ static int asus_hotk_get_info(void) ...@@ -1134,7 +1146,7 @@ static int asus_hotk_get_info(void)
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
printk(KERN_WARNING " Couldn't get the DSDT table header\n"); printk(KERN_WARNING " Couldn't get the DSDT table header\n");
else else
asus_info = (struct acpi_table_header *)dsdt.pointer; asus_info = dsdt.pointer;
/* We have to write 0 on init this far for all ASUS models */ /* We have to write 0 on init this far for all ASUS models */
if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) { if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) {
...@@ -1156,7 +1168,7 @@ static int asus_hotk_get_info(void) ...@@ -1156,7 +1168,7 @@ static int asus_hotk_get_info(void)
* asus_model_match() and try something completely different. * asus_model_match() and try something completely different.
*/ */
if (buffer.pointer) { if (buffer.pointer) {
model = (union acpi_object *)buffer.pointer; model = buffer.pointer;
switch (model->type) { switch (model->type) {
case ACPI_TYPE_STRING: case ACPI_TYPE_STRING:
string = model->string.pointer; string = model->string.pointer;
...@@ -1252,11 +1264,9 @@ static int asus_hotk_add(struct acpi_device *device) ...@@ -1252,11 +1264,9 @@ static int asus_hotk_add(struct acpi_device *device)
printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n", printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
ASUS_ACPI_VERSION); ASUS_ACPI_VERSION);
hotk = hotk = kzalloc(sizeof(struct asus_hotk), GFP_KERNEL);
(struct asus_hotk *)kmalloc(sizeof(struct asus_hotk), GFP_KERNEL);
if (!hotk) if (!hotk)
return -ENOMEM; return -ENOMEM;
memset(hotk, 0, sizeof(struct asus_hotk));
hotk->handle = device->handle; hotk->handle = device->handle;
strcpy(acpi_device_name(device), ACPI_HOTK_DEVICE_NAME); strcpy(acpi_device_name(device), ACPI_HOTK_DEVICE_NAME);
...@@ -1333,6 +1343,26 @@ static int asus_hotk_remove(struct acpi_device *device, int type) ...@@ -1333,6 +1343,26 @@ static int asus_hotk_remove(struct acpi_device *device, int type)
return 0; return 0;
} }
static struct backlight_properties asus_backlight_data = {
.owner = THIS_MODULE,
.get_brightness = read_brightness,
.update_status = set_brightness_status,
.max_brightness = 15,
};
static void __exit asus_acpi_exit(void)
{
if (asus_backlight_device)
backlight_device_unregister(asus_backlight_device);
acpi_bus_unregister_driver(&asus_hotk_driver);
remove_proc_entry(PROC_ASUS, acpi_root_dir);
kfree(asus_info);
return;
}
static int __init asus_acpi_init(void) static int __init asus_acpi_init(void)
{ {
int result; int result;
...@@ -1370,17 +1400,15 @@ static int __init asus_acpi_init(void) ...@@ -1370,17 +1400,15 @@ static int __init asus_acpi_init(void)
return result; return result;
} }
return 0; asus_backlight_device = backlight_device_register("asus",NULL,NULL,
} &asus_backlight_data);
if (IS_ERR(asus_backlight_device)) {
static void __exit asus_acpi_exit(void) printk(KERN_ERR "Could not register asus backlight device\n");
{ asus_backlight_device = NULL;
acpi_bus_unregister_driver(&asus_hotk_driver); asus_acpi_exit();
remove_proc_entry(PROC_ASUS, acpi_root_dir); }
kfree(asus_info);
return; return 0;
} }
module_init(asus_acpi_init); module_init(asus_acpi_init);
......
...@@ -149,7 +149,7 @@ acpi_battery_get_info(struct acpi_battery *battery, ...@@ -149,7 +149,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
return -ENODEV; return -ENODEV;
} }
package = (union acpi_object *)buffer.pointer; package = buffer.pointer;
/* Extract Package Data */ /* Extract Package Data */
...@@ -160,12 +160,11 @@ acpi_battery_get_info(struct acpi_battery *battery, ...@@ -160,12 +160,11 @@ acpi_battery_get_info(struct acpi_battery *battery,
goto end; goto end;
} }
data.pointer = kmalloc(data.length, GFP_KERNEL); data.pointer = kzalloc(data.length, GFP_KERNEL);
if (!data.pointer) { if (!data.pointer) {
result = -ENOMEM; result = -ENOMEM;
goto end; goto end;
} }
memset(data.pointer, 0, data.length);
status = acpi_extract_package(package, &format, &data); status = acpi_extract_package(package, &format, &data);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
...@@ -179,7 +178,7 @@ acpi_battery_get_info(struct acpi_battery *battery, ...@@ -179,7 +178,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
kfree(buffer.pointer); kfree(buffer.pointer);
if (!result) if (!result)
(*bif) = (struct acpi_battery_info *)data.pointer; (*bif) = data.pointer;
return result; return result;
} }
...@@ -209,7 +208,7 @@ acpi_battery_get_status(struct acpi_battery *battery, ...@@ -209,7 +208,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
return -ENODEV; return -ENODEV;
} }
package = (union acpi_object *)buffer.pointer; package = buffer.pointer;
/* Extract Package Data */ /* Extract Package Data */
...@@ -220,12 +219,11 @@ acpi_battery_get_status(struct acpi_battery *battery, ...@@ -220,12 +219,11 @@ acpi_battery_get_status(struct acpi_battery *battery,
goto end; goto end;
} }
data.pointer = kmalloc(data.length, GFP_KERNEL); data.pointer = kzalloc(data.length, GFP_KERNEL);
if (!data.pointer) { if (!data.pointer) {
result = -ENOMEM; result = -ENOMEM;
goto end; goto end;
} }
memset(data.pointer, 0, data.length);
status = acpi_extract_package(package, &format, &data); status = acpi_extract_package(package, &format, &data);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
...@@ -239,7 +237,7 @@ acpi_battery_get_status(struct acpi_battery *battery, ...@@ -239,7 +237,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
kfree(buffer.pointer); kfree(buffer.pointer);
if (!result) if (!result)
(*bst) = (struct acpi_battery_status *)data.pointer; (*bst) = data.pointer;
return result; return result;
} }
...@@ -334,7 +332,7 @@ static struct proc_dir_entry *acpi_battery_dir; ...@@ -334,7 +332,7 @@ static struct proc_dir_entry *acpi_battery_dir;
static int acpi_battery_read_info(struct seq_file *seq, void *offset) static int acpi_battery_read_info(struct seq_file *seq, void *offset)
{ {
int result = 0; int result = 0;
struct acpi_battery *battery = (struct acpi_battery *)seq->private; struct acpi_battery *battery = seq->private;
struct acpi_battery_info *bif = NULL; struct acpi_battery_info *bif = NULL;
char *units = "?"; char *units = "?";
...@@ -418,7 +416,7 @@ static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) ...@@ -418,7 +416,7 @@ static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
static int acpi_battery_read_state(struct seq_file *seq, void *offset) static int acpi_battery_read_state(struct seq_file *seq, void *offset)
{ {
int result = 0; int result = 0;
struct acpi_battery *battery = (struct acpi_battery *)seq->private; struct acpi_battery *battery = seq->private;
struct acpi_battery_status *bst = NULL; struct acpi_battery_status *bst = NULL;
char *units = "?"; char *units = "?";
...@@ -494,7 +492,7 @@ static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) ...@@ -494,7 +492,7 @@ static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
{ {
struct acpi_battery *battery = (struct acpi_battery *)seq->private; struct acpi_battery *battery = seq->private;
char *units = "?"; char *units = "?";
...@@ -531,8 +529,8 @@ acpi_battery_write_alarm(struct file *file, ...@@ -531,8 +529,8 @@ acpi_battery_write_alarm(struct file *file,
{ {
int result = 0; int result = 0;
char alarm_string[12] = { '\0' }; char alarm_string[12] = { '\0' };
struct seq_file *m = (struct seq_file *)file->private_data; struct seq_file *m = file->private_data;
struct acpi_battery *battery = (struct acpi_battery *)m->private; struct acpi_battery *battery = m->private;
if (!battery || (count > sizeof(alarm_string) - 1)) if (!battery || (count > sizeof(alarm_string) - 1))
...@@ -658,7 +656,7 @@ static int acpi_battery_remove_fs(struct acpi_device *device) ...@@ -658,7 +656,7 @@ static int acpi_battery_remove_fs(struct acpi_device *device)
static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
{ {
struct acpi_battery *battery = (struct acpi_battery *)data; struct acpi_battery *battery = data;
struct acpi_device *device = NULL; struct acpi_device *device = NULL;
...@@ -694,10 +692,9 @@ static int acpi_battery_add(struct acpi_device *device) ...@@ -694,10 +692,9 @@ static int acpi_battery_add(struct acpi_device *device)
if (!device) if (!device)
return -EINVAL; return -EINVAL;
battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL); battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
if (!battery) if (!battery)
return -ENOMEM; return -ENOMEM;
memset(battery, 0, sizeof(struct acpi_battery));
battery->device = device; battery->device = device;
strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
...@@ -742,7 +739,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type) ...@@ -742,7 +739,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
battery = (struct acpi_battery *)acpi_driver_data(device); battery = acpi_driver_data(device);
status = acpi_remove_notify_handler(device->handle, status = acpi_remove_notify_handler(device->handle,
ACPI_ALL_NOTIFY, ACPI_ALL_NOTIFY,
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/input.h>
#include <acpi/acpi_bus.h> #include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h> #include <acpi/acpi_drivers.h>
...@@ -62,7 +63,7 @@ ...@@ -62,7 +63,7 @@
#define _COMPONENT ACPI_BUTTON_COMPONENT #define _COMPONENT ACPI_BUTTON_COMPONENT
ACPI_MODULE_NAME("acpi_button") ACPI_MODULE_NAME("acpi_button")
MODULE_AUTHOR("Paul Diefenbaugh"); MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME); MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -78,12 +79,14 @@ static struct acpi_driver acpi_button_driver = { ...@@ -78,12 +79,14 @@ static struct acpi_driver acpi_button_driver = {
.ops = { .ops = {
.add = acpi_button_add, .add = acpi_button_add,
.remove = acpi_button_remove, .remove = acpi_button_remove,
}, },
}; };
struct acpi_button { struct acpi_button {
struct acpi_device *device; /* Fixed button kludge */ struct acpi_device *device; /* Fixed button kludge */
u8 type; unsigned int type;
struct input_dev *input;
char phys[32]; /* for input device */
unsigned long pushed; unsigned long pushed;
}; };
...@@ -109,8 +112,7 @@ static struct proc_dir_entry *acpi_button_dir; ...@@ -109,8 +112,7 @@ static struct proc_dir_entry *acpi_button_dir;
static int acpi_button_info_seq_show(struct seq_file *seq, void *offset) static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
{ {
struct acpi_button *button = (struct acpi_button *)seq->private; struct acpi_button *button = seq->private;
if (!button || !button->device) if (!button || !button->device)
return 0; return 0;
...@@ -128,22 +130,17 @@ static int acpi_button_info_open_fs(struct inode *inode, struct file *file) ...@@ -128,22 +130,17 @@ static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
{ {
struct acpi_button *button = (struct acpi_button *)seq->private; struct acpi_button *button = seq->private;
acpi_status status; acpi_status status;
unsigned long state; unsigned long state;
if (!button || !button->device) if (!button || !button->device)
return 0; return 0;
status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, &state); status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, &state);
if (ACPI_FAILURE(status)) { seq_printf(seq, "state: %s\n",
seq_printf(seq, "state: unsupported\n"); ACPI_FAILURE(status) ? "unsupported" :
} else { (state ? "open" : "closed"));
seq_printf(seq, "state: %s\n",
(state ? "open" : "closed"));
}
return 0; return 0;
} }
...@@ -159,8 +156,7 @@ static struct proc_dir_entry *acpi_lid_dir; ...@@ -159,8 +156,7 @@ static struct proc_dir_entry *acpi_lid_dir;
static int acpi_button_add_fs(struct acpi_device *device) static int acpi_button_add_fs(struct acpi_device *device)
{ {
struct proc_dir_entry *entry = NULL; struct proc_dir_entry *entry = NULL;
struct acpi_button *button = NULL; struct acpi_button *button;
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
...@@ -228,10 +224,8 @@ static int acpi_button_add_fs(struct acpi_device *device) ...@@ -228,10 +224,8 @@ static int acpi_button_add_fs(struct acpi_device *device)
static int acpi_button_remove_fs(struct acpi_device *device) static int acpi_button_remove_fs(struct acpi_device *device)
{ {
struct acpi_button *button = NULL; struct acpi_button *button = acpi_driver_data(device);
button = acpi_driver_data(device);
if (acpi_device_dir(device)) { if (acpi_device_dir(device)) {
if (button->type == ACPI_BUTTON_TYPE_LID) if (button->type == ACPI_BUTTON_TYPE_LID)
remove_proc_entry(ACPI_BUTTON_FILE_STATE, remove_proc_entry(ACPI_BUTTON_FILE_STATE,
...@@ -253,14 +247,34 @@ static int acpi_button_remove_fs(struct acpi_device *device) ...@@ -253,14 +247,34 @@ static int acpi_button_remove_fs(struct acpi_device *device)
static void acpi_button_notify(acpi_handle handle, u32 event, void *data) static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
{ {
struct acpi_button *button = (struct acpi_button *)data; struct acpi_button *button = data;
struct input_dev *input;
if (!button || !button->device) if (!button || !button->device)
return; return;
switch (event) { switch (event) {
case ACPI_BUTTON_NOTIFY_STATUS: case ACPI_BUTTON_NOTIFY_STATUS:
input = button->input;
if (button->type == ACPI_BUTTON_TYPE_LID) {
struct acpi_handle *handle = button->device->handle;
unsigned long state;
if (!ACPI_FAILURE(acpi_evaluate_integer(handle, "_LID",
NULL, &state)))
input_report_switch(input, SW_LID, !state);
} else {
int keycode = test_bit(KEY_SLEEP, input->keybit) ?
KEY_SLEEP : KEY_POWER;
input_report_key(input, keycode, 1);
input_sync(input);
input_report_key(input, keycode, 0);
}
input_sync(input);
acpi_bus_generate_event(button->device, event, acpi_bus_generate_event(button->device, event,
++button->pushed); ++button->pushed);
break; break;
...@@ -275,8 +289,7 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) ...@@ -275,8 +289,7 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
static acpi_status acpi_button_notify_fixed(void *data) static acpi_status acpi_button_notify_fixed(void *data)
{ {
struct acpi_button *button = (struct acpi_button *)data; struct acpi_button *button = data;
if (!button) if (!button)
return AE_BAD_PARAMETER; return AE_BAD_PARAMETER;
...@@ -286,24 +299,75 @@ static acpi_status acpi_button_notify_fixed(void *data) ...@@ -286,24 +299,75 @@ static acpi_status acpi_button_notify_fixed(void *data)
return AE_OK; return AE_OK;
} }
static int acpi_button_add(struct acpi_device *device) static int acpi_button_install_notify_handlers(struct acpi_button *button)
{ {
int result = 0; acpi_status status;
acpi_status status = AE_OK;
struct acpi_button *button = NULL;
switch (button->type) {
case ACPI_BUTTON_TYPE_POWERF:
status =
acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
acpi_button_notify_fixed,
button);
break;
case ACPI_BUTTON_TYPE_SLEEPF:
status =
acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
acpi_button_notify_fixed,
button);
break;
default:
status = acpi_install_notify_handler(button->device->handle,
ACPI_DEVICE_NOTIFY,
acpi_button_notify,
button);
break;
}
return ACPI_FAILURE(status) ? -ENODEV : 0;
}
static void acpi_button_remove_notify_handlers(struct acpi_button *button)
{
switch (button->type) {
case ACPI_BUTTON_TYPE_POWERF:
acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
acpi_button_notify_fixed);
break;
case ACPI_BUTTON_TYPE_SLEEPF:
acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
acpi_button_notify_fixed);
break;
default:
acpi_remove_notify_handler(button->device->handle,
ACPI_DEVICE_NOTIFY,
acpi_button_notify);
break;
}
}
static int acpi_button_add(struct acpi_device *device)
{
int error;
struct acpi_button *button;
struct input_dev *input;
if (!device) if (!device)
return -EINVAL; return -EINVAL;
button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL); button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL);
if (!button) if (!button)
return -ENOMEM; return -ENOMEM;
memset(button, 0, sizeof(struct acpi_button));
button->device = device; button->device = device;
acpi_driver_data(device) = button; acpi_driver_data(device) = button;
button->input = input = input_allocate_device();
if (!input) {
error = -ENOMEM;
goto err_free_button;
}
/* /*
* Determine the button type (via hid), as fixed-feature buttons * Determine the button type (via hid), as fixed-feature buttons
* need to be handled a bit differently than generic-space. * need to be handled a bit differently than generic-space.
...@@ -338,39 +402,48 @@ static int acpi_button_add(struct acpi_device *device) ...@@ -338,39 +402,48 @@ static int acpi_button_add(struct acpi_device *device)
} else { } else {
printk(KERN_ERR PREFIX "Unsupported hid [%s]\n", printk(KERN_ERR PREFIX "Unsupported hid [%s]\n",
acpi_device_hid(device)); acpi_device_hid(device));
result = -ENODEV; error = -ENODEV;
goto end; goto err_free_input;
} }
result = acpi_button_add_fs(device); error = acpi_button_add_fs(device);
if (result) if (error)
goto end; goto err_free_input;
error = acpi_button_install_notify_handlers(button);
if (error)
goto err_remove_fs;
snprintf(button->phys, sizeof(button->phys),
"%s/button/input0", acpi_device_hid(device));
input->name = acpi_device_name(device);
input->phys = button->phys;
input->id.bustype = BUS_HOST;
input->id.product = button->type;
switch (button->type) { switch (button->type) {
case ACPI_BUTTON_TYPE_POWER:
case ACPI_BUTTON_TYPE_POWERF: case ACPI_BUTTON_TYPE_POWERF:
status = input->evbit[0] = BIT(EV_KEY);
acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, set_bit(KEY_POWER, input->keybit);
acpi_button_notify_fixed,
button);
break; break;
case ACPI_BUTTON_TYPE_SLEEP:
case ACPI_BUTTON_TYPE_SLEEPF: case ACPI_BUTTON_TYPE_SLEEPF:
status = input->evbit[0] = BIT(EV_KEY);
acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, set_bit(KEY_SLEEP, input->keybit);
acpi_button_notify_fixed,
button);
break; break;
default:
status = acpi_install_notify_handler(device->handle, case ACPI_BUTTON_TYPE_LID:
ACPI_DEVICE_NOTIFY, input->evbit[0] = BIT(EV_SW);
acpi_button_notify, set_bit(SW_LID, input->swbit);
button);
break; break;
} }
if (ACPI_FAILURE(status)) { error = input_register_device(input);
result = -ENODEV; if (error)
goto end; goto err_remove_handlers;
}
if (device->wakeup.flags.valid) { if (device->wakeup.flags.valid) {
/* Button's GPE is run-wake GPE */ /* Button's GPE is run-wake GPE */
...@@ -385,47 +458,31 @@ static int acpi_button_add(struct acpi_device *device) ...@@ -385,47 +458,31 @@ static int acpi_button_add(struct acpi_device *device)
printk(KERN_INFO PREFIX "%s [%s]\n", printk(KERN_INFO PREFIX "%s [%s]\n",
acpi_device_name(device), acpi_device_bid(device)); acpi_device_name(device), acpi_device_bid(device));
end: return 0;
if (result) {
acpi_button_remove_fs(device);
kfree(button);
}
return result; err_remove_handlers:
acpi_button_remove_notify_handlers(button);
err_remove_fs:
acpi_button_remove_fs(device);
err_free_input:
input_free_device(input);
err_free_button:
kfree(button);
return error;
} }
static int acpi_button_remove(struct acpi_device *device, int type) static int acpi_button_remove(struct acpi_device *device, int type)
{ {
acpi_status status = 0; struct acpi_button *button;
struct acpi_button *button = NULL;
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
button = acpi_driver_data(device); button = acpi_driver_data(device);
/* Unregister for device notifications. */ acpi_button_remove_notify_handlers(button);
switch (button->type) {
case ACPI_BUTTON_TYPE_POWERF:
status =
acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
acpi_button_notify_fixed);
break;
case ACPI_BUTTON_TYPE_SLEEPF:
status =
acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
acpi_button_notify_fixed);
break;
default:
status = acpi_remove_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY,
acpi_button_notify);
break;
}
acpi_button_remove_fs(device); acpi_button_remove_fs(device);
input_unregister_device(button->input);
kfree(button); kfree(button);
return 0; return 0;
...@@ -433,8 +490,7 @@ static int acpi_button_remove(struct acpi_device *device, int type) ...@@ -433,8 +490,7 @@ static int acpi_button_remove(struct acpi_device *device, int type)
static int __init acpi_button_init(void) static int __init acpi_button_init(void)
{ {
int result = 0; int result;
acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
if (!acpi_button_dir) if (!acpi_button_dir)
...@@ -451,7 +507,6 @@ static int __init acpi_button_init(void) ...@@ -451,7 +507,6 @@ static int __init acpi_button_init(void)
static void __exit acpi_button_exit(void) static void __exit acpi_button_exit(void)
{ {
acpi_bus_unregister_driver(&acpi_button_driver); acpi_bus_unregister_driver(&acpi_button_driver);
if (acpi_power_dir) if (acpi_power_dir)
...@@ -461,8 +516,6 @@ static void __exit acpi_button_exit(void) ...@@ -461,8 +516,6 @@ static void __exit acpi_button_exit(void)
if (acpi_lid_dir) if (acpi_lid_dir)
remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
return;
} }
module_init(acpi_button_init); module_init(acpi_button_init);
......
...@@ -96,11 +96,10 @@ static int acpi_container_add(struct acpi_device *device) ...@@ -96,11 +96,10 @@ static int acpi_container_add(struct acpi_device *device)
return -EINVAL; return -EINVAL;
} }
container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL); container = kzalloc(sizeof(struct acpi_container), GFP_KERNEL);
if (!container) if (!container)
return -ENOMEM; return -ENOMEM;
memset(container, 0, sizeof(struct acpi_container));
container->handle = device->handle; container->handle = device->handle;
strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME); strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS); strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS);
...@@ -117,7 +116,7 @@ static int acpi_container_remove(struct acpi_device *device, int type) ...@@ -117,7 +116,7 @@ static int acpi_container_remove(struct acpi_device *device, int type)
acpi_status status = AE_OK; acpi_status status = AE_OK;
struct acpi_container *pc = NULL; struct acpi_container *pc = NULL;
pc = (struct acpi_container *)acpi_driver_data(device); pc = acpi_driver_data(device);
kfree(pc); kfree(pc);
return status; return status;
} }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/platform_device.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <acpi/acpi_bus.h> #include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h> #include <acpi/acpi_drivers.h>
...@@ -39,13 +40,15 @@ MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME); ...@@ -39,13 +40,15 @@ MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static struct atomic_notifier_head dock_notifier_list; static struct atomic_notifier_head dock_notifier_list;
static struct platform_device dock_device;
static char dock_device_name[] = "dock";
struct dock_station { struct dock_station {
acpi_handle handle; acpi_handle handle;
unsigned long last_dock_time; unsigned long last_dock_time;
u32 flags; u32 flags;
spinlock_t dd_lock; spinlock_t dd_lock;
spinlock_t hp_lock; struct mutex hp_lock;
struct list_head dependent_devices; struct list_head dependent_devices;
struct list_head hotplug_devices; struct list_head hotplug_devices;
}; };
...@@ -115,9 +118,9 @@ static void ...@@ -115,9 +118,9 @@ static void
dock_add_hotplug_device(struct dock_station *ds, dock_add_hotplug_device(struct dock_station *ds,
struct dock_dependent_device *dd) struct dock_dependent_device *dd)
{ {
spin_lock(&ds->hp_lock); mutex_lock(&ds->hp_lock);
list_add_tail(&dd->hotplug_list, &ds->hotplug_devices); list_add_tail(&dd->hotplug_list, &ds->hotplug_devices);
spin_unlock(&ds->hp_lock); mutex_unlock(&ds->hp_lock);
} }
/** /**
...@@ -131,9 +134,9 @@ static void ...@@ -131,9 +134,9 @@ static void
dock_del_hotplug_device(struct dock_station *ds, dock_del_hotplug_device(struct dock_station *ds,
struct dock_dependent_device *dd) struct dock_dependent_device *dd)
{ {
spin_lock(&ds->hp_lock); mutex_lock(&ds->hp_lock);
list_del(&dd->hotplug_list); list_del(&dd->hotplug_list);
spin_unlock(&ds->hp_lock); mutex_unlock(&ds->hp_lock);
} }
/** /**
...@@ -296,7 +299,7 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event) ...@@ -296,7 +299,7 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event)
{ {
struct dock_dependent_device *dd; struct dock_dependent_device *dd;
spin_lock(&ds->hp_lock); mutex_lock(&ds->hp_lock);
/* /*
* First call driver specific hotplug functions * First call driver specific hotplug functions
...@@ -318,15 +321,17 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event) ...@@ -318,15 +321,17 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event)
else else
dock_create_acpi_device(dd->handle); dock_create_acpi_device(dd->handle);
} }
spin_unlock(&ds->hp_lock); mutex_unlock(&ds->hp_lock);
} }
static void dock_event(struct dock_station *ds, u32 event, int num) static void dock_event(struct dock_station *ds, u32 event, int num)
{ {
struct device *dev = &dock_device.dev;
/* /*
* we don't do events until someone tells me that * Indicate that the status of the dock station has
* they would like to have them. * changed.
*/ */
kobject_uevent(&dev->kobj, KOBJ_CHANGE);
} }
/** /**
...@@ -441,6 +446,9 @@ static int dock_in_progress(struct dock_station *ds) ...@@ -441,6 +446,9 @@ static int dock_in_progress(struct dock_station *ds)
*/ */
int register_dock_notifier(struct notifier_block *nb) int register_dock_notifier(struct notifier_block *nb)
{ {
if (!dock_station)
return -ENODEV;
return atomic_notifier_chain_register(&dock_notifier_list, nb); return atomic_notifier_chain_register(&dock_notifier_list, nb);
} }
...@@ -452,6 +460,9 @@ EXPORT_SYMBOL_GPL(register_dock_notifier); ...@@ -452,6 +460,9 @@ EXPORT_SYMBOL_GPL(register_dock_notifier);
*/ */
void unregister_dock_notifier(struct notifier_block *nb) void unregister_dock_notifier(struct notifier_block *nb)
{ {
if (!dock_station)
return;
atomic_notifier_chain_unregister(&dock_notifier_list, nb); atomic_notifier_chain_unregister(&dock_notifier_list, nb);
} }
...@@ -511,6 +522,37 @@ void unregister_hotplug_dock_device(acpi_handle handle) ...@@ -511,6 +522,37 @@ void unregister_hotplug_dock_device(acpi_handle handle)
EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device);
/**
* handle_eject_request - handle an undock request checking for error conditions
*
* Check to make sure the dock device is still present, then undock and
* hotremove all the devices that may need removing.
*/
static int handle_eject_request(struct dock_station *ds, u32 event)
{
if (!dock_present(ds))
return -ENODEV;
if (dock_in_progress(ds))
return -EBUSY;
/*
* here we need to generate the undock
* event prior to actually doing the undock
* so that the device struct still exists.
*/
dock_event(ds, event, UNDOCK_EVENT);
hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST);
undock(ds);
eject_dock(ds);
if (dock_present(ds)) {
printk(KERN_ERR PREFIX "Unable to undock!\n");
return -EBUSY;
}
return 0;
}
/** /**
* dock_notify - act upon an acpi dock notification * dock_notify - act upon an acpi dock notification
* @handle: the dock station handle * @handle: the dock station handle
...@@ -519,13 +561,11 @@ EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); ...@@ -519,13 +561,11 @@ EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device);
* *
* If we are notified to dock, then check to see if the dock is * If we are notified to dock, then check to see if the dock is
* present and then dock. Notify all drivers of the dock event, * present and then dock. Notify all drivers of the dock event,
* and then hotplug and devices that may need hotplugging. For undock * and then hotplug and devices that may need hotplugging.
* check to make sure the dock device is still present, then undock
* and hotremove all the devices that may need removing.
*/ */
static void dock_notify(acpi_handle handle, u32 event, void *data) static void dock_notify(acpi_handle handle, u32 event, void *data)
{ {
struct dock_station *ds = (struct dock_station *)data; struct dock_station *ds = data;
switch (event) { switch (event) {
case ACPI_NOTIFY_BUS_CHECK: case ACPI_NOTIFY_BUS_CHECK:
...@@ -553,19 +593,7 @@ static void dock_notify(acpi_handle handle, u32 event, void *data) ...@@ -553,19 +593,7 @@ static void dock_notify(acpi_handle handle, u32 event, void *data)
* to the driver who wish to hotplug. * to the driver who wish to hotplug.
*/ */
case ACPI_NOTIFY_EJECT_REQUEST: case ACPI_NOTIFY_EJECT_REQUEST:
if (!dock_in_progress(ds) && dock_present(ds)) { handle_eject_request(ds, event);
/*
* here we need to generate the undock
* event prior to actually doing the undock
* so that the device struct still exists.
*/
dock_event(ds, event, UNDOCK_EVENT);
hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST);
undock(ds);
eject_dock(ds);
if (dock_present(ds))
printk(KERN_ERR PREFIX "Unable to undock!\n");
}
break; break;
default: default:
printk(KERN_ERR PREFIX "Unknown dock event %d\n", event); printk(KERN_ERR PREFIX "Unknown dock event %d\n", event);
...@@ -588,7 +616,7 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -588,7 +616,7 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
{ {
acpi_status status; acpi_status status;
acpi_handle tmp; acpi_handle tmp;
struct dock_station *ds = (struct dock_station *)context; struct dock_station *ds = context;
struct dock_dependent_device *dd; struct dock_dependent_device *dd;
status = acpi_bus_get_ejd(handle, &tmp); status = acpi_bus_get_ejd(handle, &tmp);
...@@ -604,6 +632,33 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -604,6 +632,33 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
return AE_OK; return AE_OK;
} }
/*
* show_docked - read method for "docked" file in sysfs
*/
static ssize_t show_docked(struct device *dev,
struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n", dock_present(dock_station));
}
DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
/*
* write_undock - write method for "undock" file in sysfs
*/
static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int ret;
if (!count)
return -EINVAL;
ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
return ret ? ret: count;
}
DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
/** /**
* dock_add - add a new dock station * dock_add - add a new dock station
* @handle: the dock station handle * @handle: the dock station handle
...@@ -626,9 +681,33 @@ static int dock_add(acpi_handle handle) ...@@ -626,9 +681,33 @@ static int dock_add(acpi_handle handle)
INIT_LIST_HEAD(&dock_station->dependent_devices); INIT_LIST_HEAD(&dock_station->dependent_devices);
INIT_LIST_HEAD(&dock_station->hotplug_devices); INIT_LIST_HEAD(&dock_station->hotplug_devices);
spin_lock_init(&dock_station->dd_lock); spin_lock_init(&dock_station->dd_lock);
spin_lock_init(&dock_station->hp_lock); mutex_init(&dock_station->hp_lock);
ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
/* initialize platform device stuff */
dock_device.name = dock_device_name;
ret = platform_device_register(&dock_device);
if (ret) {
printk(KERN_ERR PREFIX "Error %d registering dock device\n", ret);
kfree(dock_station);
return ret;
}
ret = device_create_file(&dock_device.dev, &dev_attr_docked);
if (ret) {
printk("Error %d adding sysfs file\n", ret);
platform_device_unregister(&dock_device);
kfree(dock_station);
return ret;
}
ret = device_create_file(&dock_device.dev, &dev_attr_undock);
if (ret) {
printk("Error %d adding sysfs file\n", ret);
device_remove_file(&dock_device.dev, &dev_attr_docked);
platform_device_unregister(&dock_device);
kfree(dock_station);
return ret;
}
/* Find dependent devices */ /* Find dependent devices */
acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, find_dock_devices, dock_station, ACPI_UINT32_MAX, find_dock_devices, dock_station,
...@@ -638,7 +717,8 @@ static int dock_add(acpi_handle handle) ...@@ -638,7 +717,8 @@ static int dock_add(acpi_handle handle)
dd = alloc_dock_dependent_device(handle); dd = alloc_dock_dependent_device(handle);
if (!dd) { if (!dd) {
kfree(dock_station); kfree(dock_station);
return -ENOMEM; ret = -ENOMEM;
goto dock_add_err_unregister;
} }
add_dock_dependent_device(dock_station, dd); add_dock_dependent_device(dock_station, dd);
...@@ -658,8 +738,12 @@ static int dock_add(acpi_handle handle) ...@@ -658,8 +738,12 @@ static int dock_add(acpi_handle handle)
return 0; return 0;
dock_add_err: dock_add_err:
kfree(dock_station);
kfree(dd); kfree(dd);
dock_add_err_unregister:
device_remove_file(&dock_device.dev, &dev_attr_docked);
device_remove_file(&dock_device.dev, &dev_attr_undock);
platform_device_unregister(&dock_device);
kfree(dock_station);
return ret; return ret;
} }
...@@ -686,6 +770,11 @@ static int dock_remove(void) ...@@ -686,6 +770,11 @@ static int dock_remove(void)
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
printk(KERN_ERR "Error removing notify handler\n"); printk(KERN_ERR "Error removing notify handler\n");
/* cleanup sysfs */
device_remove_file(&dock_device.dev, &dev_attr_docked);
device_remove_file(&dock_device.dev, &dev_attr_undock);
platform_device_unregister(&dock_device);
/* free dock station memory */ /* free dock station memory */
kfree(dock_station); kfree(dock_station);
return 0; return 0;
...@@ -703,7 +792,7 @@ static int dock_remove(void) ...@@ -703,7 +792,7 @@ static int dock_remove(void)
static acpi_status static acpi_status
find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
{ {
int *count = (int *)context; int *count = context;
acpi_status status = AE_OK; acpi_status status = AE_OK;
if (is_dock(handle)) { if (is_dock(handle)) {
...@@ -726,7 +815,7 @@ static int __init dock_init(void) ...@@ -726,7 +815,7 @@ static int __init dock_init(void)
ACPI_UINT32_MAX, find_dock, &num, NULL); ACPI_UINT32_MAX, find_dock, &num, NULL);
if (!num) if (!num)
return -ENODEV; printk(KERN_INFO "No dock devices found.\n");
return 0; return 0;
} }
......
This diff is collapsed.
...@@ -331,7 +331,6 @@ static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context) ...@@ -331,7 +331,6 @@ static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context)
static u32 acpi_ev_global_lock_handler(void *context) static u32 acpi_ev_global_lock_handler(void *context)
{ {
u8 acquired = FALSE; u8 acquired = FALSE;
acpi_status status;
/* /*
* Attempt to get the lock * Attempt to get the lock
......
...@@ -266,10 +266,10 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, ...@@ -266,10 +266,10 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
walk_state->thread->thread_id) walk_state->thread->thread_id)
&& (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) { && (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) {
ACPI_ERROR((AE_INFO, ACPI_ERROR((AE_INFO,
"Thread %X cannot release Mutex [%4.4s] acquired by thread %X", "Thread %lX cannot release Mutex [%4.4s] acquired by thread %lX",
(u32) walk_state->thread->thread_id, (unsigned long)walk_state->thread->thread_id,
acpi_ut_get_node_name(obj_desc->mutex.node), acpi_ut_get_node_name(obj_desc->mutex.node),
(u32) obj_desc->mutex.owner_thread->thread_id)); (unsigned long)obj_desc->mutex.owner_thread->thread_id));
return_ACPI_STATUS(AE_AML_NOT_OWNER); return_ACPI_STATUS(AE_AML_NOT_OWNER);
} }
......
...@@ -99,8 +99,8 @@ acpi_fan_write_state(struct file *file, const char __user * buffer, ...@@ -99,8 +99,8 @@ acpi_fan_write_state(struct file *file, const char __user * buffer,
size_t count, loff_t * ppos) size_t count, loff_t * ppos)
{ {
int result = 0; int result = 0;
struct seq_file *m = (struct seq_file *)file->private_data; struct seq_file *m = file->private_data;
struct acpi_fan *fan = (struct acpi_fan *)m->private; struct acpi_fan *fan = m->private;
char state_string[12] = { '\0' }; char state_string[12] = { '\0' };
...@@ -186,10 +186,9 @@ static int acpi_fan_add(struct acpi_device *device) ...@@ -186,10 +186,9 @@ static int acpi_fan_add(struct acpi_device *device)
if (!device) if (!device)
return -EINVAL; return -EINVAL;
fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL); fan = kzalloc(sizeof(struct acpi_fan), GFP_KERNEL);
if (!fan) if (!fan)
return -ENOMEM; return -ENOMEM;
memset(fan, 0, sizeof(struct acpi_fan));
fan->device = device; fan->device = device;
strcpy(acpi_device_name(device), "Fan"); strcpy(acpi_device_name(device), "Fan");
...@@ -229,7 +228,7 @@ static int acpi_fan_remove(struct acpi_device *device, int type) ...@@ -229,7 +228,7 @@ static int acpi_fan_remove(struct acpi_device *device, int type)
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
fan = (struct acpi_fan *)acpi_driver_data(device); fan = acpi_driver_data(device);
acpi_fan_remove_fs(device); acpi_fan_remove_fs(device);
......
...@@ -96,7 +96,7 @@ struct acpi_find_pci_root { ...@@ -96,7 +96,7 @@ struct acpi_find_pci_root {
static acpi_status static acpi_status
do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
{ {
unsigned long *busnr = (unsigned long *)data; unsigned long *busnr = data;
struct acpi_resource_address64 address; struct acpi_resource_address64 address;
if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 &&
...@@ -189,8 +189,12 @@ find_pci_rootbridge(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -189,8 +189,12 @@ find_pci_rootbridge(acpi_handle handle, u32 lvl, void *context, void **rv)
bus = tmp; bus = tmp;
if (seg == find->seg && bus == find->bus) if (seg == find->seg && bus == find->bus)
{
find->handle = handle; find->handle = handle;
status = AE_OK; status = AE_CTRL_TERMINATE;
}
else
status = AE_OK;
exit: exit:
kfree(buffer.pointer); kfree(buffer.pointer);
return status; return status;
...@@ -217,7 +221,7 @@ do_acpi_find_child(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -217,7 +221,7 @@ do_acpi_find_child(acpi_handle handle, u32 lvl, void *context, void **rv)
acpi_status status; acpi_status status;
struct acpi_device_info *info; struct acpi_device_info *info;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_find_child *find = (struct acpi_find_child *)context; struct acpi_find_child *find = context;
status = acpi_get_object_info(handle, &buffer); status = acpi_get_object_info(handle, &buffer);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
......
...@@ -265,8 +265,7 @@ static char *format_result(union acpi_object *object) ...@@ -265,8 +265,7 @@ static char *format_result(union acpi_object *object)
static int hotkey_polling_seq_show(struct seq_file *seq, void *offset) static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
{ {
struct acpi_polling_hotkey *poll_hotkey = struct acpi_polling_hotkey *poll_hotkey = seq->private;
(struct acpi_polling_hotkey *)seq->private;
char *buf; char *buf;
...@@ -577,7 +576,7 @@ init_poll_hotkey_device(union acpi_hotkey *key, char **config_entry, ...@@ -577,7 +576,7 @@ init_poll_hotkey_device(union acpi_hotkey *key, char **config_entry,
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
goto do_fail_zero; goto do_fail_zero;
key->poll_hotkey.poll_result = key->poll_hotkey.poll_result =
(union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); kmalloc(sizeof(union acpi_object), GFP_KERNEL);
if (!key->poll_hotkey.poll_result) if (!key->poll_hotkey.poll_result)
goto do_fail_zero; goto do_fail_zero;
return AE_OK; return AE_OK;
......
...@@ -309,18 +309,16 @@ static int acpi_ec_hc_add(struct acpi_device *device) ...@@ -309,18 +309,16 @@ static int acpi_ec_hc_add(struct acpi_device *device)
return -EINVAL; return -EINVAL;
} }
ec_hc = kmalloc(sizeof(struct acpi_ec_hc), GFP_KERNEL); ec_hc = kzalloc(sizeof(struct acpi_ec_hc), GFP_KERNEL);
if (!ec_hc) { if (!ec_hc) {
return -ENOMEM; return -ENOMEM;
} }
memset(ec_hc, 0, sizeof(struct acpi_ec_hc));
smbus = kmalloc(sizeof(struct acpi_ec_smbus), GFP_KERNEL); smbus = kzalloc(sizeof(struct acpi_ec_smbus), GFP_KERNEL);
if (!smbus) { if (!smbus) {
kfree(ec_hc); kfree(ec_hc);
return -ENOMEM; return -ENOMEM;
} }
memset(smbus, 0, sizeof(struct acpi_ec_smbus));
ec_hc->handle = device->handle; ec_hc->handle = device->handle;
strcpy(acpi_device_name(device), ACPI_EC_HC_DEVICE_NAME); strcpy(acpi_device_name(device), ACPI_EC_HC_DEVICE_NAME);
...@@ -393,7 +391,7 @@ static void __exit acpi_ec_hc_exit(void) ...@@ -393,7 +391,7 @@ static void __exit acpi_ec_hc_exit(void)
struct acpi_ec_hc *acpi_get_ec_hc(struct acpi_device *device) struct acpi_ec_hc *acpi_get_ec_hc(struct acpi_device *device)
{ {
return ((struct acpi_ec_hc *)acpi_driver_data(device->parent)); return acpi_driver_data(device->parent);
} }
EXPORT_SYMBOL(acpi_get_ec_hc); EXPORT_SYMBOL(acpi_get_ec_hc);
......
This diff is collapsed.
...@@ -48,6 +48,50 @@ ...@@ -48,6 +48,50 @@
#define _COMPONENT ACPI_NAMESPACE #define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME("nsxfobj") ACPI_MODULE_NAME("nsxfobj")
/*******************************************************************************
*
* FUNCTION: acpi_get_id
*
* PARAMETERS: Handle - Handle of object whose id is desired
* ret_id - Where the id will be placed
*
* RETURN: Status
*
* DESCRIPTION: This routine returns the owner id associated with a handle
*
******************************************************************************/
acpi_status acpi_get_id(acpi_handle handle, acpi_owner_id * ret_id)
{
struct acpi_namespace_node *node;
acpi_status status;
/* Parameter Validation */
if (!ret_id) {
return (AE_BAD_PARAMETER);
}
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return (status);
}
/* Convert and validate the handle */
node = acpi_ns_map_handle_to_node(handle);
if (!node) {
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
return (AE_BAD_PARAMETER);
}
*ret_id = node->owner_id;
status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
return (status);
}
ACPI_EXPORT_SYMBOL(acpi_get_id)
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_get_type * FUNCTION: acpi_get_type
......
...@@ -248,7 +248,7 @@ int acpi_get_pxm(acpi_handle h) ...@@ -248,7 +248,7 @@ int acpi_get_pxm(acpi_handle h)
handle = phandle; handle = phandle;
status = acpi_evaluate_integer(handle, "_PXM", NULL, &pxm); status = acpi_evaluate_integer(handle, "_PXM", NULL, &pxm);
if (ACPI_SUCCESS(status)) if (ACPI_SUCCESS(status))
return (int)pxm; return pxm;
status = acpi_get_parent(handle, &phandle); status = acpi_get_parent(handle, &phandle);
} while (ACPI_SUCCESS(status)); } while (ACPI_SUCCESS(status));
return -1; return -1;
......
...@@ -568,6 +568,7 @@ void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */ ...@@ -568,6 +568,7 @@ void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
static void acpi_os_execute_deferred(struct work_struct *work) static void acpi_os_execute_deferred(struct work_struct *work)
{ {
struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
if (!dpc) { if (!dpc) {
printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
return; return;
...@@ -1031,7 +1032,7 @@ acpi_status ...@@ -1031,7 +1032,7 @@ acpi_status
acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache) acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
{ {
*cache = kmem_cache_create(name, size, 0, 0, NULL, NULL); *cache = kmem_cache_create(name, size, 0, 0, NULL, NULL);
if (cache == NULL) if (*cache == NULL)
return AE_ERROR; return AE_ERROR;
else else
return AE_OK; return AE_OK;
...@@ -1051,7 +1052,7 @@ acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache) ...@@ -1051,7 +1052,7 @@ acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
acpi_status acpi_os_purge_cache(acpi_cache_t * cache) acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
{ {
(void)kmem_cache_shrink(cache); kmem_cache_shrink(cache);
return (AE_OK); return (AE_OK);
} }
......
...@@ -122,19 +122,17 @@ int acpi_pci_bind(struct acpi_device *device) ...@@ -122,19 +122,17 @@ int acpi_pci_bind(struct acpi_device *device)
if (!device || !device->parent) if (!device || !device->parent)
return -EINVAL; return -EINVAL;
pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
if (!pathname) if (!pathname)
return -ENOMEM; return -ENOMEM;
memset(pathname, 0, ACPI_PATHNAME_MAX);
buffer.length = ACPI_PATHNAME_MAX; buffer.length = ACPI_PATHNAME_MAX;
buffer.pointer = pathname; buffer.pointer = pathname;
data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
if (!data) { if (!data) {
kfree(pathname); kfree(pathname);
return -ENOMEM; return -ENOMEM;
} }
memset(data, 0, sizeof(struct acpi_pci_data));
acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n",
...@@ -281,10 +279,9 @@ int acpi_pci_unbind(struct acpi_device *device) ...@@ -281,10 +279,9 @@ int acpi_pci_unbind(struct acpi_device *device)
if (!device || !device->parent) if (!device || !device->parent)
return -EINVAL; return -EINVAL;
pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
if (!pathname) if (!pathname)
return -ENOMEM; return -ENOMEM;
memset(pathname, 0, ACPI_PATHNAME_MAX);
buffer.length = ACPI_PATHNAME_MAX; buffer.length = ACPI_PATHNAME_MAX;
buffer.pointer = pathname; buffer.pointer = pathname;
...@@ -331,11 +328,9 @@ acpi_pci_bind_root(struct acpi_device *device, ...@@ -331,11 +328,9 @@ acpi_pci_bind_root(struct acpi_device *device,
char *pathname = NULL; char *pathname = NULL;
struct acpi_buffer buffer = { 0, NULL }; struct acpi_buffer buffer = { 0, NULL };
pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
if (!pathname) if (!pathname)
return -ENOMEM; return -ENOMEM;
memset(pathname, 0, ACPI_PATHNAME_MAX);
buffer.length = ACPI_PATHNAME_MAX; buffer.length = ACPI_PATHNAME_MAX;
buffer.pointer = pathname; buffer.pointer = pathname;
...@@ -345,12 +340,11 @@ acpi_pci_bind_root(struct acpi_device *device, ...@@ -345,12 +340,11 @@ acpi_pci_bind_root(struct acpi_device *device,
return -EINVAL; return -EINVAL;
} }
data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
if (!data) { if (!data) {
kfree(pathname); kfree(pathname);
return -ENOMEM; return -ENOMEM;
} }
memset(data, 0, sizeof(struct acpi_pci_data));
data->id = *id; data->id = *id;
data->bus = bus; data->bus = bus;
......
...@@ -89,10 +89,9 @@ acpi_pci_irq_add_entry(acpi_handle handle, ...@@ -89,10 +89,9 @@ acpi_pci_irq_add_entry(acpi_handle handle,
if (!prt) if (!prt)
return -EINVAL; return -EINVAL;
entry = kmalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
if (!entry) if (!entry)
return -ENOMEM; return -ENOMEM;
memset(entry, 0, sizeof(struct acpi_prt_entry));
entry->id.segment = segment; entry->id.segment = segment;
entry->id.bus = bus; entry->id.bus = bus;
...@@ -161,10 +160,9 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) ...@@ -161,10 +160,9 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
static int first_time = 1; static int first_time = 1;
pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
if (!pathname) if (!pathname)
return -ENOMEM; return -ENOMEM;
memset(pathname, 0, ACPI_PATHNAME_MAX);
if (first_time) { if (first_time) {
acpi_prt.count = 0; acpi_prt.count = 0;
...@@ -198,11 +196,10 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) ...@@ -198,11 +196,10 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
return -ENODEV; return -ENODEV;
} }
prt = kmalloc(buffer.length, GFP_KERNEL); prt = kzalloc(buffer.length, GFP_KERNEL);
if (!prt) { if (!prt) {
return -ENOMEM; return -ENOMEM;
} }
memset(prt, 0, buffer.length);
buffer.pointer = prt; buffer.pointer = prt;
status = acpi_get_irq_routing_table(handle, &buffer); status = acpi_get_irq_routing_table(handle, &buffer);
......
...@@ -103,7 +103,7 @@ DEFINE_MUTEX(acpi_link_lock); ...@@ -103,7 +103,7 @@ DEFINE_MUTEX(acpi_link_lock);
static acpi_status static acpi_status
acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
{ {
struct acpi_pci_link *link = (struct acpi_pci_link *)context; struct acpi_pci_link *link = context;
u32 i = 0; u32 i = 0;
...@@ -307,11 +307,10 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) ...@@ -307,11 +307,10 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
if (!link || !irq) if (!link || !irq)
return -EINVAL; return -EINVAL;
resource = kmalloc(sizeof(*resource) + 1, irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL); resource = kzalloc(sizeof(*resource) + 1, irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL);
if (!resource) if (!resource)
return -ENOMEM; return -ENOMEM;
memset(resource, 0, sizeof(*resource) + 1);
buffer.length = sizeof(*resource) + 1; buffer.length = sizeof(*resource) + 1;
buffer.pointer = resource; buffer.pointer = resource;
...@@ -613,7 +612,7 @@ acpi_pci_link_allocate_irq(acpi_handle handle, ...@@ -613,7 +612,7 @@ acpi_pci_link_allocate_irq(acpi_handle handle,
return -1; return -1;
} }
link = (struct acpi_pci_link *)acpi_driver_data(device); link = acpi_driver_data(device);
if (!link) { if (!link) {
printk(KERN_ERR PREFIX "Invalid link context\n"); printk(KERN_ERR PREFIX "Invalid link context\n");
return -1; return -1;
...@@ -668,7 +667,7 @@ int acpi_pci_link_free_irq(acpi_handle handle) ...@@ -668,7 +667,7 @@ int acpi_pci_link_free_irq(acpi_handle handle)
return -1; return -1;
} }
link = (struct acpi_pci_link *)acpi_driver_data(device); link = acpi_driver_data(device);
if (!link) { if (!link) {
printk(KERN_ERR PREFIX "Invalid link context\n"); printk(KERN_ERR PREFIX "Invalid link context\n");
return -1; return -1;
...@@ -718,10 +717,9 @@ static int acpi_pci_link_add(struct acpi_device *device) ...@@ -718,10 +717,9 @@ static int acpi_pci_link_add(struct acpi_device *device)
if (!device) if (!device)
return -EINVAL; return -EINVAL;
link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL); link = kzalloc(sizeof(struct acpi_pci_link), GFP_KERNEL);
if (!link) if (!link)
return -ENOMEM; return -ENOMEM;
memset(link, 0, sizeof(struct acpi_pci_link));
link->device = device; link->device = device;
strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME); strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME);
...@@ -808,7 +806,7 @@ static int acpi_pci_link_remove(struct acpi_device *device, int type) ...@@ -808,7 +806,7 @@ static int acpi_pci_link_remove(struct acpi_device *device, int type)
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
link = (struct acpi_pci_link *)acpi_driver_data(device); link = acpi_driver_data(device);
mutex_lock(&acpi_link_lock); mutex_lock(&acpi_link_lock);
list_del(&link->node); list_del(&link->node);
......
...@@ -98,11 +98,12 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) ...@@ -98,11 +98,12 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver)
struct acpi_pci_driver **pptr = &sub_driver; struct acpi_pci_driver **pptr = &sub_driver;
while (*pptr) { while (*pptr) {
if (*pptr != driver) if (*pptr == driver)
continue; break;
*pptr = (*pptr)->next; pptr = &(*pptr)->next;
break;
} }
BUG_ON(!*pptr);
*pptr = (*pptr)->next;
if (!driver->remove) if (!driver->remove)
return; return;
...@@ -119,7 +120,7 @@ EXPORT_SYMBOL(acpi_pci_unregister_driver); ...@@ -119,7 +120,7 @@ EXPORT_SYMBOL(acpi_pci_unregister_driver);
static acpi_status static acpi_status
get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
{ {
int *busnr = (int *)data; int *busnr = data;
struct acpi_resource_address64 address; struct acpi_resource_address64 address;
if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 &&
...@@ -164,10 +165,9 @@ static int acpi_pci_root_add(struct acpi_device *device) ...@@ -164,10 +165,9 @@ static int acpi_pci_root_add(struct acpi_device *device)
if (!device) if (!device)
return -EINVAL; return -EINVAL;
root = kmalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
if (!root) if (!root)
return -ENOMEM; return -ENOMEM;
memset(root, 0, sizeof(struct acpi_pci_root));
INIT_LIST_HEAD(&root->node); INIT_LIST_HEAD(&root->node);
root->device = device; root->device = device;
...@@ -331,7 +331,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type) ...@@ -331,7 +331,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
root = (struct acpi_pci_root *)acpi_driver_data(device); root = acpi_driver_data(device);
kfree(root); kfree(root);
......
...@@ -108,7 +108,7 @@ acpi_power_get_context(acpi_handle handle, ...@@ -108,7 +108,7 @@ acpi_power_get_context(acpi_handle handle,
return result; return result;
} }
*resource = (struct acpi_power_resource *)acpi_driver_data(device); *resource = acpi_driver_data(device);
if (!resource) if (!resource)
return -ENODEV; return -ENODEV;
...@@ -442,7 +442,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset) ...@@ -442,7 +442,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
struct acpi_power_resource *resource = NULL; struct acpi_power_resource *resource = NULL;
resource = (struct acpi_power_resource *)seq->private; resource = seq->private;
if (!resource) if (!resource)
goto end; goto end;
...@@ -532,10 +532,9 @@ static int acpi_power_add(struct acpi_device *device) ...@@ -532,10 +532,9 @@ static int acpi_power_add(struct acpi_device *device)
if (!device) if (!device)
return -EINVAL; return -EINVAL;
resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL); resource = kzalloc(sizeof(struct acpi_power_resource), GFP_KERNEL);
if (!resource) if (!resource)
return -ENOMEM; return -ENOMEM;
memset(resource, 0, sizeof(struct acpi_power_resource));
resource->device = device; resource->device = device;
strcpy(resource->name, device->pnp.bus_id); strcpy(resource->name, device->pnp.bus_id);
...@@ -590,7 +589,7 @@ static int acpi_power_remove(struct acpi_device *device, int type) ...@@ -590,7 +589,7 @@ static int acpi_power_remove(struct acpi_device *device, int type)
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
resource = (struct acpi_power_resource *)acpi_driver_data(device); resource = acpi_driver_data(device);
acpi_power_remove_fs(device); acpi_power_remove_fs(device);
......
...@@ -277,7 +277,7 @@ static struct proc_dir_entry *acpi_processor_dir = NULL; ...@@ -277,7 +277,7 @@ static struct proc_dir_entry *acpi_processor_dir = NULL;
static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset) static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
{ {
struct acpi_processor *pr = (struct acpi_processor *)seq->private; struct acpi_processor *pr = seq->private;
if (!pr) if (!pr)
...@@ -542,12 +542,12 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) ...@@ -542,12 +542,12 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
* Don't trust it blindly * Don't trust it blindly
*/ */
if (processor_device_array[pr->id] != NULL && if (processor_device_array[pr->id] != NULL &&
processor_device_array[pr->id] != (void *)device) { processor_device_array[pr->id] != device) {
printk(KERN_WARNING "BIOS reported wrong ACPI id" printk(KERN_WARNING "BIOS reported wrong ACPI id"
"for the processor\n"); "for the processor\n");
return -ENODEV; return -ENODEV;
} }
processor_device_array[pr->id] = (void *)device; processor_device_array[pr->id] = device;
processors[pr->id] = pr; processors[pr->id] = pr;
...@@ -578,7 +578,7 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) ...@@ -578,7 +578,7 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
{ {
struct acpi_processor *pr = (struct acpi_processor *)data; struct acpi_processor *pr = data;
struct acpi_device *device = NULL; struct acpi_device *device = NULL;
...@@ -615,10 +615,9 @@ static int acpi_processor_add(struct acpi_device *device) ...@@ -615,10 +615,9 @@ static int acpi_processor_add(struct acpi_device *device)
if (!device) if (!device)
return -EINVAL; return -EINVAL;
pr = kmalloc(sizeof(struct acpi_processor), GFP_KERNEL); pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
if (!pr) if (!pr)
return -ENOMEM; return -ENOMEM;
memset(pr, 0, sizeof(struct acpi_processor));
pr->handle = device->handle; pr->handle = device->handle;
strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
...@@ -637,7 +636,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type) ...@@ -637,7 +636,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
pr = (struct acpi_processor *)acpi_driver_data(device); pr = acpi_driver_data(device);
if (pr->id >= NR_CPUS) { if (pr->id >= NR_CPUS) {
kfree(pr); kfree(pr);
...@@ -901,13 +900,13 @@ static int __init acpi_processor_init(void) ...@@ -901,13 +900,13 @@ static int __init acpi_processor_init(void)
acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
if (!acpi_processor_dir) if (!acpi_processor_dir)
return 0; return -ENOMEM;
acpi_processor_dir->owner = THIS_MODULE; acpi_processor_dir->owner = THIS_MODULE;
result = acpi_bus_register_driver(&acpi_processor_driver); result = acpi_bus_register_driver(&acpi_processor_driver);
if (result < 0) { if (result < 0) {
remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
return 0; return result;
} }
acpi_processor_install_hotplug_notify(); acpi_processor_install_hotplug_notify();
......
...@@ -681,7 +681,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) ...@@ -681,7 +681,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
return -ENODEV; return -ENODEV;
} }
cst = (union acpi_object *)buffer.pointer; cst = buffer.pointer;
/* There must be at least 2 elements */ /* There must be at least 2 elements */
if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) { if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) {
...@@ -710,14 +710,14 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) ...@@ -710,14 +710,14 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
memset(&cx, 0, sizeof(cx)); memset(&cx, 0, sizeof(cx));
element = (union acpi_object *)&(cst->package.elements[i]); element = &(cst->package.elements[i]);
if (element->type != ACPI_TYPE_PACKAGE) if (element->type != ACPI_TYPE_PACKAGE)
continue; continue;
if (element->package.count != 4) if (element->package.count != 4)
continue; continue;
obj = (union acpi_object *)&(element->package.elements[0]); obj = &(element->package.elements[0]);
if (obj->type != ACPI_TYPE_BUFFER) if (obj->type != ACPI_TYPE_BUFFER)
continue; continue;
...@@ -729,7 +729,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) ...@@ -729,7 +729,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
continue; continue;
/* There should be an easy way to extract an integer... */ /* There should be an easy way to extract an integer... */
obj = (union acpi_object *)&(element->package.elements[1]); obj = &(element->package.elements[1]);
if (obj->type != ACPI_TYPE_INTEGER) if (obj->type != ACPI_TYPE_INTEGER)
continue; continue;
...@@ -762,13 +762,13 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) ...@@ -762,13 +762,13 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
} }
} }
obj = (union acpi_object *)&(element->package.elements[2]); obj = &(element->package.elements[2]);
if (obj->type != ACPI_TYPE_INTEGER) if (obj->type != ACPI_TYPE_INTEGER)
continue; continue;
cx.latency = obj->integer.value; cx.latency = obj->integer.value;
obj = (union acpi_object *)&(element->package.elements[3]); obj = &(element->package.elements[3]);
if (obj->type != ACPI_TYPE_INTEGER) if (obj->type != ACPI_TYPE_INTEGER)
continue; continue;
...@@ -1037,7 +1037,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr) ...@@ -1037,7 +1037,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
{ {
struct acpi_processor *pr = (struct acpi_processor *)seq->private; struct acpi_processor *pr = seq->private;
unsigned int i; unsigned int i;
......
...@@ -236,7 +236,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr) ...@@ -236,7 +236,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
return -ENODEV; return -ENODEV;
} }
pss = (union acpi_object *)buffer.pointer; pss = buffer.pointer;
if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) { if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) {
printk(KERN_ERR PREFIX "Invalid _PSS data\n"); printk(KERN_ERR PREFIX "Invalid _PSS data\n");
result = -EFAULT; result = -EFAULT;
...@@ -410,7 +410,7 @@ static struct file_operations acpi_processor_perf_fops = { ...@@ -410,7 +410,7 @@ static struct file_operations acpi_processor_perf_fops = {
static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset) static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
{ {
struct acpi_processor *pr = (struct acpi_processor *)seq->private; struct acpi_processor *pr = seq->private;
int i; int i;
...@@ -451,8 +451,8 @@ acpi_processor_write_performance(struct file *file, ...@@ -451,8 +451,8 @@ acpi_processor_write_performance(struct file *file,
size_t count, loff_t * data) size_t count, loff_t * data)
{ {
int result = 0; int result = 0;
struct seq_file *m = (struct seq_file *)file->private_data; struct seq_file *m = file->private_data;
struct acpi_processor *pr = (struct acpi_processor *)m->private; struct acpi_processor *pr = m->private;
struct acpi_processor_performance *perf; struct acpi_processor_performance *perf;
char state_string[12] = { '\0' }; char state_string[12] = { '\0' };
unsigned int new_state = 0; unsigned int new_state = 0;
...@@ -551,7 +551,7 @@ static int acpi_processor_get_psd(struct acpi_processor *pr) ...@@ -551,7 +551,7 @@ static int acpi_processor_get_psd(struct acpi_processor *pr)
return -ENODEV; return -ENODEV;
} }
psd = (union acpi_object *) buffer.pointer; psd = buffer.pointer;
if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) { if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n")); ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n"));
result = -EFAULT; result = -EFAULT;
......
...@@ -208,7 +208,7 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type) ...@@ -208,7 +208,7 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
if (result) if (result)
return result; return result;
pr = (struct acpi_processor *)acpi_driver_data(device); pr = acpi_driver_data(device);
if (!pr) if (!pr)
return -ENODEV; return -ENODEV;
...@@ -348,8 +348,8 @@ static ssize_t acpi_processor_write_limit(struct file * file, ...@@ -348,8 +348,8 @@ static ssize_t acpi_processor_write_limit(struct file * file,
size_t count, loff_t * data) size_t count, loff_t * data)
{ {
int result = 0; int result = 0;
struct seq_file *m = (struct seq_file *)file->private_data; struct seq_file *m = file->private_data;
struct acpi_processor *pr = (struct acpi_processor *)m->private; struct acpi_processor *pr = m->private;
char limit_string[25] = { '\0' }; char limit_string[25] = { '\0' };
int px = 0; int px = 0;
int tx = 0; int tx = 0;
......
...@@ -259,7 +259,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) ...@@ -259,7 +259,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
static int acpi_processor_throttling_seq_show(struct seq_file *seq, static int acpi_processor_throttling_seq_show(struct seq_file *seq,
void *offset) void *offset)
{ {
struct acpi_processor *pr = (struct acpi_processor *)seq->private; struct acpi_processor *pr = seq->private;
int i = 0; int i = 0;
int result = 0; int result = 0;
...@@ -307,8 +307,8 @@ static ssize_t acpi_processor_write_throttling(struct file * file, ...@@ -307,8 +307,8 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
size_t count, loff_t * data) size_t count, loff_t * data)
{ {
int result = 0; int result = 0;
struct seq_file *m = (struct seq_file *)file->private_data; struct seq_file *m = file->private_data;
struct acpi_processor *pr = (struct acpi_processor *)m->private; struct acpi_processor *pr = m->private;
char state_string[12] = { '\0' }; char state_string[12] = { '\0' };
......
...@@ -923,7 +923,7 @@ static struct proc_dir_entry *acpi_battery_dir = NULL; ...@@ -923,7 +923,7 @@ static struct proc_dir_entry *acpi_battery_dir = NULL;
static int acpi_battery_read_info(struct seq_file *seq, void *offset) static int acpi_battery_read_info(struct seq_file *seq, void *offset)
{ {
struct acpi_battery *battery = (struct acpi_battery *)seq->private; struct acpi_battery *battery = seq->private;
int cscale; int cscale;
int result = 0; int result = 0;
...@@ -1076,7 +1076,7 @@ static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) ...@@ -1076,7 +1076,7 @@ static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
{ {
struct acpi_battery *battery = (struct acpi_battery *)seq->private; struct acpi_battery *battery = seq->private;
int result = 0; int result = 0;
int cscale; int cscale;
...@@ -1125,8 +1125,8 @@ static ssize_t ...@@ -1125,8 +1125,8 @@ static ssize_t
acpi_battery_write_alarm(struct file *file, const char __user * buffer, acpi_battery_write_alarm(struct file *file, const char __user * buffer,
size_t count, loff_t * ppos) size_t count, loff_t * ppos)
{ {
struct seq_file *seq = (struct seq_file *)file->private_data; struct seq_file *seq = file->private_data;
struct acpi_battery *battery = (struct acpi_battery *)seq->private; struct acpi_battery *battery = seq->private;
char alarm_string[12] = { '\0' }; char alarm_string[12] = { '\0' };
int result, old_alarm, new_alarm; int result, old_alarm, new_alarm;
...@@ -1160,14 +1160,14 @@ acpi_battery_write_alarm(struct file *file, const char __user * buffer, ...@@ -1160,14 +1160,14 @@ acpi_battery_write_alarm(struct file *file, const char __user * buffer,
if (result) { if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"acpi_battery_set_alarm() failed\n")); "acpi_battery_set_alarm() failed\n"));
(void)acpi_battery_set_alarm(battery, old_alarm); acpi_battery_set_alarm(battery, old_alarm);
goto end; goto end;
} }
result = acpi_battery_get_alarm(battery); result = acpi_battery_get_alarm(battery);
if (result) { if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"acpi_battery_get_alarm() failed\n")); "acpi_battery_get_alarm() failed\n"));
(void)acpi_battery_set_alarm(battery, old_alarm); acpi_battery_set_alarm(battery, old_alarm);
goto end; goto end;
} }
...@@ -1217,7 +1217,7 @@ static struct proc_dir_entry *acpi_ac_dir = NULL; ...@@ -1217,7 +1217,7 @@ static struct proc_dir_entry *acpi_ac_dir = NULL;
static int acpi_ac_read_state(struct seq_file *seq, void *offset) static int acpi_ac_read_state(struct seq_file *seq, void *offset)
{ {
struct acpi_sbs *sbs = (struct acpi_sbs *)seq->private; struct acpi_sbs *sbs = seq->private;
int result; int result;
if (sbs->zombie) { if (sbs->zombie) {
...@@ -1302,7 +1302,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) ...@@ -1302,7 +1302,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
battery->init_state = 1; battery->init_state = 1;
} }
(void)sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id); sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id);
result = acpi_sbs_generic_add_fs(&battery->battery_entry, result = acpi_sbs_generic_add_fs(&battery->battery_entry,
acpi_battery_dir, acpi_battery_dir,
...@@ -1485,7 +1485,7 @@ static int acpi_sbs_update_run(struct acpi_sbs *sbs, int data_type) ...@@ -1485,7 +1485,7 @@ static int acpi_sbs_update_run(struct acpi_sbs *sbs, int data_type)
} }
if (old_battery_present != new_battery_present) { if (old_battery_present != new_battery_present) {
(void)sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id); sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id);
result = acpi_sbs_generate_event(sbs->device, result = acpi_sbs_generate_event(sbs->device,
ACPI_SBS_BATTERY_NOTIFY_STATUS, ACPI_SBS_BATTERY_NOTIFY_STATUS,
new_battery_present, new_battery_present,
...@@ -1498,7 +1498,7 @@ static int acpi_sbs_update_run(struct acpi_sbs *sbs, int data_type) ...@@ -1498,7 +1498,7 @@ static int acpi_sbs_update_run(struct acpi_sbs *sbs, int data_type)
} }
} }
if (old_remaining_capacity != battery->state.remaining_capacity) { if (old_remaining_capacity != battery->state.remaining_capacity) {
(void)sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id); sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id);
result = acpi_sbs_generate_event(sbs->device, result = acpi_sbs_generate_event(sbs->device,
ACPI_SBS_BATTERY_NOTIFY_STATUS, ACPI_SBS_BATTERY_NOTIFY_STATUS,
new_battery_present, new_battery_present,
...@@ -1576,12 +1576,11 @@ static int acpi_sbs_add(struct acpi_device *device) ...@@ -1576,12 +1576,11 @@ static int acpi_sbs_add(struct acpi_device *device)
int id, cnt; int id, cnt;
acpi_status status = AE_OK; acpi_status status = AE_OK;
sbs = kmalloc(sizeof(struct acpi_sbs), GFP_KERNEL); sbs = kzalloc(sizeof(struct acpi_sbs), GFP_KERNEL);
if (!sbs) { if (!sbs) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "kmalloc() failed\n")); ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "kmalloc() failed\n"));
return -ENOMEM; return -ENOMEM;
} }
memset(sbs, 0, sizeof(struct acpi_sbs));
cnt = 0; cnt = 0;
while (cnt < 10) { while (cnt < 10) {
...@@ -1659,7 +1658,7 @@ static int acpi_sbs_add(struct acpi_device *device) ...@@ -1659,7 +1658,7 @@ static int acpi_sbs_add(struct acpi_device *device)
init_timer(&sbs->update_timer); init_timer(&sbs->update_timer);
if (update_mode == QUEUE_UPDATE_MODE) { if (update_mode == QUEUE_UPDATE_MODE) {
status = acpi_os_execute(OSL_GPE_HANDLER, status = acpi_os_execute(OSL_GPE_HANDLER,
acpi_sbs_update_queue, (void *)sbs); acpi_sbs_update_queue, sbs);
if (status != AE_OK) { if (status != AE_OK) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"acpi_os_execute() failed\n")); "acpi_os_execute() failed\n"));
...@@ -1685,7 +1684,7 @@ static int acpi_sbs_add(struct acpi_device *device) ...@@ -1685,7 +1684,7 @@ static int acpi_sbs_add(struct acpi_device *device)
int acpi_sbs_remove(struct acpi_device *device, int type) int acpi_sbs_remove(struct acpi_device *device, int type)
{ {
struct acpi_sbs *sbs = NULL; struct acpi_sbs *sbs;
int id; int id;
if (!device) { if (!device) {
......
...@@ -984,12 +984,11 @@ acpi_add_single_object(struct acpi_device **child, ...@@ -984,12 +984,11 @@ acpi_add_single_object(struct acpi_device **child,
if (!child) if (!child)
return -EINVAL; return -EINVAL;
device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL); device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL);
if (!device) { if (!device) {
printk(KERN_ERR PREFIX "Memory allocation error\n"); printk(KERN_ERR PREFIX "Memory allocation error\n");
return -ENOMEM; return -ENOMEM;
} }
memset(device, 0, sizeof(struct acpi_device));
device->handle = handle; device->handle = handle;
device->parent = parent; device->parent = parent;
......
...@@ -183,11 +183,11 @@ late_initcall(acpi_wakeup_device_init); ...@@ -183,11 +183,11 @@ late_initcall(acpi_wakeup_device_init);
#endif #endif
/* /*
* Disable all wakeup GPEs before power off. * Disable all wakeup GPEs before entering requested sleep state.
* * @sleep_state: ACPI state
* Since acpi_enter_sleep_state() will disable all * Since acpi_enter_sleep_state() will disable all
* RUNTIME GPEs, we simply mark all GPES that * RUNTIME GPEs, we simply mark all GPES that
* are not enabled for wakeup from S5 as RUNTIME. * are not enabled for wakeup from requested state as RUNTIME.
*/ */
void acpi_gpe_sleep_prepare(u32 sleep_state) void acpi_gpe_sleep_prepare(u32 sleep_state)
{ {
......
...@@ -228,7 +228,7 @@ void acpi_table_print_madt_entry(acpi_table_entry_header * header) ...@@ -228,7 +228,7 @@ void acpi_table_print_madt_entry(acpi_table_entry_header * header)
static int static int
acpi_table_compute_checksum(void *table_pointer, unsigned long length) acpi_table_compute_checksum(void *table_pointer, unsigned long length)
{ {
u8 *p = (u8 *) table_pointer; u8 *p = table_pointer;
unsigned long remains = length; unsigned long remains = length;
unsigned long sum = 0; unsigned long sum = 0;
......
...@@ -123,7 +123,6 @@ acpi_status acpi_load_tables(void) ...@@ -123,7 +123,6 @@ acpi_status acpi_load_tables(void)
ACPI_EXPORT_SYMBOL(acpi_load_tables) ACPI_EXPORT_SYMBOL(acpi_load_tables)
#ifdef ACPI_FUTURE_USAGE
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_load_table * FUNCTION: acpi_load_table
...@@ -219,6 +218,59 @@ acpi_status acpi_load_table(struct acpi_table_header *table_ptr) ...@@ -219,6 +218,59 @@ acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
ACPI_EXPORT_SYMBOL(acpi_load_table) ACPI_EXPORT_SYMBOL(acpi_load_table)
/*******************************************************************************
*
* FUNCTION: acpi_unload_table_id
*
* PARAMETERS: table_type - Type of table to be unloaded
* id - Owner ID of the table to be removed.
*
* RETURN: Status
*
* DESCRIPTION: This routine is used to force the unload of a table (by id)
*
******************************************************************************/
acpi_status acpi_unload_table_id(acpi_table_type table_type, acpi_owner_id id)
{
struct acpi_table_desc *table_desc;
acpi_status status;
ACPI_FUNCTION_TRACE(acpi_unload_table);
/* Parameter validation */
if (table_type > ACPI_TABLE_ID_MAX)
return_ACPI_STATUS(AE_BAD_PARAMETER);
/* Find table from the requested type list */
table_desc = acpi_gbl_table_lists[table_type].next;
while (table_desc && table_desc->owner_id != id)
table_desc = table_desc->next;
if (!table_desc)
return_ACPI_STATUS(AE_NOT_EXIST);
/*
* Delete all namespace objects owned by this table. Note that these
* objects can appear anywhere in the namespace by virtue of the AML
* "Scope" operator. Thus, we need to track ownership by an ID, not
* simply a position within the hierarchy
*/
acpi_ns_delete_namespace_by_owner(table_desc->owner_id);
status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
if (ACPI_FAILURE(status))
return_ACPI_STATUS(status);
(void)acpi_tb_uninstall_table(table_desc);
(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
return_ACPI_STATUS(AE_OK);
}
ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
#ifdef ACPI_FUTURE_USAGE
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_unload_table * FUNCTION: acpi_unload_table
......
...@@ -663,7 +663,7 @@ static void acpi_thermal_run(unsigned long data) ...@@ -663,7 +663,7 @@ static void acpi_thermal_run(unsigned long data)
static void acpi_thermal_check(void *data) static void acpi_thermal_check(void *data)
{ {
int result = 0; int result = 0;
struct acpi_thermal *tz = (struct acpi_thermal *)data; struct acpi_thermal *tz = data;
unsigned long sleep_time = 0; unsigned long sleep_time = 0;
int i = 0; int i = 0;
struct acpi_thermal_state state; struct acpi_thermal_state state;
...@@ -778,7 +778,7 @@ static struct proc_dir_entry *acpi_thermal_dir; ...@@ -778,7 +778,7 @@ static struct proc_dir_entry *acpi_thermal_dir;
static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
{ {
struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; struct acpi_thermal *tz = seq->private;
if (!tz) if (!tz)
...@@ -813,7 +813,7 @@ static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file) ...@@ -813,7 +813,7 @@ static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file)
static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset) static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
{ {
int result = 0; int result = 0;
struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; struct acpi_thermal *tz = seq->private;
if (!tz) if (!tz)
...@@ -837,7 +837,7 @@ static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file) ...@@ -837,7 +837,7 @@ static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file)
static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset) static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
{ {
struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; struct acpi_thermal *tz = seq->private;
int i = 0; int i = 0;
int j = 0; int j = 0;
...@@ -893,8 +893,8 @@ acpi_thermal_write_trip_points(struct file *file, ...@@ -893,8 +893,8 @@ acpi_thermal_write_trip_points(struct file *file,
const char __user * buffer, const char __user * buffer,
size_t count, loff_t * ppos) size_t count, loff_t * ppos)
{ {
struct seq_file *m = (struct seq_file *)file->private_data; struct seq_file *m = file->private_data;
struct acpi_thermal *tz = (struct acpi_thermal *)m->private; struct acpi_thermal *tz = m->private;
char *limit_string; char *limit_string;
int num, critical, hot, passive; int num, critical, hot, passive;
...@@ -902,12 +902,10 @@ acpi_thermal_write_trip_points(struct file *file, ...@@ -902,12 +902,10 @@ acpi_thermal_write_trip_points(struct file *file,
int i = 0; int i = 0;
limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); limit_string = kzalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL);
if (!limit_string) if (!limit_string)
return -ENOMEM; return -ENOMEM;
memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN);
active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL); active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL);
if (!active) { if (!active) {
kfree(limit_string); kfree(limit_string);
...@@ -953,7 +951,7 @@ acpi_thermal_write_trip_points(struct file *file, ...@@ -953,7 +951,7 @@ acpi_thermal_write_trip_points(struct file *file,
static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
{ {
struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; struct acpi_thermal *tz = seq->private;
if (!tz) if (!tz)
...@@ -984,8 +982,8 @@ acpi_thermal_write_cooling_mode(struct file *file, ...@@ -984,8 +982,8 @@ acpi_thermal_write_cooling_mode(struct file *file,
const char __user * buffer, const char __user * buffer,
size_t count, loff_t * ppos) size_t count, loff_t * ppos)
{ {
struct seq_file *m = (struct seq_file *)file->private_data; struct seq_file *m = file->private_data;
struct acpi_thermal *tz = (struct acpi_thermal *)m->private; struct acpi_thermal *tz = m->private;
int result = 0; int result = 0;
char mode_string[12] = { '\0' }; char mode_string[12] = { '\0' };
...@@ -1014,7 +1012,7 @@ acpi_thermal_write_cooling_mode(struct file *file, ...@@ -1014,7 +1012,7 @@ acpi_thermal_write_cooling_mode(struct file *file,
static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
{ {
struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; struct acpi_thermal *tz = seq->private;
if (!tz) if (!tz)
...@@ -1043,8 +1041,8 @@ acpi_thermal_write_polling(struct file *file, ...@@ -1043,8 +1041,8 @@ acpi_thermal_write_polling(struct file *file,
const char __user * buffer, const char __user * buffer,
size_t count, loff_t * ppos) size_t count, loff_t * ppos)
{ {
struct seq_file *m = (struct seq_file *)file->private_data; struct seq_file *m = file->private_data;
struct acpi_thermal *tz = (struct acpi_thermal *)m->private; struct acpi_thermal *tz = m->private;
int result = 0; int result = 0;
char polling_string[12] = { '\0' }; char polling_string[12] = { '\0' };
int seconds = 0; int seconds = 0;
...@@ -1170,7 +1168,7 @@ static int acpi_thermal_remove_fs(struct acpi_device *device) ...@@ -1170,7 +1168,7 @@ static int acpi_thermal_remove_fs(struct acpi_device *device)
static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
{ {
struct acpi_thermal *tz = (struct acpi_thermal *)data; struct acpi_thermal *tz = data;
struct acpi_device *device = NULL; struct acpi_device *device = NULL;
...@@ -1271,10 +1269,9 @@ static int acpi_thermal_add(struct acpi_device *device) ...@@ -1271,10 +1269,9 @@ static int acpi_thermal_add(struct acpi_device *device)
if (!device) if (!device)
return -EINVAL; return -EINVAL;
tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL); tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
if (!tz) if (!tz)
return -ENOMEM; return -ENOMEM;
memset(tz, 0, sizeof(struct acpi_thermal));
tz->device = device; tz->device = device;
strcpy(tz->name, device->pnp.bus_id); strcpy(tz->name, device->pnp.bus_id);
...@@ -1324,7 +1321,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type) ...@@ -1324,7 +1321,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
tz = (struct acpi_thermal *)acpi_driver_data(device); tz = acpi_driver_data(device);
/* avoid timer adding new defer task */ /* avoid timer adding new defer task */
tz->zombie = 1; tz->zombie = 1;
...@@ -1364,7 +1361,7 @@ static int acpi_thermal_resume(struct acpi_device *device, int state) ...@@ -1364,7 +1361,7 @@ static int acpi_thermal_resume(struct acpi_device *device, int state)
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
tz = (struct acpi_thermal *)acpi_driver_data(device); tz = acpi_driver_data(device);
acpi_thermal_get_temperature(tz); acpi_thermal_get_temperature(tz);
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/backlight.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <acpi/acpi_drivers.h> #include <acpi/acpi_drivers.h>
...@@ -210,6 +212,7 @@ static acpi_status hci_read1(u32 reg, u32 * out1, u32 * result) ...@@ -210,6 +212,7 @@ static acpi_status hci_read1(u32 reg, u32 * out1, u32 * result)
} }
static struct proc_dir_entry *toshiba_proc_dir /*= 0*/ ; static struct proc_dir_entry *toshiba_proc_dir /*= 0*/ ;
static struct backlight_device *toshiba_backlight_device;
static int force_fan; static int force_fan;
static int last_key_event; static int last_key_event;
static int key_event_valid; static int key_event_valid;
...@@ -271,14 +274,23 @@ dispatch_write(struct file *file, const char __user * buffer, ...@@ -271,14 +274,23 @@ dispatch_write(struct file *file, const char __user * buffer,
return result; return result;
} }
static char *read_lcd(char *p) static int get_lcd(struct backlight_device *bd)
{ {
u32 hci_result; u32 hci_result;
u32 value; u32 value;
hci_read1(HCI_LCD_BRIGHTNESS, &value, &hci_result); hci_read1(HCI_LCD_BRIGHTNESS, &value, &hci_result);
if (hci_result == HCI_SUCCESS) { if (hci_result == HCI_SUCCESS) {
value = value >> HCI_LCD_BRIGHTNESS_SHIFT; return (value >> HCI_LCD_BRIGHTNESS_SHIFT);
} else
return -EFAULT;
}
static char *read_lcd(char *p)
{
int value = get_lcd(NULL);
if (value >= 0) {
p += sprintf(p, "brightness: %d\n", value); p += sprintf(p, "brightness: %d\n", value);
p += sprintf(p, "brightness_levels: %d\n", p += sprintf(p, "brightness_levels: %d\n",
HCI_LCD_BRIGHTNESS_LEVELS); HCI_LCD_BRIGHTNESS_LEVELS);
...@@ -289,22 +301,34 @@ static char *read_lcd(char *p) ...@@ -289,22 +301,34 @@ static char *read_lcd(char *p)
return p; return p;
} }
static int set_lcd(int value)
{
u32 hci_result;
value = value << HCI_LCD_BRIGHTNESS_SHIFT;
hci_write1(HCI_LCD_BRIGHTNESS, value, &hci_result);
if (hci_result != HCI_SUCCESS)
return -EFAULT;
return 0;
}
static int set_lcd_status(struct backlight_device *bd)
{
return set_lcd(bd->props->brightness);
}
static unsigned long write_lcd(const char *buffer, unsigned long count) static unsigned long write_lcd(const char *buffer, unsigned long count)
{ {
int value; int value;
u32 hci_result; int ret = count;
if (sscanf(buffer, " brightness : %i", &value) == 1 && if (sscanf(buffer, " brightness : %i", &value) == 1 &&
value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS) { value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS)
value = value << HCI_LCD_BRIGHTNESS_SHIFT; ret = set_lcd(value);
hci_write1(HCI_LCD_BRIGHTNESS, value, &hci_result); else
if (hci_result != HCI_SUCCESS) ret = -EINVAL;
return -EFAULT; return ret;
} else {
return -EINVAL;
}
return count;
} }
static char *read_video(char *p) static char *read_video(char *p)
...@@ -506,6 +530,26 @@ static acpi_status __exit remove_device(void) ...@@ -506,6 +530,26 @@ static acpi_status __exit remove_device(void)
return AE_OK; return AE_OK;
} }
static struct backlight_properties toshiba_backlight_data = {
.owner = THIS_MODULE,
.get_brightness = get_lcd,
.update_status = set_lcd_status,
.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1,
};
static void __exit toshiba_acpi_exit(void)
{
if (toshiba_backlight_device)
backlight_device_unregister(toshiba_backlight_device);
remove_device();
if (toshiba_proc_dir)
remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
return;
}
static int __init toshiba_acpi_init(void) static int __init toshiba_acpi_init(void)
{ {
acpi_status status = AE_OK; acpi_status status = AE_OK;
...@@ -546,17 +590,16 @@ static int __init toshiba_acpi_init(void) ...@@ -546,17 +590,16 @@ static int __init toshiba_acpi_init(void)
remove_proc_entry(PROC_TOSHIBA, acpi_root_dir); remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
} }
return (ACPI_SUCCESS(status)) ? 0 : -ENODEV; toshiba_backlight_device = backlight_device_register("toshiba",NULL,
} NULL,
&toshiba_backlight_data);
static void __exit toshiba_acpi_exit(void) if (IS_ERR(toshiba_backlight_device)) {
{ printk(KERN_ERR "Could not register toshiba backlight device\n");
remove_device(); toshiba_backlight_device = NULL;
toshiba_acpi_exit();
if (toshiba_proc_dir) }
remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
return; return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
} }
module_init(toshiba_acpi_init); module_init(toshiba_acpi_init);
......
...@@ -180,8 +180,9 @@ acpi_ut_debug_print(u32 requested_debug_level, ...@@ -180,8 +180,9 @@ acpi_ut_debug_print(u32 requested_debug_level,
if (thread_id != acpi_gbl_prev_thread_id) { if (thread_id != acpi_gbl_prev_thread_id) {
if (ACPI_LV_THREADS & acpi_dbg_level) { if (ACPI_LV_THREADS & acpi_dbg_level) {
acpi_os_printf acpi_os_printf
("\n**** Context Switch from TID %X to TID %X ****\n\n", ("\n**** Context Switch from TID %lX to TID %lX ****\n\n",
(u32) acpi_gbl_prev_thread_id, (u32) thread_id); (unsigned long) acpi_gbl_prev_thread_id,
(unsigned long) thread_id);
} }
acpi_gbl_prev_thread_id = thread_id; acpi_gbl_prev_thread_id = thread_id;
......
...@@ -243,23 +243,24 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) ...@@ -243,23 +243,24 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
#endif #endif
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
"Thread %X attempting to acquire Mutex [%s]\n", "Thread %lX attempting to acquire Mutex [%s]\n",
(u32) this_thread_id, acpi_ut_get_mutex_name(mutex_id))); (unsigned long) this_thread_id,
acpi_ut_get_mutex_name(mutex_id)));
status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex, status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex,
ACPI_WAIT_FOREVER); ACPI_WAIT_FOREVER);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
"Thread %X acquired Mutex [%s]\n", "Thread %lX acquired Mutex [%s]\n",
(u32) this_thread_id, (unsigned long) this_thread_id,
acpi_ut_get_mutex_name(mutex_id))); acpi_ut_get_mutex_name(mutex_id)));
acpi_gbl_mutex_info[mutex_id].use_count++; acpi_gbl_mutex_info[mutex_id].use_count++;
acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id;
} else { } else {
ACPI_EXCEPTION((AE_INFO, status, ACPI_EXCEPTION((AE_INFO, status,
"Thread %X could not acquire Mutex [%X]", "Thread %lX could not acquire Mutex [%X]",
(u32) this_thread_id, mutex_id)); (unsigned long) this_thread_id, mutex_id));
} }
return (status); return (status);
...@@ -285,7 +286,8 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) ...@@ -285,7 +286,8 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
this_thread_id = acpi_os_get_thread_id(); this_thread_id = acpi_os_get_thread_id();
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
"Thread %X releasing Mutex [%s]\n", (u32) this_thread_id, "Thread %lX releasing Mutex [%s]\n",
(unsigned long) this_thread_id,
acpi_ut_get_mutex_name(mutex_id))); acpi_ut_get_mutex_name(mutex_id)));
if (mutex_id > ACPI_MAX_MUTEX) { if (mutex_id > ACPI_MAX_MUTEX) {
......
...@@ -83,7 +83,7 @@ acpi_extract_package(union acpi_object *package, ...@@ -83,7 +83,7 @@ acpi_extract_package(union acpi_object *package,
return AE_BAD_DATA; return AE_BAD_DATA;
} }
format_string = (char *)format->pointer; format_string = format->pointer;
/* /*
* Calculate size_required. * Calculate size_required.
...@@ -262,11 +262,10 @@ acpi_evaluate_integer(acpi_handle handle, ...@@ -262,11 +262,10 @@ acpi_evaluate_integer(acpi_handle handle,
if (!data) if (!data)
return AE_BAD_PARAMETER; return AE_BAD_PARAMETER;
element = kmalloc(sizeof(union acpi_object), irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL); element = kzalloc(sizeof(union acpi_object), irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL);
if (!element) if (!element)
return AE_NO_MEMORY; return AE_NO_MEMORY;
memset(element, 0, sizeof(union acpi_object));
buffer.length = sizeof(union acpi_object); buffer.length = sizeof(union acpi_object);
buffer.pointer = element; buffer.pointer = element;
status = acpi_evaluate_object(handle, pathname, arguments, &buffer); status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
...@@ -321,12 +320,11 @@ acpi_evaluate_string(acpi_handle handle, ...@@ -321,12 +320,11 @@ acpi_evaluate_string(acpi_handle handle,
return AE_BAD_DATA; return AE_BAD_DATA;
} }
*data = kmalloc(element->string.length + 1, GFP_KERNEL); *data = kzalloc(element->string.length + 1, GFP_KERNEL);
if (!data) { if (!data) {
printk(KERN_ERR PREFIX "Memory allocation\n"); printk(KERN_ERR PREFIX "Memory allocation\n");
return -ENOMEM; return -ENOMEM;
} }
memset(*data, 0, element->string.length + 1);
memcpy(*data, element->string.pointer, element->string.length); memcpy(*data, element->string.pointer, element->string.length);
...@@ -361,7 +359,7 @@ acpi_evaluate_reference(acpi_handle handle, ...@@ -361,7 +359,7 @@ acpi_evaluate_reference(acpi_handle handle,
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
goto end; goto end;
package = (union acpi_object *)buffer.pointer; package = buffer.pointer;
if ((buffer.length == 0) || !package) { if ((buffer.length == 0) || !package) {
printk(KERN_ERR PREFIX "No return object (len %X ptr %p)\n", printk(KERN_ERR PREFIX "No return object (len %X ptr %p)\n",
......
This diff is collapsed.
...@@ -317,7 +317,8 @@ static int __init msi_init(void) ...@@ -317,7 +317,8 @@ static int __init msi_init(void)
/* Register backlight stuff */ /* Register backlight stuff */
msibl_device = backlight_device_register("msi-laptop-bl", NULL, &msibl_props); msibl_device = backlight_device_register("msi-laptop-bl", NULL, NULL,
&msibl_props);
if (IS_ERR(msibl_device)) if (IS_ERR(msibl_device))
return PTR_ERR(msibl_device); return PTR_ERR(msibl_device);
......
...@@ -319,13 +319,12 @@ static int ibm_get_table_from_acpi(char **bufp) ...@@ -319,13 +319,12 @@ static int ibm_get_table_from_acpi(char **bufp)
if (bufp == NULL) if (bufp == NULL)
goto read_table_done; goto read_table_done;
lbuf = kmalloc(size, GFP_KERNEL); lbuf = kzalloc(size, GFP_KERNEL);
dbg("%s: element count: %i, ASL table size: %i, &table = 0x%p\n", dbg("%s: element count: %i, ASL table size: %i, &table = 0x%p\n",
__FUNCTION__, package->package.count, size, lbuf); __FUNCTION__, package->package.count, size, lbuf);
if (lbuf) { if (lbuf) {
*bufp = lbuf; *bufp = lbuf;
memset(lbuf, 0, size);
} else { } else {
size = -ENOMEM; size = -ENOMEM;
goto read_table_done; goto read_table_done;
......
...@@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface, ...@@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
/* Register backlight device */ /* Register backlight device */
snprintf(bl_name, sizeof(bl_name), "appledisplay%d", snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
atomic_inc_return(&count_displays) - 1); atomic_inc_return(&count_displays) - 1);
pdata->bd = backlight_device_register(bl_name, pdata, pdata->bd = backlight_device_register(bl_name, NULL, NULL,
&appledisplay_bl_data); &appledisplay_bl_data);
if (IS_ERR(pdata->bd)) { if (IS_ERR(pdata->bd)) {
err("appledisplay: Backlight registration failed"); err("appledisplay: Backlight registration failed");
......
...@@ -1834,7 +1834,7 @@ static void aty128_bl_init(struct aty128fb_par *par) ...@@ -1834,7 +1834,7 @@ static void aty128_bl_init(struct aty128fb_par *par)
snprintf(name, sizeof(name), "aty128bl%d", info->node); snprintf(name, sizeof(name), "aty128bl%d", info->node);
bd = backlight_device_register(name, par, &aty128_bl_data); bd = backlight_device_register(name, info->dev, par, &aty128_bl_data);
if (IS_ERR(bd)) { if (IS_ERR(bd)) {
info->bl_dev = NULL; info->bl_dev = NULL;
printk(KERN_WARNING "aty128: Backlight registration failed\n"); printk(KERN_WARNING "aty128: Backlight registration failed\n");
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment