/*
- * 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>
#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"
FS Interface (/proc)
-------------------------------------------------------------------------- */
-#include <linux/compatmac.h>
-#include <linux/proc_fs.h>
-
struct proc_dir_entry *acpi_ac_dir = NULL;
static int
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;
}
if (!ac)
return;
- if (0 != acpi_bus_get_device(ac->handle, &device))
+ if (acpi_bus_get_device(ac->handle, &device))
return_VOID;
switch (event) {
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,
ac->state?"on-line":"off-line");
end:
- if (0 != result) {
+ if (result) {
acpi_ac_remove_fs(device);
kfree(ac);
}
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);
}
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>
#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>
#include "acpi_bus.h"
-#define ACPI_DRIVER_VERSION 0x20020404
#define ACPI_MAX_STRING 80
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"
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"
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"
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>
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>
#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"
end:
kfree(buffer.pointer);
- if (0 == result)
+ if (!result)
(*bif) = (struct acpi_battery_info *) data.pointer;
return_VALUE(result);
end:
kfree(buffer.pointer);
- if (0 == result)
+ if (!result)
(*bst) = (struct acpi_battery_status *) data.pointer;
return_VALUE(result);
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? */
/* 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;
FS Interface (/proc)
-------------------------------------------------------------------------- */
-#include <linux/compatmac.h>
-#include <linux/proc_fs.h>
-
struct proc_dir_entry *acpi_battery_dir = NULL;
static int
/* 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;
}
/* 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;
}
result = acpi_battery_set_alarm(battery,
simple_strtoul(alarm_string, NULL, 0));
- if (0 != result)
+ if (result)
return_VALUE(result);
return_VALUE(count);
if (!battery)
return_VOID;
- if (0 != acpi_bus_get_device(handle, &device))
+ if (acpi_bus_get_device(handle, &device))
return_VOID;
switch (event) {
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,
device->status.battery_present?"present":"absent");
end:
- if (0 != result) {
+ if (result) {
acpi_battery_remove_fs(device);
kfree(battery);
}
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);
}
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>
*
#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))
{"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? */
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;
}
else if (device->power.flags.power_resources) {
result = acpi_power_get_inferred_state(device);
- if (0 != result)
+ if (result)
return_VALUE(result);
}
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))
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) {
}
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
/* Status Change? */
result = acpi_bus_check_device(device, &status_changed);
- if (0 != result)
+ if (result)
return_VALUE(result);
if (!status_changed)
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) {
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;
}
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;
}
return_VALUE(-ENOSYS);
result = driver->ops.add(device);
- if (0 != result) {
+ if (result) {
device->driver = NULL;
acpi_driver_data(device) = NULL;
return_VALUE(result);
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);
}
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);
return_VALUE(-ENOSYS);
result = driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
- if (0 != result)
+ if (result)
return_VALUE(result);
device->driver = NULL;
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;
* present and properly initialized.
*/
result = acpi_bus_get_flags(device);
- if (0 != result)
+ if (result)
goto end;
/*
switch (type) {
case ACPI_BUS_TYPE_DEVICE:
result = acpi_bus_get_status(device);
- if (0 != result)
+ if (result)
goto end;
break;
default:
*/
if (device->flags.power_manageable) {
result = acpi_bus_get_power_flags(device);
- if (0 != result)
+ if (result)
goto end;
}
*/
if (device->flags.performance_manageable) {
result = acpi_bus_get_perf_flags(device);
- if (0 != result)
+ if (result)
goto end;
}
acpi_bus_find_driver(device);
end:
- if (0 != result) {
+ if (result) {
kfree(device);
return_VALUE(result);
}
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");
* 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)) {
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.
*/
*/
result = acpi_bus_add(&acpi_root, NULL, ACPI_ROOT_OBJECT,
ACPI_BUS_TYPE_SYSTEM);
- if (0 != result)
+ if (result)
goto end;
progress++;
/*
* [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);
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 */
#endif
result = acpi_bus_init();
- if (0 != result)
+ if (result)
return_VALUE(result);
#ifdef CONFIG_PM
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>
#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"
FS Interface (/proc)
-------------------------------------------------------------------------- */
-#include <linux/compatmac.h>
-#include <linux/proc_fs.h>
-
static struct proc_dir_entry *acpi_button_dir = NULL;
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;
}
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)
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) {
acpi_device_name(device), acpi_device_bid(device));
end:
- if (0 != result) {
+ if (result) {
acpi_button_remove_fs(device);
kfree(button);
}
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>
#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"
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);
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",
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);
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);
FS Interface (/proc)
-------------------------------------------------------------------------- */
-#include <linux/compatmac.h>
-#include <linux/proc_fs.h>
-
struct proc_dir_entry *acpi_ec_dir = NULL;
}
result = acpi_ec_add_fs(device);
- if (0 != result)
+ if (result)
goto end;
printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
(u32) ec->gpe_bit);
end:
- if (0 != result)
+ if (result)
kfree(ec);
return_VALUE(result);
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);
}
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>
#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"
FS Interface (/proc)
-------------------------------------------------------------------------- */
-#include <linux/compatmac.h>
-#include <linux/proc_fs.h>
-
struct proc_dir_entry *acpi_fan_dir = NULL;
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",
result = acpi_bus_set_power(fan->handle,
simple_strtoul(state_string, NULL, 0));
- if (0 != result)
+ if (result)
return_VALUE(result);
return_VALUE(count);
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",
!device->power.state?"on":"off");
end:
- if (0 != result)
+ if (result)
kfree(fan);
return_VALUE(result);
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);
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>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
#ifdef CONFIG_ACPI_EFI
#include <asm/efi.h>
+u64 efi_mem_attributes (u64 phys_addr);
#endif
#ifdef _IA64
* 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;
}
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*/
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;
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)
{
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;
}
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 (
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 (
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>
#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"
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);
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;
ACPI_FUNCTION_TRACE("acpi_power_on");
result = acpi_power_get_context(handle, &resource);
- if (0 != result)
+ if (result)
return_VALUE(result);
resource->references++;
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;
ACPI_FUNCTION_TRACE("acpi_power_off");
result = acpi_power_get_context(handle, &resource);
- if (0 != result)
+ if (result)
return_VALUE(result);
if (resource->references)
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;
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) {
*/
for (i=0; i<tl->count; i++) {
result = acpi_power_on(tl->handles[i]);
- if (0 != result)
+ if (result)
goto end;
}
*/
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));
FS Interface (/proc)
-------------------------------------------------------------------------- */
-#include <linux/compatmac.h>
-#include <linux/proc_fs.h>
-
struct proc_dir_entry *acpi_power_dir = NULL;
resource->order = acpi_object.power_resource.resource_order;
result = acpi_power_get_state(resource);
- if (0 != result)
+ if (result)
goto end;
switch (resource->state) {
}
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);
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);
}
/* 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>
* 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>
#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"
#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
int state;
struct {
u32 time;
+ u32 ticks;
u32 count;
u32 bm;
} threshold;
u8 valid;
u32 address;
u32 latency;
+ u32 latency_ticks;
u32 power;
u32 usage;
struct acpi_processor_cx_policy promotion;
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,
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;
}
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;
}
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)
* 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
|| (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();
* 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:
* 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) {
* 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) {
* 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;
}
* 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;
}
"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);
+ }
}
/*
"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;
}
}
* not on AC).
*/
result = acpi_processor_set_power_policy(pr);
- if (0 != result)
+ if (result)
return_VALUE(result);
/*
}
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);
/*
*/
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);
px = pr->limit.thermal.px;
result = acpi_processor_set_performance(pr, px);
- if (0 != result)
+ if (result)
goto end;
}
tx = pr->limit.thermal.tx;
result = acpi_processor_set_throttling(pr, tx);
- if (0 != result)
+ if (result)
goto end;
}
pr->limit.state.tx));
end:
- if (0 != result)
+ if (result)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n"));
return_VALUE(result);
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);
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"));
FS Interface (/proc)
-------------------------------------------------------------------------- */
-#include <linux/compatmac.h>
-#include <linux/proc_fs.h>
-
struct proc_dir_entry *acpi_processor_dir = NULL;
static int
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,
result = acpi_processor_set_performance(pr,
simple_strtoul(state_string, NULL, 0));
- if (0 != result)
+ if (result)
return_VALUE(result);
return_VALUE(count);
result = acpi_processor_set_throttling(pr,
simple_strtoul(state_string, NULL, 0));
- if (0 != result)
+ if (result)
return_VALUE(result);
return_VALUE(count);
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,
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,
printk(")\n");
end:
- if (0 != result) {
+ if (result) {
acpi_processor_remove_fs(device);
kfree(pr);
}
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);
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>
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
+#define ACPI_C
+
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#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>
#endif
/* flush caches */
- wbinvd();
+ ACPI_FLUSH_CPU_CACHE();
/* Do arch specific saving of state. */
if (state > ACPI_STATE_S1) {
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;
}
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)
/* disable interrupts and flush caches */
ACPI_DISABLE_IRQS();
- wbinvd();
+ ACPI_FLUSH_CPU_CACHE();
/* perform OS-specific sleep actions */
status = acpi_system_suspend(state);
/* reset firmware waking vector */
acpi_set_firmware_waking_vector((ACPI_PHYSICAL_ADDRESS) 0);
- thaw_processes();
-
return status;
}
FS Interface (/proc)
-------------------------------------------------------------------------- */
-#include <linux/compatmac.h>
-#include <linux/proc_fs.h>
-
-
static int
acpi_system_read_info (
char *page,
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
if (!system->states[state])
return_VALUE(-ENODEV);
+
#ifdef CONFIG_SOFTWARE_SUSPEND
if (state == 4) {
software_suspend();
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);
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;
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);
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);
#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: "
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 (
/* 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";
{
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;
{
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;
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;
}
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;
}
-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)
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;
}
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>
#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"
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);
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);
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"));
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;
}
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;
}
}
result = acpi_thermal_get_temperature(tz);
- if (0 != result)
+ if (result)
return_VOID;
memset(&tz->state, 0, sizeof(tz->state));
FS Interface (/proc)
-------------------------------------------------------------------------- */
-#include <linux/compatmac.h>
-#include <linux/proc_fs.h>
-
struct proc_dir_entry *acpi_thermal_dir = NULL;
goto end;
result = acpi_thermal_get_temperature(tz);
- if (0 != result)
+ if (result)
goto end;
p += sprintf(p, "temperature: %lu C\n",
result = acpi_thermal_set_cooling_mode(tz,
simple_strtoul(mode_string, NULL, 0));
- if (0 != result)
+ if (result)
return_VALUE(result);
return_VALUE(count);
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);
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) {
/* 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) */
/* 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);
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);
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);
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;