type
stringclasses
5 values
content
stringlengths
9
163k
defines
#define DP_C_LDOUBLE 3
defines
#define char_to_int(p) (p - '0')
defines
#define MAX(p,q) ((p >= q) ? p : q)
functions
void dopr(char *buffer, size_t maxlen, const char *format, va_list args) { char ch; long value; LDOUBLE fvalue; char *strvalue; int min; int max; int state; int flags; int cflags; size_t currlen; state = DP_S_DEFAULT; currlen = flags = cflags = min = 0; max = -1; ch = *format++; while (s...
functions
else if (ch == '*') { min = va_arg(args, int); ch = *format++; state = DP_S_DOT; }
functions
else if (ch == '*') { max = va_arg(args, int); ch = *format++; state = DP_S_MOD; }
functions
else if (cflags == DP_C_LONG) { long int *num; num = va_arg(args, long int *); *num = currlen; }
functions
void fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max) { int padlen, strln; /* amount to pad */ int cnt = 0; if (value == 0) { value = "<NULL>"; }
functions
void fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags) { int signvalue = 0; unsigned long uvalue; char convert[20]; int place = 0; int spadlen = 0; /* amount to space pad */ int zpadlen = 0; /* amount to zero ...
functions
LDOUBLE abs_val(LDOUBLE value) { LDOUBLE result = value; if (value < 0) result = -value; return result; }
functions
LDOUBLE pow10(int exp) { LDOUBLE result = 1; while (exp) { result *= 10; exp--; }
functions
long round(LDOUBLE value) { long intpart; intpart = value; value = value - intpart; if (value >= 0.5) intpart++; return intpart; }
functions
void fmtfp(char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags) { int signvalue = 0; LDOUBLE ufvalue; char iconvert[20]; char fconvert[20]; int iplace = 0; int fplace = 0; int padlen = 0; /* amount to pad */ int zpadlen = 0; int cap...
functions
void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) { if (*currlen < maxlen) buffer[(*currlen)++] = c; }
functions
int egg_vsnprintf(char *str, size_t count, const char *fmt, va_list args) { str[0] = 0; dopr(str, count, fmt, args); return (strlen(str)); }
includes
#include <linux/kernel.h>
includes
#include <linux/module.h>
includes
#include <linux/init.h>
includes
#include <linux/types.h>
includes
#include <linux/delay.h>
includes
#include <linux/proc_fs.h>
includes
#include <linux/seq_file.h>
includes
#include <linux/interrupt.h>
includes
#include <asm/io.h>
includes
#include <acpi/acpi_bus.h>
includes
#include <acpi/acpi_drivers.h>
includes
#include <acpi/actypes.h>
defines
#define _COMPONENT ACPI_EC_COMPONENT
defines
#define ACPI_EC_COMPONENT 0x00100000
defines
#define ACPI_EC_CLASS "embedded_controller"
defines
#define ACPI_EC_HID "PNP0C09"
defines
#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver"
defines
#define ACPI_EC_DEVICE_NAME "Embedded Controller"
defines
#define ACPI_EC_FILE_INFO "info"
defines
#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
defines
#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
defines
#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
defines
#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
defines
#define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */
defines
#define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */
defines
#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */
defines
#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
defines
#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */
defines
#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */
defines
#define ACPI_EC_COMMAND_READ 0x80
defines
#define ACPI_EC_COMMAND_WRITE 0x81
defines
#define ACPI_EC_BURST_ENABLE 0x82
defines
#define ACPI_EC_BURST_DISABLE 0x83
defines
#define ACPI_EC_COMMAND_QUERY 0x84
defines
#define EC_POLL 0xFF
defines
#define EC_INTR 0x00
functions
u32 acpi_ec_read_status(union acpi_ec *ec) { u32 status = 0; acpi_hw_low_level_read(8, &status, &ec->common.status_addr); return status; }
functions
int acpi_ec_wait(union acpi_ec *ec, u8 event) { if (acpi_ec_poll_mode) return acpi_ec_poll_wait(ec, event); else return acpi_ec_intr_wait(ec, event); }
functions
int acpi_ec_poll_wait(union acpi_ec *ec, u8 event) { u32 acpi_ec_status = 0; u32 i = ACPI_EC_UDELAY_COUNT; if (!ec) return -EINVAL; /* Poll the EC status register waiting for the event to occur. */ switch (event) { case ACPI_EC_EVENT_OBF: do { acpi_hw_low_level_read(8, &acpi_ec_status, &ec->c...
functions
int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event) { int result = 0; ACPI_FUNCTION_TRACE("acpi_ec_wait"); ec->intr.expect_event = event; smp_mb(); switch (event) { case ACPI_EC_EVENT_IBE: if (~acpi_ec_read_status(ec) & event) { ec->intr.expect_event = 0; return_VALUE(0); }
functions
int acpi_ec_enter_burst_mode(union acpi_ec *ec) { u32 tmp = 0; int status = 0; ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode"); status = acpi_ec_read_status(ec); if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); if (status) goto end; acpi_hw_low_lev...
functions
int acpi_ec_leave_burst_mode(union acpi_ec *ec) { int status = 0; ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); status = acpi_ec_read_status(ec); if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){ status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); if(status) goto end; acpi_hw_low_level_write(8, ACPI_E...
functions
int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data) { if (acpi_ec_poll_mode) return acpi_ec_poll_read(ec, address, data); else return acpi_ec_intr_read(ec, address, data); }
functions
int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data) { if (acpi_ec_poll_mode) return acpi_ec_poll_write(ec, address, data); else return acpi_ec_intr_write(ec, address, data); }
functions
int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data) { acpi_status status = AE_OK; int result = 0; unsigned long flags = 0; u32 glk = 0; ACPI_FUNCTION_TRACE("acpi_ec_read"); if (!ec || !data) return_VALUE(-EINVAL); *data = 0; if (ec->common.global_lock) { status = acpi_acquire_global_lock(AC...
functions
int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data) { int result = 0; acpi_status status = AE_OK; unsigned long flags = 0; u32 glk = 0; ACPI_FUNCTION_TRACE("acpi_ec_write"); if (!ec) return_VALUE(-EINVAL); if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk)...
functions
int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data) { int status = 0; u32 glk; ACPI_FUNCTION_TRACE("acpi_ec_read"); if (!ec || !data) return_VALUE(-EINVAL); *data = 0; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) ret...
functions
int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data) { int status = 0; u32 glk; ACPI_FUNCTION_TRACE("acpi_ec_write"); if (!ec) return_VALUE(-EINVAL); if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) return_VALUE(-ENODEV); }
functions
int ec_read(u8 addr, u8 * val) { union acpi_ec *ec; int err; u32 temp_data; if (!first_ec) return -ENODEV; ec = acpi_driver_data(first_ec); err = acpi_ec_read(ec, addr, &temp_data); if (!err) { *val = temp_data; return 0; }
functions
int ec_write(u8 addr, u8 val) { union acpi_ec *ec; int err; if (!first_ec) return -ENODEV; ec = acpi_driver_data(first_ec); err = acpi_ec_write(ec, addr, val); return err; }
functions
int acpi_ec_query(union acpi_ec *ec, u32 * data) { if (acpi_ec_poll_mode) return acpi_ec_poll_query(ec, data); else return acpi_ec_intr_query(ec, data); }
functions
int acpi_ec_poll_query(union acpi_ec *ec, u32 * data) { int result = 0; acpi_status status = AE_OK; unsigned long flags = 0; u32 glk = 0; ACPI_FUNCTION_TRACE("acpi_ec_query"); if (!ec || !data) return_VALUE(-EINVAL); *data = 0; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDEL...
functions
int acpi_ec_intr_query(union acpi_ec *ec, u32 * data) { int status = 0; u32 glk; ACPI_FUNCTION_TRACE("acpi_ec_query"); if (!ec || !data) return_VALUE(-EINVAL); *data = 0; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) return_VALUE(-...
functions
void acpi_ec_gpe_query(void *ec_cxt) { if (acpi_ec_poll_mode) acpi_ec_gpe_poll_query(ec_cxt); else acpi_ec_gpe_intr_query(ec_cxt); }
functions
void acpi_ec_gpe_poll_query(void *ec_cxt) { union acpi_ec *ec = (union acpi_ec *)ec_cxt; u32 value = 0; unsigned long flags = 0; static char object_name[5] = { '_', 'Q', '0', '0', '\0' }
functions
void acpi_ec_gpe_intr_query(void *ec_cxt) { union acpi_ec *ec = (union acpi_ec *)ec_cxt; u32 value; int result = -ENODATA; static char object_name[5] = { '_', 'Q', '0', '0', '\0' }
functions
u32 acpi_ec_gpe_handler(void *data) { if (acpi_ec_poll_mode) return acpi_ec_gpe_poll_handler(data); else return acpi_ec_gpe_intr_handler(data); }
functions
u32 acpi_ec_gpe_poll_handler(void *data) { acpi_status status = AE_OK; union acpi_ec *ec = (union acpi_ec *)data; if (!ec) return ACPI_INTERRUPT_NOT_HANDLED; acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, acpi_ec_gpe_query, ec); if (sta...
functions
u32 acpi_ec_gpe_intr_handler(void *data) { acpi_status status = AE_OK; u32 value; union acpi_ec *ec = (union acpi_ec *)data; if (!ec) return ACPI_INTERRUPT_NOT_HANDLED; acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); value = acpi_ec_read_status(ec); switch (ec->intr.expect_event) { case ACPI_EC_EVENT_O...
functions
acpi_status acpi_ec_space_setup(acpi_handle region_handle, u32 function, void *handler_context, void **return_context) { /* * The EC object is in the handler context and is needed * when calling the acpi_ec_space_handler. */ *return_context = (function != ACPI_REGION_DEACTIVATE) ? handler_context : N...
functions
acpi_status acpi_ec_space_handler(u32 function, acpi_physical_address address, u32 bit_width, acpi_integer * value, void *handler_context, void *region_context) { int result = 0; union acpi_ec *ec = NULL; u64 temp = *value; acpi_integer f_v = 0; int i = 0; ACPI_FUNCTION_TRACE("acp...
functions
int acpi_ec_read_info(struct seq_file *seq, void *offset) { union acpi_ec *ec = (union acpi_ec *)seq->private; ACPI_FUNCTION_TRACE("acpi_ec_read_info"); if (!ec) goto end; seq_printf(seq, "gpe bit: 0x%02x\n", (u32) ec->common.gpe_bit); seq_printf(seq, "ports: 0x%02x, 0x%...
functions
int acpi_ec_info_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_ec_read_info, PDE(inode)->data); }
functions
int acpi_ec_add_fs(struct acpi_device *device) { struct proc_dir_entry *entry = NULL; ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_ec_dir); if (!acpi_device_dir(device)) return_VALUE(-ENODEV); }
functions
int acpi_ec_remove_fs(struct acpi_device *device) { ACPI_FUNCTION_TRACE("acpi_ec_remove_fs"); if (acpi_device_dir(device)) { remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device)); remove_proc_entry(acpi_device_bid(device), acpi_ec_dir); acpi_device_dir(device) = NULL; }
functions
int acpi_ec_poll_add(struct acpi_device *device) { int result = 0; acpi_status status = AE_OK; union acpi_ec *ec = NULL; unsigned long uid; ACPI_FUNCTION_TRACE("acpi_ec_add"); if (!device) return_VALUE(-EINVAL); ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); if (!ec) return_VALUE(-ENOMEM); memset(ec, ...
functions
int acpi_ec_intr_add(struct acpi_device *device) { int result = 0; acpi_status status = AE_OK; union acpi_ec *ec = NULL; unsigned long uid; ACPI_FUNCTION_TRACE("acpi_ec_add"); if (!device) return_VALUE(-EINVAL); ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); if (!ec) return_VALUE(-ENOMEM); memset(ec, ...
functions
int acpi_ec_remove(struct acpi_device *device, int type) { union acpi_ec *ec = NULL; ACPI_FUNCTION_TRACE("acpi_ec_remove"); if (!device) return_VALUE(-EINVAL); ec = acpi_driver_data(device); acpi_ec_remove_fs(device); kfree(ec); return_VALUE(0); }
functions
acpi_status acpi_ec_io_ports(struct acpi_resource *resource, void *context) { union acpi_ec *ec = (union acpi_ec *)context; struct acpi_generic_address *addr; if (resource->type != ACPI_RESOURCE_TYPE_IO) { return AE_OK; }
functions
else if (ec->common.command_addr.register_bit_width == 0) { addr = &ec->common.command_addr; }
functions
int acpi_ec_start(struct acpi_device *device) { acpi_status status = AE_OK; union acpi_ec *ec = NULL; ACPI_FUNCTION_TRACE("acpi_ec_start"); if (!device) return_VALUE(-EINVAL); ec = acpi_driver_data(device); if (!ec) return_VALUE(-EINVAL); /* * Get I/O port addresses. Convert to GAS format. */ statu...
functions
int acpi_ec_stop(struct acpi_device *device, int type) { acpi_status status = AE_OK; union acpi_ec *ec = NULL; ACPI_FUNCTION_TRACE("acpi_ec_stop"); if (!device) return_VALUE(-EINVAL); ec = acpi_driver_data(device); status = acpi_remove_address_space_handler(ec->common.handle, ACPI_ADR_SPACE_EC, ...
functions
__init acpi_fake_ecdt_callback(acpi_handle handle, u32 Level, void *context, void **retval) { if (acpi_ec_poll_mode) return acpi_fake_ecdt_poll_callback(handle, Level, context, retval); else return acpi_fake_ecdt_intr_callback(handle, Level, context, retval); }
functions
__init acpi_fake_ecdt_poll_callback(acpi_handle handle, u32 Level, void *context, void **retval) { acpi_status status; status = acpi_walk_resources(handle, METHOD_NAME__CRS, acpi_ec_io_ports, ec_ecdt); if (ACPI_FAILURE(status)) return status; ec_ecdt->common.status_addr = ec_ecdt->common.command_add...
functions
__init acpi_fake_ecdt_intr_callback(acpi_handle handle, u32 Level, void *context, void **retval) { acpi_status status; init_MUTEX(&ec_ecdt->intr.sem); init_waitqueue_head(&ec_ecdt->intr.wait); status = acpi_walk_resources(handle, METHOD_NAME__CRS, acpi_ec_io_ports, ec_ecdt); if (ACPI_FAILURE(sta...
functions
__init acpi_ec_fake_ecdt(void) { acpi_status status; int ret = 0; printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); if (!ec_ecdt) { ret = -ENOMEM; goto error; }
functions
__init acpi_ec_get_real_ecdt(void) { if (acpi_ec_poll_mode) return acpi_ec_poll_get_real_ecdt(); else return acpi_ec_intr_get_real_ecdt(); }
functions
__init acpi_ec_poll_get_real_ecdt(void) { acpi_status status; struct acpi_table_ecdt *ecdt_ptr; status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, (struct acpi_table_header **) &ecdt_ptr); if (ACPI_FAILURE(status)) return -ENODEV; printk(KERN_INFO PREFIX "Found ECDT\n"); /* * ...
functions
__init acpi_ec_intr_get_real_ecdt(void) { acpi_status status; struct acpi_table_ecdt *ecdt_ptr; status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, (struct acpi_table_header **) &ecdt_ptr); if (ACPI_FAILURE(status)) return -ENODEV; printk(KERN_INFO PREFIX "Found ECDT\n"); /* * ...
functions
__init acpi_ec_ecdt_probe(void) { acpi_status status; int ret; ret = acpi_ec_get_real_ecdt(); /* Try to make a fake ECDT */ if (ret && acpi_fake_ecdt_enabled) { ret = acpi_ec_fake_ecdt(); }
functions
__init acpi_ec_init(void) { int result = 0; ACPI_FUNCTION_TRACE("acpi_ec_init"); if (acpi_disabled) return_VALUE(0); acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir); if (!acpi_ec_dir) return_VALUE(-ENODEV); /* Now register the driver for the EC */ result = acpi_bus_register_driver(&acpi_ec_driver)...
functions
__exit acpi_ec_exit(void) { ACPI_FUNCTION_TRACE("acpi_ec_exit"); acpi_bus_unregister_driver(&acpi_ec_driver); remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir); return_VOID; }
functions
__init acpi_fake_ecdt_setup(char *str) { acpi_fake_ecdt_enabled = 1; return 0; }
functions
__init acpi_ec_set_intr_mode(char *str) { int intr; if (!get_option(&str, &intr)) return 0; if (intr) { acpi_ec_poll_mode = EC_INTR; acpi_ec_driver.ops.add = acpi_ec_intr_add; }
defines
#define TSC 12 /* number of fixed point digits in filter percent */