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