Commit 412743bb authored by Andy Grover's avatar Andy Grover Committed by Linus Torvalds

[PATCH] ACPI patch 6/9

This removes the old OSPM code. It lived under drivers/acpi/ospm/*, but
the new code just lives in drivers/acpi, and removes some unnecessary
abstraction that this old code had.
parent 90679878
This diff is collapsed.
#
# Makefile for the Linux OSPM code.
#
O_TARGET := $(notdir $(CURDIR)).o
ACPI_CFLAGS += -I$(CURDIR)/include
EXTRA_CFLAGS += $(ACPI_CFLAGS)
subdir-$(CONFIG_ACPI_BUSMGR) += busmgr
subdir-$(CONFIG_ACPI_EC) += ec
subdir-$(CONFIG_ACPI_SYS) += system
subdir-$(CONFIG_ACPI_CPU) += processor
subdir-$(CONFIG_ACPI_CMBATT) += battery
subdir-$(CONFIG_ACPI_AC) += ac_adapter
subdir-$(CONFIG_ACPI_BUTTON) += button
subdir-$(CONFIG_ACPI_THERMAL) += thermal
obj-y += $(foreach dir,$(subdir-y),$(dir)/ospm_$(dir).o)
include $(TOPDIR)/Rules.make
O_TARGET := ospm_$(notdir $(CURDIR)).o
obj-m := $(O_TARGET)
EXTRA_CFLAGS += $(ACPI_CFLAGS)
obj-y := $(patsubst %.c,%.o,$(wildcard *.c))
include $(TOPDIR)/Rules.make
/*****************************************************************************
*
* Module Name: ac.c
* $Revision: 23 $
*
*****************************************************************************/
/*
* Copyright (C) 2000, 2001 Andrew Grover
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <acpi.h>
#include "ac.h"
#define _COMPONENT ACPI_AC_ADAPTER
MODULE_NAME ("ac")
/****************************************************************************
* Internal Functions
****************************************************************************/
/****************************************************************************
*
* FUNCTION: ac_print
*
* PARAMETERS:
*
* RETURN:
*
* DESCRIPTION: Prints out information on a specific ac_adapter.
*
****************************************************************************/
void
ac_print (
AC_CONTEXT *ac_adapter)
{
#ifdef ACPI_DEBUG
acpi_buffer buffer;
PROC_NAME("ac_print");
if (!ac_adapter) {
return;
}
buffer.length = 256;
buffer.pointer = acpi_os_callocate(buffer.length);
if (!buffer.pointer) {
return;
}
/*
* Get the full pathname for this ACPI object.
*/
acpi_get_name(ac_adapter->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
/*
* Print out basic adapter information.
*/
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| AC Adapter[%02x]:[%p] %s\n", ac_adapter->device_handle, ac_adapter->acpi_handle, (char*)buffer.pointer));
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
acpi_os_free(buffer.pointer);
#endif /*ACPI_DEBUG*/
return;
}
/****************************************************************************
*
* FUNCTION: ac_add_device
*
* PARAMETERS:
*
* RETURN:
*
* DESCRIPTION:
*
****************************************************************************/
acpi_status
ac_add_device(
BM_HANDLE device_handle,
void **context)
{
acpi_status status = AE_OK;
BM_DEVICE *device = NULL;
AC_CONTEXT *ac_adapter = NULL;
acpi_device_info info;
FUNCTION_TRACE("ac_add_device");
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Adding ac_adapter device [%02x].\n", device_handle));
if (!context || *context) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context."));
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/*
* Get information on this device.
*/
status = bm_get_device_info(device_handle, &device);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/*
* Allocate a new AC_CONTEXT structure.
*/
ac_adapter = acpi_os_callocate(sizeof(AC_CONTEXT));
if (!ac_adapter) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
ac_adapter->device_handle = device->handle;
ac_adapter->acpi_handle = device->acpi_handle;
/*
* Get information on this object.
*/
status = acpi_get_object_info(ac_adapter->acpi_handle, &info);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to get object info for ac_adapter device."));
goto end;
}
/*
* _UID?
* -----
*/
if (info.valid & ACPI_VALID_UID) {
strncpy(ac_adapter->uid, info.unique_id, sizeof(info.unique_id));
}
else {
strncpy(ac_adapter->uid, "0", sizeof("0"));
}
/*
* _STA?
* -----
*/
if (!(info.valid & ACPI_VALID_STA)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Must have valid _STA.\n"));
status = AE_ERROR;
goto end;
}
status = ac_osl_add_device(ac_adapter);
if (ACPI_FAILURE(status)) {
goto end;
}
*context = ac_adapter;
ac_print(ac_adapter);
end:
if (ACPI_FAILURE(status)) {
acpi_os_free(ac_adapter);
}
return_ACPI_STATUS(status);
}
/****************************************************************************
*
* FUNCTION: ac_remove_device
*
* PARAMETERS:
*
* RETURN:
*
* DESCRIPTION:
*
****************************************************************************/
acpi_status
ac_remove_device (
void **context)
{
acpi_status status = AE_OK;
AC_CONTEXT *ac_adapter = NULL;
FUNCTION_TRACE("ac_remove_device");
if (!context || !*context) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
ac_adapter = (AC_CONTEXT*)*context;
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing ac_adapter device [%02x].\n", ac_adapter->device_handle));
ac_osl_remove_device(ac_adapter);
acpi_os_free(ac_adapter);
*context = NULL;
return_ACPI_STATUS(status);
}
/****************************************************************************
* External Functions
****************************************************************************/
/****************************************************************************
*
* FUNCTION: ac_initialize
*
* PARAMETERS: <none>
*
* RETURN:
*
* DESCRIPTION:
*
****************************************************************************/
acpi_status
ac_initialize (void)
{
acpi_status status = AE_OK;
BM_DEVICE_ID criteria;
BM_DRIVER driver;
FUNCTION_TRACE("ac_initialize");
MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
MEMSET(&driver, 0, sizeof(BM_DRIVER));
driver.notify = &ac_notify;
driver.request = &ac_request;
/*
* Register driver for AC Adapter devices.
*/
MEMCPY(criteria.hid, AC_HID_AC_ADAPTER, sizeof(AC_HID_AC_ADAPTER));
status = bm_register_driver(&criteria, &driver);
return_ACPI_STATUS(status);
}
/****************************************************************************
*
* FUNCTION: ac_terminate
*
* PARAMETERS: <none>
*
* RETURN:
*
* DESCRIPTION:
*
****************************************************************************/
acpi_status
ac_terminate (void)
{
acpi_status status = AE_OK;
BM_DEVICE_ID criteria;
BM_DRIVER driver;
FUNCTION_TRACE("ac_terminate");
MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
MEMSET(&driver, 0, sizeof(BM_DRIVER));
/*
* Unregister driver for AC Adapter devices.
*/
MEMCPY(criteria.hid, AC_HID_AC_ADAPTER, sizeof(AC_HID_AC_ADAPTER));
driver.notify = &ac_notify;
driver.request = &ac_request;
status = bm_unregister_driver(&criteria, &driver);
return_ACPI_STATUS(status);
}
/*****************************************************************************
*
* FUNCTION: ac_notify
*
* PARAMETERS: <none>
*
* RETURN:
*
* DESCRIPTION:
*
****************************************************************************/
acpi_status
ac_notify (
BM_NOTIFY notify_type,
BM_HANDLE device_handle,
void **context)
{
acpi_status status = AE_OK;
FUNCTION_TRACE("ac_notify");
if (!context) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
switch (notify_type) {
case BM_NOTIFY_DEVICE_ADDED:
status = ac_add_device(device_handle, context);
break;
case BM_NOTIFY_DEVICE_REMOVED:
status = ac_remove_device(context);
break;
case AC_NOTIFY_STATUS_CHANGE:
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status change event detected.\n"));
status = ac_osl_generate_event(notify_type,
((AC_CONTEXT*)*context));
break;
default:
status = AE_SUPPORT;
break;
}
return_ACPI_STATUS(status);
}
/****************************************************************************
*
* FUNCTION: ac_request
*
* PARAMETERS:
*
* RETURN:
*
* DESCRIPTION:
*
****************************************************************************/
acpi_status
ac_request (
BM_REQUEST *request,
void *context)
{
acpi_status status = AE_OK;
FUNCTION_TRACE("ac_request");
/*
* Must have a valid request structure and context.
*/
if (!request || !context) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/*
* Handle Request:
* ---------------
*/
switch (request->command) {
default:
status = AE_SUPPORT;
break;
}
request->status = status;
return_ACPI_STATUS(status);
}
/*****************************************************************************
*
* Module Name: ac_osl.c
* $Revision: 10 $
*
*****************************************************************************/
/*
* Copyright (C) 2000, 2001 Andrew Grover
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <acpi.h>
#include "ac.h"
MODULE_AUTHOR("Andrew Grover");
MODULE_DESCRIPTION("ACPI Component Architecture (CA) - AC Adapter Driver");
MODULE_LICENSE("GPL");
#define AC_PROC_ROOT "ac_adapter"
#define AC_PROC_STATUS "status"
#define AC_ON_LINE "on-line"
#define AC_OFF_LINE "off-line"
extern struct proc_dir_entry *bm_proc_root;
static struct proc_dir_entry *ac_proc_root = NULL;
/****************************************************************************
*
* FUNCTION: ac_osl_proc_read_status
*
****************************************************************************/
static int
ac_osl_proc_read_status (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *context)
{
acpi_status status = AE_OK;
AC_CONTEXT *ac_adapter = NULL;
char *p = page;
int len;
if (!context) {
goto end;
}
ac_adapter = (AC_CONTEXT*)context;
/* don't get status more than once for a single proc read */
if (off != 0) {
goto end;
}
status = bm_evaluate_simple_integer(ac_adapter->acpi_handle,
"_PSR", &(ac_adapter->is_online));
if (ACPI_FAILURE(status)) {
p += sprintf(p, "Error reading AC Adapter status\n");
goto end;
}
if (ac_adapter->is_online) {
p += sprintf(p, "Status: %s\n",
AC_ON_LINE);
}
else {
p += sprintf(p, "Status: %s\n",
AC_OFF_LINE);
}
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return(len);
}
/****************************************************************************
*
* FUNCTION: ac_osl_add_device
*
****************************************************************************/
acpi_status
ac_osl_add_device(
AC_CONTEXT *ac_adapter)
{
struct proc_dir_entry *proc_entry = NULL;
if (!ac_adapter) {
return(AE_BAD_PARAMETER);
}
printk(KERN_INFO "ACPI: AC Adapter found\n");
proc_entry = proc_mkdir(ac_adapter->uid, ac_proc_root);
if (!proc_entry) {
return(AE_ERROR);
}
create_proc_read_entry(AC_PROC_STATUS, S_IFREG | S_IRUGO,
proc_entry, ac_osl_proc_read_status, (void*)ac_adapter);
return(AE_OK);
}
/****************************************************************************
*
* FUNCTION: ac_osl_remove_device
*
****************************************************************************/
acpi_status
ac_osl_remove_device (
AC_CONTEXT *ac_adapter)
{
char proc_entry[64];
if (!ac_adapter) {
return(AE_BAD_PARAMETER);
}
sprintf(proc_entry, "%s/%s", ac_adapter->uid, AC_PROC_STATUS);
remove_proc_entry(proc_entry, ac_proc_root);
sprintf(proc_entry, "%s", ac_adapter->uid);
remove_proc_entry(proc_entry, ac_proc_root);
return(AE_OK);
}
/****************************************************************************
*
* FUNCTION: ac_osl_generate_event
*
****************************************************************************/
acpi_status
ac_osl_generate_event (
u32 event,
AC_CONTEXT *ac_adapter)
{
acpi_status status = AE_OK;
if (!ac_adapter) {
return(AE_BAD_PARAMETER);
}
switch (event) {
case AC_NOTIFY_STATUS_CHANGE:
status = bm_osl_generate_event(ac_adapter->device_handle,
AC_PROC_ROOT, ac_adapter->uid, event, 0);
break;
default:
return(AE_BAD_PARAMETER);
break;
}
return(status);
}
/****************************************************************************
*
* FUNCTION: ac_osl_init
*
* PARAMETERS: <none>
*
* RETURN: 0: Success
*
* DESCRIPTION: Module initialization.
*
****************************************************************************/
static int __init
ac_osl_init (void)
{
acpi_status status = AE_OK;
ac_proc_root = proc_mkdir(AC_PROC_ROOT, bm_proc_root);
if (!ac_proc_root) {
status = AE_ERROR;
}
else {
status = ac_initialize();
if (ACPI_FAILURE(status)) {
remove_proc_entry(AC_PROC_ROOT, bm_proc_root);
}
}
return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
}
/****************************************************************************
*
* FUNCTION: ac_osl_cleanup
*
* PARAMETERS: <none>
*
* RETURN: <none>
*
* DESCRIPTION: Module cleanup.
*
****************************************************************************/
static void __exit
ac_osl_cleanup (void)
{
ac_terminate();
if (ac_proc_root) {
remove_proc_entry(AC_PROC_ROOT, bm_proc_root);
}
return;
}
module_init(ac_osl_init);
module_exit(ac_osl_cleanup);
O_TARGET := ospm_$(notdir $(CURDIR)).o
obj-m := $(O_TARGET)
EXTRA_CFLAGS += $(ACPI_CFLAGS)
obj-y := $(patsubst %.c,%.o,$(wildcard *.c))
include $(TOPDIR)/Rules.make
This diff is collapsed.
This diff is collapsed.
export-objs := bm_osl.o
O_TARGET := ospm_$(notdir $(CURDIR)).o
obj-m := $(O_TARGET)
EXTRA_CFLAGS += $(ACPI_CFLAGS)
obj-y := $(patsubst %.c,%.o,$(wildcard *.c))
include $(TOPDIR)/Rules.make
This diff is collapsed.
/*****************************************************************************
*
* Module Name: bm_osl.c
* $Revision: 17 $
*
*****************************************************************************/
/*
* Copyright (C) 2000, 2001 Andrew Grover
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <linux/spinlock.h>
#include <linux/poll.h>
#include <asm/uaccess.h>
#include <acpi.h>
#include "bm.h"
MODULE_AUTHOR("Andrew Grover");
MODULE_DESCRIPTION("ACPI Component Architecture (CA) - ACPI Bus Manager");
MODULE_LICENSE("GPL");
/*****************************************************************************
* Types & Defines
*****************************************************************************/
typedef struct
{
BM_HANDLE device_handle;
char *device_type;
char *device_instance;
u32 event_type;
u32 event_data;
struct list_head list;
} BM_OSL_EVENT;
#define BM_PROC_ROOT "acpi"
#define BM_PROC_EVENT "event"
#define BM_PROC_DEVICES "devices"
#define BM_MAX_STRING_LENGTH 80
/****************************************************************************
* Globals
****************************************************************************/
struct proc_dir_entry *bm_proc_root = NULL;
static struct proc_dir_entry *bm_proc_event = NULL;
#ifdef ACPI_DEBUG
static u32 save_dbg_layer;
static u32 save_dbg_level;
#endif /*ACPI_DEBUG*/
extern BM_NODE_LIST node_list;
static spinlock_t bm_osl_event_lock = SPIN_LOCK_UNLOCKED;
static LIST_HEAD(bm_event_list);
static DECLARE_WAIT_QUEUE_HEAD(bm_event_wait_queue);
static int event_is_open = 0;
/****************************************************************************
* Functions
****************************************************************************/
/****************************************************************************
*
* FUNCTION: bm_osl_generate_event
*
* DESCRIPTION: Generates an event for user-space consumption by writing
* the event data to the 'event' file.
*
****************************************************************************/
acpi_status
bm_osl_generate_event (
BM_HANDLE device_handle,
char *device_type,
char *device_instance,
u32 event_type,
u32 event_data)
{
BM_OSL_EVENT *event = NULL;
u32 flags = 0;
/* drop event on the floor if no one's listening */
if (!event_is_open)
return (AE_OK);
/*
* Allocate a new event structure.
*/
event = acpi_os_callocate(sizeof(BM_OSL_EVENT));
if (!event)
goto alloc_error;
event->device_type = acpi_os_callocate(strlen(device_type)
+ sizeof(char));
if (!event->device_type)
goto alloc_error;
event->device_instance = acpi_os_callocate(strlen(device_instance)
+ sizeof(char));
if (!event->device_instance)
goto alloc_error;
/*
* Set event data.
*/
event->device_handle = device_handle;
strcpy(event->device_type, device_type);
strcpy(event->device_instance, device_instance);
event->event_type = event_type;
event->event_data = event_data;
/*
* Add to the end of our event list.
*/
spin_lock_irqsave(&bm_osl_event_lock, flags);
list_add_tail(&event->list, &bm_event_list);
spin_unlock_irqrestore(&bm_osl_event_lock, flags);
/*
* Signal waiting threads (if any).
*/
wake_up_interruptible(&bm_event_wait_queue);
return(AE_OK);
alloc_error:
if (event->device_instance)
acpi_os_free(event->device_instance);
if (event->device_type)
acpi_os_free(event->device_type);
if (event)
acpi_os_free(event);
return (AE_NO_MEMORY);
}
static int bm_osl_open_event(struct inode *inode, struct file *file)
{
spin_lock_irq (&bm_osl_event_lock);
if(event_is_open)
goto out_busy;
event_is_open = 1;
spin_unlock_irq (&bm_osl_event_lock);
return 0;
out_busy:
spin_unlock_irq (&bm_osl_event_lock);
return -EBUSY;
}
static int bm_osl_close_event(struct inode *inode, struct file *file)
{
event_is_open = 0;
return 0;
}
/****************************************************************************
*
* FUNCTION: bm_osl_read_event
*
* DESCRIPTION: Handles reads to the 'event' file by blocking user-mode
* threads until data (an event) is generated.
*
****************************************************************************/
static ssize_t
bm_osl_read_event(
struct file *file,
char *buf,
size_t count,
loff_t *ppos)
{
BM_OSL_EVENT *event = NULL;
unsigned long flags = 0;
static char str[BM_MAX_STRING_LENGTH];
static int chars_remaining = 0;
static char *ptr;
if (!chars_remaining) {
DECLARE_WAITQUEUE(wait, current);
if (list_empty(&bm_event_list)) {
if (file->f_flags & O_NONBLOCK)
return -EAGAIN;
set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&bm_event_wait_queue, &wait);
if (list_empty(&bm_event_list)) {
schedule();
}
remove_wait_queue(&bm_event_wait_queue, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current)) {
return -ERESTARTSYS;
}
}
spin_lock_irqsave(&bm_osl_event_lock, flags);
event = list_entry(bm_event_list.next, BM_OSL_EVENT, list);
list_del(&event->list);
spin_unlock_irqrestore(&bm_osl_event_lock, flags);
chars_remaining = sprintf(str, "%s %s %08x %08x\n",
event->device_type, event->device_instance,
event->event_type, event->event_data);
ptr = str;
acpi_os_free(event->device_type);
acpi_os_free(event->device_instance);
acpi_os_free(event);
}
if (chars_remaining < count)
count = chars_remaining;
if (copy_to_user(buf, ptr, count))
return -EFAULT;
*ppos += count;
chars_remaining -= count;
ptr += count;
return count;
}
/****************************************************************************
*
* FUNCTION: bm_osl_poll_event
*
* DESCRIPTION: Handles poll() of the 'event' file by blocking user-mode
* threads until data (an event) is generated.
*
****************************************************************************/
static unsigned int
bm_osl_poll_event(
struct file *file,
poll_table *wait)
{
poll_wait(file, &bm_event_wait_queue, wait);
if (!list_empty(&bm_event_list))
return POLLIN | POLLRDNORM;
return 0;
}
struct file_operations proc_event_operations = {
open: bm_osl_open_event,
read: bm_osl_read_event,
release: bm_osl_close_event,
poll: bm_osl_poll_event,
};
/****************************************************************************
*
* FUNCTION: bm_osl_init
*
****************************************************************************/
int
bm_osl_init(void)
{
acpi_status status = AE_OK;
status = acpi_subsystem_status();
if (ACPI_FAILURE(status))
return -ENODEV;
bm_proc_root = proc_mkdir(BM_PROC_ROOT, NULL);
if (!bm_proc_root) {
return(AE_ERROR);
}
bm_proc_event = create_proc_entry(BM_PROC_EVENT, S_IRUSR, bm_proc_root);
if (bm_proc_event) {
bm_proc_event->proc_fops = &proc_event_operations;
}
status = bm_initialize();
return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
}
/****************************************************************************
*
* FUNCTION: bm_osl_cleanup
*
****************************************************************************/
void
bm_osl_cleanup(void)
{
bm_terminate();
if (bm_proc_event) {
remove_proc_entry(BM_PROC_EVENT, bm_proc_root);
bm_proc_event = NULL;
}
if (bm_proc_root) {
remove_proc_entry(BM_PROC_ROOT, NULL);
bm_proc_root = NULL;
}
return;
}
module_init(bm_osl_init);
module_exit(bm_osl_cleanup);
/****************************************************************************
* Symbols
****************************************************************************/
/* bm.c */
EXPORT_SYMBOL(bm_get_node);
/* bmdriver.c */
EXPORT_SYMBOL(bm_get_device_power_state);
EXPORT_SYMBOL(bm_set_device_power_state);
EXPORT_SYMBOL(bm_get_device_info);
EXPORT_SYMBOL(bm_get_device_status);
EXPORT_SYMBOL(bm_get_device_context);
EXPORT_SYMBOL(bm_register_driver);
EXPORT_SYMBOL(bm_unregister_driver);
/* bmsearch.c */
EXPORT_SYMBOL(bm_search);
/* bmrequest.c */
EXPORT_SYMBOL(bm_request);
/* bmutils.c */
EXPORT_SYMBOL(bm_extract_package_data);
EXPORT_SYMBOL(bm_evaluate_object);
EXPORT_SYMBOL(bm_evaluate_simple_integer);
EXPORT_SYMBOL(bm_evaluate_reference_list);
EXPORT_SYMBOL(bm_copy_to_buffer);
EXPORT_SYMBOL(bm_cast_buffer);
/* bm_proc.c */
EXPORT_SYMBOL(bm_osl_generate_event);
EXPORT_SYMBOL(bm_proc_root);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/******************************************************************************
*
* Module Name: bmrequest.c
* $Revision: 16 $
*
*****************************************************************************/
/*
* Copyright (C) 2000, 2001 Andrew Grover
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <acpi.h>
#include "bm.h"
#define _COMPONENT ACPI_BUS
MODULE_NAME ("bmrequest")
/****************************************************************************
* External Functions
****************************************************************************/
/****************************************************************************
*
* FUNCTION: bm_generate_request
*
* PARAMETERS:
*
* RETURN:
*
* DESCRIPTION:
*
****************************************************************************/
acpi_status
bm_generate_request (
BM_NODE *node,
BM_REQUEST *request)
{
acpi_status status = AE_OK;
BM_DEVICE *device = NULL;
FUNCTION_TRACE("bm_generate_request");
if (!node || !request) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
device = &(node->device);
if (!BM_IS_DRIVER_CONTROL(device)) {
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No driver installed for device [%02x].\n", device->handle));
return_ACPI_STATUS(AE_NOT_EXIST);
}
status = node->driver.request(request, node->driver.context);
return_ACPI_STATUS(status);
}
/****************************************************************************
*
* FUNCTION: bm_request
*
* PARAMETERS:
*
* RETURN:
*
* DESCRIPTION:
*
****************************************************************************/
acpi_status
bm_request (
BM_REQUEST *request)
{
acpi_status status = AE_OK;
BM_NODE *node = NULL;
BM_DEVICE *device = NULL;
FUNCTION_TRACE("bm_request");
/*
* Must have a valid request structure.
*/
if (!request) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Received request for device [%02x] command [%02x].\n", request->handle, request->command));
/*
* Resolve the node.
*/
status = bm_get_node(request->handle, 0, &node);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
device = &(node->device);
/*
* Device-Specific Request?
* ------------------------
* If a device-specific command (>=0x80) forward this request to
* the appropriate driver.
*/
if (request->command & BM_COMMAND_DEVICE_SPECIFIC) {
status = bm_generate_request(node, request);
return_ACPI_STATUS(status);
}
/*
* Bus-Specific Requests:
* ----------------------
*/
switch (request->command) {
case BM_COMMAND_GET_POWER_STATE:
status = bm_get_power_state(node);
if (ACPI_FAILURE(status)) {
break;
}
status = bm_copy_to_buffer(&(request->buffer),
&(device->power.state), sizeof(BM_POWER_STATE));
break;
case BM_COMMAND_SET_POWER_STATE:
{
BM_POWER_STATE *power_state = NULL;
status = bm_cast_buffer(&(request->buffer),
(void**)&power_state, sizeof(BM_POWER_STATE));
if (ACPI_FAILURE(status)) {
break;
}
status = bm_set_power_state(node, *power_state);
}
break;
default:
status = AE_SUPPORT;
request->status = AE_SUPPORT;
break;
}
return_ACPI_STATUS(status);
}
This diff is collapsed.
This diff is collapsed.
O_TARGET := ospm_$(notdir $(CURDIR)).o
obj-m := $(O_TARGET)
EXTRA_CFLAGS += $(ACPI_CFLAGS)
obj-y := $(patsubst %.c,%.o,$(wildcard *.c))
include $(TOPDIR)/Rules.make
This diff is collapsed.
This diff is collapsed.
O_TARGET := ospm_$(notdir $(CURDIR)).o
obj-m := $(O_TARGET)
EXTRA_CFLAGS += $(ACPI_CFLAGS)
obj-y := $(patsubst %.c,%.o,$(wildcard *.c))
include $(TOPDIR)/Rules.make
/*****************************************************************************
*
* Module Name: ec_osl.c
* $Revision: 11 $
*
*****************************************************************************/
/*
* Copyright (C) 2000, 2001 Andrew Grover
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <acpi.h>
#include <bm.h>
#include "ec.h"
MODULE_AUTHOR("Andrew Grover");
MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Embedded Controller Driver");
MODULE_LICENSE("GPL");
extern struct proc_dir_entry *bm_proc_root;
/****************************************************************************
*
* FUNCTION: ec_osl_init
*
* PARAMETERS: <none>
*
* RETURN: 0: Success
*
* DESCRIPTION: Module initialization.
*
****************************************************************************/
static int __init
ec_osl_init (void)
{
acpi_status status = AE_OK;
/* abort if no busmgr */
if (!bm_proc_root)
return -ENODEV;
status = ec_initialize();
return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
}
/****************************************************************************
*
* FUNCTION: ec_osl_cleanup
*
* PARAMETERS: <none>
*
* RETURN: <none>
*
* DESCRIPTION: Module cleanup.
*
****************************************************************************/
static void __exit
ec_osl_cleanup(void)
{
ec_terminate();
return;
}
module_init(ec_osl_init);
module_exit(ec_osl_cleanup);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
O_TARGET := ospm_$(notdir $(CURDIR)).o
obj-m := $(O_TARGET)
EXTRA_CFLAGS += $(ACPI_CFLAGS)
obj-y := $(patsubst %.c,%.o,$(wildcard *.c))
include $(TOPDIR)/Rules.make
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
O_TARGET := ospm_$(notdir $(CURDIR)).o
obj-m := $(O_TARGET)
EXTRA_CFLAGS += $(ACPI_CFLAGS)
obj-y := $(patsubst %.c,%.o,$(wildcard *.c))
include $(TOPDIR)/Rules.make
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment