Commit f615f385 authored by Andy Grover's avatar Andy Grover

Code cleanups

1) Eliminate everywhere "if (0 == result)" is used, replace with
"if (!result)" and the like.

2) Move headers mysteriously included in the middle of the file to the top.
parent 45361bde
/* /*
* acpi_ac.c - ACPI AC Adapter Driver ($Revision: 23 $) * acpi_ac.c - ACPI AC Adapter Driver ($Revision: 26 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include "acpi_bus.h" #include "acpi_bus.h"
#include "acpi_drivers.h" #include "acpi_drivers.h"
...@@ -91,9 +93,6 @@ acpi_ac_get_state ( ...@@ -91,9 +93,6 @@ acpi_ac_get_state (
FS Interface (/proc) FS Interface (/proc)
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
struct proc_dir_entry *acpi_ac_dir = NULL; struct proc_dir_entry *acpi_ac_dir = NULL;
static int static int
...@@ -114,7 +113,7 @@ acpi_ac_read_state ( ...@@ -114,7 +113,7 @@ acpi_ac_read_state (
if (!ac || (off != 0)) if (!ac || (off != 0))
goto end; goto end;
if (0 != acpi_ac_get_state(ac)) { if (acpi_ac_get_state(ac)) {
p += sprintf(p, "ERROR: Unable to read AC Adapter state\n"); p += sprintf(p, "ERROR: Unable to read AC Adapter state\n");
goto end; goto end;
} }
...@@ -215,7 +214,7 @@ acpi_ac_notify ( ...@@ -215,7 +214,7 @@ acpi_ac_notify (
if (!ac) if (!ac)
return; return;
if (0 != acpi_bus_get_device(ac->handle, &device)) if (acpi_bus_get_device(ac->handle, &device))
return_VOID; return_VOID;
switch (event) { switch (event) {
...@@ -257,11 +256,11 @@ acpi_ac_add ( ...@@ -257,11 +256,11 @@ acpi_ac_add (
acpi_driver_data(device) = ac; acpi_driver_data(device) = ac;
result = acpi_ac_get_state(ac); result = acpi_ac_get_state(ac);
if (0 != result) if (result)
goto end; goto end;
result = acpi_ac_add_fs(device); result = acpi_ac_add_fs(device);
if (0 != result) if (result)
goto end; goto end;
status = acpi_install_notify_handler(ac->handle, status = acpi_install_notify_handler(ac->handle,
...@@ -278,7 +277,7 @@ acpi_ac_add ( ...@@ -278,7 +277,7 @@ acpi_ac_add (
ac->state?"on-line":"off-line"); ac->state?"on-line":"off-line");
end: end:
if (0 != result) { if (result) {
acpi_ac_remove_fs(device); acpi_ac_remove_fs(device);
kfree(ac); kfree(ac);
} }
...@@ -324,7 +323,7 @@ acpi_ac_init (void) ...@@ -324,7 +323,7 @@ acpi_ac_init (void)
ACPI_FUNCTION_TRACE("acpi_ac_init"); ACPI_FUNCTION_TRACE("acpi_ac_init");
result = acpi_bus_register_driver(&acpi_ac_driver); result = acpi_bus_register_driver(&acpi_ac_driver);
if (0 > result) { if (result < 0) {
remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
} }
...@@ -341,7 +340,7 @@ acpi_ac_exit (void) ...@@ -341,7 +340,7 @@ acpi_ac_exit (void)
ACPI_FUNCTION_TRACE("acpi_ac_exit"); ACPI_FUNCTION_TRACE("acpi_ac_exit");
result = acpi_bus_unregister_driver(&acpi_ac_driver); result = acpi_bus_unregister_driver(&acpi_ac_driver);
if (0 == result) if (!result)
remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
return_VOID; return_VOID;
......
/* /*
* acpi_bus.h - ACPI Bus Driver ($Revision: 19 $) * acpi_bus.h - ACPI Bus Driver ($Revision: 21 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -56,9 +56,7 @@ acpi_status acpi_evaluate_reference (acpi_handle, acpi_string, acpi_object_list ...@@ -56,9 +56,7 @@ acpi_status acpi_evaluate_reference (acpi_handle, acpi_string, acpi_object_list
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#define ACPI_BUS_FILE_ROOT "acpi" #define ACPI_BUS_FILE_ROOT "acpi"
extern struct proc_dir_entry *acpi_root_dir; extern struct proc_dir_entry *acpi_root_dir;
extern FADT_DESCRIPTOR acpi_fadt; extern FADT_DESCRIPTOR acpi_fadt;
enum acpi_bus_removal_type { enum acpi_bus_removal_type {
......
/* /*
* acpi_drivers.h ($Revision: 23 $) * acpi_drivers.h ($Revision: 29 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "acpi_bus.h" #include "acpi_bus.h"
#define ACPI_DRIVER_VERSION 0x20020404
#define ACPI_MAX_STRING 80 #define ACPI_MAX_STRING 80
...@@ -148,41 +147,53 @@ void acpi_ec_exit (void); ...@@ -148,41 +147,53 @@ void acpi_ec_exit (void);
PCI PCI
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#define ACPI_PCI_LINK_COMPONENT 0x00400000 #ifdef CONFIG_ACPI_PCI
#define ACPI_PCI_LINK_CLASS "irq_routing"
#define ACPI_PCI_LINK_HID "PNP0C0F"
#define ACPI_PCI_LINK_DRIVER_NAME "ACPI PCI Interrupt Link Driver"
#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link"
#define ACPI_PCI_LINK_FILE_INFO "info"
#define ACPI_PCI_LINK_FILE_STATUS "state"
#define ACPI_PCI_ROOT_COMPONENT 0x00800000 #define ACPI_PCI_COMPONENT 0x00400000
#define ACPI_PCI_ROOT_CLASS "bridge"
/* ACPI PCI Root Bridge (pci_root.c) */
#define ACPI_PCI_ROOT_CLASS "pci_bridge"
#define ACPI_PCI_ROOT_HID "PNP0A03" #define ACPI_PCI_ROOT_HID "PNP0A03"
#define ACPI_PCI_ROOT_DRIVER_NAME "ACPI PCI Root Bridge Driver" #define ACPI_PCI_ROOT_DRIVER_NAME "ACPI PCI Root Bridge Driver"
#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" #define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge"
#define ACPI_PCI_PRT_DEVICE_NAME "PCI Interrupt Routing Table" int acpi_pci_root_init (void);
void acpi_pci_root_exit (void);
#ifdef CONFIG_ACPI_PCI /* ACPI PCI Interrupt Link (pci_link.c) */
#define ACPI_PCI_LINK_CLASS "pci_irq_routing"
#define ACPI_PCI_LINK_HID "PNP0C0F"
#define ACPI_PCI_LINK_DRIVER_NAME "ACPI PCI Interrupt Link Driver"
#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link"
#define ACPI_PCI_LINK_FILE_INFO "info"
#define ACPI_PCI_LINK_FILE_STATUS "state"
int acpi_pci_link_get_irq (struct acpi_prt_entry *entry, int *irq); int acpi_pci_link_check (void);
int acpi_pci_link_set_irq (struct acpi_prt_entry *entry, int irq); int acpi_pci_link_get_irq (acpi_handle handle, int index);
int acpi_pci_link_init (void); int acpi_pci_link_init (void);
void acpi_pci_link_exit (void); void acpi_pci_link_exit (void);
int acpi_pci_root_init (void); /* ACPI PCI Interrupt Routing (pci_irq.c) */
void acpi_pci_root_exit (void);
#endif int acpi_pci_irq_add_prt (acpi_handle handle, int segment, int bus);
/* ACPI PCI Device Binding (pci_bind.c) */
struct pci_bus;
int acpi_pci_bind (struct acpi_device *device);
int acpi_pci_bind_root (struct acpi_device *device, acpi_pci_id *id, struct pci_bus *bus);
#endif /*CONFIG_ACPI_PCI*/
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Power Resource Power Resource
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#define ACPI_POWER_COMPONENT 0x01000000 #define ACPI_POWER_COMPONENT 0x00800000
#define ACPI_POWER_CLASS "power_resource" #define ACPI_POWER_CLASS "power_resource"
#define ACPI_POWER_HID "ACPI_PWR" #define ACPI_POWER_HID "ACPI_PWR"
#define ACPI_POWER_DRIVER_NAME "ACPI Power Resource Driver" #define ACPI_POWER_DRIVER_NAME "ACPI Power Resource Driver"
...@@ -207,7 +218,7 @@ void acpi_power_exit (void); ...@@ -207,7 +218,7 @@ void acpi_power_exit (void);
Processor Processor
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#define ACPI_PROCESSOR_COMPONENT 0x02000000 #define ACPI_PROCESSOR_COMPONENT 0x01000000
#define ACPI_PROCESSOR_CLASS "processor" #define ACPI_PROCESSOR_CLASS "processor"
#define ACPI_PROCESSOR_HID "ACPI_CPU" #define ACPI_PROCESSOR_HID "ACPI_CPU"
#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" #define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver"
...@@ -230,7 +241,7 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type); ...@@ -230,7 +241,7 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type);
System System
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#define ACPI_SYSTEM_COMPONENT 0x04000000 #define ACPI_SYSTEM_COMPONENT 0x02000000
#define ACPI_SYSTEM_CLASS "system" #define ACPI_SYSTEM_CLASS "system"
#define ACPI_SYSTEM_HID "ACPI_SYS" #define ACPI_SYSTEM_HID "ACPI_SYS"
#define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver" #define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver"
...@@ -256,7 +267,7 @@ void acpi_system_exit (void); ...@@ -256,7 +267,7 @@ void acpi_system_exit (void);
Thermal Zone Thermal Zone
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#define ACPI_THERMAL_COMPONENT 0x08000000 #define ACPI_THERMAL_COMPONENT 0x04000000
#define ACPI_THERMAL_CLASS "thermal_zone" #define ACPI_THERMAL_CLASS "thermal_zone"
#define ACPI_THERMAL_HID "ACPI_THM" #define ACPI_THERMAL_HID "ACPI_THM"
#define ACPI_THERMAL_DRIVER_NAME "ACPI Thermal Zone Driver" #define ACPI_THERMAL_DRIVER_NAME "ACPI Thermal Zone Driver"
......
/* /*
* acpi_ksyms.c - ACPI Kernel Symbols ($Revision: 13 $) * acpi_ksyms.c - ACPI Kernel Symbols ($Revision: 15 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -80,9 +80,9 @@ EXPORT_SYMBOL(acpi_disable_event); ...@@ -80,9 +80,9 @@ EXPORT_SYMBOL(acpi_disable_event);
EXPORT_SYMBOL(acpi_clear_event); EXPORT_SYMBOL(acpi_clear_event);
EXPORT_SYMBOL(acpi_get_timer_duration); EXPORT_SYMBOL(acpi_get_timer_duration);
EXPORT_SYMBOL(acpi_get_timer); EXPORT_SYMBOL(acpi_get_timer);
EXPORT_SYMBOL(acpi_hw_get_sleep_type_data); EXPORT_SYMBOL(acpi_get_sleep_type_data);
EXPORT_SYMBOL(acpi_hw_bit_register_read); EXPORT_SYMBOL(acpi_get_register);
EXPORT_SYMBOL(acpi_hw_bit_register_write); EXPORT_SYMBOL(acpi_set_register);
EXPORT_SYMBOL(acpi_enter_sleep_state); EXPORT_SYMBOL(acpi_enter_sleep_state);
EXPORT_SYMBOL(acpi_get_system_info); EXPORT_SYMBOL(acpi_get_system_info);
......
/* /*
* acpi_battery.c - ACPI Battery Driver ($Revision: 32 $) * acpi_battery.c - ACPI Battery Driver ($Revision: 35 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include "acpi_bus.h" #include "acpi_bus.h"
#include "acpi_drivers.h" #include "acpi_drivers.h"
...@@ -162,7 +164,7 @@ acpi_battery_get_info ( ...@@ -162,7 +164,7 @@ acpi_battery_get_info (
end: end:
kfree(buffer.pointer); kfree(buffer.pointer);
if (0 == result) if (!result)
(*bif) = (struct acpi_battery_info *) data.pointer; (*bif) = (struct acpi_battery_info *) data.pointer;
return_VALUE(result); return_VALUE(result);
...@@ -223,7 +225,7 @@ acpi_battery_get_status ( ...@@ -223,7 +225,7 @@ acpi_battery_get_status (
end: end:
kfree(buffer.pointer); kfree(buffer.pointer);
if (0 == result) if (!result)
(*bst) = (struct acpi_battery_status *) data.pointer; (*bst) = (struct acpi_battery_status *) data.pointer;
return_VALUE(result); return_VALUE(result);
...@@ -277,11 +279,11 @@ acpi_battery_check ( ...@@ -277,11 +279,11 @@ acpi_battery_check (
return_VALUE(-EINVAL); return_VALUE(-EINVAL);
result = acpi_bus_get_device(battery->handle, &device); result = acpi_bus_get_device(battery->handle, &device);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
result = acpi_bus_get_status(device); result = acpi_bus_get_status(device);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
/* Insertion? */ /* Insertion? */
...@@ -293,7 +295,7 @@ acpi_battery_check ( ...@@ -293,7 +295,7 @@ acpi_battery_check (
/* Evalute _BIF to get certain static information */ /* Evalute _BIF to get certain static information */
result = acpi_battery_get_info(battery, &bif); result = acpi_battery_get_info(battery, &bif);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
battery->flags.power_unit = bif->power_unit; battery->flags.power_unit = bif->power_unit;
...@@ -326,9 +328,6 @@ acpi_battery_check ( ...@@ -326,9 +328,6 @@ acpi_battery_check (
FS Interface (/proc) FS Interface (/proc)
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
struct proc_dir_entry *acpi_battery_dir = NULL; struct proc_dir_entry *acpi_battery_dir = NULL;
static int static int
...@@ -362,7 +361,7 @@ acpi_battery_read_info ( ...@@ -362,7 +361,7 @@ acpi_battery_read_info (
/* Battery Info (_BIF) */ /* Battery Info (_BIF) */
result = acpi_battery_get_info(battery, &bif); result = acpi_battery_get_info(battery, &bif);
if ((0 != result) || !bif) { if (result || !bif) {
p += sprintf(p, "ERROR: Unable to read battery information\n"); p += sprintf(p, "ERROR: Unable to read battery information\n");
goto end; goto end;
} }
...@@ -465,7 +464,7 @@ acpi_battery_read_state ( ...@@ -465,7 +464,7 @@ acpi_battery_read_state (
/* Battery Status (_BST) */ /* Battery Status (_BST) */
result = acpi_battery_get_status(battery, &bst); result = acpi_battery_get_status(battery, &bst);
if ((0 != result) || !bst) { if (result || !bst) {
p += sprintf(p, "ERROR: Unable to read battery status\n"); p += sprintf(p, "ERROR: Unable to read battery status\n");
goto end; goto end;
} }
...@@ -590,7 +589,7 @@ acpi_battery_write_alarm ( ...@@ -590,7 +589,7 @@ acpi_battery_write_alarm (
result = acpi_battery_set_alarm(battery, result = acpi_battery_set_alarm(battery,
simple_strtoul(alarm_string, NULL, 0)); simple_strtoul(alarm_string, NULL, 0));
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
return_VALUE(count); return_VALUE(count);
...@@ -693,7 +692,7 @@ acpi_battery_notify ( ...@@ -693,7 +692,7 @@ acpi_battery_notify (
if (!battery) if (!battery)
return_VOID; return_VOID;
if (0 != acpi_bus_get_device(handle, &device)) if (acpi_bus_get_device(handle, &device))
return_VOID; return_VOID;
switch (event) { switch (event) {
...@@ -736,11 +735,11 @@ acpi_battery_add ( ...@@ -736,11 +735,11 @@ acpi_battery_add (
acpi_driver_data(device) = battery; acpi_driver_data(device) = battery;
result = acpi_battery_check(battery); result = acpi_battery_check(battery);
if (0 != result) if (result)
goto end; goto end;
result = acpi_battery_add_fs(device); result = acpi_battery_add_fs(device);
if (0 != result) if (result)
goto end; goto end;
status = acpi_install_notify_handler(battery->handle, status = acpi_install_notify_handler(battery->handle,
...@@ -757,7 +756,7 @@ acpi_battery_add ( ...@@ -757,7 +756,7 @@ acpi_battery_add (
device->status.battery_present?"present":"absent"); device->status.battery_present?"present":"absent");
end: end:
if (0 != result) { if (result) {
acpi_battery_remove_fs(device); acpi_battery_remove_fs(device);
kfree(battery); kfree(battery);
} }
...@@ -803,7 +802,7 @@ acpi_battery_init (void) ...@@ -803,7 +802,7 @@ acpi_battery_init (void)
ACPI_FUNCTION_TRACE("acpi_battery_init"); ACPI_FUNCTION_TRACE("acpi_battery_init");
result = acpi_bus_register_driver(&acpi_battery_driver); result = acpi_bus_register_driver(&acpi_battery_driver);
if (0 > result) { if (result < 0) {
remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
} }
...@@ -820,7 +819,7 @@ acpi_battery_exit (void) ...@@ -820,7 +819,7 @@ acpi_battery_exit (void)
ACPI_FUNCTION_TRACE("acpi_battery_exit"); ACPI_FUNCTION_TRACE("acpi_battery_exit");
result = acpi_bus_unregister_driver(&acpi_battery_driver); result = acpi_bus_unregister_driver(&acpi_battery_driver);
if (0 == result) if (!result)
remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
return_VOID; return_VOID;
......
/* /*
* acpi_bus.c - ACPI Bus Driver ($Revision: 66 $) * acpi_bus.c - ACPI Bus Driver ($Revision: 77 $)
* *
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
* *
...@@ -47,9 +47,9 @@ MODULE_LICENSE("GPL"); ...@@ -47,9 +47,9 @@ MODULE_LICENSE("GPL");
#define PREFIX "ACPI: " #define PREFIX "ACPI: "
FADT_DESCRIPTOR acpi_fadt; FADT_DESCRIPTOR acpi_fadt;
static u8 acpi_disabled = 0; static u8 acpi_disabled;
struct acpi_device *acpi_root = NULL; struct acpi_device *acpi_root;
struct proc_dir_entry *acpi_root_dir = NULL; struct proc_dir_entry *acpi_root_dir;
#define STRUCT_TO_INT(s) (*((int*)&s)) #define STRUCT_TO_INT(s) (*((int*)&s))
...@@ -71,6 +71,8 @@ static struct acpi_blacklist_item acpi_blacklist[] __initdata = ...@@ -71,6 +71,8 @@ static struct acpi_blacklist_item acpi_blacklist[] __initdata =
{"ASUS ", "K7M ", 0x00001000, ACPI_TABLE_DSDT, less_than_or_equal, "Field beyond end of region", 0}, {"ASUS ", "K7M ", 0x00001000, ACPI_TABLE_DSDT, less_than_or_equal, "Field beyond end of region", 0},
/* Intel 810 Motherboard? */ /* Intel 810 Motherboard? */
{"MNTRAL", "MO81010A", 0x00000012, ACPI_TABLE_DSDT, less_than_or_equal, "Field beyond end of region", 0}, {"MNTRAL", "MO81010A", 0x00000012, ACPI_TABLE_DSDT, less_than_or_equal, "Field beyond end of region", 0},
/* Compaq Presario 711FR */
{"COMAPQ", "EAGLES", 0x06040000, ACPI_TABLE_DSDT, less_than_or_equal, "SCI issues (C2 disabled)", 0},
/* Compaq Presario 1700 */ /* Compaq Presario 1700 */
{"PTLTD ", " DSDT ", 0x06040000, ACPI_TABLE_DSDT, less_than_or_equal, "Multiple problems", 1}, {"PTLTD ", " DSDT ", 0x06040000, ACPI_TABLE_DSDT, less_than_or_equal, "Multiple problems", 1},
/* Sony FX120, FX140, FX150? */ /* Sony FX120, FX140, FX150? */
...@@ -398,7 +400,7 @@ acpi_bus_get_power ( ...@@ -398,7 +400,7 @@ acpi_bus_get_power (
ACPI_FUNCTION_TRACE("acpi_bus_get_power"); ACPI_FUNCTION_TRACE("acpi_bus_get_power");
result = acpi_bus_get_device(handle, &device); result = acpi_bus_get_device(handle, &device);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
*state = ACPI_STATE_UNKNOWN; *state = ACPI_STATE_UNKNOWN;
...@@ -424,7 +426,7 @@ acpi_bus_get_power ( ...@@ -424,7 +426,7 @@ acpi_bus_get_power (
} }
else if (device->power.flags.power_resources) { else if (device->power.flags.power_resources) {
result = acpi_power_get_inferred_state(device); result = acpi_power_get_inferred_state(device);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
} }
...@@ -451,7 +453,7 @@ acpi_bus_set_power ( ...@@ -451,7 +453,7 @@ acpi_bus_set_power (
ACPI_FUNCTION_TRACE("acpi_bus_set_power"); ACPI_FUNCTION_TRACE("acpi_bus_set_power");
result = acpi_bus_get_device(handle, &device); result = acpi_bus_get_device(handle, &device);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
...@@ -486,7 +488,7 @@ acpi_bus_set_power ( ...@@ -486,7 +488,7 @@ acpi_bus_set_power (
if (state < device->power.state) { if (state < device->power.state) {
if (device->power.flags.power_resources) { if (device->power.flags.power_resources) {
result = acpi_power_transition(device, state); result = acpi_power_transition(device, state);
if (0 != result) if (result)
goto end; goto end;
} }
if (device->power.states[state].flags.explicit_set) { if (device->power.states[state].flags.explicit_set) {
...@@ -509,13 +511,13 @@ acpi_bus_set_power ( ...@@ -509,13 +511,13 @@ acpi_bus_set_power (
} }
if (device->power.flags.power_resources) { if (device->power.flags.power_resources) {
result = acpi_power_transition(device, state); result = acpi_power_transition(device, state);
if (0 != result) if (result)
goto end; goto end;
} }
} }
end: end:
if (0 != result) if (result)
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error transitioning device [%s] to D%d\n", ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error transitioning device [%s] to D%d\n",
device->pnp.bus_id, state)); device->pnp.bus_id, state));
else else
...@@ -893,7 +895,7 @@ acpi_bus_check_scope ( ...@@ -893,7 +895,7 @@ acpi_bus_check_scope (
/* Status Change? */ /* Status Change? */
result = acpi_bus_check_device(device, &status_changed); result = acpi_bus_check_device(device, &status_changed);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
if (!status_changed) if (!status_changed)
...@@ -924,7 +926,7 @@ acpi_bus_notify ( ...@@ -924,7 +926,7 @@ acpi_bus_notify (
ACPI_FUNCTION_TRACE("acpi_bus_notify"); ACPI_FUNCTION_TRACE("acpi_bus_notify");
if (0 != acpi_bus_get_device(handle, &device)) if (acpi_bus_get_device(handle, &device))
return_VOID; return_VOID;
switch (type) { switch (type) {
...@@ -1019,7 +1021,7 @@ acpi_bus_match ( ...@@ -1019,7 +1021,7 @@ acpi_bus_match (
return -EINVAL; return -EINVAL;
if (device->flags.hardware_id) { if (device->flags.hardware_id) {
if (0 != strstr(driver->ids, device->pnp.hardware_id)) if (strstr(driver->ids, device->pnp.hardware_id))
return 0; return 0;
} }
...@@ -1048,12 +1050,13 @@ acpi_bus_match ( ...@@ -1048,12 +1050,13 @@ acpi_bus_match (
break; break;
case ACPI_TYPE_PACKAGE: case ACPI_TYPE_PACKAGE:
/* TBD: Support CID packages */ /* TBD: Support CID packages */
break;
} }
if (!cid[0]) if (!cid[0])
return -ENOENT; return -ENOENT;
if (0 != strstr(cid, device->pnp.hardware_id)) if (strstr(driver->ids, cid))
return 0; return 0;
} }
...@@ -1083,7 +1086,7 @@ acpi_bus_driver_init ( ...@@ -1083,7 +1086,7 @@ acpi_bus_driver_init (
return_VALUE(-ENOSYS); return_VALUE(-ENOSYS);
result = driver->ops.add(device); result = driver->ops.add(device);
if (0 != result) { if (result) {
device->driver = NULL; device->driver = NULL;
acpi_driver_data(device) = NULL; acpi_driver_data(device) = NULL;
return_VALUE(result); return_VALUE(result);
...@@ -1096,7 +1099,7 @@ acpi_bus_driver_init ( ...@@ -1096,7 +1099,7 @@ acpi_bus_driver_init (
if (driver->ops.start) { if (driver->ops.start) {
result = driver->ops.start(device); result = driver->ops.start(device);
if ((0 != result) && (driver->ops.remove)) if (result && driver->ops.remove)
driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
return_VALUE(result); return_VALUE(result);
} }
...@@ -1149,14 +1152,14 @@ acpi_bus_attach ( ...@@ -1149,14 +1152,14 @@ acpi_bus_attach (
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
result = acpi_bus_match(device, driver); result = acpi_bus_match(device, driver);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n", ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n",
driver->name, device->pnp.bus_id)); driver->name, device->pnp.bus_id));
result = acpi_bus_driver_init(device, driver); result = acpi_bus_driver_init(device, driver);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
down(&acpi_bus_drivers_lock); down(&acpi_bus_drivers_lock);
...@@ -1194,7 +1197,7 @@ acpi_bus_unattach ( ...@@ -1194,7 +1197,7 @@ acpi_bus_unattach (
return_VALUE(-ENOSYS); return_VALUE(-ENOSYS);
result = driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); result = driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
device->driver = NULL; device->driver = NULL;
...@@ -1233,11 +1236,11 @@ acpi_bus_find_driver ( ...@@ -1233,11 +1236,11 @@ acpi_bus_find_driver (
driver = list_entry(entry, struct acpi_driver, node); driver = list_entry(entry, struct acpi_driver, node);
if (0 != acpi_bus_match(device, driver)) if (acpi_bus_match(device, driver))
continue; continue;
result = acpi_bus_driver_init(device, driver); result = acpi_bus_driver_init(device, driver);
if (0 == result) if (!result)
++driver->references; ++driver->references;
break; break;
...@@ -1431,7 +1434,7 @@ acpi_bus_add ( ...@@ -1431,7 +1434,7 @@ acpi_bus_add (
* present and properly initialized. * present and properly initialized.
*/ */
result = acpi_bus_get_flags(device); result = acpi_bus_get_flags(device);
if (0 != result) if (result)
goto end; goto end;
/* /*
...@@ -1446,7 +1449,7 @@ acpi_bus_add ( ...@@ -1446,7 +1449,7 @@ acpi_bus_add (
switch (type) { switch (type) {
case ACPI_BUS_TYPE_DEVICE: case ACPI_BUS_TYPE_DEVICE:
result = acpi_bus_get_status(device); result = acpi_bus_get_status(device);
if (0 != result) if (result)
goto end; goto end;
break; break;
default: default:
...@@ -1535,7 +1538,7 @@ acpi_bus_add ( ...@@ -1535,7 +1538,7 @@ acpi_bus_add (
*/ */
if (device->flags.power_manageable) { if (device->flags.power_manageable) {
result = acpi_bus_get_power_flags(device); result = acpi_bus_get_power_flags(device);
if (0 != result) if (result)
goto end; goto end;
} }
...@@ -1545,7 +1548,7 @@ acpi_bus_add ( ...@@ -1545,7 +1548,7 @@ acpi_bus_add (
*/ */
if (device->flags.performance_manageable) { if (device->flags.performance_manageable) {
result = acpi_bus_get_perf_flags(device); result = acpi_bus_get_perf_flags(device);
if (0 != result) if (result)
goto end; goto end;
} }
...@@ -1655,7 +1658,7 @@ acpi_bus_add ( ...@@ -1655,7 +1658,7 @@ acpi_bus_add (
acpi_bus_find_driver(device); acpi_bus_find_driver(device);
end: end:
if (0 != result) { if (result) {
kfree(device); kfree(device);
return_VALUE(result); return_VALUE(result);
} }
...@@ -1877,15 +1880,12 @@ acpi_blacklisted(void) ...@@ -1877,15 +1880,12 @@ acpi_blacklisted(void)
return blacklisted; return blacklisted;
} }
static int __init static int __init
acpi_bus_init_irq (void) acpi_bus_init_irq (void)
{ {
int result = 0;
acpi_status status = AE_OK; acpi_status status = AE_OK;
acpi_object arg = {ACPI_TYPE_INTEGER}; acpi_object arg = {ACPI_TYPE_INTEGER};
acpi_object_list arg_list = {1, &arg}; acpi_object_list arg_list = {1, &arg};
int irq_model = 0;
char *message = NULL; char *message = NULL;
ACPI_FUNCTION_TRACE("acpi_bus_init_irq"); ACPI_FUNCTION_TRACE("acpi_bus_init_irq");
...@@ -1894,28 +1894,25 @@ acpi_bus_init_irq (void) ...@@ -1894,28 +1894,25 @@ acpi_bus_init_irq (void)
* Let the system know what interrupt model we are using by * Let the system know what interrupt model we are using by
* evaluating the \_PIC object, if exists. * evaluating the \_PIC object, if exists.
*/ */
result = acpi_get_interrupt_model(&irq_model);
if (0 != result)
return_VALUE(result);
switch (irq_model) { switch (acpi_irq_model) {
case ACPI_INT_MODEL_PIC: case ACPI_IRQ_MODEL_PIC:
message = "PIC"; message = "PIC";
break; break;
case ACPI_INT_MODEL_IOAPIC: case ACPI_IRQ_MODEL_IOAPIC:
message = "IOAPIC"; message = "IOAPIC";
break; break;
case ACPI_INT_MODEL_IOSAPIC: case ACPI_IRQ_MODEL_IOSAPIC:
message = "IOSAPIC"; message = "IOSAPIC";
break; break;
default: default:
message = "UNKNOWN"; printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n");
break; return_VALUE(-ENODEV);
} }
printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message); printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message);
arg.integer.value = irq_model; arg.integer.value = acpi_irq_model;
status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL); status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL);
if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
...@@ -1998,12 +1995,14 @@ acpi_bus_init (void) ...@@ -1998,12 +1995,14 @@ acpi_bus_init (void)
progress++; progress++;
/* /*
* [5] Register for all standard device notifications. * [5] Get the system interrupt model and evaluate \_PIC.
*/ */
result = acpi_bus_init_irq(); result = acpi_bus_init_irq();
if (0 != result) if (result)
goto end; goto end;
progress++;
/* /*
* [6] Register for all standard device notifications. * [6] Register for all standard device notifications.
*/ */
...@@ -2021,7 +2020,7 @@ acpi_bus_init (void) ...@@ -2021,7 +2020,7 @@ acpi_bus_init (void)
*/ */
result = acpi_bus_add(&acpi_root, NULL, ACPI_ROOT_OBJECT, result = acpi_bus_add(&acpi_root, NULL, ACPI_ROOT_OBJECT,
ACPI_BUS_TYPE_SYSTEM); ACPI_BUS_TYPE_SYSTEM);
if (0 != result) if (result)
goto end; goto end;
progress++; progress++;
...@@ -2056,17 +2055,18 @@ acpi_bus_init (void) ...@@ -2056,17 +2055,18 @@ acpi_bus_init (void)
/* /*
* [10] Enumerate devices in the ACPI namespace. * [10] Enumerate devices in the ACPI namespace.
*/ */
result = acpi_bus_scan_fixed(acpi_root); result = acpi_bus_scan_fixed(acpi_root);
if (0 != result) if (result)
goto end; goto end;
result = acpi_bus_scan(acpi_root); result = acpi_bus_scan(acpi_root);
if (0 != result) if (result)
goto end; goto end;
end: end:
if (0 != result) { /*
* Clean up if anything went awry.
*/
if (result) {
switch (progress) { switch (progress) {
case 10: case 10:
case 9: remove_proc_entry("ACPI", NULL); case 9: remove_proc_entry("ACPI", NULL);
...@@ -2132,9 +2132,7 @@ acpi_init (void) ...@@ -2132,9 +2132,7 @@ acpi_init (void)
ACPI_FUNCTION_TRACE("acpi_init"); ACPI_FUNCTION_TRACE("acpi_init");
printk(KERN_INFO PREFIX "Bus Driver revision %08x\n", printk(KERN_INFO PREFIX "Subsystem revision %08x\n",
ACPI_DRIVER_VERSION);
printk(KERN_INFO PREFIX "Core Subsystem revision %08x\n",
ACPI_CA_VERSION); ACPI_CA_VERSION);
/* Initial core debug level excludes drivers, so include them now */ /* Initial core debug level excludes drivers, so include them now */
...@@ -2153,7 +2151,7 @@ acpi_init (void) ...@@ -2153,7 +2151,7 @@ acpi_init (void)
#endif #endif
result = acpi_bus_init(); result = acpi_bus_init();
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
#ifdef CONFIG_PM #ifdef CONFIG_PM
...@@ -2192,10 +2190,6 @@ acpi_setup(char *str) ...@@ -2192,10 +2190,6 @@ acpi_setup(char *str)
return 1; return 1;
} }
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
subsys_initcall(acpi_init); subsys_initcall(acpi_init);
#endif
__setup("acpi=", acpi_setup); __setup("acpi=", acpi_setup);
/* /*
* acpi_button.c - ACPI Button Driver ($Revision: 24 $) * acpi_button.c - ACPI Button Driver ($Revision: 29 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include "acpi_bus.h" #include "acpi_bus.h"
#include "acpi_drivers.h" #include "acpi_drivers.h"
...@@ -66,9 +68,6 @@ struct acpi_button { ...@@ -66,9 +68,6 @@ struct acpi_button {
FS Interface (/proc) FS Interface (/proc)
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
static struct proc_dir_entry *acpi_button_dir = NULL; static struct proc_dir_entry *acpi_button_dir = NULL;
...@@ -128,17 +127,17 @@ acpi_button_add_fs ( ...@@ -128,17 +127,17 @@ acpi_button_add_fs (
switch (button->type) { switch (button->type) {
case ACPI_BUTTON_TYPE_POWER: case ACPI_BUTTON_TYPE_POWER:
case ACPI_BUTTON_TYPE_POWERF: case ACPI_BUTTON_TYPE_POWERF:
entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER, entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER,
acpi_button_dir); acpi_button_dir);
break; break;
case ACPI_BUTTON_TYPE_SLEEP: case ACPI_BUTTON_TYPE_SLEEP:
case ACPI_BUTTON_TYPE_SLEEPF: case ACPI_BUTTON_TYPE_SLEEPF:
entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP, entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP,
acpi_button_dir); acpi_button_dir);
break; break;
case ACPI_BUTTON_TYPE_LID: case ACPI_BUTTON_TYPE_LID:
entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID,
acpi_button_dir); acpi_button_dir);
break; break;
} }
...@@ -234,6 +233,10 @@ acpi_button_add ( ...@@ -234,6 +233,10 @@ acpi_button_add (
acpi_status status = AE_OK; acpi_status status = AE_OK;
struct acpi_button *button = NULL; struct acpi_button *button = NULL;
static struct acpi_device *power_button;
static struct acpi_device *sleep_button;
static struct acpi_device *lid_button;
ACPI_FUNCTION_TRACE("acpi_button_add"); ACPI_FUNCTION_TRACE("acpi_button_add");
if (!device) if (!device)
...@@ -294,8 +297,40 @@ acpi_button_add ( ...@@ -294,8 +297,40 @@ acpi_button_add (
goto end; goto end;
} }
/*
* Ensure only one button of each type is used.
*/
switch (button->type) {
case ACPI_BUTTON_TYPE_POWER:
case ACPI_BUTTON_TYPE_POWERF:
if (!power_button)
power_button = device;
else {
kfree(button);
return_VALUE(-ENODEV);
}
break;
case ACPI_BUTTON_TYPE_SLEEP:
case ACPI_BUTTON_TYPE_SLEEPF:
if (!sleep_button)
sleep_button = device;
else {
kfree(button);
return_VALUE(-ENODEV);
}
break;
case ACPI_BUTTON_TYPE_LID:
if (!lid_button)
lid_button = device;
else {
kfree(button);
return_VALUE(-ENODEV);
}
break;
}
result = acpi_button_add_fs(device); result = acpi_button_add_fs(device);
if (0 != result) if (result)
goto end; goto end;
switch (button->type) { switch (button->type) {
...@@ -331,7 +366,7 @@ acpi_button_add ( ...@@ -331,7 +366,7 @@ acpi_button_add (
acpi_device_name(device), acpi_device_bid(device)); acpi_device_name(device), acpi_device_bid(device));
end: end:
if (0 != result) { if (result) {
acpi_button_remove_fs(device); acpi_button_remove_fs(device);
kfree(button); kfree(button);
} }
...@@ -389,7 +424,7 @@ acpi_button_init (void) ...@@ -389,7 +424,7 @@ acpi_button_init (void)
ACPI_FUNCTION_TRACE("acpi_button_init"); ACPI_FUNCTION_TRACE("acpi_button_init");
result = acpi_bus_register_driver(&acpi_button_driver); result = acpi_bus_register_driver(&acpi_button_driver);
if (0 > result) if (result < 0)
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
return_VALUE(0); return_VALUE(0);
......
/* /*
* acpi_ec.c - ACPI Embedded Controller Driver ($Revision: 28 $) * acpi_ec.c - ACPI Embedded Controller Driver ($Revision: 31 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include <asm/io.h> #include <asm/io.h>
#include "acpi_bus.h" #include "acpi_bus.h"
#include "acpi_drivers.h" #include "acpi_drivers.h"
...@@ -151,12 +153,12 @@ acpi_ec_read ( ...@@ -151,12 +153,12 @@ acpi_ec_read (
outb(ACPI_EC_COMMAND_READ, ec->command_port); outb(ACPI_EC_COMMAND_READ, ec->command_port);
result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
if (0 != result) if (result)
goto end; goto end;
outb(address, ec->data_port); outb(address, ec->data_port);
result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
if (0 != result) if (result)
goto end; goto end;
*data = inb(ec->data_port); *data = inb(ec->data_port);
...@@ -200,17 +202,17 @@ acpi_ec_write ( ...@@ -200,17 +202,17 @@ acpi_ec_write (
outb(ACPI_EC_COMMAND_WRITE, ec->command_port); outb(ACPI_EC_COMMAND_WRITE, ec->command_port);
result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
if (0 != result) if (result)
goto end; goto end;
outb(address, ec->data_port); outb(address, ec->data_port);
result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
if (0 != result) if (result)
goto end; goto end;
outb(data, ec->data_port); outb(data, ec->data_port);
result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
if (0 != result) if (result)
goto end; goto end;
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
...@@ -259,7 +261,7 @@ acpi_ec_query ( ...@@ -259,7 +261,7 @@ acpi_ec_query (
outb(ACPI_EC_COMMAND_QUERY, ec->command_port); outb(ACPI_EC_COMMAND_QUERY, ec->command_port);
result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
if (0 != result) if (result)
goto end; goto end;
*data = inb(ec->data_port); *data = inb(ec->data_port);
...@@ -342,7 +344,7 @@ acpi_ec_gpe_handler ( ...@@ -342,7 +344,7 @@ acpi_ec_gpe_handler (
if (!(value & ACPI_EC_FLAG_SCI)) if (!(value & ACPI_EC_FLAG_SCI))
return; return;
if (0 != acpi_ec_query(ec, &value)) if (acpi_ec_query(ec, &value))
return; return;
query_data = kmalloc(sizeof(struct acpi_ec_query_data), GFP_ATOMIC); query_data = kmalloc(sizeof(struct acpi_ec_query_data), GFP_ATOMIC);
...@@ -433,9 +435,6 @@ acpi_ec_space_handler ( ...@@ -433,9 +435,6 @@ acpi_ec_space_handler (
FS Interface (/proc) FS Interface (/proc)
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
struct proc_dir_entry *acpi_ec_dir = NULL; struct proc_dir_entry *acpi_ec_dir = NULL;
...@@ -566,7 +565,7 @@ acpi_ec_add ( ...@@ -566,7 +565,7 @@ acpi_ec_add (
} }
result = acpi_ec_add_fs(device); result = acpi_ec_add_fs(device);
if (0 != result) if (result)
goto end; goto end;
printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
...@@ -574,7 +573,7 @@ acpi_ec_add ( ...@@ -574,7 +573,7 @@ acpi_ec_add (
(u32) ec->gpe_bit); (u32) ec->gpe_bit);
end: end:
if (0 != result) if (result)
kfree(ec); kfree(ec);
return_VALUE(result); return_VALUE(result);
...@@ -712,7 +711,7 @@ acpi_ec_init (void) ...@@ -712,7 +711,7 @@ acpi_ec_init (void)
ACPI_FUNCTION_TRACE("acpi_ec_init"); ACPI_FUNCTION_TRACE("acpi_ec_init");
result = acpi_bus_register_driver(&acpi_ec_driver); result = acpi_bus_register_driver(&acpi_ec_driver);
if (0 > result) { if (result < 0) {
remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir); remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
} }
...@@ -729,7 +728,7 @@ acpi_ec_exit (void) ...@@ -729,7 +728,7 @@ acpi_ec_exit (void)
ACPI_FUNCTION_TRACE("acpi_ec_exit"); ACPI_FUNCTION_TRACE("acpi_ec_exit");
result = acpi_bus_unregister_driver(&acpi_ec_driver); result = acpi_bus_unregister_driver(&acpi_ec_driver);
if (0 == result) if (!result)
remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir); remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
return_VOID; return_VOID;
......
/* /*
* acpi_fan.c - ACPI Fan Driver ($Revision: 25 $) * acpi_fan.c - ACPI Fan Driver ($Revision: 28 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include "acpi_bus.h" #include "acpi_bus.h"
#include "acpi_drivers.h" #include "acpi_drivers.h"
...@@ -63,9 +65,6 @@ struct acpi_fan { ...@@ -63,9 +65,6 @@ struct acpi_fan {
FS Interface (/proc) FS Interface (/proc)
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
struct proc_dir_entry *acpi_fan_dir = NULL; struct proc_dir_entry *acpi_fan_dir = NULL;
...@@ -88,7 +87,7 @@ acpi_fan_read_state ( ...@@ -88,7 +87,7 @@ acpi_fan_read_state (
if (!fan || (off != 0)) if (!fan || (off != 0))
goto end; goto end;
if (0 != acpi_bus_get_power(fan->handle, &state)) if (acpi_bus_get_power(fan->handle, &state))
goto end; goto end;
p += sprintf(p, "status: %s\n", p += sprintf(p, "status: %s\n",
...@@ -129,7 +128,7 @@ acpi_fan_write_state ( ...@@ -129,7 +128,7 @@ acpi_fan_write_state (
result = acpi_bus_set_power(fan->handle, result = acpi_bus_set_power(fan->handle,
simple_strtoul(state_string, NULL, 0)); simple_strtoul(state_string, NULL, 0));
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
return_VALUE(count); return_VALUE(count);
...@@ -221,14 +220,14 @@ acpi_fan_add ( ...@@ -221,14 +220,14 @@ acpi_fan_add (
acpi_driver_data(device) = fan; acpi_driver_data(device) = fan;
result = acpi_bus_get_power(fan->handle, &state); result = acpi_bus_get_power(fan->handle, &state);
if (0 != result) { if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error reading power state\n")); "Error reading power state\n"));
goto end; goto end;
} }
result = acpi_fan_add_fs(device); result = acpi_fan_add_fs(device);
if (0 != result) if (result)
goto end; goto end;
printk(KERN_INFO PREFIX "%s [%s] (%s)\n", printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
...@@ -236,7 +235,7 @@ acpi_fan_add ( ...@@ -236,7 +235,7 @@ acpi_fan_add (
!device->power.state?"on":"off"); !device->power.state?"on":"off");
end: end:
if (0 != result) if (result)
kfree(fan); kfree(fan);
return_VALUE(result); return_VALUE(result);
...@@ -273,7 +272,7 @@ acpi_fan_init (void) ...@@ -273,7 +272,7 @@ acpi_fan_init (void)
ACPI_FUNCTION_TRACE("acpi_fan_init"); ACPI_FUNCTION_TRACE("acpi_fan_init");
result = acpi_bus_register_driver(&acpi_fan_driver); result = acpi_bus_register_driver(&acpi_fan_driver);
if (0 > result) if (result < 0)
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
return_VALUE(0); return_VALUE(0);
...@@ -288,7 +287,7 @@ acpi_fan_exit (void) ...@@ -288,7 +287,7 @@ acpi_fan_exit (void)
ACPI_FUNCTION_TRACE("acpi_fan_exit"); ACPI_FUNCTION_TRACE("acpi_fan_exit");
result = acpi_bus_unregister_driver(&acpi_fan_driver); result = acpi_bus_unregister_driver(&acpi_fan_driver);
if (0 == result) if (!result)
remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
return_VOID; return_VOID;
......
/* /*
* acpi_osl.c - OS-dependent functions ($Revision: 69 $) * acpi_osl.c - OS-dependent functions ($Revision: 78 $)
* *
* Copyright (C) 2000 Andrew Henroid * Copyright (C) 2000 Andrew Henroid
* Copyright (C) 2001 Andrew Grover * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
* *
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* *
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#ifdef CONFIG_ACPI_EFI #ifdef CONFIG_ACPI_EFI
#include <asm/efi.h> #include <asm/efi.h>
u64 efi_mem_attributes (u64 phys_addr);
#endif #endif
#ifdef _IA64 #ifdef _IA64
...@@ -77,13 +78,13 @@ acpi_os_initialize(void) ...@@ -77,13 +78,13 @@ acpi_os_initialize(void)
* Initialize PCI configuration space access, as we'll need to access * Initialize PCI configuration space access, as we'll need to access
* it while walking the namespace (bus 0 and root bridges w/ _BBNs). * it while walking the namespace (bus 0 and root bridges w/ _BBNs).
*/ */
#if 0 #ifdef CONFIG_ACPI_PCI
pcibios_config_init();
if (!pci_config_read || !pci_config_write) { if (!pci_config_read || !pci_config_write) {
printk(KERN_ERR PREFIX "Access to PCI configuration space unavailable\n"); printk(KERN_ERR PREFIX "Access to PCI configuration space unavailable\n");
return AE_NULL_ENTRY; return AE_NULL_ENTRY;
} }
#endif #endif
return AE_OK; return AE_OK;
} }
...@@ -147,24 +148,22 @@ acpi_os_free(void *ptr) ...@@ -147,24 +148,22 @@ acpi_os_free(void *ptr)
kfree(ptr); kfree(ptr);
} }
acpi_status acpi_status
acpi_os_get_root_pointer(u32 flags, ACPI_POINTER *addr) acpi_os_get_root_pointer(u32 flags, ACPI_POINTER *addr)
{ {
#ifndef CONFIG_ACPI_EFI #ifdef CONFIG_ACPI_EFI
if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) {
printk(KERN_ERR PREFIX "System description tables not found\n");
return AE_NOT_FOUND;
}
#else /*CONFIG_ACPI_EFI*/
addr->pointer_type = ACPI_PHYSICAL_POINTER; addr->pointer_type = ACPI_PHYSICAL_POINTER;
if (efi.acpi20) if (efi.acpi20)
addr->pointer.physical = (ACPI_PHYSICAL_ADDRESS) efi.acpi20; addr->pointer.physical = (ACPI_PHYSICAL_ADDRESS) virt_to_phys(efi.acpi20);
else if (efi.acpi) else if (efi.acpi)
addr->pointer.physical = (ACPI_PHYSICAL_ADDRESS) efi.acpi; addr->pointer.physical = (ACPI_PHYSICAL_ADDRESS) virt_to_phys(efi.acpi);
else { else {
printk(KERN_ERR PREFIX "System description tables not found\n"); printk(KERN_ERR PREFIX "System description tables not found\n");
addr->pointer.physical = 0; return AE_NOT_FOUND;
}
#else
if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) {
printk(KERN_ERR PREFIX "System description tables not found\n");
return AE_NOT_FOUND; return AE_NOT_FOUND;
} }
#endif /*CONFIG_ACPI_EFI*/ #endif /*CONFIG_ACPI_EFI*/
...@@ -175,15 +174,23 @@ acpi_os_get_root_pointer(u32 flags, ACPI_POINTER *addr) ...@@ -175,15 +174,23 @@ acpi_os_get_root_pointer(u32 flags, ACPI_POINTER *addr)
acpi_status acpi_status
acpi_os_map_memory(ACPI_PHYSICAL_ADDRESS phys, ACPI_SIZE size, void **virt) acpi_os_map_memory(ACPI_PHYSICAL_ADDRESS phys, ACPI_SIZE size, void **virt)
{ {
#ifdef CONFIG_ACPI_EFI
if (EFI_MEMORY_UC & efi_mem_attributes(phys)) {
*virt = ioremap(phys, size);
} else {
*virt = phys_to_virt(phys);
}
#else
if (phys > ULONG_MAX) { if (phys > ULONG_MAX) {
printk(KERN_ERR PREFIX "Cannot map memory that high\n"); printk(KERN_ERR PREFIX "Cannot map memory that high\n");
return AE_BAD_PARAMETER; return AE_BAD_PARAMETER;
} }
/* /*
* ioremap already checks to ensure this is in reserved space * ioremap checks to ensure this is in reserved space
*/ */
*virt = ioremap((unsigned long) phys, size); *virt = ioremap((unsigned long) phys, size);
#endif
if (!*virt) if (!*virt)
return AE_NO_MEMORY; return AE_NO_MEMORY;
...@@ -207,6 +214,16 @@ acpi_os_get_physical_address(void *virt, ACPI_PHYSICAL_ADDRESS *phys) ...@@ -207,6 +214,16 @@ acpi_os_get_physical_address(void *virt, ACPI_PHYSICAL_ADDRESS *phys)
return AE_OK; return AE_OK;
} }
acpi_status
acpi_os_table_override (acpi_table_header *existing_table, acpi_table_header **new_table)
{
if (!existing_table || !new_table)
return AE_BAD_PARAMETER;
*new_table = NULL;
return AE_OK;
}
static void static void
acpi_irq(int irq, void *dev_id, struct pt_regs *regs) acpi_irq(int irq, void *dev_id, struct pt_regs *regs)
{ {
...@@ -325,26 +342,43 @@ acpi_os_read_memory( ...@@ -325,26 +342,43 @@ acpi_os_read_memory(
void *value, void *value,
u32 width) u32 width)
{ {
u32 dummy; u32 dummy;
void *virt_addr;
#ifdef CONFIG_ACPI_EFI
int iomem = 0;
if (EFI_MEMORY_UC & efi_mem_attributes(phys_addr)) {
iomem = 1;
virt_addr = ioremap(phys_addr, width);
}
else
virt_addr = phys_to_virt(phys_addr);
#else
virt_addr = phys_to_virt(phys_addr);
#endif
if (!value) if (!value)
value = &dummy; value = &dummy;
switch (width) switch (width) {
{
case 8: case 8:
*(u8*) value = *(u8*) phys_to_virt(phys_addr); *(u8*) value = *(u8*) virt_addr;
break; break;
case 16: case 16:
*(u16*) value = *(u16*) phys_to_virt(phys_addr); *(u16*) value = *(u16*) virt_addr;
break; break;
case 32: case 32:
*(u32*) value = *(u32*) phys_to_virt(phys_addr); *(u32*) value = *(u32*) virt_addr;
break; break;
default: default:
BUG(); BUG();
} }
#ifdef CONFIG_ACPI_EFI
if (iomem)
iounmap(virt_addr);
#endif
return AE_OK; return AE_OK;
} }
...@@ -354,24 +388,44 @@ acpi_os_write_memory( ...@@ -354,24 +388,44 @@ acpi_os_write_memory(
acpi_integer value, acpi_integer value,
u32 width) u32 width)
{ {
switch (width) void *virt_addr;
{
#ifdef CONFIG_ACPI_EFI
int iomem = 0;
if (EFI_MEMORY_UC & efi_mem_attributes(phys_addr)) {
iomem = 1;
virt_addr = ioremap(phys_addr,width);
}
else
virt_addr = phys_to_virt(phys_addr);
#else
virt_addr = phys_to_virt(phys_addr);
#endif
switch (width) {
case 8: case 8:
*(u8*) phys_to_virt(phys_addr) = value; *(u8*) virt_addr = value;
break; break;
case 16: case 16:
*(u16*) phys_to_virt(phys_addr) = value; *(u16*) virt_addr = value;
break; break;
case 32: case 32:
*(u32*) phys_to_virt(phys_addr) = value; *(u32*) virt_addr = value;
break; break;
default: default:
BUG(); BUG();
} }
#ifdef CONFIG_ACPI_EFI
if (iomem)
iounmap(virt_addr);
#endif
return AE_OK; return AE_OK;
} }
#ifdef CONFIG_ACPI_PCI
acpi_status acpi_status
acpi_os_read_pci_configuration ( acpi_os_read_pci_configuration (
...@@ -435,6 +489,29 @@ acpi_os_write_pci_configuration ( ...@@ -435,6 +489,29 @@ acpi_os_write_pci_configuration (
return (result ? AE_ERROR : AE_OK); return (result ? AE_ERROR : AE_OK);
} }
#else /*!CONFIG_ACPI_PCI*/
acpi_status
acpi_os_write_pci_configuration (
acpi_pci_id *pci_id,
u32 reg,
acpi_integer value,
u32 width)
{
return (AE_SUPPORT);
}
acpi_status
acpi_os_read_pci_configuration (
acpi_pci_id *pci_id,
u32 reg,
void *value,
u32 width)
{
return (AE_SUPPORT);
}
#endif /*CONFIG_ACPI_PCI*/
acpi_status acpi_status
acpi_os_load_module ( acpi_os_load_module (
...@@ -445,7 +522,7 @@ acpi_os_load_module ( ...@@ -445,7 +522,7 @@ acpi_os_load_module (
if (!module_name) if (!module_name)
return_ACPI_STATUS (AE_BAD_PARAMETER); return_ACPI_STATUS (AE_BAD_PARAMETER);
if (0 > request_module(module_name)) { if (request_module(module_name) < 0) {
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to load module [%s].\n", module_name)); ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to load module [%s].\n", module_name));
return_ACPI_STATUS (AE_ERROR); return_ACPI_STATUS (AE_ERROR);
} }
......
/* /*
* acpi_power.c - ACPI Bus Power Management ($Revision: 34 $) * acpi_power.c - ACPI Bus Power Management ($Revision: 37 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include "acpi_bus.h" #include "acpi_bus.h"
#include "acpi_drivers.h" #include "acpi_drivers.h"
...@@ -81,7 +83,7 @@ acpi_power_get_context ( ...@@ -81,7 +83,7 @@ acpi_power_get_context (
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
result = acpi_bus_get_device(handle, &device); result = acpi_bus_get_device(handle, &device);
if (0 != result) { if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n", ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n",
handle)); handle));
return_VALUE(result); return_VALUE(result);
...@@ -141,10 +143,10 @@ acpi_power_get_list_state ( ...@@ -141,10 +143,10 @@ acpi_power_get_list_state (
for (i=0; i<list->count; i++) { for (i=0; i<list->count; i++) {
result = acpi_power_get_context(list->handles[i], &resource); result = acpi_power_get_context(list->handles[i], &resource);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
result = acpi_power_get_state(resource); result = acpi_power_get_state(resource);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
*state = resource->state; *state = resource->state;
...@@ -172,7 +174,7 @@ acpi_power_on ( ...@@ -172,7 +174,7 @@ acpi_power_on (
ACPI_FUNCTION_TRACE("acpi_power_on"); ACPI_FUNCTION_TRACE("acpi_power_on");
result = acpi_power_get_context(handle, &resource); result = acpi_power_get_context(handle, &resource);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
resource->references++; resource->references++;
...@@ -189,14 +191,14 @@ acpi_power_on ( ...@@ -189,14 +191,14 @@ acpi_power_on (
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
result = acpi_power_get_state(resource); result = acpi_power_get_state(resource);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
if (resource->state != ACPI_POWER_RESOURCE_STATE_ON) if (resource->state != ACPI_POWER_RESOURCE_STATE_ON)
return_VALUE(-ENOEXEC); return_VALUE(-ENOEXEC);
/* Update the power resource's _device_ power state */ /* Update the power resource's _device_ power state */
result = acpi_bus_get_device(resource->handle, &device); result = acpi_bus_get_device(resource->handle, &device);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
device->power.state = ACPI_STATE_D0; device->power.state = ACPI_STATE_D0;
...@@ -219,7 +221,7 @@ acpi_power_off ( ...@@ -219,7 +221,7 @@ acpi_power_off (
ACPI_FUNCTION_TRACE("acpi_power_off"); ACPI_FUNCTION_TRACE("acpi_power_off");
result = acpi_power_get_context(handle, &resource); result = acpi_power_get_context(handle, &resource);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
if (resource->references) if (resource->references)
...@@ -243,14 +245,14 @@ acpi_power_off ( ...@@ -243,14 +245,14 @@ acpi_power_off (
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
result = acpi_power_get_state(resource); result = acpi_power_get_state(resource);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF) if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF)
return_VALUE(-ENOEXEC); return_VALUE(-ENOEXEC);
/* Update the power resource's _device_ power state */ /* Update the power resource's _device_ power state */
result = acpi_bus_get_device(resource->handle, &device); result = acpi_bus_get_device(resource->handle, &device);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
device->power.state = ACPI_STATE_D3; device->power.state = ACPI_STATE_D3;
...@@ -291,7 +293,7 @@ acpi_power_get_inferred_state ( ...@@ -291,7 +293,7 @@ acpi_power_get_inferred_state (
continue; continue;
result = acpi_power_get_list_state(list, &list_state); result = acpi_power_get_list_state(list, &list_state);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
if (list_state == ACPI_POWER_RESOURCE_STATE_ON) { if (list_state == ACPI_POWER_RESOURCE_STATE_ON) {
...@@ -339,7 +341,7 @@ acpi_power_transition ( ...@@ -339,7 +341,7 @@ acpi_power_transition (
*/ */
for (i=0; i<tl->count; i++) { for (i=0; i<tl->count; i++) {
result = acpi_power_on(tl->handles[i]); result = acpi_power_on(tl->handles[i]);
if (0 != result) if (result)
goto end; goto end;
} }
...@@ -350,12 +352,12 @@ acpi_power_transition ( ...@@ -350,12 +352,12 @@ acpi_power_transition (
*/ */
for (i=0; i<cl->count; i++) { for (i=0; i<cl->count; i++) {
result = acpi_power_off(cl->handles[i]); result = acpi_power_off(cl->handles[i]);
if (0 != result) if (result)
goto end; goto end;
} }
end: end:
if (0 != result) if (result)
ACPI_DEBUG_PRINT((ACPI_DB_WARN, ACPI_DEBUG_PRINT((ACPI_DB_WARN,
"Error transitioning device [%s] to D%d\n", "Error transitioning device [%s] to D%d\n",
device->pnp.bus_id, state)); device->pnp.bus_id, state));
...@@ -368,9 +370,6 @@ acpi_power_transition ( ...@@ -368,9 +370,6 @@ acpi_power_transition (
FS Interface (/proc) FS Interface (/proc)
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
struct proc_dir_entry *acpi_power_dir = NULL; struct proc_dir_entry *acpi_power_dir = NULL;
...@@ -522,7 +521,7 @@ acpi_power_add ( ...@@ -522,7 +521,7 @@ acpi_power_add (
resource->order = acpi_object.power_resource.resource_order; resource->order = acpi_object.power_resource.resource_order;
result = acpi_power_get_state(resource); result = acpi_power_get_state(resource);
if (0 != result) if (result)
goto end; goto end;
switch (resource->state) { switch (resource->state) {
...@@ -538,14 +537,14 @@ acpi_power_add ( ...@@ -538,14 +537,14 @@ acpi_power_add (
} }
result = acpi_power_add_fs(device); result = acpi_power_add_fs(device);
if (0 != result) if (result)
goto end; goto end;
printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device), printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device),
acpi_device_bid(device), resource->state?"on":"off"); acpi_device_bid(device), resource->state?"on":"off");
end: end:
if (0 != result) if (result)
kfree(resource); kfree(resource);
return_VALUE(result); return_VALUE(result);
...@@ -584,7 +583,7 @@ acpi_power_init (void) ...@@ -584,7 +583,7 @@ acpi_power_init (void)
INIT_LIST_HEAD(&acpi_power_resource_list); INIT_LIST_HEAD(&acpi_power_resource_list);
result = acpi_bus_register_driver(&acpi_power_driver); result = acpi_bus_register_driver(&acpi_power_driver);
if (0 > result) { if (result < 0) {
remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir); remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir);
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
} }
...@@ -603,7 +602,7 @@ acpi_power_exit (void) ...@@ -603,7 +602,7 @@ acpi_power_exit (void)
/* TBD: Empty acpi_power_resource_list */ /* TBD: Empty acpi_power_resource_list */
result = acpi_bus_unregister_driver(&acpi_power_driver); result = acpi_bus_unregister_driver(&acpi_power_driver);
if (0 == result) if (!result)
remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir); remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir);
return_VOID; return_VOID;
......
/* /*
* acpi_processor.c - ACPI Processor Driver ($Revision: 57 $) * acpi_processor.c - ACPI Processor Driver ($Revision: 66 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
* 3. Optimize by having scheduler determine business instead of * 3. Optimize by having scheduler determine business instead of
* having us try to calculate it here. * having us try to calculate it here.
* 4. Need C1 timing -- must modify kernel (IRQ handler) to get this. * 4. Need C1 timing -- must modify kernel (IRQ handler) to get this.
* 5. Convert time values to ticks (initially) to avoid having to do
* the math (acpi_get_timer_duration).
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -40,6 +38,8 @@ ...@@ -40,6 +38,8 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/delay.h> #include <asm/delay.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include "acpi_bus.h" #include "acpi_bus.h"
#include "acpi_drivers.h" #include "acpi_drivers.h"
...@@ -53,6 +53,10 @@ MODULE_LICENSE("GPL"); ...@@ -53,6 +53,10 @@ MODULE_LICENSE("GPL");
#define PREFIX "ACPI: " #define PREFIX "ACPI: "
#define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000)
#define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */
#define C3_OVERHEAD 4 /* 1us (3.579 ticks per us) */
#define ACPI_PROCESSOR_BUSY_METRIC 10 #define ACPI_PROCESSOR_BUSY_METRIC 10
#define ACPI_PROCESSOR_MAX_POWER ACPI_C_STATE_COUNT #define ACPI_PROCESSOR_MAX_POWER ACPI_C_STATE_COUNT
...@@ -90,6 +94,7 @@ struct acpi_processor_cx_policy { ...@@ -90,6 +94,7 @@ struct acpi_processor_cx_policy {
int state; int state;
struct { struct {
u32 time; u32 time;
u32 ticks;
u32 count; u32 count;
u32 bm; u32 bm;
} threshold; } threshold;
...@@ -99,6 +104,7 @@ struct acpi_processor_cx { ...@@ -99,6 +104,7 @@ struct acpi_processor_cx {
u8 valid; u8 valid;
u32 address; u32 address;
u32 latency; u32 latency;
u32 latency_ticks;
u32 power; u32 power;
u32 usage; u32 usage;
struct acpi_processor_cx_policy promotion; struct acpi_processor_cx_policy promotion;
...@@ -346,6 +352,20 @@ acpi_processor_errata ( ...@@ -346,6 +352,20 @@ acpi_processor_errata (
Power Management Power Management
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
static inline u32
ticks_elapsed (
u32 t1,
u32 t2)
{
if (t2 >= t1)
return (t2 - t1);
else if (!acpi_fadt.tmr_val_ext)
return (((0x00FFFFFF - t1) + t2) & 0x00FFFFFF);
else
return ((0xFFFFFFFF - t1) + t2);
}
static void static void
acpi_processor_power_activate ( acpi_processor_power_activate (
struct acpi_processor *pr, struct acpi_processor *pr,
...@@ -361,7 +381,7 @@ acpi_processor_power_activate ( ...@@ -361,7 +381,7 @@ acpi_processor_power_activate (
switch (pr->power.state) { switch (pr->power.state) {
case ACPI_STATE_C3: case ACPI_STATE_C3:
/* Disable bus master reload */ /* Disable bus master reload */
acpi_hw_bit_register_write(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK); acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK);
break; break;
} }
...@@ -369,7 +389,7 @@ acpi_processor_power_activate ( ...@@ -369,7 +389,7 @@ acpi_processor_power_activate (
switch (state) { switch (state) {
case ACPI_STATE_C3: case ACPI_STATE_C3:
/* Enable bus master reload */ /* Enable bus master reload */
acpi_hw_bit_register_write(ACPI_BITREG_BUS_MASTER_RLD, 1, ACPI_MTX_DO_NOT_LOCK); acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1, ACPI_MTX_DO_NOT_LOCK);
break; break;
} }
...@@ -385,9 +405,8 @@ acpi_processor_idle (void) ...@@ -385,9 +405,8 @@ acpi_processor_idle (void)
struct acpi_processor *pr = NULL; struct acpi_processor *pr = NULL;
struct acpi_processor_cx *cx = NULL; struct acpi_processor_cx *cx = NULL;
int next_state = 0; int next_state = 0;
u32 start_ticks = 0; int sleep_ticks = 0;
u32 end_ticks = 0; u32 t1, t2 = 0;
u32 time_elapsed = 0;
pr = processors[smp_processor_id()]; pr = processors[smp_processor_id()];
if (!pr) if (!pr)
...@@ -408,13 +427,16 @@ acpi_processor_idle (void) ...@@ -408,13 +427,16 @@ acpi_processor_idle (void)
* for demotion. * for demotion.
*/ */
if (pr->flags.bm_check) { if (pr->flags.bm_check) {
u32 bm_status = 0;
pr->power.bm_activity <<= 1; pr->power.bm_activity <<= 1;
pr->power.bm_activity &= 0xFFFFFFFE;
if (acpi_hw_bit_register_read(ACPI_BITREG_BUS_MASTER_STATUS, ACPI_MTX_DO_NOT_LOCK)) { acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS,
&bm_status, ACPI_MTX_DO_NOT_LOCK);
if (bm_status) {
pr->power.bm_activity++; pr->power.bm_activity++;
acpi_hw_bit_register_write(ACPI_BITREG_BUS_MASTER_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS,
1, ACPI_MTX_DO_NOT_LOCK);
} }
/* /*
* PIIX4 Erratum #18: Note that BM_STS doesn't always reflect * PIIX4 Erratum #18: Note that BM_STS doesn't always reflect
...@@ -426,12 +448,17 @@ acpi_processor_idle (void) ...@@ -426,12 +448,17 @@ acpi_processor_idle (void)
|| (inb_p(errata.piix4.bmisx + 0x0A) & 0x01)) || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01))
pr->power.bm_activity++; pr->power.bm_activity++;
} }
/* /*
* Apply bus mastering demotion policy. Automatically demote * Apply bus mastering demotion policy. Automatically demote
* to avoid a faulty transition. Note that the processor * to avoid a faulty transition. Note that the processor
* won't enter a low-power state during this call (to this * won't enter a low-power state during this call (to this
* funciton) but should upon the next. * funciton) but should upon the next.
*
* TBD: A better policy might be to fallback to the demotion
* state (use it for this quantum only) istead of
* demoting -- and rely on duration as our sole demotion
* qualification. This may, however, introduce DMA
* issues (e.g. floppy DMA transfer overrun/underrun).
*/ */
if (pr->power.bm_activity & cx->demotion.threshold.bm) { if (pr->power.bm_activity & cx->demotion.threshold.bm) {
__sti(); __sti();
...@@ -457,49 +484,41 @@ acpi_processor_idle (void) ...@@ -457,49 +484,41 @@ acpi_processor_idle (void)
* go to an ISR rather than here. Need to instrument * go to an ISR rather than here. Need to instrument
* base interrupt handler. * base interrupt handler.
*/ */
time_elapsed = 0xFFFFFFFF; sleep_ticks = 0xFFFFFFFF;
break; break;
case ACPI_STATE_C2: case ACPI_STATE_C2:
/* See how long we're asleep for */ /* Get start time (ticks) */
start_ticks = inl(acpi_fadt.Xpm_tmr_blk.address); t1 = inl(acpi_fadt.Xpm_tmr_blk.address);
/* Invoke C2 */ /* Invoke C2 */
inb(pr->power.states[ACPI_STATE_C2].address); inb(pr->power.states[ACPI_STATE_C2].address);
/* Dummy op - must do something useless after P_LVL2 read */ /* Dummy op - must do something useless after P_LVL2 read */
end_ticks = inl(acpi_fadt.Xpm_tmr_blk.address); t2 = inl(acpi_fadt.Xpm_tmr_blk.address);
/* Compute time elapsed */ /* Get end time (ticks) */
end_ticks = inl(acpi_fadt.Xpm_tmr_blk.address); t2 = inl(acpi_fadt.Xpm_tmr_blk.address);
/* Re-enable interrupts */ /* Re-enable interrupts */
__sti(); __sti();
/* /* Compute time (ticks) that we were actually asleep */
* Compute the amount of time asleep (in the Cx state). sleep_ticks = ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD;
* TBD: Convert to PM timer ticks initially to avoid having
* to do the math (acpi_get_timer_duration).
*/
acpi_get_timer_duration(start_ticks, end_ticks, &time_elapsed);
break; break;
case ACPI_STATE_C3: case ACPI_STATE_C3:
/* Disable bus master arbitration */ /* Disable bus master arbitration */
acpi_hw_bit_register_write(ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK); acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK);
/* See how long we're asleep for */ /* Get start time (ticks) */
start_ticks = inl(acpi_fadt.Xpm_tmr_blk.address); t1 = inl(acpi_fadt.Xpm_tmr_blk.address);
/* Invoke C3 */ /* Invoke C3 */
inb(pr->power.states[ACPI_STATE_C3].address); inb(pr->power.states[ACPI_STATE_C3].address);
/* Dummy op - must do something useless after P_LVL3 read */ /* Dummy op - must do something useless after P_LVL3 read */
end_ticks = inl(acpi_fadt.Xpm_tmr_blk.address); t2 = inl(acpi_fadt.Xpm_tmr_blk.address);
/* Compute time elapsed */ /* Get end time (ticks) */
end_ticks = inl(acpi_fadt.Xpm_tmr_blk.address); t2 = inl(acpi_fadt.Xpm_tmr_blk.address);
/* Enable bus master arbitration */ /* Enable bus master arbitration */
acpi_hw_bit_register_write(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK); acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK);
/* Re-enable interrupts */ /* Re-enable interrupts */
__sti(); __sti();
/* /* Compute time (ticks) that we were actually asleep */
* Compute the amount of time asleep (in the Cx state). sleep_ticks = ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD;
* TBD: Convert to PM timer ticks initially to avoid having
* to do the math (acpi_get_timer_duration).
*/
acpi_get_timer_duration(start_ticks, end_ticks, &time_elapsed);
break; break;
default: default:
...@@ -517,7 +536,7 @@ acpi_processor_idle (void) ...@@ -517,7 +536,7 @@ acpi_processor_idle (void)
* mastering activity may prevent promotions. * mastering activity may prevent promotions.
*/ */
if (cx->promotion.state) { if (cx->promotion.state) {
if (time_elapsed >= cx->promotion.threshold.time) { if (sleep_ticks > cx->promotion.threshold.ticks) {
cx->promotion.count++; cx->promotion.count++;
cx->demotion.count = 0; cx->demotion.count = 0;
if (cx->promotion.count >= cx->promotion.threshold.count) { if (cx->promotion.count >= cx->promotion.threshold.count) {
...@@ -539,11 +558,10 @@ acpi_processor_idle (void) ...@@ -539,11 +558,10 @@ acpi_processor_idle (void)
* Demotion? * Demotion?
* --------- * ---------
* Track the number of shorts (time asleep is less than time threshold) * Track the number of shorts (time asleep is less than time threshold)
* and demote when the usage threshold is reached. Note that bus * and demote when the usage threshold is reached.
* mastering demotions are checked prior to state transitions (above).
*/ */
if (cx->demotion.state) { if (cx->demotion.state) {
if (time_elapsed < cx->demotion.threshold.time) { if (sleep_ticks < cx->demotion.threshold.ticks) {
cx->demotion.count++; cx->demotion.count++;
cx->promotion.count = 0; cx->promotion.count = 0;
if (cx->demotion.count >= cx->demotion.threshold.count) { if (cx->demotion.count >= cx->demotion.threshold.count) {
...@@ -598,18 +616,18 @@ acpi_processor_set_power_policy ( ...@@ -598,18 +616,18 @@ acpi_processor_set_power_policy (
* Set the default C1 promotion and C2 demotion policies, where we * Set the default C1 promotion and C2 demotion policies, where we
* promote from C1 to C2 after several (10) successive C1 transitions, * promote from C1 to C2 after several (10) successive C1 transitions,
* as we cannot (currently) measure the time spent in C1. Demote from * as we cannot (currently) measure the time spent in C1. Demote from
* C2 to C1 after experiencing several (3) 'shorts' (time spent in C2 * C2 to C1 after experiencing several (4) 'shorts' (time spent in C2
* is less than the C2 transtional latency). * is less than the C2 transtion latency).
*/ */
if (pr->power.states[ACPI_STATE_C2].valid) { if (pr->power.states[ACPI_STATE_C2].valid) {
pr->power.states[ACPI_STATE_C1].promotion.threshold.count = 10; pr->power.states[ACPI_STATE_C1].promotion.threshold.count = 10;
pr->power.states[ACPI_STATE_C1].promotion.threshold.time = pr->power.states[ACPI_STATE_C1].promotion.threshold.ticks =
pr->power.states[ACPI_STATE_C2].latency; pr->power.states[ACPI_STATE_C2].latency_ticks;
pr->power.states[ACPI_STATE_C1].promotion.state = ACPI_STATE_C2; pr->power.states[ACPI_STATE_C1].promotion.state = ACPI_STATE_C2;
pr->power.states[ACPI_STATE_C2].demotion.threshold.count = 3; pr->power.states[ACPI_STATE_C2].demotion.threshold.count = 4;
pr->power.states[ACPI_STATE_C2].demotion.threshold.time = pr->power.states[ACPI_STATE_C2].demotion.threshold.ticks =
pr->power.states[ACPI_STATE_C2].latency; pr->power.states[ACPI_STATE_C2].latency_ticks;
pr->power.states[ACPI_STATE_C2].demotion.state = ACPI_STATE_C1; pr->power.states[ACPI_STATE_C2].demotion.state = ACPI_STATE_C1;
} }
...@@ -617,21 +635,21 @@ acpi_processor_set_power_policy ( ...@@ -617,21 +635,21 @@ acpi_processor_set_power_policy (
* C2/C3 * C2/C3
* ----- * -----
* Set default C2 promotion and C3 demotion policies, where we promote * Set default C2 promotion and C3 demotion policies, where we promote
* from C2 to C3 after 4 cycles (0x0F) of no bus mastering activity * from C2 to C3 after several (4) cycles of no bus mastering activity
* (while maintaining sleep time criteria). Demote immediately on a * while maintaining sleep time criteria. Demote immediately on a
* short or whenever bus mastering activity occurs. * short or whenever bus mastering activity occurs.
*/ */
if ((pr->power.states[ACPI_STATE_C2].valid) && if ((pr->power.states[ACPI_STATE_C2].valid) &&
(pr->power.states[ACPI_STATE_C3].valid)) { (pr->power.states[ACPI_STATE_C3].valid)) {
pr->power.states[ACPI_STATE_C2].promotion.threshold.count = 1; pr->power.states[ACPI_STATE_C2].promotion.threshold.count = 4;
pr->power.states[ACPI_STATE_C2].promotion.threshold.time = pr->power.states[ACPI_STATE_C2].promotion.threshold.ticks =
pr->power.states[ACPI_STATE_C3].latency; pr->power.states[ACPI_STATE_C3].latency_ticks;
pr->power.states[ACPI_STATE_C2].promotion.threshold.bm = 0x0F; pr->power.states[ACPI_STATE_C2].promotion.threshold.bm = 0x0F;
pr->power.states[ACPI_STATE_C2].promotion.state = ACPI_STATE_C3; pr->power.states[ACPI_STATE_C2].promotion.state = ACPI_STATE_C3;
pr->power.states[ACPI_STATE_C3].demotion.threshold.count = 1; pr->power.states[ACPI_STATE_C3].demotion.threshold.count = 1;
pr->power.states[ACPI_STATE_C3].demotion.threshold.time = pr->power.states[ACPI_STATE_C3].demotion.threshold.ticks =
pr->power.states[ACPI_STATE_C3].latency; pr->power.states[ACPI_STATE_C3].latency_ticks;
pr->power.states[ACPI_STATE_C3].demotion.threshold.bm = 0x0F; pr->power.states[ACPI_STATE_C3].demotion.threshold.bm = 0x0F;
pr->power.states[ACPI_STATE_C3].demotion.state = ACPI_STATE_C2; pr->power.states[ACPI_STATE_C3].demotion.state = ACPI_STATE_C2;
} }
...@@ -700,9 +718,13 @@ acpi_processor_get_power_info ( ...@@ -700,9 +718,13 @@ acpi_processor_get_power_info (
"C2 not supported in SMP mode\n")); "C2 not supported in SMP mode\n"));
/* /*
* Otherwise we've met all of our C2 requirements. * Otherwise we've met all of our C2 requirements.
* Normalize the C2 latency to expidite policy.
*/ */
else else {
pr->power.states[ACPI_STATE_C2].valid = 1; pr->power.states[ACPI_STATE_C2].valid = 1;
pr->power.states[ACPI_STATE_C2].latency_ticks =
US_TO_PM_TIMER_TICKS(acpi_fadt.plvl2_lat);
}
} }
/* /*
...@@ -750,12 +772,15 @@ acpi_processor_get_power_info ( ...@@ -750,12 +772,15 @@ acpi_processor_get_power_info (
"C3 not supported on PIIX4 with Type-F DMA\n")); "C3 not supported on PIIX4 with Type-F DMA\n"));
} }
/* /*
* Otherwise we've met all of our C3 requirements. Enable * Otherwise we've met all of our C3 requirements.
* Normalize the C2 latency to expidite policy. Enable
* checking of bus mastering status (bm_check) so we can * checking of bus mastering status (bm_check) so we can
* use this in our C3 policy. * use this in our C3 policy.
*/ */
else { else {
pr->power.states[ACPI_STATE_C3].valid = 1; pr->power.states[ACPI_STATE_C3].valid = 1;
pr->power.states[ACPI_STATE_C3].latency_ticks =
US_TO_PM_TIMER_TICKS(acpi_fadt.plvl3_lat);
pr->flags.bm_check = 1; pr->flags.bm_check = 1;
} }
} }
...@@ -769,7 +794,7 @@ acpi_processor_get_power_info ( ...@@ -769,7 +794,7 @@ acpi_processor_get_power_info (
* not on AC). * not on AC).
*/ */
result = acpi_processor_set_power_policy(pr); result = acpi_processor_set_power_policy(pr);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
/* /*
...@@ -1095,15 +1120,15 @@ acpi_processor_get_performance_info ( ...@@ -1095,15 +1120,15 @@ acpi_processor_get_performance_info (
} }
result = acpi_processor_get_performance_control(pr); result = acpi_processor_get_performance_control(pr);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
result = acpi_processor_get_performance_states(pr); result = acpi_processor_get_performance_states(pr);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
result = acpi_processor_get_platform_limit(pr); result = acpi_processor_get_platform_limit(pr);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
/* /*
...@@ -1319,19 +1344,19 @@ acpi_processor_get_throttling_info ( ...@@ -1319,19 +1344,19 @@ acpi_processor_get_throttling_info (
*/ */
result = acpi_processor_get_throttling(pr); result = acpi_processor_get_throttling(pr);
if (0 != result) if (result)
goto end; goto end;
if (pr->throttling.state) { if (pr->throttling.state) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabling throttling (was T%d)\n", ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabling throttling (was T%d)\n",
pr->throttling.state)); pr->throttling.state));
result = acpi_processor_set_throttling(pr, 0); result = acpi_processor_set_throttling(pr, 0);
if (0 != result) if (result)
goto end; goto end;
} }
end: end:
if (0 != result) if (result)
pr->flags.throttling = 0; pr->flags.throttling = 0;
return_VALUE(result); return_VALUE(result);
...@@ -1366,7 +1391,7 @@ acpi_processor_apply_limit ( ...@@ -1366,7 +1391,7 @@ acpi_processor_apply_limit (
px = pr->limit.thermal.px; px = pr->limit.thermal.px;
result = acpi_processor_set_performance(pr, px); result = acpi_processor_set_performance(pr, px);
if (0 != result) if (result)
goto end; goto end;
} }
...@@ -1377,7 +1402,7 @@ acpi_processor_apply_limit ( ...@@ -1377,7 +1402,7 @@ acpi_processor_apply_limit (
tx = pr->limit.thermal.tx; tx = pr->limit.thermal.tx;
result = acpi_processor_set_throttling(pr, tx); result = acpi_processor_set_throttling(pr, tx);
if (0 != result) if (result)
goto end; goto end;
} }
...@@ -1390,7 +1415,7 @@ acpi_processor_apply_limit ( ...@@ -1390,7 +1415,7 @@ acpi_processor_apply_limit (
pr->limit.state.tx)); pr->limit.state.tx));
end: end:
if (0 != result) if (result)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n")); ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n"));
return_VALUE(result); return_VALUE(result);
...@@ -1415,7 +1440,7 @@ acpi_processor_set_thermal_limit ( ...@@ -1415,7 +1440,7 @@ acpi_processor_set_thermal_limit (
return_VALUE(-EINVAL); return_VALUE(-EINVAL);
result = acpi_bus_get_device(handle, &device); result = acpi_bus_get_device(handle, &device);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
pr = (struct acpi_processor *) acpi_driver_data(device); pr = (struct acpi_processor *) acpi_driver_data(device);
...@@ -1487,7 +1512,7 @@ acpi_processor_set_thermal_limit ( ...@@ -1487,7 +1512,7 @@ acpi_processor_set_thermal_limit (
pr->limit.thermal.tx = tx; pr->limit.thermal.tx = tx;
result = acpi_processor_apply_limit(pr); result = acpi_processor_apply_limit(pr);
if (0 != result) if (result)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to set thermal limit\n")); "Unable to set thermal limit\n"));
...@@ -1519,9 +1544,6 @@ acpi_processor_get_limit_info ( ...@@ -1519,9 +1544,6 @@ acpi_processor_get_limit_info (
FS Interface (/proc) FS Interface (/proc)
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
struct proc_dir_entry *acpi_processor_dir = NULL; struct proc_dir_entry *acpi_processor_dir = NULL;
static int static int
...@@ -1677,7 +1699,7 @@ acpi_processor_read_performance ( ...@@ -1677,7 +1699,7 @@ acpi_processor_read_performance (
p += sprintf(p, "states:\n"); p += sprintf(p, "states:\n");
for (i=0; i<pr->performance.state_count; i++) for (i=0; i<pr->performance.state_count; i++)
p += sprintf(p, " %cP%d: %d Mhz, %d mW, %d uS\n", p += sprintf(p, " %cP%d: %d MHz, %d mW, %d uS\n",
(i == pr->performance.state?'*':' '), i, (i == pr->performance.state?'*':' '), i,
(u32) pr->performance.states[i].core_frequency, (u32) pr->performance.states[i].core_frequency,
(u32) pr->performance.states[i].power, (u32) pr->performance.states[i].power,
...@@ -1718,7 +1740,7 @@ acpi_processor_write_performance ( ...@@ -1718,7 +1740,7 @@ acpi_processor_write_performance (
result = acpi_processor_set_performance(pr, result = acpi_processor_set_performance(pr,
simple_strtoul(state_string, NULL, 0)); simple_strtoul(state_string, NULL, 0));
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
return_VALUE(count); return_VALUE(count);
...@@ -1805,7 +1827,7 @@ acpi_processor_write_throttling ( ...@@ -1805,7 +1827,7 @@ acpi_processor_write_throttling (
result = acpi_processor_set_throttling(pr, result = acpi_processor_set_throttling(pr,
simple_strtoul(state_string, NULL, 0)); simple_strtoul(state_string, NULL, 0));
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
return_VALUE(count); return_VALUE(count);
...@@ -2118,13 +2140,13 @@ acpi_processor_notify ( ...@@ -2118,13 +2140,13 @@ acpi_processor_notify (
if (!pr) if (!pr)
return_VOID; return_VOID;
if (0 != acpi_bus_get_device(pr->handle, &device)) if (acpi_bus_get_device(pr->handle, &device))
return_VOID; return_VOID;
switch (event) { switch (event) {
case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
result = acpi_processor_get_platform_limit(pr); result = acpi_processor_get_platform_limit(pr);
if (0 == result) if (!result)
acpi_processor_apply_limit(pr); acpi_processor_apply_limit(pr);
acpi_bus_generate_event(device, event, acpi_bus_generate_event(device, event,
...@@ -2169,11 +2191,11 @@ acpi_processor_add ( ...@@ -2169,11 +2191,11 @@ acpi_processor_add (
acpi_driver_data(device) = pr; acpi_driver_data(device) = pr;
result = acpi_processor_get_info(pr); result = acpi_processor_get_info(pr);
if (0 != result) if (result)
goto end; goto end;
result = acpi_processor_add_fs(device); result = acpi_processor_add_fs(device);
if (0 != result) if (result)
goto end; goto end;
status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
...@@ -2209,7 +2231,7 @@ acpi_processor_add ( ...@@ -2209,7 +2231,7 @@ acpi_processor_add (
printk(")\n"); printk(")\n");
end: end:
if (0 != result) { if (result) {
acpi_processor_remove_fs(device); acpi_processor_remove_fs(device);
kfree(pr); kfree(pr);
} }
...@@ -2266,7 +2288,7 @@ acpi_processor_init (void) ...@@ -2266,7 +2288,7 @@ acpi_processor_init (void)
memset(&errata, 0, sizeof(errata)); memset(&errata, 0, sizeof(errata));
result = acpi_bus_register_driver(&acpi_processor_driver); result = acpi_bus_register_driver(&acpi_processor_driver);
if (0 > result) if (result < 0)
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
return_VALUE(0); return_VALUE(0);
...@@ -2281,7 +2303,7 @@ acpi_processor_exit (void) ...@@ -2281,7 +2303,7 @@ acpi_processor_exit (void)
ACPI_FUNCTION_TRACE("acpi_processor_exit"); ACPI_FUNCTION_TRACE("acpi_processor_exit");
result = acpi_bus_unregister_driver(&acpi_processor_driver); result = acpi_bus_unregister_driver(&acpi_processor_driver);
if (0 == result) if (!result)
remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
return_VOID; return_VOID;
......
/* /*
* acpi_system.c - ACPI System Driver ($Revision: 45 $) * acpi_system.c - ACPI System Driver ($Revision: 57 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/ */
#define ACPI_C
#include <linux/config.h> #include <linux/config.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -32,6 +34,9 @@ ...@@ -32,6 +34,9 @@
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/sysrq.h> #include <linux/sysrq.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include <linux/irq.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/suspend.h> #include <linux/suspend.h>
...@@ -185,7 +190,7 @@ acpi_system_save_state( ...@@ -185,7 +190,7 @@ acpi_system_save_state(
#endif #endif
/* flush caches */ /* flush caches */
wbinvd(); ACPI_FLUSH_CPU_CACHE();
/* Do arch specific saving of state. */ /* Do arch specific saving of state. */
if (state > ACPI_STATE_S1) { if (state > ACPI_STATE_S1) {
...@@ -255,25 +260,37 @@ acpi_system_suspend( ...@@ -255,25 +260,37 @@ acpi_system_suspend(
u32 state) u32 state)
{ {
acpi_status status = AE_ERROR; acpi_status status = AE_ERROR;
#if 0
unsigned long flags = 0; unsigned long flags = 0;
/* this is very broken, so don't do anything until it's fixed */
save_flags(flags); save_flags(flags);
switch (state) switch (state)
{ {
case ACPI_STATE_S1: case ACPI_STATE_S1:
barrier(); /* do nothing */
status = acpi_enter_sleep_state(state);
break; break;
case ACPI_STATE_S2: case ACPI_STATE_S2:
case ACPI_STATE_S3: case ACPI_STATE_S3:
do_suspend_magic(0); save_processor_context();
/* TODO: this is horribly broken, fix it */
/* TODO: inline this function in acpi_suspend,or something. */
break; break;
} }
acpi_restore_register_state(); barrier();
status = acpi_enter_sleep_state(state);
acpi_sleep_done:
restore_processor_context();
fix_processor_context();
restore_flags(flags); restore_flags(flags);
#endif
printk("ACPI: ACPI-based suspend currently broken, aborting\n");
return status; return status;
} }
...@@ -294,8 +311,6 @@ acpi_suspend ( ...@@ -294,8 +311,6 @@ acpi_suspend (
if (state < ACPI_STATE_S1 || state > ACPI_STATE_S5) if (state < ACPI_STATE_S1 || state > ACPI_STATE_S5)
return AE_ERROR; return AE_ERROR;
freeze_processes();
/* do we have a wakeup address for S2 and S3? */ /* do we have a wakeup address for S2 and S3? */
if (state == ACPI_STATE_S2 || state == ACPI_STATE_S3) { if (state == ACPI_STATE_S2 || state == ACPI_STATE_S3) {
if (!acpi_wakeup_address) if (!acpi_wakeup_address)
...@@ -311,7 +326,7 @@ acpi_suspend ( ...@@ -311,7 +326,7 @@ acpi_suspend (
/* disable interrupts and flush caches */ /* disable interrupts and flush caches */
ACPI_DISABLE_IRQS(); ACPI_DISABLE_IRQS();
wbinvd(); ACPI_FLUSH_CPU_CACHE();
/* perform OS-specific sleep actions */ /* perform OS-specific sleep actions */
status = acpi_system_suspend(state); status = acpi_system_suspend(state);
...@@ -329,8 +344,6 @@ acpi_suspend ( ...@@ -329,8 +344,6 @@ acpi_suspend (
/* reset firmware waking vector */ /* reset firmware waking vector */
acpi_set_firmware_waking_vector((ACPI_PHYSICAL_ADDRESS) 0); acpi_set_firmware_waking_vector((ACPI_PHYSICAL_ADDRESS) 0);
thaw_processes();
return status; return status;
} }
...@@ -341,10 +354,6 @@ acpi_suspend ( ...@@ -341,10 +354,6 @@ acpi_suspend (
FS Interface (/proc) FS Interface (/proc)
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
static int static int
acpi_system_read_info ( acpi_system_read_info (
char *page, char *page,
...@@ -423,40 +432,45 @@ acpi_system_read_event ( ...@@ -423,40 +432,45 @@ acpi_system_read_event (
loff_t *ppos) loff_t *ppos)
{ {
int result = 0; int result = 0;
char outbuf[ACPI_MAX_STRING];
int size = 0;
struct acpi_bus_event event; struct acpi_bus_event event;
static char str[ACPI_MAX_STRING];
static int chars_remaining = 0;
static char *ptr;
ACPI_FUNCTION_TRACE("acpi_system_read_event"); ACPI_FUNCTION_TRACE("acpi_system_read_event");
memset(&event, 0, sizeof(struct acpi_bus_event)); if (!chars_remaining) {
memset(&event, 0, sizeof(struct acpi_bus_event));
if (count < ACPI_MAX_STRING) if ((file->f_flags & O_NONBLOCK)
goto end; && (list_empty(&acpi_bus_event_list)))
return_VALUE(-EAGAIN);
if ((file->f_flags & O_NONBLOCK) result = acpi_bus_receive_event(&event);
&& (list_empty(&acpi_bus_event_list))) if (result) {
return_VALUE(-EAGAIN); return_VALUE(-EIO);
}
result = acpi_bus_receive_event(&event); chars_remaining = sprintf(str, "%s %s %08x %08x\n",
if (0 != result) { event.device_class?event.device_class:"<unknown>",
size = sprintf(outbuf, "error\n"); event.bus_id?event.bus_id:"<unknown>",
goto end; event.type, event.data);
ptr = str;
} }
size = sprintf(outbuf, "%s %s %08x %08x\n", if (chars_remaining < count) {
event.device_class?event.device_class:"<unknown>", count = chars_remaining;
event.bus_id?event.bus_id:"<unknown>", }
event.type,
event.data);
end: if (copy_to_user(buffer, ptr, count))
if (copy_to_user(buffer, outbuf, size))
return_VALUE(-EFAULT); return_VALUE(-EFAULT);
*ppos += size; *ppos += count;
chars_remaining -= count;
ptr += count;
return_VALUE(size); return_VALUE(count);
} }
static int static int
...@@ -709,6 +723,7 @@ acpi_system_write_sleep ( ...@@ -709,6 +723,7 @@ acpi_system_write_sleep (
if (!system->states[state]) if (!system->states[state])
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
#ifdef CONFIG_SOFTWARE_SUSPEND #ifdef CONFIG_SOFTWARE_SUSPEND
if (state == 4) { if (state == 4) {
software_suspend(); software_suspend();
...@@ -777,6 +792,30 @@ acpi_system_read_alarm ( ...@@ -777,6 +792,30 @@ acpi_system_read_alarm (
BCD_TO_BIN(mo); BCD_TO_BIN(mo);
BCD_TO_BIN(yr); BCD_TO_BIN(yr);
#if 0
/* we're trusting the FADT (see above)*/
#else
/* If we're not trusting the FADT, we should at least make it
* right for _this_ century... ehm, what is _this_ century?
*
* TBD:
* ASAP: find piece of code in the kernel, e.g. star tracker driver,
* which we can trust to determine the century correctly. Atom
* watch driver would be nice, too...
*
* if that has not happened, change for first release in 2050:
* if (yr<50)
* yr += 2100;
* else
* yr += 2000; // current line of code
*
* if that has not happened either, please do on 2099/12/31:23:59:59
* s/2000/2100
*
*/
yr += 2000;
#endif
p += sprintf(p,"%4.4u-", yr); p += sprintf(p,"%4.4u-", yr);
p += (mo > 12) ? sprintf(p, "**-") : sprintf(p, "%2.2u-", mo); p += (mo > 12) ? sprintf(p, "**-") : sprintf(p, "%2.2u-", mo);
p += (day > 31) ? sprintf(p, "** ") : sprintf(p, "%2.2u ", day); p += (day > 31) ? sprintf(p, "** ") : sprintf(p, "%2.2u ", day);
...@@ -979,7 +1018,7 @@ acpi_system_write_alarm ( ...@@ -979,7 +1018,7 @@ acpi_system_write_alarm (
spin_unlock_irq(&rtc_lock); spin_unlock_irq(&rtc_lock);
acpi_hw_bit_register_write(ACPI_BITREG_RT_CLOCK_ENABLE, 1, ACPI_MTX_LOCK); acpi_set_register(ACPI_BITREG_RT_CLOCK_ENABLE, 1, ACPI_MTX_LOCK);
file->f_pos += count; file->f_pos += count;
...@@ -1181,35 +1220,36 @@ acpi_system_add ( ...@@ -1181,35 +1220,36 @@ acpi_system_add (
acpi_driver_data(device) = system; acpi_driver_data(device) = system;
result = acpi_system_add_fs(device); result = acpi_system_add_fs(device);
if (0 != result) if (result)
goto end; goto end;
printk(KERN_INFO PREFIX "%s [%s] (supports", printk(KERN_INFO PREFIX "%s [%s] (supports",
acpi_device_name(device), acpi_device_bid(device)); acpi_device_name(device), acpi_device_bid(device));
for (i=0; i<ACPI_S_STATE_COUNT; i++) { for (i=0; i<ACPI_S_STATE_COUNT; i++) {
u8 type_a, type_b; u8 type_a, type_b;
status = acpi_hw_get_sleep_type_data(i, &type_a, &type_b); status = acpi_get_sleep_type_data(i, &type_a, &type_b);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
system->states[i] = 1; system->states[i] = 1;
printk(" S%d", i); printk(" S%d", i);
} }
} }
printk(")\n"); printk(")\n");
#ifdef CONFIG_SOFTWARE_SUSPEND
printk(KERN_INFO "Software suspend => we can do S4.");
system->states[4] = 1;
#endif
#ifdef CONFIG_PM #ifdef CONFIG_PM
/* Install the soft-off (S5) handler. */ /* Install the soft-off (S5) handler. */
if (system->states[ACPI_STATE_S5]) { if (system->states[ACPI_STATE_S5]) {
pm_power_off = acpi_power_off; pm_power_off = acpi_power_off;
register_sysrq_key('o', &sysrq_acpi_poweroff_op); register_sysrq_key('o', &sysrq_acpi_poweroff_op);
/* workaround: some systems don't claim S4 support, but they
do support S5 (power-down). That is all we need, so
indicate support. */
system->states[ACPI_STATE_S4] = 1;
} }
#endif #endif
end: end:
if (0 != result) if (result)
kfree(system); kfree(system);
return_VALUE(result); return_VALUE(result);
...@@ -1254,7 +1294,7 @@ acpi_system_init (void) ...@@ -1254,7 +1294,7 @@ acpi_system_init (void)
ACPI_FUNCTION_TRACE("acpi_system_init"); ACPI_FUNCTION_TRACE("acpi_system_init");
result = acpi_bus_register_driver(&acpi_system_driver); result = acpi_bus_register_driver(&acpi_system_driver);
if (0 > result) if (result < 0)
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
return_VALUE(0); return_VALUE(0);
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/errno.h>
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/err.h>
#define PREFIX "ACPI: " #define PREFIX "ACPI: "
...@@ -73,8 +73,6 @@ static struct acpi_table_sdt sdt; ...@@ -73,8 +73,6 @@ static struct acpi_table_sdt sdt;
acpi_madt_entry_handler madt_handlers[ACPI_MADT_ENTRY_COUNT]; acpi_madt_entry_handler madt_handlers[ACPI_MADT_ENTRY_COUNT];
struct acpi_boot_flags acpi_boot = {1, 0}; /* Enabled by default */
void void
acpi_table_print ( acpi_table_print (
...@@ -88,12 +86,12 @@ acpi_table_print ( ...@@ -88,12 +86,12 @@ acpi_table_print (
/* Some table signatures aren't good table names */ /* Some table signatures aren't good table names */
if (0 == strncmp((char *) &header->signature, if (!strncmp((char *) &header->signature,
acpi_table_signatures[ACPI_APIC], acpi_table_signatures[ACPI_APIC],
sizeof(header->signature))) { sizeof(header->signature))) {
name = "MADT"; name = "MADT";
} }
else if (0 == strncmp((char *) &header->signature, else if (!strncmp((char *) &header->signature,
acpi_table_signatures[ACPI_FACP], acpi_table_signatures[ACPI_FACP],
sizeof(header->signature))) { sizeof(header->signature))) {
name = "FADT"; name = "FADT";
...@@ -166,8 +164,8 @@ acpi_table_print_madt_entry ( ...@@ -166,8 +164,8 @@ acpi_table_print_madt_entry (
{ {
struct acpi_table_lapic_addr_ovr *p = struct acpi_table_lapic_addr_ovr *p =
(struct acpi_table_lapic_addr_ovr*) header; (struct acpi_table_lapic_addr_ovr*) header;
printk(KERN_INFO PREFIX "LAPIC_ADDR_OVR (address[0x%016Lx])\n", printk(KERN_INFO PREFIX "LAPIC_ADDR_OVR (address[%p])\n",
p->address); (void *) (unsigned long) p->address);
} }
break; break;
...@@ -175,8 +173,8 @@ acpi_table_print_madt_entry ( ...@@ -175,8 +173,8 @@ acpi_table_print_madt_entry (
{ {
struct acpi_table_iosapic *p = struct acpi_table_iosapic *p =
(struct acpi_table_iosapic*) header; (struct acpi_table_iosapic*) header;
printk(KERN_INFO PREFIX "IOSAPIC (id[0x%x] global_irq_base[0x%x] address[0x%016Lx])\n", printk(KERN_INFO PREFIX "IOSAPIC (id[0x%x] global_irq_base[0x%x] address[%p])\n",
p->id, p->global_irq_base, p->address); p->id, p->global_irq_base, (void *) (unsigned long) p->address);
} }
break; break;
...@@ -409,7 +407,7 @@ acpi_table_get_sdt ( ...@@ -409,7 +407,7 @@ acpi_table_get_sdt (
acpi_table_print(header, sdt.entry[i].pa); acpi_table_print(header, sdt.entry[i].pa);
if (0 != acpi_table_compute_checksum(header, header->length)) { if (acpi_table_compute_checksum(header, header->length)) {
printk(KERN_WARNING " >>> ERROR: Invalid checksum\n"); printk(KERN_WARNING " >>> ERROR: Invalid checksum\n");
continue; continue;
} }
...@@ -417,7 +415,7 @@ acpi_table_get_sdt ( ...@@ -417,7 +415,7 @@ acpi_table_get_sdt (
sdt.entry[i].size = header->length; sdt.entry[i].size = header->length;
for (id = 0; id < ACPI_TABLE_COUNT; id++) { for (id = 0; id < ACPI_TABLE_COUNT; id++) {
if (0 == strncmp((char *) &header->signature, if (!strncmp((char *) &header->signature,
acpi_table_signatures[id], acpi_table_signatures[id],
sizeof(header->signature))) { sizeof(header->signature))) {
sdt.entry[i].id = id; sdt.entry[i].id = id;
...@@ -429,44 +427,6 @@ acpi_table_get_sdt ( ...@@ -429,44 +427,6 @@ acpi_table_get_sdt (
} }
static void __init
acpi_table_parse_cmdline (
char *cmdline)
{
char *p = NULL;
/* NOTE: We're called too early in the boot process to use __setup */
if (!cmdline || !(p = strstr(cmdline, "acpi_boot=")))
return;
p += 10;
while (*p && (*p != ' ')) {
if (0 == memcmp(p, "madt", 4)) {
printk(KERN_INFO PREFIX "MADT processing enabled\n");
acpi_boot.madt = 1;
p += 4;
}
else if (0 == memcmp(p, "on", 2)) {
printk(KERN_INFO PREFIX "Boot-time table processing enabled\n");
acpi_boot.madt = 1;
p += 2;
}
else if (0 == memcmp(p, "off", 2)) {
printk(KERN_INFO PREFIX "Boot-time table processing disabled\n");
acpi_boot.madt = 0;
p += 3;
}
else
p++;
if (*p == ',')
p ++;
}
}
int __init int __init
acpi_table_init ( acpi_table_init (
char *cmdline) char *cmdline)
...@@ -478,11 +438,10 @@ acpi_table_init ( ...@@ -478,11 +438,10 @@ acpi_table_init (
memset(&sdt, 0, sizeof(struct acpi_table_sdt)); memset(&sdt, 0, sizeof(struct acpi_table_sdt));
memset(&madt_handlers, 0, sizeof(madt_handlers)); memset(&madt_handlers, 0, sizeof(madt_handlers));
acpi_table_parse_cmdline(cmdline);
/* Locate and map the Root System Description Table (RSDP) */ /* Locate and map the Root System Description Table (RSDP) */
if ((0 != acpi_find_rsdp(&rsdp_phys)) || !rsdp_phys) { rsdp_phys = acpi_find_rsdp();
if (!rsdp_phys) {
printk(KERN_ERR PREFIX "Unable to locate RSDP\n"); printk(KERN_ERR PREFIX "Unable to locate RSDP\n");
return -ENODEV; return -ENODEV;
} }
...@@ -501,15 +460,16 @@ acpi_table_init ( ...@@ -501,15 +460,16 @@ acpi_table_init (
else else
result = acpi_table_compute_checksum(rsdp, ((struct acpi20_table_rsdp *)rsdp)->length); result = acpi_table_compute_checksum(rsdp, ((struct acpi20_table_rsdp *)rsdp)->length);
if (0 != result) { if (result) {
printk(KERN_WARNING " >>> ERROR: Invalid checksum\n"); printk(KERN_WARNING " >>> ERROR: Invalid checksum\n");
return -ENODEV; return -ENODEV;
} }
/* Locate and map the System Description table (RSDT/XSDT) */ /* Locate and map the System Description table (RSDT/XSDT) */
if (0 != acpi_table_get_sdt(rsdp)) if (acpi_table_get_sdt(rsdp))
return -ENODEV; return -ENODEV;
return 0; return 0;
} }
/* /*
* acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 36 $) * acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 39 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/kmod.h> #include <linux/kmod.h>
#include "acpi_bus.h" #include "acpi_bus.h"
...@@ -399,7 +401,7 @@ acpi_thermal_critical ( ...@@ -399,7 +401,7 @@ acpi_thermal_critical (
tz->trips.critical.flags.enabled = 0; tz->trips.critical.flags.enabled = 0;
result = acpi_bus_get_device(tz->handle, &device); result = acpi_bus_get_device(tz->handle, &device);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_CRITICAL, tz->trips.critical.flags.enabled); acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_CRITICAL, tz->trips.critical.flags.enabled);
...@@ -430,7 +432,7 @@ acpi_thermal_hot ( ...@@ -430,7 +432,7 @@ acpi_thermal_hot (
tz->trips.hot.flags.enabled = 0; tz->trips.hot.flags.enabled = 0;
result = acpi_bus_get_device(tz->handle, &device); result = acpi_bus_get_device(tz->handle, &device);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT, tz->trips.hot.flags.enabled); acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT, tz->trips.hot.flags.enabled);
...@@ -497,7 +499,7 @@ acpi_thermal_passive ( ...@@ -497,7 +499,7 @@ acpi_thermal_passive (
result = acpi_processor_set_thermal_limit( result = acpi_processor_set_thermal_limit(
passive->devices.handles[i], passive->devices.handles[i],
ACPI_PROCESSOR_LIMIT_DECREMENT); ACPI_PROCESSOR_LIMIT_DECREMENT);
if (1 == result) { if (result == 1) {
tz->trips.passive.flags.enabled = 0; tz->trips.passive.flags.enabled = 0;
ACPI_DEBUG_PRINT((ACPI_DB_INFO, ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Disabling passive cooling (zone is cool)\n")); "Disabling passive cooling (zone is cool)\n"));
...@@ -539,7 +541,7 @@ acpi_thermal_active ( ...@@ -539,7 +541,7 @@ acpi_thermal_active (
if (!active->flags.enabled) { if (!active->flags.enabled) {
for (j = 0; j < active->devices.count; j++) { for (j = 0; j < active->devices.count; j++) {
result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D0); result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D0);
if (0 != result) { if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to turn cooling device [%p] 'on'\n", active->devices.handles[j])); ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to turn cooling device [%p] 'on'\n", active->devices.handles[j]));
continue; continue;
} }
...@@ -557,7 +559,7 @@ acpi_thermal_active ( ...@@ -557,7 +559,7 @@ acpi_thermal_active (
else if (active->flags.enabled) { else if (active->flags.enabled) {
for (j = 0; j < active->devices.count; j++) { for (j = 0; j < active->devices.count; j++) {
result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D3); result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D3);
if (0 != result) { if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to turn cooling device [%p] 'off'\n", active->devices.handles[j])); ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to turn cooling device [%p] 'off'\n", active->devices.handles[j]));
continue; continue;
} }
...@@ -598,7 +600,7 @@ acpi_thermal_check ( ...@@ -598,7 +600,7 @@ acpi_thermal_check (
} }
result = acpi_thermal_get_temperature(tz); result = acpi_thermal_get_temperature(tz);
if (0 != result) if (result)
return_VOID; return_VOID;
memset(&tz->state, 0, sizeof(tz->state)); memset(&tz->state, 0, sizeof(tz->state));
...@@ -696,9 +698,6 @@ acpi_thermal_check ( ...@@ -696,9 +698,6 @@ acpi_thermal_check (
FS Interface (/proc) FS Interface (/proc)
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
struct proc_dir_entry *acpi_thermal_dir = NULL; struct proc_dir_entry *acpi_thermal_dir = NULL;
...@@ -768,7 +767,7 @@ acpi_thermal_read_temperature ( ...@@ -768,7 +767,7 @@ acpi_thermal_read_temperature (
goto end; goto end;
result = acpi_thermal_get_temperature(tz); result = acpi_thermal_get_temperature(tz);
if (0 != result) if (result)
goto end; goto end;
p += sprintf(p, "temperature: %lu C\n", p += sprintf(p, "temperature: %lu C\n",
...@@ -914,7 +913,7 @@ acpi_thermal_write_cooling_mode ( ...@@ -914,7 +913,7 @@ acpi_thermal_write_cooling_mode (
result = acpi_thermal_set_cooling_mode(tz, result = acpi_thermal_set_cooling_mode(tz,
simple_strtoul(mode_string, NULL, 0)); simple_strtoul(mode_string, NULL, 0));
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
return_VALUE(count); return_VALUE(count);
...@@ -984,7 +983,7 @@ acpi_thermal_write_polling ( ...@@ -984,7 +983,7 @@ acpi_thermal_write_polling (
seconds = simple_strtoul(polling_string, NULL, 0); seconds = simple_strtoul(polling_string, NULL, 0);
result = acpi_thermal_set_polling(tz, seconds); result = acpi_thermal_set_polling(tz, seconds);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
acpi_thermal_check(tz); acpi_thermal_check(tz);
...@@ -1115,7 +1114,7 @@ acpi_thermal_notify ( ...@@ -1115,7 +1114,7 @@ acpi_thermal_notify (
if (!tz) if (!tz)
return_VOID; return_VOID;
if (0 != acpi_bus_get_device(tz->handle, &device)) if (acpi_bus_get_device(tz->handle, &device))
return_VOID; return_VOID;
switch (event) { switch (event) {
...@@ -1155,17 +1154,17 @@ acpi_thermal_get_info ( ...@@ -1155,17 +1154,17 @@ acpi_thermal_get_info (
/* Get temperature [_TMP] (required) */ /* Get temperature [_TMP] (required) */
result = acpi_thermal_get_temperature(tz); result = acpi_thermal_get_temperature(tz);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
/* Set the cooling mode [_SCP] to active cooling (default) */ /* Set the cooling mode [_SCP] to active cooling (default) */
result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
if (0 == result) if (!result)
tz->flags.cooling_mode = 1; tz->flags.cooling_mode = 1;
/* Get trip points [_CRT, _PSV, etc.] (required) */ /* Get trip points [_CRT, _PSV, etc.] (required) */
result = acpi_thermal_get_trip_points(tz); result = acpi_thermal_get_trip_points(tz);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
/* Get default polling frequency [_TZP] (optional) */ /* Get default polling frequency [_TZP] (optional) */
...@@ -1176,7 +1175,7 @@ acpi_thermal_get_info ( ...@@ -1176,7 +1175,7 @@ acpi_thermal_get_info (
/* Get devices in this thermal zone [_TZD] (optional) */ /* Get devices in this thermal zone [_TZD] (optional) */
result = acpi_thermal_get_devices(tz); result = acpi_thermal_get_devices(tz);
if (0 == result) if (!result)
tz->flags.devices = 1; tz->flags.devices = 1;
return_VALUE(0); return_VALUE(0);
...@@ -1208,11 +1207,11 @@ acpi_thermal_add ( ...@@ -1208,11 +1207,11 @@ acpi_thermal_add (
acpi_driver_data(device) = tz; acpi_driver_data(device) = tz;
result = acpi_thermal_get_info(tz); result = acpi_thermal_get_info(tz);
if (0 != result) if (result)
goto end; goto end;
result = acpi_thermal_add_fs(device); result = acpi_thermal_add_fs(device);
if (0 != result) if (result)
return_VALUE(result); return_VALUE(result);
acpi_thermal_check(tz); acpi_thermal_check(tz);
...@@ -1292,7 +1291,7 @@ acpi_thermal_init (void) ...@@ -1292,7 +1291,7 @@ acpi_thermal_init (void)
ACPI_FUNCTION_TRACE("acpi_thermal_init"); ACPI_FUNCTION_TRACE("acpi_thermal_init");
result = acpi_bus_register_driver(&acpi_thermal_driver); result = acpi_bus_register_driver(&acpi_thermal_driver);
if (0 > result) if (result < 0)
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
return_VALUE(0); return_VALUE(0);
...@@ -1307,7 +1306,7 @@ acpi_thermal_exit (void) ...@@ -1307,7 +1306,7 @@ acpi_thermal_exit (void)
ACPI_FUNCTION_TRACE("acpi_thermal_exit"); ACPI_FUNCTION_TRACE("acpi_thermal_exit");
result = acpi_bus_unregister_driver(&acpi_thermal_driver); result = acpi_bus_unregister_driver(&acpi_thermal_driver);
if (0 == result) if (!result)
remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
return_VOID; return_VOID;
......
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