From b652b438fcad4c9c079d0774e9d45ee58fae22e2 Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 15 Jun 2005 12:38:14 +0100 Subject: [PATCH] I2C: Add PXA I2C driver Add support for the I2C PXA driver. Signed-off-by: Russell King diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index a0018de..a3bec8d 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -144,6 +144,22 @@ config I2C_I810 This driver can also be built as a module. If so, the module will be called i2c-i810. +config I2C_PXA + tristate "Intel PXA2XX I2C adapter (EXPERIMENTAL)" + depends on I2C && EXPERIMENTAL && ARCH_PXA + help + If you have devices in the PXA I2C bus, say yes to this option. + This driver can also be built as a module. If so, the module + will be called i2c-pxa. + +config I2C_PXA_SLAVE + bool "Intel PXA2XX I2C Slave comms support" + depends on I2C_PXA + help + Support I2C slave mode communications on the PXA I2C bus. This + is necessary for systems where the PXA may be a target on the + I2C bus. + config I2C_PIIX4 tristate "Intel PIIX4" depends on I2C && PCI diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index 42d6d81..980b3e9 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -28,6 +28,7 @@ obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o obj-$(CONFIG_I2C_PROSAVAGE) += i2c-prosavage.o +obj-$(CONFIG_I2C_PXA) += i2c-pxa.o obj-$(CONFIG_I2C_RPXLITE) += i2c-rpx.o obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o obj-$(CONFIG_I2C_SAVAGE4) += i2c-savage4.o diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c new file mode 100644 index 0000000..a72d283 --- /dev/null +++ b/drivers/i2c/busses/i2c-pxa.c @@ -0,0 +1,1031 @@ +/* + * i2c_adap_pxa.c + * + * I2C adapter for the PXA I2C bus access. + * + * Copyright (C) 2002 Intrinsyc Software Inc. + * Copyright (C) 2004-2005 Deep Blue Solutions Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * History: + * Apr 2002: Initial version [CS] + * Jun 2002: Properly seperated algo/adap [FB] + * Jan 2003: Fixed several bugs concerning interrupt handling [Kai-Uwe Bloem] + * Jan 2003: added limited signal handling [Kai-Uwe Bloem] + * Sep 2004: Major rework to ensure efficient bus handling [RMK] + * Dec 2004: Added support for PXA27x and slave device probing [Liam Girdwood] + * Feb 2005: Rework slave mode handling [RMK] + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +struct pxa_i2c { + spinlock_t lock; + wait_queue_head_t wait; + struct i2c_msg *msg; + unsigned int msg_num; + unsigned int msg_idx; + unsigned int msg_ptr; + unsigned int slave_addr; + + struct i2c_adapter adap; +#ifdef CONFIG_I2C_PXA_SLAVE + struct i2c_slave_client *slave; +#endif + + unsigned int irqlogidx; + u32 isrlog[32]; + u32 icrlog[32]; +}; + +/* + * I2C Slave mode address + */ +#define I2C_PXA_SLAVE_ADDR 0x1 + +/* + * Set this to zero to remove all debug statements via dead code elimination. + */ +#undef DEBUG + +#if 0 +#define DBGLVL KERN_INFO +#else +#define DBGLVL KERN_DEBUG +#endif + +#ifdef DEBUG + +struct bits { + u32 mask; + const char *set; + const char *unset; +}; +#define BIT(m, s, u) { .mask = m, .set = s, .unset = u } + +static inline void +decode_bits(const char *prefix, const struct bits *bits, int num, u32 val) +{ + printk("%s %08x: ", prefix, val); + while (num--) { + const char *str = val & bits->mask ? bits->set : bits->unset; + if (str) + printk("%s ", str); + bits++; + } +} + +static const struct bits isr_bits[] = { + BIT(ISR_RWM, "RX", "TX"), + BIT(ISR_ACKNAK, "NAK", "ACK"), + BIT(ISR_UB, "Bsy", "Rdy"), + BIT(ISR_IBB, "BusBsy", "BusRdy"), + BIT(ISR_SSD, "SlaveStop", NULL), + BIT(ISR_ALD, "ALD", NULL), + BIT(ISR_ITE, "TxEmpty", NULL), + BIT(ISR_IRF, "RxFull", NULL), + BIT(ISR_GCAD, "GenCall", NULL), + BIT(ISR_SAD, "SlaveAddr", NULL), + BIT(ISR_BED, "BusErr", NULL), +}; + +static void decode_ISR(unsigned int val) +{ + decode_bits(DBGLVL "ISR", isr_bits, ARRAY_SIZE(isr_bits), val); + printk("\n"); +} + +static const struct bits icr_bits[] = { + BIT(ICR_START, "START", NULL), + BIT(ICR_STOP, "STOP", NULL), + BIT(ICR_ACKNAK, "ACKNAK", NULL), + BIT(ICR_TB, "TB", NULL), + BIT(ICR_MA, "MA", NULL), + BIT(ICR_SCLE, "SCLE", "scle"), + BIT(ICR_IUE, "IUE", "iue"), + BIT(ICR_GCD, "GCD", NULL), + BIT(ICR_ITEIE, "ITEIE", NULL), + BIT(ICR_IRFIE, "IRFIE", NULL), + BIT(ICR_BEIE, "BEIE", NULL), + BIT(ICR_SSDIE, "SSDIE", NULL), + BIT(ICR_ALDIE, "ALDIE", NULL), + BIT(ICR_SADIE, "SADIE", NULL), + BIT(ICR_UR, "UR", "ur"), +}; + +static void decode_ICR(unsigned int val) +{ + decode_bits(DBGLVL "ICR", icr_bits, ARRAY_SIZE(icr_bits), val); + printk("\n"); +} + +static unsigned int i2c_debug = DEBUG; + +static void i2c_pxa_show_state(struct pxa_i2c *i2c, int lno, const char *fname) +{ + printk(DBGLVL "state:%s:%d: ISR=%08x, ICR=%08x, IBMR=%02x\n", fname, lno, ISR, ICR, IBMR); +} + +#define show_state(i2c) i2c_pxa_show_state(i2c, __LINE__, __FUNCTION__) +#else +#define i2c_debug 0 + +#define show_state(i2c) do { } while (0) +#define decode_ISR(val) do { } while (0) +#define decode_ICR(val) do { } while (0) +#endif + +#define eedbg(lvl, x...) do { if ((lvl) < 1) { printk(DBGLVL "" x); } } while(0) + +static void i2c_pxa_master_complete(struct pxa_i2c *i2c, int ret); + +static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why) +{ + unsigned int i; + printk("i2c: error: %s\n", why); + printk("i2c: msg_num: %d msg_idx: %d msg_ptr: %d\n", + i2c->msg_num, i2c->msg_idx, i2c->msg_ptr); + printk("i2c: ICR: %08x ISR: %08x\ni2c: log: ", ICR, ISR); + for (i = 0; i < i2c->irqlogidx; i++) + printk("[%08x:%08x] ", i2c->isrlog[i], i2c->icrlog[i]); + printk("\n"); +} + +static inline int i2c_pxa_is_slavemode(struct pxa_i2c *i2c) +{ + return !(ICR & ICR_SCLE); +} + +static void i2c_pxa_abort(struct pxa_i2c *i2c) +{ + unsigned long timeout = jiffies + HZ/4; + + if (i2c_pxa_is_slavemode(i2c)) { + printk(DBGLVL "i2c_pxa_transfer: called in slave mode\n"); + return; + } + + while (time_before(jiffies, timeout) && (IBMR & 0x1) == 0) { + unsigned long icr = ICR; + + icr &= ~ICR_START; + icr |= ICR_ACKNAK | ICR_STOP | ICR_TB; + + ICR = icr; + + show_state(i2c); + + msleep(1); + } + + ICR &= ~(ICR_MA | ICR_START | ICR_STOP); +} + +static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c) +{ + int timeout = DEF_TIMEOUT; + + while (timeout-- && ISR & (ISR_IBB | ISR_UB)) { + if ((ISR & ISR_SAD) != 0) + timeout += 4; + + msleep(2); + show_state(i2c); + } + + if (timeout <= 0) + show_state(i2c); + + return timeout <= 0 ? I2C_RETRY : 0; +} + +static int i2c_pxa_wait_master(struct pxa_i2c *i2c) +{ + unsigned long timeout = jiffies + HZ*4; + + while (time_before(jiffies, timeout)) { + if (i2c_debug > 1) + printk(DBGLVL "i2c_pxa_wait_master: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n", + (long)jiffies, ISR, ICR, IBMR); + + if (ISR & ISR_SAD) { + if (i2c_debug > 0) + printk(DBGLVL "i2c_pxa_wait_master: Slave detected\n"); + goto out; + } + + /* wait for unit and bus being not busy, and we also do a + * quick check of the i2c lines themselves to ensure they've + * gone high... + */ + if ((ISR & (ISR_UB | ISR_IBB)) == 0 && IBMR == 3) { + if (i2c_debug > 0) + printk(DBGLVL "i2c_pxa_wait_master: done\n"); + return 1; + } + + msleep(1); + } + + if (i2c_debug > 0) + printk(DBGLVL "i2c_pxa_wait_master: did not free\n"); + out: + return 0; +} + +static int i2c_pxa_set_master(struct pxa_i2c *i2c) +{ + if (i2c_debug) + printk(DBGLVL "I2C: setting to bus master\n"); + + if ((ISR & (ISR_UB | ISR_IBB)) != 0) { + printk(DBGLVL "set_master: unit is busy\n"); + if (!i2c_pxa_wait_master(i2c)) { + printk(DBGLVL "set_master: error: unit busy\n"); + return I2C_RETRY; + } + } + + ICR |= ICR_SCLE; + return 0; +} + +#ifdef CONFIG_I2C_PXA_SLAVE +static int i2c_pxa_wait_slave(struct pxa_i2c *i2c) +{ + unsigned long timeout = jiffies + HZ*1; + + /* wait for stop */ + + show_state(i2c); + + while (time_before(jiffies, timeout)) { + if (i2c_debug > 1) + printk(DBGLVL "i2c_pxa_wait_slave: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n", + (long)jiffies, ISR, ICR, IBMR); + + if ((ISR & (ISR_UB|ISR_IBB|ISR_SAD)) == ISR_SAD || + (ICR & ICR_SCLE) == 0) { + if (i2c_debug > 1) + printk(DBGLVL "i2c_pxa_wait_slave: done\n"); + return 1; + } + + msleep(1); + } + + if (i2c_debug > 0) + printk(DBGLVL "i2c_pxa_wait_slave: did not free\n"); + return 0; +} + +/* + * clear the hold on the bus, and take of anything else + * that has been configured + */ +static void i2c_pxa_set_slave(struct pxa_i2c *i2c, int errcode) +{ + show_state(i2c); + + if (errcode < 0) { + udelay(100); /* simple delay */ + } else { + /* we need to wait for the stop condition to end */ + + /* if we where in stop, then clear... */ + if (ICR & ICR_STOP) { + udelay(100); + ICR &= ~ICR_STOP; + } + + if (!i2c_pxa_wait_slave(i2c)) { + printk(KERN_ERR "i2c_pxa_set_slave: wait timedout\n"); + return; + } + } + + ICR &= ~(ICR_STOP|ICR_ACKNAK|ICR_MA); + ICR &= ~ICR_SCLE; + + if (i2c_debug) { + printk(DBGLVL "ICR now %08x, ISR %08x\n", ICR, ISR); + decode_ICR(ICR); + } +} +#else +#define i2c_pxa_set_slave(i2c, err) do { } while (0) +#endif + +static void i2c_pxa_reset(struct pxa_i2c *i2c) +{ + pr_debug("Resetting I2C Controller Unit\n"); + + /* abort any transfer currently under way */ + i2c_pxa_abort(i2c); + + /* reset according to 9.8 */ + ICR = ICR_UR; + ISR = I2C_ISR_INIT; + ICR &= ~ICR_UR; + + ISAR = i2c->slave_addr; + + /* set control register values */ + ICR = I2C_ICR_INIT; + +#ifdef CONFIG_I2C_PXA_SLAVE + printk(KERN_INFO "I2C: Enabling slave mode\n"); + ICR |= ICR_SADIE | ICR_ALDIE | ICR_SSDIE; +#endif + + i2c_pxa_set_slave(i2c, 0); + + /* enable unit */ + ICR |= ICR_IUE; + udelay(100); +} + + +#ifdef CONFIG_I2C_PXA_SLAVE +/* + * I2C EEPROM emulation. + */ +static struct i2c_eeprom_emu eeprom = { + .size = I2C_EEPROM_EMU_SIZE, + .watch = LIST_HEAD_INIT(eeprom.watch), +}; + +struct i2c_eeprom_emu *i2c_pxa_get_eeprom(void) +{ + return &eeprom; +} + +int i2c_eeprom_emu_addwatcher(struct i2c_eeprom_emu *emu, void *data, + unsigned int addr, unsigned int size, + struct i2c_eeprom_emu_watcher *watcher) +{ + struct i2c_eeprom_emu_watch *watch; + unsigned long flags; + + if (addr + size > emu->size) + return -EINVAL; + + watch = kmalloc(sizeof(struct i2c_eeprom_emu_watch), GFP_KERNEL); + if (watch) { + watch->start = addr; + watch->end = addr + size - 1; + watch->ops = watcher; + watch->data = data; + + local_irq_save(flags); + list_add(&watch->node, &emu->watch); + local_irq_restore(flags); + } + + return watch ? 0 : -ENOMEM; +} + +void i2c_eeprom_emu_delwatcher(struct i2c_eeprom_emu *emu, void *data, + struct i2c_eeprom_emu_watcher *watcher) +{ + struct i2c_eeprom_emu_watch *watch, *n; + unsigned long flags; + + list_for_each_entry_safe(watch, n, &emu->watch, node) { + if (watch->ops == watcher && watch->data == data) { + local_irq_save(flags); + list_del(&watch->node); + local_irq_restore(flags); + kfree(watch); + } + } +} + +static void i2c_eeprom_emu_event(void *ptr, i2c_slave_event_t event) +{ + struct i2c_eeprom_emu *emu = ptr; + + eedbg(3, "i2c_eeprom_emu_event: %d\n", event); + + switch (event) { + case I2C_SLAVE_EVENT_START_WRITE: + emu->seen_start = 1; + eedbg(2, "i2c_eeprom: write initiated\n"); + break; + + case I2C_SLAVE_EVENT_START_READ: + emu->seen_start = 0; + eedbg(2, "i2c_eeprom: read initiated\n"); + break; + + case I2C_SLAVE_EVENT_STOP: + emu->seen_start = 0; + eedbg(2, "i2c_eeprom: received stop\n"); + break; + + default: + eedbg(0, "i2c_eeprom: unhandled event\n"); + break; + } +} + +static int i2c_eeprom_emu_read(void *ptr) +{ + struct i2c_eeprom_emu *emu = ptr; + int ret; + + ret = emu->bytes[emu->ptr]; + emu->ptr = (emu->ptr + 1) % emu->size; + + return ret; +} + +static void i2c_eeprom_emu_write(void *ptr, unsigned int val) +{ + struct i2c_eeprom_emu *emu = ptr; + struct i2c_eeprom_emu_watch *watch; + + if (emu->seen_start != 0) { + eedbg(2, "i2c_eeprom_emu_write: setting ptr %02x\n", val); + emu->ptr = val; + emu->seen_start = 0; + return; + } + + emu->bytes[emu->ptr] = val; + + eedbg(1, "i2c_eeprom_emu_write: ptr=0x%02x, val=0x%02x\n", + emu->ptr, val); + + list_for_each_entry(watch, &emu->watch, node) { + if (!watch->ops || !watch->ops->write) + continue; + if (watch->start <= emu->ptr && watch->end >= emu->ptr) + watch->ops->write(watch->data, emu->ptr, val); + } + + emu->ptr = (emu->ptr + 1) % emu->size; +} + +struct i2c_slave_client eeprom_client = { + .data = &eeprom, + .event = i2c_eeprom_emu_event, + .read = i2c_eeprom_emu_read, + .write = i2c_eeprom_emu_write +}; + +/* + * PXA I2C Slave mode + */ + +static void i2c_pxa_slave_txempty(struct pxa_i2c *i2c, u32 isr) +{ + if (isr & ISR_BED) { + /* what should we do here? */ + } else { + int ret = i2c->slave->read(i2c->slave->data); + + IDBR = ret; + ICR |= ICR_TB; /* allow next byte */ + } +} + +static void i2c_pxa_slave_rxfull(struct pxa_i2c *i2c, u32 isr) +{ + unsigned int byte = IDBR; + + if (i2c->slave != NULL) + i2c->slave->write(i2c->slave->data, byte); + + ICR |= ICR_TB; +} + +static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr) +{ + int timeout; + + if (i2c_debug > 0) + printk(DBGLVL "I2C: SAD, mode is slave-%cx\n", + (isr & ISR_RWM) ? 'r' : 't'); + + if (i2c->slave != NULL) + i2c->slave->event(i2c->slave->data, + (isr & ISR_RWM) ? I2C_SLAVE_EVENT_START_READ : I2C_SLAVE_EVENT_START_WRITE); + + /* + * slave could interrupt in the middle of us generating a + * start condition... if this happens, we'd better back off + * and stop holding the poor thing up + */ + ICR &= ~(ICR_START|ICR_STOP); + ICR |= ICR_TB; + + timeout = 0x10000; + + while (1) { + if ((IBMR & 2) == 2) + break; + + timeout--; + + if (timeout <= 0) { + printk(KERN_ERR "timeout waiting for SCL high\n"); + break; + } + } + + ICR &= ~ICR_SCLE; +} + +static void i2c_pxa_slave_stop(struct pxa_i2c *i2c) +{ + if (i2c_debug > 2) + printk(DBGLVL "ISR: SSD (Slave Stop)\n"); + + if (i2c->slave != NULL) + i2c->slave->event(i2c->slave->data, I2C_SLAVE_EVENT_STOP); + + if (i2c_debug > 2) + printk(DBGLVL "ISR: SSD (Slave Stop) acked\n"); + + /* + * If we have a master-mode message waiting, + * kick it off now that the slave has completed. + */ + if (i2c->msg) + i2c_pxa_master_complete(i2c, I2C_RETRY); +} +#else +static void i2c_pxa_slave_txempty(struct pxa_i2c *i2c, u32 isr) +{ + if (isr & ISR_BED) { + /* what should we do here? */ + } else { + IDBR = 0; + ICR |= ICR_TB; + } +} + +static void i2c_pxa_slave_rxfull(struct pxa_i2c *i2c, u32 isr) +{ + ICR |= ICR_TB | ICR_ACKNAK; +} + +static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr) +{ + int timeout; + + /* + * slave could interrupt in the middle of us generating a + * start condition... if this happens, we'd better back off + * and stop holding the poor thing up + */ + ICR &= ~(ICR_START|ICR_STOP); + ICR |= ICR_TB | ICR_ACKNAK; + + timeout = 0x10000; + + while (1) { + if ((IBMR & 2) == 2) + break; + + timeout--; + + if (timeout <= 0) { + printk(KERN_ERR "timeout waiting for SCL high\n"); + break; + } + } + + ICR &= ~ICR_SCLE; +} + +static void i2c_pxa_slave_stop(struct pxa_i2c *i2c) +{ + if (i2c->msg) + i2c_pxa_master_complete(i2c, I2C_RETRY); +} +#endif + +/* + * PXA I2C Master mode + */ + +static inline unsigned int i2c_pxa_addr_byte(struct i2c_msg *msg) +{ + unsigned int addr = (msg->addr & 0x7f) << 1; + + if (msg->flags & I2C_M_RD) + addr |= 1; + + return addr; +} + +static inline void i2c_pxa_start_message(struct pxa_i2c *i2c) +{ + u32 icr; + + /* + * Step 1: target slave address into IDBR + */ + IDBR = i2c_pxa_addr_byte(i2c->msg); + + /* + * Step 2: initiate the write. + */ + icr = ICR & ~(ICR_STOP | ICR_ALDIE); + ICR = icr | ICR_START | ICR_TB; +} + +/* + * We are protected by the adapter bus semaphore. + */ +static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num) +{ + long timeout; + int ret; + + /* + * Wait for the bus to become free. + */ + ret = i2c_pxa_wait_bus_not_busy(i2c); + if (ret) { + printk(KERN_INFO "i2c_pxa: timeout waiting for bus free\n"); + goto out; + } + + /* + * Set master mode. + */ + ret = i2c_pxa_set_master(i2c); + if (ret) { + printk(KERN_INFO "i2c_pxa_set_master: error %d\n", ret); + goto out; + } + + spin_lock_irq(&i2c->lock); + + i2c->msg = msg; + i2c->msg_num = num; + i2c->msg_idx = 0; + i2c->msg_ptr = 0; + i2c->irqlogidx = 0; + + i2c_pxa_start_message(i2c); + + spin_unlock_irq(&i2c->lock); + + /* + * The rest of the processing occurs in the interrupt handler. + */ + timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5); + + /* + * We place the return code in i2c->msg_idx. + */ + ret = i2c->msg_idx; + + if (timeout == 0) + i2c_pxa_scream_blue_murder(i2c, "timeout"); + + out: + return ret; +} + +/* + * i2c_pxa_master_complete - complete the message and wake up. + */ +static void i2c_pxa_master_complete(struct pxa_i2c *i2c, int ret) +{ + i2c->msg_ptr = 0; + i2c->msg = NULL; + i2c->msg_idx ++; + i2c->msg_num = 0; + if (ret) + i2c->msg_idx = ret; + wake_up(&i2c->wait); +} + +static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr) +{ + u32 icr = ICR & ~(ICR_START|ICR_STOP|ICR_ACKNAK|ICR_TB); + + again: + /* + * If ISR_ALD is set, we lost arbitration. + */ + if (isr & ISR_ALD) { + /* + * Do we need to do anything here? The PXA docs + * are vague about what happens. + */ + i2c_pxa_scream_blue_murder(i2c, "ALD set"); + + /* + * We ignore this error. We seem to see spurious ALDs + * for seemingly no reason. If we handle them as I think + * they should, we end up causing an I2C error, which + * is painful for some systems. + */ + return; /* ignore */ + } + + if (isr & ISR_BED) { + int ret = BUS_ERROR; + + /* + * I2C bus error - either the device NAK'd us, or + * something more serious happened. If we were NAK'd + * on the initial address phase, we can retry. + */ + if (isr & ISR_ACKNAK) { + if (i2c->msg_ptr == 0 && i2c->msg_idx == 0) + ret = I2C_RETRY; + else + ret = XFER_NAKED; + } + i2c_pxa_master_complete(i2c, ret); + } else if (isr & ISR_RWM) { + /* + * Read mode. We have just sent the address byte, and + * now we must initiate the transfer. + */ + if (i2c->msg_ptr == i2c->msg->len - 1 && + i2c->msg_idx == i2c->msg_num - 1) + icr |= ICR_STOP | ICR_ACKNAK; + + icr |= ICR_ALDIE | ICR_TB; + } else if (i2c->msg_ptr < i2c->msg->len) { + /* + * Write mode. Write the next data byte. + */ + IDBR = i2c->msg->buf[i2c->msg_ptr++]; + + icr |= ICR_ALDIE | ICR_TB; + + /* + * If this is the last byte of the last message, send + * a STOP. + */ + if (i2c->msg_ptr == i2c->msg->len && + i2c->msg_idx == i2c->msg_num - 1) + icr |= ICR_STOP; + } else if (i2c->msg_idx < i2c->msg_num - 1) { + /* + * Next segment of the message. + */ + i2c->msg_ptr = 0; + i2c->msg_idx ++; + i2c->msg++; + + /* + * If we aren't doing a repeated start and address, + * go back and try to send the next byte. Note that + * we do not support switching the R/W direction here. + */ + if (i2c->msg->flags & I2C_M_NOSTART) + goto again; + + /* + * Write the next address. + */ + IDBR = i2c_pxa_addr_byte(i2c->msg); + + /* + * And trigger a repeated start, and send the byte. + */ + icr &= ~ICR_ALDIE; + icr |= ICR_START | ICR_TB; + } else { + if (i2c->msg->len == 0) { + /* + * Device probes have a message length of zero + * and need the bus to be reset before it can + * be used again. + */ + i2c_pxa_reset(i2c); + } + i2c_pxa_master_complete(i2c, 0); + } + + i2c->icrlog[i2c->irqlogidx-1] = icr; + + ICR = icr; + show_state(i2c); +} + +static void i2c_pxa_irq_rxfull(struct pxa_i2c *i2c, u32 isr) +{ + u32 icr = ICR & ~(ICR_START|ICR_STOP|ICR_ACKNAK|ICR_TB); + + /* + * Read the byte. + */ + i2c->msg->buf[i2c->msg_ptr++] = IDBR; + + if (i2c->msg_ptr < i2c->msg->len) { + /* + * If this is the last byte of the last + * message, send a STOP. + */ + if (i2c->msg_ptr == i2c->msg->len - 1) + icr |= ICR_STOP | ICR_ACKNAK; + + icr |= ICR_ALDIE | ICR_TB; + } else { + i2c_pxa_master_complete(i2c, 0); + } + + i2c->icrlog[i2c->irqlogidx-1] = icr; + + ICR = icr; +} + +static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id, struct pt_regs *regs) +{ + struct pxa_i2c *i2c = dev_id; + u32 isr = ISR; + + if (i2c_debug > 2 && 0) { + printk(DBGLVL "i2c_pxa_handler: ISR=%08x, ICR=%08x, IBMR=%02x\n", + isr, ICR, IBMR); + decode_ISR(isr); + } + + if (i2c->irqlogidx < sizeof(i2c->isrlog)/sizeof(u32)) + i2c->isrlog[i2c->irqlogidx++] = isr; + + show_state(i2c); + + /* + * Always clear all pending IRQs. + */ + ISR = isr & (ISR_SSD|ISR_ALD|ISR_ITE|ISR_IRF|ISR_SAD|ISR_BED); + + if (isr & ISR_SAD) + i2c_pxa_slave_start(i2c, isr); + if (isr & ISR_SSD) + i2c_pxa_slave_stop(i2c); + + if (i2c_pxa_is_slavemode(i2c)) { + if (isr & ISR_ITE) + i2c_pxa_slave_txempty(i2c, isr); + if (isr & ISR_IRF) + i2c_pxa_slave_rxfull(i2c, isr); + } else if (i2c->msg) { + if (isr & ISR_ITE) + i2c_pxa_irq_txempty(i2c, isr); + if (isr & ISR_IRF) + i2c_pxa_irq_rxfull(i2c, isr); + } else { + i2c_pxa_scream_blue_murder(i2c, "spurious irq"); + } + + return IRQ_HANDLED; +} + + +static int i2c_pxa_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) +{ + struct pxa_i2c *i2c = adap->algo_data; + int ret, i; + + for (i = adap->retries; i >= 0; i--) { + ret = i2c_pxa_do_xfer(i2c, msgs, num); + if (ret != I2C_RETRY) + goto out; + + if (i2c_debug) + printk(KERN_INFO "Retrying transmission\n"); + udelay(100); + } + i2c_pxa_scream_blue_murder(i2c, "exhausted retries"); + ret = -EREMOTEIO; + out: + i2c_pxa_set_slave(i2c, ret); + return ret; +} + +static struct i2c_algorithm i2c_pxa_algorithm = { + .name = "PXA-I2C-Algorithm", + .id = I2C_ALGO_PXA, + .master_xfer = i2c_pxa_xfer, +}; + +static struct pxa_i2c i2c_pxa = { + .lock = SPIN_LOCK_UNLOCKED, + .wait = __WAIT_QUEUE_HEAD_INITIALIZER(i2c_pxa.wait), + .adap = { + .name = "pxa2xx-i2c", + .id = I2C_ALGO_PXA, + .algo = &i2c_pxa_algorithm, + .retries = 5, + }, +}; + +static int i2c_pxa_probe(struct device *dev) +{ + struct pxa_i2c *i2c = &i2c_pxa; + struct i2c_pxa_platform_data *plat = dev->platform_data; + int ret; + +#ifdef CONFIG_PXA27x + pxa_gpio_mode(GPIO117_I2CSCL_MD); + pxa_gpio_mode(GPIO118_I2CSDA_MD); + udelay(100); +#endif + + i2c->slave_addr = I2C_PXA_SLAVE_ADDR; + +#ifdef CONFIG_I2C_PXA_SLAVE + i2c->slave = &eeprom_client; + if (plat) { + i2c->slave_addr = plat->slave_addr; + if (plat->slave) + i2c->slave = plat->slave; + } +#endif + + pxa_set_cken(CKEN14_I2C, 1); + ret = request_irq(IRQ_I2C, i2c_pxa_handler, SA_INTERRUPT, + "pxa2xx-i2c", i2c); + if (ret) + goto out; + + i2c_pxa_reset(i2c); + + i2c->adap.algo_data = i2c; + i2c->adap.dev.parent = dev; + + ret = i2c_add_adapter(&i2c->adap); + if (ret < 0) { + printk(KERN_INFO "I2C: Failed to add bus\n"); + goto err_irq; + } + + dev_set_drvdata(dev, i2c); + +#ifdef CONFIG_I2C_PXA_SLAVE + printk(KERN_INFO "I2C: %s: PXA I2C adapter, slave address %d\n", + i2c->adap.dev.bus_id, i2c->slave_addr); +#else + printk(KERN_INFO "I2C: %s: PXA I2C adapter\n", + i2c->adap.dev.bus_id); +#endif + return 0; + + err_irq: + free_irq(IRQ_I2C, i2c); + out: + return ret; +} + +static int i2c_pxa_remove(struct device *dev) +{ + struct pxa_i2c *i2c = dev_get_drvdata(dev); + + dev_set_drvdata(dev, NULL); + + i2c_del_adapter(&i2c->adap); + free_irq(IRQ_I2C, i2c); + pxa_set_cken(CKEN14_I2C, 0); + + return 0; +} + +static struct device_driver i2c_pxa_driver = { + .name = "pxa2xx-i2c", + .bus = &platform_bus_type, + .probe = i2c_pxa_probe, + .remove = i2c_pxa_remove, +}; + +static int __init i2c_adap_pxa_init(void) +{ + return driver_register(&i2c_pxa_driver); +} + +static void i2c_adap_pxa_exit(void) +{ + return driver_unregister(&i2c_pxa_driver); +} + +module_init(i2c_adap_pxa_init); +module_exit(i2c_adap_pxa_exit); diff --git a/include/asm-arm/arch-pxa/i2c.h b/include/asm-arm/arch-pxa/i2c.h new file mode 100644 index 0000000..46ec224 --- /dev/null +++ b/include/asm-arm/arch-pxa/i2c.h @@ -0,0 +1,70 @@ +/* + * i2c_pxa.h + * + * Copyright (C) 2002 Intrinsyc Software Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ +#ifndef _I2C_PXA_H_ +#define _I2C_PXA_H_ + +#if 0 +#define DEF_TIMEOUT 3 +#else +/* need a longer timeout if we're dealing with the fact we may well be + * looking at a multi-master environment +*/ +#define DEF_TIMEOUT 32 +#endif + +#define BUS_ERROR (-EREMOTEIO) +#define XFER_NAKED (-ECONNREFUSED) +#define I2C_RETRY (-2000) /* an error has occurred retry transmit */ + +/* ICR initialize bit values +* +* 15. FM 0 (100 Khz operation) +* 14. UR 0 (No unit reset) +* 13. SADIE 0 (Disables the unit from interrupting on slave addresses +* matching its slave address) +* 12. ALDIE 0 (Disables the unit from interrupt when it loses arbitration +* in master mode) +* 11. SSDIE 0 (Disables interrupts from a slave stop detected, in slave mode) +* 10. BEIE 1 (Enable interrupts from detected bus errors, no ACK sent) +* 9. IRFIE 1 (Enable interrupts from full buffer received) +* 8. ITEIE 1 (Enables the I2C unit to interrupt when transmit buffer empty) +* 7. GCD 1 (Disables i2c unit response to general call messages as a slave) +* 6. IUE 0 (Disable unit until we change settings) +* 5. SCLE 1 (Enables the i2c clock output for master mode (drives SCL) +* 4. MA 0 (Only send stop with the ICR stop bit) +* 3. TB 0 (We are not transmitting a byte initially) +* 2. ACKNAK 0 (Send an ACK after the unit receives a byte) +* 1. STOP 0 (Do not send a STOP) +* 0. START 0 (Do not send a START) +* +*/ +#define I2C_ICR_INIT (ICR_BEIE | ICR_IRFIE | ICR_ITEIE | ICR_GCD | ICR_SCLE) + +/* I2C status register init values + * + * 10. BED 1 (Clear bus error detected) + * 9. SAD 1 (Clear slave address detected) + * 7. IRF 1 (Clear IDBR Receive Full) + * 6. ITE 1 (Clear IDBR Transmit Empty) + * 5. ALD 1 (Clear Arbitration Loss Detected) + * 4. SSD 1 (Clear Slave Stop Detected) + */ +#define I2C_ISR_INIT 0x7FF /* status register init */ + +struct i2c_slave_client; + +struct i2c_pxa_platform_data { + unsigned int slave_addr; + struct i2c_slave_client *slave; +}; + +extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info); +#endif diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 89270ce..74d6dc9 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -203,6 +203,7 @@ #define I2C_ALGO_MV64XXX 0x190000 /* Marvell mv64xxx i2c ctlr */ #define I2C_ALGO_PCA 0x1a0000 /* PCA 9564 style adapters */ #define I2C_ALGO_AU1550 0x1b0000 /* Au1550 PSC algorithm */ +#define I2C_ALGO_PXA 0x1c0000 /* Intel PXA I2C algorithm */ #define I2C_ALGO_EXP 0x800000 /* experimental */ diff --git a/include/linux/i2c-pxa.h b/include/linux/i2c-pxa.h new file mode 100644 index 0000000..5f3eaf8 --- /dev/null +++ b/include/linux/i2c-pxa.h @@ -0,0 +1,48 @@ +#ifndef _LINUX_I2C_ALGO_PXA_H +#define _LINUX_I2C_ALGO_PXA_H + +struct i2c_eeprom_emu_watcher { + void (*write)(void *, unsigned int addr, unsigned char newval); +}; + +struct i2c_eeprom_emu_watch { + struct list_head node; + unsigned int start; + unsigned int end; + struct i2c_eeprom_emu_watcher *ops; + void *data; +}; + +#define I2C_EEPROM_EMU_SIZE (256) + +struct i2c_eeprom_emu { + unsigned int size; + unsigned int ptr; + unsigned int seen_start; + struct list_head watch; + + unsigned char bytes[I2C_EEPROM_EMU_SIZE]; +}; + +typedef enum i2c_slave_event_e { + I2C_SLAVE_EVENT_START_READ, + I2C_SLAVE_EVENT_START_WRITE, + I2C_SLAVE_EVENT_STOP +} i2c_slave_event_t; + +struct i2c_slave_client { + void *data; + void (*event)(void *ptr, i2c_slave_event_t event); + int (*read) (void *ptr); + void (*write)(void *ptr, unsigned int val); +}; + +extern int i2c_eeprom_emu_addwatcher(struct i2c_eeprom_emu *, void *data, + unsigned int addr, unsigned int size, + struct i2c_eeprom_emu_watcher *); + +extern void i2c_eeprom_emu_delwatcher(struct i2c_eeprom_emu *, void *data, struct i2c_eeprom_emu_watcher *watcher); + +extern struct i2c_eeprom_emu *i2c_pxa_get_eeprom(void); + +#endif /* _LINUX_I2C_ALGO_PXA_H */ -- cgit v0.10.2 From 6f42ccf2fc50ecee8ea170040627f268430c1648 Mon Sep 17 00:00:00 2001 From: Robert Moore Date: Fri, 13 May 2005 00:00:00 -0400 Subject: ACPICA from Bob Moore Implemented support for PCI Express root bridges -- added support for device PNP0A08 in the root bridge search within AcpiEvPciConfigRegionSetup. acpi_ev_pci_config_region_setup(). The interpreter now automatically truncates incoming 64-bit constants to 32 bits if currently executing out of a 32-bit ACPI table (Revision < 2). This also affects the iASL compiler constant folding. (Note: as per below, the iASL compiler no longer allows 64-bit constants within 32-bit tables.) Fixed a problem where string and buffer objects with "static" pointers (pointers to initialization data within an ACPI table) were not handled consistently. The internal object copy operation now always copies the data to a newly allocated buffer, regardless of whether the source object is static or not. Fixed a problem with the FromBCD operator where an implicit result conversion was improperly performed while storing the result to the target operand. Since this is an "explicit conversion" operator, the implicit conversion should never be performed on the output. Fixed a problem with the CopyObject operator where a copy to an existing named object did not always completely overwrite the existing object stored at name. Specifically, a buffer-to-buffer copy did not delete the existing buffer. Replaced "interrupt_level" with "interrupt_number" in all GPE interfaces and structs for consistency. Signed-off-by: Len Brown diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c index bfbae4e..1eee2d5 100644 --- a/drivers/acpi/dispatcher/dsobject.c +++ b/drivers/acpi/dispatcher/dsobject.c @@ -547,6 +547,9 @@ acpi_ds_init_object_from_op ( case AML_TYPE_LITERAL: obj_desc->integer.value = op->common.value.integer; +#ifndef ACPI_NO_METHOD_EXECUTION + acpi_ex_truncate_for32bit_table (obj_desc); +#endif break; diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c index 9cd3db6..4ef0e85 100644 --- a/drivers/acpi/dispatcher/dswstate.c +++ b/drivers/acpi/dispatcher/dswstate.c @@ -261,12 +261,12 @@ acpi_ds_result_pop_from_bottom ( if (!*object) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null operand! State=%p #Ops=%X, Index=%X\n", + "Null operand! State=%p #Ops=%X Index=%X\n", walk_state, state->results.num_results, (u32) index)); return (AE_AML_NO_RETURN_VALUE); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s], Results=%p State=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Results=%p State=%p\n", *object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL", state, walk_state)); diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c index 84186a7..ee5419b 100644 --- a/drivers/acpi/events/evgpeblk.c +++ b/drivers/acpi/events/evgpeblk.c @@ -66,7 +66,7 @@ acpi_ev_match_prw_and_gpe ( static struct acpi_gpe_xrupt_info * acpi_ev_get_gpe_xrupt_block ( - u32 interrupt_level); + u32 interrupt_number); static acpi_status acpi_ev_delete_gpe_xrupt ( @@ -75,7 +75,7 @@ acpi_ev_delete_gpe_xrupt ( static acpi_status acpi_ev_install_gpe_block ( struct acpi_gpe_block_info *gpe_block, - u32 interrupt_level); + u32 interrupt_number); static acpi_status acpi_ev_create_gpe_info_blocks ( @@ -482,7 +482,7 @@ cleanup: * * FUNCTION: acpi_ev_get_gpe_xrupt_block * - * PARAMETERS: interrupt_level - Interrupt for a GPE block + * PARAMETERS: interrupt_number - Interrupt for a GPE block * * RETURN: A GPE interrupt block * @@ -495,7 +495,7 @@ cleanup: static struct acpi_gpe_xrupt_info * acpi_ev_get_gpe_xrupt_block ( - u32 interrupt_level) + u32 interrupt_number) { struct acpi_gpe_xrupt_info *next_gpe_xrupt; struct acpi_gpe_xrupt_info *gpe_xrupt; @@ -509,7 +509,7 @@ acpi_ev_get_gpe_xrupt_block ( next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; while (next_gpe_xrupt) { - if (next_gpe_xrupt->interrupt_level == interrupt_level) { + if (next_gpe_xrupt->interrupt_number == interrupt_number) { return_PTR (next_gpe_xrupt); } @@ -523,7 +523,7 @@ acpi_ev_get_gpe_xrupt_block ( return_PTR (NULL); } - gpe_xrupt->interrupt_level = interrupt_level; + gpe_xrupt->interrupt_number = interrupt_number; /* Install new interrupt descriptor with spin lock */ @@ -544,13 +544,13 @@ acpi_ev_get_gpe_xrupt_block ( /* Install new interrupt handler if not SCI_INT */ - if (interrupt_level != acpi_gbl_FADT->sci_int) { - status = acpi_os_install_interrupt_handler (interrupt_level, + if (interrupt_number != acpi_gbl_FADT->sci_int) { + status = acpi_os_install_interrupt_handler (interrupt_number, acpi_ev_gpe_xrupt_handler, gpe_xrupt); if (ACPI_FAILURE (status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not install GPE interrupt handler at level 0x%X\n", - interrupt_level)); + interrupt_number)); return_PTR (NULL); } } @@ -584,14 +584,14 @@ acpi_ev_delete_gpe_xrupt ( /* We never want to remove the SCI interrupt handler */ - if (gpe_xrupt->interrupt_level == acpi_gbl_FADT->sci_int) { + if (gpe_xrupt->interrupt_number == acpi_gbl_FADT->sci_int) { gpe_xrupt->gpe_block_list_head = NULL; return_ACPI_STATUS (AE_OK); } /* Disable this interrupt */ - status = acpi_os_remove_interrupt_handler (gpe_xrupt->interrupt_level, + status = acpi_os_remove_interrupt_handler (gpe_xrupt->interrupt_number, acpi_ev_gpe_xrupt_handler); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); @@ -621,7 +621,7 @@ acpi_ev_delete_gpe_xrupt ( * FUNCTION: acpi_ev_install_gpe_block * * PARAMETERS: gpe_block - New GPE block - * interrupt_level - Level to be associated with this GPE block + * interrupt_number - Xrupt to be associated with this GPE block * * RETURN: Status * @@ -632,7 +632,7 @@ acpi_ev_delete_gpe_xrupt ( static acpi_status acpi_ev_install_gpe_block ( struct acpi_gpe_block_info *gpe_block, - u32 interrupt_level) + u32 interrupt_number) { struct acpi_gpe_block_info *next_gpe_block; struct acpi_gpe_xrupt_info *gpe_xrupt_block; @@ -647,7 +647,7 @@ acpi_ev_install_gpe_block ( return_ACPI_STATUS (status); } - gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block (interrupt_level); + gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block (interrupt_number); if (!gpe_xrupt_block) { status = AE_NO_MEMORY; goto unlock_and_exit; @@ -887,7 +887,7 @@ error_exit: * gpe_block_address - Address and space_iD * register_count - Number of GPE register pairs in the block * gpe_block_base_number - Starting GPE number for the block - * interrupt_level - H/W interrupt for the block + * interrupt_number - H/W interrupt for the block * return_gpe_block - Where the new block descriptor is returned * * RETURN: Status @@ -902,7 +902,7 @@ acpi_ev_create_gpe_block ( struct acpi_generic_address *gpe_block_address, u32 register_count, u8 gpe_block_base_number, - u32 interrupt_level, + u32 interrupt_number, struct acpi_gpe_block_info **return_gpe_block) { struct acpi_gpe_block_info *gpe_block; @@ -948,7 +948,7 @@ acpi_ev_create_gpe_block ( /* Install the new block in the global list(s) */ - status = acpi_ev_install_gpe_block (gpe_block, interrupt_level); + status = acpi_ev_install_gpe_block (gpe_block, interrupt_number); if (ACPI_FAILURE (status)) { ACPI_MEM_FREE (gpe_block); return_ACPI_STATUS (status); @@ -1013,7 +1013,7 @@ acpi_ev_create_gpe_block ( ((gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) -1)), gpe_device->name.ascii, gpe_block->register_count, - interrupt_level)); + interrupt_number)); /* Enable all valid GPEs found above */ diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c index 95bc09c..f2d53af 100644 --- a/drivers/acpi/events/evrgnini.c +++ b/drivers/acpi/events/evrgnini.c @@ -218,10 +218,14 @@ acpi_ev_pci_config_region_setup ( while (pci_root_node != acpi_gbl_root_node) { status = acpi_ut_execute_HID (pci_root_node, &object_hID); if (ACPI_SUCCESS (status)) { - /* Got a valid _HID, check if this is a PCI root */ - + /* + * Got a valid _HID string, check if this is a PCI root. + * New for ACPI 3.0: check for a PCI Express root also. + */ if (!(ACPI_STRNCMP (object_hID.value, PCI_ROOT_HID_STRING, - sizeof (PCI_ROOT_HID_STRING)))) { + sizeof (PCI_ROOT_HID_STRING)) || + !(ACPI_STRNCMP (object_hID.value, PCI_EXPRESS_ROOT_HID_STRING, + sizeof (PCI_EXPRESS_ROOT_HID_STRING))))) { /* Install a handler for this PCI root bridge */ status = acpi_install_address_space_handler ((acpi_handle) pci_root_node, diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c index f337dc2..c5f74d7 100644 --- a/drivers/acpi/events/evxfevnt.c +++ b/drivers/acpi/events/evxfevnt.c @@ -635,7 +635,7 @@ unlock_and_exit: * PARAMETERS: gpe_device - Handle to the parent GPE Block Device * gpe_block_address - Address and space_iD * register_count - Number of GPE register pairs in the block - * interrupt_level - H/W interrupt for the block + * interrupt_number - H/W interrupt for the block * * RETURN: Status * @@ -648,7 +648,7 @@ acpi_install_gpe_block ( acpi_handle gpe_device, struct acpi_generic_address *gpe_block_address, u32 register_count, - u32 interrupt_level) + u32 interrupt_number) { acpi_status status; union acpi_operand_object *obj_desc; @@ -681,7 +681,7 @@ acpi_install_gpe_block ( * is always zero */ status = acpi_ev_create_gpe_block (node, gpe_block_address, register_count, - 0, interrupt_level, &gpe_block); + 0, interrupt_number, &gpe_block); if (ACPI_FAILURE (status)) { goto unlock_and_exit; } diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index 4085006..ae6cad8 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c @@ -51,6 +51,11 @@ #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exdump") +/* + * The following routines are used for debug output only + */ +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + /* Local prototypes */ #ifdef ACPI_FUTURE_USAGE @@ -76,11 +81,6 @@ acpi_ex_out_address ( #endif /* ACPI_FUTURE_USAGE */ -/* - * The following routines are used for debug output only - */ -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) - /******************************************************************************* * * FUNCTION: acpi_ex_dump_operand @@ -118,7 +118,7 @@ acpi_ex_dump_operand ( } if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p is a NS Node: ", obj_desc)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", obj_desc)); ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC); return; } @@ -467,7 +467,7 @@ acpi_ex_dump_operands ( } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "************* Stack dump from %s(%d), %s\n", + "************* Operand Stack dump from %s(%d), %s\n", module_name, line_number, note)); return; } diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c index 2725db0..763ffee 100644 --- a/drivers/acpi/executer/exstore.c +++ b/drivers/acpi/executer/exstore.c @@ -574,7 +574,7 @@ acpi_ex_store_object_to_node ( /* If no implicit conversion, drop into the default case below */ - if (!implicit_conversion) { + if ((!implicit_conversion) || (walk_state->opcode == AML_COPY_OP)) { /* Force execution of default (no implicit conversion) */ target_type = ACPI_TYPE_ANY; @@ -634,7 +634,7 @@ acpi_ex_store_object_to_node ( default: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Storing %s (%p) directly into node (%p), no implicit conversion\n", + "Storing %s (%p) directly into node (%p) with no implicit conversion\n", acpi_ut_get_object_type_name (source_desc), source_desc, node)); /* No conversions for all other types. Just attach the source object */ diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c index 120f30e..433588a 100644 --- a/drivers/acpi/executer/exstoren.c +++ b/drivers/acpi/executer/exstoren.c @@ -265,10 +265,6 @@ acpi_ex_store_object_to_object ( case ACPI_TYPE_BUFFER: - /* - * Note: There is different store behavior depending on the original - * source type - */ status = acpi_ex_store_buffer_to_buffer (actual_src_desc, dest_desc); break; diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c index 6c2aef0..05af953 100644 --- a/drivers/acpi/namespace/nsdump.c +++ b/drivers/acpi/namespace/nsdump.c @@ -475,7 +475,7 @@ acpi_ns_dump_one_object ( while (obj_desc) { obj_type = ACPI_TYPE_INVALID; - acpi_os_printf (" Attached Object %p: ", obj_desc); + acpi_os_printf ("Attached Object %p: ", obj_desc); /* Decode the type of attached object and dump the contents */ @@ -484,9 +484,9 @@ acpi_ns_dump_one_object ( acpi_os_printf ("(Ptr to Node)\n"); bytes_to_dump = sizeof (struct acpi_namespace_node); + ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); break; - case ACPI_DESC_TYPE_OPERAND: obj_type = ACPI_GET_OBJECT_TYPE (obj_desc); @@ -497,24 +497,19 @@ acpi_ns_dump_one_object ( bytes_to_dump = 32; } else { - acpi_os_printf ("(Ptr to ACPI Object type %s, %X)\n", - acpi_ut_get_type_name (obj_type), obj_type); + acpi_os_printf ("(Ptr to ACPI Object type %X [%s])\n", + obj_type, acpi_ut_get_type_name (obj_type)); bytes_to_dump = sizeof (union acpi_operand_object); } - break; + ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); + break; default: - acpi_os_printf ( - "(String or Buffer ptr - not an object descriptor) [%s]\n", - acpi_ut_get_descriptor_name (obj_desc)); - bytes_to_dump = 16; break; } - ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); - /* If value is NOT an internal object, we are done */ if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { @@ -525,13 +520,17 @@ acpi_ns_dump_one_object ( * Valid object, get the pointer to next level, if any */ switch (obj_type) { + case ACPI_TYPE_BUFFER: case ACPI_TYPE_STRING: + /* + * NOTE: takes advantage of common fields between string/buffer + */ + bytes_to_dump = obj_desc->string.length; obj_desc = (void *) obj_desc->string.pointer; - break; - - case ACPI_TYPE_BUFFER: - obj_desc = (void *) obj_desc->buffer.pointer; - break; + acpi_os_printf ( "(Buffer/String pointer %p length %X)\n", + obj_desc, bytes_to_dump); + ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); + goto cleanup; case ACPI_TYPE_BUFFER_FIELD: obj_desc = (union acpi_operand_object *) obj_desc->buffer_field.buffer_obj; diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c index 5744673..95ef5e8 100644 --- a/drivers/acpi/parser/psopcode.c +++ b/drivers/acpi/parser/psopcode.c @@ -311,7 +311,7 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = /* ACPI 2.0 opcodes */ /* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), -/* 6F */ ACPI_OP ("Package /*Var*/", ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER), +/* 6F */ ACPI_OP ("Package", /* Var */ ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER), /* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), /* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), /* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index 1935dab..2c3bb8c 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c @@ -48,6 +48,9 @@ #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsdump") + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + /* Local prototypes */ static void @@ -103,7 +106,6 @@ acpi_rs_dump_vendor_specific ( union acpi_resource_data *data); -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /******************************************************************************* * * FUNCTION: acpi_rs_dump_irq diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c index 11e8849..31c30a3 100644 --- a/drivers/acpi/utilities/utcopy.c +++ b/drivers/acpi/utilities/utcopy.c @@ -694,58 +694,50 @@ acpi_ut_copy_simple_object ( dest_desc->common.reference_count = reference_count; dest_desc->common.next_object = next_object; + /* New object is not static, regardless of source */ + + dest_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; + /* Handle the objects with extra data */ switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { case ACPI_TYPE_BUFFER: - - dest_desc->buffer.node = NULL; - dest_desc->common.flags = source_desc->common.flags; - /* * Allocate and copy the actual buffer if and only if: * 1) There is a valid buffer pointer - * 2) The buffer is not static (not in an ACPI table) (in this case, - * the actual pointer was already copied above) + * 2) The buffer has a length > 0 */ if ((source_desc->buffer.pointer) && - (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) { - dest_desc->buffer.pointer = NULL; - - /* Create an actual buffer only if length > 0 */ - - if (source_desc->buffer.length) { - dest_desc->buffer.pointer = - ACPI_MEM_ALLOCATE (source_desc->buffer.length); - if (!dest_desc->buffer.pointer) { - return (AE_NO_MEMORY); - } + (source_desc->buffer.length)) { + dest_desc->buffer.pointer = + ACPI_MEM_ALLOCATE (source_desc->buffer.length); + if (!dest_desc->buffer.pointer) { + return (AE_NO_MEMORY); + } - /* Copy the actual buffer data */ + /* Copy the actual buffer data */ - ACPI_MEMCPY (dest_desc->buffer.pointer, - source_desc->buffer.pointer, - source_desc->buffer.length); - } + ACPI_MEMCPY (dest_desc->buffer.pointer, + source_desc->buffer.pointer, + source_desc->buffer.length); } break; case ACPI_TYPE_STRING: - /* * Allocate and copy the actual string if and only if: * 1) There is a valid string pointer - * 2) The string is not static (not in an ACPI table) (in this case, - * the actual pointer was already copied above) + * (Pointer to a NULL string is allowed) */ - if ((source_desc->string.pointer) && - (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) { + if (source_desc->string.pointer) { dest_desc->string.pointer = ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1); if (!dest_desc->string.pointer) { return (AE_NO_MEMORY); } + /* Copy the actual string data */ + ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer, (acpi_size) source_desc->string.length + 1); } diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 2f6ab18..a268c4a 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -64,7 +64,7 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20050408 +#define ACPI_CA_VERSION 0x20050513 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/include/acpi/acevents.h b/include/acpi/acevents.h index 61a27c8..301c5cc 100644 --- a/include/acpi/acevents.h +++ b/include/acpi/acevents.h @@ -136,7 +136,7 @@ acpi_ev_create_gpe_block ( struct acpi_generic_address *gpe_block_address, u32 register_count, u8 gpe_block_base_number, - u32 interrupt_level, + u32 interrupt_number, struct acpi_gpe_block_info **return_gpe_block); acpi_status diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h index 030e641..52c6a20 100644 --- a/include/acpi/aclocal.h +++ b/include/acpi/aclocal.h @@ -365,7 +365,7 @@ struct acpi_gpe_xrupt_info struct acpi_gpe_xrupt_info *previous; struct acpi_gpe_xrupt_info *next; struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */ - u32 interrupt_level; /* System interrupt level */ + u32 interrupt_number; /* System interrupt number */ }; @@ -737,6 +737,7 @@ struct acpi_parse_state ****************************************************************************/ #define PCI_ROOT_HID_STRING "PNP0A03" +#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" struct acpi_bit_register_info { diff --git a/include/acpi/acopcode.h b/include/acpi/acopcode.h index 118ecba..093f697 100644 --- a/include/acpi/acopcode.h +++ b/include/acpi/acopcode.h @@ -246,7 +246,7 @@ #define ARGI_FIELD_OP ARGI_INVALID_OPCODE #define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) #define ARGI_IF_OP ARGI_INVALID_OPCODE #define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) #define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index f8f619f..9ca212d 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -387,7 +387,7 @@ acpi_install_gpe_block ( acpi_handle gpe_device, struct acpi_generic_address *gpe_block_address, u32 register_count, - u32 interrupt_level); + u32 interrupt_number); acpi_status acpi_remove_gpe_block ( -- cgit v0.10.2 From 88ac00f5a841dcfc5c682000f4a6add0add8caac Mon Sep 17 00:00:00 2001 From: Robert Moore Date: Thu, 26 May 2005 00:00:00 -0400 Subject: ACPICA 20050526 from Bob Moore Implemented support to execute Type 1 and Type 2 AML opcodes appearing at the module level (not within a control method.) These opcodes are executed exactly once at the time the table is loaded. This type of code was legal up until the release of ACPI 2.0B (2002) and is now supported within ACPI CA in order to provide backwards compatibility with earlier BIOS implementations. This eliminates the "Encountered executable code at module level" warning that was previously generated upon detection of such code. Fixed a problem in the interpreter where an AE_NOT_FOUND exception could inadvertently be generated during the lookup of namespace objects in the second pass parse of ACPI tables and control methods. It appears that this problem could occur during the resolution of forward references to namespace objects. Added the ACPI_MUTEX_DEBUG #ifdef to the acpi_ut_release_mutex function, corresponding to the same the deadlock detection debug code to be compiled out in the normal case, improving mutex performance (and overall subsystem performance) considerably. As suggested by Alexey Starikovskiy. Implemented a handful of miscellaneous fixes for possible memory leaks on error conditions and error handling control paths. These fixes were suggested by FreeBSD and the Coverity Prevent source code analysis tool. Added a check for a null RSDT pointer in acpi_get_firmware_table (tbxfroot.c) to prevent a fault in this error case. Signed-off-by Len Brown diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 9fc3f4c..c9d9a6c 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c @@ -139,7 +139,8 @@ acpi_ds_parse_method ( walk_state = acpi_ds_create_walk_state (owner_id, NULL, NULL, NULL); if (!walk_state) { - return_ACPI_STATUS (AE_NO_MEMORY); + status = AE_NO_MEMORY; + goto cleanup; } status = acpi_ds_init_aml_walk (walk_state, op, node, @@ -147,7 +148,7 @@ acpi_ds_parse_method ( obj_desc->method.aml_length, NULL, 1); if (ACPI_FAILURE (status)) { acpi_ds_delete_walk_state (walk_state); - return_ACPI_STATUS (status); + goto cleanup; } /* @@ -161,13 +162,14 @@ acpi_ds_parse_method ( */ status = acpi_ps_parse_aml (walk_state); if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + goto cleanup; } ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n", acpi_ut_get_node_name (obj_handle), obj_handle, op)); +cleanup: acpi_ps_delete_parse_tree (op); return_ACPI_STATUS (status); } diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c index ba13bca..750bdb1 100644 --- a/drivers/acpi/dispatcher/dsopcode.c +++ b/drivers/acpi/dispatcher/dsopcode.c @@ -119,14 +119,15 @@ acpi_ds_execute_arguments ( walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); if (!walk_state) { - return_ACPI_STATUS (AE_NO_MEMORY); + status = AE_NO_MEMORY; + goto cleanup; } status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start, aml_length, NULL, 1); if (ACPI_FAILURE (status)) { acpi_ds_delete_walk_state (walk_state); - return_ACPI_STATUS (status); + goto cleanup; } /* Mark this parse as a deferred opcode */ @@ -138,8 +139,7 @@ acpi_ds_execute_arguments ( status = acpi_ps_parse_aml (walk_state); if (ACPI_FAILURE (status)) { - acpi_ps_delete_parse_tree (op); - return_ACPI_STATUS (status); + goto cleanup; } /* Get and init the Op created above */ @@ -160,7 +160,8 @@ acpi_ds_execute_arguments ( walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); if (!walk_state) { - return_ACPI_STATUS (AE_NO_MEMORY); + status = AE_NO_MEMORY; + goto cleanup; } /* Execute the opcode and arguments */ @@ -169,13 +170,15 @@ acpi_ds_execute_arguments ( aml_length, NULL, 3); if (ACPI_FAILURE (status)) { acpi_ds_delete_walk_state (walk_state); - return_ACPI_STATUS (status); + goto cleanup; } /* Mark this execution as a deferred opcode */ walk_state->deferred_node = node; status = acpi_ps_parse_aml (walk_state); + +cleanup: acpi_ps_delete_parse_tree (op); return_ACPI_STATUS (status); } diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c index 1ac197c..e2e0a85 100644 --- a/drivers/acpi/dispatcher/dswload.c +++ b/drivers/acpi/dispatcher/dswload.c @@ -145,15 +145,6 @@ acpi_ds_load1_begin_op ( if (op) { if (!(walk_state->op_info->flags & AML_NAMED)) { -#if 0 - if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || - (walk_state->op_info->class == AML_CLASS_CONTROL)) { - acpi_os_printf ("\n\n***EXECUTABLE OPCODE %s***\n\n", - walk_state->op_info->name); - *out_op = op; - return (AE_CTRL_SKIP); - } -#endif *out_op = op; return (AE_OK); } @@ -486,6 +477,15 @@ acpi_ds_load2_begin_op ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); if (op) { + if ((walk_state->control_state) && + (walk_state->control_state->common.state == + ACPI_CONTROL_CONDITIONAL_EXECUTING)) { + /* We are executing a while loop outside of a method */ + + status = acpi_ds_exec_begin_op (walk_state, out_op); + return_ACPI_STATUS (status); + } + /* We only care about Namespace opcodes here */ if ((!(walk_state->op_info->flags & AML_NSOPCODE) && @@ -493,9 +493,14 @@ acpi_ds_load2_begin_op ( (!(walk_state->op_info->flags & AML_NAMED))) { if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || (walk_state->op_info->class == AML_CLASS_CONTROL)) { - ACPI_REPORT_WARNING (( - "Encountered executable code at module level, [%s]\n", - acpi_ps_get_opcode_name (walk_state->opcode))); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Begin/EXEC: %s (fl %8.8X)\n", walk_state->op_info->name, + walk_state->op_info->flags)); + + /* Executing a type1 or type2 opcode outside of a method */ + + status = acpi_ds_exec_begin_op (walk_state, out_op); + return_ACPI_STATUS (status); } return_ACPI_STATUS (AE_OK); } @@ -657,8 +662,10 @@ acpi_ds_load2_begin_op ( break; } + /* Add new entry into namespace */ + status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, - ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, + ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, walk_state, &(node)); break; } @@ -668,7 +675,6 @@ acpi_ds_load2_begin_op ( return_ACPI_STATUS (status); } - if (!op) { /* Create a new op */ @@ -682,9 +688,7 @@ acpi_ds_load2_begin_op ( if (node) { op->named.name = node->name.integer; } - if (out_op) { - *out_op = op; - } + *out_op = op; } /* @@ -731,9 +735,24 @@ acpi_ds_load2_end_op ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", walk_state->op_info->name, op, walk_state)); - /* Only interested in opcodes that have namespace objects */ + /* Check if opcode had an associated namespace object */ if (!(walk_state->op_info->flags & AML_NSOBJECT)) { +#ifndef ACPI_NO_METHOD_EXECUTION + /* No namespace object. Executable opcode? */ + + if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || + (walk_state->op_info->class == AML_CLASS_CONTROL)) { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "End/EXEC: %s (fl %8.8X)\n", walk_state->op_info->name, + walk_state->op_info->flags)); + + /* Executing a type1 or type2 opcode outside of a method */ + + status = acpi_ds_exec_end_op (walk_state); + return_ACPI_STATUS (status); + } +#endif return_ACPI_STATUS (AE_OK); } @@ -742,7 +761,6 @@ acpi_ds_load2_end_op ( "Ending scope Op=%p State=%p\n", op, walk_state)); } - object_type = walk_state->op_info->object_type; /* diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c index 4ef0e85..cc45d52 100644 --- a/drivers/acpi/dispatcher/dswstate.c +++ b/drivers/acpi/dispatcher/dswstate.c @@ -762,6 +762,7 @@ acpi_ds_init_aml_walk ( /* The next_op of the next_walk will be the beginning of the method */ walk_state->next_op = NULL; + walk_state->pass_number = (u8) pass_number; if (info) { if (info->parameter_type == ACPI_PARAM_GPE) { diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c index 734b2f2..8bfa6ef 100644 --- a/drivers/acpi/executer/exconfig.c +++ b/drivers/acpi/executer/exconfig.c @@ -376,16 +376,22 @@ acpi_ex_load_op ( */ status = acpi_ex_read_data_from_field (walk_state, obj_desc, &buffer_desc); if (ACPI_FAILURE (status)) { - goto cleanup; + return_ACPI_STATUS (status); } table_ptr = ACPI_CAST_PTR (struct acpi_table_header, buffer_desc->buffer.pointer); - /* Sanity check the table length */ + /* All done with the buffer_desc, delete it */ + + buffer_desc->buffer.pointer = NULL; + acpi_ut_remove_reference (buffer_desc); + + /* Sanity check the table length */ if (table_ptr->length < sizeof (struct acpi_table_header)) { - return_ACPI_STATUS (AE_BAD_HEADER); + status = AE_BAD_HEADER; + goto cleanup; } break; @@ -413,7 +419,9 @@ acpi_ex_load_op ( status = acpi_ex_add_table (table_ptr, acpi_gbl_root_node, &ddb_handle); if (ACPI_FAILURE (status)) { - goto cleanup; + /* On error, table_ptr was deallocated above */ + + return_ACPI_STATUS (status); } /* Store the ddb_handle into the Target operand */ @@ -421,17 +429,14 @@ acpi_ex_load_op ( status = acpi_ex_store (ddb_handle, target, walk_state); if (ACPI_FAILURE (status)) { (void) acpi_ex_unload_table (ddb_handle); - } - return_ACPI_STATUS (status); + /* table_ptr was deallocated above */ + return_ACPI_STATUS (status); + } cleanup: - - if (buffer_desc) { - acpi_ut_remove_reference (buffer_desc); - } - else { + if (ACPI_FAILURE (status)) { ACPI_MEM_FREE (table_ptr); } return_ACPI_STATUS (status); diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c index 22c8fa4..a690c92 100644 --- a/drivers/acpi/executer/exfield.c +++ b/drivers/acpi/executer/exfield.c @@ -87,6 +87,9 @@ acpi_ex_read_data_from_field ( if (!obj_desc) { return_ACPI_STATUS (AE_AML_NO_OPERAND); } + if (!ret_buffer_desc) { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) { /* @@ -182,7 +185,7 @@ exit: if (ACPI_FAILURE (status)) { acpi_ut_remove_reference (buffer_desc); } - else if (ret_buffer_desc) { + else { *ret_buffer_desc = buffer_desc; } diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c index 639f0bd..b6ba1a7a 100644 --- a/drivers/acpi/executer/exnames.c +++ b/drivers/acpi/executer/exnames.c @@ -438,6 +438,13 @@ acpi_ex_get_name_string ( status = AE_AML_BAD_NAME; } + if (ACPI_FAILURE (status)) { + if (name_string) { + ACPI_MEM_FREE (name_string); + } + return_ACPI_STATUS (status); + } + *out_name_string = name_string; *out_name_length = (u32) (aml_address - in_aml_address); diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c index dbdf826..ffc61dd 100644 --- a/drivers/acpi/executer/exoparg1.c +++ b/drivers/acpi/executer/exoparg1.c @@ -127,15 +127,16 @@ acpi_ex_opcode_0A_0T_1R ( cleanup: - if (!walk_state->result_obj) { - walk_state->result_obj = return_desc; - } - /* Delete return object on error */ - if (ACPI_FAILURE (status)) { + if ((ACPI_FAILURE (status)) || walk_state->result_obj) { acpi_ut_remove_reference (return_desc); } + else { + /* Save the return value */ + + walk_state->result_obj = return_desc; + } return_ACPI_STATUS (status); } diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c index a0e13e8..f81b836 100644 --- a/drivers/acpi/namespace/nsparse.c +++ b/drivers/acpi/namespace/nsparse.c @@ -146,6 +146,7 @@ acpi_ns_parse_table ( * to service the entire parse. The second pass of the parse then * performs another complete parse of the AML.. */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); status = acpi_ns_one_complete_parse (1, table_desc); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); @@ -160,6 +161,7 @@ acpi_ns_parse_table ( * overhead of this is compensated for by the fact that the * parse objects are all cached. */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); status = acpi_ns_one_complete_parse (2, table_desc); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index bbfdc1a..bdbe0d9 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c @@ -66,7 +66,7 @@ static u32 acpi_gbl_depth = 0; /* Local prototypes */ -static void +static acpi_status acpi_ps_complete_this_op ( struct acpi_walk_state *walk_state, union acpi_parse_object *op); @@ -152,13 +152,13 @@ acpi_ps_peek_opcode ( * PARAMETERS: walk_state - Current State * Op - Op to complete * - * RETURN: None. + * RETURN: Status * * DESCRIPTION: Perform any cleanup at the completion of an Op. * ******************************************************************************/ -static void +static acpi_status acpi_ps_complete_this_op ( struct acpi_walk_state *walk_state, union acpi_parse_object *op) @@ -175,19 +175,26 @@ acpi_ps_complete_this_op ( /* Check for null Op, can happen if AML code is corrupt */ if (!op) { - return_VOID; + return_ACPI_STATUS (AE_OK); /* OK for now */ } /* Delete this op and the subtree below it if asked to */ if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || (walk_state->op_info->class == AML_CLASS_ARGUMENT)) { - return_VOID; + return_ACPI_STATUS (AE_OK); } /* Make sure that we only delete this subtree */ if (op->common.parent) { + prev = op->common.parent->common.value.arg; + if (!prev) { + /* Nothing more to do */ + + goto cleanup; + } + /* * Check if we need to replace the operator and its subtree * with a return value op (placeholder op) @@ -206,7 +213,7 @@ acpi_ps_complete_this_op ( */ replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); if (!replacement_op) { - goto cleanup; + goto allocate_error; } break; @@ -223,18 +230,17 @@ acpi_ps_complete_this_op ( (op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) { replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); if (!replacement_op) { - goto cleanup; + goto allocate_error; } } - - if ((op->common.parent->common.aml_opcode == AML_NAME_OP) && - (walk_state->descending_callback != acpi_ds_exec_begin_op)) { + else if ((op->common.parent->common.aml_opcode == AML_NAME_OP) && + (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) { if ((op->common.aml_opcode == AML_BUFFER_OP) || (op->common.aml_opcode == AML_PACKAGE_OP) || (op->common.aml_opcode == AML_VAR_PACKAGE_OP)) { replacement_op = acpi_ps_alloc_op (op->common.aml_opcode); if (!replacement_op) { - goto cleanup; + goto allocate_error; } replacement_op->named.data = op->named.data; @@ -244,15 +250,15 @@ acpi_ps_complete_this_op ( break; default: + replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); if (!replacement_op) { - goto cleanup; + goto allocate_error; } } /* We must unlink this op from the parent tree */ - prev = op->common.parent->common.value.arg; if (prev == op) { /* This op is the first in the list */ @@ -298,7 +304,15 @@ cleanup: /* Now we can actually delete the subtree rooted at Op */ acpi_ps_delete_parse_tree (op); - return_VOID; + return_ACPI_STATUS (AE_OK); + + +allocate_error: + + /* Always delete the subtree, even on error */ + + acpi_ps_delete_parse_tree (op); + return_ACPI_STATUS (AE_NO_MEMORY); } @@ -443,6 +457,7 @@ acpi_ps_parse_loop ( struct acpi_walk_state *walk_state) { acpi_status status = AE_OK; + acpi_status status2; union acpi_parse_object *op = NULL; /* current op */ union acpi_parse_object *arg = NULL; union acpi_parse_object *pre_op = NULL; @@ -744,7 +759,6 @@ acpi_ps_parse_loop ( break; default: - /* * Op is not a constant or string, append each argument * to the Op @@ -770,6 +784,23 @@ acpi_ps_parse_loop ( /* Special processing for certain opcodes */ + if (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) { + switch (op->common.aml_opcode) { + case AML_IF_OP: + case AML_ELSE_OP: + case AML_WHILE_OP: + + /* Skip body of if/else/while in pass 1 */ + + parser_state->aml = parser_state->pkg_end; + walk_state->arg_count = 0; + break; + + default: + break; + } + } + switch (op->common.aml_opcode) { case AML_METHOD_OP: @@ -796,7 +827,7 @@ acpi_ps_parse_loop ( if ((op->common.parent) && (op->common.parent->common.aml_opcode == AML_NAME_OP) && - (walk_state->descending_callback != acpi_ds_exec_begin_op)) { + (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) { /* * Skip parsing of Buffers and Packages * because we don't have enough info in the first pass @@ -900,15 +931,21 @@ close_this_op: */ parser_state->scope->parse_scope.arg_count--; - /* Close this Op (will result in parse subtree deletion) */ + /* Finished with pre_op */ - acpi_ps_complete_this_op (walk_state, op); - op = NULL; if (pre_op) { acpi_ps_free_op (pre_op); pre_op = NULL; } + /* Close this Op (will result in parse subtree deletion) */ + + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } + op = NULL; + switch (status) { case AE_OK: break; @@ -936,7 +973,10 @@ close_this_op: status = walk_state->ascending_callback (walk_state); status = acpi_ps_next_parse_state (walk_state, op, status); - acpi_ps_complete_this_op (walk_state, op); + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } op = NULL; } status = AE_OK; @@ -962,7 +1002,10 @@ close_this_op: status = walk_state->ascending_callback (walk_state); status = acpi_ps_next_parse_state (walk_state, op, status); - acpi_ps_complete_this_op (walk_state, op); + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } op = NULL; status = AE_OK; @@ -976,7 +1019,10 @@ close_this_op: /* Clean up */ do { if (op) { - acpi_ps_complete_this_op (walk_state, op); + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } } acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count); @@ -990,7 +1036,10 @@ close_this_op: do { if (op) { - acpi_ps_complete_this_op (walk_state, op); + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } } acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count); @@ -1053,7 +1102,10 @@ close_this_op: /* Clean up */ do { if (op) { - acpi_ps_complete_this_op (walk_state, op); + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } } acpi_ps_pop_scope (parser_state, &op, @@ -1065,12 +1117,17 @@ close_this_op: } else if (ACPI_FAILURE (status)) { - acpi_ps_complete_this_op (walk_state, op); + /* First error is most important */ + + (void) acpi_ps_complete_this_op (walk_state, op); return_ACPI_STATUS (status); } } - acpi_ps_complete_this_op (walk_state, op); + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } } acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c index dc3c3f6..198997a 100644 --- a/drivers/acpi/tables/tbxfroot.c +++ b/drivers/acpi/tables/tbxfroot.c @@ -331,8 +331,10 @@ acpi_get_firmware_table ( cleanup: - acpi_os_unmap_memory (rsdt_info->pointer, - (acpi_size) rsdt_info->pointer->length); + if (rsdt_info->pointer) { + acpi_os_unmap_memory (rsdt_info->pointer, + (acpi_size) rsdt_info->pointer->length); + } ACPI_MEM_FREE (rsdt_info); if (header) { diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index f6de4ed..bb65877 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -787,7 +787,6 @@ acpi_ut_release_mutex ( acpi_mutex_handle mutex_id) { acpi_status status; - u32 i; u32 this_thread_id; @@ -814,25 +813,32 @@ acpi_ut_release_mutex ( return (AE_NOT_ACQUIRED); } - /* - * Deadlock prevention. Check if this thread owns any mutexes of value - * greater than this one. If so, the thread has violated the mutex - * ordering rule. This indicates a coding error somewhere in - * the ACPI subsystem code. - */ - for (i = mutex_id; i < MAX_MUTEX; i++) { - if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { - if (i == mutex_id) { - continue; - } +#ifdef ACPI_MUTEX_DEBUG + { + u32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than this one. If so, the thread has violated the mutex + * ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = mutex_id; i < MAX_MUTEX; i++) { + if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { + if (i == mutex_id) { + continue; + } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid release order: owns [%s], releasing [%s]\n", - acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid release order: owns [%s], releasing [%s]\n", + acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); - return (AE_RELEASE_DEADLOCK); + return (AE_RELEASE_DEADLOCK); + } } } +#endif /* Mark unlocked FIRST */ diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index a268c4a..6babcb1 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -64,7 +64,7 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20050513 +#define ACPI_CA_VERSION 0x20050526 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/include/acpi/acstruct.h b/include/acpi/acstruct.h index e6b9e36..4e92645 100644 --- a/include/acpi/acstruct.h +++ b/include/acpi/acstruct.h @@ -78,7 +78,7 @@ struct acpi_walk_state u8 return_used; u16 opcode; /* Current AML opcode */ u8 scope_depth; - u8 reserved1; + u8 pass_number; /* Parse pass during table load */ u32 arg_count; /* push for fixed or var args */ u32 aml_offset; u32 arg_types; -- cgit v0.10.2 From 73459f73e5d1602c59ebec114fc45185521353c1 Mon Sep 17 00:00:00 2001 From: Robert Moore Date: Fri, 24 Jun 2005 00:00:00 -0400 Subject: ACPICA 20050617-0624 from Bob Moore ACPICA 20050617: Moved the object cache operations into the OS interface layer (OSL) to allow the host OS to handle these operations if desired (for example, the Linux OSL will invoke the slab allocator). This support is optional; the compile time define ACPI_USE_LOCAL_CACHE may be used to utilize the original cache code in the ACPI CA core. The new OSL interfaces are shown below. See utalloc.c for an example implementation, and acpiosxf.h for the exact interface definitions. Thanks to Alexey Starikovskiy. acpi_os_create_cache acpi_os_delete_cache acpi_os_purge_cache acpi_os_acquire_object acpi_os_release_object Modified the interfaces to acpi_os_acquire_lock and acpi_os_release_lock to return and restore a flags parameter. This fits better with many OS lock models. Note: the current execution state (interrupt handler or not) is no longer passed to these interfaces. If necessary, the OSL must determine this state by itself, a simple and fast operation. Thanks to Alexey Starikovskiy. Fixed a problem in the ACPI table handling where a valid XSDT was assumed present if the revision of the RSDP was 2 or greater. According to the ACPI specification, the XSDT is optional in all cases, and the table manager therefore now checks for both an RSDP >=2 and a valid XSDT pointer. Otherwise, the RSDT pointer is used. Some ACPI 2.0 compliant BIOSs contain only the RSDT. Fixed an interpreter problem with the Mid() operator in the case of an input string where the resulting output string is of zero length. It now correctly returns a valid, null terminated string object instead of a string object with a null pointer. Fixed a problem with the control method argument handling to allow a store to an Arg object that already contains an object of type Device. The Device object is now correctly overwritten. Previously, an error was returned. ACPICA 20050624: Modified the new OSL cache interfaces to use ACPI_CACHE_T as the type for the host-defined cache object. This allows the OSL implementation to define and type this object in any manner desired, simplifying the OSL implementation. For example, ACPI_CACHE_T is defined as kmem_cache_t for Linux, and should be defined in the OS-specific header file for other operating systems as required. Changed the interface to AcpiOsAcquireObject to directly return the requested object as the function return (instead of ACPI_STATUS.) This change was made for performance reasons, since this is the purpose of the interface in the first place. acpi_os_acquire_object is now similar to the acpi_os_allocate interface. Thanks to Alexey Starikovskiy. Modified the initialization sequence in acpi_initialize_subsystem to call the OSL interface acpi_osl_initialize first, before any local initialization. This change was required because the global initialization now calls OSL interfaces. Restructured the code base to split some files because of size and/or because the code logically belonged in a separate file. New files are listed below. utilities/utcache.c /* Local cache interfaces */ utilities/utmutex.c /* Local mutex support */ utilities/utstate.c /* State object support */ parser/psloop.c /* Main AML parse loop */ Signed-off-by: Len Brown diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c index f799830..c83d53f 100644 --- a/drivers/acpi/dispatcher/dsmthdat.c +++ b/drivers/acpi/dispatcher/dsmthdat.c @@ -633,22 +633,11 @@ acpi_ds_store_object_to_local ( */ if (opcode == AML_ARG_OP) { /* - * Make sure that the object is the correct type. This may be - * overkill, butit is here because references were NS nodes in - * the past. Now they are operand objects of type Reference. - */ - if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) { - ACPI_REPORT_ERROR (( - "Invalid descriptor type while storing to method arg: [%s]\n", - acpi_ut_get_descriptor_name (current_obj_desc))); - return_ACPI_STATUS (AE_AML_INTERNAL); - } - - /* * If we have a valid reference object that came from ref_of(), * do the indirect store */ - if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && + if ((ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) == ACPI_DESC_TYPE_OPERAND) && + (current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && (current_obj_desc->reference.opcode == AML_REF_OF_OP)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Arg (%p) is an obj_ref(Node), storing in node %p\n", diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c index e2e0a85..d2c603f 100644 --- a/drivers/acpi/dispatcher/dswload.c +++ b/drivers/acpi/dispatcher/dswload.c @@ -50,7 +50,7 @@ #include #include -#ifdef _ACPI_ASL_COMPILER +#ifdef ACPI_ASL_COMPILER #include #endif @@ -176,7 +176,7 @@ acpi_ds_load1_begin_op ( */ status = acpi_ns_lookup (walk_state->scope_info, path, object_type, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); -#ifdef _ACPI_ASL_COMPILER +#ifdef ACPI_ASL_COMPILER if (status == AE_NOT_FOUND) { /* * Table disassembly: @@ -569,7 +569,7 @@ acpi_ds_load2_begin_op ( ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); if (ACPI_FAILURE (status)) { -#ifdef _ACPI_ASL_COMPILER +#ifdef ACPI_ASL_COMPILER if (status == AE_NOT_FOUND) { status = AE_OK; } diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c index cc45d52..d360d8e 100644 --- a/drivers/acpi/dispatcher/dswstate.c +++ b/drivers/acpi/dispatcher/dswstate.c @@ -681,7 +681,7 @@ acpi_ds_create_walk_state ( ACPI_FUNCTION_TRACE ("ds_create_walk_state"); - walk_state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_WALK); + walk_state = ACPI_MEM_CALLOCATE (sizeof (struct acpi_walk_state)); if (!walk_state) { return_PTR (NULL); } @@ -704,7 +704,7 @@ acpi_ds_create_walk_state ( status = acpi_ds_result_stack_push (walk_state); if (ACPI_FAILURE (status)) { - acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state); + ACPI_MEM_FREE (walk_state); return_PTR (NULL); } @@ -900,38 +900,11 @@ acpi_ds_delete_walk_state ( acpi_ut_delete_generic_state (state); } - acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state); + ACPI_MEM_FREE (walk_state); return_VOID; } -#ifdef ACPI_ENABLE_OBJECT_CACHE -/****************************************************************************** - * - * FUNCTION: acpi_ds_delete_walk_state_cache - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Purge the global state object cache. Used during subsystem - * termination. - * - ******************************************************************************/ - -void -acpi_ds_delete_walk_state_cache ( - void) -{ - ACPI_FUNCTION_TRACE ("ds_delete_walk_state_cache"); - - - acpi_ut_delete_generic_cache (ACPI_MEM_LIST_WALK); - return_VOID; -} -#endif - - #ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index 081120b..ede834d 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c @@ -396,6 +396,7 @@ acpi_ev_gpe_detect ( struct acpi_gpe_register_info *gpe_register_info; u32 status_reg; u32 enable_reg; + u32 flags; acpi_status status; struct acpi_gpe_block_info *gpe_block; acpi_native_uint i; @@ -412,7 +413,7 @@ acpi_ev_gpe_detect ( /* Examine all GPE blocks attached to this interrupt level */ - acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_ISR); + flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); gpe_block = gpe_xrupt_list->gpe_block_list_head; while (gpe_block) { /* @@ -476,7 +477,7 @@ acpi_ev_gpe_detect ( unlock_and_exit: - acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_ISR); + acpi_os_release_lock (acpi_gbl_gpe_lock, flags); return (int_status); } diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c index ee5419b..dfc5469 100644 --- a/drivers/acpi/events/evgpeblk.c +++ b/drivers/acpi/events/evgpeblk.c @@ -138,7 +138,6 @@ acpi_ev_valid_gpe_event ( * FUNCTION: acpi_ev_walk_gpe_list * * PARAMETERS: gpe_walk_callback - Routine called for each GPE block - * Flags - ACPI_NOT_ISR or ACPI_ISR * * RETURN: Status * @@ -148,18 +147,18 @@ acpi_ev_valid_gpe_event ( acpi_status acpi_ev_walk_gpe_list ( - ACPI_GPE_CALLBACK gpe_walk_callback, - u32 flags) + ACPI_GPE_CALLBACK gpe_walk_callback) { struct acpi_gpe_block_info *gpe_block; struct acpi_gpe_xrupt_info *gpe_xrupt_info; acpi_status status = AE_OK; + u32 flags; ACPI_FUNCTION_TRACE ("ev_walk_gpe_list"); - acpi_os_acquire_lock (acpi_gbl_gpe_lock, flags); + flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); /* Walk the interrupt level descriptor list */ @@ -500,6 +499,7 @@ acpi_ev_get_gpe_xrupt_block ( struct acpi_gpe_xrupt_info *next_gpe_xrupt; struct acpi_gpe_xrupt_info *gpe_xrupt; acpi_status status; + u32 flags; ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block"); @@ -527,7 +527,7 @@ acpi_ev_get_gpe_xrupt_block ( /* Install new interrupt descriptor with spin lock */ - acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); + flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); if (acpi_gbl_gpe_xrupt_list_head) { next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; while (next_gpe_xrupt->next) { @@ -540,7 +540,7 @@ acpi_ev_get_gpe_xrupt_block ( else { acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; } - acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); + acpi_os_release_lock (acpi_gbl_gpe_lock, flags); /* Install new interrupt handler if not SCI_INT */ @@ -577,6 +577,7 @@ acpi_ev_delete_gpe_xrupt ( struct acpi_gpe_xrupt_info *gpe_xrupt) { acpi_status status; + u32 flags; ACPI_FUNCTION_TRACE ("ev_delete_gpe_xrupt"); @@ -599,7 +600,7 @@ acpi_ev_delete_gpe_xrupt ( /* Unlink the interrupt block with lock */ - acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); + flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); if (gpe_xrupt->previous) { gpe_xrupt->previous->next = gpe_xrupt->next; } @@ -607,7 +608,7 @@ acpi_ev_delete_gpe_xrupt ( if (gpe_xrupt->next) { gpe_xrupt->next->previous = gpe_xrupt->previous; } - acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); + acpi_os_release_lock (acpi_gbl_gpe_lock, flags); /* Free the block */ @@ -637,6 +638,7 @@ acpi_ev_install_gpe_block ( struct acpi_gpe_block_info *next_gpe_block; struct acpi_gpe_xrupt_info *gpe_xrupt_block; acpi_status status; + u32 flags; ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); @@ -655,7 +657,7 @@ acpi_ev_install_gpe_block ( /* Install the new block at the end of the list with lock */ - acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); + flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); if (gpe_xrupt_block->gpe_block_list_head) { next_gpe_block = gpe_xrupt_block->gpe_block_list_head; while (next_gpe_block->next) { @@ -670,7 +672,7 @@ acpi_ev_install_gpe_block ( } gpe_block->xrupt_block = gpe_xrupt_block; - acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); + acpi_os_release_lock (acpi_gbl_gpe_lock, flags); unlock_and_exit: status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); @@ -695,6 +697,7 @@ acpi_ev_delete_gpe_block ( struct acpi_gpe_block_info *gpe_block) { acpi_status status; + u32 flags; ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); @@ -720,7 +723,7 @@ acpi_ev_delete_gpe_block ( else { /* Remove the block on this interrupt with lock */ - acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); + flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); if (gpe_block->previous) { gpe_block->previous->next = gpe_block->next; } @@ -731,7 +734,7 @@ acpi_ev_delete_gpe_block ( if (gpe_block->next) { gpe_block->next->previous = gpe_block->previous; } - acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); + acpi_os_release_lock (acpi_gbl_gpe_lock, flags); } /* Free the gpe_block */ diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c index 659e909..38d7ab8 100644 --- a/drivers/acpi/events/evmisc.c +++ b/drivers/acpi/events/evmisc.c @@ -589,7 +589,7 @@ acpi_ev_terminate ( /* Disable all GPEs in all GPE blocks */ - status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, ACPI_NOT_ISR); + status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block); /* Remove SCI handler */ @@ -602,7 +602,7 @@ acpi_ev_terminate ( /* Deallocate all handler objects installed within GPE info structs */ - status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers, ACPI_NOT_ISR); + status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers); /* Return to original mode if necessary */ diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c index 4092d47..4c1c25e 100644 --- a/drivers/acpi/events/evxface.c +++ b/drivers/acpi/events/evxface.c @@ -591,6 +591,7 @@ acpi_install_gpe_handler ( struct acpi_gpe_event_info *gpe_event_info; struct acpi_handler_info *handler; acpi_status status; + u32 flags; ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler"); @@ -643,7 +644,7 @@ acpi_install_gpe_handler ( /* Install the handler */ - acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); + flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); gpe_event_info->dispatch.handler = handler; /* Setup up dispatch flags to indicate handler (vs. method) */ @@ -651,7 +652,7 @@ acpi_install_gpe_handler ( gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); - acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); + acpi_os_release_lock (acpi_gbl_gpe_lock, flags); unlock_and_exit: @@ -685,6 +686,7 @@ acpi_remove_gpe_handler ( struct acpi_gpe_event_info *gpe_event_info; struct acpi_handler_info *handler; acpi_status status; + u32 flags; ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler"); @@ -741,7 +743,7 @@ acpi_remove_gpe_handler ( /* Remove the handler */ - acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); + flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); handler = gpe_event_info->dispatch.handler; /* Restore Method node (if any), set dispatch flags */ @@ -751,7 +753,7 @@ acpi_remove_gpe_handler ( if (handler->method_node) { gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD; } - acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); + acpi_os_release_lock (acpi_gbl_gpe_lock, flags); /* Now we can free the handler object */ diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c index 97856c4..2133162 100644 --- a/drivers/acpi/executer/exconvrt.c +++ b/drivers/acpi/executer/exconvrt.c @@ -367,7 +367,7 @@ acpi_ex_convert_to_ascii ( /* hex_length: 2 ascii hex chars per data byte */ - hex_length = ACPI_MUL_2 (data_width); + hex_length = (acpi_native_uint) ACPI_MUL_2 (data_width); for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) { /* Get one hex digit, most significant digits first */ diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index ae6cad8..7007abb 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c @@ -80,6 +80,16 @@ acpi_ex_out_address ( acpi_physical_address value); #endif /* ACPI_FUTURE_USAGE */ +static void +acpi_ex_dump_reference ( + union acpi_operand_object *obj_desc); + +static void +acpi_ex_dump_package ( + union acpi_operand_object *obj_desc, + u32 level, + u32 index); + /******************************************************************************* * @@ -508,7 +518,7 @@ acpi_ex_out_integer ( char *title, u32 value) { - acpi_os_printf ("%20s : %X\n", title, value); + acpi_os_printf ("%20s : %.2X\n", title, value); } static void @@ -565,9 +575,144 @@ acpi_ex_dump_node ( /******************************************************************************* * + * FUNCTION: acpi_ex_dump_reference + * + * PARAMETERS: Object - Descriptor to dump + * + * DESCRIPTION: Dumps a reference object + * + ******************************************************************************/ + +static void +acpi_ex_dump_reference ( + union acpi_operand_object *obj_desc) +{ + struct acpi_buffer ret_buf; + acpi_status status; + + + if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) { + acpi_os_printf ("Named Object %p ", obj_desc->reference.node); + ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; + status = acpi_ns_handle_to_pathname (obj_desc->reference.node, &ret_buf); + if (ACPI_FAILURE (status)) { + acpi_os_printf ("Could not convert name to pathname\n"); + } + else { + acpi_os_printf ("%s\n", ret_buf.pointer); + ACPI_MEM_FREE (ret_buf.pointer); + } + } + else if (obj_desc->reference.object) { + acpi_os_printf ("\nReferenced Object: %p\n", obj_desc->reference.object); + } +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ex_dump_package + * + * PARAMETERS: Object - Descriptor to dump + * Level - Indentation Level + * Index - Package index for this object + * + * DESCRIPTION: Dumps the elements of the package + * + ******************************************************************************/ + +static void +acpi_ex_dump_package ( + union acpi_operand_object *obj_desc, + u32 level, + u32 index) +{ + u32 i; + + + /* Indentation and index output */ + + if (level > 0) { + for (i = 0; i < level; i++) { + acpi_os_printf (" "); + } + + acpi_os_printf ("[%.2d] ", index); + } + + acpi_os_printf ("%p ", obj_desc); + + /* Null package elements are allowed */ + + if (!obj_desc) { + acpi_os_printf ("[Null Object]\n"); + return; + } + + /* Packages may only contain a few object types */ + + switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + case ACPI_TYPE_INTEGER: + + acpi_os_printf ("[Integer] = %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (obj_desc->integer.value)); + break; + + + case ACPI_TYPE_STRING: + + acpi_os_printf ("[String] Value: "); + for (i = 0; i < obj_desc->string.length; i++) { + acpi_os_printf ("%c", obj_desc->string.pointer[i]); + } + acpi_os_printf ("\n"); + break; + + + case ACPI_TYPE_BUFFER: + + acpi_os_printf ("[Buffer] Length %.2X = ", obj_desc->buffer.length); + if (obj_desc->buffer.length) { + acpi_ut_dump_buffer ((u8 *) obj_desc->buffer.pointer, + obj_desc->buffer.length, DB_DWORD_DISPLAY, _COMPONENT); + } + else { + acpi_os_printf ("\n"); + } + break; + + + case ACPI_TYPE_PACKAGE: + + acpi_os_printf ("[Package] Contains %d Elements: \n", + obj_desc->package.count); + + for (i = 0; i < obj_desc->package.count; i++) { + acpi_ex_dump_package (obj_desc->package.elements[i], level+1, i); + } + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + acpi_os_printf ("[Object Reference] "); + acpi_ex_dump_reference (obj_desc); + break; + + + default: + + acpi_os_printf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (obj_desc)); + break; + } +} + + +/******************************************************************************* + * * FUNCTION: acpi_ex_dump_object_descriptor * - * PARAMETERS: *Object - Descriptor to dump + * PARAMETERS: Object - Descriptor to dump * Flags - Force display if TRUE * * DESCRIPTION: Dumps the members of the object descriptor given. @@ -579,9 +724,6 @@ acpi_ex_dump_object_descriptor ( union acpi_operand_object *obj_desc, u32 flags) { - u32 i; - - ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor"); @@ -648,22 +790,13 @@ acpi_ex_dump_object_descriptor ( case ACPI_TYPE_PACKAGE: acpi_ex_out_integer ("Flags", obj_desc->package.flags); - acpi_ex_out_integer ("Count", obj_desc->package.count); - acpi_ex_out_pointer ("Elements", obj_desc->package.elements); + acpi_ex_out_integer ("Elements", obj_desc->package.count); + acpi_ex_out_pointer ("Element List", obj_desc->package.elements); /* Dump the package contents */ - if (obj_desc->package.count > 0) { - acpi_os_printf ("\nPackage Contents:\n"); - for (i = 0; i < obj_desc->package.count; i++) { - acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]); - if (obj_desc->package.elements[i]) { - acpi_os_printf (" %s", - acpi_ut_get_object_type_name (obj_desc->package.elements[i])); - } - acpi_os_printf ("\n"); - } - } + acpi_os_printf ("\nPackage Contents:\n"); + acpi_ex_dump_package (obj_desc, 0, 0); break; @@ -790,10 +923,7 @@ acpi_ex_dump_object_descriptor ( acpi_ex_out_pointer ("Node", obj_desc->reference.node); acpi_ex_out_pointer ("Where", obj_desc->reference.where); - if (obj_desc->reference.object) { - acpi_os_printf ("\nReferenced Object:\n"); - acpi_ex_dump_object_descriptor (obj_desc->reference.object, flags); - } + acpi_ex_dump_reference (obj_desc); break; diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c index 022f281..237ef28 100644 --- a/drivers/acpi/executer/exmisc.c +++ b/drivers/acpi/executer/exmisc.c @@ -302,7 +302,7 @@ acpi_ex_do_concatenate ( /* Result of two Integers is a Buffer */ /* Need enough buffer space for two integers */ - return_desc = acpi_ut_create_buffer_object ( + return_desc = acpi_ut_create_buffer_object ((acpi_size) ACPI_MUL_2 (acpi_gbl_integer_byte_width)); if (!return_desc) { status = AE_NO_MEMORY; diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c index ffc61dd..131f49a 100644 --- a/drivers/acpi/executer/exoparg1.c +++ b/drivers/acpi/executer/exoparg1.c @@ -113,8 +113,9 @@ acpi_ex_opcode_0A_0T_1R ( status = AE_NO_MEMORY; goto cleanup; } - +#if ACPI_MACHINE_WIDTH != 16 return_desc->integer.value = acpi_os_get_timer (); +#endif break; default: /* Unknown opcode */ diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c index 23b068a..197890f 100644 --- a/drivers/acpi/executer/exoparg3.c +++ b/drivers/acpi/executer/exoparg3.c @@ -160,7 +160,7 @@ acpi_ex_opcode_3A_1T_1R ( { union acpi_operand_object **operand = &walk_state->operands[0]; union acpi_operand_object *return_desc = NULL; - char *buffer; + char *buffer = NULL; acpi_status status = AE_OK; acpi_integer index; acpi_size length; @@ -193,34 +193,63 @@ acpi_ex_opcode_3A_1T_1R ( * If the index is beyond the length of the String/Buffer, or if the * requested length is zero, return a zero-length String/Buffer */ - if ((index < operand[0]->string.length) && - (length > 0)) { - /* Truncate request if larger than the actual String/Buffer */ - - if ((index + length) > - operand[0]->string.length) { - length = (acpi_size) operand[0]->string.length - - (acpi_size) index; - } + if (index >= operand[0]->string.length) { + length = 0; + } + + /* Truncate request if larger than the actual String/Buffer */ + + else if ((index + length) > operand[0]->string.length) { + length = (acpi_size) operand[0]->string.length - + (acpi_size) index; + } - /* Allocate a new buffer for the String/Buffer */ + /* Strings always have a sub-pointer, not so for buffers */ + + switch (ACPI_GET_OBJECT_TYPE (operand[0])) { + case ACPI_TYPE_STRING: + + /* Always allocate a new buffer for the String */ buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1); if (!buffer) { status = AE_NO_MEMORY; goto cleanup; } + break; + + case ACPI_TYPE_BUFFER: + + /* If the requested length is zero, don't allocate a buffer */ + + if (length > 0) { + /* Allocate a new buffer for the Buffer */ + + buffer = ACPI_MEM_CALLOCATE (length); + if (!buffer) { + status = AE_NO_MEMORY; + goto cleanup; + } + } + break; + default: /* Should not happen */ + + status = AE_AML_OPERAND_TYPE; + goto cleanup; + } + + if (length > 0) { /* Copy the portion requested */ ACPI_MEMCPY (buffer, operand[0]->string.pointer + index, length); + } - /* Set the length of the new String/Buffer */ + /* Set the length of the new String/Buffer */ - return_desc->string.pointer = buffer; - return_desc->string.length = (u32) length; - } + return_desc->string.pointer = buffer; + return_desc->string.length = (u32) length; /* Mark buffer initialized */ @@ -244,13 +273,13 @@ cleanup: /* Delete return object on error */ - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE (status) || walk_state->result_obj) { acpi_ut_remove_reference (return_desc); } /* Set the return object and exit */ - if (!walk_state->result_obj) { + else { walk_state->result_obj = return_desc; } return_ACPI_STATUS (status); diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c index 763ffee..59dbfea 100644 --- a/drivers/acpi/executer/exstore.c +++ b/drivers/acpi/executer/exstore.c @@ -147,7 +147,7 @@ acpi_ex_do_debug_object ( case ACPI_TYPE_BUFFER: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]", + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n", (u32) source_desc->buffer.length)); ACPI_DUMP_BUFFER (source_desc->buffer.pointer, (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32); diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c index 5c7ec0c..d00b0dc 100644 --- a/drivers/acpi/executer/exutils.c +++ b/drivers/acpi/executer/exutils.c @@ -369,7 +369,7 @@ acpi_ex_eisa_id_to_string ( * * RETURN: None, string * - * DESCRIPTOIN: Convert a number to string representation. Assumes string + * DESCRIPTION: Convert a number to string representation. Assumes string * buffer is large enough to hold the string. * ******************************************************************************/ diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c index 8daeabb..3536bbb 100644 --- a/drivers/acpi/hardware/hwgpe.c +++ b/drivers/acpi/hardware/hwgpe.c @@ -374,7 +374,7 @@ acpi_hw_enable_wakeup_gpe_block ( * * FUNCTION: acpi_hw_disable_all_gpes * - * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR + * PARAMETERS: None * * RETURN: Status * @@ -384,7 +384,7 @@ acpi_hw_enable_wakeup_gpe_block ( acpi_status acpi_hw_disable_all_gpes ( - u32 flags) + void) { acpi_status status; @@ -392,8 +392,8 @@ acpi_hw_disable_all_gpes ( ACPI_FUNCTION_TRACE ("hw_disable_all_gpes"); - status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, flags); - status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block, flags); + status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block); + status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block); return_ACPI_STATUS (status); } @@ -402,7 +402,7 @@ acpi_hw_disable_all_gpes ( * * FUNCTION: acpi_hw_enable_all_runtime_gpes * - * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR + * PARAMETERS: None * * RETURN: Status * @@ -412,7 +412,7 @@ acpi_hw_disable_all_gpes ( acpi_status acpi_hw_enable_all_runtime_gpes ( - u32 flags) + void) { acpi_status status; @@ -420,7 +420,7 @@ acpi_hw_enable_all_runtime_gpes ( ACPI_FUNCTION_TRACE ("hw_enable_all_runtime_gpes"); - status = acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block, flags); + status = acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block); return_ACPI_STATUS (status); } @@ -429,7 +429,7 @@ acpi_hw_enable_all_runtime_gpes ( * * FUNCTION: acpi_hw_enable_all_wakeup_gpes * - * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR + * PARAMETERS: None * * RETURN: Status * @@ -439,7 +439,7 @@ acpi_hw_enable_all_runtime_gpes ( acpi_status acpi_hw_enable_all_wakeup_gpes ( - u32 flags) + void) { acpi_status status; @@ -447,7 +447,7 @@ acpi_hw_enable_all_wakeup_gpes ( ACPI_FUNCTION_TRACE ("hw_enable_all_wakeup_gpes"); - status = acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block, flags); + status = acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block); return_ACPI_STATUS (status); } diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c index 6d9e4eb..04a0585 100644 --- a/drivers/acpi/hardware/hwregs.c +++ b/drivers/acpi/hardware/hwregs.c @@ -106,7 +106,7 @@ acpi_hw_clear_acpi_status ( /* Clear the GPE Bits in all GPE registers in all GPE blocks */ - status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block, ACPI_ISR); + status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block); unlock_and_exit: if (flags & ACPI_MTX_LOCK) { diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c index 415d342..cedee0c 100644 --- a/drivers/acpi/hardware/hwsleep.c +++ b/drivers/acpi/hardware/hwsleep.c @@ -274,13 +274,13 @@ acpi_enter_sleep_state ( * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ - status = acpi_hw_disable_all_gpes (ACPI_ISR); + status = acpi_hw_disable_all_gpes (); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } acpi_gbl_system_awake_and_running = FALSE; - status = acpi_hw_enable_all_wakeup_gpes (ACPI_ISR); + status = acpi_hw_enable_all_wakeup_gpes (); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } @@ -424,13 +424,13 @@ acpi_enter_sleep_state_s4bios ( * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ - status = acpi_hw_disable_all_gpes (ACPI_ISR); + status = acpi_hw_disable_all_gpes (); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } acpi_gbl_system_awake_and_running = FALSE; - status = acpi_hw_enable_all_wakeup_gpes (ACPI_ISR); + status = acpi_hw_enable_all_wakeup_gpes (); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } @@ -557,13 +557,13 @@ acpi_leave_sleep_state ( * 1) Disable/Clear all GPEs * 2) Enable all runtime GPEs */ - status = acpi_hw_disable_all_gpes (ACPI_NOT_ISR); + status = acpi_hw_disable_all_gpes (); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } acpi_gbl_system_awake_and_running = TRUE; - status = acpi_hw_enable_all_runtime_gpes (ACPI_NOT_ISR); + status = acpi_hw_enable_all_runtime_gpes (); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c index ece7a9d..9df0a64 100644 --- a/drivers/acpi/namespace/nsaccess.c +++ b/drivers/acpi/namespace/nsaccess.c @@ -159,7 +159,7 @@ acpi_ns_root_initialize ( obj_desc->method.param_count = (u8) ACPI_TO_INTEGER (val); obj_desc->common.flags |= AOPOBJ_DATA_VALID; -#if defined (_ACPI_ASL_COMPILER) || defined (_ACPI_DUMP_App) +#if defined (ACPI_ASL_COMPILER) || defined (ACPI_DUMP_App) /* * i_aSL Compiler cheats by putting parameter count diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c index 5653a19..3f94b08 100644 --- a/drivers/acpi/namespace/nsalloc.c +++ b/drivers/acpi/namespace/nsalloc.c @@ -83,7 +83,7 @@ acpi_ns_create_node ( return_PTR (NULL); } - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_allocated++); + ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_allocated++); node->name.integer = name; node->reference_count = 1; @@ -151,7 +151,7 @@ acpi_ns_delete_node ( } } - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); + ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_freed++); /* * Detach an object if there is one then delete the node @@ -362,7 +362,7 @@ acpi_ns_delete_children ( /* Now we can free this child object */ - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); + ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_freed++); ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", child_node, acpi_gbl_current_node_count)); diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c index 05af953..c9f35dd 100644 --- a/drivers/acpi/namespace/nsdump.c +++ b/drivers/acpi/namespace/nsdump.c @@ -208,33 +208,37 @@ acpi_ns_dump_one_object ( return (AE_OK); } - /* Indent the object according to the level */ + if (!(info->display_type & ACPI_DISPLAY_SHORT)) { + /* Indent the object according to the level */ - acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " "); + acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " "); - /* Check the node type and name */ + /* Check the node type and name */ - if (type > ACPI_TYPE_LOCAL_MAX) { - ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type)); - } + if (type > ACPI_TYPE_LOCAL_MAX) { + ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type)); + } + + if (!acpi_ut_valid_acpi_name (this_node->name.integer)) { + ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", + this_node->name.integer)); + } - if (!acpi_ut_valid_acpi_name (this_node->name.integer)) { - ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", - this_node->name.integer)); + acpi_os_printf ("%4.4s", acpi_ut_get_node_name (this_node)); } /* * Now we can print out the pertinent information */ - acpi_os_printf ("%4.4s %-12s %p ", - acpi_ut_get_node_name (this_node), acpi_ut_get_type_name (type), this_node); + acpi_os_printf (" %-12s %p ", + acpi_ut_get_type_name (type), this_node); dbg_level = acpi_dbg_level; acpi_dbg_level = 0; obj_desc = acpi_ns_get_attached_object (this_node); acpi_dbg_level = dbg_level; - switch (info->display_type) { + switch (info->display_type & ACPI_DISPLAY_MASK) { case ACPI_DISPLAY_SUMMARY: if (!obj_desc) { @@ -646,7 +650,7 @@ acpi_ns_dump_entry ( } -#ifdef _ACPI_ASL_COMPILER +#ifdef ACPI_ASL_COMPILER /******************************************************************************* * * FUNCTION: acpi_ns_dump_tables diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index bdd9f37..56e7ced 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -778,54 +778,6 @@ acpi_os_delete_lock ( return_VOID; } -/* - * Acquire a spinlock. - * - * handle is a pointer to the spinlock_t. - * flags is *not* the result of save_flags - it is an ACPI-specific flag variable - * that indicates whether we are at interrupt level. - */ -void -acpi_os_acquire_lock ( - acpi_handle handle, - u32 flags) -{ - ACPI_FUNCTION_TRACE ("os_acquire_lock"); - - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquiring spinlock[%p] from %s level\n", handle, - ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt"))); - - if (flags & ACPI_NOT_ISR) - ACPI_DISABLE_IRQS(); - - spin_lock((spinlock_t *)handle); - - return_VOID; -} - - -/* - * Release a spinlock. See above. - */ -void -acpi_os_release_lock ( - acpi_handle handle, - u32 flags) -{ - ACPI_FUNCTION_TRACE ("os_release_lock"); - - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Releasing spinlock[%p] from %s level\n", handle, - ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt"))); - - spin_unlock((spinlock_t *)handle); - - if (flags & ACPI_NOT_ISR) - ACPI_ENABLE_IRQS(); - - return_VOID; -} - - acpi_status acpi_os_create_semaphore( u32 max_units, @@ -1172,3 +1124,151 @@ unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER; EXPORT_SYMBOL(max_cstate); + +/* + * Acquire a spinlock. + * + * handle is a pointer to the spinlock_t. + * flags is *not* the result of save_flags - it is an ACPI-specific flag variable + * that indicates whether we are at interrupt level. + */ + +unsigned long +acpi_os_acquire_lock ( + acpi_handle handle) +{ + unsigned long flags; + spin_lock_irqsave((spinlock_t *)handle, flags); + return flags; +} + +/* + * Release a spinlock. See above. + */ + +void +acpi_os_release_lock ( + acpi_handle handle, + unsigned long flags) +{ + spin_unlock_irqrestore((spinlock_t *)handle, flags); +} + + +#ifndef ACPI_USE_LOCAL_CACHE + +/******************************************************************************* + * + * FUNCTION: acpi_os_create_cache + * + * PARAMETERS: CacheName - Ascii name for the cache + * ObjectSize - Size of each cached object + * MaxDepth - Maximum depth of the cache (in objects) + * ReturnCache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a cache object + * + ******************************************************************************/ + +acpi_status +acpi_os_create_cache ( + char *name, + u16 size, + u16 depth, + acpi_cache_t **cache) +{ + *cache = kmem_cache_create (name, size, 0, 0, NULL, NULL); + return AE_OK; +} + +/******************************************************************************* + * + * FUNCTION: acpi_os_purge_cache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache. + * + ******************************************************************************/ + +acpi_status +acpi_os_purge_cache ( + acpi_cache_t *cache) +{ + (void) kmem_cache_shrink(cache); + return (AE_OK); +} + +/******************************************************************************* + * + * FUNCTION: acpi_os_delete_cache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache and delete the + * cache object. + * + ******************************************************************************/ + +acpi_status +acpi_os_delete_cache ( + acpi_cache_t *cache) +{ + (void)kmem_cache_destroy(cache); + return (AE_OK); +} + +/******************************************************************************* + * + * FUNCTION: acpi_os_release_object + * + * PARAMETERS: Cache - Handle to cache object + * Object - The object to be released + * + * RETURN: None + * + * DESCRIPTION: Release an object to the specified cache. If cache is full, + * the object is deleted. + * + ******************************************************************************/ + +acpi_status +acpi_os_release_object ( + acpi_cache_t *cache, + void *object) +{ + kmem_cache_free(cache, object); + return (AE_OK); +} + +/******************************************************************************* + * + * FUNCTION: acpi_os_acquire_object + * + * PARAMETERS: Cache - Handle to cache object + * ReturnObject - Where the object is returned + * + * RETURN: Status + * + * DESCRIPTION: Get an object from the specified cache. If cache is empty, + * the object is allocated. + * + ******************************************************************************/ + +void * +acpi_os_acquire_object ( + acpi_cache_t *cache) +{ + void *object = kmem_cache_alloc(cache, GFP_KERNEL); + WARN_ON(!object); + return object; +} + +#endif + diff --git a/drivers/acpi/parser/Makefile b/drivers/acpi/parser/Makefile index bbdd286..db24ee0 100644 --- a/drivers/acpi/parser/Makefile +++ b/drivers/acpi/parser/Makefile @@ -2,7 +2,7 @@ # Makefile for all Linux ACPI interpreter subdirectories # -obj-y := psargs.o psparse.o pstree.o pswalk.o \ +obj-y := psargs.o psparse.o psloop.o pstree.o pswalk.o \ psopcode.o psscope.o psutils.o psxface.o EXTRA_CFLAGS += $(ACPI_CFLAGS) diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c new file mode 100644 index 0000000..decb2e9 --- /dev/null +++ b/drivers/acpi/parser/psloop.c @@ -0,0 +1,775 @@ +/****************************************************************************** + * + * Module Name: psloop - Main AML parse loop + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2005, R. Byron Moore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +/* + * Parse the AML and build an operation tree as most interpreters, + * like Perl, do. Parsing is done by hand rather than with a YACC + * generated parser to tightly constrain stack and dynamic memory + * usage. At the same time, parsing is kept flexible and the code + * fairly compact by parsing based on a list of AML opcode + * templates in aml_op_info[] + */ + +#include +#include +#include +#include +#include +#include + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psloop") + +static u32 acpi_gbl_depth = 0; + + +/******************************************************************************* + * + * FUNCTION: acpi_ps_parse_loop + * + * PARAMETERS: walk_state - Current state + * + * RETURN: Status + * + * DESCRIPTION: Parse AML (pointed to by the current parser state) and return + * a tree of ops. + * + ******************************************************************************/ + +acpi_status +acpi_ps_parse_loop ( + struct acpi_walk_state *walk_state) +{ + acpi_status status = AE_OK; + acpi_status status2; + union acpi_parse_object *op = NULL; /* current op */ + union acpi_parse_object *arg = NULL; + union acpi_parse_object *pre_op = NULL; + struct acpi_parse_state *parser_state; + u8 *aml_op_start = NULL; + + + ACPI_FUNCTION_TRACE_PTR ("ps_parse_loop", walk_state); + + if (walk_state->descending_callback == NULL) { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + parser_state = &walk_state->parser_state; + walk_state->arg_types = 0; + +#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) + + if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) { + /* We are restarting a preempted control method */ + + if (acpi_ps_has_completed_scope (parser_state)) { + /* + * We must check if a predicate to an IF or WHILE statement + * was just completed + */ + if ((parser_state->scope->parse_scope.op) && + ((parser_state->scope->parse_scope.op->common.aml_opcode == AML_IF_OP) || + (parser_state->scope->parse_scope.op->common.aml_opcode == AML_WHILE_OP)) && + (walk_state->control_state) && + (walk_state->control_state->common.state == + ACPI_CONTROL_PREDICATE_EXECUTING)) { + /* + * A predicate was just completed, get the value of the + * predicate and branch based on that value + */ + walk_state->op = NULL; + status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE)); + if (ACPI_FAILURE (status) && + ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) { + if (status == AE_AML_NO_RETURN_VALUE) { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invoked method did not return a value, %s\n", + acpi_format_exception (status))); + + } + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "get_predicate Failed, %s\n", + acpi_format_exception (status))); + return_ACPI_STATUS (status); + } + + status = acpi_ps_next_parse_state (walk_state, op, status); + } + + acpi_ps_pop_scope (parser_state, &op, + &walk_state->arg_types, &walk_state->arg_count); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); + } + else if (walk_state->prev_op) { + /* We were in the middle of an op */ + + op = walk_state->prev_op; + walk_state->arg_types = walk_state->prev_arg_types; + } + } +#endif + + /* Iterative parsing loop, while there is more AML to process: */ + + while ((parser_state->aml < parser_state->aml_end) || (op)) { + aml_op_start = parser_state->aml; + if (!op) { + /* Get the next opcode from the AML stream */ + + walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml, + parser_state->aml_start); + walk_state->opcode = acpi_ps_peek_opcode (parser_state); + + /* + * First cut to determine what we have found: + * 1) A valid AML opcode + * 2) A name string + * 3) An unknown/invalid opcode + */ + walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); + switch (walk_state->op_info->class) { + case AML_CLASS_ASCII: + case AML_CLASS_PREFIX: + /* + * Starts with a valid prefix or ASCII char, this is a name + * string. Convert the bare name string to a namepath. + */ + walk_state->opcode = AML_INT_NAMEPATH_OP; + walk_state->arg_types = ARGP_NAMESTRING; + break; + + case AML_CLASS_UNKNOWN: + + /* The opcode is unrecognized. Just skip unknown opcodes */ + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Found unknown opcode %X at AML address %p offset %X, ignoring\n", + walk_state->opcode, parser_state->aml, walk_state->aml_offset)); + + ACPI_DUMP_BUFFER (parser_state->aml, 128); + + /* Assume one-byte bad opcode */ + + parser_state->aml++; + continue; + + default: + + /* Found opcode info, this is a normal opcode */ + + parser_state->aml += acpi_ps_get_opcode_size (walk_state->opcode); + walk_state->arg_types = walk_state->op_info->parse_args; + break; + } + + /* Create Op structure and append to parent's argument list */ + + if (walk_state->op_info->flags & AML_NAMED) { + /* Allocate a new pre_op if necessary */ + + if (!pre_op) { + pre_op = acpi_ps_alloc_op (walk_state->opcode); + if (!pre_op) { + status = AE_NO_MEMORY; + goto close_this_op; + } + } + + pre_op->common.value.arg = NULL; + pre_op->common.aml_opcode = walk_state->opcode; + + /* + * Get and append arguments until we find the node that contains + * the name (the type ARGP_NAME). + */ + while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && + (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME)) { + status = acpi_ps_get_next_arg (walk_state, parser_state, + GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg); + if (ACPI_FAILURE (status)) { + goto close_this_op; + } + + acpi_ps_append_arg (pre_op, arg); + INCREMENT_ARG_LIST (walk_state->arg_types); + } + + /* + * Make sure that we found a NAME and didn't run out of + * arguments + */ + if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) { + status = AE_AML_NO_OPERAND; + goto close_this_op; + } + + /* We know that this arg is a name, move to next arg */ + + INCREMENT_ARG_LIST (walk_state->arg_types); + + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + walk_state->op = NULL; + + status = walk_state->descending_callback (walk_state, &op); + if (ACPI_FAILURE (status)) { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "During name lookup/catalog, %s\n", + acpi_format_exception (status))); + goto close_this_op; + } + + if (!op) { + continue; + } + + status = acpi_ps_next_parse_state (walk_state, op, status); + if (status == AE_CTRL_PENDING) { + status = AE_OK; + goto close_this_op; + } + + if (ACPI_FAILURE (status)) { + goto close_this_op; + } + + acpi_ps_append_arg (op, pre_op->common.value.arg); + acpi_gbl_depth++; + + if (op->common.aml_opcode == AML_REGION_OP) { + /* + * Defer final parsing of an operation_region body, + * because we don't have enough info in the first pass + * to parse it correctly (i.e., there may be method + * calls within the term_arg elements of the body.) + * + * However, we must continue parsing because + * the opregion is not a standalone package -- + * we don't know where the end is at this point. + * + * (Length is unknown until parse of the body complete) + */ + op->named.data = aml_op_start; + op->named.length = 0; + } + } + else { + /* Not a named opcode, just allocate Op and append to parent */ + + walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); + op = acpi_ps_alloc_op (walk_state->opcode); + if (!op) { + status = AE_NO_MEMORY; + goto close_this_op; + } + + if (walk_state->op_info->flags & AML_CREATE) { + /* + * Backup to beginning of create_xXXfield declaration + * body_length is unknown until we parse the body + */ + op->named.data = aml_op_start; + op->named.length = 0; + } + + acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op); + + if ((walk_state->descending_callback != NULL)) { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + walk_state->op = op; + + status = walk_state->descending_callback (walk_state, &op); + status = acpi_ps_next_parse_state (walk_state, op, status); + if (status == AE_CTRL_PENDING) { + status = AE_OK; + goto close_this_op; + } + + if (ACPI_FAILURE (status)) { + goto close_this_op; + } + } + } + + op->common.aml_offset = walk_state->aml_offset; + + if (walk_state->op_info) { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n", + (u32) op->common.aml_opcode, walk_state->op_info->name, + op, parser_state->aml, op->common.aml_offset)); + } + } + + + /* + * Start arg_count at zero because we don't know if there are + * any args yet + */ + walk_state->arg_count = 0; + + /* Are there any arguments that must be processed? */ + + if (walk_state->arg_types) { + /* Get arguments */ + + switch (op->common.aml_opcode) { + case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ + case AML_WORD_OP: /* AML_WORDDATA_ARG */ + case AML_DWORD_OP: /* AML_DWORDATA_ARG */ + case AML_QWORD_OP: /* AML_QWORDATA_ARG */ + case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ + + /* Fill in constant or string argument directly */ + + acpi_ps_get_next_simple_arg (parser_state, + GET_CURRENT_ARG_TYPE (walk_state->arg_types), op); + break; + + case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ + + status = acpi_ps_get_next_namepath (walk_state, parser_state, op, 1); + if (ACPI_FAILURE (status)) { + goto close_this_op; + } + + walk_state->arg_types = 0; + break; + + default: + /* + * Op is not a constant or string, append each argument + * to the Op + */ + while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && + !walk_state->arg_count) { + walk_state->aml_offset = (u32) + ACPI_PTR_DIFF (parser_state->aml, parser_state->aml_start); + + status = acpi_ps_get_next_arg (walk_state, parser_state, + GET_CURRENT_ARG_TYPE (walk_state->arg_types), + &arg); + if (ACPI_FAILURE (status)) { + goto close_this_op; + } + + if (arg) { + arg->common.aml_offset = walk_state->aml_offset; + acpi_ps_append_arg (op, arg); + } + INCREMENT_ARG_LIST (walk_state->arg_types); + } + + /* Special processing for certain opcodes */ + + if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) && + ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) { + /* + * We want to skip If/Else/While constructs during Pass1 + * because we want to actually conditionally execute the + * code during Pass2. + * + * Except for disassembly, where we always want to + * walk the If/Else/While packages + */ + switch (op->common.aml_opcode) { + case AML_IF_OP: + case AML_ELSE_OP: + case AML_WHILE_OP: + + /* Skip body of if/else/while in pass 1 */ + + parser_state->aml = parser_state->pkg_end; + walk_state->arg_count = 0; + break; + + default: + break; + } + } + + switch (op->common.aml_opcode) { + case AML_METHOD_OP: + + /* + * Skip parsing of control method + * because we don't have enough info in the first pass + * to parse it correctly. + * + * Save the length and address of the body + */ + op->named.data = parser_state->aml; + op->named.length = (u32) (parser_state->pkg_end - + parser_state->aml); + + /* Skip body of method */ + + parser_state->aml = parser_state->pkg_end; + walk_state->arg_count = 0; + break; + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + if ((op->common.parent) && + (op->common.parent->common.aml_opcode == AML_NAME_OP) && + (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) { + /* + * Skip parsing of Buffers and Packages + * because we don't have enough info in the first pass + * to parse them correctly. + */ + op->named.data = aml_op_start; + op->named.length = (u32) (parser_state->pkg_end - + aml_op_start); + + /* Skip body */ + + parser_state->aml = parser_state->pkg_end; + walk_state->arg_count = 0; + } + break; + + case AML_WHILE_OP: + + if (walk_state->control_state) { + walk_state->control_state->control.package_end = + parser_state->pkg_end; + } + break; + + default: + + /* No action for all other opcodes */ + break; + } + break; + } + } + + /* Check for arguments that need to be processed */ + + if (walk_state->arg_count) { + /* + * There are arguments (complex ones), push Op and + * prepare for argument + */ + status = acpi_ps_push_scope (parser_state, op, + walk_state->arg_types, walk_state->arg_count); + if (ACPI_FAILURE (status)) { + goto close_this_op; + } + op = NULL; + continue; + } + + /* + * All arguments have been processed -- Op is complete, + * prepare for next + */ + walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); + if (walk_state->op_info->flags & AML_NAMED) { + if (acpi_gbl_depth) { + acpi_gbl_depth--; + } + + if (op->common.aml_opcode == AML_REGION_OP) { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + * + * Completed parsing an op_region declaration, we now + * know the length. + */ + op->named.length = (u32) (parser_state->aml - op->named.data); + } + } + + if (walk_state->op_info->flags & AML_CREATE) { + /* + * Backup to beginning of create_xXXfield declaration (1 for + * Opcode) + * + * body_length is unknown until we parse the body + */ + op->named.length = (u32) (parser_state->aml - op->named.data); + } + + /* This op complete, notify the dispatcher */ + + if (walk_state->ascending_callback != NULL) { + walk_state->op = op; + walk_state->opcode = op->common.aml_opcode; + + status = walk_state->ascending_callback (walk_state); + status = acpi_ps_next_parse_state (walk_state, op, status); + if (status == AE_CTRL_PENDING) { + status = AE_OK; + goto close_this_op; + } + } + + +close_this_op: + /* + * Finished one argument of the containing scope + */ + parser_state->scope->parse_scope.arg_count--; + + /* Finished with pre_op */ + + if (pre_op) { + acpi_ps_free_op (pre_op); + pre_op = NULL; + } + + /* Close this Op (will result in parse subtree deletion) */ + + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } + op = NULL; + + switch (status) { + case AE_OK: + break; + + + case AE_CTRL_TRANSFER: + + /* We are about to transfer to a called method. */ + + walk_state->prev_op = op; + walk_state->prev_arg_types = walk_state->arg_types; + return_ACPI_STATUS (status); + + + case AE_CTRL_END: + + acpi_ps_pop_scope (parser_state, &op, + &walk_state->arg_types, &walk_state->arg_count); + + if (op) { + walk_state->op = op; + walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); + walk_state->opcode = op->common.aml_opcode; + + status = walk_state->ascending_callback (walk_state); + status = acpi_ps_next_parse_state (walk_state, op, status); + + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } + op = NULL; + } + status = AE_OK; + break; + + + case AE_CTRL_BREAK: + case AE_CTRL_CONTINUE: + + /* Pop off scopes until we find the While */ + + while (!op || (op->common.aml_opcode != AML_WHILE_OP)) { + acpi_ps_pop_scope (parser_state, &op, + &walk_state->arg_types, &walk_state->arg_count); + } + + /* Close this iteration of the While loop */ + + walk_state->op = op; + walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); + walk_state->opcode = op->common.aml_opcode; + + status = walk_state->ascending_callback (walk_state); + status = acpi_ps_next_parse_state (walk_state, op, status); + + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } + op = NULL; + + status = AE_OK; + break; + + + case AE_CTRL_TERMINATE: + + status = AE_OK; + + /* Clean up */ + do { + if (op) { + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } + } + acpi_ps_pop_scope (parser_state, &op, + &walk_state->arg_types, &walk_state->arg_count); + + } while (op); + + return_ACPI_STATUS (status); + + + default: /* All other non-AE_OK status */ + + do { + if (op) { + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } + } + acpi_ps_pop_scope (parser_state, &op, + &walk_state->arg_types, &walk_state->arg_count); + + } while (op); + + + /* + * TBD: Cleanup parse ops on error + */ +#if 0 + if (op == NULL) { + acpi_ps_pop_scope (parser_state, &op, + &walk_state->arg_types, &walk_state->arg_count); + } +#endif + walk_state->prev_op = op; + walk_state->prev_arg_types = walk_state->arg_types; + return_ACPI_STATUS (status); + } + + /* This scope complete? */ + + if (acpi_ps_has_completed_scope (parser_state)) { + acpi_ps_pop_scope (parser_state, &op, + &walk_state->arg_types, &walk_state->arg_count); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); + } + else { + op = NULL; + } + + } /* while parser_state->Aml */ + + + /* + * Complete the last Op (if not completed), and clear the scope stack. + * It is easily possible to end an AML "package" with an unbounded number + * of open scopes (such as when several ASL blocks are closed with + * sequential closing braces). We want to terminate each one cleanly. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", op)); + do { + if (op) { + if (walk_state->ascending_callback != NULL) { + walk_state->op = op; + walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); + walk_state->opcode = op->common.aml_opcode; + + status = walk_state->ascending_callback (walk_state); + status = acpi_ps_next_parse_state (walk_state, op, status); + if (status == AE_CTRL_PENDING) { + status = AE_OK; + goto close_this_op; + } + + if (status == AE_CTRL_TERMINATE) { + status = AE_OK; + + /* Clean up */ + do { + if (op) { + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } + } + + acpi_ps_pop_scope (parser_state, &op, + &walk_state->arg_types, &walk_state->arg_count); + + } while (op); + + return_ACPI_STATUS (status); + } + + else if (ACPI_FAILURE (status)) { + /* First error is most important */ + + (void) acpi_ps_complete_this_op (walk_state, op); + return_ACPI_STATUS (status); + } + } + + status2 = acpi_ps_complete_this_op (walk_state, op); + if (ACPI_FAILURE (status2)) { + return_ACPI_STATUS (status2); + } + } + + acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, + &walk_state->arg_count); + + } while (op); + + return_ACPI_STATUS (status); +} + + diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c index 95ef5e8..6f7594a 100644 --- a/drivers/acpi/parser/psopcode.c +++ b/drivers/acpi/parser/psopcode.c @@ -428,33 +428,23 @@ acpi_ps_get_opcode_info ( /* * Detect normal 8-bit opcode or extended 16-bit opcode */ - switch ((u8) (opcode >> 8)) { - case 0: - + if (!(opcode & 0xFF00)) { /* Simple (8-bit) opcode: 0-255, can't index beyond table */ return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]); + } - case AML_EXTOP: - - /* Extended (16-bit, prefix+opcode) opcode */ - - if (((u8) opcode) <= MAX_EXTENDED_OPCODE) { - return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]); - } - - /* Else fall through to error case below */ - /*lint -fallthrough */ - - default: + if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) && + (((u8) opcode) <= MAX_EXTENDED_OPCODE)) { + /* Valid extended (16-bit) opcode */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown AML opcode [%4.4X]\n", opcode)); - break; + return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]); } + /* Unknown AML opcode */ - /* Default is "unknown opcode" */ + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown AML opcode [%4.4X]\n", opcode)); return (&acpi_gbl_aml_op_info [_UNK]); } diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index bdbe0d9..16b84a3 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c @@ -62,26 +62,6 @@ ACPI_MODULE_NAME ("psparse") -static u32 acpi_gbl_depth = 0; - -/* Local prototypes */ - -static acpi_status -acpi_ps_complete_this_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op); - -static acpi_status -acpi_ps_next_parse_state ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - acpi_status callback_status); - -static acpi_status -acpi_ps_parse_loop ( - struct acpi_walk_state *walk_state); - - /******************************************************************************* * * FUNCTION: acpi_ps_get_opcode_size @@ -134,8 +114,8 @@ acpi_ps_peek_opcode ( aml = parser_state->aml; opcode = (u16) ACPI_GET8 (aml); - if (opcode == AML_EXTOP) { - /* Extended opcode */ + if (opcode == AML_EXTENDED_OP_PREFIX) { + /* Extended opcode, get the second opcode byte */ aml++; opcode = (u16) ((opcode << 8) | ACPI_GET8 (aml)); @@ -158,7 +138,7 @@ acpi_ps_peek_opcode ( * ******************************************************************************/ -static acpi_status +acpi_status acpi_ps_complete_this_op ( struct acpi_walk_state *walk_state, union acpi_parse_object *op) @@ -331,7 +311,7 @@ allocate_error: * ******************************************************************************/ -static acpi_status +acpi_status acpi_ps_next_parse_state ( struct acpi_walk_state *walk_state, union acpi_parse_object *op, @@ -441,706 +421,6 @@ acpi_ps_next_parse_state ( /******************************************************************************* * - * FUNCTION: acpi_ps_parse_loop - * - * PARAMETERS: walk_state - Current state - * - * RETURN: Status - * - * DESCRIPTION: Parse AML (pointed to by the current parser state) and return - * a tree of ops. - * - ******************************************************************************/ - -static acpi_status -acpi_ps_parse_loop ( - struct acpi_walk_state *walk_state) -{ - acpi_status status = AE_OK; - acpi_status status2; - union acpi_parse_object *op = NULL; /* current op */ - union acpi_parse_object *arg = NULL; - union acpi_parse_object *pre_op = NULL; - struct acpi_parse_state *parser_state; - u8 *aml_op_start = NULL; - - - ACPI_FUNCTION_TRACE_PTR ("ps_parse_loop", walk_state); - - if (walk_state->descending_callback == NULL) { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - parser_state = &walk_state->parser_state; - walk_state->arg_types = 0; - -#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) - - if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) { - /* We are restarting a preempted control method */ - - if (acpi_ps_has_completed_scope (parser_state)) { - /* - * We must check if a predicate to an IF or WHILE statement - * was just completed - */ - if ((parser_state->scope->parse_scope.op) && - ((parser_state->scope->parse_scope.op->common.aml_opcode == AML_IF_OP) || - (parser_state->scope->parse_scope.op->common.aml_opcode == AML_WHILE_OP)) && - (walk_state->control_state) && - (walk_state->control_state->common.state == - ACPI_CONTROL_PREDICATE_EXECUTING)) { - /* - * A predicate was just completed, get the value of the - * predicate and branch based on that value - */ - walk_state->op = NULL; - status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE)); - if (ACPI_FAILURE (status) && - ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) { - if (status == AE_AML_NO_RETURN_VALUE) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invoked method did not return a value, %s\n", - acpi_format_exception (status))); - - } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "get_predicate Failed, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); - } - - status = acpi_ps_next_parse_state (walk_state, op, status); - } - - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); - } - else if (walk_state->prev_op) { - /* We were in the middle of an op */ - - op = walk_state->prev_op; - walk_state->arg_types = walk_state->prev_arg_types; - } - } -#endif - - /* Iterative parsing loop, while there is more AML to process: */ - - while ((parser_state->aml < parser_state->aml_end) || (op)) { - aml_op_start = parser_state->aml; - if (!op) { - /* Get the next opcode from the AML stream */ - - walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml, - parser_state->aml_start); - walk_state->opcode = acpi_ps_peek_opcode (parser_state); - - /* - * First cut to determine what we have found: - * 1) A valid AML opcode - * 2) A name string - * 3) An unknown/invalid opcode - */ - walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); - switch (walk_state->op_info->class) { - case AML_CLASS_ASCII: - case AML_CLASS_PREFIX: - /* - * Starts with a valid prefix or ASCII char, this is a name - * string. Convert the bare name string to a namepath. - */ - walk_state->opcode = AML_INT_NAMEPATH_OP; - walk_state->arg_types = ARGP_NAMESTRING; - break; - - case AML_CLASS_UNKNOWN: - - /* The opcode is unrecognized. Just skip unknown opcodes */ - - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Found unknown opcode %X at AML address %p offset %X, ignoring\n", - walk_state->opcode, parser_state->aml, walk_state->aml_offset)); - - ACPI_DUMP_BUFFER (parser_state->aml, 128); - - /* Assume one-byte bad opcode */ - - parser_state->aml++; - continue; - - default: - - /* Found opcode info, this is a normal opcode */ - - parser_state->aml += acpi_ps_get_opcode_size (walk_state->opcode); - walk_state->arg_types = walk_state->op_info->parse_args; - break; - } - - /* Create Op structure and append to parent's argument list */ - - if (walk_state->op_info->flags & AML_NAMED) { - /* Allocate a new pre_op if necessary */ - - if (!pre_op) { - pre_op = acpi_ps_alloc_op (walk_state->opcode); - if (!pre_op) { - status = AE_NO_MEMORY; - goto close_this_op; - } - } - - pre_op->common.value.arg = NULL; - pre_op->common.aml_opcode = walk_state->opcode; - - /* - * Get and append arguments until we find the node that contains - * the name (the type ARGP_NAME). - */ - while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && - (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME)) { - status = acpi_ps_get_next_arg (walk_state, parser_state, - GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg); - if (ACPI_FAILURE (status)) { - goto close_this_op; - } - - acpi_ps_append_arg (pre_op, arg); - INCREMENT_ARG_LIST (walk_state->arg_types); - } - - /* - * Make sure that we found a NAME and didn't run out of - * arguments - */ - if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) { - status = AE_AML_NO_OPERAND; - goto close_this_op; - } - - /* We know that this arg is a name, move to next arg */ - - INCREMENT_ARG_LIST (walk_state->arg_types); - - /* - * Find the object. This will either insert the object into - * the namespace or simply look it up - */ - walk_state->op = NULL; - - status = walk_state->descending_callback (walk_state, &op); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "During name lookup/catalog, %s\n", - acpi_format_exception (status))); - goto close_this_op; - } - - if (!op) { - continue; - } - - status = acpi_ps_next_parse_state (walk_state, op, status); - if (status == AE_CTRL_PENDING) { - status = AE_OK; - goto close_this_op; - } - - if (ACPI_FAILURE (status)) { - goto close_this_op; - } - - acpi_ps_append_arg (op, pre_op->common.value.arg); - acpi_gbl_depth++; - - if (op->common.aml_opcode == AML_REGION_OP) { - /* - * Defer final parsing of an operation_region body, - * because we don't have enough info in the first pass - * to parse it correctly (i.e., there may be method - * calls within the term_arg elements of the body.) - * - * However, we must continue parsing because - * the opregion is not a standalone package -- - * we don't know where the end is at this point. - * - * (Length is unknown until parse of the body complete) - */ - op->named.data = aml_op_start; - op->named.length = 0; - } - } - else { - /* Not a named opcode, just allocate Op and append to parent */ - - walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); - op = acpi_ps_alloc_op (walk_state->opcode); - if (!op) { - status = AE_NO_MEMORY; - goto close_this_op; - } - - if (walk_state->op_info->flags & AML_CREATE) { - /* - * Backup to beginning of create_xXXfield declaration - * body_length is unknown until we parse the body - */ - op->named.data = aml_op_start; - op->named.length = 0; - } - - acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op); - - if ((walk_state->descending_callback != NULL)) { - /* - * Find the object. This will either insert the object into - * the namespace or simply look it up - */ - walk_state->op = op; - - status = walk_state->descending_callback (walk_state, &op); - status = acpi_ps_next_parse_state (walk_state, op, status); - if (status == AE_CTRL_PENDING) { - status = AE_OK; - goto close_this_op; - } - - if (ACPI_FAILURE (status)) { - goto close_this_op; - } - } - } - - op->common.aml_offset = walk_state->aml_offset; - - if (walk_state->op_info) { - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n", - (u32) op->common.aml_opcode, walk_state->op_info->name, - op, parser_state->aml, op->common.aml_offset)); - } - } - - - /* - * Start arg_count at zero because we don't know if there are - * any args yet - */ - walk_state->arg_count = 0; - - /* Are there any arguments that must be processed? */ - - if (walk_state->arg_types) { - /* Get arguments */ - - switch (op->common.aml_opcode) { - case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ - case AML_WORD_OP: /* AML_WORDDATA_ARG */ - case AML_DWORD_OP: /* AML_DWORDATA_ARG */ - case AML_QWORD_OP: /* AML_QWORDATA_ARG */ - case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ - - /* Fill in constant or string argument directly */ - - acpi_ps_get_next_simple_arg (parser_state, - GET_CURRENT_ARG_TYPE (walk_state->arg_types), op); - break; - - case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ - - status = acpi_ps_get_next_namepath (walk_state, parser_state, op, 1); - if (ACPI_FAILURE (status)) { - goto close_this_op; - } - - walk_state->arg_types = 0; - break; - - default: - /* - * Op is not a constant or string, append each argument - * to the Op - */ - while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && - !walk_state->arg_count) { - walk_state->aml_offset = (u32) - ACPI_PTR_DIFF (parser_state->aml, parser_state->aml_start); - - status = acpi_ps_get_next_arg (walk_state, parser_state, - GET_CURRENT_ARG_TYPE (walk_state->arg_types), - &arg); - if (ACPI_FAILURE (status)) { - goto close_this_op; - } - - if (arg) { - arg->common.aml_offset = walk_state->aml_offset; - acpi_ps_append_arg (op, arg); - } - INCREMENT_ARG_LIST (walk_state->arg_types); - } - - /* Special processing for certain opcodes */ - - if (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) { - switch (op->common.aml_opcode) { - case AML_IF_OP: - case AML_ELSE_OP: - case AML_WHILE_OP: - - /* Skip body of if/else/while in pass 1 */ - - parser_state->aml = parser_state->pkg_end; - walk_state->arg_count = 0; - break; - - default: - break; - } - } - - switch (op->common.aml_opcode) { - case AML_METHOD_OP: - - /* - * Skip parsing of control method - * because we don't have enough info in the first pass - * to parse it correctly. - * - * Save the length and address of the body - */ - op->named.data = parser_state->aml; - op->named.length = (u32) (parser_state->pkg_end - - parser_state->aml); - - /* Skip body of method */ - - parser_state->aml = parser_state->pkg_end; - walk_state->arg_count = 0; - break; - - case AML_BUFFER_OP: - case AML_PACKAGE_OP: - case AML_VAR_PACKAGE_OP: - - if ((op->common.parent) && - (op->common.parent->common.aml_opcode == AML_NAME_OP) && - (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) { - /* - * Skip parsing of Buffers and Packages - * because we don't have enough info in the first pass - * to parse them correctly. - */ - op->named.data = aml_op_start; - op->named.length = (u32) (parser_state->pkg_end - - aml_op_start); - - /* Skip body */ - - parser_state->aml = parser_state->pkg_end; - walk_state->arg_count = 0; - } - break; - - case AML_WHILE_OP: - - if (walk_state->control_state) { - walk_state->control_state->control.package_end = - parser_state->pkg_end; - } - break; - - default: - - /* No action for all other opcodes */ - break; - } - break; - } - } - - /* Check for arguments that need to be processed */ - - if (walk_state->arg_count) { - /* - * There are arguments (complex ones), push Op and - * prepare for argument - */ - status = acpi_ps_push_scope (parser_state, op, - walk_state->arg_types, walk_state->arg_count); - if (ACPI_FAILURE (status)) { - goto close_this_op; - } - op = NULL; - continue; - } - - /* - * All arguments have been processed -- Op is complete, - * prepare for next - */ - walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); - if (walk_state->op_info->flags & AML_NAMED) { - if (acpi_gbl_depth) { - acpi_gbl_depth--; - } - - if (op->common.aml_opcode == AML_REGION_OP) { - /* - * Skip parsing of control method or opregion body, - * because we don't have enough info in the first pass - * to parse them correctly. - * - * Completed parsing an op_region declaration, we now - * know the length. - */ - op->named.length = (u32) (parser_state->aml - op->named.data); - } - } - - if (walk_state->op_info->flags & AML_CREATE) { - /* - * Backup to beginning of create_xXXfield declaration (1 for - * Opcode) - * - * body_length is unknown until we parse the body - */ - op->named.length = (u32) (parser_state->aml - op->named.data); - } - - /* This op complete, notify the dispatcher */ - - if (walk_state->ascending_callback != NULL) { - walk_state->op = op; - walk_state->opcode = op->common.aml_opcode; - - status = walk_state->ascending_callback (walk_state); - status = acpi_ps_next_parse_state (walk_state, op, status); - if (status == AE_CTRL_PENDING) { - status = AE_OK; - goto close_this_op; - } - } - - -close_this_op: - /* - * Finished one argument of the containing scope - */ - parser_state->scope->parse_scope.arg_count--; - - /* Finished with pre_op */ - - if (pre_op) { - acpi_ps_free_op (pre_op); - pre_op = NULL; - } - - /* Close this Op (will result in parse subtree deletion) */ - - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); - } - op = NULL; - - switch (status) { - case AE_OK: - break; - - - case AE_CTRL_TRANSFER: - - /* We are about to transfer to a called method. */ - - walk_state->prev_op = op; - walk_state->prev_arg_types = walk_state->arg_types; - return_ACPI_STATUS (status); - - - case AE_CTRL_END: - - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); - - if (op) { - walk_state->op = op; - walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); - walk_state->opcode = op->common.aml_opcode; - - status = walk_state->ascending_callback (walk_state); - status = acpi_ps_next_parse_state (walk_state, op, status); - - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); - } - op = NULL; - } - status = AE_OK; - break; - - - case AE_CTRL_BREAK: - case AE_CTRL_CONTINUE: - - /* Pop off scopes until we find the While */ - - while (!op || (op->common.aml_opcode != AML_WHILE_OP)) { - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); - } - - /* Close this iteration of the While loop */ - - walk_state->op = op; - walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); - walk_state->opcode = op->common.aml_opcode; - - status = walk_state->ascending_callback (walk_state); - status = acpi_ps_next_parse_state (walk_state, op, status); - - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); - } - op = NULL; - - status = AE_OK; - break; - - - case AE_CTRL_TERMINATE: - - status = AE_OK; - - /* Clean up */ - do { - if (op) { - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); - } - } - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); - - } while (op); - - return_ACPI_STATUS (status); - - - default: /* All other non-AE_OK status */ - - do { - if (op) { - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); - } - } - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); - - } while (op); - - - /* - * TBD: Cleanup parse ops on error - */ -#if 0 - if (op == NULL) { - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); - } -#endif - walk_state->prev_op = op; - walk_state->prev_arg_types = walk_state->arg_types; - return_ACPI_STATUS (status); - } - - /* This scope complete? */ - - if (acpi_ps_has_completed_scope (parser_state)) { - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); - } - else { - op = NULL; - } - - } /* while parser_state->Aml */ - - - /* - * Complete the last Op (if not completed), and clear the scope stack. - * It is easily possible to end an AML "package" with an unbounded number - * of open scopes (such as when several ASL blocks are closed with - * sequential closing braces). We want to terminate each one cleanly. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", op)); - do { - if (op) { - if (walk_state->ascending_callback != NULL) { - walk_state->op = op; - walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); - walk_state->opcode = op->common.aml_opcode; - - status = walk_state->ascending_callback (walk_state); - status = acpi_ps_next_parse_state (walk_state, op, status); - if (status == AE_CTRL_PENDING) { - status = AE_OK; - goto close_this_op; - } - - if (status == AE_CTRL_TERMINATE) { - status = AE_OK; - - /* Clean up */ - do { - if (op) { - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); - } - } - - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); - - } while (op); - - return_ACPI_STATUS (status); - } - - else if (ACPI_FAILURE (status)) { - /* First error is most important */ - - (void) acpi_ps_complete_this_op (walk_state, op); - return_ACPI_STATUS (status); - } - } - - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); - } - } - - acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, - &walk_state->arg_count); - - } while (op); - - return_ACPI_STATUS (status); -} - - -/******************************************************************************* - * * FUNCTION: acpi_ps_parse_aml * * PARAMETERS: walk_state - Current state diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c index a10f887..19a2702 100644 --- a/drivers/acpi/parser/psutils.c +++ b/drivers/acpi/parser/psutils.c @@ -154,12 +154,14 @@ acpi_ps_alloc_op ( if (flags == ACPI_PARSEOP_GENERIC) { /* The generic op (default) is by far the most common (16 to 1) */ - op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE); + op = acpi_os_acquire_object (acpi_gbl_ps_node_cache); + memset(op, 0, sizeof(struct acpi_parse_obj_common)); } else { /* Extended parseop */ - op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE_EXT); + op = acpi_os_acquire_object (acpi_gbl_ps_node_ext_cache); + memset(op, 0, sizeof(struct acpi_parse_obj_named)); } /* Initialize the Op */ @@ -198,41 +200,14 @@ acpi_ps_free_op ( } if (op->common.flags & ACPI_PARSEOP_GENERIC) { - acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE, op); + acpi_os_release_object (acpi_gbl_ps_node_cache, op); } else { - acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE_EXT, op); + acpi_os_release_object (acpi_gbl_ps_node_ext_cache, op); } } -#ifdef ACPI_ENABLE_OBJECT_CACHE -/******************************************************************************* - * - * FUNCTION: acpi_ps_delete_parse_cache - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Free all objects that are on the parse cache list. - * - ******************************************************************************/ - -void -acpi_ps_delete_parse_cache ( - void) -{ - ACPI_FUNCTION_TRACE ("ps_delete_parse_cache"); - - - acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE); - acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE_EXT); - return_VOID; -} -#endif - - /******************************************************************************* * * FUNCTION: Utility functions diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c index 92e0c31..d4ff71f 100644 --- a/drivers/acpi/tables/tbconvrt.c +++ b/drivers/acpi/tables/tbconvrt.c @@ -97,7 +97,9 @@ acpi_tb_get_table_count ( ACPI_FUNCTION_ENTRY (); - if (RSDP->revision < 2) { + /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ + + if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { pointer_size = sizeof (u32); } else { @@ -158,7 +160,9 @@ acpi_tb_convert_to_xsdt ( /* Copy the table pointers */ for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { - if (acpi_gbl_RSDP->revision < 2) { + /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ + + if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], (ACPI_CAST_PTR (struct rsdt_descriptor_rev1, table_info->pointer))->table_offset_entry[i]); diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c index b7ffe39..13c6ddb 100644 --- a/drivers/acpi/tables/tbrsdt.c +++ b/drivers/acpi/tables/tbrsdt.c @@ -159,8 +159,8 @@ cleanup: * * RETURN: None, Address * - * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the - * version of the RSDP + * DESCRIPTION: Extract the address of either the RSDT or XSDT, depending on the + * version of the RSDP and whether the XSDT pointer is valid * ******************************************************************************/ @@ -174,16 +174,19 @@ acpi_tb_get_rsdt_address ( out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; - /* - * For RSDP revision 0 or 1, we use the RSDT. - * For RSDP revision 2 (and above), we use the XSDT - */ - if (acpi_gbl_RSDP->revision < 2) { - out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address; - } - else { + /* Use XSDT if it is present */ + + if ((acpi_gbl_RSDP->revision >= 2) && + acpi_gbl_RSDP->xsdt_physical_address) { out_address->pointer.value = acpi_gbl_RSDP->xsdt_physical_address; + acpi_gbl_root_table_type = ACPI_TABLE_TYPE_XSDT; + } + else { + /* No XSDT, use the RSDT */ + + out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address; + acpi_gbl_root_table_type = ACPI_TABLE_TYPE_RSDT; } } @@ -211,10 +214,9 @@ acpi_tb_validate_rsdt ( /* - * For RSDP revision 0 or 1, we use the RSDT. - * For RSDP revision 2 and above, we use the XSDT + * Search for appropriate signature, RSDT or XSDT */ - if (acpi_gbl_RSDP->revision < 2) { + if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG, sizeof (RSDT_SIG) -1); } @@ -236,11 +238,11 @@ acpi_tb_validate_rsdt ( acpi_gbl_RSDP->rsdt_physical_address, (void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address)); - if (acpi_gbl_RSDP->revision < 2) { - ACPI_REPORT_ERROR (("Looking for RSDT (RSDP->Rev < 2)\n")) + if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { + ACPI_REPORT_ERROR (("Looking for RSDT\n")) } else { - ACPI_REPORT_ERROR (("Looking for XSDT (RSDP->Rev >= 2)\n")) + ACPI_REPORT_ERROR (("Looking for XSDT\n")) } ACPI_DUMP_BUFFER ((char *) table_ptr, 48); diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c index 198997a..fe9c831 100644 --- a/drivers/acpi/tables/tbxfroot.c +++ b/drivers/acpi/tables/tbxfroot.c @@ -287,9 +287,11 @@ acpi_get_firmware_table ( * requested table */ for (i = 0, j = 0; i < table_count; i++) { - /* Get the next table pointer, handle RSDT vs. XSDT */ - - if (acpi_gbl_RSDP->revision < 2) { + /* + * Get the next table pointer, handle RSDT vs. XSDT + * RSDT pointers are 32 bits, XSDT pointers are 64 bits + */ + if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { address.pointer.value = (ACPI_CAST_PTR ( RSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; } diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile index 939c447..e87108b 100644 --- a/drivers/acpi/utilities/Makefile +++ b/drivers/acpi/utilities/Makefile @@ -3,6 +3,6 @@ # obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ - utcopy.o utdelete.o utglobal.o utmath.o utobject.o + utcopy.o utdelete.o utglobal.o utmath.o utobject.o utstate.o utmutex.o utobject.o utcache.o EXTRA_CFLAGS += $(ACPI_CFLAGS) diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index c4e7f98..5061c6f 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: utalloc - local cache and memory allocation routines + * Module Name: utalloc - local memory allocation routines * *****************************************************************************/ @@ -52,12 +52,10 @@ #ifdef ACPI_DBG_TRACK_ALLOCATIONS static struct acpi_debug_mem_block * acpi_ut_find_allocation ( - u32 list_id, void *allocation); static acpi_status acpi_ut_track_allocation ( - u32 list_id, struct acpi_debug_mem_block *address, acpi_size size, u8 alloc_type, @@ -67,206 +65,118 @@ acpi_ut_track_allocation ( static acpi_status acpi_ut_remove_allocation ( - u32 list_id, struct acpi_debug_mem_block *address, u32 component, char *module, u32 line); #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ - -/******************************************************************************* - * - * FUNCTION: acpi_ut_release_to_cache - * - * PARAMETERS: list_id - Memory list/cache ID - * Object - The object to be released - * - * RETURN: None - * - * DESCRIPTION: Release an object to the specified cache. If cache is full, - * the object is deleted. - * - ******************************************************************************/ - -void -acpi_ut_release_to_cache ( - u32 list_id, - void *object) -{ - struct acpi_memory_list *cache_info; - - - ACPI_FUNCTION_ENTRY (); - - - cache_info = &acpi_gbl_memory_lists[list_id]; - -#ifdef ACPI_ENABLE_OBJECT_CACHE - - /* If walk cache is full, just free this wallkstate object */ - - if (cache_info->cache_depth >= cache_info->max_cache_depth) { - ACPI_MEM_FREE (object); - ACPI_MEM_TRACKING (cache_info->total_freed++); - } - - /* Otherwise put this object back into the cache */ - - else { - if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) { - return; - } - - /* Mark the object as cached */ - - ACPI_MEMSET (object, 0xCA, cache_info->object_size); - ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED); - - /* Put the object at the head of the cache list */ - - * (ACPI_CAST_INDIRECT_PTR (char, - &(((char *) object)[cache_info->link_offset]))) = cache_info->list_head; - cache_info->list_head = object; - cache_info->cache_depth++; - - (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); - } - -#else - - /* Object cache is disabled; just free the object */ - - ACPI_MEM_FREE (object); - ACPI_MEM_TRACKING (cache_info->total_freed++); +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +static acpi_status +acpi_ut_create_list ( + char *list_name, + u16 object_size, + acpi_handle *return_cache); #endif -} /******************************************************************************* * - * FUNCTION: acpi_ut_acquire_from_cache + * FUNCTION: acpi_ut_create_caches * - * PARAMETERS: list_id - Memory list ID + * PARAMETERS: None * - * RETURN: A requested object. NULL if the object could not be - * allocated. + * RETURN: Status * - * DESCRIPTION: Get an object from the specified cache. If cache is empty, - * the object is allocated. + * DESCRIPTION: Create all local caches * ******************************************************************************/ -void * -acpi_ut_acquire_from_cache ( - u32 list_id) +acpi_status +acpi_ut_create_caches ( + void) { - struct acpi_memory_list *cache_info; - void *object; - - - ACPI_FUNCTION_NAME ("ut_acquire_from_cache"); + acpi_status status; - cache_info = &acpi_gbl_memory_lists[list_id]; +#ifdef ACPI_DBG_TRACK_ALLOCATIONS -#ifdef ACPI_ENABLE_OBJECT_CACHE + /* Memory allocation lists */ - if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) { - return (NULL); + status = acpi_ut_create_list ("Acpi-Global", 0, + &acpi_gbl_global_list); + if (ACPI_FAILURE (status)) { + return (status); } - ACPI_MEM_TRACKING (cache_info->cache_requests++); - - /* Check the cache first */ - - if (cache_info->list_head) { - /* There is an object available, use it */ - - object = cache_info->list_head; - cache_info->list_head = *(ACPI_CAST_INDIRECT_PTR (char, - &(((char *) object)[cache_info->link_offset]))); - - ACPI_MEM_TRACKING (cache_info->cache_hits++); - cache_info->cache_depth--; - -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p from %s\n", - object, acpi_gbl_memory_lists[list_id].list_name)); + status = acpi_ut_create_list ("Acpi-Namespace", sizeof (struct acpi_namespace_node), + &acpi_gbl_ns_node_list); + if (ACPI_FAILURE (status)) { + return (status); + } #endif - if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) { - return (NULL); - } - - /* Clear (zero) the previously used Object */ + /* Object Caches, for frequently used objects */ - ACPI_MEMSET (object, 0, cache_info->object_size); + status = acpi_os_create_cache ("acpi_state", sizeof (union acpi_generic_state), + ACPI_MAX_STATE_CACHE_DEPTH, &acpi_gbl_state_cache); + if (ACPI_FAILURE (status)) { + return (status); } - else { - /* The cache is empty, create a new object */ - - /* Avoid deadlock with ACPI_MEM_CALLOCATE */ - - if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) { - return (NULL); - } - - object = ACPI_MEM_CALLOCATE (cache_info->object_size); - ACPI_MEM_TRACKING (cache_info->total_allocated++); + status = acpi_os_create_cache ("acpi_parse", sizeof (struct acpi_parse_obj_common), + ACPI_MAX_PARSE_CACHE_DEPTH, &acpi_gbl_ps_node_cache); + if (ACPI_FAILURE (status)) { + return (status); } -#else - - /* Object cache is disabled; just allocate the object */ + status = acpi_os_create_cache ("acpi_parse_ext", sizeof (struct acpi_parse_obj_named), + ACPI_MAX_EXTPARSE_CACHE_DEPTH, &acpi_gbl_ps_node_ext_cache); + if (ACPI_FAILURE (status)) { + return (status); + } - object = ACPI_MEM_CALLOCATE (cache_info->object_size); - ACPI_MEM_TRACKING (cache_info->total_allocated++); -#endif + status = acpi_os_create_cache ("acpi_operand", sizeof (union acpi_operand_object), + ACPI_MAX_OBJECT_CACHE_DEPTH, &acpi_gbl_operand_cache); + if (ACPI_FAILURE (status)) { + return (status); + } - return (object); + return (AE_OK); } -#ifdef ACPI_ENABLE_OBJECT_CACHE /******************************************************************************* * - * FUNCTION: acpi_ut_delete_generic_cache + * FUNCTION: acpi_ut_delete_caches * - * PARAMETERS: list_id - Memory list ID + * PARAMETERS: None * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Free all objects within the requested cache. + * DESCRIPTION: Purge and delete all local caches * ******************************************************************************/ -void -acpi_ut_delete_generic_cache ( - u32 list_id) +acpi_status +acpi_ut_delete_caches ( + void) { - struct acpi_memory_list *cache_info; - char *next; + (void) acpi_os_delete_cache (acpi_gbl_state_cache); + acpi_gbl_state_cache = NULL; - ACPI_FUNCTION_ENTRY (); - + (void) acpi_os_delete_cache (acpi_gbl_operand_cache); + acpi_gbl_operand_cache = NULL; - cache_info = &acpi_gbl_memory_lists[list_id]; - while (cache_info->list_head) { - /* Delete one cached state object */ + (void) acpi_os_delete_cache (acpi_gbl_ps_node_cache); + acpi_gbl_ps_node_cache = NULL; - next = *(ACPI_CAST_INDIRECT_PTR (char, - &(((char *) cache_info->list_head)[cache_info->link_offset]))); - ACPI_MEM_FREE (cache_info->list_head); + (void) acpi_os_delete_cache (acpi_gbl_ps_node_ext_cache); + acpi_gbl_ps_node_ext_cache = NULL; - cache_info->list_head = next; - cache_info->cache_depth--; - } + return (AE_OK); } -#endif - /******************************************************************************* * @@ -500,6 +410,43 @@ acpi_ut_callocate ( * occurs in the body of acpi_ut_free. */ +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_list + * + * PARAMETERS: cache_name - Ascii name for the cache + * object_size - Size of each cached object + * return_cache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a local memory list for tracking purposed + * + ******************************************************************************/ + +static acpi_status +acpi_ut_create_list ( + char *list_name, + u16 object_size, + acpi_handle *return_cache) +{ + struct acpi_memory_list *cache; + + + cache = acpi_os_allocate (sizeof (struct acpi_memory_list)); + if (!cache) { + return (AE_NO_MEMORY); + } + + ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); + + cache->list_name = list_name; + cache->object_size = object_size; + + *return_cache = cache; + return (AE_OK); +} + /******************************************************************************* * @@ -533,15 +480,15 @@ acpi_ut_allocate_and_track ( return (NULL); } - status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, + status = acpi_ut_track_allocation (allocation, size, ACPI_MEM_MALLOC, component, module, line); if (ACPI_FAILURE (status)) { acpi_os_free (allocation); return (NULL); } - acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++; - acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size; + acpi_gbl_global_list->total_allocated++; + acpi_gbl_global_list->current_total_size += (u32) size; return ((void *) &allocation->user_space); } @@ -583,15 +530,15 @@ acpi_ut_callocate_and_track ( return (NULL); } - status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, + status = acpi_ut_track_allocation (allocation, size, ACPI_MEM_CALLOC, component, module, line); if (ACPI_FAILURE (status)) { acpi_os_free (allocation); return (NULL); } - acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++; - acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size; + acpi_gbl_global_list->total_allocated++; + acpi_gbl_global_list->current_total_size += (u32) size; return ((void *) &allocation->user_space); } @@ -636,10 +583,10 @@ acpi_ut_free_and_track ( debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block, (((char *) allocation) - sizeof (struct acpi_debug_mem_header))); - acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_freed++; - acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size -= debug_block->size; + acpi_gbl_global_list->total_freed++; + acpi_gbl_global_list->current_total_size -= debug_block->size; - status = acpi_ut_remove_allocation (ACPI_MEM_LIST_GLOBAL, debug_block, + status = acpi_ut_remove_allocation (debug_block, component, module, line); if (ACPI_FAILURE (status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n", @@ -658,8 +605,7 @@ acpi_ut_free_and_track ( * * FUNCTION: acpi_ut_find_allocation * - * PARAMETERS: list_id - Memory list to search - * Allocation - Address of allocated memory + * PARAMETERS: Allocation - Address of allocated memory * * RETURN: A list element if found; NULL otherwise. * @@ -669,7 +615,6 @@ acpi_ut_free_and_track ( static struct acpi_debug_mem_block * acpi_ut_find_allocation ( - u32 list_id, void *allocation) { struct acpi_debug_mem_block *element; @@ -678,11 +623,7 @@ acpi_ut_find_allocation ( ACPI_FUNCTION_ENTRY (); - if (list_id > ACPI_MEM_LIST_MAX) { - return (NULL); - } - - element = acpi_gbl_memory_lists[list_id].list_head; + element = acpi_gbl_global_list->list_head; /* Search for the address. */ @@ -702,8 +643,7 @@ acpi_ut_find_allocation ( * * FUNCTION: acpi_ut_track_allocation * - * PARAMETERS: list_id - Memory list to search - * Allocation - Address of allocated memory + * PARAMETERS: Allocation - Address of allocated memory * Size - Size of the allocation * alloc_type - MEM_MALLOC or MEM_CALLOC * Component - Component type of caller @@ -718,7 +658,6 @@ acpi_ut_find_allocation ( static acpi_status acpi_ut_track_allocation ( - u32 list_id, struct acpi_debug_mem_block *allocation, acpi_size size, u8 alloc_type, @@ -734,11 +673,7 @@ acpi_ut_track_allocation ( ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation); - if (list_id > ACPI_MEM_LIST_MAX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - mem_list = &acpi_gbl_memory_lists[list_id]; + mem_list = acpi_gbl_global_list; status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); @@ -748,8 +683,7 @@ acpi_ut_track_allocation ( * Search list for this address to make sure it is not already on the list. * This will catch several kinds of problems. */ - - element = acpi_ut_find_allocation (list_id, allocation); + element = acpi_ut_find_allocation (allocation); if (element) { ACPI_REPORT_ERROR (( "ut_track_allocation: Allocation already present in list! (%p)\n", @@ -793,8 +727,7 @@ unlock_and_exit: * * FUNCTION: acpi_ut_remove_allocation * - * PARAMETERS: list_id - Memory list to search - * Allocation - Address of allocated memory + * PARAMETERS: Allocation - Address of allocated memory * Component - Component type of caller * Module - Source file name of caller * Line - Line number of caller @@ -807,7 +740,6 @@ unlock_and_exit: static acpi_status acpi_ut_remove_allocation ( - u32 list_id, struct acpi_debug_mem_block *allocation, u32 component, char *module, @@ -820,11 +752,7 @@ acpi_ut_remove_allocation ( ACPI_FUNCTION_TRACE ("ut_remove_allocation"); - if (list_id > ACPI_MEM_LIST_MAX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - mem_list = &acpi_gbl_memory_lists[list_id]; + mem_list = acpi_gbl_global_list; if (NULL == mem_list->list_head) { /* No allocations! */ @@ -959,7 +887,7 @@ acpi_ut_dump_allocations ( return; } - element = acpi_gbl_memory_lists[0].list_head; + element = acpi_gbl_global_list->list_head; while (element) { if ((element->component & component) && ((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) { diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c new file mode 100644 index 0000000..0758881 --- /dev/null +++ b/drivers/acpi/utilities/utcache.c @@ -0,0 +1,322 @@ +/****************************************************************************** + * + * Module Name: utcache - local cache allocation routines + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2005, R. Byron Moore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +#include + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utcache") + + +#ifdef ACPI_USE_LOCAL_CACHE +/******************************************************************************* + * + * FUNCTION: acpi_os_create_cache + * + * PARAMETERS: cache_name - Ascii name for the cache + * object_size - Size of each cached object + * max_depth - Maximum depth of the cache (in objects) + * return_cache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a cache object + * + ******************************************************************************/ + +acpi_status +acpi_os_create_cache ( + char *cache_name, + u16 object_size, + u16 max_depth, + struct acpi_memory_list **return_cache) +{ + struct acpi_memory_list *cache; + + + if (!cache_name || !return_cache || (object_size < 16)) { + return (AE_BAD_PARAMETER); + } + + /* Create the cache object */ + + cache = acpi_os_allocate (sizeof (struct acpi_memory_list)); + if (!cache) { + return (AE_NO_MEMORY); + } + + /* Populate the cache object and return it */ + + ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); + cache->link_offset = 8; + cache->list_name = cache_name; + cache->object_size = object_size; + cache->max_depth = max_depth; + + *return_cache = cache; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_os_purge_cache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache. + * + ******************************************************************************/ + +acpi_status +acpi_os_purge_cache ( + struct acpi_memory_list *cache) +{ + char *next; + + + ACPI_FUNCTION_ENTRY (); + + + if (!cache) { + return (AE_BAD_PARAMETER); + } + + /* Walk the list of objects in this cache */ + + while (cache->list_head) { + /* Delete and unlink one cached state object */ + + next = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) cache->list_head)[cache->link_offset]))); + ACPI_MEM_FREE (cache->list_head); + + cache->list_head = next; + cache->current_depth--; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_os_delete_cache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache and delete the + * cache object. + * + ******************************************************************************/ + +acpi_status +acpi_os_delete_cache ( + struct acpi_memory_list *cache) +{ + acpi_status status; + + + /* Purge all objects in the cache */ + + status = acpi_os_purge_cache (cache); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Now we can delete the cache object */ + + acpi_os_free (cache); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_os_release_object + * + * PARAMETERS: Cache - Handle to cache object + * Object - The object to be released + * + * RETURN: None + * + * DESCRIPTION: Release an object to the specified cache. If cache is full, + * the object is deleted. + * + ******************************************************************************/ + +acpi_status +acpi_os_release_object ( + struct acpi_memory_list *cache, + void *object) +{ + acpi_status status; + + + ACPI_FUNCTION_ENTRY (); + + + if (!cache || !object) { + return (AE_BAD_PARAMETER); + } + + /* If cache is full, just free this object */ + + if (cache->current_depth >= cache->max_depth) { + ACPI_MEM_FREE (object); + ACPI_MEM_TRACKING (cache->total_freed++); + } + + /* Otherwise put this object back into the cache */ + + else { + status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Mark the object as cached */ + + ACPI_MEMSET (object, 0xCA, cache->object_size); + ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED); + + /* Put the object at the head of the cache list */ + + * (ACPI_CAST_INDIRECT_PTR (char, + &(((char *) object)[cache->link_offset]))) = cache->list_head; + cache->list_head = object; + cache->current_depth++; + + (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_os_acquire_object + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: the acquired object. NULL on error + * + * DESCRIPTION: Get an object from the specified cache. If cache is empty, + * the object is allocated. + * + ******************************************************************************/ + +void * +acpi_os_acquire_object ( + struct acpi_memory_list *cache) +{ + acpi_status status; + void *object; + + + ACPI_FUNCTION_NAME ("ut_acquire_from_cache"); + + + if (!cache) { + return (NULL); + } + + status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (status)) { + return (NULL); + } + + ACPI_MEM_TRACKING (cache->requests++); + + /* Check the cache first */ + + if (cache->list_head) { + /* There is an object available, use it */ + + object = cache->list_head; + cache->list_head = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) object)[cache->link_offset]))); + + cache->current_depth--; + + ACPI_MEM_TRACKING (cache->hits++); + ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Object %p from %s\n", object, cache->list_name))); + + status = acpi_ut_release_mutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (status)) { + return (NULL); + } + + /* Clear (zero) the previously used Object */ + + ACPI_MEMSET (object, 0, cache->object_size); + } + else { + /* The cache is empty, create a new object */ + + ACPI_MEM_TRACKING (cache->total_allocated++); + + /* Avoid deadlock with ACPI_MEM_CALLOCATE */ + + status = acpi_ut_release_mutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (status)) { + return (NULL); + } + + object = ACPI_MEM_CALLOCATE (cache->object_size); + if (!object) { + return (NULL); + } + } + + return (object); +} +#endif /* ACPI_USE_LOCAL_CACHE */ + + diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c index 794c7df..08362f6 100644 --- a/drivers/acpi/utilities/utdebug.c +++ b/drivers/acpi/utilities/utdebug.c @@ -549,7 +549,7 @@ acpi_ut_dump_buffer ( /* Dump fill spaces */ acpi_os_printf ("%*s", ((display * 2) + 1), " "); - j += display; + j += (acpi_native_uint) display; continue; } @@ -584,7 +584,7 @@ acpi_ut_dump_buffer ( break; } - j += display; + j += (acpi_native_uint) display; } /* diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 4146019..8653dda 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -820,42 +820,20 @@ void acpi_ut_init_globals ( void) { + acpi_status status; u32 i; ACPI_FUNCTION_TRACE ("ut_init_globals"); - /* Memory allocation and cache lists */ - - ACPI_MEMSET (acpi_gbl_memory_lists, 0, sizeof (struct acpi_memory_list) * ACPI_NUM_MEM_LISTS); - - acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_generic_state *) NULL)->common.next), NULL); - acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL); - acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL); - acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_operand_object *) NULL)->cache.next), NULL); - acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset = (u16) ACPI_PTR_DIFF (&(((struct acpi_walk_state *) NULL)->next), NULL); - - acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].object_size = sizeof (struct acpi_namespace_node); - acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].object_size = sizeof (union acpi_generic_state); - acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].object_size = sizeof (struct acpi_parse_obj_common); - acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].object_size = sizeof (struct acpi_parse_obj_named); - acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].object_size = sizeof (union acpi_operand_object); - acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].object_size = sizeof (struct acpi_walk_state); - - acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].max_cache_depth = ACPI_MAX_STATE_CACHE_DEPTH; - acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].max_cache_depth = ACPI_MAX_PARSE_CACHE_DEPTH; - acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].max_cache_depth = ACPI_MAX_EXTPARSE_CACHE_DEPTH; - acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].max_cache_depth = ACPI_MAX_OBJECT_CACHE_DEPTH; - acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].max_cache_depth = ACPI_MAX_WALK_CACHE_DEPTH; - - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].list_name = "Global Memory Allocation"); - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].list_name = "Namespace Nodes"); - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].list_name = "State Object Cache"); - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].list_name = "Parse Node Cache"); - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].list_name = "Extended Parse Node Cache"); - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].list_name = "Operand Object Cache"); - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].list_name = "Tree Walk Node Cache"); + /* Create all memory caches */ + + status = acpi_ut_create_caches (); + if (ACPI_FAILURE (status)) + { + return; + } /* ACPI table structure */ diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c index 7f37138..fd7ceba 100644 --- a/drivers/acpi/utilities/utinit.c +++ b/drivers/acpi/utilities/utinit.c @@ -264,7 +264,7 @@ acpi_ut_subsystem_shutdown ( /* Purge the local caches */ - (void) acpi_purge_cached_objects (); + (void) acpi_ut_delete_caches (); /* Debug only - display leftover memory allocation, if any */ diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index bb65877..207c836 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -49,16 +49,6 @@ #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utmisc") -/* Local prototypes */ - -static acpi_status -acpi_ut_create_mutex ( - acpi_mutex_handle mutex_id); - -static acpi_status -acpi_ut_delete_mutex ( - acpi_mutex_handle mutex_id); - /******************************************************************************* * @@ -84,6 +74,10 @@ acpi_ut_strupr ( ACPI_FUNCTION_ENTRY (); + if (!src_string) { + return (NULL); + } + /* Walk entire string, uppercasing the letters */ for (string = src_string; *string; string++) { @@ -543,326 +537,6 @@ error_exit: /******************************************************************************* * - * FUNCTION: acpi_ut_mutex_initialize - * - * PARAMETERS: None. - * - * RETURN: Status - * - * DESCRIPTION: Create the system mutex objects. - * - ******************************************************************************/ - -acpi_status -acpi_ut_mutex_initialize ( - void) -{ - u32 i; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ut_mutex_initialize"); - - - /* - * Create each of the predefined mutex objects - */ - for (i = 0; i < NUM_MUTEX; i++) { - status = acpi_ut_create_mutex (i); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); - } - } - - status = acpi_os_create_lock (&acpi_gbl_gpe_lock); - return_ACPI_STATUS (status); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_mutex_terminate - * - * PARAMETERS: None. - * - * RETURN: None. - * - * DESCRIPTION: Delete all of the system mutex objects. - * - ******************************************************************************/ - -void -acpi_ut_mutex_terminate ( - void) -{ - u32 i; - - - ACPI_FUNCTION_TRACE ("ut_mutex_terminate"); - - - /* - * Delete each predefined mutex object - */ - for (i = 0; i < NUM_MUTEX; i++) { - (void) acpi_ut_delete_mutex (i); - } - - acpi_os_delete_lock (acpi_gbl_gpe_lock); - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_create_mutex - * - * PARAMETERS: mutex_iD - ID of the mutex to be created - * - * RETURN: Status - * - * DESCRIPTION: Create a mutex object. - * - ******************************************************************************/ - -static acpi_status -acpi_ut_create_mutex ( - acpi_mutex_handle mutex_id) -{ - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id); - - - if (mutex_id > MAX_MUTEX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (!acpi_gbl_mutex_info[mutex_id].mutex) { - status = acpi_os_create_semaphore (1, 1, - &acpi_gbl_mutex_info[mutex_id].mutex); - acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; - acpi_gbl_mutex_info[mutex_id].use_count = 0; - } - - return_ACPI_STATUS (status); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_delete_mutex - * - * PARAMETERS: mutex_iD - ID of the mutex to be deleted - * - * RETURN: Status - * - * DESCRIPTION: Delete a mutex object. - * - ******************************************************************************/ - -static acpi_status -acpi_ut_delete_mutex ( - acpi_mutex_handle mutex_id) -{ - acpi_status status; - - - ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id); - - - if (mutex_id > MAX_MUTEX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex); - - acpi_gbl_mutex_info[mutex_id].mutex = NULL; - acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; - - return_ACPI_STATUS (status); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_acquire_mutex - * - * PARAMETERS: mutex_iD - ID of the mutex to be acquired - * - * RETURN: Status - * - * DESCRIPTION: Acquire a mutex object. - * - ******************************************************************************/ - -acpi_status -acpi_ut_acquire_mutex ( - acpi_mutex_handle mutex_id) -{ - acpi_status status; - u32 this_thread_id; - - - ACPI_FUNCTION_NAME ("ut_acquire_mutex"); - - - if (mutex_id > MAX_MUTEX) { - return (AE_BAD_PARAMETER); - } - - this_thread_id = acpi_os_get_thread_id (); - -#ifdef ACPI_MUTEX_DEBUG - { - u32 i; - /* - * Mutex debug code, for internal debugging only. - * - * Deadlock prevention. Check if this thread owns any mutexes of value - * greater than or equal to this one. If so, the thread has violated - * the mutex ordering rule. This indicates a coding error somewhere in - * the ACPI subsystem code. - */ - for (i = mutex_id; i < MAX_MUTEX; i++) { - if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { - if (i == mutex_id) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Mutex [%s] already acquired by this thread [%X]\n", - acpi_ut_get_mutex_name (mutex_id), this_thread_id)); - - return (AE_ALREADY_ACQUIRED); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", - this_thread_id, acpi_ut_get_mutex_name (i), - acpi_ut_get_mutex_name (mutex_id))); - - return (AE_ACQUIRE_DEADLOCK); - } - } - } -#endif - - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X attempting to acquire Mutex [%s]\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id))); - - status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, - 1, ACPI_WAIT_FOREVER); - if (ACPI_SUCCESS (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id))); - - acpi_gbl_mutex_info[mutex_id].use_count++; - acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id; - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Thread %X could not acquire Mutex [%s] %s\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id), - acpi_format_exception (status))); - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_release_mutex - * - * PARAMETERS: mutex_iD - ID of the mutex to be released - * - * RETURN: Status - * - * DESCRIPTION: Release a mutex object. - * - ******************************************************************************/ - -acpi_status -acpi_ut_release_mutex ( - acpi_mutex_handle mutex_id) -{ - acpi_status status; - u32 this_thread_id; - - - ACPI_FUNCTION_NAME ("ut_release_mutex"); - - - this_thread_id = acpi_os_get_thread_id (); - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X releasing Mutex [%s]\n", this_thread_id, - acpi_ut_get_mutex_name (mutex_id))); - - if (mutex_id > MAX_MUTEX) { - return (AE_BAD_PARAMETER); - } - - /* - * Mutex must be acquired in order to release it! - */ - if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Mutex [%s] is not acquired, cannot release\n", - acpi_ut_get_mutex_name (mutex_id))); - - return (AE_NOT_ACQUIRED); - } - -#ifdef ACPI_MUTEX_DEBUG - { - u32 i; - /* - * Mutex debug code, for internal debugging only. - * - * Deadlock prevention. Check if this thread owns any mutexes of value - * greater than this one. If so, the thread has violated the mutex - * ordering rule. This indicates a coding error somewhere in - * the ACPI subsystem code. - */ - for (i = mutex_id; i < MAX_MUTEX; i++) { - if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { - if (i == mutex_id) { - continue; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid release order: owns [%s], releasing [%s]\n", - acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); - - return (AE_RELEASE_DEADLOCK); - } - } - } -#endif - - /* Mark unlocked FIRST */ - - acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; - - status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); - - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Thread %X could not release Mutex [%s] %s\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id), - acpi_format_exception (status))); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id))); - } - - return (status); -} - - -/******************************************************************************* - * * FUNCTION: acpi_ut_create_update_state_and_push * * PARAMETERS: Object - Object to be added to the new state @@ -905,361 +579,6 @@ acpi_ut_create_update_state_and_push ( /******************************************************************************* * - * FUNCTION: acpi_ut_create_pkg_state_and_push - * - * PARAMETERS: Object - Object to be added to the new state - * Action - Increment/Decrement - * state_list - List the state will be added to - * - * RETURN: Status - * - * DESCRIPTION: Create a new state and push it - * - ******************************************************************************/ - -#ifdef ACPI_FUTURE_USAGE -acpi_status -acpi_ut_create_pkg_state_and_push ( - void *internal_object, - void *external_object, - u16 index, - union acpi_generic_state **state_list) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_ENTRY (); - - - state = acpi_ut_create_pkg_state (internal_object, external_object, index); - if (!state) { - return (AE_NO_MEMORY); - } - - acpi_ut_push_generic_state (state_list, state); - return (AE_OK); -} -#endif /* ACPI_FUTURE_USAGE */ - -/******************************************************************************* - * - * FUNCTION: acpi_ut_push_generic_state - * - * PARAMETERS: list_head - Head of the state stack - * State - State object to push - * - * RETURN: None - * - * DESCRIPTION: Push a state object onto a state stack - * - ******************************************************************************/ - -void -acpi_ut_push_generic_state ( - union acpi_generic_state **list_head, - union acpi_generic_state *state) -{ - ACPI_FUNCTION_TRACE ("ut_push_generic_state"); - - - /* Push the state object onto the front of the list (stack) */ - - state->common.next = *list_head; - *list_head = state; - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_pop_generic_state - * - * PARAMETERS: list_head - Head of the state stack - * - * RETURN: The popped state object - * - * DESCRIPTION: Pop a state object from a state stack - * - ******************************************************************************/ - -union acpi_generic_state * -acpi_ut_pop_generic_state ( - union acpi_generic_state **list_head) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE ("ut_pop_generic_state"); - - - /* Remove the state object at the head of the list (stack) */ - - state = *list_head; - if (state) { - /* Update the list head */ - - *list_head = state->common.next; - } - - return_PTR (state); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_create_generic_state - * - * PARAMETERS: None - * - * RETURN: The new state object. NULL on failure. - * - * DESCRIPTION: Create a generic state object. Attempt to obtain one from - * the global state cache; If none available, create a new one. - * - ******************************************************************************/ - -union acpi_generic_state * -acpi_ut_create_generic_state ( - void) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_ENTRY (); - - - state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_STATE); - - /* Initialize */ - - if (state) { - state->common.data_type = ACPI_DESC_TYPE_STATE; - } - - return (state); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_create_thread_state - * - * PARAMETERS: None - * - * RETURN: New Thread State. NULL on failure - * - * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used - * to track per-thread info during method execution - * - ******************************************************************************/ - -struct acpi_thread_state * -acpi_ut_create_thread_state ( - void) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE ("ut_create_thread_state"); - - - /* Create the generic state object */ - - state = acpi_ut_create_generic_state (); - if (!state) { - return_PTR (NULL); - } - - /* Init fields specific to the update struct */ - - state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD; - state->thread.thread_id = acpi_os_get_thread_id (); - - return_PTR ((struct acpi_thread_state *) state); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_create_update_state - * - * PARAMETERS: Object - Initial Object to be installed in the state - * Action - Update action to be performed - * - * RETURN: New state object, null on failure - * - * DESCRIPTION: Create an "Update State" - a flavor of the generic state used - * to update reference counts and delete complex objects such - * as packages. - * - ******************************************************************************/ - -union acpi_generic_state * -acpi_ut_create_update_state ( - union acpi_operand_object *object, - u16 action) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object); - - - /* Create the generic state object */ - - state = acpi_ut_create_generic_state (); - if (!state) { - return_PTR (NULL); - } - - /* Init fields specific to the update struct */ - - state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE; - state->update.object = object; - state->update.value = action; - - return_PTR (state); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_create_pkg_state - * - * PARAMETERS: Object - Initial Object to be installed in the state - * Action - Update action to be performed - * - * RETURN: New state object, null on failure - * - * DESCRIPTION: Create a "Package State" - * - ******************************************************************************/ - -union acpi_generic_state * -acpi_ut_create_pkg_state ( - void *internal_object, - void *external_object, - u16 index) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object); - - - /* Create the generic state object */ - - state = acpi_ut_create_generic_state (); - if (!state) { - return_PTR (NULL); - } - - /* Init fields specific to the update struct */ - - state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE; - state->pkg.source_object = (union acpi_operand_object *) internal_object; - state->pkg.dest_object = external_object; - state->pkg.index = index; - state->pkg.num_packages = 1; - - return_PTR (state); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_create_control_state - * - * PARAMETERS: None - * - * RETURN: New state object, null on failure - * - * DESCRIPTION: Create a "Control State" - a flavor of the generic state used - * to support nested IF/WHILE constructs in the AML. - * - ******************************************************************************/ - -union acpi_generic_state * -acpi_ut_create_control_state ( - void) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE ("ut_create_control_state"); - - - /* Create the generic state object */ - - state = acpi_ut_create_generic_state (); - if (!state) { - return_PTR (NULL); - } - - /* Init fields specific to the control struct */ - - state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL; - state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; - - return_PTR (state); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_delete_generic_state - * - * PARAMETERS: State - The state object to be deleted - * - * RETURN: None - * - * DESCRIPTION: Put a state object back into the global state cache. The object - * is not actually freed at this time. - * - ******************************************************************************/ - -void -acpi_ut_delete_generic_state ( - union acpi_generic_state *state) -{ - ACPI_FUNCTION_TRACE ("ut_delete_generic_state"); - - - acpi_ut_release_to_cache (ACPI_MEM_LIST_STATE, state); - return_VOID; -} - - -#ifdef ACPI_ENABLE_OBJECT_CACHE -/******************************************************************************* - * - * FUNCTION: acpi_ut_delete_generic_state_cache - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Purge the global state object cache. Used during subsystem - * termination. - * - ******************************************************************************/ - -void -acpi_ut_delete_generic_state_cache ( - void) -{ - ACPI_FUNCTION_TRACE ("ut_delete_generic_state_cache"); - - - acpi_ut_delete_generic_cache (ACPI_MEM_LIST_STATE); - return_VOID; -} -#endif - - -/******************************************************************************* - * * FUNCTION: acpi_ut_walk_package_tree * * PARAMETERS: source_object - The package to walk diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c new file mode 100644 index 0000000..a80b97c --- /dev/null +++ b/drivers/acpi/utilities/utmutex.c @@ -0,0 +1,380 @@ +/******************************************************************************* + * + * Module Name: utmutex - local mutex support + * + ******************************************************************************/ + +/* + * Copyright (C) 2000 - 2005, R. Byron Moore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +#include + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utmutex") + +/* Local prototypes */ + +static acpi_status +acpi_ut_create_mutex ( + acpi_mutex_handle mutex_id); + +static acpi_status +acpi_ut_delete_mutex ( + acpi_mutex_handle mutex_id); + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_mutex_initialize + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Create the system mutex objects. + * + ******************************************************************************/ + +acpi_status +acpi_ut_mutex_initialize ( + void) +{ + u32 i; + acpi_status status; + + + ACPI_FUNCTION_TRACE ("ut_mutex_initialize"); + + + /* + * Create each of the predefined mutex objects + */ + for (i = 0; i < NUM_MUTEX; i++) { + status = acpi_ut_create_mutex (i); + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); + } + } + + status = acpi_os_create_lock (&acpi_gbl_gpe_lock); + return_ACPI_STATUS (status); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_mutex_terminate + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete all of the system mutex objects. + * + ******************************************************************************/ + +void +acpi_ut_mutex_terminate ( + void) +{ + u32 i; + + + ACPI_FUNCTION_TRACE ("ut_mutex_terminate"); + + + /* + * Delete each predefined mutex object + */ + for (i = 0; i < NUM_MUTEX; i++) { + (void) acpi_ut_delete_mutex (i); + } + + acpi_os_delete_lock (acpi_gbl_gpe_lock); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_mutex + * + * PARAMETERS: mutex_iD - ID of the mutex to be created + * + * RETURN: Status + * + * DESCRIPTION: Create a mutex object. + * + ******************************************************************************/ + +static acpi_status +acpi_ut_create_mutex ( + acpi_mutex_handle mutex_id) +{ + acpi_status status = AE_OK; + + + ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id); + + + if (mutex_id > MAX_MUTEX) { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!acpi_gbl_mutex_info[mutex_id].mutex) { + status = acpi_os_create_semaphore (1, 1, + &acpi_gbl_mutex_info[mutex_id].mutex); + acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; + acpi_gbl_mutex_info[mutex_id].use_count = 0; + } + + return_ACPI_STATUS (status); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_delete_mutex + * + * PARAMETERS: mutex_iD - ID of the mutex to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Delete a mutex object. + * + ******************************************************************************/ + +static acpi_status +acpi_ut_delete_mutex ( + acpi_mutex_handle mutex_id) +{ + acpi_status status; + + + ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id); + + + if (mutex_id > MAX_MUTEX) { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex); + + acpi_gbl_mutex_info[mutex_id].mutex = NULL; + acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; + + return_ACPI_STATUS (status); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_acquire_mutex + * + * PARAMETERS: mutex_iD - ID of the mutex to be acquired + * + * RETURN: Status + * + * DESCRIPTION: Acquire a mutex object. + * + ******************************************************************************/ + +acpi_status +acpi_ut_acquire_mutex ( + acpi_mutex_handle mutex_id) +{ + acpi_status status; + u32 this_thread_id; + + + ACPI_FUNCTION_NAME ("ut_acquire_mutex"); + + + if (mutex_id > MAX_MUTEX) { + return (AE_BAD_PARAMETER); + } + + this_thread_id = acpi_os_get_thread_id (); + +#ifdef ACPI_MUTEX_DEBUG + { + u32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than or equal to this one. If so, the thread has violated + * the mutex ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = mutex_id; i < MAX_MUTEX; i++) { + if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { + if (i == mutex_id) { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Mutex [%s] already acquired by this thread [%X]\n", + acpi_ut_get_mutex_name (mutex_id), this_thread_id)); + + return (AE_ALREADY_ACQUIRED); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", + this_thread_id, acpi_ut_get_mutex_name (i), + acpi_ut_get_mutex_name (mutex_id))); + + return (AE_ACQUIRE_DEADLOCK); + } + } + } +#endif + + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, + "Thread %X attempting to acquire Mutex [%s]\n", + this_thread_id, acpi_ut_get_mutex_name (mutex_id))); + + status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, + 1, ACPI_WAIT_FOREVER); + if (ACPI_SUCCESS (status)) { + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", + this_thread_id, acpi_ut_get_mutex_name (mutex_id))); + + acpi_gbl_mutex_info[mutex_id].use_count++; + acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id; + } + else { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Thread %X could not acquire Mutex [%s] %s\n", + this_thread_id, acpi_ut_get_mutex_name (mutex_id), + acpi_format_exception (status))); + } + + return (status); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_release_mutex + * + * PARAMETERS: mutex_iD - ID of the mutex to be released + * + * RETURN: Status + * + * DESCRIPTION: Release a mutex object. + * + ******************************************************************************/ + +acpi_status +acpi_ut_release_mutex ( + acpi_mutex_handle mutex_id) +{ + acpi_status status; + u32 this_thread_id; + + + ACPI_FUNCTION_NAME ("ut_release_mutex"); + + + this_thread_id = acpi_os_get_thread_id (); + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, + "Thread %X releasing Mutex [%s]\n", this_thread_id, + acpi_ut_get_mutex_name (mutex_id))); + + if (mutex_id > MAX_MUTEX) { + return (AE_BAD_PARAMETER); + } + + /* + * Mutex must be acquired in order to release it! + */ + if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Mutex [%s] is not acquired, cannot release\n", + acpi_ut_get_mutex_name (mutex_id))); + + return (AE_NOT_ACQUIRED); + } + +#ifdef ACPI_MUTEX_DEBUG + { + u32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than this one. If so, the thread has violated the mutex + * ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = mutex_id; i < MAX_MUTEX; i++) { + if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { + if (i == mutex_id) { + continue; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid release order: owns [%s], releasing [%s]\n", + acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); + + return (AE_RELEASE_DEADLOCK); + } + } + } +#endif + + /* Mark unlocked FIRST */ + + acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; + + status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); + + if (ACPI_FAILURE (status)) { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Thread %X could not release Mutex [%s] %s\n", + this_thread_id, acpi_ut_get_mutex_name (mutex_id), + acpi_format_exception (status))); + } + else { + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", + this_thread_id, acpi_ut_get_mutex_name (mutex_id))); + } + + return (status); +} + + diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c index cd3899b9..19178e1 100644 --- a/drivers/acpi/utilities/utobject.c +++ b/drivers/acpi/utilities/utobject.c @@ -338,7 +338,7 @@ acpi_ut_allocate_object_desc_dbg ( ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg"); - object = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_OPERAND); + object = acpi_os_acquire_object (acpi_gbl_operand_cache); if (!object) { _ACPI_REPORT_ERROR (module_name, line_number, component_id, ("Could not allocate an object descriptor\n")); @@ -347,7 +347,7 @@ acpi_ut_allocate_object_desc_dbg ( } /* Mark the descriptor type */ - + memset(object, 0, sizeof(union acpi_operand_object)); ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND); ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", @@ -385,37 +385,9 @@ acpi_ut_delete_object_desc ( return_VOID; } - acpi_ut_release_to_cache (ACPI_MEM_LIST_OPERAND, object); - - return_VOID; -} - - -#ifdef ACPI_ENABLE_OBJECT_CACHE -/******************************************************************************* - * - * FUNCTION: acpi_ut_delete_object_cache - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Purge the global state object cache. Used during subsystem - * termination. - * - ******************************************************************************/ - -void -acpi_ut_delete_object_cache ( - void) -{ - ACPI_FUNCTION_TRACE ("ut_delete_object_cache"); - - - acpi_ut_delete_generic_cache (ACPI_MEM_LIST_OPERAND); + (void) acpi_os_release_object (acpi_gbl_operand_cache, object); return_VOID; } -#endif /******************************************************************************* diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c new file mode 100644 index 0000000..192e7ac --- /dev/null +++ b/drivers/acpi/utilities/utstate.c @@ -0,0 +1,376 @@ +/******************************************************************************* + * + * Module Name: utstate - state object support procedures + * + ******************************************************************************/ + +/* + * Copyright (C) 2000 - 2005, R. Byron Moore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +#include + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utstate") + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_pkg_state_and_push + * + * PARAMETERS: Object - Object to be added to the new state + * Action - Increment/Decrement + * state_list - List the state will be added to + * + * RETURN: Status + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +acpi_status +acpi_ut_create_pkg_state_and_push ( + void *internal_object, + void *external_object, + u16 index, + union acpi_generic_state **state_list) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_ENTRY (); + + + state = acpi_ut_create_pkg_state (internal_object, external_object, index); + if (!state) { + return (AE_NO_MEMORY); + } + + acpi_ut_push_generic_state (state_list, state); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_push_generic_state + * + * PARAMETERS: list_head - Head of the state stack + * State - State object to push + * + * RETURN: None + * + * DESCRIPTION: Push a state object onto a state stack + * + ******************************************************************************/ + +void +acpi_ut_push_generic_state ( + union acpi_generic_state **list_head, + union acpi_generic_state *state) +{ + ACPI_FUNCTION_TRACE ("ut_push_generic_state"); + + + /* Push the state object onto the front of the list (stack) */ + + state->common.next = *list_head; + *list_head = state; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_pop_generic_state + * + * PARAMETERS: list_head - Head of the state stack + * + * RETURN: The popped state object + * + * DESCRIPTION: Pop a state object from a state stack + * + ******************************************************************************/ + +union acpi_generic_state * +acpi_ut_pop_generic_state ( + union acpi_generic_state **list_head) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_TRACE ("ut_pop_generic_state"); + + + /* Remove the state object at the head of the list (stack) */ + + state = *list_head; + if (state) { + /* Update the list head */ + + *list_head = state->common.next; + } + + return_PTR (state); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_generic_state + * + * PARAMETERS: None + * + * RETURN: The new state object. NULL on failure. + * + * DESCRIPTION: Create a generic state object. Attempt to obtain one from + * the global state cache; If none available, create a new one. + * + ******************************************************************************/ + +union acpi_generic_state * +acpi_ut_create_generic_state ( + void) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_ENTRY (); + + + state = acpi_os_acquire_object (acpi_gbl_state_cache); + if (state) { + /* Initialize */ + memset(state, 0, sizeof(union acpi_generic_state)); + state->common.data_type = ACPI_DESC_TYPE_STATE; + } + + return (state); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_thread_state + * + * PARAMETERS: None + * + * RETURN: New Thread State. NULL on failure + * + * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used + * to track per-thread info during method execution + * + ******************************************************************************/ + +struct acpi_thread_state * +acpi_ut_create_thread_state ( + void) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_TRACE ("ut_create_thread_state"); + + + /* Create the generic state object */ + + state = acpi_ut_create_generic_state (); + if (!state) { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD; + state->thread.thread_id = acpi_os_get_thread_id (); + + return_PTR ((struct acpi_thread_state *) state); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_update_state + * + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create an "Update State" - a flavor of the generic state used + * to update reference counts and delete complex objects such + * as packages. + * + ******************************************************************************/ + +union acpi_generic_state * +acpi_ut_create_update_state ( + union acpi_operand_object *object, + u16 action) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object); + + + /* Create the generic state object */ + + state = acpi_ut_create_generic_state (); + if (!state) { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE; + state->update.object = object; + state->update.value = action; + + return_PTR (state); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_pkg_state + * + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create a "Package State" + * + ******************************************************************************/ + +union acpi_generic_state * +acpi_ut_create_pkg_state ( + void *internal_object, + void *external_object, + u16 index) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object); + + + /* Create the generic state object */ + + state = acpi_ut_create_generic_state (); + if (!state) { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE; + state->pkg.source_object = (union acpi_operand_object *) internal_object; + state->pkg.dest_object = external_object; + state->pkg.index = index; + state->pkg.num_packages = 1; + + return_PTR (state); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_control_state + * + * PARAMETERS: None + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create a "Control State" - a flavor of the generic state used + * to support nested IF/WHILE constructs in the AML. + * + ******************************************************************************/ + +union acpi_generic_state * +acpi_ut_create_control_state ( + void) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_TRACE ("ut_create_control_state"); + + + /* Create the generic state object */ + + state = acpi_ut_create_generic_state (); + if (!state) { + return_PTR (NULL); + } + + /* Init fields specific to the control struct */ + + state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL; + state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; + + return_PTR (state); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_delete_generic_state + * + * PARAMETERS: State - The state object to be deleted + * + * RETURN: None + * + * DESCRIPTION: Put a state object back into the global state cache. The object + * is not actually freed at this time. + * + ******************************************************************************/ + +void +acpi_ut_delete_generic_state ( + union acpi_generic_state *state) +{ + ACPI_FUNCTION_TRACE ("ut_delete_generic_state"); + + + (void) acpi_os_release_object (acpi_gbl_state_cache, state); + return_VOID; +} + + diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c index e8803d8..850da68 100644 --- a/drivers/acpi/utilities/utxface.c +++ b/drivers/acpi/utilities/utxface.c @@ -46,8 +46,6 @@ #include #include #include -#include -#include #include #define _COMPONENT ACPI_UTILITIES @@ -79,11 +77,6 @@ acpi_initialize_subsystem ( ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ()); - - /* Initialize all globals used by the subsystem */ - - acpi_ut_init_globals (); - /* Initialize the OS-Dependent layer */ status = acpi_os_initialize (); @@ -93,6 +86,10 @@ acpi_initialize_subsystem ( return_ACPI_STATUS (status); } + /* Initialize all globals used by the subsystem */ + + acpi_ut_init_globals (); + /* Create the default mutex objects */ status = acpi_ut_mutex_initialize (); @@ -522,13 +519,9 @@ acpi_purge_cached_objects ( { ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects"); - -#ifdef ACPI_ENABLE_OBJECT_CACHE - acpi_ut_delete_generic_state_cache (); - acpi_ut_delete_object_cache (); - acpi_ds_delete_walk_state_cache (); - acpi_ps_delete_parse_cache (); -#endif - + (void) acpi_os_purge_cache (acpi_gbl_state_cache); + (void) acpi_os_purge_cache (acpi_gbl_operand_cache); + (void) acpi_os_purge_cache (acpi_gbl_ps_node_cache); + (void) acpi_os_purge_cache (acpi_gbl_ps_node_ext_cache); return_ACPI_STATUS (AE_OK); } diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 6babcb1..dd9b70c 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -64,7 +64,7 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20050526 +#define ACPI_CA_VERSION 0x20050624 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, @@ -78,11 +78,10 @@ /* Maximum objects in the various object caches */ -#define ACPI_MAX_STATE_CACHE_DEPTH 64 /* State objects */ +#define ACPI_MAX_STATE_CACHE_DEPTH 96 /* State objects */ #define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ -#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 64 /* Parse tree objects */ -#define ACPI_MAX_OBJECT_CACHE_DEPTH 64 /* Interpreter operand objects */ -#define ACPI_MAX_WALK_CACHE_DEPTH 4 /* Objects for parse tree walks */ +#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */ /* * Should the subystem abort the loading of an ACPI table if the diff --git a/include/acpi/acdebug.h b/include/acpi/acdebug.h index 8ba372b..f8fa222 100644 --- a/include/acpi/acdebug.h +++ b/include/acpi/acdebug.h @@ -114,6 +114,10 @@ acpi_db_set_method_call_breakpoint ( union acpi_parse_object *op); void +acpi_db_get_bus_info ( + void); + +void acpi_db_disassemble_aml ( char *statements, union acpi_parse_object *op); @@ -327,7 +331,7 @@ acpi_db_set_output_destination ( u32 where); void -acpi_db_dump_object ( +acpi_db_dump_external_object ( union acpi_object *obj_desc, u32 level); diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h index dbfa877..fcc2d50 100644 --- a/include/acpi/acdisasm.h +++ b/include/acpi/acdisasm.h @@ -90,6 +90,7 @@ struct acpi_op_walk_info { u32 level; u32 bit_offset; + struct acpi_walk_state *walk_state; }; typedef diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h index 8f5f2f7..fde6aa9 100644 --- a/include/acpi/acdispat.h +++ b/include/acpi/acdispat.h @@ -450,10 +450,4 @@ acpi_ds_result_pop_from_bottom ( union acpi_operand_object **object, struct acpi_walk_state *walk_state); -#ifdef ACPI_ENABLE_OBJECT_CACHE -void -acpi_ds_delete_walk_state_cache ( - void); -#endif - #endif /* _ACDISPAT_H_ */ diff --git a/include/acpi/acevents.h b/include/acpi/acevents.h index 301c5cc..33ae2ca 100644 --- a/include/acpi/acevents.h +++ b/include/acpi/acevents.h @@ -122,8 +122,7 @@ acpi_ev_valid_gpe_event ( acpi_status acpi_ev_walk_gpe_list ( - ACPI_GPE_CALLBACK gpe_walk_callback, - u32 flags); + ACPI_GPE_CALLBACK gpe_walk_callback); acpi_status acpi_ev_delete_gpe_handlers ( diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h index 4946696..8d5a397a 100644 --- a/include/acpi/acglobal.h +++ b/include/acpi/acglobal.h @@ -151,6 +151,13 @@ ACPI_EXTERN struct acpi_common_facs acpi_gbl_common_fACS; */ +/* The root table can be either an RSDT or an XSDT */ + +ACPI_EXTERN u8 acpi_gbl_root_table_type; +#define ACPI_TABLE_TYPE_RSDT 'R' +#define ACPI_TABLE_TYPE_XSDT 'X' + + /* * Handle both ACPI 1.0 and ACPI 2.0 Integer widths: * If we are executing a method that exists in a 32-bit ACPI table, @@ -180,8 +187,23 @@ ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[NUM_MUTEX]; * ****************************************************************************/ +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + +/* Lists for tracking memory allocations */ + +ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list; +ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list; +#endif + +/* Object caches */ + +ACPI_EXTERN acpi_cache_t *acpi_gbl_state_cache; +ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_cache; +ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_ext_cache; +ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache; + +/* Global handlers */ -ACPI_EXTERN struct acpi_memory_list acpi_gbl_memory_lists[ACPI_NUM_MEM_LISTS]; ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_device_notify; ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify; ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler; @@ -189,6 +211,8 @@ ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler; ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk; ACPI_EXTERN acpi_handle acpi_gbl_global_lock_semaphore; +/* Misc */ + ACPI_EXTERN u32 acpi_gbl_global_lock_thread_count; ACPI_EXTERN u32 acpi_gbl_original_mode; ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; diff --git a/include/acpi/achware.h b/include/acpi/achware.h index 9d63641..cf5de46 100644 --- a/include/acpi/achware.h +++ b/include/acpi/achware.h @@ -143,15 +143,15 @@ acpi_hw_get_gpe_status ( acpi_status acpi_hw_disable_all_gpes ( - u32 flags); + void); acpi_status acpi_hw_enable_all_runtime_gpes ( - u32 flags); + void); acpi_status acpi_hw_enable_all_wakeup_gpes ( - u32 flags); + void); acpi_status acpi_hw_enable_runtime_gpe_block ( diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h index 52c6a20..58f9ba1 100644 --- a/include/acpi/aclocal.h +++ b/include/acpi/aclocal.h @@ -953,24 +953,18 @@ struct acpi_debug_mem_block #define ACPI_MEM_LIST_GLOBAL 0 #define ACPI_MEM_LIST_NSNODE 1 - -#define ACPI_MEM_LIST_FIRST_CACHE_LIST 2 -#define ACPI_MEM_LIST_STATE 2 -#define ACPI_MEM_LIST_PSNODE 3 -#define ACPI_MEM_LIST_PSNODE_EXT 4 -#define ACPI_MEM_LIST_OPERAND 5 -#define ACPI_MEM_LIST_WALK 6 -#define ACPI_MEM_LIST_MAX 6 -#define ACPI_NUM_MEM_LISTS 7 +#define ACPI_MEM_LIST_MAX 1 +#define ACPI_NUM_MEM_LISTS 2 struct acpi_memory_list { + char *list_name; void *list_head; - u16 link_offset; - u16 max_cache_depth; - u16 cache_depth; u16 object_size; + u16 max_depth; + u16 current_depth; + u16 link_offset; #ifdef ACPI_DBG_TRACK_ALLOCATIONS @@ -979,11 +973,9 @@ struct acpi_memory_list u32 total_allocated; u32 total_freed; u32 current_total_size; - u32 cache_requests; - u32 cache_hits; - char *list_name; + u32 requests; + u32 hits; #endif }; - #endif /* __ACLOCAL_H__ */ diff --git a/include/acpi/acparser.h b/include/acpi/acparser.h index 6982765..ba9548f 100644 --- a/include/acpi/acparser.h +++ b/include/acpi/acparser.h @@ -63,6 +63,7 @@ #define ACPI_PARSE_MODE_MASK 0x0030 #define ACPI_PARSE_DEFERRED_OP 0x0100 +#define ACPI_PARSE_DISASSEMBLE 0x0200 /****************************************************************************** @@ -158,6 +159,25 @@ u16 acpi_ps_peek_opcode ( struct acpi_parse_state *state); +acpi_status +acpi_ps_complete_this_op ( + struct acpi_walk_state *walk_state, + union acpi_parse_object *op); + +acpi_status +acpi_ps_next_parse_state ( + struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + acpi_status callback_status); + + +/* + * psloop - main parse loop + */ +acpi_status +acpi_ps_parse_loop ( + struct acpi_walk_state *walk_state); + /* * psscope - Scope stack management routines @@ -291,12 +311,6 @@ acpi_ps_set_name( union acpi_parse_object *op, u32 name); -#ifdef ACPI_ENABLE_OBJECT_CACHE -void -acpi_ps_delete_parse_cache ( - void); -#endif - /* * psdump - display parser tree diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h index ea489f2..819a53f 100644 --- a/include/acpi/acpiosxf.h +++ b/include/acpi/acpiosxf.h @@ -139,15 +139,14 @@ void acpi_os_delete_lock ( acpi_handle handle); -void +unsigned long acpi_os_acquire_lock ( - acpi_handle handle, - u32 flags); + acpi_handle handle); void acpi_os_release_lock ( acpi_handle handle, - u32 flags); + unsigned long flags); /* @@ -180,6 +179,34 @@ acpi_os_get_physical_address ( #endif + +/* + * Memory/Object Cache + */ +acpi_status +acpi_os_create_cache ( + char *cache_name, + u16 object_size, + u16 max_depth, + acpi_cache_t **return_cache); + +acpi_status +acpi_os_delete_cache ( + acpi_cache_t *cache); + +acpi_status +acpi_os_purge_cache ( + acpi_cache_t *cache); + +void * +acpi_os_acquire_object ( + acpi_cache_t *cache); + +acpi_status +acpi_os_release_object ( + acpi_cache_t *cache, + void *object); + /* * Interrupt handlers */ diff --git a/include/acpi/acstruct.h b/include/acpi/acstruct.h index 4e92645..a2025a8 100644 --- a/include/acpi/acstruct.h +++ b/include/acpi/acstruct.h @@ -162,6 +162,9 @@ struct acpi_walk_info #define ACPI_DISPLAY_SUMMARY 0 #define ACPI_DISPLAY_OBJECTS 1 +#define ACPI_DISPLAY_MASK 1 + +#define ACPI_DISPLAY_SHORT 2 struct acpi_get_devices_info { diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 3a451dc..8cd774a2 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -243,6 +243,11 @@ struct acpi_pointer #define ACPI_LOGMODE_PHYSPTR ACPI_LOGICAL_ADDRESSING | ACPI_PHYSICAL_POINTER #define ACPI_LOGMODE_LOGPTR ACPI_LOGICAL_ADDRESSING | ACPI_LOGICAL_POINTER +/* Types for the OS interface layer (OSL) */ + +#ifdef ACPI_USE_LOCAL_CACHE +#define acpi_cache_t struct acpi_memory_list +#endif /* * Useful defines diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h index 192d0be..e9c1584d 100644 --- a/include/acpi/acutils.h +++ b/include/acpi/acutils.h @@ -557,16 +557,6 @@ void acpi_ut_delete_generic_state ( union acpi_generic_state *state); -#ifdef ACPI_ENABLE_OBJECT_CACHE -void -acpi_ut_delete_generic_state_cache ( - void); - -void -acpi_ut_delete_object_cache ( - void); -#endif - /* * utmath @@ -622,22 +612,6 @@ acpi_ut_strtoul64 ( #define ACPI_ANY_BASE 0 -acpi_status -acpi_ut_mutex_initialize ( - void); - -void -acpi_ut_mutex_terminate ( - void); - -acpi_status -acpi_ut_acquire_mutex ( - acpi_mutex_handle mutex_id); - -acpi_status -acpi_ut_release_mutex ( - acpi_mutex_handle mutex_id); - u8 * acpi_ut_get_resource_end_tag ( union acpi_operand_object *obj_desc); @@ -666,22 +640,35 @@ acpi_ut_display_init_pathname ( /* - * utalloc - memory allocation and object caching + * utmutex - mutex support */ -void * -acpi_ut_acquire_from_cache ( - u32 list_id); +acpi_status +acpi_ut_mutex_initialize ( + void); void -acpi_ut_release_to_cache ( - u32 list_id, - void *object); +acpi_ut_mutex_terminate ( + void); -#ifdef ACPI_ENABLE_OBJECT_CACHE -void -acpi_ut_delete_generic_cache ( - u32 list_id); -#endif +acpi_status +acpi_ut_acquire_mutex ( + acpi_mutex_handle mutex_id); + +acpi_status +acpi_ut_release_mutex ( + acpi_mutex_handle mutex_id); + + +/* + * utalloc - memory allocation and object caching + */ +acpi_status +acpi_ut_create_caches ( + void); + +acpi_status +acpi_ut_delete_caches ( + void); acpi_status acpi_ut_validate_buffer ( diff --git a/include/acpi/amlcode.h b/include/acpi/amlcode.h index 55e97ed..50a0889 100644 --- a/include/acpi/amlcode.h +++ b/include/acpi/amlcode.h @@ -69,7 +69,7 @@ #define AML_MULTI_NAME_PREFIX_OP (u16) 0x2f #define AML_NAME_CHAR_SUBSEQ (u16) 0x30 #define AML_NAME_CHAR_FIRST (u16) 0x41 -#define AML_OP_PREFIX (u16) 0x5b +#define AML_EXTENDED_OP_PREFIX (u16) 0x5b #define AML_ROOT_PREFIX (u16) 0x5c #define AML_PARENT_PREFIX (u16) 0x5e #define AML_LOCAL_OP (u16) 0x60 @@ -146,7 +146,7 @@ /* prefixed opcodes */ -#define AML_EXTOP (u16) 0x005b /* prefix for 2-byte opcodes */ +#define AML_EXTENDED_OPCODE (u16) 0x5b00 /* prefix for 2-byte opcodes */ #define AML_MUTEX_OP (u16) 0x5b01 #define AML_EVENT_OP (u16) 0x5b02 diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index adf969e..aa63202e 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -49,35 +49,38 @@ * Configuration for ACPI tools and utilities */ -#ifdef _ACPI_DUMP_APP +#ifdef ACPI_LIBRARY +#define ACPI_USE_LOCAL_CACHE +#endif + +#ifdef ACPI_DUMP_APP #ifndef MSDOS #define ACPI_DEBUG_OUTPUT #endif #define ACPI_APPLICATION #define ACPI_DISASSEMBLER #define ACPI_NO_METHOD_EXECUTION -#define ACPI_USE_SYSTEM_CLIBRARY -#define ACPI_ENABLE_OBJECT_CACHE #endif -#ifdef _ACPI_EXEC_APP +#ifdef ACPI_EXEC_APP #undef DEBUGGER_THREADING #define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED #define ACPI_DEBUG_OUTPUT #define ACPI_APPLICATION #define ACPI_DEBUGGER #define ACPI_DISASSEMBLER -#define ACPI_USE_SYSTEM_CLIBRARY -#define ACPI_ENABLE_OBJECT_CACHE #endif -#ifdef _ACPI_ASL_COMPILER +#ifdef ACPI_ASL_COMPILER #define ACPI_DEBUG_OUTPUT #define ACPI_APPLICATION #define ACPI_DISASSEMBLER #define ACPI_CONSTANT_EVAL_ONLY +#endif + +#ifdef ACPI_APPLICATION #define ACPI_USE_SYSTEM_CLIBRARY -#define ACPI_ENABLE_OBJECT_CACHE +#define ACPI_USE_LOCAL_CACHE #endif /* diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h index a3de0db..4fbc0fd 100644 --- a/include/acpi/platform/aclinux.h +++ b/include/acpi/platform/aclinux.h @@ -62,6 +62,17 @@ #define ACPI_MACHINE_WIDTH BITS_PER_LONG +/* Type(s) for the OSL */ + +#ifdef ACPI_USE_LOCAL_CACHE +#define acpi_cache_t struct acpi_memory_list +#else +#include +#define acpi_cache_t kmem_cache_t +#endif + + + #else /* !__KERNEL__ */ #include -- cgit v0.10.2 From 4c3ffbd79529b680b3c3ef2b6f42f0c89c694ec5 Mon Sep 17 00:00:00 2001 From: David Shaohua Li Date: Thu, 14 Jul 2005 00:00:00 -0400 Subject: [ACPI] revert R40 workaround Should not be necessary... http://bugme.osdl.org/show_bug.cgi?id=1038 Signed-off-by: Len Brown diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index bc54030..be97ada 100644 --- a/drivers/acpi/utilities/utdelete.c +++ b/drivers/acpi/utilities/utdelete.c @@ -439,7 +439,7 @@ acpi_ut_update_object_reference ( u32 i; union acpi_generic_state *state_list = NULL; union acpi_generic_state *state; - union acpi_operand_object *tmp; + ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object); @@ -472,16 +472,8 @@ acpi_ut_update_object_reference ( switch (ACPI_GET_OBJECT_TYPE (object)) { case ACPI_TYPE_DEVICE: - tmp = object->device.system_notify; - if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->device.system_notify = NULL; - acpi_ut_update_ref_count (tmp, action); - - tmp = object->device.device_notify; - if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->device.device_notify = NULL; - acpi_ut_update_ref_count (tmp, action); - + acpi_ut_update_ref_count (object->device.system_notify, action); + acpi_ut_update_ref_count (object->device.device_notify, action); break; @@ -502,10 +494,6 @@ acpi_ut_update_object_reference ( if (ACPI_FAILURE (status)) { goto error_exit; } - - tmp = object->package.elements[i]; - if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->package.elements[i] = NULL; } break; @@ -517,10 +505,6 @@ acpi_ut_update_object_reference ( if (ACPI_FAILURE (status)) { goto error_exit; } - - tmp = object->buffer_field.buffer_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->buffer_field.buffer_obj = NULL; break; @@ -531,10 +515,6 @@ acpi_ut_update_object_reference ( if (ACPI_FAILURE (status)) { goto error_exit; } - - tmp = object->field.region_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->field.region_obj = NULL; break; @@ -546,19 +526,11 @@ acpi_ut_update_object_reference ( goto error_exit; } - tmp = object->bank_field.bank_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->bank_field.bank_obj = NULL; - status = acpi_ut_create_update_state_and_push ( object->bank_field.region_obj, action, &state_list); if (ACPI_FAILURE (status)) { goto error_exit; } - - tmp = object->bank_field.region_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->bank_field.region_obj = NULL; break; @@ -570,19 +542,11 @@ acpi_ut_update_object_reference ( goto error_exit; } - tmp = object->index_field.index_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->index_field.index_obj = NULL; - status = acpi_ut_create_update_state_and_push ( object->index_field.data_obj, action, &state_list); if (ACPI_FAILURE (status)) { goto error_exit; } - - tmp = object->index_field.data_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->index_field.data_obj = NULL; break; -- cgit v0.10.2 From f9f4601f331aa1226d7a798a01950efbb388f07f Mon Sep 17 00:00:00 2001 From: Robert Moore Date: Fri, 8 Jul 2005 00:00:00 -0400 Subject: ACPICA 20050708 from Bob Moore The use of the CPU stack in the debug version of the subsystem has been considerably reduced. Previously, a debug structure was declared in every function that used the debug macros. This structure has been removed in favor of declaring the individual elements as parameters to the debug functions. This reduces the cumulative stack use during nested execution of ACPI function calls at the cost of a small increase in the code size of the debug version of the subsystem. With assistance from Alexey Starikovskiy and Len Brown. Added the ACPI_GET_FUNCTION_NAME macro to enable the compiler-dependent headers to define a macro that will return the current function name at runtime (such as __FUNCTION__ or _func_, etc.) The function name is used by the debug trace output. If ACPI_GET_FUNCTION_NAME is not defined in the compiler-dependent header, the function name is saved on the CPU stack (one pointer per function.) This mechanism is used because apparently there exists no standard ANSI-C defined macro that that returns the function name. Alexey Starikovskiy redesigned and reimplemented the "Owner ID" mechanism used to track namespace objects created/deleted by ACPI tables and control method execution. A bitmap is now used to allocate and free the IDs, thus solving the wraparound problem present in the previous implementation. The size of the namespace node descriptor was reduced by 2 bytes as a result. Removed the UINT32_BIT and UINT16_BIT types that were used for the bitfield flag definitions within the headers for the predefined ACPI tables. These have been replaced by UINT8_BIT in order to increase the code portability of the subsystem. If the use of UINT8 remains a problem, we may be forced to eliminate bitfields entirely because of a lack of portability. Alexey Starikovksiy enhanced the performance of acpi_ut_update_object_reference. This is a frequently used function and this improvement increases the performance of the entire subsystem. Alexey Starikovskiy fixed several possible memory leaks and the inverse - premature object deletion. Signed-off-by: Len Brown diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c index d7790db..ebc07aa 100644 --- a/drivers/acpi/dispatcher/dsinit.c +++ b/drivers/acpi/dispatcher/dsinit.c @@ -99,7 +99,7 @@ acpi_ds_init_one_object ( * was just loaded */ if (((struct acpi_namespace_node *) obj_handle)->owner_id != - info->table_desc->table_id) { + info->table_desc->owner_id) { return (AE_OK); } @@ -168,7 +168,7 @@ acpi_ds_init_one_object ( */ acpi_ns_delete_namespace_subtree (obj_handle); acpi_ns_delete_namespace_by_owner ( - ((struct acpi_namespace_node *) obj_handle)->object->method.owning_id); + ((struct acpi_namespace_node *) obj_handle)->object->method.owner_id); break; @@ -237,7 +237,7 @@ acpi_ds_initialize_objects ( ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n", - table_desc->pointer->signature, table_desc->table_id, info.object_count, + table_desc->pointer->signature, table_desc->owner_id, info.object_count, info.device_count, info.method_count, info.op_region_count)); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index c9d9a6c..1b90813 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c @@ -77,7 +77,6 @@ acpi_ds_parse_method ( union acpi_operand_object *obj_desc; union acpi_parse_object *op; struct acpi_namespace_node *node; - acpi_owner_id owner_id; struct acpi_walk_state *walk_state; @@ -132,15 +131,18 @@ acpi_ds_parse_method ( * objects (such as Operation Regions) can be created during the * first pass parse. */ - owner_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD); - obj_desc->method.owning_id = owner_id; + status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); + if (ACPI_FAILURE (status)) { + goto cleanup; + } /* Create and initialize a new walk state */ - walk_state = acpi_ds_create_walk_state (owner_id, NULL, NULL, NULL); + walk_state = acpi_ds_create_walk_state ( + obj_desc->method.owner_id, NULL, NULL, NULL); if (!walk_state) { status = AE_NO_MEMORY; - goto cleanup; + goto cleanup2; } status = acpi_ds_init_aml_walk (walk_state, op, node, @@ -148,7 +150,7 @@ acpi_ds_parse_method ( obj_desc->method.aml_length, NULL, 1); if (ACPI_FAILURE (status)) { acpi_ds_delete_walk_state (walk_state); - goto cleanup; + goto cleanup2; } /* @@ -162,13 +164,16 @@ acpi_ds_parse_method ( */ status = acpi_ps_parse_aml (walk_state); if (ACPI_FAILURE (status)) { - goto cleanup; + goto cleanup2; } ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n", acpi_ut_get_node_name (obj_handle), obj_handle, op)); +cleanup2: + (void) acpi_ut_release_owner_id (obj_desc->method.owner_id); + cleanup: acpi_ps_delete_parse_tree (op); return_ACPI_STATUS (status); @@ -265,7 +270,7 @@ acpi_ds_call_control_method ( { acpi_status status; struct acpi_namespace_node *method_node; - struct acpi_walk_state *next_walk_state; + struct acpi_walk_state *next_walk_state = NULL; union acpi_operand_object *obj_desc; struct acpi_parameter_info info; u32 i; @@ -289,20 +294,23 @@ acpi_ds_call_control_method ( return_ACPI_STATUS (AE_NULL_OBJECT); } - obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD); + status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); + } /* Init for new method, wait on concurrency semaphore */ status = acpi_ds_begin_method_execution (method_node, obj_desc, this_walk_state->method_node); if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + goto cleanup; } if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) { /* 1) Parse: Create a new walk state for the preempting walk */ - next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, + next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, op, obj_desc, NULL); if (!next_walk_state) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -332,7 +340,7 @@ acpi_ds_call_control_method ( /* 2) Execute: Create a new state for the preempting walk */ - next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, + next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, NULL, obj_desc, thread); if (!next_walk_state) { status = AE_NO_MEMORY; @@ -383,6 +391,7 @@ acpi_ds_call_control_method ( /* On error, we must delete the new walk state */ cleanup: + (void) acpi_ut_release_owner_id (obj_desc->method.owner_id); if (next_walk_state && (next_walk_state->method_desc)) { /* Decrement the thread count on the method parse tree */ @@ -584,7 +593,7 @@ acpi_ds_terminate_control_method ( * Delete any namespace entries created anywhere else within * the namespace */ - acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owning_id); + acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owner_id); status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c index 8bfa6ef..76c6ebd0 100644 --- a/drivers/acpi/executer/exconfig.c +++ b/drivers/acpi/executer/exconfig.c @@ -487,7 +487,7 @@ acpi_ex_unload_table ( * Delete the entire namespace under this table Node * (Offset contains the table_id) */ - acpi_ns_delete_namespace_by_owner (table_info->table_id); + acpi_ns_delete_namespace_by_owner (table_info->owner_id); /* Delete the table itself */ diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index 7007abb..6158f51 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c @@ -819,7 +819,7 @@ acpi_ex_dump_object_descriptor ( acpi_ex_out_integer ("param_count", obj_desc->method.param_count); acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency); acpi_ex_out_pointer ("Semaphore", obj_desc->method.semaphore); - acpi_ex_out_integer ("owning_id", obj_desc->method.owning_id); + acpi_ex_out_integer ("owner_id", obj_desc->method.owner_id); acpi_ex_out_integer ("aml_length", obj_desc->method.aml_length); acpi_ex_out_pointer ("aml_start", obj_desc->method.aml_start); break; diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c index 131f49a..c1ba8b4 100644 --- a/drivers/acpi/executer/exoparg1.c +++ b/drivers/acpi/executer/exoparg1.c @@ -904,6 +904,7 @@ acpi_ex_opcode_1A_0T_1R ( */ return_desc = acpi_ns_get_attached_object ( (struct acpi_namespace_node *) operand[0]); + acpi_ut_add_reference (return_desc); } else { /* @@ -953,20 +954,10 @@ acpi_ex_opcode_1A_0T_1R ( * add another reference to the referenced object, however. */ return_desc = *(operand[0]->reference.where); - if (!return_desc) { - /* - * We can't return a NULL dereferenced value. This is - * an uninitialized package element and is thus a - * severe error. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "NULL package element obj %p\n", - operand[0])); - status = AE_AML_UNINITIALIZED_ELEMENT; - goto cleanup; + if (return_desc) { + acpi_ut_add_reference (return_desc); } - acpi_ut_add_reference (return_desc); break; diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c index d8b470e..aaba7ab 100644 --- a/drivers/acpi/executer/exresop.c +++ b/drivers/acpi/executer/exresop.c @@ -426,6 +426,10 @@ acpi_ex_resolve_operands ( return_ACPI_STATUS (status); } + + if (obj_desc != *stack_ptr) { + acpi_ut_remove_reference (obj_desc); + } goto next_operand; @@ -448,6 +452,10 @@ acpi_ex_resolve_operands ( return_ACPI_STATUS (status); } + + if (obj_desc != *stack_ptr) { + acpi_ut_remove_reference (obj_desc); + } goto next_operand; @@ -471,6 +479,10 @@ acpi_ex_resolve_operands ( return_ACPI_STATUS (status); } + + if (obj_desc != *stack_ptr) { + acpi_ut_remove_reference (obj_desc); + } goto next_operand; @@ -515,6 +527,10 @@ acpi_ex_resolve_operands ( if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } + + if (obj_desc != *stack_ptr) { + acpi_ut_remove_reference (obj_desc); + } break; default: diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c index 9df0a64..0bda88d 100644 --- a/drivers/acpi/namespace/nsaccess.c +++ b/drivers/acpi/namespace/nsaccess.c @@ -163,7 +163,7 @@ acpi_ns_root_initialize ( /* * i_aSL Compiler cheats by putting parameter count - * in the owner_iD + * in the owner_iD (param_count max is 7) */ new_node->owner_id = obj_desc->method.param_count; #else diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c index 3f94b08..edbf1db 100644 --- a/drivers/acpi/namespace/nsalloc.c +++ b/drivers/acpi/namespace/nsalloc.c @@ -190,7 +190,7 @@ acpi_ns_install_node ( struct acpi_namespace_node *node, /* New Child*/ acpi_object_type type) { - u16 owner_id = 0; + acpi_owner_id owner_id = 0; struct acpi_namespace_node *child_node; #ifdef ACPI_ALPHABETIC_NAMESPACE @@ -559,7 +559,7 @@ acpi_ns_remove_reference ( void acpi_ns_delete_namespace_by_owner ( - u16 owner_id) + acpi_owner_id owner_id) { struct acpi_namespace_node *child_node; struct acpi_namespace_node *deletion_node; @@ -635,6 +635,7 @@ acpi_ns_delete_namespace_by_owner ( } } + (void) acpi_ut_release_owner_id (owner_id); return_VOID; } diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c index c9f35dd..d86ccbc 100644 --- a/drivers/acpi/namespace/nsdump.c +++ b/drivers/acpi/namespace/nsdump.c @@ -203,7 +203,7 @@ acpi_ns_dump_one_object ( /* Check if the owner matches */ - if ((info->owner_id != ACPI_UINT32_MAX) && + if ((info->owner_id != ACPI_OWNER_ID_MAX) && (info->owner_id != this_node->owner_id)) { return (AE_OK); } @@ -598,7 +598,7 @@ acpi_ns_dump_objects ( acpi_object_type type, u8 display_type, u32 max_depth, - u32 owner_id, + acpi_owner_id owner_id, acpi_handle start_handle) { struct acpi_walk_info info; @@ -643,7 +643,7 @@ acpi_ns_dump_entry ( info.debug_level = debug_level; - info.owner_id = ACPI_UINT32_MAX; + info.owner_id = ACPI_OWNER_ID_MAX; info.display_type = ACPI_DISPLAY_SUMMARY; (void) acpi_ns_dump_one_object (handle, 1, &info, NULL); @@ -694,7 +694,7 @@ acpi_ns_dump_tables ( } acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth, - ACPI_UINT32_MAX, search_handle); + ACPI_OWNER_ID_MAX, search_handle); return_VOID; } #endif /* _ACPI_ASL_COMPILER */ diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c index f81b836..64e0b2b 100644 --- a/drivers/acpi/namespace/nsparse.c +++ b/drivers/acpi/namespace/nsparse.c @@ -87,7 +87,7 @@ acpi_ns_one_complete_parse ( /* Create and initialize a new walk state */ - walk_state = acpi_ds_create_walk_state (table_desc->table_id, + walk_state = acpi_ds_create_walk_state (table_desc->owner_id, NULL, NULL, NULL); if (!walk_state) { acpi_ps_free_op (parse_root); diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c index decb2e9..095672a 100644 --- a/drivers/acpi/parser/psloop.c +++ b/drivers/acpi/parser/psloop.c @@ -407,9 +407,14 @@ acpi_ps_parse_loop ( INCREMENT_ARG_LIST (walk_state->arg_types); } + /* Special processing for certain opcodes */ - if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) && + /* TBD (remove): Temporary mechanism to disable this code if needed */ + +#ifndef ACPI_NO_MODULE_LEVEL_CODE + + if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) && ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) { /* * We want to skip If/Else/While constructs during Pass1 @@ -434,7 +439,7 @@ acpi_ps_parse_loop ( break; } } - +#endif switch (op->common.aml_opcode) { case AML_METHOD_OP: diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c index dba8936..5279b51 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -138,11 +138,14 @@ acpi_psx_execute ( * objects (such as Operation Regions) can be created during the * first pass parse. */ - obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD); + status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); + if (ACPI_FAILURE (status)) { + goto cleanup2; + } /* Create and initialize a new walk state */ - walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, + walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, NULL, NULL, NULL); if (!walk_state) { status = AE_NO_MEMORY; diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c index 629b64c..2ad72f2 100644 --- a/drivers/acpi/tables/tbinstal.c +++ b/drivers/acpi/tables/tbinstal.c @@ -251,6 +251,7 @@ acpi_tb_init_table_descriptor ( { struct acpi_table_list *list_head; struct acpi_table_desc *table_desc; + acpi_status status; ACPI_FUNCTION_TRACE_U32 ("tb_init_table_descriptor", table_type); @@ -263,6 +264,13 @@ acpi_tb_init_table_descriptor ( return_ACPI_STATUS (AE_NO_MEMORY); } + /* Get a new owner ID for the table */ + + status = acpi_ut_allocate_owner_id (&table_desc->owner_id); + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); + } + /* Install the table into the global data structure */ list_head = &acpi_gbl_table_lists[table_type]; @@ -325,8 +333,6 @@ acpi_tb_init_table_descriptor ( table_desc->aml_start = (u8 *) (table_desc->pointer + 1), table_desc->aml_length = (u32) (table_desc->length - (u32) sizeof (struct acpi_table_header)); - table_desc->table_id = acpi_ut_allocate_owner_id ( - ACPI_OWNER_TYPE_TABLE); table_desc->loaded_into_namespace = FALSE; /* @@ -339,7 +345,7 @@ acpi_tb_init_table_descriptor ( /* Return Data */ - table_info->table_id = table_desc->table_id; + table_info->owner_id = table_desc->owner_id; table_info->installed_desc = table_desc; return_ACPI_STATUS (AE_OK); diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c index 13c6ddb..069d498 100644 --- a/drivers/acpi/tables/tbrsdt.c +++ b/drivers/acpi/tables/tbrsdt.c @@ -96,32 +96,13 @@ acpi_tb_verify_rsdp ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * The signature and checksum must both be correct - */ - if (ACPI_STRNCMP ((char *) rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { - /* Nope, BAD Signature */ - - status = AE_BAD_SIGNATURE; - goto cleanup; - } - - /* Check the standard checksum */ + /* Verify RSDP signature and checksum */ - if (acpi_tb_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { - status = AE_BAD_CHECKSUM; + status = acpi_tb_validate_rsdp (rsdp); + if (ACPI_FAILURE (status)) { goto cleanup; } - /* Check extended checksum if table version >= 2 */ - - if (rsdp->revision >= 2) { - if (acpi_tb_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0) { - status = AE_BAD_CHECKSUM; - goto cleanup; - } - } - /* The RSDP supplied is OK */ table_info.pointer = ACPI_CAST_PTR (struct acpi_table_header, rsdp); diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c index 0c0b908..ca2dbdd 100644 --- a/drivers/acpi/tables/tbxface.c +++ b/drivers/acpi/tables/tbxface.c @@ -260,8 +260,7 @@ acpi_unload_table ( * "Scope" operator. Thus, we need to track ownership by an ID, not * simply a position within the hierarchy */ - acpi_ns_delete_namespace_by_owner (table_desc->table_id); - + acpi_ns_delete_namespace_by_owner (table_desc->owner_id); table_desc = table_desc->next; } diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c index fe9c831..abb4c93 100644 --- a/drivers/acpi/tables/tbxfroot.c +++ b/drivers/acpi/tables/tbxfroot.c @@ -65,6 +65,51 @@ acpi_tb_scan_memory_for_rsdp ( /******************************************************************************* * + * FUNCTION: acpi_tb_validate_rsdp + * + * PARAMETERS: Rsdp - Pointer to unvalidated RSDP + * + * RETURN: Status + * + * DESCRIPTION: Validate the RSDP (ptr) + * + ******************************************************************************/ + +acpi_status +acpi_tb_validate_rsdp ( + struct rsdp_descriptor *rsdp) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * The signature and checksum must both be correct + */ + if (ACPI_STRNCMP ((char *) rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { + /* Nope, BAD Signature */ + + return (AE_BAD_SIGNATURE); + } + + /* Check the standard checksum */ + + if (acpi_tb_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { + return (AE_BAD_CHECKSUM); + } + + /* Check extended checksum if table version >= 2 */ + + if ((rsdp->revision >= 2) && + (acpi_tb_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) { + return (AE_BAD_CHECKSUM); + } + + return (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: acpi_tb_find_table * * PARAMETERS: Signature - String with ACPI table signature @@ -218,19 +263,11 @@ acpi_get_firmware_table ( acpi_gbl_RSDP = address.pointer.logical; } - /* The signature and checksum must both be correct */ - - if (ACPI_STRNCMP ((char *) acpi_gbl_RSDP, RSDP_SIG, - sizeof (RSDP_SIG)-1) != 0) { - /* Nope, BAD Signature */ + /* The RDSP signature and checksum must both be correct */ - return_ACPI_STATUS (AE_BAD_SIGNATURE); - } - - if (acpi_tb_checksum (acpi_gbl_RSDP, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { - /* Nope, BAD Checksum */ - - return_ACPI_STATUS (AE_BAD_CHECKSUM); + status = acpi_tb_validate_rsdp (acpi_gbl_RSDP); + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); } } @@ -414,9 +451,9 @@ acpi_tb_scan_memory_for_rsdp ( u8 *start_address, u32 length) { + acpi_status status; u8 *mem_rover; u8 *end_address; - u8 checksum; ACPI_FUNCTION_TRACE ("tb_scan_memory_for_rsdp"); @@ -428,45 +465,25 @@ acpi_tb_scan_memory_for_rsdp ( for (mem_rover = start_address; mem_rover < end_address; mem_rover += ACPI_RSDP_SCAN_STEP) { - /* The signature and checksum must both be correct */ + /* The RSDP signature and checksum must both be correct */ - if (ACPI_STRNCMP ((char *) mem_rover, - RSDP_SIG, sizeof (RSDP_SIG) - 1) != 0) { - /* No signature match, keep looking */ - - continue; - } - - /* Signature matches, check the appropriate checksum */ - - if ((ACPI_CAST_PTR (struct rsdp_descriptor, mem_rover))->revision < 2) { - /* ACPI version 1.0 */ - - checksum = acpi_tb_checksum (mem_rover, ACPI_RSDP_CHECKSUM_LENGTH); - } - else { - /* Post ACPI 1.0, use extended_checksum */ - - checksum = acpi_tb_checksum (mem_rover, ACPI_RSDP_XCHECKSUM_LENGTH); - } - - if (checksum == 0) { - /* Checksum valid, we have found a valid RSDP */ + status = acpi_tb_validate_rsdp (ACPI_CAST_PTR (struct rsdp_descriptor, mem_rover)); + if (ACPI_SUCCESS (status)) { + /* Sig and checksum valid, we have found a real RSDP */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP located at physical address %p\n", mem_rover)); return_PTR (mem_rover); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Found an RSDP at physical address %p, but it has a bad checksum\n", - mem_rover)); + /* No sig match or bad checksum, keep searching */ } /* Searched entire block, no RSDP was found */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Searched entire block, no valid RSDP was found.\n")); + "Searched entire block from %p, valid RSDP was not found\n", + start_address)); return_PTR (NULL); } @@ -554,7 +571,7 @@ acpi_tb_find_rsdp ( acpi_os_unmap_memory (table_ptr, ACPI_EBDA_WINDOW_SIZE); if (mem_rover) { - /* Found it, return the physical address */ + /* Return the physical address */ physical_address += ACPI_PTR_DIFF (mem_rover, table_ptr); @@ -583,7 +600,7 @@ acpi_tb_find_rsdp ( acpi_os_unmap_memory (table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); if (mem_rover) { - /* Found it, return the physical address */ + /* Return the physical address */ physical_address = ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (mem_rover, table_ptr); @@ -614,7 +631,7 @@ acpi_tb_find_rsdp ( ACPI_PHYSADDR_TO_PTR (physical_address), ACPI_EBDA_WINDOW_SIZE); if (mem_rover) { - /* Found it, return the physical address */ + /* Return the physical address */ table_info->physical_address = ACPI_TO_INTEGER (mem_rover); return_ACPI_STATUS (AE_OK); @@ -634,8 +651,9 @@ acpi_tb_find_rsdp ( } } - /* RSDP signature was not found */ + /* A valid RSDP was not found */ + ACPI_REPORT_ERROR (("No valid RSDP was found\n")); return_ACPI_STATUS (AE_NOT_FOUND); } diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c index 0758881..c0df058 100644 --- a/drivers/acpi/utilities/utcache.c +++ b/drivers/acpi/utilities/utcache.c @@ -74,6 +74,9 @@ acpi_os_create_cache ( struct acpi_memory_list *cache; + ACPI_FUNCTION_ENTRY (); + + if (!cache_name || !return_cache || (object_size < 16)) { return (AE_BAD_PARAMETER); } @@ -161,7 +164,10 @@ acpi_os_delete_cache ( acpi_status status; - /* Purge all objects in the cache */ + ACPI_FUNCTION_ENTRY (); + + + /* Purge all objects in the cache */ status = acpi_os_purge_cache (cache); if (ACPI_FAILURE (status)) { @@ -259,7 +265,7 @@ acpi_os_acquire_object ( void *object; - ACPI_FUNCTION_NAME ("ut_acquire_from_cache"); + ACPI_FUNCTION_NAME ("os_acquire_object"); if (!cache) { @@ -286,7 +292,7 @@ acpi_os_acquire_object ( ACPI_MEM_TRACKING (cache->hits++); ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Object %p from %s\n", object, cache->list_name))); + "Object %p from %s cache\n", object, cache->list_name))); status = acpi_ut_release_mutex (ACPI_MTX_CACHES); if (ACPI_FAILURE (status)) { diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c index 08362f6..3d5fbc8 100644 --- a/drivers/acpi/utilities/utdebug.c +++ b/drivers/acpi/utilities/utdebug.c @@ -116,10 +116,9 @@ acpi_ut_track_stack_ptr ( * * PARAMETERS: requested_debug_level - Requested debug print level * line_number - Caller's line number (for error output) - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Format - Printf format field * ... - Optional printf arguments * @@ -134,7 +133,9 @@ void ACPI_INTERNAL_VAR_XFACE acpi_ut_debug_print ( u32 requested_debug_level, u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, char *format, ...) { @@ -146,7 +147,7 @@ acpi_ut_debug_print ( * Stay silent if the debug level or component ID is disabled */ if (!(requested_debug_level & acpi_dbg_level) || - !(dbg_info->component_id & acpi_dbg_layer)) { + !(component_id & acpi_dbg_layer)) { return; } @@ -169,14 +170,14 @@ acpi_ut_debug_print ( * Display the module name, current line number, thread ID (if requested), * current procedure nesting level, and the current procedure name */ - acpi_os_printf ("%8s-%04ld ", dbg_info->module_name, line_number); + acpi_os_printf ("%8s-%04ld ", module_name, line_number); if (ACPI_LV_THREADS & acpi_dbg_level) { acpi_os_printf ("[%04lX] ", thread_id); } acpi_os_printf ("[%02ld] %-22.22s: ", - acpi_gbl_nesting_level, dbg_info->proc_name); + acpi_gbl_nesting_level, function_name); va_start (args, format); acpi_os_vprintf (format, args); @@ -190,10 +191,9 @@ EXPORT_SYMBOL(acpi_ut_debug_print); * * PARAMETERS: requested_debug_level - Requested debug print level * line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Format - Printf format field * ... - Optional printf arguments * @@ -208,7 +208,9 @@ void ACPI_INTERNAL_VAR_XFACE acpi_ut_debug_print_raw ( u32 requested_debug_level, u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, char *format, ...) { @@ -216,7 +218,7 @@ acpi_ut_debug_print_raw ( if (!(requested_debug_level & acpi_dbg_level) || - !(dbg_info->component_id & acpi_dbg_layer)) { + !(component_id & acpi_dbg_layer)) { return; } @@ -231,10 +233,9 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw); * FUNCTION: acpi_ut_trace * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * * RETURN: None * @@ -246,14 +247,17 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw); void acpi_ut_trace ( u32 line_number, - struct acpi_debug_print_info *dbg_info) + char *function_name, + char *module_name, + u32 component_id) { acpi_gbl_nesting_level++; acpi_ut_track_stack_ptr (); - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s\n", acpi_gbl_fn_entry_str); + acpi_ut_debug_print (ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, component_id, + "%s\n", acpi_gbl_fn_entry_str); } EXPORT_SYMBOL(acpi_ut_trace); @@ -263,10 +267,9 @@ EXPORT_SYMBOL(acpi_ut_trace); * FUNCTION: acpi_ut_trace_ptr * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Pointer - Pointer to display * * RETURN: None @@ -279,14 +282,17 @@ EXPORT_SYMBOL(acpi_ut_trace); void acpi_ut_trace_ptr ( u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, void *pointer) { acpi_gbl_nesting_level++; acpi_ut_track_stack_ptr (); - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s %p\n", acpi_gbl_fn_entry_str, pointer); + acpi_ut_debug_print (ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, component_id, + "%s %p\n", acpi_gbl_fn_entry_str, pointer); } @@ -295,10 +301,9 @@ acpi_ut_trace_ptr ( * FUNCTION: acpi_ut_trace_str * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * String - Additional string to display * * RETURN: None @@ -311,15 +316,18 @@ acpi_ut_trace_ptr ( void acpi_ut_trace_str ( u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, char *string) { acpi_gbl_nesting_level++; acpi_ut_track_stack_ptr (); - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s %s\n", acpi_gbl_fn_entry_str, string); + acpi_ut_debug_print (ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, component_id, + "%s %s\n", acpi_gbl_fn_entry_str, string); } @@ -328,10 +336,9 @@ acpi_ut_trace_str ( * FUNCTION: acpi_ut_trace_u32 * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Integer - Integer to display * * RETURN: None @@ -344,15 +351,18 @@ acpi_ut_trace_str ( void acpi_ut_trace_u32 ( u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, u32 integer) { acpi_gbl_nesting_level++; acpi_ut_track_stack_ptr (); - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s %08X\n", acpi_gbl_fn_entry_str, integer); + acpi_ut_debug_print (ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, component_id, + "%s %08X\n", acpi_gbl_fn_entry_str, integer); } @@ -361,10 +371,9 @@ acpi_ut_trace_u32 ( * FUNCTION: acpi_ut_exit * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * * RETURN: None * @@ -376,11 +385,14 @@ acpi_ut_trace_u32 ( void acpi_ut_exit ( u32 line_number, - struct acpi_debug_print_info *dbg_info) + char *function_name, + char *module_name, + u32 component_id) { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s\n", acpi_gbl_fn_exit_str); + acpi_ut_debug_print (ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, component_id, + "%s\n", acpi_gbl_fn_exit_str); acpi_gbl_nesting_level--; } @@ -392,10 +404,9 @@ EXPORT_SYMBOL(acpi_ut_exit); * FUNCTION: acpi_ut_status_exit * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Status - Exit status code * * RETURN: None @@ -408,19 +419,23 @@ EXPORT_SYMBOL(acpi_ut_exit); void acpi_ut_status_exit ( u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, acpi_status status) { if (ACPI_SUCCESS (status)) { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s %s\n", acpi_gbl_fn_exit_str, - acpi_format_exception (status)); + acpi_ut_debug_print (ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, component_id, + "%s %s\n", acpi_gbl_fn_exit_str, + acpi_format_exception (status)); } else { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s ****Exception****: %s\n", acpi_gbl_fn_exit_str, - acpi_format_exception (status)); + acpi_ut_debug_print (ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, component_id, + "%s ****Exception****: %s\n", acpi_gbl_fn_exit_str, + acpi_format_exception (status)); } acpi_gbl_nesting_level--; @@ -433,10 +448,9 @@ EXPORT_SYMBOL(acpi_ut_status_exit); * FUNCTION: acpi_ut_value_exit * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Value - Value to be printed with exit msg * * RETURN: None @@ -449,13 +463,16 @@ EXPORT_SYMBOL(acpi_ut_status_exit); void acpi_ut_value_exit ( u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, acpi_integer value) { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, - ACPI_FORMAT_UINT64 (value)); + acpi_ut_debug_print (ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, component_id, + "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, + ACPI_FORMAT_UINT64 (value)); acpi_gbl_nesting_level--; } @@ -467,10 +484,9 @@ EXPORT_SYMBOL(acpi_ut_value_exit); * FUNCTION: acpi_ut_ptr_exit * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Ptr - Pointer to display * * RETURN: None @@ -483,12 +499,15 @@ EXPORT_SYMBOL(acpi_ut_value_exit); void acpi_ut_ptr_exit ( u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, u8 *ptr) { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s %p\n", acpi_gbl_fn_exit_str, ptr); + acpi_ut_debug_print (ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, component_id, + "%s %p\n", acpi_gbl_fn_exit_str, ptr); acpi_gbl_nesting_level--; } diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index be97ada..eeafb32 100644 --- a/drivers/acpi/utilities/utdelete.c +++ b/drivers/acpi/utilities/utdelete.c @@ -435,35 +435,24 @@ acpi_ut_update_object_reference ( union acpi_operand_object *object, u16 action) { - acpi_status status; - u32 i; - union acpi_generic_state *state_list = NULL; - union acpi_generic_state *state; + acpi_status status = AE_OK; + union acpi_generic_state *state_list = NULL; + union acpi_operand_object *next_object = NULL; + union acpi_generic_state *state; + acpi_native_uint i; ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object); - /* Ignore a null object ptr */ + while (object) { + /* Make sure that this isn't a namespace handle */ - if (!object) { - return_ACPI_STATUS (AE_OK); - } - - /* Make sure that this isn't a namespace handle */ - - if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Object %p is NS handle\n", object)); - return_ACPI_STATUS (AE_OK); - } - - state = acpi_ut_create_update_state (object, action); - - while (state) { - object = state->update.object; - action = state->update.value; - acpi_ut_delete_generic_state (state); + if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Object %p is NS handle\n", object)); + return_ACPI_STATUS (AE_OK); + } /* * All sub-objects must have their reference count incremented also. @@ -476,12 +465,10 @@ acpi_ut_update_object_reference ( acpi_ut_update_ref_count (object->device.device_notify, action); break; - case ACPI_TYPE_PACKAGE: - /* - * We must update all the sub-objects of the package - * (Each of whom may have their own sub-objects, etc. + * We must update all the sub-objects of the package, + * each of whom may have their own sub-objects. */ for (i = 0; i < object->package.count; i++) { /* @@ -497,35 +484,19 @@ acpi_ut_update_object_reference ( } break; - case ACPI_TYPE_BUFFER_FIELD: - status = acpi_ut_create_update_state_and_push ( - object->buffer_field.buffer_obj, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } + next_object = object->buffer_field.buffer_obj; break; - case ACPI_TYPE_LOCAL_REGION_FIELD: - status = acpi_ut_create_update_state_and_push ( - object->field.region_obj, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } - break; - + next_object = object->field.region_obj; + break; case ACPI_TYPE_LOCAL_BANK_FIELD: - status = acpi_ut_create_update_state_and_push ( - object->bank_field.bank_obj, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } - + next_object = object->bank_field.bank_obj; status = acpi_ut_create_update_state_and_push ( object->bank_field.region_obj, action, &state_list); if (ACPI_FAILURE (status)) { @@ -533,15 +504,9 @@ acpi_ut_update_object_reference ( } break; - case ACPI_TYPE_LOCAL_INDEX_FIELD: - status = acpi_ut_create_update_state_and_push ( - object->index_field.index_obj, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } - + next_object = object->index_field.index_obj; status = acpi_ut_create_update_state_and_push ( object->index_field.data_obj, action, &state_list); if (ACPI_FAILURE (status)) { @@ -549,28 +514,19 @@ acpi_ut_update_object_reference ( } break; - case ACPI_TYPE_LOCAL_REFERENCE: - /* * The target of an Index (a package, string, or buffer) must track * changes to the ref count of the index. */ if (object->reference.opcode == AML_INDEX_OP) { - status = acpi_ut_create_update_state_and_push ( - object->reference.object, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } + next_object = object->reference.object; } break; - case ACPI_TYPE_REGION: default: - - /* No subobjects */ - break; + break;/* No subobjects */ } /* @@ -579,15 +535,23 @@ acpi_ut_update_object_reference ( * main object to be deleted. */ acpi_ut_update_ref_count (object, action); + object = NULL; /* Move on to the next object to be updated */ - state = acpi_ut_pop_generic_state (&state_list); + if (next_object) { + object = next_object; + next_object = NULL; + } + else if (state_list) { + state = acpi_ut_pop_generic_state (&state_list); + object = state->update.object; + acpi_ut_delete_generic_state (state); + } } return_ACPI_STATUS (AE_OK); - error_exit: ACPI_REPORT_ERROR (("Could not update object reference count, %s\n", diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 8653dda..0e4161c 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -738,73 +738,6 @@ acpi_ut_valid_object_type ( /******************************************************************************* * - * FUNCTION: acpi_ut_allocate_owner_id - * - * PARAMETERS: id_type - Type of ID (method or table) - * - * DESCRIPTION: Allocate a table or method owner id - * - * NOTE: this algorithm has a wraparound problem at 64_k method invocations, and - * should be revisited (TBD) - * - ******************************************************************************/ - -acpi_owner_id -acpi_ut_allocate_owner_id ( - u32 id_type) -{ - acpi_owner_id owner_id = 0xFFFF; - - - ACPI_FUNCTION_TRACE ("ut_allocate_owner_id"); - - - if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) - { - return (0); - } - - switch (id_type) - { - case ACPI_OWNER_TYPE_TABLE: - - owner_id = acpi_gbl_next_table_owner_id; - acpi_gbl_next_table_owner_id++; - - /* Check for wraparound */ - - if (acpi_gbl_next_table_owner_id == ACPI_FIRST_METHOD_ID) - { - acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID; - ACPI_REPORT_WARNING (("Table owner ID wraparound\n")); - } - break; - - - case ACPI_OWNER_TYPE_METHOD: - - owner_id = acpi_gbl_next_method_owner_id; - acpi_gbl_next_method_owner_id++; - - if (acpi_gbl_next_method_owner_id == ACPI_FIRST_TABLE_ID) - { - /* Check for wraparound */ - - acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID; - } - break; - - default: - break; - } - - (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); - return_VALUE (owner_id); -} - - -/******************************************************************************* - * * FUNCTION: acpi_ut_init_globals * * PARAMETERS: None @@ -848,7 +781,7 @@ acpi_ut_init_globals ( for (i = 0; i < NUM_MUTEX; i++) { acpi_gbl_mutex_info[i].mutex = NULL; - acpi_gbl_mutex_info[i].owner_id = ACPI_MUTEX_NOT_ACQUIRED; + acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED; acpi_gbl_mutex_info[i].use_count = 0; } @@ -889,8 +822,7 @@ acpi_ut_init_globals ( acpi_gbl_ns_lookup_count = 0; acpi_gbl_ps_find_count = 0; acpi_gbl_acpi_hardware_present = TRUE; - acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID; - acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID; + acpi_gbl_owner_id_mask = 0; acpi_gbl_debugger_configuration = DEBUGGER_THREADING; acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index 207c836..df715cd 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -52,6 +52,100 @@ /******************************************************************************* * + * FUNCTION: acpi_ut_allocate_owner_id + * + * PARAMETERS: owner_id - Where the new owner ID is returned + * + * DESCRIPTION: Allocate a table or method owner id + * + ******************************************************************************/ + +acpi_status +acpi_ut_allocate_owner_id ( + acpi_owner_id *owner_id) +{ + acpi_native_uint i; + acpi_status status; + + + ACPI_FUNCTION_TRACE ("ut_allocate_owner_id"); + + + status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); + } + + /* Find a free owner ID */ + + for (i = 0; i < 32; i++) { + if (!(acpi_gbl_owner_id_mask & (1 << i))) { + acpi_gbl_owner_id_mask |= (1 << i); + *owner_id = (acpi_owner_id) i; + goto exit; + } + } + + /* + * If we are here, all owner_ids have been allocated. This probably should + * not happen since the IDs are reused after deallocation. The IDs are + * allocated upon table load (one per table) and method execution, and + * they are released when a table is unloaded or a method completes + * execution. + */ + status = AE_OWNER_ID_LIMIT; + ACPI_REPORT_ERROR (( + "Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); + +exit: + (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); + return_ACPI_STATUS (status); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_release_owner_id + * + * PARAMETERS: owner_id - A previously allocated owner ID + * + * DESCRIPTION: Release a table or method owner id + * + ******************************************************************************/ + +acpi_status +acpi_ut_release_owner_id ( + acpi_owner_id owner_id) +{ + acpi_status status; + + + ACPI_FUNCTION_TRACE ("ut_release_owner_id"); + + + status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); + } + + /* Free the owner ID */ + + if (acpi_gbl_owner_id_mask & (1 << owner_id)) { + acpi_gbl_owner_id_mask ^= (1 << owner_id); + } + else { + /* This owner_id has not been allocated */ + + status = AE_NOT_EXIST; + } + + (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); + return_ACPI_STATUS (status); +} + + +/******************************************************************************* + * * FUNCTION: acpi_ut_strupr (strupr) * * PARAMETERS: src_string - The source string to convert diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c index a80b97c..0699b6b 100644 --- a/drivers/acpi/utilities/utmutex.c +++ b/drivers/acpi/utilities/utmutex.c @@ -159,7 +159,7 @@ acpi_ut_create_mutex ( if (!acpi_gbl_mutex_info[mutex_id].mutex) { status = acpi_os_create_semaphore (1, 1, &acpi_gbl_mutex_info[mutex_id].mutex); - acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; + acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; acpi_gbl_mutex_info[mutex_id].use_count = 0; } @@ -196,7 +196,7 @@ acpi_ut_delete_mutex ( status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex); acpi_gbl_mutex_info[mutex_id].mutex = NULL; - acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; + acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; return_ACPI_STATUS (status); } @@ -274,7 +274,7 @@ acpi_ut_acquire_mutex ( this_thread_id, acpi_ut_get_mutex_name (mutex_id))); acpi_gbl_mutex_info[mutex_id].use_count++; - acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id; + acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; } else { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, @@ -322,7 +322,7 @@ acpi_ut_release_mutex ( /* * Mutex must be acquired in order to release it! */ - if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) { + if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Mutex [%s] is not acquired, cannot release\n", acpi_ut_get_mutex_name (mutex_id))); @@ -359,7 +359,7 @@ acpi_ut_release_mutex ( /* Mark unlocked FIRST */ - acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; + acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index dd9b70c..aa3c08c 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -64,7 +64,7 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20050624 +#define ACPI_CA_VERSION 0x20050708 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h index fcc2d50..2632543 100644 --- a/include/acpi/acdisasm.h +++ b/include/acpi/acdisasm.h @@ -211,7 +211,7 @@ acpi_dm_byte_list ( union acpi_parse_object *op); void -acpi_is_eisa_id ( +acpi_dm_is_eisa_id ( union acpi_parse_object *op); void diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h index 60d737b..0a6f492 100644 --- a/include/acpi/acexcep.h +++ b/include/acpi/acexcep.h @@ -95,8 +95,9 @@ #define AE_ABORT_METHOD (acpi_status) (0x001C | AE_CODE_ENVIRONMENTAL) #define AE_SAME_HANDLER (acpi_status) (0x001D | AE_CODE_ENVIRONMENTAL) #define AE_WAKE_ONLY_GPE (acpi_status) (0x001E | AE_CODE_ENVIRONMENTAL) +#define AE_OWNER_ID_LIMIT (acpi_status) (0x001F | AE_CODE_ENVIRONMENTAL) -#define AE_CODE_ENV_MAX 0x001E +#define AE_CODE_ENV_MAX 0x001F /* @@ -226,7 +227,8 @@ char const *acpi_gbl_exception_names_env[] = "AE_LOGICAL_ADDRESS", "AE_ABORT_METHOD", "AE_SAME_HANDLER", - "AE_WAKE_ONLY_GPE" + "AE_WAKE_ONLY_GPE", + "AE_OWNER_ID_LIMIT" }; char const *acpi_gbl_exception_names_pgm[] = diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h index 8d5a397a..e3cf16e 100644 --- a/include/acpi/acglobal.h +++ b/include/acpi/acglobal.h @@ -218,9 +218,8 @@ ACPI_EXTERN u32 acpi_gbl_original_mode; ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; ACPI_EXTERN u32 acpi_gbl_ns_lookup_count; ACPI_EXTERN u32 acpi_gbl_ps_find_count; +ACPI_EXTERN u32 acpi_gbl_owner_id_mask; ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; -ACPI_EXTERN u16 acpi_gbl_next_table_owner_id; -ACPI_EXTERN u16 acpi_gbl_next_method_owner_id; ACPI_EXTERN u16 acpi_gbl_global_lock_handle; ACPI_EXTERN u8 acpi_gbl_debugger_configuration; ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h index 58f9ba1..4d26356 100644 --- a/include/acpi/aclocal.h +++ b/include/acpi/aclocal.h @@ -56,6 +56,13 @@ typedef u32 acpi_mutex_handle; #define AML_NUM_OPCODES 0x7F +/* Forward declarations */ + +struct acpi_walk_state ; +struct acpi_obj_mutex; +union acpi_parse_object ; + + /***************************************************************************** * * Mutex typedefs and structs @@ -116,19 +123,24 @@ static char *acpi_gbl_mutex_names[] = #endif +/* Owner IDs are used to track namespace nodes for selective deletion */ + +typedef u8 acpi_owner_id; +#define ACPI_OWNER_ID_MAX 0xFF + +/* This Thread ID means that the mutex is not in use (unlocked) */ + +#define ACPI_MUTEX_NOT_ACQUIRED (u32) -1 + /* Table for the global mutexes */ struct acpi_mutex_info { acpi_mutex mutex; u32 use_count; - u32 owner_id; + u32 thread_id; }; -/* This owner ID means that the mutex is not in use (unlocked) */ - -#define ACPI_MUTEX_NOT_ACQUIRED (u32) (-1) - /* Lock flag parameter for various interfaces */ @@ -136,13 +148,6 @@ struct acpi_mutex_info #define ACPI_MTX_LOCK 1 -typedef u16 acpi_owner_id; -#define ACPI_OWNER_TYPE_TABLE 0x0 -#define ACPI_OWNER_TYPE_METHOD 0x1 -#define ACPI_FIRST_METHOD_ID 0x0001 -#define ACPI_FIRST_TABLE_ID 0xF000 - - /* Field access granularities */ #define ACPI_FIELD_BYTE_GRANULARITY 1 @@ -185,13 +190,20 @@ struct acpi_namespace_node { u8 descriptor; /* Used to differentiate object descriptor types */ u8 type; /* Type associated with this name */ - u16 owner_id; + u16 reference_count; /* Current count of references and children */ union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */ union acpi_operand_object *object; /* Pointer to attached ACPI object (optional) */ struct acpi_namespace_node *child; /* First child */ struct acpi_namespace_node *peer; /* Next peer*/ - u16 reference_count; /* Current count of references and children */ + u8 owner_id; /* Who created this node */ u8 flags; + + /* Fields used by the ASL compiler only */ + +#ifdef ACPI_ASL_COMPILER + u32 value; + union acpi_parse_object *op; +#endif }; @@ -222,7 +234,7 @@ struct acpi_table_desc u64 physical_address; u32 aml_length; acpi_size length; - acpi_owner_id table_id; + acpi_owner_id owner_id; u8 type; u8 allocation; u8 loaded_into_namespace; @@ -420,13 +432,6 @@ struct acpi_field_info #define ACPI_CONTROL_PREDICATE_TRUE 0xC4 -/* Forward declarations */ - -struct acpi_walk_state ; -struct acpi_obj_mutex; -union acpi_parse_object ; - - #define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ u8 data_type; /* To differentiate various internal objs */\ u8 flags; \ @@ -916,14 +921,6 @@ struct acpi_integrity_info * ****************************************************************************/ -struct acpi_debug_print_info -{ - u32 component_id; - char *proc_name; - char *module_name; -}; - - /* Entry for a memory allocation (debug only) */ #define ACPI_MEM_MALLOC 0 diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index 09be937..5b100ce 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h @@ -437,21 +437,22 @@ #define ACPI_PARAM_LIST(pl) pl /* - * Error reporting. These versions add callers module and line#. Since - * _THIS_MODULE gets compiled out when ACPI_DEBUG_OUTPUT isn't defined, only - * use it in debug mode. + * Error reporting. These versions add callers module and line#. + * + * Since _acpi_module_name gets compiled out when ACPI_DEBUG_OUTPUT + * isn't defined, only use it in debug mode. */ #ifdef ACPI_DEBUG_OUTPUT -#define ACPI_REPORT_INFO(fp) {acpi_ut_report_info(_THIS_MODULE,__LINE__,_COMPONENT); \ +#define ACPI_REPORT_INFO(fp) {acpi_ut_report_info(_acpi_module_name,__LINE__,_COMPONENT); \ acpi_os_printf ACPI_PARAM_LIST(fp);} -#define ACPI_REPORT_ERROR(fp) {acpi_ut_report_error(_THIS_MODULE,__LINE__,_COMPONENT); \ +#define ACPI_REPORT_ERROR(fp) {acpi_ut_report_error(_acpi_module_name,__LINE__,_COMPONENT); \ acpi_os_printf ACPI_PARAM_LIST(fp);} -#define ACPI_REPORT_WARNING(fp) {acpi_ut_report_warning(_THIS_MODULE,__LINE__,_COMPONENT); \ +#define ACPI_REPORT_WARNING(fp) {acpi_ut_report_warning(_acpi_module_name,__LINE__,_COMPONENT); \ acpi_os_printf ACPI_PARAM_LIST(fp);} -#define ACPI_REPORT_NSERROR(s,e) acpi_ns_report_error(_THIS_MODULE,__LINE__,_COMPONENT, s, e); +#define ACPI_REPORT_NSERROR(s,e) acpi_ns_report_error(_acpi_module_name,__LINE__,_COMPONENT, s, e); -#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) acpi_ns_report_method_error(_THIS_MODULE,__LINE__,_COMPONENT, s, n, p, e); +#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) acpi_ns_report_method_error(_acpi_module_name,__LINE__,_COMPONENT, s, n, p, e); #else @@ -480,36 +481,56 @@ * Debug macros that are conditionally compiled */ #ifdef ACPI_DEBUG_OUTPUT +#define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_acpi_module_name = name; -#define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_THIS_MODULE = name; +/* + * Common parameters used for debug output functions: + * line number, function name, module(file) name, component ID + */ +#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _acpi_module_name, _COMPONENT /* - * Function entry tracing. - * The first parameter should be the procedure name as a quoted string. This is declared - * as a local string ("_proc_name) so that it can be also used by the function exit macros below. + * Function entry tracing */ -#define ACPI_FUNCTION_NAME(a) struct acpi_debug_print_info _debug_info; \ - _debug_info.component_id = _COMPONENT; \ - _debug_info.proc_name = a; \ - _debug_info.module_name = _THIS_MODULE; - -#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ - acpi_ut_trace(__LINE__,&_debug_info) -#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ - acpi_ut_trace_ptr(__LINE__,&_debug_info,(void *)b) -#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ - acpi_ut_trace_u32(__LINE__,&_debug_info,(u32)b) -#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \ - acpi_ut_trace_str(__LINE__,&_debug_info,(char *)b) - -#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr() + +/* + * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header, + * define it now. This is the case where there the compiler does not support + * a __FUNCTION__ macro or equivalent. We save the function name on the + * local stack. + */ +#ifndef ACPI_GET_FUNCTION_NAME +#define ACPI_GET_FUNCTION_NAME _acpi_function_name +/* + * The Name parameter should be the procedure name as a quoted string. + * This is declared as a local string ("my_function_name") so that it can + * be also used by the function exit macros below. + */ +#define ACPI_FUNCTION_NAME(name) char *_acpi_function_name = name; + +#else +/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ + +#define ACPI_FUNCTION_NAME(name) +#endif + +#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ + acpi_ut_trace(ACPI_DEBUG_PARAMETERS) +#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ + acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS,(void *)b) +#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ + acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS,(u32)b) +#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \ + acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS,(char *)b) + +#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr() /* * Function exit tracing. * WARNING: These macros include a return statement. This is usually considered * bad form, but having a separate exit macro is very ugly and difficult to maintain. * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros - * so that "_proc_name" is defined. + * so that "_acpi_function_name" is defined. */ #ifdef ACPI_USE_DO_WHILE_0 #define ACPI_DO_WHILE0(a) do a while(0) @@ -517,10 +538,10 @@ #define ACPI_DO_WHILE0(a) a #endif -#define return_VOID ACPI_DO_WHILE0 ({acpi_ut_exit(__LINE__,&_debug_info);return;}) -#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({acpi_ut_status_exit(__LINE__,&_debug_info,(s));return((s));}) -#define return_VALUE(s) ACPI_DO_WHILE0 ({acpi_ut_value_exit(__LINE__,&_debug_info,(acpi_integer)(s));return((s));}) -#define return_PTR(s) ACPI_DO_WHILE0 ({acpi_ut_ptr_exit(__LINE__,&_debug_info,(u8 *)(s));return((s));}) +#define return_VOID ACPI_DO_WHILE0 ({acpi_ut_exit(ACPI_DEBUG_PARAMETERS);return;}) +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({acpi_ut_status_exit(ACPI_DEBUG_PARAMETERS,(s));return((s));}) +#define return_VALUE(s) ACPI_DO_WHILE0 ({acpi_ut_value_exit(ACPI_DEBUG_PARAMETERS,(acpi_integer)(s));return((s));}) +#define return_PTR(s) ACPI_DO_WHILE0 ({acpi_ut_ptr_exit(ACPI_DEBUG_PARAMETERS,(u8 *)(s));return((s));}) /* Conditional execution */ @@ -535,7 +556,7 @@ /* Stack and buffer dumping */ #define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a),0) -#define ACPI_DUMP_OPERANDS(a,b,c,d,e) acpi_ex_dump_operands(a,b,c,d,e,_THIS_MODULE,__LINE__) +#define ACPI_DUMP_OPERANDS(a,b,c,d,e) acpi_ex_dump_operands(a,b,c,d,e,_acpi_module_name,__LINE__) #define ACPI_DUMP_ENTRY(a,b) acpi_ns_dump_entry (a,b) @@ -572,7 +593,7 @@ * leaving no executable debug code! */ #define ACPI_MODULE_NAME(name) -#define _THIS_MODULE "" +#define _acpi_module_name "" #define ACPI_DEBUG_EXEC(a) #define ACPI_NORMAL_EXEC(a) a; @@ -648,19 +669,18 @@ /* Memory allocation */ -#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_THIS_MODULE,__LINE__) -#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate((acpi_size)(a), _COMPONENT,_THIS_MODULE,__LINE__) +#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) +#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__) #define ACPI_MEM_FREE(a) acpi_os_free(a) #define ACPI_MEM_TRACKING(a) - #else /* Memory allocation */ -#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_THIS_MODULE,__LINE__) -#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate_and_track((acpi_size)(a), _COMPONENT,_THIS_MODULE,__LINE__) -#define ACPI_MEM_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_THIS_MODULE,__LINE__) +#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) +#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate_and_track((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__) +#define ACPI_MEM_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_acpi_module_name,__LINE__) #define ACPI_MEM_TRACKING(a) a #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ diff --git a/include/acpi/acnamesp.h b/include/acpi/acnamesp.h index d1b3ce8..870e254 100644 --- a/include/acpi/acnamesp.h +++ b/include/acpi/acnamesp.h @@ -163,7 +163,7 @@ acpi_ns_delete_namespace_subtree ( void acpi_ns_delete_namespace_by_owner ( - u16 table_id); + acpi_owner_id owner_id); void acpi_ns_detach_object ( @@ -219,7 +219,7 @@ acpi_ns_dump_objects ( acpi_object_type type, u8 display_type, u32 max_depth, - u32 ownder_id, + acpi_owner_id owner_id, acpi_handle start_handle); #endif /* ACPI_FUTURE_USAGE */ diff --git a/include/acpi/acobject.h b/include/acpi/acobject.h index e079b94..34f9d1f 100644 --- a/include/acpi/acobject.h +++ b/include/acpi/acobject.h @@ -199,7 +199,7 @@ struct acpi_object_method ACPI_INTERNAL_METHOD implementation; u8 concurrency; u8 thread_count; - acpi_owner_id owning_id; + acpi_owner_id owner_id; }; diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h index 2fbe180..d7e828c 100644 --- a/include/acpi/acoutput.h +++ b/include/acpi/acoutput.h @@ -136,7 +136,7 @@ /* * Debug level macros that are used in the DEBUG_PRINT macros */ -#define ACPI_DEBUG_LEVEL(dl) (u32) dl,__LINE__,&_debug_info +#define ACPI_DEBUG_LEVEL(dl) (u32) dl,ACPI_DEBUG_PARAMETERS /* Exception level -- used in the global "debug_level" */ diff --git a/include/acpi/acstruct.h b/include/acpi/acstruct.h index a2025a8..f375c17 100644 --- a/include/acpi/acstruct.h +++ b/include/acpi/acstruct.h @@ -71,7 +71,6 @@ struct acpi_walk_state u8 walk_type; acpi_owner_id owner_id; /* Owner of objects created during the walk */ u8 last_predicate; /* Result of last predicate */ - u8 reserved; /* For alignment */ u8 current_result; /* */ u8 next_op_info; /* Info about next_op */ u8 num_operands; /* Stack pointer for Operands[] array */ @@ -154,17 +153,17 @@ struct acpi_device_walk_info struct acpi_walk_info { u32 debug_level; - u32 owner_id; + acpi_owner_id owner_id; u8 display_type; }; /* Display Types */ -#define ACPI_DISPLAY_SUMMARY 0 -#define ACPI_DISPLAY_OBJECTS 1 -#define ACPI_DISPLAY_MASK 1 +#define ACPI_DISPLAY_SUMMARY (u8) 0 +#define ACPI_DISPLAY_OBJECTS (u8) 1 +#define ACPI_DISPLAY_MASK (u8) 1 -#define ACPI_DISPLAY_SHORT 2 +#define ACPI_DISPLAY_SHORT (u8) 2 struct acpi_get_devices_info { diff --git a/include/acpi/actables.h b/include/acpi/actables.h index 39df92e..97e6f12 100644 --- a/include/acpi/actables.h +++ b/include/acpi/actables.h @@ -169,6 +169,10 @@ acpi_status acpi_tb_get_table_rsdt ( void); +acpi_status +acpi_tb_validate_rsdp ( + struct rsdp_descriptor *rsdp); + /* * tbutils - common table utilities diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h index b5cdcca..c1e9110 100644 --- a/include/acpi/actbl.h +++ b/include/acpi/actbl.h @@ -86,15 +86,15 @@ */ struct rsdp_descriptor /* Root System Descriptor Pointer */ { - char signature [8]; /* ACPI signature, contains "RSD PTR " */ - u8 checksum; /* To make sum of struct == 0 */ - char oem_id [6]; /* OEM identification */ - u8 revision; /* Must be 0 for 1.0, 2 for 2.0 */ - u32 rsdt_physical_address; /* 32-bit physical address of RSDT */ - u32 length; /* XSDT Length in bytes including hdr */ - u64 xsdt_physical_address; /* 64-bit physical address of XSDT */ - u8 extended_checksum; /* Checksum of entire table */ - char reserved [3]; /* Reserved field must be 0 */ + char signature[8]; /* ACPI signature, contains "RSD PTR " */ + u8 checksum; /* ACPI 1.0 checksum */ + char oem_id[6]; /* OEM identification */ + u8 revision; /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */ + u32 rsdt_physical_address; /* 32-bit physical address of the RSDT */ + u32 length; /* XSDT Length in bytes, including header */ + u64 xsdt_physical_address; /* 64-bit physical address of the XSDT */ + u8 extended_checksum; /* Checksum of entire table (ACPI 2.0) */ + char reserved[3]; /* Reserved, must be zero */ }; @@ -107,15 +107,15 @@ struct acpi_common_facs /* Common FACS for internal use */ #define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \ - char signature [4]; /* ACPI signature (4 ASCII characters) */\ - u32 length; /* Length of table, in bytes, including header */\ + char signature[4]; /* ASCII table signature */\ + u32 length; /* Length of table in bytes, including this header */\ u8 revision; /* ACPI Specification minor version # */\ u8 checksum; /* To make sum of entire table == 0 */\ - char oem_id [6]; /* OEM identification */\ - char oem_table_id [8]; /* OEM table identification */\ + char oem_id[6]; /* ASCII OEM identification */\ + char oem_table_id[8]; /* ASCII OEM table identification */\ u32 oem_revision; /* OEM revision number */\ - char asl_compiler_id [4]; /* ASL compiler vendor ID */\ - u32 asl_compiler_revision; /* ASL compiler revision number */ + char asl_compiler_id [4]; /* ASCII ASL compiler vendor ID */\ + u32 asl_compiler_revision; /* ASL compiler version */ struct acpi_table_header /* ACPI common table header */ @@ -139,8 +139,12 @@ struct multiple_apic_table { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ u32 local_apic_address; /* Physical address of local APIC */ - u32 PCATcompat : 1; /* A one indicates system also has dual 8259s */ - u32 reserved1 : 31; + + /* Flags (32 bits) */ + + u8 PCATcompat : 1; /* 00: System also has dual 8259s */ + u8 : 7; /* 01-07: Reserved, must be zero */ + u8 reserved1[3]; /* 08-31: Reserved, must be zero */ }; /* Values for Type in APIC_HEADER_DEF */ @@ -180,16 +184,18 @@ struct apic_header #define TRIGGER_RESERVED 2 #define TRIGGER_LEVEL 3 -/* Common flag definitions */ +/* Common flag definitions (16 bits each) */ #define MPS_INTI_FLAGS \ - u16 polarity : 2; /* Polarity of APIC I/O input signals */\ - u16 trigger_mode : 2; /* Trigger mode of APIC input signals */\ - u16 reserved1 : 12; /* Reserved, must be zero */ + u8 polarity : 2; /* 00-01: Polarity of APIC I/O input signals */\ + u8 trigger_mode : 2; /* 02-03: Trigger mode of APIC input signals */\ + u8 : 4; /* 04-07: Reserved, must be zero */\ + u8 reserved1; /* 08-15: Reserved, must be zero */ #define LOCAL_APIC_FLAGS \ - u32 processor_enabled: 1; /* Processor is usable if set */\ - u32 reserved2 : 31; /* Reserved, must be zero */ + u8 processor_enabled: 1; /* 00: Processor is usable if set */\ + u8 : 7; /* 01-07: Reserved, must be zero */\ + u8 reserved2; /* 08-15: Reserved, must be zero */ /* Sub-structures for MADT */ @@ -238,7 +244,7 @@ struct madt_local_apic_nmi struct madt_address_override { APIC_HEADER_DEF - u16 reserved; /* Reserved - must be zero */ + u16 reserved; /* Reserved, must be zero */ u64 address; /* APIC physical address */ }; @@ -246,7 +252,7 @@ struct madt_io_sapic { APIC_HEADER_DEF u8 io_sapic_id; /* I/O SAPIC ID */ - u8 reserved; /* Reserved - must be zero */ + u8 reserved; /* Reserved, must be zero */ u32 interrupt_base; /* Glocal interrupt for SAPIC start */ u64 address; /* SAPIC physical address */ }; @@ -257,7 +263,7 @@ struct madt_local_sapic u8 processor_id; /* ACPI processor id */ u8 local_sapic_id; /* SAPIC ID */ u8 local_sapic_eid; /* SAPIC EID */ - u8 reserved [3]; /* Reserved - must be zero */ + u8 reserved[3]; /* Reserved, must be zero */ LOCAL_APIC_FLAGS u32 processor_uID; /* Numeric UID - ACPI 3.0 */ char processor_uIDstring[1]; /* String UID - ACPI 3.0 */ diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h index 33de5f4..93c175a 100644 --- a/include/acpi/actbl1.h +++ b/include/acpi/actbl1.h @@ -52,8 +52,7 @@ struct rsdt_descriptor_rev1 { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - u32 table_offset_entry [1]; /* Array of pointers to other */ - /* ACPI tables */ + u32 table_offset_entry[1]; /* Array of pointers to ACPI tables */ }; @@ -62,14 +61,19 @@ struct rsdt_descriptor_rev1 */ struct facs_descriptor_rev1 { - char signature[4]; /* ACPI Signature */ - u32 length; /* Length of structure, in bytes */ + char signature[4]; /* ASCII table signature */ + u32 length; /* Length of structure in bytes */ u32 hardware_signature; /* Hardware configuration signature */ u32 firmware_waking_vector; /* ACPI OS waking vector */ u32 global_lock; /* Global Lock */ - u32 S4bios_f : 1; /* Indicates if S4BIOS support is present */ - u32 reserved1 : 31; /* Must be 0 */ - u8 resverved3 [40]; /* Reserved - must be zero */ + + /* Flags (32 bits) */ + + u8 S4bios_f : 1; /* 00: S4BIOS support is present */ + u8 : 7; /* 01-07: Reserved, must be zero */ + u8 reserved1[3]; /* 08-31: Reserved, must be zero */ + + u8 reserved2[40]; /* Reserved, must be zero */ }; @@ -82,13 +86,13 @@ struct fadt_descriptor_rev1 u32 firmware_ctrl; /* Physical address of FACS */ u32 dsdt; /* Physical address of DSDT */ u8 model; /* System Interrupt Model */ - u8 reserved1; /* Reserved */ + u8 reserved1; /* Reserved, must be zero */ u16 sci_int; /* System vector of SCI interrupt */ u32 smi_cmd; /* Port address of SMI command port */ u8 acpi_enable; /* Value to write to smi_cmd to enable ACPI */ u8 acpi_disable; /* Value to write to smi_cmd to disable ACPI */ u8 S4bios_req; /* Value to write to SMI CMD to enter S4BIOS state */ - u8 reserved2; /* Reserved - must be zero */ + u8 reserved2; /* Reserved, must be zero */ u32 pm1a_evt_blk; /* Port address of Power Mgt 1a acpi_event Reg Blk */ u32 pm1b_evt_blk; /* Port address of Power Mgt 1b acpi_event Reg Blk */ u32 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ @@ -104,7 +108,7 @@ struct fadt_descriptor_rev1 u8 gpe0_blk_len; /* Byte Length of ports at gpe0_blk */ u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ u8 gpe1_base; /* Offset in gpe model where gpe1 events start */ - u8 reserved3; /* Reserved */ + u8 reserved3; /* Reserved, must be zero */ u16 plvl2_lat; /* Worst case HW latency to enter/exit C2 state */ u16 plvl3_lat; /* Worst case HW latency to enter/exit C3 state */ u16 flush_size; /* Size of area read to flush caches */ @@ -114,19 +118,21 @@ struct fadt_descriptor_rev1 u8 day_alrm; /* Index to day-of-month alarm in RTC CMOS RAM */ u8 mon_alrm; /* Index to month-of-year alarm in RTC CMOS RAM */ u8 century; /* Index to century in RTC CMOS RAM */ - u8 reserved4; /* Reserved */ - u8 reserved4a; /* Reserved */ - u8 reserved4b; /* Reserved */ - u32 wb_invd : 1; /* The wbinvd instruction works properly */ - u32 wb_invd_flush : 1; /* The wbinvd flushes but does not invalidate */ - u32 proc_c1 : 1; /* All processors support C1 state */ - u32 plvl2_up : 1; /* C2 state works on MP system */ - u32 pwr_button : 1; /* Power button is handled as a generic feature */ - u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ - u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ - u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ - u32 tmr_val_ext : 1; /* The tmr_val width is 32 bits (0 = 24 bits) */ - u32 reserved5 : 23; /* Reserved - must be zero */ + u8 reserved4[3]; /* Reserved, must be zero */ + + /* Flags (32 bits) */ + + u8 wb_invd : 1; /* 00: The wbinvd instruction works properly */ + u8 wb_invd_flush : 1; /* 01: The wbinvd flushes but does not invalidate */ + u8 proc_c1 : 1; /* 02: All processors support C1 state */ + u8 plvl2_up : 1; /* 03: C2 state works on MP system */ + u8 pwr_button : 1; /* 04: Power button is handled as a generic feature */ + u8 sleep_button : 1; /* 05: Sleep button is handled as a generic feature, or not present */ + u8 fixed_rTC : 1; /* 06: RTC wakeup stat not in fixed register space */ + u8 rtcs4 : 1; /* 07: RTC wakeup stat not possible from S4 */ + u8 tmr_val_ext : 1; /* 08: tmr_val width is 32 bits (0 = 24 bits) */ + u8 : 7; /* 09-15: Reserved, must be zero */ + u8 reserved5[2]; /* 16-31: Reserved, must be zero */ }; #pragma pack() diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index e1729c9..84ce5ab 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -73,8 +73,7 @@ struct rsdt_descriptor_rev2 { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - u32 table_offset_entry [1]; /* Array of pointers to */ - /* ACPI table headers */ + u32 table_offset_entry[1]; /* Array of pointers to ACPI tables */ }; @@ -84,8 +83,7 @@ struct rsdt_descriptor_rev2 struct xsdt_descriptor_rev2 { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - u64 table_offset_entry [1]; /* Array of pointers to */ - /* ACPI table headers */ + u64 table_offset_entry[1]; /* Array of pointers to ACPI tables */ }; @@ -94,16 +92,21 @@ struct xsdt_descriptor_rev2 */ struct facs_descriptor_rev2 { - char signature[4]; /* ACPI signature */ + char signature[4]; /* ASCII table signature */ u32 length; /* Length of structure, in bytes */ u32 hardware_signature; /* Hardware configuration signature */ - u32 firmware_waking_vector; /* 32bit physical address of the Firmware Waking Vector. */ + u32 firmware_waking_vector; /* 32-bit physical address of the Firmware Waking Vector. */ u32 global_lock; /* Global Lock used to synchronize access to shared hardware resources */ - u32 S4bios_f : 1; /* S4Bios_f - Indicates if S4BIOS support is present */ - u32 reserved1 : 31; /* Must be 0 */ - u64 xfirmware_waking_vector; /* 64bit physical address of the Firmware Waking Vector. */ + + /* Flags (32 bits) */ + + u8 S4bios_f : 1; /* 00: S4BIOS support is present */ + u8 : 7; /* 01-07: Reserved, must be zero */ + u8 reserved1[3]; /* 08-31: Reserved, must be zero */ + + u64 xfirmware_waking_vector; /* 64-bit physical address of the Firmware Waking Vector. */ u8 version; /* Version of this table */ - u8 reserved3 [31]; /* Reserved - must be zero */ + u8 reserved3[31]; /* Reserved, must be zero */ }; @@ -165,35 +168,37 @@ struct fadt_descriptor_rev2 { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ FADT_REV2_COMMON - u8 reserved2; /* Reserved */ - u32 wb_invd : 1; /* The wbinvd instruction works properly */ - u32 wb_invd_flush : 1; /* The wbinvd flushes but does not invalidate */ - u32 proc_c1 : 1; /* All processors support C1 state */ - u32 plvl2_up : 1; /* C2 state works on MP system */ - u32 pwr_button : 1; /* Power button is handled as a generic feature */ - u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ - u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ - u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ - u32 tmr_val_ext : 1; /* Indicates tmr_val is 32 bits 0=24-bits */ - u32 dock_cap : 1; /* Supports Docking */ - u32 reset_reg_sup : 1; /* Indicates system supports system reset via the FADT RESET_REG */ - u32 sealed_case : 1; /* Indicates system has no internal expansion capabilities and case is sealed */ - u32 headless : 1; /* Indicates system does not have local video capabilities or local input devices */ - u32 cpu_sw_sleep : 1; /* Indicates to OSPM that a processor native instruction */ - /* must be executed after writing the SLP_TYPx register */ - /* ACPI 3.0 flag bits */ - - u32 pci_exp_wak : 1; /* System supports PCIEXP_WAKE (STS/EN) bits */ - u32 use_platform_clock : 1; /* OSPM should use platform-provided timer */ - u32 S4rtc_sts_valid : 1; /* Contents of RTC_STS valid after S4 wake */ - u32 remote_power_on_capable : 1; /* System is compatible with remote power on */ - u32 force_apic_cluster_model : 1; /* All local APICs must use cluster model */ - u32 force_apic_physical_destination_mode : 1; /* all local x_aPICs must use physical dest mode */ - u32 reserved6 : 12;/* Reserved - must be zero */ + u8 reserved2; /* Reserved, must be zero */ + + /* Flags (32 bits) */ + + u8 wb_invd : 1; /* 00: The wbinvd instruction works properly */ + u8 wb_invd_flush : 1; /* 01: The wbinvd flushes but does not invalidate */ + u8 proc_c1 : 1; /* 02: All processors support C1 state */ + u8 plvl2_up : 1; /* 03: C2 state works on MP system */ + u8 pwr_button : 1; /* 04: Power button is handled as a generic feature */ + u8 sleep_button : 1; /* 05: Sleep button is handled as a generic feature, or not present */ + u8 fixed_rTC : 1; /* 06: RTC wakeup stat not in fixed register space */ + u8 rtcs4 : 1; /* 07: RTC wakeup stat not possible from S4 */ + u8 tmr_val_ext : 1; /* 08: tmr_val is 32 bits 0=24-bits */ + u8 dock_cap : 1; /* 09: Docking supported */ + u8 reset_reg_sup : 1; /* 10: System reset via the FADT RESET_REG supported */ + u8 sealed_case : 1; /* 11: No internal expansion capabilities and case is sealed */ + u8 headless : 1; /* 12: No local video capabilities or local input devices */ + u8 cpu_sw_sleep : 1; /* 13: Must execute native instruction after writing SLP_TYPx register */ + + u8 pci_exp_wak : 1; /* 14: System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */ + u8 use_platform_clock : 1; /* 15: OSPM should use platform-provided timer (ACPI 3.0) */ + u8 S4rtc_sts_valid : 1; /* 16: Contents of RTC_STS valid after S4 wake (ACPI 3.0) */ + u8 remote_power_on_capable : 1; /* 17: System is compatible with remote power on (ACPI 3.0) */ + u8 force_apic_cluster_model : 1; /* 18: All local APICs must use cluster model (ACPI 3.0) */ + u8 force_apic_physical_destination_mode : 1; /* 19: all local x_aPICs must use physical dest mode (ACPI 3.0) */ + u8 : 4; /* 20-23: Reserved, must be zero */ + u8 reserved3; /* 24-31: Reserved, must be zero */ struct acpi_generic_address reset_register; /* Reset register address in GAS format */ u8 reset_value; /* Value to write to the reset_register port to reset the system */ - u8 reserved7[3]; /* These three bytes must be zero */ + u8 reserved4[3]; /* These three bytes must be zero */ u64 xfirmware_ctrl; /* 64-bit physical address of FACS */ u64 Xdsdt; /* 64-bit physical address of DSDT */ struct acpi_generic_address xpm1a_evt_blk; /* Extended Power Mgt 1a acpi_event Reg Blk address */ @@ -213,11 +218,11 @@ struct fadt_descriptor_rev2_minus { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ FADT_REV2_COMMON - u8 reserved2; /* Reserved */ + u8 reserved2; /* Reserved, must be zero */ u32 flags; struct acpi_generic_address reset_register; /* Reset register address in GAS format */ u8 reset_value; /* Value to write to the reset_register port to reset the system. */ - u8 reserved7[3]; /* These three bytes must be zero */ + u8 reserved7[3]; /* Reserved, must be zero */ }; @@ -242,11 +247,16 @@ struct static_resource_alloc u8 length; u8 proximity_domain_lo; u8 apic_id; - u32 enabled :1; - u32 reserved3 :31; + + /* Flags (32 bits) */ + + u8 enabled :1; /* 00: Use affinity structure */ + u8 :7; /* 01-07: Reserved, must be zero */ + u8 reserved3[3]; /* 08-31: Reserved, must be zero */ + u8 local_sapic_eid; u8 proximity_domain_hi[3]; - u32 reserved4; + u32 reserved4; /* Reserved, must be zero */ }; struct memory_affinity @@ -258,18 +268,23 @@ struct memory_affinity u64 base_address; u64 address_length; u32 reserved4; - u32 enabled :1; - u32 hot_pluggable :1; - u32 non_volatile :1; - u32 reserved5 :29; - u64 reserved6; + + /* Flags (32 bits) */ + + u8 enabled :1; /* 00: Use affinity structure */ + u8 hot_pluggable :1; /* 01: Memory region is hot pluggable */ + u8 non_volatile :1; /* 02: Memory is non-volatile */ + u8 :5; /* 03-07: Reserved, must be zero */ + u8 reserved5[3]; /* 08-31: Reserved, must be zero */ + + u64 reserved6; /* Reserved, must be zero */ }; struct system_resource_affinity { ACPI_TABLE_HEADER_DEF u32 reserved1; /* Must be value '1' */ - u64 reserved2; + u64 reserved2; /* Reserved, must be zero */ }; diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 8cd774a2..1895b86 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -205,10 +205,11 @@ typedef u32 acpi_size; /* - * Miscellaneous common types + * This type is used for bitfields in ACPI tables. The only type that is + * even remotely portable is u8. Anything else is not portable, so + * do not add any more bitfield types. */ -typedef u16 UINT16_BIT; -typedef u32 UINT32_BIT; +typedef u8 UINT8_BIT; typedef acpi_native_uint ACPI_PTRDIFF; /* @@ -243,10 +244,13 @@ struct acpi_pointer #define ACPI_LOGMODE_PHYSPTR ACPI_LOGICAL_ADDRESSING | ACPI_PHYSICAL_POINTER #define ACPI_LOGMODE_LOGPTR ACPI_LOGICAL_ADDRESSING | ACPI_LOGICAL_POINTER -/* Types for the OS interface layer (OSL) */ - -#ifdef ACPI_USE_LOCAL_CACHE -#define acpi_cache_t struct acpi_memory_list +/* + * If acpi_cache_t was not defined in the OS-dependent header, + * define it now. This is typically the case where the local cache + * manager implementation is to be used (ACPI_USE_LOCAL_CACHE) + */ +#ifndef acpi_cache_t +#define acpi_cache_t struct acpi_memory_list #endif /* diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h index e9c1584d..9c05c10e 100644 --- a/include/acpi/acutils.h +++ b/include/acpi/acutils.h @@ -120,10 +120,6 @@ u8 acpi_ut_valid_object_type ( acpi_object_type type); -acpi_owner_id -acpi_ut_allocate_owner_id ( - u32 id_type); - /* * utinit - miscellaneous initialization and shutdown @@ -306,47 +302,63 @@ acpi_ut_track_stack_ptr ( void acpi_ut_trace ( u32 line_number, - struct acpi_debug_print_info *dbg_info); + char *function_name, + char *module_name, + u32 component_id); void acpi_ut_trace_ptr ( u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, void *pointer); void acpi_ut_trace_u32 ( u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, u32 integer); void acpi_ut_trace_str ( u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, char *string); void acpi_ut_exit ( u32 line_number, - struct acpi_debug_print_info *dbg_info); + char *function_name, + char *module_name, + u32 component_id); void acpi_ut_status_exit ( u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, acpi_status status); void acpi_ut_value_exit ( u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, acpi_integer value); void acpi_ut_ptr_exit ( u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, u8 *ptr); void @@ -378,7 +390,9 @@ void ACPI_INTERNAL_VAR_XFACE acpi_ut_debug_print ( u32 requested_debug_level, u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, char *format, ...) ACPI_PRINTF_LIKE_FUNC; @@ -386,7 +400,9 @@ void ACPI_INTERNAL_VAR_XFACE acpi_ut_debug_print_raw ( u32 requested_debug_level, u32 line_number, - struct acpi_debug_print_info *dbg_info, + char *function_name, + char *module_name, + u32 component_id, char *format, ...) ACPI_PRINTF_LIKE_FUNC; @@ -477,8 +493,8 @@ acpi_ut_allocate_object_desc_dbg ( u32 line_number, u32 component_id); -#define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_THIS_MODULE,__LINE__,_COMPONENT,t) -#define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_THIS_MODULE,__LINE__,_COMPONENT) +#define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_acpi_module_name,__LINE__,_COMPONENT,t) +#define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_acpi_module_name,__LINE__,_COMPONENT) void acpi_ut_delete_object_desc ( @@ -579,6 +595,14 @@ acpi_ut_short_divide ( * utmisc */ acpi_status +acpi_ut_allocate_owner_id ( + acpi_owner_id *owner_id); + +acpi_status +acpi_ut_release_owner_id ( + acpi_owner_id owner_id); + +acpi_status acpi_ut_walk_package_tree ( union acpi_operand_object *source_object, void *target_object, diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h index 91fda36..3926412 100644 --- a/include/acpi/platform/acgcc.h +++ b/include/acpi/platform/acgcc.h @@ -44,13 +44,17 @@ #ifndef __ACGCC_H__ #define __ACGCC_H__ +/* Function name is used for debug output. Non-ANSI, compiler-dependent */ + +#define ACPI_GET_FUNCTION_NAME __FUNCTION__ + /* This macro is used to tag functions as "printf-like" because * some compilers (like GCC) can catch printf format string problems. */ -#define ACPI_PRINTF_LIKE_FUNC __attribute__ ((__format__ (__printf__, 4, 5))) +#define ACPI_PRINTF_LIKE_FUNC __attribute__ ((__format__ (__printf__, 6, 7))) /* Some compilers complain about unused variables. Sometimes we don't want to - * use all the variables (most specifically for _THIS_MODULE). This allow us + * use all the variables (for example, _acpi_module_name). This allows us * to to tell the compiler warning in a per-variable manner that a variable * is unused. */ -- cgit v0.10.2 From feee9570753645f9f6888937ff9aee426b7afe55 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Fri, 29 Jul 2005 00:01:00 -0400 Subject: [ACPI] comment out prototypes for new unused debug routines Signed-off-by: Len Brown diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index 6158f51..fd13cc3 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c @@ -78,7 +78,6 @@ static void acpi_ex_out_address ( char *title, acpi_physical_address value); -#endif /* ACPI_FUTURE_USAGE */ static void acpi_ex_dump_reference ( @@ -89,7 +88,7 @@ acpi_ex_dump_package ( union acpi_operand_object *obj_desc, u32 level, u32 index); - +#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * -- cgit v0.10.2 From 5d75ab45594c78d2d976a3248ea1ca281c9d7056 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Fri, 29 Jul 2005 00:03:55 -0400 Subject: [ACPI] handle const char * __FUNCTION__ in debug code build warning: discards qualifiers from pointer target type when mixing "const char *" and "char *" We should probably update the routines to expect const, but easier for now to shut up the warning with 1 cast. Signed-off-by: Len Brown diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h index 3926412..e410e3b 100644 --- a/include/acpi/platform/acgcc.h +++ b/include/acpi/platform/acgcc.h @@ -46,7 +46,7 @@ /* Function name is used for debug output. Non-ANSI, compiler-dependent */ -#define ACPI_GET_FUNCTION_NAME __FUNCTION__ +#define ACPI_GET_FUNCTION_NAME (char *) __FUNCTION__ /* This macro is used to tag functions as "printf-like" because * some compilers (like GCC) can catch printf format string problems. -- cgit v0.10.2 From 670fac79b9dcf16549a4c1f4c0b73c457e53bd7e Mon Sep 17 00:00:00 2001 From: Len Brown Date: Fri, 29 Jul 2005 00:16:54 -0400 Subject: [ACPI] disable module level AML code (for now) It is important that we support module level code -- BIOS's implement it. But this implementation needs more testing. Signed-off-by: Len Brown diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c index 095672a..edf8aa5f 100644 --- a/drivers/acpi/parser/psloop.c +++ b/drivers/acpi/parser/psloop.c @@ -410,6 +410,8 @@ acpi_ps_parse_loop ( /* Special processing for certain opcodes */ +#define ACPI_NO_MODULE_LEVEL_CODE + /* TBD (remove): Temporary mechanism to disable this code if needed */ #ifndef ACPI_NO_MODULE_LEVEL_CODE -- cgit v0.10.2 From c2c2e03409f5f5405e79d9d9156202b75cb5b35b Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 17 Jul 2005 02:06:00 -0400 Subject: [ACPI] update hotkey documentation http://bugzilla.kernel.org/show_bug.cgi?id=4903 Signed-off-by: Iacopo Spalletti Signed-off-by: Len Brown diff --git a/Documentation/acpi-hotkey.txt b/Documentation/acpi-hotkey.txt index 4c115a7..d57b02a 100644 --- a/Documentation/acpi-hotkey.txt +++ b/Documentation/acpi-hotkey.txt @@ -33,3 +33,6 @@ The result of the execution of this aml method is attached to /proc/acpi/hotkey/poll_method, which is dnyamically created. Please use command "cat /proc/acpi/hotkey/polling_method" to retrieve it. + +Note: Use cmdline "acpi_specific_hotkey" to enable legacy platform +specific drivers. -- cgit v0.10.2 From 0c9938cc75057c0fca1af55a55dcfc2842436695 Mon Sep 17 00:00:00 2001 From: Robert Moore Date: Fri, 29 Jul 2005 15:15:00 -0700 Subject: [ACPI] ACPICA 20050729 from Bob Moore Implemented support to ignore an attempt to install/load a particular ACPI table more than once. Apparently there exists BIOS code that repeatedly attempts to load the same SSDT upon certain events. Thanks to Venkatesh Pallipadi. Restructured the main interface to the AML parser in order to correctly handle all exceptional conditions. This will prevent leakage of the OwnerId resource and should eliminate the AE_OWNER_ID_LIMIT exceptions seen on some machines. Thanks to Alexey Starikovskiy. Support for "module level code" has been disabled in this version due to a number of issues that have appeared on various machines. The support can be enabled by defining ACPI_ENABLE_MODULE_LEVEL_CODE during subsystem compilation. When the issues are fully resolved, the code will be enabled by default again. Modified the internal functions for debug print support to define the FunctionName parameter as a (const char *) for compatibility with compiler built-in macros such as __FUNCTION__, etc. Linted the entire ACPICA source tree for both 32-bit and 64-bit. Signed-off-by: Robert Moore Signed-off-by: Len Brown diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c index ebc07aa..bcd1d47 100644 --- a/drivers/acpi/dispatcher/dsinit.c +++ b/drivers/acpi/dispatcher/dsinit.c @@ -86,20 +86,20 @@ acpi_ds_init_one_object ( void *context, void **return_value) { + struct acpi_init_walk_info *info = (struct acpi_init_walk_info *) context; + struct acpi_namespace_node *node = (struct acpi_namespace_node *) obj_handle; acpi_object_type type; acpi_status status; - struct acpi_init_walk_info *info = (struct acpi_init_walk_info *) context; ACPI_FUNCTION_NAME ("ds_init_one_object"); /* - * We are only interested in objects owned by the table that + * We are only interested in NS nodes owned by the table that * was just loaded */ - if (((struct acpi_namespace_node *) obj_handle)->owner_id != - info->table_desc->owner_id) { + if (node->owner_id != info->table_desc->owner_id) { return (AE_OK); } @@ -126,8 +126,6 @@ acpi_ds_init_one_object ( case ACPI_TYPE_METHOD: - info->method_count++; - /* * Print a dot for each method unless we are going to print * the entire pathname @@ -143,7 +141,7 @@ acpi_ds_init_one_object ( * on a per-table basis. Currently, we just use a global for the width. */ if (info->table_desc->pointer->revision == 1) { - ((struct acpi_namespace_node *) obj_handle)->flags |= ANOBJ_DATA_WIDTH_32; + node->flags |= ANOBJ_DATA_WIDTH_32; } /* @@ -153,22 +151,14 @@ acpi_ds_init_one_object ( status = acpi_ds_parse_method (obj_handle); if (ACPI_FAILURE (status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Method %p [%4.4s] - parse failure, %s\n", + "\n+Method %p [%4.4s] - parse failure, %s\n", obj_handle, acpi_ut_get_node_name (obj_handle), acpi_format_exception (status))); /* This parse failed, but we will continue parsing more methods */ - - break; } - /* - * Delete the parse tree. We simply re-parse the method - * for every execution since there isn't much overhead - */ - acpi_ns_delete_namespace_subtree (obj_handle); - acpi_ns_delete_namespace_by_owner ( - ((struct acpi_namespace_node *) obj_handle)->object->method.owner_id); + info->method_count++; break; diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 1b90813..e344c06 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c @@ -58,12 +58,11 @@ * * FUNCTION: acpi_ds_parse_method * - * PARAMETERS: obj_handle - Method node + * PARAMETERS: Node - Method node * * RETURN: Status * - * DESCRIPTION: Call the parser and parse the AML that is associated with the - * method. + * DESCRIPTION: Parse the AML that is associated with the method. * * MUTEX: Assumes parser is locked * @@ -71,30 +70,28 @@ acpi_status acpi_ds_parse_method ( - acpi_handle obj_handle) + struct acpi_namespace_node *node) { acpi_status status; union acpi_operand_object *obj_desc; union acpi_parse_object *op; - struct acpi_namespace_node *node; struct acpi_walk_state *walk_state; - ACPI_FUNCTION_TRACE_PTR ("ds_parse_method", obj_handle); + ACPI_FUNCTION_TRACE_PTR ("ds_parse_method", node); /* Parameter Validation */ - if (!obj_handle) { + if (!node) { return_ACPI_STATUS (AE_NULL_ENTRY); } ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Parsing [%4.4s] **** named_obj=%p\n", - acpi_ut_get_node_name (obj_handle), obj_handle)); + acpi_ut_get_node_name (node), node)); /* Extract the method object from the method Node */ - node = (struct acpi_namespace_node *) obj_handle; obj_desc = acpi_ns_get_attached_object (node); if (!obj_desc) { return_ACPI_STATUS (AE_NULL_OBJECT); @@ -169,10 +166,18 @@ acpi_ds_parse_method ( ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n", - acpi_ut_get_node_name (obj_handle), obj_handle, op)); + acpi_ut_get_node_name (node), node, op)); + + /* + * Delete the parse tree. We simply re-parse the method for every + * execution since there isn't much overhead (compared to keeping lots + * of parse trees around) + */ + acpi_ns_delete_namespace_subtree (node); + acpi_ns_delete_namespace_by_owner (obj_desc->method.owner_id); cleanup2: - (void) acpi_ut_release_owner_id (obj_desc->method.owner_id); + acpi_ut_release_owner_id (&obj_desc->method.owner_id); cleanup: acpi_ps_delete_parse_tree (op); @@ -391,7 +396,7 @@ acpi_ds_call_control_method ( /* On error, we must delete the new walk state */ cleanup: - (void) acpi_ut_release_owner_id (obj_desc->method.owner_id); + acpi_ut_release_owner_id (&obj_desc->method.owner_id); if (next_walk_state && (next_walk_state->method_desc)) { /* Decrement the thread count on the method parse tree */ @@ -563,8 +568,7 @@ acpi_ds_terminate_control_method ( */ if ((walk_state->method_desc->method.concurrency == 1) && (!walk_state->method_desc->method.semaphore)) { - status = acpi_os_create_semaphore (1, - 1, + status = acpi_os_create_semaphore (1, 1, &walk_state->method_desc->method.semaphore); } @@ -595,6 +599,8 @@ acpi_ds_terminate_control_method ( */ acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owner_id); status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + acpi_ut_release_owner_id (&walk_state->method_desc->method.owner_id); + if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c index d360d8e..5621665 100644 --- a/drivers/acpi/dispatcher/dswstate.c +++ b/drivers/acpi/dispatcher/dswstate.c @@ -744,7 +744,7 @@ acpi_ds_init_aml_walk ( u8 *aml_start, u32 aml_length, struct acpi_parameter_info *info, - u32 pass_number) + u8 pass_number) { acpi_status status; struct acpi_parse_state *parser_state = &walk_state->parser_state; @@ -762,7 +762,7 @@ acpi_ds_init_aml_walk ( /* The next_op of the next_walk will be the beginning of the method */ walk_state->next_op = NULL; - walk_state->pass_number = (u8) pass_number; + walk_state->pass_number = pass_number; if (info) { if (info->parameter_type == ACPI_PARAM_GPE) { diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c index 38d7ab8..3df3ada 100644 --- a/drivers/acpi/events/evmisc.c +++ b/drivers/acpi/events/evmisc.c @@ -411,6 +411,9 @@ acpi_ev_init_global_lock_handler ( * with an error. */ if (status == AE_NO_HARDWARE_RESPONSE) { + ACPI_REPORT_ERROR (( + "No response from Global Lock hardware, disabling lock\n")); + acpi_gbl_global_lock_present = FALSE; status = AE_OK; } diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c index 76c6ebd0..d11e9ec 100644 --- a/drivers/acpi/executer/exconfig.c +++ b/drivers/acpi/executer/exconfig.c @@ -99,6 +99,11 @@ acpi_ex_add_table ( return_ACPI_STATUS (AE_NO_MEMORY); } + /* Init the table handle */ + + obj_desc->reference.opcode = AML_LOAD_OP; + *ddb_handle = obj_desc; + /* Install the new table into the local data structures */ ACPI_MEMSET (&table_info, 0, sizeof (struct acpi_table_desc)); @@ -109,7 +114,14 @@ acpi_ex_add_table ( table_info.allocation = ACPI_MEM_ALLOCATED; status = acpi_tb_install_table (&table_info); + obj_desc->reference.object = table_info.installed_desc; + if (ACPI_FAILURE (status)) { + if (status == AE_ALREADY_EXISTS) { + /* Table already exists, just return the handle */ + + return_ACPI_STATUS (AE_OK); + } goto cleanup; } @@ -123,16 +135,12 @@ acpi_ex_add_table ( goto cleanup; } - /* Init the table handle */ - - obj_desc->reference.opcode = AML_LOAD_OP; - obj_desc->reference.object = table_info.installed_desc; - *ddb_handle = obj_desc; return_ACPI_STATUS (AE_OK); cleanup: acpi_ut_remove_reference (obj_desc); + *ddb_handle = NULL; return_ACPI_STATUS (status); } @@ -488,6 +496,7 @@ acpi_ex_unload_table ( * (Offset contains the table_id) */ acpi_ns_delete_namespace_by_owner (table_info->owner_id); + acpi_ut_release_owner_id (&table_info->owner_id); /* Delete the table itself */ diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index fd13cc3..4f98dce 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c @@ -598,7 +598,7 @@ acpi_ex_dump_reference ( acpi_os_printf ("Could not convert name to pathname\n"); } else { - acpi_os_printf ("%s\n", ret_buf.pointer); + acpi_os_printf ("%s\n", (char *) ret_buf.pointer); ACPI_MEM_FREE (ret_buf.pointer); } } diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c index c1ba8b4..48c30f8 100644 --- a/drivers/acpi/executer/exoparg1.c +++ b/drivers/acpi/executer/exoparg1.c @@ -955,7 +955,7 @@ acpi_ex_opcode_1A_0T_1R ( */ return_desc = *(operand[0]->reference.where); if (return_desc) { - acpi_ut_add_reference (return_desc); + acpi_ut_add_reference (return_desc); } break; diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c index 0bda88d..7589e1f 100644 --- a/drivers/acpi/namespace/nsaccess.c +++ b/drivers/acpi/namespace/nsaccess.c @@ -159,19 +159,20 @@ acpi_ns_root_initialize ( obj_desc->method.param_count = (u8) ACPI_TO_INTEGER (val); obj_desc->common.flags |= AOPOBJ_DATA_VALID; -#if defined (ACPI_ASL_COMPILER) || defined (ACPI_DUMP_App) +#if defined (ACPI_ASL_COMPILER) - /* - * i_aSL Compiler cheats by putting parameter count - * in the owner_iD (param_count max is 7) - */ - new_node->owner_id = obj_desc->method.param_count; + /* save the parameter count for the i_aSL compiler */ + + new_node->value = obj_desc->method.param_count; #else /* Mark this as a very SPECIAL method */ obj_desc->method.method_flags = AML_METHOD_INTERNAL_ONLY; + +#ifndef ACPI_DUMP_APP obj_desc->method.implementation = acpi_ut_osi_implementation; #endif +#endif break; case ACPI_TYPE_INTEGER: diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c index edbf1db..21d560d 100644 --- a/drivers/acpi/namespace/nsalloc.c +++ b/drivers/acpi/namespace/nsalloc.c @@ -176,10 +176,9 @@ acpi_ns_delete_node ( * DESCRIPTION: Initialize a new namespace node and install it amongst * its peers. * - * Note: Current namespace lookup is linear search. However, the - * nodes are linked in alphabetical order to 1) put all reserved - * names (start with underscore) first, and to 2) make a readable - * namespace dump. + * Note: Current namespace lookup is linear search. This appears + * to be sufficient as namespace searches consume only a small + * fraction of the execution time of the ACPI subsystem. * ******************************************************************************/ @@ -192,10 +191,6 @@ acpi_ns_install_node ( { acpi_owner_id owner_id = 0; struct acpi_namespace_node *child_node; -#ifdef ACPI_ALPHABETIC_NAMESPACE - - struct acpi_namespace_node *previous_child_node; -#endif ACPI_FUNCTION_TRACE ("ns_install_node"); @@ -219,57 +214,6 @@ acpi_ns_install_node ( node->peer = parent_node; } else { -#ifdef ACPI_ALPHABETIC_NAMESPACE - /* - * Walk the list whilst searching for the correct - * alphabetic placement. - */ - previous_child_node = NULL; - while (acpi_ns_compare_names (acpi_ut_get_node_name (child_node), - acpi_ut_get_node_name (node)) < 0) { - if (child_node->flags & ANOBJ_END_OF_PEER_LIST) { - /* Last peer; Clear end-of-list flag */ - - child_node->flags &= ~ANOBJ_END_OF_PEER_LIST; - - /* This node is the new peer to the child node */ - - child_node->peer = node; - - /* This node is the new end-of-list */ - - node->flags |= ANOBJ_END_OF_PEER_LIST; - node->peer = parent_node; - break; - } - - /* Get next peer */ - - previous_child_node = child_node; - child_node = child_node->peer; - } - - /* Did the node get inserted at the end-of-list? */ - - if (!(node->flags & ANOBJ_END_OF_PEER_LIST)) { - /* - * Loop above terminated without reaching the end-of-list. - * Insert the new node at the current location - */ - if (previous_child_node) { - /* Insert node alphabetically */ - - node->peer = child_node; - previous_child_node->peer = node; - } - else { - /* Insert node alphabetically at start of list */ - - node->peer = child_node; - parent_node->child = node; - } - } -#else while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) { child_node = child_node->peer; } @@ -279,9 +223,8 @@ acpi_ns_install_node ( /* Clear end-of-list flag */ child_node->flags &= ~ANOBJ_END_OF_PEER_LIST; - node->flags |= ANOBJ_END_OF_PEER_LIST; + node->flags |= ANOBJ_END_OF_PEER_LIST; node->peer = parent_node; -#endif } /* Init the new entry */ @@ -570,6 +513,10 @@ acpi_ns_delete_namespace_by_owner ( ACPI_FUNCTION_TRACE_U32 ("ns_delete_namespace_by_owner", owner_id); + if (owner_id == 0) { + return_VOID; + } + parent_node = acpi_gbl_root_node; child_node = NULL; deletion_node = NULL; @@ -635,59 +582,7 @@ acpi_ns_delete_namespace_by_owner ( } } - (void) acpi_ut_release_owner_id (owner_id); return_VOID; } -#ifdef ACPI_ALPHABETIC_NAMESPACE -/******************************************************************************* - * - * FUNCTION: acpi_ns_compare_names - * - * PARAMETERS: Name1 - First name to compare - * Name2 - Second name to compare - * - * RETURN: value from strncmp - * - * DESCRIPTION: Compare two ACPI names. Names that are prefixed with an - * underscore are forced to be alphabetically first. - * - ******************************************************************************/ - -int -acpi_ns_compare_names ( - char *name1, - char *name2) -{ - char reversed_name1[ACPI_NAME_SIZE]; - char reversed_name2[ACPI_NAME_SIZE]; - u32 i; - u32 j; - - - /* - * Replace all instances of "underscore" with a value that is smaller so - * that all names that are prefixed with underscore(s) are alphabetically - * first. - * - * Reverse the name bytewise so we can just do a 32-bit compare instead - * of a strncmp. - */ - for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) { - reversed_name1[j] = name1[i]; - if (name1[i] == '_') { - reversed_name1[j] = '*'; - } - - reversed_name2[j] = name2[i]; - if (name2[i] == '_') { - reversed_name2[j] = '*'; - } - } - - return (*(int *) reversed_name1 - *(int *) reversed_name2); -} -#endif - - diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c index d86ccbc..5d25add 100644 --- a/drivers/acpi/namespace/nsdump.c +++ b/drivers/acpi/namespace/nsdump.c @@ -85,6 +85,9 @@ acpi_ns_print_pathname ( u32 num_segments, char *pathname) { + acpi_native_uint i; + + ACPI_FUNCTION_NAME ("ns_print_pathname"); @@ -97,9 +100,13 @@ acpi_ns_print_pathname ( ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[")); while (num_segments) { - acpi_os_printf ("%4.4s", pathname); - pathname += ACPI_NAME_SIZE; + for (i = 0; i < 4; i++) { + ACPI_IS_PRINT (pathname[i]) ? + acpi_os_printf ("%c", pathname[i]) : + acpi_os_printf ("?"); + } + pathname += ACPI_NAME_SIZE; num_segments--; if (num_segments) { acpi_os_printf ("."); diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c index 1ae89a1..908cffd 100644 --- a/drivers/acpi/namespace/nseval.c +++ b/drivers/acpi/namespace/nseval.c @@ -365,6 +365,7 @@ acpi_ns_evaluate_by_handle ( * * PARAMETERS: Info - Method info block, contains: * Node - Method Node to execute + * obj_desc - Method object * Parameters - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. @@ -387,7 +388,6 @@ acpi_ns_execute_control_method ( struct acpi_parameter_info *info) { acpi_status status; - union acpi_operand_object *obj_desc; ACPI_FUNCTION_TRACE ("ns_execute_control_method"); @@ -395,8 +395,8 @@ acpi_ns_execute_control_method ( /* Verify that there is a method associated with this object */ - obj_desc = acpi_ns_get_attached_object (info->node); - if (!obj_desc) { + info->obj_desc = acpi_ns_get_attached_object (info->node); + if (!info->obj_desc) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n")); (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); @@ -407,7 +407,7 @@ acpi_ns_execute_control_method ( ACPI_LV_INFO, _COMPONENT); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n", - obj_desc->method.aml_start + 1, obj_desc->method.aml_length - 1)); + info->obj_desc->method.aml_start + 1, info->obj_desc->method.aml_length - 1)); /* * Unlock the namespace before execution. This allows namespace access @@ -430,7 +430,7 @@ acpi_ns_execute_control_method ( return_ACPI_STATUS (status); } - status = acpi_psx_execute (info); + status = acpi_ps_execute_method (info); acpi_ex_exit_interpreter (); return_ACPI_STATUS (status); diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c index 34e4970..1428a84 100644 --- a/drivers/acpi/namespace/nsload.c +++ b/drivers/acpi/namespace/nsload.c @@ -198,7 +198,7 @@ acpi_ns_load_table_by_type ( switch (table_type) { case ACPI_TABLE_DSDT: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading DSDT\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace load: DSDT\n")); table_desc = acpi_gbl_table_lists[ACPI_TABLE_DSDT].next; @@ -218,17 +218,18 @@ acpi_ns_load_table_by_type ( case ACPI_TABLE_SSDT: + case ACPI_TABLE_PSDT: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d SSDTs\n", - acpi_gbl_table_lists[ACPI_TABLE_SSDT].count)); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace load: %d SSDT or PSDTs\n", + acpi_gbl_table_lists[table_type].count)); /* - * Traverse list of SSDT tables + * Traverse list of SSDT or PSDT tables */ - table_desc = acpi_gbl_table_lists[ACPI_TABLE_SSDT].next; - for (i = 0; i < acpi_gbl_table_lists[ACPI_TABLE_SSDT].count; i++) { + table_desc = acpi_gbl_table_lists[table_type].next; + for (i = 0; i < acpi_gbl_table_lists[table_type].count; i++) { /* - * Only attempt to load table if it is not + * Only attempt to load table into namespace if it is not * already loaded! */ if (!table_desc->loaded_into_namespace) { @@ -245,33 +246,6 @@ acpi_ns_load_table_by_type ( break; - case ACPI_TABLE_PSDT: - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d PSDTs\n", - acpi_gbl_table_lists[ACPI_TABLE_PSDT].count)); - - /* - * Traverse list of PSDT tables - */ - table_desc = acpi_gbl_table_lists[ACPI_TABLE_PSDT].next; - - for (i = 0; i < acpi_gbl_table_lists[ACPI_TABLE_PSDT].count; i++) { - /* Only attempt to load table if it is not already loaded! */ - - if (!table_desc->loaded_into_namespace) { - status = acpi_ns_load_table (table_desc, acpi_gbl_root_node); - if (ACPI_FAILURE (status)) { - break; - } - - table_desc->loaded_into_namespace = TRUE; - } - - table_desc = table_desc->next; - } - break; - - default: status = AE_SUPPORT; break; diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c index 64e0b2b..24bed93 100644 --- a/drivers/acpi/namespace/nsparse.c +++ b/drivers/acpi/namespace/nsparse.c @@ -67,7 +67,7 @@ acpi_status acpi_ns_one_complete_parse ( - u32 pass_number, + u8 pass_number, struct acpi_table_desc *table_desc) { union acpi_parse_object *parse_root; diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c index edf8aa5f..551d54b 100644 --- a/drivers/acpi/parser/psloop.c +++ b/drivers/acpi/parser/psloop.c @@ -55,8 +55,6 @@ #include #include #include -#include -#include #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psloop") @@ -410,11 +408,9 @@ acpi_ps_parse_loop ( /* Special processing for certain opcodes */ -#define ACPI_NO_MODULE_LEVEL_CODE - /* TBD (remove): Temporary mechanism to disable this code if needed */ -#ifndef ACPI_NO_MODULE_LEVEL_CODE +#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) && ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) { @@ -431,6 +427,9 @@ acpi_ps_parse_loop ( case AML_ELSE_OP: case AML_WHILE_OP: + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Pass1: Skipping an If/Else/While body\n")); + /* Skip body of if/else/while in pass 1 */ parser_state->aml = parser_state->pkg_end; diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c index 19a2702..4221b41 100644 --- a/drivers/acpi/parser/psutils.c +++ b/drivers/acpi/parser/psutils.c @@ -200,10 +200,10 @@ acpi_ps_free_op ( } if (op->common.flags & ACPI_PARSEOP_GENERIC) { - acpi_os_release_object (acpi_gbl_ps_node_cache, op); + (void) acpi_os_release_object (acpi_gbl_ps_node_cache, op); } else { - acpi_os_release_object (acpi_gbl_ps_node_ext_cache, op); + (void) acpi_os_release_object (acpi_gbl_ps_node_ext_cache, op); } } diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c index 5279b51..d1541fa 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -46,19 +46,30 @@ #include #include #include -#include #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psxface") +/* Local Prototypes */ + +static acpi_status +acpi_ps_execute_pass ( + struct acpi_parameter_info *info); + +static void +acpi_ps_update_parameter_list ( + struct acpi_parameter_info *info, + u16 action); + /******************************************************************************* * - * FUNCTION: acpi_psx_execute + * FUNCTION: acpi_ps_execute_method * * PARAMETERS: Info - Method info block, contains: * Node - Method Node to execute + * obj_desc - Method object * Parameters - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. @@ -67,6 +78,7 @@ * parameter_type - Type of Parameter list * return_object - Where to put method's return value (if * any). If NULL, no value is returned. + * pass_number - Parse or execute pass * * RETURN: Status * @@ -75,174 +87,194 @@ ******************************************************************************/ acpi_status -acpi_psx_execute ( +acpi_ps_execute_method ( struct acpi_parameter_info *info) { acpi_status status; - union acpi_operand_object *obj_desc; - u32 i; - union acpi_parse_object *op; - struct acpi_walk_state *walk_state; - ACPI_FUNCTION_TRACE ("psx_execute"); + ACPI_FUNCTION_TRACE ("ps_execute_method"); - /* Validate the Node and get the attached object */ + /* Validate the Info and method Node */ if (!info || !info->node) { return_ACPI_STATUS (AE_NULL_ENTRY); } - obj_desc = acpi_ns_get_attached_object (info->node); - if (!obj_desc) { - return_ACPI_STATUS (AE_NULL_OBJECT); - } - /* Init for new method, wait on concurrency semaphore */ - status = acpi_ds_begin_method_execution (info->node, obj_desc, NULL); + status = acpi_ds_begin_method_execution (info->node, info->obj_desc, NULL); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } - if ((info->parameter_type == ACPI_PARAM_ARGS) && - (info->parameters)) { - /* - * The caller "owns" the parameters, so give each one an extra - * reference - */ - for (i = 0; info->parameters[i]; i++) { - acpi_ut_add_reference (info->parameters[i]); - } - } - - /* - * 1) Perform the first pass parse of the method to enter any - * named objects that it creates into the namespace - */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "**** Begin Method Parse **** Entry=%p obj=%p\n", - info->node, obj_desc)); - - /* Create and init a Root Node */ - - op = acpi_ps_create_scope_op (); - if (!op) { - status = AE_NO_MEMORY; - goto cleanup1; - } - /* * Get a new owner_id for objects created by this method. Namespace * objects (such as Operation Regions) can be created during the * first pass parse. */ - status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); + status = acpi_ut_allocate_owner_id (&info->obj_desc->method.owner_id); if (ACPI_FAILURE (status)) { - goto cleanup2; - } - - /* Create and initialize a new walk state */ - - walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, - NULL, NULL, NULL); - if (!walk_state) { - status = AE_NO_MEMORY; - goto cleanup2; + return_ACPI_STATUS (status); } - status = acpi_ds_init_aml_walk (walk_state, op, info->node, - obj_desc->method.aml_start, - obj_desc->method.aml_length, NULL, 1); - if (ACPI_FAILURE (status)) { - goto cleanup3; - } + /* + * The caller "owns" the parameters, so give each one an extra + * reference + */ + acpi_ps_update_parameter_list (info, REF_INCREMENT); - /* Parse the AML */ + /* + * 1) Perform the first pass parse of the method to enter any + * named objects that it creates into the namespace + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "**** Begin Method Parse **** Entry=%p obj=%p\n", + info->node, info->obj_desc)); - status = acpi_ps_parse_aml (walk_state); - acpi_ps_delete_parse_tree (op); + info->pass_number = 1; + status = acpi_ps_execute_pass (info); if (ACPI_FAILURE (status)) { - goto cleanup1; /* Walk state is already deleted */ + goto cleanup; } /* - * 2) Execute the method. Performs second pass parse simultaneously + * 2) Execute the method. Performs second pass parse simultaneously */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Begin Method Execution **** Entry=%p obj=%p\n", - info->node, obj_desc)); + info->node, info->obj_desc)); - /* Create and init a Root Node */ + info->pass_number = 3; + status = acpi_ps_execute_pass (info); - op = acpi_ps_create_scope_op (); - if (!op) { - status = AE_NO_MEMORY; - goto cleanup1; + +cleanup: + if (info->obj_desc->method.owner_id) { + acpi_ut_release_owner_id (&info->obj_desc->method.owner_id); } - /* Init new op with the method name and pointer back to the NS node */ + /* Take away the extra reference that we gave the parameters above */ - acpi_ps_set_name (op, info->node->name.integer); - op->common.node = info->node; + acpi_ps_update_parameter_list (info, REF_DECREMENT); - /* Create and initialize a new walk state */ + /* Exit now if error above */ - walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); - if (!walk_state) { - status = AE_NO_MEMORY; - goto cleanup2; + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); } - status = acpi_ds_init_aml_walk (walk_state, op, info->node, - obj_desc->method.aml_start, - obj_desc->method.aml_length, info, 3); - if (ACPI_FAILURE (status)) { - goto cleanup3; + /* + * If the method has returned an object, signal this to the caller with + * a control exception code + */ + if (info->return_object) { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned obj_desc=%p\n", + info->return_object)); + ACPI_DUMP_STACK_ENTRY (info->return_object); + + status = AE_CTRL_RETURN_VALUE; } - /* The walk of the parse tree is where we actually execute the method */ + return_ACPI_STATUS (status); +} - status = acpi_ps_parse_aml (walk_state); - goto cleanup2; /* Walk state already deleted */ +/******************************************************************************* + * + * FUNCTION: acpi_ps_update_parameter_list + * + * PARAMETERS: Info - See struct acpi_parameter_info + * (Used: parameter_type and Parameters) + * Action - Add or Remove reference + * + * RETURN: Status + * + * DESCRIPTION: Update reference count on all method parameter objects + * + ******************************************************************************/ -cleanup3: - acpi_ds_delete_walk_state (walk_state); +static void +acpi_ps_update_parameter_list ( + struct acpi_parameter_info *info, + u16 action) +{ + acpi_native_uint i; -cleanup2: - acpi_ps_delete_parse_tree (op); -cleanup1: if ((info->parameter_type == ACPI_PARAM_ARGS) && (info->parameters)) { - /* Take away the extra reference that we gave the parameters above */ + /* Update reference count for each parameter */ for (i = 0; info->parameters[i]; i++) { /* Ignore errors, just do them all */ - (void) acpi_ut_update_object_reference ( - info->parameters[i], REF_DECREMENT); + (void) acpi_ut_update_object_reference (info->parameters[i], action); } } +} - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + +/******************************************************************************* + * + * FUNCTION: acpi_ps_execute_pass + * + * PARAMETERS: Info - See struct acpi_parameter_info + * (Used: pass_number, Node, and obj_desc) + * + * RETURN: Status + * + * DESCRIPTION: Single AML pass: Parse or Execute a control method + * + ******************************************************************************/ + +static acpi_status +acpi_ps_execute_pass ( + struct acpi_parameter_info *info) +{ + acpi_status status; + union acpi_parse_object *op; + struct acpi_walk_state *walk_state; + + + ACPI_FUNCTION_TRACE ("ps_execute_pass"); + + + /* Create and init a Root Node */ + + op = acpi_ps_create_scope_op (); + if (!op) { + return_ACPI_STATUS (AE_NO_MEMORY); } - /* - * If the method has returned an object, signal this to the caller with - * a control exception code - */ - if (info->return_object) { - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned obj_desc=%p\n", - info->return_object)); - ACPI_DUMP_STACK_ENTRY (info->return_object); + /* Create and initialize a new walk state */ - status = AE_CTRL_RETURN_VALUE; + walk_state = acpi_ds_create_walk_state ( + info->obj_desc->method.owner_id, NULL, NULL, NULL); + if (!walk_state) { + status = AE_NO_MEMORY; + goto cleanup; + } + + status = acpi_ds_init_aml_walk (walk_state, op, info->node, + info->obj_desc->method.aml_start, + info->obj_desc->method.aml_length, + info->pass_number == 1 ? NULL : info, + info->pass_number); + if (ACPI_FAILURE (status)) { + acpi_ds_delete_walk_state (walk_state); + goto cleanup; } + /* Parse the AML */ + + status = acpi_ps_parse_aml (walk_state); + + /* Walk state was deleted by parse_aml */ + +cleanup: + acpi_ps_delete_parse_tree (op); return_ACPI_STATUS (status); } diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c index 2ad72f2..6987999 100644 --- a/drivers/acpi/tables/tbinstal.c +++ b/drivers/acpi/tables/tbinstal.c @@ -124,9 +124,7 @@ acpi_tb_match_signature ( * * RETURN: Status * - * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must - * already be loaded and validated. - * Install the table into the global data structs. + * DESCRIPTION: Install the table into the global data structures. * ******************************************************************************/ @@ -136,6 +134,7 @@ acpi_tb_install_table ( { acpi_status status; + ACPI_FUNCTION_TRACE ("tb_install_table"); @@ -143,22 +142,33 @@ acpi_tb_install_table ( status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES); if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not acquire table mutex for [%4.4s], %s\n", - table_info->pointer->signature, acpi_format_exception (status))); + ACPI_REPORT_ERROR (("Could not acquire table mutex, %s\n", + acpi_format_exception (status))); return_ACPI_STATUS (status); } + /* + * Ignore a table that is already installed. For example, some BIOS + * ASL code will repeatedly attempt to load the same SSDT. + */ + status = acpi_tb_is_table_installed (table_info); + if (ACPI_FAILURE (status)) { + goto unlock_and_exit; + } + /* Install the table into the global data structure */ status = acpi_tb_init_table_descriptor (table_info->type, table_info); if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not install ACPI table [%4.4s], %s\n", + ACPI_REPORT_ERROR (("Could not install table [%4.4s], %s\n", table_info->pointer->signature, acpi_format_exception (status))); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n", acpi_gbl_table_data[table_info->type].name, table_info->pointer)); + +unlock_and_exit: (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); return_ACPI_STATUS (status); } diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index e69d01d..6fc1e36 100644 --- a/drivers/acpi/tables/tbutils.c +++ b/drivers/acpi/tables/tbutils.c @@ -61,6 +61,67 @@ acpi_tb_handle_to_object ( /******************************************************************************* * + * FUNCTION: acpi_tb_is_table_installed + * + * PARAMETERS: new_table_desc - Descriptor for new table being installed + * + * RETURN: Status - AE_ALREADY_EXISTS if the table is already installed + * + * DESCRIPTION: Determine if an ACPI table is already installed + * + * MUTEX: Table data structures should be locked + * + ******************************************************************************/ + +acpi_status +acpi_tb_is_table_installed ( + struct acpi_table_desc *new_table_desc) +{ + struct acpi_table_desc *table_desc; + + + ACPI_FUNCTION_TRACE ("tb_is_table_installed"); + + + /* Get the list descriptor and first table descriptor */ + + table_desc = acpi_gbl_table_lists[new_table_desc->type].next; + + /* Examine all installed tables of this type */ + + while (table_desc) { + /* Compare Revision and oem_table_id */ + + if ((table_desc->loaded_into_namespace) && + (table_desc->pointer->revision == + new_table_desc->pointer->revision) && + (!ACPI_MEMCMP (table_desc->pointer->oem_table_id, + new_table_desc->pointer->oem_table_id, 8))) { + /* This table is already installed */ + + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, + "Table [%4.4s] already installed: Rev %X oem_table_id [%8.8s]\n", + new_table_desc->pointer->signature, + new_table_desc->pointer->revision, + new_table_desc->pointer->oem_table_id)); + + new_table_desc->owner_id = table_desc->owner_id; + new_table_desc->installed_desc = table_desc; + + return_ACPI_STATUS (AE_ALREADY_EXISTS); + } + + /* Get next table on the list */ + + table_desc = table_desc->next; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: acpi_tb_validate_table_header * * PARAMETERS: table_header - Logical pointer to the table @@ -157,7 +218,7 @@ acpi_tb_verify_table_checksum ( /* Compute the checksum on the table */ - checksum = acpi_tb_checksum (table_header, table_header->length); + checksum = acpi_tb_generate_checksum (table_header, table_header->length); /* Return the appropriate exception */ @@ -175,7 +236,7 @@ acpi_tb_verify_table_checksum ( /******************************************************************************* * - * FUNCTION: acpi_tb_checksum + * FUNCTION: acpi_tb_generate_checksum * * PARAMETERS: Buffer - Buffer to checksum * Length - Size of the buffer @@ -187,7 +248,7 @@ acpi_tb_verify_table_checksum ( ******************************************************************************/ u8 -acpi_tb_checksum ( +acpi_tb_generate_checksum ( void *buffer, u32 length) { diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c index ca2dbdd..e18a05d 100644 --- a/drivers/acpi/tables/tbxface.c +++ b/drivers/acpi/tables/tbxface.c @@ -182,10 +182,23 @@ acpi_load_table ( return_ACPI_STATUS (status); } + /* Check signature for a valid table type */ + + status = acpi_tb_recognize_table (&table_info, ACPI_TABLE_ALL); + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); + } + /* Install the new table into the local data structures */ status = acpi_tb_install_table (&table_info); if (ACPI_FAILURE (status)) { + if (status == AE_ALREADY_EXISTS) { + /* Table already exists, no error */ + + status = AE_OK; + } + /* Free table allocated by acpi_tb_get_table_body */ acpi_tb_delete_single_table (&table_info); @@ -261,6 +274,7 @@ acpi_unload_table ( * simply a position within the hierarchy */ acpi_ns_delete_namespace_by_owner (table_desc->owner_id); + acpi_ut_release_owner_id (&table_desc->owner_id); table_desc = table_desc->next; } diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c index abb4c93..87dccdd 100644 --- a/drivers/acpi/tables/tbxfroot.c +++ b/drivers/acpi/tables/tbxfroot.c @@ -93,14 +93,14 @@ acpi_tb_validate_rsdp ( /* Check the standard checksum */ - if (acpi_tb_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { + if (acpi_tb_generate_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { return (AE_BAD_CHECKSUM); } /* Check extended checksum if table version >= 2 */ if ((rsdp->revision >= 2) && - (acpi_tb_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) { + (acpi_tb_generate_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) { return (AE_BAD_CHECKSUM); } diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index 5061c6f..78270f5 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c @@ -76,7 +76,7 @@ static acpi_status acpi_ut_create_list ( char *list_name, u16 object_size, - acpi_handle *return_cache); + struct acpi_memory_list **return_cache); #endif @@ -428,7 +428,7 @@ static acpi_status acpi_ut_create_list ( char *list_name, u16 object_size, - acpi_handle *return_cache) + struct acpi_memory_list **return_cache) { struct acpi_memory_list *cache; diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c index 3d5fbc8..c27cbb7 100644 --- a/drivers/acpi/utilities/utdebug.c +++ b/drivers/acpi/utilities/utdebug.c @@ -55,6 +55,12 @@ static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF; static char *acpi_gbl_fn_entry_str = "----Entry"; static char *acpi_gbl_fn_exit_str = "----Exit-"; +/* Local prototypes */ + +static const char * +acpi_ut_trim_function_name ( + const char *function_name); + /******************************************************************************* * @@ -72,7 +78,7 @@ void acpi_ut_init_stack_ptr_trace ( void) { - u32 current_sp; + u32 current_sp; acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF (¤t_sp, NULL); @@ -95,7 +101,7 @@ void acpi_ut_track_stack_ptr ( void) { - acpi_size current_sp; + acpi_size current_sp; current_sp = ACPI_PTR_DIFF (¤t_sp, NULL); @@ -112,6 +118,43 @@ acpi_ut_track_stack_ptr ( /******************************************************************************* * + * FUNCTION: acpi_ut_trim_function_name + * + * PARAMETERS: function_name - Ascii string containing a procedure name + * + * RETURN: Updated pointer to the function name + * + * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. + * This allows compiler macros such as __FUNCTION__ to be used + * with no change to the debug output. + * + ******************************************************************************/ + +static const char * +acpi_ut_trim_function_name ( + const char *function_name) +{ + + /* All Function names are longer than 4 chars, check is safe */ + + if (*(ACPI_CAST_PTR (u32, function_name)) == ACPI_FUNCTION_PREFIX1) { + /* This is the case where the original source has not been modified */ + + return (function_name + 4); + } + + if (*(ACPI_CAST_PTR (u32, function_name)) == ACPI_FUNCTION_PREFIX2) { + /* This is the case where the source has been 'linuxized' */ + + return (function_name + 5); + } + + return (function_name); +} + + +/******************************************************************************* + * * FUNCTION: acpi_ut_debug_print * * PARAMETERS: requested_debug_level - Requested debug print level @@ -133,7 +176,7 @@ void ACPI_INTERNAL_VAR_XFACE acpi_ut_debug_print ( u32 requested_debug_level, u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, char *format, @@ -177,7 +220,7 @@ acpi_ut_debug_print ( } acpi_os_printf ("[%02ld] %-22.22s: ", - acpi_gbl_nesting_level, function_name); + acpi_gbl_nesting_level, acpi_ut_trim_function_name (function_name)); va_start (args, format); acpi_os_vprintf (format, args); @@ -208,7 +251,7 @@ void ACPI_INTERNAL_VAR_XFACE acpi_ut_debug_print_raw ( u32 requested_debug_level, u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, char *format, @@ -247,7 +290,7 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw); void acpi_ut_trace ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id) { @@ -282,7 +325,7 @@ EXPORT_SYMBOL(acpi_ut_trace); void acpi_ut_trace_ptr ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, void *pointer) @@ -316,7 +359,7 @@ acpi_ut_trace_ptr ( void acpi_ut_trace_str ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, char *string) @@ -351,7 +394,7 @@ acpi_ut_trace_str ( void acpi_ut_trace_u32 ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, u32 integer) @@ -385,7 +428,7 @@ acpi_ut_trace_u32 ( void acpi_ut_exit ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id) { @@ -419,7 +462,7 @@ EXPORT_SYMBOL(acpi_ut_exit); void acpi_ut_status_exit ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, acpi_status status) @@ -463,7 +506,7 @@ EXPORT_SYMBOL(acpi_ut_status_exit); void acpi_ut_value_exit ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, acpi_integer value) @@ -499,7 +542,7 @@ EXPORT_SYMBOL(acpi_ut_value_exit); void acpi_ut_ptr_exit ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, u8 *ptr) @@ -607,8 +650,8 @@ acpi_ut_dump_buffer ( } /* - * Print the ASCII equivalent characters - * But watch out for the bad unprintable ones... + * Print the ASCII equivalent characters but watch out for the bad + * unprintable ones (printable chars are 0x20 through 0x7E) */ acpi_os_printf (" "); for (j = 0; j < 16; j++) { @@ -618,9 +661,7 @@ acpi_ut_dump_buffer ( } buf_char = buffer[i + j]; - if ((buf_char > 0x1F && buf_char < 0x2E) || - (buf_char > 0x2F && buf_char < 0x61) || - (buf_char > 0x60 && buf_char < 0x7F)) { + if (ACPI_IS_PRINT (buf_char)) { acpi_os_printf ("%c", buf_char); } else { diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index df715cd..1d350b3 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -56,7 +56,11 @@ * * PARAMETERS: owner_id - Where the new owner ID is returned * - * DESCRIPTION: Allocate a table or method owner id + * RETURN: Status + * + * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to + * track objects created by the table or method, to be deleted + * when the method exits or the table is unloaded. * ******************************************************************************/ @@ -71,6 +75,8 @@ acpi_ut_allocate_owner_id ( ACPI_FUNCTION_TRACE ("ut_allocate_owner_id"); + /* Mutex for the global ID mask */ + status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); @@ -81,7 +87,7 @@ acpi_ut_allocate_owner_id ( for (i = 0; i < 32; i++) { if (!(acpi_gbl_owner_id_mask & (1 << i))) { acpi_gbl_owner_id_mask |= (1 << i); - *owner_id = (acpi_owner_id) i; + *owner_id = (acpi_owner_id) (i + 1); goto exit; } } @@ -93,6 +99,7 @@ acpi_ut_allocate_owner_id ( * they are released when a table is unloaded or a method completes * execution. */ + *owner_id = 0; status = AE_OWNER_ID_LIMIT; ACPI_REPORT_ERROR (( "Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); @@ -107,40 +114,55 @@ exit: * * FUNCTION: acpi_ut_release_owner_id * - * PARAMETERS: owner_id - A previously allocated owner ID + * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_iD * - * DESCRIPTION: Release a table or method owner id + * RETURN: None. No error is returned because we are either exiting a + * control method or unloading a table. Either way, we would + * ignore any error anyway. + * + * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 32 * ******************************************************************************/ -acpi_status +void acpi_ut_release_owner_id ( - acpi_owner_id owner_id) + acpi_owner_id *owner_id_ptr) { + acpi_owner_id owner_id = *owner_id_ptr; acpi_status status; ACPI_FUNCTION_TRACE ("ut_release_owner_id"); + /* Always clear the input owner_id (zero is an invalid ID) */ + + *owner_id_ptr = 0; + + /* Zero is not a valid owner_iD */ + + if ((owner_id == 0) || (owner_id > 32)) { + ACPI_REPORT_ERROR (("Invalid owner_id: %2.2X\n", owner_id)); + return_VOID; + } + + /* Mutex for the global ID mask */ + status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + return_VOID; } - /* Free the owner ID */ + owner_id--; /* Normalize to zero */ + + /* Free the owner ID only if it is valid */ if (acpi_gbl_owner_id_mask & (1 << owner_id)) { acpi_gbl_owner_id_mask ^= (1 << owner_id); } - else { - /* This owner_id has not been allocated */ - - status = AE_NOT_EXIST; - } (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); - return_ACPI_STATUS (status); + return_VOID; } @@ -150,7 +172,7 @@ acpi_ut_release_owner_id ( * * PARAMETERS: src_string - The source string to convert * - * RETURN: Converted src_string (same as input pointer) + * RETURN: None * * DESCRIPTION: Convert string to uppercase * @@ -158,7 +180,7 @@ acpi_ut_release_owner_id ( * ******************************************************************************/ -char * +void acpi_ut_strupr ( char *src_string) { @@ -169,7 +191,7 @@ acpi_ut_strupr ( if (!src_string) { - return (NULL); + return; } /* Walk entire string, uppercasing the letters */ @@ -178,7 +200,7 @@ acpi_ut_strupr ( *string = (char) ACPI_TOUPPER (*string); } - return (src_string); + return; } diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index aa3c08c..d62af72 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -64,7 +64,7 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20050708 +#define ACPI_CA_VERSION 0x20050729 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h index fde6aa9..90b7d30 100644 --- a/include/acpi/acdispat.h +++ b/include/acpi/acdispat.h @@ -236,7 +236,7 @@ acpi_ds_method_data_init ( */ acpi_status acpi_ds_parse_method ( - acpi_handle obj_handle); + struct acpi_namespace_node *node); acpi_status acpi_ds_call_control_method ( @@ -391,7 +391,7 @@ acpi_ds_init_aml_walk ( u8 *aml_start, u32 aml_length, struct acpi_parameter_info *info, - u32 pass_number); + u8 pass_number); acpi_status acpi_ds_obj_stack_pop_and_delete ( diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index 5b100ce..fcdef0a 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h @@ -505,8 +505,10 @@ * The Name parameter should be the procedure name as a quoted string. * This is declared as a local string ("my_function_name") so that it can * be also used by the function exit macros below. + * Note: (const char) is used to be compatible with the debug interfaces + * and macros such as __FUNCTION__. */ -#define ACPI_FUNCTION_NAME(name) char *_acpi_function_name = name; +#define ACPI_FUNCTION_NAME(name) const char *_acpi_function_name = name; #else /* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h index deb7cb0..280e9ed 100644 --- a/include/acpi/acnames.h +++ b/include/acpi/acnames.h @@ -78,6 +78,11 @@ #define ACPI_NS_ROOT_PATH "\\" #define ACPI_NS_SYSTEM_BUS "_SB_" +/*! [Begin] no source code translation (not handled by acpisrc) */ +#define ACPI_FUNCTION_PREFIX1 'ipcA' +#define ACPI_FUNCTION_PREFIX2 'ipca' +/*! [End] no source code translation !*/ + #endif /* __ACNAMES_H__ */ diff --git a/include/acpi/acnamesp.h b/include/acpi/acnamesp.h index 870e254..0c9ba70 100644 --- a/include/acpi/acnamesp.h +++ b/include/acpi/acnamesp.h @@ -124,7 +124,7 @@ acpi_ns_parse_table ( acpi_status acpi_ns_one_complete_parse ( - u32 pass_number, + u8 pass_number, struct acpi_table_desc *table_desc); diff --git a/include/acpi/acparser.h b/include/acpi/acparser.h index ba9548f..f692ad5 100644 --- a/include/acpi/acparser.h +++ b/include/acpi/acparser.h @@ -77,12 +77,7 @@ * psxface - Parser external interfaces */ acpi_status -acpi_psx_load_table ( - u8 *pcode_addr, - u32 pcode_length); - -acpi_status -acpi_psx_execute ( +acpi_ps_execute_method ( struct acpi_parameter_info *info); diff --git a/include/acpi/acstruct.h b/include/acpi/acstruct.h index f375c17..27b22bb 100644 --- a/include/acpi/acstruct.h +++ b/include/acpi/acstruct.h @@ -153,6 +153,7 @@ struct acpi_device_walk_info struct acpi_walk_info { u32 debug_level; + u32 count; acpi_owner_id owner_id; u8 display_type; }; @@ -209,8 +210,10 @@ union acpi_aml_operands struct acpi_parameter_info { struct acpi_namespace_node *node; + union acpi_operand_object *obj_desc; union acpi_operand_object **parameters; union acpi_operand_object *return_object; + u8 pass_number; u8 parameter_type; u8 return_object_type; }; diff --git a/include/acpi/actables.h b/include/acpi/actables.h index 97e6f12..e6ceb18 100644 --- a/include/acpi/actables.h +++ b/include/acpi/actables.h @@ -178,11 +178,15 @@ acpi_tb_validate_rsdp ( * tbutils - common table utilities */ acpi_status +acpi_tb_is_table_installed ( + struct acpi_table_desc *new_table_desc); + +acpi_status acpi_tb_verify_table_checksum ( struct acpi_table_header *table_header); u8 -acpi_tb_checksum ( +acpi_tb_generate_checksum ( void *buffer, u32 length); diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h index 9c05c10e..0e7b0a3 100644 --- a/include/acpi/acutils.h +++ b/include/acpi/acutils.h @@ -302,14 +302,14 @@ acpi_ut_track_stack_ptr ( void acpi_ut_trace ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id); void acpi_ut_trace_ptr ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, void *pointer); @@ -317,7 +317,7 @@ acpi_ut_trace_ptr ( void acpi_ut_trace_u32 ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, u32 integer); @@ -325,7 +325,7 @@ acpi_ut_trace_u32 ( void acpi_ut_trace_str ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, char *string); @@ -333,14 +333,14 @@ acpi_ut_trace_str ( void acpi_ut_exit ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id); void acpi_ut_status_exit ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, acpi_status status); @@ -348,7 +348,7 @@ acpi_ut_status_exit ( void acpi_ut_value_exit ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, acpi_integer value); @@ -356,7 +356,7 @@ acpi_ut_value_exit ( void acpi_ut_ptr_exit ( u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, u8 *ptr); @@ -390,7 +390,7 @@ void ACPI_INTERNAL_VAR_XFACE acpi_ut_debug_print ( u32 requested_debug_level, u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, char *format, @@ -400,7 +400,7 @@ void ACPI_INTERNAL_VAR_XFACE acpi_ut_debug_print_raw ( u32 requested_debug_level, u32 line_number, - char *function_name, + const char *function_name, char *module_name, u32 component_id, char *format, @@ -598,9 +598,9 @@ acpi_status acpi_ut_allocate_owner_id ( acpi_owner_id *owner_id); -acpi_status +void acpi_ut_release_owner_id ( - acpi_owner_id owner_id); + acpi_owner_id *owner_id); acpi_status acpi_ut_walk_package_tree ( @@ -609,7 +609,7 @@ acpi_ut_walk_package_tree ( acpi_pkg_callback walk_callback, void *context); -char * +void acpi_ut_strupr ( char *src_string); diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index aa63202e..bae1fbe 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -241,15 +241,15 @@ #define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (acpi_size)(n)) #define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (acpi_size)(n)) -#define ACPI_TOUPPER toupper -#define ACPI_TOLOWER tolower -#define ACPI_IS_XDIGIT isxdigit -#define ACPI_IS_DIGIT isdigit -#define ACPI_IS_SPACE isspace -#define ACPI_IS_UPPER isupper -#define ACPI_IS_PRINT isprint -#define ACPI_IS_ALPHA isalpha -#define ACPI_IS_ASCII isascii +#define ACPI_TOUPPER(i) toupper((int) (i)) +#define ACPI_TOLOWER(i) tolower((int) (i)) +#define ACPI_IS_XDIGIT(i) isxdigit((int) (i)) +#define ACPI_IS_DIGIT(i) isdigit((int) (i)) +#define ACPI_IS_SPACE(i) isspace((int) (i)) +#define ACPI_IS_UPPER(i) isupper((int) (i)) +#define ACPI_IS_PRINT(i) isprint((int) (i)) +#define ACPI_IS_ALPHA(i) isalpha((int) (i)) +#define ACPI_IS_ASCII(i) isascii((int) (i)) #else diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h index e410e3b..3926412 100644 --- a/include/acpi/platform/acgcc.h +++ b/include/acpi/platform/acgcc.h @@ -46,7 +46,7 @@ /* Function name is used for debug output. Non-ANSI, compiler-dependent */ -#define ACPI_GET_FUNCTION_NAME (char *) __FUNCTION__ +#define ACPI_GET_FUNCTION_NAME __FUNCTION__ /* This macro is used to tag functions as "printf-like" because * some compilers (like GCC) can catch printf format string problems. -- cgit v0.10.2 From 1f3a6a15771ed70d3b2581663dcc6b9bc134baa5 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 28 Jul 2005 14:42:00 -0400 Subject: [ACPI] acpi_register_gsi() can return error Current acpi_register_gsi() function has no way to indicate errors to its callers even though acpi_register_gsi() can fail to register gsi because of some reasons (out of memory, lack of interrupt vectors, incorrect BIOS, and so on). As a result, caller of acpi_register_gsi() cannot handle the case that acpi_register_gsi() fails. I think failure of acpi_register_gsi() should be handled properly. This series of patches changes acpi_register_gsi() to return negative value on error, and also changes callers of acpi_register_gsi() to handle failure of acpi_register_gsi(). This patch changes the type of return value of acpi_register_gsi() from "unsigned int" to "int" to indicate an error. If acpi_register_gsi() fails to register gsi, it returns negative value. Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index 848bb97..364f4b7 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c @@ -457,7 +457,11 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) return 0; } -unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low) +/* + * success: return IRQ number (>=0) + * failure: return < 0 + */ +int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low) { unsigned int irq; unsigned int plat_gsi = gsi; diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index 1c118b72d..7513ff9 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c @@ -565,7 +565,11 @@ acpi_numa_arch_fixup (void) } #endif /* CONFIG_ACPI_NUMA */ -unsigned int +/* + * success: return IRQ number (>=0) + * failure: return < 0 + */ +int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low) { if (has_8259 && gsi < 16) diff --git a/include/linux/acpi.h b/include/linux/acpi.h index ca0cd24..9378bcd 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -432,7 +432,7 @@ static inline int acpi_boot_table_init(void) #endif /*!CONFIG_ACPI_BOOT*/ -unsigned int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low); +int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low); int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); /* -- cgit v0.10.2 From 349f0d5640c18db09a646f9da51a97f1da908660 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 28 Jul 2005 14:42:00 -0400 Subject: [ACPI] acpi_pci_enable_irq() now checks for acpi_register_gsi() errors Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index c536ccf..7ed4b2e 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c @@ -424,6 +424,7 @@ acpi_pci_irq_enable ( int edge_level = ACPI_LEVEL_SENSITIVE; int active_high_low = ACPI_ACTIVE_LOW; char *link = NULL; + int rc; ACPI_FUNCTION_TRACE("acpi_pci_irq_enable"); @@ -475,7 +476,13 @@ acpi_pci_irq_enable ( } } - dev->irq = acpi_register_gsi(irq, edge_level, active_high_low); + rc = acpi_register_gsi(irq, edge_level, active_high_low); + if (rc < 0) { + printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed " + "to register GSI\n", pci_name(dev), ('A' + pin)); + return_VALUE(rc); + } + dev->irq = rc; printk(KERN_INFO PREFIX "PCI Interrupt %s[%c] -> ", pci_name(dev), 'A' + pin); -- cgit v0.10.2 From a9bd53bc49ee8984633e57c1d9d45111c58e9457 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 28 Jul 2005 14:42:00 -0400 Subject: [ACPI] HPET driver now checks for acpi_register_gsi() errors Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index 5ec732e..a8d4c47 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -906,11 +906,15 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data) if (irqp->number_of_interrupts > 0) { hdp->hd_nirqs = irqp->number_of_interrupts; - for (i = 0; i < hdp->hd_nirqs; i++) - hdp->hd_irq[i] = + for (i = 0; i < hdp->hd_nirqs; i++) { + int rc = acpi_register_gsi(irqp->interrupts[i], irqp->edge_level, irqp->active_high_low); + if (rc < 0) + return AE_ERROR; + hdp->hd_irq[i] = rc; + } } } -- cgit v0.10.2 From 71df30f8e3e97fde573c41df063c2d66c1ad01b0 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 28 Jul 2005 14:42:00 -0400 Subject: [ACPI] PNPACPI driver now checks for acpi_register_gsi() errors Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 75575f6..1e296cb 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -81,7 +81,7 @@ pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, int irq) i++; if (i < PNP_MAX_IRQ) { res->irq_resource[i].flags = IORESOURCE_IRQ; //Also clears _UNSET flag - if (irq == -1) { + if (irq < 0) { res->irq_resource[i].flags |= IORESOURCE_DISABLED; return; } -- cgit v0.10.2 From 58e0276245f6c60119f0384e7eca576b08aa89e2 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 28 Jul 2005 14:42:00 -0400 Subject: [ACPI] 8250 driver now checks for acpi_register_gsi() errors Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/drivers/serial/8250_acpi.c b/drivers/serial/8250_acpi.c index 6b9ead2..a802bdc 100644 --- a/drivers/serial/8250_acpi.c +++ b/drivers/serial/8250_acpi.c @@ -47,18 +47,30 @@ static acpi_status acpi_serial_port(struct uart_port *port, static acpi_status acpi_serial_ext_irq(struct uart_port *port, struct acpi_resource_ext_irq *ext_irq) { - if (ext_irq->number_of_interrupts > 0) - port->irq = acpi_register_gsi(ext_irq->interrupts[0], + int rc; + + if (ext_irq->number_of_interrupts > 0) { + rc = acpi_register_gsi(ext_irq->interrupts[0], ext_irq->edge_level, ext_irq->active_high_low); + if (rc < 0) + return AE_ERROR; + port->irq = rc; + } return AE_OK; } static acpi_status acpi_serial_irq(struct uart_port *port, struct acpi_resource_irq *irq) { - if (irq->number_of_interrupts > 0) - port->irq = acpi_register_gsi(irq->interrupts[0], + int rc; + + if (irq->number_of_interrupts > 0) { + rc = acpi_register_gsi(irq->interrupts[0], irq->edge_level, irq->active_high_low); + if (rc < 0) + return AE_ERROR; + port->irq = rc; + } return AE_OK; } -- cgit v0.10.2 From 14454a1b3ff8d1d15fbe7cc77f27373777184ddf Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 28 Jul 2005 14:42:00 -0400 Subject: [ACPI] iosapic_register_intr() now returns error instead of panic error condition is passed along by acpi_register_gsi(). Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c index 88b0143..40afbfa 100644 --- a/arch/ia64/kernel/iosapic.c +++ b/arch/ia64/kernel/iosapic.c @@ -562,7 +562,7 @@ static inline int vector_is_shared (int vector) return (iosapic_intr_info[vector].count > 1); } -static void +static int register_intr (unsigned int gsi, int vector, unsigned char delivery, unsigned long polarity, unsigned long trigger) { @@ -577,7 +577,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery, index = find_iosapic(gsi); if (index < 0) { printk(KERN_WARNING "%s: No IOSAPIC for GSI %u\n", __FUNCTION__, gsi); - return; + return -ENODEV; } iosapic_address = iosapic_lists[index].addr; @@ -588,7 +588,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery, rte = iosapic_alloc_rte(); if (!rte) { printk(KERN_WARNING "%s: cannot allocate memory\n", __FUNCTION__); - return; + return -ENOMEM; } rte_index = gsi - gsi_base; @@ -603,7 +603,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery, struct iosapic_intr_info *info = &iosapic_intr_info[vector]; if (info->trigger != trigger || info->polarity != polarity) { printk (KERN_WARNING "%s: cannot override the interrupt\n", __FUNCTION__); - return; + return -EINVAL; } } @@ -623,6 +623,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery, __FUNCTION__, vector, idesc->handler->typename, irq_type->typename); idesc->handler = irq_type; } + return 0; } static unsigned int @@ -710,7 +711,7 @@ int iosapic_register_intr (unsigned int gsi, unsigned long polarity, unsigned long trigger) { - int vector, mask = 1; + int vector, mask = 1, err; unsigned int dest; unsigned long flags; struct iosapic_rte_info *rte; @@ -735,8 +736,11 @@ again: /* If vector is running out, we try to find a sharable vector */ vector = assign_irq_vector_nopanic(AUTO_ASSIGN); - if (vector < 0) + if (vector < 0) { vector = iosapic_find_sharable_vector(trigger, polarity); + if (vector < 0) + Return -ENOSPC; + } spin_lock_irqsave(&irq_descp(vector)->lock, flags); spin_lock(&iosapic_lock); @@ -750,8 +754,13 @@ again: } dest = get_target_cpu(gsi, vector); - register_intr(gsi, vector, IOSAPIC_LOWEST_PRIORITY, + err = register_intr(gsi, vector, IOSAPIC_LOWEST_PRIORITY, polarity, trigger); + if (err < 0) { + spin_unlock(&iosapic_lock); + spin_unlock_irqrestore(&irq_descp(vector)->lock, flags); + return err; + } /* * If the vector is shared and already unmasked for -- cgit v0.10.2 From 53de49f52e305e96143375d1741f15acff7bf34b Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 30 Jul 2005 04:18:00 -0400 Subject: [ACPI] CONFIG_ACPI=n build fix Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 9378bcd..bf96ae9 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -420,16 +420,6 @@ extern int sbf_port ; #define acpi_mp_config 0 -static inline int acpi_boot_init(void) -{ - return 0; -} - -static inline int acpi_boot_table_init(void) -{ - return 0; -} - #endif /*!CONFIG_ACPI_BOOT*/ int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low); @@ -536,5 +526,17 @@ static inline int acpi_get_pxm(acpi_handle handle) extern int pnpacpi_disabled; +#else /* CONFIG_ACPI */ + +static inline int acpi_boot_init(void) +{ + return 0; +} + +static inline int acpi_boot_table_init(void) +{ + return 0; +} + #endif /* CONFIG_ACPI */ #endif /*_LINUX_ACPI_H*/ -- cgit v0.10.2 From e92310a930462c6e1611f35453f57357c42bde14 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 30 Jul 2005 04:18:00 -0400 Subject: [ACPI] fix IA64 build warning Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/include/asm-ia64/acpi-ext.h b/include/asm-ia64/acpi-ext.h index 9271d74..56d2ddc 100644 --- a/include/asm-ia64/acpi-ext.h +++ b/include/asm-ia64/acpi-ext.h @@ -11,6 +11,7 @@ #define _ASM_IA64_ACPI_EXT_H #include +#include extern acpi_status hp_acpi_csr_space (acpi_handle, u64 *base, u64 *length); -- cgit v0.10.2 From 031ec77bf67e4bda994ef8ceba267be3295ffdb7 Mon Sep 17 00:00:00 2001 From: Karol Kozimor Date: Sat, 30 Jul 2005 04:18:00 -0400 Subject: [ACPI] acpi_remove_notify_handler() on video driver unload The video driver doesn't properly remove all the notify handlers on module unload. This has a side effect of subdevices failing to register on module reload, but sudden death looms if the handlers trigger after the module is unloaded. Signed-off-by: Karol Kozimor Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 2cf264f..7b10a7b 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1665,6 +1665,7 @@ static int acpi_video_bus_put_one_device( struct acpi_video_device *device) { + acpi_status status; struct acpi_video_bus *video; ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device"); @@ -1679,6 +1680,12 @@ acpi_video_bus_put_one_device( up(&video->sem); acpi_video_device_remove_fs(device->dev); + status = acpi_remove_notify_handler(device->handle, + ACPI_DEVICE_NOTIFY, acpi_video_device_notify); + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); + return_VALUE(0); } -- cgit v0.10.2 From 4fdcf0804598f44b0f48da9e5281af48a4db393f Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 30 Jul 2005 04:18:00 -0400 Subject: [ACPI] lint: irqrouter_suspend() takes a pm_message_t, not a u32 Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 0091dbd..a0df2f3 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -786,10 +786,7 @@ end: return_VALUE(result); } -static int -irqrouter_suspend( - struct sys_device *dev, - u32 state) +static int irqrouter_suspend(struct sys_device *dev, pm_message_t state) { struct list_head *node = NULL; struct acpi_pci_link *link = NULL; -- cgit v0.10.2 From cbfc1bae55bbd053308ef0fa6b6448cd1ddf3e67 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sat, 30 Jul 2005 04:18:00 -0400 Subject: [ACPI] ACPI_HOTPLUG_CPU Kconfig dependency update prevent: HOTPLUG_CPU=y ACPI_PROCESSOR=y ACPI_HOTPLUG_CPU=n Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 281a640..eded2e8 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -154,12 +154,10 @@ config ACPI_PROCESSOR support it. config ACPI_HOTPLUG_CPU - bool "Processor Hotplug (EXPERIMENTAL)" - depends on ACPI_PROCESSOR && HOTPLUG_CPU && EXPERIMENTAL + bool + depends on ACPI_PROCESSOR && HOTPLUG_CPU select ACPI_CONTAINER - default n - ---help--- - Select this option if your platform support physical CPU hotplug. + default y config ACPI_THERMAL tristate "Thermal Zone" -- cgit v0.10.2 From c65ade4dc8b486e8c8b9b0a6399789a5428e2039 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Fri, 5 Aug 2005 00:37:45 -0400 Subject: [ACPI] whitespace Signed-off-by: Pavel Machek Signed-off-by: Len Brown diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index 43c49f6..ce8d3ee 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c @@ -24,27 +24,23 @@ extern wait_queue_head_t acpi_bus_event_queue; static int acpi_system_open_event(struct inode *inode, struct file *file) { - spin_lock_irq (&acpi_system_event_lock); + spin_lock_irq(&acpi_system_event_lock); - if(event_is_open) + if (event_is_open) goto out_busy; event_is_open = 1; - spin_unlock_irq (&acpi_system_event_lock); + spin_unlock_irq(&acpi_system_event_lock); return 0; out_busy: - spin_unlock_irq (&acpi_system_event_lock); + spin_unlock_irq(&acpi_system_event_lock); return -EBUSY; } static ssize_t -acpi_system_read_event ( - struct file *file, - char __user *buffer, - size_t count, - loff_t *ppos) +acpi_system_read_event(struct file *file, char __user *buffer, size_t count, loff_t *ppos) { int result = 0; struct acpi_bus_event event; @@ -98,9 +94,7 @@ acpi_system_close_event(struct inode *inode, struct file *file) } static unsigned int -acpi_system_poll_event( - struct file *file, - poll_table *wait) +acpi_system_poll_event(struct file *file, poll_table *wait) { poll_wait(file, &acpi_bus_event_queue, wait); if (!list_empty(&acpi_bus_event_list)) diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index 14192ee..2ee1d06 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c @@ -37,11 +37,8 @@ #define ACPI_FAN_COMPONENT 0x00200000 #define ACPI_FAN_CLASS "fan" -#define ACPI_FAN_HID "PNP0C0B" #define ACPI_FAN_DRIVER_NAME "ACPI Fan Driver" -#define ACPI_FAN_DEVICE_NAME "Fan" #define ACPI_FAN_FILE_STATE "state" -#define ACPI_FAN_NOTIFY_STATUS 0x80 #define _COMPONENT ACPI_FAN_COMPONENT ACPI_MODULE_NAME ("acpi_fan") @@ -56,7 +53,7 @@ static int acpi_fan_remove (struct acpi_device *device, int type); static struct acpi_driver acpi_fan_driver = { .name = ACPI_FAN_DRIVER_NAME, .class = ACPI_FAN_CLASS, - .ids = ACPI_FAN_HID, + .ids = "PNP0C0B", .ops = { .add = acpi_fan_add, .remove = acpi_fan_remove, @@ -76,7 +73,7 @@ static struct proc_dir_entry *acpi_fan_dir; static int -acpi_fan_read_state (struct seq_file *seq, void *offset) +acpi_fan_read_state(struct seq_file *seq, void *offset) { struct acpi_fan *fan = seq->private; int state = 0; @@ -99,11 +96,8 @@ static int acpi_fan_state_open_fs(struct inode *inode, struct file *file) } static ssize_t -acpi_fan_write_state ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *ppos) +acpi_fan_write_state(struct file *file, const char __user *buffer, + size_t count, loff_t *ppos) { int result = 0; struct seq_file *m = (struct seq_file *)file->private_data; @@ -138,8 +132,7 @@ static struct file_operations acpi_fan_state_ops = { }; static int -acpi_fan_add_fs ( - struct acpi_device *device) +acpi_fan_add_fs(struct acpi_device *device) { struct proc_dir_entry *entry = NULL; @@ -174,8 +167,7 @@ acpi_fan_add_fs ( static int -acpi_fan_remove_fs ( - struct acpi_device *device) +acpi_fan_remove_fs(struct acpi_device *device) { ACPI_FUNCTION_TRACE("acpi_fan_remove_fs"); @@ -195,8 +187,7 @@ acpi_fan_remove_fs ( -------------------------------------------------------------------------- */ static int -acpi_fan_add ( - struct acpi_device *device) +acpi_fan_add(struct acpi_device *device) { int result = 0; struct acpi_fan *fan = NULL; @@ -213,7 +204,7 @@ acpi_fan_add ( memset(fan, 0, sizeof(struct acpi_fan)); fan->handle = device->handle; - strcpy(acpi_device_name(device), ACPI_FAN_DEVICE_NAME); + strcpy(acpi_device_name(device), "Fan"); strcpy(acpi_device_class(device), ACPI_FAN_CLASS); acpi_driver_data(device) = fan; @@ -241,11 +232,9 @@ end: static int -acpi_fan_remove ( - struct acpi_device *device, - int type) +acpi_fan_remove(struct acpi_device *device, int type) { - struct acpi_fan *fan = NULL; + struct acpi_fan *fan = NULL; ACPI_FUNCTION_TRACE("acpi_fan_remove"); @@ -263,9 +252,9 @@ acpi_fan_remove ( static int __init -acpi_fan_init (void) +acpi_fan_init(void) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_fan_init"); @@ -285,7 +274,7 @@ acpi_fan_init (void) static void __exit -acpi_fan_exit (void) +acpi_fan_exit(void) { ACPI_FUNCTION_TRACE("acpi_fan_exit"); diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 26aa382..e8334ce 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -529,8 +529,7 @@ acpi_irq_penalty_init(void) static int acpi_irq_balance; /* 0: static, 1: balance */ -static int acpi_pci_link_allocate( - struct acpi_pci_link *link) +static int acpi_pci_link_allocate(struct acpi_pci_link *link) { int irq; int i; @@ -718,8 +717,7 @@ acpi_pci_link_free_irq(acpi_handle handle) -------------------------------------------------------------------------- */ static int -acpi_pci_link_add ( - struct acpi_device *device) +acpi_pci_link_add(struct acpi_device *device) { int result = 0; struct acpi_pci_link *link = NULL; @@ -827,9 +825,7 @@ irqrouter_resume(struct sys_device *dev) static int -acpi_pci_link_remove ( - struct acpi_device *device, - int type) +acpi_pci_link_remove(struct acpi_device *device, int type) { struct acpi_pci_link *link = NULL; diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index 1be99f0..a962fc2 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c @@ -13,13 +13,6 @@ #include "sleep.h" -#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP -#define ACPI_SYSTEM_FILE_SLEEP "sleep" -#endif - -#define ACPI_SYSTEM_FILE_ALARM "alarm" -#define ACPI_SYSTEM_FILE_WAKEUP_DEVICE "wakeup" - #define _COMPONENT ACPI_SYSTEM_COMPONENT ACPI_MODULE_NAME ("sleep") @@ -378,14 +371,10 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) if (!dev->wakeup.flags.valid) continue; spin_unlock(&acpi_device_lock); - if (dev->wakeup.flags.run_wake) - seq_printf(seq, "%4s %4d %8s\n", - dev->pnp.bus_id, (u32) dev->wakeup.sleep_state, - dev->wakeup.state.enabled ? "*enabled" : "*disabled"); - else - seq_printf(seq, "%4s %4d %8s\n", - dev->pnp.bus_id, (u32) dev->wakeup.sleep_state, - dev->wakeup.state.enabled ? "enabled" : "disabled"); + seq_printf(seq, "%4s %4d %s%8s\n", + dev->pnp.bus_id, (u32) dev->wakeup.sleep_state, + dev->wakeup.flags.run_wake ? "*" : "", + dev->wakeup.state.enabled ? "enabled" : "disabled"); spin_lock(&acpi_device_lock); } spin_unlock(&acpi_device_lock); @@ -486,28 +475,25 @@ static u32 rtc_handler(void * context) static int acpi_sleep_proc_init(void) { - struct proc_dir_entry *entry = NULL; + struct proc_dir_entry *entry = NULL; if (acpi_disabled) return 0; #ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP - /* 'sleep' [R/W]*/ - entry = create_proc_entry(ACPI_SYSTEM_FILE_SLEEP, - S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); + /* 'sleep' [R/W] */ + entry = create_proc_entry("sleep", S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); if (entry) entry->proc_fops = &acpi_system_sleep_fops; #endif /* 'alarm' [R/W] */ - entry = create_proc_entry(ACPI_SYSTEM_FILE_ALARM, - S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); + entry = create_proc_entry("alarm", S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); if (entry) entry->proc_fops = &acpi_system_alarm_fops; - /* 'wakeup device' [R/W]*/ - entry = create_proc_entry(ACPI_SYSTEM_FILE_WAKEUP_DEVICE, - S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); + /* 'wakeup device' [R/W] */ + entry = create_proc_entry("wakeup", S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); if (entry) entry->proc_fops = &acpi_system_wakeup_device_fops; -- cgit v0.10.2 From 4be44fcd3bf648b782f4460fd06dfae6c42ded4b Mon Sep 17 00:00:00 2001 From: Len Brown Date: Fri, 5 Aug 2005 00:44:28 -0400 Subject: [ACPI] Lindent all ACPI files Signed-off-by: Len Brown diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index 55c0fbd..98d119c 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c @@ -40,19 +40,25 @@ #ifdef CONFIG_X86_64 -static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id) { } +static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id) +{ +} extern void __init clustered_apic_check(void); -static inline int ioapic_setup_disabled(void) { return 0; } +static inline int ioapic_setup_disabled(void) +{ + return 0; +} + #include -#else /* X86 */ +#else /* X86 */ #ifdef CONFIG_X86_LOCAL_APIC #include #include -#endif /* CONFIG_X86_LOCAL_APIC */ +#endif /* CONFIG_X86_LOCAL_APIC */ -#endif /* X86 */ +#endif /* X86 */ #define BAD_MADT_ENTRY(entry, end) ( \ (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ @@ -62,7 +68,7 @@ static inline int ioapic_setup_disabled(void) { return 0; } #ifdef CONFIG_ACPI_PCI int acpi_noirq __initdata; /* skip ACPI IRQ initialization */ -int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */ +int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */ #else int acpi_noirq __initdata = 1; int acpi_pci_disabled __initdata = 1; @@ -88,7 +94,7 @@ static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; #define MAX_MADT_ENTRIES 256 u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] = - { [0 ... MAX_MADT_ENTRIES-1] = 0xff }; + {[0...MAX_MADT_ENTRIES - 1] = 0xff }; EXPORT_SYMBOL(x86_acpiid_to_apicid); /* -------------------------------------------------------------------------- @@ -99,7 +105,7 @@ EXPORT_SYMBOL(x86_acpiid_to_apicid); * The default interrupt routing model is PIC (8259). This gets * overriden if IOAPICs are enumerated (below). */ -enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC; +enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC; #ifdef CONFIG_X86_64 @@ -107,7 +113,7 @@ enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC; char *__acpi_map_table(unsigned long phys_addr, unsigned long size) { if (!phys_addr || !size) - return NULL; + return NULL; if (phys_addr < (end_pfn_map << PAGE_SHIFT)) return __va(phys_addr); @@ -134,8 +140,8 @@ char *__acpi_map_table(unsigned long phys, unsigned long size) unsigned long base, offset, mapped_size; int idx; - if (phys + size < 8*1024*1024) - return __va(phys); + if (phys + size < 8 * 1024 * 1024) + return __va(phys); offset = phys & (PAGE_SIZE - 1); mapped_size = PAGE_SIZE - offset; @@ -154,7 +160,7 @@ char *__acpi_map_table(unsigned long phys, unsigned long size) mapped_size += PAGE_SIZE; } - return ((unsigned char *) base + offset); + return ((unsigned char *)base + offset); } #endif @@ -172,7 +178,7 @@ int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size) if (!phys_addr || !size) return -EINVAL; - mcfg = (struct acpi_table_mcfg *) __acpi_map_table(phys_addr, size); + mcfg = (struct acpi_table_mcfg *)__acpi_map_table(phys_addr, size); if (!mcfg) { printk(KERN_WARNING PREFIX "Unable to map MCFG\n"); return -ENODEV; @@ -209,20 +215,17 @@ int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size) return 0; } -#endif /* CONFIG_PCI_MMCONFIG */ +#endif /* CONFIG_PCI_MMCONFIG */ #ifdef CONFIG_X86_LOCAL_APIC -static int __init -acpi_parse_madt ( - unsigned long phys_addr, - unsigned long size) +static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size) { - struct acpi_table_madt *madt = NULL; + struct acpi_table_madt *madt = NULL; if (!phys_addr || !size) return -EINVAL; - madt = (struct acpi_table_madt *) __acpi_map_table(phys_addr, size); + madt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size); if (!madt) { printk(KERN_WARNING PREFIX "Unable to map MADT\n"); return -ENODEV; @@ -232,22 +235,20 @@ acpi_parse_madt ( acpi_lapic_addr = (u64) madt->lapic_address; printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n", - madt->lapic_address); + madt->lapic_address); } acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id); - + return 0; } - static int __init -acpi_parse_lapic ( - acpi_table_entry_header *header, const unsigned long end) +acpi_parse_lapic(acpi_table_entry_header * header, const unsigned long end) { - struct acpi_table_lapic *processor = NULL; + struct acpi_table_lapic *processor = NULL; - processor = (struct acpi_table_lapic*) header; + processor = (struct acpi_table_lapic *)header; if (BAD_MADT_ENTRY(processor, end)) return -EINVAL; @@ -260,20 +261,19 @@ acpi_parse_lapic ( x86_acpiid_to_apicid[processor->acpi_id] = processor->id; - mp_register_lapic ( - processor->id, /* APIC ID */ - processor->flags.enabled); /* Enabled? */ + mp_register_lapic(processor->id, /* APIC ID */ + processor->flags.enabled); /* Enabled? */ return 0; } static int __init -acpi_parse_lapic_addr_ovr ( - acpi_table_entry_header *header, const unsigned long end) +acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header, + const unsigned long end) { struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL; - lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr*) header; + lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr *)header; if (BAD_MADT_ENTRY(lapic_addr_ovr, end)) return -EINVAL; @@ -284,12 +284,11 @@ acpi_parse_lapic_addr_ovr ( } static int __init -acpi_parse_lapic_nmi ( - acpi_table_entry_header *header, const unsigned long end) +acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end) { struct acpi_table_lapic_nmi *lapic_nmi = NULL; - lapic_nmi = (struct acpi_table_lapic_nmi*) header; + lapic_nmi = (struct acpi_table_lapic_nmi *)header; if (BAD_MADT_ENTRY(lapic_nmi, end)) return -EINVAL; @@ -302,37 +301,32 @@ acpi_parse_lapic_nmi ( return 0; } - -#endif /*CONFIG_X86_LOCAL_APIC*/ +#endif /*CONFIG_X86_LOCAL_APIC */ #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) static int __init -acpi_parse_ioapic ( - acpi_table_entry_header *header, const unsigned long end) +acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end) { struct acpi_table_ioapic *ioapic = NULL; - ioapic = (struct acpi_table_ioapic*) header; + ioapic = (struct acpi_table_ioapic *)header; if (BAD_MADT_ENTRY(ioapic, end)) return -EINVAL; - + acpi_table_print_madt_entry(header); - mp_register_ioapic ( - ioapic->id, - ioapic->address, - ioapic->global_irq_base); - + mp_register_ioapic(ioapic->id, + ioapic->address, ioapic->global_irq_base); + return 0; } /* * Parse Interrupt Source Override for the ACPI SCI */ -static void -acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger) +static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger) { if (trigger == 0) /* compatible SCI trigger is level */ trigger = 3; @@ -348,7 +342,7 @@ acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger) polarity = acpi_sci_flags.polarity; /* - * mp_config_acpi_legacy_irqs() already setup IRQs < 16 + * mp_config_acpi_legacy_irqs() already setup IRQs < 16 * If GSI is < 16, this will update its flags, * else it will create a new mp_irqs[] entry. */ @@ -363,12 +357,12 @@ acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger) } static int __init -acpi_parse_int_src_ovr ( - acpi_table_entry_header *header, const unsigned long end) +acpi_parse_int_src_ovr(acpi_table_entry_header * header, + const unsigned long end) { struct acpi_table_int_src_ovr *intsrc = NULL; - intsrc = (struct acpi_table_int_src_ovr*) header; + intsrc = (struct acpi_table_int_src_ovr *)header; if (BAD_MADT_ENTRY(intsrc, end)) return -EINVAL; @@ -377,33 +371,30 @@ acpi_parse_int_src_ovr ( if (intsrc->bus_irq == acpi_fadt.sci_int) { acpi_sci_ioapic_setup(intsrc->global_irq, - intsrc->flags.polarity, intsrc->flags.trigger); + intsrc->flags.polarity, + intsrc->flags.trigger); return 0; } if (acpi_skip_timer_override && - intsrc->bus_irq == 0 && intsrc->global_irq == 2) { - printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n"); - return 0; + intsrc->bus_irq == 0 && intsrc->global_irq == 2) { + printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n"); + return 0; } - mp_override_legacy_irq ( - intsrc->bus_irq, - intsrc->flags.polarity, - intsrc->flags.trigger, - intsrc->global_irq); + mp_override_legacy_irq(intsrc->bus_irq, + intsrc->flags.polarity, + intsrc->flags.trigger, intsrc->global_irq); return 0; } - static int __init -acpi_parse_nmi_src ( - acpi_table_entry_header *header, const unsigned long end) +acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end) { struct acpi_table_nmi_src *nmi_src = NULL; - nmi_src = (struct acpi_table_nmi_src*) header; + nmi_src = (struct acpi_table_nmi_src *)header; if (BAD_MADT_ENTRY(nmi_src, end)) return -EINVAL; @@ -415,7 +406,7 @@ acpi_parse_nmi_src ( return 0; } -#endif /* CONFIG_X86_IO_APIC */ +#endif /* CONFIG_X86_IO_APIC */ #ifdef CONFIG_ACPI_BUS @@ -433,8 +424,7 @@ acpi_parse_nmi_src ( * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0) */ -void __init -acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger) +void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger) { unsigned int mask = 1 << irq; unsigned int old, new; @@ -454,10 +444,10 @@ acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger) * routing tables.. */ switch (trigger) { - case 1: /* Edge - clear */ + case 1: /* Edge - clear */ new &= ~mask; break; - case 3: /* Level - set */ + case 3: /* Level - set */ new |= mask; break; } @@ -470,14 +460,13 @@ acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger) outb(new >> 8, 0x4d1); } - -#endif /* CONFIG_ACPI_BUS */ +#endif /* CONFIG_ACPI_BUS */ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) { #ifdef CONFIG_X86_IO_APIC if (use_pci_vector() && !platform_legacy_irq(gsi)) - *irq = IO_APIC_VECTOR(gsi); + *irq = IO_APIC_VECTOR(gsi); else #endif *irq = gsi; @@ -501,7 +490,7 @@ int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low) extern void eisa_set_level_irq(unsigned int irq); if (edge_level == ACPI_LEVEL_SENSITIVE) - eisa_set_level_irq(gsi); + eisa_set_level_irq(gsi); } #endif @@ -513,60 +502,58 @@ int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low) acpi_gsi_to_irq(plat_gsi, &irq); return irq; } + EXPORT_SYMBOL(acpi_register_gsi); /* * ACPI based hotplug support for CPU */ #ifdef CONFIG_ACPI_HOTPLUG_CPU -int -acpi_map_lsapic(acpi_handle handle, int *pcpu) +int acpi_map_lsapic(acpi_handle handle, int *pcpu) { /* TBD */ return -EINVAL; } -EXPORT_SYMBOL(acpi_map_lsapic); +EXPORT_SYMBOL(acpi_map_lsapic); -int -acpi_unmap_lsapic(int cpu) +int acpi_unmap_lsapic(int cpu) { /* TBD */ return -EINVAL; } + EXPORT_SYMBOL(acpi_unmap_lsapic); -#endif /* CONFIG_ACPI_HOTPLUG_CPU */ +#endif /* CONFIG_ACPI_HOTPLUG_CPU */ -int -acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) +int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) { /* TBD */ return -EINVAL; } + EXPORT_SYMBOL(acpi_register_ioapic); -int -acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base) +int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base) { /* TBD */ return -EINVAL; } + EXPORT_SYMBOL(acpi_unregister_ioapic); static unsigned long __init -acpi_scan_rsdp ( - unsigned long start, - unsigned long length) +acpi_scan_rsdp(unsigned long start, unsigned long length) { - unsigned long offset = 0; - unsigned long sig_len = sizeof("RSD PTR ") - 1; + unsigned long offset = 0; + unsigned long sig_len = sizeof("RSD PTR ") - 1; /* * Scan all 16-byte boundaries of the physical memory region for the * RSDP signature. */ for (offset = 0; offset < length; offset += 16) { - if (strncmp((char *) (start + offset), "RSD PTR ", sig_len)) + if (strncmp((char *)(start + offset), "RSD PTR ", sig_len)) continue; return (start + offset); } @@ -579,20 +566,19 @@ static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size) struct acpi_table_sbf *sb; if (!phys_addr || !size) - return -EINVAL; + return -EINVAL; - sb = (struct acpi_table_sbf *) __acpi_map_table(phys_addr, size); + sb = (struct acpi_table_sbf *)__acpi_map_table(phys_addr, size); if (!sb) { printk(KERN_WARNING PREFIX "Unable to map SBF\n"); return -ENODEV; } - sbf_port = sb->sbf_cmos; /* Save CMOS port */ + sbf_port = sb->sbf_cmos; /* Save CMOS port */ return 0; } - #ifdef CONFIG_HPET_TIMER static int __init acpi_parse_hpet(unsigned long phys, unsigned long size) @@ -602,7 +588,7 @@ static int __init acpi_parse_hpet(unsigned long phys, unsigned long size) if (!phys || !size) return -EINVAL; - hpet_tbl = (struct acpi_table_hpet *) __acpi_map_table(phys, size); + hpet_tbl = (struct acpi_table_hpet *)__acpi_map_table(phys, size); if (!hpet_tbl) { printk(KERN_WARNING PREFIX "Unable to map HPET\n"); return -ENODEV; @@ -613,22 +599,21 @@ static int __init acpi_parse_hpet(unsigned long phys, unsigned long size) "memory.\n"); return -1; } - #ifdef CONFIG_X86_64 - vxtime.hpet_address = hpet_tbl->addr.addrl | - ((long) hpet_tbl->addr.addrh << 32); + vxtime.hpet_address = hpet_tbl->addr.addrl | + ((long)hpet_tbl->addr.addrh << 32); - printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", - hpet_tbl->id, vxtime.hpet_address); -#else /* X86 */ + printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", + hpet_tbl->id, vxtime.hpet_address); +#else /* X86 */ { extern unsigned long hpet_address; hpet_address = hpet_tbl->addr.addrl; printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", - hpet_tbl->id, hpet_address); + hpet_tbl->id, hpet_address); } -#endif /* X86 */ +#endif /* X86 */ return 0; } @@ -644,12 +629,11 @@ static int __init acpi_parse_fadt(unsigned long phys, unsigned long size) { struct fadt_descriptor_rev2 *fadt = NULL; - fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size); - if(!fadt) { + fadt = (struct fadt_descriptor_rev2 *)__acpi_map_table(phys, size); + if (!fadt) { printk(KERN_WARNING PREFIX "Unable to map FADT\n"); return 0; } - #ifdef CONFIG_ACPI_INTERPRETER /* initialize sci_int early for INT_SRC_OVR MADT parsing */ acpi_fadt.sci_int = fadt->sci_int; @@ -658,14 +642,16 @@ static int __init acpi_parse_fadt(unsigned long phys, unsigned long size) #ifdef CONFIG_ACPI_BUS /* initialize rev and apic_phys_dest_mode for x86_64 genapic */ acpi_fadt.revision = fadt->revision; - acpi_fadt.force_apic_physical_destination_mode = fadt->force_apic_physical_destination_mode; + acpi_fadt.force_apic_physical_destination_mode = + fadt->force_apic_physical_destination_mode; #endif #ifdef CONFIG_X86_PM_TIMER /* detect the location of the ACPI PM Timer */ if (fadt->revision >= FADT2_REVISION_ID) { /* FADT rev. 2 */ - if (fadt->xpm_tmr_blk.address_space_id != ACPI_ADR_SPACE_SYSTEM_IO) + if (fadt->xpm_tmr_blk.address_space_id != + ACPI_ADR_SPACE_SYSTEM_IO) return 0; pmtmr_ioport = fadt->xpm_tmr_blk.address; @@ -674,16 +660,15 @@ static int __init acpi_parse_fadt(unsigned long phys, unsigned long size) pmtmr_ioport = fadt->V1_pm_tmr_blk; } if (pmtmr_ioport) - printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", pmtmr_ioport); + printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", + pmtmr_ioport); #endif return 0; } - -unsigned long __init -acpi_find_rsdp (void) +unsigned long __init acpi_find_rsdp(void) { - unsigned long rsdp_phys = 0; + unsigned long rsdp_phys = 0; if (efi_enabled) { if (efi.acpi20) @@ -695,9 +680,9 @@ acpi_find_rsdp (void) * Scan memory looking for the RSDP signature. First search EBDA (low * memory) paragraphs and then search upper memory (E0000-FFFFF). */ - rsdp_phys = acpi_scan_rsdp (0, 0x400); + rsdp_phys = acpi_scan_rsdp(0, 0x400); if (!rsdp_phys) - rsdp_phys = acpi_scan_rsdp (0xE0000, 0x20000); + rsdp_phys = acpi_scan_rsdp(0xE0000, 0x20000); return rsdp_phys; } @@ -707,8 +692,7 @@ acpi_find_rsdp (void) * Parse LAPIC entries in MADT * returns 0 on success, < 0 on error */ -static int __init -acpi_parse_madt_lapic_entries(void) +static int __init acpi_parse_madt_lapic_entries(void) { int count; @@ -717,28 +701,31 @@ acpi_parse_madt_lapic_entries(void) * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value). */ - count = acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0); + count = + acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, + acpi_parse_lapic_addr_ovr, 0); if (count < 0) { - printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n"); + printk(KERN_ERR PREFIX + "Error parsing LAPIC address override entry\n"); return count; } mp_register_lapic_address(acpi_lapic_addr); count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic, - MAX_APICS); - if (!count) { + MAX_APICS); + if (!count) { printk(KERN_ERR PREFIX "No LAPIC entries present\n"); /* TBD: Cleanup to allow fallback to MPS */ return -ENODEV; - } - else if (count < 0) { + } else if (count < 0) { printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n"); /* TBD: Cleanup to allow fallback to MPS */ return count; } - count = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0); + count = + acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0); if (count < 0) { printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); /* TBD: Cleanup to allow fallback to MPS */ @@ -746,15 +733,14 @@ acpi_parse_madt_lapic_entries(void) } return 0; } -#endif /* CONFIG_X86_LOCAL_APIC */ +#endif /* CONFIG_X86_LOCAL_APIC */ #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) /* * Parse IOAPIC related entries in MADT * returns 0 on success, < 0 on error */ -static int __init -acpi_parse_madt_ioapic_entries(void) +static int __init acpi_parse_madt_ioapic_entries(void) { int count; @@ -766,30 +752,34 @@ acpi_parse_madt_ioapic_entries(void) */ if (acpi_disabled || acpi_noirq) { return -ENODEV; - } + } /* - * if "noapic" boot option, don't look for IO-APICs + * if "noapic" boot option, don't look for IO-APICs */ if (skip_ioapic_setup) { printk(KERN_INFO PREFIX "Skipping IOAPIC probe " - "due to 'noapic' option.\n"); + "due to 'noapic' option.\n"); return -ENODEV; } - count = acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic, MAX_IO_APICS); + count = + acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic, + MAX_IO_APICS); if (!count) { printk(KERN_ERR PREFIX "No IOAPIC entries present\n"); return -ENODEV; - } - else if (count < 0) { + } else if (count < 0) { printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n"); return count; } - count = acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, NR_IRQ_VECTORS); + count = + acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, + NR_IRQ_VECTORS); if (count < 0) { - printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n"); + printk(KERN_ERR PREFIX + "Error parsing interrupt source overrides entry\n"); /* TBD: Cleanup to allow fallback to MPS */ return count; } @@ -804,7 +794,9 @@ acpi_parse_madt_ioapic_entries(void) /* Fill in identity legacy mapings where no override */ mp_config_acpi_legacy_irqs(); - count = acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, NR_IRQ_VECTORS); + count = + acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, + NR_IRQ_VECTORS); if (count < 0) { printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); /* TBD: Cleanup to allow fallback to MPS */ @@ -818,11 +810,9 @@ static inline int acpi_parse_madt_ioapic_entries(void) { return -1; } -#endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */ - +#endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */ -static void __init -acpi_process_madt(void) +static void __init acpi_process_madt(void) { #ifdef CONFIG_X86_LOCAL_APIC int count, error; @@ -854,7 +844,8 @@ acpi_process_madt(void) /* * Dell Precision Workstation 410, 610 come here. */ - printk(KERN_ERR PREFIX "Invalid BIOS MADT, disabling ACPI\n"); + printk(KERN_ERR PREFIX + "Invalid BIOS MADT, disabling ACPI\n"); disable_acpi(); } } @@ -891,7 +882,7 @@ static int __init disable_acpi_pci(struct dmi_system_id *d) static int __init dmi_disable_acpi(struct dmi_system_id *d) { if (!acpi_force) { - printk(KERN_NOTICE "%s detected: acpi off\n",d->ident); + printk(KERN_NOTICE "%s detected: acpi off\n", d->ident); disable_acpi(); } else { printk(KERN_NOTICE @@ -906,7 +897,8 @@ static int __init dmi_disable_acpi(struct dmi_system_id *d) static int __init force_acpi_ht(struct dmi_system_id *d) { if (!acpi_force) { - printk(KERN_NOTICE "%s detected: force use of acpi=ht\n", d->ident); + printk(KERN_NOTICE "%s detected: force use of acpi=ht\n", + d->ident); disable_acpi(); acpi_ht = 1; } else { @@ -925,155 +917,157 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = { * Boxes that need ACPI disabled */ { - .callback = dmi_disable_acpi, - .ident = "IBM Thinkpad", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), - DMI_MATCH(DMI_BOARD_NAME, "2629H1G"), - }, - }, + .callback = dmi_disable_acpi, + .ident = "IBM Thinkpad", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), + DMI_MATCH(DMI_BOARD_NAME, "2629H1G"), + }, + }, /* * Boxes that need acpi=ht */ { - .callback = force_acpi_ht, - .ident = "FSC Primergy T850", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), - DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"), - }, - }, + .callback = force_acpi_ht, + .ident = "FSC Primergy T850", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), + DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"), + }, + }, { - .callback = force_acpi_ht, - .ident = "DELL GX240", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"), - DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"), - }, - }, + .callback = force_acpi_ht, + .ident = "DELL GX240", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"), + DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"), + }, + }, { - .callback = force_acpi_ht, - .ident = "HP VISUALIZE NT Workstation", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), - DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"), - }, - }, + .callback = force_acpi_ht, + .ident = "HP VISUALIZE NT Workstation", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), + DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"), + }, + }, { - .callback = force_acpi_ht, - .ident = "Compaq Workstation W8000", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Compaq"), - DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"), - }, - }, + .callback = force_acpi_ht, + .ident = "Compaq Workstation W8000", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Compaq"), + DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"), + }, + }, { - .callback = force_acpi_ht, - .ident = "ASUS P4B266", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), - DMI_MATCH(DMI_BOARD_NAME, "P4B266"), - }, - }, + .callback = force_acpi_ht, + .ident = "ASUS P4B266", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), + DMI_MATCH(DMI_BOARD_NAME, "P4B266"), + }, + }, { - .callback = force_acpi_ht, - .ident = "ASUS P2B-DS", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), - DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"), - }, - }, + .callback = force_acpi_ht, + .ident = "ASUS P2B-DS", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), + DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"), + }, + }, { - .callback = force_acpi_ht, - .ident = "ASUS CUR-DLS", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), - DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"), - }, - }, + .callback = force_acpi_ht, + .ident = "ASUS CUR-DLS", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), + DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"), + }, + }, { - .callback = force_acpi_ht, - .ident = "ABIT i440BX-W83977", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "ABIT "), - DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"), - }, - }, + .callback = force_acpi_ht, + .ident = "ABIT i440BX-W83977", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ABIT "), + DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"), + }, + }, { - .callback = force_acpi_ht, - .ident = "IBM Bladecenter", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), - DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"), - }, - }, + .callback = force_acpi_ht, + .ident = "IBM Bladecenter", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), + DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"), + }, + }, { - .callback = force_acpi_ht, - .ident = "IBM eServer xSeries 360", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), - DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"), - }, - }, + .callback = force_acpi_ht, + .ident = "IBM eServer xSeries 360", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), + DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"), + }, + }, { - .callback = force_acpi_ht, - .ident = "IBM eserver xSeries 330", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), - DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"), - }, - }, + .callback = force_acpi_ht, + .ident = "IBM eserver xSeries 330", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), + DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"), + }, + }, { - .callback = force_acpi_ht, - .ident = "IBM eserver xSeries 440", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), - DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"), - }, - }, + .callback = force_acpi_ht, + .ident = "IBM eserver xSeries 440", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), + DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"), + }, + }, #ifdef CONFIG_ACPI_PCI /* * Boxes that need ACPI PCI IRQ routing disabled */ { - .callback = disable_acpi_irq, - .ident = "ASUS A7V", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"), - DMI_MATCH(DMI_BOARD_NAME, ""), - /* newer BIOS, Revision 1011, does work */ - DMI_MATCH(DMI_BIOS_VERSION, "ASUS A7V ACPI BIOS Revision 1007"), - }, - }, + .callback = disable_acpi_irq, + .ident = "ASUS A7V", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"), + DMI_MATCH(DMI_BOARD_NAME, ""), + /* newer BIOS, Revision 1011, does work */ + DMI_MATCH(DMI_BIOS_VERSION, + "ASUS A7V ACPI BIOS Revision 1007"), + }, + }, /* * Boxes that need ACPI PCI IRQ routing and PCI scan disabled */ - { /* _BBN 0 bug */ - .callback = disable_acpi_pci, - .ident = "ASUS PR-DLS", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), - DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"), - DMI_MATCH(DMI_BIOS_VERSION, "ASUS PR-DLS ACPI BIOS Revision 1010"), - DMI_MATCH(DMI_BIOS_DATE, "03/21/2003") - }, - }, + { /* _BBN 0 bug */ + .callback = disable_acpi_pci, + .ident = "ASUS PR-DLS", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), + DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"), + DMI_MATCH(DMI_BIOS_VERSION, + "ASUS PR-DLS ACPI BIOS Revision 1010"), + DMI_MATCH(DMI_BIOS_DATE, "03/21/2003") + }, + }, { - .callback = disable_acpi_pci, - .ident = "Acer TravelMate 36x Laptop", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Acer"), - DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"), - }, - }, + .callback = disable_acpi_pci, + .ident = "Acer TravelMate 36x Laptop", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), + DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"), + }, + }, #endif - { } + {} }; -#endif /* __i386__ */ +#endif /* __i386__ */ /* * acpi_boot_table_init() and acpi_boot_init() @@ -1098,8 +1092,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = { * !0: failure */ -int __init -acpi_boot_table_init(void) +int __init acpi_boot_table_init(void) { int error; @@ -1112,7 +1105,7 @@ acpi_boot_table_init(void) * One exception: acpi=ht continues far enough to enumerate LAPICs */ if (acpi_disabled && !acpi_ht) - return 1; + return 1; /* * Initialize the ACPI boot-time table parser. @@ -1122,7 +1115,6 @@ acpi_boot_table_init(void) disable_acpi(); return error; } - #ifdef __i386__ check_acpi_pci(); #endif @@ -1146,7 +1138,6 @@ acpi_boot_table_init(void) return 0; } - int __init acpi_boot_init(void) { /* @@ -1154,7 +1145,7 @@ int __init acpi_boot_init(void) * One exception: acpi=ht continues far enough to enumerate LAPICs */ if (acpi_disabled && !acpi_ht) - return 1; + return 1; acpi_table_parse(ACPI_BOOT, acpi_parse_sbf); @@ -1172,4 +1163,3 @@ int __init acpi_boot_init(void) return 0; } - diff --git a/arch/i386/kernel/acpi/earlyquirk.c b/arch/i386/kernel/acpi/earlyquirk.c index 726a5ca..f1b9d2a 100644 --- a/arch/i386/kernel/acpi/earlyquirk.c +++ b/arch/i386/kernel/acpi/earlyquirk.c @@ -8,44 +8,44 @@ #include #include -static int __init check_bridge(int vendor, int device) +static int __init check_bridge(int vendor, int device) { /* According to Nvidia all timer overrides are bogus. Just ignore them all. */ - if (vendor == PCI_VENDOR_ID_NVIDIA) { - acpi_skip_timer_override = 1; + if (vendor == PCI_VENDOR_ID_NVIDIA) { + acpi_skip_timer_override = 1; } return 0; } - -void __init check_acpi_pci(void) -{ - int num,slot,func; + +void __init check_acpi_pci(void) +{ + int num, slot, func; /* Assume the machine supports type 1. If not it will always read ffffffff and should not have any side effect. */ /* Poor man's PCI discovery */ - for (num = 0; num < 32; num++) { - for (slot = 0; slot < 32; slot++) { - for (func = 0; func < 8; func++) { + for (num = 0; num < 32; num++) { + for (slot = 0; slot < 32; slot++) { + for (func = 0; func < 8; func++) { u32 class; u32 vendor; - class = read_pci_config(num,slot,func, + class = read_pci_config(num, slot, func, PCI_CLASS_REVISION); if (class == 0xffffffff) - break; + break; if ((class >> 16) != PCI_CLASS_BRIDGE_PCI) - continue; - - vendor = read_pci_config(num, slot, func, + continue; + + vendor = read_pci_config(num, slot, func, PCI_VENDOR_ID); - - if (check_bridge(vendor&0xffff, vendor >> 16)) - return; - } - + + if (check_bridge(vendor & 0xffff, vendor >> 16)) + return; + } + } } } diff --git a/arch/i386/kernel/acpi/sleep.c b/arch/i386/kernel/acpi/sleep.c index c1af930..1cb2b18 100644 --- a/arch/i386/kernel/acpi/sleep.c +++ b/arch/i386/kernel/acpi/sleep.c @@ -20,12 +20,13 @@ extern void zap_low_mappings(void); extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long)); -static void init_low_mapping(pgd_t *pgd, int pgd_limit) +static void init_low_mapping(pgd_t * pgd, int pgd_limit) { int pgd_ofs = 0; - while ((pgd_ofs < pgd_limit) && (pgd_ofs + USER_PTRS_PER_PGD < PTRS_PER_PGD)) { - set_pgd(pgd, *(pgd+USER_PTRS_PER_PGD)); + while ((pgd_ofs < pgd_limit) + && (pgd_ofs + USER_PTRS_PER_PGD < PTRS_PER_PGD)) { + set_pgd(pgd, *(pgd + USER_PTRS_PER_PGD)); pgd_ofs++, pgd++; } flush_tlb_all(); @@ -37,12 +38,13 @@ static void init_low_mapping(pgd_t *pgd, int pgd_limit) * Create an identity mapped page table and copy the wakeup routine to * low memory. */ -int acpi_save_state_mem (void) +int acpi_save_state_mem(void) { if (!acpi_wakeup_address) return 1; init_low_mapping(swapper_pg_dir, USER_PTRS_PER_PGD); - memcpy((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start); + memcpy((void *)acpi_wakeup_address, &wakeup_start, + &wakeup_end - &wakeup_start); acpi_copy_wakeup_routine(acpi_wakeup_address); return 0; @@ -51,7 +53,7 @@ int acpi_save_state_mem (void) /* * acpi_restore_state - undo effects of acpi_save_state_mem */ -void acpi_restore_state_mem (void) +void acpi_restore_state_mem(void) { zap_low_mappings(); } @@ -67,7 +69,8 @@ void acpi_restore_state_mem (void) void __init acpi_reserve_bootmem(void) { if ((&wakeup_end - &wakeup_start) > PAGE_SIZE) { - printk(KERN_ERR "ACPI: Wakeup code way too big, S3 disabled.\n"); + printk(KERN_ERR + "ACPI: Wakeup code way too big, S3 disabled.\n"); return; } @@ -90,10 +93,8 @@ static int __init acpi_sleep_setup(char *str) return 1; } - __setup("acpi_sleep=", acpi_sleep_setup); - static __init int reset_videomode_after_s3(struct dmi_system_id *d) { acpi_video_flags |= 2; @@ -101,14 +102,14 @@ static __init int reset_videomode_after_s3(struct dmi_system_id *d) } static __initdata struct dmi_system_id acpisleep_dmi_table[] = { - { /* Reset video mode after returning from ACPI S3 sleep */ - .callback = reset_videomode_after_s3, - .ident = "Toshiba Satellite 4030cdt", - .matches = { - DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"), - }, - }, - { } + { /* Reset video mode after returning from ACPI S3 sleep */ + .callback = reset_videomode_after_s3, + .ident = "Toshiba Satellite 4030cdt", + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"), + }, + }, + {} }; static int __init acpisleep_dmi_init(void) diff --git a/arch/ia64/kernel/acpi-ext.c b/arch/ia64/kernel/acpi-ext.c index 2623df5..13a5b3b 100644 --- a/arch/ia64/kernel/acpi-ext.c +++ b/arch/ia64/kernel/acpi-ext.c @@ -17,20 +17,20 @@ #include struct acpi_vendor_descriptor { - u8 guid_id; - efi_guid_t guid; + u8 guid_id; + efi_guid_t guid; }; struct acpi_vendor_info { - struct acpi_vendor_descriptor *descriptor; - u8 *data; - u32 length; + struct acpi_vendor_descriptor *descriptor; + u8 *data; + u32 length; }; acpi_status acpi_vendor_resource_match(struct acpi_resource *resource, void *context) { - struct acpi_vendor_info *info = (struct acpi_vendor_info *) context; + struct acpi_vendor_info *info = (struct acpi_vendor_info *)context; struct acpi_resource_vendor *vendor; struct acpi_vendor_descriptor *descriptor; u32 length; @@ -38,8 +38,8 @@ acpi_vendor_resource_match(struct acpi_resource *resource, void *context) if (resource->id != ACPI_RSTYPE_VENDOR) return AE_OK; - vendor = (struct acpi_resource_vendor *) &resource->data; - descriptor = (struct acpi_vendor_descriptor *) vendor->reserved; + vendor = (struct acpi_resource_vendor *)&resource->data; + descriptor = (struct acpi_vendor_descriptor *)vendor->reserved; if (vendor->length <= sizeof(*info->descriptor) || descriptor->guid_id != info->descriptor->guid_id || efi_guidcmp(descriptor->guid, info->descriptor->guid)) @@ -50,21 +50,24 @@ acpi_vendor_resource_match(struct acpi_resource *resource, void *context) if (!info->data) return AE_NO_MEMORY; - memcpy(info->data, vendor->reserved + sizeof(struct acpi_vendor_descriptor), length); + memcpy(info->data, + vendor->reserved + sizeof(struct acpi_vendor_descriptor), + length); info->length = length; return AE_CTRL_TERMINATE; } acpi_status -acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor *id, - u8 **data, u32 *length) +acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id, + u8 ** data, u32 * length) { struct acpi_vendor_info info; info.descriptor = id; info.data = NULL; - acpi_walk_resources(obj, METHOD_NAME__CRS, acpi_vendor_resource_match, &info); + acpi_walk_resources(obj, METHOD_NAME__CRS, acpi_vendor_resource_match, + &info); if (!info.data) return AE_NOT_FOUND; @@ -75,17 +78,19 @@ acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor *id, struct acpi_vendor_descriptor hp_ccsr_descriptor = { .guid_id = 2, - .guid = EFI_GUID(0x69e9adf9, 0x924f, 0xab5f, 0xf6, 0x4a, 0x24, 0xd2, 0x01, 0x37, 0x0e, 0xad) + .guid = + EFI_GUID(0x69e9adf9, 0x924f, 0xab5f, 0xf6, 0x4a, 0x24, 0xd2, 0x01, + 0x37, 0x0e, 0xad) }; -acpi_status -hp_acpi_csr_space(acpi_handle obj, u64 *csr_base, u64 *csr_length) +acpi_status hp_acpi_csr_space(acpi_handle obj, u64 * csr_base, u64 * csr_length) { acpi_status status; u8 *data; u32 length; - status = acpi_find_vendor_resource(obj, &hp_ccsr_descriptor, &data, &length); + status = + acpi_find_vendor_resource(obj, &hp_ccsr_descriptor, &data, &length); if (ACPI_FAILURE(status) || length != 16) return AE_NOT_FOUND; diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index d362ecf..f3046bd 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c @@ -74,12 +74,11 @@ unsigned int acpi_cpei_override; unsigned int acpi_cpei_phys_cpuid; #define MAX_SAPICS 256 -u16 ia64_acpiid_to_sapicid[MAX_SAPICS] = - { [0 ... MAX_SAPICS - 1] = -1 }; +u16 ia64_acpiid_to_sapicid[MAX_SAPICS] = {[0...MAX_SAPICS - 1] = -1 }; + EXPORT_SYMBOL(ia64_acpiid_to_sapicid); -const char * -acpi_get_sysname (void) +const char *acpi_get_sysname(void) { #ifdef CONFIG_IA64_GENERIC unsigned long rsdp_phys; @@ -89,27 +88,29 @@ acpi_get_sysname (void) rsdp_phys = acpi_find_rsdp(); if (!rsdp_phys) { - printk(KERN_ERR "ACPI 2.0 RSDP not found, default to \"dig\"\n"); + printk(KERN_ERR + "ACPI 2.0 RSDP not found, default to \"dig\"\n"); return "dig"; } - rsdp = (struct acpi20_table_rsdp *) __va(rsdp_phys); + rsdp = (struct acpi20_table_rsdp *)__va(rsdp_phys); if (strncmp(rsdp->signature, RSDP_SIG, sizeof(RSDP_SIG) - 1)) { - printk(KERN_ERR "ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n"); + printk(KERN_ERR + "ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n"); return "dig"; } - xsdt = (struct acpi_table_xsdt *) __va(rsdp->xsdt_address); + xsdt = (struct acpi_table_xsdt *)__va(rsdp->xsdt_address); hdr = &xsdt->header; if (strncmp(hdr->signature, XSDT_SIG, sizeof(XSDT_SIG) - 1)) { - printk(KERN_ERR "ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n"); + printk(KERN_ERR + "ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n"); return "dig"; } if (!strcmp(hdr->oem_id, "HP")) { return "hpzx1"; - } - else if (!strcmp(hdr->oem_id, "SGI")) { + } else if (!strcmp(hdr->oem_id, "SGI")) { return "sn2"; } @@ -137,7 +138,7 @@ acpi_get_sysname (void) /* Array to record platform interrupt vectors for generic interrupt routing. */ int platform_intr_list[ACPI_MAX_PLATFORM_INTERRUPTS] = { - [0 ... ACPI_MAX_PLATFORM_INTERRUPTS - 1] = -1 + [0...ACPI_MAX_PLATFORM_INTERRUPTS - 1] = -1 }; enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC; @@ -146,8 +147,7 @@ enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC; * Interrupt routing API for device drivers. Provides interrupt vector for * a generic platform event. Currently only CPEI is implemented. */ -int -acpi_request_vector (u32 int_type) +int acpi_request_vector(u32 int_type) { int vector = -1; @@ -155,12 +155,12 @@ acpi_request_vector (u32 int_type) /* corrected platform error interrupt */ vector = platform_intr_list[int_type]; } else - printk(KERN_ERR "acpi_request_vector(): invalid interrupt type\n"); + printk(KERN_ERR + "acpi_request_vector(): invalid interrupt type\n"); return vector; } -char * -__acpi_map_table (unsigned long phys_addr, unsigned long size) +char *__acpi_map_table(unsigned long phys_addr, unsigned long size) { return __va(phys_addr); } @@ -169,19 +169,18 @@ __acpi_map_table (unsigned long phys_addr, unsigned long size) Boot-time Table Parsing -------------------------------------------------------------------------- */ -static int total_cpus __initdata; -static int available_cpus __initdata; -struct acpi_table_madt * acpi_madt __initdata; -static u8 has_8259; - +static int total_cpus __initdata; +static int available_cpus __initdata; +struct acpi_table_madt *acpi_madt __initdata; +static u8 has_8259; static int __init -acpi_parse_lapic_addr_ovr ( - acpi_table_entry_header *header, const unsigned long end) +acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header, + const unsigned long end) { struct acpi_table_lapic_addr_ovr *lapic; - lapic = (struct acpi_table_lapic_addr_ovr *) header; + lapic = (struct acpi_table_lapic_addr_ovr *)header; if (BAD_MADT_ENTRY(lapic, end)) return -EINVAL; @@ -193,22 +192,23 @@ acpi_parse_lapic_addr_ovr ( return 0; } - static int __init -acpi_parse_lsapic (acpi_table_entry_header *header, const unsigned long end) +acpi_parse_lsapic(acpi_table_entry_header * header, const unsigned long end) { struct acpi_table_lsapic *lsapic; - lsapic = (struct acpi_table_lsapic *) header; + lsapic = (struct acpi_table_lsapic *)header; if (BAD_MADT_ENTRY(lsapic, end)) return -EINVAL; if (lsapic->flags.enabled) { #ifdef CONFIG_SMP - smp_boot_data.cpu_phys_id[available_cpus] = (lsapic->id << 8) | lsapic->eid; + smp_boot_data.cpu_phys_id[available_cpus] = + (lsapic->id << 8) | lsapic->eid; #endif - ia64_acpiid_to_sapicid[lsapic->acpi_id] = (lsapic->id << 8) | lsapic->eid; + ia64_acpiid_to_sapicid[lsapic->acpi_id] = + (lsapic->id << 8) | lsapic->eid; ++available_cpus; } @@ -216,13 +216,12 @@ acpi_parse_lsapic (acpi_table_entry_header *header, const unsigned long end) return 0; } - static int __init -acpi_parse_lapic_nmi (acpi_table_entry_header *header, const unsigned long end) +acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end) { struct acpi_table_lapic_nmi *lacpi_nmi; - lacpi_nmi = (struct acpi_table_lapic_nmi*) header; + lacpi_nmi = (struct acpi_table_lapic_nmi *)header; if (BAD_MADT_ENTRY(lacpi_nmi, end)) return -EINVAL; @@ -231,13 +230,12 @@ acpi_parse_lapic_nmi (acpi_table_entry_header *header, const unsigned long end) return 0; } - static int __init -acpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end) +acpi_parse_iosapic(acpi_table_entry_header * header, const unsigned long end) { struct acpi_table_iosapic *iosapic; - iosapic = (struct acpi_table_iosapic *) header; + iosapic = (struct acpi_table_iosapic *)header; if (BAD_MADT_ENTRY(iosapic, end)) return -EINVAL; @@ -245,15 +243,14 @@ acpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end) return iosapic_init(iosapic->address, iosapic->global_irq_base); } - static int __init -acpi_parse_plat_int_src ( - acpi_table_entry_header *header, const unsigned long end) +acpi_parse_plat_int_src(acpi_table_entry_header * header, + const unsigned long end) { struct acpi_table_plat_int_src *plintsrc; int vector; - plintsrc = (struct acpi_table_plat_int_src *) header; + plintsrc = (struct acpi_table_plat_int_src *)header; if (BAD_MADT_ENTRY(plintsrc, end)) return -EINVAL; @@ -267,8 +264,12 @@ acpi_parse_plat_int_src ( plintsrc->iosapic_vector, plintsrc->eid, plintsrc->id, - (plintsrc->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, - (plintsrc->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); + (plintsrc->flags.polarity == + 1) ? IOSAPIC_POL_HIGH : + IOSAPIC_POL_LOW, + (plintsrc->flags.trigger == + 1) ? IOSAPIC_EDGE : + IOSAPIC_LEVEL); platform_intr_list[plintsrc->type] = vector; if (acpi_madt_rev > 1) { @@ -283,7 +284,6 @@ acpi_parse_plat_int_src ( return 0; } - unsigned int can_cpei_retarget(void) { extern int cpe_vector; @@ -322,29 +322,30 @@ unsigned int get_cpei_target_cpu(void) } static int __init -acpi_parse_int_src_ovr ( - acpi_table_entry_header *header, const unsigned long end) +acpi_parse_int_src_ovr(acpi_table_entry_header * header, + const unsigned long end) { struct acpi_table_int_src_ovr *p; - p = (struct acpi_table_int_src_ovr *) header; + p = (struct acpi_table_int_src_ovr *)header; if (BAD_MADT_ENTRY(p, end)) return -EINVAL; iosapic_override_isa_irq(p->bus_irq, p->global_irq, - (p->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, - (p->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); + (p->flags.polarity == + 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, + (p->flags.trigger == + 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); return 0; } - static int __init -acpi_parse_nmi_src (acpi_table_entry_header *header, const unsigned long end) +acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end) { struct acpi_table_nmi_src *nmi_src; - nmi_src = (struct acpi_table_nmi_src*) header; + nmi_src = (struct acpi_table_nmi_src *)header; if (BAD_MADT_ENTRY(nmi_src, end)) return -EINVAL; @@ -353,11 +354,9 @@ acpi_parse_nmi_src (acpi_table_entry_header *header, const unsigned long end) return 0; } -static void __init -acpi_madt_oem_check (char *oem_id, char *oem_table_id) +static void __init acpi_madt_oem_check(char *oem_id, char *oem_table_id) { - if (!strncmp(oem_id, "IBM", 3) && - (!strncmp(oem_table_id, "SERMOW", 6))) { + if (!strncmp(oem_id, "IBM", 3) && (!strncmp(oem_table_id, "SERMOW", 6))) { /* * Unfortunately ITC_DRIFT is not yet part of the @@ -370,19 +369,18 @@ acpi_madt_oem_check (char *oem_id, char *oem_table_id) } } -static int __init -acpi_parse_madt (unsigned long phys_addr, unsigned long size) +static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size) { if (!phys_addr || !size) return -EINVAL; - acpi_madt = (struct acpi_table_madt *) __va(phys_addr); + acpi_madt = (struct acpi_table_madt *)__va(phys_addr); acpi_madt_rev = acpi_madt->header.revision; /* remember the value for reference after free_initmem() */ #ifdef CONFIG_ITANIUM - has_8259 = 1; /* Firmware on old Itanium systems is broken */ + has_8259 = 1; /* Firmware on old Itanium systems is broken */ #else has_8259 = acpi_madt->flags.pcat_compat; #endif @@ -396,19 +394,18 @@ acpi_parse_madt (unsigned long phys_addr, unsigned long size) printk(KERN_INFO PREFIX "Local APIC address %p\n", ipi_base_addr); acpi_madt_oem_check(acpi_madt->header.oem_id, - acpi_madt->header.oem_table_id); + acpi_madt->header.oem_table_id); return 0; } - #ifdef CONFIG_ACPI_NUMA #undef SLIT_DEBUG #define PXM_FLAG_LEN ((MAX_PXM_DOMAINS + 1)/32) -static int __initdata srat_num_cpus; /* number of cpus */ +static int __initdata srat_num_cpus; /* number of cpus */ static u32 __devinitdata pxm_flag[PXM_FLAG_LEN]; #define pxm_bit_set(bit) (set_bit(bit,(void *)pxm_flag)) #define pxm_bit_test(bit) (test_bit(bit,(void *)pxm_flag)) @@ -421,15 +418,15 @@ static struct acpi_table_slit __initdata *slit_table; * ACPI 2.0 SLIT (System Locality Information Table) * http://devresource.hp.com/devresource/Docs/TechPapers/IA64/slit.pdf */ -void __init -acpi_numa_slit_init (struct acpi_table_slit *slit) +void __init acpi_numa_slit_init(struct acpi_table_slit *slit) { u32 len; len = sizeof(struct acpi_table_header) + 8 - + slit->localities * slit->localities; + + slit->localities * slit->localities; if (slit->header.length != len) { - printk(KERN_ERR "ACPI 2.0 SLIT: size mismatch: %d expected, %d actual\n", + printk(KERN_ERR + "ACPI 2.0 SLIT: size mismatch: %d expected, %d actual\n", len, slit->header.length); memset(numa_slit, 10, sizeof(numa_slit)); return; @@ -438,19 +435,20 @@ acpi_numa_slit_init (struct acpi_table_slit *slit) } void __init -acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa) +acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa) { /* record this node in proximity bitmap */ pxm_bit_set(pa->proximity_domain); - node_cpuid[srat_num_cpus].phys_id = (pa->apic_id << 8) | (pa->lsapic_eid); + node_cpuid[srat_num_cpus].phys_id = + (pa->apic_id << 8) | (pa->lsapic_eid); /* nid should be overridden as logical node id later */ node_cpuid[srat_num_cpus].nid = pa->proximity_domain; srat_num_cpus++; } void __init -acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma) +acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma) { unsigned long paddr, size; u8 pxm; @@ -487,8 +485,7 @@ acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma) num_node_memblks++; } -void __init -acpi_numa_arch_fixup (void) +void __init acpi_numa_arch_fixup(void) { int i, j, node_from, node_to; @@ -534,21 +531,24 @@ acpi_numa_arch_fixup (void) for (i = 0; i < srat_num_cpus; i++) node_cpuid[i].nid = pxm_to_nid_map[node_cpuid[i].nid]; - printk(KERN_INFO "Number of logical nodes in system = %d\n", num_online_nodes()); - printk(KERN_INFO "Number of memory chunks in system = %d\n", num_node_memblks); + printk(KERN_INFO "Number of logical nodes in system = %d\n", + num_online_nodes()); + printk(KERN_INFO "Number of memory chunks in system = %d\n", + num_node_memblks); - if (!slit_table) return; + if (!slit_table) + return; memset(numa_slit, -1, sizeof(numa_slit)); - for (i=0; ilocalities; i++) { + for (i = 0; i < slit_table->localities; i++) { if (!pxm_bit_test(i)) continue; node_from = pxm_to_nid_map[i]; - for (j=0; jlocalities; j++) { + for (j = 0; j < slit_table->localities; j++) { if (!pxm_bit_test(j)) continue; node_to = pxm_to_nid_map[j]; node_distance(node_from, node_to) = - slit_table->entry[i*slit_table->localities + j]; + slit_table->entry[i * slit_table->localities + j]; } } @@ -556,40 +556,43 @@ acpi_numa_arch_fixup (void) printk("ACPI 2.0 SLIT locality table:\n"); for_each_online_node(i) { for_each_online_node(j) - printk("%03d ", node_distance(i,j)); + printk("%03d ", node_distance(i, j)); printk("\n"); } #endif } -#endif /* CONFIG_ACPI_NUMA */ +#endif /* CONFIG_ACPI_NUMA */ /* * success: return IRQ number (>=0) * failure: return < 0 */ -int -acpi_register_gsi (u32 gsi, int edge_level, int active_high_low) +int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low) { if (has_8259 && gsi < 16) return isa_irq_to_vector(gsi); return iosapic_register_intr(gsi, - (active_high_low == ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, - (edge_level == ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); + (active_high_low == + ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH : + IOSAPIC_POL_LOW, + (edge_level == + ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE : + IOSAPIC_LEVEL); } + EXPORT_SYMBOL(acpi_register_gsi); #ifdef CONFIG_ACPI_DEALLOCATE_IRQ -void -acpi_unregister_gsi (u32 gsi) +void acpi_unregister_gsi(u32 gsi) { iosapic_unregister_intr(gsi); } + EXPORT_SYMBOL(acpi_unregister_gsi); -#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */ +#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */ -static int __init -acpi_parse_fadt (unsigned long phys_addr, unsigned long size) +static int __init acpi_parse_fadt(unsigned long phys_addr, unsigned long size) { struct acpi_table_header *fadt_header; struct fadt_descriptor_rev2 *fadt; @@ -597,11 +600,11 @@ acpi_parse_fadt (unsigned long phys_addr, unsigned long size) if (!phys_addr || !size) return -EINVAL; - fadt_header = (struct acpi_table_header *) __va(phys_addr); + fadt_header = (struct acpi_table_header *)__va(phys_addr); if (fadt_header->revision != 3) - return -ENODEV; /* Only deal with ACPI 2.0 FADT */ + return -ENODEV; /* Only deal with ACPI 2.0 FADT */ - fadt = (struct fadt_descriptor_rev2 *) fadt_header; + fadt = (struct fadt_descriptor_rev2 *)fadt_header; if (!(fadt->iapc_boot_arch & BAF_8042_KEYBOARD_CONTROLLER)) acpi_kbd_controller_present = 0; @@ -613,22 +616,19 @@ acpi_parse_fadt (unsigned long phys_addr, unsigned long size) return 0; } - -unsigned long __init -acpi_find_rsdp (void) +unsigned long __init acpi_find_rsdp(void) { unsigned long rsdp_phys = 0; if (efi.acpi20) rsdp_phys = __pa(efi.acpi20); else if (efi.acpi) - printk(KERN_WARNING PREFIX "v1.0/r0.71 tables no longer supported\n"); + printk(KERN_WARNING PREFIX + "v1.0/r0.71 tables no longer supported\n"); return rsdp_phys; } - -int __init -acpi_boot_init (void) +int __init acpi_boot_init(void) { /* @@ -646,31 +646,43 @@ acpi_boot_init (void) /* Local APIC */ - if (acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0) < 0) - printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n"); + if (acpi_table_parse_madt + (ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0) < 0) + printk(KERN_ERR PREFIX + "Error parsing LAPIC address override entry\n"); - if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_parse_lsapic, NR_CPUS) < 1) - printk(KERN_ERR PREFIX "Error parsing MADT - no LAPIC entries\n"); + if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_parse_lsapic, NR_CPUS) + < 1) + printk(KERN_ERR PREFIX + "Error parsing MADT - no LAPIC entries\n"); - if (acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0) < 0) + if (acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0) + < 0) printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); /* I/O APIC */ - if (acpi_table_parse_madt(ACPI_MADT_IOSAPIC, acpi_parse_iosapic, NR_IOSAPICS) < 1) - printk(KERN_ERR PREFIX "Error parsing MADT - no IOSAPIC entries\n"); + if (acpi_table_parse_madt + (ACPI_MADT_IOSAPIC, acpi_parse_iosapic, NR_IOSAPICS) < 1) + printk(KERN_ERR PREFIX + "Error parsing MADT - no IOSAPIC entries\n"); /* System-Level Interrupt Routing */ - if (acpi_table_parse_madt(ACPI_MADT_PLAT_INT_SRC, acpi_parse_plat_int_src, ACPI_MAX_PLATFORM_INTERRUPTS) < 0) - printk(KERN_ERR PREFIX "Error parsing platform interrupt source entry\n"); + if (acpi_table_parse_madt + (ACPI_MADT_PLAT_INT_SRC, acpi_parse_plat_int_src, + ACPI_MAX_PLATFORM_INTERRUPTS) < 0) + printk(KERN_ERR PREFIX + "Error parsing platform interrupt source entry\n"); - if (acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, 0) < 0) - printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n"); + if (acpi_table_parse_madt + (ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, 0) < 0) + printk(KERN_ERR PREFIX + "Error parsing interrupt source overrides entry\n"); if (acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, 0) < 0) printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); - skip_madt: + skip_madt: /* * FADT says whether a legacy keyboard controller is present. @@ -685,8 +697,9 @@ acpi_boot_init (void) if (available_cpus == 0) { printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n"); printk(KERN_INFO "CPU 0 (0x%04x)", hard_smp_processor_id()); - smp_boot_data.cpu_phys_id[available_cpus] = hard_smp_processor_id(); - available_cpus = 1; /* We've got at least one of these, no? */ + smp_boot_data.cpu_phys_id[available_cpus] = + hard_smp_processor_id(); + available_cpus = 1; /* We've got at least one of these, no? */ } smp_boot_data.cpu_count = available_cpus; @@ -695,8 +708,10 @@ acpi_boot_init (void) if (srat_num_cpus == 0) { int cpu, i = 1; for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++) - if (smp_boot_data.cpu_phys_id[cpu] != hard_smp_processor_id()) - node_cpuid[i++].phys_id = smp_boot_data.cpu_phys_id[cpu]; + if (smp_boot_data.cpu_phys_id[cpu] != + hard_smp_processor_id()) + node_cpuid[i++].phys_id = + smp_boot_data.cpu_phys_id[cpu]; } # endif #endif @@ -704,12 +719,12 @@ acpi_boot_init (void) build_cpu_to_node_map(); #endif /* Make boot-up look pretty */ - printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus, total_cpus); + printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus, + total_cpus); return 0; } -int -acpi_gsi_to_irq (u32 gsi, unsigned int *irq) +int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) { int vector; @@ -730,11 +745,10 @@ acpi_gsi_to_irq (u32 gsi, unsigned int *irq) */ #ifdef CONFIG_ACPI_HOTPLUG_CPU static -int -acpi_map_cpu2node(acpi_handle handle, int cpu, long physid) +int acpi_map_cpu2node(acpi_handle handle, int cpu, long physid) { #ifdef CONFIG_ACPI_NUMA - int pxm_id; + int pxm_id; pxm_id = acpi_get_pxm(handle); @@ -742,31 +756,28 @@ acpi_map_cpu2node(acpi_handle handle, int cpu, long physid) * Assuming that the container driver would have set the proximity * domain and would have initialized pxm_to_nid_map[pxm_id] && pxm_flag */ - node_cpuid[cpu].nid = (pxm_id < 0) ? 0: - pxm_to_nid_map[pxm_id]; + node_cpuid[cpu].nid = (pxm_id < 0) ? 0 : pxm_to_nid_map[pxm_id]; - node_cpuid[cpu].phys_id = physid; + node_cpuid[cpu].phys_id = physid; #endif - return(0); + return (0); } - -int -acpi_map_lsapic(acpi_handle handle, int *pcpu) +int acpi_map_lsapic(acpi_handle handle, int *pcpu) { - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; union acpi_object *obj; struct acpi_table_lsapic *lsapic; cpumask_t tmp_map; long physid; int cpu; - + if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) return -EINVAL; - if (!buffer.length || !buffer.pointer) + if (!buffer.length || !buffer.pointer) return -EINVAL; - + obj = buffer.pointer; if (obj->type != ACPI_TYPE_BUFFER || obj->buffer.length < sizeof(*lsapic)) { @@ -782,7 +793,7 @@ acpi_map_lsapic(acpi_handle handle, int *pcpu) return -EINVAL; } - physid = ((lsapic->id <<8) | (lsapic->eid)); + physid = ((lsapic->id << 8) | (lsapic->eid)); acpi_os_free(buffer.pointer); buffer.length = ACPI_ALLOCATE_BUFFER; @@ -790,50 +801,49 @@ acpi_map_lsapic(acpi_handle handle, int *pcpu) cpus_complement(tmp_map, cpu_present_map); cpu = first_cpu(tmp_map); - if(cpu >= NR_CPUS) + if (cpu >= NR_CPUS) return -EINVAL; acpi_map_cpu2node(handle, cpu, physid); - cpu_set(cpu, cpu_present_map); + cpu_set(cpu, cpu_present_map); ia64_cpu_to_sapicid[cpu] = physid; ia64_acpiid_to_sapicid[lsapic->acpi_id] = ia64_cpu_to_sapicid[cpu]; *pcpu = cpu; - return(0); + return (0); } -EXPORT_SYMBOL(acpi_map_lsapic); +EXPORT_SYMBOL(acpi_map_lsapic); -int -acpi_unmap_lsapic(int cpu) +int acpi_unmap_lsapic(int cpu) { int i; - for (i=0; i #include - /* -------------------------------------------------------------------------- Low-Level Sleep Support -------------------------------------------------------------------------- */ @@ -77,11 +76,12 @@ static void init_low_mapping(void) * Create an identity mapped page table and copy the wakeup routine to * low memory. */ -int acpi_save_state_mem (void) +int acpi_save_state_mem(void) { init_low_mapping(); - memcpy((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start); + memcpy((void *)acpi_wakeup_address, &wakeup_start, + &wakeup_end - &wakeup_start); acpi_copy_wakeup_routine(acpi_wakeup_address); return 0; @@ -90,7 +90,7 @@ int acpi_save_state_mem (void) /* * acpi_restore_state */ -void acpi_restore_state_mem (void) +void acpi_restore_state_mem(void) { set_pgd(pgd_offset(current->mm, 0UL), low_ptr); flush_tlb_all(); @@ -108,7 +108,8 @@ void __init acpi_reserve_bootmem(void) { acpi_wakeup_address = (unsigned long)alloc_bootmem_low(PAGE_SIZE); if ((&wakeup_end - &wakeup_start) > PAGE_SIZE) - printk(KERN_CRIT "ACPI: Wakeup code way too big, will crash on attempt to suspend\n"); + printk(KERN_CRIT + "ACPI: Wakeup code way too big, will crash on attempt to suspend\n"); } static int __init acpi_sleep_setup(char *str) @@ -127,6 +128,8 @@ static int __init acpi_sleep_setup(char *str) __setup("acpi_sleep=", acpi_sleep_setup); -#endif /*CONFIG_ACPI_SLEEP*/ +#endif /*CONFIG_ACPI_SLEEP */ -void acpi_pci_link_exit(void) {} +void acpi_pci_link_exit(void) +{ +} diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 23ab761..7839b83 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -32,7 +32,6 @@ #include #include - #define ACPI_AC_COMPONENT 0x00020000 #define ACPI_AC_CLASS "ac_adapter" #define ACPI_AC_HID "ACPI0003" @@ -45,47 +44,45 @@ #define ACPI_AC_STATUS_UNKNOWN 0xFF #define _COMPONENT ACPI_AC_COMPONENT -ACPI_MODULE_NAME ("acpi_ac") +ACPI_MODULE_NAME("acpi_ac") -MODULE_AUTHOR("Paul Diefenbaugh"); + MODULE_AUTHOR("Paul Diefenbaugh"); MODULE_DESCRIPTION(ACPI_AC_DRIVER_NAME); MODULE_LICENSE("GPL"); -static int acpi_ac_add (struct acpi_device *device); -static int acpi_ac_remove (struct acpi_device *device, int type); +static int acpi_ac_add(struct acpi_device *device); +static int acpi_ac_remove(struct acpi_device *device, int type); static int acpi_ac_open_fs(struct inode *inode, struct file *file); static struct acpi_driver acpi_ac_driver = { - .name = ACPI_AC_DRIVER_NAME, - .class = ACPI_AC_CLASS, - .ids = ACPI_AC_HID, - .ops = { - .add = acpi_ac_add, - .remove = acpi_ac_remove, - }, + .name = ACPI_AC_DRIVER_NAME, + .class = ACPI_AC_CLASS, + .ids = ACPI_AC_HID, + .ops = { + .add = acpi_ac_add, + .remove = acpi_ac_remove, + }, }; struct acpi_ac { - acpi_handle handle; - unsigned long state; + acpi_handle handle; + unsigned long state; }; static struct file_operations acpi_ac_fops = { - .open = acpi_ac_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_ac_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; /* -------------------------------------------------------------------------- AC Adapter Management -------------------------------------------------------------------------- */ -static int -acpi_ac_get_state ( - struct acpi_ac *ac) +static int acpi_ac_get_state(struct acpi_ac *ac) { - acpi_status status = AE_OK; + acpi_status status = AE_OK; ACPI_FUNCTION_TRACE("acpi_ac_get_state"); @@ -95,24 +92,23 @@ acpi_ac_get_state ( status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error reading AC Adapter state\n")); + "Error reading AC Adapter state\n")); ac->state = ACPI_AC_STATUS_UNKNOWN; return_VALUE(-ENODEV); } - + return_VALUE(0); } - /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ -static struct proc_dir_entry *acpi_ac_dir; +static struct proc_dir_entry *acpi_ac_dir; static int acpi_ac_seq_show(struct seq_file *seq, void *offset) { - struct acpi_ac *ac = (struct acpi_ac *) seq->private; + struct acpi_ac *ac = (struct acpi_ac *)seq->private; ACPI_FUNCTION_TRACE("acpi_ac_seq_show"); @@ -139,23 +135,21 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset) return_VALUE(0); } - + static int acpi_ac_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_ac_seq_show, PDE(inode)->data); } -static int -acpi_ac_add_fs ( - struct acpi_device *device) +static int acpi_ac_add_fs(struct acpi_device *device) { - struct proc_dir_entry *entry = NULL; + struct proc_dir_entry *entry = NULL; ACPI_FUNCTION_TRACE("acpi_ac_add_fs"); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), - acpi_ac_dir); + acpi_ac_dir); if (!acpi_device_dir(device)) return_VALUE(-ENODEV); acpi_device_dir(device)->owner = THIS_MODULE; @@ -163,11 +157,11 @@ acpi_ac_add_fs ( /* 'state' [R] */ entry = create_proc_entry(ACPI_AC_FILE_STATE, - S_IRUGO, acpi_device_dir(device)); + S_IRUGO, acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_AC_FILE_STATE)); + "Unable to create '%s' fs entry\n", + ACPI_AC_FILE_STATE)); else { entry->proc_fops = &acpi_ac_fops; entry->data = acpi_driver_data(device); @@ -177,16 +171,12 @@ acpi_ac_add_fs ( return_VALUE(0); } - -static int -acpi_ac_remove_fs ( - struct acpi_device *device) +static int acpi_ac_remove_fs(struct acpi_device *device) { ACPI_FUNCTION_TRACE("acpi_ac_remove_fs"); if (acpi_device_dir(device)) { - remove_proc_entry(ACPI_AC_FILE_STATE, - acpi_device_dir(device)); + remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device)); remove_proc_entry(acpi_device_bid(device), acpi_ac_dir); acpi_device_dir(device) = NULL; @@ -195,19 +185,14 @@ acpi_ac_remove_fs ( return_VALUE(0); } - /* -------------------------------------------------------------------------- Driver Model -------------------------------------------------------------------------- */ -static void -acpi_ac_notify ( - acpi_handle handle, - u32 event, - void *data) +static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_ac *ac = (struct acpi_ac *) data; - struct acpi_device *device = NULL; + struct acpi_ac *ac = (struct acpi_ac *)data; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_ac_notify"); @@ -224,21 +209,18 @@ acpi_ac_notify ( break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Unsupported event [0x%x]\n", event)); + "Unsupported event [0x%x]\n", event)); break; } return_VOID; } - -static int -acpi_ac_add ( - struct acpi_device *device) +static int acpi_ac_add(struct acpi_device *device) { - int result = 0; - acpi_status status = AE_OK; - struct acpi_ac *ac = NULL; + int result = 0; + acpi_status status = AE_OK; + struct acpi_ac *ac = NULL; ACPI_FUNCTION_TRACE("acpi_ac_add"); @@ -264,19 +246,20 @@ acpi_ac_add ( goto end; status = acpi_install_notify_handler(ac->handle, - ACPI_DEVICE_NOTIFY, acpi_ac_notify, ac); + ACPI_DEVICE_NOTIFY, acpi_ac_notify, + ac); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); + "Error installing notify handler\n")); result = -ENODEV; goto end; } - printk(KERN_INFO PREFIX "%s [%s] (%s)\n", - acpi_device_name(device), acpi_device_bid(device), - ac->state?"on-line":"off-line"); + printk(KERN_INFO PREFIX "%s [%s] (%s)\n", + acpi_device_name(device), acpi_device_bid(device), + ac->state ? "on-line" : "off-line"); -end: + end: if (result) { acpi_ac_remove_fs(device); kfree(ac); @@ -285,27 +268,23 @@ end: return_VALUE(result); } - -static int -acpi_ac_remove ( - struct acpi_device *device, - int type) +static int acpi_ac_remove(struct acpi_device *device, int type) { - acpi_status status = AE_OK; - struct acpi_ac *ac = NULL; + acpi_status status = AE_OK; + struct acpi_ac *ac = NULL; ACPI_FUNCTION_TRACE("acpi_ac_remove"); if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); - ac = (struct acpi_ac *) acpi_driver_data(device); + ac = (struct acpi_ac *)acpi_driver_data(device); status = acpi_remove_notify_handler(ac->handle, - ACPI_DEVICE_NOTIFY, acpi_ac_notify); + ACPI_DEVICE_NOTIFY, acpi_ac_notify); if (ACPI_FAILURE(status)) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); + "Error removing notify handler\n")); acpi_ac_remove_fs(device); @@ -314,11 +293,9 @@ acpi_ac_remove ( return_VALUE(0); } - -static int __init -acpi_ac_init (void) +static int __init acpi_ac_init(void) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_ac_init"); @@ -336,9 +313,7 @@ acpi_ac_init (void) return_VALUE(0); } - -static void __exit -acpi_ac_exit (void) +static void __exit acpi_ac_exit(void) { ACPI_FUNCTION_TRACE("acpi_ac_exit"); @@ -349,6 +324,5 @@ acpi_ac_exit (void) return_VOID; } - module_init(acpi_ac_init); module_exit(acpi_ac_exit); diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 77285ff..01a1bd2 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -32,7 +32,6 @@ #include #include - #define ACPI_MEMORY_DEVICE_COMPONENT 0x08000000UL #define ACPI_MEMORY_DEVICE_CLASS "memory" #define ACPI_MEMORY_DEVICE_HID "PNP0C80" @@ -41,8 +40,8 @@ #define _COMPONENT ACPI_MEMORY_DEVICE_COMPONENT -ACPI_MODULE_NAME ("acpi_memory") -MODULE_AUTHOR("Naveen B S "); +ACPI_MODULE_NAME("acpi_memory") + MODULE_AUTHOR("Naveen B S "); MODULE_DESCRIPTION(ACPI_MEMORY_DEVICE_DRIVER_NAME); MODULE_LICENSE("GPL"); @@ -56,34 +55,33 @@ MODULE_LICENSE("GPL"); #define MEMORY_POWER_ON_STATE 1 #define MEMORY_POWER_OFF_STATE 2 -static int acpi_memory_device_add (struct acpi_device *device); -static int acpi_memory_device_remove (struct acpi_device *device, int type); +static int acpi_memory_device_add(struct acpi_device *device); +static int acpi_memory_device_remove(struct acpi_device *device, int type); static struct acpi_driver acpi_memory_device_driver = { - .name = ACPI_MEMORY_DEVICE_DRIVER_NAME, - .class = ACPI_MEMORY_DEVICE_CLASS, - .ids = ACPI_MEMORY_DEVICE_HID, - .ops = { - .add = acpi_memory_device_add, - .remove = acpi_memory_device_remove, - }, + .name = ACPI_MEMORY_DEVICE_DRIVER_NAME, + .class = ACPI_MEMORY_DEVICE_CLASS, + .ids = ACPI_MEMORY_DEVICE_HID, + .ops = { + .add = acpi_memory_device_add, + .remove = acpi_memory_device_remove, + }, }; struct acpi_memory_device { acpi_handle handle; - unsigned int state; /* State of the memory device */ + unsigned int state; /* State of the memory device */ unsigned short cache_attribute; /* memory cache attribute */ - unsigned short read_write_attribute;/* memory read/write attribute */ - u64 start_addr; /* Memory Range start physical addr */ - u64 end_addr; /* Memory Range end physical addr */ + unsigned short read_write_attribute; /* memory read/write attribute */ + u64 start_addr; /* Memory Range start physical addr */ + u64 end_addr; /* Memory Range end physical addr */ }; - static int acpi_memory_get_device_resources(struct acpi_memory_device *mem_device) { acpi_status status; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_resource *resource = NULL; struct acpi_resource_address64 address64; @@ -94,15 +92,15 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device) if (ACPI_FAILURE(status)) return_VALUE(-EINVAL); - resource = (struct acpi_resource *) buffer.pointer; + resource = (struct acpi_resource *)buffer.pointer; status = acpi_resource_to_address64(resource, &address64); if (ACPI_SUCCESS(status)) { if (address64.resource_type == ACPI_MEMORY_RANGE) { /* Populate the structure */ mem_device->cache_attribute = - address64.attribute.memory.cache_attribute; + address64.attribute.memory.cache_attribute; mem_device->read_write_attribute = - address64.attribute.memory.read_write_attribute; + address64.attribute.memory.read_write_attribute; mem_device->start_addr = address64.min_address_range; mem_device->end_addr = address64.max_address_range; } @@ -114,7 +112,7 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device) static int acpi_memory_get_device(acpi_handle handle, - struct acpi_memory_device **mem_device) + struct acpi_memory_device **mem_device) { acpi_status status; acpi_handle phandle; @@ -128,8 +126,7 @@ acpi_memory_get_device(acpi_handle handle, status = acpi_get_parent(handle, &phandle); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error in acpi_get_parent\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_get_parent\n")); return_VALUE(-EINVAL); } @@ -137,7 +134,7 @@ acpi_memory_get_device(acpi_handle handle, status = acpi_bus_get_device(phandle, &pdevice); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error in acpi_bus_get_device\n")); + "Error in acpi_bus_get_device\n")); return_VALUE(-EINVAL); } @@ -147,23 +144,21 @@ acpi_memory_get_device(acpi_handle handle, */ status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error in acpi_bus_add\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_bus_add\n")); return_VALUE(-EINVAL); } -end: + end: *mem_device = acpi_driver_data(device); if (!(*mem_device)) { - printk(KERN_ERR "\n driver data not found" ); + printk(KERN_ERR "\n driver data not found"); return_VALUE(-ENODEV); } return_VALUE(0); } -static int -acpi_memory_check_device(struct acpi_memory_device *mem_device) +static int acpi_memory_check_device(struct acpi_memory_device *mem_device) { unsigned long current_status; @@ -171,22 +166,21 @@ acpi_memory_check_device(struct acpi_memory_device *mem_device) /* Get device present/absent information from the _STA */ if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA", - NULL, ¤t_status))) + NULL, ¤t_status))) return_VALUE(-ENODEV); /* * Check for device status. Device should be * present/enabled/functioning. */ if (!((current_status & ACPI_MEMORY_STA_PRESENT) - && (current_status & ACPI_MEMORY_STA_ENABLED) - && (current_status & ACPI_MEMORY_STA_FUNCTIONAL))) + && (current_status & ACPI_MEMORY_STA_ENABLED) + && (current_status & ACPI_MEMORY_STA_FUNCTIONAL))) return_VALUE(-ENODEV); return_VALUE(0); } -static int -acpi_memory_enable_device(struct acpi_memory_device *mem_device) +static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) { int result; @@ -196,7 +190,7 @@ acpi_memory_enable_device(struct acpi_memory_device *mem_device) result = acpi_memory_get_device_resources(mem_device); if (result) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "\nget_device_resources failed\n")); + "\nget_device_resources failed\n")); mem_device->state = MEMORY_INVALID_STATE; return result; } @@ -206,11 +200,10 @@ acpi_memory_enable_device(struct acpi_memory_device *mem_device) * Note: Assume that this function returns zero on success */ result = add_memory(mem_device->start_addr, - (mem_device->end_addr - mem_device->start_addr) + 1, - mem_device->read_write_attribute); + (mem_device->end_addr - mem_device->start_addr) + 1, + mem_device->read_write_attribute); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "\nadd_memory failed\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "\nadd_memory failed\n")); mem_device->state = MEMORY_INVALID_STATE; return result; } @@ -218,11 +211,10 @@ acpi_memory_enable_device(struct acpi_memory_device *mem_device) return result; } -static int -acpi_memory_powerdown_device(struct acpi_memory_device *mem_device) +static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device) { acpi_status status; - struct acpi_object_list arg_list; + struct acpi_object_list arg_list; union acpi_object arg; unsigned long current_status; @@ -234,16 +226,16 @@ acpi_memory_powerdown_device(struct acpi_memory_device *mem_device) arg.type = ACPI_TYPE_INTEGER; arg.integer.value = 1; status = acpi_evaluate_object(mem_device->handle, - "_EJ0", &arg_list, NULL); + "_EJ0", &arg_list, NULL); /* Return on _EJ0 failure */ if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"_EJ0 failed.\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_EJ0 failed.\n")); return_VALUE(-ENODEV); } /* Evalute _STA to check if the device is disabled */ status = acpi_evaluate_integer(mem_device->handle, "_STA", - NULL, ¤t_status); + NULL, ¤t_status); if (ACPI_FAILURE(status)) return_VALUE(-ENODEV); @@ -254,8 +246,7 @@ acpi_memory_powerdown_device(struct acpi_memory_device *mem_device) return_VALUE(0); } -static int -acpi_memory_disable_device(struct acpi_memory_device *mem_device) +static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) { int result; u64 start = mem_device->start_addr; @@ -278,7 +269,7 @@ acpi_memory_disable_device(struct acpi_memory_device *mem_device) result = acpi_memory_powerdown_device(mem_device); if (result) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Device Power Down failed.\n")); + "Device Power Down failed.\n")); /* Set the status of the device to invalid */ mem_device->state = MEMORY_INVALID_STATE; return result; @@ -288,8 +279,7 @@ acpi_memory_disable_device(struct acpi_memory_device *mem_device) return result; } -static void -acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) +static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) { struct acpi_memory_device *mem_device; struct acpi_device *device; @@ -299,37 +289,37 @@ acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) switch (event) { case ACPI_NOTIFY_BUS_CHECK: ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "\nReceived BUS CHECK notification for device\n")); + "\nReceived BUS CHECK notification for device\n")); /* Fall Through */ case ACPI_NOTIFY_DEVICE_CHECK: if (event == ACPI_NOTIFY_DEVICE_CHECK) ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "\nReceived DEVICE CHECK notification for device\n")); + "\nReceived DEVICE CHECK notification for device\n")); if (acpi_memory_get_device(handle, &mem_device)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error in finding driver data\n")); + "Error in finding driver data\n")); return_VOID; } if (!acpi_memory_check_device(mem_device)) { if (acpi_memory_enable_device(mem_device)) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error in acpi_memory_enable_device\n")); + "Error in acpi_memory_enable_device\n")); } break; case ACPI_NOTIFY_EJECT_REQUEST: ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "\nReceived EJECT REQUEST notification for device\n")); + "\nReceived EJECT REQUEST notification for device\n")); if (acpi_bus_get_device(handle, &device)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Device doesn't exist\n")); + "Device doesn't exist\n")); break; } mem_device = acpi_driver_data(device); if (!mem_device) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Driver Data is NULL\n")); + "Driver Data is NULL\n")); break; } @@ -337,26 +327,25 @@ acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) * Currently disabling memory device from kernel mode * TBD: Can also be disabled from user mode scripts * TBD: Can also be disabled by Callback registration - * with generic sysfs driver + * with generic sysfs driver */ if (acpi_memory_disable_device(mem_device)) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error in acpi_memory_disable_device\n")); + "Error in acpi_memory_disable_device\n")); /* * TBD: Invoke acpi_bus_remove to cleanup data structures */ break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Unsupported event [0x%x]\n", event)); + "Unsupported event [0x%x]\n", event)); break; } return_VOID; } -static int -acpi_memory_device_add(struct acpi_device *device) +static int acpi_memory_device_add(struct acpi_device *device) { int result; struct acpi_memory_device *mem_device = NULL; @@ -391,8 +380,7 @@ acpi_memory_device_add(struct acpi_device *device) return_VALUE(result); } -static int -acpi_memory_device_remove (struct acpi_device *device, int type) +static int acpi_memory_device_remove(struct acpi_device *device, int type) { struct acpi_memory_device *mem_device = NULL; @@ -401,7 +389,7 @@ acpi_memory_device_remove (struct acpi_device *device, int type) if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); - mem_device = (struct acpi_memory_device *) acpi_driver_data(device); + mem_device = (struct acpi_memory_device *)acpi_driver_data(device); kfree(mem_device); return_VALUE(0); @@ -410,12 +398,11 @@ acpi_memory_device_remove (struct acpi_device *device, int type) /* * Helper function to check for memory device */ -static acpi_status -is_memory_device(acpi_handle handle) +static acpi_status is_memory_device(acpi_handle handle) { char *hardware_id; acpi_status status; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_device_info *info; ACPI_FUNCTION_TRACE("is_memory_device"); @@ -432,7 +419,7 @@ is_memory_device(acpi_handle handle) hardware_id = info->hardware_id.value; if ((hardware_id == NULL) || - (strcmp(hardware_id, ACPI_MEMORY_DEVICE_HID))) + (strcmp(hardware_id, ACPI_MEMORY_DEVICE_HID))) status = AE_ERROR; acpi_os_free(buffer.pointer); @@ -440,8 +427,8 @@ is_memory_device(acpi_handle handle) } static acpi_status -acpi_memory_register_notify_handler (acpi_handle handle, - u32 level, void *ctxt, void **retv) +acpi_memory_register_notify_handler(acpi_handle handle, + u32 level, void *ctxt, void **retv) { acpi_status status; @@ -452,10 +439,10 @@ acpi_memory_register_notify_handler (acpi_handle handle, return_ACPI_STATUS(AE_OK); /* continue */ status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, - acpi_memory_device_notify, NULL); + acpi_memory_device_notify, NULL); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); + "Error installing notify handler\n")); return_ACPI_STATUS(AE_OK); /* continue */ } @@ -463,8 +450,8 @@ acpi_memory_register_notify_handler (acpi_handle handle, } static acpi_status -acpi_memory_deregister_notify_handler (acpi_handle handle, - u32 level, void *ctxt, void **retv) +acpi_memory_deregister_notify_handler(acpi_handle handle, + u32 level, void *ctxt, void **retv) { acpi_status status; @@ -475,18 +462,18 @@ acpi_memory_deregister_notify_handler (acpi_handle handle, return_ACPI_STATUS(AE_OK); /* continue */ status = acpi_remove_notify_handler(handle, - ACPI_SYSTEM_NOTIFY, acpi_memory_device_notify); + ACPI_SYSTEM_NOTIFY, + acpi_memory_device_notify); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); + "Error removing notify handler\n")); return_ACPI_STATUS(AE_OK); /* continue */ } return_ACPI_STATUS(status); } -static int __init -acpi_memory_device_init (void) +static int __init acpi_memory_device_init(void) { int result; acpi_status status; @@ -499,21 +486,20 @@ acpi_memory_device_init (void) return_VALUE(-ENODEV); status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, - acpi_memory_register_notify_handler, - NULL, NULL); + ACPI_UINT32_MAX, + acpi_memory_register_notify_handler, + NULL, NULL); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed\n")); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n")); acpi_bus_unregister_driver(&acpi_memory_device_driver); return_VALUE(-ENODEV); - } + } return_VALUE(0); } -static void __exit -acpi_memory_device_exit (void) +static void __exit acpi_memory_device_exit(void) { acpi_status status; @@ -524,12 +510,12 @@ acpi_memory_device_exit (void) * handles. */ status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, - acpi_memory_deregister_notify_handler, - NULL, NULL); + ACPI_UINT32_MAX, + acpi_memory_deregister_notify_handler, + NULL, NULL); - if (ACPI_FAILURE (status)) - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed\n")); + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n")); acpi_bus_unregister_driver(&acpi_memory_device_driver); @@ -538,5 +524,3 @@ acpi_memory_device_exit (void) module_init(acpi_memory_device_init); module_exit(acpi_memory_device_exit); - - diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c index a560b1e..fec895a 100644 --- a/drivers/acpi/asus_acpi.c +++ b/drivers/acpi/asus_acpi.c @@ -61,7 +61,7 @@ /* * Some events we use, same for all Asus */ -#define BR_UP 0x10 +#define BR_UP 0x10 #define BR_DOWN 0x20 /* @@ -75,7 +75,6 @@ MODULE_AUTHOR("Julien Lerouge, Karol Kozimor"); MODULE_DESCRIPTION(ACPI_HOTK_NAME); MODULE_LICENSE("GPL"); - static uid_t asus_uid; static gid_t asus_gid; module_param(asus_uid, uint, 0); @@ -83,26 +82,25 @@ MODULE_PARM_DESC(uid, "UID for entries in /proc/acpi/asus.\n"); module_param(asus_gid, uint, 0); MODULE_PARM_DESC(gid, "GID for entries in /proc/acpi/asus.\n"); - /* For each model, all features implemented, * those marked with R are relative to HOTK, A for absolute */ struct model_data { - char *name; //name of the laptop________________A - char *mt_mled; //method to handle mled_____________R - char *mled_status; //node to handle mled reading_______A - char *mt_wled; //method to handle wled_____________R - char *wled_status; //node to handle wled reading_______A - char *mt_tled; //method to handle tled_____________R - char *tled_status; //node to handle tled reading_______A - char *mt_lcd_switch; //method to turn LCD ON/OFF_________A - char *lcd_status; //node to read LCD panel state______A - char *brightness_up; //method to set brightness up_______A - char *brightness_down; //guess what ?______________________A - char *brightness_set; //method to set absolute brightness_R - char *brightness_get; //method to get absolute brightness_R - char *brightness_status; //node to get brightness____________A - char *display_set; //method to set video output________R - char *display_get; //method to get video output________R + char *name; //name of the laptop________________A + char *mt_mled; //method to handle mled_____________R + char *mled_status; //node to handle mled reading_______A + char *mt_wled; //method to handle wled_____________R + char *wled_status; //node to handle wled reading_______A + char *mt_tled; //method to handle tled_____________R + char *tled_status; //node to handle tled reading_______A + char *mt_lcd_switch; //method to turn LCD ON/OFF_________A + char *lcd_status; //node to read LCD panel state______A + char *brightness_up; //method to set brightness up_______A + char *brightness_down; //guess what ?______________________A + char *brightness_set; //method to set absolute brightness_R + char *brightness_get; //method to get absolute brightness_R + char *brightness_status; //node to get brightness____________A + char *display_set; //method to set video output________R + char *display_get; //method to get video output________R }; /* @@ -110,34 +108,34 @@ struct model_data { * about the hotk device */ struct asus_hotk { - struct acpi_device *device; //the device we are in - acpi_handle handle; //the handle of the hotk device - char status; //status of the hotk, for LEDs, ... - struct model_data *methods; //methods available on the laptop - u8 brightness; //brightness level + struct acpi_device *device; //the device we are in + acpi_handle handle; //the handle of the hotk device + char status; //status of the hotk, for LEDs, ... + struct model_data *methods; //methods available on the laptop + u8 brightness; //brightness level enum { - A1x = 0, //A1340D, A1300F - A2x, //A2500H - D1x, //D1 - L2D, //L2000D - L3C, //L3800C - L3D, //L3400D - L3H, //L3H, but also L2000E - L4R, //L4500R - L5x, //L5800C - L8L, //L8400L - M1A, //M1300A - M2E, //M2400E, L4400L - M6N, //M6800N - M6R, //M6700R - P30, //Samsung P30 - S1x, //S1300A, but also L1400B and M2400A (L84F) - S2x, //S200 (J1 reported), Victor MP-XP7210 - xxN, //M2400N, M3700N, M5200N, S1300N, S5200N, W1OOON - //(Centrino) + A1x = 0, //A1340D, A1300F + A2x, //A2500H + D1x, //D1 + L2D, //L2000D + L3C, //L3800C + L3D, //L3400D + L3H, //L3H, but also L2000E + L4R, //L4500R + L5x, //L5800C + L8L, //L8400L + M1A, //M1300A + M2E, //M2400E, L4400L + M6N, //M6800N + M6R, //M6700R + P30, //Samsung P30 + S1x, //S1300A, but also L1400B and M2400A (L84F) + S2x, //S200 (J1 reported), Victor MP-XP7210 + xxN, //M2400N, M3700N, M5200N, S1300N, S5200N, W1OOON + //(Centrino) END_MODEL - } model; //Models currently supported - u16 event_count[128]; //count for each event TODO make this better + } model; //Models currently supported + u16 event_count[128]; //count for each event TODO make this better }; /* Here we go */ @@ -150,7 +148,7 @@ struct asus_hotk { #define xxN_PREFIX "\\_SB.PCI0.SBRG.EC0." static struct model_data model_conf[END_MODEL] = { - /* + /* * Those pathnames are relative to the HOTK / ATKD device : * - mt_mled * - mt_wled @@ -165,215 +163,197 @@ static struct model_data model_conf[END_MODEL] = { */ { - .name = "A1x", - .mt_mled = "MLED", - .mled_status = "\\MAIL", - .mt_lcd_switch = A1x_PREFIX "_Q10", - .lcd_status = "\\BKLI", - .brightness_up = A1x_PREFIX "_Q0E", - .brightness_down = A1x_PREFIX "_Q0F" - }, + .name = "A1x", + .mt_mled = "MLED", + .mled_status = "\\MAIL", + .mt_lcd_switch = A1x_PREFIX "_Q10", + .lcd_status = "\\BKLI", + .brightness_up = A1x_PREFIX "_Q0E", + .brightness_down = A1x_PREFIX "_Q0F"}, { - .name = "A2x", - .mt_mled = "MLED", - .mt_wled = "WLED", - .wled_status = "\\SG66", - .mt_lcd_switch = "\\Q10", - .lcd_status = "\\BAOF", - .brightness_set = "SPLV", - .brightness_get = "GPLV", - .display_set = "SDSP", - .display_get = "\\INFB" - }, + .name = "A2x", + .mt_mled = "MLED", + .mt_wled = "WLED", + .wled_status = "\\SG66", + .mt_lcd_switch = "\\Q10", + .lcd_status = "\\BAOF", + .brightness_set = "SPLV", + .brightness_get = "GPLV", + .display_set = "SDSP", + .display_get = "\\INFB"}, { - .name = "D1x", - .mt_mled = "MLED", - .mt_lcd_switch = "\\Q0D", - .lcd_status = "\\GP11", - .brightness_up = "\\Q0C", - .brightness_down = "\\Q0B", - .brightness_status = "\\BLVL", - .display_set = "SDSP", - .display_get = "\\INFB" - }, + .name = "D1x", + .mt_mled = "MLED", + .mt_lcd_switch = "\\Q0D", + .lcd_status = "\\GP11", + .brightness_up = "\\Q0C", + .brightness_down = "\\Q0B", + .brightness_status = "\\BLVL", + .display_set = "SDSP", + .display_get = "\\INFB"}, { - .name = "L2D", - .mt_mled = "MLED", - .mled_status = "\\SGP6", - .mt_wled = "WLED", - .wled_status = "\\RCP3", - .mt_lcd_switch = "\\Q10", - .lcd_status = "\\SGP0", - .brightness_up = "\\Q0E", - .brightness_down = "\\Q0F", - .display_set = "SDSP", - .display_get = "\\INFB" - }, + .name = "L2D", + .mt_mled = "MLED", + .mled_status = "\\SGP6", + .mt_wled = "WLED", + .wled_status = "\\RCP3", + .mt_lcd_switch = "\\Q10", + .lcd_status = "\\SGP0", + .brightness_up = "\\Q0E", + .brightness_down = "\\Q0F", + .display_set = "SDSP", + .display_get = "\\INFB"}, { - .name = "L3C", - .mt_mled = "MLED", - .mt_wled = "WLED", - .mt_lcd_switch = L3C_PREFIX "_Q10", - .lcd_status = "\\GL32", - .brightness_set = "SPLV", - .brightness_get = "GPLV", - .display_set = "SDSP", - .display_get = "\\_SB.PCI0.PCI1.VGAC.NMAP" - }, + .name = "L3C", + .mt_mled = "MLED", + .mt_wled = "WLED", + .mt_lcd_switch = L3C_PREFIX "_Q10", + .lcd_status = "\\GL32", + .brightness_set = "SPLV", + .brightness_get = "GPLV", + .display_set = "SDSP", + .display_get = "\\_SB.PCI0.PCI1.VGAC.NMAP"}, { - .name = "L3D", - .mt_mled = "MLED", - .mled_status = "\\MALD", - .mt_wled = "WLED", - .mt_lcd_switch = "\\Q10", - .lcd_status = "\\BKLG", - .brightness_set = "SPLV", - .brightness_get = "GPLV", - .display_set = "SDSP", - .display_get = "\\INFB" - }, + .name = "L3D", + .mt_mled = "MLED", + .mled_status = "\\MALD", + .mt_wled = "WLED", + .mt_lcd_switch = "\\Q10", + .lcd_status = "\\BKLG", + .brightness_set = "SPLV", + .brightness_get = "GPLV", + .display_set = "SDSP", + .display_get = "\\INFB"}, { - .name = "L3H", - .mt_mled = "MLED", - .mt_wled = "WLED", - .mt_lcd_switch = "EHK", - .lcd_status = "\\_SB.PCI0.PM.PBC", - .brightness_set = "SPLV", - .brightness_get = "GPLV", - .display_set = "SDSP", - .display_get = "\\INFB" - }, + .name = "L3H", + .mt_mled = "MLED", + .mt_wled = "WLED", + .mt_lcd_switch = "EHK", + .lcd_status = "\\_SB.PCI0.PM.PBC", + .brightness_set = "SPLV", + .brightness_get = "GPLV", + .display_set = "SDSP", + .display_get = "\\INFB"}, { - .name = "L4R", - .mt_mled = "MLED", - .mt_wled = "WLED", - .wled_status = "\\_SB.PCI0.SBRG.SG13", - .mt_lcd_switch = xxN_PREFIX "_Q10", - .lcd_status = "\\_SB.PCI0.SBSM.SEO4", - .brightness_set = "SPLV", - .brightness_get = "GPLV", - .display_set = "SDSP", - .display_get = "\\_SB.PCI0.P0P1.VGA.GETD" - }, + .name = "L4R", + .mt_mled = "MLED", + .mt_wled = "WLED", + .wled_status = "\\_SB.PCI0.SBRG.SG13", + .mt_lcd_switch = xxN_PREFIX "_Q10", + .lcd_status = "\\_SB.PCI0.SBSM.SEO4", + .brightness_set = "SPLV", + .brightness_get = "GPLV", + .display_set = "SDSP", + .display_get = "\\_SB.PCI0.P0P1.VGA.GETD"}, { - .name = "L5x", - .mt_mled = "MLED", + .name = "L5x", + .mt_mled = "MLED", /* WLED present, but not controlled by ACPI */ - .mt_tled = "TLED", - .mt_lcd_switch = "\\Q0D", - .lcd_status = "\\BAOF", - .brightness_set = "SPLV", - .brightness_get = "GPLV", - .display_set = "SDSP", - .display_get = "\\INFB" - }, + .mt_tled = "TLED", + .mt_lcd_switch = "\\Q0D", + .lcd_status = "\\BAOF", + .brightness_set = "SPLV", + .brightness_get = "GPLV", + .display_set = "SDSP", + .display_get = "\\INFB"}, { - .name = "L8L" + .name = "L8L" /* No features, but at least support the hotkeys */ - }, + }, { - .name = "M1A", - .mt_mled = "MLED", - .mt_lcd_switch = M1A_PREFIX "Q10", - .lcd_status = "\\PNOF", - .brightness_up = M1A_PREFIX "Q0E", - .brightness_down = M1A_PREFIX "Q0F", - .brightness_status = "\\BRIT", - .display_set = "SDSP", - .display_get = "\\INFB" - }, + .name = "M1A", + .mt_mled = "MLED", + .mt_lcd_switch = M1A_PREFIX "Q10", + .lcd_status = "\\PNOF", + .brightness_up = M1A_PREFIX "Q0E", + .brightness_down = M1A_PREFIX "Q0F", + .brightness_status = "\\BRIT", + .display_set = "SDSP", + .display_get = "\\INFB"}, { - .name = "M2E", - .mt_mled = "MLED", - .mt_wled = "WLED", - .mt_lcd_switch = "\\Q10", - .lcd_status = "\\GP06", - .brightness_set = "SPLV", - .brightness_get = "GPLV", - .display_set = "SDSP", - .display_get = "\\INFB" - }, + .name = "M2E", + .mt_mled = "MLED", + .mt_wled = "WLED", + .mt_lcd_switch = "\\Q10", + .lcd_status = "\\GP06", + .brightness_set = "SPLV", + .brightness_get = "GPLV", + .display_set = "SDSP", + .display_get = "\\INFB"}, { - .name = "M6N", - .mt_mled = "MLED", - .mt_wled = "WLED", - .wled_status = "\\_SB.PCI0.SBRG.SG13", - .mt_lcd_switch = xxN_PREFIX "_Q10", - .lcd_status = "\\_SB.BKLT", - .brightness_set = "SPLV", - .brightness_get = "GPLV", - .display_set = "SDSP", - .display_get = "\\SSTE" - }, + .name = "M6N", + .mt_mled = "MLED", + .mt_wled = "WLED", + .wled_status = "\\_SB.PCI0.SBRG.SG13", + .mt_lcd_switch = xxN_PREFIX "_Q10", + .lcd_status = "\\_SB.BKLT", + .brightness_set = "SPLV", + .brightness_get = "GPLV", + .display_set = "SDSP", + .display_get = "\\SSTE"}, { - .name = "M6R", - .mt_mled = "MLED", - .mt_wled = "WLED", - .mt_lcd_switch = xxN_PREFIX "_Q10", - .lcd_status = "\\_SB.PCI0.SBSM.SEO4", - .brightness_set = "SPLV", - .brightness_get = "GPLV", - .display_set = "SDSP", - .display_get = "\\SSTE" - }, - + .name = "M6R", + .mt_mled = "MLED", + .mt_wled = "WLED", + .mt_lcd_switch = xxN_PREFIX "_Q10", + .lcd_status = "\\_SB.PCI0.SBSM.SEO4", + .brightness_set = "SPLV", + .brightness_get = "GPLV", + .display_set = "SDSP", + .display_get = "\\SSTE"}, { - .name = "P30", - .mt_wled = "WLED", - .mt_lcd_switch = P30_PREFIX "_Q0E", - .lcd_status = "\\BKLT", - .brightness_up = P30_PREFIX "_Q68", - .brightness_down = P30_PREFIX "_Q69", - .brightness_get = "GPLV", - .display_set = "SDSP", - .display_get = "\\DNXT" - }, + .name = "P30", + .mt_wled = "WLED", + .mt_lcd_switch = P30_PREFIX "_Q0E", + .lcd_status = "\\BKLT", + .brightness_up = P30_PREFIX "_Q68", + .brightness_down = P30_PREFIX "_Q69", + .brightness_get = "GPLV", + .display_set = "SDSP", + .display_get = "\\DNXT"}, { - .name = "S1x", - .mt_mled = "MLED", - .mled_status = "\\EMLE", - .mt_wled = "WLED", - .mt_lcd_switch = S1x_PREFIX "Q10" , - .lcd_status = "\\PNOF", - .brightness_set = "SPLV", - .brightness_get = "GPLV" - }, + .name = "S1x", + .mt_mled = "MLED", + .mled_status = "\\EMLE", + .mt_wled = "WLED", + .mt_lcd_switch = S1x_PREFIX "Q10", + .lcd_status = "\\PNOF", + .brightness_set = "SPLV", + .brightness_get = "GPLV"}, { - .name = "S2x", - .mt_mled = "MLED", - .mled_status = "\\MAIL", - .mt_lcd_switch = S2x_PREFIX "_Q10", - .lcd_status = "\\BKLI", - .brightness_up = S2x_PREFIX "_Q0B", - .brightness_down = S2x_PREFIX "_Q0A" - }, + .name = "S2x", + .mt_mled = "MLED", + .mled_status = "\\MAIL", + .mt_lcd_switch = S2x_PREFIX "_Q10", + .lcd_status = "\\BKLI", + .brightness_up = S2x_PREFIX "_Q0B", + .brightness_down = S2x_PREFIX "_Q0A"}, { - .name = "xxN", - .mt_mled = "MLED", + .name = "xxN", + .mt_mled = "MLED", /* WLED present, but not controlled by ACPI */ - .mt_lcd_switch = xxN_PREFIX "_Q10", - .lcd_status = "\\BKLT", - .brightness_set = "SPLV", - .brightness_get = "GPLV", - .display_set = "SDSP", - .display_get = "\\ADVG" - } + .mt_lcd_switch = xxN_PREFIX "_Q10", + .lcd_status = "\\BKLT", + .brightness_set = "SPLV", + .brightness_get = "GPLV", + .display_set = "SDSP", + .display_get = "\\ADVG"} }; /* procdir we use */ @@ -395,13 +375,13 @@ static struct asus_hotk *hotk; static int asus_hotk_add(struct acpi_device *device); static int asus_hotk_remove(struct acpi_device *device, int type); static struct acpi_driver asus_hotk_driver = { - .name = ACPI_HOTK_NAME, - .class = ACPI_HOTK_CLASS, - .ids = ACPI_HOTK_HID, - .ops = { - .add = asus_hotk_add, - .remove = asus_hotk_remove, - }, + .name = ACPI_HOTK_NAME, + .class = ACPI_HOTK_CLASS, + .ids = ACPI_HOTK_HID, + .ops = { + .add = asus_hotk_add, + .remove = asus_hotk_remove, + }, }; /* @@ -423,11 +403,10 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val, in_obj.type = ACPI_TYPE_INTEGER; in_obj.integer.value = val; - status = acpi_evaluate_object(handle, (char *) method, ¶ms, output); + status = acpi_evaluate_object(handle, (char *)method, ¶ms, output); return (status == AE_OK); } - static int read_acpi_int(acpi_handle handle, const char *method, int *val) { struct acpi_buffer output; @@ -437,7 +416,7 @@ static int read_acpi_int(acpi_handle handle, const char *method, int *val) output.length = sizeof(out_obj); output.pointer = &out_obj; - status = acpi_evaluate_object(handle, (char *) method, NULL, &output); + status = acpi_evaluate_object(handle, (char *)method, NULL, &output); *val = out_obj.integer.value; return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER); } @@ -449,7 +428,7 @@ static int read_acpi_int(acpi_handle handle, const char *method, int *val) */ static int proc_read_info(char *page, char **start, off_t off, int count, int *eof, - void *data) + void *data) { int len = 0; int temp; @@ -460,7 +439,7 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof, */ len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n"); - len += sprintf(page + len, "Model reference : %s\n", + len += sprintf(page + len, "Model reference : %s\n", hotk->methods->name); /* * The SFUN method probably allows the original driver to get the list @@ -469,7 +448,8 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof, * The significance of others is yet to be found. */ if (read_acpi_int(hotk->handle, "SFUN", &temp)) - len += sprintf(page + len, "SFUN value : 0x%04x\n", temp); + len += + sprintf(page + len, "SFUN value : 0x%04x\n", temp); /* * Another value for userspace: the ASYM method returns 0x02 for * battery low and 0x04 for battery critical, its readings tend to be @@ -478,7 +458,8 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof, * silently ignored. */ if (read_acpi_int(hotk->handle, "ASYM", &temp)) - len += sprintf(page + len, "ASYM value : 0x%04x\n", temp); + len += + sprintf(page + len, "ASYM value : 0x%04x\n", temp); if (asus_info) { snprintf(buf, 16, "%d", asus_info->length); len += sprintf(page + len, "DSDT length : %s\n", buf); @@ -501,7 +482,6 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof, return len; } - /* * /proc handlers * We write our info in page, we begin at offset off and cannot write more @@ -510,8 +490,7 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof, */ /* Generic LED functions */ -static int -read_led(const char *ledname, int ledmask) +static int read_led(const char *ledname, int ledmask) { if (ledname) { int led_status; @@ -525,7 +504,7 @@ read_led(const char *ledname, int ledmask) return (hotk->status & ledmask) ? 1 : 0; } -static int parse_arg(const char __user *buf, unsigned long count, int *val) +static int parse_arg(const char __user * buf, unsigned long count, int *val) { char s[32]; if (!count) @@ -542,8 +521,8 @@ static int parse_arg(const char __user *buf, unsigned long count, int *val) /* FIXME: kill extraneous args so it can be called independently */ static int -write_led(const char __user *buffer, unsigned long count, - char *ledname, int ledmask, int invert) +write_led(const char __user * buffer, unsigned long count, + char *ledname, int ledmask, int invert) { int value; int led_out = 0; @@ -555,16 +534,16 @@ write_led(const char __user *buffer, unsigned long count, hotk->status = (led_out) ? (hotk->status | ledmask) : (hotk->status & ~ledmask); - if (invert) /* invert target value */ + if (invert) /* invert target value */ led_out = !led_out & 0x1; if (!write_acpi_int(hotk->handle, ledname, led_out, NULL)) - printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n", ledname); + printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n", + ledname); return count; } - /* * Proc handlers for MLED */ @@ -572,12 +551,12 @@ static int proc_read_mled(char *page, char **start, off_t off, int count, int *eof, void *data) { - return sprintf(page, "%d\n", read_led(hotk->methods->mled_status, MLED_ON)); + return sprintf(page, "%d\n", + read_led(hotk->methods->mled_status, MLED_ON)); } - static int -proc_write_mled(struct file *file, const char __user *buffer, +proc_write_mled(struct file *file, const char __user * buffer, unsigned long count, void *data) { return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1); @@ -590,11 +569,12 @@ static int proc_read_wled(char *page, char **start, off_t off, int count, int *eof, void *data) { - return sprintf(page, "%d\n", read_led(hotk->methods->wled_status, WLED_ON)); + return sprintf(page, "%d\n", + read_led(hotk->methods->wled_status, WLED_ON)); } static int -proc_write_wled(struct file *file, const char __user *buffer, +proc_write_wled(struct file *file, const char __user * buffer, unsigned long count, void *data) { return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0); @@ -607,35 +587,36 @@ static int proc_read_tled(char *page, char **start, off_t off, int count, int *eof, void *data) { - return sprintf(page, "%d\n", read_led(hotk->methods->tled_status, TLED_ON)); + return sprintf(page, "%d\n", + read_led(hotk->methods->tled_status, TLED_ON)); } static int -proc_write_tled(struct file *file, const char __user *buffer, +proc_write_tled(struct file *file, const char __user * buffer, unsigned long count, void *data) { return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0); } - static int get_lcd_state(void) { int lcd = 0; if (hotk->model != L3H) { - /* We don't have to check anything if we are here */ + /* We don't have to check anything if we are here */ if (!read_acpi_int(NULL, hotk->methods->lcd_status, &lcd)) - printk(KERN_WARNING "Asus ACPI: Error reading LCD status\n"); - + printk(KERN_WARNING + "Asus ACPI: Error reading LCD status\n"); + if (hotk->model == L2D) lcd = ~lcd; - } else { /* L3H and the like have to be handled differently */ + } else { /* L3H and the like have to be handled differently */ acpi_status status = 0; struct acpi_object_list input; union acpi_object mt_params[2]; struct acpi_buffer output; union acpi_object out_obj; - + input.count = 2; input.pointer = mt_params; /* Note: the following values are partly guessed up, but @@ -647,15 +628,17 @@ static int get_lcd_state(void) output.length = sizeof(out_obj); output.pointer = &out_obj; - - status = acpi_evaluate_object(NULL, hotk->methods->lcd_status, &input, &output); + + status = + acpi_evaluate_object(NULL, hotk->methods->lcd_status, + &input, &output); if (status != AE_OK) return -1; if (out_obj.type == ACPI_TYPE_INTEGER) /* That's what the AML code does */ lcd = out_obj.integer.value >> 8; } - + return (lcd & 1); } @@ -669,10 +652,13 @@ static int set_lcd_state(int value) /* switch */ if (hotk->model != L3H) { status = - acpi_evaluate_object(NULL, hotk->methods->mt_lcd_switch, + acpi_evaluate_object(NULL, + hotk->methods->mt_lcd_switch, NULL, NULL); - } else { /* L3H and the like have to be handled differently */ - if (!write_acpi_int(hotk->handle, hotk->methods->mt_lcd_switch, 0x07, NULL)) + } else { /* L3H and the like have to be handled differently */ + if (!write_acpi_int + (hotk->handle, hotk->methods->mt_lcd_switch, 0x07, + NULL)) status = AE_ERROR; /* L3H's AML executes EHK (0x07) upon Fn+F7 keypress, the exact behaviour is simulated here */ @@ -691,33 +677,33 @@ proc_read_lcd(char *page, char **start, off_t off, int count, int *eof, return sprintf(page, "%d\n", get_lcd_state()); } - static int -proc_write_lcd(struct file *file, const char __user *buffer, +proc_write_lcd(struct file *file, const char __user * buffer, unsigned long count, void *data) { int value; - + count = parse_arg(buffer, count, &value); if (count > 0) set_lcd_state(value); return count; } - static int read_brightness(void) { int value; - - if(hotk->methods->brightness_get) { /* SPLV/GPLV laptop */ - if (!read_acpi_int(hotk->handle, hotk->methods->brightness_get, + + if (hotk->methods->brightness_get) { /* SPLV/GPLV laptop */ + if (!read_acpi_int(hotk->handle, hotk->methods->brightness_get, &value)) - printk(KERN_WARNING "Asus ACPI: Error reading brightness\n"); - } else if (hotk->methods->brightness_status) { /* For D1 for example */ - if (!read_acpi_int(NULL, hotk->methods->brightness_status, + printk(KERN_WARNING + "Asus ACPI: Error reading brightness\n"); + } else if (hotk->methods->brightness_status) { /* For D1 for example */ + if (!read_acpi_int(NULL, hotk->methods->brightness_status, &value)) - printk(KERN_WARNING "Asus ACPI: Error reading brightness\n"); - } else /* No GPLV method */ + printk(KERN_WARNING + "Asus ACPI: Error reading brightness\n"); + } else /* No GPLV method */ value = hotk->brightness; return value; } @@ -730,23 +716,25 @@ static void set_brightness(int value) acpi_status status = 0; /* SPLV laptop */ - if(hotk->methods->brightness_set) { - if (!write_acpi_int(hotk->handle, hotk->methods->brightness_set, + if (hotk->methods->brightness_set) { + if (!write_acpi_int(hotk->handle, hotk->methods->brightness_set, value, NULL)) - printk(KERN_WARNING "Asus ACPI: Error changing brightness\n"); + printk(KERN_WARNING + "Asus ACPI: Error changing brightness\n"); return; } /* No SPLV method if we are here, act as appropriate */ value -= read_brightness(); while (value != 0) { - status = acpi_evaluate_object(NULL, (value > 0) ? - hotk->methods->brightness_up : + status = acpi_evaluate_object(NULL, (value > 0) ? + hotk->methods->brightness_up : hotk->methods->brightness_down, NULL, NULL); (value > 0) ? value-- : value++; if (ACPI_FAILURE(status)) - printk(KERN_WARNING "Asus ACPI: Error changing brightness\n"); + printk(KERN_WARNING + "Asus ACPI: Error changing brightness\n"); } return; } @@ -759,7 +747,7 @@ proc_read_brn(char *page, char **start, off_t off, int count, int *eof, } static int -proc_write_brn(struct file *file, const char __user *buffer, +proc_write_brn(struct file *file, const char __user * buffer, unsigned long count, void *data) { int value; @@ -767,7 +755,7 @@ proc_write_brn(struct file *file, const char __user *buffer, count = parse_arg(buffer, count, &value); if (count > 0) { value = (0 < value) ? ((15 < value) ? 15 : value) : 0; - /* 0 <= value <= 15 */ + /* 0 <= value <= 15 */ set_brightness(value); } else if (count < 0) { printk(KERN_WARNING "Asus ACPI: Error reading user input\n"); @@ -779,7 +767,7 @@ proc_write_brn(struct file *file, const char __user *buffer, static void set_display(int value) { /* no sanity check needed for now */ - if (!write_acpi_int(hotk->handle, hotk->methods->display_set, + if (!write_acpi_int(hotk->handle, hotk->methods->display_set, value, NULL)) printk(KERN_WARNING "Asus ACPI: Error setting display\n"); return; @@ -791,13 +779,14 @@ static void set_display(int value) */ static int proc_read_disp(char *page, char **start, off_t off, int count, int *eof, - void *data) + void *data) { int value = 0; - + if (!read_acpi_int(hotk->handle, hotk->methods->display_get, &value)) - printk(KERN_WARNING "Asus ACPI: Error reading display status\n"); - value &= 0x07; /* needed for some models, shouldn't hurt others */ + printk(KERN_WARNING + "Asus ACPI: Error reading display status\n"); + value &= 0x07; /* needed for some models, shouldn't hurt others */ return sprintf(page, "%d\n", value); } @@ -808,8 +797,8 @@ proc_read_disp(char *page, char **start, off_t off, int count, int *eof, * simultaneously, so be warned. See the acpi4asus README for more info. */ static int -proc_write_disp(struct file *file, const char __user *buffer, - unsigned long count, void *data) +proc_write_disp(struct file *file, const char __user * buffer, + unsigned long count, void *data) { int value; @@ -822,19 +811,19 @@ proc_write_disp(struct file *file, const char __user *buffer, return count; } - -typedef int (proc_readfunc)(char *page, char **start, off_t off, int count, - int *eof, void *data); -typedef int (proc_writefunc)(struct file *file, const char __user *buffer, - unsigned long count, void *data); +typedef int (proc_readfunc) (char *page, char **start, off_t off, int count, + int *eof, void *data); +typedef int (proc_writefunc) (struct file * file, const char __user * buffer, + unsigned long count, void *data); static int -__init asus_proc_add(char *name, proc_writefunc *writefunc, - proc_readfunc *readfunc, mode_t mode, - struct acpi_device *device) +__init asus_proc_add(char *name, proc_writefunc * writefunc, + proc_readfunc * readfunc, mode_t mode, + struct acpi_device *device) { - struct proc_dir_entry *proc = create_proc_entry(name, mode, acpi_device_dir(device)); - if(!proc) { + struct proc_dir_entry *proc = + create_proc_entry(name, mode, acpi_device_dir(device)); + if (!proc) { printk(KERN_WARNING " Unable to create %s fs entry\n", name); return -1; } @@ -851,14 +840,14 @@ static int __init asus_hotk_add_fs(struct acpi_device *device) { struct proc_dir_entry *proc; mode_t mode; - + /* * If parameter uid or gid is not changed, keep the default setting for * our proc entries (-rw-rw-rw-) else, it means we care about security, * and then set to -rw-rw---- */ - if ((asus_uid == 0) && (asus_gid == 0)){ + if ((asus_uid == 0) && (asus_gid == 0)) { mode = S_IFREG | S_IRUGO | S_IWUGO; } else { mode = S_IFREG | S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP; @@ -881,15 +870,18 @@ static int __init asus_hotk_add_fs(struct acpi_device *device) } if (hotk->methods->mt_wled) { - asus_proc_add(PROC_WLED, &proc_write_wled, &proc_read_wled, mode, device); + asus_proc_add(PROC_WLED, &proc_write_wled, &proc_read_wled, + mode, device); } if (hotk->methods->mt_mled) { - asus_proc_add(PROC_MLED, &proc_write_mled, &proc_read_mled, mode, device); + asus_proc_add(PROC_MLED, &proc_write_mled, &proc_read_mled, + mode, device); } if (hotk->methods->mt_tled) { - asus_proc_add(PROC_TLED, &proc_write_tled, &proc_read_tled, mode, device); + asus_proc_add(PROC_TLED, &proc_write_tled, &proc_read_tled, + mode, device); } /* @@ -897,35 +889,40 @@ static int __init asus_hotk_add_fs(struct acpi_device *device) * from keyboard */ if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) { - asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode, device); + asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode, + device); } - + if ((hotk->methods->brightness_up && hotk->methods->brightness_down) || (hotk->methods->brightness_get && hotk->methods->brightness_set)) { - asus_proc_add(PROC_BRN, &proc_write_brn, &proc_read_brn, mode, device); + asus_proc_add(PROC_BRN, &proc_write_brn, &proc_read_brn, mode, + device); } if (hotk->methods->display_set) { - asus_proc_add(PROC_DISP, &proc_write_disp, &proc_read_disp, mode, device); + asus_proc_add(PROC_DISP, &proc_write_disp, &proc_read_disp, + mode, device); } return 0; } -static int asus_hotk_remove_fs(struct acpi_device* device) +static int asus_hotk_remove_fs(struct acpi_device *device) { - if(acpi_device_dir(device)) { - remove_proc_entry(PROC_INFO,acpi_device_dir(device)); + if (acpi_device_dir(device)) { + remove_proc_entry(PROC_INFO, acpi_device_dir(device)); if (hotk->methods->mt_wled) - remove_proc_entry(PROC_WLED,acpi_device_dir(device)); + remove_proc_entry(PROC_WLED, acpi_device_dir(device)); if (hotk->methods->mt_mled) - remove_proc_entry(PROC_MLED,acpi_device_dir(device)); + remove_proc_entry(PROC_MLED, acpi_device_dir(device)); if (hotk->methods->mt_tled) - remove_proc_entry(PROC_TLED,acpi_device_dir(device)); + remove_proc_entry(PROC_TLED, acpi_device_dir(device)); if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) remove_proc_entry(PROC_LCD, acpi_device_dir(device)); - if ((hotk->methods->brightness_up && hotk->methods->brightness_down) || - (hotk->methods->brightness_get && hotk->methods->brightness_set)) + if ((hotk->methods->brightness_up + && hotk->methods->brightness_down) + || (hotk->methods->brightness_get + && hotk->methods->brightness_set)) remove_proc_entry(PROC_BRN, acpi_device_dir(device)); if (hotk->methods->display_set) remove_proc_entry(PROC_DISP, acpi_device_dir(device)); @@ -933,16 +930,15 @@ static int asus_hotk_remove_fs(struct acpi_device* device) return 0; } - static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) { - /* TODO Find a better way to handle events count.*/ + /* TODO Find a better way to handle events count. */ if (!hotk) return; if ((event & ~((u32) BR_UP)) < 16) { hotk->brightness = (event & ~((u32) BR_UP)); - } else if ((event & ~((u32) BR_DOWN)) < 16 ) { + } else if ((event & ~((u32) BR_DOWN)) < 16) { hotk->brightness = (event & ~((u32) BR_DOWN)); } @@ -976,7 +972,7 @@ static int __init asus_hotk_get_info(void) if (ACPI_FAILURE(status)) printk(KERN_WARNING " Couldn't get the DSDT table header\n"); else - asus_info = (struct acpi_table_header *) dsdt.pointer; + asus_info = (struct acpi_table_header *)dsdt.pointer; /* We have to write 0 on init this far for all ASUS models */ if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) { @@ -988,15 +984,17 @@ static int __init asus_hotk_get_info(void) if (!read_acpi_int(hotk->handle, "BSTS", &bsts_result)) printk(KERN_WARNING " Error calling BSTS\n"); else if (bsts_result) - printk(KERN_NOTICE " BSTS called, 0x%02x returned\n", bsts_result); + printk(KERN_NOTICE " BSTS called, 0x%02x returned\n", + bsts_result); /* Samsung P30 has a device with a valid _HID whose INIT does not * return anything. Catch this one and any similar here */ if (buffer.pointer == NULL) { - if (asus_info && /* Samsung P30 */ + if (asus_info && /* Samsung P30 */ strncmp(asus_info->oem_table_id, "ODEM", 4) == 0) { hotk->model = P30; - printk(KERN_NOTICE " Samsung P30 detected, supported\n"); + printk(KERN_NOTICE + " Samsung P30 detected, supported\n"); } else { hotk->model = M2E; printk(KERN_WARNING " no string returned by INIT\n"); @@ -1006,10 +1004,11 @@ static int __init asus_hotk_get_info(void) hotk->methods = &model_conf[hotk->model]; return AE_OK; } - - model = (union acpi_object *) buffer.pointer; + + model = (union acpi_object *)buffer.pointer; if (model->type == ACPI_TYPE_STRING) { - printk(KERN_NOTICE " %s model detected, ", model->string.pointer); + printk(KERN_NOTICE " %s model detected, ", + model->string.pointer); } hotk->model = END_MODEL; @@ -1035,7 +1034,7 @@ static int __init asus_hotk_get_info(void) strncmp(model->string.pointer, "M6N", 3) == 0 || strncmp(model->string.pointer, "S1N", 3) == 0 || strncmp(model->string.pointer, "S5N", 3) == 0 || - strncmp(model->string.pointer, "W1N", 3) == 0) + strncmp(model->string.pointer, "W1N", 3) == 0) hotk->model = xxN; else if (strncmp(model->string.pointer, "M1", 2) == 0) hotk->model = M1A; @@ -1069,21 +1068,21 @@ static int __init asus_hotk_get_info(void) /* Sort of per-model blacklist */ if (strncmp(model->string.pointer, "L2B", 3) == 0) - hotk->methods->lcd_status = NULL; + hotk->methods->lcd_status = NULL; /* L2B is similar enough to L3C to use its settings, with this only exception */ else if (strncmp(model->string.pointer, "S5N", 3) == 0 || strncmp(model->string.pointer, "M5N", 3) == 0) - hotk->methods->mt_mled = NULL; + hotk->methods->mt_mled = NULL; /* S5N and M5N have no MLED */ else if (strncmp(model->string.pointer, "M2N", 3) == 0 || strncmp(model->string.pointer, "W1N", 3) == 0) - hotk->methods->mt_wled = "WLED"; + hotk->methods->mt_wled = "WLED"; /* M2N and W1N have a usable WLED */ else if (asus_info) { if (strncmp(asus_info->oem_table_id, "L1", 2) == 0) hotk->methods->mled_status = NULL; - /* S1300A reports L84F, but L1400B too, account for that */ + /* S1300A reports L84F, but L1400B too, account for that */ } acpi_os_free(model); @@ -1091,7 +1090,6 @@ static int __init asus_hotk_get_info(void) return AE_OK; } - static int __init asus_hotk_check(void) { int result = 0; @@ -1110,7 +1108,6 @@ static int __init asus_hotk_check(void) return result; } - static int __init asus_hotk_add(struct acpi_device *device) { acpi_status status = AE_OK; @@ -1123,7 +1120,7 @@ static int __init asus_hotk_add(struct acpi_device *device) ASUS_ACPI_VERSION); hotk = - (struct asus_hotk *) kmalloc(sizeof(struct asus_hotk), GFP_KERNEL); + (struct asus_hotk *)kmalloc(sizeof(struct asus_hotk), GFP_KERNEL); if (!hotk) return -ENOMEM; memset(hotk, 0, sizeof(struct asus_hotk)); @@ -1134,7 +1131,6 @@ static int __init asus_hotk_add(struct acpi_device *device) acpi_driver_data(device) = hotk; hotk->device = device; - result = asus_hotk_check(); if (result) goto end; @@ -1153,17 +1149,22 @@ static int __init asus_hotk_add(struct acpi_device *device) printk(KERN_ERR " Error installing notify handler\n"); /* For laptops without GPLV: init the hotk->brightness value */ - if ((!hotk->methods->brightness_get) && (!hotk->methods->brightness_status) && - (hotk->methods->brightness_up && hotk->methods->brightness_down)) { - status = acpi_evaluate_object(NULL, hotk->methods->brightness_down, - NULL, NULL); + if ((!hotk->methods->brightness_get) + && (!hotk->methods->brightness_status) + && (hotk->methods->brightness_up + && hotk->methods->brightness_down)) { + status = + acpi_evaluate_object(NULL, hotk->methods->brightness_down, + NULL, NULL); if (ACPI_FAILURE(status)) printk(KERN_WARNING " Error changing brightness\n"); else { - status = acpi_evaluate_object(NULL, hotk->methods->brightness_up, - NULL, NULL); + status = + acpi_evaluate_object(NULL, + hotk->methods->brightness_up, + NULL, NULL); if (ACPI_FAILURE(status)) - printk(KERN_WARNING " Strange, error changing" + printk(KERN_WARNING " Strange, error changing" " brightness\n"); } } @@ -1176,7 +1177,6 @@ static int __init asus_hotk_add(struct acpi_device *device) return result; } - static int asus_hotk_remove(struct acpi_device *device, int type) { acpi_status status = 0; @@ -1196,7 +1196,6 @@ static int asus_hotk_remove(struct acpi_device *device, int type) return 0; } - static int __init asus_acpi_init(void) { int result; @@ -1204,9 +1203,9 @@ static int __init asus_acpi_init(void) if (acpi_disabled) return -ENODEV; - if (!acpi_specific_hotkey_enabled){ + if (!acpi_specific_hotkey_enabled) { printk(KERN_ERR "Using generic hotkey driver\n"); - return -ENODEV; + return -ENODEV; } asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir); if (!asus_proc_dir) { @@ -1225,7 +1224,6 @@ static int __init asus_acpi_init(void) return 0; } - static void __exit asus_acpi_exit(void) { acpi_bus_unregister_driver(&asus_hotk_driver); diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index c55feca..702e857 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -34,7 +34,6 @@ #include #include - #define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF #define ACPI_BATTERY_FORMAT_BIF "NNNNNNNNNSSSS" @@ -53,87 +52,85 @@ #define ACPI_BATTERY_UNITS_WATTS "mW" #define ACPI_BATTERY_UNITS_AMPS "mA" - #define _COMPONENT ACPI_BATTERY_COMPONENT -ACPI_MODULE_NAME ("acpi_battery") +ACPI_MODULE_NAME("acpi_battery") -MODULE_AUTHOR("Paul Diefenbaugh"); + MODULE_AUTHOR("Paul Diefenbaugh"); MODULE_DESCRIPTION(ACPI_BATTERY_DRIVER_NAME); MODULE_LICENSE("GPL"); -static int acpi_battery_add (struct acpi_device *device); -static int acpi_battery_remove (struct acpi_device *device, int type); +static int acpi_battery_add(struct acpi_device *device); +static int acpi_battery_remove(struct acpi_device *device, int type); static struct acpi_driver acpi_battery_driver = { - .name = ACPI_BATTERY_DRIVER_NAME, - .class = ACPI_BATTERY_CLASS, - .ids = ACPI_BATTERY_HID, - .ops = { - .add = acpi_battery_add, - .remove = acpi_battery_remove, - }, + .name = ACPI_BATTERY_DRIVER_NAME, + .class = ACPI_BATTERY_CLASS, + .ids = ACPI_BATTERY_HID, + .ops = { + .add = acpi_battery_add, + .remove = acpi_battery_remove, + }, }; struct acpi_battery_status { - acpi_integer state; - acpi_integer present_rate; - acpi_integer remaining_capacity; - acpi_integer present_voltage; + acpi_integer state; + acpi_integer present_rate; + acpi_integer remaining_capacity; + acpi_integer present_voltage; }; struct acpi_battery_info { - acpi_integer power_unit; - acpi_integer design_capacity; - acpi_integer last_full_capacity; - acpi_integer battery_technology; - acpi_integer design_voltage; - acpi_integer design_capacity_warning; - acpi_integer design_capacity_low; - acpi_integer battery_capacity_granularity_1; - acpi_integer battery_capacity_granularity_2; - acpi_string model_number; - acpi_string serial_number; - acpi_string battery_type; - acpi_string oem_info; + acpi_integer power_unit; + acpi_integer design_capacity; + acpi_integer last_full_capacity; + acpi_integer battery_technology; + acpi_integer design_voltage; + acpi_integer design_capacity_warning; + acpi_integer design_capacity_low; + acpi_integer battery_capacity_granularity_1; + acpi_integer battery_capacity_granularity_2; + acpi_string model_number; + acpi_string serial_number; + acpi_string battery_type; + acpi_string oem_info; }; struct acpi_battery_flags { - u8 present:1; /* Bay occupied? */ - u8 power_unit:1; /* 0=watts, 1=apms */ - u8 alarm:1; /* _BTP present? */ - u8 reserved:5; + u8 present:1; /* Bay occupied? */ + u8 power_unit:1; /* 0=watts, 1=apms */ + u8 alarm:1; /* _BTP present? */ + u8 reserved:5; }; struct acpi_battery_trips { - unsigned long warning; - unsigned long low; + unsigned long warning; + unsigned long low; }; struct acpi_battery { - acpi_handle handle; + acpi_handle handle; struct acpi_battery_flags flags; struct acpi_battery_trips trips; - unsigned long alarm; + unsigned long alarm; struct acpi_battery_info *info; }; - /* -------------------------------------------------------------------------- Battery Management -------------------------------------------------------------------------- */ static int -acpi_battery_get_info ( - struct acpi_battery *battery, - struct acpi_battery_info **bif) +acpi_battery_get_info(struct acpi_battery *battery, + struct acpi_battery_info **bif) { - int result = 0; - acpi_status status = 0; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - struct acpi_buffer format = {sizeof(ACPI_BATTERY_FORMAT_BIF), - ACPI_BATTERY_FORMAT_BIF}; - struct acpi_buffer data = {0, NULL}; - union acpi_object *package = NULL; + int result = 0; + acpi_status status = 0; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BIF), + ACPI_BATTERY_FORMAT_BIF + }; + struct acpi_buffer data = { 0, NULL }; + union acpi_object *package = NULL; ACPI_FUNCTION_TRACE("acpi_battery_get_info"); @@ -148,7 +145,7 @@ acpi_battery_get_info ( return_VALUE(-ENODEV); } - package = (union acpi_object *) buffer.pointer; + package = (union acpi_object *)buffer.pointer; /* Extract Package Data */ @@ -174,27 +171,27 @@ acpi_battery_get_info ( goto end; } -end: + end: acpi_os_free(buffer.pointer); if (!result) - (*bif) = (struct acpi_battery_info *) data.pointer; + (*bif) = (struct acpi_battery_info *)data.pointer; return_VALUE(result); } static int -acpi_battery_get_status ( - struct acpi_battery *battery, - struct acpi_battery_status **bst) +acpi_battery_get_status(struct acpi_battery *battery, + struct acpi_battery_status **bst) { - int result = 0; - acpi_status status = 0; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - struct acpi_buffer format = {sizeof(ACPI_BATTERY_FORMAT_BST), - ACPI_BATTERY_FORMAT_BST}; - struct acpi_buffer data = {0, NULL}; - union acpi_object *package = NULL; + int result = 0; + acpi_status status = 0; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BST), + ACPI_BATTERY_FORMAT_BST + }; + struct acpi_buffer data = { 0, NULL }; + union acpi_object *package = NULL; ACPI_FUNCTION_TRACE("acpi_battery_get_status"); @@ -209,7 +206,7 @@ acpi_battery_get_status ( return_VALUE(-ENODEV); } - package = (union acpi_object *) buffer.pointer; + package = (union acpi_object *)buffer.pointer; /* Extract Package Data */ @@ -235,24 +232,21 @@ acpi_battery_get_status ( goto end; } -end: + end: acpi_os_free(buffer.pointer); if (!result) - (*bst) = (struct acpi_battery_status *) data.pointer; + (*bst) = (struct acpi_battery_status *)data.pointer; return_VALUE(result); } - static int -acpi_battery_set_alarm ( - struct acpi_battery *battery, - unsigned long alarm) +acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm) { - acpi_status status = 0; - union acpi_object arg0 = {ACPI_TYPE_INTEGER}; - struct acpi_object_list arg_list = {1, &arg0}; + acpi_status status = 0; + union acpi_object arg0 = { ACPI_TYPE_INTEGER }; + struct acpi_object_list arg_list = { 1, &arg0 }; ACPI_FUNCTION_TRACE("acpi_battery_set_alarm"); @@ -275,19 +269,16 @@ acpi_battery_set_alarm ( return_VALUE(0); } - -static int -acpi_battery_check ( - struct acpi_battery *battery) +static int acpi_battery_check(struct acpi_battery *battery) { - int result = 0; - acpi_status status = AE_OK; - acpi_handle handle = NULL; - struct acpi_device *device = NULL; + int result = 0; + acpi_status status = AE_OK; + acpi_handle handle = NULL; + struct acpi_device *device = NULL; struct acpi_battery_info *bif = NULL; ACPI_FUNCTION_TRACE("acpi_battery_check"); - + if (!battery) return_VALUE(-EINVAL); @@ -336,18 +327,17 @@ acpi_battery_check ( return_VALUE(result); } - /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ -static struct proc_dir_entry *acpi_battery_dir; +static struct proc_dir_entry *acpi_battery_dir; static int acpi_battery_read_info(struct seq_file *seq, void *offset) { - int result = 0; - struct acpi_battery *battery = (struct acpi_battery *) seq->private; + int result = 0; + struct acpi_battery *battery = (struct acpi_battery *)seq->private; struct acpi_battery_info *bif = NULL; - char *units = "?"; + char *units = "?"; ACPI_FUNCTION_TRACE("acpi_battery_read_info"); @@ -369,19 +359,21 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset) goto end; } - units = bif->power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; - + units = + bif-> + power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; + if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN) seq_printf(seq, "design capacity: unknown\n"); else seq_printf(seq, "design capacity: %d %sh\n", - (u32) bif->design_capacity, units); + (u32) bif->design_capacity, units); if (bif->last_full_capacity == ACPI_BATTERY_VALUE_UNKNOWN) seq_printf(seq, "last full capacity: unknown\n"); else seq_printf(seq, "last full capacity: %d %sh\n", - (u32) bif->last_full_capacity, units); + (u32) bif->last_full_capacity, units); switch ((u32) bif->battery_technology) { case 0: @@ -399,26 +391,22 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset) seq_printf(seq, "design voltage: unknown\n"); else seq_printf(seq, "design voltage: %d mV\n", - (u32) bif->design_voltage); - + (u32) bif->design_voltage); + seq_printf(seq, "design capacity warning: %d %sh\n", - (u32) bif->design_capacity_warning, units); + (u32) bif->design_capacity_warning, units); seq_printf(seq, "design capacity low: %d %sh\n", - (u32) bif->design_capacity_low, units); + (u32) bif->design_capacity_low, units); seq_printf(seq, "capacity granularity 1: %d %sh\n", - (u32) bif->battery_capacity_granularity_1, units); + (u32) bif->battery_capacity_granularity_1, units); seq_printf(seq, "capacity granularity 2: %d %sh\n", - (u32) bif->battery_capacity_granularity_2, units); - seq_printf(seq, "model number: %s\n", - bif->model_number); - seq_printf(seq, "serial number: %s\n", - bif->serial_number); - seq_printf(seq, "battery type: %s\n", - bif->battery_type); - seq_printf(seq, "OEM info: %s\n", - bif->oem_info); - -end: + (u32) bif->battery_capacity_granularity_2, units); + seq_printf(seq, "model number: %s\n", bif->model_number); + seq_printf(seq, "serial number: %s\n", bif->serial_number); + seq_printf(seq, "battery type: %s\n", bif->battery_type); + seq_printf(seq, "OEM info: %s\n", bif->oem_info); + + end: kfree(bif); return_VALUE(0); @@ -429,14 +417,12 @@ static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) return single_open(file, acpi_battery_read_info, PDE(inode)->data); } - -static int -acpi_battery_read_state (struct seq_file *seq, void *offset) +static int acpi_battery_read_state(struct seq_file *seq, void *offset) { - int result = 0; - struct acpi_battery *battery = (struct acpi_battery *) seq->private; + int result = 0; + struct acpi_battery *battery = (struct acpi_battery *)seq->private; struct acpi_battery_status *bst = NULL; - char *units = "?"; + char *units = "?"; ACPI_FUNCTION_TRACE("acpi_battery_read_state"); @@ -452,7 +438,9 @@ acpi_battery_read_state (struct seq_file *seq, void *offset) /* Battery Units */ - units = battery->flags.power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; + units = + battery->flags. + power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; /* Battery Status (_BST) */ @@ -467,12 +455,12 @@ acpi_battery_read_state (struct seq_file *seq, void *offset) else seq_printf(seq, "capacity state: critical\n"); - if ((bst->state & 0x01) && (bst->state & 0x02)){ - seq_printf(seq, "charging state: charging/discharging\n"); - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Battery Charging and Discharging?\n")); - } - else if (bst->state & 0x01) + if ((bst->state & 0x01) && (bst->state & 0x02)) { + seq_printf(seq, + "charging state: charging/discharging\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Battery Charging and Discharging?\n")); + } else if (bst->state & 0x01) seq_printf(seq, "charging state: discharging\n"); else if (bst->state & 0x02) seq_printf(seq, "charging state: charging\n"); @@ -484,21 +472,21 @@ acpi_battery_read_state (struct seq_file *seq, void *offset) seq_printf(seq, "present rate: unknown\n"); else seq_printf(seq, "present rate: %d %s\n", - (u32) bst->present_rate, units); + (u32) bst->present_rate, units); if (bst->remaining_capacity == ACPI_BATTERY_VALUE_UNKNOWN) seq_printf(seq, "remaining capacity: unknown\n"); else seq_printf(seq, "remaining capacity: %d %sh\n", - (u32) bst->remaining_capacity, units); + (u32) bst->remaining_capacity, units); if (bst->present_voltage == ACPI_BATTERY_VALUE_UNKNOWN) seq_printf(seq, "present voltage: unknown\n"); else seq_printf(seq, "present voltage: %d mV\n", - (u32) bst->present_voltage); + (u32) bst->present_voltage); -end: + end: kfree(bst); return_VALUE(0); @@ -509,12 +497,10 @@ static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) return single_open(file, acpi_battery_read_state, PDE(inode)->data); } - -static int -acpi_battery_read_alarm (struct seq_file *seq, void *offset) +static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) { - struct acpi_battery *battery = (struct acpi_battery *) seq->private; - char *units = "?"; + struct acpi_battery *battery = (struct acpi_battery *)seq->private; + char *units = "?"; ACPI_FUNCTION_TRACE("acpi_battery_read_alarm"); @@ -527,8 +513,10 @@ acpi_battery_read_alarm (struct seq_file *seq, void *offset) } /* Battery Units */ - - units = battery->flags.power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; + + units = + battery->flags. + power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; /* Battery Alarm */ @@ -538,22 +526,19 @@ acpi_battery_read_alarm (struct seq_file *seq, void *offset) else seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units); -end: + end: return_VALUE(0); } - static ssize_t -acpi_battery_write_alarm ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *ppos) +acpi_battery_write_alarm(struct file *file, + const char __user * buffer, + size_t count, loff_t * ppos) { - int result = 0; - char alarm_string[12] = {'\0'}; - struct seq_file *m = (struct seq_file *)file->private_data; - struct acpi_battery *battery = (struct acpi_battery *)m->private; + int result = 0; + char alarm_string[12] = { '\0' }; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_battery *battery = (struct acpi_battery *)m->private; ACPI_FUNCTION_TRACE("acpi_battery_write_alarm"); @@ -565,11 +550,11 @@ acpi_battery_write_alarm ( if (copy_from_user(alarm_string, buffer, count)) return_VALUE(-EFAULT); - + alarm_string[count] = '\0'; - result = acpi_battery_set_alarm(battery, - simple_strtoul(alarm_string, NULL, 0)); + result = acpi_battery_set_alarm(battery, + simple_strtoul(alarm_string, NULL, 0)); if (result) return_VALUE(result); @@ -582,41 +567,39 @@ static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) } static struct file_operations acpi_battery_info_ops = { - .open = acpi_battery_info_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_battery_info_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, .owner = THIS_MODULE, }; static struct file_operations acpi_battery_state_ops = { - .open = acpi_battery_state_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_battery_state_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, .owner = THIS_MODULE, }; static struct file_operations acpi_battery_alarm_ops = { - .open = acpi_battery_alarm_open_fs, - .read = seq_read, - .write = acpi_battery_write_alarm, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_battery_alarm_open_fs, + .read = seq_read, + .write = acpi_battery_write_alarm, + .llseek = seq_lseek, + .release = single_release, .owner = THIS_MODULE, }; -static int -acpi_battery_add_fs ( - struct acpi_device *device) +static int acpi_battery_add_fs(struct acpi_device *device) { - struct proc_dir_entry *entry = NULL; + struct proc_dir_entry *entry = NULL; ACPI_FUNCTION_TRACE("acpi_battery_add_fs"); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), - acpi_battery_dir); + acpi_battery_dir); if (!acpi_device_dir(device)) return_VALUE(-ENODEV); acpi_device_dir(device)->owner = THIS_MODULE; @@ -624,24 +607,24 @@ acpi_battery_add_fs ( /* 'info' [R] */ entry = create_proc_entry(ACPI_BATTERY_FILE_INFO, - S_IRUGO, acpi_device_dir(device)); + S_IRUGO, acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_BATTERY_FILE_INFO)); + "Unable to create '%s' fs entry\n", + ACPI_BATTERY_FILE_INFO)); else { - entry->proc_fops = &acpi_battery_info_ops; + entry->proc_fops = &acpi_battery_info_ops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } /* 'status' [R] */ entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS, - S_IRUGO, acpi_device_dir(device)); + S_IRUGO, acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_BATTERY_FILE_STATUS)); + "Unable to create '%s' fs entry\n", + ACPI_BATTERY_FILE_STATUS)); else { entry->proc_fops = &acpi_battery_state_ops; entry->data = acpi_driver_data(device); @@ -650,11 +633,12 @@ acpi_battery_add_fs ( /* 'alarm' [R/W] */ entry = create_proc_entry(ACPI_BATTERY_FILE_ALARM, - S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_BATTERY_FILE_ALARM)); + "Unable to create '%s' fs entry\n", + ACPI_BATTERY_FILE_ALARM)); else { entry->proc_fops = &acpi_battery_alarm_ops; entry->data = acpi_driver_data(device); @@ -664,10 +648,7 @@ acpi_battery_add_fs ( return_VALUE(0); } - -static int -acpi_battery_remove_fs ( - struct acpi_device *device) +static int acpi_battery_remove_fs(struct acpi_device *device) { ACPI_FUNCTION_TRACE("acpi_battery_remove_fs"); @@ -686,19 +667,14 @@ acpi_battery_remove_fs ( return_VALUE(0); } - /* -------------------------------------------------------------------------- Driver Interface -------------------------------------------------------------------------- */ -static void -acpi_battery_notify ( - acpi_handle handle, - u32 event, - void *data) +static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_battery *battery = (struct acpi_battery *) data; - struct acpi_device *device = NULL; + struct acpi_battery *battery = (struct acpi_battery *)data; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_battery_notify"); @@ -716,24 +692,21 @@ acpi_battery_notify ( break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Unsupported event [0x%x]\n", event)); + "Unsupported event [0x%x]\n", event)); break; } return_VOID; } - -static int -acpi_battery_add ( - struct acpi_device *device) +static int acpi_battery_add(struct acpi_device *device) { - int result = 0; - acpi_status status = 0; - struct acpi_battery *battery = NULL; + int result = 0; + acpi_status status = 0; + struct acpi_battery *battery = NULL; ACPI_FUNCTION_TRACE("acpi_battery_add"); - + if (!device) return_VALUE(-EINVAL); @@ -756,19 +729,20 @@ acpi_battery_add ( goto end; status = acpi_install_notify_handler(battery->handle, - ACPI_DEVICE_NOTIFY, acpi_battery_notify, battery); + ACPI_DEVICE_NOTIFY, + acpi_battery_notify, battery); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); + "Error installing notify handler\n")); result = -ENODEV; goto end; } printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", - ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), - device->status.battery_present?"present":"absent"); - -end: + ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), + device->status.battery_present ? "present" : "absent"); + + end: if (result) { acpi_battery_remove_fs(device); kfree(battery); @@ -777,27 +751,24 @@ end: return_VALUE(result); } - -static int -acpi_battery_remove ( - struct acpi_device *device, - int type) +static int acpi_battery_remove(struct acpi_device *device, int type) { - acpi_status status = 0; - struct acpi_battery *battery = NULL; + acpi_status status = 0; + struct acpi_battery *battery = NULL; ACPI_FUNCTION_TRACE("acpi_battery_remove"); if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); - battery = (struct acpi_battery *) acpi_driver_data(device); + battery = (struct acpi_battery *)acpi_driver_data(device); status = acpi_remove_notify_handler(battery->handle, - ACPI_DEVICE_NOTIFY, acpi_battery_notify); + ACPI_DEVICE_NOTIFY, + acpi_battery_notify); if (ACPI_FAILURE(status)) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); + "Error removing notify handler\n")); acpi_battery_remove_fs(device); @@ -806,11 +777,9 @@ acpi_battery_remove ( return_VALUE(0); } - -static int __init -acpi_battery_init (void) +static int __init acpi_battery_init(void) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_battery_init"); @@ -828,9 +797,7 @@ acpi_battery_init (void) return_VALUE(0); } - -static void __exit -acpi_battery_exit (void) +static void __exit acpi_battery_exit(void) { ACPI_FUNCTION_TRACE("acpi_battery_exit"); @@ -841,6 +808,5 @@ acpi_battery_exit (void) return_VOID; } - module_init(acpi_battery_init); module_exit(acpi_battery_exit); diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index 4c010e7..9824f67 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c @@ -26,7 +26,6 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - #include #include #include @@ -34,49 +33,49 @@ #include #include -enum acpi_blacklist_predicates -{ - all_versions, - less_than_or_equal, - equal, - greater_than_or_equal, +enum acpi_blacklist_predicates { + all_versions, + less_than_or_equal, + equal, + greater_than_or_equal, }; -struct acpi_blacklist_item -{ - char oem_id[7]; - char oem_table_id[9]; - u32 oem_revision; - acpi_table_type table; - enum acpi_blacklist_predicates oem_revision_predicate; - char *reason; - u32 is_critical_error; +struct acpi_blacklist_item { + char oem_id[7]; + char oem_table_id[9]; + u32 oem_revision; + acpi_table_type table; + enum acpi_blacklist_predicates oem_revision_predicate; + char *reason; + u32 is_critical_error; }; /* * POLICY: If *anything* doesn't work, put it on the blacklist. * If they are critical errors, mark it critical, and abort driver load. */ -static struct acpi_blacklist_item acpi_blacklist[] __initdata = -{ +static struct acpi_blacklist_item acpi_blacklist[] __initdata = { /* Compaq Presario 1700 */ - {"PTLTD ", " DSDT ", 0x06040000, ACPI_DSDT, less_than_or_equal, "Multiple problems", 1}, + {"PTLTD ", " DSDT ", 0x06040000, ACPI_DSDT, less_than_or_equal, + "Multiple problems", 1}, /* Sony FX120, FX140, FX150? */ - {"SONY ", "U0 ", 0x20010313, ACPI_DSDT, less_than_or_equal, "ACPI driver problem", 1}, + {"SONY ", "U0 ", 0x20010313, ACPI_DSDT, less_than_or_equal, + "ACPI driver problem", 1}, /* Compaq Presario 800, Insyde BIOS */ - {"INT440", "SYSFexxx", 0x00001001, ACPI_DSDT, less_than_or_equal, "Does not use _REG to protect EC OpRegions", 1}, + {"INT440", "SYSFexxx", 0x00001001, ACPI_DSDT, less_than_or_equal, + "Does not use _REG to protect EC OpRegions", 1}, /* IBM 600E - _ADR should return 7, but it returns 1 */ - {"IBM ", "TP600E ", 0x00000105, ACPI_DSDT, less_than_or_equal, "Incorrect _ADR", 1}, - {"ASUS\0\0", "P2B-S ", 0, ACPI_DSDT, all_versions, "Bogus PCI routing", 1}, + {"IBM ", "TP600E ", 0x00000105, ACPI_DSDT, less_than_or_equal, + "Incorrect _ADR", 1}, + {"ASUS\0\0", "P2B-S ", 0, ACPI_DSDT, all_versions, + "Bogus PCI routing", 1}, {""} }; - #if CONFIG_ACPI_BLACKLIST_YEAR -static int __init -blacklist_by_year(void) +static int __init blacklist_by_year(void) { int year; char *s = dmi_get_system_info(DMI_BIOS_DATE); @@ -92,36 +91,38 @@ blacklist_by_year(void) s += 1; - year = simple_strtoul(s,NULL,0); + year = simple_strtoul(s, NULL, 0); - if (year < 100) { /* 2-digit year */ + if (year < 100) { /* 2-digit year */ year += 1900; if (year < 1996) /* no dates < spec 1.0 */ year += 100; } if (year < CONFIG_ACPI_BLACKLIST_YEAR) { - printk(KERN_ERR PREFIX "BIOS age (%d) fails cutoff (%d), " - "acpi=force is required to enable ACPI\n", - year, CONFIG_ACPI_BLACKLIST_YEAR); + printk(KERN_ERR PREFIX "BIOS age (%d) fails cutoff (%d), " + "acpi=force is required to enable ACPI\n", + year, CONFIG_ACPI_BLACKLIST_YEAR); return 1; } return 0; } #else -static inline int blacklist_by_year(void) { return 0; } +static inline int blacklist_by_year(void) +{ + return 0; +} #endif -int __init -acpi_blacklisted(void) +int __init acpi_blacklisted(void) { int i = 0; int blacklisted = 0; struct acpi_table_header *table_header; - while (acpi_blacklist[i].oem_id[0] != '\0') - { - if (acpi_get_table_header_early(acpi_blacklist[i].table, &table_header)) { + while (acpi_blacklist[i].oem_id[0] != '\0') { + if (acpi_get_table_header_early + (acpi_blacklist[i].table, &table_header)) { i++; continue; } @@ -131,33 +132,43 @@ acpi_blacklisted(void) continue; } - if (strncmp(acpi_blacklist[i].oem_table_id, table_header->oem_table_id, 8)) { + if (strncmp + (acpi_blacklist[i].oem_table_id, table_header->oem_table_id, + 8)) { i++; continue; } if ((acpi_blacklist[i].oem_revision_predicate == all_versions) - || (acpi_blacklist[i].oem_revision_predicate == less_than_or_equal - && table_header->oem_revision <= acpi_blacklist[i].oem_revision) - || (acpi_blacklist[i].oem_revision_predicate == greater_than_or_equal - && table_header->oem_revision >= acpi_blacklist[i].oem_revision) + || (acpi_blacklist[i].oem_revision_predicate == + less_than_or_equal + && table_header->oem_revision <= + acpi_blacklist[i].oem_revision) + || (acpi_blacklist[i].oem_revision_predicate == + greater_than_or_equal + && table_header->oem_revision >= + acpi_blacklist[i].oem_revision) || (acpi_blacklist[i].oem_revision_predicate == equal - && table_header->oem_revision == acpi_blacklist[i].oem_revision)) { - - printk(KERN_ERR PREFIX "Vendor \"%6.6s\" System \"%8.8s\" " - "Revision 0x%x has a known ACPI BIOS problem.\n", - acpi_blacklist[i].oem_id, - acpi_blacklist[i].oem_table_id, - acpi_blacklist[i].oem_revision); - - printk(KERN_ERR PREFIX "Reason: %s. This is a %s error\n", - acpi_blacklist[i].reason, - (acpi_blacklist[i].is_critical_error ? "non-recoverable" : "recoverable")); + && table_header->oem_revision == + acpi_blacklist[i].oem_revision)) { + + printk(KERN_ERR PREFIX + "Vendor \"%6.6s\" System \"%8.8s\" " + "Revision 0x%x has a known ACPI BIOS problem.\n", + acpi_blacklist[i].oem_id, + acpi_blacklist[i].oem_table_id, + acpi_blacklist[i].oem_revision); + + printk(KERN_ERR PREFIX + "Reason: %s. This is a %s error\n", + acpi_blacklist[i].reason, + (acpi_blacklist[i]. + is_critical_error ? "non-recoverable" : + "recoverable")); blacklisted = acpi_blacklist[i].is_critical_error; break; - } - else { + } else { i++; } } @@ -166,4 +177,3 @@ acpi_blacklisted(void) return blacklisted; } - diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index d77c230..6a4da417 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -36,19 +36,17 @@ #include #include - #define _COMPONENT ACPI_BUS_COMPONENT -ACPI_MODULE_NAME ("acpi_bus") - +ACPI_MODULE_NAME("acpi_bus") #ifdef CONFIG_X86 extern void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger); #endif -FADT_DESCRIPTOR acpi_fadt; +FADT_DESCRIPTOR acpi_fadt; EXPORT_SYMBOL(acpi_fadt); -struct acpi_device *acpi_root; -struct proc_dir_entry *acpi_root_dir; +struct acpi_device *acpi_root; +struct proc_dir_entry *acpi_root_dir; EXPORT_SYMBOL(acpi_root_dir); #define STRUCT_TO_INT(s) (*((int*)&s)) @@ -57,12 +55,9 @@ EXPORT_SYMBOL(acpi_root_dir); Device Management -------------------------------------------------------------------------- */ -int -acpi_bus_get_device ( - acpi_handle handle, - struct acpi_device **device) +int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) { - acpi_status status = AE_OK; + acpi_status status = AE_OK; ACPI_FUNCTION_TRACE("acpi_bus_get_device"); @@ -71,24 +66,23 @@ acpi_bus_get_device ( /* TBD: Support fixed-feature devices */ - status = acpi_get_data(handle, acpi_bus_data_handler, (void**) device); + status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device); if (ACPI_FAILURE(status) || !*device) { ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No context for object [%p]\n", - handle)); + handle)); return_VALUE(-ENODEV); } return_VALUE(0); } + EXPORT_SYMBOL(acpi_bus_get_device); -int -acpi_bus_get_status ( - struct acpi_device *device) +int acpi_bus_get_status(struct acpi_device *device) { - acpi_status status = AE_OK; - unsigned long sta = 0; - + acpi_status status = AE_OK; + unsigned long sta = 0; + ACPI_FUNCTION_TRACE("acpi_bus_get_status"); if (!device) @@ -98,10 +92,11 @@ acpi_bus_get_status ( * Evaluate _STA if present. */ if (device->flags.dynamic_status) { - status = acpi_evaluate_integer(device->handle, "_STA", NULL, &sta); + status = + acpi_evaluate_integer(device->handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status)) return_VALUE(-ENODEV); - STRUCT_TO_INT(device->status) = (int) sta; + STRUCT_TO_INT(device->status) = (int)sta; } /* @@ -115,33 +110,30 @@ acpi_bus_get_status ( if (device->status.functional && !device->status.present) { printk(KERN_WARNING PREFIX "Device [%s] status [%08x]: " - "functional but not present; setting present\n", - device->pnp.bus_id, - (u32) STRUCT_TO_INT(device->status)); + "functional but not present; setting present\n", + device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status)); device->status.present = 1; } - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", - device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status))); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", + device->pnp.bus_id, + (u32) STRUCT_TO_INT(device->status))); return_VALUE(0); } -EXPORT_SYMBOL(acpi_bus_get_status); +EXPORT_SYMBOL(acpi_bus_get_status); /* -------------------------------------------------------------------------- Power Management -------------------------------------------------------------------------- */ -int -acpi_bus_get_power ( - acpi_handle handle, - int *state) +int acpi_bus_get_power(acpi_handle handle, int *state) { - int result = 0; - acpi_status status = 0; - struct acpi_device *device = NULL; - unsigned long psc = 0; + int result = 0; + acpi_status status = 0; + struct acpi_device *device = NULL; + unsigned long psc = 0; ACPI_FUNCTION_TRACE("acpi_bus_get_power"); @@ -157,20 +149,18 @@ acpi_bus_get_power ( *state = device->parent->power.state; else *state = ACPI_STATE_D0; - } - else { + } else { /* * Get the device's power state either directly (via _PSC) or * indirectly (via power resources). */ if (device->power.flags.explicit_get) { - status = acpi_evaluate_integer(device->handle, "_PSC", - NULL, &psc); + status = acpi_evaluate_integer(device->handle, "_PSC", + NULL, &psc); if (ACPI_FAILURE(status)) return_VALUE(-ENODEV); - device->power.state = (int) psc; - } - else if (device->power.flags.power_resources) { + device->power.state = (int)psc; + } else if (device->power.flags.power_resources) { result = acpi_power_get_inferred_state(device); if (result) return_VALUE(result); @@ -180,22 +170,19 @@ acpi_bus_get_power ( } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n", - device->pnp.bus_id, device->power.state)); + device->pnp.bus_id, device->power.state)); return_VALUE(0); } -EXPORT_SYMBOL(acpi_bus_get_power); +EXPORT_SYMBOL(acpi_bus_get_power); -int -acpi_bus_set_power ( - acpi_handle handle, - int state) +int acpi_bus_set_power(acpi_handle handle, int state) { - int result = 0; - acpi_status status = AE_OK; - struct acpi_device *device = NULL; - char object_name[5] = {'_','P','S','0'+state,'\0'}; + int result = 0; + acpi_status status = AE_OK; + struct acpi_device *device = NULL; + char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' }; ACPI_FUNCTION_TRACE("acpi_bus_set_power"); @@ -209,7 +196,8 @@ acpi_bus_set_power ( /* Make sure this is a valid target state */ if (!device->flags.power_manageable) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device is not power manageable\n")); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Device is not power manageable\n")); return_VALUE(-ENODEV); } /* @@ -219,15 +207,18 @@ acpi_bus_set_power ( if (device->power.state == ACPI_STATE_UNKNOWN) acpi_bus_get_power(device->handle, &device->power.state); if (state == device->power.state) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", state)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", + state)); return_VALUE(0); } if (!device->power.states[state].flags.valid) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n", state)); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n", + state)); return_VALUE(-ENODEV); } if (device->parent && (state < device->parent->power.state)) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Cannot set device to a higher-powered state than parent\n")); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Cannot set device to a higher-powered state than parent\n")); return_VALUE(-ENODEV); } @@ -245,18 +236,17 @@ acpi_bus_set_power ( goto end; } if (device->power.states[state].flags.explicit_set) { - status = acpi_evaluate_object(device->handle, - object_name, NULL, NULL); + status = acpi_evaluate_object(device->handle, + object_name, NULL, NULL); if (ACPI_FAILURE(status)) { result = -ENODEV; goto end; } } - } - else { + } else { if (device->power.states[state].flags.explicit_set) { - status = acpi_evaluate_object(device->handle, - object_name, NULL, NULL); + status = acpi_evaluate_object(device->handle, + object_name, NULL, NULL); if (ACPI_FAILURE(status)) { result = -ENODEV; goto end; @@ -269,19 +259,20 @@ acpi_bus_set_power ( } } -end: + end: if (result) - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error transitioning device [%s] to D%d\n", - device->pnp.bus_id, state)); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Error transitioning device [%s] to D%d\n", + device->pnp.bus_id, state)); else - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] transitioned to D%d\n", - device->pnp.bus_id, state)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Device [%s] transitioned to D%d\n", + device->pnp.bus_id, state)); return_VALUE(result); } -EXPORT_SYMBOL(acpi_bus_set_power); - +EXPORT_SYMBOL(acpi_bus_set_power); /* -------------------------------------------------------------------------- Event Management @@ -292,16 +283,12 @@ static DEFINE_SPINLOCK(acpi_bus_event_lock); LIST_HEAD(acpi_bus_event_list); DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue); -extern int event_is_open; +extern int event_is_open; -int -acpi_bus_generate_event ( - struct acpi_device *device, - u8 type, - int data) +int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data) { - struct acpi_bus_event *event = NULL; - unsigned long flags = 0; + struct acpi_bus_event *event = NULL; + unsigned long flags = 0; ACPI_FUNCTION_TRACE("acpi_bus_generate_event"); @@ -329,14 +316,13 @@ acpi_bus_generate_event ( return_VALUE(0); } + EXPORT_SYMBOL(acpi_bus_generate_event); -int -acpi_bus_receive_event ( - struct acpi_bus_event *event) +int acpi_bus_receive_event(struct acpi_bus_event *event) { - unsigned long flags = 0; - struct acpi_bus_event *entry = NULL; + unsigned long flags = 0; + struct acpi_bus_event *entry = NULL; DECLARE_WAITQUEUE(wait, current); @@ -361,7 +347,8 @@ acpi_bus_receive_event ( } spin_lock_irqsave(&acpi_bus_event_lock, flags); - entry = list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node); + entry = + list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node); if (entry) list_del(&entry->node); spin_unlock_irqrestore(&acpi_bus_event_lock, flags); @@ -375,19 +362,17 @@ acpi_bus_receive_event ( return_VALUE(0); } -EXPORT_SYMBOL(acpi_bus_receive_event); +EXPORT_SYMBOL(acpi_bus_receive_event); /* -------------------------------------------------------------------------- Notification Handling -------------------------------------------------------------------------- */ static int -acpi_bus_check_device ( - struct acpi_device *device, - int *status_changed) +acpi_bus_check_device(struct acpi_device *device, int *status_changed) { - acpi_status status = 0; + acpi_status status = 0; struct acpi_device_status old_status; ACPI_FUNCTION_TRACE("acpi_bus_check_device"); @@ -422,15 +407,14 @@ acpi_bus_check_device ( if (status_changed) *status_changed = 1; - + /* * Device Insertion/Removal */ if ((device->status.present) && !(old_status.present)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n")); /* TBD: Handle device insertion */ - } - else if (!(device->status.present) && (old_status.present)) { + } else if (!(device->status.present) && (old_status.present)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n")); /* TBD: Handle device removal */ } @@ -438,13 +422,10 @@ acpi_bus_check_device ( return_VALUE(0); } - -static int -acpi_bus_check_scope ( - struct acpi_device *device) +static int acpi_bus_check_scope(struct acpi_device *device) { - int result = 0; - int status_changed = 0; + int result = 0; + int status_changed = 0; ACPI_FUNCTION_TRACE("acpi_bus_check_scope"); @@ -467,20 +448,15 @@ acpi_bus_check_scope ( return_VALUE(0); } - /** * acpi_bus_notify * --------------- * Callback for all 'system-level' device notifications (values 0x00-0x7F). */ -static void -acpi_bus_notify ( - acpi_handle handle, - u32 type, - void *data) +static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) { - int result = 0; - struct acpi_device *device = NULL; + int result = 0; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_bus_notify"); @@ -490,64 +466,73 @@ acpi_bus_notify ( switch (type) { case ACPI_NOTIFY_BUS_CHECK: - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received BUS CHECK notification for device [%s]\n", - device->pnp.bus_id)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Received BUS CHECK notification for device [%s]\n", + device->pnp.bus_id)); result = acpi_bus_check_scope(device); /* * TBD: We'll need to outsource certain events to non-ACPI - * drivers via the device manager (device.c). + * drivers via the device manager (device.c). */ break; case ACPI_NOTIFY_DEVICE_CHECK: - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE CHECK notification for device [%s]\n", - device->pnp.bus_id)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Received DEVICE CHECK notification for device [%s]\n", + device->pnp.bus_id)); result = acpi_bus_check_device(device, NULL); /* * TBD: We'll need to outsource certain events to non-ACPI - * drivers via the device manager (device.c). + * drivers via the device manager (device.c). */ break; case ACPI_NOTIFY_DEVICE_WAKE: - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE WAKE notification for device [%s]\n", - device->pnp.bus_id)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Received DEVICE WAKE notification for device [%s]\n", + device->pnp.bus_id)); /* TBD */ break; case ACPI_NOTIFY_EJECT_REQUEST: - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received EJECT REQUEST notification for device [%s]\n", - device->pnp.bus_id)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Received EJECT REQUEST notification for device [%s]\n", + device->pnp.bus_id)); /* TBD */ break; case ACPI_NOTIFY_DEVICE_CHECK_LIGHT: - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE CHECK LIGHT notification for device [%s]\n", - device->pnp.bus_id)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Received DEVICE CHECK LIGHT notification for device [%s]\n", + device->pnp.bus_id)); /* TBD: Exactly what does 'light' mean? */ break; case ACPI_NOTIFY_FREQUENCY_MISMATCH: - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received FREQUENCY MISMATCH notification for device [%s]\n", - device->pnp.bus_id)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Received FREQUENCY MISMATCH notification for device [%s]\n", + device->pnp.bus_id)); /* TBD */ break; case ACPI_NOTIFY_BUS_MODE_MISMATCH: - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received BUS MODE MISMATCH notification for device [%s]\n", - device->pnp.bus_id)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Received BUS MODE MISMATCH notification for device [%s]\n", + device->pnp.bus_id)); /* TBD */ break; case ACPI_NOTIFY_POWER_FAULT: - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received POWER FAULT notification for device [%s]\n", - device->pnp.bus_id)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Received POWER FAULT notification for device [%s]\n", + device->pnp.bus_id)); /* TBD */ break; default: - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received unknown/unsupported notification [%08x]\n", - type)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Received unknown/unsupported notification [%08x]\n", + type)); break; } @@ -558,13 +543,12 @@ acpi_bus_notify ( Initialization/Cleanup -------------------------------------------------------------------------- */ -static int __init -acpi_bus_init_irq (void) +static int __init acpi_bus_init_irq(void) { - acpi_status status = AE_OK; - union acpi_object arg = {ACPI_TYPE_INTEGER}; - struct acpi_object_list arg_list = {1, &arg}; - char *message = NULL; + acpi_status status = AE_OK; + union acpi_object arg = { ACPI_TYPE_INTEGER }; + struct acpi_object_list arg_list = { 1, &arg }; + char *message = NULL; ACPI_FUNCTION_TRACE("acpi_bus_init_irq"); @@ -601,12 +585,10 @@ acpi_bus_init_irq (void) return_VALUE(0); } - -void __init -acpi_early_init (void) +void __init acpi_early_init(void) { - acpi_status status = AE_OK; - struct acpi_buffer buffer = {sizeof(acpi_fadt), &acpi_fadt}; + acpi_status status = AE_OK; + struct acpi_buffer buffer = { sizeof(acpi_fadt), &acpi_fadt }; ACPI_FUNCTION_TRACE("acpi_early_init"); @@ -619,13 +601,15 @@ acpi_early_init (void) status = acpi_initialize_subsystem(); if (ACPI_FAILURE(status)) { - printk(KERN_ERR PREFIX "Unable to initialize the ACPI Interpreter\n"); + printk(KERN_ERR PREFIX + "Unable to initialize the ACPI Interpreter\n"); goto error0; } status = acpi_load_tables(); if (ACPI_FAILURE(status)) { - printk(KERN_ERR PREFIX "Unable to load the System Description Tables\n"); + printk(KERN_ERR PREFIX + "Unable to load the System Description Tables\n"); goto error0; } @@ -637,7 +621,6 @@ acpi_early_init (void) printk(KERN_ERR PREFIX "Unable to get the FADT\n"); goto error0; } - #ifdef CONFIG_X86 if (!acpi_ioapic) { extern acpi_interrupt_flags acpi_sci_flags; @@ -647,7 +630,8 @@ acpi_early_init (void) acpi_sci_flags.trigger = 3; /* Set PIC-mode SCI trigger type */ - acpi_pic_sci_set_trigger(acpi_fadt.sci_int, acpi_sci_flags.trigger); + acpi_pic_sci_set_trigger(acpi_fadt.sci_int, + acpi_sci_flags.trigger); } else { extern int acpi_sci_override_gsi; /* @@ -658,7 +642,10 @@ acpi_early_init (void) } #endif - status = acpi_enable_subsystem(~(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE)); + status = + acpi_enable_subsystem(~ + (ACPI_NO_HARDWARE_INIT | + ACPI_NO_ACPI_ENABLE)); if (ACPI_FAILURE(status)) { printk(KERN_ERR PREFIX "Unable to enable ACPI\n"); goto error0; @@ -666,30 +653,32 @@ acpi_early_init (void) return_VOID; -error0: + error0: disable_acpi(); return_VOID; } -static int __init -acpi_bus_init (void) +static int __init acpi_bus_init(void) { - int result = 0; - acpi_status status = AE_OK; - extern acpi_status acpi_os_initialize1(void); + int result = 0; + acpi_status status = AE_OK; + extern acpi_status acpi_os_initialize1(void); ACPI_FUNCTION_TRACE("acpi_bus_init"); status = acpi_os_initialize1(); - status = acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE); + status = + acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE); if (ACPI_FAILURE(status)) { - printk(KERN_ERR PREFIX "Unable to start the ACPI Interpreter\n"); + printk(KERN_ERR PREFIX + "Unable to start the ACPI Interpreter\n"); goto error1; } if (ACPI_FAILURE(status)) { - printk(KERN_ERR PREFIX "Unable to initialize ACPI OS objects\n"); + printk(KERN_ERR PREFIX + "Unable to initialize ACPI OS objects\n"); goto error1; } #ifdef CONFIG_ACPI_EC @@ -723,9 +712,12 @@ acpi_bus_init (void) /* * Register the for all standard device notifications. */ - status = acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, &acpi_bus_notify, NULL); + status = + acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, + &acpi_bus_notify, NULL); if (ACPI_FAILURE(status)) { - printk(KERN_ERR PREFIX "Unable to register for device notifications\n"); + printk(KERN_ERR PREFIX + "Unable to register for device notifications\n"); goto error1; } @@ -737,21 +729,20 @@ acpi_bus_init (void) return_VALUE(0); /* Mimic structured exception handling */ -error1: + error1: acpi_terminate(); return_VALUE(-ENODEV); } -decl_subsys(acpi,NULL,NULL); +decl_subsys(acpi, NULL, NULL); -static int __init acpi_init (void) +static int __init acpi_init(void) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_init"); - printk(KERN_INFO PREFIX "Subsystem revision %08x\n", - ACPI_CA_VERSION); + printk(KERN_INFO PREFIX "Subsystem revision %08x\n", ACPI_CA_VERSION); if (acpi_disabled) { printk(KERN_INFO PREFIX "Interpreter disabled.\n"); @@ -767,7 +758,8 @@ static int __init acpi_init (void) if (!PM_IS_ACTIVE()) pm_active = 1; else { - printk(KERN_INFO PREFIX "APM is already active, exiting\n"); + printk(KERN_INFO PREFIX + "APM is already active, exiting\n"); disable_acpi(); result = -ENODEV; } diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 8162fd0..4b6d9f0 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -32,7 +32,6 @@ #include #include - #define ACPI_BUTTON_COMPONENT 0x00080000 #define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver" #define ACPI_BUTTON_CLASS "button" @@ -42,7 +41,7 @@ #define ACPI_BUTTON_NOTIFY_STATUS 0x80 #define ACPI_BUTTON_SUBCLASS_POWER "power" -#define ACPI_BUTTON_HID_POWER "PNP0C0C" +#define ACPI_BUTTON_HID_POWER "PNP0C0C" #define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button (CM)" #define ACPI_BUTTON_DEVICE_NAME_POWERF "Power Button (FF)" #define ACPI_BUTTON_TYPE_POWER 0x01 @@ -61,65 +60,65 @@ #define ACPI_BUTTON_TYPE_LID 0x05 #define _COMPONENT ACPI_BUTTON_COMPONENT -ACPI_MODULE_NAME ("acpi_button") +ACPI_MODULE_NAME("acpi_button") -MODULE_AUTHOR("Paul Diefenbaugh"); + MODULE_AUTHOR("Paul Diefenbaugh"); MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME); MODULE_LICENSE("GPL"); - -static int acpi_button_add (struct acpi_device *device); -static int acpi_button_remove (struct acpi_device *device, int type); +static int acpi_button_add(struct acpi_device *device); +static int acpi_button_remove(struct acpi_device *device, int type); static int acpi_button_info_open_fs(struct inode *inode, struct file *file); static int acpi_button_state_open_fs(struct inode *inode, struct file *file); static struct acpi_driver acpi_button_driver = { - .name = ACPI_BUTTON_DRIVER_NAME, - .class = ACPI_BUTTON_CLASS, - .ids = "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E", - .ops = { - .add = acpi_button_add, - .remove = acpi_button_remove, - }, + .name = ACPI_BUTTON_DRIVER_NAME, + .class = ACPI_BUTTON_CLASS, + .ids = "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E", + .ops = { + .add = acpi_button_add, + .remove = acpi_button_remove, + }, }; struct acpi_button { - acpi_handle handle; - struct acpi_device *device; /* Fixed button kludge */ - u8 type; - unsigned long pushed; + acpi_handle handle; + struct acpi_device *device; /* Fixed button kludge */ + u8 type; + unsigned long pushed; }; static struct file_operations acpi_button_info_fops = { - .open = acpi_button_info_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_button_info_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; static struct file_operations acpi_button_state_fops = { - .open = acpi_button_state_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_button_state_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; + /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ -static struct proc_dir_entry *acpi_button_dir; +static struct proc_dir_entry *acpi_button_dir; static int acpi_button_info_seq_show(struct seq_file *seq, void *offset) { - struct acpi_button *button = (struct acpi_button *) seq->private; + struct acpi_button *button = (struct acpi_button *)seq->private; ACPI_FUNCTION_TRACE("acpi_button_info_seq_show"); if (!button || !button->device) return_VALUE(0); - seq_printf(seq, "type: %s\n", - acpi_device_name(button->device)); + seq_printf(seq, "type: %s\n", + acpi_device_name(button->device)); return_VALUE(0); } @@ -128,24 +127,24 @@ static int acpi_button_info_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_button_info_seq_show, PDE(inode)->data); } - + static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) { - struct acpi_button *button = (struct acpi_button *) seq->private; - acpi_status status; - unsigned long state; + struct acpi_button *button = (struct acpi_button *)seq->private; + acpi_status status; + unsigned long state; ACPI_FUNCTION_TRACE("acpi_button_state_seq_show"); if (!button || !button->device) return_VALUE(0); - status = acpi_evaluate_integer(button->handle,"_LID",NULL,&state); + status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state); if (ACPI_FAILURE(status)) { seq_printf(seq, "state: unsupported\n"); - } - else{ - seq_printf(seq, "state: %s\n", (state ? "open" : "closed")); + } else { + seq_printf(seq, "state: %s\n", + (state ? "open" : "closed")); } return_VALUE(0); @@ -160,12 +159,10 @@ static struct proc_dir_entry *acpi_power_dir; static struct proc_dir_entry *acpi_sleep_dir; static struct proc_dir_entry *acpi_lid_dir; -static int -acpi_button_add_fs ( - struct acpi_device *device) +static int acpi_button_add_fs(struct acpi_device *device) { - struct proc_dir_entry *entry = NULL; - struct acpi_button *button = NULL; + struct proc_dir_entry *entry = NULL; + struct acpi_button *button = NULL; ACPI_FUNCTION_TRACE("acpi_button_add_fs"); @@ -178,21 +175,21 @@ acpi_button_add_fs ( case ACPI_BUTTON_TYPE_POWER: case ACPI_BUTTON_TYPE_POWERF: if (!acpi_power_dir) - acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER, - acpi_button_dir); + acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER, + acpi_button_dir); entry = acpi_power_dir; break; case ACPI_BUTTON_TYPE_SLEEP: case ACPI_BUTTON_TYPE_SLEEPF: if (!acpi_sleep_dir) - acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP, - acpi_button_dir); + acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP, + acpi_button_dir); entry = acpi_sleep_dir; break; case ACPI_BUTTON_TYPE_LID: if (!acpi_lid_dir) - acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, - acpi_button_dir); + acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, + acpi_button_dir); entry = acpi_lid_dir; break; } @@ -208,11 +205,11 @@ acpi_button_add_fs ( /* 'info' [R] */ entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, - S_IRUGO, acpi_device_dir(device)); + S_IRUGO, acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_BUTTON_FILE_INFO)); + "Unable to create '%s' fs entry\n", + ACPI_BUTTON_FILE_INFO)); else { entry->proc_fops = &acpi_button_info_fops; entry->data = acpi_driver_data(device); @@ -222,11 +219,11 @@ acpi_button_add_fs ( /* show lid state [R] */ if (button->type == ACPI_BUTTON_TYPE_LID) { entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, - S_IRUGO, acpi_device_dir(device)); + S_IRUGO, acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_BUTTON_FILE_INFO)); + "Unable to create '%s' fs entry\n", + ACPI_BUTTON_FILE_INFO)); else { entry->proc_fops = &acpi_button_state_fops; entry->data = acpi_driver_data(device); @@ -237,12 +234,9 @@ acpi_button_add_fs ( return_VALUE(0); } - -static int -acpi_button_remove_fs ( - struct acpi_device *device) +static int acpi_button_remove_fs(struct acpi_device *device) { - struct acpi_button *button = NULL; + struct acpi_button *button = NULL; ACPI_FUNCTION_TRACE("acpi_button_remove_fs"); @@ -250,30 +244,25 @@ acpi_button_remove_fs ( if (acpi_device_dir(device)) { if (button->type == ACPI_BUTTON_TYPE_LID) remove_proc_entry(ACPI_BUTTON_FILE_STATE, - acpi_device_dir(device)); + acpi_device_dir(device)); remove_proc_entry(ACPI_BUTTON_FILE_INFO, - acpi_device_dir(device)); + acpi_device_dir(device)); remove_proc_entry(acpi_device_bid(device), - acpi_device_dir(device)->parent); + acpi_device_dir(device)->parent); acpi_device_dir(device) = NULL; } return_VALUE(0); } - /* -------------------------------------------------------------------------- Driver Interface -------------------------------------------------------------------------- */ -static void -acpi_button_notify ( - acpi_handle handle, - u32 event, - void *data) +static void acpi_button_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_button *button = (struct acpi_button *) data; + struct acpi_button *button = (struct acpi_button *)data; ACPI_FUNCTION_TRACE("acpi_button_notify"); @@ -282,24 +271,22 @@ acpi_button_notify ( switch (event) { case ACPI_BUTTON_NOTIFY_STATUS: - acpi_bus_generate_event(button->device, event, ++button->pushed); + acpi_bus_generate_event(button->device, event, + ++button->pushed); break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Unsupported event [0x%x]\n", event)); + "Unsupported event [0x%x]\n", event)); break; } return_VOID; } - -static acpi_status -acpi_button_notify_fixed ( - void *data) +static acpi_status acpi_button_notify_fixed(void *data) { - struct acpi_button *button = (struct acpi_button *) data; - + struct acpi_button *button = (struct acpi_button *)data; + ACPI_FUNCTION_TRACE("acpi_button_notify_fixed"); if (!button) @@ -310,14 +297,11 @@ acpi_button_notify_fixed ( return_ACPI_STATUS(AE_OK); } - -static int -acpi_button_add ( - struct acpi_device *device) +static int acpi_button_add(struct acpi_device *device) { - int result = 0; - acpi_status status = AE_OK; - struct acpi_button *button = NULL; + int result = 0; + acpi_status status = AE_OK; + struct acpi_button *button = NULL; ACPI_FUNCTION_TRACE("acpi_button_add"); @@ -339,42 +323,34 @@ acpi_button_add ( */ if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) { button->type = ACPI_BUTTON_TYPE_POWER; - strcpy(acpi_device_name(device), - ACPI_BUTTON_DEVICE_NAME_POWER); - sprintf(acpi_device_class(device), "%s/%s", + strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_POWER); + sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); - } - else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) { + } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) { button->type = ACPI_BUTTON_TYPE_POWERF; strcpy(acpi_device_name(device), - ACPI_BUTTON_DEVICE_NAME_POWERF); - sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_DEVICE_NAME_POWERF); + sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); - } - else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) { + } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) { button->type = ACPI_BUTTON_TYPE_SLEEP; - strcpy(acpi_device_name(device), - ACPI_BUTTON_DEVICE_NAME_SLEEP); - sprintf(acpi_device_class(device), "%s/%s", + strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_SLEEP); + sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); - } - else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) { + } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) { button->type = ACPI_BUTTON_TYPE_SLEEPF; strcpy(acpi_device_name(device), - ACPI_BUTTON_DEVICE_NAME_SLEEPF); - sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_DEVICE_NAME_SLEEPF); + sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); - } - else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) { + } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) { button->type = ACPI_BUTTON_TYPE_LID; - strcpy(acpi_device_name(device), - ACPI_BUTTON_DEVICE_NAME_LID); - sprintf(acpi_device_class(device), "%s/%s", + strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_LID); + sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); - } - else { + } else { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n", - acpi_device_hid(device))); + acpi_device_hid(device))); result = -ENODEV; goto end; } @@ -385,46 +361,46 @@ acpi_button_add ( switch (button->type) { case ACPI_BUTTON_TYPE_POWERF: - status = acpi_install_fixed_event_handler ( - ACPI_EVENT_POWER_BUTTON, - acpi_button_notify_fixed, - button); + status = + acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, + acpi_button_notify_fixed, + button); break; case ACPI_BUTTON_TYPE_SLEEPF: - status = acpi_install_fixed_event_handler ( - ACPI_EVENT_SLEEP_BUTTON, - acpi_button_notify_fixed, - button); + status = + acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, + acpi_button_notify_fixed, + button); break; default: - status = acpi_install_notify_handler ( - button->handle, - ACPI_DEVICE_NOTIFY, - acpi_button_notify, - button); + status = acpi_install_notify_handler(button->handle, + ACPI_DEVICE_NOTIFY, + acpi_button_notify, + button); break; } if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); + "Error installing notify handler\n")); result = -ENODEV; goto end; } if (device->wakeup.flags.valid) { /* Button's GPE is run-wake GPE */ - acpi_set_gpe_type(device->wakeup.gpe_device, - device->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN); - acpi_enable_gpe(device->wakeup.gpe_device, - device->wakeup.gpe_number, ACPI_NOT_ISR); + acpi_set_gpe_type(device->wakeup.gpe_device, + device->wakeup.gpe_number, + ACPI_GPE_TYPE_WAKE_RUN); + acpi_enable_gpe(device->wakeup.gpe_device, + device->wakeup.gpe_number, ACPI_NOT_ISR); device->wakeup.state.enabled = 1; } - printk(KERN_INFO PREFIX "%s [%s]\n", - acpi_device_name(device), acpi_device_bid(device)); + printk(KERN_INFO PREFIX "%s [%s]\n", + acpi_device_name(device), acpi_device_bid(device)); -end: + end: if (result) { acpi_button_remove_fs(device); kfree(button); @@ -433,12 +409,10 @@ end: return_VALUE(result); } - -static int -acpi_button_remove (struct acpi_device *device, int type) +static int acpi_button_remove(struct acpi_device *device, int type) { - acpi_status status = 0; - struct acpi_button *button = NULL; + acpi_status status = 0; + struct acpi_button *button = NULL; ACPI_FUNCTION_TRACE("acpi_button_remove"); @@ -450,35 +424,36 @@ acpi_button_remove (struct acpi_device *device, int type) /* Unregister for device notifications. */ switch (button->type) { case ACPI_BUTTON_TYPE_POWERF: - status = acpi_remove_fixed_event_handler( - ACPI_EVENT_POWER_BUTTON, acpi_button_notify_fixed); + status = + acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, + acpi_button_notify_fixed); break; case ACPI_BUTTON_TYPE_SLEEPF: - status = acpi_remove_fixed_event_handler( - ACPI_EVENT_SLEEP_BUTTON, acpi_button_notify_fixed); + status = + acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, + acpi_button_notify_fixed); break; default: status = acpi_remove_notify_handler(button->handle, - ACPI_DEVICE_NOTIFY, acpi_button_notify); + ACPI_DEVICE_NOTIFY, + acpi_button_notify); break; } if (ACPI_FAILURE(status)) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); + "Error removing notify handler\n")); - acpi_button_remove_fs(device); + acpi_button_remove_fs(device); kfree(button); return_VALUE(0); } - -static int __init -acpi_button_init (void) +static int __init acpi_button_init(void) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_button_init"); @@ -495,15 +470,13 @@ acpi_button_init (void) return_VALUE(0); } - -static void __exit -acpi_button_exit (void) +static void __exit acpi_button_exit(void) { ACPI_FUNCTION_TRACE("acpi_button_exit"); acpi_bus_unregister_driver(&acpi_button_driver); - if (acpi_power_dir) + if (acpi_power_dir) remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir); if (acpi_sleep_dir) remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir); @@ -514,6 +487,5 @@ acpi_button_exit (void) return_VOID; } - module_init(acpi_button_init); module_exit(acpi_button_exit); diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 97013dd..10dd695 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c @@ -44,9 +44,9 @@ #define ACPI_CONTAINER_COMPONENT 0x01000000 #define _COMPONENT ACPI_CONTAINER_COMPONENT -ACPI_MODULE_NAME ("acpi_container") +ACPI_MODULE_NAME("acpi_container") -MODULE_AUTHOR("Anil S Keshavamurthy"); + MODULE_AUTHOR("Anil S Keshavamurthy"); MODULE_DESCRIPTION(ACPI_CONTAINER_DRIVER_NAME); MODULE_LICENSE("GPL"); @@ -56,41 +56,38 @@ static int acpi_container_add(struct acpi_device *device); static int acpi_container_remove(struct acpi_device *device, int type); static struct acpi_driver acpi_container_driver = { - .name = ACPI_CONTAINER_DRIVER_NAME, - .class = ACPI_CONTAINER_CLASS, - .ids = "ACPI0004,PNP0A05,PNP0A06", - .ops = { - .add = acpi_container_add, - .remove = acpi_container_remove, - }, + .name = ACPI_CONTAINER_DRIVER_NAME, + .class = ACPI_CONTAINER_CLASS, + .ids = "ACPI0004,PNP0A05,PNP0A06", + .ops = { + .add = acpi_container_add, + .remove = acpi_container_remove, + }, }; - /*******************************************************************/ -static int -is_device_present(acpi_handle handle) +static int is_device_present(acpi_handle handle) { - acpi_handle temp; - acpi_status status; - unsigned long sta; + acpi_handle temp; + acpi_status status; + unsigned long sta; ACPI_FUNCTION_TRACE("is_device_present"); status = acpi_get_handle(handle, "_STA", &temp); if (ACPI_FAILURE(status)) - return_VALUE(1); /* _STA not found, assmue device present */ + return_VALUE(1); /* _STA not found, assmue device present */ status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status)) - return_VALUE(0); /* Firmware error */ + return_VALUE(0); /* Firmware error */ return_VALUE((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT); } /*******************************************************************/ -static int -acpi_container_add(struct acpi_device *device) +static int acpi_container_add(struct acpi_device *device) { struct acpi_container *container; @@ -102,28 +99,26 @@ acpi_container_add(struct acpi_device *device) } container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL); - if(!container) + if (!container) return_VALUE(-ENOMEM); - + memset(container, 0, sizeof(struct acpi_container)); container->handle = device->handle; strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS); acpi_driver_data(device) = container; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n", \ - acpi_device_name(device), acpi_device_bid(device))); - + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n", + acpi_device_name(device), acpi_device_bid(device))); return_VALUE(0); } -static int -acpi_container_remove(struct acpi_device *device, int type) +static int acpi_container_remove(struct acpi_device *device, int type) { - acpi_status status = AE_OK; - struct acpi_container *pc = NULL; - pc = (struct acpi_container*) acpi_driver_data(device); + acpi_status status = AE_OK; + struct acpi_container *pc = NULL; + pc = (struct acpi_container *)acpi_driver_data(device); if (pc) kfree(pc); @@ -131,9 +126,7 @@ acpi_container_remove(struct acpi_device *device, int type) return status; } - -static int -container_device_add(struct acpi_device **device, acpi_handle handle) +static int container_device_add(struct acpi_device **device, acpi_handle handle) { acpi_handle phandle; struct acpi_device *pdev; @@ -158,10 +151,9 @@ container_device_add(struct acpi_device **device, acpi_handle handle) return_VALUE(result); } -static void -container_notify_cb(acpi_handle handle, u32 type, void *context) +static void container_notify_cb(acpi_handle handle, u32 type, void *context) { - struct acpi_device *device = NULL; + struct acpi_device *device = NULL; int result; int present; acpi_status status; @@ -169,14 +161,14 @@ container_notify_cb(acpi_handle handle, u32 type, void *context) ACPI_FUNCTION_TRACE("container_notify_cb"); present = is_device_present(handle); - + switch (type) { case ACPI_NOTIFY_BUS_CHECK: /* Fall through */ case ACPI_NOTIFY_DEVICE_CHECK: printk("Container driver received %s event\n", - (type == ACPI_NOTIFY_BUS_CHECK)? - "ACPI_NOTIFY_BUS_CHECK":"ACPI_NOTIFY_DEVICE_CHECK"); + (type == ACPI_NOTIFY_BUS_CHECK) ? + "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"); status = acpi_bus_get_device(handle, &device); if (present) { if (ACPI_FAILURE(status) || !device) { @@ -207,15 +199,13 @@ container_notify_cb(acpi_handle handle, u32 type, void *context) static acpi_status container_walk_namespace_cb(acpi_handle handle, - u32 lvl, - void *context, - void **rv) + u32 lvl, void *context, void **rv) { - char *hid = NULL; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - struct acpi_device_info *info; - acpi_status status; - int *action = context; + char *hid = NULL; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_device_info *info; + acpi_status status; + int *action = context; ACPI_FUNCTION_TRACE("container_walk_namespace_cb"); @@ -233,66 +223,60 @@ container_walk_namespace_cb(acpi_handle handle, } if (strcmp(hid, "ACPI0004") && strcmp(hid, "PNP0A05") && - strcmp(hid, "PNP0A06")) { + strcmp(hid, "PNP0A06")) { goto end; } - switch(*action) { + switch (*action) { case INSTALL_NOTIFY_HANDLER: acpi_install_notify_handler(handle, - ACPI_SYSTEM_NOTIFY, - container_notify_cb, - NULL); + ACPI_SYSTEM_NOTIFY, + container_notify_cb, NULL); break; case UNINSTALL_NOTIFY_HANDLER: acpi_remove_notify_handler(handle, - ACPI_SYSTEM_NOTIFY, - container_notify_cb); + ACPI_SYSTEM_NOTIFY, + container_notify_cb); break; default: break; } -end: + end: acpi_os_free(buffer.pointer); return_ACPI_STATUS(AE_OK); } - -static int __init -acpi_container_init(void) +static int __init acpi_container_init(void) { - int result = 0; - int action = INSTALL_NOTIFY_HANDLER; + int result = 0; + int action = INSTALL_NOTIFY_HANDLER; result = acpi_bus_register_driver(&acpi_container_driver); if (result < 0) { - return(result); + return (result); } /* register notify handler to every container device */ acpi_walk_namespace(ACPI_TYPE_DEVICE, - ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, - container_walk_namespace_cb, - &action, NULL); + ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, + container_walk_namespace_cb, &action, NULL); - return(0); + return (0); } -static void __exit -acpi_container_exit(void) +static void __exit acpi_container_exit(void) { - int action = UNINSTALL_NOTIFY_HANDLER; + int action = UNINSTALL_NOTIFY_HANDLER; ACPI_FUNCTION_TRACE("acpi_container_exit"); acpi_walk_namespace(ACPI_TYPE_DEVICE, - ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, - container_walk_namespace_cb, - &action, NULL); + ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, + container_walk_namespace_cb, &action, NULL); acpi_bus_unregister_driver(&acpi_container_driver); diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c index 2c0dac5..263322b 100644 --- a/drivers/acpi/debug.c +++ b/drivers/acpi/debug.c @@ -12,17 +12,14 @@ #include #define _COMPONENT ACPI_SYSTEM_COMPONENT -ACPI_MODULE_NAME ("debug") - +ACPI_MODULE_NAME("debug") #define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer" #define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level" - #ifdef MODULE_PARAM_PREFIX #undef MODULE_PARAM_PREFIX #endif - #define MODULE_PARAM_PREFIX -module_param(acpi_dbg_layer, uint, 0400); + module_param(acpi_dbg_layer, uint, 0400); module_param(acpi_dbg_level, uint, 0400); struct acpi_dlayer { @@ -35,8 +32,7 @@ struct acpi_dlevel { }; #define ACPI_DEBUG_INIT(v) { .name = #v, .value = v } -static const struct acpi_dlayer acpi_debug_layers[] = -{ +static const struct acpi_dlayer acpi_debug_layers[] = { ACPI_DEBUG_INIT(ACPI_UTILITIES), ACPI_DEBUG_INIT(ACPI_HARDWARE), ACPI_DEBUG_INIT(ACPI_EVENTS), @@ -53,8 +49,7 @@ static const struct acpi_dlayer acpi_debug_layers[] = ACPI_DEBUG_INIT(ACPI_TOOLS), }; -static const struct acpi_dlevel acpi_debug_levels[] = -{ +static const struct acpi_dlevel acpi_debug_levels[] = { ACPI_DEBUG_INIT(ACPI_LV_ERROR), ACPI_DEBUG_INIT(ACPI_LV_WARN), ACPI_DEBUG_INIT(ACPI_LV_INIT), @@ -88,81 +83,77 @@ static const struct acpi_dlevel acpi_debug_levels[] = ACPI_DEBUG_INIT(ACPI_LV_AML_DISASSEMBLE), ACPI_DEBUG_INIT(ACPI_LV_VERBOSE_INFO), ACPI_DEBUG_INIT(ACPI_LV_FULL_TABLES), - ACPI_DEBUG_INIT(ACPI_LV_EVENTS), + ACPI_DEBUG_INIT(ACPI_LV_EVENTS), }; static int -acpi_system_read_debug ( - char *page, - char **start, - off_t off, - int count, - int *eof, - void *data) +acpi_system_read_debug(char *page, + char **start, off_t off, int count, int *eof, void *data) { - char *p = page; - int size = 0; - unsigned int i; + char *p = page; + int size = 0; + unsigned int i; if (off != 0) goto end; p += sprintf(p, "%-25s\tHex SET\n", "Description"); - switch ((unsigned long) data) { + switch ((unsigned long)data) { case 0: for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) { p += sprintf(p, "%-25s\t0x%08lX [%c]\n", - acpi_debug_layers[i].name, - acpi_debug_layers[i].value, - (acpi_dbg_layer & acpi_debug_layers[i].value) ? - '*' : ' '); + acpi_debug_layers[i].name, + acpi_debug_layers[i].value, + (acpi_dbg_layer & acpi_debug_layers[i]. + value) ? '*' : ' '); } p += sprintf(p, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS", - ACPI_ALL_DRIVERS, - (acpi_dbg_layer & ACPI_ALL_DRIVERS) == ACPI_ALL_DRIVERS? - '*' : (acpi_dbg_layer & ACPI_ALL_DRIVERS) == 0 ? - ' ' : '-'); + ACPI_ALL_DRIVERS, + (acpi_dbg_layer & ACPI_ALL_DRIVERS) == + ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer & + ACPI_ALL_DRIVERS) == + 0 ? ' ' : '-'); p += sprintf(p, - "--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n", - acpi_dbg_layer); + "--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n", + acpi_dbg_layer); break; case 1: for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) { p += sprintf(p, "%-25s\t0x%08lX [%c]\n", - acpi_debug_levels[i].name, - acpi_debug_levels[i].value, - (acpi_dbg_level & acpi_debug_levels[i].value) ? - '*' : ' '); + acpi_debug_levels[i].name, + acpi_debug_levels[i].value, + (acpi_dbg_level & acpi_debug_levels[i]. + value) ? '*' : ' '); } p += sprintf(p, "--\ndebug_level = 0x%08X (* = enabled)\n", - acpi_dbg_level); + acpi_dbg_level); break; default: p += sprintf(p, "Invalid debug option\n"); break; } - -end: + + end: size = (p - page); - if (size <= off+count) *eof = 1; + if (size <= off + count) + *eof = 1; *start = page + off; size -= off; - if (size>count) size = count; - if (size<0) size = 0; + if (size > count) + size = count; + if (size < 0) + size = 0; return size; } - static int -acpi_system_write_debug ( - struct file *file, - const char __user *buffer, - unsigned long count, - void *data) +acpi_system_write_debug(struct file *file, + const char __user * buffer, + unsigned long count, void *data) { - char debug_string[12] = {'\0'}; + char debug_string[12] = { '\0' }; ACPI_FUNCTION_TRACE("acpi_system_write_debug"); @@ -174,7 +165,7 @@ acpi_system_write_debug ( debug_string[count] = '\0'; - switch ((unsigned long) data) { + switch ((unsigned long)data) { case 0: acpi_dbg_layer = simple_strtoul(debug_string, NULL, 0); break; @@ -190,9 +181,9 @@ acpi_system_write_debug ( static int __init acpi_debug_init(void) { - struct proc_dir_entry *entry; + struct proc_dir_entry *entry; int error = 0; - char * name; + char *name; ACPI_FUNCTION_TRACE("acpi_debug_init"); @@ -201,8 +192,10 @@ static int __init acpi_debug_init(void) /* 'debug_layer' [R/W] */ name = ACPI_SYSTEM_FILE_DEBUG_LAYER; - entry = create_proc_read_entry(name, S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir, - acpi_system_read_debug,(void *)0); + entry = + create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, + acpi_root_dir, acpi_system_read_debug, + (void *)0); if (entry) entry->write_proc = acpi_system_write_debug; else @@ -210,19 +203,21 @@ static int __init acpi_debug_init(void) /* 'debug_level' [R/W] */ name = ACPI_SYSTEM_FILE_DEBUG_LEVEL; - entry = create_proc_read_entry(name, S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir, - acpi_system_read_debug, (void *)1); - if (entry) + entry = + create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, + acpi_root_dir, acpi_system_read_debug, + (void *)1); + if (entry) entry->write_proc = acpi_system_write_debug; else goto Error; - Done: + Done: return_VALUE(error); - Error: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' proc fs entry\n", name)); + Error: + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' proc fs entry\n", name)); remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir); remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir); diff --git a/drivers/acpi/dispatcher/dsfield.c b/drivers/acpi/dispatcher/dsfield.c index 8419398..2022aea 100644 --- a/drivers/acpi/dispatcher/dsfield.c +++ b/drivers/acpi/dispatcher/dsfield.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -49,18 +48,14 @@ #include #include - #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dsfield") +ACPI_MODULE_NAME("dsfield") /* Local prototypes */ - static acpi_status -acpi_ds_get_field_names ( - struct acpi_create_field_info *info, - struct acpi_walk_state *walk_state, - union acpi_parse_object *arg); - +acpi_ds_get_field_names(struct acpi_create_field_info *info, + struct acpi_walk_state *walk_state, + union acpi_parse_object *arg); /******************************************************************************* * @@ -82,41 +77,36 @@ acpi_ds_get_field_names ( ******************************************************************************/ acpi_status -acpi_ds_create_buffer_field ( - union acpi_parse_object *op, - struct acpi_walk_state *walk_state) +acpi_ds_create_buffer_field(union acpi_parse_object *op, + struct acpi_walk_state *walk_state) { - union acpi_parse_object *arg; - struct acpi_namespace_node *node; - acpi_status status; - union acpi_operand_object *obj_desc; - union acpi_operand_object *second_desc = NULL; - u32 flags; - - - ACPI_FUNCTION_TRACE ("ds_create_buffer_field"); + union acpi_parse_object *arg; + struct acpi_namespace_node *node; + acpi_status status; + union acpi_operand_object *obj_desc; + union acpi_operand_object *second_desc = NULL; + u32 flags; + ACPI_FUNCTION_TRACE("ds_create_buffer_field"); /* Get the name_string argument */ if (op->common.aml_opcode == AML_CREATE_FIELD_OP) { - arg = acpi_ps_get_arg (op, 3); - } - else { + arg = acpi_ps_get_arg(op, 3); + } else { /* Create Bit/Byte/Word/Dword field */ - arg = acpi_ps_get_arg (op, 2); + arg = acpi_ps_get_arg(op, 2); } if (!arg) { - return_ACPI_STATUS (AE_AML_NO_OPERAND); + return_ACPI_STATUS(AE_AML_NO_OPERAND); } if (walk_state->deferred_node) { node = walk_state->deferred_node; status = AE_OK; - } - else { + } else { /* * During the load phase, we want to enter the name of the field into * the namespace. During the execute phase (when we evaluate the size @@ -124,21 +114,22 @@ acpi_ds_create_buffer_field ( */ if (walk_state->parse_flags & ACPI_PARSE_EXECUTE) { flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE; - } - else { + } else { flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | - ACPI_NS_ERROR_IF_FOUND; + ACPI_NS_ERROR_IF_FOUND; } /* * Enter the name_string into the namespace */ - status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string, - ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, - flags, walk_state, &(node)); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR (arg->common.value.string, status); - return_ACPI_STATUS (status); + status = + acpi_ns_lookup(walk_state->scope_info, + arg->common.value.string, ACPI_TYPE_ANY, + ACPI_IMODE_LOAD_PASS1, flags, walk_state, + &(node)); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR(arg->common.value.string, status); + return_ACPI_STATUS(status); } } @@ -153,9 +144,9 @@ acpi_ds_create_buffer_field ( * and we need to create the field object. Otherwise, this was a lookup * of an existing node and we don't want to create the field object again. */ - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (obj_desc) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* @@ -165,7 +156,7 @@ acpi_ds_create_buffer_field ( /* Create the buffer field object */ - obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER_FIELD); + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER_FIELD); if (!obj_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -176,28 +167,26 @@ acpi_ds_create_buffer_field ( * opcode and operands -- since the buffer and index * operands must be evaluated. */ - second_desc = obj_desc->common.next_object; + second_desc = obj_desc->common.next_object; second_desc->extra.aml_start = op->named.data; second_desc->extra.aml_length = op->named.length; obj_desc->buffer_field.node = node; /* Attach constructed field descriptors to parent node */ - status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_BUFFER_FIELD); - if (ACPI_FAILURE (status)) { + status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_BUFFER_FIELD); + if (ACPI_FAILURE(status)) { goto cleanup; } - -cleanup: + cleanup: /* Remove local reference to the object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_get_field_names @@ -214,17 +203,14 @@ cleanup: ******************************************************************************/ static acpi_status -acpi_ds_get_field_names ( - struct acpi_create_field_info *info, - struct acpi_walk_state *walk_state, - union acpi_parse_object *arg) +acpi_ds_get_field_names(struct acpi_create_field_info *info, + struct acpi_walk_state *walk_state, + union acpi_parse_object *arg) { - acpi_status status; - acpi_integer position; - - - ACPI_FUNCTION_TRACE_PTR ("ds_get_field_names", info); + acpi_status status; + acpi_integer position; + ACPI_FUNCTION_TRACE_PTR("ds_get_field_names", info); /* First field starts at bit zero */ @@ -243,18 +229,16 @@ acpi_ds_get_field_names ( case AML_INT_RESERVEDFIELD_OP: position = (acpi_integer) info->field_bit_position - + (acpi_integer) arg->common.value.size; + + (acpi_integer) arg->common.value.size; if (position > ACPI_UINT32_MAX) { - ACPI_REPORT_ERROR (( - "Bit offset within field too large (> 0xFFFFFFFF)\n")); - return_ACPI_STATUS (AE_SUPPORT); + ACPI_REPORT_ERROR(("Bit offset within field too large (> 0xFFFFFFFF)\n")); + return_ACPI_STATUS(AE_SUPPORT); } info->field_bit_position = (u32) position; break; - case AML_INT_ACCESSFIELD_OP: /* @@ -266,73 +250,70 @@ acpi_ds_get_field_names ( * ACCESS_TYPE bits */ info->field_flags = (u8) - ((info->field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | - ((u8) ((u32) arg->common.value.integer >> 8))); + ((info-> + field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | + ((u8) ((u32) arg->common.value.integer >> 8))); info->attribute = (u8) (arg->common.value.integer); break; - case AML_INT_NAMEDFIELD_OP: /* Lookup the name */ - status = acpi_ns_lookup (walk_state->scope_info, - (char *) &arg->named.name, - info->field_type, ACPI_IMODE_EXECUTE, - ACPI_NS_DONT_OPEN_SCOPE, - walk_state, &info->field_node); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR ((char *) &arg->named.name, status); + status = acpi_ns_lookup(walk_state->scope_info, + (char *)&arg->named.name, + info->field_type, + ACPI_IMODE_EXECUTE, + ACPI_NS_DONT_OPEN_SCOPE, + walk_state, &info->field_node); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR((char *)&arg->named.name, + status); if (status != AE_ALREADY_EXISTS) { - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Already exists, ignore error */ - } - else { + } else { arg->common.node = info->field_node; info->field_bit_length = arg->common.value.size; /* Create and initialize an object for the new Field Node */ - status = acpi_ex_prep_field_value (info); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_prep_field_value(info); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Keep track of bit position for the next field */ position = (acpi_integer) info->field_bit_position - + (acpi_integer) arg->common.value.size; + + (acpi_integer) arg->common.value.size; if (position > ACPI_UINT32_MAX) { - ACPI_REPORT_ERROR (( - "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", - (char *) &info->field_node->name)); - return_ACPI_STATUS (AE_SUPPORT); + ACPI_REPORT_ERROR(("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", (char *)&info->field_node->name)); + return_ACPI_STATUS(AE_SUPPORT); } info->field_bit_position += info->field_bit_length; break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid opcode in field list: %X\n", - arg->common.aml_opcode)); - return_ACPI_STATUS (AE_AML_BAD_OPCODE); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid opcode in field list: %X\n", + arg->common.aml_opcode)); + return_ACPI_STATUS(AE_AML_BAD_OPCODE); } arg = arg->common.next; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_create_field @@ -348,29 +329,28 @@ acpi_ds_get_field_names ( ******************************************************************************/ acpi_status -acpi_ds_create_field ( - union acpi_parse_object *op, - struct acpi_namespace_node *region_node, - struct acpi_walk_state *walk_state) +acpi_ds_create_field(union acpi_parse_object *op, + struct acpi_namespace_node *region_node, + struct acpi_walk_state *walk_state) { - acpi_status status; - union acpi_parse_object *arg; - struct acpi_create_field_info info; - - - ACPI_FUNCTION_TRACE_PTR ("ds_create_field", op); + acpi_status status; + union acpi_parse_object *arg; + struct acpi_create_field_info info; + ACPI_FUNCTION_TRACE_PTR("ds_create_field", op); /* First arg is the name of the parent op_region (must already exist) */ arg = op->common.value.arg; if (!region_node) { - status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.name, - ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT, walk_state, ®ion_node); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR (arg->common.value.name, status); - return_ACPI_STATUS (status); + status = + acpi_ns_lookup(walk_state->scope_info, + arg->common.value.name, ACPI_TYPE_REGION, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + walk_state, ®ion_node); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR(arg->common.value.name, status); + return_ACPI_STATUS(status); } } @@ -385,12 +365,11 @@ acpi_ds_create_field ( info.field_type = ACPI_TYPE_LOCAL_REGION_FIELD; info.region_node = region_node; - status = acpi_ds_get_field_names (&info, walk_state, arg->common.next); + status = acpi_ds_get_field_names(&info, walk_state, arg->common.next); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_init_field_objects @@ -407,37 +386,34 @@ acpi_ds_create_field ( ******************************************************************************/ acpi_status -acpi_ds_init_field_objects ( - union acpi_parse_object *op, - struct acpi_walk_state *walk_state) +acpi_ds_init_field_objects(union acpi_parse_object *op, + struct acpi_walk_state *walk_state) { - acpi_status status; - union acpi_parse_object *arg = NULL; - struct acpi_namespace_node *node; - u8 type = 0; - - - ACPI_FUNCTION_TRACE_PTR ("ds_init_field_objects", op); + acpi_status status; + union acpi_parse_object *arg = NULL; + struct acpi_namespace_node *node; + u8 type = 0; + ACPI_FUNCTION_TRACE_PTR("ds_init_field_objects", op); switch (walk_state->opcode) { case AML_FIELD_OP: - arg = acpi_ps_get_arg (op, 2); + arg = acpi_ps_get_arg(op, 2); type = ACPI_TYPE_LOCAL_REGION_FIELD; break; case AML_BANK_FIELD_OP: - arg = acpi_ps_get_arg (op, 4); + arg = acpi_ps_get_arg(op, 4); type = ACPI_TYPE_LOCAL_BANK_FIELD; break; case AML_INDEX_FIELD_OP: - arg = acpi_ps_get_arg (op, 3); + arg = acpi_ps_get_arg(op, 3); type = ACPI_TYPE_LOCAL_INDEX_FIELD; break; default: - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* @@ -447,16 +423,18 @@ acpi_ds_init_field_objects ( /* Ignore OFFSET and ACCESSAS terms here */ if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) { - status = acpi_ns_lookup (walk_state->scope_info, - (char *) &arg->named.name, - type, ACPI_IMODE_LOAD_PASS1, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | - ACPI_NS_ERROR_IF_FOUND, - walk_state, &node); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR ((char *) &arg->named.name, status); + status = acpi_ns_lookup(walk_state->scope_info, + (char *)&arg->named.name, + type, ACPI_IMODE_LOAD_PASS1, + ACPI_NS_NO_UPSEARCH | + ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND, + walk_state, &node); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR((char *)&arg->named.name, + status); if (status != AE_ALREADY_EXISTS) { - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Name already exists, just ignore this error */ @@ -472,10 +450,9 @@ acpi_ds_init_field_objects ( arg = arg->common.next; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_create_bank_field @@ -491,41 +468,42 @@ acpi_ds_init_field_objects ( ******************************************************************************/ acpi_status -acpi_ds_create_bank_field ( - union acpi_parse_object *op, - struct acpi_namespace_node *region_node, - struct acpi_walk_state *walk_state) +acpi_ds_create_bank_field(union acpi_parse_object *op, + struct acpi_namespace_node *region_node, + struct acpi_walk_state *walk_state) { - acpi_status status; - union acpi_parse_object *arg; - struct acpi_create_field_info info; - - - ACPI_FUNCTION_TRACE_PTR ("ds_create_bank_field", op); + acpi_status status; + union acpi_parse_object *arg; + struct acpi_create_field_info info; + ACPI_FUNCTION_TRACE_PTR("ds_create_bank_field", op); /* First arg is the name of the parent op_region (must already exist) */ arg = op->common.value.arg; if (!region_node) { - status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.name, - ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT, walk_state, ®ion_node); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR (arg->common.value.name, status); - return_ACPI_STATUS (status); + status = + acpi_ns_lookup(walk_state->scope_info, + arg->common.value.name, ACPI_TYPE_REGION, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + walk_state, ®ion_node); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR(arg->common.value.name, status); + return_ACPI_STATUS(status); } } /* Second arg is the Bank Register (Field) (must already exist) */ arg = arg->common.next; - status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT, walk_state, &info.register_node); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR (arg->common.value.string, status); - return_ACPI_STATUS (status); + status = + acpi_ns_lookup(walk_state->scope_info, arg->common.value.string, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, walk_state, + &info.register_node); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR(arg->common.value.string, status); + return_ACPI_STATUS(status); } /* Third arg is the bank_value */ @@ -543,12 +521,11 @@ acpi_ds_create_bank_field ( info.field_type = ACPI_TYPE_LOCAL_BANK_FIELD; info.region_node = region_node; - status = acpi_ds_get_field_names (&info, walk_state, arg->common.next); + status = acpi_ds_get_field_names(&info, walk_state, arg->common.next); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_create_index_field @@ -564,39 +541,40 @@ acpi_ds_create_bank_field ( ******************************************************************************/ acpi_status -acpi_ds_create_index_field ( - union acpi_parse_object *op, - struct acpi_namespace_node *region_node, - struct acpi_walk_state *walk_state) +acpi_ds_create_index_field(union acpi_parse_object *op, + struct acpi_namespace_node *region_node, + struct acpi_walk_state *walk_state) { - acpi_status status; - union acpi_parse_object *arg; - struct acpi_create_field_info info; - - - ACPI_FUNCTION_TRACE_PTR ("ds_create_index_field", op); + acpi_status status; + union acpi_parse_object *arg; + struct acpi_create_field_info info; + ACPI_FUNCTION_TRACE_PTR("ds_create_index_field", op); /* First arg is the name of the Index register (must already exist) */ arg = op->common.value.arg; - status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT, walk_state, &info.register_node); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR (arg->common.value.string, status); - return_ACPI_STATUS (status); + status = + acpi_ns_lookup(walk_state->scope_info, arg->common.value.string, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, walk_state, + &info.register_node); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR(arg->common.value.string, status); + return_ACPI_STATUS(status); } /* Second arg is the data register (must already exist) */ arg = arg->common.next; - status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT, walk_state, &info.data_register_node); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR (arg->common.value.string, status); - return_ACPI_STATUS (status); + status = + acpi_ns_lookup(walk_state->scope_info, arg->common.value.string, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, walk_state, + &info.data_register_node); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR(arg->common.value.string, status); + return_ACPI_STATUS(status); } /* Next arg is the field flags */ @@ -609,9 +587,7 @@ acpi_ds_create_index_field ( info.field_type = ACPI_TYPE_LOCAL_INDEX_FIELD; info.region_node = region_node; - status = acpi_ds_get_field_names (&info, walk_state, arg->common.next); + status = acpi_ds_get_field_names(&info, walk_state, arg->common.next); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c index bcd1d47..8693c70 100644 --- a/drivers/acpi/dispatcher/dsinit.c +++ b/drivers/acpi/dispatcher/dsinit.c @@ -41,23 +41,17 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dsinit") +ACPI_MODULE_NAME("dsinit") /* Local prototypes */ - static acpi_status -acpi_ds_init_one_object ( - acpi_handle obj_handle, - u32 level, - void *context, - void **return_value); - +acpi_ds_init_one_object(acpi_handle obj_handle, + u32 level, void *context, void **return_value); /******************************************************************************* * @@ -80,20 +74,17 @@ acpi_ds_init_one_object ( ******************************************************************************/ static acpi_status -acpi_ds_init_one_object ( - acpi_handle obj_handle, - u32 level, - void *context, - void **return_value) +acpi_ds_init_one_object(acpi_handle obj_handle, + u32 level, void *context, void **return_value) { - struct acpi_init_walk_info *info = (struct acpi_init_walk_info *) context; - struct acpi_namespace_node *node = (struct acpi_namespace_node *) obj_handle; - acpi_object_type type; - acpi_status status; - - - ACPI_FUNCTION_NAME ("ds_init_one_object"); + struct acpi_init_walk_info *info = + (struct acpi_init_walk_info *)context; + struct acpi_namespace_node *node = + (struct acpi_namespace_node *)obj_handle; + acpi_object_type type; + acpi_status status; + ACPI_FUNCTION_NAME("ds_init_one_object"); /* * We are only interested in NS nodes owned by the table that @@ -107,23 +98,23 @@ acpi_ds_init_one_object ( /* And even then, we are only interested in a few object types */ - type = acpi_ns_get_type (obj_handle); + type = acpi_ns_get_type(obj_handle); switch (type) { case ACPI_TYPE_REGION: - status = acpi_ds_initialize_region (obj_handle); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Region %p [%4.4s] - Init failure, %s\n", - obj_handle, acpi_ut_get_node_name (obj_handle), - acpi_format_exception (status))); + status = acpi_ds_initialize_region(obj_handle); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Region %p [%4.4s] - Init failure, %s\n", + obj_handle, + acpi_ut_get_node_name(obj_handle), + acpi_format_exception(status))); } info->op_region_count++; break; - case ACPI_TYPE_METHOD: /* @@ -131,7 +122,7 @@ acpi_ds_init_one_object ( * the entire pathname */ if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, ".")); } /* @@ -148,12 +139,13 @@ acpi_ds_init_one_object ( * Always parse methods to detect errors, we will delete * the parse tree below */ - status = acpi_ds_parse_method (obj_handle); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "\n+Method %p [%4.4s] - parse failure, %s\n", - obj_handle, acpi_ut_get_node_name (obj_handle), - acpi_format_exception (status))); + status = acpi_ds_parse_method(obj_handle); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "\n+Method %p [%4.4s] - parse failure, %s\n", + obj_handle, + acpi_ut_get_node_name(obj_handle), + acpi_format_exception(status))); /* This parse failed, but we will continue parsing more methods */ } @@ -161,13 +153,11 @@ acpi_ds_init_one_object ( info->method_count++; break; - case ACPI_TYPE_DEVICE: info->device_count++; break; - default: break; } @@ -179,7 +169,6 @@ acpi_ds_init_one_object ( return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_initialize_objects @@ -195,45 +184,43 @@ acpi_ds_init_one_object ( ******************************************************************************/ acpi_status -acpi_ds_initialize_objects ( - struct acpi_table_desc *table_desc, - struct acpi_namespace_node *start_node) +acpi_ds_initialize_objects(struct acpi_table_desc * table_desc, + struct acpi_namespace_node * start_node) { - acpi_status status; - struct acpi_init_walk_info info; - + acpi_status status; + struct acpi_init_walk_info info; - ACPI_FUNCTION_TRACE ("ds_initialize_objects"); + ACPI_FUNCTION_TRACE("ds_initialize_objects"); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "**** Starting initialization of namespace objects ****\n")); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:")); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "**** Starting initialization of namespace objects ****\n")); - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:")); - - info.method_count = 0; + info.method_count = 0; info.op_region_count = 0; - info.object_count = 0; - info.device_count = 0; - info.table_desc = table_desc; + info.object_count = 0; + info.device_count = 0; + info.table_desc = table_desc; /* Walk entire namespace from the supplied root */ - status = acpi_walk_namespace (ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, - acpi_ds_init_one_object, &info, NULL); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed, %s\n", - acpi_format_exception (status))); + status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, + acpi_ds_init_one_object, &info, NULL); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed, %s\n", + acpi_format_exception(status))); } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n", - table_desc->pointer->signature, table_desc->owner_id, info.object_count, - info.device_count, info.method_count, info.op_region_count)); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, + "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n", + table_desc->pointer->signature, + table_desc->owner_id, info.object_count, + info.device_count, info.method_count, + info.op_region_count)); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "%hd Methods, %hd Regions\n", info.method_count, info.op_region_count)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "%hd Methods, %hd Regions\n", info.method_count, + info.op_region_count)); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - - diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index e344c06..77fcfc3 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -49,10 +48,8 @@ #include #include - #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dsmethod") - +ACPI_MODULE_NAME("dsmethod") /******************************************************************************* * @@ -67,45 +64,41 @@ * MUTEX: Assumes parser is locked * ******************************************************************************/ - -acpi_status -acpi_ds_parse_method ( - struct acpi_namespace_node *node) +acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node) { - acpi_status status; - union acpi_operand_object *obj_desc; - union acpi_parse_object *op; - struct acpi_walk_state *walk_state; - - - ACPI_FUNCTION_TRACE_PTR ("ds_parse_method", node); + acpi_status status; + union acpi_operand_object *obj_desc; + union acpi_parse_object *op; + struct acpi_walk_state *walk_state; + ACPI_FUNCTION_TRACE_PTR("ds_parse_method", node); /* Parameter Validation */ if (!node) { - return_ACPI_STATUS (AE_NULL_ENTRY); + return_ACPI_STATUS(AE_NULL_ENTRY); } - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Parsing [%4.4s] **** named_obj=%p\n", - acpi_ut_get_node_name (node), node)); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "**** Parsing [%4.4s] **** named_obj=%p\n", + acpi_ut_get_node_name(node), node)); /* Extract the method object from the method Node */ - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { - return_ACPI_STATUS (AE_NULL_OBJECT); + return_ACPI_STATUS(AE_NULL_OBJECT); } /* Create a mutex for the method if there is a concurrency limit */ if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) && - (!obj_desc->method.semaphore)) { - status = acpi_os_create_semaphore (obj_desc->method.concurrency, - obj_desc->method.concurrency, - &obj_desc->method.semaphore); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + (!obj_desc->method.semaphore)) { + status = acpi_os_create_semaphore(obj_desc->method.concurrency, + obj_desc->method.concurrency, + &obj_desc->method.semaphore); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -113,14 +106,14 @@ acpi_ds_parse_method ( * Allocate a new parser op to be the root of the parsed * method tree */ - op = acpi_ps_alloc_op (AML_METHOD_OP); + op = acpi_ps_alloc_op(AML_METHOD_OP); if (!op) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Init new op with the method name and pointer back to the Node */ - acpi_ps_set_name (op, node->name.integer); + acpi_ps_set_name(op, node->name.integer); op->common.node = node; /* @@ -128,25 +121,26 @@ acpi_ds_parse_method ( * objects (such as Operation Regions) can be created during the * first pass parse. */ - status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); - if (ACPI_FAILURE (status)) { + status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id); + if (ACPI_FAILURE(status)) { goto cleanup; } /* Create and initialize a new walk state */ - walk_state = acpi_ds_create_walk_state ( - obj_desc->method.owner_id, NULL, NULL, NULL); + walk_state = + acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL, + NULL); if (!walk_state) { status = AE_NO_MEMORY; goto cleanup2; } - status = acpi_ds_init_aml_walk (walk_state, op, node, - obj_desc->method.aml_start, - obj_desc->method.aml_length, NULL, 1); - if (ACPI_FAILURE (status)) { - acpi_ds_delete_walk_state (walk_state); + status = acpi_ds_init_aml_walk(walk_state, op, node, + obj_desc->method.aml_start, + obj_desc->method.aml_length, NULL, 1); + if (ACPI_FAILURE(status)) { + acpi_ds_delete_walk_state(walk_state); goto cleanup2; } @@ -159,32 +153,31 @@ acpi_ds_parse_method ( * method so that operands to the named objects can take on dynamic * run-time values. */ - status = acpi_ps_parse_aml (walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ps_parse_aml(walk_state); + if (ACPI_FAILURE(status)) { goto cleanup2; } - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n", - acpi_ut_get_node_name (node), node, op)); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n", + acpi_ut_get_node_name(node), node, op)); /* * Delete the parse tree. We simply re-parse the method for every * execution since there isn't much overhead (compared to keeping lots * of parse trees around) */ - acpi_ns_delete_namespace_subtree (node); - acpi_ns_delete_namespace_by_owner (obj_desc->method.owner_id); + acpi_ns_delete_namespace_subtree(node); + acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id); -cleanup2: - acpi_ut_release_owner_id (&obj_desc->method.owner_id); + cleanup2: + acpi_ut_release_owner_id(&obj_desc->method.owner_id); -cleanup: - acpi_ps_delete_parse_tree (op); - return_ACPI_STATUS (status); + cleanup: + acpi_ps_delete_parse_tree(op); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_begin_method_execution @@ -202,19 +195,16 @@ cleanup: ******************************************************************************/ acpi_status -acpi_ds_begin_method_execution ( - struct acpi_namespace_node *method_node, - union acpi_operand_object *obj_desc, - struct acpi_namespace_node *calling_method_node) +acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, + union acpi_operand_object *obj_desc, + struct acpi_namespace_node *calling_method_node) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_PTR ("ds_begin_method_execution", method_node); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE_PTR("ds_begin_method_execution", method_node); if (!method_node) { - return_ACPI_STATUS (AE_NULL_ENTRY); + return_ACPI_STATUS(AE_NULL_ENTRY); } /* @@ -231,8 +221,9 @@ acpi_ds_begin_method_execution ( * thread that is making recursive method calls. */ if (method_node == calling_method_node) { - if (obj_desc->method.thread_count >= obj_desc->method.concurrency) { - return_ACPI_STATUS (AE_AML_METHOD_LIMIT); + if (obj_desc->method.thread_count >= + obj_desc->method.concurrency) { + return_ACPI_STATUS(AE_AML_METHOD_LIMIT); } } @@ -240,8 +231,9 @@ acpi_ds_begin_method_execution ( * Get a unit from the method semaphore. This releases the * interpreter if we block */ - status = acpi_ex_system_wait_semaphore (obj_desc->method.semaphore, - ACPI_WAIT_FOREVER); + status = + acpi_ex_system_wait_semaphore(obj_desc->method.semaphore, + ACPI_WAIT_FOREVER); } /* @@ -249,10 +241,9 @@ acpi_ds_begin_method_execution ( * reentered one more time (even if it is the same thread) */ obj_desc->method.thread_count++; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_call_control_method @@ -268,85 +259,86 @@ acpi_ds_begin_method_execution ( ******************************************************************************/ acpi_status -acpi_ds_call_control_method ( - struct acpi_thread_state *thread, - struct acpi_walk_state *this_walk_state, - union acpi_parse_object *op) +acpi_ds_call_control_method(struct acpi_thread_state *thread, + struct acpi_walk_state *this_walk_state, + union acpi_parse_object *op) { - acpi_status status; - struct acpi_namespace_node *method_node; - struct acpi_walk_state *next_walk_state = NULL; - union acpi_operand_object *obj_desc; - struct acpi_parameter_info info; - u32 i; - + acpi_status status; + struct acpi_namespace_node *method_node; + struct acpi_walk_state *next_walk_state = NULL; + union acpi_operand_object *obj_desc; + struct acpi_parameter_info info; + u32 i; - ACPI_FUNCTION_TRACE_PTR ("ds_call_control_method", this_walk_state); + ACPI_FUNCTION_TRACE_PTR("ds_call_control_method", this_walk_state); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Execute method %p, currentstate=%p\n", - this_walk_state->prev_op, this_walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Execute method %p, currentstate=%p\n", + this_walk_state->prev_op, this_walk_state)); /* * Get the namespace entry for the control method we are about to call */ method_node = this_walk_state->method_call_node; if (!method_node) { - return_ACPI_STATUS (AE_NULL_ENTRY); + return_ACPI_STATUS(AE_NULL_ENTRY); } - obj_desc = acpi_ns_get_attached_object (method_node); + obj_desc = acpi_ns_get_attached_object(method_node); if (!obj_desc) { - return_ACPI_STATUS (AE_NULL_OBJECT); + return_ACPI_STATUS(AE_NULL_OBJECT); } - status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Init for new method, wait on concurrency semaphore */ - status = acpi_ds_begin_method_execution (method_node, obj_desc, - this_walk_state->method_node); - if (ACPI_FAILURE (status)) { + status = acpi_ds_begin_method_execution(method_node, obj_desc, + this_walk_state->method_node); + if (ACPI_FAILURE(status)) { goto cleanup; } if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) { /* 1) Parse: Create a new walk state for the preempting walk */ - next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, - op, obj_desc, NULL); + next_walk_state = + acpi_ds_create_walk_state(obj_desc->method.owner_id, op, + obj_desc, NULL); if (!next_walk_state) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Create and init a Root Node */ - op = acpi_ps_create_scope_op (); + op = acpi_ps_create_scope_op(); if (!op) { status = AE_NO_MEMORY; goto cleanup; } - status = acpi_ds_init_aml_walk (next_walk_state, op, method_node, - obj_desc->method.aml_start, obj_desc->method.aml_length, - NULL, 1); - if (ACPI_FAILURE (status)) { - acpi_ds_delete_walk_state (next_walk_state); + status = acpi_ds_init_aml_walk(next_walk_state, op, method_node, + obj_desc->method.aml_start, + obj_desc->method.aml_length, + NULL, 1); + if (ACPI_FAILURE(status)) { + acpi_ds_delete_walk_state(next_walk_state); goto cleanup; } /* Begin AML parse */ - status = acpi_ps_parse_aml (next_walk_state); - acpi_ps_delete_parse_tree (op); + status = acpi_ps_parse_aml(next_walk_state); + acpi_ps_delete_parse_tree(op); } /* 2) Execute: Create a new state for the preempting walk */ - next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, - NULL, obj_desc, thread); + next_walk_state = acpi_ds_create_walk_state(obj_desc->method.owner_id, + NULL, obj_desc, thread); if (!next_walk_state) { status = AE_NO_MEMORY; goto cleanup; @@ -357,15 +349,15 @@ acpi_ds_call_control_method ( * start at index 0. * Null terminate the list of arguments */ - this_walk_state->operands [this_walk_state->num_operands] = NULL; + this_walk_state->operands[this_walk_state->num_operands] = NULL; info.parameters = &this_walk_state->operands[0]; info.parameter_type = ACPI_PARAM_ARGS; - status = acpi_ds_init_aml_walk (next_walk_state, NULL, method_node, - obj_desc->method.aml_start, obj_desc->method.aml_length, - &info, 3); - if (ACPI_FAILURE (status)) { + status = acpi_ds_init_aml_walk(next_walk_state, NULL, method_node, + obj_desc->method.aml_start, + obj_desc->method.aml_length, &info, 3); + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -374,40 +366,39 @@ acpi_ds_call_control_method ( * (they were copied to new objects) */ for (i = 0; i < obj_desc->method.param_count; i++) { - acpi_ut_remove_reference (this_walk_state->operands [i]); - this_walk_state->operands [i] = NULL; + acpi_ut_remove_reference(this_walk_state->operands[i]); + this_walk_state->operands[i] = NULL; } /* Clear the operand stack */ this_walk_state->num_operands = 0; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Starting nested execution, newstate=%p\n", next_walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Starting nested execution, newstate=%p\n", + next_walk_state)); if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { - status = obj_desc->method.implementation (next_walk_state); - return_ACPI_STATUS (status); + status = obj_desc->method.implementation(next_walk_state); + return_ACPI_STATUS(status); } - return_ACPI_STATUS (AE_OK); - + return_ACPI_STATUS(AE_OK); /* On error, we must delete the new walk state */ -cleanup: - acpi_ut_release_owner_id (&obj_desc->method.owner_id); + cleanup: + acpi_ut_release_owner_id(&obj_desc->method.owner_id); if (next_walk_state && (next_walk_state->method_desc)) { /* Decrement the thread count on the method parse tree */ - next_walk_state->method_desc->method.thread_count--; + next_walk_state->method_desc->method.thread_count--; } - (void) acpi_ds_terminate_control_method (next_walk_state); - acpi_ds_delete_walk_state (next_walk_state); - return_ACPI_STATUS (status); + (void)acpi_ds_terminate_control_method(next_walk_state); + acpi_ds_delete_walk_state(next_walk_state); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_restart_control_method @@ -423,25 +414,22 @@ cleanup: ******************************************************************************/ acpi_status -acpi_ds_restart_control_method ( - struct acpi_walk_state *walk_state, - union acpi_operand_object *return_desc) +acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, + union acpi_operand_object *return_desc) { - acpi_status status; - + acpi_status status; - ACPI_FUNCTION_TRACE_PTR ("ds_restart_control_method", walk_state); + ACPI_FUNCTION_TRACE_PTR("ds_restart_control_method", walk_state); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "****Restart [%4.4s] Op %p return_value_from_callee %p\n", + (char *)&walk_state->method_node->name, + walk_state->method_call_op, return_desc)); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "****Restart [%4.4s] Op %p return_value_from_callee %p\n", - (char *) &walk_state->method_node->name, walk_state->method_call_op, - return_desc)); - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - " return_from_this_method_used?=%X res_stack %p Walk %p\n", - walk_state->return_used, - walk_state->results, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + " return_from_this_method_used?=%X res_stack %p Walk %p\n", + walk_state->return_used, + walk_state->results, walk_state)); /* Did the called method return a value? */ @@ -451,10 +439,10 @@ acpi_ds_restart_control_method ( if (walk_state->return_used) { /* Save the return value from the previous method */ - status = acpi_ds_result_push (return_desc, walk_state); - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (return_desc); - return_ACPI_STATUS (status); + status = acpi_ds_result_push(return_desc, walk_state); + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference(return_desc); + return_ACPI_STATUS(status); } /* @@ -472,19 +460,19 @@ acpi_ds_restart_control_method ( * NOTE: this is optional because the ASL language does not actually * support this behavior. */ - else if (!acpi_ds_do_implicit_return (return_desc, walk_state, FALSE)) { + else if (!acpi_ds_do_implicit_return + (return_desc, walk_state, FALSE)) { /* * Delete the return value if it will not be used by the * calling method */ - acpi_ut_remove_reference (return_desc); + acpi_ut_remove_reference(return_desc); } } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_terminate_control_method @@ -499,17 +487,13 @@ acpi_ds_restart_control_method ( * ******************************************************************************/ -acpi_status -acpi_ds_terminate_control_method ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) { - union acpi_operand_object *obj_desc; - struct acpi_namespace_node *method_node; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ds_terminate_control_method", walk_state); + union acpi_operand_object *obj_desc; + struct acpi_namespace_node *method_node; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ds_terminate_control_method", walk_state); if (!walk_state) { return (AE_BAD_PARAMETER); @@ -519,30 +503,31 @@ acpi_ds_terminate_control_method ( obj_desc = walk_state->method_desc; if (!obj_desc) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Delete all arguments and locals */ - acpi_ds_method_data_delete_all (walk_state); + acpi_ds_method_data_delete_all(walk_state); /* * Lock the parser while we terminate this method. * If this is the last thread executing the method, * we have additional cleanup to perform */ - status = acpi_ut_acquire_mutex (ACPI_MTX_PARSER); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_PARSER); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Signal completion of the execution of this method if necessary */ if (walk_state->method_desc->method.semaphore) { - status = acpi_os_signal_semaphore ( - walk_state->method_desc->method.semaphore, 1); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not signal method semaphore\n")); + status = + acpi_os_signal_semaphore(walk_state->method_desc->method. + semaphore, 1); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not signal method semaphore\n")); status = AE_OK; /* Ignore error and continue cleanup */ @@ -550,9 +535,10 @@ acpi_ds_terminate_control_method ( } if (walk_state->method_desc->method.thread_count) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "*** Not deleting method namespace, there are still %d threads\n", - walk_state->method_desc->method.thread_count)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "*** Not deleting method namespace, there are still %d threads\n", + walk_state->method_desc->method. + thread_count)); } if (!walk_state->method_desc->method.thread_count) { @@ -567,9 +553,11 @@ acpi_ds_terminate_control_method ( * before creating the synchronization semaphore. */ if ((walk_state->method_desc->method.concurrency == 1) && - (!walk_state->method_desc->method.semaphore)) { - status = acpi_os_create_semaphore (1, 1, - &walk_state->method_desc->method.semaphore); + (!walk_state->method_desc->method.semaphore)) { + status = acpi_os_create_semaphore(1, 1, + &walk_state-> + method_desc->method. + semaphore); } /* @@ -584,30 +572,30 @@ acpi_ds_terminate_control_method ( * Delete any namespace entries created immediately underneath * the method */ - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } if (method_node->child) { - acpi_ns_delete_namespace_subtree (method_node); + acpi_ns_delete_namespace_subtree(method_node); } /* * Delete any namespace entries created anywhere else within * the namespace */ - acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owner_id); - status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - acpi_ut_release_owner_id (&walk_state->method_desc->method.owner_id); - - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + acpi_ns_delete_namespace_by_owner(walk_state->method_desc-> + method.owner_id); + status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + acpi_ut_release_owner_id(&walk_state->method_desc->method. + owner_id); + + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } - status = acpi_ut_release_mutex (ACPI_MTX_PARSER); - return_ACPI_STATUS (status); + status = acpi_ut_release_mutex(ACPI_MTX_PARSER); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c index c83d53f..4095ce7 100644 --- a/drivers/acpi/dispatcher/dsmthdat.c +++ b/drivers/acpi/dispatcher/dsmthdat.c @@ -41,41 +41,32 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include #include - #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dsmthdat") +ACPI_MODULE_NAME("dsmthdat") /* Local prototypes */ - static void -acpi_ds_method_data_delete_value ( - u16 opcode, - u32 index, - struct acpi_walk_state *walk_state); +acpi_ds_method_data_delete_value(u16 opcode, + u32 index, struct acpi_walk_state *walk_state); static acpi_status -acpi_ds_method_data_set_value ( - u16 opcode, - u32 index, - union acpi_operand_object *object, - struct acpi_walk_state *walk_state); +acpi_ds_method_data_set_value(u16 opcode, + u32 index, + union acpi_operand_object *object, + struct acpi_walk_state *walk_state); #ifdef ACPI_OBSOLETE_FUNCTIONS acpi_object_type -acpi_ds_method_data_get_type ( - u16 opcode, - u32 index, - struct acpi_walk_state *walk_state); +acpi_ds_method_data_get_type(u16 opcode, + u32 index, struct acpi_walk_state *walk_state); #endif - /******************************************************************************* * * FUNCTION: acpi_ds_method_data_init @@ -97,45 +88,41 @@ acpi_ds_method_data_get_type ( * ******************************************************************************/ -void -acpi_ds_method_data_init ( - struct acpi_walk_state *walk_state) +void acpi_ds_method_data_init(struct acpi_walk_state *walk_state) { - u32 i; - - - ACPI_FUNCTION_TRACE ("ds_method_data_init"); + u32 i; + ACPI_FUNCTION_TRACE("ds_method_data_init"); /* Init the method arguments */ for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) { - ACPI_MOVE_32_TO_32 (&walk_state->arguments[i].name, + ACPI_MOVE_32_TO_32(&walk_state->arguments[i].name, NAMEOF_ARG_NTE); walk_state->arguments[i].name.integer |= (i << 24); - walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED; - walk_state->arguments[i].type = ACPI_TYPE_ANY; - walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST | - ANOBJ_METHOD_ARG; + walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED; + walk_state->arguments[i].type = ACPI_TYPE_ANY; + walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST | + ANOBJ_METHOD_ARG; } /* Init the method locals */ for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) { - ACPI_MOVE_32_TO_32 (&walk_state->local_variables[i].name, + ACPI_MOVE_32_TO_32(&walk_state->local_variables[i].name, NAMEOF_LOCAL_NTE); walk_state->local_variables[i].name.integer |= (i << 24); - walk_state->local_variables[i].descriptor = ACPI_DESC_TYPE_NAMED; - walk_state->local_variables[i].type = ACPI_TYPE_ANY; - walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST | - ANOBJ_METHOD_LOCAL; + walk_state->local_variables[i].descriptor = + ACPI_DESC_TYPE_NAMED; + walk_state->local_variables[i].type = ACPI_TYPE_ANY; + walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST | + ANOBJ_METHOD_LOCAL; } return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ds_method_data_delete_all @@ -149,26 +136,25 @@ acpi_ds_method_data_init ( * ******************************************************************************/ -void -acpi_ds_method_data_delete_all ( - struct acpi_walk_state *walk_state) +void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state) { - u32 index; - - - ACPI_FUNCTION_TRACE ("ds_method_data_delete_all"); + u32 index; + ACPI_FUNCTION_TRACE("ds_method_data_delete_all"); /* Detach the locals */ for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) { if (walk_state->local_variables[index].object) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", - index, walk_state->local_variables[index].object)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Local%d=%p\n", + index, + walk_state->local_variables[index]. + object)); /* Detach object (if present) and remove a reference */ - acpi_ns_detach_object (&walk_state->local_variables[index]); + acpi_ns_detach_object(&walk_state-> + local_variables[index]); } } @@ -176,19 +162,19 @@ acpi_ds_method_data_delete_all ( for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) { if (walk_state->arguments[index].object) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", - index, walk_state->arguments[index].object)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", + index, + walk_state->arguments[index].object)); /* Detach object (if present) and remove a reference */ - acpi_ns_detach_object (&walk_state->arguments[index]); + acpi_ns_detach_object(&walk_state->arguments[index]); } } return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ds_method_data_init_args @@ -206,47 +192,44 @@ acpi_ds_method_data_delete_all ( ******************************************************************************/ acpi_status -acpi_ds_method_data_init_args ( - union acpi_operand_object **params, - u32 max_param_count, - struct acpi_walk_state *walk_state) +acpi_ds_method_data_init_args(union acpi_operand_object **params, + u32 max_param_count, + struct acpi_walk_state *walk_state) { - acpi_status status; - u32 index = 0; - - - ACPI_FUNCTION_TRACE_PTR ("ds_method_data_init_args", params); + acpi_status status; + u32 index = 0; + ACPI_FUNCTION_TRACE_PTR("ds_method_data_init_args", params); if (!params) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); - return_ACPI_STATUS (AE_OK); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "No param list passed to method\n")); + return_ACPI_STATUS(AE_OK); } /* Copy passed parameters into the new method stack frame */ while ((index < ACPI_METHOD_NUM_ARGS) && - (index < max_param_count) && - params[index]) { + (index < max_param_count) && params[index]) { /* * A valid parameter. * Store the argument in the method/walk descriptor. * Do not copy the arg in order to implement call by reference */ - status = acpi_ds_method_data_set_value (AML_ARG_OP, index, - params[index], walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_method_data_set_value(AML_ARG_OP, index, + params[index], + walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } index++; } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", index)); - return_ACPI_STATUS (AE_OK); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%d args passed to method\n", index)); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_method_data_get_node @@ -263,14 +246,12 @@ acpi_ds_method_data_init_args ( ******************************************************************************/ acpi_status -acpi_ds_method_data_get_node ( - u16 opcode, - u32 index, - struct acpi_walk_state *walk_state, - struct acpi_namespace_node **node) +acpi_ds_method_data_get_node(u16 opcode, + u32 index, + struct acpi_walk_state *walk_state, + struct acpi_namespace_node **node) { - ACPI_FUNCTION_TRACE ("ds_method_data_get_node"); - + ACPI_FUNCTION_TRACE("ds_method_data_get_node"); /* * Method Locals and Arguments are supported @@ -279,10 +260,10 @@ acpi_ds_method_data_get_node ( case AML_LOCAL_OP: if (index > ACPI_METHOD_MAX_LOCAL) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Local index %d is invalid (max %d)\n", - index, ACPI_METHOD_MAX_LOCAL)); - return_ACPI_STATUS (AE_AML_INVALID_INDEX); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Local index %d is invalid (max %d)\n", + index, ACPI_METHOD_MAX_LOCAL)); + return_ACPI_STATUS(AE_AML_INVALID_INDEX); } /* Return a pointer to the pseudo-node */ @@ -293,10 +274,10 @@ acpi_ds_method_data_get_node ( case AML_ARG_OP: if (index > ACPI_METHOD_MAX_ARG) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Arg index %d is invalid (max %d)\n", - index, ACPI_METHOD_MAX_ARG)); - return_ACPI_STATUS (AE_AML_INVALID_INDEX); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Arg index %d is invalid (max %d)\n", + index, ACPI_METHOD_MAX_ARG)); + return_ACPI_STATUS(AE_AML_INVALID_INDEX); } /* Return a pointer to the pseudo-node */ @@ -305,14 +286,14 @@ acpi_ds_method_data_get_node ( break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", opcode)); - return_ACPI_STATUS (AE_AML_BAD_OPCODE); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Opcode %d is invalid\n", + opcode)); + return_ACPI_STATUS(AE_AML_BAD_OPCODE); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_method_data_set_value @@ -330,29 +311,26 @@ acpi_ds_method_data_get_node ( ******************************************************************************/ static acpi_status -acpi_ds_method_data_set_value ( - u16 opcode, - u32 index, - union acpi_operand_object *object, - struct acpi_walk_state *walk_state) +acpi_ds_method_data_set_value(u16 opcode, + u32 index, + union acpi_operand_object *object, + struct acpi_walk_state *walk_state) { - acpi_status status; - struct acpi_namespace_node *node; - + acpi_status status; + struct acpi_namespace_node *node; - ACPI_FUNCTION_TRACE ("ds_method_data_set_value"); + ACPI_FUNCTION_TRACE("ds_method_data_set_value"); - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "new_obj %p Opcode %X, Refs=%d [%s]\n", object, - opcode, object->common.reference_count, - acpi_ut_get_type_name (object->common.type))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "new_obj %p Opcode %X, Refs=%d [%s]\n", object, + opcode, object->common.reference_count, + acpi_ut_get_type_name(object->common.type))); /* Get the namespace node for the arg/local */ - status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -361,15 +339,14 @@ acpi_ds_method_data_set_value ( * reference semantics of ACPI Control Method invocation. * (See ACPI specification 2.0_c) */ - acpi_ut_add_reference (object); + acpi_ut_add_reference(object); /* Install the object */ node->object = object; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_method_data_get_value @@ -387,32 +364,30 @@ acpi_ds_method_data_set_value ( ******************************************************************************/ acpi_status -acpi_ds_method_data_get_value ( - u16 opcode, - u32 index, - struct acpi_walk_state *walk_state, - union acpi_operand_object **dest_desc) +acpi_ds_method_data_get_value(u16 opcode, + u32 index, + struct acpi_walk_state *walk_state, + union acpi_operand_object **dest_desc) { - acpi_status status; - struct acpi_namespace_node *node; - union acpi_operand_object *object; - - - ACPI_FUNCTION_TRACE ("ds_method_data_get_value"); + acpi_status status; + struct acpi_namespace_node *node; + union acpi_operand_object *object; + ACPI_FUNCTION_TRACE("ds_method_data_get_value"); /* Validate the object descriptor */ if (!dest_desc) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n")); - return_ACPI_STATUS (AE_BAD_PARAMETER); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Null object descriptor pointer\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Get the namespace node for the arg/local */ - status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Get the object from the node */ @@ -433,9 +408,10 @@ acpi_ds_method_data_get_value ( /* If slack enabled, init the local_x/arg_x to an Integer of value zero */ if (acpi_gbl_enable_interpreter_slack) { - object = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + object = + acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!object) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } object->integer.value = 0; @@ -444,27 +420,29 @@ acpi_ds_method_data_get_value ( /* Otherwise, return the error */ - else switch (opcode) { - case AML_ARG_OP: + else + switch (opcode) { + case AML_ARG_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Uninitialized Arg[%d] at node %p\n", - index, node)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Uninitialized Arg[%d] at node %p\n", + index, node)); - return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); + return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); - case AML_LOCAL_OP: + case AML_LOCAL_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Uninitialized Local[%d] at node %p\n", - index, node)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Uninitialized Local[%d] at node %p\n", + index, node)); - return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); + return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL); - default: - ACPI_REPORT_ERROR (("Not Arg/Local opcode: %X\n", opcode)); - return_ACPI_STATUS (AE_AML_INTERNAL); - } + default: + ACPI_REPORT_ERROR(("Not Arg/Local opcode: %X\n", + opcode)); + return_ACPI_STATUS(AE_AML_INTERNAL); + } } /* @@ -472,12 +450,11 @@ acpi_ds_method_data_get_value ( * Return an additional reference to the object */ *dest_desc = object; - acpi_ut_add_reference (object); + acpi_ut_add_reference(object); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_method_data_delete_value @@ -494,29 +471,25 @@ acpi_ds_method_data_get_value ( ******************************************************************************/ static void -acpi_ds_method_data_delete_value ( - u16 opcode, - u32 index, - struct acpi_walk_state *walk_state) +acpi_ds_method_data_delete_value(u16 opcode, + u32 index, struct acpi_walk_state *walk_state) { - acpi_status status; - struct acpi_namespace_node *node; - union acpi_operand_object *object; - - - ACPI_FUNCTION_TRACE ("ds_method_data_delete_value"); + acpi_status status; + struct acpi_namespace_node *node; + union acpi_operand_object *object; + ACPI_FUNCTION_TRACE("ds_method_data_delete_value"); /* Get the namespace node for the arg/local */ - status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); - if (ACPI_FAILURE (status)) { + status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); + if (ACPI_FAILURE(status)) { return_VOID; } /* Get the associated object */ - object = acpi_ns_get_attached_object (node); + object = acpi_ns_get_attached_object(node); /* * Undefine the Arg or Local by setting its descriptor @@ -526,19 +499,18 @@ acpi_ds_method_data_delete_value ( node->object = NULL; if ((object) && - (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_OPERAND)) { + (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_OPERAND)) { /* * There is a valid object. * Decrement the reference count by one to balance the * increment when the object was stored. */ - acpi_ut_remove_reference (object); + acpi_ut_remove_reference(object); } return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ds_store_object_to_local @@ -557,40 +529,38 @@ acpi_ds_method_data_delete_value ( ******************************************************************************/ acpi_status -acpi_ds_store_object_to_local ( - u16 opcode, - u32 index, - union acpi_operand_object *obj_desc, - struct acpi_walk_state *walk_state) +acpi_ds_store_object_to_local(u16 opcode, + u32 index, + union acpi_operand_object *obj_desc, + struct acpi_walk_state *walk_state) { - acpi_status status; - struct acpi_namespace_node *node; - union acpi_operand_object *current_obj_desc; - union acpi_operand_object *new_obj_desc; + acpi_status status; + struct acpi_namespace_node *node; + union acpi_operand_object *current_obj_desc; + union acpi_operand_object *new_obj_desc; - - ACPI_FUNCTION_TRACE ("ds_store_object_to_local"); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n", - opcode, index, obj_desc)); + ACPI_FUNCTION_TRACE("ds_store_object_to_local"); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n", + opcode, index, obj_desc)); /* Parameter validation */ if (!obj_desc) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Get the namespace node for the arg/local */ - status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - current_obj_desc = acpi_ns_get_attached_object (node); + current_obj_desc = acpi_ns_get_attached_object(node); if (current_obj_desc == obj_desc) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", - obj_desc)); - return_ACPI_STATUS (status); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p already installed!\n", + obj_desc)); + return_ACPI_STATUS(status); } /* @@ -602,9 +572,11 @@ acpi_ds_store_object_to_local ( */ new_obj_desc = obj_desc; if (obj_desc->common.reference_count > 1) { - status = acpi_ut_copy_iobject_to_iobject (obj_desc, &new_obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ut_copy_iobject_to_iobject(obj_desc, &new_obj_desc, + walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -636,28 +608,36 @@ acpi_ds_store_object_to_local ( * If we have a valid reference object that came from ref_of(), * do the indirect store */ - if ((ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) == ACPI_DESC_TYPE_OPERAND) && - (current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && - (current_obj_desc->reference.opcode == AML_REF_OF_OP)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Arg (%p) is an obj_ref(Node), storing in node %p\n", - new_obj_desc, current_obj_desc)); + if ((ACPI_GET_DESCRIPTOR_TYPE(current_obj_desc) == + ACPI_DESC_TYPE_OPERAND) + && (current_obj_desc->common.type == + ACPI_TYPE_LOCAL_REFERENCE) + && (current_obj_desc->reference.opcode == + AML_REF_OF_OP)) { + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Arg (%p) is an obj_ref(Node), storing in node %p\n", + new_obj_desc, + current_obj_desc)); /* * Store this object to the Node (perform the indirect store) * NOTE: No implicit conversion is performed, as per the ACPI * specification rules on storing to Locals/Args. */ - status = acpi_ex_store_object_to_node (new_obj_desc, - current_obj_desc->reference.object, walk_state, - ACPI_NO_IMPLICIT_CONVERSION); + status = + acpi_ex_store_object_to_node(new_obj_desc, + current_obj_desc-> + reference. + object, + walk_state, + ACPI_NO_IMPLICIT_CONVERSION); /* Remove local reference if we copied the object above */ if (new_obj_desc != obj_desc) { - acpi_ut_remove_reference (new_obj_desc); + acpi_ut_remove_reference(new_obj_desc); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } } @@ -665,7 +645,7 @@ acpi_ds_store_object_to_local ( * Delete the existing object * before storing the new one */ - acpi_ds_method_data_delete_value (opcode, index, walk_state); + acpi_ds_method_data_delete_value(opcode, index, walk_state); } /* @@ -673,18 +653,19 @@ acpi_ds_store_object_to_local ( * the descriptor for the Arg or Local. * (increments the object reference count by one) */ - status = acpi_ds_method_data_set_value (opcode, index, new_obj_desc, walk_state); + status = + acpi_ds_method_data_set_value(opcode, index, new_obj_desc, + walk_state); /* Remove local reference if we copied the object above */ if (new_obj_desc != obj_desc) { - acpi_ut_remove_reference (new_obj_desc); + acpi_ut_remove_reference(new_obj_desc); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - #ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * @@ -701,39 +682,33 @@ acpi_ds_store_object_to_local ( ******************************************************************************/ acpi_object_type -acpi_ds_method_data_get_type ( - u16 opcode, - u32 index, - struct acpi_walk_state *walk_state) +acpi_ds_method_data_get_type(u16 opcode, + u32 index, struct acpi_walk_state *walk_state) { - acpi_status status; - struct acpi_namespace_node *node; - union acpi_operand_object *object; - - - ACPI_FUNCTION_TRACE ("ds_method_data_get_type"); + acpi_status status; + struct acpi_namespace_node *node; + union acpi_operand_object *object; + ACPI_FUNCTION_TRACE("ds_method_data_get_type"); /* Get the namespace node for the arg/local */ - status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); - if (ACPI_FAILURE (status)) { - return_VALUE ((ACPI_TYPE_NOT_FOUND)); + status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); + if (ACPI_FAILURE(status)) { + return_VALUE((ACPI_TYPE_NOT_FOUND)); } /* Get the object */ - object = acpi_ns_get_attached_object (node); + object = acpi_ns_get_attached_object(node); if (!object) { /* Uninitialized local/arg, return TYPE_ANY */ - return_VALUE (ACPI_TYPE_ANY); + return_VALUE(ACPI_TYPE_ANY); } /* Get the object type */ - return_VALUE (ACPI_GET_OBJECT_TYPE (object)); + return_VALUE(ACPI_GET_OBJECT_TYPE(object)); } #endif - - diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c index 1eee2d5..8ac0cd9 100644 --- a/drivers/acpi/dispatcher/dsobject.c +++ b/drivers/acpi/dispatcher/dsobject.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -50,14 +49,12 @@ #include #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dsobject") +ACPI_MODULE_NAME("dsobject") static acpi_status -acpi_ds_build_internal_object ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - union acpi_operand_object **obj_desc_ptr); - +acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + union acpi_operand_object **obj_desc_ptr); #ifndef ACPI_NO_METHOD_EXECUTION /******************************************************************************* @@ -76,17 +73,14 @@ acpi_ds_build_internal_object ( ******************************************************************************/ static acpi_status -acpi_ds_build_internal_object ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - union acpi_operand_object **obj_desc_ptr) +acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + union acpi_operand_object **obj_desc_ptr) { - union acpi_operand_object *obj_desc; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ds_build_internal_object"); + union acpi_operand_object *obj_desc; + acpi_status status; + ACPI_FUNCTION_TRACE("ds_build_internal_object"); *obj_desc_ptr = NULL; if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { @@ -96,40 +90,44 @@ acpi_ds_build_internal_object ( * Otherwise, go ahead and look it up now */ if (!op->common.node) { - status = acpi_ns_lookup (walk_state->scope_info, - op->common.value.string, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - NULL, - (struct acpi_namespace_node **) &(op->common.node)); - - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR (op->common.value.string, status); - return_ACPI_STATUS (status); + status = acpi_ns_lookup(walk_state->scope_info, + op->common.value.string, + ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | + ACPI_NS_DONT_OPEN_SCOPE, NULL, + (struct acpi_namespace_node **) + &(op->common.node)); + + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR(op->common.value.string, + status); + return_ACPI_STATUS(status); } } } /* Create and init the internal ACPI object */ - obj_desc = acpi_ut_create_internal_object ( - (acpi_ps_get_opcode_info (op->common.aml_opcode))->object_type); + obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info + (op->common.aml_opcode))-> + object_type); if (!obj_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } - status = acpi_ds_init_object_from_op (walk_state, op, op->common.aml_opcode, - &obj_desc); - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + status = + acpi_ds_init_object_from_op(walk_state, op, op->common.aml_opcode, + &obj_desc); + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } *obj_desc_ptr = obj_desc; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_build_internal_buffer_obj @@ -147,20 +145,17 @@ acpi_ds_build_internal_object ( ******************************************************************************/ acpi_status -acpi_ds_build_internal_buffer_obj ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - u32 buffer_length, - union acpi_operand_object **obj_desc_ptr) +acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + u32 buffer_length, + union acpi_operand_object **obj_desc_ptr) { - union acpi_parse_object *arg; - union acpi_operand_object *obj_desc; - union acpi_parse_object *byte_list; - u32 byte_list_length = 0; - - - ACPI_FUNCTION_TRACE ("ds_build_internal_buffer_obj"); + union acpi_parse_object *arg; + union acpi_operand_object *obj_desc; + union acpi_parse_object *byte_list; + u32 byte_list_length = 0; + ACPI_FUNCTION_TRACE("ds_build_internal_buffer_obj"); obj_desc = *obj_desc_ptr; if (obj_desc) { @@ -168,14 +163,13 @@ acpi_ds_build_internal_buffer_obj ( * We are evaluating a Named buffer object "Name (xxxx, Buffer)". * The buffer object already exists (from the NS node) */ - } - else { + } else { /* Create a new buffer object */ - obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); *obj_desc_ptr = obj_desc; if (!obj_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } } @@ -184,16 +178,17 @@ acpi_ds_build_internal_buffer_obj ( * individual bytes or a string initializer. In either case, a * byte_list appears in the AML. */ - arg = op->common.value.arg; /* skip first arg */ + arg = op->common.value.arg; /* skip first arg */ byte_list = arg->named.next; if (byte_list) { if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Expecting bytelist, got AML opcode %X in op %p\n", - byte_list->common.aml_opcode, byte_list)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Expecting bytelist, got AML opcode %X in op %p\n", + byte_list->common.aml_opcode, + byte_list)); - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); return (AE_TYPE); } @@ -214,31 +209,29 @@ acpi_ds_build_internal_buffer_obj ( if (obj_desc->buffer.length == 0) { obj_desc->buffer.pointer = NULL; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Buffer defined with zero length in AML, creating\n")); - } - else { - obj_desc->buffer.pointer = ACPI_MEM_CALLOCATE ( - obj_desc->buffer.length); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Buffer defined with zero length in AML, creating\n")); + } else { + obj_desc->buffer.pointer = + ACPI_MEM_CALLOCATE(obj_desc->buffer.length); if (!obj_desc->buffer.pointer) { - acpi_ut_delete_object_desc (obj_desc); - return_ACPI_STATUS (AE_NO_MEMORY); + acpi_ut_delete_object_desc(obj_desc); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Initialize buffer from the byte_list (if present) */ if (byte_list) { - ACPI_MEMCPY (obj_desc->buffer.pointer, byte_list->named.data, - byte_list_length); + ACPI_MEMCPY(obj_desc->buffer.pointer, + byte_list->named.data, byte_list_length); } } obj_desc->buffer.flags |= AOPOBJ_DATA_VALID; - op->common.node = (struct acpi_namespace_node *) obj_desc; - return_ACPI_STATUS (AE_OK); + op->common.node = (struct acpi_namespace_node *)obj_desc; + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_build_internal_package_obj @@ -256,28 +249,25 @@ acpi_ds_build_internal_buffer_obj ( ******************************************************************************/ acpi_status -acpi_ds_build_internal_package_obj ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - u32 package_length, - union acpi_operand_object **obj_desc_ptr) +acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + u32 package_length, + union acpi_operand_object **obj_desc_ptr) { - union acpi_parse_object *arg; - union acpi_parse_object *parent; - union acpi_operand_object *obj_desc = NULL; - u32 package_list_length; - acpi_status status = AE_OK; - u32 i; - - - ACPI_FUNCTION_TRACE ("ds_build_internal_package_obj"); + union acpi_parse_object *arg; + union acpi_parse_object *parent; + union acpi_operand_object *obj_desc = NULL; + u32 package_list_length; + acpi_status status = AE_OK; + u32 i; + ACPI_FUNCTION_TRACE("ds_build_internal_package_obj"); /* Find the parent of a possibly nested package */ parent = op->common.parent; - while ((parent->common.aml_opcode == AML_PACKAGE_OP) || - (parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) { + while ((parent->common.aml_opcode == AML_PACKAGE_OP) || + (parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) { parent = parent->common.parent; } @@ -287,12 +277,11 @@ acpi_ds_build_internal_package_obj ( * We are evaluating a Named package object "Name (xxxx, Package)". * Get the existing package object from the NS node */ - } - else { - obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE); + } else { + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE); *obj_desc_ptr = obj_desc; if (!obj_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } obj_desc->package.node = parent->common.node; @@ -323,12 +312,13 @@ acpi_ds_build_internal_package_obj ( * individual objects). Add an extra pointer slot so * that the list is always null terminated. */ - obj_desc->package.elements = ACPI_MEM_CALLOCATE ( - ((acpi_size) obj_desc->package.count + 1) * sizeof (void *)); + obj_desc->package.elements = ACPI_MEM_CALLOCATE(((acpi_size) obj_desc-> + package.count + + 1) * sizeof(void *)); if (!obj_desc->package.elements) { - acpi_ut_delete_object_desc (obj_desc); - return_ACPI_STATUS (AE_NO_MEMORY); + acpi_ut_delete_object_desc(obj_desc); + return_ACPI_STATUS(AE_NO_MEMORY); } /* @@ -342,11 +332,13 @@ acpi_ds_build_internal_package_obj ( /* Object (package or buffer) is already built */ obj_desc->package.elements[i] = - ACPI_CAST_PTR (union acpi_operand_object, arg->common.node); - } - else { - status = acpi_ds_build_internal_object (walk_state, arg, - &obj_desc->package.elements[i]); + ACPI_CAST_PTR(union acpi_operand_object, + arg->common.node); + } else { + status = acpi_ds_build_internal_object(walk_state, arg, + &obj_desc-> + package. + elements[i]); } i++; @@ -354,11 +346,10 @@ acpi_ds_build_internal_package_obj ( } obj_desc->package.flags |= AOPOBJ_DATA_VALID; - op->common.node = (struct acpi_namespace_node *) obj_desc; - return_ACPI_STATUS (status); + op->common.node = (struct acpi_namespace_node *)obj_desc; + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_create_node @@ -374,57 +365,53 @@ acpi_ds_build_internal_package_obj ( ******************************************************************************/ acpi_status -acpi_ds_create_node ( - struct acpi_walk_state *walk_state, - struct acpi_namespace_node *node, - union acpi_parse_object *op) +acpi_ds_create_node(struct acpi_walk_state *walk_state, + struct acpi_namespace_node *node, + union acpi_parse_object *op) { - acpi_status status; - union acpi_operand_object *obj_desc; - - - ACPI_FUNCTION_TRACE_PTR ("ds_create_node", op); + acpi_status status; + union acpi_operand_object *obj_desc; + ACPI_FUNCTION_TRACE_PTR("ds_create_node", op); /* * Because of the execution pass through the non-control-method * parts of the table, we can arrive here twice. Only init * the named object node the first time through */ - if (acpi_ns_get_attached_object (node)) { - return_ACPI_STATUS (AE_OK); + if (acpi_ns_get_attached_object(node)) { + return_ACPI_STATUS(AE_OK); } if (!op->common.value.arg) { /* No arguments, there is nothing to do */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Build an internal object for the argument(s) */ - status = acpi_ds_build_internal_object (walk_state, op->common.value.arg, - &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_build_internal_object(walk_state, op->common.value.arg, + &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Re-type the object according to its argument */ - node->type = ACPI_GET_OBJECT_TYPE (obj_desc); + node->type = ACPI_GET_OBJECT_TYPE(obj_desc); /* Attach obj to node */ - status = acpi_ns_attach_object (node, obj_desc, node->type); + status = acpi_ns_attach_object(node, obj_desc, node->type); /* Remove local reference to the object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } -#endif /* ACPI_NO_METHOD_EXECUTION */ - +#endif /* ACPI_NO_METHOD_EXECUTION */ /******************************************************************************* * @@ -444,55 +431,50 @@ acpi_ds_create_node ( ******************************************************************************/ acpi_status -acpi_ds_init_object_from_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - u16 opcode, - union acpi_operand_object **ret_obj_desc) +acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + u16 opcode, + union acpi_operand_object **ret_obj_desc) { - const struct acpi_opcode_info *op_info; - union acpi_operand_object *obj_desc; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ds_init_object_from_op"); + const struct acpi_opcode_info *op_info; + union acpi_operand_object *obj_desc; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ds_init_object_from_op"); obj_desc = *ret_obj_desc; - op_info = acpi_ps_get_opcode_info (opcode); + op_info = acpi_ps_get_opcode_info(opcode); if (op_info->class == AML_CLASS_UNKNOWN) { /* Unknown opcode */ - return_ACPI_STATUS (AE_TYPE); + return_ACPI_STATUS(AE_TYPE); } /* Perform per-object initialization */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_BUFFER: /* * Defer evaluation of Buffer term_arg operand */ - obj_desc->buffer.node = (struct acpi_namespace_node *) - walk_state->operands[0]; + obj_desc->buffer.node = (struct acpi_namespace_node *) + walk_state->operands[0]; obj_desc->buffer.aml_start = op->named.data; obj_desc->buffer.aml_length = op->named.length; break; - case ACPI_TYPE_PACKAGE: /* * Defer evaluation of Package term_arg operand */ - obj_desc->package.node = (struct acpi_namespace_node *) - walk_state->operands[0]; + obj_desc->package.node = (struct acpi_namespace_node *) + walk_state->operands[0]; obj_desc->package.aml_start = op->named.data; obj_desc->package.aml_length = op->named.length; break; - case ACPI_TYPE_INTEGER: switch (op_info->type) { @@ -525,7 +507,7 @@ acpi_ds_init_object_from_op ( /* Truncate value if we are executing from a 32-bit ACPI table */ #ifndef ACPI_NO_METHOD_EXECUTION - acpi_ex_truncate_for32bit_table (obj_desc); + acpi_ex_truncate_for32bit_table(obj_desc); #endif break; @@ -536,36 +518,36 @@ acpi_ds_init_object_from_op ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown constant opcode %X\n", opcode)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown constant opcode %X\n", + opcode)); status = AE_AML_OPERAND_TYPE; break; } break; - case AML_TYPE_LITERAL: obj_desc->integer.value = op->common.value.integer; #ifndef ACPI_NO_METHOD_EXECUTION - acpi_ex_truncate_for32bit_table (obj_desc); + acpi_ex_truncate_for32bit_table(obj_desc); #endif break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", - op_info->type)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown Integer type %X\n", + op_info->type)); status = AE_AML_OPERAND_TYPE; break; } break; - case ACPI_TYPE_STRING: obj_desc->string.pointer = op->common.value.string; - obj_desc->string.length = (u32) ACPI_STRLEN (op->common.value.string); + obj_desc->string.length = + (u32) ACPI_STRLEN(op->common.value.string); /* * The string is contained in the ACPI table, don't ever try @@ -574,11 +556,9 @@ acpi_ds_init_object_from_op ( obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; break; - case ACPI_TYPE_METHOD: break; - case ACPI_TYPE_LOCAL_REFERENCE: switch (op_info->type) { @@ -590,14 +570,17 @@ acpi_ds_init_object_from_op ( obj_desc->reference.offset = opcode - AML_LOCAL_OP; #ifndef ACPI_NO_METHOD_EXECUTION - status = acpi_ds_method_data_get_node (AML_LOCAL_OP, - obj_desc->reference.offset, - walk_state, - (struct acpi_namespace_node **) &obj_desc->reference.object); + status = acpi_ds_method_data_get_node(AML_LOCAL_OP, + obj_desc-> + reference.offset, + walk_state, + (struct + acpi_namespace_node + **)&obj_desc-> + reference.object); #endif break; - case AML_TYPE_METHOD_ARGUMENT: /* Split the opcode into a base opcode + offset */ @@ -606,14 +589,18 @@ acpi_ds_init_object_from_op ( obj_desc->reference.offset = opcode - AML_ARG_OP; #ifndef ACPI_NO_METHOD_EXECUTION - status = acpi_ds_method_data_get_node (AML_ARG_OP, - obj_desc->reference.offset, - walk_state, - (struct acpi_namespace_node **) &obj_desc->reference.object); + status = acpi_ds_method_data_get_node(AML_ARG_OP, + obj_desc-> + reference.offset, + walk_state, + (struct + acpi_namespace_node + **)&obj_desc-> + reference.object); #endif break; - default: /* Other literals, etc.. */ + default: /* Other literals, etc.. */ if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { /* Node was saved in Op */ @@ -626,17 +613,15 @@ acpi_ds_init_object_from_op ( } break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %X\n", - ACPI_GET_OBJECT_TYPE (obj_desc))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unimplemented data type: %X\n", + ACPI_GET_OBJECT_TYPE(obj_desc))); status = AE_AML_OPERAND_TYPE; break; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c index 750bdb1..939d167 100644 --- a/drivers/acpi/dispatcher/dsopcode.c +++ b/drivers/acpi/dispatcher/dsopcode.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -52,26 +51,21 @@ #include #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dsopcode") +ACPI_MODULE_NAME("dsopcode") /* Local prototypes */ - static acpi_status -acpi_ds_execute_arguments ( - struct acpi_namespace_node *node, - struct acpi_namespace_node *scope_node, - u32 aml_length, - u8 *aml_start); +acpi_ds_execute_arguments(struct acpi_namespace_node *node, + struct acpi_namespace_node *scope_node, + u32 aml_length, u8 * aml_start); static acpi_status -acpi_ds_init_buffer_field ( - u16 aml_opcode, - union acpi_operand_object *obj_desc, - union acpi_operand_object *buffer_desc, - union acpi_operand_object *offset_desc, - union acpi_operand_object *length_desc, - union acpi_operand_object *result_desc); - +acpi_ds_init_buffer_field(u16 aml_opcode, + union acpi_operand_object *obj_desc, + union acpi_operand_object *buffer_desc, + union acpi_operand_object *offset_desc, + union acpi_operand_object *length_desc, + union acpi_operand_object *result_desc); /******************************************************************************* * @@ -89,26 +83,22 @@ acpi_ds_init_buffer_field ( ******************************************************************************/ static acpi_status -acpi_ds_execute_arguments ( - struct acpi_namespace_node *node, - struct acpi_namespace_node *scope_node, - u32 aml_length, - u8 *aml_start) +acpi_ds_execute_arguments(struct acpi_namespace_node *node, + struct acpi_namespace_node *scope_node, + u32 aml_length, u8 * aml_start) { - acpi_status status; - union acpi_parse_object *op; - struct acpi_walk_state *walk_state; - - - ACPI_FUNCTION_TRACE ("ds_execute_arguments"); + acpi_status status; + union acpi_parse_object *op; + struct acpi_walk_state *walk_state; + ACPI_FUNCTION_TRACE("ds_execute_arguments"); /* * Allocate a new parser op to be the root of the parsed tree */ - op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP); + op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP); if (!op) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Save the Node for use in acpi_ps_parse_aml */ @@ -117,16 +107,16 @@ acpi_ds_execute_arguments ( /* Create and initialize a new parser state */ - walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); + walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL); if (!walk_state) { status = AE_NO_MEMORY; goto cleanup; } - status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start, - aml_length, NULL, 1); - if (ACPI_FAILURE (status)) { - acpi_ds_delete_walk_state (walk_state); + status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start, + aml_length, NULL, 1); + if (ACPI_FAILURE(status)) { + acpi_ds_delete_walk_state(walk_state); goto cleanup; } @@ -137,28 +127,28 @@ acpi_ds_execute_arguments ( /* Pass1: Parse the entire declaration */ - status = acpi_ps_parse_aml (walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ps_parse_aml(walk_state); + if (ACPI_FAILURE(status)) { goto cleanup; } /* Get and init the Op created above */ op->common.node = node; - acpi_ps_delete_parse_tree (op); + acpi_ps_delete_parse_tree(op); /* Evaluate the deferred arguments */ - op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP); + op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP); if (!op) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } op->common.node = scope_node; /* Create and initialize a new parser state */ - walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); + walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL); if (!walk_state) { status = AE_NO_MEMORY; goto cleanup; @@ -166,24 +156,23 @@ acpi_ds_execute_arguments ( /* Execute the opcode and arguments */ - status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start, - aml_length, NULL, 3); - if (ACPI_FAILURE (status)) { - acpi_ds_delete_walk_state (walk_state); + status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start, + aml_length, NULL, 3); + if (ACPI_FAILURE(status)) { + acpi_ds_delete_walk_state(walk_state); goto cleanup; } /* Mark this execution as a deferred opcode */ walk_state->deferred_node = node; - status = acpi_ps_parse_aml (walk_state); + status = acpi_ps_parse_aml(walk_state); -cleanup: - acpi_ps_delete_parse_tree (op); - return_ACPI_STATUS (status); + cleanup: + acpi_ps_delete_parse_tree(op); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_get_buffer_field_arguments @@ -198,38 +187,36 @@ cleanup: ******************************************************************************/ acpi_status -acpi_ds_get_buffer_field_arguments ( - union acpi_operand_object *obj_desc) +acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc) { - union acpi_operand_object *extra_desc; - struct acpi_namespace_node *node; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_field_arguments", obj_desc); + union acpi_operand_object *extra_desc; + struct acpi_namespace_node *node; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ds_get_buffer_field_arguments", obj_desc); if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Get the AML pointer (method object) and buffer_field node */ - extra_desc = acpi_ns_get_secondary_object (obj_desc); + extra_desc = acpi_ns_get_secondary_object(obj_desc); node = obj_desc->buffer_field.node; - ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_BUFFER_FIELD, node, NULL)); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] buffer_field Arg Init\n", - acpi_ut_get_node_name (node))); + ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname + (ACPI_TYPE_BUFFER_FIELD, node, NULL)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] buffer_field Arg Init\n", + acpi_ut_get_node_name(node))); /* Execute the AML code for the term_arg arguments */ - status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node), - extra_desc->extra.aml_length, extra_desc->extra.aml_start); - return_ACPI_STATUS (status); + status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), + extra_desc->extra.aml_length, + extra_desc->extra.aml_start); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_get_buffer_arguments @@ -243,40 +230,35 @@ acpi_ds_get_buffer_field_arguments ( * ******************************************************************************/ -acpi_status -acpi_ds_get_buffer_arguments ( - union acpi_operand_object *obj_desc) +acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc) { - struct acpi_namespace_node *node; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_arguments", obj_desc); + struct acpi_namespace_node *node; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ds_get_buffer_arguments", obj_desc); if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Get the Buffer node */ node = obj_desc->buffer.node; if (!node) { - ACPI_REPORT_ERROR (( - "No pointer back to NS node in buffer obj %p\n", obj_desc)); - return_ACPI_STATUS (AE_AML_INTERNAL); + ACPI_REPORT_ERROR(("No pointer back to NS node in buffer obj %p\n", obj_desc)); + return_ACPI_STATUS(AE_AML_INTERNAL); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n")); /* Execute the AML code for the term_arg arguments */ - status = acpi_ds_execute_arguments (node, node, - obj_desc->buffer.aml_length, obj_desc->buffer.aml_start); - return_ACPI_STATUS (status); + status = acpi_ds_execute_arguments(node, node, + obj_desc->buffer.aml_length, + obj_desc->buffer.aml_start); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_get_package_arguments @@ -290,40 +272,36 @@ acpi_ds_get_buffer_arguments ( * ******************************************************************************/ -acpi_status -acpi_ds_get_package_arguments ( - union acpi_operand_object *obj_desc) +acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc) { - struct acpi_namespace_node *node; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ds_get_package_arguments", obj_desc); + struct acpi_namespace_node *node; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ds_get_package_arguments", obj_desc); if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Get the Package node */ node = obj_desc->package.node; if (!node) { - ACPI_REPORT_ERROR (( - "No pointer back to NS node in package %p\n", obj_desc)); - return_ACPI_STATUS (AE_AML_INTERNAL); + ACPI_REPORT_ERROR(("No pointer back to NS node in package %p\n", + obj_desc)); + return_ACPI_STATUS(AE_AML_INTERNAL); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n")); /* Execute the AML code for the term_arg arguments */ - status = acpi_ds_execute_arguments (node, node, - obj_desc->package.aml_length, obj_desc->package.aml_start); - return_ACPI_STATUS (status); + status = acpi_ds_execute_arguments(node, node, + obj_desc->package.aml_length, + obj_desc->package.aml_start); + return_ACPI_STATUS(status); } - /***************************************************************************** * * FUNCTION: acpi_ds_get_region_arguments @@ -337,44 +315,43 @@ acpi_ds_get_package_arguments ( * ****************************************************************************/ -acpi_status -acpi_ds_get_region_arguments ( - union acpi_operand_object *obj_desc) +acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc) { - struct acpi_namespace_node *node; - acpi_status status; - union acpi_operand_object *extra_desc; - - - ACPI_FUNCTION_TRACE_PTR ("ds_get_region_arguments", obj_desc); + struct acpi_namespace_node *node; + acpi_status status; + union acpi_operand_object *extra_desc; + ACPI_FUNCTION_TRACE_PTR("ds_get_region_arguments", obj_desc); if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - extra_desc = acpi_ns_get_secondary_object (obj_desc); + extra_desc = acpi_ns_get_secondary_object(obj_desc); if (!extra_desc) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } /* Get the Region node */ node = obj_desc->region.node; - ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_REGION, node, NULL)); + ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname + (ACPI_TYPE_REGION, node, NULL)); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] op_region Arg Init at AML %p\n", - acpi_ut_get_node_name (node), extra_desc->extra.aml_start)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[%4.4s] op_region Arg Init at AML %p\n", + acpi_ut_get_node_name(node), + extra_desc->extra.aml_start)); /* Execute the argument AML */ - status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node), - extra_desc->extra.aml_length, extra_desc->extra.aml_start); - return_ACPI_STATUS (status); + status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), + extra_desc->extra.aml_length, + extra_desc->extra.aml_start); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_initialize_region @@ -387,23 +364,19 @@ acpi_ds_get_region_arguments ( * ******************************************************************************/ -acpi_status -acpi_ds_initialize_region ( - acpi_handle obj_handle) +acpi_status acpi_ds_initialize_region(acpi_handle obj_handle) { - union acpi_operand_object *obj_desc; - acpi_status status; + union acpi_operand_object *obj_desc; + acpi_status status; - - obj_desc = acpi_ns_get_attached_object (obj_handle); + obj_desc = acpi_ns_get_attached_object(obj_handle); /* Namespace is NOT locked */ - status = acpi_ev_initialize_region (obj_desc, FALSE); + status = acpi_ev_initialize_region(obj_desc, FALSE); return (status); } - /******************************************************************************* * * FUNCTION: acpi_ds_init_buffer_field @@ -422,30 +395,27 @@ acpi_ds_initialize_region ( ******************************************************************************/ static acpi_status -acpi_ds_init_buffer_field ( - u16 aml_opcode, - union acpi_operand_object *obj_desc, - union acpi_operand_object *buffer_desc, - union acpi_operand_object *offset_desc, - union acpi_operand_object *length_desc, - union acpi_operand_object *result_desc) +acpi_ds_init_buffer_field(u16 aml_opcode, + union acpi_operand_object *obj_desc, + union acpi_operand_object *buffer_desc, + union acpi_operand_object *offset_desc, + union acpi_operand_object *length_desc, + union acpi_operand_object *result_desc) { - u32 offset; - u32 bit_offset; - u32 bit_count; - u8 field_flags; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ds_init_buffer_field", obj_desc); + u32 offset; + u32 bit_offset; + u32 bit_count; + u8 field_flags; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ds_init_buffer_field", obj_desc); /* Host object must be a Buffer */ - if (ACPI_GET_OBJECT_TYPE (buffer_desc) != ACPI_TYPE_BUFFER) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Target of Create Field is not a Buffer object - %s\n", - acpi_ut_get_object_type_name (buffer_desc))); + if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Target of Create Field is not a Buffer object - %s\n", + acpi_ut_get_object_type_name(buffer_desc))); status = AE_AML_OPERAND_TYPE; goto cleanup; @@ -456,11 +426,11 @@ acpi_ds_init_buffer_field ( * out as a name_string, and should therefore now be a NS node * after resolution in acpi_ex_resolve_operands(). */ - if (ACPI_GET_DESCRIPTOR_TYPE (result_desc) != ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "(%s) destination not a NS Node [%s]\n", - acpi_ps_get_opcode_name (aml_opcode), - acpi_ut_get_descriptor_name (result_desc))); + if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "(%s) destination not a NS Node [%s]\n", + acpi_ps_get_opcode_name(aml_opcode), + acpi_ut_get_descriptor_name(result_desc))); status = AE_AML_OPERAND_TYPE; goto cleanup; @@ -478,13 +448,13 @@ acpi_ds_init_buffer_field ( field_flags = AML_FIELD_ACCESS_BYTE; bit_offset = offset; - bit_count = (u32) length_desc->integer.value; + bit_count = (u32) length_desc->integer.value; /* Must have a valid (>0) bit count */ if (bit_count == 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Attempt to create_field of length 0\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Attempt to create_field of length 0\n")); status = AE_AML_OPERAND_VALUE; goto cleanup; } @@ -495,7 +465,7 @@ acpi_ds_init_buffer_field ( /* Offset is in bits, Field is one bit */ bit_offset = offset; - bit_count = 1; + bit_count = 1; field_flags = AML_FIELD_ACCESS_BYTE; break; @@ -504,7 +474,7 @@ acpi_ds_init_buffer_field ( /* Offset is in bytes, field is one byte */ bit_offset = 8 * offset; - bit_count = 8; + bit_count = 8; field_flags = AML_FIELD_ACCESS_BYTE; break; @@ -513,7 +483,7 @@ acpi_ds_init_buffer_field ( /* Offset is in bytes, field is one word */ bit_offset = 8 * offset; - bit_count = 16; + bit_count = 16; field_flags = AML_FIELD_ACCESS_WORD; break; @@ -522,7 +492,7 @@ acpi_ds_init_buffer_field ( /* Offset is in bytes, field is one dword */ bit_offset = 8 * offset; - bit_count = 32; + bit_count = 32; field_flags = AML_FIELD_ACCESS_DWORD; break; @@ -531,29 +501,29 @@ acpi_ds_init_buffer_field ( /* Offset is in bytes, field is one qword */ bit_offset = 8 * offset; - bit_count = 64; + bit_count = 64; field_flags = AML_FIELD_ACCESS_QWORD; break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown field creation opcode %02x\n", - aml_opcode)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown field creation opcode %02x\n", + aml_opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } /* Entire field must fit within the current length of the buffer */ - if ((bit_offset + bit_count) > - (8 * (u32) buffer_desc->buffer.length)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", - acpi_ut_get_node_name (result_desc), - bit_offset + bit_count, - acpi_ut_get_node_name (buffer_desc->buffer.node), - 8 * (u32) buffer_desc->buffer.length)); + if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", + acpi_ut_get_node_name(result_desc), + bit_offset + bit_count, + acpi_ut_get_node_name(buffer_desc->buffer. + node), + 8 * (u32) buffer_desc->buffer.length)); status = AE_AML_BUFFER_LIMIT; goto cleanup; } @@ -563,9 +533,9 @@ acpi_ds_init_buffer_field ( * For field_flags, use LOCK_RULE = 0 (NO_LOCK), * UPDATE_RULE = 0 (UPDATE_PRESERVE) */ - status = acpi_ex_prep_common_field_object (obj_desc, field_flags, 0, - bit_offset, bit_count); - if (ACPI_FAILURE (status)) { + status = acpi_ex_prep_common_field_object(obj_desc, field_flags, 0, + bit_offset, bit_count); + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -574,35 +544,33 @@ acpi_ds_init_buffer_field ( /* Reference count for buffer_desc inherits obj_desc count */ buffer_desc->common.reference_count = (u16) - (buffer_desc->common.reference_count + obj_desc->common.reference_count); + (buffer_desc->common.reference_count + + obj_desc->common.reference_count); - -cleanup: + cleanup: /* Always delete the operands */ - acpi_ut_remove_reference (offset_desc); - acpi_ut_remove_reference (buffer_desc); + acpi_ut_remove_reference(offset_desc); + acpi_ut_remove_reference(buffer_desc); if (aml_opcode == AML_CREATE_FIELD_OP) { - acpi_ut_remove_reference (length_desc); + acpi_ut_remove_reference(length_desc); } /* On failure, delete the result descriptor */ - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (result_desc); /* Result descriptor */ - } - else { + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference(result_desc); /* Result descriptor */ + } else { /* Now the address and length are valid for this buffer_field */ obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_eval_buffer_field_operands @@ -618,24 +586,21 @@ cleanup: ******************************************************************************/ acpi_status -acpi_ds_eval_buffer_field_operands ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op) +acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state, + union acpi_parse_object *op) { - acpi_status status; - union acpi_operand_object *obj_desc; - struct acpi_namespace_node *node; - union acpi_parse_object *next_op; - - - ACPI_FUNCTION_TRACE_PTR ("ds_eval_buffer_field_operands", op); + acpi_status status; + union acpi_operand_object *obj_desc; + struct acpi_namespace_node *node; + union acpi_parse_object *next_op; + ACPI_FUNCTION_TRACE_PTR("ds_eval_buffer_field_operands", op); /* * This is where we evaluate the address and length fields of the * create_xxx_field declaration */ - node = op->common.node; + node = op->common.node; /* next_op points to the op that holds the Buffer */ @@ -643,30 +608,32 @@ acpi_ds_eval_buffer_field_operands ( /* Evaluate/create the address and length operands */ - status = acpi_ds_create_operands (walk_state, next_op); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_create_operands(walk_state, next_op); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } /* Resolve the operands */ - status = acpi_ex_resolve_operands (op->common.aml_opcode, - ACPI_WALK_OPERANDS, walk_state); + status = acpi_ex_resolve_operands(op->common.aml_opcode, + ACPI_WALK_OPERANDS, walk_state); - ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, - acpi_ps_get_opcode_name (op->common.aml_opcode), - walk_state->num_operands, "after acpi_ex_resolve_operands"); + ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, + acpi_ps_get_opcode_name(op->common.aml_opcode), + walk_state->num_operands, + "after acpi_ex_resolve_operands"); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", - acpi_ps_get_opcode_name (op->common.aml_opcode), status)); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", + acpi_ps_get_opcode_name(op->common. + aml_opcode), status)); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Initialize the Buffer Field */ @@ -674,22 +641,25 @@ acpi_ds_eval_buffer_field_operands ( if (op->common.aml_opcode == AML_CREATE_FIELD_OP) { /* NOTE: Slightly different operands for this opcode */ - status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc, - walk_state->operands[0], walk_state->operands[1], - walk_state->operands[2], walk_state->operands[3]); - } - else { + status = + acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc, + walk_state->operands[0], + walk_state->operands[1], + walk_state->operands[2], + walk_state->operands[3]); + } else { /* All other, create_xxx_field opcodes */ - status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc, - walk_state->operands[0], walk_state->operands[1], - NULL, walk_state->operands[2]); + status = + acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc, + walk_state->operands[0], + walk_state->operands[1], NULL, + walk_state->operands[2]); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_eval_region_operands @@ -705,25 +675,22 @@ acpi_ds_eval_buffer_field_operands ( ******************************************************************************/ acpi_status -acpi_ds_eval_region_operands ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op) +acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state, + union acpi_parse_object *op) { - acpi_status status; - union acpi_operand_object *obj_desc; - union acpi_operand_object *operand_desc; - struct acpi_namespace_node *node; - union acpi_parse_object *next_op; - - - ACPI_FUNCTION_TRACE_PTR ("ds_eval_region_operands", op); + acpi_status status; + union acpi_operand_object *obj_desc; + union acpi_operand_object *operand_desc; + struct acpi_namespace_node *node; + union acpi_parse_object *next_op; + ACPI_FUNCTION_TRACE_PTR("ds_eval_region_operands", op); /* * This is where we evaluate the address and length fields of the * op_region declaration */ - node = op->common.node; + node = op->common.node; /* next_op points to the op that holds the space_iD */ @@ -735,26 +702,26 @@ acpi_ds_eval_region_operands ( /* Evaluate/create the address and length operands */ - status = acpi_ds_create_operands (walk_state, next_op); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_create_operands(walk_state, next_op); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Resolve the length and address operands to numbers */ - status = acpi_ex_resolve_operands (op->common.aml_opcode, - ACPI_WALK_OPERANDS, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_resolve_operands(op->common.aml_opcode, + ACPI_WALK_OPERANDS, walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, - acpi_ps_get_opcode_name (op->common.aml_opcode), - 1, "after acpi_ex_resolve_operands"); + ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, + acpi_ps_get_opcode_name(op->common.aml_opcode), + 1, "after acpi_ex_resolve_operands"); - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } /* @@ -764,7 +731,7 @@ acpi_ds_eval_region_operands ( operand_desc = walk_state->operands[walk_state->num_operands - 1]; obj_desc->region.length = (u32) operand_desc->integer.value; - acpi_ut_remove_reference (operand_desc); + acpi_ut_remove_reference(operand_desc); /* * Get the address and save it @@ -773,22 +740,21 @@ acpi_ds_eval_region_operands ( operand_desc = walk_state->operands[walk_state->num_operands - 2]; obj_desc->region.address = (acpi_physical_address) - operand_desc->integer.value; - acpi_ut_remove_reference (operand_desc); + operand_desc->integer.value; + acpi_ut_remove_reference(operand_desc); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n", - obj_desc, - ACPI_FORMAT_UINT64 (obj_desc->region.address), - obj_desc->region.length)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n", + obj_desc, + ACPI_FORMAT_UINT64(obj_desc->region.address), + obj_desc->region.length)); /* Now the address and length are valid for this opregion */ obj_desc->region.flags |= AOPOBJ_DATA_VALID; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_eval_data_object_operands @@ -805,46 +771,44 @@ acpi_ds_eval_region_operands ( ******************************************************************************/ acpi_status -acpi_ds_eval_data_object_operands ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - union acpi_operand_object *obj_desc) +acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + union acpi_operand_object *obj_desc) { - acpi_status status; - union acpi_operand_object *arg_desc; - u32 length; - - - ACPI_FUNCTION_TRACE ("ds_eval_data_object_operands"); + acpi_status status; + union acpi_operand_object *arg_desc; + u32 length; + ACPI_FUNCTION_TRACE("ds_eval_data_object_operands"); /* The first operand (for all of these data objects) is the length */ - status = acpi_ds_create_operand (walk_state, op->common.value.arg, 1); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_ex_resolve_operands (walk_state->opcode, - &(walk_state->operands [walk_state->num_operands -1]), - walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_resolve_operands(walk_state->opcode, + &(walk_state-> + operands[walk_state->num_operands - + 1]), walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Extract length operand */ - arg_desc = walk_state->operands [walk_state->num_operands - 1]; + arg_desc = walk_state->operands[walk_state->num_operands - 1]; length = (u32) arg_desc->integer.value; /* Cleanup for length operand */ - status = acpi_ds_obj_stack_pop (1, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_obj_stack_pop(1, walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - acpi_ut_remove_reference (arg_desc); + acpi_ut_remove_reference(arg_desc); /* * Create the actual data object @@ -852,37 +816,42 @@ acpi_ds_eval_data_object_operands ( switch (op->common.aml_opcode) { case AML_BUFFER_OP: - status = acpi_ds_build_internal_buffer_obj (walk_state, op, length, &obj_desc); + status = + acpi_ds_build_internal_buffer_obj(walk_state, op, length, + &obj_desc); break; case AML_PACKAGE_OP: case AML_VAR_PACKAGE_OP: - status = acpi_ds_build_internal_package_obj (walk_state, op, length, &obj_desc); + status = + acpi_ds_build_internal_package_obj(walk_state, op, length, + &obj_desc); break; default: - return_ACPI_STATUS (AE_AML_BAD_OPCODE); + return_ACPI_STATUS(AE_AML_BAD_OPCODE); } - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { /* * Return the object in the walk_state, unless the parent is a package - * in this case, the return object will be stored in the parse tree * for the package. */ if ((!op->common.parent) || - ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && - (op->common.parent->common.aml_opcode != AML_VAR_PACKAGE_OP) && - (op->common.parent->common.aml_opcode != AML_NAME_OP))) { + ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && + (op->common.parent->common.aml_opcode != + AML_VAR_PACKAGE_OP) + && (op->common.parent->common.aml_opcode != + AML_NAME_OP))) { walk_state->result_obj = obj_desc; } } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_exec_begin_control_op @@ -898,19 +867,16 @@ acpi_ds_eval_data_object_operands ( ******************************************************************************/ acpi_status -acpi_ds_exec_begin_control_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op) +acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, + union acpi_parse_object *op) { - acpi_status status = AE_OK; - union acpi_generic_state *control_state; - - - ACPI_FUNCTION_NAME ("ds_exec_begin_control_op"); + acpi_status status = AE_OK; + union acpi_generic_state *control_state; + ACPI_FUNCTION_NAME("ds_exec_begin_control_op"); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op, - op->common.aml_opcode, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op, + op->common.aml_opcode, walk_state)); switch (op->common.aml_opcode) { case AML_IF_OP: @@ -921,7 +887,7 @@ acpi_ds_exec_begin_control_op ( * constructs. We need to manage these as a stack, in order * to handle nesting. */ - control_state = acpi_ut_create_control_state (); + control_state = acpi_ut_create_control_state(); if (!control_state) { status = AE_NO_MEMORY; break; @@ -930,14 +896,16 @@ acpi_ds_exec_begin_control_op ( * Save a pointer to the predicate for multiple executions * of a loop */ - control_state->control.aml_predicate_start = walk_state->parser_state.aml - 1; - control_state->control.package_end = walk_state->parser_state.pkg_end; + control_state->control.aml_predicate_start = + walk_state->parser_state.aml - 1; + control_state->control.package_end = + walk_state->parser_state.pkg_end; control_state->control.opcode = op->common.aml_opcode; - /* Push the control state on this walk's control stack */ - acpi_ut_push_generic_state (&walk_state->control_state, control_state); + acpi_ut_push_generic_state(&walk_state->control_state, + control_state); break; case AML_ELSE_OP: @@ -962,7 +930,6 @@ acpi_ds_exec_begin_control_op ( return (status); } - /******************************************************************************* * * FUNCTION: acpi_ds_exec_end_control_op @@ -978,46 +945,42 @@ acpi_ds_exec_begin_control_op ( ******************************************************************************/ acpi_status -acpi_ds_exec_end_control_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op) +acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state, + union acpi_parse_object * op) { - acpi_status status = AE_OK; - union acpi_generic_state *control_state; - - - ACPI_FUNCTION_NAME ("ds_exec_end_control_op"); + acpi_status status = AE_OK; + union acpi_generic_state *control_state; + ACPI_FUNCTION_NAME("ds_exec_end_control_op"); switch (op->common.aml_opcode) { case AML_IF_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op)); /* * Save the result of the predicate in case there is an * ELSE to come */ walk_state->last_predicate = - (u8) walk_state->control_state->common.value; + (u8) walk_state->control_state->common.value; /* * Pop the control state that was created at the start * of the IF and free it */ - control_state = acpi_ut_pop_generic_state (&walk_state->control_state); - acpi_ut_delete_generic_state (control_state); + control_state = + acpi_ut_pop_generic_state(&walk_state->control_state); + acpi_ut_delete_generic_state(control_state); break; - case AML_ELSE_OP: break; - case AML_WHILE_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); if (walk_state->control_state->common.value) { /* Predicate was true, go back and evaluate it again! */ @@ -1025,22 +988,24 @@ acpi_ds_exec_end_control_op ( status = AE_CTRL_PENDING; } - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "[WHILE_OP] termination! Op=%p\n",op)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "[WHILE_OP] termination! Op=%p\n", op)); /* Pop this control state and free it */ - control_state = acpi_ut_pop_generic_state (&walk_state->control_state); + control_state = + acpi_ut_pop_generic_state(&walk_state->control_state); - walk_state->aml_last_while = control_state->control.aml_predicate_start; - acpi_ut_delete_generic_state (control_state); + walk_state->aml_last_while = + control_state->control.aml_predicate_start; + acpi_ut_delete_generic_state(control_state); break; - case AML_RETURN_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "[RETURN_OP] Op=%p Arg=%p\n",op, op->common.value.arg)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "[RETURN_OP] Op=%p Arg=%p\n", op, + op->common.value.arg)); /* * One optional operand -- the return value @@ -1050,12 +1015,14 @@ acpi_ds_exec_end_control_op ( if (op->common.value.arg) { /* Since we have a real Return(), delete any implicit return */ - acpi_ds_clear_implicit_return (walk_state); + acpi_ds_clear_implicit_return(walk_state); /* Return statement has an immediate operand */ - status = acpi_ds_create_operands (walk_state, op->common.value.arg); - if (ACPI_FAILURE (status)) { + status = + acpi_ds_create_operands(walk_state, + op->common.value.arg); + if (ACPI_FAILURE(status)) { return (status); } @@ -1064,8 +1031,10 @@ acpi_ds_exec_end_control_op ( * an arg or local), resolve it now because it may * cease to exist at the end of the method. */ - status = acpi_ex_resolve_to_value (&walk_state->operands [0], walk_state); - if (ACPI_FAILURE (status)) { + status = + acpi_ex_resolve_to_value(&walk_state->operands[0], + walk_state); + if (ACPI_FAILURE(status)) { return (status); } @@ -1075,12 +1044,11 @@ acpi_ds_exec_end_control_op ( * is set to anything other than zero! */ walk_state->return_desc = walk_state->operands[0]; - } - else if ((walk_state->results) && - (walk_state->results->results.num_results > 0)) { + } else if ((walk_state->results) && + (walk_state->results->results.num_results > 0)) { /* Since we have a real Return(), delete any implicit return */ - acpi_ds_clear_implicit_return (walk_state); + acpi_ds_clear_implicit_return(walk_state); /* * The return value has come from a previous calculation. @@ -1091,67 +1059,78 @@ acpi_ds_exec_end_control_op ( * * Allow references created by the Index operator to return unchanged. */ - if ((ACPI_GET_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc[0]) == ACPI_DESC_TYPE_OPERAND) && - (ACPI_GET_OBJECT_TYPE (walk_state->results->results.obj_desc [0]) == ACPI_TYPE_LOCAL_REFERENCE) && - ((walk_state->results->results.obj_desc [0])->reference.opcode != AML_INDEX_OP)) { - status = acpi_ex_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state); - if (ACPI_FAILURE (status)) { + if ((ACPI_GET_DESCRIPTOR_TYPE + (walk_state->results->results.obj_desc[0]) == + ACPI_DESC_TYPE_OPERAND) + && + (ACPI_GET_OBJECT_TYPE + (walk_state->results->results.obj_desc[0]) == + ACPI_TYPE_LOCAL_REFERENCE) + && ((walk_state->results->results.obj_desc[0])-> + reference.opcode != AML_INDEX_OP)) { + status = + acpi_ex_resolve_to_value(&walk_state-> + results->results. + obj_desc[0], + walk_state); + if (ACPI_FAILURE(status)) { return (status); } } - walk_state->return_desc = walk_state->results->results.obj_desc [0]; - } - else { + walk_state->return_desc = + walk_state->results->results.obj_desc[0]; + } else { /* No return operand */ if (walk_state->num_operands) { - acpi_ut_remove_reference (walk_state->operands [0]); + acpi_ut_remove_reference(walk_state-> + operands[0]); } - walk_state->operands [0] = NULL; - walk_state->num_operands = 0; - walk_state->return_desc = NULL; + walk_state->operands[0] = NULL; + walk_state->num_operands = 0; + walk_state->return_desc = NULL; } - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Completed RETURN_OP State=%p, ret_val=%p\n", - walk_state, walk_state->return_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Completed RETURN_OP State=%p, ret_val=%p\n", + walk_state, walk_state->return_desc)); /* End the control method execution right now */ status = AE_CTRL_TERMINATE; break; - case AML_NOOP_OP: /* Just do nothing! */ break; - case AML_BREAK_POINT_OP: /* Call up to the OS service layer to handle this */ - status = acpi_os_signal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); + status = + acpi_os_signal(ACPI_SIGNAL_BREAKPOINT, + "Executed AML Breakpoint opcode"); /* If and when it returns, all done. */ break; - case AML_BREAK_OP: - case AML_CONTINUE_OP: /* ACPI 2.0 */ - + case AML_CONTINUE_OP: /* ACPI 2.0 */ /* Pop and delete control states until we find a while */ while (walk_state->control_state && - (walk_state->control_state->control.opcode != AML_WHILE_OP)) { - control_state = acpi_ut_pop_generic_state (&walk_state->control_state); - acpi_ut_delete_generic_state (control_state); + (walk_state->control_state->control.opcode != + AML_WHILE_OP)) { + control_state = + acpi_ut_pop_generic_state(&walk_state-> + control_state); + acpi_ut_delete_generic_state(control_state); } /* No while found? */ @@ -1162,23 +1141,23 @@ acpi_ds_exec_end_control_op ( /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */ - walk_state->aml_last_while = walk_state->control_state->control.package_end; + walk_state->aml_last_while = + walk_state->control_state->control.package_end; /* Return status depending on opcode */ if (op->common.aml_opcode == AML_BREAK_OP) { status = AE_CTRL_BREAK; - } - else { + } else { status = AE_CTRL_CONTINUE; } break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n", - op->common.aml_opcode, op)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown control opcode=%X Op=%p\n", + op->common.aml_opcode, op)); status = AE_AML_BAD_OPCODE; break; @@ -1186,4 +1165,3 @@ acpi_ds_exec_end_control_op ( return (status); } - diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c index 9613349..83ae1c1 100644 --- a/drivers/acpi/dispatcher/dsutils.c +++ b/drivers/acpi/dispatcher/dsutils.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -51,8 +50,7 @@ #include #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dsutils") - +ACPI_MODULE_NAME("dsutils") /******************************************************************************* * @@ -68,13 +66,9 @@ * parent method exits.) * ******************************************************************************/ - -void -acpi_ds_clear_implicit_return ( - struct acpi_walk_state *walk_state) +void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state) { - ACPI_FUNCTION_NAME ("ds_clear_implicit_return"); - + ACPI_FUNCTION_NAME("ds_clear_implicit_return"); /* * Slack must be enabled for this feature @@ -89,16 +83,15 @@ acpi_ds_clear_implicit_return ( * complex statements, the implicit return value can be * bubbled up several levels. */ - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Removing reference on stale implicit return obj %p\n", - walk_state->implicit_return_obj)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Removing reference on stale implicit return obj %p\n", + walk_state->implicit_return_obj)); - acpi_ut_remove_reference (walk_state->implicit_return_obj); + acpi_ut_remove_reference(walk_state->implicit_return_obj); walk_state->implicit_return_obj = NULL; } } - #ifndef ACPI_NO_METHOD_EXECUTION /******************************************************************************* * @@ -119,27 +112,22 @@ acpi_ds_clear_implicit_return ( ******************************************************************************/ u8 -acpi_ds_do_implicit_return ( - union acpi_operand_object *return_desc, - struct acpi_walk_state *walk_state, - u8 add_reference) +acpi_ds_do_implicit_return(union acpi_operand_object *return_desc, + struct acpi_walk_state *walk_state, u8 add_reference) { - ACPI_FUNCTION_NAME ("ds_do_implicit_return"); - + ACPI_FUNCTION_NAME("ds_do_implicit_return"); /* * Slack must be enabled for this feature, and we must * have a valid return object */ - if ((!acpi_gbl_enable_interpreter_slack) || - (!return_desc)) { + if ((!acpi_gbl_enable_interpreter_slack) || (!return_desc)) { return (FALSE); } - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Result %p will be implicitly returned; Prev=%p\n", - return_desc, - walk_state->implicit_return_obj)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Result %p will be implicitly returned; Prev=%p\n", + return_desc, walk_state->implicit_return_obj)); /* * Delete any "stale" implicit return value first. However, in @@ -151,20 +139,19 @@ acpi_ds_do_implicit_return ( if (walk_state->implicit_return_obj == return_desc) { return (TRUE); } - acpi_ds_clear_implicit_return (walk_state); + acpi_ds_clear_implicit_return(walk_state); } /* Save the implicit return value, add a reference if requested */ walk_state->implicit_return_obj = return_desc; if (add_reference) { - acpi_ut_add_reference (return_desc); + acpi_ut_add_reference(return_desc); } return (TRUE); } - /******************************************************************************* * * FUNCTION: acpi_ds_is_result_used @@ -179,20 +166,18 @@ acpi_ds_do_implicit_return ( ******************************************************************************/ u8 -acpi_ds_is_result_used ( - union acpi_parse_object *op, - struct acpi_walk_state *walk_state) +acpi_ds_is_result_used(union acpi_parse_object * op, + struct acpi_walk_state * walk_state) { - const struct acpi_opcode_info *parent_info; - - ACPI_FUNCTION_TRACE_PTR ("ds_is_result_used", op); + const struct acpi_opcode_info *parent_info; + ACPI_FUNCTION_TRACE_PTR("ds_is_result_used", op); /* Must have both an Op and a Result Object */ if (!op) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n")); - return_VALUE (TRUE); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n")); + return_VALUE(TRUE); } /* @@ -204,7 +189,8 @@ acpi_ds_is_result_used ( * NOTE: this is optional because the ASL language does not actually * support this behavior. */ - (void) acpi_ds_do_implicit_return (walk_state->result_obj, walk_state, TRUE); + (void)acpi_ds_do_implicit_return(walk_state->result_obj, walk_state, + TRUE); /* * Now determine if the parent will use the result @@ -215,22 +201,24 @@ acpi_ds_is_result_used ( * via execute_control_method has a scope_op as the parent. */ if ((!op->common.parent) || - (op->common.parent->common.aml_opcode == AML_SCOPE_OP)) { + (op->common.parent->common.aml_opcode == AML_SCOPE_OP)) { /* No parent, the return value cannot possibly be used */ - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "At Method level, result of [%s] not used\n", - acpi_ps_get_opcode_name (op->common.aml_opcode))); - return_VALUE (FALSE); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "At Method level, result of [%s] not used\n", + acpi_ps_get_opcode_name(op->common. + aml_opcode))); + return_VALUE(FALSE); } /* Get info on the parent. The root_op is AML_SCOPE */ - parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode); + parent_info = + acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode); if (parent_info->class == AML_CLASS_UNKNOWN) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown parent opcode. Op=%p\n", op)); - return_VALUE (FALSE); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown parent opcode. Op=%p\n", op)); + return_VALUE(FALSE); } /* @@ -256,8 +244,10 @@ acpi_ds_is_result_used ( * If we are executing the predicate AND this is the predicate op, * we will use the return value */ - if ((walk_state->control_state->common.state == ACPI_CONTROL_PREDICATE_EXECUTING) && - (walk_state->control_state->control.predicate_op == op)) { + if ((walk_state->control_state->common.state == + ACPI_CONTROL_PREDICATE_EXECUTING) + && (walk_state->control_state->control. + predicate_op == op)) { goto result_used; } break; @@ -271,7 +261,6 @@ acpi_ds_is_result_used ( goto result_not_used; - case AML_CLASS_CREATE: /* @@ -280,15 +269,16 @@ acpi_ds_is_result_used ( */ goto result_used; - case AML_CLASS_NAMED_OBJECT: - if ((op->common.parent->common.aml_opcode == AML_REGION_OP) || - (op->common.parent->common.aml_opcode == AML_DATA_REGION_OP) || - (op->common.parent->common.aml_opcode == AML_PACKAGE_OP) || - (op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP) || - (op->common.parent->common.aml_opcode == AML_BUFFER_OP) || - (op->common.parent->common.aml_opcode == AML_INT_EVAL_SUBTREE_OP)) { + if ((op->common.parent->common.aml_opcode == AML_REGION_OP) || + (op->common.parent->common.aml_opcode == AML_DATA_REGION_OP) + || (op->common.parent->common.aml_opcode == AML_PACKAGE_OP) + || (op->common.parent->common.aml_opcode == + AML_VAR_PACKAGE_OP) + || (op->common.parent->common.aml_opcode == AML_BUFFER_OP) + || (op->common.parent->common.aml_opcode == + AML_INT_EVAL_SUBTREE_OP)) { /* * These opcodes allow term_arg(s) as operands and therefore * the operands can be method calls. The result is used. @@ -298,7 +288,6 @@ acpi_ds_is_result_used ( goto result_not_used; - default: /* @@ -308,26 +297,25 @@ acpi_ds_is_result_used ( goto result_used; } + result_used: + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Result of [%s] used by Parent [%s] Op=%p\n", + acpi_ps_get_opcode_name(op->common.aml_opcode), + acpi_ps_get_opcode_name(op->common.parent->common. + aml_opcode), op)); -result_used: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Result of [%s] used by Parent [%s] Op=%p\n", - acpi_ps_get_opcode_name (op->common.aml_opcode), - acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op)); - - return_VALUE (TRUE); - + return_VALUE(TRUE); -result_not_used: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Result of [%s] not used by Parent [%s] Op=%p\n", - acpi_ps_get_opcode_name (op->common.aml_opcode), - acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op)); + result_not_used: + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Result of [%s] not used by Parent [%s] Op=%p\n", + acpi_ps_get_opcode_name(op->common.aml_opcode), + acpi_ps_get_opcode_name(op->common.parent->common. + aml_opcode), op)); - return_VALUE (FALSE); + return_VALUE(FALSE); } - /******************************************************************************* * * FUNCTION: acpi_ds_delete_result_if_not_used @@ -346,20 +334,17 @@ result_not_used: ******************************************************************************/ void -acpi_ds_delete_result_if_not_used ( - union acpi_parse_object *op, - union acpi_operand_object *result_obj, - struct acpi_walk_state *walk_state) +acpi_ds_delete_result_if_not_used(union acpi_parse_object *op, + union acpi_operand_object *result_obj, + struct acpi_walk_state *walk_state) { - union acpi_operand_object *obj_desc; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ds_delete_result_if_not_used", result_obj); + union acpi_operand_object *obj_desc; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ds_delete_result_if_not_used", result_obj); if (!op) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n")); return_VOID; } @@ -367,19 +352,18 @@ acpi_ds_delete_result_if_not_used ( return_VOID; } - if (!acpi_ds_is_result_used (op, walk_state)) { + if (!acpi_ds_is_result_used(op, walk_state)) { /* Must pop the result stack (obj_desc should be equal to result_obj) */ - status = acpi_ds_result_pop (&obj_desc, walk_state); - if (ACPI_SUCCESS (status)) { - acpi_ut_remove_reference (result_obj); + status = acpi_ds_result_pop(&obj_desc, walk_state); + if (ACPI_SUCCESS(status)) { + acpi_ut_remove_reference(result_obj); } } return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ds_resolve_operands @@ -394,16 +378,12 @@ acpi_ds_delete_result_if_not_used ( * ******************************************************************************/ -acpi_status -acpi_ds_resolve_operands ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state) { - u32 i; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_PTR ("ds_resolve_operands", walk_state); + u32 i; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE_PTR("ds_resolve_operands", walk_state); /* * Attempt to resolve each of the valid operands @@ -411,16 +391,17 @@ acpi_ds_resolve_operands ( * that the actual objects are passed, not copies of the objects. */ for (i = 0; i < walk_state->num_operands; i++) { - status = acpi_ex_resolve_to_value (&walk_state->operands[i], walk_state); - if (ACPI_FAILURE (status)) { + status = + acpi_ex_resolve_to_value(&walk_state->operands[i], + walk_state); + if (ACPI_FAILURE(status)) { break; } } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_clear_operands @@ -433,15 +414,11 @@ acpi_ds_resolve_operands ( * ******************************************************************************/ -void -acpi_ds_clear_operands ( - struct acpi_walk_state *walk_state) +void acpi_ds_clear_operands(struct acpi_walk_state *walk_state) { - u32 i; - - - ACPI_FUNCTION_TRACE_PTR ("ds_clear_operands", walk_state); + u32 i; + ACPI_FUNCTION_TRACE_PTR("ds_clear_operands", walk_state); /* Remove a reference on each operand on the stack */ @@ -450,7 +427,7 @@ acpi_ds_clear_operands ( * Remove a reference to all operands, including both * "Arguments" and "Targets". */ - acpi_ut_remove_reference (walk_state->operands[i]); + acpi_ut_remove_reference(walk_state->operands[i]); walk_state->operands[i] = NULL; } @@ -459,7 +436,6 @@ acpi_ds_clear_operands ( } #endif - /******************************************************************************* * * FUNCTION: acpi_ds_create_operand @@ -478,37 +454,36 @@ acpi_ds_clear_operands ( ******************************************************************************/ acpi_status -acpi_ds_create_operand ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *arg, - u32 arg_index) +acpi_ds_create_operand(struct acpi_walk_state *walk_state, + union acpi_parse_object *arg, u32 arg_index) { - acpi_status status = AE_OK; - char *name_string; - u32 name_length; - union acpi_operand_object *obj_desc; - union acpi_parse_object *parent_op; - u16 opcode; - acpi_interpreter_mode interpreter_mode; - const struct acpi_opcode_info *op_info; - - - ACPI_FUNCTION_TRACE_PTR ("ds_create_operand", arg); + acpi_status status = AE_OK; + char *name_string; + u32 name_length; + union acpi_operand_object *obj_desc; + union acpi_parse_object *parent_op; + u16 opcode; + acpi_interpreter_mode interpreter_mode; + const struct acpi_opcode_info *op_info; + ACPI_FUNCTION_TRACE_PTR("ds_create_operand", arg); /* A valid name must be looked up in the namespace */ if ((arg->common.aml_opcode == AML_INT_NAMEPATH_OP) && - (arg->common.value.string)) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", arg)); + (arg->common.value.string)) { + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", + arg)); /* Get the entire name string from the AML stream */ - status = acpi_ex_get_name_string (ACPI_TYPE_ANY, arg->common.value.buffer, - &name_string, &name_length); + status = + acpi_ex_get_name_string(ACPI_TYPE_ANY, + arg->common.value.buffer, + &name_string, &name_length); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* All prefixes have been handled, and the name is in name_string */ @@ -523,13 +498,14 @@ acpi_ds_create_operand ( * actual opcode exists. */ if ((walk_state->deferred_node) && - (walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD) && - (arg_index != 0)) { - obj_desc = ACPI_CAST_PTR ( - union acpi_operand_object, walk_state->deferred_node); + (walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD) + && (arg_index != 0)) { + obj_desc = + ACPI_CAST_PTR(union acpi_operand_object, + walk_state->deferred_node); status = AE_OK; - } - else /* All other opcodes */ { + } else { /* All other opcodes */ + /* * Differentiate between a namespace "create" operation * versus a "lookup" operation (IMODE_LOAD_PASS2 vs. @@ -537,43 +513,51 @@ acpi_ds_create_operand ( * namespace objects during the execution of control methods. */ parent_op = arg->common.parent; - op_info = acpi_ps_get_opcode_info (parent_op->common.aml_opcode); - if ((op_info->flags & AML_NSNODE) && - (parent_op->common.aml_opcode != AML_INT_METHODCALL_OP) && - (parent_op->common.aml_opcode != AML_REGION_OP) && - (parent_op->common.aml_opcode != AML_INT_NAMEPATH_OP)) { + op_info = + acpi_ps_get_opcode_info(parent_op->common. + aml_opcode); + if ((op_info->flags & AML_NSNODE) + && (parent_op->common.aml_opcode != + AML_INT_METHODCALL_OP) + && (parent_op->common.aml_opcode != AML_REGION_OP) + && (parent_op->common.aml_opcode != + AML_INT_NAMEPATH_OP)) { /* Enter name into namespace if not found */ interpreter_mode = ACPI_IMODE_LOAD_PASS2; - } - else { + } else { /* Return a failure if name not found */ interpreter_mode = ACPI_IMODE_EXECUTE; } - status = acpi_ns_lookup (walk_state->scope_info, name_string, - ACPI_TYPE_ANY, interpreter_mode, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - walk_state, - ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &obj_desc)); + status = + acpi_ns_lookup(walk_state->scope_info, name_string, + ACPI_TYPE_ANY, interpreter_mode, + ACPI_NS_SEARCH_PARENT | + ACPI_NS_DONT_OPEN_SCOPE, walk_state, + ACPI_CAST_INDIRECT_PTR(struct + acpi_namespace_node, + &obj_desc)); /* * The only case where we pass through (ignore) a NOT_FOUND * error is for the cond_ref_of opcode. */ if (status == AE_NOT_FOUND) { - if (parent_op->common.aml_opcode == AML_COND_REF_OF_OP) { + if (parent_op->common.aml_opcode == + AML_COND_REF_OF_OP) { /* * For the Conditional Reference op, it's OK if * the name is not found; We just need a way to * indicate this to the interpreter, set the * object to the root */ - obj_desc = ACPI_CAST_PTR ( - union acpi_operand_object, acpi_gbl_root_node); + obj_desc = + ACPI_CAST_PTR(union + acpi_operand_object, + acpi_gbl_root_node); status = AE_OK; - } - else { + } else { /* * We just plain didn't find it -- which is a * very serious error at this point @@ -582,30 +566,30 @@ acpi_ds_create_operand ( } } - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR (name_string, status); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR(name_string, status); } } /* Free the namestring created above */ - ACPI_MEM_FREE (name_string); + ACPI_MEM_FREE(name_string); /* Check status from the lookup */ - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Put the resulting object onto the current object stack */ - status = acpi_ds_obj_stack_push (obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_obj_stack_push(obj_desc, walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state)); - } - else { + ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object + (obj_desc, walk_state)); + } else { /* Check for null name case */ if (arg->common.aml_opcode == AML_INT_NAMEPATH_OP) { @@ -615,77 +599,83 @@ acpi_ds_create_operand ( * in the original ASL. Create a Zero Constant for a * placeholder. (Store to a constant is a Noop.) */ - opcode = AML_ZERO_OP; /* Has no arguments! */ + opcode = AML_ZERO_OP; /* Has no arguments! */ - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Null namepath: Arg=%p\n", arg)); - } - else { + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Null namepath: Arg=%p\n", arg)); + } else { opcode = arg->common.aml_opcode; } /* Get the object type of the argument */ - op_info = acpi_ps_get_opcode_info (opcode); + op_info = acpi_ps_get_opcode_info(opcode); if (op_info->object_type == ACPI_TYPE_INVALID) { - return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + return_ACPI_STATUS(AE_NOT_IMPLEMENTED); } if (op_info->flags & AML_HAS_RETVAL) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Argument previously created, already stacked \n")); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Argument previously created, already stacked \n")); - ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object ( - walk_state->operands [walk_state->num_operands - 1], walk_state)); + ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object + (walk_state-> + operands[walk_state->num_operands - + 1], walk_state)); /* * Use value that was already previously returned * by the evaluation of this argument */ - status = acpi_ds_result_pop_from_bottom (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { + status = + acpi_ds_result_pop_from_bottom(&obj_desc, + walk_state); + if (ACPI_FAILURE(status)) { /* * Only error is underflow, and this indicates * a missing or null operand! */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Missing or null operand, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Missing or null operand, %s\n", + acpi_format_exception + (status))); + return_ACPI_STATUS(status); } - } - else { + } else { /* Create an ACPI_INTERNAL_OBJECT for the argument */ - obj_desc = acpi_ut_create_internal_object (op_info->object_type); + obj_desc = + acpi_ut_create_internal_object(op_info-> + object_type); if (!obj_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Initialize the new object */ - status = acpi_ds_init_object_from_op ( - walk_state, arg, opcode, &obj_desc); - if (ACPI_FAILURE (status)) { - acpi_ut_delete_object_desc (obj_desc); - return_ACPI_STATUS (status); + status = + acpi_ds_init_object_from_op(walk_state, arg, opcode, + &obj_desc); + if (ACPI_FAILURE(status)) { + acpi_ut_delete_object_desc(obj_desc); + return_ACPI_STATUS(status); } } /* Put the operand object on the object stack */ - status = acpi_ds_obj_stack_push (obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_obj_stack_push(obj_desc, walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state)); + ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object + (obj_desc, walk_state)); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_create_operands @@ -702,29 +692,27 @@ acpi_ds_create_operand ( ******************************************************************************/ acpi_status -acpi_ds_create_operands ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *first_arg) +acpi_ds_create_operands(struct acpi_walk_state *walk_state, + union acpi_parse_object *first_arg) { - acpi_status status = AE_OK; - union acpi_parse_object *arg; - u32 arg_count = 0; - - - ACPI_FUNCTION_TRACE_PTR ("ds_create_operands", first_arg); + acpi_status status = AE_OK; + union acpi_parse_object *arg; + u32 arg_count = 0; + ACPI_FUNCTION_TRACE_PTR("ds_create_operands", first_arg); /* For all arguments in the list... */ arg = first_arg; while (arg) { - status = acpi_ds_create_operand (walk_state, arg, arg_count); - if (ACPI_FAILURE (status)) { + status = acpi_ds_create_operand(walk_state, arg, arg_count); + if (ACPI_FAILURE(status)) { goto cleanup; } - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n", - arg_count, arg, first_arg)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Arg #%d (%p) done, Arg1=%p\n", arg_count, + arg, first_arg)); /* Move on to next argument, if any */ @@ -732,20 +720,17 @@ acpi_ds_create_operands ( arg_count++; } - return_ACPI_STATUS (status); - + return_ACPI_STATUS(status); -cleanup: + cleanup: /* * We must undo everything done above; meaning that we must * pop everything off of the operand stack and delete those * objects */ - (void) acpi_ds_obj_stack_pop_and_delete (arg_count, walk_state); + (void)acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state); - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While creating Arg %d - %s\n", - (arg_count + 1), acpi_format_exception (status))); - return_ACPI_STATUS (status); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "While creating Arg %d - %s\n", + (arg_count + 1), acpi_format_exception(status))); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c index 10f7131..e522763 100644 --- a/drivers/acpi/dispatcher/dswexec.c +++ b/drivers/acpi/dispatcher/dswexec.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -52,27 +51,26 @@ #include #include - #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dswexec") +ACPI_MODULE_NAME("dswexec") /* * Dispatch table for opcode classes */ -static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch [] = { - acpi_ex_opcode_0A_0T_1R, - acpi_ex_opcode_1A_0T_0R, - acpi_ex_opcode_1A_0T_1R, - acpi_ex_opcode_1A_1T_0R, - acpi_ex_opcode_1A_1T_1R, - acpi_ex_opcode_2A_0T_0R, - acpi_ex_opcode_2A_0T_1R, - acpi_ex_opcode_2A_1T_1R, - acpi_ex_opcode_2A_2T_1R, - acpi_ex_opcode_3A_0T_0R, - acpi_ex_opcode_3A_1T_1R, - acpi_ex_opcode_6A_0T_1R}; - +static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch[] = { + acpi_ex_opcode_0A_0T_1R, + acpi_ex_opcode_1A_0T_0R, + acpi_ex_opcode_1A_0T_1R, + acpi_ex_opcode_1A_1T_0R, + acpi_ex_opcode_1A_1T_1R, + acpi_ex_opcode_2A_0T_0R, + acpi_ex_opcode_2A_0T_1R, + acpi_ex_opcode_2A_1T_1R, + acpi_ex_opcode_2A_2T_1R, + acpi_ex_opcode_3A_0T_0R, + acpi_ex_opcode_3A_1T_1R, + acpi_ex_opcode_6A_0T_1R +}; /***************************************************************************** * @@ -88,64 +86,64 @@ static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch [] = { ****************************************************************************/ acpi_status -acpi_ds_get_predicate_value ( - struct acpi_walk_state *walk_state, - union acpi_operand_object *result_obj) { - acpi_status status = AE_OK; - union acpi_operand_object *obj_desc; - union acpi_operand_object *local_obj_desc = NULL; - - - ACPI_FUNCTION_TRACE_PTR ("ds_get_predicate_value", walk_state); +acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state, + union acpi_operand_object *result_obj) +{ + acpi_status status = AE_OK; + union acpi_operand_object *obj_desc; + union acpi_operand_object *local_obj_desc = NULL; + ACPI_FUNCTION_TRACE_PTR("ds_get_predicate_value", walk_state); walk_state->control_state->common.state = 0; if (result_obj) { - status = acpi_ds_result_pop (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not get result from predicate evaluation, %s\n", - acpi_format_exception (status))); + status = acpi_ds_result_pop(&obj_desc, walk_state); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not get result from predicate evaluation, %s\n", + acpi_format_exception(status))); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - } - else { - status = acpi_ds_create_operand (walk_state, walk_state->op, 0); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + } else { + status = acpi_ds_create_operand(walk_state, walk_state->op, 0); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_ex_resolve_to_value (&walk_state->operands [0], walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ex_resolve_to_value(&walk_state->operands[0], + walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - obj_desc = walk_state->operands [0]; + obj_desc = walk_state->operands[0]; } if (!obj_desc) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "No predicate obj_desc=%p State=%p\n", - obj_desc, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No predicate obj_desc=%p State=%p\n", + obj_desc, walk_state)); - return_ACPI_STATUS (AE_AML_NO_OPERAND); + return_ACPI_STATUS(AE_AML_NO_OPERAND); } /* * Result of predicate evaluation must be an Integer * object. Implicitly convert the argument if necessary. */ - status = acpi_ex_convert_to_integer (obj_desc, &local_obj_desc, 16); - if (ACPI_FAILURE (status)) { + status = acpi_ex_convert_to_integer(obj_desc, &local_obj_desc, 16); + if (ACPI_FAILURE(status)) { goto cleanup; } - if (ACPI_GET_OBJECT_TYPE (local_obj_desc) != ACPI_TYPE_INTEGER) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n", - obj_desc, walk_state, ACPI_GET_OBJECT_TYPE (obj_desc))); + if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n", + obj_desc, walk_state, + ACPI_GET_OBJECT_TYPE(obj_desc))); status = AE_AML_OPERAND_TYPE; goto cleanup; @@ -153,7 +151,7 @@ acpi_ds_get_predicate_value ( /* Truncate the predicate to 32-bits if necessary */ - acpi_ex_truncate_for32bit_table (local_obj_desc); + acpi_ex_truncate_for32bit_table(local_obj_desc); /* * Save the result of the predicate evaluation on @@ -161,8 +159,7 @@ acpi_ds_get_predicate_value ( */ if (local_obj_desc->integer.value) { walk_state->control_state->common.value = TRUE; - } - else { + } else { /* * Predicate is FALSE, we will just toss the * rest of the package @@ -171,30 +168,30 @@ acpi_ds_get_predicate_value ( status = AE_CTRL_FALSE; } + cleanup: -cleanup: + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n", + walk_state->control_state->common.value, + walk_state->op)); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n", - walk_state->control_state->common.value, walk_state->op)); + /* Break to debugger to display result */ - /* Break to debugger to display result */ - - ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (local_obj_desc, walk_state)); + ACPI_DEBUGGER_EXEC(acpi_db_display_result_object + (local_obj_desc, walk_state)); /* * Delete the predicate result object (we know that * we don't need it anymore) */ if (local_obj_desc != obj_desc) { - acpi_ut_remove_reference (local_obj_desc); + acpi_ut_remove_reference(local_obj_desc); } - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); walk_state->control_state->common.state = ACPI_CONTROL_NORMAL; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /***************************************************************************** * * FUNCTION: acpi_ds_exec_begin_op @@ -211,38 +208,39 @@ cleanup: ****************************************************************************/ acpi_status -acpi_ds_exec_begin_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object **out_op) +acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state, + union acpi_parse_object **out_op) { - union acpi_parse_object *op; - acpi_status status = AE_OK; - u32 opcode_class; - - - ACPI_FUNCTION_TRACE_PTR ("ds_exec_begin_op", walk_state); + union acpi_parse_object *op; + acpi_status status = AE_OK; + u32 opcode_class; + ACPI_FUNCTION_TRACE_PTR("ds_exec_begin_op", walk_state); op = walk_state->op; if (!op) { - status = acpi_ds_load2_begin_op (walk_state, out_op); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_load2_begin_op(walk_state, out_op); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } op = *out_op; walk_state->op = op; walk_state->opcode = op->common.aml_opcode; - walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); - - if (acpi_ns_opens_scope (walk_state->op_info->object_type)) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "(%s) Popping scope for Op %p\n", - acpi_ut_get_type_name (walk_state->op_info->object_type), op)); - - status = acpi_ds_scope_stack_pop (walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + walk_state->op_info = + acpi_ps_get_opcode_info(op->common.aml_opcode); + + if (acpi_ns_opens_scope(walk_state->op_info->object_type)) { + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "(%s) Popping scope for Op %p\n", + acpi_ut_get_type_name(walk_state-> + op_info-> + object_type), + op)); + + status = acpi_ds_scope_stack_pop(walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } } @@ -252,7 +250,7 @@ acpi_ds_exec_begin_op ( *out_op = op; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* @@ -261,19 +259,20 @@ acpi_ds_exec_begin_op ( * Save this knowledge in the current scope descriptor */ if ((walk_state->control_state) && - (walk_state->control_state->common.state == - ACPI_CONTROL_CONDITIONAL_EXECUTING)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n", - op, walk_state)); + (walk_state->control_state->common.state == + ACPI_CONTROL_CONDITIONAL_EXECUTING)) { + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Exec predicate Op=%p State=%p\n", op, + walk_state)); - walk_state->control_state->common.state = ACPI_CONTROL_PREDICATE_EXECUTING; + walk_state->control_state->common.state = + ACPI_CONTROL_PREDICATE_EXECUTING; /* Save start of predicate */ walk_state->control_state->control.predicate_op = op; } - opcode_class = walk_state->op_info->class; /* We want to send namepaths to the load code */ @@ -288,15 +287,14 @@ acpi_ds_exec_begin_op ( switch (opcode_class) { case AML_CLASS_CONTROL: - status = acpi_ds_result_stack_push (walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_result_stack_push(walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_ds_exec_begin_control_op (walk_state, op); + status = acpi_ds_exec_begin_control_op(walk_state, op); break; - case AML_CLASS_NAMED_OBJECT: if (walk_state->walk_type == ACPI_WALK_METHOD) { @@ -306,15 +304,14 @@ acpi_ds_exec_begin_op ( * object is temporary and will be deleted upon completion of * the execution of this method. */ - status = acpi_ds_load2_begin_op (walk_state, NULL); + status = acpi_ds_load2_begin_op(walk_state, NULL); } if (op->common.aml_opcode == AML_REGION_OP) { - status = acpi_ds_result_stack_push (walk_state); + status = acpi_ds_result_stack_push(walk_state); } break; - case AML_CLASS_EXECUTE: case AML_CLASS_CREATE: @@ -322,20 +319,18 @@ acpi_ds_exec_begin_op ( * Most operators with arguments. * Start a new result/operand state */ - status = acpi_ds_result_stack_push (walk_state); + status = acpi_ds_result_stack_push(walk_state); break; - default: break; } /* Nothing to do here during method execution */ - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /***************************************************************************** * * FUNCTION: acpi_ds_exec_end_op @@ -350,28 +345,25 @@ acpi_ds_exec_begin_op ( * ****************************************************************************/ -acpi_status -acpi_ds_exec_end_op ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) { - union acpi_parse_object *op; - acpi_status status = AE_OK; - u32 op_type; - u32 op_class; - union acpi_parse_object *next_op; - union acpi_parse_object *first_arg; + union acpi_parse_object *op; + acpi_status status = AE_OK; + u32 op_type; + u32 op_class; + union acpi_parse_object *next_op; + union acpi_parse_object *first_arg; + ACPI_FUNCTION_TRACE_PTR("ds_exec_end_op", walk_state); - ACPI_FUNCTION_TRACE_PTR ("ds_exec_end_op", walk_state); - - - op = walk_state->op; + op = walk_state->op; op_type = walk_state->op_info->type; op_class = walk_state->op_info->class; if (op_class == AML_CLASS_UNKNOWN) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", op->common.aml_opcode)); - return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown opcode %X\n", + op->common.aml_opcode)); + return_ACPI_STATUS(AE_NOT_IMPLEMENTED); } first_arg = op->common.value.arg; @@ -384,29 +376,31 @@ acpi_ds_exec_end_op ( /* Call debugger for single step support (DEBUG build only) */ - ACPI_DEBUGGER_EXEC (status = acpi_db_single_step (walk_state, op, op_class)); - ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (status)) {return_ACPI_STATUS (status);}); + ACPI_DEBUGGER_EXEC(status = + acpi_db_single_step(walk_state, op, op_class)); + ACPI_DEBUGGER_EXEC(if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status);} + ) ; /* Decode the Opcode Class */ switch (op_class) { - case AML_CLASS_ARGUMENT: /* constants, literals, etc. - do nothing */ + case AML_CLASS_ARGUMENT: /* constants, literals, etc. - do nothing */ break; - - case AML_CLASS_EXECUTE: /* most operators with arguments */ + case AML_CLASS_EXECUTE: /* most operators with arguments */ /* Build resolved operand stack */ - status = acpi_ds_create_operands (walk_state, first_arg); - if (ACPI_FAILURE (status)) { + status = acpi_ds_create_operands(walk_state, first_arg); + if (ACPI_FAILURE(status)) { goto cleanup; } /* Done with this result state (Now that operand stack is built) */ - status = acpi_ds_result_stack_pop (walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ds_result_stack_pop(walk_state); + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -417,86 +411,93 @@ acpi_ds_exec_end_op ( if (!(walk_state->op_info->flags & AML_NO_OPERAND_RESOLVE)) { /* Resolve all operands */ - status = acpi_ex_resolve_operands (walk_state->opcode, - &(walk_state->operands [walk_state->num_operands -1]), - walk_state); - if (ACPI_SUCCESS (status)) { - ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, - acpi_ps_get_opcode_name (walk_state->opcode), - walk_state->num_operands, "after ex_resolve_operands"); + status = acpi_ex_resolve_operands(walk_state->opcode, + &(walk_state-> + operands + [walk_state-> + num_operands - 1]), + walk_state); + if (ACPI_SUCCESS(status)) { + ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, + ACPI_IMODE_EXECUTE, + acpi_ps_get_opcode_name + (walk_state->opcode), + walk_state->num_operands, + "after ex_resolve_operands"); } } - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { /* * Dispatch the request to the appropriate interpreter handler * routine. There is one routine per opcode "type" based upon the * number of opcode arguments and return type. */ - status = acpi_gbl_op_type_dispatch[op_type] (walk_state); - } - else { + status = + acpi_gbl_op_type_dispatch[op_type] (walk_state); + } else { /* * Treat constructs of the form "Store(local_x,local_x)" as noops when the * Local is uninitialized. */ - if ((status == AE_AML_UNINITIALIZED_LOCAL) && - (walk_state->opcode == AML_STORE_OP) && - (walk_state->operands[0]->common.type == ACPI_TYPE_LOCAL_REFERENCE) && - (walk_state->operands[1]->common.type == ACPI_TYPE_LOCAL_REFERENCE) && - (walk_state->operands[0]->reference.opcode == - walk_state->operands[1]->reference.opcode) && - (walk_state->operands[0]->reference.offset == - walk_state->operands[1]->reference.offset)) { + if ((status == AE_AML_UNINITIALIZED_LOCAL) && + (walk_state->opcode == AML_STORE_OP) && + (walk_state->operands[0]->common.type == + ACPI_TYPE_LOCAL_REFERENCE) + && (walk_state->operands[1]->common.type == + ACPI_TYPE_LOCAL_REFERENCE) + && (walk_state->operands[0]->reference.opcode == + walk_state->operands[1]->reference.opcode) + && (walk_state->operands[0]->reference.offset == + walk_state->operands[1]->reference.offset)) { status = AE_OK; - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "[%s]: Could not resolve operands, %s\n", - acpi_ps_get_opcode_name (walk_state->opcode), - acpi_format_exception (status))); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "[%s]: Could not resolve operands, %s\n", + acpi_ps_get_opcode_name + (walk_state->opcode), + acpi_format_exception + (status))); } } /* Always delete the argument objects and clear the operand stack */ - acpi_ds_clear_operands (walk_state); + acpi_ds_clear_operands(walk_state); /* * If a result object was returned from above, push it on the * current result stack */ - if (ACPI_SUCCESS (status) && - walk_state->result_obj) { - status = acpi_ds_result_push (walk_state->result_obj, walk_state); + if (ACPI_SUCCESS(status) && walk_state->result_obj) { + status = + acpi_ds_result_push(walk_state->result_obj, + walk_state); } break; - default: switch (op_type) { - case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */ + case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */ /* 1 Operand, 0 external_result, 0 internal_result */ - status = acpi_ds_exec_end_control_op (walk_state, op); + status = acpi_ds_exec_end_control_op(walk_state, op); /* Make sure to properly pop the result stack */ - if (ACPI_SUCCESS (status)) { - status = acpi_ds_result_stack_pop (walk_state); - } - else if (status == AE_CTRL_PENDING) { - status = acpi_ds_result_stack_pop (walk_state); - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { + status = acpi_ds_result_stack_pop(walk_state); + } else if (status == AE_CTRL_PENDING) { + status = acpi_ds_result_stack_pop(walk_state); + if (ACPI_SUCCESS(status)) { status = AE_CTRL_PENDING; } } break; - case AML_TYPE_METHOD_CALL: /* @@ -505,16 +506,22 @@ acpi_ds_exec_end_op ( * a reference to it. */ if ((op->asl.parent) && - ((op->asl.parent->asl.aml_opcode == AML_PACKAGE_OP) || - (op->asl.parent->asl.aml_opcode == AML_VAR_PACKAGE_OP))) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Method Reference in a Package, Op=%p\n", op)); - op->common.node = (struct acpi_namespace_node *) op->asl.value.arg->asl.node->object; - acpi_ut_add_reference (op->asl.value.arg->asl.node->object); - return_ACPI_STATUS (AE_OK); + ((op->asl.parent->asl.aml_opcode == AML_PACKAGE_OP) + || (op->asl.parent->asl.aml_opcode == + AML_VAR_PACKAGE_OP))) { + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Method Reference in a Package, Op=%p\n", + op)); + op->common.node = + (struct acpi_namespace_node *)op->asl.value. + arg->asl.node->object; + acpi_ut_add_reference(op->asl.value.arg->asl. + node->object); + return_ACPI_STATUS(AE_OK); } - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", op)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Method invocation, Op=%p\n", op)); /* * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains @@ -531,8 +538,8 @@ acpi_ds_exec_end_op ( /* * Get the method's arguments and put them on the operand stack */ - status = acpi_ds_create_operands (walk_state, next_op); - if (ACPI_FAILURE (status)) { + status = acpi_ds_create_operands(walk_state, next_op); + if (ACPI_FAILURE(status)) { break; } @@ -541,11 +548,11 @@ acpi_ds_exec_end_op ( * we must resolve all local references here (Local variables, * arguments to *this* method, etc.) */ - status = acpi_ds_resolve_operands (walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ds_resolve_operands(walk_state); + if (ACPI_FAILURE(status)) { /* On error, clear all resolved operands */ - acpi_ds_clear_operands (walk_state); + acpi_ds_clear_operands(walk_state); break; } @@ -559,27 +566,28 @@ acpi_ds_exec_end_op ( * Return now; we don't want to disturb anything, * especially the operand count! */ - return_ACPI_STATUS (status); - + return_ACPI_STATUS(status); case AML_TYPE_CREATE_FIELD: - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Executing create_field Buffer/Index Op=%p\n", op)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Executing create_field Buffer/Index Op=%p\n", + op)); - status = acpi_ds_load2_end_op (walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ds_load2_end_op(walk_state); + if (ACPI_FAILURE(status)) { break; } - status = acpi_ds_eval_buffer_field_operands (walk_state, op); + status = + acpi_ds_eval_buffer_field_operands(walk_state, op); break; - case AML_TYPE_CREATE_OBJECT: - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Executing create_object (Buffer/Package) Op=%p\n", op)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Executing create_object (Buffer/Package) Op=%p\n", + op)); switch (op->common.parent->common.aml_opcode) { case AML_NAME_OP: @@ -588,13 +596,15 @@ acpi_ds_exec_end_op ( * Put the Node on the object stack (Contains the ACPI Name * of this object) */ - walk_state->operands[0] = (void *) op->common.parent->common.node; + walk_state->operands[0] = + (void *)op->common.parent->common.node; walk_state->num_operands = 1; - status = acpi_ds_create_node (walk_state, - op->common.parent->common.node, - op->common.parent); - if (ACPI_FAILURE (status)) { + status = acpi_ds_create_node(walk_state, + op->common.parent-> + common.node, + op->common.parent); + if (ACPI_FAILURE(status)) { break; } @@ -603,20 +613,26 @@ acpi_ds_exec_end_op ( case AML_INT_EVAL_SUBTREE_OP: - status = acpi_ds_eval_data_object_operands (walk_state, op, - acpi_ns_get_attached_object (op->common.parent->common.node)); + status = + acpi_ds_eval_data_object_operands + (walk_state, op, + acpi_ns_get_attached_object(op->common. + parent->common. + node)); break; default: - status = acpi_ds_eval_data_object_operands (walk_state, op, NULL); + status = + acpi_ds_eval_data_object_operands + (walk_state, op, NULL); break; } /* Done with result state (Now that operand stack is built) */ - status = acpi_ds_result_stack_pop (walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ds_result_stack_pop(walk_state); + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -625,56 +641,58 @@ acpi_ds_exec_end_op ( * current result stack */ if (walk_state->result_obj) { - status = acpi_ds_result_push (walk_state->result_obj, walk_state); + status = + acpi_ds_result_push(walk_state->result_obj, + walk_state); } break; - case AML_TYPE_NAMED_FIELD: case AML_TYPE_NAMED_COMPLEX: case AML_TYPE_NAMED_SIMPLE: case AML_TYPE_NAMED_NO_OBJ: - status = acpi_ds_load2_end_op (walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ds_load2_end_op(walk_state); + if (ACPI_FAILURE(status)) { break; } if (op->common.aml_opcode == AML_REGION_OP) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Executing op_region Address/Length Op=%p\n", op)); - - status = acpi_ds_eval_region_operands (walk_state, op); - if (ACPI_FAILURE (status)) { + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Executing op_region Address/Length Op=%p\n", + op)); + + status = + acpi_ds_eval_region_operands(walk_state, + op); + if (ACPI_FAILURE(status)) { break; } - status = acpi_ds_result_stack_pop (walk_state); + status = acpi_ds_result_stack_pop(walk_state); } break; - case AML_TYPE_UNDEFINED: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Undefined opcode type Op=%p\n", op)); - return_ACPI_STATUS (AE_NOT_IMPLEMENTED); - + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Undefined opcode type Op=%p\n", op)); + return_ACPI_STATUS(AE_NOT_IMPLEMENTED); case AML_TYPE_BOGUS: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Internal opcode=%X type Op=%p\n", - walk_state->opcode, op)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Internal opcode=%X type Op=%p\n", + walk_state->opcode, op)); break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n", - op_class, op_type, op->common.aml_opcode, op)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n", + op_class, op_type, + op->common.aml_opcode, op)); status = AE_NOT_IMPLEMENTED; break; @@ -685,55 +703,58 @@ acpi_ds_exec_end_op ( * ACPI 2.0 support for 64-bit integers: Truncate numeric * result value if we are executing from a 32-bit ACPI table */ - acpi_ex_truncate_for32bit_table (walk_state->result_obj); + acpi_ex_truncate_for32bit_table(walk_state->result_obj); /* * Check if we just completed the evaluation of a * conditional predicate */ - if ((ACPI_SUCCESS (status)) && - (walk_state->control_state) && - (walk_state->control_state->common.state == - ACPI_CONTROL_PREDICATE_EXECUTING) && - (walk_state->control_state->control.predicate_op == op)) { - status = acpi_ds_get_predicate_value (walk_state, walk_state->result_obj); + if ((ACPI_SUCCESS(status)) && + (walk_state->control_state) && + (walk_state->control_state->common.state == + ACPI_CONTROL_PREDICATE_EXECUTING) && + (walk_state->control_state->control.predicate_op == op)) { + status = + acpi_ds_get_predicate_value(walk_state, + walk_state->result_obj); walk_state->result_obj = NULL; } - -cleanup: + cleanup: /* Invoke exception handler on error */ - if (ACPI_FAILURE (status) && - acpi_gbl_exception_handler && - !(status & AE_CODE_CONTROL)) { - acpi_ex_exit_interpreter (); - status = acpi_gbl_exception_handler (status, - walk_state->method_node->name.integer, walk_state->opcode, - walk_state->aml_offset, NULL); - (void) acpi_ex_enter_interpreter (); + if (ACPI_FAILURE(status) && + acpi_gbl_exception_handler && !(status & AE_CODE_CONTROL)) { + acpi_ex_exit_interpreter(); + status = acpi_gbl_exception_handler(status, + walk_state->method_node-> + name.integer, + walk_state->opcode, + walk_state->aml_offset, + NULL); + (void)acpi_ex_enter_interpreter(); } if (walk_state->result_obj) { /* Break to debugger to display result */ - ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (walk_state->result_obj, - walk_state)); + ACPI_DEBUGGER_EXEC(acpi_db_display_result_object + (walk_state->result_obj, walk_state)); /* * Delete the result op if and only if: * Parent will not use the result -- such as any * non-nested type2 op in a method (parent will be method) */ - acpi_ds_delete_result_if_not_used (op, walk_state->result_obj, walk_state); + acpi_ds_delete_result_if_not_used(op, walk_state->result_obj, + walk_state); } - #ifdef _UNDER_DEVELOPMENT if (walk_state->parser_state.aml == walk_state->parser_state.aml_end) { - acpi_db_method_end (walk_state); + acpi_db_method_end(walk_state); } #endif @@ -745,12 +766,10 @@ cleanup: /* On error, display method locals/args */ - if (ACPI_FAILURE (status)) { - acpi_dm_dump_method_info (status, walk_state, op); + if (ACPI_FAILURE(status)) { + acpi_dm_dump_method_info(status, walk_state, op); } #endif - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c index 9100c0b..362bbcf 100644 --- a/drivers/acpi/dispatcher/dswload.c +++ b/drivers/acpi/dispatcher/dswload.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -55,8 +54,7 @@ #endif #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dswload") - +ACPI_MODULE_NAME("dswload") /******************************************************************************* * @@ -70,32 +68,29 @@ * DESCRIPTION: Init walk state callbacks * ******************************************************************************/ - acpi_status -acpi_ds_init_callbacks ( - struct acpi_walk_state *walk_state, - u32 pass_number) +acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number) { switch (pass_number) { case 1: - walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | - ACPI_PARSE_DELETE_TREE; + walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | + ACPI_PARSE_DELETE_TREE; walk_state->descending_callback = acpi_ds_load1_begin_op; walk_state->ascending_callback = acpi_ds_load1_end_op; break; case 2: - walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | - ACPI_PARSE_DELETE_TREE; + walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | + ACPI_PARSE_DELETE_TREE; walk_state->descending_callback = acpi_ds_load2_begin_op; walk_state->ascending_callback = acpi_ds_load2_end_op; break; case 3: #ifndef ACPI_NO_METHOD_EXECUTION - walk_state->parse_flags |= ACPI_PARSE_EXECUTE | - ACPI_PARSE_DELETE_TREE; + walk_state->parse_flags |= ACPI_PARSE_EXECUTE | + ACPI_PARSE_DELETE_TREE; walk_state->descending_callback = acpi_ds_exec_begin_op; walk_state->ascending_callback = acpi_ds_exec_end_op; #endif @@ -108,7 +103,6 @@ acpi_ds_init_callbacks ( return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_load1_begin_op @@ -123,23 +117,21 @@ acpi_ds_init_callbacks ( ******************************************************************************/ acpi_status -acpi_ds_load1_begin_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object **out_op) +acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, + union acpi_parse_object ** out_op) { - union acpi_parse_object *op; - struct acpi_namespace_node *node; - acpi_status status; - acpi_object_type object_type; - char *path; - u32 flags; - - - ACPI_FUNCTION_NAME ("ds_load1_begin_op"); + union acpi_parse_object *op; + struct acpi_namespace_node *node; + acpi_status status; + acpi_object_type object_type; + char *path; + u32 flags; + ACPI_FUNCTION_NAME("ds_load1_begin_op"); op = walk_state->op; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, + walk_state)); /* We are only interested in opcodes that have an associated name */ @@ -157,14 +149,15 @@ acpi_ds_load1_begin_op ( } } - path = acpi_ps_get_next_namestring (&walk_state->parser_state); + path = acpi_ps_get_next_namestring(&walk_state->parser_state); /* Map the raw opcode into an internal object type */ object_type = walk_state->op_info->object_type; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "State=%p Op=%p [%s]\n", walk_state, op, acpi_ut_get_type_name (object_type))); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "State=%p Op=%p [%s]\n", walk_state, op, + acpi_ut_get_type_name(object_type))); switch (walk_state->opcode) { case AML_SCOPE_OP: @@ -174,8 +167,10 @@ acpi_ds_load1_begin_op ( * that we can actually open the scope to enter new names underneath it. * Allow search-to-root for single namesegs. */ - status = acpi_ns_lookup (walk_state->scope_info, path, object_type, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); + status = + acpi_ns_lookup(walk_state->scope_info, path, object_type, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + walk_state, &(node)); #ifdef ACPI_ASL_COMPILER if (status == AE_NOT_FOUND) { /* @@ -183,14 +178,16 @@ acpi_ds_load1_begin_op ( * Target of Scope() not found. Generate an External for it, and * insert the name into the namespace. */ - acpi_dm_add_to_external_list (path); - status = acpi_ns_lookup (walk_state->scope_info, path, object_type, - ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, - walk_state, &(node)); + acpi_dm_add_to_external_list(path); + status = + acpi_ns_lookup(walk_state->scope_info, path, + object_type, ACPI_IMODE_LOAD_PASS1, + ACPI_NS_SEARCH_PARENT, walk_state, + &(node)); } #endif - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR (path, status); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR(path, status); return (status); } @@ -199,7 +196,7 @@ acpi_ds_load1_begin_op ( * one of the opcodes that actually opens a scope */ switch (node->type) { - case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ + case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ case ACPI_TYPE_DEVICE: case ACPI_TYPE_POWER: case ACPI_TYPE_PROCESSOR: @@ -223,9 +220,10 @@ acpi_ds_load1_begin_op ( * a warning */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", - path, acpi_ut_get_type_name (node->type))); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", + path, + acpi_ut_get_type_name(node->type))); node->type = ACPI_TYPE_ANY; walk_state->scope_info->common.value = ACPI_TYPE_ANY; @@ -235,15 +233,12 @@ acpi_ds_load1_begin_op ( /* All other types are an error */ - ACPI_REPORT_ERROR (( - "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", - acpi_ut_get_type_name (node->type), path)); + ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", acpi_ut_get_type_name(node->type), path)); return (AE_AML_OPERAND_TYPE); } break; - default: /* @@ -272,15 +267,15 @@ acpi_ds_load1_begin_op ( flags = ACPI_NS_NO_UPSEARCH; if ((walk_state->opcode != AML_SCOPE_OP) && - (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) { + (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) { flags |= ACPI_NS_ERROR_IF_FOUND; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", - acpi_ut_get_type_name (object_type))); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "[%s] Both Find or Create allowed\n", - acpi_ut_get_type_name (object_type))); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "[%s] Cannot already exist\n", + acpi_ut_get_type_name(object_type))); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "[%s] Both Find or Create allowed\n", + acpi_ut_get_type_name(object_type))); } /* @@ -289,22 +284,23 @@ acpi_ds_load1_begin_op ( * involve arguments to the opcode must be created as we go back up the * parse tree later. */ - status = acpi_ns_lookup (walk_state->scope_info, path, object_type, - ACPI_IMODE_LOAD_PASS1, flags, walk_state, &(node)); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR (path, status); + status = + acpi_ns_lookup(walk_state->scope_info, path, object_type, + ACPI_IMODE_LOAD_PASS1, flags, walk_state, + &(node)); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR(path, status); return (status); } break; } - /* Common exit */ if (!op) { /* Create a new op */ - op = acpi_ps_alloc_op (walk_state->opcode); + op = acpi_ps_alloc_op(walk_state->opcode); if (!op) { return (AE_NO_MEMORY); } @@ -318,19 +314,18 @@ acpi_ds_load1_begin_op ( op->named.path = (u8 *) path; #endif - /* * Put the Node in the "op" object that the parser uses, so we * can get it again quickly when this scope is closed */ op->common.node = node; - acpi_ps_append_arg (acpi_ps_get_parent_scope (&walk_state->parser_state), op); + acpi_ps_append_arg(acpi_ps_get_parent_scope(&walk_state->parser_state), + op); *out_op = op; return (status); } - /******************************************************************************* * * FUNCTION: acpi_ds_load1_end_op @@ -344,20 +339,17 @@ acpi_ds_load1_begin_op ( * ******************************************************************************/ -acpi_status -acpi_ds_load1_end_op ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state) { - union acpi_parse_object *op; - acpi_object_type object_type; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_NAME ("ds_load1_end_op"); + union acpi_parse_object *op; + acpi_object_type object_type; + acpi_status status = AE_OK; + ACPI_FUNCTION_NAME("ds_load1_end_op"); op = walk_state->op; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, + walk_state)); /* We are only interested in opcodes that have an associated name */ @@ -371,21 +363,20 @@ acpi_ds_load1_end_op ( #ifndef ACPI_NO_METHOD_EXECUTION if (walk_state->op_info->flags & AML_FIELD) { - if (walk_state->opcode == AML_FIELD_OP || - walk_state->opcode == AML_BANK_FIELD_OP || - walk_state->opcode == AML_INDEX_FIELD_OP) { - status = acpi_ds_init_field_objects (op, walk_state); + if (walk_state->opcode == AML_FIELD_OP || + walk_state->opcode == AML_BANK_FIELD_OP || + walk_state->opcode == AML_INDEX_FIELD_OP) { + status = acpi_ds_init_field_objects(op, walk_state); } return (status); } - if (op->common.aml_opcode == AML_REGION_OP) { - status = acpi_ex_create_region (op->named.data, op->named.length, - (acpi_adr_space_type) - ((op->common.value.arg)->common.value.integer), - walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ex_create_region(op->named.data, op->named.length, + (acpi_adr_space_type) + ((op->common.value.arg)->common. + value.integer), walk_state); + if (ACPI_FAILURE(status)) { return (status); } } @@ -395,8 +386,11 @@ acpi_ds_load1_end_op ( /* For Name opcode, get the object type from the argument */ if (op->common.value.arg) { - object_type = (acpi_ps_get_opcode_info ( - (op->common.value.arg)->common.aml_opcode))->object_type; + object_type = (acpi_ps_get_opcode_info((op->common. + value.arg)-> + common. + aml_opcode))-> + object_type; op->common.node->type = (u8) object_type; } } @@ -410,23 +404,26 @@ acpi_ds_load1_end_op ( * of invocations of the method (need to know the number of * arguments.) */ - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "LOADING-Method: State=%p Op=%p named_obj=%p\n", - walk_state, op, op->named.node)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "LOADING-Method: State=%p Op=%p named_obj=%p\n", + walk_state, op, op->named.node)); - if (!acpi_ns_get_attached_object (op->named.node)) { - walk_state->operands[0] = (void *) op->named.node; + if (!acpi_ns_get_attached_object(op->named.node)) { + walk_state->operands[0] = (void *)op->named.node; walk_state->num_operands = 1; - status = acpi_ds_create_operands (walk_state, op->common.value.arg); - if (ACPI_SUCCESS (status)) { - status = acpi_ex_create_method (op->named.data, - op->named.length, walk_state); + status = + acpi_ds_create_operands(walk_state, + op->common.value.arg); + if (ACPI_SUCCESS(status)) { + status = acpi_ex_create_method(op->named.data, + op->named.length, + walk_state); } walk_state->operands[0] = NULL; walk_state->num_operands = 0; - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { return (status); } } @@ -434,17 +431,17 @@ acpi_ds_load1_end_op ( /* Pop the scope stack */ - if (acpi_ns_opens_scope (object_type)) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", - acpi_ut_get_type_name (object_type), op)); + if (acpi_ns_opens_scope(object_type)) { + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "(%s): Popping scope for Op %p\n", + acpi_ut_get_type_name(object_type), op)); - status = acpi_ds_scope_stack_pop (walk_state); + status = acpi_ds_scope_stack_pop(walk_state); } return (status); } - /******************************************************************************* * * FUNCTION: acpi_ds_load2_begin_op @@ -459,50 +456,50 @@ acpi_ds_load1_end_op ( ******************************************************************************/ acpi_status -acpi_ds_load2_begin_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object **out_op) +acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state, + union acpi_parse_object ** out_op) { - union acpi_parse_object *op; - struct acpi_namespace_node *node; - acpi_status status; - acpi_object_type object_type; - char *buffer_ptr; - - - ACPI_FUNCTION_TRACE ("ds_load2_begin_op"); + union acpi_parse_object *op; + struct acpi_namespace_node *node; + acpi_status status; + acpi_object_type object_type; + char *buffer_ptr; + ACPI_FUNCTION_TRACE("ds_load2_begin_op"); op = walk_state->op; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, + walk_state)); if (op) { if ((walk_state->control_state) && - (walk_state->control_state->common.state == - ACPI_CONTROL_CONDITIONAL_EXECUTING)) { + (walk_state->control_state->common.state == + ACPI_CONTROL_CONDITIONAL_EXECUTING)) { /* We are executing a while loop outside of a method */ - status = acpi_ds_exec_begin_op (walk_state, out_op); - return_ACPI_STATUS (status); + status = acpi_ds_exec_begin_op(walk_state, out_op); + return_ACPI_STATUS(status); } /* We only care about Namespace opcodes here */ if ((!(walk_state->op_info->flags & AML_NSOPCODE) && - (walk_state->opcode != AML_INT_NAMEPATH_OP)) || - (!(walk_state->op_info->flags & AML_NAMED))) { + (walk_state->opcode != AML_INT_NAMEPATH_OP)) || + (!(walk_state->op_info->flags & AML_NAMED))) { if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || - (walk_state->op_info->class == AML_CLASS_CONTROL)) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Begin/EXEC: %s (fl %8.8X)\n", walk_state->op_info->name, - walk_state->op_info->flags)); + (walk_state->op_info->class == AML_CLASS_CONTROL)) { + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Begin/EXEC: %s (fl %8.8X)\n", + walk_state->op_info->name, + walk_state->op_info->flags)); /* Executing a type1 or type2 opcode outside of a method */ - status = acpi_ds_exec_begin_op (walk_state, out_op); - return_ACPI_STATUS (status); + status = + acpi_ds_exec_begin_op(walk_state, out_op); + return_ACPI_STATUS(status); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Get the name we are going to enter or lookup in the namespace */ @@ -514,28 +511,27 @@ acpi_ds_load2_begin_op ( if (!buffer_ptr) { /* No name, just exit */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - } - else { + } else { /* Get name from the op */ - buffer_ptr = (char *) &op->named.name; + buffer_ptr = (char *)&op->named.name; } - } - else { + } else { /* Get the namestring from the raw AML */ - buffer_ptr = acpi_ps_get_next_namestring (&walk_state->parser_state); + buffer_ptr = + acpi_ps_get_next_namestring(&walk_state->parser_state); } /* Map the opcode into an internal object type */ object_type = walk_state->op_info->object_type; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "State=%p Op=%p Type=%X\n", walk_state, op, object_type)); - + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "State=%p Op=%p Type=%X\n", walk_state, op, + object_type)); switch (walk_state->opcode) { case AML_FIELD_OP: @@ -553,9 +549,10 @@ acpi_ds_load2_begin_op ( * Don't enter the name into the namespace, but look it up * for use later. */ - status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, - walk_state, &(node)); + status = + acpi_ns_lookup(walk_state->scope_info, buffer_ptr, + object_type, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, walk_state, &(node)); break; case AML_SCOPE_OP: @@ -565,28 +562,28 @@ acpi_ds_load2_begin_op ( * Don't enter the name into the namespace, but look it up * for use later. */ - status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, - walk_state, &(node)); - if (ACPI_FAILURE (status)) { + status = + acpi_ns_lookup(walk_state->scope_info, buffer_ptr, + object_type, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, walk_state, &(node)); + if (ACPI_FAILURE(status)) { #ifdef ACPI_ASL_COMPILER if (status == AE_NOT_FOUND) { status = AE_OK; - } - else { - ACPI_REPORT_NSERROR (buffer_ptr, status); + } else { + ACPI_REPORT_NSERROR(buffer_ptr, status); } #else - ACPI_REPORT_NSERROR (buffer_ptr, status); + ACPI_REPORT_NSERROR(buffer_ptr, status); #endif - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* * We must check to make sure that the target is * one of the opcodes that actually opens a scope */ switch (node->type) { - case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ + case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ case ACPI_TYPE_DEVICE: case ACPI_TYPE_POWER: case ACPI_TYPE_PROCESSOR: @@ -607,9 +604,7 @@ acpi_ds_load2_begin_op ( * Scope (DEB) { ... } */ - ACPI_REPORT_WARNING (( - "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", - buffer_ptr, acpi_ut_get_type_name (node->type))); + ACPI_REPORT_WARNING(("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", buffer_ptr, acpi_ut_get_type_name(node->type))); node->type = ACPI_TYPE_ANY; walk_state->scope_info->common.value = ACPI_TYPE_ANY; @@ -619,9 +614,7 @@ acpi_ds_load2_begin_op ( /* All other types are an error */ - ACPI_REPORT_ERROR (( - "Invalid type (%s) for target of Scope operator [%4.4s]\n", - acpi_ut_get_type_name (node->type), buffer_ptr)); + ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s]\n", acpi_ut_get_type_name(node->type), buffer_ptr)); return (AE_AML_OPERAND_TYPE); } @@ -636,14 +629,16 @@ acpi_ds_load2_begin_op ( node = op->common.node; - if (acpi_ns_opens_scope (object_type)) { - status = acpi_ds_scope_stack_push (node, object_type, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + if (acpi_ns_opens_scope(object_type)) { + status = + acpi_ds_scope_stack_push(node, object_type, + walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* @@ -664,23 +659,24 @@ acpi_ds_load2_begin_op ( /* Add new entry into namespace */ - status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, - ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, - walk_state, &(node)); + status = + acpi_ns_lookup(walk_state->scope_info, buffer_ptr, + object_type, ACPI_IMODE_LOAD_PASS2, + ACPI_NS_NO_UPSEARCH, walk_state, &(node)); break; } - if (ACPI_FAILURE (status)) { - ACPI_REPORT_NSERROR (buffer_ptr, status); - return_ACPI_STATUS (status); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR(buffer_ptr, status); + return_ACPI_STATUS(status); } if (!op) { /* Create a new op */ - op = acpi_ps_alloc_op (walk_state->opcode); + op = acpi_ps_alloc_op(walk_state->opcode); if (!op) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Initialize the new op */ @@ -697,10 +693,9 @@ acpi_ds_load2_begin_op ( */ op->common.node = node; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_load2_end_op @@ -714,26 +709,23 @@ acpi_ds_load2_begin_op ( * ******************************************************************************/ -acpi_status -acpi_ds_load2_end_op ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) { - union acpi_parse_object *op; - acpi_status status = AE_OK; - acpi_object_type object_type; - struct acpi_namespace_node *node; - union acpi_parse_object *arg; - struct acpi_namespace_node *new_node; + union acpi_parse_object *op; + acpi_status status = AE_OK; + acpi_object_type object_type; + struct acpi_namespace_node *node; + union acpi_parse_object *arg; + struct acpi_namespace_node *new_node; #ifndef ACPI_NO_METHOD_EXECUTION - u32 i; + u32 i; #endif - - ACPI_FUNCTION_TRACE ("ds_load2_end_op"); + ACPI_FUNCTION_TRACE("ds_load2_end_op"); op = walk_state->op; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", - walk_state->op_info->name, op, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", + walk_state->op_info->name, op, walk_state)); /* Check if opcode had an associated namespace object */ @@ -742,23 +734,25 @@ acpi_ds_load2_end_op ( /* No namespace object. Executable opcode? */ if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || - (walk_state->op_info->class == AML_CLASS_CONTROL)) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "End/EXEC: %s (fl %8.8X)\n", walk_state->op_info->name, - walk_state->op_info->flags)); + (walk_state->op_info->class == AML_CLASS_CONTROL)) { + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "End/EXEC: %s (fl %8.8X)\n", + walk_state->op_info->name, + walk_state->op_info->flags)); /* Executing a type1 or type2 opcode outside of a method */ - status = acpi_ds_exec_end_op (walk_state); - return_ACPI_STATUS (status); + status = acpi_ds_exec_end_op(walk_state); + return_ACPI_STATUS(status); } #endif - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } if (op->common.aml_opcode == AML_SCOPE_OP) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Ending scope Op=%p State=%p\n", op, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Ending scope Op=%p State=%p\n", op, + walk_state)); } object_type = walk_state->op_info->object_type; @@ -773,18 +767,19 @@ acpi_ds_load2_end_op ( * Put the Node on the object stack (Contains the ACPI Name of * this object) */ - walk_state->operands[0] = (void *) node; + walk_state->operands[0] = (void *)node; walk_state->num_operands = 1; /* Pop the scope stack */ - if (acpi_ns_opens_scope (object_type) && - (op->common.aml_opcode != AML_INT_METHODCALL_OP)) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", - acpi_ut_get_type_name (object_type), op)); + if (acpi_ns_opens_scope(object_type) && + (op->common.aml_opcode != AML_INT_METHODCALL_OP)) { + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "(%s) Popping scope for Op %p\n", + acpi_ut_get_type_name(object_type), op)); - status = acpi_ds_scope_stack_pop (walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ds_scope_stack_pop(walk_state); + if (ACPI_FAILURE(status)) { goto cleanup; } } @@ -817,9 +812,10 @@ acpi_ds_load2_end_op ( * AML_THERMALZONE */ - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Create-Load [%s] State=%p Op=%p named_obj=%p\n", - acpi_ps_get_opcode_name (op->common.aml_opcode), walk_state, op, node)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Create-Load [%s] State=%p Op=%p named_obj=%p\n", + acpi_ps_get_opcode_name(op->common.aml_opcode), + walk_state, op, node)); /* Decode the opcode */ @@ -834,27 +830,32 @@ acpi_ds_load2_end_op ( * Create the field object, but the field buffer and index must * be evaluated later during the execution phase */ - status = acpi_ds_create_buffer_field (op, walk_state); + status = acpi_ds_create_buffer_field(op, walk_state); break; - - case AML_TYPE_NAMED_FIELD: + case AML_TYPE_NAMED_FIELD: switch (op->common.aml_opcode) { case AML_INDEX_FIELD_OP: - status = acpi_ds_create_index_field (op, (acpi_handle) arg->common.node, - walk_state); + status = + acpi_ds_create_index_field(op, + (acpi_handle) arg-> + common.node, walk_state); break; case AML_BANK_FIELD_OP: - status = acpi_ds_create_bank_field (op, arg->common.node, walk_state); + status = + acpi_ds_create_bank_field(op, arg->common.node, + walk_state); break; case AML_FIELD_OP: - status = acpi_ds_create_field (op, arg->common.node, walk_state); + status = + acpi_ds_create_field(op, arg->common.node, + walk_state); break; default: @@ -863,43 +864,42 @@ acpi_ds_load2_end_op ( } break; + case AML_TYPE_NAMED_SIMPLE: - case AML_TYPE_NAMED_SIMPLE: - - status = acpi_ds_create_operands (walk_state, arg); - if (ACPI_FAILURE (status)) { + status = acpi_ds_create_operands(walk_state, arg); + if (ACPI_FAILURE(status)) { goto cleanup; } switch (op->common.aml_opcode) { case AML_PROCESSOR_OP: - status = acpi_ex_create_processor (walk_state); + status = acpi_ex_create_processor(walk_state); break; case AML_POWER_RES_OP: - status = acpi_ex_create_power_resource (walk_state); + status = acpi_ex_create_power_resource(walk_state); break; case AML_MUTEX_OP: - status = acpi_ex_create_mutex (walk_state); + status = acpi_ex_create_mutex(walk_state); break; case AML_EVENT_OP: - status = acpi_ex_create_event (walk_state); + status = acpi_ex_create_event(walk_state); break; case AML_DATA_REGION_OP: - status = acpi_ex_create_table_region (walk_state); + status = acpi_ex_create_table_region(walk_state); break; case AML_ALIAS_OP: - status = acpi_ex_create_alias (walk_state); + status = acpi_ex_create_alias(walk_state); break; default: @@ -912,12 +912,12 @@ acpi_ds_load2_end_op ( /* Delete operands */ for (i = 1; i < walk_state->num_operands; i++) { - acpi_ut_remove_reference (walk_state->operands[i]); + acpi_ut_remove_reference(walk_state->operands[i]); walk_state->operands[i] = NULL; } break; -#endif /* ACPI_NO_METHOD_EXECUTION */ +#endif /* ACPI_NO_METHOD_EXECUTION */ case AML_TYPE_NAMED_COMPLEX: @@ -933,9 +933,10 @@ acpi_ds_load2_end_op ( * If we have a valid region, initialize it * Namespace is NOT locked at this point. */ - status = acpi_ev_initialize_region (acpi_ns_get_attached_object (node), - FALSE); - if (ACPI_FAILURE (status)) { + status = + acpi_ev_initialize_region + (acpi_ns_get_attached_object(node), FALSE); + if (ACPI_FAILURE(status)) { /* * If AE_NOT_EXIST is returned, it is not fatal * because many regions get created before a handler @@ -947,13 +948,11 @@ acpi_ds_load2_end_op ( } break; - case AML_NAME_OP: - status = acpi_ds_create_node (walk_state, node, op); + status = acpi_ds_create_node(walk_state, node, op); break; -#endif /* ACPI_NO_METHOD_EXECUTION */ - +#endif /* ACPI_NO_METHOD_EXECUTION */ default: /* All NAMED_COMPLEX opcodes must be handled above */ @@ -962,27 +961,28 @@ acpi_ds_load2_end_op ( } break; - case AML_CLASS_INTERNAL: /* case AML_INT_NAMEPATH_OP: */ break; - case AML_CLASS_METHOD_CALL: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "RESOLVING-method_call: State=%p Op=%p named_obj=%p\n", - walk_state, op, node)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "RESOLVING-method_call: State=%p Op=%p named_obj=%p\n", + walk_state, op, node)); /* * Lookup the method name and save the Node */ - status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string, - ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - walk_state, &(new_node)); - if (ACPI_SUCCESS (status)) { + status = + acpi_ns_lookup(walk_state->scope_info, + arg->common.value.string, ACPI_TYPE_ANY, + ACPI_IMODE_LOAD_PASS2, + ACPI_NS_SEARCH_PARENT | + ACPI_NS_DONT_OPEN_SCOPE, walk_state, + &(new_node)); + if (ACPI_SUCCESS(status)) { /* * Make sure that what we found is indeed a method @@ -998,24 +998,20 @@ acpi_ds_load2_end_op ( * parser uses, so we can get it again at the end of this scope */ op->common.node = new_node; - } - else { - ACPI_REPORT_NSERROR (arg->common.value.string, status); + } else { + ACPI_REPORT_NSERROR(arg->common.value.string, status); } break; - default: break; } -cleanup: + cleanup: /* Remove the Node pushed at the very beginning */ walk_state->operands[0] = NULL; walk_state->num_operands = 0; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/dispatcher/dswscope.c b/drivers/acpi/dispatcher/dswscope.c index 21f4548..defe956 100644 --- a/drivers/acpi/dispatcher/dswscope.c +++ b/drivers/acpi/dispatcher/dswscope.c @@ -41,14 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dswscope") - +ACPI_MODULE_NAME("dswscope") /**************************************************************************** * @@ -62,15 +59,11 @@ * root scope object (which remains at the stack top.) * ***************************************************************************/ - -void -acpi_ds_scope_stack_clear ( - struct acpi_walk_state *walk_state) +void acpi_ds_scope_stack_clear(struct acpi_walk_state *walk_state) { - union acpi_generic_state *scope_info; - - ACPI_FUNCTION_NAME ("ds_scope_stack_clear"); + union acpi_generic_state *scope_info; + ACPI_FUNCTION_NAME("ds_scope_stack_clear"); while (walk_state->scope_info) { /* Pop a scope off the stack */ @@ -78,14 +71,14 @@ acpi_ds_scope_stack_clear ( scope_info = walk_state->scope_info; walk_state->scope_info = scope_info->scope.next; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Popped object type (%s)\n", - acpi_ut_get_type_name (scope_info->common.value))); - acpi_ut_delete_generic_state (scope_info); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Popped object type (%s)\n", + acpi_ut_get_type_name(scope_info->common. + value))); + acpi_ut_delete_generic_state(scope_info); } } - /**************************************************************************** * * FUNCTION: acpi_ds_scope_stack_push @@ -102,74 +95,70 @@ acpi_ds_scope_stack_clear ( ***************************************************************************/ acpi_status -acpi_ds_scope_stack_push ( - struct acpi_namespace_node *node, - acpi_object_type type, - struct acpi_walk_state *walk_state) +acpi_ds_scope_stack_push(struct acpi_namespace_node *node, + acpi_object_type type, + struct acpi_walk_state *walk_state) { - union acpi_generic_state *scope_info; - union acpi_generic_state *old_scope_info; - - - ACPI_FUNCTION_TRACE ("ds_scope_stack_push"); + union acpi_generic_state *scope_info; + union acpi_generic_state *old_scope_info; + ACPI_FUNCTION_TRACE("ds_scope_stack_push"); if (!node) { /* Invalid scope */ - ACPI_REPORT_ERROR (("ds_scope_stack_push: null scope passed\n")); - return_ACPI_STATUS (AE_BAD_PARAMETER); + ACPI_REPORT_ERROR(("ds_scope_stack_push: null scope passed\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Make sure object type is valid */ - if (!acpi_ut_valid_object_type (type)) { - ACPI_REPORT_WARNING (( - "ds_scope_stack_push: Invalid object type: 0x%X\n", type)); + if (!acpi_ut_valid_object_type(type)) { + ACPI_REPORT_WARNING(("ds_scope_stack_push: Invalid object type: 0x%X\n", type)); } /* Allocate a new scope object */ - scope_info = acpi_ut_create_generic_state (); + scope_info = acpi_ut_create_generic_state(); if (!scope_info) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Init new scope object */ scope_info->common.data_type = ACPI_DESC_TYPE_STATE_WSCOPE; - scope_info->scope.node = node; - scope_info->common.value = (u16) type; + scope_info->scope.node = node; + scope_info->common.value = (u16) type; walk_state->scope_depth++; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[%.2d] Pushed scope ", (u32) walk_state->scope_depth)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[%.2d] Pushed scope ", + (u32) walk_state->scope_depth)); old_scope_info = walk_state->scope_info; if (old_scope_info) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, - "[%4.4s] (%s)", - acpi_ut_get_node_name (old_scope_info->scope.node), - acpi_ut_get_type_name (old_scope_info->common.value))); - } - else { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, - "[\\___] (%s)", "ROOT")); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, + "[%4.4s] (%s)", + acpi_ut_get_node_name(old_scope_info-> + scope.node), + acpi_ut_get_type_name(old_scope_info-> + common.value))); + } else { + ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "[\\___] (%s)", "ROOT")); } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, - ", New scope -> [%4.4s] (%s)\n", - acpi_ut_get_node_name (scope_info->scope.node), - acpi_ut_get_type_name (scope_info->common.value))); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, + ", New scope -> [%4.4s] (%s)\n", + acpi_ut_get_node_name(scope_info->scope.node), + acpi_ut_get_type_name(scope_info->common.value))); /* Push new scope object onto stack */ - acpi_ut_push_generic_state (&walk_state->scope_info, scope_info); - return_ACPI_STATUS (AE_OK); + acpi_ut_push_generic_state(&walk_state->scope_info, scope_info); + return_ACPI_STATUS(AE_OK); } - /**************************************************************************** * * FUNCTION: acpi_ds_scope_stack_pop @@ -182,47 +171,41 @@ acpi_ds_scope_stack_push ( * ***************************************************************************/ -acpi_status -acpi_ds_scope_stack_pop ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ds_scope_stack_pop(struct acpi_walk_state *walk_state) { - union acpi_generic_state *scope_info; - union acpi_generic_state *new_scope_info; - - - ACPI_FUNCTION_TRACE ("ds_scope_stack_pop"); + union acpi_generic_state *scope_info; + union acpi_generic_state *new_scope_info; + ACPI_FUNCTION_TRACE("ds_scope_stack_pop"); /* * Pop scope info object off the stack. */ - scope_info = acpi_ut_pop_generic_state (&walk_state->scope_info); + scope_info = acpi_ut_pop_generic_state(&walk_state->scope_info); if (!scope_info) { - return_ACPI_STATUS (AE_STACK_UNDERFLOW); + return_ACPI_STATUS(AE_STACK_UNDERFLOW); } walk_state->scope_depth--; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[%.2d] Popped scope [%4.4s] (%s), New scope -> ", - (u32) walk_state->scope_depth, - acpi_ut_get_node_name (scope_info->scope.node), - acpi_ut_get_type_name (scope_info->common.value))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[%.2d] Popped scope [%4.4s] (%s), New scope -> ", + (u32) walk_state->scope_depth, + acpi_ut_get_node_name(scope_info->scope.node), + acpi_ut_get_type_name(scope_info->common.value))); new_scope_info = walk_state->scope_info; if (new_scope_info) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, - "[%4.4s] (%s)\n", - acpi_ut_get_node_name (new_scope_info->scope.node), - acpi_ut_get_type_name (new_scope_info->common.value))); - } - else { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, - "[\\___] (ROOT)\n")); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, + "[%4.4s] (%s)\n", + acpi_ut_get_node_name(new_scope_info-> + scope.node), + acpi_ut_get_type_name(new_scope_info-> + common.value))); + } else { + ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "[\\___] (ROOT)\n")); } - acpi_ut_delete_generic_state (scope_info); - return_ACPI_STATUS (AE_OK); + acpi_ut_delete_generic_state(scope_info); + return_ACPI_STATUS(AE_OK); } - - diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c index 5621665..7d68a5a 100644 --- a/drivers/acpi/dispatcher/dswstate.c +++ b/drivers/acpi/dispatcher/dswstate.c @@ -41,37 +41,28 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dswstate") +ACPI_MODULE_NAME("dswstate") /* Local prototypes */ - #ifdef ACPI_OBSOLETE_FUNCTIONS acpi_status -acpi_ds_result_insert ( - void *object, - u32 index, - struct acpi_walk_state *walk_state); +acpi_ds_result_insert(void *object, + u32 index, struct acpi_walk_state *walk_state); -acpi_status -acpi_ds_obj_stack_delete_all ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ds_obj_stack_delete_all(struct acpi_walk_state *walk_state); acpi_status -acpi_ds_obj_stack_pop_object ( - union acpi_operand_object **object, - struct acpi_walk_state *walk_state); - -void * -acpi_ds_obj_stack_get_value ( - u32 index, - struct acpi_walk_state *walk_state); +acpi_ds_obj_stack_pop_object(union acpi_operand_object **object, + struct acpi_walk_state *walk_state); + +void *acpi_ds_obj_stack_get_value(u32 index, + struct acpi_walk_state *walk_state); #endif #ifdef ACPI_FUTURE_USAGE @@ -92,36 +83,35 @@ acpi_ds_obj_stack_get_value ( ******************************************************************************/ acpi_status -acpi_ds_result_remove ( - union acpi_operand_object **object, - u32 index, - struct acpi_walk_state *walk_state) +acpi_ds_result_remove(union acpi_operand_object **object, + u32 index, struct acpi_walk_state *walk_state) { - union acpi_generic_state *state; - - - ACPI_FUNCTION_NAME ("ds_result_remove"); + union acpi_generic_state *state; + ACPI_FUNCTION_NAME("ds_result_remove"); state = walk_state->results; if (!state) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", - walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No result object pushed! State=%p\n", + walk_state)); return (AE_NOT_EXIST); } if (index >= ACPI_OBJ_MAX_OPERAND) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index out of range: %X State=%p Num=%X\n", - index, walk_state, state->results.num_results)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Index out of range: %X State=%p Num=%X\n", + index, walk_state, + state->results.num_results)); } /* Check for a valid result object */ - if (!state->results.obj_desc [index]) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null operand! State=%p #Ops=%X, Index=%X\n", - walk_state, state->results.num_results, index)); + if (!state->results.obj_desc[index]) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Null operand! State=%p #Ops=%X, Index=%X\n", + walk_state, state->results.num_results, + index)); return (AE_AML_NO_RETURN_VALUE); } @@ -129,18 +119,20 @@ acpi_ds_result_remove ( state->results.num_results--; - *object = state->results.obj_desc [index]; - state->results.obj_desc [index] = NULL; + *object = state->results.obj_desc[index]; + state->results.obj_desc[index] = NULL; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Obj=%p [%s] Index=%X State=%p Num=%X\n", - *object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL", - index, walk_state, state->results.num_results)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Obj=%p [%s] Index=%X State=%p Num=%X\n", + *object, + (*object) ? acpi_ut_get_object_type_name(*object) : + "NULL", index, walk_state, + state->results.num_results)); return (AE_OK); } -#endif /* ACPI_FUTURE_USAGE */ +#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * @@ -157,16 +149,13 @@ acpi_ds_result_remove ( ******************************************************************************/ acpi_status -acpi_ds_result_pop ( - union acpi_operand_object **object, - struct acpi_walk_state *walk_state) +acpi_ds_result_pop(union acpi_operand_object ** object, + struct acpi_walk_state * walk_state) { - acpi_native_uint index; - union acpi_generic_state *state; - - - ACPI_FUNCTION_NAME ("ds_result_pop"); + acpi_native_uint index; + union acpi_generic_state *state; + ACPI_FUNCTION_NAME("ds_result_pop"); state = walk_state->results; if (!state) { @@ -174,8 +163,9 @@ acpi_ds_result_pop ( } if (!state->results.num_results) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack is empty! State=%p\n", - walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Result stack is empty! State=%p\n", + walk_state)); return (AE_AML_NO_RETURN_VALUE); } @@ -186,26 +176,27 @@ acpi_ds_result_pop ( for (index = ACPI_OBJ_NUM_OPERANDS; index; index--) { /* Check for a valid result object */ - if (state->results.obj_desc [index -1]) { - *object = state->results.obj_desc [index -1]; - state->results.obj_desc [index -1] = NULL; + if (state->results.obj_desc[index - 1]) { + *object = state->results.obj_desc[index - 1]; + state->results.obj_desc[index - 1] = NULL; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Obj=%p [%s] Index=%X State=%p Num=%X\n", - *object, - (*object) ? acpi_ut_get_object_type_name (*object) : "NULL", - (u32) index -1, walk_state, state->results.num_results)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Obj=%p [%s] Index=%X State=%p Num=%X\n", + *object, + (*object) ? + acpi_ut_get_object_type_name(*object) + : "NULL", (u32) index - 1, walk_state, + state->results.num_results)); return (AE_OK); } } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "No result objects! State=%p\n", walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No result objects! State=%p\n", walk_state)); return (AE_AML_NO_RETURN_VALUE); } - /******************************************************************************* * * FUNCTION: acpi_ds_result_pop_from_bottom @@ -221,38 +212,37 @@ acpi_ds_result_pop ( ******************************************************************************/ acpi_status -acpi_ds_result_pop_from_bottom ( - union acpi_operand_object **object, - struct acpi_walk_state *walk_state) +acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object, + struct acpi_walk_state * walk_state) { - acpi_native_uint index; - union acpi_generic_state *state; - - - ACPI_FUNCTION_NAME ("ds_result_pop_from_bottom"); + acpi_native_uint index; + union acpi_generic_state *state; + ACPI_FUNCTION_NAME("ds_result_pop_from_bottom"); state = walk_state->results; if (!state) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Warning: No result object pushed! State=%p\n", walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Warning: No result object pushed! State=%p\n", + walk_state)); return (AE_NOT_EXIST); } if (!state->results.num_results) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", - walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No result objects! State=%p\n", walk_state)); return (AE_AML_NO_RETURN_VALUE); } /* Remove Bottom element */ - *object = state->results.obj_desc [0]; + *object = state->results.obj_desc[0]; /* Push entire stack down one element */ for (index = 0; index < state->results.num_results; index++) { - state->results.obj_desc [index] = state->results.obj_desc [index + 1]; + state->results.obj_desc[index] = + state->results.obj_desc[index + 1]; } state->results.num_results--; @@ -260,20 +250,21 @@ acpi_ds_result_pop_from_bottom ( /* Check for a valid result object */ if (!*object) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null operand! State=%p #Ops=%X Index=%X\n", - walk_state, state->results.num_results, (u32) index)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Null operand! State=%p #Ops=%X Index=%X\n", + walk_state, state->results.num_results, + (u32) index)); return (AE_AML_NO_RETURN_VALUE); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Results=%p State=%p\n", - *object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL", - state, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] Results=%p State=%p\n", + *object, + (*object) ? acpi_ut_get_object_type_name(*object) : + "NULL", state, walk_state)); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_result_push @@ -288,47 +279,50 @@ acpi_ds_result_pop_from_bottom ( ******************************************************************************/ acpi_status -acpi_ds_result_push ( - union acpi_operand_object *object, - struct acpi_walk_state *walk_state) +acpi_ds_result_push(union acpi_operand_object * object, + struct acpi_walk_state * walk_state) { - union acpi_generic_state *state; - - - ACPI_FUNCTION_NAME ("ds_result_push"); + union acpi_generic_state *state; + ACPI_FUNCTION_NAME("ds_result_push"); state = walk_state->results; if (!state) { - ACPI_REPORT_ERROR (("No result stack frame during push\n")); + ACPI_REPORT_ERROR(("No result stack frame during push\n")); return (AE_AML_INTERNAL); } if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Result stack overflow: Obj=%p State=%p Num=%X\n", - object, walk_state, state->results.num_results)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Result stack overflow: Obj=%p State=%p Num=%X\n", + object, walk_state, + state->results.num_results)); return (AE_STACK_OVERFLOW); } if (!object) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null Object! Obj=%p State=%p Num=%X\n", - object, walk_state, state->results.num_results)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Null Object! Obj=%p State=%p Num=%X\n", + object, walk_state, + state->results.num_results)); return (AE_BAD_PARAMETER); } - state->results.obj_desc [state->results.num_results] = object; + state->results.obj_desc[state->results.num_results] = object; state->results.num_results++; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", - object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL", - walk_state, state->results.num_results, walk_state->current_result)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", + object, + object ? + acpi_ut_get_object_type_name((union + acpi_operand_object *) + object) : "NULL", + walk_state, state->results.num_results, + walk_state->current_result)); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_result_stack_push @@ -341,30 +335,26 @@ acpi_ds_result_push ( * ******************************************************************************/ -acpi_status -acpi_ds_result_stack_push ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ds_result_stack_push(struct acpi_walk_state * walk_state) { - union acpi_generic_state *state; + union acpi_generic_state *state; - ACPI_FUNCTION_NAME ("ds_result_stack_push"); + ACPI_FUNCTION_NAME("ds_result_stack_push"); - - state = acpi_ut_create_generic_state (); + state = acpi_ut_create_generic_state(); if (!state) { return (AE_NO_MEMORY); } state->common.data_type = ACPI_DESC_TYPE_STATE_RESULT; - acpi_ut_push_generic_state (&walk_state->results, state); + acpi_ut_push_generic_state(&walk_state->results, state); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", - state, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n", + state, walk_state)); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_result_stack_pop @@ -377,35 +367,31 @@ acpi_ds_result_stack_push ( * ******************************************************************************/ -acpi_status -acpi_ds_result_stack_pop ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state * walk_state) { - union acpi_generic_state *state; - - ACPI_FUNCTION_NAME ("ds_result_stack_pop"); + union acpi_generic_state *state; + ACPI_FUNCTION_NAME("ds_result_stack_pop"); /* Check for stack underflow */ if (walk_state->results == NULL) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Underflow - State=%p\n", - walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Underflow - State=%p\n", + walk_state)); return (AE_AML_NO_OPERAND); } - state = acpi_ut_pop_generic_state (&walk_state->results); + state = acpi_ut_pop_generic_state(&walk_state->results); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Result=%p remaining_results=%X State=%p\n", - state, state->results.num_results, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Result=%p remaining_results=%X State=%p\n", + state, state->results.num_results, walk_state)); - acpi_ut_delete_generic_state (state); + acpi_ut_delete_generic_state(state); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_obj_stack_push @@ -420,35 +406,35 @@ acpi_ds_result_stack_pop ( ******************************************************************************/ acpi_status -acpi_ds_obj_stack_push ( - void *object, - struct acpi_walk_state *walk_state) +acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state) { - ACPI_FUNCTION_NAME ("ds_obj_stack_push"); - + ACPI_FUNCTION_NAME("ds_obj_stack_push"); /* Check for stack overflow */ if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "overflow! Obj=%p State=%p #Ops=%X\n", - object, walk_state, walk_state->num_operands)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "overflow! Obj=%p State=%p #Ops=%X\n", + object, walk_state, + walk_state->num_operands)); return (AE_STACK_OVERFLOW); } /* Put the object onto the stack */ - walk_state->operands [walk_state->num_operands] = object; + walk_state->operands[walk_state->num_operands] = object; walk_state->num_operands++; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", - object, acpi_ut_get_object_type_name ((union acpi_operand_object *) object), - walk_state, walk_state->num_operands)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", + object, + acpi_ut_get_object_type_name((union + acpi_operand_object *) + object), walk_state, + walk_state->num_operands)); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_obj_stack_pop @@ -464,38 +450,35 @@ acpi_ds_obj_stack_push ( ******************************************************************************/ acpi_status -acpi_ds_obj_stack_pop ( - u32 pop_count, - struct acpi_walk_state *walk_state) +acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state * walk_state) { - u32 i; - - ACPI_FUNCTION_NAME ("ds_obj_stack_pop"); + u32 i; + ACPI_FUNCTION_NAME("ds_obj_stack_pop"); for (i = 0; i < pop_count; i++) { /* Check for stack underflow */ if (walk_state->num_operands == 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Underflow! Count=%X State=%p #Ops=%X\n", - pop_count, walk_state, walk_state->num_operands)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Underflow! Count=%X State=%p #Ops=%X\n", + pop_count, walk_state, + walk_state->num_operands)); return (AE_STACK_UNDERFLOW); } /* Just set the stack entry to null */ walk_state->num_operands--; - walk_state->operands [walk_state->num_operands] = NULL; + walk_state->operands[walk_state->num_operands] = NULL; } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", pop_count, walk_state, walk_state->num_operands)); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_obj_stack_pop_and_delete @@ -511,44 +494,43 @@ acpi_ds_obj_stack_pop ( ******************************************************************************/ acpi_status -acpi_ds_obj_stack_pop_and_delete ( - u32 pop_count, - struct acpi_walk_state *walk_state) +acpi_ds_obj_stack_pop_and_delete(u32 pop_count, + struct acpi_walk_state * walk_state) { - u32 i; - union acpi_operand_object *obj_desc; - - - ACPI_FUNCTION_NAME ("ds_obj_stack_pop_and_delete"); + u32 i; + union acpi_operand_object *obj_desc; + ACPI_FUNCTION_NAME("ds_obj_stack_pop_and_delete"); for (i = 0; i < pop_count; i++) { /* Check for stack underflow */ if (walk_state->num_operands == 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Underflow! Count=%X State=%p #Ops=%X\n", - pop_count, walk_state, walk_state->num_operands)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Underflow! Count=%X State=%p #Ops=%X\n", + pop_count, walk_state, + walk_state->num_operands)); return (AE_STACK_UNDERFLOW); } /* Pop the stack and delete an object if present in this stack entry */ walk_state->num_operands--; - obj_desc = walk_state->operands [walk_state->num_operands]; + obj_desc = walk_state->operands[walk_state->num_operands]; if (obj_desc) { - acpi_ut_remove_reference (walk_state->operands [walk_state->num_operands]); - walk_state->operands [walk_state->num_operands] = NULL; + acpi_ut_remove_reference(walk_state-> + operands[walk_state-> + num_operands]); + walk_state->operands[walk_state->num_operands] = NULL; } } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", pop_count, walk_state, walk_state->num_operands)); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_get_current_walk_state @@ -562,25 +544,21 @@ acpi_ds_obj_stack_pop_and_delete ( * ******************************************************************************/ -struct acpi_walk_state * -acpi_ds_get_current_walk_state ( - struct acpi_thread_state *thread) - +struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state + *thread) { - ACPI_FUNCTION_NAME ("ds_get_current_walk_state"); - + ACPI_FUNCTION_NAME("ds_get_current_walk_state"); if (!thread) { return (NULL); } - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current walk_state %p\n", - thread->walk_state_list)); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Current walk_state %p\n", + thread->walk_state_list)); return (thread->walk_state_list); } - /******************************************************************************* * * FUNCTION: acpi_ds_push_walk_state @@ -595,20 +573,17 @@ acpi_ds_get_current_walk_state ( ******************************************************************************/ void -acpi_ds_push_walk_state ( - struct acpi_walk_state *walk_state, - struct acpi_thread_state *thread) +acpi_ds_push_walk_state(struct acpi_walk_state *walk_state, + struct acpi_thread_state *thread) { - ACPI_FUNCTION_TRACE ("ds_push_walk_state"); - + ACPI_FUNCTION_TRACE("ds_push_walk_state"); - walk_state->next = thread->walk_state_list; + walk_state->next = thread->walk_state_list; thread->walk_state_list = walk_state; return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ds_pop_walk_state @@ -623,15 +598,11 @@ acpi_ds_push_walk_state ( * ******************************************************************************/ -struct acpi_walk_state * -acpi_ds_pop_walk_state ( - struct acpi_thread_state *thread) +struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread) { - struct acpi_walk_state *walk_state; - - - ACPI_FUNCTION_TRACE ("ds_pop_walk_state"); + struct acpi_walk_state *walk_state; + ACPI_FUNCTION_TRACE("ds_pop_walk_state"); walk_state = thread->walk_state_list; @@ -647,10 +618,9 @@ acpi_ds_pop_walk_state ( */ } - return_PTR (walk_state); + return_PTR(walk_state); } - /******************************************************************************* * * FUNCTION: acpi_ds_create_walk_state @@ -667,57 +637,55 @@ acpi_ds_pop_walk_state ( * ******************************************************************************/ -struct acpi_walk_state * -acpi_ds_create_walk_state ( - acpi_owner_id owner_id, - union acpi_parse_object *origin, - union acpi_operand_object *mth_desc, - struct acpi_thread_state *thread) +struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, + union acpi_parse_object + *origin, + union acpi_operand_object + *mth_desc, + struct acpi_thread_state + *thread) { - struct acpi_walk_state *walk_state; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ds_create_walk_state"); + struct acpi_walk_state *walk_state; + acpi_status status; + ACPI_FUNCTION_TRACE("ds_create_walk_state"); - walk_state = ACPI_MEM_CALLOCATE (sizeof (struct acpi_walk_state)); + walk_state = ACPI_MEM_CALLOCATE(sizeof(struct acpi_walk_state)); if (!walk_state) { - return_PTR (NULL); + return_PTR(NULL); } - walk_state->data_type = ACPI_DESC_TYPE_WALK; - walk_state->owner_id = owner_id; - walk_state->origin = origin; - walk_state->method_desc = mth_desc; - walk_state->thread = thread; + walk_state->data_type = ACPI_DESC_TYPE_WALK; + walk_state->owner_id = owner_id; + walk_state->origin = origin; + walk_state->method_desc = mth_desc; + walk_state->thread = thread; walk_state->parser_state.start_op = origin; /* Init the method args/local */ #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) - acpi_ds_method_data_init (walk_state); + acpi_ds_method_data_init(walk_state); #endif /* Create an initial result stack entry */ - status = acpi_ds_result_stack_push (walk_state); - if (ACPI_FAILURE (status)) { - ACPI_MEM_FREE (walk_state); - return_PTR (NULL); + status = acpi_ds_result_stack_push(walk_state); + if (ACPI_FAILURE(status)) { + ACPI_MEM_FREE(walk_state); + return_PTR(NULL); } /* Put the new state at the head of the walk list */ if (thread) { - acpi_ds_push_walk_state (walk_state, thread); + acpi_ds_push_walk_state(walk_state, thread); } - return_PTR (walk_state); + return_PTR(walk_state); } - /******************************************************************************* * * FUNCTION: acpi_ds_init_aml_walk @@ -737,27 +705,23 @@ acpi_ds_create_walk_state ( ******************************************************************************/ acpi_status -acpi_ds_init_aml_walk ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - struct acpi_namespace_node *method_node, - u8 *aml_start, - u32 aml_length, - struct acpi_parameter_info *info, - u8 pass_number) +acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + struct acpi_namespace_node *method_node, + u8 * aml_start, + u32 aml_length, + struct acpi_parameter_info *info, u8 pass_number) { - acpi_status status; - struct acpi_parse_state *parser_state = &walk_state->parser_state; - union acpi_parse_object *extra_op; - + acpi_status status; + struct acpi_parse_state *parser_state = &walk_state->parser_state; + union acpi_parse_object *extra_op; - ACPI_FUNCTION_TRACE ("ds_init_aml_walk"); + ACPI_FUNCTION_TRACE("ds_init_aml_walk"); - - walk_state->parser_state.aml = - walk_state->parser_state.aml_start = aml_start; + walk_state->parser_state.aml = + walk_state->parser_state.aml_start = aml_start; walk_state->parser_state.aml_end = - walk_state->parser_state.pkg_end = aml_start + aml_length; + walk_state->parser_state.pkg_end = aml_start + aml_length; /* The next_op of the next_walk will be the beginning of the method */ @@ -766,42 +730,45 @@ acpi_ds_init_aml_walk ( if (info) { if (info->parameter_type == ACPI_PARAM_GPE) { - walk_state->gpe_event_info = ACPI_CAST_PTR (struct acpi_gpe_event_info, - info->parameters); - } - else { - walk_state->params = info->parameters; + walk_state->gpe_event_info = + ACPI_CAST_PTR(struct acpi_gpe_event_info, + info->parameters); + } else { + walk_state->params = info->parameters; walk_state->caller_return_desc = &info->return_object; } } - status = acpi_ps_init_scope (&walk_state->parser_state, op); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ps_init_scope(&walk_state->parser_state, op); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } if (method_node) { walk_state->parser_state.start_node = method_node; - walk_state->walk_type = ACPI_WALK_METHOD; - walk_state->method_node = method_node; - walk_state->method_desc = acpi_ns_get_attached_object (method_node); + walk_state->walk_type = ACPI_WALK_METHOD; + walk_state->method_node = method_node; + walk_state->method_desc = + acpi_ns_get_attached_object(method_node); /* Push start scope on scope stack and make it current */ - status = acpi_ds_scope_stack_push (method_node, ACPI_TYPE_METHOD, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ds_scope_stack_push(method_node, ACPI_TYPE_METHOD, + walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Init the method arguments */ - status = acpi_ds_method_data_init_args (walk_state->params, - ACPI_METHOD_NUM_ARGS, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_method_data_init_args(walk_state->params, + ACPI_METHOD_NUM_ARGS, + walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - } - else { + } else { /* * Setup the current scope. * Find a Named Op that has a namespace node associated with it. @@ -815,27 +782,27 @@ acpi_ds_init_aml_walk ( if (!extra_op) { parser_state->start_node = NULL; - } - else { + } else { parser_state->start_node = extra_op->common.node; } if (parser_state->start_node) { /* Push start scope on scope stack and make it current */ - status = acpi_ds_scope_stack_push (parser_state->start_node, - parser_state->start_node->type, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ds_scope_stack_push(parser_state->start_node, + parser_state->start_node-> + type, walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } } - status = acpi_ds_init_callbacks (walk_state, pass_number); - return_ACPI_STATUS (status); + status = acpi_ds_init_callbacks(walk_state, pass_number); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_delete_walk_state @@ -848,29 +815,27 @@ acpi_ds_init_aml_walk ( * ******************************************************************************/ -void -acpi_ds_delete_walk_state ( - struct acpi_walk_state *walk_state) +void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state) { - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE_PTR ("ds_delete_walk_state", walk_state); + union acpi_generic_state *state; + ACPI_FUNCTION_TRACE_PTR("ds_delete_walk_state", walk_state); if (!walk_state) { return; } if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", - walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "%p is not a valid walk state\n", + walk_state)); return; } if (walk_state->parser_state.scope) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", - walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "%p walk still has a scope list\n", + walk_state)); } /* Always must free any linked control states */ @@ -879,7 +844,7 @@ acpi_ds_delete_walk_state ( state = walk_state->control_state; walk_state->control_state = state->common.next; - acpi_ut_delete_generic_state (state); + acpi_ut_delete_generic_state(state); } /* Always must free any linked parse states */ @@ -888,7 +853,7 @@ acpi_ds_delete_walk_state ( state = walk_state->scope_info; walk_state->scope_info = state->common.next; - acpi_ut_delete_generic_state (state); + acpi_ut_delete_generic_state(state); } /* Always must free any stacked result states */ @@ -897,14 +862,13 @@ acpi_ds_delete_walk_state ( state = walk_state->results; walk_state->results = state->common.next; - acpi_ut_delete_generic_state (state); + acpi_ut_delete_generic_state(state); } - ACPI_MEM_FREE (walk_state); + ACPI_MEM_FREE(walk_state); return_VOID; } - #ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * @@ -921,50 +885,53 @@ acpi_ds_delete_walk_state ( ******************************************************************************/ acpi_status -acpi_ds_result_insert ( - void *object, - u32 index, - struct acpi_walk_state *walk_state) +acpi_ds_result_insert(void *object, + u32 index, struct acpi_walk_state *walk_state) { - union acpi_generic_state *state; - - - ACPI_FUNCTION_NAME ("ds_result_insert"); + union acpi_generic_state *state; + ACPI_FUNCTION_NAME("ds_result_insert"); state = walk_state->results; if (!state) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", - walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No result object pushed! State=%p\n", + walk_state)); return (AE_NOT_EXIST); } if (index >= ACPI_OBJ_NUM_OPERANDS) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index out of range: %X Obj=%p State=%p Num=%X\n", - index, object, walk_state, state->results.num_results)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Index out of range: %X Obj=%p State=%p Num=%X\n", + index, object, walk_state, + state->results.num_results)); return (AE_BAD_PARAMETER); } if (!object) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null Object! Index=%X Obj=%p State=%p Num=%X\n", - index, object, walk_state, state->results.num_results)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Null Object! Index=%X Obj=%p State=%p Num=%X\n", + index, object, walk_state, + state->results.num_results)); return (AE_BAD_PARAMETER); } - state->results.obj_desc [index] = object; + state->results.obj_desc[index] = object; state->results.num_results++; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Obj=%p [%s] State=%p Num=%X Cur=%X\n", - object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL", - walk_state, state->results.num_results, walk_state->current_result)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Obj=%p [%s] State=%p Num=%X Cur=%X\n", + object, + object ? + acpi_ut_get_object_type_name((union + acpi_operand_object *) + object) : "NULL", + walk_state, state->results.num_results, + walk_state->current_result)); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_obj_stack_delete_all @@ -978,29 +945,24 @@ acpi_ds_result_insert ( * ******************************************************************************/ -acpi_status -acpi_ds_obj_stack_delete_all ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ds_obj_stack_delete_all(struct acpi_walk_state * walk_state) { - u32 i; - - - ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_delete_all", walk_state); + u32 i; + ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_delete_all", walk_state); /* The stack size is configurable, but fixed */ for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) { if (walk_state->operands[i]) { - acpi_ut_remove_reference (walk_state->operands[i]); + acpi_ut_remove_reference(walk_state->operands[i]); walk_state->operands[i] = NULL; } } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_obj_stack_pop_object @@ -1016,19 +978,17 @@ acpi_ds_obj_stack_delete_all ( ******************************************************************************/ acpi_status -acpi_ds_obj_stack_pop_object ( - union acpi_operand_object **object, - struct acpi_walk_state *walk_state) +acpi_ds_obj_stack_pop_object(union acpi_operand_object **object, + struct acpi_walk_state *walk_state) { - ACPI_FUNCTION_NAME ("ds_obj_stack_pop_object"); - + ACPI_FUNCTION_NAME("ds_obj_stack_pop_object"); /* Check for stack underflow */ if (walk_state->num_operands == 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Missing operand/stack empty! State=%p #Ops=%X\n", - walk_state, walk_state->num_operands)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Missing operand/stack empty! State=%p #Ops=%X\n", + walk_state, walk_state->num_operands)); *object = NULL; return (AE_AML_NO_OPERAND); } @@ -1039,27 +999,26 @@ acpi_ds_obj_stack_pop_object ( /* Check for a valid operand */ - if (!walk_state->operands [walk_state->num_operands]) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null operand! State=%p #Ops=%X\n", - walk_state, walk_state->num_operands)); + if (!walk_state->operands[walk_state->num_operands]) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Null operand! State=%p #Ops=%X\n", + walk_state, walk_state->num_operands)); *object = NULL; return (AE_AML_NO_OPERAND); } /* Get operand and set stack entry to null */ - *object = walk_state->operands [walk_state->num_operands]; - walk_state->operands [walk_state->num_operands] = NULL; + *object = walk_state->operands[walk_state->num_operands]; + walk_state->operands[walk_state->num_operands] = NULL; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", - *object, acpi_ut_get_object_type_name (*object), + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", + *object, acpi_ut_get_object_type_name(*object), walk_state, walk_state->num_operands)); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ds_obj_stack_get_value @@ -1075,30 +1034,25 @@ acpi_ds_obj_stack_pop_object ( * ******************************************************************************/ -void * -acpi_ds_obj_stack_get_value ( - u32 index, - struct acpi_walk_state *walk_state) +void *acpi_ds_obj_stack_get_value(u32 index, struct acpi_walk_state *walk_state) { - ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_get_value", walk_state); - + ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_get_value", walk_state); /* Can't do it if the stack is empty */ if (walk_state->num_operands == 0) { - return_PTR (NULL); + return_PTR(NULL); } /* or if the index is past the top of the stack */ if (index > (walk_state->num_operands - (u32) 1)) { - return_PTR (NULL); + return_PTR(NULL); } - return_PTR (walk_state->operands[(acpi_native_uint)(walk_state->num_operands - 1) - - index]); + return_PTR(walk_state-> + operands[(acpi_native_uint) (walk_state->num_operands - 1) - + index]); } #endif - - diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 1ac5731..b15f5ec 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -38,130 +38,112 @@ #include #define _COMPONENT ACPI_EC_COMPONENT -ACPI_MODULE_NAME ("acpi_ec") - +ACPI_MODULE_NAME("acpi_ec") #define ACPI_EC_COMPONENT 0x00100000 #define ACPI_EC_CLASS "embedded_controller" #define ACPI_EC_HID "PNP0C09" #define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" #define ACPI_EC_DEVICE_NAME "Embedded Controller" #define ACPI_EC_FILE_INFO "info" - - #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ - #define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */ #define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */ - #define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */ #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ - -#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */ -#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */ - +#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */ +#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */ #define ACPI_EC_COMMAND_READ 0x80 #define ACPI_EC_COMMAND_WRITE 0x81 #define ACPI_EC_BURST_ENABLE 0x82 #define ACPI_EC_BURST_DISABLE 0x83 #define ACPI_EC_COMMAND_QUERY 0x84 - #define EC_POLLING 0xFF #define EC_BURST 0x00 - - -static int acpi_ec_remove (struct acpi_device *device, int type); -static int acpi_ec_start (struct acpi_device *device); -static int acpi_ec_stop (struct acpi_device *device, int type); -static int acpi_ec_burst_add ( struct acpi_device *device); -static int acpi_ec_polling_add ( struct acpi_device *device); +static int acpi_ec_remove(struct acpi_device *device, int type); +static int acpi_ec_start(struct acpi_device *device); +static int acpi_ec_stop(struct acpi_device *device, int type); +static int acpi_ec_burst_add(struct acpi_device *device); +static int acpi_ec_polling_add(struct acpi_device *device); static struct acpi_driver acpi_ec_driver = { - .name = ACPI_EC_DRIVER_NAME, - .class = ACPI_EC_CLASS, - .ids = ACPI_EC_HID, - .ops = { - .add = acpi_ec_polling_add, - .remove = acpi_ec_remove, - .start = acpi_ec_start, - .stop = acpi_ec_stop, - }, + .name = ACPI_EC_DRIVER_NAME, + .class = ACPI_EC_CLASS, + .ids = ACPI_EC_HID, + .ops = { + .add = acpi_ec_polling_add, + .remove = acpi_ec_remove, + .start = acpi_ec_start, + .stop = acpi_ec_stop, + }, }; union acpi_ec { struct { - u32 mode; - acpi_handle handle; - unsigned long uid; - unsigned long gpe_bit; - struct acpi_generic_address status_addr; - struct acpi_generic_address command_addr; - struct acpi_generic_address data_addr; - unsigned long global_lock; + u32 mode; + acpi_handle handle; + unsigned long uid; + unsigned long gpe_bit; + struct acpi_generic_address status_addr; + struct acpi_generic_address command_addr; + struct acpi_generic_address data_addr; + unsigned long global_lock; } common; struct { - u32 mode; - acpi_handle handle; - unsigned long uid; - unsigned long gpe_bit; - struct acpi_generic_address status_addr; - struct acpi_generic_address command_addr; - struct acpi_generic_address data_addr; - unsigned long global_lock; - unsigned int expect_event; - atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort*/ - atomic_t pending_gpe; - struct semaphore sem; - wait_queue_head_t wait; - }burst; + u32 mode; + acpi_handle handle; + unsigned long uid; + unsigned long gpe_bit; + struct acpi_generic_address status_addr; + struct acpi_generic_address command_addr; + struct acpi_generic_address data_addr; + unsigned long global_lock; + unsigned int expect_event; + atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */ + atomic_t pending_gpe; + struct semaphore sem; + wait_queue_head_t wait; + } burst; struct { - u32 mode; - acpi_handle handle; - unsigned long uid; - unsigned long gpe_bit; - struct acpi_generic_address status_addr; - struct acpi_generic_address command_addr; - struct acpi_generic_address data_addr; - unsigned long global_lock; - spinlock_t lock; - }polling; + u32 mode; + acpi_handle handle; + unsigned long uid; + unsigned long gpe_bit; + struct acpi_generic_address status_addr; + struct acpi_generic_address command_addr; + struct acpi_generic_address data_addr; + unsigned long global_lock; + spinlock_t lock; + } polling; }; -static int acpi_ec_polling_wait ( union acpi_ec *ec, u8 event); +static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event); static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event); -static int acpi_ec_polling_read ( union acpi_ec *ec, u8 address, u32 *data); -static int acpi_ec_burst_read( union acpi_ec *ec, u8 address, u32 *data); -static int acpi_ec_polling_write ( union acpi_ec *ec, u8 address, u8 data); -static int acpi_ec_burst_write ( union acpi_ec *ec, u8 address, u8 data); -static int acpi_ec_polling_query ( union acpi_ec *ec, u32 *data); -static int acpi_ec_burst_query ( union acpi_ec *ec, u32 *data); -static void acpi_ec_gpe_polling_query ( void *ec_cxt); -static void acpi_ec_gpe_burst_query ( void *ec_cxt); -static u32 acpi_ec_gpe_polling_handler ( void *data); -static u32 acpi_ec_gpe_burst_handler ( void *data); +static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data); +static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data); +static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data); +static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data); +static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data); +static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data); +static void acpi_ec_gpe_polling_query(void *ec_cxt); +static void acpi_ec_gpe_burst_query(void *ec_cxt); +static u32 acpi_ec_gpe_polling_handler(void *data); +static u32 acpi_ec_gpe_burst_handler(void *data); static acpi_status __init -acpi_fake_ecdt_polling_callback ( - acpi_handle handle, - u32 Level, - void *context, - void **retval); +acpi_fake_ecdt_polling_callback(acpi_handle handle, + u32 Level, void *context, void **retval); static acpi_status __init -acpi_fake_ecdt_burst_callback ( - acpi_handle handle, - u32 Level, - void *context, - void **retval); - -static int __init -acpi_ec_polling_get_real_ecdt(void); -static int __init -acpi_ec_burst_get_real_ecdt(void); +acpi_fake_ecdt_burst_callback(acpi_handle handle, + u32 Level, void *context, void **retval); + +static int __init acpi_ec_polling_get_real_ecdt(void); +static int __init acpi_ec_burst_get_real_ecdt(void); /* If we find an EC via the ECDT, we need to keep a ptr to its context */ -static union acpi_ec *ec_ecdt; +static union acpi_ec *ec_ecdt; /* External interfaces use first EC only, so remember */ static struct acpi_device *first_ec; @@ -173,30 +155,24 @@ static int acpi_ec_polling_mode = EC_POLLING; static inline u32 acpi_ec_read_status(union acpi_ec *ec) { - u32 status = 0; + u32 status = 0; acpi_hw_low_level_read(8, &status, &ec->common.status_addr); return status; } -static int -acpi_ec_wait ( - union acpi_ec *ec, - u8 event) +static int acpi_ec_wait(union acpi_ec *ec, u8 event) { - if (acpi_ec_polling_mode) - return acpi_ec_polling_wait (ec, event); + if (acpi_ec_polling_mode) + return acpi_ec_polling_wait(ec, event); else - return acpi_ec_burst_wait (ec, event); + return acpi_ec_burst_wait(ec, event); } -static int -acpi_ec_polling_wait ( - union acpi_ec *ec, - u8 event) +static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event) { - u32 acpi_ec_status = 0; - u32 i = ACPI_EC_UDELAY_COUNT; + u32 acpi_ec_status = 0; + u32 i = ACPI_EC_UDELAY_COUNT; if (!ec) return -EINVAL; @@ -205,19 +181,21 @@ acpi_ec_polling_wait ( switch (event) { case ACPI_EC_EVENT_OBF: do { - acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr); + acpi_hw_low_level_read(8, &acpi_ec_status, + &ec->common.status_addr); if (acpi_ec_status & ACPI_EC_FLAG_OBF) return 0; udelay(ACPI_EC_UDELAY); - } while (--i>0); + } while (--i > 0); break; case ACPI_EC_EVENT_IBE: do { - acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr); + acpi_hw_low_level_read(8, &acpi_ec_status, + &ec->common.status_addr); if (!(acpi_ec_status & ACPI_EC_FLAG_IBF)) return 0; udelay(ACPI_EC_UDELAY); - } while (--i>0); + } while (--i > 0); break; default: return -EINVAL; @@ -227,7 +205,7 @@ acpi_ec_polling_wait ( } static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_ec_wait"); @@ -235,14 +213,15 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) smp_mb(); result = wait_event_interruptible_timeout(ec->burst.wait, - !ec->burst.expect_event, - msecs_to_jiffies(ACPI_EC_DELAY)); - + !ec->burst.expect_event, + msecs_to_jiffies + (ACPI_EC_DELAY)); + ec->burst.expect_event = 0; smp_mb(); - if (result < 0){ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR," result = %d ", result)); + if (result < 0) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, " result = %d ", result)); return_VALUE(result); } @@ -266,54 +245,49 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) return_VALUE(-ETIME); } - - -static int -acpi_ec_enter_burst_mode ( - union acpi_ec *ec) +static int acpi_ec_enter_burst_mode(union acpi_ec *ec) { - u32 tmp = 0; - int status = 0; + 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)){ - acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr); + if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { + acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, + &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); - if (status){ + if (status) { acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); return_VALUE(-EINVAL); } acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - if(tmp != 0x90 ) {/* Burst ACK byte*/ + if (tmp != 0x90) { /* Burst ACK byte */ return_VALUE(-EINVAL); } } - atomic_set(&ec->burst.leaving_burst , 0); + atomic_set(&ec->burst.leaving_burst, 0); return_VALUE(0); } -static int -acpi_ec_leave_burst_mode ( - union acpi_ec *ec) +static int acpi_ec_leave_burst_mode(union acpi_ec *ec) { - int status =0; + int status = 0; ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); - atomic_set(&ec->burst.leaving_burst , 1); + atomic_set(&ec->burst.leaving_burst, 1); status = acpi_ec_read_status(ec); - if (status != -EINVAL && - (status & ACPI_EC_FLAG_BURST)){ - acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr); + if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)) { + acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, + &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); - if (status){ + if (status) { acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "------->wait fail\n")); return_VALUE(-EINVAL); } acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); @@ -323,38 +297,26 @@ acpi_ec_leave_burst_mode ( return_VALUE(0); } -static int -acpi_ec_read ( - union acpi_ec *ec, - u8 address, - u32 *data) +static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data) { - if (acpi_ec_polling_mode) + if (acpi_ec_polling_mode) return acpi_ec_polling_read(ec, address, data); else return acpi_ec_burst_read(ec, address, data); } -static int -acpi_ec_write ( - union acpi_ec *ec, - u8 address, - u8 data) +static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data) { - if (acpi_ec_polling_mode) + if (acpi_ec_polling_mode) return acpi_ec_polling_write(ec, address, data); else return acpi_ec_burst_write(ec, address, data); } -static int -acpi_ec_polling_read ( - union acpi_ec *ec, - u8 address, - u32 *data) +static int acpi_ec_polling_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_status status = AE_OK; + int result = 0; + unsigned long flags = 0; + u32 glk = 0; ACPI_FUNCTION_TRACE("acpi_ec_read"); @@ -371,7 +333,8 @@ acpi_ec_polling_read ( spin_lock_irqsave(&ec->polling.lock, flags); - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, + &ec->common.command_addr); result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); if (result) goto end; @@ -384,9 +347,9 @@ acpi_ec_polling_read ( acpi_hw_low_level_read(8, data, &ec->common.data_addr); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", - *data, address)); - -end: + *data, address)); + + end: spin_unlock_irqrestore(&ec->polling.lock, flags); if (ec->common.global_lock) @@ -395,17 +358,12 @@ end: return_VALUE(result); } - -static int -acpi_ec_polling_write ( - union acpi_ec *ec, - u8 address, - u8 data) +static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data) { - int result = 0; - acpi_status status = AE_OK; - unsigned long flags = 0; - u32 glk = 0; + int result = 0; + acpi_status status = AE_OK; + unsigned long flags = 0; + u32 glk = 0; ACPI_FUNCTION_TRACE("acpi_ec_write"); @@ -420,7 +378,8 @@ acpi_ec_polling_write ( spin_lock_irqsave(&ec->polling.lock, flags); - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, + &ec->common.command_addr); result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); if (result) goto end; @@ -436,9 +395,9 @@ acpi_ec_polling_write ( goto end; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", - data, address)); + data, address)); -end: + end: spin_unlock_irqrestore(&ec->polling.lock, flags); if (ec->common.global_lock) @@ -447,21 +406,17 @@ end: return_VALUE(result); } -static int -acpi_ec_burst_read ( - union acpi_ec *ec, - u8 address, - u32 *data) +static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data) { - int status = 0; - u32 glk; + int status = 0; + u32 glk; ACPI_FUNCTION_TRACE("acpi_ec_read"); if (!ec || !data) return_VALUE(-EINVAL); -retry: + retry: *data = 0; if (ec->common.global_lock) { @@ -473,10 +428,11 @@ retry: WARN_ON(in_interrupt()); down(&ec->burst.sem); - if(acpi_ec_enter_burst_mode(ec)) + if (acpi_ec_enter_burst_mode(ec)) goto end; - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, + &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); if (status) { @@ -484,8 +440,8 @@ retry: } acpi_hw_low_level_write(8, address, &ec->common.data_addr); - status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); - if (status){ + status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); + if (status) { acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); goto end; } @@ -494,19 +450,19 @@ retry: acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", - *data, address)); - -end: + *data, address)); + + end: acpi_ec_leave_burst_mode(ec); up(&ec->burst.sem); if (ec->common.global_lock) acpi_release_global_lock(glk); - if(atomic_read(&ec->burst.leaving_burst) == 2){ - ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); - while(atomic_read(&ec->burst.pending_gpe)){ - msleep(1); + if (atomic_read(&ec->burst.leaving_burst) == 2) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aborted, retry ...\n")); + while (atomic_read(&ec->burst.pending_gpe)) { + msleep(1); } acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); goto retry; @@ -515,22 +471,17 @@ end: return_VALUE(status); } - -static int -acpi_ec_burst_write ( - union acpi_ec *ec, - u8 address, - u8 data) +static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data) { - int status = 0; - u32 glk; - u32 tmp; + int status = 0; + u32 glk; + u32 tmp; ACPI_FUNCTION_TRACE("acpi_ec_write"); if (!ec) return_VALUE(-EINVAL); -retry: + retry: if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) @@ -540,32 +491,33 @@ retry: WARN_ON(in_interrupt()); down(&ec->burst.sem); - if(acpi_ec_enter_burst_mode(ec)) + if (acpi_ec_enter_burst_mode(ec)) goto end; status = acpi_ec_read_status(ec); - if (status != -EINVAL && - !(status & ACPI_EC_FLAG_BURST)){ - acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr); + if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { + acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, + &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); if (status) goto end; acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); - if(tmp != 0x90 ) /* Burst ACK byte*/ + if (tmp != 0x90) /* Burst ACK byte */ goto end; } - /*Now we are in burst mode*/ + /*Now we are in burst mode */ - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, + &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - if (status){ + if (status) { goto end; } acpi_hw_low_level_write(8, address, &ec->common.data_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); - if (status){ + if (status) { acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); goto end; } @@ -577,19 +529,19 @@ retry: goto end; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", - data, address)); + data, address)); -end: + end: acpi_ec_leave_burst_mode(ec); up(&ec->burst.sem); if (ec->common.global_lock) acpi_release_global_lock(glk); - if(atomic_read(&ec->burst.leaving_burst) == 2){ - ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); - while(atomic_read(&ec->burst.pending_gpe)){ - msleep(1); + if (atomic_read(&ec->burst.leaving_burst) == 2) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aborted, retry ...\n")); + while (atomic_read(&ec->burst.pending_gpe)) { + msleep(1); } acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); goto retry; @@ -601,8 +553,7 @@ end: /* * Externally callable EC access functions. For now, assume 1 EC only */ -int -ec_read(u8 addr, u8 *val) +int ec_read(u8 addr, u8 * val) { union acpi_ec *ec; int err; @@ -618,14 +569,13 @@ ec_read(u8 addr, u8 *val) if (!err) { *val = temp_data; return 0; - } - else + } else return err; } + EXPORT_SYMBOL(ec_read); -int -ec_write(u8 addr, u8 val) +int ec_write(u8 addr, u8 val) { union acpi_ec *ec; int err; @@ -639,27 +589,22 @@ ec_write(u8 addr, u8 val) return err; } + EXPORT_SYMBOL(ec_write); -static int -acpi_ec_query ( - union acpi_ec *ec, - u32 *data) +static int acpi_ec_query(union acpi_ec *ec, u32 * data) { - if (acpi_ec_polling_mode) + if (acpi_ec_polling_mode) return acpi_ec_polling_query(ec, data); else return acpi_ec_burst_query(ec, data); } -static int -acpi_ec_polling_query ( - union acpi_ec *ec, - u32 *data) +static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data) { - int result = 0; - acpi_status status = AE_OK; - unsigned long flags = 0; - u32 glk = 0; + int result = 0; + acpi_status status = AE_OK; + unsigned long flags = 0; + u32 glk = 0; ACPI_FUNCTION_TRACE("acpi_ec_query"); @@ -681,7 +626,8 @@ acpi_ec_polling_query ( */ spin_lock_irqsave(&ec->polling.lock, flags); - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, + &ec->common.command_addr); result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); if (result) goto end; @@ -690,7 +636,7 @@ acpi_ec_polling_query ( if (!*data) result = -ENODATA; -end: + end: spin_unlock_irqrestore(&ec->polling.lock, flags); if (ec->common.global_lock) @@ -698,13 +644,10 @@ end: return_VALUE(result); } -static int -acpi_ec_burst_query ( - union acpi_ec *ec, - u32 *data) +static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data) { - int status = 0; - u32 glk; + int status = 0; + u32 glk; ACPI_FUNCTION_TRACE("acpi_ec_query"); @@ -719,16 +662,17 @@ acpi_ec_burst_query ( } down(&ec->burst.sem); - if(acpi_ec_enter_burst_mode(ec)) + if (acpi_ec_enter_burst_mode(ec)) goto end; /* * Query the EC to find out which _Qxx method we need to evaluate. * Note that successful completion of the query causes the ACPI_EC_SCI * bit to be cleared (and thus clearing the interrupt source). */ - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, + &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); - if (status){ + if (status) { acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); goto end; } @@ -738,51 +682,47 @@ acpi_ec_burst_query ( if (!*data) status = -ENODATA; -end: + end: acpi_ec_leave_burst_mode(ec); up(&ec->burst.sem); if (ec->common.global_lock) acpi_release_global_lock(glk); - if(atomic_read(&ec->burst.leaving_burst) == 2){ - ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); + if (atomic_read(&ec->burst.leaving_burst) == 2) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aborted, retry ...\n")); acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); status = -ENODATA; } return_VALUE(status); } - /* -------------------------------------------------------------------------- Event Management -------------------------------------------------------------------------- */ union acpi_ec_query_data { - acpi_handle handle; - u8 data; + acpi_handle handle; + u8 data; }; -static void -acpi_ec_gpe_query ( - void *ec_cxt) +static void acpi_ec_gpe_query(void *ec_cxt) { - if (acpi_ec_polling_mode) + if (acpi_ec_polling_mode) acpi_ec_gpe_polling_query(ec_cxt); else acpi_ec_gpe_burst_query(ec_cxt); } -static void -acpi_ec_gpe_polling_query ( - void *ec_cxt) +static void acpi_ec_gpe_polling_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'}; - const char hex[] = {'0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F'}; + 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' }; + const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' + }; ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); @@ -812,19 +752,18 @@ acpi_ec_gpe_polling_query ( acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); -end: + end: acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); } -static void -acpi_ec_gpe_burst_query ( - void *ec_cxt) +static void acpi_ec_gpe_burst_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'}; - const char hex[] = {'0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F'}; + union acpi_ec *ec = (union acpi_ec *)ec_cxt; + u32 value; + int result = -ENODATA; + static char object_name[5] = { '_', 'Q', '0', '0', '\0' }; + const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' + }; ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); @@ -840,26 +779,22 @@ acpi_ec_gpe_burst_query ( ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); -end: + end: atomic_dec(&ec->burst.pending_gpe); return; } -static u32 -acpi_ec_gpe_handler ( - void *data) +static u32 acpi_ec_gpe_handler(void *data) { - if (acpi_ec_polling_mode) + if (acpi_ec_polling_mode) return acpi_ec_gpe_polling_handler(data); else - return acpi_ec_gpe_burst_handler(data); + return acpi_ec_gpe_burst_handler(data); } -static u32 -acpi_ec_gpe_polling_handler ( - void *data) +static u32 acpi_ec_gpe_polling_handler(void *data) { - acpi_status status = AE_OK; - union acpi_ec *ec = (union acpi_ec *) data; + acpi_status status = AE_OK; + union acpi_ec *ec = (union acpi_ec *)data; if (!ec) return ACPI_INTERRUPT_NOT_HANDLED; @@ -867,20 +802,18 @@ acpi_ec_gpe_polling_handler ( acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, - acpi_ec_gpe_query, ec); + acpi_ec_gpe_query, ec); if (status == AE_OK) return ACPI_INTERRUPT_HANDLED; else return ACPI_INTERRUPT_NOT_HANDLED; } -static u32 -acpi_ec_gpe_burst_handler ( - void *data) +static u32 acpi_ec_gpe_burst_handler(void *data) { - acpi_status status = AE_OK; - u32 value; - union acpi_ec *ec = (union acpi_ec *) data; + acpi_status status = AE_OK; + u32 value; + union acpi_ec *ec = (union acpi_ec *)data; if (!ec) return ACPI_INTERRUPT_NOT_HANDLED; @@ -889,39 +822,39 @@ acpi_ec_gpe_burst_handler ( value = acpi_ec_read_status(ec); - if((value & ACPI_EC_FLAG_IBF) && - !(value & ACPI_EC_FLAG_BURST) && - (atomic_read(&ec->burst.leaving_burst) == 0)) { - /* - * the embedded controller disables - * burst mode for any reason other - * than the burst disable command - * to process critical event. - */ - atomic_set(&ec->burst.leaving_burst , 2); /* block current pending transaction - and retry */ + if ((value & ACPI_EC_FLAG_IBF) && + !(value & ACPI_EC_FLAG_BURST) && + (atomic_read(&ec->burst.leaving_burst) == 0)) { + /* + * the embedded controller disables + * burst mode for any reason other + * than the burst disable command + * to process critical event. + */ + atomic_set(&ec->burst.leaving_burst, 2); /* block current pending transaction + and retry */ wake_up(&ec->burst.wait); - }else { + } else { if ((ec->burst.expect_event == ACPI_EC_EVENT_OBF && - (value & ACPI_EC_FLAG_OBF)) || - (ec->burst.expect_event == ACPI_EC_EVENT_IBE && - !(value & ACPI_EC_FLAG_IBF))) { + (value & ACPI_EC_FLAG_OBF)) || + (ec->burst.expect_event == ACPI_EC_EVENT_IBE && + !(value & ACPI_EC_FLAG_IBF))) { ec->burst.expect_event = 0; wake_up(&ec->burst.wait); return ACPI_INTERRUPT_HANDLED; } } - if (value & ACPI_EC_FLAG_SCI){ - atomic_add(1, &ec->burst.pending_gpe) ; + if (value & ACPI_EC_FLAG_SCI) { + atomic_add(1, &ec->burst.pending_gpe); status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, - acpi_ec_gpe_query, ec); + acpi_ec_gpe_query, ec); return status == AE_OK ? - ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; - } + ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; + } acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); return status == AE_OK ? - ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; + ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; } /* -------------------------------------------------------------------------- @@ -929,37 +862,31 @@ acpi_ec_gpe_burst_handler ( -------------------------------------------------------------------------- */ static acpi_status -acpi_ec_space_setup ( - acpi_handle region_handle, - u32 function, - void *handler_context, - void **return_context) +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 : NULL; + *return_context = (function != ACPI_REGION_DEACTIVATE) ? + handler_context : NULL; return AE_OK; } - static acpi_status -acpi_ec_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context) +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; + int result = 0; + union acpi_ec *ec = NULL; + u64 temp = *value; + acpi_integer f_v = 0; + int i = 0; ACPI_FUNCTION_TRACE("acpi_ec_space_handler"); @@ -967,17 +894,18 @@ acpi_ec_space_handler ( return_VALUE(AE_BAD_PARAMETER); if (bit_width != 8 && acpi_strict) { - printk(KERN_WARNING PREFIX "acpi_ec_space_handler: bit_width should be 8\n"); + printk(KERN_WARNING PREFIX + "acpi_ec_space_handler: bit_width should be 8\n"); return_VALUE(AE_BAD_PARAMETER); } - ec = (union acpi_ec *) handler_context; + ec = (union acpi_ec *)handler_context; -next_byte: + next_byte: switch (function) { case ACPI_READ: temp = 0; - result = acpi_ec_read(ec, (u8) address, (u32 *)&temp); + result = acpi_ec_read(ec, (u8) address, (u32 *) & temp); break; case ACPI_WRITE: result = acpi_ec_write(ec, (u8) address, (u8) temp); @@ -1004,8 +932,7 @@ next_byte: *value = f_v; } - -out: + out: switch (result) { case -EINVAL: return_VALUE(AE_BAD_PARAMETER); @@ -1021,18 +948,15 @@ out: } } - /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ -static struct proc_dir_entry *acpi_ec_dir; +static struct proc_dir_entry *acpi_ec_dir; - -static int -acpi_ec_read_info (struct seq_file *seq, void *offset) +static int acpi_ec_read_info(struct seq_file *seq, void *offset) { - union acpi_ec *ec = (union acpi_ec *) seq->private; + union acpi_ec *ec = (union acpi_ec *)seq->private; ACPI_FUNCTION_TRACE("acpi_ec_read_info"); @@ -1040,14 +964,15 @@ acpi_ec_read_info (struct seq_file *seq, void *offset) goto end; seq_printf(seq, "gpe bit: 0x%02x\n", - (u32) ec->common.gpe_bit); + (u32) ec->common.gpe_bit); seq_printf(seq, "ports: 0x%02x, 0x%02x\n", - (u32) ec->common.status_addr.address, (u32) ec->common.data_addr.address); + (u32) ec->common.status_addr.address, + (u32) ec->common.data_addr.address); seq_printf(seq, "use global lock: %s\n", - ec->common.global_lock?"yes":"no"); + ec->common.global_lock ? "yes" : "no"); acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); -end: + end: return_VALUE(0); } @@ -1057,34 +982,32 @@ static int acpi_ec_info_open_fs(struct inode *inode, struct file *file) } static struct file_operations acpi_ec_info_ops = { - .open = acpi_ec_info_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_ec_info_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, .owner = THIS_MODULE, }; -static int -acpi_ec_add_fs ( - struct acpi_device *device) +static int acpi_ec_add_fs(struct acpi_device *device) { - struct proc_dir_entry *entry = NULL; + 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); + acpi_ec_dir); if (!acpi_device_dir(device)) return_VALUE(-ENODEV); } entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, - acpi_device_dir(device)); + acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Unable to create '%s' fs entry\n", - ACPI_EC_FILE_INFO)); + "Unable to create '%s' fs entry\n", + ACPI_EC_FILE_INFO)); else { entry->proc_fops = &acpi_ec_info_ops; entry->data = acpi_driver_data(device); @@ -1094,10 +1017,7 @@ acpi_ec_add_fs ( return_VALUE(0); } - -static int -acpi_ec_remove_fs ( - struct acpi_device *device) +static int acpi_ec_remove_fs(struct acpi_device *device) { ACPI_FUNCTION_TRACE("acpi_ec_remove_fs"); @@ -1110,20 +1030,16 @@ acpi_ec_remove_fs ( return_VALUE(0); } - /* -------------------------------------------------------------------------- Driver Interface -------------------------------------------------------------------------- */ - -static int -acpi_ec_polling_add ( - struct acpi_device *device) +static int acpi_ec_polling_add(struct acpi_device *device) { - int result = 0; - acpi_status status = AE_OK; - union acpi_ec *ec = NULL; - unsigned long uid; + int result = 0; + acpi_status status = AE_OK; + union acpi_ec *ec = NULL; + unsigned long uid; ACPI_FUNCTION_TRACE("acpi_ec_add"); @@ -1143,26 +1059,31 @@ acpi_ec_polling_add ( acpi_driver_data(device) = ec; /* Use the global lock for all EC transactions? */ - acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock); + acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, + &ec->common.global_lock); /* If our UID matches the UID for the ECDT-enumerated EC, - we now have the *real* EC info, so kill the makeshift one.*/ + we now have the *real* EC info, so kill the makeshift one. */ acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); if (ec_ecdt && ec_ecdt->common.uid == uid) { acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); - - acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler); + ACPI_ADR_SPACE_EC, + &acpi_ec_space_handler); + + acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, + &acpi_ec_gpe_handler); kfree(ec_ecdt); } /* Get GPE bit assignment (EC events). */ /* TODO: Add support for _GPE returning a package */ - status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); + status = + acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, + &ec->common.gpe_bit); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error obtaining GPE bit assignment\n")); + "Error obtaining GPE bit assignment\n")); result = -ENODEV; goto end; } @@ -1172,26 +1093,24 @@ acpi_ec_polling_add ( goto end; printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", - acpi_device_name(device), acpi_device_bid(device), - (u32) ec->common.gpe_bit); + acpi_device_name(device), acpi_device_bid(device), + (u32) ec->common.gpe_bit); if (!first_ec) first_ec = device; -end: + end: if (result) kfree(ec); return_VALUE(result); } -static int -acpi_ec_burst_add ( - struct acpi_device *device) +static int acpi_ec_burst_add(struct acpi_device *device) { - int result = 0; - acpi_status status = AE_OK; - union acpi_ec *ec = NULL; - unsigned long uid; + int result = 0; + acpi_status status = AE_OK; + union acpi_ec *ec = NULL; + unsigned long uid; ACPI_FUNCTION_TRACE("acpi_ec_add"); @@ -1205,35 +1124,40 @@ acpi_ec_burst_add ( ec->common.handle = device->handle; ec->common.uid = -1; - atomic_set(&ec->burst.pending_gpe, 0); - atomic_set(&ec->burst.leaving_burst , 1); - init_MUTEX(&ec->burst.sem); - init_waitqueue_head(&ec->burst.wait); + atomic_set(&ec->burst.pending_gpe, 0); + atomic_set(&ec->burst.leaving_burst, 1); + init_MUTEX(&ec->burst.sem); + init_waitqueue_head(&ec->burst.wait); strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_EC_CLASS); acpi_driver_data(device) = ec; /* Use the global lock for all EC transactions? */ - acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock); + acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, + &ec->common.global_lock); /* If our UID matches the UID for the ECDT-enumerated EC, - we now have the *real* EC info, so kill the makeshift one.*/ + we now have the *real* EC info, so kill the makeshift one. */ acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); if (ec_ecdt && ec_ecdt->common.uid == uid) { acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); + ACPI_ADR_SPACE_EC, + &acpi_ec_space_handler); - acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler); + acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, + &acpi_ec_gpe_handler); kfree(ec_ecdt); } /* Get GPE bit assignment (EC events). */ /* TODO: Add support for _GPE returning a package */ - status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); + status = + acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, + &ec->common.gpe_bit); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error obtaining GPE bit assignment\n")); + "Error obtaining GPE bit assignment\n")); result = -ENODEV; goto end; } @@ -1243,26 +1167,22 @@ acpi_ec_burst_add ( goto end; printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", - acpi_device_name(device), acpi_device_bid(device), - (u32) ec->common.gpe_bit); + acpi_device_name(device), acpi_device_bid(device), + (u32) ec->common.gpe_bit); if (!first_ec) first_ec = device; -end: + end: if (result) kfree(ec); return_VALUE(result); } - -static int -acpi_ec_remove ( - struct acpi_device *device, - int type) +static int acpi_ec_remove(struct acpi_device *device, int type) { - union acpi_ec *ec = NULL; + union acpi_ec *ec = NULL; ACPI_FUNCTION_TRACE("acpi_ec_remove"); @@ -1278,13 +1198,10 @@ acpi_ec_remove ( return_VALUE(0); } - static acpi_status -acpi_ec_io_ports ( - struct acpi_resource *resource, - void *context) +acpi_ec_io_ports(struct acpi_resource *resource, void *context) { - union acpi_ec *ec = (union acpi_ec *) context; + union acpi_ec *ec = (union acpi_ec *)context; struct acpi_generic_address *addr; if (resource->id != ACPI_RSTYPE_IO) { @@ -1312,13 +1229,10 @@ acpi_ec_io_ports ( return AE_OK; } - -static int -acpi_ec_start ( - struct acpi_device *device) +static int acpi_ec_start(struct acpi_device *device) { - acpi_status status = AE_OK; - union acpi_ec *ec = NULL; + acpi_status status = AE_OK; + union acpi_ec *ec = NULL; ACPI_FUNCTION_TRACE("acpi_ec_start"); @@ -1334,49 +1248,50 @@ acpi_ec_start ( * Get I/O port addresses. Convert to GAS format. */ status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS, - acpi_ec_io_ports, ec); - if (ACPI_FAILURE(status) || ec->common.command_addr.register_bit_width == 0) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting I/O port addresses")); + acpi_ec_io_ports, ec); + if (ACPI_FAILURE(status) + || ec->common.command_addr.register_bit_width == 0) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error getting I/O port addresses")); return_VALUE(-ENODEV); } ec->common.status_addr = ec->common.command_addr; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n", - (u32) ec->common.gpe_bit, (u32) ec->common.command_addr.address, - (u32) ec->common.data_addr.address)); - + (u32) ec->common.gpe_bit, + (u32) ec->common.command_addr.address, + (u32) ec->common.data_addr.address)); /* * Install GPE handler */ status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit, - ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec); + ACPI_GPE_EDGE_TRIGGERED, + &acpi_ec_gpe_handler, ec); if (ACPI_FAILURE(status)) { return_VALUE(-ENODEV); } - acpi_set_gpe_type (NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); - acpi_enable_gpe (NULL, ec->common.gpe_bit, ACPI_NOT_ISR); + acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); + acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - status = acpi_install_address_space_handler (ec->common.handle, - ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, - &acpi_ec_space_setup, ec); + status = acpi_install_address_space_handler(ec->common.handle, + ACPI_ADR_SPACE_EC, + &acpi_ec_space_handler, + &acpi_ec_space_setup, ec); if (ACPI_FAILURE(status)) { - acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); + acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, + &acpi_ec_gpe_handler); return_VALUE(-ENODEV); } return_VALUE(AE_OK); } - -static int -acpi_ec_stop ( - struct acpi_device *device, - int type) +static int acpi_ec_stop(struct acpi_device *device, int type) { - acpi_status status = AE_OK; - union acpi_ec *ec = NULL; + acpi_status status = AE_OK; + union acpi_ec *ec = NULL; ACPI_FUNCTION_TRACE("acpi_ec_stop"); @@ -1386,11 +1301,14 @@ acpi_ec_stop ( ec = acpi_driver_data(device); status = acpi_remove_address_space_handler(ec->common.handle, - ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); + ACPI_ADR_SPACE_EC, + &acpi_ec_space_handler); if (ACPI_FAILURE(status)) return_VALUE(-ENODEV); - status = acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); + status = + acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, + &acpi_ec_gpe_handler); if (ACPI_FAILURE(status)) return_VALUE(-ENODEV); @@ -1398,32 +1316,26 @@ acpi_ec_stop ( } static acpi_status __init -acpi_fake_ecdt_callback ( - acpi_handle handle, - u32 Level, - void *context, - void **retval) +acpi_fake_ecdt_callback(acpi_handle handle, + u32 Level, void *context, void **retval) { if (acpi_ec_polling_mode) return acpi_fake_ecdt_polling_callback(handle, - Level, context, retval); + Level, context, retval); else return acpi_fake_ecdt_burst_callback(handle, - Level, context, retval); + Level, context, retval); } static acpi_status __init -acpi_fake_ecdt_polling_callback ( - acpi_handle handle, - u32 Level, - void *context, - void **retval) +acpi_fake_ecdt_polling_callback(acpi_handle handle, + u32 Level, void *context, void **retval) { - acpi_status status; + acpi_status status; status = acpi_walk_resources(handle, METHOD_NAME__CRS, - acpi_ec_io_ports, ec_ecdt); + acpi_ec_io_ports, ec_ecdt); if (ACPI_FAILURE(status)) return status; ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; @@ -1431,33 +1343,33 @@ acpi_fake_ecdt_polling_callback ( ec_ecdt->common.uid = -1; acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); - status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit); + status = + acpi_evaluate_integer(handle, "_GPE", NULL, + &ec_ecdt->common.gpe_bit); if (ACPI_FAILURE(status)) return status; spin_lock_init(&ec_ecdt->polling.lock); ec_ecdt->common.global_lock = TRUE; ec_ecdt->common.handle = handle; - printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", - (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address, - (u32) ec_ecdt->common.data_addr.address); + printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", + (u32) ec_ecdt->common.gpe_bit, + (u32) ec_ecdt->common.command_addr.address, + (u32) ec_ecdt->common.data_addr.address); return AE_CTRL_TERMINATE; } static acpi_status __init -acpi_fake_ecdt_burst_callback ( - acpi_handle handle, - u32 Level, - void *context, - void **retval) +acpi_fake_ecdt_burst_callback(acpi_handle handle, + u32 Level, void *context, void **retval) { - acpi_status status; + acpi_status status; init_MUTEX(&ec_ecdt->burst.sem); init_waitqueue_head(&ec_ecdt->burst.wait); status = acpi_walk_resources(handle, METHOD_NAME__CRS, - acpi_ec_io_ports, ec_ecdt); + acpi_ec_io_ports, ec_ecdt); if (ACPI_FAILURE(status)) return status; ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; @@ -1465,15 +1377,18 @@ acpi_fake_ecdt_burst_callback ( ec_ecdt->common.uid = -1; acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); - status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit); + status = + acpi_evaluate_integer(handle, "_GPE", NULL, + &ec_ecdt->common.gpe_bit); if (ACPI_FAILURE(status)) return status; ec_ecdt->common.global_lock = TRUE; ec_ecdt->common.handle = handle; - printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", - (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address, - (u32) ec_ecdt->common.data_addr.address); + printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", + (u32) ec_ecdt->common.gpe_bit, + (u32) ec_ecdt->common.command_addr.address, + (u32) ec_ecdt->common.data_addr.address); return AE_CTRL_TERMINATE; } @@ -1488,11 +1403,10 @@ acpi_fake_ecdt_burst_callback ( * op region (since _REG isn't invoked yet). The assumption is true for * all systems found. */ -static int __init -acpi_ec_fake_ecdt(void) +static int __init acpi_ec_fake_ecdt(void) { - acpi_status status; - int ret = 0; + acpi_status status; + int ret = 0; printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); @@ -1503,10 +1417,8 @@ acpi_ec_fake_ecdt(void) } memset(ec_ecdt, 0, sizeof(union acpi_ec)); - status = acpi_get_devices (ACPI_EC_HID, - acpi_fake_ecdt_callback, - NULL, - NULL); + status = acpi_get_devices(ACPI_EC_HID, + acpi_fake_ecdt_callback, NULL, NULL); if (ACPI_FAILURE(status)) { kfree(ec_ecdt); ec_ecdt = NULL; @@ -1514,13 +1426,12 @@ acpi_ec_fake_ecdt(void) goto error; } return 0; -error: + error: printk(KERN_ERR PREFIX "Can't make an fake ECDT\n"); return ret; } -static int __init -acpi_ec_get_real_ecdt(void) +static int __init acpi_ec_get_real_ecdt(void) { if (acpi_ec_polling_mode) return acpi_ec_polling_get_real_ecdt(); @@ -1528,14 +1439,14 @@ acpi_ec_get_real_ecdt(void) return acpi_ec_burst_get_real_ecdt(); } -static int __init -acpi_ec_polling_get_real_ecdt(void) +static int __init acpi_ec_polling_get_real_ecdt(void) { - acpi_status status; - struct acpi_table_ecdt *ecdt_ptr; + 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); + status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, + (struct acpi_table_header **) + &ecdt_ptr); if (ACPI_FAILURE(status)) return -ENODEV; @@ -1558,13 +1469,14 @@ acpi_ec_polling_get_real_ecdt(void) ec_ecdt->common.global_lock = TRUE; ec_ecdt->common.uid = ecdt_ptr->uid; - status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); + status = + acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); if (ACPI_FAILURE(status)) { goto error; } return 0; -error: + error: printk(KERN_ERR PREFIX "Could not use ECDT\n"); kfree(ec_ecdt); ec_ecdt = NULL; @@ -1572,15 +1484,14 @@ error: return -ENODEV; } - -static int __init -acpi_ec_burst_get_real_ecdt(void) +static int __init acpi_ec_burst_get_real_ecdt(void) { - acpi_status status; - struct acpi_table_ecdt *ecdt_ptr; + 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); + (struct acpi_table_header **) + &ecdt_ptr); if (ACPI_FAILURE(status)) return -ENODEV; @@ -1594,8 +1505,8 @@ acpi_ec_burst_get_real_ecdt(void) return -ENOMEM; memset(ec_ecdt, 0, sizeof(union acpi_ec)); - init_MUTEX(&ec_ecdt->burst.sem); - init_waitqueue_head(&ec_ecdt->burst.wait); + init_MUTEX(&ec_ecdt->burst.sem); + init_waitqueue_head(&ec_ecdt->burst.wait); ec_ecdt->common.command_addr = ecdt_ptr->ec_control; ec_ecdt->common.status_addr = ecdt_ptr->ec_control; ec_ecdt->common.data_addr = ecdt_ptr->ec_data; @@ -1604,13 +1515,14 @@ acpi_ec_burst_get_real_ecdt(void) ec_ecdt->common.global_lock = TRUE; ec_ecdt->common.uid = ecdt_ptr->uid; - status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); + status = + acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); if (ACPI_FAILURE(status)) { goto error; } return 0; -error: + error: printk(KERN_ERR PREFIX "Could not use ECDT\n"); kfree(ec_ecdt); ec_ecdt = NULL; @@ -1619,11 +1531,10 @@ error: } static int __initdata acpi_fake_ecdt_enabled; -int __init -acpi_ec_ecdt_probe (void) +int __init acpi_ec_ecdt_probe(void) { - acpi_status status; - int ret; + acpi_status status; + int ret; ret = acpi_ec_get_real_ecdt(); /* Try to make a fake ECDT */ @@ -1638,26 +1549,28 @@ acpi_ec_ecdt_probe (void) * Install GPE handler */ status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit, - ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, - ec_ecdt); + ACPI_GPE_EDGE_TRIGGERED, + &acpi_ec_gpe_handler, ec_ecdt); if (ACPI_FAILURE(status)) { goto error; } - acpi_set_gpe_type (NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); - acpi_enable_gpe (NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR); - - status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, - &acpi_ec_space_setup, ec_ecdt); + acpi_set_gpe_type(NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); + acpi_enable_gpe(NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR); + + status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT, + ACPI_ADR_SPACE_EC, + &acpi_ec_space_handler, + &acpi_ec_space_setup, + ec_ecdt); if (ACPI_FAILURE(status)) { acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, - &acpi_ec_gpe_handler); + &acpi_ec_gpe_handler); goto error; } return 0; -error: + error: printk(KERN_ERR PREFIX "Could not use ECDT\n"); kfree(ec_ecdt); ec_ecdt = NULL; @@ -1665,10 +1578,9 @@ error: return -ENODEV; } - -static int __init acpi_ec_init (void) +static int __init acpi_ec_init(void) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_ec_init"); @@ -1693,8 +1605,7 @@ subsys_initcall(acpi_ec_init); /* EC driver currently not unloadable */ #if 0 -static void __exit -acpi_ec_exit (void) +static void __exit acpi_ec_exit(void) { ACPI_FUNCTION_TRACE("acpi_ec_exit"); @@ -1704,7 +1615,7 @@ acpi_ec_exit (void) return_VOID; } -#endif /* 0 */ +#endif /* 0 */ static int __init acpi_fake_ecdt_setup(char *str) { @@ -1727,8 +1638,8 @@ static int __init acpi_ec_set_polling_mode(char *str) acpi_ec_polling_mode = EC_POLLING; acpi_ec_driver.ops.add = acpi_ec_polling_add; } - printk(KERN_INFO PREFIX "EC %s mode.\n", - burst ? "burst": "polling"); + printk(KERN_INFO PREFIX "EC %s mode.\n", burst ? "burst" : "polling"); return 0; } + __setup("ec_burst=", acpi_ec_set_polling_mode); diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index ce8d3ee..bfa8b76 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c @@ -13,16 +13,15 @@ #include #define _COMPONENT ACPI_SYSTEM_COMPONENT -ACPI_MODULE_NAME ("event") +ACPI_MODULE_NAME("event") /* Global vars for handling event proc entry */ static DEFINE_SPINLOCK(acpi_system_event_lock); -int event_is_open = 0; -extern struct list_head acpi_bus_event_list; -extern wait_queue_head_t acpi_bus_event_queue; +int event_is_open = 0; +extern struct list_head acpi_bus_event_list; +extern wait_queue_head_t acpi_bus_event_queue; -static int -acpi_system_open_event(struct inode *inode, struct file *file) +static int acpi_system_open_event(struct inode *inode, struct file *file) { spin_lock_irq(&acpi_system_event_lock); @@ -34,20 +33,20 @@ acpi_system_open_event(struct inode *inode, struct file *file) spin_unlock_irq(&acpi_system_event_lock); return 0; -out_busy: + out_busy: spin_unlock_irq(&acpi_system_event_lock); return -EBUSY; } static ssize_t -acpi_system_read_event(struct file *file, char __user *buffer, size_t count, loff_t *ppos) +acpi_system_read_event(struct file *file, char __user * buffer, size_t count, + loff_t * ppos) { - int result = 0; - struct acpi_bus_event event; - static char str[ACPI_MAX_STRING]; - static int chars_remaining = 0; - static char *ptr; - + int result = 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"); @@ -63,10 +62,12 @@ acpi_system_read_event(struct file *file, char __user *buffer, size_t count, lof return_VALUE(-EIO); } - chars_remaining = sprintf(str, "%s %s %08x %08x\n", - event.device_class?event.device_class:"", - event.bus_id?event.bus_id:"", - event.type, event.data); + chars_remaining = sprintf(str, "%s %s %08x %08x\n", + event.device_class ? event. + device_class : "", + event.bus_id ? event. + bus_id : "", event.type, + event.data); ptr = str; } @@ -84,17 +85,15 @@ acpi_system_read_event(struct file *file, char __user *buffer, size_t count, lof return_VALUE(count); } -static int -acpi_system_close_event(struct inode *inode, struct file *file) +static int acpi_system_close_event(struct inode *inode, struct file *file) { - spin_lock_irq (&acpi_system_event_lock); + spin_lock_irq(&acpi_system_event_lock); event_is_open = 0; - spin_unlock_irq (&acpi_system_event_lock); + spin_unlock_irq(&acpi_system_event_lock); return 0; } -static unsigned int -acpi_system_poll_event(struct file *file, poll_table *wait) +static unsigned int acpi_system_poll_event(struct file *file, poll_table * wait) { poll_wait(file, &acpi_bus_event_queue, wait); if (!list_empty(&acpi_bus_event_list)) @@ -103,15 +102,15 @@ acpi_system_poll_event(struct file *file, poll_table *wait) } static struct file_operations acpi_system_event_ops = { - .open = acpi_system_open_event, - .read = acpi_system_read_event, - .release = acpi_system_close_event, - .poll = acpi_system_poll_event, + .open = acpi_system_open_event, + .read = acpi_system_read_event, + .release = acpi_system_close_event, + .poll = acpi_system_poll_event, }; static int __init acpi_event_init(void) { - struct proc_dir_entry *entry; + struct proc_dir_entry *entry; int error = 0; ACPI_FUNCTION_TRACE("acpi_event_init"); @@ -124,8 +123,9 @@ static int __init acpi_event_init(void) if (entry) entry->proc_fops = &acpi_system_event_ops; else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' proc fs entry\n","event" )); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' proc fs entry\n", + "event")); error = -EFAULT; } return_VALUE(error); diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c index dd3a72a..842d1e3 100644 --- a/drivers/acpi/events/evevent.c +++ b/drivers/acpi/events/evevent.c @@ -45,18 +45,12 @@ #include #define _COMPONENT ACPI_EVENTS - ACPI_MODULE_NAME ("evevent") +ACPI_MODULE_NAME("evevent") /* Local prototypes */ +static acpi_status acpi_ev_fixed_event_initialize(void); -static acpi_status -acpi_ev_fixed_event_initialize ( - void); - -static u32 -acpi_ev_fixed_event_dispatch ( - u32 event); - +static u32 acpi_ev_fixed_event_dispatch(u32 event); /******************************************************************************* * @@ -70,21 +64,17 @@ acpi_ev_fixed_event_dispatch ( * ******************************************************************************/ -acpi_status -acpi_ev_initialize_events ( - void) +acpi_status acpi_ev_initialize_events(void) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_initialize_events"); + acpi_status status; + ACPI_FUNCTION_TRACE("ev_initialize_events"); /* Make sure we have ACPI tables */ if (!acpi_gbl_DSDT) { - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No ACPI tables present!\n")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No ACPI tables present!\n")); + return_ACPI_STATUS(AE_NO_ACPI_TABLES); } /* @@ -92,26 +82,22 @@ acpi_ev_initialize_events ( * enabling SCIs to prevent interrupts from occurring before the handlers are * installed. */ - status = acpi_ev_fixed_event_initialize (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "Unable to initialize fixed events, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_ev_fixed_event_initialize(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Unable to initialize fixed events, %s\n", + acpi_format_exception(status))); + return_ACPI_STATUS(status); } - status = acpi_ev_gpe_initialize (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "Unable to initialize general purpose events, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_ev_gpe_initialize(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Unable to initialize general purpose events, %s\n", acpi_format_exception(status))); + return_ACPI_STATUS(status); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_install_xrupt_handlers @@ -124,41 +110,32 @@ acpi_ev_initialize_events ( * ******************************************************************************/ -acpi_status -acpi_ev_install_xrupt_handlers ( - void) +acpi_status acpi_ev_install_xrupt_handlers(void) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_install_xrupt_handlers"); + acpi_status status; + ACPI_FUNCTION_TRACE("ev_install_xrupt_handlers"); /* Install the SCI handler */ - status = acpi_ev_install_sci_handler (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "Unable to install System Control Interrupt Handler, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_ev_install_sci_handler(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Unable to install System Control Interrupt Handler, %s\n", acpi_format_exception(status))); + return_ACPI_STATUS(status); } /* Install the handler for the Global Lock */ - status = acpi_ev_init_global_lock_handler (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "Unable to initialize Global Lock handler, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_ev_init_global_lock_handler(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Unable to initialize Global Lock handler, %s\n", acpi_format_exception(status))); + return_ACPI_STATUS(status); } acpi_gbl_events_initialized = TRUE; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_fixed_event_initialize @@ -171,13 +148,10 @@ acpi_ev_install_xrupt_handlers ( * ******************************************************************************/ -static acpi_status -acpi_ev_fixed_event_initialize ( - void) +static acpi_status acpi_ev_fixed_event_initialize(void) { - acpi_native_uint i; - acpi_status status; - + acpi_native_uint i; + acpi_status status; /* * Initialize the structure that keeps track of fixed event handlers @@ -190,10 +164,11 @@ acpi_ev_fixed_event_initialize ( /* Enable the fixed event */ if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) { - status = acpi_set_register ( - acpi_gbl_fixed_event_info[i].enable_register_id, - 0, ACPI_MTX_LOCK); - if (ACPI_FAILURE (status)) { + status = + acpi_set_register(acpi_gbl_fixed_event_info[i]. + enable_register_id, 0, + ACPI_MTX_LOCK); + if (ACPI_FAILURE(status)) { return (status); } } @@ -202,7 +177,6 @@ acpi_ev_fixed_event_initialize ( return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_fixed_event_detect @@ -215,31 +189,27 @@ acpi_ev_fixed_event_initialize ( * ******************************************************************************/ -u32 -acpi_ev_fixed_event_detect ( - void) +u32 acpi_ev_fixed_event_detect(void) { - u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; - u32 fixed_status; - u32 fixed_enable; - acpi_native_uint i; - - - ACPI_FUNCTION_NAME ("ev_fixed_event_detect"); + u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; + u32 fixed_status; + u32 fixed_enable; + acpi_native_uint i; + ACPI_FUNCTION_NAME("ev_fixed_event_detect"); /* * Read the fixed feature status and enable registers, as all the cases * depend on their values. Ignore errors here. */ - (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, - &fixed_status); - (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE, - &fixed_enable); + (void)acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_STATUS, &fixed_status); + (void)acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_ENABLE, &fixed_enable); - ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, - "Fixed Event Block: Enable %08X Status %08X\n", - fixed_enable, fixed_status)); + ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS, + "Fixed Event Block: Enable %08X Status %08X\n", + fixed_enable, fixed_status)); /* * Check for all possible Fixed Events and dispatch those that are active @@ -247,18 +217,19 @@ acpi_ev_fixed_event_detect ( for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { /* Both the status and enable bits must be on for this event */ - if ((fixed_status & acpi_gbl_fixed_event_info[i].status_bit_mask) && - (fixed_enable & acpi_gbl_fixed_event_info[i].enable_bit_mask)) { + if ((fixed_status & acpi_gbl_fixed_event_info[i]. + status_bit_mask) + && (fixed_enable & acpi_gbl_fixed_event_info[i]. + enable_bit_mask)) { /* Found an active (signalled) event */ - int_status |= acpi_ev_fixed_event_dispatch ((u32) i); + int_status |= acpi_ev_fixed_event_dispatch((u32) i); } } return (int_status); } - /******************************************************************************* * * FUNCTION: acpi_ev_fixed_event_dispatch @@ -272,39 +243,32 @@ acpi_ev_fixed_event_detect ( * ******************************************************************************/ -static u32 -acpi_ev_fixed_event_dispatch ( - u32 event) +static u32 acpi_ev_fixed_event_dispatch(u32 event) { - - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_ENTRY(); /* Clear the status bit */ - (void) acpi_set_register (acpi_gbl_fixed_event_info[event].status_register_id, - 1, ACPI_MTX_DO_NOT_LOCK); + (void)acpi_set_register(acpi_gbl_fixed_event_info[event]. + status_register_id, 1, ACPI_MTX_DO_NOT_LOCK); /* * Make sure we've got a handler. If not, report an error. * The event is disabled to prevent further interrupts. */ if (NULL == acpi_gbl_fixed_event_handlers[event].handler) { - (void) acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id, - 0, ACPI_MTX_DO_NOT_LOCK); + (void)acpi_set_register(acpi_gbl_fixed_event_info[event]. + enable_register_id, 0, + ACPI_MTX_DO_NOT_LOCK); - ACPI_REPORT_ERROR ( - ("No installed handler for fixed event [%08X]\n", - event)); + ACPI_REPORT_ERROR(("No installed handler for fixed event [%08X]\n", event)); return (ACPI_INTERRUPT_NOT_HANDLED); } /* Invoke the Fixed Event handler */ - return ((acpi_gbl_fixed_event_handlers[event].handler)( - acpi_gbl_fixed_event_handlers[event].context)); + return ((acpi_gbl_fixed_event_handlers[event]. + handler) (acpi_gbl_fixed_event_handlers[event].context)); } - - diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index ede834d..b2f232d 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c @@ -46,14 +46,10 @@ #include #define _COMPONENT ACPI_EVENTS - ACPI_MODULE_NAME ("evgpe") +ACPI_MODULE_NAME("evgpe") /* Local prototypes */ - -static void ACPI_SYSTEM_XFACE -acpi_ev_asynch_execute_gpe_method ( - void *context); - +static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context); /******************************************************************************* * @@ -69,15 +65,11 @@ acpi_ev_asynch_execute_gpe_method ( ******************************************************************************/ acpi_status -acpi_ev_set_gpe_type ( - struct acpi_gpe_event_info *gpe_event_info, - u8 type) +acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_set_gpe_type"); + acpi_status status; + ACPI_FUNCTION_TRACE("ev_set_gpe_type"); /* Validate type and update register enable masks */ @@ -88,21 +80,20 @@ acpi_ev_set_gpe_type ( break; default: - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Disable the GPE if currently enabled */ - status = acpi_ev_disable_gpe (gpe_event_info); + status = acpi_ev_disable_gpe(gpe_event_info); /* Type was validated above */ - gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */ - gpe_event_info->flags |= type; /* Insert type */ - return_ACPI_STATUS (status); + gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */ + gpe_event_info->flags |= type; /* Insert type */ + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_update_gpe_enable_masks @@ -118,57 +109,55 @@ acpi_ev_set_gpe_type ( ******************************************************************************/ acpi_status -acpi_ev_update_gpe_enable_masks ( - struct acpi_gpe_event_info *gpe_event_info, - u8 type) +acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info, + u8 type) { - struct acpi_gpe_register_info *gpe_register_info; - u8 register_bit; - - - ACPI_FUNCTION_TRACE ("ev_update_gpe_enable_masks"); + struct acpi_gpe_register_info *gpe_register_info; + u8 register_bit; + ACPI_FUNCTION_TRACE("ev_update_gpe_enable_masks"); gpe_register_info = gpe_event_info->register_info; if (!gpe_register_info) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } register_bit = gpe_event_info->register_bit; /* 1) Disable case. Simply clear all enable bits */ if (type == ACPI_GPE_DISABLE) { - ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit); - ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit); - return_ACPI_STATUS (AE_OK); + ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake, + register_bit); + ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit); + return_ACPI_STATUS(AE_OK); } /* 2) Enable case. Set/Clear the appropriate enable bits */ switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { case ACPI_GPE_TYPE_WAKE: - ACPI_SET_BIT (gpe_register_info->enable_for_wake, register_bit); - ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit); + ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit); + ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit); break; case ACPI_GPE_TYPE_RUNTIME: - ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit); - ACPI_SET_BIT (gpe_register_info->enable_for_run, register_bit); + ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake, + register_bit); + ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit); break; case ACPI_GPE_TYPE_WAKE_RUN: - ACPI_SET_BIT (gpe_register_info->enable_for_wake, register_bit); - ACPI_SET_BIT (gpe_register_info->enable_for_run, register_bit); + ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit); + ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit); break; default: - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_enable_gpe @@ -184,21 +173,19 @@ acpi_ev_update_gpe_enable_masks ( ******************************************************************************/ acpi_status -acpi_ev_enable_gpe ( - struct acpi_gpe_event_info *gpe_event_info, - u8 write_to_hardware) +acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info, + u8 write_to_hardware) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_enable_gpe"); + acpi_status status; + ACPI_FUNCTION_TRACE("ev_enable_gpe"); /* Make sure HW enable masks are updated */ - status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_ENABLE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ev_update_gpe_enable_masks(gpe_event_info, ACPI_GPE_ENABLE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Mark wake-enabled or HW enable, or both */ @@ -206,41 +193,40 @@ acpi_ev_enable_gpe ( switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { case ACPI_GPE_TYPE_WAKE: - ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); + ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); break; case ACPI_GPE_TYPE_WAKE_RUN: - ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); + ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); /*lint -fallthrough */ case ACPI_GPE_TYPE_RUNTIME: - ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED); + ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED); if (write_to_hardware) { /* Clear the GPE (of stale events), then enable it */ - status = acpi_hw_clear_gpe (gpe_event_info); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_clear_gpe(gpe_event_info); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Enable the requested runtime GPE */ - status = acpi_hw_write_gpe_enable_reg (gpe_event_info); + status = acpi_hw_write_gpe_enable_reg(gpe_event_info); } break; default: - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_disable_gpe @@ -253,36 +239,33 @@ acpi_ev_enable_gpe ( * ******************************************************************************/ -acpi_status -acpi_ev_disable_gpe ( - struct acpi_gpe_event_info *gpe_event_info) +acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_disable_gpe"); + acpi_status status; + ACPI_FUNCTION_TRACE("ev_disable_gpe"); if (!(gpe_event_info->flags & ACPI_GPE_ENABLE_MASK)) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Make sure HW enable masks are updated */ - status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_DISABLE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ev_update_gpe_enable_masks(gpe_event_info, ACPI_GPE_DISABLE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Mark wake-disabled or HW disable, or both */ switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { case ACPI_GPE_TYPE_WAKE: - ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); + ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); break; case ACPI_GPE_TYPE_WAKE_RUN: - ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); + ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); /*lint -fallthrough */ @@ -290,18 +273,17 @@ acpi_ev_disable_gpe ( /* Disable the requested runtime GPE */ - ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED); - status = acpi_hw_write_gpe_enable_reg (gpe_event_info); + ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED); + status = acpi_hw_write_gpe_enable_reg(gpe_event_info); break; default: - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_get_gpe_event_info @@ -319,18 +301,14 @@ acpi_ev_disable_gpe ( * ******************************************************************************/ -struct acpi_gpe_event_info * -acpi_ev_get_gpe_event_info ( - acpi_handle gpe_device, - u32 gpe_number) +struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, + u32 gpe_number) { - union acpi_operand_object *obj_desc; - struct acpi_gpe_block_info *gpe_block; - acpi_native_uint i; - - - ACPI_FUNCTION_ENTRY (); + union acpi_operand_object *obj_desc; + struct acpi_gpe_block_info *gpe_block; + acpi_native_uint i; + ACPI_FUNCTION_ENTRY(); /* A NULL gpe_block means use the FADT-defined GPE block(s) */ @@ -340,11 +318,14 @@ acpi_ev_get_gpe_event_info ( for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) { gpe_block = acpi_gbl_gpe_fadt_blocks[i]; if (gpe_block) { - if ((gpe_number >= gpe_block->block_base_number) && - (gpe_number < gpe_block->block_base_number + - (gpe_block->register_count * 8))) { - return (&gpe_block->event_info[gpe_number - - gpe_block->block_base_number]); + if ((gpe_number >= gpe_block->block_base_number) + && (gpe_number < + gpe_block->block_base_number + + (gpe_block->register_count * 8))) { + return (&gpe_block-> + event_info[gpe_number - + gpe_block-> + block_base_number]); } } } @@ -356,23 +337,25 @@ acpi_ev_get_gpe_event_info ( /* A Non-NULL gpe_device means this is a GPE Block Device */ - obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) gpe_device); - if (!obj_desc || - !obj_desc->device.gpe_block) { + obj_desc = + acpi_ns_get_attached_object((struct acpi_namespace_node *) + gpe_device); + if (!obj_desc || !obj_desc->device.gpe_block) { return (NULL); } gpe_block = obj_desc->device.gpe_block; if ((gpe_number >= gpe_block->block_base_number) && - (gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) { - return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]); + (gpe_number < + gpe_block->block_base_number + (gpe_block->register_count * 8))) { + return (&gpe_block-> + event_info[gpe_number - gpe_block->block_base_number]); } return (NULL); } - /******************************************************************************* * * FUNCTION: acpi_ev_gpe_detect @@ -387,23 +370,20 @@ acpi_ev_get_gpe_event_info ( * ******************************************************************************/ -u32 -acpi_ev_gpe_detect ( - struct acpi_gpe_xrupt_info *gpe_xrupt_list) +u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) { - u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; - u8 enabled_status_byte; - struct acpi_gpe_register_info *gpe_register_info; - u32 status_reg; - u32 enable_reg; - u32 flags; - acpi_status status; - struct acpi_gpe_block_info *gpe_block; - acpi_native_uint i; - acpi_native_uint j; - - - ACPI_FUNCTION_NAME ("ev_gpe_detect"); + u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; + u8 enabled_status_byte; + struct acpi_gpe_register_info *gpe_register_info; + u32 status_reg; + u32 enable_reg; + u32 flags; + acpi_status status; + struct acpi_gpe_block_info *gpe_block; + acpi_native_uint i; + acpi_native_uint j; + + ACPI_FUNCTION_NAME("ev_gpe_detect"); /* Check for the case where there are no GPEs */ @@ -413,7 +393,7 @@ acpi_ev_gpe_detect ( /* Examine all GPE blocks attached to this interrupt level */ - flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); + flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); gpe_block = gpe_xrupt_list->gpe_block_list_head; while (gpe_block) { /* @@ -428,23 +408,30 @@ acpi_ev_gpe_detect ( /* Read the Status Register */ - status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &status_reg, - &gpe_register_info->status_address); - if (ACPI_FAILURE (status)) { + status = + acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, + &status_reg, + &gpe_register_info-> + status_address); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* Read the Enable Register */ - status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &enable_reg, - &gpe_register_info->enable_address); - if (ACPI_FAILURE (status)) { + status = + acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, + &enable_reg, + &gpe_register_info-> + enable_address); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } - ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, - "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", - gpe_register_info->base_gpe_number, status_reg, enable_reg)); + ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS, + "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", + gpe_register_info->base_gpe_number, + status_reg, enable_reg)); /* Check if there is anything active at all in this register */ @@ -460,14 +447,21 @@ acpi_ev_gpe_detect ( for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { /* Examine one GPE bit */ - if (enabled_status_byte & acpi_gbl_decode_to8bit[j]) { + if (enabled_status_byte & + acpi_gbl_decode_to8bit[j]) { /* * Found an active GPE. Dispatch the event to a handler * or method. */ - int_status |= acpi_ev_gpe_dispatch ( - &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j], - (u32) j + gpe_register_info->base_gpe_number); + int_status |= + acpi_ev_gpe_dispatch(&gpe_block-> + event_info[(i * + ACPI_GPE_REGISTER_WIDTH) + + + j], + (u32) j + + gpe_register_info-> + base_gpe_number); } } } @@ -475,13 +469,12 @@ acpi_ev_gpe_detect ( gpe_block = gpe_block->next; } -unlock_and_exit: + unlock_and_exit: - acpi_os_release_lock (acpi_gbl_gpe_lock, flags); + acpi_os_release_lock(acpi_gbl_gpe_lock, flags); return (int_status); } - /******************************************************************************* * * FUNCTION: acpi_ev_asynch_execute_gpe_method @@ -498,45 +491,41 @@ unlock_and_exit: * ******************************************************************************/ -static void ACPI_SYSTEM_XFACE -acpi_ev_asynch_execute_gpe_method ( - void *context) +static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context) { - struct acpi_gpe_event_info *gpe_event_info = (void *) context; - u32 gpe_number = 0; - acpi_status status; - struct acpi_gpe_event_info local_gpe_event_info; - struct acpi_parameter_info info; - + struct acpi_gpe_event_info *gpe_event_info = (void *)context; + u32 gpe_number = 0; + acpi_status status; + struct acpi_gpe_event_info local_gpe_event_info; + struct acpi_parameter_info info; - ACPI_FUNCTION_TRACE ("ev_asynch_execute_gpe_method"); + ACPI_FUNCTION_TRACE("ev_asynch_execute_gpe_method"); - - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { return_VOID; } /* Must revalidate the gpe_number/gpe_block */ - if (!acpi_ev_valid_gpe_event (gpe_event_info)) { - status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); + if (!acpi_ev_valid_gpe_event(gpe_event_info)) { + status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); return_VOID; } /* Set the GPE flags for return to enabled state */ - (void) acpi_ev_enable_gpe (gpe_event_info, FALSE); + (void)acpi_ev_enable_gpe(gpe_event_info, FALSE); /* * Take a snapshot of the GPE info for this level - we copy the * info to prevent a race condition with remove_handler/remove_block. */ - ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info, - sizeof (struct acpi_gpe_event_info)); + ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info, + sizeof(struct acpi_gpe_event_info)); - status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { + status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { return_VOID; } @@ -545,44 +534,40 @@ acpi_ev_asynch_execute_gpe_method ( * time to avoid race with ev_gpe_install_handler */ if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == - ACPI_GPE_DISPATCH_METHOD) { + ACPI_GPE_DISPATCH_METHOD) { /* * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx * control method that corresponds to this GPE */ info.node = local_gpe_event_info.dispatch.method_node; - info.parameters = ACPI_CAST_PTR (union acpi_operand_object *, gpe_event_info); + info.parameters = + ACPI_CAST_PTR(union acpi_operand_object *, gpe_event_info); info.parameter_type = ACPI_PARAM_GPE; - status = acpi_ns_evaluate_by_handle (&info); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "%s while evaluating method [%4.4s] for GPE[%2X]\n", - acpi_format_exception (status), - acpi_ut_get_node_name (local_gpe_event_info.dispatch.method_node), - gpe_number)); + status = acpi_ns_evaluate_by_handle(&info); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("%s while evaluating method [%4.4s] for GPE[%2X]\n", acpi_format_exception(status), acpi_ut_get_node_name(local_gpe_event_info.dispatch.method_node), gpe_number)); } } if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) == - ACPI_GPE_LEVEL_TRIGGERED) { + ACPI_GPE_LEVEL_TRIGGERED) { /* * GPE is level-triggered, we clear the GPE status bit after * handling the event. */ - status = acpi_hw_clear_gpe (&local_gpe_event_info); - if (ACPI_FAILURE (status)) { + status = acpi_hw_clear_gpe(&local_gpe_event_info); + if (ACPI_FAILURE(status)) { return_VOID; } } /* Enable this GPE */ - (void) acpi_hw_write_gpe_enable_reg (&local_gpe_event_info); + (void)acpi_hw_write_gpe_enable_reg(&local_gpe_event_info); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ev_gpe_dispatch @@ -600,38 +585,31 @@ acpi_ev_asynch_execute_gpe_method ( ******************************************************************************/ u32 -acpi_ev_gpe_dispatch ( - struct acpi_gpe_event_info *gpe_event_info, - u32 gpe_number) +acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_gpe_dispatch"); + acpi_status status; + ACPI_FUNCTION_TRACE("ev_gpe_dispatch"); /* * If edge-triggered, clear the GPE status bit now. Note that * level-triggered events are cleared after the GPE is serviced. */ if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == - ACPI_GPE_EDGE_TRIGGERED) { - status = acpi_hw_clear_gpe (gpe_event_info); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", - acpi_format_exception (status), gpe_number)); - return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); + ACPI_GPE_EDGE_TRIGGERED) { + status = acpi_hw_clear_gpe(gpe_event_info); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); + return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); } } /* Save current system state */ if (acpi_gbl_system_awake_and_running) { - ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING); - } - else { - ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING); + ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING); + } else { + ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING); } /* @@ -648,19 +626,19 @@ acpi_ev_gpe_dispatch ( * Invoke the installed handler (at interrupt level) * Ignore return status for now. TBD: leave GPE disabled on error? */ - (void) gpe_event_info->dispatch.handler->address ( - gpe_event_info->dispatch.handler->context); + (void)gpe_event_info->dispatch.handler->address(gpe_event_info-> + dispatch. + handler-> + context); /* It is now safe to clear level-triggered events. */ if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == - ACPI_GPE_LEVEL_TRIGGERED) { - status = acpi_hw_clear_gpe (gpe_event_info); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", - acpi_format_exception (status), gpe_number)); - return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); + ACPI_GPE_LEVEL_TRIGGERED) { + status = acpi_hw_clear_gpe(gpe_event_info); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); + return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); } } break; @@ -671,24 +649,21 @@ acpi_ev_gpe_dispatch ( * Disable GPE, so it doesn't keep firing before the method has a * chance to run. */ - status = acpi_ev_disable_gpe (gpe_event_info); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", - acpi_format_exception (status), gpe_number)); - return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); + status = acpi_ev_disable_gpe(gpe_event_info); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); + return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); } /* * Execute the method associated with the GPE * NOTE: Level-triggered GPEs are cleared after the method completes. */ - status = acpi_os_queue_for_execution (OSD_PRIORITY_GPE, - acpi_ev_asynch_execute_gpe_method, gpe_event_info); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", - acpi_format_exception (status), gpe_number)); + status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, + acpi_ev_asynch_execute_gpe_method, + gpe_event_info); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", acpi_format_exception(status), gpe_number)); } break; @@ -696,28 +671,23 @@ acpi_ev_gpe_dispatch ( /* No handler or method to run! */ - ACPI_REPORT_ERROR (( - "acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n", - gpe_number)); + ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n", gpe_number)); /* * Disable the GPE. The GPE will remain disabled until the ACPI * Core Subsystem is restarted, or a handler is installed. */ - status = acpi_ev_disable_gpe (gpe_event_info); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", - acpi_format_exception (status), gpe_number)); - return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); + status = acpi_ev_disable_gpe(gpe_event_info); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); + return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); } break; } - return_VALUE (ACPI_INTERRUPT_HANDLED); + return_VALUE(ACPI_INTERRUPT_HANDLED); } - #ifdef ACPI_GPE_NOTIFY_CHECK /******************************************************************************* * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED @@ -736,35 +706,29 @@ acpi_ev_gpe_dispatch ( ******************************************************************************/ acpi_status -acpi_ev_check_for_wake_only_gpe ( - struct acpi_gpe_event_info *gpe_event_info) +acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info) { - acpi_status status; + acpi_status status; + ACPI_FUNCTION_TRACE("ev_check_for_wake_only_gpe"); - ACPI_FUNCTION_TRACE ("ev_check_for_wake_only_gpe"); - - - if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */ - ((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */ { + if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */ + ((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) { /* System state at GPE time */ /* This must be a wake-only GPE, disable it */ - status = acpi_ev_disable_gpe (gpe_event_info); + status = acpi_ev_disable_gpe(gpe_event_info); /* Set GPE to wake-only. Do not change wake disabled/enabled status */ - acpi_ev_set_gpe_type (gpe_event_info, ACPI_GPE_TYPE_WAKE); + acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE); - ACPI_REPORT_INFO (("GPE %p was updated from wake/run to wake-only\n", - gpe_event_info)); + ACPI_REPORT_INFO(("GPE %p was updated from wake/run to wake-only\n", gpe_event_info)); /* This was a wake-only GPE */ - return_ACPI_STATUS (AE_WAKE_ONLY_GPE); + return_ACPI_STATUS(AE_WAKE_ONLY_GPE); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } #endif - - diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c index dfc5469..b312eb3 100644 --- a/drivers/acpi/events/evgpeblk.c +++ b/drivers/acpi/events/evgpeblk.c @@ -46,41 +46,29 @@ #include #define _COMPONENT ACPI_EVENTS - ACPI_MODULE_NAME ("evgpeblk") +ACPI_MODULE_NAME("evgpeblk") /* Local prototypes */ - static acpi_status -acpi_ev_save_method_info ( - acpi_handle obj_handle, - u32 level, - void *obj_desc, - void **return_value); +acpi_ev_save_method_info(acpi_handle obj_handle, + u32 level, void *obj_desc, void **return_value); static acpi_status -acpi_ev_match_prw_and_gpe ( - acpi_handle obj_handle, - u32 level, - void *info, - void **return_value); +acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, + u32 level, void *info, void **return_value); -static struct acpi_gpe_xrupt_info * -acpi_ev_get_gpe_xrupt_block ( - u32 interrupt_number); +static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 + interrupt_number); static acpi_status -acpi_ev_delete_gpe_xrupt ( - struct acpi_gpe_xrupt_info *gpe_xrupt); +acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt); static acpi_status -acpi_ev_install_gpe_block ( - struct acpi_gpe_block_info *gpe_block, - u32 interrupt_number); +acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, + u32 interrupt_number); static acpi_status -acpi_ev_create_gpe_info_blocks ( - struct acpi_gpe_block_info *gpe_block); - +acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block); /******************************************************************************* * @@ -96,16 +84,12 @@ acpi_ev_create_gpe_info_blocks ( * ******************************************************************************/ -u8 -acpi_ev_valid_gpe_event ( - struct acpi_gpe_event_info *gpe_event_info) +u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info) { - struct acpi_gpe_xrupt_info *gpe_xrupt_block; - struct acpi_gpe_block_info *gpe_block; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_gpe_xrupt_info *gpe_xrupt_block; + struct acpi_gpe_block_info *gpe_block; + ACPI_FUNCTION_ENTRY(); /* No need for spin lock since we are not changing any list elements */ @@ -119,7 +103,10 @@ acpi_ev_valid_gpe_event ( while (gpe_block) { if ((&gpe_block->event_info[0] <= gpe_event_info) && - (&gpe_block->event_info[((acpi_size) gpe_block->register_count) * 8] > gpe_event_info)) { + (&gpe_block-> + event_info[((acpi_size) gpe_block-> + register_count) * 8] > + gpe_event_info)) { return (TRUE); } @@ -132,7 +119,6 @@ acpi_ev_valid_gpe_event ( return (FALSE); } - /******************************************************************************* * * FUNCTION: acpi_ev_walk_gpe_list @@ -145,20 +131,16 @@ acpi_ev_valid_gpe_event ( * ******************************************************************************/ -acpi_status -acpi_ev_walk_gpe_list ( - ACPI_GPE_CALLBACK gpe_walk_callback) +acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback) { - struct acpi_gpe_block_info *gpe_block; - struct acpi_gpe_xrupt_info *gpe_xrupt_info; - acpi_status status = AE_OK; - u32 flags; - + struct acpi_gpe_block_info *gpe_block; + struct acpi_gpe_xrupt_info *gpe_xrupt_info; + acpi_status status = AE_OK; + u32 flags; - ACPI_FUNCTION_TRACE ("ev_walk_gpe_list"); + ACPI_FUNCTION_TRACE("ev_walk_gpe_list"); - - flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); + flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); /* Walk the interrupt level descriptor list */ @@ -170,8 +152,8 @@ acpi_ev_walk_gpe_list ( while (gpe_block) { /* One callback per GPE block */ - status = gpe_walk_callback (gpe_xrupt_info, gpe_block); - if (ACPI_FAILURE (status)) { + status = gpe_walk_callback(gpe_xrupt_info, gpe_block); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } @@ -181,12 +163,11 @@ acpi_ev_walk_gpe_list ( gpe_xrupt_info = gpe_xrupt_info->next; } -unlock_and_exit: - acpi_os_release_lock (acpi_gbl_gpe_lock, flags); - return_ACPI_STATUS (status); + unlock_and_exit: + acpi_os_release_lock(acpi_gbl_gpe_lock, flags); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_delete_gpe_handlers @@ -202,17 +183,14 @@ unlock_and_exit: ******************************************************************************/ acpi_status -acpi_ev_delete_gpe_handlers ( - struct acpi_gpe_xrupt_info *gpe_xrupt_info, - struct acpi_gpe_block_info *gpe_block) +acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, + struct acpi_gpe_block_info *gpe_block) { - struct acpi_gpe_event_info *gpe_event_info; - acpi_native_uint i; - acpi_native_uint j; - - - ACPI_FUNCTION_TRACE ("ev_delete_gpe_handlers"); + struct acpi_gpe_event_info *gpe_event_info; + acpi_native_uint i; + acpi_native_uint j; + ACPI_FUNCTION_TRACE("ev_delete_gpe_handlers"); /* Examine each GPE Register within the block */ @@ -220,21 +198,23 @@ acpi_ev_delete_gpe_handlers ( /* Now look at the individual GPEs in this byte register */ for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { - gpe_event_info = &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j]; + gpe_event_info = + &gpe_block-> + event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j]; if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == - ACPI_GPE_DISPATCH_HANDLER) { - ACPI_MEM_FREE (gpe_event_info->dispatch.handler); + ACPI_GPE_DISPATCH_HANDLER) { + ACPI_MEM_FREE(gpe_event_info->dispatch.handler); gpe_event_info->dispatch.handler = NULL; - gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; + gpe_event_info->flags &= + ~ACPI_GPE_DISPATCH_MASK; } } } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_save_method_info @@ -258,30 +238,26 @@ acpi_ev_delete_gpe_handlers ( ******************************************************************************/ static acpi_status -acpi_ev_save_method_info ( - acpi_handle obj_handle, - u32 level, - void *obj_desc, - void **return_value) +acpi_ev_save_method_info(acpi_handle obj_handle, + u32 level, void *obj_desc, void **return_value) { - struct acpi_gpe_block_info *gpe_block = (void *) obj_desc; - struct acpi_gpe_event_info *gpe_event_info; - u32 gpe_number; - char name[ACPI_NAME_SIZE + 1]; - u8 type; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_save_method_info"); + struct acpi_gpe_block_info *gpe_block = (void *)obj_desc; + struct acpi_gpe_event_info *gpe_event_info; + u32 gpe_number; + char name[ACPI_NAME_SIZE + 1]; + u8 type; + acpi_status status; + ACPI_FUNCTION_TRACE("ev_save_method_info"); /* * _Lxx and _Exx GPE method support * * 1) Extract the name from the object and convert to a string */ - ACPI_MOVE_32_TO_32 (name, - &((struct acpi_namespace_node *) obj_handle)->name.integer); + ACPI_MOVE_32_TO_32(name, + &((struct acpi_namespace_node *)obj_handle)->name. + integer); name[ACPI_NAME_SIZE] = 0; /* @@ -303,34 +279,36 @@ acpi_ev_save_method_info ( default: /* Unknown method type, just ignore it! */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n", - name)); - return_ACPI_STATUS (AE_OK); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n", + name)); + return_ACPI_STATUS(AE_OK); } /* Convert the last two characters of the name to the GPE Number */ - gpe_number = ACPI_STRTOUL (&name[2], NULL, 16); + gpe_number = ACPI_STRTOUL(&name[2], NULL, 16); if (gpe_number == ACPI_UINT32_MAX) { /* Conversion failed; invalid method, just ignore it */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n", - name)); - return_ACPI_STATUS (AE_OK); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n", + name)); + return_ACPI_STATUS(AE_OK); } /* Ensure that we have a valid GPE number for this GPE block */ if ((gpe_number < gpe_block->block_base_number) || - (gpe_number >= (gpe_block->block_base_number + (gpe_block->register_count * 8)))) { + (gpe_number >= + (gpe_block->block_base_number + + (gpe_block->register_count * 8)))) { /* * Not valid for this GPE block, just ignore it * However, it may be valid for a different GPE block, since GPE0 and GPE1 * methods both appear under \_GPE. */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* @@ -338,24 +316,25 @@ acpi_ev_save_method_info ( * for use during dispatch of this GPE. Default type is RUNTIME, although * this may change when the _PRW methods are executed later. */ - gpe_event_info = &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; + gpe_event_info = + &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD | - ACPI_GPE_TYPE_RUNTIME); + ACPI_GPE_TYPE_RUNTIME); - gpe_event_info->dispatch.method_node = (struct acpi_namespace_node *) obj_handle; + gpe_event_info->dispatch.method_node = + (struct acpi_namespace_node *)obj_handle; /* Update enable mask, but don't enable the HW GPE as of yet */ - status = acpi_ev_enable_gpe (gpe_event_info, FALSE); + status = acpi_ev_enable_gpe(gpe_event_info, FALSE); - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, - "Registered GPE method %s as GPE number 0x%.2X\n", - name, gpe_number)); - return_ACPI_STATUS (status); + ACPI_DEBUG_PRINT((ACPI_DB_LOAD, + "Registered GPE method %s as GPE number 0x%.2X\n", + name, gpe_number)); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_match_prw_and_gpe @@ -372,34 +351,29 @@ acpi_ev_save_method_info ( ******************************************************************************/ static acpi_status -acpi_ev_match_prw_and_gpe ( - acpi_handle obj_handle, - u32 level, - void *info, - void **return_value) +acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, + u32 level, void *info, void **return_value) { - struct acpi_gpe_walk_info *gpe_info = (void *) info; - struct acpi_namespace_node *gpe_device; - struct acpi_gpe_block_info *gpe_block; - struct acpi_namespace_node *target_gpe_device; - struct acpi_gpe_event_info *gpe_event_info; - union acpi_operand_object *pkg_desc; - union acpi_operand_object *obj_desc; - u32 gpe_number; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_match_prw_and_gpe"); - + struct acpi_gpe_walk_info *gpe_info = (void *)info; + struct acpi_namespace_node *gpe_device; + struct acpi_gpe_block_info *gpe_block; + struct acpi_namespace_node *target_gpe_device; + struct acpi_gpe_event_info *gpe_event_info; + union acpi_operand_object *pkg_desc; + union acpi_operand_object *obj_desc; + u32 gpe_number; + acpi_status status; + + ACPI_FUNCTION_TRACE("ev_match_prw_and_gpe"); /* Check for a _PRW method under this device */ - status = acpi_ut_evaluate_object (obj_handle, METHOD_NAME__PRW, - ACPI_BTYPE_PACKAGE, &pkg_desc); - if (ACPI_FAILURE (status)) { + status = acpi_ut_evaluate_object(obj_handle, METHOD_NAME__PRW, + ACPI_BTYPE_PACKAGE, &pkg_desc); + if (ACPI_FAILURE(status)) { /* Ignore all errors from _PRW, we don't want to abort the subsystem */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* The returned _PRW package must have at least two elements */ @@ -419,7 +393,7 @@ acpi_ev_match_prw_and_gpe ( */ obj_desc = pkg_desc->package.elements[0]; - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { /* Use FADT-defined GPE device (from definition of _PRW) */ target_gpe_device = acpi_gbl_fadt_gpe_device; @@ -427,22 +401,23 @@ acpi_ev_match_prw_and_gpe ( /* Integer is the GPE number in the FADT described GPE blocks */ gpe_number = (u32) obj_desc->integer.value; - } - else if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) { + } else if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { /* Package contains a GPE reference and GPE number within a GPE block */ if ((obj_desc->package.count < 2) || - (ACPI_GET_OBJECT_TYPE (obj_desc->package.elements[0]) != ACPI_TYPE_LOCAL_REFERENCE) || - (ACPI_GET_OBJECT_TYPE (obj_desc->package.elements[1]) != ACPI_TYPE_INTEGER)) { + (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[0]) != + ACPI_TYPE_LOCAL_REFERENCE) + || (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[1]) != + ACPI_TYPE_INTEGER)) { goto cleanup; } /* Get GPE block reference and decode */ - target_gpe_device = obj_desc->package.elements[0]->reference.node; + target_gpe_device = + obj_desc->package.elements[0]->reference.node; gpe_number = (u32) obj_desc->package.elements[1]->integer.value; - } - else { + } else { /* Unknown type, just ignore it */ goto cleanup; @@ -457,26 +432,32 @@ acpi_ev_match_prw_and_gpe ( * associated with the GPE device. */ if ((gpe_device == target_gpe_device) && - (gpe_number >= gpe_block->block_base_number) && - (gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) { - gpe_event_info = &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; + (gpe_number >= gpe_block->block_base_number) && + (gpe_number < + gpe_block->block_base_number + (gpe_block->register_count * 8))) { + gpe_event_info = + &gpe_block->event_info[gpe_number - + gpe_block->block_base_number]; /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ - gpe_event_info->flags &= ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); - status = acpi_ev_set_gpe_type (gpe_event_info, ACPI_GPE_TYPE_WAKE); - if (ACPI_FAILURE (status)) { + gpe_event_info->flags &= + ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); + status = + acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE); + if (ACPI_FAILURE(status)) { goto cleanup; } - status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_DISABLE); + status = + acpi_ev_update_gpe_enable_masks(gpe_event_info, + ACPI_GPE_DISABLE); } -cleanup: - acpi_ut_remove_reference (pkg_desc); - return_ACPI_STATUS (AE_OK); + cleanup: + acpi_ut_remove_reference(pkg_desc); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_get_gpe_xrupt_block @@ -492,25 +473,22 @@ cleanup: * ******************************************************************************/ -static struct acpi_gpe_xrupt_info * -acpi_ev_get_gpe_xrupt_block ( - u32 interrupt_number) +static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 + interrupt_number) { - struct acpi_gpe_xrupt_info *next_gpe_xrupt; - struct acpi_gpe_xrupt_info *gpe_xrupt; - acpi_status status; - u32 flags; - - - ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block"); + struct acpi_gpe_xrupt_info *next_gpe_xrupt; + struct acpi_gpe_xrupt_info *gpe_xrupt; + acpi_status status; + u32 flags; + ACPI_FUNCTION_TRACE("ev_get_gpe_xrupt_block"); /* No need for lock since we are not changing any list elements here */ next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; while (next_gpe_xrupt) { if (next_gpe_xrupt->interrupt_number == interrupt_number) { - return_PTR (next_gpe_xrupt); + return_PTR(next_gpe_xrupt); } next_gpe_xrupt = next_gpe_xrupt->next; @@ -518,16 +496,16 @@ acpi_ev_get_gpe_xrupt_block ( /* Not found, must allocate a new xrupt descriptor */ - gpe_xrupt = ACPI_MEM_CALLOCATE (sizeof (struct acpi_gpe_xrupt_info)); + gpe_xrupt = ACPI_MEM_CALLOCATE(sizeof(struct acpi_gpe_xrupt_info)); if (!gpe_xrupt) { - return_PTR (NULL); + return_PTR(NULL); } gpe_xrupt->interrupt_number = interrupt_number; /* Install new interrupt descriptor with spin lock */ - flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); + flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); if (acpi_gbl_gpe_xrupt_list_head) { next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; while (next_gpe_xrupt->next) { @@ -536,29 +514,28 @@ acpi_ev_get_gpe_xrupt_block ( next_gpe_xrupt->next = gpe_xrupt; gpe_xrupt->previous = next_gpe_xrupt; - } - else { + } else { acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; } - acpi_os_release_lock (acpi_gbl_gpe_lock, flags); + acpi_os_release_lock(acpi_gbl_gpe_lock, flags); /* Install new interrupt handler if not SCI_INT */ if (interrupt_number != acpi_gbl_FADT->sci_int) { - status = acpi_os_install_interrupt_handler (interrupt_number, - acpi_ev_gpe_xrupt_handler, gpe_xrupt); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not install GPE interrupt handler at level 0x%X\n", - interrupt_number)); - return_PTR (NULL); + status = acpi_os_install_interrupt_handler(interrupt_number, + acpi_ev_gpe_xrupt_handler, + gpe_xrupt); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not install GPE interrupt handler at level 0x%X\n", + interrupt_number)); + return_PTR(NULL); } } - return_PTR (gpe_xrupt); + return_PTR(gpe_xrupt); } - /******************************************************************************* * * FUNCTION: acpi_ev_delete_gpe_xrupt @@ -573,34 +550,31 @@ acpi_ev_get_gpe_xrupt_block ( ******************************************************************************/ static acpi_status -acpi_ev_delete_gpe_xrupt ( - struct acpi_gpe_xrupt_info *gpe_xrupt) +acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt) { - acpi_status status; - u32 flags; - - - ACPI_FUNCTION_TRACE ("ev_delete_gpe_xrupt"); + acpi_status status; + u32 flags; + ACPI_FUNCTION_TRACE("ev_delete_gpe_xrupt"); /* We never want to remove the SCI interrupt handler */ if (gpe_xrupt->interrupt_number == acpi_gbl_FADT->sci_int) { gpe_xrupt->gpe_block_list_head = NULL; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Disable this interrupt */ - status = acpi_os_remove_interrupt_handler (gpe_xrupt->interrupt_number, - acpi_ev_gpe_xrupt_handler); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, + acpi_ev_gpe_xrupt_handler); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Unlink the interrupt block with lock */ - flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); + flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); if (gpe_xrupt->previous) { gpe_xrupt->previous->next = gpe_xrupt->next; } @@ -608,15 +582,14 @@ acpi_ev_delete_gpe_xrupt ( if (gpe_xrupt->next) { gpe_xrupt->next->previous = gpe_xrupt->previous; } - acpi_os_release_lock (acpi_gbl_gpe_lock, flags); + acpi_os_release_lock(acpi_gbl_gpe_lock, flags); /* Free the block */ - ACPI_MEM_FREE (gpe_xrupt); - return_ACPI_STATUS (AE_OK); + ACPI_MEM_FREE(gpe_xrupt); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_install_gpe_block @@ -631,25 +604,22 @@ acpi_ev_delete_gpe_xrupt ( ******************************************************************************/ static acpi_status -acpi_ev_install_gpe_block ( - struct acpi_gpe_block_info *gpe_block, - u32 interrupt_number) +acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, + u32 interrupt_number) { - struct acpi_gpe_block_info *next_gpe_block; - struct acpi_gpe_xrupt_info *gpe_xrupt_block; - acpi_status status; - u32 flags; + struct acpi_gpe_block_info *next_gpe_block; + struct acpi_gpe_xrupt_info *gpe_xrupt_block; + acpi_status status; + u32 flags; + ACPI_FUNCTION_TRACE("ev_install_gpe_block"); - ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); - - - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block (interrupt_number); + gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block(interrupt_number); if (!gpe_xrupt_block) { status = AE_NO_MEMORY; goto unlock_and_exit; @@ -657,7 +627,7 @@ acpi_ev_install_gpe_block ( /* Install the new block at the end of the list with lock */ - flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); + flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); if (gpe_xrupt_block->gpe_block_list_head) { next_gpe_block = gpe_xrupt_block->gpe_block_list_head; while (next_gpe_block->next) { @@ -666,20 +636,18 @@ acpi_ev_install_gpe_block ( next_gpe_block->next = gpe_block; gpe_block->previous = next_gpe_block; - } - else { + } else { gpe_xrupt_block->gpe_block_list_head = gpe_block; } gpe_block->xrupt_block = gpe_xrupt_block; - acpi_os_release_lock (acpi_gbl_gpe_lock, flags); + acpi_os_release_lock(acpi_gbl_gpe_lock, flags); -unlock_and_exit: - status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); - return_ACPI_STATUS (status); + unlock_and_exit: + status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_delete_gpe_block @@ -692,63 +660,57 @@ unlock_and_exit: * ******************************************************************************/ -acpi_status -acpi_ev_delete_gpe_block ( - struct acpi_gpe_block_info *gpe_block) +acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block) { - acpi_status status; - u32 flags; - - - ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); + acpi_status status; + u32 flags; + ACPI_FUNCTION_TRACE("ev_install_gpe_block"); - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Disable all GPEs in this block */ - status = acpi_hw_disable_gpe_block (gpe_block->xrupt_block, gpe_block); + status = acpi_hw_disable_gpe_block(gpe_block->xrupt_block, gpe_block); if (!gpe_block->previous && !gpe_block->next) { /* This is the last gpe_block on this interrupt */ - status = acpi_ev_delete_gpe_xrupt (gpe_block->xrupt_block); - if (ACPI_FAILURE (status)) { + status = acpi_ev_delete_gpe_xrupt(gpe_block->xrupt_block); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } - } - else { + } else { /* Remove the block on this interrupt with lock */ - flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); + flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); if (gpe_block->previous) { gpe_block->previous->next = gpe_block->next; - } - else { - gpe_block->xrupt_block->gpe_block_list_head = gpe_block->next; + } else { + gpe_block->xrupt_block->gpe_block_list_head = + gpe_block->next; } if (gpe_block->next) { gpe_block->next->previous = gpe_block->previous; } - acpi_os_release_lock (acpi_gbl_gpe_lock, flags); + acpi_os_release_lock(acpi_gbl_gpe_lock, flags); } /* Free the gpe_block */ - ACPI_MEM_FREE (gpe_block->register_info); - ACPI_MEM_FREE (gpe_block->event_info); - ACPI_MEM_FREE (gpe_block); + ACPI_MEM_FREE(gpe_block->register_info); + ACPI_MEM_FREE(gpe_block->event_info); + ACPI_MEM_FREE(gpe_block); -unlock_and_exit: - status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); - return_ACPI_STATUS (status); + unlock_and_exit: + status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_create_gpe_info_blocks @@ -762,43 +724,41 @@ unlock_and_exit: ******************************************************************************/ static acpi_status -acpi_ev_create_gpe_info_blocks ( - struct acpi_gpe_block_info *gpe_block) +acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) { - struct acpi_gpe_register_info *gpe_register_info = NULL; - struct acpi_gpe_event_info *gpe_event_info = NULL; - struct acpi_gpe_event_info *this_event; - struct acpi_gpe_register_info *this_register; - acpi_native_uint i; - acpi_native_uint j; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_create_gpe_info_blocks"); + struct acpi_gpe_register_info *gpe_register_info = NULL; + struct acpi_gpe_event_info *gpe_event_info = NULL; + struct acpi_gpe_event_info *this_event; + struct acpi_gpe_register_info *this_register; + acpi_native_uint i; + acpi_native_uint j; + acpi_status status; + ACPI_FUNCTION_TRACE("ev_create_gpe_info_blocks"); /* Allocate the GPE register information block */ - gpe_register_info = ACPI_MEM_CALLOCATE ( - (acpi_size) gpe_block->register_count * - sizeof (struct acpi_gpe_register_info)); + gpe_register_info = ACPI_MEM_CALLOCATE((acpi_size) gpe_block-> + register_count * + sizeof(struct + acpi_gpe_register_info)); if (!gpe_register_info) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not allocate the gpe_register_info table\n")); - return_ACPI_STATUS (AE_NO_MEMORY); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not allocate the gpe_register_info table\n")); + return_ACPI_STATUS(AE_NO_MEMORY); } /* * Allocate the GPE event_info block. There are eight distinct GPEs * per register. Initialization to zeros is sufficient. */ - gpe_event_info = ACPI_MEM_CALLOCATE ( - ((acpi_size) gpe_block->register_count * - ACPI_GPE_REGISTER_WIDTH) * - sizeof (struct acpi_gpe_event_info)); + gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block-> + register_count * + ACPI_GPE_REGISTER_WIDTH) * + sizeof(struct acpi_gpe_event_info)); if (!gpe_event_info) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not allocate the gpe_event_info table\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not allocate the gpe_event_info table\n")); status = AE_NO_MEMORY; goto error_exit; } @@ -806,7 +766,7 @@ acpi_ev_create_gpe_info_blocks ( /* Save the new Info arrays in the GPE block */ gpe_block->register_info = gpe_register_info; - gpe_block->event_info = gpe_event_info; + gpe_block->event_info = gpe_event_info; /* * Initialize the GPE Register and Event structures. A goal of these @@ -815,29 +775,34 @@ acpi_ev_create_gpe_info_blocks ( * and the enable registers occupy the second half. */ this_register = gpe_register_info; - this_event = gpe_event_info; + this_event = gpe_event_info; for (i = 0; i < gpe_block->register_count; i++) { /* Init the register_info for this GPE register (8 GPEs) */ - this_register->base_gpe_number = (u8) (gpe_block->block_base_number + - (i * ACPI_GPE_REGISTER_WIDTH)); - - ACPI_STORE_ADDRESS (this_register->status_address.address, - (gpe_block->block_address.address - + i)); - - ACPI_STORE_ADDRESS (this_register->enable_address.address, - (gpe_block->block_address.address - + i - + gpe_block->register_count)); - - this_register->status_address.address_space_id = gpe_block->block_address.address_space_id; - this_register->enable_address.address_space_id = gpe_block->block_address.address_space_id; - this_register->status_address.register_bit_width = ACPI_GPE_REGISTER_WIDTH; - this_register->enable_address.register_bit_width = ACPI_GPE_REGISTER_WIDTH; - this_register->status_address.register_bit_offset = ACPI_GPE_REGISTER_WIDTH; - this_register->enable_address.register_bit_offset = ACPI_GPE_REGISTER_WIDTH; + this_register->base_gpe_number = + (u8) (gpe_block->block_base_number + + (i * ACPI_GPE_REGISTER_WIDTH)); + + ACPI_STORE_ADDRESS(this_register->status_address.address, + (gpe_block->block_address.address + i)); + + ACPI_STORE_ADDRESS(this_register->enable_address.address, + (gpe_block->block_address.address + + i + gpe_block->register_count)); + + this_register->status_address.address_space_id = + gpe_block->block_address.address_space_id; + this_register->enable_address.address_space_id = + gpe_block->block_address.address_space_id; + this_register->status_address.register_bit_width = + ACPI_GPE_REGISTER_WIDTH; + this_register->enable_address.register_bit_width = + ACPI_GPE_REGISTER_WIDTH; + this_register->status_address.register_bit_offset = + ACPI_GPE_REGISTER_WIDTH; + this_register->enable_address.register_bit_offset = + ACPI_GPE_REGISTER_WIDTH; /* Init the event_info for each GPE within this register */ @@ -852,36 +817,36 @@ acpi_ev_create_gpe_info_blocks ( * are cleared by writing a '1', while enable registers are cleared * by writing a '0'. */ - status = acpi_hw_low_level_write (ACPI_GPE_REGISTER_WIDTH, 0x00, - &this_register->enable_address); - if (ACPI_FAILURE (status)) { + status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00, + &this_register-> + enable_address); + if (ACPI_FAILURE(status)) { goto error_exit; } - status = acpi_hw_low_level_write (ACPI_GPE_REGISTER_WIDTH, 0xFF, - &this_register->status_address); - if (ACPI_FAILURE (status)) { + status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF, + &this_register-> + status_address); + if (ACPI_FAILURE(status)) { goto error_exit; } this_register++; } - return_ACPI_STATUS (AE_OK); - + return_ACPI_STATUS(AE_OK); -error_exit: + error_exit: if (gpe_register_info) { - ACPI_MEM_FREE (gpe_register_info); + ACPI_MEM_FREE(gpe_register_info); } if (gpe_event_info) { - ACPI_MEM_FREE (gpe_event_info); + ACPI_MEM_FREE(gpe_event_info); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_create_gpe_block @@ -900,68 +865,66 @@ error_exit: ******************************************************************************/ acpi_status -acpi_ev_create_gpe_block ( - struct acpi_namespace_node *gpe_device, - struct acpi_generic_address *gpe_block_address, - u32 register_count, - u8 gpe_block_base_number, - u32 interrupt_number, - struct acpi_gpe_block_info **return_gpe_block) +acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, + struct acpi_generic_address *gpe_block_address, + u32 register_count, + u8 gpe_block_base_number, + u32 interrupt_number, + struct acpi_gpe_block_info **return_gpe_block) { - struct acpi_gpe_block_info *gpe_block; - struct acpi_gpe_event_info *gpe_event_info; - acpi_native_uint i; - acpi_native_uint j; - u32 wake_gpe_count; - u32 gpe_enabled_count; - acpi_status status; - struct acpi_gpe_walk_info gpe_info; - - - ACPI_FUNCTION_TRACE ("ev_create_gpe_block"); + struct acpi_gpe_block_info *gpe_block; + struct acpi_gpe_event_info *gpe_event_info; + acpi_native_uint i; + acpi_native_uint j; + u32 wake_gpe_count; + u32 gpe_enabled_count; + acpi_status status; + struct acpi_gpe_walk_info gpe_info; + ACPI_FUNCTION_TRACE("ev_create_gpe_block"); if (!register_count) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Allocate a new GPE block */ - gpe_block = ACPI_MEM_CALLOCATE (sizeof (struct acpi_gpe_block_info)); + gpe_block = ACPI_MEM_CALLOCATE(sizeof(struct acpi_gpe_block_info)); if (!gpe_block) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Initialize the new GPE block */ gpe_block->register_count = register_count; gpe_block->block_base_number = gpe_block_base_number; - gpe_block->node = gpe_device; + gpe_block->node = gpe_device; - ACPI_MEMCPY (&gpe_block->block_address, gpe_block_address, - sizeof (struct acpi_generic_address)); + ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address, + sizeof(struct acpi_generic_address)); /* Create the register_info and event_info sub-structures */ - status = acpi_ev_create_gpe_info_blocks (gpe_block); - if (ACPI_FAILURE (status)) { - ACPI_MEM_FREE (gpe_block); - return_ACPI_STATUS (status); + status = acpi_ev_create_gpe_info_blocks(gpe_block); + if (ACPI_FAILURE(status)) { + ACPI_MEM_FREE(gpe_block); + return_ACPI_STATUS(status); } /* Install the new block in the global list(s) */ - status = acpi_ev_install_gpe_block (gpe_block, interrupt_number); - if (ACPI_FAILURE (status)) { - ACPI_MEM_FREE (gpe_block); - return_ACPI_STATUS (status); + status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); + if (ACPI_FAILURE(status)) { + ACPI_MEM_FREE(gpe_block); + return_ACPI_STATUS(status); } /* Find all GPE methods (_Lxx, _Exx) for this block */ - status = acpi_ns_walk_namespace (ACPI_TYPE_METHOD, gpe_device, - ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, acpi_ev_save_method_info, - gpe_block, NULL); + status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device, + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, + acpi_ev_save_method_info, gpe_block, + NULL); /* * Runtime option: Should Wake GPEs be enabled at runtime? The default @@ -977,9 +940,11 @@ acpi_ev_create_gpe_block ( gpe_info.gpe_block = gpe_block; gpe_info.gpe_device = gpe_device; - status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, acpi_ev_match_prw_and_gpe, - &gpe_info, NULL); + status = + acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, + acpi_ev_match_prw_and_gpe, &gpe_info, + NULL); } /* @@ -994,10 +959,14 @@ acpi_ev_create_gpe_block ( for (j = 0; j < 8; j++) { /* Get the info block for this particular GPE */ - gpe_event_info = &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j]; + gpe_event_info = + &gpe_block-> + event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j]; - if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) && - (gpe_event_info->flags & ACPI_GPE_TYPE_RUNTIME)) { + if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_METHOD) + && (gpe_event_info-> + flags & ACPI_GPE_TYPE_RUNTIME)) { gpe_enabled_count++; } @@ -1009,22 +978,22 @@ acpi_ev_create_gpe_block ( /* Dump info about this GPE block */ - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", - (u32) gpe_block->block_base_number, - (u32) (gpe_block->block_base_number + - ((gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) -1)), - gpe_device->name.ascii, - gpe_block->register_count, - interrupt_number)); + ACPI_DEBUG_PRINT((ACPI_DB_INIT, + "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", + (u32) gpe_block->block_base_number, + (u32) (gpe_block->block_base_number + + ((gpe_block->register_count * + ACPI_GPE_REGISTER_WIDTH) - 1)), + gpe_device->name.ascii, gpe_block->register_count, + interrupt_number)); /* Enable all valid GPEs found above */ - status = acpi_hw_enable_runtime_gpe_block (NULL, gpe_block); + status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block); - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "Found %u Wake, Enabled %u Runtime GPEs in this block\n", - wake_gpe_count, gpe_enabled_count)); + ACPI_DEBUG_PRINT((ACPI_DB_INIT, + "Found %u Wake, Enabled %u Runtime GPEs in this block\n", + wake_gpe_count, gpe_enabled_count)); /* Return the new block */ @@ -1032,10 +1001,9 @@ acpi_ev_create_gpe_block ( (*return_gpe_block) = gpe_block; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_gpe_initialize @@ -1048,22 +1016,18 @@ acpi_ev_create_gpe_block ( * ******************************************************************************/ -acpi_status -acpi_ev_gpe_initialize ( - void) +acpi_status acpi_ev_gpe_initialize(void) { - u32 register_count0 = 0; - u32 register_count1 = 0; - u32 gpe_number_max = 0; - acpi_status status; + u32 register_count0 = 0; + u32 register_count1 = 0; + u32 gpe_number_max = 0; + acpi_status status; + ACPI_FUNCTION_TRACE("ev_gpe_initialize"); - ACPI_FUNCTION_TRACE ("ev_gpe_initialize"); - - - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -1091,29 +1055,29 @@ acpi_ev_gpe_initialize ( * If EITHER the register length OR the block address are zero, then that * particular block is not supported. */ - if (acpi_gbl_FADT->gpe0_blk_len && - acpi_gbl_FADT->xgpe0_blk.address) { + if (acpi_gbl_FADT->gpe0_blk_len && acpi_gbl_FADT->xgpe0_blk.address) { /* GPE block 0 exists (has both length and address > 0) */ register_count0 = (u16) (acpi_gbl_FADT->gpe0_blk_len / 2); - gpe_number_max = (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1; + gpe_number_max = + (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1; /* Install GPE Block 0 */ - status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device, - &acpi_gbl_FADT->xgpe0_blk, register_count0, 0, - acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[0]); + status = acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device, + &acpi_gbl_FADT->xgpe0_blk, + register_count0, 0, + acpi_gbl_FADT->sci_int, + &acpi_gbl_gpe_fadt_blocks[0]); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "Could not create GPE Block 0, %s\n", - acpi_format_exception (status))); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not create GPE Block 0, %s\n", + acpi_format_exception(status))); } } - if (acpi_gbl_FADT->gpe1_blk_len && - acpi_gbl_FADT->xgpe1_blk.address) { + if (acpi_gbl_FADT->gpe1_blk_len && acpi_gbl_FADT->xgpe1_blk.address) { /* GPE block 1 exists (has both length and address > 0) */ register_count1 = (u16) (acpi_gbl_FADT->gpe1_blk_len / 2); @@ -1121,29 +1085,26 @@ acpi_ev_gpe_initialize ( /* Check for GPE0/GPE1 overlap (if both banks exist) */ if ((register_count0) && - (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) { - ACPI_REPORT_ERROR (( - "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1\n", - gpe_number_max, acpi_gbl_FADT->gpe1_base, - acpi_gbl_FADT->gpe1_base + - ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1))); + (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) { + ACPI_REPORT_ERROR(("GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1\n", gpe_number_max, acpi_gbl_FADT->gpe1_base, acpi_gbl_FADT->gpe1_base + ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1))); /* Ignore GPE1 block by setting the register count to zero */ register_count1 = 0; - } - else { + } else { /* Install GPE Block 1 */ - status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device, - &acpi_gbl_FADT->xgpe1_blk, register_count1, - acpi_gbl_FADT->gpe1_base, - acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[1]); - - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "Could not create GPE Block 1, %s\n", - acpi_format_exception (status))); + status = + acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device, + &acpi_gbl_FADT->xgpe1_blk, + register_count1, + acpi_gbl_FADT->gpe1_base, + acpi_gbl_FADT->sci_int, + &acpi_gbl_gpe_fadt_blocks + [1]); + + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not create GPE Block 1, %s\n", acpi_format_exception(status))); } /* @@ -1151,7 +1112,7 @@ acpi_ev_gpe_initialize ( * space. However, GPE0 always starts at GPE number zero. */ gpe_number_max = acpi_gbl_FADT->gpe1_base + - ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1); + ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1); } } @@ -1160,8 +1121,8 @@ acpi_ev_gpe_initialize ( if ((register_count0 + register_count1) == 0) { /* GPEs are not required by ACPI, this is OK */ - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "There are no GPE blocks defined in the FADT\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INIT, + "There are no GPE blocks defined in the FADT\n")); status = AE_OK; goto cleanup; } @@ -1169,15 +1130,12 @@ acpi_ev_gpe_initialize ( /* Check for Max GPE number out-of-range */ if (gpe_number_max > ACPI_GPE_MAX) { - ACPI_REPORT_ERROR (("Maximum GPE number from FADT is too large: 0x%X\n", - gpe_number_max)); + ACPI_REPORT_ERROR(("Maximum GPE number from FADT is too large: 0x%X\n", gpe_number_max)); status = AE_BAD_VALUE; goto cleanup; } -cleanup: - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (AE_OK); + cleanup: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(AE_OK); } - - diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c index 3df3ada..7e57b84 100644 --- a/drivers/acpi/events/evmisc.c +++ b/drivers/acpi/events/evmisc.c @@ -47,12 +47,10 @@ #include #define _COMPONENT ACPI_EVENTS - ACPI_MODULE_NAME ("evmisc") - +ACPI_MODULE_NAME("evmisc") #ifdef ACPI_DEBUG_OUTPUT -static const char *acpi_notify_value_names[] = -{ +static const char *acpi_notify_value_names[] = { "Bus Check", "Device Check", "Device Wake", @@ -66,18 +64,11 @@ static const char *acpi_notify_value_names[] = /* Local prototypes */ -static void ACPI_SYSTEM_XFACE -acpi_ev_notify_dispatch ( - void *context); - -static void ACPI_SYSTEM_XFACE -acpi_ev_global_lock_thread ( - void *context); +static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context); -static u32 -acpi_ev_global_lock_handler ( - void *context); +static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context); +static u32 acpi_ev_global_lock_handler(void *context); /******************************************************************************* * @@ -93,9 +84,7 @@ acpi_ev_global_lock_handler ( * ******************************************************************************/ -u8 -acpi_ev_is_notify_object ( - struct acpi_namespace_node *node) +u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node) { switch (node->type) { case ACPI_TYPE_DEVICE: @@ -112,7 +101,6 @@ acpi_ev_is_notify_object ( } } - /******************************************************************************* * * FUNCTION: acpi_ev_queue_notify_request @@ -128,18 +116,15 @@ acpi_ev_is_notify_object ( ******************************************************************************/ acpi_status -acpi_ev_queue_notify_request ( - struct acpi_namespace_node *node, - u32 notify_value) +acpi_ev_queue_notify_request(struct acpi_namespace_node * node, + u32 notify_value) { - union acpi_operand_object *obj_desc; - union acpi_operand_object *handler_obj = NULL; - union acpi_generic_state *notify_info; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_NAME ("ev_queue_notify_request"); + union acpi_operand_object *obj_desc; + union acpi_operand_object *handler_obj = NULL; + union acpi_generic_state *notify_info; + acpi_status status = AE_OK; + ACPI_FUNCTION_NAME("ev_queue_notify_request"); /* * For value 3 (Ejection Request), some device method may need to be run. @@ -148,22 +133,22 @@ acpi_ev_queue_notify_request ( * For value 0x80 (Status Change) on the power button or sleep button, * initiate soft-off or sleep operation? */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Dispatching Notify(%X) on node %p\n", notify_value, node)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Dispatching Notify(%X) on node %p\n", notify_value, + node)); if (notify_value <= 7) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: %s\n", - acpi_notify_value_names[notify_value])); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Notify value: 0x%2.2X **Device Specific**\n", - notify_value)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Notify value: %s\n", + acpi_notify_value_names[notify_value])); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Notify value: 0x%2.2X **Device Specific**\n", + notify_value)); } /* Get the notify object attached to the NS Node */ - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (obj_desc) { /* We have the notify object, Get the right handler */ @@ -174,10 +159,11 @@ acpi_ev_queue_notify_request ( case ACPI_TYPE_POWER: if (notify_value <= ACPI_MAX_SYS_NOTIFY) { - handler_obj = obj_desc->common_notify.system_notify; - } - else { - handler_obj = obj_desc->common_notify.device_notify; + handler_obj = + obj_desc->common_notify.system_notify; + } else { + handler_obj = + obj_desc->common_notify.device_notify; } break; @@ -189,23 +175,25 @@ acpi_ev_queue_notify_request ( /* If there is any handler to run, schedule the dispatcher */ - if ((acpi_gbl_system_notify.handler && (notify_value <= ACPI_MAX_SYS_NOTIFY)) || - (acpi_gbl_device_notify.handler && (notify_value > ACPI_MAX_SYS_NOTIFY)) || - handler_obj) { - notify_info = acpi_ut_create_generic_state (); + if ((acpi_gbl_system_notify.handler + && (notify_value <= ACPI_MAX_SYS_NOTIFY)) + || (acpi_gbl_device_notify.handler + && (notify_value > ACPI_MAX_SYS_NOTIFY)) || handler_obj) { + notify_info = acpi_ut_create_generic_state(); if (!notify_info) { return (AE_NO_MEMORY); } notify_info->common.data_type = ACPI_DESC_TYPE_STATE_NOTIFY; - notify_info->notify.node = node; - notify_info->notify.value = (u16) notify_value; + notify_info->notify.node = node; + notify_info->notify.value = (u16) notify_value; notify_info->notify.handler_obj = handler_obj; - status = acpi_os_queue_for_execution (OSD_PRIORITY_HIGH, - acpi_ev_notify_dispatch, notify_info); - if (ACPI_FAILURE (status)) { - acpi_ut_delete_generic_state (notify_info); + status = acpi_os_queue_for_execution(OSD_PRIORITY_HIGH, + acpi_ev_notify_dispatch, + notify_info); + if (ACPI_FAILURE(status)) { + acpi_ut_delete_generic_state(notify_info); } } @@ -214,15 +202,15 @@ acpi_ev_queue_notify_request ( * There is no per-device notify handler for this device. * This may or may not be a problem. */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "No notify handler for Notify(%4.4s, %X) node %p\n", - acpi_ut_get_node_name (node), notify_value, node)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "No notify handler for Notify(%4.4s, %X) node %p\n", + acpi_ut_get_node_name(node), notify_value, + node)); } return (status); } - /******************************************************************************* * * FUNCTION: acpi_ev_notify_dispatch @@ -236,18 +224,15 @@ acpi_ev_queue_notify_request ( * ******************************************************************************/ -static void ACPI_SYSTEM_XFACE -acpi_ev_notify_dispatch ( - void *context) +static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context) { - union acpi_generic_state *notify_info = (union acpi_generic_state *) context; - acpi_notify_handler global_handler = NULL; - void *global_context = NULL; - union acpi_operand_object *handler_obj; - - - ACPI_FUNCTION_ENTRY (); + union acpi_generic_state *notify_info = + (union acpi_generic_state *)context; + acpi_notify_handler global_handler = NULL; + void *global_context = NULL; + union acpi_operand_object *handler_obj; + ACPI_FUNCTION_ENTRY(); /* * We will invoke a global notify handler if installed. @@ -261,8 +246,7 @@ acpi_ev_notify_dispatch ( global_handler = acpi_gbl_system_notify.handler; global_context = acpi_gbl_system_notify.context; } - } - else { + } else { /* Global driver notification handler */ if (acpi_gbl_device_notify.handler) { @@ -274,25 +258,24 @@ acpi_ev_notify_dispatch ( /* Invoke the system handler first, if present */ if (global_handler) { - global_handler (notify_info->notify.node, notify_info->notify.value, - global_context); + global_handler(notify_info->notify.node, + notify_info->notify.value, global_context); } /* Now invoke the per-device handler, if present */ handler_obj = notify_info->notify.handler_obj; if (handler_obj) { - handler_obj->notify.handler (notify_info->notify.node, - notify_info->notify.value, - handler_obj->notify.context); + handler_obj->notify.handler(notify_info->notify.node, + notify_info->notify.value, + handler_obj->notify.context); } /* All done with the info object */ - acpi_ut_delete_generic_state (notify_info); + acpi_ut_delete_generic_state(notify_info); } - /******************************************************************************* * * FUNCTION: acpi_ev_global_lock_thread @@ -307,27 +290,24 @@ acpi_ev_notify_dispatch ( * ******************************************************************************/ -static void ACPI_SYSTEM_XFACE -acpi_ev_global_lock_thread ( - void *context) +static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context) { - acpi_status status; - + acpi_status status; /* Signal threads that are waiting for the lock */ if (acpi_gbl_global_lock_thread_count) { /* Send sufficient units to the semaphore */ - status = acpi_os_signal_semaphore (acpi_gbl_global_lock_semaphore, - acpi_gbl_global_lock_thread_count); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not signal Global Lock semaphore\n")); + status = + acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore, + acpi_gbl_global_lock_thread_count); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not signal Global Lock semaphore\n")); } } } - /******************************************************************************* * * FUNCTION: acpi_ev_global_lock_handler @@ -342,20 +322,17 @@ acpi_ev_global_lock_thread ( * ******************************************************************************/ -static u32 -acpi_ev_global_lock_handler ( - void *context) +static u32 acpi_ev_global_lock_handler(void *context) { - u8 acquired = FALSE; - acpi_status status; - + u8 acquired = FALSE; + acpi_status status; /* * Attempt to get the lock * If we don't get it now, it will be marked pending and we will * take another interrupt when it becomes free. */ - ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired); + ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, acquired); if (acquired) { /* Got the lock, now wake all threads waiting for it */ @@ -363,11 +340,11 @@ acpi_ev_global_lock_handler ( /* Run the Global Lock thread which will signal all waiting threads */ - status = acpi_os_queue_for_execution (OSD_PRIORITY_HIGH, - acpi_ev_global_lock_thread, context); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not queue Global Lock thread, %s\n", - acpi_format_exception (status))); + status = acpi_os_queue_for_execution(OSD_PRIORITY_HIGH, + acpi_ev_global_lock_thread, + context); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not queue Global Lock thread, %s\n", acpi_format_exception(status))); return (ACPI_INTERRUPT_NOT_HANDLED); } @@ -376,7 +353,6 @@ acpi_ev_global_lock_handler ( return (ACPI_INTERRUPT_HANDLED); } - /******************************************************************************* * * FUNCTION: acpi_ev_init_global_lock_handler @@ -389,19 +365,16 @@ acpi_ev_global_lock_handler ( * ******************************************************************************/ -acpi_status -acpi_ev_init_global_lock_handler ( - void) +acpi_status acpi_ev_init_global_lock_handler(void) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_init_global_lock_handler"); + acpi_status status; + ACPI_FUNCTION_TRACE("ev_init_global_lock_handler"); acpi_gbl_global_lock_present = TRUE; - status = acpi_install_fixed_event_handler (ACPI_EVENT_GLOBAL, - acpi_ev_global_lock_handler, NULL); + status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL, + acpi_ev_global_lock_handler, + NULL); /* * If the global lock does not exist on this platform, the attempt @@ -411,17 +384,15 @@ acpi_ev_init_global_lock_handler ( * with an error. */ if (status == AE_NO_HARDWARE_RESPONSE) { - ACPI_REPORT_ERROR (( - "No response from Global Lock hardware, disabling lock\n")); + ACPI_REPORT_ERROR(("No response from Global Lock hardware, disabling lock\n")); acpi_gbl_global_lock_present = FALSE; status = AE_OK; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /****************************************************************************** * * FUNCTION: acpi_ev_acquire_global_lock @@ -434,22 +405,18 @@ acpi_ev_init_global_lock_handler ( * *****************************************************************************/ -acpi_status -acpi_ev_acquire_global_lock ( - u16 timeout) +acpi_status acpi_ev_acquire_global_lock(u16 timeout) { - acpi_status status = AE_OK; - u8 acquired = FALSE; - - - ACPI_FUNCTION_TRACE ("ev_acquire_global_lock"); + acpi_status status = AE_OK; + u8 acquired = FALSE; + ACPI_FUNCTION_TRACE("ev_acquire_global_lock"); #ifndef ACPI_APPLICATION /* Make sure that we actually have a global lock */ if (!acpi_gbl_global_lock_present) { - return_ACPI_STATUS (AE_NO_GLOBAL_LOCK); + return_ACPI_STATUS(AE_NO_GLOBAL_LOCK); } #endif @@ -462,37 +429,37 @@ acpi_ev_acquire_global_lock ( * we are done */ if (acpi_gbl_global_lock_acquired) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* We must acquire the actual hardware lock */ - ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired); + ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, acquired); if (acquired) { - /* We got the lock */ + /* We got the lock */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired the HW Global Lock\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Acquired the HW Global Lock\n")); acpi_gbl_global_lock_acquired = TRUE; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* * Did not get the lock. The pending bit was set above, and we must now * wait until we get the global lock released interrupt. */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n")); /* * Acquire the global lock semaphore first. * Since this wait will block, we must release the interpreter */ - status = acpi_ex_system_wait_semaphore (acpi_gbl_global_lock_semaphore, - timeout); - return_ACPI_STATUS (status); + status = acpi_ex_system_wait_semaphore(acpi_gbl_global_lock_semaphore, + timeout); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_release_global_lock @@ -505,21 +472,16 @@ acpi_ev_acquire_global_lock ( * ******************************************************************************/ -acpi_status -acpi_ev_release_global_lock ( - void) +acpi_status acpi_ev_release_global_lock(void) { - u8 pending = FALSE; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ev_release_global_lock"); + u8 pending = FALSE; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ev_release_global_lock"); if (!acpi_gbl_global_lock_thread_count) { - ACPI_REPORT_WARNING(( - "Cannot release HW Global Lock, it has not been acquired\n")); - return_ACPI_STATUS (AE_NOT_ACQUIRED); + ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n")); + return_ACPI_STATUS(AE_NOT_ACQUIRED); } /* One fewer thread has the global lock */ @@ -528,14 +490,14 @@ acpi_ev_release_global_lock ( if (acpi_gbl_global_lock_thread_count) { /* There are still some threads holding the lock, cannot release */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* * No more threads holding lock, we can do the actual hardware * release */ - ACPI_RELEASE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, pending); + ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, pending); acpi_gbl_global_lock_acquired = FALSE; /* @@ -543,14 +505,13 @@ acpi_ev_release_global_lock ( * register */ if (pending) { - status = acpi_set_register (ACPI_BITREG_GLOBAL_LOCK_RELEASE, - 1, ACPI_MTX_LOCK); + status = acpi_set_register(ACPI_BITREG_GLOBAL_LOCK_RELEASE, + 1, ACPI_MTX_LOCK); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /****************************************************************************** * * FUNCTION: acpi_ev_terminate @@ -563,16 +524,12 @@ acpi_ev_release_global_lock ( * ******************************************************************************/ -void -acpi_ev_terminate ( - void) +void acpi_ev_terminate(void) { - acpi_native_uint i; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_terminate"); + acpi_native_uint i; + acpi_status status; + ACPI_FUNCTION_TRACE("ev_terminate"); if (acpi_gbl_events_initialized) { /* @@ -583,38 +540,39 @@ acpi_ev_terminate ( /* Disable all fixed events */ for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { - status = acpi_disable_event ((u32) i, 0); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not disable fixed event %d\n", (u32) i)); + status = acpi_disable_event((u32) i, 0); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not disable fixed event %d\n", + (u32) i)); } } /* Disable all GPEs in all GPE blocks */ - status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block); + status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block); /* Remove SCI handler */ - status = acpi_ev_remove_sci_handler (); + status = acpi_ev_remove_sci_handler(); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not remove SCI handler\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not remove SCI handler\n")); } } /* Deallocate all handler objects installed within GPE info structs */ - status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers); + status = acpi_ev_walk_gpe_list(acpi_ev_delete_gpe_handlers); /* Return to original mode if necessary */ if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) { - status = acpi_disable (); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_disable failed\n")); + status = acpi_disable(); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "acpi_disable failed\n")); } } return_VOID; } - diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c index a1d7276c..84fad08 100644 --- a/drivers/acpi/events/evregion.c +++ b/drivers/acpi/events/evregion.c @@ -41,39 +41,30 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include #define _COMPONENT ACPI_EVENTS - ACPI_MODULE_NAME ("evregion") - +ACPI_MODULE_NAME("evregion") #define ACPI_NUM_DEFAULT_SPACES 4 - -static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { - ACPI_ADR_SPACE_SYSTEM_MEMORY, - ACPI_ADR_SPACE_SYSTEM_IO, - ACPI_ADR_SPACE_PCI_CONFIG, - ACPI_ADR_SPACE_DATA_TABLE}; +static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { + ACPI_ADR_SPACE_SYSTEM_MEMORY, + ACPI_ADR_SPACE_SYSTEM_IO, + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_ADR_SPACE_DATA_TABLE +}; /* Local prototypes */ static acpi_status -acpi_ev_reg_run ( - acpi_handle obj_handle, - u32 level, - void *context, - void **return_value); +acpi_ev_reg_run(acpi_handle obj_handle, + u32 level, void *context, void **return_value); static acpi_status -acpi_ev_install_handler ( - acpi_handle obj_handle, - u32 level, - void *context, - void **return_value); - +acpi_ev_install_handler(acpi_handle obj_handle, + u32 level, void *context, void **return_value); /******************************************************************************* * @@ -87,19 +78,16 @@ acpi_ev_install_handler ( * ******************************************************************************/ -acpi_status -acpi_ev_install_region_handlers ( - void) { - acpi_status status; - acpi_native_uint i; - - - ACPI_FUNCTION_TRACE ("ev_install_region_handlers"); +acpi_status acpi_ev_install_region_handlers(void) +{ + acpi_status status; + acpi_native_uint i; + ACPI_FUNCTION_TRACE("ev_install_region_handlers"); - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -121,9 +109,11 @@ acpi_ev_install_region_handlers ( * Similar for AE_SAME_HANDLER. */ for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { - status = acpi_ev_install_space_handler (acpi_gbl_root_node, - acpi_gbl_default_address_spaces[i], - ACPI_DEFAULT_HANDLER, NULL, NULL); + status = acpi_ev_install_space_handler(acpi_gbl_root_node, + acpi_gbl_default_address_spaces + [i], + ACPI_DEFAULT_HANDLER, + NULL, NULL); switch (status) { case AE_OK: case AE_SAME_HANDLER: @@ -140,12 +130,11 @@ acpi_ev_install_region_handlers ( } } -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (status); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_initialize_op_regions @@ -159,20 +148,16 @@ unlock_and_exit: * ******************************************************************************/ -acpi_status -acpi_ev_initialize_op_regions ( - void) +acpi_status acpi_ev_initialize_op_regions(void) { - acpi_status status; - acpi_native_uint i; - + acpi_status status; + acpi_native_uint i; - ACPI_FUNCTION_TRACE ("ev_initialize_op_regions"); + ACPI_FUNCTION_TRACE("ev_initialize_op_regions"); - - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -182,15 +167,15 @@ acpi_ev_initialize_op_regions ( /* TBD: Make sure handler is the DEFAULT handler, otherwise * _REG will have already been run. */ - status = acpi_ev_execute_reg_methods (acpi_gbl_root_node, - acpi_gbl_default_address_spaces[i]); + status = acpi_ev_execute_reg_methods(acpi_gbl_root_node, + acpi_gbl_default_address_spaces + [i]); } - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (status); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_execute_reg_method @@ -205,26 +190,22 @@ acpi_ev_initialize_op_regions ( ******************************************************************************/ acpi_status -acpi_ev_execute_reg_method ( - union acpi_operand_object *region_obj, - u32 function) +acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function) { - struct acpi_parameter_info info; - union acpi_operand_object *params[3]; - union acpi_operand_object *region_obj2; - acpi_status status; - + struct acpi_parameter_info info; + union acpi_operand_object *params[3]; + union acpi_operand_object *region_obj2; + acpi_status status; - ACPI_FUNCTION_TRACE ("ev_execute_reg_method"); + ACPI_FUNCTION_TRACE("ev_execute_reg_method"); - - region_obj2 = acpi_ns_get_secondary_object (region_obj); + region_obj2 = acpi_ns_get_secondary_object(region_obj); if (!region_obj2) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } if (region_obj2->extra.method_REG == NULL) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* @@ -237,12 +218,12 @@ acpi_ev_execute_reg_method ( * 0 for disconnecting the handler * Passed as a parameter */ - params[0] = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + params[0] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!params[0]) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } - params[1] = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + params[1] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!params[1]) { status = AE_NO_MEMORY; goto cleanup; @@ -260,19 +241,18 @@ acpi_ev_execute_reg_method ( /* Execute the method, no return value */ - ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname ( - ACPI_TYPE_METHOD, info.node, NULL)); - status = acpi_ns_evaluate_by_handle (&info); + ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname + (ACPI_TYPE_METHOD, info.node, NULL)); + status = acpi_ns_evaluate_by_handle(&info); - acpi_ut_remove_reference (params[1]); + acpi_ut_remove_reference(params[1]); -cleanup: - acpi_ut_remove_reference (params[0]); + cleanup: + acpi_ut_remove_reference(params[0]); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_address_space_dispatch @@ -291,40 +271,38 @@ cleanup: ******************************************************************************/ acpi_status -acpi_ev_address_space_dispatch ( - union acpi_operand_object *region_obj, - u32 function, - acpi_physical_address address, - u32 bit_width, - void *value) +acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, + u32 function, + acpi_physical_address address, + u32 bit_width, void *value) { - acpi_status status; - acpi_status status2; - acpi_adr_space_handler handler; - acpi_adr_space_setup region_setup; - union acpi_operand_object *handler_desc; - union acpi_operand_object *region_obj2; - void *region_context = NULL; + acpi_status status; + acpi_status status2; + acpi_adr_space_handler handler; + acpi_adr_space_setup region_setup; + union acpi_operand_object *handler_desc; + union acpi_operand_object *region_obj2; + void *region_context = NULL; + ACPI_FUNCTION_TRACE("ev_address_space_dispatch"); - ACPI_FUNCTION_TRACE ("ev_address_space_dispatch"); - - - region_obj2 = acpi_ns_get_secondary_object (region_obj); + region_obj2 = acpi_ns_get_secondary_object(region_obj); if (!region_obj2) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } /* Ensure that there is a handler associated with this region */ handler_desc = region_obj->region.handler; if (!handler_desc) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "No handler for Region [%4.4s] (%p) [%s]\n", - acpi_ut_get_node_name (region_obj->region.node), - region_obj, acpi_ut_get_region_name (region_obj->region.space_id))); - - return_ACPI_STATUS (AE_NOT_EXIST); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No handler for Region [%4.4s] (%p) [%s]\n", + acpi_ut_get_node_name(region_obj->region. + node), region_obj, + acpi_ut_get_region_name(region_obj->region. + space_id))); + + return_ACPI_STATUS(AE_NOT_EXIST); } /* @@ -339,10 +317,13 @@ acpi_ev_address_space_dispatch ( if (!region_setup) { /* No initialization routine, exit with error */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "No init routine for region(%p) [%s]\n", - region_obj, acpi_ut_get_region_name (region_obj->region.space_id))); - return_ACPI_STATUS (AE_NOT_EXIST); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No init routine for region(%p) [%s]\n", + region_obj, + acpi_ut_get_region_name(region_obj-> + region. + space_id))); + return_ACPI_STATUS(AE_NOT_EXIST); } /* @@ -350,25 +331,29 @@ acpi_ev_address_space_dispatch ( * setup will potentially execute control methods * (e.g., _REG method for this region) */ - acpi_ex_exit_interpreter (); + acpi_ex_exit_interpreter(); - status = region_setup (region_obj, ACPI_REGION_ACTIVATE, - handler_desc->address_space.context, ®ion_context); + status = region_setup(region_obj, ACPI_REGION_ACTIVATE, + handler_desc->address_space.context, + ®ion_context); /* Re-enter the interpreter */ - status2 = acpi_ex_enter_interpreter (); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); + status2 = acpi_ex_enter_interpreter(); + if (ACPI_FAILURE(status2)) { + return_ACPI_STATUS(status2); } /* Check for failure of the Region Setup */ - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region Init: %s [%s]\n", - acpi_format_exception (status), - acpi_ut_get_region_name (region_obj->region.space_id))); - return_ACPI_STATUS (status); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Region Init: %s [%s]\n", + acpi_format_exception(status), + acpi_ut_get_region_name(region_obj-> + region. + space_id))); + return_ACPI_STATUS(status); } /* @@ -380,14 +365,14 @@ acpi_ev_address_space_dispatch ( if (region_obj2->extra.region_context) { /* The handler for this region was already installed */ - ACPI_MEM_FREE (region_context); - } - else { + ACPI_MEM_FREE(region_context); + } else { /* * Save the returned context for use in all accesses to * this particular region */ - region_obj2->extra.region_context = region_context; + region_obj2->extra.region_context = + region_context; } } } @@ -396,13 +381,16 @@ acpi_ev_address_space_dispatch ( handler = handler_desc->address_space.handler; - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", - ®ion_obj->region.handler->address_space, handler, - ACPI_FORMAT_UINT64 (address), - acpi_ut_get_region_name (region_obj->region.space_id))); + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, + "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", + ®ion_obj->region.handler->address_space, handler, + ACPI_FORMAT_UINT64(address), + acpi_ut_get_region_name(region_obj->region. + space_id))); - if (!(handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { + if (! + (handler_desc->address_space. + hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { /* * For handlers other than the default (supplied) handlers, we must * exit the interpreter because the handler *might* block -- we don't @@ -413,31 +401,33 @@ acpi_ev_address_space_dispatch ( /* Call the handler */ - status = handler (function, address, bit_width, value, + status = handler(function, address, bit_width, value, handler_desc->address_space.context, region_obj2->extra.region_context); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Handler for [%s] returned %s\n", - acpi_ut_get_region_name (region_obj->region.space_id), - acpi_format_exception (status))); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Handler for [%s] returned %s\n", + acpi_ut_get_region_name(region_obj->region. + space_id), + acpi_format_exception(status))); } - if (!(handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { + if (! + (handler_desc->address_space. + hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { /* * We just returned from a non-default handler, we must re-enter the * interpreter */ - status2 = acpi_ex_enter_interpreter (); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); + status2 = acpi_ex_enter_interpreter(); + if (ACPI_FAILURE(status2)) { + return_ACPI_STATUS(status2); } } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_detach_region @@ -453,23 +443,20 @@ acpi_ev_address_space_dispatch ( ******************************************************************************/ void -acpi_ev_detach_region( - union acpi_operand_object *region_obj, - u8 acpi_ns_is_locked) +acpi_ev_detach_region(union acpi_operand_object *region_obj, + u8 acpi_ns_is_locked) { - union acpi_operand_object *handler_obj; - union acpi_operand_object *obj_desc; - union acpi_operand_object **last_obj_ptr; - acpi_adr_space_setup region_setup; - void **region_context; - union acpi_operand_object *region_obj2; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_detach_region"); + union acpi_operand_object *handler_obj; + union acpi_operand_object *obj_desc; + union acpi_operand_object **last_obj_ptr; + acpi_adr_space_setup region_setup; + void **region_context; + union acpi_operand_object *region_obj2; + acpi_status status; + ACPI_FUNCTION_TRACE("ev_detach_region"); - region_obj2 = acpi_ns_get_secondary_object (region_obj); + region_obj2 = acpi_ns_get_secondary_object(region_obj); if (!region_obj2) { return_VOID; } @@ -493,34 +480,39 @@ acpi_ev_detach_region( /* Is this the correct Region? */ if (obj_desc == region_obj) { - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Removing Region %p from address handler %p\n", - region_obj, handler_obj)); + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, + "Removing Region %p from address handler %p\n", + region_obj, handler_obj)); /* This is it, remove it from the handler's list */ *last_obj_ptr = obj_desc->region.next; - obj_desc->region.next = NULL; /* Must clear field */ + obj_desc->region.next = NULL; /* Must clear field */ if (acpi_ns_is_locked) { - status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return_VOID; } } /* Now stop region accesses by executing the _REG method */ - status = acpi_ev_execute_reg_method (region_obj, 0); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region _REG, [%s]\n", - acpi_format_exception (status), - acpi_ut_get_region_name (region_obj->region.space_id))); + status = acpi_ev_execute_reg_method(region_obj, 0); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "%s from region _REG, [%s]\n", + acpi_format_exception(status), + acpi_ut_get_region_name + (region_obj->region. + space_id))); } if (acpi_ns_is_locked) { - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return_VOID; } } @@ -528,15 +520,20 @@ acpi_ev_detach_region( /* Call the setup handler with the deactivate notification */ region_setup = handler_obj->address_space.setup; - status = region_setup (region_obj, ACPI_REGION_DEACTIVATE, - handler_obj->address_space.context, region_context); + status = + region_setup(region_obj, ACPI_REGION_DEACTIVATE, + handler_obj->address_space.context, + region_context); /* Init routine may fail, Just ignore errors */ - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region init, [%s]\n", - acpi_format_exception (status), - acpi_ut_get_region_name (region_obj->region.space_id))); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "%s from region init, [%s]\n", + acpi_format_exception(status), + acpi_ut_get_region_name + (region_obj->region. + space_id))); } region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE); @@ -552,7 +549,7 @@ acpi_ev_detach_region( * this better be the region's handler */ region_obj->region.handler = NULL; - acpi_ut_remove_reference (handler_obj); + acpi_ut_remove_reference(handler_obj); return_VOID; } @@ -565,14 +562,13 @@ acpi_ev_detach_region( /* If we get here, the region was not in the handler's region list */ - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Cannot remove region %p from address handler %p\n", - region_obj, handler_obj)); + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, + "Cannot remove region %p from address handler %p\n", + region_obj, handler_obj)); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ev_attach_region @@ -589,20 +585,19 @@ acpi_ev_detach_region( ******************************************************************************/ acpi_status -acpi_ev_attach_region ( - union acpi_operand_object *handler_obj, - union acpi_operand_object *region_obj, - u8 acpi_ns_is_locked) +acpi_ev_attach_region(union acpi_operand_object *handler_obj, + union acpi_operand_object *region_obj, + u8 acpi_ns_is_locked) { - ACPI_FUNCTION_TRACE ("ev_attach_region"); - + ACPI_FUNCTION_TRACE("ev_attach_region"); - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Adding Region [%4.4s] %p to address handler %p [%s]\n", - acpi_ut_get_node_name (region_obj->region.node), - region_obj, handler_obj, - acpi_ut_get_region_name (region_obj->region.space_id))); + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, + "Adding Region [%4.4s] %p to address handler %p [%s]\n", + acpi_ut_get_node_name(region_obj->region.node), + region_obj, handler_obj, + acpi_ut_get_region_name(region_obj->region. + space_id))); /* Link this region to the front of the handler's list */ @@ -612,16 +607,15 @@ acpi_ev_attach_region ( /* Install the region's handler */ if (region_obj->region.handler) { - return_ACPI_STATUS (AE_ALREADY_EXISTS); + return_ACPI_STATUS(AE_ALREADY_EXISTS); } region_obj->region.handler = handler_obj; - acpi_ut_add_reference (handler_obj); + acpi_ut_add_reference(handler_obj); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_install_handler @@ -640,23 +634,18 @@ acpi_ev_attach_region ( ******************************************************************************/ static acpi_status -acpi_ev_install_handler ( - acpi_handle obj_handle, - u32 level, - void *context, - void **return_value) +acpi_ev_install_handler(acpi_handle obj_handle, + u32 level, void *context, void **return_value) { - union acpi_operand_object *handler_obj; - union acpi_operand_object *next_handler_obj; - union acpi_operand_object *obj_desc; - struct acpi_namespace_node *node; - acpi_status status; + union acpi_operand_object *handler_obj; + union acpi_operand_object *next_handler_obj; + union acpi_operand_object *obj_desc; + struct acpi_namespace_node *node; + acpi_status status; + ACPI_FUNCTION_NAME("ev_install_handler"); - ACPI_FUNCTION_NAME ("ev_install_handler"); - - - handler_obj = (union acpi_operand_object *) context; + handler_obj = (union acpi_operand_object *)context; /* Parameter validation */ @@ -666,7 +655,7 @@ acpi_ev_install_handler ( /* Convert and validate the device handle */ - node = acpi_ns_map_handle_to_node (obj_handle); + node = acpi_ns_map_handle_to_node(obj_handle); if (!node) { return (AE_BAD_PARAMETER); } @@ -676,14 +665,13 @@ acpi_ev_install_handler ( * that are allowed to have address space handlers */ if ((node->type != ACPI_TYPE_DEVICE) && - (node->type != ACPI_TYPE_REGION) && - (node != acpi_gbl_root_node)) { + (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { return (AE_OK); } /* Check for an existing internal object */ - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { /* No object, just exit */ @@ -692,18 +680,22 @@ acpi_ev_install_handler ( /* Devices are handled different than regions */ - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_DEVICE) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_DEVICE) { /* Check if this Device already has a handler for this address space */ next_handler_obj = obj_desc->device.handler; while (next_handler_obj) { /* Found a handler, is it for the same address space? */ - if (next_handler_obj->address_space.space_id == handler_obj->address_space.space_id) { - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Found handler for region [%s] in device %p(%p) handler %p\n", - acpi_ut_get_region_name (handler_obj->address_space.space_id), - obj_desc, next_handler_obj, handler_obj)); + if (next_handler_obj->address_space.space_id == + handler_obj->address_space.space_id) { + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, + "Found handler for region [%s] in device %p(%p) handler %p\n", + acpi_ut_get_region_name + (handler_obj->address_space. + space_id), obj_desc, + next_handler_obj, + handler_obj)); /* * Since the object we found it on was a device, then it @@ -744,15 +736,14 @@ acpi_ev_install_handler ( * * First disconnect region for any previous handler (if any) */ - acpi_ev_detach_region (obj_desc, FALSE); + acpi_ev_detach_region(obj_desc, FALSE); /* Connect the region to the new handler */ - status = acpi_ev_attach_region (handler_obj, obj_desc, FALSE); + status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE); return (status); } - /******************************************************************************* * * FUNCTION: acpi_ev_install_space_handler @@ -771,32 +762,27 @@ acpi_ev_install_handler ( ******************************************************************************/ acpi_status -acpi_ev_install_space_handler ( - struct acpi_namespace_node *node, - acpi_adr_space_type space_id, - acpi_adr_space_handler handler, - acpi_adr_space_setup setup, - void *context) +acpi_ev_install_space_handler(struct acpi_namespace_node * node, + acpi_adr_space_type space_id, + acpi_adr_space_handler handler, + acpi_adr_space_setup setup, void *context) { - union acpi_operand_object *obj_desc; - union acpi_operand_object *handler_obj; - acpi_status status; - acpi_object_type type; - u16 flags = 0; - - - ACPI_FUNCTION_TRACE ("ev_install_space_handler"); + union acpi_operand_object *obj_desc; + union acpi_operand_object *handler_obj; + acpi_status status; + acpi_object_type type; + u16 flags = 0; + ACPI_FUNCTION_TRACE("ev_install_space_handler"); /* * This registration is valid for only the types below * and the root. This is where the default handlers * get placed. */ - if ((node->type != ACPI_TYPE_DEVICE) && - (node->type != ACPI_TYPE_PROCESSOR) && - (node->type != ACPI_TYPE_THERMAL) && - (node != acpi_gbl_root_node)) { + if ((node->type != ACPI_TYPE_DEVICE) && + (node->type != ACPI_TYPE_PROCESSOR) && + (node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } @@ -807,32 +793,32 @@ acpi_ev_install_space_handler ( switch (space_id) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: handler = acpi_ex_system_memory_space_handler; - setup = acpi_ev_system_memory_region_setup; + setup = acpi_ev_system_memory_region_setup; break; case ACPI_ADR_SPACE_SYSTEM_IO: handler = acpi_ex_system_io_space_handler; - setup = acpi_ev_io_space_region_setup; + setup = acpi_ev_io_space_region_setup; break; case ACPI_ADR_SPACE_PCI_CONFIG: handler = acpi_ex_pci_config_space_handler; - setup = acpi_ev_pci_config_region_setup; + setup = acpi_ev_pci_config_region_setup; break; case ACPI_ADR_SPACE_CMOS: handler = acpi_ex_cmos_space_handler; - setup = acpi_ev_cmos_region_setup; + setup = acpi_ev_cmos_region_setup; break; case ACPI_ADR_SPACE_PCI_BAR_TARGET: handler = acpi_ex_pci_bar_space_handler; - setup = acpi_ev_pci_bar_region_setup; + setup = acpi_ev_pci_bar_region_setup; break; case ACPI_ADR_SPACE_DATA_TABLE: handler = acpi_ex_data_table_space_handler; - setup = NULL; + setup = NULL; break; default: @@ -849,7 +835,7 @@ acpi_ev_install_space_handler ( /* Check for an existing internal object */ - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (obj_desc) { /* * The attached device object already exists. @@ -863,7 +849,8 @@ acpi_ev_install_space_handler ( /* Same space_id indicates a handler already installed */ if (handler_obj->address_space.space_id == space_id) { - if (handler_obj->address_space.handler == handler) { + if (handler_obj->address_space.handler == + handler) { /* * It is (relatively) OK to attempt to install the SAME * handler twice. This can easily happen @@ -871,8 +858,7 @@ acpi_ev_install_space_handler ( */ status = AE_SAME_HANDLER; goto unlock_and_exit; - } - else { + } else { /* A handler is already installed */ status = AE_ALREADY_EXISTS; @@ -884,21 +870,20 @@ acpi_ev_install_space_handler ( handler_obj = handler_obj->address_space.next; } - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Creating object on Device %p while installing handler\n", node)); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, + "Creating object on Device %p while installing handler\n", + node)); /* obj_desc does not exist, create one */ if (node->type == ACPI_TYPE_ANY) { type = ACPI_TYPE_DEVICE; - } - else { + } else { type = node->type; } - obj_desc = acpi_ut_create_internal_object (type); + obj_desc = acpi_ut_create_internal_object(type); if (!obj_desc) { status = AE_NO_MEMORY; goto unlock_and_exit; @@ -910,21 +895,21 @@ acpi_ev_install_space_handler ( /* Attach the new object to the Node */ - status = acpi_ns_attach_object (node, obj_desc, type); + status = acpi_ns_attach_object(node, obj_desc, type); /* Remove local reference to the object */ - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } } - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", - acpi_ut_get_region_name (space_id), space_id, - acpi_ut_get_node_name (node), node, obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, + "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", + acpi_ut_get_region_name(space_id), space_id, + acpi_ut_get_node_name(node), node, obj_desc)); /* * Install the handler @@ -933,7 +918,8 @@ acpi_ev_install_space_handler ( * Just allocate the object for the handler and link it * into the list. */ - handler_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); + handler_obj = + acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER); if (!handler_obj) { status = AE_NO_MEMORY; goto unlock_and_exit; @@ -941,17 +927,17 @@ acpi_ev_install_space_handler ( /* Init handler obj */ - handler_obj->address_space.space_id = (u8) space_id; - handler_obj->address_space.hflags = flags; + handler_obj->address_space.space_id = (u8) space_id; + handler_obj->address_space.hflags = flags; handler_obj->address_space.region_list = NULL; - handler_obj->address_space.node = node; - handler_obj->address_space.handler = handler; - handler_obj->address_space.context = context; - handler_obj->address_space.setup = setup; + handler_obj->address_space.node = node; + handler_obj->address_space.handler = handler; + handler_obj->address_space.context = context; + handler_obj->address_space.setup = setup; /* Install at head of Device.address_space list */ - handler_obj->address_space.next = obj_desc->device.handler; + handler_obj->address_space.next = obj_desc->device.handler; /* * The Device object is the first reference on the handler_obj. @@ -971,15 +957,15 @@ acpi_ev_install_space_handler ( * In either case, back up and search down the remainder * of the branch */ - status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, acpi_ev_install_handler, - handler_obj, NULL); + status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, + acpi_ev_install_handler, handler_obj, + NULL); -unlock_and_exit: - return_ACPI_STATUS (status); + unlock_and_exit: + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_execute_reg_methods @@ -995,15 +981,12 @@ unlock_and_exit: ******************************************************************************/ acpi_status -acpi_ev_execute_reg_methods ( - struct acpi_namespace_node *node, - acpi_adr_space_type space_id) +acpi_ev_execute_reg_methods(struct acpi_namespace_node *node, + acpi_adr_space_type space_id) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_execute_reg_methods"); + acpi_status status; + ACPI_FUNCTION_TRACE("ev_execute_reg_methods"); /* * Run all _REG methods for all Operation Regions for this @@ -1012,14 +995,13 @@ acpi_ev_execute_reg_methods ( * must be installed for all regions of this Space ID before we * can run any _REG methods) */ - status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, - &space_id, NULL); + status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, + &space_id, NULL); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ev_reg_run @@ -1031,23 +1013,19 @@ acpi_ev_execute_reg_methods ( ******************************************************************************/ static acpi_status -acpi_ev_reg_run ( - acpi_handle obj_handle, - u32 level, - void *context, - void **return_value) +acpi_ev_reg_run(acpi_handle obj_handle, + u32 level, void *context, void **return_value) { - union acpi_operand_object *obj_desc; - struct acpi_namespace_node *node; - acpi_adr_space_type space_id; - acpi_status status; + union acpi_operand_object *obj_desc; + struct acpi_namespace_node *node; + acpi_adr_space_type space_id; + acpi_status status; - - space_id = *ACPI_CAST_PTR (acpi_adr_space_type, context); + space_id = *ACPI_CAST_PTR(acpi_adr_space_type, context); /* Convert and validate the device handle */ - node = acpi_ns_map_handle_to_node (obj_handle); + node = acpi_ns_map_handle_to_node(obj_handle); if (!node) { return (AE_BAD_PARAMETER); } @@ -1056,14 +1034,13 @@ acpi_ev_reg_run ( * We only care about regions.and objects * that are allowed to have address space handlers */ - if ((node->type != ACPI_TYPE_REGION) && - (node != acpi_gbl_root_node)) { + if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { return (AE_OK); } /* Check for an existing internal object */ - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { /* No object, just exit */ @@ -1080,7 +1057,6 @@ acpi_ev_reg_run ( return (AE_OK); } - status = acpi_ev_execute_reg_method (obj_desc, 1); + status = acpi_ev_execute_reg_method(obj_desc, 1); return (status); } - diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c index f2d53af..a1bd2da 100644 --- a/drivers/acpi/events/evrgnini.c +++ b/drivers/acpi/events/evrgnini.c @@ -41,14 +41,12 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #define _COMPONENT ACPI_EVENTS - ACPI_MODULE_NAME ("evrgnini") - +ACPI_MODULE_NAME("evrgnini") /******************************************************************************* * @@ -64,34 +62,31 @@ * DESCRIPTION: Setup a system_memory operation region * ******************************************************************************/ - acpi_status -acpi_ev_system_memory_region_setup ( - acpi_handle handle, - u32 function, - void *handler_context, - void **region_context) +acpi_ev_system_memory_region_setup(acpi_handle handle, + u32 function, + void *handler_context, void **region_context) { - union acpi_operand_object *region_desc = (union acpi_operand_object *) handle; - struct acpi_mem_space_context *local_region_context; - - - ACPI_FUNCTION_TRACE ("ev_system_memory_region_setup"); + union acpi_operand_object *region_desc = + (union acpi_operand_object *)handle; + struct acpi_mem_space_context *local_region_context; + ACPI_FUNCTION_TRACE("ev_system_memory_region_setup"); if (function == ACPI_REGION_DEACTIVATE) { if (*region_context) { - ACPI_MEM_FREE (*region_context); + ACPI_MEM_FREE(*region_context); *region_context = NULL; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Create a new context */ - local_region_context = ACPI_MEM_CALLOCATE (sizeof (struct acpi_mem_space_context)); + local_region_context = + ACPI_MEM_CALLOCATE(sizeof(struct acpi_mem_space_context)); if (!(local_region_context)) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Save the region length and address for use in the handler */ @@ -100,10 +95,9 @@ acpi_ev_system_memory_region_setup ( local_region_context->address = region_desc->region.address; *region_context = local_region_context; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_io_space_region_setup @@ -120,26 +114,21 @@ acpi_ev_system_memory_region_setup ( ******************************************************************************/ acpi_status -acpi_ev_io_space_region_setup ( - acpi_handle handle, - u32 function, - void *handler_context, - void **region_context) +acpi_ev_io_space_region_setup(acpi_handle handle, + u32 function, + void *handler_context, void **region_context) { - ACPI_FUNCTION_TRACE ("ev_io_space_region_setup"); - + ACPI_FUNCTION_TRACE("ev_io_space_region_setup"); if (function == ACPI_REGION_DEACTIVATE) { *region_context = NULL; - } - else { + } else { *region_context = handler_context; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_pci_config_region_setup @@ -158,24 +147,21 @@ acpi_ev_io_space_region_setup ( ******************************************************************************/ acpi_status -acpi_ev_pci_config_region_setup ( - acpi_handle handle, - u32 function, - void *handler_context, - void **region_context) +acpi_ev_pci_config_region_setup(acpi_handle handle, + u32 function, + void *handler_context, void **region_context) { - acpi_status status = AE_OK; - acpi_integer pci_value; - struct acpi_pci_id *pci_id = *region_context; - union acpi_operand_object *handler_obj; - struct acpi_namespace_node *parent_node; - struct acpi_namespace_node *pci_root_node; - union acpi_operand_object *region_obj = (union acpi_operand_object *) handle; - struct acpi_device_id object_hID; - - - ACPI_FUNCTION_TRACE ("ev_pci_config_region_setup"); - + acpi_status status = AE_OK; + acpi_integer pci_value; + struct acpi_pci_id *pci_id = *region_context; + union acpi_operand_object *handler_obj; + struct acpi_namespace_node *parent_node; + struct acpi_namespace_node *pci_root_node; + union acpi_operand_object *region_obj = + (union acpi_operand_object *)handle; + struct acpi_device_id object_hID; + + ACPI_FUNCTION_TRACE("ev_pci_config_region_setup"); handler_obj = region_obj->region.handler; if (!handler_obj) { @@ -183,20 +169,21 @@ acpi_ev_pci_config_region_setup ( * No installed handler. This shouldn't happen because the dispatch * routine checks before we get here, but we check again just in case. */ - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Attempting to init a region %p, with no handler\n", region_obj)); - return_ACPI_STATUS (AE_NOT_EXIST); + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, + "Attempting to init a region %p, with no handler\n", + region_obj)); + return_ACPI_STATUS(AE_NOT_EXIST); } *region_context = NULL; if (function == ACPI_REGION_DEACTIVATE) { if (pci_id) { - ACPI_MEM_FREE (pci_id); + ACPI_MEM_FREE(pci_id); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - parent_node = acpi_ns_get_parent_node (region_obj->region.node); + parent_node = acpi_ns_get_parent_node(region_obj->region.node); /* * Get the _SEG and _BBN values from the device upon which the handler @@ -216,22 +203,28 @@ acpi_ev_pci_config_region_setup ( pci_root_node = parent_node; while (pci_root_node != acpi_gbl_root_node) { - status = acpi_ut_execute_HID (pci_root_node, &object_hID); - if (ACPI_SUCCESS (status)) { + status = + acpi_ut_execute_HID(pci_root_node, &object_hID); + if (ACPI_SUCCESS(status)) { /* * Got a valid _HID string, check if this is a PCI root. * New for ACPI 3.0: check for a PCI Express root also. */ - if (!(ACPI_STRNCMP (object_hID.value, PCI_ROOT_HID_STRING, - sizeof (PCI_ROOT_HID_STRING)) || - !(ACPI_STRNCMP (object_hID.value, PCI_EXPRESS_ROOT_HID_STRING, - sizeof (PCI_EXPRESS_ROOT_HID_STRING))))) { + if (! + (ACPI_STRNCMP + (object_hID.value, PCI_ROOT_HID_STRING, + sizeof(PCI_ROOT_HID_STRING)) + || + !(ACPI_STRNCMP + (object_hID.value, + PCI_EXPRESS_ROOT_HID_STRING, + sizeof(PCI_EXPRESS_ROOT_HID_STRING))))) + { /* Install a handler for this PCI root bridge */ - status = acpi_install_address_space_handler ((acpi_handle) pci_root_node, - ACPI_ADR_SPACE_PCI_CONFIG, - ACPI_DEFAULT_HANDLER, NULL, NULL); - if (ACPI_FAILURE (status)) { + status = + acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); + if (ACPI_FAILURE(status)) { if (status == AE_SAME_HANDLER) { /* * It is OK if the handler is already installed on the root @@ -239,23 +232,19 @@ acpi_ev_pci_config_region_setup ( * new PCI_Config operation region, however. */ status = AE_OK; - } - else { - ACPI_REPORT_ERROR (( - "Could not install pci_config handler for Root Bridge %4.4s, %s\n", - acpi_ut_get_node_name (pci_root_node), acpi_format_exception (status))); + } else { + ACPI_REPORT_ERROR(("Could not install pci_config handler for Root Bridge %4.4s, %s\n", acpi_ut_get_node_name(pci_root_node), acpi_format_exception(status))); } } break; } } - pci_root_node = acpi_ns_get_parent_node (pci_root_node); + pci_root_node = acpi_ns_get_parent_node(pci_root_node); } /* PCI root bridge not found, use namespace root node */ - } - else { + } else { pci_root_node = handler_obj->address_space.node; } @@ -264,14 +253,14 @@ acpi_ev_pci_config_region_setup ( * (install_address_space_handler could have initialized it) */ if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Region is still not initialized. Create a new context */ - pci_id = ACPI_MEM_CALLOCATE (sizeof (struct acpi_pci_id)); + pci_id = ACPI_MEM_CALLOCATE(sizeof(struct acpi_pci_id)); if (!pci_id) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* @@ -283,40 +272,45 @@ acpi_ev_pci_config_region_setup ( * Get the PCI device and function numbers from the _ADR object * contained in the parent's scope. */ - status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, parent_node, &pci_value); + status = + acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, parent_node, + &pci_value); /* * The default is zero, and since the allocation above zeroed * the data, just do nothing on failure. */ - if (ACPI_SUCCESS (status)) { - pci_id->device = ACPI_HIWORD (ACPI_LODWORD (pci_value)); - pci_id->function = ACPI_LOWORD (ACPI_LODWORD (pci_value)); + if (ACPI_SUCCESS(status)) { + pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value)); + pci_id->function = ACPI_LOWORD(ACPI_LODWORD(pci_value)); } /* The PCI segment number comes from the _SEG method */ - status = acpi_ut_evaluate_numeric_object (METHOD_NAME__SEG, pci_root_node, &pci_value); - if (ACPI_SUCCESS (status)) { - pci_id->segment = ACPI_LOWORD (pci_value); + status = + acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG, pci_root_node, + &pci_value); + if (ACPI_SUCCESS(status)) { + pci_id->segment = ACPI_LOWORD(pci_value); } /* The PCI bus number comes from the _BBN method */ - status = acpi_ut_evaluate_numeric_object (METHOD_NAME__BBN, pci_root_node, &pci_value); - if (ACPI_SUCCESS (status)) { - pci_id->bus = ACPI_LOWORD (pci_value); + status = + acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN, pci_root_node, + &pci_value); + if (ACPI_SUCCESS(status)) { + pci_id->bus = ACPI_LOWORD(pci_value); } /* Complete this device's pci_id */ - acpi_os_derive_pci_id (pci_root_node, region_obj->region.node, &pci_id); + acpi_os_derive_pci_id(pci_root_node, region_obj->region.node, &pci_id); *region_context = pci_id; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_pci_bar_region_setup @@ -335,19 +329,15 @@ acpi_ev_pci_config_region_setup ( ******************************************************************************/ acpi_status -acpi_ev_pci_bar_region_setup ( - acpi_handle handle, - u32 function, - void *handler_context, - void **region_context) +acpi_ev_pci_bar_region_setup(acpi_handle handle, + u32 function, + void *handler_context, void **region_context) { - ACPI_FUNCTION_TRACE ("ev_pci_bar_region_setup"); - + ACPI_FUNCTION_TRACE("ev_pci_bar_region_setup"); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_cmos_region_setup @@ -366,19 +356,15 @@ acpi_ev_pci_bar_region_setup ( ******************************************************************************/ acpi_status -acpi_ev_cmos_region_setup ( - acpi_handle handle, - u32 function, - void *handler_context, - void **region_context) +acpi_ev_cmos_region_setup(acpi_handle handle, + u32 function, + void *handler_context, void **region_context) { - ACPI_FUNCTION_TRACE ("ev_cmos_region_setup"); - + ACPI_FUNCTION_TRACE("ev_cmos_region_setup"); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_default_region_setup @@ -395,26 +381,21 @@ acpi_ev_cmos_region_setup ( ******************************************************************************/ acpi_status -acpi_ev_default_region_setup ( - acpi_handle handle, - u32 function, - void *handler_context, - void **region_context) +acpi_ev_default_region_setup(acpi_handle handle, + u32 function, + void *handler_context, void **region_context) { - ACPI_FUNCTION_TRACE ("ev_default_region_setup"); - + ACPI_FUNCTION_TRACE("ev_default_region_setup"); if (function == ACPI_REGION_DEACTIVATE) { *region_context = NULL; - } - else { + } else { *region_context = handler_context; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ev_initialize_region @@ -438,37 +419,34 @@ acpi_ev_default_region_setup ( ******************************************************************************/ acpi_status -acpi_ev_initialize_region ( - union acpi_operand_object *region_obj, - u8 acpi_ns_locked) +acpi_ev_initialize_region(union acpi_operand_object *region_obj, + u8 acpi_ns_locked) { - union acpi_operand_object *handler_obj; - union acpi_operand_object *obj_desc; - acpi_adr_space_type space_id; - struct acpi_namespace_node *node; - acpi_status status; - struct acpi_namespace_node *method_node; - acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG; - union acpi_operand_object *region_obj2; - - - ACPI_FUNCTION_TRACE_U32 ("ev_initialize_region", acpi_ns_locked); + union acpi_operand_object *handler_obj; + union acpi_operand_object *obj_desc; + acpi_adr_space_type space_id; + struct acpi_namespace_node *node; + acpi_status status; + struct acpi_namespace_node *method_node; + acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG; + union acpi_operand_object *region_obj2; + ACPI_FUNCTION_TRACE_U32("ev_initialize_region", acpi_ns_locked); if (!region_obj) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - region_obj2 = acpi_ns_get_secondary_object (region_obj); + region_obj2 = acpi_ns_get_secondary_object(region_obj); if (!region_obj2) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } - node = acpi_ns_get_parent_node (region_obj->region.node); + node = acpi_ns_get_parent_node(region_obj->region.node); space_id = region_obj->region.space_id; /* Setup defaults */ @@ -480,9 +458,9 @@ acpi_ev_initialize_region ( /* Find any "_REG" method associated with this region definition */ - status = acpi_ns_search_node (*reg_name_ptr, node, - ACPI_TYPE_METHOD, &method_node); - if (ACPI_SUCCESS (status)) { + status = acpi_ns_search_node(*reg_name_ptr, node, + ACPI_TYPE_METHOD, &method_node); + if (ACPI_SUCCESS(status)) { /* * The _REG method is optional and there can be only one per region * definition. This will be executed when the handler is attached @@ -499,7 +477,7 @@ acpi_ev_initialize_region ( /* Check to see if a handler exists */ handler_obj = NULL; - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (obj_desc) { /* Can only be a handler if the object exists */ @@ -527,37 +505,50 @@ acpi_ev_initialize_region ( while (handler_obj) { /* Is this handler of the correct type? */ - if (handler_obj->address_space.space_id == space_id) { + if (handler_obj->address_space.space_id == + space_id) { /* Found correct handler */ - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Found handler %p for region %p in obj %p\n", - handler_obj, region_obj, obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, + "Found handler %p for region %p in obj %p\n", + handler_obj, + region_obj, + obj_desc)); - status = acpi_ev_attach_region (handler_obj, region_obj, - acpi_ns_locked); + status = + acpi_ev_attach_region(handler_obj, + region_obj, + acpi_ns_locked); /* * Tell all users that this region is usable by running the _REG * method */ if (acpi_ns_locked) { - status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ut_release_mutex + (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS + (status); } } - status = acpi_ev_execute_reg_method (region_obj, 1); + status = + acpi_ev_execute_reg_method + (region_obj, 1); if (acpi_ns_locked) { - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ut_acquire_mutex + (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS + (status); } } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Try next handler in the list */ @@ -570,15 +561,15 @@ acpi_ev_initialize_region ( * This node does not have the handler we need; * Pop up one level */ - node = acpi_ns_get_parent_node (node); + node = acpi_ns_get_parent_node(node); } /* If we get here, there is no handler for this region */ - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "No handler for region_type %s(%X) (region_obj %p)\n", - acpi_ut_get_region_name (space_id), space_id, region_obj)); + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, + "No handler for region_type %s(%X) (region_obj %p)\n", + acpi_ut_get_region_name(space_id), space_id, + region_obj)); - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } - diff --git a/drivers/acpi/events/evsci.c b/drivers/acpi/events/evsci.c index f3123c2..1418359 100644 --- a/drivers/acpi/events/evsci.c +++ b/drivers/acpi/events/evsci.c @@ -45,16 +45,11 @@ #include #include - #define _COMPONENT ACPI_EVENTS - ACPI_MODULE_NAME ("evsci") +ACPI_MODULE_NAME("evsci") /* Local prototypes */ - -static u32 ACPI_SYSTEM_XFACE -acpi_ev_sci_xrupt_handler ( - void *context); - +static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context); /******************************************************************************* * @@ -69,17 +64,13 @@ acpi_ev_sci_xrupt_handler ( * ******************************************************************************/ -static u32 ACPI_SYSTEM_XFACE -acpi_ev_sci_xrupt_handler ( - void *context) +static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context) { - struct acpi_gpe_xrupt_info *gpe_xrupt_list = context; - u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED; - + struct acpi_gpe_xrupt_info *gpe_xrupt_list = context; + u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED; ACPI_FUNCTION_TRACE("ev_sci_xrupt_handler"); - /* * We are guaranteed by the ACPI CA initialization/shutdown code that * if this interrupt handler is installed, ACPI is enabled. @@ -89,18 +80,17 @@ acpi_ev_sci_xrupt_handler ( * Fixed Events: * Check for and dispatch any Fixed Events that have occurred */ - interrupt_handled |= acpi_ev_fixed_event_detect (); + interrupt_handled |= acpi_ev_fixed_event_detect(); /* * General Purpose Events: * Check for and dispatch any GPEs that have occurred */ - interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list); + interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); - return_VALUE (interrupt_handled); + return_VALUE(interrupt_handled); } - /******************************************************************************* * * FUNCTION: acpi_ev_gpe_xrupt_handler @@ -113,17 +103,13 @@ acpi_ev_sci_xrupt_handler ( * ******************************************************************************/ -u32 ACPI_SYSTEM_XFACE -acpi_ev_gpe_xrupt_handler ( - void *context) +u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context) { - struct acpi_gpe_xrupt_info *gpe_xrupt_list = context; - u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED; - + struct acpi_gpe_xrupt_info *gpe_xrupt_list = context; + u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED; ACPI_FUNCTION_TRACE("ev_gpe_xrupt_handler"); - /* * We are guaranteed by the ACPI CA initialization/shutdown code that * if this interrupt handler is installed, ACPI is enabled. @@ -133,12 +119,11 @@ acpi_ev_gpe_xrupt_handler ( * GPEs: * Check for and dispatch any GPEs that have occurred */ - interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list); + interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); - return_VALUE (interrupt_handled); + return_VALUE(interrupt_handled); } - /****************************************************************************** * * FUNCTION: acpi_ev_install_sci_handler @@ -151,22 +136,18 @@ acpi_ev_gpe_xrupt_handler ( * ******************************************************************************/ -u32 -acpi_ev_install_sci_handler ( - void) +u32 acpi_ev_install_sci_handler(void) { - u32 status = AE_OK; - + u32 status = AE_OK; - ACPI_FUNCTION_TRACE ("ev_install_sci_handler"); + ACPI_FUNCTION_TRACE("ev_install_sci_handler"); - - status = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int, - acpi_ev_sci_xrupt_handler, acpi_gbl_gpe_xrupt_list_head); - return_ACPI_STATUS (status); + status = acpi_os_install_interrupt_handler((u32) acpi_gbl_FADT->sci_int, + acpi_ev_sci_xrupt_handler, + acpi_gbl_gpe_xrupt_list_head); + return_ACPI_STATUS(status); } - /****************************************************************************** * * FUNCTION: acpi_ev_remove_sci_handler @@ -186,22 +167,16 @@ acpi_ev_install_sci_handler ( * ******************************************************************************/ -acpi_status -acpi_ev_remove_sci_handler ( - void) +acpi_status acpi_ev_remove_sci_handler(void) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ev_remove_sci_handler"); + acpi_status status; + ACPI_FUNCTION_TRACE("ev_remove_sci_handler"); /* Just let the OS remove the handler and disable the level */ - status = acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int, - acpi_ev_sci_xrupt_handler); + status = acpi_os_remove_interrupt_handler((u32) acpi_gbl_FADT->sci_int, + acpi_ev_sci_xrupt_handler); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c index 4c1c25e..43b33d1 100644 --- a/drivers/acpi/events/evxface.c +++ b/drivers/acpi/events/evxface.c @@ -49,8 +49,7 @@ #include #define _COMPONENT ACPI_EVENTS - ACPI_MODULE_NAME ("evxface") - +ACPI_MODULE_NAME("evxface") /******************************************************************************* * @@ -64,21 +63,16 @@ * DESCRIPTION: Saves the pointer to the handler function * ******************************************************************************/ - #ifdef ACPI_FUTURE_USAGE -acpi_status -acpi_install_exception_handler ( - acpi_exception_handler handler) +acpi_status acpi_install_exception_handler(acpi_exception_handler handler) { - acpi_status status; - + acpi_status status; - ACPI_FUNCTION_TRACE ("acpi_install_exception_handler"); + ACPI_FUNCTION_TRACE("acpi_install_exception_handler"); - - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Don't allow two handlers. */ @@ -92,12 +86,11 @@ acpi_install_exception_handler ( acpi_gbl_exception_handler = handler; -cleanup: - (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); - return_ACPI_STATUS (status); + cleanup: + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); + return_ACPI_STATUS(status); } -#endif /* ACPI_FUTURE_USAGE */ - +#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * @@ -116,26 +109,22 @@ cleanup: ******************************************************************************/ acpi_status -acpi_install_fixed_event_handler ( - u32 event, - acpi_event_handler handler, - void *context) +acpi_install_fixed_event_handler(u32 event, + acpi_event_handler handler, void *context) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_install_fixed_event_handler"); + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_install_fixed_event_handler"); /* Parameter validation */ if (event > ACPI_EVENT_MAX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Don't allow two handlers. */ @@ -150,29 +139,29 @@ acpi_install_fixed_event_handler ( acpi_gbl_fixed_event_handlers[event].handler = handler; acpi_gbl_fixed_event_handlers[event].context = context; - status = acpi_clear_event (event); + status = acpi_clear_event(event); if (ACPI_SUCCESS(status)) - status = acpi_enable_event (event, 0); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not enable fixed event.\n")); + status = acpi_enable_event(event, 0); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Could not enable fixed event.\n")); /* Remove the handler */ acpi_gbl_fixed_event_handlers[event].handler = NULL; acpi_gbl_fixed_event_handlers[event].context = NULL; - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Enabled fixed event %X, Handler=%p\n", event, handler)); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Enabled fixed event %X, Handler=%p\n", event, + handler)); } - -cleanup: - (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); - return_ACPI_STATUS (status); + cleanup: + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_install_fixed_event_handler); +EXPORT_SYMBOL(acpi_install_fixed_event_handler); /******************************************************************************* * @@ -188,49 +177,45 @@ EXPORT_SYMBOL(acpi_install_fixed_event_handler); ******************************************************************************/ acpi_status -acpi_remove_fixed_event_handler ( - u32 event, - acpi_event_handler handler) +acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("acpi_remove_fixed_event_handler"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_remove_fixed_event_handler"); /* Parameter validation */ if (event > ACPI_EVENT_MAX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Disable the event before removing the handler */ - status = acpi_disable_event (event, 0); + status = acpi_disable_event(event, 0); /* Always Remove the handler */ acpi_gbl_fixed_event_handlers[event].handler = NULL; acpi_gbl_fixed_event_handlers[event].context = NULL; - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, - "Could not write to fixed event enable register.\n")); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X.\n", event)); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Could not write to fixed event enable register.\n")); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X.\n", + event)); } - (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); - return_ACPI_STATUS (status); + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_remove_fixed_event_handler); +EXPORT_SYMBOL(acpi_remove_fixed_event_handler); /******************************************************************************* * @@ -251,37 +236,32 @@ EXPORT_SYMBOL(acpi_remove_fixed_event_handler); ******************************************************************************/ acpi_status -acpi_install_notify_handler ( - acpi_handle device, - u32 handler_type, - acpi_notify_handler handler, - void *context) +acpi_install_notify_handler(acpi_handle device, + u32 handler_type, + acpi_notify_handler handler, void *context) { - union acpi_operand_object *obj_desc; - union acpi_operand_object *notify_obj; - struct acpi_namespace_node *node; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_install_notify_handler"); + union acpi_operand_object *obj_desc; + union acpi_operand_object *notify_obj; + struct acpi_namespace_node *node; + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_install_notify_handler"); /* Parameter validation */ - if ((!device) || - (!handler) || - (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if ((!device) || + (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Convert and validate the device handle */ - node = acpi_ns_map_handle_to_node (device); + node = acpi_ns_map_handle_to_node(device); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -297,21 +277,21 @@ acpi_install_notify_handler ( /* Make sure the handler is not already installed */ if (((handler_type & ACPI_SYSTEM_NOTIFY) && - acpi_gbl_system_notify.handler) || - ((handler_type & ACPI_DEVICE_NOTIFY) && - acpi_gbl_device_notify.handler)) { + acpi_gbl_system_notify.handler) || + ((handler_type & ACPI_DEVICE_NOTIFY) && + acpi_gbl_device_notify.handler)) { status = AE_ALREADY_EXISTS; goto unlock_and_exit; } if (handler_type & ACPI_SYSTEM_NOTIFY) { - acpi_gbl_system_notify.node = node; + acpi_gbl_system_notify.node = node; acpi_gbl_system_notify.handler = handler; acpi_gbl_system_notify.context = context; } if (handler_type & ACPI_DEVICE_NOTIFY) { - acpi_gbl_device_notify.node = node; + acpi_gbl_device_notify.node = node; acpi_gbl_device_notify.handler = handler; acpi_gbl_device_notify.context = context; } @@ -327,29 +307,28 @@ acpi_install_notify_handler ( else { /* Notifies allowed on this object? */ - if (!acpi_ev_is_notify_object (node)) { + if (!acpi_ev_is_notify_object(node)) { status = AE_TYPE; goto unlock_and_exit; } /* Check for an existing internal object */ - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (obj_desc) { /* Object exists - make sure there's no handler */ if (((handler_type & ACPI_SYSTEM_NOTIFY) && - obj_desc->common_notify.system_notify) || - ((handler_type & ACPI_DEVICE_NOTIFY) && - obj_desc->common_notify.device_notify)) { + obj_desc->common_notify.system_notify) || + ((handler_type & ACPI_DEVICE_NOTIFY) && + obj_desc->common_notify.device_notify)) { status = AE_ALREADY_EXISTS; goto unlock_and_exit; } - } - else { + } else { /* Create a new object */ - obj_desc = acpi_ut_create_internal_object (node->type); + obj_desc = acpi_ut_create_internal_object(node->type); if (!obj_desc) { status = AE_NO_MEMORY; goto unlock_and_exit; @@ -357,25 +336,27 @@ acpi_install_notify_handler ( /* Attach new object to the Node */ - status = acpi_ns_attach_object (device, obj_desc, node->type); + status = + acpi_ns_attach_object(device, obj_desc, node->type); /* Remove local reference to the object */ - acpi_ut_remove_reference (obj_desc); - if (ACPI_FAILURE (status)) { + acpi_ut_remove_reference(obj_desc); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } } /* Install the handler */ - notify_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_NOTIFY); + notify_obj = + acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_NOTIFY); if (!notify_obj) { status = AE_NO_MEMORY; goto unlock_and_exit; } - notify_obj->notify.node = node; + notify_obj->notify.node = node; notify_obj->notify.handler = handler; notify_obj->notify.context = context; @@ -390,17 +371,16 @@ acpi_install_notify_handler ( if (handler_type == ACPI_ALL_NOTIFY) { /* Extra ref if installed in both */ - acpi_ut_add_reference (notify_obj); + acpi_ut_add_reference(notify_obj); } } - -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (status); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_install_notify_handler); +EXPORT_SYMBOL(acpi_install_notify_handler); /******************************************************************************* * @@ -420,36 +400,31 @@ EXPORT_SYMBOL(acpi_install_notify_handler); ******************************************************************************/ acpi_status -acpi_remove_notify_handler ( - acpi_handle device, - u32 handler_type, - acpi_notify_handler handler) +acpi_remove_notify_handler(acpi_handle device, + u32 handler_type, acpi_notify_handler handler) { - union acpi_operand_object *notify_obj; - union acpi_operand_object *obj_desc; - struct acpi_namespace_node *node; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_remove_notify_handler"); + union acpi_operand_object *notify_obj; + union acpi_operand_object *obj_desc; + struct acpi_namespace_node *node; + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_remove_notify_handler"); /* Parameter validation */ - if ((!device) || - (!handler) || - (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if ((!device) || + (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Convert and validate the device handle */ - node = acpi_ns_map_handle_to_node (device); + node = acpi_ns_map_handle_to_node(device); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -458,34 +433,34 @@ acpi_remove_notify_handler ( /* Root Object */ if (device == ACPI_ROOT_OBJECT) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Removing notify handler for ROOT object.\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Removing notify handler for ROOT object.\n")); if (((handler_type & ACPI_SYSTEM_NOTIFY) && - !acpi_gbl_system_notify.handler) || - ((handler_type & ACPI_DEVICE_NOTIFY) && - !acpi_gbl_device_notify.handler)) { + !acpi_gbl_system_notify.handler) || + ((handler_type & ACPI_DEVICE_NOTIFY) && + !acpi_gbl_device_notify.handler)) { status = AE_NOT_EXIST; goto unlock_and_exit; } /* Make sure all deferred tasks are completed */ - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); acpi_os_wait_events_complete(NULL); - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); - } + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } if (handler_type & ACPI_SYSTEM_NOTIFY) { - acpi_gbl_system_notify.node = NULL; + acpi_gbl_system_notify.node = NULL; acpi_gbl_system_notify.handler = NULL; acpi_gbl_system_notify.context = NULL; } if (handler_type & ACPI_DEVICE_NOTIFY) { - acpi_gbl_device_notify.node = NULL; + acpi_gbl_device_notify.node = NULL; acpi_gbl_device_notify.handler = NULL; acpi_gbl_device_notify.context = NULL; } @@ -496,14 +471,14 @@ acpi_remove_notify_handler ( else { /* Notifies allowed on this object? */ - if (!acpi_ev_is_notify_object (node)) { + if (!acpi_ev_is_notify_object(node)) { status = AE_TYPE; goto unlock_and_exit; } /* Check for an existing internal object */ - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { status = AE_NOT_EXIST; goto unlock_and_exit; @@ -514,53 +489,52 @@ acpi_remove_notify_handler ( if (handler_type & ACPI_SYSTEM_NOTIFY) { notify_obj = obj_desc->common_notify.system_notify; if ((!notify_obj) || - (notify_obj->notify.handler != handler)) { + (notify_obj->notify.handler != handler)) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } /* Make sure all deferred tasks are completed */ - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); acpi_os_wait_events_complete(NULL); - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); - } + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } /* Remove the handler */ obj_desc->common_notify.system_notify = NULL; - acpi_ut_remove_reference (notify_obj); + acpi_ut_remove_reference(notify_obj); } if (handler_type & ACPI_DEVICE_NOTIFY) { notify_obj = obj_desc->common_notify.device_notify; if ((!notify_obj) || - (notify_obj->notify.handler != handler)) { + (notify_obj->notify.handler != handler)) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } /* Make sure all deferred tasks are completed */ - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); acpi_os_wait_events_complete(NULL); - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); - } + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } /* Remove the handler */ obj_desc->common_notify.device_notify = NULL; - acpi_ut_remove_reference (notify_obj); + acpi_ut_remove_reference(notify_obj); } } - -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (status); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_remove_notify_handler); +EXPORT_SYMBOL(acpi_remove_notify_handler); /******************************************************************************* * @@ -581,36 +555,31 @@ EXPORT_SYMBOL(acpi_remove_notify_handler); ******************************************************************************/ acpi_status -acpi_install_gpe_handler ( - acpi_handle gpe_device, - u32 gpe_number, - u32 type, - acpi_event_handler address, - void *context) +acpi_install_gpe_handler(acpi_handle gpe_device, + u32 gpe_number, + u32 type, acpi_event_handler address, void *context) { - struct acpi_gpe_event_info *gpe_event_info; - struct acpi_handler_info *handler; - acpi_status status; - u32 flags; - - - ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler"); + struct acpi_gpe_event_info *gpe_event_info; + struct acpi_handler_info *handler; + acpi_status status; + u32 flags; + ACPI_FUNCTION_TRACE("acpi_install_gpe_handler"); /* Parameter validation */ if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Ensure that we have a valid GPE number */ - gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); + gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); if (!gpe_event_info) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -618,49 +587,49 @@ acpi_install_gpe_handler ( /* Make sure that there isn't a handler there already */ - if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { + if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) { status = AE_ALREADY_EXISTS; goto unlock_and_exit; } /* Allocate and init handler object */ - handler = ACPI_MEM_CALLOCATE (sizeof (struct acpi_handler_info)); + handler = ACPI_MEM_CALLOCATE(sizeof(struct acpi_handler_info)); if (!handler) { status = AE_NO_MEMORY; goto unlock_and_exit; } - handler->address = address; - handler->context = context; + handler->address = address; + handler->context = context; handler->method_node = gpe_event_info->dispatch.method_node; /* Disable the GPE before installing the handler */ - status = acpi_ev_disable_gpe (gpe_event_info); - if (ACPI_FAILURE (status)) { + status = acpi_ev_disable_gpe(gpe_event_info); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* Install the handler */ - flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); + flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); gpe_event_info->dispatch.handler = handler; /* Setup up dispatch flags to indicate handler (vs. method) */ - gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ + gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); - acpi_os_release_lock (acpi_gbl_gpe_lock, flags); - + acpi_os_release_lock(acpi_gbl_gpe_lock, flags); -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); - return_ACPI_STATUS (status); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_install_gpe_handler); +EXPORT_SYMBOL(acpi_install_gpe_handler); /******************************************************************************* * @@ -678,34 +647,30 @@ EXPORT_SYMBOL(acpi_install_gpe_handler); ******************************************************************************/ acpi_status -acpi_remove_gpe_handler ( - acpi_handle gpe_device, - u32 gpe_number, - acpi_event_handler address) +acpi_remove_gpe_handler(acpi_handle gpe_device, + u32 gpe_number, acpi_event_handler address) { - struct acpi_gpe_event_info *gpe_event_info; - struct acpi_handler_info *handler; - acpi_status status; - u32 flags; - - - ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler"); + struct acpi_gpe_event_info *gpe_event_info; + struct acpi_handler_info *handler; + acpi_status status; + u32 flags; + ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler"); /* Parameter validation */ if (!address) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Ensure that we have a valid GPE number */ - gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); + gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); if (!gpe_event_info) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -713,7 +678,8 @@ acpi_remove_gpe_handler ( /* Make sure that a handler is indeed installed */ - if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) != ACPI_GPE_DISPATCH_HANDLER) { + if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) != + ACPI_GPE_DISPATCH_HANDLER) { status = AE_NOT_EXIST; goto unlock_and_exit; } @@ -727,45 +693,44 @@ acpi_remove_gpe_handler ( /* Disable the GPE before removing the handler */ - status = acpi_ev_disable_gpe (gpe_event_info); - if (ACPI_FAILURE (status)) { + status = acpi_ev_disable_gpe(gpe_event_info); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* Make sure all deferred tasks are completed */ - (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); acpi_os_wait_events_complete(NULL); - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); - } + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } /* Remove the handler */ - flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); + flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); handler = gpe_event_info->dispatch.handler; /* Restore Method node (if any), set dispatch flags */ gpe_event_info->dispatch.method_node = handler->method_node; - gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */ + gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */ if (handler->method_node) { gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD; } - acpi_os_release_lock (acpi_gbl_gpe_lock, flags); + acpi_os_release_lock(acpi_gbl_gpe_lock, flags); /* Now we can free the handler object */ - ACPI_MEM_FREE (handler); + ACPI_MEM_FREE(handler); - -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); - return_ACPI_STATUS (status); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_remove_gpe_handler); +EXPORT_SYMBOL(acpi_remove_gpe_handler); /******************************************************************************* * @@ -781,35 +746,31 @@ EXPORT_SYMBOL(acpi_remove_gpe_handler); * ******************************************************************************/ -acpi_status -acpi_acquire_global_lock ( - u16 timeout, - u32 *handle) +acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle) { - acpi_status status; - + acpi_status status; if (!handle) { return (AE_BAD_PARAMETER); } - status = acpi_ex_enter_interpreter (); - if (ACPI_FAILURE (status)) { + status = acpi_ex_enter_interpreter(); + if (ACPI_FAILURE(status)) { return (status); } - status = acpi_ev_acquire_global_lock (timeout); - acpi_ex_exit_interpreter (); + status = acpi_ev_acquire_global_lock(timeout); + acpi_ex_exit_interpreter(); - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { acpi_gbl_global_lock_handle++; *handle = acpi_gbl_global_lock_handle; } return (status); } -EXPORT_SYMBOL(acpi_acquire_global_lock); +EXPORT_SYMBOL(acpi_acquire_global_lock); /******************************************************************************* * @@ -823,19 +784,16 @@ EXPORT_SYMBOL(acpi_acquire_global_lock); * ******************************************************************************/ -acpi_status -acpi_release_global_lock ( - u32 handle) +acpi_status acpi_release_global_lock(u32 handle) { - acpi_status status; - + acpi_status status; if (handle != acpi_gbl_global_lock_handle) { return (AE_NOT_ACQUIRED); } - status = acpi_ev_release_global_lock (); + status = acpi_ev_release_global_lock(); return (status); } -EXPORT_SYMBOL(acpi_release_global_lock); +EXPORT_SYMBOL(acpi_release_global_lock); diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c index c5f74d7..887ff9f 100644 --- a/drivers/acpi/events/evxfevnt.c +++ b/drivers/acpi/events/evxfevnt.c @@ -48,8 +48,7 @@ #include #define _COMPONENT ACPI_EVENTS - ACPI_MODULE_NAME ("evxfevnt") - +ACPI_MODULE_NAME("evxfevnt") /******************************************************************************* * @@ -62,44 +61,39 @@ * DESCRIPTION: Transfers the system into ACPI mode. * ******************************************************************************/ - -acpi_status -acpi_enable ( - void) +acpi_status acpi_enable(void) { - acpi_status status = AE_OK; - + acpi_status status = AE_OK; - ACPI_FUNCTION_TRACE ("acpi_enable"); + ACPI_FUNCTION_TRACE("acpi_enable"); - - /* Make sure we have the FADT*/ + /* Make sure we have the FADT */ if (!acpi_gbl_FADT) { - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "No FADT information present!\n")); + return_ACPI_STATUS(AE_NO_ACPI_TABLES); } if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) { - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n")); - } - else { + ACPI_DEBUG_PRINT((ACPI_DB_INIT, + "System is already in ACPI mode\n")); + } else { /* Transition to ACPI mode */ - status = acpi_hw_set_mode (ACPI_SYS_MODE_ACPI); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not transition to ACPI mode.\n")); - return_ACPI_STATUS (status); + status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not transition to ACPI mode.\n")); + return_ACPI_STATUS(status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "Transition to ACPI mode successful\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INIT, + "Transition to ACPI mode successful\n")); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_disable @@ -112,43 +106,38 @@ acpi_enable ( * ******************************************************************************/ -acpi_status -acpi_disable ( - void) +acpi_status acpi_disable(void) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("acpi_disable"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_disable"); if (!acpi_gbl_FADT) { - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "No FADT information present!\n")); + return_ACPI_STATUS(AE_NO_ACPI_TABLES); } if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) { - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "System is already in legacy (non-ACPI) mode\n")); - } - else { + ACPI_DEBUG_PRINT((ACPI_DB_INIT, + "System is already in legacy (non-ACPI) mode\n")); + } else { /* Transition to LEGACY mode */ - status = acpi_hw_set_mode (ACPI_SYS_MODE_LEGACY); + status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not exit ACPI mode to legacy mode")); - return_ACPI_STATUS (status); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not exit ACPI mode to legacy mode")); + return_ACPI_STATUS(status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n")); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_enable_event @@ -162,52 +151,50 @@ acpi_disable ( * ******************************************************************************/ -acpi_status -acpi_enable_event ( - u32 event, - u32 flags) +acpi_status acpi_enable_event(u32 event, u32 flags) { - acpi_status status = AE_OK; - u32 value; - - - ACPI_FUNCTION_TRACE ("acpi_enable_event"); + acpi_status status = AE_OK; + u32 value; + ACPI_FUNCTION_TRACE("acpi_enable_event"); /* Decode the Fixed Event */ if (event > ACPI_EVENT_MAX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* * Enable the requested fixed event (by writing a one to the * enable register bit) */ - status = acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id, - 1, ACPI_MTX_LOCK); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_set_register(acpi_gbl_fixed_event_info[event]. + enable_register_id, 1, ACPI_MTX_LOCK); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Make sure that the hardware responded */ - status = acpi_get_register (acpi_gbl_fixed_event_info[event].enable_register_id, - &value, ACPI_MTX_LOCK); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_get_register(acpi_gbl_fixed_event_info[event]. + enable_register_id, &value, ACPI_MTX_LOCK); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } if (value != 1) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not enable %s event\n", acpi_ut_get_event_name (event))); - return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not enable %s event\n", + acpi_ut_get_event_name(event))); + return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_enable_event); +EXPORT_SYMBOL(acpi_enable_event); /******************************************************************************* * @@ -223,40 +210,34 @@ EXPORT_SYMBOL(acpi_enable_event); * ******************************************************************************/ -acpi_status -acpi_set_gpe_type ( - acpi_handle gpe_device, - u32 gpe_number, - u8 type) +acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type) { - acpi_status status = AE_OK; - struct acpi_gpe_event_info *gpe_event_info; - - - ACPI_FUNCTION_TRACE ("acpi_set_gpe_type"); + acpi_status status = AE_OK; + struct acpi_gpe_event_info *gpe_event_info; + ACPI_FUNCTION_TRACE("acpi_set_gpe_type"); /* Ensure that we have a valid GPE number */ - gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); + gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); if (!gpe_event_info) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Set the new type (will disable GPE if currently enabled) */ - status = acpi_ev_set_gpe_type (gpe_event_info, type); + status = acpi_ev_set_gpe_type(gpe_event_info, type); -unlock_and_exit: - return_ACPI_STATUS (status); + unlock_and_exit: + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_set_gpe_type); +EXPORT_SYMBOL(acpi_set_gpe_type); /******************************************************************************* * @@ -273,31 +254,25 @@ EXPORT_SYMBOL(acpi_set_gpe_type); * ******************************************************************************/ -acpi_status -acpi_enable_gpe ( - acpi_handle gpe_device, - u32 gpe_number, - u32 flags) +acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) { - acpi_status status = AE_OK; - struct acpi_gpe_event_info *gpe_event_info; - - - ACPI_FUNCTION_TRACE ("acpi_enable_gpe"); + acpi_status status = AE_OK; + struct acpi_gpe_event_info *gpe_event_info; + ACPI_FUNCTION_TRACE("acpi_enable_gpe"); /* Use semaphore lock if not executing at interrupt level */ if (flags & ACPI_NOT_ISR) { - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Ensure that we have a valid GPE number */ - gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); + gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); if (!gpe_event_info) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -305,16 +280,16 @@ acpi_enable_gpe ( /* Perform the enable */ - status = acpi_ev_enable_gpe (gpe_event_info, TRUE); + status = acpi_ev_enable_gpe(gpe_event_info, TRUE); -unlock_and_exit: + unlock_and_exit: if (flags & ACPI_NOT_ISR) { - (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_enable_gpe); +EXPORT_SYMBOL(acpi_enable_gpe); /******************************************************************************* * @@ -331,46 +306,39 @@ EXPORT_SYMBOL(acpi_enable_gpe); * ******************************************************************************/ -acpi_status -acpi_disable_gpe ( - acpi_handle gpe_device, - u32 gpe_number, - u32 flags) +acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) { - acpi_status status = AE_OK; - struct acpi_gpe_event_info *gpe_event_info; - - - ACPI_FUNCTION_TRACE ("acpi_disable_gpe"); + acpi_status status = AE_OK; + struct acpi_gpe_event_info *gpe_event_info; + ACPI_FUNCTION_TRACE("acpi_disable_gpe"); /* Use semaphore lock if not executing at interrupt level */ if (flags & ACPI_NOT_ISR) { - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Ensure that we have a valid GPE number */ - gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); + gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); if (!gpe_event_info) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } - status = acpi_ev_disable_gpe (gpe_event_info); + status = acpi_ev_disable_gpe(gpe_event_info); -unlock_and_exit: + unlock_and_exit: if (flags & ACPI_NOT_ISR) { - (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_disable_event @@ -384,50 +352,48 @@ unlock_and_exit: * ******************************************************************************/ -acpi_status -acpi_disable_event ( - u32 event, - u32 flags) +acpi_status acpi_disable_event(u32 event, u32 flags) { - acpi_status status = AE_OK; - u32 value; - - - ACPI_FUNCTION_TRACE ("acpi_disable_event"); + acpi_status status = AE_OK; + u32 value; + ACPI_FUNCTION_TRACE("acpi_disable_event"); /* Decode the Fixed Event */ if (event > ACPI_EVENT_MAX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* * Disable the requested fixed event (by writing a zero to the * enable register bit) */ - status = acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id, - 0, ACPI_MTX_LOCK); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_set_register(acpi_gbl_fixed_event_info[event]. + enable_register_id, 0, ACPI_MTX_LOCK); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_get_register (acpi_gbl_fixed_event_info[event].enable_register_id, - &value, ACPI_MTX_LOCK); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_get_register(acpi_gbl_fixed_event_info[event]. + enable_register_id, &value, ACPI_MTX_LOCK); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } if (value != 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not disable %s events\n", acpi_ut_get_event_name (event))); - return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not disable %s events\n", + acpi_ut_get_event_name(event))); + return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_disable_event); +EXPORT_SYMBOL(acpi_disable_event); /******************************************************************************* * @@ -441,33 +407,30 @@ EXPORT_SYMBOL(acpi_disable_event); * ******************************************************************************/ -acpi_status -acpi_clear_event ( - u32 event) +acpi_status acpi_clear_event(u32 event) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("acpi_clear_event"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_clear_event"); /* Decode the Fixed Event */ if (event > ACPI_EVENT_MAX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* * Clear the requested fixed event (By writing a one to the * status register bit) */ - status = acpi_set_register (acpi_gbl_fixed_event_info[event].status_register_id, - 1, ACPI_MTX_LOCK); + status = + acpi_set_register(acpi_gbl_fixed_event_info[event]. + status_register_id, 1, ACPI_MTX_LOCK); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_clear_event); +EXPORT_SYMBOL(acpi_clear_event); /******************************************************************************* * @@ -483,46 +446,39 @@ EXPORT_SYMBOL(acpi_clear_event); * ******************************************************************************/ -acpi_status -acpi_clear_gpe ( - acpi_handle gpe_device, - u32 gpe_number, - u32 flags) +acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) { - acpi_status status = AE_OK; - struct acpi_gpe_event_info *gpe_event_info; - - - ACPI_FUNCTION_TRACE ("acpi_clear_gpe"); + acpi_status status = AE_OK; + struct acpi_gpe_event_info *gpe_event_info; + ACPI_FUNCTION_TRACE("acpi_clear_gpe"); /* Use semaphore lock if not executing at interrupt level */ if (flags & ACPI_NOT_ISR) { - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Ensure that we have a valid GPE number */ - gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); + gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); if (!gpe_event_info) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } - status = acpi_hw_clear_gpe (gpe_event_info); + status = acpi_hw_clear_gpe(gpe_event_info); -unlock_and_exit: + unlock_and_exit: if (flags & ACPI_NOT_ISR) { - (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - #ifdef ACPI_FUTURE_USAGE /******************************************************************************* * @@ -538,36 +494,31 @@ unlock_and_exit: * ******************************************************************************/ -acpi_status -acpi_get_event_status ( - u32 event, - acpi_event_status *event_status) +acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("acpi_get_event_status"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_get_event_status"); if (!event_status) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Decode the Fixed Event */ if (event > ACPI_EVENT_MAX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Get the status of the requested fixed event */ - status = acpi_get_register (acpi_gbl_fixed_event_info[event].status_register_id, - event_status, ACPI_MTX_LOCK); + status = + acpi_get_register(acpi_gbl_fixed_event_info[event]. + status_register_id, event_status, ACPI_MTX_LOCK); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_get_gpe_status @@ -585,31 +536,26 @@ acpi_get_event_status ( ******************************************************************************/ acpi_status -acpi_get_gpe_status ( - acpi_handle gpe_device, - u32 gpe_number, - u32 flags, - acpi_event_status *event_status) +acpi_get_gpe_status(acpi_handle gpe_device, + u32 gpe_number, u32 flags, acpi_event_status * event_status) { - acpi_status status = AE_OK; - struct acpi_gpe_event_info *gpe_event_info; - - - ACPI_FUNCTION_TRACE ("acpi_get_gpe_status"); + acpi_status status = AE_OK; + struct acpi_gpe_event_info *gpe_event_info; + ACPI_FUNCTION_TRACE("acpi_get_gpe_status"); /* Use semaphore lock if not executing at interrupt level */ if (flags & ACPI_NOT_ISR) { - status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Ensure that we have a valid GPE number */ - gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); + gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); if (!gpe_event_info) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -617,16 +563,15 @@ acpi_get_gpe_status ( /* Obtain status on the requested GPE number */ - status = acpi_hw_get_gpe_status (gpe_event_info, event_status); + status = acpi_hw_get_gpe_status(gpe_event_info, event_status); -unlock_and_exit: + unlock_and_exit: if (flags & ACPI_NOT_ISR) { - (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } -#endif /* ACPI_FUTURE_USAGE */ - +#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * @@ -644,33 +589,27 @@ unlock_and_exit: ******************************************************************************/ acpi_status -acpi_install_gpe_block ( - acpi_handle gpe_device, - struct acpi_generic_address *gpe_block_address, - u32 register_count, - u32 interrupt_number) +acpi_install_gpe_block(acpi_handle gpe_device, + struct acpi_generic_address *gpe_block_address, + u32 register_count, u32 interrupt_number) { - acpi_status status; - union acpi_operand_object *obj_desc; - struct acpi_namespace_node *node; - struct acpi_gpe_block_info *gpe_block; - + acpi_status status; + union acpi_operand_object *obj_desc; + struct acpi_namespace_node *node; + struct acpi_gpe_block_info *gpe_block; - ACPI_FUNCTION_TRACE ("acpi_install_gpe_block"); + ACPI_FUNCTION_TRACE("acpi_install_gpe_block"); - - if ((!gpe_device) || - (!gpe_block_address) || - (!register_count)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if ((!gpe_device) || (!gpe_block_address) || (!register_count)) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } - node = acpi_ns_map_handle_to_node (gpe_device); + node = acpi_ns_map_handle_to_node(gpe_device); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -680,31 +619,33 @@ acpi_install_gpe_block ( * For user-installed GPE Block Devices, the gpe_block_base_number * is always zero */ - status = acpi_ev_create_gpe_block (node, gpe_block_address, register_count, - 0, interrupt_number, &gpe_block); - if (ACPI_FAILURE (status)) { + status = + acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0, + interrupt_number, &gpe_block); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* Get the device_object attached to the node */ - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { /* No object, create a new one */ - obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_DEVICE); + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE); if (!obj_desc) { status = AE_NO_MEMORY; goto unlock_and_exit; } - status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_DEVICE); + status = + acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE); /* Remove local reference to the object */ - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } } @@ -713,13 +654,12 @@ acpi_install_gpe_block ( obj_desc->device.gpe_block = gpe_block; - -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (status); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_install_gpe_block); +EXPORT_SYMBOL(acpi_install_gpe_block); /******************************************************************************* * @@ -733,28 +673,24 @@ EXPORT_SYMBOL(acpi_install_gpe_block); * ******************************************************************************/ -acpi_status -acpi_remove_gpe_block ( - acpi_handle gpe_device) +acpi_status acpi_remove_gpe_block(acpi_handle gpe_device) { - union acpi_operand_object *obj_desc; - acpi_status status; - struct acpi_namespace_node *node; - - - ACPI_FUNCTION_TRACE ("acpi_remove_gpe_block"); + union acpi_operand_object *obj_desc; + acpi_status status; + struct acpi_namespace_node *node; + ACPI_FUNCTION_TRACE("acpi_remove_gpe_block"); if (!gpe_device) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } - node = acpi_ns_map_handle_to_node (gpe_device); + node = acpi_ns_map_handle_to_node(gpe_device); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -762,22 +698,21 @@ acpi_remove_gpe_block ( /* Get the device_object attached to the node */ - obj_desc = acpi_ns_get_attached_object (node); - if (!obj_desc || - !obj_desc->device.gpe_block) { - return_ACPI_STATUS (AE_NULL_OBJECT); + obj_desc = acpi_ns_get_attached_object(node); + if (!obj_desc || !obj_desc->device.gpe_block) { + return_ACPI_STATUS(AE_NULL_OBJECT); } /* Delete the GPE block (but not the device_object) */ - status = acpi_ev_delete_gpe_block (obj_desc->device.gpe_block); - if (ACPI_SUCCESS (status)) { + status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block); + if (ACPI_SUCCESS(status)) { obj_desc->device.gpe_block = NULL; } -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (status); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(status); } EXPORT_SYMBOL(acpi_remove_gpe_block); diff --git a/drivers/acpi/events/evxfregn.c b/drivers/acpi/events/evxfregn.c index d058587..6f28ea2 100644 --- a/drivers/acpi/events/evxfregn.c +++ b/drivers/acpi/events/evxfregn.c @@ -49,8 +49,7 @@ #include #define _COMPONENT ACPI_EVENTS - ACPI_MODULE_NAME ("evxfregn") - +ACPI_MODULE_NAME("evxfregn") /******************************************************************************* * @@ -67,36 +66,31 @@ * DESCRIPTION: Install a handler for all op_regions of a given space_id. * ******************************************************************************/ - acpi_status -acpi_install_address_space_handler ( - acpi_handle device, - acpi_adr_space_type space_id, - acpi_adr_space_handler handler, - acpi_adr_space_setup setup, - void *context) +acpi_install_address_space_handler(acpi_handle device, + acpi_adr_space_type space_id, + acpi_adr_space_handler handler, + acpi_adr_space_setup setup, void *context) { - struct acpi_namespace_node *node; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_install_address_space_handler"); + struct acpi_namespace_node *node; + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_install_address_space_handler"); /* Parameter validation */ if (!device) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Convert and validate the device handle */ - node = acpi_ns_map_handle_to_node (device); + node = acpi_ns_map_handle_to_node(device); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -104,21 +98,23 @@ acpi_install_address_space_handler ( /* Install the handler for all Regions for this Space ID */ - status = acpi_ev_install_space_handler (node, space_id, handler, setup, context); - if (ACPI_FAILURE (status)) { + status = + acpi_ev_install_space_handler(node, space_id, handler, setup, + context); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* Run all _REG methods for this address space */ - status = acpi_ev_execute_reg_methods (node, space_id); + status = acpi_ev_execute_reg_methods(node, space_id); -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (status); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_install_address_space_handler); +EXPORT_SYMBOL(acpi_install_address_space_handler); /******************************************************************************* * @@ -135,36 +131,33 @@ EXPORT_SYMBOL(acpi_install_address_space_handler); ******************************************************************************/ acpi_status -acpi_remove_address_space_handler ( - acpi_handle device, - acpi_adr_space_type space_id, - acpi_adr_space_handler handler) +acpi_remove_address_space_handler(acpi_handle device, + acpi_adr_space_type space_id, + acpi_adr_space_handler handler) { - union acpi_operand_object *obj_desc; - union acpi_operand_object *handler_obj; - union acpi_operand_object *region_obj; - union acpi_operand_object **last_obj_ptr; - struct acpi_namespace_node *node; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_remove_address_space_handler"); + union acpi_operand_object *obj_desc; + union acpi_operand_object *handler_obj; + union acpi_operand_object *region_obj; + union acpi_operand_object **last_obj_ptr; + struct acpi_namespace_node *node; + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_remove_address_space_handler"); /* Parameter validation */ if (!device) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Convert and validate the device handle */ - node = acpi_ns_map_handle_to_node (device); + node = acpi_ns_map_handle_to_node(device); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -172,7 +165,7 @@ acpi_remove_address_space_handler ( /* Make sure the internal object exists */ - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { status = AE_NOT_EXIST; goto unlock_and_exit; @@ -188,10 +181,11 @@ acpi_remove_address_space_handler ( if (handler_obj->address_space.space_id == space_id) { /* Matched space_id, first dereference this in the Regions */ - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Removing address handler %p(%p) for region %s on Device %p(%p)\n", - handler_obj, handler, acpi_ut_get_region_name (space_id), - node, obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, + "Removing address handler %p(%p) for region %s on Device %p(%p)\n", + handler_obj, handler, + acpi_ut_get_region_name(space_id), + node, obj_desc)); region_obj = handler_obj->address_space.region_list; @@ -205,13 +199,14 @@ acpi_remove_address_space_handler ( * The region is just inaccessible as indicated to * the _REG method */ - acpi_ev_detach_region (region_obj, TRUE); + acpi_ev_detach_region(region_obj, TRUE); /* * Walk the list: Just grab the head because the * detach_region removed the previous head. */ - region_obj = handler_obj->address_space.region_list; + region_obj = + handler_obj->address_space.region_list; } @@ -221,7 +216,7 @@ acpi_remove_address_space_handler ( /* Now we can delete the handler object */ - acpi_ut_remove_reference (handler_obj); + acpi_ut_remove_reference(handler_obj); goto unlock_and_exit; } @@ -233,15 +228,16 @@ acpi_remove_address_space_handler ( /* The handler does not exist */ - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Unable to remove address handler %p for %s(%X), dev_node %p, obj %p\n", - handler, acpi_ut_get_region_name (space_id), space_id, node, obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, + "Unable to remove address handler %p for %s(%X), dev_node %p, obj %p\n", + handler, acpi_ut_get_region_name(space_id), space_id, + node, obj_desc)); status = AE_NOT_EXIST; -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (status); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_remove_address_space_handler); +EXPORT_SYMBOL(acpi_remove_address_space_handler); diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c index d11e9ec..1ce365d 100644 --- a/drivers/acpi/executer/exconfig.c +++ b/drivers/acpi/executer/exconfig.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -50,18 +49,14 @@ #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exconfig") +ACPI_MODULE_NAME("exconfig") /* Local prototypes */ - static acpi_status -acpi_ex_add_table ( - struct acpi_table_header *table, - struct acpi_namespace_node *parent_node, - union acpi_operand_object **ddb_handle); - +acpi_ex_add_table(struct acpi_table_header *table, + struct acpi_namespace_node *parent_node, + union acpi_operand_object **ddb_handle); /******************************************************************************* * @@ -79,24 +74,21 @@ acpi_ex_add_table ( ******************************************************************************/ static acpi_status -acpi_ex_add_table ( - struct acpi_table_header *table, - struct acpi_namespace_node *parent_node, - union acpi_operand_object **ddb_handle) +acpi_ex_add_table(struct acpi_table_header *table, + struct acpi_namespace_node *parent_node, + union acpi_operand_object **ddb_handle) { - acpi_status status; - struct acpi_table_desc table_info; - union acpi_operand_object *obj_desc; - - - ACPI_FUNCTION_TRACE ("ex_add_table"); + acpi_status status; + struct acpi_table_desc table_info; + union acpi_operand_object *obj_desc; + ACPI_FUNCTION_TRACE("ex_add_table"); /* Create an object to be the table handle */ - obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE); + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE); if (!obj_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Init the table handle */ @@ -106,45 +98,43 @@ acpi_ex_add_table ( /* Install the new table into the local data structures */ - ACPI_MEMSET (&table_info, 0, sizeof (struct acpi_table_desc)); + ACPI_MEMSET(&table_info, 0, sizeof(struct acpi_table_desc)); - table_info.type = ACPI_TABLE_SSDT; - table_info.pointer = table; - table_info.length = (acpi_size) table->length; + table_info.type = ACPI_TABLE_SSDT; + table_info.pointer = table; + table_info.length = (acpi_size) table->length; table_info.allocation = ACPI_MEM_ALLOCATED; - status = acpi_tb_install_table (&table_info); + status = acpi_tb_install_table(&table_info); obj_desc->reference.object = table_info.installed_desc; - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { if (status == AE_ALREADY_EXISTS) { /* Table already exists, just return the handle */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } goto cleanup; } /* Add the table to the namespace */ - status = acpi_ns_load_table (table_info.installed_desc, parent_node); - if (ACPI_FAILURE (status)) { + status = acpi_ns_load_table(table_info.installed_desc, parent_node); + if (ACPI_FAILURE(status)) { /* Uninstall table on error */ - (void) acpi_tb_uninstall_table (table_info.installed_desc); + (void)acpi_tb_uninstall_table(table_info.installed_desc); goto cleanup; } - return_ACPI_STATUS (AE_OK); - + return_ACPI_STATUS(AE_OK); -cleanup: - acpi_ut_remove_reference (obj_desc); + cleanup: + acpi_ut_remove_reference(obj_desc); *ddb_handle = NULL; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_load_table_op @@ -159,56 +149,53 @@ cleanup: ******************************************************************************/ acpi_status -acpi_ex_load_table_op ( - struct acpi_walk_state *walk_state, - union acpi_operand_object **return_desc) +acpi_ex_load_table_op(struct acpi_walk_state *walk_state, + union acpi_operand_object **return_desc) { - acpi_status status; - union acpi_operand_object **operand = &walk_state->operands[0]; - struct acpi_table_header *table; - struct acpi_namespace_node *parent_node; - struct acpi_namespace_node *start_node; - struct acpi_namespace_node *parameter_node = NULL; - union acpi_operand_object *ddb_handle; - - - ACPI_FUNCTION_TRACE ("ex_load_table_op"); + acpi_status status; + union acpi_operand_object **operand = &walk_state->operands[0]; + struct acpi_table_header *table; + struct acpi_namespace_node *parent_node; + struct acpi_namespace_node *start_node; + struct acpi_namespace_node *parameter_node = NULL; + union acpi_operand_object *ddb_handle; + ACPI_FUNCTION_TRACE("ex_load_table_op"); #if 0 /* * Make sure that the signature does not match one of the tables that * is already loaded. */ - status = acpi_tb_match_signature (operand[0]->string.pointer, NULL); + status = acpi_tb_match_signature(operand[0]->string.pointer, NULL); if (status == AE_OK) { /* Signature matched -- don't allow override */ - return_ACPI_STATUS (AE_ALREADY_EXISTS); + return_ACPI_STATUS(AE_ALREADY_EXISTS); } #endif /* Find the ACPI table */ - status = acpi_tb_find_table (operand[0]->string.pointer, - operand[1]->string.pointer, - operand[2]->string.pointer, &table); - if (ACPI_FAILURE (status)) { + status = acpi_tb_find_table(operand[0]->string.pointer, + operand[1]->string.pointer, + operand[2]->string.pointer, &table); + if (ACPI_FAILURE(status)) { if (status != AE_NOT_FOUND) { - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Table not found, return an Integer=0 and AE_OK */ - ddb_handle = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + ddb_handle = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!ddb_handle) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } ddb_handle->integer.value = 0; *return_desc = ddb_handle; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Default nodes */ @@ -223,10 +210,12 @@ acpi_ex_load_table_op ( * Find the node referenced by the root_path_string. This is the * location within the namespace where the table will be loaded. */ - status = acpi_ns_get_node_by_path (operand[3]->string.pointer, start_node, - ACPI_NS_SEARCH_PARENT, &parent_node); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ns_get_node_by_path(operand[3]->string.pointer, + start_node, ACPI_NS_SEARCH_PARENT, + &parent_node); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -234,7 +223,7 @@ acpi_ex_load_table_op ( if (operand[4]->string.length > 0) { if ((operand[4]->string.pointer[0] != '\\') && - (operand[4]->string.pointer[0] != '^')) { + (operand[4]->string.pointer[0] != '^')) { /* * Path is not absolute, so it will be relative to the node * referenced by the root_path_string (or the NS root if omitted) @@ -244,18 +233,20 @@ acpi_ex_load_table_op ( /* Find the node referenced by the parameter_path_string */ - status = acpi_ns_get_node_by_path (operand[4]->string.pointer, start_node, - ACPI_NS_SEARCH_PARENT, ¶meter_node); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ns_get_node_by_path(operand[4]->string.pointer, + start_node, ACPI_NS_SEARCH_PARENT, + ¶meter_node); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Load the table into the namespace */ - status = acpi_ex_add_table (table, parent_node, &ddb_handle); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_add_table(table, parent_node, &ddb_handle); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Parameter Data (optional) */ @@ -263,20 +254,20 @@ acpi_ex_load_table_op ( if (parameter_node) { /* Store the parameter data into the optional parameter object */ - status = acpi_ex_store (operand[5], - ACPI_CAST_PTR (union acpi_operand_object, parameter_node), - walk_state); - if (ACPI_FAILURE (status)) { - (void) acpi_ex_unload_table (ddb_handle); - return_ACPI_STATUS (status); + status = acpi_ex_store(operand[5], + ACPI_CAST_PTR(union acpi_operand_object, + parameter_node), + walk_state); + if (ACPI_FAILURE(status)) { + (void)acpi_ex_unload_table(ddb_handle); + return_ACPI_STATUS(status); } } *return_desc = ddb_handle; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_load_op @@ -293,38 +284,37 @@ acpi_ex_load_table_op ( ******************************************************************************/ acpi_status -acpi_ex_load_op ( - union acpi_operand_object *obj_desc, - union acpi_operand_object *target, - struct acpi_walk_state *walk_state) +acpi_ex_load_op(union acpi_operand_object *obj_desc, + union acpi_operand_object *target, + struct acpi_walk_state *walk_state) { - acpi_status status; - union acpi_operand_object *ddb_handle; - union acpi_operand_object *buffer_desc = NULL; - struct acpi_table_header *table_ptr = NULL; - acpi_physical_address address; - struct acpi_table_header table_header; - u32 i; - - ACPI_FUNCTION_TRACE ("ex_load_op"); + acpi_status status; + union acpi_operand_object *ddb_handle; + union acpi_operand_object *buffer_desc = NULL; + struct acpi_table_header *table_ptr = NULL; + acpi_physical_address address; + struct acpi_table_header table_header; + u32 i; + ACPI_FUNCTION_TRACE("ex_load_op"); /* Object can be either an op_region or a Field */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_REGION: - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n", - obj_desc, acpi_ut_get_object_type_name (obj_desc))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Load from Region %p %s\n", + obj_desc, + acpi_ut_get_object_type_name(obj_desc))); /* * If the Region Address and Length have not been previously evaluated, * evaluate them now and save the results. */ if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { - status = acpi_ds_get_region_arguments (obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_get_region_arguments(obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -336,121 +326,127 @@ acpi_ex_load_op ( table_header.length = 0; for (i = 0; i < 8; i++) { - status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ, - (acpi_physical_address) (i + address), 8, - ((u8 *) &table_header) + i); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ev_address_space_dispatch(obj_desc, ACPI_READ, + (acpi_physical_address) + (i + address), 8, + ((u8 *) & + table_header) + i); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Sanity check the table length */ - if (table_header.length < sizeof (struct acpi_table_header)) { - return_ACPI_STATUS (AE_BAD_HEADER); + if (table_header.length < sizeof(struct acpi_table_header)) { + return_ACPI_STATUS(AE_BAD_HEADER); } /* Allocate a buffer for the entire table */ - table_ptr = ACPI_MEM_ALLOCATE (table_header.length); + table_ptr = ACPI_MEM_ALLOCATE(table_header.length); if (!table_ptr) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Get the entire table from the op region */ for (i = 0; i < table_header.length; i++) { - status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ, - (acpi_physical_address) (i + address), 8, - ((u8 *) table_ptr + i)); - if (ACPI_FAILURE (status)) { + status = + acpi_ev_address_space_dispatch(obj_desc, ACPI_READ, + (acpi_physical_address) + (i + address), 8, + ((u8 *) table_ptr + + i)); + if (ACPI_FAILURE(status)) { goto cleanup; } } break; - case ACPI_TYPE_LOCAL_REGION_FIELD: case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Field %p %s\n", - obj_desc, acpi_ut_get_object_type_name (obj_desc))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Load from Field %p %s\n", + obj_desc, + acpi_ut_get_object_type_name(obj_desc))); /* * The length of the field must be at least as large as the table. * Read the entire field and thus the entire table. Buffer is * allocated during the read. */ - status = acpi_ex_read_data_from_field (walk_state, obj_desc, &buffer_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ex_read_data_from_field(walk_state, obj_desc, + &buffer_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - table_ptr = ACPI_CAST_PTR (struct acpi_table_header, - buffer_desc->buffer.pointer); + table_ptr = ACPI_CAST_PTR(struct acpi_table_header, + buffer_desc->buffer.pointer); /* All done with the buffer_desc, delete it */ buffer_desc->buffer.pointer = NULL; - acpi_ut_remove_reference (buffer_desc); + acpi_ut_remove_reference(buffer_desc); /* Sanity check the table length */ - if (table_ptr->length < sizeof (struct acpi_table_header)) { + if (table_ptr->length < sizeof(struct acpi_table_header)) { status = AE_BAD_HEADER; goto cleanup; } break; - default: - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* The table must be either an SSDT or a PSDT */ - if ((!ACPI_STRNCMP (table_ptr->signature, - acpi_gbl_table_data[ACPI_TABLE_PSDT].signature, - acpi_gbl_table_data[ACPI_TABLE_PSDT].sig_length)) && - (!ACPI_STRNCMP (table_ptr->signature, - acpi_gbl_table_data[ACPI_TABLE_SSDT].signature, - acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Table has invalid signature [%4.4s], must be SSDT or PSDT\n", - table_ptr->signature)); + if ((!ACPI_STRNCMP(table_ptr->signature, + acpi_gbl_table_data[ACPI_TABLE_PSDT].signature, + acpi_gbl_table_data[ACPI_TABLE_PSDT].sig_length)) && + (!ACPI_STRNCMP(table_ptr->signature, + acpi_gbl_table_data[ACPI_TABLE_SSDT].signature, + acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Table has invalid signature [%4.4s], must be SSDT or PSDT\n", + table_ptr->signature)); status = AE_BAD_SIGNATURE; goto cleanup; } /* Install the new table into the local data structures */ - status = acpi_ex_add_table (table_ptr, acpi_gbl_root_node, &ddb_handle); - if (ACPI_FAILURE (status)) { + status = acpi_ex_add_table(table_ptr, acpi_gbl_root_node, &ddb_handle); + if (ACPI_FAILURE(status)) { /* On error, table_ptr was deallocated above */ - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Store the ddb_handle into the Target operand */ - status = acpi_ex_store (ddb_handle, target, walk_state); - if (ACPI_FAILURE (status)) { - (void) acpi_ex_unload_table (ddb_handle); + status = acpi_ex_store(ddb_handle, target, walk_state); + if (ACPI_FAILURE(status)) { + (void)acpi_ex_unload_table(ddb_handle); /* table_ptr was deallocated above */ - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } -cleanup: - if (ACPI_FAILURE (status)) { - ACPI_MEM_FREE (table_ptr); + cleanup: + if (ACPI_FAILURE(status)) { + ACPI_MEM_FREE(table_ptr); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_unload_table @@ -463,17 +459,13 @@ cleanup: * ******************************************************************************/ -acpi_status -acpi_ex_unload_table ( - union acpi_operand_object *ddb_handle) +acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle) { - acpi_status status = AE_OK; - union acpi_operand_object *table_desc = ddb_handle; - struct acpi_table_desc *table_info; - - - ACPI_FUNCTION_TRACE ("ex_unload_table"); + acpi_status status = AE_OK; + union acpi_operand_object *table_desc = ddb_handle; + struct acpi_table_desc *table_info; + ACPI_FUNCTION_TRACE("ex_unload_table"); /* * Validate the handle @@ -482,29 +474,28 @@ acpi_ex_unload_table ( * validated here. */ if ((!ddb_handle) || - (ACPI_GET_DESCRIPTOR_TYPE (ddb_handle) != ACPI_DESC_TYPE_OPERAND) || - (ACPI_GET_OBJECT_TYPE (ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) || + (ACPI_GET_OBJECT_TYPE(ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Get the actual table descriptor from the ddb_handle */ - table_info = (struct acpi_table_desc *) table_desc->reference.object; + table_info = (struct acpi_table_desc *)table_desc->reference.object; /* * Delete the entire namespace under this table Node * (Offset contains the table_id) */ - acpi_ns_delete_namespace_by_owner (table_info->owner_id); - acpi_ut_release_owner_id (&table_info->owner_id); + acpi_ns_delete_namespace_by_owner(table_info->owner_id); + acpi_ut_release_owner_id(&table_info->owner_id); /* Delete the table itself */ - (void) acpi_tb_uninstall_table (table_info->installed_desc); + (void)acpi_tb_uninstall_table(table_info->installed_desc); /* Delete the table descriptor (ddb_handle) */ - acpi_ut_remove_reference (table_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(table_desc); + return_ACPI_STATUS(status); } - diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c index 2133162..04e5194 100644 --- a/drivers/acpi/executer/exconvrt.c +++ b/drivers/acpi/executer/exconvrt.c @@ -41,24 +41,17 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exconvrt") +ACPI_MODULE_NAME("exconvrt") /* Local prototypes */ - static u32 -acpi_ex_convert_to_ascii ( - acpi_integer integer, - u16 base, - u8 *string, - u8 max_length); - +acpi_ex_convert_to_ascii(acpi_integer integer, + u16 base, u8 * string, u8 max_length); /******************************************************************************* * @@ -76,29 +69,25 @@ acpi_ex_convert_to_ascii ( ******************************************************************************/ acpi_status -acpi_ex_convert_to_integer ( - union acpi_operand_object *obj_desc, - union acpi_operand_object **result_desc, - u32 flags) +acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, + union acpi_operand_object **result_desc, u32 flags) { - union acpi_operand_object *return_desc; - u8 *pointer; - acpi_integer result; - u32 i; - u32 count; - acpi_status status; - + union acpi_operand_object *return_desc; + u8 *pointer; + acpi_integer result; + u32 i; + u32 count; + acpi_status status; - ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_integer", obj_desc); + ACPI_FUNCTION_TRACE_PTR("ex_convert_to_integer", obj_desc); - - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_INTEGER: /* No conversion necessary */ *result_desc = obj_desc; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); case ACPI_TYPE_BUFFER: case ACPI_TYPE_STRING: @@ -106,11 +95,11 @@ acpi_ex_convert_to_integer ( /* Note: Takes advantage of common buffer/string fields */ pointer = obj_desc->buffer.pointer; - count = obj_desc->buffer.length; + count = obj_desc->buffer.length; break; default: - return_ACPI_STATUS (AE_TYPE); + return_ACPI_STATUS(AE_TYPE); } /* @@ -126,7 +115,7 @@ acpi_ex_convert_to_integer ( /* String conversion is different than Buffer conversion */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_STRING: /* @@ -135,19 +124,18 @@ acpi_ex_convert_to_integer ( * of ACPI 3.0) is that the to_integer() operator allows both decimal * and hexadecimal strings (hex prefixed with "0x"). */ - status = acpi_ut_strtoul64 ((char *) pointer, flags, &result); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_strtoul64((char *)pointer, flags, &result); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } break; - case ACPI_TYPE_BUFFER: /* Check for zero-length buffer */ if (!count) { - return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + return_ACPI_STATUS(AE_AML_BUFFER_LIMIT); } /* Transfer no more than an integer's worth of data */ @@ -170,7 +158,6 @@ acpi_ex_convert_to_integer ( } break; - default: /* No other types can get here */ break; @@ -178,20 +165,19 @@ acpi_ex_convert_to_integer ( /* Create a new integer */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Save the Result */ return_desc->integer.value = result; - acpi_ex_truncate_for32bit_table (return_desc); + acpi_ex_truncate_for32bit_table(return_desc); *result_desc = return_desc; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ex_convert_to_buffer @@ -207,25 +193,21 @@ acpi_ex_convert_to_integer ( ******************************************************************************/ acpi_status -acpi_ex_convert_to_buffer ( - union acpi_operand_object *obj_desc, - union acpi_operand_object **result_desc) +acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc, + union acpi_operand_object **result_desc) { - union acpi_operand_object *return_desc; - u8 *new_buf; + union acpi_operand_object *return_desc; + u8 *new_buf; + ACPI_FUNCTION_TRACE_PTR("ex_convert_to_buffer", obj_desc); - ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_buffer", obj_desc); - - - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_BUFFER: /* No conversion necessary */ *result_desc = obj_desc; - return_ACPI_STATUS (AE_OK); - + return_ACPI_STATUS(AE_OK); case ACPI_TYPE_INTEGER: @@ -233,20 +215,20 @@ acpi_ex_convert_to_buffer ( * Create a new Buffer object. * Need enough space for one integer */ - return_desc = acpi_ut_create_buffer_object (acpi_gbl_integer_byte_width); + return_desc = + acpi_ut_create_buffer_object(acpi_gbl_integer_byte_width); if (!return_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Copy the integer to the buffer, LSB first */ new_buf = return_desc->buffer.pointer; - ACPI_MEMCPY (new_buf, - &obj_desc->integer.value, - acpi_gbl_integer_byte_width); + ACPI_MEMCPY(new_buf, + &obj_desc->integer.value, + acpi_gbl_integer_byte_width); break; - case ACPI_TYPE_STRING: /* @@ -258,32 +240,31 @@ acpi_ex_convert_to_buffer ( * ASL/AML code that depends on the null being transferred to the new * buffer. */ - return_desc = acpi_ut_create_buffer_object ( - (acpi_size) obj_desc->string.length + 1); + return_desc = acpi_ut_create_buffer_object((acpi_size) + obj_desc->string. + length + 1); if (!return_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Copy the string to the buffer */ new_buf = return_desc->buffer.pointer; - ACPI_STRNCPY ((char *) new_buf, (char *) obj_desc->string.pointer, - obj_desc->string.length); + ACPI_STRNCPY((char *)new_buf, (char *)obj_desc->string.pointer, + obj_desc->string.length); break; - default: - return_ACPI_STATUS (AE_TYPE); + return_ACPI_STATUS(AE_TYPE); } /* Mark buffer initialized */ return_desc->common.flags |= AOPOBJ_DATA_VALID; *result_desc = return_desc; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ex_convert_to_ascii @@ -300,24 +281,19 @@ acpi_ex_convert_to_buffer ( ******************************************************************************/ static u32 -acpi_ex_convert_to_ascii ( - acpi_integer integer, - u16 base, - u8 *string, - u8 data_width) +acpi_ex_convert_to_ascii(acpi_integer integer, + u16 base, u8 * string, u8 data_width) { - acpi_integer digit; - acpi_native_uint i; - acpi_native_uint j; - acpi_native_uint k = 0; - acpi_native_uint hex_length; - acpi_native_uint decimal_length; - u32 remainder; - u8 supress_zeros; - - - ACPI_FUNCTION_ENTRY (); + acpi_integer digit; + acpi_native_uint i; + acpi_native_uint j; + acpi_native_uint k = 0; + acpi_native_uint hex_length; + acpi_native_uint decimal_length; + u32 remainder; + u8 supress_zeros; + ACPI_FUNCTION_ENTRY(); switch (base) { case 10: @@ -339,7 +315,7 @@ acpi_ex_convert_to_ascii ( break; } - supress_zeros = TRUE; /* No leading zeros */ + supress_zeros = TRUE; /* No leading zeros */ remainder = 0; for (i = decimal_length; i > 0; i--) { @@ -347,7 +323,8 @@ acpi_ex_convert_to_ascii ( digit = integer; for (j = 0; j < i; j++) { - (void) acpi_ut_short_divide (digit, 10, &digit, &remainder); + (void)acpi_ut_short_divide(digit, 10, &digit, + &remainder); } /* Handle leading zeros */ @@ -367,11 +344,13 @@ acpi_ex_convert_to_ascii ( /* hex_length: 2 ascii hex chars per data byte */ - hex_length = (acpi_native_uint) ACPI_MUL_2 (data_width); - for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) { + hex_length = (acpi_native_uint) ACPI_MUL_2(data_width); + for (i = 0, j = (hex_length - 1); i < hex_length; i++, j--) { /* Get one hex digit, most significant digits first */ - string[k] = (u8) acpi_ut_hex_to_ascii_char (integer, ACPI_MUL_4 (j)); + string[k] = + (u8) acpi_ut_hex_to_ascii_char(integer, + ACPI_MUL_4(j)); k++; } break; @@ -387,15 +366,14 @@ acpi_ex_convert_to_ascii ( * Finally, null terminate the string and return the length */ if (!k) { - string [0] = ACPI_ASCII_ZERO; + string[0] = ACPI_ASCII_ZERO; k = 1; } - string [k] = 0; + string[k] = 0; return ((u32) k); } - /******************************************************************************* * * FUNCTION: acpi_ex_convert_to_string @@ -412,30 +390,25 @@ acpi_ex_convert_to_ascii ( ******************************************************************************/ acpi_status -acpi_ex_convert_to_string ( - union acpi_operand_object *obj_desc, - union acpi_operand_object **result_desc, - u32 type) +acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, + union acpi_operand_object ** result_desc, u32 type) { - union acpi_operand_object *return_desc; - u8 *new_buf; - u32 i; - u32 string_length = 0; - u16 base = 16; - u8 separator = ','; + union acpi_operand_object *return_desc; + u8 *new_buf; + u32 i; + u32 string_length = 0; + u16 base = 16; + u8 separator = ','; + ACPI_FUNCTION_TRACE_PTR("ex_convert_to_string", obj_desc); - ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_string", obj_desc); - - - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_STRING: /* No conversion necessary */ *result_desc = obj_desc; - return_ACPI_STATUS (AE_OK); - + return_ACPI_STATUS(AE_OK); case ACPI_TYPE_INTEGER: @@ -452,7 +425,7 @@ acpi_ex_convert_to_string ( /* Two hex string characters for each integer byte */ - string_length = ACPI_MUL_2 (acpi_gbl_integer_byte_width); + string_length = ACPI_MUL_2(acpi_gbl_integer_byte_width); break; } @@ -460,31 +433,33 @@ acpi_ex_convert_to_string ( * Create a new String * Need enough space for one ASCII integer (plus null terminator) */ - return_desc = acpi_ut_create_string_object ((acpi_size) string_length); + return_desc = + acpi_ut_create_string_object((acpi_size) string_length); if (!return_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } new_buf = return_desc->buffer.pointer; /* Convert integer to string */ - string_length = acpi_ex_convert_to_ascii (obj_desc->integer.value, base, - new_buf, acpi_gbl_integer_byte_width); + string_length = + acpi_ex_convert_to_ascii(obj_desc->integer.value, base, + new_buf, + acpi_gbl_integer_byte_width); /* Null terminate at the correct place */ return_desc->string.length = string_length; - new_buf [string_length] = 0; + new_buf[string_length] = 0; break; - case ACPI_TYPE_BUFFER: /* Setup string length, base, and separator */ switch (type) { - case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */ + case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */ /* * From ACPI: "If Data is a buffer, it is converted to a string of * decimal values separated by commas." @@ -498,11 +473,9 @@ acpi_ex_convert_to_string ( for (i = 0; i < obj_desc->buffer.length; i++) { if (obj_desc->buffer.pointer[i] >= 100) { string_length += 4; - } - else if (obj_desc->buffer.pointer[i] >= 10) { + } else if (obj_desc->buffer.pointer[i] >= 10) { string_length += 3; - } - else { + } else { string_length += 2; } } @@ -518,7 +491,7 @@ acpi_ex_convert_to_string ( string_length = (obj_desc->buffer.length * 3); break; - case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string */ + case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string */ /* * From ACPI: "If Data is a buffer, it is converted to a string of * hexadecimal values separated by commas." @@ -527,7 +500,7 @@ acpi_ex_convert_to_string ( break; default: - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* @@ -535,15 +508,16 @@ acpi_ex_convert_to_string ( * (-1 because of extra separator included in string_length from above) */ string_length--; - if (string_length > ACPI_MAX_STRING_CONVERSION) /* ACPI limit */ { - return_ACPI_STATUS (AE_AML_STRING_LIMIT); + if (string_length > ACPI_MAX_STRING_CONVERSION) { /* ACPI limit */ + return_ACPI_STATUS(AE_AML_STRING_LIMIT); } /* Create a new string object and string buffer */ - return_desc = acpi_ut_create_string_object ((acpi_size) string_length); + return_desc = + acpi_ut_create_string_object((acpi_size) string_length); if (!return_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } new_buf = return_desc->buffer.pointer; @@ -553,10 +527,11 @@ acpi_ex_convert_to_string ( * (separated by commas or spaces) */ for (i = 0; i < obj_desc->buffer.length; i++) { - new_buf += acpi_ex_convert_to_ascii ( - (acpi_integer) obj_desc->buffer.pointer[i], base, - new_buf, 1); - *new_buf++ = separator; /* each separated by a comma or space */ + new_buf += acpi_ex_convert_to_ascii((acpi_integer) + obj_desc->buffer. + pointer[i], base, + new_buf, 1); + *new_buf++ = separator; /* each separated by a comma or space */ } /* @@ -568,14 +543,13 @@ acpi_ex_convert_to_string ( break; default: - return_ACPI_STATUS (AE_TYPE); + return_ACPI_STATUS(AE_TYPE); } *result_desc = return_desc; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ex_convert_to_target_type @@ -592,17 +566,14 @@ acpi_ex_convert_to_string ( ******************************************************************************/ acpi_status -acpi_ex_convert_to_target_type ( - acpi_object_type destination_type, - union acpi_operand_object *source_desc, - union acpi_operand_object **result_desc, - struct acpi_walk_state *walk_state) +acpi_ex_convert_to_target_type(acpi_object_type destination_type, + union acpi_operand_object *source_desc, + union acpi_operand_object **result_desc, + struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ex_convert_to_target_type"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ex_convert_to_target_type"); /* Default behavior */ @@ -612,10 +583,10 @@ acpi_ex_convert_to_target_type ( * If required by the target, * perform implicit conversion on the source before we store it. */ - switch (GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args)) { + switch (GET_CURRENT_ARG_TYPE(walk_state->op_info->runtime_args)) { case ARGI_SIMPLE_TARGET: case ARGI_FIXED_TARGET: - case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ + case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ switch (destination_type) { case ACPI_TYPE_LOCAL_REGION_FIELD: @@ -627,17 +598,19 @@ acpi_ex_convert_to_target_type ( default: /* No conversion allowed for these types */ - if (destination_type != ACPI_GET_OBJECT_TYPE (source_desc)) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Explicit operator, will store (%s) over existing type (%s)\n", - acpi_ut_get_object_type_name (source_desc), - acpi_ut_get_type_name (destination_type))); + if (destination_type != + ACPI_GET_OBJECT_TYPE(source_desc)) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Explicit operator, will store (%s) over existing type (%s)\n", + acpi_ut_get_object_type_name + (source_desc), + acpi_ut_get_type_name + (destination_type))); status = AE_TYPE; } } break; - case ARGI_TARGETREF: switch (destination_type) { @@ -649,55 +622,55 @@ acpi_ex_convert_to_target_type ( * These types require an Integer operand. We can convert * a Buffer or a String to an Integer if necessary. */ - status = acpi_ex_convert_to_integer (source_desc, result_desc, - 16); + status = + acpi_ex_convert_to_integer(source_desc, result_desc, + 16); break; - case ACPI_TYPE_STRING: /* * The operand must be a String. We can convert an * Integer or Buffer if necessary */ - status = acpi_ex_convert_to_string (source_desc, result_desc, - ACPI_IMPLICIT_CONVERT_HEX); + status = + acpi_ex_convert_to_string(source_desc, result_desc, + ACPI_IMPLICIT_CONVERT_HEX); break; - case ACPI_TYPE_BUFFER: /* * The operand must be a Buffer. We can convert an * Integer or String if necessary */ - status = acpi_ex_convert_to_buffer (source_desc, result_desc); + status = + acpi_ex_convert_to_buffer(source_desc, result_desc); break; - default: - ACPI_REPORT_ERROR (("Bad destination type during conversion: %X\n", - destination_type)); + ACPI_REPORT_ERROR(("Bad destination type during conversion: %X\n", destination_type)); status = AE_AML_INTERNAL; break; } break; - case ARGI_REFERENCE: /* * create_xxxx_field cases - we are storing the field object into the name */ break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown Target type ID 0x%X Op %s dest_type %s\n", - GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args), - walk_state->op_info->name, acpi_ut_get_type_name (destination_type))); - - ACPI_REPORT_ERROR (("Bad Target Type (ARGI): %X\n", - GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args))) - status = AE_AML_INTERNAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown Target type ID 0x%X Op %s dest_type %s\n", + GET_CURRENT_ARG_TYPE(walk_state->op_info-> + runtime_args), + walk_state->op_info->name, + acpi_ut_get_type_name(destination_type))); + + ACPI_REPORT_ERROR(("Bad Target Type (ARGI): %X\n", + GET_CURRENT_ARG_TYPE(walk_state->op_info-> + runtime_args))) + status = AE_AML_INTERNAL; } /* @@ -710,7 +683,5 @@ acpi_ex_convert_to_target_type ( status = AE_OK; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/executer/excreate.c index 812cdcb..91c4918 100644 --- a/drivers/acpi/executer/excreate.c +++ b/drivers/acpi/executer/excreate.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -49,10 +48,8 @@ #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("excreate") - +ACPI_MODULE_NAME("excreate") #ifndef ACPI_NO_METHOD_EXECUTION /******************************************************************************* @@ -66,33 +63,30 @@ * DESCRIPTION: Create a new named alias * ******************************************************************************/ - -acpi_status -acpi_ex_create_alias ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state) { - struct acpi_namespace_node *target_node; - struct acpi_namespace_node *alias_node; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ex_create_alias"); + struct acpi_namespace_node *target_node; + struct acpi_namespace_node *alias_node; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ex_create_alias"); /* Get the source/alias operands (both namespace nodes) */ - alias_node = (struct acpi_namespace_node *) walk_state->operands[0]; - target_node = (struct acpi_namespace_node *) walk_state->operands[1]; + alias_node = (struct acpi_namespace_node *)walk_state->operands[0]; + target_node = (struct acpi_namespace_node *)walk_state->operands[1]; if ((target_node->type == ACPI_TYPE_LOCAL_ALIAS) || - (target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { + (target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { /* * Dereference an existing alias so that we don't create a chain * of aliases. With this code, we guarantee that an alias is * always exactly one level of indirection away from the * actual aliased name. */ - target_node = ACPI_CAST_PTR (struct acpi_namespace_node, target_node->object); + target_node = + ACPI_CAST_PTR(struct acpi_namespace_node, + target_node->object); } /* @@ -115,7 +109,8 @@ acpi_ex_create_alias ( * types, the object can change dynamically via a Store. */ alias_node->type = ACPI_TYPE_LOCAL_ALIAS; - alias_node->object = ACPI_CAST_PTR (union acpi_operand_object, target_node); + alias_node->object = + ACPI_CAST_PTR(union acpi_operand_object, target_node); break; case ACPI_TYPE_METHOD: @@ -126,7 +121,8 @@ acpi_ex_create_alias ( * types, the object can change dynamically via a Store. */ alias_node->type = ACPI_TYPE_LOCAL_METHOD_ALIAS; - alias_node->object = ACPI_CAST_PTR (union acpi_operand_object, target_node); + alias_node->object = + ACPI_CAST_PTR(union acpi_operand_object, target_node); break; default: @@ -139,17 +135,18 @@ acpi_ex_create_alias ( * additional reference to prevent deletion out from under either the * target node or the alias Node */ - status = acpi_ns_attach_object (alias_node, - acpi_ns_get_attached_object (target_node), target_node->type); + status = acpi_ns_attach_object(alias_node, + acpi_ns_get_attached_object + (target_node), + target_node->type); break; } /* Since both operands are Nodes, we don't need to delete them */ - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_create_event @@ -162,18 +159,14 @@ acpi_ex_create_alias ( * ******************************************************************************/ -acpi_status -acpi_ex_create_event ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state) { - acpi_status status; - union acpi_operand_object *obj_desc; - - - ACPI_FUNCTION_TRACE ("ex_create_event"); + acpi_status status; + union acpi_operand_object *obj_desc; + ACPI_FUNCTION_TRACE("ex_create_event"); - obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_EVENT); + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_EVENT); if (!obj_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -183,27 +176,27 @@ acpi_ex_create_event ( * Create the actual OS semaphore, with zero initial units -- meaning * that the event is created in an unsignalled state */ - status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0, - &obj_desc->event.semaphore); - if (ACPI_FAILURE (status)) { + status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, + &obj_desc->event.semaphore); + if (ACPI_FAILURE(status)) { goto cleanup; } /* Attach object to the Node */ - status = acpi_ns_attach_object ((struct acpi_namespace_node *) walk_state->operands[0], - obj_desc, ACPI_TYPE_EVENT); + status = + acpi_ns_attach_object((struct acpi_namespace_node *)walk_state-> + operands[0], obj_desc, ACPI_TYPE_EVENT); -cleanup: + cleanup: /* * Remove local reference to the object (on error, will cause deletion * of both object and semaphore if present.) */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_create_mutex @@ -218,20 +211,16 @@ cleanup: * ******************************************************************************/ -acpi_status -acpi_ex_create_mutex ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - union acpi_operand_object *obj_desc; - - - ACPI_FUNCTION_TRACE_PTR ("ex_create_mutex", ACPI_WALK_OPERANDS); + acpi_status status = AE_OK; + union acpi_operand_object *obj_desc; + ACPI_FUNCTION_TRACE_PTR("ex_create_mutex", ACPI_WALK_OPERANDS); /* Create the new mutex object */ - obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_MUTEX); + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_MUTEX); if (!obj_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -242,30 +231,30 @@ acpi_ex_create_mutex ( * One unit max to make it a mutex, with one initial unit to allow * the mutex to be acquired. */ - status = acpi_os_create_semaphore (1, 1, &obj_desc->mutex.semaphore); - if (ACPI_FAILURE (status)) { + status = acpi_os_create_semaphore(1, 1, &obj_desc->mutex.semaphore); + if (ACPI_FAILURE(status)) { goto cleanup; } /* Init object and attach to NS node */ - obj_desc->mutex.sync_level = (u8) walk_state->operands[1]->integer.value; - obj_desc->mutex.node = (struct acpi_namespace_node *) walk_state->operands[0]; - - status = acpi_ns_attach_object (obj_desc->mutex.node, - obj_desc, ACPI_TYPE_MUTEX); + obj_desc->mutex.sync_level = + (u8) walk_state->operands[1]->integer.value; + obj_desc->mutex.node = + (struct acpi_namespace_node *)walk_state->operands[0]; + status = acpi_ns_attach_object(obj_desc->mutex.node, + obj_desc, ACPI_TYPE_MUTEX); -cleanup: + cleanup: /* * Remove local reference to the object (on error, will cause deletion * of both object and semaphore if present.) */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_create_region @@ -282,20 +271,16 @@ cleanup: ******************************************************************************/ acpi_status -acpi_ex_create_region ( - u8 *aml_start, - u32 aml_length, - u8 region_space, - struct acpi_walk_state *walk_state) +acpi_ex_create_region(u8 * aml_start, + u32 aml_length, + u8 region_space, struct acpi_walk_state *walk_state) { - acpi_status status; - union acpi_operand_object *obj_desc; - struct acpi_namespace_node *node; - union acpi_operand_object *region_obj2; - - - ACPI_FUNCTION_TRACE ("ex_create_region"); + acpi_status status; + union acpi_operand_object *obj_desc; + struct acpi_namespace_node *node; + union acpi_operand_object *region_obj2; + ACPI_FUNCTION_TRACE("ex_create_region"); /* Get the Namespace Node */ @@ -305,8 +290,8 @@ acpi_ex_create_region ( * If the region object is already attached to this node, * just return */ - if (acpi_ns_get_attached_object (node)) { - return_ACPI_STATUS (AE_OK); + if (acpi_ns_get_attached_object(node)) { + return_ACPI_STATUS(AE_OK); } /* @@ -314,17 +299,18 @@ acpi_ex_create_region ( * range */ if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) && - (region_space < ACPI_USER_REGION_BEGIN)) { - ACPI_REPORT_ERROR (("Invalid address_space type %X\n", region_space)); - return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); + (region_space < ACPI_USER_REGION_BEGIN)) { + ACPI_REPORT_ERROR(("Invalid address_space type %X\n", + region_space)); + return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID); } - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", - acpi_ut_get_region_name (region_space), region_space)); + ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Region Type - %s (%X)\n", + acpi_ut_get_region_name(region_space), region_space)); /* Create the region descriptor */ - obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_REGION); + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION); if (!obj_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -334,7 +320,7 @@ acpi_ex_create_region ( * Remember location in AML stream of address & length * operands since they need to be evaluated at run time. */ - region_obj2 = obj_desc->common.next_object; + region_obj2 = obj_desc->common.next_object; region_obj2->extra.aml_start = aml_start; region_obj2->extra.aml_length = aml_length; @@ -343,22 +329,20 @@ acpi_ex_create_region ( obj_desc->region.space_id = region_space; obj_desc->region.address = 0; obj_desc->region.length = 0; - obj_desc->region.node = node; + obj_desc->region.node = node; /* Install the new region object in the parent Node */ - status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_REGION); + status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_REGION); - -cleanup: + cleanup: /* Remove local reference to the object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_create_table_region @@ -371,20 +355,16 @@ cleanup: * ******************************************************************************/ -acpi_status -acpi_ex_create_table_region ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_create_table_region(struct acpi_walk_state *walk_state) { - acpi_status status; - union acpi_operand_object **operand = &walk_state->operands[0]; - union acpi_operand_object *obj_desc; - struct acpi_namespace_node *node; - struct acpi_table_header *table; - union acpi_operand_object *region_obj2; - - - ACPI_FUNCTION_TRACE ("ex_create_table_region"); + acpi_status status; + union acpi_operand_object **operand = &walk_state->operands[0]; + union acpi_operand_object *obj_desc; + struct acpi_namespace_node *node; + struct acpi_table_header *table; + union acpi_operand_object *region_obj2; + ACPI_FUNCTION_TRACE("ex_create_table_region"); /* Get the Node from the object stack */ @@ -394,66 +374,64 @@ acpi_ex_create_table_region ( * If the region object is already attached to this node, * just return */ - if (acpi_ns_get_attached_object (node)) { - return_ACPI_STATUS (AE_OK); + if (acpi_ns_get_attached_object(node)) { + return_ACPI_STATUS(AE_OK); } /* Find the ACPI table */ - status = acpi_tb_find_table (operand[1]->string.pointer, - operand[2]->string.pointer, - operand[3]->string.pointer, &table); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_find_table(operand[1]->string.pointer, + operand[2]->string.pointer, + operand[3]->string.pointer, &table); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Create the region descriptor */ - obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_REGION); + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION); if (!obj_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } - region_obj2 = obj_desc->common.next_object; + region_obj2 = obj_desc->common.next_object; region_obj2->extra.region_context = NULL; /* Init the region from the operands */ obj_desc->region.space_id = REGION_DATA_TABLE; - obj_desc->region.address = (acpi_physical_address) ACPI_TO_INTEGER (table); + obj_desc->region.address = + (acpi_physical_address) ACPI_TO_INTEGER(table); obj_desc->region.length = table->length; - obj_desc->region.node = node; - obj_desc->region.flags = AOPOBJ_DATA_VALID; + obj_desc->region.node = node; + obj_desc->region.flags = AOPOBJ_DATA_VALID; /* Install the new region object in the parent Node */ - status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_REGION); - if (ACPI_FAILURE (status)) { + status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_REGION); + if (ACPI_FAILURE(status)) { goto cleanup; } - status = acpi_ev_initialize_region (obj_desc, FALSE); - if (ACPI_FAILURE (status)) { + status = acpi_ev_initialize_region(obj_desc, FALSE); + if (ACPI_FAILURE(status)) { if (status == AE_NOT_EXIST) { status = AE_OK; - } - else { + } else { goto cleanup; } } obj_desc->region.flags |= AOPOBJ_SETUP_COMPLETE; - -cleanup: + cleanup: /* Remove local reference to the object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_create_processor @@ -468,43 +446,39 @@ cleanup: * ******************************************************************************/ -acpi_status -acpi_ex_create_processor ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - union acpi_operand_object *obj_desc; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ex_create_processor", walk_state); + union acpi_operand_object **operand = &walk_state->operands[0]; + union acpi_operand_object *obj_desc; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ex_create_processor", walk_state); /* Create the processor object */ - obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_PROCESSOR); + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PROCESSOR); if (!obj_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Initialize the processor object from the operands */ - obj_desc->processor.proc_id = (u8) operand[1]->integer.value; - obj_desc->processor.address = (acpi_io_address) operand[2]->integer.value; - obj_desc->processor.length = (u8) operand[3]->integer.value; + obj_desc->processor.proc_id = (u8) operand[1]->integer.value; + obj_desc->processor.address = + (acpi_io_address) operand[2]->integer.value; + obj_desc->processor.length = (u8) operand[3]->integer.value; /* Install the processor object in the parent Node */ - status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0], - obj_desc, ACPI_TYPE_PROCESSOR); + status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0], + obj_desc, ACPI_TYPE_PROCESSOR); /* Remove local reference to the object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_create_power_resource @@ -519,43 +493,39 @@ acpi_ex_create_processor ( * ******************************************************************************/ -acpi_status -acpi_ex_create_power_resource ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_create_power_resource(struct acpi_walk_state *walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - acpi_status status; - union acpi_operand_object *obj_desc; - - - ACPI_FUNCTION_TRACE_PTR ("ex_create_power_resource", walk_state); + union acpi_operand_object **operand = &walk_state->operands[0]; + acpi_status status; + union acpi_operand_object *obj_desc; + ACPI_FUNCTION_TRACE_PTR("ex_create_power_resource", walk_state); /* Create the power resource object */ - obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_POWER); + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_POWER); if (!obj_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Initialize the power object from the operands */ obj_desc->power_resource.system_level = (u8) operand[1]->integer.value; - obj_desc->power_resource.resource_order = (u16) operand[2]->integer.value; + obj_desc->power_resource.resource_order = + (u16) operand[2]->integer.value; /* Install the power resource object in the parent Node */ - status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0], - obj_desc, ACPI_TYPE_POWER); + status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0], + obj_desc, ACPI_TYPE_POWER); /* Remove local reference to the object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } #endif - /******************************************************************************* * * FUNCTION: acpi_ex_create_method @@ -571,25 +541,21 @@ acpi_ex_create_power_resource ( ******************************************************************************/ acpi_status -acpi_ex_create_method ( - u8 *aml_start, - u32 aml_length, - struct acpi_walk_state *walk_state) +acpi_ex_create_method(u8 * aml_start, + u32 aml_length, struct acpi_walk_state *walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - union acpi_operand_object *obj_desc; - acpi_status status; - u8 method_flags; - - - ACPI_FUNCTION_TRACE_PTR ("ex_create_method", walk_state); + union acpi_operand_object **operand = &walk_state->operands[0]; + union acpi_operand_object *obj_desc; + acpi_status status; + u8 method_flags; + ACPI_FUNCTION_TRACE_PTR("ex_create_method", walk_state); /* Create a new method object */ - obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_METHOD); + obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_METHOD); if (!obj_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Save the method's AML pointer and length */ @@ -603,8 +569,10 @@ acpi_ex_create_method ( */ method_flags = (u8) operand[1]->integer.value; - obj_desc->method.method_flags = (u8) (method_flags & ~AML_METHOD_ARG_COUNT); - obj_desc->method.param_count = (u8) (method_flags & AML_METHOD_ARG_COUNT); + obj_desc->method.method_flags = + (u8) (method_flags & ~AML_METHOD_ARG_COUNT); + obj_desc->method.param_count = + (u8) (method_flags & AML_METHOD_ARG_COUNT); /* * Get the concurrency count. If required, a semaphore will be @@ -613,32 +581,28 @@ acpi_ex_create_method ( if (acpi_gbl_all_methods_serialized) { obj_desc->method.concurrency = 1; obj_desc->method.method_flags |= AML_METHOD_SERIALIZED; - } - else if (method_flags & AML_METHOD_SERIALIZED) { + } else if (method_flags & AML_METHOD_SERIALIZED) { /* * ACPI 1.0: Concurrency = 1 * ACPI 2.0: Concurrency = (sync_level (in method declaration) + 1) */ obj_desc->method.concurrency = (u8) - (((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1); - } - else { + (((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1); + } else { obj_desc->method.concurrency = ACPI_INFINITE_CONCURRENCY; } /* Attach the new object to the method Node */ - status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0], - obj_desc, ACPI_TYPE_METHOD); + status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0], + obj_desc, ACPI_TYPE_METHOD); /* Remove local reference to the object */ - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); /* Remove a reference to the operand */ - acpi_ut_remove_reference (operand[1]); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(operand[1]); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index 4f98dce..bc2fa99 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -49,46 +48,27 @@ #include #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exdump") +ACPI_MODULE_NAME("exdump") /* * The following routines are used for debug output only */ #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) - /* Local prototypes */ - #ifdef ACPI_FUTURE_USAGE -static void -acpi_ex_out_string ( - char *title, - char *value); +static void acpi_ex_out_string(char *title, char *value); -static void -acpi_ex_out_pointer ( - char *title, - void *value); +static void acpi_ex_out_pointer(char *title, void *value); -static void -acpi_ex_out_integer ( - char *title, - u32 value); +static void acpi_ex_out_integer(char *title, u32 value); -static void -acpi_ex_out_address ( - char *title, - acpi_physical_address value); +static void acpi_ex_out_address(char *title, acpi_physical_address value); -static void -acpi_ex_dump_reference ( - union acpi_operand_object *obj_desc); +static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc); static void -acpi_ex_dump_package ( - union acpi_operand_object *obj_desc, - u32 level, - u32 index); -#endif /* ACPI_FUTURE_USAGE */ +acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index); +#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * @@ -103,143 +83,140 @@ acpi_ex_dump_package ( * ******************************************************************************/ -void -acpi_ex_dump_operand ( - union acpi_operand_object *obj_desc, - u32 depth) +void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) { - u32 length; - u32 index; - - - ACPI_FUNCTION_NAME ("ex_dump_operand") + u32 length; + u32 index; + ACPI_FUNCTION_NAME("ex_dump_operand") - if (!((ACPI_LV_EXEC & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) { + if (! + ((ACPI_LV_EXEC & acpi_dbg_level) + && (_COMPONENT & acpi_dbg_layer))) { return; } if (!obj_desc) { /* This could be a null element of a package */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Null Object Descriptor\n")); return; } - if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", obj_desc)); - ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC); + if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) { + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p Namespace Node: ", + obj_desc)); + ACPI_DUMP_ENTRY(obj_desc, ACPI_LV_EXEC); return; } - if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "%p is not a node or operand object: [%s]\n", - obj_desc, acpi_ut_get_descriptor_name (obj_desc))); - ACPI_DUMP_BUFFER (obj_desc, sizeof (union acpi_operand_object)); + if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) { + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "%p is not a node or operand object: [%s]\n", + obj_desc, + acpi_ut_get_descriptor_name(obj_desc))); + ACPI_DUMP_BUFFER(obj_desc, sizeof(union acpi_operand_object)); return; } /* obj_desc is a valid object */ if (depth > 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ", - depth, " ", depth, obj_desc)); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%*s[%u] %p ", + depth, " ", depth, obj_desc)); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p ", obj_desc)); } /* Decode object type */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_LOCAL_REFERENCE: switch (obj_desc->reference.opcode) { case AML_DEBUG_OP: - acpi_os_printf ("Reference: Debug\n"); + acpi_os_printf("Reference: Debug\n"); break; - case AML_NAME_OP: - ACPI_DUMP_PATHNAME (obj_desc->reference.object, - "Reference: Name: ", ACPI_LV_INFO, _COMPONENT); - ACPI_DUMP_ENTRY (obj_desc->reference.object, ACPI_LV_INFO); + ACPI_DUMP_PATHNAME(obj_desc->reference.object, + "Reference: Name: ", ACPI_LV_INFO, + _COMPONENT); + ACPI_DUMP_ENTRY(obj_desc->reference.object, + ACPI_LV_INFO); break; - case AML_INDEX_OP: - acpi_os_printf ("Reference: Index %p\n", - obj_desc->reference.object); + acpi_os_printf("Reference: Index %p\n", + obj_desc->reference.object); break; - case AML_REF_OF_OP: - acpi_os_printf ("Reference: (ref_of) %p\n", - obj_desc->reference.object); + acpi_os_printf("Reference: (ref_of) %p\n", + obj_desc->reference.object); break; - case AML_ARG_OP: - acpi_os_printf ("Reference: Arg%d", - obj_desc->reference.offset); + acpi_os_printf("Reference: Arg%d", + obj_desc->reference.offset); - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { /* Value is an Integer */ - acpi_os_printf (" value is [%8.8X%8.8x]", - ACPI_FORMAT_UINT64 (obj_desc->integer.value)); + acpi_os_printf(" value is [%8.8X%8.8x]", + ACPI_FORMAT_UINT64(obj_desc-> + integer. + value)); } - acpi_os_printf ("\n"); + acpi_os_printf("\n"); break; - case AML_LOCAL_OP: - acpi_os_printf ("Reference: Local%d", - obj_desc->reference.offset); + acpi_os_printf("Reference: Local%d", + obj_desc->reference.offset); - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { /* Value is an Integer */ - acpi_os_printf (" value is [%8.8X%8.8x]", - ACPI_FORMAT_UINT64 (obj_desc->integer.value)); + acpi_os_printf(" value is [%8.8X%8.8x]", + ACPI_FORMAT_UINT64(obj_desc-> + integer. + value)); } - acpi_os_printf ("\n"); + acpi_os_printf("\n"); break; - case AML_INT_NAMEPATH_OP: - acpi_os_printf ("Reference.Node->Name %X\n", - obj_desc->reference.node->name.integer); + acpi_os_printf("Reference.Node->Name %X\n", + obj_desc->reference.node->name.integer); break; - default: /* Unknown opcode */ - acpi_os_printf ("Unknown Reference opcode=%X\n", - obj_desc->reference.opcode); + acpi_os_printf("Unknown Reference opcode=%X\n", + obj_desc->reference.opcode); break; } break; - case ACPI_TYPE_BUFFER: - acpi_os_printf ("Buffer len %X @ %p \n", - obj_desc->buffer.length, obj_desc->buffer.pointer); + acpi_os_printf("Buffer len %X @ %p \n", + obj_desc->buffer.length, + obj_desc->buffer.pointer); length = obj_desc->buffer.length; if (length > 64) { @@ -249,178 +226,166 @@ acpi_ex_dump_operand ( /* Debug only -- dump the buffer contents */ if (obj_desc->buffer.pointer) { - acpi_os_printf ("Buffer Contents: "); + acpi_os_printf("Buffer Contents: "); for (index = 0; index < length; index++) { - acpi_os_printf (" %02x", obj_desc->buffer.pointer[index]); + acpi_os_printf(" %02x", + obj_desc->buffer.pointer[index]); } - acpi_os_printf ("\n"); + acpi_os_printf("\n"); } break; - case ACPI_TYPE_INTEGER: - acpi_os_printf ("Integer %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (obj_desc->integer.value)); + acpi_os_printf("Integer %8.8X%8.8X\n", + ACPI_FORMAT_UINT64(obj_desc->integer.value)); break; - case ACPI_TYPE_PACKAGE: - acpi_os_printf ("Package [Len %X] element_array %p\n", - obj_desc->package.count, obj_desc->package.elements); + acpi_os_printf("Package [Len %X] element_array %p\n", + obj_desc->package.count, + obj_desc->package.elements); /* * If elements exist, package element pointer is valid, * and debug_level exceeds 1, dump package's elements. */ if (obj_desc->package.count && - obj_desc->package.elements && - acpi_dbg_level > 1) { - for (index = 0; index < obj_desc->package.count; index++) { - acpi_ex_dump_operand (obj_desc->package.elements[index], depth+1); + obj_desc->package.elements && acpi_dbg_level > 1) { + for (index = 0; index < obj_desc->package.count; + index++) { + acpi_ex_dump_operand(obj_desc->package. + elements[index], + depth + 1); } } break; - case ACPI_TYPE_REGION: - acpi_os_printf ("Region %s (%X)", - acpi_ut_get_region_name (obj_desc->region.space_id), - obj_desc->region.space_id); + acpi_os_printf("Region %s (%X)", + acpi_ut_get_region_name(obj_desc->region. + space_id), + obj_desc->region.space_id); /* * If the address and length have not been evaluated, * don't print them. */ if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) { - acpi_os_printf ("\n"); - } - else { - acpi_os_printf (" base %8.8X%8.8X Length %X\n", - ACPI_FORMAT_UINT64 (obj_desc->region.address), - obj_desc->region.length); + acpi_os_printf("\n"); + } else { + acpi_os_printf(" base %8.8X%8.8X Length %X\n", + ACPI_FORMAT_UINT64(obj_desc->region. + address), + obj_desc->region.length); } break; - case ACPI_TYPE_STRING: - acpi_os_printf ("String length %X @ %p ", - obj_desc->string.length, - obj_desc->string.pointer); + acpi_os_printf("String length %X @ %p ", + obj_desc->string.length, + obj_desc->string.pointer); - acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX); - acpi_os_printf ("\n"); + acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX); + acpi_os_printf("\n"); break; - case ACPI_TYPE_LOCAL_BANK_FIELD: - acpi_os_printf ("bank_field\n"); + acpi_os_printf("bank_field\n"); break; - case ACPI_TYPE_LOCAL_REGION_FIELD: - acpi_os_printf ( - "region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n", - obj_desc->field.bit_length, - obj_desc->field.access_byte_width, - obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK, - obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK, - obj_desc->field.base_byte_offset, - obj_desc->field.start_field_bit_offset); + acpi_os_printf + ("region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n", + obj_desc->field.bit_length, + obj_desc->field.access_byte_width, + obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK, + obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK, + obj_desc->field.base_byte_offset, + obj_desc->field.start_field_bit_offset); - acpi_ex_dump_operand (obj_desc->field.region_obj, depth+1); + acpi_ex_dump_operand(obj_desc->field.region_obj, depth + 1); break; - case ACPI_TYPE_LOCAL_INDEX_FIELD: - acpi_os_printf ("index_field\n"); + acpi_os_printf("index_field\n"); break; - case ACPI_TYPE_BUFFER_FIELD: - acpi_os_printf ( - "buffer_field: %X bits at byte %X bit %X of \n", - obj_desc->buffer_field.bit_length, - obj_desc->buffer_field.base_byte_offset, - obj_desc->buffer_field.start_field_bit_offset); + acpi_os_printf("buffer_field: %X bits at byte %X bit %X of \n", + obj_desc->buffer_field.bit_length, + obj_desc->buffer_field.base_byte_offset, + obj_desc->buffer_field.start_field_bit_offset); if (!obj_desc->buffer_field.buffer_obj) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n")); - } - else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) != - ACPI_TYPE_BUFFER) { - acpi_os_printf ("*not a Buffer* \n"); - } - else { - acpi_ex_dump_operand (obj_desc->buffer_field.buffer_obj, depth+1); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL* \n")); + } else + if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj) + != ACPI_TYPE_BUFFER) { + acpi_os_printf("*not a Buffer* \n"); + } else { + acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj, + depth + 1); } break; - case ACPI_TYPE_EVENT: - acpi_os_printf ("Event\n"); + acpi_os_printf("Event\n"); break; - case ACPI_TYPE_METHOD: - acpi_os_printf ("Method(%X) @ %p:%X\n", - obj_desc->method.param_count, - obj_desc->method.aml_start, - obj_desc->method.aml_length); + acpi_os_printf("Method(%X) @ %p:%X\n", + obj_desc->method.param_count, + obj_desc->method.aml_start, + obj_desc->method.aml_length); break; - case ACPI_TYPE_MUTEX: - acpi_os_printf ("Mutex\n"); + acpi_os_printf("Mutex\n"); break; - case ACPI_TYPE_DEVICE: - acpi_os_printf ("Device\n"); + acpi_os_printf("Device\n"); break; - case ACPI_TYPE_POWER: - acpi_os_printf ("Power\n"); + acpi_os_printf("Power\n"); break; - case ACPI_TYPE_PROCESSOR: - acpi_os_printf ("Processor\n"); + acpi_os_printf("Processor\n"); break; - case ACPI_TYPE_THERMAL: - acpi_os_printf ("Thermal\n"); + acpi_os_printf("Thermal\n"); break; - default: /* Unknown Type */ - acpi_os_printf ("Unknown Type %X\n", ACPI_GET_OBJECT_TYPE (obj_desc)); + acpi_os_printf("Unknown Type %X\n", + ACPI_GET_OBJECT_TYPE(obj_desc)); break; } return; } - /******************************************************************************* * * FUNCTION: acpi_ex_dump_operands @@ -438,20 +403,15 @@ acpi_ex_dump_operand ( ******************************************************************************/ void -acpi_ex_dump_operands ( - union acpi_operand_object **operands, - acpi_interpreter_mode interpreter_mode, - char *ident, - u32 num_levels, - char *note, - char *module_name, - u32 line_number) +acpi_ex_dump_operands(union acpi_operand_object **operands, + acpi_interpreter_mode interpreter_mode, + char *ident, + u32 num_levels, + char *note, char *module_name, u32 line_number) { - acpi_native_uint i; - - - ACPI_FUNCTION_NAME ("ex_dump_operands"); + acpi_native_uint i; + ACPI_FUNCTION_NAME("ex_dump_operands"); if (!ident) { ident = "?"; @@ -461,9 +421,9 @@ acpi_ex_dump_operands ( note = "?"; } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "************* Operand Stack Contents (Opcode [%s], %d Operands)\n", - ident, num_levels)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "************* Operand Stack Contents (Opcode [%s], %d Operands)\n", + ident, num_levels)); if (num_levels == 0) { num_levels = 1; @@ -472,16 +432,15 @@ acpi_ex_dump_operands ( /* Dump the operand stack starting at the top */ for (i = 0; num_levels > 0; i--, num_levels--) { - acpi_ex_dump_operand (operands[i], 0); + acpi_ex_dump_operand(operands[i], 0); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "************* Operand Stack dump from %s(%d), %s\n", - module_name, line_number, note)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "************* Operand Stack dump from %s(%d), %s\n", + module_name, line_number, note)); return; } - #ifdef ACPI_FUTURE_USAGE /******************************************************************************* * @@ -496,44 +455,31 @@ acpi_ex_dump_operands ( * ******************************************************************************/ -static void -acpi_ex_out_string ( - char *title, - char *value) +static void acpi_ex_out_string(char *title, char *value) { - acpi_os_printf ("%20s : %s\n", title, value); + acpi_os_printf("%20s : %s\n", title, value); } -static void -acpi_ex_out_pointer ( - char *title, - void *value) +static void acpi_ex_out_pointer(char *title, void *value) { - acpi_os_printf ("%20s : %p\n", title, value); + acpi_os_printf("%20s : %p\n", title, value); } -static void -acpi_ex_out_integer ( - char *title, - u32 value) +static void acpi_ex_out_integer(char *title, u32 value) { - acpi_os_printf ("%20s : %.2X\n", title, value); + acpi_os_printf("%20s : %.2X\n", title, value); } -static void -acpi_ex_out_address ( - char *title, - acpi_physical_address value) +static void acpi_ex_out_address(char *title, acpi_physical_address value) { #if ACPI_MACHINE_WIDTH == 16 - acpi_os_printf ("%20s : %p\n", title, value); + acpi_os_printf("%20s : %p\n", title, value); #else - acpi_os_printf ("%20s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64 (value)); + acpi_os_printf("%20s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value)); #endif } - /******************************************************************************* * * FUNCTION: acpi_ex_dump_node @@ -545,33 +491,31 @@ acpi_ex_out_address ( * ******************************************************************************/ -void -acpi_ex_dump_node ( - struct acpi_namespace_node *node, - u32 flags) +void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags) { - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_ENTRY(); if (!flags) { - if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) { + if (! + ((ACPI_LV_OBJECTS & acpi_dbg_level) + && (_COMPONENT & acpi_dbg_layer))) { return; } } - acpi_os_printf ("%20s : %4.4s\n", "Name", acpi_ut_get_node_name (node)); - acpi_ex_out_string ("Type", acpi_ut_get_type_name (node->type)); - acpi_ex_out_integer ("Flags", node->flags); - acpi_ex_out_integer ("Owner Id", node->owner_id); - acpi_ex_out_integer ("Reference Count", node->reference_count); - acpi_ex_out_pointer ("Attached Object", acpi_ns_get_attached_object (node)); - acpi_ex_out_pointer ("child_list", node->child); - acpi_ex_out_pointer ("next_peer", node->peer); - acpi_ex_out_pointer ("Parent", acpi_ns_get_parent_node (node)); + acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node)); + acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type)); + acpi_ex_out_integer("Flags", node->flags); + acpi_ex_out_integer("Owner Id", node->owner_id); + acpi_ex_out_integer("Reference Count", node->reference_count); + acpi_ex_out_pointer("Attached Object", + acpi_ns_get_attached_object(node)); + acpi_ex_out_pointer("child_list", node->child); + acpi_ex_out_pointer("next_peer", node->peer); + acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node)); } - /******************************************************************************* * * FUNCTION: acpi_ex_dump_reference @@ -582,32 +526,29 @@ acpi_ex_dump_node ( * ******************************************************************************/ -static void -acpi_ex_dump_reference ( - union acpi_operand_object *obj_desc) +static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc) { - struct acpi_buffer ret_buf; - acpi_status status; - + struct acpi_buffer ret_buf; + acpi_status status; if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) { - acpi_os_printf ("Named Object %p ", obj_desc->reference.node); + acpi_os_printf("Named Object %p ", obj_desc->reference.node); ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; - status = acpi_ns_handle_to_pathname (obj_desc->reference.node, &ret_buf); - if (ACPI_FAILURE (status)) { - acpi_os_printf ("Could not convert name to pathname\n"); + status = + acpi_ns_handle_to_pathname(obj_desc->reference.node, + &ret_buf); + if (ACPI_FAILURE(status)) { + acpi_os_printf("Could not convert name to pathname\n"); + } else { + acpi_os_printf("%s\n", (char *)ret_buf.pointer); + ACPI_MEM_FREE(ret_buf.pointer); } - else { - acpi_os_printf ("%s\n", (char *) ret_buf.pointer); - ACPI_MEM_FREE (ret_buf.pointer); - } - } - else if (obj_desc->reference.object) { - acpi_os_printf ("\nReferenced Object: %p\n", obj_desc->reference.object); + } else if (obj_desc->reference.object) { + acpi_os_printf("\nReferenced Object: %p\n", + obj_desc->reference.object); } } - /******************************************************************************* * * FUNCTION: acpi_ex_dump_package @@ -621,92 +562,85 @@ acpi_ex_dump_reference ( ******************************************************************************/ static void -acpi_ex_dump_package ( - union acpi_operand_object *obj_desc, - u32 level, - u32 index) +acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index) { - u32 i; - + u32 i; /* Indentation and index output */ if (level > 0) { for (i = 0; i < level; i++) { - acpi_os_printf (" "); + acpi_os_printf(" "); } - acpi_os_printf ("[%.2d] ", index); + acpi_os_printf("[%.2d] ", index); } - acpi_os_printf ("%p ", obj_desc); + acpi_os_printf("%p ", obj_desc); /* Null package elements are allowed */ if (!obj_desc) { - acpi_os_printf ("[Null Object]\n"); + acpi_os_printf("[Null Object]\n"); return; } /* Packages may only contain a few object types */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_INTEGER: - acpi_os_printf ("[Integer] = %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (obj_desc->integer.value)); + acpi_os_printf("[Integer] = %8.8X%8.8X\n", + ACPI_FORMAT_UINT64(obj_desc->integer.value)); break; - case ACPI_TYPE_STRING: - acpi_os_printf ("[String] Value: "); + acpi_os_printf("[String] Value: "); for (i = 0; i < obj_desc->string.length; i++) { - acpi_os_printf ("%c", obj_desc->string.pointer[i]); + acpi_os_printf("%c", obj_desc->string.pointer[i]); } - acpi_os_printf ("\n"); + acpi_os_printf("\n"); break; - case ACPI_TYPE_BUFFER: - acpi_os_printf ("[Buffer] Length %.2X = ", obj_desc->buffer.length); + acpi_os_printf("[Buffer] Length %.2X = ", + obj_desc->buffer.length); if (obj_desc->buffer.length) { - acpi_ut_dump_buffer ((u8 *) obj_desc->buffer.pointer, - obj_desc->buffer.length, DB_DWORD_DISPLAY, _COMPONENT); - } - else { - acpi_os_printf ("\n"); + acpi_ut_dump_buffer((u8 *) obj_desc->buffer.pointer, + obj_desc->buffer.length, + DB_DWORD_DISPLAY, _COMPONENT); + } else { + acpi_os_printf("\n"); } break; - case ACPI_TYPE_PACKAGE: - acpi_os_printf ("[Package] Contains %d Elements: \n", - obj_desc->package.count); + acpi_os_printf("[Package] Contains %d Elements: \n", + obj_desc->package.count); for (i = 0; i < obj_desc->package.count; i++) { - acpi_ex_dump_package (obj_desc->package.elements[i], level+1, i); + acpi_ex_dump_package(obj_desc->package.elements[i], + level + 1, i); } break; - case ACPI_TYPE_LOCAL_REFERENCE: - acpi_os_printf ("[Object Reference] "); - acpi_ex_dump_reference (obj_desc); + acpi_os_printf("[Object Reference] "); + acpi_ex_dump_reference(obj_desc); break; - default: - acpi_os_printf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (obj_desc)); + acpi_os_printf("[Unknown Type] %X\n", + ACPI_GET_OBJECT_TYPE(obj_desc)); break; } } - /******************************************************************************* * * FUNCTION: acpi_ex_dump_object_descriptor @@ -719,190 +653,213 @@ acpi_ex_dump_package ( ******************************************************************************/ void -acpi_ex_dump_object_descriptor ( - union acpi_operand_object *obj_desc, - u32 flags) +acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags) { - ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor"); - + ACPI_FUNCTION_TRACE("ex_dump_object_descriptor"); if (!obj_desc) { return_VOID; } if (!flags) { - if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) { + if (! + ((ACPI_LV_OBJECTS & acpi_dbg_level) + && (_COMPONENT & acpi_dbg_layer))) { return_VOID; } } - if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { - acpi_ex_dump_node ((struct acpi_namespace_node *) obj_desc, flags); - acpi_os_printf ("\nAttached Object (%p):\n", - ((struct acpi_namespace_node *) obj_desc)->object); - acpi_ex_dump_object_descriptor ( - ((struct acpi_namespace_node *) obj_desc)->object, flags); + if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) { + acpi_ex_dump_node((struct acpi_namespace_node *)obj_desc, + flags); + acpi_os_printf("\nAttached Object (%p):\n", + ((struct acpi_namespace_node *)obj_desc)-> + object); + acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *) + obj_desc)->object, flags); return_VOID; } - if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { - acpi_os_printf ( - "ex_dump_object_descriptor: %p is not an ACPI operand object: [%s]\n", - obj_desc, acpi_ut_get_descriptor_name (obj_desc)); + if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) { + acpi_os_printf + ("ex_dump_object_descriptor: %p is not an ACPI operand object: [%s]\n", + obj_desc, acpi_ut_get_descriptor_name(obj_desc)); return_VOID; } /* Common Fields */ - acpi_ex_out_string ("Type", acpi_ut_get_object_type_name (obj_desc)); - acpi_ex_out_integer ("Reference Count", obj_desc->common.reference_count); - acpi_ex_out_integer ("Flags", obj_desc->common.flags); + acpi_ex_out_string("Type", acpi_ut_get_object_type_name(obj_desc)); + acpi_ex_out_integer("Reference Count", + obj_desc->common.reference_count); + acpi_ex_out_integer("Flags", obj_desc->common.flags); /* Object-specific Fields */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_INTEGER: - acpi_os_printf ("%20s : %8.8X%8.8X\n", "Value", - ACPI_FORMAT_UINT64 (obj_desc->integer.value)); + acpi_os_printf("%20s : %8.8X%8.8X\n", "Value", + ACPI_FORMAT_UINT64(obj_desc->integer.value)); break; - case ACPI_TYPE_STRING: - acpi_ex_out_integer ("Length", obj_desc->string.length); + acpi_ex_out_integer("Length", obj_desc->string.length); - acpi_os_printf ("%20s : %p ", "Pointer", obj_desc->string.pointer); - acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX); - acpi_os_printf ("\n"); + acpi_os_printf("%20s : %p ", "Pointer", + obj_desc->string.pointer); + acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX); + acpi_os_printf("\n"); break; - case ACPI_TYPE_BUFFER: - acpi_ex_out_integer ("Length", obj_desc->buffer.length); - acpi_ex_out_pointer ("Pointer", obj_desc->buffer.pointer); - ACPI_DUMP_BUFFER (obj_desc->buffer.pointer, obj_desc->buffer.length); + acpi_ex_out_integer("Length", obj_desc->buffer.length); + acpi_ex_out_pointer("Pointer", obj_desc->buffer.pointer); + ACPI_DUMP_BUFFER(obj_desc->buffer.pointer, + obj_desc->buffer.length); break; - case ACPI_TYPE_PACKAGE: - acpi_ex_out_integer ("Flags", obj_desc->package.flags); - acpi_ex_out_integer ("Elements", obj_desc->package.count); - acpi_ex_out_pointer ("Element List", obj_desc->package.elements); + acpi_ex_out_integer("Flags", obj_desc->package.flags); + acpi_ex_out_integer("Elements", obj_desc->package.count); + acpi_ex_out_pointer("Element List", obj_desc->package.elements); /* Dump the package contents */ - acpi_os_printf ("\nPackage Contents:\n"); - acpi_ex_dump_package (obj_desc, 0, 0); + acpi_os_printf("\nPackage Contents:\n"); + acpi_ex_dump_package(obj_desc, 0, 0); break; - case ACPI_TYPE_DEVICE: - acpi_ex_out_pointer ("Handler", obj_desc->device.handler); - acpi_ex_out_pointer ("system_notify", obj_desc->device.system_notify); - acpi_ex_out_pointer ("device_notify", obj_desc->device.device_notify); + acpi_ex_out_pointer("Handler", obj_desc->device.handler); + acpi_ex_out_pointer("system_notify", + obj_desc->device.system_notify); + acpi_ex_out_pointer("device_notify", + obj_desc->device.device_notify); break; - case ACPI_TYPE_EVENT: - acpi_ex_out_pointer ("Semaphore", obj_desc->event.semaphore); + acpi_ex_out_pointer("Semaphore", obj_desc->event.semaphore); break; - case ACPI_TYPE_METHOD: - acpi_ex_out_integer ("param_count", obj_desc->method.param_count); - acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency); - acpi_ex_out_pointer ("Semaphore", obj_desc->method.semaphore); - acpi_ex_out_integer ("owner_id", obj_desc->method.owner_id); - acpi_ex_out_integer ("aml_length", obj_desc->method.aml_length); - acpi_ex_out_pointer ("aml_start", obj_desc->method.aml_start); + acpi_ex_out_integer("param_count", + obj_desc->method.param_count); + acpi_ex_out_integer("Concurrency", + obj_desc->method.concurrency); + acpi_ex_out_pointer("Semaphore", obj_desc->method.semaphore); + acpi_ex_out_integer("owner_id", obj_desc->method.owner_id); + acpi_ex_out_integer("aml_length", obj_desc->method.aml_length); + acpi_ex_out_pointer("aml_start", obj_desc->method.aml_start); break; - case ACPI_TYPE_MUTEX: - acpi_ex_out_integer ("sync_level", obj_desc->mutex.sync_level); - acpi_ex_out_pointer ("owner_thread", obj_desc->mutex.owner_thread); - acpi_ex_out_integer ("acquire_depth", obj_desc->mutex.acquisition_depth); - acpi_ex_out_pointer ("Semaphore", obj_desc->mutex.semaphore); + acpi_ex_out_integer("sync_level", obj_desc->mutex.sync_level); + acpi_ex_out_pointer("owner_thread", + obj_desc->mutex.owner_thread); + acpi_ex_out_integer("acquire_depth", + obj_desc->mutex.acquisition_depth); + acpi_ex_out_pointer("Semaphore", obj_desc->mutex.semaphore); break; - case ACPI_TYPE_REGION: - acpi_ex_out_integer ("space_id", obj_desc->region.space_id); - acpi_ex_out_integer ("Flags", obj_desc->region.flags); - acpi_ex_out_address ("Address", obj_desc->region.address); - acpi_ex_out_integer ("Length", obj_desc->region.length); - acpi_ex_out_pointer ("Handler", obj_desc->region.handler); - acpi_ex_out_pointer ("Next", obj_desc->region.next); + acpi_ex_out_integer("space_id", obj_desc->region.space_id); + acpi_ex_out_integer("Flags", obj_desc->region.flags); + acpi_ex_out_address("Address", obj_desc->region.address); + acpi_ex_out_integer("Length", obj_desc->region.length); + acpi_ex_out_pointer("Handler", obj_desc->region.handler); + acpi_ex_out_pointer("Next", obj_desc->region.next); break; - case ACPI_TYPE_POWER: - acpi_ex_out_integer ("system_level", obj_desc->power_resource.system_level); - acpi_ex_out_integer ("resource_order", obj_desc->power_resource.resource_order); - acpi_ex_out_pointer ("system_notify", obj_desc->power_resource.system_notify); - acpi_ex_out_pointer ("device_notify", obj_desc->power_resource.device_notify); + acpi_ex_out_integer("system_level", + obj_desc->power_resource.system_level); + acpi_ex_out_integer("resource_order", + obj_desc->power_resource.resource_order); + acpi_ex_out_pointer("system_notify", + obj_desc->power_resource.system_notify); + acpi_ex_out_pointer("device_notify", + obj_desc->power_resource.device_notify); break; - case ACPI_TYPE_PROCESSOR: - acpi_ex_out_integer ("Processor ID", obj_desc->processor.proc_id); - acpi_ex_out_integer ("Length", obj_desc->processor.length); - acpi_ex_out_address ("Address", (acpi_physical_address) obj_desc->processor.address); - acpi_ex_out_pointer ("system_notify", obj_desc->processor.system_notify); - acpi_ex_out_pointer ("device_notify", obj_desc->processor.device_notify); - acpi_ex_out_pointer ("Handler", obj_desc->processor.handler); + acpi_ex_out_integer("Processor ID", + obj_desc->processor.proc_id); + acpi_ex_out_integer("Length", obj_desc->processor.length); + acpi_ex_out_address("Address", + (acpi_physical_address) obj_desc->processor. + address); + acpi_ex_out_pointer("system_notify", + obj_desc->processor.system_notify); + acpi_ex_out_pointer("device_notify", + obj_desc->processor.device_notify); + acpi_ex_out_pointer("Handler", obj_desc->processor.handler); break; - case ACPI_TYPE_THERMAL: - acpi_ex_out_pointer ("system_notify", obj_desc->thermal_zone.system_notify); - acpi_ex_out_pointer ("device_notify", obj_desc->thermal_zone.device_notify); - acpi_ex_out_pointer ("Handler", obj_desc->thermal_zone.handler); + acpi_ex_out_pointer("system_notify", + obj_desc->thermal_zone.system_notify); + acpi_ex_out_pointer("device_notify", + obj_desc->thermal_zone.device_notify); + acpi_ex_out_pointer("Handler", obj_desc->thermal_zone.handler); break; - case ACPI_TYPE_BUFFER_FIELD: case ACPI_TYPE_LOCAL_REGION_FIELD: case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - acpi_ex_out_integer ("field_flags", obj_desc->common_field.field_flags); - acpi_ex_out_integer ("access_byte_width",obj_desc->common_field.access_byte_width); - acpi_ex_out_integer ("bit_length", obj_desc->common_field.bit_length); - acpi_ex_out_integer ("fld_bit_offset", obj_desc->common_field.start_field_bit_offset); - acpi_ex_out_integer ("base_byte_offset", obj_desc->common_field.base_byte_offset); - acpi_ex_out_pointer ("parent_node", obj_desc->common_field.node); - - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + acpi_ex_out_integer("field_flags", + obj_desc->common_field.field_flags); + acpi_ex_out_integer("access_byte_width", + obj_desc->common_field.access_byte_width); + acpi_ex_out_integer("bit_length", + obj_desc->common_field.bit_length); + acpi_ex_out_integer("fld_bit_offset", + obj_desc->common_field. + start_field_bit_offset); + acpi_ex_out_integer("base_byte_offset", + obj_desc->common_field.base_byte_offset); + acpi_ex_out_pointer("parent_node", obj_desc->common_field.node); + + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_BUFFER_FIELD: - acpi_ex_out_pointer ("buffer_obj", obj_desc->buffer_field.buffer_obj); + acpi_ex_out_pointer("buffer_obj", + obj_desc->buffer_field.buffer_obj); break; case ACPI_TYPE_LOCAL_REGION_FIELD: - acpi_ex_out_pointer ("region_obj", obj_desc->field.region_obj); + acpi_ex_out_pointer("region_obj", + obj_desc->field.region_obj); break; case ACPI_TYPE_LOCAL_BANK_FIELD: - acpi_ex_out_integer ("Value", obj_desc->bank_field.value); - acpi_ex_out_pointer ("region_obj", obj_desc->bank_field.region_obj); - acpi_ex_out_pointer ("bank_obj", obj_desc->bank_field.bank_obj); + acpi_ex_out_integer("Value", + obj_desc->bank_field.value); + acpi_ex_out_pointer("region_obj", + obj_desc->bank_field.region_obj); + acpi_ex_out_pointer("bank_obj", + obj_desc->bank_field.bank_obj); break; case ACPI_TYPE_LOCAL_INDEX_FIELD: - acpi_ex_out_integer ("Value", obj_desc->index_field.value); - acpi_ex_out_pointer ("Index", obj_desc->index_field.index_obj); - acpi_ex_out_pointer ("Data", obj_desc->index_field.data_obj); + acpi_ex_out_integer("Value", + obj_desc->index_field.value); + acpi_ex_out_pointer("Index", + obj_desc->index_field.index_obj); + acpi_ex_out_pointer("Data", + obj_desc->index_field.data_obj); break; default: @@ -911,53 +868,52 @@ acpi_ex_dump_object_descriptor ( } break; - case ACPI_TYPE_LOCAL_REFERENCE: - acpi_ex_out_integer ("target_type", obj_desc->reference.target_type); - acpi_ex_out_string ("Opcode", (acpi_ps_get_opcode_info ( - obj_desc->reference.opcode))->name); - acpi_ex_out_integer ("Offset", obj_desc->reference.offset); - acpi_ex_out_pointer ("obj_desc", obj_desc->reference.object); - acpi_ex_out_pointer ("Node", obj_desc->reference.node); - acpi_ex_out_pointer ("Where", obj_desc->reference.where); + acpi_ex_out_integer("target_type", + obj_desc->reference.target_type); + acpi_ex_out_string("Opcode", + (acpi_ps_get_opcode_info + (obj_desc->reference.opcode))->name); + acpi_ex_out_integer("Offset", obj_desc->reference.offset); + acpi_ex_out_pointer("obj_desc", obj_desc->reference.object); + acpi_ex_out_pointer("Node", obj_desc->reference.node); + acpi_ex_out_pointer("Where", obj_desc->reference.where); - acpi_ex_dump_reference (obj_desc); + acpi_ex_dump_reference(obj_desc); break; - case ACPI_TYPE_LOCAL_ADDRESS_HANDLER: - acpi_ex_out_integer ("space_id", obj_desc->address_space.space_id); - acpi_ex_out_pointer ("Next", obj_desc->address_space.next); - acpi_ex_out_pointer ("region_list", obj_desc->address_space.region_list); - acpi_ex_out_pointer ("Node", obj_desc->address_space.node); - acpi_ex_out_pointer ("Context", obj_desc->address_space.context); + acpi_ex_out_integer("space_id", + obj_desc->address_space.space_id); + acpi_ex_out_pointer("Next", obj_desc->address_space.next); + acpi_ex_out_pointer("region_list", + obj_desc->address_space.region_list); + acpi_ex_out_pointer("Node", obj_desc->address_space.node); + acpi_ex_out_pointer("Context", obj_desc->address_space.context); break; - case ACPI_TYPE_LOCAL_NOTIFY: - acpi_ex_out_pointer ("Node", obj_desc->notify.node); - acpi_ex_out_pointer ("Context", obj_desc->notify.context); + acpi_ex_out_pointer("Node", obj_desc->notify.node); + acpi_ex_out_pointer("Context", obj_desc->notify.context); break; - case ACPI_TYPE_LOCAL_ALIAS: case ACPI_TYPE_LOCAL_METHOD_ALIAS: case ACPI_TYPE_LOCAL_EXTRA: case ACPI_TYPE_LOCAL_DATA: default: - acpi_os_printf ( - "ex_dump_object_descriptor: Display not implemented for object type %s\n", - acpi_ut_get_object_type_name (obj_desc)); + acpi_os_printf + ("ex_dump_object_descriptor: Display not implemented for object type %s\n", + acpi_ut_get_object_type_name(obj_desc)); break; } return_VOID; } -#endif /* ACPI_FUTURE_USAGE */ +#endif /* ACPI_FUTURE_USAGE */ #endif - diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c index a690c92..ab1ba39 100644 --- a/drivers/acpi/executer/exfield.c +++ b/drivers/acpi/executer/exfield.c @@ -41,15 +41,12 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exfield") - +ACPI_MODULE_NAME("exfield") /******************************************************************************* * @@ -65,67 +62,70 @@ * Buffer, depending on the size of the field. * ******************************************************************************/ - acpi_status -acpi_ex_read_data_from_field ( - struct acpi_walk_state *walk_state, - union acpi_operand_object *obj_desc, - union acpi_operand_object **ret_buffer_desc) +acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, + union acpi_operand_object *obj_desc, + union acpi_operand_object **ret_buffer_desc) { - acpi_status status; - union acpi_operand_object *buffer_desc; - acpi_size length; - void *buffer; - u8 locked; - - - ACPI_FUNCTION_TRACE_PTR ("ex_read_data_from_field", obj_desc); + acpi_status status; + union acpi_operand_object *buffer_desc; + acpi_size length; + void *buffer; + u8 locked; + ACPI_FUNCTION_TRACE_PTR("ex_read_data_from_field", obj_desc); /* Parameter validation */ if (!obj_desc) { - return_ACPI_STATUS (AE_AML_NO_OPERAND); + return_ACPI_STATUS(AE_AML_NO_OPERAND); } if (!ret_buffer_desc) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { /* * If the buffer_field arguments have not been previously evaluated, * evaluate them now and save the results. */ if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { - status = acpi_ds_get_buffer_field_arguments (obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_get_buffer_field_arguments(obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } - } - else if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) && - (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS)) { + } else + if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) + && (obj_desc->field.region_obj->region.space_id == + ACPI_ADR_SPACE_SMBUS)) { /* * This is an SMBus read. We must create a buffer to hold the data * and directly access the region handler. */ - buffer_desc = acpi_ut_create_buffer_object (ACPI_SMBUS_BUFFER_SIZE); + buffer_desc = + acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE); if (!buffer_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Lock entire transaction if requested */ - locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags); + locked = + acpi_ex_acquire_global_lock(obj_desc->common_field. + field_flags); /* * Perform the read. * Note: Smbus protocol value is passed in upper 16-bits of Function */ - status = acpi_ex_access_region (obj_desc, 0, - ACPI_CAST_PTR (acpi_integer, buffer_desc->buffer.pointer), - ACPI_READ | (obj_desc->field.attribute << 16)); - acpi_ex_release_global_lock (locked); + status = acpi_ex_access_region(obj_desc, 0, + ACPI_CAST_PTR(acpi_integer, + buffer_desc-> + buffer.pointer), + ACPI_READ | (obj_desc->field. + attribute << 16)); + acpi_ex_release_global_lock(locked); goto exit; } @@ -139,22 +139,22 @@ acpi_ex_read_data_from_field ( * * Note: Field.length is in bits. */ - length = (acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->field.bit_length); + length = + (acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length); if (length > acpi_gbl_integer_byte_width) { /* Field is too large for an Integer, create a Buffer instead */ - buffer_desc = acpi_ut_create_buffer_object (length); + buffer_desc = acpi_ut_create_buffer_object(length); if (!buffer_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } buffer = buffer_desc->buffer.pointer; - } - else { + } else { /* Field will fit within an Integer (normal case) */ - buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + buffer_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!buffer_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } length = acpi_gbl_integer_byte_width; @@ -162,37 +162,36 @@ acpi_ex_read_data_from_field ( buffer = &buffer_desc->integer.value; } - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "field_read [TO]: Obj %p, Type %X, Buf %p, byte_len %X\n", - obj_desc, ACPI_GET_OBJECT_TYPE (obj_desc), buffer, (u32) length)); - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "field_read [FROM]: bit_len %X, bit_off %X, byte_off %X\n", - obj_desc->common_field.bit_length, - obj_desc->common_field.start_field_bit_offset, - obj_desc->common_field.base_byte_offset)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "field_read [TO]: Obj %p, Type %X, Buf %p, byte_len %X\n", + obj_desc, ACPI_GET_OBJECT_TYPE(obj_desc), buffer, + (u32) length)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "field_read [FROM]: bit_len %X, bit_off %X, byte_off %X\n", + obj_desc->common_field.bit_length, + obj_desc->common_field.start_field_bit_offset, + obj_desc->common_field.base_byte_offset)); /* Lock entire transaction if requested */ - locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags); + locked = + acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags); /* Read from the field */ - status = acpi_ex_extract_from_field (obj_desc, buffer, (u32) length); - acpi_ex_release_global_lock (locked); - + status = acpi_ex_extract_from_field(obj_desc, buffer, (u32) length); + acpi_ex_release_global_lock(locked); -exit: - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (buffer_desc); - } - else { + exit: + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference(buffer_desc); + } else { *ret_buffer_desc = buffer_desc; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_write_data_to_field @@ -208,97 +207,96 @@ exit: ******************************************************************************/ acpi_status -acpi_ex_write_data_to_field ( - union acpi_operand_object *source_desc, - union acpi_operand_object *obj_desc, - union acpi_operand_object **result_desc) +acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, + union acpi_operand_object *obj_desc, + union acpi_operand_object **result_desc) { - acpi_status status; - u32 length; - u32 required_length; - void *buffer; - void *new_buffer; - u8 locked; - union acpi_operand_object *buffer_desc; - - - ACPI_FUNCTION_TRACE_PTR ("ex_write_data_to_field", obj_desc); + acpi_status status; + u32 length; + u32 required_length; + void *buffer; + void *new_buffer; + u8 locked; + union acpi_operand_object *buffer_desc; + ACPI_FUNCTION_TRACE_PTR("ex_write_data_to_field", obj_desc); /* Parameter validation */ if (!source_desc || !obj_desc) { - return_ACPI_STATUS (AE_AML_NO_OPERAND); + return_ACPI_STATUS(AE_AML_NO_OPERAND); } - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { /* * If the buffer_field arguments have not been previously evaluated, * evaluate them now and save the results. */ if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { - status = acpi_ds_get_buffer_field_arguments (obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_get_buffer_field_arguments(obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } - } - else if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) && - (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS)) { + } else + if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) + && (obj_desc->field.region_obj->region.space_id == + ACPI_ADR_SPACE_SMBUS)) { /* * This is an SMBus write. We will bypass the entire field mechanism * and handoff the buffer directly to the handler. * * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE). */ - if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) { - ACPI_REPORT_ERROR (("SMBus write requires Buffer, found type %s\n", - acpi_ut_get_object_type_name (source_desc))); + if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { + ACPI_REPORT_ERROR(("SMBus write requires Buffer, found type %s\n", acpi_ut_get_object_type_name(source_desc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) { - ACPI_REPORT_ERROR (( - "SMBus write requires Buffer of length %X, found length %X\n", - ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length)); + ACPI_REPORT_ERROR(("SMBus write requires Buffer of length %X, found length %X\n", ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length)); - return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + return_ACPI_STATUS(AE_AML_BUFFER_LIMIT); } - buffer_desc = acpi_ut_create_buffer_object (ACPI_SMBUS_BUFFER_SIZE); + buffer_desc = + acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE); if (!buffer_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } buffer = buffer_desc->buffer.pointer; - ACPI_MEMCPY (buffer, source_desc->buffer.pointer, - ACPI_SMBUS_BUFFER_SIZE); + ACPI_MEMCPY(buffer, source_desc->buffer.pointer, + ACPI_SMBUS_BUFFER_SIZE); /* Lock entire transaction if requested */ - locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags); + locked = + acpi_ex_acquire_global_lock(obj_desc->common_field. + field_flags); /* * Perform the write (returns status and perhaps data in the * same buffer) * Note: SMBus protocol type is passed in upper 16-bits of Function. */ - status = acpi_ex_access_region (obj_desc, 0, - (acpi_integer *) buffer, - ACPI_WRITE | (obj_desc->field.attribute << 16)); - acpi_ex_release_global_lock (locked); + status = acpi_ex_access_region(obj_desc, 0, + (acpi_integer *) buffer, + ACPI_WRITE | (obj_desc->field. + attribute << 16)); + acpi_ex_release_global_lock(locked); *result_desc = buffer_desc; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Get a pointer to the data to be written */ - switch (ACPI_GET_OBJECT_TYPE (source_desc)) { + switch (ACPI_GET_OBJECT_TYPE(source_desc)) { case ACPI_TYPE_INTEGER: buffer = &source_desc->integer.value; - length = sizeof (source_desc->integer.value); + length = sizeof(source_desc->integer.value); break; case ACPI_TYPE_BUFFER: @@ -312,7 +310,7 @@ acpi_ex_write_data_to_field ( break; default: - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* @@ -322,15 +320,15 @@ acpi_ex_write_data_to_field ( * the ACPI specification. */ new_buffer = NULL; - required_length = ACPI_ROUND_BITS_UP_TO_BYTES ( - obj_desc->common_field.bit_length); + required_length = + ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length); if (length < required_length) { /* We need to create a new buffer */ - new_buffer = ACPI_MEM_CALLOCATE (required_length); + new_buffer = ACPI_MEM_CALLOCATE(required_length); if (!new_buffer) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* @@ -338,40 +336,42 @@ acpi_ex_write_data_to_field ( * at Byte zero. All unused (upper) bytes of the * buffer will be 0. */ - ACPI_MEMCPY ((char *) new_buffer, (char *) buffer, length); + ACPI_MEMCPY((char *)new_buffer, (char *)buffer, length); buffer = new_buffer; length = required_length; } - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "field_write [FROM]: Obj %p (%s:%X), Buf %p, byte_len %X\n", - source_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (source_desc)), - ACPI_GET_OBJECT_TYPE (source_desc), buffer, length)); - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "field_write [TO]: Obj %p (%s:%X), bit_len %X, bit_off %X, byte_off %X\n", - obj_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc)), - ACPI_GET_OBJECT_TYPE (obj_desc), - obj_desc->common_field.bit_length, - obj_desc->common_field.start_field_bit_offset, - obj_desc->common_field.base_byte_offset)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "field_write [FROM]: Obj %p (%s:%X), Buf %p, byte_len %X\n", + source_desc, + acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE + (source_desc)), + ACPI_GET_OBJECT_TYPE(source_desc), buffer, length)); + + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "field_write [TO]: Obj %p (%s:%X), bit_len %X, bit_off %X, byte_off %X\n", + obj_desc, + acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)), + ACPI_GET_OBJECT_TYPE(obj_desc), + obj_desc->common_field.bit_length, + obj_desc->common_field.start_field_bit_offset, + obj_desc->common_field.base_byte_offset)); /* Lock entire transaction if requested */ - locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags); + locked = + acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags); /* Write to the field */ - status = acpi_ex_insert_into_field (obj_desc, buffer, length); - acpi_ex_release_global_lock (locked); + status = acpi_ex_insert_into_field(obj_desc, buffer, length); + acpi_ex_release_global_lock(locked); /* Free temporary buffer if we used one */ if (new_buffer) { - ACPI_MEM_FREE (new_buffer); + ACPI_MEM_FREE(new_buffer); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c index 3c2f89e..ba6e088 100644 --- a/drivers/acpi/executer/exfldio.c +++ b/drivers/acpi/executer/exfldio.c @@ -41,36 +41,28 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exfldio") +ACPI_MODULE_NAME("exfldio") /* Local prototypes */ - static acpi_status -acpi_ex_field_datum_io ( - union acpi_operand_object *obj_desc, - u32 field_datum_byte_offset, - acpi_integer *value, - u32 read_write); +acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, + u32 field_datum_byte_offset, + acpi_integer * value, u32 read_write); static u8 -acpi_ex_register_overflow ( - union acpi_operand_object *obj_desc, - acpi_integer value); +acpi_ex_register_overflow(union acpi_operand_object *obj_desc, + acpi_integer value); static acpi_status -acpi_ex_setup_region ( - union acpi_operand_object *obj_desc, - u32 field_datum_byte_offset); - +acpi_ex_setup_region(union acpi_operand_object *obj_desc, + u32 field_datum_byte_offset); /******************************************************************************* * @@ -89,27 +81,25 @@ acpi_ex_setup_region ( ******************************************************************************/ static acpi_status -acpi_ex_setup_region ( - union acpi_operand_object *obj_desc, - u32 field_datum_byte_offset) +acpi_ex_setup_region(union acpi_operand_object *obj_desc, + u32 field_datum_byte_offset) { - acpi_status status = AE_OK; - union acpi_operand_object *rgn_desc; - - - ACPI_FUNCTION_TRACE_U32 ("ex_setup_region", field_datum_byte_offset); + acpi_status status = AE_OK; + union acpi_operand_object *rgn_desc; + ACPI_FUNCTION_TRACE_U32("ex_setup_region", field_datum_byte_offset); rgn_desc = obj_desc->common_field.region_obj; /* We must have a valid region */ - if (ACPI_GET_OBJECT_TYPE (rgn_desc) != ACPI_TYPE_REGION) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed Region, found type %X (%s)\n", - ACPI_GET_OBJECT_TYPE (rgn_desc), - acpi_ut_get_object_type_name (rgn_desc))); + if (ACPI_GET_OBJECT_TYPE(rgn_desc) != ACPI_TYPE_REGION) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Needed Region, found type %X (%s)\n", + ACPI_GET_OBJECT_TYPE(rgn_desc), + acpi_ut_get_object_type_name(rgn_desc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* @@ -117,26 +107,25 @@ acpi_ex_setup_region ( * evaluate them now and save the results. */ if (!(rgn_desc->common.flags & AOPOBJ_DATA_VALID)) { - status = acpi_ds_get_region_arguments (rgn_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_get_region_arguments(rgn_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } if (rgn_desc->region.space_id == ACPI_ADR_SPACE_SMBUS) { /* SMBus has a non-linear address space */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - #ifdef ACPI_UNDER_DEVELOPMENT /* * If the Field access is any_acc, we can now compute the optimal * access (because we know know the length of the parent region) */ if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } #endif @@ -147,56 +136,64 @@ acpi_ex_setup_region ( * (Region length is specified in bytes) */ if (rgn_desc->region.length < (obj_desc->common_field.base_byte_offset + - field_datum_byte_offset + - obj_desc->common_field.access_byte_width)) { + field_datum_byte_offset + + obj_desc->common_field. + access_byte_width)) { if (acpi_gbl_enable_interpreter_slack) { /* * Slack mode only: We will go ahead and allow access to this * field if it is within the region length rounded up to the next * access width boundary. */ - if (ACPI_ROUND_UP (rgn_desc->region.length, - obj_desc->common_field.access_byte_width) >= - (obj_desc->common_field.base_byte_offset + - (acpi_native_uint) obj_desc->common_field.access_byte_width + - field_datum_byte_offset)) { - return_ACPI_STATUS (AE_OK); + if (ACPI_ROUND_UP(rgn_desc->region.length, + obj_desc->common_field. + access_byte_width) >= + (obj_desc->common_field.base_byte_offset + + (acpi_native_uint) obj_desc->common_field. + access_byte_width + field_datum_byte_offset)) { + return_ACPI_STATUS(AE_OK); } } - if (rgn_desc->region.length < obj_desc->common_field.access_byte_width) { + if (rgn_desc->region.length < + obj_desc->common_field.access_byte_width) { /* * This is the case where the access_type (acc_word, etc.) is wider * than the region itself. For example, a region of length one * byte, and a field with Dword access specified. */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", - acpi_ut_get_node_name (obj_desc->common_field.node), - obj_desc->common_field.access_byte_width, - acpi_ut_get_node_name (rgn_desc->region.node), - rgn_desc->region.length)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", + acpi_ut_get_node_name(obj_desc-> + common_field. + node), + obj_desc->common_field. + access_byte_width, + acpi_ut_get_node_name(rgn_desc-> + region.node), + rgn_desc->region.length)); } /* * Offset rounded up to next multiple of field width * exceeds region length, indicate an error */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n", - acpi_ut_get_node_name (obj_desc->common_field.node), - obj_desc->common_field.base_byte_offset, - field_datum_byte_offset, obj_desc->common_field.access_byte_width, - acpi_ut_get_node_name (rgn_desc->region.node), - rgn_desc->region.length)); - - return_ACPI_STATUS (AE_AML_REGION_LIMIT); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n", + acpi_ut_get_node_name(obj_desc->common_field. + node), + obj_desc->common_field.base_byte_offset, + field_datum_byte_offset, + obj_desc->common_field.access_byte_width, + acpi_ut_get_node_name(rgn_desc->region.node), + rgn_desc->region.length)); + + return_ACPI_STATUS(AE_AML_REGION_LIMIT); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ex_access_region @@ -216,27 +213,23 @@ acpi_ex_setup_region ( ******************************************************************************/ acpi_status -acpi_ex_access_region ( - union acpi_operand_object *obj_desc, - u32 field_datum_byte_offset, - acpi_integer *value, - u32 function) +acpi_ex_access_region(union acpi_operand_object *obj_desc, + u32 field_datum_byte_offset, + acpi_integer * value, u32 function) { - acpi_status status; - union acpi_operand_object *rgn_desc; - acpi_physical_address address; - - - ACPI_FUNCTION_TRACE ("ex_access_region"); + acpi_status status; + union acpi_operand_object *rgn_desc; + acpi_physical_address address; + ACPI_FUNCTION_TRACE("ex_access_region"); /* * Ensure that the region operands are fully evaluated and verify * the validity of the request */ - status = acpi_ex_setup_region (obj_desc, field_datum_byte_offset); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_setup_region(obj_desc, field_datum_byte_offset); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -248,50 +241,53 @@ acpi_ex_access_region ( */ rgn_desc = obj_desc->common_field.region_obj; address = rgn_desc->region.address + - obj_desc->common_field.base_byte_offset + - field_datum_byte_offset; + obj_desc->common_field.base_byte_offset + field_datum_byte_offset; if ((function & ACPI_IO_MASK) == ACPI_READ) { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]")); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]")); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "[READ]")); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "[WRITE]")); } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD, - " Region [%s:%X], Width %X, byte_base %X, Offset %X at %8.8X%8.8X\n", - acpi_ut_get_region_name (rgn_desc->region.space_id), - rgn_desc->region.space_id, - obj_desc->common_field.access_byte_width, - obj_desc->common_field.base_byte_offset, - field_datum_byte_offset, - ACPI_FORMAT_UINT64 (address))); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_BFIELD, + " Region [%s:%X], Width %X, byte_base %X, Offset %X at %8.8X%8.8X\n", + acpi_ut_get_region_name(rgn_desc->region. + space_id), + rgn_desc->region.space_id, + obj_desc->common_field.access_byte_width, + obj_desc->common_field.base_byte_offset, + field_datum_byte_offset, + ACPI_FORMAT_UINT64(address))); /* Invoke the appropriate address_space/op_region handler */ - status = acpi_ev_address_space_dispatch (rgn_desc, function, - address, - ACPI_MUL_8 (obj_desc->common_field.access_byte_width), value); + status = acpi_ev_address_space_dispatch(rgn_desc, function, + address, + ACPI_MUL_8(obj_desc-> + common_field. + access_byte_width), + value); - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { if (status == AE_NOT_IMPLEMENTED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Region %s(%X) not implemented\n", - acpi_ut_get_region_name (rgn_desc->region.space_id), - rgn_desc->region.space_id)); - } - else if (status == AE_NOT_EXIST) { - ACPI_REPORT_ERROR (( - "Region %s(%X) has no handler\n", - acpi_ut_get_region_name (rgn_desc->region.space_id), - rgn_desc->region.space_id)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Region %s(%X) not implemented\n", + acpi_ut_get_region_name(rgn_desc-> + region. + space_id), + rgn_desc->region.space_id)); + } else if (status == AE_NOT_EXIST) { + ACPI_REPORT_ERROR(("Region %s(%X) has no handler\n", + acpi_ut_get_region_name(rgn_desc-> + region. + space_id), + rgn_desc->region.space_id)); } } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_register_overflow @@ -310,9 +306,8 @@ acpi_ex_access_region ( ******************************************************************************/ static u8 -acpi_ex_register_overflow ( - union acpi_operand_object *obj_desc, - acpi_integer value) +acpi_ex_register_overflow(union acpi_operand_object *obj_desc, + acpi_integer value) { if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) { @@ -336,7 +331,6 @@ acpi_ex_register_overflow ( return (FALSE); } - /******************************************************************************* * * FUNCTION: acpi_ex_field_datum_io @@ -356,18 +350,14 @@ acpi_ex_register_overflow ( ******************************************************************************/ static acpi_status -acpi_ex_field_datum_io ( - union acpi_operand_object *obj_desc, - u32 field_datum_byte_offset, - acpi_integer *value, - u32 read_write) +acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, + u32 field_datum_byte_offset, + acpi_integer * value, u32 read_write) { - acpi_status status; - acpi_integer local_value; - - - ACPI_FUNCTION_TRACE_U32 ("ex_field_datum_io", field_datum_byte_offset); + acpi_status status; + acpi_integer local_value; + ACPI_FUNCTION_TRACE_U32("ex_field_datum_io", field_datum_byte_offset); if (read_write == ACPI_READ) { if (!value) { @@ -392,16 +382,16 @@ acpi_ex_field_datum_io ( * index_field - Write to an Index Register, then read/write from/to a * Data Register */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_BUFFER_FIELD: /* * If the buffer_field arguments have not been previously evaluated, * evaluate them now and save the results. */ if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { - status = acpi_ds_get_buffer_field_arguments (obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_get_buffer_field_arguments(obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -410,47 +400,50 @@ acpi_ex_field_datum_io ( * Copy the data from the source buffer. * Length is the field width in bytes. */ - ACPI_MEMCPY (value, - (obj_desc->buffer_field.buffer_obj)->buffer.pointer + - obj_desc->buffer_field.base_byte_offset + - field_datum_byte_offset, - obj_desc->common_field.access_byte_width); - } - else { + ACPI_MEMCPY(value, + (obj_desc->buffer_field.buffer_obj)->buffer. + pointer + + obj_desc->buffer_field.base_byte_offset + + field_datum_byte_offset, + obj_desc->common_field.access_byte_width); + } else { /* * Copy the data to the target buffer. * Length is the field width in bytes. */ - ACPI_MEMCPY ((obj_desc->buffer_field.buffer_obj)->buffer.pointer + - obj_desc->buffer_field.base_byte_offset + - field_datum_byte_offset, - value, obj_desc->common_field.access_byte_width); + ACPI_MEMCPY((obj_desc->buffer_field.buffer_obj)->buffer. + pointer + + obj_desc->buffer_field.base_byte_offset + + field_datum_byte_offset, value, + obj_desc->common_field.access_byte_width); } status = AE_OK; break; - case ACPI_TYPE_LOCAL_BANK_FIELD: /* * Ensure that the bank_value is not beyond the capacity of * the register */ - if (acpi_ex_register_overflow (obj_desc->bank_field.bank_obj, - (acpi_integer) obj_desc->bank_field.value)) { - return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); + if (acpi_ex_register_overflow(obj_desc->bank_field.bank_obj, + (acpi_integer) obj_desc-> + bank_field.value)) { + return_ACPI_STATUS(AE_AML_REGISTER_LIMIT); } /* * For bank_fields, we must write the bank_value to the bank_register * (itself a region_field) before we can access the data. */ - status = acpi_ex_insert_into_field (obj_desc->bank_field.bank_obj, - &obj_desc->bank_field.value, - sizeof (obj_desc->bank_field.value)); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ex_insert_into_field(obj_desc->bank_field.bank_obj, + &obj_desc->bank_field.value, + sizeof(obj_desc->bank_field. + value)); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -460,90 +453,92 @@ acpi_ex_field_datum_io ( /*lint -fallthrough */ - case ACPI_TYPE_LOCAL_REGION_FIELD: /* * For simple region_fields, we just directly access the owning * Operation Region. */ - status = acpi_ex_access_region (obj_desc, field_datum_byte_offset, value, - read_write); + status = + acpi_ex_access_region(obj_desc, field_datum_byte_offset, + value, read_write); break; - case ACPI_TYPE_LOCAL_INDEX_FIELD: - /* * Ensure that the index_value is not beyond the capacity of * the register */ - if (acpi_ex_register_overflow (obj_desc->index_field.index_obj, - (acpi_integer) obj_desc->index_field.value)) { - return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); + if (acpi_ex_register_overflow(obj_desc->index_field.index_obj, + (acpi_integer) obj_desc-> + index_field.value)) { + return_ACPI_STATUS(AE_AML_REGISTER_LIMIT); } /* Write the index value to the index_register (itself a region_field) */ field_datum_byte_offset += obj_desc->index_field.value; - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Write to Index Register: Value %8.8X\n", - field_datum_byte_offset)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Write to Index Register: Value %8.8X\n", + field_datum_byte_offset)); - status = acpi_ex_insert_into_field (obj_desc->index_field.index_obj, - &field_datum_byte_offset, - sizeof (field_datum_byte_offset)); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ex_insert_into_field(obj_desc->index_field.index_obj, + &field_datum_byte_offset, + sizeof(field_datum_byte_offset)); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "I/O to Data Register: value_ptr %p\n", - value)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "I/O to Data Register: value_ptr %p\n", + value)); if (read_write == ACPI_READ) { /* Read the datum from the data_register */ - status = acpi_ex_extract_from_field (obj_desc->index_field.data_obj, - value, sizeof (acpi_integer)); - } - else { + status = + acpi_ex_extract_from_field(obj_desc->index_field. + data_obj, value, + sizeof(acpi_integer)); + } else { /* Write the datum to the data_register */ - status = acpi_ex_insert_into_field (obj_desc->index_field.data_obj, - value, sizeof (acpi_integer)); + status = + acpi_ex_insert_into_field(obj_desc->index_field. + data_obj, value, + sizeof(acpi_integer)); } break; - default: - ACPI_REPORT_ERROR (("Wrong object type in field I/O %X\n", - ACPI_GET_OBJECT_TYPE (obj_desc))); + ACPI_REPORT_ERROR(("Wrong object type in field I/O %X\n", + ACPI_GET_OBJECT_TYPE(obj_desc))); status = AE_AML_INTERNAL; break; } - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { if (read_write == ACPI_READ) { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Value Read %8.8X%8.8X, Width %d\n", - ACPI_FORMAT_UINT64 (*value), - obj_desc->common_field.access_byte_width)); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Value Written %8.8X%8.8X, Width %d\n", - ACPI_FORMAT_UINT64 (*value), - obj_desc->common_field.access_byte_width)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Value Read %8.8X%8.8X, Width %d\n", + ACPI_FORMAT_UINT64(*value), + obj_desc->common_field. + access_byte_width)); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Value Written %8.8X%8.8X, Width %d\n", + ACPI_FORMAT_UINT64(*value), + obj_desc->common_field. + access_byte_width)); } } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_write_with_update_rule @@ -560,19 +555,16 @@ acpi_ex_field_datum_io ( ******************************************************************************/ acpi_status -acpi_ex_write_with_update_rule ( - union acpi_operand_object *obj_desc, - acpi_integer mask, - acpi_integer field_value, - u32 field_datum_byte_offset) +acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc, + acpi_integer mask, + acpi_integer field_value, + u32 field_datum_byte_offset) { - acpi_status status = AE_OK; - acpi_integer merged_value; - acpi_integer current_value; - - - ACPI_FUNCTION_TRACE_U32 ("ex_write_with_update_rule", mask); + acpi_status status = AE_OK; + acpi_integer merged_value; + acpi_integer current_value; + ACPI_FUNCTION_TRACE_U32("ex_write_with_update_rule", mask); /* Start with the new bits */ @@ -583,22 +575,27 @@ acpi_ex_write_with_update_rule ( if (mask != ACPI_INTEGER_MAX) { /* Decode the update rule */ - switch (obj_desc->common_field.field_flags & AML_FIELD_UPDATE_RULE_MASK) { + switch (obj_desc->common_field. + field_flags & AML_FIELD_UPDATE_RULE_MASK) { case AML_FIELD_UPDATE_PRESERVE: /* * Check if update rule needs to be applied (not if mask is all * ones) The left shift drops the bits we want to ignore. */ - if ((~mask << (ACPI_MUL_8 (sizeof (mask)) - - ACPI_MUL_8 (obj_desc->common_field.access_byte_width))) != 0) { + if ((~mask << (ACPI_MUL_8(sizeof(mask)) - + ACPI_MUL_8(obj_desc->common_field. + access_byte_width))) != 0) { /* * Read the current contents of the byte/word/dword containing * the field, and merge with the new field value. */ - status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset, - ¤t_value, ACPI_READ); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ex_field_datum_io(obj_desc, + field_datum_byte_offset, + ¤t_value, + ACPI_READ); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } merged_value |= (current_value & ~mask); @@ -621,30 +618,31 @@ acpi_ex_write_with_update_rule ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "write_with_update_rule: Unknown update_rule setting: %X\n", - (obj_desc->common_field.field_flags & AML_FIELD_UPDATE_RULE_MASK))); - return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "write_with_update_rule: Unknown update_rule setting: %X\n", + (obj_desc->common_field. + field_flags & + AML_FIELD_UPDATE_RULE_MASK))); + return_ACPI_STATUS(AE_AML_OPERAND_VALUE); } } - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Mask %8.8X%8.8X, datum_offset %X, Width %X, Value %8.8X%8.8X, merged_value %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (mask), - field_datum_byte_offset, - obj_desc->common_field.access_byte_width, - ACPI_FORMAT_UINT64 (field_value), - ACPI_FORMAT_UINT64 (merged_value))); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Mask %8.8X%8.8X, datum_offset %X, Width %X, Value %8.8X%8.8X, merged_value %8.8X%8.8X\n", + ACPI_FORMAT_UINT64(mask), + field_datum_byte_offset, + obj_desc->common_field.access_byte_width, + ACPI_FORMAT_UINT64(field_value), + ACPI_FORMAT_UINT64(merged_value))); /* Write the merged value */ - status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset, - &merged_value, ACPI_WRITE); + status = acpi_ex_field_datum_io(obj_desc, field_datum_byte_offset, + &merged_value, ACPI_WRITE); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_extract_from_field @@ -660,54 +658,54 @@ acpi_ex_write_with_update_rule ( ******************************************************************************/ acpi_status -acpi_ex_extract_from_field ( - union acpi_operand_object *obj_desc, - void *buffer, - u32 buffer_length) +acpi_ex_extract_from_field(union acpi_operand_object *obj_desc, + void *buffer, u32 buffer_length) { - acpi_status status; - acpi_integer raw_datum; - acpi_integer merged_datum; - u32 field_offset = 0; - u32 buffer_offset = 0; - u32 buffer_tail_bits; - u32 datum_count; - u32 field_datum_count; - u32 i; - - - ACPI_FUNCTION_TRACE ("ex_extract_from_field"); - + acpi_status status; + acpi_integer raw_datum; + acpi_integer merged_datum; + u32 field_offset = 0; + u32 buffer_offset = 0; + u32 buffer_tail_bits; + u32 datum_count; + u32 field_datum_count; + u32 i; + + ACPI_FUNCTION_TRACE("ex_extract_from_field"); /* Validate target buffer and clear it */ - if (buffer_length < ACPI_ROUND_BITS_UP_TO_BYTES ( - obj_desc->common_field.bit_length)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Field size %X (bits) is too large for buffer (%X)\n", - obj_desc->common_field.bit_length, buffer_length)); + if (buffer_length < + ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Field size %X (bits) is too large for buffer (%X)\n", + obj_desc->common_field.bit_length, + buffer_length)); - return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + return_ACPI_STATUS(AE_BUFFER_OVERFLOW); } - ACPI_MEMSET (buffer, 0, buffer_length); + ACPI_MEMSET(buffer, 0, buffer_length); /* Compute the number of datums (access width data items) */ - datum_count = ACPI_ROUND_UP_TO ( - obj_desc->common_field.bit_length, - obj_desc->common_field.access_bit_width); - field_datum_count = ACPI_ROUND_UP_TO ( - obj_desc->common_field.bit_length + - obj_desc->common_field.start_field_bit_offset, - obj_desc->common_field.access_bit_width); + datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length, + obj_desc->common_field.access_bit_width); + field_datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length + + obj_desc->common_field. + start_field_bit_offset, + obj_desc->common_field. + access_bit_width); /* Priming read from the field */ - status = acpi_ex_field_datum_io (obj_desc, field_offset, &raw_datum, ACPI_READ); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ex_field_datum_io(obj_desc, field_offset, &raw_datum, + ACPI_READ); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - merged_datum = raw_datum >> obj_desc->common_field.start_field_bit_offset; + merged_datum = + raw_datum >> obj_desc->common_field.start_field_bit_offset; /* Read the rest of the field */ @@ -715,17 +713,17 @@ acpi_ex_extract_from_field ( /* Get next input datum from the field */ field_offset += obj_desc->common_field.access_byte_width; - status = acpi_ex_field_datum_io (obj_desc, field_offset, - &raw_datum, ACPI_READ); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_field_datum_io(obj_desc, field_offset, + &raw_datum, ACPI_READ); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Merge with previous datum if necessary */ merged_datum |= raw_datum << - (obj_desc->common_field.access_bit_width - - obj_desc->common_field.start_field_bit_offset); + (obj_desc->common_field.access_bit_width - + obj_desc->common_field.start_field_bit_offset); if (i == datum_count) { break; @@ -733,32 +731,32 @@ acpi_ex_extract_from_field ( /* Write merged datum to target buffer */ - ACPI_MEMCPY (((char *) buffer) + buffer_offset, &merged_datum, - ACPI_MIN(obj_desc->common_field.access_byte_width, - buffer_length - buffer_offset)); + ACPI_MEMCPY(((char *)buffer) + buffer_offset, &merged_datum, + ACPI_MIN(obj_desc->common_field.access_byte_width, + buffer_length - buffer_offset)); buffer_offset += obj_desc->common_field.access_byte_width; - merged_datum = raw_datum >> obj_desc->common_field.start_field_bit_offset; + merged_datum = + raw_datum >> obj_desc->common_field.start_field_bit_offset; } /* Mask off any extra bits in the last datum */ buffer_tail_bits = obj_desc->common_field.bit_length % - obj_desc->common_field.access_bit_width; + obj_desc->common_field.access_bit_width; if (buffer_tail_bits) { - merged_datum &= ACPI_MASK_BITS_ABOVE (buffer_tail_bits); + merged_datum &= ACPI_MASK_BITS_ABOVE(buffer_tail_bits); } /* Write the last datum to the buffer */ - ACPI_MEMCPY (((char *) buffer) + buffer_offset, &merged_datum, - ACPI_MIN(obj_desc->common_field.access_byte_width, - buffer_length - buffer_offset)); + ACPI_MEMCPY(((char *)buffer) + buffer_offset, &merged_datum, + ACPI_MIN(obj_desc->common_field.access_byte_width, + buffer_length - buffer_offset)); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ex_insert_into_field @@ -774,53 +772,54 @@ acpi_ex_extract_from_field ( ******************************************************************************/ acpi_status -acpi_ex_insert_into_field ( - union acpi_operand_object *obj_desc, - void *buffer, - u32 buffer_length) +acpi_ex_insert_into_field(union acpi_operand_object *obj_desc, + void *buffer, u32 buffer_length) { - acpi_status status; - acpi_integer mask; - acpi_integer merged_datum; - acpi_integer raw_datum = 0; - u32 field_offset = 0; - u32 buffer_offset = 0; - u32 buffer_tail_bits; - u32 datum_count; - u32 field_datum_count; - u32 i; - - - ACPI_FUNCTION_TRACE ("ex_insert_into_field"); - + acpi_status status; + acpi_integer mask; + acpi_integer merged_datum; + acpi_integer raw_datum = 0; + u32 field_offset = 0; + u32 buffer_offset = 0; + u32 buffer_tail_bits; + u32 datum_count; + u32 field_datum_count; + u32 i; + + ACPI_FUNCTION_TRACE("ex_insert_into_field"); /* Validate input buffer */ - if (buffer_length < ACPI_ROUND_BITS_UP_TO_BYTES ( - obj_desc->common_field.bit_length)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Field size %X (bits) is too large for buffer (%X)\n", - obj_desc->common_field.bit_length, buffer_length)); + if (buffer_length < + ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Field size %X (bits) is too large for buffer (%X)\n", + obj_desc->common_field.bit_length, + buffer_length)); - return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + return_ACPI_STATUS(AE_BUFFER_OVERFLOW); } /* Compute the number of datums (access width data items) */ - mask = ACPI_MASK_BITS_BELOW (obj_desc->common_field.start_field_bit_offset); - datum_count = ACPI_ROUND_UP_TO (obj_desc->common_field.bit_length, - obj_desc->common_field.access_bit_width); - field_datum_count = ACPI_ROUND_UP_TO (obj_desc->common_field.bit_length + - obj_desc->common_field.start_field_bit_offset, - obj_desc->common_field.access_bit_width); + mask = + ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset); + datum_count = + ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length, + obj_desc->common_field.access_bit_width); + field_datum_count = + ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length + + obj_desc->common_field.start_field_bit_offset, + obj_desc->common_field.access_bit_width); /* Get initial Datum from the input buffer */ - ACPI_MEMCPY (&raw_datum, buffer, - ACPI_MIN(obj_desc->common_field.access_byte_width, - buffer_length - buffer_offset)); + ACPI_MEMCPY(&raw_datum, buffer, + ACPI_MIN(obj_desc->common_field.access_byte_width, + buffer_length - buffer_offset)); - merged_datum = raw_datum << obj_desc->common_field.start_field_bit_offset; + merged_datum = + raw_datum << obj_desc->common_field.start_field_bit_offset; /* Write the entire field */ @@ -828,18 +827,19 @@ acpi_ex_insert_into_field ( /* Write merged datum to the target field */ merged_datum &= mask; - status = acpi_ex_write_with_update_rule (obj_desc, mask, - merged_datum, field_offset); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_write_with_update_rule(obj_desc, mask, + merged_datum, + field_offset); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Start new output datum by merging with previous input datum */ field_offset += obj_desc->common_field.access_byte_width; merged_datum = raw_datum >> - (obj_desc->common_field.access_bit_width - - obj_desc->common_field.start_field_bit_offset); + (obj_desc->common_field.access_bit_width - + obj_desc->common_field.start_field_bit_offset); mask = ACPI_INTEGER_MAX; if (i == datum_count) { @@ -849,28 +849,28 @@ acpi_ex_insert_into_field ( /* Get the next input datum from the buffer */ buffer_offset += obj_desc->common_field.access_byte_width; - ACPI_MEMCPY (&raw_datum, ((char *) buffer) + buffer_offset, - ACPI_MIN(obj_desc->common_field.access_byte_width, - buffer_length - buffer_offset)); - merged_datum |= raw_datum << obj_desc->common_field.start_field_bit_offset; + ACPI_MEMCPY(&raw_datum, ((char *)buffer) + buffer_offset, + ACPI_MIN(obj_desc->common_field.access_byte_width, + buffer_length - buffer_offset)); + merged_datum |= + raw_datum << obj_desc->common_field.start_field_bit_offset; } /* Mask off any extra bits in the last datum */ buffer_tail_bits = (obj_desc->common_field.bit_length + - obj_desc->common_field.start_field_bit_offset) % - obj_desc->common_field.access_bit_width; + obj_desc->common_field.start_field_bit_offset) % + obj_desc->common_field.access_bit_width; if (buffer_tail_bits) { - mask &= ACPI_MASK_BITS_ABOVE (buffer_tail_bits); + mask &= ACPI_MASK_BITS_ABOVE(buffer_tail_bits); } /* Write the last datum to the field */ merged_datum &= mask; - status = acpi_ex_write_with_update_rule (obj_desc, - mask, merged_datum, field_offset); + status = acpi_ex_write_with_update_rule(obj_desc, + mask, merged_datum, + field_offset); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c index 237ef28..a3f4d72 100644 --- a/drivers/acpi/executer/exmisc.c +++ b/drivers/acpi/executer/exmisc.c @@ -42,15 +42,12 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exmisc") - +ACPI_MODULE_NAME("exmisc") /******************************************************************************* * @@ -66,27 +63,23 @@ * Common code for the ref_of_op and the cond_ref_of_op. * ******************************************************************************/ - acpi_status -acpi_ex_get_object_reference ( - union acpi_operand_object *obj_desc, - union acpi_operand_object **return_desc, - struct acpi_walk_state *walk_state) +acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, + union acpi_operand_object **return_desc, + struct acpi_walk_state *walk_state) { - union acpi_operand_object *reference_obj; - union acpi_operand_object *referenced_obj; - - - ACPI_FUNCTION_TRACE_PTR ("ex_get_object_reference", obj_desc); + union acpi_operand_object *reference_obj; + union acpi_operand_object *referenced_obj; + ACPI_FUNCTION_TRACE_PTR("ex_get_object_reference", obj_desc); *return_desc = NULL; - switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { + switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) { case ACPI_DESC_TYPE_OPERAND: - if (ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_LOCAL_REFERENCE) { - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_LOCAL_REFERENCE) { + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* @@ -104,13 +97,11 @@ acpi_ex_get_object_reference ( default: - ACPI_REPORT_ERROR (("Unknown Reference opcode in get_reference %X\n", - obj_desc->reference.opcode)); - return_ACPI_STATUS (AE_AML_INTERNAL); + ACPI_REPORT_ERROR(("Unknown Reference opcode in get_reference %X\n", obj_desc->reference.opcode)); + return_ACPI_STATUS(AE_AML_INTERNAL); } break; - case ACPI_DESC_TYPE_NAMED: /* @@ -119,34 +110,32 @@ acpi_ex_get_object_reference ( referenced_obj = obj_desc; break; - default: - ACPI_REPORT_ERROR (("Invalid descriptor type in get_reference: %X\n", - ACPI_GET_DESCRIPTOR_TYPE (obj_desc))); - return_ACPI_STATUS (AE_TYPE); + ACPI_REPORT_ERROR(("Invalid descriptor type in get_reference: %X\n", ACPI_GET_DESCRIPTOR_TYPE(obj_desc))); + return_ACPI_STATUS(AE_TYPE); } - /* Create a new reference object */ - reference_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE); + reference_obj = + acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE); if (!reference_obj) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } reference_obj->reference.opcode = AML_REF_OF_OP; reference_obj->reference.object = referenced_obj; *return_desc = reference_obj; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Object %p Type [%s], returning Reference %p\n", - obj_desc, acpi_ut_get_object_type_name (obj_desc), *return_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Object %p Type [%s], returning Reference %p\n", + obj_desc, acpi_ut_get_object_type_name(obj_desc), + *return_desc)); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ex_concat_template @@ -163,63 +152,58 @@ acpi_ex_get_object_reference ( ******************************************************************************/ acpi_status -acpi_ex_concat_template ( - union acpi_operand_object *operand0, - union acpi_operand_object *operand1, - union acpi_operand_object **actual_return_desc, - struct acpi_walk_state *walk_state) +acpi_ex_concat_template(union acpi_operand_object *operand0, + union acpi_operand_object *operand1, + union acpi_operand_object **actual_return_desc, + struct acpi_walk_state *walk_state) { - union acpi_operand_object *return_desc; - u8 *new_buf; - u8 *end_tag1; - u8 *end_tag2; - acpi_size length1; - acpi_size length2; - - - ACPI_FUNCTION_TRACE ("ex_concat_template"); + union acpi_operand_object *return_desc; + u8 *new_buf; + u8 *end_tag1; + u8 *end_tag2; + acpi_size length1; + acpi_size length2; + ACPI_FUNCTION_TRACE("ex_concat_template"); /* Find the end_tags in each resource template */ - end_tag1 = acpi_ut_get_resource_end_tag (operand0); - end_tag2 = acpi_ut_get_resource_end_tag (operand1); + end_tag1 = acpi_ut_get_resource_end_tag(operand0); + end_tag2 = acpi_ut_get_resource_end_tag(operand1); if (!end_tag1 || !end_tag2) { - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* Compute the length of each part */ - length1 = ACPI_PTR_DIFF (end_tag1, operand0->buffer.pointer); - length2 = ACPI_PTR_DIFF (end_tag2, operand1->buffer.pointer) + - 2; /* Size of END_TAG */ + length1 = ACPI_PTR_DIFF(end_tag1, operand0->buffer.pointer); + length2 = ACPI_PTR_DIFF(end_tag2, operand1->buffer.pointer) + 2; /* Size of END_TAG */ /* Create a new buffer object for the result */ - return_desc = acpi_ut_create_buffer_object (length1 + length2); + return_desc = acpi_ut_create_buffer_object(length1 + length2); if (!return_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Copy the templates to the new descriptor */ new_buf = return_desc->buffer.pointer; - ACPI_MEMCPY (new_buf, operand0->buffer.pointer, length1); - ACPI_MEMCPY (new_buf + length1, operand1->buffer.pointer, length2); + ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length1); + ACPI_MEMCPY(new_buf + length1, operand1->buffer.pointer, length2); /* Compute the new checksum */ new_buf[return_desc->buffer.length - 1] = - acpi_ut_generate_checksum (return_desc->buffer.pointer, - (return_desc->buffer.length - 1)); + acpi_ut_generate_checksum(return_desc->buffer.pointer, + (return_desc->buffer.length - 1)); /* Return the completed template descriptor */ *actual_return_desc = return_desc; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ex_do_concatenate @@ -236,21 +220,18 @@ acpi_ex_concat_template ( ******************************************************************************/ acpi_status -acpi_ex_do_concatenate ( - union acpi_operand_object *operand0, - union acpi_operand_object *operand1, - union acpi_operand_object **actual_return_desc, - struct acpi_walk_state *walk_state) +acpi_ex_do_concatenate(union acpi_operand_object *operand0, + union acpi_operand_object *operand1, + union acpi_operand_object **actual_return_desc, + struct acpi_walk_state *walk_state) { - union acpi_operand_object *local_operand1 = operand1; - union acpi_operand_object *return_desc; - char *new_buf; - acpi_status status; - acpi_size new_length; - - - ACPI_FUNCTION_TRACE ("ex_do_concatenate"); + union acpi_operand_object *local_operand1 = operand1; + union acpi_operand_object *return_desc; + char *new_buf; + acpi_status status; + acpi_size new_length; + ACPI_FUNCTION_TRACE("ex_do_concatenate"); /* * Convert the second operand if necessary. The first operand @@ -259,27 +240,28 @@ acpi_ex_do_concatenate ( * guaranteed to be either Integer/String/Buffer by the operand * resolution mechanism. */ - switch (ACPI_GET_OBJECT_TYPE (operand0)) { + switch (ACPI_GET_OBJECT_TYPE(operand0)) { case ACPI_TYPE_INTEGER: - status = acpi_ex_convert_to_integer (operand1, &local_operand1, 16); + status = + acpi_ex_convert_to_integer(operand1, &local_operand1, 16); break; case ACPI_TYPE_STRING: - status = acpi_ex_convert_to_string (operand1, &local_operand1, - ACPI_IMPLICIT_CONVERT_HEX); + status = acpi_ex_convert_to_string(operand1, &local_operand1, + ACPI_IMPLICIT_CONVERT_HEX); break; case ACPI_TYPE_BUFFER: - status = acpi_ex_convert_to_buffer (operand1, &local_operand1); + status = acpi_ex_convert_to_buffer(operand1, &local_operand1); break; default: - ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n", - ACPI_GET_OBJECT_TYPE (operand0))); + ACPI_REPORT_ERROR(("Concat - invalid obj type: %X\n", + ACPI_GET_OBJECT_TYPE(operand0))); status = AE_AML_INTERNAL; } - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -296,32 +278,33 @@ acpi_ex_do_concatenate ( * 2) Two Strings concatenated to produce a new String * 3) Two Buffers concatenated to produce a new Buffer */ - switch (ACPI_GET_OBJECT_TYPE (operand0)) { + switch (ACPI_GET_OBJECT_TYPE(operand0)) { case ACPI_TYPE_INTEGER: /* Result of two Integers is a Buffer */ /* Need enough buffer space for two integers */ - return_desc = acpi_ut_create_buffer_object ((acpi_size) - ACPI_MUL_2 (acpi_gbl_integer_byte_width)); + return_desc = acpi_ut_create_buffer_object((acpi_size) + ACPI_MUL_2 + (acpi_gbl_integer_byte_width)); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; } - new_buf = (char *) return_desc->buffer.pointer; + new_buf = (char *)return_desc->buffer.pointer; /* Copy the first integer, LSB first */ - ACPI_MEMCPY (new_buf, - &operand0->integer.value, - acpi_gbl_integer_byte_width); + ACPI_MEMCPY(new_buf, + &operand0->integer.value, + acpi_gbl_integer_byte_width); /* Copy the second integer (LSB first) after the first */ - ACPI_MEMCPY (new_buf + acpi_gbl_integer_byte_width, - &local_operand1->integer.value, - acpi_gbl_integer_byte_width); + ACPI_MEMCPY(new_buf + acpi_gbl_integer_byte_width, + &local_operand1->integer.value, + acpi_gbl_integer_byte_width); break; case ACPI_TYPE_STRING: @@ -329,13 +312,13 @@ acpi_ex_do_concatenate ( /* Result of two Strings is a String */ new_length = (acpi_size) operand0->string.length + - (acpi_size) local_operand1->string.length; + (acpi_size) local_operand1->string.length; if (new_length > ACPI_MAX_STRING_CONVERSION) { status = AE_AML_STRING_LIMIT; goto cleanup; } - return_desc = acpi_ut_create_string_object (new_length); + return_desc = acpi_ut_create_string_object(new_length); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -345,56 +328,56 @@ acpi_ex_do_concatenate ( /* Concatenate the strings */ - ACPI_STRCPY (new_buf, - operand0->string.pointer); - ACPI_STRCPY (new_buf + operand0->string.length, - local_operand1->string.pointer); + ACPI_STRCPY(new_buf, operand0->string.pointer); + ACPI_STRCPY(new_buf + operand0->string.length, + local_operand1->string.pointer); break; case ACPI_TYPE_BUFFER: /* Result of two Buffers is a Buffer */ - return_desc = acpi_ut_create_buffer_object ( - (acpi_size) operand0->buffer.length + - (acpi_size) local_operand1->buffer.length); + return_desc = acpi_ut_create_buffer_object((acpi_size) + operand0->buffer. + length + + (acpi_size) + local_operand1-> + buffer.length); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; } - new_buf = (char *) return_desc->buffer.pointer; + new_buf = (char *)return_desc->buffer.pointer; /* Concatenate the buffers */ - ACPI_MEMCPY (new_buf, - operand0->buffer.pointer, - operand0->buffer.length); - ACPI_MEMCPY (new_buf + operand0->buffer.length, - local_operand1->buffer.pointer, - local_operand1->buffer.length); + ACPI_MEMCPY(new_buf, + operand0->buffer.pointer, operand0->buffer.length); + ACPI_MEMCPY(new_buf + operand0->buffer.length, + local_operand1->buffer.pointer, + local_operand1->buffer.length); break; default: /* Invalid object type, should not happen here */ - ACPI_REPORT_ERROR (("Concatenate - Invalid object type: %X\n", - ACPI_GET_OBJECT_TYPE (operand0))); - status =AE_AML_INTERNAL; + ACPI_REPORT_ERROR(("Concatenate - Invalid object type: %X\n", + ACPI_GET_OBJECT_TYPE(operand0))); + status = AE_AML_INTERNAL; goto cleanup; } *actual_return_desc = return_desc; -cleanup: + cleanup: if (local_operand1 != operand1) { - acpi_ut_remove_reference (local_operand1); + acpi_ut_remove_reference(local_operand1); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_do_math_op @@ -412,62 +395,49 @@ cleanup: ******************************************************************************/ acpi_integer -acpi_ex_do_math_op ( - u16 opcode, - acpi_integer integer0, - acpi_integer integer1) +acpi_ex_do_math_op(u16 opcode, acpi_integer integer0, acpi_integer integer1) { - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_ENTRY(); switch (opcode) { - case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */ + case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */ return (integer0 + integer1); - - case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */ + case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */ return (integer0 & integer1); - - case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */ + case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */ return (~(integer0 & integer1)); - - case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */ + case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */ return (integer0 | integer1); - - case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */ + case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */ return (~(integer0 | integer1)); - - case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */ + case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */ return (integer0 ^ integer1); - - case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */ + case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */ return (integer0 * integer1); - - case AML_SHIFT_LEFT_OP: /* shift_left (Operand, shift_count, Result)*/ + case AML_SHIFT_LEFT_OP: /* shift_left (Operand, shift_count, Result) */ return (integer0 << integer1); - - case AML_SHIFT_RIGHT_OP: /* shift_right (Operand, shift_count, Result) */ + case AML_SHIFT_RIGHT_OP: /* shift_right (Operand, shift_count, Result) */ return (integer0 >> integer1); - - case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */ + case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */ return (integer0 - integer1); @@ -477,7 +447,6 @@ acpi_ex_do_math_op ( } } - /******************************************************************************* * * FUNCTION: acpi_ex_do_logical_numeric_op @@ -499,28 +468,24 @@ acpi_ex_do_math_op ( ******************************************************************************/ acpi_status -acpi_ex_do_logical_numeric_op ( - u16 opcode, - acpi_integer integer0, - acpi_integer integer1, - u8 *logical_result) +acpi_ex_do_logical_numeric_op(u16 opcode, + acpi_integer integer0, + acpi_integer integer1, u8 * logical_result) { - acpi_status status = AE_OK; - u8 local_result = FALSE; - - - ACPI_FUNCTION_TRACE ("ex_do_logical_numeric_op"); + acpi_status status = AE_OK; + u8 local_result = FALSE; + ACPI_FUNCTION_TRACE("ex_do_logical_numeric_op"); switch (opcode) { - case AML_LAND_OP: /* LAnd (Integer0, Integer1) */ + case AML_LAND_OP: /* LAnd (Integer0, Integer1) */ if (integer0 && integer1) { local_result = TRUE; } break; - case AML_LOR_OP: /* LOr (Integer0, Integer1) */ + case AML_LOR_OP: /* LOr (Integer0, Integer1) */ if (integer0 || integer1) { local_result = TRUE; @@ -535,10 +500,9 @@ acpi_ex_do_logical_numeric_op ( /* Return the logical result and status */ *logical_result = local_result; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_do_logical_op @@ -566,24 +530,20 @@ acpi_ex_do_logical_numeric_op ( ******************************************************************************/ acpi_status -acpi_ex_do_logical_op ( - u16 opcode, - union acpi_operand_object *operand0, - union acpi_operand_object *operand1, - u8 *logical_result) +acpi_ex_do_logical_op(u16 opcode, + union acpi_operand_object *operand0, + union acpi_operand_object *operand1, u8 * logical_result) { - union acpi_operand_object *local_operand1 = operand1; - acpi_integer integer0; - acpi_integer integer1; - u32 length0; - u32 length1; - acpi_status status = AE_OK; - u8 local_result = FALSE; - int compare; - - - ACPI_FUNCTION_TRACE ("ex_do_logical_op"); + union acpi_operand_object *local_operand1 = operand1; + acpi_integer integer0; + acpi_integer integer1; + u32 length0; + u32 length1; + acpi_status status = AE_OK; + u8 local_result = FALSE; + int compare; + ACPI_FUNCTION_TRACE("ex_do_logical_op"); /* * Convert the second operand if necessary. The first operand @@ -592,18 +552,19 @@ acpi_ex_do_logical_op ( * guaranteed to be either Integer/String/Buffer by the operand * resolution mechanism. */ - switch (ACPI_GET_OBJECT_TYPE (operand0)) { + switch (ACPI_GET_OBJECT_TYPE(operand0)) { case ACPI_TYPE_INTEGER: - status = acpi_ex_convert_to_integer (operand1, &local_operand1, 16); + status = + acpi_ex_convert_to_integer(operand1, &local_operand1, 16); break; case ACPI_TYPE_STRING: - status = acpi_ex_convert_to_string (operand1, &local_operand1, - ACPI_IMPLICIT_CONVERT_HEX); + status = acpi_ex_convert_to_string(operand1, &local_operand1, + ACPI_IMPLICIT_CONVERT_HEX); break; case ACPI_TYPE_BUFFER: - status = acpi_ex_convert_to_buffer (operand1, &local_operand1); + status = acpi_ex_convert_to_buffer(operand1, &local_operand1); break; default: @@ -611,14 +572,14 @@ acpi_ex_do_logical_op ( break; } - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { goto cleanup; } /* * Two cases: 1) Both Integers, 2) Both Strings or Buffers */ - if (ACPI_GET_OBJECT_TYPE (operand0) == ACPI_TYPE_INTEGER) { + if (ACPI_GET_OBJECT_TYPE(operand0) == ACPI_TYPE_INTEGER) { /* * 1) Both operands are of type integer * Note: local_operand1 may have changed above @@ -627,21 +588,21 @@ acpi_ex_do_logical_op ( integer1 = local_operand1->integer.value; switch (opcode) { - case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ if (integer0 == integer1) { local_result = TRUE; } break; - case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ if (integer0 > integer1) { local_result = TRUE; } break; - case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ if (integer0 < integer1) { local_result = TRUE; @@ -652,8 +613,7 @@ acpi_ex_do_logical_op ( status = AE_AML_INTERNAL; break; } - } - else { + } else { /* * 2) Both operands are Strings or both are Buffers * Note: Code below takes advantage of common Buffer/String @@ -665,31 +625,31 @@ acpi_ex_do_logical_op ( /* Lexicographic compare: compare the data bytes */ - compare = ACPI_MEMCMP ((const char * ) operand0->buffer.pointer, - (const char * ) local_operand1->buffer.pointer, - (length0 > length1) ? length1 : length0); + compare = ACPI_MEMCMP((const char *)operand0->buffer.pointer, + (const char *)local_operand1->buffer. + pointer, + (length0 > length1) ? length1 : length0); switch (opcode) { - case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ /* Length and all bytes must be equal */ - if ((length0 == length1) && - (compare == 0)) { + if ((length0 == length1) && (compare == 0)) { /* Length and all bytes match ==> TRUE */ local_result = TRUE; } break; - case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ if (compare > 0) { local_result = TRUE; - goto cleanup; /* TRUE */ + goto cleanup; /* TRUE */ } if (compare < 0) { - goto cleanup; /* FALSE */ + goto cleanup; /* FALSE */ } /* Bytes match (to shortest length), compare lengths */ @@ -699,14 +659,14 @@ acpi_ex_do_logical_op ( } break; - case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ if (compare > 0) { - goto cleanup; /* FALSE */ + goto cleanup; /* FALSE */ } if (compare < 0) { local_result = TRUE; - goto cleanup; /* TRUE */ + goto cleanup; /* TRUE */ } /* Bytes match (to shortest length), compare lengths */ @@ -722,18 +682,16 @@ acpi_ex_do_logical_op ( } } -cleanup: + cleanup: /* New object was created if implicit conversion performed - delete */ if (local_operand1 != operand1) { - acpi_ut_remove_reference (local_operand1); + acpi_ut_remove_reference(local_operand1); } /* Return the logical result and status */ *logical_result = local_result; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c index c3cb714..ab47f6d 100644 --- a/drivers/acpi/executer/exmutex.c +++ b/drivers/acpi/executer/exmutex.c @@ -42,20 +42,16 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exmutex") +ACPI_MODULE_NAME("exmutex") /* Local prototypes */ - static void -acpi_ex_link_mutex ( - union acpi_operand_object *obj_desc, - struct acpi_thread_state *thread); - +acpi_ex_link_mutex(union acpi_operand_object *obj_desc, + struct acpi_thread_state *thread); /******************************************************************************* * @@ -69,12 +65,9 @@ acpi_ex_link_mutex ( * ******************************************************************************/ -void -acpi_ex_unlink_mutex ( - union acpi_operand_object *obj_desc) +void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc) { - struct acpi_thread_state *thread = obj_desc->mutex.owner_thread; - + struct acpi_thread_state *thread = obj_desc->mutex.owner_thread; if (!thread) { return; @@ -88,13 +81,11 @@ acpi_ex_unlink_mutex ( if (obj_desc->mutex.prev) { (obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next; - } - else { + } else { thread->acquired_mutex_list = obj_desc->mutex.next; } } - /******************************************************************************* * * FUNCTION: acpi_ex_link_mutex @@ -109,12 +100,10 @@ acpi_ex_unlink_mutex ( ******************************************************************************/ static void -acpi_ex_link_mutex ( - union acpi_operand_object *obj_desc, - struct acpi_thread_state *thread) +acpi_ex_link_mutex(union acpi_operand_object *obj_desc, + struct acpi_thread_state *thread) { - union acpi_operand_object *list_head; - + union acpi_operand_object *list_head; list_head = thread->acquired_mutex_list; @@ -134,7 +123,6 @@ acpi_ex_link_mutex ( thread->acquired_mutex_list = obj_desc; } - /******************************************************************************* * * FUNCTION: acpi_ex_acquire_mutex @@ -150,27 +138,23 @@ acpi_ex_link_mutex ( ******************************************************************************/ acpi_status -acpi_ex_acquire_mutex ( - union acpi_operand_object *time_desc, - union acpi_operand_object *obj_desc, - struct acpi_walk_state *walk_state) +acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, + union acpi_operand_object *obj_desc, + struct acpi_walk_state *walk_state) { - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ex_acquire_mutex", obj_desc); + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ex_acquire_mutex", obj_desc); if (!obj_desc) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Sanity check -- we must have a valid thread ID */ if (!walk_state->thread) { - ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], null thread info\n", - acpi_ut_get_node_name (obj_desc->mutex.node))); - return_ACPI_STATUS (AE_AML_INTERNAL); + ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node))); + return_ACPI_STATUS(AE_AML_INTERNAL); } /* @@ -178,10 +162,8 @@ acpi_ex_acquire_mutex ( * mutex. This mechanism provides some deadlock prevention */ if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) { - ACPI_REPORT_ERROR (( - "Cannot acquire Mutex [%4.4s], incorrect sync_level\n", - acpi_ut_get_node_name (obj_desc->mutex.node))); - return_ACPI_STATUS (AE_AML_MUTEX_ORDER); + ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node))); + return_ACPI_STATUS(AE_AML_MUTEX_ORDER); } /* Support for multiple acquires by the owning thread */ @@ -190,43 +172,43 @@ acpi_ex_acquire_mutex ( /* Special case for Global Lock, allow all threads */ if ((obj_desc->mutex.owner_thread->thread_id == - walk_state->thread->thread_id) || - (obj_desc->mutex.semaphore == - acpi_gbl_global_lock_semaphore)) { + walk_state->thread->thread_id) || + (obj_desc->mutex.semaphore == + acpi_gbl_global_lock_semaphore)) { /* * The mutex is already owned by this thread, * just increment the acquisition depth */ obj_desc->mutex.acquisition_depth++; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } } /* Acquire the mutex, wait if necessary */ - status = acpi_ex_system_acquire_mutex (time_desc, obj_desc); - if (ACPI_FAILURE (status)) { + status = acpi_ex_system_acquire_mutex(time_desc, obj_desc); + if (ACPI_FAILURE(status)) { /* Includes failure from a timeout on time_desc */ - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Have the mutex: update mutex and walk info and save the sync_level */ - obj_desc->mutex.owner_thread = walk_state->thread; + obj_desc->mutex.owner_thread = walk_state->thread; obj_desc->mutex.acquisition_depth = 1; - obj_desc->mutex.original_sync_level = walk_state->thread->current_sync_level; + obj_desc->mutex.original_sync_level = + walk_state->thread->current_sync_level; walk_state->thread->current_sync_level = obj_desc->mutex.sync_level; /* Link the mutex to the current thread for force-unlock at method exit */ - acpi_ex_link_mutex (obj_desc, walk_state->thread); + acpi_ex_link_mutex(obj_desc, walk_state->thread); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ex_release_mutex @@ -241,48 +223,40 @@ acpi_ex_acquire_mutex ( ******************************************************************************/ acpi_status -acpi_ex_release_mutex ( - union acpi_operand_object *obj_desc, - struct acpi_walk_state *walk_state) +acpi_ex_release_mutex(union acpi_operand_object *obj_desc, + struct acpi_walk_state *walk_state) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ex_release_mutex"); + acpi_status status; + ACPI_FUNCTION_TRACE("ex_release_mutex"); if (!obj_desc) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* The mutex must have been previously acquired in order to release it */ if (!obj_desc->mutex.owner_thread) { - ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], not acquired\n", - acpi_ut_get_node_name (obj_desc->mutex.node))); - return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED); + ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], not acquired\n", acpi_ut_get_node_name(obj_desc->mutex.node))); + return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); } /* Sanity check -- we must have a valid thread ID */ if (!walk_state->thread) { - ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], null thread info\n", - acpi_ut_get_node_name (obj_desc->mutex.node))); - return_ACPI_STATUS (AE_AML_INTERNAL); + ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node))); + return_ACPI_STATUS(AE_AML_INTERNAL); } /* * The Mutex is owned, but this thread must be the owner. * Special case for Global Lock, any thread can release */ - if ((obj_desc->mutex.owner_thread->thread_id != walk_state->thread->thread_id) && - (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) { - ACPI_REPORT_ERROR (( - "Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", - walk_state->thread->thread_id, - acpi_ut_get_node_name (obj_desc->mutex.node), - obj_desc->mutex.owner_thread->thread_id)); - return_ACPI_STATUS (AE_AML_NOT_OWNER); + if ((obj_desc->mutex.owner_thread->thread_id != + walk_state->thread->thread_id) + && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) { + ACPI_REPORT_ERROR(("Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", walk_state->thread->thread_id, acpi_ut_get_node_name(obj_desc->mutex.node), obj_desc->mutex.owner_thread->thread_id)); + return_ACPI_STATUS(AE_AML_NOT_OWNER); } /* @@ -290,10 +264,8 @@ acpi_ex_release_mutex ( * equal to the current sync level */ if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) { - ACPI_REPORT_ERROR (( - "Cannot release Mutex [%4.4s], incorrect sync_level\n", - acpi_ut_get_node_name (obj_desc->mutex.node))); - return_ACPI_STATUS (AE_AML_MUTEX_ORDER); + ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node))); + return_ACPI_STATUS(AE_AML_MUTEX_ORDER); } /* Match multiple Acquires with multiple Releases */ @@ -302,26 +274,26 @@ acpi_ex_release_mutex ( if (obj_desc->mutex.acquisition_depth != 0) { /* Just decrement the depth and return */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Unlink the mutex from the owner's list */ - acpi_ex_unlink_mutex (obj_desc); + acpi_ex_unlink_mutex(obj_desc); /* Release the mutex */ - status = acpi_ex_system_release_mutex (obj_desc); + status = acpi_ex_system_release_mutex(obj_desc); /* Update the mutex and walk state, restore sync_level before acquire */ obj_desc->mutex.owner_thread = NULL; - walk_state->thread->current_sync_level = obj_desc->mutex.original_sync_level; + walk_state->thread->current_sync_level = + obj_desc->mutex.original_sync_level; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_release_all_mutexes @@ -334,17 +306,13 @@ acpi_ex_release_mutex ( * ******************************************************************************/ -void -acpi_ex_release_all_mutexes ( - struct acpi_thread_state *thread) +void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread) { - union acpi_operand_object *next = thread->acquired_mutex_list; - union acpi_operand_object *this; - acpi_status status; - - - ACPI_FUNCTION_ENTRY (); + union acpi_operand_object *next = thread->acquired_mutex_list; + union acpi_operand_object *this; + acpi_status status; + ACPI_FUNCTION_ENTRY(); /* Traverse the list of owned mutexes, releasing each one */ @@ -353,13 +321,13 @@ acpi_ex_release_all_mutexes ( next = this->mutex.next; this->mutex.acquisition_depth = 1; - this->mutex.prev = NULL; - this->mutex.next = NULL; + this->mutex.prev = NULL; + this->mutex.next = NULL; - /* Release the mutex */ + /* Release the mutex */ - status = acpi_ex_system_release_mutex (this); - if (ACPI_FAILURE (status)) { + status = acpi_ex_system_release_mutex(this); + if (ACPI_FAILURE(status)) { continue; } @@ -372,5 +340,3 @@ acpi_ex_release_all_mutexes ( thread->current_sync_level = this->mutex.original_sync_level; } } - - diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c index b6ba1a7a..239d847 100644 --- a/drivers/acpi/executer/exnames.c +++ b/drivers/acpi/executer/exnames.c @@ -42,26 +42,18 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exnames") +ACPI_MODULE_NAME("exnames") /* Local prototypes */ - -static char * -acpi_ex_allocate_name_string ( - u32 prefix_count, - u32 num_name_segs); +static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs); static acpi_status -acpi_ex_name_segment ( - u8 **in_aml_address, - char *name_string); - +acpi_ex_name_segment(u8 ** in_aml_address, char *name_string); /******************************************************************************* * @@ -79,17 +71,13 @@ acpi_ex_name_segment ( * ******************************************************************************/ -static char * -acpi_ex_allocate_name_string ( - u32 prefix_count, - u32 num_name_segs) +static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs) { - char *temp_ptr; - char *name_string; - u32 size_needed; - - ACPI_FUNCTION_TRACE ("ex_allocate_name_string"); + char *temp_ptr; + char *name_string; + u32 size_needed; + ACPI_FUNCTION_TRACE("ex_allocate_name_string"); /* * Allow room for all \ and ^ prefixes, all segments and a multi_name_prefix. @@ -100,20 +88,19 @@ acpi_ex_allocate_name_string ( /* Special case for root */ size_needed = 1 + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1; - } - else { - size_needed = prefix_count + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1; + } else { + size_needed = + prefix_count + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1; } /* * Allocate a buffer for the name. * This buffer must be deleted by the caller! */ - name_string = ACPI_MEM_ALLOCATE (size_needed); + name_string = ACPI_MEM_ALLOCATE(size_needed); if (!name_string) { - ACPI_REPORT_ERROR (( - "ex_allocate_name_string: Could not allocate size %d\n", size_needed)); - return_PTR (NULL); + ACPI_REPORT_ERROR(("ex_allocate_name_string: Could not allocate size %d\n", size_needed)); + return_PTR(NULL); } temp_ptr = name_string; @@ -122,23 +109,20 @@ acpi_ex_allocate_name_string ( if (prefix_count == ACPI_UINT32_MAX) { *temp_ptr++ = AML_ROOT_PREFIX; - } - else { + } else { while (prefix_count--) { *temp_ptr++ = AML_PARENT_PREFIX; } } - /* Set up Dual or Multi prefixes if needed */ if (num_name_segs > 2) { /* Set up multi prefixes */ *temp_ptr++ = AML_MULTI_NAME_PREFIX_OP; - *temp_ptr++ = (char) num_name_segs; - } - else if (2 == num_name_segs) { + *temp_ptr++ = (char)num_name_segs; + } else if (2 == num_name_segs) { /* Set up dual prefixes */ *temp_ptr++ = AML_DUAL_NAME_PREFIX; @@ -150,7 +134,7 @@ acpi_ex_allocate_name_string ( */ *temp_ptr = 0; - return_PTR (name_string); + return_PTR(name_string); } /******************************************************************************* @@ -167,19 +151,14 @@ acpi_ex_allocate_name_string ( * ******************************************************************************/ -static acpi_status -acpi_ex_name_segment ( - u8 **in_aml_address, - char *name_string) +static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string) { - char *aml_address = (void *) *in_aml_address; - acpi_status status = AE_OK; - u32 index; - char char_buf[5]; - - - ACPI_FUNCTION_TRACE ("ex_name_segment"); + char *aml_address = (void *)*in_aml_address; + acpi_status status = AE_OK; + u32 index; + char char_buf[5]; + ACPI_FUNCTION_TRACE("ex_name_segment"); /* * If first character is a digit, then we know that we aren't looking at a @@ -188,20 +167,20 @@ acpi_ex_name_segment ( char_buf[0] = *aml_address; if ('0' <= char_buf[0] && char_buf[0] <= '9') { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "leading digit: %c\n", char_buf[0])); - return_ACPI_STATUS (AE_CTRL_PENDING); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "leading digit: %c\n", + char_buf[0])); + return_ACPI_STATUS(AE_CTRL_PENDING); } - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n")); + ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Bytes from stream:\n")); for (index = 0; - (index < ACPI_NAME_SIZE) && (acpi_ut_valid_acpi_character (*aml_address)); - index++) { + (index < ACPI_NAME_SIZE) + && (acpi_ut_valid_acpi_character(*aml_address)); index++) { char_buf[index] = *aml_address++; - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", char_buf[index])); + ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index])); } - /* Valid name segment */ if (index == 4) { @@ -210,41 +189,37 @@ acpi_ex_name_segment ( char_buf[4] = '\0'; if (name_string) { - ACPI_STRCAT (name_string, char_buf); - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Appended to - %s \n", name_string)); + ACPI_STRCAT(name_string, char_buf); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Appended to - %s \n", name_string)); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "No Name string - %s \n", char_buf)); } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "No Name string - %s \n", char_buf)); - } - } - else if (index == 0) { + } else if (index == 0) { /* * First character was not a valid name character, * so we are looking at something other than a name. */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Leading character is not alpha: %02Xh (not a name)\n", - char_buf[0])); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Leading character is not alpha: %02Xh (not a name)\n", + char_buf[0])); status = AE_CTRL_PENDING; - } - else { + } else { /* * Segment started with one or more valid characters, but fewer than * the required 4 */ status = AE_AML_BAD_NAME; - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Bad character %02x in name, at %p\n", - *aml_address, aml_address)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Bad character %02x in name, at %p\n", + *aml_address, aml_address)); } *in_aml_address = (u8 *) aml_address; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_get_name_string @@ -263,37 +238,32 @@ acpi_ex_name_segment ( ******************************************************************************/ acpi_status -acpi_ex_get_name_string ( - acpi_object_type data_type, - u8 *in_aml_address, - char **out_name_string, - u32 *out_name_length) +acpi_ex_get_name_string(acpi_object_type data_type, + u8 * in_aml_address, + char **out_name_string, u32 * out_name_length) { - acpi_status status = AE_OK; - u8 *aml_address = in_aml_address; - char *name_string = NULL; - u32 num_segments; - u32 prefix_count = 0; - u8 has_prefix = FALSE; - - - ACPI_FUNCTION_TRACE_PTR ("ex_get_name_string", aml_address); - - - if (ACPI_TYPE_LOCAL_REGION_FIELD == data_type || - ACPI_TYPE_LOCAL_BANK_FIELD == data_type || - ACPI_TYPE_LOCAL_INDEX_FIELD == data_type) { + acpi_status status = AE_OK; + u8 *aml_address = in_aml_address; + char *name_string = NULL; + u32 num_segments; + u32 prefix_count = 0; + u8 has_prefix = FALSE; + + ACPI_FUNCTION_TRACE_PTR("ex_get_name_string", aml_address); + + if (ACPI_TYPE_LOCAL_REGION_FIELD == data_type || + ACPI_TYPE_LOCAL_BANK_FIELD == data_type || + ACPI_TYPE_LOCAL_INDEX_FIELD == data_type) { /* Disallow prefixes for types associated with field_unit names */ - name_string = acpi_ex_allocate_name_string (0, 1); + name_string = acpi_ex_allocate_name_string(0, 1); if (!name_string) { status = AE_NO_MEMORY; + } else { + status = + acpi_ex_name_segment(&aml_address, name_string); } - else { - status = acpi_ex_name_segment (&aml_address, name_string); - } - } - else { + } else { /* * data_type is not a field name. * Examine first character of name for root or parent prefix operators @@ -301,8 +271,9 @@ acpi_ex_get_name_string ( switch (*aml_address) { case AML_ROOT_PREFIX: - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "root_prefix(\\) at %p\n", - aml_address)); + ACPI_DEBUG_PRINT((ACPI_DB_LOAD, + "root_prefix(\\) at %p\n", + aml_address)); /* * Remember that we have a root_prefix -- @@ -313,14 +284,14 @@ acpi_ex_get_name_string ( has_prefix = TRUE; break; - case AML_PARENT_PREFIX: /* Increment past possibly multiple parent prefixes */ do { - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "parent_prefix (^) at %p\n", - aml_address)); + ACPI_DEBUG_PRINT((ACPI_DB_LOAD, + "parent_prefix (^) at %p\n", + aml_address)); aml_address++; prefix_count++; @@ -330,7 +301,6 @@ acpi_ex_get_name_string ( has_prefix = TRUE; break; - default: /* Not a prefix character */ @@ -343,11 +313,13 @@ acpi_ex_get_name_string ( switch (*aml_address) { case AML_DUAL_NAME_PREFIX: - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "dual_name_prefix at %p\n", - aml_address)); + ACPI_DEBUG_PRINT((ACPI_DB_LOAD, + "dual_name_prefix at %p\n", + aml_address)); aml_address++; - name_string = acpi_ex_allocate_name_string (prefix_count, 2); + name_string = + acpi_ex_allocate_name_string(prefix_count, 2); if (!name_string) { status = AE_NO_MEMORY; break; @@ -357,24 +329,29 @@ acpi_ex_get_name_string ( has_prefix = TRUE; - status = acpi_ex_name_segment (&aml_address, name_string); - if (ACPI_SUCCESS (status)) { - status = acpi_ex_name_segment (&aml_address, name_string); + status = + acpi_ex_name_segment(&aml_address, name_string); + if (ACPI_SUCCESS(status)) { + status = + acpi_ex_name_segment(&aml_address, + name_string); } break; - case AML_MULTI_NAME_PREFIX_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "multi_name_prefix at %p\n", - aml_address)); + ACPI_DEBUG_PRINT((ACPI_DB_LOAD, + "multi_name_prefix at %p\n", + aml_address)); /* Fetch count of segments remaining in name path */ aml_address++; num_segments = *aml_address; - name_string = acpi_ex_allocate_name_string (prefix_count, num_segments); + name_string = + acpi_ex_allocate_name_string(prefix_count, + num_segments); if (!name_string) { status = AE_NO_MEMORY; break; @@ -386,27 +363,28 @@ acpi_ex_get_name_string ( has_prefix = TRUE; while (num_segments && - (status = acpi_ex_name_segment (&aml_address, name_string)) == - AE_OK) { + (status = + acpi_ex_name_segment(&aml_address, + name_string)) == AE_OK) { num_segments--; } break; - case 0: /* null_name valid as of 8-12-98 ASL/AML Grammar Update */ if (prefix_count == ACPI_UINT32_MAX) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "name_seg is \"\\\" followed by NULL\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "name_seg is \"\\\" followed by NULL\n")); } /* Consume the NULL byte */ aml_address++; - name_string = acpi_ex_allocate_name_string (prefix_count, 0); + name_string = + acpi_ex_allocate_name_string(prefix_count, 0); if (!name_string) { status = AE_NO_MEMORY; break; @@ -414,18 +392,19 @@ acpi_ex_get_name_string ( break; - default: /* Name segment string */ - name_string = acpi_ex_allocate_name_string (prefix_count, 1); + name_string = + acpi_ex_allocate_name_string(prefix_count, 1); if (!name_string) { status = AE_NO_MEMORY; break; } - status = acpi_ex_name_segment (&aml_address, name_string); + status = + acpi_ex_name_segment(&aml_address, name_string); break; } } @@ -433,22 +412,20 @@ acpi_ex_get_name_string ( if (AE_CTRL_PENDING == status && has_prefix) { /* Ran out of segments after processing a prefix */ - ACPI_REPORT_ERROR ( - ("ex_do_name: Malformed Name at %p\n", name_string)); + ACPI_REPORT_ERROR(("ex_do_name: Malformed Name at %p\n", + name_string)); status = AE_AML_BAD_NAME; } - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { if (name_string) { - ACPI_MEM_FREE (name_string); + ACPI_MEM_FREE(name_string); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } *out_name_string = name_string; *out_name_length = (u32) (aml_address - in_aml_address); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c index 48c30f8..97e3454 100644 --- a/drivers/acpi/executer/exoparg1.c +++ b/drivers/acpi/executer/exoparg1.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -50,10 +49,8 @@ #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exoparg1") - +ACPI_MODULE_NAME("exoparg1") /*! * Naming convention for AML interpreter execution routines. @@ -76,7 +73,6 @@ * The AcpiExOpcode* functions are called via the Dispatcher component with * fully resolved operands. !*/ - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_0A_0T_1R @@ -88,61 +84,53 @@ * DESCRIPTION: Execute operator with no operands, one return value * ******************************************************************************/ - -acpi_status -acpi_ex_opcode_0A_0T_1R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - union acpi_operand_object *return_desc = NULL; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_0A_0T_1R", - acpi_ps_get_opcode_name (walk_state->opcode)); + acpi_status status = AE_OK; + union acpi_operand_object *return_desc = NULL; + ACPI_FUNCTION_TRACE_STR("ex_opcode_0A_0T_1R", + acpi_ps_get_opcode_name(walk_state->opcode)); /* Examine the AML opcode */ switch (walk_state->opcode) { - case AML_TIMER_OP: /* Timer () */ + case AML_TIMER_OP: /* Timer () */ /* Create a return object of type Integer */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; } #if ACPI_MACHINE_WIDTH != 16 - return_desc->integer.value = acpi_os_get_timer (); + return_desc->integer.value = acpi_os_get_timer(); #endif break; - default: /* Unknown opcode */ + default: /* Unknown opcode */ - ACPI_REPORT_ERROR (("acpi_ex_opcode_0A_0T_1R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_REPORT_ERROR(("acpi_ex_opcode_0A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); status = AE_AML_BAD_OPCODE; break; } -cleanup: + cleanup: /* Delete return object on error */ - if ((ACPI_FAILURE (status)) || walk_state->result_obj) { - acpi_ut_remove_reference (return_desc); - } - else { + if ((ACPI_FAILURE(status)) || walk_state->result_obj) { + acpi_ut_remove_reference(return_desc); + } else { /* Save the return value */ walk_state->result_obj = return_desc; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_1A_0T_0R @@ -156,69 +144,58 @@ cleanup: * ******************************************************************************/ -acpi_status -acpi_ex_opcode_1A_0T_0R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R", - acpi_ps_get_opcode_name (walk_state->opcode)); + union acpi_operand_object **operand = &walk_state->operands[0]; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_0T_0R", + acpi_ps_get_opcode_name(walk_state->opcode)); /* Examine the AML opcode */ switch (walk_state->opcode) { - case AML_RELEASE_OP: /* Release (mutex_object) */ + case AML_RELEASE_OP: /* Release (mutex_object) */ - status = acpi_ex_release_mutex (operand[0], walk_state); + status = acpi_ex_release_mutex(operand[0], walk_state); break; + case AML_RESET_OP: /* Reset (event_object) */ - case AML_RESET_OP: /* Reset (event_object) */ - - status = acpi_ex_system_reset_event (operand[0]); + status = acpi_ex_system_reset_event(operand[0]); break; + case AML_SIGNAL_OP: /* Signal (event_object) */ - case AML_SIGNAL_OP: /* Signal (event_object) */ - - status = acpi_ex_system_signal_event (operand[0]); + status = acpi_ex_system_signal_event(operand[0]); break; + case AML_SLEEP_OP: /* Sleep (msec_time) */ - case AML_SLEEP_OP: /* Sleep (msec_time) */ - - status = acpi_ex_system_do_suspend (operand[0]->integer.value); + status = acpi_ex_system_do_suspend(operand[0]->integer.value); break; + case AML_STALL_OP: /* Stall (usec_time) */ - case AML_STALL_OP: /* Stall (usec_time) */ - - status = acpi_ex_system_do_stall ((u32) operand[0]->integer.value); + status = + acpi_ex_system_do_stall((u32) operand[0]->integer.value); break; + case AML_UNLOAD_OP: /* Unload (Handle) */ - case AML_UNLOAD_OP: /* Unload (Handle) */ - - status = acpi_ex_unload_table (operand[0]); + status = acpi_ex_unload_table(operand[0]); break; + default: /* Unknown opcode */ - default: /* Unknown opcode */ - - ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); status = AE_AML_BAD_OPCODE; break; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_1A_1T_0R @@ -232,41 +209,34 @@ acpi_ex_opcode_1A_0T_0R ( * ******************************************************************************/ -acpi_status -acpi_ex_opcode_1A_1T_0R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - union acpi_operand_object **operand = &walk_state->operands[0]; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_0R", - acpi_ps_get_opcode_name (walk_state->opcode)); + acpi_status status = AE_OK; + union acpi_operand_object **operand = &walk_state->operands[0]; + ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_1T_0R", + acpi_ps_get_opcode_name(walk_state->opcode)); /* Examine the AML opcode */ switch (walk_state->opcode) { case AML_LOAD_OP: - status = acpi_ex_load_op (operand[0], operand[1], walk_state); + status = acpi_ex_load_op(operand[0], operand[1], walk_state); break; - default: /* Unknown opcode */ + default: /* Unknown opcode */ - ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n", walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } + cleanup: -cleanup: - - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_1A_1T_1R @@ -280,23 +250,19 @@ cleanup: * ******************************************************************************/ -acpi_status -acpi_ex_opcode_1A_1T_1R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - union acpi_operand_object **operand = &walk_state->operands[0]; - union acpi_operand_object *return_desc = NULL; - union acpi_operand_object *return_desc2 = NULL; - u32 temp32; - u32 i; - acpi_integer power_of_ten; - acpi_integer digit; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_1R", - acpi_ps_get_opcode_name (walk_state->opcode)); - + acpi_status status = AE_OK; + union acpi_operand_object **operand = &walk_state->operands[0]; + union acpi_operand_object *return_desc = NULL; + union acpi_operand_object *return_desc2 = NULL; + u32 temp32; + u32 i; + acpi_integer power_of_ten; + acpi_integer digit; + + ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_1T_1R", + acpi_ps_get_opcode_name(walk_state->opcode)); /* Examine the AML opcode */ @@ -310,20 +276,19 @@ acpi_ex_opcode_1A_1T_1R ( /* Create a return object of type Integer for these opcodes */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; } switch (walk_state->opcode) { - case AML_BIT_NOT_OP: /* Not (Operand, Result) */ + case AML_BIT_NOT_OP: /* Not (Operand, Result) */ return_desc->integer.value = ~operand[0]->integer.value; break; - - case AML_FIND_SET_LEFT_BIT_OP: /* find_set_left_bit (Operand, Result) */ + case AML_FIND_SET_LEFT_BIT_OP: /* find_set_left_bit (Operand, Result) */ return_desc->integer.value = operand[0]->integer.value; @@ -332,15 +297,14 @@ acpi_ex_opcode_1A_1T_1R ( * endian unsigned value, so this boundary condition is valid. */ for (temp32 = 0; return_desc->integer.value && - temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) { + temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) { return_desc->integer.value >>= 1; } return_desc->integer.value = temp32; break; - - case AML_FIND_SET_RIGHT_BIT_OP: /* find_set_right_bit (Operand, Result) */ + case AML_FIND_SET_RIGHT_BIT_OP: /* find_set_right_bit (Operand, Result) */ return_desc->integer.value = operand[0]->integer.value; @@ -349,18 +313,17 @@ acpi_ex_opcode_1A_1T_1R ( * endian unsigned value, so this boundary condition is valid. */ for (temp32 = 0; return_desc->integer.value && - temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) { + temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) { return_desc->integer.value <<= 1; } /* Since the bit position is one-based, subtract from 33 (65) */ return_desc->integer.value = temp32 == 0 ? 0 : - (ACPI_INTEGER_BIT_SIZE + 1) - temp32; + (ACPI_INTEGER_BIT_SIZE + 1) - temp32; break; - - case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */ + case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */ /* * The 64-bit ACPI integer can hold 16 4-bit BCD characters @@ -373,7 +336,9 @@ acpi_ex_opcode_1A_1T_1R ( /* Convert each BCD digit (each is one nybble wide) */ - for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) { + for (i = 0; + (i < acpi_gbl_integer_nybble_width) && (digit > 0); + i++) { /* Get the least significant 4-bit BCD digit */ temp32 = ((u32) digit) & 0xF; @@ -381,9 +346,9 @@ acpi_ex_opcode_1A_1T_1R ( /* Check the range of the digit */ if (temp32 > 9) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "BCD digit too large (not decimal): 0x%X\n", - temp32)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "BCD digit too large (not decimal): 0x%X\n", + temp32)); status = AE_AML_NUMERIC_OVERFLOW; goto cleanup; @@ -391,8 +356,8 @@ acpi_ex_opcode_1A_1T_1R ( /* Sum the digit into the result with the current power of 10 */ - return_desc->integer.value += (((acpi_integer) temp32) * - power_of_ten); + return_desc->integer.value += + (((acpi_integer) temp32) * power_of_ten); /* Shift to next BCD digit */ @@ -404,45 +369,50 @@ acpi_ex_opcode_1A_1T_1R ( } break; - - case AML_TO_BCD_OP: /* to_bcd (Operand, Result) */ + case AML_TO_BCD_OP: /* to_bcd (Operand, Result) */ return_desc->integer.value = 0; digit = operand[0]->integer.value; /* Each BCD digit is one nybble wide */ - for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) { - (void) acpi_ut_short_divide (digit, 10, &digit, &temp32); + for (i = 0; + (i < acpi_gbl_integer_nybble_width) && (digit > 0); + i++) { + (void)acpi_ut_short_divide(digit, 10, &digit, + &temp32); /* * Insert the BCD digit that resides in the * remainder from above */ - return_desc->integer.value |= (((acpi_integer) temp32) << - ACPI_MUL_4 (i)); + return_desc->integer.value |= + (((acpi_integer) temp32) << ACPI_MUL_4(i)); } /* Overflow if there is any data left in Digit */ if (digit > 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Integer too large to convert to BCD: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (operand[0]->integer.value))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Integer too large to convert to BCD: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64(operand + [0]-> + integer. + value))); status = AE_AML_NUMERIC_OVERFLOW; goto cleanup; } break; - - case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */ + case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */ /* * This op is a little strange because the internal return value is * different than the return value stored in the result descriptor * (There are really two return values) */ - if ((struct acpi_namespace_node *) operand[0] == acpi_gbl_root_node) { + if ((struct acpi_namespace_node *)operand[0] == + acpi_gbl_root_node) { /* * This means that the object does not exist in the namespace, * return FALSE @@ -453,38 +423,38 @@ acpi_ex_opcode_1A_1T_1R ( /* Get the object reference, store it, and remove our reference */ - status = acpi_ex_get_object_reference (operand[0], - &return_desc2, walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ex_get_object_reference(operand[0], + &return_desc2, + walk_state); + if (ACPI_FAILURE(status)) { goto cleanup; } - status = acpi_ex_store (return_desc2, operand[1], walk_state); - acpi_ut_remove_reference (return_desc2); + status = + acpi_ex_store(return_desc2, operand[1], walk_state); + acpi_ut_remove_reference(return_desc2); /* The object exists in the namespace, return TRUE */ return_desc->integer.value = ACPI_INTEGER_MAX; goto cleanup; - default: /* No other opcodes get here */ break; } break; - - case AML_STORE_OP: /* Store (Source, Target) */ + case AML_STORE_OP: /* Store (Source, Target) */ /* * A store operand is typically a number, string, buffer or lvalue * Be careful about deleting the source object, * since the object itself may have been stored. */ - status = acpi_ex_store (operand[0], operand[1], walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_store(operand[0], operand[1], walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* It is possible that the Store already produced a return object */ @@ -497,92 +467,84 @@ acpi_ex_opcode_1A_1T_1R ( * cancel out, and we simply don't do anything. */ walk_state->result_obj = operand[0]; - walk_state->operands[0] = NULL; /* Prevent deletion */ + walk_state->operands[0] = NULL; /* Prevent deletion */ } - return_ACPI_STATUS (status); - + return_ACPI_STATUS(status); - /* - * ACPI 2.0 Opcodes - */ - case AML_COPY_OP: /* Copy (Source, Target) */ + /* + * ACPI 2.0 Opcodes + */ + case AML_COPY_OP: /* Copy (Source, Target) */ - status = acpi_ut_copy_iobject_to_iobject (operand[0], &return_desc, - walk_state); + status = + acpi_ut_copy_iobject_to_iobject(operand[0], &return_desc, + walk_state); break; + case AML_TO_DECSTRING_OP: /* to_decimal_string (Data, Result) */ - case AML_TO_DECSTRING_OP: /* to_decimal_string (Data, Result) */ - - status = acpi_ex_convert_to_string (operand[0], &return_desc, - ACPI_EXPLICIT_CONVERT_DECIMAL); + status = acpi_ex_convert_to_string(operand[0], &return_desc, + ACPI_EXPLICIT_CONVERT_DECIMAL); if (return_desc == operand[0]) { /* No conversion performed, add ref to handle return value */ - acpi_ut_add_reference (return_desc); + acpi_ut_add_reference(return_desc); } break; + case AML_TO_HEXSTRING_OP: /* to_hex_string (Data, Result) */ - case AML_TO_HEXSTRING_OP: /* to_hex_string (Data, Result) */ - - status = acpi_ex_convert_to_string (operand[0], &return_desc, - ACPI_EXPLICIT_CONVERT_HEX); + status = acpi_ex_convert_to_string(operand[0], &return_desc, + ACPI_EXPLICIT_CONVERT_HEX); if (return_desc == operand[0]) { /* No conversion performed, add ref to handle return value */ - acpi_ut_add_reference (return_desc); + acpi_ut_add_reference(return_desc); } break; + case AML_TO_BUFFER_OP: /* to_buffer (Data, Result) */ - case AML_TO_BUFFER_OP: /* to_buffer (Data, Result) */ - - status = acpi_ex_convert_to_buffer (operand[0], &return_desc); + status = acpi_ex_convert_to_buffer(operand[0], &return_desc); if (return_desc == operand[0]) { /* No conversion performed, add ref to handle return value */ - acpi_ut_add_reference (return_desc); + acpi_ut_add_reference(return_desc); } break; + case AML_TO_INTEGER_OP: /* to_integer (Data, Result) */ - case AML_TO_INTEGER_OP: /* to_integer (Data, Result) */ - - status = acpi_ex_convert_to_integer (operand[0], &return_desc, - ACPI_ANY_BASE); + status = acpi_ex_convert_to_integer(operand[0], &return_desc, + ACPI_ANY_BASE); if (return_desc == operand[0]) { /* No conversion performed, add ref to handle return value */ - acpi_ut_add_reference (return_desc); + acpi_ut_add_reference(return_desc); } break; - - case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */ - case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */ + case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */ + case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */ /* These are two obsolete opcodes */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "%s is obsolete and not implemented\n", - acpi_ps_get_opcode_name (walk_state->opcode))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "%s is obsolete and not implemented\n", + acpi_ps_get_opcode_name(walk_state->opcode))); status = AE_SUPPORT; goto cleanup; + default: /* Unknown opcode */ - default: /* Unknown opcode */ - - ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n", walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { /* Store the return value computed above into the target object */ - status = acpi_ex_store (return_desc, operand[1], walk_state); + status = acpi_ex_store(return_desc, operand[1], walk_state); } - -cleanup: + cleanup: if (!walk_state->result_obj) { walk_state->result_obj = return_desc; @@ -590,14 +552,13 @@ cleanup: /* Delete return object on error */ - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (return_desc); + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference(return_desc); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_1A_0T_1R @@ -610,28 +571,24 @@ cleanup: * ******************************************************************************/ -acpi_status -acpi_ex_opcode_1A_0T_1R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - union acpi_operand_object *temp_desc; - union acpi_operand_object *return_desc = NULL; - acpi_status status = AE_OK; - u32 type; - acpi_integer value; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_1R", - acpi_ps_get_opcode_name (walk_state->opcode)); + union acpi_operand_object **operand = &walk_state->operands[0]; + union acpi_operand_object *temp_desc; + union acpi_operand_object *return_desc = NULL; + acpi_status status = AE_OK; + u32 type; + acpi_integer value; + ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_0T_1R", + acpi_ps_get_opcode_name(walk_state->opcode)); /* Examine the AML opcode */ switch (walk_state->opcode) { - case AML_LNOT_OP: /* LNot (Operand) */ + case AML_LNOT_OP: /* LNot (Operand) */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -646,15 +603,14 @@ acpi_ex_opcode_1A_0T_1R ( } break; - - case AML_DECREMENT_OP: /* Decrement (Operand) */ - case AML_INCREMENT_OP: /* Increment (Operand) */ + case AML_DECREMENT_OP: /* Decrement (Operand) */ + case AML_INCREMENT_OP: /* Increment (Operand) */ /* * Create a new integer. Can't just get the base integer and * increment it because it may be an Arg or Field. */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -665,10 +621,11 @@ acpi_ex_opcode_1A_0T_1R ( * NS Node or an internal object. */ temp_desc = operand[0]; - if (ACPI_GET_DESCRIPTOR_TYPE (temp_desc) == ACPI_DESC_TYPE_OPERAND) { + if (ACPI_GET_DESCRIPTOR_TYPE(temp_desc) == + ACPI_DESC_TYPE_OPERAND) { /* Internal reference object - prevent deletion */ - acpi_ut_add_reference (temp_desc); + acpi_ut_add_reference(temp_desc); } /* @@ -678,11 +635,15 @@ acpi_ex_opcode_1A_0T_1R ( * NOTE: We use LNOT_OP here in order to force resolution of the * reference operand to an actual integer. */ - status = acpi_ex_resolve_operands (AML_LNOT_OP, &temp_desc, walk_state); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n", - acpi_ps_get_opcode_name (walk_state->opcode), - acpi_format_exception(status))); + status = + acpi_ex_resolve_operands(AML_LNOT_OP, &temp_desc, + walk_state); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "%s: bad operand(s) %s\n", + acpi_ps_get_opcode_name(walk_state-> + opcode), + acpi_format_exception(status))); goto cleanup; } @@ -692,25 +653,25 @@ acpi_ex_opcode_1A_0T_1R ( * Perform the actual increment or decrement */ if (walk_state->opcode == AML_INCREMENT_OP) { - return_desc->integer.value = temp_desc->integer.value +1; - } - else { - return_desc->integer.value = temp_desc->integer.value -1; + return_desc->integer.value = + temp_desc->integer.value + 1; + } else { + return_desc->integer.value = + temp_desc->integer.value - 1; } /* Finished with this Integer object */ - acpi_ut_remove_reference (temp_desc); + acpi_ut_remove_reference(temp_desc); /* * Store the result back (indirectly) through the original * Reference object */ - status = acpi_ex_store (return_desc, operand[0], walk_state); + status = acpi_ex_store(return_desc, operand[0], walk_state); break; - - case AML_TYPE_OP: /* object_type (source_object) */ + case AML_TYPE_OP: /* object_type (source_object) */ /* * Note: The operand is not resolved at this point because we want to @@ -721,13 +682,15 @@ acpi_ex_opcode_1A_0T_1R ( /* Get the type of the base object */ - status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, NULL); - if (ACPI_FAILURE (status)) { + status = + acpi_ex_resolve_multiple(walk_state, operand[0], &type, + NULL); + if (ACPI_FAILURE(status)) { goto cleanup; } /* Allocate a descriptor to hold the type. */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -736,8 +699,7 @@ acpi_ex_opcode_1A_0T_1R ( return_desc->integer.value = type; break; - - case AML_SIZE_OF_OP: /* size_of (source_object) */ + case AML_SIZE_OF_OP: /* size_of (source_object) */ /* * Note: The operand is not resolved at this point because we want to @@ -746,9 +708,10 @@ acpi_ex_opcode_1A_0T_1R ( /* Get the base object */ - status = acpi_ex_resolve_multiple (walk_state, - operand[0], &type, &temp_desc); - if (ACPI_FAILURE (status)) { + status = acpi_ex_resolve_multiple(walk_state, + operand[0], &type, + &temp_desc); + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -779,9 +742,9 @@ acpi_ex_opcode_1A_0T_1R ( break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "size_of - Operand is not Buf/Int/Str/Pkg - found type %s\n", - acpi_ut_get_type_name (type))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "size_of - Operand is not Buf/Int/Str/Pkg - found type %s\n", + acpi_ut_get_type_name(type))); status = AE_AML_OPERAND_TYPE; goto cleanup; } @@ -790,7 +753,7 @@ acpi_ex_opcode_1A_0T_1R ( * Now that we have the size of the object, create a result * object to hold the value */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -799,22 +762,23 @@ acpi_ex_opcode_1A_0T_1R ( return_desc->integer.value = value; break; + case AML_REF_OF_OP: /* ref_of (source_object) */ - case AML_REF_OF_OP: /* ref_of (source_object) */ - - status = acpi_ex_get_object_reference (operand[0], &return_desc, walk_state); - if (ACPI_FAILURE (status)) { + status = + acpi_ex_get_object_reference(operand[0], &return_desc, + walk_state); + if (ACPI_FAILURE(status)) { goto cleanup; } break; - - case AML_DEREF_OF_OP: /* deref_of (obj_reference | String) */ + case AML_DEREF_OF_OP: /* deref_of (obj_reference | String) */ /* Check for a method local or argument, or standalone String */ - if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) != ACPI_DESC_TYPE_NAMED) { - switch (ACPI_GET_OBJECT_TYPE (operand[0])) { + if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) != + ACPI_DESC_TYPE_NAMED) { + switch (ACPI_GET_OBJECT_TYPE(operand[0])) { case ACPI_TYPE_LOCAL_REFERENCE: /* * This is a deref_of (local_x | arg_x) @@ -827,11 +791,12 @@ acpi_ex_opcode_1A_0T_1R ( /* Set Operand[0] to the value of the local/arg */ - status = acpi_ds_method_data_get_value ( - operand[0]->reference.opcode, - operand[0]->reference.offset, - walk_state, &temp_desc); - if (ACPI_FAILURE (status)) { + status = + acpi_ds_method_data_get_value + (operand[0]->reference.opcode, + operand[0]->reference.offset, + walk_state, &temp_desc); + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -839,7 +804,7 @@ acpi_ex_opcode_1A_0T_1R ( * Delete our reference to the input object and * point to the object just retrieved */ - acpi_ut_remove_reference (operand[0]); + acpi_ut_remove_reference(operand[0]); operand[0] = temp_desc; break; @@ -847,8 +812,9 @@ acpi_ex_opcode_1A_0T_1R ( /* Get the object to which the reference refers */ - temp_desc = operand[0]->reference.object; - acpi_ut_remove_reference (operand[0]); + temp_desc = + operand[0]->reference.object; + acpi_ut_remove_reference(operand[0]); operand[0] = temp_desc; break; @@ -859,7 +825,6 @@ acpi_ex_opcode_1A_0T_1R ( } break; - case ACPI_TYPE_STRING: /* @@ -870,22 +835,28 @@ acpi_ex_opcode_1A_0T_1R ( * 2) Dereference the node to an actual object. Could be a * Field, so we need to resolve the node to a value. */ - status = acpi_ns_get_node_by_path (operand[0]->string.pointer, - walk_state->scope_info->scope.node, - ACPI_NS_SEARCH_PARENT, - ACPI_CAST_INDIRECT_PTR ( - struct acpi_namespace_node, &return_desc)); - if (ACPI_FAILURE (status)) { + status = + acpi_ns_get_node_by_path(operand[0]->string. + pointer, + walk_state-> + scope_info->scope. + node, + ACPI_NS_SEARCH_PARENT, + ACPI_CAST_INDIRECT_PTR + (struct + acpi_namespace_node, + &return_desc)); + if (ACPI_FAILURE(status)) { goto cleanup; } - status = acpi_ex_resolve_node_to_value ( - ACPI_CAST_INDIRECT_PTR ( - struct acpi_namespace_node, &return_desc), - walk_state); + status = + acpi_ex_resolve_node_to_value + (ACPI_CAST_INDIRECT_PTR + (struct acpi_namespace_node, &return_desc), + walk_state); goto cleanup; - default: status = AE_AML_OPERAND_TYPE; @@ -895,18 +866,20 @@ acpi_ex_opcode_1A_0T_1R ( /* Operand[0] may have changed from the code above */ - if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_NAMED) { + if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) == + ACPI_DESC_TYPE_NAMED) { /* * This is a deref_of (object_reference) * Get the actual object from the Node (This is the dereference). * This case may only happen when a local_x or arg_x is * dereferenced above. */ - return_desc = acpi_ns_get_attached_object ( - (struct acpi_namespace_node *) operand[0]); - acpi_ut_add_reference (return_desc); - } - else { + return_desc = acpi_ns_get_attached_object((struct + acpi_namespace_node + *) + operand[0]); + acpi_ut_add_reference(return_desc); + } else { /* * This must be a reference object produced by either the * Index() or ref_of() operator @@ -921,7 +894,8 @@ acpi_ex_opcode_1A_0T_1R ( switch (operand[0]->reference.target_type) { case ACPI_TYPE_BUFFER_FIELD: - temp_desc = operand[0]->reference.object; + temp_desc = + operand[0]->reference.object; /* * Create a new object that contains one element of the @@ -931,7 +905,9 @@ acpi_ex_opcode_1A_0T_1R ( * sub-buffer of the main buffer, it is only a pointer to a * single element (byte) of the buffer! */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = + acpi_ut_create_internal_object + (ACPI_TYPE_INTEGER); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -943,56 +919,63 @@ acpi_ex_opcode_1A_0T_1R ( * reference to the buffer itself. */ return_desc->integer.value = - temp_desc->buffer.pointer[operand[0]->reference.offset]; + temp_desc->buffer. + pointer[operand[0]->reference. + offset]; break; - case ACPI_TYPE_PACKAGE: /* * Return the referenced element of the package. We must * add another reference to the referenced object, however. */ - return_desc = *(operand[0]->reference.where); + return_desc = + *(operand[0]->reference.where); if (return_desc) { - acpi_ut_add_reference (return_desc); + acpi_ut_add_reference + (return_desc); } break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown Index target_type %X in obj %p\n", - operand[0]->reference.target_type, operand[0])); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown Index target_type %X in obj %p\n", + operand[0]->reference. + target_type, + operand[0])); status = AE_AML_OPERAND_TYPE; goto cleanup; } break; - case AML_REF_OF_OP: return_desc = operand[0]->reference.object; - if (ACPI_GET_DESCRIPTOR_TYPE (return_desc) == - ACPI_DESC_TYPE_NAMED) { + if (ACPI_GET_DESCRIPTOR_TYPE(return_desc) == + ACPI_DESC_TYPE_NAMED) { - return_desc = acpi_ns_get_attached_object ( - (struct acpi_namespace_node *) return_desc); + return_desc = + acpi_ns_get_attached_object((struct + acpi_namespace_node + *) + return_desc); } /* Add another reference to the object! */ - acpi_ut_add_reference (return_desc); + acpi_ut_add_reference(return_desc); break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown opcode in ref(%p) - %X\n", - operand[0], operand[0]->reference.opcode)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown opcode in ref(%p) - %X\n", + operand[0], + operand[0]->reference. + opcode)); status = AE_TYPE; goto cleanup; @@ -1000,25 +983,21 @@ acpi_ex_opcode_1A_0T_1R ( } break; - default: - ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } - -cleanup: + cleanup: /* Delete return object on error */ - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (return_desc); + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference(return_desc); } walk_state->result_obj = return_desc; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c index 7429032..8d70c6b 100644 --- a/drivers/acpi/executer/exoparg2.c +++ b/drivers/acpi/executer/exoparg2.c @@ -41,17 +41,14 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exoparg2") - +ACPI_MODULE_NAME("exoparg2") /*! * Naming convention for AML interpreter execution routines. @@ -74,8 +71,6 @@ * The AcpiExOpcode* functions are called via the Dispatcher component with * fully resolved operands. !*/ - - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_2A_0T_0R @@ -90,29 +85,24 @@ * ALLOCATION: Deletes both operands * ******************************************************************************/ - -acpi_status -acpi_ex_opcode_2A_0T_0R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - struct acpi_namespace_node *node; - u32 value; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_0T_0R", - acpi_ps_get_opcode_name (walk_state->opcode)); + union acpi_operand_object **operand = &walk_state->operands[0]; + struct acpi_namespace_node *node; + u32 value; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE_STR("ex_opcode_2A_0T_0R", + acpi_ps_get_opcode_name(walk_state->opcode)); /* Examine the opcode */ switch (walk_state->opcode) { - case AML_NOTIFY_OP: /* Notify (notify_object, notify_value) */ + case AML_NOTIFY_OP: /* Notify (notify_object, notify_value) */ /* The first operand is a namespace node */ - node = (struct acpi_namespace_node *) operand[0]; + node = (struct acpi_namespace_node *)operand[0]; /* Second value is the notify value */ @@ -120,15 +110,14 @@ acpi_ex_opcode_2A_0T_0R ( /* Are notifies allowed on this object? */ - if (!acpi_ev_is_notify_object (node)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unexpected notify object type [%s]\n", - acpi_ut_get_type_name (node->type))); + if (!acpi_ev_is_notify_object(node)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unexpected notify object type [%s]\n", + acpi_ut_get_type_name(node->type))); status = AE_AML_OPERAND_TYPE; break; } - #ifdef ACPI_GPE_NOTIFY_CHECK /* * GPE method wake/notify check. Here, we want to ensure that we @@ -144,12 +133,14 @@ acpi_ex_opcode_2A_0T_0R ( * If all three cases are true, this is a wake-only GPE that should * be disabled at runtime. */ - if (value == 2) /* device_wake */ { - status = acpi_ev_check_for_wake_only_gpe (walk_state->gpe_event_info); - if (ACPI_FAILURE (status)) { + if (value == 2) { /* device_wake */ + status = + acpi_ev_check_for_wake_only_gpe(walk_state-> + gpe_event_info); + if (ACPI_FAILURE(status)) { /* AE_WAKE_ONLY_GPE only error, means ignore this notify */ - return_ACPI_STATUS (AE_OK) + return_ACPI_STATUS(AE_OK) } } #endif @@ -161,21 +152,18 @@ acpi_ex_opcode_2A_0T_0R ( * from this thread -- because handlers may in turn run other * control methods. */ - status = acpi_ev_queue_notify_request (node, value); + status = acpi_ev_queue_notify_request(node, value); break; - default: - ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); status = AE_AML_BAD_OPCODE; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_2A_2T_1R @@ -189,19 +177,15 @@ acpi_ex_opcode_2A_0T_0R ( * ******************************************************************************/ -acpi_status -acpi_ex_opcode_2A_2T_1R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - union acpi_operand_object *return_desc1 = NULL; - union acpi_operand_object *return_desc2 = NULL; - acpi_status status; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_2T_1R", - acpi_ps_get_opcode_name (walk_state->opcode)); + union acpi_operand_object **operand = &walk_state->operands[0]; + union acpi_operand_object *return_desc1 = NULL; + union acpi_operand_object *return_desc2 = NULL; + acpi_status status; + ACPI_FUNCTION_TRACE_STR("ex_opcode_2A_2T_1R", + acpi_ps_get_opcode_name(walk_state->opcode)); /* Execute the opcode */ @@ -210,13 +194,15 @@ acpi_ex_opcode_2A_2T_1R ( /* Divide (Dividend, Divisor, remainder_result quotient_result) */ - return_desc1 = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc1 = + acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc1) { status = AE_NO_MEMORY; goto cleanup; } - return_desc2 = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc2 = + acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc2) { status = AE_NO_MEMORY; goto cleanup; @@ -224,33 +210,31 @@ acpi_ex_opcode_2A_2T_1R ( /* Quotient to return_desc1, remainder to return_desc2 */ - status = acpi_ut_divide (operand[0]->integer.value, - operand[1]->integer.value, - &return_desc1->integer.value, - &return_desc2->integer.value); - if (ACPI_FAILURE (status)) { + status = acpi_ut_divide(operand[0]->integer.value, + operand[1]->integer.value, + &return_desc1->integer.value, + &return_desc2->integer.value); + if (ACPI_FAILURE(status)) { goto cleanup; } break; - default: - ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n", walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } /* Store the results to the target reference operands */ - status = acpi_ex_store (return_desc2, operand[2], walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ex_store(return_desc2, operand[2], walk_state); + if (ACPI_FAILURE(status)) { goto cleanup; } - status = acpi_ex_store (return_desc1, operand[3], walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ex_store(return_desc1, operand[3], walk_state); + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -258,24 +242,22 @@ acpi_ex_opcode_2A_2T_1R ( walk_state->result_obj = return_desc1; - -cleanup: + cleanup: /* * Since the remainder is not returned indirectly, remove a reference to * it. Only the quotient is returned indirectly. */ - acpi_ut_remove_reference (return_desc2); + acpi_ut_remove_reference(return_desc2); - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { /* Delete the return object */ - acpi_ut_remove_reference (return_desc1); + acpi_ut_remove_reference(return_desc1); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_2A_1T_1R @@ -289,42 +271,39 @@ cleanup: * ******************************************************************************/ -acpi_status -acpi_ex_opcode_2A_1T_1R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - union acpi_operand_object *return_desc = NULL; - acpi_integer index; - acpi_status status = AE_OK; - acpi_size length; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_1T_1R", - acpi_ps_get_opcode_name (walk_state->opcode)); + union acpi_operand_object **operand = &walk_state->operands[0]; + union acpi_operand_object *return_desc = NULL; + acpi_integer index; + acpi_status status = AE_OK; + acpi_size length; + ACPI_FUNCTION_TRACE_STR("ex_opcode_2A_1T_1R", + acpi_ps_get_opcode_name(walk_state->opcode)); /* Execute the opcode */ if (walk_state->op_info->flags & AML_MATH) { /* All simple math opcodes (add, etc.) */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; } - return_desc->integer.value = acpi_ex_do_math_op (walk_state->opcode, - operand[0]->integer.value, - operand[1]->integer.value); + return_desc->integer.value = + acpi_ex_do_math_op(walk_state->opcode, + operand[0]->integer.value, + operand[1]->integer.value); goto store_result_to_target; } switch (walk_state->opcode) { - case AML_MOD_OP: /* Mod (Dividend, Divisor, remainder_result (ACPI 2.0) */ + case AML_MOD_OP: /* Mod (Dividend, Divisor, remainder_result (ACPI 2.0) */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -332,21 +311,18 @@ acpi_ex_opcode_2A_1T_1R ( /* return_desc will contain the remainder */ - status = acpi_ut_divide (operand[0]->integer.value, - operand[1]->integer.value, - NULL, - &return_desc->integer.value); + status = acpi_ut_divide(operand[0]->integer.value, + operand[1]->integer.value, + NULL, &return_desc->integer.value); break; + case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ - case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ - - status = acpi_ex_do_concatenate (operand[0], operand[1], - &return_desc, walk_state); + status = acpi_ex_do_concatenate(operand[0], operand[1], + &return_desc, walk_state); break; - - case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */ + case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */ /* * Input object is guaranteed to be a buffer at this point (it may have @@ -365,8 +341,8 @@ acpi_ex_opcode_2A_1T_1R ( */ length = 0; while ((length < operand[0]->buffer.length) && - (length < operand[1]->integer.value) && - (operand[0]->buffer.pointer[length])) { + (length < operand[1]->integer.value) && + (operand[0]->buffer.pointer[length])) { length++; if (length > ACPI_MAX_STRING_CONVERSION) { status = AE_AML_STRING_LIMIT; @@ -376,33 +352,32 @@ acpi_ex_opcode_2A_1T_1R ( /* Allocate a new string object */ - return_desc = acpi_ut_create_string_object (length); + return_desc = acpi_ut_create_string_object(length); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; } - /* Copy the raw buffer data with no transform. NULL terminated already*/ + /* Copy the raw buffer data with no transform. NULL terminated already */ - ACPI_MEMCPY (return_desc->string.pointer, - operand[0]->buffer.pointer, length); + ACPI_MEMCPY(return_desc->string.pointer, + operand[0]->buffer.pointer, length); break; - case AML_CONCAT_RES_OP: /* concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */ - status = acpi_ex_concat_template (operand[0], operand[1], - &return_desc, walk_state); + status = acpi_ex_concat_template(operand[0], operand[1], + &return_desc, walk_state); break; - - case AML_INDEX_OP: /* Index (Source Index Result) */ + case AML_INDEX_OP: /* Index (Source Index Result) */ /* Create the internal return object */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE); + return_desc = + acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -412,76 +387,75 @@ acpi_ex_opcode_2A_1T_1R ( /* At this point, the Source operand is a Package, Buffer, or String */ - if (ACPI_GET_OBJECT_TYPE (operand[0]) == ACPI_TYPE_PACKAGE) { + if (ACPI_GET_OBJECT_TYPE(operand[0]) == ACPI_TYPE_PACKAGE) { /* Object to be indexed is a Package */ if (index >= operand[0]->package.count) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index value (%X%8.8X) beyond package end (%X)\n", - ACPI_FORMAT_UINT64 (index), operand[0]->package.count)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Index value (%X%8.8X) beyond package end (%X)\n", + ACPI_FORMAT_UINT64(index), + operand[0]->package.count)); status = AE_AML_PACKAGE_LIMIT; goto cleanup; } return_desc->reference.target_type = ACPI_TYPE_PACKAGE; - return_desc->reference.object = operand[0]; - return_desc->reference.where = &operand[0]->package.elements [ - index]; - } - else { + return_desc->reference.object = operand[0]; + return_desc->reference.where = + &operand[0]->package.elements[index]; + } else { /* Object to be indexed is a Buffer/String */ if (index >= operand[0]->buffer.length) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index value (%X%8.8X) beyond end of buffer (%X)\n", - ACPI_FORMAT_UINT64 (index), operand[0]->buffer.length)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Index value (%X%8.8X) beyond end of buffer (%X)\n", + ACPI_FORMAT_UINT64(index), + operand[0]->buffer.length)); status = AE_AML_BUFFER_LIMIT; goto cleanup; } - return_desc->reference.target_type = ACPI_TYPE_BUFFER_FIELD; - return_desc->reference.object = operand[0]; + return_desc->reference.target_type = + ACPI_TYPE_BUFFER_FIELD; + return_desc->reference.object = operand[0]; } /* * Add a reference to the target package/buffer/string for the life * of the index. */ - acpi_ut_add_reference (operand[0]); + acpi_ut_add_reference(operand[0]); /* Complete the Index reference object */ - return_desc->reference.opcode = AML_INDEX_OP; - return_desc->reference.offset = (u32) index; + return_desc->reference.opcode = AML_INDEX_OP; + return_desc->reference.offset = (u32) index; /* Store the reference to the Target */ - status = acpi_ex_store (return_desc, operand[2], walk_state); + status = acpi_ex_store(return_desc, operand[2], walk_state); /* Return the reference */ walk_state->result_obj = return_desc; goto cleanup; - default: - ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n", walk_state->opcode)); status = AE_AML_BAD_OPCODE; break; } + store_result_to_target: -store_result_to_target: - - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { /* * Store the result of the operation (which is now in return_desc) into * the Target descriptor. */ - status = acpi_ex_store (return_desc, operand[2], walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ex_store(return_desc, operand[2], walk_state); + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -490,19 +464,17 @@ store_result_to_target: } } - -cleanup: + cleanup: /* Delete return object on error */ - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (return_desc); + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference(return_desc); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_2A_0T_1R @@ -515,23 +487,19 @@ cleanup: * ******************************************************************************/ -acpi_status -acpi_ex_opcode_2A_0T_1R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - union acpi_operand_object *return_desc = NULL; - acpi_status status = AE_OK; - u8 logical_result = FALSE; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_0T_1R", - acpi_ps_get_opcode_name (walk_state->opcode)); + union acpi_operand_object **operand = &walk_state->operands[0]; + union acpi_operand_object *return_desc = NULL; + acpi_status status = AE_OK; + u8 logical_result = FALSE; + ACPI_FUNCTION_TRACE_STR("ex_opcode_2A_0T_1R", + acpi_ps_get_opcode_name(walk_state->opcode)); /* Create the internal return object */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -542,50 +510,48 @@ acpi_ex_opcode_2A_0T_1R ( if (walk_state->op_info->flags & AML_LOGICAL_NUMERIC) { /* logical_op (Operand0, Operand1) */ - status = acpi_ex_do_logical_numeric_op (walk_state->opcode, - operand[0]->integer.value, operand[1]->integer.value, - &logical_result); + status = acpi_ex_do_logical_numeric_op(walk_state->opcode, + operand[0]->integer. + value, + operand[1]->integer. + value, &logical_result); goto store_logical_result; - } - else if (walk_state->op_info->flags & AML_LOGICAL) { + } else if (walk_state->op_info->flags & AML_LOGICAL) { /* logical_op (Operand0, Operand1) */ - status = acpi_ex_do_logical_op (walk_state->opcode, operand[0], - operand[1], &logical_result); + status = acpi_ex_do_logical_op(walk_state->opcode, operand[0], + operand[1], &logical_result); goto store_logical_result; } switch (walk_state->opcode) { - case AML_ACQUIRE_OP: /* Acquire (mutex_object, Timeout) */ + case AML_ACQUIRE_OP: /* Acquire (mutex_object, Timeout) */ - status = acpi_ex_acquire_mutex (operand[1], operand[0], walk_state); + status = + acpi_ex_acquire_mutex(operand[1], operand[0], walk_state); if (status == AE_TIME) { - logical_result = TRUE; /* TRUE = Acquire timed out */ + logical_result = TRUE; /* TRUE = Acquire timed out */ status = AE_OK; } break; + case AML_WAIT_OP: /* Wait (event_object, Timeout) */ - case AML_WAIT_OP: /* Wait (event_object, Timeout) */ - - status = acpi_ex_system_wait_event (operand[1], operand[0]); + status = acpi_ex_system_wait_event(operand[1], operand[0]); if (status == AE_TIME) { - logical_result = TRUE; /* TRUE, Wait timed out */ + logical_result = TRUE; /* TRUE, Wait timed out */ status = AE_OK; } break; - default: - ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } - -store_logical_result: + store_logical_result: /* * Set return value to according to logical_result. logical TRUE (all ones) * Default is FALSE (zero) @@ -596,16 +562,13 @@ store_logical_result: walk_state->result_obj = return_desc; - -cleanup: + cleanup: /* Delete return object on error */ - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (return_desc); + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference(return_desc); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c index 197890f..4833657 100644 --- a/drivers/acpi/executer/exoparg3.c +++ b/drivers/acpi/executer/exoparg3.c @@ -42,16 +42,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exoparg3") - +ACPI_MODULE_NAME("exoparg3") /*! * Naming convention for AML interpreter execution routines. @@ -74,8 +71,6 @@ * The AcpiExOpcode* functions are called via the Dispatcher component with * fully resolved operands. !*/ - - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_3A_0T_0R @@ -87,61 +82,53 @@ * DESCRIPTION: Execute Triadic operator (3 operands) * ******************************************************************************/ - -acpi_status -acpi_ex_opcode_3A_0T_0R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - struct acpi_signal_fatal_info *fatal; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_0T_0R", - acpi_ps_get_opcode_name (walk_state->opcode)); + union acpi_operand_object **operand = &walk_state->operands[0]; + struct acpi_signal_fatal_info *fatal; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE_STR("ex_opcode_3A_0T_0R", + acpi_ps_get_opcode_name(walk_state->opcode)); switch (walk_state->opcode) { - case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */ + case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "fatal_op: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", - (u32) operand[0]->integer.value, - (u32) operand[1]->integer.value, - (u32) operand[2]->integer.value)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "fatal_op: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", + (u32) operand[0]->integer.value, + (u32) operand[1]->integer.value, + (u32) operand[2]->integer.value)); - fatal = ACPI_MEM_ALLOCATE (sizeof (struct acpi_signal_fatal_info)); + fatal = + ACPI_MEM_ALLOCATE(sizeof(struct acpi_signal_fatal_info)); if (fatal) { - fatal->type = (u32) operand[0]->integer.value; - fatal->code = (u32) operand[1]->integer.value; + fatal->type = (u32) operand[0]->integer.value; + fatal->code = (u32) operand[1]->integer.value; fatal->argument = (u32) operand[2]->integer.value; } /* Always signal the OS! */ - status = acpi_os_signal (ACPI_SIGNAL_FATAL, fatal); + status = acpi_os_signal(ACPI_SIGNAL_FATAL, fatal); /* Might return while OS is shutting down, just continue */ - ACPI_MEM_FREE (fatal); + ACPI_MEM_FREE(fatal); break; - default: - ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_REPORT_ERROR(("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } + cleanup: -cleanup: - - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_3A_1T_1R @@ -154,31 +141,28 @@ cleanup: * ******************************************************************************/ -acpi_status -acpi_ex_opcode_3A_1T_1R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - union acpi_operand_object *return_desc = NULL; - char *buffer = NULL; - acpi_status status = AE_OK; - acpi_integer index; - acpi_size length; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_1T_1R", - acpi_ps_get_opcode_name (walk_state->opcode)); + union acpi_operand_object **operand = &walk_state->operands[0]; + union acpi_operand_object *return_desc = NULL; + char *buffer = NULL; + acpi_status status = AE_OK; + acpi_integer index; + acpi_size length; + ACPI_FUNCTION_TRACE_STR("ex_opcode_3A_1T_1R", + acpi_ps_get_opcode_name(walk_state->opcode)); switch (walk_state->opcode) { - case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ + case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ /* * Create the return object. The Source operand is guaranteed to be * either a String or a Buffer, so just use its type. */ - return_desc = acpi_ut_create_internal_object ( - ACPI_GET_OBJECT_TYPE (operand[0])); + return_desc = + acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE + (operand[0])); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -201,17 +185,17 @@ acpi_ex_opcode_3A_1T_1R ( else if ((index + length) > operand[0]->string.length) { length = (acpi_size) operand[0]->string.length - - (acpi_size) index; + (acpi_size) index; } /* Strings always have a sub-pointer, not so for buffers */ - switch (ACPI_GET_OBJECT_TYPE (operand[0])) { + switch (ACPI_GET_OBJECT_TYPE(operand[0])) { case ACPI_TYPE_STRING: /* Always allocate a new buffer for the String */ - buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1); + buffer = ACPI_MEM_CALLOCATE((acpi_size) length + 1); if (!buffer) { status = AE_NO_MEMORY; goto cleanup; @@ -225,7 +209,7 @@ acpi_ex_opcode_3A_1T_1R ( if (length > 0) { /* Allocate a new buffer for the Buffer */ - buffer = ACPI_MEM_CALLOCATE (length); + buffer = ACPI_MEM_CALLOCATE(length); if (!buffer) { status = AE_NO_MEMORY; goto cleanup; @@ -233,7 +217,7 @@ acpi_ex_opcode_3A_1T_1R ( } break; - default: /* Should not happen */ + default: /* Should not happen */ status = AE_AML_OPERAND_TYPE; goto cleanup; @@ -242,8 +226,8 @@ acpi_ex_opcode_3A_1T_1R ( if (length > 0) { /* Copy the portion requested */ - ACPI_MEMCPY (buffer, operand[0]->string.pointer + index, - length); + ACPI_MEMCPY(buffer, operand[0]->string.pointer + index, + length); } /* Set the length of the new String/Buffer */ @@ -256,25 +240,23 @@ acpi_ex_opcode_3A_1T_1R ( return_desc->buffer.flags |= AOPOBJ_DATA_VALID; break; - default: - ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_REPORT_ERROR(("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } /* Store the result in the target */ - status = acpi_ex_store (return_desc, operand[3], walk_state); + status = acpi_ex_store(return_desc, operand[3], walk_state); -cleanup: + cleanup: /* Delete return object on error */ - if (ACPI_FAILURE (status) || walk_state->result_obj) { - acpi_ut_remove_reference (return_desc); + if (ACPI_FAILURE(status) || walk_state->result_obj) { + acpi_ut_remove_reference(return_desc); } /* Set the return object and exit */ @@ -282,7 +264,5 @@ cleanup: else { walk_state->result_obj = return_desc; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/exoparg6.c b/drivers/acpi/executer/exoparg6.c index 17f81d4..5dee771 100644 --- a/drivers/acpi/executer/exoparg6.c +++ b/drivers/acpi/executer/exoparg6.c @@ -42,16 +42,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exoparg6") - +ACPI_MODULE_NAME("exoparg6") /*! * Naming convention for AML interpreter execution routines. @@ -74,15 +71,11 @@ * The AcpiExOpcode* functions are called via the Dispatcher component with * fully resolved operands. !*/ - /* Local prototypes */ - static u8 -acpi_ex_do_match ( - u32 match_op, - union acpi_operand_object *package_obj, - union acpi_operand_object *match_obj); - +acpi_ex_do_match(u32 match_op, + union acpi_operand_object *package_obj, + union acpi_operand_object *match_obj); /******************************************************************************* * @@ -101,14 +94,12 @@ acpi_ex_do_match ( ******************************************************************************/ static u8 -acpi_ex_do_match ( - u32 match_op, - union acpi_operand_object *package_obj, - union acpi_operand_object *match_obj) +acpi_ex_do_match(u32 match_op, + union acpi_operand_object *package_obj, + union acpi_operand_object *match_obj) { - u8 logical_result = TRUE; - acpi_status status; - + u8 logical_result = TRUE; + acpi_status status; /* * Note: Since the package_obj/match_obj ordering is opposite to that of @@ -133,9 +124,10 @@ acpi_ex_do_match ( * True if equal: (P[i] == M) * Change to: (M == P[i]) */ - status = acpi_ex_do_logical_op (AML_LEQUAL_OP, match_obj, package_obj, - &logical_result); - if (ACPI_FAILURE (status)) { + status = + acpi_ex_do_logical_op(AML_LEQUAL_OP, match_obj, package_obj, + &logical_result); + if (ACPI_FAILURE(status)) { return (FALSE); } break; @@ -146,12 +138,13 @@ acpi_ex_do_match ( * True if less than or equal: (P[i] <= M) (P[i] not_greater than M) * Change to: (M >= P[i]) (M not_less than P[i]) */ - status = acpi_ex_do_logical_op (AML_LLESS_OP, match_obj, package_obj, - &logical_result); - if (ACPI_FAILURE (status)) { + status = + acpi_ex_do_logical_op(AML_LLESS_OP, match_obj, package_obj, + &logical_result); + if (ACPI_FAILURE(status)) { return (FALSE); } - logical_result = (u8) !logical_result; + logical_result = (u8) ! logical_result; break; case MATCH_MLT: @@ -160,9 +153,10 @@ acpi_ex_do_match ( * True if less than: (P[i] < M) * Change to: (M > P[i]) */ - status = acpi_ex_do_logical_op (AML_LGREATER_OP, match_obj, package_obj, - &logical_result); - if (ACPI_FAILURE (status)) { + status = + acpi_ex_do_logical_op(AML_LGREATER_OP, match_obj, + package_obj, &logical_result); + if (ACPI_FAILURE(status)) { return (FALSE); } break; @@ -173,12 +167,13 @@ acpi_ex_do_match ( * True if greater than or equal: (P[i] >= M) (P[i] not_less than M) * Change to: (M <= P[i]) (M not_greater than P[i]) */ - status = acpi_ex_do_logical_op (AML_LGREATER_OP, match_obj, package_obj, - &logical_result); - if (ACPI_FAILURE (status)) { + status = + acpi_ex_do_logical_op(AML_LGREATER_OP, match_obj, + package_obj, &logical_result); + if (ACPI_FAILURE(status)) { return (FALSE); } - logical_result = (u8)!logical_result; + logical_result = (u8) ! logical_result; break; case MATCH_MGT: @@ -187,9 +182,10 @@ acpi_ex_do_match ( * True if greater than: (P[i] > M) * Change to: (M < P[i]) */ - status = acpi_ex_do_logical_op (AML_LLESS_OP, match_obj, package_obj, - &logical_result); - if (ACPI_FAILURE (status)) { + status = + acpi_ex_do_logical_op(AML_LLESS_OP, match_obj, package_obj, + &logical_result); + if (ACPI_FAILURE(status)) { return (FALSE); } break; @@ -204,7 +200,6 @@ acpi_ex_do_match ( return logical_result; } - /******************************************************************************* * * FUNCTION: acpi_ex_opcode_6A_0T_1R @@ -217,20 +212,16 @@ acpi_ex_do_match ( * ******************************************************************************/ -acpi_status -acpi_ex_opcode_6A_0T_1R ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) { - union acpi_operand_object **operand = &walk_state->operands[0]; - union acpi_operand_object *return_desc = NULL; - acpi_status status = AE_OK; - acpi_integer index; - union acpi_operand_object *this_element; - - - ACPI_FUNCTION_TRACE_STR ("ex_opcode_6A_0T_1R", - acpi_ps_get_opcode_name (walk_state->opcode)); + union acpi_operand_object **operand = &walk_state->operands[0]; + union acpi_operand_object *return_desc = NULL; + acpi_status status = AE_OK; + acpi_integer index; + union acpi_operand_object *this_element; + ACPI_FUNCTION_TRACE_STR("ex_opcode_6A_0T_1R", + acpi_ps_get_opcode_name(walk_state->opcode)); switch (walk_state->opcode) { case AML_MATCH_OP: @@ -242,8 +233,9 @@ acpi_ex_opcode_6A_0T_1R ( /* Validate both Match Term Operators (MTR, MEQ, etc.) */ if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) || - (operand[3]->integer.value > MAX_MATCH_OPERATOR)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Match operator out of range\n")); + (operand[3]->integer.value > MAX_MATCH_OPERATOR)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Match operator out of range\n")); status = AE_AML_OPERAND_VALUE; goto cleanup; } @@ -252,16 +244,17 @@ acpi_ex_opcode_6A_0T_1R ( index = operand[5]->integer.value; if (index >= operand[0]->package.count) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index (%X%8.8X) beyond package end (%X)\n", - ACPI_FORMAT_UINT64 (index), operand[0]->package.count)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Index (%X%8.8X) beyond package end (%X)\n", + ACPI_FORMAT_UINT64(index), + operand[0]->package.count)); status = AE_AML_PACKAGE_LIMIT; goto cleanup; } /* Create an integer for the return value */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -283,7 +276,7 @@ acpi_ex_opcode_6A_0T_1R ( * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no * match was found. */ - for ( ; index < operand[0]->package.count; index++) { + for (; index < operand[0]->package.count; index++) { /* Get the current package element */ this_element = operand[0]->package.elements[index]; @@ -299,13 +292,13 @@ acpi_ex_opcode_6A_0T_1R ( * (proceed to next iteration of enclosing for loop) signifies a * non-match. */ - if (!acpi_ex_do_match ((u32) operand[1]->integer.value, - this_element, operand[2])) { + if (!acpi_ex_do_match((u32) operand[1]->integer.value, + this_element, operand[2])) { continue; } - if (!acpi_ex_do_match ((u32) operand[3]->integer.value, - this_element, operand[4])) { + if (!acpi_ex_do_match((u32) operand[3]->integer.value, + this_element, operand[4])) { continue; } @@ -316,31 +309,27 @@ acpi_ex_opcode_6A_0T_1R ( } break; - case AML_LOAD_TABLE_OP: - status = acpi_ex_load_table_op (walk_state, &return_desc); + status = acpi_ex_load_table_op(walk_state, &return_desc); break; - default: - ACPI_REPORT_ERROR (("acpi_ex_opcode_6A_0T_1R: Unknown opcode %X\n", - walk_state->opcode)); + ACPI_REPORT_ERROR(("acpi_ex_opcode_6A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } walk_state->result_obj = return_desc; - -cleanup: + cleanup: /* Delete return object on error */ - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (return_desc); + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference(return_desc); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c index c9e3c68..7476c36 100644 --- a/drivers/acpi/executer/exprep.c +++ b/drivers/acpi/executer/exprep.c @@ -42,32 +42,24 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exprep") +ACPI_MODULE_NAME("exprep") /* Local prototypes */ - static u32 -acpi_ex_decode_field_access ( - union acpi_operand_object *obj_desc, - u8 field_flags, - u32 *return_byte_alignment); - +acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, + u8 field_flags, u32 * return_byte_alignment); #ifdef ACPI_UNDER_DEVELOPMENT static u32 -acpi_ex_generate_access ( - u32 field_bit_offset, - u32 field_bit_length, - u32 region_length); +acpi_ex_generate_access(u32 field_bit_offset, + u32 field_bit_length, u32 region_length); /******************************************************************************* * @@ -92,39 +84,36 @@ acpi_ex_generate_access ( ******************************************************************************/ static u32 -acpi_ex_generate_access ( - u32 field_bit_offset, - u32 field_bit_length, - u32 region_length) +acpi_ex_generate_access(u32 field_bit_offset, + u32 field_bit_length, u32 region_length) { - u32 field_byte_length; - u32 field_byte_offset; - u32 field_byte_end_offset; - u32 access_byte_width; - u32 field_start_offset; - u32 field_end_offset; - u32 minimum_access_width = 0xFFFFFFFF; - u32 minimum_accesses = 0xFFFFFFFF; - u32 accesses; - - - ACPI_FUNCTION_TRACE ("ex_generate_access"); - + u32 field_byte_length; + u32 field_byte_offset; + u32 field_byte_end_offset; + u32 access_byte_width; + u32 field_start_offset; + u32 field_end_offset; + u32 minimum_access_width = 0xFFFFFFFF; + u32 minimum_accesses = 0xFFFFFFFF; + u32 accesses; + + ACPI_FUNCTION_TRACE("ex_generate_access"); /* Round Field start offset and length to "minimal" byte boundaries */ - field_byte_offset = ACPI_DIV_8 (ACPI_ROUND_DOWN (field_bit_offset, 8)); - field_byte_end_offset = ACPI_DIV_8 (ACPI_ROUND_UP (field_bit_length + - field_bit_offset, 8)); - field_byte_length = field_byte_end_offset - field_byte_offset; + field_byte_offset = ACPI_DIV_8(ACPI_ROUND_DOWN(field_bit_offset, 8)); + field_byte_end_offset = ACPI_DIV_8(ACPI_ROUND_UP(field_bit_length + + field_bit_offset, 8)); + field_byte_length = field_byte_end_offset - field_byte_offset; - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Bit length %d, Bit offset %d\n", - field_bit_length, field_bit_offset)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Bit length %d, Bit offset %d\n", + field_bit_length, field_bit_offset)); - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Byte Length %d, Byte Offset %d, End Offset %d\n", - field_byte_length, field_byte_offset, field_byte_end_offset)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Byte Length %d, Byte Offset %d, End Offset %d\n", + field_byte_length, field_byte_offset, + field_byte_end_offset)); /* * Iterative search for the maximum access width that is both aligned @@ -132,7 +121,8 @@ acpi_ex_generate_access ( * * Start at byte_acc and work upwards to qword_acc max. (1,2,4,8 bytes) */ - for (access_byte_width = 1; access_byte_width <= 8; access_byte_width <<= 1) { + for (access_byte_width = 1; access_byte_width <= 8; + access_byte_width <<= 1) { /* * 1) Round end offset up to next access boundary and make sure that * this does not go beyond the end of the parent region. @@ -140,31 +130,37 @@ acpi_ex_generate_access ( * are done. (This does not optimize for the perfectly aligned * case yet). */ - if (ACPI_ROUND_UP (field_byte_end_offset, access_byte_width) <= region_length) { + if (ACPI_ROUND_UP(field_byte_end_offset, access_byte_width) <= + region_length) { field_start_offset = - ACPI_ROUND_DOWN (field_byte_offset, access_byte_width) / - access_byte_width; + ACPI_ROUND_DOWN(field_byte_offset, + access_byte_width) / + access_byte_width; field_end_offset = - ACPI_ROUND_UP ((field_byte_length + field_byte_offset), - access_byte_width) / access_byte_width; + ACPI_ROUND_UP((field_byte_length + + field_byte_offset), + access_byte_width) / + access_byte_width; accesses = field_end_offset - field_start_offset; - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "access_width %d end is within region\n", access_byte_width)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "access_width %d end is within region\n", + access_byte_width)); - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Field Start %d, Field End %d -- requires %d accesses\n", - field_start_offset, field_end_offset, accesses)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Field Start %d, Field End %d -- requires %d accesses\n", + field_start_offset, field_end_offset, + accesses)); /* Single access is optimal */ if (accesses <= 1) { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Entire field can be accessed with one operation of size %d\n", - access_byte_width)); - return_VALUE (access_byte_width); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Entire field can be accessed with one operation of size %d\n", + access_byte_width)); + return_VALUE(access_byte_width); } /* @@ -172,30 +168,30 @@ acpi_ex_generate_access ( * try the next wider access on next iteration */ if (accesses < minimum_accesses) { - minimum_accesses = accesses; + minimum_accesses = accesses; minimum_access_width = access_byte_width; } - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "access_width %d end is NOT within region\n", access_byte_width)); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "access_width %d end is NOT within region\n", + access_byte_width)); if (access_byte_width == 1) { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Field goes beyond end-of-region!\n")); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Field goes beyond end-of-region!\n")); /* Field does not fit in the region at all */ - return_VALUE (0); + return_VALUE(0); } /* * This width goes beyond the end-of-region, back off to * previous access */ - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Backing off to previous optimal access width of %d\n", - minimum_access_width)); - return_VALUE (minimum_access_width); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Backing off to previous optimal access width of %d\n", + minimum_access_width)); + return_VALUE(minimum_access_width); } } @@ -203,12 +199,11 @@ acpi_ex_generate_access ( * Could not read/write field with one operation, * just use max access width */ - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Cannot access field in one operation, using width 8\n")); - return_VALUE (8); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Cannot access field in one operation, using width 8\n")); + return_VALUE(8); } -#endif /* ACPI_UNDER_DEVELOPMENT */ - +#endif /* ACPI_UNDER_DEVELOPMENT */ /******************************************************************************* * @@ -226,18 +221,14 @@ acpi_ex_generate_access ( ******************************************************************************/ static u32 -acpi_ex_decode_field_access ( - union acpi_operand_object *obj_desc, - u8 field_flags, - u32 *return_byte_alignment) +acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, + u8 field_flags, u32 * return_byte_alignment) { - u32 access; - u32 byte_alignment; - u32 bit_length; - - - ACPI_FUNCTION_TRACE ("ex_decode_field_access"); + u32 access; + u32 byte_alignment; + u32 bit_length; + ACPI_FUNCTION_TRACE("ex_decode_field_access"); access = (field_flags & AML_FIELD_ACCESS_TYPE_MASK); @@ -246,9 +237,12 @@ acpi_ex_decode_field_access ( #ifdef ACPI_UNDER_DEVELOPMENT byte_alignment = - acpi_ex_generate_access (obj_desc->common_field.start_field_bit_offset, - obj_desc->common_field.bit_length, - 0xFFFFFFFF /* Temp until we pass region_length as parameter */); + acpi_ex_generate_access(obj_desc->common_field. + start_field_bit_offset, + obj_desc->common_field.bit_length, + 0xFFFFFFFF + /* Temp until we pass region_length as parameter */ + ); bit_length = byte_alignment * 8; #endif @@ -257,36 +251,35 @@ acpi_ex_decode_field_access ( break; case AML_FIELD_ACCESS_BYTE: - case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ + case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ byte_alignment = 1; - bit_length = 8; + bit_length = 8; break; case AML_FIELD_ACCESS_WORD: byte_alignment = 2; - bit_length = 16; + bit_length = 16; break; case AML_FIELD_ACCESS_DWORD: byte_alignment = 4; - bit_length = 32; + bit_length = 32; break; - case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ + case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ byte_alignment = 8; - bit_length = 64; + bit_length = 64; break; default: /* Invalid field access type */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown field access type %X\n", - access)); - return_VALUE (0); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown field access type %X\n", access)); + return_VALUE(0); } - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { /* * buffer_field access can be on any byte boundary, so the * byte_alignment is always 1 byte -- regardless of any byte_alignment @@ -296,10 +289,9 @@ acpi_ex_decode_field_access ( } *return_byte_alignment = byte_alignment; - return_VALUE (bit_length); + return_VALUE(bit_length); } - /******************************************************************************* * * FUNCTION: acpi_ex_prep_common_field_object @@ -322,20 +314,16 @@ acpi_ex_decode_field_access ( ******************************************************************************/ acpi_status -acpi_ex_prep_common_field_object ( - union acpi_operand_object *obj_desc, - u8 field_flags, - u8 field_attribute, - u32 field_bit_position, - u32 field_bit_length) +acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc, + u8 field_flags, + u8 field_attribute, + u32 field_bit_position, u32 field_bit_length) { - u32 access_bit_width; - u32 byte_alignment; - u32 nearest_byte_address; - - - ACPI_FUNCTION_TRACE ("ex_prep_common_field_object"); + u32 access_bit_width; + u32 byte_alignment; + u32 nearest_byte_address; + ACPI_FUNCTION_TRACE("ex_prep_common_field_object"); /* * Note: the structure being initialized is the @@ -361,16 +349,16 @@ acpi_ex_prep_common_field_object ( * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is * the same (equivalent) as the byte_alignment. */ - access_bit_width = acpi_ex_decode_field_access (obj_desc, field_flags, - &byte_alignment); + access_bit_width = acpi_ex_decode_field_access(obj_desc, field_flags, + &byte_alignment); if (!access_bit_width) { - return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + return_ACPI_STATUS(AE_AML_OPERAND_VALUE); } /* Setup width (access granularity) fields */ obj_desc->common_field.access_byte_width = (u8) - ACPI_DIV_8 (access_bit_width); /* 1, 2, 4, 8 */ + ACPI_DIV_8(access_bit_width); /* 1, 2, 4, 8 */ obj_desc->common_field.access_bit_width = (u8) access_bit_width; @@ -385,30 +373,30 @@ acpi_ex_prep_common_field_object ( * region or buffer. */ nearest_byte_address = - ACPI_ROUND_BITS_DOWN_TO_BYTES (field_bit_position); + ACPI_ROUND_BITS_DOWN_TO_BYTES(field_bit_position); obj_desc->common_field.base_byte_offset = (u32) - ACPI_ROUND_DOWN (nearest_byte_address, byte_alignment); + ACPI_ROUND_DOWN(nearest_byte_address, byte_alignment); /* * start_field_bit_offset is the offset of the first bit of the field within * a field datum. */ obj_desc->common_field.start_field_bit_offset = (u8) - (field_bit_position - ACPI_MUL_8 (obj_desc->common_field.base_byte_offset)); + (field_bit_position - + ACPI_MUL_8(obj_desc->common_field.base_byte_offset)); /* * Does the entire field fit within a single field access element? (datum) * (i.e., without crossing a datum boundary) */ - if ((obj_desc->common_field.start_field_bit_offset + field_bit_length) <= - (u16) access_bit_width) { + if ((obj_desc->common_field.start_field_bit_offset + + field_bit_length) <= (u16) access_bit_width) { obj_desc->common.flags |= AOPOBJ_SINGLE_DATUM; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ex_prep_field_value @@ -422,51 +410,49 @@ acpi_ex_prep_common_field_object ( * ******************************************************************************/ -acpi_status -acpi_ex_prep_field_value ( - struct acpi_create_field_info *info) +acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info) { - union acpi_operand_object *obj_desc; - u32 type; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ex_prep_field_value"); + union acpi_operand_object *obj_desc; + u32 type; + acpi_status status; + ACPI_FUNCTION_TRACE("ex_prep_field_value"); /* Parameter validation */ if (info->field_type != ACPI_TYPE_LOCAL_INDEX_FIELD) { if (!info->region_node) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null region_node\n")); - return_ACPI_STATUS (AE_AML_NO_OPERAND); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null region_node\n")); + return_ACPI_STATUS(AE_AML_NO_OPERAND); } - type = acpi_ns_get_type (info->region_node); + type = acpi_ns_get_type(info->region_node); if (type != ACPI_TYPE_REGION) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Needed Region, found type %X (%s)\n", - type, acpi_ut_get_type_name (type))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Needed Region, found type %X (%s)\n", + type, acpi_ut_get_type_name(type))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } } /* Allocate a new field object */ - obj_desc = acpi_ut_create_internal_object (info->field_type); + obj_desc = acpi_ut_create_internal_object(info->field_type); if (!obj_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Initialize areas of the object that are common to all fields */ obj_desc->common_field.node = info->field_node; - status = acpi_ex_prep_common_field_object (obj_desc, info->field_flags, - info->attribute, info->field_bit_position, info->field_bit_length); - if (ACPI_FAILURE (status)) { - acpi_ut_delete_object_desc (obj_desc); - return_ACPI_STATUS (status); + status = acpi_ex_prep_common_field_object(obj_desc, info->field_flags, + info->attribute, + info->field_bit_position, + info->field_bit_length); + if (ACPI_FAILURE(status)) { + acpi_ut_delete_object_desc(obj_desc); + return_ACPI_STATUS(status); } /* Initialize areas of the object that are specific to the field type */ @@ -474,71 +460,73 @@ acpi_ex_prep_field_value ( switch (info->field_type) { case ACPI_TYPE_LOCAL_REGION_FIELD: - obj_desc->field.region_obj = acpi_ns_get_attached_object (info->region_node); + obj_desc->field.region_obj = + acpi_ns_get_attached_object(info->region_node); /* An additional reference for the container */ - acpi_ut_add_reference (obj_desc->field.region_obj); + acpi_ut_add_reference(obj_desc->field.region_obj); - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "region_field: bit_off %X, Off %X, Gran %X, Region %p\n", - obj_desc->field.start_field_bit_offset, obj_desc->field.base_byte_offset, - obj_desc->field.access_byte_width, obj_desc->field.region_obj)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "region_field: bit_off %X, Off %X, Gran %X, Region %p\n", + obj_desc->field.start_field_bit_offset, + obj_desc->field.base_byte_offset, + obj_desc->field.access_byte_width, + obj_desc->field.region_obj)); break; - case ACPI_TYPE_LOCAL_BANK_FIELD: - obj_desc->bank_field.value = info->bank_value; - obj_desc->bank_field.region_obj = acpi_ns_get_attached_object ( - info->region_node); - obj_desc->bank_field.bank_obj = acpi_ns_get_attached_object ( - info->register_node); + obj_desc->bank_field.value = info->bank_value; + obj_desc->bank_field.region_obj = + acpi_ns_get_attached_object(info->region_node); + obj_desc->bank_field.bank_obj = + acpi_ns_get_attached_object(info->register_node); /* An additional reference for the attached objects */ - acpi_ut_add_reference (obj_desc->bank_field.region_obj); - acpi_ut_add_reference (obj_desc->bank_field.bank_obj); + acpi_ut_add_reference(obj_desc->bank_field.region_obj); + acpi_ut_add_reference(obj_desc->bank_field.bank_obj); - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Bank Field: bit_off %X, Off %X, Gran %X, Region %p, bank_reg %p\n", - obj_desc->bank_field.start_field_bit_offset, - obj_desc->bank_field.base_byte_offset, - obj_desc->field.access_byte_width, - obj_desc->bank_field.region_obj, - obj_desc->bank_field.bank_obj)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Bank Field: bit_off %X, Off %X, Gran %X, Region %p, bank_reg %p\n", + obj_desc->bank_field.start_field_bit_offset, + obj_desc->bank_field.base_byte_offset, + obj_desc->field.access_byte_width, + obj_desc->bank_field.region_obj, + obj_desc->bank_field.bank_obj)); break; - case ACPI_TYPE_LOCAL_INDEX_FIELD: - obj_desc->index_field.index_obj = acpi_ns_get_attached_object ( - info->register_node); - obj_desc->index_field.data_obj = acpi_ns_get_attached_object ( - info->data_register_node); - obj_desc->index_field.value = (u32) - (info->field_bit_position / ACPI_MUL_8 ( - obj_desc->field.access_byte_width)); - - if (!obj_desc->index_field.data_obj || !obj_desc->index_field.index_obj) { - ACPI_REPORT_ERROR (("Null Index Object during field prep\n")); - acpi_ut_delete_object_desc (obj_desc); - return_ACPI_STATUS (AE_AML_INTERNAL); + obj_desc->index_field.index_obj = + acpi_ns_get_attached_object(info->register_node); + obj_desc->index_field.data_obj = + acpi_ns_get_attached_object(info->data_register_node); + obj_desc->index_field.value = (u32) + (info->field_bit_position / + ACPI_MUL_8(obj_desc->field.access_byte_width)); + + if (!obj_desc->index_field.data_obj + || !obj_desc->index_field.index_obj) { + ACPI_REPORT_ERROR(("Null Index Object during field prep\n")); + acpi_ut_delete_object_desc(obj_desc); + return_ACPI_STATUS(AE_AML_INTERNAL); } /* An additional reference for the attached objects */ - acpi_ut_add_reference (obj_desc->index_field.data_obj); - acpi_ut_add_reference (obj_desc->index_field.index_obj); - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "index_field: bit_off %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", - obj_desc->index_field.start_field_bit_offset, - obj_desc->index_field.base_byte_offset, - obj_desc->index_field.value, - obj_desc->field.access_byte_width, - obj_desc->index_field.index_obj, - obj_desc->index_field.data_obj)); + acpi_ut_add_reference(obj_desc->index_field.data_obj); + acpi_ut_add_reference(obj_desc->index_field.index_obj); + + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "index_field: bit_off %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", + obj_desc->index_field.start_field_bit_offset, + obj_desc->index_field.base_byte_offset, + obj_desc->index_field.value, + obj_desc->field.access_byte_width, + obj_desc->index_field.index_obj, + obj_desc->index_field.data_obj)); break; default: @@ -550,15 +538,16 @@ acpi_ex_prep_field_value ( * Store the constructed descriptor (obj_desc) into the parent Node, * preserving the current type of that named_obj. */ - status = acpi_ns_attach_object (info->field_node, obj_desc, - acpi_ns_get_type (info->field_node)); + status = acpi_ns_attach_object(info->field_node, obj_desc, + acpi_ns_get_type(info->field_node)); - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set named_obj %p [%4.4s], obj_desc %p\n", - info->field_node, acpi_ut_get_node_name (info->field_node), obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "Set named_obj %p [%4.4s], obj_desc %p\n", + info->field_node, + acpi_ut_get_node_name(info->field_node), obj_desc)); /* Remove local reference to the object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c index 723aaef..9a2f5be 100644 --- a/drivers/acpi/executer/exregion.c +++ b/drivers/acpi/executer/exregion.c @@ -42,14 +42,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exregion") - +ACPI_MODULE_NAME("exregion") /******************************************************************************* * @@ -68,27 +65,23 @@ * DESCRIPTION: Handler for the System Memory address space (Op Region) * ******************************************************************************/ - acpi_status -acpi_ex_system_memory_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context) +acpi_ex_system_memory_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, void *region_context) { - acpi_status status = AE_OK; - void *logical_addr_ptr = NULL; - struct acpi_mem_space_context *mem_info = region_context; - u32 length; - acpi_size window_size; + acpi_status status = AE_OK; + void *logical_addr_ptr = NULL; + struct acpi_mem_space_context *mem_info = region_context; + u32 length; + acpi_size window_size; #ifndef ACPI_MISALIGNED_TRANSFERS - u32 remainder; + u32 remainder; #endif - ACPI_FUNCTION_TRACE ("ex_system_memory_space_handler"); - + ACPI_FUNCTION_TRACE("ex_system_memory_space_handler"); /* Validate and translate the bit width */ @@ -110,9 +103,10 @@ acpi_ex_system_memory_space_handler ( break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid system_memory width %d\n", - bit_width)); - return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid system_memory width %d\n", + bit_width)); + return_ACPI_STATUS(AE_AML_OPERAND_VALUE); } #ifndef ACPI_MISALIGNED_TRANSFERS @@ -120,9 +114,10 @@ acpi_ex_system_memory_space_handler ( * Hardware does not support non-aligned data transfers, we must verify * the request. */ - (void) acpi_ut_short_divide ((acpi_integer) address, length, NULL, &remainder); + (void)acpi_ut_short_divide((acpi_integer) address, length, NULL, + &remainder); if (remainder != 0) { - return_ACPI_STATUS (AE_AML_ALIGNMENT); + return_ACPI_STATUS(AE_AML_ALIGNMENT); } #endif @@ -132,9 +127,10 @@ acpi_ex_system_memory_space_handler ( * 2) Address beyond the current mapping? */ if ((address < mem_info->mapped_physical_address) || - (((acpi_integer) address + length) > - ((acpi_integer) - mem_info->mapped_physical_address + mem_info->mapped_length))) { + (((acpi_integer) address + length) > ((acpi_integer) + mem_info-> + mapped_physical_address + + mem_info->mapped_length))) { /* * The request cannot be resolved by the current memory mapping; * Delete the existing mapping and create a new one. @@ -142,8 +138,8 @@ acpi_ex_system_memory_space_handler ( if (mem_info->mapped_length) { /* Valid mapping, delete it */ - acpi_os_unmap_memory (mem_info->mapped_logical_address, - mem_info->mapped_length); + acpi_os_unmap_memory(mem_info->mapped_logical_address, + mem_info->mapped_length); } /* @@ -151,7 +147,7 @@ acpi_ex_system_memory_space_handler ( * constrain the maximum mapping size to something reasonable. */ window_size = (acpi_size) - ((mem_info->address + mem_info->length) - address); + ((mem_info->address + mem_info->length) - address); if (window_size > ACPI_SYSMEM_REGION_WINDOW_SIZE) { window_size = ACPI_SYSMEM_REGION_WINDOW_SIZE; @@ -159,14 +155,16 @@ acpi_ex_system_memory_space_handler ( /* Create a new mapping starting at the address given */ - status = acpi_os_map_memory (address, window_size, - (void **) &mem_info->mapped_logical_address); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not map memory at %8.8X%8.8X, size %X\n", - ACPI_FORMAT_UINT64 (address), (u32) window_size)); + status = acpi_os_map_memory(address, window_size, + (void **)&mem_info-> + mapped_logical_address); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not map memory at %8.8X%8.8X, size %X\n", + ACPI_FORMAT_UINT64(address), + (u32) window_size)); mem_info->mapped_length = 0; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Save the physical address and mapping size */ @@ -180,42 +178,41 @@ acpi_ex_system_memory_space_handler ( * access */ logical_addr_ptr = mem_info->mapped_logical_address + - ((acpi_integer) address - - (acpi_integer) mem_info->mapped_physical_address); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "system_memory %d (%d width) Address=%8.8X%8.8X\n", - function, bit_width, - ACPI_FORMAT_UINT64 (address))); - - /* - * Perform the memory read or write - * - * Note: For machines that do not support non-aligned transfers, the target - * address was checked for alignment above. We do not attempt to break the - * transfer up into smaller (byte-size) chunks because the AML specifically - * asked for a transfer width that the hardware may require. - */ + ((acpi_integer) address - + (acpi_integer) mem_info->mapped_physical_address); + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "system_memory %d (%d width) Address=%8.8X%8.8X\n", + function, bit_width, ACPI_FORMAT_UINT64(address))); + + /* + * Perform the memory read or write + * + * Note: For machines that do not support non-aligned transfers, the target + * address was checked for alignment above. We do not attempt to break the + * transfer up into smaller (byte-size) chunks because the AML specifically + * asked for a transfer width that the hardware may require. + */ switch (function) { case ACPI_READ: *value = 0; switch (bit_width) { case 8: - *value = (acpi_integer) *((u8 *) logical_addr_ptr); + *value = (acpi_integer) * ((u8 *) logical_addr_ptr); break; case 16: - *value = (acpi_integer) *((u16 *) logical_addr_ptr); + *value = (acpi_integer) * ((u16 *) logical_addr_ptr); break; case 32: - *value = (acpi_integer) *((u32 *) logical_addr_ptr); + *value = (acpi_integer) * ((u32 *) logical_addr_ptr); break; #if ACPI_MACHINE_WIDTH != 16 case 64: - *value = (acpi_integer) *((u64 *) logical_addr_ptr); + *value = (acpi_integer) * ((u64 *) logical_addr_ptr); break; #endif default: @@ -228,20 +225,20 @@ acpi_ex_system_memory_space_handler ( switch (bit_width) { case 8: - *(u8 *) logical_addr_ptr = (u8) *value; + *(u8 *) logical_addr_ptr = (u8) * value; break; case 16: - *(u16 *) logical_addr_ptr = (u16) *value; + *(u16 *) logical_addr_ptr = (u16) * value; break; case 32: - *(u32 *) logical_addr_ptr = (u32) *value; + *(u32 *) logical_addr_ptr = (u32) * value; break; #if ACPI_MACHINE_WIDTH != 16 case 64: - *(u64 *) logical_addr_ptr = (u64) *value; + *(u64 *) logical_addr_ptr = (u64) * value; break; #endif @@ -256,10 +253,9 @@ acpi_ex_system_memory_space_handler ( break; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_system_io_space_handler @@ -279,39 +275,35 @@ acpi_ex_system_memory_space_handler ( ******************************************************************************/ acpi_status -acpi_ex_system_io_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context) +acpi_ex_system_io_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, void *region_context) { - acpi_status status = AE_OK; - u32 value32; + acpi_status status = AE_OK; + u32 value32; + ACPI_FUNCTION_TRACE("ex_system_io_space_handler"); - ACPI_FUNCTION_TRACE ("ex_system_io_space_handler"); - - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "system_iO %d (%d width) Address=%8.8X%8.8X\n", function, bit_width, - ACPI_FORMAT_UINT64 (address))); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "system_iO %d (%d width) Address=%8.8X%8.8X\n", + function, bit_width, ACPI_FORMAT_UINT64(address))); /* Decode the function parameter */ switch (function) { case ACPI_READ: - status = acpi_os_read_port ((acpi_io_address) address, - &value32, bit_width); + status = acpi_os_read_port((acpi_io_address) address, + &value32, bit_width); *value = value32; break; case ACPI_WRITE: - status = acpi_os_write_port ((acpi_io_address) address, - (u32) *value, bit_width); + status = acpi_os_write_port((acpi_io_address) address, + (u32) * value, bit_width); break; default: @@ -319,10 +311,9 @@ acpi_ex_system_io_space_handler ( break; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_pci_config_space_handler @@ -342,21 +333,17 @@ acpi_ex_system_io_space_handler ( ******************************************************************************/ acpi_status -acpi_ex_pci_config_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context) +acpi_ex_pci_config_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, void *region_context) { - acpi_status status = AE_OK; - struct acpi_pci_id *pci_id; - u16 pci_register; - - - ACPI_FUNCTION_TRACE ("ex_pci_config_space_handler"); + acpi_status status = AE_OK; + struct acpi_pci_id *pci_id; + u16 pci_register; + ACPI_FUNCTION_TRACE("ex_pci_config_space_handler"); /* * The arguments to acpi_os(Read|Write)pci_configuration are: @@ -370,26 +357,26 @@ acpi_ex_pci_config_space_handler ( * Value - input value for write, output address for read * */ - pci_id = (struct acpi_pci_id *) region_context; + pci_id = (struct acpi_pci_id *)region_context; pci_register = (u16) (u32) address; - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", - function, bit_width, pci_id->segment, pci_id->bus, pci_id->device, - pci_id->function, pci_register)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", + function, bit_width, pci_id->segment, pci_id->bus, + pci_id->device, pci_id->function, pci_register)); switch (function) { case ACPI_READ: *value = 0; - status = acpi_os_read_pci_configuration (pci_id, pci_register, - value, bit_width); + status = acpi_os_read_pci_configuration(pci_id, pci_register, + value, bit_width); break; case ACPI_WRITE: - status = acpi_os_write_pci_configuration (pci_id, pci_register, - *value, bit_width); + status = acpi_os_write_pci_configuration(pci_id, pci_register, + *value, bit_width); break; default: @@ -398,10 +385,9 @@ acpi_ex_pci_config_space_handler ( break; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_cmos_space_handler @@ -421,24 +407,19 @@ acpi_ex_pci_config_space_handler ( ******************************************************************************/ acpi_status -acpi_ex_cmos_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context) +acpi_ex_cmos_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, void *region_context) { - acpi_status status = AE_OK; - + acpi_status status = AE_OK; - ACPI_FUNCTION_TRACE ("ex_cmos_space_handler"); + ACPI_FUNCTION_TRACE("ex_cmos_space_handler"); - - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_pci_bar_space_handler @@ -458,24 +439,19 @@ acpi_ex_cmos_space_handler ( ******************************************************************************/ acpi_status -acpi_ex_pci_bar_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context) +acpi_ex_pci_bar_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, void *region_context) { - acpi_status status = AE_OK; - + acpi_status status = AE_OK; - ACPI_FUNCTION_TRACE ("ex_pci_bar_space_handler"); + ACPI_FUNCTION_TRACE("ex_pci_bar_space_handler"); - - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_data_table_space_handler @@ -495,24 +471,20 @@ acpi_ex_pci_bar_space_handler ( ******************************************************************************/ acpi_status -acpi_ex_data_table_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context) +acpi_ex_data_table_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, void *region_context) { - acpi_status status = AE_OK; - u32 byte_width = ACPI_DIV_8 (bit_width); - u32 i; - char *logical_addr_ptr; - + acpi_status status = AE_OK; + u32 byte_width = ACPI_DIV_8(bit_width); + u32 i; + char *logical_addr_ptr; - ACPI_FUNCTION_TRACE ("ex_data_table_space_handler"); + ACPI_FUNCTION_TRACE("ex_data_table_space_handler"); - - logical_addr_ptr = ACPI_PHYSADDR_TO_PTR (address); + logical_addr_ptr = ACPI_PHYSADDR_TO_PTR(address); /* Perform the memory read or write */ @@ -520,17 +492,15 @@ acpi_ex_data_table_space_handler ( case ACPI_READ: for (i = 0; i < byte_width; i++) { - ((char *) value) [i] = logical_addr_ptr[i]; + ((char *)value)[i] = logical_addr_ptr[i]; } break; case ACPI_WRITE: default: - return_ACPI_STATUS (AE_SUPPORT); + return_ACPI_STATUS(AE_SUPPORT); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/executer/exresnte.c index 21d5c74..ff5d8f9 100644 --- a/drivers/acpi/executer/exresnte.c +++ b/drivers/acpi/executer/exresnte.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -50,10 +49,8 @@ #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exresnte") - +ACPI_MODULE_NAME("exresnte") /******************************************************************************* * @@ -80,41 +77,37 @@ * ACPI_TYPE_PACKAGE * ******************************************************************************/ - acpi_status -acpi_ex_resolve_node_to_value ( - struct acpi_namespace_node **object_ptr, - struct acpi_walk_state *walk_state) - +acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, + struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - union acpi_operand_object *source_desc; - union acpi_operand_object *obj_desc = NULL; - struct acpi_namespace_node *node; - acpi_object_type entry_type; - - - ACPI_FUNCTION_TRACE ("ex_resolve_node_to_value"); + acpi_status status = AE_OK; + union acpi_operand_object *source_desc; + union acpi_operand_object *obj_desc = NULL; + struct acpi_namespace_node *node; + acpi_object_type entry_type; + ACPI_FUNCTION_TRACE("ex_resolve_node_to_value"); /* * The stack pointer points to a struct acpi_namespace_node (Node). Get the * object that is attached to the Node. */ - node = *object_ptr; - source_desc = acpi_ns_get_attached_object (node); - entry_type = acpi_ns_get_type ((acpi_handle) node); + node = *object_ptr; + source_desc = acpi_ns_get_attached_object(node); + entry_type = acpi_ns_get_type((acpi_handle) node); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p source_desc=%p [%s]\n", - node, source_desc, acpi_ut_get_type_name (entry_type))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Entry=%p source_desc=%p [%s]\n", + node, source_desc, + acpi_ut_get_type_name(entry_type))); if ((entry_type == ACPI_TYPE_LOCAL_ALIAS) || - (entry_type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { + (entry_type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { /* There is always exactly one level of indirection */ - node = ACPI_CAST_PTR (struct acpi_namespace_node, node->object); - source_desc = acpi_ns_get_attached_object (node); - entry_type = acpi_ns_get_type ((acpi_handle) node); + node = ACPI_CAST_PTR(struct acpi_namespace_node, node->object); + source_desc = acpi_ns_get_attached_object(node); + entry_type = acpi_ns_get_type((acpi_handle) node); *object_ptr = node; } @@ -124,14 +117,14 @@ acpi_ex_resolve_node_to_value ( * 2) Method locals and arguments have a pseudo-Node */ if (entry_type == ACPI_TYPE_DEVICE || - (node->flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) { - return_ACPI_STATUS (AE_OK); + (node->flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) { + return_ACPI_STATUS(AE_OK); } if (!source_desc) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object attached to node %p\n", - node)); - return_ACPI_STATUS (AE_AML_NO_OPERAND); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No object attached to node %p\n", node)); + return_ACPI_STATUS(AE_AML_NO_OPERAND); } /* @@ -141,83 +134,89 @@ acpi_ex_resolve_node_to_value ( switch (entry_type) { case ACPI_TYPE_PACKAGE: - if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_PACKAGE) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Package, type %s\n", - acpi_ut_get_object_type_name (source_desc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_PACKAGE) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Object not a Package, type %s\n", + acpi_ut_get_object_type_name + (source_desc))); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } - status = acpi_ds_get_package_arguments (source_desc); - if (ACPI_SUCCESS (status)) { + status = acpi_ds_get_package_arguments(source_desc); + if (ACPI_SUCCESS(status)) { /* Return an additional reference to the object */ obj_desc = source_desc; - acpi_ut_add_reference (obj_desc); + acpi_ut_add_reference(obj_desc); } break; - case ACPI_TYPE_BUFFER: - if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Buffer, type %s\n", - acpi_ut_get_object_type_name (source_desc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Object not a Buffer, type %s\n", + acpi_ut_get_object_type_name + (source_desc))); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } - status = acpi_ds_get_buffer_arguments (source_desc); - if (ACPI_SUCCESS (status)) { + status = acpi_ds_get_buffer_arguments(source_desc); + if (ACPI_SUCCESS(status)) { /* Return an additional reference to the object */ obj_desc = source_desc; - acpi_ut_add_reference (obj_desc); + acpi_ut_add_reference(obj_desc); } break; - case ACPI_TYPE_STRING: - if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_STRING) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a String, type %s\n", - acpi_ut_get_object_type_name (source_desc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Object not a String, type %s\n", + acpi_ut_get_object_type_name + (source_desc))); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* Return an additional reference to the object */ obj_desc = source_desc; - acpi_ut_add_reference (obj_desc); + acpi_ut_add_reference(obj_desc); break; - case ACPI_TYPE_INTEGER: - if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_INTEGER) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Integer, type %s\n", - acpi_ut_get_object_type_name (source_desc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Object not a Integer, type %s\n", + acpi_ut_get_object_type_name + (source_desc))); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* Return an additional reference to the object */ obj_desc = source_desc; - acpi_ut_add_reference (obj_desc); + acpi_ut_add_reference(obj_desc); break; - case ACPI_TYPE_BUFFER_FIELD: case ACPI_TYPE_LOCAL_REGION_FIELD: case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "field_read Node=%p source_desc=%p Type=%X\n", - node, source_desc, entry_type)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "field_read Node=%p source_desc=%p Type=%X\n", + node, source_desc, entry_type)); - status = acpi_ex_read_data_from_field (walk_state, source_desc, &obj_desc); + status = + acpi_ex_read_data_from_field(walk_state, source_desc, + &obj_desc); break; - /* For these objects, just return the object attached to the Node */ + /* For these objects, just return the object attached to the Node */ case ACPI_TYPE_MUTEX: case ACPI_TYPE_METHOD: @@ -230,19 +229,18 @@ acpi_ex_resolve_node_to_value ( /* Return an additional reference to the object */ obj_desc = source_desc; - acpi_ut_add_reference (obj_desc); + acpi_ut_add_reference(obj_desc); break; - /* TYPE_ANY is untyped, and thus there is no object associated with it */ + /* TYPE_ANY is untyped, and thus there is no object associated with it */ case ACPI_TYPE_ANY: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Untyped entry %p, no attached object!\n", - node)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Untyped entry %p, no attached object!\n", + node)); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ case ACPI_TYPE_LOCAL_REFERENCE: @@ -253,39 +251,37 @@ acpi_ex_resolve_node_to_value ( /* Return an additional reference to the object */ obj_desc = source_desc; - acpi_ut_add_reference (obj_desc); + acpi_ut_add_reference(obj_desc); break; default: /* No named references are allowed here */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unsupported Reference opcode %X (%s)\n", - source_desc->reference.opcode, - acpi_ps_get_opcode_name (source_desc->reference.opcode))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unsupported Reference opcode %X (%s)\n", + source_desc->reference.opcode, + acpi_ps_get_opcode_name(source_desc-> + reference. + opcode))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } break; - default: /* Default case is for unknown types */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Node %p - Unknown object type %X\n", - node, entry_type)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Node %p - Unknown object type %X\n", + node, entry_type)); - } /* switch (entry_type) */ + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); + } /* switch (entry_type) */ /* Return the object descriptor */ - *object_ptr = (void *) obj_desc; - return_ACPI_STATUS (status); + *object_ptr = (void *)obj_desc; + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/executer/exresolv.c index 3de4567..97eecbd 100644 --- a/drivers/acpi/executer/exresolv.c +++ b/drivers/acpi/executer/exresolv.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -50,17 +49,13 @@ #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exresolv") +ACPI_MODULE_NAME("exresolv") /* Local prototypes */ - static acpi_status -acpi_ex_resolve_object_to_value ( - union acpi_operand_object **stack_ptr, - struct acpi_walk_state *walk_state); - +acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, + struct acpi_walk_state *walk_state); /******************************************************************************* * @@ -78,19 +73,16 @@ acpi_ex_resolve_object_to_value ( ******************************************************************************/ acpi_status -acpi_ex_resolve_to_value ( - union acpi_operand_object **stack_ptr, - struct acpi_walk_state *walk_state) +acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr, + struct acpi_walk_state *walk_state) { - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ex_resolve_to_value", stack_ptr); + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ex_resolve_to_value", stack_ptr); if (!stack_ptr || !*stack_ptr) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n")); - return_ACPI_STATUS (AE_AML_NO_OPERAND); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Internal - null pointer\n")); + return_ACPI_STATUS(AE_AML_NO_OPERAND); } /* @@ -98,15 +90,16 @@ acpi_ex_resolve_to_value ( * 1) A valid union acpi_operand_object, or * 2) A struct acpi_namespace_node (named_obj) */ - if (ACPI_GET_DESCRIPTOR_TYPE (*stack_ptr) == ACPI_DESC_TYPE_OPERAND) { - status = acpi_ex_resolve_object_to_value (stack_ptr, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + if (ACPI_GET_DESCRIPTOR_TYPE(*stack_ptr) == ACPI_DESC_TYPE_OPERAND) { + status = acpi_ex_resolve_object_to_value(stack_ptr, walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } if (!*stack_ptr) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n")); - return_ACPI_STATUS (AE_AML_NO_OPERAND); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Internal - null pointer\n")); + return_ACPI_STATUS(AE_AML_NO_OPERAND); } } @@ -114,20 +107,20 @@ acpi_ex_resolve_to_value ( * Object on the stack may have changed if acpi_ex_resolve_object_to_value() * was called (i.e., we can't use an _else_ here.) */ - if (ACPI_GET_DESCRIPTOR_TYPE (*stack_ptr) == ACPI_DESC_TYPE_NAMED) { - status = acpi_ex_resolve_node_to_value ( - ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, stack_ptr), - walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + if (ACPI_GET_DESCRIPTOR_TYPE(*stack_ptr) == ACPI_DESC_TYPE_NAMED) { + status = + acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR + (struct acpi_namespace_node, + stack_ptr), walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *stack_ptr)); - return_ACPI_STATUS (AE_OK); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Resolved object %p\n", *stack_ptr)); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ex_resolve_object_to_value @@ -143,25 +136,22 @@ acpi_ex_resolve_to_value ( ******************************************************************************/ static acpi_status -acpi_ex_resolve_object_to_value ( - union acpi_operand_object **stack_ptr, - struct acpi_walk_state *walk_state) +acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, + struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - union acpi_operand_object *stack_desc; - void *temp_node; - union acpi_operand_object *obj_desc; - u16 opcode; - - - ACPI_FUNCTION_TRACE ("ex_resolve_object_to_value"); + acpi_status status = AE_OK; + union acpi_operand_object *stack_desc; + void *temp_node; + union acpi_operand_object *obj_desc; + u16 opcode; + ACPI_FUNCTION_TRACE("ex_resolve_object_to_value"); stack_desc = *stack_ptr; /* This is an union acpi_operand_object */ - switch (ACPI_GET_OBJECT_TYPE (stack_desc)) { + switch (ACPI_GET_OBJECT_TYPE(stack_desc)) { case ACPI_TYPE_LOCAL_REFERENCE: opcode = stack_desc->reference.opcode; @@ -177,14 +167,13 @@ acpi_ex_resolve_object_to_value ( /* Delete the Reference Object */ - acpi_ut_remove_reference (stack_desc); + acpi_ut_remove_reference(stack_desc); /* Return the namespace node */ (*stack_ptr) = temp_node; break; - case AML_LOCAL_OP: case AML_ARG_OP: @@ -192,24 +181,28 @@ acpi_ex_resolve_object_to_value ( * Get the local from the method's state info * Note: this increments the local's object reference count */ - status = acpi_ds_method_data_get_value (opcode, - stack_desc->reference.offset, walk_state, &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_method_data_get_value(opcode, + stack_desc-> + reference.offset, + walk_state, + &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] value_obj is %p\n", - stack_desc->reference.offset, obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Arg/Local %X] value_obj is %p\n", + stack_desc->reference.offset, + obj_desc)); /* * Now we can delete the original Reference Object and * replace it with the resolved value */ - acpi_ut_remove_reference (stack_desc); + acpi_ut_remove_reference(stack_desc); *stack_ptr = obj_desc; break; - case AML_INDEX_OP: switch (stack_desc->reference.target_type) { @@ -218,7 +211,6 @@ acpi_ex_resolve_object_to_value ( /* Just return - leave the Reference on the stack */ break; - case ACPI_TYPE_PACKAGE: obj_desc = *stack_desc->reference.where; @@ -228,36 +220,31 @@ acpi_ex_resolve_object_to_value ( * (i.e., dereference the package index) * Delete the ref object, increment the returned object */ - acpi_ut_remove_reference (stack_desc); - acpi_ut_add_reference (obj_desc); + acpi_ut_remove_reference(stack_desc); + acpi_ut_add_reference(obj_desc); *stack_ptr = obj_desc; - } - else { + } else { /* * A NULL object descriptor means an unitialized element of * the package, can't dereference it */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Attempt to deref an Index to NULL pkg element Idx=%p\n", - stack_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Attempt to deref an Index to NULL pkg element Idx=%p\n", + stack_desc)); status = AE_AML_UNINITIALIZED_ELEMENT; } break; - default: /* Invalid reference object */ - ACPI_REPORT_ERROR (( - "During resolve, Unknown target_type %X in Index/Reference obj %p\n", - stack_desc->reference.target_type, stack_desc)); + ACPI_REPORT_ERROR(("During resolve, Unknown target_type %X in Index/Reference obj %p\n", stack_desc->reference.target_type, stack_desc)); status = AE_AML_INTERNAL; break; } break; - case AML_REF_OF_OP: case AML_DEBUG_OP: case AML_LOAD_OP: @@ -266,60 +253,58 @@ acpi_ex_resolve_object_to_value ( break; - case AML_INT_NAMEPATH_OP: /* Reference to a named object */ + case AML_INT_NAMEPATH_OP: /* Reference to a named object */ /* Get the object pointed to by the namespace node */ *stack_ptr = (stack_desc->reference.node)->object; - acpi_ut_add_reference (*stack_ptr); - acpi_ut_remove_reference (stack_desc); + acpi_ut_add_reference(*stack_ptr); + acpi_ut_remove_reference(stack_desc); break; default: - ACPI_REPORT_ERROR (( - "During resolve, Unknown Reference opcode %X (%s) in %p\n", - opcode, acpi_ps_get_opcode_name (opcode), stack_desc)); + ACPI_REPORT_ERROR(("During resolve, Unknown Reference opcode %X (%s) in %p\n", opcode, acpi_ps_get_opcode_name(opcode), stack_desc)); status = AE_AML_INTERNAL; break; } break; - case ACPI_TYPE_BUFFER: - status = acpi_ds_get_buffer_arguments (stack_desc); + status = acpi_ds_get_buffer_arguments(stack_desc); break; - case ACPI_TYPE_PACKAGE: - status = acpi_ds_get_package_arguments (stack_desc); + status = acpi_ds_get_package_arguments(stack_desc); break; - - /* These cases may never happen here, but just in case.. */ + /* These cases may never happen here, but just in case.. */ case ACPI_TYPE_BUFFER_FIELD: case ACPI_TYPE_LOCAL_REGION_FIELD: case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "field_read source_desc=%p Type=%X\n", - stack_desc, ACPI_GET_OBJECT_TYPE (stack_desc))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "field_read source_desc=%p Type=%X\n", + stack_desc, + ACPI_GET_OBJECT_TYPE(stack_desc))); - status = acpi_ex_read_data_from_field (walk_state, stack_desc, &obj_desc); - *stack_ptr = (void *) obj_desc; + status = + acpi_ex_read_data_from_field(walk_state, stack_desc, + &obj_desc); + *stack_ptr = (void *)obj_desc; break; default: break; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_resolve_multiple @@ -337,42 +322,44 @@ acpi_ex_resolve_object_to_value ( ******************************************************************************/ acpi_status -acpi_ex_resolve_multiple ( - struct acpi_walk_state *walk_state, - union acpi_operand_object *operand, - acpi_object_type *return_type, - union acpi_operand_object **return_desc) +acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, + union acpi_operand_object *operand, + acpi_object_type * return_type, + union acpi_operand_object **return_desc) { - union acpi_operand_object *obj_desc = (void *) operand; - struct acpi_namespace_node *node; - acpi_object_type type; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_ex_resolve_multiple"); + union acpi_operand_object *obj_desc = (void *)operand; + struct acpi_namespace_node *node; + acpi_object_type type; + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_ex_resolve_multiple"); /* Operand can be either a namespace node or an operand descriptor */ - switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { + switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) { case ACPI_DESC_TYPE_OPERAND: type = obj_desc->common.type; break; case ACPI_DESC_TYPE_NAMED: - type = ((struct acpi_namespace_node *) obj_desc)->type; - obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) obj_desc); + type = ((struct acpi_namespace_node *)obj_desc)->type; + obj_desc = + acpi_ns_get_attached_object((struct acpi_namespace_node *) + obj_desc); /* If we had an Alias node, use the attached object for type info */ if (type == ACPI_TYPE_LOCAL_ALIAS) { - type = ((struct acpi_namespace_node *) obj_desc)->type; - obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) obj_desc); + type = ((struct acpi_namespace_node *)obj_desc)->type; + obj_desc = + acpi_ns_get_attached_object((struct + acpi_namespace_node *) + obj_desc); } break; default: - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* If type is anything other than a reference, we are done */ @@ -387,7 +374,7 @@ acpi_ex_resolve_multiple ( * of the object_type and size_of operators). This means traversing * the list of possibly many nested references. */ - while (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) { + while (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) { switch (obj_desc->reference.opcode) { case AML_REF_OF_OP: @@ -397,31 +384,29 @@ acpi_ex_resolve_multiple ( /* All "References" point to a NS node */ - if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR (( - "acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", - node, acpi_ut_get_descriptor_name (node))); - return_ACPI_STATUS (AE_AML_INTERNAL); + if (ACPI_GET_DESCRIPTOR_TYPE(node) != + ACPI_DESC_TYPE_NAMED) { + ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", node, acpi_ut_get_descriptor_name(node))); + return_ACPI_STATUS(AE_AML_INTERNAL); } /* Get the attached object */ - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { /* No object, use the NS node type */ - type = acpi_ns_get_type (node); + type = acpi_ns_get_type(node); goto exit; } /* Check for circular references */ if (obj_desc == operand) { - return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); + return_ACPI_STATUS(AE_AML_CIRCULAR_REFERENCE); } break; - case AML_INDEX_OP: /* Get the type of this reference (index into another object) */ @@ -442,12 +427,11 @@ acpi_ex_resolve_multiple ( if (!obj_desc) { /* NULL package elements are allowed */ - type = 0; /* Uninitialized */ + type = 0; /* Uninitialized */ goto exit; } break; - case AML_INT_NAMEPATH_OP: /* Dereference the reference pointer */ @@ -456,50 +440,61 @@ acpi_ex_resolve_multiple ( /* All "References" point to a NS node */ - if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR (( - "acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", - node, acpi_ut_get_descriptor_name (node))); - return_ACPI_STATUS (AE_AML_INTERNAL); + if (ACPI_GET_DESCRIPTOR_TYPE(node) != + ACPI_DESC_TYPE_NAMED) { + ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", node, acpi_ut_get_descriptor_name(node))); + return_ACPI_STATUS(AE_AML_INTERNAL); } /* Get the attached object */ - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { /* No object, use the NS node type */ - type = acpi_ns_get_type (node); + type = acpi_ns_get_type(node); goto exit; } /* Check for circular references */ if (obj_desc == operand) { - return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); + return_ACPI_STATUS(AE_AML_CIRCULAR_REFERENCE); } break; - case AML_LOCAL_OP: case AML_ARG_OP: if (return_desc) { - status = acpi_ds_method_data_get_value (obj_desc->reference.opcode, - obj_desc->reference.offset, walk_state, &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ds_method_data_get_value(obj_desc-> + reference. + opcode, + obj_desc-> + reference. + offset, + walk_state, + &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - acpi_ut_remove_reference (obj_desc); - } - else { - status = acpi_ds_method_data_get_node (obj_desc->reference.opcode, - obj_desc->reference.offset, walk_state, &node); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + } else { + status = + acpi_ds_method_data_get_node(obj_desc-> + reference. + opcode, + obj_desc-> + reference. + offset, + walk_state, + &node); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { type = ACPI_TYPE_ANY; goto exit; @@ -507,7 +502,6 @@ acpi_ex_resolve_multiple ( } break; - case AML_DEBUG_OP: /* The Debug Object is of type "debug_object" */ @@ -515,13 +509,10 @@ acpi_ex_resolve_multiple ( type = ACPI_TYPE_DEBUG_OBJECT; goto exit; - default: - ACPI_REPORT_ERROR (( - "acpi_ex_resolve_multiple: Unknown Reference subtype %X\n", - obj_desc->reference.opcode)); - return_ACPI_STATUS (AE_AML_INTERNAL); + ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Unknown Reference subtype %X\n", obj_desc->reference.opcode)); + return_ACPI_STATUS(AE_AML_INTERNAL); } } @@ -529,10 +520,9 @@ acpi_ex_resolve_multiple ( * Now we are guaranteed to have an object that has not been created * via the ref_of or Index operators. */ - type = ACPI_GET_OBJECT_TYPE (obj_desc); + type = ACPI_GET_OBJECT_TYPE(obj_desc); - -exit: + exit: /* Convert internal types to external types */ switch (type) { @@ -559,7 +549,5 @@ exit: if (return_desc) { *return_desc = obj_desc; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - - diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c index aaba7ab..ff064e7 100644 --- a/drivers/acpi/executer/exresop.c +++ b/drivers/acpi/executer/exresop.c @@ -42,24 +42,18 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exresop") +ACPI_MODULE_NAME("exresop") /* Local prototypes */ - static acpi_status -acpi_ex_check_object_type ( - acpi_object_type type_needed, - acpi_object_type this_type, - void *object); - +acpi_ex_check_object_type(acpi_object_type type_needed, + acpi_object_type this_type, void *object); /******************************************************************************* * @@ -76,13 +70,10 @@ acpi_ex_check_object_type ( ******************************************************************************/ static acpi_status -acpi_ex_check_object_type ( - acpi_object_type type_needed, - acpi_object_type this_type, - void *object) +acpi_ex_check_object_type(acpi_object_type type_needed, + acpi_object_type this_type, void *object) { - ACPI_FUNCTION_NAME ("ex_check_object_type"); - + ACPI_FUNCTION_NAME("ex_check_object_type"); if (type_needed == ACPI_TYPE_ANY) { /* All types OK, so we don't perform any typechecks */ @@ -97,16 +88,17 @@ acpi_ex_check_object_type ( * specification, a store to a constant is a noop.) */ if ((this_type == ACPI_TYPE_INTEGER) && - (((union acpi_operand_object *) object)->common.flags & AOPOBJ_AML_CONSTANT)) { + (((union acpi_operand_object *)object)->common. + flags & AOPOBJ_AML_CONSTANT)) { return (AE_OK); } } if (type_needed != this_type) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Needed [%s], found [%s] %p\n", - acpi_ut_get_type_name (type_needed), - acpi_ut_get_type_name (this_type), object)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Needed [%s], found [%s] %p\n", + acpi_ut_get_type_name(type_needed), + acpi_ut_get_type_name(this_type), object)); return (AE_AML_OPERAND_TYPE); } @@ -114,7 +106,6 @@ acpi_ex_check_object_type ( return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ex_resolve_operands @@ -137,41 +128,37 @@ acpi_ex_check_object_type ( ******************************************************************************/ acpi_status -acpi_ex_resolve_operands ( - u16 opcode, - union acpi_operand_object **stack_ptr, - struct acpi_walk_state *walk_state) +acpi_ex_resolve_operands(u16 opcode, + union acpi_operand_object ** stack_ptr, + struct acpi_walk_state * walk_state) { - union acpi_operand_object *obj_desc; - acpi_status status = AE_OK; - u8 object_type; - void *temp_node; - u32 arg_types; - const struct acpi_opcode_info *op_info; - u32 this_arg_type; - acpi_object_type type_needed; - u16 target_op = 0; - - - ACPI_FUNCTION_TRACE_U32 ("ex_resolve_operands", opcode); - - - op_info = acpi_ps_get_opcode_info (opcode); + union acpi_operand_object *obj_desc; + acpi_status status = AE_OK; + u8 object_type; + void *temp_node; + u32 arg_types; + const struct acpi_opcode_info *op_info; + u32 this_arg_type; + acpi_object_type type_needed; + u16 target_op = 0; + + ACPI_FUNCTION_TRACE_U32("ex_resolve_operands", opcode); + + op_info = acpi_ps_get_opcode_info(opcode); if (op_info->class == AML_CLASS_UNKNOWN) { - return_ACPI_STATUS (AE_AML_BAD_OPCODE); + return_ACPI_STATUS(AE_AML_BAD_OPCODE); } arg_types = op_info->runtime_args; if (arg_types == ARGI_INVALID_OPCODE) { - ACPI_REPORT_ERROR (("resolve_operands: %X is not a valid AML opcode\n", - opcode)); + ACPI_REPORT_ERROR(("resolve_operands: %X is not a valid AML opcode\n", opcode)); - return_ACPI_STATUS (AE_AML_INTERNAL); + return_ACPI_STATUS(AE_AML_INTERNAL); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Opcode %X [%s] required_operand_types=%8.8X \n", - opcode, op_info->name, arg_types)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Opcode %X [%s] required_operand_types=%8.8X \n", + opcode, op_info->name, arg_types)); /* * Normal exit is with (arg_types == 0) at end of argument list. @@ -180,12 +167,11 @@ acpi_ex_resolve_operands ( * to) the required type; if stack underflows; or upon * finding a NULL stack entry (which should not happen). */ - while (GET_CURRENT_ARG_TYPE (arg_types)) { + while (GET_CURRENT_ARG_TYPE(arg_types)) { if (!stack_ptr || !*stack_ptr) { - ACPI_REPORT_ERROR (("resolve_operands: Null stack entry at %p\n", - stack_ptr)); + ACPI_REPORT_ERROR(("resolve_operands: Null stack entry at %p\n", stack_ptr)); - return_ACPI_STATUS (AE_AML_INTERNAL); + return_ACPI_STATUS(AE_AML_INTERNAL); } /* Extract useful items */ @@ -194,37 +180,37 @@ acpi_ex_resolve_operands ( /* Decode the descriptor type */ - switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { + switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) { case ACPI_DESC_TYPE_NAMED: /* Namespace Node */ - object_type = ((struct acpi_namespace_node *) obj_desc)->type; + object_type = + ((struct acpi_namespace_node *)obj_desc)->type; break; - case ACPI_DESC_TYPE_OPERAND: /* ACPI internal object */ - object_type = ACPI_GET_OBJECT_TYPE (obj_desc); + object_type = ACPI_GET_OBJECT_TYPE(obj_desc); /* Check for bad acpi_object_type */ - if (!acpi_ut_valid_object_type (object_type)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Bad operand object type [%X]\n", - object_type)); + if (!acpi_ut_valid_object_type(object_type)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Bad operand object type [%X]\n", + object_type)); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) { /* Decode the Reference */ - op_info = acpi_ps_get_opcode_info (opcode); + op_info = acpi_ps_get_opcode_info(opcode); if (op_info->class == AML_CLASS_UNKNOWN) { - return_ACPI_STATUS (AE_AML_BAD_OPCODE); + return_ACPI_STATUS(AE_AML_BAD_OPCODE); } switch (obj_desc->reference.opcode) { @@ -238,51 +224,62 @@ acpi_ex_resolve_operands ( case AML_REF_OF_OP: case AML_ARG_OP: case AML_LOCAL_OP: - case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */ - case AML_INT_NAMEPATH_OP: /* Reference to a named object */ - - ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Operand is a Reference, ref_opcode [%s]\n", - (acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name))); + case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */ + case AML_INT_NAMEPATH_OP: /* Reference to a named object */ + + ACPI_DEBUG_ONLY_MEMBERS(ACPI_DEBUG_PRINT + ((ACPI_DB_EXEC, + "Operand is a Reference, ref_opcode [%s]\n", + (acpi_ps_get_opcode_info + (obj_desc-> + reference. + opcode))-> + name))); break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Operand is a Reference, Unknown Reference Opcode %X [%s]\n", - obj_desc->reference.opcode, - (acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Operand is a Reference, Unknown Reference Opcode %X [%s]\n", + obj_desc->reference. + opcode, + (acpi_ps_get_opcode_info + (obj_desc->reference. + opcode))->name)); + + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } } break; - default: /* Invalid descriptor */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid descriptor %p [%s]\n", - obj_desc, acpi_ut_get_descriptor_name (obj_desc))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid descriptor %p [%s]\n", + obj_desc, + acpi_ut_get_descriptor_name + (obj_desc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* Get one argument type, point to the next */ - this_arg_type = GET_CURRENT_ARG_TYPE (arg_types); - INCREMENT_ARG_LIST (arg_types); + this_arg_type = GET_CURRENT_ARG_TYPE(arg_types); + INCREMENT_ARG_LIST(arg_types); /* * Handle cases where the object does not need to be * resolved to a value */ switch (this_arg_type) { - case ARGI_REF_OR_STRING: /* Can be a String or Reference */ + case ARGI_REF_OR_STRING: /* Can be a String or Reference */ - if ((ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) && - (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_STRING)) { + if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == + ACPI_DESC_TYPE_OPERAND) + && (ACPI_GET_OBJECT_TYPE(obj_desc) == + ACPI_TYPE_STRING)) { /* * String found - the string references a named object and * must be resolved to a node @@ -296,39 +293,40 @@ acpi_ex_resolve_operands ( */ /*lint -fallthrough */ - case ARGI_REFERENCE: /* References: */ + case ARGI_REFERENCE: /* References: */ case ARGI_INTEGER_REF: case ARGI_OBJECT_REF: case ARGI_DEVICE_REF: - case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ - case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ - case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ + case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ + case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ + case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ /* * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE * A Namespace Node is OK as-is */ - if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { + if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == + ACPI_DESC_TYPE_NAMED) { goto next_operand; } - status = acpi_ex_check_object_type (ACPI_TYPE_LOCAL_REFERENCE, - object_type, obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ex_check_object_type(ACPI_TYPE_LOCAL_REFERENCE, + object_type, obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } if (obj_desc->reference.opcode == AML_NAME_OP) { /* Convert a named reference to the actual named object */ temp_node = obj_desc->reference.object; - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); (*stack_ptr) = temp_node; } goto next_operand; - - case ARGI_DATAREFOBJ: /* Store operator only */ + case ARGI_DATAREFOBJ: /* Store operator only */ /* * We don't want to resolve index_op reference objects during @@ -337,8 +335,10 @@ acpi_ex_resolve_operands ( * -- All others must be resolved below. */ if ((opcode == AML_STORE_OP) && - (ACPI_GET_OBJECT_TYPE (*stack_ptr) == ACPI_TYPE_LOCAL_REFERENCE) && - ((*stack_ptr)->reference.opcode == AML_INDEX_OP)) { + (ACPI_GET_OBJECT_TYPE(*stack_ptr) == + ACPI_TYPE_LOCAL_REFERENCE) + && ((*stack_ptr)->reference.opcode == + AML_INDEX_OP)) { goto next_operand; } break; @@ -351,9 +351,9 @@ acpi_ex_resolve_operands ( /* * Resolve this object to a value */ - status = acpi_ex_resolve_to_value (stack_ptr, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_resolve_to_value(stack_ptr, walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Get the resolved object */ @@ -364,10 +364,10 @@ acpi_ex_resolve_operands ( * Check the resulting object (value) type */ switch (this_arg_type) { - /* - * For the simple cases, only one type of resolved object - * is allowed - */ + /* + * For the simple cases, only one type of resolved object + * is allowed + */ case ARGI_MUTEX: /* Need an operand of type ACPI_TYPE_MUTEX */ @@ -382,7 +382,7 @@ acpi_ex_resolve_operands ( type_needed = ACPI_TYPE_EVENT; break; - case ARGI_PACKAGE: /* Package */ + case ARGI_PACKAGE: /* Package */ /* Need an operand of type ACPI_TYPE_PACKAGE */ @@ -403,10 +403,9 @@ acpi_ex_resolve_operands ( type_needed = ACPI_TYPE_LOCAL_REFERENCE; break; - - /* - * The more complex cases allow multiple resolved object types - */ + /* + * The more complex cases allow multiple resolved object types + */ case ARGI_INTEGER: /* @@ -414,25 +413,27 @@ acpi_ex_resolve_operands ( * But we can implicitly convert from a STRING or BUFFER * Aka - "Implicit Source Operand Conversion" */ - status = acpi_ex_convert_to_integer (obj_desc, stack_ptr, 16); - if (ACPI_FAILURE (status)) { + status = + acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16); + if (ACPI_FAILURE(status)) { if (status == AE_TYPE) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Needed [Integer/String/Buffer], found [%s] %p\n", - acpi_ut_get_object_type_name (obj_desc), obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Needed [Integer/String/Buffer], found [%s] %p\n", + acpi_ut_get_object_type_name + (obj_desc), + obj_desc)); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } if (obj_desc != *stack_ptr) { - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); } goto next_operand; - case ARGI_BUFFER: /* @@ -440,25 +441,26 @@ acpi_ex_resolve_operands ( * But we can implicitly convert from a STRING or INTEGER * Aka - "Implicit Source Operand Conversion" */ - status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr); - if (ACPI_FAILURE (status)) { + status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr); + if (ACPI_FAILURE(status)) { if (status == AE_TYPE) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Needed [Integer/String/Buffer], found [%s] %p\n", - acpi_ut_get_object_type_name (obj_desc), obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Needed [Integer/String/Buffer], found [%s] %p\n", + acpi_ut_get_object_type_name + (obj_desc), + obj_desc)); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } if (obj_desc != *stack_ptr) { - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); } goto next_operand; - case ARGI_STRING: /* @@ -466,83 +468,86 @@ acpi_ex_resolve_operands ( * But we can implicitly convert from a BUFFER or INTEGER * Aka - "Implicit Source Operand Conversion" */ - status = acpi_ex_convert_to_string (obj_desc, stack_ptr, - ACPI_IMPLICIT_CONVERT_HEX); - if (ACPI_FAILURE (status)) { + status = acpi_ex_convert_to_string(obj_desc, stack_ptr, + ACPI_IMPLICIT_CONVERT_HEX); + if (ACPI_FAILURE(status)) { if (status == AE_TYPE) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Needed [Integer/String/Buffer], found [%s] %p\n", - acpi_ut_get_object_type_name (obj_desc), obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Needed [Integer/String/Buffer], found [%s] %p\n", + acpi_ut_get_object_type_name + (obj_desc), + obj_desc)); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } if (obj_desc != *stack_ptr) { - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); } goto next_operand; - case ARGI_COMPUTEDATA: /* Need an operand of type INTEGER, STRING or BUFFER */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: /* Valid operand */ - break; + break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Needed [Integer/String/Buffer], found [%s] %p\n", - acpi_ut_get_object_type_name (obj_desc), obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Needed [Integer/String/Buffer], found [%s] %p\n", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } goto next_operand; - case ARGI_BUFFER_OR_STRING: /* Need an operand of type STRING or BUFFER */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: /* Valid operand */ - break; + break; case ACPI_TYPE_INTEGER: /* Highest priority conversion is to type Buffer */ - status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ex_convert_to_buffer(obj_desc, + stack_ptr); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } if (obj_desc != *stack_ptr) { - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); } break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Needed [Integer/String/Buffer], found [%s] %p\n", - acpi_ut_get_object_type_name (obj_desc), obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Needed [Integer/String/Buffer], found [%s] %p\n", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } goto next_operand; - case ARGI_DATAOBJECT: /* * ARGI_DATAOBJECT is only used by the size_of operator. @@ -551,7 +556,7 @@ acpi_ex_resolve_operands ( * The only reference allowed here is a direct reference to * a namespace node. */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_PACKAGE: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: @@ -561,20 +566,20 @@ acpi_ex_resolve_operands ( break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Needed [Buffer/String/Package/Reference], found [%s] %p\n", - acpi_ut_get_object_type_name (obj_desc), obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Needed [Buffer/String/Package/Reference], found [%s] %p\n", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } goto next_operand; - case ARGI_COMPLEXOBJ: /* Need a buffer or package or (ACPI 2.0) String */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_PACKAGE: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: @@ -583,20 +588,20 @@ acpi_ex_resolve_operands ( break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Needed [Buffer/String/Package], found [%s] %p\n", - acpi_ut_get_object_type_name (obj_desc), obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Needed [Buffer/String/Package], found [%s] %p\n", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } goto next_operand; - case ARGI_REGION_OR_FIELD: /* Need an operand of type REGION or a FIELD in a region */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_REGION: case ACPI_TYPE_LOCAL_REGION_FIELD: case ACPI_TYPE_LOCAL_BANK_FIELD: @@ -606,20 +611,20 @@ acpi_ex_resolve_operands ( break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Needed [Region/region_field], found [%s] %p\n", - acpi_ut_get_object_type_name (obj_desc), obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Needed [Region/region_field], found [%s] %p\n", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } goto next_operand; - case ARGI_DATAREFOBJ: /* Used by the Store() operator only */ - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_INTEGER: case ACPI_TYPE_PACKAGE: case ACPI_TYPE_STRING: @@ -651,47 +656,46 @@ acpi_ex_resolve_operands ( break; } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", - acpi_ut_get_object_type_name (obj_desc), obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } goto next_operand; - default: /* Unknown type */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Internal - Unknown ARGI (required operand) type %X\n", - this_arg_type)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Internal - Unknown ARGI (required operand) type %X\n", + this_arg_type)); - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* * Make sure that the original object was resolved to the * required object type (Simple cases only). */ - status = acpi_ex_check_object_type (type_needed, - ACPI_GET_OBJECT_TYPE (*stack_ptr), *stack_ptr); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_check_object_type(type_needed, + ACPI_GET_OBJECT_TYPE + (*stack_ptr), *stack_ptr); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } -next_operand: + next_operand: /* * If more operands needed, decrement stack_ptr to point * to next operand on stack */ - if (GET_CURRENT_ARG_TYPE (arg_types)) { + if (GET_CURRENT_ARG_TYPE(arg_types)) { stack_ptr--; } } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c index 59dbfea..a7d8eea 100644 --- a/drivers/acpi/executer/exstore.c +++ b/drivers/acpi/executer/exstore.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -50,24 +49,18 @@ #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exstore") +ACPI_MODULE_NAME("exstore") /* Local prototypes */ - static void -acpi_ex_do_debug_object ( - union acpi_operand_object *source_desc, - u32 level, - u32 index); +acpi_ex_do_debug_object(union acpi_operand_object *source_desc, + u32 level, u32 index); static acpi_status -acpi_ex_store_object_to_index ( - union acpi_operand_object *val_desc, - union acpi_operand_object *dest_desc, - struct acpi_walk_state *walk_state); - +acpi_ex_store_object_to_index(union acpi_operand_object *val_desc, + union acpi_operand_object *dest_desc, + struct acpi_walk_state *walk_state); /******************************************************************************* * @@ -84,136 +77,146 @@ acpi_ex_store_object_to_index ( ******************************************************************************/ static void -acpi_ex_do_debug_object ( - union acpi_operand_object *source_desc, - u32 level, - u32 index) +acpi_ex_do_debug_object(union acpi_operand_object *source_desc, + u32 level, u32 index) { - u32 i; - + u32 i; - ACPI_FUNCTION_TRACE_PTR ("ex_do_debug_object", source_desc); + ACPI_FUNCTION_TRACE_PTR("ex_do_debug_object", source_desc); - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s", - level, " ")); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s", + level, " ")); /* Display index for package output only */ if (index > 0) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, - "(%.2u) ", index -1)); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, + "(%.2u) ", index - 1)); } if (!source_desc) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "\n")); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "\n")); return_VOID; } - if (ACPI_GET_DESCRIPTOR_TYPE (source_desc) == ACPI_DESC_TYPE_OPERAND) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: ", - acpi_ut_get_object_type_name (source_desc))); + if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) { + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%s: ", + acpi_ut_get_object_type_name + (source_desc))); - if (!acpi_ut_valid_internal_object (source_desc)) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, - "%p, Invalid Internal Object!\n", source_desc)); - return_VOID; + if (!acpi_ut_valid_internal_object(source_desc)) { + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, + "%p, Invalid Internal Object!\n", + source_desc)); + return_VOID; } - } - else if (ACPI_GET_DESCRIPTOR_TYPE (source_desc) == ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n", - acpi_ut_get_type_name (((struct acpi_namespace_node *) source_desc)->type), - source_desc)); + } else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == + ACPI_DESC_TYPE_NAMED) { + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%s: %p\n", + acpi_ut_get_type_name(((struct + acpi_namespace_node + *)source_desc)-> + type), + source_desc)); return_VOID; - } - else { + } else { return_VOID; } - switch (ACPI_GET_OBJECT_TYPE (source_desc)) { + switch (ACPI_GET_OBJECT_TYPE(source_desc)) { case ACPI_TYPE_INTEGER: /* Output correct integer width */ if (acpi_gbl_integer_byte_width == 4) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n", - (u32) source_desc->integer.value)); - } - else { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (source_desc->integer.value))); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n", + (u32) source_desc->integer. + value)); + } else { + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, + "0x%8.8X%8.8X\n", + ACPI_FORMAT_UINT64(source_desc-> + integer. + value))); } break; case ACPI_TYPE_BUFFER: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n", - (u32) source_desc->buffer.length)); - ACPI_DUMP_BUFFER (source_desc->buffer.pointer, - (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n", + (u32) source_desc->buffer.length)); + ACPI_DUMP_BUFFER(source_desc->buffer.pointer, + (source_desc->buffer.length < + 32) ? source_desc->buffer.length : 32); break; case ACPI_TYPE_STRING: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n", - source_desc->string.length, source_desc->string.pointer)); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n", + source_desc->string.length, + source_desc->string.pointer)); break; case ACPI_TYPE_PACKAGE: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X Elements]\n", - source_desc->package.count)); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, + "[0x%.2X Elements]\n", + source_desc->package.count)); /* Output the entire contents of the package */ for (i = 0; i < source_desc->package.count; i++) { - acpi_ex_do_debug_object (source_desc->package.elements[i], - level+4, i+1); + acpi_ex_do_debug_object(source_desc->package. + elements[i], level + 4, i + 1); } break; case ACPI_TYPE_LOCAL_REFERENCE: if (source_desc->reference.opcode == AML_INDEX_OP) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s, 0x%X]\n", - acpi_ps_get_opcode_name (source_desc->reference.opcode), - source_desc->reference.offset)); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, + "[%s, 0x%X]\n", + acpi_ps_get_opcode_name + (source_desc->reference.opcode), + source_desc->reference.offset)); + } else { + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[%s]\n", + acpi_ps_get_opcode_name + (source_desc->reference.opcode))); } - else { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s]\n", - acpi_ps_get_opcode_name (source_desc->reference.opcode))); - } - if (source_desc->reference.object) { - if (ACPI_GET_DESCRIPTOR_TYPE (source_desc->reference.object) == - ACPI_DESC_TYPE_NAMED) { - acpi_ex_do_debug_object (((struct acpi_namespace_node *) - source_desc->reference.object)->object, - level+4, 0); + if (ACPI_GET_DESCRIPTOR_TYPE + (source_desc->reference.object) == + ACPI_DESC_TYPE_NAMED) { + acpi_ex_do_debug_object(((struct + acpi_namespace_node *) + source_desc->reference. + object)->object, + level + 4, 0); + } else { + acpi_ex_do_debug_object(source_desc->reference. + object, level + 4, 0); } - else { - acpi_ex_do_debug_object (source_desc->reference.object, level+4, 0); - } - } - else if (source_desc->reference.node) { - acpi_ex_do_debug_object ((source_desc->reference.node)->object, - level+4, 0); + } else if (source_desc->reference.node) { + acpi_ex_do_debug_object((source_desc->reference.node)-> + object, level + 4, 0); } break; default: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p %s\n", - source_desc, acpi_ut_get_object_type_name (source_desc))); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%p %s\n", + source_desc, + acpi_ut_get_object_type_name + (source_desc))); break; } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n")); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ex_store @@ -235,42 +238,41 @@ acpi_ex_do_debug_object ( ******************************************************************************/ acpi_status -acpi_ex_store ( - union acpi_operand_object *source_desc, - union acpi_operand_object *dest_desc, - struct acpi_walk_state *walk_state) +acpi_ex_store(union acpi_operand_object *source_desc, + union acpi_operand_object *dest_desc, + struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - union acpi_operand_object *ref_desc = dest_desc; - - - ACPI_FUNCTION_TRACE_PTR ("ex_store", dest_desc); + acpi_status status = AE_OK; + union acpi_operand_object *ref_desc = dest_desc; + ACPI_FUNCTION_TRACE_PTR("ex_store", dest_desc); /* Validate parameters */ if (!source_desc || !dest_desc) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null parameter\n")); - return_ACPI_STATUS (AE_AML_NO_OPERAND); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null parameter\n")); + return_ACPI_STATUS(AE_AML_NO_OPERAND); } /* dest_desc can be either a namespace node or an ACPI object */ - if (ACPI_GET_DESCRIPTOR_TYPE (dest_desc) == ACPI_DESC_TYPE_NAMED) { + if (ACPI_GET_DESCRIPTOR_TYPE(dest_desc) == ACPI_DESC_TYPE_NAMED) { /* * Dest is a namespace node, * Storing an object into a Named node. */ - status = acpi_ex_store_object_to_node (source_desc, - (struct acpi_namespace_node *) dest_desc, walk_state, - ACPI_IMPLICIT_CONVERSION); + status = acpi_ex_store_object_to_node(source_desc, + (struct + acpi_namespace_node *) + dest_desc, walk_state, + ACPI_IMPLICIT_CONVERSION); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Destination object must be a Reference or a Constant object */ - switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { + switch (ACPI_GET_OBJECT_TYPE(dest_desc)) { case ACPI_TYPE_LOCAL_REFERENCE: break; @@ -279,7 +281,7 @@ acpi_ex_store ( /* Allow stores to Constants -- a Noop as per ACPI spec */ if (dest_desc->common.flags & AOPOBJ_AML_CONSTANT) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /*lint -fallthrough */ @@ -288,16 +290,18 @@ acpi_ex_store ( /* Destination is not a Reference object */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Target is not a Reference or Constant object - %s [%p]\n", - acpi_ut_get_object_type_name (dest_desc), dest_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Target is not a Reference or Constant object - %s [%p]\n", + acpi_ut_get_object_type_name(dest_desc), + dest_desc)); - ACPI_DUMP_STACK_ENTRY (source_desc); - ACPI_DUMP_STACK_ENTRY (dest_desc); - ACPI_DUMP_OPERANDS (&dest_desc, ACPI_IMODE_EXECUTE, "ex_store", - 2, "Target is not a Reference or Constant object"); + ACPI_DUMP_STACK_ENTRY(source_desc); + ACPI_DUMP_STACK_ENTRY(dest_desc); + ACPI_DUMP_OPERANDS(&dest_desc, ACPI_IMODE_EXECUTE, "ex_store", + 2, + "Target is not a Reference or Constant object"); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* @@ -314,58 +318,59 @@ acpi_ex_store ( /* Storing an object into a Name "container" */ - status = acpi_ex_store_object_to_node (source_desc, - ref_desc->reference.object, - walk_state, ACPI_IMPLICIT_CONVERSION); + status = acpi_ex_store_object_to_node(source_desc, + ref_desc->reference. + object, walk_state, + ACPI_IMPLICIT_CONVERSION); break; - case AML_INDEX_OP: /* Storing to an Index (pointer into a packager or buffer) */ - status = acpi_ex_store_object_to_index (source_desc, ref_desc, walk_state); + status = + acpi_ex_store_object_to_index(source_desc, ref_desc, + walk_state); break; - case AML_LOCAL_OP: case AML_ARG_OP: /* Store to a method local/arg */ - status = acpi_ds_store_object_to_local (ref_desc->reference.opcode, - ref_desc->reference.offset, source_desc, walk_state); + status = + acpi_ds_store_object_to_local(ref_desc->reference.opcode, + ref_desc->reference.offset, + source_desc, walk_state); break; - case AML_DEBUG_OP: /* * Storing to the Debug object causes the value stored to be * displayed and otherwise has no effect -- see ACPI Specification */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "**** Write to Debug Object: Object %p %s ****:\n\n", - source_desc, acpi_ut_get_object_type_name (source_desc))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "**** Write to Debug Object: Object %p %s ****:\n\n", + source_desc, + acpi_ut_get_object_type_name(source_desc))); - acpi_ex_do_debug_object (source_desc, 0, 0); + acpi_ex_do_debug_object(source_desc, 0, 0); break; - default: - ACPI_REPORT_ERROR (("ex_store: Unknown Reference opcode %X\n", - ref_desc->reference.opcode)); - ACPI_DUMP_ENTRY (ref_desc, ACPI_LV_ERROR); + ACPI_REPORT_ERROR(("ex_store: Unknown Reference opcode %X\n", + ref_desc->reference.opcode)); + ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR); status = AE_AML_INTERNAL; break; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_store_object_to_index @@ -381,20 +386,17 @@ acpi_ex_store ( ******************************************************************************/ static acpi_status -acpi_ex_store_object_to_index ( - union acpi_operand_object *source_desc, - union acpi_operand_object *index_desc, - struct acpi_walk_state *walk_state) +acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, + union acpi_operand_object *index_desc, + struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - union acpi_operand_object *obj_desc; - union acpi_operand_object *new_desc; - u8 value = 0; - u32 i; - - - ACPI_FUNCTION_TRACE ("ex_store_object_to_index"); + acpi_status status = AE_OK; + union acpi_operand_object *obj_desc; + union acpi_operand_object *new_desc; + u8 value = 0; + u32 i; + ACPI_FUNCTION_TRACE("ex_store_object_to_index"); /* * Destination must be a reference pointer, and @@ -413,19 +415,20 @@ acpi_ex_store_object_to_index ( */ obj_desc = *(index_desc->reference.where); - status = acpi_ut_copy_iobject_to_iobject (source_desc, &new_desc, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc, + walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } if (obj_desc) { /* Decrement reference count by the ref count of the parent package */ - for (i = 0; - i < ((union acpi_operand_object *) - index_desc->reference.object)->common.reference_count; - i++) { - acpi_ut_remove_reference (obj_desc); + for (i = 0; i < ((union acpi_operand_object *) + index_desc->reference.object)->common. + reference_count; i++) { + acpi_ut_remove_reference(obj_desc); } } @@ -433,16 +436,14 @@ acpi_ex_store_object_to_index ( /* Increment ref count by the ref count of the parent package-1 */ - for (i = 1; - i < ((union acpi_operand_object *) - index_desc->reference.object)->common.reference_count; - i++) { - acpi_ut_add_reference (new_desc); + for (i = 1; i < ((union acpi_operand_object *) + index_desc->reference.object)->common. + reference_count; i++) { + acpi_ut_add_reference(new_desc); } break; - case ACPI_TYPE_BUFFER_FIELD: /* @@ -460,16 +461,16 @@ acpi_ex_store_object_to_index ( * by the INDEX_OP code. */ obj_desc = index_desc->reference.object; - if ((ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_BUFFER) && - (ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_STRING)) { - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + if ((ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_BUFFER) && + (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_STRING)) { + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* * The assignment of the individual elements will be slightly * different for each source type. */ - switch (ACPI_GET_OBJECT_TYPE (source_desc)) { + switch (ACPI_GET_OBJECT_TYPE(source_desc)) { case ACPI_TYPE_INTEGER: /* Use the least-significant byte of the integer */ @@ -489,10 +490,11 @@ acpi_ex_store_object_to_index ( /* All other types are invalid */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Source must be Integer/Buffer/String type, not %s\n", - acpi_ut_get_object_type_name (source_desc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Source must be Integer/Buffer/String type, not %s\n", + acpi_ut_get_object_type_name + (source_desc))); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* Store the source value into the target buffer byte */ @@ -500,18 +502,16 @@ acpi_ex_store_object_to_index ( obj_desc->buffer.pointer[index_desc->reference.offset] = value; break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Target is not a Package or buffer_field\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Target is not a Package or buffer_field\n")); status = AE_AML_OPERAND_TYPE; break; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_store_object_to_node @@ -539,37 +539,35 @@ acpi_ex_store_object_to_index ( ******************************************************************************/ acpi_status -acpi_ex_store_object_to_node ( - union acpi_operand_object *source_desc, - struct acpi_namespace_node *node, - struct acpi_walk_state *walk_state, - u8 implicit_conversion) +acpi_ex_store_object_to_node(union acpi_operand_object *source_desc, + struct acpi_namespace_node *node, + struct acpi_walk_state *walk_state, + u8 implicit_conversion) { - acpi_status status = AE_OK; - union acpi_operand_object *target_desc; - union acpi_operand_object *new_desc; - acpi_object_type target_type; - - - ACPI_FUNCTION_TRACE_PTR ("ex_store_object_to_node", source_desc); + acpi_status status = AE_OK; + union acpi_operand_object *target_desc; + union acpi_operand_object *new_desc; + acpi_object_type target_type; + ACPI_FUNCTION_TRACE_PTR("ex_store_object_to_node", source_desc); /* Get current type of the node, and object attached to Node */ - target_type = acpi_ns_get_type (node); - target_desc = acpi_ns_get_attached_object (node); + target_type = acpi_ns_get_type(node); + target_desc = acpi_ns_get_attached_object(node); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", - source_desc, acpi_ut_get_object_type_name (source_desc), - node, acpi_ut_get_type_name (target_type))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", + source_desc, + acpi_ut_get_object_type_name(source_desc), node, + acpi_ut_get_type_name(target_type))); /* * Resolve the source object to an actual value * (If it is a reference object) */ - status = acpi_ex_resolve_object (&source_desc, target_type, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_resolve_object(&source_desc, target_type, walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* If no implicit conversion, drop into the default case below */ @@ -590,11 +588,10 @@ acpi_ex_store_object_to_node ( /* For fields, copy the source data to the target field. */ - status = acpi_ex_write_data_to_field (source_desc, target_desc, - &walk_state->result_obj); + status = acpi_ex_write_data_to_field(source_desc, target_desc, + &walk_state->result_obj); break; - case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: @@ -605,10 +602,11 @@ acpi_ex_store_object_to_node ( * * Copy and/or convert the source object to a new target object */ - status = acpi_ex_store_object_to_object (source_desc, target_desc, - &new_desc, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ex_store_object_to_object(source_desc, target_desc, + &new_desc, walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } if (new_desc != target_desc) { @@ -621,30 +619,33 @@ acpi_ex_store_object_to_node ( * has been performed such that the node/object type has been * changed. */ - status = acpi_ns_attach_object (node, new_desc, new_desc->common.type); - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Store %s into %s via Convert/Attach\n", - acpi_ut_get_object_type_name (source_desc), - acpi_ut_get_object_type_name (new_desc))); + status = + acpi_ns_attach_object(node, new_desc, + new_desc->common.type); + + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Store %s into %s via Convert/Attach\n", + acpi_ut_get_object_type_name + (source_desc), + acpi_ut_get_object_type_name + (new_desc))); } break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Storing %s (%p) directly into node (%p) with no implicit conversion\n", - acpi_ut_get_object_type_name (source_desc), source_desc, node)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Storing %s (%p) directly into node (%p) with no implicit conversion\n", + acpi_ut_get_object_type_name(source_desc), + source_desc, node)); /* No conversions for all other types. Just attach the source object */ - status = acpi_ns_attach_object (node, source_desc, - ACPI_GET_OBJECT_TYPE (source_desc)); + status = acpi_ns_attach_object(node, source_desc, + ACPI_GET_OBJECT_TYPE + (source_desc)); break; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c index 433588a..382f63c 100644 --- a/drivers/acpi/executer/exstoren.c +++ b/drivers/acpi/executer/exstoren.c @@ -43,15 +43,12 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exstoren") - +ACPI_MODULE_NAME("exstoren") /******************************************************************************* * @@ -67,19 +64,15 @@ * it and return the actual object in the source_desc_ptr. * ******************************************************************************/ - acpi_status -acpi_ex_resolve_object ( - union acpi_operand_object **source_desc_ptr, - acpi_object_type target_type, - struct acpi_walk_state *walk_state) +acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, + acpi_object_type target_type, + struct acpi_walk_state *walk_state) { - union acpi_operand_object *source_desc = *source_desc_ptr; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ex_resolve_object"); + union acpi_operand_object *source_desc = *source_desc_ptr; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ex_resolve_object"); /* Ensure we have a Target that can be stored to */ @@ -102,11 +95,14 @@ acpi_ex_resolve_object ( * are all essentially the same. This case handles the * "interchangeable" types Integer, String, and Buffer. */ - if (ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_LOCAL_REFERENCE) { + if (ACPI_GET_OBJECT_TYPE(source_desc) == + ACPI_TYPE_LOCAL_REFERENCE) { /* Resolve a reference object first */ - status = acpi_ex_resolve_to_value (source_desc_ptr, walk_state); - if (ACPI_FAILURE (status)) { + status = + acpi_ex_resolve_to_value(source_desc_ptr, + walk_state); + if (ACPI_FAILURE(status)) { break; } } @@ -119,31 +115,32 @@ acpi_ex_resolve_object ( /* Must have a Integer, Buffer, or String */ - if ((ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_INTEGER) && - (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) && - (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_STRING) && - !((ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_LOCAL_REFERENCE) && (source_desc->reference.opcode == AML_LOAD_OP))) { + if ((ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) && + (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) && + (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) && + !((ACPI_GET_OBJECT_TYPE(source_desc) == + ACPI_TYPE_LOCAL_REFERENCE) + && (source_desc->reference.opcode == AML_LOAD_OP))) { /* Conversion successful but still not a valid type */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Cannot assign type %s to %s (must be type Int/Str/Buf)\n", - acpi_ut_get_object_type_name (source_desc), - acpi_ut_get_type_name (target_type))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Cannot assign type %s to %s (must be type Int/Str/Buf)\n", + acpi_ut_get_object_type_name + (source_desc), + acpi_ut_get_type_name(target_type))); status = AE_AML_OPERAND_TYPE; } break; - case ACPI_TYPE_LOCAL_ALIAS: case ACPI_TYPE_LOCAL_METHOD_ALIAS: /* Aliases are resolved by acpi_ex_prep_operands */ - ACPI_REPORT_ERROR (("Store into Alias - should never happen\n")); + ACPI_REPORT_ERROR(("Store into Alias - should never happen\n")); status = AE_AML_INTERNAL; break; - case ACPI_TYPE_PACKAGE: default: @@ -154,10 +151,9 @@ acpi_ex_resolve_object ( break; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_store_object_to_object @@ -194,18 +190,15 @@ acpi_ex_resolve_object ( ******************************************************************************/ acpi_status -acpi_ex_store_object_to_object ( - union acpi_operand_object *source_desc, - union acpi_operand_object *dest_desc, - union acpi_operand_object **new_desc, - struct acpi_walk_state *walk_state) +acpi_ex_store_object_to_object(union acpi_operand_object *source_desc, + union acpi_operand_object *dest_desc, + union acpi_operand_object **new_desc, + struct acpi_walk_state *walk_state) { - union acpi_operand_object *actual_src_desc; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_PTR ("ex_store_object_to_object", source_desc); + union acpi_operand_object *actual_src_desc; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE_PTR("ex_store_object_to_object", source_desc); actual_src_desc = source_desc; if (!dest_desc) { @@ -214,11 +207,14 @@ acpi_ex_store_object_to_object ( * package element), so we can simply copy the source object * creating a new destination object */ - status = acpi_ut_copy_iobject_to_iobject (actual_src_desc, new_desc, walk_state); - return_ACPI_STATUS (status); + status = + acpi_ut_copy_iobject_to_iobject(actual_src_desc, new_desc, + walk_state); + return_ACPI_STATUS(status); } - if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_GET_OBJECT_TYPE (dest_desc)) { + if (ACPI_GET_OBJECT_TYPE(source_desc) != + ACPI_GET_OBJECT_TYPE(dest_desc)) { /* * The source type does not match the type of the destination. * Perform the "implicit conversion" of the source to the current type @@ -228,10 +224,13 @@ acpi_ex_store_object_to_object ( * Otherwise, actual_src_desc is a temporary object to hold the * converted object. */ - status = acpi_ex_convert_to_target_type (ACPI_GET_OBJECT_TYPE (dest_desc), - source_desc, &actual_src_desc, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ex_convert_to_target_type(ACPI_GET_OBJECT_TYPE + (dest_desc), source_desc, + &actual_src_desc, + walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } if (source_desc == actual_src_desc) { @@ -240,7 +239,7 @@ acpi_ex_store_object_to_object ( * new object. */ *new_desc = source_desc; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } } @@ -248,38 +247,42 @@ acpi_ex_store_object_to_object ( * We now have two objects of identical types, and we can perform a * copy of the *value* of the source object. */ - switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { + switch (ACPI_GET_OBJECT_TYPE(dest_desc)) { case ACPI_TYPE_INTEGER: dest_desc->integer.value = actual_src_desc->integer.value; /* Truncate value if we are executing from a 32-bit ACPI table */ - acpi_ex_truncate_for32bit_table (dest_desc); + acpi_ex_truncate_for32bit_table(dest_desc); break; case ACPI_TYPE_STRING: - status = acpi_ex_store_string_to_string (actual_src_desc, dest_desc); + status = + acpi_ex_store_string_to_string(actual_src_desc, dest_desc); break; case ACPI_TYPE_BUFFER: - status = acpi_ex_store_buffer_to_buffer (actual_src_desc, dest_desc); + status = + acpi_ex_store_buffer_to_buffer(actual_src_desc, dest_desc); break; case ACPI_TYPE_PACKAGE: - status = acpi_ut_copy_iobject_to_iobject (actual_src_desc, &dest_desc, - walk_state); + status = + acpi_ut_copy_iobject_to_iobject(actual_src_desc, &dest_desc, + walk_state); break; default: /* * All other types come here. */ - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into type %s not implemented\n", - acpi_ut_get_object_type_name (dest_desc))); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Store into type %s not implemented\n", + acpi_ut_get_object_type_name(dest_desc))); status = AE_NOT_IMPLEMENTED; break; @@ -288,11 +291,9 @@ acpi_ex_store_object_to_object ( if (actual_src_desc != source_desc) { /* Delete the intermediate (temporary) source object */ - acpi_ut_remove_reference (actual_src_desc); + acpi_ut_remove_reference(actual_src_desc); } *new_desc = dest_desc; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/executer/exstorob.c index 12d1527..c4ff654 100644 --- a/drivers/acpi/executer/exstorob.c +++ b/drivers/acpi/executer/exstorob.c @@ -42,14 +42,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exstorob") - +ACPI_MODULE_NAME("exstorob") /******************************************************************************* * @@ -63,18 +60,14 @@ * DESCRIPTION: Copy a buffer object to another buffer object. * ******************************************************************************/ - acpi_status -acpi_ex_store_buffer_to_buffer ( - union acpi_operand_object *source_desc, - union acpi_operand_object *target_desc) +acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc, + union acpi_operand_object *target_desc) { - u32 length; - u8 *buffer; - - - ACPI_FUNCTION_TRACE_PTR ("ex_store_buffer_to_buffer", source_desc); + u32 length; + u8 *buffer; + ACPI_FUNCTION_TRACE_PTR("ex_store_buffer_to_buffer", source_desc); /* We know that source_desc is a buffer by now */ @@ -86,10 +79,10 @@ acpi_ex_store_buffer_to_buffer ( * allocate a new buffer of the proper length */ if ((target_desc->buffer.length == 0) || - (target_desc->common.flags & AOPOBJ_STATIC_POINTER)) { - target_desc->buffer.pointer = ACPI_MEM_ALLOCATE (length); + (target_desc->common.flags & AOPOBJ_STATIC_POINTER)) { + target_desc->buffer.pointer = ACPI_MEM_ALLOCATE(length); if (!target_desc->buffer.pointer) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } target_desc->buffer.length = length; @@ -100,8 +93,9 @@ acpi_ex_store_buffer_to_buffer ( if (length <= target_desc->buffer.length) { /* Clear existing buffer and copy in the new one */ - ACPI_MEMSET (target_desc->buffer.pointer, 0, target_desc->buffer.length); - ACPI_MEMCPY (target_desc->buffer.pointer, buffer, length); + ACPI_MEMSET(target_desc->buffer.pointer, 0, + target_desc->buffer.length); + ACPI_MEMCPY(target_desc->buffer.pointer, buffer, length); #ifdef ACPI_OBSOLETE_BEHAVIOR /* @@ -124,26 +118,24 @@ acpi_ex_store_buffer_to_buffer ( target_desc->buffer.length = length; } #endif - } - else { + } else { /* Truncate the source, copy only what will fit */ - ACPI_MEMCPY (target_desc->buffer.pointer, buffer, - target_desc->buffer.length); + ACPI_MEMCPY(target_desc->buffer.pointer, buffer, + target_desc->buffer.length); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Truncating source buffer from %X to %X\n", - length, target_desc->buffer.length)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Truncating source buffer from %X to %X\n", + length, target_desc->buffer.length)); } /* Copy flags */ target_desc->buffer.flags = source_desc->buffer.flags; target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ex_store_string_to_string @@ -158,16 +150,13 @@ acpi_ex_store_buffer_to_buffer ( ******************************************************************************/ acpi_status -acpi_ex_store_string_to_string ( - union acpi_operand_object *source_desc, - union acpi_operand_object *target_desc) +acpi_ex_store_string_to_string(union acpi_operand_object *source_desc, + union acpi_operand_object *target_desc) { - u32 length; - u8 *buffer; - - - ACPI_FUNCTION_TRACE_PTR ("ex_store_string_to_string", source_desc); + u32 length; + u8 *buffer; + ACPI_FUNCTION_TRACE_PTR("ex_store_string_to_string", source_desc); /* We know that source_desc is a string by now */ @@ -179,41 +168,38 @@ acpi_ex_store_string_to_string ( * pointer is not a static pointer (part of an ACPI table) */ if ((length < target_desc->string.length) && - (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) { + (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) { /* * String will fit in existing non-static buffer. * Clear old string and copy in the new one */ - ACPI_MEMSET (target_desc->string.pointer, 0, - (acpi_size) target_desc->string.length + 1); - ACPI_MEMCPY (target_desc->string.pointer, buffer, length); - } - else { + ACPI_MEMSET(target_desc->string.pointer, 0, + (acpi_size) target_desc->string.length + 1); + ACPI_MEMCPY(target_desc->string.pointer, buffer, length); + } else { /* * Free the current buffer, then allocate a new buffer * large enough to hold the value */ if (target_desc->string.pointer && - (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) { + (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) { /* Only free if not a pointer into the DSDT */ - ACPI_MEM_FREE (target_desc->string.pointer); + ACPI_MEM_FREE(target_desc->string.pointer); } - target_desc->string.pointer = ACPI_MEM_CALLOCATE ( - (acpi_size) length + 1); + target_desc->string.pointer = ACPI_MEM_CALLOCATE((acpi_size) + length + 1); if (!target_desc->string.pointer) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; - ACPI_MEMCPY (target_desc->string.pointer, buffer, length); + ACPI_MEMCPY(target_desc->string.pointer, buffer, length); } /* Set the new target length */ target_desc->string.length = length; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - - diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c index cafa702..8a88b84 100644 --- a/drivers/acpi/executer/exsystem.c +++ b/drivers/acpi/executer/exsystem.c @@ -42,14 +42,12 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exsystem") - +ACPI_MODULE_NAME("exsystem") /******************************************************************************* * @@ -65,49 +63,42 @@ * interpreter is released. * ******************************************************************************/ - -acpi_status -acpi_ex_system_wait_semaphore ( - acpi_handle semaphore, - u16 timeout) +acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout) { - acpi_status status; - acpi_status status2; - + acpi_status status; + acpi_status status2; - ACPI_FUNCTION_TRACE ("ex_system_wait_semaphore"); + ACPI_FUNCTION_TRACE("ex_system_wait_semaphore"); - - status = acpi_os_wait_semaphore (semaphore, 1, 0); - if (ACPI_SUCCESS (status)) { - return_ACPI_STATUS (status); + status = acpi_os_wait_semaphore(semaphore, 1, 0); + if (ACPI_SUCCESS(status)) { + return_ACPI_STATUS(status); } if (status == AE_TIME) { /* We must wait, so unlock the interpreter */ - acpi_ex_exit_interpreter (); + acpi_ex_exit_interpreter(); - status = acpi_os_wait_semaphore (semaphore, 1, timeout); + status = acpi_os_wait_semaphore(semaphore, 1, timeout); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "*** Thread awake after blocking, %s\n", - acpi_format_exception (status))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "*** Thread awake after blocking, %s\n", + acpi_format_exception(status))); /* Reacquire the interpreter */ - status2 = acpi_ex_enter_interpreter (); - if (ACPI_FAILURE (status2)) { + status2 = acpi_ex_enter_interpreter(); + if (ACPI_FAILURE(status2)) { /* Report fatal error, could not acquire interpreter */ - return_ACPI_STATUS (status2); + return_ACPI_STATUS(status2); } } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_system_do_stall @@ -125,35 +116,29 @@ acpi_ex_system_wait_semaphore ( * ******************************************************************************/ -acpi_status -acpi_ex_system_do_stall ( - u32 how_long) +acpi_status acpi_ex_system_do_stall(u32 how_long) { - acpi_status status = AE_OK; - + acpi_status status = AE_OK; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); - - if (how_long > 255) /* 255 microseconds */ { + if (how_long > 255) { /* 255 microseconds */ /* * Longer than 255 usec, this is an error * * (ACPI specifies 100 usec as max, but this gives some slack in * order to support existing BIOSs) */ - ACPI_REPORT_ERROR (("Stall: Time parameter is too large (%d)\n", - how_long)); + ACPI_REPORT_ERROR(("Stall: Time parameter is too large (%d)\n", + how_long)); status = AE_AML_OPERAND_VALUE; - } - else { - acpi_os_stall (how_long); + } else { + acpi_os_stall(how_long); } return (status); } - /******************************************************************************* * * FUNCTION: acpi_ex_system_do_suspend @@ -167,29 +152,24 @@ acpi_ex_system_do_stall ( * ******************************************************************************/ -acpi_status -acpi_ex_system_do_suspend ( - acpi_integer how_long) +acpi_status acpi_ex_system_do_suspend(acpi_integer how_long) { - acpi_status status; - - - ACPI_FUNCTION_ENTRY (); + acpi_status status; + ACPI_FUNCTION_ENTRY(); /* Since this thread will sleep, we must release the interpreter */ - acpi_ex_exit_interpreter (); + acpi_ex_exit_interpreter(); - acpi_os_sleep (how_long); + acpi_os_sleep(how_long); /* And now we must get the interpreter again */ - status = acpi_ex_enter_interpreter (); + status = acpi_ex_enter_interpreter(); return (status); } - /******************************************************************************* * * FUNCTION: acpi_ex_system_acquire_mutex @@ -206,33 +186,30 @@ acpi_ex_system_do_suspend ( ******************************************************************************/ acpi_status -acpi_ex_system_acquire_mutex ( - union acpi_operand_object *time_desc, - union acpi_operand_object *obj_desc) +acpi_ex_system_acquire_mutex(union acpi_operand_object * time_desc, + union acpi_operand_object * obj_desc) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_PTR ("ex_system_acquire_mutex", obj_desc); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE_PTR("ex_system_acquire_mutex", obj_desc); if (!obj_desc) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Support for the _GL_ Mutex object -- go get the global lock */ if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { - status = acpi_ev_acquire_global_lock ((u16) time_desc->integer.value); - return_ACPI_STATUS (status); + status = + acpi_ev_acquire_global_lock((u16) time_desc->integer.value); + return_ACPI_STATUS(status); } - status = acpi_ex_system_wait_semaphore (obj_desc->mutex.semaphore, - (u16) time_desc->integer.value); - return_ACPI_STATUS (status); + status = acpi_ex_system_wait_semaphore(obj_desc->mutex.semaphore, + (u16) time_desc->integer.value); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_system_release_mutex @@ -248,32 +225,27 @@ acpi_ex_system_acquire_mutex ( * ******************************************************************************/ -acpi_status -acpi_ex_system_release_mutex ( - union acpi_operand_object *obj_desc) +acpi_status acpi_ex_system_release_mutex(union acpi_operand_object *obj_desc) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ex_system_release_mutex"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ex_system_release_mutex"); if (!obj_desc) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Support for the _GL_ Mutex object -- release the global lock */ if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { - status = acpi_ev_release_global_lock (); - return_ACPI_STATUS (status); + status = acpi_ev_release_global_lock(); + return_ACPI_STATUS(status); } - status = acpi_os_signal_semaphore (obj_desc->mutex.semaphore, 1); - return_ACPI_STATUS (status); + status = acpi_os_signal_semaphore(obj_desc->mutex.semaphore, 1); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_system_signal_event @@ -287,24 +259,19 @@ acpi_ex_system_release_mutex ( * ******************************************************************************/ -acpi_status -acpi_ex_system_signal_event ( - union acpi_operand_object *obj_desc) +acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ex_system_signal_event"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ex_system_signal_event"); if (obj_desc) { - status = acpi_os_signal_semaphore (obj_desc->event.semaphore, 1); + status = acpi_os_signal_semaphore(obj_desc->event.semaphore, 1); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_system_wait_event @@ -321,25 +288,23 @@ acpi_ex_system_signal_event ( ******************************************************************************/ acpi_status -acpi_ex_system_wait_event ( - union acpi_operand_object *time_desc, - union acpi_operand_object *obj_desc) +acpi_ex_system_wait_event(union acpi_operand_object *time_desc, + union acpi_operand_object *obj_desc) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ex_system_wait_event"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ex_system_wait_event"); if (obj_desc) { - status = acpi_ex_system_wait_semaphore (obj_desc->event.semaphore, - (u16) time_desc->integer.value); + status = + acpi_ex_system_wait_semaphore(obj_desc->event.semaphore, + (u16) time_desc->integer. + value); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_system_reset_event @@ -352,27 +317,23 @@ acpi_ex_system_wait_event ( * ******************************************************************************/ -acpi_status -acpi_ex_system_reset_event ( - union acpi_operand_object *obj_desc) +acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc) { - acpi_status status = AE_OK; - void *temp_semaphore; - - - ACPI_FUNCTION_ENTRY (); + acpi_status status = AE_OK; + void *temp_semaphore; + ACPI_FUNCTION_ENTRY(); /* * We are going to simply delete the existing semaphore and * create a new one! */ - status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore); - if (ACPI_SUCCESS (status)) { - (void) acpi_os_delete_semaphore (obj_desc->event.semaphore); + status = + acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore); + if (ACPI_SUCCESS(status)) { + (void)acpi_os_delete_semaphore(obj_desc->event.semaphore); obj_desc->event.semaphore = temp_semaphore; } return (status); } - diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c index d00b0dc..1ee79d8 100644 --- a/drivers/acpi/executer/exutils.c +++ b/drivers/acpi/executer/exutils.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* * DEFINE_AML_GLOBALS is tested in amlcode.h * to determine whether certain global names should be "defined" or only @@ -65,15 +64,10 @@ #include #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exutils") +ACPI_MODULE_NAME("exutils") /* Local prototypes */ - -static u32 -acpi_ex_digits_needed ( - acpi_integer value, - u32 base); - +static u32 acpi_ex_digits_needed(acpi_integer value, u32 base); #ifndef ACPI_NO_METHOD_EXECUTION /******************************************************************************* @@ -89,24 +83,20 @@ acpi_ex_digits_needed ( * ******************************************************************************/ -acpi_status -acpi_ex_enter_interpreter ( - void) +acpi_status acpi_ex_enter_interpreter(void) { - acpi_status status; - - ACPI_FUNCTION_TRACE ("ex_enter_interpreter"); + acpi_status status; + ACPI_FUNCTION_TRACE("ex_enter_interpreter"); - status = acpi_ut_acquire_mutex (ACPI_MTX_EXECUTE); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not acquire interpreter mutex\n")); + status = acpi_ut_acquire_mutex(ACPI_MTX_EXECUTE); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not acquire interpreter mutex\n")); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ex_exit_interpreter @@ -129,25 +119,20 @@ acpi_ex_enter_interpreter ( * ******************************************************************************/ -void -acpi_ex_exit_interpreter ( - void) +void acpi_ex_exit_interpreter(void) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ex_exit_interpreter"); + acpi_status status; + ACPI_FUNCTION_TRACE("ex_exit_interpreter"); - status = acpi_ut_release_mutex (ACPI_MTX_EXECUTE); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not release interpreter mutex\n")); + status = acpi_ut_release_mutex(ACPI_MTX_EXECUTE); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not release interpreter mutex\n")); } return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ex_truncate_for32bit_table @@ -161,20 +146,17 @@ acpi_ex_exit_interpreter ( * ******************************************************************************/ -void -acpi_ex_truncate_for32bit_table ( - union acpi_operand_object *obj_desc) +void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc) { - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_ENTRY(); /* * Object must be a valid number and we must be executing * a control method */ if ((!obj_desc) || - (ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_INTEGER)) { + (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER)) { return; } @@ -187,7 +169,6 @@ acpi_ex_truncate_for32bit_table ( } } - /******************************************************************************* * * FUNCTION: acpi_ex_acquire_global_lock @@ -203,37 +184,31 @@ acpi_ex_truncate_for32bit_table ( * ******************************************************************************/ -u8 -acpi_ex_acquire_global_lock ( - u32 field_flags) +u8 acpi_ex_acquire_global_lock(u32 field_flags) { - u8 locked = FALSE; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ex_acquire_global_lock"); + u8 locked = FALSE; + acpi_status status; + ACPI_FUNCTION_TRACE("ex_acquire_global_lock"); /* Only attempt lock if the always_lock bit is set */ if (field_flags & AML_FIELD_LOCK_RULE_MASK) { /* We should attempt to get the lock, wait forever */ - status = acpi_ev_acquire_global_lock (ACPI_WAIT_FOREVER); - if (ACPI_SUCCESS (status)) { + status = acpi_ev_acquire_global_lock(ACPI_WAIT_FOREVER); + if (ACPI_SUCCESS(status)) { locked = TRUE; - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not acquire Global Lock, %s\n", - acpi_format_exception (status))); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not acquire Global Lock, %s\n", + acpi_format_exception(status))); } } - return_VALUE (locked); + return_VALUE(locked); } - /******************************************************************************* * * FUNCTION: acpi_ex_release_global_lock @@ -247,34 +222,28 @@ acpi_ex_acquire_global_lock ( * ******************************************************************************/ -void -acpi_ex_release_global_lock ( - u8 locked_by_me) +void acpi_ex_release_global_lock(u8 locked_by_me) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ex_release_global_lock"); + acpi_status status; + ACPI_FUNCTION_TRACE("ex_release_global_lock"); /* Only attempt unlock if the caller locked it */ if (locked_by_me) { /* OK, now release the lock */ - status = acpi_ev_release_global_lock (); - if (ACPI_FAILURE (status)) { + status = acpi_ev_release_global_lock(); + if (ACPI_FAILURE(status)) { /* Report the error, but there isn't much else we can do */ - ACPI_REPORT_ERROR (("Could not release ACPI Global Lock, %s\n", - acpi_format_exception (status))); + ACPI_REPORT_ERROR(("Could not release ACPI Global Lock, %s\n", acpi_format_exception(status))); } } return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ex_digits_needed @@ -289,22 +258,17 @@ acpi_ex_release_global_lock ( * ******************************************************************************/ -static u32 -acpi_ex_digits_needed ( - acpi_integer value, - u32 base) +static u32 acpi_ex_digits_needed(acpi_integer value, u32 base) { - u32 num_digits; - acpi_integer current_value; - - - ACPI_FUNCTION_TRACE ("ex_digits_needed"); + u32 num_digits; + acpi_integer current_value; + ACPI_FUNCTION_TRACE("ex_digits_needed"); /* acpi_integer is unsigned, so we don't worry about a '-' prefix */ if (value == 0) { - return_VALUE (1); + return_VALUE(1); } current_value = value; @@ -313,14 +277,14 @@ acpi_ex_digits_needed ( /* Count the digits in the requested base */ while (current_value) { - (void) acpi_ut_short_divide (current_value, base, ¤t_value, NULL); + (void)acpi_ut_short_divide(current_value, base, ¤t_value, + NULL); num_digits++; } - return_VALUE (num_digits); + return_VALUE(num_digits); } - /******************************************************************************* * * FUNCTION: acpi_ex_eisa_id_to_string @@ -334,32 +298,26 @@ acpi_ex_digits_needed ( * ******************************************************************************/ -void -acpi_ex_eisa_id_to_string ( - u32 numeric_id, - char *out_string) +void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string) { - u32 eisa_id; - - - ACPI_FUNCTION_ENTRY (); + u32 eisa_id; + ACPI_FUNCTION_ENTRY(); /* Swap ID to big-endian to get contiguous bits */ - eisa_id = acpi_ut_dword_byte_swap (numeric_id); + eisa_id = acpi_ut_dword_byte_swap(numeric_id); - out_string[0] = (char) ('@' + (((unsigned long) eisa_id >> 26) & 0x1f)); - out_string[1] = (char) ('@' + ((eisa_id >> 21) & 0x1f)); - out_string[2] = (char) ('@' + ((eisa_id >> 16) & 0x1f)); - out_string[3] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 12); - out_string[4] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 8); - out_string[5] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 4); - out_string[6] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 0); + out_string[0] = (char)('@' + (((unsigned long)eisa_id >> 26) & 0x1f)); + out_string[1] = (char)('@' + ((eisa_id >> 21) & 0x1f)); + out_string[2] = (char)('@' + ((eisa_id >> 16) & 0x1f)); + out_string[3] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 12); + out_string[4] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 8); + out_string[5] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 4); + out_string[6] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 0); out_string[7] = 0; } - /******************************************************************************* * * FUNCTION: acpi_ex_unsigned_integer_to_string @@ -374,25 +332,20 @@ acpi_ex_eisa_id_to_string ( * ******************************************************************************/ -void -acpi_ex_unsigned_integer_to_string ( - acpi_integer value, - char *out_string) +void acpi_ex_unsigned_integer_to_string(acpi_integer value, char *out_string) { - u32 count; - u32 digits_needed; - u32 remainder; - - - ACPI_FUNCTION_ENTRY (); + u32 count; + u32 digits_needed; + u32 remainder; + ACPI_FUNCTION_ENTRY(); - digits_needed = acpi_ex_digits_needed (value, 10); + digits_needed = acpi_ex_digits_needed(value, 10); out_string[digits_needed] = 0; for (count = digits_needed; count > 0; count--) { - (void) acpi_ut_short_divide (value, 10, &value, &remainder); - out_string[count-1] = (char) ('0' + remainder);\ + (void)acpi_ut_short_divide(value, 10, &value, &remainder); + out_string[count - 1] = (char)('0' + remainder); } } diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index 2ee1d06..e8165c4 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c @@ -34,49 +34,45 @@ #include #include - #define ACPI_FAN_COMPONENT 0x00200000 #define ACPI_FAN_CLASS "fan" #define ACPI_FAN_DRIVER_NAME "ACPI Fan Driver" #define ACPI_FAN_FILE_STATE "state" #define _COMPONENT ACPI_FAN_COMPONENT -ACPI_MODULE_NAME ("acpi_fan") +ACPI_MODULE_NAME("acpi_fan") -MODULE_AUTHOR("Paul Diefenbaugh"); + MODULE_AUTHOR("Paul Diefenbaugh"); MODULE_DESCRIPTION(ACPI_FAN_DRIVER_NAME); MODULE_LICENSE("GPL"); -static int acpi_fan_add (struct acpi_device *device); -static int acpi_fan_remove (struct acpi_device *device, int type); +static int acpi_fan_add(struct acpi_device *device); +static int acpi_fan_remove(struct acpi_device *device, int type); static struct acpi_driver acpi_fan_driver = { - .name = ACPI_FAN_DRIVER_NAME, - .class = ACPI_FAN_CLASS, - .ids = "PNP0C0B", - .ops = { - .add = acpi_fan_add, - .remove = acpi_fan_remove, - }, + .name = ACPI_FAN_DRIVER_NAME, + .class = ACPI_FAN_CLASS, + .ids = "PNP0C0B", + .ops = { + .add = acpi_fan_add, + .remove = acpi_fan_remove, + }, }; struct acpi_fan { - acpi_handle handle; + acpi_handle handle; }; - /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ -static struct proc_dir_entry *acpi_fan_dir; - +static struct proc_dir_entry *acpi_fan_dir; -static int -acpi_fan_read_state(struct seq_file *seq, void *offset) +static int acpi_fan_read_state(struct seq_file *seq, void *offset) { - struct acpi_fan *fan = seq->private; - int state = 0; + struct acpi_fan *fan = seq->private; + int state = 0; ACPI_FUNCTION_TRACE("acpi_fan_read_state"); @@ -85,7 +81,7 @@ acpi_fan_read_state(struct seq_file *seq, void *offset) seq_printf(seq, "status: ERROR\n"); else seq_printf(seq, "status: %s\n", - !state?"on":"off"); + !state ? "on" : "off"); } return_VALUE(0); } @@ -96,26 +92,26 @@ static int acpi_fan_state_open_fs(struct inode *inode, struct file *file) } static ssize_t -acpi_fan_write_state(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) +acpi_fan_write_state(struct file *file, const char __user * buffer, + size_t count, loff_t * ppos) { - int result = 0; - struct seq_file *m = (struct seq_file *)file->private_data; - struct acpi_fan *fan = (struct acpi_fan *) m->private; - char state_string[12] = {'\0'}; + int result = 0; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_fan *fan = (struct acpi_fan *)m->private; + char state_string[12] = { '\0' }; ACPI_FUNCTION_TRACE("acpi_fan_write_state"); if (!fan || (count > sizeof(state_string) - 1)) return_VALUE(-EINVAL); - + if (copy_from_user(state_string, buffer, count)) return_VALUE(-EFAULT); - + state_string[count] = '\0'; - - result = acpi_bus_set_power(fan->handle, - simple_strtoul(state_string, NULL, 0)); + + result = acpi_bus_set_power(fan->handle, + simple_strtoul(state_string, NULL, 0)); if (result) return_VALUE(result); @@ -123,18 +119,17 @@ acpi_fan_write_state(struct file *file, const char __user *buffer, } static struct file_operations acpi_fan_state_ops = { - .open = acpi_fan_state_open_fs, - .read = seq_read, - .write = acpi_fan_write_state, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_fan_state_open_fs, + .read = seq_read, + .write = acpi_fan_write_state, + .llseek = seq_lseek, + .release = single_release, .owner = THIS_MODULE, }; -static int -acpi_fan_add_fs(struct acpi_device *device) +static int acpi_fan_add_fs(struct acpi_device *device) { - struct proc_dir_entry *entry = NULL; + struct proc_dir_entry *entry = NULL; ACPI_FUNCTION_TRACE("acpi_fan_add_fs"); @@ -143,7 +138,7 @@ acpi_fan_add_fs(struct acpi_device *device) if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), - acpi_fan_dir); + acpi_fan_dir); if (!acpi_device_dir(device)) return_VALUE(-ENODEV); acpi_device_dir(device)->owner = THIS_MODULE; @@ -151,11 +146,12 @@ acpi_fan_add_fs(struct acpi_device *device) /* 'status' [R/W] */ entry = create_proc_entry(ACPI_FAN_FILE_STATE, - S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_FAN_FILE_STATE)); + "Unable to create '%s' fs entry\n", + ACPI_FAN_FILE_STATE)); else { entry->proc_fops = &acpi_fan_state_ops; entry->data = acpi_driver_data(device); @@ -165,15 +161,12 @@ acpi_fan_add_fs(struct acpi_device *device) return_VALUE(0); } - -static int -acpi_fan_remove_fs(struct acpi_device *device) +static int acpi_fan_remove_fs(struct acpi_device *device) { ACPI_FUNCTION_TRACE("acpi_fan_remove_fs"); if (acpi_device_dir(device)) { - remove_proc_entry(ACPI_FAN_FILE_STATE, - acpi_device_dir(device)); + remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device)); remove_proc_entry(acpi_device_bid(device), acpi_fan_dir); acpi_device_dir(device) = NULL; } @@ -181,17 +174,15 @@ acpi_fan_remove_fs(struct acpi_device *device) return_VALUE(0); } - /* -------------------------------------------------------------------------- Driver Interface -------------------------------------------------------------------------- */ -static int -acpi_fan_add(struct acpi_device *device) +static int acpi_fan_add(struct acpi_device *device) { - int result = 0; - struct acpi_fan *fan = NULL; - int state = 0; + int result = 0; + struct acpi_fan *fan = NULL; + int state = 0; ACPI_FUNCTION_TRACE("acpi_fan_add"); @@ -211,7 +202,7 @@ acpi_fan_add(struct acpi_device *device) result = acpi_bus_get_power(fan->handle, &state); if (result) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error reading power state\n")); + "Error reading power state\n")); goto end; } @@ -220,19 +211,17 @@ acpi_fan_add(struct acpi_device *device) goto end; printk(KERN_INFO PREFIX "%s [%s] (%s)\n", - acpi_device_name(device), acpi_device_bid(device), - !device->power.state?"on":"off"); + acpi_device_name(device), acpi_device_bid(device), + !device->power.state ? "on" : "off"); -end: + end: if (result) kfree(fan); return_VALUE(result); } - -static int -acpi_fan_remove(struct acpi_device *device, int type) +static int acpi_fan_remove(struct acpi_device *device, int type) { struct acpi_fan *fan = NULL; @@ -241,7 +230,7 @@ acpi_fan_remove(struct acpi_device *device, int type) if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); - fan = (struct acpi_fan *) acpi_driver_data(device); + fan = (struct acpi_fan *)acpi_driver_data(device); acpi_fan_remove_fs(device); @@ -250,9 +239,7 @@ acpi_fan_remove(struct acpi_device *device, int type) return_VALUE(0); } - -static int __init -acpi_fan_init(void) +static int __init acpi_fan_init(void) { int result = 0; @@ -272,9 +259,7 @@ acpi_fan_init(void) return_VALUE(0); } - -static void __exit -acpi_fan_exit(void) +static void __exit acpi_fan_exit(void) { ACPI_FUNCTION_TRACE("acpi_fan_exit"); @@ -285,7 +270,5 @@ acpi_fan_exit(void) return_VOID; } - module_init(acpi_fan_init); module_exit(acpi_fan_exit); - diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 770cfc8..1943461 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -29,7 +29,8 @@ int register_acpi_bus_type(struct acpi_bus_type *type) down_write(&bus_type_sem); list_add_tail(&type->list, &bus_type_list); up_write(&bus_type_sem); - printk(KERN_INFO PREFIX "bus type %s registered\n", type->bus->name); + printk(KERN_INFO PREFIX "bus type %s registered\n", + type->bus->name); return 0; } return -ENODEV; @@ -45,7 +46,8 @@ int unregister_acpi_bus_type(struct acpi_bus_type *type) down_write(&bus_type_sem); list_del_init(&type->list); up_write(&bus_type_sem); - printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n", type->bus->name); + printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n", + type->bus->name); return 0; } return -ENODEV; diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c index b51001e..1bb3463 100644 --- a/drivers/acpi/hardware/hwacpi.c +++ b/drivers/acpi/hardware/hwacpi.c @@ -42,13 +42,10 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include - #define _COMPONENT ACPI_HARDWARE - ACPI_MODULE_NAME ("hwacpi") - +ACPI_MODULE_NAME("hwacpi") /****************************************************************************** * @@ -62,36 +59,30 @@ * the FADT. * ******************************************************************************/ - -acpi_status -acpi_hw_initialize ( - void) +acpi_status acpi_hw_initialize(void) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("hw_initialize"); + acpi_status status; + ACPI_FUNCTION_TRACE("hw_initialize"); /* We must have the ACPI tables by the time we get here */ if (!acpi_gbl_FADT) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No FADT is present\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No FADT is present\n")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + return_ACPI_STATUS(AE_NO_ACPI_TABLES); } /* Sanity check the FADT for valid values */ - status = acpi_ut_validate_fadt (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_validate_fadt(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /****************************************************************************** * * FUNCTION: acpi_hw_set_mode @@ -104,24 +95,21 @@ acpi_hw_initialize ( * ******************************************************************************/ -acpi_status -acpi_hw_set_mode ( - u32 mode) +acpi_status acpi_hw_set_mode(u32 mode) { - acpi_status status; - u32 retry; - + acpi_status status; + u32 retry; - ACPI_FUNCTION_TRACE ("hw_set_mode"); + ACPI_FUNCTION_TRACE("hw_set_mode"); /* * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, * system does not support mode transition. */ if (!acpi_gbl_FADT->smi_cmd) { - ACPI_REPORT_ERROR (("No SMI_CMD in FADT, mode transition failed.\n")); - return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + ACPI_REPORT_ERROR(("No SMI_CMD in FADT, mode transition failed.\n")); + return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); } /* @@ -132,9 +120,8 @@ acpi_hw_set_mode ( * transitions are not supported. */ if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) { - ACPI_REPORT_ERROR (( - "No ACPI mode transition supported in this system (enable/disable both zero)\n")); - return_ACPI_STATUS (AE_OK); + ACPI_REPORT_ERROR(("No ACPI mode transition supported in this system (enable/disable both zero)\n")); + return_ACPI_STATUS(AE_OK); } switch (mode) { @@ -142,9 +129,11 @@ acpi_hw_set_mode ( /* BIOS should have disabled ALL fixed and GP events */ - status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, - (u32) acpi_gbl_FADT->acpi_enable, 8); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n")); + status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd, + (u32) acpi_gbl_FADT->acpi_enable, + 8); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Attempting to enable ACPI mode\n")); break; case ACPI_SYS_MODE_LEGACY: @@ -153,20 +142,21 @@ acpi_hw_set_mode ( * BIOS should clear all fixed status bits and restore fixed event * enable bits to default */ - status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, - (u32) acpi_gbl_FADT->acpi_disable, 8); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Attempting to enable Legacy (non-ACPI) mode\n")); + status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd, + (u32) acpi_gbl_FADT->acpi_disable, + 8); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Attempting to enable Legacy (non-ACPI) mode\n")); break; default: - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not write mode change, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not write mode change, %s\n", + acpi_format_exception(status))); + return_ACPI_STATUS(status); } /* @@ -176,19 +166,19 @@ acpi_hw_set_mode ( retry = 3000; while (retry) { if (acpi_hw_get_mode() == mode) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", - mode)); - return_ACPI_STATUS (AE_OK); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Mode %X successfully enabled\n", + mode)); + return_ACPI_STATUS(AE_OK); } acpi_os_stall(1000); retry--; } - ACPI_REPORT_ERROR (("Hardware never changed modes\n")); - return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + ACPI_REPORT_ERROR(("Hardware never changed modes\n")); + return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); } - /******************************************************************************* * * FUNCTION: acpi_hw_get_mode @@ -202,34 +192,30 @@ acpi_hw_set_mode ( * ******************************************************************************/ -u32 -acpi_hw_get_mode ( - void) +u32 acpi_hw_get_mode(void) { - acpi_status status; - u32 value; - - - ACPI_FUNCTION_TRACE ("hw_get_mode"); + acpi_status status; + u32 value; + ACPI_FUNCTION_TRACE("hw_get_mode"); /* * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, * system does not support mode transition. */ if (!acpi_gbl_FADT->smi_cmd) { - return_VALUE (ACPI_SYS_MODE_ACPI); + return_VALUE(ACPI_SYS_MODE_ACPI); } - status = acpi_get_register (ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK); - if (ACPI_FAILURE (status)) { - return_VALUE (ACPI_SYS_MODE_LEGACY); + status = + acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK); + if (ACPI_FAILURE(status)) { + return_VALUE(ACPI_SYS_MODE_LEGACY); } if (value) { - return_VALUE (ACPI_SYS_MODE_ACPI); - } - else { - return_VALUE (ACPI_SYS_MODE_LEGACY); + return_VALUE(ACPI_SYS_MODE_ACPI); + } else { + return_VALUE(ACPI_SYS_MODE_LEGACY); } } diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c index 3536bbb..5c8e5df 100644 --- a/drivers/acpi/hardware/hwgpe.c +++ b/drivers/acpi/hardware/hwgpe.c @@ -46,15 +46,12 @@ #include #define _COMPONENT ACPI_HARDWARE - ACPI_MODULE_NAME ("hwgpe") +ACPI_MODULE_NAME("hwgpe") /* Local prototypes */ - static acpi_status -acpi_hw_enable_wakeup_gpe_block ( - struct acpi_gpe_xrupt_info *gpe_xrupt_info, - struct acpi_gpe_block_info *gpe_block); - +acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, + struct acpi_gpe_block_info *gpe_block); /****************************************************************************** * @@ -71,15 +68,12 @@ acpi_hw_enable_wakeup_gpe_block ( ******************************************************************************/ acpi_status -acpi_hw_write_gpe_enable_reg ( - struct acpi_gpe_event_info *gpe_event_info) +acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info *gpe_event_info) { - struct acpi_gpe_register_info *gpe_register_info; - acpi_status status; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_gpe_register_info *gpe_register_info; + acpi_status status; + ACPI_FUNCTION_ENTRY(); /* Get the info block for the entire GPE register */ @@ -90,13 +84,12 @@ acpi_hw_write_gpe_enable_reg ( /* Write the entire GPE (runtime) enable register */ - status = acpi_hw_low_level_write (8, gpe_register_info->enable_for_run, - &gpe_register_info->enable_address); + status = acpi_hw_low_level_write(8, gpe_register_info->enable_for_run, + &gpe_register_info->enable_address); return (status); } - /****************************************************************************** * * FUNCTION: acpi_hw_clear_gpe @@ -109,27 +102,23 @@ acpi_hw_write_gpe_enable_reg ( * ******************************************************************************/ -acpi_status -acpi_hw_clear_gpe ( - struct acpi_gpe_event_info *gpe_event_info) +acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info) { - acpi_status status; - - - ACPI_FUNCTION_ENTRY (); + acpi_status status; + ACPI_FUNCTION_ENTRY(); /* * Write a one to the appropriate bit in the status register to * clear this GPE. */ - status = acpi_hw_low_level_write (8, gpe_event_info->register_bit, - &gpe_event_info->register_info->status_address); + status = acpi_hw_low_level_write(8, gpe_event_info->register_bit, + &gpe_event_info->register_info-> + status_address); return (status); } - /****************************************************************************** * * FUNCTION: acpi_hw_get_gpe_status @@ -145,19 +134,16 @@ acpi_hw_clear_gpe ( #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_hw_get_gpe_status ( - struct acpi_gpe_event_info *gpe_event_info, - acpi_event_status *event_status) +acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info, + acpi_event_status * event_status) { - u32 in_byte; - u8 register_bit; - struct acpi_gpe_register_info *gpe_register_info; - acpi_status status; - acpi_event_status local_event_status = 0; - - - ACPI_FUNCTION_ENTRY (); + u32 in_byte; + u8 register_bit; + struct acpi_gpe_register_info *gpe_register_info; + acpi_status status; + acpi_event_status local_event_status = 0; + ACPI_FUNCTION_ENTRY(); if (!event_status) { return (AE_BAD_PARAMETER); @@ -185,8 +171,10 @@ acpi_hw_get_gpe_status ( /* GPE currently active (status bit == 1)? */ - status = acpi_hw_low_level_read (8, &in_byte, &gpe_register_info->status_address); - if (ACPI_FAILURE (status)) { + status = + acpi_hw_low_level_read(8, &in_byte, + &gpe_register_info->status_address); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } @@ -198,12 +186,10 @@ acpi_hw_get_gpe_status ( (*event_status) = local_event_status; - -unlock_and_exit: + unlock_and_exit: return (status); } -#endif /* ACPI_FUTURE_USAGE */ - +#endif /* ACPI_FUTURE_USAGE */ /****************************************************************************** * @@ -219,22 +205,21 @@ unlock_and_exit: ******************************************************************************/ acpi_status -acpi_hw_disable_gpe_block ( - struct acpi_gpe_xrupt_info *gpe_xrupt_info, - struct acpi_gpe_block_info *gpe_block) +acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info, + struct acpi_gpe_block_info * gpe_block) { - u32 i; - acpi_status status; - + u32 i; + acpi_status status; /* Examine each GPE Register within the block */ for (i = 0; i < gpe_block->register_count; i++) { /* Disable all GPEs in this register */ - status = acpi_hw_low_level_write (8, 0x00, - &gpe_block->register_info[i].enable_address); - if (ACPI_FAILURE (status)) { + status = acpi_hw_low_level_write(8, 0x00, + &gpe_block->register_info[i]. + enable_address); + if (ACPI_FAILURE(status)) { return (status); } } @@ -242,7 +227,6 @@ acpi_hw_disable_gpe_block ( return (AE_OK); } - /****************************************************************************** * * FUNCTION: acpi_hw_clear_gpe_block @@ -257,22 +241,21 @@ acpi_hw_disable_gpe_block ( ******************************************************************************/ acpi_status -acpi_hw_clear_gpe_block ( - struct acpi_gpe_xrupt_info *gpe_xrupt_info, - struct acpi_gpe_block_info *gpe_block) +acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info, + struct acpi_gpe_block_info * gpe_block) { - u32 i; - acpi_status status; - + u32 i; + acpi_status status; /* Examine each GPE Register within the block */ for (i = 0; i < gpe_block->register_count; i++) { /* Clear status on all GPEs in this register */ - status = acpi_hw_low_level_write (8, 0xFF, - &gpe_block->register_info[i].status_address); - if (ACPI_FAILURE (status)) { + status = acpi_hw_low_level_write(8, 0xFF, + &gpe_block->register_info[i]. + status_address); + if (ACPI_FAILURE(status)) { return (status); } } @@ -280,7 +263,6 @@ acpi_hw_clear_gpe_block ( return (AE_OK); } - /****************************************************************************** * * FUNCTION: acpi_hw_enable_runtime_gpe_block @@ -296,13 +278,11 @@ acpi_hw_clear_gpe_block ( ******************************************************************************/ acpi_status -acpi_hw_enable_runtime_gpe_block ( - struct acpi_gpe_xrupt_info *gpe_xrupt_info, - struct acpi_gpe_block_info *gpe_block) +acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info, + struct acpi_gpe_block_info * gpe_block) { - u32 i; - acpi_status status; - + u32 i; + acpi_status status; /* NOTE: assumes that all GPEs are currently disabled */ @@ -315,9 +295,13 @@ acpi_hw_enable_runtime_gpe_block ( /* Enable all "runtime" GPEs in this register */ - status = acpi_hw_low_level_write (8, gpe_block->register_info[i].enable_for_run, - &gpe_block->register_info[i].enable_address); - if (ACPI_FAILURE (status)) { + status = + acpi_hw_low_level_write(8, + gpe_block->register_info[i]. + enable_for_run, + &gpe_block->register_info[i]. + enable_address); + if (ACPI_FAILURE(status)) { return (status); } } @@ -325,7 +309,6 @@ acpi_hw_enable_runtime_gpe_block ( return (AE_OK); } - /****************************************************************************** * * FUNCTION: acpi_hw_enable_wakeup_gpe_block @@ -341,13 +324,11 @@ acpi_hw_enable_runtime_gpe_block ( ******************************************************************************/ static acpi_status -acpi_hw_enable_wakeup_gpe_block ( - struct acpi_gpe_xrupt_info *gpe_xrupt_info, - struct acpi_gpe_block_info *gpe_block) +acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, + struct acpi_gpe_block_info *gpe_block) { - u32 i; - acpi_status status; - + u32 i; + acpi_status status; /* Examine each GPE Register within the block */ @@ -358,10 +339,12 @@ acpi_hw_enable_wakeup_gpe_block ( /* Enable all "wake" GPEs in this register */ - status = acpi_hw_low_level_write (8, - gpe_block->register_info[i].enable_for_wake, - &gpe_block->register_info[i].enable_address); - if (ACPI_FAILURE (status)) { + status = acpi_hw_low_level_write(8, + gpe_block->register_info[i]. + enable_for_wake, + &gpe_block->register_info[i]. + enable_address); + if (ACPI_FAILURE(status)) { return (status); } } @@ -369,7 +352,6 @@ acpi_hw_enable_wakeup_gpe_block ( return (AE_OK); } - /****************************************************************************** * * FUNCTION: acpi_hw_disable_all_gpes @@ -382,22 +364,17 @@ acpi_hw_enable_wakeup_gpe_block ( * ******************************************************************************/ -acpi_status -acpi_hw_disable_all_gpes ( - void) +acpi_status acpi_hw_disable_all_gpes(void) { - acpi_status status; - + acpi_status status; - ACPI_FUNCTION_TRACE ("hw_disable_all_gpes"); + ACPI_FUNCTION_TRACE("hw_disable_all_gpes"); - - status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block); - status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block); - return_ACPI_STATUS (status); + status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block); + status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block); + return_ACPI_STATUS(status); } - /****************************************************************************** * * FUNCTION: acpi_hw_enable_all_runtime_gpes @@ -410,21 +387,16 @@ acpi_hw_disable_all_gpes ( * ******************************************************************************/ -acpi_status -acpi_hw_enable_all_runtime_gpes ( - void) +acpi_status acpi_hw_enable_all_runtime_gpes(void) { - acpi_status status; - + acpi_status status; - ACPI_FUNCTION_TRACE ("hw_enable_all_runtime_gpes"); + ACPI_FUNCTION_TRACE("hw_enable_all_runtime_gpes"); - - status = acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block); - return_ACPI_STATUS (status); + status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block); + return_ACPI_STATUS(status); } - /****************************************************************************** * * FUNCTION: acpi_hw_enable_all_wakeup_gpes @@ -437,17 +409,12 @@ acpi_hw_enable_all_runtime_gpes ( * ******************************************************************************/ -acpi_status -acpi_hw_enable_all_wakeup_gpes ( - void) +acpi_status acpi_hw_enable_all_wakeup_gpes(void) { - acpi_status status; - + acpi_status status; - ACPI_FUNCTION_TRACE ("hw_enable_all_wakeup_gpes"); + ACPI_FUNCTION_TRACE("hw_enable_all_wakeup_gpes"); - - status = acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block); - return_ACPI_STATUS (status); + status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block); + return_ACPI_STATUS(status); } - diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c index 04a0585..536a7ae 100644 --- a/drivers/acpi/hardware/hwregs.c +++ b/drivers/acpi/hardware/hwregs.c @@ -50,8 +50,7 @@ #include #define _COMPONENT ACPI_HARDWARE - ACPI_MODULE_NAME ("hwregs") - +ACPI_MODULE_NAME("hwregs") /******************************************************************************* * @@ -65,57 +64,52 @@ * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED * ******************************************************************************/ - -acpi_status -acpi_hw_clear_acpi_status ( - u32 flags) +acpi_status acpi_hw_clear_acpi_status(u32 flags) { - acpi_status status; - + acpi_status status; - ACPI_FUNCTION_TRACE ("hw_clear_acpi_status"); + ACPI_FUNCTION_TRACE("hw_clear_acpi_status"); - - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n", - ACPI_BITMASK_ALL_FIXED_STATUS, - (u16) acpi_gbl_FADT->xpm1a_evt_blk.address)); + ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n", + ACPI_BITMASK_ALL_FIXED_STATUS, + (u16) acpi_gbl_FADT->xpm1a_evt_blk.address)); if (flags & ACPI_MTX_LOCK) { - status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } - status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_STATUS, - ACPI_BITMASK_ALL_FIXED_STATUS); - if (ACPI_FAILURE (status)) { + status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_STATUS, + ACPI_BITMASK_ALL_FIXED_STATUS); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* Clear the fixed events */ if (acpi_gbl_FADT->xpm1b_evt_blk.address) { - status = acpi_hw_low_level_write (16, ACPI_BITMASK_ALL_FIXED_STATUS, - &acpi_gbl_FADT->xpm1b_evt_blk); - if (ACPI_FAILURE (status)) { + status = + acpi_hw_low_level_write(16, ACPI_BITMASK_ALL_FIXED_STATUS, + &acpi_gbl_FADT->xpm1b_evt_blk); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } } /* Clear the GPE Bits in all GPE registers in all GPE blocks */ - status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block); + status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block); -unlock_and_exit: + unlock_and_exit: if (flags & ACPI_MTX_LOCK) { - (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); + (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_get_sleep_type_data @@ -132,53 +126,48 @@ unlock_and_exit: ******************************************************************************/ acpi_status -acpi_get_sleep_type_data ( - u8 sleep_state, - u8 *sleep_type_a, - u8 *sleep_type_b) +acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b) { - acpi_status status = AE_OK; - struct acpi_parameter_info info; - char *sleep_state_name; - - - ACPI_FUNCTION_TRACE ("acpi_get_sleep_type_data"); + acpi_status status = AE_OK; + struct acpi_parameter_info info; + char *sleep_state_name; + ACPI_FUNCTION_TRACE("acpi_get_sleep_type_data"); /* Validate parameters */ - if ((sleep_state > ACPI_S_STATES_MAX) || - !sleep_type_a || !sleep_type_b) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if ((sleep_state > ACPI_S_STATES_MAX) || !sleep_type_a || !sleep_type_b) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Evaluate the namespace object containing the values for this state */ info.parameters = NULL; info.return_object = NULL; - sleep_state_name = (char *) acpi_gbl_sleep_state_names[sleep_state]; + sleep_state_name = (char *)acpi_gbl_sleep_state_names[sleep_state]; - status = acpi_ns_evaluate_by_name (sleep_state_name, &info); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "%s while evaluating sleep_state [%s]\n", - acpi_format_exception (status), sleep_state_name)); + status = acpi_ns_evaluate_by_name(sleep_state_name, &info); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "%s while evaluating sleep_state [%s]\n", + acpi_format_exception(status), + sleep_state_name)); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Must have a return object */ if (!info.return_object) { - ACPI_REPORT_ERROR (("No Sleep State object returned from [%s]\n", - sleep_state_name)); + ACPI_REPORT_ERROR(("No Sleep State object returned from [%s]\n", + sleep_state_name)); status = AE_NOT_EXIST; } /* It must be of type Package */ - else if (ACPI_GET_OBJECT_TYPE (info.return_object) != ACPI_TYPE_PACKAGE) { - ACPI_REPORT_ERROR (("Sleep State return object is not a Package\n")); + else if (ACPI_GET_OBJECT_TYPE(info.return_object) != ACPI_TYPE_PACKAGE) { + ACPI_REPORT_ERROR(("Sleep State return object is not a Package\n")); status = AE_AML_OPERAND_TYPE; } @@ -190,45 +179,41 @@ acpi_get_sleep_type_data ( * one per sleep type (A/B). */ else if (info.return_object->package.count < 2) { - ACPI_REPORT_ERROR (( - "Sleep State return package does not have at least two elements\n")); + ACPI_REPORT_ERROR(("Sleep State return package does not have at least two elements\n")); status = AE_AML_NO_OPERAND; } /* The first two elements must both be of type Integer */ - else if ((ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[0]) - != ACPI_TYPE_INTEGER) || - (ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[1]) - != ACPI_TYPE_INTEGER)) { - ACPI_REPORT_ERROR (( - "Sleep State return package elements are not both Integers (%s, %s)\n", - acpi_ut_get_object_type_name (info.return_object->package.elements[0]), - acpi_ut_get_object_type_name (info.return_object->package.elements[1]))); + else if ((ACPI_GET_OBJECT_TYPE(info.return_object->package.elements[0]) + != ACPI_TYPE_INTEGER) || + (ACPI_GET_OBJECT_TYPE(info.return_object->package.elements[1]) + != ACPI_TYPE_INTEGER)) { + ACPI_REPORT_ERROR(("Sleep State return package elements are not both Integers (%s, %s)\n", acpi_ut_get_object_type_name(info.return_object->package.elements[0]), acpi_ut_get_object_type_name(info.return_object->package.elements[1]))); status = AE_AML_OPERAND_TYPE; - } - else { + } else { /* Valid _Sx_ package size, type, and value */ *sleep_type_a = (u8) - (info.return_object->package.elements[0])->integer.value; + (info.return_object->package.elements[0])->integer.value; *sleep_type_b = (u8) - (info.return_object->package.elements[1])->integer.value; + (info.return_object->package.elements[1])->integer.value; } - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n", - acpi_format_exception (status), - sleep_state_name, info.return_object, - acpi_ut_get_object_type_name (info.return_object))); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n", + acpi_format_exception(status), + sleep_state_name, info.return_object, + acpi_ut_get_object_type_name(info. + return_object))); } - acpi_ut_remove_reference (info.return_object); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(info.return_object); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_sleep_type_data); +EXPORT_SYMBOL(acpi_get_sleep_type_data); /******************************************************************************* * @@ -242,22 +227,20 @@ EXPORT_SYMBOL(acpi_get_sleep_type_data); * ******************************************************************************/ -struct acpi_bit_register_info * -acpi_hw_get_bit_register_info ( - u32 register_id) +struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) { - ACPI_FUNCTION_NAME ("hw_get_bit_register_info"); - + ACPI_FUNCTION_NAME("hw_get_bit_register_info"); if (register_id > ACPI_BITREG_MAX) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid bit_register ID: %X\n", register_id)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid bit_register ID: %X\n", + register_id)); return (NULL); } return (&acpi_gbl_bit_register_info[register_id]); } - /******************************************************************************* * * FUNCTION: acpi_get_register @@ -273,59 +256,56 @@ acpi_hw_get_bit_register_info ( * ******************************************************************************/ -acpi_status -acpi_get_register ( - u32 register_id, - u32 *return_value, - u32 flags) +acpi_status acpi_get_register(u32 register_id, u32 * return_value, u32 flags) { - u32 register_value = 0; - struct acpi_bit_register_info *bit_reg_info; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_get_register"); + u32 register_value = 0; + struct acpi_bit_register_info *bit_reg_info; + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_get_register"); /* Get the info structure corresponding to the requested ACPI Register */ - bit_reg_info = acpi_hw_get_bit_register_info (register_id); + bit_reg_info = acpi_hw_get_bit_register_info(register_id); if (!bit_reg_info) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } if (flags & ACPI_MTX_LOCK) { - status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Read from the register */ - status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, - bit_reg_info->parent_register, ®ister_value); + status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, + bit_reg_info->parent_register, + ®ister_value); if (flags & ACPI_MTX_LOCK) { - (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); + (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE); } - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { /* Normalize the value that was read */ - register_value = ((register_value & bit_reg_info->access_bit_mask) - >> bit_reg_info->bit_position); + register_value = + ((register_value & bit_reg_info->access_bit_mask) + >> bit_reg_info->bit_position); *return_value = register_value; - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read value %8.8X register %X\n", - register_value, bit_reg_info->parent_register)); + ACPI_DEBUG_PRINT((ACPI_DB_IO, "Read value %8.8X register %X\n", + register_value, + bit_reg_info->parent_register)); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_register); +EXPORT_SYMBOL(acpi_get_register); /******************************************************************************* * @@ -342,40 +322,36 @@ EXPORT_SYMBOL(acpi_get_register); * ******************************************************************************/ -acpi_status -acpi_set_register ( - u32 register_id, - u32 value, - u32 flags) +acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags) { - u32 register_value = 0; - struct acpi_bit_register_info *bit_reg_info; - acpi_status status; - - - ACPI_FUNCTION_TRACE_U32 ("acpi_set_register", register_id); + u32 register_value = 0; + struct acpi_bit_register_info *bit_reg_info; + acpi_status status; + ACPI_FUNCTION_TRACE_U32("acpi_set_register", register_id); /* Get the info structure corresponding to the requested ACPI Register */ - bit_reg_info = acpi_hw_get_bit_register_info (register_id); + bit_reg_info = acpi_hw_get_bit_register_info(register_id); if (!bit_reg_info) { - ACPI_REPORT_ERROR (("Bad ACPI HW register_id: %X\n", register_id)); - return_ACPI_STATUS (AE_BAD_PARAMETER); + ACPI_REPORT_ERROR(("Bad ACPI HW register_id: %X\n", + register_id)); + return_ACPI_STATUS(AE_BAD_PARAMETER); } if (flags & ACPI_MTX_LOCK) { - status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Always do a register read first so we can insert the new bits */ - status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, - bit_reg_info->parent_register, ®ister_value); - if (ACPI_FAILURE (status)) { + status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, + bit_reg_info->parent_register, + ®ister_value); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } @@ -395,26 +371,30 @@ acpi_set_register ( * information is the single bit we're interested in, all others should * be written as 0 so they will be left unchanged. */ - value = ACPI_REGISTER_PREPARE_BITS (value, - bit_reg_info->bit_position, bit_reg_info->access_bit_mask); + value = ACPI_REGISTER_PREPARE_BITS(value, + bit_reg_info->bit_position, + bit_reg_info-> + access_bit_mask); if (value) { - status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_STATUS, (u16) value); + status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_STATUS, + (u16) value); register_value = 0; } break; - case ACPI_REGISTER_PM1_ENABLE: - ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, - bit_reg_info->access_bit_mask, value); + ACPI_REGISTER_INSERT_VALUE(register_value, + bit_reg_info->bit_position, + bit_reg_info->access_bit_mask, + value); - status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_ENABLE, (u16) register_value); + status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_ENABLE, + (u16) register_value); break; - case ACPI_REGISTER_PM1_CONTROL: /* @@ -422,65 +402,73 @@ acpi_set_register ( * Note that at this level, the fact that there are actually TWO * registers (A and B - and B may not exist) is abstracted. */ - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM1 control: Read %X\n", register_value)); + ACPI_DEBUG_PRINT((ACPI_DB_IO, "PM1 control: Read %X\n", + register_value)); - ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, - bit_reg_info->access_bit_mask, value); + ACPI_REGISTER_INSERT_VALUE(register_value, + bit_reg_info->bit_position, + bit_reg_info->access_bit_mask, + value); - status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_CONTROL, (u16) register_value); + status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_CONTROL, + (u16) register_value); break; - case ACPI_REGISTER_PM2_CONTROL: - status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM2_CONTROL, ®ister_value); - if (ACPI_FAILURE (status)) { + status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM2_CONTROL, + ®ister_value); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n", - register_value, - ACPI_FORMAT_UINT64 ( - acpi_gbl_FADT->xpm2_cnt_blk.address))); - - ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, - bit_reg_info->access_bit_mask, value); - - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n", - register_value, - ACPI_FORMAT_UINT64 ( - acpi_gbl_FADT->xpm2_cnt_blk.address))); - - status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM2_CONTROL, (u8) (register_value)); + ACPI_DEBUG_PRINT((ACPI_DB_IO, + "PM2 control: Read %X from %8.8X%8.8X\n", + register_value, + ACPI_FORMAT_UINT64(acpi_gbl_FADT-> + xpm2_cnt_blk.address))); + + ACPI_REGISTER_INSERT_VALUE(register_value, + bit_reg_info->bit_position, + bit_reg_info->access_bit_mask, + value); + + ACPI_DEBUG_PRINT((ACPI_DB_IO, + "About to write %4.4X to %8.8X%8.8X\n", + register_value, + ACPI_FORMAT_UINT64(acpi_gbl_FADT-> + xpm2_cnt_blk.address))); + + status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM2_CONTROL, + (u8) (register_value)); break; - default: break; } - -unlock_and_exit: + unlock_and_exit: if (flags & ACPI_MTX_LOCK) { - (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); + (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE); } /* Normalize the value that was read */ - ACPI_DEBUG_EXEC (register_value = - ((register_value & bit_reg_info->access_bit_mask) >> - bit_reg_info->bit_position)); + ACPI_DEBUG_EXEC(register_value = + ((register_value & bit_reg_info->access_bit_mask) >> + bit_reg_info->bit_position)); - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n", - value, register_value, bit_reg_info->parent_register)); - return_ACPI_STATUS (status); + ACPI_DEBUG_PRINT((ACPI_DB_IO, + "Set bits: %8.8X actual %8.8X register %X\n", value, + register_value, bit_reg_info->parent_register)); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_set_register); +EXPORT_SYMBOL(acpi_set_register); /****************************************************************************** * @@ -498,103 +486,107 @@ EXPORT_SYMBOL(acpi_set_register); ******************************************************************************/ acpi_status -acpi_hw_register_read ( - u8 use_lock, - u32 register_id, - u32 *return_value) +acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) { - u32 value1 = 0; - u32 value2 = 0; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("hw_register_read"); + u32 value1 = 0; + u32 value2 = 0; + acpi_status status; + ACPI_FUNCTION_TRACE("hw_register_read"); if (ACPI_MTX_LOCK == use_lock) { - status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } switch (register_id) { - case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ + case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ - status = acpi_hw_low_level_read (16, &value1, &acpi_gbl_FADT->xpm1a_evt_blk); - if (ACPI_FAILURE (status)) { + status = + acpi_hw_low_level_read(16, &value1, + &acpi_gbl_FADT->xpm1a_evt_blk); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* PM1B is optional */ - status = acpi_hw_low_level_read (16, &value2, &acpi_gbl_FADT->xpm1b_evt_blk); + status = + acpi_hw_low_level_read(16, &value2, + &acpi_gbl_FADT->xpm1b_evt_blk); value1 |= value2; break; + case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ - case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ - - status = acpi_hw_low_level_read (16, &value1, &acpi_gbl_xpm1a_enable); - if (ACPI_FAILURE (status)) { + status = + acpi_hw_low_level_read(16, &value1, &acpi_gbl_xpm1a_enable); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* PM1B is optional */ - status = acpi_hw_low_level_read (16, &value2, &acpi_gbl_xpm1b_enable); + status = + acpi_hw_low_level_read(16, &value2, &acpi_gbl_xpm1b_enable); value1 |= value2; break; + case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ - case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ - - status = acpi_hw_low_level_read (16, &value1, &acpi_gbl_FADT->xpm1a_cnt_blk); - if (ACPI_FAILURE (status)) { + status = + acpi_hw_low_level_read(16, &value1, + &acpi_gbl_FADT->xpm1a_cnt_blk); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } - status = acpi_hw_low_level_read (16, &value2, &acpi_gbl_FADT->xpm1b_cnt_blk); + status = + acpi_hw_low_level_read(16, &value2, + &acpi_gbl_FADT->xpm1b_cnt_blk); value1 |= value2; break; + case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ - case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ - - status = acpi_hw_low_level_read (8, &value1, &acpi_gbl_FADT->xpm2_cnt_blk); + status = + acpi_hw_low_level_read(8, &value1, + &acpi_gbl_FADT->xpm2_cnt_blk); break; + case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ - case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ - - status = acpi_hw_low_level_read (32, &value1, &acpi_gbl_FADT->xpm_tmr_blk); + status = + acpi_hw_low_level_read(32, &value1, + &acpi_gbl_FADT->xpm_tmr_blk); break; - case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ + case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ - status = acpi_os_read_port (acpi_gbl_FADT->smi_cmd, &value1, 8); + status = acpi_os_read_port(acpi_gbl_FADT->smi_cmd, &value1, 8); break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", - register_id)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown Register ID: %X\n", + register_id)); status = AE_BAD_PARAMETER; break; } -unlock_and_exit: + unlock_and_exit: if (ACPI_MTX_LOCK == use_lock) { - (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); + (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE); } - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { *return_value = value1; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /****************************************************************************** * * FUNCTION: acpi_hw_register_write @@ -610,109 +602,112 @@ unlock_and_exit: * ******************************************************************************/ -acpi_status -acpi_hw_register_write ( - u8 use_lock, - u32 register_id, - u32 value) +acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("hw_register_write"); + acpi_status status; + ACPI_FUNCTION_TRACE("hw_register_write"); if (ACPI_MTX_LOCK == use_lock) { - status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } switch (register_id) { - case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ + case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ - status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1a_evt_blk); - if (ACPI_FAILURE (status)) { + status = + acpi_hw_low_level_write(16, value, + &acpi_gbl_FADT->xpm1a_evt_blk); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* PM1B is optional */ - status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1b_evt_blk); + status = + acpi_hw_low_level_write(16, value, + &acpi_gbl_FADT->xpm1b_evt_blk); break; + case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ - case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access*/ - - status = acpi_hw_low_level_write (16, value, &acpi_gbl_xpm1a_enable); - if (ACPI_FAILURE (status)) { + status = + acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1a_enable); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* PM1B is optional */ - status = acpi_hw_low_level_write (16, value, &acpi_gbl_xpm1b_enable); + status = + acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1b_enable); break; + case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ - case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ - - status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1a_cnt_blk); - if (ACPI_FAILURE (status)) { + status = + acpi_hw_low_level_write(16, value, + &acpi_gbl_FADT->xpm1a_cnt_blk); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } - status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1b_cnt_blk); + status = + acpi_hw_low_level_write(16, value, + &acpi_gbl_FADT->xpm1b_cnt_blk); break; + case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ - case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ - - status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1a_cnt_blk); + status = + acpi_hw_low_level_write(16, value, + &acpi_gbl_FADT->xpm1a_cnt_blk); break; + case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ - case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ - - status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1b_cnt_blk); + status = + acpi_hw_low_level_write(16, value, + &acpi_gbl_FADT->xpm1b_cnt_blk); break; + case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ - case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ - - status = acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->xpm2_cnt_blk); + status = + acpi_hw_low_level_write(8, value, + &acpi_gbl_FADT->xpm2_cnt_blk); break; + case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ - case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ - - status = acpi_hw_low_level_write (32, value, &acpi_gbl_FADT->xpm_tmr_blk); + status = + acpi_hw_low_level_write(32, value, + &acpi_gbl_FADT->xpm_tmr_blk); break; - - case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ + case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ /* SMI_CMD is currently always in IO space */ - status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, value, 8); + status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd, value, 8); break; - default: status = AE_BAD_PARAMETER; break; } -unlock_and_exit: + unlock_and_exit: if (ACPI_MTX_LOCK == use_lock) { - (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); + (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /****************************************************************************** * * FUNCTION: acpi_hw_low_level_read @@ -728,17 +723,12 @@ unlock_and_exit: ******************************************************************************/ acpi_status -acpi_hw_low_level_read ( - u32 width, - u32 *value, - struct acpi_generic_address *reg) +acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg) { - u64 address; - acpi_status status; - - - ACPI_FUNCTION_NAME ("hw_low_level_read"); + u64 address; + acpi_status status; + ACPI_FUNCTION_NAME("hw_low_level_read"); /* * Must have a valid pointer to a GAS structure, and @@ -751,7 +741,7 @@ acpi_hw_low_level_read ( /* Get a local copy of the address. Handles possible alignment issues */ - ACPI_MOVE_64_TO_64 (&address, ®->address); + ACPI_MOVE_64_TO_64(&address, ®->address); if (!address) { return (AE_OK); } @@ -764,35 +754,32 @@ acpi_hw_low_level_read ( switch (reg->address_space_id) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: - status = acpi_os_read_memory ( - (acpi_physical_address) address, - value, width); + status = acpi_os_read_memory((acpi_physical_address) address, + value, width); break; - case ACPI_ADR_SPACE_SYSTEM_IO: - status = acpi_os_read_port ((acpi_io_address) address, - value, width); + status = acpi_os_read_port((acpi_io_address) address, + value, width); break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unsupported address space: %X\n", reg->address_space_id)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unsupported address space: %X\n", + reg->address_space_id)); return (AE_BAD_PARAMETER); } - ACPI_DEBUG_PRINT ((ACPI_DB_IO, - "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", - *value, width, - ACPI_FORMAT_UINT64 (address), - acpi_ut_get_region_name (reg->address_space_id))); + ACPI_DEBUG_PRINT((ACPI_DB_IO, + "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", + *value, width, + ACPI_FORMAT_UINT64(address), + acpi_ut_get_region_name(reg->address_space_id))); return (status); } - /****************************************************************************** * * FUNCTION: acpi_hw_low_level_write @@ -808,17 +795,12 @@ acpi_hw_low_level_read ( ******************************************************************************/ acpi_status -acpi_hw_low_level_write ( - u32 width, - u32 value, - struct acpi_generic_address *reg) +acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg) { - u64 address; - acpi_status status; - - - ACPI_FUNCTION_NAME ("hw_low_level_write"); + u64 address; + acpi_status status; + ACPI_FUNCTION_NAME("hw_low_level_write"); /* * Must have a valid pointer to a GAS structure, and @@ -831,7 +813,7 @@ acpi_hw_low_level_write ( /* Get a local copy of the address. Handles possible alignment issues */ - ACPI_MOVE_64_TO_64 (&address, ®->address); + ACPI_MOVE_64_TO_64(&address, ®->address); if (!address) { return (AE_OK); } @@ -843,30 +825,28 @@ acpi_hw_low_level_write ( switch (reg->address_space_id) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: - status = acpi_os_write_memory ( - (acpi_physical_address) address, - value, width); + status = acpi_os_write_memory((acpi_physical_address) address, + value, width); break; - case ACPI_ADR_SPACE_SYSTEM_IO: - status = acpi_os_write_port ((acpi_io_address) address, - value, width); + status = acpi_os_write_port((acpi_io_address) address, + value, width); break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unsupported address space: %X\n", reg->address_space_id)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unsupported address space: %X\n", + reg->address_space_id)); return (AE_BAD_PARAMETER); } - ACPI_DEBUG_PRINT ((ACPI_DB_IO, - "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", - value, width, - ACPI_FORMAT_UINT64 (address), - acpi_ut_get_region_name (reg->address_space_id))); + ACPI_DEBUG_PRINT((ACPI_DB_IO, + "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", + value, width, + ACPI_FORMAT_UINT64(address), + acpi_ut_get_region_name(reg->address_space_id))); return (status); } diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c index cedee0c..3451906 100644 --- a/drivers/acpi/hardware/hwsleep.c +++ b/drivers/acpi/hardware/hwsleep.c @@ -46,8 +46,7 @@ #include #define _COMPONENT ACPI_HARDWARE - ACPI_MODULE_NAME ("hwsleep") - +ACPI_MODULE_NAME("hwsleep") /******************************************************************************* * @@ -61,30 +60,25 @@ * DESCRIPTION: Access function for the firmware_waking_vector field in FACS * ******************************************************************************/ - acpi_status -acpi_set_firmware_waking_vector ( - acpi_physical_address physical_address) +acpi_set_firmware_waking_vector(acpi_physical_address physical_address) { - ACPI_FUNCTION_TRACE ("acpi_set_firmware_waking_vector"); - + ACPI_FUNCTION_TRACE("acpi_set_firmware_waking_vector"); /* Set the vector */ if (acpi_gbl_common_fACS.vector_width == 32) { - *(ACPI_CAST_PTR (u32, acpi_gbl_common_fACS.firmware_waking_vector)) - = (u32) physical_address; - } - else { - *acpi_gbl_common_fACS.firmware_waking_vector - = physical_address; + *(ACPI_CAST_PTR + (u32, acpi_gbl_common_fACS.firmware_waking_vector)) + = (u32) physical_address; + } else { + *acpi_gbl_common_fACS.firmware_waking_vector = physical_address; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_get_firmware_waking_vector @@ -101,33 +95,31 @@ acpi_set_firmware_waking_vector ( #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_get_firmware_waking_vector ( - acpi_physical_address *physical_address) +acpi_get_firmware_waking_vector(acpi_physical_address * physical_address) { - ACPI_FUNCTION_TRACE ("acpi_get_firmware_waking_vector"); - + ACPI_FUNCTION_TRACE("acpi_get_firmware_waking_vector"); if (!physical_address) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Get the vector */ if (acpi_gbl_common_fACS.vector_width == 32) { *physical_address = (acpi_physical_address) - *(ACPI_CAST_PTR (u32, acpi_gbl_common_fACS.firmware_waking_vector)); - } - else { + * + (ACPI_CAST_PTR + (u32, acpi_gbl_common_fACS.firmware_waking_vector)); + } else { *physical_address = - *acpi_gbl_common_fACS.firmware_waking_vector; + *acpi_gbl_common_fACS.firmware_waking_vector; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } #endif - /******************************************************************************* * * FUNCTION: acpi_enter_sleep_state_prep @@ -143,25 +135,22 @@ acpi_get_firmware_waking_vector ( * ******************************************************************************/ -acpi_status -acpi_enter_sleep_state_prep ( - u8 sleep_state) +acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) { - acpi_status status; - struct acpi_object_list arg_list; - union acpi_object arg; - - - ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state_prep"); + acpi_status status; + struct acpi_object_list arg_list; + union acpi_object arg; + ACPI_FUNCTION_TRACE("acpi_enter_sleep_state_prep"); /* * _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */ - status = acpi_get_sleep_type_data (sleep_state, - &acpi_gbl_sleep_type_a, &acpi_gbl_sleep_type_b); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_get_sleep_type_data(sleep_state, + &acpi_gbl_sleep_type_a, + &acpi_gbl_sleep_type_b); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Setup parameter object */ @@ -174,14 +163,14 @@ acpi_enter_sleep_state_prep ( /* Run the _PTS and _GTS methods */ - status = acpi_evaluate_object (NULL, METHOD_NAME__PTS, &arg_list, NULL); - if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { - return_ACPI_STATUS (status); + status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, &arg_list, NULL); + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { + return_ACPI_STATUS(status); } - status = acpi_evaluate_object (NULL, METHOD_NAME__GTS, &arg_list, NULL); - if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { - return_ACPI_STATUS (status); + status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL); + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { + return_ACPI_STATUS(status); } /* Setup the argument to _SST */ @@ -202,22 +191,21 @@ acpi_enter_sleep_state_prep ( break; default: - arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */ + arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */ break; } /* Set the system indicators to show the desired sleep state. */ - status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); - if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _SST failed, %s\n", - acpi_format_exception (status))); + status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { + ACPI_REPORT_ERROR(("Method _SST failed, %s\n", + acpi_format_exception(status))); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_enter_sleep_state @@ -231,80 +219,82 @@ acpi_enter_sleep_state_prep ( * ******************************************************************************/ -acpi_status asmlinkage -acpi_enter_sleep_state ( - u8 sleep_state) +acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) { - u32 PM1Acontrol; - u32 PM1Bcontrol; - struct acpi_bit_register_info *sleep_type_reg_info; - struct acpi_bit_register_info *sleep_enable_reg_info; - u32 in_value; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state"); + u32 PM1Acontrol; + u32 PM1Bcontrol; + struct acpi_bit_register_info *sleep_type_reg_info; + struct acpi_bit_register_info *sleep_enable_reg_info; + u32 in_value; + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_enter_sleep_state"); if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) || - (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { - ACPI_REPORT_ERROR (("Sleep values out of range: A=%X B=%X\n", - acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b)); - return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { + ACPI_REPORT_ERROR(("Sleep values out of range: A=%X B=%X\n", + acpi_gbl_sleep_type_a, + acpi_gbl_sleep_type_b)); + return_ACPI_STATUS(AE_AML_OPERAND_VALUE); } - sleep_type_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_TYPE_A); - sleep_enable_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_ENABLE); + sleep_type_reg_info = + acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A); + sleep_enable_reg_info = + acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE); /* Clear wake status */ - status = acpi_set_register (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Clear all fixed and general purpose status bits */ - status = acpi_hw_clear_acpi_status (ACPI_MTX_DO_NOT_LOCK); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_clear_acpi_status(ACPI_MTX_DO_NOT_LOCK); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ - status = acpi_hw_disable_all_gpes (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_disable_all_gpes(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } acpi_gbl_system_awake_and_running = FALSE; - status = acpi_hw_enable_all_wakeup_gpes (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_enable_all_wakeup_gpes(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Get current value of PM1A control */ - status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "Entering sleep state [S%d]\n", sleep_state)); + ACPI_DEBUG_PRINT((ACPI_DB_INIT, + "Entering sleep state [S%d]\n", sleep_state)); /* Clear SLP_EN and SLP_TYP fields */ PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | - sleep_enable_reg_info->access_bit_mask); + sleep_enable_reg_info->access_bit_mask); PM1Bcontrol = PM1Acontrol; /* Insert SLP_TYP bits */ - PM1Acontrol |= (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); - PM1Bcontrol |= (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); + PM1Acontrol |= + (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); + PM1Bcontrol |= + (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); /* * We split the writes of SLP_TYP and SLP_EN to workaround @@ -313,16 +303,18 @@ acpi_enter_sleep_state ( /* Write #1: fill in SLP_TYP data */ - status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1A_CONTROL, + PM1Acontrol); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1B_CONTROL, + PM1Bcontrol); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Insert SLP_ENABLE bit */ @@ -332,18 +324,20 @@ acpi_enter_sleep_state ( /* Write #2: SLP_TYP + SLP_EN */ - ACPI_FLUSH_CPU_CACHE (); + ACPI_FLUSH_CPU_CACHE(); - status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1A_CONTROL, + PM1Acontrol); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1B_CONTROL, + PM1Bcontrol); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } if (sleep_state > ACPI_STATE_S3) { @@ -358,33 +352,34 @@ acpi_enter_sleep_state ( * still read the right value. Ideally, this block would go * away entirely. */ - acpi_os_stall (10000000); - - status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_CONTROL, - sleep_enable_reg_info->access_bit_mask); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + acpi_os_stall(10000000); + + status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_CONTROL, + sleep_enable_reg_info-> + access_bit_mask); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Wait until we enter sleep state */ do { - status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, - ACPI_MTX_DO_NOT_LOCK); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value, + ACPI_MTX_DO_NOT_LOCK); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Spin until we wake */ } while (!in_value); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_enter_sleep_state); +EXPORT_SYMBOL(acpi_enter_sleep_state); /******************************************************************************* * @@ -399,60 +394,57 @@ EXPORT_SYMBOL(acpi_enter_sleep_state); * ******************************************************************************/ -acpi_status asmlinkage -acpi_enter_sleep_state_s4bios ( - void) +acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void) { - u32 in_value; - acpi_status status; - + u32 in_value; + acpi_status status; - ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state_s4bios"); + ACPI_FUNCTION_TRACE("acpi_enter_sleep_state_s4bios"); - - status = acpi_set_register (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_hw_clear_acpi_status (ACPI_MTX_DO_NOT_LOCK); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_clear_acpi_status(ACPI_MTX_DO_NOT_LOCK); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ - status = acpi_hw_disable_all_gpes (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_disable_all_gpes(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } acpi_gbl_system_awake_and_running = FALSE; - status = acpi_hw_enable_all_wakeup_gpes (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_enable_all_wakeup_gpes(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - ACPI_FLUSH_CPU_CACHE (); + ACPI_FLUSH_CPU_CACHE(); - status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, - (u32) acpi_gbl_FADT->S4bios_req, 8); + status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd, + (u32) acpi_gbl_FADT->S4bios_req, 8); do { acpi_os_stall(1000); - status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, - ACPI_MTX_DO_NOT_LOCK); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value, + ACPI_MTX_DO_NOT_LOCK); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } while (!in_value); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios); +EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios); /******************************************************************************* * @@ -467,55 +459,62 @@ EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios); * ******************************************************************************/ -acpi_status -acpi_leave_sleep_state ( - u8 sleep_state) +acpi_status acpi_leave_sleep_state(u8 sleep_state) { - struct acpi_object_list arg_list; - union acpi_object arg; - acpi_status status; - struct acpi_bit_register_info *sleep_type_reg_info; - struct acpi_bit_register_info *sleep_enable_reg_info; - u32 PM1Acontrol; - u32 PM1Bcontrol; - - - ACPI_FUNCTION_TRACE ("acpi_leave_sleep_state"); + struct acpi_object_list arg_list; + union acpi_object arg; + acpi_status status; + struct acpi_bit_register_info *sleep_type_reg_info; + struct acpi_bit_register_info *sleep_enable_reg_info; + u32 PM1Acontrol; + u32 PM1Bcontrol; + ACPI_FUNCTION_TRACE("acpi_leave_sleep_state"); /* * Set SLP_TYPE and SLP_EN to state S0. * This is unclear from the ACPI Spec, but it is required * by some machines. */ - status = acpi_get_sleep_type_data (ACPI_STATE_S0, - &acpi_gbl_sleep_type_a, &acpi_gbl_sleep_type_b); - if (ACPI_SUCCESS (status)) { - sleep_type_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_TYPE_A); - sleep_enable_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_ENABLE); + status = acpi_get_sleep_type_data(ACPI_STATE_S0, + &acpi_gbl_sleep_type_a, + &acpi_gbl_sleep_type_b); + if (ACPI_SUCCESS(status)) { + sleep_type_reg_info = + acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A); + sleep_enable_reg_info = + acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE); /* Get current value of PM1A control */ - status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); - if (ACPI_SUCCESS (status)) { + status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_CONTROL, + &PM1Acontrol); + if (ACPI_SUCCESS(status)) { /* Clear SLP_EN and SLP_TYP fields */ PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | - sleep_enable_reg_info->access_bit_mask); + sleep_enable_reg_info-> + access_bit_mask); PM1Bcontrol = PM1Acontrol; /* Insert SLP_TYP bits */ - PM1Acontrol |= (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); - PM1Bcontrol |= (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); + PM1Acontrol |= + (acpi_gbl_sleep_type_a << sleep_type_reg_info-> + bit_position); + PM1Bcontrol |= + (acpi_gbl_sleep_type_b << sleep_type_reg_info-> + bit_position); /* Just ignore any errors */ - (void) acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); - (void) acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); + (void)acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1A_CONTROL, + PM1Acontrol); + (void)acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1B_CONTROL, + PM1Bcontrol); } } @@ -532,23 +531,23 @@ acpi_leave_sleep_state ( /* Ignore any errors from these methods */ arg.integer.value = ACPI_SST_WAKING; - status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); - if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _SST failed, %s\n", - acpi_format_exception (status))); + status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { + ACPI_REPORT_ERROR(("Method _SST failed, %s\n", + acpi_format_exception(status))); } arg.integer.value = sleep_state; - status = acpi_evaluate_object (NULL, METHOD_NAME__BFS, &arg_list, NULL); - if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", - acpi_format_exception (status))); + status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL); + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { + ACPI_REPORT_ERROR(("Method _BFS failed, %s\n", + acpi_format_exception(status))); } - status = acpi_evaluate_object (NULL, METHOD_NAME__WAK, &arg_list, NULL); - if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", - acpi_format_exception (status))); + status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { + ACPI_REPORT_ERROR(("Method _WAK failed, %s\n", + acpi_format_exception(status))); } /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ @@ -557,33 +556,35 @@ acpi_leave_sleep_state ( * 1) Disable/Clear all GPEs * 2) Enable all runtime GPEs */ - status = acpi_hw_disable_all_gpes (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_disable_all_gpes(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } acpi_gbl_system_awake_and_running = TRUE; - status = acpi_hw_enable_all_runtime_gpes (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_enable_all_runtime_gpes(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Enable power button */ - (void) acpi_set_register( - acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].enable_register_id, - 1, ACPI_MTX_DO_NOT_LOCK); + (void) + acpi_set_register(acpi_gbl_fixed_event_info + [ACPI_EVENT_POWER_BUTTON].enable_register_id, 1, + ACPI_MTX_DO_NOT_LOCK); - (void) acpi_set_register( - acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].status_register_id, - 1, ACPI_MTX_DO_NOT_LOCK); + (void) + acpi_set_register(acpi_gbl_fixed_event_info + [ACPI_EVENT_POWER_BUTTON].status_register_id, 1, + ACPI_MTX_DO_NOT_LOCK); arg.integer.value = ACPI_SST_WORKING; - status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); - if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _SST failed, %s\n", - acpi_format_exception (status))); + status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { + ACPI_REPORT_ERROR(("Method _SST failed, %s\n", + acpi_format_exception(status))); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } diff --git a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/hardware/hwtimer.c index 49d7b39..aff6dc1 100644 --- a/drivers/acpi/hardware/hwtimer.c +++ b/drivers/acpi/hardware/hwtimer.c @@ -46,8 +46,7 @@ #include #define _COMPONENT ACPI_HARDWARE - ACPI_MODULE_NAME ("hwtimer") - +ACPI_MODULE_NAME("hwtimer") /****************************************************************************** * @@ -60,29 +59,23 @@ * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits). * ******************************************************************************/ - -acpi_status -acpi_get_timer_resolution ( - u32 *resolution) +acpi_status acpi_get_timer_resolution(u32 * resolution) { - ACPI_FUNCTION_TRACE ("acpi_get_timer_resolution"); - + ACPI_FUNCTION_TRACE("acpi_get_timer_resolution"); if (!resolution) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } if (0 == acpi_gbl_FADT->tmr_val_ext) { *resolution = 24; - } - else { + } else { *resolution = 32; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /****************************************************************************** * * FUNCTION: acpi_get_timer @@ -95,26 +88,22 @@ acpi_get_timer_resolution ( * ******************************************************************************/ -acpi_status -acpi_get_timer ( - u32 *ticks) +acpi_status acpi_get_timer(u32 * ticks) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_get_timer"); + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_get_timer"); if (!ticks) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_hw_low_level_read (32, ticks, &acpi_gbl_FADT->xpm_tmr_blk); + status = acpi_hw_low_level_read(32, ticks, &acpi_gbl_FADT->xpm_tmr_blk); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_timer); +EXPORT_SYMBOL(acpi_get_timer); /****************************************************************************** * @@ -146,21 +135,16 @@ EXPORT_SYMBOL(acpi_get_timer); ******************************************************************************/ acpi_status -acpi_get_timer_duration ( - u32 start_ticks, - u32 end_ticks, - u32 *time_elapsed) +acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed) { - acpi_status status; - u32 delta_ticks; - acpi_integer quotient; - - - ACPI_FUNCTION_TRACE ("acpi_get_timer_duration"); + acpi_status status; + u32 delta_ticks; + acpi_integer quotient; + ACPI_FUNCTION_TRACE("acpi_get_timer_duration"); if (!time_elapsed) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* @@ -169,22 +153,22 @@ acpi_get_timer_duration ( */ if (start_ticks < end_ticks) { delta_ticks = end_ticks - start_ticks; - } - else if (start_ticks > end_ticks) { + } else if (start_ticks > end_ticks) { if (0 == acpi_gbl_FADT->tmr_val_ext) { /* 24-bit Timer */ - delta_ticks = (((0x00FFFFFF - start_ticks) + end_ticks) & 0x00FFFFFF); - } - else { + delta_ticks = + (((0x00FFFFFF - start_ticks) + + end_ticks) & 0x00FFFFFF); + } else { /* 32-bit Timer */ delta_ticks = (0xFFFFFFFF - start_ticks) + end_ticks; } - } - else /* start_ticks == end_ticks */ { + } else { /* start_ticks == end_ticks */ + *time_elapsed = 0; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* @@ -192,12 +176,11 @@ acpi_get_timer_duration ( * * time_elapsed = (delta_ticks * 1000000) / PM_TIMER_FREQUENCY; */ - status = acpi_ut_short_divide (((u64) delta_ticks) * 1000000, - PM_TIMER_FREQUENCY, "ient, NULL); + status = acpi_ut_short_divide(((u64) delta_ticks) * 1000000, + PM_TIMER_FREQUENCY, "ient, NULL); *time_elapsed = (u32) quotient; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } EXPORT_SYMBOL(acpi_get_timer_duration); - diff --git a/drivers/acpi/hotkey.c b/drivers/acpi/hotkey.c index 1f76a40..2e2e4051 100644 --- a/drivers/acpi/hotkey.c +++ b/drivers/acpi/hotkey.c @@ -62,7 +62,7 @@ #define _COMPONENT ACPI_HOTKEY_COMPONENT ACPI_MODULE_NAME("acpi_hotkey") -MODULE_AUTHOR("luming.yu@intel.com"); + MODULE_AUTHOR("luming.yu@intel.com"); MODULE_DESCRIPTION(ACPI_HOTK_NAME); MODULE_LICENSE("GPL"); @@ -180,8 +180,8 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset); static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset); static int hotkey_polling_open_fs(struct inode *inode, struct file *file); static union acpi_hotkey *get_hotkey_by_event(struct - acpi_hotkey_list - *hotkey_list, int event); + acpi_hotkey_list + *hotkey_list, int event); /* event based config */ static struct file_operations hotkey_config_fops = { @@ -246,7 +246,7 @@ static int hotkey_info_open_fs(struct inode *inode, struct file *file) static char *format_result(union acpi_object *object) { char *buf = NULL; - + buf = (char *)kmalloc(RESULT_STR_LEN, GFP_KERNEL); if (buf) memset(buf, 0, RESULT_STR_LEN); @@ -256,7 +256,7 @@ static char *format_result(union acpi_object *object) /* Now, just support integer type */ if (object->type == ACPI_TYPE_INTEGER) sprintf(buf, "%d\n", (u32) object->integer.value); -do_fail: + do_fail: return (buf); } @@ -268,9 +268,9 @@ static int hotkey_polling_seq_show(struct seq_file *seq, void *offset) ACPI_FUNCTION_TRACE("hotkey_polling_seq_show"); - if (poll_hotkey->poll_result){ + if (poll_hotkey->poll_result) { buf = format_result(poll_hotkey->poll_result); - if(buf) + if (buf) seq_printf(seq, "%s", buf); kfree(buf); } @@ -299,7 +299,7 @@ static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list) union acpi_hotkey *key = container_of(entries, union acpi_hotkey, entries); if (key->link.hotkey_type == ACPI_HOTKEY_EVENT - && key->event_hotkey.external_hotkey_num == event){ + && key->event_hotkey.external_hotkey_num == event) { val = key->link.hotkey_standard_num; break; } @@ -343,7 +343,7 @@ static int auto_hotkey_remove(struct acpi_device *device, int type) static int create_polling_proc(union acpi_hotkey *device) { struct proc_dir_entry *proc; - char proc_name[80]; + char proc_name[80]; mode_t mode; ACPI_FUNCTION_TRACE("create_polling_proc"); @@ -351,8 +351,8 @@ static int create_polling_proc(union acpi_hotkey *device) sprintf(proc_name, "%d", device->link.hotkey_standard_num); /* - strcat(proc_name, device->poll_hotkey.poll_method); - */ + strcat(proc_name, device->poll_hotkey.poll_method); + */ proc = create_proc_entry(proc_name, mode, hotkey_proc_dir); if (!proc) { @@ -415,50 +415,50 @@ static int hotkey_remove(union acpi_hotkey *device) return_VALUE(0); } -static int hotkey_update(union acpi_hotkey *key) +static int hotkey_update(union acpi_hotkey *key) { struct list_head *entries; ACPI_FUNCTION_TRACE("hotkey_update"); list_for_each(entries, global_hotkey_list.entries) { - union acpi_hotkey *tmp= + union acpi_hotkey *tmp = container_of(entries, union acpi_hotkey, entries); if (tmp->link.hotkey_standard_num == key->link.hotkey_standard_num) { if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { free_hotkey_buffer(tmp); tmp->event_hotkey.bus_handle = - key->event_hotkey.bus_handle; + key->event_hotkey.bus_handle; tmp->event_hotkey.external_hotkey_num = - key->event_hotkey.external_hotkey_num; + key->event_hotkey.external_hotkey_num; tmp->event_hotkey.action_handle = - key->event_hotkey.action_handle; + key->event_hotkey.action_handle; tmp->event_hotkey.action_method = - key->event_hotkey.action_method; + key->event_hotkey.action_method; kfree(key); } else { /* - char proc_name[80]; + char proc_name[80]; - sprintf(proc_name, "%d", tmp->link.hotkey_standard_num); - strcat(proc_name, tmp->poll_hotkey.poll_method); - remove_proc_entry(proc_name,hotkey_proc_dir); - */ + sprintf(proc_name, "%d", tmp->link.hotkey_standard_num); + strcat(proc_name, tmp->poll_hotkey.poll_method); + remove_proc_entry(proc_name,hotkey_proc_dir); + */ free_poll_hotkey_buffer(tmp); tmp->poll_hotkey.poll_handle = - key->poll_hotkey.poll_handle; + key->poll_hotkey.poll_handle; tmp->poll_hotkey.poll_method = - key->poll_hotkey.poll_method; + key->poll_hotkey.poll_method; tmp->poll_hotkey.action_handle = - key->poll_hotkey.action_handle; + key->poll_hotkey.action_handle; tmp->poll_hotkey.action_method = - key->poll_hotkey.action_method; + key->poll_hotkey.action_method; tmp->poll_hotkey.poll_result = - key->poll_hotkey.poll_result; + key->poll_hotkey.poll_result; /* - create_polling_proc(tmp); - */ + create_polling_proc(tmp); + */ kfree(key); } return_VALUE(0); @@ -483,27 +483,25 @@ static void free_hotkey_device(union acpi_hotkey *key) acpi_hotkey_notify_handler); free_hotkey_buffer(key); } else { - char proc_name[80]; + char proc_name[80]; sprintf(proc_name, "%d", key->link.hotkey_standard_num); /* - strcat(proc_name, key->poll_hotkey.poll_method); - */ - remove_proc_entry(proc_name,hotkey_proc_dir); + strcat(proc_name, key->poll_hotkey.poll_method); + */ + remove_proc_entry(proc_name, hotkey_proc_dir); free_poll_hotkey_buffer(key); } kfree(key); return_VOID; } -static void -free_hotkey_buffer(union acpi_hotkey *key) +static void free_hotkey_buffer(union acpi_hotkey *key) { kfree(key->event_hotkey.action_method); } -static void -free_poll_hotkey_buffer(union acpi_hotkey *key) +static void free_poll_hotkey_buffer(union acpi_hotkey *key) { kfree(key->poll_hotkey.action_method); kfree(key->poll_hotkey.poll_method); @@ -513,15 +511,15 @@ static int init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str, char *method, int std_num, int external_num) { - acpi_handle tmp_handle; + acpi_handle tmp_handle; acpi_status status = AE_OK; ACPI_FUNCTION_TRACE("init_hotkey_device"); - if(std_num < 0 || IS_POLL(std_num) || !key ) + if (std_num < 0 || IS_POLL(std_num) || !key) goto do_fail; - if(!bus_str || !action_str || !method) + if (!bus_str || !action_str || !method) goto do_fail; key->link.hotkey_type = ACPI_HOTKEY_EVENT; @@ -529,19 +527,22 @@ init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str, key->event_hotkey.flag = 0; key->event_hotkey.action_method = method; - status = acpi_get_handle(NULL,bus_str, &(key->event_hotkey.bus_handle)); - if(ACPI_FAILURE(status)) + status = + acpi_get_handle(NULL, bus_str, &(key->event_hotkey.bus_handle)); + if (ACPI_FAILURE(status)) goto do_fail; key->event_hotkey.external_hotkey_num = external_num; - status = acpi_get_handle(NULL,action_str, &(key->event_hotkey.action_handle)); - if(ACPI_FAILURE(status)) + status = + acpi_get_handle(NULL, action_str, + &(key->event_hotkey.action_handle)); + if (ACPI_FAILURE(status)) goto do_fail; status = acpi_get_handle(key->event_hotkey.action_handle, - method, &tmp_handle); + method, &tmp_handle); if (ACPI_FAILURE(status)) goto do_fail; return_VALUE(AE_OK); -do_fail: + do_fail: return_VALUE(-ENODEV); } @@ -552,14 +553,14 @@ init_poll_hotkey_device(union acpi_hotkey *key, char *action_str, char *action_method, int std_num) { acpi_status status = AE_OK; - acpi_handle tmp_handle; + acpi_handle tmp_handle; ACPI_FUNCTION_TRACE("init_poll_hotkey_device"); - if(std_num < 0 || IS_EVENT(std_num) || !key) + if (std_num < 0 || IS_EVENT(std_num) || !key) goto do_fail; - if(!poll_str || !poll_method || !action_str || !action_method) + if (!poll_str || !poll_method || !action_str || !action_method) goto do_fail; key->link.hotkey_type = ACPI_HOTKEY_POLLING; @@ -568,30 +569,32 @@ init_poll_hotkey_device(union acpi_hotkey *key, key->poll_hotkey.poll_method = poll_method; key->poll_hotkey.action_method = action_method; - status = acpi_get_handle(NULL,poll_str, &(key->poll_hotkey.poll_handle)); - if(ACPI_FAILURE(status)) + status = + acpi_get_handle(NULL, poll_str, &(key->poll_hotkey.poll_handle)); + if (ACPI_FAILURE(status)) goto do_fail; status = acpi_get_handle(key->poll_hotkey.poll_handle, - poll_method, &tmp_handle); - if (ACPI_FAILURE(status)) - goto do_fail; - status = acpi_get_handle(NULL,action_str, &(key->poll_hotkey.action_handle)); + poll_method, &tmp_handle); + if (ACPI_FAILURE(status)) + goto do_fail; + status = + acpi_get_handle(NULL, action_str, + &(key->poll_hotkey.action_handle)); if (ACPI_FAILURE(status)) goto do_fail; status = acpi_get_handle(key->poll_hotkey.action_handle, - action_method, &tmp_handle); + action_method, &tmp_handle); if (ACPI_FAILURE(status)) goto do_fail; key->poll_hotkey.poll_result = (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); - if(!key->poll_hotkey.poll_result) + if (!key->poll_hotkey.poll_result) goto do_fail; return_VALUE(AE_OK); -do_fail: + do_fail: return_VALUE(-ENODEV); } - static int hotkey_open_config(struct inode *inode, struct file *file) { ACPI_FUNCTION_TRACE("hotkey_open_config"); @@ -679,8 +682,9 @@ get_parms(char *config_record, sscanf(config_record, "%d", cmd); - if(*cmd == 1){ - if(sscanf(config_record, "%d:%d", cmd, internal_event_num)!=2) + if (*cmd == 1) { + if (sscanf(config_record, "%d:%d", cmd, internal_event_num) != + 2) goto do_fail; else return (6); @@ -694,8 +698,8 @@ get_parms(char *config_record, goto do_fail; count = tmp1 - tmp; - *bus_handle = (char *) kmalloc(count+1, GFP_KERNEL); - if(!*bus_handle) + *bus_handle = (char *)kmalloc(count + 1, GFP_KERNEL); + if (!*bus_handle) goto do_fail; strncpy(*bus_handle, tmp, count); *(*bus_handle + count) = 0; @@ -706,8 +710,8 @@ get_parms(char *config_record, if (!tmp1) goto do_fail; count = tmp1 - tmp; - *bus_method = (char *) kmalloc(count+1, GFP_KERNEL); - if(!*bus_method) + *bus_method = (char *)kmalloc(count + 1, GFP_KERNEL); + if (!*bus_method) goto do_fail; strncpy(*bus_method, tmp, count); *(*bus_method + count) = 0; @@ -718,7 +722,7 @@ get_parms(char *config_record, if (!tmp1) goto do_fail; count = tmp1 - tmp; - *action_handle = (char *) kmalloc(count+1, GFP_KERNEL); + *action_handle = (char *)kmalloc(count + 1, GFP_KERNEL); strncpy(*action_handle, tmp, count); *(*action_handle + count) = 0; @@ -728,17 +732,18 @@ get_parms(char *config_record, if (!tmp1) goto do_fail; count = tmp1 - tmp; - *method = (char *) kmalloc(count+1, GFP_KERNEL); - if(!*method) + *method = (char *)kmalloc(count + 1, GFP_KERNEL); + if (!*method) goto do_fail; strncpy(*method, tmp, count); *(*method + count) = 0; - if(sscanf(tmp1 + 1, "%d:%d", internal_event_num, external_event_num)<=0) + if (sscanf(tmp1 + 1, "%d:%d", internal_event_num, external_event_num) <= + 0) goto do_fail; return_VALUE(6); -do_fail: + do_fail: return_VALUE(-1); } @@ -758,8 +763,8 @@ static ssize_t hotkey_write_config(struct file *file, ACPI_FUNCTION_TRACE(("hotkey_write_config")); - config_record = (char *) kmalloc(count+1, GFP_KERNEL); - if(!config_record) + config_record = (char *)kmalloc(count + 1, GFP_KERNEL); + if (!config_record) return_VALUE(-ENOMEM); if (copy_from_user(config_record, buffer, count)) { @@ -777,10 +782,10 @@ static ssize_t hotkey_write_config(struct file *file, &method, &internal_event_num, &external_event_num); kfree(config_record); - if(IS_OTHERS(internal_event_num)) + if (IS_OTHERS(internal_event_num)) goto do_fail; if (ret != 6) { -do_fail: + do_fail: kfree(bus_handle); kfree(bus_method); kfree(action_handle); @@ -791,14 +796,14 @@ do_fail: } key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL); - if(!key) + if (!key) goto do_fail; memset(key, 0, sizeof(union acpi_hotkey)); - if(cmd == 1) { + if (cmd == 1) { union acpi_hotkey *tmp = NULL; tmp = get_hotkey_by_event(&global_hotkey_list, - internal_event_num); - if(!tmp) + internal_event_num); + if (!tmp) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid key")); else memcpy(key, tmp, sizeof(union acpi_hotkey)); @@ -807,15 +812,16 @@ do_fail: if (IS_EVENT(internal_event_num)) { kfree(bus_method); ret = init_hotkey_device(key, bus_handle, action_handle, method, - internal_event_num, external_event_num); + internal_event_num, + external_event_num); } else ret = init_poll_hotkey_device(key, bus_handle, bus_method, - action_handle, method, - internal_event_num); + action_handle, method, + internal_event_num); if (ret) { kfree(bus_handle); kfree(action_handle); - if(IS_EVENT(internal_event_num)) + if (IS_EVENT(internal_event_num)) free_hotkey_buffer(key); else free_poll_hotkey_buffer(key); @@ -824,13 +830,14 @@ do_fail: return_VALUE(-EINVAL); } -cont_cmd: + cont_cmd: kfree(bus_handle); kfree(action_handle); switch (cmd) { case 0: - if(get_hotkey_by_event(&global_hotkey_list,key->link.hotkey_standard_num)) + if (get_hotkey_by_event + (&global_hotkey_list, key->link.hotkey_standard_num)) goto fail_out; else hotkey_add(key); @@ -839,7 +846,7 @@ cont_cmd: hotkey_remove(key); break; case 2: - if(hotkey_update(key)) + if (hotkey_update(key)) goto fail_out; break; default: @@ -847,8 +854,8 @@ cont_cmd: break; } return_VALUE(count); -fail_out: - if(IS_EVENT(internal_event_num)) + fail_out: + if (IS_EVENT(internal_event_num)) free_hotkey_buffer(key); else free_poll_hotkey_buffer(key); @@ -882,7 +889,8 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val, return_VALUE(status == AE_OK); } -static int read_acpi_int(acpi_handle handle, const char *method, union acpi_object *val) +static int read_acpi_int(acpi_handle handle, const char *method, + union acpi_object *val) { struct acpi_buffer output; union acpi_object out_obj; @@ -893,7 +901,7 @@ static int read_acpi_int(acpi_handle handle, const char *method, union acpi_obje output.pointer = &out_obj; status = acpi_evaluate_object(handle, (char *)method, NULL, &output); - if(val){ + if (val) { val->integer.value = out_obj.integer.value; val->type = out_obj.type; } else @@ -903,8 +911,8 @@ static int read_acpi_int(acpi_handle handle, const char *method, union acpi_obje } static union acpi_hotkey *get_hotkey_by_event(struct - acpi_hotkey_list - *hotkey_list, int event) + acpi_hotkey_list + *hotkey_list, int event) { struct list_head *entries; @@ -912,10 +920,10 @@ static union acpi_hotkey *get_hotkey_by_event(struct union acpi_hotkey *key = container_of(entries, union acpi_hotkey, entries); if (key->link.hotkey_standard_num == event) { - return(key); + return (key); } } - return(NULL); + return (NULL); } /* @@ -932,15 +940,15 @@ static ssize_t hotkey_execute_aml_method(struct file *file, { struct acpi_hotkey_list *hotkey_list = &global_hotkey_list; char *arg; - int event,method_type,type, value; + int event, method_type, type, value; union acpi_hotkey *key; ACPI_FUNCTION_TRACE("hotkey_execte_aml_method"); - arg = (char *) kmalloc(count+1, GFP_KERNEL); - if(!arg) + arg = (char *)kmalloc(count + 1, GFP_KERNEL); + if (!arg) return_VALUE(-ENOMEM); - arg[count]=0; + arg[count] = 0; if (copy_from_user(arg, buffer, count)) { kfree(arg); @@ -948,7 +956,8 @@ static ssize_t hotkey_execute_aml_method(struct file *file, return_VALUE(-EINVAL); } - if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) != 4) { + if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) != + 4) { kfree(arg); ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3")); return_VALUE(-EINVAL); @@ -956,19 +965,21 @@ static ssize_t hotkey_execute_aml_method(struct file *file, kfree(arg); if (type == ACPI_TYPE_INTEGER) { key = get_hotkey_by_event(hotkey_list, event); - if(!key) + if (!key) goto do_fail; if (IS_EVENT(event)) write_acpi_int(key->event_hotkey.action_handle, - key->event_hotkey.action_method, value, NULL); + key->event_hotkey.action_method, value, + NULL); else if (IS_POLL(event)) { - if ( method_type == POLL_METHOD ) + if (method_type == POLL_METHOD) read_acpi_int(key->poll_hotkey.poll_handle, - key->poll_hotkey.poll_method, - key->poll_hotkey.poll_result); - else if ( method_type == ACTION_METHOD ) + key->poll_hotkey.poll_method, + key->poll_hotkey.poll_result); + else if (method_type == ACTION_METHOD) write_acpi_int(key->poll_hotkey.action_handle, - key->poll_hotkey.action_method, value, NULL); + key->poll_hotkey.action_method, + value, NULL); else goto do_fail; @@ -978,7 +989,7 @@ static ssize_t hotkey_execute_aml_method(struct file *file, return_VALUE(-EINVAL); } return_VALUE(count); -do_fail: + do_fail: return_VALUE(-EINVAL); } @@ -1074,15 +1085,15 @@ static int __init hotkey_init(void) return (0); -do_fail5: + do_fail5: remove_proc_entry(HOTKEY_INFO, hotkey_proc_dir); -do_fail4: + do_fail4: remove_proc_entry(HOTKEY_ACTION, hotkey_proc_dir); -do_fail3: + do_fail3: remove_proc_entry(HOTKEY_PL_CONFIG, hotkey_proc_dir); -do_fail2: + do_fail2: remove_proc_entry(HOTKEY_EV_CONFIG, hotkey_proc_dir); -do_fail1: + do_fail1: remove_proc_entry(HOTKEY_PROC, acpi_root_dir); return (-ENODEV); } diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c index ad85e10..62233bd 100644 --- a/drivers/acpi/ibm_acpi.c +++ b/drivers/acpi/ibm_acpi.c @@ -86,52 +86,46 @@ static acpi_handle root_handle = NULL; static acpi_handle *object##_parent = &parent##_handle; \ static char *object##_paths[] = { paths } -IBM_HANDLE(ec, root, - "\\_SB.PCI0.ISA.EC", /* A21e, A22p, T20, T21, X20 */ - "\\_SB.PCI0.LPC.EC", /* all others */ -); - -IBM_HANDLE(vid, root, - "\\_SB.PCI0.VID", /* A21e, G40, X30, X40 */ - "\\_SB.PCI0.AGP.VID", /* all others */ -); - -IBM_HANDLE(cmos, root, - "\\UCMS", /* R50, R50p, R51, T4x, X31, X40 */ - "\\CMOS", /* A3x, G40, R32, T23, T30, X22, X24, X30 */ - "\\CMS", /* R40, R40e */ -); /* A21e, A22p, T20, T21, X20 */ - -IBM_HANDLE(dock, root, - "\\_SB.GDCK", /* X30, X31, X40 */ - "\\_SB.PCI0.DOCK", /* A22p, T20, T21, X20 */ - "\\_SB.PCI0.PCI1.DOCK", /* all others */ -); /* A21e, G40, R32, R40, R40e */ - -IBM_HANDLE(bay, root, - "\\_SB.PCI0.IDE0.SCND.MSTR"); /* all except A21e */ -IBM_HANDLE(bayej, root, - "\\_SB.PCI0.IDE0.SCND.MSTR._EJ0"); /* all except A2x, A3x */ - -IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A22p, T20, T21, X20 */ -IBM_HANDLE(hkey, ec, "HKEY"); /* all */ -IBM_HANDLE(led, ec, "LED"); /* all except A21e, A22p, T20, T21, X20 */ -IBM_HANDLE(sysl, ec, "SYSL"); /* A21e, A22p, T20, T21, X20 */ -IBM_HANDLE(bled, ec, "BLED"); /* A22p, T20, T21, X20 */ -IBM_HANDLE(beep, ec, "BEEP"); /* all models */ +IBM_HANDLE(ec, root, "\\_SB.PCI0.ISA.EC", /* A21e, A22p, T20, T21, X20 */ + "\\_SB.PCI0.LPC.EC", /* all others */ + ); + +IBM_HANDLE(vid, root, "\\_SB.PCI0.VID", /* A21e, G40, X30, X40 */ + "\\_SB.PCI0.AGP.VID", /* all others */ + ); + +IBM_HANDLE(cmos, root, "\\UCMS", /* R50, R50p, R51, T4x, X31, X40 */ + "\\CMOS", /* A3x, G40, R32, T23, T30, X22, X24, X30 */ + "\\CMS", /* R40, R40e */ + ); /* A21e, A22p, T20, T21, X20 */ + +IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */ + "\\_SB.PCI0.DOCK", /* A22p, T20, T21, X20 */ + "\\_SB.PCI0.PCI1.DOCK", /* all others */ + ); /* A21e, G40, R32, R40, R40e */ + +IBM_HANDLE(bay, root, "\\_SB.PCI0.IDE0.SCND.MSTR"); /* all except A21e */ +IBM_HANDLE(bayej, root, "\\_SB.PCI0.IDE0.SCND.MSTR._EJ0"); /* all except A2x, A3x */ + +IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A22p, T20, T21, X20 */ +IBM_HANDLE(hkey, ec, "HKEY"); /* all */ +IBM_HANDLE(led, ec, "LED"); /* all except A21e, A22p, T20, T21, X20 */ +IBM_HANDLE(sysl, ec, "SYSL"); /* A21e, A22p, T20, T21, X20 */ +IBM_HANDLE(bled, ec, "BLED"); /* A22p, T20, T21, X20 */ +IBM_HANDLE(beep, ec, "BEEP"); /* all models */ struct ibm_struct { char *name; char *hid; struct acpi_driver *driver; - - int (*init) (struct ibm_struct *); - int (*read) (struct ibm_struct *, char *); - int (*write) (struct ibm_struct *, char *); - void (*exit) (struct ibm_struct *); - void (*notify) (struct ibm_struct *, u32); + int (*init) (struct ibm_struct *); + int (*read) (struct ibm_struct *, char *); + int (*write) (struct ibm_struct *, char *); + void (*exit) (struct ibm_struct *); + + void (*notify) (struct ibm_struct *, u32); acpi_handle *handle; int type; struct acpi_device *device; @@ -165,15 +159,15 @@ static int acpi_evalf(acpi_handle handle, void *res, char *method, char *fmt, ...) { char *fmt0 = fmt; - struct acpi_object_list params; - union acpi_object in_objs[IBM_MAX_ACPI_ARGS]; - struct acpi_buffer result; - union acpi_object out_obj; - acpi_status status; - va_list ap; - char res_type; - int success; - int quiet; + struct acpi_object_list params; + union acpi_object in_objs[IBM_MAX_ACPI_ARGS]; + struct acpi_buffer result; + union acpi_object out_obj; + acpi_status status; + va_list ap; + char res_type; + int success; + int quiet; if (!*fmt) { printk(IBM_ERR "acpi_evalf() called with empty format\n"); @@ -199,7 +193,7 @@ static int acpi_evalf(acpi_handle handle, in_objs[params.count].integer.value = va_arg(ap, int); in_objs[params.count++].type = ACPI_TYPE_INTEGER; break; - /* add more types as needed */ + /* add more types as needed */ default: printk(IBM_ERR "acpi_evalf() called " "with invalid format character '%c'\n", c); @@ -214,15 +208,15 @@ static int acpi_evalf(acpi_handle handle, status = acpi_evaluate_object(handle, method, ¶ms, &result); switch (res_type) { - case 'd': /* int */ + case 'd': /* int */ if (res) *(int *)res = out_obj.integer.value; success = status == AE_OK && out_obj.type == ACPI_TYPE_INTEGER; break; - case 'v': /* void */ + case 'v': /* void */ success = status == AE_OK; break; - /* add more types as needed */ + /* add more types as needed */ default: printk(IBM_ERR "acpi_evalf() called " "with invalid format character '%c'\n", res_type); @@ -303,9 +297,9 @@ static int hotkey_set(struct ibm_struct *ibm, int status, int mask) if (!ibm->supported) return 0; - for (i=0; i<32; i++) { + for (i = 0; i < 32; i++) { int bit = ((1 << i) & mask) != 0; - if (!acpi_evalf(hkey_handle, NULL, "MHKM", "vdd", i+1, bit)) + if (!acpi_evalf(hkey_handle, NULL, "MHKM", "vdd", i + 1, bit)) return -EIO; } @@ -318,8 +312,7 @@ static int hotkey_init(struct ibm_struct *ibm) ibm->supported = 1; ret = hotkey_get(ibm, - &ibm->state.hotkey.status, - &ibm->state.hotkey.mask); + &ibm->state.hotkey.status, &ibm->state.hotkey.mask); if (ret < 0) { /* mask not supported on A21e, A22p, T20, T21, X20, X22, X24 */ ibm->supported = 0; @@ -329,7 +322,7 @@ static int hotkey_init(struct ibm_struct *ibm) } return ret; -} +} static int hotkey_read(struct ibm_struct *ibm, char *p) { @@ -368,7 +361,7 @@ static int hotkey_write(struct ibm_struct *ibm, char *buf) status = 0; } else if (strlencmp(cmd, "reset") == 0) { status = ibm->state.hotkey.status; - mask = ibm->state.hotkey.mask; + mask = ibm->state.hotkey.mask; } else if (sscanf(cmd, "0x%x", &mask) == 1) { /* mask set */ } else if (sscanf(cmd, "%x", &mask) == 1) { @@ -382,7 +375,7 @@ static int hotkey_write(struct ibm_struct *ibm, char *buf) return -EIO; return 0; -} +} static void hotkey_exit(struct ibm_struct *ibm) { @@ -398,7 +391,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) else { printk(IBM_ERR "unknown hotkey event %d\n", event); acpi_bus_generate_event(ibm->device, event, 0); - } + } } static int bluetooth_init(struct ibm_struct *ibm) @@ -456,15 +449,14 @@ static int bluetooth_write(struct ibm_struct *ibm, char *buf) } if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) - return -EIO; + return -EIO; return 0; } static int video_init(struct ibm_struct *ibm) { - if (!acpi_evalf(vid_handle, - &ibm->state.video.autoswitch, "^VDEE", "d")) + if (!acpi_evalf(vid_handle, &ibm->state.video.autoswitch, "^VDEE", "d")) return -ENODEV; return 0; @@ -566,8 +558,7 @@ static int video_write(struct ibm_struct *ibm, char *buf) static void video_exit(struct ibm_struct *ibm) { - acpi_evalf(vid_handle, NULL, "_DOS", "vd", - ibm->state.video.autoswitch); + acpi_evalf(vid_handle, NULL, "_DOS", "vd", ibm->state.video.autoswitch); } static int light_init(struct ibm_struct *ibm) @@ -600,7 +591,7 @@ static int light_write(struct ibm_struct *ibm, char *buf) int cmos_cmd, lght_cmd; char *cmd; int success; - + while ((cmd = next_cmd(&buf))) { if (strlencmp(cmd, "on") == 0) { cmos_cmd = 0x0c; @@ -610,10 +601,10 @@ static int light_write(struct ibm_struct *ibm, char *buf) lght_cmd = 0; } else return -EINVAL; - + success = cmos_handle ? - acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd) : - acpi_evalf(lght_handle, NULL, NULL, "vd", lght_cmd); + acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd) : + acpi_evalf(lght_handle, NULL, NULL, "vd", lght_cmd); if (!success) return -EIO; } @@ -671,22 +662,22 @@ static int dock_write(struct ibm_struct *ibm, char *buf) } return 0; -} +} static void dock_notify(struct ibm_struct *ibm, u32 event) { int docked = dock_docked(); if (event == 3 && docked) - acpi_bus_generate_event(ibm->device, event, 1); /* button */ + acpi_bus_generate_event(ibm->device, event, 1); /* button */ else if (event == 3 && !docked) - acpi_bus_generate_event(ibm->device, event, 2); /* undock */ + acpi_bus_generate_event(ibm->device, event, 2); /* undock */ else if (event == 0 && docked) - acpi_bus_generate_event(ibm->device, event, 3); /* dock */ + acpi_bus_generate_event(ibm->device, event, 3); /* dock */ else { printk(IBM_ERR "unknown dock event %d, status %d\n", event, _sta(dock_handle)); - acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ + acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ } } @@ -696,7 +687,7 @@ static int bay_init(struct ibm_struct *ibm) { /* bay not supported on A21e, A22p, A31, A31p, G40, R32, R40e */ ibm->supported = bay_handle && bayej_handle && - acpi_evalf(bay_handle, NULL, "_STA", "qv"); + acpi_evalf(bay_handle, NULL, "_STA", "qv"); return 0; } @@ -705,7 +696,7 @@ static int bay_read(struct ibm_struct *ibm, char *p) { int len = 0; int occupied = bay_occupied(); - + if (!ibm->supported) len += sprintf(p + len, "status:\t\tnot supported\n"); else if (!occupied) @@ -732,7 +723,7 @@ static int bay_write(struct ibm_struct *ibm, char *buf) } return 0; -} +} static void bay_notify(struct ibm_struct *ibm, u32 event) { @@ -773,8 +764,8 @@ static int cmos_write(struct ibm_struct *ibm, char *buf) } return 0; -} - +} + static int led_read(struct ibm_struct *ibm, char *p) { int len = 0; @@ -809,7 +800,7 @@ static int led_write(struct ibm_struct *ibm, char *buf) led_cmd = sysl_cmd = bled_a = bled_b = 0; } else return -EINVAL; - + if (led_handle) { if (!acpi_evalf(led_handle, NULL, NULL, "vdd", led, led_cmd)) @@ -827,8 +818,8 @@ static int led_write(struct ibm_struct *ibm, char *buf) } return 0; -} - +} + static int beep_read(struct ibm_struct *ibm, char *p) { int len = 0; @@ -854,80 +845,81 @@ static int beep_write(struct ibm_struct *ibm, char *buf) } return 0; -} - +} + static struct ibm_struct ibms[] = { { - .name = "driver", - .init = driver_init, - .read = driver_read, - }, + .name = "driver", + .init = driver_init, + .read = driver_read, + }, { - .name = "hotkey", - .hid = "IBM0068", - .init = hotkey_init, - .read = hotkey_read, - .write = hotkey_write, - .exit = hotkey_exit, - .notify = hotkey_notify, - .handle = &hkey_handle, - .type = ACPI_DEVICE_NOTIFY, - }, + .name = "hotkey", + .hid = "IBM0068", + .init = hotkey_init, + .read = hotkey_read, + .write = hotkey_write, + .exit = hotkey_exit, + .notify = hotkey_notify, + .handle = &hkey_handle, + .type = ACPI_DEVICE_NOTIFY, + }, { - .name = "bluetooth", - .init = bluetooth_init, - .read = bluetooth_read, - .write = bluetooth_write, - }, + .name = "bluetooth", + .init = bluetooth_init, + .read = bluetooth_read, + .write = bluetooth_write, + }, { - .name = "video", - .init = video_init, - .read = video_read, - .write = video_write, - .exit = video_exit, - }, + .name = "video", + .init = video_init, + .read = video_read, + .write = video_write, + .exit = video_exit, + }, { - .name = "light", - .init = light_init, - .read = light_read, - .write = light_write, - }, + .name = "light", + .init = light_init, + .read = light_read, + .write = light_write, + }, { - .name = "dock", - .read = dock_read, - .write = dock_write, - .notify = dock_notify, - .handle = &dock_handle, - .type = ACPI_SYSTEM_NOTIFY, - }, + .name = "dock", + .read = dock_read, + .write = dock_write, + .notify = dock_notify, + .handle = &dock_handle, + .type = ACPI_SYSTEM_NOTIFY, + }, { - .name = "bay", - .init = bay_init, - .read = bay_read, - .write = bay_write, - .notify = bay_notify, - .handle = &bay_handle, - .type = ACPI_SYSTEM_NOTIFY, - }, + .name = "bay", + .init = bay_init, + .read = bay_read, + .write = bay_write, + .notify = bay_notify, + .handle = &bay_handle, + .type = ACPI_SYSTEM_NOTIFY, + }, { - .name = "cmos", - .read = cmos_read, - .write = cmos_write, - .experimental = 1, - }, + .name = "cmos", + .read = cmos_read, + .write = cmos_write, + .experimental = 1, + }, { - .name = "led", - .read = led_read, - .write = led_write, - .experimental = 1, - }, + .name = "led", + .read = led_read, + .write = led_write, + .experimental = 1, + }, { - .name = "beep", - .read = beep_read, - .write = beep_write, - .experimental = 1, - }, + .name = "beep", + .read = beep_read, + .write = beep_write, + .experimental = 1, + }, }; + #define NUM_IBMS (sizeof(ibms)/sizeof(ibms[0])) static int dispatch_read(char *page, char **start, off_t off, int count, @@ -935,7 +927,7 @@ static int dispatch_read(char *page, char **start, off_t off, int count, { struct ibm_struct *ibm = (struct ibm_struct *)data; int len; - + if (!ibm || !ibm->read) return -EINVAL; @@ -955,7 +947,7 @@ static int dispatch_read(char *page, char **start, off_t off, int count, return len; } -static int dispatch_write(struct file *file, const char __user *userbuf, +static int dispatch_write(struct file *file, const char __user * userbuf, unsigned long count, void *data) { struct ibm_struct *ibm = (struct ibm_struct *)data; @@ -969,9 +961,9 @@ static int dispatch_write(struct file *file, const char __user *userbuf, if (!kernbuf) return -ENOMEM; - if (copy_from_user(kernbuf, userbuf, count)) { + if (copy_from_user(kernbuf, userbuf, count)) { kfree(kernbuf); - return -EFAULT; + return -EFAULT; } kernbuf[count] = 0; @@ -982,7 +974,7 @@ static int dispatch_write(struct file *file, const char __user *userbuf, kfree(kernbuf); - return ret; + return ret; } static void dispatch_notify(acpi_handle handle, u32 event, void *data) @@ -1085,7 +1077,7 @@ static int ibm_init(struct ibm_struct *ibm) } entry->owner = THIS_MODULE; ibm->proc_created = 1; - + entry->data = ibm; if (ibm->read) entry->read_proc = &dispatch_read; @@ -1120,18 +1112,18 @@ static void ibm_exit(struct ibm_struct *ibm) } static int ibm_handle_init(char *name, - acpi_handle *handle, acpi_handle parent, + acpi_handle * handle, acpi_handle parent, char **paths, int num_paths, int required) { int i; acpi_status status; - for (i=0; iname) == 0) return ibms[i].write(&ibms[i], arg_with_comma); BUG(); @@ -1172,7 +1163,7 @@ static void acpi_ibm_exit(void) { int i; - for (i=NUM_IBMS-1; i>=0; i--) + for (i = NUM_IBMS - 1; i >= 0; i--) ibm_exit(&ibms[i]); remove_proc_entry(IBM_DIR, acpi_root_dir); @@ -1185,15 +1176,14 @@ static int __init acpi_ibm_init(void) if (acpi_disabled) return -ENODEV; - if (!acpi_specific_hotkey_enabled){ + if (!acpi_specific_hotkey_enabled) { printk(IBM_ERR "Using generic hotkey driver\n"); - return -ENODEV; + return -ENODEV; } /* these handles are required */ - if (IBM_HANDLE_INIT(ec, 1) < 0 || + if (IBM_HANDLE_INIT(ec, 1) < 0 || IBM_HANDLE_INIT(hkey, 1) < 0 || - IBM_HANDLE_INIT(vid, 1) < 0 || - IBM_HANDLE_INIT(beep, 1) < 0) + IBM_HANDLE_INIT(vid, 1) < 0 || IBM_HANDLE_INIT(beep, 1) < 0) return -ENODEV; /* these handles have alternatives */ @@ -1205,10 +1195,10 @@ static int __init acpi_ibm_init(void) return -ENODEV; /* these handles are not required */ - IBM_HANDLE_INIT(dock, 0); - IBM_HANDLE_INIT(bay, 0); + IBM_HANDLE_INIT(dock, 0); + IBM_HANDLE_INIT(bay, 0); IBM_HANDLE_INIT(bayej, 0); - IBM_HANDLE_INIT(bled, 0); + IBM_HANDLE_INIT(bled, 0); proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir); if (!proc_dir) { @@ -1216,8 +1206,8 @@ static int __init acpi_ibm_init(void) return -ENODEV; } proc_dir->owner = THIS_MODULE; - - for (i=0; i #define _COMPONENT ACPI_SYSTEM_COMPONENT -ACPI_MODULE_NAME ("acpi_motherboard") +ACPI_MODULE_NAME("acpi_motherboard") /* Dell use PNP0C01 instead of PNP0C02 */ #define ACPI_MB_HID1 "PNP0C01" #define ACPI_MB_HID2 "PNP0C02" - /** * Doesn't care about legacy IO ports, only IO ports beyond 0x1000 are reserved * Doesn't care about the failure of 'request_region', since other may reserve @@ -44,15 +43,12 @@ ACPI_MODULE_NAME ("acpi_motherboard") #define IS_RESERVED_ADDR(base, len) \ (((len) > 0) && ((base) > 0) && ((base) + (len) < IO_SPACE_LIMIT) \ && ((base) + (len) > 0x1000)) - /* * Clearing the flag (IORESOURCE_BUSY) allows drivers to use * the io ports if they really know they can use it, while * still preventing hotplug PCI devices from using it. */ - -static acpi_status -acpi_reserve_io_ranges (struct acpi_resource *res, void *data) +static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data) { struct resource *requested_res = NULL; @@ -63,22 +59,32 @@ acpi_reserve_io_ranges (struct acpi_resource *res, void *data) if (io_res->min_base_address != io_res->max_base_address) return_VALUE(AE_OK); - if (IS_RESERVED_ADDR(io_res->min_base_address, io_res->range_length)) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Motherboard resources 0x%08x - 0x%08x\n", - io_res->min_base_address, - io_res->min_base_address + io_res->range_length)); - requested_res = request_region(io_res->min_base_address, - io_res->range_length, "motherboard"); + if (IS_RESERVED_ADDR + (io_res->min_base_address, io_res->range_length)) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Motherboard resources 0x%08x - 0x%08x\n", + io_res->min_base_address, + io_res->min_base_address + + io_res->range_length)); + requested_res = + request_region(io_res->min_base_address, + io_res->range_length, "motherboard"); } } else if (res->id == ACPI_RSTYPE_FIXED_IO) { - struct acpi_resource_fixed_io *fixed_io_res = &res->data.fixed_io; - - if (IS_RESERVED_ADDR(fixed_io_res->base_address, fixed_io_res->range_length)) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Motherboard resources 0x%08x - 0x%08x\n", - fixed_io_res->base_address, - fixed_io_res->base_address + fixed_io_res->range_length)); - requested_res = request_region(fixed_io_res->base_address, - fixed_io_res->range_length, "motherboard"); + struct acpi_resource_fixed_io *fixed_io_res = + &res->data.fixed_io; + + if (IS_RESERVED_ADDR + (fixed_io_res->base_address, fixed_io_res->range_length)) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Motherboard resources 0x%08x - 0x%08x\n", + fixed_io_res->base_address, + fixed_io_res->base_address + + fixed_io_res->range_length)); + requested_res = + request_region(fixed_io_res->base_address, + fixed_io_res->range_length, + "motherboard"); } } else { /* Memory mapped IO? */ @@ -89,72 +95,70 @@ acpi_reserve_io_ranges (struct acpi_resource *res, void *data) return_VALUE(AE_OK); } -static int acpi_motherboard_add (struct acpi_device *device) +static int acpi_motherboard_add(struct acpi_device *device) { if (!device) return -EINVAL; - acpi_walk_resources(device->handle, METHOD_NAME__CRS, - acpi_reserve_io_ranges, NULL); + acpi_walk_resources(device->handle, METHOD_NAME__CRS, + acpi_reserve_io_ranges, NULL); return 0; } static struct acpi_driver acpi_motherboard_driver1 = { - .name = "motherboard", - .class = "", - .ids = ACPI_MB_HID1, - .ops = { - .add = acpi_motherboard_add, - }, + .name = "motherboard", + .class = "", + .ids = ACPI_MB_HID1, + .ops = { + .add = acpi_motherboard_add, + }, }; static struct acpi_driver acpi_motherboard_driver2 = { - .name = "motherboard", - .class = "", - .ids = ACPI_MB_HID2, - .ops = { - .add = acpi_motherboard_add, - }, + .name = "motherboard", + .class = "", + .ids = ACPI_MB_HID2, + .ops = { + .add = acpi_motherboard_add, + }, }; -static void __init -acpi_reserve_resources (void) +static void __init acpi_reserve_resources(void) { if (acpi_gbl_FADT->xpm1a_evt_blk.address && acpi_gbl_FADT->pm1_evt_len) - request_region(acpi_gbl_FADT->xpm1a_evt_blk.address, - acpi_gbl_FADT->pm1_evt_len, "PM1a_EVT_BLK"); + request_region(acpi_gbl_FADT->xpm1a_evt_blk.address, + acpi_gbl_FADT->pm1_evt_len, "PM1a_EVT_BLK"); if (acpi_gbl_FADT->xpm1b_evt_blk.address && acpi_gbl_FADT->pm1_evt_len) request_region(acpi_gbl_FADT->xpm1b_evt_blk.address, - acpi_gbl_FADT->pm1_evt_len, "PM1b_EVT_BLK"); + acpi_gbl_FADT->pm1_evt_len, "PM1b_EVT_BLK"); if (acpi_gbl_FADT->xpm1a_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len) - request_region(acpi_gbl_FADT->xpm1a_cnt_blk.address, - acpi_gbl_FADT->pm1_cnt_len, "PM1a_CNT_BLK"); + request_region(acpi_gbl_FADT->xpm1a_cnt_blk.address, + acpi_gbl_FADT->pm1_cnt_len, "PM1a_CNT_BLK"); if (acpi_gbl_FADT->xpm1b_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len) - request_region(acpi_gbl_FADT->xpm1b_cnt_blk.address, - acpi_gbl_FADT->pm1_cnt_len, "PM1b_CNT_BLK"); + request_region(acpi_gbl_FADT->xpm1b_cnt_blk.address, + acpi_gbl_FADT->pm1_cnt_len, "PM1b_CNT_BLK"); if (acpi_gbl_FADT->xpm_tmr_blk.address && acpi_gbl_FADT->pm_tm_len == 4) - request_region(acpi_gbl_FADT->xpm_tmr_blk.address, - 4, "PM_TMR"); + request_region(acpi_gbl_FADT->xpm_tmr_blk.address, 4, "PM_TMR"); if (acpi_gbl_FADT->xpm2_cnt_blk.address && acpi_gbl_FADT->pm2_cnt_len) request_region(acpi_gbl_FADT->xpm2_cnt_blk.address, - acpi_gbl_FADT->pm2_cnt_len, "PM2_CNT_BLK"); + acpi_gbl_FADT->pm2_cnt_len, "PM2_CNT_BLK"); /* Length of GPE blocks must be a non-negative multiple of 2 */ if (acpi_gbl_FADT->xgpe0_blk.address && acpi_gbl_FADT->gpe0_blk_len && - !(acpi_gbl_FADT->gpe0_blk_len & 0x1)) + !(acpi_gbl_FADT->gpe0_blk_len & 0x1)) request_region(acpi_gbl_FADT->xgpe0_blk.address, - acpi_gbl_FADT->gpe0_blk_len, "GPE0_BLK"); + acpi_gbl_FADT->gpe0_blk_len, "GPE0_BLK"); if (acpi_gbl_FADT->xgpe1_blk.address && acpi_gbl_FADT->gpe1_blk_len && - !(acpi_gbl_FADT->gpe1_blk_len & 0x1)) + !(acpi_gbl_FADT->gpe1_blk_len & 0x1)) request_region(acpi_gbl_FADT->xgpe1_blk.address, - acpi_gbl_FADT->gpe1_blk_len, "GPE1_BLK"); + acpi_gbl_FADT->gpe1_blk_len, "GPE1_BLK"); } static int __init acpi_motherboard_init(void) @@ -166,7 +170,7 @@ static int __init acpi_motherboard_init(void) * This module must run after scan.c */ if (!acpi_disabled) - acpi_reserve_resources (); + acpi_reserve_resources(); return 0; } diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c index 7589e1f..edfbe34 100644 --- a/drivers/acpi/namespace/nsaccess.c +++ b/drivers/acpi/namespace/nsaccess.c @@ -41,16 +41,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsaccess") - +ACPI_MODULE_NAME("nsaccess") /******************************************************************************* * @@ -65,24 +62,19 @@ * MUTEX: Locks namespace for entire execution * ******************************************************************************/ - -acpi_status -acpi_ns_root_initialize ( - void) +acpi_status acpi_ns_root_initialize(void) { - acpi_status status; + acpi_status status; const struct acpi_predefined_names *init_val = NULL; - struct acpi_namespace_node *new_node; - union acpi_operand_object *obj_desc; - acpi_string val = NULL; - + struct acpi_namespace_node *new_node; + union acpi_operand_object *obj_desc; + acpi_string val = NULL; - ACPI_FUNCTION_TRACE ("ns_root_initialize"); + ACPI_FUNCTION_TRACE("ns_root_initialize"); - - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -102,24 +94,26 @@ acpi_ns_root_initialize ( /* Enter the pre-defined names in the name table */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Entering predefined entries into namespace\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Entering predefined entries into namespace\n")); for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) { /* _OSI is optional for now, will be permanent later */ - if (!ACPI_STRCMP (init_val->name, "_OSI") && !acpi_gbl_create_osi_method) { + if (!ACPI_STRCMP(init_val->name, "_OSI") + && !acpi_gbl_create_osi_method) { continue; } - status = acpi_ns_lookup (NULL, init_val->name, init_val->type, - ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, - NULL, &new_node); + status = acpi_ns_lookup(NULL, init_val->name, init_val->type, + ACPI_IMODE_LOAD_PASS2, + ACPI_NS_NO_UPSEARCH, NULL, &new_node); - if (ACPI_FAILURE (status) || (!new_node)) /* Must be on same line for code converter */ { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not create predefined name %s, %s\n", - init_val->name, acpi_format_exception (status))); + if (ACPI_FAILURE(status) || (!new_node)) { /* Must be on same line for code converter */ + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not create predefined name %s, %s\n", + init_val->name, + acpi_format_exception(status))); } /* @@ -128,11 +122,11 @@ acpi_ns_root_initialize ( * initial value, create the initial value. */ if (init_val->val) { - status = acpi_os_predefined_override (init_val, &val); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not override predefined %s\n", - init_val->name)); + status = acpi_os_predefined_override(init_val, &val); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not override predefined %s\n", + init_val->name)); } if (!val) { @@ -143,7 +137,8 @@ acpi_ns_root_initialize ( * Entry requests an initial value, allocate a * descriptor for it. */ - obj_desc = acpi_ut_create_internal_object (init_val->type); + obj_desc = + acpi_ut_create_internal_object(init_val->type); if (!obj_desc) { status = AE_NO_MEMORY; goto unlock_and_exit; @@ -156,7 +151,8 @@ acpi_ns_root_initialize ( */ switch (init_val->type) { case ACPI_TYPE_METHOD: - obj_desc->method.param_count = (u8) ACPI_TO_INTEGER (val); + obj_desc->method.param_count = + (u8) ACPI_TO_INTEGER(val); obj_desc->common.flags |= AOPOBJ_DATA_VALID; #if defined (ACPI_ASL_COMPILER) @@ -167,45 +163,50 @@ acpi_ns_root_initialize ( #else /* Mark this as a very SPECIAL method */ - obj_desc->method.method_flags = AML_METHOD_INTERNAL_ONLY; + obj_desc->method.method_flags = + AML_METHOD_INTERNAL_ONLY; #ifndef ACPI_DUMP_APP - obj_desc->method.implementation = acpi_ut_osi_implementation; + obj_desc->method.implementation = + acpi_ut_osi_implementation; #endif #endif break; case ACPI_TYPE_INTEGER: - obj_desc->integer.value = ACPI_TO_INTEGER (val); + obj_desc->integer.value = ACPI_TO_INTEGER(val); break; - case ACPI_TYPE_STRING: /* * Build an object around the static string */ - obj_desc->string.length = (u32) ACPI_STRLEN (val); + obj_desc->string.length = + (u32) ACPI_STRLEN(val); obj_desc->string.pointer = val; obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; break; - case ACPI_TYPE_MUTEX: obj_desc->mutex.node = new_node; - obj_desc->mutex.sync_level = (u8) (ACPI_TO_INTEGER (val) - 1); + obj_desc->mutex.sync_level = + (u8) (ACPI_TO_INTEGER(val) - 1); - if (ACPI_STRCMP (init_val->name, "_GL_") == 0) { + if (ACPI_STRCMP(init_val->name, "_GL_") == 0) { /* * Create a counting semaphore for the * global lock */ - status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, - 1, &obj_desc->mutex.semaphore); - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (obj_desc); + status = + acpi_os_create_semaphore + (ACPI_NO_UNIT_LIMIT, 1, + &obj_desc->mutex.semaphore); + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference + (obj_desc); goto unlock_and_exit; } @@ -213,56 +214,58 @@ acpi_ns_root_initialize ( * We just created the mutex for the * global lock, save it */ - acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore; - } - else { + acpi_gbl_global_lock_semaphore = + obj_desc->mutex.semaphore; + } else { /* Create a mutex */ - status = acpi_os_create_semaphore (1, 1, - &obj_desc->mutex.semaphore); - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (obj_desc); + status = acpi_os_create_semaphore(1, 1, + &obj_desc-> + mutex. + semaphore); + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference + (obj_desc); goto unlock_and_exit; } } break; - default: - ACPI_REPORT_ERROR (("Unsupported initial type value %X\n", - init_val->type)); - acpi_ut_remove_reference (obj_desc); + ACPI_REPORT_ERROR(("Unsupported initial type value %X\n", init_val->type)); + acpi_ut_remove_reference(obj_desc); obj_desc = NULL; continue; } /* Store pointer to value descriptor in the Node */ - status = acpi_ns_attach_object (new_node, obj_desc, - ACPI_GET_OBJECT_TYPE (obj_desc)); + status = acpi_ns_attach_object(new_node, obj_desc, + ACPI_GET_OBJECT_TYPE + (obj_desc)); /* Remove local reference to the object */ - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); } } - -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); /* Save a handle to "_GPE", it is always present */ - if (ACPI_SUCCESS (status)) { - status = acpi_ns_get_node_by_path ("\\_GPE", NULL, ACPI_NS_NO_UPSEARCH, - &acpi_gbl_fadt_gpe_device); + if (ACPI_SUCCESS(status)) { + status = + acpi_ns_get_node_by_path("\\_GPE", NULL, + ACPI_NS_NO_UPSEARCH, + &acpi_gbl_fadt_gpe_device); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ns_lookup @@ -287,62 +290,57 @@ unlock_and_exit: ******************************************************************************/ acpi_status -acpi_ns_lookup ( - union acpi_generic_state *scope_info, - char *pathname, - acpi_object_type type, - acpi_interpreter_mode interpreter_mode, - u32 flags, - struct acpi_walk_state *walk_state, - struct acpi_namespace_node **return_node) +acpi_ns_lookup(union acpi_generic_state *scope_info, + char *pathname, + acpi_object_type type, + acpi_interpreter_mode interpreter_mode, + u32 flags, + struct acpi_walk_state *walk_state, + struct acpi_namespace_node **return_node) { - acpi_status status; - char *path = pathname; - struct acpi_namespace_node *prefix_node; - struct acpi_namespace_node *current_node = NULL; - struct acpi_namespace_node *this_node = NULL; - u32 num_segments; - u32 num_carats; - acpi_name simple_name; - acpi_object_type type_to_check_for; - acpi_object_type this_search_type; - u32 search_parent_flag = ACPI_NS_SEARCH_PARENT; - u32 local_flags = flags & ~(ACPI_NS_ERROR_IF_FOUND | - ACPI_NS_SEARCH_PARENT); - - - ACPI_FUNCTION_TRACE ("ns_lookup"); - + acpi_status status; + char *path = pathname; + struct acpi_namespace_node *prefix_node; + struct acpi_namespace_node *current_node = NULL; + struct acpi_namespace_node *this_node = NULL; + u32 num_segments; + u32 num_carats; + acpi_name simple_name; + acpi_object_type type_to_check_for; + acpi_object_type this_search_type; + u32 search_parent_flag = ACPI_NS_SEARCH_PARENT; + u32 local_flags = flags & ~(ACPI_NS_ERROR_IF_FOUND | + ACPI_NS_SEARCH_PARENT); + + ACPI_FUNCTION_TRACE("ns_lookup"); if (!return_node) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } acpi_gbl_ns_lookup_count++; *return_node = ACPI_ENTRY_NOT_FOUND; if (!acpi_gbl_root_node) { - return_ACPI_STATUS (AE_NO_NAMESPACE); + return_ACPI_STATUS(AE_NO_NAMESPACE); } /* * Get the prefix scope. * A null scope means use the root scope */ - if ((!scope_info) || - (!scope_info->scope.node)) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Null scope prefix, using root node (%p)\n", - acpi_gbl_root_node)); + if ((!scope_info) || (!scope_info->scope.node)) { + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Null scope prefix, using root node (%p)\n", + acpi_gbl_root_node)); prefix_node = acpi_gbl_root_node; - } - else { + } else { prefix_node = scope_info->scope.node; - if (ACPI_GET_DESCRIPTOR_TYPE (prefix_node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR (("ns_lookup: %p is not a namespace node [%s]\n", - prefix_node, acpi_ut_get_descriptor_name (prefix_node))); - return_ACPI_STATUS (AE_AML_INTERNAL); + if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) != + ACPI_DESC_TYPE_NAMED) { + ACPI_REPORT_ERROR(("ns_lookup: %p is not a namespace node [%s]\n", prefix_node, acpi_ut_get_descriptor_name(prefix_node))); + return_ACPI_STATUS(AE_AML_INTERNAL); } /* @@ -350,9 +348,9 @@ acpi_ns_lookup ( * Device/Method, etc.) It could be a Package or other object node. * Backup up the tree to find the containing scope node. */ - while (!acpi_ns_opens_scope (prefix_node->type) && - prefix_node->type != ACPI_TYPE_ANY) { - prefix_node = acpi_ns_get_parent_node (prefix_node); + while (!acpi_ns_opens_scope(prefix_node->type) && + prefix_node->type != ACPI_TYPE_ANY) { + prefix_node = acpi_ns_get_parent_node(prefix_node); } } @@ -367,13 +365,13 @@ acpi_ns_lookup ( /* A Null name_path is allowed and refers to the root */ num_segments = 0; - this_node = acpi_gbl_root_node; - path = ""; + this_node = acpi_gbl_root_node; + path = ""; - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Null Pathname (Zero segments), Flags=%X\n", flags)); - } - else { + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Null Pathname (Zero segments), Flags=%X\n", + flags)); + } else { /* * Name pointer is valid (and must be in internal name format) * @@ -397,15 +395,16 @@ acpi_ns_lookup ( path++; - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Path is absolute from root [%p]\n", this_node)); - } - else { + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Path is absolute from root [%p]\n", + this_node)); + } else { /* Pathname is relative to current scope, start there */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Searching relative to prefix scope [%4.4s] (%p)\n", - acpi_ut_get_node_name (prefix_node), prefix_node)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Searching relative to prefix scope [%4.4s] (%p)\n", + acpi_ut_get_node_name(prefix_node), + prefix_node)); /* * Handle multiple Parent Prefixes (carat) by just getting @@ -426,20 +425,20 @@ acpi_ns_lookup ( /* Backup to the parent node */ num_carats++; - this_node = acpi_ns_get_parent_node (this_node); + this_node = acpi_ns_get_parent_node(this_node); if (!this_node) { /* Current scope has no parent scope */ - ACPI_REPORT_ERROR ( - ("ACPI path has too many parent prefixes (^) - reached beyond root node\n")); - return_ACPI_STATUS (AE_NOT_FOUND); + ACPI_REPORT_ERROR(("ACPI path has too many parent prefixes (^) - reached beyond root node\n")); + return_ACPI_STATUS(AE_NOT_FOUND); } } if (search_parent_flag == ACPI_NS_NO_UPSEARCH) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Search scope is [%4.4s], path has %d carat(s)\n", - acpi_ut_get_node_name (this_node), num_carats)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Search scope is [%4.4s], path has %d carat(s)\n", + acpi_ut_get_node_name + (this_node), num_carats)); } } @@ -465,9 +464,9 @@ acpi_ns_lookup ( num_segments = 0; type = this_node->type; - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Prefix-only Pathname (Zero name segments), Flags=%X\n", - flags)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Prefix-only Pathname (Zero name segments), Flags=%X\n", + flags)); break; case AML_DUAL_NAME_PREFIX: @@ -481,8 +480,9 @@ acpi_ns_lookup ( num_segments = 2; path++; - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Dual Pathname (2 segments, Flags=%X)\n", flags)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Dual Pathname (2 segments, Flags=%X)\n", + flags)); break; case AML_MULTI_NAME_PREFIX_OP: @@ -494,12 +494,12 @@ acpi_ns_lookup ( /* Extract segment count, point to first name segment */ path++; - num_segments = (u32) (u8) *path; + num_segments = (u32) (u8) * path; path++; - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Multi Pathname (%d Segments, Flags=%X) \n", - num_segments, flags)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Multi Pathname (%d Segments, Flags=%X) \n", + num_segments, flags)); break; default: @@ -509,15 +509,15 @@ acpi_ns_lookup ( */ num_segments = 1; - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Simple Pathname (1 segment, Flags=%X)\n", flags)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Simple Pathname (1 segment, Flags=%X)\n", + flags)); break; } - ACPI_DEBUG_EXEC (acpi_ns_print_pathname (num_segments, path)); + ACPI_DEBUG_EXEC(acpi_ns_print_pathname(num_segments, path)); } - /* * Search namespace for each segment of the name. Loop through and * verify (or add to the namespace) each name segment. @@ -541,7 +541,7 @@ acpi_ns_lookup ( * requested it AND we have a single, non-fully-qualified name_seg */ if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) && - (flags & ACPI_NS_SEARCH_PARENT)) { + (flags & ACPI_NS_SEARCH_PARENT)) { local_flags |= ACPI_NS_SEARCH_PARENT; } @@ -554,24 +554,28 @@ acpi_ns_lookup ( /* Extract one ACPI name from the front of the pathname */ - ACPI_MOVE_32_TO_32 (&simple_name, path); + ACPI_MOVE_32_TO_32(&simple_name, path); /* Try to find the single (4 character) ACPI name */ - status = acpi_ns_search_and_enter (simple_name, walk_state, current_node, - interpreter_mode, this_search_type, local_flags, &this_node); - if (ACPI_FAILURE (status)) { + status = + acpi_ns_search_and_enter(simple_name, walk_state, + current_node, interpreter_mode, + this_search_type, local_flags, + &this_node); + if (ACPI_FAILURE(status)) { if (status == AE_NOT_FOUND) { /* Name not found in ACPI namespace */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Name [%4.4s] not found in scope [%4.4s] %p\n", - (char *) &simple_name, (char *) ¤t_node->name, - current_node)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Name [%4.4s] not found in scope [%4.4s] %p\n", + (char *)&simple_name, + (char *)¤t_node->name, + current_node)); } *return_node = this_node; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* @@ -587,19 +591,16 @@ acpi_ns_lookup ( * * Then we have a type mismatch. Just warn and ignore it. */ - if ((num_segments == 0) && - (type_to_check_for != ACPI_TYPE_ANY) && - (type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) && - (type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS) && - (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE) && - (this_node->type != ACPI_TYPE_ANY) && - (this_node->type != type_to_check_for)) { + if ((num_segments == 0) && + (type_to_check_for != ACPI_TYPE_ANY) && + (type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) && + (type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS) && + (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE) && + (this_node->type != ACPI_TYPE_ANY) && + (this_node->type != type_to_check_for)) { /* Complain about a type mismatch */ - ACPI_REPORT_WARNING ( - ("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n", - (char *) &simple_name, acpi_ut_get_type_name (this_node->type), - acpi_ut_get_type_name (type_to_check_for))); + ACPI_REPORT_WARNING(("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n", (char *)&simple_name, acpi_ut_get_type_name(this_node->type), acpi_ut_get_type_name(type_to_check_for))); } /* @@ -625,15 +626,16 @@ acpi_ns_lookup ( * If entry is a type which opens a scope, push the new scope on the * scope stack. */ - if (acpi_ns_opens_scope (type)) { - status = acpi_ds_scope_stack_push (this_node, type, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + if (acpi_ns_opens_scope(type)) { + status = + acpi_ds_scope_stack_push(this_node, type, + walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } } *return_node = this_node; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c index 21d560d..cc7a85f 100644 --- a/drivers/acpi/namespace/nsalloc.c +++ b/drivers/acpi/namespace/nsalloc.c @@ -41,20 +41,14 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsalloc") +ACPI_MODULE_NAME("nsalloc") /* Local prototypes */ - -static void -acpi_ns_remove_reference ( - struct acpi_namespace_node *node); - +static void acpi_ns_remove_reference(struct acpi_namespace_node *node); /******************************************************************************* * @@ -68,31 +62,26 @@ acpi_ns_remove_reference ( * ******************************************************************************/ -struct acpi_namespace_node * -acpi_ns_create_node ( - u32 name) +struct acpi_namespace_node *acpi_ns_create_node(u32 name) { - struct acpi_namespace_node *node; - + struct acpi_namespace_node *node; - ACPI_FUNCTION_TRACE ("ns_create_node"); + ACPI_FUNCTION_TRACE("ns_create_node"); - - node = ACPI_MEM_CALLOCATE (sizeof (struct acpi_namespace_node)); + node = ACPI_MEM_CALLOCATE(sizeof(struct acpi_namespace_node)); if (!node) { - return_PTR (NULL); + return_PTR(NULL); } - ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_allocated++); + ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++); - node->name.integer = name; + node->name.integer = name; node->reference_count = 1; - ACPI_SET_DESCRIPTOR_TYPE (node, ACPI_DESC_TYPE_NAMED); + ACPI_SET_DESCRIPTOR_TYPE(node, ACPI_DESC_TYPE_NAMED); - return_PTR (node); + return_PTR(node); } - /******************************************************************************* * * FUNCTION: acpi_ns_delete_node @@ -105,19 +94,15 @@ acpi_ns_create_node ( * ******************************************************************************/ -void -acpi_ns_delete_node ( - struct acpi_namespace_node *node) +void acpi_ns_delete_node(struct acpi_namespace_node *node) { - struct acpi_namespace_node *parent_node; - struct acpi_namespace_node *prev_node; - struct acpi_namespace_node *next_node; - - - ACPI_FUNCTION_TRACE_PTR ("ns_delete_node", node); + struct acpi_namespace_node *parent_node; + struct acpi_namespace_node *prev_node; + struct acpi_namespace_node *next_node; + ACPI_FUNCTION_TRACE_PTR("ns_delete_node", node); - parent_node = acpi_ns_get_parent_node (node); + parent_node = acpi_ns_get_parent_node(node); prev_node = NULL; next_node = parent_node->child; @@ -136,32 +121,29 @@ acpi_ns_delete_node ( if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { prev_node->flags |= ANOBJ_END_OF_PEER_LIST; } - } - else { + } else { /* Node is first child (has no previous peer) */ if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { /* No peers at all */ parent_node->child = NULL; - } - else { /* Link peer list to parent */ + } else { /* Link peer list to parent */ parent_node->child = next_node->peer; } } - ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_freed++); + ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++); /* * Detach an object if there is one then delete the node */ - acpi_ns_detach_object (node); - ACPI_MEM_FREE (node); + acpi_ns_detach_object(node); + ACPI_MEM_FREE(node); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ns_install_node @@ -182,19 +164,14 @@ acpi_ns_delete_node ( * ******************************************************************************/ -void -acpi_ns_install_node ( - struct acpi_walk_state *walk_state, - struct acpi_namespace_node *parent_node, /* Parent */ - struct acpi_namespace_node *node, /* New Child*/ - acpi_object_type type) +void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namespace_node *parent_node, /* Parent */ + struct acpi_namespace_node *node, /* New Child */ + acpi_object_type type) { - acpi_owner_id owner_id = 0; - struct acpi_namespace_node *child_node; - - - ACPI_FUNCTION_TRACE ("ns_install_node"); + acpi_owner_id owner_id = 0; + struct acpi_namespace_node *child_node; + ACPI_FUNCTION_TRACE("ns_install_node"); /* * Get the owner ID from the Walk state @@ -212,8 +189,7 @@ acpi_ns_install_node ( parent_node->child = node; node->flags |= ANOBJ_END_OF_PEER_LIST; node->peer = parent_node; - } - else { + } else { while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) { child_node = child_node->peer; } @@ -232,24 +208,25 @@ acpi_ns_install_node ( node->owner_id = owner_id; node->type = (u8) type; - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n", - acpi_ut_get_node_name (node), acpi_ut_get_type_name (node->type), node, owner_id, - acpi_ut_get_node_name (parent_node), acpi_ut_get_type_name (parent_node->type), - parent_node)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n", + acpi_ut_get_node_name(node), + acpi_ut_get_type_name(node->type), node, owner_id, + acpi_ut_get_node_name(parent_node), + acpi_ut_get_type_name(parent_node->type), + parent_node)); /* * Increment the reference count(s) of all parents up to * the root! */ - while ((node = acpi_ns_get_parent_node (node)) != NULL) { + while ((node = acpi_ns_get_parent_node(node)) != NULL) { node->reference_count++; } return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ns_delete_children @@ -263,18 +240,14 @@ acpi_ns_install_node ( * ******************************************************************************/ -void -acpi_ns_delete_children ( - struct acpi_namespace_node *parent_node) +void acpi_ns_delete_children(struct acpi_namespace_node *parent_node) { - struct acpi_namespace_node *child_node; - struct acpi_namespace_node *next_node; - struct acpi_namespace_node *node; - u8 flags; - - - ACPI_FUNCTION_TRACE_PTR ("ns_delete_children", parent_node); + struct acpi_namespace_node *child_node; + struct acpi_namespace_node *next_node; + struct acpi_namespace_node *node; + u8 flags; + ACPI_FUNCTION_TRACE_PTR("ns_delete_children", parent_node); if (!parent_node) { return_VOID; @@ -293,48 +266,48 @@ acpi_ns_delete_children ( do { /* Get the things we need */ - next_node = child_node->peer; - flags = child_node->flags; + next_node = child_node->peer; + flags = child_node->flags; /* Grandchildren should have all been deleted already */ if (child_node->child) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Found a grandchild! P=%p C=%p\n", - parent_node, child_node)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Found a grandchild! P=%p C=%p\n", + parent_node, child_node)); } /* Now we can free this child object */ - ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_freed++); + ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++); - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", - child_node, acpi_gbl_current_node_count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Object %p, Remaining %X\n", child_node, + acpi_gbl_current_node_count)); /* * Detach an object if there is one, then free the child node */ - acpi_ns_detach_object (child_node); + acpi_ns_detach_object(child_node); /* * Decrement the reference count(s) of all parents up to * the root! (counts were incremented when the node was created) */ node = child_node; - while ((node = acpi_ns_get_parent_node (node)) != NULL) { + while ((node = acpi_ns_get_parent_node(node)) != NULL) { node->reference_count--; } /* There should be only one reference remaining on this node */ if (child_node->reference_count != 1) { - ACPI_REPORT_WARNING (( - "Existing references (%d) on node being deleted (%p)\n", - child_node->reference_count, child_node)); + ACPI_REPORT_WARNING(("Existing references (%d) on node being deleted (%p)\n", child_node->reference_count, child_node)); } /* Now we can delete the node */ - ACPI_MEM_FREE (child_node); + ACPI_MEM_FREE(child_node); /* And move on to the next child in the list */ @@ -342,7 +315,6 @@ acpi_ns_delete_children ( } while (!(flags & ANOBJ_END_OF_PEER_LIST)); - /* Clear the parent's child pointer */ parent_node->child = NULL; @@ -350,7 +322,6 @@ acpi_ns_delete_children ( return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ns_delete_namespace_subtree @@ -364,16 +335,12 @@ acpi_ns_delete_children ( * ******************************************************************************/ -void -acpi_ns_delete_namespace_subtree ( - struct acpi_namespace_node *parent_node) +void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node) { - struct acpi_namespace_node *child_node = NULL; - u32 level = 1; - - - ACPI_FUNCTION_TRACE ("ns_delete_namespace_subtree"); + struct acpi_namespace_node *child_node = NULL; + u32 level = 1; + ACPI_FUNCTION_TRACE("ns_delete_namespace_subtree"); if (!parent_node) { return_VOID; @@ -386,16 +353,17 @@ acpi_ns_delete_namespace_subtree ( while (level > 0) { /* Get the next node in this scope (NULL if none) */ - child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node, - child_node); + child_node = acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node, + child_node); if (child_node) { /* Found a child node - detach any attached object */ - acpi_ns_detach_object (child_node); + acpi_ns_detach_object(child_node); /* Check if this node has any children */ - if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) { + if (acpi_ns_get_next_node + (ACPI_TYPE_ANY, child_node, NULL)) { /* * There is at least one child of this node, * visit the node @@ -404,8 +372,7 @@ acpi_ns_delete_namespace_subtree ( parent_node = child_node; child_node = NULL; } - } - else { + } else { /* * No more children of this parent node. * Move up to the grandparent. @@ -416,7 +383,7 @@ acpi_ns_delete_namespace_subtree ( * Now delete all of the children of this parent * all at the same time. */ - acpi_ns_delete_children (parent_node); + acpi_ns_delete_children(parent_node); /* New "last child" is this parent node */ @@ -424,14 +391,13 @@ acpi_ns_delete_namespace_subtree ( /* Move up the tree to the grandparent */ - parent_node = acpi_ns_get_parent_node (parent_node); + parent_node = acpi_ns_get_parent_node(parent_node); } } return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ns_remove_reference @@ -447,16 +413,12 @@ acpi_ns_delete_namespace_subtree ( * ******************************************************************************/ -static void -acpi_ns_remove_reference ( - struct acpi_namespace_node *node) +static void acpi_ns_remove_reference(struct acpi_namespace_node *node) { - struct acpi_namespace_node *parent_node; - struct acpi_namespace_node *this_node; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_namespace_node *parent_node; + struct acpi_namespace_node *this_node; + ACPI_FUNCTION_ENTRY(); /* * Decrement the reference count(s) of this node and all @@ -466,7 +428,7 @@ acpi_ns_remove_reference ( while (this_node) { /* Prepare to move up to parent */ - parent_node = acpi_ns_get_parent_node (this_node); + parent_node = acpi_ns_get_parent_node(this_node); /* Decrement the reference count on this node */ @@ -477,15 +439,14 @@ acpi_ns_remove_reference ( if (!this_node->reference_count) { /* Delete all children and delete the node */ - acpi_ns_delete_children (this_node); - acpi_ns_delete_node (this_node); + acpi_ns_delete_children(this_node); + acpi_ns_delete_node(this_node); } this_node = parent_node; } } - /******************************************************************************* * * FUNCTION: acpi_ns_delete_namespace_by_owner @@ -500,27 +461,23 @@ acpi_ns_remove_reference ( * ******************************************************************************/ -void -acpi_ns_delete_namespace_by_owner ( - acpi_owner_id owner_id) +void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id) { - struct acpi_namespace_node *child_node; - struct acpi_namespace_node *deletion_node; - u32 level; - struct acpi_namespace_node *parent_node; - - - ACPI_FUNCTION_TRACE_U32 ("ns_delete_namespace_by_owner", owner_id); + struct acpi_namespace_node *child_node; + struct acpi_namespace_node *deletion_node; + u32 level; + struct acpi_namespace_node *parent_node; + ACPI_FUNCTION_TRACE_U32("ns_delete_namespace_by_owner", owner_id); if (owner_id == 0) { return_VOID; } - parent_node = acpi_gbl_root_node; - child_node = NULL; + parent_node = acpi_gbl_root_node; + child_node = NULL; deletion_node = NULL; - level = 1; + level = 1; /* * Traverse the tree of nodes until we bubble back up @@ -531,10 +488,12 @@ acpi_ns_delete_namespace_by_owner ( * Get the next child of this parent node. When child_node is NULL, * the first child of the parent is returned */ - child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node, child_node); + child_node = + acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node, + child_node); if (deletion_node) { - acpi_ns_remove_reference (deletion_node); + acpi_ns_remove_reference(deletion_node); deletion_node = NULL; } @@ -542,12 +501,13 @@ acpi_ns_delete_namespace_by_owner ( if (child_node->owner_id == owner_id) { /* Found a matching child node - detach any attached object */ - acpi_ns_detach_object (child_node); + acpi_ns_detach_object(child_node); } /* Check if this node has any children */ - if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) { + if (acpi_ns_get_next_node + (ACPI_TYPE_ANY, child_node, NULL)) { /* * There is at least one child of this node, * visit the node @@ -555,12 +515,10 @@ acpi_ns_delete_namespace_by_owner ( level++; parent_node = child_node; child_node = NULL; - } - else if (child_node->owner_id == owner_id) { + } else if (child_node->owner_id == owner_id) { deletion_node = child_node; } - } - else { + } else { /* * No more children of this parent node. * Move up to the grandparent. @@ -578,11 +536,9 @@ acpi_ns_delete_namespace_by_owner ( /* Move up the tree to the grandparent */ - parent_node = acpi_ns_get_parent_node (parent_node); + parent_node = acpi_ns_get_parent_node(parent_node); } } return_VOID; } - - diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c index 5d25add..9faf1d5 100644 --- a/drivers/acpi/namespace/nsdump.c +++ b/drivers/acpi/namespace/nsdump.c @@ -41,31 +41,22 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsdump") +ACPI_MODULE_NAME("nsdump") /* Local prototypes */ - #ifdef ACPI_OBSOLETE_FUNCTIONS -void -acpi_ns_dump_root_devices ( - void); +void acpi_ns_dump_root_devices(void); static acpi_status -acpi_ns_dump_one_device ( - acpi_handle obj_handle, - u32 level, - void *context, - void **return_value); +acpi_ns_dump_one_device(acpi_handle obj_handle, + u32 level, void *context, void **return_value); #endif - #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /******************************************************************************* * @@ -80,43 +71,38 @@ acpi_ns_dump_one_device ( * ******************************************************************************/ -void -acpi_ns_print_pathname ( - u32 num_segments, - char *pathname) +void acpi_ns_print_pathname(u32 num_segments, char *pathname) { - acpi_native_uint i; + acpi_native_uint i; + ACPI_FUNCTION_NAME("ns_print_pathname"); - ACPI_FUNCTION_NAME ("ns_print_pathname"); - - - if (!(acpi_dbg_level & ACPI_LV_NAMES) || !(acpi_dbg_layer & ACPI_NAMESPACE)) { + if (!(acpi_dbg_level & ACPI_LV_NAMES) + || !(acpi_dbg_layer & ACPI_NAMESPACE)) { return; } /* Print the entire name */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[")); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "[")); while (num_segments) { for (i = 0; i < 4; i++) { - ACPI_IS_PRINT (pathname[i]) ? - acpi_os_printf ("%c", pathname[i]) : - acpi_os_printf ("?"); + ACPI_IS_PRINT(pathname[i]) ? + acpi_os_printf("%c", pathname[i]) : + acpi_os_printf("?"); } pathname += ACPI_NAME_SIZE; num_segments--; if (num_segments) { - acpi_os_printf ("."); + acpi_os_printf("."); } } - acpi_os_printf ("]\n"); + acpi_os_printf("]\n"); } - /******************************************************************************* * * FUNCTION: acpi_ns_dump_pathname @@ -134,15 +120,10 @@ acpi_ns_print_pathname ( ******************************************************************************/ void -acpi_ns_dump_pathname ( - acpi_handle handle, - char *msg, - u32 level, - u32 component) +acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component) { - ACPI_FUNCTION_TRACE ("ns_dump_pathname"); - + ACPI_FUNCTION_TRACE("ns_dump_pathname"); /* Do this only if the requested debug level and component are enabled */ @@ -152,12 +133,11 @@ acpi_ns_dump_pathname ( /* Convert handle to a full pathname and print it (with supplied message) */ - acpi_ns_print_node_pathname (handle, msg); - acpi_os_printf ("\n"); + acpi_ns_print_node_pathname(handle, msg); + acpi_os_printf("\n"); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ns_dump_one_object @@ -175,24 +155,19 @@ acpi_ns_dump_pathname ( ******************************************************************************/ acpi_status -acpi_ns_dump_one_object ( - acpi_handle obj_handle, - u32 level, - void *context, - void **return_value) +acpi_ns_dump_one_object(acpi_handle obj_handle, + u32 level, void *context, void **return_value) { - struct acpi_walk_info *info = (struct acpi_walk_info *) context; - struct acpi_namespace_node *this_node; - union acpi_operand_object *obj_desc = NULL; - acpi_object_type obj_type; - acpi_object_type type; - u32 bytes_to_dump; - u32 dbg_level; - u32 i; - - - ACPI_FUNCTION_NAME ("ns_dump_one_object"); + struct acpi_walk_info *info = (struct acpi_walk_info *)context; + struct acpi_namespace_node *this_node; + union acpi_operand_object *obj_desc = NULL; + acpi_object_type obj_type; + acpi_object_type type; + u32 bytes_to_dump; + u32 dbg_level; + u32 i; + ACPI_FUNCTION_NAME("ns_dump_one_object"); /* Is output enabled? */ @@ -201,48 +176,47 @@ acpi_ns_dump_one_object ( } if (!obj_handle) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Null object handle\n")); return (AE_OK); } - this_node = acpi_ns_map_handle_to_node (obj_handle); + this_node = acpi_ns_map_handle_to_node(obj_handle); type = this_node->type; /* Check if the owner matches */ if ((info->owner_id != ACPI_OWNER_ID_MAX) && - (info->owner_id != this_node->owner_id)) { + (info->owner_id != this_node->owner_id)) { return (AE_OK); } if (!(info->display_type & ACPI_DISPLAY_SHORT)) { /* Indent the object according to the level */ - acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " "); + acpi_os_printf("%2d%*s", (u32) level - 1, (int)level * 2, " "); /* Check the node type and name */ if (type > ACPI_TYPE_LOCAL_MAX) { - ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type)); + ACPI_REPORT_WARNING(("Invalid ACPI Type %08X\n", type)); } - if (!acpi_ut_valid_acpi_name (this_node->name.integer)) { - ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", - this_node->name.integer)); + if (!acpi_ut_valid_acpi_name(this_node->name.integer)) { + ACPI_REPORT_WARNING(("Invalid ACPI Name %08X\n", + this_node->name.integer)); } - acpi_os_printf ("%4.4s", acpi_ut_get_node_name (this_node)); + acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node)); } /* * Now we can print out the pertinent information */ - acpi_os_printf (" %-12s %p ", - acpi_ut_get_type_name (type), this_node); + acpi_os_printf(" %-12s %p ", acpi_ut_get_type_name(type), this_node); dbg_level = acpi_dbg_level; acpi_dbg_level = 0; - obj_desc = acpi_ns_get_attached_object (this_node); + obj_desc = acpi_ns_get_attached_object(this_node); acpi_dbg_level = dbg_level; switch (info->display_type & ACPI_DISPLAY_MASK) { @@ -251,147 +225,166 @@ acpi_ns_dump_one_object ( if (!obj_desc) { /* No attached object, we are done */ - acpi_os_printf ("\n"); + acpi_os_printf("\n"); return (AE_OK); } switch (type) { case ACPI_TYPE_PROCESSOR: - acpi_os_printf ("ID %X Len %.4X Addr %p\n", - obj_desc->processor.proc_id, obj_desc->processor.length, - (char *) obj_desc->processor.address); + acpi_os_printf("ID %X Len %.4X Addr %p\n", + obj_desc->processor.proc_id, + obj_desc->processor.length, + (char *)obj_desc->processor.address); break; - case ACPI_TYPE_DEVICE: - acpi_os_printf ("Notify Object: %p\n", obj_desc); + acpi_os_printf("Notify Object: %p\n", obj_desc); break; - case ACPI_TYPE_METHOD: - acpi_os_printf ("Args %X Len %.4X Aml %p\n", - (u32) obj_desc->method.param_count, - obj_desc->method.aml_length, obj_desc->method.aml_start); + acpi_os_printf("Args %X Len %.4X Aml %p\n", + (u32) obj_desc->method.param_count, + obj_desc->method.aml_length, + obj_desc->method.aml_start); break; - case ACPI_TYPE_INTEGER: - acpi_os_printf ("= %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (obj_desc->integer.value)); + acpi_os_printf("= %8.8X%8.8X\n", + ACPI_FORMAT_UINT64(obj_desc->integer. + value)); break; - case ACPI_TYPE_PACKAGE: if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { - acpi_os_printf ("Elements %.2X\n", - obj_desc->package.count); - } - else { - acpi_os_printf ("[Length not yet evaluated]\n"); + acpi_os_printf("Elements %.2X\n", + obj_desc->package.count); + } else { + acpi_os_printf("[Length not yet evaluated]\n"); } break; - case ACPI_TYPE_BUFFER: if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { - acpi_os_printf ("Len %.2X", - obj_desc->buffer.length); + acpi_os_printf("Len %.2X", + obj_desc->buffer.length); /* Dump some of the buffer */ if (obj_desc->buffer.length > 0) { - acpi_os_printf (" ="); - for (i = 0; (i < obj_desc->buffer.length && i < 12); i++) { - acpi_os_printf (" %.2hX", obj_desc->buffer.pointer[i]); + acpi_os_printf(" ="); + for (i = 0; + (i < obj_desc->buffer.length + && i < 12); i++) { + acpi_os_printf(" %.2hX", + obj_desc->buffer. + pointer[i]); } } - acpi_os_printf ("\n"); - } - else { - acpi_os_printf ("[Length not yet evaluated]\n"); + acpi_os_printf("\n"); + } else { + acpi_os_printf("[Length not yet evaluated]\n"); } break; - case ACPI_TYPE_STRING: - acpi_os_printf ("Len %.2X ", obj_desc->string.length); - acpi_ut_print_string (obj_desc->string.pointer, 32); - acpi_os_printf ("\n"); + acpi_os_printf("Len %.2X ", obj_desc->string.length); + acpi_ut_print_string(obj_desc->string.pointer, 32); + acpi_os_printf("\n"); break; - case ACPI_TYPE_REGION: - acpi_os_printf ("[%s]", - acpi_ut_get_region_name (obj_desc->region.space_id)); + acpi_os_printf("[%s]", + acpi_ut_get_region_name(obj_desc->region. + space_id)); if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { - acpi_os_printf (" Addr %8.8X%8.8X Len %.4X\n", - ACPI_FORMAT_UINT64 (obj_desc->region.address), - obj_desc->region.length); - } - else { - acpi_os_printf (" [Address/Length not yet evaluated]\n"); + acpi_os_printf(" Addr %8.8X%8.8X Len %.4X\n", + ACPI_FORMAT_UINT64(obj_desc-> + region. + address), + obj_desc->region.length); + } else { + acpi_os_printf + (" [Address/Length not yet evaluated]\n"); } break; - case ACPI_TYPE_LOCAL_REFERENCE: - acpi_os_printf ("[%s]\n", - acpi_ps_get_opcode_name (obj_desc->reference.opcode)); + acpi_os_printf("[%s]\n", + acpi_ps_get_opcode_name(obj_desc-> + reference. + opcode)); break; - case ACPI_TYPE_BUFFER_FIELD: if (obj_desc->buffer_field.buffer_obj && - obj_desc->buffer_field.buffer_obj->buffer.node) { - acpi_os_printf ("Buf [%4.4s]", - acpi_ut_get_node_name (obj_desc->buffer_field.buffer_obj->buffer.node)); + obj_desc->buffer_field.buffer_obj->buffer.node) { + acpi_os_printf("Buf [%4.4s]", + acpi_ut_get_node_name(obj_desc-> + buffer_field. + buffer_obj-> + buffer. + node)); } break; - case ACPI_TYPE_LOCAL_REGION_FIELD: - acpi_os_printf ("Rgn [%4.4s]", - acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node)); + acpi_os_printf("Rgn [%4.4s]", + acpi_ut_get_node_name(obj_desc-> + common_field. + region_obj->region. + node)); break; - case ACPI_TYPE_LOCAL_BANK_FIELD: - acpi_os_printf ("Rgn [%4.4s] Bnk [%4.4s]", - acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node), - acpi_ut_get_node_name (obj_desc->bank_field.bank_obj->common_field.node)); + acpi_os_printf("Rgn [%4.4s] Bnk [%4.4s]", + acpi_ut_get_node_name(obj_desc-> + common_field. + region_obj->region. + node), + acpi_ut_get_node_name(obj_desc-> + bank_field. + bank_obj-> + common_field. + node)); break; - case ACPI_TYPE_LOCAL_INDEX_FIELD: - acpi_os_printf ("Idx [%4.4s] Dat [%4.4s]", - acpi_ut_get_node_name (obj_desc->index_field.index_obj->common_field.node), - acpi_ut_get_node_name (obj_desc->index_field.data_obj->common_field.node)); + acpi_os_printf("Idx [%4.4s] Dat [%4.4s]", + acpi_ut_get_node_name(obj_desc-> + index_field. + index_obj-> + common_field.node), + acpi_ut_get_node_name(obj_desc-> + index_field. + data_obj-> + common_field. + node)); break; - case ACPI_TYPE_LOCAL_ALIAS: case ACPI_TYPE_LOCAL_METHOD_ALIAS: - acpi_os_printf ("Target %4.4s (%p)\n", - acpi_ut_get_node_name (obj_desc), obj_desc); + acpi_os_printf("Target %4.4s (%p)\n", + acpi_ut_get_node_name(obj_desc), + obj_desc); break; default: - acpi_os_printf ("Object %p\n", obj_desc); + acpi_os_printf("Object %p\n", obj_desc); break; } @@ -403,11 +396,15 @@ acpi_ns_dump_one_object ( case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - acpi_os_printf (" Off %.3X Len %.2X Acc %.2hd\n", - (obj_desc->common_field.base_byte_offset * 8) - + obj_desc->common_field.start_field_bit_offset, - obj_desc->common_field.bit_length, - obj_desc->common_field.access_byte_width); + acpi_os_printf(" Off %.3X Len %.2X Acc %.2hd\n", + (obj_desc->common_field. + base_byte_offset * 8) + + + obj_desc->common_field. + start_field_bit_offset, + obj_desc->common_field.bit_length, + obj_desc->common_field. + access_byte_width); break; default: @@ -415,56 +412,55 @@ acpi_ns_dump_one_object ( } break; - case ACPI_DISPLAY_OBJECTS: - acpi_os_printf ("O:%p", obj_desc); + acpi_os_printf("O:%p", obj_desc); if (!obj_desc) { /* No attached object, we are done */ - acpi_os_printf ("\n"); + acpi_os_printf("\n"); return (AE_OK); } - acpi_os_printf ("(R%d)", obj_desc->common.reference_count); + acpi_os_printf("(R%d)", obj_desc->common.reference_count); switch (type) { case ACPI_TYPE_METHOD: /* Name is a Method and its AML offset/length are set */ - acpi_os_printf (" M:%p-%X\n", obj_desc->method.aml_start, - obj_desc->method.aml_length); + acpi_os_printf(" M:%p-%X\n", obj_desc->method.aml_start, + obj_desc->method.aml_length); break; case ACPI_TYPE_INTEGER: - acpi_os_printf (" I:%8.8X8.8%X\n", - ACPI_FORMAT_UINT64 (obj_desc->integer.value)); + acpi_os_printf(" I:%8.8X8.8%X\n", + ACPI_FORMAT_UINT64(obj_desc->integer. + value)); break; case ACPI_TYPE_STRING: - acpi_os_printf (" S:%p-%X\n", obj_desc->string.pointer, - obj_desc->string.length); + acpi_os_printf(" S:%p-%X\n", obj_desc->string.pointer, + obj_desc->string.length); break; case ACPI_TYPE_BUFFER: - acpi_os_printf (" B:%p-%X\n", obj_desc->buffer.pointer, - obj_desc->buffer.length); + acpi_os_printf(" B:%p-%X\n", obj_desc->buffer.pointer, + obj_desc->buffer.length); break; default: - acpi_os_printf ("\n"); + acpi_os_printf("\n"); break; } break; - default: - acpi_os_printf ("\n"); + acpi_os_printf("\n"); break; } @@ -474,46 +470,47 @@ acpi_ns_dump_one_object ( return (AE_OK); } - /* If there is an attached object, display it */ - dbg_level = acpi_dbg_level; + dbg_level = acpi_dbg_level; acpi_dbg_level = 0; - obj_desc = acpi_ns_get_attached_object (this_node); + obj_desc = acpi_ns_get_attached_object(this_node); acpi_dbg_level = dbg_level; /* Dump attached objects */ while (obj_desc) { obj_type = ACPI_TYPE_INVALID; - acpi_os_printf ("Attached Object %p: ", obj_desc); + acpi_os_printf("Attached Object %p: ", obj_desc); /* Decode the type of attached object and dump the contents */ - switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { + switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) { case ACPI_DESC_TYPE_NAMED: - acpi_os_printf ("(Ptr to Node)\n"); - bytes_to_dump = sizeof (struct acpi_namespace_node); - ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); + acpi_os_printf("(Ptr to Node)\n"); + bytes_to_dump = sizeof(struct acpi_namespace_node); + ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump); break; case ACPI_DESC_TYPE_OPERAND: - obj_type = ACPI_GET_OBJECT_TYPE (obj_desc); + obj_type = ACPI_GET_OBJECT_TYPE(obj_desc); if (obj_type > ACPI_TYPE_LOCAL_MAX) { - acpi_os_printf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", - obj_type); + acpi_os_printf + ("(Ptr to ACPI Object type %X [UNKNOWN])\n", + obj_type); bytes_to_dump = 32; - } - else { - acpi_os_printf ("(Ptr to ACPI Object type %X [%s])\n", - obj_type, acpi_ut_get_type_name (obj_type)); - bytes_to_dump = sizeof (union acpi_operand_object); + } else { + acpi_os_printf + ("(Ptr to ACPI Object type %X [%s])\n", + obj_type, acpi_ut_get_type_name(obj_type)); + bytes_to_dump = + sizeof(union acpi_operand_object); } - ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); + ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump); break; default: @@ -523,7 +520,8 @@ acpi_ns_dump_one_object ( /* If value is NOT an internal object, we are done */ - if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { + if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != + ACPI_DESC_TYPE_OPERAND) { goto cleanup; } @@ -537,49 +535,50 @@ acpi_ns_dump_one_object ( * NOTE: takes advantage of common fields between string/buffer */ bytes_to_dump = obj_desc->string.length; - obj_desc = (void *) obj_desc->string.pointer; - acpi_os_printf ( "(Buffer/String pointer %p length %X)\n", - obj_desc, bytes_to_dump); - ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); + obj_desc = (void *)obj_desc->string.pointer; + acpi_os_printf("(Buffer/String pointer %p length %X)\n", + obj_desc, bytes_to_dump); + ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump); goto cleanup; case ACPI_TYPE_BUFFER_FIELD: - obj_desc = (union acpi_operand_object *) obj_desc->buffer_field.buffer_obj; + obj_desc = + (union acpi_operand_object *)obj_desc->buffer_field. + buffer_obj; break; case ACPI_TYPE_PACKAGE: - obj_desc = (void *) obj_desc->package.elements; + obj_desc = (void *)obj_desc->package.elements; break; case ACPI_TYPE_METHOD: - obj_desc = (void *) obj_desc->method.aml_start; + obj_desc = (void *)obj_desc->method.aml_start; break; case ACPI_TYPE_LOCAL_REGION_FIELD: - obj_desc = (void *) obj_desc->field.region_obj; + obj_desc = (void *)obj_desc->field.region_obj; break; case ACPI_TYPE_LOCAL_BANK_FIELD: - obj_desc = (void *) obj_desc->bank_field.region_obj; + obj_desc = (void *)obj_desc->bank_field.region_obj; break; case ACPI_TYPE_LOCAL_INDEX_FIELD: - obj_desc = (void *) obj_desc->index_field.index_obj; + obj_desc = (void *)obj_desc->index_field.index_obj; break; default: goto cleanup; } - obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */ + obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */ } -cleanup: - acpi_os_printf ("\n"); + cleanup: + acpi_os_printf("\n"); return (AE_OK); } - #ifdef ACPI_FUTURE_USAGE /******************************************************************************* * @@ -601,29 +600,25 @@ cleanup: ******************************************************************************/ void -acpi_ns_dump_objects ( - acpi_object_type type, - u8 display_type, - u32 max_depth, - acpi_owner_id owner_id, - acpi_handle start_handle) +acpi_ns_dump_objects(acpi_object_type type, + u8 display_type, + u32 max_depth, + acpi_owner_id owner_id, acpi_handle start_handle) { - struct acpi_walk_info info; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_walk_info info; + ACPI_FUNCTION_ENTRY(); info.debug_level = ACPI_LV_TABLES; info.owner_id = owner_id; info.display_type = display_type; - (void) acpi_ns_walk_namespace (type, start_handle, max_depth, - ACPI_NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object, - (void *) &info, NULL); + (void)acpi_ns_walk_namespace(type, start_handle, max_depth, + ACPI_NS_WALK_NO_UNLOCK, + acpi_ns_dump_one_object, (void *)&info, + NULL); } -#endif /* ACPI_FUTURE_USAGE */ - +#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * @@ -638,25 +633,19 @@ acpi_ns_dump_objects ( * ******************************************************************************/ -void -acpi_ns_dump_entry ( - acpi_handle handle, - u32 debug_level) +void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level) { - struct acpi_walk_info info; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_walk_info info; + ACPI_FUNCTION_ENTRY(); info.debug_level = debug_level; info.owner_id = ACPI_OWNER_ID_MAX; info.display_type = ACPI_DISPLAY_SUMMARY; - (void) acpi_ns_dump_one_object (handle, 1, &info, NULL); + (void)acpi_ns_dump_one_object(handle, 1, &info, NULL); } - #ifdef ACPI_ASL_COMPILER /******************************************************************************* * @@ -673,23 +662,19 @@ acpi_ns_dump_entry ( * ******************************************************************************/ -void -acpi_ns_dump_tables ( - acpi_handle search_base, - u32 max_depth) +void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth) { - acpi_handle search_handle = search_base; - - - ACPI_FUNCTION_TRACE ("ns_dump_tables"); + acpi_handle search_handle = search_base; + ACPI_FUNCTION_TRACE("ns_dump_tables"); if (!acpi_gbl_root_node) { /* * If the name space has not been initialized, * there is nothing to dump. */ - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n")); + ACPI_DEBUG_PRINT((ACPI_DB_TABLES, + "namespace not initialized!\n")); return_VOID; } @@ -697,12 +682,12 @@ acpi_ns_dump_tables ( /* Entire namespace */ search_handle = acpi_gbl_root_node; - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); + ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "\\\n")); } - acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth, - ACPI_OWNER_ID_MAX, search_handle); + acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth, + ACPI_OWNER_ID_MAX, search_handle); return_VOID; } -#endif /* _ACPI_ASL_COMPILER */ -#endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */ +#endif /* _ACPI_ASL_COMPILER */ +#endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */ diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/namespace/nsdumpdv.c index 27c4f7c..55de883 100644 --- a/drivers/acpi/namespace/nsdumpdv.c +++ b/drivers/acpi/namespace/nsdumpdv.c @@ -41,20 +41,15 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include - /* TBD: This entire module is apparently obsolete and should be removed */ #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsdumpdv") - +ACPI_MODULE_NAME("nsdumpdv") #ifdef ACPI_OBSOLETE_FUNCTIONS #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) - #include - /******************************************************************************* * * FUNCTION: acpi_ns_dump_one_device @@ -70,44 +65,39 @@ * This procedure is a user_function called by acpi_ns_walk_namespace. * ******************************************************************************/ - static acpi_status -acpi_ns_dump_one_device ( - acpi_handle obj_handle, - u32 level, - void *context, - void **return_value) +acpi_ns_dump_one_device(acpi_handle obj_handle, + u32 level, void *context, void **return_value) { - struct acpi_buffer buffer; - struct acpi_device_info *info; - acpi_status status; - u32 i; - + struct acpi_buffer buffer; + struct acpi_device_info *info; + acpi_status status; + u32 i; - ACPI_FUNCTION_NAME ("ns_dump_one_device"); + ACPI_FUNCTION_NAME("ns_dump_one_device"); - - status = acpi_ns_dump_one_object (obj_handle, level, context, return_value); + status = + acpi_ns_dump_one_object(obj_handle, level, context, return_value); buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; - status = acpi_get_object_info (obj_handle, &buffer); - if (ACPI_SUCCESS (status)) { + status = acpi_get_object_info(obj_handle, &buffer); + if (ACPI_SUCCESS(status)) { info = buffer.pointer; for (i = 0; i < level; i++) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " ")); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES, " ")); } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, - " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", - info->hardware_id.value, ACPI_FORMAT_UINT64 (info->address), - info->current_status)); - ACPI_MEM_FREE (info); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES, + " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", + info->hardware_id.value, + ACPI_FORMAT_UINT64(info->address), + info->current_status)); + ACPI_MEM_FREE(info); } return (status); } - /******************************************************************************* * * FUNCTION: acpi_ns_dump_root_devices @@ -120,16 +110,12 @@ acpi_ns_dump_one_device ( * ******************************************************************************/ -void -acpi_ns_dump_root_devices ( - void) +void acpi_ns_dump_root_devices(void) { - acpi_handle sys_bus_handle; - acpi_status status; - - - ACPI_FUNCTION_NAME ("ns_dump_root_devices"); + acpi_handle sys_bus_handle; + acpi_status status; + ACPI_FUNCTION_NAME("ns_dump_root_devices"); /* Only dump the table if tracing is enabled */ @@ -138,19 +124,17 @@ acpi_ns_dump_root_devices ( } status = acpi_get_handle(NULL, ACPI_NS_SYSTEM_BUS, &sys_bus_handle); - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { return; } - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, - "Display of all devices in the namespace:\n")); + ACPI_DEBUG_PRINT((ACPI_DB_TABLES, + "Display of all devices in the namespace:\n")); - status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, sys_bus_handle, - ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, - acpi_ns_dump_one_device, NULL, NULL); + status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, sys_bus_handle, + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, + acpi_ns_dump_one_device, NULL, NULL); } #endif #endif - - diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c index 908cffd..0191c7d 100644 --- a/drivers/acpi/namespace/nseval.c +++ b/drivers/acpi/namespace/nseval.c @@ -42,26 +42,19 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nseval") +ACPI_MODULE_NAME("nseval") /* Local prototypes */ - static acpi_status -acpi_ns_execute_control_method ( - struct acpi_parameter_info *info); - -static acpi_status -acpi_ns_get_object_value ( - struct acpi_parameter_info *info); +acpi_ns_execute_control_method(struct acpi_parameter_info *info); +static acpi_status acpi_ns_get_object_value(struct acpi_parameter_info *info); /******************************************************************************* * @@ -85,48 +78,44 @@ acpi_ns_get_object_value ( ******************************************************************************/ acpi_status -acpi_ns_evaluate_relative ( - char *pathname, - struct acpi_parameter_info *info) +acpi_ns_evaluate_relative(char *pathname, struct acpi_parameter_info *info) { - acpi_status status; - struct acpi_namespace_node *node = NULL; - union acpi_generic_state *scope_info; - char *internal_path = NULL; - - - ACPI_FUNCTION_TRACE ("ns_evaluate_relative"); + acpi_status status; + struct acpi_namespace_node *node = NULL; + union acpi_generic_state *scope_info; + char *internal_path = NULL; + ACPI_FUNCTION_TRACE("ns_evaluate_relative"); /* * Must have a valid object handle */ if (!info || !info->node) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Build an internal name string for the method */ - status = acpi_ns_internalize_name (pathname, &internal_path); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ns_internalize_name(pathname, &internal_path); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - scope_info = acpi_ut_create_generic_state (); + scope_info = acpi_ut_create_generic_state(); if (!scope_info) { goto cleanup1; } /* Get the prefix handle and Node */ - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { goto cleanup; } - info->node = acpi_ns_map_handle_to_node (info->node); + info->node = acpi_ns_map_handle_to_node(info->node); if (!info->node) { - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); status = AE_BAD_PARAMETER; goto cleanup; } @@ -134,39 +123,38 @@ acpi_ns_evaluate_relative ( /* Lookup the name in the namespace */ scope_info->scope.node = info->node; - status = acpi_ns_lookup (scope_info, internal_path, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, - &node); + status = acpi_ns_lookup(scope_info, internal_path, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, + &node); - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object [%s] not found [%s]\n", - pathname, acpi_format_exception (status))); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Object [%s] not found [%s]\n", + pathname, acpi_format_exception(status))); goto cleanup; } /* * Now that we have a handle to the object, we can attempt to evaluate it. */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", - pathname, node, acpi_ns_get_attached_object (node))); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n", + pathname, node, acpi_ns_get_attached_object(node))); info->node = node; - status = acpi_ns_evaluate_by_handle (info); + status = acpi_ns_evaluate_by_handle(info); - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", - pathname)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "*** Completed eval of object %s ***\n", pathname)); -cleanup: - acpi_ut_delete_generic_state (scope_info); + cleanup: + acpi_ut_delete_generic_state(scope_info); -cleanup1: - ACPI_MEM_FREE (internal_path); - return_ACPI_STATUS (status); + cleanup1: + ACPI_MEM_FREE(internal_path); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ns_evaluate_by_name @@ -189,68 +177,63 @@ cleanup1: ******************************************************************************/ acpi_status -acpi_ns_evaluate_by_name ( - char *pathname, - struct acpi_parameter_info *info) +acpi_ns_evaluate_by_name(char *pathname, struct acpi_parameter_info *info) { - acpi_status status; - char *internal_path = NULL; - - - ACPI_FUNCTION_TRACE ("ns_evaluate_by_name"); + acpi_status status; + char *internal_path = NULL; + ACPI_FUNCTION_TRACE("ns_evaluate_by_name"); /* Build an internal name string for the method */ - status = acpi_ns_internalize_name (pathname, &internal_path); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ns_internalize_name(pathname, &internal_path); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { goto cleanup; } /* Lookup the name in the namespace */ - status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, - &info->node); + status = acpi_ns_lookup(NULL, internal_path, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, + &info->node); - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Object at [%s] was not found, status=%.4X\n", - pathname, status)); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Object at [%s] was not found, status=%.4X\n", + pathname, status)); goto cleanup; } /* * Now that we have a handle to the object, we can attempt to evaluate it. */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", - pathname, info->node, acpi_ns_get_attached_object (info->node))); - - status = acpi_ns_evaluate_by_handle (info); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n", + pathname, info->node, + acpi_ns_get_attached_object(info->node))); - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", - pathname)); + status = acpi_ns_evaluate_by_handle(info); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "*** Completed eval of object %s ***\n", pathname)); -cleanup: + cleanup: /* Cleanup */ if (internal_path) { - ACPI_MEM_FREE (internal_path); + ACPI_MEM_FREE(internal_path); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ns_evaluate_by_handle @@ -275,26 +258,22 @@ cleanup: * ******************************************************************************/ -acpi_status -acpi_ns_evaluate_by_handle ( - struct acpi_parameter_info *info) +acpi_status acpi_ns_evaluate_by_handle(struct acpi_parameter_info *info) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ns_evaluate_by_handle"); + acpi_status status; + ACPI_FUNCTION_TRACE("ns_evaluate_by_handle"); /* Check if namespace has been initialized */ if (!acpi_gbl_root_node) { - return_ACPI_STATUS (AE_NO_NAMESPACE); + return_ACPI_STATUS(AE_NO_NAMESPACE); } /* Parameter Validation */ if (!info) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Initialize the return value to an invalid object */ @@ -303,23 +282,25 @@ acpi_ns_evaluate_by_handle ( /* Get the prefix handle and Node */ - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - info->node = acpi_ns_map_handle_to_node (info->node); + info->node = acpi_ns_map_handle_to_node(info->node); if (!info->node) { - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (AE_BAD_PARAMETER); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* * For a method alias, we must grab the actual method node so that proper * scoping context will be established before execution. */ - if (acpi_ns_get_type (info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { - info->node = ACPI_CAST_PTR (struct acpi_namespace_node, info->node->object); + if (acpi_ns_get_type(info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { + info->node = + ACPI_CAST_PTR(struct acpi_namespace_node, + info->node->object); } /* @@ -329,17 +310,16 @@ acpi_ns_evaluate_by_handle ( * * In both cases, the namespace is unlocked by the acpi_ns* procedure */ - if (acpi_ns_get_type (info->node) == ACPI_TYPE_METHOD) { + if (acpi_ns_get_type(info->node) == ACPI_TYPE_METHOD) { /* * Case 1) We have an actual control method to execute */ - status = acpi_ns_execute_control_method (info); - } - else { + status = acpi_ns_execute_control_method(info); + } else { /* * Case 2) Object is NOT a method, just return its current value */ - status = acpi_ns_get_object_value (info); + status = acpi_ns_get_object_value(info); } /* @@ -355,10 +335,9 @@ acpi_ns_evaluate_by_handle ( * Namespace was unlocked by the handling acpi_ns* function, so we * just return */ - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ns_execute_control_method @@ -384,30 +363,29 @@ acpi_ns_evaluate_by_handle ( ******************************************************************************/ static acpi_status -acpi_ns_execute_control_method ( - struct acpi_parameter_info *info) +acpi_ns_execute_control_method(struct acpi_parameter_info *info) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ns_execute_control_method"); + acpi_status status; + ACPI_FUNCTION_TRACE("ns_execute_control_method"); /* Verify that there is a method associated with this object */ - info->obj_desc = acpi_ns_get_attached_object (info->node); + info->obj_desc = acpi_ns_get_attached_object(info->node); if (!info->obj_desc) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No attached method object\n")); - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (AE_NULL_OBJECT); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(AE_NULL_OBJECT); } - ACPI_DUMP_PATHNAME (info->node, "Execute Method:", - ACPI_LV_INFO, _COMPONENT); + ACPI_DUMP_PATHNAME(info->node, "Execute Method:", + ACPI_LV_INFO, _COMPONENT); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n", - info->obj_desc->method.aml_start + 1, info->obj_desc->method.aml_length - 1)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Method at AML address %p Length %X\n", + info->obj_desc->method.aml_start + 1, + info->obj_desc->method.aml_length - 1)); /* * Unlock the namespace before execution. This allows namespace access @@ -416,27 +394,26 @@ acpi_ns_execute_control_method ( * interpreter locks to ensure that no thread is using the portion of the * namespace that is being deleted. */ - status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* * Execute the method via the interpreter. The interpreter is locked * here before calling into the AML parser */ - status = acpi_ex_enter_interpreter (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_enter_interpreter(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_ps_execute_method (info); - acpi_ex_exit_interpreter (); + status = acpi_ps_execute_method(info); + acpi_ex_exit_interpreter(); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ns_get_object_value @@ -454,16 +431,12 @@ acpi_ns_execute_control_method ( * ******************************************************************************/ -static acpi_status -acpi_ns_get_object_value ( - struct acpi_parameter_info *info) +static acpi_status acpi_ns_get_object_value(struct acpi_parameter_info *info) { - acpi_status status = AE_OK; - struct acpi_namespace_node *resolved_node = info->node; - - - ACPI_FUNCTION_TRACE ("ns_get_object_value"); + acpi_status status = AE_OK; + struct acpi_namespace_node *resolved_node = info->node; + ACPI_FUNCTION_TRACE("ns_get_object_value"); /* * Objects require additional resolution steps (e.g., the Node may be a @@ -486,32 +459,33 @@ acpi_ns_get_object_value ( * * We must release the namespace lock before entering the intepreter. */ - status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_ex_enter_interpreter (); - if (ACPI_SUCCESS (status)) { - status = acpi_ex_resolve_node_to_value (&resolved_node, NULL); + status = acpi_ex_enter_interpreter(); + if (ACPI_SUCCESS(status)) { + status = acpi_ex_resolve_node_to_value(&resolved_node, NULL); /* * If acpi_ex_resolve_node_to_value() succeeded, the return value was placed * in resolved_node. */ - acpi_ex_exit_interpreter (); + acpi_ex_exit_interpreter(); - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { status = AE_CTRL_RETURN_VALUE; info->return_object = ACPI_CAST_PTR - (union acpi_operand_object, resolved_node); - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", - info->return_object, - acpi_ut_get_object_type_name (info->return_object))); + (union acpi_operand_object, resolved_node); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Returning object %p [%s]\n", + info->return_object, + acpi_ut_get_object_type_name(info-> + return_object))); } } /* Namespace is unlocked */ - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c index 362802a..0a08d2f 100644 --- a/drivers/acpi/namespace/nsinit.c +++ b/drivers/acpi/namespace/nsinit.c @@ -41,31 +41,22 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsinit") +ACPI_MODULE_NAME("nsinit") /* Local prototypes */ - static acpi_status -acpi_ns_init_one_object ( - acpi_handle obj_handle, - u32 level, - void *context, - void **return_value); +acpi_ns_init_one_object(acpi_handle obj_handle, + u32 level, void *context, void **return_value); static acpi_status -acpi_ns_init_one_device ( - acpi_handle obj_handle, - u32 nesting_level, - void *context, - void **return_value); - +acpi_ns_init_one_device(acpi_handle obj_handle, + u32 nesting_level, void *context, void **return_value); /******************************************************************************* * @@ -80,52 +71,48 @@ acpi_ns_init_one_device ( * ******************************************************************************/ -acpi_status -acpi_ns_initialize_objects ( - void) +acpi_status acpi_ns_initialize_objects(void) { - acpi_status status; - struct acpi_init_walk_info info; - + acpi_status status; + struct acpi_init_walk_info info; - ACPI_FUNCTION_TRACE ("ns_initialize_objects"); + ACPI_FUNCTION_TRACE("ns_initialize_objects"); - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "**** Starting initialization of namespace objects ****\n")); - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "Completing Region/Field/Buffer/Package initialization:")); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "**** Starting initialization of namespace objects ****\n")); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, + "Completing Region/Field/Buffer/Package initialization:")); /* Set all init info to zero */ - ACPI_MEMSET (&info, 0, sizeof (struct acpi_init_walk_info)); + ACPI_MEMSET(&info, 0, sizeof(struct acpi_init_walk_info)); /* Walk entire namespace from the supplied root */ - status = acpi_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, acpi_ns_init_one_object, - &info, NULL); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed! %s\n", - acpi_format_exception (status))); + status = acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, acpi_ns_init_one_object, + &info, NULL); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n", + acpi_format_exception(status))); } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n", - info.op_region_init, info.op_region_count, - info.field_init, info.field_count, - info.buffer_init, info.buffer_count, - info.package_init, info.package_count, info.object_count)); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, + "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n", + info.op_region_init, info.op_region_count, + info.field_init, info.field_count, + info.buffer_init, info.buffer_count, + info.package_init, info.package_count, + info.object_count)); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "%hd Control Methods found\n", info.method_count)); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "%hd Op Regions found\n", info.op_region_count)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "%hd Control Methods found\n", info.method_count)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "%hd Op Regions found\n", info.op_region_count)); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ns_initialize_devices @@ -142,16 +129,12 @@ acpi_ns_initialize_objects ( * ******************************************************************************/ -acpi_status -acpi_ns_initialize_devices ( - void) +acpi_status acpi_ns_initialize_devices(void) { - acpi_status status; - struct acpi_device_walk_info info; - - - ACPI_FUNCTION_TRACE ("ns_initialize_devices"); + acpi_status status; + struct acpi_device_walk_info info; + ACPI_FUNCTION_TRACE("ns_initialize_devices"); /* Init counters */ @@ -159,34 +142,34 @@ acpi_ns_initialize_devices ( info.num_STA = 0; info.num_INI = 0; - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "Executing all Device _STA and_INI methods:")); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, + "Executing all Device _STA and_INI methods:")); - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Walk namespace for all objects */ - status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, TRUE, acpi_ns_init_one_device, &info, NULL); + status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, TRUE, + acpi_ns_init_one_device, &info, NULL); - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed! %s\n", - acpi_format_exception (status))); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n", + acpi_format_exception(status))); } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n", - info.device_count, info.num_STA, info.num_INI)); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, + "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n", + info.device_count, info.num_STA, info.num_INI)); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ns_init_one_object @@ -208,28 +191,25 @@ acpi_ns_initialize_devices ( ******************************************************************************/ static acpi_status -acpi_ns_init_one_object ( - acpi_handle obj_handle, - u32 level, - void *context, - void **return_value) +acpi_ns_init_one_object(acpi_handle obj_handle, + u32 level, void *context, void **return_value) { - acpi_object_type type; - acpi_status status; - struct acpi_init_walk_info *info = (struct acpi_init_walk_info *) context; - struct acpi_namespace_node *node = (struct acpi_namespace_node *) obj_handle; - union acpi_operand_object *obj_desc; - - - ACPI_FUNCTION_NAME ("ns_init_one_object"); + acpi_object_type type; + acpi_status status; + struct acpi_init_walk_info *info = + (struct acpi_init_walk_info *)context; + struct acpi_namespace_node *node = + (struct acpi_namespace_node *)obj_handle; + union acpi_operand_object *obj_desc; + ACPI_FUNCTION_NAME("ns_init_one_object"); info->object_count++; /* And even then, we are only interested in a few object types */ - type = acpi_ns_get_type (obj_handle); - obj_desc = acpi_ns_get_attached_object (node); + type = acpi_ns_get_type(obj_handle); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { return (AE_OK); } @@ -269,8 +249,8 @@ acpi_ns_init_one_object ( /* * Must lock the interpreter before executing AML code */ - status = acpi_ex_enter_interpreter (); - if (ACPI_FAILURE (status)) { + status = acpi_ex_enter_interpreter(); + if (ACPI_FAILURE(status)) { return (status); } @@ -282,25 +262,25 @@ acpi_ns_init_one_object ( case ACPI_TYPE_REGION: info->op_region_init++; - status = acpi_ds_get_region_arguments (obj_desc); + status = acpi_ds_get_region_arguments(obj_desc); break; case ACPI_TYPE_BUFFER_FIELD: info->field_init++; - status = acpi_ds_get_buffer_field_arguments (obj_desc); + status = acpi_ds_get_buffer_field_arguments(obj_desc); break; case ACPI_TYPE_BUFFER: info->buffer_init++; - status = acpi_ds_get_buffer_arguments (obj_desc); + status = acpi_ds_get_buffer_arguments(obj_desc); break; case ACPI_TYPE_PACKAGE: info->package_init++; - status = acpi_ds_get_package_arguments (obj_desc); + status = acpi_ds_get_package_arguments(obj_desc); break; default: @@ -308,12 +288,13 @@ acpi_ns_init_one_object ( break; } - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "\n")); - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not execute arguments for [%4.4s] (%s), %s\n", - acpi_ut_get_node_name (node), acpi_ut_get_type_name (type), - acpi_format_exception (status))); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, "\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not execute arguments for [%4.4s] (%s), %s\n", + acpi_ut_get_node_name(node), + acpi_ut_get_type_name(type), + acpi_format_exception(status))); } /* @@ -321,18 +302,17 @@ acpi_ns_init_one_object ( * pathname */ if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, ".")); } /* * We ignore errors from above, and always return OK, since we don't want * to abort the walk on any single error. */ - acpi_ex_exit_interpreter (); + acpi_ex_exit_interpreter(); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ns_init_one_device @@ -348,41 +328,37 @@ acpi_ns_init_one_object ( ******************************************************************************/ static acpi_status -acpi_ns_init_one_device ( - acpi_handle obj_handle, - u32 nesting_level, - void *context, - void **return_value) +acpi_ns_init_one_device(acpi_handle obj_handle, + u32 nesting_level, void *context, void **return_value) { - struct acpi_device_walk_info *info = (struct acpi_device_walk_info *) context; - struct acpi_parameter_info pinfo; - u32 flags; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ns_init_one_device"); + struct acpi_device_walk_info *info = + (struct acpi_device_walk_info *)context; + struct acpi_parameter_info pinfo; + u32 flags; + acpi_status status; + ACPI_FUNCTION_TRACE("ns_init_one_device"); pinfo.parameters = NULL; pinfo.parameter_type = ACPI_PARAM_ARGS; - pinfo.node = acpi_ns_map_handle_to_node (obj_handle); + pinfo.node = acpi_ns_map_handle_to_node(obj_handle); if (!pinfo.node) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* * We will run _STA/_INI on Devices, Processors and thermal_zones only */ - if ((pinfo.node->type != ACPI_TYPE_DEVICE) && - (pinfo.node->type != ACPI_TYPE_PROCESSOR) && - (pinfo.node->type != ACPI_TYPE_THERMAL)) { - return_ACPI_STATUS (AE_OK); + if ((pinfo.node->type != ACPI_TYPE_DEVICE) && + (pinfo.node->type != ACPI_TYPE_PROCESSOR) && + (pinfo.node->type != ACPI_TYPE_THERMAL)) { + return_ACPI_STATUS(AE_OK); } if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) && - (!(acpi_dbg_level & ACPI_LV_INFO))) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); + (!(acpi_dbg_level & ACPI_LV_INFO))) { + ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, ".")); } info->device_count++; @@ -390,20 +366,20 @@ acpi_ns_init_one_device ( /* * Run _STA to determine if we can run _INI on the device. */ - ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, - pinfo.node, METHOD_NAME__STA)); - status = acpi_ut_execute_STA (pinfo.node, &flags); + ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, + pinfo.node, + METHOD_NAME__STA)); + status = acpi_ut_execute_STA(pinfo.node, &flags); - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { if (pinfo.node->type == ACPI_TYPE_DEVICE) { /* Ignore error and move on to next device */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* _STA is not required for Processor or thermal_zone objects */ - } - else { + } else { info->num_STA++; if (!(flags & 0x01)) { @@ -416,32 +392,34 @@ acpi_ns_init_one_device ( /* * The device is present. Run _INI. */ - ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, - pinfo.node, METHOD_NAME__INI)); - status = acpi_ns_evaluate_relative (METHOD_NAME__INI, &pinfo); - if (ACPI_FAILURE (status)) { + ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, + pinfo.node, + METHOD_NAME__INI)); + status = acpi_ns_evaluate_relative(METHOD_NAME__INI, &pinfo); + if (ACPI_FAILURE(status)) { /* No _INI (AE_NOT_FOUND) means device requires no initialization */ if (status != AE_NOT_FOUND) { /* Ignore error and move on to next device */ #ifdef ACPI_DEBUG_OUTPUT - char *scope_name = acpi_ns_get_external_pathname (pinfo.node); + char *scope_name = + acpi_ns_get_external_pathname(pinfo.node); - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%s._INI failed: %s\n", - scope_name, acpi_format_exception (status))); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "%s._INI failed: %s\n", + scope_name, + acpi_format_exception(status))); - ACPI_MEM_FREE (scope_name); + ACPI_MEM_FREE(scope_name); #endif } status = AE_OK; - } - else { + } else { /* Delete any return object (especially if implicit_return is enabled) */ if (pinfo.return_object) { - acpi_ut_remove_reference (pinfo.return_object); + acpi_ut_remove_reference(pinfo.return_object); } /* Count of successful INIs */ @@ -452,8 +430,9 @@ acpi_ns_init_one_device ( if (acpi_gbl_init_handler) { /* External initialization handler is present, call it */ - status = acpi_gbl_init_handler (pinfo.node, ACPI_INIT_DEVICE_INI); + status = + acpi_gbl_init_handler(pinfo.node, ACPI_INIT_DEVICE_INI); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c index 1428a84..c28849d 100644 --- a/drivers/acpi/namespace/nsload.c +++ b/drivers/acpi/namespace/nsload.c @@ -41,32 +41,22 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsload") +ACPI_MODULE_NAME("nsload") /* Local prototypes */ - -static acpi_status -acpi_ns_load_table_by_type ( - acpi_table_type table_type); +static acpi_status acpi_ns_load_table_by_type(acpi_table_type table_type); #ifdef ACPI_FUTURE_IMPLEMENTATION -acpi_status -acpi_ns_unload_namespace ( - acpi_handle handle); +acpi_status acpi_ns_unload_namespace(acpi_handle handle); -static acpi_status -acpi_ns_delete_subtree ( - acpi_handle start_handle); +static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle); #endif - #ifndef ACPI_NO_METHOD_EXECUTION /******************************************************************************* * @@ -82,40 +72,39 @@ acpi_ns_delete_subtree ( ******************************************************************************/ acpi_status -acpi_ns_load_table ( - struct acpi_table_desc *table_desc, - struct acpi_namespace_node *node) +acpi_ns_load_table(struct acpi_table_desc *table_desc, + struct acpi_namespace_node *node) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ns_load_table"); + acpi_status status; + ACPI_FUNCTION_TRACE("ns_load_table"); /* Check if table contains valid AML (must be DSDT, PSDT, SSDT, etc.) */ - if (!(acpi_gbl_table_data[table_desc->type].flags & ACPI_TABLE_EXECUTABLE)) { + if (! + (acpi_gbl_table_data[table_desc->type]. + flags & ACPI_TABLE_EXECUTABLE)) { /* Just ignore this table */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Check validity of the AML start and length */ if (!table_desc->aml_start) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null AML pointer\n")); - return_ACPI_STATUS (AE_BAD_PARAMETER); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null AML pointer\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n", - table_desc->aml_start)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AML block at %p\n", + table_desc->aml_start)); /* Ignore table if there is no AML contained within */ if (!table_desc->aml_length) { - ACPI_REPORT_WARNING (("Zero-length AML block in table [%4.4s]\n", - table_desc->pointer->signature)); - return_ACPI_STATUS (AE_OK); + ACPI_REPORT_WARNING(("Zero-length AML block in table [%4.4s]\n", + table_desc->pointer->signature)); + return_ACPI_STATUS(AE_OK); } /* @@ -127,19 +116,19 @@ acpi_ns_load_table ( * to another control method, we can't continue parsing * because we don't know how many arguments to parse next! */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "**** Loading table into namespace ****\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "**** Loading table into namespace ****\n")); - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_ns_parse_table (table_desc, node->child); - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + status = acpi_ns_parse_table(table_desc, node->child); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -148,18 +137,17 @@ acpi_ns_load_table ( * just-in-time parsing, we delete the control method * parse trees. */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "**** Begin Table Method Parsing and Object Initialization ****\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "**** Begin Table Method Parsing and Object Initialization ****\n")); - status = acpi_ds_initialize_objects (table_desc, node); + status = acpi_ds_initialize_objects(table_desc, node); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "**** Completed Table Method Parsing and Object Initialization ****\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "**** Completed Table Method Parsing and Object Initialization ****\n")); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ns_load_table_by_type @@ -174,21 +162,17 @@ acpi_ns_load_table ( * ******************************************************************************/ -static acpi_status -acpi_ns_load_table_by_type ( - acpi_table_type table_type) +static acpi_status acpi_ns_load_table_by_type(acpi_table_type table_type) { - u32 i; - acpi_status status; - struct acpi_table_desc *table_desc; - - - ACPI_FUNCTION_TRACE ("ns_load_table_by_type"); + u32 i; + acpi_status status; + struct acpi_table_desc *table_desc; + ACPI_FUNCTION_TRACE("ns_load_table_by_type"); - status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -198,7 +182,7 @@ acpi_ns_load_table_by_type ( switch (table_type) { case ACPI_TABLE_DSDT: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace load: DSDT\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace load: DSDT\n")); table_desc = acpi_gbl_table_lists[ACPI_TABLE_DSDT].next; @@ -210,18 +194,18 @@ acpi_ns_load_table_by_type ( /* Now load the single DSDT */ - status = acpi_ns_load_table (table_desc, acpi_gbl_root_node); - if (ACPI_SUCCESS (status)) { + status = acpi_ns_load_table(table_desc, acpi_gbl_root_node); + if (ACPI_SUCCESS(status)) { table_desc->loaded_into_namespace = TRUE; } break; - case ACPI_TABLE_SSDT: case ACPI_TABLE_PSDT: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace load: %d SSDT or PSDTs\n", - acpi_gbl_table_lists[table_type].count)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Namespace load: %d SSDT or PSDTs\n", + acpi_gbl_table_lists[table_type].count)); /* * Traverse list of SSDT or PSDT tables @@ -233,8 +217,10 @@ acpi_ns_load_table_by_type ( * already loaded! */ if (!table_desc->loaded_into_namespace) { - status = acpi_ns_load_table (table_desc, acpi_gbl_root_node); - if (ACPI_FAILURE (status)) { + status = + acpi_ns_load_table(table_desc, + acpi_gbl_root_node); + if (ACPI_FAILURE(status)) { break; } @@ -245,19 +231,16 @@ acpi_ns_load_table_by_type ( } break; - default: status = AE_SUPPORT; break; } - -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (status); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_load_namespace @@ -271,45 +254,40 @@ unlock_and_exit: * ******************************************************************************/ -acpi_status -acpi_ns_load_namespace ( - void) +acpi_status acpi_ns_load_namespace(void) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_load_name_space"); + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_load_name_space"); /* There must be at least a DSDT installed */ if (acpi_gbl_DSDT == NULL) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "DSDT is not in memory\n")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "DSDT is not in memory\n")); + return_ACPI_STATUS(AE_NO_ACPI_TABLES); } /* * Load the namespace. The DSDT is required, * but the SSDT and PSDT tables are optional. */ - status = acpi_ns_load_table_by_type (ACPI_TABLE_DSDT); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ns_load_table_by_type(ACPI_TABLE_DSDT); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Ignore exceptions from these */ - (void) acpi_ns_load_table_by_type (ACPI_TABLE_SSDT); - (void) acpi_ns_load_table_by_type (ACPI_TABLE_PSDT); + (void)acpi_ns_load_table_by_type(ACPI_TABLE_SSDT); + (void)acpi_ns_load_table_by_type(ACPI_TABLE_PSDT); - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "ACPI Namespace successfully loaded at root %p\n", - acpi_gbl_root_node)); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, + "ACPI Namespace successfully loaded at root %p\n", + acpi_gbl_root_node)); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - #ifdef ACPI_FUTURE_IMPLEMENTATION /******************************************************************************* * @@ -327,24 +305,20 @@ acpi_ns_load_namespace ( * ******************************************************************************/ -static acpi_status -acpi_ns_delete_subtree ( - acpi_handle start_handle) +static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle) { - acpi_status status; - acpi_handle child_handle; - acpi_handle parent_handle; - acpi_handle next_child_handle; - acpi_handle dummy; - u32 level; - - - ACPI_FUNCTION_TRACE ("ns_delete_subtree"); + acpi_status status; + acpi_handle child_handle; + acpi_handle parent_handle; + acpi_handle next_child_handle; + acpi_handle dummy; + u32 level; + ACPI_FUNCTION_TRACE("ns_delete_subtree"); parent_handle = start_handle; child_handle = NULL; - level = 1; + level = 1; /* * Traverse the tree of objects until we bubble back up @@ -353,18 +327,19 @@ acpi_ns_delete_subtree ( while (level > 0) { /* Attempt to get the next object in this scope */ - status = acpi_get_next_object (ACPI_TYPE_ANY, parent_handle, - child_handle, &next_child_handle); + status = acpi_get_next_object(ACPI_TYPE_ANY, parent_handle, + child_handle, &next_child_handle); child_handle = next_child_handle; /* Did we get a new object? */ - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { /* Check if this object has any children */ - if (ACPI_SUCCESS (acpi_get_next_object (ACPI_TYPE_ANY, child_handle, - NULL, &dummy))) { + if (ACPI_SUCCESS + (acpi_get_next_object + (ACPI_TYPE_ANY, child_handle, NULL, &dummy))) { /* * There is at least one child of this object, * visit the object @@ -373,8 +348,7 @@ acpi_ns_delete_subtree ( parent_handle = child_handle; child_handle = NULL; } - } - else { + } else { /* * No more children in this object, go back up to * the object's parent @@ -383,24 +357,23 @@ acpi_ns_delete_subtree ( /* Delete all children now */ - acpi_ns_delete_children (child_handle); + acpi_ns_delete_children(child_handle); child_handle = parent_handle; - status = acpi_get_parent (parent_handle, &parent_handle); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_get_parent(parent_handle, &parent_handle); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } } /* Now delete the starting object, and we are done */ - acpi_ns_delete_node (child_handle); + acpi_ns_delete_node(child_handle); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ns_unload_name_space @@ -415,32 +388,27 @@ acpi_ns_delete_subtree ( * ******************************************************************************/ -acpi_status -acpi_ns_unload_namespace ( - acpi_handle handle) +acpi_status acpi_ns_unload_namespace(acpi_handle handle) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ns_unload_name_space"); + acpi_status status; + ACPI_FUNCTION_TRACE("ns_unload_name_space"); /* Parameter validation */ if (!acpi_gbl_root_node) { - return_ACPI_STATUS (AE_NO_NAMESPACE); + return_ACPI_STATUS(AE_NO_NAMESPACE); } if (!handle) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* This function does the real work */ - status = acpi_ns_delete_subtree (handle); + status = acpi_ns_delete_subtree(handle); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } #endif #endif - diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c index d8ce7e3..d5e8dea 100644 --- a/drivers/acpi/namespace/nsnames.c +++ b/drivers/acpi/namespace/nsnames.c @@ -41,23 +41,17 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsnames") +ACPI_MODULE_NAME("nsnames") /* Local prototypes */ - static void -acpi_ns_build_external_path ( - struct acpi_namespace_node *node, - acpi_size size, - char *name_buffer); - +acpi_ns_build_external_path(struct acpi_namespace_node *node, + acpi_size size, char *name_buffer); /******************************************************************************* * @@ -75,17 +69,13 @@ acpi_ns_build_external_path ( ******************************************************************************/ static void -acpi_ns_build_external_path ( - struct acpi_namespace_node *node, - acpi_size size, - char *name_buffer) +acpi_ns_build_external_path(struct acpi_namespace_node *node, + acpi_size size, char *name_buffer) { - acpi_size index; - struct acpi_namespace_node *parent_node; - - - ACPI_FUNCTION_NAME ("ns_build_external_path"); + acpi_size index; + struct acpi_namespace_node *parent_node; + ACPI_FUNCTION_NAME("ns_build_external_path"); /* Special case for root */ @@ -106,8 +96,8 @@ acpi_ns_build_external_path ( /* Put the name into the buffer */ - ACPI_MOVE_32_TO_32 ((name_buffer + index), &parent_node->name); - parent_node = acpi_ns_get_parent_node (parent_node); + ACPI_MOVE_32_TO_32((name_buffer + index), &parent_node->name); + parent_node = acpi_ns_get_parent_node(parent_node); /* Prefix name with the path separator */ @@ -120,15 +110,14 @@ acpi_ns_build_external_path ( name_buffer[index] = AML_ROOT_PREFIX; if (index != 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not construct pathname; index=%X, size=%X, Path=%s\n", - (u32) index, (u32) size, &name_buffer[size])); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not construct pathname; index=%X, size=%X, Path=%s\n", + (u32) index, (u32) size, &name_buffer[size])); } return; } - #ifdef ACPI_DEBUG_OUTPUT /******************************************************************************* * @@ -144,37 +133,32 @@ acpi_ns_build_external_path ( * ******************************************************************************/ -char * -acpi_ns_get_external_pathname ( - struct acpi_namespace_node *node) +char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node) { - char *name_buffer; - acpi_size size; - - - ACPI_FUNCTION_TRACE_PTR ("ns_get_external_pathname", node); + char *name_buffer; + acpi_size size; + ACPI_FUNCTION_TRACE_PTR("ns_get_external_pathname", node); /* Calculate required buffer size based on depth below root */ - size = acpi_ns_get_pathname_length (node); + size = acpi_ns_get_pathname_length(node); /* Allocate a buffer to be returned to caller */ - name_buffer = ACPI_MEM_CALLOCATE (size); + name_buffer = ACPI_MEM_CALLOCATE(size); if (!name_buffer) { - ACPI_REPORT_ERROR (("ns_get_table_pathname: allocation failure\n")); - return_PTR (NULL); + ACPI_REPORT_ERROR(("ns_get_table_pathname: allocation failure\n")); + return_PTR(NULL); } /* Build the path in the allocated buffer */ - acpi_ns_build_external_path (node, size, name_buffer); - return_PTR (name_buffer); + acpi_ns_build_external_path(node, size, name_buffer); + return_PTR(name_buffer); } #endif - /******************************************************************************* * * FUNCTION: acpi_ns_get_pathname_length @@ -187,16 +171,12 @@ acpi_ns_get_external_pathname ( * ******************************************************************************/ -acpi_size -acpi_ns_get_pathname_length ( - struct acpi_namespace_node *node) +acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node) { - acpi_size size; - struct acpi_namespace_node *next_node; - - - ACPI_FUNCTION_ENTRY (); + acpi_size size; + struct acpi_namespace_node *next_node; + ACPI_FUNCTION_ENTRY(); /* * Compute length of pathname as 5 * number of name segments. @@ -207,17 +187,16 @@ acpi_ns_get_pathname_length ( while (next_node && (next_node != acpi_gbl_root_node)) { size += ACPI_PATH_SEGMENT_LENGTH; - next_node = acpi_ns_get_parent_node (next_node); + next_node = acpi_ns_get_parent_node(next_node); } if (!size) { - size = 1; /* Root node case */ + size = 1; /* Root node case */ } - return (size + 1); /* +1 for null string terminator */ + return (size + 1); /* +1 for null string terminator */ } - /******************************************************************************* * * FUNCTION: acpi_ns_handle_to_pathname @@ -233,41 +212,36 @@ acpi_ns_get_pathname_length ( ******************************************************************************/ acpi_status -acpi_ns_handle_to_pathname ( - acpi_handle target_handle, - struct acpi_buffer *buffer) +acpi_ns_handle_to_pathname(acpi_handle target_handle, + struct acpi_buffer * buffer) { - acpi_status status; - struct acpi_namespace_node *node; - acpi_size required_size; + acpi_status status; + struct acpi_namespace_node *node; + acpi_size required_size; + ACPI_FUNCTION_TRACE_PTR("ns_handle_to_pathname", target_handle); - ACPI_FUNCTION_TRACE_PTR ("ns_handle_to_pathname", target_handle); - - - node = acpi_ns_map_handle_to_node (target_handle); + node = acpi_ns_map_handle_to_node(target_handle); if (!node) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Determine size required for the caller buffer */ - required_size = acpi_ns_get_pathname_length (node); + required_size = acpi_ns_get_pathname_length(node); /* Validate/Allocate/Clear caller buffer */ - status = acpi_ut_initialize_buffer (buffer, required_size); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_initialize_buffer(buffer, required_size); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Build the path in the caller buffer */ - acpi_ns_build_external_path (node, required_size, buffer->pointer); + acpi_ns_build_external_path(node, required_size, buffer->pointer); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", - (char *) buffer->pointer, (u32) required_size)); - return_ACPI_STATUS (AE_OK); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X] \n", + (char *)buffer->pointer, (u32) required_size)); + return_ACPI_STATUS(AE_OK); } - - diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c index 27258c1..fc9be94 100644 --- a/drivers/acpi/namespace/nsobject.c +++ b/drivers/acpi/namespace/nsobject.c @@ -42,14 +42,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsobject") - +ACPI_MODULE_NAME("nsobject") /******************************************************************************* * @@ -71,20 +68,15 @@ * MUTEX: Assumes namespace is locked * ******************************************************************************/ - acpi_status -acpi_ns_attach_object ( - struct acpi_namespace_node *node, - union acpi_operand_object *object, - acpi_object_type type) +acpi_ns_attach_object(struct acpi_namespace_node *node, + union acpi_operand_object *object, acpi_object_type type) { - union acpi_operand_object *obj_desc; - union acpi_operand_object *last_obj_desc; - acpi_object_type object_type = ACPI_TYPE_ANY; - - - ACPI_FUNCTION_TRACE ("ns_attach_object"); + union acpi_operand_object *obj_desc; + union acpi_operand_object *last_obj_desc; + acpi_object_type object_type = ACPI_TYPE_ANY; + ACPI_FUNCTION_TRACE("ns_attach_object"); /* * Parameter validation @@ -92,40 +84,39 @@ acpi_ns_attach_object ( if (!node) { /* Invalid handle */ - ACPI_REPORT_ERROR (("ns_attach_object: Null named_obj handle\n")); - return_ACPI_STATUS (AE_BAD_PARAMETER); + ACPI_REPORT_ERROR(("ns_attach_object: Null named_obj handle\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); } if (!object && (ACPI_TYPE_ANY != type)) { /* Null object */ - ACPI_REPORT_ERROR (( - "ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n")); - return_ACPI_STATUS (AE_BAD_PARAMETER); + ACPI_REPORT_ERROR(("ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) { + if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { /* Not a name handle */ - ACPI_REPORT_ERROR (("ns_attach_object: Invalid handle %p [%s]\n", - node, acpi_ut_get_descriptor_name (node))); - return_ACPI_STATUS (AE_BAD_PARAMETER); + ACPI_REPORT_ERROR(("ns_attach_object: Invalid handle %p [%s]\n", + node, acpi_ut_get_descriptor_name(node))); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Check if this object is already attached */ if (node->object == object) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Obj %p already installed in name_obj %p\n", - object, node)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Obj %p already installed in name_obj %p\n", + object, node)); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* If null object, we will just install it */ if (!object) { - obj_desc = NULL; + obj_desc = NULL; object_type = ACPI_TYPE_ANY; } @@ -133,14 +124,14 @@ acpi_ns_attach_object ( * If the source object is a namespace Node with an attached object, * we will use that (attached) object */ - else if ((ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) && - ((struct acpi_namespace_node *) object)->object) { + else if ((ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) && + ((struct acpi_namespace_node *)object)->object) { /* * Value passed is a name handle and that name has a * non-null value. Use that name's value and type. */ - obj_desc = ((struct acpi_namespace_node *) object)->object; - object_type = ((struct acpi_namespace_node *) object)->type; + obj_desc = ((struct acpi_namespace_node *)object)->object; + object_type = ((struct acpi_namespace_node *)object)->type; } /* @@ -148,20 +139,20 @@ acpi_ns_attach_object ( * it first */ else { - obj_desc = (union acpi_operand_object *) object; + obj_desc = (union acpi_operand_object *)object; /* Use the given type */ object_type = type; } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", - obj_desc, node, acpi_ut_get_node_name (node))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", + obj_desc, node, acpi_ut_get_node_name(node))); /* Detach an existing attached object if present */ if (node->object) { - acpi_ns_detach_object (node); + acpi_ns_detach_object(node); } if (obj_desc) { @@ -169,7 +160,7 @@ acpi_ns_attach_object ( * Must increment the new value's reference count * (if it is an internal object) */ - acpi_ut_add_reference (obj_desc); + acpi_ut_add_reference(obj_desc); /* * Handle objects with multiple descriptors - walk @@ -185,13 +176,12 @@ acpi_ns_attach_object ( last_obj_desc->common.next_object = node->object; } - node->type = (u8) object_type; - node->object = obj_desc; + node->type = (u8) object_type; + node->object = obj_desc; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ns_detach_object @@ -206,30 +196,27 @@ acpi_ns_attach_object ( * ******************************************************************************/ -void -acpi_ns_detach_object ( - struct acpi_namespace_node *node) +void acpi_ns_detach_object(struct acpi_namespace_node *node) { - union acpi_operand_object *obj_desc; - - - ACPI_FUNCTION_TRACE ("ns_detach_object"); + union acpi_operand_object *obj_desc; + ACPI_FUNCTION_TRACE("ns_detach_object"); obj_desc = node->object; if (!obj_desc || - (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA)) { + (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA)) { return_VOID; } /* Clear the entry in all cases */ node->object = NULL; - if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) { + if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_OPERAND) { node->object = obj_desc->common.next_object; if (node->object && - (ACPI_GET_OBJECT_TYPE (node->object) != ACPI_TYPE_LOCAL_DATA)) { + (ACPI_GET_OBJECT_TYPE(node->object) != + ACPI_TYPE_LOCAL_DATA)) { node->object = node->object->common.next_object; } } @@ -238,16 +225,15 @@ acpi_ns_detach_object ( node->type = ACPI_TYPE_ANY; - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n", - node, acpi_ut_get_node_name (node), obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n", + node, acpi_ut_get_node_name(node), obj_desc)); /* Remove one reference on the object (and all subobjects) */ - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ns_get_attached_object @@ -261,29 +247,28 @@ acpi_ns_detach_object ( * ******************************************************************************/ -union acpi_operand_object * -acpi_ns_get_attached_object ( - struct acpi_namespace_node *node) +union acpi_operand_object *acpi_ns_get_attached_object(struct + acpi_namespace_node + *node) { - ACPI_FUNCTION_TRACE_PTR ("ns_get_attached_object", node); - + ACPI_FUNCTION_TRACE_PTR("ns_get_attached_object", node); if (!node) { - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Null Node ptr\n")); - return_PTR (NULL); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Null Node ptr\n")); + return_PTR(NULL); } if (!node->object || - ((ACPI_GET_DESCRIPTOR_TYPE (node->object) != ACPI_DESC_TYPE_OPERAND) && - (ACPI_GET_DESCRIPTOR_TYPE (node->object) != ACPI_DESC_TYPE_NAMED)) || - (ACPI_GET_OBJECT_TYPE (node->object) == ACPI_TYPE_LOCAL_DATA)) { - return_PTR (NULL); + ((ACPI_GET_DESCRIPTOR_TYPE(node->object) != ACPI_DESC_TYPE_OPERAND) + && (ACPI_GET_DESCRIPTOR_TYPE(node->object) != + ACPI_DESC_TYPE_NAMED)) + || (ACPI_GET_OBJECT_TYPE(node->object) == ACPI_TYPE_LOCAL_DATA)) { + return_PTR(NULL); } - return_PTR (node->object); + return_PTR(node->object); } - /******************************************************************************* * * FUNCTION: acpi_ns_get_secondary_object @@ -297,24 +282,23 @@ acpi_ns_get_attached_object ( * ******************************************************************************/ -union acpi_operand_object * -acpi_ns_get_secondary_object ( - union acpi_operand_object *obj_desc) +union acpi_operand_object *acpi_ns_get_secondary_object(union + acpi_operand_object + *obj_desc) { - ACPI_FUNCTION_TRACE_PTR ("ns_get_secondary_object", obj_desc); - - - if ((!obj_desc) || - (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) || - (!obj_desc->common.next_object) || - (ACPI_GET_OBJECT_TYPE (obj_desc->common.next_object) == ACPI_TYPE_LOCAL_DATA)) { - return_PTR (NULL); + ACPI_FUNCTION_TRACE_PTR("ns_get_secondary_object", obj_desc); + + if ((!obj_desc) || + (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) || + (!obj_desc->common.next_object) || + (ACPI_GET_OBJECT_TYPE(obj_desc->common.next_object) == + ACPI_TYPE_LOCAL_DATA)) { + return_PTR(NULL); } - return_PTR (obj_desc->common.next_object); + return_PTR(obj_desc->common.next_object); } - /******************************************************************************* * * FUNCTION: acpi_ns_attach_data @@ -330,23 +314,20 @@ acpi_ns_get_secondary_object ( ******************************************************************************/ acpi_status -acpi_ns_attach_data ( - struct acpi_namespace_node *node, - acpi_object_handler handler, - void *data) +acpi_ns_attach_data(struct acpi_namespace_node *node, + acpi_object_handler handler, void *data) { - union acpi_operand_object *prev_obj_desc; - union acpi_operand_object *obj_desc; - union acpi_operand_object *data_desc; - + union acpi_operand_object *prev_obj_desc; + union acpi_operand_object *obj_desc; + union acpi_operand_object *data_desc; /* We only allow one attachment per handler */ prev_obj_desc = NULL; obj_desc = node->object; while (obj_desc) { - if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) && - (obj_desc->data.handler == handler)) { + if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) && + (obj_desc->data.handler == handler)) { return (AE_ALREADY_EXISTS); } @@ -356,7 +337,7 @@ acpi_ns_attach_data ( /* Create an internal object for the data */ - data_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_DATA); + data_desc = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_DATA); if (!data_desc) { return (AE_NO_MEMORY); } @@ -368,15 +349,13 @@ acpi_ns_attach_data ( if (prev_obj_desc) { prev_obj_desc->common.next_object = data_desc; - } - else { + } else { node->object = data_desc; } return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ns_detach_data @@ -392,27 +371,25 @@ acpi_ns_attach_data ( ******************************************************************************/ acpi_status -acpi_ns_detach_data ( - struct acpi_namespace_node *node, - acpi_object_handler handler) +acpi_ns_detach_data(struct acpi_namespace_node * node, + acpi_object_handler handler) { - union acpi_operand_object *obj_desc; - union acpi_operand_object *prev_obj_desc; - + union acpi_operand_object *obj_desc; + union acpi_operand_object *prev_obj_desc; prev_obj_desc = NULL; obj_desc = node->object; while (obj_desc) { - if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) && - (obj_desc->data.handler == handler)) { + if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) && + (obj_desc->data.handler == handler)) { if (prev_obj_desc) { - prev_obj_desc->common.next_object = obj_desc->common.next_object; - } - else { + prev_obj_desc->common.next_object = + obj_desc->common.next_object; + } else { node->object = obj_desc->common.next_object; } - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); return (AE_OK); } @@ -423,7 +400,6 @@ acpi_ns_detach_data ( return (AE_NOT_FOUND); } - /******************************************************************************* * * FUNCTION: acpi_ns_get_attached_data @@ -440,18 +416,15 @@ acpi_ns_detach_data ( ******************************************************************************/ acpi_status -acpi_ns_get_attached_data ( - struct acpi_namespace_node *node, - acpi_object_handler handler, - void **data) +acpi_ns_get_attached_data(struct acpi_namespace_node * node, + acpi_object_handler handler, void **data) { - union acpi_operand_object *obj_desc; - + union acpi_operand_object *obj_desc; obj_desc = node->object; while (obj_desc) { - if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) && - (obj_desc->data.handler == handler)) { + if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) && + (obj_desc->data.handler == handler)) { *data = obj_desc->data.pointer; return (AE_OK); } @@ -461,5 +434,3 @@ acpi_ns_get_attached_data ( return (AE_NOT_FOUND); } - - diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c index 24bed93..433442a 100644 --- a/drivers/acpi/namespace/nsparse.c +++ b/drivers/acpi/namespace/nsparse.c @@ -41,16 +41,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsparse") - +ACPI_MODULE_NAME("nsparse") /******************************************************************************* * @@ -64,54 +61,50 @@ * DESCRIPTION: Perform one complete parse of an ACPI/AML table. * ******************************************************************************/ - acpi_status -acpi_ns_one_complete_parse ( - u8 pass_number, - struct acpi_table_desc *table_desc) +acpi_ns_one_complete_parse(u8 pass_number, struct acpi_table_desc * table_desc) { - union acpi_parse_object *parse_root; - acpi_status status; - struct acpi_walk_state *walk_state; - - - ACPI_FUNCTION_TRACE ("ns_one_complete_parse"); + union acpi_parse_object *parse_root; + acpi_status status; + struct acpi_walk_state *walk_state; + ACPI_FUNCTION_TRACE("ns_one_complete_parse"); /* Create and init a Root Node */ - parse_root = acpi_ps_create_scope_op (); + parse_root = acpi_ps_create_scope_op(); if (!parse_root) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Create and initialize a new walk state */ - walk_state = acpi_ds_create_walk_state (table_desc->owner_id, - NULL, NULL, NULL); + walk_state = acpi_ds_create_walk_state(table_desc->owner_id, + NULL, NULL, NULL); if (!walk_state) { - acpi_ps_free_op (parse_root); - return_ACPI_STATUS (AE_NO_MEMORY); + acpi_ps_free_op(parse_root); + return_ACPI_STATUS(AE_NO_MEMORY); } - status = acpi_ds_init_aml_walk (walk_state, parse_root, NULL, - table_desc->aml_start, table_desc->aml_length, - NULL, pass_number); - if (ACPI_FAILURE (status)) { - acpi_ds_delete_walk_state (walk_state); - return_ACPI_STATUS (status); + status = acpi_ds_init_aml_walk(walk_state, parse_root, NULL, + table_desc->aml_start, + table_desc->aml_length, NULL, + pass_number); + if (ACPI_FAILURE(status)) { + acpi_ds_delete_walk_state(walk_state); + return_ACPI_STATUS(status); } /* Parse the AML */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", pass_number)); - status = acpi_ps_parse_aml (walk_state); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", + pass_number)); + status = acpi_ps_parse_aml(walk_state); - acpi_ps_delete_parse_tree (parse_root); - return_ACPI_STATUS (status); + acpi_ps_delete_parse_tree(parse_root); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ns_parse_table @@ -126,15 +119,12 @@ acpi_ns_one_complete_parse ( ******************************************************************************/ acpi_status -acpi_ns_parse_table ( - struct acpi_table_desc *table_desc, - struct acpi_namespace_node *start_node) +acpi_ns_parse_table(struct acpi_table_desc *table_desc, + struct acpi_namespace_node *start_node) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ns_parse_table"); + acpi_status status; + ACPI_FUNCTION_TRACE("ns_parse_table"); /* * AML Parse, pass 1 @@ -146,10 +136,10 @@ acpi_ns_parse_table ( * to service the entire parse. The second pass of the parse then * performs another complete parse of the AML.. */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); - status = acpi_ns_one_complete_parse (1, table_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n")); + status = acpi_ns_one_complete_parse(1, table_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -161,13 +151,11 @@ acpi_ns_parse_table ( * overhead of this is compensated for by the fact that the * parse objects are all cached. */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); - status = acpi_ns_one_complete_parse (2, table_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 2\n")); + status = acpi_ns_one_complete_parse(2, table_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c index af8aaa9..50a3ca5 100644 --- a/drivers/acpi/namespace/nssearch.c +++ b/drivers/acpi/namespace/nssearch.c @@ -41,23 +41,18 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nssearch") +ACPI_MODULE_NAME("nssearch") /* Local prototypes */ - static acpi_status -acpi_ns_search_parent_tree ( - u32 target_name, - struct acpi_namespace_node *node, - acpi_object_type type, - struct acpi_namespace_node **return_node); - +acpi_ns_search_parent_tree(u32 target_name, + struct acpi_namespace_node *node, + acpi_object_type type, + struct acpi_namespace_node **return_node); /******************************************************************************* * @@ -87,30 +82,28 @@ acpi_ns_search_parent_tree ( ******************************************************************************/ acpi_status -acpi_ns_search_node ( - u32 target_name, - struct acpi_namespace_node *node, - acpi_object_type type, - struct acpi_namespace_node **return_node) +acpi_ns_search_node(u32 target_name, + struct acpi_namespace_node *node, + acpi_object_type type, + struct acpi_namespace_node **return_node) { - struct acpi_namespace_node *next_node; - - - ACPI_FUNCTION_TRACE ("ns_search_node"); + struct acpi_namespace_node *next_node; + ACPI_FUNCTION_TRACE("ns_search_node"); #ifdef ACPI_DEBUG_OUTPUT if (ACPI_LV_NAMES & acpi_dbg_level) { - char *scope_name; + char *scope_name; - scope_name = acpi_ns_get_external_pathname (node); + scope_name = acpi_ns_get_external_pathname(node); if (scope_name) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Searching %s (%p) For [%4.4s] (%s)\n", - scope_name, node, (char *) &target_name, - acpi_ut_get_type_name (type))); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Searching %s (%p) For [%4.4s] (%s)\n", + scope_name, node, + (char *)&target_name, + acpi_ut_get_type_name(type))); - ACPI_MEM_FREE (scope_name); + ACPI_MEM_FREE(scope_name); } } #endif @@ -126,20 +119,26 @@ acpi_ns_search_node ( if (next_node->name.integer == target_name) { /* Resolve a control method alias if any */ - if (acpi_ns_get_type (next_node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { - next_node = ACPI_CAST_PTR (struct acpi_namespace_node, next_node->object); + if (acpi_ns_get_type(next_node) == + ACPI_TYPE_LOCAL_METHOD_ALIAS) { + next_node = + ACPI_CAST_PTR(struct acpi_namespace_node, + next_node->object); } /* * Found matching entry. */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", - (char *) &target_name, acpi_ut_get_type_name (next_node->type), - next_node, acpi_ut_get_node_name (node), node)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", + (char *)&target_name, + acpi_ut_get_type_name(next_node-> + type), + next_node, + acpi_ut_get_node_name(node), node)); *return_node = next_node; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* @@ -159,15 +158,14 @@ acpi_ns_search_node ( /* Searched entire namespace level, not found */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n", - (char *) &target_name, acpi_ut_get_type_name (type), - acpi_ut_get_node_name (node), node, node->child)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n", + (char *)&target_name, acpi_ut_get_type_name(type), + acpi_ut_get_node_name(node), node, node->child)); - return_ACPI_STATUS (AE_NOT_FOUND); + return_ACPI_STATUS(AE_NOT_FOUND); } - /******************************************************************************* * * FUNCTION: acpi_ns_search_parent_tree @@ -194,43 +192,42 @@ acpi_ns_search_node ( ******************************************************************************/ static acpi_status -acpi_ns_search_parent_tree ( - u32 target_name, - struct acpi_namespace_node *node, - acpi_object_type type, - struct acpi_namespace_node **return_node) +acpi_ns_search_parent_tree(u32 target_name, + struct acpi_namespace_node *node, + acpi_object_type type, + struct acpi_namespace_node **return_node) { - acpi_status status; - struct acpi_namespace_node *parent_node; + acpi_status status; + struct acpi_namespace_node *parent_node; + ACPI_FUNCTION_TRACE("ns_search_parent_tree"); - ACPI_FUNCTION_TRACE ("ns_search_parent_tree"); - - - parent_node = acpi_ns_get_parent_node (node); + parent_node = acpi_ns_get_parent_node(node); /* * If there is no parent (i.e., we are at the root) or type is "local", * we won't be searching the parent tree. */ if (!parent_node) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", - (char *) &target_name)); - return_ACPI_STATUS (AE_NOT_FOUND); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "[%4.4s] has no parent\n", + (char *)&target_name)); + return_ACPI_STATUS(AE_NOT_FOUND); } - if (acpi_ns_local (type)) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "[%4.4s] type [%s] must be local to this scope (no parent search)\n", - (char *) &target_name, acpi_ut_get_type_name (type))); - return_ACPI_STATUS (AE_NOT_FOUND); + if (acpi_ns_local(type)) { + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "[%4.4s] type [%s] must be local to this scope (no parent search)\n", + (char *)&target_name, + acpi_ut_get_type_name(type))); + return_ACPI_STATUS(AE_NOT_FOUND); } /* Search the parent tree */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Searching parent [%4.4s] for [%4.4s]\n", - acpi_ut_get_node_name (parent_node), (char *) &target_name)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "Searching parent [%4.4s] for [%4.4s]\n", + acpi_ut_get_node_name(parent_node), + (char *)&target_name)); /* * Search parents until target is found or we have backed up to the root @@ -241,25 +238,24 @@ acpi_ns_search_parent_tree ( * object type at this point, we only care about the existence of * the actual name we are searching for. Typechecking comes later. */ - status = acpi_ns_search_node (target_name, parent_node, - ACPI_TYPE_ANY, return_node); - if (ACPI_SUCCESS (status)) { - return_ACPI_STATUS (status); + status = acpi_ns_search_node(target_name, parent_node, + ACPI_TYPE_ANY, return_node); + if (ACPI_SUCCESS(status)) { + return_ACPI_STATUS(status); } /* * Not found here, go up another level * (until we reach the root) */ - parent_node = acpi_ns_get_parent_node (parent_node); + parent_node = acpi_ns_get_parent_node(parent_node); } /* Not found in parent tree */ - return_ACPI_STATUS (AE_NOT_FOUND); + return_ACPI_STATUS(AE_NOT_FOUND); } - /******************************************************************************* * * FUNCTION: acpi_ns_search_and_enter @@ -286,52 +282,46 @@ acpi_ns_search_parent_tree ( ******************************************************************************/ acpi_status -acpi_ns_search_and_enter ( - u32 target_name, - struct acpi_walk_state *walk_state, - struct acpi_namespace_node *node, - acpi_interpreter_mode interpreter_mode, - acpi_object_type type, - u32 flags, - struct acpi_namespace_node **return_node) +acpi_ns_search_and_enter(u32 target_name, + struct acpi_walk_state *walk_state, + struct acpi_namespace_node *node, + acpi_interpreter_mode interpreter_mode, + acpi_object_type type, + u32 flags, struct acpi_namespace_node **return_node) { - acpi_status status; - struct acpi_namespace_node *new_node; - - - ACPI_FUNCTION_TRACE ("ns_search_and_enter"); + acpi_status status; + struct acpi_namespace_node *new_node; + ACPI_FUNCTION_TRACE("ns_search_and_enter"); /* Parameter validation */ if (!node || !target_name || !return_node) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null param: Node %p Name %X return_node %p\n", - node, target_name, return_node)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Null param: Node %p Name %X return_node %p\n", + node, target_name, return_node)); - ACPI_REPORT_ERROR (("ns_search_and_enter: Null parameter\n")); - return_ACPI_STATUS (AE_BAD_PARAMETER); + ACPI_REPORT_ERROR(("ns_search_and_enter: Null parameter\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Name must consist of printable characters */ - if (!acpi_ut_valid_acpi_name (target_name)) { - ACPI_REPORT_ERROR (("ns_search_and_enter: Bad character in ACPI Name: %X\n", - target_name)); - return_ACPI_STATUS (AE_BAD_CHARACTER); + if (!acpi_ut_valid_acpi_name(target_name)) { + ACPI_REPORT_ERROR(("ns_search_and_enter: Bad character in ACPI Name: %X\n", target_name)); + return_ACPI_STATUS(AE_BAD_CHARACTER); } /* Try to find the name in the namespace level specified by the caller */ *return_node = ACPI_ENTRY_NOT_FOUND; - status = acpi_ns_search_node (target_name, node, type, return_node); + status = acpi_ns_search_node(target_name, node, type, return_node); if (status != AE_NOT_FOUND) { /* * If we found it AND the request specifies that a find is an error, * return the error */ - if ((status == AE_OK) && - (flags & ACPI_NS_ERROR_IF_FOUND)) { + if ((status == AE_OK) && (flags & ACPI_NS_ERROR_IF_FOUND)) { status = AE_ALREADY_EXISTS; } @@ -339,7 +329,7 @@ acpi_ns_search_and_enter ( * Either found it or there was an error * -- finished either way */ - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* @@ -351,14 +341,16 @@ acpi_ns_search_and_enter ( * and during the execution phase. */ if ((interpreter_mode != ACPI_IMODE_LOAD_PASS1) && - (flags & ACPI_NS_SEARCH_PARENT)) { + (flags & ACPI_NS_SEARCH_PARENT)) { /* * Not found at this level - search parent tree according to the * ACPI specification */ - status = acpi_ns_search_parent_tree (target_name, node, type, return_node); - if (ACPI_SUCCESS (status)) { - return_ACPI_STATUS (status); + status = + acpi_ns_search_parent_tree(target_name, node, type, + return_node); + if (ACPI_SUCCESS(status)) { + return_ACPI_STATUS(status); } } @@ -366,25 +358,24 @@ acpi_ns_search_and_enter ( * In execute mode, just search, never add names. Exit now. */ if (interpreter_mode == ACPI_IMODE_EXECUTE) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "%4.4s Not found in %p [Not adding]\n", - (char *) &target_name, node)); + ACPI_DEBUG_PRINT((ACPI_DB_NAMES, + "%4.4s Not found in %p [Not adding]\n", + (char *)&target_name, node)); - return_ACPI_STATUS (AE_NOT_FOUND); + return_ACPI_STATUS(AE_NOT_FOUND); } /* Create the new named object */ - new_node = acpi_ns_create_node (target_name); + new_node = acpi_ns_create_node(target_name); if (!new_node) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Install the new object into the parent's list of children */ - acpi_ns_install_node (walk_state, node, new_node, type); + acpi_ns_install_node(walk_state, node, new_node, type); *return_node = new_node; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c index c53b82e..ebec036 100644 --- a/drivers/acpi/namespace/nsutils.c +++ b/drivers/acpi/namespace/nsutils.c @@ -42,28 +42,21 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsutils") +ACPI_MODULE_NAME("nsutils") /* Local prototypes */ - -static u8 -acpi_ns_valid_path_separator ( - char sep); +static u8 acpi_ns_valid_path_separator(char sep); #ifdef ACPI_OBSOLETE_FUNCTIONS -acpi_name -acpi_ns_find_parent_name ( - struct acpi_namespace_node *node_to_search); +acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search); #endif - /******************************************************************************* * * FUNCTION: acpi_ns_report_error @@ -81,51 +74,45 @@ acpi_ns_find_parent_name ( ******************************************************************************/ void -acpi_ns_report_error ( - char *module_name, - u32 line_number, - u32 component_id, - char *internal_name, - acpi_status lookup_status) +acpi_ns_report_error(char *module_name, + u32 line_number, + u32 component_id, + char *internal_name, acpi_status lookup_status) { - acpi_status status; - char *name = NULL; - + acpi_status status; + char *name = NULL; - acpi_os_printf ("%8s-%04d: *** Error: Looking up ", - module_name, line_number); + acpi_os_printf("%8s-%04d: *** Error: Looking up ", + module_name, line_number); if (lookup_status == AE_BAD_CHARACTER) { /* There is a non-ascii character in the name */ - acpi_os_printf ("[0x%4.4X] (NON-ASCII)\n", - *(ACPI_CAST_PTR (u32, internal_name))); - } - else { + acpi_os_printf("[0x%4.4X] (NON-ASCII)\n", + *(ACPI_CAST_PTR(u32, internal_name))); + } else { /* Convert path to external format */ - status = acpi_ns_externalize_name (ACPI_UINT32_MAX, - internal_name, NULL, &name); + status = acpi_ns_externalize_name(ACPI_UINT32_MAX, + internal_name, NULL, &name); /* Print target name */ - if (ACPI_SUCCESS (status)) { - acpi_os_printf ("[%s]", name); - } - else { - acpi_os_printf ("[COULD NOT EXTERNALIZE NAME]"); + if (ACPI_SUCCESS(status)) { + acpi_os_printf("[%s]", name); + } else { + acpi_os_printf("[COULD NOT EXTERNALIZE NAME]"); } if (name) { - ACPI_MEM_FREE (name); + ACPI_MEM_FREE(name); } } - acpi_os_printf (" in namespace, %s\n", - acpi_format_exception (lookup_status)); + acpi_os_printf(" in namespace, %s\n", + acpi_format_exception(lookup_status)); } - /******************************************************************************* * * FUNCTION: acpi_ns_report_method_error @@ -145,34 +132,31 @@ acpi_ns_report_error ( ******************************************************************************/ void -acpi_ns_report_method_error ( - char *module_name, - u32 line_number, - u32 component_id, - char *message, - struct acpi_namespace_node *prefix_node, - char *path, - acpi_status method_status) +acpi_ns_report_method_error(char *module_name, + u32 line_number, + u32 component_id, + char *message, + struct acpi_namespace_node *prefix_node, + char *path, acpi_status method_status) { - acpi_status status; - struct acpi_namespace_node *node = prefix_node; - + acpi_status status; + struct acpi_namespace_node *node = prefix_node; if (path) { - status = acpi_ns_get_node_by_path (path, prefix_node, - ACPI_NS_NO_UPSEARCH, &node); - if (ACPI_FAILURE (status)) { - acpi_os_printf ("report_method_error: Could not get node\n"); + status = acpi_ns_get_node_by_path(path, prefix_node, + ACPI_NS_NO_UPSEARCH, &node); + if (ACPI_FAILURE(status)) { + acpi_os_printf + ("report_method_error: Could not get node\n"); return; } } - acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number); - acpi_ns_print_node_pathname (node, message); - acpi_os_printf (", %s\n", acpi_format_exception (method_status)); + acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number); + acpi_ns_print_node_pathname(node, message); + acpi_os_printf(", %s\n", acpi_format_exception(method_status)); } - /******************************************************************************* * * FUNCTION: acpi_ns_print_node_pathname @@ -186,16 +170,13 @@ acpi_ns_report_method_error ( ******************************************************************************/ void -acpi_ns_print_node_pathname ( - struct acpi_namespace_node *node, - char *message) +acpi_ns_print_node_pathname(struct acpi_namespace_node *node, char *message) { - struct acpi_buffer buffer; - acpi_status status; - + struct acpi_buffer buffer; + acpi_status status; if (!node) { - acpi_os_printf ("[NULL NAME]"); + acpi_os_printf("[NULL NAME]"); return; } @@ -203,18 +184,17 @@ acpi_ns_print_node_pathname ( buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; - status = acpi_ns_handle_to_pathname (node, &buffer); - if (ACPI_SUCCESS (status)) { + status = acpi_ns_handle_to_pathname(node, &buffer); + if (ACPI_SUCCESS(status)) { if (message) { - acpi_os_printf ("%s ", message); + acpi_os_printf("%s ", message); } - acpi_os_printf ("[%s] (Node %p)", (char *) buffer.pointer, node); - ACPI_MEM_FREE (buffer.pointer); + acpi_os_printf("[%s] (Node %p)", (char *)buffer.pointer, node); + ACPI_MEM_FREE(buffer.pointer); } } - /******************************************************************************* * * FUNCTION: acpi_ns_valid_root_prefix @@ -227,15 +207,12 @@ acpi_ns_print_node_pathname ( * ******************************************************************************/ -u8 -acpi_ns_valid_root_prefix ( - char prefix) +u8 acpi_ns_valid_root_prefix(char prefix) { return ((u8) (prefix == '\\')); } - /******************************************************************************* * * FUNCTION: acpi_ns_valid_path_separator @@ -248,15 +225,12 @@ acpi_ns_valid_root_prefix ( * ******************************************************************************/ -static u8 -acpi_ns_valid_path_separator ( - char sep) +static u8 acpi_ns_valid_path_separator(char sep) { return ((u8) (sep == '.')); } - /******************************************************************************* * * FUNCTION: acpi_ns_get_type @@ -269,22 +243,18 @@ acpi_ns_valid_path_separator ( * ******************************************************************************/ -acpi_object_type -acpi_ns_get_type ( - struct acpi_namespace_node *node) +acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node) { - ACPI_FUNCTION_TRACE ("ns_get_type"); - + ACPI_FUNCTION_TRACE("ns_get_type"); if (!node) { - ACPI_REPORT_WARNING (("ns_get_type: Null Node input pointer\n")); - return_VALUE (ACPI_TYPE_ANY); + ACPI_REPORT_WARNING(("ns_get_type: Null Node input pointer\n")); + return_VALUE(ACPI_TYPE_ANY); } - return_VALUE ((acpi_object_type) node->type); + return_VALUE((acpi_object_type) node->type); } - /******************************************************************************* * * FUNCTION: acpi_ns_local @@ -298,24 +268,20 @@ acpi_ns_get_type ( * ******************************************************************************/ -u32 -acpi_ns_local ( - acpi_object_type type) +u32 acpi_ns_local(acpi_object_type type) { - ACPI_FUNCTION_TRACE ("ns_local"); - + ACPI_FUNCTION_TRACE("ns_local"); - if (!acpi_ut_valid_object_type (type)) { + if (!acpi_ut_valid_object_type(type)) { /* Type code out of range */ - ACPI_REPORT_WARNING (("ns_local: Invalid Object Type\n")); - return_VALUE (ACPI_NS_NORMAL); + ACPI_REPORT_WARNING(("ns_local: Invalid Object Type\n")); + return_VALUE(ACPI_NS_NORMAL); } - return_VALUE ((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); + return_VALUE((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); } - /******************************************************************************* * * FUNCTION: acpi_ns_get_internal_name_length @@ -330,16 +296,12 @@ acpi_ns_local ( * ******************************************************************************/ -void -acpi_ns_get_internal_name_length ( - struct acpi_namestring_info *info) +void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info) { - char *next_external_char; - u32 i; - - - ACPI_FUNCTION_ENTRY (); + char *next_external_char; + u32 i; + ACPI_FUNCTION_ENTRY(); next_external_char = info->external_name; info->num_carats = 0; @@ -353,11 +315,10 @@ acpi_ns_get_internal_name_length ( * * strlen() + 1 covers the first name_seg, which has no path separator */ - if (acpi_ns_valid_root_prefix (next_external_char[0])) { + if (acpi_ns_valid_root_prefix(next_external_char[0])) { info->fully_qualified = TRUE; next_external_char++; - } - else { + } else { /* * Handle Carat prefixes */ @@ -375,19 +336,18 @@ acpi_ns_get_internal_name_length ( if (*next_external_char) { info->num_segments = 1; for (i = 0; next_external_char[i]; i++) { - if (acpi_ns_valid_path_separator (next_external_char[i])) { + if (acpi_ns_valid_path_separator(next_external_char[i])) { info->num_segments++; } } } info->length = (ACPI_NAME_SIZE * info->num_segments) + - 4 + info->num_carats; + 4 + info->num_carats; info->next_external_char = next_external_char; } - /******************************************************************************* * * FUNCTION: acpi_ns_build_internal_name @@ -401,19 +361,15 @@ acpi_ns_get_internal_name_length ( * ******************************************************************************/ -acpi_status -acpi_ns_build_internal_name ( - struct acpi_namestring_info *info) +acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info) { - u32 num_segments = info->num_segments; - char *internal_name = info->internal_name; - char *external_name = info->next_external_char; - char *result = NULL; - acpi_native_uint i; - - - ACPI_FUNCTION_TRACE ("ns_build_internal_name"); + u32 num_segments = info->num_segments; + char *internal_name = info->internal_name; + char *external_name = info->next_external_char; + char *result = NULL; + acpi_native_uint i; + ACPI_FUNCTION_TRACE("ns_build_internal_name"); /* Setup the correct prefixes, counts, and pointers */ @@ -422,18 +378,15 @@ acpi_ns_build_internal_name ( if (num_segments <= 1) { result = &internal_name[1]; - } - else if (num_segments == 2) { + } else if (num_segments == 2) { internal_name[1] = AML_DUAL_NAME_PREFIX; result = &internal_name[2]; - } - else { + } else { internal_name[1] = AML_MULTI_NAME_PREFIX_OP; - internal_name[2] = (char) num_segments; + internal_name[2] = (char)num_segments; result = &internal_name[3]; } - } - else { + } else { /* * Not fully qualified. * Handle Carats first, then append the name segments @@ -447,15 +400,14 @@ acpi_ns_build_internal_name ( if (num_segments <= 1) { result = &internal_name[i]; - } - else if (num_segments == 2) { + } else if (num_segments == 2) { internal_name[i] = AML_DUAL_NAME_PREFIX; - result = &internal_name[(acpi_native_uint) (i+1)]; - } - else { + result = &internal_name[(acpi_native_uint) (i + 1)]; + } else { internal_name[i] = AML_MULTI_NAME_PREFIX_OP; - internal_name[(acpi_native_uint) (i+1)] = (char) num_segments; - result = &internal_name[(acpi_native_uint) (i+2)]; + internal_name[(acpi_native_uint) (i + 1)] = + (char)num_segments; + result = &internal_name[(acpi_native_uint) (i + 2)]; } } @@ -463,25 +415,25 @@ acpi_ns_build_internal_name ( for (; num_segments; num_segments--) { for (i = 0; i < ACPI_NAME_SIZE; i++) { - if (acpi_ns_valid_path_separator (*external_name) || - (*external_name == 0)) { + if (acpi_ns_valid_path_separator(*external_name) || + (*external_name == 0)) { /* Pad the segment with underscore(s) if segment is short */ result[i] = '_'; - } - else { + } else { /* Convert the character to uppercase and save it */ - result[i] = (char) ACPI_TOUPPER ((int) *external_name); + result[i] = + (char)ACPI_TOUPPER((int)*external_name); external_name++; } } /* Now we must have a path separator, or the pathname is bad */ - if (!acpi_ns_valid_path_separator (*external_name) && - (*external_name != 0)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if (!acpi_ns_valid_path_separator(*external_name) && + (*external_name != 0)) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Move on the next segment */ @@ -495,18 +447,17 @@ acpi_ns_build_internal_name ( *result = 0; if (info->fully_qualified) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n", - internal_name, internal_name)); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n", - internal_name, internal_name)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Returning [%p] (abs) \"\\%s\"\n", + internal_name, internal_name)); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n", + internal_name, internal_name)); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ns_internalize_name @@ -522,51 +473,43 @@ acpi_ns_build_internal_name ( * *******************************************************************************/ -acpi_status -acpi_ns_internalize_name ( - char *external_name, - char **converted_name) +acpi_status acpi_ns_internalize_name(char *external_name, char **converted_name) { - char *internal_name; - struct acpi_namestring_info info; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ns_internalize_name"); + char *internal_name; + struct acpi_namestring_info info; + acpi_status status; + ACPI_FUNCTION_TRACE("ns_internalize_name"); - if ((!external_name) || - (*external_name == 0) || - (!converted_name)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if ((!external_name) || (*external_name == 0) || (!converted_name)) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Get the length of the new internal name */ info.external_name = external_name; - acpi_ns_get_internal_name_length (&info); + acpi_ns_get_internal_name_length(&info); /* We need a segment to store the internal name */ - internal_name = ACPI_MEM_CALLOCATE (info.length); + internal_name = ACPI_MEM_CALLOCATE(info.length); if (!internal_name) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Build the name */ info.internal_name = internal_name; - status = acpi_ns_build_internal_name (&info); - if (ACPI_FAILURE (status)) { - ACPI_MEM_FREE (internal_name); - return_ACPI_STATUS (status); + status = acpi_ns_build_internal_name(&info); + if (ACPI_FAILURE(status)) { + ACPI_MEM_FREE(internal_name); + return_ACPI_STATUS(status); } *converted_name = internal_name; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ns_externalize_name @@ -585,27 +528,21 @@ acpi_ns_internalize_name ( ******************************************************************************/ acpi_status -acpi_ns_externalize_name ( - u32 internal_name_length, - char *internal_name, - u32 *converted_name_length, - char **converted_name) +acpi_ns_externalize_name(u32 internal_name_length, + char *internal_name, + u32 * converted_name_length, char **converted_name) { - acpi_native_uint names_index = 0; - acpi_native_uint num_segments = 0; - acpi_native_uint required_length; - acpi_native_uint prefix_length = 0; - acpi_native_uint i = 0; - acpi_native_uint j = 0; - + acpi_native_uint names_index = 0; + acpi_native_uint num_segments = 0; + acpi_native_uint required_length; + acpi_native_uint prefix_length = 0; + acpi_native_uint i = 0; + acpi_native_uint j = 0; - ACPI_FUNCTION_TRACE ("ns_externalize_name"); + ACPI_FUNCTION_TRACE("ns_externalize_name"); - - if (!internal_name_length || - !internal_name || - !converted_name) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if (!internal_name_length || !internal_name || !converted_name) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* @@ -620,8 +557,7 @@ acpi_ns_externalize_name ( for (i = 0; i < internal_name_length; i++) { if (internal_name[i] == '^') { prefix_length = i + 1; - } - else { + } else { break; } } @@ -648,7 +584,8 @@ acpi_ns_externalize_name ( names_index = prefix_length + 2; num_segments = (acpi_native_uint) (u8) - internal_name[(acpi_native_uint) (prefix_length + 1)]; + internal_name[(acpi_native_uint) + (prefix_length + 1)]; break; case AML_DUAL_NAME_PREFIX: @@ -683,23 +620,23 @@ acpi_ns_externalize_name ( * punctuation ('.') between object names, plus the NULL terminator. */ required_length = prefix_length + (4 * num_segments) + - ((num_segments > 0) ? (num_segments - 1) : 0) + 1; + ((num_segments > 0) ? (num_segments - 1) : 0) + 1; /* * Check to see if we're still in bounds. If not, there's a problem * with internal_name (invalid format). */ if (required_length > internal_name_length) { - ACPI_REPORT_ERROR (("ns_externalize_name: Invalid internal name\n")); - return_ACPI_STATUS (AE_BAD_PATHNAME); + ACPI_REPORT_ERROR(("ns_externalize_name: Invalid internal name\n")); + return_ACPI_STATUS(AE_BAD_PATHNAME); } /* * Build converted_name */ - *converted_name = ACPI_MEM_CALLOCATE (required_length); + *converted_name = ACPI_MEM_CALLOCATE(required_length); if (!(*converted_name)) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } j = 0; @@ -725,10 +662,9 @@ acpi_ns_externalize_name ( *converted_name_length = (u32) required_length; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ns_map_handle_to_node @@ -745,13 +681,10 @@ acpi_ns_externalize_name ( * ******************************************************************************/ -struct acpi_namespace_node * -acpi_ns_map_handle_to_node ( - acpi_handle handle) +struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle) { - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_ENTRY(); /* * Simple implementation. @@ -766,14 +699,13 @@ acpi_ns_map_handle_to_node ( /* We can at least attempt to verify the handle */ - if (ACPI_GET_DESCRIPTOR_TYPE (handle) != ACPI_DESC_TYPE_NAMED) { + if (ACPI_GET_DESCRIPTOR_TYPE(handle) != ACPI_DESC_TYPE_NAMED) { return (NULL); } - return ((struct acpi_namespace_node *) handle); + return ((struct acpi_namespace_node *)handle); } - /******************************************************************************* * * FUNCTION: acpi_ns_convert_entry_to_handle @@ -786,18 +718,14 @@ acpi_ns_map_handle_to_node ( * ******************************************************************************/ -acpi_handle -acpi_ns_convert_entry_to_handle ( - struct acpi_namespace_node *node) +acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node) { - /* * Simple implementation for now; */ return ((acpi_handle) node); - /* Example future implementation --------------------- if (!Node) @@ -810,12 +738,10 @@ acpi_ns_convert_entry_to_handle ( return (ACPI_ROOT_OBJECT); } - return ((acpi_handle) Node); ------------------------------------------------------*/ } - /******************************************************************************* * * FUNCTION: acpi_ns_terminate @@ -828,42 +754,37 @@ acpi_ns_convert_entry_to_handle ( * ******************************************************************************/ -void -acpi_ns_terminate ( - void) +void acpi_ns_terminate(void) { - union acpi_operand_object *obj_desc; - - - ACPI_FUNCTION_TRACE ("ns_terminate"); + union acpi_operand_object *obj_desc; + ACPI_FUNCTION_TRACE("ns_terminate"); /* * 1) Free the entire namespace -- all nodes and objects * * Delete all object descriptors attached to namepsace nodes */ - acpi_ns_delete_namespace_subtree (acpi_gbl_root_node); + acpi_ns_delete_namespace_subtree(acpi_gbl_root_node); /* Detach any objects attached to the root */ - obj_desc = acpi_ns_get_attached_object (acpi_gbl_root_node); + obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node); if (obj_desc) { - acpi_ns_detach_object (acpi_gbl_root_node); + acpi_ns_detach_object(acpi_gbl_root_node); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n")); /* * 2) Now we can delete the ACPI tables */ - acpi_tb_delete_all_tables (); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); + acpi_tb_delete_all_tables(); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ns_opens_scope @@ -875,24 +796,21 @@ acpi_ns_terminate ( * ******************************************************************************/ -u32 -acpi_ns_opens_scope ( - acpi_object_type type) +u32 acpi_ns_opens_scope(acpi_object_type type) { - ACPI_FUNCTION_TRACE_STR ("ns_opens_scope", acpi_ut_get_type_name (type)); - + ACPI_FUNCTION_TRACE_STR("ns_opens_scope", acpi_ut_get_type_name(type)); - if (!acpi_ut_valid_object_type (type)) { + if (!acpi_ut_valid_object_type(type)) { /* type code out of range */ - ACPI_REPORT_WARNING (("ns_opens_scope: Invalid Object Type %X\n", type)); - return_VALUE (ACPI_NS_NORMAL); + ACPI_REPORT_WARNING(("ns_opens_scope: Invalid Object Type %X\n", + type)); + return_VALUE(ACPI_NS_NORMAL); } - return_VALUE (((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); + return_VALUE(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); } - /******************************************************************************* * * FUNCTION: acpi_ns_get_node_by_path @@ -916,33 +834,29 @@ acpi_ns_opens_scope ( ******************************************************************************/ acpi_status -acpi_ns_get_node_by_path ( - char *pathname, - struct acpi_namespace_node *start_node, - u32 flags, - struct acpi_namespace_node **return_node) +acpi_ns_get_node_by_path(char *pathname, + struct acpi_namespace_node *start_node, + u32 flags, struct acpi_namespace_node **return_node) { - union acpi_generic_state scope_info; - acpi_status status; - char *internal_path = NULL; - - - ACPI_FUNCTION_TRACE_PTR ("ns_get_node_by_path", pathname); + union acpi_generic_state scope_info; + acpi_status status; + char *internal_path = NULL; + ACPI_FUNCTION_TRACE_PTR("ns_get_node_by_path", pathname); if (pathname) { /* Convert path to internal representation */ - status = acpi_ns_internalize_name (pathname, &internal_path); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ns_internalize_name(pathname, &internal_path); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Must lock namespace during lookup */ - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -952,25 +866,25 @@ acpi_ns_get_node_by_path ( /* Lookup the name in the namespace */ - status = acpi_ns_lookup (&scope_info, internal_path, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - (flags | ACPI_NS_DONT_OPEN_SCOPE), - NULL, return_node); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n", - internal_path, acpi_format_exception (status))); + status = acpi_ns_lookup(&scope_info, internal_path, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + (flags | ACPI_NS_DONT_OPEN_SCOPE), + NULL, return_node); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s, %s\n", + internal_path, + acpi_format_exception(status))); } - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); -cleanup: + cleanup: if (internal_path) { - ACPI_MEM_FREE (internal_path); + ACPI_MEM_FREE(internal_path); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ns_get_parent_node @@ -983,12 +897,10 @@ cleanup: * ******************************************************************************/ -struct acpi_namespace_node * -acpi_ns_get_parent_node ( - struct acpi_namespace_node *node) +struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node + *node) { - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_ENTRY(); if (!node) { return (NULL); @@ -1006,7 +918,6 @@ acpi_ns_get_parent_node ( return (node->peer); } - /******************************************************************************* * * FUNCTION: acpi_ns_get_next_valid_node @@ -1021,9 +932,9 @@ acpi_ns_get_parent_node ( * ******************************************************************************/ -struct acpi_namespace_node * -acpi_ns_get_next_valid_node ( - struct acpi_namespace_node *node) +struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct + acpi_namespace_node + *node) { /* If we are at the end of this peer list, return NULL */ @@ -1037,7 +948,6 @@ acpi_ns_get_next_valid_node ( return (node->peer); } - #ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * @@ -1053,38 +963,36 @@ acpi_ns_get_next_valid_node ( * ******************************************************************************/ -acpi_name -acpi_ns_find_parent_name ( - struct acpi_namespace_node *child_node) +acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node * child_node) { - struct acpi_namespace_node *parent_node; - - - ACPI_FUNCTION_TRACE ("ns_find_parent_name"); + struct acpi_namespace_node *parent_node; + ACPI_FUNCTION_TRACE("ns_find_parent_name"); if (child_node) { /* Valid entry. Get the parent Node */ - parent_node = acpi_ns_get_parent_node (child_node); + parent_node = acpi_ns_get_parent_node(child_node); if (parent_node) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Parent of %p [%4.4s] is %p [%4.4s]\n", - child_node, acpi_ut_get_node_name (child_node), - parent_node, acpi_ut_get_node_name (parent_node))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Parent of %p [%4.4s] is %p [%4.4s]\n", + child_node, + acpi_ut_get_node_name(child_node), + parent_node, + acpi_ut_get_node_name(parent_node))); if (parent_node->name.integer) { - return_VALUE ((acpi_name) parent_node->name.integer); + return_VALUE((acpi_name) parent_node->name. + integer); } } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Unable to find parent of %p (%4.4s)\n", - child_node, acpi_ut_get_node_name (child_node))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Unable to find parent of %p (%4.4s)\n", + child_node, + acpi_ut_get_node_name(child_node))); } - return_VALUE (ACPI_UNKNOWN_NAME); + return_VALUE(ACPI_UNKNOWN_NAME); } #endif - - diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c index f9a7277..5f164c0 100644 --- a/drivers/acpi/namespace/nswalk.c +++ b/drivers/acpi/namespace/nswalk.c @@ -41,14 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nswalk") - +ACPI_MODULE_NAME("nswalk") /******************************************************************************* * @@ -68,18 +65,15 @@ * within Scope is returned. * ******************************************************************************/ - -struct acpi_namespace_node * -acpi_ns_get_next_node ( - acpi_object_type type, - struct acpi_namespace_node *parent_node, - struct acpi_namespace_node *child_node) +struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type, + struct acpi_namespace_node + *parent_node, + struct acpi_namespace_node + *child_node) { - struct acpi_namespace_node *next_node = NULL; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_namespace_node *next_node = NULL; + ACPI_FUNCTION_ENTRY(); if (!child_node) { /* It's really the parent's _scope_ that we want */ @@ -92,7 +86,7 @@ acpi_ns_get_next_node ( else { /* Start search at the NEXT node */ - next_node = acpi_ns_get_next_valid_node (child_node); + next_node = acpi_ns_get_next_valid_node(child_node); } /* If any type is OK, we are done */ @@ -114,7 +108,7 @@ acpi_ns_get_next_node ( /* Otherwise, move on to the next node */ - next_node = acpi_ns_get_next_valid_node (next_node); + next_node = acpi_ns_get_next_valid_node(next_node); } /* Not found */ @@ -122,7 +116,6 @@ acpi_ns_get_next_node ( return (NULL); } - /******************************************************************************* * * FUNCTION: acpi_ns_walk_namespace @@ -154,25 +147,21 @@ acpi_ns_get_next_node ( ******************************************************************************/ acpi_status -acpi_ns_walk_namespace ( - acpi_object_type type, - acpi_handle start_node, - u32 max_depth, - u8 unlock_before_callback, - acpi_walk_callback user_function, - void *context, - void **return_value) +acpi_ns_walk_namespace(acpi_object_type type, + acpi_handle start_node, + u32 max_depth, + u8 unlock_before_callback, + acpi_walk_callback user_function, + void *context, void **return_value) { - acpi_status status; - acpi_status mutex_status; - struct acpi_namespace_node *child_node; - struct acpi_namespace_node *parent_node; - acpi_object_type child_type; - u32 level; - - - ACPI_FUNCTION_TRACE ("ns_walk_namespace"); + acpi_status status; + acpi_status mutex_status; + struct acpi_namespace_node *child_node; + struct acpi_namespace_node *parent_node; + acpi_object_type child_type; + u32 level; + ACPI_FUNCTION_TRACE("ns_walk_namespace"); /* Special case for the namespace Root Node */ @@ -183,9 +172,9 @@ acpi_ns_walk_namespace ( /* Null child means "get first node" */ parent_node = start_node; - child_node = NULL; - child_type = ACPI_TYPE_ANY; - level = 1; + child_node = NULL; + child_type = ACPI_TYPE_ANY; + level = 1; /* * Traverse the tree of nodes until we bubble back up to where we @@ -196,7 +185,9 @@ acpi_ns_walk_namespace ( /* Get the next node in this scope. Null if not found */ status = AE_OK; - child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node, child_node); + child_node = + acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node, + child_node); if (child_node) { /* * Found node, Get the type if we are not @@ -212,19 +203,25 @@ acpi_ns_walk_namespace ( * callback function */ if (unlock_before_callback) { - mutex_status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (mutex_status)) { - return_ACPI_STATUS (mutex_status); + mutex_status = + acpi_ut_release_mutex + (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(mutex_status)) { + return_ACPI_STATUS + (mutex_status); } } - status = user_function (child_node, level, - context, return_value); + status = user_function(child_node, level, + context, return_value); if (unlock_before_callback) { - mutex_status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (mutex_status)) { - return_ACPI_STATUS (mutex_status); + mutex_status = + acpi_ut_acquire_mutex + (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(mutex_status)) { + return_ACPI_STATUS + (mutex_status); } } @@ -239,13 +236,13 @@ acpi_ns_walk_namespace ( /* Exit now, with OK status */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); default: /* All others are valid exceptions */ - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } } @@ -258,7 +255,8 @@ acpi_ns_walk_namespace ( * maximum depth has been reached. */ if ((level < max_depth) && (status != AE_CTRL_DEPTH)) { - if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) { + if (acpi_ns_get_next_node + (ACPI_TYPE_ANY, child_node, NULL)) { /* * There is at least one child of this * node, visit the onde @@ -268,8 +266,7 @@ acpi_ns_walk_namespace ( child_node = NULL; } } - } - else { + } else { /* * No more children of this node (acpi_ns_get_next_node * failed), go back upwards in the namespace tree to @@ -277,13 +274,11 @@ acpi_ns_walk_namespace ( */ level--; child_node = parent_node; - parent_node = acpi_ns_get_parent_node (parent_node); + parent_node = acpi_ns_get_parent_node(parent_node); } } /* Complete walk, not terminated by user function */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - - diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c index 12ea202..c07b046 100644 --- a/drivers/acpi/namespace/nsxfeval.c +++ b/drivers/acpi/namespace/nsxfeval.c @@ -48,10 +48,8 @@ #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsxfeval") - +ACPI_MODULE_NAME("nsxfeval") /******************************************************************************* * @@ -73,27 +71,23 @@ * be valid (non-null) * ******************************************************************************/ - #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_evaluate_object_typed ( - acpi_handle handle, - acpi_string pathname, - struct acpi_object_list *external_params, - struct acpi_buffer *return_buffer, - acpi_object_type return_type) +acpi_evaluate_object_typed(acpi_handle handle, + acpi_string pathname, + struct acpi_object_list *external_params, + struct acpi_buffer *return_buffer, + acpi_object_type return_type) { - acpi_status status; - u8 must_free = FALSE; - - - ACPI_FUNCTION_TRACE ("acpi_evaluate_object_typed"); + acpi_status status; + u8 must_free = FALSE; + ACPI_FUNCTION_TRACE("acpi_evaluate_object_typed"); /* Return buffer must be valid */ if (!return_buffer) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } if (return_buffer->length == ACPI_ALLOCATE_BUFFER) { @@ -102,51 +96,52 @@ acpi_evaluate_object_typed ( /* Evaluate the object */ - status = acpi_evaluate_object (handle, pathname, external_params, return_buffer); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_evaluate_object(handle, pathname, external_params, + return_buffer); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Type ANY means "don't care" */ if (return_type == ACPI_TYPE_ANY) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } if (return_buffer->length == 0) { /* Error because caller specifically asked for a return value */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "No return value\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No return value\n")); - return_ACPI_STATUS (AE_NULL_OBJECT); + return_ACPI_STATUS(AE_NULL_OBJECT); } /* Examine the object type returned from evaluate_object */ - if (((union acpi_object *) return_buffer->pointer)->type == return_type) { - return_ACPI_STATUS (AE_OK); + if (((union acpi_object *)return_buffer->pointer)->type == return_type) { + return_ACPI_STATUS(AE_OK); } /* Return object type does not match requested type */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Incorrect return type [%s] requested [%s]\n", - acpi_ut_get_type_name (((union acpi_object *) return_buffer->pointer)->type), - acpi_ut_get_type_name (return_type))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Incorrect return type [%s] requested [%s]\n", + acpi_ut_get_type_name(((union acpi_object *) + return_buffer->pointer)->type), + acpi_ut_get_type_name(return_type))); if (must_free) { /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ - acpi_os_free (return_buffer->pointer); + acpi_os_free(return_buffer->pointer); return_buffer->pointer = NULL; } return_buffer->length = 0; - return_ACPI_STATUS (AE_TYPE); + return_ACPI_STATUS(AE_TYPE); } -#endif /* ACPI_FUTURE_USAGE */ - +#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * @@ -169,21 +164,18 @@ acpi_evaluate_object_typed ( ******************************************************************************/ acpi_status -acpi_evaluate_object ( - acpi_handle handle, - acpi_string pathname, - struct acpi_object_list *external_params, - struct acpi_buffer *return_buffer) +acpi_evaluate_object(acpi_handle handle, + acpi_string pathname, + struct acpi_object_list *external_params, + struct acpi_buffer *return_buffer) { - acpi_status status; - acpi_status status2; - struct acpi_parameter_info info; - acpi_size buffer_space_needed; - u32 i; - - - ACPI_FUNCTION_TRACE ("acpi_evaluate_object"); + acpi_status status; + acpi_status status2; + struct acpi_parameter_info info; + acpi_size buffer_space_needed; + u32 i; + ACPI_FUNCTION_TRACE("acpi_evaluate_object"); info.node = handle; info.parameters = NULL; @@ -200,11 +192,11 @@ acpi_evaluate_object ( * Allocate a new parameter block for the internal objects * Add 1 to count to allow for null terminated internal list */ - info.parameters = ACPI_MEM_CALLOCATE ( - ((acpi_size) external_params->count + 1) * - sizeof (void *)); + info.parameters = ACPI_MEM_CALLOCATE(((acpi_size) + external_params->count + + 1) * sizeof(void *)); if (!info.parameters) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* @@ -212,48 +204,47 @@ acpi_evaluate_object ( * internal object */ for (i = 0; i < external_params->count; i++) { - status = acpi_ut_copy_eobject_to_iobject (&external_params->pointer[i], - &info.parameters[i]); - if (ACPI_FAILURE (status)) { - acpi_ut_delete_internal_object_list (info.parameters); - return_ACPI_STATUS (status); + status = + acpi_ut_copy_eobject_to_iobject(&external_params-> + pointer[i], + &info. + parameters[i]); + if (ACPI_FAILURE(status)) { + acpi_ut_delete_internal_object_list(info. + parameters); + return_ACPI_STATUS(status); } } info.parameters[external_params->count] = NULL; } - /* * Three major cases: * 1) Fully qualified pathname * 2) No handle, not fully qualified pathname (error) * 3) Valid handle */ - if ((pathname) && - (acpi_ns_valid_root_prefix (pathname[0]))) { + if ((pathname) && (acpi_ns_valid_root_prefix(pathname[0]))) { /* * The path is fully qualified, just evaluate by name */ - status = acpi_ns_evaluate_by_name (pathname, &info); - } - else if (!handle) { + status = acpi_ns_evaluate_by_name(pathname, &info); + } else if (!handle) { /* * A handle is optional iff a fully qualified pathname * is specified. Since we've already handled fully * qualified names above, this is an error */ if (!pathname) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Both Handle and Pathname are NULL\n")); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Handle is NULL and Pathname is relative\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Both Handle and Pathname are NULL\n")); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Handle is NULL and Pathname is relative\n")); } status = AE_BAD_PARAMETER; - } - else { + } else { /* * We get here if we have a handle -- and if we have a * pathname it is relative. The handle will be validated @@ -264,17 +255,15 @@ acpi_evaluate_object ( * The null pathname case means the handle is for * the actual object to be evaluated */ - status = acpi_ns_evaluate_by_handle (&info); - } - else { - /* - * Both a Handle and a relative Pathname - */ - status = acpi_ns_evaluate_relative (pathname, &info); + status = acpi_ns_evaluate_by_handle(&info); + } else { + /* + * Both a Handle and a relative Pathname + */ + status = acpi_ns_evaluate_relative(pathname, &info); } } - /* * If we are expecting a return value, and all went well above, * copy the return value to an external object. @@ -282,9 +271,9 @@ acpi_evaluate_object ( if (return_buffer) { if (!info.return_object) { return_buffer->length = 0; - } - else { - if (ACPI_GET_DESCRIPTOR_TYPE (info.return_object) == ACPI_DESC_TYPE_NAMED) { + } else { + if (ACPI_GET_DESCRIPTOR_TYPE(info.return_object) == + ACPI_DESC_TYPE_NAMED) { /* * If we received a NS Node as a return object, this means that * the object we are evaluating has nothing interesting to @@ -294,37 +283,43 @@ acpi_evaluate_object ( * support for various types at a later date if necessary. */ status = AE_TYPE; - info.return_object = NULL; /* No need to delete a NS Node */ + info.return_object = NULL; /* No need to delete a NS Node */ return_buffer->length = 0; } - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { /* * Find out how large a buffer is needed * to contain the returned object */ - status = acpi_ut_get_object_size (info.return_object, - &buffer_space_needed); - if (ACPI_SUCCESS (status)) { + status = + acpi_ut_get_object_size(info.return_object, + &buffer_space_needed); + if (ACPI_SUCCESS(status)) { /* Validate/Allocate/Clear caller buffer */ - status = acpi_ut_initialize_buffer (return_buffer, - buffer_space_needed); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_initialize_buffer + (return_buffer, + buffer_space_needed); + if (ACPI_FAILURE(status)) { /* * Caller's buffer is too small or a new one can't be allocated */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Needed buffer size %X, %s\n", - (u32) buffer_space_needed, - acpi_format_exception (status))); - } - else { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Needed buffer size %X, %s\n", + (u32) + buffer_space_needed, + acpi_format_exception + (status))); + } else { /* * We have enough space for the object, build it */ - status = acpi_ut_copy_iobject_to_eobject (info.return_object, - return_buffer); + status = + acpi_ut_copy_iobject_to_eobject + (info.return_object, + return_buffer); } } } @@ -336,14 +331,14 @@ acpi_evaluate_object ( * Delete the internal return object. NOTE: Interpreter * must be locked to avoid race condition. */ - status2 = acpi_ex_enter_interpreter (); - if (ACPI_SUCCESS (status2)) { + status2 = acpi_ex_enter_interpreter(); + if (ACPI_SUCCESS(status2)) { /* * Delete the internal return object. (Or at least * decrement the reference count by one) */ - acpi_ut_remove_reference (info.return_object); - acpi_ex_exit_interpreter (); + acpi_ut_remove_reference(info.return_object); + acpi_ex_exit_interpreter(); } } @@ -353,13 +348,13 @@ acpi_evaluate_object ( if (info.parameters) { /* Free the allocated parameter block */ - acpi_ut_delete_internal_object_list (info.parameters); + acpi_ut_delete_internal_object_list(info.parameters); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_evaluate_object); +EXPORT_SYMBOL(acpi_evaluate_object); /******************************************************************************* * @@ -392,26 +387,20 @@ EXPORT_SYMBOL(acpi_evaluate_object); ******************************************************************************/ acpi_status -acpi_walk_namespace ( - acpi_object_type type, - acpi_handle start_object, - u32 max_depth, - acpi_walk_callback user_function, - void *context, - void **return_value) +acpi_walk_namespace(acpi_object_type type, + acpi_handle start_object, + u32 max_depth, + acpi_walk_callback user_function, + void *context, void **return_value) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_walk_namespace"); + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_walk_namespace"); /* Parameter validation */ - if ((type > ACPI_TYPE_EXTERNAL_MAX) || - (!max_depth) || - (!user_function)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if ((type > ACPI_TYPE_EXTERNAL_MAX) || (!max_depth) || (!user_function)) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* @@ -420,20 +409,20 @@ acpi_walk_namespace ( * to the user function - since this function * must be allowed to make Acpi calls itself. */ - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_ns_walk_namespace (type, start_object, max_depth, - ACPI_NS_WALK_UNLOCK, - user_function, context, return_value); + status = acpi_ns_walk_namespace(type, start_object, max_depth, + ACPI_NS_WALK_UNLOCK, + user_function, context, return_value); - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (status); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_walk_namespace); +EXPORT_SYMBOL(acpi_walk_namespace); /******************************************************************************* * @@ -450,29 +439,26 @@ EXPORT_SYMBOL(acpi_walk_namespace); ******************************************************************************/ static acpi_status -acpi_ns_get_device_callback ( - acpi_handle obj_handle, - u32 nesting_level, - void *context, - void **return_value) +acpi_ns_get_device_callback(acpi_handle obj_handle, + u32 nesting_level, + void *context, void **return_value) { - struct acpi_get_devices_info *info = context; - acpi_status status; - struct acpi_namespace_node *node; - u32 flags; - struct acpi_device_id hid; + struct acpi_get_devices_info *info = context; + acpi_status status; + struct acpi_namespace_node *node; + u32 flags; + struct acpi_device_id hid; struct acpi_compatible_id_list *cid; - acpi_native_uint i; - + acpi_native_uint i; - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } - node = acpi_ns_map_handle_to_node (obj_handle); - status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + node = acpi_ns_map_handle_to_node(obj_handle); + status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } @@ -482,8 +468,8 @@ acpi_ns_get_device_callback ( /* Run _STA to determine if device is present */ - status = acpi_ut_execute_STA (node, &flags); - if (ACPI_FAILURE (status)) { + status = acpi_ut_execute_STA(node, &flags); + if (ACPI_FAILURE(status)) { return (AE_CTRL_DEPTH); } @@ -496,44 +482,43 @@ acpi_ns_get_device_callback ( /* Filter based on device HID & CID */ if (info->hid != NULL) { - status = acpi_ut_execute_HID (node, &hid); + status = acpi_ut_execute_HID(node, &hid); if (status == AE_NOT_FOUND) { return (AE_OK); - } - else if (ACPI_FAILURE (status)) { + } else if (ACPI_FAILURE(status)) { return (AE_CTRL_DEPTH); } - if (ACPI_STRNCMP (hid.value, info->hid, sizeof (hid.value)) != 0) { + if (ACPI_STRNCMP(hid.value, info->hid, sizeof(hid.value)) != 0) { /* Get the list of Compatible IDs */ - status = acpi_ut_execute_CID (node, &cid); + status = acpi_ut_execute_CID(node, &cid); if (status == AE_NOT_FOUND) { return (AE_OK); - } - else if (ACPI_FAILURE (status)) { + } else if (ACPI_FAILURE(status)) { return (AE_CTRL_DEPTH); } /* Walk the CID list */ for (i = 0; i < cid->count; i++) { - if (ACPI_STRNCMP (cid->id[i].value, info->hid, - sizeof (struct acpi_compatible_id)) != 0) { - ACPI_MEM_FREE (cid); + if (ACPI_STRNCMP(cid->id[i].value, info->hid, + sizeof(struct + acpi_compatible_id)) != + 0) { + ACPI_MEM_FREE(cid); return (AE_OK); } } - ACPI_MEM_FREE (cid); + ACPI_MEM_FREE(cid); } } - status = info->user_function (obj_handle, nesting_level, info->context, - return_value); + status = info->user_function(obj_handle, nesting_level, info->context, + return_value); return (status); } - /******************************************************************************* * * FUNCTION: acpi_get_devices @@ -560,32 +545,28 @@ acpi_ns_get_device_callback ( ******************************************************************************/ acpi_status -acpi_get_devices ( - char *HID, - acpi_walk_callback user_function, - void *context, - void **return_value) +acpi_get_devices(char *HID, + acpi_walk_callback user_function, + void *context, void **return_value) { - acpi_status status; - struct acpi_get_devices_info info; - - - ACPI_FUNCTION_TRACE ("acpi_get_devices"); + acpi_status status; + struct acpi_get_devices_info info; + ACPI_FUNCTION_TRACE("acpi_get_devices"); /* Parameter validation */ if (!user_function) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* * We're going to call their callback from OUR callback, so we need * to know what it is, and their context parameter. */ - info.context = context; + info.context = context; info.user_function = user_function; - info.hid = HID; + info.hid = HID; /* * Lock the namespace around the walk. @@ -593,22 +574,22 @@ acpi_get_devices ( * to the user function - since this function * must be allowed to make Acpi calls itself. */ - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, - ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, - acpi_ns_get_device_callback, &info, - return_value); + status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, + ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, + acpi_ns_get_device_callback, &info, + return_value); - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (status); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_devices); +EXPORT_SYMBOL(acpi_get_devices); /******************************************************************************* * @@ -625,44 +606,38 @@ EXPORT_SYMBOL(acpi_get_devices); ******************************************************************************/ acpi_status -acpi_attach_data ( - acpi_handle obj_handle, - acpi_object_handler handler, - void *data) +acpi_attach_data(acpi_handle obj_handle, + acpi_object_handler handler, void *data) { - struct acpi_namespace_node *node; - acpi_status status; - + struct acpi_namespace_node *node; + acpi_status status; /* Parameter validation */ - if (!obj_handle || - !handler || - !data) { + if (!obj_handle || !handler || !data) { return (AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } /* Convert and validate the handle */ - node = acpi_ns_map_handle_to_node (obj_handle); + node = acpi_ns_map_handle_to_node(obj_handle); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } - status = acpi_ns_attach_data (node, handler, data); + status = acpi_ns_attach_data(node, handler, data); -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return (status); } - /******************************************************************************* * * FUNCTION: acpi_detach_data @@ -677,42 +652,37 @@ unlock_and_exit: ******************************************************************************/ acpi_status -acpi_detach_data ( - acpi_handle obj_handle, - acpi_object_handler handler) +acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler) { - struct acpi_namespace_node *node; - acpi_status status; - + struct acpi_namespace_node *node; + acpi_status status; /* Parameter validation */ - if (!obj_handle || - !handler) { + if (!obj_handle || !handler) { return (AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } /* Convert and validate the handle */ - node = acpi_ns_map_handle_to_node (obj_handle); + node = acpi_ns_map_handle_to_node(obj_handle); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } - status = acpi_ns_detach_data (node, handler); + status = acpi_ns_detach_data(node, handler); -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return (status); } - /******************************************************************************* * * FUNCTION: acpi_get_data @@ -728,41 +698,33 @@ unlock_and_exit: ******************************************************************************/ acpi_status -acpi_get_data ( - acpi_handle obj_handle, - acpi_object_handler handler, - void **data) +acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data) { - struct acpi_namespace_node *node; - acpi_status status; - + struct acpi_namespace_node *node; + acpi_status status; /* Parameter validation */ - if (!obj_handle || - !handler || - !data) { + if (!obj_handle || !handler || !data) { return (AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } /* Convert and validate the handle */ - node = acpi_ns_map_handle_to_node (obj_handle); + node = acpi_ns_map_handle_to_node(obj_handle); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } - status = acpi_ns_get_attached_data (node, handler, data); + status = acpi_ns_get_attached_data(node, handler, data); -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return (status); } - - diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c index 8d09791..6b5f8d4 100644 --- a/drivers/acpi/namespace/nsxfname.c +++ b/drivers/acpi/namespace/nsxfname.c @@ -47,10 +47,8 @@ #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsxfname") - +ACPI_MODULE_NAME("nsxfname") /****************************************************************************** * @@ -69,20 +67,15 @@ * namespace handle. * ******************************************************************************/ - acpi_status -acpi_get_handle ( - acpi_handle parent, - acpi_string pathname, - acpi_handle *ret_handle) +acpi_get_handle(acpi_handle parent, + acpi_string pathname, acpi_handle * ret_handle) { - acpi_status status; - struct acpi_namespace_node *node = NULL; - struct acpi_namespace_node *prefix_node = NULL; - - - ACPI_FUNCTION_ENTRY (); + acpi_status status; + struct acpi_namespace_node *node = NULL; + struct acpi_namespace_node *prefix_node = NULL; + ACPI_FUNCTION_ENTRY(); /* Parameter Validation */ @@ -93,45 +86,47 @@ acpi_get_handle ( /* Convert a parent handle to a prefix node */ if (parent) { - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } - prefix_node = acpi_ns_map_handle_to_node (parent); + prefix_node = acpi_ns_map_handle_to_node(parent); if (!prefix_node) { - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return (AE_BAD_PARAMETER); } - status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } } /* Special case for root, since we can't search for it */ - if (ACPI_STRCMP (pathname, ACPI_NS_ROOT_PATH) == 0) { - *ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_node); + if (ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH) == 0) { + *ret_handle = + acpi_ns_convert_entry_to_handle(acpi_gbl_root_node); return (AE_OK); } /* * Find the Node and convert to a handle */ - status = acpi_ns_get_node_by_path (pathname, prefix_node, ACPI_NS_NO_UPSEARCH, - &node); + status = + acpi_ns_get_node_by_path(pathname, prefix_node, ACPI_NS_NO_UPSEARCH, + &node); *ret_handle = NULL; - if (ACPI_SUCCESS (status)) { - *ret_handle = acpi_ns_convert_entry_to_handle (node); + if (ACPI_SUCCESS(status)) { + *ret_handle = acpi_ns_convert_entry_to_handle(node); } return (status); } -EXPORT_SYMBOL(acpi_get_handle); +EXPORT_SYMBOL(acpi_get_handle); /****************************************************************************** * @@ -150,14 +145,10 @@ EXPORT_SYMBOL(acpi_get_handle); ******************************************************************************/ acpi_status -acpi_get_name ( - acpi_handle handle, - u32 name_type, - struct acpi_buffer *buffer) +acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer) { - acpi_status status; - struct acpi_namespace_node *node; - + acpi_status status; + struct acpi_namespace_node *node; /* Parameter validation */ @@ -165,15 +156,15 @@ acpi_get_name ( return (AE_BAD_PARAMETER); } - status = acpi_ut_validate_buffer (buffer); - if (ACPI_FAILURE (status)) { + status = acpi_ut_validate_buffer(buffer); + if (ACPI_FAILURE(status)) { return (status); } if (name_type == ACPI_FULL_PATHNAME) { /* Get the full pathname (From the namespace root) */ - status = acpi_ns_handle_to_pathname (handle, buffer); + status = acpi_ns_handle_to_pathname(handle, buffer); return (status); } @@ -181,12 +172,12 @@ acpi_get_name ( * Wants the single segment ACPI name. * Validate handle and convert to a namespace Node */ - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } - node = acpi_ns_map_handle_to_node (handle); + node = acpi_ns_map_handle_to_node(handle); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -194,26 +185,25 @@ acpi_get_name ( /* Validate/Allocate/Clear caller buffer */ - status = acpi_ut_initialize_buffer (buffer, ACPI_PATH_SEGMENT_LENGTH); - if (ACPI_FAILURE (status)) { + status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* Just copy the ACPI name from the Node and zero terminate it */ - ACPI_STRNCPY (buffer->pointer, acpi_ut_get_node_name (node), - ACPI_NAME_SIZE); - ((char *) buffer->pointer) [ACPI_NAME_SIZE] = 0; + ACPI_STRNCPY(buffer->pointer, acpi_ut_get_node_name(node), + ACPI_NAME_SIZE); + ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0; status = AE_OK; + unlock_and_exit: -unlock_and_exit: - - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return (status); } -EXPORT_SYMBOL(acpi_get_name); +EXPORT_SYMBOL(acpi_get_name); /****************************************************************************** * @@ -231,17 +221,14 @@ EXPORT_SYMBOL(acpi_get_name); ******************************************************************************/ acpi_status -acpi_get_object_info ( - acpi_handle handle, - struct acpi_buffer *buffer) +acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer) { - acpi_status status; - struct acpi_namespace_node *node; - struct acpi_device_info *info; - struct acpi_device_info *return_info; + acpi_status status; + struct acpi_namespace_node *node; + struct acpi_device_info *info; + struct acpi_device_info *return_info; struct acpi_compatible_id_list *cid_list = NULL; - acpi_size size; - + acpi_size size; /* Parameter validation */ @@ -249,37 +236,37 @@ acpi_get_object_info ( return (AE_BAD_PARAMETER); } - status = acpi_ut_validate_buffer (buffer); - if (ACPI_FAILURE (status)) { + status = acpi_ut_validate_buffer(buffer); + if (ACPI_FAILURE(status)) { return (status); } - info = ACPI_MEM_CALLOCATE (sizeof (struct acpi_device_info)); + info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_device_info)); if (!info) { return (AE_NO_MEMORY); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { goto cleanup; } - node = acpi_ns_map_handle_to_node (handle); + node = acpi_ns_map_handle_to_node(handle); if (!node) { - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); goto cleanup; } /* Init return structure */ - size = sizeof (struct acpi_device_info); + size = sizeof(struct acpi_device_info); - info->type = node->type; - info->name = node->name.integer; + info->type = node->type; + info->name = node->name.integer; info->valid = 0; - status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -297,73 +284,73 @@ acpi_get_object_info ( /* Execute the Device._HID method */ - status = acpi_ut_execute_HID (node, &info->hardware_id); - if (ACPI_SUCCESS (status)) { + status = acpi_ut_execute_HID(node, &info->hardware_id); + if (ACPI_SUCCESS(status)) { info->valid |= ACPI_VALID_HID; } /* Execute the Device._UID method */ - status = acpi_ut_execute_UID (node, &info->unique_id); - if (ACPI_SUCCESS (status)) { + status = acpi_ut_execute_UID(node, &info->unique_id); + if (ACPI_SUCCESS(status)) { info->valid |= ACPI_VALID_UID; } /* Execute the Device._CID method */ - status = acpi_ut_execute_CID (node, &cid_list); - if (ACPI_SUCCESS (status)) { + status = acpi_ut_execute_CID(node, &cid_list); + if (ACPI_SUCCESS(status)) { size += ((acpi_size) cid_list->count - 1) * - sizeof (struct acpi_compatible_id); + sizeof(struct acpi_compatible_id); info->valid |= ACPI_VALID_CID; } /* Execute the Device._STA method */ - status = acpi_ut_execute_STA (node, &info->current_status); - if (ACPI_SUCCESS (status)) { + status = acpi_ut_execute_STA(node, &info->current_status); + if (ACPI_SUCCESS(status)) { info->valid |= ACPI_VALID_STA; } /* Execute the Device._ADR method */ - status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, node, - &info->address); - if (ACPI_SUCCESS (status)) { + status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, node, + &info->address); + if (ACPI_SUCCESS(status)) { info->valid |= ACPI_VALID_ADR; } /* Execute the Device._sx_d methods */ - status = acpi_ut_execute_sxds (node, info->highest_dstates); - if (ACPI_SUCCESS (status)) { + status = acpi_ut_execute_sxds(node, info->highest_dstates); + if (ACPI_SUCCESS(status)) { info->valid |= ACPI_VALID_SXDS; } } /* Validate/Allocate/Clear caller buffer */ - status = acpi_ut_initialize_buffer (buffer, size); - if (ACPI_FAILURE (status)) { + status = acpi_ut_initialize_buffer(buffer, size); + if (ACPI_FAILURE(status)) { goto cleanup; } /* Populate the return buffer */ return_info = buffer->pointer; - ACPI_MEMCPY (return_info, info, sizeof (struct acpi_device_info)); + ACPI_MEMCPY(return_info, info, sizeof(struct acpi_device_info)); if (cid_list) { - ACPI_MEMCPY (&return_info->compatibility_id, cid_list, cid_list->size); + ACPI_MEMCPY(&return_info->compatibility_id, cid_list, + cid_list->size); } - -cleanup: - ACPI_MEM_FREE (info); + cleanup: + ACPI_MEM_FREE(info); if (cid_list) { - ACPI_MEM_FREE (cid_list); + ACPI_MEM_FREE(cid_list); } return (status); } -EXPORT_SYMBOL(acpi_get_object_info); +EXPORT_SYMBOL(acpi_get_object_info); diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c index 363e1f6..0856d42 100644 --- a/drivers/acpi/namespace/nsxfobj.c +++ b/drivers/acpi/namespace/nsxfobj.c @@ -47,9 +47,8 @@ #include #include - #define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsxfobj") +ACPI_MODULE_NAME("nsxfobj") /******************************************************************************* * @@ -63,15 +62,10 @@ * DESCRIPTION: This routine returns the type associatd with a particular handle * ******************************************************************************/ - -acpi_status -acpi_get_type ( - acpi_handle handle, - acpi_object_type *ret_type) +acpi_status acpi_get_type(acpi_handle handle, acpi_object_type * ret_type) { - struct acpi_namespace_node *node; - acpi_status status; - + struct acpi_namespace_node *node; + acpi_status status; /* Parameter Validation */ @@ -88,27 +82,26 @@ acpi_get_type ( return (AE_OK); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } /* Convert and validate the handle */ - node = acpi_ns_map_handle_to_node (handle); + node = acpi_ns_map_handle_to_node(handle); if (!node) { - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return (AE_BAD_PARAMETER); } *ret_type = node->type; - - status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return (status); } -EXPORT_SYMBOL(acpi_get_type); +EXPORT_SYMBOL(acpi_get_type); /******************************************************************************* * @@ -124,14 +117,10 @@ EXPORT_SYMBOL(acpi_get_type); * ******************************************************************************/ -acpi_status -acpi_get_parent ( - acpi_handle handle, - acpi_handle *ret_handle) +acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle) { - struct acpi_namespace_node *node; - acpi_status status; - + struct acpi_namespace_node *node; + acpi_status status; if (!ret_handle) { return (AE_BAD_PARAMETER); @@ -143,14 +132,14 @@ acpi_get_parent ( return (AE_NULL_ENTRY); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } /* Convert and validate the handle */ - node = acpi_ns_map_handle_to_node (handle); + node = acpi_ns_map_handle_to_node(handle); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -159,22 +148,21 @@ acpi_get_parent ( /* Get the parent entry */ *ret_handle = - acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_node (node)); + acpi_ns_convert_entry_to_handle(acpi_ns_get_parent_node(node)); /* Return exception if parent is null */ - if (!acpi_ns_get_parent_node (node)) { + if (!acpi_ns_get_parent_node(node)) { status = AE_NULL_ENTRY; } + unlock_and_exit: -unlock_and_exit: - - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return (status); } -EXPORT_SYMBOL(acpi_get_parent); +EXPORT_SYMBOL(acpi_get_parent); /******************************************************************************* * @@ -195,17 +183,14 @@ EXPORT_SYMBOL(acpi_get_parent); ******************************************************************************/ acpi_status -acpi_get_next_object ( - acpi_object_type type, - acpi_handle parent, - acpi_handle child, - acpi_handle *ret_handle) +acpi_get_next_object(acpi_object_type type, + acpi_handle parent, + acpi_handle child, acpi_handle * ret_handle) { - acpi_status status; - struct acpi_namespace_node *node; - struct acpi_namespace_node *parent_node = NULL; - struct acpi_namespace_node *child_node = NULL; - + acpi_status status; + struct acpi_namespace_node *node; + struct acpi_namespace_node *parent_node = NULL; + struct acpi_namespace_node *child_node = NULL; /* Parameter validation */ @@ -213,8 +198,8 @@ acpi_get_next_object ( return (AE_BAD_PARAMETER); } - status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { return (status); } @@ -223,17 +208,16 @@ acpi_get_next_object ( if (!child) { /* Start search at the beginning of the specified scope */ - parent_node = acpi_ns_map_handle_to_node (parent); + parent_node = acpi_ns_map_handle_to_node(parent); if (!parent_node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } - } - else { + } else { /* Non-null handle, ignore the parent */ /* Convert and validate the handle */ - child_node = acpi_ns_map_handle_to_node (child); + child_node = acpi_ns_map_handle_to_node(child); if (!child_node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -242,20 +226,19 @@ acpi_get_next_object ( /* Internal function does the real work */ - node = acpi_ns_get_next_node (type, parent_node, child_node); + node = acpi_ns_get_next_node(type, parent_node, child_node); if (!node) { status = AE_NOT_FOUND; goto unlock_and_exit; } if (ret_handle) { - *ret_handle = acpi_ns_convert_entry_to_handle (node); + *ret_handle = acpi_ns_convert_entry_to_handle(node); } + unlock_and_exit: -unlock_and_exit: - - (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return (status); } diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index a82834b..64b98e8 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c @@ -34,16 +34,18 @@ #define ACPI_NUMA 0x80000000 #define _COMPONENT ACPI_NUMA - ACPI_MODULE_NAME ("numa") +ACPI_MODULE_NAME("numa") -extern int __init acpi_table_parse_madt_family (enum acpi_table_id id, unsigned long madt_size, int entry_id, acpi_madt_entry_handler handler, unsigned int max_entries); +extern int __init acpi_table_parse_madt_family(enum acpi_table_id id, + unsigned long madt_size, + int entry_id, + acpi_madt_entry_handler handler, + unsigned int max_entries); -void __init -acpi_table_print_srat_entry ( - acpi_table_entry_header *header) +void __init acpi_table_print_srat_entry(acpi_table_entry_header * header) { - ACPI_FUNCTION_NAME ("acpi_table_print_srat_entry"); + ACPI_FUNCTION_NAME("acpi_table_print_srat_entry"); if (!header) return; @@ -52,48 +54,55 @@ acpi_table_print_srat_entry ( case ACPI_SRAT_PROCESSOR_AFFINITY: #ifdef ACPI_DEBUG_OUTPUT - { - struct acpi_table_processor_affinity *p = - (struct acpi_table_processor_affinity*) header; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "SRAT Processor (id[0x%02x] eid[0x%02x]) in proximity domain %d %s\n", - p->apic_id, p->lsapic_eid, p->proximity_domain, - p->flags.enabled?"enabled":"disabled")); - } -#endif /* ACPI_DEBUG_OUTPUT */ + { + struct acpi_table_processor_affinity *p = + (struct acpi_table_processor_affinity *)header; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "SRAT Processor (id[0x%02x] eid[0x%02x]) in proximity domain %d %s\n", + p->apic_id, p->lsapic_eid, + p->proximity_domain, + p->flags. + enabled ? "enabled" : "disabled")); + } +#endif /* ACPI_DEBUG_OUTPUT */ break; case ACPI_SRAT_MEMORY_AFFINITY: #ifdef ACPI_DEBUG_OUTPUT - { - struct acpi_table_memory_affinity *p = - (struct acpi_table_memory_affinity*) header; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "SRAT Memory (0x%08x%08x length 0x%08x%08x type 0x%x) in proximity domain %d %s%s\n", - p->base_addr_hi, p->base_addr_lo, p->length_hi, p->length_lo, - p->memory_type, p->proximity_domain, - p->flags.enabled ? "enabled" : "disabled", - p->flags.hot_pluggable ? " hot-pluggable" : "")); - } -#endif /* ACPI_DEBUG_OUTPUT */ + { + struct acpi_table_memory_affinity *p = + (struct acpi_table_memory_affinity *)header; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "SRAT Memory (0x%08x%08x length 0x%08x%08x type 0x%x) in proximity domain %d %s%s\n", + p->base_addr_hi, p->base_addr_lo, + p->length_hi, p->length_lo, + p->memory_type, p->proximity_domain, + p->flags. + enabled ? "enabled" : "disabled", + p->flags. + hot_pluggable ? " hot-pluggable" : + "")); + } +#endif /* ACPI_DEBUG_OUTPUT */ break; default: - printk(KERN_WARNING PREFIX "Found unsupported SRAT entry (type = 0x%x)\n", - header->type); + printk(KERN_WARNING PREFIX + "Found unsupported SRAT entry (type = 0x%x)\n", + header->type); break; } } - -static int __init -acpi_parse_slit (unsigned long phys_addr, unsigned long size) +static int __init acpi_parse_slit(unsigned long phys_addr, unsigned long size) { - struct acpi_table_slit *slit; - u32 localities; + struct acpi_table_slit *slit; + u32 localities; if (!phys_addr || !size) return -EINVAL; - slit = (struct acpi_table_slit *) __va(phys_addr); + slit = (struct acpi_table_slit *)__va(phys_addr); /* downcast just for %llu vs %lu for i386/ia64 */ localities = (u32) slit->localities; @@ -103,15 +112,13 @@ acpi_parse_slit (unsigned long phys_addr, unsigned long size) return 0; } - static int __init -acpi_parse_processor_affinity ( - acpi_table_entry_header *header, - const unsigned long end) +acpi_parse_processor_affinity(acpi_table_entry_header * header, + const unsigned long end) { struct acpi_table_processor_affinity *processor_affinity; - processor_affinity = (struct acpi_table_processor_affinity*) header; + processor_affinity = (struct acpi_table_processor_affinity *)header; if (!processor_affinity) return -EINVAL; @@ -123,15 +130,13 @@ acpi_parse_processor_affinity ( return 0; } - static int __init -acpi_parse_memory_affinity ( - acpi_table_entry_header *header, - const unsigned long end) +acpi_parse_memory_affinity(acpi_table_entry_header * header, + const unsigned long end) { struct acpi_table_memory_affinity *memory_affinity; - memory_affinity = (struct acpi_table_memory_affinity*) header; + memory_affinity = (struct acpi_table_memory_affinity *)header; if (!memory_affinity) return -EINVAL; @@ -143,36 +148,30 @@ acpi_parse_memory_affinity ( return 0; } - -static int __init -acpi_parse_srat (unsigned long phys_addr, unsigned long size) +static int __init acpi_parse_srat(unsigned long phys_addr, unsigned long size) { - struct acpi_table_srat *srat; + struct acpi_table_srat *srat; if (!phys_addr || !size) return -EINVAL; - srat = (struct acpi_table_srat *) __va(phys_addr); + srat = (struct acpi_table_srat *)__va(phys_addr); return 0; } - int __init -acpi_table_parse_srat ( - enum acpi_srat_entry_id id, - acpi_madt_entry_handler handler, - unsigned int max_entries) +acpi_table_parse_srat(enum acpi_srat_entry_id id, + acpi_madt_entry_handler handler, unsigned int max_entries) { - return acpi_table_parse_madt_family(ACPI_SRAT, sizeof(struct acpi_table_srat), - id, handler, max_entries); + return acpi_table_parse_madt_family(ACPI_SRAT, + sizeof(struct acpi_table_srat), id, + handler, max_entries); } - -int __init -acpi_numa_init(void) +int __init acpi_numa_init(void) { - int result; + int result; /* SRAT: Static Resource Affinity Table */ result = acpi_table_parse(ACPI_SRAT, acpi_parse_srat); @@ -181,9 +180,7 @@ acpi_numa_init(void) result = acpi_table_parse_srat(ACPI_SRAT_PROCESSOR_AFFINITY, acpi_parse_processor_affinity, NR_CPUS); - result = acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY, - acpi_parse_memory_affinity, - NR_NODE_MEMBLKS); // IA64 specific + result = acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY, acpi_parse_memory_affinity, NR_NODE_MEMBLKS); // IA64 specific } /* SLIT: System Locality Information Table */ @@ -193,8 +190,7 @@ acpi_numa_init(void) return 0; } -int -acpi_get_pxm(acpi_handle h) +int acpi_get_pxm(acpi_handle h) { unsigned long pxm; acpi_status status; @@ -207,7 +203,8 @@ acpi_get_pxm(acpi_handle h) if (ACPI_SUCCESS(status)) return (int)pxm; status = acpi_get_parent(handle, &phandle); - } while(ACPI_SUCCESS(status)); + } while (ACPI_SUCCESS(status)); return -1; } + EXPORT_SYMBOL(acpi_get_pxm); diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index f3a807c..9127760 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -45,16 +45,12 @@ #include - #define _COMPONENT ACPI_OS_SERVICES -ACPI_MODULE_NAME ("osl") - +ACPI_MODULE_NAME("osl") #define PREFIX "ACPI: " - -struct acpi_os_dpc -{ - acpi_osd_exec_callback function; - void *context; +struct acpi_os_dpc { + acpi_osd_exec_callback function; + void *context; }; #ifdef CONFIG_ACPI_CUSTOM_DSDT @@ -69,7 +65,7 @@ int acpi_in_debugger; EXPORT_SYMBOL(acpi_in_debugger); extern char line_buf[80]; -#endif /*ENABLE_DEBUGGER*/ +#endif /*ENABLE_DEBUGGER */ int acpi_specific_hotkey_enabled; EXPORT_SYMBOL(acpi_specific_hotkey_enabled); @@ -79,14 +75,12 @@ static acpi_osd_handler acpi_irq_handler; static void *acpi_irq_context; static struct workqueue_struct *kacpid_wq; -acpi_status -acpi_os_initialize(void) +acpi_status acpi_os_initialize(void) { return AE_OK; } -acpi_status -acpi_os_initialize1(void) +acpi_status acpi_os_initialize1(void) { /* * Initialize PCI configuration space access, as we'll need to access @@ -94,7 +88,8 @@ acpi_os_initialize1(void) */ #ifdef CONFIG_ACPI_PCI if (!raw_pci_ops) { - printk(KERN_ERR PREFIX "Access to PCI configuration space unavailable\n"); + printk(KERN_ERR PREFIX + "Access to PCI configuration space unavailable\n"); return AE_NULL_ENTRY; } #endif @@ -104,8 +99,7 @@ acpi_os_initialize1(void) return AE_OK; } -acpi_status -acpi_os_terminate(void) +acpi_status acpi_os_terminate(void) { if (acpi_irq_handler) { acpi_os_remove_interrupt_handler(acpi_irq_irq, @@ -117,21 +111,20 @@ acpi_os_terminate(void) return AE_OK; } -void -acpi_os_printf(const char *fmt,...) +void acpi_os_printf(const char *fmt, ...) { va_list args; va_start(args, fmt); acpi_os_vprintf(fmt, args); va_end(args); } + EXPORT_SYMBOL(acpi_os_printf); -void -acpi_os_vprintf(const char *fmt, va_list args) +void acpi_os_vprintf(const char *fmt, va_list args) { static char buffer[512]; - + vsprintf(buffer, fmt, args); #ifdef ENABLE_DEBUGGER @@ -146,8 +139,7 @@ acpi_os_vprintf(const char *fmt, va_list args) } extern int acpi_in_resume; -void * -acpi_os_allocate(acpi_size size) +void *acpi_os_allocate(acpi_size size) { if (acpi_in_resume) return kmalloc(size, GFP_ATOMIC); @@ -155,31 +147,32 @@ acpi_os_allocate(acpi_size size) return kmalloc(size, GFP_KERNEL); } -void -acpi_os_free(void *ptr) +void acpi_os_free(void *ptr) { kfree(ptr); } + EXPORT_SYMBOL(acpi_os_free); -acpi_status -acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr) +acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr) { if (efi_enabled) { addr->pointer_type = ACPI_PHYSICAL_POINTER; if (efi.acpi20) addr->pointer.physical = - (acpi_physical_address) virt_to_phys(efi.acpi20); + (acpi_physical_address) virt_to_phys(efi.acpi20); else if (efi.acpi) addr->pointer.physical = - (acpi_physical_address) virt_to_phys(efi.acpi); + (acpi_physical_address) virt_to_phys(efi.acpi); else { - printk(KERN_ERR PREFIX "System description tables not found\n"); + printk(KERN_ERR PREFIX + "System description tables not found\n"); return AE_NOT_FOUND; } } else { if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) { - printk(KERN_ERR PREFIX "System description tables not found\n"); + printk(KERN_ERR PREFIX + "System description tables not found\n"); return AE_NOT_FOUND; } } @@ -188,11 +181,12 @@ acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr) } acpi_status -acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void __iomem **virt) +acpi_os_map_memory(acpi_physical_address phys, acpi_size size, + void __iomem ** virt) { if (efi_enabled) { if (EFI_MEMORY_WB & efi_mem_attributes(phys)) { - *virt = (void __iomem *) phys_to_virt(phys); + *virt = (void __iomem *)phys_to_virt(phys); } else { *virt = ioremap(phys, size); } @@ -202,9 +196,9 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void __iomem **vi return AE_BAD_PARAMETER; } /* - * ioremap checks to ensure this is in reserved space - */ - *virt = ioremap((unsigned long) phys, size); + * ioremap checks to ensure this is in reserved space + */ + *virt = ioremap((unsigned long)phys, size); } if (!*virt) @@ -213,17 +207,16 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void __iomem **vi return AE_OK; } -void -acpi_os_unmap_memory(void __iomem *virt, acpi_size size) +void acpi_os_unmap_memory(void __iomem * virt, acpi_size size) { iounmap(virt); } #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_os_get_physical_address(void *virt, acpi_physical_address *phys) +acpi_os_get_physical_address(void *virt, acpi_physical_address * phys) { - if(!phys || !virt) + if (!phys || !virt) return AE_BAD_PARAMETER; *phys = virt_to_phys(virt); @@ -237,16 +230,16 @@ acpi_os_get_physical_address(void *virt, acpi_physical_address *phys) static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN]; acpi_status -acpi_os_predefined_override (const struct acpi_predefined_names *init_val, - acpi_string *new_val) +acpi_os_predefined_override(const struct acpi_predefined_names *init_val, + acpi_string * new_val) { if (!init_val || !new_val) return AE_BAD_PARAMETER; *new_val = NULL; - if (!memcmp (init_val->name, "_OS_", 4) && strlen(acpi_os_name)) { + if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) { printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n", - acpi_os_name); + acpi_os_name); *new_val = acpi_os_name; } @@ -254,15 +247,15 @@ acpi_os_predefined_override (const struct acpi_predefined_names *init_val, } acpi_status -acpi_os_table_override (struct acpi_table_header *existing_table, - struct acpi_table_header **new_table) +acpi_os_table_override(struct acpi_table_header * existing_table, + struct acpi_table_header ** new_table) { if (!existing_table || !new_table) return AE_BAD_PARAMETER; #ifdef CONFIG_ACPI_CUSTOM_DSDT if (strncmp(existing_table->signature, "DSDT", 4) == 0) - *new_table = (struct acpi_table_header*)AmlCode; + *new_table = (struct acpi_table_header *)AmlCode; else *new_table = NULL; #else @@ -271,14 +264,14 @@ acpi_os_table_override (struct acpi_table_header *existing_table, return AE_OK; } -static irqreturn_t -acpi_irq(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t acpi_irq(int irq, void *dev_id, struct pt_regs *regs) { - return (*acpi_irq_handler)(acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE; + return (*acpi_irq_handler) (acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE; } acpi_status -acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, void *context) +acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, + void *context) { unsigned int irq; @@ -305,8 +298,7 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, void *conte return AE_OK; } -acpi_status -acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler) +acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler) { if (irq) { free_irq(irq, acpi_irq); @@ -321,16 +313,15 @@ acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler) * Running in interpreter thread context, safe to sleep */ -void -acpi_os_sleep(acpi_integer ms) +void acpi_os_sleep(acpi_integer ms) { current->state = TASK_INTERRUPTIBLE; - schedule_timeout(((signed long) ms * HZ) / 1000); + schedule_timeout(((signed long)ms * HZ) / 1000); } + EXPORT_SYMBOL(acpi_os_sleep); -void -acpi_os_stall(u32 us) +void acpi_os_stall(u32 us) { while (us) { u32 delay = 1000; @@ -342,6 +333,7 @@ acpi_os_stall(u32 us) us -= delay; } } + EXPORT_SYMBOL(acpi_os_stall); /* @@ -349,8 +341,7 @@ EXPORT_SYMBOL(acpi_os_stall); * Returns 64-bit free-running, monotonically increasing timer * with 100ns granularity */ -u64 -acpi_os_get_timer (void) +u64 acpi_os_get_timer(void) { static u64 t; @@ -367,27 +358,22 @@ acpi_os_get_timer (void) return ++t; } -acpi_status -acpi_os_read_port( - acpi_io_address port, - u32 *value, - u32 width) +acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) { u32 dummy; if (!value) value = &dummy; - switch (width) - { + switch (width) { case 8: - *(u8*) value = inb(port); + *(u8 *) value = inb(port); break; case 16: - *(u16*) value = inw(port); + *(u16 *) value = inw(port); break; case 32: - *(u32*) value = inl(port); + *(u32 *) value = inl(port); break; default: BUG(); @@ -395,16 +381,12 @@ acpi_os_read_port( return AE_OK; } + EXPORT_SYMBOL(acpi_os_read_port); -acpi_status -acpi_os_write_port( - acpi_io_address port, - u32 value, - u32 width) +acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width) { - switch (width) - { + switch (width) { case 8: outb(value, port); break; @@ -420,40 +402,38 @@ acpi_os_write_port( return AE_OK; } + EXPORT_SYMBOL(acpi_os_write_port); acpi_status -acpi_os_read_memory( - acpi_physical_address phys_addr, - u32 *value, - u32 width) +acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width) { - u32 dummy; - void __iomem *virt_addr; - int iomem = 0; + u32 dummy; + void __iomem *virt_addr; + int iomem = 0; if (efi_enabled) { if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) { /* HACK ALERT! We can use readb/w/l on real memory too.. */ - virt_addr = (void __iomem *) phys_to_virt(phys_addr); + virt_addr = (void __iomem *)phys_to_virt(phys_addr); } else { iomem = 1; virt_addr = ioremap(phys_addr, width); } } else - virt_addr = (void __iomem *) phys_to_virt(phys_addr); + virt_addr = (void __iomem *)phys_to_virt(phys_addr); if (!value) value = &dummy; switch (width) { case 8: - *(u8*) value = readb(virt_addr); + *(u8 *) value = readb(virt_addr); break; case 16: - *(u16*) value = readw(virt_addr); + *(u16 *) value = readw(virt_addr); break; case 32: - *(u32*) value = readl(virt_addr); + *(u32 *) value = readl(virt_addr); break; default: BUG(); @@ -468,24 +448,21 @@ acpi_os_read_memory( } acpi_status -acpi_os_write_memory( - acpi_physical_address phys_addr, - u32 value, - u32 width) +acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) { - void __iomem *virt_addr; - int iomem = 0; + void __iomem *virt_addr; + int iomem = 0; if (efi_enabled) { if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) { /* HACK ALERT! We can use writeb/w/l on real memory too */ - virt_addr = (void __iomem *) phys_to_virt(phys_addr); + virt_addr = (void __iomem *)phys_to_virt(phys_addr); } else { iomem = 1; virt_addr = ioremap(phys_addr, width); } } else - virt_addr = (void __iomem *) phys_to_virt(phys_addr); + virt_addr = (void __iomem *)phys_to_virt(phys_addr); switch (width) { case 8: @@ -510,7 +487,8 @@ acpi_os_write_memory( #ifdef CONFIG_ACPI_PCI acpi_status -acpi_os_read_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, void *value, u32 width) +acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, + void *value, u32 width) { int result, size; @@ -534,15 +512,17 @@ acpi_os_read_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, void *value BUG_ON(!raw_pci_ops); result = raw_pci_ops->read(pci_id->segment, pci_id->bus, - PCI_DEVFN(pci_id->device, pci_id->function), - reg, size, value); + PCI_DEVFN(pci_id->device, pci_id->function), + reg, size, value); return (result ? AE_ERROR : AE_OK); } + EXPORT_SYMBOL(acpi_os_read_pci_configuration); acpi_status -acpi_os_write_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, acpi_integer value, u32 width) +acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, + acpi_integer value, u32 width) { int result, size; @@ -563,56 +543,62 @@ acpi_os_write_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, acpi_integ BUG_ON(!raw_pci_ops); result = raw_pci_ops->write(pci_id->segment, pci_id->bus, - PCI_DEVFN(pci_id->device, pci_id->function), - reg, size, value); + PCI_DEVFN(pci_id->device, pci_id->function), + reg, size, value); return (result ? AE_ERROR : AE_OK); } /* TODO: Change code to take advantage of driver model more */ -static void -acpi_os_derive_pci_id_2 ( - acpi_handle rhandle, /* upper bound */ - acpi_handle chandle, /* current node */ - struct acpi_pci_id **id, - int *is_bridge, - u8 *bus_number) +static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */ + acpi_handle chandle, /* current node */ + struct acpi_pci_id **id, + int *is_bridge, u8 * bus_number) { - acpi_handle handle; - struct acpi_pci_id *pci_id = *id; - acpi_status status; - unsigned long temp; - acpi_object_type type; - u8 tu8; + acpi_handle handle; + struct acpi_pci_id *pci_id = *id; + acpi_status status; + unsigned long temp; + acpi_object_type type; + u8 tu8; acpi_get_parent(chandle, &handle); if (handle != rhandle) { - acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge, bus_number); + acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge, + bus_number); status = acpi_get_type(handle, &type); - if ( (ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE) ) + if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE)) return; - status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &temp); + status = + acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, + &temp); if (ACPI_SUCCESS(status)) { - pci_id->device = ACPI_HIWORD (ACPI_LODWORD (temp)); - pci_id->function = ACPI_LOWORD (ACPI_LODWORD (temp)); + pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp)); + pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp)); if (*is_bridge) pci_id->bus = *bus_number; /* any nicer way to get bus number of bridge ? */ - status = acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8, 8); - if (ACPI_SUCCESS(status) && - ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) { - status = acpi_os_read_pci_configuration(pci_id, 0x18, &tu8, 8); + status = + acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8, + 8); + if (ACPI_SUCCESS(status) + && ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) { + status = + acpi_os_read_pci_configuration(pci_id, 0x18, + &tu8, 8); if (!ACPI_SUCCESS(status)) { /* Certainly broken... FIX ME */ return; } *is_bridge = 1; pci_id->bus = tu8; - status = acpi_os_read_pci_configuration(pci_id, 0x19, &tu8, 8); + status = + acpi_os_read_pci_configuration(pci_id, 0x19, + &tu8, 8); if (ACPI_SUCCESS(status)) { *bus_number = tu8; } @@ -622,11 +608,9 @@ acpi_os_derive_pci_id_2 ( } } -void -acpi_os_derive_pci_id ( - acpi_handle rhandle, /* upper bound */ - acpi_handle chandle, /* current node */ - struct acpi_pci_id **id) +void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */ + acpi_handle chandle, /* current node */ + struct acpi_pci_id **id) { int is_bridge = 1; u8 bus_number = (*id)->bus; @@ -634,49 +618,39 @@ acpi_os_derive_pci_id ( acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number); } -#else /*!CONFIG_ACPI_PCI*/ +#else /*!CONFIG_ACPI_PCI */ acpi_status -acpi_os_write_pci_configuration ( - struct acpi_pci_id *pci_id, - u32 reg, - acpi_integer value, - u32 width) +acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, + u32 reg, acpi_integer value, u32 width) { return AE_SUPPORT; } acpi_status -acpi_os_read_pci_configuration ( - struct acpi_pci_id *pci_id, - u32 reg, - void *value, - u32 width) +acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, + u32 reg, void *value, u32 width) { return AE_SUPPORT; } -void -acpi_os_derive_pci_id ( - acpi_handle rhandle, /* upper bound */ - acpi_handle chandle, /* current node */ - struct acpi_pci_id **id) +void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */ + acpi_handle chandle, /* current node */ + struct acpi_pci_id **id) { } -#endif /*CONFIG_ACPI_PCI*/ +#endif /*CONFIG_ACPI_PCI */ -static void -acpi_os_execute_deferred ( - void *context) +static void acpi_os_execute_deferred(void *context) { - struct acpi_os_dpc *dpc = NULL; + struct acpi_os_dpc *dpc = NULL; - ACPI_FUNCTION_TRACE ("os_execute_deferred"); + ACPI_FUNCTION_TRACE("os_execute_deferred"); - dpc = (struct acpi_os_dpc *) context; + dpc = (struct acpi_os_dpc *)context; if (!dpc) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); return_VOID; } @@ -688,21 +662,21 @@ acpi_os_execute_deferred ( } acpi_status -acpi_os_queue_for_execution( - u32 priority, - acpi_osd_exec_callback function, - void *context) +acpi_os_queue_for_execution(u32 priority, + acpi_osd_exec_callback function, void *context) { - acpi_status status = AE_OK; - struct acpi_os_dpc *dpc; - struct work_struct *task; + acpi_status status = AE_OK; + struct acpi_os_dpc *dpc; + struct work_struct *task; - ACPI_FUNCTION_TRACE ("os_queue_for_execution"); + ACPI_FUNCTION_TRACE("os_queue_for_execution"); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Scheduling function [%p(%p)] for deferred execution.\n", function, context)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Scheduling function [%p(%p)] for deferred execution.\n", + function, context)); if (!function) - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); /* * Allocate/initialize DPC structure. Note that this memory will be @@ -715,67 +689,65 @@ acpi_os_queue_for_execution( * from the same memory. */ - dpc = kmalloc(sizeof(struct acpi_os_dpc)+sizeof(struct work_struct), GFP_ATOMIC); + dpc = + kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct), + GFP_ATOMIC); if (!dpc) - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); dpc->function = function; dpc->context = context; - task = (void *)(dpc+1); - INIT_WORK(task, acpi_os_execute_deferred, (void*)dpc); + task = (void *)(dpc + 1); + INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc); if (!queue_work(kacpid_wq, task)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Call to queue_work() failed.\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Call to queue_work() failed.\n")); kfree(dpc); status = AE_ERROR; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } + EXPORT_SYMBOL(acpi_os_queue_for_execution); -void -acpi_os_wait_events_complete( - void *context) +void acpi_os_wait_events_complete(void *context) { flush_workqueue(kacpid_wq); } + EXPORT_SYMBOL(acpi_os_wait_events_complete); /* * Allocate the memory for a spinlock and initialize it. */ -acpi_status -acpi_os_create_lock ( - acpi_handle *out_handle) +acpi_status acpi_os_create_lock(acpi_handle * out_handle) { spinlock_t *lock_ptr; - ACPI_FUNCTION_TRACE ("os_create_lock"); + ACPI_FUNCTION_TRACE("os_create_lock"); lock_ptr = acpi_os_allocate(sizeof(spinlock_t)); spin_lock_init(lock_ptr); - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr)); + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr)); *out_handle = lock_ptr; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /* * Deallocate the memory for a spinlock. */ -void -acpi_os_delete_lock ( - acpi_handle handle) +void acpi_os_delete_lock(acpi_handle handle) { - ACPI_FUNCTION_TRACE ("os_create_lock"); + ACPI_FUNCTION_TRACE("os_create_lock"); - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle)); + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle)); acpi_os_free(handle); @@ -783,30 +755,28 @@ acpi_os_delete_lock ( } acpi_status -acpi_os_create_semaphore( - u32 max_units, - u32 initial_units, - acpi_handle *handle) +acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) { - struct semaphore *sem = NULL; + struct semaphore *sem = NULL; - ACPI_FUNCTION_TRACE ("os_create_semaphore"); + ACPI_FUNCTION_TRACE("os_create_semaphore"); sem = acpi_os_allocate(sizeof(struct semaphore)); if (!sem) - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); memset(sem, 0, sizeof(struct semaphore)); sema_init(sem, initial_units); - *handle = (acpi_handle*)sem; + *handle = (acpi_handle *) sem; - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", *handle, initial_units)); + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", + *handle, initial_units)); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_os_create_semaphore); +EXPORT_SYMBOL(acpi_os_create_semaphore); /* * TODO: A better way to delete semaphores? Linux doesn't have a @@ -815,25 +785,24 @@ EXPORT_SYMBOL(acpi_os_create_semaphore); * we at least check for blocked threads and signal/cancel them? */ -acpi_status -acpi_os_delete_semaphore( - acpi_handle handle) +acpi_status acpi_os_delete_semaphore(acpi_handle handle) { - struct semaphore *sem = (struct semaphore*) handle; + struct semaphore *sem = (struct semaphore *)handle; - ACPI_FUNCTION_TRACE ("os_delete_semaphore"); + ACPI_FUNCTION_TRACE("os_delete_semaphore"); if (!sem) - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); - acpi_os_free(sem); sem = NULL; + acpi_os_free(sem); + sem = NULL; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_os_delete_semaphore); +EXPORT_SYMBOL(acpi_os_delete_semaphore); /* * TODO: The kernel doesn't have a 'down_timeout' function -- had to @@ -844,31 +813,27 @@ EXPORT_SYMBOL(acpi_os_delete_semaphore); * * TODO: Support for units > 1? */ -acpi_status -acpi_os_wait_semaphore( - acpi_handle handle, - u32 units, - u16 timeout) +acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) { - acpi_status status = AE_OK; - struct semaphore *sem = (struct semaphore*)handle; - int ret = 0; + acpi_status status = AE_OK; + struct semaphore *sem = (struct semaphore *)handle; + int ret = 0; - ACPI_FUNCTION_TRACE ("os_wait_semaphore"); + ACPI_FUNCTION_TRACE("os_wait_semaphore"); if (!sem || (units < 1)) - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); if (units > 1) - return_ACPI_STATUS (AE_SUPPORT); + return_ACPI_STATUS(AE_SUPPORT); - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", handle, units, timeout)); + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", + handle, units, timeout)); if (in_atomic()) timeout = 0; - switch (timeout) - { + switch (timeout) { /* * No Wait: * -------- @@ -876,8 +841,8 @@ acpi_os_wait_semaphore( * acquire the semaphore if available otherwise return AE_TIME * (a.k.a. 'would block'). */ - case 0: - if(down_trylock(sem)) + case 0: + if (down_trylock(sem)) status = AE_TIME; break; @@ -885,7 +850,7 @@ acpi_os_wait_semaphore( * Wait Indefinitely: * ------------------ */ - case ACPI_WAIT_FOREVER: + case ACPI_WAIT_FOREVER: down(sem); break; @@ -893,11 +858,11 @@ acpi_os_wait_semaphore( * Wait w/ Timeout: * ---------------- */ - default: + default: // TODO: A better timeout algorithm? { int i = 0; - static const int quantum_ms = 1000/HZ; + static const int quantum_ms = 1000 / HZ; ret = down_trylock(sem); for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) { @@ -905,7 +870,7 @@ acpi_os_wait_semaphore( schedule_timeout(1); ret = down_trylock(sem); } - + if (ret != 0) status = AE_TIME; } @@ -913,47 +878,48 @@ acpi_os_wait_semaphore( } if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Failed to acquire semaphore[%p|%d|%d], %s\n", - handle, units, timeout, acpi_format_exception(status))); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquired semaphore[%p|%d|%d]\n", handle, units, timeout)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Failed to acquire semaphore[%p|%d|%d], %s\n", + handle, units, timeout, + acpi_format_exception(status))); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, + "Acquired semaphore[%p|%d|%d]\n", handle, + units, timeout)); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_os_wait_semaphore); +EXPORT_SYMBOL(acpi_os_wait_semaphore); /* * TODO: Support for units > 1? */ -acpi_status -acpi_os_signal_semaphore( - acpi_handle handle, - u32 units) +acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units) { - struct semaphore *sem = (struct semaphore *) handle; + struct semaphore *sem = (struct semaphore *)handle; - ACPI_FUNCTION_TRACE ("os_signal_semaphore"); + ACPI_FUNCTION_TRACE("os_signal_semaphore"); if (!sem || (units < 1)) - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); if (units > 1) - return_ACPI_STATUS (AE_SUPPORT); + return_ACPI_STATUS(AE_SUPPORT); - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, units)); + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, + units)); up(sem); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } + EXPORT_SYMBOL(acpi_os_signal_semaphore); #ifdef ACPI_FUTURE_USAGE -u32 -acpi_os_get_line(char *buffer) +u32 acpi_os_get_line(char *buffer) { #ifdef ENABLE_DEBUGGER @@ -970,22 +936,21 @@ acpi_os_get_line(char *buffer) return 0; } -#endif /* ACPI_FUTURE_USAGE */ +#endif /* ACPI_FUTURE_USAGE */ /* Assumes no unreadable holes inbetween */ -u8 -acpi_os_readable(void *ptr, acpi_size len) +u8 acpi_os_readable(void *ptr, acpi_size len) { -#if defined(__i386__) || defined(__x86_64__) +#if defined(__i386__) || defined(__x86_64__) char tmp; - return !__get_user(tmp, (char __user *)ptr) && !__get_user(tmp, (char __user *)ptr + len - 1); + return !__get_user(tmp, (char __user *)ptr) + && !__get_user(tmp, (char __user *)ptr + len - 1); #endif return 1; } #ifdef ACPI_FUTURE_USAGE -u8 -acpi_os_writable(void *ptr, acpi_size len) +u8 acpi_os_writable(void *ptr, acpi_size len) { /* could do dummy write (racy) or a kernel page table lookup. The later may be difficult at early boot when kmap doesn't work yet. */ @@ -993,8 +958,7 @@ acpi_os_writable(void *ptr, acpi_size len) } #endif -u32 -acpi_os_get_thread_id (void) +u32 acpi_os_get_thread_id(void) { if (!in_atomic()) return current->pid; @@ -1002,13 +966,9 @@ acpi_os_get_thread_id (void) return 0; } -acpi_status -acpi_os_signal ( - u32 function, - void *info) +acpi_status acpi_os_signal(u32 function, void *info) { - switch (function) - { + switch (function) { case ACPI_SIGNAL_FATAL: printk(KERN_ERR PREFIX "Fatal opcode executed\n"); break; @@ -1028,13 +988,13 @@ acpi_os_signal ( return AE_OK; } + EXPORT_SYMBOL(acpi_os_signal); -static int __init -acpi_os_name_setup(char *str) +static int __init acpi_os_name_setup(char *str) { char *p = acpi_os_name; - int count = ACPI_MAX_OVERRIDE_LEN-1; + int count = ACPI_MAX_OVERRIDE_LEN - 1; if (!str || !*str) return 0; @@ -1050,7 +1010,7 @@ acpi_os_name_setup(char *str) *p = 0; return 1; - + } __setup("acpi_os_name=", acpi_os_name_setup); @@ -1060,16 +1020,15 @@ __setup("acpi_os_name=", acpi_os_name_setup); * empty string disables _OSI * TBD additional string adds to _OSI */ -static int __init -acpi_osi_setup(char *str) +static int __init acpi_osi_setup(char *str) { if (str == NULL || *str == '\0') { printk(KERN_INFO PREFIX "_OSI method disabled\n"); acpi_gbl_create_osi_method = FALSE; - } else - { + } else { /* TBD */ - printk(KERN_ERR PREFIX "_OSI additional string ignored -- %s\n", str); + printk(KERN_ERR PREFIX "_OSI additional string ignored -- %s\n", + str); } return 1; @@ -1078,8 +1037,7 @@ acpi_osi_setup(char *str) __setup("acpi_osi=", acpi_osi_setup); /* enable serialization to combat AE_ALREADY_EXISTS errors */ -static int __init -acpi_serialize_setup(char *str) +static int __init acpi_serialize_setup(char *str) { printk(KERN_INFO PREFIX "serialize enabled\n"); @@ -1099,8 +1057,7 @@ __setup("acpi_serialize", acpi_serialize_setup); * Run-time events on the same GPE this flag is available * to tell Linux to keep the wake-time GPEs enabled at run-time. */ -static int __init -acpi_wake_gpes_always_on_setup(char *str) +static int __init acpi_wake_gpes_always_on_setup(char *str) { printk(KERN_INFO PREFIX "wake GPEs not disabled\n"); @@ -1111,8 +1068,7 @@ acpi_wake_gpes_always_on_setup(char *str) __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); -int __init -acpi_hotkey_setup(char *str) +int __init acpi_hotkey_setup(char *str) { acpi_specific_hotkey_enabled = TRUE; return 1; @@ -1126,7 +1082,6 @@ __setup("acpi_specific_hotkey", acpi_hotkey_setup); */ unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER; - EXPORT_SYMBOL(max_cstate); /* @@ -1137,12 +1092,10 @@ EXPORT_SYMBOL(max_cstate); * that indicates whether we are at interrupt level. */ -unsigned long -acpi_os_acquire_lock ( - acpi_handle handle) +unsigned long acpi_os_acquire_lock(acpi_handle handle) { unsigned long flags; - spin_lock_irqsave((spinlock_t *)handle, flags); + spin_lock_irqsave((spinlock_t *) handle, flags); return flags; } @@ -1150,15 +1103,11 @@ acpi_os_acquire_lock ( * Release a spinlock. See above. */ -void -acpi_os_release_lock ( - acpi_handle handle, - unsigned long flags) +void acpi_os_release_lock(acpi_handle handle, unsigned long flags) { - spin_unlock_irqrestore((spinlock_t *)handle, flags); + spin_unlock_irqrestore((spinlock_t *) handle, flags); } - #ifndef ACPI_USE_LOCAL_CACHE /******************************************************************************* @@ -1177,13 +1126,9 @@ acpi_os_release_lock ( ******************************************************************************/ acpi_status -acpi_os_create_cache ( - char *name, - u16 size, - u16 depth, - acpi_cache_t **cache) +acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache) { - *cache = kmem_cache_create (name, size, 0, 0, NULL, NULL); + *cache = kmem_cache_create(name, size, 0, 0, NULL, NULL); return AE_OK; } @@ -1199,12 +1144,10 @@ acpi_os_create_cache ( * ******************************************************************************/ -acpi_status -acpi_os_purge_cache ( - acpi_cache_t *cache) +acpi_status acpi_os_purge_cache(acpi_cache_t * cache) { - (void) kmem_cache_shrink(cache); - return (AE_OK); + (void)kmem_cache_shrink(cache); + return (AE_OK); } /******************************************************************************* @@ -1220,12 +1163,10 @@ acpi_os_purge_cache ( * ******************************************************************************/ -acpi_status -acpi_os_delete_cache ( - acpi_cache_t *cache) +acpi_status acpi_os_delete_cache(acpi_cache_t * cache) { - (void)kmem_cache_destroy(cache); - return (AE_OK); + (void)kmem_cache_destroy(cache); + return (AE_OK); } /******************************************************************************* @@ -1242,13 +1183,10 @@ acpi_os_delete_cache ( * ******************************************************************************/ -acpi_status -acpi_os_release_object ( - acpi_cache_t *cache, - void *object) +acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object) { - kmem_cache_free(cache, object); - return (AE_OK); + kmem_cache_free(cache, object); + return (AE_OK); } /******************************************************************************* @@ -1265,14 +1203,11 @@ acpi_os_release_object ( * ******************************************************************************/ -void * -acpi_os_acquire_object ( - acpi_cache_t *cache) +void *acpi_os_acquire_object(acpi_cache_t * cache) { - void *object = kmem_cache_alloc(cache, GFP_KERNEL); - WARN_ON(!object); - return object; + void *object = kmem_cache_alloc(cache, GFP_KERNEL); + WARN_ON(!object); + return object; } #endif - diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c index b7ac68c..5858188 100644 --- a/drivers/acpi/parser/psargs.c +++ b/drivers/acpi/parser/psargs.c @@ -41,25 +41,20 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include #define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("psargs") +ACPI_MODULE_NAME("psargs") /* Local prototypes */ - static u32 -acpi_ps_get_next_package_length ( - struct acpi_parse_state *parser_state); - -static union acpi_parse_object * -acpi_ps_get_next_field ( - struct acpi_parse_state *parser_state); +acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state); +static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state + *parser_state); /******************************************************************************* * @@ -75,49 +70,43 @@ acpi_ps_get_next_field ( ******************************************************************************/ static u32 -acpi_ps_get_next_package_length ( - struct acpi_parse_state *parser_state) +acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) { - u32 encoded_length; - u32 length = 0; + u32 encoded_length; + u32 length = 0; + ACPI_FUNCTION_TRACE("ps_get_next_package_length"); - ACPI_FUNCTION_TRACE ("ps_get_next_package_length"); - - - encoded_length = (u32) ACPI_GET8 (parser_state->aml); + encoded_length = (u32) ACPI_GET8(parser_state->aml); parser_state->aml++; - switch (encoded_length >> 6) /* bits 6-7 contain encoding scheme */ { - case 0: /* 1-byte encoding (bits 0-5) */ + switch (encoded_length >> 6) { /* bits 6-7 contain encoding scheme */ + case 0: /* 1-byte encoding (bits 0-5) */ length = (encoded_length & 0x3F); break; + case 1: /* 2-byte encoding (next byte + bits 0-3) */ - case 1: /* 2-byte encoding (next byte + bits 0-3) */ - - length = ((ACPI_GET8 (parser_state->aml) << 04) | - (encoded_length & 0x0F)); + length = ((ACPI_GET8(parser_state->aml) << 04) | + (encoded_length & 0x0F)); parser_state->aml++; break; + case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */ - case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */ - - length = ((ACPI_GET8 (parser_state->aml + 1) << 12) | - (ACPI_GET8 (parser_state->aml) << 04) | - (encoded_length & 0x0F)); + length = ((ACPI_GET8(parser_state->aml + 1) << 12) | + (ACPI_GET8(parser_state->aml) << 04) | + (encoded_length & 0x0F)); parser_state->aml += 2; break; + case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ - case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ - - length = ((ACPI_GET8 (parser_state->aml + 2) << 20) | - (ACPI_GET8 (parser_state->aml + 1) << 12) | - (ACPI_GET8 (parser_state->aml) << 04) | - (encoded_length & 0x0F)); + length = ((ACPI_GET8(parser_state->aml + 2) << 20) | + (ACPI_GET8(parser_state->aml + 1) << 12) | + (ACPI_GET8(parser_state->aml) << 04) | + (encoded_length & 0x0F)); parser_state->aml += 3; break; @@ -127,10 +116,9 @@ acpi_ps_get_next_package_length ( break; } - return_VALUE (length); + return_VALUE(length); } - /******************************************************************************* * * FUNCTION: acpi_ps_get_next_package_end @@ -144,25 +132,21 @@ acpi_ps_get_next_package_length ( * ******************************************************************************/ -u8 * -acpi_ps_get_next_package_end ( - struct acpi_parse_state *parser_state) +u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state) { - u8 *start = parser_state->aml; - acpi_native_uint length; - - - ACPI_FUNCTION_TRACE ("ps_get_next_package_end"); + u8 *start = parser_state->aml; + acpi_native_uint length; + ACPI_FUNCTION_TRACE("ps_get_next_package_end"); /* Function below changes parser_state->Aml */ - length = (acpi_native_uint) acpi_ps_get_next_package_length (parser_state); + length = + (acpi_native_uint) acpi_ps_get_next_package_length(parser_state); - return_PTR (start + length); /* end of package */ + return_PTR(start + length); /* end of package */ } - /******************************************************************************* * * FUNCTION: acpi_ps_get_next_namestring @@ -178,20 +162,16 @@ acpi_ps_get_next_package_end ( * ******************************************************************************/ -char * -acpi_ps_get_next_namestring ( - struct acpi_parse_state *parser_state) +char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state) { - u8 *start = parser_state->aml; - u8 *end = parser_state->aml; - - - ACPI_FUNCTION_TRACE ("ps_get_next_namestring"); + u8 *start = parser_state->aml; + u8 *end = parser_state->aml; + ACPI_FUNCTION_TRACE("ps_get_next_namestring"); /* Handle multiple prefix characters */ - while (acpi_ps_is_prefix_char (ACPI_GET8 (end))) { + while (acpi_ps_is_prefix_char(ACPI_GET8(end))) { /* Include prefix '\\' or '^' */ end++; @@ -199,7 +179,7 @@ acpi_ps_get_next_namestring ( /* Decode the path */ - switch (ACPI_GET8 (end)) { + switch (ACPI_GET8(end)) { case 0: /* null_name */ @@ -221,7 +201,7 @@ acpi_ps_get_next_namestring ( /* Multiple name segments, 4 chars each */ - end += 2 + ((acpi_size) ACPI_GET8 (end + 1) * ACPI_NAME_SIZE); + end += 2 + ((acpi_size) ACPI_GET8(end + 1) * ACPI_NAME_SIZE); break; default: @@ -232,11 +212,10 @@ acpi_ps_get_next_namestring ( break; } - parser_state->aml = (u8*) end; - return_PTR ((char *) start); + parser_state->aml = (u8 *) end; + return_PTR((char *)start); } - /******************************************************************************* * * FUNCTION: acpi_ps_get_next_namepath @@ -259,24 +238,20 @@ acpi_ps_get_next_namestring ( ******************************************************************************/ acpi_status -acpi_ps_get_next_namepath ( - struct acpi_walk_state *walk_state, - struct acpi_parse_state *parser_state, - union acpi_parse_object *arg, - u8 method_call) +acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, + struct acpi_parse_state *parser_state, + union acpi_parse_object *arg, u8 method_call) { - char *path; - union acpi_parse_object *name_op; - acpi_status status = AE_OK; - union acpi_operand_object *method_desc; - struct acpi_namespace_node *node; - union acpi_generic_state scope_info; + char *path; + union acpi_parse_object *name_op; + acpi_status status = AE_OK; + union acpi_operand_object *method_desc; + struct acpi_namespace_node *node; + union acpi_generic_state scope_info; + ACPI_FUNCTION_TRACE("ps_get_next_namepath"); - ACPI_FUNCTION_TRACE ("ps_get_next_namepath"); - - - path = acpi_ps_get_next_namestring (parser_state); + path = acpi_ps_get_next_namestring(parser_state); /* Null path case is allowed */ @@ -296,49 +271,50 @@ acpi_ps_get_next_namepath ( * parent tree, but don't open a new scope -- we just want to lookup the * object (MUST BE mode EXECUTE to perform upsearch) */ - status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - NULL, &node); - if (ACPI_SUCCESS (status) && method_call) { + status = acpi_ns_lookup(&scope_info, path, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | + ACPI_NS_DONT_OPEN_SCOPE, NULL, &node); + if (ACPI_SUCCESS(status) && method_call) { if (node->type == ACPI_TYPE_METHOD) { /* This name is actually a control method invocation */ - method_desc = acpi_ns_get_attached_object (node); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Control Method - %p Desc %p Path=%p\n", - node, method_desc, path)); + method_desc = acpi_ns_get_attached_object(node); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "Control Method - %p Desc %p Path=%p\n", + node, method_desc, path)); - name_op = acpi_ps_alloc_op (AML_INT_NAMEPATH_OP); + name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP); if (!name_op) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Change arg into a METHOD CALL and attach name to it */ - acpi_ps_init_op (arg, AML_INT_METHODCALL_OP); + acpi_ps_init_op(arg, AML_INT_METHODCALL_OP); name_op->common.value.name = path; /* Point METHODCALL/NAME to the METHOD Node */ name_op->common.node = node; - acpi_ps_append_arg (arg, name_op); + acpi_ps_append_arg(arg, name_op); if (!method_desc) { - ACPI_REPORT_ERROR (( - "ps_get_next_namepath: Control Method %p has no attached object\n", - node)); - return_ACPI_STATUS (AE_AML_INTERNAL); + ACPI_REPORT_ERROR(("ps_get_next_namepath: Control Method %p has no attached object\n", node)); + return_ACPI_STATUS(AE_AML_INTERNAL); } - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Control Method - %p Args %X\n", - node, method_desc->method.param_count)); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "Control Method - %p Args %X\n", + node, + method_desc->method. + param_count)); /* Get the number of arguments to expect */ - walk_state->arg_count = method_desc->method.param_count; - return_ACPI_STATUS (AE_OK); + walk_state->arg_count = + method_desc->method.param_count; + return_ACPI_STATUS(AE_OK); } /* @@ -348,25 +324,26 @@ acpi_ps_get_next_namepath ( */ } - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { /* * 1) Any error other than NOT_FOUND is always severe * 2) NOT_FOUND is only important if we are executing a method. * 3) If executing a cond_ref_of opcode, NOT_FOUND is ok. */ - if ((((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) && - (status == AE_NOT_FOUND) && - (walk_state->op->common.aml_opcode != AML_COND_REF_OF_OP)) || - - (status != AE_NOT_FOUND)) { - ACPI_REPORT_NSERROR (path, status); - - acpi_os_printf ("search_node %p start_node %p return_node %p\n", - scope_info.scope.node, parser_state->start_node, node); - - - } - else { + if ((((walk_state-> + parse_flags & ACPI_PARSE_MODE_MASK) == + ACPI_PARSE_EXECUTE) && (status == AE_NOT_FOUND) + && (walk_state->op->common.aml_opcode != + AML_COND_REF_OF_OP)) + || (status != AE_NOT_FOUND)) { + ACPI_REPORT_NSERROR(path, status); + + acpi_os_printf + ("search_node %p start_node %p return_node %p\n", + scope_info.scope.node, + parser_state->start_node, node); + + } else { /* * We got a NOT_FOUND during table load or we encountered * a cond_ref_of(x) where the target does not exist. @@ -381,13 +358,12 @@ acpi_ps_get_next_namepath ( * Regardless of success/failure above, * Just initialize the Op with the pathname. */ - acpi_ps_init_op (arg, AML_INT_NAMEPATH_OP); + acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); arg->common.value.name = path; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ps_get_next_simple_arg @@ -403,87 +379,81 @@ acpi_ps_get_next_namepath ( ******************************************************************************/ void -acpi_ps_get_next_simple_arg ( - struct acpi_parse_state *parser_state, - u32 arg_type, - union acpi_parse_object *arg) +acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, + u32 arg_type, union acpi_parse_object *arg) { - ACPI_FUNCTION_TRACE_U32 ("ps_get_next_simple_arg", arg_type); - + ACPI_FUNCTION_TRACE_U32("ps_get_next_simple_arg", arg_type); switch (arg_type) { case ARGP_BYTEDATA: - acpi_ps_init_op (arg, AML_BYTE_OP); - arg->common.value.integer = (u32) ACPI_GET8 (parser_state->aml); + acpi_ps_init_op(arg, AML_BYTE_OP); + arg->common.value.integer = (u32) ACPI_GET8(parser_state->aml); parser_state->aml++; break; - case ARGP_WORDDATA: - acpi_ps_init_op (arg, AML_WORD_OP); + acpi_ps_init_op(arg, AML_WORD_OP); /* Get 2 bytes from the AML stream */ - ACPI_MOVE_16_TO_32 (&arg->common.value.integer, parser_state->aml); + ACPI_MOVE_16_TO_32(&arg->common.value.integer, + parser_state->aml); parser_state->aml += 2; break; - case ARGP_DWORDDATA: - acpi_ps_init_op (arg, AML_DWORD_OP); + acpi_ps_init_op(arg, AML_DWORD_OP); /* Get 4 bytes from the AML stream */ - ACPI_MOVE_32_TO_32 (&arg->common.value.integer, parser_state->aml); + ACPI_MOVE_32_TO_32(&arg->common.value.integer, + parser_state->aml); parser_state->aml += 4; break; - case ARGP_QWORDDATA: - acpi_ps_init_op (arg, AML_QWORD_OP); + acpi_ps_init_op(arg, AML_QWORD_OP); /* Get 8 bytes from the AML stream */ - ACPI_MOVE_64_TO_64 (&arg->common.value.integer, parser_state->aml); + ACPI_MOVE_64_TO_64(&arg->common.value.integer, + parser_state->aml); parser_state->aml += 8; break; - case ARGP_CHARLIST: - acpi_ps_init_op (arg, AML_STRING_OP); - arg->common.value.string = (char *) parser_state->aml; + acpi_ps_init_op(arg, AML_STRING_OP); + arg->common.value.string = (char *)parser_state->aml; - while (ACPI_GET8 (parser_state->aml) != '\0') { + while (ACPI_GET8(parser_state->aml) != '\0') { parser_state->aml++; } parser_state->aml++; break; - case ARGP_NAME: case ARGP_NAMESTRING: - acpi_ps_init_op (arg, AML_INT_NAMEPATH_OP); - arg->common.value.name = acpi_ps_get_next_namestring (parser_state); + acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); + arg->common.value.name = + acpi_ps_get_next_namestring(parser_state); break; - default: - ACPI_REPORT_ERROR (("Invalid arg_type %X\n", arg_type)); + ACPI_REPORT_ERROR(("Invalid arg_type %X\n", arg_type)); break; } return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ps_get_next_field @@ -496,24 +466,21 @@ acpi_ps_get_next_simple_arg ( * ******************************************************************************/ -static union acpi_parse_object * -acpi_ps_get_next_field ( - struct acpi_parse_state *parser_state) +static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state + *parser_state) { - u32 aml_offset = (u32) - ACPI_PTR_DIFF (parser_state->aml, - parser_state->aml_start); - union acpi_parse_object *field; - u16 opcode; - u32 name; - - - ACPI_FUNCTION_TRACE ("ps_get_next_field"); + u32 aml_offset = (u32) + ACPI_PTR_DIFF(parser_state->aml, + parser_state->aml_start); + union acpi_parse_object *field; + u16 opcode; + u32 name; + ACPI_FUNCTION_TRACE("ps_get_next_field"); /* Determine field type */ - switch (ACPI_GET8 (parser_state->aml)) { + switch (ACPI_GET8(parser_state->aml)) { default: opcode = AML_INT_NAMEDFIELD_OP; @@ -534,9 +501,9 @@ acpi_ps_get_next_field ( /* Allocate a new field op */ - field = acpi_ps_alloc_op (opcode); + field = acpi_ps_alloc_op(opcode); if (!field) { - return_PTR (NULL); + return_PTR(NULL); } field->common.aml_offset = aml_offset; @@ -548,33 +515,34 @@ acpi_ps_get_next_field ( /* Get the 4-character name */ - ACPI_MOVE_32_TO_32 (&name, parser_state->aml); - acpi_ps_set_name (field, name); + ACPI_MOVE_32_TO_32(&name, parser_state->aml); + acpi_ps_set_name(field, name); parser_state->aml += ACPI_NAME_SIZE; /* Get the length which is encoded as a package length */ - field->common.value.size = acpi_ps_get_next_package_length (parser_state); + field->common.value.size = + acpi_ps_get_next_package_length(parser_state); break; - case AML_INT_RESERVEDFIELD_OP: /* Get the length which is encoded as a package length */ - field->common.value.size = acpi_ps_get_next_package_length (parser_state); + field->common.value.size = + acpi_ps_get_next_package_length(parser_state); break; - case AML_INT_ACCESSFIELD_OP: /* * Get access_type and access_attrib and merge into the field Op * access_type is first operand, access_attribute is second */ - field->common.value.integer = (ACPI_GET8 (parser_state->aml) << 8); + field->common.value.integer = + (ACPI_GET8(parser_state->aml) << 8); parser_state->aml++; - field->common.value.integer |= ACPI_GET8 (parser_state->aml); + field->common.value.integer |= ACPI_GET8(parser_state->aml); parser_state->aml++; break; @@ -584,10 +552,9 @@ acpi_ps_get_next_field ( break; } - return_PTR (field); + return_PTR(field); } - /******************************************************************************* * * FUNCTION: acpi_ps_get_next_arg @@ -605,21 +572,17 @@ acpi_ps_get_next_field ( ******************************************************************************/ acpi_status -acpi_ps_get_next_arg ( - struct acpi_walk_state *walk_state, - struct acpi_parse_state *parser_state, - u32 arg_type, - union acpi_parse_object **return_arg) +acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, + struct acpi_parse_state *parser_state, + u32 arg_type, union acpi_parse_object **return_arg) { - union acpi_parse_object *arg = NULL; - union acpi_parse_object *prev = NULL; - union acpi_parse_object *field; - u32 subop; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_PTR ("ps_get_next_arg", parser_state); + union acpi_parse_object *arg = NULL; + union acpi_parse_object *prev = NULL; + union acpi_parse_object *field; + u32 subop; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE_PTR("ps_get_next_arg", parser_state); switch (arg_type) { case ARGP_BYTEDATA: @@ -631,37 +594,35 @@ acpi_ps_get_next_arg ( /* Constants, strings, and namestrings are all the same size */ - arg = acpi_ps_alloc_op (AML_BYTE_OP); + arg = acpi_ps_alloc_op(AML_BYTE_OP); if (!arg) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } - acpi_ps_get_next_simple_arg (parser_state, arg_type, arg); + acpi_ps_get_next_simple_arg(parser_state, arg_type, arg); break; - case ARGP_PKGLENGTH: /* Package length, nothing returned */ - parser_state->pkg_end = acpi_ps_get_next_package_end (parser_state); + parser_state->pkg_end = + acpi_ps_get_next_package_end(parser_state); break; - case ARGP_FIELDLIST: if (parser_state->aml < parser_state->pkg_end) { /* Non-empty list */ while (parser_state->aml < parser_state->pkg_end) { - field = acpi_ps_get_next_field (parser_state); + field = acpi_ps_get_next_field(parser_state); if (!field) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } if (prev) { prev->common.next = field; - } - else { + } else { arg = field; } prev = field; @@ -673,21 +634,21 @@ acpi_ps_get_next_arg ( } break; - case ARGP_BYTELIST: if (parser_state->aml < parser_state->pkg_end) { /* Non-empty list */ - arg = acpi_ps_alloc_op (AML_INT_BYTELIST_OP); + arg = acpi_ps_alloc_op(AML_INT_BYTELIST_OP); if (!arg) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Fill in bytelist data */ arg->common.value.size = (u32) - ACPI_PTR_DIFF (parser_state->pkg_end, parser_state->aml); + ACPI_PTR_DIFF(parser_state->pkg_end, + parser_state->aml); arg->named.data = parser_state->aml; /* Skip to End of byte data */ @@ -696,32 +657,31 @@ acpi_ps_get_next_arg ( } break; - case ARGP_TARGET: case ARGP_SUPERNAME: case ARGP_SIMPLENAME: - subop = acpi_ps_peek_opcode (parser_state); - if (subop == 0 || - acpi_ps_is_leading_char (subop) || - acpi_ps_is_prefix_char (subop)) { + subop = acpi_ps_peek_opcode(parser_state); + if (subop == 0 || + acpi_ps_is_leading_char(subop) || + acpi_ps_is_prefix_char(subop)) { /* null_name or name_string */ - arg = acpi_ps_alloc_op (AML_INT_NAMEPATH_OP); + arg = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP); if (!arg) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } - status = acpi_ps_get_next_namepath (walk_state, parser_state, arg, 0); - } - else { + status = + acpi_ps_get_next_namepath(walk_state, parser_state, + arg, 0); + } else { /* Single complex argument, nothing returned */ walk_state->arg_count = 1; } break; - case ARGP_DATAOBJ: case ARGP_TERMARG: @@ -730,7 +690,6 @@ acpi_ps_get_next_arg ( walk_state->arg_count = 1; break; - case ARGP_DATAOBJLIST: case ARGP_TERMLIST: case ARGP_OBJLIST: @@ -742,14 +701,13 @@ acpi_ps_get_next_arg ( } break; - default: - ACPI_REPORT_ERROR (("Invalid arg_type: %X\n", arg_type)); + ACPI_REPORT_ERROR(("Invalid arg_type: %X\n", arg_type)); status = AE_AML_OPERAND_TYPE; break; } *return_arg = arg; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c index 551d54b..088d339 100644 --- a/drivers/acpi/parser/psloop.c +++ b/drivers/acpi/parser/psloop.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* * Parse the AML and build an operation tree as most interpreters, * like Perl, do. Parsing is done by hand rather than with a YACC @@ -57,10 +56,9 @@ #include #define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("psloop") - -static u32 acpi_gbl_depth = 0; +ACPI_MODULE_NAME("psloop") +static u32 acpi_gbl_depth = 0; /******************************************************************************* * @@ -75,23 +73,20 @@ static u32 acpi_gbl_depth = 0; * ******************************************************************************/ -acpi_status -acpi_ps_parse_loop ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - acpi_status status2; - union acpi_parse_object *op = NULL; /* current op */ - union acpi_parse_object *arg = NULL; - union acpi_parse_object *pre_op = NULL; - struct acpi_parse_state *parser_state; - u8 *aml_op_start = NULL; - + acpi_status status = AE_OK; + acpi_status status2; + union acpi_parse_object *op = NULL; /* current op */ + union acpi_parse_object *arg = NULL; + union acpi_parse_object *pre_op = NULL; + struct acpi_parse_state *parser_state; + u8 *aml_op_start = NULL; - ACPI_FUNCTION_TRACE_PTR ("ps_parse_loop", walk_state); + ACPI_FUNCTION_TRACE_PTR("ps_parse_loop", walk_state); if (walk_state->descending_callback == NULL) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } parser_state = &walk_state->parser_state; @@ -102,45 +97,56 @@ acpi_ps_parse_loop ( if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) { /* We are restarting a preempted control method */ - if (acpi_ps_has_completed_scope (parser_state)) { + if (acpi_ps_has_completed_scope(parser_state)) { /* * We must check if a predicate to an IF or WHILE statement * was just completed */ if ((parser_state->scope->parse_scope.op) && - ((parser_state->scope->parse_scope.op->common.aml_opcode == AML_IF_OP) || - (parser_state->scope->parse_scope.op->common.aml_opcode == AML_WHILE_OP)) && - (walk_state->control_state) && - (walk_state->control_state->common.state == - ACPI_CONTROL_PREDICATE_EXECUTING)) { + ((parser_state->scope->parse_scope.op->common. + aml_opcode == AML_IF_OP) + || (parser_state->scope->parse_scope.op->common. + aml_opcode == AML_WHILE_OP)) + && (walk_state->control_state) + && (walk_state->control_state->common.state == + ACPI_CONTROL_PREDICATE_EXECUTING)) { /* * A predicate was just completed, get the value of the * predicate and branch based on that value */ walk_state->op = NULL; - status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE)); - if (ACPI_FAILURE (status) && - ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) { + status = + acpi_ds_get_predicate_value(walk_state, + ACPI_TO_POINTER + (TRUE)); + if (ACPI_FAILURE(status) + && ((status & AE_CODE_MASK) != + AE_CODE_CONTROL)) { if (status == AE_AML_NO_RETURN_VALUE) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invoked method did not return a value, %s\n", - acpi_format_exception (status))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invoked method did not return a value, %s\n", + acpi_format_exception + (status))); } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "get_predicate Failed, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "get_predicate Failed, %s\n", + acpi_format_exception + (status))); + return_ACPI_STATUS(status); } - status = acpi_ps_next_parse_state (walk_state, op, status); + status = + acpi_ps_next_parse_state(walk_state, op, + status); } - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); - } - else if (walk_state->prev_op) { + acpi_ps_pop_scope(parser_state, &op, + &walk_state->arg_types, + &walk_state->arg_count); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "Popped scope, Op=%p\n", op)); + } else if (walk_state->prev_op) { /* We were in the middle of an op */ op = walk_state->prev_op; @@ -156,9 +162,10 @@ acpi_ps_parse_loop ( if (!op) { /* Get the next opcode from the AML stream */ - walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml, - parser_state->aml_start); - walk_state->opcode = acpi_ps_peek_opcode (parser_state); + walk_state->aml_offset = + (u32) ACPI_PTR_DIFF(parser_state->aml, + parser_state->aml_start); + walk_state->opcode = acpi_ps_peek_opcode(parser_state); /* * First cut to determine what we have found: @@ -166,7 +173,8 @@ acpi_ps_parse_loop ( * 2) A name string * 3) An unknown/invalid opcode */ - walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); + walk_state->op_info = + acpi_ps_get_opcode_info(walk_state->opcode); switch (walk_state->op_info->class) { case AML_CLASS_ASCII: case AML_CLASS_PREFIX: @@ -182,11 +190,13 @@ acpi_ps_parse_loop ( /* The opcode is unrecognized. Just skip unknown opcodes */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Found unknown opcode %X at AML address %p offset %X, ignoring\n", - walk_state->opcode, parser_state->aml, walk_state->aml_offset)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Found unknown opcode %X at AML address %p offset %X, ignoring\n", + walk_state->opcode, + parser_state->aml, + walk_state->aml_offset)); - ACPI_DUMP_BUFFER (parser_state->aml, 128); + ACPI_DUMP_BUFFER(parser_state->aml, 128); /* Assume one-byte bad opcode */ @@ -197,8 +207,10 @@ acpi_ps_parse_loop ( /* Found opcode info, this is a normal opcode */ - parser_state->aml += acpi_ps_get_opcode_size (walk_state->opcode); - walk_state->arg_types = walk_state->op_info->parse_args; + parser_state->aml += + acpi_ps_get_opcode_size(walk_state->opcode); + walk_state->arg_types = + walk_state->op_info->parse_args; break; } @@ -208,7 +220,9 @@ acpi_ps_parse_loop ( /* Allocate a new pre_op if necessary */ if (!pre_op) { - pre_op = acpi_ps_alloc_op (walk_state->opcode); + pre_op = + acpi_ps_alloc_op(walk_state-> + opcode); if (!pre_op) { status = AE_NO_MEMORY; goto close_this_op; @@ -222,30 +236,40 @@ acpi_ps_parse_loop ( * Get and append arguments until we find the node that contains * the name (the type ARGP_NAME). */ - while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && - (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME)) { - status = acpi_ps_get_next_arg (walk_state, parser_state, - GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg); - if (ACPI_FAILURE (status)) { + while (GET_CURRENT_ARG_TYPE + (walk_state->arg_types) + && + (GET_CURRENT_ARG_TYPE + (walk_state->arg_types) != ARGP_NAME)) { + status = + acpi_ps_get_next_arg(walk_state, + parser_state, + GET_CURRENT_ARG_TYPE + (walk_state-> + arg_types), + &arg); + if (ACPI_FAILURE(status)) { goto close_this_op; } - acpi_ps_append_arg (pre_op, arg); - INCREMENT_ARG_LIST (walk_state->arg_types); + acpi_ps_append_arg(pre_op, arg); + INCREMENT_ARG_LIST(walk_state-> + arg_types); } /* * Make sure that we found a NAME and didn't run out of * arguments */ - if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) { + if (!GET_CURRENT_ARG_TYPE + (walk_state->arg_types)) { status = AE_AML_NO_OPERAND; goto close_this_op; } /* We know that this arg is a name, move to next arg */ - INCREMENT_ARG_LIST (walk_state->arg_types); + INCREMENT_ARG_LIST(walk_state->arg_types); /* * Find the object. This will either insert the object into @@ -253,11 +277,14 @@ acpi_ps_parse_loop ( */ walk_state->op = NULL; - status = walk_state->descending_callback (walk_state, &op); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "During name lookup/catalog, %s\n", - acpi_format_exception (status))); + status = + walk_state->descending_callback(walk_state, + &op); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "During name lookup/catalog, %s\n", + acpi_format_exception + (status))); goto close_this_op; } @@ -265,17 +292,20 @@ acpi_ps_parse_loop ( continue; } - status = acpi_ps_next_parse_state (walk_state, op, status); + status = + acpi_ps_next_parse_state(walk_state, op, + status); if (status == AE_CTRL_PENDING) { status = AE_OK; goto close_this_op; } - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { goto close_this_op; } - acpi_ps_append_arg (op, pre_op->common.value.arg); + acpi_ps_append_arg(op, + pre_op->common.value.arg); acpi_gbl_depth++; if (op->common.aml_opcode == AML_REGION_OP) { @@ -291,15 +321,15 @@ acpi_ps_parse_loop ( * * (Length is unknown until parse of the body complete) */ - op->named.data = aml_op_start; - op->named.length = 0; + op->named.data = aml_op_start; + op->named.length = 0; } - } - else { + } else { /* Not a named opcode, just allocate Op and append to parent */ - walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); - op = acpi_ps_alloc_op (walk_state->opcode); + walk_state->op_info = + acpi_ps_get_opcode_info(walk_state->opcode); + op = acpi_ps_alloc_op(walk_state->opcode); if (!op) { status = AE_NO_MEMORY; goto close_this_op; @@ -310,11 +340,12 @@ acpi_ps_parse_loop ( * Backup to beginning of create_xXXfield declaration * body_length is unknown until we parse the body */ - op->named.data = aml_op_start; - op->named.length = 0; + op->named.data = aml_op_start; + op->named.length = 0; } - acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op); + acpi_ps_append_arg(acpi_ps_get_parent_scope + (parser_state), op); if ((walk_state->descending_callback != NULL)) { /* @@ -323,14 +354,20 @@ acpi_ps_parse_loop ( */ walk_state->op = op; - status = walk_state->descending_callback (walk_state, &op); - status = acpi_ps_next_parse_state (walk_state, op, status); + status = + walk_state-> + descending_callback(walk_state, + &op); + status = + acpi_ps_next_parse_state(walk_state, + op, + status); if (status == AE_CTRL_PENDING) { status = AE_OK; goto close_this_op; } - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { goto close_this_op; } } @@ -339,14 +376,15 @@ acpi_ps_parse_loop ( op->common.aml_offset = walk_state->aml_offset; if (walk_state->op_info) { - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n", - (u32) op->common.aml_opcode, walk_state->op_info->name, - op, parser_state->aml, op->common.aml_offset)); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n", + (u32) op->common.aml_opcode, + walk_state->op_info->name, op, + parser_state->aml, + op->common.aml_offset)); } } - /* * Start arg_count at zero because we don't know if there are * any args yet @@ -359,22 +397,27 @@ acpi_ps_parse_loop ( /* Get arguments */ switch (op->common.aml_opcode) { - case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ - case AML_WORD_OP: /* AML_WORDDATA_ARG */ - case AML_DWORD_OP: /* AML_DWORDATA_ARG */ - case AML_QWORD_OP: /* AML_QWORDATA_ARG */ - case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ + case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ + case AML_WORD_OP: /* AML_WORDDATA_ARG */ + case AML_DWORD_OP: /* AML_DWORDATA_ARG */ + case AML_QWORD_OP: /* AML_QWORDATA_ARG */ + case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ /* Fill in constant or string argument directly */ - acpi_ps_get_next_simple_arg (parser_state, - GET_CURRENT_ARG_TYPE (walk_state->arg_types), op); + acpi_ps_get_next_simple_arg(parser_state, + GET_CURRENT_ARG_TYPE + (walk_state-> + arg_types), op); break; - case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ + case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ - status = acpi_ps_get_next_namepath (walk_state, parser_state, op, 1); - if (ACPI_FAILURE (status)) { + status = + acpi_ps_get_next_namepath(walk_state, + parser_state, op, + 1); + if (ACPI_FAILURE(status)) { goto close_this_op; } @@ -386,34 +429,46 @@ acpi_ps_parse_loop ( * Op is not a constant or string, append each argument * to the Op */ - while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && - !walk_state->arg_count) { + while (GET_CURRENT_ARG_TYPE + (walk_state->arg_types) + && !walk_state->arg_count) { walk_state->aml_offset = (u32) - ACPI_PTR_DIFF (parser_state->aml, parser_state->aml_start); - - status = acpi_ps_get_next_arg (walk_state, parser_state, - GET_CURRENT_ARG_TYPE (walk_state->arg_types), - &arg); - if (ACPI_FAILURE (status)) { + ACPI_PTR_DIFF(parser_state->aml, + parser_state-> + aml_start); + + status = + acpi_ps_get_next_arg(walk_state, + parser_state, + GET_CURRENT_ARG_TYPE + (walk_state-> + arg_types), + &arg); + if (ACPI_FAILURE(status)) { goto close_this_op; } if (arg) { - arg->common.aml_offset = walk_state->aml_offset; - acpi_ps_append_arg (op, arg); + arg->common.aml_offset = + walk_state->aml_offset; + acpi_ps_append_arg(op, arg); } - INCREMENT_ARG_LIST (walk_state->arg_types); + INCREMENT_ARG_LIST(walk_state-> + arg_types); } - /* Special processing for certain opcodes */ - /* TBD (remove): Temporary mechanism to disable this code if needed */ + /* TBD (remove): Temporary mechanism to disable this code if needed */ #ifdef ACPI_ENABLE_MODULE_LEVEL_CODE - if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) && - ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) { + if ((walk_state->pass_number <= + ACPI_IMODE_LOAD_PASS1) + && + ((walk_state-> + parse_flags & ACPI_PARSE_DISASSEMBLE) == + 0)) { /* * We want to skip If/Else/While constructs during Pass1 * because we want to actually conditionally execute the @@ -427,12 +482,13 @@ acpi_ps_parse_loop ( case AML_ELSE_OP: case AML_WHILE_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Pass1: Skipping an If/Else/While body\n")); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "Pass1: Skipping an If/Else/While body\n")); /* Skip body of if/else/while in pass 1 */ - parser_state->aml = parser_state->pkg_end; + parser_state->aml = + parser_state->pkg_end; walk_state->arg_count = 0; break; @@ -451,13 +507,15 @@ acpi_ps_parse_loop ( * * Save the length and address of the body */ - op->named.data = parser_state->aml; - op->named.length = (u32) (parser_state->pkg_end - - parser_state->aml); + op->named.data = parser_state->aml; + op->named.length = + (u32) (parser_state->pkg_end - + parser_state->aml); /* Skip body of method */ - parser_state->aml = parser_state->pkg_end; + parser_state->aml = + parser_state->pkg_end; walk_state->arg_count = 0; break; @@ -466,20 +524,25 @@ acpi_ps_parse_loop ( case AML_VAR_PACKAGE_OP: if ((op->common.parent) && - (op->common.parent->common.aml_opcode == AML_NAME_OP) && - (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) { + (op->common.parent->common. + aml_opcode == AML_NAME_OP) + && (walk_state->pass_number <= + ACPI_IMODE_LOAD_PASS2)) { /* * Skip parsing of Buffers and Packages * because we don't have enough info in the first pass * to parse them correctly. */ - op->named.data = aml_op_start; - op->named.length = (u32) (parser_state->pkg_end - - aml_op_start); + op->named.data = aml_op_start; + op->named.length = + (u32) (parser_state-> + pkg_end - + aml_op_start); /* Skip body */ - parser_state->aml = parser_state->pkg_end; + parser_state->aml = + parser_state->pkg_end; walk_state->arg_count = 0; } break; @@ -487,8 +550,9 @@ acpi_ps_parse_loop ( case AML_WHILE_OP: if (walk_state->control_state) { - walk_state->control_state->control.package_end = - parser_state->pkg_end; + walk_state->control_state-> + control.package_end = + parser_state->pkg_end; } break; @@ -508,9 +572,10 @@ acpi_ps_parse_loop ( * There are arguments (complex ones), push Op and * prepare for argument */ - status = acpi_ps_push_scope (parser_state, op, - walk_state->arg_types, walk_state->arg_count); - if (ACPI_FAILURE (status)) { + status = acpi_ps_push_scope(parser_state, op, + walk_state->arg_types, + walk_state->arg_count); + if (ACPI_FAILURE(status)) { goto close_this_op; } op = NULL; @@ -521,7 +586,8 @@ acpi_ps_parse_loop ( * All arguments have been processed -- Op is complete, * prepare for next */ - walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); + walk_state->op_info = + acpi_ps_get_opcode_info(op->common.aml_opcode); if (walk_state->op_info->flags & AML_NAMED) { if (acpi_gbl_depth) { acpi_gbl_depth--; @@ -536,7 +602,8 @@ acpi_ps_parse_loop ( * Completed parsing an op_region declaration, we now * know the length. */ - op->named.length = (u32) (parser_state->aml - op->named.data); + op->named.length = + (u32) (parser_state->aml - op->named.data); } } @@ -547,25 +614,26 @@ acpi_ps_parse_loop ( * * body_length is unknown until we parse the body */ - op->named.length = (u32) (parser_state->aml - op->named.data); + op->named.length = + (u32) (parser_state->aml - op->named.data); } /* This op complete, notify the dispatcher */ if (walk_state->ascending_callback != NULL) { - walk_state->op = op; + walk_state->op = op; walk_state->opcode = op->common.aml_opcode; - status = walk_state->ascending_callback (walk_state); - status = acpi_ps_next_parse_state (walk_state, op, status); + status = walk_state->ascending_callback(walk_state); + status = + acpi_ps_next_parse_state(walk_state, op, status); if (status == AE_CTRL_PENDING) { status = AE_OK; goto close_this_op; } } - -close_this_op: + close_this_op: /* * Finished one argument of the containing scope */ @@ -574,15 +642,15 @@ close_this_op: /* Finished with pre_op */ if (pre_op) { - acpi_ps_free_op (pre_op); + acpi_ps_free_op(pre_op); pre_op = NULL; } /* Close this Op (will result in parse subtree deletion) */ - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); + status2 = acpi_ps_complete_this_op(walk_state, op); + if (ACPI_FAILURE(status2)) { + return_ACPI_STATUS(status2); } op = NULL; @@ -590,68 +658,74 @@ close_this_op: case AE_OK: break; - case AE_CTRL_TRANSFER: /* We are about to transfer to a called method. */ walk_state->prev_op = op; walk_state->prev_arg_types = walk_state->arg_types; - return_ACPI_STATUS (status); - + return_ACPI_STATUS(status); case AE_CTRL_END: - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); + acpi_ps_pop_scope(parser_state, &op, + &walk_state->arg_types, + &walk_state->arg_count); if (op) { - walk_state->op = op; - walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); + walk_state->op = op; + walk_state->op_info = + acpi_ps_get_opcode_info(op->common. + aml_opcode); walk_state->opcode = op->common.aml_opcode; - status = walk_state->ascending_callback (walk_state); - status = acpi_ps_next_parse_state (walk_state, op, status); + status = + walk_state->ascending_callback(walk_state); + status = + acpi_ps_next_parse_state(walk_state, op, + status); - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); + status2 = + acpi_ps_complete_this_op(walk_state, op); + if (ACPI_FAILURE(status2)) { + return_ACPI_STATUS(status2); } op = NULL; } status = AE_OK; break; - case AE_CTRL_BREAK: case AE_CTRL_CONTINUE: /* Pop off scopes until we find the While */ while (!op || (op->common.aml_opcode != AML_WHILE_OP)) { - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); + acpi_ps_pop_scope(parser_state, &op, + &walk_state->arg_types, + &walk_state->arg_count); } /* Close this iteration of the While loop */ - walk_state->op = op; - walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); + walk_state->op = op; + walk_state->op_info = + acpi_ps_get_opcode_info(op->common.aml_opcode); walk_state->opcode = op->common.aml_opcode; - status = walk_state->ascending_callback (walk_state); - status = acpi_ps_next_parse_state (walk_state, op, status); + status = walk_state->ascending_callback(walk_state); + status = + acpi_ps_next_parse_state(walk_state, op, status); - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); + status2 = acpi_ps_complete_this_op(walk_state, op); + if (ACPI_FAILURE(status2)) { + return_ACPI_STATUS(status2); } op = NULL; status = AE_OK; break; - case AE_CTRL_TERMINATE: status = AE_OK; @@ -659,61 +733,66 @@ close_this_op: /* Clean up */ do { if (op) { - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); + status2 = + acpi_ps_complete_this_op(walk_state, + op); + if (ACPI_FAILURE(status2)) { + return_ACPI_STATUS(status2); } } - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); + acpi_ps_pop_scope(parser_state, &op, + &walk_state->arg_types, + &walk_state->arg_count); } while (op); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); - - default: /* All other non-AE_OK status */ + default: /* All other non-AE_OK status */ do { if (op) { - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); + status2 = + acpi_ps_complete_this_op(walk_state, + op); + if (ACPI_FAILURE(status2)) { + return_ACPI_STATUS(status2); } } - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); + acpi_ps_pop_scope(parser_state, &op, + &walk_state->arg_types, + &walk_state->arg_count); } while (op); - /* * TBD: Cleanup parse ops on error */ #if 0 if (op == NULL) { - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); + acpi_ps_pop_scope(parser_state, &op, + &walk_state->arg_types, + &walk_state->arg_count); } #endif walk_state->prev_op = op; walk_state->prev_arg_types = walk_state->arg_types; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* This scope complete? */ - if (acpi_ps_has_completed_scope (parser_state)) { - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); - } - else { + if (acpi_ps_has_completed_scope(parser_state)) { + acpi_ps_pop_scope(parser_state, &op, + &walk_state->arg_types, + &walk_state->arg_count); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "Popped scope, Op=%p\n", op)); + } else { op = NULL; } - } /* while parser_state->Aml */ - + } /* while parser_state->Aml */ /* * Complete the last Op (if not completed), and clear the scope stack. @@ -721,16 +800,22 @@ close_this_op: * of open scopes (such as when several ASL blocks are closed with * sequential closing braces). We want to terminate each one cleanly. */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", op)); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n", + op)); do { if (op) { if (walk_state->ascending_callback != NULL) { - walk_state->op = op; - walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); + walk_state->op = op; + walk_state->op_info = + acpi_ps_get_opcode_info(op->common. + aml_opcode); walk_state->opcode = op->common.aml_opcode; - status = walk_state->ascending_callback (walk_state); - status = acpi_ps_next_parse_state (walk_state, op, status); + status = + walk_state->ascending_callback(walk_state); + status = + acpi_ps_next_parse_state(walk_state, op, + status); if (status == AE_CTRL_PENDING) { status = AE_OK; goto close_this_op; @@ -742,40 +827,48 @@ close_this_op: /* Clean up */ do { if (op) { - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); + status2 = + acpi_ps_complete_this_op + (walk_state, op); + if (ACPI_FAILURE + (status2)) { + return_ACPI_STATUS + (status2); } } - acpi_ps_pop_scope (parser_state, &op, - &walk_state->arg_types, &walk_state->arg_count); + acpi_ps_pop_scope(parser_state, + &op, + &walk_state-> + arg_types, + &walk_state-> + arg_count); } while (op); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - else if (ACPI_FAILURE (status)) { + else if (ACPI_FAILURE(status)) { /* First error is most important */ - (void) acpi_ps_complete_this_op (walk_state, op); - return_ACPI_STATUS (status); + (void) + acpi_ps_complete_this_op(walk_state, + op); + return_ACPI_STATUS(status); } } - status2 = acpi_ps_complete_this_op (walk_state, op); - if (ACPI_FAILURE (status2)) { - return_ACPI_STATUS (status2); + status2 = acpi_ps_complete_this_op(walk_state, op); + if (ACPI_FAILURE(status2)) { + return_ACPI_STATUS(status2); } } - acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, - &walk_state->arg_count); + acpi_ps_pop_scope(parser_state, &op, &walk_state->arg_types, + &walk_state->arg_count); } while (op); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c index 6f7594a..229ae86 100644 --- a/drivers/acpi/parser/psopcode.c +++ b/drivers/acpi/parser/psopcode.c @@ -41,16 +41,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include - #define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("psopcode") - +ACPI_MODULE_NAME("psopcode") /******************************************************************************* * @@ -62,7 +59,6 @@ * the operand type. * ******************************************************************************/ - /* * Summary of opcode types/flags * @@ -180,156 +176,468 @@ AML_CREATE_QWORD_FIELD_OP ******************************************************************************/ - - /* * Master Opcode information table. A summary of everything we know about each * opcode, all in one place. */ -const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = -{ +const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = { /*! [Begin] no source code translation */ /* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */ -/* 00 */ ACPI_OP ("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), -/* 01 */ ACPI_OP ("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), -/* 02 */ ACPI_OP ("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 03 */ ACPI_OP ("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 04 */ ACPI_OP ("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), -/* 05 */ ACPI_OP ("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), -/* 06 */ ACPI_OP ("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), -/* 07 */ ACPI_OP ("String", ARGP_STRING_OP, ARGI_STRING_OP, ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), -/* 08 */ ACPI_OP ("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 09 */ ACPI_OP ("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, ACPI_TYPE_BUFFER, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), -/* 0A */ ACPI_OP ("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), -/* 0B */ ACPI_OP ("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), -/* 0C */ ACPI_OP ("Local0", ARGP_LOCAL0, ARGI_LOCAL0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 0D */ ACPI_OP ("Local1", ARGP_LOCAL1, ARGI_LOCAL1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 0E */ ACPI_OP ("Local2", ARGP_LOCAL2, ARGI_LOCAL2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 0F */ ACPI_OP ("Local3", ARGP_LOCAL3, ARGI_LOCAL3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 10 */ ACPI_OP ("Local4", ARGP_LOCAL4, ARGI_LOCAL4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 11 */ ACPI_OP ("Local5", ARGP_LOCAL5, ARGI_LOCAL5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 12 */ ACPI_OP ("Local6", ARGP_LOCAL6, ARGI_LOCAL6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 13 */ ACPI_OP ("Local7", ARGP_LOCAL7, ARGI_LOCAL7, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 14 */ ACPI_OP ("Arg0", ARGP_ARG0, ARGI_ARG0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 15 */ ACPI_OP ("Arg1", ARGP_ARG1, ARGI_ARG1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 16 */ ACPI_OP ("Arg2", ARGP_ARG2, ARGI_ARG2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 17 */ ACPI_OP ("Arg3", ARGP_ARG3, ARGI_ARG3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 18 */ ACPI_OP ("Arg4", ARGP_ARG4, ARGI_ARG4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 19 */ ACPI_OP ("Arg5", ARGP_ARG5, ARGI_ARG5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 1A */ ACPI_OP ("Arg6", ARGP_ARG6, ARGI_ARG6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 1B */ ACPI_OP ("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), -/* 1C */ ACPI_OP ("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), -/* 1D */ ACPI_OP ("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 1E */ ACPI_OP ("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), -/* 1F */ ACPI_OP ("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 20 */ ACPI_OP ("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), -/* 21 */ ACPI_OP ("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), -/* 22 */ ACPI_OP ("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 23 */ ACPI_OP ("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_2T_1R, AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT), -/* 24 */ ACPI_OP ("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 25 */ ACPI_OP ("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 26 */ ACPI_OP ("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 27 */ ACPI_OP ("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 28 */ ACPI_OP ("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 29 */ ACPI_OP ("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 2A */ ACPI_OP ("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 2B */ ACPI_OP ("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 2C */ ACPI_OP ("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 2D */ ACPI_OP ("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 2E */ ACPI_OP ("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), -/* 2F */ ACPI_OP ("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R), -/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), -/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R), -/* 32 */ ACPI_OP ("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT), -/* 33 */ ACPI_OP ("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), -/* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), -/* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), -/* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), -/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), -/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), -/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), -/* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), -/* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), -/* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), -/* 3D */ ACPI_OP ("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), -/* 3E */ ACPI_OP ("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), -/* 3F */ ACPI_OP ("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), -/* 40 */ ACPI_OP ("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), -/* 41 */ ACPI_OP ("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), -/* 42 */ ACPI_OP ("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), -/* 43 */ ACPI_OP ("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), -/* 44 */ ACPI_OP ("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), -/* 45 */ ACPI_OP ("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), +/* 00 */ ACPI_OP("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, + AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), +/* 01 */ ACPI_OP("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, + AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), +/* 02 */ ACPI_OP("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, + ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, + AML_TYPE_NAMED_SIMPLE, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_NSNODE | AML_NAMED), +/* 03 */ ACPI_OP("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, + AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_NSNODE | AML_NAMED), +/* 04 */ ACPI_OP("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, + ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, + AML_TYPE_LITERAL, AML_CONSTANT), +/* 05 */ ACPI_OP("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, + ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, + AML_TYPE_LITERAL, AML_CONSTANT), +/* 06 */ ACPI_OP("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, + ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, + AML_TYPE_LITERAL, AML_CONSTANT), +/* 07 */ ACPI_OP("String", ARGP_STRING_OP, ARGI_STRING_OP, + ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, + AML_TYPE_LITERAL, AML_CONSTANT), +/* 08 */ ACPI_OP("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, + ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, + AML_TYPE_NAMED_NO_OBJ, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_NSNODE | AML_NAMED), +/* 09 */ ACPI_OP("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, + ACPI_TYPE_BUFFER, AML_CLASS_CREATE, + AML_TYPE_CREATE_OBJECT, + AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), +/* 0A */ ACPI_OP("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, + ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, + AML_TYPE_CREATE_OBJECT, + AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), +/* 0B */ ACPI_OP("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, + ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, + AML_TYPE_NAMED_COMPLEX, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_NSNODE | AML_NAMED | AML_DEFER), +/* 0C */ ACPI_OP("Local0", ARGP_LOCAL0, ARGI_LOCAL0, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_LOCAL_VARIABLE, 0), +/* 0D */ ACPI_OP("Local1", ARGP_LOCAL1, ARGI_LOCAL1, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_LOCAL_VARIABLE, 0), +/* 0E */ ACPI_OP("Local2", ARGP_LOCAL2, ARGI_LOCAL2, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_LOCAL_VARIABLE, 0), +/* 0F */ ACPI_OP("Local3", ARGP_LOCAL3, ARGI_LOCAL3, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_LOCAL_VARIABLE, 0), +/* 10 */ ACPI_OP("Local4", ARGP_LOCAL4, ARGI_LOCAL4, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_LOCAL_VARIABLE, 0), +/* 11 */ ACPI_OP("Local5", ARGP_LOCAL5, ARGI_LOCAL5, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_LOCAL_VARIABLE, 0), +/* 12 */ ACPI_OP("Local6", ARGP_LOCAL6, ARGI_LOCAL6, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_LOCAL_VARIABLE, 0), +/* 13 */ ACPI_OP("Local7", ARGP_LOCAL7, ARGI_LOCAL7, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_LOCAL_VARIABLE, 0), +/* 14 */ ACPI_OP("Arg0", ARGP_ARG0, ARGI_ARG0, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_METHOD_ARGUMENT, 0), +/* 15 */ ACPI_OP("Arg1", ARGP_ARG1, ARGI_ARG1, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_METHOD_ARGUMENT, 0), +/* 16 */ ACPI_OP("Arg2", ARGP_ARG2, ARGI_ARG2, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_METHOD_ARGUMENT, 0), +/* 17 */ ACPI_OP("Arg3", ARGP_ARG3, ARGI_ARG3, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_METHOD_ARGUMENT, 0), +/* 18 */ ACPI_OP("Arg4", ARGP_ARG4, ARGI_ARG4, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_METHOD_ARGUMENT, 0), +/* 19 */ ACPI_OP("Arg5", ARGP_ARG5, ARGI_ARG5, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_METHOD_ARGUMENT, 0), +/* 1A */ ACPI_OP("Arg6", ARGP_ARG6, ARGI_ARG6, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_METHOD_ARGUMENT, 0), +/* 1B */ ACPI_OP("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, + AML_FLAGS_EXEC_1A_1T_1R), +/* 1C */ ACPI_OP("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, + AML_FLAGS_EXEC_1A_0T_1R), +/* 1D */ ACPI_OP("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 1E */ ACPI_OP("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 1F */ ACPI_OP("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 20 */ ACPI_OP("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_0T_1R, + AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 21 */ ACPI_OP("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_0T_1R, + AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 22 */ ACPI_OP("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 23 */ ACPI_OP("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_2A_2T_1R, + AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT), +/* 24 */ ACPI_OP("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 25 */ ACPI_OP("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 26 */ ACPI_OP("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 27 */ ACPI_OP("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 28 */ ACPI_OP("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 29 */ ACPI_OP("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 2A */ ACPI_OP("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 2B */ ACPI_OP("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, + AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2C */ ACPI_OP("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, + ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, + AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2D */ ACPI_OP("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP, + ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, + AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2E */ ACPI_OP("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), +/* 2F */ ACPI_OP("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R), +/* 30 */ ACPI_OP("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_0T_1R, + AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), +/* 31 */ ACPI_OP("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R), +/* 32 */ ACPI_OP("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, + AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT), +/* 33 */ ACPI_OP("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP, + ARGI_CREATE_DWORD_FIELD_OP, + ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, + AML_TYPE_CREATE_FIELD, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | + AML_DEFER | AML_CREATE), +/* 34 */ ACPI_OP("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, + ARGI_CREATE_WORD_FIELD_OP, + ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, + AML_TYPE_CREATE_FIELD, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | + AML_DEFER | AML_CREATE), +/* 35 */ ACPI_OP("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, + ARGI_CREATE_BYTE_FIELD_OP, + ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, + AML_TYPE_CREATE_FIELD, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | + AML_DEFER | AML_CREATE), +/* 36 */ ACPI_OP("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, + ARGI_CREATE_BIT_FIELD_OP, + ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, + AML_TYPE_CREATE_FIELD, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | + AML_DEFER | AML_CREATE), +/* 37 */ ACPI_OP("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_0T_1R, + AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), +/* 38 */ ACPI_OP("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, + AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | + AML_CONSTANT), +/* 39 */ ACPI_OP("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, + AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | + AML_CONSTANT), +/* 3A */ ACPI_OP("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, + AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 3B */ ACPI_OP("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_2A_0T_1R, + AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3C */ ACPI_OP("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_2A_0T_1R, + AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3D */ ACPI_OP("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, + AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3E */ ACPI_OP("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, + AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 3F */ ACPI_OP("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, + AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 40 */ ACPI_OP("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, + AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 41 */ ACPI_OP("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, + AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 42 */ ACPI_OP("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, + ACPI_TYPE_ANY, AML_CLASS_CONTROL, + AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 43 */ ACPI_OP("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, + AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 44 */ ACPI_OP("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, + ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 45 */ ACPI_OP("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, + AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), /* Prefixed opcodes (Two-byte opcodes with a prefix op) */ -/* 46 */ ACPI_OP ("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 47 */ ACPI_OP ("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), -/* 48 */ ACPI_OP ("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), -/* 49 */ ACPI_OP ("CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE), -/* 4A */ ACPI_OP ("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, AML_FLAGS_EXEC_1A_1T_0R), -/* 4B */ ACPI_OP ("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), -/* 4C */ ACPI_OP ("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), -/* 4D */ ACPI_OP ("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), -/* 4E */ ACPI_OP ("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), -/* 4F */ ACPI_OP ("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), -/* 50 */ ACPI_OP ("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), -/* 51 */ ACPI_OP ("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), -/* 52 */ ACPI_OP ("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 53 */ ACPI_OP ("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 54 */ ACPI_OP ("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), -/* 55 */ ACPI_OP ("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), -/* 56 */ ACPI_OP ("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), -/* 57 */ ACPI_OP ("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R), -/* 58 */ ACPI_OP ("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), -/* 59 */ ACPI_OP ("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), -/* 5A */ ACPI_OP ("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 5B */ ACPI_OP ("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 5C */ ACPI_OP ("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 5D */ ACPI_OP ("ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 5E */ ACPI_OP ("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), -/* 5F */ ACPI_OP ("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), +/* 46 */ ACPI_OP("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, + AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_NSNODE | AML_NAMED), +/* 47 */ ACPI_OP("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, + AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, + AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 48 */ ACPI_OP("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 49 */ ACPI_OP("CreateField", ARGP_CREATE_FIELD_OP, + ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, + AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | + AML_DEFER | AML_FIELD | AML_CREATE), +/* 4A */ ACPI_OP("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, + AML_FLAGS_EXEC_1A_1T_0R), +/* 4B */ ACPI_OP("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, + AML_FLAGS_EXEC_1A_0T_0R), +/* 4C */ ACPI_OP("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, + AML_FLAGS_EXEC_1A_0T_0R), +/* 4D */ ACPI_OP("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), +/* 4E */ ACPI_OP("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4F */ ACPI_OP("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, + AML_FLAGS_EXEC_2A_0T_1R), +/* 50 */ ACPI_OP("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, + AML_FLAGS_EXEC_1A_0T_0R), +/* 51 */ ACPI_OP("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 52 */ ACPI_OP("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_1T_1R, + AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 53 */ ACPI_OP("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, + AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 54 */ ACPI_OP("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 55 */ ACPI_OP("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, + ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, + AML_TYPE_CONSTANT, 0), +/* 56 */ ACPI_OP("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_CONSTANT, 0), +/* 57 */ ACPI_OP("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, + AML_FLAGS_EXEC_3A_0T_0R), +/* 58 */ ACPI_OP("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, + ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, + AML_TYPE_NAMED_COMPLEX, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_NSNODE | AML_NAMED | AML_DEFER), +/* 59 */ ACPI_OP("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, + AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_FIELD), +/* 5A */ ACPI_OP("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, + ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, + AML_TYPE_NAMED_NO_OBJ, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_NSNODE | AML_NAMED), +/* 5B */ ACPI_OP("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, + ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, + AML_TYPE_NAMED_SIMPLE, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_NSNODE | AML_NAMED), +/* 5C */ ACPI_OP("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, + ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, + AML_TYPE_NAMED_SIMPLE, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_NSNODE | AML_NAMED), +/* 5D */ ACPI_OP("ThermalZone", ARGP_THERMAL_ZONE_OP, + ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, + AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_NSNODE | AML_NAMED), +/* 5E */ ACPI_OP("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, + ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, + AML_TYPE_NAMED_FIELD, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_FIELD), +/* 5F */ ACPI_OP("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, + ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, + AML_TYPE_NAMED_FIELD, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_FIELD), /* Internal opcodes that map to invalid AML opcodes */ -/* 60 */ ACPI_OP ("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), -/* 61 */ ACPI_OP ("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), -/* 62 */ ACPI_OP ("LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), -/* 63 */ ACPI_OP ("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE ), -/* 64 */ ACPI_OP ("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, AML_TYPE_METHOD_CALL, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE), -/* 65 */ ACPI_OP ("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, 0), -/* 66 */ ACPI_OP ("-ReservedField-", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), -/* 67 */ ACPI_OP ("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), -/* 68 */ ACPI_OP ("-AccessField-", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), -/* 69 */ ACPI_OP ("-StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), -/* 6A */ ACPI_OP ("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, AML_HAS_ARGS | AML_HAS_RETVAL), -/* 6B */ ACPI_OP ("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS), -/* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), -/* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), +/* 60 */ ACPI_OP("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, + ACPI_TYPE_ANY, AML_CLASS_INTERNAL, + AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 61 */ ACPI_OP("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, + ACPI_TYPE_ANY, AML_CLASS_INTERNAL, + AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 62 */ ACPI_OP("LGreaterEqual", ARGP_LGREATEREQUAL_OP, + ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, + AML_CLASS_INTERNAL, AML_TYPE_BOGUS, + AML_HAS_ARGS | AML_CONSTANT), +/* 63 */ ACPI_OP("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, + ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, + AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE), +/* 64 */ ACPI_OP("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, + ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, + AML_TYPE_METHOD_CALL, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE), +/* 65 */ ACPI_OP("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, + ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, + AML_TYPE_LITERAL, 0), +/* 66 */ ACPI_OP("-ReservedField-", ARGP_RESERVEDFIELD_OP, + ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, + AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 67 */ ACPI_OP("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, + ACPI_TYPE_ANY, AML_CLASS_INTERNAL, + AML_TYPE_BOGUS, + AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 68 */ ACPI_OP("-AccessField-", ARGP_ACCESSFIELD_OP, + ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, + AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 69 */ ACPI_OP("-StaticString", ARGP_STATICSTRING_OP, + ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, + AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 6A */ ACPI_OP("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, + AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, + AML_HAS_ARGS | AML_HAS_RETVAL), +/* 6B */ ACPI_OP("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, + AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS), +/* 6C */ ACPI_OP("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, + AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), +/* 6D */ ACPI_OP("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, + AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), /* ACPI 2.0 opcodes */ -/* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), -/* 6F */ ACPI_OP ("Package", /* Var */ ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER), -/* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), -/* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), -/* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), -/* 73 */ ACPI_OP ("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 74 */ ACPI_OP ("ToDecimalString", ARGP_TO_DEC_STR_OP, ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 75 */ ACPI_OP ("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 76 */ ACPI_OP ("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 77 */ ACPI_OP ("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), -/* 78 */ ACPI_OP ("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), -/* 79 */ ACPI_OP ("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT), -/* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), -/* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), -/* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE), +/* 6E */ ACPI_OP("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, + ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, + AML_TYPE_LITERAL, AML_CONSTANT), + /* 6F */ ACPI_OP("Package", /* Var */ ARGP_VAR_PACKAGE_OP, + ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, + AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, + AML_HAS_ARGS | AML_DEFER), +/* 70 */ ACPI_OP("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, + ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 71 */ ACPI_OP("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 72 */ ACPI_OP("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP, + ARGI_CREATE_QWORD_FIELD_OP, + ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, + AML_TYPE_CREATE_FIELD, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | + AML_DEFER | AML_CREATE), +/* 73 */ ACPI_OP("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_1T_1R, + AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 74 */ ACPI_OP("ToDecimalString", ARGP_TO_DEC_STR_OP, + ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, + AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 75 */ ACPI_OP("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_1T_1R, + AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 76 */ ACPI_OP("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_1T_1R, + AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 77 */ ACPI_OP("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_2A_1T_1R, + AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 78 */ ACPI_OP("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 79 */ ACPI_OP("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, + AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT), +/* 7A */ ACPI_OP("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, + ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 7B */ ACPI_OP("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, + ACPI_TYPE_ANY, AML_CLASS_EXECUTE, + AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), +/* 7C */ ACPI_OP("DataTableRegion", ARGP_DATA_REGION_OP, + ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, + AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_NSNODE | AML_NAMED), +/* 7D */ ACPI_OP("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, + ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, + AML_TYPE_NAMED_NO_OBJ, + AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | + AML_NSNODE), /* ACPI 3.0 opcodes */ -/* 7E */ ACPI_OP ("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, AML_FLAGS_EXEC_0A_0T_1R) +/* 7E */ ACPI_OP("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, + AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, + AML_FLAGS_EXEC_0A_0T_1R) /*! [End] no source code translation !*/ }; @@ -338,73 +646,70 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = * This table is directly indexed by the opcodes, and returns an * index into the table above */ -static const u8 acpi_gbl_short_op_index[256] = -{ +static const u8 acpi_gbl_short_op_index[256] = { /* 0 1 2 3 4 5 6 7 */ /* 8 9 A B C D E F */ -/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, -/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK, -/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK, -/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, -/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D, -/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, -/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, -/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, -/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, -/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, -/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, -/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, -/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, -/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30, -/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72, -/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74, -/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A, -/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, -/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, -/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, +/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, +/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK, +/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK, +/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, +/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, +/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, +/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, +/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, +/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, +/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30, +/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72, +/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74, +/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A, +/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, +/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, +/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, }; /* * This table is indexed by the second opcode of the extended opcode * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info) */ -static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = -{ +static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = { /* 0 1 2 3 4 5 6 7 */ /* 8 9 A B C D E F */ -/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, -/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, -/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, -/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK, -/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, -/* 0x88 */ 0x7C, +/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, +/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, +/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, +/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, +/* 0x88 */ 0x7C, }; - /******************************************************************************* * * FUNCTION: acpi_ps_get_opcode_info @@ -418,12 +723,9 @@ static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = * ******************************************************************************/ -const struct acpi_opcode_info * -acpi_ps_get_opcode_info ( - u16 opcode) +const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode) { - ACPI_FUNCTION_NAME ("ps_get_opcode_info"); - + ACPI_FUNCTION_NAME("ps_get_opcode_info"); /* * Detect normal 8-bit opcode or extended 16-bit opcode @@ -431,25 +733,26 @@ acpi_ps_get_opcode_info ( if (!(opcode & 0xFF00)) { /* Simple (8-bit) opcode: 0-255, can't index beyond table */ - return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]); + return (&acpi_gbl_aml_op_info + [acpi_gbl_short_op_index[(u8) opcode]]); } if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) && - (((u8) opcode) <= MAX_EXTENDED_OPCODE)) { + (((u8) opcode) <= MAX_EXTENDED_OPCODE)) { /* Valid extended (16-bit) opcode */ - return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]); + return (&acpi_gbl_aml_op_info + [acpi_gbl_long_op_index[(u8) opcode]]); } /* Unknown AML opcode */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown AML opcode [%4.4X]\n", opcode)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown AML opcode [%4.4X]\n", opcode)); - return (&acpi_gbl_aml_op_info [_UNK]); + return (&acpi_gbl_aml_op_info[_UNK]); } - /******************************************************************************* * * FUNCTION: acpi_ps_get_opcode_name @@ -463,16 +766,13 @@ acpi_ps_get_opcode_info ( * ******************************************************************************/ -char * -acpi_ps_get_opcode_name ( - u16 opcode) +char *acpi_ps_get_opcode_name(u16 opcode) { #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) - const struct acpi_opcode_info *op; - + const struct acpi_opcode_info *op; - op = acpi_ps_get_opcode_info (opcode); + op = acpi_ps_get_opcode_info(opcode); /* Always guaranteed to return a valid pointer */ @@ -483,4 +783,3 @@ acpi_ps_get_opcode_name ( #endif } - diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index 16b84a3..3248051 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* * Parse the AML and build an operation tree as most interpreters, * like Perl, do. Parsing is done by hand rather than with a YACC @@ -59,8 +58,7 @@ #include #define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("psparse") - +ACPI_MODULE_NAME("psparse") /******************************************************************************* * @@ -73,10 +71,7 @@ * DESCRIPTION: Get the size of the current opcode. * ******************************************************************************/ - -u32 -acpi_ps_get_opcode_size ( - u32 opcode) +u32 acpi_ps_get_opcode_size(u32 opcode) { /* Extended (2-byte) opcode if > 255 */ @@ -90,7 +85,6 @@ acpi_ps_get_opcode_size ( return (1); } - /******************************************************************************* * * FUNCTION: acpi_ps_peek_opcode @@ -103,28 +97,24 @@ acpi_ps_get_opcode_size ( * ******************************************************************************/ -u16 -acpi_ps_peek_opcode ( - struct acpi_parse_state *parser_state) +u16 acpi_ps_peek_opcode(struct acpi_parse_state * parser_state) { - u8 *aml; - u16 opcode; - + u8 *aml; + u16 opcode; aml = parser_state->aml; - opcode = (u16) ACPI_GET8 (aml); + opcode = (u16) ACPI_GET8(aml); if (opcode == AML_EXTENDED_OP_PREFIX) { /* Extended opcode, get the second opcode byte */ aml++; - opcode = (u16) ((opcode << 8) | ACPI_GET8 (aml)); + opcode = (u16) ((opcode << 8) | ACPI_GET8(aml)); } return (opcode); } - /******************************************************************************* * * FUNCTION: acpi_ps_complete_this_op @@ -139,30 +129,28 @@ acpi_ps_peek_opcode ( ******************************************************************************/ acpi_status -acpi_ps_complete_this_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op) +acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, + union acpi_parse_object * op) { - union acpi_parse_object *prev; - union acpi_parse_object *next; - const struct acpi_opcode_info *parent_info; - union acpi_parse_object *replacement_op = NULL; - - - ACPI_FUNCTION_TRACE_PTR ("ps_complete_this_op", op); + union acpi_parse_object *prev; + union acpi_parse_object *next; + const struct acpi_opcode_info *parent_info; + union acpi_parse_object *replacement_op = NULL; + ACPI_FUNCTION_TRACE_PTR("ps_complete_this_op", op); /* Check for null Op, can happen if AML code is corrupt */ if (!op) { - return_ACPI_STATUS (AE_OK); /* OK for now */ + return_ACPI_STATUS(AE_OK); /* OK for now */ } /* Delete this op and the subtree below it if asked to */ - if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || - (walk_state->op_info->class == AML_CLASS_ARGUMENT)) { - return_ACPI_STATUS (AE_OK); + if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) != + ACPI_PARSE_DELETE_TREE) + || (walk_state->op_info->class == AML_CLASS_ARGUMENT)) { + return_ACPI_STATUS(AE_OK); } /* Make sure that we only delete this subtree */ @@ -179,7 +167,9 @@ acpi_ps_complete_this_op ( * Check if we need to replace the operator and its subtree * with a return value op (placeholder op) */ - parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode); + parent_info = + acpi_ps_get_opcode_info(op->common.parent->common. + aml_opcode); switch (parent_info->class) { case AML_CLASS_CONTROL: @@ -191,7 +181,8 @@ acpi_ps_complete_this_op ( * These opcodes contain term_arg operands. The current * op must be replaced by a placeholder return op */ - replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); + replacement_op = + acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); if (!replacement_op) { goto allocate_error; } @@ -203,35 +194,49 @@ acpi_ps_complete_this_op ( * These opcodes contain term_arg operands. The current * op must be replaced by a placeholder return op */ - if ((op->common.parent->common.aml_opcode == AML_REGION_OP) || - (op->common.parent->common.aml_opcode == AML_DATA_REGION_OP) || - (op->common.parent->common.aml_opcode == AML_BUFFER_OP) || - (op->common.parent->common.aml_opcode == AML_PACKAGE_OP) || - (op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) { - replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); + if ((op->common.parent->common.aml_opcode == + AML_REGION_OP) + || (op->common.parent->common.aml_opcode == + AML_DATA_REGION_OP) + || (op->common.parent->common.aml_opcode == + AML_BUFFER_OP) + || (op->common.parent->common.aml_opcode == + AML_PACKAGE_OP) + || (op->common.parent->common.aml_opcode == + AML_VAR_PACKAGE_OP)) { + replacement_op = + acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); if (!replacement_op) { goto allocate_error; } - } - else if ((op->common.parent->common.aml_opcode == AML_NAME_OP) && - (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) { - if ((op->common.aml_opcode == AML_BUFFER_OP) || - (op->common.aml_opcode == AML_PACKAGE_OP) || - (op->common.aml_opcode == AML_VAR_PACKAGE_OP)) { - replacement_op = acpi_ps_alloc_op (op->common.aml_opcode); + } else + if ((op->common.parent->common.aml_opcode == + AML_NAME_OP) + && (walk_state->pass_number <= + ACPI_IMODE_LOAD_PASS2)) { + if ((op->common.aml_opcode == AML_BUFFER_OP) + || (op->common.aml_opcode == AML_PACKAGE_OP) + || (op->common.aml_opcode == + AML_VAR_PACKAGE_OP)) { + replacement_op = + acpi_ps_alloc_op(op->common. + aml_opcode); if (!replacement_op) { goto allocate_error; } - replacement_op->named.data = op->named.data; - replacement_op->named.length = op->named.length; + replacement_op->named.data = + op->named.data; + replacement_op->named.length = + op->named.length; } } break; default: - replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); + replacement_op = + acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); if (!replacement_op) { goto allocate_error; } @@ -243,59 +248,64 @@ acpi_ps_complete_this_op ( /* This op is the first in the list */ if (replacement_op) { - replacement_op->common.parent = op->common.parent; - replacement_op->common.value.arg = NULL; - replacement_op->common.node = op->common.node; - op->common.parent->common.value.arg = replacement_op; - replacement_op->common.next = op->common.next; - } - else { - op->common.parent->common.value.arg = op->common.next; + replacement_op->common.parent = + op->common.parent; + replacement_op->common.value.arg = NULL; + replacement_op->common.node = op->common.node; + op->common.parent->common.value.arg = + replacement_op; + replacement_op->common.next = op->common.next; + } else { + op->common.parent->common.value.arg = + op->common.next; } } /* Search the parent list */ - else while (prev) { - /* Traverse all siblings in the parent's argument list */ - - next = prev->common.next; - if (next == op) { - if (replacement_op) { - replacement_op->common.parent = op->common.parent; - replacement_op->common.value.arg = NULL; - replacement_op->common.node = op->common.node; - prev->common.next = replacement_op; - replacement_op->common.next = op->common.next; - next = NULL; - } - else { - prev->common.next = op->common.next; - next = NULL; + else + while (prev) { + /* Traverse all siblings in the parent's argument list */ + + next = prev->common.next; + if (next == op) { + if (replacement_op) { + replacement_op->common.parent = + op->common.parent; + replacement_op->common.value. + arg = NULL; + replacement_op->common.node = + op->common.node; + prev->common.next = + replacement_op; + replacement_op->common.next = + op->common.next; + next = NULL; + } else { + prev->common.next = + op->common.next; + next = NULL; + } } + prev = next; } - prev = next; - } } - -cleanup: + cleanup: /* Now we can actually delete the subtree rooted at Op */ - acpi_ps_delete_parse_tree (op); - return_ACPI_STATUS (AE_OK); + acpi_ps_delete_parse_tree(op); + return_ACPI_STATUS(AE_OK); - -allocate_error: + allocate_error: /* Always delete the subtree, even on error */ - acpi_ps_delete_parse_tree (op); - return_ACPI_STATUS (AE_NO_MEMORY); + acpi_ps_delete_parse_tree(op); + return_ACPI_STATUS(AE_NO_MEMORY); } - /******************************************************************************* * * FUNCTION: acpi_ps_next_parse_state @@ -312,17 +322,14 @@ allocate_error: ******************************************************************************/ acpi_status -acpi_ps_next_parse_state ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - acpi_status callback_status) +acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + acpi_status callback_status) { - struct acpi_parse_state *parser_state = &walk_state->parser_state; - acpi_status status = AE_CTRL_PENDING; - - - ACPI_FUNCTION_TRACE_PTR ("ps_next_parse_state", op); + struct acpi_parse_state *parser_state = &walk_state->parser_state; + acpi_status status = AE_CTRL_PENDING; + ACPI_FUNCTION_TRACE_PTR("ps_next_parse_state", op); switch (callback_status) { case AE_CTRL_TERMINATE: @@ -335,7 +342,6 @@ acpi_ps_next_parse_state ( status = AE_CTRL_TERMINATE; break; - case AE_CTRL_BREAK: parser_state->aml = walk_state->aml_last_while; @@ -345,7 +351,6 @@ acpi_ps_next_parse_state ( case AE_CTRL_CONTINUE: - parser_state->aml = walk_state->aml_last_while; status = AE_CTRL_CONTINUE; break; @@ -369,10 +374,9 @@ acpi_ps_next_parse_state ( * Predicate of an IF was true, and we are at the matching ELSE. * Just close out this package */ - parser_state->aml = acpi_ps_get_next_package_end (parser_state); + parser_state->aml = acpi_ps_get_next_package_end(parser_state); break; - case AE_CTRL_FALSE: /* @@ -390,7 +394,6 @@ acpi_ps_next_parse_state ( status = AE_CTRL_END; break; - case AE_CTRL_TRANSFER: /* A method call (invocation) -- transfer control */ @@ -398,14 +401,15 @@ acpi_ps_next_parse_state ( status = AE_CTRL_TRANSFER; walk_state->prev_op = op; walk_state->method_call_op = op; - walk_state->method_call_node = (op->common.value.arg)->common.node; + walk_state->method_call_node = + (op->common.value.arg)->common.node; /* Will return value (if any) be used by the caller? */ - walk_state->return_used = acpi_ds_is_result_used (op, walk_state); + walk_state->return_used = + acpi_ds_is_result_used(op, walk_state); break; - default: status = callback_status; @@ -415,10 +419,9 @@ acpi_ps_next_parse_state ( break; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ps_parse_aml @@ -432,34 +435,30 @@ acpi_ps_next_parse_state ( * ******************************************************************************/ -acpi_status -acpi_ps_parse_aml ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) { - acpi_status status; - acpi_status terminate_status; - struct acpi_thread_state *thread; - struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list; - struct acpi_walk_state *previous_walk_state; - - - ACPI_FUNCTION_TRACE ("ps_parse_aml"); + acpi_status status; + acpi_status terminate_status; + struct acpi_thread_state *thread; + struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list; + struct acpi_walk_state *previous_walk_state; - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Entered with walk_state=%p Aml=%p size=%X\n", - walk_state, walk_state->parser_state.aml, - walk_state->parser_state.aml_size)); + ACPI_FUNCTION_TRACE("ps_parse_aml"); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "Entered with walk_state=%p Aml=%p size=%X\n", + walk_state, walk_state->parser_state.aml, + walk_state->parser_state.aml_size)); /* Create and initialize a new thread state */ - thread = acpi_ut_create_thread_state (); + thread = acpi_ut_create_thread_state(); if (!thread) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } walk_state->thread = thread; - acpi_ds_push_walk_state (walk_state, thread); + acpi_ds_push_walk_state(walk_state, thread); /* * This global allows the AML debugger to get a handle to the currently @@ -471,54 +470,56 @@ acpi_ps_parse_aml ( * Execute the walk loop as long as there is a valid Walk State. This * handles nested control method invocations without recursion. */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "State=%p\n", walk_state)); status = AE_OK; while (walk_state) { - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { /* * The parse_loop executes AML until the method terminates * or calls another method. */ - status = acpi_ps_parse_loop (walk_state); + status = acpi_ps_parse_loop(walk_state); } - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Completed one call to walk loop, %s State=%p\n", - acpi_format_exception (status), walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "Completed one call to walk loop, %s State=%p\n", + acpi_format_exception(status), walk_state)); if (status == AE_CTRL_TRANSFER) { /* * A method call was detected. * Transfer control to the called control method */ - status = acpi_ds_call_control_method (thread, walk_state, NULL); + status = + acpi_ds_call_control_method(thread, walk_state, + NULL); /* * If the transfer to the new method method call worked, a new walk * state was created -- get it */ - walk_state = acpi_ds_get_current_walk_state (thread); + walk_state = acpi_ds_get_current_walk_state(thread); continue; - } - else if (status == AE_CTRL_TERMINATE) { + } else if (status == AE_CTRL_TERMINATE) { status = AE_OK; - } - else if ((status != AE_OK) && (walk_state->method_desc)) { - ACPI_REPORT_METHOD_ERROR ("Method execution failed", - walk_state->method_node, NULL, status); + } else if ((status != AE_OK) && (walk_state->method_desc)) { + ACPI_REPORT_METHOD_ERROR("Method execution failed", + walk_state->method_node, NULL, + status); /* Check for possible multi-thread reentrancy problem */ if ((status == AE_ALREADY_EXISTS) && - (!walk_state->method_desc->method.semaphore)) { + (!walk_state->method_desc->method.semaphore)) { /* * This method is marked not_serialized, but it tried to create * a named object, causing the second thread entrance to fail. * We will workaround this by marking the method permanently * as Serialized. */ - walk_state->method_desc->method.method_flags |= AML_METHOD_SERIALIZED; + walk_state->method_desc->method.method_flags |= + AML_METHOD_SERIALIZED; walk_state->method_desc->method.concurrency = 1; } } @@ -533,21 +534,22 @@ acpi_ps_parse_aml ( /* We are done with this walk, move on to the parent if any */ - walk_state = acpi_ds_pop_walk_state (thread); + walk_state = acpi_ds_pop_walk_state(thread); /* Reset the current scope to the beginning of scope stack */ - acpi_ds_scope_stack_clear (walk_state); + acpi_ds_scope_stack_clear(walk_state); /* * If we just returned from the execution of a control method, * there's lots of cleanup to do */ - if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) { - terminate_status = acpi_ds_terminate_control_method (walk_state); - if (ACPI_FAILURE (terminate_status)) { - ACPI_REPORT_ERROR (( - "Could not terminate control method properly\n")); + if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == + ACPI_PARSE_EXECUTE) { + terminate_status = + acpi_ds_terminate_control_method(walk_state); + if (ACPI_FAILURE(terminate_status)) { + ACPI_REPORT_ERROR(("Could not terminate control method properly\n")); /* Ignore error and continue */ } @@ -555,46 +557,53 @@ acpi_ps_parse_aml ( /* Delete this walk state and all linked control states */ - acpi_ps_cleanup_scope (&walk_state->parser_state); + acpi_ps_cleanup_scope(&walk_state->parser_state); previous_walk_state = walk_state; - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "return_value=%p, implicit_value=%p State=%p\n", - walk_state->return_desc, walk_state->implicit_return_obj, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "return_value=%p, implicit_value=%p State=%p\n", + walk_state->return_desc, + walk_state->implicit_return_obj, walk_state)); /* Check if we have restarted a preempted walk */ - walk_state = acpi_ds_get_current_walk_state (thread); + walk_state = acpi_ds_get_current_walk_state(thread); if (walk_state) { - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { /* * There is another walk state, restart it. * If the method return value is not used by the parent, * The object is deleted */ if (!previous_walk_state->return_desc) { - status = acpi_ds_restart_control_method (walk_state, - previous_walk_state->implicit_return_obj); - } - else { + status = + acpi_ds_restart_control_method + (walk_state, + previous_walk_state-> + implicit_return_obj); + } else { /* * We have a valid return value, delete any implicit * return value. */ - acpi_ds_clear_implicit_return (previous_walk_state); + acpi_ds_clear_implicit_return + (previous_walk_state); - status = acpi_ds_restart_control_method (walk_state, - previous_walk_state->return_desc); + status = + acpi_ds_restart_control_method + (walk_state, + previous_walk_state->return_desc); } - if (ACPI_SUCCESS (status)) { - walk_state->walk_type |= ACPI_WALK_METHOD_RESTART; + if (ACPI_SUCCESS(status)) { + walk_state->walk_type |= + ACPI_WALK_METHOD_RESTART; } - } - else { + } else { /* On error, delete any return object */ - acpi_ut_remove_reference (previous_walk_state->return_desc); + acpi_ut_remove_reference(previous_walk_state-> + return_desc); } } @@ -605,37 +614,36 @@ acpi_ps_parse_aml ( else if (previous_walk_state->caller_return_desc) { if (previous_walk_state->implicit_return_obj) { *(previous_walk_state->caller_return_desc) = - previous_walk_state->implicit_return_obj; - } - else { - /* NULL if no return value */ + previous_walk_state->implicit_return_obj; + } else { + /* NULL if no return value */ *(previous_walk_state->caller_return_desc) = - previous_walk_state->return_desc; + previous_walk_state->return_desc; } - } - else { + } else { if (previous_walk_state->return_desc) { /* Caller doesn't want it, must delete it */ - acpi_ut_remove_reference (previous_walk_state->return_desc); + acpi_ut_remove_reference(previous_walk_state-> + return_desc); } if (previous_walk_state->implicit_return_obj) { /* Caller doesn't want it, must delete it */ - acpi_ut_remove_reference (previous_walk_state->implicit_return_obj); + acpi_ut_remove_reference(previous_walk_state-> + implicit_return_obj); } } - acpi_ds_delete_walk_state (previous_walk_state); + acpi_ds_delete_walk_state(previous_walk_state); } /* Normal exit */ - acpi_ex_release_all_mutexes (thread); - acpi_ut_delete_generic_state (ACPI_CAST_PTR (union acpi_generic_state, thread)); + acpi_ex_release_all_mutexes(thread); + acpi_ut_delete_generic_state(ACPI_CAST_PTR + (union acpi_generic_state, thread)); acpi_gbl_current_walk_list = prev_walk_list; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/parser/psscope.c index 8dcd1b1..1c953b6 100644 --- a/drivers/acpi/parser/psscope.c +++ b/drivers/acpi/parser/psscope.c @@ -41,13 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("psscope") - +ACPI_MODULE_NAME("psscope") /******************************************************************************* * @@ -60,16 +58,13 @@ * DESCRIPTION: Get parent of current op being parsed * ******************************************************************************/ - -union acpi_parse_object * -acpi_ps_get_parent_scope ( - struct acpi_parse_state *parser_state) +union acpi_parse_object *acpi_ps_get_parent_scope(struct acpi_parse_state + *parser_state) { return (parser_state->scope->parse_scope.op); } - /******************************************************************************* * * FUNCTION: acpi_ps_has_completed_scope @@ -84,17 +79,14 @@ acpi_ps_get_parent_scope ( * ******************************************************************************/ -u8 -acpi_ps_has_completed_scope ( - struct acpi_parse_state *parser_state) +u8 acpi_ps_has_completed_scope(struct acpi_parse_state * parser_state) { return ((u8) - ((parser_state->aml >= parser_state->scope->parse_scope.arg_end || - !parser_state->scope->parse_scope.arg_count))); + ((parser_state->aml >= parser_state->scope->parse_scope.arg_end + || !parser_state->scope->parse_scope.arg_count))); } - /******************************************************************************* * * FUNCTION: acpi_ps_init_scope @@ -109,34 +101,30 @@ acpi_ps_has_completed_scope ( ******************************************************************************/ acpi_status -acpi_ps_init_scope ( - struct acpi_parse_state *parser_state, - union acpi_parse_object *root_op) +acpi_ps_init_scope(struct acpi_parse_state * parser_state, + union acpi_parse_object * root_op) { - union acpi_generic_state *scope; + union acpi_generic_state *scope; + ACPI_FUNCTION_TRACE_PTR("ps_init_scope", root_op); - ACPI_FUNCTION_TRACE_PTR ("ps_init_scope", root_op); - - - scope = acpi_ut_create_generic_state (); + scope = acpi_ut_create_generic_state(); if (!scope) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } - scope->common.data_type = ACPI_DESC_TYPE_STATE_RPSCOPE; - scope->parse_scope.op = root_op; + scope->common.data_type = ACPI_DESC_TYPE_STATE_RPSCOPE; + scope->parse_scope.op = root_op; scope->parse_scope.arg_count = ACPI_VAR_ARGS; - scope->parse_scope.arg_end = parser_state->aml_end; - scope->parse_scope.pkg_end = parser_state->aml_end; + scope->parse_scope.arg_end = parser_state->aml_end; + scope->parse_scope.pkg_end = parser_state->aml_end; - parser_state->scope = scope; - parser_state->start_op = root_op; + parser_state->scope = scope; + parser_state->start_op = root_op; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ps_push_scope @@ -153,48 +141,42 @@ acpi_ps_init_scope ( ******************************************************************************/ acpi_status -acpi_ps_push_scope ( - struct acpi_parse_state *parser_state, - union acpi_parse_object *op, - u32 remaining_args, - u32 arg_count) +acpi_ps_push_scope(struct acpi_parse_state *parser_state, + union acpi_parse_object *op, + u32 remaining_args, u32 arg_count) { - union acpi_generic_state *scope; - - - ACPI_FUNCTION_TRACE_PTR ("ps_push_scope", op); + union acpi_generic_state *scope; + ACPI_FUNCTION_TRACE_PTR("ps_push_scope", op); - scope = acpi_ut_create_generic_state (); + scope = acpi_ut_create_generic_state(); if (!scope) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } - scope->common.data_type = ACPI_DESC_TYPE_STATE_PSCOPE; - scope->parse_scope.op = op; + scope->common.data_type = ACPI_DESC_TYPE_STATE_PSCOPE; + scope->parse_scope.op = op; scope->parse_scope.arg_list = remaining_args; scope->parse_scope.arg_count = arg_count; scope->parse_scope.pkg_end = parser_state->pkg_end; /* Push onto scope stack */ - acpi_ut_push_generic_state (&parser_state->scope, scope); + acpi_ut_push_generic_state(&parser_state->scope, scope); if (arg_count == ACPI_VAR_ARGS) { /* Multiple arguments */ scope->parse_scope.arg_end = parser_state->pkg_end; - } - else { + } else { /* Single argument */ - scope->parse_scope.arg_end = ACPI_TO_POINTER (ACPI_MAX_PTR); + scope->parse_scope.arg_end = ACPI_TO_POINTER(ACPI_MAX_PTR); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ps_pop_scope @@ -212,48 +194,41 @@ acpi_ps_push_scope ( ******************************************************************************/ void -acpi_ps_pop_scope ( - struct acpi_parse_state *parser_state, - union acpi_parse_object **op, - u32 *arg_list, - u32 *arg_count) +acpi_ps_pop_scope(struct acpi_parse_state *parser_state, + union acpi_parse_object **op, u32 * arg_list, u32 * arg_count) { - union acpi_generic_state *scope = parser_state->scope; - - - ACPI_FUNCTION_TRACE ("ps_pop_scope"); + union acpi_generic_state *scope = parser_state->scope; + ACPI_FUNCTION_TRACE("ps_pop_scope"); /* Only pop the scope if there is in fact a next scope */ if (scope->common.next) { - scope = acpi_ut_pop_generic_state (&parser_state->scope); + scope = acpi_ut_pop_generic_state(&parser_state->scope); /* return to parsing previous op */ - *op = scope->parse_scope.op; - *arg_list = scope->parse_scope.arg_list; - *arg_count = scope->parse_scope.arg_count; + *op = scope->parse_scope.op; + *arg_list = scope->parse_scope.arg_list; + *arg_count = scope->parse_scope.arg_count; parser_state->pkg_end = scope->parse_scope.pkg_end; /* All done with this scope state structure */ - acpi_ut_delete_generic_state (scope); - } - else { + acpi_ut_delete_generic_state(scope); + } else { /* empty parse stack, prepare to fetch next opcode */ - *op = NULL; + *op = NULL; *arg_list = 0; *arg_count = 0; } - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Popped Op %p Args %X\n", *op, *arg_count)); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "Popped Op %p Args %X\n", *op, *arg_count)); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ps_cleanup_scope @@ -267,15 +242,11 @@ acpi_ps_pop_scope ( * ******************************************************************************/ -void -acpi_ps_cleanup_scope ( - struct acpi_parse_state *parser_state) +void acpi_ps_cleanup_scope(struct acpi_parse_state *parser_state) { - union acpi_generic_state *scope; - - - ACPI_FUNCTION_TRACE_PTR ("ps_cleanup_scope", parser_state); + union acpi_generic_state *scope; + ACPI_FUNCTION_TRACE_PTR("ps_cleanup_scope", parser_state); if (!parser_state) { return_VOID; @@ -284,10 +255,9 @@ acpi_ps_cleanup_scope ( /* Delete anything on the scope stack */ while (parser_state->scope) { - scope = acpi_ut_pop_generic_state (&parser_state->scope); - acpi_ut_delete_generic_state (scope); + scope = acpi_ut_pop_generic_state(&parser_state->scope); + acpi_ut_delete_generic_state(scope); } return_VOID; } - diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/parser/pstree.c index d5aafe7..f0e7558 100644 --- a/drivers/acpi/parser/pstree.c +++ b/drivers/acpi/parser/pstree.c @@ -41,23 +41,18 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("pstree") +ACPI_MODULE_NAME("pstree") /* Local prototypes */ - #ifdef ACPI_OBSOLETE_FUNCTIONS -union acpi_parse_object * -acpi_ps_get_child ( - union acpi_parse_object *op); +union acpi_parse_object *acpi_ps_get_child(union acpi_parse_object *op); #endif - /******************************************************************************* * * FUNCTION: acpi_ps_get_arg @@ -71,21 +66,16 @@ acpi_ps_get_child ( * ******************************************************************************/ -union acpi_parse_object * -acpi_ps_get_arg ( - union acpi_parse_object *op, - u32 argn) +union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn) { - union acpi_parse_object *arg = NULL; - const struct acpi_opcode_info *op_info; - - - ACPI_FUNCTION_ENTRY (); + union acpi_parse_object *arg = NULL; + const struct acpi_opcode_info *op_info; + ACPI_FUNCTION_ENTRY(); /* Get the info structure for this opcode */ - op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); + op_info = acpi_ps_get_opcode_info(op->common.aml_opcode); if (op_info->class == AML_CLASS_UNKNOWN) { /* Invalid opcode or ASCII character */ @@ -111,7 +101,6 @@ acpi_ps_get_arg ( return (arg); } - /******************************************************************************* * * FUNCTION: acpi_ps_append_arg @@ -126,16 +115,12 @@ acpi_ps_get_arg ( ******************************************************************************/ void -acpi_ps_append_arg ( - union acpi_parse_object *op, - union acpi_parse_object *arg) +acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg) { - union acpi_parse_object *prev_arg; - const struct acpi_opcode_info *op_info; - - - ACPI_FUNCTION_ENTRY (); + union acpi_parse_object *prev_arg; + const struct acpi_opcode_info *op_info; + ACPI_FUNCTION_ENTRY(); if (!op) { return; @@ -143,12 +128,11 @@ acpi_ps_append_arg ( /* Get the info structure for this opcode */ - op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); + op_info = acpi_ps_get_opcode_info(op->common.aml_opcode); if (op_info->class == AML_CLASS_UNKNOWN) { /* Invalid opcode */ - ACPI_REPORT_ERROR (("ps_append_arg: Invalid AML Opcode: 0x%2.2X\n", - op->common.aml_opcode)); + ACPI_REPORT_ERROR(("ps_append_arg: Invalid AML Opcode: 0x%2.2X\n", op->common.aml_opcode)); return; } @@ -170,8 +154,7 @@ acpi_ps_append_arg ( prev_arg = prev_arg->common.next; } prev_arg->common.next = arg; - } - else { + } else { /* No argument list, this will be the first argument */ op->common.value.arg = arg; @@ -185,7 +168,6 @@ acpi_ps_append_arg ( } } - #ifdef ACPI_FUTURE_USAGE /******************************************************************************* * @@ -201,18 +183,14 @@ acpi_ps_append_arg ( * ******************************************************************************/ -union acpi_parse_object * -acpi_ps_get_depth_next ( - union acpi_parse_object *origin, - union acpi_parse_object *op) +union acpi_parse_object *acpi_ps_get_depth_next(union acpi_parse_object *origin, + union acpi_parse_object *op) { - union acpi_parse_object *next = NULL; - union acpi_parse_object *parent; - union acpi_parse_object *arg; - - - ACPI_FUNCTION_ENTRY (); + union acpi_parse_object *next = NULL; + union acpi_parse_object *parent; + union acpi_parse_object *arg; + ACPI_FUNCTION_ENTRY(); if (!op) { return (NULL); @@ -220,7 +198,7 @@ acpi_ps_get_depth_next ( /* Look for an argument or child */ - next = acpi_ps_get_arg (op, 0); + next = acpi_ps_get_arg(op, 0); if (next) { return (next); } @@ -237,7 +215,7 @@ acpi_ps_get_depth_next ( parent = op->common.parent; while (parent) { - arg = acpi_ps_get_arg (parent, 0); + arg = acpi_ps_get_arg(parent, 0); while (arg && (arg != origin) && (arg != op)) { arg = arg->common.next; } @@ -261,7 +239,6 @@ acpi_ps_get_depth_next ( return (next); } - #ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * @@ -275,15 +252,11 @@ acpi_ps_get_depth_next ( * ******************************************************************************/ -union acpi_parse_object * -acpi_ps_get_child ( - union acpi_parse_object *op) +union acpi_parse_object *acpi_ps_get_child(union acpi_parse_object *op) { - union acpi_parse_object *child = NULL; - - - ACPI_FUNCTION_ENTRY (); + union acpi_parse_object *child = NULL; + ACPI_FUNCTION_ENTRY(); switch (op->common.aml_opcode) { case AML_SCOPE_OP: @@ -292,10 +265,9 @@ acpi_ps_get_child ( case AML_THERMAL_ZONE_OP: case AML_INT_METHODCALL_OP: - child = acpi_ps_get_arg (op, 0); + child = acpi_ps_get_arg(op, 0); break; - case AML_BUFFER_OP: case AML_PACKAGE_OP: case AML_METHOD_OP: @@ -303,24 +275,21 @@ acpi_ps_get_child ( case AML_WHILE_OP: case AML_FIELD_OP: - child = acpi_ps_get_arg (op, 1); + child = acpi_ps_get_arg(op, 1); break; - case AML_POWER_RES_OP: case AML_INDEX_FIELD_OP: - child = acpi_ps_get_arg (op, 2); + child = acpi_ps_get_arg(op, 2); break; - case AML_PROCESSOR_OP: case AML_BANK_FIELD_OP: - child = acpi_ps_get_arg (op, 3); + child = acpi_ps_get_arg(op, 3); break; - default: /* All others have no children */ break; @@ -330,5 +299,4 @@ acpi_ps_get_child ( } #endif -#endif /* ACPI_FUTURE_USAGE */ - +#endif /* ACPI_FUTURE_USAGE */ diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c index 4221b41..2075efb 100644 --- a/drivers/acpi/parser/psutils.c +++ b/drivers/acpi/parser/psutils.c @@ -41,14 +41,12 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("psutils") - +ACPI_MODULE_NAME("psutils") /******************************************************************************* * @@ -61,15 +59,11 @@ * DESCRIPTION: Create a Scope and associated namepath op with the root name * ******************************************************************************/ - -union acpi_parse_object * -acpi_ps_create_scope_op ( - void) +union acpi_parse_object *acpi_ps_create_scope_op(void) { - union acpi_parse_object *scope_op; + union acpi_parse_object *scope_op; - - scope_op = acpi_ps_alloc_op (AML_SCOPE_OP); + scope_op = acpi_ps_alloc_op(AML_SCOPE_OP); if (!scope_op) { return (NULL); } @@ -78,7 +72,6 @@ acpi_ps_create_scope_op ( return (scope_op); } - /******************************************************************************* * * FUNCTION: acpi_ps_init_op @@ -92,23 +85,19 @@ acpi_ps_create_scope_op ( * ******************************************************************************/ -void -acpi_ps_init_op ( - union acpi_parse_object *op, - u16 opcode) +void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode) { - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_ENTRY(); op->common.data_type = ACPI_DESC_TYPE_PARSER; op->common.aml_opcode = opcode; - ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (op->common.aml_op_name, - (acpi_ps_get_opcode_info (opcode))->name, - sizeof (op->common.aml_op_name))); + ACPI_DISASM_ONLY_MEMBERS(ACPI_STRNCPY(op->common.aml_op_name, + (acpi_ps_get_opcode_info + (opcode))->name, + sizeof(op->common.aml_op_name))); } - /******************************************************************************* * * FUNCTION: acpi_ps_alloc_op @@ -123,29 +112,23 @@ acpi_ps_init_op ( * ******************************************************************************/ -union acpi_parse_object* -acpi_ps_alloc_op ( - u16 opcode) +union acpi_parse_object *acpi_ps_alloc_op(u16 opcode) { - union acpi_parse_object *op; - const struct acpi_opcode_info *op_info; - u8 flags = ACPI_PARSEOP_GENERIC; - - - ACPI_FUNCTION_ENTRY (); + union acpi_parse_object *op; + const struct acpi_opcode_info *op_info; + u8 flags = ACPI_PARSEOP_GENERIC; + ACPI_FUNCTION_ENTRY(); - op_info = acpi_ps_get_opcode_info (opcode); + op_info = acpi_ps_get_opcode_info(opcode); /* Determine type of parse_op required */ if (op_info->flags & AML_DEFER) { flags = ACPI_PARSEOP_DEFERRED; - } - else if (op_info->flags & AML_NAMED) { + } else if (op_info->flags & AML_NAMED) { flags = ACPI_PARSEOP_NAMED; - } - else if (opcode == AML_INT_BYTELIST_OP) { + } else if (opcode == AML_INT_BYTELIST_OP) { flags = ACPI_PARSEOP_BYTELIST; } @@ -154,27 +137,25 @@ acpi_ps_alloc_op ( if (flags == ACPI_PARSEOP_GENERIC) { /* The generic op (default) is by far the most common (16 to 1) */ - op = acpi_os_acquire_object (acpi_gbl_ps_node_cache); + op = acpi_os_acquire_object(acpi_gbl_ps_node_cache); memset(op, 0, sizeof(struct acpi_parse_obj_common)); - } - else { + } else { /* Extended parseop */ - op = acpi_os_acquire_object (acpi_gbl_ps_node_ext_cache); + op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache); memset(op, 0, sizeof(struct acpi_parse_obj_named)); } /* Initialize the Op */ if (op) { - acpi_ps_init_op (op, opcode); + acpi_ps_init_op(op, opcode); op->common.flags = flags; } return (op); } - /******************************************************************************* * * FUNCTION: acpi_ps_free_op @@ -188,26 +169,22 @@ acpi_ps_alloc_op ( * ******************************************************************************/ -void -acpi_ps_free_op ( - union acpi_parse_object *op) +void acpi_ps_free_op(union acpi_parse_object *op) { - ACPI_FUNCTION_NAME ("ps_free_op"); - + ACPI_FUNCTION_NAME("ps_free_op"); if (op->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", op)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", + op)); } if (op->common.flags & ACPI_PARSEOP_GENERIC) { - (void) acpi_os_release_object (acpi_gbl_ps_node_cache, op); - } - else { - (void) acpi_os_release_object (acpi_gbl_ps_node_ext_cache, op); + (void)acpi_os_release_object(acpi_gbl_ps_node_cache, op); + } else { + (void)acpi_os_release_object(acpi_gbl_ps_node_ext_cache, op); } } - /******************************************************************************* * * FUNCTION: Utility functions @@ -216,36 +193,27 @@ acpi_ps_free_op ( * ******************************************************************************/ - /* * Is "c" a namestring lead character? */ -u8 -acpi_ps_is_leading_char ( - u32 c) +u8 acpi_ps_is_leading_char(u32 c) { return ((u8) (c == '_' || (c >= 'A' && c <= 'Z'))); } - /* * Is "c" a namestring prefix character? */ -u8 -acpi_ps_is_prefix_char ( - u32 c) +u8 acpi_ps_is_prefix_char(u32 c) { return ((u8) (c == '\\' || c == '^')); } - /* * Get op's name (4-byte name segment) or 0 if unnamed */ #ifdef ACPI_FUTURE_USAGE -u32 -acpi_ps_get_name ( - union acpi_parse_object *op) +u32 acpi_ps_get_name(union acpi_parse_object * op) { /* The "generic" object has no name associated with it */ @@ -258,16 +226,12 @@ acpi_ps_get_name ( return (op->named.name); } -#endif /* ACPI_FUTURE_USAGE */ - +#endif /* ACPI_FUTURE_USAGE */ /* * Set op's name */ -void -acpi_ps_set_name ( - union acpi_parse_object *op, - u32 name) +void acpi_ps_set_name(union acpi_parse_object *op, u32 name) { /* The "generic" object has no name associated with it */ @@ -278,4 +242,3 @@ acpi_ps_set_name ( op->named.name = name; } - diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/parser/pswalk.c index 9d20cb2..08f2321 100644 --- a/drivers/acpi/parser/pswalk.c +++ b/drivers/acpi/parser/pswalk.c @@ -41,13 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("pswalk") - +ACPI_MODULE_NAME("pswalk") /******************************************************************************* * @@ -60,18 +58,13 @@ * DESCRIPTION: Delete a portion of or an entire parse tree. * ******************************************************************************/ - -void -acpi_ps_delete_parse_tree ( - union acpi_parse_object *subtree_root) +void acpi_ps_delete_parse_tree(union acpi_parse_object *subtree_root) { - union acpi_parse_object *op = subtree_root; - union acpi_parse_object *next = NULL; - union acpi_parse_object *parent = NULL; - - - ACPI_FUNCTION_TRACE_PTR ("ps_delete_parse_tree", subtree_root); + union acpi_parse_object *op = subtree_root; + union acpi_parse_object *next = NULL; + union acpi_parse_object *parent = NULL; + ACPI_FUNCTION_TRACE_PTR("ps_delete_parse_tree", subtree_root); /* Visit all nodes in the subtree */ @@ -81,7 +74,7 @@ acpi_ps_delete_parse_tree ( if (op != parent) { /* Look for an argument or child of the current op */ - next = acpi_ps_get_arg (op, 0); + next = acpi_ps_get_arg(op, 0); if (next) { /* Still going downward in tree (Op is not completed yet) */ @@ -95,7 +88,7 @@ acpi_ps_delete_parse_tree ( next = op->common.next; parent = op->common.parent; - acpi_ps_free_op (op); + acpi_ps_free_op(op); /* If we are back to the starting point, the walk is complete. */ @@ -104,8 +97,7 @@ acpi_ps_delete_parse_tree ( } if (next) { op = next; - } - else { + } else { op = parent; } } diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c index d1541fa..80c67f2 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -41,27 +41,19 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include - #define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("psxface") +ACPI_MODULE_NAME("psxface") /* Local Prototypes */ - -static acpi_status -acpi_ps_execute_pass ( - struct acpi_parameter_info *info); +static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info); static void -acpi_ps_update_parameter_list ( - struct acpi_parameter_info *info, - u16 action); - +acpi_ps_update_parameter_list(struct acpi_parameter_info *info, u16 action); /******************************************************************************* * @@ -86,27 +78,24 @@ acpi_ps_update_parameter_list ( * ******************************************************************************/ -acpi_status -acpi_ps_execute_method ( - struct acpi_parameter_info *info) +acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ps_execute_method"); + acpi_status status; + ACPI_FUNCTION_TRACE("ps_execute_method"); /* Validate the Info and method Node */ if (!info || !info->node) { - return_ACPI_STATUS (AE_NULL_ENTRY); + return_ACPI_STATUS(AE_NULL_ENTRY); } /* Init for new method, wait on concurrency semaphore */ - status = acpi_ds_begin_method_execution (info->node, info->obj_desc, NULL); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ds_begin_method_execution(info->node, info->obj_desc, NULL); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -114,55 +103,54 @@ acpi_ps_execute_method ( * objects (such as Operation Regions) can be created during the * first pass parse. */ - status = acpi_ut_allocate_owner_id (&info->obj_desc->method.owner_id); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_allocate_owner_id(&info->obj_desc->method.owner_id); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* * The caller "owns" the parameters, so give each one an extra * reference */ - acpi_ps_update_parameter_list (info, REF_INCREMENT); + acpi_ps_update_parameter_list(info, REF_INCREMENT); /* * 1) Perform the first pass parse of the method to enter any * named objects that it creates into the namespace */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "**** Begin Method Parse **** Entry=%p obj=%p\n", - info->node, info->obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "**** Begin Method Parse **** Entry=%p obj=%p\n", + info->node, info->obj_desc)); info->pass_number = 1; - status = acpi_ps_execute_pass (info); - if (ACPI_FAILURE (status)) { + status = acpi_ps_execute_pass(info); + if (ACPI_FAILURE(status)) { goto cleanup; } /* * 2) Execute the method. Performs second pass parse simultaneously */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "**** Begin Method Execution **** Entry=%p obj=%p\n", - info->node, info->obj_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "**** Begin Method Execution **** Entry=%p obj=%p\n", + info->node, info->obj_desc)); info->pass_number = 3; - status = acpi_ps_execute_pass (info); - + status = acpi_ps_execute_pass(info); -cleanup: + cleanup: if (info->obj_desc->method.owner_id) { - acpi_ut_release_owner_id (&info->obj_desc->method.owner_id); + acpi_ut_release_owner_id(&info->obj_desc->method.owner_id); } /* Take away the extra reference that we gave the parameters above */ - acpi_ps_update_parameter_list (info, REF_DECREMENT); + acpi_ps_update_parameter_list(info, REF_DECREMENT); /* Exit now if error above */ - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -170,17 +158,17 @@ cleanup: * a control exception code */ if (info->return_object) { - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned obj_desc=%p\n", - info->return_object)); - ACPI_DUMP_STACK_ENTRY (info->return_object); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "Method returned obj_desc=%p\n", + info->return_object)); + ACPI_DUMP_STACK_ENTRY(info->return_object); status = AE_CTRL_RETURN_VALUE; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ps_update_parameter_list @@ -196,26 +184,23 @@ cleanup: ******************************************************************************/ static void -acpi_ps_update_parameter_list ( - struct acpi_parameter_info *info, - u16 action) +acpi_ps_update_parameter_list(struct acpi_parameter_info *info, u16 action) { - acpi_native_uint i; - + acpi_native_uint i; - if ((info->parameter_type == ACPI_PARAM_ARGS) && - (info->parameters)) { + if ((info->parameter_type == ACPI_PARAM_ARGS) && (info->parameters)) { /* Update reference count for each parameter */ for (i = 0; info->parameters[i]; i++) { /* Ignore errors, just do them all */ - (void) acpi_ut_update_object_reference (info->parameters[i], action); + (void)acpi_ut_update_object_reference(info-> + parameters[i], + action); } } } - /******************************************************************************* * * FUNCTION: acpi_ps_execute_pass @@ -229,53 +214,48 @@ acpi_ps_update_parameter_list ( * ******************************************************************************/ -static acpi_status -acpi_ps_execute_pass ( - struct acpi_parameter_info *info) +static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info) { - acpi_status status; - union acpi_parse_object *op; - struct acpi_walk_state *walk_state; - - - ACPI_FUNCTION_TRACE ("ps_execute_pass"); + acpi_status status; + union acpi_parse_object *op; + struct acpi_walk_state *walk_state; + ACPI_FUNCTION_TRACE("ps_execute_pass"); /* Create and init a Root Node */ - op = acpi_ps_create_scope_op (); + op = acpi_ps_create_scope_op(); if (!op) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Create and initialize a new walk state */ - walk_state = acpi_ds_create_walk_state ( - info->obj_desc->method.owner_id, NULL, NULL, NULL); + walk_state = + acpi_ds_create_walk_state(info->obj_desc->method.owner_id, NULL, + NULL, NULL); if (!walk_state) { status = AE_NO_MEMORY; goto cleanup; } - status = acpi_ds_init_aml_walk (walk_state, op, info->node, - info->obj_desc->method.aml_start, - info->obj_desc->method.aml_length, - info->pass_number == 1 ? NULL : info, - info->pass_number); - if (ACPI_FAILURE (status)) { - acpi_ds_delete_walk_state (walk_state); + status = acpi_ds_init_aml_walk(walk_state, op, info->node, + info->obj_desc->method.aml_start, + info->obj_desc->method.aml_length, + info->pass_number == 1 ? NULL : info, + info->pass_number); + if (ACPI_FAILURE(status)) { + acpi_ds_delete_walk_state(walk_state); goto cleanup; } /* Parse the AML */ - status = acpi_ps_parse_aml (walk_state); + status = acpi_ps_parse_aml(walk_state); /* Walk state was deleted by parse_aml */ -cleanup: - acpi_ps_delete_parse_tree (op); - return_ACPI_STATUS (status); + cleanup: + acpi_ps_delete_parse_tree(op); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c index 5148f3c..a495568 100644 --- a/drivers/acpi/pci_bind.c +++ b/drivers/acpi/pci_bind.c @@ -35,22 +35,16 @@ #include #include - #define _COMPONENT ACPI_PCI_COMPONENT -ACPI_MODULE_NAME ("pci_bind") +ACPI_MODULE_NAME("pci_bind") struct acpi_pci_data { - struct acpi_pci_id id; - struct pci_bus *bus; - struct pci_dev *dev; + struct acpi_pci_id id; + struct pci_bus *bus; + struct pci_dev *dev; }; - -void -acpi_pci_data_handler ( - acpi_handle handle, - u32 function, - void *context) +void acpi_pci_data_handler(acpi_handle handle, u32 function, void *context) { ACPI_FUNCTION_TRACE("acpi_pci_data_handler"); @@ -59,7 +53,6 @@ acpi_pci_data_handler ( return_VOID; } - /** * acpi_get_pci_id * ------------------ @@ -67,15 +60,12 @@ acpi_pci_data_handler ( * to resolve PCI information for ACPI-PCI devices defined in the namespace. * This typically occurs when resolving PCI operation region information. */ -acpi_status -acpi_get_pci_id ( - acpi_handle handle, - struct acpi_pci_id *id) +acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id) { - int result = 0; - acpi_status status = AE_OK; - struct acpi_device *device = NULL; - struct acpi_pci_data *data = NULL; + int result = 0; + acpi_status status = AE_OK; + struct acpi_device *device = NULL; + struct acpi_pci_data *data = NULL; ACPI_FUNCTION_TRACE("acpi_get_pci_id"); @@ -84,52 +74,50 @@ acpi_get_pci_id ( result = acpi_bus_get_device(handle, &device); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid ACPI Bus context for device %s\n", - acpi_device_bid(device))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid ACPI Bus context for device %s\n", + acpi_device_bid(device))); return_ACPI_STATUS(AE_NOT_EXIST); } - status = acpi_get_data(handle, acpi_pci_data_handler, (void**) &data); + status = acpi_get_data(handle, acpi_pci_data_handler, (void **)&data); if (ACPI_FAILURE(status) || !data) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid ACPI-PCI context for device %s\n", - acpi_device_bid(device))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid ACPI-PCI context for device %s\n", + acpi_device_bid(device))); return_ACPI_STATUS(status); } *id = data->id; - + /* - id->segment = data->id.segment; - id->bus = data->id.bus; - id->device = data->id.device; - id->function = data->id.function; - */ + id->segment = data->id.segment; + id->bus = data->id.bus; + id->device = data->id.device; + id->function = data->id.function; + */ - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Device %s has PCI address %02x:%02x:%02x.%02x\n", - acpi_device_bid(device), id->segment, id->bus, - id->device, id->function)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Device %s has PCI address %02x:%02x:%02x.%02x\n", + acpi_device_bid(device), id->segment, id->bus, + id->device, id->function)); return_ACPI_STATUS(AE_OK); } + EXPORT_SYMBOL(acpi_get_pci_id); - -int -acpi_pci_bind ( - struct acpi_device *device) +int acpi_pci_bind(struct acpi_device *device) { - int result = 0; - acpi_status status = AE_OK; - struct acpi_pci_data *data = NULL; - struct acpi_pci_data *pdata = NULL; - char *pathname = NULL; - struct acpi_buffer buffer = {0, NULL}; - acpi_handle handle = NULL; - struct pci_dev *dev; - struct pci_bus *bus; + int result = 0; + acpi_status status = AE_OK; + struct acpi_pci_data *data = NULL; + struct acpi_pci_data *pdata = NULL; + char *pathname = NULL; + struct acpi_buffer buffer = { 0, NULL }; + acpi_handle handle = NULL; + struct pci_dev *dev; + struct pci_bus *bus; ACPI_FUNCTION_TRACE("acpi_pci_bind"); @@ -137,34 +125,34 @@ acpi_pci_bind ( return_VALUE(-EINVAL); pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); - if(!pathname) + if (!pathname) return_VALUE(-ENOMEM); memset(pathname, 0, ACPI_PATHNAME_MAX); buffer.length = ACPI_PATHNAME_MAX; buffer.pointer = pathname; data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); - if (!data){ - kfree (pathname); + if (!data) { + kfree(pathname); return_VALUE(-ENOMEM); } memset(data, 0, sizeof(struct acpi_pci_data)); acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", - pathname)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", + pathname)); /* * Segment & Bus * ------------- * These are obtained via the parent device's ACPI-PCI context. */ - status = acpi_get_data(device->parent->handle, acpi_pci_data_handler, - (void**) &pdata); + status = acpi_get_data(device->parent->handle, acpi_pci_data_handler, + (void **)&pdata); if (ACPI_FAILURE(status) || !pdata || !pdata->bus) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid ACPI-PCI context for parent device %s\n", - acpi_device_bid(device->parent))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid ACPI-PCI context for parent device %s\n", + acpi_device_bid(device->parent))); result = -ENODEV; goto end; } @@ -181,8 +169,8 @@ acpi_pci_bind ( data->id.function = device->pnp.bus_address & 0xFFFF; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n", - data->id.segment, data->id.bus, data->id.device, - data->id.function)); + data->id.segment, data->id.bus, data->id.device, + data->id.function)); /* * TBD: Support slot devices (e.g. function=0xFFFF). @@ -202,25 +190,25 @@ acpi_pci_bind ( if (bus) { list_for_each_entry(dev, &bus->devices, bus_list) { if (dev->devfn == PCI_DEVFN(data->id.device, - data->id.function)) { + data->id.function)) { data->dev = dev; break; } } } if (!data->dev) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Device %02x:%02x:%02x.%02x not present in PCI namespace\n", - data->id.segment, data->id.bus, - data->id.device, data->id.function)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Device %02x:%02x:%02x.%02x not present in PCI namespace\n", + data->id.segment, data->id.bus, + data->id.device, data->id.function)); result = -ENODEV; goto end; } if (!data->dev->bus) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", - data->id.segment, data->id.bus, - data->id.device, data->id.function)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", + data->id.segment, data->id.bus, + data->id.device, data->id.function)); result = -ENODEV; goto end; } @@ -232,10 +220,10 @@ acpi_pci_bind ( * facilitate callbacks for all of its children. */ if (data->dev->subordinate) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Device %02x:%02x:%02x.%02x is a PCI bridge\n", - data->id.segment, data->id.bus, - data->id.device, data->id.function)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Device %02x:%02x:%02x.%02x is a PCI bridge\n", + data->id.segment, data->id.bus, + data->id.device, data->id.function)); data->bus = data->dev->subordinate; device->ops.bind = acpi_pci_bind; device->ops.unbind = acpi_pci_unbind; @@ -249,8 +237,8 @@ acpi_pci_bind ( status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to attach ACPI-PCI context to device %s\n", - acpi_device_bid(device))); + "Unable to attach ACPI-PCI context to device %s\n", + acpi_device_bid(device))); result = -ENODEV; goto end; } @@ -267,15 +255,15 @@ acpi_pci_bind ( */ status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); if (ACPI_SUCCESS(status)) { - if (data->bus) /* PCI-PCI bridge */ - acpi_pci_irq_add_prt(device->handle, data->id.segment, - data->bus->number); - else /* non-bridge PCI device */ + if (data->bus) /* PCI-PCI bridge */ acpi_pci_irq_add_prt(device->handle, data->id.segment, - data->id.bus); + data->bus->number); + else /* non-bridge PCI device */ + acpi_pci_irq_add_prt(device->handle, data->id.segment, + data->id.bus); } -end: + end: kfree(pathname); if (result) kfree(data); @@ -283,22 +271,21 @@ end: return_VALUE(result); } -int acpi_pci_unbind( - struct acpi_device *device) +int acpi_pci_unbind(struct acpi_device *device) { - int result = 0; - acpi_status status = AE_OK; - struct acpi_pci_data *data = NULL; - char *pathname = NULL; - struct acpi_buffer buffer = {0, NULL}; + int result = 0; + acpi_status status = AE_OK; + struct acpi_pci_data *data = NULL; + char *pathname = NULL; + struct acpi_buffer buffer = { 0, NULL }; ACPI_FUNCTION_TRACE("acpi_pci_unbind"); if (!device || !device->parent) return_VALUE(-EINVAL); - pathname = (char *) kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); - if(!pathname) + pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); + if (!pathname) return_VALUE(-ENOMEM); memset(pathname, 0, ACPI_PATHNAME_MAX); @@ -306,14 +293,16 @@ int acpi_pci_unbind( buffer.pointer = pathname; acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n", - pathname)); + pathname)); kfree(pathname); - status = acpi_get_data(device->handle, acpi_pci_data_handler, (void**)&data); + status = + acpi_get_data(device->handle, acpi_pci_data_handler, + (void **)&data); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to get data from device %s\n", - acpi_device_bid(device))); + "Unable to get data from device %s\n", + acpi_device_bid(device))); result = -ENODEV; goto end; } @@ -321,8 +310,8 @@ int acpi_pci_unbind( status = acpi_detach_data(device->handle, acpi_pci_data_handler); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to detach data from device %s\n", - acpi_device_bid(device))); + "Unable to detach data from device %s\n", + acpi_device_bid(device))); result = -ENODEV; goto end; } @@ -331,39 +320,37 @@ int acpi_pci_unbind( } kfree(data); -end: + end: return_VALUE(result); } -int -acpi_pci_bind_root ( - struct acpi_device *device, - struct acpi_pci_id *id, - struct pci_bus *bus) +int +acpi_pci_bind_root(struct acpi_device *device, + struct acpi_pci_id *id, struct pci_bus *bus) { - int result = 0; - acpi_status status = AE_OK; - struct acpi_pci_data *data = NULL; - char *pathname = NULL; - struct acpi_buffer buffer = {0, NULL}; + int result = 0; + acpi_status status = AE_OK; + struct acpi_pci_data *data = NULL; + char *pathname = NULL; + struct acpi_buffer buffer = { 0, NULL }; ACPI_FUNCTION_TRACE("acpi_pci_bind_root"); pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); - if(!pathname) + if (!pathname) return_VALUE(-ENOMEM); memset(pathname, 0, ACPI_PATHNAME_MAX); buffer.length = ACPI_PATHNAME_MAX; buffer.pointer = pathname; - if (!device || !id || !bus){ + if (!device || !id || !bus) { kfree(pathname); return_VALUE(-EINVAL); } data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); - if (!data){ + if (!data) { kfree(pathname); return_VALUE(-ENOMEM); } @@ -377,18 +364,18 @@ acpi_pci_bind_root ( acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to " - "%02x:%02x\n", pathname, id->segment, id->bus)); + "%02x:%02x\n", pathname, id->segment, id->bus)); status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to attach ACPI-PCI context to device %s\n", - pathname)); + "Unable to attach ACPI-PCI context to device %s\n", + pathname)); result = -ENODEV; goto end; } -end: + end: kfree(pathname); if (result != 0) kfree(data); diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index c885300..2bbfba8 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c @@ -38,26 +38,22 @@ #include #include - #define _COMPONENT ACPI_PCI_COMPONENT -ACPI_MODULE_NAME ("pci_irq") +ACPI_MODULE_NAME("pci_irq") -static struct acpi_prt_list acpi_prt; +static struct acpi_prt_list acpi_prt; static DEFINE_SPINLOCK(acpi_prt_lock); /* -------------------------------------------------------------------------- PCI IRQ Routing Table (PRT) Support -------------------------------------------------------------------------- */ -static struct acpi_prt_entry * -acpi_pci_irq_find_prt_entry ( - int segment, - int bus, - int device, - int pin) +static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment, + int bus, + int device, int pin) { - struct list_head *node = NULL; - struct acpi_prt_entry *entry = NULL; + struct list_head *node = NULL; + struct acpi_prt_entry *entry = NULL; ACPI_FUNCTION_TRACE("acpi_pci_irq_find_prt_entry"); @@ -72,10 +68,10 @@ acpi_pci_irq_find_prt_entry ( spin_lock(&acpi_prt_lock); list_for_each(node, &acpi_prt.entries) { entry = list_entry(node, struct acpi_prt_entry, node); - if ((segment == entry->id.segment) - && (bus == entry->id.bus) - && (device == entry->id.device) - && (pin == entry->pin)) { + if ((segment == entry->id.segment) + && (bus == entry->id.bus) + && (device == entry->id.device) + && (pin == entry->pin)) { spin_unlock(&acpi_prt_lock); return_PTR(entry); } @@ -85,15 +81,11 @@ acpi_pci_irq_find_prt_entry ( return_PTR(NULL); } - static int -acpi_pci_irq_add_entry ( - acpi_handle handle, - int segment, - int bus, - struct acpi_pci_routing_table *prt) +acpi_pci_irq_add_entry(acpi_handle handle, + int segment, int bus, struct acpi_pci_routing_table *prt) { - struct acpi_prt_entry *entry = NULL; + struct acpi_prt_entry *entry = NULL; ACPI_FUNCTION_TRACE("acpi_pci_irq_add_entry"); @@ -139,9 +131,10 @@ acpi_pci_irq_add_entry ( entry->link.index = prt->source_index; ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, - " %02X:%02X:%02X[%c] -> %s[%d]\n", - entry->id.segment, entry->id.bus, entry->id.device, - ('A' + entry->pin), prt->source, entry->link.index)); + " %02X:%02X:%02X[%c] -> %s[%d]\n", + entry->id.segment, entry->id.bus, + entry->id.device, ('A' + entry->pin), prt->source, + entry->link.index)); spin_lock(&acpi_prt_lock); list_add_tail(&entry->node, &acpi_prt.entries); @@ -151,38 +144,29 @@ acpi_pci_irq_add_entry ( return_VALUE(0); } - static void -acpi_pci_irq_del_entry ( - int segment, - int bus, - struct acpi_prt_entry *entry) +acpi_pci_irq_del_entry(int segment, int bus, struct acpi_prt_entry *entry) { - if (segment == entry->id.segment && bus == entry->id.bus){ + if (segment == entry->id.segment && bus == entry->id.bus) { acpi_prt.count--; list_del(&entry->node); kfree(entry); } } - -int -acpi_pci_irq_add_prt ( - acpi_handle handle, - int segment, - int bus) +int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) { - acpi_status status = AE_OK; - char *pathname = NULL; - struct acpi_buffer buffer = {0, NULL}; - struct acpi_pci_routing_table *prt = NULL; - struct acpi_pci_routing_table *entry = NULL; - static int first_time = 1; + acpi_status status = AE_OK; + char *pathname = NULL; + struct acpi_buffer buffer = { 0, NULL }; + struct acpi_pci_routing_table *prt = NULL; + struct acpi_pci_routing_table *entry = NULL; + static int first_time = 1; ACPI_FUNCTION_TRACE("acpi_pci_irq_add_prt"); - pathname = (char *) kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); - if(!pathname) + pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); + if (!pathname) return_VALUE(-ENOMEM); memset(pathname, 0, ACPI_PATHNAME_MAX); @@ -202,7 +186,7 @@ acpi_pci_irq_add_prt ( acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n", - pathname); + pathname); /* * Evaluate this _PRT and add its entries to our global list (acpi_prt). @@ -214,12 +198,12 @@ acpi_pci_irq_add_prt ( status = acpi_get_irq_routing_table(handle, &buffer); if (status != AE_BUFFER_OVERFLOW) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n", - acpi_format_exception(status))); + acpi_format_exception(status))); return_VALUE(-ENODEV); } prt = kmalloc(buffer.length, GFP_KERNEL); - if (!prt){ + if (!prt) { return_VALUE(-ENOMEM); } memset(prt, 0, buffer.length); @@ -228,7 +212,7 @@ acpi_pci_irq_add_prt ( status = acpi_get_irq_routing_table(handle, &buffer); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n", - acpi_format_exception(status))); + acpi_format_exception(status))); kfree(buffer.pointer); return_VALUE(-ENODEV); } @@ -238,7 +222,7 @@ acpi_pci_irq_add_prt ( while (entry && (entry->length > 0)) { acpi_pci_irq_add_entry(handle, segment, bus, entry); entry = (struct acpi_pci_routing_table *) - ((unsigned long) entry + entry->length); + ((unsigned long)entry + entry->length); } kfree(prt); @@ -246,18 +230,18 @@ acpi_pci_irq_add_prt ( return_VALUE(0); } -void -acpi_pci_irq_del_prt (int segment, int bus) +void acpi_pci_irq_del_prt(int segment, int bus) { - struct list_head *node = NULL, *n = NULL; - struct acpi_prt_entry *entry = NULL; + struct list_head *node = NULL, *n = NULL; + struct acpi_prt_entry *entry = NULL; - if (!acpi_prt.count) { + if (!acpi_prt.count) { return; } - printk(KERN_DEBUG "ACPI: Delete PCI Interrupt Routing Table for %x:%x\n", - segment, bus); + printk(KERN_DEBUG + "ACPI: Delete PCI Interrupt Routing Table for %x:%x\n", segment, + bus); spin_lock(&acpi_prt_lock); list_for_each_safe(node, n, &acpi_prt.entries) { entry = list_entry(node, struct acpi_prt_entry, node); @@ -266,26 +250,27 @@ acpi_pci_irq_del_prt (int segment, int bus) } spin_unlock(&acpi_prt_lock); } + /* -------------------------------------------------------------------------- PCI Interrupt Routing Support -------------------------------------------------------------------------- */ -typedef int (*irq_lookup_func)(struct acpi_prt_entry *, int *, int *, char **); +typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **); static int acpi_pci_allocate_irq(struct acpi_prt_entry *entry, - int *edge_level, - int *active_high_low, - char **link) + int *edge_level, int *active_high_low, char **link) { - int irq; + int irq; ACPI_FUNCTION_TRACE("acpi_pci_allocate_irq"); if (entry->link.handle) { irq = acpi_pci_link_allocate_irq(entry->link.handle, - entry->link.index, edge_level, active_high_low, link); + entry->link.index, edge_level, + active_high_low, link); if (irq < 0) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ link routing entry\n")); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid IRQ link routing entry\n")); return_VALUE(-1); } } else { @@ -300,11 +285,9 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry, static int acpi_pci_free_irq(struct acpi_prt_entry *entry, - int *edge_level, - int *active_high_low, - char **link) + int *edge_level, int *active_high_low, char **link) { - int irq; + int irq; ACPI_FUNCTION_TRACE("acpi_pci_free_irq"); if (entry->link.handle) { @@ -314,38 +297,36 @@ acpi_pci_free_irq(struct acpi_prt_entry *entry, } return_VALUE(irq); } + /* * acpi_pci_irq_lookup * success: return IRQ >= 0 * failure: return -1 */ static int -acpi_pci_irq_lookup ( - struct pci_bus *bus, - int device, - int pin, - int *edge_level, - int *active_high_low, - char **link, - irq_lookup_func func) +acpi_pci_irq_lookup(struct pci_bus *bus, + int device, + int pin, + int *edge_level, + int *active_high_low, char **link, irq_lookup_func func) { - struct acpi_prt_entry *entry = NULL; + struct acpi_prt_entry *entry = NULL; int segment = pci_domain_nr(bus); int bus_nr = bus->number; int ret; ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup"); - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Searching for PRT entry for %02x:%02x:%02x[%c]\n", - segment, bus_nr, device, ('A' + pin))); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Searching for PRT entry for %02x:%02x:%02x[%c]\n", + segment, bus_nr, device, ('A' + pin))); - entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin); + entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin); if (!entry) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n")); return_VALUE(-1); } - + ret = func(entry, edge_level, active_high_low, link); return_VALUE(ret); } @@ -356,17 +337,14 @@ acpi_pci_irq_lookup ( * failure: return < 0 */ static int -acpi_pci_irq_derive ( - struct pci_dev *dev, - int pin, - int *edge_level, - int *active_high_low, - char **link, - irq_lookup_func func) +acpi_pci_irq_derive(struct pci_dev *dev, + int pin, + int *edge_level, + int *active_high_low, char **link, irq_lookup_func func) { - struct pci_dev *bridge = dev; - int irq = -1; - u8 bridge_pin = 0; + struct pci_dev *bridge = dev; + int irq = -1; + u8 bridge_pin = 0; ACPI_FUNCTION_TRACE("acpi_pci_irq_derive"); @@ -383,28 +361,33 @@ acpi_pci_irq_derive ( if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) { /* PC card has the same IRQ as its cardbridge */ - pci_read_config_byte(bridge, PCI_INTERRUPT_PIN, &bridge_pin); + pci_read_config_byte(bridge, PCI_INTERRUPT_PIN, + &bridge_pin); if (!bridge_pin) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "No interrupt pin configured for device %s\n", pci_name(bridge))); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "No interrupt pin configured for device %s\n", + pci_name(bridge))); return_VALUE(-1); } /* Pin is from 0 to 3 */ - bridge_pin --; + bridge_pin--; pin = bridge_pin; } irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), - pin, edge_level, active_high_low, link, func); + pin, edge_level, active_high_low, + link, func); } if (irq < 0) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to derive IRQ for device %s\n", pci_name(dev))); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Unable to derive IRQ for device %s\n", + pci_name(dev))); return_VALUE(-1); } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n", - irq, pci_name(dev), pci_name(bridge))); + irq, pci_name(dev), pci_name(bridge))); return_VALUE(irq); } @@ -415,31 +398,32 @@ acpi_pci_irq_derive ( * failure: return < 0 */ -int -acpi_pci_irq_enable ( - struct pci_dev *dev) +int acpi_pci_irq_enable(struct pci_dev *dev) { - int irq = 0; - u8 pin = 0; - int edge_level = ACPI_LEVEL_SENSITIVE; - int active_high_low = ACPI_ACTIVE_LOW; - char *link = NULL; - int rc; + int irq = 0; + u8 pin = 0; + int edge_level = ACPI_LEVEL_SENSITIVE; + int active_high_low = ACPI_ACTIVE_LOW; + char *link = NULL; + int rc; ACPI_FUNCTION_TRACE("acpi_pci_irq_enable"); if (!dev) return_VALUE(-EINVAL); - + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); if (!pin) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No interrupt pin configured for device %s\n", pci_name(dev))); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "No interrupt pin configured for device %s\n", + pci_name(dev))); return_VALUE(0); } pin--; if (!dev->bus) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) 'bus' field\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid (NULL) 'bus' field\n")); return_VALUE(-ENODEV); } @@ -447,35 +431,37 @@ acpi_pci_irq_enable ( * First we check the PCI IRQ routing table (PRT) for an IRQ. PRT * values override any BIOS-assigned IRQs set during boot. */ - irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, - &edge_level, &active_high_low, &link, acpi_pci_allocate_irq); + irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, + &edge_level, &active_high_low, &link, + acpi_pci_allocate_irq); /* * If no PRT entry was found, we'll try to derive an IRQ from the * device's parent bridge. */ if (irq < 0) - irq = acpi_pci_irq_derive(dev, pin, &edge_level, - &active_high_low, &link, acpi_pci_allocate_irq); - + irq = acpi_pci_irq_derive(dev, pin, &edge_level, + &active_high_low, &link, + acpi_pci_allocate_irq); + /* * No IRQ known to the ACPI subsystem - maybe the BIOS / * driver reported one, then use it. Exit in any case. */ if (irq < 0) { printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: no GSI", - pci_name(dev), ('A' + pin)); + pci_name(dev), ('A' + pin)); /* Interrupt Line values above 0xF are forbidden */ if (dev->irq > 0 && (dev->irq <= 0xF)) { printk(" - using IRQ %d\n", dev->irq); - acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW); + acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, + ACPI_ACTIVE_LOW); return_VALUE(0); - } - else { + } else { printk("\n"); return_VALUE(0); } - } + } rc = acpi_register_gsi(irq, edge_level, active_high_low); if (rc < 0) { @@ -486,32 +472,31 @@ acpi_pci_irq_enable ( dev->irq = rc; printk(KERN_INFO PREFIX "PCI Interrupt %s[%c] -> ", - pci_name(dev), 'A' + pin); + pci_name(dev), 'A' + pin); if (link) printk("Link [%s] -> ", link); printk("GSI %u (%s, %s) -> IRQ %d\n", irq, - (edge_level == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", - (active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high", - dev->irq); + (edge_level == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", + (active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); return_VALUE(0); } -EXPORT_SYMBOL(acpi_pci_irq_enable); +EXPORT_SYMBOL(acpi_pci_irq_enable); /* FIXME: implement x86/x86_64 version */ -void __attribute__((weak)) acpi_unregister_gsi(u32 i) {} +void __attribute__ ((weak)) acpi_unregister_gsi(u32 i) +{ +} -void -acpi_pci_irq_disable ( - struct pci_dev *dev) +void acpi_pci_irq_disable(struct pci_dev *dev) { - int gsi = 0; - u8 pin = 0; - int edge_level = ACPI_LEVEL_SENSITIVE; - int active_high_low = ACPI_ACTIVE_LOW; + int gsi = 0; + u8 pin = 0; + int edge_level = ACPI_LEVEL_SENSITIVE; + int active_high_low = ACPI_ACTIVE_LOW; ACPI_FUNCTION_TRACE("acpi_pci_irq_disable"); @@ -529,15 +514,17 @@ acpi_pci_irq_disable ( /* * First we check the PCI IRQ routing table (PRT) for an IRQ. */ - gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, - &edge_level, &active_high_low, NULL, acpi_pci_free_irq); + gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, + &edge_level, &active_high_low, NULL, + acpi_pci_free_irq); /* * If no PRT entry was found, we'll try to derive an IRQ from the * device's parent bridge. */ if (gsi < 0) - gsi = acpi_pci_irq_derive(dev, pin, - &edge_level, &active_high_low, NULL, acpi_pci_free_irq); + gsi = acpi_pci_irq_derive(dev, pin, + &edge_level, &active_high_low, NULL, + acpi_pci_free_irq); if (gsi < 0) return_VOID; diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index e8334ce..82292b7 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -42,30 +42,26 @@ #include #include - #define _COMPONENT ACPI_PCI_COMPONENT -ACPI_MODULE_NAME ("pci_link") - +ACPI_MODULE_NAME("pci_link") #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" - #define ACPI_PCI_LINK_MAX_POSSIBLE 16 - -static int acpi_pci_link_add (struct acpi_device *device); -static int acpi_pci_link_remove (struct acpi_device *device, int type); +static int acpi_pci_link_add(struct acpi_device *device); +static int acpi_pci_link_remove(struct acpi_device *device, int type); static struct acpi_driver acpi_pci_link_driver = { - .name = ACPI_PCI_LINK_DRIVER_NAME, - .class = ACPI_PCI_LINK_CLASS, - .ids = ACPI_PCI_LINK_HID, - .ops = { - .add = acpi_pci_link_add, - .remove = acpi_pci_link_remove, - }, + .name = ACPI_PCI_LINK_DRIVER_NAME, + .class = ACPI_PCI_LINK_CLASS, + .ids = ACPI_PCI_LINK_HID, + .ops = { + .add = acpi_pci_link_add, + .remove = acpi_pci_link_remove, + }, }; /* @@ -73,31 +69,30 @@ static struct acpi_driver acpi_pci_link_driver = { * later even the link is disable. Instead, we just repick the active irq */ struct acpi_pci_link_irq { - u8 active; /* Current IRQ */ - u8 edge_level; /* All IRQs */ - u8 active_high_low; /* All IRQs */ - u8 resource_type; - u8 possible_count; - u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; - u8 initialized:1; - u8 reserved:7; + u8 active; /* Current IRQ */ + u8 edge_level; /* All IRQs */ + u8 active_high_low; /* All IRQs */ + u8 resource_type; + u8 possible_count; + u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; + u8 initialized:1; + u8 reserved:7; }; struct acpi_pci_link { - struct list_head node; - struct acpi_device *device; - acpi_handle handle; + struct list_head node; + struct acpi_device *device; + acpi_handle handle; struct acpi_pci_link_irq irq; - int refcnt; + int refcnt; }; static struct { - int count; - struct list_head entries; -} acpi_link; + int count; + struct list_head entries; +} acpi_link; DECLARE_MUTEX(acpi_link_lock); - /* -------------------------------------------------------------------------- PCI Link Device Management -------------------------------------------------------------------------- */ @@ -106,12 +101,10 @@ DECLARE_MUTEX(acpi_link_lock); * set context (link) possible list from resource list */ static acpi_status -acpi_pci_link_check_possible ( - struct acpi_resource *resource, - void *context) +acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) { - struct acpi_pci_link *link = (struct acpi_pci_link *) context; - u32 i = 0; + struct acpi_pci_link *link = (struct acpi_pci_link *)context; + u32 i = 0; ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible"); @@ -119,61 +112,68 @@ acpi_pci_link_check_possible ( case ACPI_RSTYPE_START_DPF: return_ACPI_STATUS(AE_OK); case ACPI_RSTYPE_IRQ: - { - struct acpi_resource_irq *p = &resource->data.irq; - if (!p || !p->number_of_interrupts) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Blank IRQ resource\n")); - return_ACPI_STATUS(AE_OK); - } - for (i = 0; (inumber_of_interrupts && iinterrupts[i]) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ %d\n", p->interrupts[i])); - continue; + { + struct acpi_resource_irq *p = &resource->data.irq; + if (!p || !p->number_of_interrupts) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Blank IRQ resource\n")); + return_ACPI_STATUS(AE_OK); } - link->irq.possible[i] = p->interrupts[i]; - link->irq.possible_count++; + for (i = 0; + (i < p->number_of_interrupts + && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { + if (!p->interrupts[i]) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid IRQ %d\n", + p->interrupts[i])); + continue; + } + link->irq.possible[i] = p->interrupts[i]; + link->irq.possible_count++; + } + link->irq.edge_level = p->edge_level; + link->irq.active_high_low = p->active_high_low; + link->irq.resource_type = ACPI_RSTYPE_IRQ; + break; } - link->irq.edge_level = p->edge_level; - link->irq.active_high_low = p->active_high_low; - link->irq.resource_type = ACPI_RSTYPE_IRQ; - break; - } case ACPI_RSTYPE_EXT_IRQ: - { - struct acpi_resource_ext_irq *p = &resource->data.extended_irq; - if (!p || !p->number_of_interrupts) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Blank EXT IRQ resource\n")); - return_ACPI_STATUS(AE_OK); - } - for (i = 0; (inumber_of_interrupts && iinterrupts[i]) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ %d\n", p->interrupts[i])); - continue; + { + struct acpi_resource_ext_irq *p = + &resource->data.extended_irq; + if (!p || !p->number_of_interrupts) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Blank EXT IRQ resource\n")); + return_ACPI_STATUS(AE_OK); + } + for (i = 0; + (i < p->number_of_interrupts + && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { + if (!p->interrupts[i]) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid IRQ %d\n", + p->interrupts[i])); + continue; + } + link->irq.possible[i] = p->interrupts[i]; + link->irq.possible_count++; } - link->irq.possible[i] = p->interrupts[i]; - link->irq.possible_count++; + link->irq.edge_level = p->edge_level; + link->irq.active_high_low = p->active_high_low; + link->irq.resource_type = ACPI_RSTYPE_EXT_IRQ; + break; } - link->irq.edge_level = p->edge_level; - link->irq.active_high_low = p->active_high_low; - link->irq.resource_type = ACPI_RSTYPE_EXT_IRQ; - break; - } default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Resource is not an IRQ entry\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Resource is not an IRQ entry\n")); return_ACPI_STATUS(AE_OK); } return_ACPI_STATUS(AE_CTRL_TERMINATE); } - -static int -acpi_pci_link_get_possible ( - struct acpi_pci_link *link) +static int acpi_pci_link_get_possible(struct acpi_pci_link *link) { - acpi_status status; + acpi_status status; ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible"); @@ -181,62 +181,60 @@ acpi_pci_link_get_possible ( return_VALUE(-EINVAL); status = acpi_walk_resources(link->handle, METHOD_NAME__PRS, - acpi_pci_link_check_possible, link); + acpi_pci_link_check_possible, link); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRS\n")); return_VALUE(-ENODEV); } - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Found %d possible IRQs\n", link->irq.possible_count)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Found %d possible IRQs\n", + link->irq.possible_count)); return_VALUE(0); } - static acpi_status -acpi_pci_link_check_current ( - struct acpi_resource *resource, - void *context) +acpi_pci_link_check_current(struct acpi_resource *resource, void *context) { - int *irq = (int *) context; + int *irq = (int *)context; ACPI_FUNCTION_TRACE("acpi_pci_link_check_current"); switch (resource->id) { case ACPI_RSTYPE_IRQ: - { - struct acpi_resource_irq *p = &resource->data.irq; - if (!p || !p->number_of_interrupts) { - /* - * IRQ descriptors may have no IRQ# bits set, - * particularly those those w/ _STA disabled - */ - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Blank IRQ resource\n")); - return_ACPI_STATUS(AE_OK); + { + struct acpi_resource_irq *p = &resource->data.irq; + if (!p || !p->number_of_interrupts) { + /* + * IRQ descriptors may have no IRQ# bits set, + * particularly those those w/ _STA disabled + */ + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Blank IRQ resource\n")); + return_ACPI_STATUS(AE_OK); + } + *irq = p->interrupts[0]; + break; } - *irq = p->interrupts[0]; - break; - } case ACPI_RSTYPE_EXT_IRQ: - { - struct acpi_resource_ext_irq *p = &resource->data.extended_irq; - if (!p || !p->number_of_interrupts) { - /* - * extended IRQ descriptors must - * return at least 1 IRQ - */ - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Blank EXT IRQ resource\n")); - return_ACPI_STATUS(AE_OK); + { + struct acpi_resource_ext_irq *p = + &resource->data.extended_irq; + if (!p || !p->number_of_interrupts) { + /* + * extended IRQ descriptors must + * return at least 1 IRQ + */ + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Blank EXT IRQ resource\n")); + return_ACPI_STATUS(AE_OK); + } + *irq = p->interrupts[0]; + break; } - *irq = p->interrupts[0]; - break; - } default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Resource isn't an IRQ\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource isn't an IRQ\n")); return_ACPI_STATUS(AE_OK); } return_ACPI_STATUS(AE_CTRL_TERMINATE); @@ -249,13 +247,11 @@ acpi_pci_link_check_current ( * 0 - success * !0 - failure */ -static int -acpi_pci_link_get_current ( - struct acpi_pci_link *link) +static int acpi_pci_link_get_current(struct acpi_pci_link *link) { - int result = 0; - acpi_status status = AE_OK; - int irq = 0; + int result = 0; + acpi_status status = AE_OK; + int irq = 0; ACPI_FUNCTION_TRACE("acpi_pci_link_get_current"); @@ -269,7 +265,8 @@ acpi_pci_link_get_current ( /* Query _STA, set link->device->status */ result = acpi_bus_get_status(link->device); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to read status\n")); goto end; } @@ -284,7 +281,7 @@ acpi_pci_link_get_current ( */ status = acpi_walk_resources(link->handle, METHOD_NAME__CRS, - acpi_pci_link_check_current, &irq); + acpi_pci_link_check_current, &irq); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _CRS\n")); result = -ENODEV; @@ -300,58 +297,61 @@ acpi_pci_link_get_current ( ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active)); -end: + end: return_VALUE(result); } -static int -acpi_pci_link_set ( - struct acpi_pci_link *link, - int irq) +static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) { - int result = 0; - acpi_status status = AE_OK; + int result = 0; + acpi_status status = AE_OK; struct { - struct acpi_resource res; - struct acpi_resource end; - } *resource; - struct acpi_buffer buffer = {0, NULL}; + struct acpi_resource res; + struct acpi_resource end; + } *resource; + struct acpi_buffer buffer = { 0, NULL }; ACPI_FUNCTION_TRACE("acpi_pci_link_set"); if (!link || !irq) return_VALUE(-EINVAL); - resource = kmalloc( sizeof(*resource)+1, GFP_KERNEL); - if(!resource) + resource = kmalloc(sizeof(*resource) + 1, GFP_KERNEL); + if (!resource) return_VALUE(-ENOMEM); - memset(resource, 0, sizeof(*resource)+1); - buffer.length = sizeof(*resource) +1; + memset(resource, 0, sizeof(*resource) + 1); + buffer.length = sizeof(*resource) + 1; buffer.pointer = resource; - switch(link->irq.resource_type) { + switch (link->irq.resource_type) { case ACPI_RSTYPE_IRQ: resource->res.id = ACPI_RSTYPE_IRQ; resource->res.length = sizeof(struct acpi_resource); resource->res.data.irq.edge_level = link->irq.edge_level; - resource->res.data.irq.active_high_low = link->irq.active_high_low; + resource->res.data.irq.active_high_low = + link->irq.active_high_low; if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) - resource->res.data.irq.shared_exclusive = ACPI_EXCLUSIVE; + resource->res.data.irq.shared_exclusive = + ACPI_EXCLUSIVE; else resource->res.data.irq.shared_exclusive = ACPI_SHARED; resource->res.data.irq.number_of_interrupts = 1; resource->res.data.irq.interrupts[0] = irq; break; - + case ACPI_RSTYPE_EXT_IRQ: resource->res.id = ACPI_RSTYPE_EXT_IRQ; resource->res.length = sizeof(struct acpi_resource); - resource->res.data.extended_irq.producer_consumer = ACPI_CONSUMER; - resource->res.data.extended_irq.edge_level = link->irq.edge_level; - resource->res.data.extended_irq.active_high_low = link->irq.active_high_low; + resource->res.data.extended_irq.producer_consumer = + ACPI_CONSUMER; + resource->res.data.extended_irq.edge_level = + link->irq.edge_level; + resource->res.data.extended_irq.active_high_low = + link->irq.active_high_low; if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) - resource->res.data.irq.shared_exclusive = ACPI_EXCLUSIVE; + resource->res.data.irq.shared_exclusive = + ACPI_EXCLUSIVE; else resource->res.data.irq.shared_exclusive = ACPI_SHARED; resource->res.data.extended_irq.number_of_interrupts = 1; @@ -384,9 +384,9 @@ acpi_pci_link_set ( } if (!link->device->status.enabled) { printk(KERN_WARNING PREFIX - "%s [%s] disabled and referenced, BIOS bug.\n", - acpi_device_name(link->device), - acpi_device_bid(link->device)); + "%s [%s] disabled and referenced, BIOS bug.\n", + acpi_device_name(link->device), + acpi_device_bid(link->device)); } /* Query _CRS, set link->irq.active */ @@ -404,22 +404,20 @@ acpi_pci_link_set ( * policy: when _CRS doesn't return what we just _SRS * assume _SRS worked and override _CRS value. */ - printk(KERN_WARNING PREFIX - "%s [%s] BIOS reported IRQ %d, using IRQ %d\n", - acpi_device_name(link->device), - acpi_device_bid(link->device), - link->irq.active, irq); + printk(KERN_WARNING PREFIX + "%s [%s] BIOS reported IRQ %d, using IRQ %d\n", + acpi_device_name(link->device), + acpi_device_bid(link->device), link->irq.active, irq); link->irq.active = irq; } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Set IRQ %d\n", link->irq.active)); - -end: + + end: kfree(resource); return_VALUE(result); } - /* -------------------------------------------------------------------------- PCI Link IRQ Management -------------------------------------------------------------------------- */ @@ -469,8 +467,8 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = { PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */ PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */ PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */ - PIRQ_PENALTY_ISA_TYPICAL, /* IRQ3 serial */ - PIRQ_PENALTY_ISA_TYPICAL, /* IRQ4 serial */ + PIRQ_PENALTY_ISA_TYPICAL, /* IRQ3 serial */ + PIRQ_PENALTY_ISA_TYPICAL, /* IRQ4 serial */ PIRQ_PENALTY_ISA_TYPICAL, /* IRQ5 sometimes SoundBlaster */ PIRQ_PENALTY_ISA_TYPICAL, /* IRQ6 */ PIRQ_PENALTY_ISA_TYPICAL, /* IRQ7 parallel, spurious */ @@ -482,15 +480,14 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = { PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */ PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */ PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */ - /* >IRQ15 */ + /* >IRQ15 */ }; -int __init -acpi_irq_penalty_init(void) +int __init acpi_irq_penalty_init(void) { - struct list_head *node = NULL; - struct acpi_pci_link *link = NULL; - int i = 0; + struct list_head *node = NULL; + struct acpi_pci_link *link = NULL; + int i = 0; ACPI_FUNCTION_TRACE("acpi_irq_penalty_init"); @@ -501,7 +498,8 @@ acpi_irq_penalty_init(void) link = list_entry(node, struct acpi_pci_link, node); if (!link) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid link context\n")); continue; } @@ -510,15 +508,20 @@ acpi_irq_penalty_init(void) * useful for breaking ties. */ if (link->irq.possible_count) { - int penalty = PIRQ_PENALTY_PCI_POSSIBLE / link->irq.possible_count; + int penalty = + PIRQ_PENALTY_PCI_POSSIBLE / + link->irq.possible_count; for (i = 0; i < link->irq.possible_count; i++) { if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ) - acpi_irq_penalty[link->irq.possible[i]] += penalty; + acpi_irq_penalty[link->irq. + possible[i]] += + penalty; } } else if (link->irq.active) { - acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_POSSIBLE; + acpi_irq_penalty[link->irq.active] += + PIRQ_PENALTY_PCI_POSSIBLE; } } /* Add a penalty for the SCI */ @@ -529,10 +532,10 @@ acpi_irq_penalty_init(void) static int acpi_irq_balance; /* 0: static, 1: balance */ -static int acpi_pci_link_allocate(struct acpi_pci_link *link) +static int acpi_pci_link_allocate(struct acpi_pci_link *link) { - int irq; - int i; + int irq; + int i; ACPI_FUNCTION_TRACE("acpi_pci_link_allocate"); @@ -556,7 +559,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) if (i == link->irq.possible_count) { if (acpi_strict) printk(KERN_WARNING PREFIX "_CRS %d not found" - " in _PRS\n", link->irq.active); + " in _PRS\n", link->irq.active); link->irq.active = 0; } @@ -575,23 +578,25 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) * the use of IRQs 9, 10, 11, and >15. */ for (i = (link->irq.possible_count - 1); i >= 0; i--) { - if (acpi_irq_penalty[irq] > acpi_irq_penalty[link->irq.possible[i]]) + if (acpi_irq_penalty[irq] > + acpi_irq_penalty[link->irq.possible[i]]) irq = link->irq.possible[i]; } } /* Attempt to enable the link device at this IRQ. */ if (acpi_pci_link_set(link, irq)) { - printk(PREFIX "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n" - "Try pci=noacpi or acpi=off\n", - acpi_device_name(link->device), - acpi_device_bid(link->device)); + printk(PREFIX + "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n" + "Try pci=noacpi or acpi=off\n", + acpi_device_name(link->device), + acpi_device_bid(link->device)); return_VALUE(-ENODEV); } else { acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; - printk(PREFIX "%s [%s] enabled at IRQ %d\n", - acpi_device_name(link->device), - acpi_device_bid(link->device), link->irq.active); + printk(PREFIX "%s [%s] enabled at IRQ %d\n", + acpi_device_name(link->device), + acpi_device_bid(link->device), link->irq.active); } link->irq.initialized = 1; @@ -606,16 +611,13 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) */ int -acpi_pci_link_allocate_irq ( - acpi_handle handle, - int index, - int *edge_level, - int *active_high_low, - char **name) +acpi_pci_link_allocate_irq(acpi_handle handle, + int index, + int *edge_level, int *active_high_low, char **name) { - int result = 0; - struct acpi_device *device = NULL; - struct acpi_pci_link *link = NULL; + int result = 0; + struct acpi_device *device = NULL; + struct acpi_pci_link *link = NULL; ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq"); @@ -625,7 +627,7 @@ acpi_pci_link_allocate_irq ( return_VALUE(-1); } - link = (struct acpi_pci_link *) acpi_driver_data(device); + link = (struct acpi_pci_link *)acpi_driver_data(device); if (!link) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); return_VALUE(-1); @@ -642,20 +644,24 @@ acpi_pci_link_allocate_irq ( up(&acpi_link_lock); return_VALUE(-1); } - + if (!link->irq.active) { up(&acpi_link_lock); ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n")); return_VALUE(-1); } - link->refcnt ++; + link->refcnt++; up(&acpi_link_lock); - if (edge_level) *edge_level = link->irq.edge_level; - if (active_high_low) *active_high_low = link->irq.active_high_low; - if (name) *name = acpi_device_bid(link->device); + if (edge_level) + *edge_level = link->irq.edge_level; + if (active_high_low) + *active_high_low = link->irq.active_high_low; + if (name) + *name = acpi_device_bid(link->device); ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Link %s is referenced\n", acpi_device_bid(link->device))); + "Link %s is referenced\n", + acpi_device_bid(link->device))); return_VALUE(link->irq.active); } @@ -663,12 +669,11 @@ acpi_pci_link_allocate_irq ( * We don't change link's irq information here. After it is reenabled, we * continue use the info */ -int -acpi_pci_link_free_irq(acpi_handle handle) +int acpi_pci_link_free_irq(acpi_handle handle) { - struct acpi_device *device = NULL; - struct acpi_pci_link *link = NULL; - acpi_status result; + struct acpi_device *device = NULL; + struct acpi_pci_link *link = NULL; + acpi_status result; ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq"); @@ -678,7 +683,7 @@ acpi_pci_link_free_irq(acpi_handle handle) return_VALUE(-1); } - link = (struct acpi_pci_link *) acpi_driver_data(device); + link = (struct acpi_pci_link *)acpi_driver_data(device); if (!link) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); return_VALUE(-1); @@ -690,7 +695,6 @@ acpi_pci_link_free_irq(acpi_handle handle) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n")); return_VALUE(-1); } - #ifdef FUTURE_USE /* * The Link reference count allows us to _DISable an unused link @@ -701,10 +705,11 @@ acpi_pci_link_free_irq(acpi_handle handle) * to prevent duplicate acpi_pci_link_set() * which would harm some systems */ - link->refcnt --; + link->refcnt--; #endif ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Link %s is dereferenced\n", acpi_device_bid(link->device))); + "Link %s is dereferenced\n", + acpi_device_bid(link->device))); if (link->refcnt == 0) { acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); @@ -712,17 +717,17 @@ acpi_pci_link_free_irq(acpi_handle handle) up(&acpi_link_lock); return_VALUE(link->irq.active); } + /* -------------------------------------------------------------------------- Driver Interface -------------------------------------------------------------------------- */ -static int -acpi_pci_link_add(struct acpi_device *device) +static int acpi_pci_link_add(struct acpi_device *device) { - int result = 0; - struct acpi_pci_link *link = NULL; - int i = 0; - int found = 0; + int result = 0; + struct acpi_pci_link *link = NULL; + int i = 0; + int found = 0; ACPI_FUNCTION_TRACE("acpi_pci_link_add"); @@ -749,13 +754,12 @@ acpi_pci_link_add(struct acpi_device *device) acpi_pci_link_get_current(link); printk(PREFIX "%s [%s] (IRQs", acpi_device_name(device), - acpi_device_bid(device)); + acpi_device_bid(device)); for (i = 0; i < link->irq.possible_count; i++) { if (link->irq.active == link->irq.possible[i]) { printk(" *%d", link->irq.possible[i]); found = 1; - } - else + } else printk(" %d", link->irq.possible[i]); } @@ -764,7 +768,7 @@ acpi_pci_link_add(struct acpi_device *device) if (!found) printk(" *%d", link->irq.active); - if(!link->device->status.enabled) + if (!link->device->status.enabled) printk(", disabled."); printk("\n"); @@ -773,7 +777,7 @@ acpi_pci_link_add(struct acpi_device *device) list_add_tail(&link->node, &acpi_link.entries); acpi_link.count++; -end: + end: /* disable all links -- to be activated on use */ acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); up(&acpi_link_lock); @@ -784,9 +788,7 @@ end: return_VALUE(result); } -static int -acpi_pci_link_resume( - struct acpi_pci_link *link) +static int acpi_pci_link_resume(struct acpi_pci_link *link) { ACPI_FUNCTION_TRACE("acpi_pci_link_resume"); @@ -801,11 +803,10 @@ acpi_pci_link_resume( * after every device calls pci_disable_device in .resume. */ int acpi_in_resume; -static int -irqrouter_resume(struct sys_device *dev) +static int irqrouter_resume(struct sys_device *dev) { - struct list_head *node = NULL; - struct acpi_pci_link *link = NULL; + struct list_head *node = NULL; + struct acpi_pci_link *link = NULL; ACPI_FUNCTION_TRACE("irqrouter_resume"); @@ -814,7 +815,7 @@ irqrouter_resume(struct sys_device *dev) link = list_entry(node, struct acpi_pci_link, node); if (!link) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid link context\n")); + "Invalid link context\n")); continue; } acpi_pci_link_resume(link); @@ -823,9 +824,7 @@ irqrouter_resume(struct sys_device *dev) return_VALUE(0); } - -static int -acpi_pci_link_remove(struct acpi_device *device, int type) +static int acpi_pci_link_remove(struct acpi_device *device, int type) { struct acpi_pci_link *link = NULL; @@ -834,7 +833,7 @@ acpi_pci_link_remove(struct acpi_device *device, int type) if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); - link = (struct acpi_pci_link *) acpi_driver_data(device); + link = (struct acpi_pci_link *)acpi_driver_data(device); down(&acpi_link_lock); list_del(&link->node); @@ -856,14 +855,14 @@ static int __init acpi_irq_penalty_update(char *str, int used) int retval; int irq; - retval = get_option(&str,&irq); + retval = get_option(&str, &irq); if (!retval) break; /* no number found */ if (irq < 0) continue; - + if (irq >= ACPI_MAX_IRQS) continue; @@ -902,6 +901,7 @@ static int __init acpi_irq_isa(char *str) { return acpi_irq_penalty_update(str, 1); } + __setup("acpi_irq_isa=", acpi_irq_isa); /* @@ -913,6 +913,7 @@ static int __init acpi_irq_pci(char *str) { return acpi_irq_penalty_update(str, 0); } + __setup("acpi_irq_pci=", acpi_irq_pci); static int __init acpi_irq_nobalance_set(char *str) @@ -920,6 +921,7 @@ static int __init acpi_irq_nobalance_set(char *str) acpi_irq_balance = 0; return 1; } + __setup("acpi_irq_nobalance", acpi_irq_nobalance_set); int __init acpi_irq_balance_set(char *str) @@ -927,22 +929,20 @@ int __init acpi_irq_balance_set(char *str) acpi_irq_balance = 1; return 1; } -__setup("acpi_irq_balance", acpi_irq_balance_set); +__setup("acpi_irq_balance", acpi_irq_balance_set); /* FIXME: we will remove this interface after all drivers call pci_disable_device */ static struct sysdev_class irqrouter_sysdev_class = { - set_kset_name("irqrouter"), - .resume = irqrouter_resume, + set_kset_name("irqrouter"), + .resume = irqrouter_resume, }; - static struct sys_device device_irqrouter = { - .id = 0, - .cls = &irqrouter_sysdev_class, + .id = 0, + .cls = &irqrouter_sysdev_class, }; - static int __init irqrouter_init_sysfs(void) { int error; @@ -957,12 +957,11 @@ static int __init irqrouter_init_sysfs(void) error = sysdev_register(&device_irqrouter); return_VALUE(error); -} +} device_initcall(irqrouter_init_sysfs); - -static int __init acpi_pci_link_init (void) +static int __init acpi_pci_link_init(void) { ACPI_FUNCTION_TRACE("acpi_pci_link_init"); diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 5d2f77f..0fd9988 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -35,35 +35,32 @@ #include #include - #define _COMPONENT ACPI_PCI_COMPONENT -ACPI_MODULE_NAME ("pci_root") - +ACPI_MODULE_NAME("pci_root") #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" - -static int acpi_pci_root_add (struct acpi_device *device); -static int acpi_pci_root_remove (struct acpi_device *device, int type); -static int acpi_pci_root_start (struct acpi_device *device); +static int acpi_pci_root_add(struct acpi_device *device); +static int acpi_pci_root_remove(struct acpi_device *device, int type); +static int acpi_pci_root_start(struct acpi_device *device); static struct acpi_driver acpi_pci_root_driver = { - .name = ACPI_PCI_ROOT_DRIVER_NAME, - .class = ACPI_PCI_ROOT_CLASS, - .ids = ACPI_PCI_ROOT_HID, - .ops = { - .add = acpi_pci_root_add, - .remove = acpi_pci_root_remove, - .start = acpi_pci_root_start, - }, + .name = ACPI_PCI_ROOT_DRIVER_NAME, + .class = ACPI_PCI_ROOT_CLASS, + .ids = ACPI_PCI_ROOT_HID, + .ops = { + .add = acpi_pci_root_add, + .remove = acpi_pci_root_remove, + .start = acpi_pci_root_start, + }, }; struct acpi_pci_root { - struct list_head node; - acpi_handle handle; - struct acpi_pci_id id; - struct pci_bus *bus; + struct list_head node; + acpi_handle handle; + struct acpi_pci_id id; + struct pci_bus *bus; }; static LIST_HEAD(acpi_pci_roots); @@ -92,6 +89,7 @@ int acpi_pci_register_driver(struct acpi_pci_driver *driver) return n; } + EXPORT_SYMBOL(acpi_pci_register_driver); void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) @@ -115,10 +113,11 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) driver->remove(root->handle); } } + EXPORT_SYMBOL(acpi_pci_unregister_driver); static acpi_status -get_root_bridge_busnr_callback (struct acpi_resource *resource, void *data) +get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) { int *busnr = (int *)data; struct acpi_resource_address64 address; @@ -129,20 +128,21 @@ get_root_bridge_busnr_callback (struct acpi_resource *resource, void *data) return AE_OK; acpi_resource_to_address64(resource, &address); - if ((address.address_length > 0) && - (address.resource_type == ACPI_BUS_NUMBER_RANGE)) + if ((address.address_length > 0) && + (address.resource_type == ACPI_BUS_NUMBER_RANGE)) *busnr = address.min_address_range; return AE_OK; } -static acpi_status -try_get_root_bridge_busnr(acpi_handle handle, int *busnum) +static acpi_status try_get_root_bridge_busnr(acpi_handle handle, int *busnum) { acpi_status status; *busnum = -1; - status = acpi_walk_resources(handle, METHOD_NAME__CRS, get_root_bridge_busnr_callback, busnum); + status = + acpi_walk_resources(handle, METHOD_NAME__CRS, + get_root_bridge_busnr_callback, busnum); if (ACPI_FAILURE(status)) return status; /* Check if we really get a bus number from _CRS */ @@ -151,16 +151,14 @@ try_get_root_bridge_busnr(acpi_handle handle, int *busnum) return AE_OK; } -static int -acpi_pci_root_add ( - struct acpi_device *device) +static int acpi_pci_root_add(struct acpi_device *device) { - int result = 0; - struct acpi_pci_root *root = NULL; - struct acpi_pci_root *tmp; - acpi_status status = AE_OK; - unsigned long value = 0; - acpi_handle handle = NULL; + int result = 0; + struct acpi_pci_root *root = NULL; + struct acpi_pci_root *tmp; + acpi_status status = AE_OK; + unsigned long value = 0; + acpi_handle handle = NULL; ACPI_FUNCTION_TRACE("acpi_pci_root_add"); @@ -188,15 +186,15 @@ acpi_pci_root_add ( * ------- * Obtained via _SEG, if exists, otherwise assumed to be zero (0). */ - status = acpi_evaluate_integer(root->handle, METHOD_NAME__SEG, NULL, - &value); + status = acpi_evaluate_integer(root->handle, METHOD_NAME__SEG, NULL, + &value); switch (status) { case AE_OK: root->id.segment = (u16) value; break; case AE_NOT_FOUND: - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Assuming segment 0 (no _SEG)\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Assuming segment 0 (no _SEG)\n")); root->id.segment = 0; break; default: @@ -210,8 +208,8 @@ acpi_pci_root_add ( * --- * Obtained via _BBN, if exists, otherwise assumed to be zero (0). */ - status = acpi_evaluate_integer(root->handle, METHOD_NAME__BBN, NULL, - &value); + status = acpi_evaluate_integer(root->handle, METHOD_NAME__BBN, NULL, + &value); switch (status) { case AE_OK: root->id.bus = (u16) value; @@ -229,18 +227,19 @@ acpi_pci_root_add ( /* Some systems have wrong _BBN */ list_for_each_entry(tmp, &acpi_pci_roots, node) { if ((tmp->id.segment == root->id.segment) - && (tmp->id.bus == root->id.bus)) { + && (tmp->id.bus == root->id.bus)) { int bus = 0; acpi_status status; - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Wrong _BBN value, please reboot and using option 'pci=noacpi'\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Wrong _BBN value, please reboot and using option 'pci=noacpi'\n")); status = try_get_root_bridge_busnr(root->handle, &bus); if (ACPI_FAILURE(status)) break; if (bus != root->id.bus) { - printk(KERN_INFO PREFIX "PCI _CRS %d overrides _BBN 0\n", bus); + printk(KERN_INFO PREFIX + "PCI _CRS %d overrides _BBN 0\n", bus); root->id.bus = bus; } break; @@ -258,12 +257,12 @@ acpi_pci_root_add ( * TBD: Need PCI interface for enumeration/configuration of roots. */ - /* TBD: Locking */ - list_add_tail(&root->node, &acpi_pci_roots); + /* TBD: Locking */ + list_add_tail(&root->node, &acpi_pci_roots); - printk(KERN_INFO PREFIX "%s [%s] (%04x:%02x)\n", - acpi_device_name(device), acpi_device_bid(device), - root->id.segment, root->id.bus); + printk(KERN_INFO PREFIX "%s [%s] (%04x:%02x)\n", + acpi_device_name(device), acpi_device_bid(device), + root->id.segment, root->id.bus); /* * Scan the Root Bridge @@ -274,9 +273,9 @@ acpi_pci_root_add ( */ root->bus = pci_acpi_scan_root(device, root->id.segment, root->id.bus); if (!root->bus) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Bus %04x:%02x not present in PCI namespace\n", - root->id.segment, root->id.bus)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Bus %04x:%02x not present in PCI namespace\n", + root->id.segment, root->id.bus)); result = -ENODEV; goto end; } @@ -298,9 +297,9 @@ acpi_pci_root_add ( status = acpi_get_handle(root->handle, METHOD_NAME__PRT, &handle); if (ACPI_SUCCESS(status)) result = acpi_pci_irq_add_prt(root->handle, root->id.segment, - root->id.bus); + root->id.bus); -end: + end: if (result) { if (!list_empty(&root->node)) list_del(&root->node); @@ -310,11 +309,9 @@ end: return_VALUE(result); } -static int -acpi_pci_root_start ( - struct acpi_device *device) +static int acpi_pci_root_start(struct acpi_device *device) { - struct acpi_pci_root *root; + struct acpi_pci_root *root; ACPI_FUNCTION_TRACE("acpi_pci_root_start"); @@ -327,27 +324,23 @@ acpi_pci_root_start ( return_VALUE(-ENODEV); } -static int -acpi_pci_root_remove ( - struct acpi_device *device, - int type) +static int acpi_pci_root_remove(struct acpi_device *device, int type) { - struct acpi_pci_root *root = NULL; + struct acpi_pci_root *root = NULL; ACPI_FUNCTION_TRACE("acpi_pci_root_remove"); if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); - root = (struct acpi_pci_root *) acpi_driver_data(device); + root = (struct acpi_pci_root *)acpi_driver_data(device); kfree(root); return_VALUE(0); } - -static int __init acpi_pci_root_init (void) +static int __init acpi_pci_root_init(void) { ACPI_FUNCTION_TRACE("acpi_pci_root_init"); @@ -355,8 +348,8 @@ static int __init acpi_pci_root_init (void) return_VALUE(0); /* DEBUG: - acpi_dbg_layer = ACPI_PCI_COMPONENT; - acpi_dbg_level = 0xFFFFFFFF; + acpi_dbg_layer = ACPI_PCI_COMPONENT; + acpi_dbg_level = 0xFFFFFFFF; */ if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) @@ -366,4 +359,3 @@ static int __init acpi_pci_root_init (void) } subsys_initcall(acpi_pci_root_init); - diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 373a3a9..62a5595 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -44,10 +44,8 @@ #include #include - #define _COMPONENT ACPI_POWER_COMPONENT -ACPI_MODULE_NAME ("acpi_power") - +ACPI_MODULE_NAME("acpi_power") #define ACPI_POWER_COMPONENT 0x00800000 #define ACPI_POWER_CLASS "power_resource" #define ACPI_POWER_DRIVER_NAME "ACPI Power Resource Driver" @@ -57,38 +55,36 @@ ACPI_MODULE_NAME ("acpi_power") #define ACPI_POWER_RESOURCE_STATE_OFF 0x00 #define ACPI_POWER_RESOURCE_STATE_ON 0x01 #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF - -static int acpi_power_add (struct acpi_device *device); -static int acpi_power_remove (struct acpi_device *device, int type); +static int acpi_power_add(struct acpi_device *device); +static int acpi_power_remove(struct acpi_device *device, int type); static int acpi_power_open_fs(struct inode *inode, struct file *file); static struct acpi_driver acpi_power_driver = { - .name = ACPI_POWER_DRIVER_NAME, - .class = ACPI_POWER_CLASS, - .ids = ACPI_POWER_HID, - .ops = { - .add = acpi_power_add, - .remove = acpi_power_remove, - }, + .name = ACPI_POWER_DRIVER_NAME, + .class = ACPI_POWER_CLASS, + .ids = ACPI_POWER_HID, + .ops = { + .add = acpi_power_add, + .remove = acpi_power_remove, + }, }; -struct acpi_power_resource -{ - acpi_handle handle; - acpi_bus_id name; - u32 system_level; - u32 order; - int state; - int references; +struct acpi_power_resource { + acpi_handle handle; + acpi_bus_id name; + u32 system_level; + u32 order; + int state; + int references; }; -static struct list_head acpi_power_resource_list; +static struct list_head acpi_power_resource_list; static struct file_operations acpi_power_fops = { - .open = acpi_power_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_power_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; /* -------------------------------------------------------------------------- @@ -96,12 +92,11 @@ static struct file_operations acpi_power_fops = { -------------------------------------------------------------------------- */ static int -acpi_power_get_context ( - acpi_handle handle, - struct acpi_power_resource **resource) +acpi_power_get_context(acpi_handle handle, + struct acpi_power_resource **resource) { - int result = 0; - struct acpi_device *device = NULL; + int result = 0; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_power_get_context"); @@ -111,24 +106,21 @@ acpi_power_get_context ( result = acpi_bus_get_device(handle, &device); if (result) { ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n", - handle)); + handle)); return_VALUE(result); } - *resource = (struct acpi_power_resource *) acpi_driver_data(device); + *resource = (struct acpi_power_resource *)acpi_driver_data(device); if (!resource) return_VALUE(-ENODEV); return_VALUE(0); } - -static int -acpi_power_get_state ( - struct acpi_power_resource *resource) +static int acpi_power_get_state(struct acpi_power_resource *resource) { - acpi_status status = AE_OK; - unsigned long sta = 0; + acpi_status status = AE_OK; + unsigned long sta = 0; ACPI_FUNCTION_TRACE("acpi_power_get_state"); @@ -145,20 +137,16 @@ acpi_power_get_state ( resource->state = ACPI_POWER_RESOURCE_STATE_OFF; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", - resource->name, resource->state?"on":"off")); + resource->name, resource->state ? "on" : "off")); return_VALUE(0); } - -static int -acpi_power_get_list_state ( - struct acpi_handle_list *list, - int *state) +static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) { - int result = 0; + int result = 0; struct acpi_power_resource *resource = NULL; - u32 i = 0; + u32 i = 0; ACPI_FUNCTION_TRACE("acpi_power_get_list_state"); @@ -167,7 +155,7 @@ acpi_power_get_list_state ( /* The state of the list is 'on' IFF all resources are 'on'. */ - for (i=0; icount; i++) { + for (i = 0; i < list->count; i++) { result = acpi_power_get_context(list->handles[i], &resource); if (result) return_VALUE(result); @@ -182,19 +170,16 @@ acpi_power_get_list_state ( } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n", - *state?"on":"off")); + *state ? "on" : "off")); return_VALUE(result); } - -static int -acpi_power_on ( - acpi_handle handle) +static int acpi_power_on(acpi_handle handle) { - int result = 0; - acpi_status status = AE_OK; - struct acpi_device *device = NULL; + int result = 0; + acpi_status status = AE_OK; + struct acpi_device *device = NULL; struct acpi_power_resource *resource = NULL; ACPI_FUNCTION_TRACE("acpi_power_on"); @@ -205,10 +190,10 @@ acpi_power_on ( resource->references++; - if ((resource->references > 1) - || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) { + if ((resource->references > 1) + || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n", - resource->name)); + resource->name)); return_VALUE(0); } @@ -229,19 +214,16 @@ acpi_power_on ( device->power.state = ACPI_STATE_D0; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n", - resource->name)); + resource->name)); return_VALUE(0); } - -static int -acpi_power_off_device ( - acpi_handle handle) +static int acpi_power_off_device(acpi_handle handle) { - int result = 0; - acpi_status status = AE_OK; - struct acpi_device *device = NULL; + int result = 0; + acpi_status status = AE_OK; + struct acpi_device *device = NULL; struct acpi_power_resource *resource = NULL; ACPI_FUNCTION_TRACE("acpi_power_off_device"); @@ -254,15 +236,15 @@ acpi_power_off_device ( resource->references--; if (resource->references) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Resource [%s] is still in use, dereferencing\n", - device->pnp.bus_id)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Resource [%s] is still in use, dereferencing\n", + device->pnp.bus_id)); return_VALUE(0); } if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n", - device->pnp.bus_id)); + device->pnp.bus_id)); return_VALUE(0); } @@ -283,7 +265,7 @@ acpi_power_off_device ( device->power.state = ACPI_STATE_D3; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", - resource->name)); + resource->name)); return_VALUE(0); } @@ -293,13 +275,13 @@ acpi_power_off_device ( * 1. Power on the power resources required for the wakeup device * 2. Enable _PSW (power state wake) for the device if present */ -int acpi_enable_wakeup_device_power (struct acpi_device *dev) +int acpi_enable_wakeup_device_power(struct acpi_device *dev) { - union acpi_object arg = {ACPI_TYPE_INTEGER}; - struct acpi_object_list arg_list = {1, &arg}; - acpi_status status = AE_OK; - int i; - int ret = 0; + union acpi_object arg = { ACPI_TYPE_INTEGER }; + struct acpi_object_list arg_list = { 1, &arg }; + acpi_status status = AE_OK; + int i; + int ret = 0; ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_power"); if (!dev || !dev->wakeup.flags.valid) @@ -310,8 +292,8 @@ int acpi_enable_wakeup_device_power (struct acpi_device *dev) for (i = 0; i < dev->wakeup.resources.count; i++) { ret = acpi_power_on(dev->wakeup.resources.handles[i]); if (ret) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error transition power state\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error transition power state\n")); dev->wakeup.flags.valid = 0; return_VALUE(-1); } @@ -333,20 +315,20 @@ int acpi_enable_wakeup_device_power (struct acpi_device *dev) * 1. Disable _PSW (power state wake) * 2. Shutdown down the power resources */ -int acpi_disable_wakeup_device_power (struct acpi_device *dev) +int acpi_disable_wakeup_device_power(struct acpi_device *dev) { - union acpi_object arg = {ACPI_TYPE_INTEGER}; - struct acpi_object_list arg_list = {1, &arg}; - acpi_status status = AE_OK; - int i; - int ret = 0; + union acpi_object arg = { ACPI_TYPE_INTEGER }; + struct acpi_object_list arg_list = { 1, &arg }; + acpi_status status = AE_OK; + int i; + int ret = 0; ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device_power"); if (!dev || !dev->wakeup.flags.valid) return_VALUE(-1); - arg.integer.value = 0; + arg.integer.value = 0; /* Execute PSW */ status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL); if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { @@ -359,8 +341,8 @@ int acpi_disable_wakeup_device_power (struct acpi_device *dev) for (i = 0; i < dev->wakeup.resources.count; i++) { ret = acpi_power_off_device(dev->wakeup.resources.handles[i]); if (ret) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error transition power state\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error transition power state\n")); dev->wakeup.flags.valid = 0; return_VALUE(-1); } @@ -373,14 +355,12 @@ int acpi_disable_wakeup_device_power (struct acpi_device *dev) Device Power Management -------------------------------------------------------------------------- */ -int -acpi_power_get_inferred_state ( - struct acpi_device *device) +int acpi_power_get_inferred_state(struct acpi_device *device) { - int result = 0; - struct acpi_handle_list *list = NULL; - int list_state = 0; - int i = 0; + int result = 0; + struct acpi_handle_list *list = NULL; + int list_state = 0; + int i = 0; ACPI_FUNCTION_TRACE("acpi_power_get_inferred_state"); @@ -393,7 +373,7 @@ acpi_power_get_inferred_state ( * We know a device's inferred power state when all the resources * required for a given D-state are 'on'. */ - for (i=ACPI_STATE_D0; ipower.states[i].resources; if (list->count < 1) continue; @@ -413,23 +393,20 @@ acpi_power_get_inferred_state ( return_VALUE(0); } - -int -acpi_power_transition ( - struct acpi_device *device, - int state) +int acpi_power_transition(struct acpi_device *device, int state) { - int result = 0; - struct acpi_handle_list *cl = NULL; /* Current Resources */ - struct acpi_handle_list *tl = NULL; /* Target Resources */ - int i = 0; + int result = 0; + struct acpi_handle_list *cl = NULL; /* Current Resources */ + struct acpi_handle_list *tl = NULL; /* Target Resources */ + int i = 0; ACPI_FUNCTION_TRACE("acpi_power_transition"); if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) return_VALUE(-EINVAL); - if ((device->power.state < ACPI_STATE_D0) || (device->power.state > ACPI_STATE_D3)) + if ((device->power.state < ACPI_STATE_D0) + || (device->power.state > ACPI_STATE_D3)) return_VALUE(-ENODEV); cl = &device->power.states[device->power.state].resources; @@ -448,7 +425,7 @@ acpi_power_transition ( * First we reference all power resources required in the target list * (e.g. so the device doesn't lose power while transitioning). */ - for (i=0; icount; i++) { + for (i = 0; i < tl->count; i++) { result = acpi_power_on(tl->handles[i]); if (result) goto end; @@ -457,7 +434,7 @@ acpi_power_transition ( /* * Then we dereference all power resources used in the current list. */ - for (i=0; icount; i++) { + for (i = 0; i < cl->count; i++) { result = acpi_power_off_device(cl->handles[i]); if (result) goto end; @@ -465,21 +442,20 @@ acpi_power_transition ( /* We shouldn't change the state till all above operations succeed */ device->power.state = state; -end: + end: if (result) - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Error transitioning device [%s] to D%d\n", - device->pnp.bus_id, state)); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Error transitioning device [%s] to D%d\n", + device->pnp.bus_id, state)); return_VALUE(result); } - /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ -static struct proc_dir_entry *acpi_power_dir; +static struct proc_dir_entry *acpi_power_dir; static int acpi_power_seq_show(struct seq_file *seq, void *offset) { @@ -506,13 +482,12 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset) } seq_printf(seq, "system level: S%d\n" - "order: %d\n" - "reference count: %d\n", - resource->system_level, - resource->order, - resource->references); + "order: %d\n" + "reference count: %d\n", + resource->system_level, + resource->order, resource->references); -end: + end: return_VALUE(0); } @@ -521,11 +496,9 @@ static int acpi_power_open_fs(struct inode *inode, struct file *file) return single_open(file, acpi_power_seq_show, PDE(inode)->data); } -static int -acpi_power_add_fs ( - struct acpi_device *device) +static int acpi_power_add_fs(struct acpi_device *device) { - struct proc_dir_entry *entry = NULL; + struct proc_dir_entry *entry = NULL; ACPI_FUNCTION_TRACE("acpi_power_add_fs"); @@ -534,18 +507,18 @@ acpi_power_add_fs ( if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), - acpi_power_dir); + acpi_power_dir); if (!acpi_device_dir(device)) return_VALUE(-ENODEV); } /* 'status' [R] */ entry = create_proc_entry(ACPI_POWER_FILE_STATUS, - S_IRUGO, acpi_device_dir(device)); + S_IRUGO, acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_POWER_FILE_STATUS)); + "Unable to create '%s' fs entry\n", + ACPI_POWER_FILE_STATUS)); else { entry->proc_fops = &acpi_power_fops; entry->data = acpi_driver_data(device); @@ -554,10 +527,7 @@ acpi_power_add_fs ( return_VALUE(0); } - -static int -acpi_power_remove_fs ( - struct acpi_device *device) +static int acpi_power_remove_fs(struct acpi_device *device) { ACPI_FUNCTION_TRACE("acpi_power_remove_fs"); @@ -571,20 +541,17 @@ acpi_power_remove_fs ( return_VALUE(0); } - /* -------------------------------------------------------------------------- Driver Interface -------------------------------------------------------------------------- */ -static int -acpi_power_add ( - struct acpi_device *device) +static int acpi_power_add(struct acpi_device *device) { - int result = 0; - acpi_status status = AE_OK; + int result = 0; + acpi_status status = AE_OK; struct acpi_power_resource *resource = NULL; - union acpi_object acpi_object; - struct acpi_buffer buffer = {sizeof(acpi_object), &acpi_object}; + union acpi_object acpi_object; + struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object }; ACPI_FUNCTION_TRACE("acpi_power_add"); @@ -630,22 +597,18 @@ acpi_power_add ( result = acpi_power_add_fs(device); if (result) goto end; - + printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device), - acpi_device_bid(device), resource->state?"on":"off"); + acpi_device_bid(device), resource->state ? "on" : "off"); -end: + end: if (result) kfree(resource); - + return_VALUE(result); } - -static int -acpi_power_remove ( - struct acpi_device *device, - int type) +static int acpi_power_remove(struct acpi_device *device, int type) { struct acpi_power_resource *resource = NULL; @@ -654,7 +617,7 @@ acpi_power_remove ( if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); - resource = (struct acpi_power_resource *) acpi_driver_data(device); + resource = (struct acpi_power_resource *)acpi_driver_data(device); acpi_power_remove_fs(device); @@ -663,10 +626,9 @@ acpi_power_remove ( return_VALUE(0); } - -static int __init acpi_power_init (void) +static int __init acpi_power_init(void) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_power_init"); @@ -689,4 +651,3 @@ static int __init acpi_power_init (void) } subsys_initcall(acpi_power_init); - diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index d56a439..819cb0b 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -58,7 +58,6 @@ #include #include - #define ACPI_PROCESSOR_COMPONENT 0x01000000 #define ACPI_PROCESSOR_CLASS "processor" #define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" @@ -75,59 +74,53 @@ #define ACPI_STA_PRESENT 0x00000001 #define _COMPONENT ACPI_PROCESSOR_COMPONENT -ACPI_MODULE_NAME ("acpi_processor") +ACPI_MODULE_NAME("acpi_processor") -MODULE_AUTHOR("Paul Diefenbaugh"); + MODULE_AUTHOR("Paul Diefenbaugh"); MODULE_DESCRIPTION(ACPI_PROCESSOR_DRIVER_NAME); MODULE_LICENSE("GPL"); - -static int acpi_processor_add (struct acpi_device *device); -static int acpi_processor_start (struct acpi_device *device); -static int acpi_processor_remove (struct acpi_device *device, int type); +static int acpi_processor_add(struct acpi_device *device); +static int acpi_processor_start(struct acpi_device *device); +static int acpi_processor_remove(struct acpi_device *device, int type); static int acpi_processor_info_open_fs(struct inode *inode, struct file *file); -static void acpi_processor_notify ( acpi_handle handle, u32 event, void *data); +static void acpi_processor_notify(acpi_handle handle, u32 event, void *data); static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu); static int acpi_processor_handle_eject(struct acpi_processor *pr); static struct acpi_driver acpi_processor_driver = { - .name = ACPI_PROCESSOR_DRIVER_NAME, - .class = ACPI_PROCESSOR_CLASS, - .ids = ACPI_PROCESSOR_HID, - .ops = { - .add = acpi_processor_add, - .remove = acpi_processor_remove, - .start = acpi_processor_start, - }, + .name = ACPI_PROCESSOR_DRIVER_NAME, + .class = ACPI_PROCESSOR_CLASS, + .ids = ACPI_PROCESSOR_HID, + .ops = { + .add = acpi_processor_add, + .remove = acpi_processor_remove, + .start = acpi_processor_start, + }, }; #define INSTALL_NOTIFY_HANDLER 1 #define UNINSTALL_NOTIFY_HANDLER 2 - static struct file_operations acpi_processor_info_fops = { - .open = acpi_processor_info_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_processor_info_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; - -struct acpi_processor *processors[NR_CPUS]; +struct acpi_processor *processors[NR_CPUS]; struct acpi_processor_errata errata; - /* -------------------------------------------------------------------------- Errata Handling -------------------------------------------------------------------------- */ -static int -acpi_processor_errata_piix4 ( - struct pci_dev *dev) +static int acpi_processor_errata_piix4(struct pci_dev *dev) { - u8 rev = 0; - u8 value1 = 0; - u8 value2 = 0; + u8 rev = 0; + u8 value1 = 0; + u8 value2 = 0; ACPI_FUNCTION_TRACE("acpi_processor_errata_piix4"); @@ -188,8 +181,8 @@ acpi_processor_errata_piix4 ( * DMA activity. */ dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_INTEL_82371AB, - PCI_ANY_ID, PCI_ANY_ID, NULL); + PCI_DEVICE_ID_INTEL_82371AB, + PCI_ANY_ID, PCI_ANY_ID, NULL); if (dev) { errata.piix4.bmisx = pci_resource_start(dev, 4); pci_dev_put(dev); @@ -205,8 +198,8 @@ acpi_processor_errata_piix4 ( * devices won't operate well if fast DMA is disabled. */ dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_INTEL_82371AB_0, - PCI_ANY_ID, PCI_ANY_ID, NULL); + PCI_DEVICE_ID_INTEL_82371AB_0, + PCI_ANY_ID, PCI_ANY_ID, NULL); if (dev) { pci_read_config_byte(dev, 0x76, &value1); pci_read_config_byte(dev, 0x77, &value2); @@ -220,21 +213,18 @@ acpi_processor_errata_piix4 ( if (errata.piix4.bmisx) ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Bus master activity detection (BM-IDE) erratum enabled\n")); + "Bus master activity detection (BM-IDE) erratum enabled\n")); if (errata.piix4.fdma) ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Type-F DMA livelock erratum (C3 disabled)\n")); + "Type-F DMA livelock erratum (C3 disabled)\n")); return_VALUE(0); } - -int -acpi_processor_errata ( - struct acpi_processor *pr) +int acpi_processor_errata(struct acpi_processor *pr) { - int result = 0; - struct pci_dev *dev = NULL; + int result = 0; + struct pci_dev *dev = NULL; ACPI_FUNCTION_TRACE("acpi_processor_errata"); @@ -245,7 +235,8 @@ acpi_processor_errata ( * PIIX4 */ dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, PCI_ANY_ID, NULL); + PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, + PCI_ANY_ID, NULL); if (dev) { result = acpi_processor_errata_piix4(dev); pci_dev_put(dev); @@ -254,7 +245,6 @@ acpi_processor_errata ( return_VALUE(result); } - /* -------------------------------------------------------------------------- Common ACPI processor fucntions -------------------------------------------------------------------------- */ @@ -265,13 +255,13 @@ acpi_processor_errata ( */ int acpi_processor_set_pdc(struct acpi_processor *pr, - struct acpi_object_list *pdc_in) + struct acpi_object_list *pdc_in) { - acpi_status status = AE_OK; - u32 arg0_buf[3]; - union acpi_object arg0 = {ACPI_TYPE_BUFFER}; - struct acpi_object_list no_object = {1, &arg0}; - struct acpi_object_list *pdc; + acpi_status status = AE_OK; + u32 arg0_buf[3]; + union acpi_object arg0 = { ACPI_TYPE_BUFFER }; + struct acpi_object_list no_object = { 1, &arg0 }; + struct acpi_object_list *pdc; ACPI_FUNCTION_TRACE("acpi_processor_set_pdc"); @@ -286,21 +276,21 @@ int acpi_processor_set_pdc(struct acpi_processor *pr, status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL); if ((ACPI_FAILURE(status)) && (pdc_in)) - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Error evaluating _PDC, using legacy perf. control...\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Error evaluating _PDC, using legacy perf. control...\n")); return_VALUE(status); } - /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ -static struct proc_dir_entry *acpi_processor_dir = NULL; +static struct proc_dir_entry *acpi_processor_dir = NULL; static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset) { - struct acpi_processor *pr = (struct acpi_processor *)seq->private; + struct acpi_processor *pr = (struct acpi_processor *)seq->private; ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show"); @@ -308,40 +298,37 @@ static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset) goto end; seq_printf(seq, "processor id: %d\n" - "acpi id: %d\n" - "bus mastering control: %s\n" - "power management: %s\n" - "throttling control: %s\n" - "limit interface: %s\n", - pr->id, - pr->acpi_id, - pr->flags.bm_control ? "yes" : "no", - pr->flags.power ? "yes" : "no", - pr->flags.throttling ? "yes" : "no", - pr->flags.limit ? "yes" : "no"); - -end: + "acpi id: %d\n" + "bus mastering control: %s\n" + "power management: %s\n" + "throttling control: %s\n" + "limit interface: %s\n", + pr->id, + pr->acpi_id, + pr->flags.bm_control ? "yes" : "no", + pr->flags.power ? "yes" : "no", + pr->flags.throttling ? "yes" : "no", + pr->flags.limit ? "yes" : "no"); + + end: return_VALUE(0); } static int acpi_processor_info_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_processor_info_seq_show, - PDE(inode)->data); + PDE(inode)->data); } - -static int -acpi_processor_add_fs ( - struct acpi_device *device) +static int acpi_processor_add_fs(struct acpi_device *device) { - struct proc_dir_entry *entry = NULL; + struct proc_dir_entry *entry = NULL; ACPI_FUNCTION_TRACE("acpi_processor_add_fs"); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), - acpi_processor_dir); + acpi_processor_dir); if (!acpi_device_dir(device)) return_VALUE(-ENODEV); } @@ -349,11 +336,11 @@ acpi_processor_add_fs ( /* 'info' [R] */ entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO, - S_IRUGO, acpi_device_dir(device)); + S_IRUGO, acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_PROCESSOR_FILE_INFO)); + "Unable to create '%s' fs entry\n", + ACPI_PROCESSOR_FILE_INFO)); else { entry->proc_fops = &acpi_processor_info_fops; entry->data = acpi_driver_data(device); @@ -362,11 +349,12 @@ acpi_processor_add_fs ( /* 'throttling' [R/W] */ entry = create_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, - S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_PROCESSOR_FILE_THROTTLING)); + "Unable to create '%s' fs entry\n", + ACPI_PROCESSOR_FILE_THROTTLING)); else { entry->proc_fops = &acpi_processor_throttling_fops; entry->proc_fops->write = acpi_processor_write_throttling; @@ -376,11 +364,12 @@ acpi_processor_add_fs ( /* 'limit' [R/W] */ entry = create_proc_entry(ACPI_PROCESSOR_FILE_LIMIT, - S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_PROCESSOR_FILE_LIMIT)); + "Unable to create '%s' fs entry\n", + ACPI_PROCESSOR_FILE_LIMIT)); else { entry->proc_fops = &acpi_processor_limit_fops; entry->proc_fops->write = acpi_processor_write_limit; @@ -391,18 +380,17 @@ acpi_processor_add_fs ( return_VALUE(0); } - -static int -acpi_processor_remove_fs ( - struct acpi_device *device) +static int acpi_processor_remove_fs(struct acpi_device *device) { ACPI_FUNCTION_TRACE("acpi_processor_remove_fs"); if (acpi_device_dir(device)) { - remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,acpi_device_dir(device)); + remove_proc_entry(ACPI_PROCESSOR_FILE_INFO, + acpi_device_dir(device)); remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, - acpi_device_dir(device)); - remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,acpi_device_dir(device)); + acpi_device_dir(device)); + remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT, + acpi_device_dir(device)); remove_proc_entry(acpi_device_bid(device), acpi_processor_dir); acpi_device_dir(device) = NULL; } @@ -446,15 +434,13 @@ static u8 convert_acpiid_to_cpu(u8 acpi_id) Driver Interface -------------------------------------------------------------------------- */ -static int -acpi_processor_get_info ( - struct acpi_processor *pr) +static int acpi_processor_get_info(struct acpi_processor *pr) { - acpi_status status = 0; - union acpi_object object = {0}; - struct acpi_buffer buffer = {sizeof(union acpi_object), &object}; - u8 cpu_index; - static int cpu0_initialized; + acpi_status status = 0; + union acpi_object object = { 0 }; + struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; + u8 cpu_index; + static int cpu0_initialized; ACPI_FUNCTION_TRACE("acpi_processor_get_info"); @@ -473,11 +459,10 @@ acpi_processor_get_info ( if (acpi_fadt.V1_pm2_cnt_blk && acpi_fadt.pm2_cnt_len) { pr->flags.bm_control = 1; ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Bus mastering arbitration control present\n")); - } - else + "Bus mastering arbitration control present\n")); + } else ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "No bus mastering arbitration control\n")); + "No bus mastering arbitration control\n")); /* * Evalute the processor object. Note that it is common on SMP to @@ -487,50 +472,51 @@ acpi_processor_get_info ( status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error evaluating processor object\n")); + "Error evaluating processor object\n")); return_VALUE(-ENODEV); } /* * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. - * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c + * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c */ pr->acpi_id = object.processor.proc_id; cpu_index = convert_acpiid_to_cpu(pr->acpi_id); - /* Handle UP system running SMP kernel, with no LAPIC in MADT */ - if ( !cpu0_initialized && (cpu_index == 0xff) && - (num_online_cpus() == 1)) { - cpu_index = 0; - } - - cpu0_initialized = 1; - - pr->id = cpu_index; - - /* - * Extra Processor objects may be enumerated on MP systems with - * less than the max # of CPUs. They should be ignored _iff - * they are physically not present. - */ - if (cpu_index >= NR_CPUS) { - if (ACPI_FAILURE(acpi_processor_hotadd_init(pr->handle, &pr->id))) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error getting cpuindex for acpiid 0x%x\n", - pr->acpi_id)); - return_VALUE(-ENODEV); - } - } + /* Handle UP system running SMP kernel, with no LAPIC in MADT */ + if (!cpu0_initialized && (cpu_index == 0xff) && + (num_online_cpus() == 1)) { + cpu_index = 0; + } + + cpu0_initialized = 1; + + pr->id = cpu_index; + + /* + * Extra Processor objects may be enumerated on MP systems with + * less than the max # of CPUs. They should be ignored _iff + * they are physically not present. + */ + if (cpu_index >= NR_CPUS) { + if (ACPI_FAILURE + (acpi_processor_hotadd_init(pr->handle, &pr->id))) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error getting cpuindex for acpiid 0x%x\n", + pr->acpi_id)); + return_VALUE(-ENODEV); + } + } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id, - pr->acpi_id)); + pr->acpi_id)); if (!object.processor.pblk_address) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); else if (object.processor.pblk_length != 6) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n", - object.processor.pblk_length)); + object.processor.pblk_length)); else { pr->throttling.address = object.processor.pblk_address; pr->throttling.duty_offset = acpi_fadt.duty_offset; @@ -557,13 +543,11 @@ acpi_processor_get_info ( return_VALUE(0); } -static int -acpi_processor_start( - struct acpi_device *device) +static int acpi_processor_start(struct acpi_device *device) { - int result = 0; - acpi_status status = AE_OK; - struct acpi_processor *pr; + int result = 0; + acpi_status status = AE_OK; + struct acpi_processor *pr; ACPI_FUNCTION_TRACE("acpi_processor_start"); @@ -584,36 +568,30 @@ acpi_processor_start( goto end; status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, - acpi_processor_notify, pr); + acpi_processor_notify, pr); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing device notify handler\n")); + "Error installing device notify handler\n")); } acpi_processor_power_init(pr, device); if (pr->flags.throttling) { printk(KERN_INFO PREFIX "%s [%s] (supports", - acpi_device_name(device), acpi_device_bid(device)); + acpi_device_name(device), acpi_device_bid(device)); printk(" %d throttling states", pr->throttling.state_count); printk(")\n"); } -end: + end: return_VALUE(result); } - - -static void -acpi_processor_notify ( - acpi_handle handle, - u32 event, - void *data) +static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_processor *pr = (struct acpi_processor *) data; - struct acpi_device *device = NULL; + struct acpi_processor *pr = (struct acpi_processor *)data; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_processor_notify"); @@ -627,7 +605,7 @@ acpi_processor_notify ( case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: acpi_processor_ppc_has_changed(pr); acpi_bus_generate_event(device, event, - pr->performance_platform_limit); + pr->performance_platform_limit); break; case ACPI_PROCESSOR_NOTIFY_POWER: acpi_processor_cst_has_changed(pr); @@ -635,19 +613,16 @@ acpi_processor_notify ( break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Unsupported event [0x%x]\n", event)); + "Unsupported event [0x%x]\n", event)); break; } return_VOID; } - -static int -acpi_processor_add ( - struct acpi_device *device) +static int acpi_processor_add(struct acpi_device *device) { - struct acpi_processor *pr = NULL; + struct acpi_processor *pr = NULL; ACPI_FUNCTION_TRACE("acpi_processor_add"); @@ -667,21 +642,17 @@ acpi_processor_add ( return_VALUE(0); } - -static int -acpi_processor_remove ( - struct acpi_device *device, - int type) +static int acpi_processor_remove(struct acpi_device *device, int type) { - acpi_status status = AE_OK; - struct acpi_processor *pr = NULL; + acpi_status status = AE_OK; + struct acpi_processor *pr = NULL; ACPI_FUNCTION_TRACE("acpi_processor_remove"); if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); - pr = (struct acpi_processor *) acpi_driver_data(device); + pr = (struct acpi_processor *)acpi_driver_data(device); if (pr->id >= NR_CPUS) { kfree(pr); @@ -696,10 +667,10 @@ acpi_processor_remove ( acpi_processor_power_exit(pr, device); status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, - acpi_processor_notify); + acpi_processor_notify); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); + "Error removing notify handler\n")); } acpi_processor_remove_fs(device); @@ -718,33 +689,28 @@ acpi_processor_remove ( static int is_processor_present(acpi_handle handle); -static int -is_processor_present( - acpi_handle handle) +static int is_processor_present(acpi_handle handle) { - acpi_status status; - unsigned long sta = 0; + acpi_status status; + unsigned long sta = 0; ACPI_FUNCTION_TRACE("is_processor_present"); status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Processor Device is not present\n")); + "Processor Device is not present\n")); return_VALUE(0); } return_VALUE(1); } - static -int acpi_processor_device_add( - acpi_handle handle, - struct acpi_device **device) +int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device) { - acpi_handle phandle; - struct acpi_device *pdev; - struct acpi_processor *pr; + acpi_handle phandle; + struct acpi_device *pdev; + struct acpi_processor *pr; ACPI_FUNCTION_TRACE("acpi_processor_device_add"); @@ -766,21 +732,17 @@ int acpi_processor_device_add( if (!pr) return_VALUE(-ENODEV); - if ((pr->id >=0) && (pr->id < NR_CPUS)) { + if ((pr->id >= 0) && (pr->id < NR_CPUS)) { kobject_hotplug(&(*device)->kobj, KOBJ_ONLINE); } return_VALUE(0); } - static void -acpi_processor_hotplug_notify ( - acpi_handle handle, - u32 event, - void *data) +acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_processor *pr; - struct acpi_device *device = NULL; + struct acpi_processor *pr; + struct acpi_device *device = NULL; int result; ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify"); @@ -789,8 +751,8 @@ acpi_processor_hotplug_notify ( case ACPI_NOTIFY_BUS_CHECK: case ACPI_NOTIFY_DEVICE_CHECK: printk("Processor driver received %s event\n", - (event==ACPI_NOTIFY_BUS_CHECK)? - "ACPI_NOTIFY_BUS_CHECK":"ACPI_NOTIFY_DEVICE_CHECK"); + (event == ACPI_NOTIFY_BUS_CHECK) ? + "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"); if (!is_processor_present(handle)) break; @@ -799,14 +761,14 @@ acpi_processor_hotplug_notify ( result = acpi_processor_device_add(handle, &device); if (result) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to add the device\n")); + "Unable to add the device\n")); break; } pr = acpi_driver_data(device); if (!pr) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Driver data is NULL\n")); + "Driver data is NULL\n")); break; } @@ -816,24 +778,27 @@ acpi_processor_hotplug_notify ( } result = acpi_processor_start(device); - if ((!result) && ((pr->id >=0) && (pr->id < NR_CPUS))) { + if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) { kobject_hotplug(&device->kobj, KOBJ_ONLINE); } else { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Device [%s] failed to start\n", - acpi_device_bid(device))); + "Device [%s] failed to start\n", + acpi_device_bid(device))); } - break; + break; case ACPI_NOTIFY_EJECT_REQUEST: - ACPI_DEBUG_PRINT((ACPI_DB_INFO,"received ACPI_NOTIFY_EJECT_REQUEST\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "received ACPI_NOTIFY_EJECT_REQUEST\n")); if (acpi_bus_get_device(handle, &device)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Device don't exist, dropping EJECT\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Device don't exist, dropping EJECT\n")); break; } pr = acpi_driver_data(device); if (!pr) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Driver data is NULL, dropping EJECT\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Driver data is NULL, dropping EJECT\n")); return_VOID; } @@ -842,7 +807,7 @@ acpi_processor_hotplug_notify ( break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Unsupported event [0x%x]\n", event)); + "Unsupported event [0x%x]\n", event)); break; } @@ -851,45 +816,39 @@ acpi_processor_hotplug_notify ( static acpi_status processor_walk_namespace_cb(acpi_handle handle, - u32 lvl, - void *context, - void **rv) + u32 lvl, void *context, void **rv) { - acpi_status status; + acpi_status status; int *action = context; - acpi_object_type type = 0; + acpi_object_type type = 0; status = acpi_get_type(handle, &type); if (ACPI_FAILURE(status)) - return(AE_OK); + return (AE_OK); if (type != ACPI_TYPE_PROCESSOR) - return(AE_OK); + return (AE_OK); - switch(*action) { + switch (*action) { case INSTALL_NOTIFY_HANDLER: acpi_install_notify_handler(handle, - ACPI_SYSTEM_NOTIFY, - acpi_processor_hotplug_notify, - NULL); + ACPI_SYSTEM_NOTIFY, + acpi_processor_hotplug_notify, + NULL); break; case UNINSTALL_NOTIFY_HANDLER: acpi_remove_notify_handler(handle, - ACPI_SYSTEM_NOTIFY, - acpi_processor_hotplug_notify); + ACPI_SYSTEM_NOTIFY, + acpi_processor_hotplug_notify); break; default: break; } - return(AE_OK); + return (AE_OK); } - -static acpi_status -acpi_processor_hotadd_init( - acpi_handle handle, - int *p_cpu) +static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) { ACPI_FUNCTION_TRACE("acpi_processor_hotadd_init"); @@ -908,57 +867,47 @@ acpi_processor_hotadd_init( return_VALUE(AE_OK); } - -static int -acpi_processor_handle_eject(struct acpi_processor *pr) +static int acpi_processor_handle_eject(struct acpi_processor *pr) { if (cpu_online(pr->id)) { - return(-EINVAL); + return (-EINVAL); } arch_unregister_cpu(pr->id); acpi_unmap_lsapic(pr->id); - return(0); + return (0); } #else -static acpi_status -acpi_processor_hotadd_init( - acpi_handle handle, - int *p_cpu) +static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) { return AE_ERROR; } -static int -acpi_processor_handle_eject(struct acpi_processor *pr) +static int acpi_processor_handle_eject(struct acpi_processor *pr) { - return(-EINVAL); + return (-EINVAL); } #endif - static void acpi_processor_install_hotplug_notify(void) { #ifdef CONFIG_ACPI_HOTPLUG_CPU int action = INSTALL_NOTIFY_HANDLER; acpi_walk_namespace(ACPI_TYPE_PROCESSOR, - ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, - processor_walk_namespace_cb, - &action, NULL); + ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, + processor_walk_namespace_cb, &action, NULL); #endif } - static void acpi_processor_uninstall_hotplug_notify(void) { #ifdef CONFIG_ACPI_HOTPLUG_CPU int action = UNINSTALL_NOTIFY_HANDLER; acpi_walk_namespace(ACPI_TYPE_PROCESSOR, - ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, - processor_walk_namespace_cb, - &action, NULL); + ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, + processor_walk_namespace_cb, &action, NULL); #endif } @@ -968,10 +917,9 @@ void acpi_processor_uninstall_hotplug_notify(void) * ACPI, but needs symbols from this driver */ -static int __init -acpi_processor_init (void) +static int __init acpi_processor_init(void) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_processor_init"); @@ -998,9 +946,7 @@ acpi_processor_init (void) return_VALUE(0); } - -static void __exit -acpi_processor_exit (void) +static void __exit acpi_processor_exit(void) { ACPI_FUNCTION_TRACE("acpi_processor_exit"); @@ -1017,7 +963,6 @@ acpi_processor_exit (void) return_VOID; } - module_init(acpi_processor_init); module_exit(acpi_processor_exit); diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 2c04740..26a3a40 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -48,15 +48,12 @@ #define ACPI_PROCESSOR_CLASS "processor" #define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" #define _COMPONENT ACPI_PROCESSOR_COMPONENT -ACPI_MODULE_NAME ("acpi_processor") - +ACPI_MODULE_NAME("acpi_processor") #define ACPI_PROCESSOR_FILE_POWER "power" - #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) */ - -static void (*pm_idle_save)(void); +static void (*pm_idle_save) (void); module_param(max_cstate, uint, 0644); static unsigned int nocst = 0; @@ -69,7 +66,8 @@ module_param(nocst, uint, 0000); * 100 HZ: 0x0000000F: 4 jiffies = 40ms * reduce history for more aggressive entry into C3 */ -static unsigned int bm_history = (HZ >= 800 ? 0xFFFFFFFF : ((1U << (HZ / 25)) - 1)); +static unsigned int bm_history = + (HZ >= 800 ? 0xFFFFFFFF : ((1U << (HZ / 25)) - 1)); module_param(bm_history, uint, 0644); /* -------------------------------------------------------------------------- Power Management @@ -87,34 +85,36 @@ static int set_max_cstate(struct dmi_system_id *id) return 0; printk(KERN_NOTICE PREFIX "%s detected - limiting to C%ld max_cstate." - " Override with \"processor.max_cstate=%d\"\n", id->ident, - (long)id->driver_data, ACPI_PROCESSOR_MAX_POWER + 1); + " Override with \"processor.max_cstate=%d\"\n", id->ident, + (long)id->driver_data, ACPI_PROCESSOR_MAX_POWER + 1); max_cstate = (long)id->driver_data; return 0; } - static struct dmi_system_id __initdata processor_power_dmi_table[] = { - { set_max_cstate, "IBM ThinkPad R40e", { - DMI_MATCH(DMI_BIOS_VENDOR,"IBM"), - DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW") }, (void*)1}, - { set_max_cstate, "Medion 41700", { - DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"), - DMI_MATCH(DMI_BIOS_VERSION,"R01-A1J") }, (void*)1}, - { set_max_cstate, "Clevo 5600D", { - DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"), - DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307") }, - (void*)2}, + {set_max_cstate, "IBM ThinkPad R40e", { + DMI_MATCH(DMI_BIOS_VENDOR, + "IBM"), + DMI_MATCH(DMI_BIOS_VERSION, + "1SET60WW")}, + (void *)1}, + {set_max_cstate, "Medion 41700", { + DMI_MATCH(DMI_BIOS_VENDOR, + "Phoenix Technologies LTD"), + DMI_MATCH(DMI_BIOS_VERSION, + "R01-A1J")}, (void *)1}, + {set_max_cstate, "Clevo 5600D", { + DMI_MATCH(DMI_BIOS_VENDOR, + "Phoenix Technologies LTD"), + DMI_MATCH(DMI_BIOS_VERSION, + "SHE845M0.86C.0013.D.0302131307")}, + (void *)2}, {}, }; - -static inline u32 -ticks_elapsed ( - u32 t1, - u32 t2) +static inline u32 ticks_elapsed(u32 t1, u32 t2) { if (t2 >= t1) return (t2 - t1); @@ -124,13 +124,11 @@ ticks_elapsed ( return ((0xFFFFFFFF - t1) + t2); } - static void -acpi_processor_power_activate ( - struct acpi_processor *pr, - struct acpi_processor_cx *new) +acpi_processor_power_activate(struct acpi_processor *pr, + struct acpi_processor_cx *new) { - struct acpi_processor_cx *old; + struct acpi_processor_cx *old; if (!pr || !new) return; @@ -139,7 +137,7 @@ acpi_processor_power_activate ( if (old) old->promotion.count = 0; - new->demotion.count = 0; + new->demotion.count = 0; /* Cleanup from old state. */ if (old) { @@ -147,7 +145,8 @@ acpi_processor_power_activate ( case ACPI_STATE_C3: /* Disable bus master reload */ if (new->type != ACPI_STATE_C3 && pr->flags.bm_check) - acpi_set_register(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; } } @@ -157,7 +156,8 @@ acpi_processor_power_activate ( case ACPI_STATE_C3: /* Enable bus master reload */ if (old->type != ACPI_STATE_C3 && pr->flags.bm_check) - acpi_set_register(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; } @@ -166,17 +166,15 @@ acpi_processor_power_activate ( return; } +static atomic_t c3_cpu_count; -static atomic_t c3_cpu_count; - - -static void acpi_processor_idle (void) +static void acpi_processor_idle(void) { - struct acpi_processor *pr = NULL; + struct acpi_processor *pr = NULL; struct acpi_processor_cx *cx = NULL; struct acpi_processor_cx *next_state = NULL; - int sleep_ticks = 0; - u32 t1, t2 = 0; + int sleep_ticks = 0; + u32 t1, t2 = 0; pr = processors[raw_smp_processor_id()]; if (!pr) @@ -208,8 +206,8 @@ static void acpi_processor_idle (void) * for demotion. */ if (pr->flags.bm_check) { - u32 bm_status = 0; - unsigned long diff = jiffies - pr->power.bm_check_timestamp; + u32 bm_status = 0; + unsigned long diff = jiffies - pr->power.bm_check_timestamp; if (diff > 32) diff = 32; @@ -223,11 +221,11 @@ static void acpi_processor_idle (void) } acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, - &bm_status, ACPI_MTX_DO_NOT_LOCK); + &bm_status, ACPI_MTX_DO_NOT_LOCK); if (bm_status) { pr->power.bm_activity++; acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, - 1, ACPI_MTX_DO_NOT_LOCK); + 1, ACPI_MTX_DO_NOT_LOCK); } /* * PIIX4 Erratum #18: Note that BM_STS doesn't always reflect @@ -236,7 +234,7 @@ static void acpi_processor_idle (void) */ else if (errata.piix4.bmisx) { if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01) - || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01)) + || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01)) pr->power.bm_activity++; } @@ -281,7 +279,7 @@ static void acpi_processor_idle (void) else safe_halt(); /* - * TBD: Can't get time duration while in C1, as resumes + * TBD: Can't get time duration while in C1, as resumes * go to an ISR rather than here. Need to instrument * base interrupt handler. */ @@ -300,26 +298,27 @@ static void acpi_processor_idle (void) /* Re-enable interrupts */ local_irq_enable(); /* Compute time (ticks) that we were actually asleep */ - sleep_ticks = ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD; + sleep_ticks = + ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD; break; case ACPI_STATE_C3: - + if (pr->flags.bm_check) { if (atomic_inc_return(&c3_cpu_count) == - num_online_cpus()) { + num_online_cpus()) { /* * All CPUs are trying to go to C3 * Disable bus master arbitration */ acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1, - ACPI_MTX_DO_NOT_LOCK); + ACPI_MTX_DO_NOT_LOCK); } } else { /* SMP with no shared cache... Invalidate cache */ ACPI_FLUSH_CPU_CACHE(); } - + /* Get start time (ticks) */ t1 = inl(acpi_fadt.xpm_tmr_blk.address); /* Invoke C3 */ @@ -331,13 +330,15 @@ static void acpi_processor_idle (void) if (pr->flags.bm_check) { /* Enable bus master arbitration */ atomic_dec(&c3_cpu_count); - acpi_set_register(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 */ local_irq_enable(); /* Compute time (ticks) that we were actually asleep */ - sleep_ticks = ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD; + sleep_ticks = + ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD; break; default: @@ -359,15 +360,18 @@ static void acpi_processor_idle (void) ((cx->promotion.state - pr->power.states) <= max_cstate)) { if (sleep_ticks > cx->promotion.threshold.ticks) { cx->promotion.count++; - cx->demotion.count = 0; - if (cx->promotion.count >= cx->promotion.threshold.count) { + cx->demotion.count = 0; + if (cx->promotion.count >= + cx->promotion.threshold.count) { if (pr->flags.bm_check) { - if (!(pr->power.bm_activity & cx->promotion.threshold.bm)) { - next_state = cx->promotion.state; + if (! + (pr->power.bm_activity & cx-> + promotion.threshold.bm)) { + next_state = + cx->promotion.state; goto end; } - } - else { + } else { next_state = cx->promotion.state; goto end; } @@ -392,7 +396,7 @@ static void acpi_processor_idle (void) } } -end: + end: /* * Demote if current state exceeds max_cstate */ @@ -412,7 +416,7 @@ end: return; - easy_out: + easy_out: /* do C1 instead of busy loop */ if (pm_idle_save) pm_idle_save(); @@ -421,10 +425,7 @@ end: return; } - -static int -acpi_processor_set_power_policy ( - struct acpi_processor *pr) +static int acpi_processor_set_power_policy(struct acpi_processor *pr) { unsigned int i; unsigned int state_is_set = 0; @@ -432,7 +433,7 @@ acpi_processor_set_power_policy ( struct acpi_processor_cx *higher = NULL; struct acpi_processor_cx *cx; - ACPI_FUNCTION_TRACE("acpi_processor_set_power_policy"); + ACPI_FUNCTION_TRACE("acpi_processor_set_power_policy"); if (!pr) return_VALUE(-EINVAL); @@ -447,7 +448,7 @@ acpi_processor_set_power_policy ( */ /* startup state */ - for (i=1; i < ACPI_PROCESSOR_MAX_POWER; i++) { + for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { cx = &pr->power.states[i]; if (!cx->valid) continue; @@ -456,13 +457,13 @@ acpi_processor_set_power_policy ( pr->power.state = cx; state_is_set++; break; - } + } if (!state_is_set) return_VALUE(-ENODEV); /* demotion */ - for (i=1; i < ACPI_PROCESSOR_MAX_POWER; i++) { + for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { cx = &pr->power.states[i]; if (!cx->valid) continue; @@ -485,7 +486,7 @@ acpi_processor_set_power_policy ( continue; if (higher) { - cx->promotion.state = higher; + cx->promotion.state = higher; cx->promotion.threshold.ticks = cx->latency_ticks; if (cx->type >= ACPI_STATE_C2) cx->promotion.threshold.count = 4; @@ -498,11 +499,10 @@ acpi_processor_set_power_policy ( higher = cx; } - return_VALUE(0); + return_VALUE(0); } - -static int acpi_processor_get_power_info_fadt (struct acpi_processor *pr) +static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) { int i; @@ -543,15 +543,14 @@ static int acpi_processor_get_power_info_fadt (struct acpi_processor *pr) return_VALUE(0); } - -static int acpi_processor_get_power_info_default_c1 (struct acpi_processor *pr) +static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr) { int i; ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1"); for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) - memset(&(pr->power.states[i]), 0, + memset(&(pr->power.states[i]), 0, sizeof(struct acpi_processor_cx)); /* if info is obtained from pblk/fadt, type equals state */ @@ -567,14 +566,13 @@ static int acpi_processor_get_power_info_default_c1 (struct acpi_processor *pr) return_VALUE(0); } - -static int acpi_processor_get_power_info_cst (struct acpi_processor *pr) +static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) { - acpi_status status = 0; - acpi_integer count; - int i; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - union acpi_object *cst; + acpi_status status = 0; + acpi_integer count; + int i; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *cst; ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst"); @@ -583,20 +581,21 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr) pr->power.count = 0; for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) - memset(&(pr->power.states[i]), 0, + memset(&(pr->power.states[i]), 0, sizeof(struct acpi_processor_cx)); status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No _CST, giving up\n")); return_VALUE(-ENODEV); - } + } - cst = (union acpi_object *) buffer.pointer; + cst = (union acpi_object *)buffer.pointer; /* There must be at least 2 elements */ if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "not enough elements in _CST\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "not enough elements in _CST\n")); status = -EFAULT; goto end; } @@ -605,15 +604,19 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr) /* Validate number of power states. */ if (count < 1 || count != cst->package.count - 1) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "count given by _CST is not valid\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "count given by _CST is not valid\n")); status = -EFAULT; goto end; } /* We support up to ACPI_PROCESSOR_MAX_POWER. */ if (count > ACPI_PROCESSOR_MAX_POWER) { - printk(KERN_WARNING "Limiting number of power states to max (%d)\n", ACPI_PROCESSOR_MAX_POWER); - printk(KERN_WARNING "Please increase ACPI_PROCESSOR_MAX_POWER if needed.\n"); + printk(KERN_WARNING + "Limiting number of power states to max (%d)\n", + ACPI_PROCESSOR_MAX_POWER); + printk(KERN_WARNING + "Please increase ACPI_PROCESSOR_MAX_POWER if needed.\n"); count = ACPI_PROCESSOR_MAX_POWER; } @@ -628,29 +631,29 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr) memset(&cx, 0, sizeof(cx)); - element = (union acpi_object *) &(cst->package.elements[i]); + element = (union acpi_object *)&(cst->package.elements[i]); if (element->type != ACPI_TYPE_PACKAGE) continue; if (element->package.count != 4) continue; - obj = (union acpi_object *) &(element->package.elements[0]); + obj = (union acpi_object *)&(element->package.elements[0]); if (obj->type != ACPI_TYPE_BUFFER) continue; - reg = (struct acpi_power_register *) obj->buffer.pointer; + reg = (struct acpi_power_register *)obj->buffer.pointer; if (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO && - (reg->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) + (reg->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) continue; cx.address = (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) ? - 0 : reg->address; + 0 : reg->address; /* There should be an easy way to extract an integer... */ - obj = (union acpi_object *) &(element->package.elements[1]); + obj = (union acpi_object *)&(element->package.elements[1]); if (obj->type != ACPI_TYPE_INTEGER) continue; @@ -660,17 +663,16 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr) (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO)) continue; - if ((cx.type < ACPI_STATE_C1) || - (cx.type > ACPI_STATE_C3)) + if ((cx.type < ACPI_STATE_C1) || (cx.type > ACPI_STATE_C3)) continue; - obj = (union acpi_object *) &(element->package.elements[2]); + obj = (union acpi_object *)&(element->package.elements[2]); if (obj->type != ACPI_TYPE_INTEGER) continue; cx.latency = obj->integer.value; - obj = (union acpi_object *) &(element->package.elements[3]); + obj = (union acpi_object *)&(element->package.elements[3]); if (obj->type != ACPI_TYPE_INTEGER) continue; @@ -680,19 +682,19 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr) memcpy(&(pr->power.states[pr->power.count]), &cx, sizeof(cx)); } - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d power states\n", pr->power.count)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d power states\n", + pr->power.count)); /* Validate number of power states discovered */ if (pr->power.count < 2) status = -ENODEV; -end: + end: acpi_os_free(buffer.pointer); return_VALUE(status); } - static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx) { ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c2"); @@ -706,8 +708,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx) */ else if (cx->latency > ACPI_PROCESSOR_MAX_C2_LATENCY) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "latency too large [%d]\n", - cx->latency)); + "latency too large [%d]\n", cx->latency)); return_VOID; } @@ -721,10 +722,8 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx) return_VOID; } - -static void acpi_processor_power_verify_c3( - struct acpi_processor *pr, - struct acpi_processor_cx *cx) +static void acpi_processor_power_verify_c3(struct acpi_processor *pr, + struct acpi_processor_cx *cx) { static int bm_check_flag; @@ -739,8 +738,7 @@ static void acpi_processor_power_verify_c3( */ else if (cx->latency > ACPI_PROCESSOR_MAX_C3_LATENCY) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "latency too large [%d]\n", - cx->latency)); + "latency too large [%d]\n", cx->latency)); return_VOID; } @@ -753,7 +751,7 @@ static void acpi_processor_power_verify_c3( */ else if (errata.piix4.fdma) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "C3 not supported on PIIX4 with Type-F DMA\n")); + "C3 not supported on PIIX4 with Type-F DMA\n")); return_VOID; } @@ -770,7 +768,7 @@ static void acpi_processor_power_verify_c3( /* bus mastering control is necessary */ if (!pr->flags.bm_control) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "C3 support requires bus mastering control\n")); + "C3 support requires bus mastering control\n")); return_VOID; } } else { @@ -780,12 +778,12 @@ static void acpi_processor_power_verify_c3( */ if (acpi_fadt.wb_invd != 1) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Cache invalidation should work properly" - " for C3 to be enabled on SMP systems\n")); + "Cache invalidation should work properly" + " for C3 to be enabled on SMP systems\n")); return_VOID; } acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, - 0, ACPI_MTX_DO_NOT_LOCK); + 0, ACPI_MTX_DO_NOT_LOCK); } /* @@ -800,13 +798,12 @@ static void acpi_processor_power_verify_c3( return_VOID; } - static int acpi_processor_power_verify(struct acpi_processor *pr) { unsigned int i; unsigned int working = 0; - for (i=1; i < ACPI_PROCESSOR_MAX_POWER; i++) { + for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { struct acpi_processor_cx *cx = &pr->power.states[i]; switch (cx->type) { @@ -830,8 +827,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) return (working); } -static int acpi_processor_get_power_info ( - struct acpi_processor *pr) +static int acpi_processor_get_power_info(struct acpi_processor *pr) { unsigned int i; int result; @@ -874,16 +870,16 @@ static int acpi_processor_get_power_info ( return_VALUE(0); } -int acpi_processor_cst_has_changed (struct acpi_processor *pr) +int acpi_processor_cst_has_changed(struct acpi_processor *pr) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_processor_cst_has_changed"); if (!pr) - return_VALUE(-EINVAL); + return_VALUE(-EINVAL); - if ( nocst) { + if (nocst) { return_VALUE(-ENODEV); } @@ -892,7 +888,7 @@ int acpi_processor_cst_has_changed (struct acpi_processor *pr) /* Fall back to the default idle loop */ pm_idle = pm_idle_save; - synchronize_sched(); /* Relies on interrupts forcing exit from idle. */ + synchronize_sched(); /* Relies on interrupts forcing exit from idle. */ pr->flags.power = 0; result = acpi_processor_get_power_info(pr); @@ -906,8 +902,8 @@ int acpi_processor_cst_has_changed (struct acpi_processor *pr) static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) { - struct acpi_processor *pr = (struct acpi_processor *)seq->private; - unsigned int i; + struct acpi_processor *pr = (struct acpi_processor *)seq->private; + unsigned int i; ACPI_FUNCTION_TRACE("acpi_processor_power_seq_show"); @@ -915,17 +911,17 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) goto end; seq_printf(seq, "active state: C%zd\n" - "max_cstate: C%d\n" - "bus master activity: %08x\n", - pr->power.state ? pr->power.state - pr->power.states : 0, - max_cstate, - (unsigned)pr->power.bm_activity); + "max_cstate: C%d\n" + "bus master activity: %08x\n", + pr->power.state ? pr->power.state - pr->power.states : 0, + max_cstate, (unsigned)pr->power.bm_activity); seq_puts(seq, "states:\n"); for (i = 1; i <= pr->power.count; i++) { seq_printf(seq, " %cC%d: ", - (&pr->power.states[i] == pr->power.state?'*':' '), i); + (&pr->power.states[i] == + pr->power.state ? '*' : ' '), i); if (!pr->power.states[i].valid) { seq_puts(seq, "\n"); @@ -949,45 +945,46 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) if (pr->power.states[i].promotion.state) seq_printf(seq, "promotion[C%zd] ", - (pr->power.states[i].promotion.state - - pr->power.states)); + (pr->power.states[i].promotion.state - + pr->power.states)); else seq_puts(seq, "promotion[--] "); if (pr->power.states[i].demotion.state) seq_printf(seq, "demotion[C%zd] ", - (pr->power.states[i].demotion.state - - pr->power.states)); + (pr->power.states[i].demotion.state - + pr->power.states)); else seq_puts(seq, "demotion[--] "); seq_printf(seq, "latency[%03d] usage[%08d]\n", - pr->power.states[i].latency, - pr->power.states[i].usage); + pr->power.states[i].latency, + pr->power.states[i].usage); } -end: + end: return_VALUE(0); } static int acpi_processor_power_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_processor_power_seq_show, - PDE(inode)->data); + PDE(inode)->data); } static struct file_operations acpi_processor_power_fops = { - .open = acpi_processor_power_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_processor_power_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; -int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *device) +int acpi_processor_power_init(struct acpi_processor *pr, + struct acpi_device *device) { - acpi_status status = 0; - static int first_run = 0; - struct proc_dir_entry *entry = NULL; + acpi_status status = 0; + static int first_run = 0; + struct proc_dir_entry *entry = NULL; unsigned int i; ACPI_FUNCTION_TRACE("acpi_processor_power_init"); @@ -995,7 +992,9 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev if (!first_run) { dmi_check_system(processor_power_dmi_table); if (max_cstate < ACPI_C_STATES_MAX) - printk(KERN_NOTICE "ACPI: processor limited to max C-state %d\n", max_cstate); + printk(KERN_NOTICE + "ACPI: processor limited to max C-state %d\n", + max_cstate); first_run++; } @@ -1003,7 +1002,8 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev return_VALUE(-EINVAL); if (acpi_fadt.cst_cnt && !nocst) { - status = acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8); + status = + acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Notifying BIOS of _CST ability failed\n")); @@ -1023,7 +1023,8 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev printk(KERN_INFO PREFIX "CPU%d (power states:", pr->id); for (i = 1; i <= pr->power.count; i++) if (pr->power.states[i].valid) - printk(" C%d[C%d]", i, pr->power.states[i].type); + printk(" C%d[C%d]", i, + pr->power.states[i].type); printk(")\n"); if (pr->id == 0) { @@ -1034,11 +1035,11 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev /* 'power' [R] */ entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER, - S_IRUGO, acpi_device_dir(device)); + S_IRUGO, acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_PROCESSOR_FILE_POWER)); + "Unable to create '%s' fs entry\n", + ACPI_PROCESSOR_FILE_POWER)); else { entry->proc_fops = &acpi_processor_power_fops; entry->data = acpi_driver_data(device); @@ -1050,14 +1051,16 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev return_VALUE(0); } -int acpi_processor_power_exit(struct acpi_processor *pr, struct acpi_device *device) +int acpi_processor_power_exit(struct acpi_processor *pr, + struct acpi_device *device) { ACPI_FUNCTION_TRACE("acpi_processor_power_exit"); pr->flags.power_setup_done = 0; if (acpi_device_dir(device)) - remove_proc_entry(ACPI_PROCESSOR_FILE_POWER,acpi_device_dir(device)); + remove_proc_entry(ACPI_PROCESSOR_FILE_POWER, + acpi_device_dir(device)); /* Unregister the idle handler when processor #0 is removed. */ if (pr->id == 0) { diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 1f0d625..22c7bb6 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c @@ -26,7 +26,6 @@ * */ - #include #include #include @@ -42,14 +41,12 @@ #include #include - #define ACPI_PROCESSOR_COMPONENT 0x01000000 #define ACPI_PROCESSOR_CLASS "processor" #define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" #define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" #define _COMPONENT ACPI_PROCESSOR_COMPONENT -ACPI_MODULE_NAME ("acpi_processor") - +ACPI_MODULE_NAME("acpi_processor") static DECLARE_MUTEX(performance_sem); @@ -69,8 +66,7 @@ static DECLARE_MUTEX(performance_sem); static int acpi_processor_ppc_status = 0; static int acpi_processor_ppc_notifier(struct notifier_block *nb, - unsigned long event, - void *data) + unsigned long event, void *data) { struct cpufreq_policy *policy = data; struct acpi_processor *pr; @@ -85,7 +81,7 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb, if (!pr || !pr->performance) goto out; - ppc = (unsigned int) pr->performance_platform_limit; + ppc = (unsigned int)pr->performance_platform_limit; if (!ppc) goto out; @@ -93,26 +89,23 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb, goto out; cpufreq_verify_within_limits(policy, 0, - pr->performance->states[ppc].core_frequency * 1000); + pr->performance->states[ppc]. + core_frequency * 1000); - out: + out: up(&performance_sem); return 0; } - static struct notifier_block acpi_ppc_notifier_block = { .notifier_call = acpi_processor_ppc_notifier, }; - -static int -acpi_processor_get_platform_limit ( - struct acpi_processor* pr) +static int acpi_processor_get_platform_limit(struct acpi_processor *pr) { - acpi_status status = 0; - unsigned long ppc = 0; + acpi_status status = 0; + unsigned long ppc = 0; ACPI_FUNCTION_TRACE("acpi_processor_get_platform_limit"); @@ -128,19 +121,17 @@ acpi_processor_get_platform_limit ( if (status != AE_NOT_FOUND) acpi_processor_ppc_status |= PPC_IN_USE; - if(ACPI_FAILURE(status) && status != AE_NOT_FOUND) { + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PPC\n")); return_VALUE(-ENODEV); } - pr->performance_platform_limit = (int) ppc; + pr->performance_platform_limit = (int)ppc; return_VALUE(0); } - -int acpi_processor_ppc_has_changed( - struct acpi_processor *pr) +int acpi_processor_ppc_has_changed(struct acpi_processor *pr) { int ret = acpi_processor_get_platform_limit(pr); if (ret < 0) @@ -149,44 +140,44 @@ int acpi_processor_ppc_has_changed( return cpufreq_update_policy(pr->id); } - -void acpi_processor_ppc_init(void) { - if (!cpufreq_register_notifier(&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER)) +void acpi_processor_ppc_init(void) +{ + if (!cpufreq_register_notifier + (&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER)) acpi_processor_ppc_status |= PPC_REGISTERED; else - printk(KERN_DEBUG "Warning: Processor Platform Limit not supported.\n"); + printk(KERN_DEBUG + "Warning: Processor Platform Limit not supported.\n"); } - -void acpi_processor_ppc_exit(void) { +void acpi_processor_ppc_exit(void) +{ if (acpi_processor_ppc_status & PPC_REGISTERED) - cpufreq_unregister_notifier(&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER); + cpufreq_unregister_notifier(&acpi_ppc_notifier_block, + CPUFREQ_POLICY_NOTIFIER); acpi_processor_ppc_status &= ~PPC_REGISTERED; } - -static int -acpi_processor_get_performance_control ( - struct acpi_processor *pr) +static int acpi_processor_get_performance_control(struct acpi_processor *pr) { - int result = 0; - acpi_status status = 0; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - union acpi_object *pct = NULL; - union acpi_object obj = {0}; + int result = 0; + acpi_status status = 0; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *pct = NULL; + union acpi_object obj = { 0 }; ACPI_FUNCTION_TRACE("acpi_processor_get_performance_control"); status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer); - if(ACPI_FAILURE(status)) { + if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PCT\n")); return_VALUE(-ENODEV); } - pct = (union acpi_object *) buffer.pointer; + pct = (union acpi_object *)buffer.pointer; if (!pct || (pct->type != ACPI_TYPE_PACKAGE) - || (pct->package.count != 2)) { + || (pct->package.count != 2)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PCT data\n")); result = -EFAULT; goto end; @@ -199,15 +190,15 @@ acpi_processor_get_performance_control ( obj = pct->package.elements[0]; if ((obj.type != ACPI_TYPE_BUFFER) - || (obj.buffer.length < sizeof(struct acpi_pct_register)) - || (obj.buffer.pointer == NULL)) { + || (obj.buffer.length < sizeof(struct acpi_pct_register)) + || (obj.buffer.pointer == NULL)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid _PCT data (control_register)\n")); + "Invalid _PCT data (control_register)\n")); result = -EFAULT; goto end; } - memcpy(&pr->performance->control_register, obj.buffer.pointer, sizeof(struct acpi_pct_register)); - + memcpy(&pr->performance->control_register, obj.buffer.pointer, + sizeof(struct acpi_pct_register)); /* * status_register @@ -216,44 +207,42 @@ acpi_processor_get_performance_control ( obj = pct->package.elements[1]; if ((obj.type != ACPI_TYPE_BUFFER) - || (obj.buffer.length < sizeof(struct acpi_pct_register)) - || (obj.buffer.pointer == NULL)) { + || (obj.buffer.length < sizeof(struct acpi_pct_register)) + || (obj.buffer.pointer == NULL)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid _PCT data (status_register)\n")); + "Invalid _PCT data (status_register)\n")); result = -EFAULT; goto end; } - memcpy(&pr->performance->status_register, obj.buffer.pointer, sizeof(struct acpi_pct_register)); + memcpy(&pr->performance->status_register, obj.buffer.pointer, + sizeof(struct acpi_pct_register)); -end: + end: acpi_os_free(buffer.pointer); return_VALUE(result); } - -static int -acpi_processor_get_performance_states ( - struct acpi_processor *pr) +static int acpi_processor_get_performance_states(struct acpi_processor *pr) { - int result = 0; - acpi_status status = AE_OK; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - struct acpi_buffer format = {sizeof("NNNNNN"), "NNNNNN"}; - struct acpi_buffer state = {0, NULL}; - union acpi_object *pss = NULL; - int i; + int result = 0; + acpi_status status = AE_OK; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_buffer format = { sizeof("NNNNNN"), "NNNNNN" }; + struct acpi_buffer state = { 0, NULL }; + union acpi_object *pss = NULL; + int i; ACPI_FUNCTION_TRACE("acpi_processor_get_performance_states"); status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer); - if(ACPI_FAILURE(status)) { + if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PSS\n")); return_VALUE(-ENODEV); } - pss = (union acpi_object *) buffer.pointer; + pss = (union acpi_object *)buffer.pointer; if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n")); result = -EFAULT; @@ -261,10 +250,12 @@ acpi_processor_get_performance_states ( } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d performance states\n", - pss->package.count)); + pss->package.count)); pr->performance->state_count = pss->package.count; - pr->performance->states = kmalloc(sizeof(struct acpi_processor_px) * pss->package.count, GFP_KERNEL); + pr->performance->states = + kmalloc(sizeof(struct acpi_processor_px) * pss->package.count, + GFP_KERNEL); if (!pr->performance->states) { result = -ENOMEM; goto end; @@ -280,46 +271,44 @@ acpi_processor_get_performance_states ( ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i)); status = acpi_extract_package(&(pss->package.elements[i]), - &format, &state); + &format, &state); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid _PSS data\n")); result = -EFAULT; kfree(pr->performance->states); goto end; } ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n", - i, - (u32) px->core_frequency, - (u32) px->power, - (u32) px->transition_latency, - (u32) px->bus_master_latency, - (u32) px->control, - (u32) px->status)); + "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n", + i, + (u32) px->core_frequency, + (u32) px->power, + (u32) px->transition_latency, + (u32) px->bus_master_latency, + (u32) px->control, (u32) px->status)); if (!px->core_frequency) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data: freq is zero\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid _PSS data: freq is zero\n")); result = -EFAULT; kfree(pr->performance->states); goto end; } } -end: + end: acpi_os_free(buffer.pointer); return_VALUE(result); } - -static int -acpi_processor_get_performance_info ( - struct acpi_processor *pr) +static int acpi_processor_get_performance_info(struct acpi_processor *pr) { - int result = 0; - acpi_status status = AE_OK; - acpi_handle handle = NULL; + int result = 0; + acpi_status status = AE_OK; + acpi_handle handle = NULL; ACPI_FUNCTION_TRACE("acpi_processor_get_performance_info"); @@ -331,7 +320,7 @@ acpi_processor_get_performance_info ( status = acpi_get_handle(pr->handle, "_PCT", &handle); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "ACPI-based processor performance control unavailable\n")); + "ACPI-based processor performance control unavailable\n")); return_VALUE(-ENODEV); } @@ -350,10 +339,10 @@ acpi_processor_get_performance_info ( return_VALUE(0); } - -int acpi_processor_notify_smm(struct module *calling_module) { - acpi_status status; - static int is_done = 0; +int acpi_processor_notify_smm(struct module *calling_module) +{ + acpi_status status; + static int is_done = 0; ACPI_FUNCTION_TRACE("acpi_processor_notify_smm"); @@ -371,8 +360,7 @@ int acpi_processor_notify_smm(struct module *calling_module) { if (is_done > 0) { module_put(calling_module); return_VALUE(0); - } - else if (is_done < 0) { + } else if (is_done < 0) { module_put(calling_module); return_VALUE(is_done); } @@ -380,28 +368,30 @@ int acpi_processor_notify_smm(struct module *calling_module) { is_done = -EIO; /* Can't write pstate_cnt to smi_cmd if either value is zero */ - if ((!acpi_fadt.smi_cmd) || - (!acpi_fadt.pstate_cnt)) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "No SMI port or pstate_cnt\n")); + if ((!acpi_fadt.smi_cmd) || (!acpi_fadt.pstate_cnt)) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_cnt\n")); module_put(calling_module); return_VALUE(0); } - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Writing pstate_cnt [0x%x] to smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, acpi_fadt.smi_cmd)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Writing pstate_cnt [0x%x] to smi_cmd [0x%x]\n", + acpi_fadt.pstate_cnt, acpi_fadt.smi_cmd)); /* FADT v1 doesn't support pstate_cnt, many BIOS vendors use * it anyway, so we need to support it... */ if (acpi_fadt_is_v1) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Using v1.0 FADT reserved value for pstate_cnt\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Using v1.0 FADT reserved value for pstate_cnt\n")); } - status = acpi_os_write_port (acpi_fadt.smi_cmd, - (u32) acpi_fadt.pstate_cnt, 8); - if (ACPI_FAILURE (status)) { + status = acpi_os_write_port(acpi_fadt.smi_cmd, + (u32) acpi_fadt.pstate_cnt, 8); + if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Failed to write pstate_cnt [0x%x] to " - "smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, acpi_fadt.smi_cmd)); + "smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, + acpi_fadt.smi_cmd)); module_put(calling_module); return_VALUE(status); } @@ -415,24 +405,24 @@ int acpi_processor_notify_smm(struct module *calling_module) { return_VALUE(0); } -EXPORT_SYMBOL(acpi_processor_notify_smm); +EXPORT_SYMBOL(acpi_processor_notify_smm); #ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF /* /proc/acpi/processor/../performance interface (DEPRECATED) */ static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_processor_perf_fops = { - .open = acpi_processor_perf_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_processor_perf_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset) { - struct acpi_processor *pr = (struct acpi_processor *)seq->private; - int i; + struct acpi_processor *pr = (struct acpi_processor *)seq->private; + int i; ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show"); @@ -445,42 +435,40 @@ static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset) } seq_printf(seq, "state count: %d\n" - "active state: P%d\n", - pr->performance->state_count, - pr->performance->state); + "active state: P%d\n", + pr->performance->state_count, pr->performance->state); seq_puts(seq, "states:\n"); for (i = 0; i < pr->performance->state_count; i++) - seq_printf(seq, " %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, - (u32) pr->performance->states[i].transition_latency); - -end: + seq_printf(seq, + " %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, + (u32) pr->performance->states[i].transition_latency); + + end: return_VALUE(0); } static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_processor_perf_seq_show, - PDE(inode)->data); + PDE(inode)->data); } static ssize_t -acpi_processor_write_performance ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *data) +acpi_processor_write_performance(struct file *file, + const char __user * buffer, + size_t count, loff_t * data) { - int result = 0; - struct seq_file *m = (struct seq_file *) file->private_data; - struct acpi_processor *pr = (struct acpi_processor *) m->private; + int result = 0; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_processor *pr = (struct acpi_processor *)m->private; struct acpi_processor_performance *perf; - char state_string[12] = {'\0'}; - unsigned int new_state = 0; - struct cpufreq_policy policy; + char state_string[12] = { '\0' }; + unsigned int new_state = 0; + struct cpufreq_policy policy; ACPI_FUNCTION_TRACE("acpi_processor_write_performance"); @@ -513,12 +501,10 @@ acpi_processor_write_performance ( return_VALUE(count); } -static void -acpi_cpufreq_add_file ( - struct acpi_processor *pr) +static void acpi_cpufreq_add_file(struct acpi_processor *pr) { - struct proc_dir_entry *entry = NULL; - struct acpi_device *device = NULL; + struct proc_dir_entry *entry = NULL; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile"); @@ -527,11 +513,12 @@ acpi_cpufreq_add_file ( /* add file 'performance' [R/W] */ entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, - S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_PROCESSOR_FILE_PERFORMANCE)); + "Unable to create '%s' fs entry\n", + ACPI_PROCESSOR_FILE_PERFORMANCE)); else { entry->proc_fops = &acpi_processor_perf_fops; entry->proc_fops->write = acpi_processor_write_performance; @@ -541,11 +528,9 @@ acpi_cpufreq_add_file ( return_VOID; } -static void -acpi_cpufreq_remove_file ( - struct acpi_processor *pr) +static void acpi_cpufreq_remove_file(struct acpi_processor *pr) { - struct acpi_device *device = NULL; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile"); @@ -554,21 +539,25 @@ acpi_cpufreq_remove_file ( /* remove file 'performance' */ remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, - acpi_device_dir(device)); + acpi_device_dir(device)); return_VOID; } #else -static void acpi_cpufreq_add_file (struct acpi_processor *pr) { return; } -static void acpi_cpufreq_remove_file (struct acpi_processor *pr) { return; } -#endif /* CONFIG_X86_ACPI_CPUFREQ_PROC_INTF */ - +static void acpi_cpufreq_add_file(struct acpi_processor *pr) +{ + return; +} +static void acpi_cpufreq_remove_file(struct acpi_processor *pr) +{ + return; +} +#endif /* CONFIG_X86_ACPI_CPUFREQ_PROC_INTF */ int -acpi_processor_register_performance ( - struct acpi_processor_performance * performance, - unsigned int cpu) +acpi_processor_register_performance(struct acpi_processor_performance + *performance, unsigned int cpu) { struct acpi_processor *pr; @@ -603,13 +592,12 @@ acpi_processor_register_performance ( up(&performance_sem); return_VALUE(0); } -EXPORT_SYMBOL(acpi_processor_register_performance); +EXPORT_SYMBOL(acpi_processor_register_performance); void -acpi_processor_unregister_performance ( - struct acpi_processor_performance * performance, - unsigned int cpu) +acpi_processor_unregister_performance(struct acpi_processor_performance + *performance, unsigned int cpu) { struct acpi_processor *pr; @@ -632,4 +620,5 @@ acpi_processor_unregister_performance ( return_VOID; } + EXPORT_SYMBOL(acpi_processor_unregister_performance); diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index 12bd980..37528c3 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c @@ -43,20 +43,16 @@ #define ACPI_PROCESSOR_CLASS "processor" #define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" #define _COMPONENT ACPI_PROCESSOR_COMPONENT -ACPI_MODULE_NAME ("acpi_processor") - +ACPI_MODULE_NAME("acpi_processor") /* -------------------------------------------------------------------------- Limit Interface -------------------------------------------------------------------------- */ - -static int -acpi_processor_apply_limit ( - struct acpi_processor* pr) +static int acpi_processor_apply_limit(struct acpi_processor *pr) { - int result = 0; - u16 px = 0; - u16 tx = 0; + int result = 0; + u16 px = 0; + u16 tx = 0; ACPI_FUNCTION_TRACE("acpi_processor_apply_limit"); @@ -80,19 +76,17 @@ acpi_processor_apply_limit ( pr->limit.state.px = px; pr->limit.state.tx = tx; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d] limit set to (P%d:T%d)\n", - pr->id, - pr->limit.state.px, - pr->limit.state.tx)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Processor [%d] limit set to (P%d:T%d)\n", pr->id, + pr->limit.state.px, pr->limit.state.tx)); -end: + end: if (result) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n")); return_VALUE(result); } - #ifdef CONFIG_CPU_FREQ /* If a passive cooling situation is detected, primarily CPUfreq is used, as it @@ -104,7 +98,6 @@ end: static unsigned int cpufreq_thermal_reduction_pctg[NR_CPUS]; static unsigned int acpi_thermal_cpufreq_is_init = 0; - static int cpu_has_cpufreq(unsigned int cpu) { struct cpufreq_policy policy; @@ -115,7 +108,6 @@ static int cpu_has_cpufreq(unsigned int cpu) return 0; } - static int acpi_thermal_cpufreq_increase(unsigned int cpu) { if (!cpu_has_cpufreq(cpu)) @@ -130,7 +122,6 @@ static int acpi_thermal_cpufreq_increase(unsigned int cpu) return -ERANGE; } - static int acpi_thermal_cpufreq_decrease(unsigned int cpu) { if (!cpu_has_cpufreq(cpu)) @@ -145,11 +136,8 @@ static int acpi_thermal_cpufreq_decrease(unsigned int cpu) return -ERANGE; } - -static int acpi_thermal_cpufreq_notifier( - struct notifier_block *nb, - unsigned long event, - void *data) +static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb, + unsigned long event, void *data) { struct cpufreq_policy *policy = data; unsigned long max_freq = 0; @@ -157,68 +145,74 @@ static int acpi_thermal_cpufreq_notifier( if (event != CPUFREQ_ADJUST) goto out; - max_freq = (policy->cpuinfo.max_freq * (100 - cpufreq_thermal_reduction_pctg[policy->cpu])) / 100; + max_freq = + (policy->cpuinfo.max_freq * + (100 - cpufreq_thermal_reduction_pctg[policy->cpu])) / 100; cpufreq_verify_within_limits(policy, 0, max_freq); - out: + out: return 0; } - static struct notifier_block acpi_thermal_cpufreq_notifier_block = { .notifier_call = acpi_thermal_cpufreq_notifier, }; - -void acpi_thermal_cpufreq_init(void) { +void acpi_thermal_cpufreq_init(void) +{ int i; - for (i=0; i ACPI_PROCESSOR_LIMIT_DECREMENT)) + || (type > ACPI_PROCESSOR_LIMIT_DECREMENT)) return_VALUE(-EINVAL); result = acpi_bus_get_device(handle, &device); if (result) return_VALUE(result); - pr = (struct acpi_processor *) acpi_driver_data(device); + pr = (struct acpi_processor *)acpi_driver_data(device); if (!pr) return_VALUE(-ENODEV); @@ -250,12 +244,12 @@ acpi_processor_set_thermal_limit ( goto end; else if (result == -ERANGE) ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "At maximum performance state\n")); + "At maximum performance state\n")); if (pr->flags.throttling) { if (tx == (pr->throttling.state_count - 1)) ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "At maximum throttling state\n")); + "At maximum throttling state\n")); else tx++; } @@ -267,7 +261,7 @@ acpi_processor_set_thermal_limit ( if (pr->flags.throttling) { if (tx == 0) ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "At minimum throttling state\n")); + "At minimum throttling state\n")); else { tx--; goto end; @@ -277,12 +271,12 @@ acpi_processor_set_thermal_limit ( result = acpi_thermal_cpufreq_decrease(pr->id); if (result == -ERANGE) ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "At minimum performance state\n")); + "At minimum performance state\n")); break; } -end: + end: if (pr->flags.throttling) { pr->limit.thermal.px = 0; pr->limit.thermal.tx = tx; @@ -293,18 +287,14 @@ end: "Unable to set thermal limit\n")); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n", - pr->limit.thermal.px, - pr->limit.thermal.tx)); + pr->limit.thermal.px, pr->limit.thermal.tx)); } else result = 0; return_VALUE(result); } - -int -acpi_processor_get_limit_info ( - struct acpi_processor *pr) +int acpi_processor_get_limit_info(struct acpi_processor *pr) { ACPI_FUNCTION_TRACE("acpi_processor_get_limit_info"); @@ -317,12 +307,11 @@ acpi_processor_get_limit_info ( return_VALUE(0); } - /* /proc interface */ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset) { - struct acpi_processor *pr = (struct acpi_processor *)seq->private; + struct acpi_processor *pr = (struct acpi_processor *)seq->private; ACPI_FUNCTION_TRACE("acpi_processor_limit_seq_show"); @@ -335,34 +324,32 @@ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset) } seq_printf(seq, "active limit: P%d:T%d\n" - "user limit: P%d:T%d\n" - "thermal limit: P%d:T%d\n", - pr->limit.state.px, pr->limit.state.tx, - pr->limit.user.px, pr->limit.user.tx, - pr->limit.thermal.px, pr->limit.thermal.tx); + "user limit: P%d:T%d\n" + "thermal limit: P%d:T%d\n", + pr->limit.state.px, pr->limit.state.tx, + pr->limit.user.px, pr->limit.user.tx, + pr->limit.thermal.px, pr->limit.thermal.tx); -end: + end: return_VALUE(0); } static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_processor_limit_seq_show, - PDE(inode)->data); + PDE(inode)->data); } -ssize_t acpi_processor_write_limit ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *data) +ssize_t acpi_processor_write_limit(struct file * file, + const char __user * buffer, + size_t count, loff_t * data) { - int result = 0; - struct seq_file *m = (struct seq_file *)file->private_data; - struct acpi_processor *pr = (struct acpi_processor *)m->private; - char limit_string[25] = {'\0'}; - int px = 0; - int tx = 0; + int result = 0; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_processor *pr = (struct acpi_processor *)m->private; + char limit_string[25] = { '\0' }; + int px = 0; + int tx = 0; ACPI_FUNCTION_TRACE("acpi_processor_write_limit"); @@ -396,11 +383,9 @@ ssize_t acpi_processor_write_limit ( return_VALUE(count); } - struct file_operations acpi_processor_limit_fops = { - .open = acpi_processor_limit_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_processor_limit_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; - diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index be9f569..74a52d4 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -43,21 +43,17 @@ #define ACPI_PROCESSOR_CLASS "processor" #define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" #define _COMPONENT ACPI_PROCESSOR_COMPONENT -ACPI_MODULE_NAME ("acpi_processor") - +ACPI_MODULE_NAME("acpi_processor") /* -------------------------------------------------------------------------- Throttling Control -------------------------------------------------------------------------- */ - -static int -acpi_processor_get_throttling ( - struct acpi_processor *pr) +static int acpi_processor_get_throttling(struct acpi_processor *pr) { - int state = 0; - u32 value = 0; - u32 duty_mask = 0; - u32 duty_value = 0; + int state = 0; + u32 value = 0; + u32 duty_mask = 0; + u32 duty_value = 0; ACPI_FUNCTION_TRACE("acpi_processor_get_throttling"); @@ -86,7 +82,7 @@ acpi_processor_get_throttling ( duty_value >>= pr->throttling.duty_offset; if (duty_value) - state = pr->throttling.state_count-duty_value; + state = pr->throttling.state_count - duty_value; } pr->throttling.state = state; @@ -94,20 +90,17 @@ acpi_processor_get_throttling ( local_irq_enable(); ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Throttling state is T%d (%d%% throttling applied)\n", - state, pr->throttling.states[state].performance)); + "Throttling state is T%d (%d%% throttling applied)\n", + state, pr->throttling.states[state].performance)); return_VALUE(0); } - -int acpi_processor_set_throttling ( - struct acpi_processor *pr, - int state) +int acpi_processor_set_throttling(struct acpi_processor *pr, int state) { - u32 value = 0; - u32 duty_mask = 0; - u32 duty_value = 0; + u32 value = 0; + u32 duty_mask = 0; + u32 duty_value = 0; ACPI_FUNCTION_TRACE("acpi_processor_set_throttling"); @@ -168,28 +161,26 @@ int acpi_processor_set_throttling ( local_irq_enable(); ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Throttling state set to T%d (%d%%)\n", state, - (pr->throttling.states[state].performance?pr->throttling.states[state].performance/10:0))); + "Throttling state set to T%d (%d%%)\n", state, + (pr->throttling.states[state].performance ? pr-> + throttling.states[state].performance / 10 : 0))); return_VALUE(0); } - -int -acpi_processor_get_throttling_info ( - struct acpi_processor *pr) +int acpi_processor_get_throttling_info(struct acpi_processor *pr) { - int result = 0; - int step = 0; - int i = 0; + int result = 0; + int step = 0; + int i = 0; ACPI_FUNCTION_TRACE("acpi_processor_get_throttling_info"); ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", - pr->throttling.address, - pr->throttling.duty_offset, - pr->throttling.duty_width)); + "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", + pr->throttling.address, + pr->throttling.duty_offset, + pr->throttling.duty_width)); if (!pr) return_VALUE(-EINVAL); @@ -199,14 +190,12 @@ acpi_processor_get_throttling_info ( if (!pr->throttling.address) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); return_VALUE(0); - } - else if (!pr->throttling.duty_width) { + } else if (!pr->throttling.duty_width) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); return_VALUE(0); } /* TBD: Support duty_cycle values that span bit 4. */ - else if ((pr->throttling.duty_offset - + pr->throttling.duty_width) > 4) { + else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) { ACPI_DEBUG_PRINT((ACPI_DB_WARN, "duty_cycle spans bit 4\n")); return_VALUE(0); } @@ -218,7 +207,7 @@ acpi_processor_get_throttling_info ( */ if (errata.piix4.throttle) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Throttling not supported on PIIX4 A- or B-step\n")); + "Throttling not supported on PIIX4 A- or B-step\n")); return_VALUE(0); } @@ -232,13 +221,13 @@ acpi_processor_get_throttling_info ( step = (1000 / pr->throttling.state_count); - for (i=0; ithrottling.state_count; i++) { + for (i = 0; i < pr->throttling.state_count; i++) { pr->throttling.states[i].performance = step * i; pr->throttling.states[i].power = step * i; } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n", - pr->throttling.state_count)); + pr->throttling.state_count)); pr->flags.throttling = 1; @@ -253,28 +242,29 @@ acpi_processor_get_throttling_info ( goto end; if (pr->throttling.state) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabling throttling (was T%d)\n", - 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 (result) goto end; } -end: + end: if (result) pr->flags.throttling = 0; return_VALUE(result); } - /* proc interface */ -static int acpi_processor_throttling_seq_show(struct seq_file *seq, void *offset) +static int acpi_processor_throttling_seq_show(struct seq_file *seq, + void *offset) { - struct acpi_processor *pr = (struct acpi_processor *)seq->private; - int i = 0; - int result = 0; + struct acpi_processor *pr = (struct acpi_processor *)seq->private; + int i = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_processor_throttling_seq_show"); @@ -289,41 +279,41 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq, void *offset result = acpi_processor_get_throttling(pr); if (result) { - seq_puts(seq, "Could not determine current throttling state.\n"); + seq_puts(seq, + "Could not determine current throttling state.\n"); goto end; } seq_printf(seq, "state count: %d\n" - "active state: T%d\n", - pr->throttling.state_count, - pr->throttling.state); + "active state: T%d\n", + pr->throttling.state_count, pr->throttling.state); seq_puts(seq, "states:\n"); for (i = 0; i < pr->throttling.state_count; i++) seq_printf(seq, " %cT%d: %02d%%\n", - (i == pr->throttling.state?'*':' '), i, - (pr->throttling.states[i].performance?pr->throttling.states[i].performance/10:0)); + (i == pr->throttling.state ? '*' : ' '), i, + (pr->throttling.states[i].performance ? pr-> + throttling.states[i].performance / 10 : 0)); -end: + end: return_VALUE(0); } -static int acpi_processor_throttling_open_fs(struct inode *inode, struct file *file) +static int acpi_processor_throttling_open_fs(struct inode *inode, + struct file *file) { return single_open(file, acpi_processor_throttling_seq_show, - PDE(inode)->data); + PDE(inode)->data); } -ssize_t acpi_processor_write_throttling ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *data) +ssize_t acpi_processor_write_throttling(struct file * file, + const char __user * buffer, + size_t count, loff_t * data) { - int result = 0; - struct seq_file *m = (struct seq_file *)file->private_data; - struct acpi_processor *pr = (struct acpi_processor *)m->private; - char state_string[12] = {'\0'}; + int result = 0; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_processor *pr = (struct acpi_processor *)m->private; + char state_string[12] = { '\0' }; ACPI_FUNCTION_TRACE("acpi_processor_write_throttling"); @@ -336,7 +326,8 @@ ssize_t acpi_processor_write_throttling ( state_string[count] = '\0'; result = acpi_processor_set_throttling(pr, - simple_strtoul(state_string, NULL, 0)); + simple_strtoul(state_string, + NULL, 0)); if (result) return_VALUE(result); @@ -344,8 +335,8 @@ ssize_t acpi_processor_write_throttling ( } struct file_operations acpi_processor_throttling_fops = { - .open = acpi_processor_throttling_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_processor_throttling_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c index 55d2647..4cf46e1 100644 --- a/drivers/acpi/resources/rsaddr.c +++ b/drivers/acpi/resources/rsaddr.c @@ -41,13 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #define _COMPONENT ACPI_RESOURCES - ACPI_MODULE_NAME ("rsaddr") - +ACPI_MODULE_NAME("rsaddr") /******************************************************************************* * @@ -69,36 +67,31 @@ * number of bytes consumed from the byte stream. * ******************************************************************************/ - acpi_status -acpi_rs_address16_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_address16_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - u32 index; - u16 temp16; - u8 temp8; - u8 *temp_ptr; - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( - struct acpi_resource_address16); - - - ACPI_FUNCTION_TRACE ("rs_address16_resource"); + u32 index; + u16 temp16; + u8 temp8; + u8 *temp_ptr; + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + acpi_size struct_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16); + ACPI_FUNCTION_TRACE("rs_address16_resource"); /* Point past the Descriptor to get the number of bytes consumed */ buffer += 1; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); /* Validate minimum descriptor length */ if (temp16 < 13) { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); } *bytes_consumed = temp16 + 3; @@ -112,7 +105,7 @@ acpi_rs_address16_resource ( /* Values 0-2 and 0xC0-0xFF are valid */ if ((temp8 > 2) && (temp8 < 0xC0)) { - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); } output_struct->data.address16.resource_type = temp8; @@ -144,19 +137,18 @@ acpi_rs_address16_resource ( temp8 = *buffer; if (ACPI_MEMORY_RANGE == output_struct->data.address16.resource_type) { - output_struct->data.address16.attribute.memory.read_write_attribute = - (u16) (temp8 & 0x01); + output_struct->data.address16.attribute.memory. + read_write_attribute = (u16) (temp8 & 0x01); output_struct->data.address16.attribute.memory.cache_attribute = - (u16) ((temp8 >> 1) & 0x03); - } - else { - if (ACPI_IO_RANGE == output_struct->data.address16.resource_type) { - output_struct->data.address16.attribute.io.range_attribute = - (u16) (temp8 & 0x03); - output_struct->data.address16.attribute.io.translation_attribute = - (u16) ((temp8 >> 4) & 0x03); - } - else { + (u16) ((temp8 >> 1) & 0x03); + } else { + if (ACPI_IO_RANGE == + output_struct->data.address16.resource_type) { + output_struct->data.address16.attribute.io. + range_attribute = (u16) (temp8 & 0x03); + output_struct->data.address16.attribute.io. + translation_attribute = (u16) ((temp8 >> 4) & 0x03); + } else { /* BUS_NUMBER_RANGE == Address16.Data->resource_type */ /* Nothing needs to be filled in */ } @@ -165,28 +157,31 @@ acpi_rs_address16_resource ( /* Get Granularity (Bytes 6-7) */ buffer += 1; - ACPI_MOVE_16_TO_32 (&output_struct->data.address16.granularity, buffer); + ACPI_MOVE_16_TO_32(&output_struct->data.address16.granularity, buffer); /* Get min_address_range (Bytes 8-9) */ buffer += 2; - ACPI_MOVE_16_TO_32 (&output_struct->data.address16.min_address_range, buffer); + ACPI_MOVE_16_TO_32(&output_struct->data.address16.min_address_range, + buffer); /* Get max_address_range (Bytes 10-11) */ buffer += 2; - ACPI_MOVE_16_TO_32 (&output_struct->data.address16.max_address_range, buffer); + ACPI_MOVE_16_TO_32(&output_struct->data.address16.max_address_range, + buffer); /* Get address_translation_offset (Bytes 12-13) */ buffer += 2; - ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_translation_offset, - buffer); + ACPI_MOVE_16_TO_32(&output_struct->data.address16. + address_translation_offset, buffer); /* Get address_length (Bytes 14-15) */ buffer += 2; - ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_length, buffer); + ACPI_MOVE_16_TO_32(&output_struct->data.address16.address_length, + buffer); /* Resource Source Index (if present) */ @@ -206,7 +201,8 @@ acpi_rs_address16_resource ( /* Dereference the Index */ temp8 = *buffer; - output_struct->data.address16.resource_source.index = (u32) temp8; + output_struct->data.address16.resource_source.index = + (u32) temp8; /* Point to the String */ @@ -215,10 +211,10 @@ acpi_rs_address16_resource ( /* Point the String pointer to the end of this structure */ output_struct->data.address16.resource_source.string_ptr = - (char *)((u8 * )output_struct + struct_size); + (char *)((u8 *) output_struct + struct_size); temp_ptr = (u8 *) - output_struct->data.address16.resource_source.string_ptr; + output_struct->data.address16.resource_source.string_ptr; /* Copy the string into the buffer */ @@ -236,7 +232,8 @@ acpi_rs_address16_resource ( *temp_ptr = 0x00; - output_struct->data.address16.resource_source.string_length = index + 1; + output_struct->data.address16.resource_source.string_length = + index + 1; /* * In order for the struct_size to fall on a 32-bit boundary, @@ -244,9 +241,8 @@ acpi_rs_address16_resource ( * struct_size to the next 32-bit boundary. */ temp8 = (u8) (index + 1); - struct_size += ACPI_ROUND_UP_to_32_bITS (temp8); - } - else { + struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); + } else { output_struct->data.address16.resource_source.index = 0x00; output_struct->data.address16.resource_source.string_length = 0; output_struct->data.address16.resource_source.string_ptr = NULL; @@ -259,10 +255,9 @@ acpi_rs_address16_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_address16_stream @@ -280,20 +275,16 @@ acpi_rs_address16_resource ( ******************************************************************************/ acpi_status -acpi_rs_address16_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_address16_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - u8 *length_field; - u8 temp8; - char *temp_pointer = NULL; - acpi_size actual_bytes; - - - ACPI_FUNCTION_TRACE ("rs_address16_stream"); + u8 *buffer = *output_buffer; + u8 *length_field; + u8 temp8; + char *temp_pointer = NULL; + acpi_size actual_bytes; + ACPI_FUNCTION_TRACE("rs_address16_stream"); /* The descriptor field is static */ @@ -328,20 +319,19 @@ acpi_rs_address16_stream ( if (ACPI_MEMORY_RANGE == linked_list->data.address16.resource_type) { temp8 = (u8) - (linked_list->data.address16.attribute.memory.read_write_attribute & - 0x01); + (linked_list->data.address16.attribute.memory. + read_write_attribute & 0x01); temp8 |= - (linked_list->data.address16.attribute.memory.cache_attribute & - 0x03) << 1; - } - else if (ACPI_IO_RANGE == linked_list->data.address16.resource_type) { + (linked_list->data.address16.attribute.memory. + cache_attribute & 0x03) << 1; + } else if (ACPI_IO_RANGE == linked_list->data.address16.resource_type) { temp8 = (u8) - (linked_list->data.address16.attribute.io.range_attribute & - 0x03); + (linked_list->data.address16.attribute.io.range_attribute & + 0x03); temp8 |= - (linked_list->data.address16.attribute.io.translation_attribute & - 0x03) << 4; + (linked_list->data.address16.attribute.io. + translation_attribute & 0x03) << 4; } *buffer = temp8; @@ -349,28 +339,31 @@ acpi_rs_address16_stream ( /* Set the address space granularity */ - ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.granularity); + ACPI_MOVE_32_TO_16(buffer, &linked_list->data.address16.granularity); buffer += 2; /* Set the address range minimum */ - ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.min_address_range); + ACPI_MOVE_32_TO_16(buffer, + &linked_list->data.address16.min_address_range); buffer += 2; /* Set the address range maximum */ - ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.max_address_range); + ACPI_MOVE_32_TO_16(buffer, + &linked_list->data.address16.max_address_range); buffer += 2; /* Set the address translation offset */ - ACPI_MOVE_32_TO_16 (buffer, - &linked_list->data.address16.address_translation_offset); + ACPI_MOVE_32_TO_16(buffer, + &linked_list->data.address16. + address_translation_offset); buffer += 2; /* Set the address length */ - ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_length); + ACPI_MOVE_32_TO_16(buffer, &linked_list->data.address16.address_length); buffer += 2; /* Resource Source Index and Resource Source are optional */ @@ -381,24 +374,27 @@ acpi_rs_address16_stream ( *buffer = temp8; buffer += 1; - temp_pointer = (char *) buffer; + temp_pointer = (char *)buffer; /* Copy the string */ - ACPI_STRCPY (temp_pointer, - linked_list->data.address16.resource_source.string_ptr); + ACPI_STRCPY(temp_pointer, + linked_list->data.address16.resource_source. + string_ptr); /* * Buffer needs to be set to the length of the sting + one for the * terminating null */ - buffer += (acpi_size)(ACPI_STRLEN ( - linked_list->data.address16.resource_source.string_ptr) + 1); + buffer += + (acpi_size) (ACPI_STRLEN + (linked_list->data.address16.resource_source. + string_ptr) + 1); } /* Return the number of bytes consumed in this operation */ - actual_bytes = ACPI_PTR_DIFF (buffer, *output_buffer); + actual_bytes = ACPI_PTR_DIFF(buffer, *output_buffer); *bytes_consumed = actual_bytes; /* @@ -406,11 +402,10 @@ acpi_rs_address16_stream ( * minus the header size (3 bytes) */ actual_bytes -= 3; - ACPI_MOVE_SIZE_TO_16 (length_field, &actual_bytes); - return_ACPI_STATUS (AE_OK); + ACPI_MOVE_SIZE_TO_16(length_field, &actual_bytes); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_address32_resource @@ -433,36 +428,32 @@ acpi_rs_address16_stream ( ******************************************************************************/ acpi_status -acpi_rs_address32_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_address32_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer; - struct acpi_resource *output_struct= (void *) *output_buffer; - u16 temp16; - u8 temp8; - u8 *temp_ptr; - acpi_size struct_size; - u32 index; - - - ACPI_FUNCTION_TRACE ("rs_address32_resource"); + u8 *buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + u16 temp16; + u8 temp8; + u8 *temp_ptr; + acpi_size struct_size; + u32 index; + ACPI_FUNCTION_TRACE("rs_address32_resource"); buffer = byte_stream_buffer; - struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32); + struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32); /* Point past the Descriptor to get the number of bytes consumed */ buffer += 1; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); /* Validate minimum descriptor length */ if (temp16 < 23) { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); } *bytes_consumed = temp16 + 3; @@ -476,7 +467,7 @@ acpi_rs_address32_resource ( /* Values 0-2 and 0xC0-0xFF are valid */ if ((temp8 > 2) && (temp8 < 0xC0)) { - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); } output_struct->data.address32.resource_type = temp8; @@ -508,20 +499,19 @@ acpi_rs_address32_resource ( temp8 = *buffer; if (ACPI_MEMORY_RANGE == output_struct->data.address32.resource_type) { - output_struct->data.address32.attribute.memory.read_write_attribute = - (u16) (temp8 & 0x01); + output_struct->data.address32.attribute.memory. + read_write_attribute = (u16) (temp8 & 0x01); output_struct->data.address32.attribute.memory.cache_attribute = - (u16) ((temp8 >> 1) & 0x03); - } - else { - if (ACPI_IO_RANGE == output_struct->data.address32.resource_type) { - output_struct->data.address32.attribute.io.range_attribute = - (u16) (temp8 & 0x03); - output_struct->data.address32.attribute.io.translation_attribute = - (u16) ((temp8 >> 4) & 0x03); - } - else { + (u16) ((temp8 >> 1) & 0x03); + } else { + if (ACPI_IO_RANGE == + output_struct->data.address32.resource_type) { + output_struct->data.address32.attribute.io. + range_attribute = (u16) (temp8 & 0x03); + output_struct->data.address32.attribute.io. + translation_attribute = (u16) ((temp8 >> 4) & 0x03); + } else { /* BUS_NUMBER_RANGE == output_struct->Data.Address32.resource_type */ /* Nothing needs to be filled in */ } @@ -530,28 +520,31 @@ acpi_rs_address32_resource ( /* Get Granularity (Bytes 6-9) */ buffer += 1; - ACPI_MOVE_32_TO_32 (&output_struct->data.address32.granularity, buffer); + ACPI_MOVE_32_TO_32(&output_struct->data.address32.granularity, buffer); /* Get min_address_range (Bytes 10-13) */ buffer += 4; - ACPI_MOVE_32_TO_32 (&output_struct->data.address32.min_address_range, buffer); + ACPI_MOVE_32_TO_32(&output_struct->data.address32.min_address_range, + buffer); /* Get max_address_range (Bytes 14-17) */ buffer += 4; - ACPI_MOVE_32_TO_32 (&output_struct->data.address32.max_address_range, buffer); + ACPI_MOVE_32_TO_32(&output_struct->data.address32.max_address_range, + buffer); /* Get address_translation_offset (Bytes 18-21) */ buffer += 4; - ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_translation_offset, - buffer); + ACPI_MOVE_32_TO_32(&output_struct->data.address32. + address_translation_offset, buffer); /* Get address_length (Bytes 22-25) */ buffer += 4; - ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_length, buffer); + ACPI_MOVE_32_TO_32(&output_struct->data.address32.address_length, + buffer); /* Resource Source Index (if present) */ @@ -570,7 +563,7 @@ acpi_rs_address32_resource ( temp8 = *buffer; output_struct->data.address32.resource_source.index = - (u32) temp8; + (u32) temp8; /* Point to the String */ @@ -579,10 +572,10 @@ acpi_rs_address32_resource ( /* Point the String pointer to the end of this structure */ output_struct->data.address32.resource_source.string_ptr = - (char *)((u8 *)output_struct + struct_size); + (char *)((u8 *) output_struct + struct_size); temp_ptr = (u8 *) - output_struct->data.address32.resource_source.string_ptr; + output_struct->data.address32.resource_source.string_ptr; /* Copy the string into the buffer */ @@ -598,7 +591,8 @@ acpi_rs_address32_resource ( /* Add the terminating null */ *temp_ptr = 0x00; - output_struct->data.address32.resource_source.string_length = index + 1; + output_struct->data.address32.resource_source.string_length = + index + 1; /* * In order for the struct_size to fall on a 32-bit boundary, @@ -606,9 +600,8 @@ acpi_rs_address32_resource ( * struct_size to the next 32-bit boundary. */ temp8 = (u8) (index + 1); - struct_size += ACPI_ROUND_UP_to_32_bITS (temp8); - } - else { + struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); + } else { output_struct->data.address32.resource_source.index = 0x00; output_struct->data.address32.resource_source.string_length = 0; output_struct->data.address32.resource_source.string_ptr = NULL; @@ -621,10 +614,9 @@ acpi_rs_address32_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_address32_stream @@ -642,19 +634,15 @@ acpi_rs_address32_resource ( ******************************************************************************/ acpi_status -acpi_rs_address32_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_address32_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer; - u16 *length_field; - u8 temp8; - char *temp_pointer; - - - ACPI_FUNCTION_TRACE ("rs_address32_stream"); + u8 *buffer; + u16 *length_field; + u8 temp8; + char *temp_pointer; + ACPI_FUNCTION_TRACE("rs_address32_stream"); buffer = *output_buffer; @@ -665,7 +653,7 @@ acpi_rs_address32_stream ( /* Set a pointer to the Length field - to be filled in later */ - length_field = ACPI_CAST_PTR (u16, buffer); + length_field = ACPI_CAST_PTR(u16, buffer); buffer += 2; /* Set the Resource Type (Memory, Io, bus_number) */ @@ -691,20 +679,19 @@ acpi_rs_address32_stream ( if (ACPI_MEMORY_RANGE == linked_list->data.address32.resource_type) { temp8 = (u8) - (linked_list->data.address32.attribute.memory.read_write_attribute & - 0x01); + (linked_list->data.address32.attribute.memory. + read_write_attribute & 0x01); temp8 |= - (linked_list->data.address32.attribute.memory.cache_attribute & - 0x03) << 1; - } - else if (ACPI_IO_RANGE == linked_list->data.address32.resource_type) { + (linked_list->data.address32.attribute.memory. + cache_attribute & 0x03) << 1; + } else if (ACPI_IO_RANGE == linked_list->data.address32.resource_type) { temp8 = (u8) - (linked_list->data.address32.attribute.io.range_attribute & - 0x03); + (linked_list->data.address32.attribute.io.range_attribute & + 0x03); temp8 |= - (linked_list->data.address32.attribute.io.translation_attribute & - 0x03) << 4; + (linked_list->data.address32.attribute.io. + translation_attribute & 0x03) << 4; } *buffer = temp8; @@ -712,28 +699,31 @@ acpi_rs_address32_stream ( /* Set the address space granularity */ - ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.granularity); + ACPI_MOVE_32_TO_32(buffer, &linked_list->data.address32.granularity); buffer += 4; /* Set the address range minimum */ - ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.min_address_range); + ACPI_MOVE_32_TO_32(buffer, + &linked_list->data.address32.min_address_range); buffer += 4; /* Set the address range maximum */ - ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.max_address_range); + ACPI_MOVE_32_TO_32(buffer, + &linked_list->data.address32.max_address_range); buffer += 4; /* Set the address translation offset */ - ACPI_MOVE_32_TO_32 (buffer, - &linked_list->data.address32.address_translation_offset); + ACPI_MOVE_32_TO_32(buffer, + &linked_list->data.address32. + address_translation_offset); buffer += 4; /* Set the address length */ - ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_length); + ACPI_MOVE_32_TO_32(buffer, &linked_list->data.address32.address_length); buffer += 4; /* Resource Source Index and Resource Source are optional */ @@ -744,34 +734,36 @@ acpi_rs_address32_stream ( *buffer = temp8; buffer += 1; - temp_pointer = (char *) buffer; + temp_pointer = (char *)buffer; /* Copy the string */ - ACPI_STRCPY (temp_pointer, - linked_list->data.address32.resource_source.string_ptr); + ACPI_STRCPY(temp_pointer, + linked_list->data.address32.resource_source. + string_ptr); /* * Buffer needs to be set to the length of the sting + one for the * terminating null */ - buffer += (acpi_size)(ACPI_STRLEN ( - linked_list->data.address32.resource_source.string_ptr) + 1); + buffer += + (acpi_size) (ACPI_STRLEN + (linked_list->data.address32.resource_source. + string_ptr) + 1); } /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); /* * Set the length field to the number of bytes consumed * minus the header size (3 bytes) */ *length_field = (u16) (*bytes_consumed - 3); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_address64_resource @@ -794,38 +786,34 @@ acpi_rs_address32_stream ( ******************************************************************************/ acpi_status -acpi_rs_address64_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_address64_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - u16 temp16; - u8 temp8; - u8 resource_type; - u8 *temp_ptr; - acpi_size struct_size; - u32 index; - - - ACPI_FUNCTION_TRACE ("rs_address64_resource"); + u8 *buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + u16 temp16; + u8 temp8; + u8 resource_type; + u8 *temp_ptr; + acpi_size struct_size; + u32 index; + ACPI_FUNCTION_TRACE("rs_address64_resource"); buffer = byte_stream_buffer; - struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64); + struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64); resource_type = *buffer; /* Point past the Descriptor to get the number of bytes consumed */ buffer += 1; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); /* Validate minimum descriptor length */ if (temp16 < 43) { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); } *bytes_consumed = temp16 + 3; @@ -839,7 +827,7 @@ acpi_rs_address64_resource ( /* Values 0-2 and 0xC0-0xFF are valid */ if ((temp8 > 2) && (temp8 < 0xC0)) { - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); } output_struct->data.address64.resource_type = temp8; @@ -871,20 +859,19 @@ acpi_rs_address64_resource ( temp8 = *buffer; if (ACPI_MEMORY_RANGE == output_struct->data.address64.resource_type) { - output_struct->data.address64.attribute.memory.read_write_attribute = - (u16) (temp8 & 0x01); + output_struct->data.address64.attribute.memory. + read_write_attribute = (u16) (temp8 & 0x01); output_struct->data.address64.attribute.memory.cache_attribute = - (u16) ((temp8 >> 1) & 0x03); - } - else { - if (ACPI_IO_RANGE == output_struct->data.address64.resource_type) { - output_struct->data.address64.attribute.io.range_attribute = - (u16) (temp8 & 0x03); - output_struct->data.address64.attribute.io.translation_attribute = - (u16) ((temp8 >> 4) & 0x03); - } - else { + (u16) ((temp8 >> 1) & 0x03); + } else { + if (ACPI_IO_RANGE == + output_struct->data.address64.resource_type) { + output_struct->data.address64.attribute.io. + range_attribute = (u16) (temp8 & 0x03); + output_struct->data.address64.attribute.io. + translation_attribute = (u16) ((temp8 >> 4) & 0x03); + } else { /* BUS_NUMBER_RANGE == output_struct->Data.Address64.resource_type */ /* Nothing needs to be filled in */ } @@ -899,28 +886,31 @@ acpi_rs_address64_resource ( /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */ buffer += 1; - ACPI_MOVE_64_TO_64 (&output_struct->data.address64.granularity, buffer); + ACPI_MOVE_64_TO_64(&output_struct->data.address64.granularity, buffer); /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */ buffer += 8; - ACPI_MOVE_64_TO_64 (&output_struct->data.address64.min_address_range, buffer); + ACPI_MOVE_64_TO_64(&output_struct->data.address64.min_address_range, + buffer); /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */ buffer += 8; - ACPI_MOVE_64_TO_64 (&output_struct->data.address64.max_address_range, buffer); + ACPI_MOVE_64_TO_64(&output_struct->data.address64.max_address_range, + buffer); /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */ buffer += 8; - ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_translation_offset, - buffer); + ACPI_MOVE_64_TO_64(&output_struct->data.address64. + address_translation_offset, buffer); /* Get address_length (Bytes 38-45) or (Bytes 40-47) */ buffer += 8; - ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_length, buffer); + ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length, + buffer); output_struct->data.address64.resource_source.index = 0x00; output_struct->data.address64.resource_source.string_length = 0; @@ -930,11 +920,9 @@ acpi_rs_address64_resource ( /* Get type_specific_attribute (Bytes 48-55) */ buffer += 8; - ACPI_MOVE_64_TO_64 ( - &output_struct->data.address64.type_specific_attributes, - buffer); - } - else { + ACPI_MOVE_64_TO_64(&output_struct->data.address64. + type_specific_attributes, buffer); + } else { output_struct->data.address64.type_specific_attributes = 0; /* Resource Source Index (if present) */ @@ -956,7 +944,7 @@ acpi_rs_address64_resource ( temp8 = *buffer; output_struct->data.address64.resource_source.index = - (u32) temp8; + (u32) temp8; /* Point to the String */ @@ -964,11 +952,13 @@ acpi_rs_address64_resource ( /* Point the String pointer to the end of this structure */ - output_struct->data.address64.resource_source.string_ptr = - (char *)((u8 *)output_struct + struct_size); + output_struct->data.address64.resource_source. + string_ptr = + (char *)((u8 *) output_struct + struct_size); temp_ptr = (u8 *) - output_struct->data.address64.resource_source.string_ptr; + output_struct->data.address64.resource_source. + string_ptr; /* Copy the string into the buffer */ @@ -985,8 +975,8 @@ acpi_rs_address64_resource ( * Add the terminating null */ *temp_ptr = 0x00; - output_struct->data.address64.resource_source.string_length = - index + 1; + output_struct->data.address64.resource_source. + string_length = index + 1; /* * In order for the struct_size to fall on a 32-bit boundary, @@ -994,7 +984,7 @@ acpi_rs_address64_resource ( * struct_size to the next 32-bit boundary. */ temp8 = (u8) (index + 1); - struct_size += ACPI_ROUND_UP_to_32_bITS (temp8); + struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); } } @@ -1005,10 +995,9 @@ acpi_rs_address64_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_address64_stream @@ -1026,19 +1015,15 @@ acpi_rs_address64_resource ( ******************************************************************************/ acpi_status -acpi_rs_address64_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_address64_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer; - u16 *length_field; - u8 temp8; - char *temp_pointer; - - - ACPI_FUNCTION_TRACE ("rs_address64_stream"); + u8 *buffer; + u16 *length_field; + u8 temp8; + char *temp_pointer; + ACPI_FUNCTION_TRACE("rs_address64_stream"); buffer = *output_buffer; @@ -1049,7 +1034,7 @@ acpi_rs_address64_stream ( /* Set a pointer to the Length field - to be filled in later */ - length_field = ACPI_CAST_PTR (u16, buffer); + length_field = ACPI_CAST_PTR(u16, buffer); buffer += 2; /* Set the Resource Type (Memory, Io, bus_number) */ @@ -1075,20 +1060,19 @@ acpi_rs_address64_stream ( if (ACPI_MEMORY_RANGE == linked_list->data.address64.resource_type) { temp8 = (u8) - (linked_list->data.address64.attribute.memory.read_write_attribute & - 0x01); + (linked_list->data.address64.attribute.memory. + read_write_attribute & 0x01); temp8 |= - (linked_list->data.address64.attribute.memory.cache_attribute & - 0x03) << 1; - } - else if (ACPI_IO_RANGE == linked_list->data.address64.resource_type) { + (linked_list->data.address64.attribute.memory. + cache_attribute & 0x03) << 1; + } else if (ACPI_IO_RANGE == linked_list->data.address64.resource_type) { temp8 = (u8) - (linked_list->data.address64.attribute.io.range_attribute & - 0x03); + (linked_list->data.address64.attribute.io.range_attribute & + 0x03); temp8 |= - (linked_list->data.address64.attribute.io.range_attribute & - 0x03) << 4; + (linked_list->data.address64.attribute.io.range_attribute & + 0x03) << 4; } *buffer = temp8; @@ -1096,28 +1080,31 @@ acpi_rs_address64_stream ( /* Set the address space granularity */ - ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.granularity); + ACPI_MOVE_64_TO_64(buffer, &linked_list->data.address64.granularity); buffer += 8; /* Set the address range minimum */ - ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.min_address_range); + ACPI_MOVE_64_TO_64(buffer, + &linked_list->data.address64.min_address_range); buffer += 8; /* Set the address range maximum */ - ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.max_address_range); + ACPI_MOVE_64_TO_64(buffer, + &linked_list->data.address64.max_address_range); buffer += 8; /* Set the address translation offset */ - ACPI_MOVE_64_TO_64 (buffer, - &linked_list->data.address64.address_translation_offset); + ACPI_MOVE_64_TO_64(buffer, + &linked_list->data.address64. + address_translation_offset); buffer += 8; /* Set the address length */ - ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_length); + ACPI_MOVE_64_TO_64(buffer, &linked_list->data.address64.address_length); buffer += 8; /* Resource Source Index and Resource Source are optional */ @@ -1128,30 +1115,32 @@ acpi_rs_address64_stream ( *buffer = temp8; buffer += 1; - temp_pointer = (char *) buffer; + temp_pointer = (char *)buffer; /* Copy the string */ - ACPI_STRCPY (temp_pointer, - linked_list->data.address64.resource_source.string_ptr); + ACPI_STRCPY(temp_pointer, + linked_list->data.address64.resource_source. + string_ptr); /* * Buffer needs to be set to the length of the sting + one for the * terminating null */ - buffer += (acpi_size)(ACPI_STRLEN ( - linked_list->data.address64.resource_source.string_ptr) + 1); + buffer += + (acpi_size) (ACPI_STRLEN + (linked_list->data.address64.resource_source. + string_ptr) + 1); } /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); /* * Set the length field to the number of bytes consumed * minus the header size (3 bytes) */ *length_field = (u16) (*bytes_consumed - 3); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index 98176f2..378f583 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c @@ -41,15 +41,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include #define _COMPONENT ACPI_RESOURCES - ACPI_MODULE_NAME ("rscalc") - +ACPI_MODULE_NAME("rscalc") /******************************************************************************* * @@ -66,19 +64,15 @@ * the resource data. * ******************************************************************************/ - acpi_status -acpi_rs_get_byte_stream_length ( - struct acpi_resource *linked_list, - acpi_size *size_needed) +acpi_rs_get_byte_stream_length(struct acpi_resource *linked_list, + acpi_size * size_needed) { - acpi_size byte_stream_size_needed = 0; - acpi_size segment_size; - u8 done = FALSE; - - - ACPI_FUNCTION_TRACE ("rs_get_byte_stream_length"); + acpi_size byte_stream_size_needed = 0; + acpi_size segment_size; + u8 done = FALSE; + ACPI_FUNCTION_TRACE("rs_get_byte_stream_length"); while (!done) { /* Init the variable that will hold the size to add to the total. */ @@ -145,11 +139,11 @@ acpi_rs_get_byte_stream_length ( */ if (linked_list->data.vendor_specific.length > 7) { segment_size = 3; - } - else { + } else { segment_size = 1; } - segment_size += linked_list->data.vendor_specific.length; + segment_size += + linked_list->data.vendor_specific.length; break; case ACPI_RSTYPE_END_TAG: @@ -194,9 +188,11 @@ acpi_rs_get_byte_stream_length ( */ segment_size = 16; - if (linked_list->data.address16.resource_source.string_ptr) { + if (linked_list->data.address16.resource_source. + string_ptr) { segment_size += - linked_list->data.address16.resource_source.string_length; + linked_list->data.address16.resource_source. + string_length; segment_size++; } break; @@ -211,9 +207,11 @@ acpi_rs_get_byte_stream_length ( */ segment_size = 26; - if (linked_list->data.address32.resource_source.string_ptr) { + if (linked_list->data.address32.resource_source. + string_ptr) { segment_size += - linked_list->data.address32.resource_source.string_length; + linked_list->data.address32.resource_source. + string_length; segment_size++; } break; @@ -227,9 +225,11 @@ acpi_rs_get_byte_stream_length ( */ segment_size = 46; - if (linked_list->data.address64.resource_source.string_ptr) { + if (linked_list->data.address64.resource_source. + string_ptr) { segment_size += - linked_list->data.address64.resource_source.string_length; + linked_list->data.address64.resource_source. + string_length; segment_size++; } break; @@ -244,11 +244,14 @@ acpi_rs_get_byte_stream_length ( * Resource Source + 1 for the null. */ segment_size = 9 + (((acpi_size) - linked_list->data.extended_irq.number_of_interrupts - 1) * 4); + linked_list->data.extended_irq. + number_of_interrupts - 1) * 4); - if (linked_list->data.extended_irq.resource_source.string_ptr) { + if (linked_list->data.extended_irq.resource_source. + string_ptr) { segment_size += - linked_list->data.extended_irq.resource_source.string_length; + linked_list->data.extended_irq. + resource_source.string_length; segment_size++; } break; @@ -257,9 +260,9 @@ acpi_rs_get_byte_stream_length ( /* If we get here, everything is out of sync, exit with error */ - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); - } /* switch (linked_list->Id) */ + } /* switch (linked_list->Id) */ /* Update the total */ @@ -267,17 +270,16 @@ acpi_rs_get_byte_stream_length ( /* Point to the next object */ - linked_list = ACPI_PTR_ADD (struct acpi_resource, - linked_list, linked_list->length); + linked_list = ACPI_PTR_ADD(struct acpi_resource, + linked_list, linked_list->length); } /* This is the data the caller needs */ *size_needed = byte_stream_size_needed; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_get_list_length @@ -297,32 +299,28 @@ acpi_rs_get_byte_stream_length ( ******************************************************************************/ acpi_status -acpi_rs_get_list_length ( - u8 *byte_stream_buffer, - u32 byte_stream_buffer_length, - acpi_size *size_needed) +acpi_rs_get_list_length(u8 * byte_stream_buffer, + u32 byte_stream_buffer_length, acpi_size * size_needed) { - u32 buffer_size = 0; - u32 bytes_parsed = 0; - u8 number_of_interrupts = 0; - u8 number_of_channels = 0; - u8 resource_type; - u32 structure_size; - u32 bytes_consumed; - u8 *buffer; - u8 temp8; - u16 temp16; - u8 index; - u8 additional_bytes; - - - ACPI_FUNCTION_TRACE ("rs_get_list_length"); - + u32 buffer_size = 0; + u32 bytes_parsed = 0; + u8 number_of_interrupts = 0; + u8 number_of_channels = 0; + u8 resource_type; + u32 structure_size; + u32 bytes_consumed; + u8 *buffer; + u8 temp8; + u16 temp16; + u8 index; + u8 additional_bytes; + + ACPI_FUNCTION_TRACE("rs_get_list_length"); while (bytes_parsed < byte_stream_buffer_length) { /* The next byte in the stream is the resource type */ - resource_type = acpi_rs_get_resource_type (*byte_stream_buffer); + resource_type = acpi_rs_get_resource_type(*byte_stream_buffer); switch (resource_type) { case ACPI_RDESC_TYPE_MEMORY_24: @@ -331,10 +329,10 @@ acpi_rs_get_list_length ( */ bytes_consumed = 12; - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem24); + structure_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24); break; - case ACPI_RDESC_TYPE_LARGE_VENDOR: /* * Vendor Defined Resource @@ -342,38 +340,39 @@ acpi_rs_get_list_length ( buffer = byte_stream_buffer; ++buffer; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); bytes_consumed = temp16 + 3; /* Ensure a 32-bit boundary for the structure */ - temp16 = (u16) ACPI_ROUND_UP_to_32_bITS (temp16); + temp16 = (u16) ACPI_ROUND_UP_to_32_bITS(temp16); - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) + - (temp16 * sizeof (u8)); + structure_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) + + (temp16 * sizeof(u8)); break; - case ACPI_RDESC_TYPE_MEMORY_32: /* * 32-Bit Memory Range Resource */ bytes_consumed = 20; - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem32); + structure_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32); break; - case ACPI_RDESC_TYPE_FIXED_MEMORY_32: /* * 32-Bit Fixed Memory Resource */ bytes_consumed = 12; - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_mem32); + structure_size = + ACPI_SIZEOF_RESOURCE(struct + acpi_resource_fixed_mem32); break; - case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE: /* * 64-Bit Address Resource @@ -381,13 +380,14 @@ acpi_rs_get_list_length ( buffer = byte_stream_buffer; ++buffer; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); bytes_consumed = temp16 + 3; - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64); + structure_size = + ACPI_SIZEOF_RESOURCE(struct + acpi_resource_address64); break; - case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: /* * 64-Bit Address Resource @@ -395,7 +395,7 @@ acpi_rs_get_list_length ( buffer = byte_stream_buffer; ++buffer; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); bytes_consumed = temp16 + 3; @@ -409,20 +409,19 @@ acpi_rs_get_list_length ( */ if (43 < temp16) { temp8 = (u8) (temp16 - 44); - } - else { + } else { temp8 = 0; } /* Ensure a 64-bit boundary for the structure */ - temp8 = (u8) ACPI_ROUND_UP_to_64_bITS (temp8); + temp8 = (u8) ACPI_ROUND_UP_to_64_bITS(temp8); - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64) + - (temp8 * sizeof (u8)); + structure_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64) + + (temp8 * sizeof(u8)); break; - case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: /* * 32-Bit Address Resource @@ -430,7 +429,7 @@ acpi_rs_get_list_length ( buffer = byte_stream_buffer; ++buffer; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); bytes_consumed = temp16 + 3; @@ -444,20 +443,19 @@ acpi_rs_get_list_length ( */ if (23 < temp16) { temp8 = (u8) (temp16 - 24); - } - else { + } else { temp8 = 0; } /* Ensure a 32-bit boundary for the structure */ - temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); + temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8); - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32) + - (temp8 * sizeof (u8)); + structure_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32) + + (temp8 * sizeof(u8)); break; - case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: /* * 16-Bit Address Resource @@ -465,7 +463,7 @@ acpi_rs_get_list_length ( buffer = byte_stream_buffer; ++buffer; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); bytes_consumed = temp16 + 3; @@ -479,20 +477,19 @@ acpi_rs_get_list_length ( */ if (13 < temp16) { temp8 = (u8) (temp16 - 14); - } - else { + } else { temp8 = 0; } /* Ensure a 32-bit boundary for the structure */ - temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); + temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8); - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address16) + - (temp8 * sizeof (u8)); + structure_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16) + + (temp8 * sizeof(u8)); break; - case ACPI_RDESC_TYPE_EXTENDED_XRUPT: /* * Extended IRQ @@ -500,7 +497,7 @@ acpi_rs_get_list_length ( buffer = byte_stream_buffer; ++buffer; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); bytes_consumed = temp16 + 3; @@ -527,21 +524,20 @@ acpi_rs_get_list_length ( */ if (9 + additional_bytes < temp16) { temp8 = (u8) (temp16 - (9 + additional_bytes)); - } - else { + } else { temp8 = 0; } /* Ensure a 32-bit boundary for the structure */ - temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); + temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8); - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_ext_irq) + - (additional_bytes * sizeof (u8)) + - (temp8 * sizeof (u8)); + structure_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq) + + (additional_bytes * sizeof(u8)) + + (temp8 * sizeof(u8)); break; - case ACPI_RDESC_TYPE_IRQ_FORMAT: /* * IRQ Resource. @@ -550,10 +546,9 @@ acpi_rs_get_list_length ( buffer = byte_stream_buffer; temp8 = *buffer; - if(temp8 & 0x01) { + if (temp8 & 0x01) { bytes_consumed = 4; - } - else { + } else { bytes_consumed = 3; } @@ -563,7 +558,7 @@ acpi_rs_get_list_length ( /* Look at the number of bits set */ - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); for (index = 0; index < 16; index++) { if (temp16 & 0x1) { @@ -573,11 +568,11 @@ acpi_rs_get_list_length ( temp16 >>= 1; } - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_io) + - (number_of_interrupts * sizeof (u32)); + structure_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_io) + + (number_of_interrupts * sizeof(u32)); break; - case ACPI_RDESC_TYPE_DMA_FORMAT: /* * DMA Resource @@ -593,19 +588,19 @@ acpi_rs_get_list_length ( temp8 = *buffer; - for(index = 0; index < 8; index++) { - if(temp8 & 0x1) { + for (index = 0; index < 8; index++) { + if (temp8 & 0x1) { ++number_of_channels; } temp8 >>= 1; } - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_dma) + - (number_of_channels * sizeof (u32)); + structure_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma) + + (number_of_channels * sizeof(u32)); break; - case ACPI_RDESC_TYPE_START_DEPENDENT: /* * Start Dependent Functions Resource @@ -614,17 +609,17 @@ acpi_rs_get_list_length ( buffer = byte_stream_buffer; temp8 = *buffer; - if(temp8 & 0x01) { + if (temp8 & 0x01) { bytes_consumed = 2; - } - else { + } else { bytes_consumed = 1; } - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_start_dpf); + structure_size = + ACPI_SIZEOF_RESOURCE(struct + acpi_resource_start_dpf); break; - case ACPI_RDESC_TYPE_END_DEPENDENT: /* * End Dependent Functions Resource @@ -633,25 +628,24 @@ acpi_rs_get_list_length ( structure_size = ACPI_RESOURCE_LENGTH; break; - case ACPI_RDESC_TYPE_IO_PORT: /* * IO Port Resource */ bytes_consumed = 8; - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_io); + structure_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); break; - case ACPI_RDESC_TYPE_FIXED_IO_PORT: /* * Fixed IO Port Resource */ bytes_consumed = 4; - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_io); + structure_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); break; - case ACPI_RDESC_TYPE_SMALL_VENDOR: /* * Vendor Specific Resource @@ -664,12 +658,12 @@ acpi_rs_get_list_length ( /* Ensure a 32-bit boundary for the structure */ - temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); - structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) + - (temp8 * sizeof (u8)); + temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8); + structure_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) + + (temp8 * sizeof(u8)); break; - case ACPI_RDESC_TYPE_END_TAG: /* * End Tag @@ -679,18 +673,17 @@ acpi_rs_get_list_length ( byte_stream_buffer_length = bytes_parsed; break; - default: /* * If we get here, everything is out of sync, * exit with an error */ - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); } /* Update the return value and counter */ - buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE (structure_size); + buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(structure_size); bytes_parsed += bytes_consumed; /* Set the byte stream to point to the next resource */ @@ -701,10 +694,9 @@ acpi_rs_get_list_length ( /* This is the data the caller needs */ *size_needed = buffer_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_get_pci_routing_table_length @@ -723,22 +715,19 @@ acpi_rs_get_list_length ( ******************************************************************************/ acpi_status -acpi_rs_get_pci_routing_table_length ( - union acpi_operand_object *package_object, - acpi_size *buffer_size_needed) +acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, + acpi_size * buffer_size_needed) { - u32 number_of_elements; - acpi_size temp_size_needed = 0; - union acpi_operand_object **top_object_list; - u32 index; - union acpi_operand_object *package_element; - union acpi_operand_object **sub_object_list; - u8 name_found; - u32 table_index; - - - ACPI_FUNCTION_TRACE ("rs_get_pci_routing_table_length"); + u32 number_of_elements; + acpi_size temp_size_needed = 0; + union acpi_operand_object **top_object_list; + u32 index; + union acpi_operand_object *package_element; + union acpi_operand_object **sub_object_list; + u8 name_found; + u32 table_index; + ACPI_FUNCTION_TRACE("rs_get_pci_routing_table_length"); number_of_elements = package_object->package.count; @@ -769,53 +758,51 @@ acpi_rs_get_pci_routing_table_length ( name_found = FALSE; - for (table_index = 0; table_index < 4 && !name_found; table_index++) { + for (table_index = 0; table_index < 4 && !name_found; + table_index++) { if ((ACPI_TYPE_STRING == - ACPI_GET_OBJECT_TYPE (*sub_object_list)) || - - ((ACPI_TYPE_LOCAL_REFERENCE == - ACPI_GET_OBJECT_TYPE (*sub_object_list)) && - - ((*sub_object_list)->reference.opcode == - AML_INT_NAMEPATH_OP))) { + ACPI_GET_OBJECT_TYPE(*sub_object_list)) + || + ((ACPI_TYPE_LOCAL_REFERENCE == + ACPI_GET_OBJECT_TYPE(*sub_object_list)) + && ((*sub_object_list)->reference.opcode == + AML_INT_NAMEPATH_OP))) { name_found = TRUE; - } - else { + } else { /* Look at the next element */ sub_object_list++; } } - temp_size_needed += (sizeof (struct acpi_pci_routing_table) - 4); + temp_size_needed += (sizeof(struct acpi_pci_routing_table) - 4); /* Was a String type found? */ if (name_found) { - if (ACPI_GET_OBJECT_TYPE (*sub_object_list) == ACPI_TYPE_STRING) { + if (ACPI_GET_OBJECT_TYPE(*sub_object_list) == + ACPI_TYPE_STRING) { /* * The length String.Length field does not include the * terminating NULL, add 1 */ temp_size_needed += ((acpi_size) - (*sub_object_list)->string.length + 1); + (*sub_object_list)->string. + length + 1); + } else { + temp_size_needed += acpi_ns_get_pathname_length((*sub_object_list)->reference.node); } - else { - temp_size_needed += acpi_ns_get_pathname_length ( - (*sub_object_list)->reference.node); - } - } - else { + } else { /* * If no name was found, then this is a NULL, which is * translated as a u32 zero. */ - temp_size_needed += sizeof (u32); + temp_size_needed += sizeof(u32); } /* Round up the size since each element must be aligned */ - temp_size_needed = ACPI_ROUND_UP_to_64_bITS (temp_size_needed); + temp_size_needed = ACPI_ROUND_UP_to_64_bITS(temp_size_needed); /* Point to the next union acpi_operand_object */ @@ -826,6 +813,7 @@ acpi_rs_get_pci_routing_table_length ( * Adding an extra element to the end of the list, essentially a * NULL terminator */ - *buffer_size_needed = temp_size_needed + sizeof (struct acpi_pci_routing_table); - return_ACPI_STATUS (AE_OK); + *buffer_size_needed = + temp_size_needed + sizeof(struct acpi_pci_routing_table); + return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c index 8e0eae0..0911526 100644 --- a/drivers/acpi/resources/rscreate.c +++ b/drivers/acpi/resources/rscreate.c @@ -41,15 +41,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #include #define _COMPONENT ACPI_RESOURCES - ACPI_MODULE_NAME ("rscreate") - +ACPI_MODULE_NAME("rscreate") /******************************************************************************* * @@ -68,24 +66,20 @@ * of device resources. * ******************************************************************************/ - acpi_status -acpi_rs_create_resource_list ( - union acpi_operand_object *byte_stream_buffer, - struct acpi_buffer *output_buffer) +acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, + struct acpi_buffer *output_buffer) { - acpi_status status; - u8 *byte_stream_start; - acpi_size list_size_needed = 0; - u32 byte_stream_buffer_length; + acpi_status status; + u8 *byte_stream_start; + acpi_size list_size_needed = 0; + u32 byte_stream_buffer_length; + ACPI_FUNCTION_TRACE("rs_create_resource_list"); - ACPI_FUNCTION_TRACE ("rs_create_resource_list"); - - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "byte_stream_buffer = %p\n", - byte_stream_buffer)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_buffer = %p\n", + byte_stream_buffer)); /* Params already validated, so we don't re-validate here */ @@ -96,36 +90,39 @@ acpi_rs_create_resource_list ( * Pass the byte_stream_buffer into a module that can calculate * the buffer size needed for the linked list */ - status = acpi_rs_get_list_length (byte_stream_start, byte_stream_buffer_length, - &list_size_needed); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", - status, (u32) list_size_needed)); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_rs_get_list_length(byte_stream_start, + byte_stream_buffer_length, + &list_size_needed); + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", + status, (u32) list_size_needed)); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Validate/Allocate/Clear caller buffer */ - status = acpi_ut_initialize_buffer (output_buffer, list_size_needed); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_initialize_buffer(output_buffer, list_size_needed); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Do the conversion */ - status = acpi_rs_byte_stream_to_list (byte_stream_start, byte_stream_buffer_length, - output_buffer->pointer); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_rs_byte_stream_to_list(byte_stream_start, + byte_stream_buffer_length, + output_buffer->pointer); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "output_buffer %p Length %X\n", - output_buffer->pointer, (u32) output_buffer->length)); - return_ACPI_STATUS (AE_OK); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "output_buffer %p Length %X\n", + output_buffer->pointer, (u32) output_buffer->length)); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_create_pci_routing_table @@ -148,44 +145,41 @@ acpi_rs_create_resource_list ( ******************************************************************************/ acpi_status -acpi_rs_create_pci_routing_table ( - union acpi_operand_object *package_object, - struct acpi_buffer *output_buffer) +acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, + struct acpi_buffer *output_buffer) { - u8 *buffer; - union acpi_operand_object **top_object_list; - union acpi_operand_object **sub_object_list; - union acpi_operand_object *obj_desc; - acpi_size buffer_size_needed = 0; - u32 number_of_elements; - u32 index; - struct acpi_pci_routing_table *user_prt; - struct acpi_namespace_node *node; - acpi_status status; - struct acpi_buffer path_buffer; - - - ACPI_FUNCTION_TRACE ("rs_create_pci_routing_table"); - + u8 *buffer; + union acpi_operand_object **top_object_list; + union acpi_operand_object **sub_object_list; + union acpi_operand_object *obj_desc; + acpi_size buffer_size_needed = 0; + u32 number_of_elements; + u32 index; + struct acpi_pci_routing_table *user_prt; + struct acpi_namespace_node *node; + acpi_status status; + struct acpi_buffer path_buffer; + + ACPI_FUNCTION_TRACE("rs_create_pci_routing_table"); /* Params already validated, so we don't re-validate here */ /* Get the required buffer length */ - status = acpi_rs_get_pci_routing_table_length (package_object, - &buffer_size_needed); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_rs_get_pci_routing_table_length(package_object, + &buffer_size_needed); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "buffer_size_needed = %X\n", - (u32) buffer_size_needed)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "buffer_size_needed = %X\n", + (u32) buffer_size_needed)); /* Validate/Allocate/Clear caller buffer */ - status = acpi_ut_initialize_buffer (output_buffer, buffer_size_needed); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_initialize_buffer(output_buffer, buffer_size_needed); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -193,10 +187,10 @@ acpi_rs_create_pci_routing_table ( * should be a package that in turn contains an * acpi_integer Address, a u8 Pin, a Name and a u8 source_index. */ - top_object_list = package_object->package.elements; + top_object_list = package_object->package.elements; number_of_elements = package_object->package.count; - buffer = output_buffer->pointer; - user_prt = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); + buffer = output_buffer->pointer; + user_prt = ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer); for (index = 0; index < number_of_elements; index++) { /* @@ -206,31 +200,34 @@ acpi_rs_create_pci_routing_table ( * be zero because we cleared the return buffer earlier */ buffer += user_prt->length; - user_prt = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); + user_prt = ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer); /* * Fill in the Length field with the information we have at this point. * The minus four is to subtract the size of the u8 Source[4] member * because it is added below. */ - user_prt->length = (sizeof (struct acpi_pci_routing_table) - 4); + user_prt->length = (sizeof(struct acpi_pci_routing_table) - 4); /* Each element of the top-level package must also be a package */ - if (ACPI_GET_OBJECT_TYPE (*top_object_list) != ACPI_TYPE_PACKAGE) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "(PRT[%X]) Need sub-package, found %s\n", - index, acpi_ut_get_object_type_name (*top_object_list))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + if (ACPI_GET_OBJECT_TYPE(*top_object_list) != ACPI_TYPE_PACKAGE) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "(PRT[%X]) Need sub-package, found %s\n", + index, + acpi_ut_get_object_type_name + (*top_object_list))); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* Each sub-package must be of length 4 */ if ((*top_object_list)->package.count != 4) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "(PRT[%X]) Need package of length 4, found length %d\n", - index, (*top_object_list)->package.count)); - return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "(PRT[%X]) Need package of length 4, found length %d\n", + index, + (*top_object_list)->package.count)); + return_ACPI_STATUS(AE_AML_PACKAGE_LIMIT); } /* @@ -243,40 +240,43 @@ acpi_rs_create_pci_routing_table ( /* 1) First subobject: Dereference the PRT.Address */ obj_desc = sub_object_list[0]; - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { user_prt->address = obj_desc->integer.value; - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "(PRT[%X].Address) Need Integer, found %s\n", - index, acpi_ut_get_object_type_name (obj_desc))); - return_ACPI_STATUS (AE_BAD_DATA); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "(PRT[%X].Address) Need Integer, found %s\n", + index, + acpi_ut_get_object_type_name + (obj_desc))); + return_ACPI_STATUS(AE_BAD_DATA); } /* 2) Second subobject: Dereference the PRT.Pin */ obj_desc = sub_object_list[1]; - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { user_prt->pin = (u32) obj_desc->integer.value; - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "(PRT[%X].Pin) Need Integer, found %s\n", - index, acpi_ut_get_object_type_name (obj_desc))); - return_ACPI_STATUS (AE_BAD_DATA); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "(PRT[%X].Pin) Need Integer, found %s\n", + index, + acpi_ut_get_object_type_name + (obj_desc))); + return_ACPI_STATUS(AE_BAD_DATA); } /* 3) Third subobject: Dereference the PRT.source_name */ obj_desc = sub_object_list[2]; - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_LOCAL_REFERENCE: if (obj_desc->reference.opcode != AML_INT_NAMEPATH_OP) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "(PRT[%X].Source) Need name, found reference op %X\n", - index, obj_desc->reference.opcode)); - return_ACPI_STATUS (AE_BAD_DATA); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "(PRT[%X].Source) Need name, found reference op %X\n", + index, + obj_desc->reference.opcode)); + return_ACPI_STATUS(AE_BAD_DATA); } node = obj_desc->reference.node; @@ -284,21 +284,23 @@ acpi_rs_create_pci_routing_table ( /* Use *remaining* length of the buffer as max for pathname */ path_buffer.length = output_buffer->length - - (u32) ((u8 *) user_prt->source - - (u8 *) output_buffer->pointer); + (u32) ((u8 *) user_prt->source - + (u8 *) output_buffer->pointer); path_buffer.pointer = user_prt->source; - status = acpi_ns_handle_to_pathname ((acpi_handle) node, &path_buffer); + status = + acpi_ns_handle_to_pathname((acpi_handle) node, + &path_buffer); /* +1 to include null terminator */ - user_prt->length += (u32) ACPI_STRLEN (user_prt->source) + 1; + user_prt->length += + (u32) ACPI_STRLEN(user_prt->source) + 1; break; - case ACPI_TYPE_STRING: - ACPI_STRCPY (user_prt->source, obj_desc->string.pointer); + ACPI_STRCPY(user_prt->source, obj_desc->string.pointer); /* * Add to the Length field the length of the string @@ -307,7 +309,6 @@ acpi_rs_create_pci_routing_table ( user_prt->length += obj_desc->string.length + 1; break; - case ACPI_TYPE_INTEGER: /* * If this is a number, then the Source Name is NULL, since the @@ -315,33 +316,36 @@ acpi_rs_create_pci_routing_table ( * * Add to the Length field the length of the u32 NULL */ - user_prt->length += sizeof (u32); + user_prt->length += sizeof(u32); break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "(PRT[%X].Source) Need Ref/String/Integer, found %s\n", - index, acpi_ut_get_object_type_name (obj_desc))); - return_ACPI_STATUS (AE_BAD_DATA); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "(PRT[%X].Source) Need Ref/String/Integer, found %s\n", + index, + acpi_ut_get_object_type_name + (obj_desc))); + return_ACPI_STATUS(AE_BAD_DATA); } /* Now align the current length */ - user_prt->length = (u32) ACPI_ROUND_UP_to_64_bITS (user_prt->length); + user_prt->length = + (u32) ACPI_ROUND_UP_to_64_bITS(user_prt->length); /* 4) Fourth subobject: Dereference the PRT.source_index */ obj_desc = sub_object_list[3]; - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { user_prt->source_index = (u32) obj_desc->integer.value; - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "(PRT[%X].source_index) Need Integer, found %s\n", - index, acpi_ut_get_object_type_name (obj_desc))); - return_ACPI_STATUS (AE_BAD_DATA); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "(PRT[%X].source_index) Need Integer, found %s\n", + index, + acpi_ut_get_object_type_name + (obj_desc))); + return_ACPI_STATUS(AE_BAD_DATA); } /* Point to the next union acpi_operand_object in the top level package */ @@ -349,12 +353,11 @@ acpi_rs_create_pci_routing_table ( top_object_list++; } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "output_buffer %p Length %X\n", - output_buffer->pointer, (u32) output_buffer->length)); - return_ACPI_STATUS (AE_OK); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "output_buffer %p Length %X\n", + output_buffer->pointer, (u32) output_buffer->length)); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_create_byte_stream @@ -374,19 +377,16 @@ acpi_rs_create_pci_routing_table ( ******************************************************************************/ acpi_status -acpi_rs_create_byte_stream ( - struct acpi_resource *linked_list_buffer, - struct acpi_buffer *output_buffer) +acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, + struct acpi_buffer *output_buffer) { - acpi_status status; - acpi_size byte_stream_size_needed = 0; - - - ACPI_FUNCTION_TRACE ("rs_create_byte_stream"); + acpi_status status; + acpi_size byte_stream_size_needed = 0; + ACPI_FUNCTION_TRACE("rs_create_byte_stream"); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "linked_list_buffer = %p\n", - linked_list_buffer)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n", + linked_list_buffer)); /* * Params already validated, so we don't re-validate here @@ -394,32 +394,35 @@ acpi_rs_create_byte_stream ( * Pass the linked_list_buffer into a module that calculates * the buffer size needed for the byte stream. */ - status = acpi_rs_get_byte_stream_length (linked_list_buffer, - &byte_stream_size_needed); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n", - (u32) byte_stream_size_needed, acpi_format_exception (status))); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_rs_get_byte_stream_length(linked_list_buffer, + &byte_stream_size_needed); + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n", + (u32) byte_stream_size_needed, + acpi_format_exception(status))); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Validate/Allocate/Clear caller buffer */ - status = acpi_ut_initialize_buffer (output_buffer, byte_stream_size_needed); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ut_initialize_buffer(output_buffer, byte_stream_size_needed); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Do the conversion */ - status = acpi_rs_list_to_byte_stream (linked_list_buffer, byte_stream_size_needed, - output_buffer->pointer); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_rs_list_to_byte_stream(linked_list_buffer, + byte_stream_size_needed, + output_buffer->pointer); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "output_buffer %p Length %X\n", - output_buffer->pointer, (u32) output_buffer->length)); - return_ACPI_STATUS (AE_OK); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "output_buffer %p Length %X\n", + output_buffer->pointer, (u32) output_buffer->length)); + return_ACPI_STATUS(AE_OK); } - diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index 2c3bb8c..75bd34d 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c @@ -41,70 +41,39 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #define _COMPONENT ACPI_RESOURCES - ACPI_MODULE_NAME ("rsdump") - +ACPI_MODULE_NAME("rsdump") #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) - /* Local prototypes */ +static void acpi_rs_dump_irq(union acpi_resource_data *data); -static void -acpi_rs_dump_irq ( - union acpi_resource_data *data); - -static void -acpi_rs_dump_address16 ( - union acpi_resource_data *data); +static void acpi_rs_dump_address16(union acpi_resource_data *data); -static void -acpi_rs_dump_address32 ( - union acpi_resource_data *data); +static void acpi_rs_dump_address32(union acpi_resource_data *data); -static void -acpi_rs_dump_address64 ( - union acpi_resource_data *data); +static void acpi_rs_dump_address64(union acpi_resource_data *data); -static void -acpi_rs_dump_dma ( - union acpi_resource_data *data); +static void acpi_rs_dump_dma(union acpi_resource_data *data); -static void -acpi_rs_dump_io ( - union acpi_resource_data *data); +static void acpi_rs_dump_io(union acpi_resource_data *data); -static void -acpi_rs_dump_extended_irq ( - union acpi_resource_data *data); +static void acpi_rs_dump_extended_irq(union acpi_resource_data *data); -static void -acpi_rs_dump_fixed_io ( - union acpi_resource_data *data); +static void acpi_rs_dump_fixed_io(union acpi_resource_data *data); -static void -acpi_rs_dump_fixed_memory32 ( - union acpi_resource_data *data); +static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *data); -static void -acpi_rs_dump_memory24 ( - union acpi_resource_data *data); +static void acpi_rs_dump_memory24(union acpi_resource_data *data); -static void -acpi_rs_dump_memory32 ( - union acpi_resource_data *data); +static void acpi_rs_dump_memory32(union acpi_resource_data *data); -static void -acpi_rs_dump_start_depend_fns ( - union acpi_resource_data *data); - -static void -acpi_rs_dump_vendor_specific ( - union acpi_resource_data *data); +static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *data); +static void acpi_rs_dump_vendor_specific(union acpi_resource_data *data); /******************************************************************************* * @@ -118,39 +87,37 @@ acpi_rs_dump_vendor_specific ( * ******************************************************************************/ -static void -acpi_rs_dump_irq ( - union acpi_resource_data *data) +static void acpi_rs_dump_irq(union acpi_resource_data *data) { - struct acpi_resource_irq *irq_data = (struct acpi_resource_irq *) data; - u8 index = 0; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_resource_irq *irq_data = (struct acpi_resource_irq *)data; + u8 index = 0; + ACPI_FUNCTION_ENTRY(); - acpi_os_printf ("IRQ Resource\n"); + acpi_os_printf("IRQ Resource\n"); - acpi_os_printf (" %s Triggered\n", - ACPI_LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge"); + acpi_os_printf(" %s Triggered\n", + ACPI_LEVEL_SENSITIVE == + irq_data->edge_level ? "Level" : "Edge"); - acpi_os_printf (" Active %s\n", - ACPI_ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High"); + acpi_os_printf(" Active %s\n", + ACPI_ACTIVE_LOW == + irq_data->active_high_low ? "Low" : "High"); - acpi_os_printf (" %s\n", - ACPI_SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive"); + acpi_os_printf(" %s\n", + ACPI_SHARED == + irq_data->shared_exclusive ? "Shared" : "Exclusive"); - acpi_os_printf (" %X Interrupts ( ", irq_data->number_of_interrupts); + acpi_os_printf(" %X Interrupts ( ", irq_data->number_of_interrupts); for (index = 0; index < irq_data->number_of_interrupts; index++) { - acpi_os_printf ("%X ", irq_data->interrupts[index]); + acpi_os_printf("%X ", irq_data->interrupts[index]); } - acpi_os_printf (")\n"); + acpi_os_printf(")\n"); return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_dma @@ -163,75 +130,69 @@ acpi_rs_dump_irq ( * ******************************************************************************/ -static void -acpi_rs_dump_dma ( - union acpi_resource_data *data) +static void acpi_rs_dump_dma(union acpi_resource_data *data) { - struct acpi_resource_dma *dma_data = (struct acpi_resource_dma *) data; - u8 index = 0; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_resource_dma *dma_data = (struct acpi_resource_dma *)data; + u8 index = 0; + ACPI_FUNCTION_ENTRY(); - acpi_os_printf ("DMA Resource\n"); + acpi_os_printf("DMA Resource\n"); switch (dma_data->type) { case ACPI_COMPATIBILITY: - acpi_os_printf (" Compatibility mode\n"); + acpi_os_printf(" Compatibility mode\n"); break; case ACPI_TYPE_A: - acpi_os_printf (" Type A\n"); + acpi_os_printf(" Type A\n"); break; case ACPI_TYPE_B: - acpi_os_printf (" Type B\n"); + acpi_os_printf(" Type B\n"); break; case ACPI_TYPE_F: - acpi_os_printf (" Type F\n"); + acpi_os_printf(" Type F\n"); break; default: - acpi_os_printf (" Invalid DMA type\n"); + acpi_os_printf(" Invalid DMA type\n"); break; } - acpi_os_printf (" %sBus Master\n", - ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a "); - + acpi_os_printf(" %sBus Master\n", + ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a "); switch (dma_data->transfer) { case ACPI_TRANSFER_8: - acpi_os_printf (" 8-bit only transfer\n"); + acpi_os_printf(" 8-bit only transfer\n"); break; case ACPI_TRANSFER_8_16: - acpi_os_printf (" 8 and 16-bit transfer\n"); + acpi_os_printf(" 8 and 16-bit transfer\n"); break; case ACPI_TRANSFER_16: - acpi_os_printf (" 16 bit only transfer\n"); + acpi_os_printf(" 16 bit only transfer\n"); break; default: - acpi_os_printf (" Invalid transfer preference\n"); + acpi_os_printf(" Invalid transfer preference\n"); break; } - acpi_os_printf (" Number of Channels: %X ( ", - dma_data->number_of_channels); + acpi_os_printf(" Number of Channels: %X ( ", + dma_data->number_of_channels); for (index = 0; index < dma_data->number_of_channels; index++) { - acpi_os_printf ("%X ", dma_data->channels[index]); + acpi_os_printf("%X ", dma_data->channels[index]); } - acpi_os_printf (")\n"); + acpi_os_printf(")\n"); return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_start_depend_fns @@ -244,58 +205,54 @@ acpi_rs_dump_dma ( * ******************************************************************************/ -static void -acpi_rs_dump_start_depend_fns ( - union acpi_resource_data *data) +static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *data) { - struct acpi_resource_start_dpf *sdf_data = (struct acpi_resource_start_dpf *) data; - + struct acpi_resource_start_dpf *sdf_data = + (struct acpi_resource_start_dpf *)data; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); - - acpi_os_printf ("Start Dependent Functions Resource\n"); + acpi_os_printf("Start Dependent Functions Resource\n"); switch (sdf_data->compatibility_priority) { case ACPI_GOOD_CONFIGURATION: - acpi_os_printf (" Good configuration\n"); + acpi_os_printf(" Good configuration\n"); break; case ACPI_ACCEPTABLE_CONFIGURATION: - acpi_os_printf (" Acceptable configuration\n"); + acpi_os_printf(" Acceptable configuration\n"); break; case ACPI_SUB_OPTIMAL_CONFIGURATION: - acpi_os_printf (" Sub-optimal configuration\n"); + acpi_os_printf(" Sub-optimal configuration\n"); break; default: - acpi_os_printf (" Invalid compatibility priority\n"); + acpi_os_printf(" Invalid compatibility priority\n"); break; } - switch(sdf_data->performance_robustness) { + switch (sdf_data->performance_robustness) { case ACPI_GOOD_CONFIGURATION: - acpi_os_printf (" Good configuration\n"); + acpi_os_printf(" Good configuration\n"); break; case ACPI_ACCEPTABLE_CONFIGURATION: - acpi_os_printf (" Acceptable configuration\n"); + acpi_os_printf(" Acceptable configuration\n"); break; case ACPI_SUB_OPTIMAL_CONFIGURATION: - acpi_os_printf (" Sub-optimal configuration\n"); + acpi_os_printf(" Sub-optimal configuration\n"); break; default: - acpi_os_printf (" Invalid performance robustness preference\n"); + acpi_os_printf(" Invalid performance robustness preference\n"); break; } return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_io @@ -308,33 +265,30 @@ acpi_rs_dump_start_depend_fns ( * ******************************************************************************/ -static void -acpi_rs_dump_io ( - union acpi_resource_data *data) +static void acpi_rs_dump_io(union acpi_resource_data *data) { - struct acpi_resource_io *io_data = (struct acpi_resource_io *) data; - + struct acpi_resource_io *io_data = (struct acpi_resource_io *)data; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); + acpi_os_printf("Io Resource\n"); - acpi_os_printf ("Io Resource\n"); + acpi_os_printf(" %d bit decode\n", + ACPI_DECODE_16 == io_data->io_decode ? 16 : 10); - acpi_os_printf (" %d bit decode\n", - ACPI_DECODE_16 == io_data->io_decode ? 16 : 10); + acpi_os_printf(" Range minimum base: %08X\n", + io_data->min_base_address); - acpi_os_printf (" Range minimum base: %08X\n", io_data->min_base_address); + acpi_os_printf(" Range maximum base: %08X\n", + io_data->max_base_address); - acpi_os_printf (" Range maximum base: %08X\n", io_data->max_base_address); + acpi_os_printf(" Alignment: %08X\n", io_data->alignment); - acpi_os_printf (" Alignment: %08X\n", io_data->alignment); - - acpi_os_printf (" Range Length: %08X\n", io_data->range_length); + acpi_os_printf(" Range Length: %08X\n", io_data->range_length); return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_fixed_io @@ -347,25 +301,22 @@ acpi_rs_dump_io ( * ******************************************************************************/ -static void -acpi_rs_dump_fixed_io ( - union acpi_resource_data *data) +static void acpi_rs_dump_fixed_io(union acpi_resource_data *data) { - struct acpi_resource_fixed_io *fixed_io_data = (struct acpi_resource_fixed_io *) data; - + struct acpi_resource_fixed_io *fixed_io_data = + (struct acpi_resource_fixed_io *)data; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); + acpi_os_printf("Fixed Io Resource\n"); + acpi_os_printf(" Range base address: %08X", + fixed_io_data->base_address); - acpi_os_printf ("Fixed Io Resource\n"); - acpi_os_printf (" Range base address: %08X", fixed_io_data->base_address); - - acpi_os_printf (" Range length: %08X", fixed_io_data->range_length); + acpi_os_printf(" Range length: %08X", fixed_io_data->range_length); return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_vendor_specific @@ -378,30 +329,26 @@ acpi_rs_dump_fixed_io ( * ******************************************************************************/ -static void -acpi_rs_dump_vendor_specific ( - union acpi_resource_data *data) +static void acpi_rs_dump_vendor_specific(union acpi_resource_data *data) { - struct acpi_resource_vendor *vendor_data = (struct acpi_resource_vendor *) data; - u16 index = 0; - + struct acpi_resource_vendor *vendor_data = + (struct acpi_resource_vendor *)data; + u16 index = 0; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); + acpi_os_printf("Vendor Specific Resource\n"); - acpi_os_printf ("Vendor Specific Resource\n"); - - acpi_os_printf (" Length: %08X\n", vendor_data->length); + acpi_os_printf(" Length: %08X\n", vendor_data->length); for (index = 0; index < vendor_data->length; index++) { - acpi_os_printf (" Byte %X: %08X\n", - index, vendor_data->reserved[index]); + acpi_os_printf(" Byte %X: %08X\n", + index, vendor_data->reserved[index]); } return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_memory24 @@ -414,37 +361,33 @@ acpi_rs_dump_vendor_specific ( * ******************************************************************************/ -static void -acpi_rs_dump_memory24 ( - union acpi_resource_data *data) +static void acpi_rs_dump_memory24(union acpi_resource_data *data) { - struct acpi_resource_mem24 *memory24_data = (struct acpi_resource_mem24 *) data; - + struct acpi_resource_mem24 *memory24_data = + (struct acpi_resource_mem24 *)data; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); + acpi_os_printf("24-Bit Memory Range Resource\n"); - acpi_os_printf ("24-Bit Memory Range Resource\n"); + acpi_os_printf(" Read%s\n", + ACPI_READ_WRITE_MEMORY == + memory24_data->read_write_attribute ? + "/Write" : " only"); - acpi_os_printf (" Read%s\n", - ACPI_READ_WRITE_MEMORY == - memory24_data->read_write_attribute ? - "/Write" : " only"); + acpi_os_printf(" Range minimum base: %08X\n", + memory24_data->min_base_address); - acpi_os_printf (" Range minimum base: %08X\n", - memory24_data->min_base_address); + acpi_os_printf(" Range maximum base: %08X\n", + memory24_data->max_base_address); - acpi_os_printf (" Range maximum base: %08X\n", - memory24_data->max_base_address); + acpi_os_printf(" Alignment: %08X\n", memory24_data->alignment); - acpi_os_printf (" Alignment: %08X\n", memory24_data->alignment); - - acpi_os_printf (" Range length: %08X\n", memory24_data->range_length); + acpi_os_printf(" Range length: %08X\n", memory24_data->range_length); return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_memory32 @@ -457,37 +400,33 @@ acpi_rs_dump_memory24 ( * ******************************************************************************/ -static void -acpi_rs_dump_memory32 ( - union acpi_resource_data *data) +static void acpi_rs_dump_memory32(union acpi_resource_data *data) { - struct acpi_resource_mem32 *memory32_data = (struct acpi_resource_mem32 *) data; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_resource_mem32 *memory32_data = + (struct acpi_resource_mem32 *)data; + ACPI_FUNCTION_ENTRY(); - acpi_os_printf ("32-Bit Memory Range Resource\n"); + acpi_os_printf("32-Bit Memory Range Resource\n"); - acpi_os_printf (" Read%s\n", - ACPI_READ_WRITE_MEMORY == - memory32_data->read_write_attribute ? - "/Write" : " only"); + acpi_os_printf(" Read%s\n", + ACPI_READ_WRITE_MEMORY == + memory32_data->read_write_attribute ? + "/Write" : " only"); - acpi_os_printf (" Range minimum base: %08X\n", - memory32_data->min_base_address); + acpi_os_printf(" Range minimum base: %08X\n", + memory32_data->min_base_address); - acpi_os_printf (" Range maximum base: %08X\n", - memory32_data->max_base_address); + acpi_os_printf(" Range maximum base: %08X\n", + memory32_data->max_base_address); - acpi_os_printf (" Alignment: %08X\n", memory32_data->alignment); + acpi_os_printf(" Alignment: %08X\n", memory32_data->alignment); - acpi_os_printf (" Range length: %08X\n", memory32_data->range_length); + acpi_os_printf(" Range length: %08X\n", memory32_data->range_length); return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_fixed_memory32 @@ -500,33 +439,29 @@ acpi_rs_dump_memory32 ( * ******************************************************************************/ -static void -acpi_rs_dump_fixed_memory32 ( - union acpi_resource_data *data) +static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *data) { - struct acpi_resource_fixed_mem32 *fixed_memory32_data = - (struct acpi_resource_fixed_mem32 *) data; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_resource_fixed_mem32 *fixed_memory32_data = + (struct acpi_resource_fixed_mem32 *)data; + ACPI_FUNCTION_ENTRY(); - acpi_os_printf ("32-Bit Fixed Location Memory Range Resource\n"); + acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n"); - acpi_os_printf (" Read%s\n", - ACPI_READ_WRITE_MEMORY == - fixed_memory32_data->read_write_attribute ? "/Write" : " Only"); + acpi_os_printf(" Read%s\n", + ACPI_READ_WRITE_MEMORY == + fixed_memory32_data-> + read_write_attribute ? "/Write" : " Only"); - acpi_os_printf (" Range base address: %08X\n", - fixed_memory32_data->range_base_address); + acpi_os_printf(" Range base address: %08X\n", + fixed_memory32_data->range_base_address); - acpi_os_printf (" Range length: %08X\n", - fixed_memory32_data->range_length); + acpi_os_printf(" Range length: %08X\n", + fixed_memory32_data->range_length); return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_address16 @@ -539,134 +474,136 @@ acpi_rs_dump_fixed_memory32 ( * ******************************************************************************/ -static void -acpi_rs_dump_address16 ( - union acpi_resource_data *data) +static void acpi_rs_dump_address16(union acpi_resource_data *data) { - struct acpi_resource_address16 *address16_data = (struct acpi_resource_address16 *) data; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_resource_address16 *address16_data = + (struct acpi_resource_address16 *)data; + ACPI_FUNCTION_ENTRY(); - acpi_os_printf ("16-Bit Address Space Resource\n"); - acpi_os_printf (" Resource Type: "); + acpi_os_printf("16-Bit Address Space Resource\n"); + acpi_os_printf(" Resource Type: "); switch (address16_data->resource_type) { case ACPI_MEMORY_RANGE: - acpi_os_printf ("Memory Range\n"); + acpi_os_printf("Memory Range\n"); switch (address16_data->attribute.memory.cache_attribute) { case ACPI_NON_CACHEABLE_MEMORY: - acpi_os_printf (" Type Specific: Noncacheable memory\n"); + acpi_os_printf + (" Type Specific: Noncacheable memory\n"); break; case ACPI_CACHABLE_MEMORY: - acpi_os_printf (" Type Specific: Cacheable memory\n"); + acpi_os_printf(" Type Specific: Cacheable memory\n"); break; case ACPI_WRITE_COMBINING_MEMORY: - acpi_os_printf (" Type Specific: Write-combining memory\n"); + acpi_os_printf + (" Type Specific: Write-combining memory\n"); break; case ACPI_PREFETCHABLE_MEMORY: - acpi_os_printf (" Type Specific: Prefetchable memory\n"); + acpi_os_printf + (" Type Specific: Prefetchable memory\n"); break; default: - acpi_os_printf (" Type Specific: Invalid cache attribute\n"); + acpi_os_printf + (" Type Specific: Invalid cache attribute\n"); break; } - acpi_os_printf (" Type Specific: Read%s\n", - ACPI_READ_WRITE_MEMORY == - address16_data->attribute.memory.read_write_attribute ? - "/Write" : " Only"); + acpi_os_printf(" Type Specific: Read%s\n", + ACPI_READ_WRITE_MEMORY == + address16_data->attribute.memory. + read_write_attribute ? "/Write" : " Only"); break; case ACPI_IO_RANGE: - acpi_os_printf ("I/O Range\n"); + acpi_os_printf("I/O Range\n"); switch (address16_data->attribute.io.range_attribute) { case ACPI_NON_ISA_ONLY_RANGES: - acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n"); + acpi_os_printf + (" Type Specific: Non-ISA Io Addresses\n"); break; case ACPI_ISA_ONLY_RANGES: - acpi_os_printf (" Type Specific: ISA Io Addresses\n"); + acpi_os_printf(" Type Specific: ISA Io Addresses\n"); break; case ACPI_ENTIRE_RANGE: - acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n"); + acpi_os_printf + (" Type Specific: ISA and non-ISA Io Addresses\n"); break; default: - acpi_os_printf (" Type Specific: Invalid range attribute\n"); + acpi_os_printf + (" Type Specific: Invalid range attribute\n"); break; } - acpi_os_printf (" Type Specific: %s Translation\n", - ACPI_SPARSE_TRANSLATION == - address16_data->attribute.io.translation_attribute ? - "Sparse" : "Dense"); + acpi_os_printf(" Type Specific: %s Translation\n", + ACPI_SPARSE_TRANSLATION == + address16_data->attribute.io. + translation_attribute ? "Sparse" : "Dense"); break; case ACPI_BUS_NUMBER_RANGE: - acpi_os_printf ("Bus Number Range\n"); + acpi_os_printf("Bus Number Range\n"); break; default: - acpi_os_printf ("0x%2.2X\n", address16_data->resource_type); + acpi_os_printf("0x%2.2X\n", address16_data->resource_type); break; } - acpi_os_printf (" Resource %s\n", - ACPI_CONSUMER == address16_data->producer_consumer ? - "Consumer" : "Producer"); + acpi_os_printf(" Resource %s\n", + ACPI_CONSUMER == address16_data->producer_consumer ? + "Consumer" : "Producer"); - acpi_os_printf (" %s decode\n", - ACPI_SUB_DECODE == address16_data->decode ? - "Subtractive" : "Positive"); + acpi_os_printf(" %s decode\n", + ACPI_SUB_DECODE == address16_data->decode ? + "Subtractive" : "Positive"); - acpi_os_printf (" Min address is %s fixed\n", - ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ? - "" : "not"); + acpi_os_printf(" Min address is %s fixed\n", + ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ? + "" : "not"); - acpi_os_printf (" Max address is %s fixed\n", - ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ? - "" : "not"); + acpi_os_printf(" Max address is %s fixed\n", + ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ? + "" : "not"); - acpi_os_printf (" Granularity: %08X\n", - address16_data->granularity); + acpi_os_printf(" Granularity: %08X\n", address16_data->granularity); - acpi_os_printf (" Address range min: %08X\n", - address16_data->min_address_range); + acpi_os_printf(" Address range min: %08X\n", + address16_data->min_address_range); - acpi_os_printf (" Address range max: %08X\n", - address16_data->max_address_range); + acpi_os_printf(" Address range max: %08X\n", + address16_data->max_address_range); - acpi_os_printf (" Address translation offset: %08X\n", - address16_data->address_translation_offset); + acpi_os_printf(" Address translation offset: %08X\n", + address16_data->address_translation_offset); - acpi_os_printf (" Address Length: %08X\n", - address16_data->address_length); + acpi_os_printf(" Address Length: %08X\n", + address16_data->address_length); if (0xFF != address16_data->resource_source.index) { - acpi_os_printf (" Resource Source Index: %X\n", - address16_data->resource_source.index); + acpi_os_printf(" Resource Source Index: %X\n", + address16_data->resource_source.index); - acpi_os_printf (" Resource Source: %s\n", - address16_data->resource_source.string_ptr); + acpi_os_printf(" Resource Source: %s\n", + address16_data->resource_source.string_ptr); } return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_address32 @@ -679,134 +616,136 @@ acpi_rs_dump_address16 ( * ******************************************************************************/ -static void -acpi_rs_dump_address32 ( - union acpi_resource_data *data) +static void acpi_rs_dump_address32(union acpi_resource_data *data) { - struct acpi_resource_address32 *address32_data = (struct acpi_resource_address32 *) data; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_resource_address32 *address32_data = + (struct acpi_resource_address32 *)data; + ACPI_FUNCTION_ENTRY(); - acpi_os_printf ("32-Bit Address Space Resource\n"); + acpi_os_printf("32-Bit Address Space Resource\n"); switch (address32_data->resource_type) { case ACPI_MEMORY_RANGE: - acpi_os_printf (" Resource Type: Memory Range\n"); + acpi_os_printf(" Resource Type: Memory Range\n"); switch (address32_data->attribute.memory.cache_attribute) { case ACPI_NON_CACHEABLE_MEMORY: - acpi_os_printf (" Type Specific: Noncacheable memory\n"); + acpi_os_printf + (" Type Specific: Noncacheable memory\n"); break; case ACPI_CACHABLE_MEMORY: - acpi_os_printf (" Type Specific: Cacheable memory\n"); + acpi_os_printf(" Type Specific: Cacheable memory\n"); break; case ACPI_WRITE_COMBINING_MEMORY: - acpi_os_printf (" Type Specific: Write-combining memory\n"); + acpi_os_printf + (" Type Specific: Write-combining memory\n"); break; case ACPI_PREFETCHABLE_MEMORY: - acpi_os_printf (" Type Specific: Prefetchable memory\n"); + acpi_os_printf + (" Type Specific: Prefetchable memory\n"); break; default: - acpi_os_printf (" Type Specific: Invalid cache attribute\n"); + acpi_os_printf + (" Type Specific: Invalid cache attribute\n"); break; } - acpi_os_printf (" Type Specific: Read%s\n", - ACPI_READ_WRITE_MEMORY == - address32_data->attribute.memory.read_write_attribute ? - "/Write" : " Only"); + acpi_os_printf(" Type Specific: Read%s\n", + ACPI_READ_WRITE_MEMORY == + address32_data->attribute.memory. + read_write_attribute ? "/Write" : " Only"); break; case ACPI_IO_RANGE: - acpi_os_printf (" Resource Type: Io Range\n"); + acpi_os_printf(" Resource Type: Io Range\n"); switch (address32_data->attribute.io.range_attribute) { case ACPI_NON_ISA_ONLY_RANGES: - acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n"); + acpi_os_printf + (" Type Specific: Non-ISA Io Addresses\n"); break; case ACPI_ISA_ONLY_RANGES: - acpi_os_printf (" Type Specific: ISA Io Addresses\n"); + acpi_os_printf(" Type Specific: ISA Io Addresses\n"); break; case ACPI_ENTIRE_RANGE: - acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n"); + acpi_os_printf + (" Type Specific: ISA and non-ISA Io Addresses\n"); break; default: - acpi_os_printf (" Type Specific: Invalid Range attribute"); + acpi_os_printf + (" Type Specific: Invalid Range attribute"); break; } - acpi_os_printf (" Type Specific: %s Translation\n", - ACPI_SPARSE_TRANSLATION == - address32_data->attribute.io.translation_attribute ? - "Sparse" : "Dense"); + acpi_os_printf(" Type Specific: %s Translation\n", + ACPI_SPARSE_TRANSLATION == + address32_data->attribute.io. + translation_attribute ? "Sparse" : "Dense"); break; case ACPI_BUS_NUMBER_RANGE: - acpi_os_printf (" Resource Type: Bus Number Range\n"); + acpi_os_printf(" Resource Type: Bus Number Range\n"); break; default: - acpi_os_printf (" Resource Type: 0x%2.2X\n", - address32_data->resource_type); + acpi_os_printf(" Resource Type: 0x%2.2X\n", + address32_data->resource_type); break; } - acpi_os_printf (" Resource %s\n", - ACPI_CONSUMER == address32_data->producer_consumer ? - "Consumer" : "Producer"); + acpi_os_printf(" Resource %s\n", + ACPI_CONSUMER == address32_data->producer_consumer ? + "Consumer" : "Producer"); - acpi_os_printf (" %s decode\n", - ACPI_SUB_DECODE == address32_data->decode ? - "Subtractive" : "Positive"); + acpi_os_printf(" %s decode\n", + ACPI_SUB_DECODE == address32_data->decode ? + "Subtractive" : "Positive"); - acpi_os_printf (" Min address is %s fixed\n", - ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ? - "" : "not "); + acpi_os_printf(" Min address is %s fixed\n", + ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ? + "" : "not "); - acpi_os_printf (" Max address is %s fixed\n", - ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ? - "" : "not "); + acpi_os_printf(" Max address is %s fixed\n", + ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ? + "" : "not "); - acpi_os_printf (" Granularity: %08X\n", - address32_data->granularity); + acpi_os_printf(" Granularity: %08X\n", address32_data->granularity); - acpi_os_printf (" Address range min: %08X\n", - address32_data->min_address_range); + acpi_os_printf(" Address range min: %08X\n", + address32_data->min_address_range); - acpi_os_printf (" Address range max: %08X\n", - address32_data->max_address_range); + acpi_os_printf(" Address range max: %08X\n", + address32_data->max_address_range); - acpi_os_printf (" Address translation offset: %08X\n", - address32_data->address_translation_offset); + acpi_os_printf(" Address translation offset: %08X\n", + address32_data->address_translation_offset); - acpi_os_printf (" Address Length: %08X\n", - address32_data->address_length); + acpi_os_printf(" Address Length: %08X\n", + address32_data->address_length); - if(0xFF != address32_data->resource_source.index) { - acpi_os_printf (" Resource Source Index: %X\n", - address32_data->resource_source.index); + if (0xFF != address32_data->resource_source.index) { + acpi_os_printf(" Resource Source Index: %X\n", + address32_data->resource_source.index); - acpi_os_printf (" Resource Source: %s\n", - address32_data->resource_source.string_ptr); + acpi_os_printf(" Resource Source: %s\n", + address32_data->resource_source.string_ptr); } return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_address64 @@ -819,137 +758,142 @@ acpi_rs_dump_address32 ( * ******************************************************************************/ -static void -acpi_rs_dump_address64 ( - union acpi_resource_data *data) +static void acpi_rs_dump_address64(union acpi_resource_data *data) { - struct acpi_resource_address64 *address64_data = (struct acpi_resource_address64 *) data; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_resource_address64 *address64_data = + (struct acpi_resource_address64 *)data; + ACPI_FUNCTION_ENTRY(); - acpi_os_printf ("64-Bit Address Space Resource\n"); + acpi_os_printf("64-Bit Address Space Resource\n"); switch (address64_data->resource_type) { case ACPI_MEMORY_RANGE: - acpi_os_printf (" Resource Type: Memory Range\n"); + acpi_os_printf(" Resource Type: Memory Range\n"); switch (address64_data->attribute.memory.cache_attribute) { case ACPI_NON_CACHEABLE_MEMORY: - acpi_os_printf (" Type Specific: Noncacheable memory\n"); + acpi_os_printf + (" Type Specific: Noncacheable memory\n"); break; case ACPI_CACHABLE_MEMORY: - acpi_os_printf (" Type Specific: Cacheable memory\n"); + acpi_os_printf(" Type Specific: Cacheable memory\n"); break; case ACPI_WRITE_COMBINING_MEMORY: - acpi_os_printf (" Type Specific: Write-combining memory\n"); + acpi_os_printf + (" Type Specific: Write-combining memory\n"); break; case ACPI_PREFETCHABLE_MEMORY: - acpi_os_printf (" Type Specific: Prefetchable memory\n"); + acpi_os_printf + (" Type Specific: Prefetchable memory\n"); break; default: - acpi_os_printf (" Type Specific: Invalid cache attribute\n"); + acpi_os_printf + (" Type Specific: Invalid cache attribute\n"); break; } - acpi_os_printf (" Type Specific: Read%s\n", - ACPI_READ_WRITE_MEMORY == - address64_data->attribute.memory.read_write_attribute ? - "/Write" : " Only"); + acpi_os_printf(" Type Specific: Read%s\n", + ACPI_READ_WRITE_MEMORY == + address64_data->attribute.memory. + read_write_attribute ? "/Write" : " Only"); break; case ACPI_IO_RANGE: - acpi_os_printf (" Resource Type: Io Range\n"); + acpi_os_printf(" Resource Type: Io Range\n"); switch (address64_data->attribute.io.range_attribute) { case ACPI_NON_ISA_ONLY_RANGES: - acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n"); + acpi_os_printf + (" Type Specific: Non-ISA Io Addresses\n"); break; case ACPI_ISA_ONLY_RANGES: - acpi_os_printf (" Type Specific: ISA Io Addresses\n"); + acpi_os_printf(" Type Specific: ISA Io Addresses\n"); break; case ACPI_ENTIRE_RANGE: - acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n"); + acpi_os_printf + (" Type Specific: ISA and non-ISA Io Addresses\n"); break; default: - acpi_os_printf (" Type Specific: Invalid Range attribute"); + acpi_os_printf + (" Type Specific: Invalid Range attribute"); break; } - acpi_os_printf (" Type Specific: %s Translation\n", - ACPI_SPARSE_TRANSLATION == - address64_data->attribute.io.translation_attribute ? - "Sparse" : "Dense"); + acpi_os_printf(" Type Specific: %s Translation\n", + ACPI_SPARSE_TRANSLATION == + address64_data->attribute.io. + translation_attribute ? "Sparse" : "Dense"); break; case ACPI_BUS_NUMBER_RANGE: - acpi_os_printf (" Resource Type: Bus Number Range\n"); + acpi_os_printf(" Resource Type: Bus Number Range\n"); break; default: - acpi_os_printf (" Resource Type: 0x%2.2X\n", - address64_data->resource_type); + acpi_os_printf(" Resource Type: 0x%2.2X\n", + address64_data->resource_type); break; } - acpi_os_printf (" Resource %s\n", - ACPI_CONSUMER == address64_data->producer_consumer ? - "Consumer" : "Producer"); + acpi_os_printf(" Resource %s\n", + ACPI_CONSUMER == address64_data->producer_consumer ? + "Consumer" : "Producer"); - acpi_os_printf (" %s decode\n", - ACPI_SUB_DECODE == address64_data->decode ? - "Subtractive" : "Positive"); + acpi_os_printf(" %s decode\n", + ACPI_SUB_DECODE == address64_data->decode ? + "Subtractive" : "Positive"); - acpi_os_printf (" Min address is %s fixed\n", - ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ? - "" : "not "); + acpi_os_printf(" Min address is %s fixed\n", + ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ? + "" : "not "); - acpi_os_printf (" Max address is %s fixed\n", - ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ? - "" : "not "); + acpi_os_printf(" Max address is %s fixed\n", + ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ? + "" : "not "); - acpi_os_printf (" Granularity: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (address64_data->granularity)); + acpi_os_printf(" Granularity: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64(address64_data->granularity)); - acpi_os_printf (" Address range min: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (address64_data->min_address_range)); + acpi_os_printf(" Address range min: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64(address64_data->min_address_range)); - acpi_os_printf (" Address range max: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (address64_data->max_address_range)); + acpi_os_printf(" Address range max: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64(address64_data->max_address_range)); - acpi_os_printf (" Address translation offset: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (address64_data->address_translation_offset)); + acpi_os_printf(" Address translation offset: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64(address64_data-> + address_translation_offset)); - acpi_os_printf (" Address Length: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (address64_data->address_length)); + acpi_os_printf(" Address Length: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64(address64_data->address_length)); - acpi_os_printf (" Type Specific Attributes: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (address64_data->type_specific_attributes)); + acpi_os_printf(" Type Specific Attributes: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64(address64_data-> + type_specific_attributes)); if (0xFF != address64_data->resource_source.index) { - acpi_os_printf (" Resource Source Index: %X\n", - address64_data->resource_source.index); + acpi_os_printf(" Resource Source Index: %X\n", + address64_data->resource_source.index); - acpi_os_printf (" Resource Source: %s\n", - address64_data->resource_source.string_ptr); + acpi_os_printf(" Resource Source: %s\n", + address64_data->resource_source.string_ptr); } return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_extended_irq @@ -962,55 +906,52 @@ acpi_rs_dump_address64 ( * ******************************************************************************/ -static void -acpi_rs_dump_extended_irq ( - union acpi_resource_data *data) +static void acpi_rs_dump_extended_irq(union acpi_resource_data *data) { - struct acpi_resource_ext_irq *ext_irq_data = (struct acpi_resource_ext_irq *) data; - u8 index = 0; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_resource_ext_irq *ext_irq_data = + (struct acpi_resource_ext_irq *)data; + u8 index = 0; + ACPI_FUNCTION_ENTRY(); - acpi_os_printf ("Extended IRQ Resource\n"); + acpi_os_printf("Extended IRQ Resource\n"); - acpi_os_printf (" Resource %s\n", - ACPI_CONSUMER == ext_irq_data->producer_consumer ? - "Consumer" : "Producer"); + acpi_os_printf(" Resource %s\n", + ACPI_CONSUMER == ext_irq_data->producer_consumer ? + "Consumer" : "Producer"); - acpi_os_printf (" %s\n", - ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ? - "Level" : "Edge"); + acpi_os_printf(" %s\n", + ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ? + "Level" : "Edge"); - acpi_os_printf (" Active %s\n", - ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ? - "low" : "high"); + acpi_os_printf(" Active %s\n", + ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ? + "low" : "high"); - acpi_os_printf (" %s\n", - ACPI_SHARED == ext_irq_data->shared_exclusive ? - "Shared" : "Exclusive"); + acpi_os_printf(" %s\n", + ACPI_SHARED == ext_irq_data->shared_exclusive ? + "Shared" : "Exclusive"); - acpi_os_printf (" Interrupts : %X ( ", ext_irq_data->number_of_interrupts); + acpi_os_printf(" Interrupts : %X ( ", + ext_irq_data->number_of_interrupts); for (index = 0; index < ext_irq_data->number_of_interrupts; index++) { - acpi_os_printf ("%X ", ext_irq_data->interrupts[index]); + acpi_os_printf("%X ", ext_irq_data->interrupts[index]); } - acpi_os_printf (")\n"); + acpi_os_printf(")\n"); - if(0xFF != ext_irq_data->resource_source.index) { - acpi_os_printf (" Resource Source Index: %X", - ext_irq_data->resource_source.index); + if (0xFF != ext_irq_data->resource_source.index) { + acpi_os_printf(" Resource Source Index: %X", + ext_irq_data->resource_source.index); - acpi_os_printf (" Resource Source: %s", - ext_irq_data->resource_source.string_ptr); + acpi_os_printf(" Resource Source: %s", + ext_irq_data->resource_source.string_ptr); } return; } - /******************************************************************************* * * FUNCTION: acpi_rs_dump_resource_list @@ -1023,92 +964,91 @@ acpi_rs_dump_extended_irq ( * ******************************************************************************/ -void -acpi_rs_dump_resource_list ( - struct acpi_resource *resource) +void acpi_rs_dump_resource_list(struct acpi_resource *resource) { - u8 count = 0; - u8 done = FALSE; - - - ACPI_FUNCTION_ENTRY (); + u8 count = 0; + u8 done = FALSE; + ACPI_FUNCTION_ENTRY(); if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) { while (!done) { - acpi_os_printf ("Resource structure %X.\n", count++); + acpi_os_printf("Resource structure %X.\n", count++); switch (resource->id) { case ACPI_RSTYPE_IRQ: - acpi_rs_dump_irq (&resource->data); + acpi_rs_dump_irq(&resource->data); break; case ACPI_RSTYPE_DMA: - acpi_rs_dump_dma (&resource->data); + acpi_rs_dump_dma(&resource->data); break; case ACPI_RSTYPE_START_DPF: - acpi_rs_dump_start_depend_fns (&resource->data); + acpi_rs_dump_start_depend_fns(&resource->data); break; case ACPI_RSTYPE_END_DPF: - acpi_os_printf ("end_dependent_functions Resource\n"); - /* acpi_rs_dump_end_dependent_functions (Resource->Data);*/ + acpi_os_printf + ("end_dependent_functions Resource\n"); + /* acpi_rs_dump_end_dependent_functions (Resource->Data); */ break; case ACPI_RSTYPE_IO: - acpi_rs_dump_io (&resource->data); + acpi_rs_dump_io(&resource->data); break; case ACPI_RSTYPE_FIXED_IO: - acpi_rs_dump_fixed_io (&resource->data); + acpi_rs_dump_fixed_io(&resource->data); break; case ACPI_RSTYPE_VENDOR: - acpi_rs_dump_vendor_specific (&resource->data); + acpi_rs_dump_vendor_specific(&resource->data); break; case ACPI_RSTYPE_END_TAG: - /*rs_dump_end_tag (Resource->Data);*/ - acpi_os_printf ("end_tag Resource\n"); + /*rs_dump_end_tag (Resource->Data); */ + acpi_os_printf("end_tag Resource\n"); done = TRUE; break; case ACPI_RSTYPE_MEM24: - acpi_rs_dump_memory24 (&resource->data); + acpi_rs_dump_memory24(&resource->data); break; case ACPI_RSTYPE_MEM32: - acpi_rs_dump_memory32 (&resource->data); + acpi_rs_dump_memory32(&resource->data); break; case ACPI_RSTYPE_FIXED_MEM32: - acpi_rs_dump_fixed_memory32 (&resource->data); + acpi_rs_dump_fixed_memory32(&resource->data); break; case ACPI_RSTYPE_ADDRESS16: - acpi_rs_dump_address16 (&resource->data); + acpi_rs_dump_address16(&resource->data); break; case ACPI_RSTYPE_ADDRESS32: - acpi_rs_dump_address32 (&resource->data); + acpi_rs_dump_address32(&resource->data); break; case ACPI_RSTYPE_ADDRESS64: - acpi_rs_dump_address64 (&resource->data); + acpi_rs_dump_address64(&resource->data); break; case ACPI_RSTYPE_EXT_IRQ: - acpi_rs_dump_extended_irq (&resource->data); + acpi_rs_dump_extended_irq(&resource->data); break; default: - acpi_os_printf ("Invalid resource type\n"); + acpi_os_printf("Invalid resource type\n"); break; } - resource = ACPI_PTR_ADD (struct acpi_resource, resource, resource->length); + resource = + ACPI_PTR_ADD(struct acpi_resource, resource, + resource->length); } } @@ -1127,36 +1067,38 @@ acpi_rs_dump_resource_list ( * ******************************************************************************/ -void -acpi_rs_dump_irq_list ( - u8 *route_table) +void acpi_rs_dump_irq_list(u8 * route_table) { - u8 *buffer = route_table; - u8 count = 0; - u8 done = FALSE; - struct acpi_pci_routing_table *prt_element; - - - ACPI_FUNCTION_ENTRY (); + u8 *buffer = route_table; + u8 count = 0; + u8 done = FALSE; + struct acpi_pci_routing_table *prt_element; + ACPI_FUNCTION_ENTRY(); if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) { - prt_element = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); + prt_element = + ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer); while (!done) { - acpi_os_printf ("PCI IRQ Routing Table structure %X.\n", count++); + acpi_os_printf("PCI IRQ Routing Table structure %X.\n", + count++); - acpi_os_printf (" Address: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (prt_element->address)); + acpi_os_printf(" Address: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64(prt_element-> + address)); - acpi_os_printf (" Pin: %X\n", prt_element->pin); + acpi_os_printf(" Pin: %X\n", prt_element->pin); - acpi_os_printf (" Source: %s\n", prt_element->source); + acpi_os_printf(" Source: %s\n", prt_element->source); - acpi_os_printf (" source_index: %X\n", prt_element->source_index); + acpi_os_printf(" source_index: %X\n", + prt_element->source_index); buffer += prt_element->length; - prt_element = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); + prt_element = + ACPI_CAST_PTR(struct acpi_pci_routing_table, + buffer); if (0 == prt_element->length) { done = TRUE; } @@ -1167,4 +1109,3 @@ acpi_rs_dump_irq_list ( } #endif - diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c index 23a4d14..d53bbe8 100644 --- a/drivers/acpi/resources/rsio.c +++ b/drivers/acpi/resources/rsio.c @@ -41,13 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #define _COMPONENT ACPI_RESOURCES - ACPI_MODULE_NAME ("rsio") - +ACPI_MODULE_NAME("rsio") /******************************************************************************* * @@ -69,24 +67,18 @@ * number of bytes consumed from the byte stream. * ******************************************************************************/ - acpi_status -acpi_rs_io_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_io_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( - struct acpi_resource_io); - - - ACPI_FUNCTION_TRACE ("rs_io_resource"); + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); + ACPI_FUNCTION_TRACE("rs_io_resource"); /* The number of bytes consumed are Constant */ @@ -104,14 +96,14 @@ acpi_rs_io_resource ( /* Check min_base Address */ buffer += 1; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); output_struct->data.io.min_base_address = temp16; /* Check max_base Address */ buffer += 2; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); output_struct->data.io.max_base_address = temp16; @@ -136,10 +128,9 @@ acpi_rs_io_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_fixed_io_resource @@ -162,22 +153,18 @@ acpi_rs_io_resource ( ******************************************************************************/ acpi_status -acpi_rs_fixed_io_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( - struct acpi_resource_fixed_io); - - - ACPI_FUNCTION_TRACE ("rs_fixed_io_resource"); + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + acpi_size struct_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); + ACPI_FUNCTION_TRACE("rs_fixed_io_resource"); /* The number of bytes consumed are Constant */ @@ -188,7 +175,7 @@ acpi_rs_fixed_io_resource ( /* Check Range Base Address */ buffer += 1; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); output_struct->data.fixed_io.base_address = temp16; @@ -206,10 +193,9 @@ acpi_rs_fixed_io_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_io_stream @@ -227,18 +213,14 @@ acpi_rs_fixed_io_resource ( ******************************************************************************/ acpi_status -acpi_rs_io_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_io_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - - ACPI_FUNCTION_TRACE ("rs_io_stream"); + u8 *buffer = *output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + ACPI_FUNCTION_TRACE("rs_io_stream"); /* The descriptor field is static */ @@ -256,14 +238,14 @@ acpi_rs_io_stream ( temp16 = (u16) linked_list->data.io.min_base_address; - ACPI_MOVE_16_TO_16 (buffer, &temp16); + ACPI_MOVE_16_TO_16(buffer, &temp16); buffer += 2; /* Set the Range maximum base address */ temp16 = (u16) linked_list->data.io.max_base_address; - ACPI_MOVE_16_TO_16 (buffer, &temp16); + ACPI_MOVE_16_TO_16(buffer, &temp16); buffer += 2; /* Set the base alignment */ @@ -282,11 +264,10 @@ acpi_rs_io_stream ( /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); - return_ACPI_STATUS (AE_OK); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_fixed_io_stream @@ -304,18 +285,14 @@ acpi_rs_io_stream ( ******************************************************************************/ acpi_status -acpi_rs_fixed_io_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_fixed_io_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - - ACPI_FUNCTION_TRACE ("rs_fixed_io_stream"); + u8 *buffer = *output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + ACPI_FUNCTION_TRACE("rs_fixed_io_stream"); /* The descriptor field is static */ @@ -327,7 +304,7 @@ acpi_rs_fixed_io_stream ( temp16 = (u16) linked_list->data.fixed_io.base_address; - ACPI_MOVE_16_TO_16 (buffer, &temp16); + ACPI_MOVE_16_TO_16(buffer, &temp16); buffer += 2; /* Set the range length */ @@ -339,11 +316,10 @@ acpi_rs_fixed_io_stream ( /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); - return_ACPI_STATUS (AE_OK); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_dma_resource @@ -366,23 +342,18 @@ acpi_rs_fixed_io_stream ( ******************************************************************************/ acpi_status -acpi_rs_dma_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_dma_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - u8 temp8 = 0; - u8 index; - u8 i; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( - struct acpi_resource_dma); - - - ACPI_FUNCTION_TRACE ("rs_dma_resource"); + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + u8 temp8 = 0; + u8 index; + u8 i; + acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma); + ACPI_FUNCTION_TRACE("rs_dma_resource"); /* The number of bytes consumed are Constant */ @@ -422,9 +393,9 @@ acpi_rs_dma_resource ( output_struct->data.dma.transfer = temp8 & 0x03; if (0x03 == output_struct->data.dma.transfer) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid DMA.Transfer preference (3)\n")); - return_ACPI_STATUS (AE_BAD_DATA); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid DMA.Transfer preference (3)\n")); + return_ACPI_STATUS(AE_BAD_DATA); } /* Get bus master preference (Bit[2]) */ @@ -442,10 +413,9 @@ acpi_rs_dma_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_dma_stream @@ -463,19 +433,15 @@ acpi_rs_dma_resource ( ******************************************************************************/ acpi_status -acpi_rs_dma_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_dma_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - - - ACPI_FUNCTION_TRACE ("rs_dma_stream"); + u8 *buffer = *output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + u8 index; + ACPI_FUNCTION_TRACE("rs_dma_stream"); /* The descriptor field is static */ @@ -486,8 +452,7 @@ acpi_rs_dma_stream ( /* Loop through all of the Channels and set the mask bits */ for (index = 0; - index < linked_list->data.dma.number_of_channels; - index++) { + index < linked_list->data.dma.number_of_channels; index++) { temp16 = (u16) linked_list->data.dma.channels[index]; temp8 |= 0x1 << temp16; } @@ -506,7 +471,6 @@ acpi_rs_dma_stream ( /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); - return_ACPI_STATUS (AE_OK); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + return_ACPI_STATUS(AE_OK); } - diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c index 8a2b630..7179b62 100644 --- a/drivers/acpi/resources/rsirq.c +++ b/drivers/acpi/resources/rsirq.c @@ -41,13 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #define _COMPONENT ACPI_RESOURCES - ACPI_MODULE_NAME ("rsirq") - +ACPI_MODULE_NAME("rsirq") /******************************************************************************* * @@ -69,26 +67,20 @@ * number of bytes consumed from the byte stream. * ******************************************************************************/ - acpi_status -acpi_rs_irq_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_irq_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - u8 i; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( - struct acpi_resource_irq); - - - ACPI_FUNCTION_TRACE ("rs_irq_resource"); + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + u8 index; + u8 i; + acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq); + ACPI_FUNCTION_TRACE("rs_irq_resource"); /* * The number of bytes consumed are contained in the descriptor @@ -101,7 +93,7 @@ acpi_rs_irq_resource ( /* Point to the 16-bits of Bytes 1 and 2 */ buffer += 1; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); output_struct->data.irq.number_of_interrupts = 0; @@ -132,14 +124,18 @@ acpi_rs_irq_resource ( /* Check for HE, LL interrupts */ switch (temp8 & 0x09) { - case 0x01: /* HE */ - output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE; - output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH; + case 0x01: /* HE */ + output_struct->data.irq.edge_level = + ACPI_EDGE_SENSITIVE; + output_struct->data.irq.active_high_low = + ACPI_ACTIVE_HIGH; break; - case 0x08: /* LL */ - output_struct->data.irq.edge_level = ACPI_LEVEL_SENSITIVE; - output_struct->data.irq.active_high_low = ACPI_ACTIVE_LOW; + case 0x08: /* LL */ + output_struct->data.irq.edge_level = + ACPI_LEVEL_SENSITIVE; + output_struct->data.irq.active_high_low = + ACPI_ACTIVE_LOW; break; default: @@ -148,17 +144,16 @@ acpi_rs_irq_resource ( * are allowed (ACPI spec, section "IRQ Format") * so 0x00 and 0x09 are illegal. */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid interrupt polarity/trigger in resource list, %X\n", - temp8)); - return_ACPI_STATUS (AE_BAD_DATA); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid interrupt polarity/trigger in resource list, %X\n", + temp8)); + return_ACPI_STATUS(AE_BAD_DATA); } /* Check for sharable */ output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; - } - else { + } else { /* * Assume Edge Sensitive, Active High, Non-Sharable * per ACPI Specification @@ -175,10 +170,9 @@ acpi_rs_irq_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_irq_stream @@ -196,32 +190,27 @@ acpi_rs_irq_resource ( ******************************************************************************/ acpi_status -acpi_rs_irq_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_irq_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - u8 IRqinfo_byte_needed; - - - ACPI_FUNCTION_TRACE ("rs_irq_stream"); + u8 *buffer = *output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + u8 index; + u8 IRqinfo_byte_needed; + ACPI_FUNCTION_TRACE("rs_irq_stream"); /* * The descriptor field is set based upon whether a third byte is * needed to contain the IRQ Information. */ if (ACPI_EDGE_SENSITIVE == linked_list->data.irq.edge_level && - ACPI_ACTIVE_HIGH == linked_list->data.irq.active_high_low && - ACPI_EXCLUSIVE == linked_list->data.irq.shared_exclusive) { + ACPI_ACTIVE_HIGH == linked_list->data.irq.active_high_low && + ACPI_EXCLUSIVE == linked_list->data.irq.shared_exclusive) { *buffer = 0x22; IRqinfo_byte_needed = FALSE; - } - else { + } else { *buffer = 0x23; IRqinfo_byte_needed = TRUE; } @@ -231,14 +220,13 @@ acpi_rs_irq_stream ( /* Loop through all of the interrupts and set the mask bits */ - for(index = 0; - index < linked_list->data.irq.number_of_interrupts; - index++) { + for (index = 0; + index < linked_list->data.irq.number_of_interrupts; index++) { temp8 = (u8) linked_list->data.irq.interrupts[index]; temp16 |= 0x1 << temp8; } - ACPI_MOVE_16_TO_16 (buffer, &temp16); + ACPI_MOVE_16_TO_16(buffer, &temp16); buffer += 2; /* Set the IRQ Info byte if needed. */ @@ -246,13 +234,12 @@ acpi_rs_irq_stream ( if (IRqinfo_byte_needed) { temp8 = 0; temp8 = (u8) ((linked_list->data.irq.shared_exclusive & - 0x01) << 4); + 0x01) << 4); if (ACPI_LEVEL_SENSITIVE == linked_list->data.irq.edge_level && - ACPI_ACTIVE_LOW == linked_list->data.irq.active_high_low) { + ACPI_ACTIVE_LOW == linked_list->data.irq.active_high_low) { temp8 |= 0x08; - } - else { + } else { temp8 |= 0x01; } @@ -262,11 +249,10 @@ acpi_rs_irq_stream ( /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); - return_ACPI_STATUS (AE_OK); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_extended_irq_resource @@ -289,34 +275,30 @@ acpi_rs_irq_stream ( ******************************************************************************/ acpi_status -acpi_rs_extended_irq_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 *temp_ptr; - u8 index; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( - struct acpi_resource_ext_irq); - - - ACPI_FUNCTION_TRACE ("rs_extended_irq_resource"); + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + u8 *temp_ptr; + u8 index; + acpi_size struct_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq); + ACPI_FUNCTION_TRACE("rs_extended_irq_resource"); /* Point past the Descriptor to get the number of bytes consumed */ buffer += 1; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); /* Validate minimum descriptor length */ if (temp16 < 6) { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); } *bytes_consumed = temp16 + 3; @@ -338,7 +320,7 @@ acpi_rs_extended_irq_resource ( * - Edge/Level are defined opposite in the table vs the headers */ output_struct->data.extended_irq.edge_level = - (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; + (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; /* Check Interrupt Polarity */ @@ -356,7 +338,7 @@ acpi_rs_extended_irq_resource ( /* Must have at least one IRQ */ if (temp8 < 1) { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); } output_struct->data.extended_irq.number_of_interrupts = temp8; @@ -374,8 +356,8 @@ acpi_rs_extended_irq_resource ( /* Cycle through every IRQ in the table */ for (index = 0; index < temp8; index++) { - ACPI_MOVE_32_TO_32 ( - &output_struct->data.extended_irq.interrupts[index], buffer); + ACPI_MOVE_32_TO_32(&output_struct->data.extended_irq. + interrupts[index], buffer); /* Point to the next IRQ */ @@ -393,12 +375,13 @@ acpi_rs_extended_irq_resource ( * we add 1 to the length. */ if (*bytes_consumed > - ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 4) + - (5 + 1)) { + ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * + 4) + (5 + 1)) { /* Dereference the Index */ temp8 = *buffer; - output_struct->data.extended_irq.resource_source.index = (u32) temp8; + output_struct->data.extended_irq.resource_source.index = + (u32) temp8; /* Point to the String */ @@ -407,10 +390,10 @@ acpi_rs_extended_irq_resource ( /* Point the String pointer to the end of this structure. */ output_struct->data.extended_irq.resource_source.string_ptr = - (char *)((char *) output_struct + struct_size); + (char *)((char *)output_struct + struct_size); temp_ptr = (u8 *) - output_struct->data.extended_irq.resource_source.string_ptr; + output_struct->data.extended_irq.resource_source.string_ptr; /* Copy the string into the buffer */ @@ -426,7 +409,8 @@ acpi_rs_extended_irq_resource ( /* Add the terminating null */ *temp_ptr = 0x00; - output_struct->data.extended_irq.resource_source.string_length = index + 1; + output_struct->data.extended_irq.resource_source.string_length = + index + 1; /* * In order for the struct_size to fall on a 32-bit boundary, @@ -434,12 +418,13 @@ acpi_rs_extended_irq_resource ( * struct_size to the next 32-bit boundary. */ temp8 = (u8) (index + 1); - struct_size += ACPI_ROUND_UP_to_32_bITS (temp8); - } - else { + struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); + } else { output_struct->data.extended_irq.resource_source.index = 0x00; - output_struct->data.extended_irq.resource_source.string_length = 0; - output_struct->data.extended_irq.resource_source.string_ptr = NULL; + output_struct->data.extended_irq.resource_source.string_length = + 0; + output_struct->data.extended_irq.resource_source.string_ptr = + NULL; } /* Set the Length parameter */ @@ -449,10 +434,9 @@ acpi_rs_extended_irq_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_extended_irq_stream @@ -470,20 +454,16 @@ acpi_rs_extended_irq_resource ( ******************************************************************************/ acpi_status -acpi_rs_extended_irq_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_extended_irq_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - u16 *length_field; - u8 temp8 = 0; - u8 index; - char *temp_pointer = NULL; - - - ACPI_FUNCTION_TRACE ("rs_extended_irq_stream"); + u8 *buffer = *output_buffer; + u16 *length_field; + u8 temp8 = 0; + u8 index; + char *temp_pointer = NULL; + ACPI_FUNCTION_TRACE("rs_extended_irq_stream"); /* The descriptor field is static */ @@ -492,13 +472,14 @@ acpi_rs_extended_irq_stream ( /* Set a pointer to the Length field - to be filled in later */ - length_field = ACPI_CAST_PTR (u16, buffer); + length_field = ACPI_CAST_PTR(u16, buffer); buffer += 2; /* Set the Interrupt vector flags */ - temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01); - temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3); + temp8 = (u8) (linked_list->data.extended_irq.producer_consumer & 0x01); + temp8 |= + ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3); /* * Set the Interrupt Mode @@ -527,43 +508,48 @@ acpi_rs_extended_irq_stream ( *buffer = temp8; buffer += 1; - for (index = 0; index < linked_list->data.extended_irq.number_of_interrupts; - index++) { - ACPI_MOVE_32_TO_32 (buffer, - &linked_list->data.extended_irq.interrupts[index]); + for (index = 0; + index < linked_list->data.extended_irq.number_of_interrupts; + index++) { + ACPI_MOVE_32_TO_32(buffer, + &linked_list->data.extended_irq. + interrupts[index]); buffer += 4; } /* Resource Source Index and Resource Source are optional */ if (0 != linked_list->data.extended_irq.resource_source.string_length) { - *buffer = (u8) linked_list->data.extended_irq.resource_source.index; + *buffer = + (u8) linked_list->data.extended_irq.resource_source.index; buffer += 1; - temp_pointer = (char *) buffer; + temp_pointer = (char *)buffer; /* Copy the string */ - ACPI_STRCPY (temp_pointer, - linked_list->data.extended_irq.resource_source.string_ptr); + ACPI_STRCPY(temp_pointer, + linked_list->data.extended_irq.resource_source. + string_ptr); /* * Buffer needs to be set to the length of the sting + one for the * terminating null */ - buffer += (acpi_size) (ACPI_STRLEN ( - linked_list->data.extended_irq.resource_source.string_ptr) + 1); + buffer += + (acpi_size) (ACPI_STRLEN + (linked_list->data.extended_irq. + resource_source.string_ptr) + 1); } /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); /* * Set the length field to the number of bytes consumed * minus the header size (3 bytes) */ *length_field = (u16) (*bytes_consumed - 3); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index db7bcb4..103eb31 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c @@ -41,13 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #define _COMPONENT ACPI_RESOURCES - ACPI_MODULE_NAME ("rslist") - +ACPI_MODULE_NAME("rslist") /******************************************************************************* * @@ -61,14 +59,10 @@ * a resource descriptor. * ******************************************************************************/ - -u8 -acpi_rs_get_resource_type ( - u8 resource_start_byte) +u8 acpi_rs_get_resource_type(u8 resource_start_byte) { - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_ENTRY(); /* Determine if this is a small or large resource */ @@ -79,14 +73,12 @@ acpi_rs_get_resource_type ( return ((u8) (resource_start_byte & ACPI_RDESC_SMALL_MASK)); - case ACPI_RDESC_TYPE_LARGE: /* Large Resource Type -- All bits are valid */ return (resource_start_byte); - default: /* Invalid type */ break; @@ -95,7 +87,6 @@ acpi_rs_get_resource_type ( return (0xFF); } - /******************************************************************************* * * FUNCTION: acpi_rs_byte_stream_to_list @@ -113,176 +104,189 @@ acpi_rs_get_resource_type ( ******************************************************************************/ acpi_status -acpi_rs_byte_stream_to_list ( - u8 *byte_stream_buffer, - u32 byte_stream_buffer_length, - u8 *output_buffer) +acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, + u32 byte_stream_buffer_length, u8 * output_buffer) { - acpi_status status; - acpi_size bytes_parsed = 0; - u8 resource_type = 0; - acpi_size bytes_consumed = 0; - u8 *buffer = output_buffer; - acpi_size structure_size = 0; - u8 end_tag_processed = FALSE; - struct acpi_resource *resource; - - ACPI_FUNCTION_TRACE ("rs_byte_stream_to_list"); - - - while (bytes_parsed < byte_stream_buffer_length && - !end_tag_processed) { + acpi_status status; + acpi_size bytes_parsed = 0; + u8 resource_type = 0; + acpi_size bytes_consumed = 0; + u8 *buffer = output_buffer; + acpi_size structure_size = 0; + u8 end_tag_processed = FALSE; + struct acpi_resource *resource; + + ACPI_FUNCTION_TRACE("rs_byte_stream_to_list"); + + while (bytes_parsed < byte_stream_buffer_length && !end_tag_processed) { /* The next byte in the stream is the resource type */ - resource_type = acpi_rs_get_resource_type (*byte_stream_buffer); + resource_type = acpi_rs_get_resource_type(*byte_stream_buffer); switch (resource_type) { case ACPI_RDESC_TYPE_MEMORY_24: /* * 24-Bit Memory Resource */ - status = acpi_rs_memory24_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = acpi_rs_memory24_resource(byte_stream_buffer, + &bytes_consumed, + &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_LARGE_VENDOR: /* * Vendor Defined Resource */ - status = acpi_rs_vendor_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = acpi_rs_vendor_resource(byte_stream_buffer, + &bytes_consumed, + &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_MEMORY_32: /* * 32-Bit Memory Range Resource */ - status = acpi_rs_memory32_range_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = + acpi_rs_memory32_range_resource(byte_stream_buffer, + &bytes_consumed, + &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_FIXED_MEMORY_32: /* * 32-Bit Fixed Memory Resource */ - status = acpi_rs_fixed_memory32_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = + acpi_rs_fixed_memory32_resource(byte_stream_buffer, + &bytes_consumed, + &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE: /* * 64-Bit Address Resource */ - status = acpi_rs_address64_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = acpi_rs_address64_resource(byte_stream_buffer, + &bytes_consumed, + &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: /* * 32-Bit Address Resource */ - status = acpi_rs_address32_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = acpi_rs_address32_resource(byte_stream_buffer, + &bytes_consumed, + &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: /* * 16-Bit Address Resource */ - status = acpi_rs_address16_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = acpi_rs_address16_resource(byte_stream_buffer, + &bytes_consumed, + &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_EXTENDED_XRUPT: /* * Extended IRQ */ - status = acpi_rs_extended_irq_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = + acpi_rs_extended_irq_resource(byte_stream_buffer, + &bytes_consumed, + &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_IRQ_FORMAT: /* * IRQ Resource */ - status = acpi_rs_irq_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = acpi_rs_irq_resource(byte_stream_buffer, + &bytes_consumed, &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_DMA_FORMAT: /* * DMA Resource */ - status = acpi_rs_dma_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = acpi_rs_dma_resource(byte_stream_buffer, + &bytes_consumed, &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_START_DEPENDENT: /* * Start Dependent Functions Resource */ - status = acpi_rs_start_depend_fns_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = + acpi_rs_start_depend_fns_resource + (byte_stream_buffer, &bytes_consumed, &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_END_DEPENDENT: /* * End Dependent Functions Resource */ - status = acpi_rs_end_depend_fns_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = + acpi_rs_end_depend_fns_resource(byte_stream_buffer, + &bytes_consumed, + &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_IO_PORT: /* * IO Port Resource */ - status = acpi_rs_io_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = acpi_rs_io_resource(byte_stream_buffer, + &bytes_consumed, &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_FIXED_IO_PORT: /* * Fixed IO Port Resource */ - status = acpi_rs_fixed_io_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = acpi_rs_fixed_io_resource(byte_stream_buffer, + &bytes_consumed, + &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_SMALL_VENDOR: /* * Vendor Specific Resource */ - status = acpi_rs_vendor_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = acpi_rs_vendor_resource(byte_stream_buffer, + &bytes_consumed, + &buffer, + &structure_size); break; - case ACPI_RDESC_TYPE_END_TAG: /* * End Tag */ end_tag_processed = TRUE; - status = acpi_rs_end_tag_resource (byte_stream_buffer, - &bytes_consumed, &buffer, &structure_size); + status = acpi_rs_end_tag_resource(byte_stream_buffer, + &bytes_consumed, + &buffer, + &structure_size); break; - default: /* * Invalid/Unknown resource type @@ -291,8 +295,8 @@ acpi_rs_byte_stream_to_list ( break; } - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Update the return value and counter */ @@ -305,21 +309,21 @@ acpi_rs_byte_stream_to_list ( /* Set the Buffer to the next structure */ - resource = ACPI_CAST_PTR (struct acpi_resource, buffer); - resource->length = (u32) ACPI_ALIGN_RESOURCE_SIZE (resource->length); - buffer += ACPI_ALIGN_RESOURCE_SIZE (structure_size); + resource = ACPI_CAST_PTR(struct acpi_resource, buffer); + resource->length = + (u32) ACPI_ALIGN_RESOURCE_SIZE(resource->length); + buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size); } /* Check the reason for exiting the while loop */ if (!end_tag_processed) { - return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_list_to_byte_stream @@ -342,19 +346,16 @@ acpi_rs_byte_stream_to_list ( ******************************************************************************/ acpi_status -acpi_rs_list_to_byte_stream ( - struct acpi_resource *linked_list, - acpi_size byte_stream_size_needed, - u8 *output_buffer) +acpi_rs_list_to_byte_stream(struct acpi_resource *linked_list, + acpi_size byte_stream_size_needed, + u8 * output_buffer) { - acpi_status status; - u8 *buffer = output_buffer; - acpi_size bytes_consumed = 0; - u8 done = FALSE; - - - ACPI_FUNCTION_TRACE ("rs_list_to_byte_stream"); + acpi_status status; + u8 *buffer = output_buffer; + acpi_size bytes_consumed = 0; + u8 done = FALSE; + ACPI_FUNCTION_TRACE("rs_list_to_byte_stream"); while (!done) { switch (linked_list->id) { @@ -362,58 +363,72 @@ acpi_rs_list_to_byte_stream ( /* * IRQ Resource */ - status = acpi_rs_irq_stream (linked_list, &buffer, &bytes_consumed); + status = + acpi_rs_irq_stream(linked_list, &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_DMA: /* * DMA Resource */ - status = acpi_rs_dma_stream (linked_list, &buffer, &bytes_consumed); + status = + acpi_rs_dma_stream(linked_list, &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_START_DPF: /* * Start Dependent Functions Resource */ - status = acpi_rs_start_depend_fns_stream (linked_list, - &buffer, &bytes_consumed); + status = acpi_rs_start_depend_fns_stream(linked_list, + &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_END_DPF: /* * End Dependent Functions Resource */ - status = acpi_rs_end_depend_fns_stream (linked_list, - &buffer, &bytes_consumed); + status = acpi_rs_end_depend_fns_stream(linked_list, + &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_IO: /* * IO Port Resource */ - status = acpi_rs_io_stream (linked_list, &buffer, &bytes_consumed); + status = + acpi_rs_io_stream(linked_list, &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_FIXED_IO: /* * Fixed IO Port Resource */ - status = acpi_rs_fixed_io_stream (linked_list, &buffer, &bytes_consumed); + status = + acpi_rs_fixed_io_stream(linked_list, &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_VENDOR: /* * Vendor Defined Resource */ - status = acpi_rs_vendor_stream (linked_list, &buffer, &bytes_consumed); + status = + acpi_rs_vendor_stream(linked_list, &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_END_TAG: /* * End Tag */ - status = acpi_rs_end_tag_stream (linked_list, &buffer, &bytes_consumed); + status = + acpi_rs_end_tag_stream(linked_list, &buffer, + &bytes_consumed); /* An End Tag indicates the end of the Resource Template */ @@ -424,55 +439,60 @@ acpi_rs_list_to_byte_stream ( /* * 24-Bit Memory Resource */ - status = acpi_rs_memory24_stream (linked_list, &buffer, &bytes_consumed); + status = + acpi_rs_memory24_stream(linked_list, &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_MEM32: /* * 32-Bit Memory Range Resource */ - status = acpi_rs_memory32_range_stream (linked_list, &buffer, - &bytes_consumed); + status = + acpi_rs_memory32_range_stream(linked_list, &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_FIXED_MEM32: /* * 32-Bit Fixed Memory Resource */ - status = acpi_rs_fixed_memory32_stream (linked_list, &buffer, - &bytes_consumed); + status = + acpi_rs_fixed_memory32_stream(linked_list, &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_ADDRESS16: /* * 16-Bit Address Descriptor Resource */ - status = acpi_rs_address16_stream (linked_list, &buffer, - &bytes_consumed); + status = acpi_rs_address16_stream(linked_list, &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_ADDRESS32: /* * 32-Bit Address Descriptor Resource */ - status = acpi_rs_address32_stream (linked_list, &buffer, - &bytes_consumed); + status = acpi_rs_address32_stream(linked_list, &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_ADDRESS64: /* * 64-Bit Address Descriptor Resource */ - status = acpi_rs_address64_stream (linked_list, &buffer, - &bytes_consumed); + status = acpi_rs_address64_stream(linked_list, &buffer, + &bytes_consumed); break; case ACPI_RSTYPE_EXT_IRQ: /* * Extended IRQ Resource */ - status = acpi_rs_extended_irq_stream (linked_list, &buffer, - &bytes_consumed); + status = + acpi_rs_extended_irq_stream(linked_list, &buffer, + &bytes_consumed); break; default: @@ -480,15 +500,15 @@ acpi_rs_list_to_byte_stream ( * If we get here, everything is out of sync, * so exit with an error */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid descriptor type (%X) in resource list\n", - linked_list->id)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid descriptor type (%X) in resource list\n", + linked_list->id)); status = AE_BAD_DATA; break; } - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Set the Buffer to point to the open byte */ @@ -497,10 +517,9 @@ acpi_rs_list_to_byte_stream ( /* Point to the next object */ - linked_list = ACPI_PTR_ADD (struct acpi_resource, - linked_list, linked_list->length); + linked_list = ACPI_PTR_ADD(struct acpi_resource, + linked_list, linked_list->length); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c index 91d0207..daba1a1 100644 --- a/drivers/acpi/resources/rsmemory.c +++ b/drivers/acpi/resources/rsmemory.c @@ -41,13 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #define _COMPONENT ACPI_RESOURCES - ACPI_MODULE_NAME ("rsmemory") - +ACPI_MODULE_NAME("rsmemory") /******************************************************************************* * @@ -69,30 +67,25 @@ * number of bytes consumed from the byte stream. * ******************************************************************************/ - acpi_status -acpi_rs_memory24_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_memory24_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( - struct acpi_resource_mem24); - - - ACPI_FUNCTION_TRACE ("rs_memory24_resource"); + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + acpi_size struct_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24); + ACPI_FUNCTION_TRACE("rs_memory24_resource"); /* Point past the Descriptor to get the number of bytes consumed */ buffer += 1; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); buffer += 2; *bytes_consumed = (acpi_size) temp16 + 3; output_struct->id = ACPI_RSTYPE_MEM24; @@ -105,25 +98,25 @@ acpi_rs_memory24_resource ( /* Get min_base_address (Bytes 4-5) */ - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); buffer += 2; output_struct->data.memory24.min_base_address = temp16; /* Get max_base_address (Bytes 6-7) */ - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); buffer += 2; output_struct->data.memory24.max_base_address = temp16; /* Get Alignment (Bytes 8-9) */ - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); buffer += 2; output_struct->data.memory24.alignment = temp16; /* Get range_length (Bytes 10-11) */ - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); output_struct->data.memory24.range_length = temp16; /* Set the Length parameter */ @@ -133,10 +126,9 @@ acpi_rs_memory24_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_memory24_stream @@ -154,18 +146,14 @@ acpi_rs_memory24_resource ( ******************************************************************************/ acpi_status -acpi_rs_memory24_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_memory24_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - - ACPI_FUNCTION_TRACE ("rs_memory24_stream"); + u8 *buffer = *output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + ACPI_FUNCTION_TRACE("rs_memory24_stream"); /* The descriptor field is static */ @@ -175,7 +163,7 @@ acpi_rs_memory24_stream ( /* The length field is static */ temp16 = 0x09; - ACPI_MOVE_16_TO_16 (buffer, &temp16); + ACPI_MOVE_16_TO_16(buffer, &temp16); buffer += 2; /* Set the Information Byte */ @@ -186,31 +174,32 @@ acpi_rs_memory24_stream ( /* Set the Range minimum base address */ - ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.min_base_address); + ACPI_MOVE_32_TO_16(buffer, + &linked_list->data.memory24.min_base_address); buffer += 2; /* Set the Range maximum base address */ - ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.max_base_address); + ACPI_MOVE_32_TO_16(buffer, + &linked_list->data.memory24.max_base_address); buffer += 2; /* Set the base alignment */ - ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.alignment); + ACPI_MOVE_32_TO_16(buffer, &linked_list->data.memory24.alignment); buffer += 2; /* Set the range length */ - ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.range_length); + ACPI_MOVE_32_TO_16(buffer, &linked_list->data.memory24.range_length); buffer += 2; /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); - return_ACPI_STATUS (AE_OK); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_memory32_range_resource @@ -233,28 +222,24 @@ acpi_rs_memory24_stream ( ******************************************************************************/ acpi_status -acpi_rs_memory32_range_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( - struct acpi_resource_mem32); - - - ACPI_FUNCTION_TRACE ("rs_memory32_range_resource"); + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + acpi_size struct_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32); + ACPI_FUNCTION_TRACE("rs_memory32_range_resource"); /* Point past the Descriptor to get the number of bytes consumed */ buffer += 1; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); buffer += 2; *bytes_consumed = (acpi_size) temp16 + 3; @@ -279,22 +264,24 @@ acpi_rs_memory32_range_resource ( /* Get min_base_address (Bytes 4-7) */ - ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.min_base_address, buffer); + ACPI_MOVE_32_TO_32(&output_struct->data.memory32.min_base_address, + buffer); buffer += 4; /* Get max_base_address (Bytes 8-11) */ - ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.max_base_address, buffer); + ACPI_MOVE_32_TO_32(&output_struct->data.memory32.max_base_address, + buffer); buffer += 4; /* Get Alignment (Bytes 12-15) */ - ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.alignment, buffer); + ACPI_MOVE_32_TO_32(&output_struct->data.memory32.alignment, buffer); buffer += 4; /* Get range_length (Bytes 16-19) */ - ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.range_length, buffer); + ACPI_MOVE_32_TO_32(&output_struct->data.memory32.range_length, buffer); /* Set the Length parameter */ @@ -303,10 +290,9 @@ acpi_rs_memory32_range_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_fixed_memory32_resource @@ -329,27 +315,23 @@ acpi_rs_memory32_range_resource ( ******************************************************************************/ acpi_status -acpi_rs_fixed_memory32_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( - struct acpi_resource_fixed_mem32); - - - ACPI_FUNCTION_TRACE ("rs_fixed_memory32_resource"); + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + acpi_size struct_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32); + ACPI_FUNCTION_TRACE("rs_fixed_memory32_resource"); /* Point past the Descriptor to get the number of bytes consumed */ buffer += 1; - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); buffer += 2; *bytes_consumed = (acpi_size) temp16 + 3; @@ -364,13 +346,14 @@ acpi_rs_fixed_memory32_resource ( /* Get range_base_address (Bytes 4-7) */ - ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address, - buffer); + ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32. + range_base_address, buffer); buffer += 4; /* Get range_length (Bytes 8-11) */ - ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_length, buffer); + ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.range_length, + buffer); /* Set the Length parameter */ @@ -379,10 +362,9 @@ acpi_rs_fixed_memory32_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_memory32_range_stream @@ -400,18 +382,14 @@ acpi_rs_fixed_memory32_resource ( ******************************************************************************/ acpi_status -acpi_rs_memory32_range_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_memory32_range_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - - ACPI_FUNCTION_TRACE ("rs_memory32_range_stream"); + u8 *buffer = *output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + ACPI_FUNCTION_TRACE("rs_memory32_range_stream"); /* The descriptor field is static */ @@ -422,7 +400,7 @@ acpi_rs_memory32_range_stream ( temp16 = 0x11; - ACPI_MOVE_16_TO_16 (buffer, &temp16); + ACPI_MOVE_16_TO_16(buffer, &temp16); buffer += 2; /* Set the Information Byte */ @@ -433,31 +411,32 @@ acpi_rs_memory32_range_stream ( /* Set the Range minimum base address */ - ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.min_base_address); + ACPI_MOVE_32_TO_32(buffer, + &linked_list->data.memory32.min_base_address); buffer += 4; /* Set the Range maximum base address */ - ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.max_base_address); + ACPI_MOVE_32_TO_32(buffer, + &linked_list->data.memory32.max_base_address); buffer += 4; /* Set the base alignment */ - ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.alignment); + ACPI_MOVE_32_TO_32(buffer, &linked_list->data.memory32.alignment); buffer += 4; /* Set the range length */ - ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.range_length); + ACPI_MOVE_32_TO_32(buffer, &linked_list->data.memory32.range_length); buffer += 4; /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); - return_ACPI_STATUS (AE_OK); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_fixed_memory32_stream @@ -475,18 +454,14 @@ acpi_rs_memory32_range_stream ( ******************************************************************************/ acpi_status -acpi_rs_fixed_memory32_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_fixed_memory32_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - - ACPI_FUNCTION_TRACE ("rs_fixed_memory32_stream"); + u8 *buffer = *output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + ACPI_FUNCTION_TRACE("rs_fixed_memory32_stream"); /* The descriptor field is static */ @@ -497,30 +472,31 @@ acpi_rs_fixed_memory32_stream ( temp16 = 0x09; - ACPI_MOVE_16_TO_16 (buffer, &temp16); + ACPI_MOVE_16_TO_16(buffer, &temp16); buffer += 2; /* Set the Information Byte */ - temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01); + temp8 = + (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01); *buffer = temp8; buffer += 1; /* Set the Range base address */ - ACPI_MOVE_32_TO_32 (buffer, - &linked_list->data.fixed_memory32.range_base_address); + ACPI_MOVE_32_TO_32(buffer, + &linked_list->data.fixed_memory32. + range_base_address); buffer += 4; /* Set the range length */ - ACPI_MOVE_32_TO_32 (buffer, - &linked_list->data.fixed_memory32.range_length); + ACPI_MOVE_32_TO_32(buffer, + &linked_list->data.fixed_memory32.range_length); buffer += 4; /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); - return_ACPI_STATUS (AE_OK); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + return_ACPI_STATUS(AE_OK); } - diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index a1f1741..7a8a34e 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c @@ -41,13 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #define _COMPONENT ACPI_RESOURCES - ACPI_MODULE_NAME ("rsmisc") - +ACPI_MODULE_NAME("rsmisc") /******************************************************************************* * @@ -69,20 +67,15 @@ * number of bytes consumed from the byte stream. * ******************************************************************************/ - acpi_status -acpi_rs_end_tag_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_end_tag_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - struct acpi_resource *output_struct = (void *) *output_buffer; - acpi_size struct_size = ACPI_RESOURCE_LENGTH; - - - ACPI_FUNCTION_TRACE ("rs_end_tag_resource"); + struct acpi_resource *output_struct = (void *)*output_buffer; + acpi_size struct_size = ACPI_RESOURCE_LENGTH; + ACPI_FUNCTION_TRACE("rs_end_tag_resource"); /* The number of bytes consumed is static */ @@ -99,10 +92,9 @@ acpi_rs_end_tag_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_end_tag_stream @@ -120,17 +112,13 @@ acpi_rs_end_tag_resource ( ******************************************************************************/ acpi_status -acpi_rs_end_tag_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_end_tag_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - u8 temp8 = 0; - - - ACPI_FUNCTION_TRACE ("rs_end_tag_stream"); + u8 *buffer = *output_buffer; + u8 temp8 = 0; + ACPI_FUNCTION_TRACE("rs_end_tag_stream"); /* The descriptor field is static */ @@ -148,11 +136,10 @@ acpi_rs_end_tag_stream ( /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); - return_ACPI_STATUS (AE_OK); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_vendor_resource @@ -175,23 +162,19 @@ acpi_rs_end_tag_stream ( ******************************************************************************/ acpi_status -acpi_rs_vendor_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_vendor_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( - struct acpi_resource_vendor); - - - ACPI_FUNCTION_TRACE ("rs_vendor_resource"); + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + u8 index; + acpi_size struct_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor); + ACPI_FUNCTION_TRACE("rs_vendor_resource"); /* Dereference the Descriptor to find if this is a large or small item. */ @@ -204,7 +187,7 @@ acpi_rs_vendor_resource ( /* Dereference */ - ACPI_MOVE_16_TO_16 (&temp16, buffer); + ACPI_MOVE_16_TO_16(&temp16, buffer); /* Calculate bytes consumed */ @@ -213,11 +196,10 @@ acpi_rs_vendor_resource ( /* Point to the first vendor byte */ buffer += 2; - } - else { + } else { /* Small Item, dereference the size */ - temp16 = (u8)(*buffer & 0x07); + temp16 = (u8) (*buffer & 0x07); /* Calculate bytes consumed */ @@ -241,7 +223,7 @@ acpi_rs_vendor_resource ( * calculate the length of the vendor string and expand the * struct_size to the next 32-bit boundary. */ - struct_size += ACPI_ROUND_UP_to_32_bITS (temp16); + struct_size += ACPI_ROUND_UP_to_32_bITS(temp16); /* Set the Length parameter */ @@ -250,10 +232,9 @@ acpi_rs_vendor_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_vendor_stream @@ -271,23 +252,19 @@ acpi_rs_vendor_resource ( ******************************************************************************/ acpi_status -acpi_rs_vendor_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_vendor_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - - - ACPI_FUNCTION_TRACE ("rs_vendor_stream"); + u8 *buffer = *output_buffer; + u16 temp16 = 0; + u8 temp8 = 0; + u8 index; + ACPI_FUNCTION_TRACE("rs_vendor_stream"); /* Dereference the length to find if this is a large or small item. */ - if(linked_list->data.vendor_specific.length > 7) { + if (linked_list->data.vendor_specific.length > 7) { /* Large Item, Set the descriptor field and length bytes */ *buffer = 0x84; @@ -295,10 +272,9 @@ acpi_rs_vendor_stream ( temp16 = (u16) linked_list->data.vendor_specific.length; - ACPI_MOVE_16_TO_16 (buffer, &temp16); + ACPI_MOVE_16_TO_16(buffer, &temp16); buffer += 2; - } - else { + } else { /* Small Item, Set the descriptor field */ temp8 = 0x70; @@ -310,7 +286,8 @@ acpi_rs_vendor_stream ( /* Loop through all of the Vendor Specific fields */ - for (index = 0; index < linked_list->data.vendor_specific.length; index++) { + for (index = 0; index < linked_list->data.vendor_specific.length; + index++) { temp8 = linked_list->data.vendor_specific.reserved[index]; *buffer = temp8; @@ -319,11 +296,10 @@ acpi_rs_vendor_stream ( /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); - return_ACPI_STATUS (AE_OK); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_start_depend_fns_resource @@ -346,21 +322,18 @@ acpi_rs_vendor_stream ( ******************************************************************************/ acpi_status -acpi_rs_start_depend_fns_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, + acpi_size * structure_size) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - u8 temp8 = 0; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( - struct acpi_resource_start_dpf); - - - ACPI_FUNCTION_TRACE ("rs_start_depend_fns_resource"); + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + u8 temp8 = 0; + acpi_size struct_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf); + ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource"); /* The number of bytes consumed are found in the descriptor (Bits:0-1) */ @@ -378,26 +351,27 @@ acpi_rs_start_depend_fns_resource ( /* Check Compatibility priority */ - output_struct->data.start_dpf.compatibility_priority = temp8 & 0x03; + output_struct->data.start_dpf.compatibility_priority = + temp8 & 0x03; if (3 == output_struct->data.start_dpf.compatibility_priority) { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); + return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); } /* Check Performance/Robustness preference */ - output_struct->data.start_dpf.performance_robustness = (temp8 >> 2) & 0x03; + output_struct->data.start_dpf.performance_robustness = + (temp8 >> 2) & 0x03; if (3 == output_struct->data.start_dpf.performance_robustness) { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); + return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); } - } - else { + } else { output_struct->data.start_dpf.compatibility_priority = - ACPI_ACCEPTABLE_CONFIGURATION; + ACPI_ACCEPTABLE_CONFIGURATION; output_struct->data.start_dpf.performance_robustness = - ACPI_ACCEPTABLE_CONFIGURATION; + ACPI_ACCEPTABLE_CONFIGURATION; } /* Set the Length parameter */ @@ -407,10 +381,9 @@ acpi_rs_start_depend_fns_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_end_depend_fns_resource @@ -433,18 +406,14 @@ acpi_rs_start_depend_fns_resource ( ******************************************************************************/ acpi_status -acpi_rs_end_depend_fns_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size) +acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size) { - struct acpi_resource *output_struct = (void *) *output_buffer; - acpi_size struct_size = ACPI_RESOURCE_LENGTH; - - - ACPI_FUNCTION_TRACE ("rs_end_depend_fns_resource"); + struct acpi_resource *output_struct = (void *)*output_buffer; + acpi_size struct_size = ACPI_RESOURCE_LENGTH; + ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource"); /* The number of bytes consumed is static */ @@ -461,10 +430,9 @@ acpi_rs_end_depend_fns_resource ( /* Return the final size of the structure */ *structure_size = struct_size; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_start_depend_fns_stream @@ -483,39 +451,35 @@ acpi_rs_end_depend_fns_resource ( ******************************************************************************/ acpi_status -acpi_rs_start_depend_fns_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - u8 temp8 = 0; - - - ACPI_FUNCTION_TRACE ("rs_start_depend_fns_stream"); + u8 *buffer = *output_buffer; + u8 temp8 = 0; + ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream"); /* * The descriptor field is set based upon whether a byte is needed * to contain Priority data. */ if (ACPI_ACCEPTABLE_CONFIGURATION == - linked_list->data.start_dpf.compatibility_priority && - ACPI_ACCEPTABLE_CONFIGURATION == - linked_list->data.start_dpf.performance_robustness) { + linked_list->data.start_dpf.compatibility_priority && + ACPI_ACCEPTABLE_CONFIGURATION == + linked_list->data.start_dpf.performance_robustness) { *buffer = 0x30; - } - else { + } else { *buffer = 0x31; buffer += 1; /* Set the Priority Byte Definition */ temp8 = 0; - temp8 = (u8) ((linked_list->data.start_dpf.performance_robustness & - 0x03) << 2); - temp8 |= (linked_list->data.start_dpf.compatibility_priority & - 0x03); + temp8 = + (u8) ((linked_list->data.start_dpf. + performance_robustness & 0x03) << 2); + temp8 |= + (linked_list->data.start_dpf.compatibility_priority & 0x03); *buffer = temp8; } @@ -523,11 +487,10 @@ acpi_rs_start_depend_fns_stream ( /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); - return_ACPI_STATUS (AE_OK); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_rs_end_depend_fns_stream @@ -545,16 +508,12 @@ acpi_rs_start_depend_fns_stream ( ******************************************************************************/ acpi_status -acpi_rs_end_depend_fns_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed) +acpi_rs_end_depend_fns_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed) { - u8 *buffer = *output_buffer; - - - ACPI_FUNCTION_TRACE ("rs_end_depend_fns_stream"); + u8 *buffer = *output_buffer; + ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream"); /* The descriptor field is static */ @@ -563,7 +522,6 @@ acpi_rs_end_depend_fns_stream ( /* Return the number of bytes consumed in this operation */ - *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); - return_ACPI_STATUS (AE_OK); + *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + return_ACPI_STATUS(AE_OK); } - diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index 700cf7d..4446778 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c @@ -41,15 +41,12 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include - #define _COMPONENT ACPI_RESOURCES - ACPI_MODULE_NAME ("rsutils") - +ACPI_MODULE_NAME("rsutils") /******************************************************************************* * @@ -68,42 +65,36 @@ * and the contents of the callers buffer is undefined. * ******************************************************************************/ - acpi_status -acpi_rs_get_prt_method_data ( - acpi_handle handle, - struct acpi_buffer *ret_buffer) +acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) { - union acpi_operand_object *obj_desc; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("rs_get_prt_method_data"); + union acpi_operand_object *obj_desc; + acpi_status status; + ACPI_FUNCTION_TRACE("rs_get_prt_method_data"); /* Parameters guaranteed valid by caller */ /* Execute the method, no parameters */ - status = acpi_ut_evaluate_object (handle, METHOD_NAME__PRT, - ACPI_BTYPE_PACKAGE, &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_evaluate_object(handle, METHOD_NAME__PRT, + ACPI_BTYPE_PACKAGE, &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* * Create a resource linked list from the byte stream buffer that comes * back from the _CRS method execution. */ - status = acpi_rs_create_pci_routing_table (obj_desc, ret_buffer); + status = acpi_rs_create_pci_routing_table(obj_desc, ret_buffer); /* On exit, we must delete the object returned by evaluate_object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_rs_get_crs_method_data @@ -123,25 +114,21 @@ acpi_rs_get_prt_method_data ( ******************************************************************************/ acpi_status -acpi_rs_get_crs_method_data ( - acpi_handle handle, - struct acpi_buffer *ret_buffer) +acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) { - union acpi_operand_object *obj_desc; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("rs_get_crs_method_data"); + union acpi_operand_object *obj_desc; + acpi_status status; + ACPI_FUNCTION_TRACE("rs_get_crs_method_data"); /* Parameters guaranteed valid by caller */ /* Execute the method, no parameters */ - status = acpi_ut_evaluate_object (handle, METHOD_NAME__CRS, - ACPI_BTYPE_BUFFER, &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_evaluate_object(handle, METHOD_NAME__CRS, + ACPI_BTYPE_BUFFER, &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -149,15 +136,14 @@ acpi_rs_get_crs_method_data ( * byte stream buffer that comes back from the _CRS method * execution. */ - status = acpi_rs_create_resource_list (obj_desc, ret_buffer); + status = acpi_rs_create_resource_list(obj_desc, ret_buffer); /* on exit, we must delete the object returned by evaluate_object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_rs_get_prs_method_data @@ -178,25 +164,21 @@ acpi_rs_get_crs_method_data ( #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_rs_get_prs_method_data ( - acpi_handle handle, - struct acpi_buffer *ret_buffer) +acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) { - union acpi_operand_object *obj_desc; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("rs_get_prs_method_data"); + union acpi_operand_object *obj_desc; + acpi_status status; + ACPI_FUNCTION_TRACE("rs_get_prs_method_data"); /* Parameters guaranteed valid by caller */ /* Execute the method, no parameters */ - status = acpi_ut_evaluate_object (handle, METHOD_NAME__PRS, - ACPI_BTYPE_BUFFER, &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_evaluate_object(handle, METHOD_NAME__PRS, + ACPI_BTYPE_BUFFER, &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -204,15 +186,14 @@ acpi_rs_get_prs_method_data ( * byte stream buffer that comes back from the _CRS method * execution. */ - status = acpi_rs_create_resource_list (obj_desc, ret_buffer); + status = acpi_rs_create_resource_list(obj_desc, ret_buffer); /* on exit, we must delete the object returned by evaluate_object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } -#endif /* ACPI_FUTURE_USAGE */ - +#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * @@ -234,25 +215,22 @@ acpi_rs_get_prs_method_data ( ******************************************************************************/ acpi_status -acpi_rs_get_method_data ( - acpi_handle handle, - char *path, - struct acpi_buffer *ret_buffer) +acpi_rs_get_method_data(acpi_handle handle, + char *path, struct acpi_buffer *ret_buffer) { - union acpi_operand_object *obj_desc; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("rs_get_method_data"); + union acpi_operand_object *obj_desc; + acpi_status status; + ACPI_FUNCTION_TRACE("rs_get_method_data"); /* Parameters guaranteed valid by caller */ /* Execute the method, no parameters */ - status = acpi_ut_evaluate_object (handle, path, ACPI_BTYPE_BUFFER, &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ut_evaluate_object(handle, path, ACPI_BTYPE_BUFFER, &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -260,12 +238,12 @@ acpi_rs_get_method_data ( * byte stream buffer that comes back from the method * execution. */ - status = acpi_rs_create_resource_list (obj_desc, ret_buffer); + status = acpi_rs_create_resource_list(obj_desc, ret_buffer); /* On exit, we must delete the object returned by evaluate_object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } /******************************************************************************* @@ -287,18 +265,14 @@ acpi_rs_get_method_data ( ******************************************************************************/ acpi_status -acpi_rs_set_srs_method_data ( - acpi_handle handle, - struct acpi_buffer *in_buffer) +acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *in_buffer) { - struct acpi_parameter_info info; - union acpi_operand_object *params[2]; - acpi_status status; - struct acpi_buffer buffer; - - - ACPI_FUNCTION_TRACE ("rs_set_srs_method_data"); + struct acpi_parameter_info info; + union acpi_operand_object *params[2]; + acpi_status status; + struct acpi_buffer buffer; + ACPI_FUNCTION_TRACE("rs_set_srs_method_data"); /* Parameters guaranteed valid by caller */ @@ -310,24 +284,24 @@ acpi_rs_set_srs_method_data ( * Convert the linked list into a byte stream */ buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; - status = acpi_rs_create_byte_stream (in_buffer->pointer, &buffer); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_rs_create_byte_stream(in_buffer->pointer, &buffer); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Init the param object */ - params[0] = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); + params[0] = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); if (!params[0]) { - acpi_os_free (buffer.pointer); - return_ACPI_STATUS (AE_NO_MEMORY); + acpi_os_free(buffer.pointer); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Set up the parameter object */ - params[0]->buffer.length = (u32) buffer.length; + params[0]->buffer.length = (u32) buffer.length; params[0]->buffer.pointer = buffer.pointer; - params[0]->common.flags = AOPOBJ_DATA_VALID; + params[0]->common.flags = AOPOBJ_DATA_VALID; params[1] = NULL; info.node = handle; @@ -336,18 +310,17 @@ acpi_rs_set_srs_method_data ( /* Execute the method, no return value */ - status = acpi_ns_evaluate_relative (METHOD_NAME__SRS, &info); - if (ACPI_SUCCESS (status)) { + status = acpi_ns_evaluate_relative(METHOD_NAME__SRS, &info); + if (ACPI_SUCCESS(status)) { /* Delete any return object (especially if implicit_return is enabled) */ if (info.return_object) { - acpi_ut_remove_reference (info.return_object); + acpi_ut_remove_reference(info.return_object); } } /* Clean up and return the status from acpi_ns_evaluate_relative */ - acpi_ut_remove_reference (params[0]); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(params[0]); + return_ACPI_STATUS(status); } - diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c index 83c944b..ee5a5c5 100644 --- a/drivers/acpi/resources/rsxface.c +++ b/drivers/acpi/resources/rsxface.c @@ -47,10 +47,9 @@ #include #define _COMPONENT ACPI_RESOURCES - ACPI_MODULE_NAME ("rsxface") +ACPI_MODULE_NAME("rsxface") /* Local macros for 16,32-bit to 64-bit conversion */ - #define ACPI_COPY_FIELD(out, in, field) ((out)->field = (in)->field) #define ACPI_COPY_ADDRESS(out, in) \ ACPI_COPY_FIELD(out, in, resource_type); \ @@ -65,8 +64,6 @@ ACPI_COPY_FIELD(out, in, address_translation_offset); \ ACPI_COPY_FIELD(out, in, address_length); \ ACPI_COPY_FIELD(out, in, resource_source); - - /******************************************************************************* * * FUNCTION: acpi_get_irq_routing_table @@ -89,17 +86,13 @@ * the object indicated by the passed device_handle. * ******************************************************************************/ - acpi_status -acpi_get_irq_routing_table ( - acpi_handle device_handle, - struct acpi_buffer *ret_buffer) +acpi_get_irq_routing_table(acpi_handle device_handle, + struct acpi_buffer *ret_buffer) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_get_irq_routing_table "); + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_get_irq_routing_table "); /* * Must have a valid handle and buffer, So we have to have a handle @@ -108,19 +101,18 @@ acpi_get_irq_routing_table ( * we'll be returning the needed buffer size, so keep going. */ if (!device_handle) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_validate_buffer (ret_buffer); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_validate_buffer(ret_buffer); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_rs_get_prt_method_data (device_handle, ret_buffer); - return_ACPI_STATUS (status); + status = acpi_rs_get_prt_method_data(device_handle, ret_buffer); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_get_current_resources @@ -146,15 +138,12 @@ acpi_get_irq_routing_table ( ******************************************************************************/ acpi_status -acpi_get_current_resources ( - acpi_handle device_handle, - struct acpi_buffer *ret_buffer) +acpi_get_current_resources(acpi_handle device_handle, + struct acpi_buffer *ret_buffer) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_get_current_resources"); + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_get_current_resources"); /* * Must have a valid handle and buffer, So we have to have a handle @@ -163,19 +152,19 @@ acpi_get_current_resources ( * we'll be returning the needed buffer size, so keep going. */ if (!device_handle) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_validate_buffer (ret_buffer); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_validate_buffer(ret_buffer); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_rs_get_crs_method_data (device_handle, ret_buffer); - return_ACPI_STATUS (status); + status = acpi_rs_get_crs_method_data(device_handle, ret_buffer); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_current_resources); +EXPORT_SYMBOL(acpi_get_current_resources); /******************************************************************************* * @@ -200,15 +189,12 @@ EXPORT_SYMBOL(acpi_get_current_resources); #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_get_possible_resources ( - acpi_handle device_handle, - struct acpi_buffer *ret_buffer) +acpi_get_possible_resources(acpi_handle device_handle, + struct acpi_buffer *ret_buffer) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_get_possible_resources"); + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_get_possible_resources"); /* * Must have a valid handle and buffer, So we have to have a handle @@ -217,20 +203,20 @@ acpi_get_possible_resources ( * we'll be returning the needed buffer size, so keep going. */ if (!device_handle) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_validate_buffer (ret_buffer); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_validate_buffer(ret_buffer); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_rs_get_prs_method_data (device_handle, ret_buffer); - return_ACPI_STATUS (status); + status = acpi_rs_get_prs_method_data(device_handle, ret_buffer); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_possible_resources); -#endif /* ACPI_FUTURE_USAGE */ +EXPORT_SYMBOL(acpi_get_possible_resources); +#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * @@ -252,37 +238,33 @@ EXPORT_SYMBOL(acpi_get_possible_resources); ******************************************************************************/ acpi_status -acpi_walk_resources ( - acpi_handle device_handle, - char *path, - ACPI_WALK_RESOURCE_CALLBACK user_function, - void *context) +acpi_walk_resources(acpi_handle device_handle, + char *path, + ACPI_WALK_RESOURCE_CALLBACK user_function, void *context) { - acpi_status status; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - struct acpi_resource *resource; - struct acpi_resource *buffer_end; - - - ACPI_FUNCTION_TRACE ("acpi_walk_resources"); + acpi_status status; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_resource *resource; + struct acpi_resource *buffer_end; + ACPI_FUNCTION_TRACE("acpi_walk_resources"); if (!device_handle || - (ACPI_STRNCMP (path, METHOD_NAME__CRS, sizeof (METHOD_NAME__CRS)) && - ACPI_STRNCMP (path, METHOD_NAME__PRS, sizeof (METHOD_NAME__PRS)))) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + (ACPI_STRNCMP(path, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) && + ACPI_STRNCMP(path, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_rs_get_method_data (device_handle, path, &buffer); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_rs_get_method_data(device_handle, path, &buffer); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Setup pointers */ - resource = (struct acpi_resource *) buffer.pointer; - buffer_end = ACPI_CAST_PTR (struct acpi_resource, - ((u8 *) buffer.pointer + buffer.length)); + resource = (struct acpi_resource *)buffer.pointer; + buffer_end = ACPI_CAST_PTR(struct acpi_resource, + ((u8 *) buffer.pointer + buffer.length)); /* Walk the resource list */ @@ -291,7 +273,7 @@ acpi_walk_resources ( break; } - status = user_function (resource, context); + status = user_function(resource, context); switch (status) { case AE_OK: @@ -318,7 +300,7 @@ acpi_walk_resources ( /* Get the next resource descriptor */ - resource = ACPI_NEXT_RESOURCE (resource); + resource = ACPI_NEXT_RESOURCE(resource); /* Check for end-of-buffer */ @@ -327,13 +309,13 @@ acpi_walk_resources ( } } -cleanup: + cleanup: - acpi_os_free (buffer.pointer); - return_ACPI_STATUS (status); + acpi_os_free(buffer.pointer); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_walk_resources); +EXPORT_SYMBOL(acpi_walk_resources); /******************************************************************************* * @@ -354,30 +336,25 @@ EXPORT_SYMBOL(acpi_walk_resources); ******************************************************************************/ acpi_status -acpi_set_current_resources ( - acpi_handle device_handle, - struct acpi_buffer *in_buffer) +acpi_set_current_resources(acpi_handle device_handle, + struct acpi_buffer *in_buffer) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_set_current_resources"); + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_set_current_resources"); /* Must have a valid handle and buffer */ - if ((!device_handle) || - (!in_buffer) || - (!in_buffer->pointer) || - (!in_buffer->length)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if ((!device_handle) || + (!in_buffer) || (!in_buffer->pointer) || (!in_buffer->length)) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_rs_set_srs_method_data (device_handle, in_buffer); - return_ACPI_STATUS (status); + status = acpi_rs_set_srs_method_data(device_handle, in_buffer); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_set_current_resources); +EXPORT_SYMBOL(acpi_set_current_resources); /****************************************************************************** * @@ -398,41 +375,38 @@ EXPORT_SYMBOL(acpi_set_current_resources); ******************************************************************************/ acpi_status -acpi_resource_to_address64 ( - struct acpi_resource *resource, - struct acpi_resource_address64 *out) +acpi_resource_to_address64(struct acpi_resource *resource, + struct acpi_resource_address64 *out) { - struct acpi_resource_address16 *address16; - struct acpi_resource_address32 *address32; - + struct acpi_resource_address16 *address16; + struct acpi_resource_address32 *address32; switch (resource->id) { case ACPI_RSTYPE_ADDRESS16: - address16 = (struct acpi_resource_address16 *) &resource->data; - ACPI_COPY_ADDRESS (out, address16); + address16 = (struct acpi_resource_address16 *)&resource->data; + ACPI_COPY_ADDRESS(out, address16); break; - case ACPI_RSTYPE_ADDRESS32: - address32 = (struct acpi_resource_address32 *) &resource->data; - ACPI_COPY_ADDRESS (out, address32); + address32 = (struct acpi_resource_address32 *)&resource->data; + ACPI_COPY_ADDRESS(out, address32); break; - case ACPI_RSTYPE_ADDRESS64: /* Simple copy for 64 bit source */ - ACPI_MEMCPY (out, &resource->data, sizeof (struct acpi_resource_address64)); + ACPI_MEMCPY(out, &resource->data, + sizeof(struct acpi_resource_address64)); break; - default: return (AE_BAD_PARAMETER); } return (AE_OK); } + EXPORT_SYMBOL(acpi_resource_to_address64); diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index cbcda30..8a3ea41 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -9,14 +9,10 @@ #include #include /* for acpi_ex_eisa_id_to_string() */ - #define _COMPONENT ACPI_BUS_COMPONENT -ACPI_MODULE_NAME ("scan") - +ACPI_MODULE_NAME("scan") #define STRUCT_TO_INT(s) (*((int*)&s)) - -extern struct acpi_device *acpi_root; - +extern struct acpi_device *acpi_root; #define ACPI_BUS_CLASS "system_bus" #define ACPI_BUS_HID "ACPI_BUS" @@ -27,13 +23,11 @@ static LIST_HEAD(acpi_device_list); DEFINE_SPINLOCK(acpi_device_lock); LIST_HEAD(acpi_wakeup_device_list); -static int -acpi_bus_trim(struct acpi_device *start, - int rmdevice); +static int acpi_bus_trim(struct acpi_device *start, int rmdevice); -static void acpi_device_release(struct kobject * kobj) +static void acpi_device_release(struct kobject *kobj) { - struct acpi_device * dev = container_of(kobj,struct acpi_device,kobj); + struct acpi_device *dev = container_of(kobj, struct acpi_device, kobj); if (dev->pnp.cid_list) kfree(dev->pnp.cid_list); kfree(dev); @@ -41,34 +35,34 @@ static void acpi_device_release(struct kobject * kobj) struct acpi_device_attribute { struct attribute attr; - ssize_t (*show)(struct acpi_device *, char *); - ssize_t (*store)(struct acpi_device *, const char *, size_t); + ssize_t(*show) (struct acpi_device *, char *); + ssize_t(*store) (struct acpi_device *, const char *, size_t); }; typedef void acpi_device_sysfs_files(struct kobject *, - const struct attribute *); + const struct attribute *); static void setup_sys_fs_device_files(struct acpi_device *dev, - acpi_device_sysfs_files *func); + acpi_device_sysfs_files * func); #define create_sysfs_device_files(dev) \ setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_create_file) #define remove_sysfs_device_files(dev) \ setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_remove_file) - #define to_acpi_device(n) container_of(n, struct acpi_device, kobj) #define to_handle_attr(n) container_of(n, struct acpi_device_attribute, attr); static ssize_t acpi_device_attr_show(struct kobject *kobj, - struct attribute *attr, char *buf) + struct attribute *attr, char *buf) { struct acpi_device *device = to_acpi_device(kobj); struct acpi_device_attribute *attribute = to_handle_attr(attr); return attribute->show ? attribute->show(device, buf) : -EIO; } static ssize_t acpi_device_attr_store(struct kobject *kobj, - struct attribute *attr, const char *buf, size_t len) + struct attribute *attr, const char *buf, + size_t len) { struct acpi_device *device = to_acpi_device(kobj); struct acpi_device_attribute *attribute = to_handle_attr(attr); @@ -76,13 +70,13 @@ static ssize_t acpi_device_attr_store(struct kobject *kobj, } static struct sysfs_ops acpi_device_sysfs_ops = { - .show = acpi_device_attr_show, - .store = acpi_device_attr_store, + .show = acpi_device_attr_show, + .store = acpi_device_attr_store, }; static struct kobj_type ktype_acpi_ns = { - .sysfs_ops = &acpi_device_sysfs_ops, - .release = acpi_device_release, + .sysfs_ops = &acpi_device_sysfs_ops, + .release = acpi_device_release, }; static int namespace_hotplug(struct kset *kset, struct kobject *kobj, @@ -110,16 +104,16 @@ static struct kset_hotplug_ops namespace_hotplug_ops = { }; static struct kset acpi_namespace_kset = { - .kobj = { - .name = "namespace", - }, + .kobj = { + .name = "namespace", + }, .subsys = &acpi_subsys, - .ktype = &ktype_acpi_ns, + .ktype = &ktype_acpi_ns, .hotplug_ops = &namespace_hotplug_ops, }; - -static void acpi_device_register(struct acpi_device * device, struct acpi_device * parent) +static void acpi_device_register(struct acpi_device *device, + struct acpi_device *parent) { /* * Linkage @@ -134,14 +128,14 @@ static void acpi_device_register(struct acpi_device * device, struct acpi_device spin_lock(&acpi_device_lock); if (device->parent) { list_add_tail(&device->node, &device->parent->children); - list_add_tail(&device->g_list,&device->parent->g_list); + list_add_tail(&device->g_list, &device->parent->g_list); } else - list_add_tail(&device->g_list,&acpi_device_list); + list_add_tail(&device->g_list, &acpi_device_list); if (device->wakeup.flags.valid) - list_add_tail(&device->wakeup_list,&acpi_wakeup_device_list); + list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list); spin_unlock(&acpi_device_lock); - strlcpy(device->kobj.name,device->pnp.bus_id,KOBJ_NAME_LEN); + strlcpy(device->kobj.name, device->pnp.bus_id, KOBJ_NAME_LEN); if (parent) device->kobj.parent = &parent->kobj; device->kobj.ktype = &ktype_acpi_ns; @@ -150,10 +144,7 @@ static void acpi_device_register(struct acpi_device * device, struct acpi_device create_sysfs_device_files(device); } -static int -acpi_device_unregister ( - struct acpi_device *device, - int type) +static int acpi_device_unregister(struct acpi_device *device, int type) { spin_lock(&acpi_device_lock); if (device->parent) { @@ -172,11 +163,7 @@ acpi_device_unregister ( return 0; } -void -acpi_bus_data_handler ( - acpi_handle handle, - u32 function, - void *context) +void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context) { ACPI_FUNCTION_TRACE("acpi_bus_data_handler"); @@ -185,13 +172,11 @@ acpi_bus_data_handler ( return_VOID; } -static int -acpi_bus_get_power_flags ( - struct acpi_device *device) +static int acpi_bus_get_power_flags(struct acpi_device *device) { - acpi_status status = 0; - acpi_handle handle = NULL; - u32 i = 0; + acpi_status status = 0; + acpi_handle handle = NULL; + u32 i = 0; ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags"); @@ -210,11 +195,11 @@ acpi_bus_get_power_flags ( */ for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) { struct acpi_device_power_state *ps = &device->power.states[i]; - char object_name[5] = {'_','P','R','0'+i,'\0'}; + char object_name[5] = { '_', 'P', 'R', '0' + i, '\0' }; /* Evaluate "_PRx" to se if power resources are referenced */ acpi_evaluate_reference(device->handle, object_name, NULL, - &ps->resources); + &ps->resources); if (ps->resources.count) { device->power.flags.power_resources = 1; ps->flags.valid = 1; @@ -232,7 +217,7 @@ acpi_bus_get_power_flags ( if (ps->resources.count || ps->flags.explicit_set) ps->flags.valid = 1; - ps->power = -1; /* Unknown - driver assigned */ + ps->power = -1; /* Unknown - driver assigned */ ps->latency = -1; /* Unknown - driver assigned */ } @@ -249,13 +234,10 @@ acpi_bus_get_power_flags ( return_VALUE(0); } -int -acpi_match_ids ( - struct acpi_device *device, - char *ids) +int acpi_match_ids(struct acpi_device *device, char *ids) { int error = 0; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; if (device->flags.hardware_id) if (strstr(ids, device->pnp.hardware_id)) @@ -266,27 +248,25 @@ acpi_match_ids ( int i; /* compare multiple _CID entries against driver ids */ - for (i = 0; i < cid_list->count; i++) - { + for (i = 0; i < cid_list->count; i++) { if (strstr(ids, cid_list->id[i].value)) goto Done; } } error = -ENOENT; - Done: + Done: if (buffer.pointer) acpi_os_free(buffer.pointer); return error; } static acpi_status -acpi_bus_extract_wakeup_device_power_package ( - struct acpi_device *device, - union acpi_object *package) +acpi_bus_extract_wakeup_device_power_package(struct acpi_device *device, + union acpi_object *package) { - int i = 0; - union acpi_object *element = NULL; + int i = 0; + union acpi_object *element = NULL; if (!device || !package || (package->package.count < 2)) return AE_BAD_PARAMETER; @@ -296,14 +276,17 @@ acpi_bus_extract_wakeup_device_power_package ( return AE_BAD_PARAMETER; if (element->type == ACPI_TYPE_PACKAGE) { if ((element->package.count < 2) || - (element->package.elements[0].type != ACPI_TYPE_LOCAL_REFERENCE) || - (element->package.elements[1].type != ACPI_TYPE_INTEGER)) + (element->package.elements[0].type != + ACPI_TYPE_LOCAL_REFERENCE) + || (element->package.elements[1].type != ACPI_TYPE_INTEGER)) return AE_BAD_DATA; - device->wakeup.gpe_device = element->package.elements[0].reference.handle; - device->wakeup.gpe_number = (u32)element->package.elements[1].integer.value; - }else if (element->type == ACPI_TYPE_INTEGER) { + device->wakeup.gpe_device = + element->package.elements[0].reference.handle; + device->wakeup.gpe_number = + (u32) element->package.elements[1].integer.value; + } else if (element->type == ACPI_TYPE_INTEGER) { device->wakeup.gpe_number = element->integer.value; - }else + } else return AE_BAD_DATA; element = &(package->package.elements[1]); @@ -316,9 +299,9 @@ acpi_bus_extract_wakeup_device_power_package ( return AE_NO_MEMORY; } device->wakeup.resources.count = package->package.count - 2; - for (i=0; i < device->wakeup.resources.count; i++) { + for (i = 0; i < device->wakeup.resources.count; i++) { element = &(package->package.elements[i + 2]); - if (element->type != ACPI_TYPE_ANY ) { + if (element->type != ACPI_TYPE_ANY) { return AE_BAD_DATA; } @@ -328,13 +311,11 @@ acpi_bus_extract_wakeup_device_power_package ( return AE_OK; } -static int -acpi_bus_get_wakeup_device_flags ( - struct acpi_device *device) +static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device) { - acpi_status status = 0; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - union acpi_object *package = NULL; + acpi_status status = 0; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *package = NULL; ACPI_FUNCTION_TRACE("acpi_bus_get_wakeup_flags"); @@ -345,21 +326,22 @@ acpi_bus_get_wakeup_device_flags ( goto end; } - package = (union acpi_object *) buffer.pointer; + package = (union acpi_object *)buffer.pointer; status = acpi_bus_extract_wakeup_device_power_package(device, package); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _PRW package\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error extracting _PRW package\n")); goto end; } acpi_os_free(buffer.pointer); device->wakeup.flags.valid = 1; - /* Power button, Lid switch always enable wakeup*/ + /* Power button, Lid switch always enable wakeup */ if (!acpi_match_ids(device, "PNP0C0D,PNP0C0C,PNP0C0E")) device->wakeup.flags.run_wake = 1; -end: + end: if (ACPI_FAILURE(status)) device->flags.wake_capable = 0; return_VALUE(0); @@ -368,8 +350,8 @@ end: /* -------------------------------------------------------------------------- ACPI hotplug sysfs device file support -------------------------------------------------------------------------- */ -static ssize_t acpi_eject_store(struct acpi_device *device, - const char *buf, size_t count); +static ssize_t acpi_eject_store(struct acpi_device *device, + const char *buf, size_t count); #define ACPI_DEVICE_ATTR(_name,_mode,_show,_store) \ static struct acpi_device_attribute acpi_device_attr_##_name = \ @@ -383,12 +365,11 @@ ACPI_DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store); * @func: function pointer to create or destroy the device file */ static void -setup_sys_fs_device_files ( - struct acpi_device *dev, - acpi_device_sysfs_files *func) +setup_sys_fs_device_files(struct acpi_device *dev, + acpi_device_sysfs_files * func) { - acpi_status status; - acpi_handle temp = NULL; + acpi_status status; + acpi_handle temp = NULL; /* * If device has _EJ0, 'eject' file is created that is used to trigger @@ -396,11 +377,10 @@ setup_sys_fs_device_files ( */ status = acpi_get_handle(dev->handle, "_EJ0", &temp); if (ACPI_SUCCESS(status)) - (*(func))(&dev->kobj,&acpi_device_attr_eject.attr); + (*(func)) (&dev->kobj, &acpi_device_attr_eject.attr); } -static int -acpi_eject_operation(acpi_handle handle, int lockable) +static int acpi_eject_operation(acpi_handle handle, int lockable) { struct acpi_object_list arg_list; union acpi_object arg; @@ -429,27 +409,25 @@ acpi_eject_operation(acpi_handle handle, int lockable) status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); if (ACPI_FAILURE(status)) { - return(-ENODEV); + return (-ENODEV); } - return(0); + return (0); } - static ssize_t acpi_eject_store(struct acpi_device *device, const char *buf, size_t count) { - int result; - int ret = count; - int islockable; - acpi_status status; - acpi_handle handle; - acpi_object_type type = 0; + int result; + int ret = count; + int islockable; + acpi_status status; + acpi_handle handle; + acpi_object_type type = 0; if ((!count) || (buf[0] != '1')) { return -EINVAL; } - #ifndef FORCE_EJECT if (device->driver == NULL) { ret = -ENODEV; @@ -457,7 +435,7 @@ acpi_eject_store(struct acpi_device *device, const char *buf, size_t count) } #endif status = acpi_get_type(device->handle, &type); - if (ACPI_FAILURE(status) || (!device->flags.ejectable) ) { + if (ACPI_FAILURE(status) || (!device->flags.ejectable)) { ret = -ENODEV; goto err; } @@ -476,18 +454,15 @@ acpi_eject_store(struct acpi_device *device, const char *buf, size_t count) if (result) { ret = -EBUSY; } -err: + err: return ret; } - /* -------------------------------------------------------------------------- Performance Management -------------------------------------------------------------------------- */ -static int -acpi_bus_get_perf_flags ( - struct acpi_device *device) +static int acpi_bus_get_perf_flags(struct acpi_device *device) { device->performance.state = ACPI_STATE_UNKNOWN; return 0; @@ -500,7 +475,6 @@ acpi_bus_get_perf_flags ( static LIST_HEAD(acpi_bus_drivers); static DECLARE_MUTEX(acpi_bus_drivers_lock); - /** * acpi_bus_match * -------------- @@ -508,16 +482,13 @@ static DECLARE_MUTEX(acpi_bus_drivers_lock); * matches the specified driver's criteria. */ static int -acpi_bus_match ( - struct acpi_device *device, - struct acpi_driver *driver) +acpi_bus_match(struct acpi_device *device, struct acpi_driver *driver) { if (driver && driver->ops.match) return driver->ops.match(device, driver); return acpi_match_ids(device, driver->ids); } - /** * acpi_bus_driver_init * -------------------- @@ -525,11 +496,9 @@ acpi_bus_match ( * driver is bound to a device. Invokes the driver's add() and start() ops. */ static int -acpi_bus_driver_init ( - struct acpi_device *device, - struct acpi_driver *driver) +acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_bus_driver_init"); @@ -553,13 +522,12 @@ acpi_bus_driver_init ( * upon possible configuration and currently allocated resources. */ - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Driver successfully bound to device\n")); return_VALUE(0); } -int -acpi_start_single_object ( - struct acpi_device *device) +int acpi_start_single_object(struct acpi_device *device) { int result = 0; struct acpi_driver *driver; @@ -578,16 +546,17 @@ acpi_start_single_object ( return_VALUE(result); } -static int acpi_driver_attach(struct acpi_driver * drv) +static int acpi_driver_attach(struct acpi_driver *drv) { - struct list_head * node, * next; + struct list_head *node, *next; int count = 0; ACPI_FUNCTION_TRACE("acpi_driver_attach"); spin_lock(&acpi_device_lock); list_for_each_safe(node, next, &acpi_device_list) { - struct acpi_device * dev = container_of(node, struct acpi_device, g_list); + struct acpi_device *dev = + container_of(node, struct acpi_device, g_list); if (dev->driver || !dev->status.present) continue; @@ -598,7 +567,8 @@ static int acpi_driver_attach(struct acpi_driver * drv) acpi_start_single_object(dev); atomic_inc(&drv->references); count++; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n", + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Found driver [%s] for device [%s]\n", drv->name, dev->pnp.bus_id)); } } @@ -608,20 +578,21 @@ static int acpi_driver_attach(struct acpi_driver * drv) return_VALUE(count); } -static int acpi_driver_detach(struct acpi_driver * drv) +static int acpi_driver_detach(struct acpi_driver *drv) { - struct list_head * node, * next; + struct list_head *node, *next; ACPI_FUNCTION_TRACE("acpi_driver_detach"); spin_lock(&acpi_device_lock); - list_for_each_safe(node,next,&acpi_device_list) { - struct acpi_device * dev = container_of(node,struct acpi_device,g_list); + list_for_each_safe(node, next, &acpi_device_list) { + struct acpi_device *dev = + container_of(node, struct acpi_device, g_list); if (dev->driver == drv) { spin_unlock(&acpi_device_lock); if (drv->ops.remove) - drv->ops.remove(dev,ACPI_BUS_REMOVAL_NORMAL); + drv->ops.remove(dev, ACPI_BUS_REMOVAL_NORMAL); spin_lock(&acpi_device_lock); dev->driver = NULL; dev->driver_data = NULL; @@ -640,9 +611,7 @@ static int acpi_driver_detach(struct acpi_driver * drv) * number of devices that were claimed by the driver, or a negative * error status for failure. */ -int -acpi_bus_register_driver ( - struct acpi_driver *driver) +int acpi_bus_register_driver(struct acpi_driver *driver) { int count; @@ -661,8 +630,8 @@ acpi_bus_register_driver ( return_VALUE(count); } -EXPORT_SYMBOL(acpi_bus_register_driver); +EXPORT_SYMBOL(acpi_bus_register_driver); /** * acpi_bus_unregister_driver @@ -670,9 +639,7 @@ EXPORT_SYMBOL(acpi_bus_register_driver); * Unregisters a driver with the ACPI bus. Searches the namespace for all * devices that match the driver's criteria and unbinds. */ -int -acpi_bus_unregister_driver ( - struct acpi_driver *driver) +int acpi_bus_unregister_driver(struct acpi_driver *driver) { int error = 0; @@ -685,11 +652,12 @@ acpi_bus_unregister_driver ( spin_lock(&acpi_device_lock); list_del_init(&driver->node); spin_unlock(&acpi_device_lock); - } - } else + } + } else error = -EINVAL; return_VALUE(error); } + EXPORT_SYMBOL(acpi_bus_unregister_driver); /** @@ -698,18 +666,17 @@ EXPORT_SYMBOL(acpi_bus_unregister_driver); * Parses the list of registered drivers looking for a driver applicable for * the specified device. */ -static int -acpi_bus_find_driver ( - struct acpi_device *device) +static int acpi_bus_find_driver(struct acpi_device *device) { - int result = 0; - struct list_head * node, *next; + int result = 0; + struct list_head *node, *next; ACPI_FUNCTION_TRACE("acpi_bus_find_driver"); spin_lock(&acpi_device_lock); - list_for_each_safe(node,next,&acpi_bus_drivers) { - struct acpi_driver * driver = container_of(node,struct acpi_driver,node); + list_for_each_safe(node, next, &acpi_bus_drivers) { + struct acpi_driver *driver = + container_of(node, struct acpi_driver, node); atomic_inc(&driver->references); spin_unlock(&acpi_device_lock); @@ -723,21 +690,18 @@ acpi_bus_find_driver ( } spin_unlock(&acpi_device_lock); - Done: + Done: return_VALUE(result); } - /* -------------------------------------------------------------------------- Device Enumeration -------------------------------------------------------------------------- */ -static int -acpi_bus_get_flags ( - struct acpi_device *device) +static int acpi_bus_get_flags(struct acpi_device *device) { - acpi_status status = AE_OK; - acpi_handle temp = NULL; + acpi_status status = AE_OK; + acpi_handle temp = NULL; ACPI_FUNCTION_TRACE("acpi_bus_get_flags"); @@ -788,11 +752,12 @@ acpi_bus_get_flags ( return_VALUE(0); } -static void acpi_device_get_busid(struct acpi_device * device, acpi_handle handle, int type) +static void acpi_device_get_busid(struct acpi_device *device, + acpi_handle handle, int type) { - char bus_id[5] = {'?',0}; - struct acpi_buffer buffer = {sizeof(bus_id), bus_id}; - int i = 0; + char bus_id[5] = { '?', 0 }; + struct acpi_buffer buffer = { sizeof(bus_id), bus_id }; + int i = 0; /* * Bus ID @@ -824,21 +789,22 @@ static void acpi_device_get_busid(struct acpi_device * device, acpi_handle handl } } -static void acpi_device_set_id(struct acpi_device * device, struct acpi_device * parent, - acpi_handle handle, int type) +static void acpi_device_set_id(struct acpi_device *device, + struct acpi_device *parent, acpi_handle handle, + int type) { - struct acpi_device_info *info; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - char *hid = NULL; - char *uid = NULL; + struct acpi_device_info *info; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + char *hid = NULL; + char *uid = NULL; struct acpi_compatible_id_list *cid_list = NULL; - acpi_status status; + acpi_status status; switch (type) { case ACPI_BUS_TYPE_DEVICE: status = acpi_get_object_info(handle, &buffer); if (ACPI_FAILURE(status)) { - printk("%s: Error reading device info\n",__FUNCTION__); + printk("%s: Error reading device info\n", __FUNCTION__); return; } @@ -904,7 +870,7 @@ static void acpi_device_set_id(struct acpi_device * device, struct acpi_device * acpi_os_free(buffer.pointer); } -static int acpi_device_set_context(struct acpi_device * device, int type) +static int acpi_device_set_context(struct acpi_device *device, int type) { acpi_status status = AE_OK; int result = 0; @@ -916,10 +882,10 @@ static int acpi_device_set_context(struct acpi_device * device, int type) * to be careful with fixed-feature devices as they all attach to the * root object. */ - if (type != ACPI_BUS_TYPE_POWER_BUTTON && + if (type != ACPI_BUS_TYPE_POWER_BUTTON && type != ACPI_BUS_TYPE_SLEEP_BUTTON) { status = acpi_attach_data(device->handle, - acpi_bus_data_handler, device); + acpi_bus_data_handler, device); if (ACPI_FAILURE(status)) { printk("Error attaching device data\n"); @@ -929,12 +895,13 @@ static int acpi_device_set_context(struct acpi_device * device, int type) return result; } -static void acpi_device_get_debug_info(struct acpi_device * device, acpi_handle handle, int type) +static void acpi_device_get_debug_info(struct acpi_device *device, + acpi_handle handle, int type) { #ifdef CONFIG_ACPI_DEBUG_OUTPUT - char *type_string = NULL; - char name[80] = {'?','\0'}; - struct acpi_buffer buffer = {sizeof(name), name}; + char *type_string = NULL; + char name[80] = { '?', '\0' }; + struct acpi_buffer buffer = { sizeof(name), name }; switch (type) { case ACPI_BUS_TYPE_DEVICE: @@ -968,18 +935,14 @@ static void acpi_device_get_debug_info(struct acpi_device * device, acpi_handle } printk(KERN_DEBUG "Found %s %s [%p]\n", type_string, name, handle); -#endif /*CONFIG_ACPI_DEBUG_OUTPUT*/ +#endif /*CONFIG_ACPI_DEBUG_OUTPUT */ } - -static int -acpi_bus_remove ( - struct acpi_device *dev, - int rmdevice) +static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) { - int result = 0; - struct acpi_driver *driver; - + int result = 0; + struct acpi_driver *driver; + ACPI_FUNCTION_TRACE("acpi_bus_remove"); if (!dev) @@ -1012,22 +975,18 @@ acpi_bus_remove ( if ((dev->parent) && (dev->parent->ops.unbind)) dev->parent->ops.unbind(dev); } - + acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); return_VALUE(0); } - static int -acpi_add_single_object ( - struct acpi_device **child, - struct acpi_device *parent, - acpi_handle handle, - int type) +acpi_add_single_object(struct acpi_device **child, + struct acpi_device *parent, acpi_handle handle, int type) { - int result = 0; - struct acpi_device *device = NULL; + int result = 0; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_add_single_object"); @@ -1044,7 +1003,7 @@ acpi_add_single_object ( device->handle = handle; device->parent = parent; - acpi_device_get_busid(device,handle,type); + acpi_device_get_busid(device, handle, type); /* * Flags @@ -1092,7 +1051,7 @@ acpi_add_single_object ( * Hardware ID, Unique ID, & Bus Address * ------------------------------------- */ - acpi_device_set_id(device,parent,handle,type); + acpi_device_set_id(device, parent, handle, type); /* * Power Management @@ -1104,7 +1063,7 @@ acpi_add_single_object ( goto end; } - /* + /* * Wakeup device management *----------------------- */ @@ -1124,12 +1083,12 @@ acpi_add_single_object ( goto end; } - if ((result = acpi_device_set_context(device,type))) + if ((result = acpi_device_set_context(device, type))) goto end; - acpi_device_get_debug_info(device,handle,type); + acpi_device_get_debug_info(device, handle, type); - acpi_device_register(device,parent); + acpi_device_register(device, parent); /* * Bind _ADR-Based Devices @@ -1154,7 +1113,7 @@ acpi_add_single_object ( */ result = acpi_bus_find_driver(device); -end: + end: if (!result) *child = device; else { @@ -1166,17 +1125,15 @@ end: return_VALUE(result); } - -static int acpi_bus_scan (struct acpi_device *start, - struct acpi_bus_ops *ops) +static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) { - acpi_status status = AE_OK; - struct acpi_device *parent = NULL; - struct acpi_device *child = NULL; - acpi_handle phandle = NULL; - acpi_handle chandle = NULL; - acpi_object_type type = 0; - u32 level = 1; + acpi_status status = AE_OK; + struct acpi_device *parent = NULL; + struct acpi_device *child = NULL; + acpi_handle phandle = NULL; + acpi_handle chandle = NULL; + acpi_object_type type = 0; + u32 level = 1; ACPI_FUNCTION_TRACE("acpi_bus_scan"); @@ -1185,7 +1142,7 @@ static int acpi_bus_scan (struct acpi_device *start, parent = start; phandle = start->handle; - + /* * Parse through the ACPI namespace, identify all 'devices', and * create a new 'struct acpi_device' for each. @@ -1193,7 +1150,7 @@ static int acpi_bus_scan (struct acpi_device *start, while ((level > 0) && parent) { status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, - chandle, &chandle); + chandle, &chandle); /* * If this scope is exhausted then move our way back up. @@ -1243,12 +1200,12 @@ static int acpi_bus_scan (struct acpi_device *start, if (ops->acpi_op_add) status = acpi_add_single_object(&child, parent, - chandle, type); - else + chandle, type); + else status = acpi_bus_get_device(chandle, &child); - if (ACPI_FAILURE(status)) - continue; + if (ACPI_FAILURE(status)) + continue; if (ops->acpi_op_start) { status = acpi_start_single_object(child); @@ -1264,7 +1221,7 @@ static int acpi_bus_scan (struct acpi_device *start, * which will be enumerated when the parent is inserted). * * TBD: Need notifications and other detection mechanisms - * in place before we can fully implement this. + * in place before we can fully implement this. */ if (child->status.present) { status = acpi_get_next_object(ACPI_TYPE_ANY, chandle, @@ -1282,11 +1239,8 @@ static int acpi_bus_scan (struct acpi_device *start, } int -acpi_bus_add ( - struct acpi_device **child, - struct acpi_device *parent, - acpi_handle handle, - int type) +acpi_bus_add(struct acpi_device **child, + struct acpi_device *parent, acpi_handle handle, int type) { int result; struct acpi_bus_ops ops; @@ -1301,11 +1255,10 @@ acpi_bus_add ( } return_VALUE(result); } + EXPORT_SYMBOL(acpi_bus_add); -int -acpi_bus_start ( - struct acpi_device *device) +int acpi_bus_start(struct acpi_device *device) { int result; struct acpi_bus_ops ops; @@ -1323,26 +1276,25 @@ acpi_bus_start ( } return_VALUE(result); } + EXPORT_SYMBOL(acpi_bus_start); -static int -acpi_bus_trim(struct acpi_device *start, - int rmdevice) +static int acpi_bus_trim(struct acpi_device *start, int rmdevice) { - acpi_status status; - struct acpi_device *parent, *child; - acpi_handle phandle, chandle; - acpi_object_type type; - u32 level = 1; - int err = 0; - - parent = start; + acpi_status status; + struct acpi_device *parent, *child; + acpi_handle phandle, chandle; + acpi_object_type type; + u32 level = 1; + int err = 0; + + parent = start; phandle = start->handle; child = chandle = NULL; while ((level > 0) && parent && (!err)) { status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, - chandle, &chandle); + chandle, &chandle); /* * If this scope is exhausted then move our way back up. @@ -1381,12 +1333,10 @@ acpi_bus_trim(struct acpi_device *start, return err; } -static int -acpi_bus_scan_fixed ( - struct acpi_device *root) +static int acpi_bus_scan_fixed(struct acpi_device *root) { - int result = 0; - struct acpi_device *device = NULL; + int result = 0; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed"); @@ -1398,14 +1348,16 @@ acpi_bus_scan_fixed ( */ if (acpi_fadt.pwr_button == 0) { result = acpi_add_single_object(&device, acpi_root, - NULL, ACPI_BUS_TYPE_POWER_BUTTON); + NULL, + ACPI_BUS_TYPE_POWER_BUTTON); if (!result) result = acpi_start_single_object(device); } if (acpi_fadt.sleep_button == 0) { result = acpi_add_single_object(&device, acpi_root, - NULL, ACPI_BUS_TYPE_SLEEP_BUTTON); + NULL, + ACPI_BUS_TYPE_SLEEP_BUTTON); if (!result) result = acpi_start_single_object(device); } @@ -1413,7 +1365,6 @@ acpi_bus_scan_fixed ( return_VALUE(result); } - static int __init acpi_scan_init(void) { int result; @@ -1430,7 +1381,7 @@ static int __init acpi_scan_init(void) * Create the root device in the bus's device tree */ result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT, - ACPI_BUS_TYPE_SYSTEM); + ACPI_BUS_TYPE_SYSTEM); if (result) goto Done; @@ -1450,7 +1401,7 @@ static int __init acpi_scan_init(void) if (result) acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); - Done: + Done: return_VALUE(result); } diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c index 186b182..f8538b5 100644 --- a/drivers/acpi/sleep/poweroff.c +++ b/drivers/acpi/sleep/poweroff.c @@ -91,4 +91,4 @@ static int acpi_poweroff_init(void) late_initcall(acpi_poweroff_init); -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM */ diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index a962fc2..09a603f 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c @@ -14,19 +14,17 @@ #include "sleep.h" #define _COMPONENT ACPI_SYSTEM_COMPONENT -ACPI_MODULE_NAME ("sleep") - +ACPI_MODULE_NAME("sleep") #ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP - static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset) { - int i; + int i; ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show"); for (i = 0; i <= ACPI_STATE_S5; i++) { if (sleep_states[i]) { - seq_printf(seq,"S%d ", i); + seq_printf(seq, "S%d ", i); if (i == ACPI_STATE_S4 && acpi_gbl_FACS->S4bios_f) seq_printf(seq, "S4bios "); } @@ -43,24 +41,21 @@ static int acpi_system_sleep_open_fs(struct inode *inode, struct file *file) } static ssize_t -acpi_system_write_sleep ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *ppos) +acpi_system_write_sleep(struct file *file, + const char __user * buffer, size_t count, loff_t * ppos) { - char str[12]; - u32 state = 0; - int error = 0; + char str[12]; + u32 state = 0; + int error = 0; if (count > sizeof(str) - 1) goto Done; - memset(str,0,sizeof(str)); + memset(str, 0, sizeof(str)); if (copy_from_user(str, buffer, count)) return -EFAULT; /* Check for S4 bios request */ - if (!strcmp(str,"4b")) { + if (!strcmp(str, "4b")) { error = acpi_suspend(4); goto Done; } @@ -72,17 +67,17 @@ acpi_system_write_sleep ( } #endif error = acpi_suspend(state); - Done: + Done: return error ? error : count; } -#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ +#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset) { - u32 sec, min, hr; - u32 day, mo, yr; - unsigned char rtc_control = 0; - unsigned long flags; + u32 sec, min, hr; + u32 day, mo, yr; + unsigned char rtc_control = 0; + unsigned long flags; ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show"); @@ -98,13 +93,14 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset) /* ACPI spec: only low 6 its should be cared */ day = CMOS_READ(acpi_gbl_FADT->day_alrm) & 0x3F; else - day = CMOS_READ(RTC_DAY_OF_MONTH); + day = CMOS_READ(RTC_DAY_OF_MONTH); if (acpi_gbl_FADT->mon_alrm) mo = CMOS_READ(acpi_gbl_FADT->mon_alrm); else mo = CMOS_READ(RTC_MONTH); if (acpi_gbl_FADT->century) - yr = CMOS_READ(acpi_gbl_FADT->century) * 100 + CMOS_READ(RTC_YEAR); + yr = CMOS_READ(acpi_gbl_FADT->century) * 100 + + CMOS_READ(RTC_YEAR); else yr = CMOS_READ(RTC_YEAR); @@ -119,33 +115,33 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset) BCD_TO_BIN(yr); } - /* we're trusting the FADT (see above)*/ + /* we're trusting the FADT (see above) */ if (!acpi_gbl_FADT->century) - /* 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 - * - */ + /* 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; - seq_printf(seq,"%4.4u-", yr); - (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo); - (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day); - (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr); - (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min); + seq_printf(seq, "%4.4u-", yr); + (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo); + (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day); + (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr); + (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min); (sec > 59) ? seq_puts(seq, "**\n") : seq_printf(seq, "%2.2u\n", sec); return 0; @@ -156,15 +152,11 @@ static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file) return single_open(file, acpi_system_alarm_seq_show, PDE(inode)->data); } - -static int -get_date_field ( - char **p, - u32 *value) +static int get_date_field(char **p, u32 * value) { - char *next = NULL; - char *string_end = NULL; - int result = -EINVAL; + char *next = NULL; + char *string_end = NULL; + int result = -EINVAL; /* * Try to find delimeter, only to insert null. The end of the @@ -186,26 +178,22 @@ get_date_field ( return result; } - static ssize_t -acpi_system_write_alarm ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *ppos) +acpi_system_write_alarm(struct file *file, + const char __user * buffer, size_t count, loff_t * ppos) { - int result = 0; - char alarm_string[30] = {'\0'}; - char *p = alarm_string; - u32 sec, min, hr, day, mo, yr; - int adjust = 0; - unsigned char rtc_control = 0; + int result = 0; + char alarm_string[30] = { '\0' }; + char *p = alarm_string; + u32 sec, min, hr, day, mo, yr; + int adjust = 0; + unsigned char rtc_control = 0; ACPI_FUNCTION_TRACE("acpi_system_write_alarm"); if (count > sizeof(alarm_string) - 1) return_VALUE(-EINVAL); - + if (copy_from_user(alarm_string, buffer, count)) return_VALUE(-EFAULT); @@ -264,10 +252,10 @@ acpi_system_write_alarm ( } if (adjust) { - yr += CMOS_READ(RTC_YEAR); - mo += CMOS_READ(RTC_MONTH); + yr += CMOS_READ(RTC_YEAR); + mo += CMOS_READ(RTC_MONTH); day += CMOS_READ(RTC_DAY_OF_MONTH); - hr += CMOS_READ(RTC_HOURS); + hr += CMOS_READ(RTC_HOURS); min += CMOS_READ(RTC_MINUTES); sec += CMOS_READ(RTC_SECONDS); } @@ -336,7 +324,7 @@ acpi_system_write_alarm ( if (acpi_gbl_FADT->mon_alrm) CMOS_WRITE(mo, acpi_gbl_FADT->mon_alrm); if (acpi_gbl_FADT->century) - CMOS_WRITE(yr/100, acpi_gbl_FADT->century); + CMOS_WRITE(yr / 100, acpi_gbl_FADT->century); /* enable the rtc alarm interrupt */ rtc_control |= RTC_AIE; CMOS_WRITE(rtc_control, RTC_CONTROL); @@ -350,29 +338,31 @@ acpi_system_write_alarm ( *ppos += count; result = 0; -end: + end: return_VALUE(result ? result : count); } -extern struct list_head acpi_wakeup_device_list; +extern struct list_head acpi_wakeup_device_list; extern spinlock_t acpi_device_lock; static int acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) { - struct list_head * node, * next; + struct list_head *node, *next; seq_printf(seq, "Device Sleep state Status\n"); spin_lock(&acpi_device_lock); list_for_each_safe(node, next, &acpi_wakeup_device_list) { - struct acpi_device * dev = container_of(node, struct acpi_device, wakeup_list); + struct acpi_device *dev = + container_of(node, struct acpi_device, wakeup_list); if (!dev->wakeup.flags.valid) continue; spin_unlock(&acpi_device_lock); seq_printf(seq, "%4s %4d %s%8s\n", - dev->pnp.bus_id, (u32) dev->wakeup.sleep_state, + dev->pnp.bus_id, + (u32) dev->wakeup.sleep_state, dev->wakeup.flags.run_wake ? "*" : "", dev->wakeup.state.enabled ? "enabled" : "disabled"); spin_lock(&acpi_device_lock); @@ -382,19 +372,18 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) } static ssize_t -acpi_system_write_wakeup_device ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *ppos) +acpi_system_write_wakeup_device(struct file *file, + const char __user * buffer, + size_t count, loff_t * ppos) { - struct list_head * node, * next; - char strbuf[5]; - char str[5] = ""; - int len = count; + struct list_head *node, *next; + char strbuf[5]; + char str[5] = ""; + int len = count; struct acpi_device *found_dev = NULL; - if (len > 4) len = 4; + if (len > 4) + len = 4; if (copy_from_user(strbuf, buffer, len)) return -EFAULT; @@ -403,28 +392,36 @@ acpi_system_write_wakeup_device ( spin_lock(&acpi_device_lock); list_for_each_safe(node, next, &acpi_wakeup_device_list) { - struct acpi_device * dev = container_of(node, struct acpi_device, wakeup_list); + struct acpi_device *dev = + container_of(node, struct acpi_device, wakeup_list); if (!dev->wakeup.flags.valid) continue; if (!strncmp(dev->pnp.bus_id, str, 4)) { - dev->wakeup.state.enabled = dev->wakeup.state.enabled ? 0:1; + dev->wakeup.state.enabled = + dev->wakeup.state.enabled ? 0 : 1; found_dev = dev; break; } } if (found_dev) { list_for_each_safe(node, next, &acpi_wakeup_device_list) { - struct acpi_device * dev = container_of(node, - struct acpi_device, wakeup_list); + struct acpi_device *dev = container_of(node, + struct + acpi_device, + wakeup_list); if ((dev != found_dev) && - (dev->wakeup.gpe_number == found_dev->wakeup.gpe_number) && - (dev->wakeup.gpe_device == found_dev->wakeup.gpe_device)) { - printk(KERN_WARNING "ACPI: '%s' and '%s' have the same GPE, " - "can't disable/enable one seperately\n", - dev->pnp.bus_id, found_dev->pnp.bus_id); - dev->wakeup.state.enabled = found_dev->wakeup.state.enabled; + (dev->wakeup.gpe_number == + found_dev->wakeup.gpe_number) + && (dev->wakeup.gpe_device == + found_dev->wakeup.gpe_device)) { + printk(KERN_WARNING + "ACPI: '%s' and '%s' have the same GPE, " + "can't disable/enable one seperately\n", + dev->pnp.bus_id, found_dev->pnp.bus_id); + dev->wakeup.state.enabled = + found_dev->wakeup.state.enabled; } } } @@ -435,37 +432,37 @@ acpi_system_write_wakeup_device ( static int acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file) { - return single_open(file, acpi_system_wakeup_device_seq_show, PDE(inode)->data); + return single_open(file, acpi_system_wakeup_device_seq_show, + PDE(inode)->data); } static struct file_operations acpi_system_wakeup_device_fops = { - .open = acpi_system_wakeup_device_open_fs, - .read = seq_read, - .write = acpi_system_write_wakeup_device, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_system_wakeup_device_open_fs, + .read = seq_read, + .write = acpi_system_write_wakeup_device, + .llseek = seq_lseek, + .release = single_release, }; #ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP static struct file_operations acpi_system_sleep_fops = { - .open = acpi_system_sleep_open_fs, - .read = seq_read, - .write = acpi_system_write_sleep, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_system_sleep_open_fs, + .read = seq_read, + .write = acpi_system_write_sleep, + .llseek = seq_lseek, + .release = single_release, }; -#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ +#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ static struct file_operations acpi_system_alarm_fops = { - .open = acpi_system_alarm_open_fs, - .read = seq_read, - .write = acpi_system_write_alarm, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_system_alarm_open_fs, + .read = seq_read, + .write = acpi_system_write_alarm, + .llseek = seq_lseek, + .release = single_release, }; - -static u32 rtc_handler(void * context) +static u32 rtc_handler(void *context) { acpi_clear_event(ACPI_EVENT_RTC); acpi_disable_event(ACPI_EVENT_RTC, 0); @@ -479,21 +476,27 @@ static int acpi_sleep_proc_init(void) if (acpi_disabled) return 0; - + #ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP /* 'sleep' [R/W] */ - entry = create_proc_entry("sleep", S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); + entry = + create_proc_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR, + acpi_root_dir); if (entry) entry->proc_fops = &acpi_system_sleep_fops; #endif /* 'alarm' [R/W] */ - entry = create_proc_entry("alarm", S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); + entry = + create_proc_entry("alarm", S_IFREG | S_IRUGO | S_IWUSR, + acpi_root_dir); if (entry) entry->proc_fops = &acpi_system_alarm_fops; /* 'wakeup device' [R/W] */ - entry = create_proc_entry("wakeup", S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); + entry = + create_proc_entry("wakeup", S_IFREG | S_IRUGO | S_IWUSR, + acpi_root_dir); if (entry) entry->proc_fops = &acpi_system_wakeup_device_fops; diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c index d9b1999..4134ed4 100644 --- a/drivers/acpi/sleep/wakeup.c +++ b/drivers/acpi/sleep/wakeup.c @@ -12,9 +12,9 @@ #include "sleep.h" #define _COMPONENT ACPI_SYSTEM_COMPONENT -ACPI_MODULE_NAME ("wakeup_devices") +ACPI_MODULE_NAME("wakeup_devices") -extern struct list_head acpi_wakeup_device_list; +extern struct list_head acpi_wakeup_device_list; extern spinlock_t acpi_device_lock; #ifdef CONFIG_ACPI_SLEEP @@ -25,22 +25,21 @@ extern spinlock_t acpi_device_lock; * is higher than requested sleep level */ -void -acpi_enable_wakeup_device_prep( - u8 sleep_state) +void acpi_enable_wakeup_device_prep(u8 sleep_state) { - struct list_head * node, * next; + struct list_head *node, *next; ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_prep"); spin_lock(&acpi_device_lock); list_for_each_safe(node, next, &acpi_wakeup_device_list) { - struct acpi_device * dev = container_of(node, - struct acpi_device, wakeup_list); - - if (!dev->wakeup.flags.valid || - !dev->wakeup.state.enabled || - (sleep_state > (u32) dev->wakeup.sleep_state)) + struct acpi_device *dev = container_of(node, + struct acpi_device, + wakeup_list); + + if (!dev->wakeup.flags.valid || + !dev->wakeup.state.enabled || + (sleep_state > (u32) dev->wakeup.sleep_state)) continue; spin_unlock(&acpi_device_lock); @@ -55,11 +54,9 @@ acpi_enable_wakeup_device_prep( * @sleep_state: ACPI state * Enable all wakup devices's GPE */ -void -acpi_enable_wakeup_device( - u8 sleep_state) +void acpi_enable_wakeup_device(u8 sleep_state) { - struct list_head * node, * next; + struct list_head *node, *next; /* * Caution: this routine must be invoked when interrupt is disabled @@ -68,33 +65,35 @@ acpi_enable_wakeup_device( ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device"); spin_lock(&acpi_device_lock); list_for_each_safe(node, next, &acpi_wakeup_device_list) { - struct acpi_device * dev = container_of(node, - struct acpi_device, wakeup_list); + struct acpi_device *dev = container_of(node, + struct acpi_device, + wakeup_list); /* If users want to disable run-wake GPE, * we only disable it for wake and leave it for runtime */ if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { spin_unlock(&acpi_device_lock); - acpi_set_gpe_type(dev->wakeup.gpe_device, - dev->wakeup.gpe_number, ACPI_GPE_TYPE_RUNTIME); + acpi_set_gpe_type(dev->wakeup.gpe_device, + dev->wakeup.gpe_number, + ACPI_GPE_TYPE_RUNTIME); /* Re-enable it, since set_gpe_type will disable it */ - acpi_enable_gpe(dev->wakeup.gpe_device, - dev->wakeup.gpe_number, ACPI_ISR); + acpi_enable_gpe(dev->wakeup.gpe_device, + dev->wakeup.gpe_number, ACPI_ISR); spin_lock(&acpi_device_lock); continue; } if (!dev->wakeup.flags.valid || - !dev->wakeup.state.enabled || - (sleep_state > (u32) dev->wakeup.sleep_state)) + !dev->wakeup.state.enabled || + (sleep_state > (u32) dev->wakeup.sleep_state)) continue; spin_unlock(&acpi_device_lock); /* run-wake GPE has been enabled */ if (!dev->wakeup.flags.run_wake) - acpi_enable_gpe(dev->wakeup.gpe_device, - dev->wakeup.gpe_number, ACPI_ISR); + acpi_enable_gpe(dev->wakeup.gpe_device, + dev->wakeup.gpe_number, ACPI_ISR); dev->wakeup.state.active = 1; spin_lock(&acpi_device_lock); } @@ -106,43 +105,43 @@ acpi_enable_wakeup_device( * @sleep_state: ACPI state * Disable all wakup devices's GPE and wakeup capability */ -void -acpi_disable_wakeup_device ( - u8 sleep_state) +void acpi_disable_wakeup_device(u8 sleep_state) { - struct list_head * node, * next; + struct list_head *node, *next; ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device"); spin_lock(&acpi_device_lock); list_for_each_safe(node, next, &acpi_wakeup_device_list) { - struct acpi_device * dev = container_of(node, - struct acpi_device, wakeup_list); + struct acpi_device *dev = container_of(node, + struct acpi_device, + wakeup_list); if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { spin_unlock(&acpi_device_lock); - acpi_set_gpe_type(dev->wakeup.gpe_device, - dev->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN); + acpi_set_gpe_type(dev->wakeup.gpe_device, + dev->wakeup.gpe_number, + ACPI_GPE_TYPE_WAKE_RUN); /* Re-enable it, since set_gpe_type will disable it */ - acpi_enable_gpe(dev->wakeup.gpe_device, - dev->wakeup.gpe_number, ACPI_NOT_ISR); + acpi_enable_gpe(dev->wakeup.gpe_device, + dev->wakeup.gpe_number, ACPI_NOT_ISR); spin_lock(&acpi_device_lock); continue; } - if (!dev->wakeup.flags.valid || - !dev->wakeup.state.active || - (sleep_state > (u32) dev->wakeup.sleep_state)) + if (!dev->wakeup.flags.valid || + !dev->wakeup.state.active || + (sleep_state > (u32) dev->wakeup.sleep_state)) continue; spin_unlock(&acpi_device_lock); acpi_disable_wakeup_device_power(dev); /* Never disable run-wake GPE */ if (!dev->wakeup.flags.run_wake) { - acpi_disable_gpe(dev->wakeup.gpe_device, - dev->wakeup.gpe_number, ACPI_NOT_ISR); - acpi_clear_gpe(dev->wakeup.gpe_device, - dev->wakeup.gpe_number, ACPI_NOT_ISR); + acpi_disable_gpe(dev->wakeup.gpe_device, + dev->wakeup.gpe_number, ACPI_NOT_ISR); + acpi_clear_gpe(dev->wakeup.gpe_device, + dev->wakeup.gpe_number, ACPI_NOT_ISR); } dev->wakeup.state.active = 0; spin_lock(&acpi_device_lock); @@ -152,7 +151,7 @@ acpi_disable_wakeup_device ( static int __init acpi_wakeup_device_init(void) { - struct list_head * node, * next; + struct list_head *node, *next; if (acpi_disabled) return 0; @@ -160,16 +159,18 @@ static int __init acpi_wakeup_device_init(void) spin_lock(&acpi_device_lock); list_for_each_safe(node, next, &acpi_wakeup_device_list) { - struct acpi_device * dev = container_of(node, - struct acpi_device, wakeup_list); - + struct acpi_device *dev = container_of(node, + struct acpi_device, + wakeup_list); + /* In case user doesn't load button driver */ if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { spin_unlock(&acpi_device_lock); - acpi_set_gpe_type(dev->wakeup.gpe_device, - dev->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN); - acpi_enable_gpe(dev->wakeup.gpe_device, - dev->wakeup.gpe_number, ACPI_NOT_ISR); + acpi_set_gpe_type(dev->wakeup.gpe_device, + dev->wakeup.gpe_number, + ACPI_GPE_TYPE_WAKE_RUN); + acpi_enable_gpe(dev->wakeup.gpe_device, + dev->wakeup.gpe_number, ACPI_NOT_ISR); dev->wakeup.state.enabled = 1; spin_lock(&acpi_device_lock); } @@ -193,17 +194,19 @@ late_initcall(acpi_wakeup_device_init); */ void acpi_wakeup_gpe_poweroff_prepare(void) { - struct list_head * node, * next; + struct list_head *node, *next; list_for_each_safe(node, next, &acpi_wakeup_device_list) { - struct acpi_device * dev = container_of(node, - struct acpi_device, wakeup_list); + struct acpi_device *dev = container_of(node, + struct acpi_device, + wakeup_list); /* The GPE can wakeup system from S5, don't touch it */ - if ((u32)dev->wakeup.sleep_state == ACPI_STATE_S5) + if ((u32) dev->wakeup.sleep_state == ACPI_STATE_S5) continue; /* acpi_set_gpe_type will automatically disable GPE */ acpi_set_gpe_type(dev->wakeup.gpe_device, - dev->wakeup.gpe_number, ACPI_GPE_TYPE_RUNTIME); + dev->wakeup.gpe_number, + ACPI_GPE_TYPE_RUNTIME); } } diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index 8925a6c..e4308c7 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c @@ -30,10 +30,8 @@ #include - #define _COMPONENT ACPI_SYSTEM_COMPONENT -ACPI_MODULE_NAME ("acpi_system") - +ACPI_MODULE_NAME("acpi_system") #define ACPI_SYSTEM_CLASS "system" #define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver" #define ACPI_SYSTEM_DEVICE_NAME "System" @@ -41,15 +39,13 @@ ACPI_MODULE_NAME ("acpi_system") #define ACPI_SYSTEM_FILE_EVENT "event" #define ACPI_SYSTEM_FILE_DSDT "dsdt" #define ACPI_SYSTEM_FILE_FADT "fadt" - -extern FADT_DESCRIPTOR acpi_fadt; +extern FADT_DESCRIPTOR acpi_fadt; /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ -static int -acpi_system_read_info (struct seq_file *seq, void *offset) +static int acpi_system_read_info(struct seq_file *seq, void *offset) { ACPI_FUNCTION_TRACE("acpi_system_read_info"); @@ -63,28 +59,26 @@ static int acpi_system_info_open_fs(struct inode *inode, struct file *file) } static struct file_operations acpi_system_info_ops = { - .open = acpi_system_info_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_system_info_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; -static ssize_t acpi_system_read_dsdt (struct file*, char __user *, size_t, loff_t*); +static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t, + loff_t *); static struct file_operations acpi_system_dsdt_ops = { - .read = acpi_system_read_dsdt, + .read = acpi_system_read_dsdt, }; static ssize_t -acpi_system_read_dsdt ( - struct file *file, - char __user *buffer, - size_t count, - loff_t *ppos) +acpi_system_read_dsdt(struct file *file, + char __user * buffer, size_t count, loff_t * ppos) { - acpi_status status = AE_OK; - struct acpi_buffer dsdt = {ACPI_ALLOCATE_BUFFER, NULL}; - ssize_t res; + acpi_status status = AE_OK; + struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL }; + ssize_t res; ACPI_FUNCTION_TRACE("acpi_system_read_dsdt"); @@ -99,23 +93,20 @@ acpi_system_read_dsdt ( return_VALUE(res); } - -static ssize_t acpi_system_read_fadt (struct file*, char __user *, size_t, loff_t*); +static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, + loff_t *); static struct file_operations acpi_system_fadt_ops = { - .read = acpi_system_read_fadt, + .read = acpi_system_read_fadt, }; static ssize_t -acpi_system_read_fadt ( - struct file *file, - char __user *buffer, - size_t count, - loff_t *ppos) +acpi_system_read_fadt(struct file *file, + char __user * buffer, size_t count, loff_t * ppos) { - acpi_status status = AE_OK; - struct acpi_buffer fadt = {ACPI_ALLOCATE_BUFFER, NULL}; - ssize_t res; + acpi_status status = AE_OK; + struct acpi_buffer fadt = { ACPI_ALLOCATE_BUFFER, NULL }; + ssize_t res; ACPI_FUNCTION_TRACE("acpi_system_read_fadt"); @@ -130,12 +121,11 @@ acpi_system_read_fadt ( return_VALUE(res); } - -static int __init acpi_system_init (void) +static int __init acpi_system_init(void) { - struct proc_dir_entry *entry; + struct proc_dir_entry *entry; int error = 0; - char * name; + char *name; ACPI_FUNCTION_TRACE("acpi_system_init"); @@ -144,8 +134,7 @@ static int __init acpi_system_init (void) /* 'info' [R] */ name = ACPI_SYSTEM_FILE_INFO; - entry = create_proc_entry(name, - S_IRUGO, acpi_root_dir); + entry = create_proc_entry(name, S_IRUGO, acpi_root_dir); if (!entry) goto Error; else { @@ -157,7 +146,7 @@ static int __init acpi_system_init (void) entry = create_proc_entry(name, S_IRUSR, acpi_root_dir); if (entry) entry->proc_fops = &acpi_system_dsdt_ops; - else + else goto Error; /* 'fadt' [R] */ @@ -168,12 +157,12 @@ static int __init acpi_system_init (void) else goto Error; - Done: + Done: return_VALUE(error); - Error: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' proc fs entry\n", name)); + Error: + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' proc fs entry\n", name)); remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir); remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir); @@ -183,5 +172,4 @@ static int __init acpi_system_init (void) goto Done; } - subsys_initcall(acpi_system_init); diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index fb64bd5..a2bf25b 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -40,25 +40,25 @@ #define ACPI_MAX_TABLES 256 static char *acpi_table_signatures[ACPI_TABLE_COUNT] = { - [ACPI_TABLE_UNKNOWN] = "????", - [ACPI_APIC] = "APIC", - [ACPI_BOOT] = "BOOT", - [ACPI_DBGP] = "DBGP", - [ACPI_DSDT] = "DSDT", - [ACPI_ECDT] = "ECDT", - [ACPI_ETDT] = "ETDT", - [ACPI_FADT] = "FACP", - [ACPI_FACS] = "FACS", - [ACPI_OEMX] = "OEM", - [ACPI_PSDT] = "PSDT", - [ACPI_SBST] = "SBST", - [ACPI_SLIT] = "SLIT", - [ACPI_SPCR] = "SPCR", - [ACPI_SRAT] = "SRAT", - [ACPI_SSDT] = "SSDT", - [ACPI_SPMI] = "SPMI", - [ACPI_HPET] = "HPET", - [ACPI_MCFG] = "MCFG", + [ACPI_TABLE_UNKNOWN] = "????", + [ACPI_APIC] = "APIC", + [ACPI_BOOT] = "BOOT", + [ACPI_DBGP] = "DBGP", + [ACPI_DSDT] = "DSDT", + [ACPI_ECDT] = "ECDT", + [ACPI_ETDT] = "ETDT", + [ACPI_FADT] = "FACP", + [ACPI_FACS] = "FACS", + [ACPI_OEMX] = "OEM", + [ACPI_PSDT] = "PSDT", + [ACPI_SBST] = "SBST", + [ACPI_SLIT] = "SLIT", + [ACPI_SPCR] = "SPCR", + [ACPI_SRAT] = "SRAT", + [ACPI_SSDT] = "SSDT", + [ACPI_SPMI] = "SPMI", + [ACPI_HPET] = "HPET", + [ACPI_MCFG] = "MCFG", }; static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" }; @@ -66,52 +66,44 @@ static char *mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level" }; /* System Description Table (RSDT/XSDT) */ struct acpi_table_sdt { - unsigned long pa; - enum acpi_table_id id; - unsigned long size; + unsigned long pa; + enum acpi_table_id id; + unsigned long size; } __attribute__ ((packed)); -static unsigned long sdt_pa; /* Physical Address */ -static unsigned long sdt_count; /* Table count */ +static unsigned long sdt_pa; /* Physical Address */ +static unsigned long sdt_count; /* Table count */ -static struct acpi_table_sdt sdt_entry[ACPI_MAX_TABLES]; +static struct acpi_table_sdt sdt_entry[ACPI_MAX_TABLES]; -void -acpi_table_print ( - struct acpi_table_header *header, - unsigned long phys_addr) +void acpi_table_print(struct acpi_table_header *header, unsigned long phys_addr) { - char *name = NULL; + char *name = NULL; if (!header) return; /* Some table signatures aren't good table names */ - if (!strncmp((char *) &header->signature, - acpi_table_signatures[ACPI_APIC], - sizeof(header->signature))) { + if (!strncmp((char *)&header->signature, + acpi_table_signatures[ACPI_APIC], + sizeof(header->signature))) { name = "MADT"; - } - else if (!strncmp((char *) &header->signature, - acpi_table_signatures[ACPI_FADT], - sizeof(header->signature))) { + } else if (!strncmp((char *)&header->signature, + acpi_table_signatures[ACPI_FADT], + sizeof(header->signature))) { name = "FADT"; - } - else + } else name = header->signature; - printk(KERN_DEBUG PREFIX "%.4s (v%3.3d %6.6s %8.8s 0x%08x %.4s 0x%08x) @ 0x%p\n", - name, header->revision, header->oem_id, - header->oem_table_id, header->oem_revision, - header->asl_compiler_id, header->asl_compiler_revision, - (void *) phys_addr); + printk(KERN_DEBUG PREFIX + "%.4s (v%3.3d %6.6s %8.8s 0x%08x %.4s 0x%08x) @ 0x%p\n", name, + header->revision, header->oem_id, header->oem_table_id, + header->oem_revision, header->asl_compiler_id, + header->asl_compiler_revision, (void *)phys_addr); } - -void -acpi_table_print_madt_entry ( - acpi_table_entry_header *header) +void acpi_table_print_madt_entry(acpi_table_entry_header * header) { if (!header) return; @@ -119,113 +111,127 @@ acpi_table_print_madt_entry ( switch (header->type) { case ACPI_MADT_LAPIC: - { - struct acpi_table_lapic *p = - (struct acpi_table_lapic*) header; - printk(KERN_INFO PREFIX "LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n", - p->acpi_id, p->id, p->flags.enabled?"enabled":"disabled"); - } + { + struct acpi_table_lapic *p = + (struct acpi_table_lapic *)header; + printk(KERN_INFO PREFIX + "LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n", + p->acpi_id, p->id, + p->flags.enabled ? "enabled" : "disabled"); + } break; case ACPI_MADT_IOAPIC: - { - struct acpi_table_ioapic *p = - (struct acpi_table_ioapic*) header; - printk(KERN_INFO PREFIX "IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n", - p->id, p->address, p->global_irq_base); - } + { + struct acpi_table_ioapic *p = + (struct acpi_table_ioapic *)header; + printk(KERN_INFO PREFIX + "IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n", + p->id, p->address, p->global_irq_base); + } break; case ACPI_MADT_INT_SRC_OVR: - { - struct acpi_table_int_src_ovr *p = - (struct acpi_table_int_src_ovr*) header; - printk(KERN_INFO PREFIX "INT_SRC_OVR (bus %d bus_irq %d global_irq %d %s %s)\n", - p->bus, p->bus_irq, p->global_irq, - mps_inti_flags_polarity[p->flags.polarity], - mps_inti_flags_trigger[p->flags.trigger]); - if(p->flags.reserved) - printk(KERN_INFO PREFIX "INT_SRC_OVR unexpected reserved flags: 0x%x\n", - p->flags.reserved); + { + struct acpi_table_int_src_ovr *p = + (struct acpi_table_int_src_ovr *)header; + printk(KERN_INFO PREFIX + "INT_SRC_OVR (bus %d bus_irq %d global_irq %d %s %s)\n", + p->bus, p->bus_irq, p->global_irq, + mps_inti_flags_polarity[p->flags.polarity], + mps_inti_flags_trigger[p->flags.trigger]); + if (p->flags.reserved) + printk(KERN_INFO PREFIX + "INT_SRC_OVR unexpected reserved flags: 0x%x\n", + p->flags.reserved); - } + } break; case ACPI_MADT_NMI_SRC: - { - struct acpi_table_nmi_src *p = - (struct acpi_table_nmi_src*) header; - printk(KERN_INFO PREFIX "NMI_SRC (%s %s global_irq %d)\n", - mps_inti_flags_polarity[p->flags.polarity], - mps_inti_flags_trigger[p->flags.trigger], p->global_irq); - } + { + struct acpi_table_nmi_src *p = + (struct acpi_table_nmi_src *)header; + printk(KERN_INFO PREFIX + "NMI_SRC (%s %s global_irq %d)\n", + mps_inti_flags_polarity[p->flags.polarity], + mps_inti_flags_trigger[p->flags.trigger], + p->global_irq); + } break; case ACPI_MADT_LAPIC_NMI: - { - struct acpi_table_lapic_nmi *p = - (struct acpi_table_lapic_nmi*) header; - printk(KERN_INFO PREFIX "LAPIC_NMI (acpi_id[0x%02x] %s %s lint[0x%x])\n", - p->acpi_id, - mps_inti_flags_polarity[p->flags.polarity], - mps_inti_flags_trigger[p->flags.trigger], p->lint); - } + { + struct acpi_table_lapic_nmi *p = + (struct acpi_table_lapic_nmi *)header; + printk(KERN_INFO PREFIX + "LAPIC_NMI (acpi_id[0x%02x] %s %s lint[0x%x])\n", + p->acpi_id, + mps_inti_flags_polarity[p->flags.polarity], + mps_inti_flags_trigger[p->flags.trigger], + p->lint); + } break; case ACPI_MADT_LAPIC_ADDR_OVR: - { - struct acpi_table_lapic_addr_ovr *p = - (struct acpi_table_lapic_addr_ovr*) header; - printk(KERN_INFO PREFIX "LAPIC_ADDR_OVR (address[%p])\n", - (void *) (unsigned long) p->address); - } + { + struct acpi_table_lapic_addr_ovr *p = + (struct acpi_table_lapic_addr_ovr *)header; + printk(KERN_INFO PREFIX + "LAPIC_ADDR_OVR (address[%p])\n", + (void *)(unsigned long)p->address); + } break; case ACPI_MADT_IOSAPIC: - { - struct acpi_table_iosapic *p = - (struct acpi_table_iosapic*) header; - printk(KERN_INFO PREFIX "IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n", - p->id, (void *) (unsigned long) p->address, p->global_irq_base); - } + { + struct acpi_table_iosapic *p = + (struct acpi_table_iosapic *)header; + printk(KERN_INFO PREFIX + "IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n", + p->id, (void *)(unsigned long)p->address, + p->global_irq_base); + } break; case ACPI_MADT_LSAPIC: - { - struct acpi_table_lsapic *p = - (struct acpi_table_lsapic*) header; - printk(KERN_INFO PREFIX "LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n", - p->acpi_id, p->id, p->eid, p->flags.enabled?"enabled":"disabled"); - } + { + struct acpi_table_lsapic *p = + (struct acpi_table_lsapic *)header; + printk(KERN_INFO PREFIX + "LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n", + p->acpi_id, p->id, p->eid, + p->flags.enabled ? "enabled" : "disabled"); + } break; case ACPI_MADT_PLAT_INT_SRC: - { - struct acpi_table_plat_int_src *p = - (struct acpi_table_plat_int_src*) header; - printk(KERN_INFO PREFIX "PLAT_INT_SRC (%s %s type[0x%x] id[0x%04x] eid[0x%x] iosapic_vector[0x%x] global_irq[0x%x]\n", - mps_inti_flags_polarity[p->flags.polarity], - mps_inti_flags_trigger[p->flags.trigger], - p->type, p->id, p->eid, p->iosapic_vector, p->global_irq); - } + { + struct acpi_table_plat_int_src *p = + (struct acpi_table_plat_int_src *)header; + printk(KERN_INFO PREFIX + "PLAT_INT_SRC (%s %s type[0x%x] id[0x%04x] eid[0x%x] iosapic_vector[0x%x] global_irq[0x%x]\n", + mps_inti_flags_polarity[p->flags.polarity], + mps_inti_flags_trigger[p->flags.trigger], + p->type, p->id, p->eid, p->iosapic_vector, + p->global_irq); + } break; default: - printk(KERN_WARNING PREFIX "Found unsupported MADT entry (type = 0x%x)\n", - header->type); + printk(KERN_WARNING PREFIX + "Found unsupported MADT entry (type = 0x%x)\n", + header->type); break; } } - static int -acpi_table_compute_checksum ( - void *table_pointer, - unsigned long length) +acpi_table_compute_checksum(void *table_pointer, unsigned long length) { - u8 *p = (u8 *) table_pointer; - unsigned long remains = length; - unsigned long sum = 0; + u8 *p = (u8 *) table_pointer; + unsigned long remains = length; + unsigned long sum = 0; if (!p || !length) return -EINVAL; @@ -241,9 +247,8 @@ acpi_table_compute_checksum ( * for acpi_blacklisted(), acpi_table_get_sdt() */ int __init -acpi_get_table_header_early ( - enum acpi_table_id id, - struct acpi_table_header **header) +acpi_get_table_header_early(enum acpi_table_id id, + struct acpi_table_header **header) { unsigned int i; enum acpi_table_id temp_id; @@ -260,7 +265,7 @@ acpi_get_table_header_early ( if (sdt_entry[i].id != temp_id) continue; *header = (void *) - __acpi_map_table(sdt_entry[i].pa, sdt_entry[i].size); + __acpi_map_table(sdt_entry[i].pa, sdt_entry[i].size); if (!*header) { printk(KERN_WARNING PREFIX "Unable to map %s\n", acpi_table_signatures[temp_id]); @@ -277,14 +282,17 @@ acpi_get_table_header_early ( /* Map the DSDT header via the pointer in the FADT */ if (id == ACPI_DSDT) { - struct fadt_descriptor_rev2 *fadt = (struct fadt_descriptor_rev2 *) *header; + struct fadt_descriptor_rev2 *fadt = + (struct fadt_descriptor_rev2 *)*header; if (fadt->revision == 3 && fadt->Xdsdt) { - *header = (void *) __acpi_map_table(fadt->Xdsdt, - sizeof(struct acpi_table_header)); + *header = (void *)__acpi_map_table(fadt->Xdsdt, + sizeof(struct + acpi_table_header)); } else if (fadt->V1_dsdt) { - *header = (void *) __acpi_map_table(fadt->V1_dsdt, - sizeof(struct acpi_table_header)); + *header = (void *)__acpi_map_table(fadt->V1_dsdt, + sizeof(struct + acpi_table_header)); } else *header = NULL; @@ -296,21 +304,19 @@ acpi_get_table_header_early ( return 0; } - int __init -acpi_table_parse_madt_family ( - enum acpi_table_id id, - unsigned long madt_size, - int entry_id, - acpi_madt_entry_handler handler, - unsigned int max_entries) +acpi_table_parse_madt_family(enum acpi_table_id id, + unsigned long madt_size, + int entry_id, + acpi_madt_entry_handler handler, + unsigned int max_entries) { - void *madt = NULL; - acpi_table_entry_header *entry; - unsigned int count = 0; - unsigned long madt_end; - unsigned int i; + void *madt = NULL; + acpi_table_entry_header *entry; + unsigned int count = 0; + unsigned long madt_end; + unsigned int i; if (!handler) return -EINVAL; @@ -321,7 +327,7 @@ acpi_table_parse_madt_family ( if (sdt_entry[i].id != id) continue; madt = (void *) - __acpi_map_table(sdt_entry[i].pa, sdt_entry[i].size); + __acpi_map_table(sdt_entry[i].pa, sdt_entry[i].size); if (!madt) { printk(KERN_WARNING PREFIX "Unable to map %s\n", acpi_table_signatures[id]); @@ -336,21 +342,22 @@ acpi_table_parse_madt_family ( return -ENODEV; } - madt_end = (unsigned long) madt + sdt_entry[i].size; + madt_end = (unsigned long)madt + sdt_entry[i].size; /* Parse all entries looking for a match. */ entry = (acpi_table_entry_header *) - ((unsigned long) madt + madt_size); + ((unsigned long)madt + madt_size); - while (((unsigned long) entry) + sizeof(acpi_table_entry_header) < madt_end) { - if (entry->type == entry_id && - (!max_entries || count++ < max_entries)) + while (((unsigned long)entry) + sizeof(acpi_table_entry_header) < + madt_end) { + if (entry->type == entry_id + && (!max_entries || count++ < max_entries)) if (handler(entry, madt_end)) return -EINVAL; entry = (acpi_table_entry_header *) - ((unsigned long) entry + entry->length); + ((unsigned long)entry + entry->length); } if (max_entries && count > max_entries) { printk(KERN_WARNING PREFIX "[%s:0x%02x] ignored %i entries of " @@ -361,25 +368,19 @@ acpi_table_parse_madt_family ( return count; } - int __init -acpi_table_parse_madt ( - enum acpi_madt_entry_id id, - acpi_madt_entry_handler handler, - unsigned int max_entries) +acpi_table_parse_madt(enum acpi_madt_entry_id id, + acpi_madt_entry_handler handler, unsigned int max_entries) { - return acpi_table_parse_madt_family(ACPI_APIC, sizeof(struct acpi_table_madt), - id, handler, max_entries); + return acpi_table_parse_madt_family(ACPI_APIC, + sizeof(struct acpi_table_madt), id, + handler, max_entries); } - -int __init -acpi_table_parse ( - enum acpi_table_id id, - acpi_table_handler handler) +int __init acpi_table_parse(enum acpi_table_id id, acpi_table_handler handler) { - int count = 0; - unsigned int i = 0; + int count = 0; + unsigned int i = 0; if (!handler) return -EINVAL; @@ -392,20 +393,18 @@ acpi_table_parse ( handler(sdt_entry[i].pa, sdt_entry[i].size); else - printk(KERN_WARNING PREFIX "%d duplicate %s table ignored.\n", - count, acpi_table_signatures[id]); + printk(KERN_WARNING PREFIX + "%d duplicate %s table ignored.\n", count, + acpi_table_signatures[id]); } return count; } - -static int __init -acpi_table_get_sdt ( - struct acpi_table_rsdp *rsdp) +static int __init acpi_table_get_sdt(struct acpi_table_rsdp *rsdp) { struct acpi_table_header *header = NULL; - unsigned int i, id = 0; + unsigned int i, id = 0; if (!rsdp) return -EINVAL; @@ -413,24 +412,25 @@ acpi_table_get_sdt ( /* First check XSDT (but only on ACPI 2.0-compatible systems) */ if ((rsdp->revision >= 2) && - (((struct acpi20_table_rsdp*)rsdp)->xsdt_address)) { - - struct acpi_table_xsdt *mapped_xsdt = NULL; + (((struct acpi20_table_rsdp *)rsdp)->xsdt_address)) { + + struct acpi_table_xsdt *mapped_xsdt = NULL; - sdt_pa = ((struct acpi20_table_rsdp*)rsdp)->xsdt_address; + sdt_pa = ((struct acpi20_table_rsdp *)rsdp)->xsdt_address; /* map in just the header */ header = (struct acpi_table_header *) - __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header)); + __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header)); if (!header) { - printk(KERN_WARNING PREFIX "Unable to map XSDT header\n"); + printk(KERN_WARNING PREFIX + "Unable to map XSDT header\n"); return -ENODEV; } /* remap in the entire table before processing */ mapped_xsdt = (struct acpi_table_xsdt *) - __acpi_map_table(sdt_pa, header->length); + __acpi_map_table(sdt_pa, header->length); if (!mapped_xsdt) { printk(KERN_WARNING PREFIX "Unable to map XSDT\n"); return -ENODEV; @@ -438,7 +438,8 @@ acpi_table_get_sdt ( header = &mapped_xsdt->header; if (strncmp(header->signature, "XSDT", 4)) { - printk(KERN_WARNING PREFIX "XSDT signature incorrect\n"); + printk(KERN_WARNING PREFIX + "XSDT signature incorrect\n"); return -ENODEV; } @@ -447,36 +448,39 @@ acpi_table_get_sdt ( return -ENODEV; } - sdt_count = (header->length - sizeof(struct acpi_table_header)) >> 3; + sdt_count = + (header->length - sizeof(struct acpi_table_header)) >> 3; if (sdt_count > ACPI_MAX_TABLES) { - printk(KERN_WARNING PREFIX "Truncated %lu XSDT entries\n", - (sdt_count - ACPI_MAX_TABLES)); + printk(KERN_WARNING PREFIX + "Truncated %lu XSDT entries\n", + (sdt_count - ACPI_MAX_TABLES)); sdt_count = ACPI_MAX_TABLES; } for (i = 0; i < sdt_count; i++) - sdt_entry[i].pa = (unsigned long) mapped_xsdt->entry[i]; + sdt_entry[i].pa = (unsigned long)mapped_xsdt->entry[i]; } /* Then check RSDT */ else if (rsdp->rsdt_address) { - struct acpi_table_rsdt *mapped_rsdt = NULL; + struct acpi_table_rsdt *mapped_rsdt = NULL; sdt_pa = rsdp->rsdt_address; /* map in just the header */ header = (struct acpi_table_header *) - __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header)); + __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header)); if (!header) { - printk(KERN_WARNING PREFIX "Unable to map RSDT header\n"); + printk(KERN_WARNING PREFIX + "Unable to map RSDT header\n"); return -ENODEV; } /* remap in the entire table before processing */ mapped_rsdt = (struct acpi_table_rsdt *) - __acpi_map_table(sdt_pa, header->length); + __acpi_map_table(sdt_pa, header->length); if (!mapped_rsdt) { printk(KERN_WARNING PREFIX "Unable to map RSDT\n"); return -ENODEV; @@ -484,7 +488,8 @@ acpi_table_get_sdt ( header = &mapped_rsdt->header; if (strncmp(header->signature, "RSDT", 4)) { - printk(KERN_WARNING PREFIX "RSDT signature incorrect\n"); + printk(KERN_WARNING PREFIX + "RSDT signature incorrect\n"); return -ENODEV; } @@ -493,19 +498,22 @@ acpi_table_get_sdt ( return -ENODEV; } - sdt_count = (header->length - sizeof(struct acpi_table_header)) >> 2; + sdt_count = + (header->length - sizeof(struct acpi_table_header)) >> 2; if (sdt_count > ACPI_MAX_TABLES) { - printk(KERN_WARNING PREFIX "Truncated %lu RSDT entries\n", - (sdt_count - ACPI_MAX_TABLES)); + printk(KERN_WARNING PREFIX + "Truncated %lu RSDT entries\n", + (sdt_count - ACPI_MAX_TABLES)); sdt_count = ACPI_MAX_TABLES; } for (i = 0; i < sdt_count; i++) - sdt_entry[i].pa = (unsigned long) mapped_rsdt->entry[i]; + sdt_entry[i].pa = (unsigned long)mapped_rsdt->entry[i]; } else { - printk(KERN_WARNING PREFIX "No System Description Table (RSDT/XSDT) specified in RSDP\n"); + printk(KERN_WARNING PREFIX + "No System Description Table (RSDT/XSDT) specified in RSDP\n"); return -ENODEV; } @@ -515,18 +523,17 @@ acpi_table_get_sdt ( /* map in just the header */ header = (struct acpi_table_header *) - __acpi_map_table(sdt_entry[i].pa, - sizeof(struct acpi_table_header)); + __acpi_map_table(sdt_entry[i].pa, + sizeof(struct acpi_table_header)); if (!header) continue; /* remap in the entire table before processing */ header = (struct acpi_table_header *) - __acpi_map_table(sdt_entry[i].pa, - header->length); + __acpi_map_table(sdt_entry[i].pa, header->length); if (!header) continue; - + acpi_table_print(header, sdt_entry[i].pa); if (acpi_table_compute_checksum(header, header->length)) { @@ -537,9 +544,9 @@ acpi_table_get_sdt ( sdt_entry[i].size = header->length; for (id = 0; id < ACPI_TABLE_COUNT; id++) { - if (!strncmp((char *) &header->signature, - acpi_table_signatures[id], - sizeof(header->signature))) { + if (!strncmp((char *)&header->signature, + acpi_table_signatures[id], + sizeof(header->signature))) { sdt_entry[i].id = id; } } @@ -551,7 +558,7 @@ acpi_table_get_sdt ( * against. Unfortunately, we don't know the phys_addr, so just * print 0. Maybe no one will notice. */ - if(!acpi_get_table_header_early(ACPI_DSDT, &header)) + if (!acpi_get_table_header_early(ACPI_DSDT, &header)) acpi_table_print(header, 0); return 0; @@ -566,12 +573,11 @@ acpi_table_get_sdt ( * result: sdt_entry[] is initialized */ -int __init -acpi_table_init (void) +int __init acpi_table_init(void) { - struct acpi_table_rsdp *rsdp = NULL; - unsigned long rsdp_phys = 0; - int result = 0; + struct acpi_table_rsdp *rsdp = NULL; + unsigned long rsdp_phys = 0; + int result = 0; /* Locate and map the Root System Description Table (RSDP) */ @@ -581,19 +587,25 @@ acpi_table_init (void) return -ENODEV; } - rsdp = (struct acpi_table_rsdp *) __va(rsdp_phys); + rsdp = (struct acpi_table_rsdp *)__va(rsdp_phys); if (!rsdp) { printk(KERN_WARNING PREFIX "Unable to map RSDP\n"); return -ENODEV; } - printk(KERN_DEBUG PREFIX "RSDP (v%3.3d %6.6s ) @ 0x%p\n", - rsdp->revision, rsdp->oem_id, (void *) rsdp_phys); + printk(KERN_DEBUG PREFIX + "RSDP (v%3.3d %6.6s ) @ 0x%p\n", + rsdp->revision, rsdp->oem_id, (void *)rsdp_phys); if (rsdp->revision < 2) - result = acpi_table_compute_checksum(rsdp, sizeof(struct acpi_table_rsdp)); + result = + acpi_table_compute_checksum(rsdp, + sizeof(struct acpi_table_rsdp)); else - result = acpi_table_compute_checksum(rsdp, ((struct acpi20_table_rsdp *)rsdp)->length); + result = + acpi_table_compute_checksum(rsdp, + ((struct acpi20_table_rsdp *) + rsdp)->length); if (result) { printk(KERN_WARNING " >>> ERROR: Invalid checksum\n"); diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c index d4ff71f..a039393 100644 --- a/drivers/acpi/tables/tbconvrt.c +++ b/drivers/acpi/tables/tbconvrt.c @@ -46,28 +46,22 @@ #include #include - #define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbconvrt") +ACPI_MODULE_NAME("tbconvrt") /* Local prototypes */ - static void -acpi_tb_init_generic_address ( - struct acpi_generic_address *new_gas_struct, - u8 register_bit_width, - acpi_physical_address address); +acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct, + u8 register_bit_width, + acpi_physical_address address); static void -acpi_tb_convert_fadt1 ( - struct fadt_descriptor_rev2 *local_fadt, - struct fadt_descriptor_rev1 *original_fadt); +acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt, + struct fadt_descriptor_rev1 *original_fadt); static void -acpi_tb_convert_fadt2 ( - struct fadt_descriptor_rev2 *local_fadt, - struct fadt_descriptor_rev2 *original_fadt); - +acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt, + struct fadt_descriptor_rev2 *original_fadt); u8 acpi_fadt_is_v1; EXPORT_SYMBOL(acpi_fadt_is_v1); @@ -87,23 +81,19 @@ EXPORT_SYMBOL(acpi_fadt_is_v1); ******************************************************************************/ u32 -acpi_tb_get_table_count ( - struct rsdp_descriptor *RSDP, - struct acpi_table_header *RSDT) +acpi_tb_get_table_count(struct rsdp_descriptor *RSDP, + struct acpi_table_header *RSDT) { - u32 pointer_size; - - - ACPI_FUNCTION_ENTRY (); + u32 pointer_size; + ACPI_FUNCTION_ENTRY(); /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { - pointer_size = sizeof (u32); - } - else { - pointer_size = sizeof (u64); + pointer_size = sizeof(u32); + } else { + pointer_size = sizeof(u64); } /* @@ -112,10 +102,10 @@ acpi_tb_get_table_count ( * pointers contained within the RSDT/XSDT. The size of the pointers * is architecture-dependent. */ - return ((RSDT->length - sizeof (struct acpi_table_header)) / pointer_size); + return ((RSDT->length - + sizeof(struct acpi_table_header)) / pointer_size); } - /******************************************************************************* * * FUNCTION: acpi_tb_convert_to_xsdt @@ -128,33 +118,30 @@ acpi_tb_get_table_count ( * ******************************************************************************/ -acpi_status -acpi_tb_convert_to_xsdt ( - struct acpi_table_desc *table_info) +acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info) { - acpi_size table_size; - u32 i; - XSDT_DESCRIPTOR *new_table; - - - ACPI_FUNCTION_ENTRY (); + acpi_size table_size; + u32 i; + XSDT_DESCRIPTOR *new_table; + ACPI_FUNCTION_ENTRY(); /* Compute size of the converted XSDT */ - table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof (u64)) + - sizeof (struct acpi_table_header); + table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof(u64)) + + sizeof(struct acpi_table_header); /* Allocate an XSDT */ - new_table = ACPI_MEM_CALLOCATE (table_size); + new_table = ACPI_MEM_CALLOCATE(table_size); if (!new_table) { return (AE_NO_MEMORY); } /* Copy the header and set the length */ - ACPI_MEMCPY (new_table, table_info->pointer, sizeof (struct acpi_table_header)); + ACPI_MEMCPY(new_table, table_info->pointer, + sizeof(struct acpi_table_header)); new_table->length = (u32) table_size; /* Copy the table pointers */ @@ -163,31 +150,33 @@ acpi_tb_convert_to_xsdt ( /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { - ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], - (ACPI_CAST_PTR (struct rsdt_descriptor_rev1, - table_info->pointer))->table_offset_entry[i]); - } - else { + ACPI_STORE_ADDRESS(new_table->table_offset_entry[i], + (ACPI_CAST_PTR + (struct rsdt_descriptor_rev1, + table_info->pointer))-> + table_offset_entry[i]); + } else { new_table->table_offset_entry[i] = - (ACPI_CAST_PTR (XSDT_DESCRIPTOR, - table_info->pointer))->table_offset_entry[i]; + (ACPI_CAST_PTR(XSDT_DESCRIPTOR, + table_info->pointer))-> + table_offset_entry[i]; } } /* Delete the original table (either mapped or in a buffer) */ - acpi_tb_delete_single_table (table_info); + acpi_tb_delete_single_table(table_info); /* Point the table descriptor to the new table */ - table_info->pointer = ACPI_CAST_PTR (struct acpi_table_header, new_table); - table_info->length = table_size; - table_info->allocation = ACPI_MEM_ALLOCATED; + table_info->pointer = + ACPI_CAST_PTR(struct acpi_table_header, new_table); + table_info->length = table_size; + table_info->allocation = ACPI_MEM_ALLOCATED; return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_tb_init_generic_address @@ -203,21 +192,19 @@ acpi_tb_convert_to_xsdt ( ******************************************************************************/ static void -acpi_tb_init_generic_address ( - struct acpi_generic_address *new_gas_struct, - u8 register_bit_width, - acpi_physical_address address) +acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct, + u8 register_bit_width, + acpi_physical_address address) { - ACPI_STORE_ADDRESS (new_gas_struct->address, address); + ACPI_STORE_ADDRESS(new_gas_struct->address, address); new_gas_struct->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO; new_gas_struct->register_bit_width = register_bit_width; new_gas_struct->register_bit_offset = 0; - new_gas_struct->access_width = 0; + new_gas_struct->access_width = 0; } - /******************************************************************************* * * FUNCTION: acpi_tb_convert_fadt1 @@ -232,9 +219,8 @@ acpi_tb_init_generic_address ( ******************************************************************************/ static void -acpi_tb_convert_fadt1 ( - struct fadt_descriptor_rev2 *local_fadt, - struct fadt_descriptor_rev1 *original_fadt) +acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt, + struct fadt_descriptor_rev1 *original_fadt) { /* ACPI 1.0 FACS */ @@ -247,12 +233,14 @@ acpi_tb_convert_fadt1 ( * The 2.0 table is an extension of the 1.0 table, so the entire 1.0 * table can be copied first, then expand some fields to 64 bits. */ - ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev1)); + ACPI_MEMCPY(local_fadt, original_fadt, + sizeof(struct fadt_descriptor_rev1)); /* Convert table pointers to 64-bit fields */ - ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, local_fadt->V1_firmware_ctrl); - ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt); + ACPI_STORE_ADDRESS(local_fadt->xfirmware_ctrl, + local_fadt->V1_firmware_ctrl); + ACPI_STORE_ADDRESS(local_fadt->Xdsdt, local_fadt->V1_dsdt); /* * System Interrupt Model isn't used in ACPI 2.0 @@ -287,17 +275,17 @@ acpi_tb_convert_fadt1 ( * It primarily adds the FADT reset mechanism. */ if ((original_fadt->revision == 2) && - (original_fadt->length == sizeof (struct fadt_descriptor_rev2_minus))) { + (original_fadt->length == + sizeof(struct fadt_descriptor_rev2_minus))) { /* * Grab the entire generic address struct, plus the 1-byte reset value * that immediately follows. */ - ACPI_MEMCPY (&local_fadt->reset_register, - &(ACPI_CAST_PTR (struct fadt_descriptor_rev2_minus, - original_fadt))->reset_register, - sizeof (struct acpi_generic_address) + 1); - } - else { + ACPI_MEMCPY(&local_fadt->reset_register, + &(ACPI_CAST_PTR(struct fadt_descriptor_rev2_minus, + original_fadt))->reset_register, + sizeof(struct acpi_generic_address) + 1); + } else { /* * Since there isn't any equivalence in 1.0 and since it is highly * likely that a 1.0 system has legacy support. @@ -308,43 +296,60 @@ acpi_tb_convert_fadt1 ( /* * Convert the V1.0 block addresses to V2.0 GAS structures */ - acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk, local_fadt->pm1_evt_len, - (acpi_physical_address) local_fadt->V1_pm1a_evt_blk); - acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, local_fadt->pm1_evt_len, - (acpi_physical_address) local_fadt->V1_pm1b_evt_blk); - acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk, local_fadt->pm1_cnt_len, - (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk); - acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, local_fadt->pm1_cnt_len, - (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk); - acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk, local_fadt->pm2_cnt_len, - (acpi_physical_address) local_fadt->V1_pm2_cnt_blk); - acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, local_fadt->pm_tm_len, - (acpi_physical_address) local_fadt->V1_pm_tmr_blk); - acpi_tb_init_generic_address (&local_fadt->xgpe0_blk, 0, - (acpi_physical_address) local_fadt->V1_gpe0_blk); - acpi_tb_init_generic_address (&local_fadt->xgpe1_blk, 0, - (acpi_physical_address) local_fadt->V1_gpe1_blk); + acpi_tb_init_generic_address(&local_fadt->xpm1a_evt_blk, + local_fadt->pm1_evt_len, + (acpi_physical_address) local_fadt-> + V1_pm1a_evt_blk); + acpi_tb_init_generic_address(&local_fadt->xpm1b_evt_blk, + local_fadt->pm1_evt_len, + (acpi_physical_address) local_fadt-> + V1_pm1b_evt_blk); + acpi_tb_init_generic_address(&local_fadt->xpm1a_cnt_blk, + local_fadt->pm1_cnt_len, + (acpi_physical_address) local_fadt-> + V1_pm1a_cnt_blk); + acpi_tb_init_generic_address(&local_fadt->xpm1b_cnt_blk, + local_fadt->pm1_cnt_len, + (acpi_physical_address) local_fadt-> + V1_pm1b_cnt_blk); + acpi_tb_init_generic_address(&local_fadt->xpm2_cnt_blk, + local_fadt->pm2_cnt_len, + (acpi_physical_address) local_fadt-> + V1_pm2_cnt_blk); + acpi_tb_init_generic_address(&local_fadt->xpm_tmr_blk, + local_fadt->pm_tm_len, + (acpi_physical_address) local_fadt-> + V1_pm_tmr_blk); + acpi_tb_init_generic_address(&local_fadt->xgpe0_blk, 0, + (acpi_physical_address) local_fadt-> + V1_gpe0_blk); + acpi_tb_init_generic_address(&local_fadt->xgpe1_blk, 0, + (acpi_physical_address) local_fadt-> + V1_gpe1_blk); /* Create separate GAS structs for the PM1 Enable registers */ - acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable, - (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), - (acpi_physical_address) - (local_fadt->xpm1a_evt_blk.address + - ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); + acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable, + (u8) ACPI_DIV_2(acpi_gbl_FADT-> + pm1_evt_len), + (acpi_physical_address) + (local_fadt->xpm1a_evt_blk.address + + ACPI_DIV_2(acpi_gbl_FADT->pm1_evt_len))); /* PM1B is optional; leave null if not present */ if (local_fadt->xpm1b_evt_blk.address) { - acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable, - (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), - (acpi_physical_address) - (local_fadt->xpm1b_evt_blk.address + - ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); + acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable, + (u8) ACPI_DIV_2(acpi_gbl_FADT-> + pm1_evt_len), + (acpi_physical_address) + (local_fadt->xpm1b_evt_blk. + address + + ACPI_DIV_2(acpi_gbl_FADT-> + pm1_evt_len))); } } - /******************************************************************************* * * FUNCTION: acpi_tb_convert_fadt2 @@ -360,14 +365,14 @@ acpi_tb_convert_fadt1 ( ******************************************************************************/ static void -acpi_tb_convert_fadt2 ( - struct fadt_descriptor_rev2 *local_fadt, - struct fadt_descriptor_rev2 *original_fadt) +acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt, + struct fadt_descriptor_rev2 *original_fadt) { /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */ - ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev2)); + ACPI_MEMCPY(local_fadt, original_fadt, + sizeof(struct fadt_descriptor_rev2)); /* * "X" fields are optional extensions to the original V1.0 fields, so @@ -375,86 +380,99 @@ acpi_tb_convert_fadt2 ( * is zero. */ if (!(local_fadt->xfirmware_ctrl)) { - ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, - local_fadt->V1_firmware_ctrl); + ACPI_STORE_ADDRESS(local_fadt->xfirmware_ctrl, + local_fadt->V1_firmware_ctrl); } if (!(local_fadt->Xdsdt)) { - ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt); + ACPI_STORE_ADDRESS(local_fadt->Xdsdt, local_fadt->V1_dsdt); } if (!(local_fadt->xpm1a_evt_blk.address)) { - acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk, - local_fadt->pm1_evt_len, - (acpi_physical_address) local_fadt->V1_pm1a_evt_blk); + acpi_tb_init_generic_address(&local_fadt->xpm1a_evt_blk, + local_fadt->pm1_evt_len, + (acpi_physical_address) + local_fadt->V1_pm1a_evt_blk); } if (!(local_fadt->xpm1b_evt_blk.address)) { - acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, - local_fadt->pm1_evt_len, - (acpi_physical_address) local_fadt->V1_pm1b_evt_blk); + acpi_tb_init_generic_address(&local_fadt->xpm1b_evt_blk, + local_fadt->pm1_evt_len, + (acpi_physical_address) + local_fadt->V1_pm1b_evt_blk); } if (!(local_fadt->xpm1a_cnt_blk.address)) { - acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk, - local_fadt->pm1_cnt_len, - (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk); + acpi_tb_init_generic_address(&local_fadt->xpm1a_cnt_blk, + local_fadt->pm1_cnt_len, + (acpi_physical_address) + local_fadt->V1_pm1a_cnt_blk); } if (!(local_fadt->xpm1b_cnt_blk.address)) { - acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, - local_fadt->pm1_cnt_len, - (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk); + acpi_tb_init_generic_address(&local_fadt->xpm1b_cnt_blk, + local_fadt->pm1_cnt_len, + (acpi_physical_address) + local_fadt->V1_pm1b_cnt_blk); } if (!(local_fadt->xpm2_cnt_blk.address)) { - acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk, - local_fadt->pm2_cnt_len, - (acpi_physical_address) local_fadt->V1_pm2_cnt_blk); + acpi_tb_init_generic_address(&local_fadt->xpm2_cnt_blk, + local_fadt->pm2_cnt_len, + (acpi_physical_address) + local_fadt->V1_pm2_cnt_blk); } if (!(local_fadt->xpm_tmr_blk.address)) { - acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, - local_fadt->pm_tm_len, - (acpi_physical_address) local_fadt->V1_pm_tmr_blk); + acpi_tb_init_generic_address(&local_fadt->xpm_tmr_blk, + local_fadt->pm_tm_len, + (acpi_physical_address) + local_fadt->V1_pm_tmr_blk); } if (!(local_fadt->xgpe0_blk.address)) { - acpi_tb_init_generic_address (&local_fadt->xgpe0_blk, - 0, (acpi_physical_address) local_fadt->V1_gpe0_blk); + acpi_tb_init_generic_address(&local_fadt->xgpe0_blk, + 0, + (acpi_physical_address) + local_fadt->V1_gpe0_blk); } if (!(local_fadt->xgpe1_blk.address)) { - acpi_tb_init_generic_address (&local_fadt->xgpe1_blk, - 0, (acpi_physical_address) local_fadt->V1_gpe1_blk); + acpi_tb_init_generic_address(&local_fadt->xgpe1_blk, + 0, + (acpi_physical_address) + local_fadt->V1_gpe1_blk); } /* Create separate GAS structs for the PM1 Enable registers */ - acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable, - (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), - (acpi_physical_address) - (local_fadt->xpm1a_evt_blk.address + - ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); + acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable, + (u8) ACPI_DIV_2(acpi_gbl_FADT-> + pm1_evt_len), + (acpi_physical_address) + (local_fadt->xpm1a_evt_blk.address + + ACPI_DIV_2(acpi_gbl_FADT->pm1_evt_len))); acpi_gbl_xpm1a_enable.address_space_id = - local_fadt->xpm1a_evt_blk.address_space_id; + local_fadt->xpm1a_evt_blk.address_space_id; /* PM1B is optional; leave null if not present */ if (local_fadt->xpm1b_evt_blk.address) { - acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable, - (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), - (acpi_physical_address) - (local_fadt->xpm1b_evt_blk.address + - ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); + acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable, + (u8) ACPI_DIV_2(acpi_gbl_FADT-> + pm1_evt_len), + (acpi_physical_address) + (local_fadt->xpm1b_evt_blk. + address + + ACPI_DIV_2(acpi_gbl_FADT-> + pm1_evt_len))); acpi_gbl_xpm1b_enable.address_space_id = - local_fadt->xpm1b_evt_blk.address_space_id; + local_fadt->xpm1b_evt_blk.address_space_id; } } - /******************************************************************************* * * FUNCTION: acpi_tb_convert_table_fadt @@ -471,83 +489,76 @@ acpi_tb_convert_fadt2 ( * ******************************************************************************/ -acpi_status -acpi_tb_convert_table_fadt ( - void) +acpi_status acpi_tb_convert_table_fadt(void) { - struct fadt_descriptor_rev2 *local_fadt; - struct acpi_table_desc *table_desc; - - - ACPI_FUNCTION_TRACE ("tb_convert_table_fadt"); + struct fadt_descriptor_rev2 *local_fadt; + struct acpi_table_desc *table_desc; + ACPI_FUNCTION_TRACE("tb_convert_table_fadt"); /* * acpi_gbl_FADT is valid. Validate the FADT length. The table must be * at least as long as the version 1.0 FADT */ - if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev1)) { - ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n", - acpi_gbl_FADT->length)); - return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev1)) { + ACPI_REPORT_ERROR(("FADT is invalid, too short: 0x%X\n", + acpi_gbl_FADT->length)); + return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); } /* Allocate buffer for the ACPI 2.0(+) FADT */ - local_fadt = ACPI_MEM_CALLOCATE (sizeof (struct fadt_descriptor_rev2)); + local_fadt = ACPI_MEM_CALLOCATE(sizeof(struct fadt_descriptor_rev2)); if (!local_fadt) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) { - if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev2)) { + if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev2)) { /* Length is too short to be a V2.0 table */ - ACPI_REPORT_WARNING (( - "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", - acpi_gbl_FADT->length, acpi_gbl_FADT->revision)); + ACPI_REPORT_WARNING(("Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", acpi_gbl_FADT->length, acpi_gbl_FADT->revision)); - acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT); - } - else { + acpi_tb_convert_fadt1(local_fadt, + (void *)acpi_gbl_FADT); + } else { /* Valid V2.0 table */ - acpi_tb_convert_fadt2 (local_fadt, acpi_gbl_FADT); + acpi_tb_convert_fadt2(local_fadt, acpi_gbl_FADT); } - } - else { + } else { /* Valid V1.0 table */ - acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT); + acpi_tb_convert_fadt1(local_fadt, (void *)acpi_gbl_FADT); } /* Global FADT pointer will point to the new common V2.0 FADT */ acpi_gbl_FADT = local_fadt; - acpi_gbl_FADT->length = sizeof (FADT_DESCRIPTOR); + acpi_gbl_FADT->length = sizeof(FADT_DESCRIPTOR); /* Free the original table */ table_desc = acpi_gbl_table_lists[ACPI_TABLE_FADT].next; - acpi_tb_delete_single_table (table_desc); + acpi_tb_delete_single_table(table_desc); /* Install the new table */ - table_desc->pointer = ACPI_CAST_PTR (struct acpi_table_header, acpi_gbl_FADT); - table_desc->allocation = ACPI_MEM_ALLOCATED; - table_desc->length = sizeof (struct fadt_descriptor_rev2); + table_desc->pointer = + ACPI_CAST_PTR(struct acpi_table_header, acpi_gbl_FADT); + table_desc->allocation = ACPI_MEM_ALLOCATED; + table_desc->length = sizeof(struct fadt_descriptor_rev2); /* Dump the entire FADT */ - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, - "Hex dump of common internal FADT, size %d (%X)\n", - acpi_gbl_FADT->length, acpi_gbl_FADT->length)); - ACPI_DUMP_BUFFER ((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length); + ACPI_DEBUG_PRINT((ACPI_DB_TABLES, + "Hex dump of common internal FADT, size %d (%X)\n", + acpi_gbl_FADT->length, acpi_gbl_FADT->length)); + ACPI_DUMP_BUFFER((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_tb_build_common_facs @@ -561,26 +572,21 @@ acpi_tb_convert_table_fadt ( * ******************************************************************************/ -acpi_status -acpi_tb_build_common_facs ( - struct acpi_table_desc *table_info) +acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info) { - ACPI_FUNCTION_TRACE ("tb_build_common_facs"); - + ACPI_FUNCTION_TRACE("tb_build_common_facs"); /* Absolute minimum length is 24, but the ACPI spec says 64 */ if (acpi_gbl_FACS->length < 24) { - ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n", - acpi_gbl_FACS->length)); - return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + ACPI_REPORT_ERROR(("Invalid FACS table length: 0x%X\n", + acpi_gbl_FACS->length)); + return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); } if (acpi_gbl_FACS->length < 64) { - ACPI_REPORT_WARNING (( - "FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", - acpi_gbl_FACS->length)); + ACPI_REPORT_WARNING(("FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", acpi_gbl_FACS->length)); } /* Copy fields to the new FACS */ @@ -588,22 +594,22 @@ acpi_tb_build_common_facs ( acpi_gbl_common_fACS.global_lock = &(acpi_gbl_FACS->global_lock); if ((acpi_gbl_RSDP->revision < 2) || - (acpi_gbl_FACS->length < 32) || - (!(acpi_gbl_FACS->xfirmware_waking_vector))) { + (acpi_gbl_FACS->length < 32) || + (!(acpi_gbl_FACS->xfirmware_waking_vector))) { /* ACPI 1.0 FACS or short table or optional X_ field is zero */ - acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR (u64, - &(acpi_gbl_FACS->firmware_waking_vector)); + acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR(u64, + & + (acpi_gbl_FACS-> + firmware_waking_vector)); acpi_gbl_common_fACS.vector_width = 32; - } - else { + } else { /* ACPI 2.0 FACS with valid X_ field */ - acpi_gbl_common_fACS.firmware_waking_vector = &acpi_gbl_FACS->xfirmware_waking_vector; + acpi_gbl_common_fACS.firmware_waking_vector = + &acpi_gbl_FACS->xfirmware_waking_vector; acpi_gbl_common_fACS.vector_width = 64; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - - diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c index 4ab2aad..6acd5ae 100644 --- a/drivers/acpi/tables/tbget.c +++ b/drivers/acpi/tables/tbget.c @@ -41,27 +41,21 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbget") +ACPI_MODULE_NAME("tbget") /* Local prototypes */ - static acpi_status -acpi_tb_get_this_table ( - struct acpi_pointer *address, - struct acpi_table_header *header, - struct acpi_table_desc *table_info); +acpi_tb_get_this_table(struct acpi_pointer *address, + struct acpi_table_header *header, + struct acpi_table_desc *table_info); static acpi_status -acpi_tb_table_override ( - struct acpi_table_header *header, - struct acpi_table_desc *table_info); - +acpi_tb_table_override(struct acpi_table_header *header, + struct acpi_table_desc *table_info); /******************************************************************************* * @@ -78,37 +72,34 @@ acpi_tb_table_override ( ******************************************************************************/ acpi_status -acpi_tb_get_table ( - struct acpi_pointer *address, - struct acpi_table_desc *table_info) +acpi_tb_get_table(struct acpi_pointer *address, + struct acpi_table_desc *table_info) { - acpi_status status; - struct acpi_table_header header; - - - ACPI_FUNCTION_TRACE ("tb_get_table"); + acpi_status status; + struct acpi_table_header header; + ACPI_FUNCTION_TRACE("tb_get_table"); /* Get the header in order to get signature and table size */ - status = acpi_tb_get_table_header (address, &header); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_get_table_header(address, &header); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Get the entire table */ - status = acpi_tb_get_table_body (address, &header, table_info); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not get ACPI table (size %X), %s\n", - header.length, acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_tb_get_table_body(address, &header, table_info); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not get ACPI table (size %X), %s\n", + header.length, + acpi_format_exception(status))); + return_ACPI_STATUS(status); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_tb_get_table_header @@ -127,16 +118,13 @@ acpi_tb_get_table ( ******************************************************************************/ acpi_status -acpi_tb_get_table_header ( - struct acpi_pointer *address, - struct acpi_table_header *return_header) +acpi_tb_get_table_header(struct acpi_pointer *address, + struct acpi_table_header *return_header) { - acpi_status status = AE_OK; - struct acpi_table_header *header = NULL; - - - ACPI_FUNCTION_TRACE ("tb_get_table_header"); + acpi_status status = AE_OK; + struct acpi_table_header *header = NULL; + ACPI_FUNCTION_TRACE("tb_get_table_header"); /* * Flags contains the current processor mode (Virtual or Physical @@ -148,46 +136,42 @@ acpi_tb_get_table_header ( /* Pointer matches processor mode, copy the header */ - ACPI_MEMCPY (return_header, address->pointer.logical, - sizeof (struct acpi_table_header)); + ACPI_MEMCPY(return_header, address->pointer.logical, + sizeof(struct acpi_table_header)); break; - case ACPI_LOGMODE_PHYSPTR: - /* Create a logical address for the physical pointer*/ + /* Create a logical address for the physical pointer */ - status = acpi_os_map_memory (address->pointer.physical, - sizeof (struct acpi_table_header), (void *) &header); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "Could not map memory at %8.8X%8.8X for length %X\n", - ACPI_FORMAT_UINT64 (address->pointer.physical), - sizeof (struct acpi_table_header))); - return_ACPI_STATUS (status); + status = acpi_os_map_memory(address->pointer.physical, + sizeof(struct acpi_table_header), + (void *)&header); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not map memory at %8.8X%8.8X for length %X\n", ACPI_FORMAT_UINT64(address->pointer.physical), sizeof(struct acpi_table_header))); + return_ACPI_STATUS(status); } /* Copy header and delete mapping */ - ACPI_MEMCPY (return_header, header, sizeof (struct acpi_table_header)); - acpi_os_unmap_memory (header, sizeof (struct acpi_table_header)); + ACPI_MEMCPY(return_header, header, + sizeof(struct acpi_table_header)); + acpi_os_unmap_memory(header, sizeof(struct acpi_table_header)); break; - default: - ACPI_REPORT_ERROR (("Invalid address flags %X\n", - address->pointer_type)); - return_ACPI_STATUS (AE_BAD_PARAMETER); + ACPI_REPORT_ERROR(("Invalid address flags %X\n", + address->pointer_type)); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Table Signature: [%4.4s]\n", - return_header->signature)); + ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Table Signature: [%4.4s]\n", + return_header->signature)); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_tb_get_table_body @@ -209,37 +193,33 @@ acpi_tb_get_table_header ( ******************************************************************************/ acpi_status -acpi_tb_get_table_body ( - struct acpi_pointer *address, - struct acpi_table_header *header, - struct acpi_table_desc *table_info) +acpi_tb_get_table_body(struct acpi_pointer *address, + struct acpi_table_header *header, + struct acpi_table_desc *table_info) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("tb_get_table_body"); + acpi_status status; + ACPI_FUNCTION_TRACE("tb_get_table_body"); if (!table_info || !address) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Attempt table override. */ - status = acpi_tb_table_override (header, table_info); - if (ACPI_SUCCESS (status)) { + status = acpi_tb_table_override(header, table_info); + if (ACPI_SUCCESS(status)) { /* Table was overridden by the host OS */ - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* No override, get the original table */ - status = acpi_tb_get_this_table (address, header, table_info); - return_ACPI_STATUS (status); + status = acpi_tb_get_this_table(address, header, table_info); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_tb_table_override @@ -255,61 +235,57 @@ acpi_tb_get_table_body ( ******************************************************************************/ static acpi_status -acpi_tb_table_override ( - struct acpi_table_header *header, - struct acpi_table_desc *table_info) +acpi_tb_table_override(struct acpi_table_header *header, + struct acpi_table_desc *table_info) { - struct acpi_table_header *new_table; - acpi_status status; - struct acpi_pointer address; - - - ACPI_FUNCTION_TRACE ("tb_table_override"); + struct acpi_table_header *new_table; + acpi_status status; + struct acpi_pointer address; + ACPI_FUNCTION_TRACE("tb_table_override"); /* * The OSL will examine the header and decide whether to override this * table. If it decides to override, a table will be returned in new_table, * which we will then copy. */ - status = acpi_os_table_override (header, &new_table); - if (ACPI_FAILURE (status)) { + status = acpi_os_table_override(header, &new_table); + if (ACPI_FAILURE(status)) { /* Some severe error from the OSL, but we basically ignore it */ - ACPI_REPORT_ERROR (("Could not override ACPI table, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + ACPI_REPORT_ERROR(("Could not override ACPI table, %s\n", + acpi_format_exception(status))); + return_ACPI_STATUS(status); } if (!new_table) { /* No table override */ - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + return_ACPI_STATUS(AE_NO_ACPI_TABLES); } /* * We have a new table to override the old one. Get a copy of * the new one. We know that the new table has a logical pointer. */ - address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING; + address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING; address.pointer.logical = new_table; - status = acpi_tb_get_this_table (&address, new_table, table_info); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not copy override ACPI table, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_tb_get_this_table(&address, new_table, table_info); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not copy override ACPI table, %s\n", + acpi_format_exception(status))); + return_ACPI_STATUS(status); } /* Copy the table info */ - ACPI_REPORT_INFO (("Table [%4.4s] replaced by host OS\n", - table_info->pointer->signature)); + ACPI_REPORT_INFO(("Table [%4.4s] replaced by host OS\n", + table_info->pointer->signature)); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_tb_get_this_table @@ -329,18 +305,15 @@ acpi_tb_table_override ( ******************************************************************************/ static acpi_status -acpi_tb_get_this_table ( - struct acpi_pointer *address, - struct acpi_table_header *header, - struct acpi_table_desc *table_info) +acpi_tb_get_this_table(struct acpi_pointer *address, + struct acpi_table_header *header, + struct acpi_table_desc *table_info) { - struct acpi_table_header *full_table = NULL; - u8 allocation; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("tb_get_this_table"); + struct acpi_table_header *full_table = NULL; + u8 allocation; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("tb_get_this_table"); /* * Flags contains the current processor mode (Virtual or Physical @@ -352,38 +325,33 @@ acpi_tb_get_this_table ( /* Pointer matches processor mode, copy the table to a new buffer */ - full_table = ACPI_MEM_ALLOCATE (header->length); + full_table = ACPI_MEM_ALLOCATE(header->length); if (!full_table) { - ACPI_REPORT_ERROR (( - "Could not allocate table memory for [%4.4s] length %X\n", - header->signature, header->length)); - return_ACPI_STATUS (AE_NO_MEMORY); + ACPI_REPORT_ERROR(("Could not allocate table memory for [%4.4s] length %X\n", header->signature, header->length)); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Copy the entire table (including header) to the local buffer */ - ACPI_MEMCPY (full_table, address->pointer.logical, header->length); + ACPI_MEMCPY(full_table, address->pointer.logical, + header->length); /* Save allocation type */ allocation = ACPI_MEM_ALLOCATED; break; - case ACPI_LOGMODE_PHYSPTR: /* * Just map the table's physical memory * into our address space. */ - status = acpi_os_map_memory (address->pointer.physical, - (acpi_size) header->length, (void *) &full_table); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", - header->signature, - ACPI_FORMAT_UINT64 (address->pointer.physical), - header->length)); + status = acpi_os_map_memory(address->pointer.physical, + (acpi_size) header->length, + (void *)&full_table); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", header->signature, ACPI_FORMAT_UINT64(address->pointer.physical), header->length)); return (status); } @@ -392,12 +360,11 @@ acpi_tb_get_this_table ( allocation = ACPI_MEM_MAPPED; break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid address flags %X\n", - address->pointer_type)); - return_ACPI_STATUS (AE_BAD_PARAMETER); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid address flags %X\n", + address->pointer_type)); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* @@ -405,10 +372,10 @@ acpi_tb_get_this_table ( * even the ones whose signature we don't recognize */ if (table_info->type != ACPI_TABLE_FACS) { - status = acpi_tb_verify_table_checksum (full_table); + status = acpi_tb_verify_table_checksum(full_table); #if (!ACPI_CHECKSUM_ABORT) - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { /* Ignore the error if configuration says so */ status = AE_OK; @@ -418,19 +385,19 @@ acpi_tb_get_this_table ( /* Return values */ - table_info->pointer = full_table; - table_info->length = (acpi_size) header->length; - table_info->allocation = allocation; + table_info->pointer = full_table; + table_info->length = (acpi_size) header->length; + table_info->allocation = allocation; - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Found table [%4.4s] at %8.8X%8.8X, mapped/copied to %p\n", - full_table->signature, - ACPI_FORMAT_UINT64 (address->pointer.physical), full_table)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Found table [%4.4s] at %8.8X%8.8X, mapped/copied to %p\n", + full_table->signature, + ACPI_FORMAT_UINT64(address->pointer.physical), + full_table)); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_tb_get_table_ptr @@ -447,24 +414,20 @@ acpi_tb_get_this_table ( ******************************************************************************/ acpi_status -acpi_tb_get_table_ptr ( - acpi_table_type table_type, - u32 instance, - struct acpi_table_header **table_ptr_loc) +acpi_tb_get_table_ptr(acpi_table_type table_type, + u32 instance, struct acpi_table_header **table_ptr_loc) { - struct acpi_table_desc *table_desc; - u32 i; - - - ACPI_FUNCTION_TRACE ("tb_get_table_ptr"); + struct acpi_table_desc *table_desc; + u32 i; + ACPI_FUNCTION_TRACE("tb_get_table_ptr"); if (!acpi_gbl_DSDT) { - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + return_ACPI_STATUS(AE_NO_ACPI_TABLES); } if (table_type > ACPI_TABLE_MAX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* @@ -476,15 +439,16 @@ acpi_tb_get_table_ptr ( *table_ptr_loc = NULL; if (acpi_gbl_table_lists[table_type].next) { - *table_ptr_loc = acpi_gbl_table_lists[table_type].next->pointer; + *table_ptr_loc = + acpi_gbl_table_lists[table_type].next->pointer; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Check for instance out of range */ if (instance > acpi_gbl_table_lists[table_type].count) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } /* Walk the list to get the desired table @@ -503,6 +467,5 @@ acpi_tb_get_table_ptr ( *table_ptr_loc = table_desc->pointer; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c index eea5b8c..8d72343 100644 --- a/drivers/acpi/tables/tbgetall.c +++ b/drivers/acpi/tables/tbgetall.c @@ -41,27 +41,21 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbgetall") +ACPI_MODULE_NAME("tbgetall") /* Local prototypes */ - static acpi_status -acpi_tb_get_primary_table ( - struct acpi_pointer *address, - struct acpi_table_desc *table_info); +acpi_tb_get_primary_table(struct acpi_pointer *address, + struct acpi_table_desc *table_info); static acpi_status -acpi_tb_get_secondary_table ( - struct acpi_pointer *address, - acpi_string signature, - struct acpi_table_desc *table_info); - +acpi_tb_get_secondary_table(struct acpi_pointer *address, + acpi_string signature, + struct acpi_table_desc *table_info); /******************************************************************************* * @@ -77,58 +71,54 @@ acpi_tb_get_secondary_table ( ******************************************************************************/ static acpi_status -acpi_tb_get_primary_table ( - struct acpi_pointer *address, - struct acpi_table_desc *table_info) +acpi_tb_get_primary_table(struct acpi_pointer *address, + struct acpi_table_desc *table_info) { - acpi_status status; - struct acpi_table_header header; - - - ACPI_FUNCTION_TRACE ("tb_get_primary_table"); + acpi_status status; + struct acpi_table_header header; + ACPI_FUNCTION_TRACE("tb_get_primary_table"); /* Ignore a NULL address in the RSDT */ if (!address->pointer.value) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Get the header in order to get signature and table size */ - status = acpi_tb_get_table_header (address, &header); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_get_table_header(address, &header); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Clear the table_info */ - ACPI_MEMSET (table_info, 0, sizeof (struct acpi_table_desc)); + ACPI_MEMSET(table_info, 0, sizeof(struct acpi_table_desc)); /* * Check the table signature and make sure it is recognized. * Also checks the header checksum */ table_info->pointer = &header; - status = acpi_tb_recognize_table (table_info, ACPI_TABLE_PRIMARY); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_recognize_table(table_info, ACPI_TABLE_PRIMARY); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Get the entire table */ - status = acpi_tb_get_table_body (address, &header, table_info); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_get_table_body(address, &header, table_info); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Install the table */ - status = acpi_tb_install_table (table_info); - return_ACPI_STATUS (status); + status = acpi_tb_install_table(table_info); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_tb_get_secondary_table @@ -143,32 +133,27 @@ acpi_tb_get_primary_table ( ******************************************************************************/ static acpi_status -acpi_tb_get_secondary_table ( - struct acpi_pointer *address, - acpi_string signature, - struct acpi_table_desc *table_info) +acpi_tb_get_secondary_table(struct acpi_pointer *address, + acpi_string signature, + struct acpi_table_desc *table_info) { - acpi_status status; - struct acpi_table_header header; - - - ACPI_FUNCTION_TRACE_STR ("tb_get_secondary_table", signature); + acpi_status status; + struct acpi_table_header header; + ACPI_FUNCTION_TRACE_STR("tb_get_secondary_table", signature); /* Get the header in order to match the signature */ - status = acpi_tb_get_table_header (address, &header); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_get_table_header(address, &header); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Signature must match request */ - if (ACPI_STRNCMP (header.signature, signature, ACPI_NAME_SIZE)) { - ACPI_REPORT_ERROR (( - "Incorrect table signature - wanted [%s] found [%4.4s]\n", - signature, header.signature)); - return_ACPI_STATUS (AE_BAD_SIGNATURE); + if (ACPI_STRNCMP(header.signature, signature, ACPI_NAME_SIZE)) { + ACPI_REPORT_ERROR(("Incorrect table signature - wanted [%s] found [%4.4s]\n", signature, header.signature)); + return_ACPI_STATUS(AE_BAD_SIGNATURE); } /* @@ -176,25 +161,24 @@ acpi_tb_get_secondary_table ( * Also checks the header checksum */ table_info->pointer = &header; - status = acpi_tb_recognize_table (table_info, ACPI_TABLE_SECONDARY); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_recognize_table(table_info, ACPI_TABLE_SECONDARY); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Get the entire table */ - status = acpi_tb_get_table_body (address, &header, table_info); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_get_table_body(address, &header, table_info); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Install the table */ - status = acpi_tb_install_table (table_info); - return_ACPI_STATUS (status); + status = acpi_tb_install_table(table_info); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_tb_get_required_tables @@ -214,23 +198,19 @@ acpi_tb_get_secondary_table ( * ******************************************************************************/ -acpi_status -acpi_tb_get_required_tables ( - void) +acpi_status acpi_tb_get_required_tables(void) { - acpi_status status = AE_OK; - u32 i; - struct acpi_table_desc table_info; - struct acpi_pointer address; - + acpi_status status = AE_OK; + u32 i; + struct acpi_table_desc table_info; + struct acpi_pointer address; - ACPI_FUNCTION_TRACE ("tb_get_required_tables"); + ACPI_FUNCTION_TRACE("tb_get_required_tables"); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%d ACPI tables in RSDT\n", - acpi_gbl_rsdt_table_count)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%d ACPI tables in RSDT\n", + acpi_gbl_rsdt_table_count)); - - address.pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; + address.pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; /* * Loop through all table pointers found in RSDT. @@ -243,84 +223,79 @@ acpi_tb_get_required_tables ( for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { /* Get the table address from the common internal XSDT */ - address.pointer.value = - acpi_gbl_XSDT->table_offset_entry[i]; + address.pointer.value = acpi_gbl_XSDT->table_offset_entry[i]; /* * Get the tables needed by this subsystem (FADT and any SSDTs). * NOTE: All other tables are completely ignored at this time. */ - status = acpi_tb_get_primary_table (&address, &table_info); + status = acpi_tb_get_primary_table(&address, &table_info); if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) { - ACPI_REPORT_WARNING (("%s, while getting table at %8.8X%8.8X\n", - acpi_format_exception (status), - ACPI_FORMAT_UINT64 (address.pointer.value))); + ACPI_REPORT_WARNING(("%s, while getting table at %8.8X%8.8X\n", acpi_format_exception(status), ACPI_FORMAT_UINT64(address.pointer.value))); } } /* We must have a FADT to continue */ if (!acpi_gbl_FADT) { - ACPI_REPORT_ERROR (("No FADT present in RSDT/XSDT\n")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + ACPI_REPORT_ERROR(("No FADT present in RSDT/XSDT\n")); + return_ACPI_STATUS(AE_NO_ACPI_TABLES); } /* * Convert the FADT to a common format. This allows earlier revisions of * the table to coexist with newer versions, using common access code. */ - status = acpi_tb_convert_table_fadt (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "Could not convert FADT to internal common format\n")); - return_ACPI_STATUS (status); + status = acpi_tb_convert_table_fadt(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not convert FADT to internal common format\n")); + return_ACPI_STATUS(status); } /* Get the FACS (Pointed to by the FADT) */ address.pointer.value = acpi_gbl_FADT->xfirmware_ctrl; - status = acpi_tb_get_secondary_table (&address, FACS_SIG, &table_info); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not get/install the FACS, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_tb_get_secondary_table(&address, FACS_SIG, &table_info); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not get/install the FACS, %s\n", + acpi_format_exception(status))); + return_ACPI_STATUS(status); } /* * Create the common FACS pointer table * (Contains pointers to the original table) */ - status = acpi_tb_build_common_facs (&table_info); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_build_common_facs(&table_info); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Get/install the DSDT (Pointed to by the FADT) */ address.pointer.value = acpi_gbl_FADT->Xdsdt; - status = acpi_tb_get_secondary_table (&address, DSDT_SIG, &table_info); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not get/install the DSDT\n")); - return_ACPI_STATUS (status); + status = acpi_tb_get_secondary_table(&address, DSDT_SIG, &table_info); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not get/install the DSDT\n")); + return_ACPI_STATUS(status); } /* Set Integer Width (32/64) based upon DSDT revision */ - acpi_ut_set_integer_width (acpi_gbl_DSDT->revision); + acpi_ut_set_integer_width(acpi_gbl_DSDT->revision); /* Dump the entire DSDT */ - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, - "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n", - acpi_gbl_DSDT->length, acpi_gbl_DSDT->length, acpi_gbl_integer_bit_width)); - ACPI_DUMP_BUFFER ((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length); + ACPI_DEBUG_PRINT((ACPI_DB_TABLES, + "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n", + acpi_gbl_DSDT->length, acpi_gbl_DSDT->length, + acpi_gbl_integer_bit_width)); + ACPI_DUMP_BUFFER((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length); /* Always delete the RSDP mapping, we are done with it */ - acpi_tb_delete_tables_by_type (ACPI_TABLE_RSDP); - return_ACPI_STATUS (status); + acpi_tb_delete_tables_by_type(ACPI_TABLE_RSDP); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c index 6987999..10db848 100644 --- a/drivers/acpi/tables/tbinstal.c +++ b/drivers/acpi/tables/tbinstal.c @@ -41,22 +41,16 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbinstal") +ACPI_MODULE_NAME("tbinstal") /* Local prototypes */ - static acpi_status -acpi_tb_match_signature ( - char *signature, - struct acpi_table_desc *table_info, - u8 search_type); - +acpi_tb_match_signature(char *signature, + struct acpi_table_desc *table_info, u8 search_type); /******************************************************************************* * @@ -74,16 +68,12 @@ acpi_tb_match_signature ( ******************************************************************************/ static acpi_status -acpi_tb_match_signature ( - char *signature, - struct acpi_table_desc *table_info, - u8 search_type) +acpi_tb_match_signature(char *signature, + struct acpi_table_desc *table_info, u8 search_type) { - acpi_native_uint i; - - - ACPI_FUNCTION_TRACE ("tb_match_signature"); + acpi_native_uint i; + ACPI_FUNCTION_TRACE("tb_match_signature"); /* Search for a signature match among the known table types */ @@ -92,30 +82,30 @@ acpi_tb_match_signature ( continue; } - if (!ACPI_STRNCMP (signature, acpi_gbl_table_data[i].signature, - acpi_gbl_table_data[i].sig_length)) { + if (!ACPI_STRNCMP(signature, acpi_gbl_table_data[i].signature, + acpi_gbl_table_data[i].sig_length)) { /* Found a signature match, return index if requested */ if (table_info) { table_info->type = (u8) i; } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Table [%4.4s] is an ACPI table consumed by the core subsystem\n", - (char *) acpi_gbl_table_data[i].signature)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Table [%4.4s] is an ACPI table consumed by the core subsystem\n", + (char *)acpi_gbl_table_data[i]. + signature)); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Table [%4.4s] is not an ACPI table consumed by the core subsystem - ignored\n", - (char *) signature)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Table [%4.4s] is not an ACPI table consumed by the core subsystem - ignored\n", + (char *)signature)); - return_ACPI_STATUS (AE_TABLE_NOT_SUPPORTED); + return_ACPI_STATUS(AE_TABLE_NOT_SUPPORTED); } - /******************************************************************************* * * FUNCTION: acpi_tb_install_table @@ -128,52 +118,48 @@ acpi_tb_match_signature ( * ******************************************************************************/ -acpi_status -acpi_tb_install_table ( - struct acpi_table_desc *table_info) +acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("tb_install_table"); + acpi_status status; + ACPI_FUNCTION_TRACE("tb_install_table"); /* Lock tables while installing */ - status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not acquire table mutex, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not acquire table mutex, %s\n", + acpi_format_exception(status))); + return_ACPI_STATUS(status); } /* * Ignore a table that is already installed. For example, some BIOS * ASL code will repeatedly attempt to load the same SSDT. */ - status = acpi_tb_is_table_installed (table_info); - if (ACPI_FAILURE (status)) { + status = acpi_tb_is_table_installed(table_info); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } /* Install the table into the global data structure */ - status = acpi_tb_init_table_descriptor (table_info->type, table_info); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not install table [%4.4s], %s\n", - table_info->pointer->signature, acpi_format_exception (status))); + status = acpi_tb_init_table_descriptor(table_info->type, table_info); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not install table [%4.4s], %s\n", + table_info->pointer->signature, + acpi_format_exception(status))); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n", - acpi_gbl_table_data[table_info->type].name, table_info->pointer)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s located at %p\n", + acpi_gbl_table_data[table_info->type].name, + table_info->pointer)); - -unlock_and_exit: - (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (status); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_tb_recognize_table @@ -196,22 +182,18 @@ unlock_and_exit: ******************************************************************************/ acpi_status -acpi_tb_recognize_table ( - struct acpi_table_desc *table_info, - u8 search_type) +acpi_tb_recognize_table(struct acpi_table_desc *table_info, u8 search_type) { - struct acpi_table_header *table_header; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("tb_recognize_table"); + struct acpi_table_header *table_header; + acpi_status status; + ACPI_FUNCTION_TRACE("tb_recognize_table"); /* Ensure that we have a valid table pointer */ - table_header = (struct acpi_table_header *) table_info->pointer; + table_header = (struct acpi_table_header *)table_info->pointer; if (!table_header) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* @@ -222,25 +204,24 @@ acpi_tb_recognize_table ( * This can be any one of many valid ACPI tables, it just isn't one of * the tables that is consumed by the core subsystem */ - status = acpi_tb_match_signature (table_header->signature, - table_info, search_type); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_match_signature(table_header->signature, + table_info, search_type); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_tb_validate_table_header (table_header); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_validate_table_header(table_header); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Return the table type and length via the info struct */ table_info->length = (acpi_size) table_header->length; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_tb_init_table_descriptor @@ -255,30 +236,27 @@ acpi_tb_recognize_table ( ******************************************************************************/ acpi_status -acpi_tb_init_table_descriptor ( - acpi_table_type table_type, - struct acpi_table_desc *table_info) +acpi_tb_init_table_descriptor(acpi_table_type table_type, + struct acpi_table_desc *table_info) { - struct acpi_table_list *list_head; - struct acpi_table_desc *table_desc; - acpi_status status; - - - ACPI_FUNCTION_TRACE_U32 ("tb_init_table_descriptor", table_type); + struct acpi_table_list *list_head; + struct acpi_table_desc *table_desc; + acpi_status status; + ACPI_FUNCTION_TRACE_U32("tb_init_table_descriptor", table_type); /* Allocate a descriptor for this table */ - table_desc = ACPI_MEM_CALLOCATE (sizeof (struct acpi_table_desc)); + table_desc = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc)); if (!table_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Get a new owner ID for the table */ - status = acpi_ut_allocate_owner_id (&table_desc->owner_id); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_allocate_owner_id(&table_desc->owner_id); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Install the table into the global data structure */ @@ -290,14 +268,14 @@ acpi_tb_init_table_descriptor ( * includes most ACPI tables such as the DSDT. 2) Multiple instances of * the table are allowed. This includes SSDT and PSDTs. */ - if (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags)) { + if (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags)) { /* * Only one table allowed, and a table has alread been installed * at this location, so return an error. */ if (list_head->next) { - ACPI_MEM_FREE (table_desc); - return_ACPI_STATUS (AE_ALREADY_EXISTS); + ACPI_MEM_FREE(table_desc); + return_ACPI_STATUS(AE_ALREADY_EXISTS); } table_desc->next = list_head->next; @@ -308,8 +286,7 @@ acpi_tb_init_table_descriptor ( } list_head->count++; - } - else { + } else { /* * Link the new table in to the list of tables of this type. * Insert at the end of the list, order IS IMPORTANT. @@ -320,8 +297,7 @@ acpi_tb_init_table_descriptor ( if (!list_head->next) { list_head->next = table_desc; - } - else { + } else { table_desc->next = list_head->next; while (table_desc->next->next) { @@ -336,13 +312,14 @@ acpi_tb_init_table_descriptor ( /* Finish initialization of the table descriptor */ - table_desc->type = (u8) table_type; - table_desc->pointer = table_info->pointer; - table_desc->length = table_info->length; - table_desc->allocation = table_info->allocation; - table_desc->aml_start = (u8 *) (table_desc->pointer + 1), - table_desc->aml_length = (u32) (table_desc->length - - (u32) sizeof (struct acpi_table_header)); + table_desc->type = (u8) table_type; + table_desc->pointer = table_info->pointer; + table_desc->length = table_info->length; + table_desc->allocation = table_info->allocation; + table_desc->aml_start = (u8 *) (table_desc->pointer + 1), + table_desc->aml_length = (u32) (table_desc->length - + (u32) sizeof(struct + acpi_table_header)); table_desc->loaded_into_namespace = FALSE; /* @@ -350,18 +327,18 @@ acpi_tb_init_table_descriptor ( * newly installed table */ if (acpi_gbl_table_data[table_type].global_ptr) { - *(acpi_gbl_table_data[table_type].global_ptr) = table_info->pointer; + *(acpi_gbl_table_data[table_type].global_ptr) = + table_info->pointer; } /* Return Data */ - table_info->owner_id = table_desc->owner_id; - table_info->installed_desc = table_desc; + table_info->owner_id = table_desc->owner_id; + table_info->installed_desc = table_desc; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_tb_delete_all_tables @@ -374,23 +351,19 @@ acpi_tb_init_table_descriptor ( * ******************************************************************************/ -void -acpi_tb_delete_all_tables ( - void) +void acpi_tb_delete_all_tables(void) { - acpi_table_type type; - + acpi_table_type type; /* * Free memory allocated for ACPI tables * Memory can either be mapped or allocated */ for (type = 0; type < NUM_ACPI_TABLE_TYPES; type++) { - acpi_tb_delete_tables_by_type (type); + acpi_tb_delete_tables_by_type(type); } } - /******************************************************************************* * * FUNCTION: acpi_tb_delete_tables_by_type @@ -404,23 +377,19 @@ acpi_tb_delete_all_tables ( * ******************************************************************************/ -void -acpi_tb_delete_tables_by_type ( - acpi_table_type type) +void acpi_tb_delete_tables_by_type(acpi_table_type type) { - struct acpi_table_desc *table_desc; - u32 count; - u32 i; - - - ACPI_FUNCTION_TRACE_U32 ("tb_delete_tables_by_type", type); + struct acpi_table_desc *table_desc; + u32 count; + u32 i; + ACPI_FUNCTION_TRACE_U32("tb_delete_tables_by_type", type); if (type > ACPI_TABLE_MAX) { return_VOID; } - if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_TABLES))) { + if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_TABLES))) { return; } @@ -458,21 +427,20 @@ acpi_tb_delete_tables_by_type ( * 1) Get the head of the list */ table_desc = acpi_gbl_table_lists[type].next; - count = acpi_gbl_table_lists[type].count; + count = acpi_gbl_table_lists[type].count; /* * 2) Walk the entire list, deleting both the allocated tables * and the table descriptors */ for (i = 0; i < count; i++) { - table_desc = acpi_tb_uninstall_table (table_desc); + table_desc = acpi_tb_uninstall_table(table_desc); } - (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); + (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_tb_delete_single_table @@ -486,15 +454,12 @@ acpi_tb_delete_tables_by_type ( * ******************************************************************************/ -void -acpi_tb_delete_single_table ( - struct acpi_table_desc *table_desc) +void acpi_tb_delete_single_table(struct acpi_table_desc *table_desc) { /* Must have a valid table descriptor and pointer */ - if ((!table_desc) || - (!table_desc->pointer)) { + if ((!table_desc) || (!table_desc->pointer)) { return; } @@ -506,12 +471,12 @@ acpi_tb_delete_single_table ( case ACPI_MEM_ALLOCATED: - ACPI_MEM_FREE (table_desc->pointer); + ACPI_MEM_FREE(table_desc->pointer); break; case ACPI_MEM_MAPPED: - acpi_os_unmap_memory (table_desc->pointer, table_desc->length); + acpi_os_unmap_memory(table_desc->pointer, table_desc->length); break; default: @@ -519,7 +484,6 @@ acpi_tb_delete_single_table ( } } - /******************************************************************************* * * FUNCTION: acpi_tb_uninstall_table @@ -534,26 +498,22 @@ acpi_tb_delete_single_table ( * ******************************************************************************/ -struct acpi_table_desc * -acpi_tb_uninstall_table ( - struct acpi_table_desc *table_desc) +struct acpi_table_desc *acpi_tb_uninstall_table(struct acpi_table_desc + *table_desc) { - struct acpi_table_desc *next_desc; - - - ACPI_FUNCTION_TRACE_PTR ("tb_uninstall_table", table_desc); + struct acpi_table_desc *next_desc; + ACPI_FUNCTION_TRACE_PTR("tb_uninstall_table", table_desc); if (!table_desc) { - return_PTR (NULL); + return_PTR(NULL); } /* Unlink the descriptor from the doubly linked list */ if (table_desc->prev) { table_desc->prev->next = table_desc->next; - } - else { + } else { /* Is first on list, update list head */ acpi_gbl_table_lists[table_desc->type].next = table_desc->next; @@ -565,16 +525,14 @@ acpi_tb_uninstall_table ( /* Free the memory allocated for the table itself */ - acpi_tb_delete_single_table (table_desc); + acpi_tb_delete_single_table(table_desc); /* Free the table descriptor */ next_desc = table_desc->next; - ACPI_MEM_FREE (table_desc); + ACPI_MEM_FREE(table_desc); /* Return pointer to the next descriptor */ - return_PTR (next_desc); + return_PTR(next_desc); } - - diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c index 069d498..ad0252c 100644 --- a/drivers/acpi/tables/tbrsdt.c +++ b/drivers/acpi/tables/tbrsdt.c @@ -41,14 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbrsdt") - +ACPI_MODULE_NAME("tbrsdt") /******************************************************************************* * @@ -61,18 +58,13 @@ * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) * ******************************************************************************/ - -acpi_status -acpi_tb_verify_rsdp ( - struct acpi_pointer *address) +acpi_status acpi_tb_verify_rsdp(struct acpi_pointer *address) { - struct acpi_table_desc table_info; - acpi_status status; - struct rsdp_descriptor *rsdp; - - - ACPI_FUNCTION_TRACE ("tb_verify_rsdp"); + struct acpi_table_desc table_info; + acpi_status status; + struct rsdp_descriptor *rsdp; + ACPI_FUNCTION_TRACE("tb_verify_rsdp"); switch (address->pointer_type) { case ACPI_LOGICAL_POINTER: @@ -84,54 +76,53 @@ acpi_tb_verify_rsdp ( /* * Obtain access to the RSDP structure */ - status = acpi_os_map_memory (address->pointer.physical, - sizeof (struct rsdp_descriptor), - (void *) &rsdp); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_os_map_memory(address->pointer.physical, + sizeof(struct rsdp_descriptor), + (void *)&rsdp); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } break; default: - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Verify RSDP signature and checksum */ - status = acpi_tb_validate_rsdp (rsdp); - if (ACPI_FAILURE (status)) { + status = acpi_tb_validate_rsdp(rsdp); + if (ACPI_FAILURE(status)) { goto cleanup; } /* The RSDP supplied is OK */ - table_info.pointer = ACPI_CAST_PTR (struct acpi_table_header, rsdp); - table_info.length = sizeof (struct rsdp_descriptor); - table_info.allocation = ACPI_MEM_MAPPED; + table_info.pointer = ACPI_CAST_PTR(struct acpi_table_header, rsdp); + table_info.length = sizeof(struct rsdp_descriptor); + table_info.allocation = ACPI_MEM_MAPPED; /* Save the table pointers and allocation info */ - status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info); - if (ACPI_FAILURE (status)) { + status = acpi_tb_init_table_descriptor(ACPI_TABLE_RSDP, &table_info); + if (ACPI_FAILURE(status)) { goto cleanup; } /* Save the RSDP in a global for easy access */ - acpi_gbl_RSDP = ACPI_CAST_PTR (struct rsdp_descriptor, table_info.pointer); - return_ACPI_STATUS (status); - + acpi_gbl_RSDP = + ACPI_CAST_PTR(struct rsdp_descriptor, table_info.pointer); + return_ACPI_STATUS(status); /* Error exit */ -cleanup: + cleanup: if (acpi_gbl_table_flags & ACPI_PHYSICAL_POINTER) { - acpi_os_unmap_memory (rsdp, sizeof (struct rsdp_descriptor)); + acpi_os_unmap_memory(rsdp, sizeof(struct rsdp_descriptor)); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_tb_get_rsdt_address @@ -145,33 +136,30 @@ cleanup: * ******************************************************************************/ -void -acpi_tb_get_rsdt_address ( - struct acpi_pointer *out_address) +void acpi_tb_get_rsdt_address(struct acpi_pointer *out_address) { - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_ENTRY(); - out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; + out_address->pointer_type = + acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; /* Use XSDT if it is present */ if ((acpi_gbl_RSDP->revision >= 2) && - acpi_gbl_RSDP->xsdt_physical_address) { + acpi_gbl_RSDP->xsdt_physical_address) { out_address->pointer.value = - acpi_gbl_RSDP->xsdt_physical_address; + acpi_gbl_RSDP->xsdt_physical_address; acpi_gbl_root_table_type = ACPI_TABLE_TYPE_XSDT; - } - else { + } else { /* No XSDT, use the RSDT */ - out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address; + out_address->pointer.value = + acpi_gbl_RSDP->rsdt_physical_address; acpi_gbl_root_table_type = ACPI_TABLE_TYPE_RSDT; } } - /******************************************************************************* * * FUNCTION: acpi_tb_validate_rsdt @@ -184,49 +172,43 @@ acpi_tb_get_rsdt_address ( * ******************************************************************************/ -acpi_status -acpi_tb_validate_rsdt ( - struct acpi_table_header *table_ptr) +acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr) { - int no_match; - - - ACPI_FUNCTION_NAME ("tb_validate_rsdt"); + int no_match; + ACPI_FUNCTION_NAME("tb_validate_rsdt"); /* * Search for appropriate signature, RSDT or XSDT */ if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { - no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG, - sizeof (RSDT_SIG) -1); - } - else { - no_match = ACPI_STRNCMP ((char *) table_ptr, XSDT_SIG, - sizeof (XSDT_SIG) -1); + no_match = ACPI_STRNCMP((char *)table_ptr, RSDT_SIG, + sizeof(RSDT_SIG) - 1); + } else { + no_match = ACPI_STRNCMP((char *)table_ptr, XSDT_SIG, + sizeof(XSDT_SIG) - 1); } if (no_match) { /* Invalid RSDT or XSDT signature */ - ACPI_REPORT_ERROR (( - "Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); + ACPI_REPORT_ERROR(("Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); - ACPI_DUMP_BUFFER (acpi_gbl_RSDP, 20); + ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20); - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, - "RSDT/XSDT signature at %X (%p) is invalid\n", - acpi_gbl_RSDP->rsdt_physical_address, - (void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address)); + ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, + "RSDT/XSDT signature at %X (%p) is invalid\n", + acpi_gbl_RSDP->rsdt_physical_address, + (void *)(acpi_native_uint) acpi_gbl_RSDP-> + rsdt_physical_address)); if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { - ACPI_REPORT_ERROR (("Looking for RSDT\n")) - } - else { - ACPI_REPORT_ERROR (("Looking for XSDT\n")) + ACPI_REPORT_ERROR(("Looking for RSDT\n")) + } else { + ACPI_REPORT_ERROR(("Looking for XSDT\n")) } - ACPI_DUMP_BUFFER ((char *) table_ptr, 48); + ACPI_DUMP_BUFFER((char *)table_ptr, 48); return (AE_BAD_SIGNATURE); } @@ -234,7 +216,6 @@ acpi_tb_validate_rsdt ( return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_tb_get_table_rsdt @@ -247,66 +228,61 @@ acpi_tb_validate_rsdt ( * ******************************************************************************/ -acpi_status -acpi_tb_get_table_rsdt ( - void) +acpi_status acpi_tb_get_table_rsdt(void) { - struct acpi_table_desc table_info; - acpi_status status; - struct acpi_pointer address; - - - ACPI_FUNCTION_TRACE ("tb_get_table_rsdt"); + struct acpi_table_desc table_info; + acpi_status status; + struct acpi_pointer address; + ACPI_FUNCTION_TRACE("tb_get_table_rsdt"); /* Get the RSDT/XSDT via the RSDP */ - acpi_tb_get_rsdt_address (&address); + acpi_tb_get_rsdt_address(&address); table_info.type = ACPI_TABLE_XSDT; - status = acpi_tb_get_table (&address, &table_info); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT/XSDT, %s\n", - acpi_format_exception (status))); + status = acpi_tb_get_table(&address, &table_info); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not get the RSDT/XSDT, %s\n", + acpi_format_exception(status))); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n", - acpi_gbl_RSDP, - ACPI_FORMAT_UINT64 (address.pointer.value))); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n", + acpi_gbl_RSDP, + ACPI_FORMAT_UINT64(address.pointer.value))); /* Check the RSDT or XSDT signature */ - status = acpi_tb_validate_rsdt (table_info.pointer); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_validate_rsdt(table_info.pointer); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Get the number of tables defined in the RSDT or XSDT */ - acpi_gbl_rsdt_table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, - table_info.pointer); + acpi_gbl_rsdt_table_count = acpi_tb_get_table_count(acpi_gbl_RSDP, + table_info.pointer); /* Convert and/or copy to an XSDT structure */ - status = acpi_tb_convert_to_xsdt (&table_info); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_convert_to_xsdt(&table_info); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Save the table pointers and allocation info */ - status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_init_table_descriptor(ACPI_TABLE_XSDT, &table_info); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - acpi_gbl_XSDT = ACPI_CAST_PTR (XSDT_DESCRIPTOR, table_info.pointer); + acpi_gbl_XSDT = ACPI_CAST_PTR(XSDT_DESCRIPTOR, table_info.pointer); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT)); - return_ACPI_STATUS (status); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT)); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index 6fc1e36..5bcafeb 100644 --- a/drivers/acpi/tables/tbutils.c +++ b/drivers/acpi/tables/tbutils.c @@ -41,24 +41,18 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbutils") +ACPI_MODULE_NAME("tbutils") /* Local prototypes */ - #ifdef ACPI_OBSOLETE_FUNCTIONS acpi_status -acpi_tb_handle_to_object ( - u16 table_id, - struct acpi_table_desc **table_desc); +acpi_tb_handle_to_object(u16 table_id, struct acpi_table_desc **table_desc); #endif - /******************************************************************************* * * FUNCTION: acpi_tb_is_table_installed @@ -73,15 +67,11 @@ acpi_tb_handle_to_object ( * ******************************************************************************/ -acpi_status -acpi_tb_is_table_installed ( - struct acpi_table_desc *new_table_desc) +acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc) { - struct acpi_table_desc *table_desc; - - - ACPI_FUNCTION_TRACE ("tb_is_table_installed"); + struct acpi_table_desc *table_desc; + ACPI_FUNCTION_TRACE("tb_is_table_installed"); /* Get the list descriptor and first table descriptor */ @@ -93,22 +83,23 @@ acpi_tb_is_table_installed ( /* Compare Revision and oem_table_id */ if ((table_desc->loaded_into_namespace) && - (table_desc->pointer->revision == - new_table_desc->pointer->revision) && - (!ACPI_MEMCMP (table_desc->pointer->oem_table_id, - new_table_desc->pointer->oem_table_id, 8))) { + (table_desc->pointer->revision == + new_table_desc->pointer->revision) && + (!ACPI_MEMCMP(table_desc->pointer->oem_table_id, + new_table_desc->pointer->oem_table_id, 8))) { /* This table is already installed */ - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, - "Table [%4.4s] already installed: Rev %X oem_table_id [%8.8s]\n", - new_table_desc->pointer->signature, - new_table_desc->pointer->revision, - new_table_desc->pointer->oem_table_id)); + ACPI_DEBUG_PRINT((ACPI_DB_TABLES, + "Table [%4.4s] already installed: Rev %X oem_table_id [%8.8s]\n", + new_table_desc->pointer->signature, + new_table_desc->pointer->revision, + new_table_desc->pointer-> + oem_table_id)); - new_table_desc->owner_id = table_desc->owner_id; + new_table_desc->owner_id = table_desc->owner_id; new_table_desc->installed_desc = table_desc; - return_ACPI_STATUS (AE_ALREADY_EXISTS); + return_ACPI_STATUS(AE_ALREADY_EXISTS); } /* Get next table on the list */ @@ -116,10 +107,9 @@ acpi_tb_is_table_installed ( table_desc = table_desc->next; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_tb_validate_table_header @@ -141,57 +131,55 @@ acpi_tb_is_table_installed ( ******************************************************************************/ acpi_status -acpi_tb_validate_table_header ( - struct acpi_table_header *table_header) +acpi_tb_validate_table_header(struct acpi_table_header *table_header) { - acpi_name signature; - - - ACPI_FUNCTION_NAME ("tb_validate_table_header"); + acpi_name signature; + ACPI_FUNCTION_NAME("tb_validate_table_header"); /* Verify that this is a valid address */ - if (!acpi_os_readable (table_header, sizeof (struct acpi_table_header))) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Cannot read table header at %p\n", table_header)); + if (!acpi_os_readable(table_header, sizeof(struct acpi_table_header))) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Cannot read table header at %p\n", + table_header)); return (AE_BAD_ADDRESS); } /* Ensure that the signature is 4 ASCII characters */ - ACPI_MOVE_32_TO_32 (&signature, table_header->signature); - if (!acpi_ut_valid_acpi_name (signature)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Table signature at %p [%p] has invalid characters\n", - table_header, &signature)); + ACPI_MOVE_32_TO_32(&signature, table_header->signature); + if (!acpi_ut_valid_acpi_name(signature)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Table signature at %p [%p] has invalid characters\n", + table_header, &signature)); - ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n", - (char *) &signature)); + ACPI_REPORT_WARNING(("Invalid table signature found: [%4.4s]\n", + (char *)&signature)); - ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header)); + ACPI_DUMP_BUFFER(table_header, + sizeof(struct acpi_table_header)); return (AE_BAD_SIGNATURE); } /* Validate the table length */ - if (table_header->length < sizeof (struct acpi_table_header)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid length in table header %p name %4.4s\n", - table_header, (char *) &signature)); + if (table_header->length < sizeof(struct acpi_table_header)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid length in table header %p name %4.4s\n", + table_header, (char *)&signature)); - ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n", - (u32) table_header->length)); + ACPI_REPORT_WARNING(("Invalid table header length (0x%X) found\n", (u32) table_header->length)); - ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header)); + ACPI_DUMP_BUFFER(table_header, + sizeof(struct acpi_table_header)); return (AE_BAD_HEADER); } return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_tb_verify_table_checksum @@ -206,34 +194,28 @@ acpi_tb_validate_table_header ( ******************************************************************************/ acpi_status -acpi_tb_verify_table_checksum ( - struct acpi_table_header *table_header) +acpi_tb_verify_table_checksum(struct acpi_table_header * table_header) { - u8 checksum; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("tb_verify_table_checksum"); + u8 checksum; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("tb_verify_table_checksum"); /* Compute the checksum on the table */ - checksum = acpi_tb_generate_checksum (table_header, table_header->length); + checksum = + acpi_tb_generate_checksum(table_header, table_header->length); /* Return the appropriate exception */ if (checksum) { - ACPI_REPORT_WARNING (( - "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", - table_header->signature, (u32) table_header->checksum, - (u32) checksum)); + ACPI_REPORT_WARNING(("Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", table_header->signature, (u32) table_header->checksum, (u32) checksum)); status = AE_BAD_CHECKSUM; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_tb_generate_checksum @@ -247,15 +229,11 @@ acpi_tb_verify_table_checksum ( * ******************************************************************************/ -u8 -acpi_tb_generate_checksum ( - void *buffer, - u32 length) +u8 acpi_tb_generate_checksum(void *buffer, u32 length) { - const u8 *limit; - const u8 *rover; - u8 sum = 0; - + const u8 *limit; + const u8 *rover; + u8 sum = 0; if (buffer && length) { /* Buffer and Length are valid */ @@ -269,7 +247,6 @@ acpi_tb_generate_checksum ( return (sum); } - #ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * @@ -285,16 +262,13 @@ acpi_tb_generate_checksum ( ******************************************************************************/ acpi_status -acpi_tb_handle_to_object ( - u16 table_id, - struct acpi_table_desc **return_table_desc) +acpi_tb_handle_to_object(u16 table_id, + struct acpi_table_desc ** return_table_desc) { - u32 i; - struct acpi_table_desc *table_desc; - - - ACPI_FUNCTION_NAME ("tb_handle_to_object"); + u32 i; + struct acpi_table_desc *table_desc; + ACPI_FUNCTION_NAME("tb_handle_to_object"); for (i = 0; i < ACPI_TABLE_MAX; i++) { table_desc = acpi_gbl_table_lists[i].next; @@ -308,9 +282,8 @@ acpi_tb_handle_to_object ( } } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "table_id=%X does not exist\n", table_id)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "table_id=%X does not exist\n", + table_id)); return (AE_BAD_PARAMETER); } #endif - - diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c index e18a05d..3f96a49 100644 --- a/drivers/acpi/tables/tbxface.c +++ b/drivers/acpi/tables/tbxface.c @@ -48,10 +48,8 @@ #include #include - #define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbxface") - +ACPI_MODULE_NAME("tbxface") /******************************************************************************* * @@ -65,25 +63,20 @@ * provided RSDT * ******************************************************************************/ - -acpi_status -acpi_load_tables ( - void) +acpi_status acpi_load_tables(void) { - struct acpi_pointer rsdp_address; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_load_tables"); + struct acpi_pointer rsdp_address; + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_load_tables"); /* Get the RSDP */ - status = acpi_os_get_root_pointer (ACPI_LOGICAL_ADDRESSING, - &rsdp_address); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("acpi_load_tables: Could not get RSDP, %s\n", - acpi_format_exception (status))); + status = acpi_os_get_root_pointer(ACPI_LOGICAL_ADDRESSING, + &rsdp_address); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("acpi_load_tables: Could not get RSDP, %s\n", + acpi_format_exception(status))); goto error_exit; } @@ -91,54 +84,47 @@ acpi_load_tables ( acpi_gbl_table_flags = rsdp_address.pointer_type; - status = acpi_tb_verify_rsdp (&rsdp_address); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("acpi_load_tables: RSDP Failed validation: %s\n", - acpi_format_exception (status))); + status = acpi_tb_verify_rsdp(&rsdp_address); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("acpi_load_tables: RSDP Failed validation: %s\n", acpi_format_exception(status))); goto error_exit; } /* Get the RSDT via the RSDP */ - status = acpi_tb_get_table_rsdt (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("acpi_load_tables: Could not load RSDT: %s\n", - acpi_format_exception (status))); + status = acpi_tb_get_table_rsdt(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("acpi_load_tables: Could not load RSDT: %s\n", acpi_format_exception(status))); goto error_exit; } /* Now get the tables needed by this subsystem (FADT, DSDT, etc.) */ - status = acpi_tb_get_required_tables (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (( - "acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n", - acpi_format_exception (status))); + status = acpi_tb_get_required_tables(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n", acpi_format_exception(status))); goto error_exit; } - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); /* Load the namespace from the tables */ - status = acpi_ns_load_namespace (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("acpi_load_tables: Could not load namespace: %s\n", - acpi_format_exception (status))); + status = acpi_ns_load_namespace(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("acpi_load_tables: Could not load namespace: %s\n", acpi_format_exception(status))); goto error_exit; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); + error_exit: + ACPI_REPORT_ERROR(("acpi_load_tables: Could not load tables: %s\n", + acpi_format_exception(status))); -error_exit: - ACPI_REPORT_ERROR (("acpi_load_tables: Could not load tables: %s\n", - acpi_format_exception (status))); - - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - #ifdef ACPI_FUTURE_USAGE /******************************************************************************* * @@ -156,43 +142,39 @@ error_exit: * ******************************************************************************/ -acpi_status -acpi_load_table ( - struct acpi_table_header *table_ptr) +acpi_status acpi_load_table(struct acpi_table_header *table_ptr) { - acpi_status status; - struct acpi_table_desc table_info; - struct acpi_pointer address; - - - ACPI_FUNCTION_TRACE ("acpi_load_table"); + acpi_status status; + struct acpi_table_desc table_info; + struct acpi_pointer address; + ACPI_FUNCTION_TRACE("acpi_load_table"); if (!table_ptr) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Copy the table to a local buffer */ - address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING; + address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING; address.pointer.logical = table_ptr; - status = acpi_tb_get_table_body (&address, table_ptr, &table_info); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_get_table_body(&address, table_ptr, &table_info); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Check signature for a valid table type */ - status = acpi_tb_recognize_table (&table_info, ACPI_TABLE_ALL); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_recognize_table(&table_info, ACPI_TABLE_ALL); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Install the new table into the local data structures */ - status = acpi_tb_install_table (&table_info); - if (ACPI_FAILURE (status)) { + status = acpi_tb_install_table(&table_info); + if (ACPI_FAILURE(status)) { if (status == AE_ALREADY_EXISTS) { /* Table already exists, no error */ @@ -201,8 +183,8 @@ acpi_load_table ( /* Free table allocated by acpi_tb_get_table_body */ - acpi_tb_delete_single_table (&table_info); - return_ACPI_STATUS (status); + acpi_tb_delete_single_table(&table_info); + return_ACPI_STATUS(status); } /* Convert the table to common format if necessary */ @@ -210,31 +192,32 @@ acpi_load_table ( switch (table_info.type) { case ACPI_TABLE_FADT: - status = acpi_tb_convert_table_fadt (); + status = acpi_tb_convert_table_fadt(); break; case ACPI_TABLE_FACS: - status = acpi_tb_build_common_facs (&table_info); + status = acpi_tb_build_common_facs(&table_info); break; default: /* Load table into namespace if it contains executable AML */ - status = acpi_ns_load_table (table_info.installed_desc, acpi_gbl_root_node); + status = + acpi_ns_load_table(table_info.installed_desc, + acpi_gbl_root_node); break; } - if (ACPI_FAILURE (status)) { + if (ACPI_FAILURE(status)) { /* Uninstall table and free the buffer */ - (void) acpi_tb_uninstall_table (table_info.installed_desc); + (void)acpi_tb_uninstall_table(table_info.installed_desc); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_unload_table @@ -247,20 +230,16 @@ acpi_load_table ( * ******************************************************************************/ -acpi_status -acpi_unload_table ( - acpi_table_type table_type) +acpi_status acpi_unload_table(acpi_table_type table_type) { - struct acpi_table_desc *table_desc; - - - ACPI_FUNCTION_TRACE ("acpi_unload_table"); + struct acpi_table_desc *table_desc; + ACPI_FUNCTION_TRACE("acpi_unload_table"); /* Parameter validation */ if (table_type > ACPI_TABLE_MAX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Find all tables of the requested type */ @@ -273,18 +252,17 @@ acpi_unload_table ( * "Scope" operator. Thus, we need to track ownership by an ID, not * simply a position within the hierarchy */ - acpi_ns_delete_namespace_by_owner (table_desc->owner_id); - acpi_ut_release_owner_id (&table_desc->owner_id); + acpi_ns_delete_namespace_by_owner(table_desc->owner_id); + acpi_ut_release_owner_id(&table_desc->owner_id); table_desc = table_desc->next; } /* Delete (or unmap) all tables of this type */ - acpi_tb_delete_tables_by_type (table_type); - return_ACPI_STATUS (AE_OK); + acpi_tb_delete_tables_by_type(table_type); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_get_table_header @@ -307,54 +285,49 @@ acpi_unload_table ( ******************************************************************************/ acpi_status -acpi_get_table_header ( - acpi_table_type table_type, - u32 instance, - struct acpi_table_header *out_table_header) +acpi_get_table_header(acpi_table_type table_type, + u32 instance, struct acpi_table_header *out_table_header) { - struct acpi_table_header *tbl_ptr; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_get_table_header"); + struct acpi_table_header *tbl_ptr; + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_get_table_header"); - if ((instance == 0) || - (table_type == ACPI_TABLE_RSDP) || - (!out_table_header)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if ((instance == 0) || + (table_type == ACPI_TABLE_RSDP) || (!out_table_header)) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Check the table type and instance */ - if ((table_type > ACPI_TABLE_MAX) || - (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) && - instance > 1)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if ((table_type > ACPI_TABLE_MAX) || + (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) && + instance > 1)) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Get a pointer to the entire table */ - status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_get_table_ptr(table_type, instance, &tbl_ptr); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* The function will return a NULL pointer if the table is not loaded */ if (tbl_ptr == NULL) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } /* Copy the header to the caller's buffer */ - ACPI_MEMCPY ((void *) out_table_header, (void *) tbl_ptr, - sizeof (struct acpi_table_header)); + ACPI_MEMCPY((void *)out_table_header, (void *)tbl_ptr, + sizeof(struct acpi_table_header)); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } -#endif /* ACPI_FUTURE_USAGE */ +#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * @@ -380,43 +353,39 @@ acpi_get_table_header ( ******************************************************************************/ acpi_status -acpi_get_table ( - acpi_table_type table_type, - u32 instance, - struct acpi_buffer *ret_buffer) +acpi_get_table(acpi_table_type table_type, + u32 instance, struct acpi_buffer *ret_buffer) { - struct acpi_table_header *tbl_ptr; - acpi_status status; - acpi_size table_length; - - - ACPI_FUNCTION_TRACE ("acpi_get_table"); + struct acpi_table_header *tbl_ptr; + acpi_status status; + acpi_size table_length; + ACPI_FUNCTION_TRACE("acpi_get_table"); /* Parameter validation */ if (instance == 0) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_ut_validate_buffer (ret_buffer); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_validate_buffer(ret_buffer); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Check the table type and instance */ - if ((table_type > ACPI_TABLE_MAX) || - (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) && - instance > 1)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if ((table_type > ACPI_TABLE_MAX) || + (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) && + instance > 1)) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Get a pointer to the entire table */ - status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_get_table_ptr(table_type, instance, &tbl_ptr); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -424,7 +393,7 @@ acpi_get_table ( * table is not loaded. */ if (tbl_ptr == NULL) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } /* Get the table length */ @@ -432,23 +401,22 @@ acpi_get_table ( if (table_type == ACPI_TABLE_RSDP) { /* RSD PTR is the only "table" without a header */ - table_length = sizeof (struct rsdp_descriptor); - } - else { + table_length = sizeof(struct rsdp_descriptor); + } else { table_length = (acpi_size) tbl_ptr->length; } /* Validate/Allocate/Clear caller buffer */ - status = acpi_ut_initialize_buffer (ret_buffer, table_length); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_initialize_buffer(ret_buffer, table_length); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Copy the table to the buffer */ - ACPI_MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, table_length); - return_ACPI_STATUS (AE_OK); + ACPI_MEMCPY((void *)ret_buffer->pointer, (void *)tbl_ptr, table_length); + return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_get_table); +EXPORT_SYMBOL(acpi_get_table); diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c index 87dccdd..3b8a7e0 100644 --- a/drivers/acpi/tables/tbxfroot.c +++ b/drivers/acpi/tables/tbxfroot.c @@ -46,22 +46,14 @@ #include #include - #define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbxfroot") +ACPI_MODULE_NAME("tbxfroot") /* Local prototypes */ - static acpi_status -acpi_tb_find_rsdp ( - struct acpi_table_desc *table_info, - u32 flags); - -static u8 * -acpi_tb_scan_memory_for_rsdp ( - u8 *start_address, - u32 length); +acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags); +static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length); /******************************************************************************* * @@ -75,17 +67,14 @@ acpi_tb_scan_memory_for_rsdp ( * ******************************************************************************/ -acpi_status -acpi_tb_validate_rsdp ( - struct rsdp_descriptor *rsdp) +acpi_status acpi_tb_validate_rsdp(struct rsdp_descriptor *rsdp) { - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_ENTRY(); /* * The signature and checksum must both be correct */ - if (ACPI_STRNCMP ((char *) rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { + if (ACPI_STRNCMP((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0) { /* Nope, BAD Signature */ return (AE_BAD_SIGNATURE); @@ -93,21 +82,21 @@ acpi_tb_validate_rsdp ( /* Check the standard checksum */ - if (acpi_tb_generate_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { + if (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { return (AE_BAD_CHECKSUM); } /* Check extended checksum if table version >= 2 */ if ((rsdp->revision >= 2) && - (acpi_tb_generate_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) { + (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != + 0)) { return (AE_BAD_CHECKSUM); } return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_tb_find_table @@ -125,28 +114,24 @@ acpi_tb_validate_rsdp ( ******************************************************************************/ acpi_status -acpi_tb_find_table ( - char *signature, - char *oem_id, - char *oem_table_id, - struct acpi_table_header **table_ptr) +acpi_tb_find_table(char *signature, + char *oem_id, + char *oem_table_id, struct acpi_table_header ** table_ptr) { - acpi_status status; - struct acpi_table_header *table; - - - ACPI_FUNCTION_TRACE ("tb_find_table"); + acpi_status status; + struct acpi_table_header *table; + ACPI_FUNCTION_TRACE("tb_find_table"); /* Validate string lengths */ - if ((ACPI_STRLEN (signature) > ACPI_NAME_SIZE) || - (ACPI_STRLEN (oem_id) > sizeof (table->oem_id)) || - (ACPI_STRLEN (oem_table_id) > sizeof (table->oem_table_id))) { - return_ACPI_STATUS (AE_AML_STRING_LIMIT); + if ((ACPI_STRLEN(signature) > ACPI_NAME_SIZE) || + (ACPI_STRLEN(oem_id) > sizeof(table->oem_id)) || + (ACPI_STRLEN(oem_table_id) > sizeof(table->oem_table_id))) { + return_ACPI_STATUS(AE_AML_STRING_LIMIT); } - if (!ACPI_STRNCMP (signature, DSDT_SIG, ACPI_NAME_SIZE)) { + if (!ACPI_STRNCMP(signature, DSDT_SIG, ACPI_NAME_SIZE)) { /* * The DSDT pointer is contained in the FADT, not the RSDT. * This code should suffice, because the only code that would perform @@ -155,40 +140,36 @@ acpi_tb_find_table ( * If this becomes insufficient, the FADT will have to be found first. */ if (!acpi_gbl_DSDT) { - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + return_ACPI_STATUS(AE_NO_ACPI_TABLES); } table = acpi_gbl_DSDT; - } - else { + } else { /* Find the table */ - status = acpi_get_firmware_table (signature, 1, - ACPI_LOGICAL_ADDRESSING, &table); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_get_firmware_table(signature, 1, + ACPI_LOGICAL_ADDRESSING, + &table); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Check oem_id and oem_table_id */ - if ((oem_id[0] && ACPI_STRNCMP ( - oem_id, table->oem_id, - sizeof (table->oem_id))) || - - (oem_table_id[0] && ACPI_STRNCMP ( - oem_table_id, table->oem_table_id, - sizeof (table->oem_table_id)))) { - return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND); + if ((oem_id[0] && ACPI_STRNCMP(oem_id, table->oem_id, + sizeof(table->oem_id))) || + (oem_table_id[0] && ACPI_STRNCMP(oem_table_id, table->oem_table_id, + sizeof(table->oem_table_id)))) { + return_ACPI_STATUS(AE_AML_NAME_NOT_FOUND); } - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", - table->signature)); + ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Found table [%4.4s]\n", + table->signature)); *table_ptr = table; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_get_firmware_table @@ -209,34 +190,28 @@ acpi_tb_find_table ( ******************************************************************************/ acpi_status -acpi_get_firmware_table ( - acpi_string signature, - u32 instance, - u32 flags, - struct acpi_table_header **table_pointer) +acpi_get_firmware_table(acpi_string signature, + u32 instance, + u32 flags, struct acpi_table_header **table_pointer) { - acpi_status status; - struct acpi_pointer address; - struct acpi_table_header *header = NULL; - struct acpi_table_desc *table_info = NULL; - struct acpi_table_desc *rsdt_info; - u32 table_count; - u32 i; - u32 j; - - - ACPI_FUNCTION_TRACE ("acpi_get_firmware_table"); + acpi_status status; + struct acpi_pointer address; + struct acpi_table_header *header = NULL; + struct acpi_table_desc *table_info = NULL; + struct acpi_table_desc *rsdt_info; + u32 table_count; + u32 i; + u32 j; + ACPI_FUNCTION_TRACE("acpi_get_firmware_table"); /* * Ensure that at least the table manager is initialized. We don't * require that the entire ACPI subsystem is up for this interface. * If we have a buffer, we must have a length too */ - if ((instance == 0) || - (!signature) || - (!table_pointer)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if ((instance == 0) || (!signature) || (!table_pointer)) { + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Ensure that we have a RSDP */ @@ -244,40 +219,41 @@ acpi_get_firmware_table ( if (!acpi_gbl_RSDP) { /* Get the RSDP */ - status = acpi_os_get_root_pointer (flags, &address); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + status = acpi_os_get_root_pointer(flags, &address); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "RSDP not found\n")); + return_ACPI_STATUS(AE_NO_ACPI_TABLES); } /* Map and validate the RSDP */ if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { - status = acpi_os_map_memory (address.pointer.physical, - sizeof (struct rsdp_descriptor), (void *) &acpi_gbl_RSDP); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_os_map_memory(address.pointer.physical, + sizeof(struct + rsdp_descriptor), + (void *)&acpi_gbl_RSDP); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - } - else { + } else { acpi_gbl_RSDP = address.pointer.logical; } /* The RDSP signature and checksum must both be correct */ - status = acpi_tb_validate_rsdp (acpi_gbl_RSDP); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_validate_rsdp(acpi_gbl_RSDP); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Get the RSDT address via the RSDP */ - acpi_tb_get_rsdt_address (&address); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", - acpi_gbl_RSDP, - ACPI_FORMAT_UINT64 (address.pointer.value))); + acpi_tb_get_rsdt_address(&address); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", + acpi_gbl_RSDP, + ACPI_FORMAT_UINT64(address.pointer.value))); /* Insert processor_mode flags */ @@ -285,30 +261,30 @@ acpi_get_firmware_table ( /* Get and validate the RSDT */ - rsdt_info = ACPI_MEM_CALLOCATE (sizeof (struct acpi_table_desc)); + rsdt_info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc)); if (!rsdt_info) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } - status = acpi_tb_get_table (&address, rsdt_info); - if (ACPI_FAILURE (status)) { + status = acpi_tb_get_table(&address, rsdt_info); + if (ACPI_FAILURE(status)) { goto cleanup; } - status = acpi_tb_validate_rsdt (rsdt_info->pointer); - if (ACPI_FAILURE (status)) { + status = acpi_tb_validate_rsdt(rsdt_info->pointer); + if (ACPI_FAILURE(status)) { goto cleanup; } /* Allocate a scratch table header and table descriptor */ - header = ACPI_MEM_ALLOCATE (sizeof (struct acpi_table_header)); + header = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_header)); if (!header) { status = AE_NO_MEMORY; goto cleanup; } - table_info = ACPI_MEM_ALLOCATE (sizeof (struct acpi_table_desc)); + table_info = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_desc)); if (!table_info) { status = AE_NO_MEMORY; goto cleanup; @@ -316,7 +292,8 @@ acpi_get_firmware_table ( /* Get the number of table pointers within the RSDT */ - table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, rsdt_info->pointer); + table_count = + acpi_tb_get_table_count(acpi_gbl_RSDP, rsdt_info->pointer); address.pointer_type = acpi_gbl_table_flags | flags; /* @@ -329,32 +306,37 @@ acpi_get_firmware_table ( * RSDT pointers are 32 bits, XSDT pointers are 64 bits */ if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { - address.pointer.value = (ACPI_CAST_PTR ( - RSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; - } - else { - address.pointer.value = (ACPI_CAST_PTR ( - XSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; + address.pointer.value = + (ACPI_CAST_PTR + (RSDT_DESCRIPTOR, + rsdt_info->pointer))->table_offset_entry[i]; + } else { + address.pointer.value = + (ACPI_CAST_PTR + (XSDT_DESCRIPTOR, + rsdt_info->pointer))->table_offset_entry[i]; } /* Get the table header */ - status = acpi_tb_get_table_header (&address, header); - if (ACPI_FAILURE (status)) { + status = acpi_tb_get_table_header(&address, header); + if (ACPI_FAILURE(status)) { goto cleanup; } /* Compare table signatures and table instance */ - if (!ACPI_STRNCMP (header->signature, signature, ACPI_NAME_SIZE)) { + if (!ACPI_STRNCMP(header->signature, signature, ACPI_NAME_SIZE)) { /* An instance of the table was found */ j++; if (j >= instance) { /* Found the correct instance, get the entire table */ - status = acpi_tb_get_table_body (&address, header, table_info); - if (ACPI_FAILURE (status)) { + status = + acpi_tb_get_table_body(&address, header, + table_info); + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -368,24 +350,23 @@ acpi_get_firmware_table ( status = AE_NOT_EXIST; - -cleanup: + cleanup: if (rsdt_info->pointer) { - acpi_os_unmap_memory (rsdt_info->pointer, - (acpi_size) rsdt_info->pointer->length); + acpi_os_unmap_memory(rsdt_info->pointer, + (acpi_size) rsdt_info->pointer->length); } - ACPI_MEM_FREE (rsdt_info); + ACPI_MEM_FREE(rsdt_info); if (header) { - ACPI_MEM_FREE (header); + ACPI_MEM_FREE(header); } if (table_info) { - ACPI_MEM_FREE (table_info); + ACPI_MEM_FREE(table_info); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_firmware_table); +EXPORT_SYMBOL(acpi_get_firmware_table); /* TBD: Move to a new file */ @@ -404,35 +385,29 @@ EXPORT_SYMBOL(acpi_get_firmware_table); * ******************************************************************************/ -acpi_status -acpi_find_root_pointer ( - u32 flags, - struct acpi_pointer *rsdp_address) +acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address) { - struct acpi_table_desc table_info; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_find_root_pointer"); + struct acpi_table_desc table_info; + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_find_root_pointer"); /* Get the RSDP */ - status = acpi_tb_find_rsdp (&table_info, flags); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "RSDP structure not found, %s Flags=%X\n", - acpi_format_exception (status), flags)); + status = acpi_tb_find_rsdp(&table_info, flags); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "RSDP structure not found, %s Flags=%X\n", + acpi_format_exception(status), flags)); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + return_ACPI_STATUS(AE_NO_ACPI_TABLES); } rsdp_address->pointer_type = ACPI_PHYSICAL_POINTER; rsdp_address->pointer.physical = table_info.physical_address; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_tb_scan_memory_for_rsdp @@ -446,34 +421,32 @@ acpi_find_root_pointer ( * ******************************************************************************/ -static u8 * -acpi_tb_scan_memory_for_rsdp ( - u8 *start_address, - u32 length) +static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length) { - acpi_status status; - u8 *mem_rover; - u8 *end_address; - - - ACPI_FUNCTION_TRACE ("tb_scan_memory_for_rsdp"); + acpi_status status; + u8 *mem_rover; + u8 *end_address; + ACPI_FUNCTION_TRACE("tb_scan_memory_for_rsdp"); end_address = start_address + length; /* Search from given start address for the requested length */ for (mem_rover = start_address; mem_rover < end_address; - mem_rover += ACPI_RSDP_SCAN_STEP) { + mem_rover += ACPI_RSDP_SCAN_STEP) { /* The RSDP signature and checksum must both be correct */ - status = acpi_tb_validate_rsdp (ACPI_CAST_PTR (struct rsdp_descriptor, mem_rover)); - if (ACPI_SUCCESS (status)) { + status = + acpi_tb_validate_rsdp(ACPI_CAST_PTR + (struct rsdp_descriptor, mem_rover)); + if (ACPI_SUCCESS(status)) { /* Sig and checksum valid, we have found a real RSDP */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "RSDP located at physical address %p\n", mem_rover)); - return_PTR (mem_rover); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "RSDP located at physical address %p\n", + mem_rover)); + return_PTR(mem_rover); } /* No sig match or bad checksum, keep searching */ @@ -481,13 +454,12 @@ acpi_tb_scan_memory_for_rsdp ( /* Searched entire block, no RSDP was found */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Searched entire block from %p, valid RSDP was not found\n", - start_address)); - return_PTR (NULL); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Searched entire block from %p, valid RSDP was not found\n", + start_address)); + return_PTR(NULL); } - /******************************************************************************* * * FUNCTION: acpi_tb_find_rsdp @@ -511,18 +483,14 @@ acpi_tb_scan_memory_for_rsdp ( ******************************************************************************/ static acpi_status -acpi_tb_find_rsdp ( - struct acpi_table_desc *table_info, - u32 flags) +acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags) { - u8 *table_ptr; - u8 *mem_rover; - u32 physical_address; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("tb_find_rsdp"); + u8 *table_ptr; + u8 *mem_rover; + u32 physical_address; + acpi_status status; + ACPI_FUNCTION_TRACE("tb_find_rsdp"); /* * Scan supports either logical addressing or physical addressing @@ -530,23 +498,25 @@ acpi_tb_find_rsdp ( if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ - status = acpi_os_map_memory ( - (acpi_physical_address) ACPI_EBDA_PTR_LOCATION, - ACPI_EBDA_PTR_LENGTH, (void *) &table_ptr); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not map memory at %8.8X for length %X\n", - ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); - - return_ACPI_STATUS (status); + status = acpi_os_map_memory((acpi_physical_address) + ACPI_EBDA_PTR_LOCATION, + ACPI_EBDA_PTR_LENGTH, + (void *)&table_ptr); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not map memory at %8.8X for length %X\n", + ACPI_EBDA_PTR_LOCATION, + ACPI_EBDA_PTR_LENGTH)); + + return_ACPI_STATUS(status); } - ACPI_MOVE_16_TO_32 (&physical_address, table_ptr); + ACPI_MOVE_16_TO_32(&physical_address, table_ptr); /* Convert segment part to physical address */ physical_address <<= 4; - acpi_os_unmap_memory (table_ptr, ACPI_EBDA_PTR_LENGTH); + acpi_os_unmap_memory(table_ptr, ACPI_EBDA_PTR_LENGTH); /* EBDA present? */ @@ -555,59 +525,67 @@ acpi_tb_find_rsdp ( * 1b) Search EBDA paragraphs (EBDa is required to be a * minimum of 1_k length) */ - status = acpi_os_map_memory ( - (acpi_physical_address) physical_address, - ACPI_EBDA_WINDOW_SIZE, (void *) &table_ptr); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not map memory at %8.8X for length %X\n", - physical_address, ACPI_EBDA_WINDOW_SIZE)); - - return_ACPI_STATUS (status); + status = acpi_os_map_memory((acpi_physical_address) + physical_address, + ACPI_EBDA_WINDOW_SIZE, + (void *)&table_ptr); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not map memory at %8.8X for length %X\n", + physical_address, + ACPI_EBDA_WINDOW_SIZE)); + + return_ACPI_STATUS(status); } - mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, - ACPI_EBDA_WINDOW_SIZE); - acpi_os_unmap_memory (table_ptr, ACPI_EBDA_WINDOW_SIZE); + mem_rover = acpi_tb_scan_memory_for_rsdp(table_ptr, + ACPI_EBDA_WINDOW_SIZE); + acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE); if (mem_rover) { /* Return the physical address */ - physical_address += ACPI_PTR_DIFF (mem_rover, table_ptr); + physical_address += + ACPI_PTR_DIFF(mem_rover, table_ptr); table_info->physical_address = - (acpi_physical_address) physical_address; - return_ACPI_STATUS (AE_OK); + (acpi_physical_address) physical_address; + return_ACPI_STATUS(AE_OK); } } /* * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */ - status = acpi_os_map_memory ( - (acpi_physical_address) ACPI_HI_RSDP_WINDOW_BASE, - ACPI_HI_RSDP_WINDOW_SIZE, (void *) &table_ptr); - - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not map memory at %8.8X for length %X\n", - ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); - - return_ACPI_STATUS (status); + status = acpi_os_map_memory((acpi_physical_address) + ACPI_HI_RSDP_WINDOW_BASE, + ACPI_HI_RSDP_WINDOW_SIZE, + (void *)&table_ptr); + + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Could not map memory at %8.8X for length %X\n", + ACPI_HI_RSDP_WINDOW_BASE, + ACPI_HI_RSDP_WINDOW_SIZE)); + + return_ACPI_STATUS(status); } - mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); - acpi_os_unmap_memory (table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); + mem_rover = + acpi_tb_scan_memory_for_rsdp(table_ptr, + ACPI_HI_RSDP_WINDOW_SIZE); + acpi_os_unmap_memory(table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); if (mem_rover) { /* Return the physical address */ physical_address = - ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (mem_rover, table_ptr); + ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF(mem_rover, + table_ptr); table_info->physical_address = - (acpi_physical_address) physical_address; - return_ACPI_STATUS (AE_OK); + (acpi_physical_address) physical_address; + return_ACPI_STATUS(AE_OK); } } @@ -617,8 +595,8 @@ acpi_tb_find_rsdp ( else { /* 1a) Get the location of the EBDA */ - ACPI_MOVE_16_TO_32 (&physical_address, ACPI_EBDA_PTR_LOCATION); - physical_address <<= 4; /* Convert segment to physical address */ + ACPI_MOVE_16_TO_32(&physical_address, ACPI_EBDA_PTR_LOCATION); + physical_address <<= 4; /* Convert segment to physical address */ /* EBDA present? */ @@ -627,35 +605,38 @@ acpi_tb_find_rsdp ( * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of * 1_k length) */ - mem_rover = acpi_tb_scan_memory_for_rsdp ( - ACPI_PHYSADDR_TO_PTR (physical_address), - ACPI_EBDA_WINDOW_SIZE); + mem_rover = + acpi_tb_scan_memory_for_rsdp(ACPI_PHYSADDR_TO_PTR + (physical_address), + ACPI_EBDA_WINDOW_SIZE); if (mem_rover) { /* Return the physical address */ - table_info->physical_address = ACPI_TO_INTEGER (mem_rover); - return_ACPI_STATUS (AE_OK); + table_info->physical_address = + ACPI_TO_INTEGER(mem_rover); + return_ACPI_STATUS(AE_OK); } } /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */ - mem_rover = acpi_tb_scan_memory_for_rsdp ( - ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE), - ACPI_HI_RSDP_WINDOW_SIZE); + mem_rover = + acpi_tb_scan_memory_for_rsdp(ACPI_PHYSADDR_TO_PTR + (ACPI_HI_RSDP_WINDOW_BASE), + ACPI_HI_RSDP_WINDOW_SIZE); if (mem_rover) { /* Found it, return the physical address */ - table_info->physical_address = ACPI_TO_INTEGER (mem_rover); - return_ACPI_STATUS (AE_OK); + table_info->physical_address = + ACPI_TO_INTEGER(mem_rover); + return_ACPI_STATUS(AE_OK); } } /* A valid RSDP was not found */ - ACPI_REPORT_ERROR (("No valid RSDP was found\n")); - return_ACPI_STATUS (AE_NOT_FOUND); + ACPI_REPORT_ERROR(("No valid RSDP was found\n")); + return_ACPI_STATUS(AE_NOT_FOUND); } #endif - diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 79c3a68..a24847c 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -70,9 +70,9 @@ #define CELSIUS_TO_KELVIN(t) ((t+273)*10) #define _COMPONENT ACPI_THERMAL_COMPONENT -ACPI_MODULE_NAME ("acpi_thermal") +ACPI_MODULE_NAME("acpi_thermal") -MODULE_AUTHOR("Paul Diefenbaugh"); + MODULE_AUTHOR("Paul Diefenbaugh"); MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME); MODULE_LICENSE("GPL"); @@ -80,143 +80,145 @@ static int tzp; module_param(tzp, int, 0); MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n"); - -static int acpi_thermal_add (struct acpi_device *device); -static int acpi_thermal_remove (struct acpi_device *device, int type); +static int acpi_thermal_add(struct acpi_device *device); +static int acpi_thermal_remove(struct acpi_device *device, int type); static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); -static ssize_t acpi_thermal_write_trip_points (struct file*,const char __user *,size_t,loff_t *); +static ssize_t acpi_thermal_write_trip_points(struct file *, + const char __user *, size_t, + loff_t *); static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file); -static ssize_t acpi_thermal_write_cooling_mode (struct file*,const char __user *,size_t,loff_t *); +static ssize_t acpi_thermal_write_cooling_mode(struct file *, + const char __user *, size_t, + loff_t *); static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file); -static ssize_t acpi_thermal_write_polling(struct file*,const char __user *,size_t,loff_t *); +static ssize_t acpi_thermal_write_polling(struct file *, const char __user *, + size_t, loff_t *); static struct acpi_driver acpi_thermal_driver = { - .name = ACPI_THERMAL_DRIVER_NAME, - .class = ACPI_THERMAL_CLASS, - .ids = ACPI_THERMAL_HID, - .ops = { - .add = acpi_thermal_add, - .remove = acpi_thermal_remove, - }, + .name = ACPI_THERMAL_DRIVER_NAME, + .class = ACPI_THERMAL_CLASS, + .ids = ACPI_THERMAL_HID, + .ops = { + .add = acpi_thermal_add, + .remove = acpi_thermal_remove, + }, }; struct acpi_thermal_state { - u8 critical:1; - u8 hot:1; - u8 passive:1; - u8 active:1; - u8 reserved:4; - int active_index; + u8 critical:1; + u8 hot:1; + u8 passive:1; + u8 active:1; + u8 reserved:4; + int active_index; }; struct acpi_thermal_state_flags { - u8 valid:1; - u8 enabled:1; - u8 reserved:6; + u8 valid:1; + u8 enabled:1; + u8 reserved:6; }; struct acpi_thermal_critical { struct acpi_thermal_state_flags flags; - unsigned long temperature; + unsigned long temperature; }; struct acpi_thermal_hot { struct acpi_thermal_state_flags flags; - unsigned long temperature; + unsigned long temperature; }; struct acpi_thermal_passive { struct acpi_thermal_state_flags flags; - unsigned long temperature; - unsigned long tc1; - unsigned long tc2; - unsigned long tsp; - struct acpi_handle_list devices; + unsigned long temperature; + unsigned long tc1; + unsigned long tc2; + unsigned long tsp; + struct acpi_handle_list devices; }; struct acpi_thermal_active { struct acpi_thermal_state_flags flags; - unsigned long temperature; - struct acpi_handle_list devices; + unsigned long temperature; + struct acpi_handle_list devices; }; struct acpi_thermal_trips { struct acpi_thermal_critical critical; - struct acpi_thermal_hot hot; + struct acpi_thermal_hot hot; struct acpi_thermal_passive passive; struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE]; }; struct acpi_thermal_flags { - u8 cooling_mode:1; /* _SCP */ - u8 devices:1; /* _TZD */ - u8 reserved:6; + u8 cooling_mode:1; /* _SCP */ + u8 devices:1; /* _TZD */ + u8 reserved:6; }; struct acpi_thermal { - acpi_handle handle; - acpi_bus_id name; - unsigned long temperature; - unsigned long last_temperature; - unsigned long polling_frequency; - u8 cooling_mode; - volatile u8 zombie; + acpi_handle handle; + acpi_bus_id name; + unsigned long temperature; + unsigned long last_temperature; + unsigned long polling_frequency; + u8 cooling_mode; + volatile u8 zombie; struct acpi_thermal_flags flags; struct acpi_thermal_state state; struct acpi_thermal_trips trips; - struct acpi_handle_list devices; - struct timer_list timer; + struct acpi_handle_list devices; + struct timer_list timer; }; static struct file_operations acpi_thermal_state_fops = { - .open = acpi_thermal_state_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_thermal_state_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; static struct file_operations acpi_thermal_temp_fops = { - .open = acpi_thermal_temp_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_thermal_temp_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; static struct file_operations acpi_thermal_trip_fops = { - .open = acpi_thermal_trip_open_fs, - .read = seq_read, - .write = acpi_thermal_write_trip_points, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_thermal_trip_open_fs, + .read = seq_read, + .write = acpi_thermal_write_trip_points, + .llseek = seq_lseek, + .release = single_release, }; static struct file_operations acpi_thermal_cooling_fops = { - .open = acpi_thermal_cooling_open_fs, - .read = seq_read, - .write = acpi_thermal_write_cooling_mode, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_thermal_cooling_open_fs, + .read = seq_read, + .write = acpi_thermal_write_cooling_mode, + .llseek = seq_lseek, + .release = single_release, }; static struct file_operations acpi_thermal_polling_fops = { - .open = acpi_thermal_polling_open_fs, - .read = seq_read, - .write = acpi_thermal_write_polling, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_thermal_polling_open_fs, + .read = seq_read, + .write = acpi_thermal_write_polling, + .llseek = seq_lseek, + .release = single_release, }; /* -------------------------------------------------------------------------- Thermal Zone Management -------------------------------------------------------------------------- */ -static int -acpi_thermal_get_temperature ( - struct acpi_thermal *tz) +static int acpi_thermal_get_temperature(struct acpi_thermal *tz) { - acpi_status status = AE_OK; + acpi_status status = AE_OK; ACPI_FUNCTION_TRACE("acpi_thermal_get_temperature"); @@ -225,41 +227,39 @@ acpi_thermal_get_temperature ( tz->last_temperature = tz->temperature; - status = acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature); + status = + acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature); if (ACPI_FAILURE(status)) return_VALUE(-ENODEV); - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", tz->temperature)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", + tz->temperature)); return_VALUE(0); } - -static int -acpi_thermal_get_polling_frequency ( - struct acpi_thermal *tz) +static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) { - acpi_status status = AE_OK; + acpi_status status = AE_OK; ACPI_FUNCTION_TRACE("acpi_thermal_get_polling_frequency"); if (!tz) return_VALUE(-EINVAL); - status = acpi_evaluate_integer(tz->handle, "_TZP", NULL, &tz->polling_frequency); + status = + acpi_evaluate_integer(tz->handle, "_TZP", NULL, + &tz->polling_frequency); if (ACPI_FAILURE(status)) return_VALUE(-ENODEV); - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", tz->polling_frequency)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", + tz->polling_frequency)); return_VALUE(0); } - -static int -acpi_thermal_set_polling ( - struct acpi_thermal *tz, - int seconds) +static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds) { ACPI_FUNCTION_TRACE("acpi_thermal_set_polling"); @@ -268,21 +268,19 @@ acpi_thermal_set_polling ( tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */ - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency set to %lu seconds\n", tz->polling_frequency)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Polling frequency set to %lu seconds\n", + tz->polling_frequency)); return_VALUE(0); } - -static int -acpi_thermal_set_cooling_mode ( - struct acpi_thermal *tz, - int mode) +static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) { - acpi_status status = AE_OK; - union acpi_object arg0 = {ACPI_TYPE_INTEGER}; - struct acpi_object_list arg_list = {1, &arg0}; - acpi_handle handle = NULL; + acpi_status status = AE_OK; + union acpi_object arg0 = { ACPI_TYPE_INTEGER }; + struct acpi_object_list arg_list = { 1, &arg0 }; + acpi_handle handle = NULL; ACPI_FUNCTION_TRACE("acpi_thermal_set_cooling_mode"); @@ -303,19 +301,16 @@ acpi_thermal_set_cooling_mode ( tz->cooling_mode = mode; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n", - mode?"passive":"active")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n", + mode ? "passive" : "active")); return_VALUE(0); } - -static int -acpi_thermal_get_trip_points ( - struct acpi_thermal *tz) +static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) { - acpi_status status = AE_OK; - int i = 0; + acpi_status status = AE_OK; + int i = 0; ACPI_FUNCTION_TRACE("acpi_thermal_get_trip_points"); @@ -324,111 +319,128 @@ acpi_thermal_get_trip_points ( /* Critical Shutdown (required) */ - status = acpi_evaluate_integer(tz->handle, "_CRT", NULL, - &tz->trips.critical.temperature); + status = acpi_evaluate_integer(tz->handle, "_CRT", NULL, + &tz->trips.critical.temperature); if (ACPI_FAILURE(status)) { tz->trips.critical.flags.valid = 0; ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n")); return_VALUE(-ENODEV); - } - else { + } else { tz->trips.critical.flags.valid = 1; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found critical threshold [%lu]\n", tz->trips.critical.temperature)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Found critical threshold [%lu]\n", + tz->trips.critical.temperature)); } /* Critical Sleep (optional) */ - status = acpi_evaluate_integer(tz->handle, "_HOT", NULL, &tz->trips.hot.temperature); + status = + acpi_evaluate_integer(tz->handle, "_HOT", NULL, + &tz->trips.hot.temperature); if (ACPI_FAILURE(status)) { tz->trips.hot.flags.valid = 0; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No hot threshold\n")); - } - else { + } else { tz->trips.hot.flags.valid = 1; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%lu]\n", tz->trips.hot.temperature)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%lu]\n", + tz->trips.hot.temperature)); } /* Passive: Processors (optional) */ - status = acpi_evaluate_integer(tz->handle, "_PSV", NULL, &tz->trips.passive.temperature); + status = + acpi_evaluate_integer(tz->handle, "_PSV", NULL, + &tz->trips.passive.temperature); if (ACPI_FAILURE(status)) { tz->trips.passive.flags.valid = 0; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No passive threshold\n")); - } - else { + } else { tz->trips.passive.flags.valid = 1; - status = acpi_evaluate_integer(tz->handle, "_TC1", NULL, &tz->trips.passive.tc1); + status = + acpi_evaluate_integer(tz->handle, "_TC1", NULL, + &tz->trips.passive.tc1); if (ACPI_FAILURE(status)) tz->trips.passive.flags.valid = 0; - status = acpi_evaluate_integer(tz->handle, "_TC2", NULL, &tz->trips.passive.tc2); + status = + acpi_evaluate_integer(tz->handle, "_TC2", NULL, + &tz->trips.passive.tc2); if (ACPI_FAILURE(status)) tz->trips.passive.flags.valid = 0; - status = acpi_evaluate_integer(tz->handle, "_TSP", NULL, &tz->trips.passive.tsp); + status = + acpi_evaluate_integer(tz->handle, "_TSP", NULL, + &tz->trips.passive.tsp); if (ACPI_FAILURE(status)) tz->trips.passive.flags.valid = 0; - status = acpi_evaluate_reference(tz->handle, "_PSL", NULL, &tz->trips.passive.devices); + status = + acpi_evaluate_reference(tz->handle, "_PSL", NULL, + &tz->trips.passive.devices); if (ACPI_FAILURE(status)) tz->trips.passive.flags.valid = 0; if (!tz->trips.passive.flags.valid) - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid passive threshold\n")); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid passive threshold\n")); else - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found passive threshold [%lu]\n", tz->trips.passive.temperature)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Found passive threshold [%lu]\n", + tz->trips.passive.temperature)); } /* Active: Fans, etc. (optional) */ - for (i=0; ihandle, name, NULL, &tz->trips.active[i].temperature); + status = + acpi_evaluate_integer(tz->handle, name, NULL, + &tz->trips.active[i].temperature); if (ACPI_FAILURE(status)) break; name[2] = 'L'; - status = acpi_evaluate_reference(tz->handle, name, NULL, &tz->trips.active[i].devices); + status = + acpi_evaluate_reference(tz->handle, name, NULL, + &tz->trips.active[i].devices); if (ACPI_SUCCESS(status)) { tz->trips.active[i].flags.valid = 1; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found active threshold [%d]:[%lu]\n", i, tz->trips.active[i].temperature)); - } - else - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid active threshold [%d]\n", i)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Found active threshold [%d]:[%lu]\n", + i, tz->trips.active[i].temperature)); + } else + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid active threshold [%d]\n", + i)); } return_VALUE(0); } - -static int -acpi_thermal_get_devices ( - struct acpi_thermal *tz) +static int acpi_thermal_get_devices(struct acpi_thermal *tz) { - acpi_status status = AE_OK; + acpi_status status = AE_OK; ACPI_FUNCTION_TRACE("acpi_thermal_get_devices"); if (!tz) return_VALUE(-EINVAL); - status = acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices); + status = + acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices); if (ACPI_FAILURE(status)) return_VALUE(-ENODEV); return_VALUE(0); } - -static int -acpi_thermal_call_usermode ( - char *path) +static int acpi_thermal_call_usermode(char *path) { - char *argv[2] = {NULL, NULL}; - char *envp[3] = {NULL, NULL, NULL}; + char *argv[2] = { NULL, NULL }; + char *envp[3] = { NULL, NULL, NULL }; ACPI_FUNCTION_TRACE("acpi_thermal_call_usermode"); @@ -440,19 +452,16 @@ acpi_thermal_call_usermode ( /* minimal command environment */ envp[0] = "HOME=/"; envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; - + call_usermodehelper(argv[0], argv, envp, 0); return_VALUE(0); } - -static int -acpi_thermal_critical ( - struct acpi_thermal *tz) +static int acpi_thermal_critical(struct acpi_thermal *tz) { - int result = 0; - struct acpi_device *device = NULL; + int result = 0; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_thermal_critical"); @@ -462,29 +471,28 @@ acpi_thermal_critical ( if (tz->temperature >= tz->trips.critical.temperature) { ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n")); tz->trips.critical.flags.enabled = 1; - } - else if (tz->trips.critical.flags.enabled) + } else if (tz->trips.critical.flags.enabled) tz->trips.critical.flags.enabled = 0; result = acpi_bus_get_device(tz->handle, &device); if (result) return_VALUE(result); - printk(KERN_EMERG "Critical temperature reached (%ld C), shutting down.\n", KELVIN_TO_CELSIUS(tz->temperature)); - acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_CRITICAL, tz->trips.critical.flags.enabled); + printk(KERN_EMERG + "Critical temperature reached (%ld C), shutting down.\n", + KELVIN_TO_CELSIUS(tz->temperature)); + acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_CRITICAL, + tz->trips.critical.flags.enabled); acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF); return_VALUE(0); } - -static int -acpi_thermal_hot ( - struct acpi_thermal *tz) +static int acpi_thermal_hot(struct acpi_thermal *tz) { - int result = 0; - struct acpi_device *device = NULL; + int result = 0; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_thermal_hot"); @@ -494,30 +502,27 @@ acpi_thermal_hot ( if (tz->temperature >= tz->trips.hot.temperature) { ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Hot trip point\n")); tz->trips.hot.flags.enabled = 1; - } - else if (tz->trips.hot.flags.enabled) + } else if (tz->trips.hot.flags.enabled) tz->trips.hot.flags.enabled = 0; result = acpi_bus_get_device(tz->handle, &device); if (result) return_VALUE(result); - acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT, tz->trips.hot.flags.enabled); + acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT, + tz->trips.hot.flags.enabled); /* TBD: Call user-mode "sleep(S4)" function */ return_VALUE(0); } - -static int -acpi_thermal_passive ( - struct acpi_thermal *tz) +static int acpi_thermal_passive(struct acpi_thermal *tz) { - int result = 0; + int result = 0; struct acpi_thermal_passive *passive = NULL; - int trend = 0; - int i = 0; + int trend = 0; + int i = 0; ACPI_FUNCTION_TRACE("acpi_thermal_passive"); @@ -534,25 +539,29 @@ acpi_thermal_passive ( * accordingly. Note that we assume symmetry. */ if (tz->temperature >= passive->temperature) { - trend = (passive->tc1 * (tz->temperature - tz->last_temperature)) + (passive->tc2 * (tz->temperature - passive->temperature)); - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n", - trend, passive->tc1, tz->temperature, - tz->last_temperature, passive->tc2, - tz->temperature, passive->temperature)); + trend = + (passive->tc1 * (tz->temperature - tz->last_temperature)) + + (passive->tc2 * (tz->temperature - passive->temperature)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n", + trend, passive->tc1, tz->temperature, + tz->last_temperature, passive->tc2, + tz->temperature, passive->temperature)); tz->trips.passive.flags.enabled = 1; /* Heating up? */ if (trend > 0) - for (i=0; idevices.count; i++) - acpi_processor_set_thermal_limit( - passive->devices.handles[i], - ACPI_PROCESSOR_LIMIT_INCREMENT); + for (i = 0; i < passive->devices.count; i++) + acpi_processor_set_thermal_limit(passive-> + devices. + handles[i], + ACPI_PROCESSOR_LIMIT_INCREMENT); /* Cooling off? */ else if (trend < 0) - for (i=0; idevices.count; i++) - acpi_processor_set_thermal_limit( - passive->devices.handles[i], - ACPI_PROCESSOR_LIMIT_DECREMENT); + for (i = 0; i < passive->devices.count; i++) + acpi_processor_set_thermal_limit(passive-> + devices. + handles[i], + ACPI_PROCESSOR_LIMIT_DECREMENT); } /* @@ -563,37 +572,35 @@ acpi_thermal_passive ( * assume symmetry. */ else if (tz->trips.passive.flags.enabled) { - for (i=0; idevices.count; i++) - result = acpi_processor_set_thermal_limit( - passive->devices.handles[i], - ACPI_PROCESSOR_LIMIT_DECREMENT); + for (i = 0; i < passive->devices.count; i++) + result = + acpi_processor_set_thermal_limit(passive->devices. + handles[i], + ACPI_PROCESSOR_LIMIT_DECREMENT); if (result == 1) { tz->trips.passive.flags.enabled = 0; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Disabling passive cooling (zone is cool)\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Disabling passive cooling (zone is cool)\n")); } } return_VALUE(0); } - -static int -acpi_thermal_active ( - struct acpi_thermal *tz) +static int acpi_thermal_active(struct acpi_thermal *tz) { - int result = 0; + int result = 0; struct acpi_thermal_active *active = NULL; - int i = 0; - int j = 0; - unsigned long maxtemp = 0; + int i = 0; + int j = 0; + unsigned long maxtemp = 0; ACPI_FUNCTION_TRACE("acpi_thermal_active"); if (!tz) return_VALUE(-EINVAL); - for (i=0; itrips.active[i]); if (!active || !active->flags.valid) @@ -607,16 +614,27 @@ acpi_thermal_active ( */ if (tz->temperature >= active->temperature) { if (active->temperature > maxtemp) - tz->state.active_index = i, maxtemp = active->temperature; + tz->state.active_index = i, maxtemp = + active->temperature; if (!active->flags.enabled) { for (j = 0; j < active->devices.count; j++) { - result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D0); + result = + acpi_bus_set_power(active->devices. + handles[j], + ACPI_STATE_D0); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to turn cooling device [%p] 'on'\n", active->devices.handles[j])); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Unable to turn cooling device [%p] 'on'\n", + active-> + devices. + handles[j])); continue; } active->flags.enabled = 1; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling device [%p] now 'on'\n", active->devices.handles[j])); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Cooling device [%p] now 'on'\n", + active->devices. + handles[j])); } } } @@ -628,13 +646,21 @@ acpi_thermal_active ( */ else if (active->flags.enabled) { for (j = 0; j < active->devices.count; j++) { - result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D3); + result = + acpi_bus_set_power(active->devices. + handles[j], + ACPI_STATE_D3); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to turn cooling device [%p] 'off'\n", active->devices.handles[j])); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Unable to turn cooling device [%p] 'off'\n", + active->devices. + handles[j])); continue; } active->flags.enabled = 0; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling device [%p] now 'off'\n", active->devices.handles[j])); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Cooling device [%p] now 'off'\n", + active->devices.handles[j])); } } } @@ -642,28 +668,22 @@ acpi_thermal_active ( return_VALUE(0); } +static void acpi_thermal_check(void *context); -static void acpi_thermal_check (void *context); - -static void -acpi_thermal_run ( - unsigned long data) +static void acpi_thermal_run(unsigned long data) { struct acpi_thermal *tz = (struct acpi_thermal *)data; if (!tz->zombie) - acpi_os_queue_for_execution(OSD_PRIORITY_GPE, - acpi_thermal_check, (void *) data); + acpi_os_queue_for_execution(OSD_PRIORITY_GPE, + acpi_thermal_check, (void *)data); } - -static void -acpi_thermal_check ( - void *data) +static void acpi_thermal_check(void *data) { - int result = 0; - struct acpi_thermal *tz = (struct acpi_thermal *) data; - unsigned long sleep_time = 0; - int i = 0; + int result = 0; + struct acpi_thermal *tz = (struct acpi_thermal *)data; + unsigned long sleep_time = 0; + int i = 0; struct acpi_thermal_state state; ACPI_FUNCTION_TRACE("acpi_thermal_check"); @@ -678,9 +698,9 @@ acpi_thermal_check ( result = acpi_thermal_get_temperature(tz); if (result) return_VOID; - + memset(&tz->state, 0, sizeof(tz->state)); - + /* * Check Trip Points * ----------------- @@ -690,14 +710,18 @@ acpi_thermal_check ( * individual policy decides when it is exited (e.g. hysteresis). */ if (tz->trips.critical.flags.valid) - state.critical |= (tz->temperature >= tz->trips.critical.temperature); + state.critical |= + (tz->temperature >= tz->trips.critical.temperature); if (tz->trips.hot.flags.valid) state.hot |= (tz->temperature >= tz->trips.hot.temperature); if (tz->trips.passive.flags.valid) - state.passive |= (tz->temperature >= tz->trips.passive.temperature); - for (i=0; itemperature >= tz->trips.passive.temperature); + for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) if (tz->trips.active[i].flags.valid) - state.active |= (tz->temperature >= tz->trips.active[i].temperature); + state.active |= + (tz->temperature >= + tz->trips.active[i].temperature); /* * Invoke Policy @@ -726,7 +750,7 @@ acpi_thermal_check ( tz->state.hot = 1; if (tz->trips.passive.flags.enabled) tz->state.passive = 1; - for (i=0; itrips.active[i].flags.enabled) tz->state.active = 1; @@ -744,8 +768,8 @@ acpi_thermal_check ( else if (tz->polling_frequency > 0) sleep_time = tz->polling_frequency * 100; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s: temperature[%lu] sleep[%lu]\n", - tz->name, tz->temperature, sleep_time)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s: temperature[%lu] sleep[%lu]\n", + tz->name, tz->temperature, sleep_time)); /* * Schedule Next Poll @@ -754,12 +778,11 @@ acpi_thermal_check ( if (!sleep_time) { if (timer_pending(&(tz->timer))) del_timer(&(tz->timer)); - } - else { + } else { if (timer_pending(&(tz->timer))) mod_timer(&(tz->timer), (HZ * sleep_time) / 1000); else { - tz->timer.data = (unsigned long) tz; + tz->timer.data = (unsigned long)tz; tz->timer.function = acpi_thermal_run; tz->timer.expires = jiffies + (HZ * sleep_time) / 1000; add_timer(&(tz->timer)); @@ -769,16 +792,15 @@ acpi_thermal_check ( return_VOID; } - /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ -static struct proc_dir_entry *acpi_thermal_dir; +static struct proc_dir_entry *acpi_thermal_dir; static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) { - struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; + struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; ACPI_FUNCTION_TRACE("acpi_thermal_state_seq_show"); @@ -787,7 +809,8 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) seq_puts(seq, "state: "); - if (!tz->state.critical && !tz->state.hot && !tz->state.passive && !tz->state.active) + if (!tz->state.critical && !tz->state.hot && !tz->state.passive + && !tz->state.active) seq_puts(seq, "ok\n"); else { if (tz->state.critical) @@ -801,7 +824,7 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) seq_puts(seq, "\n"); } -end: + end: return_VALUE(0); } @@ -810,11 +833,10 @@ static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file) return single_open(file, acpi_thermal_state_seq_show, PDE(inode)->data); } - static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset) { - int result = 0; - struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; + int result = 0; + struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; ACPI_FUNCTION_TRACE("acpi_thermal_temp_seq_show"); @@ -825,10 +847,10 @@ static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset) if (result) goto end; - seq_printf(seq, "temperature: %ld C\n", - KELVIN_TO_CELSIUS(tz->temperature)); + seq_printf(seq, "temperature: %ld C\n", + KELVIN_TO_CELSIUS(tz->temperature)); -end: + end: return_VALUE(0); } @@ -837,12 +859,11 @@ static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file) return single_open(file, acpi_thermal_temp_seq_show, PDE(inode)->data); } - static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset) { - struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; - int i = 0; - int j = 0; + struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; + int i = 0; + int j = 0; ACPI_FUNCTION_TRACE("acpi_thermal_trip_seq_show"); @@ -851,21 +872,22 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset) if (tz->trips.critical.flags.valid) seq_printf(seq, "critical (S5): %ld C\n", - KELVIN_TO_CELSIUS(tz->trips.critical.temperature)); + KELVIN_TO_CELSIUS(tz->trips.critical.temperature)); if (tz->trips.hot.flags.valid) seq_printf(seq, "hot (S4): %ld C\n", - KELVIN_TO_CELSIUS(tz->trips.hot.temperature)); + KELVIN_TO_CELSIUS(tz->trips.hot.temperature)); if (tz->trips.passive.flags.valid) { - seq_printf(seq, "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=", - KELVIN_TO_CELSIUS(tz->trips.passive.temperature), - tz->trips.passive.tc1, - tz->trips.passive.tc2, - tz->trips.passive.tsp); - for (j=0; jtrips.passive.devices.count; j++) { - - seq_printf(seq, "0x%p ", tz->trips.passive.devices.handles[j]); + seq_printf(seq, + "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=", + KELVIN_TO_CELSIUS(tz->trips.passive.temperature), + tz->trips.passive.tc1, tz->trips.passive.tc2, + tz->trips.passive.tsp); + for (j = 0; j < tz->trips.passive.devices.count; j++) { + + seq_printf(seq, "0x%p ", + tz->trips.passive.devices.handles[j]); } seq_puts(seq, "\n"); } @@ -874,14 +896,15 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset) if (!(tz->trips.active[i].flags.valid)) break; seq_printf(seq, "active[%d]: %ld C: devices=", - i, KELVIN_TO_CELSIUS(tz->trips.active[i].temperature)); - for (j = 0; j < tz->trips.active[i].devices.count; j++) + i, + KELVIN_TO_CELSIUS(tz->trips.active[i].temperature)); + for (j = 0; j < tz->trips.active[i].devices.count; j++) seq_printf(seq, "0x%p ", - tz->trips.active[i].devices.handles[j]); + tz->trips.active[i].devices.handles[j]); seq_puts(seq, "\n"); } -end: + end: return_VALUE(0); } @@ -891,30 +914,28 @@ static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file) } static ssize_t -acpi_thermal_write_trip_points ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *ppos) +acpi_thermal_write_trip_points(struct file *file, + const char __user * buffer, + size_t count, loff_t * ppos) { - struct seq_file *m = (struct seq_file *)file->private_data; - struct acpi_thermal *tz = (struct acpi_thermal *)m->private; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_thermal *tz = (struct acpi_thermal *)m->private; - char *limit_string; - int num, critical, hot, passive; - int *active; - int i = 0; + char *limit_string; + int num, critical, hot, passive; + int *active; + int i = 0; ACPI_FUNCTION_TRACE("acpi_thermal_write_trip_points"); limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); - if(!limit_string) + if (!limit_string) return_VALUE(-ENOMEM); memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN); - active = kmalloc(ACPI_THERMAL_MAX_ACTIVE *sizeof(int), GFP_KERNEL); - if(!active) + active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL); + if (!active) return_VALUE(-ENOMEM); if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) { @@ -922,20 +943,21 @@ acpi_thermal_write_trip_points ( count = -EINVAL; goto end; } - + if (copy_from_user(limit_string, buffer, count)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n")); count = -EFAULT; goto end; } - + limit_string[count] = '\0'; num = sscanf(limit_string, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d", - &critical, &hot, &passive, - &active[0], &active[1], &active[2], &active[3], &active[4], - &active[5], &active[6], &active[7], &active[8], &active[9]); - if(!(num >=5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) { + &critical, &hot, &passive, + &active[0], &active[1], &active[2], &active[3], &active[4], + &active[5], &active[6], &active[7], &active[8], + &active[9]); + if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n")); count = -EINVAL; goto end; @@ -949,17 +971,16 @@ acpi_thermal_write_trip_points ( break; tz->trips.active[i].temperature = CELSIUS_TO_KELVIN(active[i]); } - -end: + + end: kfree(active); kfree(limit_string); return_VALUE(count); } - static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) { - struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; + struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; ACPI_FUNCTION_TRACE("acpi_thermal_cooling_seq_show"); @@ -970,33 +991,31 @@ static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) seq_puts(seq, "\n"); } - if ( tz->cooling_mode == ACPI_THERMAL_MODE_CRITICAL ) + if (tz->cooling_mode == ACPI_THERMAL_MODE_CRITICAL) seq_printf(seq, "cooling mode: critical\n"); else seq_printf(seq, "cooling mode: %s\n", - tz->cooling_mode?"passive":"active"); + tz->cooling_mode ? "passive" : "active"); -end: + end: return_VALUE(0); } static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_thermal_cooling_seq_show, - PDE(inode)->data); + PDE(inode)->data); } static ssize_t -acpi_thermal_write_cooling_mode ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *ppos) +acpi_thermal_write_cooling_mode(struct file *file, + const char __user * buffer, + size_t count, loff_t * ppos) { - struct seq_file *m = (struct seq_file *)file->private_data; - struct acpi_thermal *tz = (struct acpi_thermal *)m->private; - int result = 0; - char mode_string[12] = {'\0'}; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_thermal *tz = (struct acpi_thermal *)m->private; + int result = 0; + char mode_string[12] = { '\0' }; ACPI_FUNCTION_TRACE("acpi_thermal_write_cooling_mode"); @@ -1008,11 +1027,12 @@ acpi_thermal_write_cooling_mode ( if (copy_from_user(mode_string, buffer, count)) return_VALUE(-EFAULT); - + mode_string[count] = '\0'; - - result = acpi_thermal_set_cooling_mode(tz, - simple_strtoul(mode_string, NULL, 0)); + + result = acpi_thermal_set_cooling_mode(tz, + simple_strtoul(mode_string, NULL, + 0)); if (result) return_VALUE(result); @@ -1021,10 +1041,9 @@ acpi_thermal_write_cooling_mode ( return_VALUE(count); } - static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) { - struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; + struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; ACPI_FUNCTION_TRACE("acpi_thermal_polling_seq_show"); @@ -1037,43 +1056,41 @@ static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) } seq_printf(seq, "polling frequency: %lu seconds\n", - (tz->polling_frequency / 10)); + (tz->polling_frequency / 10)); -end: + end: return_VALUE(0); } static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_thermal_polling_seq_show, - PDE(inode)->data); + PDE(inode)->data); } static ssize_t -acpi_thermal_write_polling ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *ppos) +acpi_thermal_write_polling(struct file *file, + const char __user * buffer, + size_t count, loff_t * ppos) { - struct seq_file *m = (struct seq_file *)file->private_data; - struct acpi_thermal *tz = (struct acpi_thermal *)m->private; - int result = 0; - char polling_string[12] = {'\0'}; - int seconds = 0; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_thermal *tz = (struct acpi_thermal *)m->private; + int result = 0; + char polling_string[12] = { '\0' }; + int seconds = 0; ACPI_FUNCTION_TRACE("acpi_thermal_write_polling"); if (!tz || (count > sizeof(polling_string) - 1)) return_VALUE(-EINVAL); - + if (copy_from_user(polling_string, buffer, count)) return_VALUE(-EFAULT); - + polling_string[count] = '\0'; seconds = simple_strtoul(polling_string, NULL, 0); - + result = acpi_thermal_set_polling(tz, seconds); if (result) return_VALUE(result); @@ -1083,18 +1100,15 @@ acpi_thermal_write_polling ( return_VALUE(count); } - -static int -acpi_thermal_add_fs ( - struct acpi_device *device) +static int acpi_thermal_add_fs(struct acpi_device *device) { - struct proc_dir_entry *entry = NULL; + struct proc_dir_entry *entry = NULL; ACPI_FUNCTION_TRACE("acpi_thermal_add_fs"); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), - acpi_thermal_dir); + acpi_thermal_dir); if (!acpi_device_dir(device)) return_VALUE(-ENODEV); acpi_device_dir(device)->owner = THIS_MODULE; @@ -1102,11 +1116,11 @@ acpi_thermal_add_fs ( /* 'state' [R] */ entry = create_proc_entry(ACPI_THERMAL_FILE_STATE, - S_IRUGO, acpi_device_dir(device)); + S_IRUGO, acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_THERMAL_FILE_STATE)); + "Unable to create '%s' fs entry\n", + ACPI_THERMAL_FILE_STATE)); else { entry->proc_fops = &acpi_thermal_state_fops; entry->data = acpi_driver_data(device); @@ -1115,11 +1129,11 @@ acpi_thermal_add_fs ( /* 'temperature' [R] */ entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE, - S_IRUGO, acpi_device_dir(device)); + S_IRUGO, acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_THERMAL_FILE_TEMPERATURE)); + "Unable to create '%s' fs entry\n", + ACPI_THERMAL_FILE_TEMPERATURE)); else { entry->proc_fops = &acpi_thermal_temp_fops; entry->data = acpi_driver_data(device); @@ -1128,11 +1142,12 @@ acpi_thermal_add_fs ( /* 'trip_points' [R/W] */ entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS, - S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_THERMAL_FILE_TRIP_POINTS)); + "Unable to create '%s' fs entry\n", + ACPI_THERMAL_FILE_TRIP_POINTS)); else { entry->proc_fops = &acpi_thermal_trip_fops; entry->data = acpi_driver_data(device); @@ -1141,11 +1156,12 @@ acpi_thermal_add_fs ( /* 'cooling_mode' [R/W] */ entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE, - S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_THERMAL_FILE_COOLING_MODE)); + "Unable to create '%s' fs entry\n", + ACPI_THERMAL_FILE_COOLING_MODE)); else { entry->proc_fops = &acpi_thermal_cooling_fops; entry->data = acpi_driver_data(device); @@ -1154,11 +1170,12 @@ acpi_thermal_add_fs ( /* 'polling_frequency' [R/W] */ entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ, - S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_THERMAL_FILE_POLLING_FREQ)); + "Unable to create '%s' fs entry\n", + ACPI_THERMAL_FILE_POLLING_FREQ)); else { entry->proc_fops = &acpi_thermal_polling_fops; entry->data = acpi_driver_data(device); @@ -1168,10 +1185,7 @@ acpi_thermal_add_fs ( return_VALUE(0); } - -static int -acpi_thermal_remove_fs ( - struct acpi_device *device) +static int acpi_thermal_remove_fs(struct acpi_device *device) { ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs"); @@ -1193,19 +1207,14 @@ acpi_thermal_remove_fs ( return_VALUE(0); } - /* -------------------------------------------------------------------------- Driver Interface -------------------------------------------------------------------------- */ -static void -acpi_thermal_notify ( - acpi_handle handle, - u32 event, - void *data) +static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_thermal *tz = (struct acpi_thermal *) data; - struct acpi_device *device = NULL; + struct acpi_thermal *tz = (struct acpi_thermal *)data; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_thermal_notify"); @@ -1231,19 +1240,16 @@ acpi_thermal_notify ( break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Unsupported event [0x%x]\n", event)); + "Unsupported event [0x%x]\n", event)); break; } return_VOID; } - -static int -acpi_thermal_get_info ( - struct acpi_thermal *tz) +static int acpi_thermal_get_info(struct acpi_thermal *tz) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_thermal_get_info"); @@ -1262,20 +1268,24 @@ acpi_thermal_get_info ( /* Set the cooling mode [_SCP] to active cooling (default) */ result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); - if (!result) + if (!result) tz->flags.cooling_mode = 1; - else { + else { /* Oh,we have not _SCP method. - Generally show cooling_mode by _ACx, _PSV,spec 12.2*/ + Generally show cooling_mode by _ACx, _PSV,spec 12.2 */ tz->flags.cooling_mode = 0; - if ( tz->trips.active[0].flags.valid && tz->trips.passive.flags.valid ) { - if ( tz->trips.passive.temperature > tz->trips.active[0].temperature ) + if (tz->trips.active[0].flags.valid + && tz->trips.passive.flags.valid) { + if (tz->trips.passive.temperature > + tz->trips.active[0].temperature) tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE; - else + else tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE; - } else if ( !tz->trips.active[0].flags.valid && tz->trips.passive.flags.valid ) { + } else if (!tz->trips.active[0].flags.valid + && tz->trips.passive.flags.valid) { tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE; - } else if ( tz->trips.active[0].flags.valid && !tz->trips.passive.flags.valid ) { + } else if (tz->trips.active[0].flags.valid + && !tz->trips.passive.flags.valid) { tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE; } else { /* _ACx and _PSV are optional, but _CRT is required */ @@ -1297,14 +1307,11 @@ acpi_thermal_get_info ( return_VALUE(0); } - -static int -acpi_thermal_add ( - struct acpi_device *device) +static int acpi_thermal_add(struct acpi_device *device) { - int result = 0; - acpi_status status = AE_OK; - struct acpi_thermal *tz = NULL; + int result = 0; + acpi_status status = AE_OK; + struct acpi_thermal *tz = NULL; ACPI_FUNCTION_TRACE("acpi_thermal_add"); @@ -1335,19 +1342,20 @@ acpi_thermal_add ( acpi_thermal_check(tz); status = acpi_install_notify_handler(tz->handle, - ACPI_DEVICE_NOTIFY, acpi_thermal_notify, tz); + ACPI_DEVICE_NOTIFY, + acpi_thermal_notify, tz); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); + "Error installing notify handler\n")); result = -ENODEV; goto end; } printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n", - acpi_device_name(device), acpi_device_bid(device), - KELVIN_TO_CELSIUS(tz->temperature)); + acpi_device_name(device), acpi_device_bid(device), + KELVIN_TO_CELSIUS(tz->temperature)); -end: + end: if (result) { acpi_thermal_remove_fs(device); kfree(tz); @@ -1356,21 +1364,17 @@ end: return_VALUE(result); } - -static int -acpi_thermal_remove ( - struct acpi_device *device, - int type) +static int acpi_thermal_remove(struct acpi_device *device, int type) { - acpi_status status = AE_OK; - struct acpi_thermal *tz = NULL; + acpi_status status = AE_OK; + struct acpi_thermal *tz = NULL; ACPI_FUNCTION_TRACE("acpi_thermal_remove"); if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); - tz = (struct acpi_thermal *) acpi_driver_data(device); + tz = (struct acpi_thermal *)acpi_driver_data(device); /* avoid timer adding new defer task */ tz->zombie = 1; @@ -1382,19 +1386,19 @@ acpi_thermal_remove ( del_timer_sync(&(tz->timer)); status = acpi_remove_notify_handler(tz->handle, - ACPI_DEVICE_NOTIFY, acpi_thermal_notify); + ACPI_DEVICE_NOTIFY, + acpi_thermal_notify); if (ACPI_FAILURE(status)) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); + "Error removing notify handler\n")); /* Terminate policy */ - if (tz->trips.passive.flags.valid - && tz->trips.passive.flags.enabled) { + if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) { tz->trips.passive.flags.enabled = 0; acpi_thermal_passive(tz); } if (tz->trips.active[0].flags.valid - && tz->trips.active[0].flags.enabled) { + && tz->trips.active[0].flags.enabled) { tz->trips.active[0].flags.enabled = 0; acpi_thermal_active(tz); } @@ -1405,11 +1409,9 @@ acpi_thermal_remove ( return_VALUE(0); } - -static int __init -acpi_thermal_init (void) +static int __init acpi_thermal_init(void) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_thermal_init"); @@ -1427,9 +1429,7 @@ acpi_thermal_init (void) return_VALUE(0); } - -static void __exit -acpi_thermal_exit (void) +static void __exit acpi_thermal_exit(void) { ACPI_FUNCTION_TRACE("acpi_thermal_exit"); @@ -1440,6 +1440,5 @@ acpi_thermal_exit (void) return_VOID; } - module_init(acpi_thermal_init); module_exit(acpi_thermal_exit); diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c index 73b1d8a..7fe0b7a 100644 --- a/drivers/acpi/toshiba_acpi.c +++ b/drivers/acpi/toshiba_acpi.c @@ -100,8 +100,7 @@ MODULE_LICENSE("GPL"); /* utility */ -static __inline__ void -_set_bit(u32* word, u32 mask, int value) +static __inline__ void _set_bit(u32 * word, u32 mask, int value) { *word = (*word & ~mask) | (mask * value); } @@ -109,35 +108,32 @@ _set_bit(u32* word, u32 mask, int value) /* acpi interface wrappers */ -static int -is_valid_acpi_path(const char* methodName) +static int is_valid_acpi_path(const char *methodName) { acpi_handle handle; acpi_status status; - status = acpi_get_handle(NULL, (char*)methodName, &handle); + status = acpi_get_handle(NULL, (char *)methodName, &handle); return !ACPI_FAILURE(status); } -static int -write_acpi_int(const char* methodName, int val) +static int write_acpi_int(const char *methodName, int val) { struct acpi_object_list params; union acpi_object in_objs[1]; acpi_status status; - params.count = sizeof(in_objs)/sizeof(in_objs[0]); + params.count = sizeof(in_objs) / sizeof(in_objs[0]); params.pointer = in_objs; in_objs[0].type = ACPI_TYPE_INTEGER; in_objs[0].integer.value = val; - status = acpi_evaluate_object(NULL, (char*)methodName, ¶ms, NULL); + status = acpi_evaluate_object(NULL, (char *)methodName, ¶ms, NULL); return (status == AE_OK); } #if 0 -static int -read_acpi_int(const char* methodName, int* pVal) +static int read_acpi_int(const char *methodName, int *pVal) { struct acpi_buffer results; union acpi_object out_objs[1]; @@ -146,25 +142,24 @@ read_acpi_int(const char* methodName, int* pVal) results.length = sizeof(out_objs); results.pointer = out_objs; - status = acpi_evaluate_object(0, (char*)methodName, 0, &results); + status = acpi_evaluate_object(0, (char *)methodName, 0, &results); *pVal = out_objs[0].integer.value; return (status == AE_OK) && (out_objs[0].type == ACPI_TYPE_INTEGER); } #endif -static const char* method_hci /*= 0*/; +static const char *method_hci /*= 0*/ ; /* Perform a raw HCI call. Here we don't care about input or output buffer * format. */ -static acpi_status -hci_raw(const u32 in[HCI_WORDS], u32 out[HCI_WORDS]) +static acpi_status hci_raw(const u32 in[HCI_WORDS], u32 out[HCI_WORDS]) { struct acpi_object_list params; union acpi_object in_objs[HCI_WORDS]; struct acpi_buffer results; - union acpi_object out_objs[HCI_WORDS+1]; + union acpi_object out_objs[HCI_WORDS + 1]; acpi_status status; int i; @@ -178,8 +173,8 @@ hci_raw(const u32 in[HCI_WORDS], u32 out[HCI_WORDS]) results.length = sizeof(out_objs); results.pointer = out_objs; - status = acpi_evaluate_object(NULL, (char*)method_hci, ¶ms, - &results); + status = acpi_evaluate_object(NULL, (char *)method_hci, ¶ms, + &results); if ((status == AE_OK) && (out_objs->package.count <= HCI_WORDS)) { for (i = 0; i < out_objs->package.count; ++i) { out[i] = out_objs->package.elements[i].integer.value; @@ -195,8 +190,7 @@ hci_raw(const u32 in[HCI_WORDS], u32 out[HCI_WORDS]) * may be useful (such as "not supported"). */ -static acpi_status -hci_write1(u32 reg, u32 in1, u32* result) +static acpi_status hci_write1(u32 reg, u32 in1, u32 * result) { u32 in[HCI_WORDS] = { HCI_SET, reg, in1, 0, 0, 0 }; u32 out[HCI_WORDS]; @@ -205,8 +199,7 @@ hci_write1(u32 reg, u32 in1, u32* result) return status; } -static acpi_status -hci_read1(u32 reg, u32* out1, u32* result) +static acpi_status hci_read1(u32 reg, u32 * out1, u32 * result) { u32 in[HCI_WORDS] = { HCI_GET, reg, 0, 0, 0, 0 }; u32 out[HCI_WORDS]; @@ -216,26 +209,25 @@ hci_read1(u32 reg, u32* out1, u32* result) return status; } -static struct proc_dir_entry* toshiba_proc_dir /*= 0*/; -static int force_fan; -static int last_key_event; -static int key_event_valid; +static struct proc_dir_entry *toshiba_proc_dir /*= 0*/ ; +static int force_fan; +static int last_key_event; +static int key_event_valid; -typedef struct _ProcItem -{ - const char* name; - char* (*read_func)(char*); - unsigned long (*write_func)(const char*, unsigned long); +typedef struct _ProcItem { + const char *name; + char *(*read_func) (char *); + unsigned long (*write_func) (const char *, unsigned long); } ProcItem; /* proc file handlers */ static int -dispatch_read(char* page, char** start, off_t off, int count, int* eof, - ProcItem* item) +dispatch_read(char *page, char **start, off_t off, int count, int *eof, + ProcItem * item) { - char* p = page; + char *p = page; int len; if (off == 0) @@ -243,33 +235,35 @@ dispatch_read(char* page, char** start, off_t off, int count, int* eof, /* ISSUE: I don't understand this code */ len = (p - page); - if (len <= off+count) *eof = 1; + if (len <= off + count) + *eof = 1; *start = page + off; len -= off; - if (len>count) len = count; - if (len<0) len = 0; + if (len > count) + len = count; + if (len < 0) + len = 0; return len; } static int -dispatch_write(struct file* file, const char __user * buffer, - unsigned long count, ProcItem* item) +dispatch_write(struct file *file, const char __user * buffer, + unsigned long count, ProcItem * item) { int result; - char* tmp_buffer; + char *tmp_buffer; /* Arg buffer points to userspace memory, which can't be accessed * directly. Since we're making a copy, zero-terminate the * destination so that sscanf can be used on it safely. */ tmp_buffer = kmalloc(count + 1, GFP_KERNEL); - if(!tmp_buffer) + if (!tmp_buffer) return -ENOMEM; if (copy_from_user(tmp_buffer, buffer, count)) { result = -EFAULT; - } - else { + } else { tmp_buffer[count] = 0; result = item->write_func(tmp_buffer, count); } @@ -277,8 +271,7 @@ dispatch_write(struct file* file, const char __user * buffer, return result; } -static char* -read_lcd(char* p) +static char *read_lcd(char *p) { u32 hci_result; u32 value; @@ -288,7 +281,7 @@ read_lcd(char* p) value = value >> HCI_LCD_BRIGHTNESS_SHIFT; p += sprintf(p, "brightness: %d\n", value); p += sprintf(p, "brightness_levels: %d\n", - HCI_LCD_BRIGHTNESS_LEVELS); + HCI_LCD_BRIGHTNESS_LEVELS); } else { printk(MY_ERR "Error reading LCD brightness\n"); } @@ -296,14 +289,13 @@ read_lcd(char* p) return p; } -static unsigned long -write_lcd(const char* buffer, unsigned long count) +static unsigned long write_lcd(const char *buffer, unsigned long count) { int value; u32 hci_result; if (sscanf(buffer, " brightness : %i", &value) == 1 && - value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS) { + value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS) { value = value << HCI_LCD_BRIGHTNESS_SHIFT; hci_write1(HCI_LCD_BRIGHTNESS, value, &hci_result); if (hci_result != HCI_SUCCESS) @@ -315,8 +307,7 @@ write_lcd(const char* buffer, unsigned long count) return count; } -static char* -read_video(char* p) +static char *read_video(char *p) { u32 hci_result; u32 value; @@ -325,7 +316,7 @@ read_video(char* p) if (hci_result == HCI_SUCCESS) { int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0; int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0; - int is_tv = (value & HCI_VIDEO_OUT_TV ) ? 1 : 0; + int is_tv = (value & HCI_VIDEO_OUT_TV) ? 1 : 0; p += sprintf(p, "lcd_out: %d\n", is_lcd); p += sprintf(p, "crt_out: %d\n", is_crt); p += sprintf(p, "tv_out: %d\n", is_tv); @@ -336,8 +327,7 @@ read_video(char* p) return p; } -static unsigned long -write_video(const char* buffer, unsigned long count) +static unsigned long write_video(const char *buffer, unsigned long count) { int value; int remain = count; @@ -363,7 +353,7 @@ write_video(const char* buffer, unsigned long count) ++buffer; --remain; } - while (remain && *(buffer-1) != ';'); + while (remain && *(buffer - 1) != ';'); } hci_read1(HCI_VIDEO_OUT, &video_out, &hci_result); @@ -386,8 +376,7 @@ write_video(const char* buffer, unsigned long count) return count; } -static char* -read_fan(char* p) +static char *read_fan(char *p) { u32 hci_result; u32 value; @@ -403,14 +392,13 @@ read_fan(char* p) return p; } -static unsigned long -write_fan(const char* buffer, unsigned long count) +static unsigned long write_fan(const char *buffer, unsigned long count) { int value; u32 hci_result; if (sscanf(buffer, " force_on : %i", &value) == 1 && - value >= 0 && value <= 1) { + value >= 0 && value <= 1) { hci_write1(HCI_FAN, value, &hci_result); if (hci_result != HCI_SUCCESS) return -EFAULT; @@ -423,8 +411,7 @@ write_fan(const char* buffer, unsigned long count) return count; } -static char* -read_keys(char* p) +static char *read_keys(char *p) { u32 hci_result; u32 value; @@ -451,17 +438,15 @@ read_keys(char* p) p += sprintf(p, "hotkey_ready: %d\n", key_event_valid); p += sprintf(p, "hotkey: 0x%04x\n", last_key_event); -end: + end: return p; } -static unsigned long -write_keys(const char* buffer, unsigned long count) +static unsigned long write_keys(const char *buffer, unsigned long count) { int value; - if (sscanf(buffer, " hotkey_ready : %i", &value) == 1 && - value == 0) { + if (sscanf(buffer, " hotkey_ready : %i", &value) == 1 && value == 0) { key_event_valid = 0; } else { return -EINVAL; @@ -470,12 +455,11 @@ write_keys(const char* buffer, unsigned long count) return count; } -static char* -read_version(char* p) +static char *read_version(char *p) { p += sprintf(p, "driver: %s\n", TOSHIBA_ACPI_VERSION); p += sprintf(p, "proc_interface: %d\n", - PROC_INTERFACE_VERSION); + PROC_INTERFACE_VERSION); return p; } @@ -484,48 +468,45 @@ read_version(char* p) #define PROC_TOSHIBA "toshiba" -static ProcItem proc_items[] = -{ - { "lcd" , read_lcd , write_lcd }, - { "video" , read_video , write_video }, - { "fan" , read_fan , write_fan }, - { "keys" , read_keys , write_keys }, - { "version" , read_version , NULL }, - { NULL } +static ProcItem proc_items[] = { + {"lcd", read_lcd, write_lcd}, + {"video", read_video, write_video}, + {"fan", read_fan, write_fan}, + {"keys", read_keys, write_keys}, + {"version", read_version, NULL}, + {NULL} }; -static acpi_status __init -add_device(void) +static acpi_status __init add_device(void) { - struct proc_dir_entry* proc; - ProcItem* item; + struct proc_dir_entry *proc; + ProcItem *item; - for (item = proc_items; item->name; ++item) - { + for (item = proc_items; item->name; ++item) { proc = create_proc_read_entry(item->name, - S_IFREG | S_IRUGO | S_IWUSR, - toshiba_proc_dir, (read_proc_t*)dispatch_read, item); + S_IFREG | S_IRUGO | S_IWUSR, + toshiba_proc_dir, + (read_proc_t *) dispatch_read, + item); if (proc) proc->owner = THIS_MODULE; if (proc && item->write_func) - proc->write_proc = (write_proc_t*)dispatch_write; + proc->write_proc = (write_proc_t *) dispatch_write; } return AE_OK; } -static acpi_status __exit -remove_device(void) +static acpi_status __exit remove_device(void) { - ProcItem* item; + ProcItem *item; for (item = proc_items; item->name; ++item) remove_proc_entry(item->name, toshiba_proc_dir); return AE_OK; } -static int __init -toshiba_acpi_init(void) +static int __init toshiba_acpi_init(void) { acpi_status status = AE_OK; u32 hci_result; @@ -533,9 +514,9 @@ toshiba_acpi_init(void) if (acpi_disabled) return -ENODEV; - if (!acpi_specific_hotkey_enabled){ + if (!acpi_specific_hotkey_enabled) { printk(MY_INFO "Using generic hotkey driver\n"); - return -ENODEV; + return -ENODEV; } /* simple device detection: look for HCI method */ if (is_valid_acpi_path(METHOD_HCI_1)) @@ -546,7 +527,7 @@ toshiba_acpi_init(void) return -ENODEV; printk(MY_INFO "Toshiba Laptop ACPI Extras version %s\n", - TOSHIBA_ACPI_VERSION); + TOSHIBA_ACPI_VERSION); printk(MY_INFO " HCI method: %s\n", method_hci); force_fan = 0; @@ -568,8 +549,7 @@ toshiba_acpi_init(void) return (ACPI_SUCCESS(status)) ? 0 : -ENODEV; } -static void __exit -toshiba_acpi_exit(void) +static void __exit toshiba_acpi_exit(void) { remove_device(); diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index 78270f5..068450b 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c @@ -41,45 +41,31 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utalloc") +ACPI_MODULE_NAME("utalloc") /* Local prototypes */ - #ifdef ACPI_DBG_TRACK_ALLOCATIONS -static struct acpi_debug_mem_block * -acpi_ut_find_allocation ( - void *allocation); +static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation); static acpi_status -acpi_ut_track_allocation ( - struct acpi_debug_mem_block *address, - acpi_size size, - u8 alloc_type, - u32 component, - char *module, - u32 line); +acpi_ut_track_allocation(struct acpi_debug_mem_block *address, + acpi_size size, + u8 alloc_type, u32 component, char *module, u32 line); static acpi_status -acpi_ut_remove_allocation ( - struct acpi_debug_mem_block *address, - u32 component, - char *module, - u32 line); -#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ +acpi_ut_remove_allocation(struct acpi_debug_mem_block *address, + u32 component, char *module, u32 line); +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ #ifdef ACPI_DBG_TRACK_ALLOCATIONS static acpi_status -acpi_ut_create_list ( - char *list_name, - u16 object_size, - struct acpi_memory_list **return_cache); +acpi_ut_create_list(char *list_name, + u16 object_size, struct acpi_memory_list **return_cache); #endif - /******************************************************************************* * * FUNCTION: acpi_ut_create_caches @@ -92,60 +78,68 @@ acpi_ut_create_list ( * ******************************************************************************/ -acpi_status -acpi_ut_create_caches ( - void) +acpi_status acpi_ut_create_caches(void) { - acpi_status status; - + acpi_status status; #ifdef ACPI_DBG_TRACK_ALLOCATIONS /* Memory allocation lists */ - status = acpi_ut_create_list ("Acpi-Global", 0, - &acpi_gbl_global_list); - if (ACPI_FAILURE (status)) { + status = acpi_ut_create_list("Acpi-Global", 0, &acpi_gbl_global_list); + if (ACPI_FAILURE(status)) { return (status); } - status = acpi_ut_create_list ("Acpi-Namespace", sizeof (struct acpi_namespace_node), - &acpi_gbl_ns_node_list); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_create_list("Acpi-Namespace", + sizeof(struct acpi_namespace_node), + &acpi_gbl_ns_node_list); + if (ACPI_FAILURE(status)) { return (status); } #endif /* Object Caches, for frequently used objects */ - status = acpi_os_create_cache ("acpi_state", sizeof (union acpi_generic_state), - ACPI_MAX_STATE_CACHE_DEPTH, &acpi_gbl_state_cache); - if (ACPI_FAILURE (status)) { + status = + acpi_os_create_cache("acpi_state", sizeof(union acpi_generic_state), + ACPI_MAX_STATE_CACHE_DEPTH, + &acpi_gbl_state_cache); + if (ACPI_FAILURE(status)) { return (status); } - status = acpi_os_create_cache ("acpi_parse", sizeof (struct acpi_parse_obj_common), - ACPI_MAX_PARSE_CACHE_DEPTH, &acpi_gbl_ps_node_cache); - if (ACPI_FAILURE (status)) { + status = + acpi_os_create_cache("acpi_parse", + sizeof(struct acpi_parse_obj_common), + ACPI_MAX_PARSE_CACHE_DEPTH, + &acpi_gbl_ps_node_cache); + if (ACPI_FAILURE(status)) { return (status); } - status = acpi_os_create_cache ("acpi_parse_ext", sizeof (struct acpi_parse_obj_named), - ACPI_MAX_EXTPARSE_CACHE_DEPTH, &acpi_gbl_ps_node_ext_cache); - if (ACPI_FAILURE (status)) { + status = + acpi_os_create_cache("acpi_parse_ext", + sizeof(struct acpi_parse_obj_named), + ACPI_MAX_EXTPARSE_CACHE_DEPTH, + &acpi_gbl_ps_node_ext_cache); + if (ACPI_FAILURE(status)) { return (status); } - status = acpi_os_create_cache ("acpi_operand", sizeof (union acpi_operand_object), - ACPI_MAX_OBJECT_CACHE_DEPTH, &acpi_gbl_operand_cache); - if (ACPI_FAILURE (status)) { + status = + acpi_os_create_cache("acpi_operand", + sizeof(union acpi_operand_object), + ACPI_MAX_OBJECT_CACHE_DEPTH, + &acpi_gbl_operand_cache); + if (ACPI_FAILURE(status)) { return (status); } return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ut_delete_caches @@ -158,21 +152,19 @@ acpi_ut_create_caches ( * ******************************************************************************/ -acpi_status -acpi_ut_delete_caches ( - void) +acpi_status acpi_ut_delete_caches(void) { - (void) acpi_os_delete_cache (acpi_gbl_state_cache); + (void)acpi_os_delete_cache(acpi_gbl_state_cache); acpi_gbl_state_cache = NULL; - (void) acpi_os_delete_cache (acpi_gbl_operand_cache); + (void)acpi_os_delete_cache(acpi_gbl_operand_cache); acpi_gbl_operand_cache = NULL; - (void) acpi_os_delete_cache (acpi_gbl_ps_node_cache); + (void)acpi_os_delete_cache(acpi_gbl_ps_node_cache); acpi_gbl_ps_node_cache = NULL; - (void) acpi_os_delete_cache (acpi_gbl_ps_node_ext_cache); + (void)acpi_os_delete_cache(acpi_gbl_ps_node_ext_cache); acpi_gbl_ps_node_ext_cache = NULL; return (AE_OK); @@ -190,9 +182,7 @@ acpi_ut_delete_caches ( * ******************************************************************************/ -acpi_status -acpi_ut_validate_buffer ( - struct acpi_buffer *buffer) +acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer) { /* Obviously, the structure pointer must be valid */ @@ -203,9 +193,9 @@ acpi_ut_validate_buffer ( /* Special semantics for the length */ - if ((buffer->length == ACPI_NO_BUFFER) || - (buffer->length == ACPI_ALLOCATE_BUFFER) || - (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) { + if ((buffer->length == ACPI_NO_BUFFER) || + (buffer->length == ACPI_ALLOCATE_BUFFER) || + (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) { return (AE_OK); } @@ -218,7 +208,6 @@ acpi_ut_validate_buffer ( return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ut_initialize_buffer @@ -234,12 +223,10 @@ acpi_ut_validate_buffer ( ******************************************************************************/ acpi_status -acpi_ut_initialize_buffer ( - struct acpi_buffer *buffer, - acpi_size required_length) +acpi_ut_initialize_buffer(struct acpi_buffer * buffer, + acpi_size required_length) { - acpi_status status = AE_OK; - + acpi_status status = AE_OK; switch (buffer->length) { case ACPI_NO_BUFFER: @@ -249,33 +236,30 @@ acpi_ut_initialize_buffer ( status = AE_BUFFER_OVERFLOW; break; - case ACPI_ALLOCATE_BUFFER: /* Allocate a new buffer */ - buffer->pointer = acpi_os_allocate (required_length); + buffer->pointer = acpi_os_allocate(required_length); if (!buffer->pointer) { return (AE_NO_MEMORY); } /* Clear the buffer */ - ACPI_MEMSET (buffer->pointer, 0, required_length); + ACPI_MEMSET(buffer->pointer, 0, required_length); break; - case ACPI_ALLOCATE_LOCAL_BUFFER: /* Allocate a new buffer with local interface to allow tracking */ - buffer->pointer = ACPI_MEM_CALLOCATE (required_length); + buffer->pointer = ACPI_MEM_CALLOCATE(required_length); if (!buffer->pointer) { return (AE_NO_MEMORY); } break; - default: /* Existing buffer: Validate the size of the buffer */ @@ -287,7 +271,7 @@ acpi_ut_initialize_buffer ( /* Clear the buffer */ - ACPI_MEMSET (buffer->pointer, 0, required_length); + ACPI_MEMSET(buffer->pointer, 0, required_length); break; } @@ -295,7 +279,6 @@ acpi_ut_initialize_buffer ( return (status); } - /******************************************************************************* * * FUNCTION: acpi_ut_allocate @@ -311,41 +294,34 @@ acpi_ut_initialize_buffer ( * ******************************************************************************/ -void * -acpi_ut_allocate ( - acpi_size size, - u32 component, - char *module, - u32 line) +void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line) { - void *allocation; - - - ACPI_FUNCTION_TRACE_U32 ("ut_allocate", size); + void *allocation; + ACPI_FUNCTION_TRACE_U32("ut_allocate", size); /* Check for an inadvertent size of zero bytes */ if (!size) { - _ACPI_REPORT_ERROR (module, line, component, - ("ut_allocate: Attempt to allocate zero bytes\n")); + _ACPI_REPORT_ERROR(module, line, component, + ("ut_allocate: Attempt to allocate zero bytes\n")); size = 1; } - allocation = acpi_os_allocate (size); + allocation = acpi_os_allocate(size); if (!allocation) { /* Report allocation error */ - _ACPI_REPORT_ERROR (module, line, component, - ("ut_allocate: Could not allocate size %X\n", (u32) size)); + _ACPI_REPORT_ERROR(module, line, component, + ("ut_allocate: Could not allocate size %X\n", + (u32) size)); - return_PTR (NULL); + return_PTR(NULL); } - return_PTR (allocation); + return_PTR(allocation); } - /******************************************************************************* * * FUNCTION: acpi_ut_callocate @@ -361,43 +337,36 @@ acpi_ut_allocate ( * ******************************************************************************/ -void * -acpi_ut_callocate ( - acpi_size size, - u32 component, - char *module, - u32 line) +void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line) { - void *allocation; - - - ACPI_FUNCTION_TRACE_U32 ("ut_callocate", size); + void *allocation; + ACPI_FUNCTION_TRACE_U32("ut_callocate", size); /* Check for an inadvertent size of zero bytes */ if (!size) { - _ACPI_REPORT_ERROR (module, line, component, - ("ut_callocate: Attempt to allocate zero bytes\n")); - return_PTR (NULL); + _ACPI_REPORT_ERROR(module, line, component, + ("ut_callocate: Attempt to allocate zero bytes\n")); + return_PTR(NULL); } - allocation = acpi_os_allocate (size); + allocation = acpi_os_allocate(size); if (!allocation) { /* Report allocation error */ - _ACPI_REPORT_ERROR (module, line, component, - ("ut_callocate: Could not allocate size %X\n", (u32) size)); - return_PTR (NULL); + _ACPI_REPORT_ERROR(module, line, component, + ("ut_callocate: Could not allocate size %X\n", + (u32) size)); + return_PTR(NULL); } /* Clear the memory block */ - ACPI_MEMSET (allocation, 0, size); - return_PTR (allocation); + ACPI_MEMSET(allocation, 0, size); + return_PTR(allocation); } - #ifdef ACPI_DBG_TRACK_ALLOCATIONS /* * These procedures are used for tracking memory leaks in the subsystem, and @@ -425,29 +394,25 @@ acpi_ut_callocate ( ******************************************************************************/ static acpi_status -acpi_ut_create_list ( - char *list_name, - u16 object_size, - struct acpi_memory_list **return_cache) +acpi_ut_create_list(char *list_name, + u16 object_size, struct acpi_memory_list **return_cache) { - struct acpi_memory_list *cache; + struct acpi_memory_list *cache; - - cache = acpi_os_allocate (sizeof (struct acpi_memory_list)); + cache = acpi_os_allocate(sizeof(struct acpi_memory_list)); if (!cache) { return (AE_NO_MEMORY); } - ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); + ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list)); - cache->list_name = list_name; + cache->list_name = list_name; cache->object_size = object_size; *return_cache = cache; return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ut_allocate_and_track @@ -463,37 +428,33 @@ acpi_ut_create_list ( * ******************************************************************************/ -void * -acpi_ut_allocate_and_track ( - acpi_size size, - u32 component, - char *module, - u32 line) +void *acpi_ut_allocate_and_track(acpi_size size, + u32 component, char *module, u32 line) { - struct acpi_debug_mem_block *allocation; - acpi_status status; - + struct acpi_debug_mem_block *allocation; + acpi_status status; - allocation = acpi_ut_allocate (size + sizeof (struct acpi_debug_mem_header), - component, module, line); + allocation = + acpi_ut_allocate(size + sizeof(struct acpi_debug_mem_header), + component, module, line); if (!allocation) { return (NULL); } - status = acpi_ut_track_allocation (allocation, size, - ACPI_MEM_MALLOC, component, module, line); - if (ACPI_FAILURE (status)) { - acpi_os_free (allocation); + status = acpi_ut_track_allocation(allocation, size, + ACPI_MEM_MALLOC, component, module, + line); + if (ACPI_FAILURE(status)) { + acpi_os_free(allocation); return (NULL); } acpi_gbl_global_list->total_allocated++; acpi_gbl_global_list->current_total_size += (u32) size; - return ((void *) &allocation->user_space); + return ((void *)&allocation->user_space); } - /******************************************************************************* * * FUNCTION: acpi_ut_callocate_and_track @@ -509,41 +470,38 @@ acpi_ut_allocate_and_track ( * ******************************************************************************/ -void * -acpi_ut_callocate_and_track ( - acpi_size size, - u32 component, - char *module, - u32 line) +void *acpi_ut_callocate_and_track(acpi_size size, + u32 component, char *module, u32 line) { - struct acpi_debug_mem_block *allocation; - acpi_status status; - + struct acpi_debug_mem_block *allocation; + acpi_status status; - allocation = acpi_ut_callocate (size + sizeof (struct acpi_debug_mem_header), - component, module, line); + allocation = + acpi_ut_callocate(size + sizeof(struct acpi_debug_mem_header), + component, module, line); if (!allocation) { /* Report allocation error */ - _ACPI_REPORT_ERROR (module, line, component, - ("ut_callocate: Could not allocate size %X\n", (u32) size)); + _ACPI_REPORT_ERROR(module, line, component, + ("ut_callocate: Could not allocate size %X\n", + (u32) size)); return (NULL); } - status = acpi_ut_track_allocation (allocation, size, - ACPI_MEM_CALLOC, component, module, line); - if (ACPI_FAILURE (status)) { - acpi_os_free (allocation); + status = acpi_ut_track_allocation(allocation, size, + ACPI_MEM_CALLOC, component, module, + line); + if (ACPI_FAILURE(status)) { + acpi_os_free(allocation); return (NULL); } acpi_gbl_global_list->total_allocated++; acpi_gbl_global_list->current_total_size += (u32) size; - return ((void *) &allocation->user_space); + return ((void *)&allocation->user_space); } - /******************************************************************************* * * FUNCTION: acpi_ut_free_and_track @@ -560,47 +518,41 @@ acpi_ut_callocate_and_track ( ******************************************************************************/ void -acpi_ut_free_and_track ( - void *allocation, - u32 component, - char *module, - u32 line) +acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line) { - struct acpi_debug_mem_block *debug_block; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ut_free", allocation); + struct acpi_debug_mem_block *debug_block; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ut_free", allocation); if (NULL == allocation) { - _ACPI_REPORT_ERROR (module, line, component, - ("acpi_ut_free: Attempt to delete a NULL address\n")); + _ACPI_REPORT_ERROR(module, line, component, + ("acpi_ut_free: Attempt to delete a NULL address\n")); return_VOID; } - debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block, - (((char *) allocation) - sizeof (struct acpi_debug_mem_header))); + debug_block = ACPI_CAST_PTR(struct acpi_debug_mem_block, + (((char *)allocation) - + sizeof(struct acpi_debug_mem_header))); acpi_gbl_global_list->total_freed++; acpi_gbl_global_list->current_total_size -= debug_block->size; - status = acpi_ut_remove_allocation (debug_block, - component, module, line); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n", - acpi_format_exception (status))); + status = acpi_ut_remove_allocation(debug_block, + component, module, line); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Could not free memory, %s\n", + acpi_format_exception(status))); } - acpi_os_free (debug_block); + acpi_os_free(debug_block); - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_find_allocation @@ -613,15 +565,11 @@ acpi_ut_free_and_track ( * ******************************************************************************/ -static struct acpi_debug_mem_block * -acpi_ut_find_allocation ( - void *allocation) +static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation) { - struct acpi_debug_mem_block *element; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_debug_mem_block *element; + ACPI_FUNCTION_ENTRY(); element = acpi_gbl_global_list->list_head; @@ -638,7 +586,6 @@ acpi_ut_find_allocation ( return (NULL); } - /******************************************************************************* * * FUNCTION: acpi_ut_track_allocation @@ -657,58 +604,51 @@ acpi_ut_find_allocation ( ******************************************************************************/ static acpi_status -acpi_ut_track_allocation ( - struct acpi_debug_mem_block *allocation, - acpi_size size, - u8 alloc_type, - u32 component, - char *module, - u32 line) +acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation, + acpi_size size, + u8 alloc_type, u32 component, char *module, u32 line) { - struct acpi_memory_list *mem_list; - struct acpi_debug_mem_block *element; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation); + struct acpi_memory_list *mem_list; + struct acpi_debug_mem_block *element; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE_PTR("ut_track_allocation", allocation); mem_list = acpi_gbl_global_list; - status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* * Search list for this address to make sure it is not already on the list. * This will catch several kinds of problems. */ - element = acpi_ut_find_allocation (allocation); + element = acpi_ut_find_allocation(allocation); if (element) { - ACPI_REPORT_ERROR (( - "ut_track_allocation: Allocation already present in list! (%p)\n", - allocation)); + ACPI_REPORT_ERROR(("ut_track_allocation: Allocation already present in list! (%p)\n", allocation)); - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", - element, allocation)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Element %p Address %p\n", + element, allocation)); goto unlock_and_exit; } /* Fill in the instance data. */ - allocation->size = (u32) size; + allocation->size = (u32) size; allocation->alloc_type = alloc_type; allocation->component = component; - allocation->line = line; + allocation->line = line; - ACPI_STRNCPY (allocation->module, module, ACPI_MAX_MODULE_NAME); - allocation->module[ACPI_MAX_MODULE_NAME-1] = 0; + ACPI_STRNCPY(allocation->module, module, ACPI_MAX_MODULE_NAME); + allocation->module[ACPI_MAX_MODULE_NAME - 1] = 0; /* Insert at list head */ if (mem_list->list_head) { - ((struct acpi_debug_mem_block *)(mem_list->list_head))->previous = allocation; + ((struct acpi_debug_mem_block *)(mem_list->list_head))-> + previous = allocation; } allocation->next = mem_list->list_head; @@ -716,13 +656,11 @@ acpi_ut_track_allocation ( mem_list->list_head = allocation; - -unlock_and_exit: - status = acpi_ut_release_mutex (ACPI_MTX_MEMORY); - return_ACPI_STATUS (status); + unlock_and_exit: + status = acpi_ut_release_mutex(ACPI_MTX_MEMORY); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_remove_allocation @@ -739,40 +677,34 @@ unlock_and_exit: ******************************************************************************/ static acpi_status -acpi_ut_remove_allocation ( - struct acpi_debug_mem_block *allocation, - u32 component, - char *module, - u32 line) +acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation, + u32 component, char *module, u32 line) { - struct acpi_memory_list *mem_list; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ut_remove_allocation"); + struct acpi_memory_list *mem_list; + acpi_status status; + ACPI_FUNCTION_TRACE("ut_remove_allocation"); mem_list = acpi_gbl_global_list; if (NULL == mem_list->list_head) { /* No allocations! */ - _ACPI_REPORT_ERROR (module, line, component, - ("ut_remove_allocation: Empty allocation list, nothing to free!\n")); + _ACPI_REPORT_ERROR(module, line, component, + ("ut_remove_allocation: Empty allocation list, nothing to free!\n")); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Unlink */ if (allocation->previous) { (allocation->previous)->next = allocation->next; - } - else { + } else { mem_list->list_head = allocation->next; } @@ -782,16 +714,15 @@ acpi_ut_remove_allocation ( /* Mark the segment as deleted */ - ACPI_MEMSET (&allocation->user_space, 0xEA, allocation->size); + ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size); - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", - allocation->size)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", + allocation->size)); - status = acpi_ut_release_mutex (ACPI_MTX_MEMORY); - return_ACPI_STATUS (status); + status = acpi_ut_release_mutex(ACPI_MTX_MEMORY); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_dump_allocation_info @@ -805,15 +736,13 @@ acpi_ut_remove_allocation ( ******************************************************************************/ #ifdef ACPI_FUTURE_USAGE -void -acpi_ut_dump_allocation_info ( - void) +void acpi_ut_dump_allocation_info(void) { /* struct acpi_memory_list *mem_list; */ - ACPI_FUNCTION_TRACE ("ut_dump_allocation_info"); + ACPI_FUNCTION_TRACE("ut_dump_allocation_info"); /* ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, @@ -826,7 +755,6 @@ acpi_ut_dump_allocation_info ( mem_list->max_concurrent_count, ROUND_UP_TO_1K (mem_list->max_concurrent_size))); - ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", running_object_count, @@ -837,7 +765,6 @@ acpi_ut_dump_allocation_info ( running_alloc_count, ROUND_UP_TO_1K (running_alloc_size))); - ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%30s: %4d (%3d Kb)\n", "Current Nodes", acpi_gbl_current_node_count, @@ -851,8 +778,7 @@ acpi_ut_dump_allocation_info ( */ return_VOID; } -#endif /* ACPI_FUTURE_USAGE */ - +#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * @@ -867,84 +793,87 @@ acpi_ut_dump_allocation_info ( * ******************************************************************************/ -void -acpi_ut_dump_allocations ( - u32 component, - char *module) +void acpi_ut_dump_allocations(u32 component, char *module) { - struct acpi_debug_mem_block *element; - union acpi_descriptor *descriptor; - u32 num_outstanding = 0; - - - ACPI_FUNCTION_TRACE ("ut_dump_allocations"); + struct acpi_debug_mem_block *element; + union acpi_descriptor *descriptor; + u32 num_outstanding = 0; + ACPI_FUNCTION_TRACE("ut_dump_allocations"); /* * Walk the allocation list. */ - if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_MEMORY))) { + if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_MEMORY))) { return; } element = acpi_gbl_global_list->list_head; while (element) { if ((element->component & component) && - ((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) { + ((module == NULL) + || (0 == ACPI_STRCMP(module, element->module)))) { /* Ignore allocated objects that are in a cache */ - descriptor = ACPI_CAST_PTR (union acpi_descriptor, &element->user_space); + descriptor = + ACPI_CAST_PTR(union acpi_descriptor, + &element->user_space); if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) { - acpi_os_printf ("%p Len %04X %9.9s-%d [%s] ", - descriptor, element->size, element->module, - element->line, acpi_ut_get_descriptor_name (descriptor)); + acpi_os_printf("%p Len %04X %9.9s-%d [%s] ", + descriptor, element->size, + element->module, element->line, + acpi_ut_get_descriptor_name + (descriptor)); /* Most of the elements will be Operand objects. */ - switch (ACPI_GET_DESCRIPTOR_TYPE (descriptor)) { + switch (ACPI_GET_DESCRIPTOR_TYPE(descriptor)) { case ACPI_DESC_TYPE_OPERAND: - acpi_os_printf ("%12.12s R%hd", - acpi_ut_get_type_name (descriptor->object.common.type), - descriptor->object.common.reference_count); + acpi_os_printf("%12.12s R%hd", + acpi_ut_get_type_name + (descriptor->object. + common.type), + descriptor->object. + common.reference_count); break; case ACPI_DESC_TYPE_PARSER: - acpi_os_printf ("aml_opcode %04hX", - descriptor->op.asl.aml_opcode); + acpi_os_printf("aml_opcode %04hX", + descriptor->op.asl. + aml_opcode); break; case ACPI_DESC_TYPE_NAMED: - acpi_os_printf ("%4.4s", - acpi_ut_get_node_name (&descriptor->node)); + acpi_os_printf("%4.4s", + acpi_ut_get_node_name + (&descriptor->node)); break; default: break; } - acpi_os_printf ( "\n"); + acpi_os_printf("\n"); num_outstanding++; } } element = element->next; } - (void) acpi_ut_release_mutex (ACPI_MTX_MEMORY); + (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY); /* Print summary */ if (!num_outstanding) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "No outstanding allocations.\n")); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "%d(%X) Outstanding allocations\n", - num_outstanding, num_outstanding)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No outstanding allocations.\n")); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "%d(%X) Outstanding allocations\n", + num_outstanding, num_outstanding)); } return_VOID; } -#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */ - +#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */ diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c index c0df058..93d4868 100644 --- a/drivers/acpi/utilities/utcache.c +++ b/drivers/acpi/utilities/utcache.c @@ -41,12 +41,10 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utcache") - +ACPI_MODULE_NAME("utcache") #ifdef ACPI_USE_LOCAL_CACHE /******************************************************************************* @@ -63,19 +61,14 @@ * DESCRIPTION: Create a cache object * ******************************************************************************/ - acpi_status -acpi_os_create_cache ( - char *cache_name, - u16 object_size, - u16 max_depth, - struct acpi_memory_list **return_cache) +acpi_os_create_cache(char *cache_name, + u16 object_size, + u16 max_depth, struct acpi_memory_list **return_cache) { - struct acpi_memory_list *cache; - - - ACPI_FUNCTION_ENTRY (); + struct acpi_memory_list *cache; + ACPI_FUNCTION_ENTRY(); if (!cache_name || !return_cache || (object_size < 16)) { return (AE_BAD_PARAMETER); @@ -83,24 +76,23 @@ acpi_os_create_cache ( /* Create the cache object */ - cache = acpi_os_allocate (sizeof (struct acpi_memory_list)); + cache = acpi_os_allocate(sizeof(struct acpi_memory_list)); if (!cache) { return (AE_NO_MEMORY); } /* Populate the cache object and return it */ - ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); + ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list)); cache->link_offset = 8; - cache->list_name = cache_name; + cache->list_name = cache_name; cache->object_size = object_size; - cache->max_depth = max_depth; + cache->max_depth = max_depth; *return_cache = cache; return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_os_purge_cache @@ -113,15 +105,11 @@ acpi_os_create_cache ( * ******************************************************************************/ -acpi_status -acpi_os_purge_cache ( - struct acpi_memory_list *cache) +acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache) { - char *next; - - - ACPI_FUNCTION_ENTRY (); + char *next; + ACPI_FUNCTION_ENTRY(); if (!cache) { return (AE_BAD_PARAMETER); @@ -132,9 +120,11 @@ acpi_os_purge_cache ( while (cache->list_head) { /* Delete and unlink one cached state object */ - next = *(ACPI_CAST_INDIRECT_PTR (char, - &(((char *) cache->list_head)[cache->link_offset]))); - ACPI_MEM_FREE (cache->list_head); + next = *(ACPI_CAST_INDIRECT_PTR(char, + &(((char *)cache-> + list_head)[cache-> + link_offset]))); + ACPI_MEM_FREE(cache->list_head); cache->list_head = next; cache->current_depth--; @@ -143,7 +133,6 @@ acpi_os_purge_cache ( return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_os_delete_cache @@ -157,30 +146,25 @@ acpi_os_purge_cache ( * ******************************************************************************/ -acpi_status -acpi_os_delete_cache ( - struct acpi_memory_list *cache) +acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache) { - acpi_status status; - + acpi_status status; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); + /* Purge all objects in the cache */ - /* Purge all objects in the cache */ - - status = acpi_os_purge_cache (cache); - if (ACPI_FAILURE (status)) { + status = acpi_os_purge_cache(cache); + if (ACPI_FAILURE(status)) { return (status); } /* Now we can delete the cache object */ - acpi_os_free (cache); + acpi_os_free(cache); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_os_release_object @@ -196,15 +180,11 @@ acpi_os_delete_cache ( ******************************************************************************/ acpi_status -acpi_os_release_object ( - struct acpi_memory_list *cache, - void *object) +acpi_os_release_object(struct acpi_memory_list * cache, void *object) { - acpi_status status; - - - ACPI_FUNCTION_ENTRY (); + acpi_status status; + ACPI_FUNCTION_ENTRY(); if (!cache || !object) { return (AE_BAD_PARAMETER); @@ -213,37 +193,38 @@ acpi_os_release_object ( /* If cache is full, just free this object */ if (cache->current_depth >= cache->max_depth) { - ACPI_MEM_FREE (object); - ACPI_MEM_TRACKING (cache->total_freed++); + ACPI_MEM_FREE(object); + ACPI_MEM_TRACKING(cache->total_freed++); } /* Otherwise put this object back into the cache */ else { - status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); + if (ACPI_FAILURE(status)) { return (status); } /* Mark the object as cached */ - ACPI_MEMSET (object, 0xCA, cache->object_size); - ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED); + ACPI_MEMSET(object, 0xCA, cache->object_size); + ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_CACHED); /* Put the object at the head of the cache list */ - * (ACPI_CAST_INDIRECT_PTR (char, - &(((char *) object)[cache->link_offset]))) = cache->list_head; + *(ACPI_CAST_INDIRECT_PTR(char, + &(((char *)object)[cache-> + link_offset]))) = + cache->list_head; cache->list_head = object; cache->current_depth++; - (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); + (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); } return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_os_acquire_object @@ -257,27 +238,23 @@ acpi_os_release_object ( * ******************************************************************************/ -void * -acpi_os_acquire_object ( - struct acpi_memory_list *cache) +void *acpi_os_acquire_object(struct acpi_memory_list *cache) { - acpi_status status; - void *object; - - - ACPI_FUNCTION_NAME ("os_acquire_object"); + acpi_status status; + void *object; + ACPI_FUNCTION_NAME("os_acquire_object"); if (!cache) { return (NULL); } - status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); + if (ACPI_FAILURE(status)) { return (NULL); } - ACPI_MEM_TRACKING (cache->requests++); + ACPI_MEM_TRACKING(cache->requests++); /* Check the cache first */ @@ -285,37 +262,39 @@ acpi_os_acquire_object ( /* There is an object available, use it */ object = cache->list_head; - cache->list_head = *(ACPI_CAST_INDIRECT_PTR (char, - &(((char *) object)[cache->link_offset]))); + cache->list_head = *(ACPI_CAST_INDIRECT_PTR(char, + &(((char *) + object)[cache-> + link_offset]))); cache->current_depth--; - ACPI_MEM_TRACKING (cache->hits++); - ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Object %p from %s cache\n", object, cache->list_name))); + ACPI_MEM_TRACKING(cache->hits++); + ACPI_MEM_TRACKING(ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "Object %p from %s cache\n", + object, cache->list_name))); - status = acpi_ut_release_mutex (ACPI_MTX_CACHES); - if (ACPI_FAILURE (status)) { + status = acpi_ut_release_mutex(ACPI_MTX_CACHES); + if (ACPI_FAILURE(status)) { return (NULL); } /* Clear (zero) the previously used Object */ - ACPI_MEMSET (object, 0, cache->object_size); - } - else { + ACPI_MEMSET(object, 0, cache->object_size); + } else { /* The cache is empty, create a new object */ - ACPI_MEM_TRACKING (cache->total_allocated++); + ACPI_MEM_TRACKING(cache->total_allocated++); /* Avoid deadlock with ACPI_MEM_CALLOCATE */ - status = acpi_ut_release_mutex (ACPI_MTX_CACHES); - if (ACPI_FAILURE (status)) { + status = acpi_ut_release_mutex(ACPI_MTX_CACHES); + if (ACPI_FAILURE(status)) { return (NULL); } - object = ACPI_MEM_CALLOCATE (cache->object_size); + object = ACPI_MEM_CALLOCATE(cache->object_size); if (!object) { return (NULL); } @@ -323,6 +302,4 @@ acpi_os_acquire_object ( return (object); } -#endif /* ACPI_USE_LOCAL_CACHE */ - - +#endif /* ACPI_USE_LOCAL_CACHE */ diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c index 31c30a3..5442b32 100644 --- a/drivers/acpi/utilities/utcopy.c +++ b/drivers/acpi/utilities/utcopy.c @@ -41,59 +41,46 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utcopy") +ACPI_MODULE_NAME("utcopy") /* Local prototypes */ - static acpi_status -acpi_ut_copy_isimple_to_esimple ( - union acpi_operand_object *internal_object, - union acpi_object *external_object, - u8 *data_space, - acpi_size *buffer_space_used); +acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object, + union acpi_object *external_object, + u8 * data_space, acpi_size * buffer_space_used); static acpi_status -acpi_ut_copy_ielement_to_ielement ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context); +acpi_ut_copy_ielement_to_ielement(u8 object_type, + union acpi_operand_object *source_object, + union acpi_generic_state *state, + void *context); static acpi_status -acpi_ut_copy_ipackage_to_epackage ( - union acpi_operand_object *internal_object, - u8 *buffer, - acpi_size *space_used); +acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object, + u8 * buffer, acpi_size * space_used); static acpi_status -acpi_ut_copy_esimple_to_isimple( - union acpi_object *user_obj, - union acpi_operand_object **return_obj); +acpi_ut_copy_esimple_to_isimple(union acpi_object *user_obj, + union acpi_operand_object **return_obj); static acpi_status -acpi_ut_copy_simple_object ( - union acpi_operand_object *source_desc, - union acpi_operand_object *dest_desc); +acpi_ut_copy_simple_object(union acpi_operand_object *source_desc, + union acpi_operand_object *dest_desc); static acpi_status -acpi_ut_copy_ielement_to_eelement ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context); +acpi_ut_copy_ielement_to_eelement(u8 object_type, + union acpi_operand_object *source_object, + union acpi_generic_state *state, + void *context); static acpi_status -acpi_ut_copy_ipackage_to_ipackage ( - union acpi_operand_object *source_obj, - union acpi_operand_object *dest_obj, - struct acpi_walk_state *walk_state); - +acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj, + union acpi_operand_object *dest_obj, + struct acpi_walk_state *walk_state); /******************************************************************************* * @@ -116,17 +103,13 @@ acpi_ut_copy_ipackage_to_ipackage ( ******************************************************************************/ static acpi_status -acpi_ut_copy_isimple_to_esimple ( - union acpi_operand_object *internal_object, - union acpi_object *external_object, - u8 *data_space, - acpi_size *buffer_space_used) +acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object, + union acpi_object *external_object, + u8 * data_space, acpi_size * buffer_space_used) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ut_copy_isimple_to_esimple"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ut_copy_isimple_to_esimple"); *buffer_space_used = 0; @@ -135,54 +118,54 @@ acpi_ut_copy_isimple_to_esimple ( * package element) */ if (!internal_object) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Always clear the external object */ - ACPI_MEMSET (external_object, 0, sizeof (union acpi_object)); + ACPI_MEMSET(external_object, 0, sizeof(union acpi_object)); /* * In general, the external object will be the same type as * the internal object */ - external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); + external_object->type = ACPI_GET_OBJECT_TYPE(internal_object); /* However, only a limited number of external types are supported */ - switch (ACPI_GET_OBJECT_TYPE (internal_object)) { + switch (ACPI_GET_OBJECT_TYPE(internal_object)) { case ACPI_TYPE_STRING: - external_object->string.pointer = (char *) data_space; + external_object->string.pointer = (char *)data_space; external_object->string.length = internal_object->string.length; - *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ( - (acpi_size) internal_object->string.length + 1); - - ACPI_MEMCPY ((void *) data_space, - (void *) internal_object->string.pointer, - (acpi_size) internal_object->string.length + 1); + *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size) + internal_object-> + string. + length + 1); + + ACPI_MEMCPY((void *)data_space, + (void *)internal_object->string.pointer, + (acpi_size) internal_object->string.length + 1); break; - case ACPI_TYPE_BUFFER: external_object->buffer.pointer = data_space; external_object->buffer.length = internal_object->buffer.length; - *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ( - internal_object->string.length); + *buffer_space_used = + ACPI_ROUND_UP_TO_NATIVE_WORD(internal_object->string. + length); - ACPI_MEMCPY ((void *) data_space, - (void *) internal_object->buffer.pointer, - internal_object->buffer.length); + ACPI_MEMCPY((void *)data_space, + (void *)internal_object->buffer.pointer, + internal_object->buffer.length); break; - case ACPI_TYPE_INTEGER: external_object->integer.value = internal_object->integer.value; break; - case ACPI_TYPE_LOCAL_REFERENCE: /* @@ -199,41 +182,41 @@ acpi_ut_copy_isimple_to_esimple ( * to object containing a handle to an ACPI named object. */ external_object->type = ACPI_TYPE_ANY; - external_object->reference.handle = internal_object->reference.node; + external_object->reference.handle = + internal_object->reference.node; break; } break; - case ACPI_TYPE_PROCESSOR: - external_object->processor.proc_id = internal_object->processor.proc_id; - external_object->processor.pblk_address = internal_object->processor.address; - external_object->processor.pblk_length = internal_object->processor.length; + external_object->processor.proc_id = + internal_object->processor.proc_id; + external_object->processor.pblk_address = + internal_object->processor.address; + external_object->processor.pblk_length = + internal_object->processor.length; break; - case ACPI_TYPE_POWER: external_object->power_resource.system_level = - internal_object->power_resource.system_level; + internal_object->power_resource.system_level; external_object->power_resource.resource_order = - internal_object->power_resource.resource_order; + internal_object->power_resource.resource_order; break; - default: /* * There is no corresponding external object type */ - return_ACPI_STATUS (AE_SUPPORT); + return_ACPI_STATUS(AE_SUPPORT); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_ielement_to_eelement @@ -247,25 +230,23 @@ acpi_ut_copy_isimple_to_esimple ( ******************************************************************************/ static acpi_status -acpi_ut_copy_ielement_to_eelement ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context) +acpi_ut_copy_ielement_to_eelement(u8 object_type, + union acpi_operand_object *source_object, + union acpi_generic_state *state, + void *context) { - acpi_status status = AE_OK; - struct acpi_pkg_info *info = (struct acpi_pkg_info *) context; - acpi_size object_space; - u32 this_index; - union acpi_object *target_object; - + acpi_status status = AE_OK; + struct acpi_pkg_info *info = (struct acpi_pkg_info *)context; + acpi_size object_space; + u32 this_index; + union acpi_object *target_object; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); - - this_index = state->pkg.index; + this_index = state->pkg.index; target_object = (union acpi_object *) - &((union acpi_object *)(state->pkg.dest_object))->package.elements[this_index]; + &((union acpi_object *)(state->pkg.dest_object))->package. + elements[this_index]; switch (object_type) { case ACPI_COPY_TYPE_SIMPLE: @@ -273,23 +254,24 @@ acpi_ut_copy_ielement_to_eelement ( /* * This is a simple or null object */ - status = acpi_ut_copy_isimple_to_esimple (source_object, - target_object, info->free_space, &object_space); - if (ACPI_FAILURE (status)) { + status = acpi_ut_copy_isimple_to_esimple(source_object, + target_object, + info->free_space, + &object_space); + if (ACPI_FAILURE(status)) { return (status); } break; - case ACPI_COPY_TYPE_PACKAGE: /* * Build the package object */ - target_object->type = ACPI_TYPE_PACKAGE; - target_object->package.count = source_object->package.count; + target_object->type = ACPI_TYPE_PACKAGE; + target_object->package.count = source_object->package.count; target_object->package.elements = - ACPI_CAST_PTR (union acpi_object, info->free_space); + ACPI_CAST_PTR(union acpi_object, info->free_space); /* * Pass the new package object back to the package walk routine @@ -300,22 +282,22 @@ acpi_ut_copy_ielement_to_eelement ( * Save space for the array of objects (Package elements) * update the buffer length counter */ - object_space = ACPI_ROUND_UP_TO_NATIVE_WORD ( - (acpi_size) target_object->package.count * - sizeof (union acpi_object)); + object_space = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size) + target_object-> + package.count * + sizeof(union + acpi_object)); break; - default: return (AE_BAD_PARAMETER); } - info->free_space += object_space; - info->length += object_space; + info->free_space += object_space; + info->length += object_space; return (status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_ipackage_to_epackage @@ -336,55 +318,51 @@ acpi_ut_copy_ielement_to_eelement ( ******************************************************************************/ static acpi_status -acpi_ut_copy_ipackage_to_epackage ( - union acpi_operand_object *internal_object, - u8 *buffer, - acpi_size *space_used) +acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object, + u8 * buffer, acpi_size * space_used) { - union acpi_object *external_object; - acpi_status status; - struct acpi_pkg_info info; - - - ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_epackage"); + union acpi_object *external_object; + acpi_status status; + struct acpi_pkg_info info; + ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_epackage"); /* * First package at head of the buffer */ - external_object = ACPI_CAST_PTR (union acpi_object, buffer); + external_object = ACPI_CAST_PTR(union acpi_object, buffer); /* * Free space begins right after the first package */ - info.length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); - info.free_space = buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( - sizeof (union acpi_object)); + info.length = ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)); + info.free_space = + buffer + ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)); info.object_space = 0; info.num_packages = 1; - external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); - external_object->package.count = internal_object->package.count; - external_object->package.elements = ACPI_CAST_PTR (union acpi_object, - info.free_space); + external_object->type = ACPI_GET_OBJECT_TYPE(internal_object); + external_object->package.count = internal_object->package.count; + external_object->package.elements = ACPI_CAST_PTR(union acpi_object, + info.free_space); /* * Leave room for an array of ACPI_OBJECTS in the buffer * and move the free space past it */ - info.length += (acpi_size) external_object->package.count * - ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); + info.length += (acpi_size) external_object->package.count * + ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)); info.free_space += external_object->package.count * - ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); + ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)); - status = acpi_ut_walk_package_tree (internal_object, external_object, - acpi_ut_copy_ielement_to_eelement, &info); + status = acpi_ut_walk_package_tree(internal_object, external_object, + acpi_ut_copy_ielement_to_eelement, + &info); *space_used = info.length; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_iobject_to_eobject @@ -400,44 +378,45 @@ acpi_ut_copy_ipackage_to_epackage ( ******************************************************************************/ acpi_status -acpi_ut_copy_iobject_to_eobject ( - union acpi_operand_object *internal_object, - struct acpi_buffer *ret_buffer) +acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object, + struct acpi_buffer *ret_buffer) { - acpi_status status; + acpi_status status; + ACPI_FUNCTION_TRACE("ut_copy_iobject_to_eobject"); - ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_eobject"); - - - if (ACPI_GET_OBJECT_TYPE (internal_object) == ACPI_TYPE_PACKAGE) { + if (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE) { /* * Package object: Copy all subobjects (including * nested packages) */ - status = acpi_ut_copy_ipackage_to_epackage (internal_object, - ret_buffer->pointer, &ret_buffer->length); - } - else { + status = acpi_ut_copy_ipackage_to_epackage(internal_object, + ret_buffer->pointer, + &ret_buffer->length); + } else { /* * Build a simple object (no nested objects) */ - status = acpi_ut_copy_isimple_to_esimple (internal_object, - (union acpi_object *) ret_buffer->pointer, - ((u8 *) ret_buffer->pointer + - ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object))), - &ret_buffer->length); + status = acpi_ut_copy_isimple_to_esimple(internal_object, + (union acpi_object *) + ret_buffer->pointer, + ((u8 *) ret_buffer-> + pointer + + ACPI_ROUND_UP_TO_NATIVE_WORD + (sizeof + (union + acpi_object))), + &ret_buffer->length); /* * build simple does not include the object size in the length * so we add it in here */ - ret_buffer->length += sizeof (union acpi_object); + ret_buffer->length += sizeof(union acpi_object); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_esimple_to_isimple @@ -455,15 +434,12 @@ acpi_ut_copy_iobject_to_eobject ( ******************************************************************************/ static acpi_status -acpi_ut_copy_esimple_to_isimple ( - union acpi_object *external_object, - union acpi_operand_object **ret_internal_object) +acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object, + union acpi_operand_object **ret_internal_object) { - union acpi_operand_object *internal_object; - - - ACPI_FUNCTION_TRACE ("ut_copy_esimple_to_isimple"); + union acpi_operand_object *internal_object; + ACPI_FUNCTION_TRACE("ut_copy_esimple_to_isimple"); /* * Simple types supported are: String, Buffer, Integer @@ -473,58 +449,57 @@ acpi_ut_copy_esimple_to_isimple ( case ACPI_TYPE_BUFFER: case ACPI_TYPE_INTEGER: - internal_object = acpi_ut_create_internal_object ( - (u8) external_object->type); + internal_object = acpi_ut_create_internal_object((u8) + external_object-> + type); if (!internal_object) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } break; default: /* All other types are not supported */ - return_ACPI_STATUS (AE_SUPPORT); + return_ACPI_STATUS(AE_SUPPORT); } - /* Must COPY string and buffer contents */ switch (external_object->type) { case ACPI_TYPE_STRING: internal_object->string.pointer = - ACPI_MEM_CALLOCATE ((acpi_size) external_object->string.length + 1); + ACPI_MEM_CALLOCATE((acpi_size) external_object->string. + length + 1); if (!internal_object->string.pointer) { goto error_exit; } - ACPI_MEMCPY (internal_object->string.pointer, - external_object->string.pointer, - external_object->string.length); + ACPI_MEMCPY(internal_object->string.pointer, + external_object->string.pointer, + external_object->string.length); internal_object->string.length = external_object->string.length; break; - case ACPI_TYPE_BUFFER: internal_object->buffer.pointer = - ACPI_MEM_CALLOCATE (external_object->buffer.length); + ACPI_MEM_CALLOCATE(external_object->buffer.length); if (!internal_object->buffer.pointer) { goto error_exit; } - ACPI_MEMCPY (internal_object->buffer.pointer, - external_object->buffer.pointer, - external_object->buffer.length); + ACPI_MEMCPY(internal_object->buffer.pointer, + external_object->buffer.pointer, + external_object->buffer.length); internal_object->buffer.length = external_object->buffer.length; break; - case ACPI_TYPE_INTEGER: - internal_object->integer.value = external_object->integer.value; + internal_object->integer.value = external_object->integer.value; break; default: @@ -533,15 +508,13 @@ acpi_ut_copy_esimple_to_isimple ( } *ret_internal_object = internal_object; - return_ACPI_STATUS (AE_OK); - + return_ACPI_STATUS(AE_OK); -error_exit: - acpi_ut_remove_reference (internal_object); - return_ACPI_STATUS (AE_NO_MEMORY); + error_exit: + acpi_ut_remove_reference(internal_object); + return_ACPI_STATUS(AE_NO_MEMORY); } - #ifdef ACPI_FUTURE_IMPLEMENTATION /* Code to convert packages that are parameters to control methods */ @@ -565,22 +538,18 @@ error_exit: ******************************************************************************/ static acpi_status -acpi_ut_copy_epackage_to_ipackage ( - union acpi_operand_object *internal_object, - u8 *buffer, - u32 *space_used) +acpi_ut_copy_epackage_to_ipackage(union acpi_operand_object *internal_object, + u8 * buffer, u32 * space_used) { - u8 *free_space; - union acpi_object *external_object; - u32 length = 0; - u32 this_index; - u32 object_space = 0; - union acpi_operand_object *this_internal_obj; - union acpi_object *this_external_obj; - - - ACPI_FUNCTION_TRACE ("ut_copy_epackage_to_ipackage"); + u8 *free_space; + union acpi_object *external_object; + u32 length = 0; + u32 this_index; + u32 object_space = 0; + union acpi_operand_object *this_internal_obj; + union acpi_object *this_external_obj; + ACPI_FUNCTION_TRACE("ut_copy_epackage_to_ipackage"); /* * First package at head of the buffer @@ -592,24 +561,22 @@ acpi_ut_copy_epackage_to_ipackage ( */ free_space = buffer + sizeof(union acpi_object); - - external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); - external_object->package.count = internal_object->package.count; - external_object->package.elements = (union acpi_object *)free_space; + external_object->type = ACPI_GET_OBJECT_TYPE(internal_object); + external_object->package.count = internal_object->package.count; + external_object->package.elements = (union acpi_object *)free_space; /* * Build an array of ACPI_OBJECTS in the buffer * and move the free space past it */ - free_space += external_object->package.count * sizeof(union acpi_object); - + free_space += + external_object->package.count * sizeof(union acpi_object); /* Call walk_package */ } -#endif /* Future implementation */ - +#endif /* Future implementation */ /******************************************************************************* * @@ -625,37 +592,35 @@ acpi_ut_copy_epackage_to_ipackage ( ******************************************************************************/ acpi_status -acpi_ut_copy_eobject_to_iobject ( - union acpi_object *external_object, - union acpi_operand_object **internal_object) +acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object, + union acpi_operand_object **internal_object) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ut_copy_eobject_to_iobject"); + acpi_status status; + ACPI_FUNCTION_TRACE("ut_copy_eobject_to_iobject"); if (external_object->type == ACPI_TYPE_PACKAGE) { /* * Packages as external input to control methods are not supported, */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Packages as parameters not implemented!\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Packages as parameters not implemented!\n")); - return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + return_ACPI_STATUS(AE_NOT_IMPLEMENTED); } else { /* * Build a simple object (no nested objects) */ - status = acpi_ut_copy_esimple_to_isimple (external_object, internal_object); + status = + acpi_ut_copy_esimple_to_isimple(external_object, + internal_object); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_simple_object @@ -671,23 +636,21 @@ acpi_ut_copy_eobject_to_iobject ( ******************************************************************************/ static acpi_status -acpi_ut_copy_simple_object ( - union acpi_operand_object *source_desc, - union acpi_operand_object *dest_desc) +acpi_ut_copy_simple_object(union acpi_operand_object *source_desc, + union acpi_operand_object *dest_desc) { - u16 reference_count; - union acpi_operand_object *next_object; - + u16 reference_count; + union acpi_operand_object *next_object; /* Save fields from destination that we don't want to overwrite */ reference_count = dest_desc->common.reference_count; next_object = dest_desc->common.next_object; - /* Copy the entire source object over the destination object*/ + /* Copy the entire source object over the destination object */ - ACPI_MEMCPY ((char *) dest_desc, (char *) source_desc, - sizeof (union acpi_operand_object)); + ACPI_MEMCPY((char *)dest_desc, (char *)source_desc, + sizeof(union acpi_operand_object)); /* Restore the saved fields */ @@ -700,7 +663,7 @@ acpi_ut_copy_simple_object ( /* Handle the objects with extra data */ - switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { + switch (ACPI_GET_OBJECT_TYPE(dest_desc)) { case ACPI_TYPE_BUFFER: /* * Allocate and copy the actual buffer if and only if: @@ -708,18 +671,18 @@ acpi_ut_copy_simple_object ( * 2) The buffer has a length > 0 */ if ((source_desc->buffer.pointer) && - (source_desc->buffer.length)) { + (source_desc->buffer.length)) { dest_desc->buffer.pointer = - ACPI_MEM_ALLOCATE (source_desc->buffer.length); + ACPI_MEM_ALLOCATE(source_desc->buffer.length); if (!dest_desc->buffer.pointer) { return (AE_NO_MEMORY); } /* Copy the actual buffer data */ - ACPI_MEMCPY (dest_desc->buffer.pointer, - source_desc->buffer.pointer, - source_desc->buffer.length); + ACPI_MEMCPY(dest_desc->buffer.pointer, + source_desc->buffer.pointer, + source_desc->buffer.length); } break; @@ -731,15 +694,17 @@ acpi_ut_copy_simple_object ( */ if (source_desc->string.pointer) { dest_desc->string.pointer = - ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1); + ACPI_MEM_ALLOCATE((acpi_size) source_desc->string. + length + 1); if (!dest_desc->string.pointer) { return (AE_NO_MEMORY); } /* Copy the actual string data */ - ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer, - (acpi_size) source_desc->string.length + 1); + ACPI_MEMCPY(dest_desc->string.pointer, + source_desc->string.pointer, + (acpi_size) source_desc->string.length + 1); } break; @@ -748,7 +713,7 @@ acpi_ut_copy_simple_object ( * We copied the reference object, so we now must add a reference * to the object pointed to by the reference */ - acpi_ut_add_reference (source_desc->reference.object); + acpi_ut_add_reference(source_desc->reference.object); break; default: @@ -759,7 +724,6 @@ acpi_ut_copy_simple_object ( return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_ielement_to_ielement @@ -773,24 +737,21 @@ acpi_ut_copy_simple_object ( ******************************************************************************/ static acpi_status -acpi_ut_copy_ielement_to_ielement ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context) +acpi_ut_copy_ielement_to_ielement(u8 object_type, + union acpi_operand_object *source_object, + union acpi_generic_state *state, + void *context) { - acpi_status status = AE_OK; - u32 this_index; - union acpi_operand_object **this_target_ptr; - union acpi_operand_object *target_object; + acpi_status status = AE_OK; + u32 this_index; + union acpi_operand_object **this_target_ptr; + union acpi_operand_object *target_object; + ACPI_FUNCTION_ENTRY(); - ACPI_FUNCTION_ENTRY (); - - - this_index = state->pkg.index; + this_index = state->pkg.index; this_target_ptr = (union acpi_operand_object **) - &state->pkg.dest_object->package.elements[this_index]; + &state->pkg.dest_object->package.elements[this_index]; switch (object_type) { case ACPI_COPY_TYPE_SIMPLE: @@ -801,34 +762,36 @@ acpi_ut_copy_ielement_to_ielement ( /* * This is a simple object, just copy it */ - target_object = acpi_ut_create_internal_object ( - ACPI_GET_OBJECT_TYPE (source_object)); + target_object = + acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE + (source_object)); if (!target_object) { return (AE_NO_MEMORY); } - status = acpi_ut_copy_simple_object (source_object, target_object); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_copy_simple_object(source_object, + target_object); + if (ACPI_FAILURE(status)) { goto error_exit; } *this_target_ptr = target_object; - } - else { + } else { /* Pass through a null element */ *this_target_ptr = NULL; } break; - case ACPI_COPY_TYPE_PACKAGE: /* * This object is a package - go down another nesting level * Create and build the package object */ - target_object = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE); + target_object = + acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE); if (!target_object) { return (AE_NO_MEMORY); } @@ -840,8 +803,8 @@ acpi_ut_copy_ielement_to_ielement ( * Create the object array */ target_object->package.elements = - ACPI_MEM_CALLOCATE (((acpi_size) source_object->package.count + 1) * - sizeof (void *)); + ACPI_MEM_CALLOCATE(((acpi_size) source_object->package. + count + 1) * sizeof(void *)); if (!target_object->package.elements) { status = AE_NO_MEMORY; goto error_exit; @@ -858,19 +821,17 @@ acpi_ut_copy_ielement_to_ielement ( *this_target_ptr = target_object; break; - default: return (AE_BAD_PARAMETER); } return (status); -error_exit: - acpi_ut_remove_reference (target_object); + error_exit: + acpi_ut_remove_reference(target_object); return (status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_ipackage_to_ipackage @@ -886,49 +847,46 @@ error_exit: ******************************************************************************/ static acpi_status -acpi_ut_copy_ipackage_to_ipackage ( - union acpi_operand_object *source_obj, - union acpi_operand_object *dest_obj, - struct acpi_walk_state *walk_state) +acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj, + union acpi_operand_object *dest_obj, + struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_ipackage"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_ipackage"); - dest_obj->common.type = ACPI_GET_OBJECT_TYPE (source_obj); - dest_obj->common.flags = source_obj->common.flags; + dest_obj->common.type = ACPI_GET_OBJECT_TYPE(source_obj); + dest_obj->common.flags = source_obj->common.flags; dest_obj->package.count = source_obj->package.count; /* * Create the object array and walk the source package tree */ - dest_obj->package.elements = ACPI_MEM_CALLOCATE ( - ((acpi_size) source_obj->package.count + 1) * - sizeof (void *)); + dest_obj->package.elements = ACPI_MEM_CALLOCATE(((acpi_size) + source_obj->package. + count + + 1) * sizeof(void *)); if (!dest_obj->package.elements) { - ACPI_REPORT_ERROR ( - ("aml_build_copy_internal_package_object: Package allocation failure\n")); - return_ACPI_STATUS (AE_NO_MEMORY); + ACPI_REPORT_ERROR(("aml_build_copy_internal_package_object: Package allocation failure\n")); + return_ACPI_STATUS(AE_NO_MEMORY); } /* * Copy the package element-by-element by walking the package "tree". * This handles nested packages of arbitrary depth. */ - status = acpi_ut_walk_package_tree (source_obj, dest_obj, - acpi_ut_copy_ielement_to_ielement, walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ut_walk_package_tree(source_obj, dest_obj, + acpi_ut_copy_ielement_to_ielement, + walk_state); + if (ACPI_FAILURE(status)) { /* On failure, delete the destination package object */ - acpi_ut_remove_reference (dest_obj); + acpi_ut_remove_reference(dest_obj); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_iobject_to_iobject @@ -944,35 +902,31 @@ acpi_ut_copy_ipackage_to_ipackage ( ******************************************************************************/ acpi_status -acpi_ut_copy_iobject_to_iobject ( - union acpi_operand_object *source_desc, - union acpi_operand_object **dest_desc, - struct acpi_walk_state *walk_state) +acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc, + union acpi_operand_object **dest_desc, + struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_iobject"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ut_copy_iobject_to_iobject"); /* Create the top level object */ - *dest_desc = acpi_ut_create_internal_object (ACPI_GET_OBJECT_TYPE (source_desc)); + *dest_desc = + acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE(source_desc)); if (!*dest_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Copy the object and possible subobjects */ - if (ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_PACKAGE) { - status = acpi_ut_copy_ipackage_to_ipackage (source_desc, *dest_desc, - walk_state); - } - else { - status = acpi_ut_copy_simple_object (source_desc, *dest_desc); + if (ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_PACKAGE) { + status = + acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc, + walk_state); + } else { + status = acpi_ut_copy_simple_object(source_desc, *dest_desc); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c index c27cbb7..081a778 100644 --- a/drivers/acpi/utilities/utdebug.c +++ b/drivers/acpi/utilities/utdebug.c @@ -46,21 +46,16 @@ #include #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utdebug") - +ACPI_MODULE_NAME("utdebug") #ifdef ACPI_DEBUG_OUTPUT - -static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF; -static char *acpi_gbl_fn_entry_str = "----Entry"; -static char *acpi_gbl_fn_exit_str = "----Exit-"; +static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF; +static char *acpi_gbl_fn_entry_str = "----Entry"; +static char *acpi_gbl_fn_exit_str = "----Exit-"; /* Local prototypes */ -static const char * -acpi_ut_trim_function_name ( - const char *function_name); - +static const char *acpi_ut_trim_function_name(const char *function_name); /******************************************************************************* * @@ -74,17 +69,13 @@ acpi_ut_trim_function_name ( * ******************************************************************************/ -void -acpi_ut_init_stack_ptr_trace ( - void) +void acpi_ut_init_stack_ptr_trace(void) { - u32 current_sp; - + u32 current_sp; - acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF (¤t_sp, NULL); + acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF(¤t_sp, NULL); } - /******************************************************************************* * * FUNCTION: acpi_ut_track_stack_ptr @@ -97,14 +88,11 @@ acpi_ut_init_stack_ptr_trace ( * ******************************************************************************/ -void -acpi_ut_track_stack_ptr ( - void) +void acpi_ut_track_stack_ptr(void) { - acpi_size current_sp; + acpi_size current_sp; - - current_sp = ACPI_PTR_DIFF (¤t_sp, NULL); + current_sp = ACPI_PTR_DIFF(¤t_sp, NULL); if (current_sp < acpi_gbl_lowest_stack_pointer) { acpi_gbl_lowest_stack_pointer = current_sp; @@ -115,7 +103,6 @@ acpi_ut_track_stack_ptr ( } } - /******************************************************************************* * * FUNCTION: acpi_ut_trim_function_name @@ -130,20 +117,18 @@ acpi_ut_track_stack_ptr ( * ******************************************************************************/ -static const char * -acpi_ut_trim_function_name ( - const char *function_name) +static const char *acpi_ut_trim_function_name(const char *function_name) { /* All Function names are longer than 4 chars, check is safe */ - if (*(ACPI_CAST_PTR (u32, function_name)) == ACPI_FUNCTION_PREFIX1) { + if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_FUNCTION_PREFIX1) { /* This is the case where the original source has not been modified */ return (function_name + 4); } - if (*(ACPI_CAST_PTR (u32, function_name)) == ACPI_FUNCTION_PREFIX2) { + if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_FUNCTION_PREFIX2) { /* This is the case where the source has been 'linuxized' */ return (function_name + 5); @@ -152,7 +137,6 @@ acpi_ut_trim_function_name ( return (function_name); } - /******************************************************************************* * * FUNCTION: acpi_ut_debug_print @@ -172,38 +156,33 @@ acpi_ut_trim_function_name ( * ******************************************************************************/ -void ACPI_INTERNAL_VAR_XFACE -acpi_ut_debug_print ( - u32 requested_debug_level, - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - char *format, - ...) +void ACPI_INTERNAL_VAR_XFACE +acpi_ut_debug_print(u32 requested_debug_level, + u32 line_number, + const char *function_name, + char *module_name, u32 component_id, char *format, ...) { - u32 thread_id; - va_list args; - + u32 thread_id; + va_list args; /* * Stay silent if the debug level or component ID is disabled */ if (!(requested_debug_level & acpi_dbg_level) || - !(component_id & acpi_dbg_layer)) { + !(component_id & acpi_dbg_layer)) { return; } /* * Thread tracking and context switch notification */ - thread_id = acpi_os_get_thread_id (); + thread_id = acpi_os_get_thread_id(); if (thread_id != acpi_gbl_prev_thread_id) { if (ACPI_LV_THREADS & acpi_dbg_level) { - acpi_os_printf ( - "\n**** Context Switch from TID %X to TID %X ****\n\n", - acpi_gbl_prev_thread_id, thread_id); + acpi_os_printf + ("\n**** Context Switch from TID %X to TID %X ****\n\n", + acpi_gbl_prev_thread_id, thread_id); } acpi_gbl_prev_thread_id = thread_id; @@ -213,17 +192,18 @@ acpi_ut_debug_print ( * Display the module name, current line number, thread ID (if requested), * current procedure nesting level, and the current procedure name */ - acpi_os_printf ("%8s-%04ld ", module_name, line_number); + acpi_os_printf("%8s-%04ld ", module_name, line_number); if (ACPI_LV_THREADS & acpi_dbg_level) { - acpi_os_printf ("[%04lX] ", thread_id); + acpi_os_printf("[%04lX] ", thread_id); } - acpi_os_printf ("[%02ld] %-22.22s: ", - acpi_gbl_nesting_level, acpi_ut_trim_function_name (function_name)); + acpi_os_printf("[%02ld] %-22.22s: ", + acpi_gbl_nesting_level, + acpi_ut_trim_function_name(function_name)); - va_start (args, format); - acpi_os_vprintf (format, args); + va_start(args, format); + acpi_os_vprintf(format, args); } EXPORT_SYMBOL(acpi_ut_debug_print); @@ -247,29 +227,24 @@ EXPORT_SYMBOL(acpi_ut_debug_print); * ******************************************************************************/ -void ACPI_INTERNAL_VAR_XFACE -acpi_ut_debug_print_raw ( - u32 requested_debug_level, - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - char *format, - ...) +void ACPI_INTERNAL_VAR_XFACE +acpi_ut_debug_print_raw(u32 requested_debug_level, + u32 line_number, + const char *function_name, + char *module_name, u32 component_id, char *format, ...) { - va_list args; - + va_list args; if (!(requested_debug_level & acpi_dbg_level) || - !(component_id & acpi_dbg_layer)) { + !(component_id & acpi_dbg_layer)) { return; } - va_start (args, format); - acpi_os_vprintf (format, args); + va_start(args, format); + acpi_os_vprintf(format, args); } -EXPORT_SYMBOL(acpi_ut_debug_print_raw); +EXPORT_SYMBOL(acpi_ut_debug_print_raw); /******************************************************************************* * @@ -288,22 +263,19 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw); ******************************************************************************/ void -acpi_ut_trace ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id) +acpi_ut_trace(u32 line_number, + const char *function_name, char *module_name, u32 component_id) { acpi_gbl_nesting_level++; - acpi_ut_track_stack_ptr (); + acpi_ut_track_stack_ptr(); - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, - line_number, function_name, module_name, component_id, - "%s\n", acpi_gbl_fn_entry_str); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s\n", acpi_gbl_fn_entry_str); } -EXPORT_SYMBOL(acpi_ut_trace); +EXPORT_SYMBOL(acpi_ut_trace); /******************************************************************************* * @@ -323,22 +295,19 @@ EXPORT_SYMBOL(acpi_ut_trace); ******************************************************************************/ void -acpi_ut_trace_ptr ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - void *pointer) +acpi_ut_trace_ptr(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, void *pointer) { acpi_gbl_nesting_level++; - acpi_ut_track_stack_ptr (); + acpi_ut_track_stack_ptr(); - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, - line_number, function_name, module_name, component_id, - "%s %p\n", acpi_gbl_fn_entry_str, pointer); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s %p\n", acpi_gbl_fn_entry_str, + pointer); } - /******************************************************************************* * * FUNCTION: acpi_ut_trace_str @@ -357,23 +326,20 @@ acpi_ut_trace_ptr ( ******************************************************************************/ void -acpi_ut_trace_str ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - char *string) +acpi_ut_trace_str(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, char *string) { acpi_gbl_nesting_level++; - acpi_ut_track_stack_ptr (); + acpi_ut_track_stack_ptr(); - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, - line_number, function_name, module_name, component_id, - "%s %s\n", acpi_gbl_fn_entry_str, string); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s %s\n", acpi_gbl_fn_entry_str, + string); } - /******************************************************************************* * * FUNCTION: acpi_ut_trace_u32 @@ -392,23 +358,20 @@ acpi_ut_trace_str ( ******************************************************************************/ void -acpi_ut_trace_u32 ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - u32 integer) +acpi_ut_trace_u32(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, u32 integer) { acpi_gbl_nesting_level++; - acpi_ut_track_stack_ptr (); + acpi_ut_track_stack_ptr(); - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, - line_number, function_name, module_name, component_id, - "%s %08X\n", acpi_gbl_fn_entry_str, integer); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s %08X\n", acpi_gbl_fn_entry_str, + integer); } - /******************************************************************************* * * FUNCTION: acpi_ut_exit @@ -426,21 +389,18 @@ acpi_ut_trace_u32 ( ******************************************************************************/ void -acpi_ut_exit ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id) +acpi_ut_exit(u32 line_number, + const char *function_name, char *module_name, u32 component_id) { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, - line_number, function_name, module_name, component_id, - "%s\n", acpi_gbl_fn_exit_str); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s\n", acpi_gbl_fn_exit_str); acpi_gbl_nesting_level--; } -EXPORT_SYMBOL(acpi_ut_exit); +EXPORT_SYMBOL(acpi_ut_exit); /******************************************************************************* * @@ -460,31 +420,29 @@ EXPORT_SYMBOL(acpi_ut_exit); ******************************************************************************/ void -acpi_ut_status_exit ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - acpi_status status) +acpi_ut_status_exit(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, acpi_status status) { - if (ACPI_SUCCESS (status)) { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, - line_number, function_name, module_name, component_id, - "%s %s\n", acpi_gbl_fn_exit_str, - acpi_format_exception (status)); - } - else { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, - line_number, function_name, module_name, component_id, - "%s ****Exception****: %s\n", acpi_gbl_fn_exit_str, - acpi_format_exception (status)); + if (ACPI_SUCCESS(status)) { + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s %s\n", + acpi_gbl_fn_exit_str, + acpi_format_exception(status)); + } else { + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s ****Exception****: %s\n", + acpi_gbl_fn_exit_str, + acpi_format_exception(status)); } acpi_gbl_nesting_level--; } -EXPORT_SYMBOL(acpi_ut_status_exit); +EXPORT_SYMBOL(acpi_ut_status_exit); /******************************************************************************* * @@ -504,23 +462,20 @@ EXPORT_SYMBOL(acpi_ut_status_exit); ******************************************************************************/ void -acpi_ut_value_exit ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - acpi_integer value) +acpi_ut_value_exit(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, acpi_integer value) { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, - line_number, function_name, module_name, component_id, - "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, - ACPI_FORMAT_UINT64 (value)); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s %8.8X%8.8X\n", + acpi_gbl_fn_exit_str, ACPI_FORMAT_UINT64(value)); acpi_gbl_nesting_level--; } -EXPORT_SYMBOL(acpi_ut_value_exit); +EXPORT_SYMBOL(acpi_ut_value_exit); /******************************************************************************* * @@ -540,24 +495,20 @@ EXPORT_SYMBOL(acpi_ut_value_exit); ******************************************************************************/ void -acpi_ut_ptr_exit ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - u8 *ptr) +acpi_ut_ptr_exit(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, u8 * ptr) { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, - line_number, function_name, module_name, component_id, - "%s %p\n", acpi_gbl_fn_exit_str, ptr); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s %p\n", acpi_gbl_fn_exit_str, ptr); acpi_gbl_nesting_level--; } #endif - /******************************************************************************* * * FUNCTION: acpi_ut_dump_buffer @@ -573,23 +524,17 @@ acpi_ut_ptr_exit ( * ******************************************************************************/ -void -acpi_ut_dump_buffer ( - u8 *buffer, - u32 count, - u32 display, - u32 component_id) +void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id) { - acpi_native_uint i = 0; - acpi_native_uint j; - u32 temp32; - u8 buf_char; - + acpi_native_uint i = 0; + acpi_native_uint j; + u32 temp32; + u8 buf_char; /* Only dump the buffer if tracing is enabled */ if (!((ACPI_LV_TABLES & acpi_dbg_level) && - (component_id & acpi_dbg_layer))) { + (component_id & acpi_dbg_layer))) { return; } @@ -602,7 +547,7 @@ acpi_ut_dump_buffer ( while (i < count) { /* Print current offset */ - acpi_os_printf ("%6.4X: ", (u32) i); + acpi_os_printf("%6.4X: ", (u32) i); /* Print 16 hex chars */ @@ -610,39 +555,36 @@ acpi_ut_dump_buffer ( if (i + j >= count) { /* Dump fill spaces */ - acpi_os_printf ("%*s", ((display * 2) + 1), " "); + acpi_os_printf("%*s", ((display * 2) + 1), " "); j += (acpi_native_uint) display; continue; } switch (display) { - default: /* Default is BYTE display */ + default: /* Default is BYTE display */ - acpi_os_printf ("%02X ", buffer[i + j]); + acpi_os_printf("%02X ", buffer[i + j]); break; - case DB_WORD_DISPLAY: - ACPI_MOVE_16_TO_32 (&temp32, &buffer[i + j]); - acpi_os_printf ("%04X ", temp32); + ACPI_MOVE_16_TO_32(&temp32, &buffer[i + j]); + acpi_os_printf("%04X ", temp32); break; - case DB_DWORD_DISPLAY: - ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]); - acpi_os_printf ("%08X ", temp32); + ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]); + acpi_os_printf("%08X ", temp32); break; - case DB_QWORD_DISPLAY: - ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]); - acpi_os_printf ("%08X", temp32); + ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]); + acpi_os_printf("%08X", temp32); - ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j + 4]); - acpi_os_printf ("%08X ", temp32); + ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j + 4]); + acpi_os_printf("%08X ", temp32); break; } @@ -653,28 +595,26 @@ acpi_ut_dump_buffer ( * Print the ASCII equivalent characters but watch out for the bad * unprintable ones (printable chars are 0x20 through 0x7E) */ - acpi_os_printf (" "); + acpi_os_printf(" "); for (j = 0; j < 16; j++) { if (i + j >= count) { - acpi_os_printf ("\n"); + acpi_os_printf("\n"); return; } buf_char = buffer[i + j]; - if (ACPI_IS_PRINT (buf_char)) { - acpi_os_printf ("%c", buf_char); - } - else { - acpi_os_printf ("."); + if (ACPI_IS_PRINT(buf_char)) { + acpi_os_printf("%c", buf_char); + } else { + acpi_os_printf("."); } } /* Done with that line. */ - acpi_os_printf ("\n"); + acpi_os_printf("\n"); i += 16; } return; } - diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index eeafb32..2bc878f 100644 --- a/drivers/acpi/utilities/utdelete.c +++ b/drivers/acpi/utilities/utdelete.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -49,19 +48,13 @@ #include #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utdelete") +ACPI_MODULE_NAME("utdelete") /* Local prototypes */ +static void acpi_ut_delete_internal_obj(union acpi_operand_object *object); static void -acpi_ut_delete_internal_obj ( - union acpi_operand_object *object); - -static void -acpi_ut_update_ref_count ( - union acpi_operand_object *object, - u32 action); - +acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action); /******************************************************************************* * @@ -76,18 +69,14 @@ acpi_ut_update_ref_count ( * ******************************************************************************/ -static void -acpi_ut_delete_internal_obj ( - union acpi_operand_object *object) +static void acpi_ut_delete_internal_obj(union acpi_operand_object *object) { - void *obj_pointer = NULL; - union acpi_operand_object *handler_desc; - union acpi_operand_object *second_desc; - union acpi_operand_object *next_desc; - - - ACPI_FUNCTION_TRACE_PTR ("ut_delete_internal_obj", object); + void *obj_pointer = NULL; + union acpi_operand_object *handler_desc; + union acpi_operand_object *second_desc; + union acpi_operand_object *next_desc; + ACPI_FUNCTION_TRACE_PTR("ut_delete_internal_obj", object); if (!object) { return_VOID; @@ -97,11 +86,12 @@ acpi_ut_delete_internal_obj ( * Must delete or free any pointers within the object that are not * actual ACPI objects (for example, a raw buffer pointer). */ - switch (ACPI_GET_OBJECT_TYPE (object)) { + switch (ACPI_GET_OBJECT_TYPE(object)) { case ACPI_TYPE_STRING: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n", - object, object->string.pointer)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "**** String %p, ptr %p\n", object, + object->string.pointer)); /* Free the actual string buffer */ @@ -112,11 +102,11 @@ acpi_ut_delete_internal_obj ( } break; - case ACPI_TYPE_BUFFER: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n", - object, object->buffer.pointer)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "**** Buffer %p, ptr %p\n", object, + object->buffer.pointer)); /* Free the actual buffer */ @@ -127,11 +117,11 @@ acpi_ut_delete_internal_obj ( } break; - case ACPI_TYPE_PACKAGE: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n", - object->package.count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + " **** Package of count %X\n", + object->package.count)); /* * Elements of the package are not handled here, they are deleted @@ -143,11 +133,11 @@ acpi_ut_delete_internal_obj ( obj_pointer = object->package.elements; break; - case ACPI_TYPE_DEVICE: if (object->device.gpe_block) { - (void) acpi_ev_delete_gpe_block (object->device.gpe_block); + (void)acpi_ev_delete_gpe_block(object->device. + gpe_block); } /* Walk the handler list for this device */ @@ -155,54 +145,51 @@ acpi_ut_delete_internal_obj ( handler_desc = object->device.handler; while (handler_desc) { next_desc = handler_desc->address_space.next; - acpi_ut_remove_reference (handler_desc); + acpi_ut_remove_reference(handler_desc); handler_desc = next_desc; } break; - case ACPI_TYPE_MUTEX: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "***** Mutex %p, Semaphore %p\n", - object, object->mutex.semaphore)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "***** Mutex %p, Semaphore %p\n", + object, object->mutex.semaphore)); - acpi_ex_unlink_mutex (object); - (void) acpi_os_delete_semaphore (object->mutex.semaphore); + acpi_ex_unlink_mutex(object); + (void)acpi_os_delete_semaphore(object->mutex.semaphore); break; - case ACPI_TYPE_EVENT: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "***** Event %p, Semaphore %p\n", - object, object->event.semaphore)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "***** Event %p, Semaphore %p\n", + object, object->event.semaphore)); - (void) acpi_os_delete_semaphore (object->event.semaphore); + (void)acpi_os_delete_semaphore(object->event.semaphore); object->event.semaphore = NULL; break; - case ACPI_TYPE_METHOD: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "***** Method %p\n", object)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "***** Method %p\n", object)); /* Delete the method semaphore if it exists */ if (object->method.semaphore) { - (void) acpi_os_delete_semaphore (object->method.semaphore); + (void)acpi_os_delete_semaphore(object->method. + semaphore); object->method.semaphore = NULL; } break; - case ACPI_TYPE_REGION: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "***** Region %p\n", object)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "***** Region %p\n", object)); - second_desc = acpi_ns_get_secondary_object (object); + second_desc = acpi_ns_get_secondary_object(object); if (second_desc) { /* * Free the region_context if and only if the handler is one of the @@ -211,32 +198,33 @@ acpi_ut_delete_internal_obj ( */ handler_desc = object->region.handler; if (handler_desc) { - if (handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { - obj_pointer = second_desc->extra.region_context; + if (handler_desc->address_space. + hflags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { + obj_pointer = + second_desc->extra.region_context; } - acpi_ut_remove_reference (handler_desc); + acpi_ut_remove_reference(handler_desc); } /* Now we can free the Extra object */ - acpi_ut_delete_object_desc (second_desc); + acpi_ut_delete_object_desc(second_desc); } break; - case ACPI_TYPE_BUFFER_FIELD: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "***** Buffer Field %p\n", object)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "***** Buffer Field %p\n", object)); - second_desc = acpi_ns_get_secondary_object (object); + second_desc = acpi_ns_get_secondary_object(object); if (second_desc) { - acpi_ut_delete_object_desc (second_desc); + acpi_ut_delete_object_desc(second_desc); } break; - default: break; } @@ -244,21 +232,20 @@ acpi_ut_delete_internal_obj ( /* Free any allocated memory (pointer within the object) found above */ if (obj_pointer) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n", - obj_pointer)); - ACPI_MEM_FREE (obj_pointer); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Deleting Object Subptr %p\n", obj_pointer)); + ACPI_MEM_FREE(obj_pointer); } /* Now the object can be safely deleted */ - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", - object, acpi_ut_get_object_type_name (object))); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", + object, acpi_ut_get_object_type_name(object))); - acpi_ut_delete_object_desc (object); + acpi_ut_delete_object_desc(object); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_delete_internal_object_list @@ -272,29 +259,24 @@ acpi_ut_delete_internal_obj ( * ******************************************************************************/ -void -acpi_ut_delete_internal_object_list ( - union acpi_operand_object **obj_list) +void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list) { - union acpi_operand_object **internal_obj; - - - ACPI_FUNCTION_TRACE ("ut_delete_internal_object_list"); + union acpi_operand_object **internal_obj; + ACPI_FUNCTION_TRACE("ut_delete_internal_object_list"); /* Walk the null-terminated internal list */ for (internal_obj = obj_list; *internal_obj; internal_obj++) { - acpi_ut_remove_reference (*internal_obj); + acpi_ut_remove_reference(*internal_obj); } /* Free the combined parameter pointer list and object array */ - ACPI_MEM_FREE (obj_list); + ACPI_MEM_FREE(obj_list); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_update_ref_count @@ -309,16 +291,12 @@ acpi_ut_delete_internal_object_list ( ******************************************************************************/ static void -acpi_ut_update_ref_count ( - union acpi_operand_object *object, - u32 action) +acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) { - u16 count; - u16 new_count; - - - ACPI_FUNCTION_NAME ("ut_update_ref_count"); + u16 count; + u16 new_count; + ACPI_FUNCTION_NAME("ut_update_ref_count"); if (!object) { return; @@ -338,58 +316,55 @@ acpi_ut_update_ref_count ( new_count++; object->common.reference_count = new_count; - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, [Incremented]\n", - object, new_count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Incremented]\n", + object, new_count)); break; - case REF_DECREMENT: if (count < 1) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, can't decrement! (Set to 0)\n", - object, new_count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, can't decrement! (Set to 0)\n", + object, new_count)); new_count = 0; - } - else { + } else { new_count--; - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, [Decremented]\n", - object, new_count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Decremented]\n", + object, new_count)); } - if (ACPI_GET_OBJECT_TYPE (object) == ACPI_TYPE_METHOD) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Method Obj %p Refs=%X, [Decremented]\n", - object, new_count)); + if (ACPI_GET_OBJECT_TYPE(object) == ACPI_TYPE_METHOD) { + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Method Obj %p Refs=%X, [Decremented]\n", + object, new_count)); } object->common.reference_count = new_count; if (new_count == 0) { - acpi_ut_delete_internal_obj (object); + acpi_ut_delete_internal_obj(object); } break; - case REF_FORCE_DELETE: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, Force delete! (Set to 0)\n", - object, count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, Force delete! (Set to 0)\n", + object, count)); new_count = 0; object->common.reference_count = new_count; - acpi_ut_delete_internal_obj (object); + acpi_ut_delete_internal_obj(object); break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown action (%X)\n", action)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown action (%X)\n", + action)); break; } @@ -399,15 +374,14 @@ acpi_ut_update_ref_count ( */ if (count > ACPI_MAX_REFERENCE_COUNT) { - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, - "**** Warning **** Large Reference Count (%X) in object %p\n\n", - count, object)); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "**** Warning **** Large Reference Count (%X) in object %p\n\n", + count, object)); } return; } - /******************************************************************************* * * FUNCTION: acpi_ut_update_object_reference @@ -431,38 +405,36 @@ acpi_ut_update_ref_count ( ******************************************************************************/ acpi_status -acpi_ut_update_object_reference ( - union acpi_operand_object *object, - u16 action) +acpi_ut_update_object_reference(union acpi_operand_object * object, u16 action) { - acpi_status status = AE_OK; - union acpi_generic_state *state_list = NULL; - union acpi_operand_object *next_object = NULL; - union acpi_generic_state *state; - acpi_native_uint i; - - - ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object); + acpi_status status = AE_OK; + union acpi_generic_state *state_list = NULL; + union acpi_operand_object *next_object = NULL; + union acpi_generic_state *state; + acpi_native_uint i; + ACPI_FUNCTION_TRACE_PTR("ut_update_object_reference", object); while (object) { /* Make sure that this isn't a namespace handle */ - if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Object %p is NS handle\n", object)); - return_ACPI_STATUS (AE_OK); + if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) { + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Object %p is NS handle\n", object)); + return_ACPI_STATUS(AE_OK); } /* * All sub-objects must have their reference count incremented also. * Different object types have different subobjects. */ - switch (ACPI_GET_OBJECT_TYPE (object)) { + switch (ACPI_GET_OBJECT_TYPE(object)) { case ACPI_TYPE_DEVICE: - acpi_ut_update_ref_count (object->device.system_notify, action); - acpi_ut_update_ref_count (object->device.device_notify, action); + acpi_ut_update_ref_count(object->device.system_notify, + action); + acpi_ut_update_ref_count(object->device.device_notify, + action); break; case ACPI_TYPE_PACKAGE: @@ -476,9 +448,11 @@ acpi_ut_update_object_reference ( * Note: There can be null elements within the package, * these are simply ignored */ - status = acpi_ut_create_update_state_and_push ( - object->package.elements[i], action, &state_list); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_create_update_state_and_push + (object->package.elements[i], action, + &state_list); + if (ACPI_FAILURE(status)) { goto error_exit; } } @@ -497,9 +471,13 @@ acpi_ut_update_object_reference ( case ACPI_TYPE_LOCAL_BANK_FIELD: next_object = object->bank_field.bank_obj; - status = acpi_ut_create_update_state_and_push ( - object->bank_field.region_obj, action, &state_list); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_create_update_state_and_push(object-> + bank_field. + region_obj, + action, + &state_list); + if (ACPI_FAILURE(status)) { goto error_exit; } break; @@ -507,9 +485,13 @@ acpi_ut_update_object_reference ( case ACPI_TYPE_LOCAL_INDEX_FIELD: next_object = object->index_field.index_obj; - status = acpi_ut_create_update_state_and_push ( - object->index_field.data_obj, action, &state_list); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_create_update_state_and_push(object-> + index_field. + data_obj, + action, + &state_list); + if (ACPI_FAILURE(status)) { goto error_exit; } break; @@ -526,7 +508,7 @@ acpi_ut_update_object_reference ( case ACPI_TYPE_REGION: default: - break;/* No subobjects */ + break; /* No subobjects */ } /* @@ -534,7 +516,7 @@ acpi_ut_update_object_reference ( * happen after we update the sub-objects in case this causes the * main object to be deleted. */ - acpi_ut_update_ref_count (object, action); + acpi_ut_update_ref_count(object, action); object = NULL; /* Move on to the next object to be updated */ @@ -542,25 +524,23 @@ acpi_ut_update_object_reference ( if (next_object) { object = next_object; next_object = NULL; - } - else if (state_list) { - state = acpi_ut_pop_generic_state (&state_list); + } else if (state_list) { + state = acpi_ut_pop_generic_state(&state_list); object = state->update.object; - acpi_ut_delete_generic_state (state); + acpi_ut_delete_generic_state(state); } } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); -error_exit: + error_exit: - ACPI_REPORT_ERROR (("Could not update object reference count, %s\n", - acpi_format_exception (status))); + ACPI_REPORT_ERROR(("Could not update object reference count, %s\n", + acpi_format_exception(status))); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_add_reference @@ -574,31 +554,27 @@ error_exit: * ******************************************************************************/ -void -acpi_ut_add_reference ( - union acpi_operand_object *object) +void acpi_ut_add_reference(union acpi_operand_object *object) { - ACPI_FUNCTION_TRACE_PTR ("ut_add_reference", object); - + ACPI_FUNCTION_TRACE_PTR("ut_add_reference", object); /* Ensure that we have a valid object */ - if (!acpi_ut_valid_internal_object (object)) { + if (!acpi_ut_valid_internal_object(object)) { return_VOID; } - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Current Refs=%X [To Be Incremented]\n", - object, object->common.reference_count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Incremented]\n", + object, object->common.reference_count)); /* Increment the reference count */ - (void) acpi_ut_update_object_reference (object, REF_INCREMENT); + (void)acpi_ut_update_object_reference(object, REF_INCREMENT); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_remove_reference @@ -611,13 +587,10 @@ acpi_ut_add_reference ( * ******************************************************************************/ -void -acpi_ut_remove_reference ( - union acpi_operand_object *object) +void acpi_ut_remove_reference(union acpi_operand_object *object) { - ACPI_FUNCTION_TRACE_PTR ("ut_remove_reference", object); - + ACPI_FUNCTION_TRACE_PTR("ut_remove_reference", object); /* * Allow a NULL pointer to be passed in, just ignore it. This saves @@ -625,27 +598,25 @@ acpi_ut_remove_reference ( * */ if (!object || - (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED)) { + (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) { return_VOID; } /* Ensure that we have a valid object */ - if (!acpi_ut_valid_internal_object (object)) { + if (!acpi_ut_valid_internal_object(object)) { return_VOID; } - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Current Refs=%X [To Be Decremented]\n", - object, object->common.reference_count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Decremented]\n", + object, object->common.reference_count)); /* * Decrement the reference count, and only actually delete the object * if the reference count becomes 0. (Must also decrement the ref count * of all subobjects!) */ - (void) acpi_ut_update_object_reference (object, REF_DECREMENT); + (void)acpi_ut_update_object_reference(object, REF_DECREMENT); return_VOID; } - - diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c index 00046dd..7b81d5e 100644 --- a/drivers/acpi/utilities/uteval.c +++ b/drivers/acpi/utilities/uteval.c @@ -41,28 +41,20 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include - #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("uteval") +ACPI_MODULE_NAME("uteval") /* Local prototypes */ - static void -acpi_ut_copy_id_string ( - char *destination, - char *source, - acpi_size max_length); +acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length); static acpi_status -acpi_ut_translate_one_cid ( - union acpi_operand_object *obj_desc, - struct acpi_compatible_id *one_cid); - +acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc, + struct acpi_compatible_id *one_cid); /******************************************************************************* * @@ -77,37 +69,33 @@ acpi_ut_translate_one_cid ( * ******************************************************************************/ -acpi_status -acpi_ut_osi_implementation ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) { - union acpi_operand_object *string_desc; - union acpi_operand_object *return_desc; - acpi_native_uint i; - - - ACPI_FUNCTION_TRACE ("ut_osi_implementation"); + union acpi_operand_object *string_desc; + union acpi_operand_object *return_desc; + acpi_native_uint i; + ACPI_FUNCTION_TRACE("ut_osi_implementation"); /* Validate the string input argument */ string_desc = walk_state->arguments[0].object; if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) { - return_ACPI_STATUS (AE_TYPE); + return_ACPI_STATUS(AE_TYPE); } /* Create a return object (Default value = 0) */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Compare input string to table of supported strings */ for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) { - if (!ACPI_STRCMP (string_desc->string.pointer, - (char *) acpi_gbl_valid_osi_strings[i])) { + if (!ACPI_STRCMP(string_desc->string.pointer, + (char *)acpi_gbl_valid_osi_strings[i])) { /* This string is supported */ return_desc->integer.value = 0xFFFFFFFF; @@ -116,10 +104,9 @@ acpi_ut_osi_implementation ( } walk_state->return_desc = return_desc; - return_ACPI_STATUS (AE_CTRL_TERMINATE); + return_ACPI_STATUS(AE_CTRL_TERMINATE); } - /******************************************************************************* * * FUNCTION: acpi_ut_evaluate_object @@ -140,19 +127,16 @@ acpi_ut_osi_implementation ( ******************************************************************************/ acpi_status -acpi_ut_evaluate_object ( - struct acpi_namespace_node *prefix_node, - char *path, - u32 expected_return_btypes, - union acpi_operand_object **return_desc) +acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, + char *path, + u32 expected_return_btypes, + union acpi_operand_object **return_desc) { - struct acpi_parameter_info info; - acpi_status status; - u32 return_btype; - - - ACPI_FUNCTION_TRACE ("ut_evaluate_object"); + struct acpi_parameter_info info; + acpi_status status; + u32 return_btype; + ACPI_FUNCTION_TRACE("ut_evaluate_object"); info.node = prefix_node; info.parameters = NULL; @@ -160,36 +144,38 @@ acpi_ut_evaluate_object ( /* Evaluate the object/method */ - status = acpi_ns_evaluate_relative (path, &info); - if (ACPI_FAILURE (status)) { + status = acpi_ns_evaluate_relative(path, &info); + if (ACPI_FAILURE(status)) { if (status == AE_NOT_FOUND) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n", - acpi_ut_get_node_name (prefix_node), path)); - } - else { - ACPI_REPORT_METHOD_ERROR ("Method execution failed", - prefix_node, path, status); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[%4.4s.%s] was not found\n", + acpi_ut_get_node_name(prefix_node), + path)); + } else { + ACPI_REPORT_METHOD_ERROR("Method execution failed", + prefix_node, path, status); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Did we get a return object? */ if (!info.return_object) { if (expected_return_btypes) { - ACPI_REPORT_METHOD_ERROR ("No object was returned from", - prefix_node, path, AE_NOT_EXIST); + ACPI_REPORT_METHOD_ERROR("No object was returned from", + prefix_node, path, + AE_NOT_EXIST); - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Map the return object type to the bitmapped type */ - switch (ACPI_GET_OBJECT_TYPE (info.return_object)) { + switch (ACPI_GET_OBJECT_TYPE(info.return_object)) { case ACPI_TYPE_INTEGER: return_btype = ACPI_BTYPE_INTEGER; break; @@ -211,41 +197,41 @@ acpi_ut_evaluate_object ( break; } - if ((acpi_gbl_enable_interpreter_slack) && - (!expected_return_btypes)) { + if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) { /* * We received a return object, but one was not expected. This can * happen frequently if the "implicit return" feature is enabled. * Just delete the return object and return AE_OK. */ - acpi_ut_remove_reference (info.return_object); - return_ACPI_STATUS (AE_OK); + acpi_ut_remove_reference(info.return_object); + return_ACPI_STATUS(AE_OK); } /* Is the return object one of the expected types? */ if (!(expected_return_btypes & return_btype)) { - ACPI_REPORT_METHOD_ERROR ("Return object type is incorrect", - prefix_node, path, AE_TYPE); + ACPI_REPORT_METHOD_ERROR("Return object type is incorrect", + prefix_node, path, AE_TYPE); - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Type returned from %s was incorrect: %s, expected Btypes: %X\n", - path, acpi_ut_get_object_type_name (info.return_object), - expected_return_btypes)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Type returned from %s was incorrect: %s, expected Btypes: %X\n", + path, + acpi_ut_get_object_type_name(info. + return_object), + expected_return_btypes)); /* On error exit, we must delete the return object */ - acpi_ut_remove_reference (info.return_object); - return_ACPI_STATUS (AE_TYPE); + acpi_ut_remove_reference(info.return_object); + return_ACPI_STATUS(AE_TYPE); } /* Object type is OK, return it */ *return_desc = info.return_object; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ut_evaluate_numeric_object @@ -264,22 +250,19 @@ acpi_ut_evaluate_object ( ******************************************************************************/ acpi_status -acpi_ut_evaluate_numeric_object ( - char *object_name, - struct acpi_namespace_node *device_node, - acpi_integer *address) +acpi_ut_evaluate_numeric_object(char *object_name, + struct acpi_namespace_node *device_node, + acpi_integer * address) { - union acpi_operand_object *obj_desc; - acpi_status status; - + union acpi_operand_object *obj_desc; + acpi_status status; - ACPI_FUNCTION_TRACE ("ut_evaluate_numeric_object"); + ACPI_FUNCTION_TRACE("ut_evaluate_numeric_object"); - - status = acpi_ut_evaluate_object (device_node, object_name, - ACPI_BTYPE_INTEGER, &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_evaluate_object(device_node, object_name, + ACPI_BTYPE_INTEGER, &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Get the returned Integer */ @@ -288,11 +271,10 @@ acpi_ut_evaluate_numeric_object ( /* On exit, we must delete the return object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_id_string @@ -310,10 +292,7 @@ acpi_ut_evaluate_numeric_object ( ******************************************************************************/ static void -acpi_ut_copy_id_string ( - char *destination, - char *source, - acpi_size max_length) +acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length) { /* @@ -328,10 +307,9 @@ acpi_ut_copy_id_string ( /* Do the actual copy */ - ACPI_STRNCPY (destination, source, max_length); + ACPI_STRNCPY(destination, source, max_length); } - /******************************************************************************* * * FUNCTION: acpi_ut_execute_HID @@ -349,42 +327,39 @@ acpi_ut_copy_id_string ( ******************************************************************************/ acpi_status -acpi_ut_execute_HID ( - struct acpi_namespace_node *device_node, - struct acpi_device_id *hid) +acpi_ut_execute_HID(struct acpi_namespace_node *device_node, + struct acpi_device_id *hid) { - union acpi_operand_object *obj_desc; - acpi_status status; - + union acpi_operand_object *obj_desc; + acpi_status status; - ACPI_FUNCTION_TRACE ("ut_execute_HID"); + ACPI_FUNCTION_TRACE("ut_execute_HID"); - - status = acpi_ut_evaluate_object (device_node, METHOD_NAME__HID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, + &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { /* Convert the Numeric HID to string */ - acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, hid->value); - } - else { + acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value, + hid->value); + } else { /* Copy the String HID from the returned object */ - acpi_ut_copy_id_string (hid->value, obj_desc->string.pointer, - sizeof (hid->value)); + acpi_ut_copy_id_string(hid->value, obj_desc->string.pointer, + sizeof(hid->value)); } /* On exit, we must delete the return object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_translate_one_cid @@ -403,18 +378,17 @@ acpi_ut_execute_HID ( ******************************************************************************/ static acpi_status -acpi_ut_translate_one_cid ( - union acpi_operand_object *obj_desc, - struct acpi_compatible_id *one_cid) +acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc, + struct acpi_compatible_id *one_cid) { - - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_INTEGER: /* Convert the Numeric CID to string */ - acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, one_cid->value); + acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value, + one_cid->value); return (AE_OK); case ACPI_TYPE_STRING: @@ -425,8 +399,8 @@ acpi_ut_translate_one_cid ( /* Copy the String CID from the returned object */ - acpi_ut_copy_id_string (one_cid->value, obj_desc->string.pointer, - ACPI_MAX_CID_LENGTH); + acpi_ut_copy_id_string(one_cid->value, obj_desc->string.pointer, + ACPI_MAX_CID_LENGTH); return (AE_OK); default: @@ -435,7 +409,6 @@ acpi_ut_translate_one_cid ( } } - /******************************************************************************* * * FUNCTION: acpi_ut_execute_CID @@ -453,45 +426,42 @@ acpi_ut_translate_one_cid ( ******************************************************************************/ acpi_status -acpi_ut_execute_CID ( - struct acpi_namespace_node *device_node, - struct acpi_compatible_id_list **return_cid_list) +acpi_ut_execute_CID(struct acpi_namespace_node * device_node, + struct acpi_compatible_id_list ** return_cid_list) { - union acpi_operand_object *obj_desc; - acpi_status status; - u32 count; - u32 size; + union acpi_operand_object *obj_desc; + acpi_status status; + u32 count; + u32 size; struct acpi_compatible_id_list *cid_list; - acpi_native_uint i; - - - ACPI_FUNCTION_TRACE ("ut_execute_CID"); + acpi_native_uint i; + ACPI_FUNCTION_TRACE("ut_execute_CID"); /* Evaluate the _CID method for this device */ - status = acpi_ut_evaluate_object (device_node, METHOD_NAME__CID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, - &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING + | ACPI_BTYPE_PACKAGE, &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Get the number of _CIDs returned */ count = 1; - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { count = obj_desc->package.count; } /* Allocate a worst-case buffer for the _CIDs */ - size = (((count - 1) * sizeof (struct acpi_compatible_id)) + - sizeof (struct acpi_compatible_id_list)); + size = (((count - 1) * sizeof(struct acpi_compatible_id)) + + sizeof(struct acpi_compatible_id_list)); - cid_list = ACPI_MEM_CALLOCATE ((acpi_size) size); + cid_list = ACPI_MEM_CALLOCATE((acpi_size) size); if (!cid_list) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Init CID list */ @@ -508,39 +478,38 @@ acpi_ut_execute_CID ( /* The _CID object can be either a single CID or a package (list) of CIDs */ - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { /* Translate each package element */ for (i = 0; i < count; i++) { - status = acpi_ut_translate_one_cid (obj_desc->package.elements[i], - &cid_list->id[i]); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_translate_one_cid(obj_desc->package. + elements[i], + &cid_list->id[i]); + if (ACPI_FAILURE(status)) { break; } } - } - else { + } else { /* Only one CID, translate to a string */ - status = acpi_ut_translate_one_cid (obj_desc, cid_list->id); + status = acpi_ut_translate_one_cid(obj_desc, cid_list->id); } /* Cleanup on error */ - if (ACPI_FAILURE (status)) { - ACPI_MEM_FREE (cid_list); - } - else { + if (ACPI_FAILURE(status)) { + ACPI_MEM_FREE(cid_list); + } else { *return_cid_list = cid_list; } /* On exit, we must delete the _CID return object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_execute_UID @@ -558,42 +527,39 @@ acpi_ut_execute_CID ( ******************************************************************************/ acpi_status -acpi_ut_execute_UID ( - struct acpi_namespace_node *device_node, - struct acpi_device_id *uid) +acpi_ut_execute_UID(struct acpi_namespace_node *device_node, + struct acpi_device_id *uid) { - union acpi_operand_object *obj_desc; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ut_execute_UID"); + union acpi_operand_object *obj_desc; + acpi_status status; + ACPI_FUNCTION_TRACE("ut_execute_UID"); - status = acpi_ut_evaluate_object (device_node, METHOD_NAME__UID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, + &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { /* Convert the Numeric UID to string */ - acpi_ex_unsigned_integer_to_string (obj_desc->integer.value, uid->value); - } - else { + acpi_ex_unsigned_integer_to_string(obj_desc->integer.value, + uid->value); + } else { /* Copy the String UID from the returned object */ - acpi_ut_copy_id_string (uid->value, obj_desc->string.pointer, - sizeof (uid->value)); + acpi_ut_copy_id_string(uid->value, obj_desc->string.pointer, + sizeof(uid->value)); } /* On exit, we must delete the return object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_execute_STA @@ -611,30 +577,26 @@ acpi_ut_execute_UID ( ******************************************************************************/ acpi_status -acpi_ut_execute_STA ( - struct acpi_namespace_node *device_node, - u32 *flags) +acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags) { - union acpi_operand_object *obj_desc; - acpi_status status; - + union acpi_operand_object *obj_desc; + acpi_status status; - ACPI_FUNCTION_TRACE ("ut_execute_STA"); + ACPI_FUNCTION_TRACE("ut_execute_STA"); - - status = acpi_ut_evaluate_object (device_node, METHOD_NAME__STA, - ACPI_BTYPE_INTEGER, &obj_desc); - if (ACPI_FAILURE (status)) { + status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA, + ACPI_BTYPE_INTEGER, &obj_desc); + if (ACPI_FAILURE(status)) { if (AE_NOT_FOUND == status) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "_STA on %4.4s was not found, assuming device is present\n", - acpi_ut_get_node_name (device_node))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "_STA on %4.4s was not found, assuming device is present\n", + acpi_ut_get_node_name(device_node))); *flags = 0x0F; status = AE_OK; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Extract the status flags */ @@ -643,11 +605,10 @@ acpi_ut_execute_STA ( /* On exit, we must delete the return object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_execute_Sxds @@ -665,44 +626,45 @@ acpi_ut_execute_STA ( ******************************************************************************/ acpi_status -acpi_ut_execute_sxds ( - struct acpi_namespace_node *device_node, - u8 *highest) +acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest) { - union acpi_operand_object *obj_desc; - acpi_status status; - u32 i; - - - ACPI_FUNCTION_TRACE ("ut_execute_Sxds"); + union acpi_operand_object *obj_desc; + acpi_status status; + u32 i; + ACPI_FUNCTION_TRACE("ut_execute_Sxds"); for (i = 0; i < 4; i++) { highest[i] = 0xFF; - status = acpi_ut_evaluate_object (device_node, - (char *) acpi_gbl_highest_dstate_names[i], - ACPI_BTYPE_INTEGER, &obj_desc); - if (ACPI_FAILURE (status)) { + status = acpi_ut_evaluate_object(device_node, + (char *) + acpi_gbl_highest_dstate_names + [i], ACPI_BTYPE_INTEGER, + &obj_desc); + if (ACPI_FAILURE(status)) { if (status != AE_NOT_FOUND) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "%s on Device %4.4s, %s\n", - (char *) acpi_gbl_highest_dstate_names[i], - acpi_ut_get_node_name (device_node), - acpi_format_exception (status))); - - return_ACPI_STATUS (status); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "%s on Device %4.4s, %s\n", + (char *) + acpi_gbl_highest_dstate_names + [i], + acpi_ut_get_node_name + (device_node), + acpi_format_exception + (status))); + + return_ACPI_STATUS(status); } - } - else { + } else { /* Extract the Dstate value */ highest[i] = (u8) obj_desc->integer.value; /* Delete the return object */ - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); } } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 0e4161c..399e64b 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -48,8 +48,7 @@ #include #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utglobal") - +ACPI_MODULE_NAME("utglobal") /******************************************************************************* * @@ -63,17 +62,12 @@ * DESCRIPTION: This function translates an ACPI exception into an ASCII string. * ******************************************************************************/ - -const char * -acpi_format_exception ( - acpi_status status) +const char *acpi_format_exception(acpi_status status) { - acpi_status sub_status; - const char *exception = NULL; - - - ACPI_FUNCTION_NAME ("format_exception"); + acpi_status sub_status; + const char *exception = NULL; + ACPI_FUNCTION_NAME("format_exception"); sub_status = (status & ~AE_CODE_MASK); @@ -81,35 +75,39 @@ acpi_format_exception ( case AE_CODE_ENVIRONMENTAL: if (sub_status <= AE_CODE_ENV_MAX) { - exception = acpi_gbl_exception_names_env [sub_status]; + exception = acpi_gbl_exception_names_env[sub_status]; } break; case AE_CODE_PROGRAMMER: if (sub_status <= AE_CODE_PGM_MAX) { - exception = acpi_gbl_exception_names_pgm [sub_status -1]; + exception = + acpi_gbl_exception_names_pgm[sub_status - 1]; } break; case AE_CODE_ACPI_TABLES: if (sub_status <= AE_CODE_TBL_MAX) { - exception = acpi_gbl_exception_names_tbl [sub_status -1]; + exception = + acpi_gbl_exception_names_tbl[sub_status - 1]; } break; case AE_CODE_AML: if (sub_status <= AE_CODE_AML_MAX) { - exception = acpi_gbl_exception_names_aml [sub_status -1]; + exception = + acpi_gbl_exception_names_aml[sub_status - 1]; } break; case AE_CODE_CONTROL: if (sub_status <= AE_CODE_CTRL_MAX) { - exception = acpi_gbl_exception_names_ctrl [sub_status -1]; + exception = + acpi_gbl_exception_names_ctrl[sub_status - 1]; } break; @@ -120,16 +118,15 @@ acpi_format_exception ( if (!exception) { /* Exception code was not recognized */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown exception code: 0x%8.8X\n", status)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown exception code: 0x%8.8X\n", status)); - return ((const char *) "UNKNOWN_STATUS_CODE"); + return ((const char *)"UNKNOWN_STATUS_CODE"); } - return ((const char *) exception); + return ((const char *)exception); } - /******************************************************************************* * * Static global variable initialization. @@ -142,34 +139,32 @@ acpi_format_exception ( */ /* Debug switch - level and trace mask */ -u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT; +u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT; EXPORT_SYMBOL(acpi_dbg_level); /* Debug switch - layer (component) mask */ -u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; +u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; EXPORT_SYMBOL(acpi_dbg_layer); -u32 acpi_gbl_nesting_level = 0; - +u32 acpi_gbl_nesting_level = 0; /* Debugger globals */ -u8 acpi_gbl_db_terminate_threads = FALSE; -u8 acpi_gbl_abort_method = FALSE; -u8 acpi_gbl_method_executing = FALSE; +u8 acpi_gbl_db_terminate_threads = FALSE; +u8 acpi_gbl_abort_method = FALSE; +u8 acpi_gbl_method_executing = FALSE; /* System flags */ -u32 acpi_gbl_startup_flags = 0; +u32 acpi_gbl_startup_flags = 0; /* System starts uninitialized */ -u8 acpi_gbl_shutdown = TRUE; +u8 acpi_gbl_shutdown = TRUE; -const u8 acpi_gbl_decode_to8bit [8] = {1,2,4,8,16,32,64,128}; +const u8 acpi_gbl_decode_to8bit[8] = { 1, 2, 4, 8, 16, 32, 64, 128 }; -const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = -{ +const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = { "\\_S0_", "\\_S1_", "\\_S2_", @@ -178,8 +173,7 @@ const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COU "\\_S5_" }; -const char *acpi_gbl_highest_dstate_names[4] = -{ +const char *acpi_gbl_highest_dstate_names[4] = { "_S1D", "_S2D", "_S3D", @@ -190,8 +184,7 @@ const char *acpi_gbl_highest_dstate_names[4] = * Strings supported by the _OSI predefined (internal) method. * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS. */ -const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = -{ +const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = { /* Operating System Vendor Strings */ "Linux", @@ -209,7 +202,6 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STR "Extended Address Space Descriptor" }; - /******************************************************************************* * * Namespace globals @@ -225,74 +217,70 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STR * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to * perform a Notify() operation on it. */ -const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = -{ {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_SB_", ACPI_TYPE_DEVICE, NULL}, - {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_TZ_", ACPI_TYPE_THERMAL, NULL}, - {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, - {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, - {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, +const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = + { {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, +{"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, +{"_SB_", ACPI_TYPE_DEVICE, NULL}, +{"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, +{"_TZ_", ACPI_TYPE_THERMAL, NULL}, +{"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL}, +{"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, +{"_GL_", ACPI_TYPE_MUTEX, (char *)1}, #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) - {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, +{"_OSI", ACPI_TYPE_METHOD, (char *)1}, #endif /* Table terminator */ - {NULL, ACPI_TYPE_ANY, NULL} +{NULL, ACPI_TYPE_ANY, NULL} }; /* * Properties of the ACPI Object Types, both internal and external. * The table is indexed by values of acpi_object_type */ -const u8 acpi_gbl_ns_properties[] = -{ - ACPI_NS_NORMAL, /* 00 Any */ - ACPI_NS_NORMAL, /* 01 Number */ - ACPI_NS_NORMAL, /* 02 String */ - ACPI_NS_NORMAL, /* 03 Buffer */ - ACPI_NS_NORMAL, /* 04 Package */ - ACPI_NS_NORMAL, /* 05 field_unit */ - ACPI_NS_NEWSCOPE, /* 06 Device */ - ACPI_NS_NORMAL, /* 07 Event */ - ACPI_NS_NEWSCOPE, /* 08 Method */ - ACPI_NS_NORMAL, /* 09 Mutex */ - ACPI_NS_NORMAL, /* 10 Region */ - ACPI_NS_NEWSCOPE, /* 11 Power */ - ACPI_NS_NEWSCOPE, /* 12 Processor */ - ACPI_NS_NEWSCOPE, /* 13 Thermal */ - ACPI_NS_NORMAL, /* 14 buffer_field */ - ACPI_NS_NORMAL, /* 15 ddb_handle */ - ACPI_NS_NORMAL, /* 16 Debug Object */ - ACPI_NS_NORMAL, /* 17 def_field */ - ACPI_NS_NORMAL, /* 18 bank_field */ - ACPI_NS_NORMAL, /* 19 index_field */ - ACPI_NS_NORMAL, /* 20 Reference */ - ACPI_NS_NORMAL, /* 21 Alias */ - ACPI_NS_NORMAL, /* 22 method_alias */ - ACPI_NS_NORMAL, /* 23 Notify */ - ACPI_NS_NORMAL, /* 24 Address Handler */ - ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ - ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ - ACPI_NS_NEWSCOPE, /* 27 Scope */ - ACPI_NS_NORMAL, /* 28 Extra */ - ACPI_NS_NORMAL, /* 29 Data */ - ACPI_NS_NORMAL /* 30 Invalid */ +const u8 acpi_gbl_ns_properties[] = { + ACPI_NS_NORMAL, /* 00 Any */ + ACPI_NS_NORMAL, /* 01 Number */ + ACPI_NS_NORMAL, /* 02 String */ + ACPI_NS_NORMAL, /* 03 Buffer */ + ACPI_NS_NORMAL, /* 04 Package */ + ACPI_NS_NORMAL, /* 05 field_unit */ + ACPI_NS_NEWSCOPE, /* 06 Device */ + ACPI_NS_NORMAL, /* 07 Event */ + ACPI_NS_NEWSCOPE, /* 08 Method */ + ACPI_NS_NORMAL, /* 09 Mutex */ + ACPI_NS_NORMAL, /* 10 Region */ + ACPI_NS_NEWSCOPE, /* 11 Power */ + ACPI_NS_NEWSCOPE, /* 12 Processor */ + ACPI_NS_NEWSCOPE, /* 13 Thermal */ + ACPI_NS_NORMAL, /* 14 buffer_field */ + ACPI_NS_NORMAL, /* 15 ddb_handle */ + ACPI_NS_NORMAL, /* 16 Debug Object */ + ACPI_NS_NORMAL, /* 17 def_field */ + ACPI_NS_NORMAL, /* 18 bank_field */ + ACPI_NS_NORMAL, /* 19 index_field */ + ACPI_NS_NORMAL, /* 20 Reference */ + ACPI_NS_NORMAL, /* 21 Alias */ + ACPI_NS_NORMAL, /* 22 method_alias */ + ACPI_NS_NORMAL, /* 23 Notify */ + ACPI_NS_NORMAL, /* 24 Address Handler */ + ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ + ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ + ACPI_NS_NEWSCOPE, /* 27 Scope */ + ACPI_NS_NORMAL, /* 28 Extra */ + ACPI_NS_NORMAL, /* 29 Data */ + ACPI_NS_NORMAL /* 30 Invalid */ }; - /* Hex to ASCII conversion table */ -static const char acpi_gbl_hex_to_ascii[] = -{ - '0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F' +static const char acpi_gbl_hex_to_ascii[] = { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - /******************************************************************************* * * FUNCTION: acpi_ut_hex_to_ascii_char @@ -307,16 +295,12 @@ static const char acpi_gbl_hex_to_ascii[] = * ******************************************************************************/ -char -acpi_ut_hex_to_ascii_char ( - acpi_integer integer, - u32 position) +char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position) { return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]); } - /******************************************************************************* * * Table name globals @@ -330,67 +314,139 @@ acpi_ut_hex_to_ascii_char ( * ******************************************************************************/ -struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES]; +struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES]; -struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] = -{ +struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] = { /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */ - /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, - /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *) &acpi_gbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE}, - /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *) &acpi_gbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}, - /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *) &acpi_gbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE}, - /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, - /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, - /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, + /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof(RSDP_SIG) - 1, + ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE} + , + /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *)&acpi_gbl_DSDT, + sizeof(DSDT_SIG) - 1, + ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE | + ACPI_TABLE_EXECUTABLE} + , + /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *)&acpi_gbl_FADT, + sizeof(FADT_SIG) - 1, + ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE} + , + /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *)&acpi_gbl_FACS, + sizeof(FACS_SIG) - 1, + ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE} + , + /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof(PSDT_SIG) - 1, + ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | + ACPI_TABLE_EXECUTABLE} + , + /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof(SSDT_SIG) - 1, + ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | + ACPI_TABLE_EXECUTABLE} + , + /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof(RSDT_SIG) - 1, + ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE} + , }; - /****************************************************************************** * * Event and Hardware globals * ******************************************************************************/ -struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = -{ +struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = { /* Name Parent Register Register Bit Position Register Bit Mask */ - /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, - /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, - /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, - /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, - /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, - /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, - /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, - /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, - - /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, - /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, - /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, - /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, - /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, - /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, - /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, - - /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, - /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, - /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, - /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, - /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, - /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, - - /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} + /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_TIMER_STATUS, + ACPI_BITMASK_TIMER_STATUS}, + /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_BUS_MASTER_STATUS, + ACPI_BITMASK_BUS_MASTER_STATUS}, + /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, + ACPI_BITMASK_GLOBAL_LOCK_STATUS}, + /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_POWER_BUTTON_STATUS, + ACPI_BITMASK_POWER_BUTTON_STATUS}, + /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, + ACPI_BITMASK_SLEEP_BUTTON_STATUS}, + /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_RT_CLOCK_STATUS, + ACPI_BITMASK_RT_CLOCK_STATUS}, + /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_WAKE_STATUS, + ACPI_BITMASK_WAKE_STATUS}, + /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, + ACPI_BITMASK_PCIEXP_WAKE_STATUS}, + + /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, + ACPI_BITPOSITION_TIMER_ENABLE, + ACPI_BITMASK_TIMER_ENABLE}, + /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, + ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, + ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, + /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, + ACPI_BITPOSITION_POWER_BUTTON_ENABLE, + ACPI_BITMASK_POWER_BUTTON_ENABLE}, + /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, + ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, + ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, + /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, + ACPI_BITPOSITION_RT_CLOCK_ENABLE, + ACPI_BITMASK_RT_CLOCK_ENABLE}, + /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, + /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, + ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, + ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, + + /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_SCI_ENABLE, + ACPI_BITMASK_SCI_ENABLE}, + /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_BUS_MASTER_RLD, + ACPI_BITMASK_BUS_MASTER_RLD}, + /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, + ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, + /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_SLEEP_TYPE_X, + ACPI_BITMASK_SLEEP_TYPE_X}, + /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_SLEEP_TYPE_X, + ACPI_BITMASK_SLEEP_TYPE_X}, + /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_SLEEP_ENABLE, + ACPI_BITMASK_SLEEP_ENABLE}, + + /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, + ACPI_BITPOSITION_ARB_DISABLE, + ACPI_BITMASK_ARB_DISABLE} }; - -struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = -{ - /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, - /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, - /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, - /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, - /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, +struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = { + /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, + ACPI_BITREG_TIMER_ENABLE, + ACPI_BITMASK_TIMER_STATUS, + ACPI_BITMASK_TIMER_ENABLE}, + /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, + ACPI_BITREG_GLOBAL_LOCK_ENABLE, + ACPI_BITMASK_GLOBAL_LOCK_STATUS, + ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, + /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, + ACPI_BITREG_POWER_BUTTON_ENABLE, + ACPI_BITMASK_POWER_BUTTON_STATUS, + ACPI_BITMASK_POWER_BUTTON_ENABLE}, + /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, + ACPI_BITREG_SLEEP_BUTTON_ENABLE, + ACPI_BITMASK_SLEEP_BUTTON_STATUS, + ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, + /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, + ACPI_BITREG_RT_CLOCK_ENABLE, + ACPI_BITMASK_RT_CLOCK_STATUS, + ACPI_BITMASK_RT_CLOCK_ENABLE}, }; /******************************************************************************* @@ -407,8 +463,7 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVE /* Region type decoding */ -const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = -{ +const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = { /*! [Begin] no source code translation (keep these ASL Keywords as-is) */ "SystemMemory", "SystemIO", @@ -421,25 +476,18 @@ const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = /*! [End] no source code translation !*/ }; - -char * -acpi_ut_get_region_name ( - u8 space_id) +char *acpi_ut_get_region_name(u8 space_id) { - if (space_id >= ACPI_USER_REGION_BEGIN) - { + if (space_id >= ACPI_USER_REGION_BEGIN) { return ("user_defined_region"); - } - else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) - { + } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) { return ("invalid_space_id"); } - return ((char *) acpi_gbl_region_types[space_id]); + return ((char *)acpi_gbl_region_types[space_id]); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_event_name @@ -454,8 +502,7 @@ acpi_ut_get_region_name ( /* Event type decoding */ -static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = -{ +static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = { "PM_Timer", "global_lock", "power_button", @@ -463,21 +510,16 @@ static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = "real_time_clock", }; - -char * -acpi_ut_get_event_name ( - u32 event_id) +char *acpi_ut_get_event_name(u32 event_id) { - if (event_id > ACPI_EVENT_MAX) - { + if (event_id > ACPI_EVENT_MAX) { return ("invalid_event_iD"); } - return ((char *) acpi_gbl_event_types[event_id]); + return ((char *)acpi_gbl_event_types[event_id]); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_type_name @@ -498,12 +540,11 @@ acpi_ut_get_event_name ( * when stored in a table it really means that we have thus far seen no * evidence to indicate what type is actually going to be stored for this entry. */ -static const char acpi_gbl_bad_type[] = "UNDEFINED"; +static const char acpi_gbl_bad_type[] = "UNDEFINED"; /* Printable names of the ACPI object types */ -static const char *acpi_gbl_ns_type_names[] = -{ +static const char *acpi_gbl_ns_type_names[] = { /* 00 */ "Untyped", /* 01 */ "Integer", /* 02 */ "String", @@ -537,35 +578,26 @@ static const char *acpi_gbl_ns_type_names[] = /* 30 */ "Invalid" }; - -char * -acpi_ut_get_type_name ( - acpi_object_type type) +char *acpi_ut_get_type_name(acpi_object_type type) { - if (type > ACPI_TYPE_INVALID) - { - return ((char *) acpi_gbl_bad_type); + if (type > ACPI_TYPE_INVALID) { + return ((char *)acpi_gbl_bad_type); } - return ((char *) acpi_gbl_ns_type_names[type]); + return ((char *)acpi_gbl_ns_type_names[type]); } - -char * -acpi_ut_get_object_type_name ( - union acpi_operand_object *obj_desc) +char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc) { - if (!obj_desc) - { + if (!obj_desc) { return ("[NULL Object Descriptor]"); } - return (acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc))); + return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc))); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_node_name @@ -578,39 +610,31 @@ acpi_ut_get_object_type_name ( * ******************************************************************************/ -char * -acpi_ut_get_node_name ( - void *object) +char *acpi_ut_get_node_name(void *object) { - struct acpi_namespace_node *node = (struct acpi_namespace_node *) object; - + struct acpi_namespace_node *node = (struct acpi_namespace_node *)object; /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ - if (!object) - { + if (!object) { return ("NULL"); } /* Check for Root node */ - if ((object == ACPI_ROOT_OBJECT) || - (object == acpi_gbl_root_node)) - { + if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) { return ("\"\\\" "); } /* Descriptor must be a namespace node */ - if (node->descriptor != ACPI_DESC_TYPE_NAMED) - { + if (node->descriptor != ACPI_DESC_TYPE_NAMED) { return ("####"); } /* Name must be a valid ACPI name */ - if (!acpi_ut_valid_acpi_name (* (u32 *) node->name.ascii)) - { + if (!acpi_ut_valid_acpi_name(*(u32 *) node->name.ascii)) { return ("????"); } @@ -619,7 +643,6 @@ acpi_ut_get_node_name ( return (node->name.ascii); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_descriptor_name @@ -634,8 +657,7 @@ acpi_ut_get_node_name ( /* Printable names of object descriptor types */ -static const char *acpi_gbl_desc_type_names[] = -{ +static const char *acpi_gbl_desc_type_names[] = { /* 00 */ "Invalid", /* 01 */ "Cached", /* 02 */ "State-Generic", @@ -654,27 +676,22 @@ static const char *acpi_gbl_desc_type_names[] = /* 15 */ "Node" }; - -char * -acpi_ut_get_descriptor_name ( - void *object) +char *acpi_ut_get_descriptor_name(void *object) { - if (!object) - { + if (!object) { return ("NULL OBJECT"); } - if (ACPI_GET_DESCRIPTOR_TYPE (object) > ACPI_DESC_TYPE_MAX) - { - return ((char *) acpi_gbl_bad_type); + if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) { + return ((char *)acpi_gbl_bad_type); } - return ((char *) acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE (object)]); + return ((char *) + acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE(object)]); } - #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /* * Strings and procedures used for debug only @@ -693,13 +710,10 @@ acpi_ut_get_descriptor_name ( * ******************************************************************************/ -char * -acpi_ut_get_mutex_name ( - u32 mutex_id) +char *acpi_ut_get_mutex_name(u32 mutex_id) { - if (mutex_id > MAX_MUTEX) - { + if (mutex_id > MAX_MUTEX) { return ("Invalid Mutex ID"); } @@ -707,7 +721,6 @@ acpi_ut_get_mutex_name ( } #endif - /******************************************************************************* * * FUNCTION: acpi_ut_valid_object_type @@ -720,13 +733,10 @@ acpi_ut_get_mutex_name ( * ******************************************************************************/ -u8 -acpi_ut_valid_object_type ( - acpi_object_type type) +u8 acpi_ut_valid_object_type(acpi_object_type type) { - if (type > ACPI_TYPE_LOCAL_MAX) - { + if (type > ACPI_TYPE_LOCAL_MAX) { /* Note: Assumes all TYPEs are contiguous (external/local) */ return (FALSE); @@ -735,7 +745,6 @@ acpi_ut_valid_object_type ( return (TRUE); } - /******************************************************************************* * * FUNCTION: acpi_ut_init_globals @@ -749,106 +758,96 @@ acpi_ut_valid_object_type ( * ******************************************************************************/ -void -acpi_ut_init_globals ( - void) +void acpi_ut_init_globals(void) { - acpi_status status; - u32 i; - - - ACPI_FUNCTION_TRACE ("ut_init_globals"); + acpi_status status; + u32 i; + ACPI_FUNCTION_TRACE("ut_init_globals"); /* Create all memory caches */ - status = acpi_ut_create_caches (); - if (ACPI_FAILURE (status)) - { + status = acpi_ut_create_caches(); + if (ACPI_FAILURE(status)) { return; } /* ACPI table structure */ - for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) - { - acpi_gbl_table_lists[i].next = NULL; - acpi_gbl_table_lists[i].count = 0; + for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) { + acpi_gbl_table_lists[i].next = NULL; + acpi_gbl_table_lists[i].count = 0; } /* Mutex locked flags */ - for (i = 0; i < NUM_MUTEX; i++) - { - acpi_gbl_mutex_info[i].mutex = NULL; - acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED; - acpi_gbl_mutex_info[i].use_count = 0; + for (i = 0; i < NUM_MUTEX; i++) { + acpi_gbl_mutex_info[i].mutex = NULL; + acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED; + acpi_gbl_mutex_info[i].use_count = 0; } /* GPE support */ - acpi_gbl_gpe_xrupt_list_head = NULL; - acpi_gbl_gpe_fadt_blocks[0] = NULL; - acpi_gbl_gpe_fadt_blocks[1] = NULL; + acpi_gbl_gpe_xrupt_list_head = NULL; + acpi_gbl_gpe_fadt_blocks[0] = NULL; + acpi_gbl_gpe_fadt_blocks[1] = NULL; /* Global notify handlers */ - acpi_gbl_system_notify.handler = NULL; - acpi_gbl_device_notify.handler = NULL; - acpi_gbl_exception_handler = NULL; - acpi_gbl_init_handler = NULL; + acpi_gbl_system_notify.handler = NULL; + acpi_gbl_device_notify.handler = NULL; + acpi_gbl_exception_handler = NULL; + acpi_gbl_init_handler = NULL; /* Global "typed" ACPI table pointers */ - acpi_gbl_RSDP = NULL; - acpi_gbl_XSDT = NULL; - acpi_gbl_FACS = NULL; - acpi_gbl_FADT = NULL; - acpi_gbl_DSDT = NULL; + acpi_gbl_RSDP = NULL; + acpi_gbl_XSDT = NULL; + acpi_gbl_FACS = NULL; + acpi_gbl_FADT = NULL; + acpi_gbl_DSDT = NULL; /* Global Lock support */ - acpi_gbl_global_lock_acquired = FALSE; - acpi_gbl_global_lock_thread_count = 0; - acpi_gbl_global_lock_handle = 0; + acpi_gbl_global_lock_acquired = FALSE; + acpi_gbl_global_lock_thread_count = 0; + acpi_gbl_global_lock_handle = 0; /* Miscellaneous variables */ - acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER; - acpi_gbl_rsdp_original_location = 0; - acpi_gbl_cm_single_step = FALSE; - acpi_gbl_db_terminate_threads = FALSE; - acpi_gbl_shutdown = FALSE; - acpi_gbl_ns_lookup_count = 0; - acpi_gbl_ps_find_count = 0; - acpi_gbl_acpi_hardware_present = TRUE; - acpi_gbl_owner_id_mask = 0; - acpi_gbl_debugger_configuration = DEBUGGER_THREADING; - acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; + acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER; + acpi_gbl_rsdp_original_location = 0; + acpi_gbl_cm_single_step = FALSE; + acpi_gbl_db_terminate_threads = FALSE; + acpi_gbl_shutdown = FALSE; + acpi_gbl_ns_lookup_count = 0; + acpi_gbl_ps_find_count = 0; + acpi_gbl_acpi_hardware_present = TRUE; + acpi_gbl_owner_id_mask = 0; + acpi_gbl_debugger_configuration = DEBUGGER_THREADING; + acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; /* Hardware oriented */ - acpi_gbl_events_initialized = FALSE; - acpi_gbl_system_awake_and_running = TRUE; + acpi_gbl_events_initialized = FALSE; + acpi_gbl_system_awake_and_running = TRUE; /* Namespace */ - acpi_gbl_root_node = NULL; + acpi_gbl_root_node = NULL; acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED; - acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; - acpi_gbl_root_node_struct.child = NULL; - acpi_gbl_root_node_struct.peer = NULL; - acpi_gbl_root_node_struct.object = NULL; - acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST; - + acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; + acpi_gbl_root_node_struct.child = NULL; + acpi_gbl_root_node_struct.peer = NULL; + acpi_gbl_root_node_struct.object = NULL; + acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST; #ifdef ACPI_DEBUG_OUTPUT - acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX; + acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX; #endif return_VOID; } - - diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c index fd7ceba..9dde82b 100644 --- a/drivers/acpi/utilities/utinit.c +++ b/drivers/acpi/utilities/utinit.c @@ -41,25 +41,18 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utinit") +ACPI_MODULE_NAME("utinit") /* Local prototypes */ - static void -acpi_ut_fadt_register_error ( - char *register_name, - u32 value, - acpi_size offset); - -static void acpi_ut_terminate ( - void); +acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset); +static void acpi_ut_terminate(void); /******************************************************************************* * @@ -76,18 +69,14 @@ static void acpi_ut_terminate ( ******************************************************************************/ static void -acpi_ut_fadt_register_error ( - char *register_name, - u32 value, - acpi_size offset) +acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset) { - ACPI_REPORT_WARNING ( - ("Invalid FADT value %s=%X at offset %X FADT=%p\n", - register_name, value, (u32) offset, acpi_gbl_FADT)); + ACPI_REPORT_WARNING(("Invalid FADT value %s=%X at offset %X FADT=%p\n", + register_name, value, (u32) offset, + acpi_gbl_FADT)); } - /****************************************************************************** * * FUNCTION: acpi_ut_validate_fadt @@ -100,9 +89,7 @@ acpi_ut_fadt_register_error ( * ******************************************************************************/ -acpi_status -acpi_ut_validate_fadt ( - void) +acpi_status acpi_ut_validate_fadt(void) { /* @@ -110,64 +97,66 @@ acpi_ut_validate_fadt ( * but don't abort on any problems, just display error */ if (acpi_gbl_FADT->pm1_evt_len < 4) { - acpi_ut_fadt_register_error ("PM1_EVT_LEN", - (u32) acpi_gbl_FADT->pm1_evt_len, - ACPI_FADT_OFFSET (pm1_evt_len)); + acpi_ut_fadt_register_error("PM1_EVT_LEN", + (u32) acpi_gbl_FADT->pm1_evt_len, + ACPI_FADT_OFFSET(pm1_evt_len)); } if (!acpi_gbl_FADT->pm1_cnt_len) { - acpi_ut_fadt_register_error ("PM1_CNT_LEN", 0, - ACPI_FADT_OFFSET (pm1_cnt_len)); + acpi_ut_fadt_register_error("PM1_CNT_LEN", 0, + ACPI_FADT_OFFSET(pm1_cnt_len)); } if (!acpi_gbl_FADT->xpm1a_evt_blk.address) { - acpi_ut_fadt_register_error ("X_PM1a_EVT_BLK", 0, - ACPI_FADT_OFFSET (xpm1a_evt_blk.address)); + acpi_ut_fadt_register_error("X_PM1a_EVT_BLK", 0, + ACPI_FADT_OFFSET(xpm1a_evt_blk. + address)); } if (!acpi_gbl_FADT->xpm1a_cnt_blk.address) { - acpi_ut_fadt_register_error ("X_PM1a_CNT_BLK", 0, - ACPI_FADT_OFFSET (xpm1a_cnt_blk.address)); + acpi_ut_fadt_register_error("X_PM1a_CNT_BLK", 0, + ACPI_FADT_OFFSET(xpm1a_cnt_blk. + address)); } if (!acpi_gbl_FADT->xpm_tmr_blk.address) { - acpi_ut_fadt_register_error ("X_PM_TMR_BLK", 0, - ACPI_FADT_OFFSET (xpm_tmr_blk.address)); + acpi_ut_fadt_register_error("X_PM_TMR_BLK", 0, + ACPI_FADT_OFFSET(xpm_tmr_blk. + address)); } if ((acpi_gbl_FADT->xpm2_cnt_blk.address && - !acpi_gbl_FADT->pm2_cnt_len)) { - acpi_ut_fadt_register_error ("PM2_CNT_LEN", - (u32) acpi_gbl_FADT->pm2_cnt_len, - ACPI_FADT_OFFSET (pm2_cnt_len)); + !acpi_gbl_FADT->pm2_cnt_len)) { + acpi_ut_fadt_register_error("PM2_CNT_LEN", + (u32) acpi_gbl_FADT->pm2_cnt_len, + ACPI_FADT_OFFSET(pm2_cnt_len)); } if (acpi_gbl_FADT->pm_tm_len < 4) { - acpi_ut_fadt_register_error ("PM_TM_LEN", - (u32) acpi_gbl_FADT->pm_tm_len, - ACPI_FADT_OFFSET (pm_tm_len)); + acpi_ut_fadt_register_error("PM_TM_LEN", + (u32) acpi_gbl_FADT->pm_tm_len, + ACPI_FADT_OFFSET(pm_tm_len)); } /* Length of GPE blocks must be a multiple of 2 */ if (acpi_gbl_FADT->xgpe0_blk.address && - (acpi_gbl_FADT->gpe0_blk_len & 1)) { - acpi_ut_fadt_register_error ("(x)GPE0_BLK_LEN", - (u32) acpi_gbl_FADT->gpe0_blk_len, - ACPI_FADT_OFFSET (gpe0_blk_len)); + (acpi_gbl_FADT->gpe0_blk_len & 1)) { + acpi_ut_fadt_register_error("(x)GPE0_BLK_LEN", + (u32) acpi_gbl_FADT->gpe0_blk_len, + ACPI_FADT_OFFSET(gpe0_blk_len)); } if (acpi_gbl_FADT->xgpe1_blk.address && - (acpi_gbl_FADT->gpe1_blk_len & 1)) { - acpi_ut_fadt_register_error ("(x)GPE1_BLK_LEN", - (u32) acpi_gbl_FADT->gpe1_blk_len, - ACPI_FADT_OFFSET (gpe1_blk_len)); + (acpi_gbl_FADT->gpe1_blk_len & 1)) { + acpi_ut_fadt_register_error("(x)GPE1_BLK_LEN", + (u32) acpi_gbl_FADT->gpe1_blk_len, + ACPI_FADT_OFFSET(gpe1_blk_len)); } return (AE_OK); } - /****************************************************************************** * * FUNCTION: acpi_ut_terminate @@ -180,18 +169,14 @@ acpi_ut_validate_fadt ( * ******************************************************************************/ -static void -acpi_ut_terminate ( - void) +static void acpi_ut_terminate(void) { - struct acpi_gpe_block_info *gpe_block; - struct acpi_gpe_block_info *next_gpe_block; - struct acpi_gpe_xrupt_info *gpe_xrupt_info; - struct acpi_gpe_xrupt_info *next_gpe_xrupt_info; - - - ACPI_FUNCTION_TRACE ("ut_terminate"); + struct acpi_gpe_block_info *gpe_block; + struct acpi_gpe_block_info *next_gpe_block; + struct acpi_gpe_xrupt_info *gpe_xrupt_info; + struct acpi_gpe_xrupt_info *next_gpe_xrupt_info; + ACPI_FUNCTION_TRACE("ut_terminate"); /* Free global tables, etc. */ /* Free global GPE blocks and related info structures */ @@ -201,21 +186,20 @@ acpi_ut_terminate ( gpe_block = gpe_xrupt_info->gpe_block_list_head; while (gpe_block) { next_gpe_block = gpe_block->next; - ACPI_MEM_FREE (gpe_block->event_info); - ACPI_MEM_FREE (gpe_block->register_info); - ACPI_MEM_FREE (gpe_block); + ACPI_MEM_FREE(gpe_block->event_info); + ACPI_MEM_FREE(gpe_block->register_info); + ACPI_MEM_FREE(gpe_block); gpe_block = next_gpe_block; } next_gpe_xrupt_info = gpe_xrupt_info->next; - ACPI_MEM_FREE (gpe_xrupt_info); + ACPI_MEM_FREE(gpe_xrupt_info); gpe_xrupt_info = next_gpe_xrupt_info; } return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_subsystem_shutdown @@ -229,50 +213,45 @@ acpi_ut_terminate ( * ******************************************************************************/ -void -acpi_ut_subsystem_shutdown ( - void) +void acpi_ut_subsystem_shutdown(void) { - ACPI_FUNCTION_TRACE ("ut_subsystem_shutdown"); + ACPI_FUNCTION_TRACE("ut_subsystem_shutdown"); /* Just exit if subsystem is already shutdown */ if (acpi_gbl_shutdown) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "ACPI Subsystem is already terminated\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "ACPI Subsystem is already terminated\n")); return_VOID; } /* Subsystem appears active, go ahead and shut it down */ acpi_gbl_shutdown = TRUE; - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Shutting down ACPI Subsystem...\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n")); /* Close the acpi_event Handling */ - acpi_ev_terminate (); + acpi_ev_terminate(); /* Close the Namespace */ - acpi_ns_terminate (); + acpi_ns_terminate(); /* Close the globals */ - acpi_ut_terminate (); + acpi_ut_terminate(); /* Purge the local caches */ - (void) acpi_ut_delete_caches (); + (void)acpi_ut_delete_caches(); /* Debug only - display leftover memory allocation, if any */ #ifdef ACPI_DBG_TRACK_ALLOCATIONS - acpi_ut_dump_allocations (ACPI_UINT32_MAX, NULL); + acpi_ut_dump_allocations(ACPI_UINT32_MAX, NULL); #endif return_VOID; } - - diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/utilities/utmath.c index 0d527c9..68a0a6f 100644 --- a/drivers/acpi/utilities/utmath.c +++ b/drivers/acpi/utilities/utmath.c @@ -41,19 +41,16 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include - #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utmath") +ACPI_MODULE_NAME("utmath") /* * Support for double-precision integer divide. This code is included here * in order to support kernel environments where the double-precision math * library is not available. */ - #ifndef ACPI_USE_NATIVE_DIVIDE /******************************************************************************* * @@ -71,27 +68,22 @@ * 32-bit remainder. * ******************************************************************************/ - acpi_status -acpi_ut_short_divide ( - acpi_integer dividend, - u32 divisor, - acpi_integer *out_quotient, - u32 *out_remainder) +acpi_ut_short_divide(acpi_integer dividend, + u32 divisor, + acpi_integer * out_quotient, u32 * out_remainder) { - union uint64_overlay dividend_ovl; - union uint64_overlay quotient; - u32 remainder32; - - - ACPI_FUNCTION_TRACE ("ut_short_divide"); + union uint64_overlay dividend_ovl; + union uint64_overlay quotient; + u32 remainder32; + ACPI_FUNCTION_TRACE("ut_short_divide"); /* Always check for a zero divisor */ if (divisor == 0) { - ACPI_REPORT_ERROR (("acpi_ut_short_divide: Divide by zero\n")); - return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n")); + return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } dividend_ovl.full = dividend; @@ -100,9 +92,9 @@ acpi_ut_short_divide ( * The quotient is 64 bits, the remainder is always 32 bits, * and is generated by the second divide. */ - ACPI_DIV_64_BY_32 (0, dividend_ovl.part.hi, divisor, + ACPI_DIV_64_BY_32(0, dividend_ovl.part.hi, divisor, quotient.part.hi, remainder32); - ACPI_DIV_64_BY_32 (remainder32, dividend_ovl.part.lo, divisor, + ACPI_DIV_64_BY_32(remainder32, dividend_ovl.part.lo, divisor, quotient.part.lo, remainder32); /* Return only what was requested */ @@ -114,10 +106,9 @@ acpi_ut_short_divide ( *out_remainder = remainder32; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ut_divide @@ -134,34 +125,30 @@ acpi_ut_short_divide ( ******************************************************************************/ acpi_status -acpi_ut_divide ( - acpi_integer in_dividend, - acpi_integer in_divisor, - acpi_integer *out_quotient, - acpi_integer *out_remainder) +acpi_ut_divide(acpi_integer in_dividend, + acpi_integer in_divisor, + acpi_integer * out_quotient, acpi_integer * out_remainder) { - union uint64_overlay dividend; - union uint64_overlay divisor; - union uint64_overlay quotient; - union uint64_overlay remainder; - union uint64_overlay normalized_dividend; - union uint64_overlay normalized_divisor; - u32 partial1; - union uint64_overlay partial2; - union uint64_overlay partial3; - - - ACPI_FUNCTION_TRACE ("ut_divide"); - + union uint64_overlay dividend; + union uint64_overlay divisor; + union uint64_overlay quotient; + union uint64_overlay remainder; + union uint64_overlay normalized_dividend; + union uint64_overlay normalized_divisor; + u32 partial1; + union uint64_overlay partial2; + union uint64_overlay partial3; + + ACPI_FUNCTION_TRACE("ut_divide"); /* Always check for a zero divisor */ if (in_divisor == 0) { - ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n")); - return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n")); + return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } - divisor.full = in_divisor; + divisor.full = in_divisor; dividend.full = in_dividend; if (divisor.part.hi == 0) { /* @@ -174,9 +161,9 @@ acpi_ut_divide ( * The quotient is 64 bits, the remainder is always 32 bits, * and is generated by the second divide. */ - ACPI_DIV_64_BY_32 (0, dividend.part.hi, divisor.part.lo, + ACPI_DIV_64_BY_32(0, dividend.part.hi, divisor.part.lo, quotient.part.hi, partial1); - ACPI_DIV_64_BY_32 (partial1, dividend.part.lo, divisor.part.lo, + ACPI_DIV_64_BY_32(partial1, dividend.part.lo, divisor.part.lo, quotient.part.lo, remainder.part.lo); } @@ -185,23 +172,23 @@ acpi_ut_divide ( * 2) The general case where the divisor is a full 64 bits * is more difficult */ - quotient.part.hi = 0; + quotient.part.hi = 0; normalized_dividend = dividend; normalized_divisor = divisor; /* Normalize the operands (shift until the divisor is < 32 bits) */ do { - ACPI_SHIFT_RIGHT_64 (normalized_divisor.part.hi, - normalized_divisor.part.lo); - ACPI_SHIFT_RIGHT_64 (normalized_dividend.part.hi, - normalized_dividend.part.lo); + ACPI_SHIFT_RIGHT_64(normalized_divisor.part.hi, + normalized_divisor.part.lo); + ACPI_SHIFT_RIGHT_64(normalized_dividend.part.hi, + normalized_dividend.part.lo); } while (normalized_divisor.part.hi != 0); /* Partial divide */ - ACPI_DIV_64_BY_32 (normalized_dividend.part.hi, + ACPI_DIV_64_BY_32(normalized_dividend.part.hi, normalized_dividend.part.lo, normalized_divisor.part.lo, quotient.part.lo, partial1); @@ -210,8 +197,9 @@ acpi_ut_divide ( * The quotient is always 32 bits, and simply requires adjustment. * The 64-bit remainder must be generated. */ - partial1 = quotient.part.lo * divisor.part.hi; - partial2.full = (acpi_integer) quotient.part.lo * divisor.part.lo; + partial1 = quotient.part.lo * divisor.part.hi; + partial2.full = + (acpi_integer) quotient.part.lo * divisor.part.lo; partial3.full = (acpi_integer) partial2.part.hi + partial1; remainder.part.hi = partial3.part.lo; @@ -224,16 +212,15 @@ acpi_ut_divide ( quotient.part.lo--; remainder.full -= divisor.full; } - } - else { + } else { quotient.part.lo--; remainder.full -= divisor.full; } } - remainder.full = remainder.full - dividend.full; - remainder.part.hi = (u32) -((s32) remainder.part.hi); - remainder.part.lo = (u32) -((s32) remainder.part.lo); + remainder.full = remainder.full - dividend.full; + remainder.part.hi = (u32) - ((s32) remainder.part.hi); + remainder.part.lo = (u32) - ((s32) remainder.part.lo); if (remainder.part.lo) { remainder.part.hi--; @@ -250,11 +237,10 @@ acpi_ut_divide ( *out_remainder = remainder.full; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } #else - /******************************************************************************* * * FUNCTION: acpi_ut_short_divide, acpi_ut_divide @@ -269,23 +255,19 @@ acpi_ut_divide ( * perform the divide. * ******************************************************************************/ - acpi_status -acpi_ut_short_divide ( - acpi_integer in_dividend, - u32 divisor, - acpi_integer *out_quotient, - u32 *out_remainder) +acpi_ut_short_divide(acpi_integer in_dividend, + u32 divisor, + acpi_integer * out_quotient, u32 * out_remainder) { - ACPI_FUNCTION_TRACE ("ut_short_divide"); - + ACPI_FUNCTION_TRACE("ut_short_divide"); /* Always check for a zero divisor */ if (divisor == 0) { - ACPI_REPORT_ERROR (("acpi_ut_short_divide: Divide by zero\n")); - return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n")); + return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } /* Return only what was requested */ @@ -297,27 +279,23 @@ acpi_ut_short_divide ( *out_remainder = (u32) in_dividend % divisor; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } acpi_status -acpi_ut_divide ( - acpi_integer in_dividend, - acpi_integer in_divisor, - acpi_integer *out_quotient, - acpi_integer *out_remainder) +acpi_ut_divide(acpi_integer in_dividend, + acpi_integer in_divisor, + acpi_integer * out_quotient, acpi_integer * out_remainder) { - ACPI_FUNCTION_TRACE ("ut_divide"); - + ACPI_FUNCTION_TRACE("ut_divide"); /* Always check for a zero divisor */ if (in_divisor == 0) { - ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n")); - return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n")); + return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } - /* Return only what was requested */ if (out_quotient) { @@ -327,9 +305,7 @@ acpi_ut_divide ( *out_remainder = in_dividend % in_divisor; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } #endif - - diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index 1d350b3..474fe7c 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -41,14 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utmisc") - +ACPI_MODULE_NAME("utmisc") /******************************************************************************* * @@ -63,23 +60,18 @@ * when the method exits or the table is unloaded. * ******************************************************************************/ - -acpi_status -acpi_ut_allocate_owner_id ( - acpi_owner_id *owner_id) +acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) { - acpi_native_uint i; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ut_allocate_owner_id"); + acpi_native_uint i; + acpi_status status; + ACPI_FUNCTION_TRACE("ut_allocate_owner_id"); /* Mutex for the global ID mask */ - status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Find a free owner ID */ @@ -101,15 +93,13 @@ acpi_ut_allocate_owner_id ( */ *owner_id = 0; status = AE_OWNER_ID_LIMIT; - ACPI_REPORT_ERROR (( - "Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); + ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); -exit: - (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); - return_ACPI_STATUS (status); + exit: + (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_release_owner_id @@ -124,16 +114,12 @@ exit: * ******************************************************************************/ -void -acpi_ut_release_owner_id ( - acpi_owner_id *owner_id_ptr) +void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) { - acpi_owner_id owner_id = *owner_id_ptr; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ut_release_owner_id"); + acpi_owner_id owner_id = *owner_id_ptr; + acpi_status status; + ACPI_FUNCTION_TRACE("ut_release_owner_id"); /* Always clear the input owner_id (zero is an invalid ID) */ @@ -142,18 +128,18 @@ acpi_ut_release_owner_id ( /* Zero is not a valid owner_iD */ if ((owner_id == 0) || (owner_id > 32)) { - ACPI_REPORT_ERROR (("Invalid owner_id: %2.2X\n", owner_id)); + ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id)); return_VOID; } /* Mutex for the global ID mask */ - status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); - if (ACPI_FAILURE (status)) { + status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); + if (ACPI_FAILURE(status)) { return_VOID; } - owner_id--; /* Normalize to zero */ + owner_id--; /* Normalize to zero */ /* Free the owner ID only if it is valid */ @@ -161,11 +147,10 @@ acpi_ut_release_owner_id ( acpi_gbl_owner_id_mask ^= (1 << owner_id); } - (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); + (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_strupr (strupr) @@ -180,15 +165,11 @@ acpi_ut_release_owner_id ( * ******************************************************************************/ -void -acpi_ut_strupr ( - char *src_string) +void acpi_ut_strupr(char *src_string) { - char *string; - - - ACPI_FUNCTION_ENTRY (); + char *string; + ACPI_FUNCTION_ENTRY(); if (!src_string) { return; @@ -197,13 +178,12 @@ acpi_ut_strupr ( /* Walk entire string, uppercasing the letters */ for (string = src_string; *string; string++) { - *string = (char) ACPI_TOUPPER (*string); + *string = (char)ACPI_TOUPPER(*string); } return; } - /******************************************************************************* * * FUNCTION: acpi_ut_print_string @@ -218,85 +198,77 @@ acpi_ut_strupr ( * ******************************************************************************/ -void -acpi_ut_print_string ( - char *string, - u8 max_length) +void acpi_ut_print_string(char *string, u8 max_length) { - u32 i; - + u32 i; if (!string) { - acpi_os_printf ("<\"NULL STRING PTR\">"); + acpi_os_printf("<\"NULL STRING PTR\">"); return; } - acpi_os_printf ("\""); + acpi_os_printf("\""); for (i = 0; string[i] && (i < max_length); i++) { /* Escape sequences */ switch (string[i]) { case 0x07: - acpi_os_printf ("\\a"); /* BELL */ + acpi_os_printf("\\a"); /* BELL */ break; case 0x08: - acpi_os_printf ("\\b"); /* BACKSPACE */ + acpi_os_printf("\\b"); /* BACKSPACE */ break; case 0x0C: - acpi_os_printf ("\\f"); /* FORMFEED */ + acpi_os_printf("\\f"); /* FORMFEED */ break; case 0x0A: - acpi_os_printf ("\\n"); /* LINEFEED */ + acpi_os_printf("\\n"); /* LINEFEED */ break; case 0x0D: - acpi_os_printf ("\\r"); /* CARRIAGE RETURN*/ + acpi_os_printf("\\r"); /* CARRIAGE RETURN */ break; case 0x09: - acpi_os_printf ("\\t"); /* HORIZONTAL TAB */ + acpi_os_printf("\\t"); /* HORIZONTAL TAB */ break; case 0x0B: - acpi_os_printf ("\\v"); /* VERTICAL TAB */ + acpi_os_printf("\\v"); /* VERTICAL TAB */ break; - case '\'': /* Single Quote */ - case '\"': /* Double Quote */ - case '\\': /* Backslash */ - acpi_os_printf ("\\%c", (int) string[i]); + case '\'': /* Single Quote */ + case '\"': /* Double Quote */ + case '\\': /* Backslash */ + acpi_os_printf("\\%c", (int)string[i]); break; default: /* Check for printable character or hex escape */ - if (ACPI_IS_PRINT (string[i])) - { + if (ACPI_IS_PRINT(string[i])) { /* This is a normal character */ - acpi_os_printf ("%c", (int) string[i]); - } - else - { + acpi_os_printf("%c", (int)string[i]); + } else { /* All others will be Hex escapes */ - acpi_os_printf ("\\x%2.2X", (s32) string[i]); + acpi_os_printf("\\x%2.2X", (s32) string[i]); } break; } } - acpi_os_printf ("\""); + acpi_os_printf("\""); if (i == max_length && string[i]) { - acpi_os_printf ("..."); + acpi_os_printf("..."); } } - /******************************************************************************* * * FUNCTION: acpi_ut_dword_byte_swap @@ -309,22 +281,18 @@ acpi_ut_print_string ( * ******************************************************************************/ -u32 -acpi_ut_dword_byte_swap ( - u32 value) +u32 acpi_ut_dword_byte_swap(u32 value) { union { - u32 value; - u8 bytes[4]; + u32 value; + u8 bytes[4]; } out; union { - u32 value; - u8 bytes[4]; + u32 value; + u8 bytes[4]; } in; - - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_ENTRY(); in.value = value; @@ -336,7 +304,6 @@ acpi_ut_dword_byte_swap ( return (out.value); } - /******************************************************************************* * * FUNCTION: acpi_ut_set_integer_width @@ -352,24 +319,20 @@ acpi_ut_dword_byte_swap ( * ******************************************************************************/ -void -acpi_ut_set_integer_width ( - u8 revision) +void acpi_ut_set_integer_width(u8 revision) { if (revision <= 1) { acpi_gbl_integer_bit_width = 32; acpi_gbl_integer_nybble_width = 8; acpi_gbl_integer_byte_width = 4; - } - else { + } else { acpi_gbl_integer_bit_width = 64; acpi_gbl_integer_nybble_width = 16; acpi_gbl_integer_byte_width = 8; } } - #ifdef ACPI_DEBUG_OUTPUT /******************************************************************************* * @@ -387,17 +350,14 @@ acpi_ut_set_integer_width ( ******************************************************************************/ void -acpi_ut_display_init_pathname ( - u8 type, - struct acpi_namespace_node *obj_handle, - char *path) +acpi_ut_display_init_pathname(u8 type, + struct acpi_namespace_node *obj_handle, + char *path) { - acpi_status status; - struct acpi_buffer buffer; - - - ACPI_FUNCTION_ENTRY (); + acpi_status status; + struct acpi_buffer buffer; + ACPI_FUNCTION_ENTRY(); /* Only print the path if the appropriate debug level is enabled */ @@ -408,8 +368,8 @@ acpi_ut_display_init_pathname ( /* Get the full pathname to the node */ buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; - status = acpi_ns_handle_to_pathname (obj_handle, &buffer); - if (ACPI_FAILURE (status)) { + status = acpi_ns_handle_to_pathname(obj_handle, &buffer); + if (ACPI_FAILURE(status)) { return; } @@ -417,31 +377,30 @@ acpi_ut_display_init_pathname ( switch (type) { case ACPI_TYPE_METHOD: - acpi_os_printf ("Executing "); + acpi_os_printf("Executing "); break; default: - acpi_os_printf ("Initializing "); + acpi_os_printf("Initializing "); break; } /* Print the object type and pathname */ - acpi_os_printf ("%-12s %s", - acpi_ut_get_type_name (type), (char *) buffer.pointer); + acpi_os_printf("%-12s %s", + acpi_ut_get_type_name(type), (char *)buffer.pointer); /* Extra path is used to append names like _STA, _INI, etc. */ if (path) { - acpi_os_printf (".%s", path); + acpi_os_printf(".%s", path); } - acpi_os_printf ("\n"); + acpi_os_printf("\n"); - ACPI_MEM_FREE (buffer.pointer); + ACPI_MEM_FREE(buffer.pointer); } #endif - /******************************************************************************* * * FUNCTION: acpi_ut_valid_acpi_name @@ -457,25 +416,21 @@ acpi_ut_display_init_pathname ( * ******************************************************************************/ -u8 -acpi_ut_valid_acpi_name ( - u32 name) +u8 acpi_ut_valid_acpi_name(u32 name) { - char *name_ptr = (char *) &name; - char character; - acpi_native_uint i; - - - ACPI_FUNCTION_ENTRY (); + char *name_ptr = (char *)&name; + char character; + acpi_native_uint i; + ACPI_FUNCTION_ENTRY(); for (i = 0; i < ACPI_NAME_SIZE; i++) { character = *name_ptr; name_ptr++; if (!((character == '_') || - (character >= 'A' && character <= 'Z') || - (character >= '0' && character <= '9'))) { + (character >= 'A' && character <= 'Z') || + (character >= '0' && character <= '9'))) { return (FALSE); } } @@ -483,7 +438,6 @@ acpi_ut_valid_acpi_name ( return (TRUE); } - /******************************************************************************* * * FUNCTION: acpi_ut_valid_acpi_character @@ -496,19 +450,16 @@ acpi_ut_valid_acpi_name ( * ******************************************************************************/ -u8 -acpi_ut_valid_acpi_character ( - char character) +u8 acpi_ut_valid_acpi_character(char character) { - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); - return ((u8) ((character == '_') || - (character >= 'A' && character <= 'Z') || - (character >= '0' && character <= '9'))); + return ((u8) ((character == '_') || + (character >= 'A' && character <= 'Z') || + (character >= '0' && character <= '9'))); } - /******************************************************************************* * * FUNCTION: acpi_ut_strtoul64 @@ -525,18 +476,13 @@ acpi_ut_valid_acpi_character ( ******************************************************************************/ acpi_status -acpi_ut_strtoul64 ( - char *string, - u32 base, - acpi_integer *ret_integer) +acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer) { - u32 this_digit = 0; - acpi_integer return_value = 0; - acpi_integer quotient; - - - ACPI_FUNCTION_TRACE ("ut_stroul64"); + u32 this_digit = 0; + acpi_integer return_value = 0; + acpi_integer quotient; + ACPI_FUNCTION_TRACE("ut_stroul64"); if ((!string) || !(*string)) { goto error_exit; @@ -550,12 +496,12 @@ acpi_ut_strtoul64 ( default: /* Invalid Base */ - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Skip over any white space in the buffer */ - while (ACPI_IS_SPACE (*string) || *string == '\t') { + while (ACPI_IS_SPACE(*string) || *string == '\t') { string++; } @@ -564,12 +510,10 @@ acpi_ut_strtoul64 ( * determine if it is decimal or hexadecimal: */ if (base == 0) { - if ((*string == '0') && - (ACPI_TOLOWER (*(string + 1)) == 'x')) { + if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) { base = 16; string += 2; - } - else { + } else { base = 10; } } @@ -579,8 +523,7 @@ acpi_ut_strtoul64 ( * 0 or 0x, if they are present. */ if ((base == 16) && - (*string == '0') && - (ACPI_TOLOWER (*(string + 1)) == 'x')) { + (*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) { string += 2; } @@ -593,25 +536,23 @@ acpi_ut_strtoul64 ( /* Main loop: convert the string to a 64-bit integer */ while (*string) { - if (ACPI_IS_DIGIT (*string)) { + if (ACPI_IS_DIGIT(*string)) { /* Convert ASCII 0-9 to Decimal value */ - this_digit = ((u8) *string) - '0'; - } - else { + this_digit = ((u8) * string) - '0'; + } else { if (base == 10) { /* Digit is out of range */ goto error_exit; } - this_digit = (u8) ACPI_TOUPPER (*string); - if (ACPI_IS_XDIGIT ((char) this_digit)) { + this_digit = (u8) ACPI_TOUPPER(*string); + if (ACPI_IS_XDIGIT((char)this_digit)) { /* Convert ASCII Hex char to value */ this_digit = this_digit - 'A' + 10; - } - else { + } else { /* * We allow non-hex chars, just stop now, same as end-of-string. * See ACPI spec, string-to-integer conversion. @@ -622,8 +563,10 @@ acpi_ut_strtoul64 ( /* Divide the digit into the correct position */ - (void) acpi_ut_short_divide ((ACPI_INTEGER_MAX - (acpi_integer) this_digit), - base, "ient, NULL); + (void) + acpi_ut_short_divide((ACPI_INTEGER_MAX - + (acpi_integer) this_digit), base, + "ient, NULL); if (return_value > quotient) { goto error_exit; } @@ -636,21 +579,18 @@ acpi_ut_strtoul64 ( /* All done, normal exit */ *ret_integer = return_value; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); - -error_exit: + error_exit: /* Base was set/validated above */ if (base == 10) { - return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); - } - else { - return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); + return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT); + } else { + return_ACPI_STATUS(AE_BAD_HEX_CONSTANT); } } - /******************************************************************************* * * FUNCTION: acpi_ut_create_update_state_and_push @@ -666,16 +606,13 @@ error_exit: ******************************************************************************/ acpi_status -acpi_ut_create_update_state_and_push ( - union acpi_operand_object *object, - u16 action, - union acpi_generic_state **state_list) +acpi_ut_create_update_state_and_push(union acpi_operand_object *object, + u16 action, + union acpi_generic_state **state_list) { - union acpi_generic_state *state; - - - ACPI_FUNCTION_ENTRY (); + union acpi_generic_state *state; + ACPI_FUNCTION_ENTRY(); /* Ignore null objects; these are expected */ @@ -683,16 +620,15 @@ acpi_ut_create_update_state_and_push ( return (AE_OK); } - state = acpi_ut_create_update_state (object, action); + state = acpi_ut_create_update_state(object, action); if (!state) { return (AE_NO_MEMORY); } - acpi_ut_push_generic_state (state_list, state); + acpi_ut_push_generic_state(state_list, state); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ut_walk_package_tree @@ -709,33 +645,29 @@ acpi_ut_create_update_state_and_push ( ******************************************************************************/ acpi_status -acpi_ut_walk_package_tree ( - union acpi_operand_object *source_object, - void *target_object, - acpi_pkg_callback walk_callback, - void *context) +acpi_ut_walk_package_tree(union acpi_operand_object * source_object, + void *target_object, + acpi_pkg_callback walk_callback, void *context) { - acpi_status status = AE_OK; - union acpi_generic_state *state_list = NULL; - union acpi_generic_state *state; - u32 this_index; - union acpi_operand_object *this_source_obj; - + acpi_status status = AE_OK; + union acpi_generic_state *state_list = NULL; + union acpi_generic_state *state; + u32 this_index; + union acpi_operand_object *this_source_obj; - ACPI_FUNCTION_TRACE ("ut_walk_package_tree"); + ACPI_FUNCTION_TRACE("ut_walk_package_tree"); - - state = acpi_ut_create_pkg_state (source_object, target_object, 0); + state = acpi_ut_create_pkg_state(source_object, target_object, 0); if (!state) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } while (state) { /* Get one element of the package */ - this_index = state->pkg.index; + this_index = state->pkg.index; this_source_obj = (union acpi_operand_object *) - state->pkg.source_object->package.elements[this_index]; + state->pkg.source_object->package.elements[this_index]; /* * Check for: @@ -746,16 +678,20 @@ acpi_ut_walk_package_tree ( * case below. */ if ((!this_source_obj) || - (ACPI_GET_DESCRIPTOR_TYPE (this_source_obj) != ACPI_DESC_TYPE_OPERAND) || - (ACPI_GET_OBJECT_TYPE (this_source_obj) != ACPI_TYPE_PACKAGE)) { - status = walk_callback (ACPI_COPY_TYPE_SIMPLE, this_source_obj, - state, context); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) != + ACPI_DESC_TYPE_OPERAND) + || (ACPI_GET_OBJECT_TYPE(this_source_obj) != + ACPI_TYPE_PACKAGE)) { + status = + walk_callback(ACPI_COPY_TYPE_SIMPLE, + this_source_obj, state, context); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } state->pkg.index++; - while (state->pkg.index >= state->pkg.source_object->package.count) { + while (state->pkg.index >= + state->pkg.source_object->package.count) { /* * We've handled all of the objects at this level, This means * that we have just completed a package. That package may @@ -763,8 +699,8 @@ acpi_ut_walk_package_tree ( * * Delete this state and pop the previous state (package). */ - acpi_ut_delete_generic_state (state); - state = acpi_ut_pop_generic_state (&state_list); + acpi_ut_delete_generic_state(state); + state = acpi_ut_pop_generic_state(&state_list); /* Finished when there are no more states */ @@ -774,7 +710,7 @@ acpi_ut_walk_package_tree ( * package just add the length of the package objects * and exit */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* @@ -783,35 +719,35 @@ acpi_ut_walk_package_tree ( */ state->pkg.index++; } - } - else { + } else { /* This is a subobject of type package */ - status = walk_callback (ACPI_COPY_TYPE_PACKAGE, this_source_obj, - state, context); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + walk_callback(ACPI_COPY_TYPE_PACKAGE, + this_source_obj, state, context); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* * Push the current state and create a new one * The callback above returned a new target package object. */ - acpi_ut_push_generic_state (&state_list, state); - state = acpi_ut_create_pkg_state (this_source_obj, - state->pkg.this_target_obj, 0); + acpi_ut_push_generic_state(&state_list, state); + state = acpi_ut_create_pkg_state(this_source_obj, + state->pkg. + this_target_obj, 0); if (!state) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } } } /* We should never get here */ - return_ACPI_STATUS (AE_AML_INTERNAL); + return_ACPI_STATUS(AE_AML_INTERNAL); } - /******************************************************************************* * * FUNCTION: acpi_ut_generate_checksum @@ -825,23 +761,18 @@ acpi_ut_walk_package_tree ( * ******************************************************************************/ -u8 -acpi_ut_generate_checksum ( - u8 *buffer, - u32 length) +u8 acpi_ut_generate_checksum(u8 * buffer, u32 length) { - u32 i; - signed char sum = 0; - + u32 i; + signed char sum = 0; for (i = 0; i < length; i++) { - sum = (signed char) (sum + buffer[i]); + sum = (signed char)(sum + buffer[i]); } return ((u8) (0 - sum)); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_resource_end_tag @@ -854,17 +785,13 @@ acpi_ut_generate_checksum ( * ******************************************************************************/ - -u8 * -acpi_ut_get_resource_end_tag ( - union acpi_operand_object *obj_desc) +u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc) { - u8 buffer_byte; - u8 *buffer; - u8 *end_buffer; + u8 buffer_byte; + u8 *buffer; + u8 *end_buffer; - - buffer = obj_desc->buffer.pointer; + buffer = obj_desc->buffer.pointer; end_buffer = buffer + obj_desc->buffer.length; while (buffer < end_buffer) { @@ -872,12 +799,12 @@ acpi_ut_get_resource_end_tag ( if (buffer_byte & ACPI_RDESC_TYPE_MASK) { /* Large Descriptor - Length is next 2 bytes */ - buffer += ((*(buffer+1) | (*(buffer+2) << 8)) + 3); - } - else { + buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3); + } else { /* Small Descriptor. End Tag will be found here */ - if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == ACPI_RDESC_TYPE_END_TAG) { + if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == + ACPI_RDESC_TYPE_END_TAG) { /* Found the end tag descriptor, all done. */ return (buffer); @@ -894,7 +821,6 @@ acpi_ut_get_resource_end_tag ( return (NULL); } - /******************************************************************************* * * FUNCTION: acpi_ut_report_error @@ -909,17 +835,12 @@ acpi_ut_get_resource_end_tag ( * ******************************************************************************/ -void -acpi_ut_report_error ( - char *module_name, - u32 line_number, - u32 component_id) +void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id) { - acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number); + acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number); } - /******************************************************************************* * * FUNCTION: acpi_ut_report_warning @@ -935,16 +856,12 @@ acpi_ut_report_error ( ******************************************************************************/ void -acpi_ut_report_warning ( - char *module_name, - u32 line_number, - u32 component_id) +acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id) { - acpi_os_printf ("%8s-%04d: *** Warning: ", module_name, line_number); + acpi_os_printf("%8s-%04d: *** Warning: ", module_name, line_number); } - /******************************************************************************* * * FUNCTION: acpi_ut_report_info @@ -959,14 +876,8 @@ acpi_ut_report_warning ( * ******************************************************************************/ -void -acpi_ut_report_info ( - char *module_name, - u32 line_number, - u32 component_id) +void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id) { - acpi_os_printf ("%8s-%04d: *** Info: ", module_name, line_number); + acpi_os_printf("%8s-%04d: *** Info: ", module_name, line_number); } - - diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c index 0699b6b..90134c5 100644 --- a/drivers/acpi/utilities/utmutex.c +++ b/drivers/acpi/utilities/utmutex.c @@ -41,22 +41,15 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utmutex") +ACPI_MODULE_NAME("utmutex") /* Local prototypes */ +static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id); -static acpi_status -acpi_ut_create_mutex ( - acpi_mutex_handle mutex_id); - -static acpi_status -acpi_ut_delete_mutex ( - acpi_mutex_handle mutex_id); - +static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id); /******************************************************************************* * @@ -70,32 +63,27 @@ acpi_ut_delete_mutex ( * ******************************************************************************/ -acpi_status -acpi_ut_mutex_initialize ( - void) +acpi_status acpi_ut_mutex_initialize(void) { - u32 i; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ut_mutex_initialize"); + u32 i; + acpi_status status; + ACPI_FUNCTION_TRACE("ut_mutex_initialize"); /* * Create each of the predefined mutex objects */ for (i = 0; i < NUM_MUTEX; i++) { - status = acpi_ut_create_mutex (i); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_create_mutex(i); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } - status = acpi_os_create_lock (&acpi_gbl_gpe_lock); - return_ACPI_STATUS (status); + status = acpi_os_create_lock(&acpi_gbl_gpe_lock); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_mutex_terminate @@ -108,28 +96,23 @@ acpi_ut_mutex_initialize ( * ******************************************************************************/ -void -acpi_ut_mutex_terminate ( - void) +void acpi_ut_mutex_terminate(void) { - u32 i; - - - ACPI_FUNCTION_TRACE ("ut_mutex_terminate"); + u32 i; + ACPI_FUNCTION_TRACE("ut_mutex_terminate"); /* * Delete each predefined mutex object */ for (i = 0; i < NUM_MUTEX; i++) { - (void) acpi_ut_delete_mutex (i); + (void)acpi_ut_delete_mutex(i); } - acpi_os_delete_lock (acpi_gbl_gpe_lock); + acpi_os_delete_lock(acpi_gbl_gpe_lock); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_create_mutex @@ -142,31 +125,28 @@ acpi_ut_mutex_terminate ( * ******************************************************************************/ -static acpi_status -acpi_ut_create_mutex ( - acpi_mutex_handle mutex_id) +static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE_U32("ut_create_mutex", mutex_id); if (mutex_id > MAX_MUTEX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } if (!acpi_gbl_mutex_info[mutex_id].mutex) { - status = acpi_os_create_semaphore (1, 1, - &acpi_gbl_mutex_info[mutex_id].mutex); - acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; + status = acpi_os_create_semaphore(1, 1, + &acpi_gbl_mutex_info + [mutex_id].mutex); + acpi_gbl_mutex_info[mutex_id].thread_id = + ACPI_MUTEX_NOT_ACQUIRED; acpi_gbl_mutex_info[mutex_id].use_count = 0; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_delete_mutex @@ -179,29 +159,24 @@ acpi_ut_create_mutex ( * ******************************************************************************/ -static acpi_status -acpi_ut_delete_mutex ( - acpi_mutex_handle mutex_id) +static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id) { - acpi_status status; - - - ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id); + acpi_status status; + ACPI_FUNCTION_TRACE_U32("ut_delete_mutex", mutex_id); if (mutex_id > MAX_MUTEX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex); + status = acpi_os_delete_semaphore(acpi_gbl_mutex_info[mutex_id].mutex); acpi_gbl_mutex_info[mutex_id].mutex = NULL; acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_acquire_mutex @@ -214,26 +189,22 @@ acpi_ut_delete_mutex ( * ******************************************************************************/ -acpi_status -acpi_ut_acquire_mutex ( - acpi_mutex_handle mutex_id) +acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) { - acpi_status status; - u32 this_thread_id; - - - ACPI_FUNCTION_NAME ("ut_acquire_mutex"); + acpi_status status; + u32 this_thread_id; + ACPI_FUNCTION_NAME("ut_acquire_mutex"); if (mutex_id > MAX_MUTEX) { return (AE_BAD_PARAMETER); } - this_thread_id = acpi_os_get_thread_id (); + this_thread_id = acpi_os_get_thread_id(); #ifdef ACPI_MUTEX_DEBUG { - u32 i; + u32 i; /* * Mutex debug code, for internal debugging only. * @@ -245,17 +216,21 @@ acpi_ut_acquire_mutex ( for (i = mutex_id; i < MAX_MUTEX; i++) { if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { if (i == mutex_id) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Mutex [%s] already acquired by this thread [%X]\n", - acpi_ut_get_mutex_name (mutex_id), this_thread_id)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Mutex [%s] already acquired by this thread [%X]\n", + acpi_ut_get_mutex_name + (mutex_id), + this_thread_id)); return (AE_ALREADY_ACQUIRED); } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", - this_thread_id, acpi_ut_get_mutex_name (i), - acpi_ut_get_mutex_name (mutex_id))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", + this_thread_id, + acpi_ut_get_mutex_name(i), + acpi_ut_get_mutex_name + (mutex_id))); return (AE_ACQUIRE_DEADLOCK); } @@ -263,30 +238,31 @@ acpi_ut_acquire_mutex ( } #endif - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X attempting to acquire Mutex [%s]\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id))); + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, + "Thread %X attempting to acquire Mutex [%s]\n", + this_thread_id, acpi_ut_get_mutex_name(mutex_id))); - status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, - 1, ACPI_WAIT_FOREVER); - if (ACPI_SUCCESS (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id))); + status = acpi_os_wait_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, + 1, ACPI_WAIT_FOREVER); + if (ACPI_SUCCESS(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, + "Thread %X acquired Mutex [%s]\n", + this_thread_id, + acpi_ut_get_mutex_name(mutex_id))); acpi_gbl_mutex_info[mutex_id].use_count++; acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Thread %X could not acquire Mutex [%s] %s\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id), - acpi_format_exception (status))); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Thread %X could not acquire Mutex [%s] %s\n", + this_thread_id, + acpi_ut_get_mutex_name(mutex_id), + acpi_format_exception(status))); } return (status); } - /******************************************************************************* * * FUNCTION: acpi_ut_release_mutex @@ -299,21 +275,17 @@ acpi_ut_acquire_mutex ( * ******************************************************************************/ -acpi_status -acpi_ut_release_mutex ( - acpi_mutex_handle mutex_id) +acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) { - acpi_status status; - u32 this_thread_id; - + acpi_status status; + u32 this_thread_id; - ACPI_FUNCTION_NAME ("ut_release_mutex"); + ACPI_FUNCTION_NAME("ut_release_mutex"); - - this_thread_id = acpi_os_get_thread_id (); - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X releasing Mutex [%s]\n", this_thread_id, - acpi_ut_get_mutex_name (mutex_id))); + this_thread_id = acpi_os_get_thread_id(); + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, + "Thread %X releasing Mutex [%s]\n", this_thread_id, + acpi_ut_get_mutex_name(mutex_id))); if (mutex_id > MAX_MUTEX) { return (AE_BAD_PARAMETER); @@ -323,16 +295,15 @@ acpi_ut_release_mutex ( * Mutex must be acquired in order to release it! */ if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Mutex [%s] is not acquired, cannot release\n", - acpi_ut_get_mutex_name (mutex_id))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Mutex [%s] is not acquired, cannot release\n", + acpi_ut_get_mutex_name(mutex_id))); return (AE_NOT_ACQUIRED); } - #ifdef ACPI_MUTEX_DEBUG { - u32 i; + u32 i; /* * Mutex debug code, for internal debugging only. * @@ -347,9 +318,11 @@ acpi_ut_release_mutex ( continue; } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid release order: owns [%s], releasing [%s]\n", - acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid release order: owns [%s], releasing [%s]\n", + acpi_ut_get_mutex_name(i), + acpi_ut_get_mutex_name + (mutex_id))); return (AE_RELEASE_DEADLOCK); } @@ -361,20 +334,21 @@ acpi_ut_release_mutex ( acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; - status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); - - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Thread %X could not release Mutex [%s] %s\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id), - acpi_format_exception (status))); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id))); + status = + acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1); + + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Thread %X could not release Mutex [%s] %s\n", + this_thread_id, + acpi_ut_get_mutex_name(mutex_id), + acpi_format_exception(status))); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, + "Thread %X released Mutex [%s]\n", + this_thread_id, + acpi_ut_get_mutex_name(mutex_id))); } return (status); } - - diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c index 19178e1..3015e15 100644 --- a/drivers/acpi/utilities/utobject.c +++ b/drivers/acpi/utilities/utobject.c @@ -41,34 +41,26 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include - #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utobject") +ACPI_MODULE_NAME("utobject") /* Local prototypes */ - static acpi_status -acpi_ut_get_simple_object_size ( - union acpi_operand_object *obj, - acpi_size *obj_length); +acpi_ut_get_simple_object_size(union acpi_operand_object *obj, + acpi_size * obj_length); static acpi_status -acpi_ut_get_package_object_size ( - union acpi_operand_object *obj, - acpi_size *obj_length); +acpi_ut_get_package_object_size(union acpi_operand_object *obj, + acpi_size * obj_length); static acpi_status -acpi_ut_get_element_length ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context); - +acpi_ut_get_element_length(u8 object_type, + union acpi_operand_object *source_object, + union acpi_generic_state *state, void *context); /******************************************************************************* * @@ -91,26 +83,25 @@ acpi_ut_get_element_length ( * ******************************************************************************/ -union acpi_operand_object * -acpi_ut_create_internal_object_dbg ( - char *module_name, - u32 line_number, - u32 component_id, - acpi_object_type type) +union acpi_operand_object *acpi_ut_create_internal_object_dbg(char *module_name, + u32 line_number, + u32 component_id, + acpi_object_type + type) { - union acpi_operand_object *object; - union acpi_operand_object *second_object; - - - ACPI_FUNCTION_TRACE_STR ("ut_create_internal_object_dbg", - acpi_ut_get_type_name (type)); + union acpi_operand_object *object; + union acpi_operand_object *second_object; + ACPI_FUNCTION_TRACE_STR("ut_create_internal_object_dbg", + acpi_ut_get_type_name(type)); /* Allocate the raw object descriptor */ - object = acpi_ut_allocate_object_desc_dbg (module_name, line_number, component_id); + object = + acpi_ut_allocate_object_desc_dbg(module_name, line_number, + component_id); if (!object) { - return_PTR (NULL); + return_PTR(NULL); } switch (type) { @@ -119,11 +110,12 @@ acpi_ut_create_internal_object_dbg ( /* These types require a secondary object */ - second_object = acpi_ut_allocate_object_desc_dbg (module_name, - line_number, component_id); + second_object = acpi_ut_allocate_object_desc_dbg(module_name, + line_number, + component_id); if (!second_object) { - acpi_ut_delete_object_desc (object); - return_PTR (NULL); + acpi_ut_delete_object_desc(object); + return_PTR(NULL); } second_object->common.type = ACPI_TYPE_LOCAL_EXTRA; @@ -149,10 +141,9 @@ acpi_ut_create_internal_object_dbg ( /* Any per-type initialization should go here */ - return_PTR (object); + return_PTR(object); } - /******************************************************************************* * * FUNCTION: acpi_ut_create_buffer_object @@ -165,22 +156,18 @@ acpi_ut_create_internal_object_dbg ( * ******************************************************************************/ -union acpi_operand_object * -acpi_ut_create_buffer_object ( - acpi_size buffer_size) +union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size) { - union acpi_operand_object *buffer_desc; - u8 *buffer = NULL; - - - ACPI_FUNCTION_TRACE_U32 ("ut_create_buffer_object", buffer_size); + union acpi_operand_object *buffer_desc; + u8 *buffer = NULL; + ACPI_FUNCTION_TRACE_U32("ut_create_buffer_object", buffer_size); /* Create a new Buffer object */ - buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); + buffer_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); if (!buffer_desc) { - return_PTR (NULL); + return_PTR(NULL); } /* Create an actual buffer only if size > 0 */ @@ -188,12 +175,11 @@ acpi_ut_create_buffer_object ( if (buffer_size > 0) { /* Allocate the actual buffer */ - buffer = ACPI_MEM_CALLOCATE (buffer_size); + buffer = ACPI_MEM_CALLOCATE(buffer_size); if (!buffer) { - ACPI_REPORT_ERROR (("create_buffer: could not allocate size %X\n", - (u32) buffer_size)); - acpi_ut_remove_reference (buffer_desc); - return_PTR (NULL); + ACPI_REPORT_ERROR(("create_buffer: could not allocate size %X\n", (u32) buffer_size)); + acpi_ut_remove_reference(buffer_desc); + return_PTR(NULL); } } @@ -205,10 +191,9 @@ acpi_ut_create_buffer_object ( /* Return the new buffer descriptor */ - return_PTR (buffer_desc); + return_PTR(buffer_desc); } - /******************************************************************************* * * FUNCTION: acpi_ut_create_string_object @@ -223,34 +208,29 @@ acpi_ut_create_buffer_object ( * ******************************************************************************/ -union acpi_operand_object * -acpi_ut_create_string_object ( - acpi_size string_size) +union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size) { - union acpi_operand_object *string_desc; - char *string; - - - ACPI_FUNCTION_TRACE_U32 ("ut_create_string_object", string_size); + union acpi_operand_object *string_desc; + char *string; + ACPI_FUNCTION_TRACE_U32("ut_create_string_object", string_size); /* Create a new String object */ - string_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING); + string_desc = acpi_ut_create_internal_object(ACPI_TYPE_STRING); if (!string_desc) { - return_PTR (NULL); + return_PTR(NULL); } /* * Allocate the actual string buffer -- (Size + 1) for NULL terminator. * NOTE: Zero-length strings are NULL terminated */ - string = ACPI_MEM_CALLOCATE (string_size + 1); + string = ACPI_MEM_CALLOCATE(string_size + 1); if (!string) { - ACPI_REPORT_ERROR (("create_string: could not allocate size %X\n", - (u32) string_size)); - acpi_ut_remove_reference (string_desc); - return_PTR (NULL); + ACPI_REPORT_ERROR(("create_string: could not allocate size %X\n", (u32) string_size)); + acpi_ut_remove_reference(string_desc); + return_PTR(NULL); } /* Complete string object initialization */ @@ -260,10 +240,9 @@ acpi_ut_create_string_object ( /* Return the new string descriptor */ - return_PTR (string_desc); + return_PTR(string_desc); } - /******************************************************************************* * * FUNCTION: acpi_ut_valid_internal_object @@ -276,24 +255,21 @@ acpi_ut_create_string_object ( * ******************************************************************************/ -u8 -acpi_ut_valid_internal_object ( - void *object) +u8 acpi_ut_valid_internal_object(void *object) { - ACPI_FUNCTION_NAME ("ut_valid_internal_object"); - + ACPI_FUNCTION_NAME("ut_valid_internal_object"); /* Check for a null pointer */ if (!object) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Null Object Ptr\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "**** Null Object Ptr\n")); return (FALSE); } /* Check the descriptor type field */ - switch (ACPI_GET_DESCRIPTOR_TYPE (object)) { + switch (ACPI_GET_DESCRIPTOR_TYPE(object)) { case ACPI_DESC_TYPE_OPERAND: /* The object appears to be a valid union acpi_operand_object */ @@ -301,16 +277,15 @@ acpi_ut_valid_internal_object ( return (TRUE); default: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "%p is not not an ACPI operand obj [%s]\n", - object, acpi_ut_get_descriptor_name (object))); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "%p is not not an ACPI operand obj [%s]\n", + object, acpi_ut_get_descriptor_name(object))); break; } return (FALSE); } - /******************************************************************************* * * FUNCTION: acpi_ut_allocate_object_desc_dbg @@ -326,37 +301,31 @@ acpi_ut_valid_internal_object ( * ******************************************************************************/ -void * -acpi_ut_allocate_object_desc_dbg ( - char *module_name, - u32 line_number, - u32 component_id) +void *acpi_ut_allocate_object_desc_dbg(char *module_name, + u32 line_number, u32 component_id) { - union acpi_operand_object *object; - + union acpi_operand_object *object; - ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg"); + ACPI_FUNCTION_TRACE("ut_allocate_object_desc_dbg"); - - object = acpi_os_acquire_object (acpi_gbl_operand_cache); + object = acpi_os_acquire_object(acpi_gbl_operand_cache); if (!object) { - _ACPI_REPORT_ERROR (module_name, line_number, component_id, - ("Could not allocate an object descriptor\n")); + _ACPI_REPORT_ERROR(module_name, line_number, component_id, + ("Could not allocate an object descriptor\n")); - return_PTR (NULL); + return_PTR(NULL); } /* Mark the descriptor type */ memset(object, 0, sizeof(union acpi_operand_object)); - ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND); + ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_OPERAND); - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", - object, (u32) sizeof (union acpi_operand_object))); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p Size %X\n", + object, (u32) sizeof(union acpi_operand_object))); - return_PTR (object); + return_PTR(object); } - /******************************************************************************* * * FUNCTION: acpi_ut_delete_object_desc @@ -369,27 +338,23 @@ acpi_ut_allocate_object_desc_dbg ( * ******************************************************************************/ -void -acpi_ut_delete_object_desc ( - union acpi_operand_object *object) +void acpi_ut_delete_object_desc(union acpi_operand_object *object) { - ACPI_FUNCTION_TRACE_PTR ("ut_delete_object_desc", object); - + ACPI_FUNCTION_TRACE_PTR("ut_delete_object_desc", object); /* Object must be an union acpi_operand_object */ - if (ACPI_GET_DESCRIPTOR_TYPE (object) != ACPI_DESC_TYPE_OPERAND) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "%p is not an ACPI Operand object [%s]\n", object, - acpi_ut_get_descriptor_name (object))); + if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "%p is not an ACPI Operand object [%s]\n", + object, acpi_ut_get_descriptor_name(object))); return_VOID; } - (void) acpi_os_release_object (acpi_gbl_operand_cache, object); + (void)acpi_os_release_object(acpi_gbl_operand_cache, object); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_get_simple_object_size @@ -408,16 +373,13 @@ acpi_ut_delete_object_desc ( ******************************************************************************/ static acpi_status -acpi_ut_get_simple_object_size ( - union acpi_operand_object *internal_object, - acpi_size *obj_length) +acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, + acpi_size * obj_length) { - acpi_size length; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_PTR ("ut_get_simple_object_size", internal_object); + acpi_size length; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE_PTR("ut_get_simple_object_size", internal_object); /* * Handle a null object (Could be a uninitialized package @@ -425,18 +387,18 @@ acpi_ut_get_simple_object_size ( */ if (!internal_object) { *obj_length = 0; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Start with the length of the Acpi object */ - length = sizeof (union acpi_object); + length = sizeof(union acpi_object); - if (ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_NAMED) { + if (ACPI_GET_DESCRIPTOR_TYPE(internal_object) == ACPI_DESC_TYPE_NAMED) { /* Object is a named object (reference), just return the length */ - *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length); - return_ACPI_STATUS (status); + *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length); + return_ACPI_STATUS(status); } /* @@ -445,19 +407,17 @@ acpi_ut_get_simple_object_size ( * must be accessed bytewise or there may be alignment problems on * certain processors */ - switch (ACPI_GET_OBJECT_TYPE (internal_object)) { + switch (ACPI_GET_OBJECT_TYPE(internal_object)) { case ACPI_TYPE_STRING: length += (acpi_size) internal_object->string.length + 1; break; - case ACPI_TYPE_BUFFER: length += (acpi_size) internal_object->buffer.length; break; - case ACPI_TYPE_INTEGER: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: @@ -467,7 +427,6 @@ acpi_ut_get_simple_object_size ( */ break; - case ACPI_TYPE_LOCAL_REFERENCE: switch (internal_object->reference.opcode) { @@ -477,8 +436,10 @@ acpi_ut_get_simple_object_size ( * Get the actual length of the full pathname to this object. * The reference will be converted to the pathname to the object */ - length += ACPI_ROUND_UP_TO_NATIVE_WORD ( - acpi_ns_get_pathname_length (internal_object->reference.node)); + length += + ACPI_ROUND_UP_TO_NATIVE_WORD + (acpi_ns_get_pathname_length + (internal_object->reference.node)); break; default: @@ -488,19 +449,21 @@ acpi_ut_get_simple_object_size ( * Notably, Locals and Args are not supported, but this may be * required eventually. */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unsupported Reference opcode=%X in object %p\n", - internal_object->reference.opcode, internal_object)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unsupported Reference opcode=%X in object %p\n", + internal_object->reference.opcode, + internal_object)); status = AE_TYPE; break; } break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported type=%X in object %p\n", - ACPI_GET_OBJECT_TYPE (internal_object), internal_object)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unsupported type=%X in object %p\n", + ACPI_GET_OBJECT_TYPE(internal_object), + internal_object)); status = AE_TYPE; break; } @@ -511,11 +474,10 @@ acpi_ut_get_simple_object_size ( * on a machine word boundary. (preventing alignment faults on some * machines.) */ - *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length); - return_ACPI_STATUS (status); + *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_element_length @@ -529,16 +491,13 @@ acpi_ut_get_simple_object_size ( ******************************************************************************/ static acpi_status -acpi_ut_get_element_length ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context) +acpi_ut_get_element_length(u8 object_type, + union acpi_operand_object *source_object, + union acpi_generic_state *state, void *context) { - acpi_status status = AE_OK; - struct acpi_pkg_info *info = (struct acpi_pkg_info *) context; - acpi_size object_space; - + acpi_status status = AE_OK; + struct acpi_pkg_info *info = (struct acpi_pkg_info *)context; + acpi_size object_space; switch (object_type) { case ACPI_COPY_TYPE_SIMPLE: @@ -547,15 +506,16 @@ acpi_ut_get_element_length ( * Simple object - just get the size (Null object/entry is handled * here also) and sum it into the running package length */ - status = acpi_ut_get_simple_object_size (source_object, &object_space); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_get_simple_object_size(source_object, + &object_space); + if (ACPI_FAILURE(status)) { return (status); } info->length += object_space; break; - case ACPI_COPY_TYPE_PACKAGE: /* Package object - nothing much to do here, let the walk handle it */ @@ -564,7 +524,6 @@ acpi_ut_get_element_length ( state->pkg.this_target_obj = NULL; break; - default: /* No other types allowed */ @@ -575,7 +534,6 @@ acpi_ut_get_element_length ( return (status); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_package_object_size @@ -594,25 +552,22 @@ acpi_ut_get_element_length ( ******************************************************************************/ static acpi_status -acpi_ut_get_package_object_size ( - union acpi_operand_object *internal_object, - acpi_size *obj_length) +acpi_ut_get_package_object_size(union acpi_operand_object *internal_object, + acpi_size * obj_length) { - acpi_status status; - struct acpi_pkg_info info; + acpi_status status; + struct acpi_pkg_info info; + ACPI_FUNCTION_TRACE_PTR("ut_get_package_object_size", internal_object); - ACPI_FUNCTION_TRACE_PTR ("ut_get_package_object_size", internal_object); - - - info.length = 0; + info.length = 0; info.object_space = 0; info.num_packages = 1; - status = acpi_ut_walk_package_tree (internal_object, NULL, - acpi_ut_get_element_length, &info); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_walk_package_tree(internal_object, NULL, + acpi_ut_get_element_length, &info); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -620,16 +575,15 @@ acpi_ut_get_package_object_size ( * just add the length of the package objects themselves. * Round up to the next machine word. */ - info.length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)) * - (acpi_size) info.num_packages; + info.length += ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)) * + (acpi_size) info.num_packages; /* Return the total package length */ *obj_length = info.length; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_object_size @@ -645,25 +599,23 @@ acpi_ut_get_package_object_size ( ******************************************************************************/ acpi_status -acpi_ut_get_object_size ( - union acpi_operand_object *internal_object, - acpi_size *obj_length) +acpi_ut_get_object_size(union acpi_operand_object *internal_object, + acpi_size * obj_length) { - acpi_status status; - - - ACPI_FUNCTION_ENTRY (); - - - if ((ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_OPERAND) && - (ACPI_GET_OBJECT_TYPE (internal_object) == ACPI_TYPE_PACKAGE)) { - status = acpi_ut_get_package_object_size (internal_object, obj_length); - } - else { - status = acpi_ut_get_simple_object_size (internal_object, obj_length); + acpi_status status; + + ACPI_FUNCTION_ENTRY(); + + if ((ACPI_GET_DESCRIPTOR_TYPE(internal_object) == + ACPI_DESC_TYPE_OPERAND) + && (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE)) { + status = + acpi_ut_get_package_object_size(internal_object, + obj_length); + } else { + status = + acpi_ut_get_simple_object_size(internal_object, obj_length); } return (status); } - - diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c index 192e7ac..c1cb275 100644 --- a/drivers/acpi/utilities/utstate.c +++ b/drivers/acpi/utilities/utstate.c @@ -41,12 +41,10 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utstate") - +ACPI_MODULE_NAME("utstate") /******************************************************************************* * @@ -61,30 +59,26 @@ * DESCRIPTION: Create a new state and push it * ******************************************************************************/ - acpi_status -acpi_ut_create_pkg_state_and_push ( - void *internal_object, - void *external_object, - u16 index, - union acpi_generic_state **state_list) +acpi_ut_create_pkg_state_and_push(void *internal_object, + void *external_object, + u16 index, + union acpi_generic_state ** state_list) { - union acpi_generic_state *state; - + union acpi_generic_state *state; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); - - state = acpi_ut_create_pkg_state (internal_object, external_object, index); + state = + acpi_ut_create_pkg_state(internal_object, external_object, index); if (!state) { return (AE_NO_MEMORY); } - acpi_ut_push_generic_state (state_list, state); + acpi_ut_push_generic_state(state_list, state); return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ut_push_generic_state @@ -99,12 +93,10 @@ acpi_ut_create_pkg_state_and_push ( ******************************************************************************/ void -acpi_ut_push_generic_state ( - union acpi_generic_state **list_head, - union acpi_generic_state *state) +acpi_ut_push_generic_state(union acpi_generic_state **list_head, + union acpi_generic_state *state) { - ACPI_FUNCTION_TRACE ("ut_push_generic_state"); - + ACPI_FUNCTION_TRACE("ut_push_generic_state"); /* Push the state object onto the front of the list (stack) */ @@ -114,7 +106,6 @@ acpi_ut_push_generic_state ( return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_pop_generic_state @@ -127,15 +118,12 @@ acpi_ut_push_generic_state ( * ******************************************************************************/ -union acpi_generic_state * -acpi_ut_pop_generic_state ( - union acpi_generic_state **list_head) +union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state + **list_head) { - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE ("ut_pop_generic_state"); + union acpi_generic_state *state; + ACPI_FUNCTION_TRACE("ut_pop_generic_state"); /* Remove the state object at the head of the list (stack) */ @@ -146,10 +134,9 @@ acpi_ut_pop_generic_state ( *list_head = state->common.next; } - return_PTR (state); + return_PTR(state); } - /******************************************************************************* * * FUNCTION: acpi_ut_create_generic_state @@ -163,17 +150,13 @@ acpi_ut_pop_generic_state ( * ******************************************************************************/ -union acpi_generic_state * -acpi_ut_create_generic_state ( - void) +union acpi_generic_state *acpi_ut_create_generic_state(void) { - union acpi_generic_state *state; - + union acpi_generic_state *state; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); - - state = acpi_os_acquire_object (acpi_gbl_state_cache); + state = acpi_os_acquire_object(acpi_gbl_state_cache); if (state) { /* Initialize */ memset(state, 0, sizeof(union acpi_generic_state)); @@ -183,7 +166,6 @@ acpi_ut_create_generic_state ( return (state); } - /******************************************************************************* * * FUNCTION: acpi_ut_create_thread_state @@ -197,32 +179,27 @@ acpi_ut_create_generic_state ( * ******************************************************************************/ -struct acpi_thread_state * -acpi_ut_create_thread_state ( - void) +struct acpi_thread_state *acpi_ut_create_thread_state(void) { - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE ("ut_create_thread_state"); + union acpi_generic_state *state; + ACPI_FUNCTION_TRACE("ut_create_thread_state"); /* Create the generic state object */ - state = acpi_ut_create_generic_state (); + state = acpi_ut_create_generic_state(); if (!state) { - return_PTR (NULL); + return_PTR(NULL); } /* Init fields specific to the update struct */ state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD; - state->thread.thread_id = acpi_os_get_thread_id (); + state->thread.thread_id = acpi_os_get_thread_id(); - return_PTR ((struct acpi_thread_state *) state); + return_PTR((struct acpi_thread_state *)state); } - /******************************************************************************* * * FUNCTION: acpi_ut_create_update_state @@ -238,34 +215,29 @@ acpi_ut_create_thread_state ( * ******************************************************************************/ -union acpi_generic_state * -acpi_ut_create_update_state ( - union acpi_operand_object *object, - u16 action) +union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object + *object, u16 action) { - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object); + union acpi_generic_state *state; + ACPI_FUNCTION_TRACE_PTR("ut_create_update_state", object); /* Create the generic state object */ - state = acpi_ut_create_generic_state (); + state = acpi_ut_create_generic_state(); if (!state) { - return_PTR (NULL); + return_PTR(NULL); } /* Init fields specific to the update struct */ state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE; state->update.object = object; - state->update.value = action; + state->update.value = action; - return_PTR (state); + return_PTR(state); } - /******************************************************************************* * * FUNCTION: acpi_ut_create_pkg_state @@ -279,37 +251,32 @@ acpi_ut_create_update_state ( * ******************************************************************************/ -union acpi_generic_state * -acpi_ut_create_pkg_state ( - void *internal_object, - void *external_object, - u16 index) +union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object, + void *external_object, + u16 index) { - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object); + union acpi_generic_state *state; + ACPI_FUNCTION_TRACE_PTR("ut_create_pkg_state", internal_object); /* Create the generic state object */ - state = acpi_ut_create_generic_state (); + state = acpi_ut_create_generic_state(); if (!state) { - return_PTR (NULL); + return_PTR(NULL); } /* Init fields specific to the update struct */ state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE; - state->pkg.source_object = (union acpi_operand_object *) internal_object; - state->pkg.dest_object = external_object; - state->pkg.index = index; + state->pkg.source_object = (union acpi_operand_object *)internal_object; + state->pkg.dest_object = external_object; + state->pkg.index = index; state->pkg.num_packages = 1; - return_PTR (state); + return_PTR(state); } - /******************************************************************************* * * FUNCTION: acpi_ut_create_control_state @@ -323,32 +290,27 @@ acpi_ut_create_pkg_state ( * ******************************************************************************/ -union acpi_generic_state * -acpi_ut_create_control_state ( - void) +union acpi_generic_state *acpi_ut_create_control_state(void) { - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE ("ut_create_control_state"); + union acpi_generic_state *state; + ACPI_FUNCTION_TRACE("ut_create_control_state"); /* Create the generic state object */ - state = acpi_ut_create_generic_state (); + state = acpi_ut_create_generic_state(); if (!state) { - return_PTR (NULL); + return_PTR(NULL); } /* Init fields specific to the control struct */ state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL; - state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; + state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; - return_PTR (state); + return_PTR(state); } - /******************************************************************************* * * FUNCTION: acpi_ut_delete_generic_state @@ -362,15 +324,10 @@ acpi_ut_create_control_state ( * ******************************************************************************/ -void -acpi_ut_delete_generic_state ( - union acpi_generic_state *state) +void acpi_ut_delete_generic_state(union acpi_generic_state *state) { - ACPI_FUNCTION_TRACE ("ut_delete_generic_state"); + ACPI_FUNCTION_TRACE("ut_delete_generic_state"); - - (void) acpi_os_release_object (acpi_gbl_state_cache, state); + (void)acpi_os_release_object(acpi_gbl_state_cache, state); return_VOID; } - - diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c index 850da68..f06bd5e 100644 --- a/drivers/acpi/utilities/utxface.c +++ b/drivers/acpi/utilities/utxface.c @@ -49,8 +49,7 @@ #include #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utxface") - +ACPI_MODULE_NAME("utxface") /******************************************************************************* * @@ -64,60 +63,54 @@ * called, so any early initialization belongs here. * ******************************************************************************/ - -acpi_status -acpi_initialize_subsystem ( - void) +acpi_status acpi_initialize_subsystem(void) { - acpi_status status; - + acpi_status status; - ACPI_FUNCTION_TRACE ("acpi_initialize_subsystem"); + ACPI_FUNCTION_TRACE("acpi_initialize_subsystem"); - - ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ()); + ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace()); /* Initialize the OS-Dependent layer */ - status = acpi_os_initialize (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("OSD failed to initialize, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_os_initialize(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("OSD failed to initialize, %s\n", + acpi_format_exception(status))); + return_ACPI_STATUS(status); } /* Initialize all globals used by the subsystem */ - acpi_ut_init_globals (); + acpi_ut_init_globals(); /* Create the default mutex objects */ - status = acpi_ut_mutex_initialize (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Global mutex creation failure, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_ut_mutex_initialize(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Global mutex creation failure, %s\n", + acpi_format_exception(status))); + return_ACPI_STATUS(status); } /* * Initialize the namespace manager and * the root of the namespace tree */ - status = acpi_ns_root_initialize (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Namespace initialization failure, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_ns_root_initialize(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Namespace initialization failure, %s\n", + acpi_format_exception(status))); + return_ACPI_STATUS(status); } /* If configured, initialize the AML debugger */ - ACPI_DEBUGGER_EXEC (status = acpi_db_initialize ()); + ACPI_DEBUGGER_EXEC(status = acpi_db_initialize()); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_enable_subsystem @@ -131,41 +124,39 @@ acpi_initialize_subsystem ( * ******************************************************************************/ -acpi_status -acpi_enable_subsystem ( - u32 flags) +acpi_status acpi_enable_subsystem(u32 flags) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("acpi_enable_subsystem"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_enable_subsystem"); /* * We must initialize the hardware before we can enable ACPI. * The values from the FADT are validated here. */ if (!(flags & ACPI_NO_HARDWARE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Initializing ACPI hardware\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Initializing ACPI hardware\n")); - status = acpi_hw_initialize (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_initialize(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Enable ACPI mode */ if (!(flags & ACPI_NO_ACPI_ENABLE)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Going into ACPI mode\n")); acpi_gbl_original_mode = acpi_hw_get_mode(); - status = acpi_enable (); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_enable failed.\n")); - return_ACPI_STATUS (status); + status = acpi_enable(); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "acpi_enable failed.\n")); + return_ACPI_STATUS(status); } } @@ -175,12 +166,12 @@ acpi_enable_subsystem ( * install_address_space_handler interface. */ if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Installing default address space handlers\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Installing default address space handlers\n")); - status = acpi_ev_install_region_handlers (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ev_install_region_handlers(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -193,28 +184,28 @@ acpi_enable_subsystem ( * execution! */ if (!(flags & ACPI_NO_EVENT_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Initializing ACPI events\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Initializing ACPI events\n")); - status = acpi_ev_initialize_events (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ev_initialize_events(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Install the SCI handler and Global Lock handler */ if (!(flags & ACPI_NO_HANDLER_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Installing SCI/GL handlers\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Installing SCI/GL handlers\n")); - status = acpi_ev_install_xrupt_handlers (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ev_install_xrupt_handlers(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /******************************************************************************* @@ -230,15 +221,11 @@ acpi_enable_subsystem ( * ******************************************************************************/ -acpi_status -acpi_initialize_objects ( - u32 flags) +acpi_status acpi_initialize_objects(u32 flags) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("acpi_initialize_objects"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_initialize_objects"); /* * Run all _REG methods @@ -248,12 +235,12 @@ acpi_initialize_objects ( * contain executable AML (see call to acpi_ns_initialize_objects below). */ if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Executing _REG op_region methods\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Executing _REG op_region methods\n")); - status = acpi_ev_initialize_op_regions (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ev_initialize_op_regions(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -263,12 +250,12 @@ acpi_initialize_objects ( * objects: operation_regions, buffer_fields, Buffers, and Packages. */ if (!(flags & ACPI_NO_OBJECT_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Completing Initialization of ACPI Objects\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Completing Initialization of ACPI Objects\n")); - status = acpi_ns_initialize_objects (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ns_initialize_objects(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -277,12 +264,12 @@ acpi_initialize_objects ( * This runs the _STA and _INI methods. */ if (!(flags & ACPI_NO_DEVICE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Initializing ACPI Devices\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Initializing ACPI Devices\n")); - status = acpi_ns_initialize_devices (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ns_initialize_devices(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -291,13 +278,12 @@ acpi_initialize_objects ( * the table load filled them up more than they will be at runtime -- * thus wasting non-paged memory. */ - status = acpi_purge_cached_objects (); + status = acpi_purge_cached_objects(); acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_terminate @@ -310,15 +296,11 @@ acpi_initialize_objects ( * ******************************************************************************/ -acpi_status -acpi_terminate ( - void) +acpi_status acpi_terminate(void) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_terminate"); + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_terminate"); /* Terminate the AML Debugger if present */ @@ -326,28 +308,25 @@ acpi_terminate ( /* Shutdown and free all resources */ - acpi_ut_subsystem_shutdown (); - + acpi_ut_subsystem_shutdown(); /* Free the mutex objects */ - acpi_ut_mutex_terminate (); - + acpi_ut_mutex_terminate(); #ifdef ACPI_DEBUGGER /* Shut down the debugger */ - acpi_db_terminate (); + acpi_db_terminate(); #endif /* Now we can shutdown the OS-dependent layer */ - status = acpi_os_terminate (); - return_ACPI_STATUS (status); + status = acpi_os_terminate(); + return_ACPI_STATUS(status); } - #ifdef ACPI_FUTURE_USAGE /******************************************************************************* * @@ -363,20 +342,16 @@ acpi_terminate ( * ******************************************************************************/ -acpi_status -acpi_subsystem_status ( - void) +acpi_status acpi_subsystem_status(void) { if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) { return (AE_OK); - } - else { + } else { return (AE_ERROR); } } - /******************************************************************************* * * FUNCTION: acpi_get_system_info @@ -395,64 +370,60 @@ acpi_subsystem_status ( * ******************************************************************************/ -acpi_status -acpi_get_system_info ( - struct acpi_buffer *out_buffer) +acpi_status acpi_get_system_info(struct acpi_buffer * out_buffer) { - struct acpi_system_info *info_ptr; - acpi_status status; - u32 i; - - - ACPI_FUNCTION_TRACE ("acpi_get_system_info"); + struct acpi_system_info *info_ptr; + acpi_status status; + u32 i; + ACPI_FUNCTION_TRACE("acpi_get_system_info"); /* Parameter validation */ - status = acpi_ut_validate_buffer (out_buffer); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_validate_buffer(out_buffer); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Validate/Allocate/Clear caller buffer */ - status = acpi_ut_initialize_buffer (out_buffer, sizeof (struct acpi_system_info)); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ut_initialize_buffer(out_buffer, + sizeof(struct acpi_system_info)); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* * Populate the return buffer */ - info_ptr = (struct acpi_system_info *) out_buffer->pointer; + info_ptr = (struct acpi_system_info *)out_buffer->pointer; - info_ptr->acpi_ca_version = ACPI_CA_VERSION; + info_ptr->acpi_ca_version = ACPI_CA_VERSION; /* System flags (ACPI capabilities) */ - info_ptr->flags = ACPI_SYS_MODE_ACPI; + info_ptr->flags = ACPI_SYS_MODE_ACPI; /* Timer resolution - 24 or 32 bits */ if (!acpi_gbl_FADT) { info_ptr->timer_resolution = 0; - } - else if (acpi_gbl_FADT->tmr_val_ext == 0) { + } else if (acpi_gbl_FADT->tmr_val_ext == 0) { info_ptr->timer_resolution = 24; - } - else { + } else { info_ptr->timer_resolution = 32; } /* Clear the reserved fields */ - info_ptr->reserved1 = 0; - info_ptr->reserved2 = 0; + info_ptr->reserved1 = 0; + info_ptr->reserved2 = 0; /* Current debug levels */ - info_ptr->debug_layer = acpi_dbg_layer; - info_ptr->debug_level = acpi_dbg_level; + info_ptr->debug_layer = acpi_dbg_layer; + info_ptr->debug_level = acpi_dbg_level; /* Current status of the ACPI tables, per table type */ @@ -461,10 +432,10 @@ acpi_get_system_info ( info_ptr->table_info[i].count = acpi_gbl_table_lists[i].count; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_get_system_info); +EXPORT_SYMBOL(acpi_get_system_info); /***************************************************************************** * @@ -482,9 +453,7 @@ EXPORT_SYMBOL(acpi_get_system_info); ****************************************************************************/ acpi_status -acpi_install_initialization_handler ( - acpi_init_handler handler, - u32 function) +acpi_install_initialization_handler(acpi_init_handler handler, u32 function) { if (!handler) { @@ -499,7 +468,7 @@ acpi_install_initialization_handler ( return AE_OK; } -#endif /* ACPI_FUTURE_USAGE */ +#endif /* ACPI_FUTURE_USAGE */ /***************************************************************************** * @@ -513,15 +482,13 @@ acpi_install_initialization_handler ( * ****************************************************************************/ -acpi_status -acpi_purge_cached_objects ( - void) +acpi_status acpi_purge_cached_objects(void) { - ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects"); + ACPI_FUNCTION_TRACE("acpi_purge_cached_objects"); - (void) acpi_os_purge_cache (acpi_gbl_state_cache); - (void) acpi_os_purge_cache (acpi_gbl_operand_cache); - (void) acpi_os_purge_cache (acpi_gbl_ps_node_cache); - (void) acpi_os_purge_cache (acpi_gbl_ps_node_ext_cache); - return_ACPI_STATUS (AE_OK); + (void)acpi_os_purge_cache(acpi_gbl_state_cache); + (void)acpi_os_purge_cache(acpi_gbl_operand_cache); + (void)acpi_os_purge_cache(acpi_gbl_ps_node_cache); + (void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache); + return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 1ce2047..6458c47 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -30,15 +30,12 @@ #include #include - #define _COMPONENT ACPI_BUS_COMPONENT -ACPI_MODULE_NAME ("acpi_utils") - +ACPI_MODULE_NAME("acpi_utils") /* -------------------------------------------------------------------------- Object Evaluation Helpers -------------------------------------------------------------------------- */ - #ifdef ACPI_DEBUG_OUTPUT #define acpi_util_eval_error(h,p,s) {\ char prefix[80] = {'\0'};\ @@ -49,26 +46,24 @@ ACPI_MODULE_NAME ("acpi_utils") #else #define acpi_util_eval_error(h,p,s) #endif - - acpi_status -acpi_extract_package ( - union acpi_object *package, - struct acpi_buffer *format, - struct acpi_buffer *buffer) +acpi_extract_package(union acpi_object *package, + struct acpi_buffer *format, struct acpi_buffer *buffer) { - u32 size_required = 0; - u32 tail_offset = 0; - char *format_string = NULL; - u32 format_count = 0; - u32 i = 0; - u8 *head = NULL; - u8 *tail = NULL; + u32 size_required = 0; + u32 tail_offset = 0; + char *format_string = NULL; + u32 format_count = 0; + u32 i = 0; + u8 *head = NULL; + u8 *tail = NULL; ACPI_FUNCTION_TRACE("acpi_extract_package"); - if (!package || (package->type != ACPI_TYPE_PACKAGE) || (package->package.count < 1)) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'package' argument\n")); + if (!package || (package->type != ACPI_TYPE_PACKAGE) + || (package->package.count < 1)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid 'package' argument\n")); return_ACPI_STATUS(AE_BAD_PARAMETER); } @@ -82,18 +77,20 @@ acpi_extract_package ( return_ACPI_STATUS(AE_BAD_PARAMETER); } - format_count = (format->length/sizeof(char)) - 1; + format_count = (format->length / sizeof(char)) - 1; if (format_count > package->package.count) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Format specifies more objects [%d] than exist in package [%d].", format_count, package->package.count)); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Format specifies more objects [%d] than exist in package [%d].", + format_count, package->package.count)); return_ACPI_STATUS(AE_BAD_DATA); } - format_string = (char*)format->pointer; + format_string = (char *)format->pointer; /* * Calculate size_required. */ - for (i=0; ipackage.elements[i]); @@ -110,11 +107,15 @@ acpi_extract_package ( tail_offset += sizeof(acpi_integer); break; case 'S': - size_required += sizeof(char*) + sizeof(acpi_integer) + sizeof(char); - tail_offset += sizeof(char*); + size_required += + sizeof(char *) + sizeof(acpi_integer) + + sizeof(char); + tail_offset += sizeof(char *); break; default: - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d]: got number, expecing [%c].\n", i, format_string[i])); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid package element [%d]: got number, expecing [%c].\n", + i, format_string[i])); return_ACPI_STATUS(AE_BAD_DATA); break; } @@ -124,15 +125,22 @@ acpi_extract_package ( case ACPI_TYPE_BUFFER: switch (format_string[i]) { case 'S': - size_required += sizeof(char*) + (element->string.length * sizeof(char)) + sizeof(char); - tail_offset += sizeof(char*); + size_required += + sizeof(char *) + + (element->string.length * sizeof(char)) + + sizeof(char); + tail_offset += sizeof(char *); break; case 'B': - size_required += sizeof(u8*) + (element->buffer.length * sizeof(u8)); - tail_offset += sizeof(u8*); + size_required += + sizeof(u8 *) + + (element->buffer.length * sizeof(u8)); + tail_offset += sizeof(u8 *); break; default: - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d] got string/buffer, expecing [%c].\n", i, format_string[i])); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid package element [%d] got string/buffer, expecing [%c].\n", + i, format_string[i])); return_ACPI_STATUS(AE_BAD_DATA); break; } @@ -140,7 +148,9 @@ acpi_extract_package ( case ACPI_TYPE_PACKAGE: default: - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unsupported element at index=%d\n", i)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Found unsupported element at index=%d\n", + i)); /* TBD: handle nested packages... */ return_ACPI_STATUS(AE_SUPPORT); break; @@ -153,8 +163,7 @@ acpi_extract_package ( if (buffer->length < size_required) { buffer->length = size_required; return_ACPI_STATUS(AE_BUFFER_OVERFLOW); - } - else if (buffer->length != size_required || !buffer->pointer) { + } else if (buffer->length != size_required || !buffer->pointer) { return_ACPI_STATUS(AE_BAD_PARAMETER); } @@ -164,7 +173,7 @@ acpi_extract_package ( /* * Extract package data. */ - for (i=0; ipackage.elements[i]); @@ -178,14 +187,16 @@ acpi_extract_package ( case ACPI_TYPE_INTEGER: switch (format_string[i]) { case 'N': - *((acpi_integer*)head) = element->integer.value; + *((acpi_integer *) head) = + element->integer.value; head += sizeof(acpi_integer); break; case 'S': - pointer = (u8**)head; + pointer = (u8 **) head; *pointer = tail; - *((acpi_integer*)tail) = element->integer.value; - head += sizeof(acpi_integer*); + *((acpi_integer *) tail) = + element->integer.value; + head += sizeof(acpi_integer *); tail += sizeof(acpi_integer); /* NULL terminate string */ *tail = (char)0; @@ -201,20 +212,22 @@ acpi_extract_package ( case ACPI_TYPE_BUFFER: switch (format_string[i]) { case 'S': - pointer = (u8**)head; + pointer = (u8 **) head; *pointer = tail; - memcpy(tail, element->string.pointer, element->string.length); - head += sizeof(char*); + memcpy(tail, element->string.pointer, + element->string.length); + head += sizeof(char *); tail += element->string.length * sizeof(char); /* NULL terminate string */ *tail = (char)0; tail += sizeof(char); break; case 'B': - pointer = (u8**)head; + pointer = (u8 **) head; *pointer = tail; - memcpy(tail, element->buffer.pointer, element->buffer.length); - head += sizeof(u8*); + memcpy(tail, element->buffer.pointer, + element->buffer.length); + head += sizeof(u8 *); tail += element->buffer.length * sizeof(u8); break; default: @@ -233,19 +246,17 @@ acpi_extract_package ( return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_extract_package); +EXPORT_SYMBOL(acpi_extract_package); acpi_status -acpi_evaluate_integer ( - acpi_handle handle, - acpi_string pathname, - struct acpi_object_list *arguments, - unsigned long *data) +acpi_evaluate_integer(acpi_handle handle, + acpi_string pathname, + struct acpi_object_list *arguments, unsigned long *data) { - acpi_status status = AE_OK; - union acpi_object *element; - struct acpi_buffer buffer = {0,NULL}; + acpi_status status = AE_OK; + union acpi_object *element; + struct acpi_buffer buffer = { 0, NULL }; ACPI_FUNCTION_TRACE("acpi_evaluate_integer"); @@ -253,7 +264,7 @@ acpi_evaluate_integer ( return_ACPI_STATUS(AE_BAD_PARAMETER); element = kmalloc(sizeof(union acpi_object), GFP_KERNEL); - if(!element) + if (!element) return_ACPI_STATUS(AE_NO_MEMORY); memset(element, 0, sizeof(union acpi_object)); @@ -277,20 +288,18 @@ acpi_evaluate_integer ( return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_evaluate_integer); +EXPORT_SYMBOL(acpi_evaluate_integer); #if 0 acpi_status -acpi_evaluate_string ( - acpi_handle handle, - acpi_string pathname, - acpi_object_list *arguments, - acpi_string *data) +acpi_evaluate_string(acpi_handle handle, + acpi_string pathname, + acpi_object_list * arguments, acpi_string * data) { - acpi_status status = AE_OK; - acpi_object *element = NULL; - acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; + acpi_status status = AE_OK; + acpi_object *element = NULL; + acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; ACPI_FUNCTION_TRACE("acpi_evaluate_string"); @@ -305,9 +314,9 @@ acpi_evaluate_string ( element = (acpi_object *) buffer.pointer; - if ((element->type != ACPI_TYPE_STRING) - || (element->type != ACPI_TYPE_BUFFER) - || !element->string.length) { + if ((element->type != ACPI_TYPE_STRING) + || (element->type != ACPI_TYPE_BUFFER) + || !element->string.length) { acpi_util_eval_error(handle, pathname, AE_BAD_DATA); return_ACPI_STATUS(AE_BAD_DATA); } @@ -329,19 +338,17 @@ acpi_evaluate_string ( } #endif - acpi_status -acpi_evaluate_reference ( - acpi_handle handle, - acpi_string pathname, - struct acpi_object_list *arguments, - struct acpi_handle_list *list) +acpi_evaluate_reference(acpi_handle handle, + acpi_string pathname, + struct acpi_object_list *arguments, + struct acpi_handle_list *list) { - acpi_status status = AE_OK; - union acpi_object *package = NULL; - union acpi_object *element = NULL; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - u32 i = 0; + acpi_status status = AE_OK; + union acpi_object *package = NULL; + union acpi_object *element = NULL; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + u32 i = 0; ACPI_FUNCTION_TRACE("acpi_evaluate_reference"); @@ -355,28 +362,28 @@ acpi_evaluate_reference ( if (ACPI_FAILURE(status)) goto end; - package = (union acpi_object *) buffer.pointer; + package = (union acpi_object *)buffer.pointer; if ((buffer.length == 0) || !package) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No return object (len %X ptr %p)\n", - (unsigned)buffer.length, package)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No return object (len %X ptr %p)\n", + (unsigned)buffer.length, package)); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; } if (package->type != ACPI_TYPE_PACKAGE) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Expecting a [Package], found type %X\n", - package->type)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Expecting a [Package], found type %X\n", + package->type)); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; } if (!package->package.count) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "[Package] has zero elements (%p)\n", - package)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "[Package] has zero elements (%p)\n", + package)); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; @@ -395,9 +402,9 @@ acpi_evaluate_reference ( if (element->type != ACPI_TYPE_ANY) { status = AE_BAD_DATA; - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Expecting a [Reference] package element, found type %X\n", - element->type)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Expecting a [Reference] package element, found type %X\n", + element->type)); acpi_util_eval_error(handle, pathname, status); break; } @@ -406,10 +413,10 @@ acpi_evaluate_reference ( list->handles[i] = element->reference.handle; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n", - list->handles[i])); + list->handles[i])); } -end: + end: if (ACPI_FAILURE(status)) { list->count = 0; //kfree(list->handles); @@ -419,5 +426,5 @@ end: return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_evaluate_reference); +EXPORT_SYMBOL(acpi_evaluate_reference); diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 7b10a7b..b9132b5 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -53,21 +53,20 @@ #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85 #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86 - #define ACPI_VIDEO_HEAD_INVALID (~0u - 1) #define ACPI_VIDEO_HEAD_END (~0u) - #define _COMPONENT ACPI_VIDEO_COMPONENT -ACPI_MODULE_NAME ("acpi_video") +ACPI_MODULE_NAME("acpi_video") -MODULE_AUTHOR("Bruno Ducrot"); + MODULE_AUTHOR("Bruno Ducrot"); MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME); MODULE_LICENSE("GPL"); -static int acpi_video_bus_add (struct acpi_device *device); -static int acpi_video_bus_remove (struct acpi_device *device, int type); -static int acpi_video_bus_match (struct acpi_device *device, struct acpi_driver *driver); +static int acpi_video_bus_add(struct acpi_device *device); +static int acpi_video_bus_remove(struct acpi_device *device, int type); +static int acpi_video_bus_match(struct acpi_device *device, + struct acpi_driver *driver); static struct acpi_driver acpi_video_bus = { .name = ACPI_VIDEO_DRIVER_NAME, @@ -76,187 +75,192 @@ static struct acpi_driver acpi_video_bus = { .add = acpi_video_bus_add, .remove = acpi_video_bus_remove, .match = acpi_video_bus_match, - }, + }, }; struct acpi_video_bus_flags { - u8 multihead:1; /* can switch video heads */ - u8 rom:1; /* can retrieve a video rom */ - u8 post:1; /* can configure the head to */ - u8 reserved:5; + u8 multihead:1; /* can switch video heads */ + u8 rom:1; /* can retrieve a video rom */ + u8 post:1; /* can configure the head to */ + u8 reserved:5; }; struct acpi_video_bus_cap { - u8 _DOS:1; /*Enable/Disable output switching*/ - u8 _DOD:1; /*Enumerate all devices attached to display adapter*/ - u8 _ROM:1; /*Get ROM Data*/ - u8 _GPD:1; /*Get POST Device*/ - u8 _SPD:1; /*Set POST Device*/ - u8 _VPO:1; /*Video POST Options*/ - u8 reserved:2; + u8 _DOS:1; /*Enable/Disable output switching */ + u8 _DOD:1; /*Enumerate all devices attached to display adapter */ + u8 _ROM:1; /*Get ROM Data */ + u8 _GPD:1; /*Get POST Device */ + u8 _SPD:1; /*Set POST Device */ + u8 _VPO:1; /*Video POST Options */ + u8 reserved:2; }; -struct acpi_video_device_attrib{ - u32 display_index:4; /* A zero-based instance of the Display*/ - u32 display_port_attachment:4; /*This field differenates displays type*/ - u32 display_type:4; /*Describe the specific type in use*/ - u32 vendor_specific:4; /*Chipset Vendor Specifi*/ - u32 bios_can_detect:1; /*BIOS can detect the device*/ - u32 depend_on_vga:1; /*Non-VGA output device whose power is related to - the VGA device.*/ - u32 pipe_id:3; /*For VGA multiple-head devices.*/ - u32 reserved:10; /*Must be 0*/ - u32 device_id_scheme:1; /*Device ID Scheme*/ +struct acpi_video_device_attrib { + u32 display_index:4; /* A zero-based instance of the Display */ + u32 display_port_attachment:4; /*This field differenates displays type */ + u32 display_type:4; /*Describe the specific type in use */ + u32 vendor_specific:4; /*Chipset Vendor Specifi */ + u32 bios_can_detect:1; /*BIOS can detect the device */ + u32 depend_on_vga:1; /*Non-VGA output device whose power is related to + the VGA device. */ + u32 pipe_id:3; /*For VGA multiple-head devices. */ + u32 reserved:10; /*Must be 0 */ + u32 device_id_scheme:1; /*Device ID Scheme */ }; struct acpi_video_enumerated_device { union { u32 int_val; - struct acpi_video_device_attrib attrib; + struct acpi_video_device_attrib attrib; } value; struct acpi_video_device *bind_info; }; struct acpi_video_bus { - acpi_handle handle; - u8 dos_setting; + acpi_handle handle; + u8 dos_setting; struct acpi_video_enumerated_device *attached_array; - u8 attached_count; - struct acpi_video_bus_cap cap; + u8 attached_count; + struct acpi_video_bus_cap cap; struct acpi_video_bus_flags flags; - struct semaphore sem; - struct list_head video_device_list; - struct proc_dir_entry *dir; + struct semaphore sem; + struct list_head video_device_list; + struct proc_dir_entry *dir; }; struct acpi_video_device_flags { - u8 crt:1; - u8 lcd:1; - u8 tvout:1; - u8 bios:1; - u8 unknown:1; - u8 reserved:3; + u8 crt:1; + u8 lcd:1; + u8 tvout:1; + u8 bios:1; + u8 unknown:1; + u8 reserved:3; }; struct acpi_video_device_cap { - u8 _ADR:1; /*Return the unique ID */ - u8 _BCL:1; /*Query list of brightness control levels supported*/ - u8 _BCM:1; /*Set the brightness level*/ - u8 _DDC:1; /*Return the EDID for this device*/ - u8 _DCS:1; /*Return status of output device*/ - u8 _DGS:1; /*Query graphics state*/ - u8 _DSS:1; /*Device state set*/ - u8 _reserved:1; + u8 _ADR:1; /*Return the unique ID */ + u8 _BCL:1; /*Query list of brightness control levels supported */ + u8 _BCM:1; /*Set the brightness level */ + u8 _DDC:1; /*Return the EDID for this device */ + u8 _DCS:1; /*Return status of output device */ + u8 _DGS:1; /*Query graphics state */ + u8 _DSS:1; /*Device state set */ + u8 _reserved:1; }; struct acpi_video_device_brightness { - int curr; - int count; - int *levels; + int curr; + int count; + int *levels; }; struct acpi_video_device { - acpi_handle handle; - unsigned long device_id; - struct acpi_video_device_flags flags; - struct acpi_video_device_cap cap; - struct list_head entry; - struct acpi_video_bus *video; - struct acpi_device *dev; + acpi_handle handle; + unsigned long device_id; + struct acpi_video_device_flags flags; + struct acpi_video_device_cap cap; + struct list_head entry; + struct acpi_video_bus *video; + struct acpi_device *dev; struct acpi_video_device_brightness *brightness; }; - /* bus */ static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_bus_info_fops = { - .open = acpi_video_bus_info_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_video_bus_info_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_bus_ROM_fops = { - .open = acpi_video_bus_ROM_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_video_bus_ROM_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; -static int acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file); +static int acpi_video_bus_POST_info_open_fs(struct inode *inode, + struct file *file); static struct file_operations acpi_video_bus_POST_info_fops = { - .open = acpi_video_bus_POST_info_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_video_bus_POST_info_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_bus_POST_fops = { - .open = acpi_video_bus_POST_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_video_bus_POST_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; - static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_bus_DOS_fops = { - .open = acpi_video_bus_DOS_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_video_bus_DOS_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; /* device */ -static int acpi_video_device_info_open_fs(struct inode *inode, struct file *file); +static int acpi_video_device_info_open_fs(struct inode *inode, + struct file *file); static struct file_operations acpi_video_device_info_fops = { - .open = acpi_video_device_info_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_video_device_info_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; -static int acpi_video_device_state_open_fs(struct inode *inode, struct file *file); +static int acpi_video_device_state_open_fs(struct inode *inode, + struct file *file); static struct file_operations acpi_video_device_state_fops = { - .open = acpi_video_device_state_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_video_device_state_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; -static int acpi_video_device_brightness_open_fs(struct inode *inode, struct file *file); +static int acpi_video_device_brightness_open_fs(struct inode *inode, + struct file *file); static struct file_operations acpi_video_device_brightness_fops = { - .open = acpi_video_device_brightness_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_video_device_brightness_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; -static int acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file); +static int acpi_video_device_EDID_open_fs(struct inode *inode, + struct file *file); static struct file_operations acpi_video_device_EDID_fops = { - .open = acpi_video_device_EDID_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_video_device_EDID_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; -static char device_decode[][30] = { +static char device_decode[][30] = { "motherboard VGA device", "PCI VGA device", "AGP VGA device", "UNKNOWN", }; -static void acpi_video_device_notify ( acpi_handle handle, u32 event, void *data); -static void acpi_video_device_rebind( struct acpi_video_bus *video); -static void acpi_video_device_bind( struct acpi_video_bus *video, struct acpi_video_device *device); +static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data); +static void acpi_video_device_rebind(struct acpi_video_bus *video); +static void acpi_video_device_bind(struct acpi_video_bus *video, + struct acpi_video_device *device); static int acpi_video_device_enumerate(struct acpi_video_bus *video); -static int acpi_video_switch_output( struct acpi_video_bus *video, int event); -static int acpi_video_get_next_level( struct acpi_video_device *device, u32 level_current,u32 event); -static void acpi_video_switch_brightness ( struct acpi_video_device *device, int event); - +static int acpi_video_switch_output(struct acpi_video_bus *video, int event); +static int acpi_video_get_next_level(struct acpi_video_device *device, + u32 level_current, u32 event); +static void acpi_video_switch_brightness(struct acpi_video_device *device, + int event); /* -------------------------------------------------------------------------- Video Management @@ -265,11 +269,9 @@ static void acpi_video_switch_brightness ( struct acpi_video_device *device, int /* device */ static int -acpi_video_device_query ( - struct acpi_video_device *device, - unsigned long *state) +acpi_video_device_query(struct acpi_video_device *device, unsigned long *state) { - int status; + int status; ACPI_FUNCTION_TRACE("acpi_video_device_query"); status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state); @@ -277,11 +279,10 @@ acpi_video_device_query ( } static int -acpi_video_device_get_state ( - struct acpi_video_device *device, - unsigned long *state) +acpi_video_device_get_state(struct acpi_video_device *device, + unsigned long *state) { - int status; + int status; ACPI_FUNCTION_TRACE("acpi_video_device_get_state"); @@ -291,13 +292,11 @@ acpi_video_device_get_state ( } static int -acpi_video_device_set_state ( - struct acpi_video_device *device, - int state) +acpi_video_device_set_state(struct acpi_video_device *device, int state) { - int status; - union acpi_object arg0 = {ACPI_TYPE_INTEGER}; - struct acpi_object_list args = {1, &arg0}; + int status; + union acpi_object arg0 = { ACPI_TYPE_INTEGER }; + struct acpi_object_list args = { 1, &arg0 }; ACPI_FUNCTION_TRACE("acpi_video_device_set_state"); @@ -308,14 +307,12 @@ acpi_video_device_set_state ( } static int -acpi_video_device_lcd_query_levels ( - struct acpi_video_device *device, - union acpi_object **levels) +acpi_video_device_lcd_query_levels(struct acpi_video_device *device, + union acpi_object **levels) { - int status; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - union acpi_object *obj; - + int status; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *obj; ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels"); @@ -324,7 +321,7 @@ acpi_video_device_lcd_query_levels ( status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer); if (!ACPI_SUCCESS(status)) return_VALUE(status); - obj = (union acpi_object *) buffer.pointer; + obj = (union acpi_object *)buffer.pointer; if (!obj && (obj->type != ACPI_TYPE_PACKAGE)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n")); status = -EFAULT; @@ -335,7 +332,7 @@ acpi_video_device_lcd_query_levels ( return_VALUE(0); -err: + err: if (buffer.pointer) kfree(buffer.pointer); @@ -343,13 +340,11 @@ err: } static int -acpi_video_device_lcd_set_level ( - struct acpi_video_device *device, - int level) +acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level) { - int status; - union acpi_object arg0 = {ACPI_TYPE_INTEGER}; - struct acpi_object_list args = {1, &arg0}; + int status; + union acpi_object arg0 = { ACPI_TYPE_INTEGER }; + struct acpi_object_list args = { 1, &arg0 }; ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level"); @@ -361,11 +356,10 @@ acpi_video_device_lcd_set_level ( } static int -acpi_video_device_lcd_get_level_current ( - struct acpi_video_device *device, - unsigned long *level) +acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, + unsigned long *level) { - int status; + int status; ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current"); status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level); @@ -374,16 +368,14 @@ acpi_video_device_lcd_get_level_current ( } static int -acpi_video_device_EDID ( - struct acpi_video_device *device, - union acpi_object **edid, - ssize_t length) +acpi_video_device_EDID(struct acpi_video_device *device, + union acpi_object **edid, ssize_t length) { - int status; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - union acpi_object *obj; - union acpi_object arg0 = {ACPI_TYPE_INTEGER}; - struct acpi_object_list args = {1, &arg0}; + int status; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *obj; + union acpi_object arg0 = { ACPI_TYPE_INTEGER }; + struct acpi_object_list args = { 1, &arg0 }; ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID"); @@ -402,7 +394,7 @@ acpi_video_device_EDID ( if (ACPI_FAILURE(status)) return_VALUE(-ENODEV); - obj = (union acpi_object *) buffer.pointer; + obj = (union acpi_object *)buffer.pointer; if (obj && obj->type == ACPI_TYPE_BUFFER) *edid = obj; @@ -415,18 +407,15 @@ acpi_video_device_EDID ( return_VALUE(status); } - /* bus */ static int -acpi_video_bus_set_POST ( - struct acpi_video_bus *video, - unsigned long option) +acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option) { - int status; - unsigned long tmp; - union acpi_object arg0 = {ACPI_TYPE_INTEGER}; - struct acpi_object_list args = {1, &arg0}; + int status; + unsigned long tmp; + union acpi_object arg0 = { ACPI_TYPE_INTEGER }; + struct acpi_object_list args = { 1, &arg0 }; ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST"); @@ -434,15 +423,13 @@ acpi_video_bus_set_POST ( status = acpi_evaluate_integer(video->handle, "_SPD", &args, &tmp); if (ACPI_SUCCESS(status)) - status = tmp ? (-EINVAL):(AE_OK); + status = tmp ? (-EINVAL) : (AE_OK); return_VALUE(status); } static int -acpi_video_bus_get_POST ( - struct acpi_video_bus *video, - unsigned long *id) +acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id) { int status; @@ -454,11 +441,10 @@ acpi_video_bus_get_POST ( } static int -acpi_video_bus_POST_options ( - struct acpi_video_bus *video, - unsigned long *options) +acpi_video_bus_POST_options(struct acpi_video_bus *video, + unsigned long *options) { - int status; + int status; ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options"); status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options); @@ -489,18 +475,15 @@ acpi_video_bus_POST_options ( */ static int -acpi_video_bus_DOS( - struct acpi_video_bus *video, - int bios_flag, - int lcd_flag) +acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) { - acpi_integer status = 0; - union acpi_object arg0 = {ACPI_TYPE_INTEGER}; - struct acpi_object_list args = {1, &arg0}; + acpi_integer status = 0; + union acpi_object arg0 = { ACPI_TYPE_INTEGER }; + struct acpi_object_list args = { 1, &arg0 }; ACPI_FUNCTION_TRACE("acpi_video_bus_DOS"); - if (bios_flag < 0 || bios_flag >3 || lcd_flag < 0 || lcd_flag > 1){ + if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) { status = -1; goto Failed; } @@ -508,7 +491,7 @@ acpi_video_bus_DOS( video->dos_setting = arg0.integer.value; acpi_evaluate_object(video->handle, "_DOS", &args, NULL); -Failed: + Failed: return_VALUE(status); } @@ -523,10 +506,9 @@ Failed: * device. */ -static void -acpi_video_device_find_cap (struct acpi_video_device *device) +static void acpi_video_device_find_cap(struct acpi_video_device *device) { - acpi_integer status; + acpi_integer status; acpi_handle h_dummy1; int i; union acpi_object *obj = NULL; @@ -534,27 +516,27 @@ acpi_video_device_find_cap (struct acpi_video_device *device) ACPI_FUNCTION_TRACE("acpi_video_device_find_cap"); - memset( &device->cap, 0, 4); + memset(&device->cap, 0, 4); - if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) { device->cap._ADR = 1; } - if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCL", &h_dummy1))) { - device->cap._BCL= 1; + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCL", &h_dummy1))) { + device->cap._BCL = 1; } - if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCM", &h_dummy1))) { - device->cap._BCM= 1; + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCM", &h_dummy1))) { + device->cap._BCM = 1; } - if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DDC", &h_dummy1))) { - device->cap._DDC= 1; + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DDC", &h_dummy1))) { + device->cap._DDC = 1; } - if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DCS", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DCS", &h_dummy1))) { device->cap._DCS = 1; } - if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DGS", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DGS", &h_dummy1))) { device->cap._DGS = 1; } - if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DSS", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DSS", &h_dummy1))) { device->cap._DSS = 1; } @@ -563,34 +545,38 @@ acpi_video_device_find_cap (struct acpi_video_device *device) if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) { int count = 0; union acpi_object *o; - + br = kmalloc(sizeof(*br), GFP_KERNEL); if (!br) { printk(KERN_ERR "can't allocate memory\n"); } else { memset(br, 0, sizeof(*br)); br->levels = kmalloc(obj->package.count * - sizeof *(br->levels), GFP_KERNEL); + sizeof *(br->levels), GFP_KERNEL); if (!br->levels) goto out; for (i = 0; i < obj->package.count; i++) { - o = (union acpi_object *) &obj->package.elements[i]; + o = (union acpi_object *)&obj->package. + elements[i]; if (o->type != ACPI_TYPE_INTEGER) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid data\n")); continue; } br->levels[count] = (u32) o->integer.value; count++; } -out: + out: if (count < 2) { kfree(br->levels); kfree(br); } else { br->count = count; device->brightness = br; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "found %d brightness levels\n", count)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "found %d brightness levels\n", + count)); } } } @@ -610,28 +596,27 @@ out: * Find out all required AML method defined under the video bus device. */ -static void -acpi_video_bus_find_cap (struct acpi_video_bus *video) +static void acpi_video_bus_find_cap(struct acpi_video_bus *video) { - acpi_handle h_dummy1; + acpi_handle h_dummy1; - memset(&video->cap ,0, 4); - if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOS", &h_dummy1))) { + memset(&video->cap, 0, 4); + if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOS", &h_dummy1))) { video->cap._DOS = 1; } - if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOD", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOD", &h_dummy1))) { video->cap._DOD = 1; } - if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_ROM", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_ROM", &h_dummy1))) { video->cap._ROM = 1; } - if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_GPD", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_GPD", &h_dummy1))) { video->cap._GPD = 1; } - if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_SPD", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_SPD", &h_dummy1))) { video->cap._SPD = 1; } - if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_VPO", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_VPO", &h_dummy1))) { video->cap._VPO = 1; } } @@ -641,12 +626,9 @@ acpi_video_bus_find_cap (struct acpi_video_bus *video) * support the desired features */ -static int -acpi_video_bus_check ( - struct acpi_video_bus *video) +static int acpi_video_bus_check(struct acpi_video_bus *video) { - acpi_status status = -ENOENT; - + acpi_status status = -ENOENT; ACPI_FUNCTION_TRACE("acpi_video_bus_check"); @@ -658,19 +640,19 @@ acpi_video_bus_check ( */ /* Does this device able to support video switching ? */ - if(video->cap._DOS){ + if (video->cap._DOS) { video->flags.multihead = 1; status = 0; } /* Does this device able to retrieve a retrieve a video ROM ? */ - if(video->cap._ROM){ + if (video->cap._ROM) { video->flags.rom = 1; status = 0; } /* Does this device able to configure which video device to POST ? */ - if(video->cap._GPD && video->cap._SPD && video->cap._VPO){ + if (video->cap._GPD && video->cap._SPD && video->cap._VPO) { video->flags.post = 1; status = 0; } @@ -682,16 +664,14 @@ acpi_video_bus_check ( FS Interface (/proc) -------------------------------------------------------------------------- */ -static struct proc_dir_entry *acpi_video_dir; +static struct proc_dir_entry *acpi_video_dir; /* video devices */ -static int -acpi_video_device_info_seq_show ( - struct seq_file *seq, - void *offset) +static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset) { - struct acpi_video_device *dev = (struct acpi_video_device *) seq->private; + struct acpi_video_device *dev = + (struct acpi_video_device *)seq->private; ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show"); @@ -709,30 +689,25 @@ acpi_video_device_info_seq_show ( else seq_printf(seq, "UNKNOWN\n"); - seq_printf(seq,"known by bios: %s\n", - dev->flags.bios ? "yes":"no"); + seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no"); -end: + end: return_VALUE(0); } static int -acpi_video_device_info_open_fs ( - struct inode *inode, - struct file *file) +acpi_video_device_info_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_video_device_info_seq_show, PDE(inode)->data); } -static int -acpi_video_device_state_seq_show ( - struct seq_file *seq, - void *offset) +static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset) { - int status; - struct acpi_video_device *dev = (struct acpi_video_device *) seq->private; - unsigned long state; + int status; + struct acpi_video_device *dev = + (struct acpi_video_device *)seq->private; + unsigned long state; ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show"); @@ -753,31 +728,27 @@ acpi_video_device_state_seq_show ( else seq_printf(seq, "\n"); -end: + end: return_VALUE(0); } static int -acpi_video_device_state_open_fs ( - struct inode *inode, - struct file *file) +acpi_video_device_state_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_video_device_state_seq_show, PDE(inode)->data); } static ssize_t -acpi_video_device_write_state ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *data) +acpi_video_device_write_state(struct file *file, + const char __user * buffer, + size_t count, loff_t * data) { - int status; - struct seq_file *m = (struct seq_file *) file->private_data; - struct acpi_video_device *dev = (struct acpi_video_device *) m->private; - char str[12] = {0}; - u32 state = 0; + int status; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_video_device *dev = (struct acpi_video_device *)m->private; + char str[12] = { 0 }; + u32 state = 0; ACPI_FUNCTION_TRACE("acpi_video_device_write_state"); @@ -789,7 +760,7 @@ acpi_video_device_write_state ( str[count] = 0; state = simple_strtoul(str, NULL, 0); - state &= ((1ul<<31) | (1ul<<30) | (1ul<<0)); + state &= ((1ul << 31) | (1ul << 30) | (1ul << 0)); status = acpi_video_device_set_state(dev, state); @@ -800,12 +771,11 @@ acpi_video_device_write_state ( } static int -acpi_video_device_brightness_seq_show ( - struct seq_file *seq, - void *offset) +acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset) { - struct acpi_video_device *dev = (struct acpi_video_device *) seq->private; - int i; + struct acpi_video_device *dev = + (struct acpi_video_device *)seq->private; + int i; ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show"); @@ -823,26 +793,22 @@ acpi_video_device_brightness_seq_show ( } static int -acpi_video_device_brightness_open_fs ( - struct inode *inode, - struct file *file) +acpi_video_device_brightness_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_video_device_brightness_seq_show, PDE(inode)->data); } static ssize_t -acpi_video_device_write_brightness ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *data) +acpi_video_device_write_brightness(struct file *file, + const char __user * buffer, + size_t count, loff_t * data) { - struct seq_file *m = (struct seq_file *) file->private_data; - struct acpi_video_device *dev = (struct acpi_video_device *) m->private; - char str[4] = {0}; - unsigned int level = 0; - int i; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_video_device *dev = (struct acpi_video_device *)m->private; + char str[4] = { 0 }; + unsigned int level = 0; + int i; ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness"); @@ -854,14 +820,15 @@ acpi_video_device_write_brightness ( str[count] = 0; level = simple_strtoul(str, NULL, 0); - + if (level > 100) return_VALUE(-EFAULT); /* validate though the list of available levels */ for (i = 0; i < dev->brightness->count; i++) if (level == dev->brightness->levels[i]) { - if (ACPI_SUCCESS(acpi_video_device_lcd_set_level(dev, level))) + if (ACPI_SUCCESS + (acpi_video_device_lcd_set_level(dev, level))) dev->brightness->curr = level; break; } @@ -869,24 +836,22 @@ acpi_video_device_write_brightness ( return_VALUE(count); } -static int -acpi_video_device_EDID_seq_show ( - struct seq_file *seq, - void *offset) +static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) { - struct acpi_video_device *dev = (struct acpi_video_device *) seq->private; - int status; - int i; - union acpi_object *edid = NULL; + struct acpi_video_device *dev = + (struct acpi_video_device *)seq->private; + int status; + int i; + union acpi_object *edid = NULL; ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show"); if (!dev) goto out; - status = acpi_video_device_EDID (dev, &edid, 128); + status = acpi_video_device_EDID(dev, &edid, 128); if (ACPI_FAILURE(status)) { - status = acpi_video_device_EDID (dev, &edid, 256); + status = acpi_video_device_EDID(dev, &edid, 256); } if (ACPI_FAILURE(status)) { @@ -898,7 +863,7 @@ acpi_video_device_EDID_seq_show ( seq_putc(seq, edid->buffer.pointer[i]); } -out: + out: if (!edid) seq_printf(seq, "\n"); else @@ -908,20 +873,15 @@ out: } static int -acpi_video_device_EDID_open_fs ( - struct inode *inode, - struct file *file) +acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_video_device_EDID_seq_show, PDE(inode)->data); } - -static int -acpi_video_device_add_fs ( - struct acpi_device *device) +static int acpi_video_device_add_fs(struct acpi_device *device) { - struct proc_dir_entry *entry = NULL; + struct proc_dir_entry *entry = NULL; struct acpi_video_device *vid_dev; ACPI_FUNCTION_TRACE("acpi_video_device_add_fs"); @@ -929,13 +889,13 @@ acpi_video_device_add_fs ( if (!device) return_VALUE(-ENODEV); - vid_dev = (struct acpi_video_device *) acpi_driver_data(device); + vid_dev = (struct acpi_video_device *)acpi_driver_data(device); if (!vid_dev) return_VALUE(-ENODEV); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), - vid_dev->video->dir); + vid_dev->video->dir); if (!acpi_device_dir(device)) return_VALUE(-ENODEV); acpi_device_dir(device)->owner = THIS_MODULE; @@ -945,7 +905,7 @@ acpi_video_device_add_fs ( entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'info' fs entry\n")); + "Unable to create 'info' fs entry\n")); else { entry->proc_fops = &acpi_video_device_info_fops; entry->data = acpi_driver_data(device); @@ -953,10 +913,12 @@ acpi_video_device_add_fs ( } /* 'state' [R/W] */ - entry = create_proc_entry("state", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); + entry = + create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'state' fs entry\n")); + "Unable to create 'state' fs entry\n")); else { entry->proc_fops = &acpi_video_device_state_fops; entry->proc_fops->write = acpi_video_device_write_state; @@ -965,10 +927,12 @@ acpi_video_device_add_fs ( } /* 'brightness' [R/W] */ - entry = create_proc_entry("brightness", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); + entry = + create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'brightness' fs entry\n")); + "Unable to create 'brightness' fs entry\n")); else { entry->proc_fops = &acpi_video_device_brightness_fops; entry->proc_fops->write = acpi_video_device_write_brightness; @@ -980,7 +944,7 @@ acpi_video_device_add_fs ( entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'brightness' fs entry\n")); + "Unable to create 'brightness' fs entry\n")); else { entry->proc_fops = &acpi_video_device_EDID_fops; entry->data = acpi_driver_data(device); @@ -990,14 +954,12 @@ acpi_video_device_add_fs ( return_VALUE(0); } -static int -acpi_video_device_remove_fs ( - struct acpi_device *device) +static int acpi_video_device_remove_fs(struct acpi_device *device) { struct acpi_video_device *vid_dev; ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs"); - vid_dev = (struct acpi_video_device *) acpi_driver_data(device); + vid_dev = (struct acpi_video_device *)acpi_driver_data(device); if (!vid_dev || !vid_dev->video || !vid_dev->video->dir) return_VALUE(-ENODEV); @@ -1006,22 +968,17 @@ acpi_video_device_remove_fs ( remove_proc_entry("state", acpi_device_dir(device)); remove_proc_entry("brightness", acpi_device_dir(device)); remove_proc_entry("EDID", acpi_device_dir(device)); - remove_proc_entry(acpi_device_bid(device), - vid_dev->video->dir); + remove_proc_entry(acpi_device_bid(device), vid_dev->video->dir); acpi_device_dir(device) = NULL; } return_VALUE(0); } - /* video bus */ -static int -acpi_video_bus_info_seq_show ( - struct seq_file *seq, - void *offset) +static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset) { - struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; + struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show"); @@ -1029,30 +986,25 @@ acpi_video_bus_info_seq_show ( goto end; seq_printf(seq, "Switching heads: %s\n", - video->flags.multihead ? "yes":"no"); + video->flags.multihead ? "yes" : "no"); seq_printf(seq, "Video ROM: %s\n", - video->flags.rom ? "yes":"no"); + video->flags.rom ? "yes" : "no"); seq_printf(seq, "Device to be POSTed on boot: %s\n", - video->flags.post ? "yes":"no"); + video->flags.post ? "yes" : "no"); -end: + end: return_VALUE(0); } -static int -acpi_video_bus_info_open_fs ( - struct inode *inode, - struct file *file) +static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file) { - return single_open(file, acpi_video_bus_info_seq_show, PDE(inode)->data); + return single_open(file, acpi_video_bus_info_seq_show, + PDE(inode)->data); } -static int -acpi_video_bus_ROM_seq_show ( - struct seq_file *seq, - void *offset) +static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset) { - struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; + struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show"); @@ -1062,26 +1014,20 @@ acpi_video_bus_ROM_seq_show ( printk(KERN_INFO PREFIX "Please implement %s\n", __FUNCTION__); seq_printf(seq, "\n"); -end: + end: return_VALUE(0); } -static int -acpi_video_bus_ROM_open_fs ( - struct inode *inode, - struct file *file) +static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data); } -static int -acpi_video_bus_POST_info_seq_show ( - struct seq_file *seq, - void *offset) +static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset) { - struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; - unsigned long options; - int status; + struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; + unsigned long options; + int status; ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show"); @@ -1091,8 +1037,10 @@ acpi_video_bus_POST_info_seq_show ( status = acpi_video_bus_POST_options(video, &options); if (ACPI_SUCCESS(status)) { if (!(options & 1)) { - printk(KERN_WARNING PREFIX "The motherboard VGA device is not listed as a possible POST device.\n"); - printk(KERN_WARNING PREFIX "This indicate a BIOS bug. Please contact the manufacturer.\n"); + printk(KERN_WARNING PREFIX + "The motherboard VGA device is not listed as a possible POST device.\n"); + printk(KERN_WARNING PREFIX + "This indicate a BIOS bug. Please contact the manufacturer.\n"); } printk("%lx\n", options); seq_printf(seq, "can POST: "); @@ -1103,89 +1051,74 @@ acpi_video_bus_POST_info_seq_show ( seq_putc(seq, '\n'); } else seq_printf(seq, "\n"); -end: + end: return_VALUE(0); } static int -acpi_video_bus_POST_info_open_fs ( - struct inode *inode, - struct file *file) +acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file) { - return single_open(file, acpi_video_bus_POST_info_seq_show, PDE(inode)->data); + return single_open(file, acpi_video_bus_POST_info_seq_show, + PDE(inode)->data); } -static int -acpi_video_bus_POST_seq_show ( - struct seq_file *seq, - void *offset) +static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset) { - struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; - int status; - unsigned long id; + struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; + int status; + unsigned long id; ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show"); if (!video) goto end; - status = acpi_video_bus_get_POST (video, &id); + status = acpi_video_bus_get_POST(video, &id); if (!ACPI_SUCCESS(status)) { seq_printf(seq, "\n"); goto end; } - seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]); + seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]); -end: + end: return_VALUE(0); } -static int -acpi_video_bus_DOS_seq_show ( - struct seq_file *seq, - void *offset) +static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset) { - struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private; + struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show"); - seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting ); + seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting); return_VALUE(0); } -static int -acpi_video_bus_POST_open_fs ( - struct inode *inode, - struct file *file) +static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file) { - return single_open(file, acpi_video_bus_POST_seq_show, PDE(inode)->data); + return single_open(file, acpi_video_bus_POST_seq_show, + PDE(inode)->data); } -static int -acpi_video_bus_DOS_open_fs ( - struct inode *inode, - struct file *file) +static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data); } static ssize_t -acpi_video_bus_write_POST ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *data) +acpi_video_bus_write_POST(struct file *file, + const char __user * buffer, + size_t count, loff_t * data) { - int status; - struct seq_file *m = (struct seq_file *) file->private_data; - struct acpi_video_bus *video = (struct acpi_video_bus *) m->private; - char str[12] = {0}; - unsigned long opt, options; + int status; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_video_bus *video = (struct acpi_video_bus *)m->private; + char str[12] = { 0 }; + unsigned long opt, options; ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST"); - if (!video || count + 1 > sizeof str) return_VALUE(-EINVAL); @@ -1205,32 +1138,28 @@ acpi_video_bus_write_POST ( options |= 1; if (options & (1ul << opt)) { - status = acpi_video_bus_set_POST (video, opt); + status = acpi_video_bus_set_POST(video, opt); if (!ACPI_SUCCESS(status)) return_VALUE(-EFAULT); } - return_VALUE(count); } static ssize_t -acpi_video_bus_write_DOS ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *data) +acpi_video_bus_write_DOS(struct file *file, + const char __user * buffer, + size_t count, loff_t * data) { - int status; - struct seq_file *m = (struct seq_file *) file->private_data; - struct acpi_video_bus *video = (struct acpi_video_bus *) m->private; - char str[12] = {0}; - unsigned long opt; + int status; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_video_bus *video = (struct acpi_video_bus *)m->private; + char str[12] = { 0 }; + unsigned long opt; ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS"); - if (!video || count + 1 > sizeof str) return_VALUE(-EINVAL); @@ -1242,7 +1171,7 @@ acpi_video_bus_write_DOS ( if (opt > 7) return_VALUE(-EFAULT); - status = acpi_video_bus_DOS (video, opt & 0x3, (opt & 0x4)>>2); + status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2); if (!ACPI_SUCCESS(status)) return_VALUE(-EFAULT); @@ -1250,20 +1179,18 @@ acpi_video_bus_write_DOS ( return_VALUE(count); } -static int -acpi_video_bus_add_fs ( - struct acpi_device *device) +static int acpi_video_bus_add_fs(struct acpi_device *device) { - struct proc_dir_entry *entry = NULL; - struct acpi_video_bus *video; + struct proc_dir_entry *entry = NULL; + struct acpi_video_bus *video; ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs"); - video = (struct acpi_video_bus *) acpi_driver_data(device); + video = (struct acpi_video_bus *)acpi_driver_data(device); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), - acpi_video_dir); + acpi_video_dir); if (!acpi_device_dir(device)) return_VALUE(-ENODEV); video->dir = acpi_device_dir(device); @@ -1273,7 +1200,8 @@ acpi_video_bus_add_fs ( /* 'info' [R] */ entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'info' fs entry\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'info' fs entry\n")); else { entry->proc_fops = &acpi_video_bus_info_fops; entry->data = acpi_driver_data(device); @@ -1283,7 +1211,8 @@ acpi_video_bus_add_fs ( /* 'ROM' [R] */ entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'ROM' fs entry\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'ROM' fs entry\n")); else { entry->proc_fops = &acpi_video_bus_ROM_fops; entry->data = acpi_driver_data(device); @@ -1291,9 +1220,11 @@ acpi_video_bus_add_fs ( } /* 'POST_info' [R] */ - entry = create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device)); + entry = + create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'POST_info' fs entry\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'POST_info' fs entry\n")); else { entry->proc_fops = &acpi_video_bus_POST_info_fops; entry->data = acpi_driver_data(device); @@ -1301,9 +1232,12 @@ acpi_video_bus_add_fs ( } /* 'POST' [R/W] */ - entry = create_proc_entry("POST", S_IFREG|S_IRUGO|S_IRUSR, acpi_device_dir(device)); + entry = + create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR, + acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'POST' fs entry\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'POST' fs entry\n")); else { entry->proc_fops = &acpi_video_bus_POST_fops; entry->proc_fops->write = acpi_video_bus_write_POST; @@ -1312,9 +1246,12 @@ acpi_video_bus_add_fs ( } /* 'DOS' [R/W] */ - entry = create_proc_entry("DOS", S_IFREG|S_IRUGO|S_IRUSR, acpi_device_dir(device)); + entry = + create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR, + acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'DOS' fs entry\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'DOS' fs entry\n")); else { entry->proc_fops = &acpi_video_bus_DOS_fops; entry->proc_fops->write = acpi_video_bus_write_DOS; @@ -1325,15 +1262,13 @@ acpi_video_bus_add_fs ( return_VALUE(0); } -static int -acpi_video_bus_remove_fs ( - struct acpi_device *device) +static int acpi_video_bus_remove_fs(struct acpi_device *device) { - struct acpi_video_bus *video; + struct acpi_video_bus *video; ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs"); - video = (struct acpi_video_bus *) acpi_driver_data(device); + video = (struct acpi_video_bus *)acpi_driver_data(device); if (acpi_device_dir(device)) { remove_proc_entry("info", acpi_device_dir(device)); @@ -1341,8 +1276,7 @@ acpi_video_bus_remove_fs ( remove_proc_entry("POST_info", acpi_device_dir(device)); remove_proc_entry("POST", acpi_device_dir(device)); remove_proc_entry("DOS", acpi_device_dir(device)); - remove_proc_entry(acpi_device_bid(device), - acpi_video_dir); + remove_proc_entry(acpi_device_bid(device), acpi_video_dir); acpi_device_dir(device) = NULL; } @@ -1356,20 +1290,20 @@ acpi_video_bus_remove_fs ( /* device interface */ static int -acpi_video_bus_get_one_device ( - struct acpi_device *device, - struct acpi_video_bus *video) +acpi_video_bus_get_one_device(struct acpi_device *device, + struct acpi_video_bus *video) { - unsigned long device_id; - int status, result; - struct acpi_video_device *data; + unsigned long device_id; + int status, result; + struct acpi_video_device *data; ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device"); if (!device || !video) return_VALUE(-EINVAL); - status = acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); + status = + acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); if (ACPI_SUCCESS(status)) { data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL); @@ -1401,15 +1335,17 @@ acpi_video_bus_get_one_device ( data->flags.unknown = 1; break; } - + acpi_video_device_bind(video, data); acpi_video_device_find_cap(data); status = acpi_install_notify_handler(data->handle, - ACPI_DEVICE_NOTIFY, acpi_video_device_notify, data); + ACPI_DEVICE_NOTIFY, + acpi_video_device_notify, + data); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); + "Error installing notify handler\n")); result = -ENODEV; goto end; } @@ -1423,7 +1359,7 @@ acpi_video_bus_get_one_device ( return_VALUE(0); } -end: + end: return_VALUE(-ENOENT); } @@ -1437,15 +1373,15 @@ end: * Enumerate the video device list of the video bus, * bind the ids with the corresponding video devices * under the video bus. - */ + */ -static void -acpi_video_device_rebind( struct acpi_video_bus *video) +static void acpi_video_device_rebind(struct acpi_video_bus *video) { - struct list_head * node, * next; + struct list_head *node, *next; list_for_each_safe(node, next, &video->video_device_list) { - struct acpi_video_device * dev = container_of(node, struct acpi_video_device, entry); - acpi_video_device_bind( video, dev); + struct acpi_video_device *dev = + container_of(node, struct acpi_video_device, entry); + acpi_video_device_bind(video, dev); } } @@ -1460,21 +1396,21 @@ acpi_video_device_rebind( struct acpi_video_bus *video) * * Bind the ids with the corresponding video devices * under the video bus. - */ + */ static void -acpi_video_device_bind( struct acpi_video_bus *video, - struct acpi_video_device *device) +acpi_video_device_bind(struct acpi_video_bus *video, + struct acpi_video_device *device) { - int i; + int i; ACPI_FUNCTION_TRACE("acpi_video_device_bind"); #define IDS_VAL(i) video->attached_array[i].value.int_val #define IDS_BIND(i) video->attached_array[i].bind_info - - for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID && - i < video->attached_count; i++) { - if (device->device_id == (IDS_VAL(i)& 0xffff)) { + + for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID && + i < video->attached_count; i++) { + if (device->device_id == (IDS_VAL(i) & 0xffff)) { IDS_BIND(i) = device; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i)); } @@ -1492,17 +1428,17 @@ acpi_video_device_bind( struct acpi_video_bus *video, * * Call _DOD to enumerate all devices attached to display adapter * - */ + */ static int acpi_video_device_enumerate(struct acpi_video_bus *video) { - int status; - int count; - int i; + int status; + int count; + int i; struct acpi_video_enumerated_device *active_device_list; - struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; - union acpi_object *dod = NULL; - union acpi_object *obj; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *dod = NULL; + union acpi_object *obj; ACPI_FUNCTION_TRACE("acpi_video_device_enumerate"); @@ -1512,7 +1448,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) return_VALUE(status); } - dod = (union acpi_object *) buffer.pointer; + dod = (union acpi_object *)buffer.pointer; if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n")); status = -EFAULT; @@ -1520,11 +1456,13 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n", - dod->package.count)); + dod->package.count)); - active_device_list= kmalloc( - (1+dod->package.count)*sizeof(struct acpi_video_enumerated_device), - GFP_KERNEL); + active_device_list = kmalloc((1 + + dod->package.count) * + sizeof(struct + acpi_video_enumerated_device), + GFP_KERNEL); if (!active_device_list) { status = -ENOMEM; @@ -1533,25 +1471,28 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) count = 0; for (i = 0; i < dod->package.count; i++) { - obj = (union acpi_object *) &dod->package.elements[i]; + obj = (union acpi_object *)&dod->package.elements[i]; if (obj->type != ACPI_TYPE_INTEGER) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n")); - active_device_list[i].value.int_val = ACPI_VIDEO_HEAD_INVALID; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid _DOD data\n")); + active_device_list[i].value.int_val = + ACPI_VIDEO_HEAD_INVALID; } active_device_list[i].value.int_val = obj->integer.value; active_device_list[i].bind_info = NULL; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i, (int) obj->integer.value)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i, + (int)obj->integer.value)); count++; } active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END; - if(video->attached_array) + if (video->attached_array) kfree(video->attached_array); - + video->attached_array = active_device_list; video->attached_count = count; -out: + out: acpi_os_free(buffer.pointer); return_VALUE(status); } @@ -1567,17 +1508,14 @@ out: * 1. Find out the current active output device. * 2. Identify the next output device to switch * 3. call _DSS to do actual switch. - */ + */ -static int -acpi_video_switch_output( - struct acpi_video_bus *video, - int event) +static int acpi_video_switch_output(struct acpi_video_bus *video, int event) { - struct list_head * node, * next; - struct acpi_video_device *dev=NULL; - struct acpi_video_device *dev_next=NULL; - struct acpi_video_device *dev_prev=NULL; + struct list_head *node, *next; + struct acpi_video_device *dev = NULL; + struct acpi_video_device *dev_next = NULL; + struct acpi_video_device *dev_prev = NULL; unsigned long state; int status = 0; @@ -1586,15 +1524,19 @@ acpi_video_switch_output( list_for_each_safe(node, next, &video->video_device_list) { dev = container_of(node, struct acpi_video_device, entry); status = acpi_video_device_get_state(dev, &state); - if (state & 0x2){ - dev_next = container_of(node->next, struct acpi_video_device, entry); - dev_prev = container_of(node->prev, struct acpi_video_device, entry); + if (state & 0x2) { + dev_next = + container_of(node->next, struct acpi_video_device, + entry); + dev_prev = + container_of(node->prev, struct acpi_video_device, + entry); goto out; } } dev_next = container_of(node->next, struct acpi_video_device, entry); dev_prev = container_of(node->prev, struct acpi_video_device, entry); -out: + out: switch (event) { case ACPI_VIDEO_NOTIFY_CYCLE: case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: @@ -1611,21 +1553,16 @@ out: return_VALUE(status); } -static int -acpi_video_get_next_level( - struct acpi_video_device *device, - u32 level_current, - u32 event) +static int +acpi_video_get_next_level(struct acpi_video_device *device, + u32 level_current, u32 event) { - /*Fix me*/ + /*Fix me */ return level_current; } - static void -acpi_video_switch_brightness ( - struct acpi_video_device *device, - int event) +acpi_video_switch_brightness(struct acpi_video_device *device, int event) { unsigned long level_current, level_next; acpi_video_device_lcd_get_level_current(device, &level_current); @@ -1634,26 +1571,27 @@ acpi_video_switch_brightness ( } static int -acpi_video_bus_get_devices ( - struct acpi_video_bus *video, - struct acpi_device *device) +acpi_video_bus_get_devices(struct acpi_video_bus *video, + struct acpi_device *device) { - int status = 0; - struct list_head *node, *next; + int status = 0; + struct list_head *node, *next; ACPI_FUNCTION_TRACE("acpi_video_get_devices"); acpi_video_device_enumerate(video); list_for_each_safe(node, next, &device->children) { - struct acpi_device *dev = list_entry(node, struct acpi_device, node); + struct acpi_device *dev = + list_entry(node, struct acpi_device, node); if (!dev) continue; status = acpi_video_bus_get_one_device(dev, video); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Cant attach device\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Cant attach device\n")); continue; } @@ -1661,9 +1599,7 @@ acpi_video_bus_get_devices ( return_VALUE(status); } -static int -acpi_video_bus_put_one_device( - struct acpi_video_device *device) +static int acpi_video_bus_put_one_device(struct acpi_video_device *device) { acpi_status status; struct acpi_video_bus *video; @@ -1681,31 +1617,32 @@ acpi_video_bus_put_one_device( acpi_video_device_remove_fs(device->dev); status = acpi_remove_notify_handler(device->handle, - ACPI_DEVICE_NOTIFY, acpi_video_device_notify); + ACPI_DEVICE_NOTIFY, + acpi_video_device_notify); if (ACPI_FAILURE(status)) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); + "Error removing notify handler\n")); return_VALUE(0); } -static int -acpi_video_bus_put_devices ( - struct acpi_video_bus *video) +static int acpi_video_bus_put_devices(struct acpi_video_bus *video) { - int status; - struct list_head *node, *next; + int status; + struct list_head *node, *next; ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices"); list_for_each_safe(node, next, &video->video_device_list) { - struct acpi_video_device *data = list_entry(node, struct acpi_video_device, entry); + struct acpi_video_device *data = + list_entry(node, struct acpi_video_device, entry); if (!data) continue; status = acpi_video_bus_put_one_device(data); - if(ACPI_FAILURE(status)) - printk(KERN_WARNING PREFIX "hhuuhhuu bug in acpi video driver.\n"); + if (ACPI_FAILURE(status)) + printk(KERN_WARNING PREFIX + "hhuuhhuu bug in acpi video driver.\n"); if (data->brightness) kfree(data->brightness); @@ -1718,28 +1655,20 @@ acpi_video_bus_put_devices ( /* acpi_video interface */ -static int -acpi_video_bus_start_devices( - struct acpi_video_bus *video) +static int acpi_video_bus_start_devices(struct acpi_video_bus *video) { return acpi_video_bus_DOS(video, 1, 0); } -static int -acpi_video_bus_stop_devices( - struct acpi_video_bus *video) +static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) { return acpi_video_bus_DOS(video, 0, 1); } -static void -acpi_video_bus_notify ( - acpi_handle handle, - u32 event, - void *data) +static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_video_bus *video = (struct acpi_video_bus *) data; - struct acpi_device *device = NULL; + struct acpi_video_bus *video = (struct acpi_video_bus *)data; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_video_bus_notify"); printk("video bus notify\n"); @@ -1764,30 +1693,27 @@ acpi_video_bus_notify ( acpi_bus_generate_event(device, event, 0); break; - case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed.*/ - case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */ - case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */ + case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */ + case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */ + case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */ acpi_video_switch_output(video, event); acpi_bus_generate_event(device, event, 0); break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Unsupported event [0x%x]\n", event)); + "Unsupported event [0x%x]\n", event)); break; } return_VOID; } -static void -acpi_video_device_notify ( - acpi_handle handle, - u32 event, - void *data) +static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_video_device *video_device = (struct acpi_video_device *) data; - struct acpi_device *device = NULL; + struct acpi_video_device *video_device = + (struct acpi_video_device *)data; + struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_video_device_notify"); @@ -1799,36 +1725,34 @@ acpi_video_device_notify ( return_VOID; switch (event) { - case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */ - case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */ + case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */ + case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */ acpi_bus_generate_event(device, event, 0); break; - case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */ - case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */ - case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */ - case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */ - case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */ - acpi_video_switch_brightness (video_device, event); + case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */ + case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */ + case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */ + case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */ + case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */ + acpi_video_switch_brightness(video_device, event); acpi_bus_generate_event(device, event, 0); break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Unsupported event [0x%x]\n", event)); + "Unsupported event [0x%x]\n", event)); break; } return_VOID; } -static int -acpi_video_bus_add ( - struct acpi_device *device) +static int acpi_video_bus_add(struct acpi_device *device) { - int result = 0; - acpi_status status = 0; - struct acpi_video_bus *video = NULL; + int result = 0; + acpi_status status = 0; + struct acpi_video_bus *video = NULL; ACPI_FUNCTION_TRACE("acpi_video_bus_add"); - + if (!device) return_VALUE(-EINVAL); @@ -1858,21 +1782,22 @@ acpi_video_bus_add ( acpi_video_bus_start_devices(video); status = acpi_install_notify_handler(video->handle, - ACPI_DEVICE_NOTIFY, acpi_video_bus_notify, video); + ACPI_DEVICE_NOTIFY, + acpi_video_bus_notify, video); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); + "Error installing notify handler\n")); result = -ENODEV; goto end; } printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n", - ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), - video->flags.multihead ? "yes":"no", - video->flags.rom ? "yes":"no", - video->flags.post ? "yes":"no"); + ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), + video->flags.multihead ? "yes" : "no", + video->flags.rom ? "yes" : "no", + video->flags.post ? "yes" : "no"); -end: + end: if (result) { acpi_video_bus_remove_fs(device); kfree(video); @@ -1881,28 +1806,26 @@ end: return_VALUE(result); } -static int -acpi_video_bus_remove ( - struct acpi_device *device, - int type) +static int acpi_video_bus_remove(struct acpi_device *device, int type) { - acpi_status status = 0; - struct acpi_video_bus *video = NULL; + acpi_status status = 0; + struct acpi_video_bus *video = NULL; ACPI_FUNCTION_TRACE("acpi_video_bus_remove"); if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); - video = (struct acpi_video_bus *) acpi_driver_data(device); + video = (struct acpi_video_bus *)acpi_driver_data(device); acpi_video_bus_stop_devices(video); status = acpi_remove_notify_handler(video->handle, - ACPI_DEVICE_NOTIFY, acpi_video_bus_notify); + ACPI_DEVICE_NOTIFY, + acpi_video_bus_notify); if (ACPI_FAILURE(status)) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); + "Error removing notify handler\n")); acpi_video_bus_put_devices(video); acpi_video_bus_remove_fs(device); @@ -1914,15 +1837,12 @@ acpi_video_bus_remove ( return_VALUE(0); } - static int -acpi_video_bus_match ( - struct acpi_device *device, - struct acpi_driver *driver) +acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver) { - acpi_handle h_dummy1; - acpi_handle h_dummy2; - acpi_handle h_dummy3; + acpi_handle h_dummy1; + acpi_handle h_dummy2; + acpi_handle h_dummy3; ACPI_FUNCTION_TRACE("acpi_video_bus_match"); @@ -1948,22 +1868,19 @@ acpi_video_bus_match ( ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3))) return_VALUE(0); - return_VALUE(-ENODEV); } - -static int __init -acpi_video_init (void) +static int __init acpi_video_init(void) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_video_init"); /* - acpi_dbg_level = 0xFFFFFFFF; - acpi_dbg_layer = 0x08000000; - */ + acpi_dbg_level = 0xFFFFFFFF; + acpi_dbg_layer = 0x08000000; + */ acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); if (!acpi_video_dir) @@ -1979,8 +1896,7 @@ acpi_video_init (void) return_VALUE(0); } -static void __exit -acpi_video_exit (void) +static void __exit acpi_video_exit(void) { ACPI_FUNCTION_TRACE("acpi_video_exit"); diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index d62af72..f3810cc 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -44,7 +44,6 @@ #ifndef _ACCONFIG_H #define _ACCONFIG_H - /****************************************************************************** * * Configuration options @@ -78,10 +77,10 @@ /* Maximum objects in the various object caches */ -#define ACPI_MAX_STATE_CACHE_DEPTH 96 /* State objects */ -#define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ -#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */ -#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */ +#define ACPI_MAX_STATE_CACHE_DEPTH 96 /* State objects */ +#define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */ /* * Should the subystem abort the loading of an ACPI table if the @@ -89,7 +88,6 @@ */ #define ACPI_CHECKSUM_ABORT FALSE - /****************************************************************************** * * Subsystem Constants @@ -103,7 +101,7 @@ /* String size constants */ #define ACPI_MAX_STRING_LENGTH 512 -#define ACPI_PATHNAME_MAX 256 /* A full namespace pathname */ +#define ACPI_PATHNAME_MAX 256 /* A full namespace pathname */ /* Maximum count for a semaphore object */ @@ -117,7 +115,6 @@ #define ACPI_SYSMEM_REGION_WINDOW_SIZE 4096 - /****************************************************************************** * * ACPI Specification constants (Do not change unless the specification changes) @@ -155,15 +152,15 @@ /* Names within the namespace are 4 bytes long */ #define ACPI_NAME_SIZE 4 -#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ +#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ #define ACPI_PATH_SEPARATOR '.' /* Constants used in searching for the RSDP in low memory */ -#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */ +#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */ #define ACPI_EBDA_PTR_LENGTH 2 #define ACPI_EBDA_WINDOW_SIZE 1024 -#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */ +#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */ #define ACPI_HI_RSDP_WINDOW_SIZE 0x00020000 #define ACPI_RSDP_SCAN_STEP 16 @@ -198,18 +195,15 @@ #define ACPI_NUM_OSI_STRINGS 10 - /****************************************************************************** * * ACPI AML Debugger * *****************************************************************************/ -#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */ +#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */ #define ACPI_DEBUGGER_COMMAND_PROMPT '-' #define ACPI_DEBUGGER_EXECUTE_PROMPT '%' - -#endif /* _ACCONFIG_H */ - +#endif /* _ACCONFIG_H */ diff --git a/include/acpi/acdebug.h b/include/acpi/acdebug.h index f8fa222..70ce3b4 100644 --- a/include/acpi/acdebug.h +++ b/include/acpi/acdebug.h @@ -44,22 +44,17 @@ #ifndef __ACDEBUG_H__ #define __ACDEBUG_H__ - #define ACPI_DEBUG_BUFFER_SIZE 4196 -struct command_info -{ - char *name; /* Command Name */ - u8 min_args; /* Minimum arguments required */ +struct command_info { + char *name; /* Command Name */ + u8 min_args; /* Minimum arguments required */ }; - -struct argument_info -{ - char *name; /* Argument Name */ +struct argument_info { + char *name; /* Argument Name */ }; - #define PARAM_LIST(pl) pl #define DBTEST_OUTPUT_LEVEL(lvl) if (acpi_gbl_db_opt_verbose) #define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ @@ -68,279 +63,155 @@ struct argument_info #define EX_NO_SINGLE_STEP 1 #define EX_SINGLE_STEP 2 - /* * dbxface - external debugger interfaces */ -acpi_status -acpi_db_initialize ( - void); +acpi_status acpi_db_initialize(void); -void -acpi_db_terminate ( - void); +void acpi_db_terminate(void); acpi_status -acpi_db_single_step ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - u32 op_type); - +acpi_db_single_step(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, u32 op_type); /* * dbcmds - debug commands and output routines */ -acpi_status -acpi_db_disassemble_method ( - char *name); - -void -acpi_db_display_table_info ( - char *table_arg); +acpi_status acpi_db_disassemble_method(char *name); -void -acpi_db_unload_acpi_table ( - char *table_arg, - char *instance_arg); +void acpi_db_display_table_info(char *table_arg); -void -acpi_db_set_method_breakpoint ( - char *location, - struct acpi_walk_state *walk_state, - union acpi_parse_object *op); +void acpi_db_unload_acpi_table(char *table_arg, char *instance_arg); void -acpi_db_set_method_call_breakpoint ( - union acpi_parse_object *op); +acpi_db_set_method_breakpoint(char *location, + struct acpi_walk_state *walk_state, + union acpi_parse_object *op); -void -acpi_db_get_bus_info ( - void); +void acpi_db_set_method_call_breakpoint(union acpi_parse_object *op); -void -acpi_db_disassemble_aml ( - char *statements, - union acpi_parse_object *op); +void acpi_db_get_bus_info(void); -void -acpi_db_dump_namespace ( - char *start_arg, - char *depth_arg); +void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op); -void -acpi_db_dump_namespace_by_owner ( - char *owner_arg, - char *depth_arg); +void acpi_db_dump_namespace(char *start_arg, char *depth_arg); -void -acpi_db_send_notify ( - char *name, - u32 value); +void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg); -void -acpi_db_set_method_data ( - char *type_arg, - char *index_arg, - char *value_arg); +void acpi_db_send_notify(char *name, u32 value); -acpi_status -acpi_db_display_objects ( - char *obj_type_arg, - char *display_count_arg); +void acpi_db_set_method_data(char *type_arg, char *index_arg, char *value_arg); acpi_status -acpi_db_find_name_in_namespace ( - char *name_arg); +acpi_db_display_objects(char *obj_type_arg, char *display_count_arg); -void -acpi_db_set_scope ( - char *name); +acpi_status acpi_db_find_name_in_namespace(char *name_arg); -acpi_status -acpi_db_sleep ( - char *object_arg); +void acpi_db_set_scope(char *name); -void -acpi_db_find_references ( - char *object_arg); +acpi_status acpi_db_sleep(char *object_arg); -void -acpi_db_display_locks ( - void); +void acpi_db_find_references(char *object_arg); -void -acpi_db_display_resources ( - char *object_arg); +void acpi_db_display_locks(void); -void -acpi_db_display_gpes ( - void); +void acpi_db_display_resources(char *object_arg); -void -acpi_db_check_integrity ( - void); +void acpi_db_display_gpes(void); -void -acpi_db_generate_gpe ( - char *gpe_arg, - char *block_arg); +void acpi_db_check_integrity(void); +void acpi_db_generate_gpe(char *gpe_arg, char *block_arg); /* * dbdisply - debug display commands */ -void -acpi_db_display_method_info ( - union acpi_parse_object *op); +void acpi_db_display_method_info(union acpi_parse_object *op); -void -acpi_db_decode_and_display_object ( - char *target, - char *output_type); +void acpi_db_decode_and_display_object(char *target, char *output_type); void -acpi_db_display_result_object ( - union acpi_operand_object *obj_desc, - struct acpi_walk_state *walk_state); +acpi_db_display_result_object(union acpi_operand_object *obj_desc, + struct acpi_walk_state *walk_state); -acpi_status -acpi_db_display_all_methods ( - char *display_count_arg); +acpi_status acpi_db_display_all_methods(char *display_count_arg); -void -acpi_db_display_arguments ( - void); +void acpi_db_display_arguments(void); -void -acpi_db_display_locals ( - void); +void acpi_db_display_locals(void); -void -acpi_db_display_results ( - void); +void acpi_db_display_results(void); -void -acpi_db_display_calling_tree ( - void); +void acpi_db_display_calling_tree(void); -void -acpi_db_display_object_type ( - char *object_arg); +void acpi_db_display_object_type(char *object_arg); void -acpi_db_display_argument_object ( - union acpi_operand_object *obj_desc, - struct acpi_walk_state *walk_state); - +acpi_db_display_argument_object(union acpi_operand_object *obj_desc, + struct acpi_walk_state *walk_state); /* * dbexec - debugger control method execution */ -void -acpi_db_execute ( - char *name, - char **args, - u32 flags); +void acpi_db_execute(char *name, char **args, u32 flags); void -acpi_db_create_execution_threads ( - char *num_threads_arg, - char *num_loops_arg, - char *method_name_arg); - +acpi_db_create_execution_threads(char *num_threads_arg, + char *num_loops_arg, char *method_name_arg); /* * dbfileio - Debugger file I/O commands */ acpi_object_type -acpi_db_match_argument ( - char *user_argument, - struct argument_info *arguments); +acpi_db_match_argument(char *user_argument, struct argument_info *arguments); -void -acpi_db_close_debug_file ( - void); +void acpi_db_close_debug_file(void); -void -acpi_db_open_debug_file ( - char *name); +void acpi_db_open_debug_file(char *name); -acpi_status -acpi_db_load_acpi_table ( - char *filename); +acpi_status acpi_db_load_acpi_table(char *filename); acpi_status -acpi_db_get_table_from_file ( - char *filename, - struct acpi_table_header **table); +acpi_db_get_table_from_file(char *filename, struct acpi_table_header **table); acpi_status -acpi_db_read_table_from_file ( - char *filename, - struct acpi_table_header **table); - +acpi_db_read_table_from_file(char *filename, struct acpi_table_header **table); /* * dbhistry - debugger HISTORY command */ -void -acpi_db_add_to_history ( - char *command_line); +void acpi_db_add_to_history(char *command_line); -void -acpi_db_display_history ( - void); - -char * -acpi_db_get_from_history ( - char *command_num_arg); +void acpi_db_display_history(void); +char *acpi_db_get_from_history(char *command_num_arg); /* * dbinput - user front-end to the AML debugger */ acpi_status -acpi_db_command_dispatch ( - char *input_buffer, - struct acpi_walk_state *walk_state, - union acpi_parse_object *op); - -void ACPI_SYSTEM_XFACE -acpi_db_execute_thread ( - void *context); +acpi_db_command_dispatch(char *input_buffer, + struct acpi_walk_state *walk_state, + union acpi_parse_object *op); +void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context); /* * dbstats - Generation and display of ACPI table statistics */ -void -acpi_db_generate_statistics ( - union acpi_parse_object *root, - u8 is_method); - -acpi_status -acpi_db_display_statistics ( - char *type_arg); +void acpi_db_generate_statistics(union acpi_parse_object *root, u8 is_method); +acpi_status acpi_db_display_statistics(char *type_arg); /* * dbutils - AML debugger utilities */ -void -acpi_db_set_output_destination ( - u32 where); +void acpi_db_set_output_destination(u32 where); -void -acpi_db_dump_external_object ( - union acpi_object *obj_desc, - u32 level); +void acpi_db_dump_external_object(union acpi_object *obj_desc, u32 level); -void -acpi_db_prep_namestring ( - char *name); +void acpi_db_prep_namestring(char *name); -struct acpi_namespace_node * -acpi_db_local_ns_lookup ( - char *name); +struct acpi_namespace_node *acpi_db_local_ns_lookup(char *name); -#endif /* __ACDEBUG_H__ */ +#endif /* __ACDEBUG_H__ */ diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h index 2632543..3d96dcb 100644 --- a/include/acpi/acdisasm.h +++ b/include/acpi/acdisasm.h @@ -46,328 +46,219 @@ #include "amlresrc.h" - #define BLOCK_NONE 0 #define BLOCK_PAREN 1 #define BLOCK_BRACE 2 #define BLOCK_COMMA_LIST 4 -struct acpi_external_list -{ - char *path; - struct acpi_external_list *next; +struct acpi_external_list { + char *path; + struct acpi_external_list *next; }; -extern struct acpi_external_list *acpi_gbl_external_list; -extern const char *acpi_gbl_io_decode[2]; -extern const char *acpi_gbl_word_decode[4]; -extern const char *acpi_gbl_consume_decode[2]; -extern const char *acpi_gbl_min_decode[2]; -extern const char *acpi_gbl_max_decode[2]; -extern const char *acpi_gbl_DECdecode[2]; -extern const char *acpi_gbl_RNGdecode[4]; -extern const char *acpi_gbl_MEMdecode[4]; -extern const char *acpi_gbl_RWdecode[2]; -extern const char *acpi_gbl_irq_decode[2]; -extern const char *acpi_gbl_HEdecode[2]; -extern const char *acpi_gbl_LLdecode[2]; -extern const char *acpi_gbl_SHRdecode[2]; -extern const char *acpi_gbl_TYPdecode[4]; -extern const char *acpi_gbl_BMdecode[2]; -extern const char *acpi_gbl_SIZdecode[4]; -extern const char *acpi_gbl_TTPdecode[2]; -extern const char *acpi_gbl_MTPdecode[4]; -extern const char *acpi_gbl_TRSdecode[2]; - - -extern const char *acpi_gbl_lock_rule[ACPI_NUM_LOCK_RULES]; -extern const char *acpi_gbl_access_types[ACPI_NUM_ACCESS_TYPES]; -extern const char *acpi_gbl_update_rules[ACPI_NUM_UPDATE_RULES]; -extern const char *acpi_gbl_match_ops[ACPI_NUM_MATCH_OPS]; - - -struct acpi_op_walk_info -{ - u32 level; - u32 bit_offset; - struct acpi_walk_state *walk_state; +extern struct acpi_external_list *acpi_gbl_external_list; +extern const char *acpi_gbl_io_decode[2]; +extern const char *acpi_gbl_word_decode[4]; +extern const char *acpi_gbl_consume_decode[2]; +extern const char *acpi_gbl_min_decode[2]; +extern const char *acpi_gbl_max_decode[2]; +extern const char *acpi_gbl_DECdecode[2]; +extern const char *acpi_gbl_RNGdecode[4]; +extern const char *acpi_gbl_MEMdecode[4]; +extern const char *acpi_gbl_RWdecode[2]; +extern const char *acpi_gbl_irq_decode[2]; +extern const char *acpi_gbl_HEdecode[2]; +extern const char *acpi_gbl_LLdecode[2]; +extern const char *acpi_gbl_SHRdecode[2]; +extern const char *acpi_gbl_TYPdecode[4]; +extern const char *acpi_gbl_BMdecode[2]; +extern const char *acpi_gbl_SIZdecode[4]; +extern const char *acpi_gbl_TTPdecode[2]; +extern const char *acpi_gbl_MTPdecode[4]; +extern const char *acpi_gbl_TRSdecode[2]; + +extern const char *acpi_gbl_lock_rule[ACPI_NUM_LOCK_RULES]; +extern const char *acpi_gbl_access_types[ACPI_NUM_ACCESS_TYPES]; +extern const char *acpi_gbl_update_rules[ACPI_NUM_UPDATE_RULES]; +extern const char *acpi_gbl_match_ops[ACPI_NUM_MATCH_OPS]; + +struct acpi_op_walk_info { + u32 level; + u32 bit_offset; + struct acpi_walk_state *walk_state; }; typedef -acpi_status (*asl_walk_callback) ( - union acpi_parse_object *op, - u32 level, - void *context); - +acpi_status(*asl_walk_callback) (union acpi_parse_object * op, + u32 level, void *context); /* * dmwalk */ void -acpi_dm_disassemble ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *origin, - u32 num_opcodes); - +acpi_dm_disassemble(struct acpi_walk_state *walk_state, + union acpi_parse_object *origin, u32 num_opcodes); /* * dmopcode */ void -acpi_dm_disassemble_one_op ( - struct acpi_walk_state *walk_state, - struct acpi_op_walk_info *info, - union acpi_parse_object *op); +acpi_dm_disassemble_one_op(struct acpi_walk_state *walk_state, + struct acpi_op_walk_info *info, + union acpi_parse_object *op); -void -acpi_dm_decode_internal_object ( - union acpi_operand_object *obj_desc); +void acpi_dm_decode_internal_object(union acpi_operand_object *obj_desc); -u32 -acpi_dm_list_type ( - union acpi_parse_object *op); +u32 acpi_dm_list_type(union acpi_parse_object *op); -void -acpi_dm_method_flags ( - union acpi_parse_object *op); - -void -acpi_dm_field_flags ( - union acpi_parse_object *op); +void acpi_dm_method_flags(union acpi_parse_object *op); -void -acpi_dm_address_space ( - u8 space_id); +void acpi_dm_field_flags(union acpi_parse_object *op); -void -acpi_dm_region_flags ( - union acpi_parse_object *op); +void acpi_dm_address_space(u8 space_id); -void -acpi_dm_match_op ( - union acpi_parse_object *op); +void acpi_dm_region_flags(union acpi_parse_object *op); -u8 -acpi_dm_comma_if_list_member ( - union acpi_parse_object *op); +void acpi_dm_match_op(union acpi_parse_object *op); -void -acpi_dm_comma_if_field_member ( - union acpi_parse_object *op); +u8 acpi_dm_comma_if_list_member(union acpi_parse_object *op); +void acpi_dm_comma_if_field_member(union acpi_parse_object *op); /* * dmnames */ -u32 -acpi_dm_dump_name ( - char *name); +u32 acpi_dm_dump_name(char *name); acpi_status -acpi_ps_display_object_pathname ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op); - -void -acpi_dm_namestring ( - char *name); +acpi_ps_display_object_pathname(struct acpi_walk_state *walk_state, + union acpi_parse_object *op); +void acpi_dm_namestring(char *name); /* * dmobject */ void -acpi_dm_display_internal_object ( - union acpi_operand_object *obj_desc, - struct acpi_walk_state *walk_state); +acpi_dm_display_internal_object(union acpi_operand_object *obj_desc, + struct acpi_walk_state *walk_state); -void -acpi_dm_display_arguments ( - struct acpi_walk_state *walk_state); +void acpi_dm_display_arguments(struct acpi_walk_state *walk_state); -void -acpi_dm_display_locals ( - struct acpi_walk_state *walk_state); +void acpi_dm_display_locals(struct acpi_walk_state *walk_state); void -acpi_dm_dump_method_info ( - acpi_status status, - struct acpi_walk_state *walk_state, - union acpi_parse_object *op); - +acpi_dm_dump_method_info(acpi_status status, + struct acpi_walk_state *walk_state, + union acpi_parse_object *op); /* * dmbuffer */ -void -acpi_dm_disasm_byte_list ( - u32 level, - u8 *byte_data, - u32 byte_count); +void acpi_dm_disasm_byte_list(u32 level, u8 * byte_data, u32 byte_count); void -acpi_dm_byte_list ( - struct acpi_op_walk_info *info, - union acpi_parse_object *op); +acpi_dm_byte_list(struct acpi_op_walk_info *info, union acpi_parse_object *op); -void -acpi_dm_is_eisa_id ( - union acpi_parse_object *op); +void acpi_dm_is_eisa_id(union acpi_parse_object *op); -void -acpi_dm_eisa_id ( - u32 encoded_id); - -u8 -acpi_dm_is_unicode_buffer ( - union acpi_parse_object *op); +void acpi_dm_eisa_id(u32 encoded_id); -u8 -acpi_dm_is_string_buffer ( - union acpi_parse_object *op); +u8 acpi_dm_is_unicode_buffer(union acpi_parse_object *op); +u8 acpi_dm_is_string_buffer(union acpi_parse_object *op); /* * dmresrc */ void -acpi_dm_resource_descriptor ( - struct acpi_op_walk_info *info, - u8 *byte_data, - u32 byte_count); +acpi_dm_resource_descriptor(struct acpi_op_walk_info *info, + u8 * byte_data, u32 byte_count); -u8 -acpi_dm_is_resource_descriptor ( - union acpi_parse_object *op); +u8 acpi_dm_is_resource_descriptor(union acpi_parse_object *op); -void -acpi_dm_indent ( - u32 level); +void acpi_dm_indent(u32 level); -void -acpi_dm_bit_list ( - u16 mask); - -void -acpi_dm_decode_attribute ( - u8 attribute); +void acpi_dm_bit_list(u16 mask); +void acpi_dm_decode_attribute(u8 attribute); /* * dmresrcl */ void -acpi_dm_word_descriptor ( - struct asl_word_address_desc *resource, - u32 length, - u32 level); +acpi_dm_word_descriptor(struct asl_word_address_desc *resource, + u32 length, u32 level); void -acpi_dm_dword_descriptor ( - struct asl_dword_address_desc *resource, - u32 length, - u32 level); +acpi_dm_dword_descriptor(struct asl_dword_address_desc *resource, + u32 length, u32 level); void -acpi_dm_extended_descriptor ( - struct asl_extended_address_desc *resource, - u32 length, - u32 level); +acpi_dm_extended_descriptor(struct asl_extended_address_desc *resource, + u32 length, u32 level); void -acpi_dm_qword_descriptor ( - struct asl_qword_address_desc *resource, - u32 length, - u32 level); +acpi_dm_qword_descriptor(struct asl_qword_address_desc *resource, + u32 length, u32 level); void -acpi_dm_memory24_descriptor ( - struct asl_memory_24_desc *resource, - u32 length, - u32 level); +acpi_dm_memory24_descriptor(struct asl_memory_24_desc *resource, + u32 length, u32 level); void -acpi_dm_memory32_descriptor ( - struct asl_memory_32_desc *resource, - u32 length, - u32 level); +acpi_dm_memory32_descriptor(struct asl_memory_32_desc *resource, + u32 length, u32 level); void -acpi_dm_fixed_mem32_descriptor ( - struct asl_fixed_memory_32_desc *resource, - u32 length, - u32 level); +acpi_dm_fixed_mem32_descriptor(struct asl_fixed_memory_32_desc *resource, + u32 length, u32 level); void -acpi_dm_generic_register_descriptor ( - struct asl_general_register_desc *resource, - u32 length, - u32 level); +acpi_dm_generic_register_descriptor(struct asl_general_register_desc *resource, + u32 length, u32 level); void -acpi_dm_interrupt_descriptor ( - struct asl_extended_xrupt_desc *resource, - u32 length, - u32 level); +acpi_dm_interrupt_descriptor(struct asl_extended_xrupt_desc *resource, + u32 length, u32 level); void -acpi_dm_vendor_large_descriptor ( - struct asl_large_vendor_desc *resource, - u32 length, - u32 level); - +acpi_dm_vendor_large_descriptor(struct asl_large_vendor_desc *resource, + u32 length, u32 level); /* * dmresrcs */ void -acpi_dm_irq_descriptor ( - struct asl_irq_format_desc *resource, - u32 length, - u32 level); +acpi_dm_irq_descriptor(struct asl_irq_format_desc *resource, + u32 length, u32 level); void -acpi_dm_dma_descriptor ( - struct asl_dma_format_desc *resource, - u32 length, - u32 level); +acpi_dm_dma_descriptor(struct asl_dma_format_desc *resource, + u32 length, u32 level); void -acpi_dm_io_descriptor ( - struct asl_io_port_desc *resource, - u32 length, - u32 level); +acpi_dm_io_descriptor(struct asl_io_port_desc *resource, u32 length, u32 level); void -acpi_dm_fixed_io_descriptor ( - struct asl_fixed_io_port_desc *resource, - u32 length, - u32 level); +acpi_dm_fixed_io_descriptor(struct asl_fixed_io_port_desc *resource, + u32 length, u32 level); void -acpi_dm_start_dependent_descriptor ( - struct asl_start_dependent_desc *resource, - u32 length, - u32 level); +acpi_dm_start_dependent_descriptor(struct asl_start_dependent_desc *resource, + u32 length, u32 level); void -acpi_dm_end_dependent_descriptor ( - struct asl_start_dependent_desc *resource, - u32 length, - u32 level); +acpi_dm_end_dependent_descriptor(struct asl_start_dependent_desc *resource, + u32 length, u32 level); void -acpi_dm_vendor_small_descriptor ( - struct asl_small_vendor_desc *resource, - u32 length, - u32 level); - +acpi_dm_vendor_small_descriptor(struct asl_small_vendor_desc *resource, + u32 length, u32 level); /* * dmutils */ -void -acpi_dm_add_to_external_list ( - char *path); +void acpi_dm_add_to_external_list(char *path); -#endif /* __ACDISASM_H__ */ +#endif /* __ACDISASM_H__ */ diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h index 90b7d30..5930618 100644 --- a/include/acpi/acdispat.h +++ b/include/acpi/acdispat.h @@ -41,413 +41,305 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef _ACDISPAT_H_ #define _ACDISPAT_H_ - #define NAMEOF_LOCAL_NTE "__L0" #define NAMEOF_ARG_NTE "__A0" - /* * dsopcode - support for late evaluation */ acpi_status -acpi_ds_get_buffer_field_arguments ( - union acpi_operand_object *obj_desc); +acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc); -acpi_status -acpi_ds_get_region_arguments ( - union acpi_operand_object *rgn_desc); +acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *rgn_desc); -acpi_status -acpi_ds_get_buffer_arguments ( - union acpi_operand_object *obj_desc); +acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc); -acpi_status -acpi_ds_get_package_arguments ( - union acpi_operand_object *obj_desc); - -acpi_status -acpi_ds_eval_buffer_field_operands ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op); +acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc); acpi_status -acpi_ds_eval_region_operands ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op); +acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state, + union acpi_parse_object *op); acpi_status -acpi_ds_eval_data_object_operands ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - union acpi_operand_object *obj_desc); +acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state, + union acpi_parse_object *op); acpi_status -acpi_ds_initialize_region ( - acpi_handle obj_handle); +acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + union acpi_operand_object *obj_desc); +acpi_status acpi_ds_initialize_region(acpi_handle obj_handle); /* * dsctrl - Parser/Interpreter interface, control stack routines */ acpi_status -acpi_ds_exec_begin_control_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op); +acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, + union acpi_parse_object *op); acpi_status -acpi_ds_exec_end_control_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op); - +acpi_ds_exec_end_control_op(struct acpi_walk_state *walk_state, + union acpi_parse_object *op); /* * dsexec - Parser/Interpreter interface, method execution callbacks */ acpi_status -acpi_ds_get_predicate_value ( - struct acpi_walk_state *walk_state, - union acpi_operand_object *result_obj); +acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state, + union acpi_operand_object *result_obj); acpi_status -acpi_ds_exec_begin_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object **out_op); - -acpi_status -acpi_ds_exec_end_op ( - struct acpi_walk_state *state); +acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state, + union acpi_parse_object **out_op); +acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *state); /* * dsfield - Parser/Interpreter interface for AML fields */ acpi_status -acpi_ds_create_field ( - union acpi_parse_object *op, - struct acpi_namespace_node *region_node, - struct acpi_walk_state *walk_state); +acpi_ds_create_field(union acpi_parse_object *op, + struct acpi_namespace_node *region_node, + struct acpi_walk_state *walk_state); acpi_status -acpi_ds_create_bank_field ( - union acpi_parse_object *op, - struct acpi_namespace_node *region_node, - struct acpi_walk_state *walk_state); +acpi_ds_create_bank_field(union acpi_parse_object *op, + struct acpi_namespace_node *region_node, + struct acpi_walk_state *walk_state); acpi_status -acpi_ds_create_index_field ( - union acpi_parse_object *op, - struct acpi_namespace_node *region_node, - struct acpi_walk_state *walk_state); +acpi_ds_create_index_field(union acpi_parse_object *op, + struct acpi_namespace_node *region_node, + struct acpi_walk_state *walk_state); acpi_status -acpi_ds_create_buffer_field ( - union acpi_parse_object *op, - struct acpi_walk_state *walk_state); +acpi_ds_create_buffer_field(union acpi_parse_object *op, + struct acpi_walk_state *walk_state); acpi_status -acpi_ds_init_field_objects ( - union acpi_parse_object *op, - struct acpi_walk_state *walk_state); - +acpi_ds_init_field_objects(union acpi_parse_object *op, + struct acpi_walk_state *walk_state); /* * dsload - Parser/Interpreter interface, namespace load callbacks */ acpi_status -acpi_ds_load1_begin_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object **out_op); +acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state, + union acpi_parse_object **out_op); -acpi_status -acpi_ds_load1_end_op ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state); acpi_status -acpi_ds_load2_begin_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object **out_op); +acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, + union acpi_parse_object **out_op); -acpi_status -acpi_ds_load2_end_op ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state); acpi_status -acpi_ds_init_callbacks ( - struct acpi_walk_state *walk_state, - u32 pass_number); - +acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number); /* * dsmthdat - method data (locals/args) */ acpi_status -acpi_ds_store_object_to_local ( - u16 opcode, - u32 index, - union acpi_operand_object *src_desc, - struct acpi_walk_state *walk_state); +acpi_ds_store_object_to_local(u16 opcode, + u32 index, + union acpi_operand_object *src_desc, + struct acpi_walk_state *walk_state); acpi_status -acpi_ds_method_data_get_entry ( - u16 opcode, - u32 index, - struct acpi_walk_state *walk_state, - union acpi_operand_object ***node); +acpi_ds_method_data_get_entry(u16 opcode, + u32 index, + struct acpi_walk_state *walk_state, + union acpi_operand_object ***node); -void -acpi_ds_method_data_delete_all ( - struct acpi_walk_state *walk_state); +void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state); -u8 -acpi_ds_is_method_value ( - union acpi_operand_object *obj_desc); +u8 acpi_ds_is_method_value(union acpi_operand_object *obj_desc); acpi_status -acpi_ds_method_data_get_value ( - u16 opcode, - u32 index, - struct acpi_walk_state *walk_state, - union acpi_operand_object **dest_desc); +acpi_ds_method_data_get_value(u16 opcode, + u32 index, + struct acpi_walk_state *walk_state, + union acpi_operand_object **dest_desc); acpi_status -acpi_ds_method_data_init_args ( - union acpi_operand_object **params, - u32 max_param_count, - struct acpi_walk_state *walk_state); +acpi_ds_method_data_init_args(union acpi_operand_object **params, + u32 max_param_count, + struct acpi_walk_state *walk_state); acpi_status -acpi_ds_method_data_get_node ( - u16 opcode, - u32 index, - struct acpi_walk_state *walk_state, - struct acpi_namespace_node **node); - -void -acpi_ds_method_data_init ( - struct acpi_walk_state *walk_state); +acpi_ds_method_data_get_node(u16 opcode, + u32 index, + struct acpi_walk_state *walk_state, + struct acpi_namespace_node **node); +void acpi_ds_method_data_init(struct acpi_walk_state *walk_state); /* * dsmethod - Parser/Interpreter interface - control method parsing */ -acpi_status -acpi_ds_parse_method ( - struct acpi_namespace_node *node); +acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node); acpi_status -acpi_ds_call_control_method ( - struct acpi_thread_state *thread, - struct acpi_walk_state *walk_state, - union acpi_parse_object *op); +acpi_ds_call_control_method(struct acpi_thread_state *thread, + struct acpi_walk_state *walk_state, + union acpi_parse_object *op); acpi_status -acpi_ds_restart_control_method ( - struct acpi_walk_state *walk_state, - union acpi_operand_object *return_desc); +acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, + union acpi_operand_object *return_desc); acpi_status -acpi_ds_terminate_control_method ( - struct acpi_walk_state *walk_state); +acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state); acpi_status -acpi_ds_begin_method_execution ( - struct acpi_namespace_node *method_node, - union acpi_operand_object *obj_desc, - struct acpi_namespace_node *calling_method_node); - +acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, + union acpi_operand_object *obj_desc, + struct acpi_namespace_node *calling_method_node); /* * dsinit */ acpi_status -acpi_ds_initialize_objects ( - struct acpi_table_desc *table_desc, - struct acpi_namespace_node *start_node); - +acpi_ds_initialize_objects(struct acpi_table_desc *table_desc, + struct acpi_namespace_node *start_node); /* * dsobject - Parser/Interpreter interface - object initialization and conversion */ acpi_status -acpi_ds_build_internal_buffer_obj ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - u32 buffer_length, - union acpi_operand_object **obj_desc_ptr); +acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + u32 buffer_length, + union acpi_operand_object **obj_desc_ptr); acpi_status -acpi_ds_build_internal_package_obj ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - u32 package_length, - union acpi_operand_object **obj_desc); +acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + u32 package_length, + union acpi_operand_object **obj_desc); acpi_status -acpi_ds_init_object_from_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - u16 opcode, - union acpi_operand_object **obj_desc); +acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + u16 opcode, union acpi_operand_object **obj_desc); acpi_status -acpi_ds_create_node ( - struct acpi_walk_state *walk_state, - struct acpi_namespace_node *node, - union acpi_parse_object *op); - +acpi_ds_create_node(struct acpi_walk_state *walk_state, + struct acpi_namespace_node *node, + union acpi_parse_object *op); /* * dsutils - Parser/Interpreter interface utility routines */ -void -acpi_ds_clear_implicit_return ( - struct acpi_walk_state *walk_state); +void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state); u8 -acpi_ds_do_implicit_return ( - union acpi_operand_object *return_desc, - struct acpi_walk_state *walk_state, - u8 add_reference); +acpi_ds_do_implicit_return(union acpi_operand_object *return_desc, + struct acpi_walk_state *walk_state, + u8 add_reference); u8 -acpi_ds_is_result_used ( - union acpi_parse_object *op, - struct acpi_walk_state *walk_state); +acpi_ds_is_result_used(union acpi_parse_object *op, + struct acpi_walk_state *walk_state); void -acpi_ds_delete_result_if_not_used ( - union acpi_parse_object *op, - union acpi_operand_object *result_obj, - struct acpi_walk_state *walk_state); - -acpi_status -acpi_ds_create_operand ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *arg, - u32 args_remaining); +acpi_ds_delete_result_if_not_used(union acpi_parse_object *op, + union acpi_operand_object *result_obj, + struct acpi_walk_state *walk_state); acpi_status -acpi_ds_create_operands ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *first_arg); +acpi_ds_create_operand(struct acpi_walk_state *walk_state, + union acpi_parse_object *arg, u32 args_remaining); acpi_status -acpi_ds_resolve_operands ( - struct acpi_walk_state *walk_state); +acpi_ds_create_operands(struct acpi_walk_state *walk_state, + union acpi_parse_object *first_arg); -void -acpi_ds_clear_operands ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state); +void acpi_ds_clear_operands(struct acpi_walk_state *walk_state); /* * dswscope - Scope Stack manipulation */ acpi_status -acpi_ds_scope_stack_push ( - struct acpi_namespace_node *node, - acpi_object_type type, - struct acpi_walk_state *walk_state); +acpi_ds_scope_stack_push(struct acpi_namespace_node *node, + acpi_object_type type, + struct acpi_walk_state *walk_state); +acpi_status acpi_ds_scope_stack_pop(struct acpi_walk_state *walk_state); -acpi_status -acpi_ds_scope_stack_pop ( - struct acpi_walk_state *walk_state); - -void -acpi_ds_scope_stack_clear ( - struct acpi_walk_state *walk_state); - +void acpi_ds_scope_stack_clear(struct acpi_walk_state *walk_state); /* * dswstate - parser WALK_STATE management routines */ acpi_status -acpi_ds_obj_stack_push ( - void *object, - struct acpi_walk_state *walk_state); +acpi_ds_obj_stack_push(void *object, struct acpi_walk_state *walk_state); acpi_status -acpi_ds_obj_stack_pop ( - u32 pop_count, - struct acpi_walk_state *walk_state); +acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state *walk_state); -struct acpi_walk_state * -acpi_ds_create_walk_state ( - acpi_owner_id owner_id, - union acpi_parse_object *origin, - union acpi_operand_object *mth_desc, - struct acpi_thread_state *thread); +struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, + union acpi_parse_object + *origin, + union acpi_operand_object + *mth_desc, + struct acpi_thread_state + *thread); acpi_status -acpi_ds_init_aml_walk ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - struct acpi_namespace_node *method_node, - u8 *aml_start, - u32 aml_length, - struct acpi_parameter_info *info, - u8 pass_number); +acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + struct acpi_namespace_node *method_node, + u8 * aml_start, + u32 aml_length, + struct acpi_parameter_info *info, u8 pass_number); acpi_status -acpi_ds_obj_stack_pop_and_delete ( - u32 pop_count, - struct acpi_walk_state *walk_state); +acpi_ds_obj_stack_pop_and_delete(u32 pop_count, + struct acpi_walk_state *walk_state); -void -acpi_ds_delete_walk_state ( - struct acpi_walk_state *walk_state); +void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state); -struct acpi_walk_state * -acpi_ds_pop_walk_state ( - struct acpi_thread_state *thread); +struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state + *thread); void -acpi_ds_push_walk_state ( - struct acpi_walk_state *walk_state, - struct acpi_thread_state *thread); +acpi_ds_push_walk_state(struct acpi_walk_state *walk_state, + struct acpi_thread_state *thread); -acpi_status -acpi_ds_result_stack_pop ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state *walk_state); -acpi_status -acpi_ds_result_stack_push ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ds_result_stack_push(struct acpi_walk_state *walk_state); -acpi_status -acpi_ds_result_stack_clear ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ds_result_stack_clear(struct acpi_walk_state *walk_state); -struct acpi_walk_state * -acpi_ds_get_current_walk_state ( - struct acpi_thread_state *thread); +struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state + *thread); #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_ds_result_remove ( - union acpi_operand_object **object, - u32 index, - struct acpi_walk_state *walk_state); +acpi_ds_result_remove(union acpi_operand_object **object, + u32 index, struct acpi_walk_state *walk_state); #endif acpi_status -acpi_ds_result_pop ( - union acpi_operand_object **object, - struct acpi_walk_state *walk_state); +acpi_ds_result_pop(union acpi_operand_object **object, + struct acpi_walk_state *walk_state); acpi_status -acpi_ds_result_push ( - union acpi_operand_object *object, - struct acpi_walk_state *walk_state); +acpi_ds_result_push(union acpi_operand_object *object, + struct acpi_walk_state *walk_state); acpi_status -acpi_ds_result_pop_from_bottom ( - union acpi_operand_object **object, - struct acpi_walk_state *walk_state); +acpi_ds_result_pop_from_bottom(union acpi_operand_object **object, + struct acpi_walk_state *walk_state); -#endif /* _ACDISPAT_H_ */ +#endif /* _ACDISPAT_H_ */ diff --git a/include/acpi/acevents.h b/include/acpi/acevents.h index 33ae2ca..bfa5460 100644 --- a/include/acpi/acevents.h +++ b/include/acpi/acevents.h @@ -44,249 +44,167 @@ #ifndef __ACEVENTS_H__ #define __ACEVENTS_H__ - /* * evevent */ -acpi_status -acpi_ev_initialize_events ( - void); +acpi_status acpi_ev_initialize_events(void); -acpi_status -acpi_ev_install_xrupt_handlers ( - void); - -u32 -acpi_ev_fixed_event_detect ( - void); +acpi_status acpi_ev_install_xrupt_handlers(void); +u32 acpi_ev_fixed_event_detect(void); /* * evmisc */ -u8 -acpi_ev_is_notify_object ( - struct acpi_namespace_node *node); +u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node); -acpi_status -acpi_ev_acquire_global_lock( - u16 timeout); +acpi_status acpi_ev_acquire_global_lock(u16 timeout); -acpi_status -acpi_ev_release_global_lock( - void); +acpi_status acpi_ev_release_global_lock(void); -acpi_status -acpi_ev_init_global_lock_handler ( - void); +acpi_status acpi_ev_init_global_lock_handler(void); -u32 -acpi_ev_get_gpe_number_index ( - u32 gpe_number); +u32 acpi_ev_get_gpe_number_index(u32 gpe_number); acpi_status -acpi_ev_queue_notify_request ( - struct acpi_namespace_node *node, - u32 notify_value); - +acpi_ev_queue_notify_request(struct acpi_namespace_node *node, + u32 notify_value); /* * evgpe - GPE handling and dispatch */ acpi_status -acpi_ev_update_gpe_enable_masks ( - struct acpi_gpe_event_info *gpe_event_info, - u8 type); +acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info, + u8 type); acpi_status -acpi_ev_enable_gpe ( - struct acpi_gpe_event_info *gpe_event_info, - u8 write_to_hardware); +acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info, + u8 write_to_hardware); -acpi_status -acpi_ev_disable_gpe ( - struct acpi_gpe_event_info *gpe_event_info); - -struct acpi_gpe_event_info * -acpi_ev_get_gpe_event_info ( - acpi_handle gpe_device, - u32 gpe_number); +acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info); +struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, + u32 gpe_number); /* * evgpeblk */ -u8 -acpi_ev_valid_gpe_event ( - struct acpi_gpe_event_info *gpe_event_info); - -acpi_status -acpi_ev_walk_gpe_list ( - ACPI_GPE_CALLBACK gpe_walk_callback); +u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info); -acpi_status -acpi_ev_delete_gpe_handlers ( - struct acpi_gpe_xrupt_info *gpe_xrupt_info, - struct acpi_gpe_block_info *gpe_block); +acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback); acpi_status -acpi_ev_create_gpe_block ( - struct acpi_namespace_node *gpe_device, - struct acpi_generic_address *gpe_block_address, - u32 register_count, - u8 gpe_block_base_number, - u32 interrupt_number, - struct acpi_gpe_block_info **return_gpe_block); +acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, + struct acpi_gpe_block_info *gpe_block); acpi_status -acpi_ev_delete_gpe_block ( - struct acpi_gpe_block_info *gpe_block); +acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, + struct acpi_generic_address *gpe_block_address, + u32 register_count, + u8 gpe_block_base_number, + u32 interrupt_number, + struct acpi_gpe_block_info **return_gpe_block); -u32 -acpi_ev_gpe_dispatch ( - struct acpi_gpe_event_info *gpe_event_info, - u32 gpe_number); +acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block); u32 -acpi_ev_gpe_detect ( - struct acpi_gpe_xrupt_info *gpe_xrupt_list); +acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, + u32 gpe_number); -acpi_status -acpi_ev_set_gpe_type ( - struct acpi_gpe_event_info *gpe_event_info, - u8 type); +u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list); acpi_status -acpi_ev_check_for_wake_only_gpe ( - struct acpi_gpe_event_info *gpe_event_info); +acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type); acpi_status -acpi_ev_gpe_initialize ( - void); +acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info); +acpi_status acpi_ev_gpe_initialize(void); /* * evregion - Address Space handling */ -acpi_status -acpi_ev_install_region_handlers ( - void); +acpi_status acpi_ev_install_region_handlers(void); -acpi_status -acpi_ev_initialize_op_regions ( - void); +acpi_status acpi_ev_initialize_op_regions(void); acpi_status -acpi_ev_address_space_dispatch ( - union acpi_operand_object *region_obj, - u32 function, - acpi_physical_address address, - u32 bit_width, - void *value); +acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, + u32 function, + acpi_physical_address address, + u32 bit_width, void *value); acpi_status -acpi_ev_attach_region ( - union acpi_operand_object *handler_obj, - union acpi_operand_object *region_obj, - u8 acpi_ns_is_locked); +acpi_ev_attach_region(union acpi_operand_object *handler_obj, + union acpi_operand_object *region_obj, + u8 acpi_ns_is_locked); void -acpi_ev_detach_region ( - union acpi_operand_object *region_obj, - u8 acpi_ns_is_locked); +acpi_ev_detach_region(union acpi_operand_object *region_obj, + u8 acpi_ns_is_locked); acpi_status -acpi_ev_install_space_handler ( - struct acpi_namespace_node *node, - acpi_adr_space_type space_id, - acpi_adr_space_handler handler, - acpi_adr_space_setup setup, - void *context); +acpi_ev_install_space_handler(struct acpi_namespace_node *node, + acpi_adr_space_type space_id, + acpi_adr_space_handler handler, + acpi_adr_space_setup setup, void *context); acpi_status -acpi_ev_execute_reg_methods ( - struct acpi_namespace_node *node, - acpi_adr_space_type space_id); +acpi_ev_execute_reg_methods(struct acpi_namespace_node *node, + acpi_adr_space_type space_id); acpi_status -acpi_ev_execute_reg_method ( - union acpi_operand_object *region_obj, - u32 function); - +acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function); /* * evregini - Region initialization and setup */ acpi_status -acpi_ev_system_memory_region_setup ( - acpi_handle handle, - u32 function, - void *handler_context, - void **region_context); +acpi_ev_system_memory_region_setup(acpi_handle handle, + u32 function, + void *handler_context, + void **region_context); acpi_status -acpi_ev_io_space_region_setup ( - acpi_handle handle, - u32 function, - void *handler_context, - void **region_context); +acpi_ev_io_space_region_setup(acpi_handle handle, + u32 function, + void *handler_context, void **region_context); acpi_status -acpi_ev_pci_config_region_setup ( - acpi_handle handle, - u32 function, - void *handler_context, - void **region_context); +acpi_ev_pci_config_region_setup(acpi_handle handle, + u32 function, + void *handler_context, void **region_context); acpi_status -acpi_ev_cmos_region_setup ( - acpi_handle handle, - u32 function, - void *handler_context, - void **region_context); +acpi_ev_cmos_region_setup(acpi_handle handle, + u32 function, + void *handler_context, void **region_context); acpi_status -acpi_ev_pci_bar_region_setup ( - acpi_handle handle, - u32 function, - void *handler_context, - void **region_context); +acpi_ev_pci_bar_region_setup(acpi_handle handle, + u32 function, + void *handler_context, void **region_context); acpi_status -acpi_ev_default_region_setup ( - acpi_handle handle, - u32 function, - void *handler_context, - void **region_context); +acpi_ev_default_region_setup(acpi_handle handle, + u32 function, + void *handler_context, void **region_context); acpi_status -acpi_ev_initialize_region ( - union acpi_operand_object *region_obj, - u8 acpi_ns_locked); - +acpi_ev_initialize_region(union acpi_operand_object *region_obj, + u8 acpi_ns_locked); /* * evsci - SCI (System Control Interrupt) handling/dispatch */ -u32 ACPI_SYSTEM_XFACE -acpi_ev_gpe_xrupt_handler ( - void *context); - -u32 -acpi_ev_install_sci_handler ( - void); +u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context); -acpi_status -acpi_ev_remove_sci_handler ( - void); +u32 acpi_ev_install_sci_handler(void); -u32 -acpi_ev_initialize_sCI ( - u32 program_sCI); +acpi_status acpi_ev_remove_sci_handler(void); -void -acpi_ev_terminate ( - void); +u32 acpi_ev_initialize_sCI(u32 program_sCI); +void acpi_ev_terminate(void); -#endif /* __ACEVENTS_H__ */ +#endif /* __ACEVENTS_H__ */ diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h index 0a6f492..4f005eb 100644 --- a/include/acpi/acexcep.h +++ b/include/acpi/acexcep.h @@ -44,7 +44,6 @@ #ifndef __ACEXCEP_H__ #define __ACEXCEP_H__ - /* * Exceptions returned by external ACPI interfaces */ @@ -55,11 +54,9 @@ #define AE_CODE_CONTROL 0x4000 #define AE_CODE_MASK 0xF000 - #define ACPI_SUCCESS(a) (!(a)) #define ACPI_FAILURE(a) (a) - #define AE_OK (acpi_status) 0x0000 /* @@ -99,7 +96,6 @@ #define AE_CODE_ENV_MAX 0x001F - /* * Programmer exceptions */ @@ -115,7 +111,6 @@ #define AE_CODE_PGM_MAX 0x0009 - /* * Acpi table exceptions */ @@ -128,7 +123,6 @@ #define AE_CODE_TBL_MAX 0x0006 - /* * AML exceptions. These are caused by problems with * the actual AML byte stream @@ -169,7 +163,6 @@ #define AE_CODE_AML_MAX 0x0021 - /* * Internal exceptions used for control */ @@ -187,16 +180,13 @@ #define AE_CODE_CTRL_MAX 0x000B - #ifdef DEFINE_ACPI_GLOBALS - /* * String versions of the exception codes above * These strings must match the corresponding defines exactly */ -char const *acpi_gbl_exception_names_env[] = -{ +char const *acpi_gbl_exception_names_env[] = { "AE_OK", "AE_ERROR", "AE_NO_ACPI_TABLES", @@ -231,8 +221,7 @@ char const *acpi_gbl_exception_names_env[] = "AE_OWNER_ID_LIMIT" }; -char const *acpi_gbl_exception_names_pgm[] = -{ +char const *acpi_gbl_exception_names_pgm[] = { "AE_BAD_PARAMETER", "AE_BAD_CHARACTER", "AE_BAD_PATHNAME", @@ -244,8 +233,7 @@ char const *acpi_gbl_exception_names_pgm[] = "AE_BAD_DECIMAL_CONSTANT" }; -char const *acpi_gbl_exception_names_tbl[] = -{ +char const *acpi_gbl_exception_names_tbl[] = { "AE_BAD_SIGNATURE", "AE_BAD_HEADER", "AE_BAD_CHECKSUM", @@ -254,8 +242,7 @@ char const *acpi_gbl_exception_names_tbl[] = "AE_INVALID_TABLE_LENGTH" }; -char const *acpi_gbl_exception_names_aml[] = -{ +char const *acpi_gbl_exception_names_aml[] = { "AE_AML_ERROR", "AE_AML_PARSE", "AE_AML_BAD_OPCODE", @@ -291,8 +278,7 @@ char const *acpi_gbl_exception_names_aml[] = "AE_AML_BAD_RESOURCE_LENGTH" }; -char const *acpi_gbl_exception_names_ctrl[] = -{ +char const *acpi_gbl_exception_names_ctrl[] = { "AE_CTRL_RETURN_VALUE", "AE_CTRL_PENDING", "AE_CTRL_TERMINATE", @@ -306,6 +292,6 @@ char const *acpi_gbl_exception_names_ctrl[] = "AE_CTRL_SKIP" }; -#endif /* ACPI GLOBALS */ +#endif /* ACPI GLOBALS */ -#endif /* __ACEXCEP_H__ */ +#endif /* __ACEXCEP_H__ */ diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h index e3cf16e..e9c2790 100644 --- a/include/acpi/acglobal.h +++ b/include/acpi/acglobal.h @@ -44,7 +44,6 @@ #ifndef __ACGLOBAL_H__ #define __ACGLOBAL_H__ - /* * Ensure that the globals are actually defined and initialized only once. * @@ -63,9 +62,8 @@ * Keep local copies of these FADT-based registers. NOTE: These globals * are first in this file for alignment reasons on 64-bit systems. */ -ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_enable; -ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable; - +ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_enable; +ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable; /***************************************************************************** * @@ -75,13 +73,12 @@ ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable; /* Runtime configuration of debug print levels */ -extern u32 acpi_dbg_level; -extern u32 acpi_dbg_layer; +extern u32 acpi_dbg_level; +extern u32 acpi_dbg_layer; /* Procedure nesting level for debug output */ -extern u32 acpi_gbl_nesting_level; - +extern u32 acpi_gbl_nesting_level; /***************************************************************************** * @@ -98,7 +95,7 @@ extern u32 acpi_gbl_nesting_level; * 3) Allow access to uninitialized locals/args (auto-init to integer 0) * 4) Allow ANY object type to be a source operand for the Store() operator */ -ACPI_EXTERN u8 ACPI_INIT_GLOBAL (acpi_gbl_enable_interpreter_slack, FALSE); +ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE); /* * Automatically serialize ALL control methods? Default is FALSE, meaning @@ -106,22 +103,21 @@ ACPI_EXTERN u8 ACPI_INIT_GLOBAL (acpi_gbl_enable_interpreter_slack, FALSE) * Only change this if the ASL code is poorly written and cannot handle * reentrancy even though methods are marked "not_serialized". */ -ACPI_EXTERN u8 ACPI_INIT_GLOBAL (acpi_gbl_all_methods_serialized, FALSE); +ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_all_methods_serialized, FALSE); /* * Create the predefined _OSI method in the namespace? Default is TRUE * because ACPI CA is fully compatible with other ACPI implementations. * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. */ -ACPI_EXTERN u8 ACPI_INIT_GLOBAL (acpi_gbl_create_osi_method, TRUE); +ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_create_osi_method, TRUE); /* * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only * be enabled just before going to sleep. */ -ACPI_EXTERN u8 ACPI_INIT_GLOBAL (acpi_gbl_leave_wake_gpes_disabled, TRUE); - +ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_leave_wake_gpes_disabled, TRUE); /***************************************************************************** * @@ -137,49 +133,46 @@ ACPI_EXTERN u8 ACPI_INIT_GLOBAL (acpi_gbl_leave_wake_gpes_disabled, TRUE); * These tables are single-table only; meaning that there can be at most one * of each in the system. Each global points to the actual table. */ -ACPI_EXTERN u32 acpi_gbl_table_flags; -ACPI_EXTERN u32 acpi_gbl_rsdt_table_count; -ACPI_EXTERN struct rsdp_descriptor *acpi_gbl_RSDP; -ACPI_EXTERN XSDT_DESCRIPTOR *acpi_gbl_XSDT; -ACPI_EXTERN FADT_DESCRIPTOR *acpi_gbl_FADT; -ACPI_EXTERN struct acpi_table_header *acpi_gbl_DSDT; -ACPI_EXTERN FACS_DESCRIPTOR *acpi_gbl_FACS; -ACPI_EXTERN struct acpi_common_facs acpi_gbl_common_fACS; +ACPI_EXTERN u32 acpi_gbl_table_flags; +ACPI_EXTERN u32 acpi_gbl_rsdt_table_count; +ACPI_EXTERN struct rsdp_descriptor *acpi_gbl_RSDP; +ACPI_EXTERN XSDT_DESCRIPTOR *acpi_gbl_XSDT; +ACPI_EXTERN FADT_DESCRIPTOR *acpi_gbl_FADT; +ACPI_EXTERN struct acpi_table_header *acpi_gbl_DSDT; +ACPI_EXTERN FACS_DESCRIPTOR *acpi_gbl_FACS; +ACPI_EXTERN struct acpi_common_facs acpi_gbl_common_fACS; /* * Since there may be multiple SSDTs and PSDTs, a single pointer is not * sufficient; Therefore, there isn't one! */ - /* The root table can be either an RSDT or an XSDT */ -ACPI_EXTERN u8 acpi_gbl_root_table_type; +ACPI_EXTERN u8 acpi_gbl_root_table_type; #define ACPI_TABLE_TYPE_RSDT 'R' #define ACPI_TABLE_TYPE_XSDT 'X' - /* * Handle both ACPI 1.0 and ACPI 2.0 Integer widths: * If we are executing a method that exists in a 32-bit ACPI table, * use only the lower 32 bits of the (internal) 64-bit Integer. */ -ACPI_EXTERN u8 acpi_gbl_integer_bit_width; -ACPI_EXTERN u8 acpi_gbl_integer_byte_width; -ACPI_EXTERN u8 acpi_gbl_integer_nybble_width; +ACPI_EXTERN u8 acpi_gbl_integer_bit_width; +ACPI_EXTERN u8 acpi_gbl_integer_byte_width; +ACPI_EXTERN u8 acpi_gbl_integer_nybble_width; /* * ACPI Table info arrays */ -extern struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES]; -extern struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES]; +extern struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES]; +extern struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES]; /* * Predefined mutex objects. This array contains the * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. * (The table maps local handles to the real OS handles) */ -ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[NUM_MUTEX]; - +ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[NUM_MUTEX]; /***************************************************************************** * @@ -191,53 +184,52 @@ ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[NUM_MUTEX]; /* Lists for tracking memory allocations */ -ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list; -ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list; +ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list; +ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list; #endif /* Object caches */ -ACPI_EXTERN acpi_cache_t *acpi_gbl_state_cache; -ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_cache; -ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_ext_cache; -ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache; +ACPI_EXTERN acpi_cache_t *acpi_gbl_state_cache; +ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_cache; +ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_ext_cache; +ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache; /* Global handlers */ -ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_device_notify; -ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify; -ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler; -ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler; -ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk; -ACPI_EXTERN acpi_handle acpi_gbl_global_lock_semaphore; +ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_device_notify; +ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify; +ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler; +ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler; +ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk; +ACPI_EXTERN acpi_handle acpi_gbl_global_lock_semaphore; /* Misc */ -ACPI_EXTERN u32 acpi_gbl_global_lock_thread_count; -ACPI_EXTERN u32 acpi_gbl_original_mode; -ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; -ACPI_EXTERN u32 acpi_gbl_ns_lookup_count; -ACPI_EXTERN u32 acpi_gbl_ps_find_count; -ACPI_EXTERN u32 acpi_gbl_owner_id_mask; -ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; -ACPI_EXTERN u16 acpi_gbl_global_lock_handle; -ACPI_EXTERN u8 acpi_gbl_debugger_configuration; -ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; -ACPI_EXTERN u8 acpi_gbl_step_to_next_call; -ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present; -ACPI_EXTERN u8 acpi_gbl_global_lock_present; -ACPI_EXTERN u8 acpi_gbl_events_initialized; -ACPI_EXTERN u8 acpi_gbl_system_awake_and_running; - -extern u8 acpi_gbl_shutdown; -extern u32 acpi_gbl_startup_flags; -extern const u8 acpi_gbl_decode_to8bit[8]; -extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT]; -extern const char *acpi_gbl_highest_dstate_names[4]; -extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES]; -extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS]; -extern const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS]; - +ACPI_EXTERN u32 acpi_gbl_global_lock_thread_count; +ACPI_EXTERN u32 acpi_gbl_original_mode; +ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; +ACPI_EXTERN u32 acpi_gbl_ns_lookup_count; +ACPI_EXTERN u32 acpi_gbl_ps_find_count; +ACPI_EXTERN u32 acpi_gbl_owner_id_mask; +ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; +ACPI_EXTERN u16 acpi_gbl_global_lock_handle; +ACPI_EXTERN u8 acpi_gbl_debugger_configuration; +ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; +ACPI_EXTERN u8 acpi_gbl_step_to_next_call; +ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present; +ACPI_EXTERN u8 acpi_gbl_global_lock_present; +ACPI_EXTERN u8 acpi_gbl_events_initialized; +ACPI_EXTERN u8 acpi_gbl_system_awake_and_running; + +extern u8 acpi_gbl_shutdown; +extern u32 acpi_gbl_startup_flags; +extern const u8 acpi_gbl_decode_to8bit[8]; +extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT]; +extern const char *acpi_gbl_highest_dstate_names[4]; +extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES]; +extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS]; +extern const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS]; /***************************************************************************** * @@ -253,36 +245,34 @@ extern const char *acpi_gbl_valid_osi_strings[ACPI_ #define NUM_PREDEFINED_NAMES 9 #endif -ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct; -ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node; -ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device; +ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct; +ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node; +ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device; -extern const u8 acpi_gbl_ns_properties[NUM_NS_TYPES]; -extern const struct acpi_predefined_names acpi_gbl_pre_defined_names [NUM_PREDEFINED_NAMES]; +extern const u8 acpi_gbl_ns_properties[NUM_NS_TYPES]; +extern const struct acpi_predefined_names + acpi_gbl_pre_defined_names[NUM_PREDEFINED_NAMES]; #ifdef ACPI_DEBUG_OUTPUT -ACPI_EXTERN u32 acpi_gbl_current_node_count; -ACPI_EXTERN u32 acpi_gbl_current_node_size; -ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count; -ACPI_EXTERN acpi_size acpi_gbl_entry_stack_pointer; -ACPI_EXTERN acpi_size acpi_gbl_lowest_stack_pointer; -ACPI_EXTERN u32 acpi_gbl_deepest_nesting; +ACPI_EXTERN u32 acpi_gbl_current_node_count; +ACPI_EXTERN u32 acpi_gbl_current_node_size; +ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count; +ACPI_EXTERN acpi_size acpi_gbl_entry_stack_pointer; +ACPI_EXTERN acpi_size acpi_gbl_lowest_stack_pointer; +ACPI_EXTERN u32 acpi_gbl_deepest_nesting; #endif - /***************************************************************************** * * Interpreter globals * ****************************************************************************/ - -ACPI_EXTERN struct acpi_thread_state *acpi_gbl_current_walk_list; +ACPI_EXTERN struct acpi_thread_state *acpi_gbl_current_walk_list; /* Control method single step flag */ -ACPI_EXTERN u8 acpi_gbl_cm_single_step; - +ACPI_EXTERN u8 acpi_gbl_cm_single_step; /***************************************************************************** * @@ -290,8 +280,7 @@ ACPI_EXTERN u8 acpi_gbl_cm_single_step; * ****************************************************************************/ -ACPI_EXTERN union acpi_parse_object *acpi_gbl_parsed_namespace_root; - +ACPI_EXTERN union acpi_parse_object *acpi_gbl_parsed_namespace_root; /***************************************************************************** * @@ -299,10 +288,10 @@ ACPI_EXTERN union acpi_parse_object *acpi_gbl_parsed_namespace_root; * ****************************************************************************/ -extern struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG]; -ACPI_EXTERN u8 acpi_gbl_sleep_type_a; -ACPI_EXTERN u8 acpi_gbl_sleep_type_b; - +extern struct acpi_bit_register_info + acpi_gbl_bit_register_info[ACPI_NUM_BITREG]; +ACPI_EXTERN u8 acpi_gbl_sleep_type_a; +ACPI_EXTERN u8 acpi_gbl_sleep_type_b; /***************************************************************************** * @@ -310,12 +299,14 @@ ACPI_EXTERN u8 acpi_gbl_sleep_type_b; * ****************************************************************************/ -extern struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS]; -ACPI_EXTERN struct acpi_fixed_event_handler acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS]; -ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head; -ACPI_EXTERN struct acpi_gpe_block_info *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS]; -ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock; - +extern struct acpi_fixed_event_info + acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS]; +ACPI_EXTERN struct acpi_fixed_event_handler + acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS]; +ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head; +ACPI_EXTERN struct acpi_gpe_block_info + *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS]; +ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock; /***************************************************************************** * @@ -323,58 +314,55 @@ ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock; * ****************************************************************************/ -ACPI_EXTERN u8 acpi_gbl_db_output_flags; +ACPI_EXTERN u8 acpi_gbl_db_output_flags; #ifdef ACPI_DISASSEMBLER -ACPI_EXTERN u8 acpi_gbl_db_opt_disasm; -ACPI_EXTERN u8 acpi_gbl_db_opt_verbose; +ACPI_EXTERN u8 acpi_gbl_db_opt_disasm; +ACPI_EXTERN u8 acpi_gbl_db_opt_verbose; #endif - #ifdef ACPI_DEBUGGER -extern u8 acpi_gbl_method_executing; -extern u8 acpi_gbl_abort_method; -extern u8 acpi_gbl_db_terminate_threads; - -ACPI_EXTERN int optind; -ACPI_EXTERN char *optarg; - -ACPI_EXTERN u8 acpi_gbl_db_opt_tables; -ACPI_EXTERN u8 acpi_gbl_db_opt_stats; -ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods; - - -ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]; -ACPI_EXTERN char acpi_gbl_db_line_buf[80]; -ACPI_EXTERN char acpi_gbl_db_parsed_buf[80]; -ACPI_EXTERN char acpi_gbl_db_scope_buf[40]; -ACPI_EXTERN char acpi_gbl_db_debug_filename[40]; -ACPI_EXTERN u8 acpi_gbl_db_output_to_file; -ACPI_EXTERN char *acpi_gbl_db_buffer; -ACPI_EXTERN char *acpi_gbl_db_filename; -ACPI_EXTERN u32 acpi_gbl_db_debug_level; -ACPI_EXTERN u32 acpi_gbl_db_console_debug_level; -ACPI_EXTERN struct acpi_table_header *acpi_gbl_db_table_ptr; -ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node; +extern u8 acpi_gbl_method_executing; +extern u8 acpi_gbl_abort_method; +extern u8 acpi_gbl_db_terminate_threads; + +ACPI_EXTERN int optind; +ACPI_EXTERN char *optarg; + +ACPI_EXTERN u8 acpi_gbl_db_opt_tables; +ACPI_EXTERN u8 acpi_gbl_db_opt_stats; +ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods; + +ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]; +ACPI_EXTERN char acpi_gbl_db_line_buf[80]; +ACPI_EXTERN char acpi_gbl_db_parsed_buf[80]; +ACPI_EXTERN char acpi_gbl_db_scope_buf[40]; +ACPI_EXTERN char acpi_gbl_db_debug_filename[40]; +ACPI_EXTERN u8 acpi_gbl_db_output_to_file; +ACPI_EXTERN char *acpi_gbl_db_buffer; +ACPI_EXTERN char *acpi_gbl_db_filename; +ACPI_EXTERN u32 acpi_gbl_db_debug_level; +ACPI_EXTERN u32 acpi_gbl_db_console_debug_level; +ACPI_EXTERN struct acpi_table_header *acpi_gbl_db_table_ptr; +ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node; /* * Statistic globals */ -ACPI_EXTERN u16 acpi_gbl_obj_type_count[ACPI_TYPE_NS_NODE_MAX+1]; -ACPI_EXTERN u16 acpi_gbl_node_type_count[ACPI_TYPE_NS_NODE_MAX+1]; -ACPI_EXTERN u16 acpi_gbl_obj_type_count_misc; -ACPI_EXTERN u16 acpi_gbl_node_type_count_misc; -ACPI_EXTERN u32 acpi_gbl_num_nodes; -ACPI_EXTERN u32 acpi_gbl_num_objects; - +ACPI_EXTERN u16 acpi_gbl_obj_type_count[ACPI_TYPE_NS_NODE_MAX + 1]; +ACPI_EXTERN u16 acpi_gbl_node_type_count[ACPI_TYPE_NS_NODE_MAX + 1]; +ACPI_EXTERN u16 acpi_gbl_obj_type_count_misc; +ACPI_EXTERN u16 acpi_gbl_node_type_count_misc; +ACPI_EXTERN u32 acpi_gbl_num_nodes; +ACPI_EXTERN u32 acpi_gbl_num_objects; -ACPI_EXTERN u32 acpi_gbl_size_of_parse_tree; -ACPI_EXTERN u32 acpi_gbl_size_of_method_trees; -ACPI_EXTERN u32 acpi_gbl_size_of_node_entries; -ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects; +ACPI_EXTERN u32 acpi_gbl_size_of_parse_tree; +ACPI_EXTERN u32 acpi_gbl_size_of_method_trees; +ACPI_EXTERN u32 acpi_gbl_size_of_node_entries; +ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects; -#endif /* ACPI_DEBUGGER */ +#endif /* ACPI_DEBUGGER */ -#endif /* __ACGLOBAL_H__ */ +#endif /* __ACGLOBAL_H__ */ diff --git a/include/acpi/achware.h b/include/acpi/achware.h index cf5de46..3644d72 100644 --- a/include/acpi/achware.h +++ b/include/acpi/achware.h @@ -44,7 +44,6 @@ #ifndef __ACHWARE_H__ #define __ACHWARE_H__ - /* PM Timer ticks per second (HZ) */ #define PM_TIMER_FREQUENCY 3579545 @@ -57,126 +56,78 @@ #define ACPI_SST_SLEEPING 3 #define ACPI_SST_SLEEP_CONTEXT 4 - /* Prototypes */ - /* * hwacpi - high level functions */ -acpi_status -acpi_hw_initialize ( - void); +acpi_status acpi_hw_initialize(void); -acpi_status -acpi_hw_set_mode ( - u32 mode); - -u32 -acpi_hw_get_mode ( - void); +acpi_status acpi_hw_set_mode(u32 mode); +u32 acpi_hw_get_mode(void); /* * hwregs - ACPI Register I/O */ -struct acpi_bit_register_info * -acpi_hw_get_bit_register_info ( - u32 register_id); - -acpi_status -acpi_hw_register_read ( - u8 use_lock, - u32 register_id, - u32 *return_value); +struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id); acpi_status -acpi_hw_register_write ( - u8 use_lock, - u32 register_id, - u32 value); +acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value); -acpi_status -acpi_hw_low_level_read ( - u32 width, - u32 *value, - struct acpi_generic_address *reg); +acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value); acpi_status -acpi_hw_low_level_write ( - u32 width, - u32 value, - struct acpi_generic_address *reg); +acpi_hw_low_level_read(u32 width, + u32 * value, struct acpi_generic_address *reg); acpi_status -acpi_hw_clear_acpi_status ( - u32 flags); +acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address *reg); +acpi_status acpi_hw_clear_acpi_status(u32 flags); /* * hwgpe - GPE support */ acpi_status -acpi_hw_write_gpe_enable_reg ( - struct acpi_gpe_event_info *gpe_event_info); +acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info *gpe_event_info); acpi_status -acpi_hw_disable_gpe_block ( - struct acpi_gpe_xrupt_info *gpe_xrupt_info, - struct acpi_gpe_block_info *gpe_block); +acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, + struct acpi_gpe_block_info *gpe_block); -acpi_status -acpi_hw_clear_gpe ( - struct acpi_gpe_event_info *gpe_event_info); +acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info *gpe_event_info); acpi_status -acpi_hw_clear_gpe_block ( - struct acpi_gpe_xrupt_info *gpe_xrupt_info, - struct acpi_gpe_block_info *gpe_block); +acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, + struct acpi_gpe_block_info *gpe_block); #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_hw_get_gpe_status ( - struct acpi_gpe_event_info *gpe_event_info, - acpi_event_status *event_status); -#endif /* ACPI_FUTURE_USAGE */ +acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info, + acpi_event_status * event_status); +#endif /* ACPI_FUTURE_USAGE */ -acpi_status -acpi_hw_disable_all_gpes ( - void); +acpi_status acpi_hw_disable_all_gpes(void); -acpi_status -acpi_hw_enable_all_runtime_gpes ( - void); +acpi_status acpi_hw_enable_all_runtime_gpes(void); -acpi_status -acpi_hw_enable_all_wakeup_gpes ( - void); +acpi_status acpi_hw_enable_all_wakeup_gpes(void); acpi_status -acpi_hw_enable_runtime_gpe_block ( - struct acpi_gpe_xrupt_info *gpe_xrupt_info, - struct acpi_gpe_block_info *gpe_block); - +acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, + struct acpi_gpe_block_info *gpe_block); #ifdef ACPI_FUTURE_USAGE /* * hwtimer - ACPI Timer prototypes */ -acpi_status -acpi_get_timer_resolution ( - u32 *resolution); +acpi_status acpi_get_timer_resolution(u32 * resolution); -acpi_status -acpi_get_timer ( - u32 *ticks); +acpi_status acpi_get_timer(u32 * ticks); acpi_status -acpi_get_timer_duration ( - u32 start_ticks, - u32 end_ticks, - u32 *time_elapsed); -#endif /* ACPI_FUTURE_USAGE */ - +acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed); +#endif /* ACPI_FUTURE_USAGE */ -#endif /* __ACHWARE_H__ */ +#endif /* __ACHWARE_H__ */ diff --git a/include/acpi/acinterp.h b/include/acpi/acinterp.h index 5c71724..2c9c1a1 100644 --- a/include/acpi/acinterp.h +++ b/include/acpi/acinterp.h @@ -44,29 +44,22 @@ #ifndef __ACINTERP_H__ #define __ACINTERP_H__ - #define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1])) - /* * exconvrt - object conversion */ acpi_status -acpi_ex_convert_to_integer ( - union acpi_operand_object *obj_desc, - union acpi_operand_object **result_desc, - u32 flags); +acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, + union acpi_operand_object **result_desc, u32 flags); acpi_status -acpi_ex_convert_to_buffer ( - union acpi_operand_object *obj_desc, - union acpi_operand_object **result_desc); +acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc, + union acpi_operand_object **result_desc); acpi_status -acpi_ex_convert_to_string ( - union acpi_operand_object *obj_desc, - union acpi_operand_object **result_desc, - u32 type); +acpi_ex_convert_to_string(union acpi_operand_object *obj_desc, + union acpi_operand_object **result_desc, u32 type); /* Types for ->String conversion */ @@ -76,587 +69,412 @@ acpi_ex_convert_to_string ( #define ACPI_EXPLICIT_CONVERT_DECIMAL 0x00000003 acpi_status -acpi_ex_convert_to_target_type ( - acpi_object_type destination_type, - union acpi_operand_object *source_desc, - union acpi_operand_object **result_desc, - struct acpi_walk_state *walk_state); - +acpi_ex_convert_to_target_type(acpi_object_type destination_type, + union acpi_operand_object *source_desc, + union acpi_operand_object **result_desc, + struct acpi_walk_state *walk_state); /* * exfield - ACPI AML (p-code) execution - field manipulation */ acpi_status -acpi_ex_common_buffer_setup ( - union acpi_operand_object *obj_desc, - u32 buffer_length, - u32 *datum_count); +acpi_ex_common_buffer_setup(union acpi_operand_object *obj_desc, + u32 buffer_length, u32 * datum_count); acpi_status -acpi_ex_write_with_update_rule ( - union acpi_operand_object *obj_desc, - acpi_integer mask, - acpi_integer field_value, - u32 field_datum_byte_offset); +acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc, + acpi_integer mask, + acpi_integer field_value, + u32 field_datum_byte_offset); void -acpi_ex_get_buffer_datum( - acpi_integer *datum, - void *buffer, - u32 buffer_length, - u32 byte_granularity, - u32 buffer_offset); +acpi_ex_get_buffer_datum(acpi_integer * datum, + void *buffer, + u32 buffer_length, + u32 byte_granularity, u32 buffer_offset); void -acpi_ex_set_buffer_datum ( - acpi_integer merged_datum, - void *buffer, - u32 buffer_length, - u32 byte_granularity, - u32 buffer_offset); +acpi_ex_set_buffer_datum(acpi_integer merged_datum, + void *buffer, + u32 buffer_length, + u32 byte_granularity, u32 buffer_offset); acpi_status -acpi_ex_read_data_from_field ( - struct acpi_walk_state *walk_state, - union acpi_operand_object *obj_desc, - union acpi_operand_object **ret_buffer_desc); +acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, + union acpi_operand_object *obj_desc, + union acpi_operand_object **ret_buffer_desc); acpi_status -acpi_ex_write_data_to_field ( - union acpi_operand_object *source_desc, - union acpi_operand_object *obj_desc, - union acpi_operand_object **result_desc); - +acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, + union acpi_operand_object *obj_desc, + union acpi_operand_object **result_desc); /* * exfldio - low level field I/O */ acpi_status -acpi_ex_extract_from_field ( - union acpi_operand_object *obj_desc, - void *buffer, - u32 buffer_length); +acpi_ex_extract_from_field(union acpi_operand_object *obj_desc, + void *buffer, u32 buffer_length); acpi_status -acpi_ex_insert_into_field ( - union acpi_operand_object *obj_desc, - void *buffer, - u32 buffer_length); +acpi_ex_insert_into_field(union acpi_operand_object *obj_desc, + void *buffer, u32 buffer_length); acpi_status -acpi_ex_access_region ( - union acpi_operand_object *obj_desc, - u32 field_datum_byte_offset, - acpi_integer *value, - u32 read_write); - +acpi_ex_access_region(union acpi_operand_object *obj_desc, + u32 field_datum_byte_offset, + acpi_integer * value, u32 read_write); /* * exmisc - misc support routines */ acpi_status -acpi_ex_get_object_reference ( - union acpi_operand_object *obj_desc, - union acpi_operand_object **return_desc, - struct acpi_walk_state *walk_state); +acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, + union acpi_operand_object **return_desc, + struct acpi_walk_state *walk_state); acpi_status -acpi_ex_concat_template ( - union acpi_operand_object *obj_desc, - union acpi_operand_object *obj_desc2, - union acpi_operand_object **actual_return_desc, - struct acpi_walk_state *walk_state); +acpi_ex_concat_template(union acpi_operand_object *obj_desc, + union acpi_operand_object *obj_desc2, + union acpi_operand_object **actual_return_desc, + struct acpi_walk_state *walk_state); acpi_status -acpi_ex_do_concatenate ( - union acpi_operand_object *obj_desc, - union acpi_operand_object *obj_desc2, - union acpi_operand_object **actual_return_desc, - struct acpi_walk_state *walk_state); +acpi_ex_do_concatenate(union acpi_operand_object *obj_desc, + union acpi_operand_object *obj_desc2, + union acpi_operand_object **actual_return_desc, + struct acpi_walk_state *walk_state); acpi_status -acpi_ex_do_logical_numeric_op ( - u16 opcode, - acpi_integer integer0, - acpi_integer integer1, - u8 *logical_result); +acpi_ex_do_logical_numeric_op(u16 opcode, + acpi_integer integer0, + acpi_integer integer1, u8 * logical_result); acpi_status -acpi_ex_do_logical_op ( - u16 opcode, - union acpi_operand_object *operand0, - union acpi_operand_object *operand1, - u8 *logical_result); +acpi_ex_do_logical_op(u16 opcode, + union acpi_operand_object *operand0, + union acpi_operand_object *operand1, u8 * logical_result); acpi_integer -acpi_ex_do_math_op ( - u16 opcode, - acpi_integer operand0, - acpi_integer operand1); +acpi_ex_do_math_op(u16 opcode, acpi_integer operand0, acpi_integer operand1); -acpi_status -acpi_ex_create_mutex ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state); -acpi_status -acpi_ex_create_processor ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state); -acpi_status -acpi_ex_create_power_resource ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_create_power_resource(struct acpi_walk_state *walk_state); acpi_status -acpi_ex_create_region ( - u8 *aml_start, - u32 aml_length, - u8 region_space, - struct acpi_walk_state *walk_state); +acpi_ex_create_region(u8 * aml_start, + u32 aml_length, + u8 region_space, struct acpi_walk_state *walk_state); -acpi_status -acpi_ex_create_table_region ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_create_table_region(struct acpi_walk_state *walk_state); -acpi_status -acpi_ex_create_event ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state); -acpi_status -acpi_ex_create_alias ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state); acpi_status -acpi_ex_create_method ( - u8 *aml_start, - u32 aml_length, - struct acpi_walk_state *walk_state); - +acpi_ex_create_method(u8 * aml_start, + u32 aml_length, struct acpi_walk_state *walk_state); /* * exconfig - dynamic table load/unload */ acpi_status -acpi_ex_load_op ( - union acpi_operand_object *obj_desc, - union acpi_operand_object *target, - struct acpi_walk_state *walk_state); +acpi_ex_load_op(union acpi_operand_object *obj_desc, + union acpi_operand_object *target, + struct acpi_walk_state *walk_state); acpi_status -acpi_ex_load_table_op ( - struct acpi_walk_state *walk_state, - union acpi_operand_object **return_desc); - -acpi_status -acpi_ex_unload_table ( - union acpi_operand_object *ddb_handle); +acpi_ex_load_table_op(struct acpi_walk_state *walk_state, + union acpi_operand_object **return_desc); +acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle); /* * exmutex - mutex support */ acpi_status -acpi_ex_acquire_mutex ( - union acpi_operand_object *time_desc, - union acpi_operand_object *obj_desc, - struct acpi_walk_state *walk_state); +acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, + union acpi_operand_object *obj_desc, + struct acpi_walk_state *walk_state); acpi_status -acpi_ex_release_mutex ( - union acpi_operand_object *obj_desc, - struct acpi_walk_state *walk_state); +acpi_ex_release_mutex(union acpi_operand_object *obj_desc, + struct acpi_walk_state *walk_state); -void -acpi_ex_release_all_mutexes ( - struct acpi_thread_state *thread); - -void -acpi_ex_unlink_mutex ( - union acpi_operand_object *obj_desc); +void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread); +void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc); /* * exprep - ACPI AML execution - prep utilities */ acpi_status -acpi_ex_prep_common_field_object ( - union acpi_operand_object *obj_desc, - u8 field_flags, - u8 field_attribute, - u32 field_bit_position, - u32 field_bit_length); - -acpi_status -acpi_ex_prep_field_value ( - struct acpi_create_field_info *info); +acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc, + u8 field_flags, + u8 field_attribute, + u32 field_bit_position, u32 field_bit_length); +acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info); /* * exsystem - Interface to OS services */ acpi_status -acpi_ex_system_do_notify_op ( - union acpi_operand_object *value, - union acpi_operand_object *obj_desc); +acpi_ex_system_do_notify_op(union acpi_operand_object *value, + union acpi_operand_object *obj_desc); -acpi_status -acpi_ex_system_do_suspend( - acpi_integer time); +acpi_status acpi_ex_system_do_suspend(acpi_integer time); -acpi_status -acpi_ex_system_do_stall ( - u32 time); +acpi_status acpi_ex_system_do_stall(u32 time); acpi_status -acpi_ex_system_acquire_mutex( - union acpi_operand_object *time, - union acpi_operand_object *obj_desc); +acpi_ex_system_acquire_mutex(union acpi_operand_object *time, + union acpi_operand_object *obj_desc); -acpi_status -acpi_ex_system_release_mutex( - union acpi_operand_object *obj_desc); +acpi_status acpi_ex_system_release_mutex(union acpi_operand_object *obj_desc); -acpi_status -acpi_ex_system_signal_event( - union acpi_operand_object *obj_desc); +acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc); acpi_status -acpi_ex_system_wait_event( - union acpi_operand_object *time, - union acpi_operand_object *obj_desc); +acpi_ex_system_wait_event(union acpi_operand_object *time, + union acpi_operand_object *obj_desc); -acpi_status -acpi_ex_system_reset_event( - union acpi_operand_object *obj_desc); - -acpi_status -acpi_ex_system_wait_semaphore ( - acpi_handle semaphore, - u16 timeout); +acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc); +acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout); /* * exoparg1 - ACPI AML execution, 1 operand */ -acpi_status -acpi_ex_opcode_0A_0T_1R ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state); -acpi_status -acpi_ex_opcode_1A_0T_0R ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state); -acpi_status -acpi_ex_opcode_1A_0T_1R ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state); -acpi_status -acpi_ex_opcode_1A_1T_1R ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state); -acpi_status -acpi_ex_opcode_1A_1T_0R ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state); /* * exoparg2 - ACPI AML execution, 2 operands */ -acpi_status -acpi_ex_opcode_2A_0T_0R ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state); -acpi_status -acpi_ex_opcode_2A_0T_1R ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state); -acpi_status -acpi_ex_opcode_2A_1T_1R ( - struct acpi_walk_state *walk_state); - -acpi_status -acpi_ex_opcode_2A_2T_1R ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state); +acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state); /* * exoparg3 - ACPI AML execution, 3 operands */ -acpi_status -acpi_ex_opcode_3A_0T_0R ( - struct acpi_walk_state *walk_state); - -acpi_status -acpi_ex_opcode_3A_1T_1R ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state); +acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state); /* * exoparg6 - ACPI AML execution, 6 operands */ -acpi_status -acpi_ex_opcode_6A_0T_1R ( - struct acpi_walk_state *walk_state); - +acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state *walk_state); /* * exresolv - Object resolution and get value functions */ acpi_status -acpi_ex_resolve_to_value ( - union acpi_operand_object **stack_ptr, - struct acpi_walk_state *walk_state); +acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr, + struct acpi_walk_state *walk_state); acpi_status -acpi_ex_resolve_multiple ( - struct acpi_walk_state *walk_state, - union acpi_operand_object *operand, - acpi_object_type *return_type, - union acpi_operand_object **return_desc); - +acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, + union acpi_operand_object *operand, + acpi_object_type * return_type, + union acpi_operand_object **return_desc); /* * exresnte - resolve namespace node */ acpi_status -acpi_ex_resolve_node_to_value ( - struct acpi_namespace_node **stack_ptr, - struct acpi_walk_state *walk_state); - +acpi_ex_resolve_node_to_value(struct acpi_namespace_node **stack_ptr, + struct acpi_walk_state *walk_state); /* * exresop - resolve operand to value */ acpi_status -acpi_ex_resolve_operands ( - u16 opcode, - union acpi_operand_object **stack_ptr, - struct acpi_walk_state *walk_state); - +acpi_ex_resolve_operands(u16 opcode, + union acpi_operand_object **stack_ptr, + struct acpi_walk_state *walk_state); /* * exdump - Interpreter debug output routines */ -void -acpi_ex_dump_operand ( - union acpi_operand_object *obj_desc, - u32 depth); +void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth); void -acpi_ex_dump_operands ( - union acpi_operand_object **operands, - acpi_interpreter_mode interpreter_mode, - char *ident, - u32 num_levels, - char *note, - char *module_name, - u32 line_number); +acpi_ex_dump_operands(union acpi_operand_object **operands, + acpi_interpreter_mode interpreter_mode, + char *ident, + u32 num_levels, + char *note, char *module_name, u32 line_number); #ifdef ACPI_FUTURE_USAGE void -acpi_ex_dump_object_descriptor ( - union acpi_operand_object *object, - u32 flags); - -void -acpi_ex_dump_node ( - struct acpi_namespace_node *node, - u32 flags); -#endif /* ACPI_FUTURE_USAGE */ +acpi_ex_dump_object_descriptor(union acpi_operand_object *object, u32 flags); +void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags); +#endif /* ACPI_FUTURE_USAGE */ /* * exnames - AML namestring support */ acpi_status -acpi_ex_get_name_string ( - acpi_object_type data_type, - u8 *in_aml_address, - char **out_name_string, - u32 *out_name_length); - +acpi_ex_get_name_string(acpi_object_type data_type, + u8 * in_aml_address, + char **out_name_string, u32 * out_name_length); /* * exstore - Object store support */ acpi_status -acpi_ex_store ( - union acpi_operand_object *val_desc, - union acpi_operand_object *dest_desc, - struct acpi_walk_state *walk_state); +acpi_ex_store(union acpi_operand_object *val_desc, + union acpi_operand_object *dest_desc, + struct acpi_walk_state *walk_state); acpi_status -acpi_ex_store_object_to_node ( - union acpi_operand_object *source_desc, - struct acpi_namespace_node *node, - struct acpi_walk_state *walk_state, - u8 implicit_conversion); +acpi_ex_store_object_to_node(union acpi_operand_object *source_desc, + struct acpi_namespace_node *node, + struct acpi_walk_state *walk_state, + u8 implicit_conversion); #define ACPI_IMPLICIT_CONVERSION TRUE #define ACPI_NO_IMPLICIT_CONVERSION FALSE - /* * exstoren - resolve/store object */ acpi_status -acpi_ex_resolve_object ( - union acpi_operand_object **source_desc_ptr, - acpi_object_type target_type, - struct acpi_walk_state *walk_state); +acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, + acpi_object_type target_type, + struct acpi_walk_state *walk_state); acpi_status -acpi_ex_store_object_to_object ( - union acpi_operand_object *source_desc, - union acpi_operand_object *dest_desc, - union acpi_operand_object **new_desc, - struct acpi_walk_state *walk_state); - +acpi_ex_store_object_to_object(union acpi_operand_object *source_desc, + union acpi_operand_object *dest_desc, + union acpi_operand_object **new_desc, + struct acpi_walk_state *walk_state); /* * exstorob - store object - buffer/string */ acpi_status -acpi_ex_store_buffer_to_buffer ( - union acpi_operand_object *source_desc, - union acpi_operand_object *target_desc); +acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc, + union acpi_operand_object *target_desc); acpi_status -acpi_ex_store_string_to_string ( - union acpi_operand_object *source_desc, - union acpi_operand_object *target_desc); - +acpi_ex_store_string_to_string(union acpi_operand_object *source_desc, + union acpi_operand_object *target_desc); /* * excopy - object copy */ acpi_status -acpi_ex_copy_integer_to_index_field ( - union acpi_operand_object *source_desc, - union acpi_operand_object *target_desc); +acpi_ex_copy_integer_to_index_field(union acpi_operand_object *source_desc, + union acpi_operand_object *target_desc); acpi_status -acpi_ex_copy_integer_to_bank_field ( - union acpi_operand_object *source_desc, - union acpi_operand_object *target_desc); +acpi_ex_copy_integer_to_bank_field(union acpi_operand_object *source_desc, + union acpi_operand_object *target_desc); acpi_status -acpi_ex_copy_data_to_named_field ( - union acpi_operand_object *source_desc, - struct acpi_namespace_node *node); +acpi_ex_copy_data_to_named_field(union acpi_operand_object *source_desc, + struct acpi_namespace_node *node); acpi_status -acpi_ex_copy_integer_to_buffer_field ( - union acpi_operand_object *source_desc, - union acpi_operand_object *target_desc); - +acpi_ex_copy_integer_to_buffer_field(union acpi_operand_object *source_desc, + union acpi_operand_object *target_desc); /* * exutils - interpreter/scanner utilities */ -acpi_status -acpi_ex_enter_interpreter ( - void); +acpi_status acpi_ex_enter_interpreter(void); -void -acpi_ex_exit_interpreter ( - void); +void acpi_ex_exit_interpreter(void); -void -acpi_ex_truncate_for32bit_table ( - union acpi_operand_object *obj_desc); +void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc); -u8 -acpi_ex_acquire_global_lock ( - u32 rule); +u8 acpi_ex_acquire_global_lock(u32 rule); -void -acpi_ex_release_global_lock ( - u8 locked); +void acpi_ex_release_global_lock(u8 locked); -void -acpi_ex_eisa_id_to_string ( - u32 numeric_id, - char *out_string); - -void -acpi_ex_unsigned_integer_to_string ( - acpi_integer value, - char *out_string); +void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string); +void acpi_ex_unsigned_integer_to_string(acpi_integer value, char *out_string); /* * exregion - default op_region handlers */ acpi_status -acpi_ex_system_memory_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context); - -acpi_status -acpi_ex_system_io_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context); - -acpi_status -acpi_ex_pci_config_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context); - -acpi_status -acpi_ex_cmos_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context); - -acpi_status -acpi_ex_pci_bar_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context); - -acpi_status -acpi_ex_embedded_controller_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context); - -acpi_status -acpi_ex_sm_bus_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context); - - -acpi_status -acpi_ex_data_table_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context); - -#endif /* __INTERP_H__ */ +acpi_ex_system_memory_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, + void *region_context); + +acpi_status +acpi_ex_system_io_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, void *region_context); + +acpi_status +acpi_ex_pci_config_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, void *region_context); + +acpi_status +acpi_ex_cmos_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, void *region_context); + +acpi_status +acpi_ex_pci_bar_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, void *region_context); + +acpi_status +acpi_ex_embedded_controller_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, + void *region_context); + +acpi_status +acpi_ex_sm_bus_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, void *region_context); + +acpi_status +acpi_ex_data_table_space_handler(u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, void *region_context); + +#endif /* __INTERP_H__ */ diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h index 4d26356..9fba0fd 100644 --- a/include/acpi/aclocal.h +++ b/include/acpi/aclocal.h @@ -44,24 +44,20 @@ #ifndef __ACLOCAL_H__ #define __ACLOCAL_H__ +#define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */ -#define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */ - -typedef void * acpi_mutex; -typedef u32 acpi_mutex_handle; - +typedef void *acpi_mutex; +typedef u32 acpi_mutex_handle; /* Total number of aml opcodes defined */ #define AML_NUM_OPCODES 0x7F - /* Forward declarations */ -struct acpi_walk_state ; +struct acpi_walk_state; struct acpi_obj_mutex; -union acpi_parse_object ; - +union acpi_parse_object; /***************************************************************************** * @@ -69,7 +65,6 @@ union acpi_parse_object ; * ****************************************************************************/ - /* * Predefined handles for the mutex objects used within the subsystem * All mutex objects are automatically created by acpi_ut_mutex_initialize. @@ -96,14 +91,12 @@ union acpi_parse_object ; #define MAX_MUTEX 12 #define NUM_MUTEX MAX_MUTEX+1 - #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) #ifdef DEFINE_ACPI_GLOBALS /* Names for the mutexes used in the subsystem */ -static char *acpi_gbl_mutex_names[] = -{ +static char *acpi_gbl_mutex_names[] = { "ACPI_MTX_Execute", "ACPI_MTX_Interpreter", "ACPI_MTX_Parser", @@ -122,10 +115,9 @@ static char *acpi_gbl_mutex_names[] = #endif #endif - /* Owner IDs are used to track namespace nodes for selective deletion */ -typedef u8 acpi_owner_id; +typedef u8 acpi_owner_id; #define ACPI_OWNER_ID_MAX 0xFF /* This Thread ID means that the mutex is not in use (unlocked) */ @@ -134,20 +126,17 @@ typedef u8 acpi_owner_id; /* Table for the global mutexes */ -struct acpi_mutex_info -{ - acpi_mutex mutex; - u32 use_count; - u32 thread_id; +struct acpi_mutex_info { + acpi_mutex mutex; + u32 use_count; + u32 thread_id; }; - /* Lock flag parameter for various interfaces */ #define ACPI_MTX_DO_NOT_LOCK 0 #define ACPI_MTX_LOCK 1 - /* Field access granularities */ #define ACPI_FIELD_BYTE_GRANULARITY 1 @@ -155,7 +144,6 @@ struct acpi_mutex_info #define ACPI_FIELD_DWORD_GRANULARITY 4 #define ACPI_FIELD_QWORD_GRANULARITY 8 - /***************************************************************************** * * Namespace typedefs and structs @@ -164,15 +152,12 @@ struct acpi_mutex_info /* Operational modes of the AML interpreter/scanner */ -typedef enum -{ - ACPI_IMODE_LOAD_PASS1 = 0x01, - ACPI_IMODE_LOAD_PASS2 = 0x02, - ACPI_IMODE_EXECUTE = 0x0E - +typedef enum { + ACPI_IMODE_LOAD_PASS1 = 0x01, + ACPI_IMODE_LOAD_PASS2 = 0x02, + ACPI_IMODE_EXECUTE = 0x0E } acpi_interpreter_mode; - /* * The Node describes a named object that appears in the AML * An acpi_node is used to store Nodes. @@ -180,41 +165,37 @@ typedef enum * data_type is used to differentiate between internal descriptors, and MUST * be the first byte in this structure. */ -union acpi_name_union -{ - u32 integer; - char ascii[4]; -}; - -struct acpi_namespace_node -{ - u8 descriptor; /* Used to differentiate object descriptor types */ - u8 type; /* Type associated with this name */ - u16 reference_count; /* Current count of references and children */ - union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */ - union acpi_operand_object *object; /* Pointer to attached ACPI object (optional) */ - struct acpi_namespace_node *child; /* First child */ - struct acpi_namespace_node *peer; /* Next peer*/ - u8 owner_id; /* Who created this node */ - u8 flags; +union acpi_name_union { + u32 integer; + char ascii[4]; +}; + +struct acpi_namespace_node { + u8 descriptor; /* Used to differentiate object descriptor types */ + u8 type; /* Type associated with this name */ + u16 reference_count; /* Current count of references and children */ + union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */ + union acpi_operand_object *object; /* Pointer to attached ACPI object (optional) */ + struct acpi_namespace_node *child; /* First child */ + struct acpi_namespace_node *peer; /* Next peer */ + u8 owner_id; /* Who created this node */ + u8 flags; /* Fields used by the ASL compiler only */ #ifdef ACPI_ASL_COMPILER - u32 value; - union acpi_parse_object *op; + u32 value; + union acpi_parse_object *op; #endif }; - #define ACPI_ENTRY_NOT_FOUND NULL - /* Node flags */ #define ANOBJ_RESERVED 0x01 #define ANOBJ_END_OF_PEER_LIST 0x02 -#define ANOBJ_DATA_WIDTH_32 0x04 /* Parent table is 64-bits */ +#define ANOBJ_DATA_WIDTH_32 0x04 /* Parent table is 64-bits */ #define ANOBJ_METHOD_ARG 0x08 #define ANOBJ_METHOD_LOCAL 0x10 #define ANOBJ_METHOD_NO_RETVAL 0x20 @@ -224,91 +205,77 @@ struct acpi_namespace_node /* * ACPI Table Descriptor. One per ACPI table */ -struct acpi_table_desc -{ - struct acpi_table_desc *prev; - struct acpi_table_desc *next; - struct acpi_table_desc *installed_desc; - struct acpi_table_header *pointer; - u8 *aml_start; - u64 physical_address; - u32 aml_length; - acpi_size length; - acpi_owner_id owner_id; - u8 type; - u8 allocation; - u8 loaded_into_namespace; +struct acpi_table_desc { + struct acpi_table_desc *prev; + struct acpi_table_desc *next; + struct acpi_table_desc *installed_desc; + struct acpi_table_header *pointer; + u8 *aml_start; + u64 physical_address; + u32 aml_length; + acpi_size length; + acpi_owner_id owner_id; + u8 type; + u8 allocation; + u8 loaded_into_namespace; }; -struct acpi_table_list -{ - struct acpi_table_desc *next; - u32 count; +struct acpi_table_list { + struct acpi_table_desc *next; + u32 count; }; - -struct acpi_find_context -{ - char *search_for; - acpi_handle *list; - u32 *count; +struct acpi_find_context { + char *search_for; + acpi_handle *list; + u32 *count; }; - -struct acpi_ns_search_data -{ - struct acpi_namespace_node *node; +struct acpi_ns_search_data { + struct acpi_namespace_node *node; }; - /* * Predefined Namespace items */ -struct acpi_predefined_names -{ - char *name; - u8 type; - char *val; +struct acpi_predefined_names { + char *name; + u8 type; + char *val; }; - /* Object types used during package copies */ - #define ACPI_COPY_TYPE_SIMPLE 0 #define ACPI_COPY_TYPE_PACKAGE 1 /* Info structure used to convert external<->internal namestrings */ -struct acpi_namestring_info -{ - char *external_name; - char *next_external_char; - char *internal_name; - u32 length; - u32 num_segments; - u32 num_carats; - u8 fully_qualified; +struct acpi_namestring_info { + char *external_name; + char *next_external_char; + char *internal_name; + u32 length; + u32 num_segments; + u32 num_carats; + u8 fully_qualified; }; - /* Field creation info */ -struct acpi_create_field_info -{ - struct acpi_namespace_node *region_node; - struct acpi_namespace_node *field_node; - struct acpi_namespace_node *register_node; - struct acpi_namespace_node *data_register_node; - u32 bank_value; - u32 field_bit_position; - u32 field_bit_length; - u8 field_flags; - u8 attribute; - u8 field_type; +struct acpi_create_field_info { + struct acpi_namespace_node *region_node; + struct acpi_namespace_node *field_node; + struct acpi_namespace_node *register_node; + struct acpi_namespace_node *data_register_node; + u32 bank_value; + u32 field_bit_position; + u32 field_bit_length; + u8 field_flags; + u8 attribute; + u8 field_type; }; - /***************************************************************************** * * Event typedefs and structs @@ -317,108 +284,95 @@ struct acpi_create_field_info /* Dispatch info for each GPE -- either a method or handler, cannot be both */ -struct acpi_handler_info -{ - acpi_event_handler address; /* Address of handler, if any */ - void *context; /* Context to be passed to handler */ - struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */ +struct acpi_handler_info { + acpi_event_handler address; /* Address of handler, if any */ + void *context; /* Context to be passed to handler */ + struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */ }; -union acpi_gpe_dispatch_info -{ - struct acpi_namespace_node *method_node; /* Method node for this GPE level */ - struct acpi_handler_info *handler; +union acpi_gpe_dispatch_info { + struct acpi_namespace_node *method_node; /* Method node for this GPE level */ + struct acpi_handler_info *handler; }; /* * Information about a GPE, one per each GPE in an array. * NOTE: Important to keep this struct as small as possible. */ -struct acpi_gpe_event_info -{ - union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */ - struct acpi_gpe_register_info *register_info; /* Backpointer to register info */ - u8 flags; /* Misc info about this GPE */ - u8 register_bit; /* This GPE bit within the register */ +struct acpi_gpe_event_info { + union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */ + struct acpi_gpe_register_info *register_info; /* Backpointer to register info */ + u8 flags; /* Misc info about this GPE */ + u8 register_bit; /* This GPE bit within the register */ }; /* Information about a GPE register pair, one per each status/enable pair in an array */ -struct acpi_gpe_register_info -{ - struct acpi_generic_address status_address; /* Address of status reg */ - struct acpi_generic_address enable_address; /* Address of enable reg */ - u8 enable_for_wake; /* GPEs to keep enabled when sleeping */ - u8 enable_for_run; /* GPEs to keep enabled when running */ - u8 base_gpe_number; /* Base GPE number for this register */ +struct acpi_gpe_register_info { + struct acpi_generic_address status_address; /* Address of status reg */ + struct acpi_generic_address enable_address; /* Address of enable reg */ + u8 enable_for_wake; /* GPEs to keep enabled when sleeping */ + u8 enable_for_run; /* GPEs to keep enabled when running */ + u8 base_gpe_number; /* Base GPE number for this register */ }; /* * Information about a GPE register block, one per each installed block -- * GPE0, GPE1, and one per each installed GPE Block Device. */ -struct acpi_gpe_block_info -{ - struct acpi_namespace_node *node; - struct acpi_gpe_block_info *previous; - struct acpi_gpe_block_info *next; - struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */ - struct acpi_gpe_register_info *register_info; /* One per GPE register pair */ - struct acpi_gpe_event_info *event_info; /* One for each GPE */ - struct acpi_generic_address block_address; /* Base address of the block */ - u32 register_count; /* Number of register pairs in block */ - u8 block_base_number;/* Base GPE number for this block */ +struct acpi_gpe_block_info { + struct acpi_namespace_node *node; + struct acpi_gpe_block_info *previous; + struct acpi_gpe_block_info *next; + struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */ + struct acpi_gpe_register_info *register_info; /* One per GPE register pair */ + struct acpi_gpe_event_info *event_info; /* One for each GPE */ + struct acpi_generic_address block_address; /* Base address of the block */ + u32 register_count; /* Number of register pairs in block */ + u8 block_base_number; /* Base GPE number for this block */ }; /* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */ -struct acpi_gpe_xrupt_info -{ - struct acpi_gpe_xrupt_info *previous; - struct acpi_gpe_xrupt_info *next; - struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */ - u32 interrupt_number; /* System interrupt number */ +struct acpi_gpe_xrupt_info { + struct acpi_gpe_xrupt_info *previous; + struct acpi_gpe_xrupt_info *next; + struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */ + u32 interrupt_number; /* System interrupt number */ }; - -struct acpi_gpe_walk_info -{ - struct acpi_namespace_node *gpe_device; - struct acpi_gpe_block_info *gpe_block; +struct acpi_gpe_walk_info { + struct acpi_namespace_node *gpe_device; + struct acpi_gpe_block_info *gpe_block; }; - -typedef acpi_status (*ACPI_GPE_CALLBACK) ( - struct acpi_gpe_xrupt_info *gpe_xrupt_info, - struct acpi_gpe_block_info *gpe_block); - +typedef acpi_status(*ACPI_GPE_CALLBACK) (struct acpi_gpe_xrupt_info * + gpe_xrupt_info, + struct acpi_gpe_block_info * + gpe_block); /* Information about each particular fixed event */ -struct acpi_fixed_event_handler -{ - acpi_event_handler handler; /* Address of handler. */ - void *context; /* Context to be passed to handler */ +struct acpi_fixed_event_handler { + acpi_event_handler handler; /* Address of handler. */ + void *context; /* Context to be passed to handler */ }; -struct acpi_fixed_event_info -{ - u8 status_register_id; - u8 enable_register_id; - u16 status_bit_mask; - u16 enable_bit_mask; +struct acpi_fixed_event_info { + u8 status_register_id; + u8 enable_register_id; + u16 status_bit_mask; + u16 enable_bit_mask; }; /* Information used during field processing */ -struct acpi_field_info -{ - u8 skip_field; - u8 field_flag; - u32 pkg_length; +struct acpi_field_info { + u8 skip_field; + u8 field_flag; + u32 pkg_length; }; - /***************************************************************************** * * Generic "state" object for stacks @@ -431,7 +385,6 @@ struct acpi_field_info #define ACPI_CONTROL_PREDICATE_FALSE 0xC3 #define ACPI_CONTROL_PREDICATE_TRUE 0xC4 - #define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ u8 data_type; /* To differentiate various internal objs */\ u8 flags; \ @@ -440,147 +393,112 @@ struct acpi_field_info u16 reserved; \ void *next; \ -struct acpi_common_state -{ - ACPI_STATE_COMMON -}; - +struct acpi_common_state { +ACPI_STATE_COMMON}; /* * Update state - used to traverse complex objects such as packages */ -struct acpi_update_state -{ - ACPI_STATE_COMMON - union acpi_operand_object *object; +struct acpi_update_state { + ACPI_STATE_COMMON union acpi_operand_object *object; }; - /* * Pkg state - used to traverse nested package structures */ -struct acpi_pkg_state -{ - ACPI_STATE_COMMON - union acpi_operand_object *source_object; - union acpi_operand_object *dest_object; - struct acpi_walk_state *walk_state; - void *this_target_obj; - u32 num_packages; - u16 index; +struct acpi_pkg_state { + ACPI_STATE_COMMON union acpi_operand_object *source_object; + union acpi_operand_object *dest_object; + struct acpi_walk_state *walk_state; + void *this_target_obj; + u32 num_packages; + u16 index; }; - /* * Control state - one per if/else and while constructs. * Allows nesting of these constructs */ -struct acpi_control_state -{ - ACPI_STATE_COMMON - union acpi_parse_object *predicate_op; - u8 *aml_predicate_start; /* Start of if/while predicate */ - u8 *package_end; /* End of if/while block */ - u16 opcode; +struct acpi_control_state { + ACPI_STATE_COMMON union acpi_parse_object *predicate_op; + u8 *aml_predicate_start; /* Start of if/while predicate */ + u8 *package_end; /* End of if/while block */ + u16 opcode; }; - /* * Scope state - current scope during namespace lookups */ -struct acpi_scope_state -{ - ACPI_STATE_COMMON - struct acpi_namespace_node *node; +struct acpi_scope_state { + ACPI_STATE_COMMON struct acpi_namespace_node *node; }; - -struct acpi_pscope_state -{ - ACPI_STATE_COMMON - union acpi_parse_object *op; /* Current op being parsed */ - u8 *arg_end; /* Current argument end */ - u8 *pkg_end; /* Current package end */ - u32 arg_list; /* Next argument to parse */ - u32 arg_count; /* Number of fixed arguments */ +struct acpi_pscope_state { + ACPI_STATE_COMMON union acpi_parse_object *op; /* Current op being parsed */ + u8 *arg_end; /* Current argument end */ + u8 *pkg_end; /* Current package end */ + u32 arg_list; /* Next argument to parse */ + u32 arg_count; /* Number of fixed arguments */ }; - /* * Thread state - one per thread across multiple walk states. Multiple walk * states are created when there are nested control methods executing. */ -struct acpi_thread_state -{ - ACPI_STATE_COMMON - struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */ - union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */ - u32 thread_id; /* Running thread ID */ - u8 current_sync_level; /* Mutex Sync (nested acquire) level */ +struct acpi_thread_state { + ACPI_STATE_COMMON struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */ + union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */ + u32 thread_id; /* Running thread ID */ + u8 current_sync_level; /* Mutex Sync (nested acquire) level */ }; - /* * Result values - used to accumulate the results of nested * AML arguments */ -struct acpi_result_values -{ +struct acpi_result_values { ACPI_STATE_COMMON - union acpi_operand_object *obj_desc [ACPI_OBJ_NUM_OPERANDS]; - u8 num_results; - u8 last_insert; + union acpi_operand_object *obj_desc[ACPI_OBJ_NUM_OPERANDS]; + u8 num_results; + u8 last_insert; }; - typedef -acpi_status (*acpi_parse_downwards) ( - struct acpi_walk_state *walk_state, - union acpi_parse_object **out_op); - -typedef -acpi_status (*acpi_parse_upwards) ( - struct acpi_walk_state *walk_state); +acpi_status(*acpi_parse_downwards) (struct acpi_walk_state * walk_state, + union acpi_parse_object ** out_op); +typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state); /* * Notify info - used to pass info to the deferred notify * handler/dispatcher. */ -struct acpi_notify_info -{ - ACPI_STATE_COMMON - struct acpi_namespace_node *node; - union acpi_operand_object *handler_obj; +struct acpi_notify_info { + ACPI_STATE_COMMON struct acpi_namespace_node *node; + union acpi_operand_object *handler_obj; }; - /* Generic state is union of structs above */ -union acpi_generic_state -{ - struct acpi_common_state common; - struct acpi_control_state control; - struct acpi_update_state update; - struct acpi_scope_state scope; - struct acpi_pscope_state parse_scope; - struct acpi_pkg_state pkg; - struct acpi_thread_state thread; - struct acpi_result_values results; - struct acpi_notify_info notify; +union acpi_generic_state { + struct acpi_common_state common; + struct acpi_control_state control; + struct acpi_update_state update; + struct acpi_scope_state scope; + struct acpi_pscope_state parse_scope; + struct acpi_pkg_state pkg; + struct acpi_thread_state thread; + struct acpi_result_values results; + struct acpi_notify_info notify; }; - /***************************************************************************** * * Interpreter typedefs and structs * ****************************************************************************/ -typedef -acpi_status (*ACPI_EXECUTE_OP) ( - struct acpi_walk_state *walk_state); - +typedef acpi_status(*ACPI_EXECUTE_OP) (struct acpi_walk_state * walk_state); /***************************************************************************** * @@ -591,28 +509,26 @@ acpi_status (*ACPI_EXECUTE_OP) ( /* * AML opcode, name, and argument layout */ -struct acpi_opcode_info -{ +struct acpi_opcode_info { #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT) - char *name; /* Opcode name (disassembler/debug only) */ + char *name; /* Opcode name (disassembler/debug only) */ #endif - u32 parse_args; /* Grammar/Parse time arguments */ - u32 runtime_args; /* Interpret time arguments */ - u32 flags; /* Misc flags */ - u8 object_type; /* Corresponding internal object type */ - u8 class; /* Opcode class */ - u8 type; /* Opcode type */ + u32 parse_args; /* Grammar/Parse time arguments */ + u32 runtime_args; /* Interpret time arguments */ + u32 flags; /* Misc flags */ + u8 object_type; /* Corresponding internal object type */ + u8 class; /* Opcode class */ + u8 type; /* Opcode type */ }; -union acpi_parse_value -{ - acpi_integer integer; /* Integer constant (Up to 64 bits) */ - struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */ - u32 size; /* bytelist or field size */ - char *string; /* NULL terminated string */ - u8 *buffer; /* buffer or string */ - char *name; /* NULL terminated string */ - union acpi_parse_object *arg; /* arguments and contained ops */ +union acpi_parse_value { + acpi_integer integer; /* Integer constant (Up to 64 bits) */ + struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */ + u32 size; /* bytelist or field size */ + char *string; /* NULL terminated string */ + u8 *buffer; /* buffer or string */ + char *name; /* NULL terminated string */ + union acpi_parse_object *arg; /* arguments and contained ops */ }; #define ACPI_PARSE_COMMON \ @@ -641,84 +557,72 @@ union acpi_parse_value /* * generic operation (for example: If, While, Store) */ -struct acpi_parse_obj_common -{ - ACPI_PARSE_COMMON -}; - +struct acpi_parse_obj_common { +ACPI_PARSE_COMMON}; /* * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and op_regions), * and bytelists. */ -struct acpi_parse_obj_named -{ - ACPI_PARSE_COMMON - u8 *path; - u8 *data; /* AML body or bytelist data */ - u32 length; /* AML length */ - u32 name; /* 4-byte name or zero if no name */ +struct acpi_parse_obj_named { + ACPI_PARSE_COMMON u8 * path; + u8 *data; /* AML body or bytelist data */ + u32 length; /* AML length */ + u32 name; /* 4-byte name or zero if no name */ }; - /* The parse node is the fundamental element of the parse tree */ -struct acpi_parse_obj_asl -{ - ACPI_PARSE_COMMON - union acpi_parse_object *child; - union acpi_parse_object *parent_method; - char *filename; - char *external_name; - char *namepath; - char name_seg[4]; - u32 extra_value; - u32 column; - u32 line_number; - u32 logical_line_number; - u32 logical_byte_offset; - u32 end_line; - u32 end_logical_line; - u32 acpi_btype; - u32 aml_length; - u32 aml_subtree_length; - u32 final_aml_length; - u32 final_aml_offset; - u32 compile_flags; - u16 parse_opcode; - u8 aml_opcode_length; - u8 aml_pkg_len_bytes; - u8 extra; - char parse_op_name[12]; -}; - -union acpi_parse_object -{ - struct acpi_parse_obj_common common; - struct acpi_parse_obj_named named; - struct acpi_parse_obj_asl asl; +struct acpi_parse_obj_asl { + ACPI_PARSE_COMMON union acpi_parse_object *child; + union acpi_parse_object *parent_method; + char *filename; + char *external_name; + char *namepath; + char name_seg[4]; + u32 extra_value; + u32 column; + u32 line_number; + u32 logical_line_number; + u32 logical_byte_offset; + u32 end_line; + u32 end_logical_line; + u32 acpi_btype; + u32 aml_length; + u32 aml_subtree_length; + u32 final_aml_length; + u32 final_aml_offset; + u32 compile_flags; + u16 parse_opcode; + u8 aml_opcode_length; + u8 aml_pkg_len_bytes; + u8 extra; + char parse_op_name[12]; +}; + +union acpi_parse_object { + struct acpi_parse_obj_common common; + struct acpi_parse_obj_named named; + struct acpi_parse_obj_asl asl; }; - /* * Parse state - one state per parser invocation and each control * method. */ -struct acpi_parse_state -{ - u32 aml_size; - u8 *aml_start; /* First AML byte */ - u8 *aml; /* Next AML byte */ - u8 *aml_end; /* (last + 1) AML byte */ - u8 *pkg_start; /* Current package begin */ - u8 *pkg_end; /* Current package end */ - union acpi_parse_object *start_op; /* Root of parse tree */ - struct acpi_namespace_node *start_node; - union acpi_generic_state *scope; /* Current scope */ - union acpi_parse_object *start_scope; +struct acpi_parse_state { + u32 aml_size; + u8 *aml_start; /* First AML byte */ + u8 *aml; /* Next AML byte */ + u8 *aml_end; /* (last + 1) AML byte */ + u8 *pkg_start; /* Current package begin */ + u8 *pkg_end; /* Current package end */ + union acpi_parse_object *start_op; /* Root of parse tree */ + struct acpi_namespace_node *start_node; + union acpi_generic_state *scope; /* Current scope */ + union acpi_parse_object *start_scope; }; - /* Parse object flags */ #define ACPI_PARSEOP_GENERIC 0x01 @@ -734,7 +638,6 @@ struct acpi_parse_state #define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 #define ACPI_PARSEOP_SPECIAL 0x10 - /***************************************************************************** * * Hardware (ACPI registers) and PNP @@ -744,14 +647,12 @@ struct acpi_parse_state #define PCI_ROOT_HID_STRING "PNP0A03" #define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" -struct acpi_bit_register_info -{ - u8 parent_register; - u8 bit_position; - u16 access_bit_mask; +struct acpi_bit_register_info { + u8 parent_register; + u8 bit_position; + u16 access_bit_mask; }; - /* * Register IDs * These are the full ACPI registers @@ -766,7 +667,6 @@ struct acpi_bit_register_info #define ACPI_REGISTER_PROCESSOR_BLOCK 0x08 #define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09 - /* Masks used to access the bit_registers */ #define ACPI_BITMASK_TIMER_STATUS 0x0001 @@ -775,7 +675,7 @@ struct acpi_bit_register_info #define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100 #define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200 #define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400 -#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ +#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ #define ACPI_BITMASK_WAKE_STATUS 0x8000 #define ACPI_BITMASK_ALL_FIXED_STATUS (ACPI_BITMASK_TIMER_STATUS | \ @@ -791,7 +691,7 @@ struct acpi_bit_register_info #define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100 #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200 #define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400 -#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */ +#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */ #define ACPI_BITMASK_SCI_ENABLE 0x0001 #define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 @@ -801,7 +701,6 @@ struct acpi_bit_register_info #define ACPI_BITMASK_ARB_DISABLE 0x0001 - /* Raw bit position of each bit_register */ #define ACPI_BITPOSITION_TIMER_STATUS 0x00 @@ -810,7 +709,7 @@ struct acpi_bit_register_info #define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08 #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09 #define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A -#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */ +#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */ #define ACPI_BITPOSITION_WAKE_STATUS 0x0F #define ACPI_BITPOSITION_TIMER_ENABLE 0x00 @@ -818,7 +717,7 @@ struct acpi_bit_register_info #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08 #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09 #define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A -#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */ +#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */ #define ACPI_BITPOSITION_SCI_ENABLE 0x00 #define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 @@ -828,7 +727,6 @@ struct acpi_bit_register_info #define ACPI_BITPOSITION_ARB_DISABLE 0x00 - /***************************************************************************** * * Resource descriptors @@ -847,8 +745,7 @@ struct acpi_bit_register_info #define ACPI_RDESC_TYPE_SMALL 0x00 #define ACPI_RDESC_TYPE_MASK 0x80 -#define ACPI_RDESC_SMALL_MASK 0x78 /* Only bits 6:3 contain the type */ - +#define ACPI_RDESC_SMALL_MASK 0x78 /* Only bits 6:3 contain the type */ /* * Small resource descriptor types @@ -877,7 +774,6 @@ struct acpi_bit_register_info #define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE 0x8A #define ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE 0x8B - /***************************************************************************** * * Miscellaneous @@ -886,35 +782,30 @@ struct acpi_bit_register_info #define ACPI_ASCII_ZERO 0x30 - /***************************************************************************** * * Debugger * ****************************************************************************/ -struct acpi_db_method_info -{ - acpi_handle thread_gate; - char *name; - char **args; - u32 flags; - u32 num_loops; - char pathname[128]; +struct acpi_db_method_info { + acpi_handle thread_gate; + char *name; + char **args; + u32 flags; + u32 num_loops; + char pathname[128]; }; -struct acpi_integrity_info -{ - u32 nodes; - u32 objects; +struct acpi_integrity_info { + u32 nodes; + u32 objects; }; - #define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 #define ACPI_DB_CONSOLE_OUTPUT 0x02 #define ACPI_DB_DUPLICATE_OUTPUT 0x03 - /***************************************************************************** * * Debug @@ -936,43 +827,36 @@ struct acpi_integrity_info char module[ACPI_MAX_MODULE_NAME]; \ u8 alloc_type; -struct acpi_debug_mem_header -{ - ACPI_COMMON_DEBUG_MEM_HEADER -}; +struct acpi_debug_mem_header { +ACPI_COMMON_DEBUG_MEM_HEADER}; -struct acpi_debug_mem_block -{ - ACPI_COMMON_DEBUG_MEM_HEADER - u64 user_space; +struct acpi_debug_mem_block { + ACPI_COMMON_DEBUG_MEM_HEADER u64 user_space; }; - #define ACPI_MEM_LIST_GLOBAL 0 #define ACPI_MEM_LIST_NSNODE 1 #define ACPI_MEM_LIST_MAX 1 #define ACPI_NUM_MEM_LISTS 2 - -struct acpi_memory_list -{ - char *list_name; - void *list_head; - u16 object_size; - u16 max_depth; - u16 current_depth; - u16 link_offset; +struct acpi_memory_list { + char *list_name; + void *list_head; + u16 object_size; + u16 max_depth; + u16 current_depth; + u16 link_offset; #ifdef ACPI_DBG_TRACK_ALLOCATIONS /* Statistics for debug memory tracking only */ - u32 total_allocated; - u32 total_freed; - u32 current_total_size; - u32 requests; - u32 hits; + u32 total_allocated; + u32 total_freed; + u32 current_total_size; + u32 requests; + u32 hits; #endif }; -#endif /* __ACLOCAL_H__ */ +#endif /* __ACLOCAL_H__ */ diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index fcdef0a..702cc4e 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h @@ -44,7 +44,6 @@ #ifndef __ACMACROS_H__ #define __ACMACROS_H__ - /* * Data manipulation macros */ @@ -57,7 +56,6 @@ #define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) #define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) - #if ACPI_MACHINE_WIDTH == 16 /* @@ -168,7 +166,7 @@ /* 32-bit source, 16/32/64 destination */ -#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ +#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ #define ACPI_MOVE_32_TO_32(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\ (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\ @@ -183,9 +181,9 @@ /* 64-bit source, 16/32/64 destination */ -#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ +#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ -#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ +#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ #define ACPI_MOVE_64_TO_64(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[7];\ (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[6];\ @@ -219,14 +217,14 @@ /* 32-bit source, 16/32/64 destination */ -#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ +#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ #define ACPI_MOVE_32_TO_32(d,s) *(u32 *)(void *)(d) = *(u32 *)(void *)(s) #define ACPI_MOVE_32_TO_64(d,s) ACPI_MOVE_32_TO_32(d,s) /* 64-bit source, 16/32/64 destination */ -#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ -#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ +#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ +#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ #define ACPI_MOVE_64_TO_64(d,s) ACPI_MOVE_32_TO_32(d,s) #else @@ -238,14 +236,14 @@ /* 32-bit source, 16/32/64 destination */ -#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ +#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ #define ACPI_MOVE_32_TO_32(d,s) *(u32 *)(void *)(d) = *(u32 *)(void *)(s) #define ACPI_MOVE_32_TO_64(d,s) *(u64 *)(void *)(d) = *(u32 *)(void *)(s) /* 64-bit source, 16/32/64 destination */ -#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ -#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ +#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ +#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ #define ACPI_MOVE_64_TO_64(d,s) *(u64 *)(void *)(d) = *(u64 *)(void *)(s) #endif @@ -266,7 +264,7 @@ /* 32-bit source, 16/32/64 destination */ -#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ +#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ #define ACPI_MOVE_32_TO_32(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\ (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\ @@ -277,8 +275,8 @@ /* 64-bit source, 16/32/64 destination */ -#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ -#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ +#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ +#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ #define ACPI_MOVE_64_TO_64(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\ (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\ (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\ @@ -305,7 +303,6 @@ #error unknown ACPI_MACHINE_WIDTH #endif - /* * Fast power-of-two math macros for non-optimized compilers */ @@ -329,7 +326,6 @@ #define ACPI_MUL_16(a) _ACPI_MUL(a,4) #define ACPI_MOD_16(a) _ACPI_MOD(a,16) - /* * Rounding macros (Power of two boundaries only) */ @@ -344,7 +340,6 @@ #define ACPI_ROUND_UP_to_64_bITS(a) ACPI_ROUND_UP(a,8) #define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY) - #define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7) #define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a)) @@ -365,7 +360,6 @@ #define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) - /* Bitfields within ACPI registers */ #define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask) @@ -381,7 +375,6 @@ #define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->descriptor_id) #define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((union acpi_descriptor *)(void *)(d))->descriptor_id = t) - /* Macro to test the object type */ #define ACPI_GET_OBJECT_TYPE(d) (((union acpi_operand_object *)(void *)(d))->common.type) @@ -430,7 +423,6 @@ #define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F)) #define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH)) - /* * Reporting macros that are never compiled out */ @@ -554,20 +546,17 @@ #define ACPI_DEBUG_ONLY_MEMBERS(a) a; #define _VERBOSE_STRUCTURES - /* Stack and buffer dumping */ #define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a),0) #define ACPI_DUMP_OPERANDS(a,b,c,d,e) acpi_ex_dump_operands(a,b,c,d,e,_acpi_module_name,__LINE__) - #define ACPI_DUMP_ENTRY(a,b) acpi_ns_dump_entry (a,b) #define ACPI_DUMP_PATHNAME(a,b,c,d) acpi_ns_dump_pathname(a,b,c,d) #define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a) #define ACPI_DUMP_BUFFER(a,b) acpi_ut_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) #define ACPI_BREAK_MSG(a) acpi_os_signal (ACPI_SIGNAL_BREAKPOINT,(a)) - /* * Generate INT3 on ACPI_ERROR (Debug only!) */ @@ -588,7 +577,6 @@ #define ACPI_DEBUG_PRINT(pl) acpi_ut_debug_print ACPI_PARAM_LIST(pl) #define ACPI_DEBUG_PRINT_RAW(pl) acpi_ut_debug_print_raw ACPI_PARAM_LIST(pl) - #else /* * This is the non-debug case -- make everything go away, @@ -639,7 +627,6 @@ #define ACPI_DEBUGGER_EXEC(a) #endif - /* * For 16-bit code, we want to shrink some things even though * we are using ACPI_DEBUG_OUTPUT to get the debug output @@ -650,7 +637,6 @@ #define ACPI_DEBUG_ONLY_MEMBERS(a) #endif - #ifdef ACPI_DEBUG_OUTPUT /* * 1) Set name to blanks @@ -663,7 +649,6 @@ #define ACPI_ADD_OBJECT_NAME(a,b) #endif - /* * Memory allocation tracking (DEBUG ONLY) */ @@ -685,6 +670,6 @@ #define ACPI_MEM_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_acpi_module_name,__LINE__) #define ACPI_MEM_TRACKING(a) a -#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ -#endif /* ACMACROS_H */ +#endif /* ACMACROS_H */ diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h index 280e9ed..79152fb 100644 --- a/include/acpi/acnames.h +++ b/include/acpi/acnames.h @@ -71,9 +71,9 @@ /* Definitions of the predefined namespace names */ -#define ACPI_UNKNOWN_NAME (u32) 0x3F3F3F3F /* Unknown name is "????" */ -#define ACPI_ROOT_NAME (u32) 0x5F5F5F5C /* Root name is "\___" */ -#define ACPI_SYS_BUS_NAME (u32) 0x5F53425F /* Sys bus name is "_SB_" */ +#define ACPI_UNKNOWN_NAME (u32) 0x3F3F3F3F /* Unknown name is "????" */ +#define ACPI_ROOT_NAME (u32) 0x5F5F5F5C /* Root name is "\___" */ +#define ACPI_SYS_BUS_NAME (u32) 0x5F53425F /* Sys bus name is "_SB_" */ #define ACPI_NS_ROOT_PATH "\\" #define ACPI_NS_SYSTEM_BUS "_SB_" @@ -83,7 +83,4 @@ #define ACPI_FUNCTION_PREFIX2 'ipca' /*! [End] no source code translation !*/ - -#endif /* __ACNAMES_H__ */ - - +#endif /* __ACNAMES_H__ */ diff --git a/include/acpi/acnamesp.h b/include/acpi/acnamesp.h index 0c9ba70..dd3501f 100644 --- a/include/acpi/acnamesp.h +++ b/include/acpi/acnamesp.h @@ -44,7 +44,6 @@ #ifndef __ACNAMESP_H__ #define __ACNAMESP_H__ - /* To search the entire name space, pass this as search_base */ #define ACPI_NS_ALL ((acpi_handle)0) @@ -54,8 +53,8 @@ * and should be one-to-one with values of acpi_object_type */ #define ACPI_NS_NORMAL 0 -#define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */ -#define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */ +#define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */ +#define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */ /* Flags for acpi_ns_lookup, acpi_ns_search_and_enter */ @@ -68,357 +67,237 @@ #define ACPI_NS_WALK_UNLOCK TRUE #define ACPI_NS_WALK_NO_UNLOCK FALSE - /* * nsinit - Namespace initialization */ -acpi_status -acpi_ns_initialize_objects ( - void); - -acpi_status -acpi_ns_initialize_devices ( - void); +acpi_status acpi_ns_initialize_objects(void); +acpi_status acpi_ns_initialize_devices(void); /* * nsload - Namespace loading */ -acpi_status -acpi_ns_load_namespace ( - void); +acpi_status acpi_ns_load_namespace(void); acpi_status -acpi_ns_load_table ( - struct acpi_table_desc *table_desc, - struct acpi_namespace_node *node); - +acpi_ns_load_table(struct acpi_table_desc *table_desc, + struct acpi_namespace_node *node); /* * nswalk - walk the namespace */ acpi_status -acpi_ns_walk_namespace ( - acpi_object_type type, - acpi_handle start_object, - u32 max_depth, - u8 unlock_before_callback, - acpi_walk_callback user_function, - void *context, - void **return_value); - -struct acpi_namespace_node * -acpi_ns_get_next_node ( - acpi_object_type type, - struct acpi_namespace_node *parent, - struct acpi_namespace_node *child); - +acpi_ns_walk_namespace(acpi_object_type type, + acpi_handle start_object, + u32 max_depth, + u8 unlock_before_callback, + acpi_walk_callback user_function, + void *context, void **return_value); + +struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type, + struct acpi_namespace_node + *parent, + struct acpi_namespace_node + *child); /* * nsparse - table parsing */ acpi_status -acpi_ns_parse_table ( - struct acpi_table_desc *table_desc, - struct acpi_namespace_node *scope); +acpi_ns_parse_table(struct acpi_table_desc *table_desc, + struct acpi_namespace_node *scope); acpi_status -acpi_ns_one_complete_parse ( - u8 pass_number, - struct acpi_table_desc *table_desc); - +acpi_ns_one_complete_parse(u8 pass_number, struct acpi_table_desc *table_desc); /* * nsaccess - Top-level namespace access */ -acpi_status -acpi_ns_root_initialize ( - void); +acpi_status acpi_ns_root_initialize(void); acpi_status -acpi_ns_lookup ( - union acpi_generic_state *scope_info, - char *name, - acpi_object_type type, - acpi_interpreter_mode interpreter_mode, - u32 flags, - struct acpi_walk_state *walk_state, - struct acpi_namespace_node **ret_node); - +acpi_ns_lookup(union acpi_generic_state *scope_info, + char *name, + acpi_object_type type, + acpi_interpreter_mode interpreter_mode, + u32 flags, + struct acpi_walk_state *walk_state, + struct acpi_namespace_node **ret_node); /* * nsalloc - Named object allocation/deallocation */ -struct acpi_namespace_node * -acpi_ns_create_node ( - u32 name); - -void -acpi_ns_delete_node ( - struct acpi_namespace_node *node); +struct acpi_namespace_node *acpi_ns_create_node(u32 name); -void -acpi_ns_delete_namespace_subtree ( - struct acpi_namespace_node *parent_handle); +void acpi_ns_delete_node(struct acpi_namespace_node *node); void -acpi_ns_delete_namespace_by_owner ( - acpi_owner_id owner_id); +acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_handle); -void -acpi_ns_detach_object ( - struct acpi_namespace_node *node); +void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id); -void -acpi_ns_delete_children ( - struct acpi_namespace_node *parent); +void acpi_ns_detach_object(struct acpi_namespace_node *node); -int -acpi_ns_compare_names ( - char *name1, - char *name2); +void acpi_ns_delete_children(struct acpi_namespace_node *parent); +int acpi_ns_compare_names(char *name1, char *name2); /* * nsdump - Namespace dump/print utilities */ #ifdef ACPI_FUTURE_USAGE -void -acpi_ns_dump_tables ( - acpi_handle search_base, - u32 max_depth); -#endif /* ACPI_FUTURE_USAGE */ +void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth); +#endif /* ACPI_FUTURE_USAGE */ -void -acpi_ns_dump_entry ( - acpi_handle handle, - u32 debug_level); +void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level); void -acpi_ns_dump_pathname ( - acpi_handle handle, - char *msg, - u32 level, - u32 component); +acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component); -void -acpi_ns_print_pathname ( - u32 num_segments, - char *pathname); +void acpi_ns_print_pathname(u32 num_segments, char *pathname); acpi_status -acpi_ns_dump_one_object ( - acpi_handle obj_handle, - u32 level, - void *context, - void **return_value); +acpi_ns_dump_one_object(acpi_handle obj_handle, + u32 level, void *context, void **return_value); #ifdef ACPI_FUTURE_USAGE void -acpi_ns_dump_objects ( - acpi_object_type type, - u8 display_type, - u32 max_depth, - acpi_owner_id owner_id, - acpi_handle start_handle); -#endif /* ACPI_FUTURE_USAGE */ - +acpi_ns_dump_objects(acpi_object_type type, + u8 display_type, + u32 max_depth, + acpi_owner_id owner_id, acpi_handle start_handle); +#endif /* ACPI_FUTURE_USAGE */ /* * nseval - Namespace evaluation functions */ -acpi_status -acpi_ns_evaluate_by_handle ( - struct acpi_parameter_info *info); +acpi_status acpi_ns_evaluate_by_handle(struct acpi_parameter_info *info); acpi_status -acpi_ns_evaluate_by_name ( - char *pathname, - struct acpi_parameter_info *info); +acpi_ns_evaluate_by_name(char *pathname, struct acpi_parameter_info *info); acpi_status -acpi_ns_evaluate_relative ( - char *pathname, - struct acpi_parameter_info *info); - +acpi_ns_evaluate_relative(char *pathname, struct acpi_parameter_info *info); /* * nsnames - Name and Scope manipulation */ -u32 -acpi_ns_opens_scope ( - acpi_object_type type); +u32 acpi_ns_opens_scope(acpi_object_type type); -char * -acpi_ns_get_external_pathname ( - struct acpi_namespace_node *node); +char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node); -char * -acpi_ns_name_of_current_scope ( - struct acpi_walk_state *walk_state); +char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state); acpi_status -acpi_ns_handle_to_pathname ( - acpi_handle target_handle, - struct acpi_buffer *buffer); +acpi_ns_handle_to_pathname(acpi_handle target_handle, + struct acpi_buffer *buffer); u8 -acpi_ns_pattern_match ( - struct acpi_namespace_node *obj_node, - char *search_for); +acpi_ns_pattern_match(struct acpi_namespace_node *obj_node, char *search_for); acpi_status -acpi_ns_get_node_by_path ( - char *external_pathname, - struct acpi_namespace_node *in_prefix_node, - u32 flags, - struct acpi_namespace_node **out_node); - -acpi_size -acpi_ns_get_pathname_length ( - struct acpi_namespace_node *node); +acpi_ns_get_node_by_path(char *external_pathname, + struct acpi_namespace_node *in_prefix_node, + u32 flags, struct acpi_namespace_node **out_node); +acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node); /* * nsobject - Object management for namespace nodes */ acpi_status -acpi_ns_attach_object ( - struct acpi_namespace_node *node, - union acpi_operand_object *object, - acpi_object_type type); +acpi_ns_attach_object(struct acpi_namespace_node *node, + union acpi_operand_object *object, acpi_object_type type); -union acpi_operand_object * -acpi_ns_get_attached_object ( - struct acpi_namespace_node *node); +union acpi_operand_object *acpi_ns_get_attached_object(struct + acpi_namespace_node + *node); -union acpi_operand_object * -acpi_ns_get_secondary_object ( - union acpi_operand_object *obj_desc); +union acpi_operand_object *acpi_ns_get_secondary_object(union + acpi_operand_object + *obj_desc); acpi_status -acpi_ns_attach_data ( - struct acpi_namespace_node *node, - acpi_object_handler handler, - void *data); +acpi_ns_attach_data(struct acpi_namespace_node *node, + acpi_object_handler handler, void *data); acpi_status -acpi_ns_detach_data ( - struct acpi_namespace_node *node, - acpi_object_handler handler); +acpi_ns_detach_data(struct acpi_namespace_node *node, + acpi_object_handler handler); acpi_status -acpi_ns_get_attached_data ( - struct acpi_namespace_node *node, - acpi_object_handler handler, - void **data); - +acpi_ns_get_attached_data(struct acpi_namespace_node *node, + acpi_object_handler handler, void **data); /* * nssearch - Namespace searching and entry */ acpi_status -acpi_ns_search_and_enter ( - u32 entry_name, - struct acpi_walk_state *walk_state, - struct acpi_namespace_node *node, - acpi_interpreter_mode interpreter_mode, - acpi_object_type type, - u32 flags, - struct acpi_namespace_node **ret_node); +acpi_ns_search_and_enter(u32 entry_name, + struct acpi_walk_state *walk_state, + struct acpi_namespace_node *node, + acpi_interpreter_mode interpreter_mode, + acpi_object_type type, + u32 flags, struct acpi_namespace_node **ret_node); acpi_status -acpi_ns_search_node ( - u32 entry_name, - struct acpi_namespace_node *node, - acpi_object_type type, - struct acpi_namespace_node **ret_node); +acpi_ns_search_node(u32 entry_name, + struct acpi_namespace_node *node, + acpi_object_type type, + struct acpi_namespace_node **ret_node); void -acpi_ns_install_node ( - struct acpi_walk_state *walk_state, - struct acpi_namespace_node *parent_node, - struct acpi_namespace_node *node, - acpi_object_type type); - +acpi_ns_install_node(struct acpi_walk_state *walk_state, + struct acpi_namespace_node *parent_node, + struct acpi_namespace_node *node, acpi_object_type type); /* * nsutils - Utility functions */ -u8 -acpi_ns_valid_root_prefix ( - char prefix); +u8 acpi_ns_valid_root_prefix(char prefix); -acpi_object_type -acpi_ns_get_type ( - struct acpi_namespace_node *node); +acpi_object_type acpi_ns_get_type(struct acpi_namespace_node *node); -u32 -acpi_ns_local ( - acpi_object_type type); +u32 acpi_ns_local(acpi_object_type type); void -acpi_ns_report_error ( - char *module_name, - u32 line_number, - u32 component_id, - char *internal_name, - acpi_status lookup_status); +acpi_ns_report_error(char *module_name, + u32 line_number, + u32 component_id, + char *internal_name, acpi_status lookup_status); void -acpi_ns_report_method_error ( - char *module_name, - u32 line_number, - u32 component_id, - char *message, - struct acpi_namespace_node *node, - char *path, - acpi_status lookup_status); +acpi_ns_report_method_error(char *module_name, + u32 line_number, + u32 component_id, + char *message, + struct acpi_namespace_node *node, + char *path, acpi_status lookup_status); -void -acpi_ns_print_node_pathname ( - struct acpi_namespace_node *node, - char *msg); +void acpi_ns_print_node_pathname(struct acpi_namespace_node *node, char *msg); -acpi_status -acpi_ns_build_internal_name ( - struct acpi_namestring_info *info); +acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info); -void -acpi_ns_get_internal_name_length ( - struct acpi_namestring_info *info); +void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info); -acpi_status -acpi_ns_internalize_name ( - char *dotted_name, - char **converted_name); +acpi_status acpi_ns_internalize_name(char *dotted_name, char **converted_name); acpi_status -acpi_ns_externalize_name ( - u32 internal_name_length, - char *internal_name, - u32 *converted_name_length, - char **converted_name); +acpi_ns_externalize_name(u32 internal_name_length, + char *internal_name, + u32 * converted_name_length, char **converted_name); -struct acpi_namespace_node * -acpi_ns_map_handle_to_node ( - acpi_handle handle); +struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle); -acpi_handle -acpi_ns_convert_entry_to_handle( - struct acpi_namespace_node *node); - -void -acpi_ns_terminate ( - void); +acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node); -struct acpi_namespace_node * -acpi_ns_get_parent_node ( - struct acpi_namespace_node *node); +void acpi_ns_terminate(void); +struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node + *node); -struct acpi_namespace_node * -acpi_ns_get_next_valid_node ( - struct acpi_namespace_node *node); +struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct + acpi_namespace_node + *node); -#endif /* __ACNAMESP_H__ */ +#endif /* __ACNAMESP_H__ */ diff --git a/include/acpi/acobject.h b/include/acpi/acobject.h index 34f9d1f..4a326ba 100644 --- a/include/acpi/acobject.h +++ b/include/acpi/acobject.h @@ -45,7 +45,6 @@ #ifndef _ACOBJECT_H #define _ACOBJECT_H - /* * The union acpi_operand_object is used to pass AML operands from the dispatcher * to the interpreter, and to keep track of the various handlers such as @@ -81,7 +80,6 @@ #define AOPOBJ_SETUP_COMPLETE 0x10 #define AOPOBJ_SINGLE_DATUM 0x20 - /* * Common bitfield for the field objects * "Field Datum" -- a datum from the actual field object @@ -96,8 +94,7 @@ u8 start_field_bit_offset;/* Bit offset within first field datum (0-63) */\ u8 access_bit_width; /* Read/Write size in bits (8-64) */\ u32 value; /* Value to store into the Bank or Index register */\ - struct acpi_namespace_node *node; /* Link back to parent node */ - + struct acpi_namespace_node *node; /* Link back to parent node */ /* * Fields common to both Strings and Buffers @@ -105,15 +102,13 @@ #define ACPI_COMMON_BUFFER_INFO \ u32 length; - /* * Common fields for objects that support ASL notifications */ #define ACPI_COMMON_NOTIFY_INFO \ union acpi_operand_object *system_notify; /* Handler for system notifies */\ union acpi_operand_object *device_notify; /* Handler for driver notifies */\ - union acpi_operand_object *handler; /* Handler for Address space */ - + union acpi_operand_object *handler; /* Handler for Address space */ /****************************************************************************** * @@ -121,161 +116,110 @@ * *****************************************************************************/ -struct acpi_object_common -{ - ACPI_OBJECT_COMMON_HEADER -}; +struct acpi_object_common { +ACPI_OBJECT_COMMON_HEADER}; - -struct acpi_object_integer -{ - ACPI_OBJECT_COMMON_HEADER - acpi_integer value; +struct acpi_object_integer { + ACPI_OBJECT_COMMON_HEADER acpi_integer value; }; - /* * Note: The String and Buffer object must be identical through the Pointer * element. There is code that depends on this. */ -struct acpi_object_string /* Null terminated, ASCII characters only */ -{ - ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_BUFFER_INFO - char *pointer; /* String in AML stream or allocated string */ +struct acpi_object_string { /* Null terminated, ASCII characters only */ + ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_BUFFER_INFO char *pointer; /* String in AML stream or allocated string */ }; - -struct acpi_object_buffer -{ - ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_BUFFER_INFO - u8 *pointer; /* Buffer in AML stream or allocated buffer */ - struct acpi_namespace_node *node; /* Link back to parent node */ - u8 *aml_start; - u32 aml_length; +struct acpi_object_buffer { + ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_BUFFER_INFO u8 * pointer; /* Buffer in AML stream or allocated buffer */ + struct acpi_namespace_node *node; /* Link back to parent node */ + u8 *aml_start; + u32 aml_length; }; - -struct acpi_object_package -{ - ACPI_OBJECT_COMMON_HEADER - - u32 count; /* # of elements in package */ - u32 aml_length; - u8 *aml_start; - struct acpi_namespace_node *node; /* Link back to parent node */ - union acpi_operand_object **elements; /* Array of pointers to acpi_objects */ +struct acpi_object_package { + ACPI_OBJECT_COMMON_HEADER u32 count; /* # of elements in package */ + u32 aml_length; + u8 *aml_start; + struct acpi_namespace_node *node; /* Link back to parent node */ + union acpi_operand_object **elements; /* Array of pointers to acpi_objects */ }; - /****************************************************************************** * * Complex data types * *****************************************************************************/ -struct acpi_object_event -{ - ACPI_OBJECT_COMMON_HEADER - void *semaphore; +struct acpi_object_event { + ACPI_OBJECT_COMMON_HEADER void *semaphore; }; - #define ACPI_INFINITE_CONCURRENCY 0xFF typedef -acpi_status (*ACPI_INTERNAL_METHOD) ( - struct acpi_walk_state *walk_state); - -struct acpi_object_method -{ - ACPI_OBJECT_COMMON_HEADER - u8 method_flags; - u8 param_count; - u32 aml_length; - void *semaphore; - u8 *aml_start; - ACPI_INTERNAL_METHOD implementation; - u8 concurrency; - u8 thread_count; - acpi_owner_id owner_id; +acpi_status(*ACPI_INTERNAL_METHOD) (struct acpi_walk_state * walk_state); + +struct acpi_object_method { + ACPI_OBJECT_COMMON_HEADER u8 method_flags; + u8 param_count; + u32 aml_length; + void *semaphore; + u8 *aml_start; + ACPI_INTERNAL_METHOD implementation; + u8 concurrency; + u8 thread_count; + acpi_owner_id owner_id; }; - -struct acpi_object_mutex -{ - ACPI_OBJECT_COMMON_HEADER - u8 sync_level; /* 0-15, specified in Mutex() call */ - u16 acquisition_depth; /* Allow multiple Acquires, same thread */ - struct acpi_thread_state *owner_thread; /* Current owner of the mutex */ - void *semaphore; /* Actual OS synchronization object */ - union acpi_operand_object *prev; /* Link for list of acquired mutexes */ - union acpi_operand_object *next; /* Link for list of acquired mutexes */ - struct acpi_namespace_node *node; /* Containing namespace node */ - u8 original_sync_level; /* Owner's original sync level (0-15) */ +struct acpi_object_mutex { + ACPI_OBJECT_COMMON_HEADER u8 sync_level; /* 0-15, specified in Mutex() call */ + u16 acquisition_depth; /* Allow multiple Acquires, same thread */ + struct acpi_thread_state *owner_thread; /* Current owner of the mutex */ + void *semaphore; /* Actual OS synchronization object */ + union acpi_operand_object *prev; /* Link for list of acquired mutexes */ + union acpi_operand_object *next; /* Link for list of acquired mutexes */ + struct acpi_namespace_node *node; /* Containing namespace node */ + u8 original_sync_level; /* Owner's original sync level (0-15) */ }; - -struct acpi_object_region -{ - ACPI_OBJECT_COMMON_HEADER - - u8 space_id; - union acpi_operand_object *handler; /* Handler for region access */ - struct acpi_namespace_node *node; /* Containing namespace node */ - union acpi_operand_object *next; - u32 length; - acpi_physical_address address; +struct acpi_object_region { + ACPI_OBJECT_COMMON_HEADER u8 space_id; + union acpi_operand_object *handler; /* Handler for region access */ + struct acpi_namespace_node *node; /* Containing namespace node */ + union acpi_operand_object *next; + u32 length; + acpi_physical_address address; }; - /****************************************************************************** * * Objects that can be notified. All share a common notify_info area. * *****************************************************************************/ -struct acpi_object_notify_common /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */ -{ - ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_NOTIFY_INFO -}; - - -struct acpi_object_device -{ - ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_NOTIFY_INFO - struct acpi_gpe_block_info *gpe_block; -}; - +struct acpi_object_notify_common { /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */ +ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO}; -struct acpi_object_power_resource -{ +struct acpi_object_device { ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_NOTIFY_INFO - u32 system_level; - u32 resource_order; + ACPI_COMMON_NOTIFY_INFO struct acpi_gpe_block_info *gpe_block; }; - -struct acpi_object_processor -{ - ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_NOTIFY_INFO - u32 proc_id; - u32 length; - acpi_io_address address; +struct acpi_object_power_resource { + ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO u32 system_level; + u32 resource_order; }; - -struct acpi_object_thermal_zone -{ - ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_NOTIFY_INFO +struct acpi_object_processor { + ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO u32 proc_id; + u32 length; + acpi_io_address address; }; +struct acpi_object_thermal_zone { +ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO}; /****************************************************************************** * @@ -283,90 +227,63 @@ struct acpi_object_thermal_zone * *****************************************************************************/ -struct acpi_object_field_common /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */ -{ - ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_FIELD_INFO - union acpi_operand_object *region_obj; /* Containing Operation Region object */ - /* (REGION/BANK fields only) */ +struct acpi_object_field_common { /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */ + ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Containing Operation Region object */ + /* (REGION/BANK fields only) */ }; - -struct acpi_object_region_field -{ - ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_FIELD_INFO - union acpi_operand_object *region_obj; /* Containing op_region object */ +struct acpi_object_region_field { + ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Containing op_region object */ }; - -struct acpi_object_bank_field -{ - ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_FIELD_INFO - union acpi_operand_object *region_obj; /* Containing op_region object */ - union acpi_operand_object *bank_obj; /* bank_select Register object */ +struct acpi_object_bank_field { + ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Containing op_region object */ + union acpi_operand_object *bank_obj; /* bank_select Register object */ }; - -struct acpi_object_index_field -{ - ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_FIELD_INFO - - /* - * No "region_obj" pointer needed since the Index and Data registers - * are each field definitions unto themselves. - */ - union acpi_operand_object *index_obj; /* Index register */ - union acpi_operand_object *data_obj; /* Data register */ +struct acpi_object_index_field { + ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO + /* + * No "region_obj" pointer needed since the Index and Data registers + * are each field definitions unto themselves. + */ + union acpi_operand_object *index_obj; /* Index register */ + union acpi_operand_object *data_obj; /* Data register */ }; - /* The buffer_field is different in that it is part of a Buffer, not an op_region */ -struct acpi_object_buffer_field -{ - ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_FIELD_INFO - union acpi_operand_object *buffer_obj; /* Containing Buffer object */ +struct acpi_object_buffer_field { + ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *buffer_obj; /* Containing Buffer object */ }; - /****************************************************************************** * * Objects for handlers * *****************************************************************************/ -struct acpi_object_notify_handler -{ - ACPI_OBJECT_COMMON_HEADER - struct acpi_namespace_node *node; /* Parent device */ - acpi_notify_handler handler; - void *context; +struct acpi_object_notify_handler { + ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *node; /* Parent device */ + acpi_notify_handler handler; + void *context; }; - /* Flags for address handler */ #define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED 0x1 - -struct acpi_object_addr_handler -{ - ACPI_OBJECT_COMMON_HEADER - u8 space_id; - u16 hflags; - acpi_adr_space_handler handler; - struct acpi_namespace_node *node; /* Parent device */ - void *context; - acpi_adr_space_setup setup; - union acpi_operand_object *region_list; /* regions using this handler */ - union acpi_operand_object *next; +struct acpi_object_addr_handler { + ACPI_OBJECT_COMMON_HEADER u8 space_id; + u16 hflags; + acpi_adr_space_handler handler; + struct acpi_namespace_node *node; /* Parent device */ + void *context; + acpi_adr_space_setup setup; + union acpi_operand_object *region_list; /* regions using this handler */ + union acpi_operand_object *next; }; - /****************************************************************************** * * Special internal objects @@ -377,18 +294,15 @@ struct acpi_object_addr_handler * The Reference object type is used for these opcodes: * Arg[0-6], Local[0-7], index_op, name_op, zero_op, one_op, ones_op, debug_op */ -struct acpi_object_reference -{ - ACPI_OBJECT_COMMON_HEADER - u8 target_type; /* Used for index_op */ - u16 opcode; - u32 offset; /* Used for arg_op, local_op, and index_op */ - void *object; /* name_op=>HANDLE to obj, index_op=>union acpi_operand_object */ - struct acpi_namespace_node *node; - union acpi_operand_object **where; +struct acpi_object_reference { + ACPI_OBJECT_COMMON_HEADER u8 target_type; /* Used for index_op */ + u16 opcode; + u32 offset; /* Used for arg_op, local_op, and index_op */ + void *object; /* name_op=>HANDLE to obj, index_op=>union acpi_operand_object */ + struct acpi_namespace_node *node; + union acpi_operand_object **where; }; - /* * Extra object is used as additional storage for types that * have AML code in their declarations (term_args) that must be @@ -396,73 +310,62 @@ struct acpi_object_reference * * Currently: Region and field_unit types */ -struct acpi_object_extra -{ - ACPI_OBJECT_COMMON_HEADER - u8 byte_fill1; - u16 word_fill1; - u32 aml_length; - u8 *aml_start; - struct acpi_namespace_node *method_REG; /* _REG method for this region (if any) */ - void *region_context; /* Region-specific data */ +struct acpi_object_extra { + ACPI_OBJECT_COMMON_HEADER u8 byte_fill1; + u16 word_fill1; + u32 aml_length; + u8 *aml_start; + struct acpi_namespace_node *method_REG; /* _REG method for this region (if any) */ + void *region_context; /* Region-specific data */ }; - /* Additional data that can be attached to namespace nodes */ -struct acpi_object_data -{ - ACPI_OBJECT_COMMON_HEADER - acpi_object_handler handler; - void *pointer; +struct acpi_object_data { + ACPI_OBJECT_COMMON_HEADER acpi_object_handler handler; + void *pointer; }; - /* Structure used when objects are cached for reuse */ -struct acpi_object_cache_list -{ - ACPI_OBJECT_COMMON_HEADER - union acpi_operand_object *next; /* Link for object cache and internal lists*/ +struct acpi_object_cache_list { + ACPI_OBJECT_COMMON_HEADER union acpi_operand_object *next; /* Link for object cache and internal lists */ }; - /****************************************************************************** * * union acpi_operand_object Descriptor - a giant union of all of the above * *****************************************************************************/ -union acpi_operand_object -{ - struct acpi_object_common common; - struct acpi_object_integer integer; - struct acpi_object_string string; - struct acpi_object_buffer buffer; - struct acpi_object_package package; - struct acpi_object_event event; - struct acpi_object_method method; - struct acpi_object_mutex mutex; - struct acpi_object_region region; - struct acpi_object_notify_common common_notify; - struct acpi_object_device device; - struct acpi_object_power_resource power_resource; - struct acpi_object_processor processor; - struct acpi_object_thermal_zone thermal_zone; - struct acpi_object_field_common common_field; - struct acpi_object_region_field field; - struct acpi_object_buffer_field buffer_field; - struct acpi_object_bank_field bank_field; - struct acpi_object_index_field index_field; - struct acpi_object_notify_handler notify; - struct acpi_object_addr_handler address_space; - struct acpi_object_reference reference; - struct acpi_object_extra extra; - struct acpi_object_data data; - struct acpi_object_cache_list cache; +union acpi_operand_object { + struct acpi_object_common common; + struct acpi_object_integer integer; + struct acpi_object_string string; + struct acpi_object_buffer buffer; + struct acpi_object_package package; + struct acpi_object_event event; + struct acpi_object_method method; + struct acpi_object_mutex mutex; + struct acpi_object_region region; + struct acpi_object_notify_common common_notify; + struct acpi_object_device device; + struct acpi_object_power_resource power_resource; + struct acpi_object_processor processor; + struct acpi_object_thermal_zone thermal_zone; + struct acpi_object_field_common common_field; + struct acpi_object_region_field field; + struct acpi_object_buffer_field buffer_field; + struct acpi_object_bank_field bank_field; + struct acpi_object_index_field index_field; + struct acpi_object_notify_handler notify; + struct acpi_object_addr_handler address_space; + struct acpi_object_reference reference; + struct acpi_object_extra extra; + struct acpi_object_data data; + struct acpi_object_cache_list cache; }; - /****************************************************************************** * * union acpi_descriptor - objects that share a common descriptor identifier @@ -471,7 +374,7 @@ union acpi_operand_object /* Object descriptor types */ -#define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */ +#define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */ #define ACPI_DESC_TYPE_STATE 0x02 #define ACPI_DESC_TYPE_STATE_UPDATE 0x03 #define ACPI_DESC_TYPE_STATE_PACKAGE 0x04 @@ -488,14 +391,11 @@ union acpi_operand_object #define ACPI_DESC_TYPE_NAMED 0x0F #define ACPI_DESC_TYPE_MAX 0x0F - -union acpi_descriptor -{ - u8 descriptor_id; /* To differentiate various internal objs */\ - union acpi_operand_object object; - struct acpi_namespace_node node; - union acpi_parse_object op; +union acpi_descriptor { + u8 descriptor_id; /* To differentiate various internal objs */ + union acpi_operand_object object; + struct acpi_namespace_node node; + union acpi_parse_object op; }; - -#endif /* _ACOBJECT_H */ +#endif /* _ACOBJECT_H */ diff --git a/include/acpi/acopcode.h b/include/acpi/acopcode.h index 093f697..64da429 100644 --- a/include/acpi/acopcode.h +++ b/include/acpi/acopcode.h @@ -62,7 +62,6 @@ #define _NAM 0x6C #define _PFX 0x6D - /* * All AML opcodes and the parse-time arguments for each. Used by the AML * parser Each list is compressed into a 32-bit number and stored in the @@ -191,7 +190,6 @@ #define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA) #define ARGP_ZERO_OP ARG_NONE - /* * All AML opcodes and the runtime arguments for each. Used by the AML * interpreter Each list is compressed into a 32-bit number and stored @@ -322,4 +320,4 @@ #define ARGI_WORD_OP ARGI_INVALID_OPCODE #define ARGI_ZERO_OP ARG_NONE -#endif /* __ACOPCODE_H__ */ +#endif /* __ACOPCODE_H__ */ diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h index d7e828c..68d7edf0 100644 --- a/include/acpi/acoutput.h +++ b/include/acpi/acoutput.h @@ -73,12 +73,10 @@ #define ACPI_ALL_COMPONENTS 0x00003FFF #define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS) - /* Component IDs reserved for ACPI drivers */ #define ACPI_ALL_DRIVERS 0xFFFF0000 - /* * Raw debug output levels, do not use these in the DEBUG_PRINT macros */ @@ -132,7 +130,6 @@ #define ACPI_LV_VERBOSE 0xF0000000 - /* * Debug level macros that are used in the DEBUG_PRINT macros */ @@ -147,7 +144,6 @@ #define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO) #define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS) - /* Trace level -- also used in the global "debug_level" */ #define ACPI_DB_INIT_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES) @@ -174,12 +170,10 @@ #define ACPI_DB_ALL ACPI_DEBUG_LEVEL (ACPI_LV_ALL) - /* Defaults for debug_level, debug and normal */ #define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT) #define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT) #define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL) - -#endif /* __ACOUTPUT_H__ */ +#endif /* __ACOUTPUT_H__ */ diff --git a/include/acpi/acparser.h b/include/acpi/acparser.h index f692ad5..d352d40 100644 --- a/include/acpi/acparser.h +++ b/include/acpi/acparser.h @@ -41,18 +41,15 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ACPARSER_H__ #define __ACPARSER_H__ - #define OP_HAS_RETURN_VALUE 1 /* variable # arguments */ #define ACPI_VAR_ARGS ACPI_UINT32_MAX - #define ACPI_PARSE_DELETE_TREE 0x0001 #define ACPI_PARSE_NO_TREE_DELETE 0x0000 #define ACPI_PARSE_TREE_MASK 0x0001 @@ -65,266 +62,171 @@ #define ACPI_PARSE_DEFERRED_OP 0x0100 #define ACPI_PARSE_DISASSEMBLE 0x0200 - /****************************************************************************** * * Parser interfaces * *****************************************************************************/ - /* * psxface - Parser external interfaces */ -acpi_status -acpi_ps_execute_method ( - struct acpi_parameter_info *info); - +acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info); /* * psargs - Parse AML opcode arguments */ -u8 * -acpi_ps_get_next_package_end ( - struct acpi_parse_state *parser_state); +u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state); -char * -acpi_ps_get_next_namestring ( - struct acpi_parse_state *parser_state); +char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state); void -acpi_ps_get_next_simple_arg ( - struct acpi_parse_state *parser_state, - u32 arg_type, - union acpi_parse_object *arg); +acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, + u32 arg_type, union acpi_parse_object *arg); acpi_status -acpi_ps_get_next_namepath ( - struct acpi_walk_state *walk_state, - struct acpi_parse_state *parser_state, - union acpi_parse_object *arg, - u8 method_call); +acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, + struct acpi_parse_state *parser_state, + union acpi_parse_object *arg, u8 method_call); acpi_status -acpi_ps_get_next_arg ( - struct acpi_walk_state *walk_state, - struct acpi_parse_state *parser_state, - u32 arg_type, - union acpi_parse_object **return_arg); - +acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, + struct acpi_parse_state *parser_state, + u32 arg_type, union acpi_parse_object **return_arg); /* * psfind */ -union acpi_parse_object * -acpi_ps_find_name ( - union acpi_parse_object *scope, - u32 name, - u32 opcode); - -union acpi_parse_object* -acpi_ps_get_parent ( - union acpi_parse_object *op); +union acpi_parse_object *acpi_ps_find_name(union acpi_parse_object *scope, + u32 name, u32 opcode); +union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op); /* * psopcode - AML Opcode information */ -const struct acpi_opcode_info * -acpi_ps_get_opcode_info ( - u16 opcode); - -char * -acpi_ps_get_opcode_name ( - u16 opcode); +const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode); +char *acpi_ps_get_opcode_name(u16 opcode); /* * psparse - top level parsing routines */ -acpi_status -acpi_ps_parse_aml ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state); -u32 -acpi_ps_get_opcode_size ( - u32 opcode); +u32 acpi_ps_get_opcode_size(u32 opcode); -u16 -acpi_ps_peek_opcode ( - struct acpi_parse_state *state); +u16 acpi_ps_peek_opcode(struct acpi_parse_state *state); acpi_status -acpi_ps_complete_this_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op); +acpi_ps_complete_this_op(struct acpi_walk_state *walk_state, + union acpi_parse_object *op); acpi_status -acpi_ps_next_parse_state ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - acpi_status callback_status); - +acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + acpi_status callback_status); /* * psloop - main parse loop */ -acpi_status -acpi_ps_parse_loop ( - struct acpi_walk_state *walk_state); - +acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state); /* * psscope - Scope stack management routines */ acpi_status -acpi_ps_init_scope ( - struct acpi_parse_state *parser_state, - union acpi_parse_object *root); +acpi_ps_init_scope(struct acpi_parse_state *parser_state, + union acpi_parse_object *root); -union acpi_parse_object * -acpi_ps_get_parent_scope ( - struct acpi_parse_state *state); +union acpi_parse_object *acpi_ps_get_parent_scope(struct acpi_parse_state + *state); -u8 -acpi_ps_has_completed_scope ( - struct acpi_parse_state *parser_state); +u8 acpi_ps_has_completed_scope(struct acpi_parse_state *parser_state); void -acpi_ps_pop_scope ( - struct acpi_parse_state *parser_state, - union acpi_parse_object **op, - u32 *arg_list, - u32 *arg_count); +acpi_ps_pop_scope(struct acpi_parse_state *parser_state, + union acpi_parse_object **op, + u32 * arg_list, u32 * arg_count); acpi_status -acpi_ps_push_scope ( - struct acpi_parse_state *parser_state, - union acpi_parse_object *op, - u32 remaining_args, - u32 arg_count); - -void -acpi_ps_cleanup_scope ( - struct acpi_parse_state *state); +acpi_ps_push_scope(struct acpi_parse_state *parser_state, + union acpi_parse_object *op, + u32 remaining_args, u32 arg_count); +void acpi_ps_cleanup_scope(struct acpi_parse_state *state); /* * pstree - parse tree manipulation routines */ void -acpi_ps_append_arg( - union acpi_parse_object *op, - union acpi_parse_object *arg); - -union acpi_parse_object* -acpi_ps_find ( - union acpi_parse_object *scope, - char *path, - u16 opcode, - u32 create); - -union acpi_parse_object * -acpi_ps_get_arg( - union acpi_parse_object *op, - u32 argn); +acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg); -#ifdef ACPI_FUTURE_USAGE -union acpi_parse_object * -acpi_ps_get_depth_next ( - union acpi_parse_object *origin, - union acpi_parse_object *op); -#endif /* ACPI_FUTURE_USAGE */ +union acpi_parse_object *acpi_ps_find(union acpi_parse_object *scope, + char *path, u16 opcode, u32 create); + +union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn); +#ifdef ACPI_FUTURE_USAGE +union acpi_parse_object *acpi_ps_get_depth_next(union acpi_parse_object *origin, + union acpi_parse_object *op); +#endif /* ACPI_FUTURE_USAGE */ /* * pswalk - parse tree walk routines */ acpi_status -acpi_ps_walk_parsed_aml ( - union acpi_parse_object *start_op, - union acpi_parse_object *end_op, - union acpi_operand_object *mth_desc, - struct acpi_namespace_node *start_node, - union acpi_operand_object **params, - union acpi_operand_object **caller_return_desc, - acpi_owner_id owner_id, - acpi_parse_downwards descending_callback, - acpi_parse_upwards ascending_callback); - -acpi_status -acpi_ps_get_next_walk_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - acpi_parse_upwards ascending_callback); +acpi_ps_walk_parsed_aml(union acpi_parse_object *start_op, + union acpi_parse_object *end_op, + union acpi_operand_object *mth_desc, + struct acpi_namespace_node *start_node, + union acpi_operand_object **params, + union acpi_operand_object **caller_return_desc, + acpi_owner_id owner_id, + acpi_parse_downwards descending_callback, + acpi_parse_upwards ascending_callback); acpi_status -acpi_ps_delete_completed_op ( - struct acpi_walk_state *walk_state); +acpi_ps_get_next_walk_op(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + acpi_parse_upwards ascending_callback); -void -acpi_ps_delete_parse_tree ( - union acpi_parse_object *root); +acpi_status acpi_ps_delete_completed_op(struct acpi_walk_state *walk_state); +void acpi_ps_delete_parse_tree(union acpi_parse_object *root); /* * psutils - parser utilities */ -union acpi_parse_object * -acpi_ps_create_scope_op ( - void); +union acpi_parse_object *acpi_ps_create_scope_op(void); -void -acpi_ps_init_op ( - union acpi_parse_object *op, - u16 opcode); +void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode); -union acpi_parse_object * -acpi_ps_alloc_op ( - u16 opcode); +union acpi_parse_object *acpi_ps_alloc_op(u16 opcode); -void -acpi_ps_free_op ( - union acpi_parse_object *op); +void acpi_ps_free_op(union acpi_parse_object *op); -u8 -acpi_ps_is_leading_char ( - u32 c); +u8 acpi_ps_is_leading_char(u32 c); -u8 -acpi_ps_is_prefix_char ( - u32 c); +u8 acpi_ps_is_prefix_char(u32 c); #ifdef ACPI_FUTURE_USAGE -u32 -acpi_ps_get_name( - union acpi_parse_object *op); -#endif /* ACPI_FUTURE_USAGE */ - -void -acpi_ps_set_name( - union acpi_parse_object *op, - u32 name); +u32 acpi_ps_get_name(union acpi_parse_object *op); +#endif /* ACPI_FUTURE_USAGE */ +void acpi_ps_set_name(union acpi_parse_object *op, u32 name); /* * psdump - display parser tree */ u32 -acpi_ps_sprint_path ( - char *buffer_start, - u32 buffer_size, - union acpi_parse_object *op); +acpi_ps_sprint_path(char *buffer_start, + u32 buffer_size, union acpi_parse_object *op); u32 -acpi_ps_sprint_op ( - char *buffer_start, - u32 buffer_size, - union acpi_parse_object *op); - -void -acpi_ps_show ( - union acpi_parse_object *op); +acpi_ps_sprint_op(char *buffer_start, + u32 buffer_size, union acpi_parse_object *op); +void acpi_ps_show(union acpi_parse_object *op); -#endif /* __ACPARSER_H__ */ +#endif /* __ACPARSER_H__ */ diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h index a69d789..ccf34f9 100644 --- a/include/acpi/acpi.h +++ b/include/acpi/acpi.h @@ -49,22 +49,21 @@ * We put them here because we don't want to duplicate them * in the rest of the source code again and again. */ -#include "acnames.h" /* Global ACPI names and strings */ -#include "acconfig.h" /* Configuration constants */ -#include "platform/acenv.h" /* Target environment specific items */ -#include "actypes.h" /* Fundamental common data types */ -#include "acexcep.h" /* ACPI exception codes */ -#include "acmacros.h" /* C macros */ -#include "actbl.h" /* ACPI table definitions */ -#include "aclocal.h" /* Internal data types */ -#include "acoutput.h" /* Error output and Debug macros */ -#include "acpiosxf.h" /* Interfaces to the ACPI-to-OS layer*/ -#include "acpixf.h" /* ACPI core subsystem external interfaces */ -#include "acobject.h" /* ACPI internal object */ -#include "acstruct.h" /* Common structures */ -#include "acglobal.h" /* All global variables */ -#include "achware.h" /* Hardware defines and interfaces */ -#include "acutils.h" /* Utility interfaces */ +#include "acnames.h" /* Global ACPI names and strings */ +#include "acconfig.h" /* Configuration constants */ +#include "platform/acenv.h" /* Target environment specific items */ +#include "actypes.h" /* Fundamental common data types */ +#include "acexcep.h" /* ACPI exception codes */ +#include "acmacros.h" /* C macros */ +#include "actbl.h" /* ACPI table definitions */ +#include "aclocal.h" /* Internal data types */ +#include "acoutput.h" /* Error output and Debug macros */ +#include "acpiosxf.h" /* Interfaces to the ACPI-to-OS layer */ +#include "acpixf.h" /* ACPI core subsystem external interfaces */ +#include "acobject.h" /* ACPI internal object */ +#include "acstruct.h" /* Common structures */ +#include "acglobal.h" /* All global variables */ +#include "achware.h" /* Hardware defines and interfaces */ +#include "acutils.h" /* Utility interfaces */ - -#endif /* __ACPI_H__ */ +#endif /* __ACPI_H__ */ diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 8d0e129..4f4b2ba 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -35,48 +35,41 @@ /* TBD: Make dynamic */ #define ACPI_MAX_HANDLES 10 struct acpi_handle_list { - u32 count; - acpi_handle handles[ACPI_MAX_HANDLES]; + u32 count; + acpi_handle handles[ACPI_MAX_HANDLES]; }; - /* acpi_utils.h */ acpi_status -acpi_extract_package ( - union acpi_object *package, - struct acpi_buffer *format, - struct acpi_buffer *buffer); +acpi_extract_package(union acpi_object *package, + struct acpi_buffer *format, struct acpi_buffer *buffer); acpi_status -acpi_evaluate_integer ( - acpi_handle handle, - acpi_string pathname, - struct acpi_object_list *arguments, - unsigned long *data); +acpi_evaluate_integer(acpi_handle handle, + acpi_string pathname, + struct acpi_object_list *arguments, unsigned long *data); acpi_status -acpi_evaluate_reference ( - acpi_handle handle, - acpi_string pathname, - struct acpi_object_list *arguments, - struct acpi_handle_list *list); - +acpi_evaluate_reference(acpi_handle handle, + acpi_string pathname, + struct acpi_object_list *arguments, + struct acpi_handle_list *list); #ifdef CONFIG_ACPI_BUS #include #define ACPI_BUS_FILE_ROOT "acpi" -extern struct proc_dir_entry *acpi_root_dir; -extern FADT_DESCRIPTOR acpi_fadt; +extern struct proc_dir_entry *acpi_root_dir; +extern FADT_DESCRIPTOR acpi_fadt; enum acpi_bus_removal_type { - ACPI_BUS_REMOVAL_NORMAL = 0, + ACPI_BUS_REMOVAL_NORMAL = 0, ACPI_BUS_REMOVAL_EJECT, ACPI_BUS_REMOVAL_SUPRISE, ACPI_BUS_REMOVAL_TYPE_COUNT }; enum acpi_bus_device_type { - ACPI_BUS_TYPE_DEVICE = 0, + ACPI_BUS_TYPE_DEVICE = 0, ACPI_BUS_TYPE_POWER, ACPI_BUS_TYPE_PROCESSOR, ACPI_BUS_TYPE_THERMAL, @@ -89,61 +82,60 @@ enum acpi_bus_device_type { struct acpi_driver; struct acpi_device; - /* * ACPI Driver * ----------- */ -typedef int (*acpi_op_add) (struct acpi_device *device); -typedef int (*acpi_op_remove) (struct acpi_device *device, int type); -typedef int (*acpi_op_lock) (struct acpi_device *device, int type); -typedef int (*acpi_op_start) (struct acpi_device *device); -typedef int (*acpi_op_stop) (struct acpi_device *device, int type); -typedef int (*acpi_op_suspend) (struct acpi_device *device, int state); -typedef int (*acpi_op_resume) (struct acpi_device *device, int state); -typedef int (*acpi_op_scan) (struct acpi_device *device); -typedef int (*acpi_op_bind) (struct acpi_device *device); -typedef int (*acpi_op_unbind) (struct acpi_device *device); -typedef int (*acpi_op_match) (struct acpi_device *device, - struct acpi_driver *driver); +typedef int (*acpi_op_add) (struct acpi_device * device); +typedef int (*acpi_op_remove) (struct acpi_device * device, int type); +typedef int (*acpi_op_lock) (struct acpi_device * device, int type); +typedef int (*acpi_op_start) (struct acpi_device * device); +typedef int (*acpi_op_stop) (struct acpi_device * device, int type); +typedef int (*acpi_op_suspend) (struct acpi_device * device, int state); +typedef int (*acpi_op_resume) (struct acpi_device * device, int state); +typedef int (*acpi_op_scan) (struct acpi_device * device); +typedef int (*acpi_op_bind) (struct acpi_device * device); +typedef int (*acpi_op_unbind) (struct acpi_device * device); +typedef int (*acpi_op_match) (struct acpi_device * device, + struct acpi_driver * driver); struct acpi_bus_ops { - u32 acpi_op_add:1; - u32 acpi_op_remove:1; - u32 acpi_op_lock:1; - u32 acpi_op_start:1; - u32 acpi_op_stop:1; - u32 acpi_op_suspend:1; - u32 acpi_op_resume:1; - u32 acpi_op_scan:1; - u32 acpi_op_bind:1; - u32 acpi_op_unbind:1; - u32 acpi_op_match:1; - u32 reserved:21; + u32 acpi_op_add:1; + u32 acpi_op_remove:1; + u32 acpi_op_lock:1; + u32 acpi_op_start:1; + u32 acpi_op_stop:1; + u32 acpi_op_suspend:1; + u32 acpi_op_resume:1; + u32 acpi_op_scan:1; + u32 acpi_op_bind:1; + u32 acpi_op_unbind:1; + u32 acpi_op_match:1; + u32 reserved:21; }; struct acpi_device_ops { - acpi_op_add add; - acpi_op_remove remove; - acpi_op_lock lock; - acpi_op_start start; - acpi_op_stop stop; - acpi_op_suspend suspend; - acpi_op_resume resume; - acpi_op_scan scan; - acpi_op_bind bind; - acpi_op_unbind unbind; - acpi_op_match match; + acpi_op_add add; + acpi_op_remove remove; + acpi_op_lock lock; + acpi_op_start start; + acpi_op_stop stop; + acpi_op_suspend suspend; + acpi_op_resume resume; + acpi_op_scan scan; + acpi_op_bind bind; + acpi_op_unbind unbind; + acpi_op_match match; }; struct acpi_driver { - struct list_head node; - char name[80]; - char class[80]; - atomic_t references; - char *ids; /* Supported Hardware IDs */ - struct acpi_device_ops ops; + struct list_head node; + char name[80]; + char class[80]; + atomic_t references; + char *ids; /* Supported Hardware IDs */ + struct acpi_device_ops ops; }; /* @@ -154,60 +146,57 @@ struct acpi_driver { /* Status (_STA) */ struct acpi_device_status { - u32 present:1; - u32 enabled:1; - u32 show_in_ui:1; - u32 functional:1; - u32 battery_present:1; - u32 reserved:27; + u32 present:1; + u32 enabled:1; + u32 show_in_ui:1; + u32 functional:1; + u32 battery_present:1; + u32 reserved:27; }; - /* Flags */ struct acpi_device_flags { - u32 dynamic_status:1; - u32 hardware_id:1; - u32 compatible_ids:1; - u32 bus_address:1; - u32 unique_id:1; - u32 removable:1; - u32 ejectable:1; - u32 lockable:1; - u32 suprise_removal_ok:1; - u32 power_manageable:1; - u32 performance_manageable:1; - u32 wake_capable:1; /* Wakeup(_PRW) supported? */ - u32 reserved:20; + u32 dynamic_status:1; + u32 hardware_id:1; + u32 compatible_ids:1; + u32 bus_address:1; + u32 unique_id:1; + u32 removable:1; + u32 ejectable:1; + u32 lockable:1; + u32 suprise_removal_ok:1; + u32 power_manageable:1; + u32 performance_manageable:1; + u32 wake_capable:1; /* Wakeup(_PRW) supported? */ + u32 reserved:20; }; - /* File System */ struct acpi_device_dir { - struct proc_dir_entry *entry; + struct proc_dir_entry *entry; }; #define acpi_device_dir(d) ((d)->dir.entry) - /* Plug and Play */ -typedef char acpi_bus_id[5]; -typedef unsigned long acpi_bus_address; -typedef char acpi_hardware_id[9]; -typedef char acpi_unique_id[9]; -typedef char acpi_device_name[40]; -typedef char acpi_device_class[20]; +typedef char acpi_bus_id[5]; +typedef unsigned long acpi_bus_address; +typedef char acpi_hardware_id[9]; +typedef char acpi_unique_id[9]; +typedef char acpi_device_name[40]; +typedef char acpi_device_class[20]; struct acpi_device_pnp { - acpi_bus_id bus_id; /* Object name */ - acpi_bus_address bus_address; /* _ADR */ - acpi_hardware_id hardware_id; /* _HID */ - struct acpi_compatible_id_list *cid_list; /* _CIDs */ - acpi_unique_id unique_id; /* _UID */ - acpi_device_name device_name; /* Driver-determined */ - acpi_device_class device_class; /* " */ + acpi_bus_id bus_id; /* Object name */ + acpi_bus_address bus_address; /* _ADR */ + acpi_hardware_id hardware_id; /* _HID */ + struct acpi_compatible_id_list *cid_list; /* _CIDs */ + acpi_unique_id unique_id; /* _UID */ + acpi_device_name device_name; /* Driver-determined */ + acpi_device_class device_class; /* " */ }; #define acpi_device_bid(d) ((d)->pnp.bus_id) @@ -217,114 +206,111 @@ struct acpi_device_pnp { #define acpi_device_name(d) ((d)->pnp.device_name) #define acpi_device_class(d) ((d)->pnp.device_class) - /* Power Management */ struct acpi_device_power_flags { - u32 explicit_get:1; /* _PSC present? */ - u32 power_resources:1; /* Power resources */ - u32 inrush_current:1; /* Serialize Dx->D0 */ - u32 power_removed:1; /* Optimize Dx->D0 */ - u32 reserved:28; + u32 explicit_get:1; /* _PSC present? */ + u32 power_resources:1; /* Power resources */ + u32 inrush_current:1; /* Serialize Dx->D0 */ + u32 power_removed:1; /* Optimize Dx->D0 */ + u32 reserved:28; }; struct acpi_device_power_state { struct { - u8 valid:1; - u8 explicit_set:1; /* _PSx present? */ - u8 reserved:6; - } flags; - int power; /* % Power (compared to D0) */ - int latency; /* Dx->D0 time (microseconds) */ - struct acpi_handle_list resources; /* Power resources referenced */ + u8 valid:1; + u8 explicit_set:1; /* _PSx present? */ + u8 reserved:6; + } flags; + int power; /* % Power (compared to D0) */ + int latency; /* Dx->D0 time (microseconds) */ + struct acpi_handle_list resources; /* Power resources referenced */ }; struct acpi_device_power { - int state; /* Current state */ + int state; /* Current state */ struct acpi_device_power_flags flags; - struct acpi_device_power_state states[4]; /* Power states (D0-D3) */ + struct acpi_device_power_state states[4]; /* Power states (D0-D3) */ }; - /* Performance Management */ struct acpi_device_perf_flags { - u8 reserved:8; + u8 reserved:8; }; struct acpi_device_perf_state { struct { - u8 valid:1; - u8 reserved:7; - } flags; - u8 power; /* % Power (compared to P0) */ - u8 performance; /* % Performance ( " ) */ - int latency; /* Px->P0 time (microseconds) */ + u8 valid:1; + u8 reserved:7; + } flags; + u8 power; /* % Power (compared to P0) */ + u8 performance; /* % Performance ( " ) */ + int latency; /* Px->P0 time (microseconds) */ }; struct acpi_device_perf { - int state; + int state; struct acpi_device_perf_flags flags; - int state_count; + int state_count; struct acpi_device_perf_state *states; }; /* Wakeup Management */ struct acpi_device_wakeup_flags { - u8 valid:1; /* Can successfully enable wakeup? */ - u8 run_wake:1; /* Run-Wake GPE devices */ + u8 valid:1; /* Can successfully enable wakeup? */ + u8 run_wake:1; /* Run-Wake GPE devices */ }; struct acpi_device_wakeup_state { - u8 enabled:1; - u8 active:1; + u8 enabled:1; + u8 active:1; }; struct acpi_device_wakeup { - acpi_handle gpe_device; - acpi_integer gpe_number;; - acpi_integer sleep_state; - struct acpi_handle_list resources; - struct acpi_device_wakeup_state state; - struct acpi_device_wakeup_flags flags; + acpi_handle gpe_device; + acpi_integer gpe_number;; + acpi_integer sleep_state; + struct acpi_handle_list resources; + struct acpi_device_wakeup_state state; + struct acpi_device_wakeup_flags flags; }; /* Device */ struct acpi_device { - acpi_handle handle; - struct acpi_device *parent; - struct list_head children; - struct list_head node; - struct list_head wakeup_list; - struct list_head g_list; + acpi_handle handle; + struct acpi_device *parent; + struct list_head children; + struct list_head node; + struct list_head wakeup_list; + struct list_head g_list; struct acpi_device_status status; struct acpi_device_flags flags; - struct acpi_device_pnp pnp; + struct acpi_device_pnp pnp; struct acpi_device_power power; struct acpi_device_wakeup wakeup; - struct acpi_device_perf performance; - struct acpi_device_dir dir; - struct acpi_device_ops ops; - struct acpi_driver *driver; - void *driver_data; - struct kobject kobj; + struct acpi_device_perf performance; + struct acpi_device_dir dir; + struct acpi_device_ops ops; + struct acpi_driver *driver; + void *driver_data; + struct kobject kobj; }; #define acpi_driver_data(d) ((d)->driver_data) - /* * Events * ------ */ struct acpi_bus_event { - struct list_head node; - acpi_device_class device_class; - acpi_bus_id bus_id; - u32 type; - u32 data; + struct list_head node; + acpi_device_class device_class; + acpi_bus_id bus_id; + u32 type; + u32 data; }; extern struct subsystem acpi_subsys; @@ -335,34 +321,32 @@ extern struct subsystem acpi_subsys; int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context); -int acpi_bus_get_status (struct acpi_device *device); -int acpi_bus_get_power (acpi_handle handle, int *state); -int acpi_bus_set_power (acpi_handle handle, int state); -int acpi_bus_generate_event (struct acpi_device *device, u8 type, int data); -int acpi_bus_receive_event (struct acpi_bus_event *event); -int acpi_bus_register_driver (struct acpi_driver *driver); -int acpi_bus_unregister_driver (struct acpi_driver *driver); -int acpi_bus_add (struct acpi_device **child, struct acpi_device *parent, - acpi_handle handle, int type); -int acpi_bus_start (struct acpi_device *device); - - -int acpi_match_ids (struct acpi_device *device, char *ids); +int acpi_bus_get_status(struct acpi_device *device); +int acpi_bus_get_power(acpi_handle handle, int *state); +int acpi_bus_set_power(acpi_handle handle, int state); +int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data); +int acpi_bus_receive_event(struct acpi_bus_event *event); +int acpi_bus_register_driver(struct acpi_driver *driver); +int acpi_bus_unregister_driver(struct acpi_driver *driver); +int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, + acpi_handle handle, int type); +int acpi_bus_start(struct acpi_device *device); + +int acpi_match_ids(struct acpi_device *device, char *ids); int acpi_create_dir(struct acpi_device *); void acpi_remove_dir(struct acpi_device *); - /* * Bind physical devices with ACPI devices */ #include struct acpi_bus_type { - struct list_head list; - struct bus_type *bus; - /* For general devices under the bus*/ - int (*find_device)(struct device *, acpi_handle*); + struct list_head list; + struct bus_type *bus; + /* For general devices under the bus */ + int (*find_device) (struct device *, acpi_handle *); /* For bridges, such as PCI root bridge, IDE controller */ - int (*find_bridge)(struct device *, acpi_handle *); + int (*find_bridge) (struct device *, acpi_handle *); }; int register_acpi_bus_type(struct acpi_bus_type *); int unregister_acpi_bus_type(struct acpi_bus_type *); @@ -372,6 +356,6 @@ acpi_handle acpi_get_child(acpi_handle, acpi_integer); acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int); #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->firmware_data)) -#endif /*CONFIG_ACPI_BUS*/ +#endif /*CONFIG_ACPI_BUS */ #endif /*__ACPI_BUS_H__*/ diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h index 579fe19..e976cb1 100644 --- a/include/acpi/acpi_drivers.h +++ b/include/acpi/acpi_drivers.h @@ -29,7 +29,6 @@ #include #include - #define ACPI_MAX_STRING 80 #define ACPI_BUS_COMPONENT 0x00010000 @@ -44,7 +43,6 @@ #define ACPI_BUTTON_HID_POWERF "ACPI_FPB" #define ACPI_BUTTON_HID_SLEEPF "ACPI_FSB" - /* -------------------------------------------------------------------------- PCI -------------------------------------------------------------------------- */ @@ -55,49 +53,49 @@ /* ACPI PCI Interrupt Link (pci_link.c) */ -int acpi_irq_penalty_init (void); -int acpi_pci_link_allocate_irq (acpi_handle handle, int index, int *edge_level, - int *active_high_low, char **name); +int acpi_irq_penalty_init(void); +int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *edge_level, + int *active_high_low, char **name); int acpi_pci_link_free_irq(acpi_handle handle); /* ACPI PCI Interrupt Routing (pci_irq.c) */ -int acpi_pci_irq_add_prt (acpi_handle handle, int segment, int bus); -void acpi_pci_irq_del_prt (int segment, int bus); +int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus); +void acpi_pci_irq_del_prt(int segment, int bus); /* ACPI PCI Device Binding (pci_bind.c) */ struct pci_bus; -acpi_status acpi_get_pci_id (acpi_handle handle, struct acpi_pci_id *id); -int acpi_pci_bind (struct acpi_device *device); -int acpi_pci_unbind (struct acpi_device *device); -int acpi_pci_bind_root (struct acpi_device *device, struct acpi_pci_id *id, struct pci_bus *bus); +acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id); +int acpi_pci_bind(struct acpi_device *device); +int acpi_pci_unbind(struct acpi_device *device); +int acpi_pci_bind_root(struct acpi_device *device, struct acpi_pci_id *id, + struct pci_bus *bus); /* Arch-defined function to add a bus to the system */ -struct pci_bus *pci_acpi_scan_root(struct acpi_device *device, int domain, int bus); - -#endif /*CONFIG_ACPI_PCI*/ +struct pci_bus *pci_acpi_scan_root(struct acpi_device *device, int domain, + int bus); +#endif /*CONFIG_ACPI_PCI */ /* -------------------------------------------------------------------------- Power Resource -------------------------------------------------------------------------- */ #ifdef CONFIG_ACPI_POWER -int acpi_enable_wakeup_device_power (struct acpi_device *dev); -int acpi_disable_wakeup_device_power (struct acpi_device *dev); -int acpi_power_get_inferred_state (struct acpi_device *device); -int acpi_power_transition (struct acpi_device *device, int state); +int acpi_enable_wakeup_device_power(struct acpi_device *dev); +int acpi_disable_wakeup_device_power(struct acpi_device *dev); +int acpi_power_get_inferred_state(struct acpi_device *device); +int acpi_power_transition(struct acpi_device *device, int state); #endif - /* -------------------------------------------------------------------------- Embedded Controller -------------------------------------------------------------------------- */ #ifdef CONFIG_ACPI_EC -int acpi_ec_ecdt_probe (void); +int acpi_ec_ecdt_probe(void); #endif /* -------------------------------------------------------------------------- diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h index 819a53f..98e0b8cd 100644 --- a/include/acpi/acpiosxf.h +++ b/include/acpi/acpiosxf.h @@ -7,7 +7,6 @@ * *****************************************************************************/ - /* * Copyright (C) 2000 - 2005, R. Byron Moore * All rights reserved. @@ -51,7 +50,6 @@ #include "platform/acenv.h" #include "actypes.h" - /* Priorities for acpi_os_queue_for_execution */ #define OSD_PRIORITY_GPE 1 @@ -62,227 +60,136 @@ #define ACPI_NO_UNIT_LIMIT ((u32) -1) #define ACPI_MUTEX_SEM 1 - /* Functions for acpi_os_signal */ #define ACPI_SIGNAL_FATAL 0 #define ACPI_SIGNAL_BREAKPOINT 1 -struct acpi_signal_fatal_info -{ - u32 type; - u32 code; - u32 argument; +struct acpi_signal_fatal_info { + u32 type; + u32 code; + u32 argument; }; - /* * OSL Initialization and shutdown primitives */ -acpi_status -acpi_os_initialize ( - void); - -acpi_status -acpi_os_terminate ( - void); +acpi_status acpi_os_initialize(void); +acpi_status acpi_os_terminate(void); /* * ACPI Table interfaces */ -acpi_status -acpi_os_get_root_pointer ( - u32 flags, - struct acpi_pointer *address); +acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *address); acpi_status -acpi_os_predefined_override ( - const struct acpi_predefined_names *init_val, - acpi_string *new_val); +acpi_os_predefined_override(const struct acpi_predefined_names *init_val, + acpi_string * new_val); acpi_status -acpi_os_table_override ( - struct acpi_table_header *existing_table, - struct acpi_table_header **new_table); - +acpi_os_table_override(struct acpi_table_header *existing_table, + struct acpi_table_header **new_table); /* * Synchronization primitives */ acpi_status -acpi_os_create_semaphore ( - u32 max_units, - u32 initial_units, - acpi_handle *out_handle); - -acpi_status -acpi_os_delete_semaphore ( - acpi_handle handle); +acpi_os_create_semaphore(u32 max_units, + u32 initial_units, acpi_handle * out_handle); -acpi_status -acpi_os_wait_semaphore ( - acpi_handle handle, - u32 units, - u16 timeout); +acpi_status acpi_os_delete_semaphore(acpi_handle handle); -acpi_status -acpi_os_signal_semaphore ( - acpi_handle handle, - u32 units); +acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout); -acpi_status -acpi_os_create_lock ( - acpi_handle *out_handle); +acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units); -void -acpi_os_delete_lock ( - acpi_handle handle); +acpi_status acpi_os_create_lock(acpi_handle * out_handle); -unsigned long -acpi_os_acquire_lock ( - acpi_handle handle); +void acpi_os_delete_lock(acpi_handle handle); -void -acpi_os_release_lock ( - acpi_handle handle, - unsigned long flags); +unsigned long acpi_os_acquire_lock(acpi_handle handle); +void acpi_os_release_lock(acpi_handle handle, unsigned long flags); /* * Memory allocation and mapping */ -void * -acpi_os_allocate ( - acpi_size size); +void *acpi_os_allocate(acpi_size size); -void -acpi_os_free ( - void * memory); +void acpi_os_free(void *memory); acpi_status -acpi_os_map_memory ( - acpi_physical_address physical_address, - acpi_size size, - void __iomem **logical_address); +acpi_os_map_memory(acpi_physical_address physical_address, + acpi_size size, void __iomem ** logical_address); -void -acpi_os_unmap_memory ( - void __iomem *logical_address, - acpi_size size); +void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size); #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_os_get_physical_address ( - void *logical_address, - acpi_physical_address *physical_address); +acpi_os_get_physical_address(void *logical_address, + acpi_physical_address * physical_address); #endif - - /* * Memory/Object Cache */ acpi_status -acpi_os_create_cache ( - char *cache_name, - u16 object_size, - u16 max_depth, - acpi_cache_t **return_cache); +acpi_os_create_cache(char *cache_name, + u16 object_size, + u16 max_depth, acpi_cache_t ** return_cache); -acpi_status -acpi_os_delete_cache ( - acpi_cache_t *cache); +acpi_status acpi_os_delete_cache(acpi_cache_t * cache); -acpi_status -acpi_os_purge_cache ( - acpi_cache_t *cache); +acpi_status acpi_os_purge_cache(acpi_cache_t * cache); -void * -acpi_os_acquire_object ( - acpi_cache_t *cache); +void *acpi_os_acquire_object(acpi_cache_t * cache); -acpi_status -acpi_os_release_object ( - acpi_cache_t *cache, - void *object); +acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object); /* * Interrupt handlers */ acpi_status -acpi_os_install_interrupt_handler ( - u32 gsi, - acpi_osd_handler service_routine, - void *context); +acpi_os_install_interrupt_handler(u32 gsi, + acpi_osd_handler service_routine, + void *context); acpi_status -acpi_os_remove_interrupt_handler ( - u32 gsi, - acpi_osd_handler service_routine); - +acpi_os_remove_interrupt_handler(u32 gsi, acpi_osd_handler service_routine); /* * Threads and Scheduling */ -u32 -acpi_os_get_thread_id ( - void); +u32 acpi_os_get_thread_id(void); acpi_status -acpi_os_queue_for_execution ( - u32 priority, - acpi_osd_exec_callback function, - void *context); - -void -acpi_os_wait_events_complete( - void * context); +acpi_os_queue_for_execution(u32 priority, + acpi_osd_exec_callback function, void *context); -void -acpi_os_wait_events_complete ( - void *context); +void acpi_os_wait_events_complete(void *context); -void -acpi_os_sleep ( - acpi_integer milliseconds); +void acpi_os_wait_events_complete(void *context); -void -acpi_os_stall ( - u32 microseconds); +void acpi_os_sleep(acpi_integer milliseconds); +void acpi_os_stall(u32 microseconds); /* * Platform and hardware-independent I/O interfaces */ -acpi_status -acpi_os_read_port ( - acpi_io_address address, - u32 *value, - u32 width); - -acpi_status -acpi_os_write_port ( - acpi_io_address address, - u32 value, - u32 width); +acpi_status acpi_os_read_port(acpi_io_address address, u32 * value, u32 width); +acpi_status acpi_os_write_port(acpi_io_address address, u32 value, u32 width); /* * Platform and hardware-independent physical memory interfaces */ acpi_status -acpi_os_read_memory ( - acpi_physical_address address, - u32 *value, - u32 width); +acpi_os_read_memory(acpi_physical_address address, u32 * value, u32 width); acpi_status -acpi_os_write_memory ( - acpi_physical_address address, - u32 value, - u32 width); - +acpi_os_write_memory(acpi_physical_address address, u32 value, u32 width); /* * Platform and hardware-independent PCI configuration space access @@ -290,111 +197,69 @@ acpi_os_write_memory ( * certain compilers complain. */ acpi_status -acpi_os_read_pci_configuration ( - struct acpi_pci_id *pci_id, - u32 reg, - void *value, - u32 width); +acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id, + u32 reg, void *value, u32 width); acpi_status -acpi_os_write_pci_configuration ( - struct acpi_pci_id *pci_id, - u32 reg, - acpi_integer value, - u32 width); +acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id, + u32 reg, acpi_integer value, u32 width); /* * Interim function needed for PCI IRQ routing */ void -acpi_os_derive_pci_id( - acpi_handle rhandle, - acpi_handle chandle, - struct acpi_pci_id **pci_id); +acpi_os_derive_pci_id(acpi_handle rhandle, + acpi_handle chandle, struct acpi_pci_id **pci_id); /* * Miscellaneous */ -u8 -acpi_os_readable ( - void *pointer, - acpi_size length); +u8 acpi_os_readable(void *pointer, acpi_size length); #ifdef ACPI_FUTURE_USAGE -u8 -acpi_os_writable ( - void *pointer, - acpi_size length); +u8 acpi_os_writable(void *pointer, acpi_size length); #endif -u64 -acpi_os_get_timer ( - void); +u64 acpi_os_get_timer(void); -acpi_status -acpi_os_signal ( - u32 function, - void *info); +acpi_status acpi_os_signal(u32 function, void *info); /* * Debug print routines */ -void ACPI_INTERNAL_VAR_XFACE -acpi_os_printf ( - const char *format, - ...); - -void -acpi_os_vprintf ( - const char *format, - va_list args); +void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *format, ...); -void -acpi_os_redirect_output ( - void *destination); +void acpi_os_vprintf(const char *format, va_list args); +void acpi_os_redirect_output(void *destination); #ifdef ACPI_FUTURE_USAGE /* * Debug input */ -u32 -acpi_os_get_line ( - char *buffer); +u32 acpi_os_get_line(char *buffer); #endif - /* * Directory manipulation */ -void * -acpi_os_open_directory ( - char *pathname, - char *wildcard_spec, - char requested_file_type); +void *acpi_os_open_directory(char *pathname, + char *wildcard_spec, char requested_file_type); /* requeste_file_type values */ #define REQUEST_FILE_ONLY 0 #define REQUEST_DIR_ONLY 1 +char *acpi_os_get_next_filename(void *dir_handle); -char * -acpi_os_get_next_filename ( - void *dir_handle); - -void -acpi_os_close_directory ( - void *dir_handle); +void acpi_os_close_directory(void *dir_handle); /* * Debug */ void -acpi_os_dbg_assert( - void *failed_assertion, - void *file_name, - u32 line_number, - char *message); +acpi_os_dbg_assert(void *failed_assertion, + void *file_name, u32 line_number, char *message); -#endif /* __ACPIOSXF_H__ */ +#endif /* __ACPIOSXF_H__ */ diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 9ca212d..2a9dbc1 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -42,447 +42,283 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ACXFACE_H__ #define __ACXFACE_H__ #include "actypes.h" #include "actbl.h" - /* * Global interfaces */ -acpi_status -acpi_initialize_subsystem ( - void); +acpi_status acpi_initialize_subsystem(void); -acpi_status -acpi_enable_subsystem ( - u32 flags); +acpi_status acpi_enable_subsystem(u32 flags); -acpi_status -acpi_initialize_objects ( - u32 flags); +acpi_status acpi_initialize_objects(u32 flags); -acpi_status -acpi_terminate ( - void); +acpi_status acpi_terminate(void); #ifdef ACPI_FUTURE_USAGE -acpi_status -acpi_subsystem_status ( - void); +acpi_status acpi_subsystem_status(void); #endif -acpi_status -acpi_enable ( - void); +acpi_status acpi_enable(void); -acpi_status -acpi_disable ( - void); +acpi_status acpi_disable(void); #ifdef ACPI_FUTURE_USAGE -acpi_status -acpi_get_system_info ( - struct acpi_buffer *ret_buffer); +acpi_status acpi_get_system_info(struct acpi_buffer *ret_buffer); #endif -const char * -acpi_format_exception ( - acpi_status exception); +const char *acpi_format_exception(acpi_status exception); -acpi_status -acpi_purge_cached_objects ( - void); +acpi_status acpi_purge_cached_objects(void); #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_install_initialization_handler ( - acpi_init_handler handler, - u32 function); +acpi_install_initialization_handler(acpi_init_handler handler, u32 function); #endif /* * ACPI Memory managment */ -void * -acpi_allocate ( - u32 size); - -void * -acpi_callocate ( - u32 size); +void *acpi_allocate(u32 size); -void -acpi_free ( - void *address); +void *acpi_callocate(u32 size); +void acpi_free(void *address); /* * ACPI table manipulation interfaces */ acpi_status -acpi_find_root_pointer ( - u32 flags, - struct acpi_pointer *rsdp_address); +acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address); -acpi_status -acpi_load_tables ( - void); +acpi_status acpi_load_tables(void); #ifdef ACPI_FUTURE_USAGE -acpi_status -acpi_load_table ( - struct acpi_table_header *table_ptr); +acpi_status acpi_load_table(struct acpi_table_header *table_ptr); -acpi_status -acpi_unload_table ( - acpi_table_type table_type); +acpi_status acpi_unload_table(acpi_table_type table_type); acpi_status -acpi_get_table_header ( - acpi_table_type table_type, - u32 instance, - struct acpi_table_header *out_table_header); -#endif /* ACPI_FUTURE_USAGE */ +acpi_get_table_header(acpi_table_type table_type, + u32 instance, struct acpi_table_header *out_table_header); +#endif /* ACPI_FUTURE_USAGE */ acpi_status -acpi_get_table ( - acpi_table_type table_type, - u32 instance, - struct acpi_buffer *ret_buffer); +acpi_get_table(acpi_table_type table_type, + u32 instance, struct acpi_buffer *ret_buffer); acpi_status -acpi_get_firmware_table ( - acpi_string signature, - u32 instance, - u32 flags, - struct acpi_table_header **table_pointer); - +acpi_get_firmware_table(acpi_string signature, + u32 instance, + u32 flags, struct acpi_table_header **table_pointer); /* * Namespace and name interfaces */ acpi_status -acpi_walk_namespace ( - acpi_object_type type, - acpi_handle start_object, - u32 max_depth, - acpi_walk_callback user_function, - void *context, - void **return_value); +acpi_walk_namespace(acpi_object_type type, + acpi_handle start_object, + u32 max_depth, + acpi_walk_callback user_function, + void *context, void **return_value); acpi_status -acpi_get_devices ( - char *HID, - acpi_walk_callback user_function, - void *context, - void **return_value); +acpi_get_devices(char *HID, + acpi_walk_callback user_function, + void *context, void **return_value); acpi_status -acpi_get_name ( - acpi_handle handle, - u32 name_type, - struct acpi_buffer *ret_path_ptr); +acpi_get_name(acpi_handle handle, + u32 name_type, struct acpi_buffer *ret_path_ptr); acpi_status -acpi_get_handle ( - acpi_handle parent, - acpi_string pathname, - acpi_handle *ret_handle); +acpi_get_handle(acpi_handle parent, + acpi_string pathname, acpi_handle * ret_handle); acpi_status -acpi_attach_data ( - acpi_handle obj_handle, - acpi_object_handler handler, - void *data); +acpi_attach_data(acpi_handle obj_handle, + acpi_object_handler handler, void *data); acpi_status -acpi_detach_data ( - acpi_handle obj_handle, - acpi_object_handler handler); +acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler); acpi_status -acpi_get_data ( - acpi_handle obj_handle, - acpi_object_handler handler, - void **data); - +acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data); /* * Object manipulation and enumeration */ acpi_status -acpi_evaluate_object ( - acpi_handle object, - acpi_string pathname, - struct acpi_object_list *parameter_objects, - struct acpi_buffer *return_object_buffer); +acpi_evaluate_object(acpi_handle object, + acpi_string pathname, + struct acpi_object_list *parameter_objects, + struct acpi_buffer *return_object_buffer); #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_evaluate_object_typed ( - acpi_handle object, - acpi_string pathname, - struct acpi_object_list *external_params, - struct acpi_buffer *return_buffer, - acpi_object_type return_type); +acpi_evaluate_object_typed(acpi_handle object, + acpi_string pathname, + struct acpi_object_list *external_params, + struct acpi_buffer *return_buffer, + acpi_object_type return_type); #endif acpi_status -acpi_get_object_info ( - acpi_handle handle, - struct acpi_buffer *return_buffer); +acpi_get_object_info(acpi_handle handle, struct acpi_buffer *return_buffer); acpi_status -acpi_get_next_object ( - acpi_object_type type, - acpi_handle parent, - acpi_handle child, - acpi_handle *out_handle); +acpi_get_next_object(acpi_object_type type, + acpi_handle parent, + acpi_handle child, acpi_handle * out_handle); -acpi_status -acpi_get_type ( - acpi_handle object, - acpi_object_type *out_type); - -acpi_status -acpi_get_parent ( - acpi_handle object, - acpi_handle *out_handle); +acpi_status acpi_get_type(acpi_handle object, acpi_object_type * out_type); +acpi_status acpi_get_parent(acpi_handle object, acpi_handle * out_handle); /* * Event handler interfaces */ acpi_status -acpi_install_fixed_event_handler ( - u32 acpi_event, - acpi_event_handler handler, - void *context); +acpi_install_fixed_event_handler(u32 acpi_event, + acpi_event_handler handler, void *context); acpi_status -acpi_remove_fixed_event_handler ( - u32 acpi_event, - acpi_event_handler handler); +acpi_remove_fixed_event_handler(u32 acpi_event, acpi_event_handler handler); acpi_status -acpi_install_notify_handler ( - acpi_handle device, - u32 handler_type, - acpi_notify_handler handler, - void *context); +acpi_install_notify_handler(acpi_handle device, + u32 handler_type, + acpi_notify_handler handler, void *context); acpi_status -acpi_remove_notify_handler ( - acpi_handle device, - u32 handler_type, - acpi_notify_handler handler); +acpi_remove_notify_handler(acpi_handle device, + u32 handler_type, acpi_notify_handler handler); acpi_status -acpi_install_address_space_handler ( - acpi_handle device, - acpi_adr_space_type space_id, - acpi_adr_space_handler handler, - acpi_adr_space_setup setup, - void *context); +acpi_install_address_space_handler(acpi_handle device, + acpi_adr_space_type space_id, + acpi_adr_space_handler handler, + acpi_adr_space_setup setup, void *context); acpi_status -acpi_remove_address_space_handler ( - acpi_handle device, - acpi_adr_space_type space_id, - acpi_adr_space_handler handler); +acpi_remove_address_space_handler(acpi_handle device, + acpi_adr_space_type space_id, + acpi_adr_space_handler handler); acpi_status -acpi_install_gpe_handler ( - acpi_handle gpe_device, - u32 gpe_number, - u32 type, - acpi_event_handler address, - void *context); +acpi_install_gpe_handler(acpi_handle gpe_device, + u32 gpe_number, + u32 type, acpi_event_handler address, void *context); #ifdef ACPI_FUTURE_USAGE -acpi_status -acpi_install_exception_handler ( - acpi_exception_handler handler); +acpi_status acpi_install_exception_handler(acpi_exception_handler handler); #endif - /* * Event interfaces */ -acpi_status -acpi_acquire_global_lock ( - u16 timeout, - u32 *handle); +acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle); -acpi_status -acpi_release_global_lock ( - u32 handle); +acpi_status acpi_release_global_lock(u32 handle); acpi_status -acpi_remove_gpe_handler ( - acpi_handle gpe_device, - u32 gpe_number, - acpi_event_handler address); +acpi_remove_gpe_handler(acpi_handle gpe_device, + u32 gpe_number, acpi_event_handler address); -acpi_status -acpi_enable_event ( - u32 event, - u32 flags); +acpi_status acpi_enable_event(u32 event, u32 flags); -acpi_status -acpi_disable_event ( - u32 event, - u32 flags); +acpi_status acpi_disable_event(u32 event, u32 flags); -acpi_status -acpi_clear_event ( - u32 event); +acpi_status acpi_clear_event(u32 event); #ifdef ACPI_FUTURE_USAGE -acpi_status -acpi_get_event_status ( - u32 event, - acpi_event_status *event_status); -#endif /* ACPI_FUTURE_USAGE */ +acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status); +#endif /* ACPI_FUTURE_USAGE */ -acpi_status -acpi_set_gpe_type ( - acpi_handle gpe_device, - u32 gpe_number, - u8 type); +acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type); -acpi_status -acpi_enable_gpe ( - acpi_handle gpe_device, - u32 gpe_number, - u32 flags); +acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags); -acpi_status -acpi_disable_gpe ( - acpi_handle gpe_device, - u32 gpe_number, - u32 flags); +acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags); -acpi_status -acpi_clear_gpe ( - acpi_handle gpe_device, - u32 gpe_number, - u32 flags); +acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags); #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_get_gpe_status ( - acpi_handle gpe_device, - u32 gpe_number, - u32 flags, - acpi_event_status *event_status); -#endif /* ACPI_FUTURE_USAGE */ +acpi_get_gpe_status(acpi_handle gpe_device, + u32 gpe_number, + u32 flags, acpi_event_status * event_status); +#endif /* ACPI_FUTURE_USAGE */ acpi_status -acpi_install_gpe_block ( - acpi_handle gpe_device, - struct acpi_generic_address *gpe_block_address, - u32 register_count, - u32 interrupt_number); - -acpi_status -acpi_remove_gpe_block ( - acpi_handle gpe_device); +acpi_install_gpe_block(acpi_handle gpe_device, + struct acpi_generic_address *gpe_block_address, + u32 register_count, u32 interrupt_number); +acpi_status acpi_remove_gpe_block(acpi_handle gpe_device); /* * Resource interfaces */ typedef -acpi_status (*ACPI_WALK_RESOURCE_CALLBACK) ( - struct acpi_resource *resource, - void *context); - +acpi_status(*ACPI_WALK_RESOURCE_CALLBACK) (struct acpi_resource * resource, + void *context); acpi_status -acpi_get_current_resources( - acpi_handle device_handle, - struct acpi_buffer *ret_buffer); +acpi_get_current_resources(acpi_handle device_handle, + struct acpi_buffer *ret_buffer); #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_get_possible_resources( - acpi_handle device_handle, - struct acpi_buffer *ret_buffer); +acpi_get_possible_resources(acpi_handle device_handle, + struct acpi_buffer *ret_buffer); #endif acpi_status -acpi_walk_resources ( - acpi_handle device_handle, - char *path, - ACPI_WALK_RESOURCE_CALLBACK user_function, - void *context); +acpi_walk_resources(acpi_handle device_handle, + char *path, + ACPI_WALK_RESOURCE_CALLBACK user_function, void *context); acpi_status -acpi_set_current_resources ( - acpi_handle device_handle, - struct acpi_buffer *in_buffer); +acpi_set_current_resources(acpi_handle device_handle, + struct acpi_buffer *in_buffer); acpi_status -acpi_get_irq_routing_table ( - acpi_handle bus_device_handle, - struct acpi_buffer *ret_buffer); +acpi_get_irq_routing_table(acpi_handle bus_device_handle, + struct acpi_buffer *ret_buffer); acpi_status -acpi_resource_to_address64 ( - struct acpi_resource *resource, - struct acpi_resource_address64 *out); +acpi_resource_to_address64(struct acpi_resource *resource, + struct acpi_resource_address64 *out); /* * Hardware (ACPI device) interfaces */ -acpi_status -acpi_get_register ( - u32 register_id, - u32 *return_value, - u32 flags); +acpi_status acpi_get_register(u32 register_id, u32 * return_value, u32 flags); -acpi_status -acpi_set_register ( - u32 register_id, - u32 value, - u32 flags); +acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags); acpi_status -acpi_set_firmware_waking_vector ( - acpi_physical_address physical_address); +acpi_set_firmware_waking_vector(acpi_physical_address physical_address); #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_get_firmware_waking_vector ( - acpi_physical_address *physical_address); +acpi_get_firmware_waking_vector(acpi_physical_address * physical_address); #endif acpi_status -acpi_get_sleep_type_data ( - u8 sleep_state, - u8 *slp_typ_a, - u8 *slp_typ_b); +acpi_get_sleep_type_data(u8 sleep_state, u8 * slp_typ_a, u8 * slp_typ_b); -acpi_status -acpi_enter_sleep_state_prep ( - u8 sleep_state); +acpi_status acpi_enter_sleep_state_prep(u8 sleep_state); -acpi_status asmlinkage -acpi_enter_sleep_state ( - u8 sleep_state); +acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state); -acpi_status asmlinkage -acpi_enter_sleep_state_s4bios ( - void); - -acpi_status -acpi_leave_sleep_state ( - u8 sleep_state); +acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void); +acpi_status acpi_leave_sleep_state(u8 sleep_state); -#endif /* __ACXFACE_H__ */ +#endif /* __ACXFACE_H__ */ diff --git a/include/acpi/acresrc.h b/include/acpi/acresrc.h index ed67926..38e798b 100644 --- a/include/acpi/acresrc.h +++ b/include/acpi/acresrc.h @@ -44,303 +44,216 @@ #ifndef __ACRESRC_H__ #define __ACRESRC_H__ - /* * Function prototypes called from Acpi* APIs */ acpi_status -acpi_rs_get_prt_method_data ( - acpi_handle handle, - struct acpi_buffer *ret_buffer); - +acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer); acpi_status -acpi_rs_get_crs_method_data ( - acpi_handle handle, - struct acpi_buffer *ret_buffer); +acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer); #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_rs_get_prs_method_data ( - acpi_handle handle, - struct acpi_buffer *ret_buffer); -#endif /* ACPI_FUTURE_USAGE */ +acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer); +#endif /* ACPI_FUTURE_USAGE */ acpi_status -acpi_rs_get_method_data ( - acpi_handle handle, - char *path, - struct acpi_buffer *ret_buffer); +acpi_rs_get_method_data(acpi_handle handle, + char *path, struct acpi_buffer *ret_buffer); acpi_status -acpi_rs_set_srs_method_data ( - acpi_handle handle, - struct acpi_buffer *ret_buffer); +acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer); acpi_status -acpi_rs_create_resource_list ( - union acpi_operand_object *byte_stream_buffer, - struct acpi_buffer *output_buffer); +acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, + struct acpi_buffer *output_buffer); acpi_status -acpi_rs_create_byte_stream ( - struct acpi_resource *linked_list_buffer, - struct acpi_buffer *output_buffer); +acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, + struct acpi_buffer *output_buffer); acpi_status -acpi_rs_create_pci_routing_table ( - union acpi_operand_object *package_object, - struct acpi_buffer *output_buffer); - +acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, + struct acpi_buffer *output_buffer); /* * rsdump */ #ifdef ACPI_FUTURE_USAGE -void -acpi_rs_dump_resource_list ( - struct acpi_resource *resource); - -void -acpi_rs_dump_irq_list ( - u8 *route_table); -#endif /* ACPI_FUTURE_USAGE */ +void acpi_rs_dump_resource_list(struct acpi_resource *resource); +void acpi_rs_dump_irq_list(u8 * route_table); +#endif /* ACPI_FUTURE_USAGE */ /* * rscalc */ acpi_status -acpi_rs_get_byte_stream_start ( - u8 *byte_stream_buffer, - u8 **byte_stream_start, - u32 *size); +acpi_rs_get_byte_stream_start(u8 * byte_stream_buffer, + u8 ** byte_stream_start, u32 * size); acpi_status -acpi_rs_get_list_length ( - u8 *byte_stream_buffer, - u32 byte_stream_buffer_length, - acpi_size *size_needed); +acpi_rs_get_list_length(u8 * byte_stream_buffer, + u32 byte_stream_buffer_length, acpi_size * size_needed); acpi_status -acpi_rs_get_byte_stream_length ( - struct acpi_resource *linked_list_buffer, - acpi_size *size_needed); +acpi_rs_get_byte_stream_length(struct acpi_resource *linked_list_buffer, + acpi_size * size_needed); acpi_status -acpi_rs_get_pci_routing_table_length ( - union acpi_operand_object *package_object, - acpi_size *buffer_size_needed); +acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, + acpi_size * buffer_size_needed); acpi_status -acpi_rs_byte_stream_to_list ( - u8 *byte_stream_buffer, - u32 byte_stream_buffer_length, - u8 *output_buffer); +acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, + u32 byte_stream_buffer_length, u8 * output_buffer); acpi_status -acpi_rs_list_to_byte_stream ( - struct acpi_resource *linked_list, - acpi_size byte_stream_size_needed, - u8 *output_buffer); +acpi_rs_list_to_byte_stream(struct acpi_resource *linked_list, + acpi_size byte_stream_size_needed, + u8 * output_buffer); acpi_status -acpi_rs_io_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_io_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_fixed_io_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_io_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_io_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_fixed_io_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_fixed_io_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_irq_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_irq_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_irq_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_irq_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_dma_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_dma_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_dma_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_dma_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_address16_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_address16_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_address16_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_address16_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_address32_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_address32_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_address32_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_address32_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_address64_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_address64_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_address64_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_address64_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_start_depend_fns_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, + acpi_size * structure_size); acpi_status -acpi_rs_end_depend_fns_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, + acpi_size * structure_size); acpi_status -acpi_rs_start_depend_fns_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, + acpi_size * bytes_consumed); acpi_status -acpi_rs_end_depend_fns_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_end_depend_fns_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_memory24_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_memory24_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_memory24_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_memory24_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_memory32_range_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, + acpi_size * structure_size); acpi_status -acpi_rs_fixed_memory32_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, + acpi_size * structure_size); acpi_status -acpi_rs_memory32_range_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_memory32_range_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_fixed_memory32_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_fixed_memory32_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_extended_irq_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_extended_irq_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_extended_irq_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_end_tag_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_end_tag_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_end_tag_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_end_tag_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_vendor_resource ( - u8 *byte_stream_buffer, - acpi_size *bytes_consumed, - u8 **output_buffer, - acpi_size *structure_size); +acpi_rs_vendor_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_vendor_stream ( - struct acpi_resource *linked_list, - u8 **output_buffer, - acpi_size *bytes_consumed); +acpi_rs_vendor_stream(struct acpi_resource *linked_list, + u8 ** output_buffer, acpi_size * bytes_consumed); -u8 -acpi_rs_get_resource_type ( - u8 resource_start_byte); +u8 acpi_rs_get_resource_type(u8 resource_start_byte); -#endif /* __ACRESRC_H__ */ +#endif /* __ACRESRC_H__ */ diff --git a/include/acpi/acstruct.h b/include/acpi/acstruct.h index 27b22bb..99d2353 100644 --- a/include/acpi/acstruct.h +++ b/include/acpi/acstruct.h @@ -44,14 +44,12 @@ #ifndef __ACSTRUCT_H__ #define __ACSTRUCT_H__ - /***************************************************************************** * * Tree walking typedefs and structs * ****************************************************************************/ - /* * Walk state - current state of a parse tree walk. Used for both a leisurely stroll through * the tree (for whatever reason), and for control method execution. @@ -65,97 +63,90 @@ #define ACPI_WALK_CONST_REQUIRED 3 #define ACPI_WALK_CONST_OPTIONAL 4 -struct acpi_walk_state -{ - u8 data_type; /* To differentiate various internal objs MUST BE FIRST!*/\ - u8 walk_type; - acpi_owner_id owner_id; /* Owner of objects created during the walk */ - u8 last_predicate; /* Result of last predicate */ - u8 current_result; /* */ - u8 next_op_info; /* Info about next_op */ - u8 num_operands; /* Stack pointer for Operands[] array */ - u8 return_used; - u16 opcode; /* Current AML opcode */ - u8 scope_depth; - u8 pass_number; /* Parse pass during table load */ - u32 arg_count; /* push for fixed or var args */ - u32 aml_offset; - u32 arg_types; - u32 method_breakpoint; /* For single stepping */ - u32 user_breakpoint; /* User AML breakpoint */ - u32 parse_flags; - u32 prev_arg_types; - - u8 *aml_last_while; - struct acpi_namespace_node arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */ - union acpi_operand_object **caller_return_desc; - union acpi_generic_state *control_state; /* List of control states (nested IFs) */ - struct acpi_namespace_node *deferred_node; /* Used when executing deferred opcodes */ - struct acpi_gpe_event_info *gpe_event_info; /* Info for GPE (_Lxx/_Exx methods only */ - union acpi_operand_object *implicit_return_obj; - struct acpi_namespace_node local_variables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ - struct acpi_namespace_node *method_call_node; /* Called method Node*/ - union acpi_parse_object *method_call_op; /* method_call Op if running a method */ - union acpi_operand_object *method_desc; /* Method descriptor if running a method */ - struct acpi_namespace_node *method_node; /* Method node if running a method. */ - union acpi_parse_object *op; /* Current parser op */ - union acpi_operand_object *operands[ACPI_OBJ_NUM_OPERANDS+1]; /* Operands passed to the interpreter (+1 for NULL terminator) */ - const struct acpi_opcode_info *op_info; /* Info on current opcode */ - union acpi_parse_object *origin; /* Start of walk [Obsolete] */ - union acpi_operand_object **params; - struct acpi_parse_state parser_state; /* Current state of parser */ - union acpi_operand_object *result_obj; - union acpi_generic_state *results; /* Stack of accumulated results */ - union acpi_operand_object *return_desc; /* Return object, if any */ - union acpi_generic_state *scope_info; /* Stack of nested scopes */ - - union acpi_parse_object *prev_op; /* Last op that was processed */ - union acpi_parse_object *next_op; /* next op to be processed */ - acpi_parse_downwards descending_callback; - acpi_parse_upwards ascending_callback; - struct acpi_thread_state *thread; - struct acpi_walk_state *next; /* Next walk_state in list */ +struct acpi_walk_state { + u8 data_type; /* To differentiate various internal objs MUST BE FIRST! */ + u8 walk_type; + acpi_owner_id owner_id; /* Owner of objects created during the walk */ + u8 last_predicate; /* Result of last predicate */ + u8 current_result; /* */ + u8 next_op_info; /* Info about next_op */ + u8 num_operands; /* Stack pointer for Operands[] array */ + u8 return_used; + u16 opcode; /* Current AML opcode */ + u8 scope_depth; + u8 pass_number; /* Parse pass during table load */ + u32 arg_count; /* push for fixed or var args */ + u32 aml_offset; + u32 arg_types; + u32 method_breakpoint; /* For single stepping */ + u32 user_breakpoint; /* User AML breakpoint */ + u32 parse_flags; + u32 prev_arg_types; + + u8 *aml_last_while; + struct acpi_namespace_node arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */ + union acpi_operand_object **caller_return_desc; + union acpi_generic_state *control_state; /* List of control states (nested IFs) */ + struct acpi_namespace_node *deferred_node; /* Used when executing deferred opcodes */ + struct acpi_gpe_event_info *gpe_event_info; /* Info for GPE (_Lxx/_Exx methods only */ + union acpi_operand_object *implicit_return_obj; + struct acpi_namespace_node local_variables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ + struct acpi_namespace_node *method_call_node; /* Called method Node */ + union acpi_parse_object *method_call_op; /* method_call Op if running a method */ + union acpi_operand_object *method_desc; /* Method descriptor if running a method */ + struct acpi_namespace_node *method_node; /* Method node if running a method. */ + union acpi_parse_object *op; /* Current parser op */ + union acpi_operand_object *operands[ACPI_OBJ_NUM_OPERANDS + 1]; /* Operands passed to the interpreter (+1 for NULL terminator) */ + const struct acpi_opcode_info *op_info; /* Info on current opcode */ + union acpi_parse_object *origin; /* Start of walk [Obsolete] */ + union acpi_operand_object **params; + struct acpi_parse_state parser_state; /* Current state of parser */ + union acpi_operand_object *result_obj; + union acpi_generic_state *results; /* Stack of accumulated results */ + union acpi_operand_object *return_desc; /* Return object, if any */ + union acpi_generic_state *scope_info; /* Stack of nested scopes */ + + union acpi_parse_object *prev_op; /* Last op that was processed */ + union acpi_parse_object *next_op; /* next op to be processed */ + acpi_parse_downwards descending_callback; + acpi_parse_upwards ascending_callback; + struct acpi_thread_state *thread; + struct acpi_walk_state *next; /* Next walk_state in list */ }; - /* Info used by acpi_ps_init_objects */ -struct acpi_init_walk_info -{ - u16 method_count; - u16 device_count; - u16 op_region_count; - u16 field_count; - u16 buffer_count; - u16 package_count; - u16 op_region_init; - u16 field_init; - u16 buffer_init; - u16 package_init; - u16 object_count; - struct acpi_table_desc *table_desc; +struct acpi_init_walk_info { + u16 method_count; + u16 device_count; + u16 op_region_count; + u16 field_count; + u16 buffer_count; + u16 package_count; + u16 op_region_init; + u16 field_init; + u16 buffer_init; + u16 package_init; + u16 object_count; + struct acpi_table_desc *table_desc; }; - /* Info used by acpi_ns_initialize_devices */ -struct acpi_device_walk_info -{ - u16 device_count; - u16 num_STA; - u16 num_INI; - struct acpi_table_desc *table_desc; +struct acpi_device_walk_info { + u16 device_count; + u16 num_STA; + u16 num_INI; + struct acpi_table_desc *table_desc; }; - /* TBD: [Restructure] Merge with struct above */ -struct acpi_walk_info -{ - u32 debug_level; - u32 count; - acpi_owner_id owner_id; - u8 display_type; +struct acpi_walk_info { + u32 debug_level; + u32 count; + acpi_owner_id owner_id; + u8 display_type; }; /* Display Types */ @@ -166,56 +157,48 @@ struct acpi_walk_info #define ACPI_DISPLAY_SHORT (u8) 2 -struct acpi_get_devices_info -{ - acpi_walk_callback user_function; - void *context; - char *hid; +struct acpi_get_devices_info { + acpi_walk_callback user_function; + void *context; + char *hid; }; +union acpi_aml_operands { + union acpi_operand_object *operands[7]; -union acpi_aml_operands -{ - union acpi_operand_object *operands[7]; - - struct - { - struct acpi_object_integer *type; - struct acpi_object_integer *code; - struct acpi_object_integer *argument; + struct { + struct acpi_object_integer *type; + struct acpi_object_integer *code; + struct acpi_object_integer *argument; } fatal; - struct - { - union acpi_operand_object *source; - struct acpi_object_integer *index; - union acpi_operand_object *target; + struct { + union acpi_operand_object *source; + struct acpi_object_integer *index; + union acpi_operand_object *target; } index; - struct - { - union acpi_operand_object *source; - struct acpi_object_integer *index; - struct acpi_object_integer *length; - union acpi_operand_object *target; + struct { + union acpi_operand_object *source; + struct acpi_object_integer *index; + struct acpi_object_integer *length; + union acpi_operand_object *target; } mid; }; - /* Internal method parameter list */ -struct acpi_parameter_info -{ - struct acpi_namespace_node *node; - union acpi_operand_object *obj_desc; - union acpi_operand_object **parameters; - union acpi_operand_object *return_object; - u8 pass_number; - u8 parameter_type; - u8 return_object_type; +struct acpi_parameter_info { + struct acpi_namespace_node *node; + union acpi_operand_object *obj_desc; + union acpi_operand_object **parameters; + union acpi_operand_object *return_object; + u8 pass_number; + u8 parameter_type; + u8 return_object_type; }; /* Types for parameter_type above */ @@ -223,5 +206,4 @@ struct acpi_parameter_info #define ACPI_PARAM_ARGS 0 #define ACPI_PARAM_GPE 1 - #endif diff --git a/include/acpi/actables.h b/include/acpi/actables.h index e6ceb18..f92c185 100644 --- a/include/acpi/actables.h +++ b/include/acpi/actables.h @@ -44,154 +44,101 @@ #ifndef __ACTABLES_H__ #define __ACTABLES_H__ - /* Used in acpi_tb_map_acpi_table for size parameter if table header is to be used */ #define SIZE_IN_HEADER 0 - /* * tbconvrt - Table conversion routines */ -acpi_status -acpi_tb_convert_to_xsdt ( - struct acpi_table_desc *table_info); +acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info); -acpi_status -acpi_tb_convert_table_fadt ( - void); +acpi_status acpi_tb_convert_table_fadt(void); -acpi_status -acpi_tb_build_common_facs ( - struct acpi_table_desc *table_info); +acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info); u32 -acpi_tb_get_table_count ( - struct rsdp_descriptor *RSDP, - struct acpi_table_header *RSDT); - +acpi_tb_get_table_count(struct rsdp_descriptor *RSDP, + struct acpi_table_header *RSDT); /* * tbget - Table "get" routines */ acpi_status -acpi_tb_get_table ( - struct acpi_pointer *address, - struct acpi_table_desc *table_info); - -acpi_status -acpi_tb_get_table_header ( - struct acpi_pointer *address, - struct acpi_table_header *return_header); +acpi_tb_get_table(struct acpi_pointer *address, + struct acpi_table_desc *table_info); acpi_status -acpi_tb_get_table_body ( - struct acpi_pointer *address, - struct acpi_table_header *header, - struct acpi_table_desc *table_info); +acpi_tb_get_table_header(struct acpi_pointer *address, + struct acpi_table_header *return_header); acpi_status -acpi_tb_get_table_ptr ( - acpi_table_type table_type, - u32 instance, - struct acpi_table_header **table_ptr_loc); +acpi_tb_get_table_body(struct acpi_pointer *address, + struct acpi_table_header *header, + struct acpi_table_desc *table_info); acpi_status -acpi_tb_verify_rsdp ( - struct acpi_pointer *address); +acpi_tb_get_table_ptr(acpi_table_type table_type, + u32 instance, struct acpi_table_header **table_ptr_loc); -void -acpi_tb_get_rsdt_address ( - struct acpi_pointer *out_address); +acpi_status acpi_tb_verify_rsdp(struct acpi_pointer *address); -acpi_status -acpi_tb_validate_rsdt ( - struct acpi_table_header *table_ptr); +void acpi_tb_get_rsdt_address(struct acpi_pointer *out_address); +acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr); /* * tbgetall - get multiple required tables */ -acpi_status -acpi_tb_get_required_tables ( - void); - +acpi_status acpi_tb_get_required_tables(void); /* * tbinstall - Table installation */ -acpi_status -acpi_tb_install_table ( - struct acpi_table_desc *table_info); +acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info); acpi_status -acpi_tb_recognize_table ( - struct acpi_table_desc *table_info, - u8 search_type); +acpi_tb_recognize_table(struct acpi_table_desc *table_info, u8 search_type); acpi_status -acpi_tb_init_table_descriptor ( - acpi_table_type table_type, - struct acpi_table_desc *table_info); - +acpi_tb_init_table_descriptor(acpi_table_type table_type, + struct acpi_table_desc *table_info); /* * tbremove - Table removal and deletion */ -void -acpi_tb_delete_all_tables ( - void); - -void -acpi_tb_delete_tables_by_type ( - acpi_table_type type); +void acpi_tb_delete_all_tables(void); -void -acpi_tb_delete_single_table ( - struct acpi_table_desc *table_desc); +void acpi_tb_delete_tables_by_type(acpi_table_type type); -struct acpi_table_desc * -acpi_tb_uninstall_table ( - struct acpi_table_desc *table_desc); +void acpi_tb_delete_single_table(struct acpi_table_desc *table_desc); +struct acpi_table_desc *acpi_tb_uninstall_table(struct acpi_table_desc + *table_desc); /* * tbxfroot - RSDP, RSDT utilities */ acpi_status -acpi_tb_find_table ( - char *signature, - char *oem_id, - char *oem_table_id, - struct acpi_table_header **table_ptr); +acpi_tb_find_table(char *signature, + char *oem_id, + char *oem_table_id, struct acpi_table_header **table_ptr); -acpi_status -acpi_tb_get_table_rsdt ( - void); - -acpi_status -acpi_tb_validate_rsdp ( - struct rsdp_descriptor *rsdp); +acpi_status acpi_tb_get_table_rsdt(void); +acpi_status acpi_tb_validate_rsdp(struct rsdp_descriptor *rsdp); /* * tbutils - common table utilities */ -acpi_status -acpi_tb_is_table_installed ( - struct acpi_table_desc *new_table_desc); +acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc); acpi_status -acpi_tb_verify_table_checksum ( - struct acpi_table_header *table_header); +acpi_tb_verify_table_checksum(struct acpi_table_header *table_header); -u8 -acpi_tb_generate_checksum ( - void *buffer, - u32 length); +u8 acpi_tb_generate_checksum(void *buffer, u32 length); acpi_status -acpi_tb_validate_table_header ( - struct acpi_table_header *table_header); +acpi_tb_validate_table_header(struct acpi_table_header *table_header); -#endif /* __ACTABLES_H__ */ +#endif /* __ACTABLES_H__ */ diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h index c1e9110..a46f406 100644 --- a/include/acpi/actbl.h +++ b/include/acpi/actbl.h @@ -44,27 +44,24 @@ #ifndef __ACTBL_H__ #define __ACTBL_H__ - /* * Values for description table header signatures */ #define RSDP_NAME "RSDP" -#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */ -#define APIC_SIG "APIC" /* Multiple APIC Description Table */ -#define DSDT_SIG "DSDT" /* Differentiated System Description Table */ -#define FADT_SIG "FACP" /* Fixed ACPI Description Table */ -#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */ -#define PSDT_SIG "PSDT" /* Persistent System Description Table */ -#define RSDT_SIG "RSDT" /* Root System Description Table */ -#define XSDT_SIG "XSDT" /* Extended System Description Table */ -#define SSDT_SIG "SSDT" /* Secondary System Description Table */ -#define SBST_SIG "SBST" /* Smart Battery Specification Table */ -#define SPIC_SIG "SPIC" /* IOSAPIC table */ -#define BOOT_SIG "BOOT" /* Boot table */ - - -#define GL_OWNED 0x02 /* Ownership of global lock is bit 1 */ - +#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */ +#define APIC_SIG "APIC" /* Multiple APIC Description Table */ +#define DSDT_SIG "DSDT" /* Differentiated System Description Table */ +#define FADT_SIG "FACP" /* Fixed ACPI Description Table */ +#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */ +#define PSDT_SIG "PSDT" /* Persistent System Description Table */ +#define RSDT_SIG "RSDT" /* Root System Description Table */ +#define XSDT_SIG "XSDT" /* Extended System Description Table */ +#define SSDT_SIG "SSDT" /* Secondary System Description Table */ +#define SBST_SIG "SBST" /* Smart Battery Specification Table */ +#define SPIC_SIG "SPIC" /* IOSAPIC table */ +#define BOOT_SIG "BOOT" /* Boot table */ + +#define GL_OWNED 0x02 /* Ownership of global lock is bit 1 */ /* * Common table types. The base code can remain @@ -75,7 +72,6 @@ #define FACS_DESCRIPTOR struct facs_descriptor_rev2 #define FADT_DESCRIPTOR struct fadt_descriptor_rev2 - #pragma pack(1) /* @@ -84,28 +80,24 @@ * NOTE: The tables that are specific to ACPI versions (1.0, 2.0, etc.) * are in separate files. */ -struct rsdp_descriptor /* Root System Descriptor Pointer */ -{ - char signature[8]; /* ACPI signature, contains "RSD PTR " */ - u8 checksum; /* ACPI 1.0 checksum */ - char oem_id[6]; /* OEM identification */ - u8 revision; /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */ - u32 rsdt_physical_address; /* 32-bit physical address of the RSDT */ - u32 length; /* XSDT Length in bytes, including header */ - u64 xsdt_physical_address; /* 64-bit physical address of the XSDT */ - u8 extended_checksum; /* Checksum of entire table (ACPI 2.0) */ - char reserved[3]; /* Reserved, must be zero */ +struct rsdp_descriptor { /* Root System Descriptor Pointer */ + char signature[8]; /* ACPI signature, contains "RSD PTR " */ + u8 checksum; /* ACPI 1.0 checksum */ + char oem_id[6]; /* OEM identification */ + u8 revision; /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */ + u32 rsdt_physical_address; /* 32-bit physical address of the RSDT */ + u32 length; /* XSDT Length in bytes, including header */ + u64 xsdt_physical_address; /* 64-bit physical address of the XSDT */ + u8 extended_checksum; /* Checksum of entire table (ACPI 2.0) */ + char reserved[3]; /* Reserved, must be zero */ }; - -struct acpi_common_facs /* Common FACS for internal use */ -{ - u32 *global_lock; - u64 *firmware_waking_vector; - u8 vector_width; +struct acpi_common_facs { /* Common FACS for internal use */ + u32 *global_lock; + u64 *firmware_waking_vector; + u8 vector_width; }; - #define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \ char signature[4]; /* ASCII table signature */\ u32 length; /* Length of table in bytes, including this header */\ @@ -115,14 +107,10 @@ struct acpi_common_facs /* Common FACS for internal use */ char oem_table_id[8]; /* ASCII OEM table identification */\ u32 oem_revision; /* OEM revision number */\ char asl_compiler_id [4]; /* ASCII ASL compiler vendor ID */\ - u32 asl_compiler_revision; /* ASL compiler version */ - - -struct acpi_table_header /* ACPI common table header */ -{ - ACPI_TABLE_HEADER_DEF -}; + u32 asl_compiler_revision; /* ASL compiler version */ +struct acpi_table_header { /* ACPI common table header */ +ACPI_TABLE_HEADER_DEF}; /* * MADT values and structures @@ -135,16 +123,15 @@ struct acpi_table_header /* ACPI common table header */ /* Master MADT */ -struct multiple_apic_table -{ - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - u32 local_apic_address; /* Physical address of local APIC */ +struct multiple_apic_table { + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + u32 local_apic_address; /* Physical address of local APIC */ /* Flags (32 bits) */ - u8 PCATcompat : 1; /* 00: System also has dual 8259s */ - u8 : 7; /* 01-07: Reserved, must be zero */ - u8 reserved1[3]; /* 08-31: Reserved, must be zero */ + u8 PCATcompat:1; /* 00: System also has dual 8259s */ + u8:7; /* 01-07: Reserved, must be zero */ + u8 reserved1[3]; /* 08-31: Reserved, must be zero */ }; /* Values for Type in APIC_HEADER_DEF */ @@ -158,7 +145,7 @@ struct multiple_apic_table #define APIC_IO_SAPIC 6 #define APIC_LOCAL_SAPIC 7 #define APIC_XRUPT_SOURCE 8 -#define APIC_RESERVED 9 /* 9 and greater are reserved */ +#define APIC_RESERVED 9 /* 9 and greater are reserved */ /* * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE) @@ -167,10 +154,8 @@ struct multiple_apic_table u8 type; \ u8 length; -struct apic_header -{ - APIC_HEADER_DEF -}; +struct apic_header { +APIC_HEADER_DEF}; /* Values for MPS INTI flags */ @@ -190,113 +175,84 @@ struct apic_header u8 polarity : 2; /* 00-01: Polarity of APIC I/O input signals */\ u8 trigger_mode : 2; /* 02-03: Trigger mode of APIC input signals */\ u8 : 4; /* 04-07: Reserved, must be zero */\ - u8 reserved1; /* 08-15: Reserved, must be zero */ + u8 reserved1; /* 08-15: Reserved, must be zero */ #define LOCAL_APIC_FLAGS \ u8 processor_enabled: 1; /* 00: Processor is usable if set */\ u8 : 7; /* 01-07: Reserved, must be zero */\ - u8 reserved2; /* 08-15: Reserved, must be zero */ + u8 reserved2; /* 08-15: Reserved, must be zero */ /* Sub-structures for MADT */ -struct madt_processor_apic -{ - APIC_HEADER_DEF - u8 processor_id; /* ACPI processor id */ - u8 local_apic_id; /* Processor's local APIC id */ - LOCAL_APIC_FLAGS +struct madt_processor_apic { + APIC_HEADER_DEF u8 processor_id; /* ACPI processor id */ + u8 local_apic_id; /* Processor's local APIC id */ + LOCAL_APIC_FLAGS}; + +struct madt_io_apic { + APIC_HEADER_DEF u8 io_apic_id; /* I/O APIC ID */ + u8 reserved; /* Reserved - must be zero */ + u32 address; /* APIC physical address */ + u32 interrupt; /* Global system interrupt where INTI + * lines start */ }; -struct madt_io_apic -{ - APIC_HEADER_DEF - u8 io_apic_id; /* I/O APIC ID */ - u8 reserved; /* Reserved - must be zero */ - u32 address; /* APIC physical address */ - u32 interrupt; /* Global system interrupt where INTI - * lines start */ -}; - -struct madt_interrupt_override -{ - APIC_HEADER_DEF - u8 bus; /* 0 - ISA */ - u8 source; /* Interrupt source (IRQ) */ - u32 interrupt; /* Global system interrupt */ - MPS_INTI_FLAGS -}; +struct madt_interrupt_override { + APIC_HEADER_DEF u8 bus; /* 0 - ISA */ + u8 source; /* Interrupt source (IRQ) */ + u32 interrupt; /* Global system interrupt */ + MPS_INTI_FLAGS}; -struct madt_nmi_source -{ - APIC_HEADER_DEF - MPS_INTI_FLAGS - u32 interrupt; /* Global system interrupt */ +struct madt_nmi_source { + APIC_HEADER_DEF MPS_INTI_FLAGS u32 interrupt; /* Global system interrupt */ }; -struct madt_local_apic_nmi -{ - APIC_HEADER_DEF - u8 processor_id; /* ACPI processor id */ - MPS_INTI_FLAGS - u8 lint; /* LINTn to which NMI is connected */ +struct madt_local_apic_nmi { + APIC_HEADER_DEF u8 processor_id; /* ACPI processor id */ + MPS_INTI_FLAGS u8 lint; /* LINTn to which NMI is connected */ }; -struct madt_address_override -{ - APIC_HEADER_DEF - u16 reserved; /* Reserved, must be zero */ - u64 address; /* APIC physical address */ +struct madt_address_override { + APIC_HEADER_DEF u16 reserved; /* Reserved, must be zero */ + u64 address; /* APIC physical address */ }; -struct madt_io_sapic -{ - APIC_HEADER_DEF - u8 io_sapic_id; /* I/O SAPIC ID */ - u8 reserved; /* Reserved, must be zero */ - u32 interrupt_base; /* Glocal interrupt for SAPIC start */ - u64 address; /* SAPIC physical address */ +struct madt_io_sapic { + APIC_HEADER_DEF u8 io_sapic_id; /* I/O SAPIC ID */ + u8 reserved; /* Reserved, must be zero */ + u32 interrupt_base; /* Glocal interrupt for SAPIC start */ + u64 address; /* SAPIC physical address */ }; -struct madt_local_sapic -{ - APIC_HEADER_DEF - u8 processor_id; /* ACPI processor id */ - u8 local_sapic_id; /* SAPIC ID */ - u8 local_sapic_eid; /* SAPIC EID */ - u8 reserved[3]; /* Reserved, must be zero */ - LOCAL_APIC_FLAGS - u32 processor_uID; /* Numeric UID - ACPI 3.0 */ - char processor_uIDstring[1]; /* String UID - ACPI 3.0 */ +struct madt_local_sapic { + APIC_HEADER_DEF u8 processor_id; /* ACPI processor id */ + u8 local_sapic_id; /* SAPIC ID */ + u8 local_sapic_eid; /* SAPIC EID */ + u8 reserved[3]; /* Reserved, must be zero */ + LOCAL_APIC_FLAGS u32 processor_uID; /* Numeric UID - ACPI 3.0 */ + char processor_uIDstring[1]; /* String UID - ACPI 3.0 */ }; -struct madt_interrupt_source -{ - APIC_HEADER_DEF - MPS_INTI_FLAGS - u8 interrupt_type; /* 1=PMI, 2=INIT, 3=corrected */ - u8 processor_id; /* Processor ID */ - u8 processor_eid; /* Processor EID */ - u8 io_sapic_vector; /* Vector value for PMI interrupts */ - u32 interrupt; /* Global system interrupt */ - u32 flags; /* Interrupt Source Flags */ +struct madt_interrupt_source { + APIC_HEADER_DEF MPS_INTI_FLAGS u8 interrupt_type; /* 1=PMI, 2=INIT, 3=corrected */ + u8 processor_id; /* Processor ID */ + u8 processor_eid; /* Processor EID */ + u8 io_sapic_vector; /* Vector value for PMI interrupts */ + u32 interrupt; /* Global system interrupt */ + u32 flags; /* Interrupt Source Flags */ }; - /* * Smart Battery */ -struct smart_battery_table -{ - ACPI_TABLE_HEADER_DEF - u32 warning_level; - u32 low_level; - u32 critical_level; +struct smart_battery_table { + ACPI_TABLE_HEADER_DEF u32 warning_level; + u32 low_level; + u32 critical_level; }; - #pragma pack() - /* * ACPI Table information. We save the table address, length, * and type of memory allocation (mapped or allocated) for each @@ -320,39 +276,35 @@ struct smart_battery_table /* Data about each known table type */ -struct acpi_table_support -{ - char *name; - char *signature; - void **global_ptr; - u8 sig_length; - u8 flags; +struct acpi_table_support { + char *name; + char *signature; + void **global_ptr; + u8 sig_length; + u8 flags; }; - /* * Get the ACPI version-specific tables */ -#include "actbl1.h" /* Acpi 1.0 table definitions */ -#include "actbl2.h" /* Acpi 2.0 table definitions */ +#include "actbl1.h" /* Acpi 1.0 table definitions */ +#include "actbl2.h" /* Acpi 2.0 table definitions */ -extern u8 acpi_fadt_is_v1; /* is set to 1 if FADT is revision 1, - * needed for certain workarounds */ +extern u8 acpi_fadt_is_v1; /* is set to 1 if FADT is revision 1, + * needed for certain workarounds */ #pragma pack(1) /* * High performance timer */ -struct hpet_table -{ - ACPI_TABLE_HEADER_DEF - u32 hardware_id; - struct acpi_generic_address base_address; - u8 hpet_number; - u16 clock_tick; - u8 attributes; +struct hpet_table { + ACPI_TABLE_HEADER_DEF u32 hardware_id; + struct acpi_generic_address base_address; + u8 hpet_number; + u16 clock_tick; + u8 attributes; }; #pragma pack() -#endif /* __ACTBL_H__ */ +#endif /* __ACTBL_H__ */ diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h index 93c175a..67312c3 100644 --- a/include/acpi/actbl1.h +++ b/include/acpi/actbl1.h @@ -49,94 +49,87 @@ /* * ACPI 1.0 Root System Description Table (RSDT) */ -struct rsdt_descriptor_rev1 -{ - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - u32 table_offset_entry[1]; /* Array of pointers to ACPI tables */ +struct rsdt_descriptor_rev1 { + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + u32 table_offset_entry[1]; /* Array of pointers to ACPI tables */ }; - /* * ACPI 1.0 Firmware ACPI Control Structure (FACS) */ -struct facs_descriptor_rev1 -{ - char signature[4]; /* ASCII table signature */ - u32 length; /* Length of structure in bytes */ - u32 hardware_signature; /* Hardware configuration signature */ - u32 firmware_waking_vector; /* ACPI OS waking vector */ - u32 global_lock; /* Global Lock */ +struct facs_descriptor_rev1 { + char signature[4]; /* ASCII table signature */ + u32 length; /* Length of structure in bytes */ + u32 hardware_signature; /* Hardware configuration signature */ + u32 firmware_waking_vector; /* ACPI OS waking vector */ + u32 global_lock; /* Global Lock */ /* Flags (32 bits) */ - u8 S4bios_f : 1; /* 00: S4BIOS support is present */ - u8 : 7; /* 01-07: Reserved, must be zero */ - u8 reserved1[3]; /* 08-31: Reserved, must be zero */ + u8 S4bios_f:1; /* 00: S4BIOS support is present */ + u8:7; /* 01-07: Reserved, must be zero */ + u8 reserved1[3]; /* 08-31: Reserved, must be zero */ - u8 reserved2[40]; /* Reserved, must be zero */ + u8 reserved2[40]; /* Reserved, must be zero */ }; - /* * ACPI 1.0 Fixed ACPI Description Table (FADT) */ -struct fadt_descriptor_rev1 -{ - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - u32 firmware_ctrl; /* Physical address of FACS */ - u32 dsdt; /* Physical address of DSDT */ - u8 model; /* System Interrupt Model */ - u8 reserved1; /* Reserved, must be zero */ - u16 sci_int; /* System vector of SCI interrupt */ - u32 smi_cmd; /* Port address of SMI command port */ - u8 acpi_enable; /* Value to write to smi_cmd to enable ACPI */ - u8 acpi_disable; /* Value to write to smi_cmd to disable ACPI */ - u8 S4bios_req; /* Value to write to SMI CMD to enter S4BIOS state */ - u8 reserved2; /* Reserved, must be zero */ - u32 pm1a_evt_blk; /* Port address of Power Mgt 1a acpi_event Reg Blk */ - u32 pm1b_evt_blk; /* Port address of Power Mgt 1b acpi_event Reg Blk */ - u32 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ - u32 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ - u32 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ - u32 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ - u32 gpe0_blk; /* Port addr of General Purpose acpi_event 0 Reg Blk */ - u32 gpe1_blk; /* Port addr of General Purpose acpi_event 1 Reg Blk */ - u8 pm1_evt_len; /* Byte length of ports at pm1_x_evt_blk */ - u8 pm1_cnt_len; /* Byte length of ports at pm1_x_cnt_blk */ - u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ - u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ - u8 gpe0_blk_len; /* Byte Length of ports at gpe0_blk */ - u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ - u8 gpe1_base; /* Offset in gpe model where gpe1 events start */ - u8 reserved3; /* Reserved, must be zero */ - u16 plvl2_lat; /* Worst case HW latency to enter/exit C2 state */ - u16 plvl3_lat; /* Worst case HW latency to enter/exit C3 state */ - u16 flush_size; /* Size of area read to flush caches */ - u16 flush_stride; /* Stride used in flushing caches */ - u8 duty_offset; /* Bit location of duty cycle field in p_cnt reg */ - u8 duty_width; /* Bit width of duty cycle field in p_cnt reg */ - u8 day_alrm; /* Index to day-of-month alarm in RTC CMOS RAM */ - u8 mon_alrm; /* Index to month-of-year alarm in RTC CMOS RAM */ - u8 century; /* Index to century in RTC CMOS RAM */ - u8 reserved4[3]; /* Reserved, must be zero */ +struct fadt_descriptor_rev1 { + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + u32 firmware_ctrl; /* Physical address of FACS */ + u32 dsdt; /* Physical address of DSDT */ + u8 model; /* System Interrupt Model */ + u8 reserved1; /* Reserved, must be zero */ + u16 sci_int; /* System vector of SCI interrupt */ + u32 smi_cmd; /* Port address of SMI command port */ + u8 acpi_enable; /* Value to write to smi_cmd to enable ACPI */ + u8 acpi_disable; /* Value to write to smi_cmd to disable ACPI */ + u8 S4bios_req; /* Value to write to SMI CMD to enter S4BIOS state */ + u8 reserved2; /* Reserved, must be zero */ + u32 pm1a_evt_blk; /* Port address of Power Mgt 1a acpi_event Reg Blk */ + u32 pm1b_evt_blk; /* Port address of Power Mgt 1b acpi_event Reg Blk */ + u32 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ + u32 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ + u32 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ + u32 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ + u32 gpe0_blk; /* Port addr of General Purpose acpi_event 0 Reg Blk */ + u32 gpe1_blk; /* Port addr of General Purpose acpi_event 1 Reg Blk */ + u8 pm1_evt_len; /* Byte length of ports at pm1_x_evt_blk */ + u8 pm1_cnt_len; /* Byte length of ports at pm1_x_cnt_blk */ + u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ + u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ + u8 gpe0_blk_len; /* Byte Length of ports at gpe0_blk */ + u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ + u8 gpe1_base; /* Offset in gpe model where gpe1 events start */ + u8 reserved3; /* Reserved, must be zero */ + u16 plvl2_lat; /* Worst case HW latency to enter/exit C2 state */ + u16 plvl3_lat; /* Worst case HW latency to enter/exit C3 state */ + u16 flush_size; /* Size of area read to flush caches */ + u16 flush_stride; /* Stride used in flushing caches */ + u8 duty_offset; /* Bit location of duty cycle field in p_cnt reg */ + u8 duty_width; /* Bit width of duty cycle field in p_cnt reg */ + u8 day_alrm; /* Index to day-of-month alarm in RTC CMOS RAM */ + u8 mon_alrm; /* Index to month-of-year alarm in RTC CMOS RAM */ + u8 century; /* Index to century in RTC CMOS RAM */ + u8 reserved4[3]; /* Reserved, must be zero */ /* Flags (32 bits) */ - u8 wb_invd : 1; /* 00: The wbinvd instruction works properly */ - u8 wb_invd_flush : 1; /* 01: The wbinvd flushes but does not invalidate */ - u8 proc_c1 : 1; /* 02: All processors support C1 state */ - u8 plvl2_up : 1; /* 03: C2 state works on MP system */ - u8 pwr_button : 1; /* 04: Power button is handled as a generic feature */ - u8 sleep_button : 1; /* 05: Sleep button is handled as a generic feature, or not present */ - u8 fixed_rTC : 1; /* 06: RTC wakeup stat not in fixed register space */ - u8 rtcs4 : 1; /* 07: RTC wakeup stat not possible from S4 */ - u8 tmr_val_ext : 1; /* 08: tmr_val width is 32 bits (0 = 24 bits) */ - u8 : 7; /* 09-15: Reserved, must be zero */ - u8 reserved5[2]; /* 16-31: Reserved, must be zero */ + u8 wb_invd:1; /* 00: The wbinvd instruction works properly */ + u8 wb_invd_flush:1; /* 01: The wbinvd flushes but does not invalidate */ + u8 proc_c1:1; /* 02: All processors support C1 state */ + u8 plvl2_up:1; /* 03: C2 state works on MP system */ + u8 pwr_button:1; /* 04: Power button is handled as a generic feature */ + u8 sleep_button:1; /* 05: Sleep button is handled as a generic feature, or not present */ + u8 fixed_rTC:1; /* 06: RTC wakeup stat not in fixed register space */ + u8 rtcs4:1; /* 07: RTC wakeup stat not possible from S4 */ + u8 tmr_val_ext:1; /* 08: tmr_val width is 32 bits (0 = 24 bits) */ + u8:7; /* 09-15: Reserved, must be zero */ + u8 reserved5[2]; /* 16-31: Reserved, must be zero */ }; #pragma pack() -#endif /* __ACTBL1_H__ */ - - +#endif /* __ACTBL1_H__ */ diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index 84ce5ab..50305ce 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -64,65 +64,56 @@ #define FADT2_REVISION_ID 3 #define FADT2_MINUS_REVISION_ID 2 - #pragma pack(1) /* * ACPI 2.0 Root System Description Table (RSDT) */ -struct rsdt_descriptor_rev2 -{ - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - u32 table_offset_entry[1]; /* Array of pointers to ACPI tables */ +struct rsdt_descriptor_rev2 { + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + u32 table_offset_entry[1]; /* Array of pointers to ACPI tables */ }; - /* * ACPI 2.0 Extended System Description Table (XSDT) */ -struct xsdt_descriptor_rev2 -{ - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - u64 table_offset_entry[1]; /* Array of pointers to ACPI tables */ +struct xsdt_descriptor_rev2 { + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + u64 table_offset_entry[1]; /* Array of pointers to ACPI tables */ }; - /* * ACPI 2.0 Firmware ACPI Control Structure (FACS) */ -struct facs_descriptor_rev2 -{ - char signature[4]; /* ASCII table signature */ - u32 length; /* Length of structure, in bytes */ - u32 hardware_signature; /* Hardware configuration signature */ - u32 firmware_waking_vector; /* 32-bit physical address of the Firmware Waking Vector. */ - u32 global_lock; /* Global Lock used to synchronize access to shared hardware resources */ +struct facs_descriptor_rev2 { + char signature[4]; /* ASCII table signature */ + u32 length; /* Length of structure, in bytes */ + u32 hardware_signature; /* Hardware configuration signature */ + u32 firmware_waking_vector; /* 32-bit physical address of the Firmware Waking Vector. */ + u32 global_lock; /* Global Lock used to synchronize access to shared hardware resources */ /* Flags (32 bits) */ - u8 S4bios_f : 1; /* 00: S4BIOS support is present */ - u8 : 7; /* 01-07: Reserved, must be zero */ - u8 reserved1[3]; /* 08-31: Reserved, must be zero */ + u8 S4bios_f:1; /* 00: S4BIOS support is present */ + u8:7; /* 01-07: Reserved, must be zero */ + u8 reserved1[3]; /* 08-31: Reserved, must be zero */ - u64 xfirmware_waking_vector; /* 64-bit physical address of the Firmware Waking Vector. */ - u8 version; /* Version of this table */ - u8 reserved3[31]; /* Reserved, must be zero */ + u64 xfirmware_waking_vector; /* 64-bit physical address of the Firmware Waking Vector. */ + u8 version; /* Version of this table */ + u8 reserved3[31]; /* Reserved, must be zero */ }; - /* * ACPI 2.0+ Generic Address Structure (GAS) */ -struct acpi_generic_address -{ - u8 address_space_id; /* Address space where struct or register exists. */ - u8 register_bit_width; /* Size in bits of given register */ - u8 register_bit_offset; /* Bit offset within the register */ - u8 access_width; /* Minimum Access size (ACPI 3.0) */ - u64 address; /* 64-bit address of struct or register */ +struct acpi_generic_address { + u8 address_space_id; /* Address space where struct or register exists. */ + u8 register_bit_width; /* Size in bits of given register */ + u8 register_bit_offset; /* Bit offset within the register */ + u8 access_width; /* Minimum Access size (ACPI 3.0) */ + u64 address; /* 64-bit address of struct or register */ }; - #define FADT_REV2_COMMON \ u32 V1_firmware_ctrl; /* 32-bit physical address of FACS */ \ u32 V1_dsdt; /* 32-bit physical address of DSDT */ \ @@ -164,141 +155,123 @@ struct acpi_generic_address /* * ACPI 2.0+ Fixed ACPI Description Table (FADT) */ -struct fadt_descriptor_rev2 -{ - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - FADT_REV2_COMMON - u8 reserved2; /* Reserved, must be zero */ +struct fadt_descriptor_rev2 { + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + FADT_REV2_COMMON u8 reserved2; /* Reserved, must be zero */ /* Flags (32 bits) */ - u8 wb_invd : 1; /* 00: The wbinvd instruction works properly */ - u8 wb_invd_flush : 1; /* 01: The wbinvd flushes but does not invalidate */ - u8 proc_c1 : 1; /* 02: All processors support C1 state */ - u8 plvl2_up : 1; /* 03: C2 state works on MP system */ - u8 pwr_button : 1; /* 04: Power button is handled as a generic feature */ - u8 sleep_button : 1; /* 05: Sleep button is handled as a generic feature, or not present */ - u8 fixed_rTC : 1; /* 06: RTC wakeup stat not in fixed register space */ - u8 rtcs4 : 1; /* 07: RTC wakeup stat not possible from S4 */ - u8 tmr_val_ext : 1; /* 08: tmr_val is 32 bits 0=24-bits */ - u8 dock_cap : 1; /* 09: Docking supported */ - u8 reset_reg_sup : 1; /* 10: System reset via the FADT RESET_REG supported */ - u8 sealed_case : 1; /* 11: No internal expansion capabilities and case is sealed */ - u8 headless : 1; /* 12: No local video capabilities or local input devices */ - u8 cpu_sw_sleep : 1; /* 13: Must execute native instruction after writing SLP_TYPx register */ - - u8 pci_exp_wak : 1; /* 14: System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */ - u8 use_platform_clock : 1; /* 15: OSPM should use platform-provided timer (ACPI 3.0) */ - u8 S4rtc_sts_valid : 1; /* 16: Contents of RTC_STS valid after S4 wake (ACPI 3.0) */ - u8 remote_power_on_capable : 1; /* 17: System is compatible with remote power on (ACPI 3.0) */ - u8 force_apic_cluster_model : 1; /* 18: All local APICs must use cluster model (ACPI 3.0) */ - u8 force_apic_physical_destination_mode : 1; /* 19: all local x_aPICs must use physical dest mode (ACPI 3.0) */ - u8 : 4; /* 20-23: Reserved, must be zero */ - u8 reserved3; /* 24-31: Reserved, must be zero */ - - struct acpi_generic_address reset_register; /* Reset register address in GAS format */ - u8 reset_value; /* Value to write to the reset_register port to reset the system */ - u8 reserved4[3]; /* These three bytes must be zero */ - u64 xfirmware_ctrl; /* 64-bit physical address of FACS */ - u64 Xdsdt; /* 64-bit physical address of DSDT */ - struct acpi_generic_address xpm1a_evt_blk; /* Extended Power Mgt 1a acpi_event Reg Blk address */ - struct acpi_generic_address xpm1b_evt_blk; /* Extended Power Mgt 1b acpi_event Reg Blk address */ - struct acpi_generic_address xpm1a_cnt_blk; /* Extended Power Mgt 1a Control Reg Blk address */ - struct acpi_generic_address xpm1b_cnt_blk; /* Extended Power Mgt 1b Control Reg Blk address */ - struct acpi_generic_address xpm2_cnt_blk; /* Extended Power Mgt 2 Control Reg Blk address */ - struct acpi_generic_address xpm_tmr_blk; /* Extended Power Mgt Timer Ctrl Reg Blk address */ - struct acpi_generic_address xgpe0_blk; /* Extended General Purpose acpi_event 0 Reg Blk address */ - struct acpi_generic_address xgpe1_blk; /* Extended General Purpose acpi_event 1 Reg Blk address */ + u8 wb_invd:1; /* 00: The wbinvd instruction works properly */ + u8 wb_invd_flush:1; /* 01: The wbinvd flushes but does not invalidate */ + u8 proc_c1:1; /* 02: All processors support C1 state */ + u8 plvl2_up:1; /* 03: C2 state works on MP system */ + u8 pwr_button:1; /* 04: Power button is handled as a generic feature */ + u8 sleep_button:1; /* 05: Sleep button is handled as a generic feature, or not present */ + u8 fixed_rTC:1; /* 06: RTC wakeup stat not in fixed register space */ + u8 rtcs4:1; /* 07: RTC wakeup stat not possible from S4 */ + u8 tmr_val_ext:1; /* 08: tmr_val is 32 bits 0=24-bits */ + u8 dock_cap:1; /* 09: Docking supported */ + u8 reset_reg_sup:1; /* 10: System reset via the FADT RESET_REG supported */ + u8 sealed_case:1; /* 11: No internal expansion capabilities and case is sealed */ + u8 headless:1; /* 12: No local video capabilities or local input devices */ + u8 cpu_sw_sleep:1; /* 13: Must execute native instruction after writing SLP_TYPx register */ + + u8 pci_exp_wak:1; /* 14: System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */ + u8 use_platform_clock:1; /* 15: OSPM should use platform-provided timer (ACPI 3.0) */ + u8 S4rtc_sts_valid:1; /* 16: Contents of RTC_STS valid after S4 wake (ACPI 3.0) */ + u8 remote_power_on_capable:1; /* 17: System is compatible with remote power on (ACPI 3.0) */ + u8 force_apic_cluster_model:1; /* 18: All local APICs must use cluster model (ACPI 3.0) */ + u8 force_apic_physical_destination_mode:1; /* 19: all local x_aPICs must use physical dest mode (ACPI 3.0) */ + u8:4; /* 20-23: Reserved, must be zero */ + u8 reserved3; /* 24-31: Reserved, must be zero */ + + struct acpi_generic_address reset_register; /* Reset register address in GAS format */ + u8 reset_value; /* Value to write to the reset_register port to reset the system */ + u8 reserved4[3]; /* These three bytes must be zero */ + u64 xfirmware_ctrl; /* 64-bit physical address of FACS */ + u64 Xdsdt; /* 64-bit physical address of DSDT */ + struct acpi_generic_address xpm1a_evt_blk; /* Extended Power Mgt 1a acpi_event Reg Blk address */ + struct acpi_generic_address xpm1b_evt_blk; /* Extended Power Mgt 1b acpi_event Reg Blk address */ + struct acpi_generic_address xpm1a_cnt_blk; /* Extended Power Mgt 1a Control Reg Blk address */ + struct acpi_generic_address xpm1b_cnt_blk; /* Extended Power Mgt 1b Control Reg Blk address */ + struct acpi_generic_address xpm2_cnt_blk; /* Extended Power Mgt 2 Control Reg Blk address */ + struct acpi_generic_address xpm_tmr_blk; /* Extended Power Mgt Timer Ctrl Reg Blk address */ + struct acpi_generic_address xgpe0_blk; /* Extended General Purpose acpi_event 0 Reg Blk address */ + struct acpi_generic_address xgpe1_blk; /* Extended General Purpose acpi_event 1 Reg Blk address */ }; - /* "Down-revved" ACPI 2.0 FADT descriptor */ -struct fadt_descriptor_rev2_minus -{ - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - FADT_REV2_COMMON - u8 reserved2; /* Reserved, must be zero */ - u32 flags; - struct acpi_generic_address reset_register; /* Reset register address in GAS format */ - u8 reset_value; /* Value to write to the reset_register port to reset the system. */ - u8 reserved7[3]; /* Reserved, must be zero */ +struct fadt_descriptor_rev2_minus { + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + FADT_REV2_COMMON u8 reserved2; /* Reserved, must be zero */ + u32 flags; + struct acpi_generic_address reset_register; /* Reset register address in GAS format */ + u8 reset_value; /* Value to write to the reset_register port to reset the system. */ + u8 reserved7[3]; /* Reserved, must be zero */ }; - /* ECDT - Embedded Controller Boot Resources Table */ -struct ec_boot_resources -{ - ACPI_TABLE_HEADER_DEF - struct acpi_generic_address ec_control; /* Address of EC command/status register */ - struct acpi_generic_address ec_data; /* Address of EC data register */ - u32 uid; /* Unique ID - must be same as the EC _UID method */ - u8 gpe_bit; /* The GPE for the EC */ - u8 ec_id[1]; /* Full namepath of the EC in the ACPI namespace */ +struct ec_boot_resources { + ACPI_TABLE_HEADER_DEF struct acpi_generic_address ec_control; /* Address of EC command/status register */ + struct acpi_generic_address ec_data; /* Address of EC data register */ + u32 uid; /* Unique ID - must be same as the EC _UID method */ + u8 gpe_bit; /* The GPE for the EC */ + u8 ec_id[1]; /* Full namepath of the EC in the ACPI namespace */ }; - /* SRAT - System Resource Affinity Table */ -struct static_resource_alloc -{ - u8 type; - u8 length; - u8 proximity_domain_lo; - u8 apic_id; +struct static_resource_alloc { + u8 type; + u8 length; + u8 proximity_domain_lo; + u8 apic_id; /* Flags (32 bits) */ - u8 enabled :1; /* 00: Use affinity structure */ - u8 :7; /* 01-07: Reserved, must be zero */ - u8 reserved3[3]; /* 08-31: Reserved, must be zero */ + u8 enabled:1; /* 00: Use affinity structure */ + u8:7; /* 01-07: Reserved, must be zero */ + u8 reserved3[3]; /* 08-31: Reserved, must be zero */ - u8 local_sapic_eid; - u8 proximity_domain_hi[3]; - u32 reserved4; /* Reserved, must be zero */ + u8 local_sapic_eid; + u8 proximity_domain_hi[3]; + u32 reserved4; /* Reserved, must be zero */ }; -struct memory_affinity -{ - u8 type; - u8 length; - u32 proximity_domain; - u16 reserved3; - u64 base_address; - u64 address_length; - u32 reserved4; +struct memory_affinity { + u8 type; + u8 length; + u32 proximity_domain; + u16 reserved3; + u64 base_address; + u64 address_length; + u32 reserved4; /* Flags (32 bits) */ - u8 enabled :1; /* 00: Use affinity structure */ - u8 hot_pluggable :1; /* 01: Memory region is hot pluggable */ - u8 non_volatile :1; /* 02: Memory is non-volatile */ - u8 :5; /* 03-07: Reserved, must be zero */ - u8 reserved5[3]; /* 08-31: Reserved, must be zero */ + u8 enabled:1; /* 00: Use affinity structure */ + u8 hot_pluggable:1; /* 01: Memory region is hot pluggable */ + u8 non_volatile:1; /* 02: Memory is non-volatile */ + u8:5; /* 03-07: Reserved, must be zero */ + u8 reserved5[3]; /* 08-31: Reserved, must be zero */ - u64 reserved6; /* Reserved, must be zero */ + u64 reserved6; /* Reserved, must be zero */ }; -struct system_resource_affinity -{ - ACPI_TABLE_HEADER_DEF - u32 reserved1; /* Must be value '1' */ - u64 reserved2; /* Reserved, must be zero */ +struct system_resource_affinity { + ACPI_TABLE_HEADER_DEF u32 reserved1; /* Must be value '1' */ + u64 reserved2; /* Reserved, must be zero */ }; - /* SLIT - System Locality Distance Information Table */ -struct system_locality_info -{ - ACPI_TABLE_HEADER_DEF - u64 locality_count; - u8 entry[1][1]; +struct system_locality_info { + ACPI_TABLE_HEADER_DEF u64 locality_count; + u8 entry[1][1]; }; - #pragma pack() -#endif /* __ACTBL2_H__ */ - +#endif /* __ACTBL2_H__ */ diff --git a/include/acpi/actbl71.h b/include/acpi/actbl71.h index 7b4fb44..10ac05b 100644 --- a/include/acpi/actbl71.h +++ b/include/acpi/actbl71.h @@ -27,7 +27,6 @@ #ifndef __ACTBL71_H__ #define __ACTBL71_H__ - /* 0.71 FADT address_space data item bitmasks defines */ /* If the associated bit is zero then it is in memory space else in io space */ @@ -40,105 +39,96 @@ /* Only for clarity in declarations */ -typedef u64 IO_ADDRESS; - +typedef u64 IO_ADDRESS; #pragma pack(1) -struct /* Root System Descriptor Pointer */ -{ - NATIVE_CHAR signature [8]; /* contains "RSD PTR " */ - u8 checksum; /* to make sum of struct == 0 */ - NATIVE_CHAR oem_id [6]; /* OEM identification */ - u8 reserved; /* Must be 0 for 1.0, 2 for 2.0 */ - u64 rsdt_physical_address; /* 64-bit physical address of RSDT */ +struct { /* Root System Descriptor Pointer */ + NATIVE_CHAR signature[8]; /* contains "RSD PTR " */ + u8 checksum; /* to make sum of struct == 0 */ + NATIVE_CHAR oem_id[6]; /* OEM identification */ + u8 reserved; /* Must be 0 for 1.0, 2 for 2.0 */ + u64 rsdt_physical_address; /* 64-bit physical address of RSDT */ }; - /*****************************************/ /* IA64 Extensions to ACPI Spec Rev 0.71 */ /* for the Root System Description Table */ /*****************************************/ -struct -{ - struct acpi_table_header header; /* Table header */ - u32 reserved_pad; /* IA64 alignment, must be 0 */ - u64 table_offset_entry [1]; /* Array of pointers to other */ - /* tables' headers */ +struct { + struct acpi_table_header header; /* Table header */ + u32 reserved_pad; /* IA64 alignment, must be 0 */ + u64 table_offset_entry[1]; /* Array of pointers to other */ + /* tables' headers */ }; - /*******************************************/ /* IA64 Extensions to ACPI Spec Rev 0.71 */ /* for the Firmware ACPI Control Structure */ /*******************************************/ -struct -{ - NATIVE_CHAR signature[4]; /* signature "FACS" */ - u32 length; /* length of structure, in bytes */ - u32 hardware_signature; /* hardware configuration signature */ - u32 reserved4; /* must be 0 */ - u64 firmware_waking_vector; /* ACPI OS waking vector */ - u64 global_lock; /* Global Lock */ - u32 S4bios_f : 1; /* Indicates if S4BIOS support is present */ - u32 reserved1 : 31; /* must be 0 */ - u8 reserved3 [28]; /* reserved - must be zero */ +struct { + NATIVE_CHAR signature[4]; /* signature "FACS" */ + u32 length; /* length of structure, in bytes */ + u32 hardware_signature; /* hardware configuration signature */ + u32 reserved4; /* must be 0 */ + u64 firmware_waking_vector; /* ACPI OS waking vector */ + u64 global_lock; /* Global Lock */ + u32 S4bios_f:1; /* Indicates if S4BIOS support is present */ + u32 reserved1:31; /* must be 0 */ + u8 reserved3[28]; /* reserved - must be zero */ }; - /******************************************/ /* IA64 Extensions to ACPI Spec Rev 0.71 */ /* for the Fixed ACPI Description Table */ /******************************************/ -struct -{ - struct acpi_table_header header; /* table header */ - u32 reserved_pad; /* IA64 alignment, must be 0 */ - u64 firmware_ctrl; /* 64-bit Physical address of FACS */ - u64 dsdt; /* 64-bit Physical address of DSDT */ - u8 model; /* System Interrupt Model */ - u8 address_space; /* Address Space Bitmask */ - u16 sci_int; /* System vector of SCI interrupt */ - u8 acpi_enable; /* value to write to smi_cmd to enable ACPI */ - u8 acpi_disable; /* value to write to smi_cmd to disable ACPI */ - u8 S4bios_req; /* Value to write to SMI CMD to enter S4BIOS state */ - u8 reserved2; /* reserved - must be zero */ - u64 smi_cmd; /* Port address of SMI command port */ - u64 pm1a_evt_blk; /* Port address of Power Mgt 1a acpi_event Reg Blk */ - u64 pm1b_evt_blk; /* Port address of Power Mgt 1b acpi_event Reg Blk */ - u64 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ - u64 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ - u64 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ - u64 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ - u64 gpe0_blk; /* Port addr of General Purpose acpi_event 0 Reg Blk */ - u64 gpe1_blk; /* Port addr of General Purpose acpi_event 1 Reg Blk */ - u8 pm1_evt_len; /* Byte length of ports at pm1_x_evt_blk */ - u8 pm1_cnt_len; /* Byte length of ports at pm1_x_cnt_blk */ - u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ - u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ - u8 gpe0_blk_len; /* Byte Length of ports at gpe0_blk */ - u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ - u8 gpe1_base; /* offset in gpe model where gpe1 events start */ - u8 reserved3; /* reserved */ - u16 plvl2_lat; /* worst case HW latency to enter/exit C2 state */ - u16 plvl3_lat; /* worst case HW latency to enter/exit C3 state */ - u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */ - u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */ - u8 century; /* index to century in RTC CMOS RAM */ - u8 reserved4; /* reserved */ - u32 flush_cash : 1; /* PAL_FLUSH_CACHE is correctly supported */ - u32 reserved5 : 1; /* reserved - must be zero */ - u32 proc_c1 : 1; /* all processors support C1 state */ - u32 plvl2_up : 1; /* C2 state works on MP system */ - u32 pwr_button : 1; /* Power button is handled as a generic feature */ - u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ - u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ - u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ - u32 tmr_val_ext : 1; /* tmr_val is 32 bits */ - u32 dock_cap : 1; /* Supports Docking */ - u32 reserved6 : 22; /* reserved - must be zero */ +struct { + struct acpi_table_header header; /* table header */ + u32 reserved_pad; /* IA64 alignment, must be 0 */ + u64 firmware_ctrl; /* 64-bit Physical address of FACS */ + u64 dsdt; /* 64-bit Physical address of DSDT */ + u8 model; /* System Interrupt Model */ + u8 address_space; /* Address Space Bitmask */ + u16 sci_int; /* System vector of SCI interrupt */ + u8 acpi_enable; /* value to write to smi_cmd to enable ACPI */ + u8 acpi_disable; /* value to write to smi_cmd to disable ACPI */ + u8 S4bios_req; /* Value to write to SMI CMD to enter S4BIOS state */ + u8 reserved2; /* reserved - must be zero */ + u64 smi_cmd; /* Port address of SMI command port */ + u64 pm1a_evt_blk; /* Port address of Power Mgt 1a acpi_event Reg Blk */ + u64 pm1b_evt_blk; /* Port address of Power Mgt 1b acpi_event Reg Blk */ + u64 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ + u64 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ + u64 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ + u64 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ + u64 gpe0_blk; /* Port addr of General Purpose acpi_event 0 Reg Blk */ + u64 gpe1_blk; /* Port addr of General Purpose acpi_event 1 Reg Blk */ + u8 pm1_evt_len; /* Byte length of ports at pm1_x_evt_blk */ + u8 pm1_cnt_len; /* Byte length of ports at pm1_x_cnt_blk */ + u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ + u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ + u8 gpe0_blk_len; /* Byte Length of ports at gpe0_blk */ + u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ + u8 gpe1_base; /* offset in gpe model where gpe1 events start */ + u8 reserved3; /* reserved */ + u16 plvl2_lat; /* worst case HW latency to enter/exit C2 state */ + u16 plvl3_lat; /* worst case HW latency to enter/exit C3 state */ + u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */ + u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */ + u8 century; /* index to century in RTC CMOS RAM */ + u8 reserved4; /* reserved */ + u32 flush_cash:1; /* PAL_FLUSH_CACHE is correctly supported */ + u32 reserved5:1; /* reserved - must be zero */ + u32 proc_c1:1; /* all processors support C1 state */ + u32 plvl2_up:1; /* C2 state works on MP system */ + u32 pwr_button:1; /* Power button is handled as a generic feature */ + u32 sleep_button:1; /* Sleep button is handled as a generic feature, or not present */ + u32 fixed_rTC:1; /* RTC wakeup stat not in fixed register space */ + u32 rtcs4:1; /* RTC wakeup stat not possible from S4 */ + u32 tmr_val_ext:1; /* tmr_val is 32 bits */ + u32 dock_cap:1; /* Supports Docking */ + u32 reserved6:22; /* reserved - must be zero */ }; #pragma pack() -#endif /* __ACTBL71_H__ */ - +#endif /* __ACTBL71_H__ */ diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 1895b86..254f4b0 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -46,35 +46,31 @@ /*! [Begin] no source code translation (keep the typedefs) */ - - /* * Data type ranges * Note: These macros are designed to be compiler independent as well as * working around problems that some 32-bit compilers have with 64-bit * constants. */ -#define ACPI_UINT8_MAX (UINT8) (~((UINT8) 0)) /* 0xFF */ -#define ACPI_UINT16_MAX (UINT16)(~((UINT16) 0)) /* 0xFFFF */ -#define ACPI_UINT32_MAX (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF */ -#define ACPI_UINT64_MAX (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */ +#define ACPI_UINT8_MAX (UINT8) (~((UINT8) 0)) /* 0xFF */ +#define ACPI_UINT16_MAX (UINT16)(~((UINT16) 0)) /* 0xFFFF */ +#define ACPI_UINT32_MAX (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF */ +#define ACPI_UINT64_MAX (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */ #define ACPI_ASCII_MAX 0x7F - #ifdef DEFINE_ALTERNATE_TYPES /* * Types used only in translated source, defined here to enable * cross-platform compilation only. */ -typedef int s32; -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef COMPILER_DEPENDENT_UINT64 u64; +typedef int s32; +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef COMPILER_DEPENDENT_UINT64 u64; #endif - /* * Data types - Fixed across all compilation models (16/32/64) * @@ -102,30 +98,29 @@ typedef COMPILER_DEPENDENT_UINT64 u64; /* * 64-bit type definitions */ -typedef unsigned char UINT8; -typedef unsigned char BOOLEAN; -typedef unsigned short UINT16; -typedef int INT32; -typedef unsigned int UINT32; -typedef COMPILER_DEPENDENT_INT64 INT64; -typedef COMPILER_DEPENDENT_UINT64 UINT64; +typedef unsigned char UINT8; +typedef unsigned char BOOLEAN; +typedef unsigned short UINT16; +typedef int INT32; +typedef unsigned int UINT32; +typedef COMPILER_DEPENDENT_INT64 INT64; +typedef COMPILER_DEPENDENT_UINT64 UINT64; /*! [End] no source code translation !*/ -typedef s64 acpi_native_int; -typedef u64 acpi_native_uint; +typedef s64 acpi_native_int; +typedef u64 acpi_native_uint; -typedef u64 acpi_table_ptr; -typedef u64 acpi_io_address; -typedef u64 acpi_physical_address; -typedef u64 acpi_size; +typedef u64 acpi_table_ptr; +typedef u64 acpi_io_address; +typedef u64 acpi_physical_address; +typedef u64 acpi_size; -#define ALIGNED_ADDRESS_BOUNDARY 0x00000008 /* No hardware alignment support in IA64 */ -#define ACPI_USE_NATIVE_DIVIDE /* Native 64-bit integer support */ +#define ALIGNED_ADDRESS_BOUNDARY 0x00000008 /* No hardware alignment support in IA64 */ +#define ACPI_USE_NATIVE_DIVIDE /* Native 64-bit integer support */ #define ACPI_MAX_PTR ACPI_UINT64_MAX #define ACPI_SIZE_MAX ACPI_UINT64_MAX - #elif ACPI_MACHINE_WIDTH == 16 /*! [Begin] no source code translation (keep the typedefs) */ @@ -133,32 +128,31 @@ typedef u64 acpi_size; /* * 16-bit type definitions */ -typedef unsigned char UINT8; -typedef unsigned char BOOLEAN; -typedef unsigned int UINT16; -typedef long INT32; -typedef int INT16; -typedef unsigned long UINT32; - -struct -{ - UINT32 Lo; - UINT32 Hi; +typedef unsigned char UINT8; +typedef unsigned char BOOLEAN; +typedef unsigned int UINT16; +typedef long INT32; +typedef int INT16; +typedef unsigned long UINT32; + +struct { + UINT32 Lo; + UINT32 Hi; }; /*! [End] no source code translation !*/ -typedef u16 acpi_native_uint; -typedef s16 acpi_native_int; +typedef u16 acpi_native_uint; +typedef s16 acpi_native_int; -typedef u32 acpi_table_ptr; -typedef u32 acpi_io_address; -typedef char *acpi_physical_address; -typedef u16 acpi_size; +typedef u32 acpi_table_ptr; +typedef u32 acpi_io_address; +typedef char *acpi_physical_address; +typedef u16 acpi_size; #define ALIGNED_ADDRESS_BOUNDARY 0x00000002 #define ACPI_MISALIGNED_TRANSFERS -#define ACPI_USE_NATIVE_DIVIDE /* No 64-bit integers, ok to use native divide */ +#define ACPI_USE_NATIVE_DIVIDE /* No 64-bit integers, ok to use native divide */ #define ACPI_MAX_PTR ACPI_UINT16_MAX #define ACPI_SIZE_MAX ACPI_UINT16_MAX @@ -168,7 +162,6 @@ typedef u16 acpi_size; */ #define ACPI_NO_INTEGER64_SUPPORT - #elif ACPI_MACHINE_WIDTH == 32 /*! [Begin] no source code translation (keep the typedefs) */ @@ -176,23 +169,23 @@ typedef u16 acpi_size; /* * 32-bit type definitions (default) */ -typedef unsigned char UINT8; -typedef unsigned char BOOLEAN; -typedef unsigned short UINT16; -typedef int INT32; -typedef unsigned int UINT32; -typedef COMPILER_DEPENDENT_INT64 INT64; -typedef COMPILER_DEPENDENT_UINT64 UINT64; +typedef unsigned char UINT8; +typedef unsigned char BOOLEAN; +typedef unsigned short UINT16; +typedef int INT32; +typedef unsigned int UINT32; +typedef COMPILER_DEPENDENT_INT64 INT64; +typedef COMPILER_DEPENDENT_UINT64 UINT64; /*! [End] no source code translation !*/ -typedef s32 acpi_native_int; -typedef u32 acpi_native_uint; +typedef s32 acpi_native_int; +typedef u32 acpi_native_uint; -typedef u64 acpi_table_ptr; -typedef u32 acpi_io_address; -typedef u64 acpi_physical_address; -typedef u32 acpi_size; +typedef u64 acpi_table_ptr; +typedef u32 acpi_io_address; +typedef u64 acpi_physical_address; +typedef u32 acpi_size; #define ALIGNED_ADDRESS_BOUNDARY 0x00000004 #define ACPI_MISALIGNED_TRANSFERS @@ -203,30 +196,27 @@ typedef u32 acpi_size; #error unknown ACPI_MACHINE_WIDTH #endif - /* * This type is used for bitfields in ACPI tables. The only type that is * even remotely portable is u8. Anything else is not portable, so * do not add any more bitfield types. */ -typedef u8 UINT8_BIT; -typedef acpi_native_uint ACPI_PTRDIFF; +typedef u8 UINT8_BIT; +typedef acpi_native_uint ACPI_PTRDIFF; /* * Pointer overlays to avoid lots of typecasting for * code that accepts both physical and logical pointers. */ -union acpi_pointers -{ - acpi_physical_address physical; - void *logical; - acpi_table_ptr value; +union acpi_pointers { + acpi_physical_address physical; + void *logical; + acpi_table_ptr value; }; -struct acpi_pointer -{ - u32 pointer_type; - union acpi_pointers pointer; +struct acpi_pointer { + u32 pointer_type; + union acpi_pointers pointer; }; /* pointer_types for above */ @@ -270,34 +260,29 @@ struct acpi_pointer #define NULL (void *) 0 #endif - /* * Local datatypes */ -typedef u32 acpi_status; /* All ACPI Exceptions */ -typedef u32 acpi_name; /* 4-byte ACPI name */ -typedef char * acpi_string; /* Null terminated ASCII string */ -typedef void * acpi_handle; /* Actually a ptr to an Node */ - -struct uint64_struct -{ - u32 lo; - u32 hi; +typedef u32 acpi_status; /* All ACPI Exceptions */ +typedef u32 acpi_name; /* 4-byte ACPI name */ +typedef char *acpi_string; /* Null terminated ASCII string */ +typedef void *acpi_handle; /* Actually a ptr to an Node */ + +struct uint64_struct { + u32 lo; + u32 hi; }; -union uint64_overlay -{ - u64 full; - struct uint64_struct part; +union uint64_overlay { + u64 full; + struct uint64_struct part; }; -struct uint32_struct -{ - u32 lo; - u32 hi; +struct uint32_struct { + u32 lo; + u32 hi; }; - /* * Acpi integer width. In ACPI version 1, integers are * 32 bits. In ACPI version 2, integers are 64 bits. @@ -309,26 +294,24 @@ struct uint32_struct /* 32-bit integers only, no 64-bit support */ -typedef u32 acpi_integer; +typedef u32 acpi_integer; #define ACPI_INTEGER_MAX ACPI_UINT32_MAX #define ACPI_INTEGER_BIT_SIZE 32 -#define ACPI_MAX_DECIMAL_DIGITS 10 /* 2^32 = 4,294,967,296 */ - -#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 32-bit divide */ +#define ACPI_MAX_DECIMAL_DIGITS 10 /* 2^32 = 4,294,967,296 */ +#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 32-bit divide */ #else /* 64-bit integers */ -typedef u64 acpi_integer; +typedef u64 acpi_integer; #define ACPI_INTEGER_MAX ACPI_UINT64_MAX #define ACPI_INTEGER_BIT_SIZE 64 -#define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */ - +#define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */ #if ACPI_MACHINE_WIDTH == 64 -#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */ +#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */ #endif #endif @@ -342,7 +325,6 @@ typedef u64 acpi_integer; */ #define ACPI_ROOT_OBJECT (acpi_handle) ACPI_PTR_ADD (char, NULL, ACPI_MAX_PTR) - /* * Initialization sequence */ @@ -409,7 +391,7 @@ typedef u64 acpi_integer; /* * Table types. These values are passed to the table related APIs */ -typedef u32 acpi_table_type; +typedef u32 acpi_table_type; #define ACPI_TABLE_RSDP (acpi_table_type) 0 #define ACPI_TABLE_DSDT (acpi_table_type) 1 @@ -430,22 +412,22 @@ typedef u32 acpi_table_type; * NOTE: Types must be kept in sync with the global acpi_ns_properties * and acpi_ns_type_names arrays. */ -typedef u32 acpi_object_type; +typedef u32 acpi_object_type; #define ACPI_TYPE_ANY 0x00 -#define ACPI_TYPE_INTEGER 0x01 /* Byte/Word/Dword/Zero/One/Ones */ +#define ACPI_TYPE_INTEGER 0x01 /* Byte/Word/Dword/Zero/One/Ones */ #define ACPI_TYPE_STRING 0x02 #define ACPI_TYPE_BUFFER 0x03 -#define ACPI_TYPE_PACKAGE 0x04 /* byte_const, multiple data_term/Constant/super_name */ +#define ACPI_TYPE_PACKAGE 0x04 /* byte_const, multiple data_term/Constant/super_name */ #define ACPI_TYPE_FIELD_UNIT 0x05 -#define ACPI_TYPE_DEVICE 0x06 /* Name, multiple Node */ +#define ACPI_TYPE_DEVICE 0x06 /* Name, multiple Node */ #define ACPI_TYPE_EVENT 0x07 -#define ACPI_TYPE_METHOD 0x08 /* Name, byte_const, multiple Code */ +#define ACPI_TYPE_METHOD 0x08 /* Name, byte_const, multiple Code */ #define ACPI_TYPE_MUTEX 0x09 #define ACPI_TYPE_REGION 0x0A -#define ACPI_TYPE_POWER 0x0B /* Name,byte_const,word_const,multi Node */ -#define ACPI_TYPE_PROCESSOR 0x0C /* Name,byte_const,Dword_const,byte_const,multi nm_o */ -#define ACPI_TYPE_THERMAL 0x0D /* Name, multiple Node */ +#define ACPI_TYPE_POWER 0x0B /* Name,byte_const,word_const,multi Node */ +#define ACPI_TYPE_PROCESSOR 0x0C /* Name,byte_const,Dword_const,byte_const,multi nm_o */ +#define ACPI_TYPE_THERMAL 0x0D /* Name, multiple Node */ #define ACPI_TYPE_BUFFER_FIELD 0x0E #define ACPI_TYPE_DDB_HANDLE 0x0F #define ACPI_TYPE_DEBUG_OBJECT 0x10 @@ -462,16 +444,16 @@ typedef u32 acpi_object_type; #define ACPI_TYPE_LOCAL_REGION_FIELD 0x11 #define ACPI_TYPE_LOCAL_BANK_FIELD 0x12 #define ACPI_TYPE_LOCAL_INDEX_FIELD 0x13 -#define ACPI_TYPE_LOCAL_REFERENCE 0x14 /* Arg#, Local#, Name, Debug, ref_of, Index */ +#define ACPI_TYPE_LOCAL_REFERENCE 0x14 /* Arg#, Local#, Name, Debug, ref_of, Index */ #define ACPI_TYPE_LOCAL_ALIAS 0x15 #define ACPI_TYPE_LOCAL_METHOD_ALIAS 0x16 #define ACPI_TYPE_LOCAL_NOTIFY 0x17 #define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18 #define ACPI_TYPE_LOCAL_RESOURCE 0x19 #define ACPI_TYPE_LOCAL_RESOURCE_FIELD 0x1A -#define ACPI_TYPE_LOCAL_SCOPE 0x1B /* 1 Name, multiple object_list Nodes */ +#define ACPI_TYPE_LOCAL_SCOPE 0x1B /* 1 Name, multiple object_list Nodes */ -#define ACPI_TYPE_NS_NODE_MAX 0x1B /* Last typecode used within a NS Node */ +#define ACPI_TYPE_NS_NODE_MAX 0x1B /* Last typecode used within a NS Node */ /* * These are special object types that never appear in @@ -515,7 +497,7 @@ typedef u32 acpi_object_type; #define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) #define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE) #define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR) -#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ +#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ #define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF /* @@ -528,7 +510,7 @@ typedef u32 acpi_object_type; /* * Event Types: Fixed & General Purpose */ -typedef u32 acpi_event_type; +typedef u32 acpi_event_type; /* * Fixed events @@ -556,7 +538,7 @@ typedef u32 acpi_event_type; * | +----- Set? * +----------- */ -typedef u32 acpi_event_status; +typedef u32 acpi_event_status; #define ACPI_EVENT_FLAG_DISABLED (acpi_event_status) 0x00 #define ACPI_EVENT_FLAG_ENABLED (acpi_event_status) 0x01 @@ -573,7 +555,6 @@ typedef u32 acpi_event_status; #define ACPI_GPE_ENABLE 0 #define ACPI_GPE_DISABLE 1 - /* * GPE info flags - Per GPE * +-+-+-+---+---+-+ @@ -594,22 +575,22 @@ typedef u32 acpi_event_status; #define ACPI_GPE_TYPE_MASK (u8) 0x06 #define ACPI_GPE_TYPE_WAKE_RUN (u8) 0x06 #define ACPI_GPE_TYPE_WAKE (u8) 0x02 -#define ACPI_GPE_TYPE_RUNTIME (u8) 0x04 /* Default */ +#define ACPI_GPE_TYPE_RUNTIME (u8) 0x04 /* Default */ #define ACPI_GPE_DISPATCH_MASK (u8) 0x18 #define ACPI_GPE_DISPATCH_HANDLER (u8) 0x08 #define ACPI_GPE_DISPATCH_METHOD (u8) 0x10 -#define ACPI_GPE_DISPATCH_NOT_USED (u8) 0x00 /* Default */ +#define ACPI_GPE_DISPATCH_NOT_USED (u8) 0x00 /* Default */ #define ACPI_GPE_RUN_ENABLE_MASK (u8) 0x20 #define ACPI_GPE_RUN_ENABLED (u8) 0x20 -#define ACPI_GPE_RUN_DISABLED (u8) 0x00 /* Default */ +#define ACPI_GPE_RUN_DISABLED (u8) 0x00 /* Default */ #define ACPI_GPE_WAKE_ENABLE_MASK (u8) 0x40 #define ACPI_GPE_WAKE_ENABLED (u8) 0x40 -#define ACPI_GPE_WAKE_DISABLED (u8) 0x00 /* Default */ +#define ACPI_GPE_WAKE_DISABLED (u8) 0x00 /* Default */ -#define ACPI_GPE_ENABLE_MASK (u8) 0x60 /* Both run/wake */ +#define ACPI_GPE_ENABLE_MASK (u8) 0x60 /* Both run/wake */ #define ACPI_GPE_SYSTEM_MASK (u8) 0x80 #define ACPI_GPE_SYSTEM_RUNNING (u8) 0x80 @@ -618,13 +599,12 @@ typedef u32 acpi_event_status; /* * Flags for GPE and Lock interfaces */ -#define ACPI_EVENT_WAKE_ENABLE 0x2 /* acpi_gpe_enable */ -#define ACPI_EVENT_WAKE_DISABLE 0x2 /* acpi_gpe_disable */ +#define ACPI_EVENT_WAKE_ENABLE 0x2 /* acpi_gpe_enable */ +#define ACPI_EVENT_WAKE_DISABLE 0x2 /* acpi_gpe_disable */ #define ACPI_NOT_ISR 0x1 #define ACPI_ISR 0x0 - /* Notify types */ #define ACPI_SYSTEM_NOTIFY 0x1 @@ -634,10 +614,9 @@ typedef u32 acpi_event_status; #define ACPI_MAX_SYS_NOTIFY 0x7f - /* Address Space (Operation Region) Types */ -typedef u8 acpi_adr_space_type; +typedef u8 acpi_adr_space_type; #define ACPI_ADR_SPACE_SYSTEM_MEMORY (acpi_adr_space_type) 0 #define ACPI_ADR_SPACE_SYSTEM_IO (acpi_adr_space_type) 1 @@ -649,7 +628,6 @@ typedef u8 acpi_adr_space_type; #define ACPI_ADR_SPACE_DATA_TABLE (acpi_adr_space_type) 7 #define ACPI_ADR_SPACE_FIXED_HARDWARE (acpi_adr_space_type) 127 - /* * bit_register IDs * These are bitfields defined within the full ACPI registers @@ -683,74 +661,62 @@ typedef u8 acpi_adr_space_type; #define ACPI_BITREG_MAX 0x15 #define ACPI_NUM_BITREG ACPI_BITREG_MAX + 1 - /* * External ACPI object definition */ -union acpi_object -{ - acpi_object_type type; /* See definition of acpi_ns_type for values */ - struct - { - acpi_object_type type; - acpi_integer value; /* The actual number */ +union acpi_object { + acpi_object_type type; /* See definition of acpi_ns_type for values */ + struct { + acpi_object_type type; + acpi_integer value; /* The actual number */ } integer; - struct - { - acpi_object_type type; - u32 length; /* # of bytes in string, excluding trailing null */ - char *pointer; /* points to the string value */ + struct { + acpi_object_type type; + u32 length; /* # of bytes in string, excluding trailing null */ + char *pointer; /* points to the string value */ } string; - struct - { - acpi_object_type type; - u32 length; /* # of bytes in buffer */ - u8 *pointer; /* points to the buffer */ + struct { + acpi_object_type type; + u32 length; /* # of bytes in buffer */ + u8 *pointer; /* points to the buffer */ } buffer; - struct - { - acpi_object_type type; - u32 fill1; - acpi_handle handle; /* object reference */ + struct { + acpi_object_type type; + u32 fill1; + acpi_handle handle; /* object reference */ } reference; - struct - { - acpi_object_type type; - u32 count; /* # of elements in package */ - union acpi_object *elements; /* Pointer to an array of ACPI_OBJECTs */ + struct { + acpi_object_type type; + u32 count; /* # of elements in package */ + union acpi_object *elements; /* Pointer to an array of ACPI_OBJECTs */ } package; - struct - { - acpi_object_type type; - u32 proc_id; - acpi_io_address pblk_address; - u32 pblk_length; + struct { + acpi_object_type type; + u32 proc_id; + acpi_io_address pblk_address; + u32 pblk_length; } processor; - struct - { - acpi_object_type type; - u32 system_level; - u32 resource_order; + struct { + acpi_object_type type; + u32 system_level; + u32 resource_order; } power_resource; }; - /* * List of objects, used as a parameter list for control method evaluation */ -struct acpi_object_list -{ - u32 count; - union acpi_object *pointer; +struct acpi_object_list { + u32 count; + union acpi_object *pointer; }; - /* * Miscellaneous common Data Structures used by the interfaces */ @@ -758,13 +724,11 @@ struct acpi_object_list #define ACPI_ALLOCATE_BUFFER (acpi_size) (-1) #define ACPI_ALLOCATE_LOCAL_BUFFER (acpi_size) (-2) -struct acpi_buffer -{ - acpi_size length; /* Length in bytes of the buffer */ - void *pointer; /* pointer to buffer */ +struct acpi_buffer { + acpi_size length; /* Length in bytes of the buffer */ + void *pointer; /* pointer to buffer */ }; - /* * name_type for acpi_get_name */ @@ -772,7 +736,6 @@ struct acpi_buffer #define ACPI_SINGLE_NAME 1 #define ACPI_NAME_TYPE_MAX 1 - /* * Structure and flags for acpi_get_system_info */ @@ -781,139 +744,106 @@ struct acpi_buffer #define ACPI_SYS_MODE_LEGACY 0x0002 #define ACPI_SYS_MODES_MASK 0x0003 - /* * ACPI Table Info. One per ACPI table _type_ */ -struct acpi_table_info -{ - u32 count; +struct acpi_table_info { + u32 count; }; - /* * System info returned by acpi_get_system_info() */ -struct acpi_system_info -{ - u32 acpi_ca_version; - u32 flags; - u32 timer_resolution; - u32 reserved1; - u32 reserved2; - u32 debug_level; - u32 debug_layer; - u32 num_table_types; - struct acpi_table_info table_info [NUM_ACPI_TABLE_TYPES]; +struct acpi_system_info { + u32 acpi_ca_version; + u32 flags; + u32 timer_resolution; + u32 reserved1; + u32 reserved2; + u32 debug_level; + u32 debug_layer; + u32 num_table_types; + struct acpi_table_info table_info[NUM_ACPI_TABLE_TYPES]; }; - /* * Types specific to the OS service interfaces */ -typedef u32 -(ACPI_SYSTEM_XFACE *acpi_osd_handler) ( - void *context); +typedef u32(ACPI_SYSTEM_XFACE * acpi_osd_handler) (void *context); typedef void -(ACPI_SYSTEM_XFACE *acpi_osd_exec_callback) ( - void *context); + (ACPI_SYSTEM_XFACE * acpi_osd_exec_callback) (void *context); /* * Various handlers and callback procedures */ -typedef -u32 (*acpi_event_handler) ( - void *context); +typedef u32(*acpi_event_handler) (void *context); typedef -void (*acpi_notify_handler) ( - acpi_handle device, - u32 value, - void *context); +void (*acpi_notify_handler) (acpi_handle device, u32 value, void *context); typedef -void (*acpi_object_handler) ( - acpi_handle object, - u32 function, - void *data); +void (*acpi_object_handler) (acpi_handle object, u32 function, void *data); -typedef -acpi_status (*acpi_init_handler) ( - acpi_handle object, - u32 function); +typedef acpi_status(*acpi_init_handler) (acpi_handle object, u32 function); #define ACPI_INIT_DEVICE_INI 1 typedef -acpi_status (*acpi_exception_handler) ( - acpi_status aml_status, - acpi_name name, - u16 opcode, - u32 aml_offset, - void *context); - +acpi_status(*acpi_exception_handler) (acpi_status aml_status, + acpi_name name, + u16 opcode, + u32 aml_offset, void *context); /* Address Spaces (For Operation Regions) */ typedef -acpi_status (*acpi_adr_space_handler) ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context); +acpi_status(*acpi_adr_space_handler) (u32 function, + acpi_physical_address address, + u32 bit_width, + acpi_integer * value, + void *handler_context, + void *region_context); #define ACPI_DEFAULT_HANDLER NULL - typedef -acpi_status (*acpi_adr_space_setup) ( - acpi_handle region_handle, - u32 function, - void *handler_context, - void **region_context); +acpi_status(*acpi_adr_space_setup) (acpi_handle region_handle, + u32 function, + void *handler_context, + void **region_context); #define ACPI_REGION_ACTIVATE 0 #define ACPI_REGION_DEACTIVATE 1 typedef -acpi_status (*acpi_walk_callback) ( - acpi_handle obj_handle, - u32 nesting_level, - void *context, - void **return_value); - +acpi_status(*acpi_walk_callback) (acpi_handle obj_handle, + u32 nesting_level, + void *context, void **return_value); /* Interrupt handler return values */ #define ACPI_INTERRUPT_NOT_HANDLED 0x00 #define ACPI_INTERRUPT_HANDLED 0x01 - /* Common string version of device HIDs and UIDs */ -struct acpi_device_id -{ - char value[ACPI_DEVICE_ID_LENGTH]; +struct acpi_device_id { + char value[ACPI_DEVICE_ID_LENGTH]; }; /* Common string version of device CIDs */ -struct acpi_compatible_id -{ - char value[ACPI_MAX_CID_LENGTH]; +struct acpi_compatible_id { + char value[ACPI_MAX_CID_LENGTH]; }; -struct acpi_compatible_id_list -{ - u32 count; - u32 size; - struct acpi_compatible_id id[1]; +struct acpi_compatible_id_list { + u32 count; + u32 size; + struct acpi_compatible_id id[1]; }; - /* Structure and flags for acpi_get_object_info */ #define ACPI_VALID_STA 0x0001 @@ -923,55 +853,45 @@ struct acpi_compatible_id_list #define ACPI_VALID_CID 0x0010 #define ACPI_VALID_SXDS 0x0020 - #define ACPI_COMMON_OBJ_INFO \ acpi_object_type type; /* ACPI object type */ \ - acpi_name name /* ACPI object Name */ - + acpi_name name /* ACPI object Name */ -struct acpi_obj_info_header -{ +struct acpi_obj_info_header { ACPI_COMMON_OBJ_INFO; }; - /* Structure returned from Get Object Info */ -struct acpi_device_info -{ +struct acpi_device_info { ACPI_COMMON_OBJ_INFO; - u32 valid; /* Indicates which fields below are valid */ - u32 current_status; /* _STA value */ - acpi_integer address; /* _ADR value if any */ - struct acpi_device_id hardware_id; /* _HID value if any */ - struct acpi_device_id unique_id; /* _UID value if any */ - u8 highest_dstates[4]; /* _sx_d values: 0xFF indicates not valid */ - struct acpi_compatible_id_list compatibility_id; /* List of _CIDs if any */ + u32 valid; /* Indicates which fields below are valid */ + u32 current_status; /* _STA value */ + acpi_integer address; /* _ADR value if any */ + struct acpi_device_id hardware_id; /* _HID value if any */ + struct acpi_device_id unique_id; /* _UID value if any */ + u8 highest_dstates[4]; /* _sx_d values: 0xFF indicates not valid */ + struct acpi_compatible_id_list compatibility_id; /* List of _CIDs if any */ }; - /* Context structs for address space handlers */ -struct acpi_pci_id -{ - u16 segment; - u16 bus; - u16 device; - u16 function; +struct acpi_pci_id { + u16 segment; + u16 bus; + u16 device; + u16 function; }; - -struct acpi_mem_space_context -{ - u32 length; - acpi_physical_address address; - acpi_physical_address mapped_physical_address; - u8 *mapped_logical_address; - acpi_size mapped_length; +struct acpi_mem_space_context { + u32 length; + acpi_physical_address address; + acpi_physical_address mapped_physical_address; + u8 *mapped_logical_address; + acpi_size mapped_length; }; - /* * Definitions for Resource Attributes */ @@ -1001,8 +921,8 @@ struct acpi_mem_space_context /* * IO Port Descriptor Decode */ -#define ACPI_DECODE_10 (u8) 0x00 /* 10-bit IO address decode */ -#define ACPI_DECODE_16 (u8) 0x01 /* 16-bit IO address decode */ +#define ACPI_DECODE_10 (u8) 0x00 /* 10-bit IO address decode */ +#define ACPI_DECODE_16 (u8) 0x01 /* 16-bit IO address decode */ /* * IRQ Attributes @@ -1054,32 +974,28 @@ struct acpi_mem_space_context #define ACPI_PRODUCER (u8) 0x00 #define ACPI_CONSUMER (u8) 0x01 - /* * Structures used to describe device resources */ -struct acpi_resource_irq -{ - u32 edge_level; - u32 active_high_low; - u32 shared_exclusive; - u32 number_of_interrupts; - u32 interrupts[1]; +struct acpi_resource_irq { + u32 edge_level; + u32 active_high_low; + u32 shared_exclusive; + u32 number_of_interrupts; + u32 interrupts[1]; }; -struct acpi_resource_dma -{ - u32 type; - u32 bus_master; - u32 transfer; - u32 number_of_channels; - u32 channels[1]; +struct acpi_resource_dma { + u32 type; + u32 bus_master; + u32 transfer; + u32 number_of_channels; + u32 channels[1]; }; -struct acpi_resource_start_dpf -{ - u32 compatibility_priority; - u32 performance_robustness; +struct acpi_resource_start_dpf { + u32 compatibility_priority; + u32 performance_robustness; }; /* @@ -1087,150 +1003,133 @@ struct acpi_resource_start_dpf * needed because it has no fields */ -struct acpi_resource_io -{ - u32 io_decode; - u32 min_base_address; - u32 max_base_address; - u32 alignment; - u32 range_length; +struct acpi_resource_io { + u32 io_decode; + u32 min_base_address; + u32 max_base_address; + u32 alignment; + u32 range_length; }; -struct acpi_resource_fixed_io -{ - u32 base_address; - u32 range_length; +struct acpi_resource_fixed_io { + u32 base_address; + u32 range_length; }; -struct acpi_resource_vendor -{ - u32 length; - u8 reserved[1]; +struct acpi_resource_vendor { + u32 length; + u8 reserved[1]; }; -struct acpi_resource_end_tag -{ - u8 checksum; +struct acpi_resource_end_tag { + u8 checksum; }; -struct acpi_resource_mem24 -{ - u32 read_write_attribute; - u32 min_base_address; - u32 max_base_address; - u32 alignment; - u32 range_length; +struct acpi_resource_mem24 { + u32 read_write_attribute; + u32 min_base_address; + u32 max_base_address; + u32 alignment; + u32 range_length; }; -struct acpi_resource_mem32 -{ - u32 read_write_attribute; - u32 min_base_address; - u32 max_base_address; - u32 alignment; - u32 range_length; +struct acpi_resource_mem32 { + u32 read_write_attribute; + u32 min_base_address; + u32 max_base_address; + u32 alignment; + u32 range_length; }; -struct acpi_resource_fixed_mem32 -{ - u32 read_write_attribute; - u32 range_base_address; - u32 range_length; +struct acpi_resource_fixed_mem32 { + u32 read_write_attribute; + u32 range_base_address; + u32 range_length; }; -struct acpi_memory_attribute -{ - u16 cache_attribute; - u16 read_write_attribute; +struct acpi_memory_attribute { + u16 cache_attribute; + u16 read_write_attribute; }; -struct acpi_io_attribute -{ - u16 range_attribute; - u16 translation_attribute; +struct acpi_io_attribute { + u16 range_attribute; + u16 translation_attribute; }; -struct acpi_bus_attribute -{ - u16 reserved1; - u16 reserved2; +struct acpi_bus_attribute { + u16 reserved1; + u16 reserved2; }; -union acpi_resource_attribute -{ - struct acpi_memory_attribute memory; - struct acpi_io_attribute io; - struct acpi_bus_attribute bus; +union acpi_resource_attribute { + struct acpi_memory_attribute memory; + struct acpi_io_attribute io; + struct acpi_bus_attribute bus; }; -struct acpi_resource_source -{ - u32 index; - u32 string_length; - char *string_ptr; +struct acpi_resource_source { + u32 index; + u32 string_length; + char *string_ptr; }; -struct acpi_resource_address16 -{ - u32 resource_type; - u32 producer_consumer; - u32 decode; - u32 min_address_fixed; - u32 max_address_fixed; - union acpi_resource_attribute attribute; - u32 granularity; - u32 min_address_range; - u32 max_address_range; - u32 address_translation_offset; - u32 address_length; - struct acpi_resource_source resource_source; +struct acpi_resource_address16 { + u32 resource_type; + u32 producer_consumer; + u32 decode; + u32 min_address_fixed; + u32 max_address_fixed; + union acpi_resource_attribute attribute; + u32 granularity; + u32 min_address_range; + u32 max_address_range; + u32 address_translation_offset; + u32 address_length; + struct acpi_resource_source resource_source; }; -struct acpi_resource_address32 -{ - u32 resource_type; - u32 producer_consumer; - u32 decode; - u32 min_address_fixed; - u32 max_address_fixed; - union acpi_resource_attribute attribute; - u32 granularity; - u32 min_address_range; - u32 max_address_range; - u32 address_translation_offset; - u32 address_length; - struct acpi_resource_source resource_source; +struct acpi_resource_address32 { + u32 resource_type; + u32 producer_consumer; + u32 decode; + u32 min_address_fixed; + u32 max_address_fixed; + union acpi_resource_attribute attribute; + u32 granularity; + u32 min_address_range; + u32 max_address_range; + u32 address_translation_offset; + u32 address_length; + struct acpi_resource_source resource_source; }; -struct acpi_resource_address64 -{ - u32 resource_type; - u32 producer_consumer; - u32 decode; - u32 min_address_fixed; - u32 max_address_fixed; - union acpi_resource_attribute attribute; - u64 granularity; - u64 min_address_range; - u64 max_address_range; - u64 address_translation_offset; - u64 address_length; - u64 type_specific_attributes; - struct acpi_resource_source resource_source; +struct acpi_resource_address64 { + u32 resource_type; + u32 producer_consumer; + u32 decode; + u32 min_address_fixed; + u32 max_address_fixed; + union acpi_resource_attribute attribute; + u64 granularity; + u64 min_address_range; + u64 max_address_range; + u64 address_translation_offset; + u64 address_length; + u64 type_specific_attributes; + struct acpi_resource_source resource_source; }; -struct acpi_resource_ext_irq -{ - u32 producer_consumer; - u32 edge_level; - u32 active_high_low; - u32 shared_exclusive; - u32 number_of_interrupts; - struct acpi_resource_source resource_source; - u32 interrupts[1]; +struct acpi_resource_ext_irq { + u32 producer_consumer; + u32 edge_level; + u32 active_high_low; + u32 shared_exclusive; + u32 number_of_interrupts; + struct acpi_resource_source resource_source; + u32 interrupts[1]; }; - /* ACPI_RESOURCE_TYPEs */ #define ACPI_RSTYPE_IRQ 0 @@ -1249,35 +1148,33 @@ struct acpi_resource_ext_irq #define ACPI_RSTYPE_ADDRESS64 13 #define ACPI_RSTYPE_EXT_IRQ 14 -typedef u32 acpi_resource_type; - -union acpi_resource_data -{ - struct acpi_resource_irq irq; - struct acpi_resource_dma dma; - struct acpi_resource_start_dpf start_dpf; - struct acpi_resource_io io; - struct acpi_resource_fixed_io fixed_io; - struct acpi_resource_vendor vendor_specific; - struct acpi_resource_end_tag end_tag; - struct acpi_resource_mem24 memory24; - struct acpi_resource_mem32 memory32; - struct acpi_resource_fixed_mem32 fixed_memory32; - struct acpi_resource_address16 address16; - struct acpi_resource_address32 address32; - struct acpi_resource_address64 address64; - struct acpi_resource_ext_irq extended_irq; +typedef u32 acpi_resource_type; + +union acpi_resource_data { + struct acpi_resource_irq irq; + struct acpi_resource_dma dma; + struct acpi_resource_start_dpf start_dpf; + struct acpi_resource_io io; + struct acpi_resource_fixed_io fixed_io; + struct acpi_resource_vendor vendor_specific; + struct acpi_resource_end_tag end_tag; + struct acpi_resource_mem24 memory24; + struct acpi_resource_mem32 memory32; + struct acpi_resource_fixed_mem32 fixed_memory32; + struct acpi_resource_address16 address16; + struct acpi_resource_address32 address32; + struct acpi_resource_address64 address64; + struct acpi_resource_ext_irq extended_irq; }; -struct acpi_resource -{ - acpi_resource_type id; - u32 length; - union acpi_resource_data data; +struct acpi_resource { + acpi_resource_type id; + u32 length; + union acpi_resource_data data; }; #define ACPI_RESOURCE_LENGTH 12 -#define ACPI_RESOURCE_LENGTH_NO_DATA 8 /* Id + Length fields */ +#define ACPI_RESOURCE_LENGTH_NO_DATA 8 /* Id + Length fields */ #define ACPI_SIZEOF_RESOURCE(type) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type)) @@ -1293,19 +1190,16 @@ struct acpi_resource * END: of definitions for Resource Attributes */ - -struct acpi_pci_routing_table -{ - u32 length; - u32 pin; - acpi_integer address; /* here for 64-bit alignment */ - u32 source_index; - char source[4]; /* pad to 64 bits so sizeof() works in all cases */ +struct acpi_pci_routing_table { + u32 length; + u32 pin; + acpi_integer address; /* here for 64-bit alignment */ + u32 source_index; + char source[4]; /* pad to 64 bits so sizeof() works in all cases */ }; /* * END: of definitions for PCI Routing tables */ - -#endif /* __ACTYPES_H__ */ +#endif /* __ACTYPES_H__ */ diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h index 0e7b0a3..c108645 100644 --- a/include/acpi/acutils.h +++ b/include/acpi/acutils.h @@ -44,20 +44,17 @@ #ifndef _ACUTILS_H #define _ACUTILS_H - typedef -acpi_status (*acpi_pkg_callback) ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context); - -struct acpi_pkg_info -{ - u8 *free_space; - acpi_size length; - u32 object_space; - u32 num_packages; +acpi_status(*acpi_pkg_callback) (u8 object_type, + union acpi_operand_object * source_object, + union acpi_generic_state * state, + void *context); + +struct acpi_pkg_info { + u8 *free_space; + acpi_size length; + u32 object_space; + u32 num_packages; }; #define REF_INCREMENT (u16) 0 @@ -71,163 +68,89 @@ struct acpi_pkg_info #define DB_DWORD_DISPLAY 4 #define DB_QWORD_DISPLAY 8 - /* * utglobal - Global data structures and procedures */ -void -acpi_ut_init_globals ( - void); +void acpi_ut_init_globals(void); #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) -char * -acpi_ut_get_mutex_name ( - u32 mutex_id); +char *acpi_ut_get_mutex_name(u32 mutex_id); #endif -char * -acpi_ut_get_type_name ( - acpi_object_type type); - -char * -acpi_ut_get_node_name ( - void *object); +char *acpi_ut_get_type_name(acpi_object_type type); -char * -acpi_ut_get_descriptor_name ( - void *object); +char *acpi_ut_get_node_name(void *object); -char * -acpi_ut_get_object_type_name ( - union acpi_operand_object *obj_desc); +char *acpi_ut_get_descriptor_name(void *object); -char * -acpi_ut_get_region_name ( - u8 space_id); +char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc); -char * -acpi_ut_get_event_name ( - u32 event_id); +char *acpi_ut_get_region_name(u8 space_id); -char -acpi_ut_hex_to_ascii_char ( - acpi_integer integer, - u32 position); +char *acpi_ut_get_event_name(u32 event_id); -u8 -acpi_ut_valid_object_type ( - acpi_object_type type); +char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position); +u8 acpi_ut_valid_object_type(acpi_object_type type); /* * utinit - miscellaneous initialization and shutdown */ -acpi_status -acpi_ut_hardware_initialize ( - void); - -void -acpi_ut_subsystem_shutdown ( - void); +acpi_status acpi_ut_hardware_initialize(void); -acpi_status -acpi_ut_validate_fadt ( - void); +void acpi_ut_subsystem_shutdown(void); +acpi_status acpi_ut_validate_fadt(void); /* * utclib - Local implementations of C library functions */ #ifndef ACPI_USE_SYSTEM_CLIBRARY -acpi_size -acpi_ut_strlen ( - const char *string); - -char * -acpi_ut_strcpy ( - char *dst_string, - const char *src_string); - -char * -acpi_ut_strncpy ( - char *dst_string, - const char *src_string, - acpi_size count); - -int -acpi_ut_memcmp ( - const char *buffer1, - const char *buffer2, - acpi_size count); - -int -acpi_ut_strncmp ( - const char *string1, - const char *string2, - acpi_size count); - -int -acpi_ut_strcmp ( - const char *string1, - const char *string2); - -char * -acpi_ut_strcat ( - char *dst_string, - const char *src_string); - -char * -acpi_ut_strncat ( - char *dst_string, - const char *src_string, - acpi_size count); - -u32 -acpi_ut_strtoul ( - const char *string, - char **terminator, - u32 base); - -char * -acpi_ut_strstr ( - char *string1, - char *string2); - -void * -acpi_ut_memcpy ( - void *dest, - const void *src, - acpi_size count); - -void * -acpi_ut_memset ( - void *dest, - acpi_native_uint value, - acpi_size count); - -int -acpi_ut_to_upper ( - int c); - -int -acpi_ut_to_lower ( - int c); +acpi_size acpi_ut_strlen(const char *string); + +char *acpi_ut_strcpy(char *dst_string, const char *src_string); + +char *acpi_ut_strncpy(char *dst_string, + const char *src_string, acpi_size count); + +int acpi_ut_memcmp(const char *buffer1, const char *buffer2, acpi_size count); + +int acpi_ut_strncmp(const char *string1, const char *string2, acpi_size count); + +int acpi_ut_strcmp(const char *string1, const char *string2); + +char *acpi_ut_strcat(char *dst_string, const char *src_string); + +char *acpi_ut_strncat(char *dst_string, + const char *src_string, acpi_size count); + +u32 acpi_ut_strtoul(const char *string, char **terminator, u32 base); + +char *acpi_ut_strstr(char *string1, char *string2); + +void *acpi_ut_memcpy(void *dest, const void *src, acpi_size count); + +void *acpi_ut_memset(void *dest, acpi_native_uint value, acpi_size count); + +int acpi_ut_to_upper(int c); + +int acpi_ut_to_lower(int c); extern const u8 _acpi_ctype[]; -#define _ACPI_XA 0x00 /* extra alphabetic - not supported */ -#define _ACPI_XS 0x40 /* extra space */ -#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ -#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ -#define _ACPI_DI 0x04 /* '0'-'9' */ -#define _ACPI_LO 0x02 /* 'a'-'z' */ -#define _ACPI_PU 0x10 /* punctuation */ -#define _ACPI_SP 0x08 /* space */ -#define _ACPI_UP 0x01 /* 'A'-'Z' */ -#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ +#define _ACPI_XA 0x00 /* extra alphabetic - not supported */ +#define _ACPI_XS 0x40 /* extra space */ +#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ +#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ +#define _ACPI_DI 0x04 /* '0'-'9' */ +#define _ACPI_LO 0x02 /* 'a'-'z' */ +#define _ACPI_PU 0x10 /* punctuation */ +#define _ACPI_SP 0x08 /* space */ +#define _ACPI_UP 0x01 /* 'A'-'Z' */ +#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ #define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI)) #define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP)) @@ -238,517 +161,323 @@ extern const u8 _acpi_ctype[]; #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) #define ACPI_IS_ASCII(c) ((c) < 0x80) -#endif /* ACPI_USE_SYSTEM_CLIBRARY */ - +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ /* * utcopy - Object construction and conversion interfaces */ acpi_status -acpi_ut_build_simple_object( - union acpi_operand_object *obj, - union acpi_object *user_obj, - u8 *data_space, - u32 *buffer_space_used); +acpi_ut_build_simple_object(union acpi_operand_object *obj, + union acpi_object *user_obj, + u8 * data_space, u32 * buffer_space_used); acpi_status -acpi_ut_build_package_object ( - union acpi_operand_object *obj, - u8 *buffer, - u32 *space_used); +acpi_ut_build_package_object(union acpi_operand_object *obj, + u8 * buffer, u32 * space_used); acpi_status -acpi_ut_copy_iobject_to_eobject ( - union acpi_operand_object *obj, - struct acpi_buffer *ret_buffer); +acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *obj, + struct acpi_buffer *ret_buffer); acpi_status -acpi_ut_copy_eobject_to_iobject ( - union acpi_object *obj, - union acpi_operand_object **internal_obj); +acpi_ut_copy_eobject_to_iobject(union acpi_object *obj, + union acpi_operand_object **internal_obj); acpi_status -acpi_ut_copy_isimple_to_isimple ( - union acpi_operand_object *source_obj, - union acpi_operand_object *dest_obj); +acpi_ut_copy_isimple_to_isimple(union acpi_operand_object *source_obj, + union acpi_operand_object *dest_obj); acpi_status -acpi_ut_copy_iobject_to_iobject ( - union acpi_operand_object *source_desc, - union acpi_operand_object **dest_desc, - struct acpi_walk_state *walk_state); - +acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc, + union acpi_operand_object **dest_desc, + struct acpi_walk_state *walk_state); /* * utcreate - Object creation */ acpi_status -acpi_ut_update_object_reference ( - union acpi_operand_object *object, - u16 action); - +acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action); /* * utdebug - Debug interfaces */ -void -acpi_ut_init_stack_ptr_trace ( - void); +void acpi_ut_init_stack_ptr_trace(void); -void -acpi_ut_track_stack_ptr ( - void); +void acpi_ut_track_stack_ptr(void); void -acpi_ut_trace ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id); +acpi_ut_trace(u32 line_number, + const char *function_name, char *module_name, u32 component_id); void -acpi_ut_trace_ptr ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - void *pointer); +acpi_ut_trace_ptr(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, void *pointer); void -acpi_ut_trace_u32 ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - u32 integer); +acpi_ut_trace_u32(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, u32 integer); void -acpi_ut_trace_str ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - char *string); +acpi_ut_trace_str(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, char *string); void -acpi_ut_exit ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id); +acpi_ut_exit(u32 line_number, + const char *function_name, char *module_name, u32 component_id); void -acpi_ut_status_exit ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - acpi_status status); +acpi_ut_status_exit(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, acpi_status status); void -acpi_ut_value_exit ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - acpi_integer value); +acpi_ut_value_exit(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, acpi_integer value); void -acpi_ut_ptr_exit ( - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - u8 *ptr); +acpi_ut_ptr_exit(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, u8 * ptr); -void -acpi_ut_report_info ( - char *module_name, - u32 line_number, - u32 component_id); +void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id); -void -acpi_ut_report_error ( - char *module_name, - u32 line_number, - u32 component_id); +void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id); void -acpi_ut_report_warning ( - char *module_name, - u32 line_number, - u32 component_id); +acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id); -void -acpi_ut_dump_buffer ( - u8 *buffer, - u32 count, - u32 display, - u32 component_id); +void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id); void ACPI_INTERNAL_VAR_XFACE -acpi_ut_debug_print ( - u32 requested_debug_level, - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - char *format, - ...) ACPI_PRINTF_LIKE_FUNC; +acpi_ut_debug_print(u32 requested_debug_level, + u32 line_number, + const char *function_name, + char *module_name, + u32 component_id, char *format, ...) ACPI_PRINTF_LIKE_FUNC; void ACPI_INTERNAL_VAR_XFACE -acpi_ut_debug_print_raw ( - u32 requested_debug_level, - u32 line_number, - const char *function_name, - char *module_name, - u32 component_id, - char *format, - ...) ACPI_PRINTF_LIKE_FUNC; - +acpi_ut_debug_print_raw(u32 requested_debug_level, + u32 line_number, + const char *function_name, + char *module_name, + u32 component_id, + char *format, ...) ACPI_PRINTF_LIKE_FUNC; /* * utdelete - Object deletion and reference counts */ -void -acpi_ut_add_reference ( - union acpi_operand_object *object); +void acpi_ut_add_reference(union acpi_operand_object *object); -void -acpi_ut_remove_reference ( - union acpi_operand_object *object); +void acpi_ut_remove_reference(union acpi_operand_object *object); -void -acpi_ut_delete_internal_package_object ( - union acpi_operand_object *object); - -void -acpi_ut_delete_internal_simple_object ( - union acpi_operand_object *object); +void acpi_ut_delete_internal_package_object(union acpi_operand_object *object); -void -acpi_ut_delete_internal_object_list ( - union acpi_operand_object **obj_list); +void acpi_ut_delete_internal_simple_object(union acpi_operand_object *object); +void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list); /* * uteval - object evaluation */ -acpi_status -acpi_ut_osi_implementation ( - struct acpi_walk_state *walk_state); +acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state); acpi_status -acpi_ut_evaluate_object ( - struct acpi_namespace_node *prefix_node, - char *path, - u32 expected_return_btypes, - union acpi_operand_object **return_desc); +acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, + char *path, + u32 expected_return_btypes, + union acpi_operand_object **return_desc); acpi_status -acpi_ut_evaluate_numeric_object ( - char *object_name, - struct acpi_namespace_node *device_node, - acpi_integer *address); +acpi_ut_evaluate_numeric_object(char *object_name, + struct acpi_namespace_node *device_node, + acpi_integer * address); acpi_status -acpi_ut_execute_HID ( - struct acpi_namespace_node *device_node, - struct acpi_device_id *hid); +acpi_ut_execute_HID(struct acpi_namespace_node *device_node, + struct acpi_device_id *hid); acpi_status -acpi_ut_execute_CID ( - struct acpi_namespace_node *device_node, - struct acpi_compatible_id_list **return_cid_list); +acpi_ut_execute_CID(struct acpi_namespace_node *device_node, + struct acpi_compatible_id_list **return_cid_list); acpi_status -acpi_ut_execute_STA ( - struct acpi_namespace_node *device_node, - u32 *status_flags); +acpi_ut_execute_STA(struct acpi_namespace_node *device_node, + u32 * status_flags); acpi_status -acpi_ut_execute_UID ( - struct acpi_namespace_node *device_node, - struct acpi_device_id *uid); +acpi_ut_execute_UID(struct acpi_namespace_node *device_node, + struct acpi_device_id *uid); acpi_status -acpi_ut_execute_sxds ( - struct acpi_namespace_node *device_node, - u8 *highest); - +acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest); /* * utobject - internal object create/delete/cache routines */ -union acpi_operand_object * -acpi_ut_create_internal_object_dbg ( - char *module_name, - u32 line_number, - u32 component_id, - acpi_object_type type); - -void * -acpi_ut_allocate_object_desc_dbg ( - char *module_name, - u32 line_number, - u32 component_id); +union acpi_operand_object *acpi_ut_create_internal_object_dbg(char *module_name, + u32 line_number, + u32 component_id, + acpi_object_type + type); + +void *acpi_ut_allocate_object_desc_dbg(char *module_name, + u32 line_number, u32 component_id); #define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_acpi_module_name,__LINE__,_COMPONENT,t) #define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_acpi_module_name,__LINE__,_COMPONENT) -void -acpi_ut_delete_object_desc ( - union acpi_operand_object *object); +void acpi_ut_delete_object_desc(union acpi_operand_object *object); -u8 -acpi_ut_valid_internal_object ( - void *object); +u8 acpi_ut_valid_internal_object(void *object); -union acpi_operand_object * -acpi_ut_create_buffer_object ( - acpi_size buffer_size); +union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size); -union acpi_operand_object * -acpi_ut_create_string_object ( - acpi_size string_size); +union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size); acpi_status -acpi_ut_get_object_size( - union acpi_operand_object *obj, - acpi_size *obj_length); - +acpi_ut_get_object_size(union acpi_operand_object *obj, acpi_size * obj_length); /* * utstate - Generic state creation/cache routines */ void -acpi_ut_push_generic_state ( - union acpi_generic_state **list_head, - union acpi_generic_state *state); - -union acpi_generic_state * -acpi_ut_pop_generic_state ( - union acpi_generic_state **list_head); +acpi_ut_push_generic_state(union acpi_generic_state **list_head, + union acpi_generic_state *state); +union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state + **list_head); -union acpi_generic_state * -acpi_ut_create_generic_state ( - void); +union acpi_generic_state *acpi_ut_create_generic_state(void); -struct acpi_thread_state * -acpi_ut_create_thread_state ( - void); +struct acpi_thread_state *acpi_ut_create_thread_state(void); -union acpi_generic_state * -acpi_ut_create_update_state ( - union acpi_operand_object *object, - u16 action); +union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object + *object, u16 action); -union acpi_generic_state * -acpi_ut_create_pkg_state ( - void *internal_object, - void *external_object, - u16 index); +union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object, + void *external_object, + u16 index); acpi_status -acpi_ut_create_update_state_and_push ( - union acpi_operand_object *object, - u16 action, - union acpi_generic_state **state_list); +acpi_ut_create_update_state_and_push(union acpi_operand_object *object, + u16 action, + union acpi_generic_state **state_list); #ifdef ACPI_FUTURE_USAGE acpi_status -acpi_ut_create_pkg_state_and_push ( - void *internal_object, - void *external_object, - u16 index, - union acpi_generic_state **state_list); -#endif /* ACPI_FUTURE_USAGE */ +acpi_ut_create_pkg_state_and_push(void *internal_object, + void *external_object, + u16 index, + union acpi_generic_state **state_list); +#endif /* ACPI_FUTURE_USAGE */ -union acpi_generic_state * -acpi_ut_create_control_state ( - void); - -void -acpi_ut_delete_generic_state ( - union acpi_generic_state *state); +union acpi_generic_state *acpi_ut_create_control_state(void); +void acpi_ut_delete_generic_state(union acpi_generic_state *state); /* * utmath */ acpi_status -acpi_ut_divide ( - acpi_integer in_dividend, - acpi_integer in_divisor, - acpi_integer *out_quotient, - acpi_integer *out_remainder); +acpi_ut_divide(acpi_integer in_dividend, + acpi_integer in_divisor, + acpi_integer * out_quotient, acpi_integer * out_remainder); acpi_status -acpi_ut_short_divide ( - acpi_integer in_dividend, - u32 divisor, - acpi_integer *out_quotient, - u32 *out_remainder); +acpi_ut_short_divide(acpi_integer in_dividend, + u32 divisor, + acpi_integer * out_quotient, u32 * out_remainder); /* * utmisc */ -acpi_status -acpi_ut_allocate_owner_id ( - acpi_owner_id *owner_id); +acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id); -void -acpi_ut_release_owner_id ( - acpi_owner_id *owner_id); +void acpi_ut_release_owner_id(acpi_owner_id * owner_id); acpi_status -acpi_ut_walk_package_tree ( - union acpi_operand_object *source_object, - void *target_object, - acpi_pkg_callback walk_callback, - void *context); +acpi_ut_walk_package_tree(union acpi_operand_object *source_object, + void *target_object, + acpi_pkg_callback walk_callback, void *context); -void -acpi_ut_strupr ( - char *src_string); +void acpi_ut_strupr(char *src_string); -void -acpi_ut_print_string ( - char *string, - u8 max_length); +void acpi_ut_print_string(char *string, u8 max_length); -u8 -acpi_ut_valid_acpi_name ( - u32 name); +u8 acpi_ut_valid_acpi_name(u32 name); -u8 -acpi_ut_valid_acpi_character ( - char character); +u8 acpi_ut_valid_acpi_character(char character); acpi_status -acpi_ut_strtoul64 ( - char *string, - u32 base, - acpi_integer *ret_integer); +acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer); /* Values for Base above (16=Hex, 10=Decimal) */ #define ACPI_ANY_BASE 0 -u8 * -acpi_ut_get_resource_end_tag ( - union acpi_operand_object *obj_desc); +u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc); -u8 -acpi_ut_generate_checksum ( - u8 *buffer, - u32 length); +u8 acpi_ut_generate_checksum(u8 * buffer, u32 length); -u32 -acpi_ut_dword_byte_swap ( - u32 value); +u32 acpi_ut_dword_byte_swap(u32 value); -void -acpi_ut_set_integer_width ( - u8 revision); +void acpi_ut_set_integer_width(u8 revision); #ifdef ACPI_DEBUG_OUTPUT void -acpi_ut_display_init_pathname ( - u8 type, - struct acpi_namespace_node *obj_handle, - char *path); +acpi_ut_display_init_pathname(u8 type, + struct acpi_namespace_node *obj_handle, + char *path); #endif - /* * utmutex - mutex support */ -acpi_status -acpi_ut_mutex_initialize ( - void); - -void -acpi_ut_mutex_terminate ( - void); +acpi_status acpi_ut_mutex_initialize(void); -acpi_status -acpi_ut_acquire_mutex ( - acpi_mutex_handle mutex_id); +void acpi_ut_mutex_terminate(void); -acpi_status -acpi_ut_release_mutex ( - acpi_mutex_handle mutex_id); +acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id); +acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id); /* * utalloc - memory allocation and object caching */ -acpi_status -acpi_ut_create_caches ( - void); +acpi_status acpi_ut_create_caches(void); -acpi_status -acpi_ut_delete_caches ( - void); +acpi_status acpi_ut_delete_caches(void); -acpi_status -acpi_ut_validate_buffer ( - struct acpi_buffer *buffer); +acpi_status acpi_ut_validate_buffer(struct acpi_buffer *buffer); acpi_status -acpi_ut_initialize_buffer ( - struct acpi_buffer *buffer, - acpi_size required_length); - -void * -acpi_ut_allocate ( - acpi_size size, - u32 component, - char *module, - u32 line); - -void * -acpi_ut_callocate ( - acpi_size size, - u32 component, - char *module, - u32 line); +acpi_ut_initialize_buffer(struct acpi_buffer *buffer, + acpi_size required_length); + +void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line); + +void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line); #ifdef ACPI_DBG_TRACK_ALLOCATIONS -void * -acpi_ut_allocate_and_track ( - acpi_size size, - u32 component, - char *module, - u32 line); - -void * -acpi_ut_callocate_and_track ( - acpi_size size, - u32 component, - char *module, - u32 line); +void *acpi_ut_allocate_and_track(acpi_size size, + u32 component, char *module, u32 line); + +void *acpi_ut_callocate_and_track(acpi_size size, + u32 component, char *module, u32 line); void -acpi_ut_free_and_track ( - void *address, - u32 component, - char *module, - u32 line); +acpi_ut_free_and_track(void *address, u32 component, char *module, u32 line); #ifdef ACPI_FUTURE_USAGE -void -acpi_ut_dump_allocation_info ( - void); -#endif /* ACPI_FUTURE_USAGE */ +void acpi_ut_dump_allocation_info(void); +#endif /* ACPI_FUTURE_USAGE */ -void -acpi_ut_dump_allocations ( - u32 component, - char *module); +void acpi_ut_dump_allocations(u32 component, char *module); #endif -#endif /* _ACUTILS_H */ +#endif /* _ACUTILS_H */ diff --git a/include/acpi/amlcode.h b/include/acpi/amlcode.h index 50a0889..7fdf5299 100644 --- a/include/acpi/amlcode.h +++ b/include/acpi/amlcode.h @@ -59,11 +59,11 @@ #define AML_WORD_OP (u16) 0x0b #define AML_DWORD_OP (u16) 0x0c #define AML_STRING_OP (u16) 0x0d -#define AML_QWORD_OP (u16) 0x0e /* ACPI 2.0 */ +#define AML_QWORD_OP (u16) 0x0e /* ACPI 2.0 */ #define AML_SCOPE_OP (u16) 0x10 #define AML_BUFFER_OP (u16) 0x11 #define AML_PACKAGE_OP (u16) 0x12 -#define AML_VAR_PACKAGE_OP (u16) 0x13 /* ACPI 2.0 */ +#define AML_VAR_PACKAGE_OP (u16) 0x13 /* ACPI 2.0 */ #define AML_METHOD_OP (u16) 0x14 #define AML_DUAL_NAME_PREFIX (u16) 0x2e #define AML_MULTI_NAME_PREFIX_OP (u16) 0x2f @@ -109,8 +109,8 @@ #define AML_FIND_SET_LEFT_BIT_OP (u16) 0x81 #define AML_FIND_SET_RIGHT_BIT_OP (u16) 0x82 #define AML_DEREF_OF_OP (u16) 0x83 -#define AML_CONCAT_RES_OP (u16) 0x84 /* ACPI 2.0 */ -#define AML_MOD_OP (u16) 0x85 /* ACPI 2.0 */ +#define AML_CONCAT_RES_OP (u16) 0x84 /* ACPI 2.0 */ +#define AML_MOD_OP (u16) 0x85 /* ACPI 2.0 */ #define AML_NOTIFY_OP (u16) 0x86 #define AML_SIZE_OF_OP (u16) 0x87 #define AML_INDEX_OP (u16) 0x88 @@ -120,21 +120,21 @@ #define AML_CREATE_BYTE_FIELD_OP (u16) 0x8c #define AML_CREATE_BIT_FIELD_OP (u16) 0x8d #define AML_TYPE_OP (u16) 0x8e -#define AML_CREATE_QWORD_FIELD_OP (u16) 0x8f /* ACPI 2.0 */ +#define AML_CREATE_QWORD_FIELD_OP (u16) 0x8f /* ACPI 2.0 */ #define AML_LAND_OP (u16) 0x90 #define AML_LOR_OP (u16) 0x91 #define AML_LNOT_OP (u16) 0x92 #define AML_LEQUAL_OP (u16) 0x93 #define AML_LGREATER_OP (u16) 0x94 #define AML_LLESS_OP (u16) 0x95 -#define AML_TO_BUFFER_OP (u16) 0x96 /* ACPI 2.0 */ -#define AML_TO_DECSTRING_OP (u16) 0x97 /* ACPI 2.0 */ -#define AML_TO_HEXSTRING_OP (u16) 0x98 /* ACPI 2.0 */ -#define AML_TO_INTEGER_OP (u16) 0x99 /* ACPI 2.0 */ -#define AML_TO_STRING_OP (u16) 0x9c /* ACPI 2.0 */ -#define AML_COPY_OP (u16) 0x9d /* ACPI 2.0 */ -#define AML_MID_OP (u16) 0x9e /* ACPI 2.0 */ -#define AML_CONTINUE_OP (u16) 0x9f /* ACPI 2.0 */ +#define AML_TO_BUFFER_OP (u16) 0x96 /* ACPI 2.0 */ +#define AML_TO_DECSTRING_OP (u16) 0x97 /* ACPI 2.0 */ +#define AML_TO_HEXSTRING_OP (u16) 0x98 /* ACPI 2.0 */ +#define AML_TO_INTEGER_OP (u16) 0x99 /* ACPI 2.0 */ +#define AML_TO_STRING_OP (u16) 0x9c /* ACPI 2.0 */ +#define AML_COPY_OP (u16) 0x9d /* ACPI 2.0 */ +#define AML_MID_OP (u16) 0x9e /* ACPI 2.0 */ +#define AML_CONTINUE_OP (u16) 0x9f /* ACPI 2.0 */ #define AML_IF_OP (u16) 0xa0 #define AML_ELSE_OP (u16) 0xa1 #define AML_WHILE_OP (u16) 0xa2 @@ -146,7 +146,7 @@ /* prefixed opcodes */ -#define AML_EXTENDED_OPCODE (u16) 0x5b00 /* prefix for 2-byte opcodes */ +#define AML_EXTENDED_OPCODE (u16) 0x5b00 /* prefix for 2-byte opcodes */ #define AML_MUTEX_OP (u16) 0x5b01 #define AML_EVENT_OP (u16) 0x5b02 @@ -154,7 +154,7 @@ #define AML_SHIFT_LEFT_BIT_OP (u16) 0x5b11 #define AML_COND_REF_OF_OP (u16) 0x5b12 #define AML_CREATE_FIELD_OP (u16) 0x5b13 -#define AML_LOAD_TABLE_OP (u16) 0x5b1f /* ACPI 2.0 */ +#define AML_LOAD_TABLE_OP (u16) 0x5b1f /* ACPI 2.0 */ #define AML_LOAD_OP (u16) 0x5b20 #define AML_STALL_OP (u16) 0x5b21 #define AML_SLEEP_OP (u16) 0x5b22 @@ -169,7 +169,7 @@ #define AML_REVISION_OP (u16) 0x5b30 #define AML_DEBUG_OP (u16) 0x5b31 #define AML_FATAL_OP (u16) 0x5b32 -#define AML_TIMER_OP (u16) 0x5b33 /* ACPI 3.0 */ +#define AML_TIMER_OP (u16) 0x5b33 /* ACPI 3.0 */ #define AML_REGION_OP (u16) 0x5b80 #define AML_FIELD_OP (u16) 0x5b81 #define AML_DEVICE_OP (u16) 0x5b82 @@ -178,8 +178,7 @@ #define AML_THERMAL_ZONE_OP (u16) 0x5b85 #define AML_INDEX_FIELD_OP (u16) 0x5b86 #define AML_BANK_FIELD_OP (u16) 0x5b87 -#define AML_DATA_REGION_OP (u16) 0x5b88 /* ACPI 2.0 */ - +#define AML_DATA_REGION_OP (u16) 0x5b88 /* ACPI 2.0 */ /* Bogus opcodes (they are actually two separate opcodes) */ @@ -187,7 +186,6 @@ #define AML_LLESSEQUAL_OP (u16) 0x9294 #define AML_LNOTEQUAL_OP (u16) 0x9293 - /* * Internal opcodes * Use only "Unknown" AML opcodes, don't attempt to use @@ -203,7 +201,6 @@ #define AML_INT_RETURN_VALUE_OP (u16) 0x0036 #define AML_INT_EVAL_SUBTREE_OP (u16) 0x0037 - #define ARG_NONE 0x0 /* @@ -245,7 +242,7 @@ /* Single, simple types */ -#define ARGI_ANYTYPE 0x01 /* Don't care */ +#define ARGI_ANYTYPE 0x01 /* Don't care */ #define ARGI_PACKAGE 0x02 #define ARGI_EVENT 0x03 #define ARGI_MUTEX 0x04 @@ -256,8 +253,8 @@ #define ARGI_INTEGER 0x06 #define ARGI_STRING 0x07 #define ARGI_BUFFER 0x08 -#define ARGI_BUFFER_OR_STRING 0x09 /* Used by MID op only */ -#define ARGI_COMPUTEDATA 0x0A /* Buffer, String, or Integer */ +#define ARGI_BUFFER_OR_STRING 0x09 /* Used by MID op only */ +#define ARGI_COMPUTEDATA 0x0A /* Buffer, String, or Integer */ /* Reference objects */ @@ -265,30 +262,28 @@ #define ARGI_OBJECT_REF 0x0C #define ARGI_DEVICE_REF 0x0D #define ARGI_REFERENCE 0x0E -#define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */ -#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */ -#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */ +#define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */ +#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */ +#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */ /* Multiple/complex types */ -#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by size_of operator*/ -#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */ -#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */ -#define ARGI_REGION_OR_FIELD 0x15 /* Used by LOAD op only */ +#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by size_of operator */ +#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */ +#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */ +#define ARGI_REGION_OR_FIELD 0x15 /* Used by LOAD op only */ #define ARGI_DATAREFOBJ 0x16 /* Note: types above can expand to 0x1F maximum */ #define ARGI_INVALID_OPCODE 0xFFFFFFFF - /* * hash offsets */ #define AML_EXTOP_HASH_OFFSET 22 #define AML_LNOT_HASH_OFFSET 19 - /* * opcode groups and types */ @@ -296,7 +291,6 @@ #define OPGRP_FIELD 0x02 #define OPGRP_BYTELIST 0x04 - /* * Opcode information */ @@ -322,31 +316,30 @@ /* Convenient flag groupings */ #define AML_FLAGS_EXEC_0A_0T_1R AML_HAS_RETVAL -#define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */ -#define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */ +#define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */ +#define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */ #define AML_FLAGS_EXEC_1A_1T_0R AML_HAS_ARGS | AML_HAS_TARGET -#define AML_FLAGS_EXEC_1A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* monadic2_r */ -#define AML_FLAGS_EXEC_2A_0T_0R AML_HAS_ARGS /* Dyadic1 */ -#define AML_FLAGS_EXEC_2A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Dyadic2 */ -#define AML_FLAGS_EXEC_2A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* dyadic2_r */ +#define AML_FLAGS_EXEC_1A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* monadic2_r */ +#define AML_FLAGS_EXEC_2A_0T_0R AML_HAS_ARGS /* Dyadic1 */ +#define AML_FLAGS_EXEC_2A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Dyadic2 */ +#define AML_FLAGS_EXEC_2A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* dyadic2_r */ #define AML_FLAGS_EXEC_2A_2T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL #define AML_FLAGS_EXEC_3A_0T_0R AML_HAS_ARGS #define AML_FLAGS_EXEC_3A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL #define AML_FLAGS_EXEC_6A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL - /* * The opcode Type is used in a dispatch table, do not change * without updating the table. */ #define AML_TYPE_EXEC_0A_0T_1R 0x00 -#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* Monadic1 */ -#define AML_TYPE_EXEC_1A_0T_1R 0x02 /* Monadic2 */ +#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* Monadic1 */ +#define AML_TYPE_EXEC_1A_0T_1R 0x02 /* Monadic2 */ #define AML_TYPE_EXEC_1A_1T_0R 0x03 -#define AML_TYPE_EXEC_1A_1T_1R 0x04 /* monadic2_r */ -#define AML_TYPE_EXEC_2A_0T_0R 0x05 /* Dyadic1 */ -#define AML_TYPE_EXEC_2A_0T_1R 0x06 /* Dyadic2 */ -#define AML_TYPE_EXEC_2A_1T_1R 0x07 /* dyadic2_r */ +#define AML_TYPE_EXEC_1A_1T_1R 0x04 /* monadic2_r */ +#define AML_TYPE_EXEC_2A_0T_0R 0x05 /* Dyadic1 */ +#define AML_TYPE_EXEC_2A_0T_1R 0x06 /* Dyadic2 */ +#define AML_TYPE_EXEC_2A_1T_1R 0x07 /* dyadic2_r */ #define AML_TYPE_EXEC_2A_2T_1R 0x08 #define AML_TYPE_EXEC_3A_0T_0R 0x09 #define AML_TYPE_EXEC_3A_1T_1R 0x0A @@ -399,40 +392,33 @@ #define AML_CLASS_METHOD_CALL 0x09 #define AML_CLASS_UNKNOWN 0x0A - /* Predefined Operation Region space_iDs */ -typedef enum -{ - REGION_MEMORY = 0, +typedef enum { + REGION_MEMORY = 0, REGION_IO, REGION_PCI_CONFIG, REGION_EC, REGION_SMBUS, REGION_CMOS, REGION_PCI_BAR, - REGION_DATA_TABLE, /* Internal use only */ - REGION_FIXED_HW = 0x7F - + REGION_DATA_TABLE, /* Internal use only */ + REGION_FIXED_HW = 0x7F } AML_REGION_TYPES; - /* Comparison operation codes for match_op operator */ -typedef enum -{ - MATCH_MTR = 0, - MATCH_MEQ = 1, - MATCH_MLE = 2, - MATCH_MLT = 3, - MATCH_MGE = 4, - MATCH_MGT = 5 - +typedef enum { + MATCH_MTR = 0, + MATCH_MEQ = 1, + MATCH_MLE = 2, + MATCH_MLT = 3, + MATCH_MGE = 4, + MATCH_MGT = 5 } AML_MATCH_OPERATOR; #define MAX_MATCH_OPERATOR 5 - /* * field_flags * @@ -450,60 +436,47 @@ typedef enum #define AML_FIELD_LOCK_RULE_MASK 0x10 #define AML_FIELD_UPDATE_RULE_MASK 0x60 - /* 1) Field Access Types */ -typedef enum -{ - AML_FIELD_ACCESS_ANY = 0x00, - AML_FIELD_ACCESS_BYTE = 0x01, - AML_FIELD_ACCESS_WORD = 0x02, - AML_FIELD_ACCESS_DWORD = 0x03, - AML_FIELD_ACCESS_QWORD = 0x04, /* ACPI 2.0 */ - AML_FIELD_ACCESS_BUFFER = 0x05 /* ACPI 2.0 */ - +typedef enum { + AML_FIELD_ACCESS_ANY = 0x00, + AML_FIELD_ACCESS_BYTE = 0x01, + AML_FIELD_ACCESS_WORD = 0x02, + AML_FIELD_ACCESS_DWORD = 0x03, + AML_FIELD_ACCESS_QWORD = 0x04, /* ACPI 2.0 */ + AML_FIELD_ACCESS_BUFFER = 0x05 /* ACPI 2.0 */ } AML_ACCESS_TYPE; - /* 2) Field Lock Rules */ -typedef enum -{ - AML_FIELD_LOCK_NEVER = 0x00, - AML_FIELD_LOCK_ALWAYS = 0x10 - +typedef enum { + AML_FIELD_LOCK_NEVER = 0x00, + AML_FIELD_LOCK_ALWAYS = 0x10 } AML_LOCK_RULE; - /* 3) Field Update Rules */ -typedef enum -{ - AML_FIELD_UPDATE_PRESERVE = 0x00, - AML_FIELD_UPDATE_WRITE_AS_ONES = 0x20, +typedef enum { + AML_FIELD_UPDATE_PRESERVE = 0x00, + AML_FIELD_UPDATE_WRITE_AS_ONES = 0x20, AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40 - } AML_UPDATE_RULE; - /* * Field Access Attributes. * This byte is extracted from the AML via the * access_as keyword */ -typedef enum -{ - AML_FIELD_ATTRIB_SMB_QUICK = 0x02, - AML_FIELD_ATTRIB_SMB_SEND_RCV = 0x04, - AML_FIELD_ATTRIB_SMB_BYTE = 0x06, - AML_FIELD_ATTRIB_SMB_WORD = 0x08, - AML_FIELD_ATTRIB_SMB_BLOCK = 0x0A, - AML_FIELD_ATTRIB_SMB_WORD_CALL = 0x0C, +typedef enum { + AML_FIELD_ATTRIB_SMB_QUICK = 0x02, + AML_FIELD_ATTRIB_SMB_SEND_RCV = 0x04, + AML_FIELD_ATTRIB_SMB_BYTE = 0x06, + AML_FIELD_ATTRIB_SMB_WORD = 0x08, + AML_FIELD_ATTRIB_SMB_BLOCK = 0x0A, + AML_FIELD_ATTRIB_SMB_WORD_CALL = 0x0C, AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D - } AML_ACCESS_ATTRIBUTE; - /* Bit fields in method_flags byte */ #define AML_METHOD_ARG_COUNT 0x07 @@ -516,5 +489,4 @@ typedef enum #define AML_METHOD_RESERVED1 0x02 #define AML_METHOD_RESERVED2 0x04 - -#endif /* __AMLCODE_H__ */ +#endif /* __AMLCODE_H__ */ diff --git a/include/acpi/amlresrc.h b/include/acpi/amlresrc.h index b20ec30..051786e 100644 --- a/include/acpi/amlresrc.h +++ b/include/acpi/amlresrc.h @@ -42,29 +42,27 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __AMLRESRC_H #define __AMLRESRC_H - #define ASL_RESNAME_ADDRESS "_ADR" #define ASL_RESNAME_ALIGNMENT "_ALN" #define ASL_RESNAME_ADDRESSSPACE "_ASI" #define ASL_RESNAME_ACCESSSIZE "_ASZ" #define ASL_RESNAME_TYPESPECIFICATTRIBUTES "_ATT" #define ASL_RESNAME_BASEADDRESS "_BAS" -#define ASL_RESNAME_BUSMASTER "_BM_" /* Master(1), Slave(0) */ +#define ASL_RESNAME_BUSMASTER "_BM_" /* Master(1), Slave(0) */ #define ASL_RESNAME_DECODE "_DEC" #define ASL_RESNAME_DMA "_DMA" -#define ASL_RESNAME_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ +#define ASL_RESNAME_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ #define ASL_RESNAME_GRANULARITY "_GRA" #define ASL_RESNAME_INTERRUPT "_INT" -#define ASL_RESNAME_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */ -#define ASL_RESNAME_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */ -#define ASL_RESNAME_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ +#define ASL_RESNAME_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */ +#define ASL_RESNAME_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */ +#define ASL_RESNAME_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ #define ASL_RESNAME_LENGTH "_LEN" -#define ASL_RESNAME_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ -#define ASL_RESNAME_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ +#define ASL_RESNAME_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ +#define ASL_RESNAME_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ #define ASL_RESNAME_MAXADDR "_MAX" #define ASL_RESNAME_MINADDR "_MIN" #define ASL_RESNAME_MAXTYPE "_MAF" @@ -72,12 +70,11 @@ #define ASL_RESNAME_REGISTERBITOFFSET "_RBO" #define ASL_RESNAME_REGISTERBITWIDTH "_RBW" #define ASL_RESNAME_RANGETYPE "_RNG" -#define ASL_RESNAME_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */ +#define ASL_RESNAME_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */ #define ASL_RESNAME_TRANSLATION "_TRA" -#define ASL_RESNAME_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ -#define ASL_RESNAME_TYPE "_TTP" /* Translation(1), Static (0) */ -#define ASL_RESNAME_XFERTYPE "_SIz" /* 8(0), 8_and16(1), 16(2) */ - +#define ASL_RESNAME_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ +#define ASL_RESNAME_TYPE "_TTP" /* Translation(1), Static (0) */ +#define ASL_RESNAME_XFERTYPE "_SIz" /* 8(0), 8_and16(1), 16(2) */ /* Default sizes for "small" resource descriptors */ @@ -89,15 +86,12 @@ #define ASL_RDESC_FIXED_IO_SIZE 0x03 #define ASL_RDESC_END_TAG_SIZE 0x01 - -struct asl_resource_node -{ - u32 buffer_length; - void *buffer; - struct asl_resource_node *next; +struct asl_resource_node { + u32 buffer_length; + void *buffer; + struct asl_resource_node *next; }; - /* * Resource descriptors defined in the ACPI specification. * @@ -106,214 +100,175 @@ struct asl_resource_node */ #pragma pack(1) -struct asl_irq_format_desc -{ - u8 descriptor_type; - u16 irq_mask; - u8 flags; +struct asl_irq_format_desc { + u8 descriptor_type; + u16 irq_mask; + u8 flags; }; - -struct asl_irq_noflags_desc -{ - u8 descriptor_type; - u16 irq_mask; +struct asl_irq_noflags_desc { + u8 descriptor_type; + u16 irq_mask; }; - -struct asl_dma_format_desc -{ - u8 descriptor_type; - u8 dma_channel_mask; - u8 flags; +struct asl_dma_format_desc { + u8 descriptor_type; + u8 dma_channel_mask; + u8 flags; }; - -struct asl_start_dependent_desc -{ - u8 descriptor_type; - u8 flags; +struct asl_start_dependent_desc { + u8 descriptor_type; + u8 flags; }; - -struct asl_start_dependent_noprio_desc -{ - u8 descriptor_type; +struct asl_start_dependent_noprio_desc { + u8 descriptor_type; }; - -struct asl_end_dependent_desc -{ - u8 descriptor_type; +struct asl_end_dependent_desc { + u8 descriptor_type; }; - -struct asl_io_port_desc -{ - u8 descriptor_type; - u8 information; - u16 address_min; - u16 address_max; - u8 alignment; - u8 length; +struct asl_io_port_desc { + u8 descriptor_type; + u8 information; + u16 address_min; + u16 address_max; + u8 alignment; + u8 length; }; - -struct asl_fixed_io_port_desc -{ - u8 descriptor_type; - u16 base_address; - u8 length; +struct asl_fixed_io_port_desc { + u8 descriptor_type; + u16 base_address; + u8 length; }; - -struct asl_small_vendor_desc -{ - u8 descriptor_type; - u8 vendor_defined[7]; +struct asl_small_vendor_desc { + u8 descriptor_type; + u8 vendor_defined[7]; }; - -struct asl_end_tag_desc -{ - u8 descriptor_type; - u8 checksum; +struct asl_end_tag_desc { + u8 descriptor_type; + u8 checksum; }; - /* LARGE descriptors */ -struct asl_memory_24_desc -{ - u8 descriptor_type; - u16 length; - u8 information; - u16 address_min; - u16 address_max; - u16 alignment; - u16 range_length; +struct asl_memory_24_desc { + u8 descriptor_type; + u16 length; + u8 information; + u16 address_min; + u16 address_max; + u16 alignment; + u16 range_length; }; - -struct asl_large_vendor_desc -{ - u8 descriptor_type; - u16 length; - u8 vendor_defined[1]; +struct asl_large_vendor_desc { + u8 descriptor_type; + u16 length; + u8 vendor_defined[1]; }; - -struct asl_memory_32_desc -{ - u8 descriptor_type; - u16 length; - u8 information; - u32 address_min; - u32 address_max; - u32 alignment; - u32 range_length; +struct asl_memory_32_desc { + u8 descriptor_type; + u16 length; + u8 information; + u32 address_min; + u32 address_max; + u32 alignment; + u32 range_length; }; - -struct asl_fixed_memory_32_desc -{ - u8 descriptor_type; - u16 length; - u8 information; - u32 base_address; - u32 range_length; +struct asl_fixed_memory_32_desc { + u8 descriptor_type; + u16 length; + u8 information; + u32 base_address; + u32 range_length; }; - -struct asl_extended_address_desc -{ - u8 descriptor_type; - u16 length; - u8 resource_type; - u8 flags; - u8 specific_flags; - u8 revision_iD; - u8 reserved; - u64 granularity; - u64 address_min; - u64 address_max; - u64 translation_offset; - u64 address_length; - u64 type_specific_attributes; - u8 optional_fields[2]; /* Used for length calculation only */ +struct asl_extended_address_desc { + u8 descriptor_type; + u16 length; + u8 resource_type; + u8 flags; + u8 specific_flags; + u8 revision_iD; + u8 reserved; + u64 granularity; + u64 address_min; + u64 address_max; + u64 translation_offset; + u64 address_length; + u64 type_specific_attributes; + u8 optional_fields[2]; /* Used for length calculation only */ }; -#define ASL_EXTENDED_ADDRESS_DESC_REVISION 1 /* ACPI 3.0 */ - - -struct asl_qword_address_desc -{ - u8 descriptor_type; - u16 length; - u8 resource_type; - u8 flags; - u8 specific_flags; - u64 granularity; - u64 address_min; - u64 address_max; - u64 translation_offset; - u64 address_length; - u8 optional_fields[2]; +#define ASL_EXTENDED_ADDRESS_DESC_REVISION 1 /* ACPI 3.0 */ + +struct asl_qword_address_desc { + u8 descriptor_type; + u16 length; + u8 resource_type; + u8 flags; + u8 specific_flags; + u64 granularity; + u64 address_min; + u64 address_max; + u64 translation_offset; + u64 address_length; + u8 optional_fields[2]; }; - -struct asl_dword_address_desc -{ - u8 descriptor_type; - u16 length; - u8 resource_type; - u8 flags; - u8 specific_flags; - u32 granularity; - u32 address_min; - u32 address_max; - u32 translation_offset; - u32 address_length; - u8 optional_fields[2]; +struct asl_dword_address_desc { + u8 descriptor_type; + u16 length; + u8 resource_type; + u8 flags; + u8 specific_flags; + u32 granularity; + u32 address_min; + u32 address_max; + u32 translation_offset; + u32 address_length; + u8 optional_fields[2]; }; - -struct asl_word_address_desc -{ - u8 descriptor_type; - u16 length; - u8 resource_type; - u8 flags; - u8 specific_flags; - u16 granularity; - u16 address_min; - u16 address_max; - u16 translation_offset; - u16 address_length; - u8 optional_fields[2]; +struct asl_word_address_desc { + u8 descriptor_type; + u16 length; + u8 resource_type; + u8 flags; + u8 specific_flags; + u16 granularity; + u16 address_min; + u16 address_max; + u16 translation_offset; + u16 address_length; + u8 optional_fields[2]; }; - -struct asl_extended_xrupt_desc -{ - u8 descriptor_type; - u16 length; - u8 flags; - u8 table_length; - u32 interrupt_number[1]; +struct asl_extended_xrupt_desc { + u8 descriptor_type; + u16 length; + u8 flags; + u8 table_length; + u32 interrupt_number[1]; /* res_source_index, res_source optional fields follow */ }; - -struct asl_general_register_desc -{ - u8 descriptor_type; - u16 length; - u8 address_space_id; - u8 bit_width; - u8 bit_offset; - u8 access_size; /* ACPI 3.0, was Reserved */ - u64 address; +struct asl_general_register_desc { + u8 descriptor_type; + u16 length; + u8 address_space_id; + u8 bit_width; + u8 bit_offset; + u8 access_size; /* ACPI 3.0, was Reserved */ + u64 address; }; /* restore default alignment */ @@ -322,32 +277,29 @@ struct asl_general_register_desc /* Union of all resource descriptors, so we can allocate the worst case */ -union asl_resource_desc -{ - struct asl_irq_format_desc irq; - struct asl_dma_format_desc dma; - struct asl_start_dependent_desc std; - struct asl_end_dependent_desc end; - struct asl_io_port_desc iop; - struct asl_fixed_io_port_desc fio; - struct asl_small_vendor_desc smv; - struct asl_end_tag_desc et; - - struct asl_memory_24_desc M24; - struct asl_large_vendor_desc lgv; - struct asl_memory_32_desc M32; - struct asl_fixed_memory_32_desc F32; - struct asl_qword_address_desc qas; - struct asl_dword_address_desc das; - struct asl_word_address_desc was; - struct asl_extended_address_desc eas; - struct asl_extended_xrupt_desc exx; - struct asl_general_register_desc grg; - u32 u32_item; - u16 u16_item; - u8 U8item; +union asl_resource_desc { + struct asl_irq_format_desc irq; + struct asl_dma_format_desc dma; + struct asl_start_dependent_desc std; + struct asl_end_dependent_desc end; + struct asl_io_port_desc iop; + struct asl_fixed_io_port_desc fio; + struct asl_small_vendor_desc smv; + struct asl_end_tag_desc et; + + struct asl_memory_24_desc M24; + struct asl_large_vendor_desc lgv; + struct asl_memory_32_desc M32; + struct asl_fixed_memory_32_desc F32; + struct asl_qword_address_desc qas; + struct asl_dword_address_desc das; + struct asl_word_address_desc was; + struct asl_extended_address_desc eas; + struct asl_extended_xrupt_desc exx; + struct asl_general_register_desc grg; + u32 u32_item; + u16 u16_item; + u8 U8item; }; - #endif - diff --git a/include/acpi/container.h b/include/acpi/container.h index d716df0..a703f14 100644 --- a/include/acpi/container.h +++ b/include/acpi/container.h @@ -9,5 +9,4 @@ struct acpi_container { int state; }; -#endif /* __ACPI_CONTAINER_H */ - +#endif /* __ACPI_CONTAINER_H */ diff --git a/include/acpi/pdc_intel.h b/include/acpi/pdc_intel.h index fd6730e..91f4a12 100644 --- a/include/acpi/pdc_intel.h +++ b/include/acpi/pdc_intel.h @@ -14,7 +14,6 @@ #define ACPI_PDC_SMP_T_SWCOORD (0x0080) #define ACPI_PDC_C_C1_FFH (0x0100) - #define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \ ACPI_PDC_C_C1_HALT) @@ -25,5 +24,4 @@ ACPI_PDC_SMP_C1PT | \ ACPI_PDC_C_C1_HALT) -#endif /* __PDC_INTEL_H__ */ - +#endif /* __PDC_INTEL_H__ */ diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index bae1fbe..16609c1 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -44,7 +44,6 @@ #ifndef __ACENV_H__ #define __ACENV_H__ - /* * Configuration for ACPI tools and utilities */ @@ -134,7 +133,7 @@ #elif defined(WIN64) #include "acwin64.h" -#elif defined(MSDOS) /* Must appear after WIN32 and WIN64 check */ +#elif defined(MSDOS) /* Must appear after WIN32 and WIN64 check */ #include "acdos16.h" #elif defined(__FreeBSD__) @@ -180,7 +179,6 @@ /*! [End] no source code translation !*/ - /* * Debugger threading model * Use single threaded if the entire subsystem is contained in an application @@ -199,8 +197,7 @@ #else #define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED #endif -#endif /* !DEBUGGER_THREADING */ - +#endif /* !DEBUGGER_THREADING */ /****************************************************************************** * @@ -222,7 +219,7 @@ #include #include -#endif /* ACPI_USE_STANDARD_HEADERS */ +#endif /* ACPI_USE_STANDARD_HEADERS */ /* * We will be linking to the standard Clib functions @@ -260,18 +257,18 @@ *****************************************************************************/ /* - * Use local definitions of C library macros and functions - * NOTE: The function implementations may not be as efficient - * as an inline or assembly code implementation provided by a - * native C library. - */ + * Use local definitions of C library macros and functions + * NOTE: The function implementations may not be as efficient + * as an inline or assembly code implementation provided by a + * native C library. + */ #ifndef va_arg #ifndef _VALIST #define _VALIST typedef char *va_list; -#endif /* _VALIST */ +#endif /* _VALIST */ /* * Storage alignment properties @@ -287,8 +284,7 @@ typedef char *va_list; #define va_end(ap) (void) 0 #define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND)))) -#endif /* va_arg */ - +#endif /* va_arg */ #define ACPI_STRSTR(s1,s2) acpi_ut_strstr ((s1), (s2)) #define ACPI_STRCHR(s1,c) acpi_ut_strchr ((s1), (c)) @@ -306,8 +302,7 @@ typedef char *va_list; #define ACPI_TOUPPER acpi_ut_to_upper #define ACPI_TOLOWER acpi_ut_to_lower -#endif /* ACPI_USE_SYSTEM_CLIBRARY */ - +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ /****************************************************************************** * @@ -348,8 +343,7 @@ typedef char *va_list; #define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq) #define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq) -#endif /* ACPI_ASM_MACROS */ - +#endif /* ACPI_ASM_MACROS */ #ifdef ACPI_APPLICATION @@ -359,11 +353,10 @@ typedef char *va_list; #define BREAKPOINT3 #endif - /****************************************************************************** * * Compiler-specific information is contained in the compiler-specific * headers. * *****************************************************************************/ -#endif /* __ACENV_H__ */ +#endif /* __ACENV_H__ */ diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h index 3926412..4c0e0ba 100644 --- a/include/acpi/platform/acgcc.h +++ b/include/acpi/platform/acgcc.h @@ -60,4 +60,4 @@ */ #define ACPI_UNUSED_VAR __attribute__ ((unused)) -#endif /* __ACGCC_H__ */ +#endif /* __ACGCC_H__ */ diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h index 4fbc0fd..c93e656 100644 --- a/include/acpi/platform/aclinux.h +++ b/include/acpi/platform/aclinux.h @@ -71,9 +71,7 @@ #define acpi_cache_t kmem_cache_t #endif - - -#else /* !__KERNEL__ */ +#else /* !__KERNEL__ */ #include #include @@ -94,10 +92,10 @@ #define __cdecl #define ACPI_FLUSH_CPU_CACHE() -#endif /* __KERNEL__ */ +#endif /* __KERNEL__ */ /* Linux uses GCC */ #include "acgcc.h" -#endif /* __ACLINUX_H__ */ +#endif /* __ACLINUX_H__ */ diff --git a/include/acpi/processor.h b/include/acpi/processor.h index 50cfea4..7a00d50 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h @@ -23,45 +23,44 @@ struct acpi_processor_cx; struct acpi_power_register { - u8 descriptor; - u16 length; - u8 space_id; - u8 bit_width; - u8 bit_offset; - u8 reserved; - u64 address; + u8 descriptor; + u16 length; + u8 space_id; + u8 bit_width; + u8 bit_offset; + u8 reserved; + u64 address; } __attribute__ ((packed)); - struct acpi_processor_cx_policy { - u32 count; + u32 count; struct acpi_processor_cx *state; struct { - u32 time; - u32 ticks; - u32 count; - u32 bm; - } threshold; + u32 time; + u32 ticks; + u32 count; + u32 bm; + } threshold; }; struct acpi_processor_cx { - u8 valid; - u8 type; - u32 address; - u32 latency; - u32 latency_ticks; - u32 power; - u32 usage; + u8 valid; + u8 type; + u32 address; + u32 latency; + u32 latency_ticks; + u32 power; + u32 usage; struct acpi_processor_cx_policy promotion; struct acpi_processor_cx_policy demotion; }; struct acpi_processor_power { struct acpi_processor_cx *state; - unsigned long bm_check_timestamp; - u32 default_state; - u32 bm_activity; - int count; + unsigned long bm_check_timestamp; + u32 default_state; + u32 bm_activity; + int count; struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER]; /* the _PDC objects passed by the driver, if any */ @@ -71,85 +70,82 @@ struct acpi_processor_power { /* Performance Management */ struct acpi_pct_register { - u8 descriptor; - u16 length; - u8 space_id; - u8 bit_width; - u8 bit_offset; - u8 reserved; - u64 address; + u8 descriptor; + u16 length; + u8 space_id; + u8 bit_width; + u8 bit_offset; + u8 reserved; + u64 address; } __attribute__ ((packed)); struct acpi_processor_px { - acpi_integer core_frequency; /* megahertz */ - acpi_integer power; /* milliWatts */ - acpi_integer transition_latency; /* microseconds */ - acpi_integer bus_master_latency; /* microseconds */ - acpi_integer control; /* control value */ - acpi_integer status; /* success indicator */ + acpi_integer core_frequency; /* megahertz */ + acpi_integer power; /* milliWatts */ + acpi_integer transition_latency; /* microseconds */ + acpi_integer bus_master_latency; /* microseconds */ + acpi_integer control; /* control value */ + acpi_integer status; /* success indicator */ }; struct acpi_processor_performance { - unsigned int state; - unsigned int platform_limit; + unsigned int state; + unsigned int platform_limit; struct acpi_pct_register control_register; struct acpi_pct_register status_register; - unsigned int state_count; + unsigned int state_count; struct acpi_processor_px *states; /* the _PDC objects passed by the driver, if any */ struct acpi_object_list *pdc; }; - - /* Throttling Control */ struct acpi_processor_tx { - u16 power; - u16 performance; + u16 power; + u16 performance; }; struct acpi_processor_throttling { - int state; - u32 address; - u8 duty_offset; - u8 duty_width; - int state_count; + int state; + u32 address; + u8 duty_offset; + u8 duty_width; + int state_count; struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING]; }; /* Limit Interface */ struct acpi_processor_lx { - int px; /* performace state */ - int tx; /* throttle level */ + int px; /* performace state */ + int tx; /* throttle level */ }; struct acpi_processor_limit { - struct acpi_processor_lx state; /* current limit */ + struct acpi_processor_lx state; /* current limit */ struct acpi_processor_lx thermal; /* thermal limit */ - struct acpi_processor_lx user; /* user limit */ + struct acpi_processor_lx user; /* user limit */ }; - struct acpi_processor_flags { - u8 power:1; - u8 performance:1; - u8 throttling:1; - u8 limit:1; - u8 bm_control:1; - u8 bm_check:1; - u8 has_cst:1; - u8 power_setup_done:1; + u8 power:1; + u8 performance:1; + u8 throttling:1; + u8 limit:1; + u8 bm_control:1; + u8 bm_check:1; + u8 has_cst:1; + u8 power_setup_done:1; }; struct acpi_processor { - acpi_handle handle; - u32 acpi_id; - u32 id; - u32 pblk; - int performance_platform_limit; + acpi_handle handle; + u32 acpi_id; + u32 id; + u32 pblk; + int performance_platform_limit; struct acpi_processor_flags flags; struct acpi_processor_power power; struct acpi_processor_performance *performance; @@ -158,50 +154,49 @@ struct acpi_processor { }; struct acpi_processor_errata { - u8 smp; + u8 smp; struct { - u8 throttle:1; - u8 fdma:1; - u8 reserved:6; - u32 bmisx; - } piix4; + u8 throttle:1; + u8 fdma:1; + u8 reserved:6; + u32 bmisx; + } piix4; }; -extern int acpi_processor_register_performance ( - struct acpi_processor_performance * performance, - unsigned int cpu); -extern void acpi_processor_unregister_performance ( - struct acpi_processor_performance * performance, - unsigned int cpu); +extern int acpi_processor_register_performance(struct acpi_processor_performance + *performance, unsigned int cpu); +extern void acpi_processor_unregister_performance(struct + acpi_processor_performance + *performance, + unsigned int cpu); /* note: this locks both the calling module and the processor module if a _PPC object exists, rmmod is disallowed then */ int acpi_processor_notify_smm(struct module *calling_module); - - /* for communication between multiple parts of the processor kernel module */ -extern struct acpi_processor *processors[NR_CPUS]; +extern struct acpi_processor *processors[NR_CPUS]; extern struct acpi_processor_errata errata; int acpi_processor_set_pdc(struct acpi_processor *pr, - struct acpi_object_list *pdc_in); + struct acpi_object_list *pdc_in); #ifdef ARCH_HAS_POWER_PDC_INIT void acpi_processor_power_init_pdc(struct acpi_processor_power *pow, - unsigned int cpu); + unsigned int cpu); void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, - unsigned int cpu); + unsigned int cpu); #else -static inline void acpi_processor_power_init_pdc( - struct acpi_processor_power *pow, unsigned int cpu) +static inline void acpi_processor_power_init_pdc(struct acpi_processor_power + *pow, unsigned int cpu) { pow->pdc = NULL; return; } -static inline void acpi_processor_power_init_bm_check( - struct acpi_processor_flags *flags, unsigned int cpu) +static inline void acpi_processor_power_init_bm_check(struct + acpi_processor_flags + *flags, unsigned int cpu) { flags->bm_check = 1; return; @@ -215,51 +210,62 @@ void acpi_processor_ppc_init(void); void acpi_processor_ppc_exit(void); int acpi_processor_ppc_has_changed(struct acpi_processor *pr); #else -static inline void acpi_processor_ppc_init(void) { return; } -static inline void acpi_processor_ppc_exit(void) { return; } -static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr) { +static inline void acpi_processor_ppc_init(void) +{ + return; +} +static inline void acpi_processor_ppc_exit(void) +{ + return; +} +static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr) +{ static unsigned int printout = 1; if (printout) { - printk(KERN_WARNING "Warning: Processor Platform Limit event detected, but not handled.\n"); - printk(KERN_WARNING "Consider compiling CPUfreq support into your kernel.\n"); + printk(KERN_WARNING + "Warning: Processor Platform Limit event detected, but not handled.\n"); + printk(KERN_WARNING + "Consider compiling CPUfreq support into your kernel.\n"); printout = 0; } return 0; } -#endif /* CONFIG_CPU_FREQ */ +#endif /* CONFIG_CPU_FREQ */ /* in processor_throttling.c */ -int acpi_processor_get_throttling_info (struct acpi_processor *pr); -int acpi_processor_set_throttling (struct acpi_processor *pr, int state); -ssize_t acpi_processor_write_throttling ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *data); +int acpi_processor_get_throttling_info(struct acpi_processor *pr); +int acpi_processor_set_throttling(struct acpi_processor *pr, int state); +ssize_t acpi_processor_write_throttling(struct file *file, + const char __user * buffer, + size_t count, loff_t * data); extern struct file_operations acpi_processor_throttling_fops; /* in processor_idle.c */ -int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *device); -int acpi_processor_cst_has_changed (struct acpi_processor *pr); -int acpi_processor_power_exit(struct acpi_processor *pr, struct acpi_device *device); - +int acpi_processor_power_init(struct acpi_processor *pr, + struct acpi_device *device); +int acpi_processor_cst_has_changed(struct acpi_processor *pr); +int acpi_processor_power_exit(struct acpi_processor *pr, + struct acpi_device *device); /* in processor_thermal.c */ -int acpi_processor_get_limit_info (struct acpi_processor *pr); -ssize_t acpi_processor_write_limit ( - struct file *file, - const char __user *buffer, - size_t count, - loff_t *data); +int acpi_processor_get_limit_info(struct acpi_processor *pr); +ssize_t acpi_processor_write_limit(struct file *file, + const char __user * buffer, + size_t count, loff_t * data); extern struct file_operations acpi_processor_limit_fops; #ifdef CONFIG_CPU_FREQ void acpi_thermal_cpufreq_init(void); void acpi_thermal_cpufreq_exit(void); #else -static inline void acpi_thermal_cpufreq_init(void) { return; } -static inline void acpi_thermal_cpufreq_exit(void) { return; } +static inline void acpi_thermal_cpufreq_init(void) +{ + return; +} +static inline void acpi_thermal_cpufreq_exit(void) +{ + return; +} #endif - #endif -- cgit v0.10.2 From 1f3a730117ceda2a7c917d687921fe3c82283968 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Fri, 5 Aug 2005 03:33:14 -0400 Subject: [ACPI] Lindent created a syntax error that broke the build Signed-off-by: Len Brown diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index 98d119c..09700d8 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c @@ -94,7 +94,7 @@ static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; #define MAX_MADT_ENTRIES 256 u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] = - {[0...MAX_MADT_ENTRIES - 1] = 0xff }; + {[0 ... MAX_MADT_ENTRIES - 1] = 0xff }; EXPORT_SYMBOL(x86_acpiid_to_apicid); /* -------------------------------------------------------------------------- -- cgit v0.10.2 From 541e316aed6f7d6efeb427a88645c2a8f61418d6 Mon Sep 17 00:00:00 2001 From: Stephen Evanchik Date: Mon, 8 Aug 2005 01:26:18 -0500 Subject: Input: psmouse - add support for IBM TrackPoint devices. Signed-off-by: Dmitry Torokhov diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile index c4909b4..82b330b 100644 --- a/drivers/input/mouse/Makefile +++ b/drivers/input/mouse/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o -psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o +psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 2bb2fe7..b350827 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -25,6 +25,7 @@ #include "logips2pp.h" #include "alps.h" #include "lifebook.h" +#include "trackpoint.h" #define DRIVER_DESC "PS/2 mouse driver" @@ -520,6 +521,12 @@ static int psmouse_extensions(struct psmouse *psmouse, return PSMOUSE_IMPS; /* + * Try to initialize the IBM TrackPoint + */ + if (max_proto > PSMOUSE_IMEX && trackpoint_detect(psmouse, set_properties) == 0) + return PSMOUSE_TRACKPOINT; + +/* * Okay, all failed, we have a standard mouse here. The number of the buttons * is still a question, though. We assume 3. */ @@ -600,6 +607,12 @@ static struct psmouse_protocol psmouse_protocols[] = { .init = lifebook_init, }, { + .type = PSMOUSE_TRACKPOINT, + .name = "TPPS/2", + .alias = "trackpoint", + .detect = trackpoint_detect, + }, + { .type = PSMOUSE_AUTO, .name = "auto", .alias = "any", @@ -1234,7 +1247,7 @@ static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) *((unsigned int *)kp->arg) = proto->type; - return 0; \ + return 0; } static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp) diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index 86691cf..e312a6b 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h @@ -78,6 +78,7 @@ enum psmouse_type { PSMOUSE_SYNAPTICS, PSMOUSE_ALPS, PSMOUSE_LIFEBOOK, + PSMOUSE_TRACKPOINT, PSMOUSE_AUTO /* This one should always be last */ }; diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c new file mode 100644 index 0000000..aee3b24 --- /dev/null +++ b/drivers/input/mouse/trackpoint.c @@ -0,0 +1,297 @@ +/* + * Stephen Evanchik + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * Trademarks are the property of their respective owners. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "psmouse.h" +#include "trackpoint.h" + +PSMOUSE_DEFINE_ATTR(sensitivity); +PSMOUSE_DEFINE_ATTR(speed); +PSMOUSE_DEFINE_ATTR(inertia); +PSMOUSE_DEFINE_ATTR(reach); +PSMOUSE_DEFINE_ATTR(draghys); +PSMOUSE_DEFINE_ATTR(mindrag); +PSMOUSE_DEFINE_ATTR(thresh); +PSMOUSE_DEFINE_ATTR(upthresh); +PSMOUSE_DEFINE_ATTR(ztime); +PSMOUSE_DEFINE_ATTR(jenks); +PSMOUSE_DEFINE_ATTR(press_to_select); +PSMOUSE_DEFINE_ATTR(skipback); +PSMOUSE_DEFINE_ATTR(ext_dev); + +#define MAKE_ATTR_READ(_item) \ + static ssize_t psmouse_attr_show_##_item(struct psmouse *psmouse, char *buf) \ + { \ + struct trackpoint_data *tp = psmouse->private; \ + return sprintf(buf, "%lu\n", (unsigned long)tp->_item); \ + } + +#define MAKE_ATTR_WRITE(_item, command) \ + static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse, const char *buf, size_t count) \ + { \ + char *rest; \ + unsigned long value; \ + struct trackpoint_data *tp = psmouse->private; \ + value = simple_strtoul(buf, &rest, 10); \ + if (*rest) \ + return -EINVAL; \ + tp->_item = value; \ + trackpoint_write(&psmouse->ps2dev, command, tp->_item); \ + return count; \ + } + +#define MAKE_ATTR_TOGGLE(_item, command, mask) \ + static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse, const char *buf, size_t count) \ + { \ + unsigned char toggle; \ + struct trackpoint_data *tp = psmouse->private; \ + toggle = (buf[0] == '1') ? 1 : 0; \ + if (toggle != tp->_item) { \ + tp->_item = toggle; \ + trackpoint_toggle_bit(&psmouse->ps2dev, command, mask); \ + } \ + return count; \ + } + +/* + * Device IO: read, write and toggle bit + */ +static int trackpoint_read(struct ps2dev *ps2dev, unsigned char loc, unsigned char *results) +{ + if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || + ps2_command(ps2dev, results, MAKE_PS2_CMD(0, 1, loc))) { + return -1; + } + + return 0; +} + +static int trackpoint_write(struct ps2dev *ps2dev, unsigned char loc, unsigned char val) +{ + if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_WRITE_MEM)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, loc)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, val))) { + return -1; + } + + return 0; +} + +static int trackpoint_toggle_bit(struct ps2dev *ps2dev, unsigned char loc, unsigned char mask) +{ + /* Bad things will happen if the loc param isn't in this range */ + if (loc < 0x20 || loc >= 0x2F) + return -1; + + if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_TOGGLE)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, loc)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, mask))) { + return -1; + } + + return 0; +} + +MAKE_ATTR_WRITE(sensitivity, TP_SENS); +MAKE_ATTR_READ(sensitivity); + +MAKE_ATTR_WRITE(speed, TP_SPEED); +MAKE_ATTR_READ(speed); + +MAKE_ATTR_WRITE(inertia, TP_INERTIA); +MAKE_ATTR_READ(inertia); + +MAKE_ATTR_WRITE(reach, TP_REACH); +MAKE_ATTR_READ(reach); + +MAKE_ATTR_WRITE(draghys, TP_DRAGHYS); +MAKE_ATTR_READ(draghys); + +MAKE_ATTR_WRITE(mindrag, TP_MINDRAG); +MAKE_ATTR_READ(mindrag); + +MAKE_ATTR_WRITE(thresh, TP_THRESH); +MAKE_ATTR_READ(thresh); + +MAKE_ATTR_WRITE(upthresh, TP_UP_THRESH); +MAKE_ATTR_READ(upthresh); + +MAKE_ATTR_WRITE(ztime, TP_Z_TIME); +MAKE_ATTR_READ(ztime); + +MAKE_ATTR_WRITE(jenks, TP_JENKS_CURV); +MAKE_ATTR_READ(jenks); + +MAKE_ATTR_TOGGLE(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON); +MAKE_ATTR_READ(press_to_select); + +MAKE_ATTR_TOGGLE(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); +MAKE_ATTR_READ(skipback); + +MAKE_ATTR_TOGGLE(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); +MAKE_ATTR_READ(ext_dev); + +static struct attribute *trackpoint_attrs[] = { + &psmouse_attr_sensitivity.attr, + &psmouse_attr_speed.attr, + &psmouse_attr_inertia.attr, + &psmouse_attr_reach.attr, + &psmouse_attr_draghys.attr, + &psmouse_attr_mindrag.attr, + &psmouse_attr_thresh.attr, + &psmouse_attr_upthresh.attr, + &psmouse_attr_ztime.attr, + &psmouse_attr_jenks.attr, + &psmouse_attr_press_to_select.attr, + &psmouse_attr_skipback.attr, + &psmouse_attr_ext_dev.attr, + NULL +}; + +static struct attribute_group trackpoint_attr_group = { + .attrs = trackpoint_attrs, +}; + +static void trackpoint_disconnect(struct psmouse *psmouse) +{ + sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, &trackpoint_attr_group); + + kfree(psmouse->private); + psmouse->private = NULL; +} + +static int trackpoint_sync(struct psmouse *psmouse) +{ + unsigned char toggle; + struct trackpoint_data *tp = psmouse->private; + + if (!tp) + return -1; + + /* Disable features that may make device unusable with this driver */ + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, &toggle); + if (toggle & TP_MASK_TWOHAND) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, TP_MASK_TWOHAND); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG, &toggle); + if (toggle & TP_MASK_SOURCE_TAG) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG, TP_MASK_SOURCE_TAG); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_MB, &toggle); + if (toggle & TP_MASK_MB) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_MB, TP_MASK_MB); + + /* Push the config to the device */ + trackpoint_write(&psmouse->ps2dev, TP_SENS, tp->sensitivity); + trackpoint_write(&psmouse->ps2dev, TP_INERTIA, tp->inertia); + trackpoint_write(&psmouse->ps2dev, TP_SPEED, tp->speed); + + trackpoint_write(&psmouse->ps2dev, TP_REACH, tp->reach); + trackpoint_write(&psmouse->ps2dev, TP_DRAGHYS, tp->draghys); + trackpoint_write(&psmouse->ps2dev, TP_MINDRAG, tp->mindrag); + + trackpoint_write(&psmouse->ps2dev, TP_THRESH, tp->thresh); + trackpoint_write(&psmouse->ps2dev, TP_UP_THRESH, tp->upthresh); + + trackpoint_write(&psmouse->ps2dev, TP_Z_TIME, tp->ztime); + trackpoint_write(&psmouse->ps2dev, TP_JENKS_CURV, tp->jenks); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_PTSON, &toggle); + if (((toggle & TP_MASK_PTSON) == TP_MASK_PTSON) != tp->press_to_select) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_PTSON, TP_MASK_PTSON); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_SKIPBACK, &toggle); + if (((toggle & TP_MASK_SKIPBACK) == TP_MASK_SKIPBACK) != tp->skipback) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_EXT_DEV, &toggle); + if (((toggle & TP_MASK_EXT_DEV) == TP_MASK_EXT_DEV) != tp->ext_dev) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); + + return 0; +} + +static void trackpoint_defaults(struct trackpoint_data *tp) +{ + tp->press_to_select = TP_DEF_PTSON; + tp->sensitivity = TP_DEF_SENS; + tp->speed = TP_DEF_SPEED; + tp->reach = TP_DEF_REACH; + + tp->draghys = TP_DEF_DRAGHYS; + tp->mindrag = TP_DEF_MINDRAG; + + tp->thresh = TP_DEF_THRESH; + tp->upthresh = TP_DEF_UP_THRESH; + + tp->ztime = TP_DEF_Z_TIME; + tp->jenks = TP_DEF_JENKS_CURV; + + tp->inertia = TP_DEF_INERTIA; + tp->skipback = TP_DEF_SKIPBACK; + tp->ext_dev = TP_DEF_EXT_DEV; +} + +int trackpoint_detect(struct psmouse *psmouse, int set_properties) +{ + struct trackpoint_data *priv; + struct ps2dev *ps2dev = &psmouse->ps2dev; + unsigned char firmware_id; + unsigned char button_info; + unsigned char param[2]; + + param[0] = param[1] = 0; + + if (ps2_command(ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID))) + return -1; + + if (param[0] != TP_MAGIC_IDENT) + return -1; + + if (!set_properties) + return 0; + + firmware_id = param[1]; + + if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) { + printk(KERN_WARNING "trackpoint.c: failed to get extended button data\n"); + button_info = 0; + } + + psmouse->private = priv = kcalloc(1, sizeof(struct trackpoint_data), GFP_KERNEL); + if (!priv) + return -1; + + psmouse->vendor = "IBM"; + psmouse->name = "TrackPoint"; + + psmouse->reconnect = trackpoint_sync; + psmouse->disconnect = trackpoint_disconnect; + + trackpoint_defaults(priv); + trackpoint_sync(psmouse); + + sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group); + + printk(KERN_INFO "IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n", + firmware_id, (button_info & 0xf0) >> 4, button_info & 0x0f); + + return 0; +} + diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h new file mode 100644 index 0000000..9857d8b --- /dev/null +++ b/drivers/input/mouse/trackpoint.h @@ -0,0 +1,147 @@ +/* + * IBM TrackPoint PS/2 mouse driver + * + * Stephen Evanchik + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + */ + +#ifndef _TRACKPOINT_H +#define _TRACKPOINT_H + +/* + * These constants are from the TrackPoint System + * Engineering documentation Version 4 from IBM Watson + * research: + * http://wwwcssrv.almaden.ibm.com/trackpoint/download.html + */ + +#define TP_COMMAND 0xE2 /* Commands start with this */ + +#define TP_READ_ID 0xE1 /* Sent for device identification */ +#define TP_MAGIC_IDENT 0x01 /* Sent after a TP_READ_ID followed */ + /* by the firmware ID */ + + +/* + * Commands + */ +#define TP_RECALIB 0x51 /* Recalibrate */ +#define TP_POWER_DOWN 0x44 /* Can only be undone through HW reset */ +#define TP_EXT_DEV 0x21 /* Determines if external device is connected (RO) */ +#define TP_EXT_BTN 0x4B /* Read extended button status */ +#define TP_POR 0x7F /* Execute Power on Reset */ +#define TP_POR_RESULTS 0x25 /* Read Power on Self test results */ +#define TP_DISABLE_EXT 0x40 /* Disable external pointing device */ +#define TP_ENABLE_EXT 0x41 /* Enable external pointing device */ + +/* + * Mode manipulation + */ +#define TP_SET_SOFT_TRANS 0x4E /* Set mode */ +#define TP_CANCEL_SOFT_TRANS 0xB9 /* Cancel mode */ +#define TP_SET_HARD_TRANS 0x45 /* Mode can only be set */ + + +/* + * Register oriented commands/properties + */ +#define TP_WRITE_MEM 0x81 +#define TP_READ_MEM 0x80 /* Not used in this implementation */ + +/* +* RAM Locations for properties + */ +#define TP_SENS 0x4A /* Sensitivity */ +#define TP_MB 0x4C /* Read Middle Button Status (RO) */ +#define TP_INERTIA 0x4D /* Negative Inertia */ +#define TP_SPEED 0x60 /* Speed of TP Cursor */ +#define TP_REACH 0x57 /* Backup for Z-axis press */ +#define TP_DRAGHYS 0x58 /* Drag Hysteresis */ + /* (how hard it is to drag */ + /* with Z-axis pressed) */ + +#define TP_MINDRAG 0x59 /* Minimum amount of force needed */ + /* to trigger dragging */ + +#define TP_THRESH 0x5C /* Minimum value for a Z-axis press */ +#define TP_UP_THRESH 0x5A /* Used to generate a 'click' on Z-axis */ +#define TP_Z_TIME 0x5E /* How sharp of a press */ +#define TP_JENKS_CURV 0x5D /* Minimum curvature for double click */ + +/* + * Toggling Flag bits + */ +#define TP_TOGGLE 0x47 /* Toggle command */ + +#define TP_TOGGLE_MB 0x23 /* Disable/Enable Middle Button */ +#define TP_MASK_MB 0x01 +#define TP_TOGGLE_EXT_DEV 0x23 /* Toggle external device */ +#define TP_MASK_EXT_DEV 0x02 +#define TP_TOGGLE_DRIFT 0x23 /* Drift Correction */ +#define TP_MASK_DRIFT 0x80 +#define TP_TOGGLE_BURST 0x28 /* Burst Mode */ +#define TP_MASK_BURST 0x80 +#define TP_TOGGLE_PTSON 0x2C /* Press to Select */ +#define TP_MASK_PTSON 0x01 +#define TP_TOGGLE_HARD_TRANS 0x2C /* Alternate method to set Hard Transparency */ +#define TP_MASK_HARD_TRANS 0x80 +#define TP_TOGGLE_TWOHAND 0x2D /* Two handed */ +#define TP_MASK_TWOHAND 0x01 +#define TP_TOGGLE_STICKY_TWO 0x2D /* Sticky two handed */ +#define TP_MASK_STICKY_TWO 0x04 +#define TP_TOGGLE_SKIPBACK 0x2D /* Suppress movement after drag release */ +#define TP_MASK_SKIPBACK 0x08 +#define TP_TOGGLE_SOURCE_TAG 0x20 /* Bit 3 of the first packet will be set to + to the origin of the packet (external or TP) */ +#define TP_MASK_SOURCE_TAG 0x80 +#define TP_TOGGLE_EXT_TAG 0x22 /* Bit 3 of the first packet coming from the + external device will be forced to 1 */ +#define TP_MASK_EXT_TAG 0x04 + + +/* Power on Self Test Results */ +#define TP_POR_SUCCESS 0x3B + +/* + * Default power on values + */ +#define TP_DEF_SENS 0x80 +#define TP_DEF_INERTIA 0x06 +#define TP_DEF_SPEED 0x61 +#define TP_DEF_REACH 0x0A + +#define TP_DEF_DRAGHYS 0xFF +#define TP_DEF_MINDRAG 0x14 + +#define TP_DEF_THRESH 0x08 +#define TP_DEF_UP_THRESH 0xFF +#define TP_DEF_Z_TIME 0x26 +#define TP_DEF_JENKS_CURV 0x87 + +/* Toggles */ +#define TP_DEF_MB 0x00 +#define TP_DEF_PTSON 0x00 +#define TP_DEF_SKIPBACK 0x00 +#define TP_DEF_EXT_DEV 0x01 + +#define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd)) + +struct trackpoint_data +{ + unsigned char sensitivity, speed, inertia, reach; + unsigned char draghys, mindrag; + unsigned char thresh, upthresh; + unsigned char ztime, jenks; + + unsigned char press_to_select; + unsigned char skipback; + + unsigned char ext_dev; +}; + +extern int trackpoint_detect(struct psmouse *psmouse, int set_properties); + +#endif /* _TRACKPOINT_H */ -- cgit v0.10.2 From 716e084edb0230910b174000dc3490f9e91652e3 Mon Sep 17 00:00:00 2001 From: Luming Yu Date: Wed, 10 Aug 2005 01:40:00 -0400 Subject: [ACPI] Fix "ec_burst=1" mode latency issue http://bugzilla.kernel.org/show_bug.cgi?id=3851 Signed-off-by: Luming Yu Signed-off-by: Len Brown diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 1ac5731..31067a0 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -234,18 +234,29 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) ec->burst.expect_event = event; smp_mb(); - result = wait_event_interruptible_timeout(ec->burst.wait, + switch (event) { + case ACPI_EC_EVENT_OBF: + if (acpi_ec_read_status(ec) & event) { + ec->burst.expect_event = 0; + return_VALUE(0); + } + break; + + case ACPI_EC_EVENT_IBE: + if (~acpi_ec_read_status(ec) & event) { + ec->burst.expect_event = 0; + return_VALUE(0); + } + break; + } + + result = wait_event_timeout(ec->burst.wait, !ec->burst.expect_event, msecs_to_jiffies(ACPI_EC_DELAY)); ec->burst.expect_event = 0; smp_mb(); - if (result < 0){ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR," result = %d ", result)); - return_VALUE(result); - } - /* * Verify that the event in question has actually happened by * querying EC status. Do the check even if operation timed-out @@ -280,14 +291,14 @@ 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_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); - if (status){ - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); + if (status) return_VALUE(-EINVAL); - } acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); if(tmp != 0x90 ) {/* Burst ACK byte*/ return_VALUE(-EINVAL); } @@ -295,31 +306,19 @@ acpi_ec_enter_burst_mode ( atomic_set(&ec->burst.leaving_burst , 0); return_VALUE(0); +end: + printk("Error in acpi_ec_wait\n"); + return_VALUE(-1); } static int acpi_ec_leave_burst_mode ( union acpi_ec *ec) { - int status =0; ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); - atomic_set(&ec->burst.leaving_burst , 1); - status = acpi_ec_read_status(ec); - if (status != -EINVAL && - (status & ACPI_EC_FLAG_BURST)){ - acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr); - status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); - if (status){ - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n")); - return_VALUE(-EINVAL); - } - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - status = acpi_ec_read_status(ec); - } - + atomic_set(&ec->burst.leaving_burst, 1); return_VALUE(0); } @@ -461,7 +460,6 @@ acpi_ec_burst_read ( if (!ec || !data) return_VALUE(-EINVAL); -retry: *data = 0; if (ec->common.global_lock) { @@ -473,26 +471,25 @@ retry: WARN_ON(in_interrupt()); down(&ec->burst.sem); - if(acpi_ec_enter_burst_mode(ec)) + acpi_ec_enter_burst_mode(ec); + status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); + if (status) { + printk("read EC, IB not empty\n"); goto end; - + } acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); if (status) { - goto end; + printk("read EC, IB not empty\n"); } acpi_hw_low_level_write(8, address, &ec->common.data_addr); status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); if (status){ - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); + printk("read EC, OB not full\n"); goto end; } - acpi_hw_low_level_read(8, data, &ec->common.data_addr); - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", *data, address)); @@ -503,15 +500,6 @@ end: if (ec->common.global_lock) acpi_release_global_lock(glk); - if(atomic_read(&ec->burst.leaving_burst) == 2){ - ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); - while(atomic_read(&ec->burst.pending_gpe)){ - msleep(1); - } - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - goto retry; - } - return_VALUE(status); } @@ -524,13 +512,12 @@ acpi_ec_burst_write ( { int status = 0; u32 glk; - u32 tmp; ACPI_FUNCTION_TRACE("acpi_ec_write"); if (!ec) return_VALUE(-EINVAL); -retry: + if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) @@ -540,61 +527,35 @@ retry: WARN_ON(in_interrupt()); down(&ec->burst.sem); - if(acpi_ec_enter_burst_mode(ec)) - goto end; + acpi_ec_enter_burst_mode(ec); - status = acpi_ec_read_status(ec); - if (status != -EINVAL && - !(status & ACPI_EC_FLAG_BURST)){ - acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr); - status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); - if (status) - goto end; - acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); - if(tmp != 0x90 ) /* Burst ACK byte*/ - goto end; + status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); + if ( status) { + printk("write EC, IB not empty\n"); } - /*Now we are in burst mode*/ - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - if (status){ - goto end; + if (status) { + printk ("write EC, IB not empty\n"); } acpi_hw_low_level_write(8, address, &ec->common.data_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); if (status){ - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - goto end; + printk("write EC, IB not empty\n"); } acpi_hw_low_level_write(8, data, &ec->common.data_addr); - status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - if (status) - goto end; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", data, address)); -end: acpi_ec_leave_burst_mode(ec); up(&ec->burst.sem); if (ec->common.global_lock) acpi_release_global_lock(glk); - if(atomic_read(&ec->burst.leaving_burst) == 2){ - ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); - while(atomic_read(&ec->burst.pending_gpe)){ - msleep(1); - } - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - goto retry; - } - return_VALUE(status); } @@ -719,8 +680,12 @@ acpi_ec_burst_query ( } down(&ec->burst.sem); - if(acpi_ec_enter_burst_mode(ec)) + + status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); + if (status) { + printk("query EC, IB not empty\n"); goto end; + } /* * Query the EC to find out which _Qxx method we need to evaluate. * Note that successful completion of the query causes the ACPI_EC_SCI @@ -729,27 +694,20 @@ acpi_ec_burst_query ( acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); if (status){ - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); + printk("query EC, OB not full\n"); goto end; } acpi_hw_low_level_read(8, data, &ec->common.data_addr); - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); if (!*data) status = -ENODATA; end: - acpi_ec_leave_burst_mode(ec); up(&ec->burst.sem); if (ec->common.global_lock) acpi_release_global_lock(glk); - if(atomic_read(&ec->burst.leaving_burst) == 2){ - ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); - acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - status = -ENODATA; - } return_VALUE(status); } @@ -885,31 +843,21 @@ acpi_ec_gpe_burst_handler ( if (!ec) return ACPI_INTERRUPT_NOT_HANDLED; - acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); - + acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); value = acpi_ec_read_status(ec); - if((value & ACPI_EC_FLAG_IBF) && - !(value & ACPI_EC_FLAG_BURST) && - (atomic_read(&ec->burst.leaving_burst) == 0)) { - /* - * the embedded controller disables - * burst mode for any reason other - * than the burst disable command - * to process critical event. - */ - atomic_set(&ec->burst.leaving_burst , 2); /* block current pending transaction - and retry */ + switch ( ec->burst.expect_event) { + case ACPI_EC_EVENT_OBF: + if (!(value & ACPI_EC_FLAG_OBF)) + break; + case ACPI_EC_EVENT_IBE: + if ((value & ACPI_EC_FLAG_IBF)) + break; + ec->burst.expect_event = 0; wake_up(&ec->burst.wait); - }else { - if ((ec->burst.expect_event == ACPI_EC_EVENT_OBF && - (value & ACPI_EC_FLAG_OBF)) || - (ec->burst.expect_event == ACPI_EC_EVENT_IBE && - !(value & ACPI_EC_FLAG_IBF))) { - ec->burst.expect_event = 0; - wake_up(&ec->burst.wait); - return ACPI_INTERRUPT_HANDLED; - } + return ACPI_INTERRUPT_HANDLED; + default: + break; } if (value & ACPI_EC_FLAG_SCI){ @@ -1242,6 +1190,7 @@ acpi_ec_burst_add ( if (result) goto end; + printk("burst-mode-ec-10-Aug\n"); printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", acpi_device_name(device), acpi_device_bid(device), (u32) ec->common.gpe_bit); -- cgit v0.10.2 From 50526df605e7c3e22168664acf726269eae10171 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Thu, 11 Aug 2005 17:32:05 -0400 Subject: [ACPI] Lindent drivers/acpi/ec.c necessary for clean merge from acpi-2.6.12 to-akpm Signed-off-by: Len Brown diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 31067a0..7e1a445 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -38,130 +38,112 @@ #include #define _COMPONENT ACPI_EC_COMPONENT -ACPI_MODULE_NAME ("acpi_ec") - +ACPI_MODULE_NAME("acpi_ec") #define ACPI_EC_COMPONENT 0x00100000 #define ACPI_EC_CLASS "embedded_controller" #define ACPI_EC_HID "PNP0C09" #define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" #define ACPI_EC_DEVICE_NAME "Embedded Controller" #define ACPI_EC_FILE_INFO "info" - - #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ - #define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */ #define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */ - #define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */ #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ - -#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */ -#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */ - +#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */ +#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */ #define ACPI_EC_COMMAND_READ 0x80 #define ACPI_EC_COMMAND_WRITE 0x81 #define ACPI_EC_BURST_ENABLE 0x82 #define ACPI_EC_BURST_DISABLE 0x83 #define ACPI_EC_COMMAND_QUERY 0x84 - #define EC_POLLING 0xFF #define EC_BURST 0x00 - - -static int acpi_ec_remove (struct acpi_device *device, int type); -static int acpi_ec_start (struct acpi_device *device); -static int acpi_ec_stop (struct acpi_device *device, int type); -static int acpi_ec_burst_add ( struct acpi_device *device); -static int acpi_ec_polling_add ( struct acpi_device *device); +static int acpi_ec_remove(struct acpi_device *device, int type); +static int acpi_ec_start(struct acpi_device *device); +static int acpi_ec_stop(struct acpi_device *device, int type); +static int acpi_ec_burst_add(struct acpi_device *device); +static int acpi_ec_polling_add(struct acpi_device *device); static struct acpi_driver acpi_ec_driver = { - .name = ACPI_EC_DRIVER_NAME, - .class = ACPI_EC_CLASS, - .ids = ACPI_EC_HID, - .ops = { - .add = acpi_ec_polling_add, - .remove = acpi_ec_remove, - .start = acpi_ec_start, - .stop = acpi_ec_stop, - }, + .name = ACPI_EC_DRIVER_NAME, + .class = ACPI_EC_CLASS, + .ids = ACPI_EC_HID, + .ops = { + .add = acpi_ec_polling_add, + .remove = acpi_ec_remove, + .start = acpi_ec_start, + .stop = acpi_ec_stop, + }, }; union acpi_ec { struct { - u32 mode; - acpi_handle handle; - unsigned long uid; - unsigned long gpe_bit; - struct acpi_generic_address status_addr; - struct acpi_generic_address command_addr; - struct acpi_generic_address data_addr; - unsigned long global_lock; + u32 mode; + acpi_handle handle; + unsigned long uid; + unsigned long gpe_bit; + struct acpi_generic_address status_addr; + struct acpi_generic_address command_addr; + struct acpi_generic_address data_addr; + unsigned long global_lock; } common; struct { - u32 mode; - acpi_handle handle; - unsigned long uid; - unsigned long gpe_bit; - struct acpi_generic_address status_addr; - struct acpi_generic_address command_addr; - struct acpi_generic_address data_addr; - unsigned long global_lock; - unsigned int expect_event; - atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort*/ - atomic_t pending_gpe; - struct semaphore sem; - wait_queue_head_t wait; - }burst; + u32 mode; + acpi_handle handle; + unsigned long uid; + unsigned long gpe_bit; + struct acpi_generic_address status_addr; + struct acpi_generic_address command_addr; + struct acpi_generic_address data_addr; + unsigned long global_lock; + unsigned int expect_event; + atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */ + atomic_t pending_gpe; + struct semaphore sem; + wait_queue_head_t wait; + } burst; struct { - u32 mode; - acpi_handle handle; - unsigned long uid; - unsigned long gpe_bit; - struct acpi_generic_address status_addr; - struct acpi_generic_address command_addr; - struct acpi_generic_address data_addr; - unsigned long global_lock; - spinlock_t lock; - }polling; + u32 mode; + acpi_handle handle; + unsigned long uid; + unsigned long gpe_bit; + struct acpi_generic_address status_addr; + struct acpi_generic_address command_addr; + struct acpi_generic_address data_addr; + unsigned long global_lock; + spinlock_t lock; + } polling; }; -static int acpi_ec_polling_wait ( union acpi_ec *ec, u8 event); +static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event); static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event); -static int acpi_ec_polling_read ( union acpi_ec *ec, u8 address, u32 *data); -static int acpi_ec_burst_read( union acpi_ec *ec, u8 address, u32 *data); -static int acpi_ec_polling_write ( union acpi_ec *ec, u8 address, u8 data); -static int acpi_ec_burst_write ( union acpi_ec *ec, u8 address, u8 data); -static int acpi_ec_polling_query ( union acpi_ec *ec, u32 *data); -static int acpi_ec_burst_query ( union acpi_ec *ec, u32 *data); -static void acpi_ec_gpe_polling_query ( void *ec_cxt); -static void acpi_ec_gpe_burst_query ( void *ec_cxt); -static u32 acpi_ec_gpe_polling_handler ( void *data); -static u32 acpi_ec_gpe_burst_handler ( void *data); +static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data); +static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data); +static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data); +static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data); +static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data); +static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data); +static void acpi_ec_gpe_polling_query(void *ec_cxt); +static void acpi_ec_gpe_burst_query(void *ec_cxt); +static u32 acpi_ec_gpe_polling_handler(void *data); +static u32 acpi_ec_gpe_burst_handler(void *data); static acpi_status __init -acpi_fake_ecdt_polling_callback ( - acpi_handle handle, - u32 Level, - void *context, - void **retval); +acpi_fake_ecdt_polling_callback(acpi_handle handle, + u32 Level, void *context, void **retval); static acpi_status __init -acpi_fake_ecdt_burst_callback ( - acpi_handle handle, - u32 Level, - void *context, - void **retval); - -static int __init -acpi_ec_polling_get_real_ecdt(void); -static int __init -acpi_ec_burst_get_real_ecdt(void); +acpi_fake_ecdt_burst_callback(acpi_handle handle, + u32 Level, void *context, void **retval); + +static int __init acpi_ec_polling_get_real_ecdt(void); +static int __init acpi_ec_burst_get_real_ecdt(void); /* If we find an EC via the ECDT, we need to keep a ptr to its context */ -static union acpi_ec *ec_ecdt; +static union acpi_ec *ec_ecdt; /* External interfaces use first EC only, so remember */ static struct acpi_device *first_ec; @@ -173,30 +155,24 @@ static int acpi_ec_polling_mode = EC_POLLING; static inline u32 acpi_ec_read_status(union acpi_ec *ec) { - u32 status = 0; + u32 status = 0; acpi_hw_low_level_read(8, &status, &ec->common.status_addr); return status; } -static int -acpi_ec_wait ( - union acpi_ec *ec, - u8 event) +static int acpi_ec_wait(union acpi_ec *ec, u8 event) { - if (acpi_ec_polling_mode) - return acpi_ec_polling_wait (ec, event); + if (acpi_ec_polling_mode) + return acpi_ec_polling_wait(ec, event); else - return acpi_ec_burst_wait (ec, event); + return acpi_ec_burst_wait(ec, event); } -static int -acpi_ec_polling_wait ( - union acpi_ec *ec, - u8 event) +static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event) { - u32 acpi_ec_status = 0; - u32 i = ACPI_EC_UDELAY_COUNT; + u32 acpi_ec_status = 0; + u32 i = ACPI_EC_UDELAY_COUNT; if (!ec) return -EINVAL; @@ -205,19 +181,21 @@ acpi_ec_polling_wait ( switch (event) { case ACPI_EC_EVENT_OBF: do { - acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr); + acpi_hw_low_level_read(8, &acpi_ec_status, + &ec->common.status_addr); if (acpi_ec_status & ACPI_EC_FLAG_OBF) return 0; udelay(ACPI_EC_UDELAY); - } while (--i>0); + } while (--i > 0); break; case ACPI_EC_EVENT_IBE: do { - acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr); + acpi_hw_low_level_read(8, &acpi_ec_status, + &ec->common.status_addr); if (!(acpi_ec_status & ACPI_EC_FLAG_IBF)) return 0; udelay(ACPI_EC_UDELAY); - } while (--i>0); + } while (--i > 0); break; default: return -EINVAL; @@ -227,7 +205,7 @@ acpi_ec_polling_wait ( } static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_ec_wait"); @@ -251,9 +229,9 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) } result = wait_event_timeout(ec->burst.wait, - !ec->burst.expect_event, - msecs_to_jiffies(ACPI_EC_DELAY)); - + !ec->burst.expect_event, + msecs_to_jiffies(ACPI_EC_DELAY)); + ec->burst.expect_event = 0; smp_mb(); @@ -277,43 +255,37 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) return_VALUE(-ETIME); } - - -static int -acpi_ec_enter_burst_mode ( - union acpi_ec *ec) +static int acpi_ec_enter_burst_mode(union acpi_ec *ec) { - u32 tmp = 0; - int status = 0; + 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)){ + if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); - if(status) + if (status) goto end; - acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, + &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); if (status) return_VALUE(-EINVAL); acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); - if(tmp != 0x90 ) {/* Burst ACK byte*/ + if (tmp != 0x90) { /* Burst ACK byte */ return_VALUE(-EINVAL); } } - atomic_set(&ec->burst.leaving_burst , 0); + atomic_set(&ec->burst.leaving_burst, 0); return_VALUE(0); -end: + end: printk("Error in acpi_ec_wait\n"); return_VALUE(-1); } -static int -acpi_ec_leave_burst_mode ( - union acpi_ec *ec) +static int acpi_ec_leave_burst_mode(union acpi_ec *ec) { ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); @@ -322,38 +294,26 @@ acpi_ec_leave_burst_mode ( return_VALUE(0); } -static int -acpi_ec_read ( - union acpi_ec *ec, - u8 address, - u32 *data) +static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data) { - if (acpi_ec_polling_mode) + if (acpi_ec_polling_mode) return acpi_ec_polling_read(ec, address, data); else return acpi_ec_burst_read(ec, address, data); } -static int -acpi_ec_write ( - union acpi_ec *ec, - u8 address, - u8 data) +static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data) { - if (acpi_ec_polling_mode) + if (acpi_ec_polling_mode) return acpi_ec_polling_write(ec, address, data); else return acpi_ec_burst_write(ec, address, data); } -static int -acpi_ec_polling_read ( - union acpi_ec *ec, - u8 address, - u32 *data) +static int acpi_ec_polling_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_status status = AE_OK; + int result = 0; + unsigned long flags = 0; + u32 glk = 0; ACPI_FUNCTION_TRACE("acpi_ec_read"); @@ -370,7 +330,8 @@ acpi_ec_polling_read ( spin_lock_irqsave(&ec->polling.lock, flags); - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, + &ec->common.command_addr); result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); if (result) goto end; @@ -383,9 +344,9 @@ acpi_ec_polling_read ( acpi_hw_low_level_read(8, data, &ec->common.data_addr); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", - *data, address)); - -end: + *data, address)); + + end: spin_unlock_irqrestore(&ec->polling.lock, flags); if (ec->common.global_lock) @@ -394,17 +355,12 @@ end: return_VALUE(result); } - -static int -acpi_ec_polling_write ( - union acpi_ec *ec, - u8 address, - u8 data) +static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data) { - int result = 0; - acpi_status status = AE_OK; - unsigned long flags = 0; - u32 glk = 0; + int result = 0; + acpi_status status = AE_OK; + unsigned long flags = 0; + u32 glk = 0; ACPI_FUNCTION_TRACE("acpi_ec_write"); @@ -419,7 +375,8 @@ acpi_ec_polling_write ( spin_lock_irqsave(&ec->polling.lock, flags); - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, + &ec->common.command_addr); result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); if (result) goto end; @@ -435,9 +392,9 @@ acpi_ec_polling_write ( goto end; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", - data, address)); + data, address)); -end: + end: spin_unlock_irqrestore(&ec->polling.lock, flags); if (ec->common.global_lock) @@ -446,14 +403,10 @@ end: return_VALUE(result); } -static int -acpi_ec_burst_read ( - union acpi_ec *ec, - u8 address, - u32 *data) +static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data) { - int status = 0; - u32 glk; + int status = 0; + u32 glk; ACPI_FUNCTION_TRACE("acpi_ec_read"); @@ -477,23 +430,24 @@ acpi_ec_burst_read ( printk("read EC, IB not empty\n"); goto end; } - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, + &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); if (status) { printk("read EC, IB not empty\n"); } acpi_hw_low_level_write(8, address, &ec->common.data_addr); - status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); - if (status){ + status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); + if (status) { printk("read EC, OB not full\n"); goto end; } acpi_hw_low_level_read(8, data, &ec->common.data_addr); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", - *data, address)); - -end: + *data, address)); + + end: acpi_ec_leave_burst_mode(ec); up(&ec->burst.sem); @@ -503,15 +457,10 @@ end: return_VALUE(status); } - -static int -acpi_ec_burst_write ( - union acpi_ec *ec, - u8 address, - u8 data) +static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data) { - int status = 0; - u32 glk; + int status = 0; + u32 glk; ACPI_FUNCTION_TRACE("acpi_ec_write"); @@ -530,25 +479,26 @@ acpi_ec_burst_write ( acpi_ec_enter_burst_mode(ec); status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); - if ( status) { + if (status) { printk("write EC, IB not empty\n"); } - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, + &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); if (status) { - printk ("write EC, IB not empty\n"); + printk("write EC, IB not empty\n"); } acpi_hw_low_level_write(8, address, &ec->common.data_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); - if (status){ + if (status) { printk("write EC, IB not empty\n"); } acpi_hw_low_level_write(8, data, &ec->common.data_addr); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", - data, address)); + data, address)); acpi_ec_leave_burst_mode(ec); up(&ec->burst.sem); @@ -562,8 +512,7 @@ acpi_ec_burst_write ( /* * Externally callable EC access functions. For now, assume 1 EC only */ -int -ec_read(u8 addr, u8 *val) +int ec_read(u8 addr, u8 * val) { union acpi_ec *ec; int err; @@ -579,14 +528,13 @@ ec_read(u8 addr, u8 *val) if (!err) { *val = temp_data; return 0; - } - else + } else return err; } + EXPORT_SYMBOL(ec_read); -int -ec_write(u8 addr, u8 val) +int ec_write(u8 addr, u8 val) { union acpi_ec *ec; int err; @@ -600,27 +548,22 @@ ec_write(u8 addr, u8 val) return err; } + EXPORT_SYMBOL(ec_write); -static int -acpi_ec_query ( - union acpi_ec *ec, - u32 *data) +static int acpi_ec_query(union acpi_ec *ec, u32 * data) { - if (acpi_ec_polling_mode) + if (acpi_ec_polling_mode) return acpi_ec_polling_query(ec, data); else return acpi_ec_burst_query(ec, data); } -static int -acpi_ec_polling_query ( - union acpi_ec *ec, - u32 *data) +static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data) { - int result = 0; - acpi_status status = AE_OK; - unsigned long flags = 0; - u32 glk = 0; + int result = 0; + acpi_status status = AE_OK; + unsigned long flags = 0; + u32 glk = 0; ACPI_FUNCTION_TRACE("acpi_ec_query"); @@ -642,7 +585,8 @@ acpi_ec_polling_query ( */ spin_lock_irqsave(&ec->polling.lock, flags); - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, + &ec->common.command_addr); result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); if (result) goto end; @@ -651,7 +595,7 @@ acpi_ec_polling_query ( if (!*data) result = -ENODATA; -end: + end: spin_unlock_irqrestore(&ec->polling.lock, flags); if (ec->common.global_lock) @@ -659,13 +603,10 @@ end: return_VALUE(result); } -static int -acpi_ec_burst_query ( - union acpi_ec *ec, - u32 *data) +static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data) { - int status = 0; - u32 glk; + int status = 0; + u32 glk; ACPI_FUNCTION_TRACE("acpi_ec_query"); @@ -691,9 +632,10 @@ acpi_ec_burst_query ( * Note that successful completion of the query causes the ACPI_EC_SCI * bit to be cleared (and thus clearing the interrupt source). */ - acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr); + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, + &ec->common.command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); - if (status){ + if (status) { printk("query EC, OB not full\n"); goto end; } @@ -702,7 +644,7 @@ acpi_ec_burst_query ( if (!*data) status = -ENODATA; -end: + end: up(&ec->burst.sem); if (ec->common.global_lock) @@ -711,36 +653,32 @@ end: return_VALUE(status); } - /* -------------------------------------------------------------------------- Event Management -------------------------------------------------------------------------- */ union acpi_ec_query_data { - acpi_handle handle; - u8 data; + acpi_handle handle; + u8 data; }; -static void -acpi_ec_gpe_query ( - void *ec_cxt) +static void acpi_ec_gpe_query(void *ec_cxt) { - if (acpi_ec_polling_mode) + if (acpi_ec_polling_mode) acpi_ec_gpe_polling_query(ec_cxt); else acpi_ec_gpe_burst_query(ec_cxt); } -static void -acpi_ec_gpe_polling_query ( - void *ec_cxt) +static void acpi_ec_gpe_polling_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'}; - const char hex[] = {'0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F'}; + 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' }; + const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' + }; ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); @@ -770,19 +708,18 @@ acpi_ec_gpe_polling_query ( acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); -end: + end: acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); } -static void -acpi_ec_gpe_burst_query ( - void *ec_cxt) +static void acpi_ec_gpe_burst_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'}; - const char hex[] = {'0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F'}; + union acpi_ec *ec = (union acpi_ec *)ec_cxt; + u32 value; + int result = -ENODATA; + static char object_name[5] = { '_', 'Q', '0', '0', '\0' }; + const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' + }; ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); @@ -798,26 +735,22 @@ acpi_ec_gpe_burst_query ( ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); -end: + end: atomic_dec(&ec->burst.pending_gpe); return; } -static u32 -acpi_ec_gpe_handler ( - void *data) +static u32 acpi_ec_gpe_handler(void *data) { - if (acpi_ec_polling_mode) + if (acpi_ec_polling_mode) return acpi_ec_gpe_polling_handler(data); else - return acpi_ec_gpe_burst_handler(data); + return acpi_ec_gpe_burst_handler(data); } -static u32 -acpi_ec_gpe_polling_handler ( - void *data) +static u32 acpi_ec_gpe_polling_handler(void *data) { - acpi_status status = AE_OK; - union acpi_ec *ec = (union acpi_ec *) data; + acpi_status status = AE_OK; + union acpi_ec *ec = (union acpi_ec *)data; if (!ec) return ACPI_INTERRUPT_NOT_HANDLED; @@ -825,20 +758,18 @@ acpi_ec_gpe_polling_handler ( acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, - acpi_ec_gpe_query, ec); + acpi_ec_gpe_query, ec); if (status == AE_OK) return ACPI_INTERRUPT_HANDLED; else return ACPI_INTERRUPT_NOT_HANDLED; } -static u32 -acpi_ec_gpe_burst_handler ( - void *data) +static u32 acpi_ec_gpe_burst_handler(void *data) { - acpi_status status = AE_OK; - u32 value; - union acpi_ec *ec = (union acpi_ec *) data; + acpi_status status = AE_OK; + u32 value; + union acpi_ec *ec = (union acpi_ec *)data; if (!ec) return ACPI_INTERRUPT_NOT_HANDLED; @@ -846,7 +777,7 @@ acpi_ec_gpe_burst_handler ( acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); value = acpi_ec_read_status(ec); - switch ( ec->burst.expect_event) { + switch (ec->burst.expect_event) { case ACPI_EC_EVENT_OBF: if (!(value & ACPI_EC_FLAG_OBF)) break; @@ -860,16 +791,16 @@ acpi_ec_gpe_burst_handler ( break; } - if (value & ACPI_EC_FLAG_SCI){ - atomic_add(1, &ec->burst.pending_gpe) ; + if (value & ACPI_EC_FLAG_SCI) { + atomic_add(1, &ec->burst.pending_gpe); status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, - acpi_ec_gpe_query, ec); + acpi_ec_gpe_query, ec); return status == AE_OK ? - ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; - } + ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; + } acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); return status == AE_OK ? - ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; + ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; } /* -------------------------------------------------------------------------- @@ -877,37 +808,31 @@ acpi_ec_gpe_burst_handler ( -------------------------------------------------------------------------- */ static acpi_status -acpi_ec_space_setup ( - acpi_handle region_handle, - u32 function, - void *handler_context, - void **return_context) +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 : NULL; + *return_context = (function != ACPI_REGION_DEACTIVATE) ? + handler_context : NULL; return AE_OK; } - static acpi_status -acpi_ec_space_handler ( - u32 function, - acpi_physical_address address, - u32 bit_width, - acpi_integer *value, - void *handler_context, - void *region_context) +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; + int result = 0; + union acpi_ec *ec = NULL; + u64 temp = *value; + acpi_integer f_v = 0; + int i = 0; ACPI_FUNCTION_TRACE("acpi_ec_space_handler"); @@ -915,17 +840,18 @@ acpi_ec_space_handler ( return_VALUE(AE_BAD_PARAMETER); if (bit_width != 8 && acpi_strict) { - printk(KERN_WARNING PREFIX "acpi_ec_space_handler: bit_width should be 8\n"); + printk(KERN_WARNING PREFIX + "acpi_ec_space_handler: bit_width should be 8\n"); return_VALUE(AE_BAD_PARAMETER); } - ec = (union acpi_ec *) handler_context; + ec = (union acpi_ec *)handler_context; -next_byte: + next_byte: switch (function) { case ACPI_READ: temp = 0; - result = acpi_ec_read(ec, (u8) address, (u32 *)&temp); + result = acpi_ec_read(ec, (u8) address, (u32 *) & temp); break; case ACPI_WRITE: result = acpi_ec_write(ec, (u8) address, (u8) temp); @@ -952,8 +878,7 @@ next_byte: *value = f_v; } - -out: + out: switch (result) { case -EINVAL: return_VALUE(AE_BAD_PARAMETER); @@ -969,18 +894,15 @@ out: } } - /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ -static struct proc_dir_entry *acpi_ec_dir; +static struct proc_dir_entry *acpi_ec_dir; - -static int -acpi_ec_read_info (struct seq_file *seq, void *offset) +static int acpi_ec_read_info(struct seq_file *seq, void *offset) { - union acpi_ec *ec = (union acpi_ec *) seq->private; + union acpi_ec *ec = (union acpi_ec *)seq->private; ACPI_FUNCTION_TRACE("acpi_ec_read_info"); @@ -988,14 +910,15 @@ acpi_ec_read_info (struct seq_file *seq, void *offset) goto end; seq_printf(seq, "gpe bit: 0x%02x\n", - (u32) ec->common.gpe_bit); + (u32) ec->common.gpe_bit); seq_printf(seq, "ports: 0x%02x, 0x%02x\n", - (u32) ec->common.status_addr.address, (u32) ec->common.data_addr.address); + (u32) ec->common.status_addr.address, + (u32) ec->common.data_addr.address); seq_printf(seq, "use global lock: %s\n", - ec->common.global_lock?"yes":"no"); + ec->common.global_lock ? "yes" : "no"); acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); -end: + end: return_VALUE(0); } @@ -1005,34 +928,32 @@ static int acpi_ec_info_open_fs(struct inode *inode, struct file *file) } static struct file_operations acpi_ec_info_ops = { - .open = acpi_ec_info_open_fs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, + .open = acpi_ec_info_open_fs, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, .owner = THIS_MODULE, }; -static int -acpi_ec_add_fs ( - struct acpi_device *device) +static int acpi_ec_add_fs(struct acpi_device *device) { - struct proc_dir_entry *entry = NULL; + 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); + acpi_ec_dir); if (!acpi_device_dir(device)) return_VALUE(-ENODEV); } entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, - acpi_device_dir(device)); + acpi_device_dir(device)); if (!entry) ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Unable to create '%s' fs entry\n", - ACPI_EC_FILE_INFO)); + "Unable to create '%s' fs entry\n", + ACPI_EC_FILE_INFO)); else { entry->proc_fops = &acpi_ec_info_ops; entry->data = acpi_driver_data(device); @@ -1042,10 +963,7 @@ acpi_ec_add_fs ( return_VALUE(0); } - -static int -acpi_ec_remove_fs ( - struct acpi_device *device) +static int acpi_ec_remove_fs(struct acpi_device *device) { ACPI_FUNCTION_TRACE("acpi_ec_remove_fs"); @@ -1058,20 +976,16 @@ acpi_ec_remove_fs ( return_VALUE(0); } - /* -------------------------------------------------------------------------- Driver Interface -------------------------------------------------------------------------- */ - -static int -acpi_ec_polling_add ( - struct acpi_device *device) +static int acpi_ec_polling_add(struct acpi_device *device) { - int result = 0; - acpi_status status = AE_OK; - union acpi_ec *ec = NULL; - unsigned long uid; + int result = 0; + acpi_status status = AE_OK; + union acpi_ec *ec = NULL; + unsigned long uid; ACPI_FUNCTION_TRACE("acpi_ec_add"); @@ -1091,26 +1005,31 @@ acpi_ec_polling_add ( acpi_driver_data(device) = ec; /* Use the global lock for all EC transactions? */ - acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock); + acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, + &ec->common.global_lock); /* If our UID matches the UID for the ECDT-enumerated EC, - we now have the *real* EC info, so kill the makeshift one.*/ + we now have the *real* EC info, so kill the makeshift one. */ acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); if (ec_ecdt && ec_ecdt->common.uid == uid) { acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); - - acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler); + ACPI_ADR_SPACE_EC, + &acpi_ec_space_handler); + + acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, + &acpi_ec_gpe_handler); kfree(ec_ecdt); } /* Get GPE bit assignment (EC events). */ /* TODO: Add support for _GPE returning a package */ - status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); + status = + acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, + &ec->common.gpe_bit); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error obtaining GPE bit assignment\n")); + "Error obtaining GPE bit assignment\n")); result = -ENODEV; goto end; } @@ -1120,26 +1039,24 @@ acpi_ec_polling_add ( goto end; printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", - acpi_device_name(device), acpi_device_bid(device), - (u32) ec->common.gpe_bit); + acpi_device_name(device), acpi_device_bid(device), + (u32) ec->common.gpe_bit); if (!first_ec) first_ec = device; -end: + end: if (result) kfree(ec); return_VALUE(result); } -static int -acpi_ec_burst_add ( - struct acpi_device *device) +static int acpi_ec_burst_add(struct acpi_device *device) { - int result = 0; - acpi_status status = AE_OK; - union acpi_ec *ec = NULL; - unsigned long uid; + int result = 0; + acpi_status status = AE_OK; + union acpi_ec *ec = NULL; + unsigned long uid; ACPI_FUNCTION_TRACE("acpi_ec_add"); @@ -1153,35 +1070,40 @@ acpi_ec_burst_add ( ec->common.handle = device->handle; ec->common.uid = -1; - atomic_set(&ec->burst.pending_gpe, 0); - atomic_set(&ec->burst.leaving_burst , 1); - init_MUTEX(&ec->burst.sem); - init_waitqueue_head(&ec->burst.wait); + atomic_set(&ec->burst.pending_gpe, 0); + atomic_set(&ec->burst.leaving_burst, 1); + init_MUTEX(&ec->burst.sem); + init_waitqueue_head(&ec->burst.wait); strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_EC_CLASS); acpi_driver_data(device) = ec; /* Use the global lock for all EC transactions? */ - acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock); + acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, + &ec->common.global_lock); /* If our UID matches the UID for the ECDT-enumerated EC, - we now have the *real* EC info, so kill the makeshift one.*/ + we now have the *real* EC info, so kill the makeshift one. */ acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); if (ec_ecdt && ec_ecdt->common.uid == uid) { acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); + ACPI_ADR_SPACE_EC, + &acpi_ec_space_handler); - acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler); + acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, + &acpi_ec_gpe_handler); kfree(ec_ecdt); } /* Get GPE bit assignment (EC events). */ /* TODO: Add support for _GPE returning a package */ - status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); + status = + acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, + &ec->common.gpe_bit); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error obtaining GPE bit assignment\n")); + "Error obtaining GPE bit assignment\n")); result = -ENODEV; goto end; } @@ -1192,26 +1114,22 @@ acpi_ec_burst_add ( printk("burst-mode-ec-10-Aug\n"); printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", - acpi_device_name(device), acpi_device_bid(device), - (u32) ec->common.gpe_bit); + acpi_device_name(device), acpi_device_bid(device), + (u32) ec->common.gpe_bit); if (!first_ec) first_ec = device; -end: + end: if (result) kfree(ec); return_VALUE(result); } - -static int -acpi_ec_remove ( - struct acpi_device *device, - int type) +static int acpi_ec_remove(struct acpi_device *device, int type) { - union acpi_ec *ec = NULL; + union acpi_ec *ec = NULL; ACPI_FUNCTION_TRACE("acpi_ec_remove"); @@ -1227,13 +1145,10 @@ acpi_ec_remove ( return_VALUE(0); } - static acpi_status -acpi_ec_io_ports ( - struct acpi_resource *resource, - void *context) +acpi_ec_io_ports(struct acpi_resource *resource, void *context) { - union acpi_ec *ec = (union acpi_ec *) context; + union acpi_ec *ec = (union acpi_ec *)context; struct acpi_generic_address *addr; if (resource->id != ACPI_RSTYPE_IO) { @@ -1261,13 +1176,10 @@ acpi_ec_io_ports ( return AE_OK; } - -static int -acpi_ec_start ( - struct acpi_device *device) +static int acpi_ec_start(struct acpi_device *device) { - acpi_status status = AE_OK; - union acpi_ec *ec = NULL; + acpi_status status = AE_OK; + union acpi_ec *ec = NULL; ACPI_FUNCTION_TRACE("acpi_ec_start"); @@ -1283,49 +1195,50 @@ acpi_ec_start ( * Get I/O port addresses. Convert to GAS format. */ status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS, - acpi_ec_io_ports, ec); - if (ACPI_FAILURE(status) || ec->common.command_addr.register_bit_width == 0) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting I/O port addresses")); + acpi_ec_io_ports, ec); + if (ACPI_FAILURE(status) + || ec->common.command_addr.register_bit_width == 0) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error getting I/O port addresses")); return_VALUE(-ENODEV); } ec->common.status_addr = ec->common.command_addr; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n", - (u32) ec->common.gpe_bit, (u32) ec->common.command_addr.address, - (u32) ec->common.data_addr.address)); - + (u32) ec->common.gpe_bit, + (u32) ec->common.command_addr.address, + (u32) ec->common.data_addr.address)); /* * Install GPE handler */ status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit, - ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec); + ACPI_GPE_EDGE_TRIGGERED, + &acpi_ec_gpe_handler, ec); if (ACPI_FAILURE(status)) { return_VALUE(-ENODEV); } - acpi_set_gpe_type (NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); - acpi_enable_gpe (NULL, ec->common.gpe_bit, ACPI_NOT_ISR); + acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); + acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); - status = acpi_install_address_space_handler (ec->common.handle, - ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, - &acpi_ec_space_setup, ec); + status = acpi_install_address_space_handler(ec->common.handle, + ACPI_ADR_SPACE_EC, + &acpi_ec_space_handler, + &acpi_ec_space_setup, ec); if (ACPI_FAILURE(status)) { - acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); + acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, + &acpi_ec_gpe_handler); return_VALUE(-ENODEV); } return_VALUE(AE_OK); } - -static int -acpi_ec_stop ( - struct acpi_device *device, - int type) +static int acpi_ec_stop(struct acpi_device *device, int type) { - acpi_status status = AE_OK; - union acpi_ec *ec = NULL; + acpi_status status = AE_OK; + union acpi_ec *ec = NULL; ACPI_FUNCTION_TRACE("acpi_ec_stop"); @@ -1335,11 +1248,14 @@ acpi_ec_stop ( ec = acpi_driver_data(device); status = acpi_remove_address_space_handler(ec->common.handle, - ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); + ACPI_ADR_SPACE_EC, + &acpi_ec_space_handler); if (ACPI_FAILURE(status)) return_VALUE(-ENODEV); - status = acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); + status = + acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, + &acpi_ec_gpe_handler); if (ACPI_FAILURE(status)) return_VALUE(-ENODEV); @@ -1347,32 +1263,26 @@ acpi_ec_stop ( } static acpi_status __init -acpi_fake_ecdt_callback ( - acpi_handle handle, - u32 Level, - void *context, - void **retval) +acpi_fake_ecdt_callback(acpi_handle handle, + u32 Level, void *context, void **retval) { if (acpi_ec_polling_mode) return acpi_fake_ecdt_polling_callback(handle, - Level, context, retval); + Level, context, retval); else return acpi_fake_ecdt_burst_callback(handle, - Level, context, retval); + Level, context, retval); } static acpi_status __init -acpi_fake_ecdt_polling_callback ( - acpi_handle handle, - u32 Level, - void *context, - void **retval) +acpi_fake_ecdt_polling_callback(acpi_handle handle, + u32 Level, void *context, void **retval) { - acpi_status status; + acpi_status status; status = acpi_walk_resources(handle, METHOD_NAME__CRS, - acpi_ec_io_ports, ec_ecdt); + acpi_ec_io_ports, ec_ecdt); if (ACPI_FAILURE(status)) return status; ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; @@ -1380,33 +1290,33 @@ acpi_fake_ecdt_polling_callback ( ec_ecdt->common.uid = -1; acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); - status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit); + status = + acpi_evaluate_integer(handle, "_GPE", NULL, + &ec_ecdt->common.gpe_bit); if (ACPI_FAILURE(status)) return status; spin_lock_init(&ec_ecdt->polling.lock); ec_ecdt->common.global_lock = TRUE; ec_ecdt->common.handle = handle; - printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", - (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address, - (u32) ec_ecdt->common.data_addr.address); + printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", + (u32) ec_ecdt->common.gpe_bit, + (u32) ec_ecdt->common.command_addr.address, + (u32) ec_ecdt->common.data_addr.address); return AE_CTRL_TERMINATE; } static acpi_status __init -acpi_fake_ecdt_burst_callback ( - acpi_handle handle, - u32 Level, - void *context, - void **retval) +acpi_fake_ecdt_burst_callback(acpi_handle handle, + u32 Level, void *context, void **retval) { - acpi_status status; + acpi_status status; init_MUTEX(&ec_ecdt->burst.sem); init_waitqueue_head(&ec_ecdt->burst.wait); status = acpi_walk_resources(handle, METHOD_NAME__CRS, - acpi_ec_io_ports, ec_ecdt); + acpi_ec_io_ports, ec_ecdt); if (ACPI_FAILURE(status)) return status; ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; @@ -1414,15 +1324,18 @@ acpi_fake_ecdt_burst_callback ( ec_ecdt->common.uid = -1; acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); - status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit); + status = + acpi_evaluate_integer(handle, "_GPE", NULL, + &ec_ecdt->common.gpe_bit); if (ACPI_FAILURE(status)) return status; ec_ecdt->common.global_lock = TRUE; ec_ecdt->common.handle = handle; - printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", - (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address, - (u32) ec_ecdt->common.data_addr.address); + printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", + (u32) ec_ecdt->common.gpe_bit, + (u32) ec_ecdt->common.command_addr.address, + (u32) ec_ecdt->common.data_addr.address); return AE_CTRL_TERMINATE; } @@ -1437,11 +1350,10 @@ acpi_fake_ecdt_burst_callback ( * op region (since _REG isn't invoked yet). The assumption is true for * all systems found. */ -static int __init -acpi_ec_fake_ecdt(void) +static int __init acpi_ec_fake_ecdt(void) { - acpi_status status; - int ret = 0; + acpi_status status; + int ret = 0; printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); @@ -1452,10 +1364,8 @@ acpi_ec_fake_ecdt(void) } memset(ec_ecdt, 0, sizeof(union acpi_ec)); - status = acpi_get_devices (ACPI_EC_HID, - acpi_fake_ecdt_callback, - NULL, - NULL); + status = acpi_get_devices(ACPI_EC_HID, + acpi_fake_ecdt_callback, NULL, NULL); if (ACPI_FAILURE(status)) { kfree(ec_ecdt); ec_ecdt = NULL; @@ -1463,13 +1373,12 @@ acpi_ec_fake_ecdt(void) goto error; } return 0; -error: + error: printk(KERN_ERR PREFIX "Can't make an fake ECDT\n"); return ret; } -static int __init -acpi_ec_get_real_ecdt(void) +static int __init acpi_ec_get_real_ecdt(void) { if (acpi_ec_polling_mode) return acpi_ec_polling_get_real_ecdt(); @@ -1477,14 +1386,14 @@ acpi_ec_get_real_ecdt(void) return acpi_ec_burst_get_real_ecdt(); } -static int __init -acpi_ec_polling_get_real_ecdt(void) +static int __init acpi_ec_polling_get_real_ecdt(void) { - acpi_status status; - struct acpi_table_ecdt *ecdt_ptr; + 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); + status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, + (struct acpi_table_header **) + &ecdt_ptr); if (ACPI_FAILURE(status)) return -ENODEV; @@ -1507,13 +1416,14 @@ acpi_ec_polling_get_real_ecdt(void) ec_ecdt->common.global_lock = TRUE; ec_ecdt->common.uid = ecdt_ptr->uid; - status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); + status = + acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); if (ACPI_FAILURE(status)) { goto error; } return 0; -error: + error: printk(KERN_ERR PREFIX "Could not use ECDT\n"); kfree(ec_ecdt); ec_ecdt = NULL; @@ -1521,15 +1431,14 @@ error: return -ENODEV; } - -static int __init -acpi_ec_burst_get_real_ecdt(void) +static int __init acpi_ec_burst_get_real_ecdt(void) { - acpi_status status; - struct acpi_table_ecdt *ecdt_ptr; + 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); + (struct acpi_table_header **) + &ecdt_ptr); if (ACPI_FAILURE(status)) return -ENODEV; @@ -1543,8 +1452,8 @@ acpi_ec_burst_get_real_ecdt(void) return -ENOMEM; memset(ec_ecdt, 0, sizeof(union acpi_ec)); - init_MUTEX(&ec_ecdt->burst.sem); - init_waitqueue_head(&ec_ecdt->burst.wait); + init_MUTEX(&ec_ecdt->burst.sem); + init_waitqueue_head(&ec_ecdt->burst.wait); ec_ecdt->common.command_addr = ecdt_ptr->ec_control; ec_ecdt->common.status_addr = ecdt_ptr->ec_control; ec_ecdt->common.data_addr = ecdt_ptr->ec_data; @@ -1553,13 +1462,14 @@ acpi_ec_burst_get_real_ecdt(void) ec_ecdt->common.global_lock = TRUE; ec_ecdt->common.uid = ecdt_ptr->uid; - status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); + status = + acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); if (ACPI_FAILURE(status)) { goto error; } return 0; -error: + error: printk(KERN_ERR PREFIX "Could not use ECDT\n"); kfree(ec_ecdt); ec_ecdt = NULL; @@ -1568,11 +1478,10 @@ error: } static int __initdata acpi_fake_ecdt_enabled; -int __init -acpi_ec_ecdt_probe (void) +int __init acpi_ec_ecdt_probe(void) { - acpi_status status; - int ret; + acpi_status status; + int ret; ret = acpi_ec_get_real_ecdt(); /* Try to make a fake ECDT */ @@ -1587,26 +1496,28 @@ acpi_ec_ecdt_probe (void) * Install GPE handler */ status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit, - ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, - ec_ecdt); + ACPI_GPE_EDGE_TRIGGERED, + &acpi_ec_gpe_handler, ec_ecdt); if (ACPI_FAILURE(status)) { goto error; } - acpi_set_gpe_type (NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); - acpi_enable_gpe (NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR); - - status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, - &acpi_ec_space_setup, ec_ecdt); + acpi_set_gpe_type(NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); + acpi_enable_gpe(NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR); + + status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT, + ACPI_ADR_SPACE_EC, + &acpi_ec_space_handler, + &acpi_ec_space_setup, + ec_ecdt); if (ACPI_FAILURE(status)) { acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, - &acpi_ec_gpe_handler); + &acpi_ec_gpe_handler); goto error; } return 0; -error: + error: printk(KERN_ERR PREFIX "Could not use ECDT\n"); kfree(ec_ecdt); ec_ecdt = NULL; @@ -1614,10 +1525,9 @@ error: return -ENODEV; } - -static int __init acpi_ec_init (void) +static int __init acpi_ec_init(void) { - int result = 0; + int result = 0; ACPI_FUNCTION_TRACE("acpi_ec_init"); @@ -1642,8 +1552,7 @@ subsys_initcall(acpi_ec_init); /* EC driver currently not unloadable */ #if 0 -static void __exit -acpi_ec_exit (void) +static void __exit acpi_ec_exit(void) { ACPI_FUNCTION_TRACE("acpi_ec_exit"); @@ -1653,7 +1562,7 @@ acpi_ec_exit (void) return_VOID; } -#endif /* 0 */ +#endif /* 0 */ static int __init acpi_fake_ecdt_setup(char *str) { @@ -1676,8 +1585,8 @@ static int __init acpi_ec_set_polling_mode(char *str) acpi_ec_polling_mode = EC_POLLING; acpi_ec_driver.ops.add = acpi_ec_polling_add; } - printk(KERN_INFO PREFIX "EC %s mode.\n", - burst ? "burst": "polling"); + printk(KERN_INFO PREFIX "EC %s mode.\n", burst ? "burst" : "polling"); return 0; } + __setup("ec_burst=", acpi_ec_set_polling_mode); -- cgit v0.10.2 From 46acac3b4fd8ef66eec63b51de8d556a17c7d4f7 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 11 Aug 2005 20:28:56 -0700 Subject: [AGPGART] Drop duplicate setting of info->mode in agp_copy_info() Spotted by Jeremy Fitzhardinge, this change crept in with the multiple backend support. It's clearly incorrect to overwrite info->mode after we just went to lengths to determine which bits to mask out. Signed-off-by: Dave Jones diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index f0079e9..eb05242 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c @@ -319,7 +319,6 @@ int agp_copy_info(struct agp_bridge_data *bridge, struct agp_kern_info *info) info->mode = bridge->mode & ~AGP3_RESERVED_MASK; else info->mode = bridge->mode & ~AGP2_RESERVED_MASK; - info->mode = bridge->mode; info->aper_base = bridge->gart_bus_addr; info->aper_size = agp_return_size(); info->max_memory = bridge->max_memory_agp; -- cgit v0.10.2 From 1dadb3dadfaa01890fc10df03f0dd03a9f8774b2 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Wed, 27 Jul 2005 18:32:00 -0400 Subject: [ACPI] don't complain about PCI root bridges without _SEG There are lots of single-PCI-segment machines that don't supply _SEG for the root bridges. The PCI root bridge driver silently assumes the segment to be zero in this case, so glue.c shouldn't complain either. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 1943461..e36c5da 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -170,9 +170,6 @@ find_pci_rootbridge(acpi_handle handle, u32 lvl, void *context, void **rv) status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL, &seg); if (status == AE_NOT_FOUND) { /* Assume seg = 0 */ - printk(KERN_INFO PREFIX - "Assume root bridge [%s] segment is 0\n", - (char *)buffer.pointer); status = AE_OK; seg = 0; } -- cgit v0.10.2 From 702c7e7626deeabb057b6f529167b65ec2eefbdb Mon Sep 17 00:00:00 2001 From: MAEDA Naoaki Date: Mon, 8 Aug 2005 01:09:00 -0400 Subject: [ACPI] fix ia64 build issues resulting from Lindent and merge Signed-off-by: MAEDA Naoaki Signed-off-by: Andrew Morton Signed-off-by: Brown, Len diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index f3046bd..78bc219 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c @@ -74,7 +74,7 @@ unsigned int acpi_cpei_override; unsigned int acpi_cpei_phys_cpuid; #define MAX_SAPICS 256 -u16 ia64_acpiid_to_sapicid[MAX_SAPICS] = {[0...MAX_SAPICS - 1] = -1 }; +u16 ia64_acpiid_to_sapicid[MAX_SAPICS] = {[0 ... MAX_SAPICS - 1] = -1 }; EXPORT_SYMBOL(ia64_acpiid_to_sapicid); @@ -138,7 +138,7 @@ const char *acpi_get_sysname(void) /* Array to record platform interrupt vectors for generic interrupt routing. */ int platform_intr_list[ACPI_MAX_PLATFORM_INTERRUPTS] = { - [0...ACPI_MAX_PLATFORM_INTERRUPTS - 1] = -1 + [0 ... ACPI_MAX_PLATFORM_INTERRUPTS - 1] = -1 }; enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC; diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c index 8f53915..a13df59 100644 --- a/arch/ia64/kernel/iosapic.c +++ b/arch/ia64/kernel/iosapic.c @@ -735,11 +735,11 @@ again: spin_unlock_irqrestore(&iosapic_lock, flags); /* If vector is running out, we try to find a sharable vector */ - vector = assign_irq_vector_nopanic(AUTO_ASSIGN); + vector = assign_irq_vector(AUTO_ASSIGN); if (vector < 0) { vector = iosapic_find_sharable_vector(trigger, polarity); if (vector < 0) - Return -ENOSPC; + return -ENOSPC; } spin_lock_irqsave(&irq_descp(vector)->lock, flags); -- cgit v0.10.2 From 8c8b83854ea973ee7f37db6612d10d3acc5531d9 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Wed, 17 Aug 2005 23:08:11 -0700 Subject: Fix up various printk levels and whitespace corrections. Signed-off-by: Andrew Morton Signed-off-by: Dave Jones diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index eb05242..ac9da0c 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c @@ -355,7 +355,7 @@ int agp_bind_memory(struct agp_memory *curr, off_t pg_start) return -EINVAL; if (curr->is_bound == TRUE) { - printk (KERN_INFO PFX "memory %p is already bound!\n", curr); + printk(KERN_INFO PFX "memory %p is already bound!\n", curr); return -EINVAL; } if (curr->is_flushed == FALSE) { @@ -390,7 +390,7 @@ int agp_unbind_memory(struct agp_memory *curr) return -EINVAL; if (curr->is_bound != TRUE) { - printk (KERN_INFO PFX "memory %p was not bound!\n", curr); + printk(KERN_INFO PFX "memory %p was not bound!\n", curr); return -EINVAL; } @@ -414,7 +414,7 @@ static void agp_v2_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ u32 tmp; if (*requested_mode & AGP2_RESERVED_MASK) { - printk (KERN_INFO PFX "reserved bits set in mode 0x%x. Fixed.\n", *requested_mode); + printk(KERN_INFO PFX "reserved bits set in mode 0x%x. Fixed.\n", *requested_mode); *requested_mode &= ~AGP2_RESERVED_MASK; } @@ -422,7 +422,7 @@ static void agp_v2_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ tmp = *requested_mode & 7; switch (tmp) { case 0: - printk (KERN_INFO PFX "%s tried to set rate=x0. Setting to x1 mode.\n", current->comm); + printk(KERN_INFO PFX "%s tried to set rate=x0. Setting to x1 mode.\n", current->comm); *requested_mode |= AGPSTAT2_1X; break; case 1: @@ -492,18 +492,18 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ u32 tmp; if (*requested_mode & AGP3_RESERVED_MASK) { - printk (KERN_INFO PFX "reserved bits set in mode 0x%x. Fixed.\n", *requested_mode); + printk(KERN_INFO PFX "reserved bits set in mode 0x%x. Fixed.\n", *requested_mode); *requested_mode &= ~AGP3_RESERVED_MASK; } /* Check the speed bits make sense. */ tmp = *requested_mode & 7; if (tmp == 0) { - printk (KERN_INFO PFX "%s tried to set rate=x0. Setting to AGP3 x4 mode.\n", current->comm); + printk(KERN_INFO PFX "%s tried to set rate=x0. Setting to AGP3 x4 mode.\n", current->comm); *requested_mode |= AGPSTAT3_4X; } if (tmp >= 3) { - printk (KERN_INFO PFX "%s tried to set rate=x%d. Setting to AGP3 x8 mode.\n", current->comm, tmp * 4); + printk(KERN_INFO PFX "%s tried to set rate=x%d. Setting to AGP3 x8 mode.\n", current->comm, tmp * 4); *requested_mode = (*requested_mode & ~7) | AGPSTAT3_8X; } @@ -532,7 +532,7 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ * AGP2.x 4x -> AGP3.0 4x. */ if (*requested_mode & AGPSTAT2_4X) { - printk (KERN_INFO PFX "%s passes broken AGP3 flags (%x). Fixed.\n", + printk(KERN_INFO PFX "%s passes broken AGP3 flags (%x). Fixed.\n", current->comm, *requested_mode); *requested_mode &= ~AGPSTAT2_4X; *requested_mode |= AGPSTAT3_4X; @@ -543,7 +543,7 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ * but have been passed an AGP 2.x mode. * Convert AGP 1x,2x,4x -> AGP 3.0 4x. */ - printk (KERN_INFO PFX "%s passes broken AGP2 flags (%x) in AGP3 mode. Fixed.\n", + printk(KERN_INFO PFX "%s passes broken AGP2 flags (%x) in AGP3 mode. Fixed.\n", current->comm, *requested_mode); *requested_mode &= ~(AGPSTAT2_4X | AGPSTAT2_2X | AGPSTAT2_1X); *requested_mode |= AGPSTAT3_4X; @@ -553,13 +553,13 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ if (!(*bridge_agpstat & AGPSTAT3_8X)) { *bridge_agpstat &= ~(AGPSTAT3_8X | AGPSTAT3_RSVD); *bridge_agpstat |= AGPSTAT3_4X; - printk ("%s requested AGPx8 but bridge not capable.\n", current->comm); + printk(KERN_INFO PFX "%s requested AGPx8 but bridge not capable.\n", current->comm); return; } if (!(*vga_agpstat & AGPSTAT3_8X)) { *bridge_agpstat &= ~(AGPSTAT3_8X | AGPSTAT3_RSVD); *bridge_agpstat |= AGPSTAT3_4X; - printk ("%s requested AGPx8 but graphic card not capable.\n", current->comm); + printk(KERN_INFO PFX "%s requested AGPx8 but graphic card not capable.\n", current->comm); return; } /* All set, bridge & device can do AGP x8*/ @@ -577,13 +577,13 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ if ((*bridge_agpstat & AGPSTAT3_4X) && (*vga_agpstat & AGPSTAT3_4X)) *bridge_agpstat |= AGPSTAT3_4X; else { - printk (KERN_INFO PFX "Badness. Don't know which AGP mode to set. " + printk(KERN_INFO PFX "Badness. Don't know which AGP mode to set. " "[bridge_agpstat:%x vga_agpstat:%x fell back to:- bridge_agpstat:%x vga_agpstat:%x]\n", origbridge, origvga, *bridge_agpstat, *vga_agpstat); if (!(*bridge_agpstat & AGPSTAT3_4X)) - printk (KERN_INFO PFX "Bridge couldn't do AGP x4.\n"); + printk(KERN_INFO PFX "Bridge couldn't do AGP x4.\n"); if (!(*vga_agpstat & AGPSTAT3_4X)) - printk (KERN_INFO PFX "Graphic card couldn't do AGP x4.\n"); + printk(KERN_INFO PFX "Graphic card couldn't do AGP x4.\n"); return; } } @@ -621,7 +621,7 @@ u32 agp_collect_device_status(struct agp_bridge_data *bridge, u32 requested_mode for (;;) { device = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, device); if (!device) { - printk (KERN_INFO PFX "Couldn't find an AGP VGA controller.\n"); + printk(KERN_INFO PFX "Couldn't find an AGP VGA controller.\n"); return 0; } cap_ptr = pci_find_capability(device, PCI_CAP_ID_AGP); @@ -733,7 +733,7 @@ void agp_generic_enable(struct agp_bridge_data *bridge, u32 requested_mode) pci_write_config_dword(bridge->dev, bridge->capndx+AGPCTRL, temp); - printk (KERN_INFO PFX "Device is in legacy mode," + printk(KERN_INFO PFX "Device is in legacy mode," " falling back to 2.x\n"); } } -- cgit v0.10.2 From 888ba6c62bc61a995d283977eb3a6cbafd6f4ac6 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Wed, 24 Aug 2005 12:07:20 -0400 Subject: [ACPI] delete CONFIG_ACPI_BOOT it has been a synonym for CONFIG_ACPI since 2.6.12 Signed-off-by: Len Brown diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig index 619d843..9ba3349 100644 --- a/arch/i386/Kconfig +++ b/arch/i386/Kconfig @@ -1203,7 +1203,6 @@ config PCI_DIRECT config PCI_MMCONFIG bool depends on PCI && ACPI && (PCI_GOMMCONFIG || PCI_GOANY) - select ACPI_BOOT default y source "drivers/pci/pcie/Kconfig" diff --git a/arch/i386/defconfig b/arch/i386/defconfig index ca07b95..1c0076e 100644 --- a/arch/i386/defconfig +++ b/arch/i386/defconfig @@ -131,7 +131,6 @@ CONFIG_SOFTWARE_SUSPEND=y # ACPI (Advanced Configuration and Power Interface) Support # CONFIG_ACPI=y -CONFIG_ACPI_BOOT=y CONFIG_ACPI_INTERPRETER=y CONFIG_ACPI_SLEEP=y CONFIG_ACPI_SLEEP_PROC_FS=y diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile index 4cc83b3..c52b4fa 100644 --- a/arch/i386/kernel/Makefile +++ b/arch/i386/kernel/Makefile @@ -11,7 +11,7 @@ obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \ obj-y += cpu/ obj-y += timers/ -obj-$(CONFIG_ACPI_BOOT) += acpi/ +obj-$(CONFIG_ACPI) += acpi/ obj-$(CONFIG_X86_BIOS_REBOOT) += reboot.o obj-$(CONFIG_MCA) += mca.o obj-$(CONFIG_X86_MSR) += msr.o diff --git a/arch/i386/kernel/acpi/Makefile b/arch/i386/kernel/acpi/Makefile index 5e291a2..267ca48 100644 --- a/arch/i386/kernel/acpi/Makefile +++ b/arch/i386/kernel/acpi/Makefile @@ -1,4 +1,4 @@ -obj-$(CONFIG_ACPI_BOOT) := boot.o +obj-y := boot.o obj-$(CONFIG_X86_IO_APIC) += earlyquirk.o obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c index 6578f40..ebedd2e 100644 --- a/arch/i386/kernel/io_apic.c +++ b/arch/i386/kernel/io_apic.c @@ -2421,7 +2421,7 @@ device_initcall(ioapic_init_sysfs); ACPI-based IOAPIC Configuration -------------------------------------------------------------------------- */ -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI int __init io_apic_get_unique_id (int ioapic, int apic_id) { @@ -2574,4 +2574,4 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a return 0; } -#endif /*CONFIG_ACPI_BOOT*/ +#endif /* CONFIG_ACPI */ diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c index ce838ab..9a4db7d 100644 --- a/arch/i386/kernel/mpparse.c +++ b/arch/i386/kernel/mpparse.c @@ -653,8 +653,6 @@ void __init get_smp_config (void) struct intel_mp_floating *mpf = mpf_found; /* - * ACPI may be used to obtain the entire SMP configuration or just to - * enumerate/configure processors (CONFIG_ACPI_BOOT). Note that * ACPI supports both logical (e.g. Hyper-Threading) and physical * processors, where MPS only supports physical. */ @@ -810,7 +808,7 @@ void __init find_smp_config (void) ACPI-based MP Configuration -------------------------------------------------------------------------- */ -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI void __init mp_register_lapic_address ( u64 address) @@ -856,7 +854,7 @@ void __init mp_register_lapic ( MP_processor_info(&processor); } -#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT)) +#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) #define MP_ISA_BUS 0 #define MP_MAX_IOAPIC_PIN 127 @@ -1138,5 +1136,5 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low) return gsi; } -#endif /*CONFIG_X86_IO_APIC && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)*/ -#endif /*CONFIG_ACPI_BOOT*/ +#endif /* CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER */ +#endif /* CONFIG_ACPI */ diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c index af4de58..d3943e5 100644 --- a/arch/i386/kernel/setup.c +++ b/arch/i386/kernel/setup.c @@ -94,7 +94,7 @@ unsigned long mmu_cr4_features; #endif EXPORT_SYMBOL(acpi_disabled); -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI int __initdata acpi_force = 0; extern acpi_interrupt_flags acpi_sci_flags; #endif @@ -794,7 +794,7 @@ static void __init parse_cmdline_early (char ** cmdline_p) } #endif -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI /* "acpi=off" disables both ACPI table parsing and interpreter */ else if (!memcmp(from, "acpi=off", 8)) { disable_acpi(); @@ -850,7 +850,7 @@ static void __init parse_cmdline_early (char ** cmdline_p) else if (!memcmp(from, "noapic", 6)) disable_ioapic_setup(); #endif /* CONFIG_X86_LOCAL_APIC */ -#endif /* CONFIG_ACPI_BOOT */ +#endif /* CONFIG_ACPI */ #ifdef CONFIG_X86_LOCAL_APIC /* enable local APIC */ @@ -1575,7 +1575,7 @@ void __init setup_arch(char **cmdline_p) if (efi_enabled) efi_map_memmap(); -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI /* * Parse the ACPI tables for possible boot-time SMP configuration. */ diff --git a/arch/i386/mach-es7000/es7000plat.c b/arch/i386/mach-es7000/es7000plat.c index d5936d5..baac9da 100644 --- a/arch/i386/mach-es7000/es7000plat.c +++ b/arch/i386/mach-es7000/es7000plat.c @@ -51,7 +51,7 @@ struct mip_reg *host_reg; int mip_port; unsigned long mip_addr, host_addr; -#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT)) +#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) /* * GSI override for ES7000 platforms. @@ -73,7 +73,7 @@ es7000_rename_gsi(int ioapic, int gsi) return gsi; } -#endif // (CONFIG_X86_IO_APIC) && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT) +#endif // (CONFIG_X86_IO_APIC) && (CONFIG_ACPI_INTERPRETER) /* * Parse the OEM Table diff --git a/arch/ia64/configs/bigsur_defconfig b/arch/ia64/configs/bigsur_defconfig index b95fcf8..456c656 100644 --- a/arch/ia64/configs/bigsur_defconfig +++ b/arch/ia64/configs/bigsur_defconfig @@ -107,7 +107,6 @@ CONFIG_ACPI=y # # ACPI (Advanced Configuration and Power Interface) Support # -CONFIG_ACPI_BOOT=y CONFIG_ACPI_INTERPRETER=y CONFIG_ACPI_BUTTON=m CONFIG_ACPI_VIDEO=m diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig index dccf35c..dc483c1 100644 --- a/arch/ia64/configs/sn2_defconfig +++ b/arch/ia64/configs/sn2_defconfig @@ -130,7 +130,6 @@ CONFIG_ACPI=y # # ACPI (Advanced Configuration and Power Interface) Support # -CONFIG_ACPI_BOOT=y CONFIG_ACPI_INTERPRETER=y # CONFIG_ACPI_BUTTON is not set CONFIG_ACPI_VIDEO=m diff --git a/arch/ia64/configs/tiger_defconfig b/arch/ia64/configs/tiger_defconfig index c853cfc..cd2d637 100644 --- a/arch/ia64/configs/tiger_defconfig +++ b/arch/ia64/configs/tiger_defconfig @@ -128,7 +128,6 @@ CONFIG_ACPI=y # # ACPI (Advanced Configuration and Power Interface) Support # -CONFIG_ACPI_BOOT=y CONFIG_ACPI_INTERPRETER=y CONFIG_ACPI_BUTTON=m # CONFIG_ACPI_VIDEO is not set diff --git a/arch/ia64/configs/zx1_defconfig b/arch/ia64/configs/zx1_defconfig index 88e8867..cf58404 100644 --- a/arch/ia64/configs/zx1_defconfig +++ b/arch/ia64/configs/zx1_defconfig @@ -128,7 +128,6 @@ CONFIG_ACPI=y # # ACPI (Advanced Configuration and Power Interface) Support # -CONFIG_ACPI_BOOT=y CONFIG_ACPI_INTERPRETER=y CONFIG_ACPI_BUTTON=y CONFIG_ACPI_VIDEO=m diff --git a/arch/ia64/defconfig b/arch/ia64/defconfig index 8444add..f38c677 100644 --- a/arch/ia64/defconfig +++ b/arch/ia64/defconfig @@ -118,7 +118,6 @@ CONFIG_ACPI=y # # ACPI (Advanced Configuration and Power Interface) Support # -CONFIG_ACPI_BOOT=y CONFIG_ACPI_INTERPRETER=y CONFIG_ACPI_BUTTON=m CONFIG_ACPI_VIDEO=m diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index 78bc219..318787c 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c @@ -132,7 +132,7 @@ const char *acpi_get_sysname(void) #endif } -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI #define ACPI_MAX_PLATFORM_INTERRUPTS 256 @@ -917,4 +917,4 @@ int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base) EXPORT_SYMBOL(acpi_unregister_ioapic); -#endif /* CONFIG_ACPI_BOOT */ +#endif /* CONFIG_ACPI */ diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index 84f89da..1f5c26d 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -384,7 +384,7 @@ setup_arch (char **cmdline_p) if (early_console_setup(*cmdline_p) == 0) mark_bsp_online(); -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI /* Initialize the ACPI boot-time table parser */ acpi_table_init(); # ifdef CONFIG_ACPI_NUMA @@ -420,7 +420,7 @@ setup_arch (char **cmdline_p) cpu_init(); /* initialize the bootstrap CPU */ -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI acpi_boot_init(); #endif diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c index 92ff46a..706b773 100644 --- a/arch/ia64/kernel/topology.c +++ b/arch/ia64/kernel/topology.c @@ -36,7 +36,7 @@ int arch_register_cpu(int num) parent = &sysfs_nodes[cpu_to_node(num)]; #endif /* CONFIG_NUMA */ -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI /* * If CPEI cannot be re-targetted, and this is * CPEI target, then dont create the control file diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig index 660a03a..40242c6 100644 --- a/arch/x86_64/Kconfig +++ b/arch/x86_64/Kconfig @@ -144,7 +144,6 @@ config X86_CPUID with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to /dev/cpu/31/cpuid. -# disable it for opteron optimized builds because it pulls in ACPI_BOOT config X86_HT bool depends on SMP && !MK8 @@ -461,7 +460,6 @@ config PCI_DIRECT config PCI_MMCONFIG bool "Support mmconfig PCI config space access" depends on PCI && ACPI - select ACPI_BOOT config UNORDERED_IO bool "Unordered IO mapping access" diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig index 776f3c8..aed77c1 100644 --- a/arch/x86_64/defconfig +++ b/arch/x86_64/defconfig @@ -135,7 +135,6 @@ CONFIG_PM_STD_PARTITION="" # ACPI (Advanced Configuration and Power Interface) Support # CONFIG_ACPI=y -CONFIG_ACPI_BOOT=y CONFIG_ACPI_INTERPRETER=y CONFIG_ACPI_AC=y CONFIG_ACPI_BATTERY=y diff --git a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile index 48f9e2c..0296ca6 100644 --- a/arch/x86_64/kernel/Makefile +++ b/arch/x86_64/kernel/Makefile @@ -12,7 +12,7 @@ obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \ obj-$(CONFIG_X86_MCE) += mce.o obj-$(CONFIG_X86_MCE_INTEL) += mce_intel.o obj-$(CONFIG_MTRR) += ../../i386/kernel/cpu/mtrr/ -obj-$(CONFIG_ACPI_BOOT) += acpi/ +obj-$(CONFIG_ACPI) += acpi/ obj-$(CONFIG_X86_MSR) += msr.o obj-$(CONFIG_MICROCODE) += microcode.o obj-$(CONFIG_X86_CPUID) += cpuid.o diff --git a/arch/x86_64/kernel/acpi/Makefile b/arch/x86_64/kernel/acpi/Makefile index d2c2ee5..7da9ace 100644 --- a/arch/x86_64/kernel/acpi/Makefile +++ b/arch/x86_64/kernel/acpi/Makefile @@ -1,3 +1,3 @@ -obj-$(CONFIG_ACPI_BOOT) := boot.o -boot-$(CONFIG_ACPI_BOOT) := ../../../i386/kernel/acpi/boot.o +obj-y := boot.o +boot-y := ../../../i386/kernel/acpi/boot.o obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c index d206d7e..1013a8f 100644 --- a/arch/x86_64/kernel/io_apic.c +++ b/arch/x86_64/kernel/io_apic.c @@ -1841,7 +1841,7 @@ device_initcall(ioapic_init_sysfs); ACPI-based IOAPIC Configuration -------------------------------------------------------------------------- */ -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI #define IO_APIC_MAX_ID 0xFE @@ -1923,7 +1923,7 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a return 0; } -#endif /*CONFIG_ACPI_BOOT*/ +#endif /* CONFIG_ACPI */ /* diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c index 79c362d..86445f3 100644 --- a/arch/x86_64/kernel/mpparse.c +++ b/arch/x86_64/kernel/mpparse.c @@ -74,7 +74,7 @@ static unsigned int num_processors = 0; physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE; /* ACPI MADT entry parsing functions */ -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI extern struct acpi_boot_flags acpi_boot; #ifdef CONFIG_X86_LOCAL_APIC extern int acpi_parse_lapic (acpi_table_entry_header *header); @@ -84,7 +84,7 @@ extern int acpi_parse_lapic_nmi (acpi_table_entry_header *header); #ifdef CONFIG_X86_IO_APIC extern int acpi_parse_ioapic (acpi_table_entry_header *header); #endif /*CONFIG_X86_IO_APIC*/ -#endif /*CONFIG_ACPI_BOOT*/ +#endif /*CONFIG_ACPI*/ u8 bios_cpu_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID }; @@ -519,8 +519,6 @@ void __init get_smp_config (void) struct intel_mp_floating *mpf = mpf_found; /* - * ACPI may be used to obtain the entire SMP configuration or just to - * enumerate/configure processors (CONFIG_ACPI_BOOT). Note that * ACPI supports both logical (e.g. Hyper-Threading) and physical * processors, where MPS only supports physical. */ @@ -673,7 +671,7 @@ void __init find_smp_config (void) ACPI-based MP Configuration -------------------------------------------------------------------------- */ -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI void __init mp_register_lapic_address ( u64 address) @@ -994,4 +992,4 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low) } #endif /*CONFIG_X86_IO_APIC*/ -#endif /*CONFIG_ACPI_BOOT*/ +#endif /*CONFIG_ACPI*/ diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c index 116a491..cfcebc8 100644 --- a/arch/x86_64/kernel/setup.c +++ b/arch/x86_64/kernel/setup.c @@ -71,7 +71,7 @@ unsigned long mmu_cr4_features; int acpi_disabled; EXPORT_SYMBOL(acpi_disabled); -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI extern int __initdata acpi_ht; extern acpi_interrupt_flags acpi_sci_flags; int __initdata acpi_force = 0; @@ -294,7 +294,7 @@ static __init void parse_cmdline_early (char ** cmdline_p) maxcpus = simple_strtoul(from + 8, NULL, 0); } #endif -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI /* "acpi=off" disables both ACPI table parsing and interpreter init */ if (!memcmp(from, "acpi=off", 8)) disable_acpi(); @@ -566,7 +566,7 @@ void __init setup_arch(char **cmdline_p) init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT)); -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI /* * Initialize the ACPI boot-time table parser (gets the RSDP and SDT). * Call this early for SRAT node setup. @@ -658,7 +658,7 @@ void __init setup_arch(char **cmdline_p) check_ioapic(); -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI /* * Read APIC and some other early information from ACPI tables. */ diff --git a/drivers/Makefile b/drivers/Makefile index 126a851..784b93c 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -8,7 +8,7 @@ obj-$(CONFIG_PCI) += pci/ obj-$(CONFIG_PARISC) += parisc/ obj-y += video/ -obj-$(CONFIG_ACPI_BOOT) += acpi/ +obj-$(CONFIG_ACPI) += acpi/ # PnP must come after ACPI since it will eventually need to check if acpi # was used and do nothing if so obj-$(CONFIG_PNP) += pnp/ diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 66c6098..14b70c2 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -43,10 +43,6 @@ config ACPI if ACPI -config ACPI_BOOT - bool - default y - config ACPI_INTERPRETER bool default y @@ -312,7 +308,7 @@ endif # ACPI_INTERPRETER config X86_PM_TIMER bool "Power Management Timer Support" depends on X86 - depends on ACPI_BOOT && EXPERIMENTAL + depends on EXPERIMENTAL depends on !X86_64 default n help diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index ad67e8f..952ab35 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -15,7 +15,7 @@ EXTRA_CFLAGS += $(ACPI_CFLAGS) # # ACPI Boot-Time Table Parsing # -obj-$(CONFIG_ACPI_BOOT) += tables.o +obj-y += tables.o obj-$(CONFIG_ACPI_INTERPRETER) += blacklist.o # diff --git a/include/asm-i386/acpi.h b/include/asm-i386/acpi.h index cf828ac..1f1ade9 100644 --- a/include/asm-i386/acpi.h +++ b/include/asm-i386/acpi.h @@ -103,7 +103,7 @@ __acpi_release_global_lock (unsigned int *lock) :"=r"(n_hi), "=r"(n_lo) \ :"0"(n_hi), "1"(n_lo)) -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI extern int acpi_lapic; extern int acpi_ioapic; extern int acpi_noirq; @@ -146,7 +146,7 @@ static inline void check_acpi_pci(void) { } #endif -#else /* CONFIG_ACPI_BOOT */ +#else /* !CONFIG_ACPI */ # define acpi_lapic 0 # define acpi_ioapic 0 diff --git a/include/asm-i386/fixmap.h b/include/asm-i386/fixmap.h index c94cac9..cfb1c61 100644 --- a/include/asm-i386/fixmap.h +++ b/include/asm-i386/fixmap.h @@ -76,7 +76,7 @@ enum fixed_addresses { FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, #endif -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI FIX_ACPI_BEGIN, FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1, #endif diff --git a/include/asm-i386/io_apic.h b/include/asm-i386/io_apic.h index 002c203..51c4e5f 100644 --- a/include/asm-i386/io_apic.h +++ b/include/asm-i386/io_apic.h @@ -195,12 +195,12 @@ extern int skip_ioapic_setup; */ #define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs) -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI extern int io_apic_get_unique_id (int ioapic, int apic_id); extern int io_apic_get_version (int ioapic); extern int io_apic_get_redir_entries (int ioapic); extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low); -#endif /*CONFIG_ACPI_BOOT*/ +#endif /* CONFIG_ACPI */ extern int (*ioapic_renumber_irq)(int ioapic, int irq); diff --git a/include/asm-i386/mpspec.h b/include/asm-i386/mpspec.h index d9fafba..b9e9f66 100644 --- a/include/asm-i386/mpspec.h +++ b/include/asm-i386/mpspec.h @@ -26,14 +26,14 @@ extern unsigned long mp_lapic_addr; extern int pic_mode; extern int using_apic_timer; -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI extern void mp_register_lapic (u8 id, u8 enabled); extern void mp_register_lapic_address (u64 address); extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base); extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi); extern void mp_config_acpi_legacy_irqs (void); extern int mp_register_gsi (u32 gsi, int edge_level, int active_high_low); -#endif /*CONFIG_ACPI_BOOT*/ +#endif /* CONFIG_ACPI */ #define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS) diff --git a/include/asm-x86_64/acpi.h b/include/asm-x86_64/acpi.h index dc8c981..7d537e1 100644 --- a/include/asm-x86_64/acpi.h +++ b/include/asm-x86_64/acpi.h @@ -101,7 +101,7 @@ __acpi_release_global_lock (unsigned int *lock) :"=r"(n_hi), "=r"(n_lo) \ :"0"(n_hi), "1"(n_lo)) -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI extern int acpi_lapic; extern int acpi_ioapic; extern int acpi_noirq; @@ -122,10 +122,10 @@ static inline void disable_acpi(void) extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq); -#else /* !CONFIG_ACPI_BOOT */ +#else /* !CONFIG_ACPI */ #define acpi_lapic 0 #define acpi_ioapic 0 -#endif /* !CONFIG_ACPI_BOOT */ +#endif /* !CONFIG_ACPI */ extern int acpi_numa; extern int acpi_scan_nodes(unsigned long start, unsigned long end); diff --git a/include/asm-x86_64/io_apic.h b/include/asm-x86_64/io_apic.h index a8babd2..ee1bc69 100644 --- a/include/asm-x86_64/io_apic.h +++ b/include/asm-x86_64/io_apic.h @@ -201,7 +201,7 @@ extern int skip_ioapic_setup; */ #define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs) -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI extern int io_apic_get_version (int ioapic); extern int io_apic_get_redir_entries (int ioapic); extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int, int); diff --git a/include/asm-x86_64/mpspec.h b/include/asm-x86_64/mpspec.h index 331f6a3..f267e10 100644 --- a/include/asm-x86_64/mpspec.h +++ b/include/asm-x86_64/mpspec.h @@ -179,7 +179,7 @@ extern int mpc_default_type; extern unsigned long mp_lapic_addr; extern int pic_mode; -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI extern void mp_register_lapic (u8 id, u8 enabled); extern void mp_register_lapic_address (u64 address); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index fd48db3..fa1ad1a 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -41,7 +41,7 @@ #include -#ifdef CONFIG_ACPI_BOOT +#ifdef CONFIG_ACPI enum acpi_irq_model_id { ACPI_IRQ_MODEL_PIC = 0, @@ -429,11 +429,11 @@ extern int pci_mmcfg_config_num; extern int sbf_port ; -#else /*!CONFIG_ACPI_BOOT*/ +#else /* !CONFIG_ACPI */ #define acpi_mp_config 0 -#endif /*!CONFIG_ACPI_BOOT*/ +#endif /* !CONFIG_ACPI */ int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low); int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); -- cgit v0.10.2 From 8466361ad5233d4356a4601e16b66c25277920d1 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Wed, 24 Aug 2005 12:09:07 -0400 Subject: [ACPI] delete CONFIG_ACPI_INTERPRETER it is a synonym for CONFIG_ACPI Signed-off-by: Len Brown diff --git a/arch/i386/defconfig b/arch/i386/defconfig index 1c0076e..f137a32 100644 --- a/arch/i386/defconfig +++ b/arch/i386/defconfig @@ -131,7 +131,6 @@ CONFIG_SOFTWARE_SUSPEND=y # ACPI (Advanced Configuration and Power Interface) Support # CONFIG_ACPI=y -CONFIG_ACPI_INTERPRETER=y CONFIG_ACPI_SLEEP=y CONFIG_ACPI_SLEEP_PROC_FS=y CONFIG_ACPI_AC=y diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index 09700d8..84befae 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c @@ -303,7 +303,7 @@ acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end) #endif /*CONFIG_X86_LOCAL_APIC */ -#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) +#ifdef CONFIG_X86_IO_APIC static int __init acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end) @@ -634,10 +634,8 @@ static int __init acpi_parse_fadt(unsigned long phys, unsigned long size) printk(KERN_WARNING PREFIX "Unable to map FADT\n"); return 0; } -#ifdef CONFIG_ACPI_INTERPRETER /* initialize sci_int early for INT_SRC_OVR MADT parsing */ acpi_fadt.sci_int = fadt->sci_int; -#endif #ifdef CONFIG_ACPI_BUS /* initialize rev and apic_phys_dest_mode for x86_64 genapic */ @@ -735,7 +733,7 @@ static int __init acpi_parse_madt_lapic_entries(void) } #endif /* CONFIG_X86_LOCAL_APIC */ -#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) +#ifdef CONFIG_X86_IO_APIC /* * Parse IOAPIC related entries in MADT * returns 0 on success, < 0 on error @@ -810,7 +808,7 @@ static inline int acpi_parse_madt_ioapic_entries(void) { return -1; } -#endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */ +#endif /* !CONFIG_X86_IO_APIC */ static void __init acpi_process_madt(void) { diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c index 9a4db7d..db90d14 100644 --- a/arch/i386/kernel/mpparse.c +++ b/arch/i386/kernel/mpparse.c @@ -854,7 +854,7 @@ void __init mp_register_lapic ( MP_processor_info(&processor); } -#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) +#ifdef CONFIG_X86_IO_APIC #define MP_ISA_BUS 0 #define MP_MAX_IOAPIC_PIN 127 @@ -1136,5 +1136,5 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low) return gsi; } -#endif /* CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER */ +#endif /* CONFIG_X86_IO_APIC */ #endif /* CONFIG_ACPI */ diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c index d3943e5..d52eda39 100644 --- a/arch/i386/kernel/setup.c +++ b/arch/i386/kernel/setup.c @@ -87,7 +87,7 @@ EXPORT_SYMBOL(boot_cpu_data); unsigned long mmu_cr4_features; -#ifdef CONFIG_ACPI_INTERPRETER +#ifdef CONFIG_ACPI int acpi_disabled = 0; #else int acpi_disabled = 1; diff --git a/arch/i386/mach-es7000/es7000plat.c b/arch/i386/mach-es7000/es7000plat.c index baac9da..f549c0e 100644 --- a/arch/i386/mach-es7000/es7000plat.c +++ b/arch/i386/mach-es7000/es7000plat.c @@ -51,7 +51,7 @@ struct mip_reg *host_reg; int mip_port; unsigned long mip_addr, host_addr; -#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) +#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI) /* * GSI override for ES7000 platforms. @@ -73,7 +73,7 @@ es7000_rename_gsi(int ioapic, int gsi) return gsi; } -#endif // (CONFIG_X86_IO_APIC) && (CONFIG_ACPI_INTERPRETER) +#endif /* (CONFIG_X86_IO_APIC) && (CONFIG_ACPI) */ /* * Parse the OEM Table diff --git a/arch/ia64/configs/bigsur_defconfig b/arch/ia64/configs/bigsur_defconfig index 456c656..2c3ba6a 100644 --- a/arch/ia64/configs/bigsur_defconfig +++ b/arch/ia64/configs/bigsur_defconfig @@ -107,7 +107,6 @@ CONFIG_ACPI=y # # ACPI (Advanced Configuration and Power Interface) Support # -CONFIG_ACPI_INTERPRETER=y CONFIG_ACPI_BUTTON=m CONFIG_ACPI_VIDEO=m CONFIG_ACPI_FAN=m diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig index dc483c1..6a0c114 100644 --- a/arch/ia64/configs/sn2_defconfig +++ b/arch/ia64/configs/sn2_defconfig @@ -130,7 +130,6 @@ CONFIG_ACPI=y # # ACPI (Advanced Configuration and Power Interface) Support # -CONFIG_ACPI_INTERPRETER=y # CONFIG_ACPI_BUTTON is not set CONFIG_ACPI_VIDEO=m CONFIG_ACPI_HOTKEY=m diff --git a/arch/ia64/configs/tiger_defconfig b/arch/ia64/configs/tiger_defconfig index cd2d637..dec24a6 100644 --- a/arch/ia64/configs/tiger_defconfig +++ b/arch/ia64/configs/tiger_defconfig @@ -128,7 +128,6 @@ CONFIG_ACPI=y # # ACPI (Advanced Configuration and Power Interface) Support # -CONFIG_ACPI_INTERPRETER=y CONFIG_ACPI_BUTTON=m # CONFIG_ACPI_VIDEO is not set # CONFIG_ACPI_HOTKEY is not set diff --git a/arch/ia64/configs/zx1_defconfig b/arch/ia64/configs/zx1_defconfig index cf58404..d318087 100644 --- a/arch/ia64/configs/zx1_defconfig +++ b/arch/ia64/configs/zx1_defconfig @@ -128,7 +128,6 @@ CONFIG_ACPI=y # # ACPI (Advanced Configuration and Power Interface) Support # -CONFIG_ACPI_INTERPRETER=y CONFIG_ACPI_BUTTON=y CONFIG_ACPI_VIDEO=m CONFIG_ACPI_HOTKEY=m diff --git a/arch/ia64/defconfig b/arch/ia64/defconfig index f38c677..e6d34df 100644 --- a/arch/ia64/defconfig +++ b/arch/ia64/defconfig @@ -118,7 +118,6 @@ CONFIG_ACPI=y # # ACPI (Advanced Configuration and Power Interface) Support # -CONFIG_ACPI_INTERPRETER=y CONFIG_ACPI_BUTTON=m CONFIG_ACPI_VIDEO=m CONFIG_ACPI_FAN=m diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig index aed77c1..8ccb4a1 100644 --- a/arch/x86_64/defconfig +++ b/arch/x86_64/defconfig @@ -135,7 +135,6 @@ CONFIG_PM_STD_PARTITION="" # ACPI (Advanced Configuration and Power Interface) Support # CONFIG_ACPI=y -CONFIG_ACPI_INTERPRETER=y CONFIG_ACPI_AC=y CONFIG_ACPI_BATTERY=y CONFIG_ACPI_BUTTON=y diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 14b70c2..f023a88 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -43,12 +43,6 @@ config ACPI if ACPI -config ACPI_INTERPRETER - bool - default y - -if ACPI_INTERPRETER - config ACPI_SLEEP bool "Sleep States (EXPERIMENTAL)" depends on X86 && (!SMP || SUSPEND_SMP) @@ -126,7 +120,6 @@ config ACPI_VIDEO config ACPI_HOTKEY tristate "Generic Hotkey" - depends on ACPI_INTERPRETER depends on EXPERIMENTAL depends on !IA64_SGI_SN default n @@ -257,7 +250,6 @@ config ACPI_CUSTOM_DSDT_FILE config ACPI_BLACKLIST_YEAR int "Disable ACPI for systems before Jan 1st this year" - depends on ACPI_INTERPRETER default 0 help enter a 4-digit year, eg. 2001 to disable ACPI by default @@ -303,8 +295,6 @@ config ACPI_SYSTEM This driver will enable your system to shut down using ACPI, and dump your ACPI DSDT table using /proc/acpi/dsdt. -endif # ACPI_INTERPRETER - config X86_PM_TIMER bool "Power Management Timer Support" depends on X86 diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 952ab35..060afaf 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -16,12 +16,12 @@ EXTRA_CFLAGS += $(ACPI_CFLAGS) # ACPI Boot-Time Table Parsing # obj-y += tables.o -obj-$(CONFIG_ACPI_INTERPRETER) += blacklist.o +obj-y += blacklist.o # # ACPI Core Subsystem (Interpreter) # -obj-$(CONFIG_ACPI_INTERPRETER) += osl.o utils.o \ +obj-y += osl.o utils.o \ dispatcher/ events/ executer/ hardware/ \ namespace/ parser/ resources/ tables/ \ utilities/ diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index a44b973..c51b02d 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -986,7 +986,7 @@ MODULE_PARM_DESC(slave_addrs, "Set the default IPMB slave address for" #define IPMI_MEM_ADDR_SPACE 1 #define IPMI_IO_ADDR_SPACE 2 -#if defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_X86) || defined(CONFIG_PCI) +#if defined(CONFIG_ACPI) || defined(CONFIG_X86) || defined(CONFIG_PCI) static int is_new_interface(int intf, u8 addr_space, unsigned long base_addr) { int i; @@ -1362,7 +1362,7 @@ static int try_init_mem(int intf_num, struct smi_info **new_info) } -#ifdef CONFIG_ACPI_INTERPRETER +#ifdef CONFIG_ACPI #include @@ -2067,7 +2067,7 @@ static int init_one_smi(int intf_num, struct smi_info **smi) rv = try_init_mem(intf_num, &new_smi); if (rv) rv = try_init_port(intf_num, &new_smi); -#ifdef CONFIG_ACPI_INTERPRETER +#ifdef CONFIG_ACPI if ((rv) && (si_trydefaults)) { rv = try_init_acpi(intf_num, &new_smi); } diff --git a/include/linux/acpi.h b/include/linux/acpi.h index fa1ad1a..6882b32 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -488,20 +488,9 @@ extern int ec_write(u8 addr, u8 val); #endif /*CONFIG_ACPI_EC*/ -#ifdef CONFIG_ACPI_INTERPRETER - extern int acpi_blacklisted(void); extern void acpi_bios_year(char *s); -#else /*!CONFIG_ACPI_INTERPRETER*/ - -static inline int acpi_blacklisted(void) -{ - return 0; -} - -#endif /*!CONFIG_ACPI_INTERPRETER*/ - #define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */ #ifdef CONFIG_ACPI -- cgit v0.10.2 From 76f58584824c61eb5b3bdbf019236815921d2e7c Mon Sep 17 00:00:00 2001 From: Len Brown Date: Wed, 24 Aug 2005 12:10:49 -0400 Subject: [ACPI] delete CONFIG_ACPI_BUS it is a synonym for CONFIG_ACPI Signed-off-by: Len Brown diff --git a/arch/i386/defconfig b/arch/i386/defconfig index f137a32..1a38785 100644 --- a/arch/i386/defconfig +++ b/arch/i386/defconfig @@ -142,7 +142,6 @@ CONFIG_ACPI_THERMAL=y # CONFIG_ACPI_ASUS is not set # CONFIG_ACPI_TOSHIBA is not set # CONFIG_ACPI_DEBUG is not set -CONFIG_ACPI_BUS=y CONFIG_ACPI_EC=y CONFIG_ACPI_POWER=y CONFIG_ACPI_PCI=y diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index 84befae..552fc856 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c @@ -408,8 +408,6 @@ acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end) #endif /* CONFIG_X86_IO_APIC */ -#ifdef CONFIG_ACPI_BUS - /* * acpi_pic_sci_set_trigger() * @@ -460,8 +458,6 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger) outb(new >> 8, 0x4d1); } -#endif /* CONFIG_ACPI_BUS */ - int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) { #ifdef CONFIG_X86_IO_APIC @@ -637,12 +633,10 @@ static int __init acpi_parse_fadt(unsigned long phys, unsigned long size) /* initialize sci_int early for INT_SRC_OVR MADT parsing */ acpi_fadt.sci_int = fadt->sci_int; -#ifdef CONFIG_ACPI_BUS /* initialize rev and apic_phys_dest_mode for x86_64 genapic */ acpi_fadt.revision = fadt->revision; acpi_fadt.force_apic_physical_destination_mode = fadt->force_apic_physical_destination_mode; -#endif #ifdef CONFIG_X86_PM_TIMER /* detect the location of the ACPI PM Timer */ diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c index db90d14..97dbf28 100644 --- a/arch/i386/kernel/mpparse.c +++ b/arch/i386/kernel/mpparse.c @@ -1069,11 +1069,9 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low) */ static int gsi_to_irq[MAX_GSI_NUM]; -#ifdef CONFIG_ACPI_BUS /* Don't set up the ACPI SCI because it's already set up */ if (acpi_fadt.sci_int == gsi) return gsi; -#endif ioapic = mp_find_ioapic(gsi); if (ioapic < 0) { @@ -1116,13 +1114,11 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low) if (gsi < MAX_GSI_NUM) { if (gsi > 15) gsi = pci_irq++; -#ifdef CONFIG_ACPI_BUS /* * Don't assign IRQ used by ACPI SCI */ if (gsi == acpi_fadt.sci_int) gsi = pci_irq++; -#endif gsi_to_irq[irq] = gsi; } else { printk(KERN_ERR "GSI %u is too high\n", gsi); diff --git a/arch/ia64/configs/bigsur_defconfig b/arch/ia64/configs/bigsur_defconfig index 2c3ba6a..996144e 100644 --- a/arch/ia64/configs/bigsur_defconfig +++ b/arch/ia64/configs/bigsur_defconfig @@ -114,7 +114,6 @@ CONFIG_ACPI_PROCESSOR=m CONFIG_ACPI_THERMAL=m CONFIG_ACPI_BLACKLIST_YEAR=0 # CONFIG_ACPI_DEBUG is not set -CONFIG_ACPI_BUS=y CONFIG_ACPI_POWER=y CONFIG_ACPI_PCI=y CONFIG_ACPI_SYSTEM=y diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig index 6a0c114..4644ebe 100644 --- a/arch/ia64/configs/sn2_defconfig +++ b/arch/ia64/configs/sn2_defconfig @@ -138,7 +138,6 @@ CONFIG_ACPI_HOTKEY=m CONFIG_ACPI_NUMA=y CONFIG_ACPI_BLACKLIST_YEAR=0 # CONFIG_ACPI_DEBUG is not set -CONFIG_ACPI_BUS=y CONFIG_ACPI_POWER=y CONFIG_ACPI_PCI=y CONFIG_ACPI_SYSTEM=y diff --git a/arch/ia64/configs/tiger_defconfig b/arch/ia64/configs/tiger_defconfig index dec24a6..f5fa113 100644 --- a/arch/ia64/configs/tiger_defconfig +++ b/arch/ia64/configs/tiger_defconfig @@ -137,7 +137,6 @@ CONFIG_ACPI_PROCESSOR=m CONFIG_ACPI_THERMAL=m CONFIG_ACPI_BLACKLIST_YEAR=0 # CONFIG_ACPI_DEBUG is not set -CONFIG_ACPI_BUS=y CONFIG_ACPI_POWER=y CONFIG_ACPI_PCI=y CONFIG_ACPI_SYSTEM=y diff --git a/arch/ia64/configs/zx1_defconfig b/arch/ia64/configs/zx1_defconfig index d318087..1e6d286 100644 --- a/arch/ia64/configs/zx1_defconfig +++ b/arch/ia64/configs/zx1_defconfig @@ -136,7 +136,6 @@ CONFIG_ACPI_PROCESSOR=y CONFIG_ACPI_THERMAL=y CONFIG_ACPI_BLACKLIST_YEAR=0 # CONFIG_ACPI_DEBUG is not set -CONFIG_ACPI_BUS=y CONFIG_ACPI_POWER=y CONFIG_ACPI_PCI=y CONFIG_ACPI_SYSTEM=y diff --git a/arch/ia64/defconfig b/arch/ia64/defconfig index e6d34df..163ef12 100644 --- a/arch/ia64/defconfig +++ b/arch/ia64/defconfig @@ -127,7 +127,6 @@ CONFIG_ACPI_THERMAL=m CONFIG_ACPI_NUMA=y CONFIG_ACPI_BLACKLIST_YEAR=0 # CONFIG_ACPI_DEBUG is not set -CONFIG_ACPI_BUS=y CONFIG_ACPI_POWER=y CONFIG_ACPI_PCI=y CONFIG_ACPI_SYSTEM=y diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig index 8ccb4a1..62abdc0 100644 --- a/arch/x86_64/defconfig +++ b/arch/x86_64/defconfig @@ -149,7 +149,6 @@ CONFIG_ACPI_NUMA=y CONFIG_ACPI_TOSHIBA=y CONFIG_ACPI_BLACKLIST_YEAR=2001 # CONFIG_ACPI_DEBUG is not set -CONFIG_ACPI_BUS=y CONFIG_ACPI_EC=y CONFIG_ACPI_POWER=y CONFIG_ACPI_PCI=y diff --git a/arch/x86_64/kernel/genapic.c b/arch/x86_64/kernel/genapic.c index 30c843a..f031358 100644 --- a/arch/x86_64/kernel/genapic.c +++ b/arch/x86_64/kernel/genapic.c @@ -20,7 +20,7 @@ #include #include -#if defined(CONFIG_ACPI_BUS) +#if defined(CONFIG_ACPI) #include #endif @@ -47,7 +47,7 @@ void __init clustered_apic_check(void) u8 cluster_cnt[NUM_APIC_CLUSTERS]; int num_cpus = 0; -#if defined(CONFIG_ACPI_BUS) +#if defined(CONFIG_ACPI) /* * Some x86_64 machines use physical APIC mode regardless of how many * procs/clusters are present (x86_64 ES7000 is an example). diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c index 86445f3..8d8ed6a 100644 --- a/arch/x86_64/kernel/mpparse.c +++ b/arch/x86_64/kernel/mpparse.c @@ -927,11 +927,9 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low) if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC) return gsi; -#ifdef CONFIG_ACPI_BUS /* Don't set up the ACPI SCI because it's already set up */ if (acpi_fadt.sci_int == gsi) return gsi; -#endif ioapic = mp_find_ioapic(gsi); if (ioapic < 0) { @@ -971,13 +969,11 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low) if (gsi < MAX_GSI_NUM) { if (gsi > 15) gsi = pci_irq++; -#ifdef CONFIG_ACPI_BUS /* * Don't assign IRQ used by ACPI SCI */ if (gsi == acpi_fadt.sci_int) gsi = pci_irq++; -#endif gsi_to_irq[irq] = gsi; } else { printk(KERN_ERR "GSI %u is too high\n", gsi); diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index f023a88..8cafa4a 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -267,10 +267,6 @@ config ACPI_DEBUG of verbosity. Saying Y enables these statements. This will increase your kernel size by around 50K. -config ACPI_BUS - bool - default y - config ACPI_EC bool depends on X86 diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 060afaf..b6a3c91 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -35,8 +35,8 @@ ifdef CONFIG_CPU_FREQ processor-objs += processor_perflib.o endif -obj-$(CONFIG_ACPI_BUS) += sleep/ -obj-$(CONFIG_ACPI_BUS) += bus.o glue.o +obj-y += sleep/ +obj-y += bus.o glue.o obj-$(CONFIG_ACPI_AC) += ac.o obj-$(CONFIG_ACPI_BATTERY) += battery.o obj-$(CONFIG_ACPI_BUTTON) += button.o @@ -55,5 +55,5 @@ obj-$(CONFIG_ACPI_NUMA) += numa.o obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o obj-$(CONFIG_ACPI_IBM) += ibm_acpi.o obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o -obj-$(CONFIG_ACPI_BUS) += scan.o motherboard.o +obj-y += scan.o motherboard.o obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig index 79e9832..b58adfe 100644 --- a/drivers/char/tpm/Kconfig +++ b/drivers/char/tpm/Kconfig @@ -17,7 +17,7 @@ config TCG_TPM obtained at: . To compile this driver as a module, choose M here; the module will be called tpm. If unsure, say N. - Note: For more TPM drivers enable CONFIG_PNP, CONFIG_ACPI_BUS + Note: For more TPM drivers enable CONFIG_PNP, CONFIG_ACPI and CONFIG_PNPACPI. config TCG_NSC diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig index 9c4a39e..2f1289e 100644 --- a/drivers/pci/hotplug/Kconfig +++ b/drivers/pci/hotplug/Kconfig @@ -78,7 +78,7 @@ config HOTPLUG_PCI_IBM config HOTPLUG_PCI_ACPI tristate "ACPI PCI Hotplug driver" - depends on ACPI_BUS && HOTPLUG_PCI + depends on ACPI && HOTPLUG_PCI help Say Y here if you have a system that supports PCI Hotplug using ACPI. @@ -157,7 +157,7 @@ config HOTPLUG_PCI_SHPC_POLL_EVENT_MODE config HOTPLUG_PCI_SHPC_PHPRM_LEGACY bool "For AMD SHPC only: Use $HRT for resource/configuration" - depends on HOTPLUG_PCI_SHPC && !ACPI_BUS + depends on HOTPLUG_PCI_SHPC && !ACPI help Say Y here for AMD SHPC. You have to select this option if you are using this driver on platform with AMD SHPC. diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile index 31a3070..246586a 100644 --- a/drivers/pci/hotplug/Makefile +++ b/drivers/pci/hotplug/Makefile @@ -51,7 +51,7 @@ pciehp-objs := pciehp_core.o \ pciehp_ctrl.o \ pciehp_pci.o \ pciehp_hpc.o -ifdef CONFIG_ACPI_BUS +ifdef CONFIG_ACPI pciehp-objs += pciehprm_acpi.o else pciehp-objs += pciehprm_nonacpi.o @@ -62,7 +62,7 @@ shpchp-objs := shpchp_core.o \ shpchp_pci.o \ shpchp_sysfs.o \ shpchp_hpc.o -ifdef CONFIG_ACPI_BUS +ifdef CONFIG_ACPI shpchp-objs += shpchprm_acpi.o else ifdef CONFIG_HOTPLUG_PCI_SHPC_PHPRM_LEGACY diff --git a/drivers/pnp/Kconfig b/drivers/pnp/Kconfig index 6776308..c514320 100644 --- a/drivers/pnp/Kconfig +++ b/drivers/pnp/Kconfig @@ -6,7 +6,7 @@ menu "Plug and Play support" config PNP bool "Plug and Play support" - depends on ISA || ACPI_BUS + depends on ISA || ACPI ---help--- Plug and Play (PnP) is a standard for peripherals which allows those peripherals to be configured by software, e.g. assign IRQ's or other diff --git a/drivers/pnp/pnpacpi/Kconfig b/drivers/pnp/pnpacpi/Kconfig index 0782cdc..b185417 100644 --- a/drivers/pnp/pnpacpi/Kconfig +++ b/drivers/pnp/pnpacpi/Kconfig @@ -3,7 +3,7 @@ # config PNPACPI bool "Plug and Play ACPI support (EXPERIMENTAL)" - depends on PNP && ACPI_BUS && EXPERIMENTAL + depends on PNP && ACPI && EXPERIMENTAL default y ---help--- Linux uses the PNPACPI to autodetect built-in diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 97034d3..56de409 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -80,7 +80,7 @@ config SERIAL_8250_CS config SERIAL_8250_ACPI bool "8250/16550 device discovery via ACPI namespace" default y if IA64 - depends on ACPI_BUS && SERIAL_8250 + depends on ACPI && SERIAL_8250 ---help--- If you wish to enable serial port discovery via the ACPI namespace, say Y here. If unsure, say N. diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 4f4b2ba..0b54e9a 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -53,7 +53,7 @@ acpi_evaluate_reference(acpi_handle handle, struct acpi_object_list *arguments, struct acpi_handle_list *list); -#ifdef CONFIG_ACPI_BUS +#ifdef CONFIG_ACPI #include @@ -356,6 +356,6 @@ acpi_handle acpi_get_child(acpi_handle, acpi_integer); acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int); #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->firmware_data)) -#endif /*CONFIG_ACPI_BUS */ +#endif /* CONFIG_ACPI */ #endif /*__ACPI_BUS_H__*/ -- cgit v0.10.2 From eb7b6b32644f7a48357e02f8004f88b3220f3494 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Thu, 25 Aug 2005 12:08:25 -0400 Subject: [ACPI] IA64-related ACPI Kconfig fixes Build issues were mostly in the ACPI=n case -- don't do that. Select ACPI from IA64_GENERIC. Add some missing dependencies on ACPI. Mark BLACKLIST_YEAR and some laptop-only ACPI drivers as X86-only. Let me know when you get an IA64 Laptop. Signed-off-by: Len Brown diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 8098813..addf073 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -60,6 +60,7 @@ choice config IA64_GENERIC bool "generic" + select ACPI select NUMA select ACPI_NUMA select VIRTUAL_MEM_MAP @@ -340,6 +341,7 @@ config IA64_PALINFO config ACPI_DEALLOCATE_IRQ bool + depends on ACPI depends on IOSAPIC && EXPERIMENTAL default y @@ -351,38 +353,10 @@ endmenu menu "Power management and ACPI" -config PM - bool "Power Management support" - depends on !IA64_HP_SIM - default y - help - "Power Management" means that parts of your computer are shut - off or put into a power conserving "sleep" mode if they are not - being used. There are two competing standards for doing this: APM - and ACPI. If you want to use either one, say Y here and then also - to the requisite support below. - - Power Management is most important for battery powered laptop - computers; if you have a laptop, check out the Linux Laptop home - page on the WWW at and the - Battery Powered Linux mini-HOWTO, available from - . - - Note that, even if you say N here, Linux on the x86 architecture - will issue the hlt instruction if nothing is to be done, thereby - sending the processor to sleep and saving power. - -config ACPI - bool - depends on !IA64_HP_SIM - default y - -if !IA64_HP_SIM +source "kernel/power/Kconfig" source "drivers/acpi/Kconfig" -endif - endmenu if !IA64_HP_SIM diff --git a/arch/ia64/configs/bigsur_defconfig b/arch/ia64/configs/bigsur_defconfig index 996144e..71dcfe0 100644 --- a/arch/ia64/configs/bigsur_defconfig +++ b/arch/ia64/configs/bigsur_defconfig @@ -108,11 +108,9 @@ CONFIG_ACPI=y # ACPI (Advanced Configuration and Power Interface) Support # CONFIG_ACPI_BUTTON=m -CONFIG_ACPI_VIDEO=m CONFIG_ACPI_FAN=m CONFIG_ACPI_PROCESSOR=m CONFIG_ACPI_THERMAL=m -CONFIG_ACPI_BLACKLIST_YEAR=0 # CONFIG_ACPI_DEBUG is not set CONFIG_ACPI_POWER=y CONFIG_ACPI_PCI=y diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig index 4644ebe..ac17ed2 100644 --- a/arch/ia64/configs/sn2_defconfig +++ b/arch/ia64/configs/sn2_defconfig @@ -131,12 +131,9 @@ CONFIG_ACPI=y # ACPI (Advanced Configuration and Power Interface) Support # # CONFIG_ACPI_BUTTON is not set -CONFIG_ACPI_VIDEO=m -CONFIG_ACPI_HOTKEY=m # CONFIG_ACPI_FAN is not set # CONFIG_ACPI_PROCESSOR is not set CONFIG_ACPI_NUMA=y -CONFIG_ACPI_BLACKLIST_YEAR=0 # CONFIG_ACPI_DEBUG is not set CONFIG_ACPI_POWER=y CONFIG_ACPI_PCI=y diff --git a/arch/ia64/configs/tiger_defconfig b/arch/ia64/configs/tiger_defconfig index f5fa113..3a62941 100644 --- a/arch/ia64/configs/tiger_defconfig +++ b/arch/ia64/configs/tiger_defconfig @@ -129,13 +129,10 @@ CONFIG_ACPI=y # ACPI (Advanced Configuration and Power Interface) Support # CONFIG_ACPI_BUTTON=m -# CONFIG_ACPI_VIDEO is not set -# CONFIG_ACPI_HOTKEY is not set CONFIG_ACPI_FAN=m CONFIG_ACPI_PROCESSOR=m # CONFIG_ACPI_HOTPLUG_CPU is not set CONFIG_ACPI_THERMAL=m -CONFIG_ACPI_BLACKLIST_YEAR=0 # CONFIG_ACPI_DEBUG is not set CONFIG_ACPI_POWER=y CONFIG_ACPI_PCI=y diff --git a/arch/ia64/configs/zx1_defconfig b/arch/ia64/configs/zx1_defconfig index 1e6d286..84cdf32 100644 --- a/arch/ia64/configs/zx1_defconfig +++ b/arch/ia64/configs/zx1_defconfig @@ -129,12 +129,9 @@ CONFIG_ACPI=y # ACPI (Advanced Configuration and Power Interface) Support # CONFIG_ACPI_BUTTON=y -CONFIG_ACPI_VIDEO=m -CONFIG_ACPI_HOTKEY=m CONFIG_ACPI_FAN=y CONFIG_ACPI_PROCESSOR=y CONFIG_ACPI_THERMAL=y -CONFIG_ACPI_BLACKLIST_YEAR=0 # CONFIG_ACPI_DEBUG is not set CONFIG_ACPI_POWER=y CONFIG_ACPI_PCI=y diff --git a/arch/ia64/defconfig b/arch/ia64/defconfig index 163ef12..7002d5a 100644 --- a/arch/ia64/defconfig +++ b/arch/ia64/defconfig @@ -119,13 +119,11 @@ CONFIG_ACPI=y # ACPI (Advanced Configuration and Power Interface) Support # CONFIG_ACPI_BUTTON=m -CONFIG_ACPI_VIDEO=m CONFIG_ACPI_FAN=m CONFIG_ACPI_PROCESSOR=m CONFIG_ACPI_HOTPLUG_CPU=y CONFIG_ACPI_THERMAL=m CONFIG_ACPI_NUMA=y -CONFIG_ACPI_BLACKLIST_YEAR=0 # CONFIG_ACPI_DEBUG is not set CONFIG_ACPI_POWER=y CONFIG_ACPI_PCI=y diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 8cafa4a..5e8f15f 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -107,6 +107,7 @@ config ACPI_BUTTON config ACPI_VIDEO tristate "Video" + depends on X86 depends on EXPERIMENTAL default m help @@ -121,7 +122,7 @@ config ACPI_VIDEO config ACPI_HOTKEY tristate "Generic Hotkey" depends on EXPERIMENTAL - depends on !IA64_SGI_SN + depends on X86 default n help Experimental consolidated hotkey driver. @@ -250,6 +251,7 @@ config ACPI_CUSTOM_DSDT_FILE config ACPI_BLACKLIST_YEAR int "Disable ACPI for systems before Jan 1st this year" + depends on X86 default 0 help enter a 4-digit year, eg. 2001 to disable ACPI by default diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig index 2c7121d..b99f61b 100644 --- a/kernel/power/Kconfig +++ b/kernel/power/Kconfig @@ -1,5 +1,6 @@ config PM bool "Power Management support" + depends on !IA64_HP_SIM ---help--- "Power Management" means that parts of your computer are shut off or put into a power conserving "sleep" mode if they are not -- cgit v0.10.2 From bfea6c2af798d9a882bbc6b9ae9893ab1864d230 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Thu, 25 Aug 2005 12:15:11 -0400 Subject: [ACPI] reduce use of EXPERIMENTAL in acpi/Kconfig Distros are shipping modules we had marked EXPERIMENTAL, so clearly it has lost some meaning. Delete that dependency for shipping modules, retaining it only for ACPI_HOTKEY and ACPI_CONTAINER to emphasize that they lack testing on real hardware. Signed-off-by: Len Brown diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 5e8f15f..1117358 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -44,9 +44,9 @@ config ACPI if ACPI config ACPI_SLEEP - bool "Sleep States (EXPERIMENTAL)" + bool "Sleep States" depends on X86 && (!SMP || SUSPEND_SMP) - depends on EXPERIMENTAL && PM + depends on PM default y ---help--- This option adds support for ACPI suspend states. @@ -108,7 +108,6 @@ config ACPI_BUTTON config ACPI_VIDEO tristate "Video" depends on X86 - depends on EXPERIMENTAL default m help This driver implement the ACPI Extensions For Display Adapters @@ -120,7 +119,7 @@ config ACPI_VIDEO for your integrated video device. config ACPI_HOTKEY - tristate "Generic Hotkey" + tristate "Generic Hotkey (EXPERIMENTAL)" depends on EXPERIMENTAL depends on X86 default n @@ -296,7 +295,6 @@ config ACPI_SYSTEM config X86_PM_TIMER bool "Power Management Timer Support" depends on X86 - depends on EXPERIMENTAL depends on !X86_64 default n help -- cgit v0.10.2 From 07fefe4ca93b3e45b2bea32871a4496067888852 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Thu, 25 Aug 2005 12:22:04 -0400 Subject: [ACPI] remove "default m" from acpi/Kconfig Andi Kleen suggested it was unconventional for us to "default m" on ACPI modules -- even though they are expected to be deployed as modules. But as "default n" would likely result in some users building nonsense kernels, we compromise to "default y". Distros are expected to continue to use =m in their configs. Signed-off-by: Len Brown diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 1117358..83cac52 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -80,16 +80,16 @@ config ACPI_SLEEP_PROC_SLEEP config ACPI_AC tristate "AC Adapter" depends on X86 - default m + default y help This driver adds support for the AC Adapter object, which indicates - whether a system is on AC, or not. Typically, only mobile systems - have this object, since desktops are always on AC. + whether a system is on AC, or not. If you have a system that can + switch between A/C and battery, say Y. config ACPI_BATTERY tristate "Battery" depends on X86 - default m + default y help This driver adds support for battery information through /proc/acpi/battery. If you have a mobile system with a battery, @@ -97,18 +97,17 @@ config ACPI_BATTERY config ACPI_BUTTON tristate "Button" - default m + default y help - This driver registers for events based on buttons, such as the - power, sleep, and lid switch. In the future, a daemon will read - /proc/acpi/event and perform user-defined actions such as shutting - down the system. Until then, you can cat it, and see output when - a button is pressed. + This driver handles events on the power, sleep and lid buttons. + A daemon reads /proc/acpi/event and perform user-defined actions + such as shutting down the system. This is necessary for + software controlled poweroff. config ACPI_VIDEO tristate "Video" depends on X86 - default m + default y help This driver implement the ACPI Extensions For Display Adapters for integrated graphics devices on motherboard, as specified in @@ -129,18 +128,19 @@ config ACPI_HOTKEY config ACPI_FAN tristate "Fan" - default m + default y help This driver adds support for ACPI fan devices, allowing user-mode applications to perform basic fan control (on, off, status). config ACPI_PROCESSOR tristate "Processor" - default m + default y help This driver installs ACPI as the idle handler for Linux, and uses ACPI C2 and C3 processor states to save power, on systems that - support it. + support it. It is required by several flavors of cpufreq + Performance-state drivers. config ACPI_HOTPLUG_CPU bool @@ -151,7 +151,7 @@ config ACPI_HOTPLUG_CPU config ACPI_THERMAL tristate "Thermal Zone" depends on ACPI_PROCESSOR - default m + default y help This driver adds support for ACPI thermal zones. Most mobile and some desktop systems support ACPI thermal zones. It is HIGHLY @@ -167,7 +167,7 @@ config ACPI_NUMA config ACPI_ASUS tristate "ASUS/Medion Laptop Extras" depends on X86 - default m + default y ---help--- This driver provides support for extra features of ACPI-compatible ASUS laptops. As some of Medion laptops are made by ASUS, it may also @@ -196,7 +196,7 @@ config ACPI_ASUS config ACPI_IBM tristate "IBM ThinkPad Laptop Extras" depends on X86 - default m + default y ---help--- This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds support for Fn-Fx key combinations, Bluetooth control, video @@ -209,7 +209,7 @@ config ACPI_IBM config ACPI_TOSHIBA tristate "Toshiba Laptop Extras" depends on X86 - default m + default y ---help--- This driver adds support for access to certain system settings on "legacy free" Toshiba laptops. These laptops can be recognized by @@ -296,7 +296,7 @@ config X86_PM_TIMER bool "Power Management Timer Support" depends on X86 depends on !X86_64 - default n + default y help The Power Management Timer is available on all ACPI-capable, in most cases even if ACPI is unusable or blacklisted. -- cgit v0.10.2 From 6153df7b2f4d27c8bde054db1b947369a6f64d83 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Thu, 25 Aug 2005 12:27:09 -0400 Subject: [ACPI] delete CONFIG_ACPI_PCI Delete the ability to build an ACPI kernel that does not include PCI support. When such a machine is created and it requires a tuned kernel, send a patch. http://bugzilla.kernel.org/show_bug.cgi?id=1364 Signed-off-by: Len Brown diff --git a/arch/i386/defconfig b/arch/i386/defconfig index 1a38785..6a431b9 100644 --- a/arch/i386/defconfig +++ b/arch/i386/defconfig @@ -144,7 +144,6 @@ CONFIG_ACPI_THERMAL=y # CONFIG_ACPI_DEBUG is not set CONFIG_ACPI_EC=y CONFIG_ACPI_POWER=y -CONFIG_ACPI_PCI=y CONFIG_ACPI_SYSTEM=y # CONFIG_X86_PM_TIMER is not set diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index 552fc856..0fb23c3 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c @@ -66,13 +66,8 @@ static inline int ioapic_setup_disabled(void) #define PREFIX "ACPI: " -#ifdef CONFIG_ACPI_PCI int acpi_noirq __initdata; /* skip ACPI IRQ initialization */ int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */ -#else -int acpi_noirq __initdata = 1; -int acpi_pci_disabled __initdata = 1; -#endif int acpi_ht __initdata = 1; /* enable HT */ int acpi_lapic; @@ -849,7 +844,6 @@ extern int acpi_force; #ifdef __i386__ -#ifdef CONFIG_ACPI_PCI static int __init disable_acpi_irq(struct dmi_system_id *d) { if (!acpi_force) { @@ -869,7 +863,6 @@ static int __init disable_acpi_pci(struct dmi_system_id *d) } return 0; } -#endif static int __init dmi_disable_acpi(struct dmi_system_id *d) { @@ -1017,7 +1010,6 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = { }, }, -#ifdef CONFIG_ACPI_PCI /* * Boxes that need ACPI PCI IRQ routing disabled */ @@ -1055,7 +1047,6 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"), }, }, -#endif {} }; diff --git a/arch/i386/pci/Makefile b/arch/i386/pci/Makefile index 1bff03f..ead6122 100644 --- a/arch/i386/pci/Makefile +++ b/arch/i386/pci/Makefile @@ -5,7 +5,7 @@ obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o obj-$(CONFIG_PCI_DIRECT) += direct.o pci-y := fixup.o -pci-$(CONFIG_ACPI_PCI) += acpi.o +pci-$(CONFIG_ACPI) += acpi.o pci-y += legacy.o irq.o pci-$(CONFIG_X86_VISWS) := visws.o fixup.o diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c index 86348b6..326a2ed 100644 --- a/arch/i386/pci/irq.c +++ b/arch/i386/pci/irq.c @@ -1075,7 +1075,7 @@ static void pirq_penalize_isa_irq(int irq, int active) void pcibios_penalize_isa_irq(int irq, int active) { -#ifdef CONFIG_ACPI_PCI +#ifdef CONFIG_ACPI if (!acpi_noirq) acpi_penalize_isa_irq(irq, active); else diff --git a/arch/ia64/configs/bigsur_defconfig b/arch/ia64/configs/bigsur_defconfig index 71dcfe0..3b65cbb 100644 --- a/arch/ia64/configs/bigsur_defconfig +++ b/arch/ia64/configs/bigsur_defconfig @@ -113,7 +113,6 @@ CONFIG_ACPI_PROCESSOR=m CONFIG_ACPI_THERMAL=m # CONFIG_ACPI_DEBUG is not set CONFIG_ACPI_POWER=y -CONFIG_ACPI_PCI=y CONFIG_ACPI_SYSTEM=y # diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig index ac17ed2..1ca6e6e 100644 --- a/arch/ia64/configs/sn2_defconfig +++ b/arch/ia64/configs/sn2_defconfig @@ -136,7 +136,6 @@ CONFIG_ACPI=y CONFIG_ACPI_NUMA=y # CONFIG_ACPI_DEBUG is not set CONFIG_ACPI_POWER=y -CONFIG_ACPI_PCI=y CONFIG_ACPI_SYSTEM=y # CONFIG_ACPI_CONTAINER is not set diff --git a/arch/ia64/configs/tiger_defconfig b/arch/ia64/configs/tiger_defconfig index 3a62941..3ec94a1 100644 --- a/arch/ia64/configs/tiger_defconfig +++ b/arch/ia64/configs/tiger_defconfig @@ -135,7 +135,6 @@ CONFIG_ACPI_PROCESSOR=m CONFIG_ACPI_THERMAL=m # CONFIG_ACPI_DEBUG is not set CONFIG_ACPI_POWER=y -CONFIG_ACPI_PCI=y CONFIG_ACPI_SYSTEM=y # CONFIG_ACPI_CONTAINER is not set diff --git a/arch/ia64/configs/zx1_defconfig b/arch/ia64/configs/zx1_defconfig index 84cdf32..d4cf73d 100644 --- a/arch/ia64/configs/zx1_defconfig +++ b/arch/ia64/configs/zx1_defconfig @@ -134,7 +134,6 @@ CONFIG_ACPI_PROCESSOR=y CONFIG_ACPI_THERMAL=y # CONFIG_ACPI_DEBUG is not set CONFIG_ACPI_POWER=y -CONFIG_ACPI_PCI=y CONFIG_ACPI_SYSTEM=y # CONFIG_ACPI_CONTAINER is not set diff --git a/arch/ia64/defconfig b/arch/ia64/defconfig index 7002d5a..b6ec8d3 100644 --- a/arch/ia64/defconfig +++ b/arch/ia64/defconfig @@ -126,7 +126,6 @@ CONFIG_ACPI_THERMAL=m CONFIG_ACPI_NUMA=y # CONFIG_ACPI_DEBUG is not set CONFIG_ACPI_POWER=y -CONFIG_ACPI_PCI=y CONFIG_ACPI_SYSTEM=y CONFIG_ACPI_CONTAINER=m diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig index 62abdc0..b95c6cf 100644 --- a/arch/x86_64/defconfig +++ b/arch/x86_64/defconfig @@ -151,7 +151,6 @@ CONFIG_ACPI_BLACKLIST_YEAR=2001 # CONFIG_ACPI_DEBUG is not set CONFIG_ACPI_EC=y CONFIG_ACPI_POWER=y -CONFIG_ACPI_PCI=y CONFIG_ACPI_SYSTEM=y # CONFIG_ACPI_CONTAINER is not set diff --git a/arch/x86_64/pci/Makefile b/arch/x86_64/pci/Makefile index 37c92e8..bb34e5e 100644 --- a/arch/x86_64/pci/Makefile +++ b/arch/x86_64/pci/Makefile @@ -8,7 +8,7 @@ CFLAGS += -Iarch/i386/pci obj-y := i386.o obj-$(CONFIG_PCI_DIRECT)+= direct.o obj-y += fixup.o -obj-$(CONFIG_ACPI_PCI) += acpi.o +obj-$(CONFIG_ACPI) += acpi.o obj-y += legacy.o irq.o common.o # mmconfig has a 64bit special obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o diff --git a/arch/x86_64/pci/Makefile-BUS b/arch/x86_64/pci/Makefile-BUS index 291985f..4f0c05a 100644 --- a/arch/x86_64/pci/Makefile-BUS +++ b/arch/x86_64/pci/Makefile-BUS @@ -8,7 +8,7 @@ CFLAGS += -I arch/i386/pci obj-y := i386.o obj-$(CONFIG_PCI_DIRECT)+= direct.o obj-y += fixup.o -obj-$(CONFIG_ACPI_PCI) += acpi.o +obj-$(CONFIG_ACPI) += acpi.o obj-y += legacy.o irq.o common.o # mmconfig has a 64bit special obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 83cac52..3998c9d 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -3,7 +3,6 @@ # menu "ACPI (Advanced Configuration and Power Interface) Support" - depends on PM depends on !X86_VISWS depends on !IA64_HP_SIM depends on IA64 || X86 @@ -11,6 +10,8 @@ menu "ACPI (Advanced Configuration and Power Interface) Support" config ACPI bool "ACPI Support" depends on IA64 || X86 + select PM + select PCI default y ---help--- @@ -281,10 +282,6 @@ config ACPI_POWER bool default y -config ACPI_PCI - bool - default PCI - config ACPI_SYSTEM bool default y diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index b6a3c91..a182434 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -44,7 +44,7 @@ obj-$(CONFIG_ACPI_EC) += ec.o obj-$(CONFIG_ACPI_FAN) += fan.o obj-$(CONFIG_ACPI_VIDEO) += video.o obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o -obj-$(CONFIG_ACPI_PCI) += pci_root.o pci_link.o pci_irq.o pci_bind.o +obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o obj-$(CONFIG_ACPI_POWER) += power.o obj-$(CONFIG_ACPI_PROCESSOR) += processor.o obj-$(CONFIG_ACPI_CONTAINER) += container.o diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 81f0eb8..dc69d87 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -86,13 +86,11 @@ acpi_status acpi_os_initialize1(void) * Initialize PCI configuration space access, as we'll need to access * it while walking the namespace (bus 0 and root bridges w/ _BBNs). */ -#ifdef CONFIG_ACPI_PCI if (!raw_pci_ops) { printk(KERN_ERR PREFIX "Access to PCI configuration space unavailable\n"); return AE_NULL_ENTRY; } -#endif kacpid_wq = create_singlethread_workqueue("kacpid"); BUG_ON(!kacpid_wq); @@ -484,8 +482,6 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) return AE_OK; } -#ifdef CONFIG_ACPI_PCI - acpi_status acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, void *value, u32 width) @@ -618,30 +614,6 @@ void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */ acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number); } -#else /*!CONFIG_ACPI_PCI */ - -acpi_status -acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, - u32 reg, acpi_integer value, u32 width) -{ - return AE_SUPPORT; -} - -acpi_status -acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, - u32 reg, void *value, u32 width) -{ - return AE_SUPPORT; -} - -void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */ - acpi_handle chandle, /* current node */ - struct acpi_pci_id **id) -{ -} - -#endif /*CONFIG_ACPI_PCI */ - static void acpi_os_execute_deferred(void *context) { struct acpi_os_dpc *dpc = NULL; diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h index e976cb1..c1b4e1f 100644 --- a/include/acpi/acpi_drivers.h +++ b/include/acpi/acpi_drivers.h @@ -47,8 +47,6 @@ PCI -------------------------------------------------------------------------- */ -#ifdef CONFIG_ACPI_PCI - #define ACPI_PCI_COMPONENT 0x00400000 /* ACPI PCI Interrupt Link (pci_link.c) */ @@ -78,8 +76,6 @@ int acpi_pci_bind_root(struct acpi_device *device, struct acpi_pci_id *id, struct pci_bus *pci_acpi_scan_root(struct acpi_device *device, int domain, int bus); -#endif /*CONFIG_ACPI_PCI */ - /* -------------------------------------------------------------------------- Power Resource -------------------------------------------------------------------------- */ diff --git a/include/asm-i386/acpi.h b/include/asm-i386/acpi.h index 1f1ade9..df4ed32 100644 --- a/include/asm-i386/acpi.h +++ b/include/asm-i386/acpi.h @@ -146,13 +146,6 @@ static inline void check_acpi_pci(void) { } #endif -#else /* !CONFIG_ACPI */ -# define acpi_lapic 0 -# define acpi_ioapic 0 - -#endif - -#ifdef CONFIG_ACPI_PCI static inline void acpi_noirq_set(void) { acpi_noirq = 1; } static inline void acpi_disable_pci(void) { @@ -160,11 +153,16 @@ static inline void acpi_disable_pci(void) acpi_noirq_set(); } extern int acpi_irq_balance_set(char *str); -#else + +#else /* !CONFIG_ACPI */ + +#define acpi_lapic 0 +#define acpi_ioapic 0 static inline void acpi_noirq_set(void) { } static inline void acpi_disable_pci(void) { } -static inline int acpi_irq_balance_set(char *str) { return 0; } -#endif + +#endif /* !CONFIG_ACPI */ + #ifdef CONFIG_ACPI_SLEEP diff --git a/include/asm-x86_64/acpi.h b/include/asm-x86_64/acpi.h index 7d537e1..aa1c7b2 100644 --- a/include/asm-x86_64/acpi.h +++ b/include/asm-x86_64/acpi.h @@ -121,17 +121,6 @@ static inline void disable_acpi(void) #define FIX_ACPI_PAGES 4 extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq); - -#else /* !CONFIG_ACPI */ -#define acpi_lapic 0 -#define acpi_ioapic 0 -#endif /* !CONFIG_ACPI */ - -extern int acpi_numa; -extern int acpi_scan_nodes(unsigned long start, unsigned long end); -#define NR_NODE_MEMBLKS (MAX_NUMNODES*2) - -#ifdef CONFIG_ACPI_PCI static inline void acpi_noirq_set(void) { acpi_noirq = 1; } static inline void acpi_disable_pci(void) { @@ -139,11 +128,19 @@ static inline void acpi_disable_pci(void) acpi_noirq_set(); } extern int acpi_irq_balance_set(char *str); -#else + +#else /* !CONFIG_ACPI */ + +#define acpi_lapic 0 +#define acpi_ioapic 0 static inline void acpi_noirq_set(void) { } static inline void acpi_disable_pci(void) { } -static inline int acpi_irq_balance_set(char *str) { return 0; } -#endif + +#endif /* !CONFIG_ACPI */ + +extern int acpi_numa; +extern int acpi_scan_nodes(unsigned long start, unsigned long end); +#define NR_NODE_MEMBLKS (MAX_NUMNODES*2) #ifdef CONFIG_ACPI_SLEEP diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 6882b32..026c3c0 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -445,7 +445,7 @@ int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); */ void acpi_unregister_gsi (u32 gsi); -#ifdef CONFIG_ACPI_PCI +#ifdef CONFIG_ACPI struct acpi_prt_entry { struct list_head node; @@ -479,7 +479,7 @@ struct acpi_pci_driver { int acpi_pci_register_driver(struct acpi_pci_driver *driver); void acpi_pci_unregister_driver(struct acpi_pci_driver *driver); -#endif /*CONFIG_ACPI_PCI*/ +#endif /* CONFIG_ACPI */ #ifdef CONFIG_ACPI_EC -- cgit v0.10.2 From d0d59b98d7a0b3801ce03e695ba885b698a6d122 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Thu, 25 Aug 2005 12:41:22 -0400 Subject: [IA64] fix allnoconfig build cc: Tony Luck Signed-off-by: Len Brown diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c index 84d276a..392bf8a 100644 --- a/arch/ia64/sn/kernel/irq.c +++ b/arch/ia64/sn/kernel/irq.c @@ -23,7 +23,7 @@ static void force_interrupt(int irq); static void register_intr_pda(struct sn_irq_info *sn_irq_info); static void unregister_intr_pda(struct sn_irq_info *sn_irq_info); -extern int sn_force_interrupt_flag; +int sn_force_interrupt_flag = 1; extern int sn_ioif_inited; static struct list_head **sn_irq_lh; static spinlock_t sn_irq_info_lock = SPIN_LOCK_UNLOCKED; /* non-IRQ lock */ diff --git a/arch/ia64/sn/kernel/sn2/sn_proc_fs.c b/arch/ia64/sn/kernel/sn2/sn_proc_fs.c index 6a80fca..266a3a8 100644 --- a/arch/ia64/sn/kernel/sn2/sn_proc_fs.c +++ b/arch/ia64/sn/kernel/sn2/sn_proc_fs.c @@ -52,7 +52,7 @@ static int licenseID_open(struct inode *inode, struct file *file) * the bridge chip. The hardware will then send an interrupt message if the * interrupt line is active. This mimics a level sensitive interrupt. */ -int sn_force_interrupt_flag = 1; +extern int sn_force_interrupt_flag; static int sn_force_interrupt_show(struct seq_file *s, void *p) { -- cgit v0.10.2 From 78f81cc4355c31c798564ff7efb253cc4cdce6c0 Mon Sep 17 00:00:00 2001 From: Borislav Deianov Date: Wed, 17 Aug 2005 00:00:00 -0400 Subject: [ACPI] IBM ThinkPad ACPI Extras Driver v0.12 http://ibm-acpi.sf.net/ Signed-off-by: Borislav Deianov Signed-off-by: Len Brown diff --git a/Documentation/ibm-acpi.txt b/Documentation/ibm-acpi.txt index c437b1a..8b3fd82 100644 --- a/Documentation/ibm-acpi.txt +++ b/Documentation/ibm-acpi.txt @@ -1,16 +1,16 @@ IBM ThinkPad ACPI Extras Driver - Version 0.8 - 8 November 2004 + Version 0.12 + 17 August 2005 Borislav Deianov http://ibm-acpi.sf.net/ -This is a Linux ACPI driver for the IBM ThinkPad laptops. It aims to -support various features of these laptops which are accessible through -the ACPI framework but not otherwise supported by the generic Linux -ACPI drivers. +This is a Linux ACPI driver for the IBM ThinkPad laptops. It supports +various features of these laptops which are accessible through the +ACPI framework but not otherwise supported by the generic Linux ACPI +drivers. Status @@ -25,9 +25,14 @@ detailed description): - ThinkLight on and off - limited docking and undocking - UltraBay eject - - Experimental: CMOS control - - Experimental: LED control - - Experimental: ACPI sounds + - CMOS control + - LED control + - ACPI sounds + - temperature sensors + - Experimental: embedded controller register dump + - Experimental: LCD brightness control + - Experimental: volume control + - Experimental: fan speed, fan enable/disable A compatibility table by model and feature is maintained on the web site, http://ibm-acpi.sf.net/. I appreciate any success or failure @@ -91,12 +96,12 @@ driver is still in the alpha stage, the exact proc file format and commands supported by the various features is guaranteed to change frequently. -Driver Version -- /proc/acpi/ibm/driver --------------------------------------- +Driver version -- /proc/acpi/ibm/driver +--------------------------------------- The driver name and version. No commands can be written to this file. -Hot Keys -- /proc/acpi/ibm/hotkey +Hot keys -- /proc/acpi/ibm/hotkey --------------------------------- Without this driver, only the Fn-F4 key (sleep button) generates an @@ -188,7 +193,7 @@ and, on the X40, video corruption. By disabling automatic switching, the flickering or video corruption can be avoided. The video_switch command cycles through the available video outputs -(it sumulates the behavior of Fn-F7). +(it simulates the behavior of Fn-F7). Video expansion can be toggled through this feature. This controls whether the display is expanded to fill the entire LCD screen when a @@ -201,6 +206,12 @@ Fn-F7 from working. This also disables the video output switching features of this driver, as it uses the same ACPI methods as Fn-F7. Video switching on the console should still work. +UPDATE: There's now a patch for the X.org Radeon driver which +addresses this issue. Some people are reporting success with the patch +while others are still having problems. For more information: + +https://bugs.freedesktop.org/show_bug.cgi?id=2000 + ThinkLight control -- /proc/acpi/ibm/light ------------------------------------------ @@ -211,7 +222,7 @@ models which do not make the status available will show it as echo on > /proc/acpi/ibm/light echo off > /proc/acpi/ibm/light -Docking / Undocking -- /proc/acpi/ibm/dock +Docking / undocking -- /proc/acpi/ibm/dock ------------------------------------------ Docking and undocking (e.g. with the X4 UltraBase) requires some @@ -228,11 +239,15 @@ NOTE: These events will only be generated if the laptop was docked when originally booted. This is due to the current lack of support for hot plugging of devices in the Linux ACPI framework. If the laptop was booted while not in the dock, the following message is shown in the -logs: "ibm_acpi: dock device not present". No dock-related events are -generated but the dock and undock commands described below still -work. They can be executed manually or triggered by Fn key -combinations (see the example acpid configuration files included in -the driver tarball package available on the web site). +logs: + + Mar 17 01:42:34 aero kernel: ibm_acpi: dock device not present + +In this case, no dock-related events are generated but the dock and +undock commands described below still work. They can be executed +manually or triggered by Fn key combinations (see the example acpid +configuration files included in the driver tarball package available +on the web site). When the eject request button on the dock is pressed, the first event above is generated. The handler for this event should issue the @@ -267,7 +282,7 @@ the only docking stations currently supported are the X-series UltraBase docks and "dumb" port replicators like the Mini Dock (the latter don't need any ACPI support, actually). -UltraBay Eject -- /proc/acpi/ibm/bay +UltraBay eject -- /proc/acpi/ibm/bay ------------------------------------ Inserting or ejecting an UltraBay device requires some actions to be @@ -284,8 +299,11 @@ when the laptop was originally booted (on the X series, the UltraBay is in the dock, so it may not be present if the laptop was undocked). This is due to the current lack of support for hot plugging of devices in the Linux ACPI framework. If the laptop was booted without the -UltraBay, the following message is shown in the logs: "ibm_acpi: bay -device not present". No bay-related events are generated but the eject +UltraBay, the following message is shown in the logs: + + Mar 17 01:42:34 aero kernel: ibm_acpi: bay device not present + +In this case, no bay-related events are generated but the eject command described below still works. It can be executed manually or triggered by a hot key combination. @@ -306,22 +324,33 @@ necessary to enable the UltraBay device (e.g. call idectl). The contents of the /proc/acpi/ibm/bay file shows the current status of the UltraBay, as provided by the ACPI framework. -Experimental Features ---------------------- +EXPERIMENTAL warm eject support on the 600e/x, A22p and A3x (To use +this feature, you need to supply the experimental=1 parameter when +loading the module): + +These models do not have a button near the UltraBay device to request +a hot eject but rather require the laptop to be put to sleep +(suspend-to-ram) before the bay device is ejected or inserted). +The sequence of steps to eject the device is as follows: + + echo eject > /proc/acpi/ibm/bay + put the ThinkPad to sleep + remove the drive + resume from sleep + cat /proc/acpi/ibm/bay should show that the drive was removed + +On the A3x, both the UltraBay 2000 and UltraBay Plus devices are +supported. Use "eject2" instead of "eject" for the second bay. -The following features are marked experimental because using them -involves guessing the correct values of some parameters. Guessing -incorrectly may have undesirable effects like crashing your -ThinkPad. USE THESE WITH CAUTION! To activate them, you'll need to -supply the experimental=1 parameter when loading the module. +Note: the UltraBay eject support on the 600e/x, A22p and A3x is +EXPERIMENTAL and may not work as expected. USE WITH CAUTION! -Experimental: CMOS control - /proc/acpi/ibm/cmos ------------------------------------------------- +CMOS control -- /proc/acpi/ibm/cmos +----------------------------------- This feature is used internally by the ACPI firmware to control the -ThinkLight on most newer ThinkPad models. It appears that it can also -control LCD brightness, sounds volume and more, but only on some -models. +ThinkLight on most newer ThinkPad models. It may also control LCD +brightness, sounds volume and more, but only on some models. The commands are non-negative integer numbers: @@ -330,10 +359,9 @@ The commands are non-negative integer numbers: echo 2 >/proc/acpi/ibm/cmos ... -The range of numbers which are used internally by various models is 0 -to 21, but it's possible that numbers outside this range have -interesting behavior. Here is the behavior on the X40 (tpb is the -ThinkPad Buttons utility): +The range of valid numbers is 0 to 21, but not all have an effect and +the behavior varies from model to model. Here is the behavior on the +X40 (tpb is the ThinkPad Buttons utility): 0 - no effect but tpb reports "Volume down" 1 - no effect but tpb reports "Volume up" @@ -346,26 +374,18 @@ ThinkPad Buttons utility): 13 - ThinkLight off 14 - no effect but tpb reports ThinkLight status change -If you try this feature, please send me a report similar to the -above. On models which allow control of LCD brightness or sound -volume, I'd like to provide this functionality in an user-friendly -way, but first I need a way to identify the models which this is -possible. - -Experimental: LED control - /proc/acpi/ibm/LED ----------------------------------------------- +LED control -- /proc/acpi/ibm/led +--------------------------------- Some of the LED indicators can be controlled through this feature. The available commands are: - echo on >/proc/acpi/ibm/led - echo off >/proc/acpi/ibm/led - echo blink >/proc/acpi/ibm/led + echo ' on' >/proc/acpi/ibm/led + echo ' off' >/proc/acpi/ibm/led + echo ' blink' >/proc/acpi/ibm/led -The parameter is a non-negative integer. The range of LED -numbers used internally by various models is 0 to 7 but it's possible -that numbers outside this range are also valid. Here is the mapping on -the X40: +The range is 0 to 7. The set of LEDs that can be +controlled varies from model to model. Here is the mapping on the X40: 0 - power 1 - battery (orange) @@ -376,49 +396,224 @@ the X40: All of the above can be turned on and off and can be made to blink. -If you try this feature, please send me a report similar to the -above. I'd like to provide this functionality in an user-friendly way, -but first I need to identify the which numbers correspond to which -LEDs on various models. - -Experimental: ACPI sounds - /proc/acpi/ibm/beep ------------------------------------------------ +ACPI sounds -- /proc/acpi/ibm/beep +---------------------------------- The BEEP method is used internally by the ACPI firmware to provide -audible alerts in various situtation. This feature allows the same +audible alerts in various situations. This feature allows the same sounds to be triggered manually. The commands are non-negative integer numbers: - echo 0 >/proc/acpi/ibm/beep - echo 1 >/proc/acpi/ibm/beep - echo 2 >/proc/acpi/ibm/beep - ... + echo >/proc/acpi/ibm/beep -The range of numbers which are used internally by various models is 0 -to 17, but it's possible that numbers outside this range are also -valid. Here is the behavior on the X40: +The valid range is 0 to 17. Not all numbers trigger sounds +and the sounds vary from model to model. Here is the behavior on the +X40: - 2 - two beeps, pause, third beep + 0 - stop a sound in progress (but use 17 to stop 16) + 2 - two beeps, pause, third beep ("low battery") 3 - single beep - 4 - "unable" + 4 - high, followed by low-pitched beep ("unable") 5 - single beep - 6 - "AC/DC" + 6 - very high, followed by high-pitched beep ("AC/DC") 7 - high-pitched beep 9 - three short beeps 10 - very long beep 12 - low-pitched beep + 15 - three high-pitched beeps repeating constantly, stop with 0 + 16 - one medium-pitched beep repeating constantly, stop with 17 + 17 - stop 16 + +Temperature sensors -- /proc/acpi/ibm/thermal +--------------------------------------------- + +Most ThinkPads include six or more separate temperature sensors but +only expose the CPU temperature through the standard ACPI methods. +This feature shows readings from up to eight different sensors. Some +readings may not be valid, e.g. may show large negative values. For +example, on the X40, a typical output may be: + +temperatures: 42 42 45 41 36 -128 33 -128 + +Thomas Gruber took his R51 apart and traced all six active sensors in +his laptop (the location of sensors may vary on other models): + +1: CPU +2: Mini PCI Module +3: HDD +4: GPU +5: Battery +6: N/A +7: Battery +8: N/A + +No commands can be written to this file. + +EXPERIMENTAL: Embedded controller reigster dump -- /proc/acpi/ibm/ecdump +------------------------------------------------------------------------ + +This feature is marked EXPERIMENTAL because the implementation +directly accesses hardware registers and may not work as expected. USE +WITH CAUTION! To use this feature, you need to supply the +experimental=1 parameter when loading the module. + +This feature dumps the values of 256 embedded controller +registers. Values which have changed since the last time the registers +were dumped are marked with a star: + +[root@x40 ibm-acpi]# cat /proc/acpi/ibm/ecdump +EC +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +0a +0b +0c +0d +0e +0f +EC 0x00: a7 47 87 01 fe 96 00 08 01 00 cb 00 00 00 40 00 +EC 0x10: 00 00 ff ff f4 3c 87 09 01 ff 42 01 ff ff 0d 00 +EC 0x20: 00 00 00 00 00 00 00 00 00 00 00 03 43 00 00 80 +EC 0x30: 01 07 1a 00 30 04 00 00 *85 00 00 10 00 50 00 00 +EC 0x40: 00 00 00 00 00 00 14 01 00 04 00 00 00 00 00 00 +EC 0x50: 00 c0 02 0d 00 01 01 02 02 03 03 03 03 *bc *02 *bc +EC 0x60: *02 *bc *02 00 00 00 00 00 00 00 00 00 00 00 00 00 +EC 0x70: 00 00 00 00 00 12 30 40 *24 *26 *2c *27 *20 80 *1f 80 +EC 0x80: 00 00 00 06 *37 *0e 03 00 00 00 0e 07 00 00 00 00 +EC 0x90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +EC 0xa0: *ff 09 ff 09 ff ff *64 00 *00 *00 *a2 41 *ff *ff *e0 00 +EC 0xb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +EC 0xc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +EC 0xd0: 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +EC 0xe0: 00 00 00 00 00 00 00 00 11 20 49 04 24 06 55 03 +EC 0xf0: 31 55 48 54 35 38 57 57 08 2f 45 73 07 65 6c 1a + +This feature can be used to determine the register holding the fan +speed on some models. To do that, do the following: + + - make sure the battery is fully charged + - make sure the fan is running + - run 'cat /proc/acpi/ibm/ecdump' several times, once per second or so + +The first step makes sure various charging-related values don't +vary. The second ensures that the fan-related values do vary, since +the fan speed fluctuates a bit. The third will (hopefully) mark the +fan register with a star: + +[root@x40 ibm-acpi]# cat /proc/acpi/ibm/ecdump +EC +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +0a +0b +0c +0d +0e +0f +EC 0x00: a7 47 87 01 fe 96 00 08 01 00 cb 00 00 00 40 00 +EC 0x10: 00 00 ff ff f4 3c 87 09 01 ff 42 01 ff ff 0d 00 +EC 0x20: 00 00 00 00 00 00 00 00 00 00 00 03 43 00 00 80 +EC 0x30: 01 07 1a 00 30 04 00 00 85 00 00 10 00 50 00 00 +EC 0x40: 00 00 00 00 00 00 14 01 00 04 00 00 00 00 00 00 +EC 0x50: 00 c0 02 0d 00 01 01 02 02 03 03 03 03 bc 02 bc +EC 0x60: 02 bc 02 00 00 00 00 00 00 00 00 00 00 00 00 00 +EC 0x70: 00 00 00 00 00 12 30 40 24 27 2c 27 21 80 1f 80 +EC 0x80: 00 00 00 06 *be 0d 03 00 00 00 0e 07 00 00 00 00 +EC 0x90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +EC 0xa0: ff 09 ff 09 ff ff 64 00 00 00 a2 41 ff ff e0 00 +EC 0xb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +EC 0xc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +EC 0xd0: 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +EC 0xe0: 00 00 00 00 00 00 00 00 11 20 49 04 24 06 55 03 +EC 0xf0: 31 55 48 54 35 38 57 57 08 2f 45 73 07 65 6c 1a + +Another set of values that varies often is the temperature +readings. Since temperatures don't change vary fast, you can take +several quick dumps to eliminate them. + +You can use a similar method to figure out the meaning of other +embedded controller registers - e.g. make sure nothing else changes +except the charging or discharging battery to determine which +registers contain the current battery capacity, etc. If you experiment +with this, do send me your results (including some complete dumps with +a description of the conditions when they were taken.) + +EXPERIMENTAL: LCD brightness control -- /proc/acpi/ibm/brightness +----------------------------------------------------------------- + +This feature is marked EXPERIMENTAL because the implementation +directly accesses hardware registers and may not work as expected. USE +WITH CAUTION! To use this feature, you need to supply the +experimental=1 parameter when loading the module. + +This feature allows software control of the LCD brightness on ThinkPad +models which don't have a hardware brightness slider. The available +commands are: + + echo up >/proc/acpi/ibm/brightness + echo down >/proc/acpi/ibm/brightness + echo 'level ' >/proc/acpi/ibm/brightness + +The number range is 0 to 7, although not all of them may be +distinct. The current brightness level is shown in the file. + +EXPERIMENTAL: Volume control -- /proc/acpi/ibm/volume +----------------------------------------------------- + +This feature is marked EXPERIMENTAL because the implementation +directly accesses hardware registers and may not work as expected. USE +WITH CAUTION! To use this feature, you need to supply the +experimental=1 parameter when loading the module. + +This feature allows volume control on ThinkPad models which don't have +a hardware volume knob. The available commands are: + + echo up >/proc/acpi/ibm/volume + echo down >/proc/acpi/ibm/volume + echo mute >/proc/acpi/ibm/volume + echo 'level ' >/proc/acpi/ibm/volume + +The number range is 0 to 15 although not all of them may be +distinct. The unmute the volume after the mute command, use either the +up or down command (the level command will not unmute the volume). +The current volume level and mute state is shown in the file. + +EXPERIMENTAL: fan speed, fan enable/disable -- /proc/acpi/ibm/fan +----------------------------------------------------------------- + +This feature is marked EXPERIMENTAL because the implementation +directly accesses hardware registers and may not work as expected. USE +WITH CAUTION! To use this feature, you need to supply the +experimental=1 parameter when loading the module. + +This feature attempts to show the current fan speed. The speed is read +directly from the hardware registers of the embedded controller. This +is known to work on later R, T and X series ThinkPads but may show a +bogus value on other models. + +The fan may be enabled or disabled with the following commands: + + echo enable >/proc/acpi/ibm/fan + echo disable >/proc/acpi/ibm/fan + +WARNING WARNING WARNING: do not leave the fan disabled unless you are +monitoring the temperature sensor readings and you are ready to enable +it if necessary to avoid overheating. + +The fan only runs if it's enabled *and* the various temperature +sensors which control it read high enough. On the X40, this seems to +depend on the CPU and HDD temperatures. Specifically, the fan is +turned on when either the CPU temperature climbs to 56 degrees or the +HDD temperature climbs to 46 degrees. The fan is turned off when the +CPU temperature drops to 49 degrees and the HDD temperature drops to +41 degrees. These thresholds cannot currently be controlled. + +On the X31 and X40 (and ONLY on those models), the fan speed can be +controlled to a certain degree. Once the fan is running, it can be +forced to run faster or slower with the following command: + + echo 'speed ' > /proc/acpi/ibm/thermal + +The sustainable range of fan speeds on the X40 appears to be from +about 3700 to about 7350. Values outside this range either do not have +any effect or the fan speed eventually settles somewhere in that +range. The fan cannot be stopped or started with this command. + +On the 570, temperature readings are not available through this +feature and the fan control works a little differently. The fan speed +is reported in levels from 0 (off) to 7 (max) and can be controlled +with the following command: -(I've only been able to identify a couple of them). - -If you try this feature, please send me a report similar to the -above. I'd like to provide this functionality in an user-friendly way, -but first I need to identify the which numbers correspond to which -sounds on various models. + echo 'level ' > /proc/acpi/ibm/thermal -Multiple Command, Module Parameters ------------------------------------ +Multiple Commands, Module Parameters +------------------------------------ Multiple commands can be written to the proc files in one shot by separating them with commas, for example: @@ -451,24 +646,19 @@ scripts (included with ibm-acpi for completeness): /usr/local/sbin/laptop_mode -- from the Linux kernel source distribution, see Documentation/laptop-mode.txt /sbin/service -- comes with Redhat/Fedora distributions + /usr/sbin/hibernate -- from the Software Suspend 2 distribution, + see http://softwaresuspend.berlios.de/ -Toan T Nguyen has written a SuSE powersave -script for the X20, included in config/usr/sbin/ibm_hotkeys_X20 +Toan T Nguyen notes that Suse uses the +powersave program to suspend ('powersave --suspend-to-ram') or +hibernate ('powersave --suspend-to-disk'). This means that the +hibernate script is not needed on that distribution. Henrik Brix Andersen has written a Gentoo ACPI event handler script for the X31. You can get the latest version from http://dev.gentoo.org/~brix/files/x31.sh David Schweikert has written an alternative blank.sh -script which works on Debian systems, included in -configs/etc/acpi/actions/blank-debian.sh - - -TODO ----- - -I'd like to implement the following features but haven't yet found the -time and/or I don't yet know how to implement them: - -- UltraBay floppy drive support - +script which works on Debian systems. This scripts has now been +extended to also work on Fedora systems and included as the default +blank.sh in the distribution. diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c index ad85e10..5cc0903 100644 --- a/drivers/acpi/ibm_acpi.c +++ b/drivers/acpi/ibm_acpi.c @@ -2,7 +2,7 @@ * ibm_acpi.c - IBM ThinkPad ACPI Extras * * - * Copyright (C) 2004 Borislav Deianov + * Copyright (C) 2004-2005 Borislav Deianov * * 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 @@ -17,38 +17,62 @@ * 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 - * + */ + +#define IBM_VERSION "0.12a" + +/* * Changelog: - * - * 2004-08-09 0.1 initial release, support for X series - * 2004-08-14 0.2 support for T series, X20 - * bluetooth enable/disable - * hotkey events disabled by default - * removed fan control, currently useless - * 2004-08-17 0.3 support for R40 - * lcd off, brightness control - * thinklight on/off - * 2004-09-16 0.4 support for module parameters - * hotkey mask can be prefixed by 0x - * video output switching - * video expansion control - * ultrabay eject support - * removed lcd brightness/on/off control, didn't work + * + * 2005-08-17 0.12 fix compilation on 2.6.13-rc kernels + * 2005-03-17 0.11 support for 600e, 770x + * thanks to Jamie Lentin + * support for 770e, G41 + * G40 and G41 don't have a thinklight + * temperatures no longer experimental + * experimental brightness control + * experimental volume control + * experimental fan enable/disable + * 2005-01-16 0.10 fix module loading on R30, R31 + * 2005-01-16 0.9 support for 570, R30, R31 + * ultrabay support on A22p, A3x + * limit arg for cmos, led, beep, drop experimental status + * more capable led control on A21e, A22p, T20-22, X20 + * experimental temperatures and fan speed + * experimental embedded controller register dump + * mark more functions as __init, drop incorrect __exit + * use MODULE_VERSION + * thanks to Henrik Brix Andersen + * fix parameter passing on module loading + * thanks to Rusty Russell + * thanks to Jim Radford + * 2004-11-08 0.8 fix init error case, don't return from a macro + * thanks to Chris Wright + * 2004-10-23 0.7 fix module loading on A21e, A22p, T20, T21, X20 + * fix led control on A21e + * 2004-10-19 0.6 use acpi_bus_register_driver() to claim HKEY device * 2004-10-18 0.5 thinklight support on A21e, G40, R32, T20, T21, X20 * proc file format changed * video_switch command * experimental cmos control * experimental led control * experimental acpi sounds - * 2004-10-19 0.6 use acpi_bus_register_driver() to claim HKEY device - * 2004-10-23 0.7 fix module loading on A21e, A22p, T20, T21, X20 - * fix LED control on A21e - * 2004-11-08 0.8 fix init error case, don't return from a macro - * thanks to Chris Wright + * 2004-09-16 0.4 support for module parameters + * hotkey mask can be prefixed by 0x + * video output switching + * video expansion control + * ultrabay eject support + * removed lcd brightness/on/off control, didn't work + * 2004-08-17 0.3 support for R40 + * lcd off, brightness control + * thinklight on/off + * 2004-08-14 0.2 support for T series, X20 + * bluetooth enable/disable + * hotkey events disabled by default + * removed fan control, currently useless + * 2004-08-09 0.1 initial release, support for X series */ -#define IBM_VERSION "0.8" - #include #include #include @@ -64,6 +88,11 @@ #define IBM_FILE "ibm_acpi" #define IBM_URL "http://ibm-acpi.sf.net/" +MODULE_AUTHOR("Borislav Deianov"); +MODULE_DESCRIPTION(IBM_DESC); +MODULE_VERSION(IBM_VERSION); +MODULE_LICENSE("GPL"); + #define IBM_DIR IBM_NAME #define IBM_LOG IBM_FILE ": " @@ -84,54 +113,122 @@ static acpi_handle root_handle = NULL; #define IBM_HANDLE(object, parent, paths...) \ static acpi_handle object##_handle; \ static acpi_handle *object##_parent = &parent##_handle; \ + static char *object##_path; \ static char *object##_paths[] = { paths } -IBM_HANDLE(ec, root, - "\\_SB.PCI0.ISA.EC", /* A21e, A22p, T20, T21, X20 */ - "\\_SB.PCI0.LPC.EC", /* all others */ -); - -IBM_HANDLE(vid, root, - "\\_SB.PCI0.VID", /* A21e, G40, X30, X40 */ - "\\_SB.PCI0.AGP.VID", /* all others */ -); - -IBM_HANDLE(cmos, root, - "\\UCMS", /* R50, R50p, R51, T4x, X31, X40 */ - "\\CMOS", /* A3x, G40, R32, T23, T30, X22, X24, X30 */ - "\\CMS", /* R40, R40e */ -); /* A21e, A22p, T20, T21, X20 */ - -IBM_HANDLE(dock, root, - "\\_SB.GDCK", /* X30, X31, X40 */ - "\\_SB.PCI0.DOCK", /* A22p, T20, T21, X20 */ - "\\_SB.PCI0.PCI1.DOCK", /* all others */ -); /* A21e, G40, R32, R40, R40e */ - -IBM_HANDLE(bay, root, - "\\_SB.PCI0.IDE0.SCND.MSTR"); /* all except A21e */ -IBM_HANDLE(bayej, root, - "\\_SB.PCI0.IDE0.SCND.MSTR._EJ0"); /* all except A2x, A3x */ - -IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A22p, T20, T21, X20 */ -IBM_HANDLE(hkey, ec, "HKEY"); /* all */ -IBM_HANDLE(led, ec, "LED"); /* all except A21e, A22p, T20, T21, X20 */ -IBM_HANDLE(sysl, ec, "SYSL"); /* A21e, A22p, T20, T21, X20 */ -IBM_HANDLE(bled, ec, "BLED"); /* A22p, T20, T21, X20 */ -IBM_HANDLE(beep, ec, "BEEP"); /* all models */ +/* + * The following models are supported to various degrees: + * + * 570, 600e, 600x, 770e, 770x + * A20m, A21e, A21m, A21p, A22p, A30, A30p, A31, A31p + * G40, G41 + * R30, R31, R32, R40, R40e, R50, R50e, R50p, R51 + * T20, T21, T22, T23, T30, T40, T40p, T41, T41p, T42, T42p, T43 + * X20, X21, X22, X23, X24, X30, X31, X40 + * + * The following models have no supported features: + * + * 240, 240x, i1400 + * + * Still missing DSDTs for the following models: + * + * A20p, A22e, A22m + * R52 + * S31 + * T43p + */ + +IBM_HANDLE(ec, root, "\\_SB.PCI0.ISA.EC0", /* 240, 240x */ + "\\_SB.PCI.ISA.EC", /* 570 */ + "\\_SB.PCI0.ISA0.EC0", /* 600e/x, 770e, 770x */ + "\\_SB.PCI0.ISA.EC", /* A21e, A2xm/p, T20-22, X20-21 */ + "\\_SB.PCI0.AD4S.EC0", /* i1400, R30 */ + "\\_SB.PCI0.ICH3.EC0", /* R31 */ + "\\_SB.PCI0.LPC.EC", /* all others */ + ); + +IBM_HANDLE(vid, root, "\\_SB.PCI.AGP.VGA", /* 570 */ + "\\_SB.PCI0.AGP0.VID0", /* 600e/x, 770x */ + "\\_SB.PCI0.VID0", /* 770e */ + "\\_SB.PCI0.VID", /* A21e, G4x, R50e, X30, X40 */ + "\\_SB.PCI0.AGP.VID", /* all others */ + ); /* R30, R31 */ + +IBM_HANDLE(vid2, root, "\\_SB.PCI0.AGPB.VID"); /* G41 */ + +IBM_HANDLE(cmos, root, "\\UCMS", /* R50, R50e, R50p, R51, T4x, X31, X40 */ + "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */ + "\\CMS", /* R40, R40e */ + ); /* all others */ + +IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */ + "\\_SB.PCI0.DOCK", /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */ + "\\_SB.PCI0.PCI1.DOCK", /* all others */ + "\\_SB.PCI.ISA.SLCE", /* 570 */ + ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */ + +IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */ + "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */ + "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */ + ); /* A21e, R30, R31 */ + +IBM_HANDLE(bay_ej, bay, "_EJ3", /* 600e/x, A2xm/p, A3x */ + "_EJ0", /* all others */ + ); /* 570,A21e,G4x,R30,R31,R32,R40e,R50e */ + +IBM_HANDLE(bay2, root, "\\_SB.PCI0.IDE0.PRIM.SLAV", /* A3x, R32 */ + "\\_SB.PCI0.IDE0.IDEP.IDPS", /* 600e/x, 770e, 770x */ + ); /* all others */ + +IBM_HANDLE(bay2_ej, bay2, "_EJ3", /* 600e/x, 770e, A3x */ + "_EJ0", /* 770x */ + ); /* all others */ + +/* don't list other alternatives as we install a notify handler on the 570 */ +IBM_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */ + +IBM_HANDLE(hkey, ec, "\\_SB.HKEY", /* 600e/x, 770e, 770x */ + "^HKEY", /* R30, R31 */ + "HKEY", /* all others */ + ); /* 570 */ + +IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */ +IBM_HANDLE(ledb, ec, "LEDB"); /* G4x */ + +IBM_HANDLE(led, ec, "SLED", /* 570 */ + "SYSL", /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */ + "LED", /* all others */ + ); /* R30, R31 */ + +IBM_HANDLE(beep, ec, "BEEP"); /* all except R30, R31 */ +IBM_HANDLE(ecrd, ec, "ECRD"); /* 570 */ +IBM_HANDLE(ecwr, ec, "ECWR"); /* 570 */ +IBM_HANDLE(fans, ec, "FANS"); /* X31, X40 */ + +IBM_HANDLE(gfan, ec, "GFAN", /* 570 */ + "\\FSPD", /* 600e/x, 770e, 770x */ + ); /* all others */ + +IBM_HANDLE(sfan, ec, "SFAN", /* 570 */ + "JFNS", /* 770x-JL */ + ); /* all others */ + +#define IBM_HKEY_HID "IBM0068" +#define IBM_PCI_HID "PNP0A03" struct ibm_struct { char *name; + char param[32]; char *hid; struct acpi_driver *driver; - - int (*init) (struct ibm_struct *); - int (*read) (struct ibm_struct *, char *); - int (*write) (struct ibm_struct *, char *); - void (*exit) (struct ibm_struct *); - void (*notify) (struct ibm_struct *, u32); + int (*init) (void); + int (*read) (char *); + int (*write) (char *); + void (*exit) (void); + + void (*notify) (struct ibm_struct *, u32); acpi_handle *handle; int type; struct acpi_device *device; @@ -141,17 +238,6 @@ struct ibm_struct { int init_called; int notify_installed; - int supported; - union { - struct { - int status; - int mask; - } hotkey; - struct { - int autoswitch; - } video; - } state; - int experimental; }; @@ -165,15 +251,15 @@ static int acpi_evalf(acpi_handle handle, void *res, char *method, char *fmt, ...) { char *fmt0 = fmt; - struct acpi_object_list params; - union acpi_object in_objs[IBM_MAX_ACPI_ARGS]; - struct acpi_buffer result; - union acpi_object out_obj; - acpi_status status; - va_list ap; - char res_type; - int success; - int quiet; + struct acpi_object_list params; + union acpi_object in_objs[IBM_MAX_ACPI_ARGS]; + struct acpi_buffer result, *resultp; + union acpi_object out_obj; + acpi_status status; + va_list ap; + char res_type; + int success; + int quiet; if (!*fmt) { printk(IBM_ERR "acpi_evalf() called with empty format\n"); @@ -199,7 +285,7 @@ static int acpi_evalf(acpi_handle handle, in_objs[params.count].integer.value = va_arg(ap, int); in_objs[params.count++].type = ACPI_TYPE_INTEGER; break; - /* add more types as needed */ + /* add more types as needed */ default: printk(IBM_ERR "acpi_evalf() called " "with invalid format character '%c'\n", c); @@ -208,21 +294,25 @@ static int acpi_evalf(acpi_handle handle, } va_end(ap); - result.length = sizeof(out_obj); - result.pointer = &out_obj; + if (res_type != 'v') { + result.length = sizeof(out_obj); + result.pointer = &out_obj; + resultp = &result; + } else + resultp = NULL; - status = acpi_evaluate_object(handle, method, ¶ms, &result); + status = acpi_evaluate_object(handle, method, ¶ms, resultp); switch (res_type) { - case 'd': /* int */ + case 'd': /* int */ if (res) *(int *)res = out_obj.integer.value; success = status == AE_OK && out_obj.type == ACPI_TYPE_INTEGER; break; - case 'v': /* void */ + case 'v': /* void */ success = status == AE_OK; break; - /* add more types as needed */ + /* add more types as needed */ default: printk(IBM_ERR "acpi_evalf() called " "with invalid format character '%c'\n", res_type); @@ -262,7 +352,7 @@ static char *next_cmd(char **cmds) return start; } -static int driver_init(struct ibm_struct *ibm) +static int driver_init(void) { printk(IBM_INFO "%s v%s\n", IBM_DESC, IBM_VERSION); printk(IBM_INFO "%s\n", IBM_URL); @@ -270,7 +360,7 @@ static int driver_init(struct ibm_struct *ibm) return 0; } -static int driver_read(struct ibm_struct *ibm, char *p) +static int driver_read(char *p) { int len = 0; @@ -280,67 +370,74 @@ static int driver_read(struct ibm_struct *ibm, char *p) return len; } -static int hotkey_get(struct ibm_struct *ibm, int *status, int *mask) +static int hotkey_supported; +static int hotkey_mask_supported; +static int hotkey_orig_status; +static int hotkey_orig_mask; + +static int hotkey_get(int *status, int *mask) { if (!acpi_evalf(hkey_handle, status, "DHKC", "d")) - return -EIO; - if (ibm->supported) { - if (!acpi_evalf(hkey_handle, mask, "DHKN", "qd")) - return -EIO; - } else { - *mask = ibm->state.hotkey.mask; - } - return 0; + return 0; + + if (hotkey_mask_supported) + if (!acpi_evalf(hkey_handle, mask, "DHKN", "d")) + return 0; + + return 1; } -static int hotkey_set(struct ibm_struct *ibm, int status, int mask) +static int hotkey_set(int status, int mask) { int i; if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", status)) - return -EIO; - - if (!ibm->supported) return 0; - for (i=0; i<32; i++) { - int bit = ((1 << i) & mask) != 0; - if (!acpi_evalf(hkey_handle, NULL, "MHKM", "vdd", i+1, bit)) - return -EIO; - } + if (hotkey_mask_supported) + for (i = 0; i < 32; i++) { + int bit = ((1 << i) & mask) != 0; + if (!acpi_evalf(hkey_handle, + NULL, "MHKM", "vdd", i + 1, bit)) + return 0; + } - return 0; + return 1; } -static int hotkey_init(struct ibm_struct *ibm) +static int hotkey_init(void) { - int ret; + /* hotkey not supported on 570 */ + hotkey_supported = hkey_handle != NULL; - ibm->supported = 1; - ret = hotkey_get(ibm, - &ibm->state.hotkey.status, - &ibm->state.hotkey.mask); - if (ret < 0) { - /* mask not supported on A21e, A22p, T20, T21, X20, X22, X24 */ - ibm->supported = 0; - ret = hotkey_get(ibm, - &ibm->state.hotkey.status, - &ibm->state.hotkey.mask); + if (hotkey_supported) { + /* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, + A30, R30, R31, T20-22, X20-21, X22-24 */ + hotkey_mask_supported = + acpi_evalf(hkey_handle, NULL, "DHKN", "qv"); + + if (!hotkey_get(&hotkey_orig_status, &hotkey_orig_mask)) + return -ENODEV; } - return ret; -} + return 0; +} -static int hotkey_read(struct ibm_struct *ibm, char *p) +static int hotkey_read(char *p) { int status, mask; int len = 0; - if (hotkey_get(ibm, &status, &mask) < 0) + if (!hotkey_supported) { + len += sprintf(p + len, "status:\t\tnot supported\n"); + return len; + } + + if (!hotkey_get(&status, &mask)) return -EIO; len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0)); - if (ibm->supported) { + if (hotkey_mask_supported) { len += sprintf(p + len, "mask:\t\t0x%04x\n", mask); len += sprintf(p + len, "commands:\tenable, disable, reset, \n"); @@ -352,23 +449,26 @@ static int hotkey_read(struct ibm_struct *ibm, char *p) return len; } -static int hotkey_write(struct ibm_struct *ibm, char *buf) +static int hotkey_write(char *buf) { int status, mask; char *cmd; int do_cmd = 0; - if (hotkey_get(ibm, &status, &mask) < 0) + if (!hotkey_supported) return -ENODEV; + if (!hotkey_get(&status, &mask)) + return -EIO; + while ((cmd = next_cmd(&buf))) { if (strlencmp(cmd, "enable") == 0) { status = 1; } else if (strlencmp(cmd, "disable") == 0) { status = 0; } else if (strlencmp(cmd, "reset") == 0) { - status = ibm->state.hotkey.status; - mask = ibm->state.hotkey.mask; + status = hotkey_orig_status; + mask = hotkey_orig_mask; } else if (sscanf(cmd, "0x%x", &mask) == 1) { /* mask set */ } else if (sscanf(cmd, "%x", &mask) == 1) { @@ -378,15 +478,16 @@ static int hotkey_write(struct ibm_struct *ibm, char *buf) do_cmd = 1; } - if (do_cmd && hotkey_set(ibm, status, mask) < 0) + if (do_cmd && !hotkey_set(status, mask)) return -EIO; return 0; -} +} -static void hotkey_exit(struct ibm_struct *ibm) +static void hotkey_exit(void) { - hotkey_set(ibm, ibm->state.hotkey.status, ibm->state.hotkey.mask); + if (hotkey_supported) + hotkey_set(hotkey_orig_status, hotkey_orig_mask); } static void hotkey_notify(struct ibm_struct *ibm, u32 event) @@ -398,33 +499,38 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) else { printk(IBM_ERR "unknown hotkey event %d\n", event); acpi_bus_generate_event(ibm->device, event, 0); - } + } } -static int bluetooth_init(struct ibm_struct *ibm) +static int bluetooth_supported; + +static int bluetooth_init(void) { - /* bluetooth not supported on A21e, G40, T20, T21, X20 */ - ibm->supported = acpi_evalf(hkey_handle, NULL, "GBDC", "qv"); + /* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, + G4x, R30, R31, R40e, R50e, T20-22, X20-21 */ + bluetooth_supported = hkey_handle && + acpi_evalf(hkey_handle, NULL, "GBDC", "qv"); return 0; } -static int bluetooth_status(struct ibm_struct *ibm) +static int bluetooth_status(void) { int status; - if (!ibm->supported || !acpi_evalf(hkey_handle, &status, "GBDC", "d")) + if (!bluetooth_supported || + !acpi_evalf(hkey_handle, &status, "GBDC", "d")) status = 0; return status; } -static int bluetooth_read(struct ibm_struct *ibm, char *p) +static int bluetooth_read(char *p) { int len = 0; - int status = bluetooth_status(ibm); + int status = bluetooth_status(); - if (!ibm->supported) + if (!bluetooth_supported) len += sprintf(p + len, "status:\t\tnot supported\n"); else if (!(status & 1)) len += sprintf(p + len, "status:\t\tnot installed\n"); @@ -436,14 +542,14 @@ static int bluetooth_read(struct ibm_struct *ibm, char *p) return len; } -static int bluetooth_write(struct ibm_struct *ibm, char *buf) +static int bluetooth_write(char *buf) { - int status = bluetooth_status(ibm); + int status = bluetooth_status(); char *cmd; int do_cmd = 0; - if (!ibm->supported) - return -EINVAL; + if (!bluetooth_supported) + return -ENODEV; while ((cmd = next_cmd(&buf))) { if (strlencmp(cmd, "enable") == 0) { @@ -456,64 +562,166 @@ static int bluetooth_write(struct ibm_struct *ibm, char *buf) } if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) - return -EIO; + return -EIO; return 0; } -static int video_init(struct ibm_struct *ibm) +static int video_supported; +static int video_orig_autosw; + +#define VIDEO_570 1 +#define VIDEO_770 2 +#define VIDEO_NEW 3 + +static int video_init(void) { - if (!acpi_evalf(vid_handle, - &ibm->state.video.autoswitch, "^VDEE", "d")) - return -ENODEV; + int ivga; + + if (vid2_handle && acpi_evalf(NULL, &ivga, "\\IVGA", "d") && ivga) + /* G41, assume IVGA doesn't change */ + vid_handle = vid2_handle; + + if (!vid_handle) + /* video switching not supported on R30, R31 */ + video_supported = 0; + else if (acpi_evalf(vid_handle, &video_orig_autosw, "SWIT", "qd")) + /* 570 */ + video_supported = VIDEO_570; + else if (acpi_evalf(vid_handle, &video_orig_autosw, "^VADL", "qd")) + /* 600e/x, 770e, 770x */ + video_supported = VIDEO_770; + else + /* all others */ + video_supported = VIDEO_NEW; return 0; } -static int video_status(struct ibm_struct *ibm) +static int video_status(void) { int status = 0; int i; - acpi_evalf(NULL, NULL, "\\VUPS", "vd", 1); - if (acpi_evalf(NULL, &i, "\\VCDC", "d")) - status |= 0x02 * i; + if (video_supported == VIDEO_570) { + if (acpi_evalf(NULL, &i, "\\_SB.PHS", "dd", 0x87)) + status = i & 3; + } else if (video_supported == VIDEO_770) { + if (acpi_evalf(NULL, &i, "\\VCDL", "d")) + status |= 0x01 * i; + if (acpi_evalf(NULL, &i, "\\VCDC", "d")) + status |= 0x02 * i; + } else if (video_supported == VIDEO_NEW) { + acpi_evalf(NULL, NULL, "\\VUPS", "vd", 1); + if (acpi_evalf(NULL, &i, "\\VCDC", "d")) + status |= 0x02 * i; + + acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0); + if (acpi_evalf(NULL, &i, "\\VCDL", "d")) + status |= 0x01 * i; + if (acpi_evalf(NULL, &i, "\\VCDD", "d")) + status |= 0x08 * i; + } + + return status; +} - acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0); - if (acpi_evalf(NULL, &i, "\\VCDL", "d")) - status |= 0x01 * i; - if (acpi_evalf(NULL, &i, "\\VCDD", "d")) - status |= 0x08 * i; +static int video_autosw(void) +{ + int autosw = 0; - if (acpi_evalf(vid_handle, &i, "^VDEE", "d")) - status |= 0x10 * (i & 1); + if (video_supported == VIDEO_570) + acpi_evalf(vid_handle, &autosw, "SWIT", "d"); + else if (video_supported == VIDEO_770 || video_supported == VIDEO_NEW) + acpi_evalf(vid_handle, &autosw, "^VDEE", "d"); - return status; + return autosw & 1; } -static int video_read(struct ibm_struct *ibm, char *p) +static int video_read(char *p) { - int status = video_status(ibm); + int status = video_status(); + int autosw = video_autosw(); int len = 0; + if (!video_supported) { + len += sprintf(p + len, "status:\t\tnot supported\n"); + return len; + } + + len += sprintf(p + len, "status:\t\tsupported\n"); len += sprintf(p + len, "lcd:\t\t%s\n", enabled(status, 0)); len += sprintf(p + len, "crt:\t\t%s\n", enabled(status, 1)); - len += sprintf(p + len, "dvi:\t\t%s\n", enabled(status, 3)); - len += sprintf(p + len, "auto:\t\t%s\n", enabled(status, 4)); - len += sprintf(p + len, "commands:\tlcd_enable, lcd_disable, " - "crt_enable, crt_disable\n"); - len += sprintf(p + len, "commands:\tdvi_enable, dvi_disable, " - "auto_enable, auto_disable\n"); + if (video_supported == VIDEO_NEW) + len += sprintf(p + len, "dvi:\t\t%s\n", enabled(status, 3)); + len += sprintf(p + len, "auto:\t\t%s\n", enabled(autosw, 0)); + len += sprintf(p + len, "commands:\tlcd_enable, lcd_disable\n"); + len += sprintf(p + len, "commands:\tcrt_enable, crt_disable\n"); + if (video_supported == VIDEO_NEW) + len += sprintf(p + len, "commands:\tdvi_enable, dvi_disable\n"); + len += sprintf(p + len, "commands:\tauto_enable, auto_disable\n"); len += sprintf(p + len, "commands:\tvideo_switch, expand_toggle\n"); return len; } -static int video_write(struct ibm_struct *ibm, char *buf) +static int video_switch(void) +{ + int autosw = video_autosw(); + int ret; + + if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1)) + return -EIO; + ret = video_supported == VIDEO_570 ? + acpi_evalf(ec_handle, NULL, "_Q16", "v") : + acpi_evalf(vid_handle, NULL, "VSWT", "v"); + acpi_evalf(vid_handle, NULL, "_DOS", "vd", autosw); + + return ret; +} + +static int video_expand(void) +{ + if (video_supported == VIDEO_570) + return acpi_evalf(ec_handle, NULL, "_Q17", "v"); + else if (video_supported == VIDEO_770) + return acpi_evalf(vid_handle, NULL, "VEXP", "v"); + else + return acpi_evalf(NULL, NULL, "\\VEXP", "v"); +} + +static int video_switch2(int status) +{ + int ret; + + if (video_supported == VIDEO_570) { + ret = acpi_evalf(NULL, NULL, + "\\_SB.PHS2", "vdd", 0x8b, status | 0x80); + } else if (video_supported == VIDEO_770) { + int autosw = video_autosw(); + if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1)) + return -EIO; + + ret = acpi_evalf(vid_handle, NULL, + "ASWT", "vdd", status * 0x100, 0); + + acpi_evalf(vid_handle, NULL, "_DOS", "vd", autosw); + } else { + ret = acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0x80) && + acpi_evalf(NULL, NULL, "\\VSDS", "vdd", status, 1); + } + + return ret; +} + +static int video_write(char *buf) { char *cmd; int enable, disable, status; + if (!video_supported) + return -ENODEV; + enable = disable = 0; while ((cmd = next_cmd(&buf))) { @@ -525,9 +733,11 @@ static int video_write(struct ibm_struct *ibm, char *buf) enable |= 0x02; } else if (strlencmp(cmd, "crt_disable") == 0) { disable |= 0x02; - } else if (strlencmp(cmd, "dvi_enable") == 0) { + } else if (video_supported == VIDEO_NEW && + strlencmp(cmd, "dvi_enable") == 0) { enable |= 0x08; - } else if (strlencmp(cmd, "dvi_disable") == 0) { + } else if (video_supported == VIDEO_NEW && + strlencmp(cmd, "dvi_disable") == 0) { disable |= 0x08; } else if (strlencmp(cmd, "auto_enable") == 0) { if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1)) @@ -536,71 +746,75 @@ static int video_write(struct ibm_struct *ibm, char *buf) if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 0)) return -EIO; } else if (strlencmp(cmd, "video_switch") == 0) { - int autoswitch; - if (!acpi_evalf(vid_handle, &autoswitch, "^VDEE", "d")) - return -EIO; - if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1)) - return -EIO; - if (!acpi_evalf(vid_handle, NULL, "VSWT", "v")) - return -EIO; - if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", - autoswitch)) + if (!video_switch()) return -EIO; } else if (strlencmp(cmd, "expand_toggle") == 0) { - if (!acpi_evalf(NULL, NULL, "\\VEXP", "v")) + if (!video_expand()) return -EIO; } else return -EINVAL; } if (enable || disable) { - status = (video_status(ibm) & 0x0f & ~disable) | enable; - if (!acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0x80)) - return -EIO; - if (!acpi_evalf(NULL, NULL, "\\VSDS", "vdd", status, 1)) + status = (video_status() & 0x0f & ~disable) | enable; + if (!video_switch2(status)) return -EIO; } return 0; } -static void video_exit(struct ibm_struct *ibm) +static void video_exit(void) { - acpi_evalf(vid_handle, NULL, "_DOS", "vd", - ibm->state.video.autoswitch); + acpi_evalf(vid_handle, NULL, "_DOS", "vd", video_orig_autosw); } -static int light_init(struct ibm_struct *ibm) +static int light_supported; +static int light_status_supported; + +static int light_init(void) { - /* kblt not supported on G40, R32, X20 */ - ibm->supported = acpi_evalf(ec_handle, NULL, "KBLT", "qv"); + /* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */ + light_supported = (cmos_handle || lght_handle) && !ledb_handle; + + if (light_supported) + /* light status not supported on + 570, 600e/x, 770e, 770x, G4x, R30, R31, R32, X20 */ + light_status_supported = acpi_evalf(ec_handle, NULL, + "KBLT", "qv"); return 0; } -static int light_read(struct ibm_struct *ibm, char *p) +static int light_read(char *p) { int len = 0; int status = 0; - if (ibm->supported) { + if (!light_supported) { + len += sprintf(p + len, "status:\t\tnot supported\n"); + } else if (!light_status_supported) { + len += sprintf(p + len, "status:\t\tunknown\n"); + len += sprintf(p + len, "commands:\ton, off\n"); + } else { if (!acpi_evalf(ec_handle, &status, "KBLT", "d")) return -EIO; len += sprintf(p + len, "status:\t\t%s\n", onoff(status, 0)); - } else - len += sprintf(p + len, "status:\t\tunknown\n"); - - len += sprintf(p + len, "commands:\ton, off\n"); + len += sprintf(p + len, "commands:\ton, off\n"); + } return len; } -static int light_write(struct ibm_struct *ibm, char *buf) +static int light_write(char *buf) { int cmos_cmd, lght_cmd; char *cmd; int success; - + + if (!light_supported) + return -ENODEV; + while ((cmd = next_cmd(&buf))) { if (strlencmp(cmd, "on") == 0) { cmos_cmd = 0x0c; @@ -610,10 +824,10 @@ static int light_write(struct ibm_struct *ibm, char *buf) lght_cmd = 0; } else return -EINVAL; - + success = cmos_handle ? - acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd) : - acpi_evalf(lght_handle, NULL, NULL, "vd", lght_cmd); + acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd) : + acpi_evalf(lght_handle, NULL, NULL, "vd", lght_cmd); if (!success) return -EIO; } @@ -633,7 +847,7 @@ static int _sta(acpi_handle handle) #define dock_docked() (_sta(dock_handle) & 1) -static int dock_read(struct ibm_struct *ibm, char *p) +static int dock_read(char *p) { int len = 0; int docked = dock_docked(); @@ -650,18 +864,17 @@ static int dock_read(struct ibm_struct *ibm, char *p) return len; } -static int dock_write(struct ibm_struct *ibm, char *buf) +static int dock_write(char *buf) { char *cmd; if (!dock_docked()) - return -EINVAL; + return -ENODEV; while ((cmd = next_cmd(&buf))) { if (strlencmp(cmd, "undock") == 0) { - if (!acpi_evalf(dock_handle, NULL, "_DCK", "vd", 0)) - return -EIO; - if (!acpi_evalf(dock_handle, NULL, "_EJ0", "vd", 1)) + if (!acpi_evalf(dock_handle, NULL, "_DCK", "vd", 0) || + !acpi_evalf(dock_handle, NULL, "_EJ0", "vd", 1)) return -EIO; } else if (strlencmp(cmd, "dock") == 0) { if (!acpi_evalf(dock_handle, NULL, "_DCK", "vd", 1)) @@ -671,90 +884,131 @@ static int dock_write(struct ibm_struct *ibm, char *buf) } return 0; -} +} static void dock_notify(struct ibm_struct *ibm, u32 event) { int docked = dock_docked(); - - if (event == 3 && docked) - acpi_bus_generate_event(ibm->device, event, 1); /* button */ + int pci = ibm->hid && strstr(ibm->hid, IBM_PCI_HID); + + if (event == 1 && !pci) /* 570 */ + acpi_bus_generate_event(ibm->device, event, 1); /* button */ + else if (event == 1 && pci) /* 570 */ + acpi_bus_generate_event(ibm->device, event, 3); /* dock */ + else if (event == 3 && docked) + acpi_bus_generate_event(ibm->device, event, 1); /* button */ else if (event == 3 && !docked) - acpi_bus_generate_event(ibm->device, event, 2); /* undock */ + acpi_bus_generate_event(ibm->device, event, 2); /* undock */ else if (event == 0 && docked) - acpi_bus_generate_event(ibm->device, event, 3); /* dock */ + acpi_bus_generate_event(ibm->device, event, 3); /* dock */ else { printk(IBM_ERR "unknown dock event %d, status %d\n", event, _sta(dock_handle)); - acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ + acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ } } -#define bay_occupied() (_sta(bay_handle) & 1) +static int bay_status_supported; +static int bay_status2_supported; +static int bay_eject_supported; +static int bay_eject2_supported; -static int bay_init(struct ibm_struct *ibm) +static int bay_init(void) { - /* bay not supported on A21e, A22p, A31, A31p, G40, R32, R40e */ - ibm->supported = bay_handle && bayej_handle && - acpi_evalf(bay_handle, NULL, "_STA", "qv"); + bay_status_supported = bay_handle && + acpi_evalf(bay_handle, NULL, "_STA", "qv"); + bay_status2_supported = bay2_handle && + acpi_evalf(bay2_handle, NULL, "_STA", "qv"); + + bay_eject_supported = bay_handle && bay_ej_handle && + (strlencmp(bay_ej_path, "_EJ0") == 0 || experimental); + bay_eject2_supported = bay2_handle && bay2_ej_handle && + (strlencmp(bay2_ej_path, "_EJ0") == 0 || experimental); return 0; } -static int bay_read(struct ibm_struct *ibm, char *p) +#define bay_occupied(b) (_sta(b##_handle) & 1) + +static int bay_read(char *p) { int len = 0; - int occupied = bay_occupied(); - - if (!ibm->supported) - len += sprintf(p + len, "status:\t\tnot supported\n"); - else if (!occupied) - len += sprintf(p + len, "status:\t\tunoccupied\n"); - else { - len += sprintf(p + len, "status:\t\toccupied\n"); + int occupied = bay_occupied(bay); + int occupied2 = bay_occupied(bay2); + int eject, eject2; + + len += sprintf(p + len, "status:\t\t%s\n", bay_status_supported ? + (occupied ? "occupied" : "unoccupied") : + "not supported"); + if (bay_status2_supported) + len += sprintf(p + len, "status2:\t%s\n", occupied2 ? + "occupied" : "unoccupied"); + + eject = bay_eject_supported && occupied; + eject2 = bay_eject2_supported && occupied2; + + if (eject && eject2) + len += sprintf(p + len, "commands:\teject, eject2\n"); + else if (eject) len += sprintf(p + len, "commands:\teject\n"); - } + else if (eject2) + len += sprintf(p + len, "commands:\teject2\n"); return len; } -static int bay_write(struct ibm_struct *ibm, char *buf) +static int bay_write(char *buf) { char *cmd; + if (!bay_eject_supported && !bay_eject2_supported) + return -ENODEV; + while ((cmd = next_cmd(&buf))) { - if (strlencmp(cmd, "eject") == 0) { - if (!ibm->supported || - !acpi_evalf(bay_handle, NULL, "_EJ0", "vd", 1)) + if (bay_eject_supported && strlencmp(cmd, "eject") == 0) { + if (!acpi_evalf(bay_ej_handle, NULL, NULL, "vd", 1)) + return -EIO; + } else if (bay_eject2_supported && + strlencmp(cmd, "eject2") == 0) { + if (!acpi_evalf(bay2_ej_handle, NULL, NULL, "vd", 1)) return -EIO; } else return -EINVAL; } return 0; -} +} static void bay_notify(struct ibm_struct *ibm, u32 event) { acpi_bus_generate_event(ibm->device, event, 0); } -static int cmos_read(struct ibm_struct *ibm, char *p) +static int cmos_read(char *p) { int len = 0; - /* cmos not supported on A21e, A22p, T20, T21, X20 */ + /* cmos not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, + R30, R31, T20-22, X20-21 */ if (!cmos_handle) len += sprintf(p + len, "status:\t\tnot supported\n"); else { len += sprintf(p + len, "status:\t\tsupported\n"); - len += sprintf(p + len, "commands:\t\n"); + len += sprintf(p + len, "commands:\t ( is 0-21)\n"); } return len; } -static int cmos_write(struct ibm_struct *ibm, char *buf) +static int cmos_eval(int cmos_cmd) +{ + if (cmos_handle) + return acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd); + else + return 1; +} + +static int cmos_write(char *buf) { char *cmd; int cmos_cmd; @@ -763,183 +1017,644 @@ static int cmos_write(struct ibm_struct *ibm, char *buf) return -EINVAL; while ((cmd = next_cmd(&buf))) { - if (sscanf(cmd, "%u", &cmos_cmd) == 1) { + if (sscanf(cmd, "%u", &cmos_cmd) == 1 && + cmos_cmd >= 0 && cmos_cmd <= 21) { /* cmos_cmd set */ } else return -EINVAL; - if (!acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd)) + if (!cmos_eval(cmos_cmd)) return -EIO; } return 0; -} - -static int led_read(struct ibm_struct *ibm, char *p) +} + +static int led_supported; + +#define LED_570 1 +#define LED_OLD 2 +#define LED_NEW 3 + +static int led_init(void) +{ + if (!led_handle) + /* led not supported on R30, R31 */ + led_supported = 0; + else if (strlencmp(led_path, "SLED") == 0) + /* 570 */ + led_supported = LED_570; + else if (strlencmp(led_path, "SYSL") == 0) + /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */ + led_supported = LED_OLD; + else + /* all others */ + led_supported = LED_NEW; + + return 0; +} + +#define led_status(s) ((s) == 0 ? "off" : ((s) == 1 ? "on" : "blinking")) + +static int led_read(char *p) { int len = 0; + if (!led_supported) { + len += sprintf(p + len, "status:\t\tnot supported\n"); + return len; + } + len += sprintf(p + len, "status:\t\tsupported\n"); + + if (led_supported == LED_570) { + /* 570 */ + int i, status; + for (i = 0; i < 8; i++) { + if (!acpi_evalf(ec_handle, + &status, "GLED", "dd", 1 << i)) + return -EIO; + len += sprintf(p + len, "%d:\t\t%s\n", + i, led_status(status)); + } + } + len += sprintf(p + len, "commands:\t" - " on, off, blink\n"); + " on, off, blink ( is 0-7)\n"); return len; } -static int led_write(struct ibm_struct *ibm, char *buf) +/* off, on, blink */ +static const int led_sled_arg1[] = { 0, 1, 3 }; +static const int led_exp_hlbl[] = { 0, 0, 1 }; /* led# * */ +static const int led_exp_hlcl[] = { 0, 1, 1 }; /* led# * */ +static const int led_led_arg1[] = { 0, 0x80, 0xc0 }; + +#define EC_HLCL 0x0c +#define EC_HLBL 0x0d +#define EC_HLMS 0x0e + +static int led_write(char *buf) { char *cmd; - unsigned int led; - int led_cmd, sysl_cmd, bled_a, bled_b; + int led, ind, ret; + + if (!led_supported) + return -ENODEV; while ((cmd = next_cmd(&buf))) { - if (sscanf(cmd, "%u", &led) != 1) + if (sscanf(cmd, "%d", &led) != 1 || led < 0 || led > 7) return -EINVAL; - if (strstr(cmd, "blink")) { - led_cmd = 0xc0; - sysl_cmd = 2; - bled_a = 2; - bled_b = 1; + if (strstr(cmd, "off")) { + ind = 0; } else if (strstr(cmd, "on")) { - led_cmd = 0x80; - sysl_cmd = 1; - bled_a = 2; - bled_b = 0; - } else if (strstr(cmd, "off")) { - led_cmd = sysl_cmd = bled_a = bled_b = 0; + ind = 1; + } else if (strstr(cmd, "blink")) { + ind = 2; } else return -EINVAL; - - if (led_handle) { + + if (led_supported == LED_570) { + /* 570 */ + led = 1 << led; if (!acpi_evalf(led_handle, NULL, NULL, "vdd", - led, led_cmd)) + led, led_sled_arg1[ind])) return -EIO; - } else if (led < 2) { - if (acpi_evalf(sysl_handle, NULL, NULL, "vdd", - led, sysl_cmd)) + } else if (led_supported == LED_OLD) { + /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */ + led = 1 << led; + ret = ec_write(EC_HLMS, led); + if (ret >= 0) + ret = + ec_write(EC_HLBL, led * led_exp_hlbl[ind]); + if (ret >= 0) + ret = + ec_write(EC_HLCL, led * led_exp_hlcl[ind]); + if (ret < 0) + return ret; + } else { + /* all others */ + if (!acpi_evalf(led_handle, NULL, NULL, "vdd", + led, led_led_arg1[ind])) return -EIO; - } else if (led == 2 && bled_handle) { - if (acpi_evalf(bled_handle, NULL, NULL, "vdd", - bled_a, bled_b)) + } + } + + return 0; +} + +static int beep_read(char *p) +{ + int len = 0; + + if (!beep_handle) + len += sprintf(p + len, "status:\t\tnot supported\n"); + else { + len += sprintf(p + len, "status:\t\tsupported\n"); + len += sprintf(p + len, "commands:\t ( is 0-17)\n"); + } + + return len; +} + +static int beep_write(char *buf) +{ + char *cmd; + int beep_cmd; + + if (!beep_handle) + return -ENODEV; + + while ((cmd = next_cmd(&buf))) { + if (sscanf(cmd, "%u", &beep_cmd) == 1 && + beep_cmd >= 0 && beep_cmd <= 17) { + /* beep_cmd set */ + } else + return -EINVAL; + if (!acpi_evalf(beep_handle, NULL, NULL, "vdd", beep_cmd, 0)) + return -EIO; + } + + return 0; +} + +static int acpi_ec_read(int i, u8 * p) +{ + int v; + + if (ecrd_handle) { + if (!acpi_evalf(ecrd_handle, &v, NULL, "dd", i)) + return 0; + *p = v; + } else { + if (ec_read(i, p) < 0) + return 0; + } + + return 1; +} + +static int acpi_ec_write(int i, u8 v) +{ + if (ecwr_handle) { + if (!acpi_evalf(ecwr_handle, NULL, NULL, "vdd", i, v)) + return 0; + } else { + if (ec_write(i, v) < 0) + return 0; + } + + return 1; +} + +static int thermal_tmp_supported; +static int thermal_updt_supported; + +static int thermal_init(void) +{ + /* temperatures not supported on 570, G4x, R30, R31, R32 */ + thermal_tmp_supported = acpi_evalf(ec_handle, NULL, "TMP7", "qv"); + + /* 600e/x, 770e, 770x */ + thermal_updt_supported = acpi_evalf(ec_handle, NULL, "UPDT", "qv"); + + return 0; +} + +static int thermal_read(char *p) +{ + int len = 0; + + if (!thermal_tmp_supported) + len += sprintf(p + len, "temperatures:\tnot supported\n"); + else { + int i, t; + char tmpi[] = "TMPi"; + s8 tmp[8]; + + if (thermal_updt_supported) + if (!acpi_evalf(ec_handle, NULL, "UPDT", "v")) + return -EIO; + + for (i = 0; i < 8; i++) { + tmpi[3] = '0' + i; + if (!acpi_evalf(ec_handle, &t, tmpi, "d")) + return -EIO; + if (thermal_updt_supported) + tmp[i] = (t - 2732 + 5) / 10; + else + tmp[i] = t; + } + + len += sprintf(p + len, + "temperatures:\t%d %d %d %d %d %d %d %d\n", + tmp[0], tmp[1], tmp[2], tmp[3], + tmp[4], tmp[5], tmp[6], tmp[7]); + } + + return len; +} + +static u8 ecdump_regs[256]; + +static int ecdump_read(char *p) +{ + int len = 0; + int i, j; + u8 v; + + len += sprintf(p + len, "EC " + " +00 +01 +02 +03 +04 +05 +06 +07" + " +08 +09 +0a +0b +0c +0d +0e +0f\n"); + for (i = 0; i < 256; i += 16) { + len += sprintf(p + len, "EC 0x%02x:", i); + for (j = 0; j < 16; j++) { + if (!acpi_ec_read(i + j, &v)) + break; + if (v != ecdump_regs[i + j]) + len += sprintf(p + len, " *%02x", v); + else + len += sprintf(p + len, " %02x", v); + ecdump_regs[i + j] = v; + } + len += sprintf(p + len, "\n"); + if (j != 16) + break; + } + + /* These are way too dangerous to advertise openly... */ +#if 0 + len += sprintf(p + len, "commands:\t0x 0x" + " ( is 00-ff, is 00-ff)\n"); + len += sprintf(p + len, "commands:\t0x " + " ( is 00-ff, is 0-255)\n"); +#endif + return len; +} + +static int ecdump_write(char *buf) +{ + char *cmd; + int i, v; + + while ((cmd = next_cmd(&buf))) { + if (sscanf(cmd, "0x%x 0x%x", &i, &v) == 2) { + /* i and v set */ + } else if (sscanf(cmd, "0x%x %u", &i, &v) == 2) { + /* i and v set */ + } else + return -EINVAL; + if (i >= 0 && i < 256 && v >= 0 && v < 256) { + if (!acpi_ec_write(i, v)) return -EIO; } else return -EINVAL; } return 0; -} - -static int beep_read(struct ibm_struct *ibm, char *p) +} + +static int brightness_offset = 0x31; + +static int brightness_read(char *p) { int len = 0; + u8 level; - len += sprintf(p + len, "commands:\t\n"); + if (!acpi_ec_read(brightness_offset, &level)) { + len += sprintf(p + len, "level:\t\tunreadable\n"); + } else { + len += sprintf(p + len, "level:\t\t%d\n", level & 0x7); + len += sprintf(p + len, "commands:\tup, down\n"); + len += sprintf(p + len, "commands:\tlevel " + " ( is 0-7)\n"); + } return len; } -static int beep_write(struct ibm_struct *ibm, char *buf) +#define BRIGHTNESS_UP 4 +#define BRIGHTNESS_DOWN 5 + +static int brightness_write(char *buf) { + int cmos_cmd, inc, i; + u8 level; + int new_level; char *cmd; - int beep_cmd; while ((cmd = next_cmd(&buf))) { - if (sscanf(cmd, "%u", &beep_cmd) == 1) { - /* beep_cmd set */ + if (!acpi_ec_read(brightness_offset, &level)) + return -EIO; + level &= 7; + + if (strlencmp(cmd, "up") == 0) { + new_level = level == 7 ? 7 : level + 1; + } else if (strlencmp(cmd, "down") == 0) { + new_level = level == 0 ? 0 : level - 1; + } else if (sscanf(cmd, "level %d", &new_level) == 1 && + new_level >= 0 && new_level <= 7) { + /* new_level set */ + } else + return -EINVAL; + + cmos_cmd = new_level > level ? BRIGHTNESS_UP : BRIGHTNESS_DOWN; + inc = new_level > level ? 1 : -1; + for (i = level; i != new_level; i += inc) { + if (!cmos_eval(cmos_cmd)) + return -EIO; + if (!acpi_ec_write(brightness_offset, i + inc)) + return -EIO; + } + } + + return 0; +} + +static int volume_offset = 0x30; + +static int volume_read(char *p) +{ + int len = 0; + u8 level; + + if (!acpi_ec_read(volume_offset, &level)) { + len += sprintf(p + len, "level:\t\tunreadable\n"); + } else { + len += sprintf(p + len, "level:\t\t%d\n", level & 0xf); + len += sprintf(p + len, "mute:\t\t%s\n", onoff(level, 6)); + len += sprintf(p + len, "commands:\tup, down, mute\n"); + len += sprintf(p + len, "commands:\tlevel " + " ( is 0-15)\n"); + } + + return len; +} + +#define VOLUME_DOWN 0 +#define VOLUME_UP 1 +#define VOLUME_MUTE 2 + +static int volume_write(char *buf) +{ + int cmos_cmd, inc, i; + u8 level, mute; + int new_level, new_mute; + char *cmd; + + while ((cmd = next_cmd(&buf))) { + if (!acpi_ec_read(volume_offset, &level)) + return -EIO; + new_mute = mute = level & 0x40; + new_level = level = level & 0xf; + + if (strlencmp(cmd, "up") == 0) { + if (mute) + new_mute = 0; + else + new_level = level == 15 ? 15 : level + 1; + } else if (strlencmp(cmd, "down") == 0) { + if (mute) + new_mute = 0; + else + new_level = level == 0 ? 0 : level - 1; + } else if (sscanf(cmd, "level %d", &new_level) == 1 && + new_level >= 0 && new_level <= 15) { + /* new_level set */ + } else if (strlencmp(cmd, "mute") == 0) { + new_mute = 0x40; } else return -EINVAL; - if (!acpi_evalf(beep_handle, NULL, NULL, "vd", beep_cmd)) + if (new_level != level) { /* mute doesn't change */ + cmos_cmd = new_level > level ? VOLUME_UP : VOLUME_DOWN; + inc = new_level > level ? 1 : -1; + + if (mute && (!cmos_eval(cmos_cmd) || + !acpi_ec_write(volume_offset, level))) + return -EIO; + + for (i = level; i != new_level; i += inc) + if (!cmos_eval(cmos_cmd) || + !acpi_ec_write(volume_offset, i + inc)) + return -EIO; + + if (mute && (!cmos_eval(VOLUME_MUTE) || + !acpi_ec_write(volume_offset, + new_level + mute))) + return -EIO; + } + + if (new_mute != mute) { /* level doesn't change */ + cmos_cmd = new_mute ? VOLUME_MUTE : VOLUME_UP; + + if (!cmos_eval(cmos_cmd) || + !acpi_ec_write(volume_offset, level + new_mute)) + return -EIO; + } + } + + return 0; +} + +static int fan_status_offset = 0x2f; +static int fan_rpm_offset = 0x84; + +static int fan_read(char *p) +{ + int len = 0; + int s; + u8 lo, hi, status; + + if (gfan_handle) { + /* 570, 600e/x, 770e, 770x */ + if (!acpi_evalf(gfan_handle, &s, NULL, "d")) return -EIO; + + len += sprintf(p + len, "level:\t\t%d\n", s); + } else { + /* all except 570, 600e/x, 770e, 770x */ + if (!acpi_ec_read(fan_status_offset, &status)) + len += sprintf(p + len, "status:\t\tunreadable\n"); + else + len += sprintf(p + len, "status:\t\t%s\n", + enabled(status, 7)); + + if (!acpi_ec_read(fan_rpm_offset, &lo) || + !acpi_ec_read(fan_rpm_offset + 1, &hi)) + len += sprintf(p + len, "speed:\t\tunreadable\n"); + else + len += sprintf(p + len, "speed:\t\t%d\n", + (hi << 8) + lo); + } + + if (sfan_handle) + /* 570, 770x-JL */ + len += sprintf(p + len, "commands:\tlevel " + " ( is 0-7)\n"); + if (!gfan_handle) + /* all except 570, 600e/x, 770e, 770x */ + len += sprintf(p + len, "commands:\tenable, disable\n"); + if (fans_handle) + /* X31, X40 */ + len += sprintf(p + len, "commands:\tspeed " + " ( is 0-65535)\n"); + + return len; +} + +static int fan_write(char *buf) +{ + char *cmd; + int level, speed; + + while ((cmd = next_cmd(&buf))) { + if (sfan_handle && + sscanf(cmd, "level %d", &level) == 1 && + level >= 0 && level <= 7) { + /* 570, 770x-JL */ + if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", level)) + return -EIO; + } else if (!gfan_handle && strlencmp(cmd, "enable") == 0) { + /* all except 570, 600e/x, 770e, 770x */ + if (!acpi_ec_write(fan_status_offset, 0x80)) + return -EIO; + } else if (!gfan_handle && strlencmp(cmd, "disable") == 0) { + /* all except 570, 600e/x, 770e, 770x */ + if (!acpi_ec_write(fan_status_offset, 0x00)) + return -EIO; + } else if (fans_handle && + sscanf(cmd, "speed %d", &speed) == 1 && + speed >= 0 && speed <= 65535) { + /* X31, X40 */ + if (!acpi_evalf(fans_handle, NULL, NULL, "vddd", + speed, speed, speed)) + return -EIO; + } else + return -EINVAL; } return 0; -} - +} + static struct ibm_struct ibms[] = { { - .name = "driver", - .init = driver_init, - .read = driver_read, - }, + .name = "driver", + .init = driver_init, + .read = driver_read, + }, + { + .name = "hotkey", + .hid = IBM_HKEY_HID, + .init = hotkey_init, + .read = hotkey_read, + .write = hotkey_write, + .exit = hotkey_exit, + .notify = hotkey_notify, + .handle = &hkey_handle, + .type = ACPI_DEVICE_NOTIFY, + }, + { + .name = "bluetooth", + .init = bluetooth_init, + .read = bluetooth_read, + .write = bluetooth_write, + }, + { + .name = "video", + .init = video_init, + .read = video_read, + .write = video_write, + .exit = video_exit, + }, { - .name = "hotkey", - .hid = "IBM0068", - .init = hotkey_init, - .read = hotkey_read, - .write = hotkey_write, - .exit = hotkey_exit, - .notify = hotkey_notify, - .handle = &hkey_handle, - .type = ACPI_DEVICE_NOTIFY, - }, + .name = "light", + .init = light_init, + .read = light_read, + .write = light_write, + }, { - .name = "bluetooth", - .init = bluetooth_init, - .read = bluetooth_read, - .write = bluetooth_write, - }, + .name = "dock", + .read = dock_read, + .write = dock_write, + .notify = dock_notify, + .handle = &dock_handle, + .type = ACPI_SYSTEM_NOTIFY, + }, { - .name = "video", - .init = video_init, - .read = video_read, - .write = video_write, - .exit = video_exit, - }, + .name = "dock", + .hid = IBM_PCI_HID, + .notify = dock_notify, + .handle = &pci_handle, + .type = ACPI_SYSTEM_NOTIFY, + }, { - .name = "light", - .init = light_init, - .read = light_read, - .write = light_write, - }, + .name = "bay", + .init = bay_init, + .read = bay_read, + .write = bay_write, + .notify = bay_notify, + .handle = &bay_handle, + .type = ACPI_SYSTEM_NOTIFY, + }, { - .name = "dock", - .read = dock_read, - .write = dock_write, - .notify = dock_notify, - .handle = &dock_handle, - .type = ACPI_SYSTEM_NOTIFY, - }, + .name = "cmos", + .read = cmos_read, + .write = cmos_write, + }, { - .name = "bay", - .init = bay_init, - .read = bay_read, - .write = bay_write, - .notify = bay_notify, - .handle = &bay_handle, - .type = ACPI_SYSTEM_NOTIFY, - }, + .name = "led", + .init = led_init, + .read = led_read, + .write = led_write, + }, { - .name = "cmos", - .read = cmos_read, - .write = cmos_write, - .experimental = 1, - }, + .name = "beep", + .read = beep_read, + .write = beep_write, + }, { - .name = "led", - .read = led_read, - .write = led_write, - .experimental = 1, - }, + .name = "thermal", + .init = thermal_init, + .read = thermal_read, + }, { - .name = "beep", - .read = beep_read, - .write = beep_write, - .experimental = 1, - }, + .name = "ecdump", + .read = ecdump_read, + .write = ecdump_write, + .experimental = 1, + }, + { + .name = "brightness", + .read = brightness_read, + .write = brightness_write, + .experimental = 1, + }, + { + .name = "volume", + .read = volume_read, + .write = volume_write, + .experimental = 1, + }, + { + .name = "fan", + .read = fan_read, + .write = fan_write, + .experimental = 1, + }, }; -#define NUM_IBMS (sizeof(ibms)/sizeof(ibms[0])) static int dispatch_read(char *page, char **start, off_t off, int count, int *eof, void *data) { struct ibm_struct *ibm = (struct ibm_struct *)data; int len; - + if (!ibm || !ibm->read) return -EINVAL; - len = ibm->read(ibm, page); + len = ibm->read(page); if (len < 0) return len; @@ -955,7 +1670,7 @@ static int dispatch_read(char *page, char **start, off_t off, int count, return len; } -static int dispatch_write(struct file *file, const char __user *userbuf, +static int dispatch_write(struct file *file, const char __user * userbuf, unsigned long count, void *data) { struct ibm_struct *ibm = (struct ibm_struct *)data; @@ -969,20 +1684,20 @@ static int dispatch_write(struct file *file, const char __user *userbuf, if (!kernbuf) return -ENOMEM; - if (copy_from_user(kernbuf, userbuf, count)) { + if (copy_from_user(kernbuf, userbuf, count)) { kfree(kernbuf); - return -EFAULT; + return -EFAULT; } kernbuf[count] = 0; strcat(kernbuf, ","); - ret = ibm->write(ibm, kernbuf); + ret = ibm->write(kernbuf); if (ret == 0) ret = count; kfree(kernbuf); - return ret; + return ret; } static void dispatch_notify(acpi_handle handle, u32 event, void *data) @@ -995,7 +1710,7 @@ static void dispatch_notify(acpi_handle handle, u32 event, void *data) ibm->notify(ibm, event); } -static int setup_notify(struct ibm_struct *ibm) +static int __init setup_notify(struct ibm_struct *ibm) { acpi_status status; int ret; @@ -1020,17 +1735,15 @@ static int setup_notify(struct ibm_struct *ibm) return -ENODEV; } - ibm->notify_installed = 1; - return 0; } -static int ibmacpi_device_add(struct acpi_device *device) +static int __init ibm_device_add(struct acpi_device *device) { return 0; } -static int register_driver(struct ibm_struct *ibm) +static int __init register_driver(struct ibm_struct *ibm) { int ret; @@ -1043,7 +1756,7 @@ static int register_driver(struct ibm_struct *ibm) memset(ibm->driver, 0, sizeof(struct acpi_driver)); sprintf(ibm->driver->name, "%s/%s", IBM_NAME, ibm->name); ibm->driver->ids = ibm->hid; - ibm->driver->ops.add = &ibmacpi_device_add; + ibm->driver->ops.add = &ibm_device_add; ret = acpi_bus_register_driver(ibm->driver); if (ret < 0) { @@ -1055,7 +1768,7 @@ static int register_driver(struct ibm_struct *ibm) return ret; } -static int ibm_init(struct ibm_struct *ibm) +static int __init ibm_init(struct ibm_struct *ibm) { int ret; struct proc_dir_entry *entry; @@ -1071,31 +1784,34 @@ static int ibm_init(struct ibm_struct *ibm) } if (ibm->init) { - ret = ibm->init(ibm); + ret = ibm->init(); if (ret != 0) return ret; ibm->init_called = 1; } - entry = create_proc_entry(ibm->name, S_IFREG | S_IRUGO | S_IWUSR, - proc_dir); - if (!entry) { - printk(IBM_ERR "unable to create proc entry %s\n", ibm->name); - return -ENODEV; - } - entry->owner = THIS_MODULE; - ibm->proc_created = 1; - - entry->data = ibm; - if (ibm->read) + if (ibm->read) { + entry = create_proc_entry(ibm->name, + S_IFREG | S_IRUGO | S_IWUSR, + proc_dir); + if (!entry) { + printk(IBM_ERR "unable to create proc entry %s\n", + ibm->name); + return -ENODEV; + } + entry->owner = THIS_MODULE; + entry->data = ibm; entry->read_proc = &dispatch_read; - if (ibm->write) - entry->write_proc = &dispatch_write; + if (ibm->write) + entry->write_proc = &dispatch_write; + ibm->proc_created = 1; + } if (ibm->notify) { ret = setup_notify(ibm); if (ret < 0) return ret; + ibm->notify_installed = 1; } return 0; @@ -1111,7 +1827,7 @@ static void ibm_exit(struct ibm_struct *ibm) remove_proc_entry(ibm->name, proc_dir); if (ibm->init_called && ibm->exit) - ibm->exit(ibm); + ibm->exit(); if (ibm->driver_registered) { acpi_bus_unregister_driver(ibm->driver); @@ -1119,60 +1835,66 @@ static void ibm_exit(struct ibm_struct *ibm) } } -static int ibm_handle_init(char *name, - acpi_handle *handle, acpi_handle parent, - char **paths, int num_paths, int required) +static void __init ibm_handle_init(char *name, + acpi_handle * handle, acpi_handle parent, + char **paths, int num_paths, char **path) { int i; acpi_status status; - for (i=0; i 30) - return -ENOSPC; - strcpy(arg_with_comma, val); - strcat(arg_with_comma, ","); + for (i = 0; i < ARRAY_SIZE(ibms); i++) + if (strcmp(ibms[i].name, kp->name) == 0 && ibms[i].write) { + if (strlen(val) > sizeof(ibms[i].param) - 2) + return -ENOSPC; + strcpy(ibms[i].param, val); + strcat(ibms[i].param, ","); + return 0; + } - for (i=0; iname) == 0) - return ibms[i].write(&ibms[i], arg_with_comma); - BUG(); return -EINVAL; } #define IBM_PARAM(feature) \ module_param_call(feature, set_ibm_param, NULL, NULL, 0) +IBM_PARAM(hotkey); +IBM_PARAM(bluetooth); +IBM_PARAM(video); +IBM_PARAM(light); +IBM_PARAM(dock); +IBM_PARAM(bay); +IBM_PARAM(cmos); +IBM_PARAM(led); +IBM_PARAM(beep); +IBM_PARAM(ecdump); +IBM_PARAM(brightness); +IBM_PARAM(volume); +IBM_PARAM(fan); + static void acpi_ibm_exit(void) { int i; - for (i=NUM_IBMS-1; i>=0; i--) + for (i = ARRAY_SIZE(ibms) - 1; i >= 0; i--) ibm_exit(&ibms[i]); remove_proc_entry(IBM_DIR, acpi_root_dir); @@ -1185,30 +1907,40 @@ static int __init acpi_ibm_init(void) if (acpi_disabled) return -ENODEV; - if (!acpi_specific_hotkey_enabled){ - printk(IBM_ERR "Using generic hotkey driver\n"); - return -ENODEV; - } - /* these handles are required */ - if (IBM_HANDLE_INIT(ec, 1) < 0 || - IBM_HANDLE_INIT(hkey, 1) < 0 || - IBM_HANDLE_INIT(vid, 1) < 0 || - IBM_HANDLE_INIT(beep, 1) < 0) + if (!acpi_specific_hotkey_enabled) { + printk(IBM_ERR "using generic hotkey driver\n"); return -ENODEV; + } - /* these handles have alternatives */ - IBM_HANDLE_INIT(lght, 0); - if (IBM_HANDLE_INIT(cmos, !lght_handle) < 0) - return -ENODEV; - IBM_HANDLE_INIT(sysl, 0); - if (IBM_HANDLE_INIT(led, !sysl_handle) < 0) + /* ec is required because many other handles are relative to it */ + IBM_HANDLE_INIT(ec); + if (!ec_handle) { + printk(IBM_ERR "ec object not found\n"); return -ENODEV; + } /* these handles are not required */ - IBM_HANDLE_INIT(dock, 0); - IBM_HANDLE_INIT(bay, 0); - IBM_HANDLE_INIT(bayej, 0); - IBM_HANDLE_INIT(bled, 0); + IBM_HANDLE_INIT(vid); + IBM_HANDLE_INIT(vid2); + IBM_HANDLE_INIT(ledb); + IBM_HANDLE_INIT(led); + IBM_HANDLE_INIT(hkey); + IBM_HANDLE_INIT(lght); + IBM_HANDLE_INIT(cmos); + IBM_HANDLE_INIT(dock); + IBM_HANDLE_INIT(pci); + IBM_HANDLE_INIT(bay); + if (bay_handle) + IBM_HANDLE_INIT(bay_ej); + IBM_HANDLE_INIT(bay2); + if (bay2_handle) + IBM_HANDLE_INIT(bay2_ej); + IBM_HANDLE_INIT(beep); + IBM_HANDLE_INIT(ecrd); + IBM_HANDLE_INIT(ecwr); + IBM_HANDLE_INIT(fans); + IBM_HANDLE_INIT(gfan); + IBM_HANDLE_INIT(sfan); proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir); if (!proc_dir) { @@ -1216,9 +1948,11 @@ static int __init acpi_ibm_init(void) return -ENODEV; } proc_dir->owner = THIS_MODULE; - - for (i=0; i= 0 && *ibms[i].param) + ret = ibms[i].write(ibms[i].param); if (ret < 0) { acpi_ibm_exit(); return ret; @@ -1230,17 +1964,3 @@ static int __init acpi_ibm_init(void) module_init(acpi_ibm_init); module_exit(acpi_ibm_exit); - -MODULE_AUTHOR("Borislav Deianov"); -MODULE_DESCRIPTION(IBM_DESC); -MODULE_LICENSE("GPL"); - -IBM_PARAM(hotkey); -IBM_PARAM(bluetooth); -IBM_PARAM(video); -IBM_PARAM(light); -IBM_PARAM(dock); -IBM_PARAM(bay); -IBM_PARAM(cmos); -IBM_PARAM(led); -IBM_PARAM(beep); -- cgit v0.10.2 From d395bf12d1ba61437e546eb642f0d7ea666123ff Mon Sep 17 00:00:00 2001 From: Venkatesh Pallipadi Date: Thu, 25 Aug 2005 15:59:00 -0400 Subject: [ACPI] Reduce acpi-cpufreq switching latency by 50% The acpi-cpufreq driver does a P-state get after a P-state set to verify whether set went through successfully. This test is kind of redundant as set goes throught most of the times, and the test is also expensive as a get of P-states can take a lot of time (same as a set operation) as it goes through SMM mode. Effectively, we are doubling the P-state latency due to this get opertion. momdule parameter "acpi_pstate_strict" restores orginal paranoia. http://bugzilla.kernel.org/show_bug.cgi?id=5129 Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c index 60a9e54..822c8ce 100644 --- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,8 @@ static struct cpufreq_acpi_io *acpi_io_data[NR_CPUS]; static struct cpufreq_driver acpi_cpufreq_driver; +static unsigned int acpi_pstate_strict; + static int acpi_processor_write_port( u16 port, @@ -163,34 +166,44 @@ acpi_processor_set_performance ( } /* - * Then we read the 'status_register' and compare the value with the - * target state's 'status' to make sure the transition was successful. - * Note that we'll poll for up to 1ms (100 cycles of 10us) before - * giving up. + * Assume the write went through when acpi_pstate_strict is not used. + * As read status_register is an expensive operation and there + * are no specific error cases where an IO port write will fail. */ - - port = data->acpi_data.status_register.address; - bit_width = data->acpi_data.status_register.bit_width; - - dprintk("Looking for 0x%08x from port 0x%04x\n", - (u32) data->acpi_data.states[state].status, port); - - for (i=0; i<100; i++) { - ret = acpi_processor_read_port(port, bit_width, &value); - if (ret) { - dprintk("Invalid port width 0x%04x\n", bit_width); - retval = ret; - goto migrate_end; + if (acpi_pstate_strict) { + /* Then we read the 'status_register' and compare the value + * with the target state's 'status' to make sure the + * transition was successful. + * Note that we'll poll for up to 1ms (100 cycles of 10us) + * before giving up. + */ + + port = data->acpi_data.status_register.address; + bit_width = data->acpi_data.status_register.bit_width; + + dprintk("Looking for 0x%08x from port 0x%04x\n", + (u32) data->acpi_data.states[state].status, port); + + for (i=0; i<100; i++) { + ret = acpi_processor_read_port(port, bit_width, &value); + if (ret) { + dprintk("Invalid port width 0x%04x\n", bit_width); + retval = ret; + goto migrate_end; + } + if (value == (u32) data->acpi_data.states[state].status) + break; + udelay(10); } - if (value == (u32) data->acpi_data.states[state].status) - break; - udelay(10); + } else { + i = 0; + value = (u32) data->acpi_data.states[state].status; } /* notify cpufreq */ cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE); - if (value != (u32) data->acpi_data.states[state].status) { + if (unlikely(value != (u32) data->acpi_data.states[state].status)) { unsigned int tmp = cpufreq_freqs.new; cpufreq_freqs.new = cpufreq_freqs.old; cpufreq_freqs.old = tmp; @@ -537,6 +550,8 @@ acpi_cpufreq_exit (void) return; } +module_param(acpi_pstate_strict, uint, 0644); +MODULE_PARM_DESC(acpi_pstate_strict, "value 0 or non-zero. non-zero -> strict ACPI checks are performed during frequency changes."); late_initcall(acpi_cpufreq_init); module_exit(acpi_cpufreq_exit); -- cgit v0.10.2 From a18ecf413ca9846becb760f7f990c2c62c15965e Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Mon, 15 Aug 2005 03:42:00 -0800 Subject: [ACPI] ACPICA 20050815 Implemented a full bytewise compare to determine if a table load request is attempting to load a duplicate table. The compare is performed if the table signatures and table lengths match. This will allow different tables with the same OEM Table ID and revision to be loaded. Although the BIOS is technically violating the ACPI spec when this happens -- it does happen -- so Linux must handle it. Signed-off-by: Robert Moore Signed-off-by: Len Brown diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index 5bcafeb..4b2fbb5 100644 --- a/drivers/acpi/tables/tbutils.c +++ b/drivers/acpi/tables/tbutils.c @@ -80,14 +80,24 @@ acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc) /* Examine all installed tables of this type */ while (table_desc) { - /* Compare Revision and oem_table_id */ - + /* + * If the table lengths match, perform a full bytewise compare. This + * means that we will allow tables with duplicate oem_table_id(s), as + * long as the tables are different in some way. + * + * Checking if the table has been loaded into the namespace means that + * we don't check for duplicate tables during the initial installation + * of tables within the RSDT/XSDT. + */ if ((table_desc->loaded_into_namespace) && - (table_desc->pointer->revision == - new_table_desc->pointer->revision) && - (!ACPI_MEMCMP(table_desc->pointer->oem_table_id, - new_table_desc->pointer->oem_table_id, 8))) { - /* This table is already installed */ + (table_desc->pointer->length == + new_table_desc->pointer->length) + && + (!ACPI_MEMCMP + ((const char *)table_desc->pointer, + (const char *)new_table_desc->pointer, + (acpi_size) new_table_desc->pointer->length))) { + /* Match: this table is already installed */ ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Table [%4.4s] already installed: Rev %X oem_table_id [%8.8s]\n", diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c index 081a778..d80e926 100644 --- a/drivers/acpi/utilities/utdebug.c +++ b/drivers/acpi/utilities/utdebug.c @@ -122,13 +122,13 @@ static const char *acpi_ut_trim_function_name(const char *function_name) /* All Function names are longer than 4 chars, check is safe */ - if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_FUNCTION_PREFIX1) { + if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) { /* This is the case where the original source has not been modified */ return (function_name + 4); } - if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_FUNCTION_PREFIX2) { + if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) { /* This is the case where the source has been 'linuxized' */ return (function_name + 5); diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index 474fe7c..f027502 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -78,6 +78,10 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) for (i = 0; i < 32; i++) { if (!(acpi_gbl_owner_id_mask & (1 << i))) { + ACPI_DEBUG_PRINT((ACPI_DB_VALUES, + "Current owner_id mask: %8.8X New ID: %2.2X\n", + acpi_gbl_owner_id_mask, (i + 1))); + acpi_gbl_owner_id_mask |= (1 << i); *owner_id = (acpi_owner_id) (i + 1); goto exit; @@ -119,7 +123,7 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) acpi_owner_id owner_id = *owner_id_ptr; acpi_status status; - ACPI_FUNCTION_TRACE("ut_release_owner_id"); + ACPI_FUNCTION_TRACE_U32("ut_release_owner_id", owner_id); /* Always clear the input owner_id (zero is an invalid ID) */ diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index f3810cc..73c43a3 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -63,7 +63,7 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20050729 +#define ACPI_CA_VERSION 0x20050815 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h index 79152fb..4f9063f 100644 --- a/include/acpi/acnames.h +++ b/include/acpi/acnames.h @@ -71,16 +71,13 @@ /* Definitions of the predefined namespace names */ -#define ACPI_UNKNOWN_NAME (u32) 0x3F3F3F3F /* Unknown name is "????" */ -#define ACPI_ROOT_NAME (u32) 0x5F5F5F5C /* Root name is "\___" */ -#define ACPI_SYS_BUS_NAME (u32) 0x5F53425F /* Sys bus name is "_SB_" */ +#define ACPI_UNKNOWN_NAME (u32) 0x3F3F3F3F /* Unknown name is "????" */ +#define ACPI_ROOT_NAME (u32) 0x5F5F5F5C /* Root name is "\___" */ + +#define ACPI_PREFIX_MIXED (u32) 0x69706341 /* "Acpi" */ +#define ACPI_PREFIX_LOWER (u32) 0x69706361 /* "acpi" */ #define ACPI_NS_ROOT_PATH "\\" #define ACPI_NS_SYSTEM_BUS "_SB_" -/*! [Begin] no source code translation (not handled by acpisrc) */ -#define ACPI_FUNCTION_PREFIX1 'ipcA' -#define ACPI_FUNCTION_PREFIX2 'ipca' -/*! [End] no source code translation !*/ - #endif /* __ACNAMES_H__ */ -- cgit v0.10.2 From b1b5d7f9b7ac6a8e3452ac43a53eebf69fdf5a77 Mon Sep 17 00:00:00 2001 From: Dave Kleikamp Date: Tue, 30 Aug 2005 14:28:56 -0500 Subject: JFS: jfs_delete_inode should always call clear_inode. Signed-off-by: Dave Kleikamp diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index 767c7ec..37da3e3 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c @@ -128,21 +128,21 @@ void jfs_delete_inode(struct inode *inode) { jfs_info("In jfs_delete_inode, inode = 0x%p", inode); - if (is_bad_inode(inode) || - (JFS_IP(inode)->fileset != cpu_to_le32(FILESYSTEM_I))) - return; + if (!is_bad_inode(inode) && + (JFS_IP(inode)->fileset == cpu_to_le32(FILESYSTEM_I))) { - if (test_cflag(COMMIT_Freewmap, inode)) - jfs_free_zero_link(inode); + if (test_cflag(COMMIT_Freewmap, inode)) + jfs_free_zero_link(inode); - diFree(inode); + diFree(inode); - /* - * Free the inode from the quota allocation. - */ - DQUOT_INIT(inode); - DQUOT_FREE_INODE(inode); - DQUOT_DROP(inode); + /* + * Free the inode from the quota allocation. + */ + DQUOT_INIT(inode); + DQUOT_FREE_INODE(inode); + DQUOT_DROP(inode); + } clear_inode(inode); } -- cgit v0.10.2 From dc90e95f310f4f821c905b2aec8e9449bb3270fa Mon Sep 17 00:00:00 2001 From: Peter Chubb Date: Wed, 24 Aug 2005 17:13:00 -0700 Subject: [IA64] Add PAL_VM_SUMMARY/PAL_MEM_ATTRIB to bootloader for SKI This patch implements PAL_VM_SUMMARY (and PAL_MEM_ATTRIB for good measure) and pretends that the simulated machine is a McKinley. Some extra comments and clean-up by Tony Luck. Signed-off-by: Peter Chubb Signed-off-by: Tony Luck diff --git a/arch/ia64/hp/sim/boot/boot_head.S b/arch/ia64/hp/sim/boot/boot_head.S index 1c8c7e6..a9bd71a 100644 --- a/arch/ia64/hp/sim/boot/boot_head.S +++ b/arch/ia64/hp/sim/boot/boot_head.S @@ -4,6 +4,7 @@ */ #include +#include .bss .align 16 @@ -49,7 +50,11 @@ GLOBAL_ENTRY(jmp_to_kernel) br.sptk.few b7 END(jmp_to_kernel) - +/* + * r28 contains the index of the PAL function + * r29--31 the args + * Return values in ret0--3 (r8--11) + */ GLOBAL_ENTRY(pal_emulator_static) mov r8=-1 mov r9=256 @@ -62,7 +67,7 @@ GLOBAL_ENTRY(pal_emulator_static) cmp.gtu p6,p7=r9,r28 (p6) br.cond.sptk.few stacked ;; -static: cmp.eq p6,p7=6,r28 /* PAL_PTCE_INFO */ +static: cmp.eq p6,p7=PAL_PTCE_INFO,r28 (p7) br.cond.sptk.few 1f ;; mov r8=0 /* status = 0 */ @@ -70,21 +75,21 @@ static: cmp.eq p6,p7=6,r28 /* PAL_PTCE_INFO */ movl r10=0x0000000200000003 /* count[0], count[1] */ movl r11=0x1000000000002000 /* stride[0], stride[1] */ br.cond.sptk.few rp -1: cmp.eq p6,p7=14,r28 /* PAL_FREQ_RATIOS */ +1: cmp.eq p6,p7=PAL_FREQ_RATIOS,r28 (p7) br.cond.sptk.few 1f mov r8=0 /* status = 0 */ movl r9 =0x100000064 /* proc_ratio (1/100) */ movl r10=0x100000100 /* bus_ratio<<32 (1/256) */ movl r11=0x100000064 /* itc_ratio<<32 (1/100) */ ;; -1: cmp.eq p6,p7=19,r28 /* PAL_RSE_INFO */ +1: cmp.eq p6,p7=PAL_RSE_INFO,r28 (p7) br.cond.sptk.few 1f mov r8=0 /* status = 0 */ mov r9=96 /* num phys stacked */ mov r10=0 /* hints */ mov r11=0 br.cond.sptk.few rp -1: cmp.eq p6,p7=1,r28 /* PAL_CACHE_FLUSH */ +1: cmp.eq p6,p7=PAL_CACHE_FLUSH,r28 /* PAL_CACHE_FLUSH */ (p7) br.cond.sptk.few 1f mov r9=ar.lc movl r8=524288 /* flush 512k million cache lines (16MB) */ @@ -102,7 +107,7 @@ static: cmp.eq p6,p7=6,r28 /* PAL_PTCE_INFO */ mov ar.lc=r9 mov r8=r0 ;; -1: cmp.eq p6,p7=15,r28 /* PAL_PERF_MON_INFO */ +1: cmp.eq p6,p7=PAL_PERF_MON_INFO,r28 (p7) br.cond.sptk.few 1f mov r8=0 /* status = 0 */ movl r9 =0x08122f04 /* generic=4 width=47 retired=8 cycles=18 */ @@ -138,6 +143,20 @@ static: cmp.eq p6,p7=6,r28 /* PAL_PTCE_INFO */ st8 [r29]=r0,16 /* clear remaining bits */ st8 [r18]=r0,16 /* clear remaining bits */ ;; +1: cmp.eq p6,p7=PAL_VM_SUMMARY,r28 +(p7) br.cond.sptk.few 1f + mov r8=0 /* status = 0 */ + movl r9=0x2044040020F1865 /* num_tc_levels=2, num_unique_tcs=4 */ + /* max_itr_entry=64, max_dtr_entry=64 */ + /* hash_tag_id=2, max_pkr=15 */ + /* key_size=24, phys_add_size=50, vw=1 */ + movl r10=0x183C /* rid_size=24, impl_va_msb=60 */ + ;; +1: cmp.eq p6,p7=PAL_MEM_ATTRIB,r28 +(p7) br.cond.sptk.few 1f + mov r8=0 /* status = 0 */ + mov r9=0x80|0x01 /* NatPage|WB */ + ;; 1: br.cond.sptk.few rp stacked: br.ret.sptk.few rp -- cgit v0.10.2 From 714d2dc14914f0f7bb008effe830c99eb47c75df Mon Sep 17 00:00:00 2001 From: Peter Chubb Date: Thu, 25 Aug 2005 17:39:00 -0700 Subject: [IA64] Allow /proc/pal/cpu0/vm_info under the simulator Not all of the PAL VM calls are implemented for the SKI simulator. Don't just give up if one fails, print information from the calls that succeed. Signed-off-by: Peter Chubb Signed-off-by: Tony Luck diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c index 25e7c83..89faa60 100644 --- a/arch/ia64/kernel/palinfo.c +++ b/arch/ia64/kernel/palinfo.c @@ -307,11 +307,9 @@ vm_info(char *page) if ((status = ia64_pal_vm_summary(&vm_info_1, &vm_info_2)) !=0) { printk(KERN_ERR "ia64_pal_vm_summary=%ld\n", status); - return 0; - } + } else { - - p += sprintf(p, + p += sprintf(p, "Physical Address Space : %d bits\n" "Virtual Address Space : %d bits\n" "Protection Key Registers(PKR) : %d\n" @@ -319,92 +317,99 @@ vm_info(char *page) "Hash Tag ID : 0x%x\n" "Size of RR.rid : %d\n", vm_info_1.pal_vm_info_1_s.phys_add_size, - vm_info_2.pal_vm_info_2_s.impl_va_msb+1, vm_info_1.pal_vm_info_1_s.max_pkr+1, - vm_info_1.pal_vm_info_1_s.key_size, vm_info_1.pal_vm_info_1_s.hash_tag_id, + vm_info_2.pal_vm_info_2_s.impl_va_msb+1, + vm_info_1.pal_vm_info_1_s.max_pkr+1, + vm_info_1.pal_vm_info_1_s.key_size, + vm_info_1.pal_vm_info_1_s.hash_tag_id, vm_info_2.pal_vm_info_2_s.rid_size); + } - if (ia64_pal_mem_attrib(&attrib) != 0) - return 0; - - p += sprintf(p, "Supported memory attributes : "); - sep = ""; - for (i = 0; i < 8; i++) { - if (attrib & (1 << i)) { - p += sprintf(p, "%s%s", sep, mem_attrib[i]); - sep = ", "; + if (ia64_pal_mem_attrib(&attrib) == 0) { + p += sprintf(p, "Supported memory attributes : "); + sep = ""; + for (i = 0; i < 8; i++) { + if (attrib & (1 << i)) { + p += sprintf(p, "%s%s", sep, mem_attrib[i]); + sep = ", "; + } } + p += sprintf(p, "\n"); } - p += sprintf(p, "\n"); if ((status = ia64_pal_vm_page_size(&tr_pages, &vw_pages)) !=0) { printk(KERN_ERR "ia64_pal_vm_page_size=%ld\n", status); - return 0; - } - - p += sprintf(p, - "\nTLB walker : %simplemented\n" - "Number of DTR : %d\n" - "Number of ITR : %d\n" - "TLB insertable page sizes : ", - vm_info_1.pal_vm_info_1_s.vw ? "" : "not ", - vm_info_1.pal_vm_info_1_s.max_dtr_entry+1, - vm_info_1.pal_vm_info_1_s.max_itr_entry+1); + } else { + p += sprintf(p, + "\nTLB walker : %simplemented\n" + "Number of DTR : %d\n" + "Number of ITR : %d\n" + "TLB insertable page sizes : ", + vm_info_1.pal_vm_info_1_s.vw ? "" : "not ", + vm_info_1.pal_vm_info_1_s.max_dtr_entry+1, + vm_info_1.pal_vm_info_1_s.max_itr_entry+1); - p = bitvector_process(p, tr_pages); - p += sprintf(p, "\nTLB purgeable page sizes : "); + p = bitvector_process(p, tr_pages); - p = bitvector_process(p, vw_pages); + p += sprintf(p, "\nTLB purgeable page sizes : "); + p = bitvector_process(p, vw_pages); + } if ((status=ia64_get_ptce(&ptce)) != 0) { printk(KERN_ERR "ia64_get_ptce=%ld\n", status); - return 0; - } - - p += sprintf(p, + } else { + p += sprintf(p, "\nPurge base address : 0x%016lx\n" "Purge outer loop count : %d\n" "Purge inner loop count : %d\n" "Purge outer loop stride : %d\n" "Purge inner loop stride : %d\n", - ptce.base, ptce.count[0], ptce.count[1], ptce.stride[0], ptce.stride[1]); + ptce.base, ptce.count[0], ptce.count[1], + ptce.stride[0], ptce.stride[1]); - p += sprintf(p, + p += sprintf(p, "TC Levels : %d\n" "Unique TC(s) : %d\n", vm_info_1.pal_vm_info_1_s.num_tc_levels, vm_info_1.pal_vm_info_1_s.max_unique_tcs); - for(i=0; i < vm_info_1.pal_vm_info_1_s.num_tc_levels; i++) { - for (j=2; j>0 ; j--) { - tc_pages = 0; /* just in case */ + for(i=0; i < vm_info_1.pal_vm_info_1_s.num_tc_levels; i++) { + for (j=2; j>0 ; j--) { + tc_pages = 0; /* just in case */ - /* even without unification, some levels may not be present */ - if ((status=ia64_pal_vm_info(i,j, &tc_info, &tc_pages)) != 0) { - continue; - } + /* even without unification, some levels may not be present */ + if ((status=ia64_pal_vm_info(i,j, &tc_info, &tc_pages)) != 0) { + continue; + } - p += sprintf(p, + p += sprintf(p, "\n%s Translation Cache Level %d:\n" "\tHash sets : %d\n" "\tAssociativity : %d\n" "\tNumber of entries : %d\n" "\tFlags : ", - cache_types[j+tc_info.tc_unified], i+1, tc_info.tc_num_sets, - tc_info.tc_associativity, tc_info.tc_num_entries); + cache_types[j+tc_info.tc_unified], i+1, + tc_info.tc_num_sets, + tc_info.tc_associativity, + tc_info.tc_num_entries); - if (tc_info.tc_pf) p += sprintf(p, "PreferredPageSizeOptimized "); - if (tc_info.tc_unified) p += sprintf(p, "Unified "); - if (tc_info.tc_reduce_tr) p += sprintf(p, "TCReduction"); + if (tc_info.tc_pf) + p += sprintf(p, "PreferredPageSizeOptimized "); + if (tc_info.tc_unified) + p += sprintf(p, "Unified "); + if (tc_info.tc_reduce_tr) + p += sprintf(p, "TCReduction"); - p += sprintf(p, "\n\tSupported page sizes: "); + p += sprintf(p, "\n\tSupported page sizes: "); - p = bitvector_process(p, tc_pages); + p = bitvector_process(p, tc_pages); - /* when unified date (j=2) is enough */ - if (tc_info.tc_unified) break; + /* when unified date (j=2) is enough */ + if (tc_info.tc_unified) + break; + } } } p += sprintf(p, "\n"); @@ -440,14 +445,14 @@ register_info(char *page) p += sprintf(p, "\n"); } - if (ia64_pal_rse_info(&phys_stacked, &hints) != 0) return 0; + if (ia64_pal_rse_info(&phys_stacked, &hints) == 0) { p += sprintf(p, "RSE stacked physical registers : %ld\n" "RSE load/store hints : %ld (%s)\n", phys_stacked, hints.ph_data, hints.ph_data < RSE_HINTS_COUNT ? rse_hints[hints.ph_data]: "(??)"); - + } if (ia64_pal_debug_info(&iregs, &dregs)) return 0; -- cgit v0.10.2 From 6cf07a8cc86a0b471466c7fe45892f7ef434015b Mon Sep 17 00:00:00 2001 From: Peter Chubb Date: Tue, 23 Aug 2005 20:07:00 -0700 Subject: [IA64] Fix nasty VMLPT problem... I've solved the problem I was having with the simulator and not booting Debian. The problem is that the number of bits for the virtual linear array short-format VHPT (Virtually mapped linear page table, VMLPT for short) is being tested incorrectly. There are two problems: 1. The PAL call that should tell the kernel the size of the virtual address space isn't implemented for the simulator, so the kernel uses the default 50. This is addressed separately in dc90e95f310f4f821c905b2aec8e9449bb3270fa 2. In arch/ia64/mm/init.c there's code to calcualte the size of the VMLPT based on the number of implemented virtual address bits and the page size. It checks to see if the VMLPT base address overlaps the top of the mapped region, but this check doesn't allow for the address space hole, and in fact will never trigger. Here's an alternative test and panic, that I think is more accurate. Signed-off-by: Peter Chubb Signed-off-by: Tony Luck diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index 65f9958..1281c60 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c @@ -382,13 +382,22 @@ ia64_mmu_init (void *my_cpu_data) if (impl_va_bits < 51 || impl_va_bits > 61) panic("CPU has bogus IMPL_VA_MSB value of %lu!\n", impl_va_bits - 1); + /* + * mapped_space_bits - PAGE_SHIFT is the total number of ptes we need, + * which must fit into "vmlpt_bits - pte_bits" slots. Second half of + * the test makes sure that our mapped space doesn't overlap the + * unimplemented hole in the middle of the region. + */ + if ((mapped_space_bits - PAGE_SHIFT > vmlpt_bits - pte_bits) || + (mapped_space_bits > impl_va_bits - 1)) + panic("Cannot build a big enough virtual-linear page table" + " to cover mapped address space.\n" + " Try using a smaller page size.\n"); + /* place the VMLPT at the end of each page-table mapped region: */ pta = POW2(61) - POW2(vmlpt_bits); - if (POW2(mapped_space_bits) >= pta) - panic("mm/init: overlap between virtually mapped linear page table and " - "mapped kernel space!"); /* * Set the (virtually mapped linear) page table address. Bit * 8 selects between the short and long format, bits 2-7 the -- cgit v0.10.2 From a1cddb88920b915eaba10712ecfd0fc698b00a22 Mon Sep 17 00:00:00 2001 From: Jack Steiner Date: Wed, 31 Aug 2005 08:05:00 -0700 Subject: [IA64-SGI] Add new vendor-specific SAL calls for: - notifying the PROM of specific features that are supported by the OS. This is used to enable PROM feature if and only if the corresponding feature is implemented in the OS - fetch feature sets that are supported by the current PROM. This allows the OS to selectively enable features when the PROM support is available. Signed-off-by: Jack Steiner Signed-off-by: Tony Luck diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c index 7c7fe44..981928f 100644 --- a/arch/ia64/sn/kernel/setup.c +++ b/arch/ia64/sn/kernel/setup.c @@ -49,6 +49,7 @@ #include #include #include +#include #include "xtalk/xwidgetdev.h" #include "xtalk/hubdev.h" #include @@ -99,6 +100,7 @@ EXPORT_SYMBOL(sn_region_size); int sn_prom_type; /* 0=hardware, 1=medusa/realprom, 2=medusa/fakeprom */ short physical_node_map[MAX_PHYSNODE_ID]; +static unsigned long sn_prom_features[MAX_PROM_FEATURE_SETS]; EXPORT_SYMBOL(physical_node_map); @@ -273,7 +275,10 @@ void __init sn_setup(char **cmdline_p) u32 version = sn_sal_rev(); extern void sn_cpu_init(void); - ia64_sn_plat_set_error_handling_features(); + ia64_sn_plat_set_error_handling_features(); // obsolete + ia64_sn_set_os_feature(OSF_MCA_SLV_TO_OS_INIT_SLV); + ia64_sn_set_os_feature(OSF_FEAT_LOG_SBES); + #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) /* @@ -316,16 +321,6 @@ void __init sn_setup(char **cmdline_p) printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF); - /* - * Confirm the SAL we're running on is recent enough... - */ - if (version < SN_SAL_MIN_VERSION) { - printk(KERN_ERR "This kernel needs SGI SAL version >= " - "%x.%02x\n", SN_SAL_MIN_VERSION >> 8, - SN_SAL_MIN_VERSION & 0x00FF); - panic("PROM version too old\n"); - } - master_nasid = boot_get_nasid(); status = @@ -481,6 +476,10 @@ void __init sn_cpu_init(void) if (nodepdaindr[0] == NULL) return; + for (i = 0; i < MAX_PROM_FEATURE_SETS; i++) + if (ia64_sn_get_prom_feature_set(i, &sn_prom_features[i]) != 0) + break; + cpuid = smp_processor_id(); cpuphyid = get_sapicid(); @@ -652,3 +651,12 @@ nasid_slice_to_cpuid(int nasid, int slice) return -1; } + +int sn_prom_feature_available(int id) +{ + if (id >= BITS_PER_LONG * MAX_PROM_FEATURE_SETS) + return 0; + return test_bit(id, sn_prom_features); +} +EXPORT_SYMBOL(sn_prom_feature_available); + diff --git a/include/asm-ia64/sn/sn_feature_sets.h b/include/asm-ia64/sn/sn_feature_sets.h new file mode 100644 index 0000000..e68a808 --- /dev/null +++ b/include/asm-ia64/sn/sn_feature_sets.h @@ -0,0 +1,57 @@ +#ifndef _ASM_IA64_SN_FEATURE_SETS_H +#define _ASM_IA64_SN_FEATURE_SETS_H + +/* + * SN PROM Features + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (c) 2005 Silicon Graphics, Inc. All rights reserved. + */ + + +#include +#include + +/* --------------------- PROM Features -----------------------------*/ +extern int sn_prom_feature_available(int id); + +#define MAX_PROM_FEATURE_SETS 2 + +/* + * The following defines features that may or may not be supported by the + * current PROM. The OS uses sn_prom_feature_available(feature) to test for + * the presence of a PROM feature. Down rev (old) PROMs will always test + * "false" for new features. + * + * Use: + * if (sn_prom_feature_available(PRF_FEATURE_XXX)) + * ... + */ + +/* + * Example: feature XXX + */ +#define PRF_FEATURE_XXX 0 + + + +/* --------------------- OS Features -------------------------------*/ + +/* + * The following defines OS features that are optionally present in + * the operating system. + * During boot, PROM is notified of these features via a series of calls: + * + * ia64_sn_set_os_feature(feature1); + * + * Once enabled, a feature cannot be disabled. + * + * By default, features are disabled unless explicitly enabled. + */ +#define OSF_MCA_SLV_TO_OS_INIT_SLV 0 +#define OSF_FEAT_LOG_SBES 1 + +#endif /* _ASM_IA64_SN_FEATURE_SETS_H */ diff --git a/include/asm-ia64/sn/sn_sal.h b/include/asm-ia64/sn/sn_sal.h index 27976d2..231d0d0 100644 --- a/include/asm-ia64/sn/sn_sal.h +++ b/include/asm-ia64/sn/sn_sal.h @@ -80,6 +80,9 @@ #define SN_SAL_BTE_RECOVER 0x02000061 #define SN_SAL_IOIF_GET_PCI_TOPOLOGY 0x02000062 +#define SN_SAL_GET_PROM_FEATURE_SET 0x02000065 +#define SN_SAL_SET_OS_FEATURE_SET 0x02000066 + /* * Service-specific constants */ @@ -118,8 +121,8 @@ /* * Error Handling Features */ -#define SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV 0x1 -#define SAL_ERR_FEAT_LOG_SBES 0x2 +#define SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV 0x1 // obsolete +#define SAL_ERR_FEAT_LOG_SBES 0x2 // obsolete #define SAL_ERR_FEAT_MFR_OVERRIDE 0x4 #define SAL_ERR_FEAT_SBE_THRESHOLD 0xffff0000 @@ -152,12 +155,6 @@ sn_sal_rev(void) } /* - * Specify the minimum PROM revsion required for this kernel. - * Note that they're stored in hex format... - */ -#define SN_SAL_MIN_VERSION 0x0404 - -/* * Returns the master console nasid, if the call fails, return an illegal * value. */ @@ -336,7 +333,7 @@ ia64_sn_plat_cpei_handler(void) } /* - * Set Error Handling Features + * Set Error Handling Features (Obsolete) */ static inline u64 ia64_sn_plat_set_error_handling_features(void) @@ -1100,4 +1097,25 @@ ia64_sn_is_fake_prom(void) return (rv.status == 0); } +static inline int +ia64_sn_get_prom_feature_set(int set, unsigned long *feature_set) +{ + struct ia64_sal_retval rv; + + SAL_CALL_NOLOCK(rv, SN_SAL_GET_PROM_FEATURE_SET, set, 0, 0, 0, 0, 0, 0); + if (rv.status != 0) + return rv.status; + *feature_set = rv.v0; + return 0; +} + +static inline int +ia64_sn_set_os_feature(int feature) +{ + struct ia64_sal_retval rv; + + SAL_CALL_NOLOCK(rv, SN_SAL_SET_OS_FEATURE_SET, feature, 0, 0, 0, 0, 0, 0); + return rv.status; +} + #endif /* _ASM_IA64_SN_SN_SAL_H */ -- cgit v0.10.2 From 4fbd1514173a80f9dc93e8ebbd6d4eb97cee123e Mon Sep 17 00:00:00 2001 From: Yann Droneaud Date: Tue, 7 Jun 2005 16:54:01 +0200 Subject: [ACPI] check acpi_disabled in IPMI Signed-off-by: Yann Droneaud Signed-off-by: Len Brown diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index c51b02d..adbec73 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -1484,6 +1484,9 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info) char *io_type; u8 addr_space; + if (acpi_disabled) + return -ENODEV; + if (acpi_failure) return -ENODEV; -- cgit v0.10.2 From 8813dfbfc56b3f7c369b3115c2f70bcacd77ec51 Mon Sep 17 00:00:00 2001 From: "Alexey Y. Starikovskiy" Date: Thu, 25 Aug 2005 09:56:52 +0400 Subject: [ACPI] Error: Invalid owner_id: 00 Signed-off-by: Alexey Y. Starikovskiy Signed-off-by: Len Brown diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 77fcfc3..8b67a91 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c @@ -235,6 +235,16 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, acpi_ex_system_wait_semaphore(obj_desc->method.semaphore, ACPI_WAIT_FOREVER); } + /* + * allocate owner id for this method + */ + if (!obj_desc->method.thread_count) { + status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); + } + } + /* * Increment the method parse tree thread count since it has been @@ -289,11 +299,6 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, return_ACPI_STATUS(AE_NULL_OBJECT); } - status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - /* Init for new method, wait on concurrency semaphore */ status = acpi_ds_begin_method_execution(method_node, obj_desc, @@ -380,22 +385,18 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { status = obj_desc->method.implementation(next_walk_state); - return_ACPI_STATUS(status); } + goto end; - return_ACPI_STATUS(AE_OK); - - /* On error, we must delete the new walk state */ - - cleanup: - acpi_ut_release_owner_id(&obj_desc->method.owner_id); +cleanup: + /* Decrement the thread count on the method parse tree */ if (next_walk_state && (next_walk_state->method_desc)) { - /* Decrement the thread count on the method parse tree */ - next_walk_state->method_desc->method.thread_count--; } - (void)acpi_ds_terminate_control_method(next_walk_state); - acpi_ds_delete_walk_state(next_walk_state); + /* On error, we must delete the new walk state */ + acpi_ds_terminate_control_method (next_walk_state); + acpi_ds_delete_walk_state (next_walk_state); +end: return_ACPI_STATUS(status); } @@ -479,7 +480,7 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, * * PARAMETERS: walk_state - State of the method * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Terminate a control method. Delete everything that the method * created, delete all locals and arguments, and delete the parse @@ -487,7 +488,7 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, * ******************************************************************************/ -acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) +void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) { union acpi_operand_object *obj_desc; struct acpi_namespace_node *method_node; @@ -496,14 +497,14 @@ acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) ACPI_FUNCTION_TRACE_PTR("ds_terminate_control_method", walk_state); if (!walk_state) { - return (AE_BAD_PARAMETER); + return_VOID; } /* The current method object was saved in the walk state */ obj_desc = walk_state->method_desc; if (!obj_desc) { - return_ACPI_STATUS(AE_OK); + return_VOID; } /* Delete all arguments and locals */ @@ -517,7 +518,7 @@ acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) */ status = acpi_ut_acquire_mutex(ACPI_MTX_PARSER); if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); + return_VOID; } /* Signal completion of the execution of this method if necessary */ @@ -574,7 +575,7 @@ acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) */ status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); + goto cleanup; } if (method_node->child) { @@ -592,10 +593,9 @@ acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) owner_id); if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); + goto cleanup; } } - - status = acpi_ut_release_mutex(ACPI_MTX_PARSER); - return_ACPI_STATUS(status); +cleanup: + acpi_ut_release_mutex (ACPI_MTX_PARSER); } diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index 3248051..3677130 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c @@ -438,7 +438,6 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) { acpi_status status; - acpi_status terminate_status; struct acpi_thread_state *thread; struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list; struct acpi_walk_state *previous_walk_state; @@ -508,6 +507,9 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) walk_state->method_node, NULL, status); + /* Make sure that failed method will be cleaned as if it was executed */ + walk_state->parse_flags |= ACPI_PARSE_EXECUTE; + /* Check for possible multi-thread reentrancy problem */ if ((status == AE_ALREADY_EXISTS) && @@ -524,14 +526,6 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) } } - if (walk_state->method_desc) { - /* Decrement the thread count on the method parse tree */ - - if (walk_state->method_desc->method.thread_count) { - walk_state->method_desc->method.thread_count--; - } - } - /* We are done with this walk, move on to the parent if any */ walk_state = acpi_ds_pop_walk_state(thread); @@ -546,13 +540,10 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) */ if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) { - terminate_status = - acpi_ds_terminate_control_method(walk_state); - if (ACPI_FAILURE(terminate_status)) { - ACPI_REPORT_ERROR(("Could not terminate control method properly\n")); - - /* Ignore error and continue */ + if (walk_state->method_desc) { + walk_state->method_desc->method.thread_count--; } + acpi_ds_terminate_control_method (walk_state); } /* Delete this walk state and all linked control states */ diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c index 80c67f2..f6904bd 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -99,16 +99,6 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info) } /* - * Get a new owner_id for objects created by this method. Namespace - * objects (such as Operation Regions) can be created during the - * first pass parse. - */ - status = acpi_ut_allocate_owner_id(&info->obj_desc->method.owner_id); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - /* * The caller "owns" the parameters, so give each one an extra * reference */ @@ -139,9 +129,6 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info) status = acpi_ps_execute_pass(info); cleanup: - if (info->obj_desc->method.owner_id) { - acpi_ut_release_owner_id(&info->obj_desc->method.owner_id); - } /* Take away the extra reference that we gave the parameters above */ diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index f027502..c2f5b2a 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -67,6 +67,8 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) ACPI_FUNCTION_TRACE("ut_allocate_owner_id"); + WARN_ON(*owner_id); + /* Mutex for the global ID mask */ status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h index 5930618..c436e8b 100644 --- a/include/acpi/acdispat.h +++ b/include/acpi/acdispat.h @@ -194,7 +194,7 @@ acpi_status acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, union acpi_operand_object *return_desc); -acpi_status +void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state); acpi_status -- cgit v0.10.2 From 8085e1f1f0645fc6ddefcb54fdcba95808df5049 Mon Sep 17 00:00:00 2001 From: Venkatesh Pallipadi Date: Thu, 25 Aug 2005 13:14:06 -0700 Subject: [CPUFREQ] Bugfix: Call driver exit in cpufreq_add_dev error path A minor fix for cpufreq_add_dev() error path. We need to call driver->exit() if driver_init() call has succeeded. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Dave Jones diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 10b0149..109d62c 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -627,7 +627,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) ret = kobject_register(&policy->kobj); if (ret) - goto err_out; + goto err_out_driver_exit; /* set up files for this cpu device */ drv_attr = cpufreq_driver->attr; @@ -673,6 +673,10 @@ err_out_unregister: kobject_unregister(&policy->kobj); wait_for_completion(&policy->kobj_unregister); +err_out_driver_exit: + if (cpufreq_driver->exit) + cpufreq_driver->exit(policy); + err_out: kfree(policy); -- cgit v0.10.2 From f914be79ab2144efe291d9fc383661e0e23dca44 Mon Sep 17 00:00:00 2001 From: Venkatesh Pallipadi Date: Mon, 29 Aug 2005 13:54:55 -0700 Subject: [CPUFREQ] speedstep-centrino: skip extract_clock logic for acpi based centrino speedstep_centrino.c:extract_clock() assumes the bus speed of 100MHz, which is not true with latest laptops. Due to this assumption and due to the encoded frequency check during initialization, speedstep-centrino driver fails even on systems that has proper ACPI information to do the P-state transition. The change below moves the centrino-speedstep detection to be used only when table based P-state transition is done. For ACPI based P-state transition, we skip the centrino_cpu identification, and as a result we don't use the bus speed assumption in extract_clock. This change makes speedstep-centrino work on Pentium-M based systems, which have more than 100MHz bus speed. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Dave Jones diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c index 327a55d..95e15b7 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c @@ -498,13 +498,6 @@ static int centrino_cpu_init(struct cpufreq_policy *policy) if (cpu->x86_vendor != X86_VENDOR_INTEL || !cpu_has(cpu, X86_FEATURE_EST)) return -ENODEV; - for (i = 0; i < N_IDS; i++) - if (centrino_verify_cpu_id(cpu, &cpu_ids[i])) - break; - - if (i != N_IDS) - centrino_cpu[policy->cpu] = &cpu_ids[i]; - if (is_const_loops_cpu(policy->cpu)) { centrino_driver.flags |= CPUFREQ_CONST_LOOPS; } @@ -513,6 +506,13 @@ static int centrino_cpu_init(struct cpufreq_policy *policy) if (policy->cpu != 0) return -ENODEV; + for (i = 0; i < N_IDS; i++) + if (centrino_verify_cpu_id(cpu, &cpu_ids[i])) + break; + + if (i != N_IDS) + centrino_cpu[policy->cpu] = &cpu_ids[i]; + if (!centrino_cpu[policy->cpu]) { dprintk(KERN_INFO PFX "found unsupported CPU with " "Enhanced SpeedStep: send /proc/cpuinfo to " -- cgit v0.10.2 From 123411f2d0da5c42eb9ee0912b6e824cbe88a411 Mon Sep 17 00:00:00 2001 From: Mika Kukkonen Date: Sun, 7 Aug 2005 23:13:00 +0300 Subject: [CPUFREQ] dprintf format fixes in cpufreq/speedstep-centrino.c Ho-hum, did not notice there was more printf fixes for cpufreq (you should see the amount I have for isdn and reiser ...). Sorry for noise. Signed-off-by: Mika Kukkonen Signed-off-by: Dave Jones diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c index 95e15b7..e70f9b2 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c @@ -402,7 +402,7 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy) for (i=0; i p.states[0].core_frequency) { - dprintk("P%u has larger frequency (%u) than P0 (%u), skipping\n", i, + dprintk("P%u has larger frequency (%llu) than P0 (%llu), skipping\n", i, p.states[i].core_frequency, p.states[0].core_frequency); p.states[i].core_frequency = 0; continue; -- cgit v0.10.2 From ce38b51edfe51abacb053e88d62cf96a0c003a04 Mon Sep 17 00:00:00 2001 From: Mika Kukkonen Date: Sun, 7 Aug 2005 22:49:39 +0300 Subject: [CPUFREQ] Remove extra arg from dprintk in cpufreq/speedstep-smi.c Minor fallout from my upcoming __attribute__((format(printf,x,y))) patches. The variable 'result' is untouched, so this patch just removes it. Signed-off-by: Mika Kukkonen Signed-off-by: Dave Jones diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c index b25fb6b..2718fb6 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c @@ -99,7 +99,7 @@ static int speedstep_smi_get_freqs (unsigned int *low, unsigned int *high) u32 function = GET_SPEEDSTEP_FREQS; if (!(ist_info.event & 0xFFFF)) { - dprintk("bug #1422 -- can't read freqs from BIOS\n", result); + dprintk("bug #1422 -- can't read freqs from BIOS\n"); return -ENODEV; } -- cgit v0.10.2 From 4f4b401bfaa97edbea41a1fcab794148e7ac0421 Mon Sep 17 00:00:00 2001 From: Dave Kleikamp Date: Thu, 1 Sep 2005 09:02:43 -0500 Subject: JFS: allow extended attributes to be set within a existing transaction Signed-off-by: Dave Kleikamp diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c index e892dab..461e493 100644 --- a/fs/jfs/acl.c +++ b/fs/jfs/acl.c @@ -23,6 +23,7 @@ #include #include #include "jfs_incore.h" +#include "jfs_txnmgr.h" #include "jfs_xattr.h" #include "jfs_acl.h" @@ -75,7 +76,8 @@ static struct posix_acl *jfs_get_acl(struct inode *inode, int type) return acl; } -static int jfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) +static int jfs_set_acl(tid_t tid, struct inode *inode, int type, + struct posix_acl *acl) { char *ea_name; struct jfs_inode_info *ji = JFS_IP(inode); @@ -110,7 +112,7 @@ static int jfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) if (rc < 0) goto out; } - rc = __jfs_setxattr(inode, ea_name, value, size, 0); + rc = __jfs_setxattr(tid, inode, ea_name, value, size, 0); out: kfree(value); @@ -143,7 +145,7 @@ int jfs_permission(struct inode *inode, int mask, struct nameidata *nd) return generic_permission(inode, mask, jfs_check_acl); } -int jfs_init_acl(struct inode *inode, struct inode *dir) +int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir) { struct posix_acl *acl = NULL; struct posix_acl *clone; @@ -159,7 +161,7 @@ int jfs_init_acl(struct inode *inode, struct inode *dir) if (acl) { if (S_ISDIR(inode->i_mode)) { - rc = jfs_set_acl(inode, ACL_TYPE_DEFAULT, acl); + rc = jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, acl); if (rc) goto cleanup; } @@ -173,7 +175,8 @@ int jfs_init_acl(struct inode *inode, struct inode *dir) if (rc >= 0) { inode->i_mode = mode; if (rc > 0) - rc = jfs_set_acl(inode, ACL_TYPE_ACCESS, clone); + rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, + clone); } posix_acl_release(clone); cleanup: @@ -202,8 +205,15 @@ static int jfs_acl_chmod(struct inode *inode) return -ENOMEM; rc = posix_acl_chmod_masq(clone, inode->i_mode); - if (!rc) - rc = jfs_set_acl(inode, ACL_TYPE_ACCESS, clone); + if (!rc) { + tid_t tid = txBegin(inode->i_sb, 0); + down(&JFS_IP(inode)->commit_sem); + rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, clone); + if (!rc) + rc = txCommit(tid, 1, &inode, 0); + txEnd(tid); + up(&JFS_IP(inode)->commit_sem); + } posix_acl_release(clone); return rc; diff --git a/fs/jfs/jfs_acl.h b/fs/jfs/jfs_acl.h index a3acd3e..a7629376 100644 --- a/fs/jfs/jfs_acl.h +++ b/fs/jfs/jfs_acl.h @@ -21,8 +21,16 @@ #ifdef CONFIG_JFS_POSIX_ACL int jfs_permission(struct inode *, int, struct nameidata *); -int jfs_init_acl(struct inode *, struct inode *); +int jfs_init_acl(tid_t, struct inode *, struct inode *); int jfs_setattr(struct dentry *, struct iattr *); -#endif /* CONFIG_JFS_POSIX_ACL */ +#else + +static inline int jfs_init_acl(tid_t tid, struct inode *inode, + struct inode *dir) +{ + return 0; +} + +#endif #endif /* _H_JFS_ACL */ diff --git a/fs/jfs/jfs_xattr.h b/fs/jfs/jfs_xattr.h index a1052f3..116a73c 100644 --- a/fs/jfs/jfs_xattr.h +++ b/fs/jfs/jfs_xattr.h @@ -52,8 +52,8 @@ struct jfs_ea_list { #define END_EALIST(ealist) \ ((struct jfs_ea *) (((char *) (ealist)) + EALIST_SIZE(ealist))) -extern int __jfs_setxattr(struct inode *, const char *, const void *, size_t, - int); +extern int __jfs_setxattr(tid_t, struct inode *, const char *, const void *, + size_t, int); extern int jfs_setxattr(struct dentry *, const char *, const void *, size_t, int); extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t); diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 49ccde3..f23f9c2 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -39,6 +39,24 @@ struct dentry_operations jfs_ci_dentry_operations; static s64 commitZeroLink(tid_t, struct inode *); /* + * NAME: free_ea_wmap(inode) + * + * FUNCTION: free uncommitted extended attributes from working map + * + */ +static inline void free_ea_wmap(struct inode *inode) +{ + dxd_t *ea = &JFS_IP(inode)->ea; + + if (ea->flag & DXD_EXTENT) { + /* free EA pages from cache */ + invalidate_dxd_metapages(inode, *ea); + dbFree(inode, addressDXD(ea), lengthDXD(ea)); + } + ea->flag = 0; +} + +/* * NAME: jfs_create(dip, dentry, mode) * * FUNCTION: create a regular file in the parent directory @@ -89,8 +107,13 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, down(&JFS_IP(dip)->commit_sem); down(&JFS_IP(ip)->commit_sem); + rc = jfs_init_acl(tid, ip, dip); + if (rc) + goto out3; + if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { jfs_err("jfs_create: dtSearch returned %d", rc); + txAbort(tid, 0); goto out3; } @@ -139,6 +162,7 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, up(&JFS_IP(dip)->commit_sem); up(&JFS_IP(ip)->commit_sem); if (rc) { + free_ea_wmap(ip); ip->i_nlink = 0; iput(ip); } else @@ -147,11 +171,6 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, out2: free_UCSname(&dname); -#ifdef CONFIG_JFS_POSIX_ACL - if (rc == 0) - jfs_init_acl(ip, dip); -#endif - out1: jfs_info("jfs_create: rc:%d", rc); @@ -216,8 +235,13 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) down(&JFS_IP(dip)->commit_sem); down(&JFS_IP(ip)->commit_sem); + rc = jfs_init_acl(tid, ip, dip); + if (rc) + goto out3; + if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { jfs_err("jfs_mkdir: dtSearch returned %d", rc); + txAbort(tid, 0); goto out3; } @@ -267,6 +291,7 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) up(&JFS_IP(dip)->commit_sem); up(&JFS_IP(ip)->commit_sem); if (rc) { + free_ea_wmap(ip); ip->i_nlink = 0; iput(ip); } else @@ -275,10 +300,6 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) out2: free_UCSname(&dname); -#ifdef CONFIG_JFS_POSIX_ACL - if (rc == 0) - jfs_init_acl(ip, dip); -#endif out1: @@ -1000,6 +1021,7 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, up(&JFS_IP(dip)->commit_sem); up(&JFS_IP(ip)->commit_sem); if (rc) { + free_ea_wmap(ip); ip->i_nlink = 0; iput(ip); } else @@ -1008,11 +1030,6 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, out2: free_UCSname(&dname); -#ifdef CONFIG_JFS_POSIX_ACL - if (rc == 0) - jfs_init_acl(ip, dip); -#endif - out1: jfs_info("jfs_symlink: rc:%d", rc); return rc; @@ -1328,17 +1345,25 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, down(&JFS_IP(dir)->commit_sem); down(&JFS_IP(ip)->commit_sem); - if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) + rc = jfs_init_acl(tid, ip, dir); + if (rc) goto out3; + if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) { + txAbort(tid, 0); + goto out3; + } + tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_CREATE; tblk->ino = ip->i_ino; tblk->u.ixpxd = JFS_IP(ip)->ixpxd; ino = ip->i_ino; - if ((rc = dtInsert(tid, dir, &dname, &ino, &btstack))) + if ((rc = dtInsert(tid, dir, &dname, &ino, &btstack))) { + txAbort(tid, 0); goto out3; + } ip->i_op = &jfs_file_inode_operations; jfs_ip->dev = new_encode_dev(rdev); @@ -1360,6 +1385,7 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, up(&JFS_IP(ip)->commit_sem); up(&JFS_IP(dir)->commit_sem); if (rc) { + free_ea_wmap(ip); ip->i_nlink = 0; iput(ip); } else @@ -1368,11 +1394,6 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, out1: free_UCSname(&dname); -#ifdef CONFIG_JFS_POSIX_ACL - if (rc == 0) - jfs_init_acl(ip, dir); -#endif - out: jfs_info("jfs_mknod: returning %d", rc); return rc; diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c index 554ec73..35674b2 100644 --- a/fs/jfs/xattr.c +++ b/fs/jfs/xattr.c @@ -633,12 +633,12 @@ static void ea_release(struct inode *inode, struct ea_buffer *ea_buf) } } -static int ea_put(struct inode *inode, struct ea_buffer *ea_buf, int new_size) +static int ea_put(tid_t tid, struct inode *inode, struct ea_buffer *ea_buf, + int new_size) { struct jfs_inode_info *ji = JFS_IP(inode); unsigned long old_blocks, new_blocks; int rc = 0; - tid_t tid; if (new_size == 0) { ea_release(inode, ea_buf); @@ -664,9 +664,6 @@ static int ea_put(struct inode *inode, struct ea_buffer *ea_buf, int new_size) if (rc) return rc; - tid = txBegin(inode->i_sb, 0); - down(&ji->commit_sem); - old_blocks = new_blocks = 0; if (ji->ea.flag & DXD_EXTENT) { @@ -695,11 +692,8 @@ static int ea_put(struct inode *inode, struct ea_buffer *ea_buf, int new_size) DQUOT_FREE_BLOCK(inode, old_blocks); inode->i_ctime = CURRENT_TIME; - rc = txCommit(tid, 1, &inode, 0); - txEnd(tid); - up(&ji->commit_sem); - return rc; + return 0; } /* @@ -810,8 +804,8 @@ static int can_set_xattr(struct inode *inode, const char *name, return permission(inode, MAY_WRITE, NULL); } -int __jfs_setxattr(struct inode *inode, const char *name, const void *value, - size_t value_len, int flags) +int __jfs_setxattr(tid_t tid, struct inode *inode, const char *name, + const void *value, size_t value_len, int flags) { struct jfs_ea_list *ealist; struct jfs_ea *ea, *old_ea = NULL, *next_ea = NULL; @@ -825,9 +819,6 @@ int __jfs_setxattr(struct inode *inode, const char *name, const void *value, int rc; int length; - if ((rc = can_set_xattr(inode, name, value, value_len))) - return rc; - if (strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) { os2name = kmalloc(namelen - XATTR_OS2_PREFIX_LEN + 1, GFP_KERNEL); @@ -939,7 +930,7 @@ int __jfs_setxattr(struct inode *inode, const char *name, const void *value, ealist->size = cpu_to_le32(new_size); - rc = ea_put(inode, &ea_buf, new_size); + rc = ea_put(tid, inode, &ea_buf, new_size); goto out; release: @@ -955,12 +946,29 @@ int __jfs_setxattr(struct inode *inode, const char *name, const void *value, int jfs_setxattr(struct dentry *dentry, const char *name, const void *value, size_t value_len, int flags) { + struct inode *inode = dentry->d_inode; + struct jfs_inode_info *ji = JFS_IP(inode); + int rc; + tid_t tid; + + if ((rc = can_set_xattr(inode, name, value, value_len))) + return rc; + if (value == NULL) { /* empty EA, do not remove */ value = ""; value_len = 0; } - return __jfs_setxattr(dentry->d_inode, name, value, value_len, flags); + tid = txBegin(inode->i_sb, 0); + down(&ji->commit_sem); + rc = __jfs_setxattr(tid, dentry->d_inode, name, value, value_len, + flags); + if (!rc) + rc = txCommit(tid, 1, &inode, 0); + txEnd(tid); + up(&ji->commit_sem); + + return rc; } static int can_get_xattr(struct inode *inode, const char *name) @@ -1122,5 +1130,21 @@ ssize_t jfs_listxattr(struct dentry * dentry, char *data, size_t buf_size) int jfs_removexattr(struct dentry *dentry, const char *name) { - return __jfs_setxattr(dentry->d_inode, name, NULL, 0, XATTR_REPLACE); + struct inode *inode = dentry->d_inode; + struct jfs_inode_info *ji = JFS_IP(inode); + int rc; + tid_t tid; + + if ((rc = can_set_xattr(inode, name, NULL, 0))) + return rc; + + tid = txBegin(inode->i_sb, 0); + down(&ji->commit_sem); + rc = __jfs_setxattr(tid, dentry->d_inode, name, NULL, 0, XATTR_REPLACE); + if (!rc) + rc = txCommit(tid, 1, &inode, 0); + txEnd(tid); + up(&ji->commit_sem); + + return rc; } -- cgit v0.10.2 From 1d15b10f95d4c4295a0f2288c7be7b6a005490da Mon Sep 17 00:00:00 2001 From: Dave Kleikamp Date: Thu, 1 Sep 2005 09:05:39 -0500 Subject: JFS: Implement jfs_init_security This atomically initializes the security xattr when an object is created Signed-off-by: Dave Kleikamp diff --git a/fs/jfs/jfs_xattr.h b/fs/jfs/jfs_xattr.h index 116a73c..25e9990 100644 --- a/fs/jfs/jfs_xattr.h +++ b/fs/jfs/jfs_xattr.h @@ -61,4 +61,14 @@ extern ssize_t jfs_getxattr(struct dentry *, const char *, void *, size_t); extern ssize_t jfs_listxattr(struct dentry *, char *, size_t); extern int jfs_removexattr(struct dentry *, const char *); +#ifdef CONFIG_JFS_SECURITY +extern int jfs_init_security(tid_t, struct inode *, struct inode *); +#else +static inline int jfs_init_security(tid_t tid, struct inode *inode, + struct inode *dir) +{ + return 0; +} +#endif + #endif /* H_JFS_XATTR */ diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index f23f9c2..1abe734 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -111,6 +111,12 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, if (rc) goto out3; + rc = jfs_init_security(tid, ip, dip); + if (rc) { + txAbort(tid, 0); + goto out3; + } + if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { jfs_err("jfs_create: dtSearch returned %d", rc); txAbort(tid, 0); @@ -239,6 +245,12 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) if (rc) goto out3; + rc = jfs_init_security(tid, ip, dip); + if (rc) { + txAbort(tid, 0); + goto out3; + } + if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { jfs_err("jfs_mkdir: dtSearch returned %d", rc); txAbort(tid, 0); @@ -906,6 +918,10 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, down(&JFS_IP(dip)->commit_sem); down(&JFS_IP(ip)->commit_sem); + rc = jfs_init_security(tid, ip, dip); + if (rc) + goto out3; + tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_CREATE; tblk->ino = ip->i_ino; @@ -1349,6 +1365,12 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, if (rc) goto out3; + rc = jfs_init_security(tid, ip, dir); + if (rc) { + txAbort(tid, 0); + goto out3; + } + if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) { txAbort(tid, 0); goto out3; diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c index 35674b2..23aa506 100644 --- a/fs/jfs/xattr.c +++ b/fs/jfs/xattr.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "jfs_incore.h" #include "jfs_superblock.h" #include "jfs_dmap.h" @@ -1148,3 +1149,38 @@ int jfs_removexattr(struct dentry *dentry, const char *name) return rc; } + +#ifdef CONFIG_JFS_SECURITY +int jfs_init_security(tid_t tid, struct inode *inode, struct inode *dir) +{ + int rc; + size_t len; + void *value; + char *suffix; + char *name; + + rc = security_inode_init_security(inode, dir, &suffix, &value, &len); + if (rc) { + if (rc == -EOPNOTSUPP) + return 0; + return rc; + } + name = kmalloc(XATTR_SECURITY_PREFIX_LEN + 1 + strlen(suffix), + GFP_NOFS); + if (!name) { + rc = -ENOMEM; + goto kmalloc_failed; + } + strcpy(name, XATTR_SECURITY_PREFIX); + strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix); + + rc = __jfs_setxattr(tid, inode, name, value, len, 0); + + kfree(name); +kmalloc_failed: + kfree(suffix); + kfree(value); + + return rc; +} +#endif -- cgit v0.10.2 From 29db35edb2548c3b0299c53d62d5f26d77a8e58f Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 1 Sep 2005 10:50:13 -0700 Subject: [AGPGART] Remove trailing space before \n From: Denis Vlasenko Signed-off-by: Dave Jones diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index 59f589d..0a7624a 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c @@ -429,7 +429,7 @@ static int __devinit uli_agp_init(struct pci_dev *pdev) struct pci_dev *dev1; int i; unsigned size = amd64_fetch_size(); - printk(KERN_INFO "Setting up ULi AGP. \n"); + printk(KERN_INFO "Setting up ULi AGP.\n"); dev1 = pci_find_slot ((unsigned int)pdev->bus->number,PCI_DEVFN(0,0)); if (dev1 == NULL) { printk(KERN_INFO PFX "Detected a ULi chipset, " -- cgit v0.10.2 From 52c18fd2dc5c6d96cec4f48c69fc17b00edd9860 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 1 Sep 2005 11:01:02 -0700 Subject: [CPUFREQ] Remove trailing whitespace before \n's in printks. From: Denis Vlasenko Signed-off-by: Dave Jones diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c index 04e3563d..06aa760 100644 --- a/arch/i386/kernel/cpu/cpufreq/longhaul.c +++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c @@ -473,11 +473,11 @@ static void __init longhaul_setup_voltagescaling(void) } if (vrmrev==0) { - dprintk ("VRM 8.5 \n"); + dprintk ("VRM 8.5\n"); memcpy (voltage_table, vrm85scales, sizeof(voltage_table)); numvscales = (voltage_table[maxvid]-voltage_table[minvid])/25; } else { - dprintk ("Mobile VRM \n"); + dprintk ("Mobile VRM\n"); memcpy (voltage_table, mobilevrmscales, sizeof(voltage_table)); numvscales = (voltage_table[maxvid]-voltage_table[minvid])/5; } diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c index e70f9b2..c397b62 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c @@ -259,7 +259,7 @@ static int centrino_cpu_init_table(struct cpufreq_policy *policy) if (model->op_points == NULL) { /* Matched a non-match */ - dprintk(KERN_INFO PFX "no table support for CPU model \"%s\": \n", + dprintk(KERN_INFO PFX "no table support for CPU model \"%s\"\n", cpu->x86_model_id); #ifndef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI dprintk(KERN_INFO PFX "try compiling with CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI enabled\n"); -- cgit v0.10.2 From a94f18810f52d3a6de0a09bee0c7258b62eca262 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Sat, 3 Sep 2005 00:09:12 -0400 Subject: [ACPI] revert owner-id-3.patch Signed-off-by: Len Brown diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 8b67a91..77fcfc3 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c @@ -235,16 +235,6 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, acpi_ex_system_wait_semaphore(obj_desc->method.semaphore, ACPI_WAIT_FOREVER); } - /* - * allocate owner id for this method - */ - if (!obj_desc->method.thread_count) { - status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); - } - } - /* * Increment the method parse tree thread count since it has been @@ -299,6 +289,11 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, return_ACPI_STATUS(AE_NULL_OBJECT); } + status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + /* Init for new method, wait on concurrency semaphore */ status = acpi_ds_begin_method_execution(method_node, obj_desc, @@ -385,18 +380,22 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { status = obj_desc->method.implementation(next_walk_state); + return_ACPI_STATUS(status); } - goto end; -cleanup: - /* Decrement the thread count on the method parse tree */ + return_ACPI_STATUS(AE_OK); + + /* On error, we must delete the new walk state */ + + cleanup: + acpi_ut_release_owner_id(&obj_desc->method.owner_id); if (next_walk_state && (next_walk_state->method_desc)) { + /* Decrement the thread count on the method parse tree */ + next_walk_state->method_desc->method.thread_count--; } - /* On error, we must delete the new walk state */ - acpi_ds_terminate_control_method (next_walk_state); - acpi_ds_delete_walk_state (next_walk_state); -end: + (void)acpi_ds_terminate_control_method(next_walk_state); + acpi_ds_delete_walk_state(next_walk_state); return_ACPI_STATUS(status); } @@ -480,7 +479,7 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, * * PARAMETERS: walk_state - State of the method * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Terminate a control method. Delete everything that the method * created, delete all locals and arguments, and delete the parse @@ -488,7 +487,7 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, * ******************************************************************************/ -void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) +acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) { union acpi_operand_object *obj_desc; struct acpi_namespace_node *method_node; @@ -497,14 +496,14 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) ACPI_FUNCTION_TRACE_PTR("ds_terminate_control_method", walk_state); if (!walk_state) { - return_VOID; + return (AE_BAD_PARAMETER); } /* The current method object was saved in the walk state */ obj_desc = walk_state->method_desc; if (!obj_desc) { - return_VOID; + return_ACPI_STATUS(AE_OK); } /* Delete all arguments and locals */ @@ -518,7 +517,7 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) */ status = acpi_ut_acquire_mutex(ACPI_MTX_PARSER); if (ACPI_FAILURE(status)) { - return_VOID; + return_ACPI_STATUS(status); } /* Signal completion of the execution of this method if necessary */ @@ -575,7 +574,7 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) */ status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - goto cleanup; + return_ACPI_STATUS(status); } if (method_node->child) { @@ -593,9 +592,10 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) owner_id); if (ACPI_FAILURE(status)) { - goto cleanup; + return_ACPI_STATUS(status); } } -cleanup: - acpi_ut_release_mutex (ACPI_MTX_PARSER); + + status = acpi_ut_release_mutex(ACPI_MTX_PARSER); + return_ACPI_STATUS(status); } diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index 3677130..3248051 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c @@ -438,6 +438,7 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) { acpi_status status; + acpi_status terminate_status; struct acpi_thread_state *thread; struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list; struct acpi_walk_state *previous_walk_state; @@ -507,9 +508,6 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) walk_state->method_node, NULL, status); - /* Make sure that failed method will be cleaned as if it was executed */ - walk_state->parse_flags |= ACPI_PARSE_EXECUTE; - /* Check for possible multi-thread reentrancy problem */ if ((status == AE_ALREADY_EXISTS) && @@ -526,6 +524,14 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) } } + if (walk_state->method_desc) { + /* Decrement the thread count on the method parse tree */ + + if (walk_state->method_desc->method.thread_count) { + walk_state->method_desc->method.thread_count--; + } + } + /* We are done with this walk, move on to the parent if any */ walk_state = acpi_ds_pop_walk_state(thread); @@ -540,10 +546,13 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) */ if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) { - if (walk_state->method_desc) { - walk_state->method_desc->method.thread_count--; + terminate_status = + acpi_ds_terminate_control_method(walk_state); + if (ACPI_FAILURE(terminate_status)) { + ACPI_REPORT_ERROR(("Could not terminate control method properly\n")); + + /* Ignore error and continue */ } - acpi_ds_terminate_control_method (walk_state); } /* Delete this walk state and all linked control states */ diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c index f6904bd..80c67f2 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -99,6 +99,16 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info) } /* + * Get a new owner_id for objects created by this method. Namespace + * objects (such as Operation Regions) can be created during the + * first pass parse. + */ + status = acpi_ut_allocate_owner_id(&info->obj_desc->method.owner_id); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + + /* * The caller "owns" the parameters, so give each one an extra * reference */ @@ -129,6 +139,9 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info) status = acpi_ps_execute_pass(info); cleanup: + if (info->obj_desc->method.owner_id) { + acpi_ut_release_owner_id(&info->obj_desc->method.owner_id); + } /* Take away the extra reference that we gave the parameters above */ diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index c2f5b2a..f027502 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -67,8 +67,6 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) ACPI_FUNCTION_TRACE("ut_allocate_owner_id"); - WARN_ON(*owner_id); - /* Mutex for the global ID mask */ status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h index c436e8b..5930618 100644 --- a/include/acpi/acdispat.h +++ b/include/acpi/acdispat.h @@ -194,7 +194,7 @@ acpi_status acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, union acpi_operand_object *return_desc); -void +acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state); acpi_status -- cgit v0.10.2 From aff8c2777d1a9edf97f26bf60579f9c931443eb1 Mon Sep 17 00:00:00 2001 From: Robert Moore Date: Fri, 2 Sep 2005 17:24:17 -0400 Subject: [ACPI] ACPICA 20050902 Fixed a problem with the internal Owner ID allocation and deallocation mechanisms for control method execution and recursive method invocation. This should eliminate the OWNER_ID_LIMIT exceptions and "Invalid OwnerId" messages seen on some systems. Recursive method invocation depth is currently limited to 255. (Alexey Starikovskiy) http://bugzilla.kernel.org/show_bug.cgi?id=4892 Completely eliminated all vestiges of support for the "module-level executable code" until this support is fully implemented and debugged. This should eliminate the NO_RETURN_VALUE exceptions seen during table load on some systems that invoke this support. http://bugzilla.kernel.org/show_bug.cgi?id=5162 Fixed a problem within the resource manager code where the transaction flags for a 64-bit address descriptor were handled incorrectly in the type-specific flag byte. Consolidated duplicate code within the address descriptor resource manager code, reducing overall subsystem code size. Signed-off-by: Robert Moore Signed-off-by: Len Brown diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 77fcfc3..36c1ca0 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c @@ -207,6 +207,13 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, return_ACPI_STATUS(AE_NULL_ENTRY); } + /* Prevent wraparound of thread count */ + + if (obj_desc->method.thread_count == ACPI_UINT8_MAX) { + ACPI_REPORT_ERROR(("Method reached maximum reentrancy limit (255)\n")); + return_ACPI_STATUS(AE_AML_METHOD_LIMIT); + } + /* * If there is a concurrency limit on this method, we need to * obtain a unit from the method semaphore. @@ -237,6 +244,18 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, } /* + * Allocate an Owner ID for this method, only if this is the first thread + * to begin concurrent execution. We only need one owner_id, even if the + * method is invoked recursively. + */ + if (!obj_desc->method.owner_id) { + status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + } + + /* * Increment the method parse tree thread count since it has been * reentered one more time (even if it is the same thread) */ @@ -289,11 +308,6 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, return_ACPI_STATUS(AE_NULL_OBJECT); } - status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - /* Init for new method, wait on concurrency semaphore */ status = acpi_ds_begin_method_execution(method_node, obj_desc, @@ -345,9 +359,8 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, } /* * The resolved arguments were put on the previous walk state's operand - * stack. Operands on the previous walk state stack always - * start at index 0. - * Null terminate the list of arguments + * stack. Operands on the previous walk state stack always + * start at index 0. Also, null terminate the list of arguments */ this_walk_state->operands[this_walk_state->num_operands] = NULL; @@ -380,21 +393,20 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { status = obj_desc->method.implementation(next_walk_state); - return_ACPI_STATUS(status); } - return_ACPI_STATUS(AE_OK); - - /* On error, we must delete the new walk state */ + return_ACPI_STATUS(status); cleanup: - acpi_ut_release_owner_id(&obj_desc->method.owner_id); - if (next_walk_state && (next_walk_state->method_desc)) { - /* Decrement the thread count on the method parse tree */ + /* Decrement the thread count on the method parse tree */ + if (next_walk_state && (next_walk_state->method_desc)) { next_walk_state->method_desc->method.thread_count--; } - (void)acpi_ds_terminate_control_method(next_walk_state); + + /* On error, we must delete the new walk state */ + + acpi_ds_terminate_control_method(next_walk_state); acpi_ds_delete_walk_state(next_walk_state); return_ACPI_STATUS(status); } @@ -479,7 +491,7 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, * * PARAMETERS: walk_state - State of the method * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Terminate a control method. Delete everything that the method * created, delete all locals and arguments, and delete the parse @@ -487,7 +499,7 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, * ******************************************************************************/ -acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) +void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) { union acpi_operand_object *obj_desc; struct acpi_namespace_node *method_node; @@ -496,14 +508,14 @@ acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) ACPI_FUNCTION_TRACE_PTR("ds_terminate_control_method", walk_state); if (!walk_state) { - return (AE_BAD_PARAMETER); + return_VOID; } /* The current method object was saved in the walk state */ obj_desc = walk_state->method_desc; if (!obj_desc) { - return_ACPI_STATUS(AE_OK); + return_VOID; } /* Delete all arguments and locals */ @@ -517,7 +529,7 @@ acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) */ status = acpi_ut_acquire_mutex(ACPI_MTX_PARSER); if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); + return_VOID; } /* Signal completion of the execution of this method if necessary */ @@ -528,7 +540,6 @@ acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) semaphore, 1); if (ACPI_FAILURE(status)) { ACPI_REPORT_ERROR(("Could not signal method semaphore\n")); - status = AE_OK; /* Ignore error and continue cleanup */ } @@ -539,9 +550,8 @@ acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) "*** Not deleting method namespace, there are still %d threads\n", walk_state->method_desc->method. thread_count)); - } + } else { /* This is the last executing thread */ - if (!walk_state->method_desc->method.thread_count) { /* * Support to dynamically change a method from not_serialized to * Serialized if it appears that the method is written foolishly and @@ -574,7 +584,7 @@ acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) */ status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); + goto exit; } if (method_node->child) { @@ -590,12 +600,9 @@ acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); acpi_ut_release_owner_id(&walk_state->method_desc->method. owner_id); - - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } } - status = acpi_ut_release_mutex(ACPI_MTX_PARSER); - return_ACPI_STATUS(status); + exit: + (void)acpi_ut_release_mutex(ACPI_MTX_PARSER); + return_VOID; } diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c index 362bbcf..4117312 100644 --- a/drivers/acpi/dispatcher/dswload.c +++ b/drivers/acpi/dispatcher/dswload.c @@ -486,8 +486,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state, if ((!(walk_state->op_info->flags & AML_NSOPCODE) && (walk_state->opcode != AML_INT_NAMEPATH_OP)) || (!(walk_state->op_info->flags & AML_NAMED))) { +#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || (walk_state->op_info->class == AML_CLASS_CONTROL)) { + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Begin/EXEC: %s (fl %8.8X)\n", walk_state->op_info->name, @@ -499,6 +501,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state, acpi_ds_exec_begin_op(walk_state, out_op); return_ACPI_STATUS(status); } +#endif return_ACPI_STATUS(AE_OK); } @@ -731,6 +734,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) if (!(walk_state->op_info->flags & AML_NSOBJECT)) { #ifndef ACPI_NO_METHOD_EXECUTION +#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE /* No namespace object. Executable opcode? */ if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || @@ -746,6 +750,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) return_ACPI_STATUS(status); } #endif +#endif return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index 3248051..76d4d64 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c @@ -438,7 +438,6 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) { acpi_status status; - acpi_status terminate_status; struct acpi_thread_state *thread; struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list; struct acpi_walk_state *previous_walk_state; @@ -508,6 +507,10 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) walk_state->method_node, NULL, status); + /* Ensure proper cleanup */ + + walk_state->parse_flags |= ACPI_PARSE_EXECUTE; + /* Check for possible multi-thread reentrancy problem */ if ((status == AE_ALREADY_EXISTS) && @@ -524,14 +527,6 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) } } - if (walk_state->method_desc) { - /* Decrement the thread count on the method parse tree */ - - if (walk_state->method_desc->method.thread_count) { - walk_state->method_desc->method.thread_count--; - } - } - /* We are done with this walk, move on to the parent if any */ walk_state = acpi_ds_pop_walk_state(thread); @@ -546,13 +541,13 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) */ if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) { - terminate_status = - acpi_ds_terminate_control_method(walk_state); - if (ACPI_FAILURE(terminate_status)) { - ACPI_REPORT_ERROR(("Could not terminate control method properly\n")); + if (walk_state->method_desc) { + /* Decrement the thread count on the method parse tree */ - /* Ignore error and continue */ + walk_state->method_desc->method.thread_count--; } + + acpi_ds_terminate_control_method(walk_state); } /* Delete this walk state and all linked control states */ diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c index 80c67f2..4dcbd44 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -99,16 +99,6 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info) } /* - * Get a new owner_id for objects created by this method. Namespace - * objects (such as Operation Regions) can be created during the - * first pass parse. - */ - status = acpi_ut_allocate_owner_id(&info->obj_desc->method.owner_id); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - /* * The caller "owns" the parameters, so give each one an extra * reference */ @@ -139,10 +129,6 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info) status = acpi_ps_execute_pass(info); cleanup: - if (info->obj_desc->method.owner_id) { - acpi_ut_release_owner_id(&info->obj_desc->method.owner_id); - } - /* Take away the extra reference that we gave the parameters above */ acpi_ps_update_parameter_list(info, REF_DECREMENT); diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c index 4cf46e1..23b54ba 100644 --- a/drivers/acpi/resources/rsaddr.c +++ b/drivers/acpi/resources/rsaddr.c @@ -47,6 +47,180 @@ #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME("rsaddr") +/* Local prototypes */ +static void +acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags); + +static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource); + +static void +acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags); + +static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource); + +/******************************************************************************* + * + * FUNCTION: acpi_rs_decode_general_flags + * + * PARAMETERS: Resource - Address resource data struct + * Flags - Actual flag byte + * + * RETURN: Decoded flag bits in resource struct + * + * DESCRIPTION: Decode a general flag byte to an address resource struct + * + ******************************************************************************/ + +static void +acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags) +{ + ACPI_FUNCTION_ENTRY(); + + /* Producer / Consumer - flag bit[0] */ + + resource->address.producer_consumer = (u32) (flags & 0x01); + + /* Decode (_DEC) - flag bit[1] */ + + resource->address.decode = (u32) ((flags >> 1) & 0x01); + + /* Min Address Fixed (_MIF) - flag bit[2] */ + + resource->address.min_address_fixed = (u32) ((flags >> 2) & 0x01); + + /* Max Address Fixed (_MAF) - flag bit[3] */ + + resource->address.max_address_fixed = (u32) ((flags >> 3) & 0x01); +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_encode_general_flags + * + * PARAMETERS: Resource - Address resource data struct + * + * RETURN: Encoded general flag byte + * + * DESCRIPTION: Construct a general flag byte from an address resource struct + * + ******************************************************************************/ + +static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource) +{ + u8 flags; + + ACPI_FUNCTION_ENTRY(); + + /* Producer / Consumer - flag bit[0] */ + + flags = (u8) (resource->address.producer_consumer & 0x01); + + /* Decode (_DEC) - flag bit[1] */ + + flags |= (u8) ((resource->address.decode & 0x01) << 1); + + /* Min Address Fixed (_MIF) - flag bit[2] */ + + flags |= (u8) ((resource->address.min_address_fixed & 0x01) << 2); + + /* Max Address Fixed (_MAF) - flag bit[3] */ + + flags |= (u8) ((resource->address.max_address_fixed & 0x01) << 3); + + return (flags); +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_decode_specific_flags + * + * PARAMETERS: Resource - Address resource data struct + * Flags - Actual flag byte + * + * RETURN: Decoded flag bits in attribute struct + * + * DESCRIPTION: Decode a type-specific flag byte to an attribute struct. + * Type-specific flags are only defined for the Memory and IO + * resource types. + * + ******************************************************************************/ + +static void +acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags) +{ + ACPI_FUNCTION_ENTRY(); + + if (resource->address.resource_type == ACPI_MEMORY_RANGE) { + /* Write Status (_RW) - flag bit[0] */ + + resource->address.attribute.memory.read_write_attribute = + (u16) (flags & 0x01); + + /* Memory Attributes (_MEM) - flag bits[2:1] */ + + resource->address.attribute.memory.cache_attribute = + (u16) ((flags >> 1) & 0x03); + } else if (resource->address.resource_type == ACPI_IO_RANGE) { + /* Ranges (_RNG) - flag bits[1:0] */ + + resource->address.attribute.io.range_attribute = + (u16) (flags & 0x03); + + /* Translations (_TTP and _TRS) - flag bits[5:4] */ + + resource->address.attribute.io.translation_attribute = + (u16) ((flags >> 4) & 0x03); + } +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_encode_specific_flags + * + * PARAMETERS: Resource - Address resource data struct + * + * RETURN: Encoded type-specific flag byte + * + * DESCRIPTION: Construct a type-specific flag byte from an attribute struct. + * Type-specific flags are only defined for the Memory and IO + * resource types. + * + ******************************************************************************/ + +static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource) +{ + u8 flags = 0; + + ACPI_FUNCTION_ENTRY(); + + if (resource->address.resource_type == ACPI_MEMORY_RANGE) { + /* Write Status (_RW) - flag bit[0] */ + + flags = (u8) + (resource->address.attribute.memory. + read_write_attribute & 0x01); + + /* Memory Attributes (_MEM) - flag bits[2:1] */ + + flags |= (u8) + ((resource->address.attribute.memory. + cache_attribute & 0x03) << 1); + } else if (resource->address.resource_type == ACPI_IO_RANGE) { + /* Ranges (_RNG) - flag bits[1:0] */ + + flags = (u8) + (resource->address.attribute.io.range_attribute & 0x03); + + /* Translations (_TTP and _TRS) - flag bits[5:4] */ + + flags |= (u8) + ((resource->address.attribute.io. + translation_attribute & 0x03) << 4); + } + + return (flags); +} + /******************************************************************************* * * FUNCTION: acpi_rs_address16_resource @@ -67,6 +241,7 @@ ACPI_MODULE_NAME("rsaddr") * number of bytes consumed from the byte stream. * ******************************************************************************/ + acpi_status acpi_rs_address16_resource(u8 * byte_stream_buffer, acpi_size * bytes_consumed, @@ -83,7 +258,7 @@ acpi_rs_address16_resource(u8 * byte_stream_buffer, ACPI_FUNCTION_TRACE("rs_address16_resource"); - /* Point past the Descriptor to get the number of bytes consumed */ + /* Get the Descriptor Length field */ buffer += 1; ACPI_MOVE_16_TO_16(&temp16, buffer); @@ -113,46 +288,12 @@ acpi_rs_address16_resource(u8 * byte_stream_buffer, /* Get the General Flags (Byte4) */ buffer += 1; - temp8 = *buffer; - - /* Producer / Consumer */ - - output_struct->data.address16.producer_consumer = temp8 & 0x01; - - /* Decode */ - - output_struct->data.address16.decode = (temp8 >> 1) & 0x01; - - /* Min Address Fixed */ - - output_struct->data.address16.min_address_fixed = (temp8 >> 2) & 0x01; - - /* Max Address Fixed */ - - output_struct->data.address16.max_address_fixed = (temp8 >> 3) & 0x01; + acpi_rs_decode_general_flags(&output_struct->data, *buffer); /* Get the Type Specific Flags (Byte5) */ buffer += 1; - temp8 = *buffer; - - if (ACPI_MEMORY_RANGE == output_struct->data.address16.resource_type) { - output_struct->data.address16.attribute.memory. - read_write_attribute = (u16) (temp8 & 0x01); - output_struct->data.address16.attribute.memory.cache_attribute = - (u16) ((temp8 >> 1) & 0x03); - } else { - if (ACPI_IO_RANGE == - output_struct->data.address16.resource_type) { - output_struct->data.address16.attribute.io. - range_attribute = (u16) (temp8 & 0x03); - output_struct->data.address16.attribute.io. - translation_attribute = (u16) ((temp8 >> 4) & 0x03); - } else { - /* BUS_NUMBER_RANGE == Address16.Data->resource_type */ - /* Nothing needs to be filled in */ - } - } + acpi_rs_decode_specific_flags(&output_struct->data, *buffer); /* Get Granularity (Bytes 6-7) */ @@ -200,9 +341,8 @@ acpi_rs_address16_resource(u8 * byte_stream_buffer, if (*bytes_consumed > (16 + 1)) { /* Dereference the Index */ - temp8 = *buffer; output_struct->data.address16.resource_source.index = - (u32) temp8; + (u32) * buffer; /* Point to the String */ @@ -216,22 +356,20 @@ acpi_rs_address16_resource(u8 * byte_stream_buffer, temp_ptr = (u8 *) output_struct->data.address16.resource_source.string_ptr; - /* Copy the string into the buffer */ + /* Copy the resource_source string into the buffer */ index = 0; - - while (0x00 != *buffer) { + while (*buffer) { *temp_ptr = *buffer; - temp_ptr += 1; - buffer += 1; - index += 1; + temp_ptr++; + buffer++; + index++; } - /* Add the terminating null */ - - *temp_ptr = 0x00; + /* Add the terminating null and set the string length */ + *temp_ptr = 0; output_struct->data.address16.resource_source.string_length = index + 1; @@ -243,7 +381,7 @@ acpi_rs_address16_resource(u8 * byte_stream_buffer, temp8 = (u8) (index + 1); struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); } else { - output_struct->data.address16.resource_source.index = 0x00; + output_struct->data.address16.resource_source.index = 0; output_struct->data.address16.resource_source.string_length = 0; output_struct->data.address16.resource_source.string_ptr = NULL; } @@ -280,15 +418,13 @@ acpi_rs_address16_stream(struct acpi_resource *linked_list, { u8 *buffer = *output_buffer; u8 *length_field; - u8 temp8; - char *temp_pointer = NULL; acpi_size actual_bytes; ACPI_FUNCTION_TRACE("rs_address16_stream"); - /* The descriptor field is static */ + /* Set the Descriptor Type field */ - *buffer = 0x88; + *buffer = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE; buffer += 1; /* Save a pointer to the Length field - to be filled in later */ @@ -298,43 +434,17 @@ acpi_rs_address16_stream(struct acpi_resource *linked_list, /* Set the Resource Type (Memory, Io, bus_number) */ - temp8 = (u8) (linked_list->data.address16.resource_type & 0x03); - *buffer = temp8; + *buffer = (u8) (linked_list->data.address16.resource_type & 0x03); buffer += 1; /* Set the general flags */ - temp8 = (u8) (linked_list->data.address16.producer_consumer & 0x01); - - temp8 |= (linked_list->data.address16.decode & 0x01) << 1; - temp8 |= (linked_list->data.address16.min_address_fixed & 0x01) << 2; - temp8 |= (linked_list->data.address16.max_address_fixed & 0x01) << 3; - - *buffer = temp8; + *buffer = acpi_rs_encode_general_flags(&linked_list->data); buffer += 1; /* Set the type specific flags */ - temp8 = 0; - - if (ACPI_MEMORY_RANGE == linked_list->data.address16.resource_type) { - temp8 = (u8) - (linked_list->data.address16.attribute.memory. - read_write_attribute & 0x01); - - temp8 |= - (linked_list->data.address16.attribute.memory. - cache_attribute & 0x03) << 1; - } else if (ACPI_IO_RANGE == linked_list->data.address16.resource_type) { - temp8 = (u8) - (linked_list->data.address16.attribute.io.range_attribute & - 0x03); - temp8 |= - (linked_list->data.address16.attribute.io. - translation_attribute & 0x03) << 4; - } - - *buffer = temp8; + *buffer = acpi_rs_encode_specific_flags(&linked_list->data); buffer += 1; /* Set the address space granularity */ @@ -368,22 +478,19 @@ acpi_rs_address16_stream(struct acpi_resource *linked_list, /* Resource Source Index and Resource Source are optional */ - if (0 != linked_list->data.address16.resource_source.string_length) { - temp8 = (u8) linked_list->data.address16.resource_source.index; - - *buffer = temp8; + if (linked_list->data.address16.resource_source.string_length) { + *buffer = + (u8) linked_list->data.address16.resource_source.index; buffer += 1; - temp_pointer = (char *)buffer; - - /* Copy the string */ + /* Copy the resource_source string */ - ACPI_STRCPY(temp_pointer, + ACPI_STRCPY((char *)buffer, linked_list->data.address16.resource_source. string_ptr); /* - * Buffer needs to be set to the length of the sting + one for the + * Buffer needs to be set to the length of the string + one for the * terminating null */ buffer += @@ -432,20 +539,18 @@ acpi_rs_address32_resource(u8 * byte_stream_buffer, acpi_size * bytes_consumed, u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; u16 temp16; u8 temp8; u8 *temp_ptr; - acpi_size struct_size; u32 index; + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + acpi_size struct_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32); ACPI_FUNCTION_TRACE("rs_address32_resource"); - buffer = byte_stream_buffer; - struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32); - - /* Point past the Descriptor to get the number of bytes consumed */ + /* Get the Descriptor Length field */ buffer += 1; ACPI_MOVE_16_TO_16(&temp16, buffer); @@ -475,47 +580,12 @@ acpi_rs_address32_resource(u8 * byte_stream_buffer, /* Get the General Flags (Byte4) */ buffer += 1; - temp8 = *buffer; - - /* Producer / Consumer */ - - output_struct->data.address32.producer_consumer = temp8 & 0x01; - - /* Decode */ - - output_struct->data.address32.decode = (temp8 >> 1) & 0x01; - - /* Min Address Fixed */ - - output_struct->data.address32.min_address_fixed = (temp8 >> 2) & 0x01; - - /* Max Address Fixed */ - - output_struct->data.address32.max_address_fixed = (temp8 >> 3) & 0x01; + acpi_rs_decode_general_flags(&output_struct->data, *buffer); /* Get the Type Specific Flags (Byte5) */ buffer += 1; - temp8 = *buffer; - - if (ACPI_MEMORY_RANGE == output_struct->data.address32.resource_type) { - output_struct->data.address32.attribute.memory. - read_write_attribute = (u16) (temp8 & 0x01); - - output_struct->data.address32.attribute.memory.cache_attribute = - (u16) ((temp8 >> 1) & 0x03); - } else { - if (ACPI_IO_RANGE == - output_struct->data.address32.resource_type) { - output_struct->data.address32.attribute.io. - range_attribute = (u16) (temp8 & 0x03); - output_struct->data.address32.attribute.io. - translation_attribute = (u16) ((temp8 >> 4) & 0x03); - } else { - /* BUS_NUMBER_RANGE == output_struct->Data.Address32.resource_type */ - /* Nothing needs to be filled in */ - } - } + acpi_rs_decode_specific_flags(&output_struct->data, *buffer); /* Get Granularity (Bytes 6-9) */ @@ -561,9 +631,8 @@ acpi_rs_address32_resource(u8 * byte_stream_buffer, if (*bytes_consumed > (26 + 1)) { /* Dereference the Index */ - temp8 = *buffer; output_struct->data.address32.resource_source.index = - (u32) temp8; + (u32) * buffer; /* Point to the String */ @@ -577,20 +646,20 @@ acpi_rs_address32_resource(u8 * byte_stream_buffer, temp_ptr = (u8 *) output_struct->data.address32.resource_source.string_ptr; - /* Copy the string into the buffer */ + /* Copy the resource_source string into the buffer */ index = 0; - while (0x00 != *buffer) { + while (*buffer) { *temp_ptr = *buffer; - temp_ptr += 1; - buffer += 1; - index += 1; + temp_ptr++; + buffer++; + index++; } - /* Add the terminating null */ + /* Add the terminating null and set the string length */ - *temp_ptr = 0x00; + *temp_ptr = 0; output_struct->data.address32.resource_source.string_length = index + 1; @@ -602,7 +671,7 @@ acpi_rs_address32_resource(u8 * byte_stream_buffer, temp8 = (u8) (index + 1); struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); } else { - output_struct->data.address32.resource_source.index = 0x00; + output_struct->data.address32.resource_source.index = 0; output_struct->data.address32.resource_source.string_length = 0; output_struct->data.address32.resource_source.string_ptr = NULL; } @@ -639,62 +708,34 @@ acpi_rs_address32_stream(struct acpi_resource *linked_list, { u8 *buffer; u16 *length_field; - u8 temp8; - char *temp_pointer; ACPI_FUNCTION_TRACE("rs_address32_stream"); buffer = *output_buffer; - /* The descriptor field is static */ + /* Set the Descriptor Type field */ - *buffer = 0x87; + *buffer = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE; buffer += 1; - /* Set a pointer to the Length field - to be filled in later */ + /* Save a pointer to the Length field - to be filled in later */ length_field = ACPI_CAST_PTR(u16, buffer); buffer += 2; /* Set the Resource Type (Memory, Io, bus_number) */ - temp8 = (u8) (linked_list->data.address32.resource_type & 0x03); - - *buffer = temp8; + *buffer = (u8) (linked_list->data.address32.resource_type & 0x03); buffer += 1; /* Set the general flags */ - temp8 = (u8) (linked_list->data.address32.producer_consumer & 0x01); - temp8 |= (linked_list->data.address32.decode & 0x01) << 1; - temp8 |= (linked_list->data.address32.min_address_fixed & 0x01) << 2; - temp8 |= (linked_list->data.address32.max_address_fixed & 0x01) << 3; - - *buffer = temp8; + *buffer = acpi_rs_encode_general_flags(&linked_list->data); buffer += 1; /* Set the type specific flags */ - temp8 = 0; - - if (ACPI_MEMORY_RANGE == linked_list->data.address32.resource_type) { - temp8 = (u8) - (linked_list->data.address32.attribute.memory. - read_write_attribute & 0x01); - - temp8 |= - (linked_list->data.address32.attribute.memory. - cache_attribute & 0x03) << 1; - } else if (ACPI_IO_RANGE == linked_list->data.address32.resource_type) { - temp8 = (u8) - (linked_list->data.address32.attribute.io.range_attribute & - 0x03); - temp8 |= - (linked_list->data.address32.attribute.io. - translation_attribute & 0x03) << 4; - } - - *buffer = temp8; + *buffer = acpi_rs_encode_specific_flags(&linked_list->data); buffer += 1; /* Set the address space granularity */ @@ -728,22 +769,19 @@ acpi_rs_address32_stream(struct acpi_resource *linked_list, /* Resource Source Index and Resource Source are optional */ - if (0 != linked_list->data.address32.resource_source.string_length) { - temp8 = (u8) linked_list->data.address32.resource_source.index; - - *buffer = temp8; + if (linked_list->data.address32.resource_source.string_length) { + *buffer = + (u8) linked_list->data.address32.resource_source.index; buffer += 1; - temp_pointer = (char *)buffer; - - /* Copy the string */ + /* Copy the resource_source string */ - ACPI_STRCPY(temp_pointer, + ACPI_STRCPY((char *)buffer, linked_list->data.address32.resource_source. string_ptr); /* - * Buffer needs to be set to the length of the sting + one for the + * Buffer needs to be set to the length of the string + one for the * terminating null */ buffer += @@ -758,7 +796,7 @@ acpi_rs_address32_stream(struct acpi_resource *linked_list, /* * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) + * minus the header size (3 bytes) */ *length_field = (u16) (*bytes_consumed - 3); return_ACPI_STATUS(AE_OK); @@ -790,22 +828,23 @@ acpi_rs_address64_resource(u8 * byte_stream_buffer, acpi_size * bytes_consumed, u8 ** output_buffer, acpi_size * structure_size) { - u8 *buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; u16 temp16; u8 temp8; u8 resource_type; u8 *temp_ptr; - acpi_size struct_size; u32 index; + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *)*output_buffer; + acpi_size struct_size = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64); ACPI_FUNCTION_TRACE("rs_address64_resource"); - buffer = byte_stream_buffer; - struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64); + /* Get the Descriptor Type */ + resource_type = *buffer; - /* Point past the Descriptor to get the number of bytes consumed */ + /* Get the Descriptor Length field */ buffer += 1; ACPI_MOVE_16_TO_16(&temp16, buffer); @@ -835,47 +874,12 @@ acpi_rs_address64_resource(u8 * byte_stream_buffer, /* Get the General Flags (Byte4) */ buffer += 1; - temp8 = *buffer; - - /* Producer / Consumer */ - - output_struct->data.address64.producer_consumer = temp8 & 0x01; - - /* Decode */ - - output_struct->data.address64.decode = (temp8 >> 1) & 0x01; - - /* Min Address Fixed */ - - output_struct->data.address64.min_address_fixed = (temp8 >> 2) & 0x01; - - /* Max Address Fixed */ - - output_struct->data.address64.max_address_fixed = (temp8 >> 3) & 0x01; + acpi_rs_decode_general_flags(&output_struct->data, *buffer); /* Get the Type Specific Flags (Byte5) */ buffer += 1; - temp8 = *buffer; - - if (ACPI_MEMORY_RANGE == output_struct->data.address64.resource_type) { - output_struct->data.address64.attribute.memory. - read_write_attribute = (u16) (temp8 & 0x01); - - output_struct->data.address64.attribute.memory.cache_attribute = - (u16) ((temp8 >> 1) & 0x03); - } else { - if (ACPI_IO_RANGE == - output_struct->data.address64.resource_type) { - output_struct->data.address64.attribute.io. - range_attribute = (u16) (temp8 & 0x03); - output_struct->data.address64.attribute.io. - translation_attribute = (u16) ((temp8 >> 4) & 0x03); - } else { - /* BUS_NUMBER_RANGE == output_struct->Data.Address64.resource_type */ - /* Nothing needs to be filled in */ - } - } + acpi_rs_decode_specific_flags(&output_struct->data, *buffer); if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { /* Move past revision_id and Reserved byte */ @@ -912,7 +916,7 @@ acpi_rs_address64_resource(u8 * byte_stream_buffer, ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length, buffer); - output_struct->data.address64.resource_source.index = 0x00; + output_struct->data.address64.resource_source.index = 0; output_struct->data.address64.resource_source.string_length = 0; output_struct->data.address64.resource_source.string_ptr = NULL; @@ -942,9 +946,8 @@ acpi_rs_address64_resource(u8 * byte_stream_buffer, if (*bytes_consumed > (46 + 1)) { /* Dereference the Index */ - temp8 = *buffer; output_struct->data.address64.resource_source.index = - (u32) temp8; + (u32) * buffer; /* Point to the String */ @@ -960,21 +963,21 @@ acpi_rs_address64_resource(u8 * byte_stream_buffer, output_struct->data.address64.resource_source. string_ptr; - /* Copy the string into the buffer */ + /* Copy the resource_source string into the buffer */ index = 0; - while (0x00 != *buffer) { + while (*buffer) { *temp_ptr = *buffer; - temp_ptr += 1; - buffer += 1; - index += 1; + temp_ptr++; + buffer++; + index++; } /* - * Add the terminating null + * Add the terminating null and set the string length */ - *temp_ptr = 0x00; + *temp_ptr = 0; output_struct->data.address64.resource_source. string_length = index + 1; @@ -1020,62 +1023,34 @@ acpi_rs_address64_stream(struct acpi_resource *linked_list, { u8 *buffer; u16 *length_field; - u8 temp8; - char *temp_pointer; ACPI_FUNCTION_TRACE("rs_address64_stream"); buffer = *output_buffer; - /* The descriptor field is static */ + /* Set the Descriptor Type field */ - *buffer = 0x8A; + *buffer = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE; buffer += 1; - /* Set a pointer to the Length field - to be filled in later */ + /* Save a pointer to the Length field - to be filled in later */ length_field = ACPI_CAST_PTR(u16, buffer); buffer += 2; /* Set the Resource Type (Memory, Io, bus_number) */ - temp8 = (u8) (linked_list->data.address64.resource_type & 0x03); - - *buffer = temp8; + *buffer = (u8) (linked_list->data.address64.resource_type & 0x03); buffer += 1; /* Set the general flags */ - temp8 = (u8) (linked_list->data.address64.producer_consumer & 0x01); - temp8 |= (linked_list->data.address64.decode & 0x01) << 1; - temp8 |= (linked_list->data.address64.min_address_fixed & 0x01) << 2; - temp8 |= (linked_list->data.address64.max_address_fixed & 0x01) << 3; - - *buffer = temp8; + *buffer = acpi_rs_encode_general_flags(&linked_list->data); buffer += 1; /* Set the type specific flags */ - temp8 = 0; - - if (ACPI_MEMORY_RANGE == linked_list->data.address64.resource_type) { - temp8 = (u8) - (linked_list->data.address64.attribute.memory. - read_write_attribute & 0x01); - - temp8 |= - (linked_list->data.address64.attribute.memory. - cache_attribute & 0x03) << 1; - } else if (ACPI_IO_RANGE == linked_list->data.address64.resource_type) { - temp8 = (u8) - (linked_list->data.address64.attribute.io.range_attribute & - 0x03); - temp8 |= - (linked_list->data.address64.attribute.io.range_attribute & - 0x03) << 4; - } - - *buffer = temp8; + *buffer = acpi_rs_encode_specific_flags(&linked_list->data); buffer += 1; /* Set the address space granularity */ @@ -1109,22 +1084,19 @@ acpi_rs_address64_stream(struct acpi_resource *linked_list, /* Resource Source Index and Resource Source are optional */ - if (0 != linked_list->data.address64.resource_source.string_length) { - temp8 = (u8) linked_list->data.address64.resource_source.index; - - *buffer = temp8; + if (linked_list->data.address64.resource_source.string_length) { + *buffer = + (u8) linked_list->data.address64.resource_source.index; buffer += 1; - temp_pointer = (char *)buffer; - - /* Copy the string */ + /* Copy the resource_source string */ - ACPI_STRCPY(temp_pointer, + ACPI_STRCPY((char *)buffer, linked_list->data.address64.resource_source. string_ptr); /* - * Buffer needs to be set to the length of the sting + one for the + * Buffer needs to be set to the length of the string + one for the * terminating null */ buffer += diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c index 7179b62..56043fe 100644 --- a/drivers/acpi/resources/rsirq.c +++ b/drivers/acpi/resources/rsirq.c @@ -290,7 +290,7 @@ acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, ACPI_FUNCTION_TRACE("rs_extended_irq_resource"); - /* Point past the Descriptor to get the number of bytes consumed */ + /* Get the Descriptor Length field */ buffer += 1; ACPI_MOVE_16_TO_16(&temp16, buffer); @@ -398,7 +398,7 @@ acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, /* Copy the string into the buffer */ index = 0; - while (0x00 != *buffer) { + while (*buffer) { *temp_ptr = *buffer; temp_ptr += 1; @@ -408,7 +408,7 @@ acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, /* Add the terminating null */ - *temp_ptr = 0x00; + *temp_ptr = 0; output_struct->data.extended_irq.resource_source.string_length = index + 1; @@ -420,7 +420,7 @@ acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, temp8 = (u8) (index + 1); struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); } else { - output_struct->data.extended_irq.resource_source.index = 0x00; + output_struct->data.extended_irq.resource_source.index = 0; output_struct->data.extended_irq.resource_source.string_length = 0; output_struct->data.extended_irq.resource_source.string_ptr = @@ -461,16 +461,15 @@ acpi_rs_extended_irq_stream(struct acpi_resource *linked_list, u16 *length_field; u8 temp8 = 0; u8 index; - char *temp_pointer = NULL; ACPI_FUNCTION_TRACE("rs_extended_irq_stream"); - /* The descriptor field is static */ + /* Set the Descriptor Type field */ - *buffer = 0x89; + *buffer = ACPI_RDESC_TYPE_EXTENDED_XRUPT; buffer += 1; - /* Set a pointer to the Length field - to be filled in later */ + /* Save a pointer to the Length field - to be filled in later */ length_field = ACPI_CAST_PTR(u16, buffer); buffer += 2; @@ -524,16 +523,14 @@ acpi_rs_extended_irq_stream(struct acpi_resource *linked_list, (u8) linked_list->data.extended_irq.resource_source.index; buffer += 1; - temp_pointer = (char *)buffer; - /* Copy the string */ - ACPI_STRCPY(temp_pointer, + ACPI_STRCPY((char *)buffer, linked_list->data.extended_irq.resource_source. string_ptr); /* - * Buffer needs to be set to the length of the sting + one for the + * Buffer needs to be set to the length of the string + one for the * terminating null */ buffer += diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index f027502..0c5abc5 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -67,6 +67,14 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) ACPI_FUNCTION_TRACE("ut_allocate_owner_id"); + /* Guard against multiple allocations of ID to the same location */ + + if (*owner_id) { + ACPI_REPORT_ERROR(("Owner ID [%2.2X] already exists\n", + *owner_id)); + return_ACPI_STATUS(AE_ALREADY_EXISTS); + } + /* Mutex for the global ID mask */ status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); @@ -80,7 +88,8 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) if (!(acpi_gbl_owner_id_mask & (1 << i))) { ACPI_DEBUG_PRINT((ACPI_DB_VALUES, "Current owner_id mask: %8.8X New ID: %2.2X\n", - acpi_gbl_owner_id_mask, (i + 1))); + acpi_gbl_owner_id_mask, + (unsigned int)(i + 1))); acpi_gbl_owner_id_mask |= (1 << i); *owner_id = (acpi_owner_id) (i + 1); @@ -143,7 +152,9 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) return_VOID; } - owner_id--; /* Normalize to zero */ + /* Normalize the ID to zero */ + + owner_id--; /* Free the owner ID only if it is valid */ diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 73c43a3..427cff1 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -63,7 +63,7 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20050815 +#define ACPI_CA_VERSION 0x20050902 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h index 5930618..065f24a 100644 --- a/include/acpi/acdispat.h +++ b/include/acpi/acdispat.h @@ -194,8 +194,7 @@ acpi_status acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, union acpi_operand_object *return_desc); -acpi_status -acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state); +void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state); acpi_status acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 254f4b0..6213b27 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -1074,14 +1074,21 @@ struct acpi_resource_source { char *string_ptr; }; +/* Fields common to all address descriptors, 16/32/64 bit */ + +#define ACPI_RESOURCE_ADDRESS_COMMON \ + u32 resource_type; \ + u32 producer_consumer; \ + u32 decode; \ + u32 min_address_fixed; \ + u32 max_address_fixed; \ + union acpi_resource_attribute attribute; + +struct acpi_resource_address { +ACPI_RESOURCE_ADDRESS_COMMON}; + struct acpi_resource_address16 { - u32 resource_type; - u32 producer_consumer; - u32 decode; - u32 min_address_fixed; - u32 max_address_fixed; - union acpi_resource_attribute attribute; - u32 granularity; + ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; u32 min_address_range; u32 max_address_range; u32 address_translation_offset; @@ -1090,13 +1097,7 @@ struct acpi_resource_address16 { }; struct acpi_resource_address32 { - u32 resource_type; - u32 producer_consumer; - u32 decode; - u32 min_address_fixed; - u32 max_address_fixed; - union acpi_resource_attribute attribute; - u32 granularity; + ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; u32 min_address_range; u32 max_address_range; u32 address_translation_offset; @@ -1105,13 +1106,7 @@ struct acpi_resource_address32 { }; struct acpi_resource_address64 { - u32 resource_type; - u32 producer_consumer; - u32 decode; - u32 min_address_fixed; - u32 max_address_fixed; - union acpi_resource_attribute attribute; - u64 granularity; + ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; u64 min_address_range; u64 max_address_range; u64 address_translation_offset; @@ -1161,6 +1156,7 @@ union acpi_resource_data { struct acpi_resource_mem24 memory24; struct acpi_resource_mem32 memory32; struct acpi_resource_fixed_mem32 fixed_memory32; + struct acpi_resource_address address; /* Common 16/32/64 address fields */ struct acpi_resource_address16 address16; struct acpi_resource_address32 address32; struct acpi_resource_address64 address64; -- cgit v0.10.2 From 8713cbefafbb5a101ade541a4b0ffa108bf697cc Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 2 Sep 2005 17:16:48 -0400 Subject: [ACPI] add static to function definitions Signed-off-by: Adrian Bunk Signed-off-by: Len Brown diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index dc69d87..d528c75 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -1040,7 +1040,7 @@ static int __init acpi_wake_gpes_always_on_setup(char *str) __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); -int __init acpi_hotkey_setup(char *str) +static int __init acpi_hotkey_setup(char *str) { acpi_specific_hotkey_enabled = FALSE; return 1; diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c index a495568..2a718df 100644 --- a/drivers/acpi/pci_bind.c +++ b/drivers/acpi/pci_bind.c @@ -44,7 +44,8 @@ struct acpi_pci_data { struct pci_dev *dev; }; -void acpi_pci_data_handler(acpi_handle handle, u32 function, void *context) +static void acpi_pci_data_handler(acpi_handle handle, u32 function, + void *context) { ACPI_FUNCTION_TRACE("acpi_pci_data_handler"); diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 819cb0b..4217925 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -221,7 +221,7 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev) return_VALUE(0); } -int acpi_processor_errata(struct acpi_processor *pr) +static int acpi_processor_errata(struct acpi_processor *pr) { int result = 0; struct pci_dev *dev = NULL; diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 8a3ea41..c6db591 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -527,7 +527,7 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver) return_VALUE(0); } -int acpi_start_single_object(struct acpi_device *device) +static int acpi_start_single_object(struct acpi_device *device) { int result = 0; struct acpi_driver *driver; -- cgit v0.10.2 From 5f0110f2a716376f3b260703835f527ca8900946 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Sat, 3 Sep 2005 00:34:32 -0400 Subject: [ACPI] fix run-time error checking in acpi_pci_irq_disable() The 'bus' field in pci_dev structure should be checked before calling pci_read_config_byte() because pci_bus_read_config_byte() called by pci_read_config_byte() refers to 'bus' field. Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 2bbfba8..09567c2 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c @@ -500,7 +500,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev) ACPI_FUNCTION_TRACE("acpi_pci_irq_disable"); - if (!dev) + if (!dev || !dev->bus) return_VOID; pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); @@ -508,9 +508,6 @@ void acpi_pci_irq_disable(struct pci_dev *dev) return_VOID; pin--; - if (!dev->bus) - return_VOID; - /* * First we check the PCI IRQ routing table (PRT) for an IRQ. */ -- cgit v0.10.2 From dbed12da5bb06b15c63930e9282b45daea566d7b Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Sat, 3 Sep 2005 00:37:56 -0400 Subject: [ACPI] PNPACPI IRQ workaround for HP workstations Move pcibios_penalize_isa_irq() to pnpacpi_parse_allocated_irqresource(). Previously we passed the GSI, not the IRQ, and we did it even if parsing the IRQ resource failed. Parse IRQ descriptors that contain multiple interrupts. This violates the spec (in _CRS, only one interrupt per descriptor is allowed), but some firmware, e.g., HP rx7620 and rx8620 descriptions of HPET, has this bug. Signed-off-by: Bjorn Helgaas Cc: Adam Belay Signed-off-by: Andrew Morton Signed-off-by: Len Brown diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 1e296cb..6db549c 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -73,25 +73,35 @@ static void decode_irq_flags(int flag, int *edge_level, int *active_high_low) } static void -pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, int irq) +pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi, + int edge_level, int active_high_low) { int i = 0; + int irq; + + if (!valid_IRQ(gsi)) + return; + while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_IRQ) i++; - if (i < PNP_MAX_IRQ) { - res->irq_resource[i].flags = IORESOURCE_IRQ; //Also clears _UNSET flag - if (irq < 0) { - res->irq_resource[i].flags |= IORESOURCE_DISABLED; - return; - } - res->irq_resource[i].start =(unsigned long) irq; - res->irq_resource[i].end = (unsigned long) irq; + if (i >= PNP_MAX_IRQ) + return; + + res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag + irq = acpi_register_gsi(gsi, edge_level, active_high_low); + if (irq < 0) { + res->irq_resource[i].flags |= IORESOURCE_DISABLED; + return; } + + res->irq_resource[i].start = irq; + res->irq_resource[i].end = irq; + pcibios_penalize_isa_irq(irq, 1); } static void -pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma) +pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, u32 dma) { int i = 0; while (i < PNP_MAX_DMA && @@ -103,14 +113,14 @@ pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma) res->dma_resource[i].flags |= IORESOURCE_DISABLED; return; } - res->dma_resource[i].start =(unsigned long) dma; - res->dma_resource[i].end = (unsigned long) dma; + res->dma_resource[i].start = dma; + res->dma_resource[i].end = dma; } } static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table * res, - int io, int len) + u32 io, u32 len) { int i = 0; while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && @@ -122,14 +132,14 @@ pnpacpi_parse_allocated_ioresource(struct pnp_resource_table * res, res->port_resource[i].flags |= IORESOURCE_DISABLED; return; } - res->port_resource[i].start = (unsigned long) io; - res->port_resource[i].end = (unsigned long)(io + len - 1); + res->port_resource[i].start = io; + res->port_resource[i].end = io + len - 1; } } static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table * res, - int mem, int len) + u64 mem, u64 len) { int i = 0; while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && @@ -141,8 +151,8 @@ pnpacpi_parse_allocated_memresource(struct pnp_resource_table * res, res->mem_resource[i].flags |= IORESOURCE_DISABLED; return; } - res->mem_resource[i].start = (unsigned long) mem; - res->mem_resource[i].end = (unsigned long)(mem + len - 1); + res->mem_resource[i].start = mem; + res->mem_resource[i].end = mem + len - 1; } } @@ -151,27 +161,28 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, void *data) { struct pnp_resource_table * res_table = (struct pnp_resource_table *)data; + int i; switch (res->id) { case ACPI_RSTYPE_IRQ: - if ((res->data.irq.number_of_interrupts > 0) && - valid_IRQ(res->data.irq.interrupts[0])) { - pnpacpi_parse_allocated_irqresource(res_table, - acpi_register_gsi(res->data.irq.interrupts[0], - res->data.irq.edge_level, - res->data.irq.active_high_low)); - pcibios_penalize_isa_irq(res->data.irq.interrupts[0], 1); + /* + * Per spec, only one interrupt per descriptor is allowed in + * _CRS, but some firmware violates this, so parse them all. + */ + for (i = 0; i < res->data.irq.number_of_interrupts; i++) { + pnpacpi_parse_allocated_irqresource(res_table, + res->data.irq.interrupts[i], + res->data.irq.edge_level, + res->data.irq.active_high_low); } break; case ACPI_RSTYPE_EXT_IRQ: - if ((res->data.extended_irq.number_of_interrupts > 0) && - valid_IRQ(res->data.extended_irq.interrupts[0])) { - pnpacpi_parse_allocated_irqresource(res_table, - acpi_register_gsi(res->data.extended_irq.interrupts[0], - res->data.extended_irq.edge_level, - res->data.extended_irq.active_high_low)); - pcibios_penalize_isa_irq(res->data.extended_irq.interrupts[0], 1); + for (i = 0; i < res->data.extended_irq.number_of_interrupts; i++) { + pnpacpi_parse_allocated_irqresource(res_table, + res->data.extended_irq.interrupts[i], + res->data.extended_irq.edge_level, + res->data.extended_irq.active_high_low); } break; case ACPI_RSTYPE_DMA: -- cgit v0.10.2 From 9a31477a95d642dd42a1be7cc342f5902b56f584 Mon Sep 17 00:00:00 2001 From: Venkatesh Pallipadi Date: Tue, 30 Aug 2005 17:55:00 -0400 Subject: [ACPI] fix processor_core.c for NR_CPUS > 256 http://bugzilla.kernel.org/show_bug.cgi?id=5128 Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 4217925..ac2dfa6 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -413,18 +413,20 @@ static int acpi_processor_remove_fs(struct acpi_device *device) #define ARCH_BAD_APICID (0xff) #endif -static u8 convert_acpiid_to_cpu(u8 acpi_id) +static int convert_acpiid_to_cpu(u8 acpi_id, unsigned int *cpu_index) { u16 apic_id; - int i; + unsigned int i; apic_id = arch_acpiid_to_apicid[acpi_id]; if (apic_id == ARCH_BAD_APICID) return -1; for (i = 0; i < NR_CPUS; i++) { - if (arch_cpu_to_apicid[i] == apic_id) - return i; + if (arch_cpu_to_apicid[i] == apic_id) { + *cpu_index = i; + return 0; + } } return -1; } @@ -439,7 +441,8 @@ static int acpi_processor_get_info(struct acpi_processor *pr) acpi_status status = 0; union acpi_object object = { 0 }; struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; - u8 cpu_index; + unsigned int cpu_index; + int retval; static int cpu0_initialized; ACPI_FUNCTION_TRACE("acpi_processor_get_info"); @@ -482,10 +485,10 @@ static int acpi_processor_get_info(struct acpi_processor *pr) */ pr->acpi_id = object.processor.proc_id; - cpu_index = convert_acpiid_to_cpu(pr->acpi_id); + retval = convert_acpiid_to_cpu(pr->acpi_id, &cpu_index); /* Handle UP system running SMP kernel, with no LAPIC in MADT */ - if (!cpu0_initialized && (cpu_index == 0xff) && + if (!cpu0_initialized && retval && (num_online_cpus() == 1)) { cpu_index = 0; } @@ -499,10 +502,10 @@ static int acpi_processor_get_info(struct acpi_processor *pr) * less than the max # of CPUs. They should be ignored _iff * they are physically not present. */ - if (cpu_index >= NR_CPUS) { + if (retval) { if (ACPI_FAILURE (acpi_processor_hotadd_init(pr->handle, &pr->id))) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Error getting cpuindex for acpiid 0x%x\n", pr->acpi_id)); return_VALUE(-ENODEV); -- cgit v0.10.2 From 824b558bbe2c298b165cdb54c33718994dda30bb Mon Sep 17 00:00:00 2001 From: Luming Yu Date: Sun, 21 Aug 2005 19:17:00 -0400 Subject: [ACPI] acpi_video_device_write_state() now works http://bugzilla.kernel.org/show_bug.cgi?id=5060 Signed-off-by: Luming Yu Signed-off-by: Len Brown diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index b9132b5..e383d61 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -297,11 +297,12 @@ acpi_video_device_set_state(struct acpi_video_device *device, int state) int status; union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list args = { 1, &arg0 }; + unsigned long ret; ACPI_FUNCTION_TRACE("acpi_video_device_set_state"); arg0.integer.value = state; - status = acpi_evaluate_integer(device->handle, "_DSS", &args, NULL); + status = acpi_evaluate_integer(device->handle, "_DSS", &args, &ret); return_VALUE(status); } -- cgit v0.10.2 From 2413d2c12cf0dc5980d7b082d838d5468d83a8b9 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Sat, 3 Sep 2005 02:55:47 -0400 Subject: [ACPI] build fix - processor_core.c w/ !CONFIG_SMP http://bugzilla.kernel.org/show_bug.cgi?id=5128 Signed-off-by: Len Brown diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index ac2dfa6..40d4e62 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -400,7 +400,7 @@ static int acpi_processor_remove_fs(struct acpi_device *device) /* Use the acpiid in MADT to map cpus in case of SMP */ #ifndef CONFIG_SMP -#define convert_acpiid_to_cpu(acpi_id) (0xff) +#define convert_acpiid_to_cpu(acpi_id, cpu_indexp) (0xff) #else #ifdef CONFIG_IA64 -- cgit v0.10.2 From 4a35a46bf1cda4737c428380d1db5d15e2590d18 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Sat, 3 Sep 2005 12:40:06 -0400 Subject: [ACPI] revert bad processor_core.c patch for bug 5128 Signed-off-by: Len Brown diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 40d4e62..4217925 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -400,7 +400,7 @@ static int acpi_processor_remove_fs(struct acpi_device *device) /* Use the acpiid in MADT to map cpus in case of SMP */ #ifndef CONFIG_SMP -#define convert_acpiid_to_cpu(acpi_id, cpu_indexp) (0xff) +#define convert_acpiid_to_cpu(acpi_id) (0xff) #else #ifdef CONFIG_IA64 @@ -413,20 +413,18 @@ static int acpi_processor_remove_fs(struct acpi_device *device) #define ARCH_BAD_APICID (0xff) #endif -static int convert_acpiid_to_cpu(u8 acpi_id, unsigned int *cpu_index) +static u8 convert_acpiid_to_cpu(u8 acpi_id) { u16 apic_id; - unsigned int i; + int i; apic_id = arch_acpiid_to_apicid[acpi_id]; if (apic_id == ARCH_BAD_APICID) return -1; for (i = 0; i < NR_CPUS; i++) { - if (arch_cpu_to_apicid[i] == apic_id) { - *cpu_index = i; - return 0; - } + if (arch_cpu_to_apicid[i] == apic_id) + return i; } return -1; } @@ -441,8 +439,7 @@ static int acpi_processor_get_info(struct acpi_processor *pr) acpi_status status = 0; union acpi_object object = { 0 }; struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; - unsigned int cpu_index; - int retval; + u8 cpu_index; static int cpu0_initialized; ACPI_FUNCTION_TRACE("acpi_processor_get_info"); @@ -485,10 +482,10 @@ static int acpi_processor_get_info(struct acpi_processor *pr) */ pr->acpi_id = object.processor.proc_id; - retval = convert_acpiid_to_cpu(pr->acpi_id, &cpu_index); + cpu_index = convert_acpiid_to_cpu(pr->acpi_id); /* Handle UP system running SMP kernel, with no LAPIC in MADT */ - if (!cpu0_initialized && retval && + if (!cpu0_initialized && (cpu_index == 0xff) && (num_online_cpus() == 1)) { cpu_index = 0; } @@ -502,10 +499,10 @@ static int acpi_processor_get_info(struct acpi_processor *pr) * less than the max # of CPUs. They should be ignored _iff * they are physically not present. */ - if (retval) { + if (cpu_index >= NR_CPUS) { if (ACPI_FAILURE (acpi_processor_hotadd_init(pr->handle, &pr->id))) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting cpuindex for acpiid 0x%x\n", pr->acpi_id)); return_VALUE(-ENODEV); -- cgit v0.10.2 From cfe9e88866fe892f4f71bf132c64ec8bd5256e5e Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 4 Sep 2005 01:40:20 -0500 Subject: Input: rework psmouse attributes to reduce module size Rearrange attribute code to use generic show and set handlers instead of replicating them for every attribute; switch to using attribute_group instead of creating all attributes manually. All this saves about 4K. Signed-off-by: Dmitry Torokhov diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index 48d2b20..e65c279 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c @@ -150,12 +150,12 @@ static void ps2pp_set_smartscroll(struct psmouse *psmouse, unsigned int smartscr ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); } -static ssize_t psmouse_attr_show_smartscroll(struct psmouse *psmouse, char *buf) +static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse, void *data, char *buf) { return sprintf(buf, "%d\n", psmouse->smartscroll ? 1 : 0); } -static ssize_t psmouse_attr_set_smartscroll(struct psmouse *psmouse, const char *buf, size_t count) +static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count) { unsigned long value; char *rest; @@ -169,7 +169,8 @@ static ssize_t psmouse_attr_set_smartscroll(struct psmouse *psmouse, const char return count; } -PSMOUSE_DEFINE_ATTR(smartscroll); +PSMOUSE_DEFINE_ATTR(smartscroll, S_IWUSR | S_IRUGO, NULL, + ps2pp_attr_show_smartscroll, ps2pp_attr_set_smartscroll); /* * Support 800 dpi resolution _only_ if the user wants it (there are good @@ -194,7 +195,7 @@ static void ps2pp_set_resolution(struct psmouse *psmouse, unsigned int resolutio static void ps2pp_disconnect(struct psmouse *psmouse) { - device_remove_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_smartscroll); + device_remove_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_smartscroll.dattr); } static struct ps2pp_info *get_model_info(unsigned char model) @@ -379,7 +380,8 @@ int ps2pp_init(struct psmouse *psmouse, int set_properties) psmouse->set_resolution = ps2pp_set_resolution; psmouse->disconnect = ps2pp_disconnect; - device_create_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_smartscroll); + device_create_file(&psmouse->ps2dev.serio->dev, + &psmouse_attr_smartscroll.dattr); } } diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index b350827..0830c6e 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -58,10 +58,30 @@ static unsigned int psmouse_resetafter; module_param_named(resetafter, psmouse_resetafter, uint, 0644); MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never)."); -PSMOUSE_DEFINE_ATTR(protocol); -PSMOUSE_DEFINE_ATTR(rate); -PSMOUSE_DEFINE_ATTR(resolution); -PSMOUSE_DEFINE_ATTR(resetafter); +PSMOUSE_DEFINE_ATTR(protocol, S_IWUSR | S_IRUGO, + NULL, + psmouse_attr_show_protocol, psmouse_attr_set_protocol); +PSMOUSE_DEFINE_ATTR(rate, S_IWUSR | S_IRUGO, + (void *) offsetof(struct psmouse, rate), + psmouse_show_int_attr, psmouse_attr_set_rate); +PSMOUSE_DEFINE_ATTR(resolution, S_IWUSR | S_IRUGO, + (void *) offsetof(struct psmouse, resolution), + psmouse_show_int_attr, psmouse_attr_set_resolution); +PSMOUSE_DEFINE_ATTR(resetafter, S_IWUSR | S_IRUGO, + (void *) offsetof(struct psmouse, resetafter), + psmouse_show_int_attr, psmouse_set_int_attr); + +static struct attribute *psmouse_attributes[] = { + &psmouse_attr_protocol.dattr.attr, + &psmouse_attr_rate.dattr.attr, + &psmouse_attr_resolution.dattr.attr, + &psmouse_attr_resetafter.dattr.attr, + NULL +}; + +static struct attribute_group psmouse_attribute_group = { + .attrs = psmouse_attributes, +}; __obsolete_setup("psmouse_noext"); __obsolete_setup("psmouse_resolution="); @@ -800,10 +820,7 @@ static void psmouse_disconnect(struct serio *serio) psmouse = serio_get_drvdata(serio); - device_remove_file(&serio->dev, &psmouse_attr_protocol); - device_remove_file(&serio->dev, &psmouse_attr_rate); - device_remove_file(&serio->dev, &psmouse_attr_resolution); - device_remove_file(&serio->dev, &psmouse_attr_resetafter); + sysfs_remove_group(&serio->dev.kobj, &psmouse_attribute_group); down(&psmouse_sem); @@ -940,10 +957,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) if (parent && parent->pt_activate) parent->pt_activate(parent); - device_create_file(&serio->dev, &psmouse_attr_protocol); - device_create_file(&serio->dev, &psmouse_attr_rate); - device_create_file(&serio->dev, &psmouse_attr_resolution); - device_create_file(&serio->dev, &psmouse_attr_resetafter); + sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group); psmouse_activate(psmouse); @@ -1040,10 +1054,12 @@ static struct serio_driver psmouse_drv = { .cleanup = psmouse_cleanup, }; -ssize_t psmouse_attr_show_helper(struct device *dev, char *buf, - ssize_t (*handler)(struct psmouse *, char *)) +ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *devattr, + char *buf) { struct serio *serio = to_serio_port(dev); + struct psmouse_attribute *attr = to_psmouse_attr(devattr); + struct psmouse *psmouse; int retval; retval = serio_pin_driver(serio); @@ -1055,19 +1071,21 @@ ssize_t psmouse_attr_show_helper(struct device *dev, char *buf, goto out; } - retval = handler(serio_get_drvdata(serio), buf); + psmouse = serio_get_drvdata(serio); + + retval = attr->show(psmouse, attr->data, buf); out: serio_unpin_driver(serio); return retval; } -ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t count, - ssize_t (*handler)(struct psmouse *, const char *, size_t)) +ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *devattr, + const char *buf, size_t count) { struct serio *serio = to_serio_port(dev); - struct psmouse *psmouse = serio_get_drvdata(serio); - struct psmouse *parent = NULL; + struct psmouse_attribute *attr = to_psmouse_attr(devattr); + struct psmouse *psmouse, *parent = NULL; int retval; retval = serio_pin_driver(serio); @@ -1083,6 +1101,8 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun if (retval) goto out_unpin; + psmouse = serio_get_drvdata(serio); + if (psmouse->state == PSMOUSE_IGNORE) { retval = -ENODEV; goto out_up; @@ -1095,7 +1115,7 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun psmouse_deactivate(psmouse); - retval = handler(psmouse, buf, count); + retval = attr->set(psmouse, attr->data, buf, count); if (retval != -ENODEV) psmouse_activate(psmouse); @@ -1110,12 +1130,34 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun return retval; } -static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, char *buf) +static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char *buf) +{ + unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset); + + return sprintf(buf, "%lu\n", *field); +} + +static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count) +{ + unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset); + unsigned long value; + char *rest; + + value = simple_strtoul(buf, &rest, 10); + if (*rest) + return -EINVAL; + + *field = value; + + return count; +} + +static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, void *data, char *buf) { return sprintf(buf, "%s\n", psmouse_protocol_by_type(psmouse->type)->name); } -static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, const char *buf, size_t count) +static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, const char *buf, size_t count) { struct serio *serio = psmouse->ps2dev.serio; struct psmouse *parent = NULL; @@ -1179,12 +1221,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, const char *bu return count; } -static ssize_t psmouse_attr_show_rate(struct psmouse *psmouse, char *buf) -{ - return sprintf(buf, "%d\n", psmouse->rate); -} - -static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, const char *buf, size_t count) +static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) { unsigned long value; char *rest; @@ -1197,12 +1234,7 @@ static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, const char *buf, s return count; } -static ssize_t psmouse_attr_show_resolution(struct psmouse *psmouse, char *buf) -{ - return sprintf(buf, "%d\n", psmouse->resolution); -} - -static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, const char *buf, size_t count) +static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) { unsigned long value; char *rest; @@ -1215,23 +1247,6 @@ static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, const char * return count; } -static ssize_t psmouse_attr_show_resetafter(struct psmouse *psmouse, char *buf) -{ - return sprintf(buf, "%d\n", psmouse->resetafter); -} - -static ssize_t psmouse_attr_set_resetafter(struct psmouse *psmouse, const char *buf, size_t count) -{ - unsigned long value; - char *rest; - - value = simple_strtoul(buf, &rest, 10); - if (*rest) - return -EINVAL; - - psmouse->resetafter = value; - return count; -} static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) { diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index e312a6b..45d2bd7 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h @@ -86,24 +86,37 @@ int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); int psmouse_reset(struct psmouse *psmouse); void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); -ssize_t psmouse_attr_show_helper(struct device *dev, char *buf, - ssize_t (*handler)(struct psmouse *, char *)); -ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t count, - ssize_t (*handler)(struct psmouse *, const char *, size_t)); - -#define PSMOUSE_DEFINE_ATTR(_name) \ -static ssize_t psmouse_attr_show_##_name(struct psmouse *, char *); \ -static ssize_t psmouse_attr_set_##_name(struct psmouse *, const char *, size_t);\ -static ssize_t psmouse_do_show_##_name(struct device *d, struct device_attribute *attr, char *b) \ -{ \ - return psmouse_attr_show_helper(d, b, psmouse_attr_show_##_name); \ -} \ -static ssize_t psmouse_do_set_##_name(struct device *d, struct device_attribute *attr, const char *b, size_t s)\ -{ \ - return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \ -} \ -static struct device_attribute psmouse_attr_##_name = \ - __ATTR(_name, S_IWUSR | S_IRUGO, \ - psmouse_do_show_##_name, psmouse_do_set_##_name); + +struct psmouse_attribute { + struct device_attribute dattr; + void *data; + ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf); + ssize_t (*set)(struct psmouse *psmouse, void *data, + const char *buf, size_t count); +}; +#define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr) + +ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr, + char *buf); +ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); + +#define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \ +static ssize_t _show(struct psmouse *, void *data, char *); \ +static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \ +static struct psmouse_attribute psmouse_attr_##_name = { \ + .dattr = { \ + .attr = { \ + .name = __stringify(_name), \ + .mode = _mode, \ + .owner = THIS_MODULE, \ + }, \ + .show = psmouse_attr_show_helper, \ + .store = psmouse_attr_set_helper, \ + }, \ + .data = _data, \ + .show = _show, \ + .set = _set, \ +} #endif /* _PSMOUSE_H */ diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index aee3b24..b4898d8 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c @@ -19,54 +19,6 @@ #include "psmouse.h" #include "trackpoint.h" -PSMOUSE_DEFINE_ATTR(sensitivity); -PSMOUSE_DEFINE_ATTR(speed); -PSMOUSE_DEFINE_ATTR(inertia); -PSMOUSE_DEFINE_ATTR(reach); -PSMOUSE_DEFINE_ATTR(draghys); -PSMOUSE_DEFINE_ATTR(mindrag); -PSMOUSE_DEFINE_ATTR(thresh); -PSMOUSE_DEFINE_ATTR(upthresh); -PSMOUSE_DEFINE_ATTR(ztime); -PSMOUSE_DEFINE_ATTR(jenks); -PSMOUSE_DEFINE_ATTR(press_to_select); -PSMOUSE_DEFINE_ATTR(skipback); -PSMOUSE_DEFINE_ATTR(ext_dev); - -#define MAKE_ATTR_READ(_item) \ - static ssize_t psmouse_attr_show_##_item(struct psmouse *psmouse, char *buf) \ - { \ - struct trackpoint_data *tp = psmouse->private; \ - return sprintf(buf, "%lu\n", (unsigned long)tp->_item); \ - } - -#define MAKE_ATTR_WRITE(_item, command) \ - static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse, const char *buf, size_t count) \ - { \ - char *rest; \ - unsigned long value; \ - struct trackpoint_data *tp = psmouse->private; \ - value = simple_strtoul(buf, &rest, 10); \ - if (*rest) \ - return -EINVAL; \ - tp->_item = value; \ - trackpoint_write(&psmouse->ps2dev, command, tp->_item); \ - return count; \ - } - -#define MAKE_ATTR_TOGGLE(_item, command, mask) \ - static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse, const char *buf, size_t count) \ - { \ - unsigned char toggle; \ - struct trackpoint_data *tp = psmouse->private; \ - toggle = (buf[0] == '1') ? 1 : 0; \ - if (toggle != tp->_item) { \ - tp->_item = toggle; \ - trackpoint_toggle_bit(&psmouse->ps2dev, command, mask); \ - } \ - return count; \ - } - /* * Device IO: read, write and toggle bit */ @@ -108,59 +60,114 @@ static int trackpoint_toggle_bit(struct ps2dev *ps2dev, unsigned char loc, unsig return 0; } -MAKE_ATTR_WRITE(sensitivity, TP_SENS); -MAKE_ATTR_READ(sensitivity); - -MAKE_ATTR_WRITE(speed, TP_SPEED); -MAKE_ATTR_READ(speed); -MAKE_ATTR_WRITE(inertia, TP_INERTIA); -MAKE_ATTR_READ(inertia); +/* + * Trackpoint-specific attributes + */ +struct trackpoint_attr_data { + size_t field_offset; + unsigned char command; + unsigned char mask; +}; -MAKE_ATTR_WRITE(reach, TP_REACH); -MAKE_ATTR_READ(reach); +static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse, void *data, char *buf) +{ + struct trackpoint_data *tp = psmouse->private; + struct trackpoint_attr_data *attr = data; + unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); -MAKE_ATTR_WRITE(draghys, TP_DRAGHYS); -MAKE_ATTR_READ(draghys); + return sprintf(buf, "%u\n", *field); +} -MAKE_ATTR_WRITE(mindrag, TP_MINDRAG); -MAKE_ATTR_READ(mindrag); +static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data, + const char *buf, size_t count) +{ + struct trackpoint_data *tp = psmouse->private; + struct trackpoint_attr_data *attr = data; + unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); + unsigned long value; + char *rest; -MAKE_ATTR_WRITE(thresh, TP_THRESH); -MAKE_ATTR_READ(thresh); + value = simple_strtoul(buf, &rest, 10); + if (*rest || value > 255) + return -EINVAL; -MAKE_ATTR_WRITE(upthresh, TP_UP_THRESH); -MAKE_ATTR_READ(upthresh); + *field = value; + trackpoint_write(&psmouse->ps2dev, attr->command, value); -MAKE_ATTR_WRITE(ztime, TP_Z_TIME); -MAKE_ATTR_READ(ztime); + return count; +} -MAKE_ATTR_WRITE(jenks, TP_JENKS_CURV); -MAKE_ATTR_READ(jenks); +#define TRACKPOINT_INT_ATTR(_name, _command) \ + static struct trackpoint_attr_data trackpoint_attr_##_name = { \ + .field_offset = offsetof(struct trackpoint_data, _name), \ + .command = _command, \ + }; \ + PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ + &trackpoint_attr_##_name, \ + trackpoint_show_int_attr, trackpoint_set_int_attr) + +static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data, + const char *buf, size_t count) +{ + struct trackpoint_data *tp = psmouse->private; + struct trackpoint_attr_data *attr = data; + unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); + unsigned long value; + char *rest; + + value = simple_strtoul(buf, &rest, 10); + if (*rest || value > 1) + return -EINVAL; + + if (*field != value) { + *field = value; + trackpoint_toggle_bit(&psmouse->ps2dev, attr->command, attr->mask); + } -MAKE_ATTR_TOGGLE(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON); -MAKE_ATTR_READ(press_to_select); + return count; +} -MAKE_ATTR_TOGGLE(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); -MAKE_ATTR_READ(skipback); -MAKE_ATTR_TOGGLE(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); -MAKE_ATTR_READ(ext_dev); +#define TRACKPOINT_BIT_ATTR(_name, _command, _mask) \ + static struct trackpoint_attr_data trackpoint_attr_##_name = { \ + .field_offset = offsetof(struct trackpoint_data, _name), \ + .command = _command, \ + .mask = _mask, \ + }; \ + PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ + &trackpoint_attr_##_name, \ + trackpoint_show_int_attr, trackpoint_set_bit_attr) + +TRACKPOINT_INT_ATTR(sensitivity, TP_SENS); +TRACKPOINT_INT_ATTR(speed, TP_SPEED); +TRACKPOINT_INT_ATTR(inertia, TP_INERTIA); +TRACKPOINT_INT_ATTR(reach, TP_REACH); +TRACKPOINT_INT_ATTR(draghys, TP_DRAGHYS); +TRACKPOINT_INT_ATTR(mindrag, TP_MINDRAG); +TRACKPOINT_INT_ATTR(thresh, TP_THRESH); +TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH); +TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME); +TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV); + +TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON); +TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); +TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); static struct attribute *trackpoint_attrs[] = { - &psmouse_attr_sensitivity.attr, - &psmouse_attr_speed.attr, - &psmouse_attr_inertia.attr, - &psmouse_attr_reach.attr, - &psmouse_attr_draghys.attr, - &psmouse_attr_mindrag.attr, - &psmouse_attr_thresh.attr, - &psmouse_attr_upthresh.attr, - &psmouse_attr_ztime.attr, - &psmouse_attr_jenks.attr, - &psmouse_attr_press_to_select.attr, - &psmouse_attr_skipback.attr, - &psmouse_attr_ext_dev.attr, + &psmouse_attr_sensitivity.dattr.attr, + &psmouse_attr_speed.dattr.attr, + &psmouse_attr_inertia.dattr.attr, + &psmouse_attr_reach.dattr.attr, + &psmouse_attr_draghys.dattr.attr, + &psmouse_attr_mindrag.dattr.attr, + &psmouse_attr_thresh.dattr.attr, + &psmouse_attr_upthresh.dattr.attr, + &psmouse_attr_ztime.dattr.attr, + &psmouse_attr_jenks.dattr.attr, + &psmouse_attr_press_to_select.dattr.attr, + &psmouse_attr_skipback.dattr.attr, + &psmouse_attr_ext_dev.dattr.attr, NULL }; -- cgit v0.10.2 From e6c047b98bbd09473c586744c681e877ebf954ff Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Sun, 4 Sep 2005 01:40:43 -0500 Subject: Input: ALPS - fix wheel decoding Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 0d68e5e..b20783f 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -170,7 +170,7 @@ static void alps_process_packet(struct psmouse *psmouse, struct pt_regs *regs) input_report_key(dev, BTN_TOOL_FINGER, z > 0); if (priv->i->flags & ALPS_WHEEL) - input_report_rel(dev, REL_WHEEL, ((packet[0] >> 4) & 0x07) | ((packet[2] >> 2) & 0x08)); + input_report_rel(dev, REL_WHEEL, ((packet[2] << 1) & 0x08) - ((packet[0] >> 4) & 0x07)); if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { input_report_key(dev, BTN_FORWARD, forward); -- cgit v0.10.2 From d2b5ffca73594e4046f405e3ef2438ce41f76fb2 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Sun, 4 Sep 2005 01:40:55 -0500 Subject: Input: psmouse - add new Logitech wheel mouse model Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index e65c279..7df9652 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c @@ -223,6 +223,7 @@ static struct ps2pp_info *get_model_info(unsigned char model) { 80, PS2PP_KIND_WHEEL, PS2PP_SIDE_BTN | PS2PP_WHEEL }, { 81, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 83, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, + { 86, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 88, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 96, 0, 0 }, { 97, PS2PP_KIND_TP3, PS2PP_WHEEL | PS2PP_HWHEEL }, -- cgit v0.10.2 From 4cee99564db7f65a6f88e4b752da52768cde3802 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Sun, 4 Sep 2005 01:41:14 -0500 Subject: Input: fix checking whether new keycode fits size-wise When dev->keycodesize == sizeof(int) the old code produces incorrect result. Signed-off-by: Ian Campbell Signed-off-by: Dmitry Torokhov diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 523fd3c..1ddaabe 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c @@ -200,7 +200,7 @@ int setkeycode(unsigned int scancode, unsigned int keycode) return -EINVAL; if (keycode < 0 || keycode > KEY_MAX) return -EINVAL; - if (keycode >> (dev->keycodesize * 8)) + if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8))) return -EINVAL; oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode); diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 20e3a16..3a8314b 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -320,7 +320,7 @@ static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (t < 0 || t >= dev->keycodemax || !dev->keycodesize) return -EINVAL; if (get_user(v, ip + 1)) return -EFAULT; if (v < 0 || v > KEY_MAX) return -EINVAL; - if (v >> (dev->keycodesize * 8)) return -EINVAL; + if (dev->keycodesize < sizeof(v) && (v >> (dev->keycodesize * 8))) return -EINVAL; u = SET_INPUT_KEYCODE(dev, t, v); clear_bit(u, dev->keybit); set_bit(v, dev->keybit); -- cgit v0.10.2 From 0854e52d86080c1043bc8988daef2ebda4775f64 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 4 Sep 2005 01:41:27 -0500 Subject: Input: i8042 - clean up initialization code; abort if we can't create all ports. Signed-off-by: Dmitry Torokhov diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 708a1d3..f0d9c5f 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -338,10 +338,10 @@ static int i8042_open(struct serio *serio) return 0; -activate_fail: + activate_fail: free_irq(port->irq, i8042_request_irq_cookie); -irq_fail: + irq_fail: serio_unregister_port_delayed(serio); return -1; @@ -485,7 +485,7 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id, struct pt_regs *regs) serio_interrupt(port->serio, data, dfl, regs); ret = 1; -out: + out: return IRQ_RETVAL(ret); } @@ -552,7 +552,7 @@ static int i8042_enable_mux_ports(void) * Enable all muxed ports. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < I8042_NUM_MUX_PORTS; i++) { i8042_command(¶m, I8042_CMD_MUX_PFX + i); i8042_command(¶m, I8042_CMD_AUX_ENABLE); } @@ -682,7 +682,7 @@ static int __init i8042_port_register(struct i8042_port *port) kfree(port->serio); port->serio = NULL; i8042_ctr |= port->disable; - return -1; + return -EIO; } printk(KERN_INFO "serio: i8042 %s port at %#lx,%#lx irq %d\n", @@ -977,80 +977,83 @@ static struct device_driver i8042_driver = { .shutdown = i8042_shutdown, }; -static void __init i8042_create_kbd_port(void) +static int __init i8042_create_kbd_port(void) { struct serio *serio; struct i8042_port *port = &i8042_ports[I8042_KBD_PORT_NO]; - serio = kmalloc(sizeof(struct serio), GFP_KERNEL); - if (serio) { - memset(serio, 0, sizeof(struct serio)); - serio->id.type = i8042_direct ? SERIO_8042 : SERIO_8042_XL; - serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write; - serio->open = i8042_open; - serio->close = i8042_close; - serio->start = i8042_start; - serio->stop = i8042_stop; - serio->port_data = port; - serio->dev.parent = &i8042_platform_device->dev; - strlcpy(serio->name, "i8042 Kbd Port", sizeof(serio->name)); - strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); - - port->serio = serio; - i8042_port_register(port); - } + serio = kcalloc(1, sizeof(struct serio), GFP_KERNEL); + if (!serio) + return -ENOMEM; + + serio->id.type = i8042_direct ? SERIO_8042 : SERIO_8042_XL; + serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write; + serio->open = i8042_open; + serio->close = i8042_close; + serio->start = i8042_start; + serio->stop = i8042_stop; + serio->port_data = port; + serio->dev.parent = &i8042_platform_device->dev; + strlcpy(serio->name, "i8042 Kbd Port", sizeof(serio->name)); + strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); + + port->serio = serio; + + return i8042_port_register(port); } -static void __init i8042_create_aux_port(void) +static int __init i8042_create_aux_port(void) { struct serio *serio; struct i8042_port *port = &i8042_ports[I8042_AUX_PORT_NO]; - serio = kmalloc(sizeof(struct serio), GFP_KERNEL); - if (serio) { - memset(serio, 0, sizeof(struct serio)); - serio->id.type = SERIO_8042; - serio->write = i8042_aux_write; - serio->open = i8042_open; - serio->close = i8042_close; - serio->start = i8042_start; - serio->stop = i8042_stop; - serio->port_data = port; - serio->dev.parent = &i8042_platform_device->dev; - strlcpy(serio->name, "i8042 Aux Port", sizeof(serio->name)); - strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); - - port->serio = serio; - i8042_port_register(port); - } + serio = kcalloc(1, sizeof(struct serio), GFP_KERNEL); + if (!serio) + return -ENOMEM; + + serio->id.type = SERIO_8042; + serio->write = i8042_aux_write; + serio->open = i8042_open; + serio->close = i8042_close; + serio->start = i8042_start; + serio->stop = i8042_stop; + serio->port_data = port; + serio->dev.parent = &i8042_platform_device->dev; + strlcpy(serio->name, "i8042 Aux Port", sizeof(serio->name)); + strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); + + port->serio = serio; + + return i8042_port_register(port); } -static void __init i8042_create_mux_port(int index) +static int __init i8042_create_mux_port(int index) { struct serio *serio; struct i8042_port *port = &i8042_ports[I8042_MUX_PORT_NO + index]; - serio = kmalloc(sizeof(struct serio), GFP_KERNEL); - if (serio) { - memset(serio, 0, sizeof(struct serio)); - serio->id.type = SERIO_8042; - serio->write = i8042_aux_write; - serio->open = i8042_open; - serio->close = i8042_close; - serio->start = i8042_start; - serio->stop = i8042_stop; - serio->port_data = port; - serio->dev.parent = &i8042_platform_device->dev; - snprintf(serio->name, sizeof(serio->name), "i8042 Aux-%d Port", index); - snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, index + 1); - - *port = i8042_ports[I8042_AUX_PORT_NO]; - port->exists = 0; - snprintf(port->name, sizeof(port->name), "AUX%d", index); - port->mux = index; - port->serio = serio; - i8042_port_register(port); - } + serio = kcalloc(1, sizeof(struct serio), GFP_KERNEL); + if (!serio) + return -ENOMEM; + + serio->id.type = SERIO_8042; + serio->write = i8042_aux_write; + serio->open = i8042_open; + serio->close = i8042_close; + serio->start = i8042_start; + serio->stop = i8042_stop; + serio->port_data = port; + serio->dev.parent = &i8042_platform_device->dev; + snprintf(serio->name, sizeof(serio->name), "i8042 Aux-%d Port", index); + snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, index + 1); + + *port = i8042_ports[I8042_AUX_PORT_NO]; + port->exists = 0; + snprintf(port->name, sizeof(port->name), "AUX%d", index); + port->mux = index; + port->serio = serio; + + return i8042_port_register(port); } static int __init i8042_init(void) @@ -1070,36 +1073,55 @@ static int __init i8042_init(void) i8042_ports[I8042_KBD_PORT_NO].irq = I8042_KBD_IRQ; if (i8042_controller_init()) { - i8042_platform_exit(); - return -ENODEV; + err = -ENODEV; + goto err_platform_exit; } err = driver_register(&i8042_driver); - if (err) { - i8042_platform_exit(); - return err; - } + if (err) + goto err_controller_cleanup; i8042_platform_device = platform_device_register_simple("i8042", -1, NULL, 0); if (IS_ERR(i8042_platform_device)) { - driver_unregister(&i8042_driver); - i8042_platform_exit(); - return PTR_ERR(i8042_platform_device); + err = PTR_ERR(i8042_platform_device); + goto err_unregister_driver; } if (!i8042_noaux && !i8042_check_aux()) { - if (!i8042_nomux && !i8042_check_mux()) - for (i = 0; i < I8042_NUM_MUX_PORTS; i++) - i8042_create_mux_port(i); - else - i8042_create_aux_port(); + if (!i8042_nomux && !i8042_check_mux()) { + for (i = 0; i < I8042_NUM_MUX_PORTS; i++) { + err = i8042_create_mux_port(i); + if (err) + goto err_unregister_ports; + } + } else { + err = i8042_create_aux_port(); + if (err) + goto err_unregister_ports; + } } - i8042_create_kbd_port(); + err = i8042_create_kbd_port(); + if (err) + goto err_unregister_ports; mod_timer(&i8042_timer, jiffies + I8042_POLL_PERIOD); return 0; + + err_unregister_ports: + for (i = 0; i < I8042_NUM_PORTS; i++) + if (i8042_ports[i].serio) + serio_unregister_port(i8042_ports[i].serio); + platform_device_unregister(i8042_platform_device); + err_unregister_driver: + driver_unregister(&i8042_driver); + err_controller_cleanup: + i8042_controller_cleanup(); + err_platform_exit: + i8042_platform_exit(); + + return err; } static void __exit i8042_exit(void) -- cgit v0.10.2 From 8d5987a6e17fa36776a0c9964db0f24c3d070862 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 4 Sep 2005 01:41:38 -0500 Subject: Input: make i8042_platform_init return 'real' error code Signed-off-by: Dmitry Torokhov diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h index c9e633d..9a92216 100644 --- a/drivers/input/serio/i8042-io.h +++ b/drivers/input/serio/i8042-io.h @@ -69,16 +69,16 @@ static inline int i8042_platform_init(void) */ #if !defined(__sh__) && !defined(__alpha__) && !defined(__mips__) && !defined(CONFIG_PPC64) if (!request_region(I8042_DATA_REG, 16, "i8042")) - return -1; + return -EBUSY; #endif i8042_reset = 1; #if defined(CONFIG_PPC64) if (check_legacy_ioport(I8042_DATA_REG)) - return -1; + return -EBUSY; if (!request_region(I8042_DATA_REG, 16, "i8042")) - return -1; + return -EBUSY; #endif return 0; } diff --git a/drivers/input/serio/i8042-ip22io.h b/drivers/input/serio/i8042-ip22io.h index 863b9c9..ee1ad27 100644 --- a/drivers/input/serio/i8042-ip22io.h +++ b/drivers/input/serio/i8042-ip22io.h @@ -58,7 +58,7 @@ static inline int i8042_platform_init(void) #if 0 /* XXX sgi_kh is a virtual address */ if (!request_mem_region(sgi_kh, sizeof(struct hpc_keyb), "i8042")) - return 1; + return -EBUSY; #endif i8042_reset = 1; diff --git a/drivers/input/serio/i8042-jazzio.h b/drivers/input/serio/i8042-jazzio.h index 5c20ab1..13fd710 100644 --- a/drivers/input/serio/i8042-jazzio.h +++ b/drivers/input/serio/i8042-jazzio.h @@ -53,7 +53,7 @@ static inline int i8042_platform_init(void) #if 0 /* XXX JAZZ_KEYBOARD_ADDRESS is a virtual address */ if (!request_mem_region(JAZZ_KEYBOARD_ADDRESS, 2, "i8042")) - return 1; + return -EBUSY; #endif return 0; diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h index da2a198..ed9446f 100644 --- a/drivers/input/serio/i8042-sparcio.h +++ b/drivers/input/serio/i8042-sparcio.h @@ -48,10 +48,10 @@ static inline void i8042_write_command(int val) #define OBP_PS2MS_NAME1 "kdmouse" #define OBP_PS2MS_NAME2 "mouse" -static int i8042_platform_init(void) +static int __init i8042_platform_init(void) { #ifndef CONFIG_PCI - return -1; + return -ENODEV; #else char prop[128]; int len; @@ -59,14 +59,14 @@ static int i8042_platform_init(void) len = prom_getproperty(prom_root_node, "name", prop, sizeof(prop)); if (len < 0) { printk("i8042: Cannot get name property of root OBP node.\n"); - return -1; + return -ENODEV; } if (strncmp(prop, "SUNW,JavaStation-1", len) == 0) { /* Hardcoded values for MrCoffee. */ i8042_kbd_irq = i8042_aux_irq = 13 | 0x20; kbd_iobase = ioremap(0x71300060, 8); if (!kbd_iobase) - return -1; + return -ENODEV; } else { struct linux_ebus *ebus; struct linux_ebus_device *edev; @@ -78,7 +78,7 @@ static int i8042_platform_init(void) goto edev_found; } } - return -1; + return -ENODEV; edev_found: for_each_edevchild(edev, child) { @@ -96,7 +96,7 @@ static int i8042_platform_init(void) i8042_aux_irq == -1) { printk("i8042: Error, 8042 device lacks both kbd and " "mouse nodes.\n"); - return -1; + return -ENODEV; } } diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 03877c8..02bc231 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -256,7 +256,7 @@ static void i8042_pnp_exit(void) } } -static int i8042_pnp_init(void) +static int __init i8042_pnp_init(void) { int result_kbd, result_aux; @@ -322,25 +322,29 @@ static int i8042_pnp_init(void) return 0; } +#else +static inline int i8042_pnp_init(void) { return 0; } +static inline void i8042_pnp_exit(void) { } #endif -static inline int i8042_platform_init(void) +static int __init i8042_platform_init(void) { + int retval; + /* * On ix86 platforms touching the i8042 data register region can do really * bad things. Because of this the region is always reserved on ix86 boxes. * * if (!request_region(I8042_DATA_REG, 16, "i8042")) - * return -1; + * return -EBUSY; */ i8042_kbd_irq = I8042_MAP_IRQ(1); i8042_aux_irq = I8042_MAP_IRQ(12); -#ifdef CONFIG_PNP - if (i8042_pnp_init()) - return -1; -#endif + retval = i8042_pnp_init(); + if (retval) + return retval; #if defined(__ia64__) i8042_reset = 1; @@ -354,14 +358,12 @@ static inline int i8042_platform_init(void) i8042_nomux = 1; #endif - return 0; + return retval; } static inline void i8042_platform_exit(void) { -#ifdef CONFIG_PNP i8042_pnp_exit(); -#endif } #endif /* _I8042_X86IA64IO_H */ diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index f0d9c5f..2a76d08 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -1066,8 +1066,9 @@ static int __init i8042_init(void) init_timer(&i8042_timer); i8042_timer.function = i8042_timer_func; - if (i8042_platform_init()) - return -EBUSY; + err = i8042_platform_init(); + if (err) + return err; i8042_ports[I8042_AUX_PORT_NO].irq = I8042_AUX_IRQ; i8042_ports[I8042_KBD_PORT_NO].irq = I8042_KBD_IRQ; -- cgit v0.10.2 From c3d31e7f9a94800ba895a081e143e79954f6c62f Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 4 Sep 2005 01:41:51 -0500 Subject: Input: i8042 - fix IRQ printing when either KBD or AUX port is absent from ACPI/PNP tables. Signed-off-by: Dmitry Torokhov diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 02bc231..84a73bc 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -258,7 +258,8 @@ static void i8042_pnp_exit(void) static int __init i8042_pnp_init(void) { - int result_kbd, result_aux; + int result_kbd = 0, result_aux = 0; + char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 }; if (i8042_nopnp) { printk(KERN_INFO "i8042: PNP detection disabled\n"); @@ -267,6 +268,7 @@ static int __init i8042_pnp_init(void) if ((result_kbd = pnp_register_driver(&i8042_pnp_kbd_driver)) >= 0) i8042_pnp_kbd_registered = 1; + if ((result_aux = pnp_register_driver(&i8042_pnp_aux_driver)) >= 0) i8042_pnp_aux_registered = 1; @@ -280,6 +282,25 @@ static int __init i8042_pnp_init(void) #endif } + if (result_kbd > 0) + snprintf(kbd_irq_str, sizeof(kbd_irq_str), + "%d", i8042_pnp_kbd_irq); + if (result_aux > 0) + snprintf(aux_irq_str, sizeof(aux_irq_str), + "%d", i8042_pnp_aux_irq); + + printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n", + i8042_pnp_kbd_name, (result_kbd > 0 && result_aux > 0) ? "," : "", + i8042_pnp_aux_name, + i8042_pnp_data_reg, i8042_pnp_command_reg, + kbd_irq_str, (result_kbd > 0 && result_aux > 0) ? "," : "", + aux_irq_str); + +#if defined(__ia64__) + if (result_aux <= 0) + i8042_noaux = 1; +#endif + if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) && i8042_pnp_data_reg != i8042_data_reg) || !i8042_pnp_data_reg) { printk(KERN_WARNING "PNP: PS/2 controller has invalid data port %#x; using default %#x\n", @@ -295,30 +316,20 @@ static int __init i8042_pnp_init(void) } if (!i8042_pnp_kbd_irq) { - printk(KERN_WARNING "PNP: PS/2 controller doesn't have KBD irq; using default %#x\n", i8042_kbd_irq); + printk(KERN_WARNING "PNP: PS/2 controller doesn't have KBD irq; using default %d\n", i8042_kbd_irq); i8042_pnp_kbd_irq = i8042_kbd_irq; } - if (!i8042_pnp_aux_irq) { - printk(KERN_WARNING "PNP: PS/2 controller doesn't have AUX irq; using default %#x\n", i8042_aux_irq); + if (!i8042_noaux && !i8042_pnp_aux_irq) { + printk(KERN_WARNING "PNP: PS/2 controller doesn't have AUX irq; using default %d\n", i8042_aux_irq); i8042_pnp_aux_irq = i8042_aux_irq; } -#if defined(__ia64__) - if (result_aux <= 0) - i8042_noaux = 1; -#endif - i8042_data_reg = i8042_pnp_data_reg; i8042_command_reg = i8042_pnp_command_reg; i8042_kbd_irq = i8042_pnp_kbd_irq; i8042_aux_irq = i8042_pnp_aux_irq; - printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %d%s%d\n", - i8042_pnp_kbd_name, (result_kbd > 0 && result_aux > 0) ? "," : "", i8042_pnp_aux_name, - i8042_data_reg, i8042_command_reg, i8042_kbd_irq, - (result_aux > 0) ? "," : "", i8042_aux_irq); - return 0; } -- cgit v0.10.2 From 945ef0d428bc33c639e49d27fb8cc765adec3fdf Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 4 Sep 2005 01:42:00 -0500 Subject: Input: i8042 - add i8042.nokbd module option to allow supressing creation of keyboard port. Signed-off-by: Dmitry Torokhov diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 3d5cd7a..111e980 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -549,6 +549,7 @@ running once the system is up. keyboard and can not control its state (Don't attempt to blink the leds) i8042.noaux [HW] Don't check for auxiliary (== mouse) port + i8042.nokbd [HW] Don't check/create keyboard port i8042.nomux [HW] Don't check presence of an active multiplexing controller i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 84a73bc..d5ea3cf 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -297,6 +297,8 @@ static int __init i8042_pnp_init(void) aux_irq_str); #if defined(__ia64__) + if (result_kbd <= 0) + i8042_nokbd = 1; if (result_aux <= 0) i8042_noaux = 1; #endif @@ -315,7 +317,7 @@ static int __init i8042_pnp_init(void) i8042_pnp_command_reg = i8042_command_reg; } - if (!i8042_pnp_kbd_irq) { + if (!i8042_nokbd && !i8042_pnp_kbd_irq) { printk(KERN_WARNING "PNP: PS/2 controller doesn't have KBD irq; using default %d\n", i8042_kbd_irq); i8042_pnp_kbd_irq = i8042_kbd_irq; } diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 2a76d08..19ef35d 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -27,6 +27,10 @@ MODULE_AUTHOR("Vojtech Pavlik "); MODULE_DESCRIPTION("i8042 keyboard and mouse controller driver"); MODULE_LICENSE("GPL"); +static unsigned int i8042_nokbd; +module_param_named(nokbd, i8042_nokbd, bool, 0); +MODULE_PARM_DESC(nokbd, "Do not probe or use KBD port."); + static unsigned int i8042_noaux; module_param_named(noaux, i8042_noaux, bool, 0); MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port."); @@ -1058,7 +1062,7 @@ static int __init i8042_create_mux_port(int index) static int __init i8042_init(void) { - int i; + int i, have_ports = 0; int err; dbg_init(); @@ -1100,11 +1104,20 @@ static int __init i8042_init(void) if (err) goto err_unregister_ports; } + have_ports = 1; } - err = i8042_create_kbd_port(); - if (err) - goto err_unregister_ports; + if (!i8042_nokbd) { + err = i8042_create_kbd_port(); + if (err) + goto err_unregister_ports; + have_ports = 1; + } + + if (!have_ports) { + err = -ENODEV; + goto err_unregister_device; + } mod_timer(&i8042_timer, jiffies + I8042_POLL_PERIOD); @@ -1114,6 +1127,7 @@ static int __init i8042_init(void) for (i = 0; i < I8042_NUM_PORTS; i++) if (i8042_ports[i].serio) serio_unregister_port(i8042_ports[i].serio); + err_unregister_device: platform_device_unregister(i8042_platform_device); err_unregister_driver: driver_unregister(&i8042_driver); -- cgit v0.10.2 From 7545c24c6a6ab62922266197a72119212280ea2a Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 4 Sep 2005 01:42:10 -0500 Subject: Input: i8042 - add Lifebook E4010 to MUX blacklist Signed-off-by: Dmitry Torokhov diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index d5ea3cf..273bb3b 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -138,6 +138,13 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = { }, }, { + .ident = "Fujitsu-Siemens Lifebook E4010", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"), + }, + }, + { .ident = "Toshiba P10", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), -- cgit v0.10.2 From b8c9c642db4ab0811cc5bb0d8b90cc7819055c95 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:07:37 -0500 Subject: Inpur: recognize and ignore Logitech vendor usages in HID These get in our way with MX mice. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 63a4db7..3b162a1 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -296,6 +296,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel break; case HID_UP_MSVENDOR: + case HID_UP_LOGIVENDOR: goto ignore; diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index c1b6b69..f3b85a0 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -182,6 +182,7 @@ struct hid_item { #define HID_UP_PID 0x000f0000 #define HID_UP_HPVENDOR 0xff7f0000 #define HID_UP_MSVENDOR 0xff000000 +#define HID_UP_LOGIVENDOR 0x00ff0000 #define HID_USAGE 0x0000ffff -- cgit v0.10.2 From 0aebfdac042b63d0f2625414062e138a4333181c Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:07:59 -0500 Subject: Input: add HID simulation mappings Add simulation usage page mappings to hid-input.c to support a new crop of joysticks using them to designate Rudder and Throttle controls. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/usb/input/hid-debug.h b/drivers/usb/input/hid-debug.h index 52437e5..789df80 100644 --- a/drivers/usb/input/hid-debug.h +++ b/drivers/usb/input/hid-debug.h @@ -85,6 +85,23 @@ static const struct hid_usage_entry hid_usage_table[] = { {0, 0x91, "D-PadDown"}, {0, 0x92, "D-PadRight"}, {0, 0x93, "D-PadLeft"}, + { 2, 0, "Simulation" }, + {0, 0xb0, "Aileron"}, + {0, 0xb1, "AileronTrim"}, + {0, 0xb2, "Anti-Torque"}, + {0, 0xb3, "Autopilot"}, + {0, 0xb4, "Chaff"}, + {0, 0xb5, "Collective"}, + {0, 0xb6, "DiveBrake"}, + {0, 0xb7, "ElectronicCountermeasures"}, + {0, 0xb8, "Elevator"}, + {0, 0xb9, "ElevatorTrim"}, + {0, 0xba, "Rudder"}, + {0, 0xbb, "Throttle"}, + {0, 0xbc, "FlightCommunications"}, + {0, 0xbd, "FlareRelease"}, + {0, 0xbe, "LandingGear"}, + {0, 0xbf, "ToeBrake"}, { 7, 0, "Keyboard" }, { 8, 0, "LED" }, {0, 0x01, "NumLock"}, diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 3b162a1..fa4f79d 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -131,6 +131,15 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel map_key(code); break; + + case HID_UP_SIMULATION: + + switch (usage->hid & 0xffff) { + case 0xba: map_abs(ABS_RUDDER); break; + case 0xbb: map_abs(ABS_THROTTLE); break; + } + break; + case HID_UP_GENDESK: if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */ diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index f3b85a0..cea5cf3 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -173,6 +173,7 @@ struct hid_item { #define HID_UP_UNDEFINED 0x00000000 #define HID_UP_GENDESK 0x00010000 +#define HID_UP_SIMULATION 0x00020000 #define HID_UP_KEYBOARD 0x00070000 #define HID_UP_LED 0x00080000 #define HID_UP_BUTTON 0x00090000 -- cgit v0.10.2 From 8a409b0118c2d78f84f740f60fe03abda1fe3333 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:08:08 -0500 Subject: Input: HID - add more consumer usages Extend mapping of the consumer usage page in hid-input.c to handle more cases appearing on new USB keyboards. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/usb/input/hid-debug.h b/drivers/usb/input/hid-debug.h index 789df80..ceebab9 100644 --- a/drivers/usb/input/hid-debug.h +++ b/drivers/usb/input/hid-debug.h @@ -109,6 +109,7 @@ static const struct hid_usage_entry hid_usage_table[] = { {0, 0x03, "ScrollLock"}, {0, 0x04, "Compose"}, {0, 0x05, "Kana"}, + {0, 0x4b, "GenericIndicator"}, { 9, 0, "Button" }, { 10, 0, "Ordinal" }, { 12, 0, "Consumer" }, @@ -591,7 +592,8 @@ static char *keys[KEY_MAX + 1] = { [KEY_EXIT] = "Exit", [KEY_MOVE] = "Move", [KEY_EDIT] = "Edit", [KEY_SCROLLUP] = "ScrollUp", [KEY_SCROLLDOWN] = "ScrollDown", [KEY_KPLEFTPAREN] = "KPLeftParenthesis", - [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_F13] = "F13", + [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_NEW] = "New", + [KEY_REDO] = "Redo", [KEY_F13] = "F13", [KEY_F14] = "F14", [KEY_F15] = "F15", [KEY_F16] = "F16", [KEY_F17] = "F17", [KEY_F18] = "F18", [KEY_F19] = "F19", @@ -601,15 +603,15 @@ static char *keys[KEY_MAX + 1] = { [KEY_PAUSECD] = "PauseCD", [KEY_PROG3] = "Prog3", [KEY_PROG4] = "Prog4", [KEY_SUSPEND] = "Suspend", [KEY_CLOSE] = "Close", [KEY_PLAY] = "Play", - [KEY_FASTFORWARD] = "Fast Forward", [KEY_BASSBOOST] = "Bass Boost", + [KEY_FASTFORWARD] = "FastForward", [KEY_BASSBOOST] = "BassBoost", [KEY_PRINT] = "Print", [KEY_HP] = "HP", [KEY_CAMERA] = "Camera", [KEY_SOUND] = "Sound", [KEY_QUESTION] = "Question", [KEY_EMAIL] = "Email", [KEY_CHAT] = "Chat", [KEY_SEARCH] = "Search", [KEY_CONNECT] = "Connect", [KEY_FINANCE] = "Finance", [KEY_SPORT] = "Sport", [KEY_SHOP] = "Shop", - [KEY_ALTERASE] = "Alternate Erase", [KEY_CANCEL] = "Cancel", - [KEY_BRIGHTNESSDOWN] = "Brightness down", [KEY_BRIGHTNESSUP] = "Brightness up", + [KEY_ALTERASE] = "AlternateErase", [KEY_CANCEL] = "Cancel", + [KEY_BRIGHTNESSDOWN] = "BrightnessDown", [KEY_BRIGHTNESSUP] = "BrightnessUp", [KEY_MEDIA] = "Media", [KEY_UNKNOWN] = "Unknown", [BTN_0] = "Btn0", [BTN_1] = "Btn1", [BTN_2] = "Btn2", [BTN_3] = "Btn3", @@ -639,8 +641,8 @@ static char *keys[KEY_MAX + 1] = { [BTN_TOOL_AIRBRUSH] = "ToolAirbrush", [BTN_TOOL_FINGER] = "ToolFinger", [BTN_TOOL_MOUSE] = "ToolMouse", [BTN_TOOL_LENS] = "ToolLens", [BTN_TOUCH] = "Touch", [BTN_STYLUS] = "Stylus", - [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "Tool Doubletap", - [BTN_TOOL_TRIPLETAP] = "Tool Tripletap", [BTN_GEAR_DOWN] = "WheelBtn", + [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "ToolDoubleTap", + [BTN_TOOL_TRIPLETAP] = "ToolTripleTap", [BTN_GEAR_DOWN] = "WheelBtn", [BTN_GEAR_UP] = "Gear up", [KEY_OK] = "Ok", [KEY_SELECT] = "Select", [KEY_GOTO] = "Goto", [KEY_CLEAR] = "Clear", [KEY_POWER2] = "Power2", @@ -676,6 +678,9 @@ static char *keys[KEY_MAX + 1] = { [KEY_TWEN] = "TWEN", [KEY_DEL_EOL] = "DeleteEOL", [KEY_DEL_EOS] = "DeleteEOS", [KEY_INS_LINE] = "InsertLine", [KEY_DEL_LINE] = "DeleteLine", + [KEY_SEND] = "Send", [KEY_REPLY] = "Reply", + [KEY_FORWARDMAIL] = "ForwardMail", [KEY_SAVE] = "Save", + [KEY_DOCUMENTS] = "Documents", }; static char *relatives[REL_MAX + 1] = { diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index fa4f79d..b28cf85 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -78,8 +78,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel { struct input_dev *input = &hidinput->input; struct hid_device *device = hidinput->input.private; - int max, code; - unsigned long *bit; + int max = 0, code; + unsigned long *bit = NULL; field->hidinput = hidinput; @@ -248,7 +248,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case 0x034: map_key_clear(KEY_SLEEP); break; case 0x036: map_key_clear(BTN_MISC); break; case 0x08a: map_key_clear(KEY_WWW); break; + case 0x08d: map_key_clear(KEY_PROGRAM); break; case 0x095: map_key_clear(KEY_HELP); break; + case 0x09c: map_key_clear(KEY_CHANNELUP); break; + case 0x09d: map_key_clear(KEY_CHANNELDOWN); break; case 0x0b0: map_key_clear(KEY_PLAY); break; case 0x0b1: map_key_clear(KEY_PAUSE); break; case 0x0b2: map_key_clear(KEY_RECORD); break; @@ -268,6 +271,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case 0x18a: map_key_clear(KEY_MAIL); break; case 0x192: map_key_clear(KEY_CALC); break; case 0x194: map_key_clear(KEY_FILE); break; + case 0x1a7: map_key_clear(KEY_DOCUMENTS); break; + case 0x201: map_key_clear(KEY_NEW); break; + case 0x207: map_key_clear(KEY_SAVE); break; + case 0x208: map_key_clear(KEY_PRINT); break; + case 0x209: map_key_clear(KEY_PROPS); break; case 0x21a: map_key_clear(KEY_UNDO); break; case 0x21b: map_key_clear(KEY_COPY); break; case 0x21c: map_key_clear(KEY_CUT); break; @@ -280,7 +288,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case 0x227: map_key_clear(KEY_REFRESH); break; case 0x22a: map_key_clear(KEY_BOOKMARKS); break; case 0x238: map_rel(REL_HWHEEL); break; - default: goto unknown; + case 0x279: map_key_clear(KEY_REDO); break; + case 0x289: map_key_clear(KEY_REPLY); break; + case 0x28b: map_key_clear(KEY_FORWARDMAIL); break; + case 0x28c: map_key_clear(KEY_SEND); break; + default: goto ignore; } break; @@ -306,6 +318,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case HID_UP_MSVENDOR: case HID_UP_LOGIVENDOR: + case HID_UP_LOGIVENDOR2: goto ignore; diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index cea5cf3..ca3e170 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -184,6 +184,7 @@ struct hid_item { #define HID_UP_HPVENDOR 0xff7f0000 #define HID_UP_MSVENDOR 0xff000000 #define HID_UP_LOGIVENDOR 0x00ff0000 +#define HID_UP_LOGIVENDOR2 0xffbc0000 #define HID_USAGE 0x0000ffff diff --git a/include/linux/input.h b/include/linux/input.h index bdc53c6..227a497 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -287,6 +287,8 @@ struct input_absinfo { #define KEY_SCROLLDOWN 178 #define KEY_KPLEFTPAREN 179 #define KEY_KPRIGHTPAREN 180 +#define KEY_NEW 181 +#define KEY_REDO 182 #define KEY_F13 183 #define KEY_F14 184 @@ -333,6 +335,12 @@ struct input_absinfo { #define KEY_KBDILLUMDOWN 229 #define KEY_KBDILLUMUP 230 +#define KEY_SEND 231 +#define KEY_REPLY 232 +#define KEY_FORWARDMAIL 233 +#define KEY_SAVE 234 +#define KEY_DOCUMENTS 235 + #define KEY_UNKNOWN 240 #define BTN_MISC 0x100 -- cgit v0.10.2 From 903b126bffb77dc313b7c2971880df408bf41a9e Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:11:41 -0500 Subject: Input: atkbd - handle keyboards generating scancode 0x7f Extend bat_xl handling to do err_xl handling, so that keyboards using 0x7f scancode for regular keys can work. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 4d4985b..1ad8c2e 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -208,6 +208,7 @@ struct atkbd { unsigned char resend; unsigned char release; unsigned char bat_xl; + unsigned char err_xl; unsigned int last; unsigned long time; }; @@ -296,15 +297,18 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, if (atkbd->emul || !(code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1 || code == ATKBD_RET_HANGUEL || code == ATKBD_RET_HANJA || - code == ATKBD_RET_ERR || + (code == ATKBD_RET_ERR && !atkbd->err_xl) || (code == ATKBD_RET_BAT && !atkbd->bat_xl))) { atkbd->release = code >> 7; code &= 0x7f; } - if (!atkbd->emul && - (code & 0x7f) == (ATKBD_RET_BAT & 0x7f)) + if (!atkbd->emul) { + if ((code & 0x7f) == (ATKBD_RET_BAT & 0x7f)) atkbd->bat_xl = !atkbd->release; + if ((code & 0x7f) == (ATKBD_RET_ERR & 0x7f)) + atkbd->err_xl = !atkbd->release; + } } switch (code) { -- cgit v0.10.2 From bf0964dcda97e42964d312d0ff73a832171e080a Mon Sep 17 00:00:00 2001 From: Michael Haboustak Date: Mon, 5 Sep 2005 00:12:01 -0500 Subject: Input: HID - handle multi-transascion reports Fixes handling of multi-transaction reports for HID devices. New function hid_size_buffers() that calculates the longest report for each endpoint and stores the result in the hid_device object. These lengths are used to allocate buffers that are large enough to store any report on the endpoint. For compatibility, the minimum size for an endpoint buffer set to HID_BUFFER_SIZE rather than the known optimal case (the longest report length). It fixes bug #3063 in bugzilla. Signed-off-by: Michael Haboustak I simplified the patch a bit to use just a single buffer size. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index b2cb2b3..376b604 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -2,7 +2,8 @@ * USB HID support for Linux * * Copyright (c) 1999 Andreas Gal - * Copyright (c) 2000-2001 Vojtech Pavlik + * Copyright (c) 2000-2005 Vojtech Pavlik + * Copyright (c) 2005 Michael Haboustak for Concept2, Inc */ /* @@ -38,7 +39,7 @@ * Version Information */ -#define DRIVER_VERSION "v2.01" +#define DRIVER_VERSION "v2.6" #define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik" #define DRIVER_DESC "USB HID core driver" #define DRIVER_LICENSE "GPL" @@ -1058,8 +1059,8 @@ static int hid_submit_ctrl(struct hid_device *hid) if (maxpacket > 0) { padlen = (len + maxpacket - 1) / maxpacket; padlen *= maxpacket; - if (padlen > HID_BUFFER_SIZE) - padlen = HID_BUFFER_SIZE; + if (padlen > hid->bufsize) + padlen = hid->bufsize; } else padlen = 0; hid->urbctrl->transfer_buffer_length = padlen; @@ -1284,13 +1285,8 @@ void hid_init_reports(struct hid_device *hid) struct hid_report *report; int err, ret; - list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) { - int size = ((report->size - 1) >> 3) + 1 + hid->report_enum[HID_INPUT_REPORT].numbered; - if (size > HID_BUFFER_SIZE) size = HID_BUFFER_SIZE; - if (size > hid->urbin->transfer_buffer_length) - hid->urbin->transfer_buffer_length = size; + list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) hid_submit_report(hid, report, USB_DIR_IN); - } list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list) hid_submit_report(hid, report, USB_DIR_IN); @@ -1564,15 +1560,32 @@ static struct hid_blacklist { { 0, 0 } }; +/* + * Traverse the supplied list of reports and find the longest + */ +static void hid_find_max_report(struct hid_device *hid, unsigned int type, int *max) +{ + struct hid_report *report; + int size; + + list_for_each_entry(report, &hid->report_enum[type].report_list, list) { + size = ((report->size - 1) >> 3) + 1; + if (type == HID_INPUT_REPORT && hid->report_enum[type].numbered) + size++; + if (*max < size) + *max = size; + } +} + static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) { - if (!(hid->inbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->inbuf_dma))) + if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->inbuf_dma))) return -1; - if (!(hid->outbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->outbuf_dma))) + if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->outbuf_dma))) return -1; if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), SLAB_ATOMIC, &hid->cr_dma))) return -1; - if (!(hid->ctrlbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->ctrlbuf_dma))) + if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->ctrlbuf_dma))) return -1; return 0; @@ -1581,13 +1594,13 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) { if (hid->inbuf) - usb_buffer_free(dev, HID_BUFFER_SIZE, hid->inbuf, hid->inbuf_dma); + usb_buffer_free(dev, hid->bufsize, hid->inbuf, hid->inbuf_dma); if (hid->outbuf) - usb_buffer_free(dev, HID_BUFFER_SIZE, hid->outbuf, hid->outbuf_dma); + usb_buffer_free(dev, hid->bufsize, hid->outbuf, hid->outbuf_dma); if (hid->cr) usb_buffer_free(dev, sizeof(*(hid->cr)), hid->cr, hid->cr_dma); if (hid->ctrlbuf) - usb_buffer_free(dev, HID_BUFFER_SIZE, hid->ctrlbuf, hid->ctrlbuf_dma); + usb_buffer_free(dev, hid->bufsize, hid->ctrlbuf, hid->ctrlbuf_dma); } static struct hid_device *usb_hid_configure(struct usb_interface *intf) @@ -1598,7 +1611,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) struct hid_device *hid; unsigned quirks = 0, rsize = 0; char *buf, *rdesc; - int n; + int n, insize = 0; for (n = 0; hid_blacklist[n].idVendor; n++) if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && @@ -1652,6 +1665,19 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) kfree(rdesc); hid->quirks = quirks; + hid->bufsize = HID_MIN_BUFFER_SIZE; + hid_find_max_report(hid, HID_INPUT_REPORT, &hid->bufsize); + hid_find_max_report(hid, HID_OUTPUT_REPORT, &hid->bufsize); + hid_find_max_report(hid, HID_FEATURE_REPORT, &hid->bufsize); + + if (hid->bufsize > HID_MAX_BUFFER_SIZE) + hid->bufsize = HID_MAX_BUFFER_SIZE; + + hid_find_max_report(hid, HID_INPUT_REPORT, &insize); + + if (insize > HID_MAX_BUFFER_SIZE) + insize = HID_MAX_BUFFER_SIZE; + if (hid_alloc_buffers(dev, hid)) { hid_free_buffers(dev, hid); goto fail; @@ -1682,7 +1708,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL))) goto fail; pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); - usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, 0, + usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, insize, hid_irq_in, hid, interval); hid->urbin->transfer_dma = hid->inbuf_dma; hid->urbin->transfer_flags |=(URB_NO_TRANSFER_DMA_MAP | URB_ASYNC_UNLINK); diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index ca3e170..d76bbc8 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -351,7 +351,8 @@ struct hid_report_enum { #define HID_REPORT_TYPES 3 -#define HID_BUFFER_SIZE 64 /* use 64 for compatibility with all possible packetlen */ +#define HID_MIN_BUFFER_SIZE 64 /* make sure there is at least a packet size of space */ +#define HID_MAX_BUFFER_SIZE 4096 /* 4kb */ #define HID_CONTROL_FIFO_SIZE 256 /* to init devices with >100 reports */ #define HID_OUTPUT_FIFO_SIZE 64 @@ -389,6 +390,8 @@ struct hid_device { /* device report descriptor */ unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ + unsigned int bufsize; /* URB buffer size */ + struct urb *urbin; /* Input URB */ char *inbuf; /* Input buffer */ dma_addr_t inbuf_dma; /* Input buffer dma */ -- cgit v0.10.2 From 39fd748f56012fdde4cf862f127ce4cdec50d661 Mon Sep 17 00:00:00 2001 From: "Micah F. Galizia" Date: Mon, 5 Sep 2005 00:12:15 -0500 Subject: Input: HID - add support for Logitech UltraX Media Remote control The hid now supports the Logitech UltraX Media Remote control. For now, ID 45 on the consumer usage page has been incorrectly mapped to KEY_RADIO since no other devices uses it. Signed-off-by: Micah F. Galizia Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index b28cf85..22f9d91 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -247,6 +247,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case 0x000: goto ignore; case 0x034: map_key_clear(KEY_SLEEP); break; case 0x036: map_key_clear(BTN_MISC); break; + case 0x045: map_key_clear(KEY_RADIO); break; case 0x08a: map_key_clear(KEY_WWW); break; case 0x08d: map_key_clear(KEY_PROGRAM); break; case 0x095: map_key_clear(KEY_HELP); break; @@ -318,10 +319,33 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case HID_UP_MSVENDOR: case HID_UP_LOGIVENDOR: - case HID_UP_LOGIVENDOR2: - goto ignore; + case HID_UP_LOGIVENDOR2: /* Reported on Logitech Ultra X Media Remote */ + + set_bit(EV_REP, input->evbit); + switch(usage->hid & HID_USAGE) { + case 0x004: map_key_clear(KEY_AGAIN); break; + case 0x00d: map_key_clear(KEY_HOME); break; + case 0x024: map_key_clear(KEY_SHUFFLE); break; + case 0x025: map_key_clear(KEY_TV); break; + case 0x026: map_key_clear(KEY_MENU); break; + case 0x031: map_key_clear(KEY_AUDIO); break; + case 0x032: map_key_clear(KEY_SUBTITLE); break; + case 0x033: map_key_clear(KEY_LAST); break; + case 0x047: map_key_clear(KEY_MP3); break; + case 0x048: map_key_clear(KEY_DVD); break; + case 0x049: map_key_clear(KEY_MEDIA); break; + case 0x04a: map_key_clear(KEY_VIDEO); break; + case 0x04b: map_key_clear(KEY_ANGLE); break; + case 0x04c: map_key_clear(KEY_LANGUAGE); break; + case 0x04d: map_key_clear(KEY_SUBTITLE); break; + case 0x051: map_key_clear(KEY_RED); break; + case 0x052: map_key_clear(KEY_CLOSE); break; + default: goto ignore; + } + break; + case HID_UP_PID: set_bit(EV_FF, input->evbit); -- cgit v0.10.2 From fb76b099f86624d3c629cfab071aa2296f65b7bb Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:12:39 -0500 Subject: Input: iforce - use wait_event_interruptible_timeout The timeout while() loops in iforce-packets.c lack a set_current_state(TASK_INTERRUPTIBLE); call. The right solution is to replace them with wait_event_interruptible_timeout(). Reported-by: Nishanth Aravamudan Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c index 58728eb..e5a31e5 100644 --- a/drivers/input/joystick/iforce/iforce-packets.c +++ b/drivers/input/joystick/iforce/iforce-packets.c @@ -249,9 +249,6 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data, int iforce_get_id_packet(struct iforce *iforce, char *packet) { - DECLARE_WAITQUEUE(wait, current); - int timeout = HZ; /* 1 second */ - switch (iforce->bus) { case IFORCE_USB: @@ -260,22 +257,13 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet) iforce->cr.bRequest = packet[0]; iforce->ctrl->dev = iforce->usbdev; - set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&iforce->wait, &wait); - - if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC)) { - set_current_state(TASK_RUNNING); - remove_wait_queue(&iforce->wait, &wait); + if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC)) return -1; - } - while (timeout && iforce->ctrl->status == -EINPROGRESS) - timeout = schedule_timeout(timeout); + wait_event_interruptible_timeout(iforce->wait, + iforce->ctrl->status != -EINPROGRESS, HZ); - set_current_state(TASK_RUNNING); - remove_wait_queue(&iforce->wait, &wait); - - if (!timeout) { + if (iforce->ctrl->status != -EINPROGRESS) { usb_unlink_urb(iforce->ctrl); return -1; } @@ -290,16 +278,10 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet) iforce->expect_packet = FF_CMD_QUERY; iforce_send_packet(iforce, FF_CMD_QUERY, packet); - set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&iforce->wait, &wait); - - while (timeout && iforce->expect_packet) - timeout = schedule_timeout(timeout); - - set_current_state(TASK_RUNNING); - remove_wait_queue(&iforce->wait, &wait); + wait_event_interruptible_timeout(iforce->wait, + !iforce->expect_packet, HZ); - if (!timeout) { + if (iforce->expect_packet) { iforce->expect_packet = 0; return -1; } diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c index 6369a24..58600f9 100644 --- a/drivers/input/joystick/iforce/iforce-usb.c +++ b/drivers/input/joystick/iforce/iforce-usb.c @@ -95,6 +95,7 @@ static void iforce_usb_irq(struct urb *urb, struct pt_regs *regs) goto exit; } + wake_up(&iforce->wait); iforce_process_packet(iforce, (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs); -- cgit v0.10.2 From 8d9a9ae3b2941d94bb0023a3aca2ec2bfa83d0c2 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:12:47 -0500 Subject: Input: sunkbd - extend mapping to handle Type-6 Sun keyboards Map an unmarked key at 'Esc' position to KEY_MACRO Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index 596964c..4bae5d8 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c @@ -44,7 +44,7 @@ MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); static unsigned char sunkbd_keycode[128] = { - 0,128,114,129,115, 59, 60, 68, 61, 87, 62, 88, 63,100, 64, 0, + 0,128,114,129,115, 59, 60, 68, 61, 87, 62, 88, 63,100, 64,112, 65, 66, 67, 56,103,119, 99, 70,105,130,131,108,106, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 41, 14,110,113, 98, 55, 116,132, 83,133,102, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -- cgit v0.10.2 From c4786ca8a4274a0bbffe217917972943348bed64 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:13:03 -0500 Subject: Input: HID - fix URB success status handling Add a missing break; statement to the URB status handling in hid-core.c, avoiding flushing the request queue on success. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 376b604..7d5eb4d 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1097,6 +1097,7 @@ static void hid_irq_out(struct urb *urb, struct pt_regs *regs) switch (urb->status) { case 0: /* success */ + break; case -ESHUTDOWN: /* unplug */ case -EILSEQ: /* unplug timeout on uhci */ unplug = 1; @@ -1144,6 +1145,7 @@ static void hid_ctrl(struct urb *urb, struct pt_regs *regs) case 0: /* success */ if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN) hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs); + break; case -ESHUTDOWN: /* unplug */ case -EILSEQ: /* unplug timectrl on uhci */ unplug = 1; -- cgit v0.10.2 From c58de6d949a9d2c386c4d814013b6c967c14ea5a Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:13:15 -0500 Subject: Input: HID - add a quirk for the Apple Powermouse Add a quirk for the Apple Powermouse, remapping GenericDesktop.Z to Rel.HWheel, to allow horizontal scrolling in Linux. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 7d5eb4d..661709a 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1442,6 +1442,8 @@ void hid_init_reports(struct hid_device *hid) #define USB_DEVICE_ID_NETWORKANALYSER 0x2020 #define USB_DEVICE_ID_POWERCONTROL 0x2030 +#define USB_VENDOR_ID_APPLE 0x05ac +#define USB_DEVICE_ID_APPLE_POWERMOUSE 0x0304 /* * Alphabetically sorted blacklist by quirk type. @@ -1546,6 +1548,7 @@ static struct hid_blacklist { { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET}, { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_POWERMOUSE, HID_QUIRK_2WHEEL_POWERMOUSE }, { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 }, { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 }, diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 22f9d91..14acfc5 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -396,6 +396,9 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel if (usage->code > max) goto ignore; + if (((device->quirks & (HID_QUIRK_2WHEEL_POWERMOUSE)) && (usage->hid == 0x00010032))) + map_rel(REL_HWHEEL); + if ((device->quirks & (HID_QUIRK_2WHEEL_MOUSE_HACK_7 | HID_QUIRK_2WHEEL_MOUSE_HACK_5)) && (usage->type == EV_REL) && (usage->code == REL_WHEEL)) set_bit(REL_HWHEEL, bit); diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index d76bbc8..47f75a4 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -245,6 +245,7 @@ struct hid_item { #define HID_QUIRK_2WHEEL_MOUSE_HACK_7 0x080 #define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x100 #define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x200 +#define HID_QUIRK_2WHEEL_POWERMOUSE 0x400 /* * This is the global environment of the parser. This information is -- cgit v0.10.2 From 61cdecd9f5f602775af1e89c200179d093a94ae2 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:13:32 -0500 Subject: Input: HID - add the Trust Predator TH 400 gamepad to the badpad list Reported-by: Karl Relton Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 661709a..485575a 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1370,8 +1370,9 @@ void hid_init_reports(struct hid_device *hid) #define USB_VENDOR_ID_A4TECH 0x09da #define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 -#define USB_VENDOR_ID_AASHIMA 0x06D6 +#define USB_VENDOR_ID_AASHIMA 0x06d6 #define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025 +#define USB_DEVICE_ID_AASHIMA_PREDATOR 0x0026 #define USB_VENDOR_ID_CYPRESS 0x04b4 #define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 @@ -1553,6 +1554,7 @@ static struct hid_blacklist { { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 }, { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD }, + { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, -- cgit v0.10.2 From e875ce374759087771313c9e76b672b86ac20950 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Mon, 5 Sep 2005 01:57:33 -0500 Subject: Input: HID - add mapping for Powerbook USB keyboard Map custom HID events (such as the ones generated by some Logitech and Apple Powerbooks USB keyboards) to the FN keycode. Signed-off-by: Stelian Pop Signed-off-by: Vojtech Pavlik Signed-off-by: Andrew Morton Signed-off-by: Dmitry Torokhov diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 14acfc5..0b64522 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -318,10 +318,18 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel break; case HID_UP_MSVENDOR: - case HID_UP_LOGIVENDOR: goto ignore; - case HID_UP_LOGIVENDOR2: /* Reported on Logitech Ultra X Media Remote */ + case HID_UP_CUSTOM: /* Reported on Logitech and Powerbook USB keyboards */ + + set_bit(EV_REP, input->evbit); + switch(usage->hid & HID_USAGE) { + case 0x003: map_key_clear(KEY_FN); break; + default: goto ignore; + } + break; + + case HID_UP_LOGIVENDOR: /* Reported on Logitech Ultra X Media Remote */ set_bit(EV_REP, input->evbit); switch(usage->hid & HID_USAGE) { diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index 47f75a4..ec2412c 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -183,8 +183,8 @@ struct hid_item { #define HID_UP_PID 0x000f0000 #define HID_UP_HPVENDOR 0xff7f0000 #define HID_UP_MSVENDOR 0xff000000 -#define HID_UP_LOGIVENDOR 0x00ff0000 -#define HID_UP_LOGIVENDOR2 0xffbc0000 +#define HID_UP_CUSTOM 0x00ff0000 +#define HID_UP_LOGIVENDOR 0xffbc0000 #define HID_USAGE 0x0000ffff -- cgit v0.10.2 From 7d25258f69cedc2f2e55eb25ba2e2078060b44f4 Mon Sep 17 00:00:00 2001 From: Brian Schau Date: Mon, 5 Sep 2005 01:57:41 -0500 Subject: Input: HID - add Wireless Security Lock to HID blacklist The device is a Wireless Security Lock (WSL). The device identifies itself as a Cypress Ultra Mouse. It is, however, not a mouse at all and as such, shouldn't be handled as one. Signed-off-by: Brian Schau Signed-off-by: Vojtech Pavlik Signed-off-by: Andrew Morton Signed-off-by: Dmitry Torokhov diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 485575a..a721299 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1377,6 +1377,7 @@ void hid_init_reports(struct hid_device *hid) #define USB_VENDOR_ID_CYPRESS 0x04b4 #define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 #define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 +#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 #define USB_VENDOR_ID_BERKSHIRE 0x0c98 #define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 @@ -1469,6 +1470,7 @@ static struct hid_blacklist { { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW48, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE }, + { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, -- cgit v0.10.2 From 010988e888a0abbe7118635c1b33d049caae6b29 Mon Sep 17 00:00:00 2001 From: Stefan Nickl Date: Mon, 5 Sep 2005 01:57:46 -0500 Subject: Input: HIDDEV - make HIDIOCSREPORT wait IO completion When trying to make the hiddev driver issue several Set_Report control transfers to a custom device with 2.6.13-rc6, only the first transfer in a row is carried out, while others immediately following it are silently dropped. This happens where hid_submit_report() (in hid-core.c) tests for HID_CTRL_RUNNING, which seems to be still set because the first transfer is not finished yet. As a workaround, inserting a delay between the two calls to ioctl(HIDIOCSREPORT) in userspace "solves" the problem. The straightforward fix is to add a call to hid_wait_io() to the implementation of HIDIOCSREPORT (in hiddev.c), just like for HIDIOCGREPORT. Works fine for me. Apparently, this issue has some history: http://marc.theaimsgroup.com/?l=linux-usb-users&m=111100670105558&w=2 Signed-off-by: Stefan Nickl Signed-off-by: Andrew Morton Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index 4c13331..d324278 100644 --- a/drivers/usb/input/hiddev.c +++ b/drivers/usb/input/hiddev.c @@ -507,6 +507,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd return -EINVAL; hid_submit_report(hid, report, USB_DIR_OUT); + hid_wait_io(hid); return 0; -- cgit v0.10.2 From 63028aa7f581d9d4e6889f9dc06ded2534250a76 Mon Sep 17 00:00:00 2001 From: Kiyoshi Ueda Date: Wed, 24 Aug 2005 18:03:43 -0400 Subject: [IA64] page_not_present fault in region 5 is normal When copying data from user-space to kernel-space by __copy_user(), a page_not_present fault sometimes occurs at vmalloced kernel address because of VHPT pre-fetching. Ignore the page_not_present fault in ia64_do_page_fault() before jumping into exception handlers. Signed-off-by: Kiyoshi Ueda Signed-off-by: Jun'ichi Nomura Signed-off-by: Tony Luck diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c index ff62551..839d4f1 100644 --- a/arch/ia64/mm/fault.c +++ b/arch/ia64/mm/fault.c @@ -229,9 +229,6 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re return; } - if (ia64_done_with_exception(regs)) - return; - /* * Since we have no vma's for region 5, we might get here even if the address is * valid, due to the VHPT walker inserting a non present translation that becomes @@ -242,6 +239,9 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re if (REGION_NUMBER(address) == 5 && mapped_kernel_page_is_present(address)) return; + if (ia64_done_with_exception(regs)) + return; + /* * Oops. The kernel tried to access some bad page. We'll have to terminate things * with extreme prejudice. -- cgit v0.10.2 From 295bd89279aad6959f0d363ee8e946d4766f9ad8 Mon Sep 17 00:00:00 2001 From: "Chen, Kenneth W" Date: Tue, 6 Sep 2005 16:05:23 -0700 Subject: [IA64] make exception handler in copy_user more robust The exception handler in copy user always expects fault occurs only on user space address and the fall back recovery code is written with that very assumption in mind. Recent source code inspection revealed that while it worked splendid and to the expectation under normal circumstances, It broke down under unexpected condition where some address calculation might go outside the legal address range the original copy_user was called for. This patch is to make copy_user exception handler more robust and to prevent potential memory corruption. Signed-off-by: Ken Chen Signed-off-by: Tony Luck diff --git a/arch/ia64/lib/memcpy_mck.S b/arch/ia64/lib/memcpy_mck.S index 6f308e6..46c9331 100644 --- a/arch/ia64/lib/memcpy_mck.S +++ b/arch/ia64/lib/memcpy_mck.S @@ -625,8 +625,11 @@ EK(.ex_handler, (p17) st8 [dst1]=r39,8); \ clrrrb ;; alloc saved_pfs_stack=ar.pfs,3,3,3,0 + cmp.lt p8,p0=A,r0 sub B = dst0, saved_in0 // how many byte copied so far ;; +(p8) mov A = 0; // A shouldn't be negative, cap it + ;; sub C = A, B sub D = saved_in2, A ;; -- cgit v0.10.2 From 06c56e44f3e32a859420ecac97996cc6f12827bb Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Thu, 1 Sep 2005 09:19:02 -0700 Subject: [PATCH] IPoIB: fix memory leak Fix IPoIB memory leak on device removal. Signed-off-by: Michael S. Tsirkin Signed-off-by: Roland Dreier diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 0e8ac13..49d120d 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -1062,6 +1062,8 @@ static void ipoib_remove_one(struct ib_device *device) ipoib_dev_cleanup(priv->dev); free_netdev(priv->dev); } + + kfree(dev_list); } static int __init ipoib_init_module(void) -- cgit v0.10.2 From 1d6801f9dd3ebb054ae685153a01b1a4ec817f46 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Thu, 1 Sep 2005 09:19:44 -0700 Subject: [PATCH] IB/sa_query: avoid unnecessary list scan Using ib_get_client_data in SA event handler performs a list scan. It's better to use container_of to get the sa device directly. Signed-off-by: Michael S. Tsirkin Signed-off-by: Roland Dreier diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index 126ac80..9191793 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c @@ -431,8 +431,8 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event event->event == IB_EVENT_LID_CHANGE || event->event == IB_EVENT_PKEY_CHANGE || event->event == IB_EVENT_SM_CHANGE) { - struct ib_sa_device *sa_dev = - ib_get_client_data(event->device, &sa_client); + struct ib_sa_device *sa_dev; + sa_dev = container_of(handler, typeof(*sa_dev), event_handler); schedule_work(&sa_dev->port[event->element.port_num - sa_dev->start_port].update_task); -- cgit v0.10.2 From 0b2b35f68140ceeb1b78ef85680198e63ebc8649 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Thu, 1 Sep 2005 09:28:03 -0700 Subject: [PATCH] IB: Add user-supplied context to userspace CM ABI - Add user specified context to all uCM events. Users will not retrieve any events associated with the context after destroying the corresponding cm_id. - Provide the ib_cm_init_qp_attr() call to userspace clients of the CM. This call may be used to set QP attributes properly before modifying the QP. - Fixes some error handling synchonization and cleanup issues. - Performs some minor code cleanup. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 7959582..d0f0b0a 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c @@ -72,7 +72,6 @@ enum { static struct semaphore ctx_id_mutex; static struct idr ctx_id_table; -static int ctx_id_rover = 0; static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id) { @@ -97,33 +96,16 @@ static void ib_ucm_ctx_put(struct ib_ucm_context *ctx) wake_up(&ctx->wait); } -static ssize_t ib_ucm_destroy_ctx(struct ib_ucm_file *file, int id) +static inline int ib_ucm_new_cm_id(int event) { - struct ib_ucm_context *ctx; - struct ib_ucm_event *uevent; - - down(&ctx_id_mutex); - ctx = idr_find(&ctx_id_table, id); - if (!ctx) - ctx = ERR_PTR(-ENOENT); - else if (ctx->file != file) - ctx = ERR_PTR(-EINVAL); - else - idr_remove(&ctx_id_table, ctx->id); - up(&ctx_id_mutex); - - if (IS_ERR(ctx)) - return PTR_ERR(ctx); - - atomic_dec(&ctx->ref); - wait_event(ctx->wait, !atomic_read(&ctx->ref)); + return event == IB_CM_REQ_RECEIVED || event == IB_CM_SIDR_REQ_RECEIVED; +} - /* No new events will be generated after destroying the cm_id. */ - if (!IS_ERR(ctx->cm_id)) - ib_destroy_cm_id(ctx->cm_id); +static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx) +{ + struct ib_ucm_event *uevent; - /* Cleanup events not yet reported to the user. */ - down(&file->mutex); + down(&ctx->file->mutex); list_del(&ctx->file_list); while (!list_empty(&ctx->events)) { @@ -133,15 +115,12 @@ static ssize_t ib_ucm_destroy_ctx(struct ib_ucm_file *file, int id) list_del(&uevent->ctx_list); /* clear incoming connections. */ - if (uevent->cm_id) + if (ib_ucm_new_cm_id(uevent->resp.event)) ib_destroy_cm_id(uevent->cm_id); kfree(uevent); } - up(&file->mutex); - - kfree(ctx); - return 0; + up(&ctx->file->mutex); } static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file) @@ -153,36 +132,31 @@ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file) if (!ctx) return NULL; + memset(ctx, 0, sizeof *ctx); atomic_set(&ctx->ref, 1); init_waitqueue_head(&ctx->wait); ctx->file = file; - INIT_LIST_HEAD(&ctx->events); - list_add_tail(&ctx->file_list, &file->ctxs); - - ctx_id_rover = (ctx_id_rover + 1) & INT_MAX; -retry: - result = idr_pre_get(&ctx_id_table, GFP_KERNEL); - if (!result) - goto error; + do { + result = idr_pre_get(&ctx_id_table, GFP_KERNEL); + if (!result) + goto error; - down(&ctx_id_mutex); - result = idr_get_new_above(&ctx_id_table, ctx, ctx_id_rover, &ctx->id); - up(&ctx_id_mutex); + down(&ctx_id_mutex); + result = idr_get_new(&ctx_id_table, ctx, &ctx->id); + up(&ctx_id_mutex); + } while (result == -EAGAIN); - if (result == -EAGAIN) - goto retry; if (result) goto error; + list_add_tail(&ctx->file_list, &file->ctxs); ucm_dbg("Allocated CM ID <%d>\n", ctx->id); - return ctx; + error: - list_del(&ctx->file_list); kfree(ctx); - return NULL; } /* @@ -219,12 +193,9 @@ static void ib_ucm_event_path_get(struct ib_ucm_path_rec *upath, kpath->packet_life_time_selector; } -static void ib_ucm_event_req_get(struct ib_ucm_context *ctx, - struct ib_ucm_req_event_resp *ureq, +static void ib_ucm_event_req_get(struct ib_ucm_req_event_resp *ureq, struct ib_cm_req_event_param *kreq) { - ureq->listen_id = ctx->id; - ureq->remote_ca_guid = kreq->remote_ca_guid; ureq->remote_qkey = kreq->remote_qkey; ureq->remote_qpn = kreq->remote_qpn; @@ -259,14 +230,6 @@ static void ib_ucm_event_rep_get(struct ib_ucm_rep_event_resp *urep, urep->srq = krep->srq; } -static void ib_ucm_event_sidr_req_get(struct ib_ucm_context *ctx, - struct ib_ucm_sidr_req_event_resp *ureq, - struct ib_cm_sidr_req_event_param *kreq) -{ - ureq->listen_id = ctx->id; - ureq->pkey = kreq->pkey; -} - static void ib_ucm_event_sidr_rep_get(struct ib_ucm_sidr_rep_event_resp *urep, struct ib_cm_sidr_rep_event_param *krep) { @@ -275,15 +238,14 @@ static void ib_ucm_event_sidr_rep_get(struct ib_ucm_sidr_rep_event_resp *urep, urep->qpn = krep->qpn; }; -static int ib_ucm_event_process(struct ib_ucm_context *ctx, - struct ib_cm_event *evt, +static int ib_ucm_event_process(struct ib_cm_event *evt, struct ib_ucm_event *uvt) { void *info = NULL; switch (evt->event) { case IB_CM_REQ_RECEIVED: - ib_ucm_event_req_get(ctx, &uvt->resp.u.req_resp, + ib_ucm_event_req_get(&uvt->resp.u.req_resp, &evt->param.req_rcvd); uvt->data_len = IB_CM_REQ_PRIVATE_DATA_SIZE; uvt->resp.present = IB_UCM_PRES_PRIMARY; @@ -331,8 +293,8 @@ static int ib_ucm_event_process(struct ib_ucm_context *ctx, info = evt->param.apr_rcvd.apr_info; break; case IB_CM_SIDR_REQ_RECEIVED: - ib_ucm_event_sidr_req_get(ctx, &uvt->resp.u.sidr_req_resp, - &evt->param.sidr_req_rcvd); + uvt->resp.u.sidr_req_resp.pkey = + evt->param.sidr_req_rcvd.pkey; uvt->data_len = IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE; break; case IB_CM_SIDR_REP_RECEIVED: @@ -378,31 +340,24 @@ static int ib_ucm_event_handler(struct ib_cm_id *cm_id, struct ib_ucm_event *uevent; struct ib_ucm_context *ctx; int result = 0; - int id; ctx = cm_id->context; - if (event->event == IB_CM_REQ_RECEIVED || - event->event == IB_CM_SIDR_REQ_RECEIVED) - id = IB_UCM_CM_ID_INVALID; - else - id = ctx->id; - uevent = kmalloc(sizeof(*uevent), GFP_KERNEL); if (!uevent) goto err1; memset(uevent, 0, sizeof(*uevent)); - uevent->resp.id = id; + uevent->ctx = ctx; + uevent->cm_id = cm_id; + uevent->resp.uid = ctx->uid; + uevent->resp.id = ctx->id; uevent->resp.event = event->event; - result = ib_ucm_event_process(ctx, event, uevent); + result = ib_ucm_event_process(event, uevent); if (result) goto err2; - uevent->ctx = ctx; - uevent->cm_id = (id == IB_UCM_CM_ID_INVALID) ? cm_id : NULL; - down(&ctx->file->mutex); list_add_tail(&uevent->file_list, &ctx->file->events); list_add_tail(&uevent->ctx_list, &ctx->events); @@ -414,7 +369,7 @@ err2: kfree(uevent); err1: /* Destroy new cm_id's */ - return (id == IB_UCM_CM_ID_INVALID); + return ib_ucm_new_cm_id(event->event); } static ssize_t ib_ucm_event(struct ib_ucm_file *file, @@ -423,7 +378,7 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, { struct ib_ucm_context *ctx; struct ib_ucm_event_get cmd; - struct ib_ucm_event *uevent = NULL; + struct ib_ucm_event *uevent; int result = 0; DEFINE_WAIT(wait); @@ -436,7 +391,6 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, * wait */ down(&file->mutex); - while (list_empty(&file->events)) { if (file->filp->f_flags & O_NONBLOCK) { @@ -463,21 +417,18 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, uevent = list_entry(file->events.next, struct ib_ucm_event, file_list); - if (!uevent->cm_id) - goto user; + if (ib_ucm_new_cm_id(uevent->resp.event)) { + ctx = ib_ucm_ctx_alloc(file); + if (!ctx) { + result = -ENOMEM; + goto done; + } - ctx = ib_ucm_ctx_alloc(file); - if (!ctx) { - result = -ENOMEM; - goto done; + ctx->cm_id = uevent->cm_id; + ctx->cm_id->context = ctx; + uevent->resp.id = ctx->id; } - ctx->cm_id = uevent->cm_id; - ctx->cm_id->context = ctx; - - uevent->resp.id = ctx->id; - -user: if (copy_to_user((void __user *)(unsigned long)cmd.response, &uevent->resp, sizeof(uevent->resp))) { result = -EFAULT; @@ -485,12 +436,10 @@ user: } if (uevent->data) { - if (cmd.data_len < uevent->data_len) { result = -ENOMEM; goto done; } - if (copy_to_user((void __user *)(unsigned long)cmd.data, uevent->data, uevent->data_len)) { result = -EFAULT; @@ -499,12 +448,10 @@ user: } if (uevent->info) { - if (cmd.info_len < uevent->info_len) { result = -ENOMEM; goto done; } - if (copy_to_user((void __user *)(unsigned long)cmd.info, uevent->info, uevent->info_len)) { result = -EFAULT; @@ -514,6 +461,7 @@ user: list_del(&uevent->file_list); list_del(&uevent->ctx_list); + uevent->ctx->events_reported++; kfree(uevent->data); kfree(uevent->info); @@ -545,6 +493,7 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file, if (!ctx) return -ENOMEM; + ctx->uid = cmd.uid; ctx->cm_id = ib_create_cm_id(ib_ucm_event_handler, ctx); if (IS_ERR(ctx->cm_id)) { result = PTR_ERR(ctx->cm_id); @@ -561,7 +510,14 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file, return 0; err: - ib_ucm_destroy_ctx(file, ctx->id); + down(&ctx_id_mutex); + idr_remove(&ctx_id_table, ctx->id); + up(&ctx_id_mutex); + + if (!IS_ERR(ctx->cm_id)) + ib_destroy_cm_id(ctx->cm_id); + + kfree(ctx); return result; } @@ -570,11 +526,44 @@ static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file, int in_len, int out_len) { struct ib_ucm_destroy_id cmd; + struct ib_ucm_destroy_id_resp resp; + struct ib_ucm_context *ctx; + int result = 0; + + if (out_len < sizeof(resp)) + return -ENOSPC; if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; - return ib_ucm_destroy_ctx(file, cmd.id); + down(&ctx_id_mutex); + ctx = idr_find(&ctx_id_table, cmd.id); + if (!ctx) + ctx = ERR_PTR(-ENOENT); + else if (ctx->file != file) + ctx = ERR_PTR(-EINVAL); + else + idr_remove(&ctx_id_table, ctx->id); + up(&ctx_id_mutex); + + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + atomic_dec(&ctx->ref); + wait_event(ctx->wait, !atomic_read(&ctx->ref)); + + /* No new events will be generated after destroying the cm_id. */ + ib_destroy_cm_id(ctx->cm_id); + /* Cleanup events not yet reported to the user. */ + ib_ucm_cleanup_events(ctx); + + resp.events_reported = ctx->events_reported; + if (copy_to_user((void __user *)(unsigned long)cmd.response, + &resp, sizeof(resp))) + result = -EFAULT; + + kfree(ctx); + return result; } static ssize_t ib_ucm_attr_id(struct ib_ucm_file *file, @@ -609,6 +598,98 @@ static ssize_t ib_ucm_attr_id(struct ib_ucm_file *file, return result; } +static void ib_ucm_copy_ah_attr(struct ib_ucm_ah_attr *dest_attr, + struct ib_ah_attr *src_attr) +{ + memcpy(dest_attr->grh_dgid, src_attr->grh.dgid.raw, + sizeof src_attr->grh.dgid); + dest_attr->grh_flow_label = src_attr->grh.flow_label; + dest_attr->grh_sgid_index = src_attr->grh.sgid_index; + dest_attr->grh_hop_limit = src_attr->grh.hop_limit; + dest_attr->grh_traffic_class = src_attr->grh.traffic_class; + + dest_attr->dlid = src_attr->dlid; + dest_attr->sl = src_attr->sl; + dest_attr->src_path_bits = src_attr->src_path_bits; + dest_attr->static_rate = src_attr->static_rate; + dest_attr->is_global = (src_attr->ah_flags & IB_AH_GRH); + dest_attr->port_num = src_attr->port_num; +} + +static void ib_ucm_copy_qp_attr(struct ib_ucm_init_qp_attr_resp *dest_attr, + struct ib_qp_attr *src_attr) +{ + dest_attr->cur_qp_state = src_attr->cur_qp_state; + dest_attr->path_mtu = src_attr->path_mtu; + dest_attr->path_mig_state = src_attr->path_mig_state; + dest_attr->qkey = src_attr->qkey; + dest_attr->rq_psn = src_attr->rq_psn; + dest_attr->sq_psn = src_attr->sq_psn; + dest_attr->dest_qp_num = src_attr->dest_qp_num; + dest_attr->qp_access_flags = src_attr->qp_access_flags; + + dest_attr->max_send_wr = src_attr->cap.max_send_wr; + dest_attr->max_recv_wr = src_attr->cap.max_recv_wr; + dest_attr->max_send_sge = src_attr->cap.max_send_sge; + dest_attr->max_recv_sge = src_attr->cap.max_recv_sge; + dest_attr->max_inline_data = src_attr->cap.max_inline_data; + + ib_ucm_copy_ah_attr(&dest_attr->ah_attr, &src_attr->ah_attr); + ib_ucm_copy_ah_attr(&dest_attr->alt_ah_attr, &src_attr->alt_ah_attr); + + dest_attr->pkey_index = src_attr->pkey_index; + dest_attr->alt_pkey_index = src_attr->alt_pkey_index; + dest_attr->en_sqd_async_notify = src_attr->en_sqd_async_notify; + dest_attr->sq_draining = src_attr->sq_draining; + dest_attr->max_rd_atomic = src_attr->max_rd_atomic; + dest_attr->max_dest_rd_atomic = src_attr->max_dest_rd_atomic; + dest_attr->min_rnr_timer = src_attr->min_rnr_timer; + dest_attr->port_num = src_attr->port_num; + dest_attr->timeout = src_attr->timeout; + dest_attr->retry_cnt = src_attr->retry_cnt; + dest_attr->rnr_retry = src_attr->rnr_retry; + dest_attr->alt_port_num = src_attr->alt_port_num; + dest_attr->alt_timeout = src_attr->alt_timeout; +} + +static ssize_t ib_ucm_init_qp_attr(struct ib_ucm_file *file, + const char __user *inbuf, + int in_len, int out_len) +{ + struct ib_ucm_init_qp_attr_resp resp; + struct ib_ucm_init_qp_attr cmd; + struct ib_ucm_context *ctx; + struct ib_qp_attr qp_attr; + int result = 0; + + if (out_len < sizeof(resp)) + return -ENOSPC; + + if (copy_from_user(&cmd, inbuf, sizeof(cmd))) + return -EFAULT; + + ctx = ib_ucm_ctx_get(file, cmd.id); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + resp.qp_attr_mask = 0; + memset(&qp_attr, 0, sizeof qp_attr); + qp_attr.qp_state = cmd.qp_state; + result = ib_cm_init_qp_attr(ctx->cm_id, &qp_attr, &resp.qp_attr_mask); + if (result) + goto out; + + ib_ucm_copy_qp_attr(&resp, &qp_attr); + + if (copy_to_user((void __user *)(unsigned long)cmd.response, + &resp, sizeof(resp))) + result = -EFAULT; + +out: + ib_ucm_ctx_put(ctx); + return result; +} + static ssize_t ib_ucm_listen(struct ib_ucm_file *file, const char __user *inbuf, int in_len, int out_len) @@ -808,6 +889,7 @@ static ssize_t ib_ucm_send_rep(struct ib_ucm_file *file, ctx = ib_ucm_ctx_get(file, cmd.id); if (!IS_ERR(ctx)) { + ctx->uid = cmd.uid; result = ib_send_cm_rep(ctx->cm_id, ¶m); ib_ucm_ctx_put(ctx); } else @@ -1086,6 +1168,7 @@ static ssize_t (*ucm_cmd_table[])(struct ib_ucm_file *file, [IB_USER_CM_CMD_SEND_SIDR_REQ] = ib_ucm_send_sidr_req, [IB_USER_CM_CMD_SEND_SIDR_REP] = ib_ucm_send_sidr_rep, [IB_USER_CM_CMD_EVENT] = ib_ucm_event, + [IB_USER_CM_CMD_INIT_QP_ATTR] = ib_ucm_init_qp_attr, }; static ssize_t ib_ucm_write(struct file *filp, const char __user *buf, @@ -1161,12 +1244,18 @@ static int ib_ucm_close(struct inode *inode, struct file *filp) down(&file->mutex); while (!list_empty(&file->ctxs)) { - ctx = list_entry(file->ctxs.next, struct ib_ucm_context, file_list); - up(&file->mutex); - ib_ucm_destroy_ctx(file, ctx->id); + + down(&ctx_id_mutex); + idr_remove(&ctx_id_table, ctx->id); + up(&ctx_id_mutex); + + ib_destroy_cm_id(ctx->cm_id); + ib_ucm_cleanup_events(ctx); + kfree(ctx); + down(&file->mutex); } up(&file->mutex); diff --git a/drivers/infiniband/core/ucm.h b/drivers/infiniband/core/ucm.h index c8819b9..f46f37b 100644 --- a/drivers/infiniband/core/ucm.h +++ b/drivers/infiniband/core/ucm.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Topspin Communications. All rights reserved. + * Copyright (c) 2005 Intel Corporation. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -43,8 +44,6 @@ #include #include -#define IB_UCM_CM_ID_INVALID 0xffffffff - struct ib_ucm_file { struct semaphore mutex; struct file *filp; @@ -58,9 +57,11 @@ struct ib_ucm_context { int id; wait_queue_head_t wait; atomic_t ref; + int events_reported; struct ib_ucm_file *file; struct ib_cm_id *cm_id; + __u64 uid; struct list_head events; /* list of pending events. */ struct list_head file_list; /* member in file ctx list */ @@ -71,16 +72,12 @@ struct ib_ucm_event { struct list_head file_list; /* member in file event list */ struct list_head ctx_list; /* member in ctx event list */ + struct ib_cm_id *cm_id; struct ib_ucm_event_resp resp; void *data; void *info; int data_len; int info_len; - /* - * new connection identifiers needs to be saved until - * userspace can get a handle on them. - */ - struct ib_cm_id *cm_id; }; #endif /* UCM_H */ diff --git a/include/rdma/ib_user_cm.h b/include/rdma/ib_user_cm.h index 72182d1..e4d1654 100644 --- a/include/rdma/ib_user_cm.h +++ b/include/rdma/ib_user_cm.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Topspin Communications. All rights reserved. + * Copyright (c) 2005 Intel Corporation. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -37,7 +38,7 @@ #include -#define IB_USER_CM_ABI_VERSION 1 +#define IB_USER_CM_ABI_VERSION 2 enum { IB_USER_CM_CMD_CREATE_ID, @@ -60,6 +61,7 @@ enum { IB_USER_CM_CMD_SEND_SIDR_REP, IB_USER_CM_CMD_EVENT, + IB_USER_CM_CMD_INIT_QP_ATTR, }; /* * command ABI structures. @@ -71,6 +73,7 @@ struct ib_ucm_cmd_hdr { }; struct ib_ucm_create_id { + __u64 uid; __u64 response; }; @@ -79,9 +82,14 @@ struct ib_ucm_create_id_resp { }; struct ib_ucm_destroy_id { + __u64 response; __u32 id; }; +struct ib_ucm_destroy_id_resp { + __u32 events_reported; +}; + struct ib_ucm_attr_id { __u64 response; __u32 id; @@ -94,6 +102,64 @@ struct ib_ucm_attr_id_resp { __be32 remote_id; }; +struct ib_ucm_init_qp_attr { + __u64 response; + __u32 id; + __u32 qp_state; +}; + +struct ib_ucm_ah_attr { + __u8 grh_dgid[16]; + __u32 grh_flow_label; + __u16 dlid; + __u16 reserved; + __u8 grh_sgid_index; + __u8 grh_hop_limit; + __u8 grh_traffic_class; + __u8 sl; + __u8 src_path_bits; + __u8 static_rate; + __u8 is_global; + __u8 port_num; +}; + +struct ib_ucm_init_qp_attr_resp { + __u32 qp_attr_mask; + __u32 qp_state; + __u32 cur_qp_state; + __u32 path_mtu; + __u32 path_mig_state; + __u32 qkey; + __u32 rq_psn; + __u32 sq_psn; + __u32 dest_qp_num; + __u32 qp_access_flags; + + struct ib_ucm_ah_attr ah_attr; + struct ib_ucm_ah_attr alt_ah_attr; + + /* ib_qp_cap */ + __u32 max_send_wr; + __u32 max_recv_wr; + __u32 max_send_sge; + __u32 max_recv_sge; + __u32 max_inline_data; + + __u16 pkey_index; + __u16 alt_pkey_index; + __u8 en_sqd_async_notify; + __u8 sq_draining; + __u8 max_rd_atomic; + __u8 max_dest_rd_atomic; + __u8 min_rnr_timer; + __u8 port_num; + __u8 timeout; + __u8 retry_cnt; + __u8 rnr_retry; + __u8 alt_port_num; + __u8 alt_timeout; +}; + struct ib_ucm_listen { __be64 service_id; __be64 service_mask; @@ -157,6 +223,7 @@ struct ib_ucm_req { }; struct ib_ucm_rep { + __u64 uid; __u64 data; __u32 id; __u32 qpn; @@ -232,7 +299,6 @@ struct ib_ucm_event_get { }; struct ib_ucm_req_event_resp { - __u32 listen_id; /* device */ /* port */ struct ib_ucm_path_rec primary_path; @@ -287,7 +353,6 @@ struct ib_ucm_apr_event_resp { }; struct ib_ucm_sidr_req_event_resp { - __u32 listen_id; /* device */ /* port */ __u16 pkey; @@ -307,6 +372,7 @@ struct ib_ucm_sidr_rep_event_resp { #define IB_UCM_PRES_ALTERNATE 0x08 struct ib_ucm_event_resp { + __u64 uid; __u32 id; __u32 event; __u32 present; -- cgit v0.10.2 From c9fe2b3287498b80781284306064104ef9c8a31a Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Wed, 7 Sep 2005 09:43:23 -0700 Subject: [PATCH] IB: really reset QPs When we modify a QP to the RESET state, completely clean up the QP so that it is really and truly reset. Signed-off-by: Roland Dreier diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index 0164b84..c753f73 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -220,6 +220,16 @@ static void *get_send_wqe(struct mthca_qp *qp, int n) (PAGE_SIZE - 1)); } +static void mthca_wq_init(struct mthca_wq *wq) +{ + spin_lock_init(&wq->lock); + wq->next_ind = 0; + wq->last_comp = wq->max - 1; + wq->head = 0; + wq->tail = 0; + wq->last = NULL; +} + void mthca_qp_event(struct mthca_dev *dev, u32 qpn, enum ib_event_type event_type) { @@ -833,8 +843,8 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask) store_attrs(to_msqp(qp), attr, attr_mask); /* - * If we are moving QP0 to RTR, bring the IB link up; if we - * are moving QP0 to RESET or ERROR, bring the link back down. + * If we moved QP0 to RTR, bring the IB link up; if we moved + * QP0 to RESET or ERROR, bring the link back down. */ if (is_qp0(dev, qp)) { if (cur_state != IB_QPS_RTR && @@ -848,6 +858,26 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask) mthca_CLOSE_IB(dev, to_msqp(qp)->port, &status); } + /* + * If we moved a kernel QP to RESET, clean up all old CQ + * entries and reinitialize the QP. + */ + if (!err && new_state == IB_QPS_RESET && !qp->ibqp.uobject) { + mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq)->cqn, qp->qpn, + qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); + if (qp->ibqp.send_cq != qp->ibqp.recv_cq) + mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq)->cqn, qp->qpn, + qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); + + mthca_wq_init(&qp->sq); + mthca_wq_init(&qp->rq); + + if (mthca_is_memfree(dev)) { + *qp->sq.db = 0; + *qp->rq.db = 0; + } + } + return err; } @@ -1003,16 +1033,6 @@ static void mthca_free_memfree(struct mthca_dev *dev, } } -static void mthca_wq_init(struct mthca_wq* wq) -{ - spin_lock_init(&wq->lock); - wq->next_ind = 0; - wq->last_comp = wq->max - 1; - wq->head = 0; - wq->tail = 0; - wq->last = NULL; -} - static int mthca_alloc_qp_common(struct mthca_dev *dev, struct mthca_pd *pd, struct mthca_cq *send_cq, -- cgit v0.10.2 From 30a7e8ef13b2ff0db7b15af9afdd12b93783f01e Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 7 Sep 2005 09:45:00 -0700 Subject: [PATCH] IB: Initialize qp->wait Add missing call to init_waitqueue_head(). Signed-off-by: Michael S. Tsirkin Signed-off-by: Roland Dreier diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index c753f73..bcef06b 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -1044,6 +1044,7 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev, int i; atomic_set(&qp->refcount, 1); + init_waitqueue_head(&qp->wait); qp->state = IB_QPS_RESET; qp->atomic_rd_en = 0; qp->resp_depth = 0; -- cgit v0.10.2 From b5dcbf47e10e568273213a4410daa27c11cdba3a Mon Sep 17 00:00:00 2001 From: Hal Rosenstock Date: Wed, 7 Sep 2005 11:03:41 -0700 Subject: [PATCH] IB: RMPP fixes - Fix payload length of middle RMPP sent segments. Middle payload lengths should be 0 on the send side. (This is perhaps a compliance and should not be an interop issue as middle payload lengths are supposed to be ignored on receive). - Fix length in first segment of multipacket sends (This is a compliance issue but does not affect at least OpenIB to OpenIB RMPP transfers). Signed-off-by: Hal Rosenstock Signed-off-by: Roland Dreier diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c index 43fd805..2bd8b1c 100644 --- a/drivers/infiniband/core/mad_rmpp.c +++ b/drivers/infiniband/core/mad_rmpp.c @@ -593,7 +593,8 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr) rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(mad_send_wr->total_seg * (sizeof(struct ib_rmpp_mad) - - offsetof(struct ib_rmpp_mad, data))); + offsetof(struct ib_rmpp_mad, data)) - + mad_send_wr->pad); mad_send_wr->sg_list[0].length = sizeof(struct ib_rmpp_mad); } else { mad_send_wr->send_wr.num_sge = 2; @@ -602,6 +603,7 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr) mad_send_wr->sg_list[1].length = sizeof(struct ib_rmpp_mad) - mad_send_wr->data_offset; mad_send_wr->sg_list[1].lkey = mad_send_wr->sg_list[0].lkey; + rmpp_mad->rmpp_hdr.paylen_newwin = 0; } if (mad_send_wr->seg_num == mad_send_wr->total_seg) { -- cgit v0.10.2 From 17781cd6186cb3472ff34b2d9a15e647bd311e8b Mon Sep 17 00:00:00 2001 From: James Lentini Date: Wed, 7 Sep 2005 12:43:08 -0700 Subject: [PATCH] IB: clean up user access config options Add a new config option INFINIBAND_USER_MAD to control whether we build ib_umad. Change INFINIBAND_USER_VERBS to INFINIBAND_USER_ACCESS, and have it control ib_ucm and ib_uat as well as ib_uverbs. Signed-off-by: James Lentini Signed-off-by: Roland Dreier diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig index 32cdfb3..325d502 100644 --- a/drivers/infiniband/Kconfig +++ b/drivers/infiniband/Kconfig @@ -8,15 +8,26 @@ config INFINIBAND any protocols you wish to use as well as drivers for your InfiniBand hardware. -config INFINIBAND_USER_VERBS - tristate "InfiniBand userspace verbs support" +config INFINIBAND_USER_MAD + tristate "InfiniBand userspace MAD support" depends on INFINIBAND ---help--- - Userspace InfiniBand verbs support. This is the kernel side - of userspace verbs, which allows userspace processes to - directly access InfiniBand hardware for fast-path - operations. You will also need libibverbs and a hardware - driver library from . + Userspace InfiniBand Management Datagram (MAD) support. This + is the kernel side of the userspace MAD support, which allows + userspace processes to send and receive MADs. You will also + need libibumad from . + +config INFINIBAND_USER_ACCESS + tristate "InfiniBand userspace access (verbs and CM)" + depends on INFINIBAND + ---help--- + Userspace InfiniBand access support. This enables the + kernel side of userspace verbs and the userspace + communication manager (CM). This allows userspace processes + to set up connections and directly access InfiniBand + hardware for fast-path operations. You will also need + libibverbs, libibcm and a hardware driver library from + . source "drivers/infiniband/hw/mthca/Kconfig" diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile index 678a7e0..ec3353f 100644 --- a/drivers/infiniband/core/Makefile +++ b/drivers/infiniband/core/Makefile @@ -1,6 +1,7 @@ obj-$(CONFIG_INFINIBAND) += ib_core.o ib_mad.o ib_sa.o \ - ib_cm.o ib_umad.o ib_ucm.o -obj-$(CONFIG_INFINIBAND_USER_VERBS) += ib_uverbs.o + ib_cm.o +obj-$(CONFIG_INFINIBAND_USER_MAD) += ib_umad.o +obj-$(CONFIG_INFINIBAND_USER_ACCESS) += ib_uverbs.o ib_ucm.o ib_core-y := packer.o ud_header.o verbs.o sysfs.o \ device.o fmr_pool.o cache.o -- cgit v0.10.2 From 02326223247c773bc007629d54622d750c0371c1 Mon Sep 17 00:00:00 2001 From: "Chen, Kenneth W" Date: Wed, 7 Sep 2005 01:00:37 -0700 Subject: [IA64] minor performance tune-up in ia64_switch_to The reenabling of psr.ic should really belong to dtr mapping code block. It make the fall through code fast since it doesn't need to execute the predicated-off instruction. Logically make more sense as well since psr.ic was turned off in .map code block. Signed-off-by: Ken Chen Signed-off-by: Tony Luck diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S index 9be53e1..3c88210 100644 --- a/arch/ia64/kernel/entry.S +++ b/arch/ia64/kernel/entry.S @@ -204,9 +204,6 @@ GLOBAL_ENTRY(ia64_switch_to) (p6) br.cond.dpnt .map ;; .done: -(p6) ssm psr.ic // if we had to map, reenable the psr.ic bit FIRST!!! - ;; -(p6) srlz.d ld8 sp=[r21] // load kernel stack pointer of new task mov IA64_KR(CURRENT)=in0 // update "current" application register mov r8=r13 // return pointer to previously running task @@ -234,6 +231,9 @@ GLOBAL_ENTRY(ia64_switch_to) mov IA64_KR(CURRENT_STACK)=r26 // remember last page we mapped... ;; itr.d dtr[r25]=r23 // wire in new mapping... + ssm psr.ic // reenable the psr.ic bit + ;; + srlz.d br.cond.sptk .done END(ia64_switch_to) -- cgit v0.10.2 From a52ac87eb249f5e87f43e1a0adeb1a737f4a2b43 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Wed, 7 Sep 2005 14:04:14 +0900 Subject: [IA64] Minor cleanups - remove unnecessary function prototype in irq.h The function prototype for handl_IRQ_event() in include/asm-ia64/irq.h is no longer needed. This patch removes it. Signed-off-by: Kenji Kaneshige Signed-off-by: Tony Luck diff --git a/include/asm-ia64/irq.h b/include/asm-ia64/irq.h index bd07d11..585644c 100644 --- a/include/asm-ia64/irq.h +++ b/include/asm-ia64/irq.h @@ -36,8 +36,4 @@ extern void move_irq(int irq); #define move_irq(irq) #endif -struct irqaction; -struct pt_regs; -int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *); - #endif /* _ASM_IA64_IRQ_H */ -- cgit v0.10.2 From 697eaad417f9f2e40f62282e8b396208b72990cf Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Wed, 7 Sep 2005 14:06:25 +0900 Subject: [IA64] Minor cleanups - remove CONFIG_ACPI_DEALLOCATE_IRQ The config option 'CONFIG_ACPI_DEALLOCATE_IRQ' is no longer needed. This patch removes it. Signed-off-by: Kenji Kaneshige Signed-off-by: Tony Luck diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 3deced6..d0743c6 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -338,11 +338,6 @@ config IA64_PALINFO To use this option, you have to ensure that the "/proc file system support" (CONFIG_PROC_FS) is enabled, too. -config ACPI_DEALLOCATE_IRQ - bool - depends on IOSAPIC && EXPERIMENTAL - default y - source "drivers/firmware/Kconfig" source "fs/Kconfig.binfmt" diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig index dccf35c..5f1cceb 100644 --- a/arch/ia64/configs/sn2_defconfig +++ b/arch/ia64/configs/sn2_defconfig @@ -111,7 +111,6 @@ CONFIG_COMPAT=y CONFIG_IA64_MCA_RECOVERY=y CONFIG_PERFMON=y CONFIG_IA64_PALINFO=y -CONFIG_ACPI_DEALLOCATE_IRQ=y # # Firmware Drivers diff --git a/arch/ia64/configs/tiger_defconfig b/arch/ia64/configs/tiger_defconfig index c853cfc..d536ec7 100644 --- a/arch/ia64/configs/tiger_defconfig +++ b/arch/ia64/configs/tiger_defconfig @@ -109,7 +109,6 @@ CONFIG_COMPAT=y CONFIG_IA64_MCA_RECOVERY=y CONFIG_PERFMON=y CONFIG_IA64_PALINFO=y -CONFIG_ACPI_DEALLOCATE_IRQ=y # # Firmware Drivers diff --git a/arch/ia64/configs/zx1_defconfig b/arch/ia64/configs/zx1_defconfig index 88e8867..d569036 100644 --- a/arch/ia64/configs/zx1_defconfig +++ b/arch/ia64/configs/zx1_defconfig @@ -109,7 +109,6 @@ CONFIG_COMPAT=y CONFIG_IA64_MCA_RECOVERY=y CONFIG_PERFMON=y CONFIG_IA64_PALINFO=y -CONFIG_ACPI_DEALLOCATE_IRQ=y # # Firmware Drivers diff --git a/arch/ia64/defconfig b/arch/ia64/defconfig index 8444add..e3a907b 100644 --- a/arch/ia64/defconfig +++ b/arch/ia64/defconfig @@ -99,7 +99,6 @@ CONFIG_COMPAT=y CONFIG_IA64_MCA_RECOVERY=y CONFIG_PERFMON=y CONFIG_IA64_PALINFO=y -CONFIG_ACPI_DEALLOCATE_IRQ=y # # Firmware Drivers diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index 9609f24..66970d7 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c @@ -575,14 +575,12 @@ acpi_register_gsi (u32 gsi, int edge_level, int active_high_low) } EXPORT_SYMBOL(acpi_register_gsi); -#ifdef CONFIG_ACPI_DEALLOCATE_IRQ void acpi_unregister_gsi (u32 gsi) { iosapic_unregister_intr(gsi); } EXPORT_SYMBOL(acpi_unregister_gsi); -#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */ static int __init acpi_parse_fadt (unsigned long phys_addr, unsigned long size) diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c index 7936b62..c0c3f55 100644 --- a/arch/ia64/kernel/iosapic.c +++ b/arch/ia64/kernel/iosapic.c @@ -776,7 +776,6 @@ again: return vector; } -#ifdef CONFIG_ACPI_DEALLOCATE_IRQ void iosapic_unregister_intr (unsigned int gsi) { @@ -859,7 +858,6 @@ iosapic_unregister_intr (unsigned int gsi) spin_unlock(&iosapic_lock); spin_unlock_irqrestore(&idesc->lock, flags); } -#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */ /* * ACPI calls this when it finds an entry for a platform interrupt. diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 9977c12..9b5de58 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c @@ -498,13 +498,11 @@ pcibios_enable_device (struct pci_dev *dev, int mask) return acpi_pci_irq_enable(dev); } -#ifdef CONFIG_ACPI_DEALLOCATE_IRQ void pcibios_disable_device (struct pci_dev *dev) { acpi_pci_irq_disable(dev); } -#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */ void pcibios_align_resource (void *data, struct resource *res, diff --git a/include/asm-ia64/iosapic.h b/include/asm-ia64/iosapic.h index a429fe2..9a18820 100644 --- a/include/asm-ia64/iosapic.h +++ b/include/asm-ia64/iosapic.h @@ -83,9 +83,7 @@ extern int gsi_to_irq (unsigned int gsi); extern void iosapic_enable_intr (unsigned int vector); extern int iosapic_register_intr (unsigned int gsi, unsigned long polarity, unsigned long trigger); -#ifdef CONFIG_ACPI_DEALLOCATE_IRQ extern void iosapic_unregister_intr (unsigned int irq); -#endif extern void __init iosapic_override_isa_irq (unsigned int isa_irq, unsigned int gsi, unsigned long polarity, unsigned long trigger); -- cgit v0.10.2 From 9799e4d39a7e2763a614084f6ae6cc936047de70 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Wed, 7 Sep 2005 14:08:18 +0900 Subject: [IA64] Minor cleanups - remove unnecessary function prototype in iosapic.h The function prototypes for iosapic_enable_intr() and iosapic_pci_fixup() in include/asm-ia64/iosapic.h are no longer needed. This patch removes them. The original patch has been posted by Satoru Takeuchi. Signed-off-by: Satoru Takeuchi Signed-off-by: Kenji Kaneshige Signed-off-by: Tony Luck diff --git a/include/asm-ia64/iosapic.h b/include/asm-ia64/iosapic.h index 9a18820..20f98f1 100644 --- a/include/asm-ia64/iosapic.h +++ b/include/asm-ia64/iosapic.h @@ -80,7 +80,6 @@ extern int iosapic_remove (unsigned int gsi_base); #endif /* CONFIG_HOTPLUG */ extern int gsi_to_vector (unsigned int gsi); extern int gsi_to_irq (unsigned int gsi); -extern void iosapic_enable_intr (unsigned int vector); extern int iosapic_register_intr (unsigned int gsi, unsigned long polarity, unsigned long trigger); extern void iosapic_unregister_intr (unsigned int irq); @@ -95,7 +94,6 @@ extern int __init iosapic_register_platform_intr (u32 int_type, unsigned long trigger); extern unsigned int iosapic_version (char __iomem *addr); -extern void iosapic_pci_fixup (int); #ifdef CONFIG_NUMA extern void __devinit map_iosapic_to_node (unsigned int, int); #endif -- cgit v0.10.2 From f2c853bca542f5ac0b036377637192a74f2091c2 Mon Sep 17 00:00:00 2001 From: Arnaud Patard Date: Wed, 7 Sep 2005 22:44:48 +0200 Subject: [PATCH] sata_sis: Add support for SiS182 chipset This patch adds support for the SiS182 sata chipset. This is a minimalistic version of the patch from http://bugme.osdl.org/show_bug.cgi?id=4192. Basically, it add the PCI IDs and handles the change of the 2nd port adress register. Signed-Off-By: Arnaud Patard Signed-off-by: Jeff Garzik diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c index 43af445..7d1aaa9 100644 --- a/drivers/scsi/sata_sis.c +++ b/drivers/scsi/sata_sis.c @@ -52,7 +52,10 @@ enum { /* PCI configuration registers */ SIS_GENCTL = 0x54, /* IDE General Control register */ SIS_SCR_BASE = 0xc0, /* sata0 phy SCR registers */ - SIS_SATA1_OFS = 0x10, /* offset from sata0->sata1 phy regs */ + SIS180_SATA1_OFS = 0x10, /* offset from sata0->sata1 phy regs */ + SIS182_SATA1_OFS = 0x20, /* offset from sata0->sata1 phy regs */ + SIS_PMR = 0x90, /* port mapping register */ + SIS_PMR_COMBINED = 0x30, /* random bits */ SIS_FLAG_CFGSCR = (1 << 30), /* host flag: SCRs via PCI cfg */ @@ -67,6 +70,7 @@ static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); static struct pci_device_id sis_pci_tbl[] = { { PCI_VENDOR_ID_SI, 0x180, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sis_180 }, { PCI_VENDOR_ID_SI, 0x181, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sis_180 }, + { PCI_VENDOR_ID_SI, 0x182, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sis_180 }, { } /* terminate list */ }; @@ -139,56 +143,94 @@ MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, sis_pci_tbl); MODULE_VERSION(DRV_VERSION); -static unsigned int get_scr_cfg_addr(unsigned int port_no, unsigned int sc_reg) +static unsigned int get_scr_cfg_addr(unsigned int port_no, unsigned int sc_reg, int device) { unsigned int addr = SIS_SCR_BASE + (4 * sc_reg); - if (port_no) - addr += SIS_SATA1_OFS; + if (port_no) + if (device == 0x182) + addr += SIS182_SATA1_OFS; + else + addr += SIS180_SATA1_OFS; return addr; } static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) { struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); - unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, sc_reg); - u32 val; + unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, sc_reg, pdev->device); + u32 val, val2; + u8 pmr; if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */ return 0xffffffff; + + pci_read_config_byte(pdev, SIS_PMR, &pmr); + pci_read_config_dword(pdev, cfg_addr, &val); - return val; + + if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED)) + pci_read_config_dword(pdev, cfg_addr+0x10, &val2); + + return val|val2; } static void sis_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val) { struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); - unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, scr); + unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, scr, pdev->device); + u8 pmr; if (scr == SCR_ERROR) /* doesn't exist in PCI cfg space */ return; + + pci_read_config_byte(pdev, SIS_PMR, &pmr); + pci_write_config_dword(pdev, cfg_addr, val); + + if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED)) + pci_write_config_dword(pdev, cfg_addr+0x10, val); } static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg) { + struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); + u32 val,val2; + u8 pmr; + if (sc_reg > SCR_CONTROL) return 0xffffffffU; if (ap->flags & SIS_FLAG_CFGSCR) return sis_scr_cfg_read(ap, sc_reg); - return inl(ap->ioaddr.scr_addr + (sc_reg * 4)); + + pci_read_config_byte(pdev, SIS_PMR, &pmr); + + val = inl(ap->ioaddr.scr_addr + (sc_reg * 4)); + + if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED)) + val2 = inl(ap->ioaddr.scr_addr + (sc_reg * 4)+0x10); + + return val|val2; } static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) { + struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); + u8 pmr; + if (sc_reg > SCR_CONTROL) return; + pci_read_config_byte(pdev, SIS_PMR, &pmr); + if (ap->flags & SIS_FLAG_CFGSCR) sis_scr_cfg_write(ap, sc_reg, val); - else + else { outl(val, ap->ioaddr.scr_addr + (sc_reg * 4)); + if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED)) + outl(val, ap->ioaddr.scr_addr + (sc_reg * 4)+0x10); + } } /* move to PCI layer, integrate w/ MSI stuff */ @@ -210,6 +252,8 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) u32 genctl; struct ata_port_info *ppi; int pci_dev_busy = 0; + u8 pmr; + u8 port2_start; rc = pci_enable_device(pdev); if (rc) @@ -251,11 +295,27 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) probe_ent->host_flags |= SIS_FLAG_CFGSCR; } + pci_read_config_byte(pdev, SIS_PMR, &pmr); + if (ent->device != 0x182) { + if ((pmr & SIS_PMR_COMBINED) == 0) { + printk(KERN_INFO "sata_sis: Detected SiS 180/181 chipset in SATA mode\n"); + port2_start=0x64; + } + else { + printk(KERN_INFO "sata_sis: Detected SiS 180/181 chipset in combined mode\n"); + port2_start=0; + } + } + else { + printk(KERN_INFO "sata_sis: Detected SiS 182 chipset\n"); + port2_start = 0x20; + } + if (!(probe_ent->host_flags & SIS_FLAG_CFGSCR)) { probe_ent->port[0].scr_addr = pci_resource_start(pdev, SIS_SCR_PCI_BAR); probe_ent->port[1].scr_addr = - pci_resource_start(pdev, SIS_SCR_PCI_BAR) + 64; + pci_resource_start(pdev, SIS_SCR_PCI_BAR) + port2_start; } pci_set_master(pdev); -- cgit v0.10.2 From 333fad5364d6b457c8d837f7d05802d2aaf8a961 Mon Sep 17 00:00:00 2001 From: YOSHIFUJI Hideaki Date: Thu, 8 Sep 2005 09:59:17 +0900 Subject: [IPV6]: Support several new sockopt / ancillary data in Advanced API (RFC3542). Support several new socket options / ancillary data: IPV6_RECVPKTINFO, IPV6_PKTINFO, IPV6_RECVHOPOPTS, IPV6_HOPOPTS, IPV6_RECVDSTOPTS, IPV6_DSTOPTS, IPV6_RTHDRDSTOPTS, IPV6_RECVRTHDR, IPV6_RTHDR, IPV6_RECVHOPOPTS, IPV6_HOPOPTS Old semantics are preserved as IPV6_2292xxxx so that we can maintain backward compatibility. Signed-off-by: YOSHIFUJI Hideaki diff --git a/include/linux/in6.h b/include/linux/in6.h index dcf5720..c11022f 100644 --- a/include/linux/in6.h +++ b/include/linux/in6.h @@ -148,13 +148,13 @@ struct in6_flowlabel_req */ #define IPV6_ADDRFORM 1 -#define IPV6_PKTINFO 2 -#define IPV6_HOPOPTS 3 -#define IPV6_DSTOPTS 4 -#define IPV6_RTHDR 5 -#define IPV6_PKTOPTIONS 6 +#define IPV6_2292PKTINFO 2 +#define IPV6_2292HOPOPTS 3 +#define IPV6_2292DSTOPTS 4 +#define IPV6_2292RTHDR 5 +#define IPV6_2292PKTOPTIONS 6 #define IPV6_CHECKSUM 7 -#define IPV6_HOPLIMIT 8 +#define IPV6_2292HOPLIMIT 8 #define IPV6_NEXTHOP 9 #define IPV6_AUTHHDR 10 /* obsolete */ #define IPV6_FLOWINFO 11 @@ -198,4 +198,30 @@ struct in6_flowlabel_req * MCAST_MSFILTER 48 */ +/* RFC3542 advanced socket options (50-67) */ +#define IPV6_RECVPKTINFO 50 +#define IPV6_PKTINFO 51 +#if 0 +#define IPV6_RECVPATHMTU 52 +#define IPV6_PATHMTU 53 +#define IPV6_DONTFRAG 54 +#define IPV6_USE_MIN_MTU 55 +#endif +#define IPV6_RECVHOPOPTS 56 +#define IPV6_HOPOPTS 57 +#if 0 +#define IPV6_RECVRTHDRDSTOPTS 58 /* Unused, see net/ipv6/datagram.c */ +#endif +#define IPV6_RTHDRDSTOPTS 59 +#define IPV6_RECVRTHDR 60 +#define IPV6_RTHDR 61 +#define IPV6_RECVDSTOPTS 62 +#define IPV6_DSTOPTS 63 +#define IPV6_RECVHOPLIMIT 64 +#define IPV6_HOPLIMIT 65 +#if 0 +#define IPV6_RECVTCLASS 66 +#define IPV6_TCLASS 67 +#endif + #endif diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 3c7dbc6..2581f1c 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -189,6 +189,7 @@ struct inet6_skb_parm { __u16 dst0; __u16 srcrt; __u16 dst1; + __u16 lastopt; }; #define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb)) @@ -234,14 +235,19 @@ struct ipv6_pinfo { /* pktoption flags */ union { struct { - __u8 srcrt:2, + __u16 srcrt:2, + osrcrt:2, rxinfo:1, + rxoinfo:1, rxhlim:1, + rxohlim:1, hopopts:1, + ohopopts:1, dstopts:1, + odstopts:1, rxflow:1; } bits; - __u8 all; + __u16 all; } rxopt; /* sockopt flags */ diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 3203eaf..8a9fe94 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -233,6 +233,10 @@ extern int ip6_ra_control(struct sock *sk, int sel, extern int ipv6_parse_hopopts(struct sk_buff *skb, int); extern struct ipv6_txoptions * ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt); +extern struct ipv6_txoptions * ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt, + int newtype, + struct ipv6_opt_hdr __user *newopt, + int newoptlen); extern int ip6_frag_nqueues; extern atomic_t ip6_frag_mem; diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 01468fa..832476b 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -394,21 +394,85 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) u32 flowinfo = *(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK; put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); } + + /* HbH is allowed only once */ if (np->rxopt.bits.hopopts && opt->hop) { u8 *ptr = skb->nh.raw + opt->hop; put_cmsg(msg, SOL_IPV6, IPV6_HOPOPTS, (ptr[1]+1)<<3, ptr); } - if (np->rxopt.bits.dstopts && opt->dst0) { + + if (opt->lastopt && + (np->rxopt.bits.dstopts || np->rxopt.bits.srcrt)) { + /* + * Silly enough, but we need to reparse in order to + * report extension headers (except for HbH) + * in order. + * + * Also note that IPV6_RECVRTHDRDSTOPTS is NOT + * (and WILL NOT be) defined because + * IPV6_RECVDSTOPTS is more generic. --yoshfuji + */ + unsigned int off = sizeof(struct ipv6hdr); + u8 nexthdr = skb->nh.ipv6h->nexthdr; + + while (off <= opt->lastopt) { + unsigned len; + u8 *ptr = skb->nh.raw + off; + + switch(nexthdr) { + case IPPROTO_DSTOPTS: + nexthdr = ptr[0]; + len = (ptr[1] + 1) << 3; + if (np->rxopt.bits.dstopts) + put_cmsg(msg, SOL_IPV6, IPV6_DSTOPTS, len, ptr); + break; + case IPPROTO_ROUTING: + nexthdr = ptr[0]; + len = (ptr[1] + 1) << 3; + if (np->rxopt.bits.srcrt) + put_cmsg(msg, SOL_IPV6, IPV6_RTHDR, len, ptr); + break; + case IPPROTO_AH: + nexthdr = ptr[0]; + len = (ptr[1] + 1) << 2; + break; + default: + nexthdr = ptr[0]; + len = (ptr[1] + 1) << 3; + break; + } + + off += len; + } + } + + /* socket options in old style */ + if (np->rxopt.bits.rxoinfo) { + struct in6_pktinfo src_info; + + src_info.ipi6_ifindex = opt->iif; + ipv6_addr_copy(&src_info.ipi6_addr, &skb->nh.ipv6h->daddr); + put_cmsg(msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info); + } + if (np->rxopt.bits.rxohlim) { + int hlim = skb->nh.ipv6h->hop_limit; + put_cmsg(msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim); + } + if (np->rxopt.bits.ohopopts && opt->hop) { + u8 *ptr = skb->nh.raw + opt->hop; + put_cmsg(msg, SOL_IPV6, IPV6_2292HOPOPTS, (ptr[1]+1)<<3, ptr); + } + if (np->rxopt.bits.odstopts && opt->dst0) { u8 *ptr = skb->nh.raw + opt->dst0; - put_cmsg(msg, SOL_IPV6, IPV6_DSTOPTS, (ptr[1]+1)<<3, ptr); + put_cmsg(msg, SOL_IPV6, IPV6_2292DSTOPTS, (ptr[1]+1)<<3, ptr); } - if (np->rxopt.bits.srcrt && opt->srcrt) { + if (np->rxopt.bits.osrcrt && opt->srcrt) { struct ipv6_rt_hdr *rthdr = (struct ipv6_rt_hdr *)(skb->nh.raw + opt->srcrt); - put_cmsg(msg, SOL_IPV6, IPV6_RTHDR, (rthdr->hdrlen+1) << 3, rthdr); + put_cmsg(msg, SOL_IPV6, IPV6_2292RTHDR, (rthdr->hdrlen+1) << 3, rthdr); } - if (np->rxopt.bits.dstopts && opt->dst1) { + if (np->rxopt.bits.odstopts && opt->dst1) { u8 *ptr = skb->nh.raw + opt->dst1; - put_cmsg(msg, SOL_IPV6, IPV6_DSTOPTS, (ptr[1]+1)<<3, ptr); + put_cmsg(msg, SOL_IPV6, IPV6_2292DSTOPTS, (ptr[1]+1)<<3, ptr); } return 0; } @@ -438,6 +502,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, switch (cmsg->cmsg_type) { case IPV6_PKTINFO: + case IPV6_2292PKTINFO: if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct in6_pktinfo))) { err = -EINVAL; goto exit_f; @@ -492,6 +557,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, fl->fl6_flowlabel = IPV6_FLOWINFO_MASK & *(u32 *)CMSG_DATA(cmsg); break; + case IPV6_2292HOPOPTS: case IPV6_HOPOPTS: if (opt->hopopt || cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { err = -EINVAL; @@ -512,7 +578,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, opt->hopopt = hdr; break; - case IPV6_DSTOPTS: + case IPV6_2292DSTOPTS: if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { err = -EINVAL; goto exit_f; @@ -536,6 +602,33 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, opt->dst1opt = hdr; break; + case IPV6_DSTOPTS: + case IPV6_RTHDRDSTOPTS: + if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { + err = -EINVAL; + goto exit_f; + } + + hdr = (struct ipv6_opt_hdr *)CMSG_DATA(cmsg); + len = ((hdr->hdrlen + 1) << 3); + if (cmsg->cmsg_len < CMSG_LEN(len)) { + err = -EINVAL; + goto exit_f; + } + if (!capable(CAP_NET_RAW)) { + err = -EPERM; + goto exit_f; + } + if (cmsg->cmsg_type == IPV6_DSTOPTS) { + opt->opt_flen += len; + opt->dst1opt = hdr; + } else { + opt->opt_nflen += len; + opt->dst0opt = hdr; + } + break; + + case IPV6_2292RTHDR: case IPV6_RTHDR: if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_rt_hdr))) { err = -EINVAL; @@ -568,7 +661,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, opt->opt_nflen += len; opt->srcrt = rthdr; - if (opt->dst1opt) { + if (cmsg->cmsg_type == IPV6_2292RTHDR && opt->dst1opt) { int dsthdrlen = ((opt->dst1opt->hdrlen+1)<<3); opt->opt_nflen += dsthdrlen; @@ -579,6 +672,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, break; + case IPV6_2292HOPLIMIT: case IPV6_HOPLIMIT: if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) { err = -EINVAL; diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c index 5be6da2..ffcda45 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c @@ -164,6 +164,7 @@ static int ipv6_destopt_rcv(struct sk_buff **skbp, unsigned int *nhoffp) return -1; } + opt->lastopt = skb->h.raw - skb->nh.raw; opt->dst1 = skb->h.raw - skb->nh.raw; if (ip6_parse_tlv(tlvprocdestopt_lst, skb)) { @@ -243,6 +244,7 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp, unsigned int *nhoffp) looped_back: if (hdr->segments_left == 0) { + opt->lastopt = skb->h.raw - skb->nh.raw; opt->srcrt = skb->h.raw - skb->nh.raw; skb->h.raw += (hdr->hdrlen + 1) << 3; opt->dst0 = opt->dst1; @@ -539,10 +541,15 @@ void ipv6_push_nfrag_opts(struct sk_buff *skb, struct ipv6_txoptions *opt, u8 *proto, struct in6_addr **daddr) { - if (opt->srcrt) + if (opt->srcrt) { ipv6_push_rthdr(skb, proto, opt->srcrt, daddr); - if (opt->dst0opt) - ipv6_push_exthdr(skb, proto, NEXTHDR_DEST, opt->dst0opt); + /* + * IPV6_RTHDRDSTOPTS is ignored + * unless IPV6_RTHDR is set (RFC3542). + */ + if (opt->dst0opt) + ipv6_push_exthdr(skb, proto, NEXTHDR_DEST, opt->dst0opt); + } if (opt->hopopt) ipv6_push_exthdr(skb, proto, NEXTHDR_HOP, opt->hopopt); } @@ -573,3 +580,97 @@ ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt) } return opt2; } + +static int ipv6_renew_option(void *ohdr, + struct ipv6_opt_hdr __user *newopt, int newoptlen, + int inherit, + struct ipv6_opt_hdr **hdr, + char **p) +{ + if (inherit) { + if (ohdr) { + memcpy(*p, ohdr, ipv6_optlen((struct ipv6_opt_hdr *)ohdr)); + *hdr = (struct ipv6_opt_hdr *)*p; + *p += CMSG_ALIGN(ipv6_optlen(*(struct ipv6_opt_hdr **)hdr)); + } + } else { + if (newopt) { + if (copy_from_user(*p, newopt, newoptlen)) + return -EFAULT; + *hdr = (struct ipv6_opt_hdr *)*p; + if (ipv6_optlen(*(struct ipv6_opt_hdr **)hdr) > newoptlen) + return -EINVAL; + *p += CMSG_ALIGN(newoptlen); + } + } + return 0; +} + +struct ipv6_txoptions * +ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt, + int newtype, + struct ipv6_opt_hdr __user *newopt, int newoptlen) +{ + int tot_len = 0; + char *p; + struct ipv6_txoptions *opt2; + int err; + + if (newtype != IPV6_HOPOPTS && opt->hopopt) + tot_len += CMSG_ALIGN(ipv6_optlen(opt->hopopt)); + if (newtype != IPV6_RTHDRDSTOPTS && opt->dst0opt) + tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst0opt)); + if (newtype != IPV6_RTHDR && opt->srcrt) + tot_len += CMSG_ALIGN(ipv6_optlen(opt->srcrt)); + if (newtype != IPV6_DSTOPTS && opt->dst1opt) + tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt)); + if (newopt && newoptlen) + tot_len += CMSG_ALIGN(newoptlen); + + if (!tot_len) + return NULL; + + opt2 = sock_kmalloc(sk, tot_len, GFP_ATOMIC); + if (!opt2) + return ERR_PTR(-ENOBUFS); + + memset(opt2, 0, tot_len); + + opt2->tot_len = tot_len; + p = (char *)(opt2 + 1); + + err = ipv6_renew_option(opt->hopopt, newopt, newoptlen, + newtype != IPV6_HOPOPTS, + &opt2->hopopt, &p); + if (err) + goto out; + + err = ipv6_renew_option(opt->dst0opt, newopt, newoptlen, + newtype != IPV6_RTHDRDSTOPTS, + &opt2->dst0opt, &p); + if (err) + goto out; + + err = ipv6_renew_option(opt->srcrt, newopt, newoptlen, + newtype != IPV6_RTHDR, + (struct ipv6_opt_hdr **)opt2->srcrt, &p); + if (err) + goto out; + + err = ipv6_renew_option(opt->dst1opt, newopt, newoptlen, + newtype != IPV6_DSTOPTS, + &opt2->dst1opt, &p); + if (err) + goto out; + + opt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) + + (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) + + (opt2->srcrt ? ipv6_optlen(opt2->srcrt) : 0); + opt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0); + + return opt2; +out: + sock_kfree_s(sk, p, tot_len); + return ERR_PTR(err); +} + diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index b6c73da..2d5ce37 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c @@ -225,16 +225,20 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions * opt_space, struct ip6_flowlabel * fl, struct ipv6_txoptions * fopt) { - struct ipv6_txoptions * fl_opt = fl->opt; + struct ipv6_txoptions * fl_opt = fl ? fl->opt : NULL; - if (fopt == NULL || fopt->opt_flen == 0) - return fl_opt; + if (fopt == NULL || fopt->opt_flen == 0) { + if (!fl_opt || !fl_opt->dst0opt || fl_opt->srcrt) + return fl_opt; + } if (fl_opt != NULL) { opt_space->hopopt = fl_opt->hopopt; - opt_space->dst0opt = fl_opt->dst0opt; + opt_space->dst0opt = fl_opt->srcrt ? fl_opt->dst0opt : NULL; opt_space->srcrt = fl_opt->srcrt; opt_space->opt_nflen = fl_opt->opt_nflen; + if (fl_opt->dst0opt && !fl_opt->srcrt) + opt_space->opt_nflen -= ipv6_optlen(fl_opt->dst0opt); } else { if (fopt->opt_nflen == 0) return fopt; diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 76466af..dc1d991 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -210,39 +210,127 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, retv = 0; break; - case IPV6_PKTINFO: + case IPV6_RECVPKTINFO: np->rxopt.bits.rxinfo = valbool; retv = 0; break; + + case IPV6_2292PKTINFO: + np->rxopt.bits.rxoinfo = valbool; + retv = 0; + break; - case IPV6_HOPLIMIT: + case IPV6_RECVHOPLIMIT: np->rxopt.bits.rxhlim = valbool; retv = 0; break; - case IPV6_RTHDR: + case IPV6_2292HOPLIMIT: + np->rxopt.bits.rxohlim = valbool; + retv = 0; + break; + + case IPV6_RECVRTHDR: if (val < 0 || val > 2) goto e_inval; np->rxopt.bits.srcrt = val; retv = 0; break; - case IPV6_HOPOPTS: + case IPV6_2292RTHDR: + if (val < 0 || val > 2) + goto e_inval; + np->rxopt.bits.osrcrt = val; + retv = 0; + break; + + case IPV6_RECVHOPOPTS: np->rxopt.bits.hopopts = valbool; retv = 0; break; - case IPV6_DSTOPTS: + case IPV6_2292HOPOPTS: + np->rxopt.bits.ohopopts = valbool; + retv = 0; + break; + + case IPV6_RECVDSTOPTS: np->rxopt.bits.dstopts = valbool; retv = 0; break; + case IPV6_2292DSTOPTS: + np->rxopt.bits.odstopts = valbool; + retv = 0; + break; + case IPV6_FLOWINFO: np->rxopt.bits.rxflow = valbool; retv = 0; break; - case IPV6_PKTOPTIONS: + case IPV6_HOPOPTS: + case IPV6_RTHDRDSTOPTS: + case IPV6_RTHDR: + case IPV6_DSTOPTS: + { + struct ipv6_txoptions *opt; + if (optlen == 0) + optval = 0; + + /* hop-by-hop / destination options are privileged option */ + retv = -EPERM; + if (optname != IPV6_RTHDR && !capable(CAP_NET_RAW)) + break; + + retv = -EINVAL; + if (optlen & 0x7 || optlen > 8 * 255) + break; + + opt = ipv6_renew_options(sk, np->opt, optname, + (struct ipv6_opt_hdr __user *)optval, + optlen); + if (IS_ERR(opt)) { + retv = PTR_ERR(opt); + break; + } + + /* routing header option needs extra check */ + if (optname == IPV6_RTHDR && opt->srcrt) { + struct ipv6_rt_hdr *rthdr = opt->srcrt; + if (rthdr->type) + goto sticky_done; + if ((rthdr->hdrlen & 1) || + (rthdr->hdrlen >> 1) != rthdr->segments_left) + goto sticky_done; + } + + retv = 0; + if (sk->sk_type == SOCK_STREAM) { + if (opt) { + struct tcp_sock *tp = tcp_sk(sk); + if (!((1 << sk->sk_state) & + (TCPF_LISTEN | TCPF_CLOSE)) + && inet_sk(sk)->daddr != LOOPBACK4_IPV6) { + tp->ext_header_len = opt->opt_flen + opt->opt_nflen; + tcp_sync_mss(sk, tp->pmtu_cookie); + } + } + opt = xchg(&np->opt, opt); + sk_dst_reset(sk); + } else { + write_lock(&sk->sk_dst_lock); + opt = xchg(&np->opt, opt); + write_unlock(&sk->sk_dst_lock); + sk_dst_reset(sk); + } +sticky_done: + if (opt) + sock_kfree_s(sk, opt, opt->tot_len); + break; + } + + case IPV6_2292PKTOPTIONS: { struct ipv6_txoptions *opt = NULL; struct msghdr msg; @@ -529,6 +617,17 @@ e_inval: return -EINVAL; } +int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_opt_hdr *hdr, + char __user *optval, int len) +{ + if (!hdr) + return 0; + len = min_t(int, len, ipv6_optlen(hdr)); + if (copy_to_user(optval, hdr, ipv6_optlen(hdr))) + return -EFAULT; + return len; +} + int ipv6_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen) { @@ -567,7 +666,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, return err; } - case IPV6_PKTOPTIONS: + case IPV6_2292PKTOPTIONS: { struct msghdr msg; struct sk_buff *skb; @@ -601,6 +700,16 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, int hlim = np->mcast_hops; put_cmsg(&msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim); } + if (np->rxopt.bits.rxoinfo) { + struct in6_pktinfo src_info; + src_info.ipi6_ifindex = np->mcast_oif; + ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr); + put_cmsg(&msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info); + } + if (np->rxopt.bits.rxohlim) { + int hlim = np->mcast_hops; + put_cmsg(&msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim); + } } len -= msg.msg_controllen; return put_user(len, optlen); @@ -625,26 +734,59 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, val = np->ipv6only; break; - case IPV6_PKTINFO: + case IPV6_RECVPKTINFO: val = np->rxopt.bits.rxinfo; break; - case IPV6_HOPLIMIT: + case IPV6_2292PKTINFO: + val = np->rxopt.bits.rxoinfo; + break; + + case IPV6_RECVHOPLIMIT: val = np->rxopt.bits.rxhlim; break; - case IPV6_RTHDR: + case IPV6_2292HOPLIMIT: + val = np->rxopt.bits.rxohlim; + break; + + case IPV6_RECVRTHDR: val = np->rxopt.bits.srcrt; break; + case IPV6_2292RTHDR: + val = np->rxopt.bits.osrcrt; + break; + case IPV6_HOPOPTS: + case IPV6_RTHDRDSTOPTS: + case IPV6_RTHDR: + case IPV6_DSTOPTS: + { + + lock_sock(sk); + len = ipv6_getsockopt_sticky(sk, np->opt->hopopt, + optval, len); + release_sock(sk); + return put_user(len, optlen); + } + + case IPV6_RECVHOPOPTS: val = np->rxopt.bits.hopopts; break; - case IPV6_DSTOPTS: + case IPV6_2292HOPOPTS: + val = np->rxopt.bits.ohopopts; + break; + + case IPV6_RECVDSTOPTS: val = np->rxopt.bits.dstopts; break; + case IPV6_2292DSTOPTS: + val = np->rxopt.bits.odstopts; + break; + case IPV6_FLOWINFO: val = np->rxopt.bits.rxflow; break; diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index ed3a76b..e527a16 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -755,8 +755,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, } if (opt == NULL) opt = np->opt; - if (flowlabel) - opt = fl6_merge_options(&opt_space, flowlabel, opt); + opt = fl6_merge_options(&opt_space, flowlabel, opt); fl.proto = proto; rawv6_probe_proto_opt(&fl, msg); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 794734f..246414b 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -849,7 +849,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req, if (dst == NULL) { opt = np->opt; if (opt == NULL && - np->rxopt.bits.srcrt == 2 && + np->rxopt.bits.osrcrt == 2 && treq->pktopts) { struct sk_buff *pktopts = treq->pktopts; struct inet6_skb_parm *rxopt = IP6CB(pktopts); @@ -915,11 +915,10 @@ static int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb) struct inet6_skb_parm *opt = IP6CB(skb); if (np->rxopt.all) { - if ((opt->hop && np->rxopt.bits.hopopts) || - ((IPV6_FLOWINFO_MASK&*(u32*)skb->nh.raw) && - np->rxopt.bits.rxflow) || - (opt->srcrt && np->rxopt.bits.srcrt) || - ((opt->dst1 || opt->dst0) && np->rxopt.bits.dstopts)) + if ((opt->hop && (np->rxopt.bits.hopopts || np->rxopt.bits.ohopopts)) || + ((IPV6_FLOWINFO_MASK & *(u32*)skb->nh.raw) && np->rxopt.bits.rxflow) || + (opt->srcrt && (np->rxopt.bits.srcrt || np->rxopt.bits.osrcrt)) || + ((opt->dst1 || opt->dst0) && (np->rxopt.bits.dstopts || np->rxopt.bits.odstopts))) return 1; } return 0; @@ -1190,8 +1189,8 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) TCP_ECN_create_request(req, skb->h.th); treq->pktopts = NULL; if (ipv6_opt_accepted(sk, skb) || - np->rxopt.bits.rxinfo || - np->rxopt.bits.rxhlim) { + np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo || + np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) { atomic_inc(&skb->users); treq->pktopts = skb; } @@ -1288,7 +1287,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, if (sk_acceptq_is_full(sk)) goto out_overflow; - if (np->rxopt.bits.srcrt == 2 && + if (np->rxopt.bits.osrcrt == 2 && opt == NULL && treq->pktopts) { struct inet6_skb_parm *rxopt = IP6CB(treq->pktopts); if (rxopt->srcrt) @@ -1544,9 +1543,9 @@ ipv6_pktoptions: tp = tcp_sk(sk); if (TCP_SKB_CB(opt_skb)->end_seq == tp->rcv_nxt && !((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) { - if (np->rxopt.bits.rxinfo) + if (np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo) np->mcast_oif = inet6_iif(opt_skb); - if (np->rxopt.bits.rxhlim) + if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) np->mcast_hops = opt_skb->nh.ipv6h->hop_limit; if (ipv6_opt_accepted(sk, opt_skb)) { skb_set_owner_r(opt_skb, sk); diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 390d750..aa6eaf3 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -773,8 +773,7 @@ do_udp_sendmsg: } if (opt == NULL) opt = np->opt; - if (flowlabel) - opt = fl6_merge_options(&opt_space, flowlabel, opt); + opt = fl6_merge_options(&opt_space, flowlabel, opt); fl->proto = IPPROTO_UDP; ipv6_addr_copy(&fl->fl6_dst, daddr); -- cgit v0.10.2 From 41a1f8ea4fbfcdc4232f023732584aae2220de31 Mon Sep 17 00:00:00 2001 From: YOSHIFUJI Hideaki Date: Thu, 8 Sep 2005 10:19:03 +0900 Subject: [IPV6]: Support IPV6_{RECV,}TCLASS socket options / ancillary data. Based on patch from David L Stevens Signed-off-by: David L Stevens Signed-off-by: YOSHIFUJI Hideaki diff --git a/include/linux/in6.h b/include/linux/in6.h index c11022f..bd32b79 100644 --- a/include/linux/in6.h +++ b/include/linux/in6.h @@ -219,9 +219,7 @@ struct in6_flowlabel_req #define IPV6_DSTOPTS 63 #define IPV6_RECVHOPLIMIT 64 #define IPV6_HOPLIMIT 65 -#if 0 #define IPV6_RECVTCLASS 66 #define IPV6_TCLASS 67 -#endif #endif diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 2581f1c..6c5f7b3 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -245,7 +245,8 @@ struct ipv6_pinfo { ohopopts:1, dstopts:1, odstopts:1, - rxflow:1; + rxflow:1, + rxtclass:1; } bits; __u16 all; } rxopt; @@ -256,6 +257,7 @@ struct ipv6_pinfo { sndflow:1, pmtudisc:2, ipv6only:1; + __u8 tclass; __u32 dst_cookie; @@ -269,6 +271,7 @@ struct ipv6_pinfo { struct ipv6_txoptions *opt; struct rt6_info *rt; int hop_limit; + int tclass; } cork; }; diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 8a9fe94..65ec866 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -377,6 +377,7 @@ extern int ip6_append_data(struct sock *sk, int length, int transhdrlen, int hlimit, + int tclass, struct ipv6_txoptions *opt, struct flowi *fl, struct rt6_info *rt, diff --git a/include/net/transp_v6.h b/include/net/transp_v6.h index 8b075ab..4e86f2d 100644 --- a/include/net/transp_v6.h +++ b/include/net/transp_v6.h @@ -37,7 +37,7 @@ extern int datagram_recv_ctl(struct sock *sk, extern int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, struct ipv6_txoptions *opt, - int *hlimit); + int *hlimit, int *tclass); #define LOOPBACK4_IPV6 __constant_htonl(0x7f000006) diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 832476b..157cec6 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -390,6 +390,11 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) put_cmsg(msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim); } + if (np->rxopt.bits.rxtclass) { + int tclass = (ntohl(*(u32 *)skb->nh.ipv6h) >> 20) & 0xff; + put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); + } + if (np->rxopt.bits.rxflow && (*(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK)) { u32 flowinfo = *(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK; put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); @@ -479,7 +484,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, struct ipv6_txoptions *opt, - int *hlimit) + int *hlimit, int *tclass) { struct in6_pktinfo *src_info; struct cmsghdr *cmsg; @@ -682,6 +687,24 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, *hlimit = *(int *)CMSG_DATA(cmsg); break; + case IPV6_TCLASS: + { + int tc; + + err = -EINVAL; + if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) { + goto exit_f; + } + + tc = *(int *)CMSG_DATA(cmsg); + if (tc < 0 || tc > 0xff) + goto exit_f; + + err = 0; + *tclass = tc; + + break; + } default: LIMIT_NETDEBUG(KERN_DEBUG "invalid cmsg type: %d\n", cmsg->cmsg_type); diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index fa8f1bb..34e99c5 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -287,7 +287,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, int iif = 0; int addr_type = 0; int len; - int hlimit; + int hlimit, tclass; int err = 0; if ((u8*)hdr < skb->head || (u8*)(hdr+1) > skb->tail) @@ -385,6 +385,10 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, if (hlimit < 0) hlimit = ipv6_get_hoplimit(dst->dev); + tclass = np->cork.tclass; + if (tclass < 0) + tclass = 0; + msg.skb = skb; msg.offset = skb->nh.raw - skb->data; @@ -400,7 +404,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, err = ip6_append_data(sk, icmpv6_getfrag, &msg, len + sizeof(struct icmp6hdr), sizeof(struct icmp6hdr), - hlimit, NULL, &fl, (struct rt6_info*)dst, + hlimit, tclass, NULL, &fl, (struct rt6_info*)dst, MSG_DONTWAIT); if (err) { ip6_flush_pending_frames(sk); @@ -434,6 +438,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb) struct dst_entry *dst; int err = 0; int hlimit; + int tclass; saddr = &skb->nh.ipv6h->daddr; @@ -475,13 +480,17 @@ static void icmpv6_echo_reply(struct sk_buff *skb) if (hlimit < 0) hlimit = ipv6_get_hoplimit(dst->dev); + tclass = np->cork.tclass; + if (tclass < 0) + tclass = 0; + idev = in6_dev_get(skb->dev); msg.skb = skb; msg.offset = 0; err = ip6_append_data(sk, icmpv6_getfrag, &msg, skb->len + sizeof(struct icmp6hdr), - sizeof(struct icmp6hdr), hlimit, NULL, &fl, + sizeof(struct icmp6hdr), hlimit, tclass, NULL, &fl, (struct rt6_info*)dst, MSG_DONTWAIT); if (err) { diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index 2d5ce37..a7db762 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c @@ -314,7 +314,7 @@ fl_create(struct in6_flowlabel_req *freq, char __user *optval, int optlen, int * msg.msg_control = (void*)(fl->opt+1); flowi.oif = 0; - err = datagram_send_ctl(&msg, &flowi, fl->opt, &junk); + err = datagram_send_ctl(&msg, &flowi, fl->opt, &junk, &junk); if (err) goto done; err = -EINVAL; diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 01ef94f..2f589f2 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -166,7 +166,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, struct ipv6hdr *hdr; u8 proto = fl->proto; int seg_len = skb->len; - int hlimit; + int hlimit, tclass; u32 mtu; if (opt) { @@ -202,7 +202,6 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, * Fill in the IPv6 header */ - *(u32*)hdr = htonl(0x60000000) | fl->fl6_flowlabel; hlimit = -1; if (np) hlimit = np->hop_limit; @@ -211,6 +210,14 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, if (hlimit < 0) hlimit = ipv6_get_hoplimit(dst->dev); + tclass = -1; + if (np) + tclass = np->tclass; + if (tclass < 0) + tclass = 0; + + *(u32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl->fl6_flowlabel; + hdr->payload_len = htons(seg_len); hdr->nexthdr = proto; hdr->hop_limit = hlimit; @@ -762,10 +769,11 @@ out_err_release: return err; } -int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb), - void *from, int length, int transhdrlen, - int hlimit, struct ipv6_txoptions *opt, struct flowi *fl, struct rt6_info *rt, - unsigned int flags) +int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, + int offset, int len, int odd, struct sk_buff *skb), + void *from, int length, int transhdrlen, + int hlimit, int tclass, struct ipv6_txoptions *opt, struct flowi *fl, + struct rt6_info *rt, unsigned int flags) { struct inet_sock *inet = inet_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk); @@ -803,6 +811,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, int offse np->cork.rt = rt; inet->cork.fl = *fl; np->cork.hop_limit = hlimit; + np->cork.tclass = tclass; inet->cork.fragsize = mtu = dst_mtu(rt->u.dst.path); if (dst_allfrag(rt->u.dst.path)) inet->cork.flags |= IPCORK_ALLFRAG; @@ -1084,7 +1093,8 @@ int ip6_push_pending_frames(struct sock *sk) skb->nh.ipv6h = hdr = (struct ipv6hdr*) skb_push(skb, sizeof(struct ipv6hdr)); - *(u32*)hdr = fl->fl6_flowlabel | htonl(0x60000000); + *(u32*)hdr = fl->fl6_flowlabel | + htonl(0x60000000 | ((int)np->cork.tclass << 20)); if (skb->len <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) hdr->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index dc1d991..8567873 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -264,6 +264,18 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, retv = 0; break; + case IPV6_TCLASS: + if (val < 0 || val > 0xff) + goto e_inval; + np->tclass = val; + retv = 0; + break; + + case IPV6_RECVTCLASS: + np->rxopt.bits.rxtclass = valbool; + retv = 0; + break; + case IPV6_FLOWINFO: np->rxopt.bits.rxflow = valbool; retv = 0; @@ -364,7 +376,7 @@ sticky_done: msg.msg_controllen = optlen; msg.msg_control = (void*)(opt+1); - retv = datagram_send_ctl(&msg, &fl, opt, &junk); + retv = datagram_send_ctl(&msg, &fl, opt, &junk, &junk); if (retv) goto done; update: @@ -787,6 +799,14 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, val = np->rxopt.bits.odstopts; break; + case IPV6_TCLASS: + val = np->tclass; + break; + + case IPV6_RECVTCLASS: + val = np->rxopt.bits.rxtclass; + break; + case IPV6_FLOWINFO: val = np->rxopt.bits.rxflow; break; diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index e527a16..2ad3789 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -655,6 +655,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct flowi fl; int addr_len = msg->msg_namelen; int hlimit = -1; + int tclass = -1; u16 proto; int err; @@ -740,7 +741,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, memset(opt, 0, sizeof(struct ipv6_txoptions)); opt->tot_len = sizeof(struct ipv6_txoptions); - err = datagram_send_ctl(msg, &fl, opt, &hlimit); + err = datagram_send_ctl(msg, &fl, opt, &hlimit, &tclass); if (err < 0) { fl6_sock_release(flowlabel); return err; @@ -797,6 +798,12 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, hlimit = ipv6_get_hoplimit(dst->dev); } + if (tclass < 0) { + tclass = np->cork.tclass; + if (tclass < 0) + tclass = 0; + } + if (msg->msg_flags&MSG_CONFIRM) goto do_confirm; @@ -805,8 +812,9 @@ back_from_confirm: err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl, (struct rt6_info*)dst, msg->msg_flags); } else { lock_sock(sk); - err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, len, 0, - hlimit, opt, &fl, (struct rt6_info*)dst, msg->msg_flags); + err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, + len, 0, hlimit, tclass, opt, &fl, (struct rt6_info*)dst, + msg->msg_flags); if (err) ip6_flush_pending_frames(sk); diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index aa6eaf3..dbd18a9 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -637,6 +637,7 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, int addr_len = msg->msg_namelen; int ulen = len; int hlimit = -1; + int tclass = -1; int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; int err; @@ -758,7 +759,7 @@ do_udp_sendmsg: memset(opt, 0, sizeof(struct ipv6_txoptions)); opt->tot_len = sizeof(*opt); - err = datagram_send_ctl(msg, fl, opt, &hlimit); + err = datagram_send_ctl(msg, fl, opt, &hlimit, &tclass); if (err < 0) { fl6_sock_release(flowlabel); return err; @@ -814,6 +815,12 @@ do_udp_sendmsg: hlimit = ipv6_get_hoplimit(dst->dev); } + if (tclass < 0) { + tclass = np->tclass; + if (tclass < 0) + tclass = 0; + } + if (msg->msg_flags&MSG_CONFIRM) goto do_confirm; back_from_confirm: @@ -833,9 +840,10 @@ back_from_confirm: do_append_data: up->len += ulen; - err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, ulen, sizeof(struct udphdr), - hlimit, opt, fl, (struct rt6_info*)dst, - corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); + err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, ulen, + sizeof(struct udphdr), hlimit, tclass, opt, fl, + (struct rt6_info*)dst, + corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); if (err) udp_v6_flush_pending_frames(sk); else if (!corkreq) -- cgit v0.10.2 From f016bad6be720496b5582a59738bca00a26f876c Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Thu, 8 Sep 2005 15:30:05 +1000 Subject: [XFS] Cleanup some -Wundef flag warnings in the endian macros (thanks Christoph). SGI-PV: 942400 SGI-Modid: xfs-linux-melb:xfs-kern:23771a Signed-off-by: Nathan Scott diff --git a/fs/xfs/xfs_arch.h b/fs/xfs/xfs_arch.h index ae35189..5ab0dd8 100644 --- a/fs/xfs/xfs_arch.h +++ b/fs/xfs/xfs_arch.h @@ -40,22 +40,28 @@ #include -#ifdef __LITTLE_ENDIAN -# define __BYTE_ORDER __LITTLE_ENDIAN -#endif #ifdef __BIG_ENDIAN -# define __BYTE_ORDER __BIG_ENDIAN +#define XFS_NATIVE_HOST 1 +#else +#undef XFS_NATIVE_HOST +#endif + +#else /* __KERNEL__ */ + +#if __BYTE_ORDER == __BIG_ENDIAN +#define XFS_NATIVE_HOST 1 +#else +#undef XFS_NATIVE_HOST #endif #endif /* __KERNEL__ */ /* do we need conversion? */ - #define ARCH_NOCONVERT 1 -#if __BYTE_ORDER == __LITTLE_ENDIAN -# define ARCH_CONVERT 0 -#else +#ifdef XFS_NATIVE_HOST # define ARCH_CONVERT ARCH_NOCONVERT +#else +# define ARCH_CONVERT 0 #endif /* generic swapping macros */ diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index 09c4135..09a77b1 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c @@ -2017,7 +2017,7 @@ xfs_bmbt_get_state( ext_flag); } -#if __BYTE_ORDER != __BIG_ENDIAN +#ifndef XFS_NATIVE_HOST /* Endian flipping versions of the bmbt extraction functions */ void xfs_bmbt_disk_get_all( @@ -2087,7 +2087,7 @@ xfs_bmbt_disk_get_state( return xfs_extent_state(xfs_bmbt_disk_get_blockcount(r), ext_flag); } -#endif +#endif /* XFS_NATIVE_HOST */ /* @@ -2531,7 +2531,7 @@ xfs_bmbt_set_allf( #endif /* XFS_BIG_BLKNOS */ } -#if __BYTE_ORDER != __BIG_ENDIAN +#ifndef XFS_NATIVE_HOST /* * Set all the fields in a bmap extent record from the uncompressed form. */ @@ -2617,7 +2617,7 @@ xfs_bmbt_disk_set_allf( } #endif /* XFS_BIG_BLKNOS */ } -#endif +#endif /* XFS_NATIVE_HOST */ /* * Set the blockcount field in a bmap extent record. diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h index 0a40cf1..2cf4fe4 100644 --- a/fs/xfs/xfs_bmap_btree.h +++ b/fs/xfs/xfs_bmap_btree.h @@ -62,7 +62,7 @@ typedef struct xfs_bmdr_block * l1:0-20 are blockcount. */ -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifndef XFS_NATIVE_HOST #define BMBT_TOTAL_BITLEN 128 /* 128 bits, 16 bytes */ #define BMBT_EXNTFLAG_BITOFF 0 @@ -87,7 +87,7 @@ typedef struct xfs_bmdr_block #define BMBT_BLOCKCOUNT_BITOFF 64 /* Start of second 64 bit container */ #define BMBT_BLOCKCOUNT_BITLEN 21 -#endif +#endif /* XFS_NATIVE_HOST */ #define BMBT_USE_64 1 @@ -505,7 +505,7 @@ xfs_exntst_t xfs_bmbt_get_state( xfs_bmbt_rec_t *r); -#if __BYTE_ORDER != __BIG_ENDIAN +#ifndef XFS_NATIVE_HOST void xfs_bmbt_disk_get_all( xfs_bmbt_rec_t *r, @@ -538,7 +538,7 @@ xfs_bmbt_disk_get_startoff( xfs_bmbt_get_blockcount(r) #define xfs_bmbt_disk_get_startoff(r) \ xfs_bmbt_get_startoff(r) -#endif +#endif /* XFS_NATIVE_HOST */ int xfs_bmbt_increment( @@ -623,7 +623,7 @@ xfs_bmbt_set_state( xfs_bmbt_rec_t *r, xfs_exntst_t v); -#if __BYTE_ORDER != __BIG_ENDIAN +#ifndef XFS_NATIVE_HOST void xfs_bmbt_disk_set_all( xfs_bmbt_rec_t *r, @@ -641,7 +641,7 @@ xfs_bmbt_disk_set_allf( xfs_bmbt_set_all(r, s) #define xfs_bmbt_disk_set_allf(r, o, b, c, v) \ xfs_bmbt_set_allf(r, o, b, c, v) -#endif +#endif /* XFS_NATIVE_HOST */ void xfs_bmbt_to_bmdr( diff --git a/fs/xfs/xfs_dir_leaf.h b/fs/xfs/xfs_dir_leaf.h index dd423ce..480bffc 100644 --- a/fs/xfs/xfs_dir_leaf.h +++ b/fs/xfs/xfs_dir_leaf.h @@ -127,13 +127,13 @@ typedef union { * Watch the order here (endian-ness dependent). */ struct { -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifndef XFS_NATIVE_HOST xfs_dahash_t h; /* hash value */ __uint32_t be; /* block and entry */ -#else /* __BYTE_ORDER == __BIG_ENDIAN */ +#else __uint32_t be; /* block and entry */ xfs_dahash_t h; /* hash value */ -#endif /* __BYTE_ORDER == __BIG_ENDIAN */ +#endif /* XFS_NATIVE_HOST */ } s; } xfs_dircook_t; diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 276ec70..50e2cad 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -341,7 +341,7 @@ xfs_inode_item_format( nrecs = ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t); ASSERT(nrecs > 0); -#if __BYTE_ORDER == __BIG_ENDIAN +#ifdef XFS_NATIVE_HOST if (nrecs == ip->i_d.di_nextents) { /* * There are no delayed allocation @@ -473,7 +473,7 @@ xfs_inode_item_format( #endif ASSERT(nrecs > 0); ASSERT(nrecs == ip->i_d.di_anextents); -#if __BYTE_ORDER == __BIG_ENDIAN +#ifdef XFS_NATIVE_HOST /* * There are not delayed allocation extents * for attributes, so just point at the array. diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index eb7fdc6..a884cea 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -112,7 +112,7 @@ struct xfs_mount; * this has endian issues, of course. */ -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifndef XFS_NATIVE_HOST #define GET_CLIENT_ID(i,arch) \ ((i) & 0xff) #else @@ -414,14 +414,10 @@ typedef struct xlog_op_header { #define XLOG_FMT_IRIX_BE 3 /* our fmt */ -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define XLOG_FMT XLOG_FMT_LINUX_LE -#else -#if __BYTE_ORDER == __BIG_ENDIAN +#ifdef XFS_NATIVE_HOST #define XLOG_FMT XLOG_FMT_LINUX_BE #else -#error unknown byte order -#endif +#define XLOG_FMT XLOG_FMT_LINUX_LE #endif typedef struct xlog_rec_header { -- cgit v0.10.2 From 20ba02879bc78cdf1ed89a1c6a92ee55d31ee103 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Thu, 8 Sep 2005 15:34:58 +1000 Subject: [XFS] Remove special Kconfig XFS menu, make XFS options "inline". Signed-off-by: Eric Sandeen Signed-off-by: Nathan Scott diff --git a/fs/xfs/Kconfig b/fs/xfs/Kconfig index c92306f..8e8f32d 100644 --- a/fs/xfs/Kconfig +++ b/fs/xfs/Kconfig @@ -1,5 +1,3 @@ -menu "XFS support" - config XFS_FS tristate "XFS filesystem support" select EXPORTFS if NFSD!=n @@ -22,27 +20,11 @@ config XFS_FS config XFS_EXPORT bool - default y if XFS_FS && EXPORTFS - -config XFS_RT - bool "Realtime support (EXPERIMENTAL)" - depends on XFS_FS && EXPERIMENTAL - help - If you say Y here you will be able to mount and use XFS filesystems - which contain a realtime subvolume. The realtime subvolume is a - separate area of disk space where only file data is stored. The - realtime subvolume is designed to provide very deterministic - data rates suitable for media streaming applications. - - See the xfs man page in section 5 for a bit more information. - - This feature is unsupported at this time, is not yet fully - functional, and may cause serious problems. - - If unsure, say N. + depends on XFS_FS && EXPORTFS + default y config XFS_QUOTA - bool "Quota support" + tristate "XFS Quota support" depends on XFS_FS help If you say Y here, you will be able to set limits for disk usage on @@ -59,7 +41,7 @@ config XFS_QUOTA they are completely independent subsystems. config XFS_SECURITY - bool "Security Label support" + bool "XFS Security Label support" depends on XFS_FS help Security labels support alternative access control models @@ -71,7 +53,7 @@ config XFS_SECURITY extended attributes for inode security labels, say N. config XFS_POSIX_ACL - bool "POSIX ACL support" + bool "XFS POSIX ACL support" depends on XFS_FS help POSIX Access Control Lists (ACLs) support permissions for users and @@ -82,4 +64,19 @@ config XFS_POSIX_ACL If you don't know what Access Control Lists are, say N. -endmenu +config XFS_RT + bool "XFS Realtime support (EXPERIMENTAL)" + depends on XFS_FS && EXPERIMENTAL + help + If you say Y here you will be able to mount and use XFS filesystems + which contain a realtime subvolume. The realtime subvolume is a + separate area of disk space where only file data is stored. The + realtime subvolume is designed to provide very deterministic + data rates suitable for media streaming applications. + + See the xfs man page in section 5 for a bit more information. + + This feature is unsupported at this time, is not yet fully + functional, and may cause serious problems. + + If unsure, say N. -- cgit v0.10.2 From eccdfcd6f8265300380fa14a83aeb14e69830323 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Thu, 8 Sep 2005 15:38:52 +1000 Subject: [XFS] Fix modular XFS builds (Makefile botch). Signed-off-by: Nathan Scott diff --git a/fs/xfs/Makefile-linux-2.6 b/fs/xfs/Makefile-linux-2.6 index fbfcbe5..8e18ff1 100644 --- a/fs/xfs/Makefile-linux-2.6 +++ b/fs/xfs/Makefile-linux-2.6 @@ -55,7 +55,7 @@ ifeq ($(CONFIG_XFS_TRACE),y) endif obj-$(CONFIG_XFS_FS) += xfs.o -obj-$(CONFIG_XFS_QUOTA) += quota/ +xfs-$(CONFIG_XFS_QUOTA) += quota/ xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o diff --git a/fs/xfs/quota/Makefile-linux-2.6 b/fs/xfs/quota/Makefile-linux-2.6 index 8b7b676..93e60e8 100644 --- a/fs/xfs/quota/Makefile-linux-2.6 +++ b/fs/xfs/quota/Makefile-linux-2.6 @@ -41,13 +41,13 @@ ifeq ($(CONFIG_XFS_TRACE),y) EXTRA_CFLAGS += -DXFS_VNODE_TRACE endif -obj-$(CONFIG_XFS_QUOTA) += xfs_quota.o - -xfs_quota-y += xfs_dquot.o \ +xfs-$(CONFIG_XFS_QUOTA) += xfs_dquot.o \ xfs_dquot_item.o \ xfs_trans_dquot.o \ xfs_qm_syscalls.o \ xfs_qm_bhv.o \ xfs_qm.o -xfs_quota-$(CONFIG_PROC_FS) += xfs_qm_stats.o +ifeq ($(CONFIG_XFS_QUOTA),y) +xfs-$(CONFIG_PROC_FS) += xfs_qm_stats.o +endif -- cgit v0.10.2 From 6a690df5c8b37d4a1c41df40770d42d44fac0e97 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Tue, 28 Jun 2005 17:30:38 -0700 Subject: [PATCH] scan all enabled ports on ata_piix ICH6 spec defines the PORT_ bits as: PORT_ENABLED (R/W): 0 = Disabled. The port is in the off state and cannot detect any devices. 1 = Enabled. The port can transition between the on, partial, and slumber states and can detect devices. PORT_PRESENT (R/O) The status of this bit may change at any time. This bit is cleared when the port is disabled via PORT_ENABLED. This bit is not cleared upon surprise removal of a device. So from a textual view it is not necessary that PORT_PRESENT _must_ be set, especially if a device detection has to be done anyway. And, in fact, this is the view that ACER has been taken with its new Laptops (e.g. Travelmate 4150). And the definition of PORT_ENABLED / PORT_PRESENT is mixed up, btw. Signed-off-by: Hannes Reinecke Signed-off-by: Jens Axboe Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index deec0ce..5f86885 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c @@ -68,8 +68,8 @@ enum { PIIX_COMB_PATA_P0 = (1 << 1), PIIX_COMB = (1 << 2), /* combined mode enabled? */ - PIIX_PORT_PRESENT = (1 << 0), - PIIX_PORT_ENABLED = (1 << 4), + PIIX_PORT_ENABLED = (1 << 0), + PIIX_PORT_PRESENT = (1 << 4), PIIX_80C_PRI = (1 << 5) | (1 << 4), PIIX_80C_SEC = (1 << 7) | (1 << 6), @@ -377,7 +377,9 @@ static void piix_pata_phy_reset(struct ata_port *ap) * None (inherited from caller). * * RETURNS: - * Non-zero if device detected, zero otherwise. + * Non-zero if port is enabled, it may or may not have a device + * attached in that case (PRESENT bit would only be set if BIOS probe + * was done). Zero is returned if port is disabled. */ static int piix_sata_probe (struct ata_port *ap) { @@ -401,7 +403,7 @@ static int piix_sata_probe (struct ata_port *ap) */ for (i = 0; i < 4; i++) { - mask = (PIIX_PORT_PRESENT << i) | (PIIX_PORT_ENABLED << i); + mask = (PIIX_PORT_ENABLED << i); if ((orig_mask & mask) == mask) if (combined || (i == ap->hard_port_no)) -- cgit v0.10.2 From b38d950d3aedf90c8b15b3c7c799b5eb53c47c45 Mon Sep 17 00:00:00 2001 From: John Lenz Date: Thu, 8 Sep 2005 14:41:54 +0100 Subject: [ARM] Add suspend/resume support to locomo.c This adds low-level suspend/resume support to locomo.c. Signed-off-by: Pavel Machek Signed-off-by: Russell King diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c index 51f430c..2786f7c 100644 --- a/arch/arm/common/locomo.c +++ b/arch/arm/common/locomo.c @@ -541,6 +541,103 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info) return ret; } +#ifdef CONFIG_PM + +struct locomo_save_data { + u16 LCM_GPO; + u16 LCM_SPICT; + u16 LCM_GPE; + u16 LCM_ASD; + u16 LCM_SPIMD; +}; + +static int locomo_suspend(struct device *dev, u32 pm_message_t, u32 level) +{ + struct locomo *lchip = dev_get_drvdata(dev); + struct locomo_save_data *save; + unsigned long flags; + + if (level != SUSPEND_DISABLE) + return 0; + + save = kmalloc(sizeof(struct locomo_save_data), GFP_KERNEL); + if (!save) + return -ENOMEM; + + dev->power.saved_state = (void *) save; + + spin_lock_irqsave(&lchip->lock, flags); + + save->LCM_GPO = locomo_readl(lchip->base + LOCOMO_GPO); /* GPIO */ + locomo_writel(0x00, lchip->base + LOCOMO_GPO); + save->LCM_SPICT = locomo_readl(lchip->base + LOCOMO_SPICT); /* SPI */ + locomo_writel(0x40, lchip->base + LOCOMO_SPICT); + save->LCM_GPE = locomo_readl(lchip->base + LOCOMO_GPE); /* GPIO */ + locomo_writel(0x00, lchip->base + LOCOMO_GPE); + save->LCM_ASD = locomo_readl(lchip->base + LOCOMO_ASD); /* ADSTART */ + locomo_writel(0x00, lchip->base + LOCOMO_ASD); + save->LCM_SPIMD = locomo_readl(lchip->base + LOCOMO_SPIMD); /* SPI */ + locomo_writel(0x3C14, lchip->base + LOCOMO_SPIMD); + + locomo_writel(0x00, lchip->base + LOCOMO_PAIF); + locomo_writel(0x00, lchip->base + LOCOMO_DAC); + locomo_writel(0x00, lchip->base + LOCOMO_BACKLIGHT + LOCOMO_TC); + + if ( (locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT0) & 0x88) && (locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT1) & 0x88) ) + locomo_writel(0x00, lchip->base + LOCOMO_C32K); /* CLK32 off */ + else + /* 18MHz already enabled, so no wait */ + locomo_writel(0xc1, lchip->base + LOCOMO_C32K); /* CLK32 on */ + + locomo_writel(0x00, lchip->base + LOCOMO_TADC); /* 18MHz clock off*/ + locomo_writel(0x00, lchip->base + LOCOMO_AUDIO + LOCOMO_ACC); /* 22MHz/24MHz clock off */ + locomo_writel(0x00, lchip->base + LOCOMO_FRONTLIGHT + LOCOMO_ALS); /* FL */ + + spin_unlock_irqrestore(&lchip->lock, flags); + + return 0; +} + +static int locomo_resume(struct device *dev, u32 level) +{ + struct locomo *lchip = dev_get_drvdata(dev); + struct locomo_save_data *save; + unsigned long r; + unsigned long flags; + + if (level != RESUME_ENABLE) + return 0; + + save = (struct locomo_save_data *) dev->power.saved_state; + if (!save) + return 0; + + spin_lock_irqsave(&lchip->lock, flags); + + locomo_writel(save->LCM_GPO, lchip->base + LOCOMO_GPO); + locomo_writel(save->LCM_SPICT, lchip->base + LOCOMO_SPICT); + locomo_writel(save->LCM_GPE, lchip->base + LOCOMO_GPE); + locomo_writel(save->LCM_ASD, lchip->base + LOCOMO_ASD); + locomo_writel(save->LCM_SPIMD, lchip->base + LOCOMO_SPIMD); + + locomo_writel(0x00, lchip->base + LOCOMO_C32K); + locomo_writel(0x90, lchip->base + LOCOMO_TADC); + + locomo_writel(0, lchip->base + LOCOMO_KEYBOARD + LOCOMO_KSC); + r = locomo_readl(lchip->base + LOCOMO_KEYBOARD + LOCOMO_KIC); + r &= 0xFEFF; + locomo_writel(r, lchip->base + LOCOMO_KEYBOARD + LOCOMO_KIC); + locomo_writel(0x1, lchip->base + LOCOMO_KEYBOARD + LOCOMO_KCMD); + + spin_unlock_irqrestore(&lchip->lock, flags); + + dev->power.saved_state = NULL; + kfree(save); + + return 0; +} +#endif + /** * locomo_probe - probe for a single LoCoMo chip. * @phys_addr: physical address of device. @@ -707,6 +804,10 @@ static struct device_driver locomo_device_driver = { .bus = &platform_bus_type, .probe = locomo_probe, .remove = locomo_remove, +#ifdef CONFIG_PM + .suspend = locomo_suspend, + .resume = locomo_resume, +#endif }; /* -- cgit v0.10.2 From d7b6b3589471c3856f1e6dc9c77abc4af962ffdb Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 8 Sep 2005 15:32:23 +0100 Subject: [ARM] Fix ARMv6 VIPT cache >= 32K This adds the necessary changes to ensure that we flush the caches correctly with aliasing VIPT caches. Signed-off-by: Russell King diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c index 191788f..b0208c9 100644 --- a/arch/arm/mm/flush.c +++ b/arch/arm/mm/flush.c @@ -16,6 +16,58 @@ #include #ifdef CONFIG_CPU_CACHE_VIPT + +void flush_cache_mm(struct mm_struct *mm) +{ + if (cache_is_vivt()) { + if (cpu_isset(smp_processor_id(), mm->cpu_vm_mask)) + __cpuc_flush_user_all(); + return; + } + + if (cache_is_vipt_aliasing()) { + asm( "mcr p15, 0, %0, c7, c14, 0\n" + " mcr p15, 0, %0, c7, c5, 0\n" + " mcr p15, 0, %0, c7, c10, 4" + : + : "r" (0) + : "cc"); + } +} + +void flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) +{ + if (cache_is_vivt()) { + if (cpu_isset(smp_processor_id(), vma->vm_mm->cpu_vm_mask)) + __cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end), + vma->vm_flags); + return; + } + + if (cache_is_vipt_aliasing()) { + asm( "mcr p15, 0, %0, c7, c14, 0\n" + " mcr p15, 0, %0, c7, c5, 0\n" + " mcr p15, 0, %0, c7, c10, 4" + : + : "r" (0) + : "cc"); + } +} + +void flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr, unsigned long pfn) +{ + if (cache_is_vivt()) { + if (cpu_isset(smp_processor_id(), vma->vm_mm->cpu_vm_mask)) { + unsigned long addr = user_addr & PAGE_MASK; + __cpuc_flush_user_range(addr, addr + PAGE_SIZE, vma->vm_flags); + } + return; + } + + if (cache_is_vipt_aliasing()) + flush_pfn_alias(pfn, user_addr); +} + #define ALIAS_FLUSH_START 0xffff4000 #define TOP_PTE(x) pte_offset_kernel(top_pmd, x) diff --git a/include/asm-arm/cacheflush.h b/include/asm-arm/cacheflush.h index 035cdcf..e81baff 100644 --- a/include/asm-arm/cacheflush.h +++ b/include/asm-arm/cacheflush.h @@ -256,7 +256,7 @@ extern void dmac_flush_range(unsigned long, unsigned long); * Convert calls to our calling convention. */ #define flush_cache_all() __cpuc_flush_kern_all() - +#ifndef CONFIG_CPU_CACHE_VIPT static inline void flush_cache_mm(struct mm_struct *mm) { if (cpu_isset(smp_processor_id(), mm->cpu_vm_mask)) @@ -279,6 +279,11 @@ flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr, unsigned l __cpuc_flush_user_range(addr, addr + PAGE_SIZE, vma->vm_flags); } } +#else +extern void flush_cache_mm(struct mm_struct *mm); +extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end); +extern void flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr, unsigned long pfn); +#endif /* * flush_cache_user_range is used when we want to ensure that the -- cgit v0.10.2 From 5aa3b610a7330c3cd6f0cb264d2189a3a1dcf534 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 8 Sep 2005 09:20:55 -0500 Subject: [PATCH] ppc32: Fix head_4xx.S compile error head_4xx.S wasn't compiling due to a missing #endif Signed-off-by: Kumar Gala Signed-off-by: Linus Torvalds diff --git a/arch/ppc/kernel/head_4xx.S b/arch/ppc/kernel/head_4xx.S index 0a5e723..ca9518b 100644 --- a/arch/ppc/kernel/head_4xx.S +++ b/arch/ppc/kernel/head_4xx.S @@ -453,6 +453,7 @@ label: #else CRITICAL_EXCEPTION(0x1020, WDTException, UnknownException) #endif +#endif /* 0x1100 - Data TLB Miss Exception * As the name implies, translation is not in the MMU, so search the -- cgit v0.10.2 From 6df29debb7fc04ac3f92038c57437f40bab4e72d Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 8 Sep 2005 16:04:41 +0100 Subject: [SERIAL] Use an enum for serial8250 platform device IDs Rather than hard-coding the platform device IDs, enumerate them. We don't particularly care about the actual ID we get, just as long as they're unique. Signed-off-by: Russell King diff --git a/arch/arm/mach-clps7500/core.c b/arch/arm/mach-clps7500/core.c index 112f1d68..e216ab8 100644 --- a/arch/arm/mach-clps7500/core.c +++ b/arch/arm/mach-clps7500/core.c @@ -354,7 +354,7 @@ static struct plat_serial8250_port serial_platform_data[] = { static struct platform_device serial_device = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = serial_platform_data, }, diff --git a/arch/arm/mach-ebsa110/core.c b/arch/arm/mach-ebsa110/core.c index 23c4da1..5aeadfd 100644 --- a/arch/arm/mach-ebsa110/core.c +++ b/arch/arm/mach-ebsa110/core.c @@ -219,7 +219,7 @@ static struct plat_serial8250_port serial_platform_data[] = { static struct platform_device serial_device = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = serial_platform_data, }, diff --git a/arch/arm/mach-epxa10db/arch.c b/arch/arm/mach-epxa10db/arch.c index 7daa021..44c5657 100644 --- a/arch/arm/mach-epxa10db/arch.c +++ b/arch/arm/mach-epxa10db/arch.c @@ -52,7 +52,7 @@ static struct plat_serial8250_port serial_platform_data[] = { static struct platform_device serial_device = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = serial_platform_data, }, diff --git a/arch/arm/mach-footbridge/isa.c b/arch/arm/mach-footbridge/isa.c index aa3a1fe..28846c7 100644 --- a/arch/arm/mach-footbridge/isa.c +++ b/arch/arm/mach-footbridge/isa.c @@ -34,7 +34,7 @@ static struct plat_serial8250_port serial_platform_data[] = { static struct platform_device serial_device = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = serial_platform_data, }, diff --git a/arch/arm/mach-h720x/cpu-h7202.c b/arch/arm/mach-h720x/cpu-h7202.c index 4b31993..a4a7c01 100644 --- a/arch/arm/mach-h720x/cpu-h7202.c +++ b/arch/arm/mach-h720x/cpu-h7202.c @@ -90,7 +90,7 @@ static struct plat_serial8250_port serial_platform_data[] = { static struct platform_device serial_device = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = serial_platform_data, }, diff --git a/arch/arm/mach-ixp2000/core.c b/arch/arm/mach-ixp2000/core.c index 098c817..74bd2fd 100644 --- a/arch/arm/mach-ixp2000/core.c +++ b/arch/arm/mach-ixp2000/core.c @@ -174,7 +174,7 @@ static struct resource ixp2000_uart_resource = { static struct platform_device ixp2000_serial_device = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = ixp2000_serial_port, }, diff --git a/arch/arm/mach-ixp4xx/coyote-setup.c b/arch/arm/mach-ixp4xx/coyote-setup.c index 8b2f253..050c927 100644 --- a/arch/arm/mach-ixp4xx/coyote-setup.c +++ b/arch/arm/mach-ixp4xx/coyote-setup.c @@ -66,7 +66,7 @@ static struct plat_serial8250_port coyote_uart_data[] = { static struct platform_device coyote_uart = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = coyote_uart_data, }, diff --git a/arch/arm/mach-ixp4xx/gtwx5715-setup.c b/arch/arm/mach-ixp4xx/gtwx5715-setup.c index 3fd92c5..29a6d02 100644 --- a/arch/arm/mach-ixp4xx/gtwx5715-setup.c +++ b/arch/arm/mach-ixp4xx/gtwx5715-setup.c @@ -93,7 +93,7 @@ static struct plat_serial8250_port gtwx5715_uart_platform_data[] = { static struct platform_device gtwx5715_uart_device = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = gtwx5715_uart_platform_data, }, diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c index 6c14ff3..ae1fa09 100644 --- a/arch/arm/mach-ixp4xx/ixdp425-setup.c +++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c @@ -96,7 +96,7 @@ static struct plat_serial8250_port ixdp425_uart_data[] = { static struct platform_device ixdp425_uart = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev.platform_data = ixdp425_uart_data, .num_resources = 2, .resource = ixdp425_uart_resources diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c index e4228198..76176dd 100644 --- a/arch/arm/mach-omap1/board-voiceblue.c +++ b/arch/arm/mach-omap1/board-voiceblue.c @@ -74,7 +74,7 @@ static struct plat_serial8250_port voiceblue_ports[] = { static struct platform_device serial_device = { .name = "serial8250", - .id = 1, + .id = PLAT8250_DEV_PLATFORM1, .dev = { .platform_data = voiceblue_ports, }, diff --git a/arch/arm/mach-omap1/serial.c b/arch/arm/mach-omap1/serial.c index 214e5d1..1446bf3 100644 --- a/arch/arm/mach-omap1/serial.c +++ b/arch/arm/mach-omap1/serial.c @@ -94,7 +94,7 @@ static struct plat_serial8250_port serial_platform_data[] = { static struct platform_device serial_device = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = serial_platform_data, }, diff --git a/arch/arm/mach-rpc/riscpc.c b/arch/arm/mach-rpc/riscpc.c index a102686..e3587ef 100644 --- a/arch/arm/mach-rpc/riscpc.c +++ b/arch/arm/mach-rpc/riscpc.c @@ -140,7 +140,7 @@ static struct plat_serial8250_port serial_platform_data[] = { static struct platform_device serial_device = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = serial_platform_data, }, diff --git a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c2410/mach-bast.c index e918224..1a3367d 100644 --- a/arch/arm/mach-s3c2410/mach-bast.c +++ b/arch/arm/mach-s3c2410/mach-bast.c @@ -381,7 +381,7 @@ static struct plat_serial8250_port bast_sio_data[] = { static struct platform_device bast_sio = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = &bast_sio_data, }, diff --git a/arch/arm/mach-s3c2410/mach-vr1000.c b/arch/arm/mach-s3c2410/mach-vr1000.c index 924e846..8f9ab28 100644 --- a/arch/arm/mach-s3c2410/mach-vr1000.c +++ b/arch/arm/mach-s3c2410/mach-vr1000.c @@ -221,7 +221,7 @@ static struct plat_serial8250_port serial_platform_data[] = { static struct platform_device serial_device = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = serial_platform_data, }, diff --git a/arch/arm/mach-shark/core.c b/arch/arm/mach-shark/core.c index e737eae..946c0d1 100644 --- a/arch/arm/mach-shark/core.c +++ b/arch/arm/mach-shark/core.c @@ -41,7 +41,7 @@ static struct plat_serial8250_port serial_platform_data[] = { static struct platform_device serial_device = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = serial_platform_data, }, diff --git a/arch/ppc/syslib/mpc10x_common.c b/arch/ppc/syslib/mpc10x_common.c index 87065e2..3e03970 100644 --- a/arch/ppc/syslib/mpc10x_common.c +++ b/arch/ppc/syslib/mpc10x_common.c @@ -140,12 +140,12 @@ struct platform_device ppc_sys_platform_devices[] = { }, [MPC10X_UART0] = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev.platform_data = serial_plat_uart0, }, [MPC10X_UART1] = { .name = "serial8250", - .id = 1, + .id = PLAT8250_DEV_PLATFORM1, .dev.platform_data = serial_plat_uart1, }, diff --git a/arch/ppc/syslib/mpc83xx_devices.c b/arch/ppc/syslib/mpc83xx_devices.c index 5aaf0e5..95b3b8a 100644 --- a/arch/ppc/syslib/mpc83xx_devices.c +++ b/arch/ppc/syslib/mpc83xx_devices.c @@ -165,7 +165,7 @@ struct platform_device ppc_sys_platform_devices[] = { }, [MPC83xx_DUART] = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev.platform_data = serial_platform_data, }, [MPC83xx_SEC2] = { diff --git a/arch/ppc/syslib/mpc85xx_devices.c b/arch/ppc/syslib/mpc85xx_devices.c index 8af322d..bbc5ac0 100644 --- a/arch/ppc/syslib/mpc85xx_devices.c +++ b/arch/ppc/syslib/mpc85xx_devices.c @@ -282,7 +282,7 @@ struct platform_device ppc_sys_platform_devices[] = { }, [MPC85xx_DUART] = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev.platform_data = serial_platform_data, }, [MPC85xx_PERFMON] = { diff --git a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c index d0bb68a..bfa8791c 100644 --- a/arch/ppc64/kernel/setup.c +++ b/arch/ppc64/kernel/setup.c @@ -1283,7 +1283,7 @@ void __init generic_find_legacy_serial_ports(u64 *physport, static struct platform_device serial_device = { .name = "serial8250", - .id = 0, + .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = serial_ports, }, diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 30a0a3d..5b65e20 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -2536,7 +2536,7 @@ static int __init serial8250_init(void) goto out; serial8250_isa_devs = platform_device_register_simple("serial8250", - -1, NULL, 0); + PLAT8250_DEV_LEGACY, NULL, 0); if (IS_ERR(serial8250_isa_devs)) { ret = PTR_ERR(serial8250_isa_devs); goto unreg; diff --git a/drivers/serial/8250_accent.c b/drivers/serial/8250_accent.c index 1f2c276..9c10262 100644 --- a/drivers/serial/8250_accent.c +++ b/drivers/serial/8250_accent.c @@ -29,7 +29,7 @@ static struct plat_serial8250_port accent_data[] = { static struct platform_device accent_device = { .name = "serial8250", - .id = 2, + .id = PLAT8250_DEV_ACCENT, .dev = { .platform_data = accent_data, }, diff --git a/drivers/serial/8250_boca.c b/drivers/serial/8250_boca.c index 465c9ea..3bfe0f7 100644 --- a/drivers/serial/8250_boca.c +++ b/drivers/serial/8250_boca.c @@ -43,7 +43,7 @@ static struct plat_serial8250_port boca_data[] = { static struct platform_device boca_device = { .name = "serial8250", - .id = 3, + .id = PLAT8250_DEV_BOCA, .dev = { .platform_data = boca_data, }, diff --git a/drivers/serial/8250_fourport.c b/drivers/serial/8250_fourport.c index e9b4d90..6375d68 100644 --- a/drivers/serial/8250_fourport.c +++ b/drivers/serial/8250_fourport.c @@ -35,7 +35,7 @@ static struct plat_serial8250_port fourport_data[] = { static struct platform_device fourport_device = { .name = "serial8250", - .id = 1, + .id = PLAT8250_DEV_FOURPORT, .dev = { .platform_data = fourport_data, }, diff --git a/drivers/serial/8250_hub6.c b/drivers/serial/8250_hub6.c index 77f396f..daf569c 100644 --- a/drivers/serial/8250_hub6.c +++ b/drivers/serial/8250_hub6.c @@ -40,7 +40,7 @@ static struct plat_serial8250_port hub6_data[] = { static struct platform_device hub6_device = { .name = "serial8250", - .id = 4, + .id = PLAT8250_DEV_HUB6, .dev = { .platform_data = hub6_data, }, diff --git a/drivers/serial/8250_mca.c b/drivers/serial/8250_mca.c index f0c40d6..ac20525 100644 --- a/drivers/serial/8250_mca.c +++ b/drivers/serial/8250_mca.c @@ -44,7 +44,7 @@ static struct plat_serial8250_port mca_data[] = { static struct platform_device mca_device = { .name = "serial8250", - .id = 5, + .id = PLAT8250_DEV_MCA, .dev = { .platform_data = mca_data, }, diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index d8a023d..317a979 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -30,6 +30,21 @@ struct plat_serial8250_port { }; /* + * Allocate 8250 platform device IDs. Nothing is implied by + * the numbering here, except for the legacy entry being -1. + */ +enum { + PLAT8250_DEV_LEGACY = -1, + PLAT8250_DEV_PLATFORM, + PLAT8250_DEV_PLATFORM1, + PLAT8250_DEV_FOURPORT, + PLAT8250_DEV_ACCENT, + PLAT8250_DEV_BOCA, + PLAT8250_DEV_HUB6, + PLAT8250_DEV_MCA, +}; + +/* * This should be used by drivers which want to register * their own 8250 ports without registering their own * platform device. Using these will make your driver -- cgit v0.10.2 From e7a1033b946f4f2622f2b338ab107f559aad542c Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 16:12:28 +0100 Subject: NTFS: Support more clean journal ($LogFile) states. - Support journals ($LogFile) which have been modified by chkdsk. This means users can boot into Windows after we marked the volume dirty. The Windows boot will run chkdsk and then reboot. The user can then immediately boot into Linux rather than having to do a full Windows boot first before rebooting into Linux and we will recognize such a journal and empty it as it is clean by definition. - Support journals ($LogFile) with only one restart page as well as journals with two different restart pages. We sanity check both and either use the only sane one or the more recent one of the two in the case that both are valid. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 9eecc99..cceec3e 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -22,6 +22,19 @@ ToDo/Notes: - Enable the code for setting the NT4 compatibility flag when we start making NTFS 1.2 specific modifications. +2.1.24-WIP + + - Support journals ($LogFile) which have been modified by chkdsk. This + means users can boot into Windows after we marked the volume dirty. + The Windows boot will run chkdsk and then reboot. The user can then + immediately boot into Linux rather than having to do a full Windows + boot first before rebooting into Linux and we will recognize such a + journal and empty it as it is clean by definition. + - Support journals ($LogFile) with only one restart page as well as + journals with two different restart pages. We sanity check both and + either use the only sane one or the more recent one of the two in the + case that both are valid. + 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/Makefile b/fs/ntfs/Makefile index f083f27..ce970da 100644 --- a/fs/ntfs/Makefile +++ b/fs/ntfs/Makefile @@ -6,7 +6,7 @@ ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \ index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \ unistr.o upcase.o -EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.23\" +EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.24-WIP\" ifeq ($(CONFIG_NTFS_DEBUG),y) EXTRA_CFLAGS += -DDEBUG diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c index 8edb8e2..0173e95 100644 --- a/fs/ntfs/logfile.c +++ b/fs/ntfs/logfile.c @@ -121,7 +121,7 @@ static BOOL ntfs_check_restart_page_header(struct inode *vi, */ if (!ntfs_is_chkd_record(rp->magic) && sle64_to_cpu(rp->chkdsk_lsn)) { ntfs_error(vi->i_sb, "$LogFile restart page is not modified " - "chkdsk but a chkdsk LSN is specified."); + "by chkdsk but a chkdsk LSN is specified."); return FALSE; } ntfs_debug("Done."); @@ -312,10 +312,12 @@ err_out: * @vi: $LogFile inode to which the restart page belongs * @rp: restart page to check * @pos: position in @vi at which the restart page resides - * @wrp: copy of the multi sector transfer deprotected restart page + * @wrp: [OUT] copy of the multi sector transfer deprotected restart page + * @lsn: [OUT] set to the current logfile lsn on success * - * Check the restart page @rp for consistency and return TRUE if it is - * consistent and FALSE otherwise. + * Check the restart page @rp for consistency and return 0 if it is consistent + * and -errno otherwise. The restart page may have been modified by chkdsk in + * which case its magic is CHKD instead of RSTR. * * This function only needs NTFS_BLOCK_SIZE bytes in @rp, i.e. it does not * require the full restart page. @@ -323,25 +325,33 @@ err_out: * If @wrp is not NULL, on success, *@wrp will point to a buffer containing a * copy of the complete multi sector transfer deprotected page. On failure, * *@wrp is undefined. + * + * Simillarly, if @lsn is not NULL, on succes *@lsn will be set to the current + * logfile lsn according to this restart page. On failure, *@lsn is undefined. + * + * The following error codes are defined: + * -EINVAL - The restart page is inconsistent. + * -ENOMEM - Not enough memory to load the restart page. + * -EIO - Failed to reading from $LogFile. */ -static BOOL ntfs_check_and_load_restart_page(struct inode *vi, - RESTART_PAGE_HEADER *rp, s64 pos, RESTART_PAGE_HEADER **wrp) +static int ntfs_check_and_load_restart_page(struct inode *vi, + RESTART_PAGE_HEADER *rp, s64 pos, RESTART_PAGE_HEADER **wrp, + LSN *lsn) { RESTART_AREA *ra; RESTART_PAGE_HEADER *trp; - int size; - BOOL ret; + int size, err; ntfs_debug("Entering."); /* Check the restart page header for consistency. */ if (!ntfs_check_restart_page_header(vi, rp, pos)) { /* Error output already done inside the function. */ - return FALSE; + return -EINVAL; } /* Check the restart area for consistency. */ if (!ntfs_check_restart_area(vi, rp)) { /* Error output already done inside the function. */ - return FALSE; + return -EINVAL; } ra = (RESTART_AREA*)((u8*)rp + le16_to_cpu(rp->restart_area_offset)); /* @@ -352,7 +362,7 @@ static BOOL ntfs_check_and_load_restart_page(struct inode *vi, if (!trp) { ntfs_error(vi->i_sb, "Failed to allocate memory for $LogFile " "restart page buffer."); - return FALSE; + return -ENOMEM; } /* * Read the whole of the restart page into the buffer. If it fits @@ -379,6 +389,9 @@ static BOOL ntfs_check_and_load_restart_page(struct inode *vi, if (IS_ERR(page)) { ntfs_error(vi->i_sb, "Error mapping $LogFile " "page (index %lu).", idx); + err = PTR_ERR(page); + if (err != -EIO && err != -ENOMEM) + err = -EIO; goto err_out; } size = min_t(int, to_read, PAGE_CACHE_SIZE); @@ -392,29 +405,57 @@ static BOOL ntfs_check_and_load_restart_page(struct inode *vi, /* Perform the multi sector transfer deprotection on the buffer. */ if (post_read_mst_fixup((NTFS_RECORD*)trp, le32_to_cpu(rp->system_page_size))) { - ntfs_error(vi->i_sb, "Multi sector transfer error detected in " - "$LogFile restart page."); - goto err_out; + /* + * A multi sector tranfer error was detected. We only need to + * abort if the restart page contents exceed the multi sector + * transfer fixup of the first sector. + */ + if (le16_to_cpu(rp->restart_area_offset) + + le16_to_cpu(ra->restart_area_length) > + NTFS_BLOCK_SIZE - sizeof(u16)) { + ntfs_error(vi->i_sb, "Multi sector transfer error " + "detected in $LogFile restart page."); + err = -EINVAL; + goto err_out; + } + } + /* + * If the restart page is modified by chkdsk or there are no active + * logfile clients, the logfile is consistent. Otherwise, need to + * check the log client records for consistency, too. + */ + err = 0; + if (ntfs_is_rstr_record(rp->magic) && + ra->client_in_use_list != LOGFILE_NO_CLIENT) { + if (!ntfs_check_log_client_array(vi, trp)) { + err = -EINVAL; + goto err_out; + } + } + if (lsn) { + if (ntfs_is_rstr_record(rp->magic)) + *lsn = sle64_to_cpu(ra->current_lsn); + else /* if (ntfs_is_chkd_record(rp->magic)) */ + *lsn = sle64_to_cpu(rp->chkdsk_lsn); } - /* Check the log client records for consistency. */ - ret = ntfs_check_log_client_array(vi, trp); - if (ret && wrp) - *wrp = trp; - else - ntfs_free(trp); ntfs_debug("Done."); - return ret; + if (wrp) + *wrp = trp; + else { err_out: - ntfs_free(trp); - return FALSE; + ntfs_free(trp); + } + return err; } /** * ntfs_check_logfile - check the journal for consistency * @log_vi: struct inode of loaded journal $LogFile to check + * @rp: [OUT] on success this is a copy of the current restart page * * Check the $LogFile journal for consistency and return TRUE if it is - * consistent and FALSE if not. + * consistent and FALSE if not. On success, the current restart page is + * returned in *@rp. Caller must call ntfs_free(*@rp) when finished with it. * * At present we only check the two restart pages and ignore the log record * pages. @@ -424,19 +465,18 @@ err_out: * if the $LogFile was created on a system with a different page size to ours * yet and mst deprotection would fail if our page size is smaller. */ -BOOL ntfs_check_logfile(struct inode *log_vi) +BOOL ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp) { - s64 size, pos, rstr1_pos, rstr2_pos; + s64 size, pos; + LSN rstr1_lsn, rstr2_lsn; ntfs_volume *vol = NTFS_SB(log_vi->i_sb); struct address_space *mapping = log_vi->i_mapping; struct page *page = NULL; u8 *kaddr = NULL; RESTART_PAGE_HEADER *rstr1_ph = NULL; RESTART_PAGE_HEADER *rstr2_ph = NULL; - int log_page_size, log_page_mask, ofs; + int log_page_size, log_page_mask, err; BOOL logfile_is_empty = TRUE; - BOOL rstr1_found = FALSE; - BOOL rstr2_found = FALSE; u8 log_page_bits; ntfs_debug("Entering."); @@ -491,7 +531,7 @@ BOOL ntfs_check_logfile(struct inode *log_vi) if (IS_ERR(page)) { ntfs_error(vol->sb, "Error mapping $LogFile " "page (index %lu).", idx); - return FALSE; + goto err_out; } } kaddr = (u8*)page_address(page) + (pos & ~PAGE_CACHE_MASK); @@ -510,99 +550,95 @@ BOOL ntfs_check_logfile(struct inode *log_vi) */ if (ntfs_is_rcrd_recordp((le32*)kaddr)) break; - /* - * A modified by chkdsk restart page means we cannot handle - * this log file. - */ - if (ntfs_is_chkd_recordp((le32*)kaddr)) { - ntfs_error(vol->sb, "$LogFile has been modified by " - "chkdsk. Mount this volume in " - "Windows."); - goto err_out; - } - /* If not a restart page, continue. */ - if (!ntfs_is_rstr_recordp((le32*)kaddr)) { - /* Skip to the minimum page size for the next one. */ + /* If not a (modified by chkdsk) restart page, continue. */ + if (!ntfs_is_rstr_recordp((le32*)kaddr) && + !ntfs_is_chkd_recordp((le32*)kaddr)) { if (!pos) pos = NTFS_BLOCK_SIZE >> 1; continue; } - /* We now know we have a restart page. */ - if (!pos) { - rstr1_found = TRUE; - rstr1_pos = pos; - } else { - if (rstr2_found) { - ntfs_error(vol->sb, "Found more than two " - "restart pages in $LogFile."); - goto err_out; - } - rstr2_found = TRUE; - rstr2_pos = pos; - } /* - * Check the restart page for consistency and get a copy of the - * complete multi sector transfer deprotected restart page. + * Check the (modified by chkdsk) restart page for consistency + * and get a copy of the complete multi sector transfer + * deprotected restart page. */ - if (!ntfs_check_and_load_restart_page(log_vi, + err = ntfs_check_and_load_restart_page(log_vi, (RESTART_PAGE_HEADER*)kaddr, pos, - !pos ? &rstr1_ph : &rstr2_ph)) { - /* Error output already done inside the function. */ - goto err_out; + !rstr1_ph ? &rstr1_ph : &rstr2_ph, + !rstr1_ph ? &rstr1_lsn : &rstr2_lsn); + if (!err) { + /* + * If we have now found the first (modified by chkdsk) + * restart page, continue looking for the second one. + */ + if (!pos) { + pos = NTFS_BLOCK_SIZE >> 1; + continue; + } + /* + * We have now found the second (modified by chkdsk) + * restart page, so we can stop looking. + */ + break; } /* - * We have a valid restart page. The next one must be after - * a whole system page size as specified by the valid restart - * page. + * Error output already done inside the function. Note, we do + * not abort if the restart page was invalid as we might still + * find a valid one further in the file. */ + if (err != -EINVAL) { + ntfs_unmap_page(page); + goto err_out; + } + /* Continue looking. */ if (!pos) - pos = le32_to_cpu(rstr1_ph->system_page_size) >> 1; + pos = NTFS_BLOCK_SIZE >> 1; } - if (page) { + if (page) ntfs_unmap_page(page); - page = NULL; - } if (logfile_is_empty) { NVolSetLogFileEmpty(vol); is_empty: ntfs_debug("Done. ($LogFile is empty.)"); return TRUE; } - if (!rstr1_found || !rstr2_found) { - ntfs_error(vol->sb, "Did not find two restart pages in " - "$LogFile."); - goto err_out; + if (!rstr1_ph) { + BUG_ON(rstr2_ph); + ntfs_error(vol->sb, "Did not find any restart pages in " + "$LogFile and it was not empty."); + return FALSE; + } + /* If both restart pages were found, use the more recent one. */ + if (rstr2_ph) { + /* + * If the second restart area is more recent, switch to it. + * Otherwise just throw it away. + */ + if (rstr2_lsn > rstr1_lsn) { + ntfs_free(rstr1_ph); + rstr1_ph = rstr2_ph; + /* rstr1_lsn = rstr2_lsn; */ + } else + ntfs_free(rstr2_ph); + rstr2_ph = NULL; } - /* - * The two restart areas must be identical except for the update - * sequence number. - */ - ofs = le16_to_cpu(rstr1_ph->usa_ofs); - if (memcmp(rstr1_ph, rstr2_ph, ofs) || (ofs += sizeof(u16), - memcmp((u8*)rstr1_ph + ofs, (u8*)rstr2_ph + ofs, - le32_to_cpu(rstr1_ph->system_page_size) - ofs))) { - ntfs_error(vol->sb, "The two restart pages in $LogFile do not " - "match."); - goto err_out; - } - ntfs_free(rstr1_ph); - ntfs_free(rstr2_ph); /* All consistency checks passed. */ + if (rp) + *rp = rstr1_ph; + else + ntfs_free(rstr1_ph); ntfs_debug("Done."); return TRUE; err_out: - if (page) - ntfs_unmap_page(page); if (rstr1_ph) ntfs_free(rstr1_ph); - if (rstr2_ph) - ntfs_free(rstr2_ph); return FALSE; } /** * ntfs_is_logfile_clean - check in the journal if the volume is clean * @log_vi: struct inode of loaded journal $LogFile to check + * @rp: copy of the current restart page * * Analyze the $LogFile journal and return TRUE if it indicates the volume was * shutdown cleanly and FALSE if not. @@ -619,11 +655,9 @@ err_out: * is empty this function requires that NVolLogFileEmpty() is true otherwise an * empty volume will be reported as dirty. */ -BOOL ntfs_is_logfile_clean(struct inode *log_vi) +BOOL ntfs_is_logfile_clean(struct inode *log_vi, const RESTART_PAGE_HEADER *rp) { ntfs_volume *vol = NTFS_SB(log_vi->i_sb); - struct page *page; - RESTART_PAGE_HEADER *rp; RESTART_AREA *ra; ntfs_debug("Entering."); @@ -632,24 +666,15 @@ BOOL ntfs_is_logfile_clean(struct inode *log_vi) ntfs_debug("Done. ($LogFile is empty.)"); return TRUE; } - /* - * Read the first restart page. It will be possibly incomplete and - * will not be multi sector transfer deprotected but we only need the - * first NTFS_BLOCK_SIZE bytes so it does not matter. - */ - page = ntfs_map_page(log_vi->i_mapping, 0); - if (IS_ERR(page)) { - ntfs_error(vol->sb, "Error mapping $LogFile page (index 0)."); + BUG_ON(!rp); + if (!ntfs_is_rstr_record(rp->magic) && + !ntfs_is_chkd_record(rp->magic)) { + ntfs_error(vol->sb, "Restart page buffer is invalid. This is " + "probably a bug in that the $LogFile should " + "have been consistency checked before calling " + "this function."); return FALSE; } - rp = (RESTART_PAGE_HEADER*)page_address(page); - if (!ntfs_is_rstr_record(rp->magic)) { - ntfs_error(vol->sb, "No restart page found at offset zero in " - "$LogFile. This is probably a bug in that " - "the $LogFile should have been consistency " - "checked before calling this function."); - goto err_out; - } ra = (RESTART_AREA*)((u8*)rp + le16_to_cpu(rp->restart_area_offset)); /* * If the $LogFile has active clients, i.e. it is open, and we do not @@ -659,15 +684,11 @@ BOOL ntfs_is_logfile_clean(struct inode *log_vi) if (ra->client_in_use_list != LOGFILE_NO_CLIENT && !(ra->flags & RESTART_VOLUME_IS_CLEAN)) { ntfs_debug("Done. $LogFile indicates a dirty shutdown."); - goto err_out; + return FALSE; } - ntfs_unmap_page(page); /* $LogFile indicates a clean shutdown. */ ntfs_debug("Done. $LogFile indicates a clean shutdown."); return TRUE; -err_out: - ntfs_unmap_page(page); - return FALSE; } /** diff --git a/fs/ntfs/logfile.h b/fs/ntfs/logfile.h index 4ee4378..42388f9 100644 --- a/fs/ntfs/logfile.h +++ b/fs/ntfs/logfile.h @@ -2,7 +2,7 @@ * logfile.h - Defines for NTFS kernel journal ($LogFile) handling. Part of * the Linux-NTFS project. * - * Copyright (c) 2000-2004 Anton Altaparmakov + * Copyright (c) 2000-2005 Anton Altaparmakov * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -296,9 +296,11 @@ typedef struct { /* sizeof() = 160 (0xa0) bytes */ } __attribute__ ((__packed__)) LOG_CLIENT_RECORD; -extern BOOL ntfs_check_logfile(struct inode *log_vi); +extern BOOL ntfs_check_logfile(struct inode *log_vi, + RESTART_PAGE_HEADER **rp); -extern BOOL ntfs_is_logfile_clean(struct inode *log_vi); +extern BOOL ntfs_is_logfile_clean(struct inode *log_vi, + const RESTART_PAGE_HEADER *rp); extern BOOL ntfs_empty_logfile(struct inode *log_vi); diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 41aa8eb..bf8569d 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c @@ -1133,7 +1133,8 @@ mft_unmap_out: * * Return TRUE on success or FALSE on error. */ -static BOOL load_and_check_logfile(ntfs_volume *vol) +static BOOL load_and_check_logfile(ntfs_volume *vol, + RESTART_PAGE_HEADER **rp) { struct inode *tmp_ino; @@ -1145,7 +1146,7 @@ static BOOL load_and_check_logfile(ntfs_volume *vol) /* Caller will display error message. */ return FALSE; } - if (!ntfs_check_logfile(tmp_ino)) { + if (!ntfs_check_logfile(tmp_ino, rp)) { iput(tmp_ino); /* ntfs_check_logfile() will have displayed error output. */ return FALSE; @@ -1687,6 +1688,7 @@ static BOOL load_system_files(ntfs_volume *vol) struct super_block *sb = vol->sb; MFT_RECORD *m; VOLUME_INFORMATION *vi; + RESTART_PAGE_HEADER *rp; ntfs_attr_search_ctx *ctx; #ifdef NTFS_RW int err; @@ -1841,8 +1843,9 @@ get_ctx_vol_failed: * Get the inode for the logfile, check it and determine if the volume * was shutdown cleanly. */ - if (!load_and_check_logfile(vol) || - !ntfs_is_logfile_clean(vol->logfile_ino)) { + rp = NULL; + if (!load_and_check_logfile(vol, &rp) || + !ntfs_is_logfile_clean(vol->logfile_ino, rp)) { static const char *es1a = "Failed to load $LogFile"; static const char *es1b = "$LogFile is not clean"; static const char *es2 = ". Mount in Windows."; @@ -1857,6 +1860,10 @@ get_ctx_vol_failed: "continue nor on_errors=" "remount-ro was specified%s", es1, es2); + if (vol->logfile_ino) { + BUG_ON(!rp); + ntfs_free(rp); + } goto iput_logfile_err_out; } sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; @@ -1867,6 +1874,7 @@ get_ctx_vol_failed: /* This will prevent a read-write remount. */ NVolSetErrors(vol); } + ntfs_free(rp); #endif /* NTFS_RW */ /* Get the root directory inode so we can do path lookups. */ vol->root_ino = ntfs_iget(sb, FILE_root); -- cgit v0.10.2 From 8920e8f94c44e31a73bdf923b04721e26e88cadd Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 7 Sep 2005 18:28:51 -0700 Subject: [PATCH] Fix 32bit sendmsg() flaw When we copy 32bit ->msg_control contents to kernel, we walk the same userland data twice without sanity checks on the second pass. Second version of this patch: the original broke with 64-bit arches running 32-bit-compat-mode executables doing sendmsg() syscalls with unaligned CMSG data areas Another thing is that we use kmalloc() to allocate and sock_kfree_s() to free afterwards; less serious, but also needs fixing. Signed-off-by: Al Viro Signed-off-by: David Woodhouse Signed-off-by: Chris Wright Signed-off-by: Linus Torvalds diff --git a/include/net/compat.h b/include/net/compat.h index 9983fd8..482eb82 100644 --- a/include/net/compat.h +++ b/include/net/compat.h @@ -33,7 +33,7 @@ extern asmlinkage long compat_sys_sendmsg(int,struct compat_msghdr __user *,unsi extern asmlinkage long compat_sys_recvmsg(int,struct compat_msghdr __user *,unsigned); extern asmlinkage long compat_sys_getsockopt(int, int, int, char __user *, int __user *); extern int put_cmsg_compat(struct msghdr*, int, int, int, void *); -extern int cmsghdr_from_user_compat_to_kern(struct msghdr *, unsigned char *, +extern int cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *, unsigned char *, int); #endif /* NET_COMPAT_H */ diff --git a/net/compat.c b/net/compat.c index d99ab96..e593dac 100644 --- a/net/compat.c +++ b/net/compat.c @@ -135,13 +135,14 @@ static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *ms * thus placement) of cmsg headers and length are different for * 32-bit apps. -DaveM */ -int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, +int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk, unsigned char *stackbuf, int stackbuf_size) { struct compat_cmsghdr __user *ucmsg; struct cmsghdr *kcmsg, *kcmsg_base; compat_size_t ucmlen; __kernel_size_t kcmlen, tmp; + int err = -EFAULT; kcmlen = 0; kcmsg_base = kcmsg = (struct cmsghdr *)stackbuf; @@ -156,6 +157,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, tmp = ((ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))) + CMSG_ALIGN(sizeof(struct cmsghdr))); + tmp = CMSG_ALIGN(tmp); kcmlen += tmp; ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen); } @@ -167,30 +169,34 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, * until we have successfully copied over all of the data * from the user. */ - if(kcmlen > stackbuf_size) - kcmsg_base = kcmsg = kmalloc(kcmlen, GFP_KERNEL); - if(kcmsg == NULL) + if (kcmlen > stackbuf_size) + kcmsg_base = kcmsg = sock_kmalloc(sk, kcmlen, GFP_KERNEL); + if (kcmsg == NULL) return -ENOBUFS; /* Now copy them over neatly. */ memset(kcmsg, 0, kcmlen); ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg); while(ucmsg != NULL) { - __get_user(ucmlen, &ucmsg->cmsg_len); + if (__get_user(ucmlen, &ucmsg->cmsg_len)) + goto Efault; + if (!CMSG_COMPAT_OK(ucmlen, ucmsg, kmsg)) + goto Einval; tmp = ((ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))) + CMSG_ALIGN(sizeof(struct cmsghdr))); + if ((char *)kcmsg_base + kcmlen - (char *)kcmsg < CMSG_ALIGN(tmp)) + goto Einval; kcmsg->cmsg_len = tmp; - __get_user(kcmsg->cmsg_level, &ucmsg->cmsg_level); - __get_user(kcmsg->cmsg_type, &ucmsg->cmsg_type); - - /* Copy over the data. */ - if(copy_from_user(CMSG_DATA(kcmsg), - CMSG_COMPAT_DATA(ucmsg), - (ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))))) - goto out_free_efault; + tmp = CMSG_ALIGN(tmp); + if (__get_user(kcmsg->cmsg_level, &ucmsg->cmsg_level) || + __get_user(kcmsg->cmsg_type, &ucmsg->cmsg_type) || + copy_from_user(CMSG_DATA(kcmsg), + CMSG_COMPAT_DATA(ucmsg), + (ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))))) + goto Efault; /* Advance. */ - kcmsg = (struct cmsghdr *)((char *)kcmsg + CMSG_ALIGN(tmp)); + kcmsg = (struct cmsghdr *)((char *)kcmsg + tmp); ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen); } @@ -199,10 +205,12 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, kmsg->msg_controllen = kcmlen; return 0; -out_free_efault: - if(kcmsg_base != (struct cmsghdr *)stackbuf) - kfree(kcmsg_base); - return -EFAULT; +Einval: + err = -EINVAL; +Efault: + if (kcmsg_base != (struct cmsghdr *)stackbuf) + sock_kfree_s(sk, kcmsg_base, kcmlen); + return err; } int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data) diff --git a/net/socket.c b/net/socket.c index e1bd5d84..c699e93 100644 --- a/net/socket.c +++ b/net/socket.c @@ -1745,10 +1745,11 @@ asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags) goto out_freeiov; ctl_len = msg_sys.msg_controllen; if ((MSG_CMSG_COMPAT & flags) && ctl_len) { - err = cmsghdr_from_user_compat_to_kern(&msg_sys, ctl, sizeof(ctl)); + err = cmsghdr_from_user_compat_to_kern(&msg_sys, sock->sk, ctl, sizeof(ctl)); if (err) goto out_freeiov; ctl_buf = msg_sys.msg_control; + ctl_len = msg_sys.msg_controllen; } else if (ctl_len) { if (ctl_len > sizeof(ctl)) { -- cgit v0.10.2 From 06d0e3cf3d527f927681773c6ffbe697ccc5db7f Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 16:28:25 +0100 Subject: NTFS: Allow highmem kmalloc() in ntfs_malloc_nofs() and add _nofail() version. - Modify fs/ntfs/malloc.h::ntfs_malloc_nofs() to do the kmalloc() based allocations with __GFP_HIGHMEM, analogous to how the vmalloc() based allocations are done. - Add fs/ntfs/malloc.h::ntfs_malloc_nofs_nofail() which is analogous to ntfs_malloc_nofs() but it performs allocations with __GFP_NOFAIL and hence cannot fail. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index cceec3e..c3bf17b 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -34,6 +34,12 @@ ToDo/Notes: journals with two different restart pages. We sanity check both and either use the only sane one or the more recent one of the two in the case that both are valid. + - Modify fs/ntfs/malloc.h::ntfs_malloc_nofs() to do the kmalloc() based + allocations with __GFP_HIGHMEM, analogous to how the vmalloc() based + allocations are done. + - Add fs/ntfs/malloc.h::ntfs_malloc_nofs_nofail() which is analogous to + ntfs_malloc_nofs() but it performs allocations with __GFP_NOFAIL and + hence cannot fail. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/malloc.h b/fs/ntfs/malloc.h index fac5944..9994e01 100644 --- a/fs/ntfs/malloc.h +++ b/fs/ntfs/malloc.h @@ -27,27 +27,63 @@ #include /** - * ntfs_malloc_nofs - allocate memory in multiples of pages - * @size number of bytes to allocate + * __ntfs_malloc - allocate memory in multiples of pages + * @size: number of bytes to allocate + * @gfp_mask: extra flags for the allocator + * + * Internal function. You probably want ntfs_malloc_nofs()... * * Allocates @size bytes of memory, rounded up to multiples of PAGE_SIZE and * returns a pointer to the allocated memory. * * If there was insufficient memory to complete the request, return NULL. + * Depending on @gfp_mask the allocation may be guaranteed to succeed. */ -static inline void *ntfs_malloc_nofs(unsigned long size) +static inline void *__ntfs_malloc(unsigned long size, + unsigned int __nocast gfp_mask) { if (likely(size <= PAGE_SIZE)) { BUG_ON(!size); /* kmalloc() has per-CPU caches so is faster for now. */ - return kmalloc(PAGE_SIZE, GFP_NOFS); - /* return (void *)__get_free_page(GFP_NOFS | __GFP_HIGHMEM); */ + return kmalloc(PAGE_SIZE, gfp_mask); + /* return (void *)__get_free_page(gfp_mask); */ } if (likely(size >> PAGE_SHIFT < num_physpages)) - return __vmalloc(size, GFP_NOFS | __GFP_HIGHMEM, PAGE_KERNEL); + return __vmalloc(size, gfp_mask, PAGE_KERNEL); return NULL; } +/** + * ntfs_malloc_nofs - allocate memory in multiples of pages + * @size: number of bytes to allocate + * + * Allocates @size bytes of memory, rounded up to multiples of PAGE_SIZE and + * returns a pointer to the allocated memory. + * + * If there was insufficient memory to complete the request, return NULL. + */ +static inline void *ntfs_malloc_nofs(unsigned long size) +{ + return __ntfs_malloc(size, GFP_NOFS | __GFP_HIGHMEM); +} + +/** + * ntfs_malloc_nofs_nofail - allocate memory in multiples of pages + * @size: number of bytes to allocate + * + * Allocates @size bytes of memory, rounded up to multiples of PAGE_SIZE and + * returns a pointer to the allocated memory. + * + * This function guarantees that the allocation will succeed. It will sleep + * for as long as it takes to complete the allocation. + * + * If there was insufficient memory to complete the request, return NULL. + */ +static inline void *ntfs_malloc_nofs_nofail(unsigned long size) +{ + return __ntfs_malloc(size, GFP_NOFS | __GFP_HIGHMEM | __GFP_NOFAIL); +} + static inline void ntfs_free(void *addr) { if (likely(((unsigned long)addr < VMALLOC_START) || -- cgit v0.10.2 From 9529d461d0992959026264b8fc002ac01d226708 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 16:33:12 +0100 Subject: NTFS: Use ntfs_malloc_nofs_nofail() in runlist.c::ntfs_runlists_merge() in the two critical regions. This means we no longer need to panic() when the allocation fails as it now cannot fail. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index c3bf17b..c5bbedf 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -40,6 +40,9 @@ ToDo/Notes: - Add fs/ntfs/malloc.h::ntfs_malloc_nofs_nofail() which is analogous to ntfs_malloc_nofs() but it performs allocations with __GFP_NOFAIL and hence cannot fail. + - Use ntfs_malloc_nofs_nofail() in the two critical regions in + fs/ntfs/runlist.c::ntfs_runlists_merge(). This means we no longer + need to panic() if the allocation fails as it now cannot fail. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c index 758855b..3bb4a57 100644 --- a/fs/ntfs/runlist.c +++ b/fs/ntfs/runlist.c @@ -35,7 +35,7 @@ static inline void ntfs_rl_mm(runlist_element *base, int dst, int src, int size) { if (likely((dst != src) && (size > 0))) - memmove(base + dst, base + src, size * sizeof (*base)); + memmove(base + dst, base + src, size * sizeof(*base)); } /** @@ -95,6 +95,51 @@ static inline runlist_element *ntfs_rl_realloc(runlist_element *rl, } /** + * ntfs_rl_realloc_nofail - Reallocate memory for runlists + * @rl: original runlist + * @old_size: number of runlist elements in the original runlist @rl + * @new_size: number of runlist elements we need space for + * + * As the runlists grow, more memory will be required. To prevent the + * kernel having to allocate and reallocate large numbers of small bits of + * memory, this function returns an entire page of memory. + * + * This function guarantees that the allocation will succeed. It will sleep + * for as long as it takes to complete the allocation. + * + * It is up to the caller to serialize access to the runlist @rl. + * + * N.B. If the new allocation doesn't require a different number of pages in + * memory, the function will return the original pointer. + * + * On success, return a pointer to the newly allocated, or recycled, memory. + * On error, return -errno. The following error codes are defined: + * -ENOMEM - Not enough memory to allocate runlist array. + * -EINVAL - Invalid parameters were passed in. + */ +static inline runlist_element *ntfs_rl_realloc_nofail(runlist_element *rl, + int old_size, int new_size) +{ + runlist_element *new_rl; + + old_size = PAGE_ALIGN(old_size * sizeof(*rl)); + new_size = PAGE_ALIGN(new_size * sizeof(*rl)); + if (old_size == new_size) + return rl; + + new_rl = ntfs_malloc_nofs_nofail(new_size); + BUG_ON(!new_rl); + + if (likely(rl != NULL)) { + if (unlikely(old_size > new_size)) + old_size = new_size; + memcpy(new_rl, rl, old_size); + ntfs_free(rl); + } + return new_rl; +} + +/** * ntfs_are_rl_mergeable - test if two runlists can be joined together * @dst: original runlist * @src: new runlist to test for mergeability with @dst @@ -621,11 +666,8 @@ runlist_element *ntfs_runlists_merge(runlist_element *drl, if (drl[ds].lcn != LCN_RL_NOT_MAPPED) { /* Add an unmapped runlist element. */ if (!slots) { - /* FIXME/TODO: We need to have the - * extra memory already! (AIA) */ - drl = ntfs_rl_realloc(drl, ds, ds + 2); - if (!drl) - goto critical_error; + drl = ntfs_rl_realloc_nofail(drl, ds, + ds + 2); slots = 2; } ds++; @@ -640,13 +682,8 @@ runlist_element *ntfs_runlists_merge(runlist_element *drl, drl[ds].length = marker_vcn - drl[ds].vcn; /* Finally add the ENOENT terminator. */ ds++; - if (!slots) { - /* FIXME/TODO: We need to have the extra - * memory already! (AIA) */ - drl = ntfs_rl_realloc(drl, ds, ds + 1); - if (!drl) - goto critical_error; - } + if (!slots) + drl = ntfs_rl_realloc_nofail(drl, ds, ds + 1); drl[ds].vcn = marker_vcn; drl[ds].lcn = LCN_ENOENT; drl[ds].length = (s64)0; @@ -659,11 +696,6 @@ finished: ntfs_debug("Merged runlist:"); ntfs_debug_dump_runlist(drl); return drl; - -critical_error: - /* Critical error! We cannot afford to fail here. */ - ntfs_error(NULL, "Critical error! Not enough memory."); - panic("NTFS: Cannot continue."); } /** -- cgit v0.10.2 From 84d6ebe63f50b6efd8be252b58a207132157c60f Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 16:46:55 +0100 Subject: NTFS: Fix two nasty runlist merging bugs that had gone unnoticed so far. Thanks to Stefano Picerno for the bug report. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index c5bbedf..4bc8f91 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -43,6 +43,8 @@ ToDo/Notes: - Use ntfs_malloc_nofs_nofail() in the two critical regions in fs/ntfs/runlist.c::ntfs_runlists_merge(). This means we no longer need to panic() if the allocation fails as it now cannot fail. + - Fix two nasty runlist merging bugs that had gone unnoticed so far. + Thanks to Stefano Picerno for the bug report. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c index 3bb4a57..d26a1be 100644 --- a/fs/ntfs/runlist.c +++ b/fs/ntfs/runlist.c @@ -542,6 +542,7 @@ runlist_element *ntfs_runlists_merge(runlist_element *drl, /* Scan to the end of the source runlist. */ for (dend = 0; likely(drl[dend].length); dend++) ; + dend++; drl = ntfs_rl_realloc(drl, dend, dend + 1); if (IS_ERR(drl)) return drl; @@ -611,8 +612,8 @@ runlist_element *ntfs_runlists_merge(runlist_element *drl, ((drl[dins].vcn + drl[dins].length) <= /* End of hole */ (srl[send - 1].vcn + srl[send - 1].length))); - /* Or we'll lose an end marker */ - if (start && finish && (drl[dins].length == 0)) + /* Or we will lose an end marker. */ + if (finish && !drl[dins].length) ss++; if (marker && (drl[dins].vcn + drl[dins].length > srl[send - 1].vcn)) finish = FALSE; -- cgit v0.10.2 From 8bb735216a0675e247bbe8b8b92c09d6884d1a17 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 16:48:28 +0100 Subject: NTFS: Remove two bogus BUG_ON()s from fs/ntfs/mft.c. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 4bc8f91..f4c27f7 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -45,6 +45,7 @@ ToDo/Notes: need to panic() if the allocation fails as it now cannot fail. - Fix two nasty runlist merging bugs that had gone unnoticed so far. Thanks to Stefano Picerno for the bug report. + - Remove two bogus BUG_ON()s from fs/ntfs/mft.c. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 317f7c6..e27651d 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c @@ -511,7 +511,6 @@ int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no, } while (bh); tail->b_this_page = head; attach_page_buffers(page, head); - BUG_ON(!page_has_buffers(page)); } bh = head = page_buffers(page); BUG_ON(!bh); @@ -692,7 +691,6 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync) */ if (!NInoTestClearDirty(ni)) goto done; - BUG_ON(!page_has_buffers(page)); bh = head = page_buffers(page); BUG_ON(!bh); rl = NULL; -- cgit v0.10.2 From 2b0ada2b8e086c267dd116a39ad41ff0a717b665 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 16:52:31 +0100 Subject: NTFS: Fix handling of valid but empty mapping pairs array in fs/ntfs/runlist.c::ntfs_mapping_pairs_decompress(). Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index f4c27f7..8fe38c8 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -46,6 +46,8 @@ ToDo/Notes: - Fix two nasty runlist merging bugs that had gone unnoticed so far. Thanks to Stefano Picerno for the bug report. - Remove two bogus BUG_ON()s from fs/ntfs/mft.c. + - Fix handling of valid but empty mapping pairs array in + fs/ntfs/runlist.c::ntfs_mapping_pairs_decompress(). 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c index d26a1be..e4c4716 100644 --- a/fs/ntfs/runlist.c +++ b/fs/ntfs/runlist.c @@ -760,6 +760,9 @@ runlist_element *ntfs_mapping_pairs_decompress(const ntfs_volume *vol, ntfs_error(vol->sb, "Corrupt attribute."); return ERR_PTR(-EIO); } + /* If the mapping pairs array is valid but empty, nothing to do. */ + if (!vcn && !*buf) + return old_rl; /* Current position in runlist array. */ rlpos = 0; /* Allocate first page and set current runlist size to one page. */ -- cgit v0.10.2 From f94ad38e68e1623660fdbb063d0c580ba6661c29 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 17:04:11 +0100 Subject: NTFS: Report unrepresentable inodes during ntfs_readdir() as KERN_WARNING messages and include the inode number. Thanks to Yura Pakhuchiy for pointing this out. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 8fe38c8..45f806f 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -48,6 +48,9 @@ ToDo/Notes: - Remove two bogus BUG_ON()s from fs/ntfs/mft.c. - Fix handling of valid but empty mapping pairs array in fs/ntfs/runlist.c::ntfs_mapping_pairs_decompress(). + - Report unrepresentable inodes during ntfs_readdir() as KERN_WARNING + messages and include the inode number. Thanks to Yura Pakhuchiy for + pointing this out. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c index 4677947..795c3d1 100644 --- a/fs/ntfs/dir.c +++ b/fs/ntfs/dir.c @@ -1051,7 +1051,8 @@ static inline int ntfs_filldir(ntfs_volume *vol, loff_t fpos, ie->key.file_name.file_name_length, &name, NTFS_MAX_NAME_LEN * NLS_MAX_CHARSET_SIZE + 1); if (name_len <= 0) { - ntfs_debug("Skipping unrepresentable file."); + ntfs_warning(vol->sb, "Skipping unrepresentable inode 0x%llx.", + (long long)MREF_LE(ie->data.dir.indexed_file)); return 0; } if (ie->key.file_name.file_attributes & diff --git a/fs/ntfs/unistr.c b/fs/ntfs/unistr.c index 19c42e2..a389a5a 100644 --- a/fs/ntfs/unistr.c +++ b/fs/ntfs/unistr.c @@ -372,7 +372,8 @@ retry: wc = nls->uni2char(le16_to_cpu(ins[i]), ns + o, return -EINVAL; conversion_err: ntfs_error(vol->sb, "Unicode name contains characters that cannot be " - "converted to character set %s.", nls->charset); + "converted to character set %s. You might want to " + "try to use the mount option nls=utf8.", nls->charset); if (ns != *outs) kfree(ns); if (wc != -ENAMETOOLONG) -- cgit v0.10.2 From 8dc003359cc3996abad9e53a7b2280b272610283 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 8 Sep 2005 17:53:01 +0100 Subject: [MMC] Allow detection/removal to be delayed Change mmc_detect_change() to take a delay argument such that the detection of card insertions and removals can be delayed according to the requirements of the host driver or platform. Signed-off-by: Richard Purdie Signed-off-by: Russell King diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 0a117c6..ceae379 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1079,13 +1079,17 @@ static void mmc_setup(struct mmc_host *host) /** * mmc_detect_change - process change of state on a MMC socket * @host: host which changed state. + * @delay: optional delay to wait before detection (jiffies) * * All we know is that card(s) have been inserted or removed * from the socket(s). We don't know which socket or cards. */ -void mmc_detect_change(struct mmc_host *host) +void mmc_detect_change(struct mmc_host *host, unsigned long delay) { - schedule_work(&host->detect); + if (delay) + schedule_delayed_work(&host->detect, delay); + else + schedule_work(&host->detect); } EXPORT_SYMBOL(mmc_detect_change); @@ -1189,7 +1193,7 @@ int mmc_add_host(struct mmc_host *host) ret = mmc_add_host_sysfs(host); if (ret == 0) { mmc_power_off(host); - mmc_detect_change(host); + mmc_detect_change(host, 0); } return ret; @@ -1259,7 +1263,7 @@ EXPORT_SYMBOL(mmc_suspend_host); */ int mmc_resume_host(struct mmc_host *host) { - mmc_detect_change(host); + mmc_detect_change(host, 0); return 0; } diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c index 716c4ef..91c7484 100644 --- a/drivers/mmc/mmci.c +++ b/drivers/mmc/mmci.c @@ -442,7 +442,7 @@ static void mmci_check_status(unsigned long data) status = host->plat->status(mmc_dev(host->mmc)); if (status ^ host->oldstat) - mmc_detect_change(host->mmc); + mmc_detect_change(host->mmc, 0); host->oldstat = status; mod_timer(&host->timer, jiffies + HZ); diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c index e99a53b..5223cd3 100644 --- a/drivers/mmc/pxamci.c +++ b/drivers/mmc/pxamci.c @@ -423,7 +423,7 @@ static void pxamci_dma_irq(int dma, void *devid, struct pt_regs *regs) static irqreturn_t pxamci_detect_irq(int irq, void *devid, struct pt_regs *regs) { - mmc_detect_change(devid); + mmc_detect_change(devid, 0); return IRQ_HANDLED; } diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c index dec01d3..a62c86f 100644 --- a/drivers/mmc/wbsd.c +++ b/drivers/mmc/wbsd.c @@ -1122,7 +1122,7 @@ static void wbsd_detect_card(unsigned long data) DBG("Executing card detection\n"); - mmc_detect_change(host->mmc); + mmc_detect_change(host->mmc, 0); } /* @@ -1198,7 +1198,7 @@ static void wbsd_tasklet_card(unsigned long param) */ spin_unlock(&host->lock); - mmc_detect_change(host->mmc); + mmc_detect_change(host->mmc, 0); } else spin_unlock(&host->lock); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 6014160..c5d73c0 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -123,7 +123,7 @@ extern void mmc_free_host(struct mmc_host *); extern int mmc_suspend_host(struct mmc_host *, pm_message_t); extern int mmc_resume_host(struct mmc_host *); -extern void mmc_detect_change(struct mmc_host *); +extern void mmc_detect_change(struct mmc_host *, unsigned long delay); extern void mmc_request_done(struct mmc_host *, struct mmc_request *); #endif -- cgit v0.10.2 From 3ffc5a443824fcf426d8d35dc632acc4dd9fb6d1 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 20:23:06 +0100 Subject: NTFS: Change ntfs_rl_truncate_nolock() to throw away the runlist if the new length is zero. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 45f806f..79d9899b 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -51,6 +51,8 @@ ToDo/Notes: - Report unrepresentable inodes during ntfs_readdir() as KERN_WARNING messages and include the inode number. Thanks to Yura Pakhuchiy for pointing this out. + - Change ntfs_rl_truncate_nolock() to throw away the runlist if the new + length is zero. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c index e4c4716..539fa2b 100644 --- a/fs/ntfs/runlist.c +++ b/fs/ntfs/runlist.c @@ -1455,6 +1455,7 @@ err_out: /** * ntfs_rl_truncate_nolock - truncate a runlist starting at a specified vcn + * @vol: ntfs volume (needed for error output) * @runlist: runlist to truncate * @new_length: the new length of the runlist in VCNs * @@ -1462,12 +1463,16 @@ err_out: * holding the runlist elements to a length of @new_length VCNs. * * If @new_length lies within the runlist, the runlist elements with VCNs of - * @new_length and above are discarded. + * @new_length and above are discarded. As a special case if @new_length is + * zero, the runlist is discarded and set to NULL. * * If @new_length lies beyond the runlist, a sparse runlist element is added to * the end of the runlist @runlist or if the last runlist element is a sparse * one already, this is extended. * + * Note, no checking is done for unmapped runlist elements. It is assumed that + * the caller has mapped any elements that need to be mapped already. + * * Return 0 on success and -errno on error. * * Locking: The caller must hold @runlist->lock for writing. @@ -1482,6 +1487,13 @@ int ntfs_rl_truncate_nolock(const ntfs_volume *vol, runlist *const runlist, BUG_ON(!runlist); BUG_ON(new_length < 0); rl = runlist->rl; + if (!new_length) { + ntfs_debug("Freeing runlist."); + runlist->rl = NULL; + if (rl) + ntfs_free(rl); + return 0; + } if (unlikely(!rl)) { /* * Create a runlist consisting of a sparse runlist element of -- cgit v0.10.2 From 6e48321a40610f7213e3ac75ba234f6f8b3ed5f5 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 20:26:34 +0100 Subject: NTFS: Add ntfs_rl_punch_nolock() which punches a caller specified hole into a runlist. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 79d9899b..39dca6d 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -53,6 +53,8 @@ ToDo/Notes: pointing this out. - Change ntfs_rl_truncate_nolock() to throw away the runlist if the new length is zero. + - Add runlist.[hc]::ntfs_rl_punch_nolock() which punches a caller + specified hole into a runlist. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c index 539fa2b..f5b2ac9 100644 --- a/fs/ntfs/runlist.c +++ b/fs/ntfs/runlist.c @@ -1601,4 +1601,288 @@ int ntfs_rl_truncate_nolock(const ntfs_volume *vol, runlist *const runlist, return 0; } +/** + * ntfs_rl_punch_nolock - punch a hole into a runlist + * @vol: ntfs volume (needed for error output) + * @runlist: runlist to punch a hole into + * @start: starting VCN of the hole to be created + * @length: size of the hole to be created in units of clusters + * + * Punch a hole into the runlist @runlist starting at VCN @start and of size + * @length clusters. + * + * Return 0 on success and -errno on error, in which case @runlist has not been + * modified. + * + * If @start and/or @start + @length are outside the runlist return error code + * -ENOENT. + * + * If the runlist contains unmapped or error elements between @start and @start + * + @length return error code -EINVAL. + * + * Locking: The caller must hold @runlist->lock for writing. + */ +int ntfs_rl_punch_nolock(const ntfs_volume *vol, runlist *const runlist, + const VCN start, const s64 length) +{ + const VCN end = start + length; + s64 delta; + runlist_element *rl, *rl_end, *rl_real_end, *trl; + int old_size; + BOOL lcn_fixup = FALSE; + + ntfs_debug("Entering for start 0x%llx, length 0x%llx.", + (long long)start, (long long)length); + BUG_ON(!runlist); + BUG_ON(start < 0); + BUG_ON(length < 0); + BUG_ON(end < 0); + rl = runlist->rl; + if (unlikely(!rl)) { + if (likely(!start && !length)) + return 0; + return -ENOENT; + } + /* Find @start in the runlist. */ + while (likely(rl->length && start >= rl[1].vcn)) + rl++; + rl_end = rl; + /* Find @end in the runlist. */ + while (likely(rl_end->length && end >= rl_end[1].vcn)) { + /* Verify there are no unmapped or error elements. */ + if (unlikely(rl_end->lcn < LCN_HOLE)) + return -EINVAL; + rl_end++; + } + /* Check the last element. */ + if (unlikely(rl_end->length && rl_end->lcn < LCN_HOLE)) + return -EINVAL; + /* This covers @start being out of bounds, too. */ + if (!rl_end->length && end > rl_end->vcn) + return -ENOENT; + if (!length) + return 0; + if (!rl->length) + return -ENOENT; + rl_real_end = rl_end; + /* Determine the runlist size. */ + while (likely(rl_real_end->length)) + rl_real_end++; + old_size = rl_real_end - runlist->rl + 1; + /* If @start is in a hole simply extend the hole. */ + if (rl->lcn == LCN_HOLE) { + /* + * If both @start and @end are in the same sparse run, we are + * done. + */ + if (end <= rl[1].vcn) { + ntfs_debug("Done (requested hole is already sparse)."); + return 0; + } +extend_hole: + /* Extend the hole. */ + rl->length = end - rl->vcn; + /* If @end is in a hole, merge it with the current one. */ + if (rl_end->lcn == LCN_HOLE) { + rl_end++; + rl->length = rl_end->vcn - rl->vcn; + } + /* We have done the hole. Now deal with the remaining tail. */ + rl++; + /* Cut out all runlist elements up to @end. */ + if (rl < rl_end) + memmove(rl, rl_end, (rl_real_end - rl_end + 1) * + sizeof(*rl)); + /* Adjust the beginning of the tail if necessary. */ + if (end > rl->vcn) { + s64 delta = end - rl->vcn; + rl->vcn = end; + rl->length -= delta; + /* Only adjust the lcn if it is real. */ + if (rl->lcn >= 0) + rl->lcn += delta; + } +shrink_allocation: + /* Reallocate memory if the allocation changed. */ + if (rl < rl_end) { + rl = ntfs_rl_realloc(runlist->rl, old_size, + old_size - (rl_end - rl)); + if (IS_ERR(rl)) + ntfs_warning(vol->sb, "Failed to shrink " + "runlist buffer. This just " + "wastes a bit of memory " + "temporarily so we ignore it " + "and return success."); + else + runlist->rl = rl; + } + ntfs_debug("Done (extend hole)."); + return 0; + } + /* + * If @start is at the beginning of a run things are easier as there is + * no need to split the first run. + */ + if (start == rl->vcn) { + /* + * @start is at the beginning of a run. + * + * If the previous run is sparse, extend its hole. + * + * If @end is not in the same run, switch the run to be sparse + * and extend the newly created hole. + * + * Thus both of these cases reduce the problem to the above + * case of "@start is in a hole". + */ + if (rl > runlist->rl && (rl - 1)->lcn == LCN_HOLE) { + rl--; + goto extend_hole; + } + if (end >= rl[1].vcn) { + rl->lcn = LCN_HOLE; + goto extend_hole; + } + /* + * The final case is when @end is in the same run as @start. + * For this need to split the run into two. One run for the + * sparse region between the beginning of the old run, i.e. + * @start, and @end and one for the remaining non-sparse + * region, i.e. between @end and the end of the old run. + */ + trl = ntfs_rl_realloc(runlist->rl, old_size, old_size + 1); + if (IS_ERR(trl)) + goto enomem_out; + old_size++; + if (runlist->rl != trl) { + rl = trl + (rl - runlist->rl); + rl_end = trl + (rl_end - runlist->rl); + rl_real_end = trl + (rl_real_end - runlist->rl); + runlist->rl = trl; + } +split_end: + /* Shift all the runs up by one. */ + memmove(rl + 1, rl, (rl_real_end - rl + 1) * sizeof(*rl)); + /* Finally, setup the two split runs. */ + rl->lcn = LCN_HOLE; + rl->length = length; + rl++; + rl->vcn += length; + /* Only adjust the lcn if it is real. */ + if (rl->lcn >= 0 || lcn_fixup) + rl->lcn += length; + rl->length -= length; + ntfs_debug("Done (split one)."); + return 0; + } + /* + * @start is neither in a hole nor at the beginning of a run. + * + * If @end is in a hole, things are easier as simply truncating the run + * @start is in to end at @start - 1, deleting all runs after that up + * to @end, and finally extending the beginning of the run @end is in + * to be @start is all that is needed. + */ + if (rl_end->lcn == LCN_HOLE) { + /* Truncate the run containing @start. */ + rl->length = start - rl->vcn; + rl++; + /* Cut out all runlist elements up to @end. */ + if (rl < rl_end) + memmove(rl, rl_end, (rl_real_end - rl_end + 1) * + sizeof(*rl)); + /* Extend the beginning of the run @end is in to be @start. */ + rl->vcn = start; + rl->length = rl[1].vcn - start; + goto shrink_allocation; + } + /* + * If @end is not in a hole there are still two cases to distinguish. + * Either @end is or is not in the same run as @start. + * + * The second case is easier as it can be reduced to an already solved + * problem by truncating the run @start is in to end at @start - 1. + * Then, if @end is in the next run need to split the run into a sparse + * run followed by a non-sparse run (already covered above) and if @end + * is not in the next run switching it to be sparse, again reduces the + * problem to the already covered case of "@start is in a hole". + */ + if (end >= rl[1].vcn) { + /* + * If @end is not in the next run, reduce the problem to the + * case of "@start is in a hole". + */ + if (rl[1].length && end >= rl[2].vcn) { + /* Truncate the run containing @start. */ + rl->length = start - rl->vcn; + rl++; + rl->vcn = start; + rl->lcn = LCN_HOLE; + goto extend_hole; + } + trl = ntfs_rl_realloc(runlist->rl, old_size, old_size + 1); + if (IS_ERR(trl)) + goto enomem_out; + old_size++; + if (runlist->rl != trl) { + rl = trl + (rl - runlist->rl); + rl_end = trl + (rl_end - runlist->rl); + rl_real_end = trl + (rl_real_end - runlist->rl); + runlist->rl = trl; + } + /* Truncate the run containing @start. */ + rl->length = start - rl->vcn; + rl++; + /* + * @end is in the next run, reduce the problem to the case + * where "@start is at the beginning of a run and @end is in + * the same run as @start". + */ + delta = rl->vcn - start; + rl->vcn = start; + if (rl->lcn >= 0) { + rl->lcn -= delta; + /* Need this in case the lcn just became negative. */ + lcn_fixup = TRUE; + } + rl->length += delta; + goto split_end; + } + /* + * The first case from above, i.e. @end is in the same run as @start. + * We need to split the run into three. One run for the non-sparse + * region between the beginning of the old run and @start, one for the + * sparse region between @start and @end, and one for the remaining + * non-sparse region, i.e. between @end and the end of the old run. + */ + trl = ntfs_rl_realloc(runlist->rl, old_size, old_size + 2); + if (IS_ERR(trl)) + goto enomem_out; + old_size += 2; + if (runlist->rl != trl) { + rl = trl + (rl - runlist->rl); + rl_end = trl + (rl_end - runlist->rl); + rl_real_end = trl + (rl_real_end - runlist->rl); + runlist->rl = trl; + } + /* Shift all the runs up by two. */ + memmove(rl + 2, rl, (rl_real_end - rl + 1) * sizeof(*rl)); + /* Finally, setup the three split runs. */ + rl->length = start - rl->vcn; + rl++; + rl->vcn = start; + rl->lcn = LCN_HOLE; + rl->length = length; + rl++; + delta = end - rl->vcn; + rl->vcn = end; + rl->lcn += delta; + rl->length -= delta; + ntfs_debug("Done (split both)."); + return 0; +enomem_out: + ntfs_error(vol->sb, "Not enough memory to extend runlist buffer."); + return -ENOMEM; +} + #endif /* NTFS_RW */ diff --git a/fs/ntfs/runlist.h b/fs/ntfs/runlist.h index aa0ee65..47728fb 100644 --- a/fs/ntfs/runlist.h +++ b/fs/ntfs/runlist.h @@ -94,6 +94,9 @@ extern int ntfs_mapping_pairs_build(const ntfs_volume *vol, s8 *dst, extern int ntfs_rl_truncate_nolock(const ntfs_volume *vol, runlist *const runlist, const s64 new_length); +int ntfs_rl_punch_nolock(const ntfs_volume *vol, runlist *const runlist, + const VCN start, const s64 length); + #endif /* NTFS_RW */ #endif /* _LINUX_NTFS_RUNLIST_H */ -- cgit v0.10.2 From 8e08ceaeacd5d300aaad166f2eef8bfc37e09831 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 20:29:50 +0100 Subject: NTFS: Fix a bug in fs/ntfs/index.c::ntfs_index_lookup(). When the returned index entry is in the index root, we forgot to set the @ir pointer in the index context. Thanks for Yura Pakhuchiy for finding this bug. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 39dca6d..1168d3e 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -55,6 +55,9 @@ ToDo/Notes: length is zero. - Add runlist.[hc]::ntfs_rl_punch_nolock() which punches a caller specified hole into a runlist. + - Fix a bug in fs/ntfs/index.c::ntfs_index_lookup(). When the returned + index entry is in the index root, we forgot to set the @ir pointer in + the index context. Thanks to Yura Pakhuchiy for finding this bug. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/index.c b/fs/ntfs/index.c index 11fd530..8f2d572 100644 --- a/fs/ntfs/index.c +++ b/fs/ntfs/index.c @@ -205,6 +205,7 @@ int ntfs_index_lookup(const void *key, const int key_len, &ie->key, key_len)) { ir_done: ictx->is_in_root = TRUE; + ictx->ir = ir; ictx->actx = actx; ictx->base_ni = base_ni; ictx->ia = NULL; -- cgit v0.10.2 From 0e4e4220f10bf8f58a8606f0cb28538088c64b1a Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 8 Sep 2005 12:32:03 -0700 Subject: [NET]: Optimize pskb_trim_rcsum() Since packets almost never contain extra garbage at the end, it is worthwhile to optimize for that case. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index da7da9c..2741c0c 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1167,7 +1167,7 @@ static inline void skb_postpull_rcsum(struct sk_buff *skb, static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len) { - if (len >= skb->len) + if (likely(len >= skb->len)) return 0; if (skb->ip_summed == CHECKSUM_HW) skb->ip_summed = CHECKSUM_NONE; -- cgit v0.10.2 From e308e25c97f06cf704e65eeb773412f5460a3b93 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 8 Sep 2005 12:32:21 -0700 Subject: [IPV4] udp: trim forgets about CHECKSUM_HW A UDP packet may contain extra data that needs to be trimmed off. But when doing so, UDP forgets to fixup the skb checksum if CHECKSUM_HW is being used. I think this explains the case of a NFS receive using skge driver causing 'udp hw checksum failures' when interacting with a crufty settop box. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index e5beca7..e0bd101 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1141,7 +1141,7 @@ int udp_rcv(struct sk_buff *skb) if (ulen > len || ulen < sizeof(*uh)) goto short_packet; - if (pskb_trim(skb, ulen)) + if (pskb_trim_rcsum(skb, ulen)) goto short_packet; if (udp_checksum_init(skb, uh, ulen, saddr, daddr) < 0) -- cgit v0.10.2 From e50ef933e649a2b43aa10c8a60c491543b8b4c02 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 8 Sep 2005 12:32:46 -0700 Subject: [NET]: Need struct sock forward decl in net/compat.h Else we get build failures like: CC arch/sparc64/kernel/sparc64_ksyms.o In file included from arch/sparc64/kernel/sparc64_ksyms.c:28: include/net/compat.h:37: warning: "struct sock" declared inside parameter list include/net/compat.h:37: warning: its scope is only this definition or declaration, which is probably not what you want Signed-off-by: David S. Miller diff --git a/include/net/compat.h b/include/net/compat.h index 482eb82..290bab4 100644 --- a/include/net/compat.h +++ b/include/net/compat.h @@ -33,7 +33,8 @@ extern asmlinkage long compat_sys_sendmsg(int,struct compat_msghdr __user *,unsi extern asmlinkage long compat_sys_recvmsg(int,struct compat_msghdr __user *,unsigned); extern asmlinkage long compat_sys_getsockopt(int, int, int, char __user *, int __user *); extern int put_cmsg_compat(struct msghdr*, int, int, int, void *); -extern int cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *, unsigned char *, - int); + +struct sock; +extern int cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *, unsigned char *, int); #endif /* NET_COMPAT_H */ -- cgit v0.10.2 From f25dfb5e44fa8641961780d681bc1871abcfb861 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 20:35:33 +0100 Subject: NTFS: Remove bogus setting of PageError in ntfs_read_compressed_block(). Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 1168d3e..96224c0 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -58,6 +58,7 @@ ToDo/Notes: - Fix a bug in fs/ntfs/index.c::ntfs_index_lookup(). When the returned index entry is in the index root, we forgot to set the @ir pointer in the index context. Thanks to Yura Pakhuchiy for finding this bug. + - Remove bogus setting of PageError in ntfs_read_compressed_block(). 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c index 6d265cf..25d2410 100644 --- a/fs/ntfs/compress.c +++ b/fs/ntfs/compress.c @@ -539,7 +539,6 @@ int ntfs_read_compressed_block(struct page *page) if (unlikely(!pages || !bhs)) { kfree(bhs); kfree(pages); - SetPageError(page); unlock_page(page); ntfs_error(vol->sb, "Failed to allocate internal buffers."); return -ENOMEM; @@ -871,9 +870,6 @@ lock_retry_remap: for (; prev_cur_page < cur_page; prev_cur_page++) { page = pages[prev_cur_page]; if (page) { - if (prev_cur_page == xpage && - !xpage_done) - SetPageError(page); flush_dcache_page(page); kunmap(page); unlock_page(page); @@ -904,8 +900,6 @@ lock_retry_remap: "Terminating them with extreme " "prejudice. Inode 0x%lx, page index " "0x%lx.", ni->mft_no, page->index); - if (cur_page == xpage && !xpage_done) - SetPageError(page); flush_dcache_page(page); kunmap(page); unlock_page(page); @@ -953,8 +947,6 @@ err_out: for (i = cur_page; i < max_page; i++) { page = pages[i]; if (page) { - if (i == xpage && !xpage_done) - SetPageError(page); flush_dcache_page(page); kunmap(page); unlock_page(page); diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index e0f530c..be9fd1d 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c @@ -1,7 +1,7 @@ /* - * file.c - NTFS kernel file operations. Part of the Linux-NTFS project. + * file.c - NTFS kernel file operations. Part of the Linux-NTFS project. * - * Copyright (c) 2001-2004 Anton Altaparmakov + * Copyright (c) 2001-2005 Anton Altaparmakov * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -94,6 +94,11 @@ static int ntfs_file_fsync(struct file *filp, struct dentry *dentry, if (!datasync || !NInoNonResident(NTFS_I(vi))) ret = ntfs_write_inode(vi, 1); write_inode_now(vi, !datasync); + /* + * NOTE: If we were to use mapping->private_list (see ext2 and + * fs/buffer.c) for dirty blocks then we could optimize the below to be + * sync_mapping_buffers(vi->i_mapping). + */ err = sync_blockdev(vi->i_sb->s_bdev); if (unlikely(err && !ret)) ret = err; -- cgit v0.10.2 From 0aacceacf35451ffb771ec825555e98c5dce8b01 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 20:40:32 +0100 Subject: NTFS: Add fs/ntfs/attrib.[hc]::ntfs_resident_attr_value_resize(). Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 96224c0..29841bf 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -59,6 +59,7 @@ ToDo/Notes: index entry is in the index root, we forgot to set the @ir pointer in the index context. Thanks to Yura Pakhuchiy for finding this bug. - Remove bogus setting of PageError in ntfs_read_compressed_block(). + - Add fs/ntfs/attrib.[hc]::ntfs_resident_attr_value_resize(). 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index cd0f9e7..79dda39 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -1247,6 +1247,46 @@ int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size) } /** + * ntfs_resident_attr_value_resize - resize the value of a resident attribute + * @m: mft record containing attribute record + * @a: attribute record whose value to resize + * @new_size: new size in bytes to which to resize the attribute value of @a + * + * Resize the value of the attribute @a in the mft record @m to @new_size bytes. + * If the value is made bigger, the newly allocated space is cleared. + * + * Return 0 on success and -errno on error. The following error codes are + * defined: + * -ENOSPC - Not enough space in the mft record @m to perform the resize. + * + * Note: On error, no modifications have been performed whatsoever. + * + * Warning: If you make a record smaller without having copied all the data you + * are interested in the data may be overwritten. + */ +int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a, + const u32 new_size) +{ + u32 old_size; + + /* Resize the resident part of the attribute record. */ + if (ntfs_attr_record_resize(m, a, + le16_to_cpu(a->data.resident.value_offset) + new_size)) + return -ENOSPC; + /* + * The resize succeeded! If we made the attribute value bigger, clear + * the area between the old size and @new_size. + */ + old_size = le32_to_cpu(a->data.resident.value_length); + if (new_size > old_size) + memset((u8*)a + le16_to_cpu(a->data.resident.value_offset) + + old_size, 0, new_size - old_size); + /* Finally update the length of the attribute value. */ + a->data.resident.value_length = cpu_to_le32(new_size); + return 0; +} + +/** * ntfs_attr_make_non_resident - convert a resident to a non-resident attribute * @ni: ntfs inode describing the attribute to convert * diff --git a/fs/ntfs/attrib.h b/fs/ntfs/attrib.h index 0e4ac6d..0618ed6 100644 --- a/fs/ntfs/attrib.h +++ b/fs/ntfs/attrib.h @@ -99,6 +99,8 @@ extern int ntfs_attr_can_be_resident(const ntfs_volume *vol, const ATTR_TYPE type); extern int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size); +extern int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a, + const u32 new_size); extern int ntfs_attr_make_non_resident(ntfs_inode *ni); -- cgit v0.10.2 From 2983d1bd1a596e88cdddc0c2d45b9e97728f3f41 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 20:56:09 +0100 Subject: NTFS: Fix several bugs in fs/ntfs/attrib.c. - Fix a bug in ntfs_map_runlist_nolock() where we forgot to protect access to the allocated size in the ntfs inode with the size lock. - Fix ntfs_attr_vcn_to_lcn_nolock() and ntfs_attr_find_vcn_nolock() to return LCN_ENOENT when there is no runlist and the allocated size is zero. - Fix load_attribute_list() to handle the case of a NULL runlist. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 29841bf..1d1dcab 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -60,6 +60,12 @@ ToDo/Notes: the index context. Thanks to Yura Pakhuchiy for finding this bug. - Remove bogus setting of PageError in ntfs_read_compressed_block(). - Add fs/ntfs/attrib.[hc]::ntfs_resident_attr_value_resize(). + - Fix a bug in ntfs_map_runlist_nolock() where we forgot to protect + access to the allocated size in the ntfs inode with the size lock. + - Fix ntfs_attr_vcn_to_lcn_nolock() and ntfs_attr_find_vcn_nolock() to + return LCN_ENOENT when there is no runlist and the allocated size is + zero. + - Fix load_attribute_list() to handle the case of a NULL runlist. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index 79dda39..98b5b96 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -43,6 +43,9 @@ * which is not an error as such. This is -ENOENT. It means that @vcn is out * of bounds of the runlist. * + * Note the runlist can be NULL after this function returns if @vcn is zero and + * the attribute has zero allocated size, i.e. there simply is no runlist. + * * Locking: - The runlist must be locked for writing. * - This function modifies the runlist. */ @@ -54,6 +57,7 @@ int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn) ATTR_RECORD *a; ntfs_attr_search_ctx *ctx; runlist_element *rl; + unsigned long flags; int err = 0; ntfs_debug("Mapping runlist part containing vcn 0x%llx.", @@ -85,8 +89,11 @@ int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn) * ntfs_mapping_pairs_decompress() fails. */ end_vcn = sle64_to_cpu(a->data.non_resident.highest_vcn) + 1; - if (unlikely(!a->data.non_resident.lowest_vcn && end_vcn <= 1)) + if (unlikely(!a->data.non_resident.lowest_vcn && end_vcn <= 1)) { + read_lock_irqsave(&ni->size_lock, flags); end_vcn = ni->allocated_size >> ni->vol->cluster_size_bits; + read_unlock_irqrestore(&ni->size_lock, flags); + } if (unlikely(vcn >= end_vcn)) { err = -ENOENT; goto err_out; @@ -165,6 +172,7 @@ LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn, const BOOL write_locked) { LCN lcn; + unsigned long flags; BOOL is_retry = FALSE; ntfs_debug("Entering for i_ino 0x%lx, vcn 0x%llx, %s_locked.", @@ -173,6 +181,14 @@ LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn, BUG_ON(!ni); BUG_ON(!NInoNonResident(ni)); BUG_ON(vcn < 0); + if (!ni->runlist.rl) { + read_lock_irqsave(&ni->size_lock, flags); + if (!ni->allocated_size) { + read_unlock_irqrestore(&ni->size_lock, flags); + return LCN_ENOENT; + } + read_unlock_irqrestore(&ni->size_lock, flags); + } retry_remap: /* Convert vcn to lcn. If that fails map the runlist and retry once. */ lcn = ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn); @@ -255,6 +271,7 @@ retry_remap: runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni, const VCN vcn, const BOOL write_locked) { + unsigned long flags; runlist_element *rl; int err = 0; BOOL is_retry = FALSE; @@ -265,6 +282,14 @@ runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni, const VCN vcn, BUG_ON(!ni); BUG_ON(!NInoNonResident(ni)); BUG_ON(vcn < 0); + if (!ni->runlist.rl) { + read_lock_irqsave(&ni->size_lock, flags); + if (!ni->allocated_size) { + read_unlock_irqrestore(&ni->size_lock, flags); + return ERR_PTR(-ENOENT); + } + read_unlock_irqrestore(&ni->size_lock, flags); + } retry_remap: rl = ni->runlist.rl; if (likely(rl && vcn >= rl[0].vcn)) { @@ -528,6 +553,11 @@ int load_attribute_list(ntfs_volume *vol, runlist *runlist, u8 *al_start, block_size_bits = sb->s_blocksize_bits; down_read(&runlist->lock); rl = runlist->rl; + if (!rl) { + ntfs_error(sb, "Cannot read attribute list since runlist is " + "missing."); + goto err_out; + } /* Read all clusters specified by the runlist one run at a time. */ while (rl->length) { lcn = ntfs_rl_vcn_to_lcn(rl, rl->vcn); -- cgit v0.10.2 From 42ca89c18b75e1c4c3b02aa5589ad3aa916909a8 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 8 Sep 2005 12:57:43 -0700 Subject: [IPV6]: Need to use pskb_trim_rcsum(). Fix pskb_trim usage in ipv6. Only the udp one is really a bug, other places are just doing equivalent code. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c index 5be6da2..3b9fa90 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c @@ -459,11 +459,10 @@ static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff) IP6_INC_STATS_BH(IPSTATS_MIB_INTRUNCATEDPKTS); goto drop; } - if (pkt_len + sizeof(struct ipv6hdr) < skb->len) { - __pskb_trim(skb, pkt_len + sizeof(struct ipv6hdr)); - if (skb->ip_summed == CHECKSUM_HW) - skb->ip_summed = CHECKSUM_NONE; - } + + if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr))) + goto drop; + return 1; drop: diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 9d9e043..e4fe9ee 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -479,12 +479,9 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, /* Point into the IP datagram 'data' part. */ if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) goto err; - if (end-offset < skb->len) { - if (pskb_trim(skb, end - offset)) - goto err; - if (skb->ip_summed != CHECKSUM_UNNECESSARY) - skb->ip_summed = CHECKSUM_NONE; - } + + if (pskb_trim_rcsum(skb, end - offset)) + goto err; /* Find out which fragments are in front and at the back of us * in the chain of fragments so far. We must know where to put diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 390d750..7cbcaa3 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -483,7 +483,7 @@ static int udpv6_rcv(struct sk_buff **pskb, unsigned int *nhoffp) } if (ulen < skb->len) { - if (__pskb_trim(skb, ulen)) + if (pskb_trim_rcsum(skb, ulen)) goto discard; saddr = &skb->nh.ipv6h->saddr; daddr = &skb->nh.ipv6h->daddr; -- cgit v0.10.2 From 807c453de7c5487d2e5eece76bafdea8f39d249e Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 21:01:17 +0100 Subject: NTFS: Fix handling of sparse attributes in ntfs_attr_make_non_resident(). Also, add BUG() checks to ntfs_attr_make_non_resident() and ntfs_attr_set() to ensure that these functions are never called for compressed or encrypted attributes. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 1d1dcab..b0cc43b 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -66,6 +66,10 @@ ToDo/Notes: return LCN_ENOENT when there is no runlist and the allocated size is zero. - Fix load_attribute_list() to handle the case of a NULL runlist. + - Fix handling of sparse attributes in ntfs_attr_make_non_resident(). + - Add BUG() checks to ntfs_attr_make_non_resident() and ntfs_attr_set() + to ensure that these functions are never called for compressed or + encrypted attributes. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index 98b5b96..3f9a4ff 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -1372,6 +1372,12 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni) return err; } /* + * FIXME: Compressed and encrypted attributes are not supported when + * writing and we should never have gotten here for them. + */ + BUG_ON(NInoCompressed(ni)); + BUG_ON(NInoEncrypted(ni)); + /* * The size needs to be aligned to a cluster boundary for allocation * purposes. */ @@ -1447,10 +1453,15 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni) BUG_ON(a->non_resident); /* * Calculate new offsets for the name and the mapping pairs array. - * We assume the attribute is not compressed or sparse. */ - name_ofs = (offsetof(ATTR_REC, - data.non_resident.compressed_size) + 7) & ~7; + if (NInoSparse(ni) || NInoCompressed(ni)) + name_ofs = (offsetof(ATTR_REC, + data.non_resident.compressed_size) + + sizeof(a->data.non_resident.compressed_size) + + 7) & ~7; + else + name_ofs = (offsetof(ATTR_REC, + data.non_resident.compressed_size) + 7) & ~7; mp_ofs = (name_ofs + a->name_length * sizeof(ntfschar) + 7) & ~7; /* * Determine the size of the resident part of the now non-resident @@ -1489,24 +1500,23 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni) memmove((u8*)a + name_ofs, (u8*)a + le16_to_cpu(a->name_offset), a->name_length * sizeof(ntfschar)); a->name_offset = cpu_to_le16(name_ofs); - /* - * FIXME: For now just clear all of these as we do not support them - * when writing. - */ - a->flags &= cpu_to_le16(0xffff & ~le16_to_cpu(ATTR_IS_SPARSE | - ATTR_IS_ENCRYPTED | ATTR_COMPRESSION_MASK)); /* Setup the fields specific to non-resident attributes. */ a->data.non_resident.lowest_vcn = 0; a->data.non_resident.highest_vcn = cpu_to_sle64((new_size - 1) >> vol->cluster_size_bits); a->data.non_resident.mapping_pairs_offset = cpu_to_le16(mp_ofs); - a->data.non_resident.compression_unit = 0; memset(&a->data.non_resident.reserved, 0, sizeof(a->data.non_resident.reserved)); a->data.non_resident.allocated_size = cpu_to_sle64(new_size); a->data.non_resident.data_size = a->data.non_resident.initialized_size = cpu_to_sle64(attr_size); + if (NInoSparse(ni) || NInoCompressed(ni)) { + a->data.non_resident.compression_unit = 4; + a->data.non_resident.compressed_size = + a->data.non_resident.allocated_size; + } else + a->data.non_resident.compression_unit = 0; /* Generate the mapping pairs array into the attribute record. */ err = ntfs_mapping_pairs_build(vol, (u8*)a + mp_ofs, arec_size - mp_ofs, rl, 0, -1, NULL); @@ -1516,16 +1526,19 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni) goto undo_err_out; } /* Setup the in-memory attribute structure to be non-resident. */ - /* - * FIXME: For now just clear all of these as we do not support them - * when writing. - */ - NInoClearSparse(ni); - NInoClearEncrypted(ni); - NInoClearCompressed(ni); ni->runlist.rl = rl; write_lock_irqsave(&ni->size_lock, flags); ni->allocated_size = new_size; + if (NInoSparse(ni) || NInoCompressed(ni)) { + ni->itype.compressed.size = ni->allocated_size; + ni->itype.compressed.block_size = 1U << + (a->data.non_resident.compression_unit + + vol->cluster_size_bits); + ni->itype.compressed.block_size_bits = + ffs(ni->itype.compressed.block_size) - 1; + ni->itype.compressed.block_clusters = 1U << + a->data.non_resident.compression_unit; + } write_unlock_irqrestore(&ni->size_lock, flags); /* * This needs to be last since the address space operations ->readpage @@ -1673,6 +1686,12 @@ int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, const u8 val) BUG_ON(cnt < 0); if (!cnt) goto done; + /* + * FIXME: Compressed and encrypted attributes are not supported when + * writing and we should never have gotten here for them. + */ + BUG_ON(NInoCompressed(ni)); + BUG_ON(NInoEncrypted(ni)); mapping = VFS_I(ni)->i_mapping; /* Work out the starting index and page offset. */ idx = ofs >> PAGE_CACHE_SHIFT; -- cgit v0.10.2 From 6fd60fa97b706e52abba7c9f810b148aa230817f Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 8 Sep 2005 21:04:58 +0100 Subject: [I2C] Clean up i2c-pxa debugging/printks Fix up comments made by review by gregkh. Signed-off-by: Russell King diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index a72d283..fdf53ce 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -60,17 +60,6 @@ struct pxa_i2c { */ #define I2C_PXA_SLAVE_ADDR 0x1 -/* - * Set this to zero to remove all debug statements via dead code elimination. - */ -#undef DEBUG - -#if 0 -#define DBGLVL KERN_INFO -#else -#define DBGLVL KERN_DEBUG -#endif - #ifdef DEBUG struct bits { @@ -108,7 +97,7 @@ static const struct bits isr_bits[] = { static void decode_ISR(unsigned int val) { - decode_bits(DBGLVL "ISR", isr_bits, ARRAY_SIZE(isr_bits), val); + decode_bits(KERN_DEBUG "ISR", isr_bits, ARRAY_SIZE(isr_bits), val); printk("\n"); } @@ -132,7 +121,7 @@ static const struct bits icr_bits[] = { static void decode_ICR(unsigned int val) { - decode_bits(DBGLVL "ICR", icr_bits, ARRAY_SIZE(icr_bits), val); + decode_bits(KERN_DEBUG "ICR", icr_bits, ARRAY_SIZE(icr_bits), val); printk("\n"); } @@ -140,7 +129,7 @@ static unsigned int i2c_debug = DEBUG; static void i2c_pxa_show_state(struct pxa_i2c *i2c, int lno, const char *fname) { - printk(DBGLVL "state:%s:%d: ISR=%08x, ICR=%08x, IBMR=%02x\n", fname, lno, ISR, ICR, IBMR); + dev_dbg(&i2c->adap.dev, "state:%s:%d: ISR=%08x, ICR=%08x, IBMR=%02x\n", fname, lno, ISR, ICR, IBMR); } #define show_state(i2c) i2c_pxa_show_state(i2c, __LINE__, __FUNCTION__) @@ -152,7 +141,7 @@ static void i2c_pxa_show_state(struct pxa_i2c *i2c, int lno, const char *fname) #define decode_ICR(val) do { } while (0) #endif -#define eedbg(lvl, x...) do { if ((lvl) < 1) { printk(DBGLVL "" x); } } while(0) +#define eedbg(lvl, x...) do { if ((lvl) < 1) { printk(KERN_DEBUG "" x); } } while(0) static void i2c_pxa_master_complete(struct pxa_i2c *i2c, int ret); @@ -162,7 +151,8 @@ static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why) printk("i2c: error: %s\n", why); printk("i2c: msg_num: %d msg_idx: %d msg_ptr: %d\n", i2c->msg_num, i2c->msg_idx, i2c->msg_ptr); - printk("i2c: ICR: %08x ISR: %08x\ni2c: log: ", ICR, ISR); + printk("i2c: ICR: %08x ISR: %08x\n" + "i2c: log: ", ICR, ISR); for (i = 0; i < i2c->irqlogidx; i++) printk("[%08x:%08x] ", i2c->isrlog[i], i2c->icrlog[i]); printk("\n"); @@ -178,7 +168,7 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c) unsigned long timeout = jiffies + HZ/4; if (i2c_pxa_is_slavemode(i2c)) { - printk(DBGLVL "i2c_pxa_transfer: called in slave mode\n"); + dev_dbg(&i2c->adap.dev, "%s: called in slave mode\n", __func__); return; } @@ -222,12 +212,12 @@ static int i2c_pxa_wait_master(struct pxa_i2c *i2c) while (time_before(jiffies, timeout)) { if (i2c_debug > 1) - printk(DBGLVL "i2c_pxa_wait_master: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n", - (long)jiffies, ISR, ICR, IBMR); + dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n", + __func__, (long)jiffies, ISR, ICR, IBMR); if (ISR & ISR_SAD) { if (i2c_debug > 0) - printk(DBGLVL "i2c_pxa_wait_master: Slave detected\n"); + dev_dbg(&i2c->adap.dev, "%s: Slave detected\n", __func__); goto out; } @@ -237,7 +227,7 @@ static int i2c_pxa_wait_master(struct pxa_i2c *i2c) */ if ((ISR & (ISR_UB | ISR_IBB)) == 0 && IBMR == 3) { if (i2c_debug > 0) - printk(DBGLVL "i2c_pxa_wait_master: done\n"); + dev_dbg(&i2c->adap.dev, "%s: done\n", __func__); return 1; } @@ -245,7 +235,7 @@ static int i2c_pxa_wait_master(struct pxa_i2c *i2c) } if (i2c_debug > 0) - printk(DBGLVL "i2c_pxa_wait_master: did not free\n"); + dev_dbg(&i2c->adap.dev, "%s: did not free\n", __func__); out: return 0; } @@ -253,12 +243,12 @@ static int i2c_pxa_wait_master(struct pxa_i2c *i2c) static int i2c_pxa_set_master(struct pxa_i2c *i2c) { if (i2c_debug) - printk(DBGLVL "I2C: setting to bus master\n"); + dev_dbg(&i2c->adap.dev, "setting to bus master\n"); if ((ISR & (ISR_UB | ISR_IBB)) != 0) { - printk(DBGLVL "set_master: unit is busy\n"); + dev_dbg(&i2c->adap.dev, "%s: unit is busy\n", __func__); if (!i2c_pxa_wait_master(i2c)) { - printk(DBGLVL "set_master: error: unit busy\n"); + dev_dbg(&i2c->adap.dev, "%s: error: unit busy\n", __func__); return I2C_RETRY; } } @@ -278,13 +268,13 @@ static int i2c_pxa_wait_slave(struct pxa_i2c *i2c) while (time_before(jiffies, timeout)) { if (i2c_debug > 1) - printk(DBGLVL "i2c_pxa_wait_slave: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n", - (long)jiffies, ISR, ICR, IBMR); + dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n", + __func__, (long)jiffies, ISR, ICR, IBMR); if ((ISR & (ISR_UB|ISR_IBB|ISR_SAD)) == ISR_SAD || (ICR & ICR_SCLE) == 0) { if (i2c_debug > 1) - printk(DBGLVL "i2c_pxa_wait_slave: done\n"); + dev_dbg(&i2c->adap.dev, "%s: done\n", __func__); return 1; } @@ -292,7 +282,7 @@ static int i2c_pxa_wait_slave(struct pxa_i2c *i2c) } if (i2c_debug > 0) - printk(DBGLVL "i2c_pxa_wait_slave: did not free\n"); + dev_dbg(&i2c->adap.dev, "%s: did not free\n", __func__); return 0; } @@ -316,7 +306,8 @@ static void i2c_pxa_set_slave(struct pxa_i2c *i2c, int errcode) } if (!i2c_pxa_wait_slave(i2c)) { - printk(KERN_ERR "i2c_pxa_set_slave: wait timedout\n"); + dev_err(&i2c->adap.dev, "%s: wait timedout\n", + __func__); return; } } @@ -325,7 +316,7 @@ static void i2c_pxa_set_slave(struct pxa_i2c *i2c, int errcode) ICR &= ~ICR_SCLE; if (i2c_debug) { - printk(DBGLVL "ICR now %08x, ISR %08x\n", ICR, ISR); + dev_dbg(&i2c->adap.dev, "ICR now %08x, ISR %08x\n", ICR, ISR); decode_ICR(ICR); } } @@ -351,7 +342,7 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c) ICR = I2C_ICR_INIT; #ifdef CONFIG_I2C_PXA_SLAVE - printk(KERN_INFO "I2C: Enabling slave mode\n"); + dev_info(&i2c->adap.dev, "Enabling slave mode\n"); ICR |= ICR_SADIE | ICR_ALDIE | ICR_SSDIE; #endif @@ -522,7 +513,7 @@ static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr) int timeout; if (i2c_debug > 0) - printk(DBGLVL "I2C: SAD, mode is slave-%cx\n", + dev_dbg(&i2c->adap.dev, "SAD, mode is slave-%cx\n", (isr & ISR_RWM) ? 'r' : 't'); if (i2c->slave != NULL) @@ -546,7 +537,7 @@ static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr) timeout--; if (timeout <= 0) { - printk(KERN_ERR "timeout waiting for SCL high\n"); + dev_err(&i2c->adap.dev, "timeout waiting for SCL high\n"); break; } } @@ -557,13 +548,13 @@ static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr) static void i2c_pxa_slave_stop(struct pxa_i2c *i2c) { if (i2c_debug > 2) - printk(DBGLVL "ISR: SSD (Slave Stop)\n"); + dev_dbg(&i2c->adap.dev, "ISR: SSD (Slave Stop)\n"); if (i2c->slave != NULL) i2c->slave->event(i2c->slave->data, I2C_SLAVE_EVENT_STOP); if (i2c_debug > 2) - printk(DBGLVL "ISR: SSD (Slave Stop) acked\n"); + dev_dbg(&i2c->adap.dev, "ISR: SSD (Slave Stop) acked\n"); /* * If we have a master-mode message waiting, @@ -609,7 +600,7 @@ static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr) timeout--; if (timeout <= 0) { - printk(KERN_ERR "timeout waiting for SCL high\n"); + dev_err(&i2c->adap.dev, "timeout waiting for SCL high\n"); break; } } @@ -667,7 +658,7 @@ static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num) */ ret = i2c_pxa_wait_bus_not_busy(i2c); if (ret) { - printk(KERN_INFO "i2c_pxa: timeout waiting for bus free\n"); + dev_err(&i2c->adap.dev, "i2c_pxa: timeout waiting for bus free\n"); goto out; } @@ -676,7 +667,7 @@ static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num) */ ret = i2c_pxa_set_master(i2c); if (ret) { - printk(KERN_INFO "i2c_pxa_set_master: error %d\n", ret); + dev_err(&i2c->adap.dev, "i2c_pxa_set_master: error %d\n", ret); goto out; } @@ -864,8 +855,8 @@ static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id, struct pt_regs *r u32 isr = ISR; if (i2c_debug > 2 && 0) { - printk(DBGLVL "i2c_pxa_handler: ISR=%08x, ICR=%08x, IBMR=%02x\n", - isr, ICR, IBMR); + dev_dbg(&i2c->adap.dev, "%s: ISR=%08x, ICR=%08x, IBMR=%02x\n", + __func__, isr, ICR, IBMR); decode_ISR(isr); } @@ -913,7 +904,7 @@ static int i2c_pxa_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num goto out; if (i2c_debug) - printk(KERN_INFO "Retrying transmission\n"); + dev_dbg(&adap->dev, "Retrying transmission\n"); udelay(100); } i2c_pxa_scream_blue_murder(i2c, "exhausted retries"); -- cgit v0.10.2 From bbf1813fb8ff9d21171bf22e6d1f0e0393601e86 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 21:09:06 +0100 Subject: NTFS: Fix cluster (de)allocators to work when the runlist is NULL and more importantly to take a locked runlist rather than them locking it which leads to lock reversal. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index b0cc43b..beed90c 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -70,6 +70,9 @@ ToDo/Notes: - Add BUG() checks to ntfs_attr_make_non_resident() and ntfs_attr_set() to ensure that these functions are never called for compressed or encrypted attributes. + - Fix cluster (de)allocators to work when the runlist is NULL and more + importantly to take a locked runlist rather than them locking it + which leads to lock reversal. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/lcnalloc.c b/fs/ntfs/lcnalloc.c index a4bc076..7b59342 100644 --- a/fs/ntfs/lcnalloc.c +++ b/fs/ntfs/lcnalloc.c @@ -54,6 +54,8 @@ int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, int ret = 0; ntfs_debug("Entering."); + if (!rl) + return 0; for (; rl->length; rl++) { int err; @@ -163,17 +165,9 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn, BUG_ON(zone < FIRST_ZONE); BUG_ON(zone > LAST_ZONE); - /* Return empty runlist if @count == 0 */ - // FIXME: Do we want to just return NULL instead? (AIA) - if (!count) { - rl = ntfs_malloc_nofs(PAGE_SIZE); - if (!rl) - return ERR_PTR(-ENOMEM); - rl[0].vcn = start_vcn; - rl[0].lcn = LCN_RL_NOT_MAPPED; - rl[0].length = 0; - return rl; - } + /* Return NULL if @count is zero. */ + if (!count) + return NULL; /* Take the lcnbmp lock for writing. */ down_write(&vol->lcnbmp_lock); /* @@ -788,7 +782,8 @@ out: * @vi: vfs inode whose runlist describes the clusters to free * @start_vcn: vcn in the runlist of @vi at which to start freeing clusters * @count: number of clusters to free or -1 for all clusters - * @is_rollback: if TRUE this is a rollback operation + * @write_locked: true if the runlist is locked for writing + * @is_rollback: true if this is a rollback operation * * Free @count clusters starting at the cluster @start_vcn in the runlist * described by the vfs inode @vi. @@ -806,17 +801,17 @@ out: * Return the number of deallocated clusters (not counting sparse ones) on * success and -errno on error. * - * Locking: - The runlist described by @vi must be unlocked on entry and is - * unlocked on return. - * - This function takes the runlist lock of @vi for reading and - * sometimes for writing and sometimes modifies the runlist. + * Locking: - The runlist described by @vi must be locked on entry and is + * locked on return. Note if the runlist is locked for reading the + * lock may be dropped and reacquired. Note the runlist may be + * modified when needed runlist fragments need to be mapped. * - The volume lcn bitmap must be unlocked on entry and is unlocked * on return. * - This function takes the volume lcn bitmap lock for writing and * modifies the bitmap contents. */ s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn, s64 count, - const BOOL is_rollback) + const BOOL write_locked, const BOOL is_rollback) { s64 delta, to_free, total_freed, real_freed; ntfs_inode *ni; @@ -848,8 +843,7 @@ s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn, s64 count, total_freed = real_freed = 0; - down_read(&ni->runlist.lock); - rl = ntfs_attr_find_vcn_nolock(ni, start_vcn, FALSE); + rl = ntfs_attr_find_vcn_nolock(ni, start_vcn, write_locked); if (IS_ERR(rl)) { if (!is_rollback) ntfs_error(vol->sb, "Failed to find first runlist " @@ -903,7 +897,7 @@ s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn, s64 count, /* Attempt to map runlist. */ vcn = rl->vcn; - rl = ntfs_attr_find_vcn_nolock(ni, vcn, FALSE); + rl = ntfs_attr_find_vcn_nolock(ni, vcn, write_locked); if (IS_ERR(rl)) { err = PTR_ERR(rl); if (!is_rollback) @@ -950,7 +944,6 @@ s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn, s64 count, /* Update the total done clusters. */ total_freed += to_free; } - up_read(&ni->runlist.lock); if (likely(!is_rollback)) up_write(&vol->lcnbmp_lock); @@ -960,7 +953,6 @@ s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn, s64 count, ntfs_debug("Done."); return real_freed; err_out: - up_read(&ni->runlist.lock); if (is_rollback) return err; /* If no real clusters were freed, no need to rollback. */ @@ -973,7 +965,8 @@ err_out: * If rollback fails, set the volume errors flag, emit an error * message, and return the error code. */ - delta = __ntfs_cluster_free(vi, start_vcn, total_freed, TRUE); + delta = __ntfs_cluster_free(vi, start_vcn, total_freed, write_locked, + TRUE); if (delta < 0) { ntfs_error(vol->sb, "Failed to rollback (error %i). Leaving " "inconsistent metadata! Unmount and run " diff --git a/fs/ntfs/lcnalloc.h b/fs/ntfs/lcnalloc.h index 4cac1c0..e4d7fb9 100644 --- a/fs/ntfs/lcnalloc.h +++ b/fs/ntfs/lcnalloc.h @@ -43,13 +43,14 @@ extern runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const NTFS_CLUSTER_ALLOCATION_ZONES zone); extern s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn, - s64 count, const BOOL is_rollback); + s64 count, const BOOL write_locked, const BOOL is_rollback); /** * ntfs_cluster_free - free clusters on an ntfs volume * @vi: vfs inode whose runlist describes the clusters to free * @start_vcn: vcn in the runlist of @vi at which to start freeing clusters * @count: number of clusters to free or -1 for all clusters + * @write_locked: true if the runlist is locked for writing * * Free @count clusters starting at the cluster @start_vcn in the runlist * described by the vfs inode @vi. @@ -64,19 +65,19 @@ extern s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn, * Return the number of deallocated clusters (not counting sparse ones) on * success and -errno on error. * - * Locking: - The runlist described by @vi must be unlocked on entry and is - * unlocked on return. - * - This function takes the runlist lock of @vi for reading and - * sometimes for writing and sometimes modifies the runlist. + * Locking: - The runlist described by @vi must be locked on entry and is + * locked on return. Note if the runlist is locked for reading the + * lock may be dropped and reacquired. Note the runlist may be + * modified when needed runlist fragments need to be mapped. * - The volume lcn bitmap must be unlocked on entry and is unlocked * on return. * - This function takes the volume lcn bitmap lock for writing and * modifies the bitmap contents. */ static inline s64 ntfs_cluster_free(struct inode *vi, const VCN start_vcn, - s64 count) + s64 count, const BOOL write_locked) { - return __ntfs_cluster_free(vi, start_vcn, count, FALSE); + return __ntfs_cluster_free(vi, start_vcn, count, write_locked, FALSE); } extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, @@ -93,8 +94,10 @@ extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, * * Return 0 on success and -errno on error. * - * Locking: This function takes the volume lcn bitmap lock for writing and - * modifies the bitmap contents. + * Locking: - This function takes the volume lcn bitmap lock for writing and + * modifies the bitmap contents. + * - The caller must have locked the runlist @rl for reading or + * writing. */ static inline int ntfs_cluster_free_from_rl(ntfs_volume *vol, const runlist_element *rl) diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index e27651d..2c32b84 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c @@ -1953,7 +1953,7 @@ restore_undo_alloc: a = ctx->attr; a->data.non_resident.highest_vcn = cpu_to_sle64(old_last_vcn - 1); undo_alloc: - if (ntfs_cluster_free(vol->mft_ino, old_last_vcn, -1) < 0) { + if (ntfs_cluster_free(vol->mft_ino, old_last_vcn, -1, TRUE) < 0) { ntfs_error(vol->sb, "Failed to free clusters from mft data " "attribute.%s", es); NVolSetErrors(vol); -- cgit v0.10.2 From 1c7d469d47668f4664b892a6cd1c452a0c02d710 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 21:15:09 +0100 Subject: NTFS: Truncate {a,c,m}time to the ntfs supported time granularity when updating the times in the inode in ntfs_setattr(). Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index beed90c..9c5af9c 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -73,6 +73,8 @@ ToDo/Notes: - Fix cluster (de)allocators to work when the runlist is NULL and more importantly to take a locked runlist rather than them locking it which leads to lock reversal. + - Truncate {a,c,m}time to the ntfs supported time granularity when + updating the times in the inode in ntfs_setattr(). 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 886214a..89d844f 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -2430,16 +2430,18 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr) * We skipped the truncate but must still update * timestamps. */ - ia_valid |= ATTR_MTIME|ATTR_CTIME; + ia_valid |= ATTR_MTIME | ATTR_CTIME; } } - if (ia_valid & ATTR_ATIME) - vi->i_atime = attr->ia_atime; + vi->i_atime = timespec_trunc(attr->ia_atime, + vi->i_sb->s_time_gran); if (ia_valid & ATTR_MTIME) - vi->i_mtime = attr->ia_mtime; + vi->i_mtime = timespec_trunc(attr->ia_mtime, + vi->i_sb->s_time_gran); if (ia_valid & ATTR_CTIME) - vi->i_ctime = attr->ia_ctime; + vi->i_ctime = timespec_trunc(attr->ia_ctime, + vi->i_sb->s_time_gran); mark_inode_dirty(vi); out: return err; -- cgit v0.10.2 From c921e4c4dbb043f9435414c4e661e7f0a783053d Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Thu, 8 Sep 2005 13:15:32 -0700 Subject: [BNX2]: Fix bug in irq handler and add prefetch Fix bug in bnx2_interrupt() that caused an unnecessary register read. The BNX2_PCICFG_MISC_STATUS should only be read when the status tag has not changed. Add prefetch of the status block in bnx2_msi() similar to tg3_msi(). The status block is not touched in bnx2_msi() and prefetching it will speed up bnx2_poll() that will run on the same CPU that received the MSI. Update version. Signed-off-by: Michael Chan Signed-off-by: David S. Miller diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 55a72c7..83598e3 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c @@ -14,8 +14,8 @@ #define DRV_MODULE_NAME "bnx2" #define PFX DRV_MODULE_NAME ": " -#define DRV_MODULE_VERSION "1.2.20" -#define DRV_MODULE_RELDATE "August 22, 2005" +#define DRV_MODULE_VERSION "1.2.21" +#define DRV_MODULE_RELDATE "September 7, 2005" #define RUN_AT(x) (jiffies + (x)) @@ -1533,6 +1533,7 @@ bnx2_msi(int irq, void *dev_instance, struct pt_regs *regs) struct net_device *dev = dev_instance; struct bnx2 *bp = dev->priv; + prefetch(bp->status_blk); REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, BNX2_PCICFG_INT_ACK_CMD_USE_INT_HC_PARAM | BNX2_PCICFG_INT_ACK_CMD_MASK_INT); @@ -1558,7 +1559,7 @@ bnx2_interrupt(int irq, void *dev_instance, struct pt_regs *regs) * When using MSI, the MSI message will always complete after * the status block write. */ - if ((bp->status_blk->status_idx == bp->last_status_idx) || + if ((bp->status_blk->status_idx == bp->last_status_idx) && (REG_RD(bp, BNX2_PCICFG_MISC_STATUS) & BNX2_PCICFG_MISC_STATUS_INTA_VALUE)) return IRQ_NONE; diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h index 9ad3f57..62857b6 100644 --- a/drivers/net/bnx2.h +++ b/drivers/net/bnx2.h @@ -50,6 +50,7 @@ #endif #include #include +#include /* Hardware data structures and register definitions automatically * generated from RTL code. Do not modify. -- cgit v0.10.2 From 67bb103725e4cde322cb4ddb160a12933c5c7072 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 21:19:45 +0100 Subject: NTFS: Fixup handling of sparse, compressed, and encrypted attributes in fs/ntfs/inode.c::ntfs_read_locked_{,attr_,index_}inode(). Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 9c5af9c..ed8d001 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -75,6 +75,8 @@ ToDo/Notes: which leads to lock reversal. - Truncate {a,c,m}time to the ntfs supported time granularity when updating the times in the inode in ntfs_setattr(). + - Fixup handling of sparse, compressed, and encrypted attributes in + fs/ntfs/inode.c::ntfs_read_locked_{,attr_,index_}inode(). 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 89d844f..dc4bbe3 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -1013,41 +1013,50 @@ skip_large_dir_stuff: } a = ctx->attr; /* Setup the state. */ - if (a->non_resident) { - NInoSetNonResident(ni); - if (a->flags & (ATTR_COMPRESSION_MASK | - ATTR_IS_SPARSE)) { - if (a->flags & ATTR_COMPRESSION_MASK) { - NInoSetCompressed(ni); - if (vol->cluster_size > 4096) { - ntfs_error(vi->i_sb, "Found " + if (a->flags & (ATTR_COMPRESSION_MASK | ATTR_IS_SPARSE)) { + if (a->flags & ATTR_COMPRESSION_MASK) { + NInoSetCompressed(ni); + if (vol->cluster_size > 4096) { + ntfs_error(vi->i_sb, "Found " "compressed data but " "compression is " "disabled due to " "cluster size (%i) > " "4kiB.", vol->cluster_size); - goto unm_err_out; - } - if ((a->flags & ATTR_COMPRESSION_MASK) - != ATTR_IS_COMPRESSED) { - ntfs_error(vi->i_sb, "Found " - "unknown compression " - "method or corrupt " - "file."); - goto unm_err_out; - } + goto unm_err_out; + } + if ((a->flags & ATTR_COMPRESSION_MASK) + != ATTR_IS_COMPRESSED) { + ntfs_error(vi->i_sb, "Found unknown " + "compression method " + "or corrupt file."); + goto unm_err_out; } - if (a->flags & ATTR_IS_SPARSE) - NInoSetSparse(ni); + } + if (a->flags & ATTR_IS_SPARSE) + NInoSetSparse(ni); + } + if (a->flags & ATTR_IS_ENCRYPTED) { + if (NInoCompressed(ni)) { + ntfs_error(vi->i_sb, "Found encrypted and " + "compressed data."); + goto unm_err_out; + } + NInoSetEncrypted(ni); + } + if (a->non_resident) { + NInoSetNonResident(ni); + if (NInoCompressed(ni) || NInoSparse(ni)) { if (a->data.non_resident.compression_unit != 4) { ntfs_error(vi->i_sb, "Found " - "nonstandard compression unit " - "(%u instead of 4). Cannot " - "handle this.", - a->data.non_resident. - compression_unit); + "nonstandard " + "compression unit (%u " + "instead of 4). " + "Cannot handle this.", + a->data.non_resident. + compression_unit); err = -EOPNOTSUPP; goto unm_err_out; } @@ -1065,14 +1074,6 @@ skip_large_dir_stuff: a->data.non_resident. compressed_size); } - if (a->flags & ATTR_IS_ENCRYPTED) { - if (a->flags & ATTR_COMPRESSION_MASK) { - ntfs_error(vi->i_sb, "Found encrypted " - "and compressed data."); - goto unm_err_out; - } - NInoSetEncrypted(ni); - } if (a->data.non_resident.lowest_vcn) { ntfs_error(vi->i_sb, "First extent of $DATA " "attribute has non zero " @@ -1212,6 +1213,75 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi) if (unlikely(err)) goto unm_err_out; a = ctx->attr; + if (a->flags & (ATTR_COMPRESSION_MASK | ATTR_IS_SPARSE)) { + if (a->flags & ATTR_COMPRESSION_MASK) { + NInoSetCompressed(ni); + if ((ni->type != AT_DATA) || (ni->type == AT_DATA && + ni->name_len)) { + ntfs_error(vi->i_sb, "Found compressed " + "non-data or named data " + "attribute. Please report " + "you saw this message to " + "linux-ntfs-dev@lists." + "sourceforge.net"); + goto unm_err_out; + } + if (vol->cluster_size > 4096) { + ntfs_error(vi->i_sb, "Found compressed " + "attribute but compression is " + "disabled due to cluster size " + "(%i) > 4kiB.", + vol->cluster_size); + goto unm_err_out; + } + if ((a->flags & ATTR_COMPRESSION_MASK) != + ATTR_IS_COMPRESSED) { + ntfs_error(vi->i_sb, "Found unknown " + "compression method."); + goto unm_err_out; + } + } + /* + * The encryption flag set in an index root just means to + * compress all files. + */ + if (NInoMstProtected(ni) && ni->type != AT_INDEX_ROOT) { + ntfs_error(vi->i_sb, "Found mst protected attribute " + "but the attribute is %s. Please " + "report you saw this message to " + "linux-ntfs-dev@lists.sourceforge.net", + NInoCompressed(ni) ? "compressed" : + "sparse"); + goto unm_err_out; + } + if (a->flags & ATTR_IS_SPARSE) + NInoSetSparse(ni); + } + if (a->flags & ATTR_IS_ENCRYPTED) { + if (NInoCompressed(ni)) { + ntfs_error(vi->i_sb, "Found encrypted and compressed " + "data."); + goto unm_err_out; + } + /* + * The encryption flag set in an index root just means to + * encrypt all files. + */ + if (NInoMstProtected(ni) && ni->type != AT_INDEX_ROOT) { + ntfs_error(vi->i_sb, "Found mst protected attribute " + "but the attribute is encrypted. " + "Please report you saw this message " + "to linux-ntfs-dev@lists.sourceforge." + "net"); + goto unm_err_out; + } + if (ni->type != AT_DATA) { + ntfs_error(vi->i_sb, "Found encrypted non-data " + "attribute."); + goto unm_err_out; + } + NInoSetEncrypted(ni); + } if (!a->non_resident) { /* Ensure the attribute name is placed before the value. */ if (unlikely(a->name_length && (le16_to_cpu(a->name_offset) >= @@ -1220,11 +1290,10 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi) "the attribute value."); goto unm_err_out; } - if (NInoMstProtected(ni) || a->flags) { + if (NInoMstProtected(ni)) { ntfs_error(vi->i_sb, "Found mst protected attribute " - "or attribute with non-zero flags but " - "the attribute is resident. Please " - "report you saw this message to " + "but the attribute is resident. " + "Please report you saw this message to " "linux-ntfs-dev@lists.sourceforge.net"); goto unm_err_out; } @@ -1250,50 +1319,8 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi) "the mapping pairs array."); goto unm_err_out; } - if (a->flags & (ATTR_COMPRESSION_MASK | ATTR_IS_SPARSE)) { - if (a->flags & ATTR_COMPRESSION_MASK) { - NInoSetCompressed(ni); - if ((ni->type != AT_DATA) || (ni->type == - AT_DATA && ni->name_len)) { - ntfs_error(vi->i_sb, "Found compressed " - "non-data or named " - "data attribute. " - "Please report you " - "saw this message to " - "linux-ntfs-dev@lists." - "sourceforge.net"); - goto unm_err_out; - } - if (vol->cluster_size > 4096) { - ntfs_error(vi->i_sb, "Found compressed " - "attribute but " - "compression is " - "disabled due to " - "cluster size (%i) > " - "4kiB.", - vol->cluster_size); - goto unm_err_out; - } - if ((a->flags & ATTR_COMPRESSION_MASK) != - ATTR_IS_COMPRESSED) { - ntfs_error(vi->i_sb, "Found unknown " - "compression method."); - goto unm_err_out; - } - } - if (NInoMstProtected(ni)) { - ntfs_error(vi->i_sb, "Found mst protected " - "attribute but the attribute " - "is %s. Please report you " - "saw this message to " - "linux-ntfs-dev@lists." - "sourceforge.net", - NInoCompressed(ni) ? - "compressed" : "sparse"); - goto unm_err_out; - } - if (a->flags & ATTR_IS_SPARSE) - NInoSetSparse(ni); + if ((NInoCompressed(ni) || NInoSparse(ni)) && + ni->type != AT_INDEX_ROOT) { if (a->data.non_resident.compression_unit != 4) { ntfs_error(vi->i_sb, "Found nonstandard " "compression unit (%u instead " @@ -1313,23 +1340,6 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi) ni->itype.compressed.size = sle64_to_cpu( a->data.non_resident.compressed_size); } - if (a->flags & ATTR_IS_ENCRYPTED) { - if (a->flags & ATTR_COMPRESSION_MASK) { - ntfs_error(vi->i_sb, "Found encrypted and " - "compressed data."); - goto unm_err_out; - } - if (NInoMstProtected(ni)) { - ntfs_error(vi->i_sb, "Found mst protected " - "attribute but the attribute " - "is encrypted. Please report " - "you saw this message to " - "linux-ntfs-dev@lists." - "sourceforge.net"); - goto unm_err_out; - } - NInoSetEncrypted(ni); - } if (a->data.non_resident.lowest_vcn) { ntfs_error(vi->i_sb, "First extent of attribute has " "non-zero lowest_vcn."); @@ -1348,12 +1358,12 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi) vi->i_mapping->a_ops = &ntfs_mst_aops; else vi->i_mapping->a_ops = &ntfs_aops; - if (NInoCompressed(ni) || NInoSparse(ni)) + if ((NInoCompressed(ni) || NInoSparse(ni)) && ni->type != AT_INDEX_ROOT) vi->i_blocks = ni->itype.compressed.size >> 9; else vi->i_blocks = ni->allocated_size >> 9; /* - * Make sure the base inode doesn't go away and attach it to the + * Make sure the base inode does not go away and attach it to the * attribute inode. */ igrab(base_vi); @@ -1480,7 +1490,10 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi) "after the attribute value."); goto unm_err_out; } - /* Compressed/encrypted/sparse index root is not allowed. */ + /* + * Compressed/encrypted/sparse index root is not allowed, except for + * directories of course but those are not dealt with here. + */ if (a->flags & (ATTR_COMPRESSION_MASK | ATTR_IS_ENCRYPTED | ATTR_IS_SPARSE)) { ntfs_error(vi->i_sb, "Found compressed/encrypted/sparse index " -- cgit v0.10.2 From 8dcdebafb848415eae25924b00c4f0b9ec907da0 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 21:25:48 +0100 Subject: NTFS: Make ntfs_write_block() not instantiate sparse blocks if they are zero. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index ed8d001..b176664 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -77,6 +77,8 @@ ToDo/Notes: updating the times in the inode in ntfs_setattr(). - Fixup handling of sparse, compressed, and encrypted attributes in fs/ntfs/inode.c::ntfs_read_locked_{,attr_,index_}inode(). + - Make ntfs_write_block() not instantiate sparse blocks if they contain + only zeroes. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 78adad7..f3ad36d 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -670,6 +670,27 @@ lock_retry_remap: } /* It is a hole, need to instantiate it. */ if (lcn == LCN_HOLE) { + u8 *kaddr; + unsigned long *bpos, *bend; + + /* Check if the buffer is zero. */ + kaddr = kmap_atomic(page, KM_USER0); + bpos = (unsigned long *)(kaddr + bh_offset(bh)); + bend = (unsigned long *)((u8*)bpos + blocksize); + do { + if (unlikely(*bpos)) + break; + } while (likely(++bpos < bend)); + kunmap_atomic(kaddr, KM_USER0); + if (bpos == bend) { + /* + * Buffer is zero and sparse, no need to write + * it. + */ + bh->b_blocknr = -1; + clear_buffer_dirty(bh); + continue; + } // TODO: Instantiate the hole. // clear_buffer_new(bh); // unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr); -- cgit v0.10.2 From ce723d8e048ef98ea64d12379e3921c933f5b3e0 Mon Sep 17 00:00:00 2001 From: Julian Anastasov Date: Thu, 8 Sep 2005 13:34:47 -0700 Subject: [IPV4]: Fix refcount damaging in net/ipv4/route.c One such place that can damage the dst refcnts is route.c with CONFIG_IP_ROUTE_MULTIPATH_CACHED enabled, i don't see the user's .config. In this new code i see that rt_intern_hash is called before dst->refcnt is set to 1, dst is the 2nd arg to rt_intern_hash. Arg 2 of rt_intern_hash must come with refcnt 1 as it is added to table or dropped depending on error/add/update. One such example is ip_mkroute_input where __mkroute_input return rth with refcnt 0 which is provided to rt_intern_hash. ip_mkroute_output looks like a 2nd such place. Appending untested patch for comments and review. The idea is to put previous reference as we are going to return next result/error. Signed-off-by: Julian Anastasov Signed-off-by: David S. Miller diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 8c0b14e..8549f26 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1760,6 +1760,7 @@ static inline int __mkroute_input(struct sk_buff *skb, goto cleanup; } + atomic_set(&rth->u.dst.__refcnt, 1); rth->u.dst.flags= DST_HOST; #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED if (res->fi->fib_nhs > 1) @@ -1820,7 +1821,6 @@ static inline int ip_mkroute_input_def(struct sk_buff *skb, err = __mkroute_input(skb, res, in_dev, daddr, saddr, tos, &rth); if (err) return err; - atomic_set(&rth->u.dst.__refcnt, 1); /* put it into the cache */ hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5), tos); @@ -1834,8 +1834,8 @@ static inline int ip_mkroute_input(struct sk_buff *skb, u32 daddr, u32 saddr, u32 tos) { #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED - struct rtable* rth = NULL; - unsigned char hop, hopcount, lasthop; + struct rtable* rth = NULL, *rtres; + unsigned char hop, hopcount; int err = -EINVAL; unsigned int hash; @@ -1844,8 +1844,6 @@ static inline int ip_mkroute_input(struct sk_buff *skb, else hopcount = 1; - lasthop = hopcount - 1; - /* distinguish between multipath and singlepath */ if (hopcount < 2) return ip_mkroute_input_def(skb, res, fl, in_dev, daddr, @@ -1855,6 +1853,10 @@ static inline int ip_mkroute_input(struct sk_buff *skb, for (hop = 0; hop < hopcount; hop++) { res->nh_sel = hop; + /* put reference to previous result */ + if (hop) + ip_rt_put(rtres); + /* create a routing cache entry */ err = __mkroute_input(skb, res, in_dev, daddr, saddr, tos, &rth); @@ -1863,7 +1865,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb, /* put it into the cache */ hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5), tos); - err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); + err = rt_intern_hash(hash, rth, &rtres); if (err) return err; @@ -1873,13 +1875,8 @@ static inline int ip_mkroute_input(struct sk_buff *skb, FIB_RES_NETMASK(*res), res->prefixlen, &FIB_RES_NH(*res)); - - /* only for the last hop the reference count is handled - * outside - */ - if (hop == lasthop) - atomic_set(&(skb->dst->__refcnt), 1); } + skb->dst = &rtres->u.dst; return err; #else /* CONFIG_IP_ROUTE_MULTIPATH_CACHED */ return ip_mkroute_input_def(skb, res, fl, in_dev, daddr, saddr, tos); @@ -2208,6 +2205,7 @@ static inline int __mkroute_output(struct rtable **result, goto cleanup; } + atomic_set(&rth->u.dst.__refcnt, 1); rth->u.dst.flags= DST_HOST; #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED if (res->fi) { @@ -2290,8 +2288,6 @@ static inline int ip_mkroute_output_def(struct rtable **rp, if (err == 0) { u32 tos = RT_FL_TOS(oldflp); - atomic_set(&rth->u.dst.__refcnt, 1); - hash = rt_hash_code(oldflp->fl4_dst, oldflp->fl4_src ^ (oldflp->oif << 5), tos); err = rt_intern_hash(hash, rth, rp); @@ -2326,6 +2322,10 @@ static inline int ip_mkroute_output(struct rtable** rp, dev2nexthop = FIB_RES_DEV(*res); dev_hold(dev2nexthop); + /* put reference to previous result */ + if (hop) + ip_rt_put(*rp); + err = __mkroute_output(&rth, res, fl, oldflp, dev2nexthop, flags); @@ -2350,7 +2350,6 @@ static inline int ip_mkroute_output(struct rtable** rp, if (err != 0) return err; } - atomic_set(&(*rp)->u.dst.__refcnt, 1); return err; } else { return ip_mkroute_output_def(rp, res, fl, oldflp, dev_out, -- cgit v0.10.2 From 3a93481589dc80d9ff9082731f35031b0345442e Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 8 Sep 2005 13:36:34 -0700 Subject: [NETFILTER]: ip_conntrack_netbios_ns.c gcc-2.95.x build fix gcc-2.95.x can't do this sort of initialisation Signed-off-by: Andrew Morton Signed-off-by: David S. Miller diff --git a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c index 2b5cf9c..bb72466 100644 --- a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c +++ b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c @@ -104,12 +104,28 @@ out: static struct ip_conntrack_helper helper = { .name = "netbios-ns", .tuple = { - .src.u.udp.port = __constant_htons(137), - .dst.protonum = IPPROTO_UDP, + .src = { + .u = { + .udp = { + .port = __constant_htons(137), + } + } + }, + .dst = { + .protonum = IPPROTO_UDP, + }, }, .mask = { - .src.u.udp.port = 0xFFFF, - .dst.protonum = 0xFF, + .src = { + .u = { + .udp = { + .port = 0xFFFF, + } + } + }, + .dst = { + .protonum = 0xFF, + }, }, .max_expected = 1, .me = THIS_MODULE, -- cgit v0.10.2 From bd45fdd209ca49c5010ac9af469c41ae6dd3f145 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 21:38:05 +0100 Subject: NTFS: Fixup handling of sparse, compressed, and encrypted attributes in fs/ntfs/aops.c::ntfs_writepage(). Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index b176664..4b8666d 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -79,6 +79,8 @@ ToDo/Notes: fs/ntfs/inode.c::ntfs_read_locked_{,attr_,index_}inode(). - Make ntfs_write_block() not instantiate sparse blocks if they contain only zeroes. + - Fixup handling of sparse, compressed, and encrypted attributes in + fs/ntfs/aops.c::ntfs_writepage(). 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index f3ad36d..6f2954a 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -1301,38 +1301,42 @@ retry_writepage: ntfs_debug("Write outside i_size - truncated?"); return 0; } + /* + * Only $DATA attributes can be encrypted and only unnamed $DATA + * attributes can be compressed. Index root can have the flags set but + * this means to create compressed/encrypted files, not that the + * attribute is compressed/encrypted. + */ + if (ni->type != AT_INDEX_ROOT) { + /* If file is encrypted, deny access, just like NT4. */ + if (NInoEncrypted(ni)) { + unlock_page(page); + BUG_ON(ni->type != AT_DATA); + ntfs_debug("Denying write access to encrypted " + "file."); + return -EACCES; + } + /* Compressed data streams are handled in compress.c. */ + if (NInoNonResident(ni) && NInoCompressed(ni)) { + BUG_ON(ni->type != AT_DATA); + BUG_ON(ni->name_len); + // TODO: Implement and replace this with + // return ntfs_write_compressed_block(page); + unlock_page(page); + ntfs_error(vi->i_sb, "Writing to compressed files is " + "not supported yet. Sorry."); + return -EOPNOTSUPP; + } + // TODO: Implement and remove this check. + if (NInoNonResident(ni) && NInoSparse(ni)) { + unlock_page(page); + ntfs_error(vi->i_sb, "Writing to sparse files is not " + "supported yet. Sorry."); + return -EOPNOTSUPP; + } + } /* NInoNonResident() == NInoIndexAllocPresent() */ if (NInoNonResident(ni)) { - /* - * Only unnamed $DATA attributes can be compressed, encrypted, - * and/or sparse. - */ - if (ni->type == AT_DATA && !ni->name_len) { - /* If file is encrypted, deny access, just like NT4. */ - if (NInoEncrypted(ni)) { - unlock_page(page); - ntfs_debug("Denying write access to encrypted " - "file."); - return -EACCES; - } - /* Compressed data streams are handled in compress.c. */ - if (NInoCompressed(ni)) { - // TODO: Implement and replace this check with - // return ntfs_write_compressed_block(page); - unlock_page(page); - ntfs_error(vi->i_sb, "Writing to compressed " - "files is not supported yet. " - "Sorry."); - return -EOPNOTSUPP; - } - // TODO: Implement and remove this check. - if (NInoSparse(ni)) { - unlock_page(page); - ntfs_error(vi->i_sb, "Writing to sparse files " - "is not supported yet. Sorry."); - return -EOPNOTSUPP; - } - } /* We have to zero every time due to mmap-at-end-of-file. */ if (page->index >= (i_size >> PAGE_CACHE_SHIFT)) { /* The page straddles i_size. */ @@ -1345,14 +1349,16 @@ retry_writepage: /* Handle mst protected attributes. */ if (NInoMstProtected(ni)) return ntfs_write_mst_block(page, wbc); - /* Normal data stream. */ + /* Normal, non-resident data stream. */ return ntfs_write_block(page, wbc); } /* - * Attribute is resident, implying it is not compressed, encrypted, - * sparse, or mst protected. This also means the attribute is smaller - * than an mft record and hence smaller than a page, so can simply - * return error on any pages with index above 0. + * Attribute is resident, implying it is not compressed, encrypted, or + * mst protected. This also means the attribute is smaller than an mft + * record and hence smaller than a page, so can simply return error on + * any pages with index above 0. Note the attribute can actually be + * marked compressed but if it is resident the actual data is not + * compressed so we are ok to ignore the compressed flag here. */ BUG_ON(page_has_buffers(page)); BUG_ON(!PageUptodate(page)); @@ -1401,30 +1407,14 @@ retry_writepage: BUG_ON(PageWriteback(page)); set_page_writeback(page); unlock_page(page); - /* - * Here, we don't need to zero the out of bounds area everytime because - * the below memcpy() already takes care of the mmap-at-end-of-file - * requirements. If the file is converted to a non-resident one, then - * the code path use is switched to the non-resident one where the - * zeroing happens on each ntfs_writepage() invocation. - * - * The above also applies nicely when i_size is decreased. - * - * When i_size is increased, the memory between the old and new i_size - * _must_ be zeroed (or overwritten with new data). Otherwise we will - * expose data to userspace/disk which should never have been exposed. - * - * FIXME: Ensure that i_size increases do the zeroing/overwriting and - * if we cannot guarantee that, then enable the zeroing below. If the - * zeroing below is enabled, we MUST move the unlock_page() from above - * to after the kunmap_atomic(), i.e. just before the - * end_page_writeback(). - * UPDATE: ntfs_prepare/commit_write() do the zeroing on i_size - * increases for resident attributes so those are ok. - * TODO: ntfs_truncate(), others? + * Here, we do not need to zero the out of bounds area everytime + * because the below memcpy() already takes care of the + * mmap-at-end-of-file requirements. If the file is converted to a + * non-resident one, then the code path use is switched to the + * non-resident one where the zeroing happens on each ntfs_writepage() + * invocation. */ - attr_len = le32_to_cpu(ctx->attr->data.resident.value_length); i_size = i_size_read(vi); if (unlikely(attr_len > i_size)) { -- cgit v0.10.2 From baed16a7ff5194487764db300c2753ac7409c4c5 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 8 Sep 2005 13:40:41 -0700 Subject: [AX.25]: Make asc2ax() thread-proof Asc2ax was still using a static buffer for all invocations which isn't exactly SMP-safe. Change asc2ax to take an additional result buffer as the argument. Change all callers to provide such a buffer. This one only really is a fix for ROSE and as per recent discussions there's still much more to fix in ROSE ... Signed-off-by: Ralf Baechle DL5RB Signed-off-by: David S. Miller diff --git a/include/net/ax25.h b/include/net/ax25.h index 364b046..227d337 100644 --- a/include/net/ax25.h +++ b/include/net/ax25.h @@ -258,7 +258,7 @@ extern struct sock *ax25_make_new(struct sock *, struct ax25_dev *); /* ax25_addr.c */ extern ax25_address null_ax25_address; extern char *ax2asc(char *buf, ax25_address *); -extern ax25_address *asc2ax(char *); +extern void asc2ax(ax25_address *addr, char *callsign); extern int ax25cmp(ax25_address *, ax25_address *); extern int ax25digicmp(ax25_digi *, ax25_digi *); extern unsigned char *ax25_addr_parse(unsigned char *, int, ax25_address *, ax25_address *, ax25_digi *, int *, int *); diff --git a/net/ax25/ax25_addr.c b/net/ax25/ax25_addr.c index dca179d..0164a15 100644 --- a/net/ax25/ax25_addr.c +++ b/net/ax25/ax25_addr.c @@ -67,37 +67,34 @@ char *ax2asc(char *buf, ax25_address *a) /* * ascii -> ax25 conversion */ -ax25_address *asc2ax(char *callsign) +void asc2ax(ax25_address *addr, char *callsign) { - static ax25_address addr; char *s; int n; for (s = callsign, n = 0; n < 6; n++) { if (*s != '\0' && *s != '-') - addr.ax25_call[n] = *s++; + addr->ax25_call[n] = *s++; else - addr.ax25_call[n] = ' '; - addr.ax25_call[n] <<= 1; - addr.ax25_call[n] &= 0xFE; + addr->ax25_call[n] = ' '; + addr->ax25_call[n] <<= 1; + addr->ax25_call[n] &= 0xFE; } if (*s++ == '\0') { - addr.ax25_call[6] = 0x00; - return &addr; + addr->ax25_call[6] = 0x00; + return; } - addr.ax25_call[6] = *s++ - '0'; + addr->ax25_call[6] = *s++ - '0'; if (*s != '\0') { - addr.ax25_call[6] *= 10; - addr.ax25_call[6] += *s++ - '0'; + addr->ax25_call[6] *= 10; + addr->ax25_call[6] += *s++ - '0'; } - addr.ax25_call[6] <<= 1; - addr.ax25_call[6] &= 0x1E; - - return &addr; + addr->ax25_call[6] <<= 1; + addr->ax25_call[6] &= 0x1E; } /* diff --git a/net/rose/rose_subr.c b/net/rose/rose_subr.c index 02891ce..36a7794 100644 --- a/net/rose/rose_subr.c +++ b/net/rose/rose_subr.c @@ -337,13 +337,13 @@ static int rose_parse_ccitt(unsigned char *p, struct rose_facilities_struct *fac memcpy(&facilities->source_addr, p + 7, ROSE_ADDR_LEN); memcpy(callsign, p + 12, l - 10); callsign[l - 10] = '\0'; - facilities->source_call = *asc2ax(callsign); + asc2ax(&facilities->source_call, callsign); } if (*p == FAC_CCITT_SRC_NSAP) { memcpy(&facilities->dest_addr, p + 7, ROSE_ADDR_LEN); memcpy(callsign, p + 12, l - 10); callsign[l - 10] = '\0'; - facilities->dest_call = *asc2ax(callsign); + asc2ax(&facilities->dest_call, callsign); } p += l + 2; n += l + 2; -- cgit v0.10.2 From 54b02eb01c0172294e43e2b54d6815f65637c111 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 21:43:47 +0100 Subject: NTFS: Optimize fs/ntfs/aops.c::ntfs_write_block() by extending the page lock protection over the buffer submission for i/o which allows the removal of the get_bh()/put_bh() pairs for each buffer. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 4b8666d..10fc238 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -81,6 +81,9 @@ ToDo/Notes: only zeroes. - Fixup handling of sparse, compressed, and encrypted attributes in fs/ntfs/aops.c::ntfs_writepage(). + - Optimize fs/ntfs/aops.c::ntfs_write_block() by extending the page + lock protection over the buffer submission for i/o which allows the + removal of the get_bh()/put_bh() pairs for each buffer. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 6f2954a..821dad7 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -735,7 +735,7 @@ lock_retry_remap: /* For the error case, need to reset bh to the beginning. */ bh = head; - /* Just an optimization, so ->readpage() isn't called later. */ + /* Just an optimization, so ->readpage() is not called later. */ if (unlikely(!PageUptodate(page))) { int uptodate = 1; do { @@ -751,7 +751,6 @@ lock_retry_remap: /* Setup all mapped, dirty buffers for async write i/o. */ do { - get_bh(bh); if (buffer_mapped(bh) && buffer_dirty(bh)) { lock_buffer(bh); if (test_clear_buffer_dirty(bh)) { @@ -789,14 +788,8 @@ lock_retry_remap: BUG_ON(PageWriteback(page)); set_page_writeback(page); /* Keeps try_to_free_buffers() away. */ - unlock_page(page); - /* - * Submit the prepared buffers for i/o. Note the page is unlocked, - * and the async write i/o completion handler can end_page_writeback() - * at any time after the *first* submit_bh(). So the buffers can then - * disappear... - */ + /* Submit the prepared buffers for i/o. */ need_end_writeback = TRUE; do { struct buffer_head *next = bh->b_this_page; @@ -804,9 +797,9 @@ lock_retry_remap: submit_bh(WRITE, bh); need_end_writeback = FALSE; } - put_bh(bh); bh = next; } while (bh != head); + unlock_page(page); /* If no i/o was started, need to end_page_writeback(). */ if (unlikely(need_end_writeback)) -- cgit v0.10.2 From 45ac56ca6403b83ad880083be164c425f4b50882 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Thu, 8 Sep 2005 16:44:33 -0400 Subject: Kconfig: IEEE80211 should not depend on NET_RADIO We should not restrict use of ieee80211 to only when wireless drivers are enabled. In-development and out-of-tree drivers may wish to use it, and by removing this restriction we eliminate a circular dependency. diff --git a/net/ieee80211/Kconfig b/net/ieee80211/Kconfig index 58ed431..91b16fb 100644 --- a/net/ieee80211/Kconfig +++ b/net/ieee80211/Kconfig @@ -1,6 +1,5 @@ config IEEE80211 tristate "Generic IEEE 802.11 Networking Stack" - select NET_RADIO ---help--- This option enables the hardware independent IEEE 802.11 networking stack. -- cgit v0.10.2 From 087f902686beb6c02157c271e3fc95606dbdfdbf Mon Sep 17 00:00:00 2001 From: Martin Hicks Date: Thu, 8 Sep 2005 11:28:11 -0400 Subject: [IA64] defconfig: turn off QLOGIC_FC Turn off the QLOGIC_FC driver. Supposedly qla2xxx should support these devices. Do any ia64 machines have one of these devices as the boot device? Signed-off-by: Martin Hicks Signed-off-by: Tony Luck diff --git a/arch/ia64/defconfig b/arch/ia64/defconfig index e3a907b..2aa32f0 100644 --- a/arch/ia64/defconfig +++ b/arch/ia64/defconfig @@ -340,7 +340,7 @@ CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 # CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set # CONFIG_SCSI_IPR is not set -CONFIG_SCSI_QLOGIC_FC=y +# CONFIG_SCSI_QLOGIC_FC is not set # CONFIG_SCSI_QLOGIC_FC_FIRMWARE is not set CONFIG_SCSI_QLOGIC_1280=y # CONFIG_SCSI_QLOGIC_1280_1040 is not set -- cgit v0.10.2 From 408865ce4829376120489ac8011b72125453dcff Mon Sep 17 00:00:00 2001 From: Dean Nelson Date: Thu, 8 Sep 2005 10:46:58 -0500 Subject: [IA64] ensure XPC and XPNET are loaded on sn2 platforms only These are SN2 only drivers. They should have platform checks to prevent them from doing evil stuff in GENERIC kernels. Signed-off-by: Martin Hicks Acked-by: Dean Nelson Signed-off-by: Tony Luck diff --git a/arch/ia64/sn/kernel/xpc_main.c b/arch/ia64/sn/kernel/xpc_main.c index bb1d5cf..ed7c215 100644 --- a/arch/ia64/sn/kernel/xpc_main.c +++ b/arch/ia64/sn/kernel/xpc_main.c @@ -885,6 +885,10 @@ xpc_init(void) pid_t pid; + if (!ia64_platform_is("sn2")) { + return -ENODEV; + } + /* * xpc_remote_copy_buffer is used as a temporary buffer for bte_copy'ng * both a partition's reserved page and its XPC variables. Its size was diff --git a/arch/ia64/sn/kernel/xpnet.c b/arch/ia64/sn/kernel/xpnet.c index 78c13d6..d0c2c11 100644 --- a/arch/ia64/sn/kernel/xpnet.c +++ b/arch/ia64/sn/kernel/xpnet.c @@ -636,6 +636,10 @@ xpnet_init(void) int result = -ENOMEM; + if (!ia64_platform_is("sn2")) { + return -ENODEV; + } + dev_info(xpnet, "registering network device %s\n", XPNET_DEVICE_NAME); /* -- cgit v0.10.2 From 9b17e7e74e767d8a494a74c3c459aeecd1e08c5f Mon Sep 17 00:00:00 2001 From: Jack Steiner Date: Thu, 8 Sep 2005 15:28:28 -0500 Subject: [IA64] Increase max physical address for SN platforms Increase the value for the maximum physical address on SN systems. Signed-off-by: Jack Steiner Signed-off-by: Tony Luck diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c index a594aca..14908ad 100644 --- a/arch/ia64/sn/kernel/setup.c +++ b/arch/ia64/sn/kernel/setup.c @@ -56,7 +56,7 @@ DEFINE_PER_CPU(struct pda_s, pda_percpu); -#define MAX_PHYS_MEMORY (1UL << 49) /* 1 TB */ +#define MAX_PHYS_MEMORY (1UL << IA64_MAX_PHYS_BITS) /* Max physical address supported */ lboard_t *root_lboard[MAX_COMPACT_NODES]; -- cgit v0.10.2 From 8273d5d4c28a9fde68f830cc6ff61e37e8ae1dca Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 22:00:33 +0100 Subject: NTFS: Fix fs/ntfs/aops.c::ntfs_{read,write}_block() to handle the case where a concurrent truncate has truncated the runlist under our feet. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 10fc238..7f24cb1 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -84,6 +84,8 @@ ToDo/Notes: - Optimize fs/ntfs/aops.c::ntfs_write_block() by extending the page lock protection over the buffer submission for i/o which allows the removal of the get_bh()/put_bh() pairs for each buffer. + - Fix fs/ntfs/aops.c::ntfs_{read,write}_block() to handle the case + where a concurrent truncate has truncated the runlist under our feet. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 821dad7..59389a8 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -204,6 +204,7 @@ static int ntfs_read_block(struct page *page) nr = i = 0; do { u8 *kaddr; + int err; if (unlikely(buffer_uptodate(bh))) continue; @@ -211,6 +212,7 @@ static int ntfs_read_block(struct page *page) arr[nr++] = bh; continue; } + err = 0; bh->b_bdev = vol->sb->s_bdev; /* Is the block within the allowed limits? */ if (iblock < lblock) { @@ -252,7 +254,6 @@ lock_retry_remap: goto handle_hole; /* If first try and runlist unmapped, map and retry. */ if (!is_retry && lcn == LCN_RL_NOT_MAPPED) { - int err; is_retry = TRUE; /* * Attempt to map runlist, dropping lock for @@ -263,20 +264,30 @@ lock_retry_remap: if (likely(!err)) goto lock_retry_remap; rl = NULL; - lcn = err; } else if (!rl) up_read(&ni->runlist.lock); + /* + * If buffer is outside the runlist, treat it as a + * hole. This can happen due to concurrent truncate + * for example. + */ + if (err == -ENOENT || lcn == LCN_ENOENT) { + err = 0; + goto handle_hole; + } /* Hard error, zero out region. */ + if (!err) + err = -EIO; bh->b_blocknr = -1; SetPageError(page); ntfs_error(vol->sb, "Failed to read from inode 0x%lx, " "attribute type 0x%x, vcn 0x%llx, " "offset 0x%x because its location on " "disk could not be determined%s " - "(error code %lli).", ni->mft_no, + "(error code %i).", ni->mft_no, ni->type, (unsigned long long)vcn, vcn_ofs, is_retry ? " even after " - "retrying" : "", (long long)lcn); + "retrying" : "", err); } /* * Either iblock was outside lblock limits or @@ -289,9 +300,10 @@ handle_hole: handle_zblock: kaddr = kmap_atomic(page, KM_USER0); memset(kaddr + i * blocksize, 0, blocksize); - flush_dcache_page(page); kunmap_atomic(kaddr, KM_USER0); - set_buffer_uptodate(bh); + flush_dcache_page(page); + if (likely(!err)) + set_buffer_uptodate(bh); } while (i++, iblock++, (bh = bh->b_this_page) != head); /* Release the lock if we took it. */ @@ -711,20 +723,37 @@ lock_retry_remap: if (likely(!err)) goto lock_retry_remap; rl = NULL; - lcn = err; } else if (!rl) up_read(&ni->runlist.lock); + /* + * If buffer is outside the runlist, truncate has cut it out + * of the runlist. Just clean and clear the buffer and set it + * uptodate so it can get discarded by the VM. + */ + if (err == -ENOENT || lcn == LCN_ENOENT) { + u8 *kaddr; + + bh->b_blocknr = -1; + clear_buffer_dirty(bh); + kaddr = kmap_atomic(page, KM_USER0); + memset(kaddr + bh_offset(bh), 0, blocksize); + kunmap_atomic(kaddr, KM_USER0); + flush_dcache_page(page); + set_buffer_uptodate(bh); + err = 0; + continue; + } /* Failed to map the buffer, even after retrying. */ + if (!err) + err = -EIO; bh->b_blocknr = -1; ntfs_error(vol->sb, "Failed to write to inode 0x%lx, " "attribute type 0x%x, vcn 0x%llx, offset 0x%x " "because its location on disk could not be " - "determined%s (error code %lli).", ni->mft_no, + "determined%s (error code %i).", ni->mft_no, ni->type, (unsigned long long)vcn, vcn_ofs, is_retry ? " even after " - "retrying" : "", (long long)lcn); - if (!err) - err = -EIO; + "retrying" : "", err); break; } while (block++, (bh = bh->b_this_page) != head); -- cgit v0.10.2 From 311120eca0013083f5eb0aff13ffb8aa9fdd050c Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 22:04:20 +0100 Subject: NTFS: Fixup handling of sparse, compressed, and encrypted attributes in fs/ntfs/aops.c::ntfs_readpage(). Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 7f24cb1..c3b5102 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -76,11 +76,10 @@ ToDo/Notes: - Truncate {a,c,m}time to the ntfs supported time granularity when updating the times in the inode in ntfs_setattr(). - Fixup handling of sparse, compressed, and encrypted attributes in - fs/ntfs/inode.c::ntfs_read_locked_{,attr_,index_}inode(). + fs/ntfs/inode.c::ntfs_read_locked_{,attr_,index_}inode(), + fs/ntfs/aops.c::ntfs_{read,write}page(). - Make ntfs_write_block() not instantiate sparse blocks if they contain only zeroes. - - Fixup handling of sparse, compressed, and encrypted attributes in - fs/ntfs/aops.c::ntfs_writepage(). - Optimize fs/ntfs/aops.c::ntfs_write_block() by extending the page lock protection over the buffer submission for i/o which allows the removal of the get_bh()/put_bh() pairs for each buffer. diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 59389a8..2482b67 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -379,31 +379,38 @@ retry_readpage: return 0; } ni = NTFS_I(page->mapping->host); - + /* + * Only $DATA attributes can be encrypted and only unnamed $DATA + * attributes can be compressed. Index root can have the flags set but + * this means to create compressed/encrypted files, not that the + * attribute is compressed/encrypted. + */ + if (ni->type != AT_INDEX_ROOT) { + /* If attribute is encrypted, deny access, just like NT4. */ + if (NInoEncrypted(ni)) { + BUG_ON(ni->type != AT_DATA); + err = -EACCES; + goto err_out; + } + /* Compressed data streams are handled in compress.c. */ + if (NInoNonResident(ni) && NInoCompressed(ni)) { + BUG_ON(ni->type != AT_DATA); + BUG_ON(ni->name_len); + return ntfs_read_compressed_block(page); + } + } /* NInoNonResident() == NInoIndexAllocPresent() */ if (NInoNonResident(ni)) { - /* - * Only unnamed $DATA attributes can be compressed or - * encrypted. - */ - if (ni->type == AT_DATA && !ni->name_len) { - /* If file is encrypted, deny access, just like NT4. */ - if (NInoEncrypted(ni)) { - err = -EACCES; - goto err_out; - } - /* Compressed data streams are handled in compress.c. */ - if (NInoCompressed(ni)) - return ntfs_read_compressed_block(page); - } - /* Normal data stream. */ + /* Normal, non-resident data stream. */ return ntfs_read_block(page); } /* * Attribute is resident, implying it is not compressed or encrypted. * This also means the attribute is smaller than an mft record and * hence smaller than a page, so can simply zero out any pages with - * index above 0. + * index above 0. Note the attribute can actually be marked compressed + * but if it is resident the actual data is not compressed so we are + * ok to ignore the compressed flag here. */ if (unlikely(page->index > 0)) { kaddr = kmap_atomic(page, KM_USER0); -- cgit v0.10.2 From a01ac532b519dc0e0b4d8bc4e12373e4e4cd1b1a Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 22:08:11 +0100 Subject: NTFS: Fix page_has_buffers()/page_buffers() handling in fs/ntfs/aops.c. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index c3b5102..029f856 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -85,6 +85,7 @@ ToDo/Notes: removal of the get_bh()/put_bh() pairs for each buffer. - Fix fs/ntfs/aops.c::ntfs_{read,write}_block() to handle the case where a concurrent truncate has truncated the runlist under our feet. + - Fix page_has_buffers()/page_buffers() handling in fs/ntfs/aops.c. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 2482b67..52e1aff 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -185,13 +185,15 @@ static int ntfs_read_block(struct page *page) blocksize_bits = VFS_I(ni)->i_blkbits; blocksize = 1 << blocksize_bits; - if (!page_has_buffers(page)) + if (!page_has_buffers(page)) { create_empty_buffers(page, blocksize, 0); - bh = head = page_buffers(page); - if (unlikely(!bh)) { - unlock_page(page); - return -ENOMEM; + if (unlikely(!page_has_buffers(page))) { + unlock_page(page); + return -ENOMEM; + } } + bh = head = page_buffers(page); + BUG_ON(!bh); iblock = (s64)page->index << (PAGE_CACHE_SHIFT - blocksize_bits); read_lock_irqsave(&ni->size_lock, flags); @@ -530,19 +532,21 @@ static int ntfs_write_block(struct page *page, struct writeback_control *wbc) BUG_ON(!PageUptodate(page)); create_empty_buffers(page, blocksize, (1 << BH_Uptodate) | (1 << BH_Dirty)); + if (unlikely(!page_has_buffers(page))) { + ntfs_warning(vol->sb, "Error allocating page " + "buffers. Redirtying page so we try " + "again later."); + /* + * Put the page back on mapping->dirty_pages, but leave + * its buffers' dirty state as-is. + */ + redirty_page_for_writepage(wbc, page); + unlock_page(page); + return 0; + } } bh = head = page_buffers(page); - if (unlikely(!bh)) { - ntfs_warning(vol->sb, "Error allocating page buffers. " - "Redirtying page so we try again later."); - /* - * Put the page back on mapping->dirty_pages, but leave its - * buffer's dirty state as-is. - */ - redirty_page_for_writepage(wbc, page); - unlock_page(page); - return 0; - } + BUG_ON(!bh); /* NOTE: Different naming scheme to ntfs_read_block()! */ @@ -910,7 +914,6 @@ static int ntfs_write_mst_block(struct page *page, sync = (wbc->sync_mode == WB_SYNC_ALL); /* Make sure we have mapped buffers. */ - BUG_ON(!page_has_buffers(page)); bh = head = page_buffers(page); BUG_ON(!bh); @@ -2397,6 +2400,7 @@ void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs) { buffers_to_free = bh; } bh = head = page_buffers(page); + BUG_ON(!bh); do { bh_ofs = bh_offset(bh); if (bh_ofs + bh_size <= ofs) -- cgit v0.10.2 From e604635c8bea16f6177e6133eb3efbfb4a029ef6 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 22:13:02 +0100 Subject: NTFS: Improve scalability by changing the driver global spin lock in fs/ntfs/aops.c::ntfs_end_buffer_async_read() to a bit spin lock in the first buffer head of a page. Signed-off-by: Anton Altaparmakov diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 029f856..32a4150 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -86,6 +86,9 @@ ToDo/Notes: - Fix fs/ntfs/aops.c::ntfs_{read,write}_block() to handle the case where a concurrent truncate has truncated the runlist under our feet. - Fix page_has_buffers()/page_buffers() handling in fs/ntfs/aops.c. + - In fs/ntfs/aops.c::ntfs_end_buffer_async_read(), use a bit spin lock + in the first buffer head instead of a driver global spin lock to + improve scalability. 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 52e1aff..950b686 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -55,9 +55,8 @@ */ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate) { - static DEFINE_SPINLOCK(page_uptodate_lock); unsigned long flags; - struct buffer_head *tmp; + struct buffer_head *first, *tmp; struct page *page; ntfs_inode *ni; int page_uptodate = 1; @@ -89,11 +88,13 @@ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate) } } else { clear_buffer_uptodate(bh); + SetPageError(page); ntfs_error(ni->vol->sb, "Buffer I/O error, logical block %llu.", (unsigned long long)bh->b_blocknr); - SetPageError(page); } - spin_lock_irqsave(&page_uptodate_lock, flags); + first = page_buffers(page); + local_irq_save(flags); + bit_spin_lock(BH_Uptodate_Lock, &first->b_state); clear_buffer_async_read(bh); unlock_buffer(bh); tmp = bh; @@ -108,7 +109,8 @@ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate) } tmp = tmp->b_this_page; } while (tmp != bh); - spin_unlock_irqrestore(&page_uptodate_lock, flags); + bit_spin_unlock(BH_Uptodate_Lock, &first->b_state); + local_irq_restore(flags); /* * If none of the buffers had errors then we can set the page uptodate, * but we first have to perform the post read mst fixups, if the @@ -141,7 +143,8 @@ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate) unlock_page(page); return; still_busy: - spin_unlock_irqrestore(&page_uptodate_lock, flags); + bit_spin_unlock(BH_Uptodate_Lock, &first->b_state); + local_irq_restore(flags); return; } -- cgit v0.10.2 From a57ebc90f1350296edded12d33d7c278831bc3bf Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 8 Sep 2005 14:27:47 -0700 Subject: [IPV6]: Don't redo xfrm_lookup for cached dst entries The xfrm lookup is already done when the dst entry is looked up first and stored in the cache. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 0961372..cf94372 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -673,11 +673,12 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) if ((dst = ip6_tnl_dst_check(t)) != NULL) dst_hold(dst); - else + else { dst = ip6_route_output(NULL, &fl); - if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0) < 0) - goto tx_err_link_failure; + if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0) < 0) + goto tx_err_link_failure; + } tdev = dst->dev; -- cgit v0.10.2 From 4d803fcdcd97dd346d4b39c3b76e5879cead8a31 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 8 Sep 2005 14:37:53 -0700 Subject: [SPARC64]: Inline membar()'s again. Since GCC has to emit a call and a delay slot to the out-of-line "membar" routines in arch/sparc64/lib/mb.S it is much better to just do the necessary predicted branch inline instead as: ba,pt %xcc, 1f membar #whatever 1: instead of the current: call membar_foo dslot because this way GCC is not required to allocate a stack frame if the function can be a leaf function. This also makes this bug fix easier to backport to 2.4.x Signed-off-by: David S. Miller diff --git a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c index d89fc24..7d9a0f6 100644 --- a/arch/sparc64/kernel/sparc64_ksyms.c +++ b/arch/sparc64/kernel/sparc64_ksyms.c @@ -403,12 +403,3 @@ EXPORT_SYMBOL(xor_vis_4); EXPORT_SYMBOL(xor_vis_5); EXPORT_SYMBOL(prom_palette); - -/* memory barriers */ -EXPORT_SYMBOL(mb); -EXPORT_SYMBOL(rmb); -EXPORT_SYMBOL(wmb); -EXPORT_SYMBOL(membar_storeload); -EXPORT_SYMBOL(membar_storeload_storestore); -EXPORT_SYMBOL(membar_storeload_loadload); -EXPORT_SYMBOL(membar_storestore_loadstore); diff --git a/arch/sparc64/lib/Makefile b/arch/sparc64/lib/Makefile index 6201f10..40dbeec 100644 --- a/arch/sparc64/lib/Makefile +++ b/arch/sparc64/lib/Makefile @@ -12,7 +12,7 @@ lib-y := PeeCeeI.o copy_page.o clear_page.o strlen.o strncmp.o \ U1memcpy.o U1copy_from_user.o U1copy_to_user.o \ U3memcpy.o U3copy_from_user.o U3copy_to_user.o U3patch.o \ copy_in_user.o user_fixup.o memmove.o \ - mcount.o ipcsum.o rwsem.o xor.o find_bit.o delay.o mb.o + mcount.o ipcsum.o rwsem.o xor.o find_bit.o delay.o lib-$(CONFIG_DEBUG_SPINLOCK) += debuglocks.o lib-$(CONFIG_HAVE_DEC_LOCK) += dec_and_lock.o diff --git a/arch/sparc64/lib/mb.S b/arch/sparc64/lib/mb.S deleted file mode 100644 index 4004f74..0000000 --- a/arch/sparc64/lib/mb.S +++ /dev/null @@ -1,73 +0,0 @@ -/* mb.S: Out of line memory barriers. - * - * Copyright (C) 2005 David S. Miller (davem@davemloft.net) - */ - - /* These are here in an effort to more fully work around - * Spitfire Errata #51. Essentially, if a memory barrier - * occurs soon after a mispredicted branch, the chip can stop - * executing instructions until a trap occurs. Therefore, if - * interrupts are disabled, the chip can hang forever. - * - * It used to be believed that the memory barrier had to be - * right in the delay slot, but a case has been traced - * recently wherein the memory barrier was one instruction - * after the branch delay slot and the chip still hung. The - * offending sequence was the following in sym_wakeup_done() - * of the sym53c8xx_2 driver: - * - * call sym_ccb_from_dsa, 0 - * movge %icc, 0, %l0 - * brz,pn %o0, .LL1303 - * mov %o0, %l2 - * membar #LoadLoad - * - * The branch has to be mispredicted for the bug to occur. - * Therefore, we put the memory barrier explicitly into a - * "branch always, predicted taken" delay slot to avoid the - * problem case. - */ - - .text - -99: retl - nop - - .globl mb -mb: ba,pt %xcc, 99b - membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad - .size mb, .-mb - - .globl rmb -rmb: ba,pt %xcc, 99b - membar #LoadLoad - .size rmb, .-rmb - - .globl wmb -wmb: ba,pt %xcc, 99b - membar #StoreStore - .size wmb, .-wmb - - .globl membar_storeload -membar_storeload: - ba,pt %xcc, 99b - membar #StoreLoad - .size membar_storeload, .-membar_storeload - - .globl membar_storeload_storestore -membar_storeload_storestore: - ba,pt %xcc, 99b - membar #StoreLoad | #StoreStore - .size membar_storeload_storestore, .-membar_storeload_storestore - - .globl membar_storeload_loadload -membar_storeload_loadload: - ba,pt %xcc, 99b - membar #StoreLoad | #LoadLoad - .size membar_storeload_loadload, .-membar_storeload_loadload - - .globl membar_storestore_loadstore -membar_storestore_loadstore: - ba,pt %xcc, 99b - membar #StoreStore | #LoadStore - .size membar_storestore_loadstore, .-membar_storestore_loadstore diff --git a/include/asm-sparc64/system.h b/include/asm-sparc64/system.h index 5e94c05..b541752 100644 --- a/include/asm-sparc64/system.h +++ b/include/asm-sparc64/system.h @@ -28,13 +28,48 @@ enum sparc_cpu { #define ARCH_SUN4C_SUN4 0 #define ARCH_SUN4 0 -extern void mb(void); -extern void rmb(void); -extern void wmb(void); -extern void membar_storeload(void); -extern void membar_storeload_storestore(void); -extern void membar_storeload_loadload(void); -extern void membar_storestore_loadstore(void); +/* These are here in an effort to more fully work around Spitfire Errata + * #51. Essentially, if a memory barrier occurs soon after a mispredicted + * branch, the chip can stop executing instructions until a trap occurs. + * Therefore, if interrupts are disabled, the chip can hang forever. + * + * It used to be believed that the memory barrier had to be right in the + * delay slot, but a case has been traced recently wherein the memory barrier + * was one instruction after the branch delay slot and the chip still hung. + * The offending sequence was the following in sym_wakeup_done() of the + * sym53c8xx_2 driver: + * + * call sym_ccb_from_dsa, 0 + * movge %icc, 0, %l0 + * brz,pn %o0, .LL1303 + * mov %o0, %l2 + * membar #LoadLoad + * + * The branch has to be mispredicted for the bug to occur. Therefore, we put + * the memory barrier explicitly into a "branch always, predicted taken" + * delay slot to avoid the problem case. + */ +#define membar_safe(type) \ +do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \ + " membar " type "\n" \ + "1:\n" \ + : : : "memory"); \ +} while (0) + +#define mb() \ + membar_safe("#LoadLoad | #LoadStore | #StoreStore | #StoreLoad") +#define rmb() \ + membar_safe("#LoadLoad") +#define wmb() \ + membar_safe("#StoreStore") +#define membar_storeload() \ + membar_safe("#StoreLoad") +#define membar_storeload_storestore() \ + membar_safe("#StoreLoad | #StoreStore") +#define membar_storeload_loadload() \ + membar_safe("#StoreLoad | #LoadLoad") +#define membar_storestore_loadstore() \ + membar_safe("#StoreStore | #LoadStore") #endif -- cgit v0.10.2 From 2d8331792ea3f5ccfd147288afba148537337019 Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Wed, 27 Jul 2005 13:10:11 +0400 Subject: [PATCH] W1: w1_netlink: New init/fini netlink callbacks. They are guarded with NETLINK_DISABLE compile time options, so if CONFIG_NET is disabled, no linking errors occur. Bug noticed by Adrian Bunk . Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c index 498ad505..2a538d0 100644 --- a/drivers/w1/w1_int.c +++ b/drivers/w1/w1_int.c @@ -88,17 +88,14 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, dev->groups = 1; dev->seq = 1; - dev->nls = netlink_kernel_create(NETLINK_W1, 1, NULL, THIS_MODULE); - if (!dev->nls) { - printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n", - NETLINK_NFLOG, dev->dev.bus_id); - } + dev_init_netlink(dev); err = device_register(&dev->dev); if (err) { printk(KERN_ERR "Failed to register master device. err=%d\n", err); - if (dev->nls && dev->nls->sk_socket) - sock_release(dev->nls->sk_socket); + + dev_fini_netlink(dev); + memset(dev, 0, sizeof(struct w1_master)); kfree(dev); dev = NULL; @@ -107,11 +104,10 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, return dev; } -static void w1_free_dev(struct w1_master *dev) +void w1_free_dev(struct w1_master *dev) { device_unregister(&dev->dev); - if (dev->nls && dev->nls->sk_socket) - sock_release(dev->nls->sk_socket); + dev_fini_netlink(dev); memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master)); kfree(dev); } diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c index e7b7744..328645d 100644 --- a/drivers/w1/w1_netlink.c +++ b/drivers/w1/w1_netlink.c @@ -57,10 +57,36 @@ void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg) nlmsg_failure: return; } + +int dev_init_netlink(struct w1_master *dev) +{ + dev->nls = netlink_kernel_create(NETLINK_W1, 1, NULL, THIS_MODULE); + if (!dev->nls) { + printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n", + NETLINK_W1, dev->dev.bus_id); + } + + return 0; +} + +void dev_fini_netlink(struct w1_master *dev) +{ + if (dev->nls && dev->nls->sk_socket) + sock_release(dev->nls->sk_socket); +} #else #warning Netlink support is disabled. Please compile with NET support enabled. void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg) { } + +int dev_init_netlink(struct w1_master *dev) +{ + return 0; +} + +void dev_fini_netlink(struct w1_master *dev) +{ +} #endif diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h index 8615756..eb0c8b3 100644 --- a/drivers/w1/w1_netlink.h +++ b/drivers/w1/w1_netlink.h @@ -52,6 +52,8 @@ struct w1_netlink_msg #ifdef __KERNEL__ void w1_netlink_send(struct w1_master *, struct w1_netlink_msg *); +int dev_init_netlink(struct w1_master *dev); +void dev_fini_netlink(struct w1_master *dev); #endif /* __KERNEL__ */ #endif /* __W1_NETLINK_H */ -- cgit v0.10.2 From 8949d2aa05ddf5e9a31d738568a79915970cb38e Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Wed, 3 Aug 2005 15:14:50 +0400 Subject: [PATCH] W1: Sync with w1/ds9490 tree. Whitespace, static/nonstatic cleanups. Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/ds_w1_bridge.c b/drivers/w1/ds_w1_bridge.c index 7bddd8a..a79d16d 100644 --- a/drivers/w1/ds_w1_bridge.c +++ b/drivers/w1/ds_w1_bridge.c @@ -1,8 +1,8 @@ /* - * ds_w1_bridge.c + * ds_w1_bridge.c * * Copyright (c) 2004 Evgeniy Polyakov - * + * * * 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 @@ -25,7 +25,7 @@ #include "../w1/w1.h" #include "../w1/w1_int.h" #include "dscore.h" - + static struct ds_device *ds_dev; static struct w1_bus_master *ds_bus_master; @@ -120,7 +120,7 @@ static u8 ds9490r_reset(unsigned long data) static int __devinit ds_w1_init(void) { int err; - + ds_bus_master = kmalloc(sizeof(*ds_bus_master), GFP_KERNEL); if (!ds_bus_master) { printk(KERN_ERR "Failed to allocate DS9490R USB<->W1 bus_master structure.\n"); @@ -136,14 +136,14 @@ static int __devinit ds_w1_init(void) memset(ds_bus_master, 0, sizeof(*ds_bus_master)); - ds_bus_master->data = (unsigned long)ds_dev; - ds_bus_master->touch_bit = &ds9490r_touch_bit; - ds_bus_master->read_bit = &ds9490r_read_bit; - ds_bus_master->write_bit = &ds9490r_write_bit; - ds_bus_master->read_byte = &ds9490r_read_byte; - ds_bus_master->write_byte = &ds9490r_write_byte; - ds_bus_master->read_block = &ds9490r_read_block; - ds_bus_master->write_block = &ds9490r_write_block; + ds_bus_master->data = (unsigned long)ds_dev; + ds_bus_master->touch_bit = &ds9490r_touch_bit; + ds_bus_master->read_bit = &ds9490r_read_bit; + ds_bus_master->write_bit = &ds9490r_write_bit; + ds_bus_master->read_byte = &ds9490r_read_byte; + ds_bus_master->write_byte = &ds9490r_write_byte; + ds_bus_master->read_block = &ds9490r_read_block; + ds_bus_master->write_block = &ds9490r_write_block; ds_bus_master->reset_bus = &ds9490r_reset; err = w1_add_master_device(ds_bus_master); diff --git a/drivers/w1/dscore.c b/drivers/w1/dscore.c index eee6644..15fb250 100644 --- a/drivers/w1/dscore.c +++ b/drivers/w1/dscore.c @@ -1,8 +1,8 @@ /* - * dscore.c + * dscore.c * * Copyright (c) 2004 Evgeniy Polyakov - * + * * * 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 @@ -32,19 +32,16 @@ static struct usb_device_id ds_id_table [] = { }; MODULE_DEVICE_TABLE(usb, ds_id_table); -int ds_probe(struct usb_interface *, const struct usb_device_id *); -void ds_disconnect(struct usb_interface *); +static int ds_probe(struct usb_interface *, const struct usb_device_id *); +static void ds_disconnect(struct usb_interface *); int ds_touch_bit(struct ds_device *, u8, u8 *); int ds_read_byte(struct ds_device *, u8 *); int ds_read_bit(struct ds_device *, u8 *); int ds_write_byte(struct ds_device *, u8); int ds_write_bit(struct ds_device *, u8); -int ds_start_pulse(struct ds_device *, int); -int ds_set_speed(struct ds_device *, int); +static int ds_start_pulse(struct ds_device *, int); int ds_reset(struct ds_device *, struct ds_status *); -int ds_detect(struct ds_device *, struct ds_status *); -int ds_stop_pulse(struct ds_device *, int); struct ds_device * ds_get_device(void); void ds_put_device(struct ds_device *); @@ -79,11 +76,11 @@ void ds_put_device(struct ds_device *dev) static int ds_send_control_cmd(struct ds_device *dev, u16 value, u16 index) { int err; - - err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), + + err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), CONTROL_CMD, 0x40, value, index, NULL, 0, 1000); if (err < 0) { - printk(KERN_ERR "Failed to send command control message %x.%x: err=%d.\n", + printk(KERN_ERR "Failed to send command control message %x.%x: err=%d.\n", value, index, err); return err; } @@ -94,11 +91,11 @@ static int ds_send_control_cmd(struct ds_device *dev, u16 value, u16 index) static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index) { int err; - - err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), + + err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), MODE_CMD, 0x40, value, index, NULL, 0, 1000); if (err < 0) { - printk(KERN_ERR "Failed to send mode control message %x.%x: err=%d.\n", + printk(KERN_ERR "Failed to send mode control message %x.%x: err=%d.\n", value, index, err); return err; } @@ -109,11 +106,11 @@ static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index) static int ds_send_control(struct ds_device *dev, u16 value, u16 index) { int err; - - err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), + + err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), COMM_CMD, 0x40, value, index, NULL, 0, 1000); if (err < 0) { - printk(KERN_ERR "Failed to send control message %x.%x: err=%d.\n", + printk(KERN_ERR "Failed to send control message %x.%x: err=%d.\n", value, index, err); return err; } @@ -126,19 +123,20 @@ static inline void ds_dump_status(unsigned char *buf, unsigned char *str, int of printk("%45s: %8x\n", str, buf[off]); } -int ds_recv_status_nodump(struct ds_device *dev, struct ds_status *st, unsigned char *buf, int size) +static int ds_recv_status_nodump(struct ds_device *dev, struct ds_status *st, + unsigned char *buf, int size) { int count, err; - + memset(st, 0, sizeof(st)); - + count = 0; err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_STATUS]), buf, size, &count, 100); if (err < 0) { printk(KERN_ERR "Failed to read 1-wire data from 0x%x: err=%d.\n", dev->ep[EP_STATUS], err); return err; } - + if (count >= sizeof(*st)) memcpy(st, buf, sizeof(*st)); @@ -149,13 +147,13 @@ static int ds_recv_status(struct ds_device *dev, struct ds_status *st) { unsigned char buf[64]; int count, err = 0, i; - + memcpy(st, buf, sizeof(*st)); - + count = ds_recv_status_nodump(dev, st, buf, sizeof(buf)); if (count < 0) return err; - + printk("0x%x: count=%d, status: ", dev->ep[EP_STATUS], count); for (i=0; iudev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]), + err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]), buf, size, &count, 1000); if (err < 0) { printk(KERN_INFO "Clearing ep0x%x.\n", dev->ep[EP_DATA_IN]); @@ -234,7 +232,7 @@ static int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size) static int ds_send_data(struct ds_device *dev, unsigned char *buf, int len) { int count, err; - + count = 0; err = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, dev->ep[EP_DATA_OUT]), buf, len, &count, 1000); if (err < 0) { @@ -245,12 +243,14 @@ static int ds_send_data(struct ds_device *dev, unsigned char *buf, int len) return err; } +#if 0 + int ds_stop_pulse(struct ds_device *dev, int limit) { struct ds_status st; int count = 0, err = 0; u8 buf[0x20]; - + do { err = ds_send_control(dev, CTL_HALT_EXE_IDLE, 0); if (err) @@ -275,7 +275,7 @@ int ds_stop_pulse(struct ds_device *dev, int limit) int ds_detect(struct ds_device *dev, struct ds_status *st) { int err; - + err = ds_send_control_cmd(dev, CTL_RESET_DEVICE, 0); if (err) return err; @@ -283,11 +283,11 @@ int ds_detect(struct ds_device *dev, struct ds_status *st) err = ds_send_control(dev, COMM_SET_DURATION | COMM_IM, 0); if (err) return err; - + err = ds_send_control(dev, COMM_SET_DURATION | COMM_IM | COMM_TYPE, 0x40); if (err) return err; - + err = ds_send_control_mode(dev, MOD_PULSE_EN, PULSE_PROG); if (err) return err; @@ -297,7 +297,9 @@ int ds_detect(struct ds_device *dev, struct ds_status *st) return err; } -int ds_wait_status(struct ds_device *dev, struct ds_status *st) +#endif /* 0 */ + +static int ds_wait_status(struct ds_device *dev, struct ds_status *st) { u8 buf[0x20]; int err, count = 0; @@ -305,7 +307,7 @@ int ds_wait_status(struct ds_device *dev, struct ds_status *st) do { err = ds_recv_status_nodump(dev, st, buf, sizeof(buf)); #if 0 - if (err >= 0) { + if (err >= 0) { int i; printk("0x%x: count=%d, status: ", dev->ep[EP_STATUS], err); for (i=0; i 16) && (buf[0x10] & 0x01)) || count >= 100 || err < 0) { ds_recv_status(dev, st); return -1; - } - else { + } else return 0; - } } int ds_reset(struct ds_device *dev, struct ds_status *st) @@ -345,6 +345,7 @@ int ds_reset(struct ds_device *dev, struct ds_status *st) return 0; } +#if 0 int ds_set_speed(struct ds_device *dev, int speed) { int err; @@ -356,20 +357,21 @@ int ds_set_speed(struct ds_device *dev, int speed) speed = SPEED_FLEXIBLE; speed &= 0xff; - + err = ds_send_control_mode(dev, MOD_1WIRE_SPEED, speed); if (err) return err; return err; } +#endif /* 0 */ -int ds_start_pulse(struct ds_device *dev, int delay) +static int ds_start_pulse(struct ds_device *dev, int delay) { int err; u8 del = 1 + (u8)(delay >> 4); struct ds_status st; - + #if 0 err = ds_stop_pulse(dev, 10); if (err) @@ -390,7 +392,7 @@ int ds_start_pulse(struct ds_device *dev, int delay) mdelay(delay); ds_wait_status(dev, &st); - + return err; } @@ -400,7 +402,7 @@ int ds_touch_bit(struct ds_device *dev, u8 bit, u8 *tbit) struct ds_status st; u16 value = (COMM_BIT_IO | COMM_IM) | ((bit) ? COMM_D : 0); u16 cmd; - + err = ds_send_control(dev, value, 0); if (err) return err; @@ -430,7 +432,7 @@ int ds_write_bit(struct ds_device *dev, u8 bit) { int err; struct ds_status st; - + err = ds_send_control(dev, COMM_BIT_IO | COMM_IM | (bit) ? COMM_D : 0, 0); if (err) return err; @@ -445,7 +447,7 @@ int ds_write_byte(struct ds_device *dev, u8 byte) int err; struct ds_status st; u8 rbyte; - + err = ds_send_control(dev, COMM_BYTE_IO | COMM_IM | COMM_SPU, byte); if (err) return err; @@ -453,11 +455,11 @@ int ds_write_byte(struct ds_device *dev, u8 byte) err = ds_wait_status(dev, &st); if (err) return err; - + err = ds_recv_data(dev, &rbyte, sizeof(rbyte)); if (err < 0) return err; - + ds_start_pulse(dev, PULLUP_PULSE_DURATION); return !(byte == rbyte); @@ -470,11 +472,11 @@ int ds_read_bit(struct ds_device *dev, u8 *bit) err = ds_send_control_mode(dev, MOD_PULSE_EN, PULSE_SPUE); if (err) return err; - + err = ds_send_control(dev, COMM_BIT_IO | COMM_IM | COMM_SPU | COMM_D, 0); if (err) return err; - + err = ds_recv_data(dev, bit, sizeof(*bit)); if (err < 0) return err; @@ -492,7 +494,7 @@ int ds_read_byte(struct ds_device *dev, u8 *byte) return err; ds_wait_status(dev, &st); - + err = ds_recv_data(dev, byte, sizeof(*byte)); if (err < 0) return err; @@ -509,17 +511,17 @@ int ds_read_block(struct ds_device *dev, u8 *buf, int len) return -E2BIG; memset(buf, 0xFF, len); - + err = ds_send_data(dev, buf, len); if (err < 0) return err; - + err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | COMM_SPU, len); if (err) return err; ds_wait_status(dev, &st); - + memset(buf, 0x00, len); err = ds_recv_data(dev, buf, len); @@ -530,11 +532,11 @@ int ds_write_block(struct ds_device *dev, u8 *buf, int len) { int err; struct ds_status st; - + err = ds_send_data(dev, buf, len); if (err < 0) return err; - + ds_wait_status(dev, &st); err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | COMM_SPU, len); @@ -548,10 +550,12 @@ int ds_write_block(struct ds_device *dev, u8 *buf, int len) return err; ds_start_pulse(dev, PULLUP_PULSE_DURATION); - + return !(err == len); } +#if 0 + int ds_search(struct ds_device *dev, u64 init, u64 *buf, u8 id_number, int conditional_search) { int err; @@ -559,11 +563,11 @@ int ds_search(struct ds_device *dev, u64 init, u64 *buf, u8 id_number, int condi struct ds_status st; memset(buf, 0, sizeof(buf)); - + err = ds_send_data(ds_dev, (unsigned char *)&init, 8); if (err) return err; - + ds_wait_status(ds_dev, &st); value = COMM_SEARCH_ACCESS | COMM_IM | COMM_SM | COMM_F | COMM_RTS; @@ -589,7 +593,7 @@ int ds_match_access(struct ds_device *dev, u64 init) err = ds_send_data(dev, (unsigned char *)&init, sizeof(init)); if (err) return err; - + ds_wait_status(dev, &st); err = ds_send_control(dev, COMM_MATCH_ACCESS | COMM_IM | COMM_RST, 0x0055); @@ -609,11 +613,11 @@ int ds_set_path(struct ds_device *dev, u64 init) memcpy(buf, &init, 8); buf[8] = BRANCH_MAIN; - + err = ds_send_data(dev, buf, sizeof(buf)); if (err) return err; - + ds_wait_status(dev, &st); err = ds_send_control(dev, COMM_SET_PATH | COMM_IM | COMM_RST, 0); @@ -625,7 +629,10 @@ int ds_set_path(struct ds_device *dev, u64 init) return 0; } -int ds_probe(struct usb_interface *intf, const struct usb_device_id *udev_id) +#endif /* 0 */ + +static int ds_probe(struct usb_interface *intf, + const struct usb_device_id *udev_id) { struct usb_device *udev = interface_to_usbdev(intf); struct usb_endpoint_descriptor *endpoint; @@ -653,7 +660,7 @@ int ds_probe(struct usb_interface *intf, const struct usb_device_id *udev_id) printk(KERN_ERR "Failed to reset configuration: err=%d.\n", err); return err; } - + iface_desc = &intf->altsetting[0]; if (iface_desc->desc.bNumEndpoints != NUM_EP-1) { printk(KERN_INFO "Num endpoints=%d. It is not DS9490R.\n", iface_desc->desc.bNumEndpoints); @@ -662,37 +669,37 @@ int ds_probe(struct usb_interface *intf, const struct usb_device_id *udev_id) atomic_set(&ds_dev->refcnt, 0); memset(ds_dev->ep, 0, sizeof(ds_dev->ep)); - + /* - * This loop doesn'd show control 0 endpoint, + * This loop doesn'd show control 0 endpoint, * so we will fill only 1-3 endpoints entry. */ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; ds_dev->ep[i+1] = endpoint->bEndpointAddress; - + printk("%d: addr=%x, size=%d, dir=%s, type=%x\n", i, endpoint->bEndpointAddress, le16_to_cpu(endpoint->wMaxPacketSize), (endpoint->bEndpointAddress & USB_DIR_IN)?"IN":"OUT", endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); } - + #if 0 { int err, i; u64 buf[3]; u64 init=0xb30000002078ee81ull; struct ds_status st; - + ds_reset(ds_dev, &st); err = ds_search(ds_dev, init, buf, 3, 0); if (err < 0) return err; for (i=0; i - * + * * * 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 @@ -122,7 +122,7 @@ struct ds_device { - struct usb_device *udev; + struct usb_device *udev; struct usb_interface *intf; int ep[NUM_EP]; @@ -156,11 +156,7 @@ int ds_read_byte(struct ds_device *, u8 *); int ds_read_bit(struct ds_device *, u8 *); int ds_write_byte(struct ds_device *, u8); int ds_write_bit(struct ds_device *, u8); -int ds_start_pulse(struct ds_device *, int); -int ds_set_speed(struct ds_device *, int); int ds_reset(struct ds_device *, struct ds_status *); -int ds_detect(struct ds_device *, struct ds_status *); -int ds_stop_pulse(struct ds_device *, int); struct ds_device * ds_get_device(void); void ds_put_device(struct ds_device *); int ds_write_block(struct ds_device *, u8 *, int); -- cgit v0.10.2 From 7f772ed8df27c6941952452330c618512389c4c7 Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Thu, 11 Aug 2005 13:20:07 +0400 Subject: [PATCH] w1: hotplug support. Here is W1 hotplug in addition to netlink notifications. Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 0bbf029..9c7777b 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -125,27 +125,41 @@ static struct bin_attribute w1_slave_bin_attribute = { .read = &w1_default_read_bin, }; +static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); static struct bus_type w1_bus_type = { .name = "w1", .match = w1_master_match, + .hotplug = w1_hotplug, }; -struct device_driver w1_driver = { - .name = "w1_driver", +struct device_driver w1_master_driver = { + .name = "w1_master_driver", .bus = &w1_bus_type, .probe = w1_master_probe, .remove = w1_master_remove, }; -struct device w1_device = { +struct device w1_master_device = { .parent = NULL, .bus = &w1_bus_type, .bus_id = "w1 bus master", - .driver = &w1_driver, + .driver = &w1_master_driver, .release = &w1_master_release }; +struct device_driver w1_slave_driver = { + .name = "w1_slave_driver", + .bus = &w1_bus_type, +}; + +struct device w1_slave_device = { + .parent = NULL, + .bus = &w1_bus_type, + .bus_id = "w1 bus slave", + .driver = &w1_slave_driver, +}; + static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_attribute *attr, char *buf) { struct w1_master *md = container_of(dev, struct w1_master, dev); @@ -329,12 +343,55 @@ void w1_destroy_master_attributes(struct w1_master *master) sysfs_remove_group(&master->dev.kobj, &w1_master_defattr_group); } +#ifdef CONFIG_HOTPLUG +static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) +{ + struct w1_master *md = NULL; + struct w1_slave *sl = NULL; + char *event_owner, *name; + int err, cur_index=0, cur_len=0; + + if (dev->driver == &w1_master_driver) { + md = container_of(dev, struct w1_master, dev); + event_owner = "master"; + name = md->name; + } else if (dev->driver == &w1_slave_driver) { + sl = container_of(dev, struct w1_slave, dev); + event_owner = "slave"; + name = sl->name; + } else { + dev_dbg(dev, "Unknown hotplug event.\n"); + return -EINVAL; + } + + dev_dbg(dev, "Hotplug event for %s %s, bus_id=%s.\n", event_owner, name, dev->bus_id); + + if (dev->driver != &w1_slave_driver || !sl) + return 0; + + err = add_hotplug_env_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_FID=%02X", sl->reg_num.family); + if (err) + return err; + + err = add_hotplug_env_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_SLAVE_ID=%024llX", sl->reg_num.id); + if (err) + return err; + + return 0; +}; +#else +static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) +{ + return 0; +} +#endif + static int __w1_attach_slave_device(struct w1_slave *sl) { int err; sl->dev.parent = &sl->master->dev; - sl->dev.driver = sl->master->driver; + sl->dev.driver = &w1_slave_driver; sl->dev.bus = &w1_bus_type; sl->dev.release = &w1_slave_release; @@ -507,7 +564,6 @@ void w1_reconnect_slaves(struct w1_family *f) spin_unlock_bh(&w1_mlock); } - static void w1_slave_found(unsigned long data, u64 rn) { int slave_count; @@ -783,7 +839,7 @@ static int w1_init(void) goto err_out_exit_init; } - retval = driver_register(&w1_driver); + retval = driver_register(&w1_master_driver); if (retval) { printk(KERN_ERR "Failed to register master driver. err=%d.\n", @@ -791,18 +847,29 @@ static int w1_init(void) goto err_out_bus_unregister; } + retval = driver_register(&w1_slave_driver); + if (retval) { + printk(KERN_ERR + "Failed to register master driver. err=%d.\n", + retval); + goto err_out_master_unregister; + } + control_thread = kernel_thread(&w1_control, NULL, 0); if (control_thread < 0) { printk(KERN_ERR "Failed to create control thread. err=%d\n", control_thread); retval = control_thread; - goto err_out_driver_unregister; + goto err_out_slave_unregister; } return 0; -err_out_driver_unregister: - driver_unregister(&w1_driver); +err_out_slave_unregister: + driver_unregister(&w1_slave_driver); + +err_out_master_unregister: + driver_unregister(&w1_master_driver); err_out_bus_unregister: bus_unregister(&w1_bus_type); @@ -821,7 +888,8 @@ static void w1_fini(void) control_needs_exit = 1; wait_for_completion(&w1_control_complete); - driver_unregister(&w1_driver); + driver_unregister(&w1_slave_driver); + driver_unregister(&w1_master_driver); bus_unregister(&w1_bus_type); } diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c index 2a538d0..c13724f 100644 --- a/drivers/w1/w1_int.c +++ b/drivers/w1/w1_int.c @@ -29,9 +29,9 @@ static u32 w1_ids = 1; -extern struct device_driver w1_driver; +extern struct device_driver w1_master_driver; extern struct bus_type w1_bus_type; -extern struct device w1_device; +extern struct device w1_master_device; extern int w1_max_slave_count; extern int w1_max_slave_ttl; extern struct list_head w1_masters; @@ -125,7 +125,7 @@ int w1_add_master_device(struct w1_bus_master *master) return(-EINVAL); } - dev = w1_alloc_dev(w1_ids++, w1_max_slave_count, w1_max_slave_ttl, &w1_driver, &w1_device); + dev = w1_alloc_dev(w1_ids++, w1_max_slave_count, w1_max_slave_ttl, &w1_master_driver, &w1_master_device); if (!dev) return -ENOMEM; -- cgit v0.10.2 From 5e8eb8501212eb92826ccf191f9ca8c186f531c3 Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Thu, 11 Aug 2005 13:45:54 +0400 Subject: [PATCH] w1: Fixed 64bit compilation warning. Fixed 64bit compilation warning. Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 9c7777b..b2fe0f7 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -373,7 +373,7 @@ static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffe if (err) return err; - err = add_hotplug_env_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_SLAVE_ID=%024llX", sl->reg_num.id); + err = add_hotplug_env_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_SLAVE_ID=%024LX", (u64)sl->reg_num.id); if (err) return err; -- cgit v0.10.2 From db2d0008de519c5db6baec45f7831e08790301cf Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Thu, 11 Aug 2005 17:27:49 +0400 Subject: [PATCH] w1: Added inline functions on top of container_of(). Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index b2fe0f7..39888af 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -89,15 +89,13 @@ static int w1_master_remove(struct device *dev) static void w1_master_release(struct device *dev) { - struct w1_master *md = container_of(dev, struct w1_master, dev); - + struct w1_master *md = dev_to_w1_master(dev); complete(&md->dev_released); } static void w1_slave_release(struct device *dev) { - struct w1_slave *sl = container_of(dev, struct w1_slave, dev); - + struct w1_slave *sl = dev_to_w1_slave(dev); complete(&sl->dev_released); } @@ -162,7 +160,7 @@ struct device w1_slave_device = { static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_attribute *attr, char *buf) { - struct w1_master *md = container_of(dev, struct w1_master, dev); + struct w1_master *md = dev_to_w1_master(dev); ssize_t count; if (down_interruptible (&md->mutex)) @@ -179,7 +177,7 @@ static ssize_t w1_master_attribute_store_search(struct device * dev, struct device_attribute *attr, const char * buf, size_t count) { - struct w1_master *md = container_of(dev, struct w1_master, dev); + struct w1_master *md = dev_to_w1_master(dev); if (down_interruptible (&md->mutex)) return -EBUSY; @@ -195,7 +193,7 @@ static ssize_t w1_master_attribute_show_search(struct device *dev, struct device_attribute *attr, char *buf) { - struct w1_master *md = container_of(dev, struct w1_master, dev); + struct w1_master *md = dev_to_w1_master(dev); ssize_t count; if (down_interruptible (&md->mutex)) @@ -210,7 +208,7 @@ static ssize_t w1_master_attribute_show_search(struct device *dev, static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct device_attribute *attr, char *buf) { - struct w1_master *md = container_of(dev, struct w1_master, dev); + struct w1_master *md = dev_to_w1_master(dev); ssize_t count; if (down_interruptible(&md->mutex)) @@ -231,7 +229,7 @@ static ssize_t w1_master_attribute_show_timeout(struct device *dev, struct devic static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, struct device_attribute *attr, char *buf) { - struct w1_master *md = container_of(dev, struct w1_master, dev); + struct w1_master *md = dev_to_w1_master(dev); ssize_t count; if (down_interruptible(&md->mutex)) @@ -245,7 +243,7 @@ static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, stru static ssize_t w1_master_attribute_show_attempts(struct device *dev, struct device_attribute *attr, char *buf) { - struct w1_master *md = container_of(dev, struct w1_master, dev); + struct w1_master *md = dev_to_w1_master(dev); ssize_t count; if (down_interruptible(&md->mutex)) @@ -259,7 +257,7 @@ static ssize_t w1_master_attribute_show_attempts(struct device *dev, struct devi static ssize_t w1_master_attribute_show_slave_count(struct device *dev, struct device_attribute *attr, char *buf) { - struct w1_master *md = container_of(dev, struct w1_master, dev); + struct w1_master *md = dev_to_w1_master(dev); ssize_t count; if (down_interruptible(&md->mutex)) @@ -273,7 +271,7 @@ static ssize_t w1_master_attribute_show_slave_count(struct device *dev, struct d static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device_attribute *attr, char *buf) { - struct w1_master *md = container_of(dev, struct w1_master, dev); + struct w1_master *md = dev_to_w1_master(dev); int c = PAGE_SIZE; if (down_interruptible(&md->mutex)) diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index 4f0a986..f830826 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h @@ -191,6 +191,21 @@ struct w1_master int w1_create_master_attributes(struct w1_master *); void w1_search(struct w1_master *dev, w1_slave_found_callback cb); +static inline struct w1_slave* dev_to_w1_slave(struct device *dev) +{ + return container_of(dev, struct w1_slave, dev); +} + +static inline struct w1_slave* kobj_to_w1_slave(struct kobject *kobj) +{ + return dev_to_w1_slave(container_of(kobj, struct device, kobj)); +} + +static inline struct w1_master* dev_to_w1_master(struct device *dev) +{ + return container_of(dev, struct w1_master, dev); +} + #endif /* __KERNEL__ */ #endif /* __W1_H */ diff --git a/drivers/w1/w1_smem.c b/drivers/w1/w1_smem.c index 70d2d46..2b6580c 100644 --- a/drivers/w1/w1_smem.c +++ b/drivers/w1/w1_smem.c @@ -46,15 +46,13 @@ static struct w1_family_ops w1_smem_fops = { static ssize_t w1_smem_read_name(struct device *dev, struct device_attribute *attr, char *buf) { - struct w1_slave *sl = container_of(dev, struct w1_slave, dev); - + struct w1_slave *sl = dev_to_w1_slave(dev); return sprintf(buf, "%s\n", sl->name); } static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) { - struct w1_slave *sl = container_of(container_of(kobj, struct device, kobj), - struct w1_slave, dev); + struct w1_slave *sl = kobj_to_w1_slave(kobj); int i; atomic_inc(&sl->refcnt); diff --git a/drivers/w1/w1_therm.c b/drivers/w1/w1_therm.c index 165526c..2259f3d 100644 --- a/drivers/w1/w1_therm.c +++ b/drivers/w1/w1_therm.c @@ -92,8 +92,7 @@ static struct w1_therm_family_converter w1_therm_families[] = { static ssize_t w1_therm_read_name(struct device *dev, struct device_attribute *attr, char *buf) { - struct w1_slave *sl = container_of(dev, struct w1_slave, dev); - + struct w1_slave *sl = dev_to_w1_slave(dev); return sprintf(buf, "%s\n", sl->name); } @@ -148,8 +147,7 @@ static int w1_therm_check_rom(u8 rom[9]) static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) { - struct w1_slave *sl = container_of(container_of(kobj, struct device, kobj), - struct w1_slave, dev); + struct w1_slave *sl = kobj_to_w1_slave(kobj); struct w1_master *dev = sl->master; u8 rom[9], crc, verdict; int i, max_trying = 10; -- cgit v0.10.2 From ea7d8f65c865ebfa1d7cd67c360a87333ff013c1 Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Thu, 11 Aug 2005 17:27:49 +0400 Subject: [PATCH] w1: Added w1_reset_select_slave() - Resets the bus and then selects the slave by sending either a skip rom or a rom match. Patch from Ben Gardner Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c index 00f0322..e2a0433 100644 --- a/drivers/w1/w1_io.c +++ b/drivers/w1/w1_io.c @@ -277,6 +277,29 @@ void w1_search_devices(struct w1_master *dev, w1_slave_found_callback cb) w1_search(dev, cb); } +/** + * Resets the bus and then selects the slave by sending either a skip rom + * or a rom match. + * The w1 master lock must be held. + * + * @param sl the slave to select + * @return 0=success, anything else=error + */ +int w1_reset_select_slave(struct w1_slave *sl) +{ + if (w1_reset_bus(sl->master)) + return -1; + + if (sl->master->slave_count == 1) + w1_write_8(sl->master, W1_SKIP_ROM); + else { + u8 match[9] = {W1_MATCH_ROM, }; + memcpy(&match[1], (u8 *)&sl->reg_num, 8); + w1_write_block(sl->master, match, 9); + } + return 0; +} + EXPORT_SYMBOL(w1_touch_bit); EXPORT_SYMBOL(w1_write_8); EXPORT_SYMBOL(w1_read_8); @@ -286,3 +309,4 @@ EXPORT_SYMBOL(w1_delay); EXPORT_SYMBOL(w1_read_block); EXPORT_SYMBOL(w1_write_block); EXPORT_SYMBOL(w1_search_devices); +EXPORT_SYMBOL(w1_reset_select_slave); diff --git a/drivers/w1/w1_io.h b/drivers/w1/w1_io.h index af58297..2328601 100644 --- a/drivers/w1/w1_io.h +++ b/drivers/w1/w1_io.h @@ -34,5 +34,6 @@ u8 w1_calc_crc8(u8 *, int); void w1_write_block(struct w1_master *, const u8 *, int); u8 w1_read_block(struct w1_master *, u8 *, int); void w1_search_devices(struct w1_master *dev, w1_slave_found_callback cb); +int w1_reset_select_slave(struct w1_slave *sl); #endif /* __W1_IO_H */ diff --git a/drivers/w1/w1_therm.c b/drivers/w1/w1_therm.c index 2259f3d..2ed0e0f4 100644 --- a/drivers/w1/w1_therm.c +++ b/drivers/w1/w1_therm.c @@ -176,15 +176,10 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si crc = 0; while (max_trying--) { - if (!w1_reset_bus (dev)) { + if (!w1_reset_select_slave(sl)) { int count = 0; - u8 match[9] = {W1_MATCH_ROM, }; unsigned int tm = 750; - memcpy(&match[1], (u64 *) & sl->reg_num, 8); - - w1_write_block(dev, match, 9); - w1_write_8(dev, W1_CONVERT_TEMP); while (tm) { @@ -193,8 +188,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si flush_signals(current); } - if (!w1_reset_bus (dev)) { - w1_write_block(dev, match, 9); + if (!w1_reset_select_slave(sl)) { w1_write_8(dev, W1_READ_SCRATCHPAD); if ((count = w1_read_block(dev, rom, 9)) != 9) { @@ -205,7 +199,6 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si if (rom[8] == crc && rom[0]) verdict = 1; - } } -- cgit v0.10.2 From d2a4ef6a0ce4d841293b49bf2cdc17a0ebfaaf9d Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Thu, 11 Aug 2005 17:27:50 +0400 Subject: [PATCH] w1: Added add/remove slave callbacks. Patch is based on work from Ben Gardner Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 39888af..e592ca2 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -59,19 +59,6 @@ static pid_t control_thread; static int control_needs_exit; static DECLARE_COMPLETION(w1_control_complete); -/* stuff for the default family */ -static ssize_t w1_famdefault_read_name(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct w1_slave *sl = container_of(dev, struct w1_slave, dev); - return(sprintf(buf, "%s\n", sl->name)); -} -static struct w1_family_ops w1_default_fops = { - .rname = &w1_famdefault_read_name, -}; -static struct w1_family w1_default_family = { - .fops = &w1_default_fops, -}; - static int w1_master_match(struct device *dev, struct device_driver *drv) { return 1; @@ -99,30 +86,47 @@ static void w1_slave_release(struct device *dev) complete(&sl->dev_released); } -static ssize_t w1_default_read_name(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t w1_slave_read_name(struct device *dev, struct device_attribute *attr, char *buf) { - return sprintf(buf, "No family registered.\n"); + struct w1_slave *sl = dev_to_w1_slave(dev); + + return sprintf(buf, "%s\n", sl->name); } -static ssize_t w1_default_read_bin(struct kobject *kobj, char *buf, loff_t off, - size_t count) +static ssize_t w1_slave_read_id(struct kobject *kobj, char *buf, loff_t off, size_t count) { - return sprintf(buf, "No family registered.\n"); -} + struct w1_slave *sl = kobj_to_w1_slave(kobj); -static struct device_attribute w1_slave_attribute = - __ATTR(name, S_IRUGO, w1_default_read_name, NULL); - -static struct bin_attribute w1_slave_bin_attribute = { - .attr = { - .name = "w1_slave", - .mode = S_IRUGO, - .owner = THIS_MODULE, - }, - .size = W1_SLAVE_DATA_SIZE, - .read = &w1_default_read_bin, + atomic_inc(&sl->refcnt); + if (off > 8) { + count = 0; + } else { + if (off + count > 8) + count = 8 - off; + + memcpy(buf, (u8 *)&sl->reg_num, count); + } + atomic_dec(&sl->refcnt); + + return count; + } + +static struct device_attribute w1_slave_attr_name = + __ATTR(name, S_IRUGO, w1_slave_read_name, NULL); + +static struct bin_attribute w1_slave_attr_bin_id = { + .attr = { + .name = "id", + .mode = S_IRUGO, + .owner = THIS_MODULE, + }, + .size = 8, + .read = w1_slave_read_id, }; +/* Default family */ +static struct w1_family w1_default_family; + static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); static struct bus_type w1_bus_type = { @@ -413,36 +417,44 @@ static int __w1_attach_slave_device(struct w1_slave *sl) return err; } - memcpy(&sl->attr_bin, &w1_slave_bin_attribute, sizeof(sl->attr_bin)); - memcpy(&sl->attr_name, &w1_slave_attribute, sizeof(sl->attr_name)); - - sl->attr_bin.read = sl->family->fops->rbin; - sl->attr_name.show = sl->family->fops->rname; + /* Create "name" entry */ + err = device_create_file(&sl->dev, &w1_slave_attr_name); + if (err < 0) { + dev_err(&sl->dev, + "sysfs file creation for [%s] failed. err=%d\n", + sl->dev.bus_id, err); + goto out_unreg; + } - err = device_create_file(&sl->dev, &sl->attr_name); + /* Create "id" entry */ + err = sysfs_create_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id); if (err < 0) { dev_err(&sl->dev, "sysfs file creation for [%s] failed. err=%d\n", sl->dev.bus_id, err); - device_unregister(&sl->dev); - return err; + goto out_rem1; } - if ( sl->attr_bin.read ) { - err = sysfs_create_bin_file(&sl->dev.kobj, &sl->attr_bin); - if (err < 0) { - dev_err(&sl->dev, - "sysfs file creation for [%s] failed. err=%d\n", - sl->dev.bus_id, err); - device_remove_file(&sl->dev, &sl->attr_name); - device_unregister(&sl->dev); - return err; - } + /* if the family driver needs to initialize something... */ + if (sl->family->fops && sl->family->fops->add_slave && + ((err = sl->family->fops->add_slave(sl)) < 0)) { + dev_err(&sl->dev, + "sysfs file creation for [%s] failed. err=%d\n", + sl->dev.bus_id, err); + goto out_rem2; } list_add_tail(&sl->w1_slave_entry, &sl->master->slist); return 0; + +out_rem2: + sysfs_remove_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id); +out_rem1: + device_remove_file(&sl->dev, &w1_slave_attr_name); +out_unreg: + device_unregister(&sl->dev); + return err; } static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn) @@ -517,10 +529,11 @@ static void w1_slave_detach(struct w1_slave *sl) flush_signals(current); } - if ( sl->attr_bin.read ) { - sysfs_remove_bin_file (&sl->dev.kobj, &sl->attr_bin); - } - device_remove_file(&sl->dev, &sl->attr_name); + if (sl->family->fops && sl->family->fops->remove_slave) + sl->family->fops->remove_slave(sl); + + sysfs_remove_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id); + device_remove_file(&sl->dev, &w1_slave_attr_name); device_unregister(&sl->dev); w1_family_put(sl->family); @@ -805,8 +818,8 @@ int w1_process(void *data) if (!test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags) && !--sl->ttl) { list_del (&sl->w1_slave_entry); - w1_slave_detach (sl); - kfree (sl); + w1_slave_detach(sl); + kfree(sl); dev->slave_count--; } else if (test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags)) diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index f830826..13edc82 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h @@ -77,9 +77,6 @@ struct w1_slave struct w1_family *family; struct device dev; struct completion dev_released; - - struct bin_attribute attr_bin; - struct device_attribute attr_name; }; typedef void (* w1_slave_found_callback)(unsigned long, u64); diff --git a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c index 02eee57..88c517a 100644 --- a/drivers/w1/w1_family.c +++ b/drivers/w1/w1_family.c @@ -29,23 +29,12 @@ DEFINE_SPINLOCK(w1_flock); static LIST_HEAD(w1_families); extern void w1_reconnect_slaves(struct w1_family *f); -static int w1_check_family(struct w1_family *f) -{ - if (!f->fops->rname || !f->fops->rbin) - return -EINVAL; - - return 0; -} - int w1_register_family(struct w1_family *newf) { struct list_head *ent, *n; struct w1_family *f; int ret = 0; - if (w1_check_family(newf)) - return -EINVAL; - spin_lock(&w1_flock); list_for_each_safe(ent, n, &w1_families) { f = list_entry(ent, struct w1_family, family_entry); diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h index b26da01..0a564a0 100644 --- a/drivers/w1/w1_family.h +++ b/drivers/w1/w1_family.h @@ -35,10 +35,12 @@ #define MAXNAMELEN 32 +struct w1_slave; + struct w1_family_ops { - ssize_t (* rname)(struct device *, struct device_attribute *, char *); - ssize_t (* rbin)(struct kobject *, char *, loff_t, size_t); + int (* add_slave)(struct w1_slave *); + void (* remove_slave)(struct w1_slave *); }; struct w1_family diff --git a/drivers/w1/w1_smem.c b/drivers/w1/w1_smem.c index 2b6580c..e3209d0 100644 --- a/drivers/w1/w1_smem.c +++ b/drivers/w1/w1_smem.c @@ -36,59 +36,12 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Evgeniy Polyakov "); MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family."); -static ssize_t w1_smem_read_name(struct device *, struct device_attribute *attr, char *); -static ssize_t w1_smem_read_bin(struct kobject *, char *, loff_t, size_t); - -static struct w1_family_ops w1_smem_fops = { - .rname = &w1_smem_read_name, - .rbin = &w1_smem_read_bin, -}; - -static ssize_t w1_smem_read_name(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct w1_slave *sl = dev_to_w1_slave(dev); - return sprintf(buf, "%s\n", sl->name); -} - -static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) -{ - struct w1_slave *sl = kobj_to_w1_slave(kobj); - int i; - - atomic_inc(&sl->refcnt); - if (down_interruptible(&sl->master->mutex)) { - count = 0; - goto out_dec; - } - - if (off > W1_SLAVE_DATA_SIZE) { - count = 0; - goto out; - } - if (off + count > W1_SLAVE_DATA_SIZE) { - count = 0; - goto out; - } - for (i = 0; i < 8; ++i) - count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]); - count += sprintf(buf + count, "\n"); - -out: - up(&sl->master->mutex); -out_dec: - atomic_dec(&sl->refcnt); - - return count; -} - static struct w1_family w1_smem_family_01 = { .fid = W1_FAMILY_SMEM_01, - .fops = &w1_smem_fops, }; static struct w1_family w1_smem_family_81 = { .fid = W1_FAMILY_SMEM_81, - .fops = &w1_smem_fops, }; static int __init w1_smem_init(void) diff --git a/drivers/w1/w1_therm.c b/drivers/w1/w1_therm.c index 2ed0e0f4..4577df3 100644 --- a/drivers/w1/w1_therm.c +++ b/drivers/w1/w1_therm.c @@ -42,12 +42,31 @@ static u8 bad_roms[][9] = { {} }; -static ssize_t w1_therm_read_name(struct device *, struct device_attribute *attr, char *); static ssize_t w1_therm_read_bin(struct kobject *, char *, loff_t, size_t); +static struct bin_attribute w1_therm_bin_attr = { + .attr = { + .name = "w1_slave", + .mode = S_IRUGO, + .owner = THIS_MODULE, + }, + .size = W1_SLAVE_DATA_SIZE, + .read = w1_therm_read_bin, +}; + +static int w1_therm_add_slave(struct w1_slave *sl) +{ + return sysfs_create_bin_file(&sl->dev.kobj, &w1_therm_bin_attr); +} + +static void w1_therm_remove_slave(struct w1_slave *sl) +{ + sysfs_remove_bin_file(&sl->dev.kobj, &w1_therm_bin_attr); +} + static struct w1_family_ops w1_therm_fops = { - .rname = &w1_therm_read_name, - .rbin = &w1_therm_read_bin, + .add_slave = w1_therm_add_slave, + .remove_slave = w1_therm_remove_slave, }; static struct w1_family w1_therm_family_DS18S20 = { @@ -59,6 +78,7 @@ static struct w1_family w1_therm_family_DS18B20 = { .fid = W1_THERM_DS18B20, .fops = &w1_therm_fops, }; + static struct w1_family w1_therm_family_DS1822 = { .fid = W1_THERM_DS1822, .fops = &w1_therm_fops, @@ -90,12 +110,6 @@ static struct w1_therm_family_converter w1_therm_families[] = { }, }; -static ssize_t w1_therm_read_name(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct w1_slave *sl = dev_to_w1_slave(dev); - return sprintf(buf, "%s\n", sl->name); -} - static inline int w1_DS18B20_convert_temp(u8 rom[9]) { int t = (rom[1] << 8) | rom[0]; -- cgit v0.10.2 From 3aca692d3ec7cf89da4575f598e41f74502b22d7 Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Thu, 11 Aug 2005 17:27:50 +0400 Subject: [PATCH] w1: Detouching bug fixed. Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index e592ca2..4e98ab1 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -45,10 +45,12 @@ MODULE_AUTHOR("Evgeniy Polyakov "); MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol."); static int w1_timeout = 10; +static int w1_control_timeout = 1; int w1_max_slave_count = 10; int w1_max_slave_ttl = 10; module_param_named(timeout, w1_timeout, int, 0); +module_param_named(control_timeout, w1_control_timeout, int, 0); module_param_named(max_slave_count, w1_max_slave_count, int, 0); module_param_named(slave_ttl, w1_max_slave_ttl, int, 0); @@ -69,37 +71,51 @@ static int w1_master_probe(struct device *dev) return -ENODEV; } -static int w1_master_remove(struct device *dev) -{ - return 0; -} - static void w1_master_release(struct device *dev) { struct w1_master *md = dev_to_w1_master(dev); - complete(&md->dev_released); + + dev_dbg(dev, "%s: Releasing %s.\n", __func__, md->name); + + if (md->nls && md->nls->sk_socket) + sock_release(md->nls->sk_socket); + memset(md, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master)); + kfree(md); } static void w1_slave_release(struct device *dev) { struct w1_slave *sl = dev_to_w1_slave(dev); - complete(&sl->dev_released); + + dev_dbg(dev, "%s: Releasing %s.\n", __func__, sl->name); + + while (atomic_read(&sl->refcnt)) { + dev_dbg(dev, "Waiting for %s to become free: refcnt=%d.\n", + sl->name, atomic_read(&sl->refcnt)); + if (msleep_interruptible(1000)) + flush_signals(current); + } + + w1_family_put(sl->family); + sl->master->slave_count--; + + complete(&sl->released); } static ssize_t w1_slave_read_name(struct device *dev, struct device_attribute *attr, char *buf) { - struct w1_slave *sl = dev_to_w1_slave(dev); + struct w1_slave *sl = dev_to_w1_slave(dev); - return sprintf(buf, "%s\n", sl->name); + return sprintf(buf, "%s\n", sl->name); } static ssize_t w1_slave_read_id(struct kobject *kobj, char *buf, loff_t off, size_t count) { - struct w1_slave *sl = kobj_to_w1_slave(kobj); + struct w1_slave *sl = kobj_to_w1_slave(kobj); - atomic_inc(&sl->refcnt); - if (off > 8) { - count = 0; + atomic_inc(&sl->refcnt); + if (off > 8) { + count = 0; } else { if (off + count > 8) count = 8 - off; @@ -109,7 +125,7 @@ static ssize_t w1_slave_read_id(struct kobject *kobj, char *buf, loff_t off, siz atomic_dec(&sl->refcnt); return count; - } +} static struct device_attribute w1_slave_attr_name = __ATTR(name, S_IRUGO, w1_slave_read_name, NULL); @@ -139,7 +155,6 @@ struct device_driver w1_master_driver = { .name = "w1_master_driver", .bus = &w1_bus_type, .probe = w1_master_probe, - .remove = w1_master_remove, }; struct device w1_master_device = { @@ -160,6 +175,7 @@ struct device w1_slave_device = { .bus = &w1_bus_type, .bus_id = "w1 bus slave", .driver = &w1_slave_driver, + .release = &w1_slave_release }; static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_attribute *attr, char *buf) @@ -406,8 +422,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl) (unsigned int) sl->reg_num.family, (unsigned long long) sl->reg_num.id); - dev_dbg(&sl->dev, "%s: registering %s.\n", __func__, - &sl->dev.bus_id[0]); + dev_dbg(&sl->dev, "%s: registering %s as %p.\n", __func__, &sl->dev.bus_id[0]); err = device_register(&sl->dev); if (err < 0) { @@ -480,7 +495,7 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn) memcpy(&sl->reg_num, rn, sizeof(sl->reg_num)); atomic_set(&sl->refcnt, 0); - init_completion(&sl->dev_released); + init_completion(&sl->released); spin_lock(&w1_flock); f = w1_family_registered(rn->family); @@ -512,6 +527,8 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn) msg.type = W1_SLAVE_ADD; w1_netlink_send(dev, &msg); + dev_info(&dev->dev, "Finished %s for sl=%p.\n", __func__, sl); + return 0; } @@ -519,29 +536,23 @@ static void w1_slave_detach(struct w1_slave *sl) { struct w1_netlink_msg msg; - dev_info(&sl->dev, "%s: detaching %s.\n", __func__, sl->name); + dev_info(&sl->dev, "%s: detaching %s [%p].\n", __func__, sl->name, sl); - while (atomic_read(&sl->refcnt)) { - printk(KERN_INFO "Waiting for %s to become free: refcnt=%d.\n", - sl->name, atomic_read(&sl->refcnt)); - - if (msleep_interruptible(1000)) - flush_signals(current); - } + list_del(&sl->w1_slave_entry); if (sl->family->fops && sl->family->fops->remove_slave) sl->family->fops->remove_slave(sl); + memcpy(&msg.id.id, &sl->reg_num, sizeof(msg.id.id)); + msg.type = W1_SLAVE_REMOVE; + w1_netlink_send(sl->master, &msg); + sysfs_remove_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id); device_remove_file(&sl->dev, &w1_slave_attr_name); device_unregister(&sl->dev); - w1_family_put(sl->family); - sl->master->slave_count--; - - memcpy(&msg.id.id, &sl->reg_num, sizeof(msg.id.id)); - msg.type = W1_SLAVE_REMOVE; - w1_netlink_send(sl->master, &msg); + wait_for_completion(&sl->released); + kfree(sl); } static struct w1_master *w1_search_master(unsigned long data) @@ -713,7 +724,7 @@ static int w1_control(void *data) have_to_wait = 0; try_to_freeze(); - msleep_interruptible(w1_timeout * 1000); + msleep_interruptible(w1_control_timeout * 1000); if (signal_pending(current)) flush_signals(current); @@ -746,13 +757,12 @@ static int w1_control(void *data) list_del(&dev->w1_master_entry); spin_unlock_bh(&w1_mlock); + down(&dev->mutex); list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { - list_del(&sl->w1_slave_entry); - w1_slave_detach(sl); - kfree(sl); } w1_destroy_master_attributes(dev); + up(&dev->mutex); atomic_dec(&dev->refcnt); continue; } @@ -760,19 +770,17 @@ static int w1_control(void *data) if (test_bit(W1_MASTER_NEED_RECONNECT, &dev->flags)) { dev_info(&dev->dev, "Reconnecting slaves in device %s.\n", dev->name); down(&dev->mutex); - list_for_each_entry(sl, &dev->slist, w1_slave_entry) { + list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { if (sl->family->fid == W1_FAMILY_DEFAULT) { struct w1_reg_num rn; - list_del(&sl->w1_slave_entry); - w1_slave_detach(sl); memcpy(&rn, &sl->reg_num, sizeof(rn)); - - kfree(sl); + w1_slave_detach(sl); w1_attach_slave_device(dev, &rn); } } + dev_info(&dev->dev, "Reconnecting slaves in device %s has been finished.\n", dev->name); clear_bit(W1_MASTER_NEED_RECONNECT, &dev->flags); up(&dev->mutex); } @@ -816,10 +824,7 @@ int w1_process(void *data) list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { if (!test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags) && !--sl->ttl) { - list_del (&sl->w1_slave_entry); - w1_slave_detach(sl); - kfree(sl); dev->slave_count--; } else if (test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags)) diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index 13edc82..6cc7f0c 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h @@ -76,7 +76,7 @@ struct w1_slave struct w1_master *master; struct w1_family *family; struct device dev; - struct completion dev_released; + struct completion released; }; typedef void (* w1_slave_found_callback)(unsigned long, u64); @@ -176,7 +176,6 @@ struct w1_master struct device_driver *driver; struct device dev; - struct completion dev_released; struct completion dev_exited; struct w1_bus_master *bus_master; diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c index c13724f..c3f67ea 100644 --- a/drivers/w1/w1_int.c +++ b/drivers/w1/w1_int.c @@ -76,7 +76,6 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, INIT_LIST_HEAD(&dev->slist); init_MUTEX(&dev->mutex); - init_completion(&dev->dev_released); init_completion(&dev->dev_exited); memcpy(&dev->dev, device, sizeof(struct device)); @@ -107,9 +106,6 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, void w1_free_dev(struct w1_master *dev) { device_unregister(&dev->dev); - dev_fini_netlink(dev); - memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master)); - kfree(dev); } int w1_add_master_device(struct w1_bus_master *master) @@ -184,7 +180,7 @@ void __w1_remove_master_device(struct w1_master *dev) __func__, dev->kpid); while (atomic_read(&dev->refcnt)) { - printk(KERN_INFO "Waiting for %s to become free: refcnt=%d.\n", + dev_dbg(&dev->dev, "Waiting for %s to become free: refcnt=%d.\n", dev->name, atomic_read(&dev->refcnt)); if (msleep_interruptible(1000)) -- cgit v0.10.2 From 7c8f5703de91ade517d4fd6c3cc8e08dbba2b739 Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Thu, 11 Aug 2005 17:27:50 +0400 Subject: [PATCH] w1: Decreased debug level. Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 4e98ab1..1b6b74c 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -527,8 +527,6 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn) msg.type = W1_SLAVE_ADD; w1_netlink_send(dev, &msg); - dev_info(&dev->dev, "Finished %s for sl=%p.\n", __func__, sl); - return 0; } @@ -536,7 +534,7 @@ static void w1_slave_detach(struct w1_slave *sl) { struct w1_netlink_msg msg; - dev_info(&sl->dev, "%s: detaching %s [%p].\n", __func__, sl->name, sl); + dev_dbg(&sl->dev, "%s: detaching %s [%p].\n", __func__, sl->name, sl); list_del(&sl->w1_slave_entry); @@ -579,7 +577,7 @@ void w1_reconnect_slaves(struct w1_family *f) spin_lock_bh(&w1_mlock); list_for_each_entry(dev, &w1_masters, w1_master_entry) { - dev_info(&dev->dev, "Reconnecting slaves in %s into new family %02x.\n", + dev_dbg(&dev->dev, "Reconnecting slaves in %s into new family %02x.\n", dev->name, f->fid); set_bit(W1_MASTER_NEED_RECONNECT, &dev->flags); } @@ -768,7 +766,7 @@ static int w1_control(void *data) } if (test_bit(W1_MASTER_NEED_RECONNECT, &dev->flags)) { - dev_info(&dev->dev, "Reconnecting slaves in device %s.\n", dev->name); + dev_dbg(&dev->dev, "Reconnecting slaves in device %s.\n", dev->name); down(&dev->mutex); list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { if (sl->family->fid == W1_FAMILY_DEFAULT) { @@ -780,7 +778,7 @@ static int w1_control(void *data) w1_attach_slave_device(dev, &rn); } } - dev_info(&dev->dev, "Reconnecting slaves in device %s has been finished.\n", dev->name); + dev_dbg(&dev->dev, "Reconnecting slaves in device %s has been finished.\n", dev->name); clear_bit(W1_MASTER_NEED_RECONNECT, &dev->flags); up(&dev->mutex); } -- cgit v0.10.2 From 80895392c83e54653540e72e7d40573aac7ee690 Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Thu, 11 Aug 2005 17:27:50 +0400 Subject: [PATCH] w1: Added DS2433 driver. Work by Ben Gardner . Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig index 711b909..1d5d087 100644 --- a/drivers/w1/Kconfig +++ b/drivers/w1/Kconfig @@ -54,4 +54,11 @@ config W1_SMEM Say Y here if you want to connect 1-wire simple 64bit memory rom(ds2401/ds2411/ds1990*) to you wire. +config W1_DS2433 + tristate "4kb EEPROM family support (DS2433)" + depends on W1 + help + Say Y here if you want to use a 1-wire + 4kb EEPROM family device (DS2433). + endmenu diff --git a/drivers/w1/Makefile b/drivers/w1/Makefile index 80725c3..d894a98 100644 --- a/drivers/w1/Makefile +++ b/drivers/w1/Makefile @@ -18,3 +18,4 @@ ds9490r-objs := dscore.o obj-$(CONFIG_W1_DS9490_BRIDGE) += ds_w1_bridge.o +obj-$(CONFIG_W1_DS2433) += w1_ds2433.o diff --git a/drivers/w1/w1_ds2433.c b/drivers/w1/w1_ds2433.c new file mode 100644 index 0000000..9ec9163 --- /dev/null +++ b/drivers/w1/w1_ds2433.c @@ -0,0 +1,222 @@ +/* + * w1_ds2433.c - w1 family 23 (DS2433) driver + * + * Copyright (c) 2005 Ben Gardner + * + * This program is free software; you can redistribute it and/or modify + * it under the smems of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + */ + +#include +#include +#include +#include +#include +#include + +#include "w1.h" +#include "w1_io.h" +#include "w1_int.h" +#include "w1_family.h" + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Ben Gardner "); +MODULE_DESCRIPTION("w1 family 23 driver for DS2433, 4kb EEPROM"); + +#define W1_EEPROM_SIZE 512 +#define W1_PAGE_SIZE 32 +#define W1_PAGE_BITS 5 +#define W1_PAGE_MASK 0x1F + +#define W1_F23_READ_EEPROM 0xF0 +#define W1_F23_WRITE_SCRATCH 0x0F +#define W1_F23_READ_SCRATCH 0xAA +#define W1_F23_COPY_SCRATCH 0x55 + +/** + * Check the file size bounds and adjusts count as needed. + * This may not be needed if the sysfs layer checks bounds. + */ +static inline size_t w1_f23_fix_count(loff_t off, size_t count, size_t size) +{ + if (off > size) + return 0; + + if ((off + count) > size) + return (size - off); + + return count; +} + +static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) +{ + struct w1_slave *sl = kobj_to_w1_slave(kobj); + u8 wrbuf[3]; + + if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0) + return 0; + + atomic_inc(&sl->refcnt); + if (down_interruptible(&sl->master->mutex)) { + count = 0; + goto out_dec; + } + + /* read directly from the EEPROM */ + if (w1_reset_select_slave(sl)) { + count = -EIO; + goto out_up; + } + + wrbuf[0] = W1_F23_READ_EEPROM; + wrbuf[1] = off & 0xff; + wrbuf[2] = off >> 8; + w1_write_block(sl->master, wrbuf, 3); + w1_read_block(sl->master, buf, count); + +out_up: + up(&sl->master->mutex); +out_dec: + atomic_dec(&sl->refcnt); + + return count; +} + +/** + * Writes to the scratchpad and reads it back for verification. + * The master must be locked. + * + * @param sl The slave structure + * @param addr Address for the write + * @param len length must be <= (W1_PAGE_SIZE - (addr & W1_PAGE_MASK)) + * @param data The data to write + * @return 0=Success -1=failure + */ +static int w1_f23_write(struct w1_slave *sl, int addr, int len, const u8 *data) +{ + u8 wrbuf[4]; + u8 rdbuf[W1_PAGE_SIZE + 3]; + u8 es = (addr + len - 1) & 0x1f; + + /* Write the data to the scratchpad */ + if (w1_reset_select_slave(sl)) + return -1; + + wrbuf[0] = W1_F23_WRITE_SCRATCH; + wrbuf[1] = addr & 0xff; + wrbuf[2] = addr >> 8; + + w1_write_block(sl->master, wrbuf, 3); + w1_write_block(sl->master, data, len); + + /* Read the scratchpad and verify */ + if (w1_reset_select_slave(sl)) + return -1; + + w1_write_8(sl->master, W1_F23_READ_SCRATCH); + w1_read_block(sl->master, rdbuf, len + 3); + + /* Compare what was read against the data written */ + if ((rdbuf[0] != wrbuf[1]) || (rdbuf[1] != wrbuf[2]) || + (rdbuf[2] != es) || (memcmp(data, &rdbuf[3], len) != 0)) + return -1; + + /* Copy the scratchpad to EEPROM */ + if (w1_reset_select_slave(sl)) + return -1; + + wrbuf[0] = W1_F23_COPY_SCRATCH; + wrbuf[3] = es; + w1_write_block(sl->master, wrbuf, 4); + + /* Sleep for 5 ms to wait for the write to complete */ + msleep(5); + + /* Reset the bus to wake up the EEPROM (this may not be needed) */ + w1_reset_bus(sl->master); + + return 0; +} + +static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off, + size_t count) +{ + struct w1_slave *sl = kobj_to_w1_slave(kobj); + int addr, len, idx; + + if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0) + return 0; + + atomic_inc(&sl->refcnt); + if (down_interruptible(&sl->master->mutex)) { + count = 0; + goto out_dec; + } + + /* Can only write data to one page at a time */ + idx = 0; + while (idx < count) { + addr = off + idx; + len = W1_PAGE_SIZE - (addr & W1_PAGE_MASK); + if (len > (count - idx)) + len = count - idx; + + if (w1_f23_write(sl, addr, len, &buf[idx]) < 0) { + count = -EIO; + goto out_up; + } + idx += len; + } + +out_up: + up(&sl->master->mutex); +out_dec: + atomic_dec(&sl->refcnt); + + return count; +} + +static struct bin_attribute w1_f23_bin_attr = { + .attr = { + .name = "eeprom", + .mode = S_IRUGO | S_IWUSR, + .owner = THIS_MODULE, + }, + .size = W1_EEPROM_SIZE, + .read = w1_f23_read_bin, + .write = w1_f23_write_bin, +}; + +static int w1_f23_add_slave(struct w1_slave *sl) +{ + return sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); +} + +static void w1_f23_remove_slave(struct w1_slave *sl) +{ + sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); +} + +static struct w1_family_ops w1_f23_fops = { + .add_slave = w1_f23_add_slave, + .remove_slave = w1_f23_remove_slave, +}; + +static struct w1_family w1_family_23 = { + .fid = W1_EEPROM_DS2433, + .fops = &w1_f23_fops, +}; + +static int __init w1_f23_init(void) +{ + return w1_register_family(&w1_family_23); +} + +static void __exit w1_f23_fini(void) +{ + w1_unregister_family(&w1_family_23); +} + +module_init(w1_f23_init); +module_exit(w1_f23_fini); -- cgit v0.10.2 From a3d65f254274567daa89d8b99ab3d481d60fcaef Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Thu, 11 Aug 2005 17:27:50 +0400 Subject: [PATCH] w1: Added DS2433 driver - family id update. Work by Ben Gardner . Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h index 0a564a0..2ca0489 100644 --- a/drivers/w1/w1_family.h +++ b/drivers/w1/w1_family.h @@ -31,6 +31,7 @@ #define W1_FAMILY_SMEM_81 0x81 #define W1_THERM_DS18S20 0x10 #define W1_THERM_DS1822 0x22 +#define W1_EEPROM_DS2433 0x23 #define W1_THERM_DS18B20 0x28 #define MAXNAMELEN 32 -- cgit v0.10.2 From 7657ec1fcb69e266ab876af56332d0c484ca6d00 Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Wed, 17 Aug 2005 15:17:26 +0400 Subject: [PATCH] lib/crc16: added crc16 algorithm. Add the crc16 routines, as used by w1 devices. Signed-off-by: Ben Gardner Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/crc16.h b/include/linux/crc16.h new file mode 100644 index 0000000..bdedf82 --- /dev/null +++ b/include/linux/crc16.h @@ -0,0 +1,44 @@ +/* + * crc16.h - CRC-16 routine + * + * Implements the standard CRC-16, as used with 1-wire devices: + * Width 16 + * Poly 0x8005 (x^16 + x^15 + x^2 + 1) + * Init 0 + * + * For 1-wire devices, the CRC is stored inverted, LSB-first + * + * Example buffer with the CRC attached: + * 31 32 33 34 35 36 37 38 39 C2 44 + * + * The CRC over a buffer with the CRC attached is 0xB001. + * So, if (crc16(0, buf, size) == 0xB001) then the buffer is valid. + * + * Refer to "Application Note 937: Book of iButton Standards" for details. + * http://www.maxim-ic.com/appnotes.cfm/appnote_number/937 + * + * Copyright (c) 2005 Ben Gardner + * + * This source code is licensed under the GNU General Public License, + * Version 2. See the file COPYING for more details. + */ + +#ifndef __CRC16_H +#define __CRC16_H + +#include + +#define CRC16_INIT 0 +#define CRC16_VALID 0xb001 + +extern u16 const crc16_table[256]; + +extern u16 crc16(u16 crc, const u8 *buffer, size_t len); + +static inline u16 crc16_byte(u16 crc, const u8 data) +{ + return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff]; +} + +#endif /* __CRC16_H */ + diff --git a/lib/Kconfig b/lib/Kconfig index e43197e..3de9335 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -12,6 +12,14 @@ config CRC_CCITT the kernel tree does. Such modules that use library CRC-CCITT functions require M here. +config CRC16 + tristate "CRC16 functions" + help + This option is provided for the case where no in-kernel-tree + modules require CRC16 functions, but a module built outside + the kernel tree does. Such modules that use library CRC16 + functions require M here. + config CRC32 tristate "CRC32 functions" default y diff --git a/lib/Makefile b/lib/Makefile index 3e2bd0d..d9c38ba 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -23,11 +23,12 @@ lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o -ifneq ($(CONFIG_HAVE_DEC_LOCK),y) +ifneq ($(CONFIG_HAVE_DEC_LOCK),y) lib-y += dec_and_lock.o endif obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o +obj-$(CONFIG_CRC16) += crc16.o obj-$(CONFIG_CRC32) += crc32.o obj-$(CONFIG_LIBCRC32C) += libcrc32c.o obj-$(CONFIG_GENERIC_IOMAP) += iomap.o diff --git a/lib/crc16.c b/lib/crc16.c new file mode 100644 index 0000000..011fe57 --- /dev/null +++ b/lib/crc16.c @@ -0,0 +1,67 @@ +/* + * crc16.c + * + * This source code is licensed under the GNU General Public License, + * Version 2. See the file COPYING for more details. + */ + +#include +#include +#include + +/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */ +u16 const crc16_table[256] = { + 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, + 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, + 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, + 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, + 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, + 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, + 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, + 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, + 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, + 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, + 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, + 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, + 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, + 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, + 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, + 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041, + 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, + 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441, + 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, + 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, + 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, + 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, + 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, + 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, + 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, + 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440, + 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, + 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, + 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, + 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, + 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, + 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 +}; +EXPORT_SYMBOL(crc16_table); + +/** + * Compute the CRC-16 for the data buffer + * + * @param crc previous CRC value + * @param buffer data pointer + * @param len number of bytes in the buffer + * @return the updated CRC value + */ +u16 crc16(u16 crc, u8 const *buffer, size_t len) +{ + while (len--) + crc = crc16_byte(crc, *buffer++); + return crc; +} +EXPORT_SYMBOL(crc16); + +MODULE_DESCRIPTION("CRC16 calculations"); +MODULE_LICENSE("GPL"); + -- cgit v0.10.2 From a45f105ad4b456f99f622642056ae533f70710b7 Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Wed, 17 Aug 2005 15:19:08 +0400 Subject: [PATCH] w1: added private family data into w1_slave strucutre. Add family_data to struct w1_slave. Signed-off-by: Ben Gardner Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index 6cc7f0c..d890078 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h @@ -75,6 +75,7 @@ struct w1_slave struct w1_master *master; struct w1_family *family; + void *family_data; struct device dev; struct completion released; }; -- cgit v0.10.2 From 0a25e4d5647003a32ba5496f9d0f40ba9c1e3863 Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Wed, 17 Aug 2005 15:24:37 +0400 Subject: [PATCH] w1_ds2433: Added crc16 protection and read caching. The changes to ds2433 to add CRC16 protection and read caching. Signed-off-by: Ben Gardner Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig index 1d5d087..9a1e00d 100644 --- a/drivers/w1/Kconfig +++ b/drivers/w1/Kconfig @@ -61,4 +61,13 @@ config W1_DS2433 Say Y here if you want to use a 1-wire 4kb EEPROM family device (DS2433). +config W1_DS2433_CRC + bool "Protect DS2433 data with a CRC16" + depends on W1_DS2433 + select CRC16 + help + Say Y here to protect DS2433 data with a CRC16. + Each block has 30 bytes of data and a two byte CRC16. + Full block writes are only allowed if the CRC is valid. + endmenu diff --git a/drivers/w1/Makefile b/drivers/w1/Makefile index d894a98..01fb543 100644 --- a/drivers/w1/Makefile +++ b/drivers/w1/Makefile @@ -6,6 +6,10 @@ ifneq ($(CONFIG_NET), y) EXTRA_CFLAGS += -DNETLINK_DISABLED endif +ifeq ($(CONFIG_W1_DS2433_CRC), y) +EXTRA_CFLAGS += -DCONFIG_W1_F23_CRC +endif + obj-$(CONFIG_W1) += wire.o wire-objs := w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o @@ -13,7 +17,7 @@ obj-$(CONFIG_W1_MATROX) += matrox_w1.o obj-$(CONFIG_W1_THERM) += w1_therm.o obj-$(CONFIG_W1_SMEM) += w1_smem.o -obj-$(CONFIG_W1_DS9490) += ds9490r.o +obj-$(CONFIG_W1_DS9490) += ds9490r.o ds9490r-objs := dscore.o obj-$(CONFIG_W1_DS9490_BRIDGE) += ds_w1_bridge.o diff --git a/drivers/w1/w1_ds2433.c b/drivers/w1/w1_ds2433.c index 9ec9163..b7c24b3 100644 --- a/drivers/w1/w1_ds2433.c +++ b/drivers/w1/w1_ds2433.c @@ -3,9 +3,8 @@ * * Copyright (c) 2005 Ben Gardner * - * This program is free software; you can redistribute it and/or modify - * it under the smems of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * This source code is licensed under the GNU General Public License, + * Version 2. See the file COPYING for more details. */ #include @@ -14,6 +13,9 @@ #include #include #include +#ifdef CONFIG_W1_F23_CRC +#include +#endif #include "w1.h" #include "w1_io.h" @@ -25,18 +27,26 @@ MODULE_AUTHOR("Ben Gardner "); MODULE_DESCRIPTION("w1 family 23 driver for DS2433, 4kb EEPROM"); #define W1_EEPROM_SIZE 512 +#define W1_PAGE_COUNT 16 #define W1_PAGE_SIZE 32 #define W1_PAGE_BITS 5 #define W1_PAGE_MASK 0x1F +#define W1_F23_TIME 300 + #define W1_F23_READ_EEPROM 0xF0 #define W1_F23_WRITE_SCRATCH 0x0F #define W1_F23_READ_SCRATCH 0xAA #define W1_F23_COPY_SCRATCH 0x55 +struct w1_f23_data { + u8 memory[W1_EEPROM_SIZE]; + u32 validcrc; +}; + /** * Check the file size bounds and adjusts count as needed. - * This may not be needed if the sysfs layer checks bounds. + * This would not be needed if the file size didn't reset to 0 after a write. */ static inline size_t w1_f23_fix_count(loff_t off, size_t count, size_t size) { @@ -49,10 +59,45 @@ static inline size_t w1_f23_fix_count(loff_t off, size_t count, size_t size) return count; } -static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) +#ifdef CONFIG_W1_F23_CRC +static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data, + int block) +{ + u8 wrbuf[3]; + int off = block * W1_PAGE_SIZE; + + if (data->validcrc & (1 << block)) + return 0; + + if (w1_reset_select_slave(sl)) { + data->validcrc = 0; + return -EIO; + } + + wrbuf[0] = W1_F23_READ_EEPROM; + wrbuf[1] = off & 0xff; + wrbuf[2] = off >> 8; + w1_write_block(sl->master, wrbuf, 3); + w1_read_block(sl->master, &data->memory[off], W1_PAGE_SIZE); + + /* cache the block if the CRC is valid */ + if (crc16(CRC16_INIT, &data->memory[off], W1_PAGE_SIZE) == CRC16_VALID) + data->validcrc |= (1 << block); + + return 0; +} +#endif /* CONFIG_W1_F23_CRC */ + +static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off, + size_t count) { struct w1_slave *sl = kobj_to_w1_slave(kobj); +#ifdef CONFIG_W1_F23_CRC + struct w1_f23_data *data = sl->family_data; + int i, min_page, max_page; +#else u8 wrbuf[3]; +#endif if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0) return 0; @@ -63,6 +108,20 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off, size goto out_dec; } +#ifdef CONFIG_W1_F23_CRC + + min_page = (off >> W1_PAGE_BITS); + max_page = (off + count - 1) >> W1_PAGE_BITS; + for (i = min_page; i <= max_page; i++) { + if (w1_f23_refresh_block(sl, data, i)) { + count = -EIO; + goto out_up; + } + } + memcpy(buf, &data->memory[off], count); + +#else /* CONFIG_W1_F23_CRC */ + /* read directly from the EEPROM */ if (w1_reset_select_slave(sl)) { count = -EIO; @@ -75,6 +134,8 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off, size w1_write_block(sl->master, wrbuf, 3); w1_read_block(sl->master, buf, count); +#endif /* CONFIG_W1_F23_CRC */ + out_up: up(&sl->master->mutex); out_dec: @@ -85,6 +146,8 @@ out_dec: /** * Writes to the scratchpad and reads it back for verification. + * Then copies the scratchpad to EEPROM. + * The data must be on one page. * The master must be locked. * * @param sl The slave structure @@ -148,6 +211,23 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off, if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0) return 0; +#ifdef CONFIG_W1_F23_CRC + /* can only write full blocks in cached mode */ + if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) { + dev_err(&sl->dev, "invalid offset/count off=%d cnt=%d\n", + (int)off, count); + return -EINVAL; + } + + /* make sure the block CRCs are valid */ + for (idx = 0; idx < count; idx += W1_PAGE_SIZE) { + if (crc16(CRC16_INIT, &buf[idx], W1_PAGE_SIZE) != CRC16_VALID) { + dev_err(&sl->dev, "bad CRC at offset %d\n", (int)off); + return -EINVAL; + } + } +#endif /* CONFIG_W1_F23_CRC */ + atomic_inc(&sl->refcnt); if (down_interruptible(&sl->master->mutex)) { count = 0; @@ -190,11 +270,36 @@ static struct bin_attribute w1_f23_bin_attr = { static int w1_f23_add_slave(struct w1_slave *sl) { - return sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); + int err; +#ifdef CONFIG_W1_F23_CRC + struct w1_f23_data *data; + + data = kmalloc(sizeof(struct w1_f23_data), GFP_KERNEL); + if (!data) + return -ENOMEM; + memset(data, 0, sizeof(struct w1_f23_data)); + sl->family_data = data; + +#endif /* CONFIG_W1_F23_CRC */ + + err = sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); + +#ifdef CONFIG_W1_F23_CRC + if (err) + kfree(data); +#endif /* CONFIG_W1_F23_CRC */ + + return err; } static void w1_f23_remove_slave(struct w1_slave *sl) { +#ifdef CONFIG_W1_F23_CRC + if (sl->family_data) { + kfree(sl->family_data); + sl->family_data = NULL; + } +#endif /* CONFIG_W1_F23_CRC */ sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); } -- cgit v0.10.2 From 01357dcac62ac028de65a1c315eb75c530c8a5d6 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 8 Sep 2005 22:46:00 +0100 Subject: [MMC] Ensure correct mmc_priv() behaviour mmc_priv() has some nasty effects if the wrong pointer type is passed to it. Introduce type checking, which also means we get the right type. Also add an additional member to mmc_host which is used to align host-private data appropriately. Signed-off-by: Russell King diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index c5d73c0..c1f021e 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -109,6 +109,8 @@ struct mmc_host { struct mmc_card *card_selected; /* the selected MMC card */ struct work_struct detect; + + unsigned long private[0] ____cacheline_aligned; }; extern struct mmc_host *mmc_alloc_host(int extra, struct device *); @@ -116,7 +118,11 @@ extern int mmc_add_host(struct mmc_host *); extern void mmc_remove_host(struct mmc_host *); extern void mmc_free_host(struct mmc_host *); -#define mmc_priv(x) ((void *)((x) + 1)) +static inline void *mmc_priv(struct mmc_host *host) +{ + return (void *)host->private; +} + #define mmc_dev(x) ((x)->dev) #define mmc_hostname(x) ((x)->class_dev.class_id) -- cgit v0.10.2 From 4e1491847ef5ca1c5a661601d5f96dcb7d90d2f0 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 8 Sep 2005 14:47:12 -0700 Subject: Fix up ARM serial driver compile failure Proud member of Uglyhacks'R'US. Acked-by: David S. Miller Acked-by: Russell King Signed-off-by: Linus Torvalds diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 9b12fe7..27db8da 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -401,6 +401,9 @@ uart_handle_sysrq_char(struct uart_port *port, unsigned int ch, #endif return 0; } +#ifndef SUPPORT_SYSRQ +#define uart_handle_sysrq_char(port,ch,regs) uart_handle_sysrq_char(port, 0, NULL) +#endif /* * We do the SysRQ and SAK checking like this... -- cgit v0.10.2 From c26971cbb39727b0b692c6236f890ba13046a663 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 8 Sep 2005 22:48:16 +0100 Subject: [MMC] Add mmc_detect_change() delay support for PXAMCI driver Allow PXA platforms to pass an appropriate delay value to the PXA MCI driver for delaying detection changes. Signed-Off-By: Richard Purdie Signed-off-by: Russell King diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c index 5223cd3..b53af57 100644 --- a/drivers/mmc/pxamci.c +++ b/drivers/mmc/pxamci.c @@ -423,7 +423,9 @@ static void pxamci_dma_irq(int dma, void *devid, struct pt_regs *regs) static irqreturn_t pxamci_detect_irq(int irq, void *devid, struct pt_regs *regs) { - mmc_detect_change(devid, 0); + struct pxamci_host *host = mmc_priv(devid); + + mmc_detect_change(devid, host->pdata->detect_delay); return IRQ_HANDLED; } diff --git a/include/asm-arm/arch-pxa/mmc.h b/include/asm-arm/arch-pxa/mmc.h index 9718063..88c17dd 100644 --- a/include/asm-arm/arch-pxa/mmc.h +++ b/include/asm-arm/arch-pxa/mmc.h @@ -9,6 +9,7 @@ struct mmc_host; struct pxamci_platform_data { unsigned int ocr_mask; /* available voltages */ + unsigned long detect_delay; /* delay in jiffies before detecting cards after interrupt */ int (*init)(struct device *, irqreturn_t (*)(int, void *, struct pt_regs *), void *); int (*get_ro)(struct device *); void (*setpower)(struct device *, unsigned int); -- cgit v0.10.2 From bde168412440084e649e7e04938bd1ab6e7bf978 Mon Sep 17 00:00:00 2001 From: John Rose Date: Mon, 25 Jul 2005 10:16:37 -0500 Subject: [PATCH] PCI Hotplug: rpaphp: Remove unused stuff Subject line says it all :) Signed-off-by: John Rose Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h index 81746e6..25bea00 100644 --- a/drivers/pci/hotplug/rpaphp.h +++ b/drivers/pci/hotplug/rpaphp.h @@ -72,11 +72,6 @@ extern int debug; #define CONFIGURED 1 #define EMPTY 0 -struct rpaphp_pci_func { - struct pci_dev *pci_dev; - struct list_head sibling; -}; - /* * struct slot - slot information for each *physical* slot */ @@ -113,7 +108,6 @@ extern int rpaphp_enable_pci_slot(struct slot *slot); extern int register_pci_slot(struct slot *slot); extern int rpaphp_unconfig_pci_adapter(struct slot *slot); extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value); -extern struct hotplug_slot *rpaphp_find_hotplug_slot(struct pci_dev *dev); /* rpaphp_core.c */ extern int rpaphp_add_slot(struct device_node *dn); diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index d8305a9..ab67d3d 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c @@ -186,39 +186,6 @@ rpaphp_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus) } } -static int rpaphp_pci_config_bridge(struct pci_dev *dev); - -/***************************************************************************** - rpaphp_pci_config_slot() will configure all devices under the - given slot->dn and return the the first pci_dev. - *****************************************************************************/ -static struct pci_dev * -rpaphp_pci_config_slot(struct device_node *dn, struct pci_bus *bus) -{ - struct device_node *eads_first_child = dn->child; - struct pci_dev *dev = NULL; - int num; - - dbg("Enter %s: dn=%s bus=%s\n", __FUNCTION__, dn->full_name, bus->name); - - if (eads_first_child) { - /* pci_scan_slot should find all children of EADs */ - num = pci_scan_slot(bus, PCI_DEVFN(PCI_SLOT(eads_first_child->devfn), 0)); - if (num) { - rpaphp_fixup_new_pci_devices(bus, 1); - pci_bus_add_devices(bus); - } - dev = rpaphp_find_pci_dev(eads_first_child); - if (!dev) { - err("No new device found\n"); - return NULL; - } - if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) - rpaphp_pci_config_bridge(dev); - } - return dev; -} - static int rpaphp_pci_config_bridge(struct pci_dev *dev) { u8 sec_busno; @@ -252,6 +219,37 @@ static int rpaphp_pci_config_bridge(struct pci_dev *dev) return 0; } +/***************************************************************************** + rpaphp_pci_config_slot() will configure all devices under the + given slot->dn and return the the first pci_dev. + *****************************************************************************/ +static struct pci_dev * +rpaphp_pci_config_slot(struct device_node *dn, struct pci_bus *bus) +{ + struct device_node *eads_first_child = dn->child; + struct pci_dev *dev = NULL; + int num; + + dbg("Enter %s: dn=%s bus=%s\n", __FUNCTION__, dn->full_name, bus->name); + + if (eads_first_child) { + /* pci_scan_slot should find all children of EADs */ + num = pci_scan_slot(bus, PCI_DEVFN(PCI_SLOT(eads_first_child->devfn), 0)); + if (num) { + rpaphp_fixup_new_pci_devices(bus, 1); + pci_bus_add_devices(bus); + } + dev = rpaphp_find_pci_dev(eads_first_child); + if (!dev) { + err("No new device found\n"); + return NULL; + } + if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) + rpaphp_pci_config_bridge(dev); + } + return dev; +} + static void enable_eeh(struct device_node *dn) { struct device_node *sib; @@ -502,37 +500,3 @@ exit: dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); return retval; } - -struct hotplug_slot *rpaphp_find_hotplug_slot(struct pci_dev *dev) -{ - struct list_head *tmp, *n; - struct slot *slot; - - list_for_each_safe(tmp, n, &rpaphp_slot_head) { - struct pci_bus *bus; - struct list_head *ln; - - slot = list_entry(tmp, struct slot, rpaphp_slot_list); - if (slot->bridge == NULL) { - if (slot->dev_type == PCI_DEV) { - printk(KERN_WARNING "PCI slot missing bridge %s %s \n", - slot->name, slot->location); - } - continue; - } - - bus = slot->bridge->subordinate; - if (!bus) { - continue; /* should never happen? */ - } - for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) { - struct pci_dev *pdev = pci_dev_b(ln); - if (pdev == dev) - return slot->hotplug_slot; - } - } - - return NULL; -} - -EXPORT_SYMBOL_GPL(rpaphp_find_hotplug_slot); -- cgit v0.10.2 From 5eeb8c63a38ff20285f3bbe7bcfe5e7c33c8ba14 Mon Sep 17 00:00:00 2001 From: John Rose Date: Mon, 25 Jul 2005 10:16:42 -0500 Subject: [PATCH] PCI Hotplug: rpaphp: Move VIO registration Currently, rpaphp registers Virtual I/O slots as hotplug slots. The only purpose of this registration is to ensure that the VIO subsystem is notified of new VIO buses during DLPAR adds. Similarly, rpaphp notifies the VIO subsystem when a VIO bus is DLPAR-removed. The rpaphp module has special case code to fake results for attributes like power, adapter status, etc. The VIO register/unregister functions could just as easily be made from the DLPAR module. This patch moves the VIO registration calls to the DLPAR module, and removes the VIO fluff from rpaphp altogether. Signed-off-by: John Rose Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile index 246586a..3c71e30 100644 --- a/drivers/pci/hotplug/Makefile +++ b/drivers/pci/hotplug/Makefile @@ -41,8 +41,7 @@ acpiphp-objs := acpiphp_core.o \ rpaphp-objs := rpaphp_core.o \ rpaphp_pci.o \ - rpaphp_slot.o \ - rpaphp_vio.o + rpaphp_slot.o rpadlpar_io-objs := rpadlpar_core.o \ rpadlpar_sysfs.o diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index 86b384e..d7f1319 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "../pci.h" #include "rpaphp.h" #include "rpadlpar.h" @@ -29,23 +30,23 @@ static DECLARE_MUTEX(rpadlpar_sem); #define NODE_TYPE_SLOT 2 #define NODE_TYPE_PHB 3 -static struct device_node *find_php_slot_vio_node(char *drc_name) +static struct device_node *find_vio_slot_node(char *drc_name) { - struct device_node *child; struct device_node *parent = of_find_node_by_name(NULL, "vdevice"); - char *loc_code; + struct device_node *dn = NULL; + char *name; + int rc; if (!parent) return NULL; - for (child = of_get_next_child(parent, NULL); - child; child = of_get_next_child(parent, child)) { - loc_code = get_property(child, "ibm,loc-code", NULL); - if (loc_code && !strncmp(loc_code, drc_name, strlen(drc_name))) - return child; + while ((dn = of_get_next_child(parent, dn))) { + rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL); + if ((rc == 0) && (!strcmp(drc_name, name))) + break; } - return NULL; + return dn; } /* Find dlpar-capable pci node that contains the specified name and type */ @@ -67,7 +68,7 @@ static struct device_node *find_php_slot_pci_node(char *drc_name, return np; } -static struct device_node *find_newly_added_node(char *drc_name, int *node_type) +static struct device_node *find_dlpar_node(char *drc_name, int *node_type) { struct device_node *dn; @@ -83,7 +84,7 @@ static struct device_node *find_newly_added_node(char *drc_name, int *node_type) return dn; } - dn = find_php_slot_vio_node(drc_name); + dn = find_vio_slot_node(drc_name); if (dn) { *node_type = NODE_TYPE_VIO; return dn; @@ -231,6 +232,12 @@ static inline int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) return -EIO; } + /* Add hotplug slot */ + if (rpaphp_add_slot(dn)) { + printk(KERN_ERR "%s: unable to add hotplug slot %s\n", + __FUNCTION__, drc_name); + return -EIO; + } return 0; } @@ -288,7 +295,7 @@ static int dlpar_remove_phb(struct slot *slot) return 0; } -static int dlpar_add_phb(struct device_node *dn) +static int dlpar_add_phb(char *drc_name, struct device_node *dn) { struct pci_controller *phb; @@ -296,6 +303,11 @@ static int dlpar_add_phb(struct device_node *dn) if (!phb) return -EINVAL; + if (rpaphp_add_slot(dn)) { + printk(KERN_ERR "%s: unable to add hotplug slot %s\n", + __FUNCTION__, drc_name); + return -EIO; + } return 0; } @@ -316,7 +328,7 @@ int dlpar_add_slot(char *drc_name) { struct device_node *dn = NULL; int node_type; - int rc = 0; + int rc; if (down_interruptible(&rpadlpar_sem)) return -ERESTARTSYS; @@ -327,32 +339,39 @@ int dlpar_add_slot(char *drc_name) goto exit; } - dn = find_newly_added_node(drc_name, &node_type); + /* Find newly added node */ + dn = find_dlpar_node(drc_name, &node_type); if (!dn) { rc = -ENODEV; goto exit; } + rc = -EIO; switch (node_type) { case NODE_TYPE_VIO: - /* Just add hotplug slot */ + if (!vio_register_device_node(dn)) { + printk(KERN_ERR + "%s: failed to register vio node %s\n", + __FUNCTION__, drc_name); + goto exit; + } break; case NODE_TYPE_SLOT: rc = dlpar_add_pci_slot(drc_name, dn); + if (rc) + goto exit; break; case NODE_TYPE_PHB: - rc = dlpar_add_phb(dn); + rc = dlpar_add_phb(drc_name, dn); + if (rc) + goto exit; break; default: printk("%s: unexpected node type\n", __FUNCTION__); - return -EIO; + goto exit; } - if (!rc && rpaphp_add_slot(dn)) { - printk(KERN_ERR "%s: unable to add hotplug slot %s\n", - __FUNCTION__, drc_name); - rc = -EIO; - } + rc = 0; exit: up(&rpadlpar_sem); return rc; @@ -368,15 +387,18 @@ exit: * 0 Success * -EIO Internal Error */ -int dlpar_remove_vio_slot(struct slot *slot, char *drc_name) +static int dlpar_remove_vio_slot(struct device_node *dn, char *drc_name) { - /* Remove hotplug slot */ + struct vio_dev *vio_dev; - if (rpaphp_remove_slot(slot)) { - printk(KERN_ERR "%s: unable to remove hotplug slot %s\n", - __FUNCTION__, drc_name); + vio_dev = vio_find_node(dn); + if (!vio_dev) { + printk(KERN_ERR "%s: %s does not correspond to a vio dev\n", + __FUNCTION__, drc_name); return -EIO; } + + vio_unregister_device(vio_dev); return 0; } @@ -434,36 +456,34 @@ int dlpar_remove_pci_slot(struct slot *slot, char *drc_name) */ int dlpar_remove_slot(char *drc_name) { + struct device_node *dn; struct slot *slot; + int node_type; int rc = 0; if (down_interruptible(&rpadlpar_sem)) return -ERESTARTSYS; - if (!find_php_slot_vio_node(drc_name) && - !find_php_slot_pci_node(drc_name, "SLOT") && - !find_php_slot_pci_node(drc_name, "PHB")) { + dn = find_dlpar_node(drc_name, &node_type); + if (!dn) { rc = -ENODEV; goto exit; } - slot = find_slot(drc_name); - if (!slot) { - rc = -EINVAL; - goto exit; - } - - if (slot->type == PHB) { - rc = dlpar_remove_phb(slot); + if (node_type == NODE_TYPE_VIO) { + rc = dlpar_remove_vio_slot(dn, drc_name); } else { - switch (slot->dev_type) { - case PCI_DEV: - rc = dlpar_remove_pci_slot(slot, drc_name); - break; + slot = find_slot(drc_name); + if (!slot) { + rc = -EINVAL; + goto exit; + } - case VIO_DEV: - rc = dlpar_remove_vio_slot(slot, drc_name); - break; + if (node_type == NODE_TYPE_PHB) + rc = dlpar_remove_phb(slot); + else { + /* NODE_TYPE_SLOT */ + rc = dlpar_remove_pci_slot(slot, drc_name); } } exit: diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h index 25bea00..2d9f420 100644 --- a/drivers/pci/hotplug/rpaphp.h +++ b/drivers/pci/hotplug/rpaphp.h @@ -61,10 +61,6 @@ extern int debug; #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) -/* slot types */ -#define VIO_DEV 1 -#define PCI_DEV 2 - /* slot states */ #define NOT_VALID 3 @@ -84,14 +80,10 @@ struct slot { char *name; char *location; u8 removable; - u8 dev_type; /* VIO or PCI */ struct device_node *dn; /* slot's device_node in OFDT */ /* dn has phb info */ struct pci_dev *bridge; /* slot's pci_dev in pci_devices */ - union { - struct list_head *pci_devs; /* pci_devs in PCI slot */ - struct vio_dev *vio_dev; /* vio_dev in VIO slot */ - } dev; + struct list_head *pci_devs; /* pci_devs in PCI slot */ struct hotplug_slot *hotplug_slot; }; @@ -115,12 +107,6 @@ extern int rpaphp_remove_slot(struct slot *slot); extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, char **drc_name, char **drc_type, int *drc_power_domain); -/* rpaphp_vio.c */ -extern int rpaphp_get_vio_adapter_status(struct slot *slot, int is_init, u8 * value); -extern int rpaphp_unconfig_vio_adapter(struct slot *slot); -extern int register_vio_slot(struct device_node *dn); -extern int rpaphp_enable_vio_slot(struct slot *slot); - /* rpaphp_slot.c */ extern void dealloc_slot_struct(struct slot *slot); extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain); diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index 29117a3..22ec099 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c @@ -152,17 +152,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value) int retval = 0; down(&rpaphp_sem); - /* have to go through this */ - switch (slot->dev_type) { - case PCI_DEV: - retval = rpaphp_get_pci_adapter_status(slot, 0, value); - break; - case VIO_DEV: - retval = rpaphp_get_vio_adapter_status(slot, 0, value); - break; - default: - retval = -EINVAL; - } + retval = rpaphp_get_pci_adapter_status(slot, 0, value); up(&rpaphp_sem); return retval; } @@ -362,12 +352,6 @@ int rpaphp_add_slot(struct device_node *dn) dbg("Entry %s: dn->full_name=%s\n", __FUNCTION__, dn->full_name); - if (dn->parent && is_vdevice_root(dn->parent)) { - /* register a VIO device */ - retval = register_vio_slot(dn); - goto exit; - } - /* register PCI devices */ if (dn->name != 0 && strcmp(dn->name, "pci") == 0) { if (is_php_dn(dn, &indexes, &names, &types, &power_domains)) @@ -412,31 +396,6 @@ exit: return retval; } -/* - * init_slots - initialize 'struct slot' structures for each slot - * - */ -static void init_slots(void) -{ - struct device_node *dn; - - for (dn = find_all_nodes(); dn; dn = dn->next) - rpaphp_add_slot(dn); -} - -static int __init init_rpa(void) -{ - - init_MUTEX(&rpaphp_sem); - - /* initialize internal data structure etc. */ - init_slots(); - if (!num_slots) - return -ENODEV; - - return 0; -} - static void __exit cleanup_slots(void) { struct list_head *tmp, *n; @@ -458,10 +417,18 @@ static void __exit cleanup_slots(void) static int __init rpaphp_init(void) { + struct device_node *dn = NULL; + info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); + init_MUTEX(&rpaphp_sem); + + while ((dn = of_find_node_by_type(dn, "pci"))) + rpaphp_add_slot(dn); + + if (!num_slots) + return -ENODEV; - /* read all the PRA info from the system */ - return init_rpa(); + return 0; } static void __exit rpaphp_exit(void) @@ -481,16 +448,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot) dbg("ENABLING SLOT %s\n", slot->name); down(&rpaphp_sem); - switch (slot->dev_type) { - case PCI_DEV: - retval = rpaphp_enable_pci_slot(slot); - break; - case VIO_DEV: - retval = rpaphp_enable_vio_slot(slot); - break; - default: - retval = -EINVAL; - } + retval = rpaphp_enable_pci_slot(slot); up(&rpaphp_sem); exit: dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); @@ -511,16 +469,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot) dbg("DISABLING SLOT %s\n", slot->name); down(&rpaphp_sem); - switch (slot->dev_type) { - case PCI_DEV: - retval = rpaphp_unconfig_pci_adapter(slot); - break; - case VIO_DEV: - retval = rpaphp_unconfig_vio_adapter(slot); - break; - default: - retval = -ENODEV; - } + retval = rpaphp_unconfig_pci_adapter(slot); up(&rpaphp_sem); exit: dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index ab67d3d..30d10fc 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c @@ -265,11 +265,9 @@ static void print_slot_pci_funcs(struct slot *slot) { struct pci_dev *dev; - if (slot->dev_type == PCI_DEV) { - dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, slot->name); - list_for_each_entry (dev, slot->dev.pci_devs, bus_list) - dbg("\t%s\n", pci_name(dev)); - } + dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, slot->name); + list_for_each_entry (dev, slot->pci_devs, bus_list) + dbg("\t%s\n", pci_name(dev)); return; } @@ -328,7 +326,7 @@ int rpaphp_unconfig_pci_adapter(struct slot *slot) struct pci_dev *dev; int retval = 0; - list_for_each_entry(dev, slot->dev.pci_devs, bus_list) + list_for_each_entry(dev, slot->pci_devs, bus_list) rpaphp_eeh_remove_bus_device(dev); pci_remove_behind_bridge(slot->bridge); @@ -401,7 +399,7 @@ static int setup_pci_slot(struct slot *slot) bus = slot->bridge->subordinate; if (!bus) goto exit_rc; - slot->dev.pci_devs = &bus->devices; + slot->pci_devs = &bus->devices; dbg("%s set slot->name to %s\n", __FUNCTION__, pci_name(slot->bridge)); @@ -434,7 +432,7 @@ static int setup_pci_slot(struct slot *slot) goto exit_rc; } print_slot_pci_funcs(slot); - if (!list_empty(slot->dev.pci_devs)) { + if (!list_empty(slot->pci_devs)) { slot->state = CONFIGURED; } else { /* DLPAR add as opposed to @@ -452,7 +450,6 @@ int register_pci_slot(struct slot *slot) { int rc = -EINVAL; - slot->dev_type = PCI_DEV; if ((slot->type == EMBEDDED) || (slot->type == PHB)) slot->removable = 0; else diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index ff2cbf0..8040202 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c @@ -220,13 +220,8 @@ int register_slot(struct slot *slot) __FUNCTION__, slot->name); list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head); - - if (slot->dev_type == VIO_DEV) - info("Slot [%s](VIO location=%s) registered\n", - slot->name, slot->location); - else - info("Slot [%s](PCI location=%s) registered\n", - slot->name, slot->location); + info("Slot [%s](PCI location=%s) registered\n", slot->name, + slot->location); num_slots++; return 0; } diff --git a/drivers/pci/hotplug/rpaphp_vio.c b/drivers/pci/hotplug/rpaphp_vio.c deleted file mode 100644 index 74df6a3..0000000 --- a/drivers/pci/hotplug/rpaphp_vio.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * RPA Hot Plug Virtual I/O device functions - * Copyright (C) 2004 Linda Xie - * - * All rights reserved. - * - * 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, GOOD TITLE or - * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Send feedback to - * - */ -#include -#include "rpaphp.h" - -/* - * get_vio_adapter_status - get the status of a slot - * - * status: - * - * 1-- adapter is configured - * 2-- adapter is not configured - * 3-- not valid - */ -inline int rpaphp_get_vio_adapter_status(struct slot *slot, int is_init, u8 *value) -{ - *value = slot->state; - return 0; -} - -int rpaphp_unconfig_vio_adapter(struct slot *slot) -{ - int retval = 0; - - dbg("Entry %s: slot[%s]\n", __FUNCTION__, slot->name); - if (!slot->dev.vio_dev) { - info("%s: no VIOA in slot[%s]\n", __FUNCTION__, slot->name); - retval = -EINVAL; - goto exit; - } - /* remove the device from the vio core */ - vio_unregister_device(slot->dev.vio_dev); - slot->state = NOT_CONFIGURED; - info("%s: adapter in slot[%s] unconfigured.\n", __FUNCTION__, slot->name); -exit: - dbg("Exit %s, rc=0x%x\n", __FUNCTION__, retval); - return retval; -} - -static int setup_vio_hotplug_slot_info(struct slot *slot) -{ - slot->hotplug_slot->info->power_status = 1; - rpaphp_get_vio_adapter_status(slot, 1, - &slot->hotplug_slot->info->adapter_status); - return 0; -} - -int register_vio_slot(struct device_node *dn) -{ - u32 *index; - char *name; - int rc = -EINVAL; - struct slot *slot = NULL; - - rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL); - if (rc < 0) - goto exit_rc; - index = (u32 *) get_property(dn, "ibm,my-drc-index", NULL); - if (!index) - goto exit_rc; - if (!(slot = alloc_slot_struct(dn, *index, name, 0))) { - rc = -ENOMEM; - goto exit_rc; - } - slot->dev_type = VIO_DEV; - slot->dev.vio_dev = vio_find_node(dn); - if (slot->dev.vio_dev) { - /* - * rpaphp is the only owner of vio devices and - * does not need extra reference taken by - * vio_find_node - */ - put_device(&slot->dev.vio_dev->dev); - } else - slot->dev.vio_dev = vio_register_device_node(dn); - if (slot->dev.vio_dev) - slot->state = CONFIGURED; - else - slot->state = NOT_CONFIGURED; - if (setup_vio_hotplug_slot_info(slot)) - goto exit_rc; - strcpy(slot->name, slot->dev.vio_dev->dev.bus_id); - info("%s: registered VIO device[name=%s vio_dev=%p]\n", - __FUNCTION__, slot->name, slot->dev.vio_dev); - rc = register_slot(slot); -exit_rc: - if (rc && slot) - dealloc_slot_struct(slot); - return (rc); -} - -int rpaphp_enable_vio_slot(struct slot *slot) -{ - int retval = 0; - - if ((slot->dev.vio_dev = vio_register_device_node(slot->dn))) { - info("%s: VIO adapter %s in slot[%s] has been configured\n", - __FUNCTION__, slot->dn->name, slot->name); - slot->state = CONFIGURED; - } else { - info("%s: no vio_dev struct for adapter in slot[%s]\n", - __FUNCTION__, slot->name); - slot->state = NOT_CONFIGURED; - } - - return retval; -} -- cgit v0.10.2 From 9c209c919df95f83aa042b3352c43841ad15a02b Mon Sep 17 00:00:00 2001 From: John Rose Date: Mon, 25 Jul 2005 11:13:38 -0500 Subject: [PATCH] PCI Hotplug: rpaphp: Change slot pci reference The slot structure in the rpaphp module currently references the PCI contents of the slot using the PCI device of the parent bridge. This is unnecessary, since the module is actually interested in the subordinate bus of the bridge. The dependency on a PCI bridge device also prohibits the module from registering hotplug slots that have a root bridge as a parent, since root bridges on PPC64 don't have PCI devices. This patch changes struct slot to reference the PCI subsystem using a pci_bus rather than a pci_dev. Signed-off-by: John Rose Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index d7f1319..7f868ed 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -198,28 +198,6 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) return dev; } -static int dlpar_pci_remove_bus(struct pci_dev *bridge_dev) -{ - struct pci_bus *secondary_bus; - - if (!bridge_dev) { - printk(KERN_ERR "%s: unexpected null device\n", - __FUNCTION__); - return -EINVAL; - } - - secondary_bus = bridge_dev->subordinate; - - if (unmap_bus_range(secondary_bus)) { - printk(KERN_ERR "%s: failed to unmap bus range\n", - __FUNCTION__); - return -ERANGE; - } - - pci_remove_bus_device(bridge_dev); - return 0; -} - static inline int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) { struct pci_dev *dev; @@ -415,14 +393,7 @@ static int dlpar_remove_vio_slot(struct device_node *dn, char *drc_name) */ int dlpar_remove_pci_slot(struct slot *slot, char *drc_name) { - struct pci_dev *bridge_dev; - - bridge_dev = slot->bridge; - if (!bridge_dev) { - printk(KERN_ERR "%s: unexpected null bridge device\n", - __FUNCTION__); - return -EIO; - } + struct pci_bus *bus = slot->bus; /* Remove hotplug slot */ if (rpaphp_remove_slot(slot)) { @@ -431,13 +402,14 @@ int dlpar_remove_pci_slot(struct slot *slot, char *drc_name) return -EIO; } - /* Remove pci bus */ - - if (dlpar_pci_remove_bus(bridge_dev)) { - printk(KERN_ERR "%s: unable to remove pci bus %s\n", - __FUNCTION__, drc_name); - return -EIO; + if (unmap_bus_range(bus)) { + printk(KERN_ERR "%s: failed to unmap bus range\n", + __FUNCTION__); + return -ERANGE; } + + BUG_ON(!bus->self); + pci_remove_bus_device(bus->self); return 0; } diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h index 2d9f420..9f050fd 100644 --- a/drivers/pci/hotplug/rpaphp.h +++ b/drivers/pci/hotplug/rpaphp.h @@ -80,10 +80,9 @@ struct slot { char *name; char *location; u8 removable; - struct device_node *dn; /* slot's device_node in OFDT */ - /* dn has phb info */ - struct pci_dev *bridge; /* slot's pci_dev in pci_devices */ - struct list_head *pci_devs; /* pci_devs in PCI slot */ + struct device_node *dn; + struct pci_bus *bus; + struct list_head *pci_devs; struct hotplug_slot *hotplug_slot; }; diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index 30d10fc..54fff5f 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c @@ -45,6 +45,32 @@ struct pci_dev *rpaphp_find_pci_dev(struct device_node *dn) return dev; } +struct pci_bus *find_bus_among_children(struct pci_bus *bus, + struct device_node *dn) +{ + struct pci_bus *child = NULL; + struct list_head *tmp; + struct device_node *busdn; + + busdn = pci_bus_to_OF_node(bus); + if (busdn == dn) + return bus; + + list_for_each(tmp, &bus->children) { + child = find_bus_among_children(pci_bus_b(tmp), dn); + if (child) + break; + } + return child; +} + +struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn) +{ + BUG_ON(!dn->phb || !dn->phb->bus); + + return find_bus_among_children(dn->phb->bus, dn); +} + EXPORT_SYMBOL_GPL(rpaphp_find_pci_dev); int rpaphp_claim_resource(struct pci_dev *dev, int resource) @@ -69,11 +95,6 @@ int rpaphp_claim_resource(struct pci_dev *dev, int resource) EXPORT_SYMBOL_GPL(rpaphp_claim_resource); -static struct pci_dev *rpaphp_find_bridge_pdev(struct slot *slot) -{ - return rpaphp_find_pci_dev(slot->dn); -} - static int rpaphp_get_sensor_state(struct slot *slot, int *state) { int rc; @@ -226,20 +247,22 @@ static int rpaphp_pci_config_bridge(struct pci_dev *dev) static struct pci_dev * rpaphp_pci_config_slot(struct device_node *dn, struct pci_bus *bus) { - struct device_node *eads_first_child = dn->child; struct pci_dev *dev = NULL; + int slotno; int num; dbg("Enter %s: dn=%s bus=%s\n", __FUNCTION__, dn->full_name, bus->name); - if (eads_first_child) { - /* pci_scan_slot should find all children of EADs */ - num = pci_scan_slot(bus, PCI_DEVFN(PCI_SLOT(eads_first_child->devfn), 0)); + if (dn->child) { + slotno = PCI_SLOT(dn->child->devfn); + + /* pci_scan_slot should find all children */ + num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0)); if (num) { rpaphp_fixup_new_pci_devices(bus, 1); pci_bus_add_devices(bus); } - dev = rpaphp_find_pci_dev(eads_first_child); + dev = rpaphp_find_pci_dev(dn->child); if (!dev) { err("No new device found\n"); return NULL; @@ -273,31 +296,19 @@ static void print_slot_pci_funcs(struct slot *slot) static int rpaphp_config_pci_adapter(struct slot *slot) { - struct pci_bus *pci_bus; struct pci_dev *dev; int rc = -ENODEV; dbg("Entry %s: slot[%s]\n", __FUNCTION__, slot->name); - if (slot->bridge) { - - pci_bus = slot->bridge->subordinate; - if (!pci_bus) { - err("%s: can't find bus structure\n", __FUNCTION__); - goto exit; - } - enable_eeh(slot->dn); - dev = rpaphp_pci_config_slot(slot->dn, pci_bus); - if (!dev) { - err("%s: can't find any devices.\n", __FUNCTION__); - goto exit; - } - print_slot_pci_funcs(slot); - rc = 0; - } else { - /* slot is not enabled */ - err("slot doesn't have pci_dev structure\n"); + enable_eeh(slot->dn); + dev = rpaphp_pci_config_slot(slot->dn, slot->bus); + if (!dev) { + err("%s: can't find any devices.\n", __FUNCTION__); + goto exit; } + print_slot_pci_funcs(slot); + rc = 0; exit: dbg("Exit %s: rc=%d\n", __FUNCTION__, rc); return rc; @@ -323,13 +334,14 @@ static void rpaphp_eeh_remove_bus_device(struct pci_dev *dev) int rpaphp_unconfig_pci_adapter(struct slot *slot) { - struct pci_dev *dev; + struct pci_dev *dev, *tmp; int retval = 0; - list_for_each_entry(dev, slot->pci_devs, bus_list) + list_for_each_entry_safe(dev, tmp, slot->pci_devs, bus_list) { rpaphp_eeh_remove_bus_device(dev); + pci_remove_bus_device(dev); + } - pci_remove_behind_bridge(slot->bridge); slot->state = NOT_CONFIGURED; info("%s: devices in slot[%s] unconfigured.\n", __FUNCTION__, slot->name); @@ -352,66 +364,41 @@ static int setup_pci_hotplug_slot_info(struct slot *slot) return 0; } -static int set_phb_slot_name(struct slot *slot) +static void set_slot_name(struct slot *slot) { - struct device_node *dn; - struct pci_controller *phb; - struct pci_bus *bus; - - dn = slot->dn; - if (!dn) { - return -EINVAL; - } - phb = dn->phb; - if (!phb) { - return -EINVAL; - } - bus = phb->bus; - if (!bus) { - return -EINVAL; - } + struct pci_bus *bus = slot->bus; + struct pci_dev *bridge; - sprintf(slot->name, "%04x:%02x:%02x.%x", pci_domain_nr(bus), - bus->number, 0, 0); - return 0; + bridge = bus->self; + if (bridge) + strcpy(slot->name, pci_name(bridge)); + else + sprintf(slot->name, "%04x:%02x:00.0", pci_domain_nr(bus), + bus->number); } static int setup_pci_slot(struct slot *slot) { + struct device_node *dn = slot->dn; struct pci_bus *bus; - int rc; - if (slot->type == PHB) { - rc = set_phb_slot_name(slot); - if (rc < 0) { - err("%s: failed to set phb slot name\n", __FUNCTION__); - goto exit_rc; - } - } else { - slot->bridge = rpaphp_find_bridge_pdev(slot); - if (!slot->bridge) { - /* slot being added doesn't have pci_dev yet */ - err("%s: no pci_dev for bridge dn %s\n", - __FUNCTION__, slot->name); - goto exit_rc; - } - - bus = slot->bridge->subordinate; - if (!bus) - goto exit_rc; - slot->pci_devs = &bus->devices; - - dbg("%s set slot->name to %s\n", __FUNCTION__, - pci_name(slot->bridge)); - strcpy(slot->name, pci_name(slot->bridge)); + BUG_ON(!dn); + bus = rpaphp_find_pci_bus(dn); + if (!bus) { + err("%s: no pci_bus for dn %s\n", __FUNCTION__, dn->full_name); + goto exit_rc; } + slot->bus = bus; + slot->pci_devs = &bus->devices; + set_slot_name(slot); + /* find slot's pci_dev if it's not empty */ if (slot->hotplug_slot->info->adapter_status == EMPTY) { slot->state = EMPTY; /* slot is empty */ } else { /* slot is occupied */ - if (!(slot->dn->child)) { + if (!dn->child) { /* non-empty slot has to have child */ err("%s: slot[%s]'s device_node doesn't have child for adapter\n", __FUNCTION__, slot->name); -- cgit v0.10.2 From 0945cd5f908a09ad99bf42d7ded16f26f24f317d Mon Sep 17 00:00:00 2001 From: John Rose Date: Mon, 25 Jul 2005 10:16:53 -0500 Subject: [PATCH] PCI Hotplug: rpaphp: Remove rpaphp_find_pci The rpaphp module currently uses a fragile method to find a pci device by its device node. This function is unnecessary, so this patch scraps it. Signed-off-by: John Rose Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index 7f868ed..2ee7eb5 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -165,6 +165,20 @@ static int pci_add_secondary_bus(struct device_node *dn, return 0; } +static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, + struct device_node *dev_dn) +{ + struct pci_dev *tmp = NULL; + struct device_node *child_dn; + + list_for_each_entry(tmp, &parent->devices, bus_list) { + child_dn = pci_device_to_OF_node(tmp); + if (child_dn == dev_dn) + return tmp; + } + return NULL; +} + static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) { struct pci_controller *hose = dn->phb; @@ -180,21 +194,18 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) pci_bus_add_devices(hose->bus); /* Confirm new bridge dev was created */ - dev = rpaphp_find_pci_dev(dn); - if (!dev) { - printk(KERN_ERR "%s: failed to add pci device\n", __FUNCTION__); - return NULL; - } + dev = dlpar_find_new_dev(hose->bus, dn); + if (dev) { + if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { + printk(KERN_ERR "%s: unexpected header type %d\n", + __FUNCTION__, dev->hdr_type); + return NULL; + } - if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { - printk(KERN_ERR "%s: unexpected header type %d\n", - __FUNCTION__, dev->hdr_type); - return NULL; + if (pci_add_secondary_bus(dn, dev)) + return NULL; } - if (pci_add_secondary_bus(dn, dev)) - return NULL; - return dev; } diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h index 9f050fd..8ecff0b 100644 --- a/drivers/pci/hotplug/rpaphp.h +++ b/drivers/pci/hotplug/rpaphp.h @@ -93,7 +93,6 @@ extern int num_slots; /* function prototypes */ /* rpaphp_pci.c */ -extern struct pci_dev *rpaphp_find_pci_dev(struct device_node *dn); extern int rpaphp_claim_resource(struct pci_dev *dev, int resource); extern int rpaphp_enable_pci_slot(struct slot *slot); extern int register_pci_slot(struct slot *slot); diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index 54fff5f..30a892c 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c @@ -30,22 +30,7 @@ #include "rpaphp.h" -struct pci_dev *rpaphp_find_pci_dev(struct device_node *dn) -{ - struct pci_dev *dev = NULL; - char bus_id[BUS_ID_SIZE]; - - sprintf(bus_id, "%04x:%02x:%02x.%d", dn->phb->global_number, - dn->busno, PCI_SLOT(dn->devfn), PCI_FUNC(dn->devfn)); - for_each_pci_dev(dev) { - if (!strcmp(pci_name(dev), bus_id)) { - break; - } - } - return dev; -} - -struct pci_bus *find_bus_among_children(struct pci_bus *bus, +static struct pci_bus *find_bus_among_children(struct pci_bus *bus, struct device_node *dn) { struct pci_bus *child = NULL; @@ -64,15 +49,14 @@ struct pci_bus *find_bus_among_children(struct pci_bus *bus, return child; } -struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn) +static struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn) { - BUG_ON(!dn->phb || !dn->phb->bus); + if (!dn->phb || !dn->phb->bus) + return NULL; return find_bus_among_children(dn->phb->bus, dn); } -EXPORT_SYMBOL_GPL(rpaphp_find_pci_dev); - int rpaphp_claim_resource(struct pci_dev *dev, int resource) { struct resource *res = &dev->resource[resource]; @@ -137,9 +121,8 @@ static int rpaphp_get_sensor_state(struct slot *slot, int *state) */ int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value) { + struct pci_bus *bus; int state, rc; - struct device_node *child_dn; - struct pci_dev *child_dev = NULL; *value = NOT_VALID; rc = rpaphp_get_sensor_state(slot, &state); @@ -156,20 +139,11 @@ int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value) /* config/unconfig adapter */ *value = slot->state; } else { - child_dn = slot->dn->child; - if (child_dn) - child_dev = rpaphp_find_pci_dev(child_dn); - - if (child_dev) - *value = CONFIGURED; - else if (!child_dn) - dbg("%s: %s is not valid OFDT node\n", - __FUNCTION__, slot->dn->full_name); - else { - err("%s: can't find pdev of adapter in slot[%s]\n", - __FUNCTION__, slot->dn->full_name); + bus = rpaphp_find_pci_bus(slot->dn); + if (bus && !list_empty(&bus->devices)) + *value = CONFIGURED; + else *value = NOT_CONFIGURED; - } } } exit: @@ -252,24 +226,26 @@ rpaphp_pci_config_slot(struct device_node *dn, struct pci_bus *bus) int num; dbg("Enter %s: dn=%s bus=%s\n", __FUNCTION__, dn->full_name, bus->name); + if (!dn->child) + return NULL; - if (dn->child) { - slotno = PCI_SLOT(dn->child->devfn); + slotno = PCI_SLOT(dn->child->devfn); - /* pci_scan_slot should find all children */ - num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0)); - if (num) { - rpaphp_fixup_new_pci_devices(bus, 1); - pci_bus_add_devices(bus); - } - dev = rpaphp_find_pci_dev(dn->child); - if (!dev) { - err("No new device found\n"); - return NULL; - } + /* pci_scan_slot should find all children */ + num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0)); + if (num) { + rpaphp_fixup_new_pci_devices(bus, 1); + pci_bus_add_devices(bus); + } + if (list_empty(&bus->devices)) { + err("%s: No new device found\n", __FUNCTION__); + return NULL; + } + list_for_each_entry(dev, &bus->devices, bus_list) { if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) rpaphp_pci_config_bridge(dev); } + return dev; } -- cgit v0.10.2 From 940903c5a5a906c622a79b3101586deb1a1b3480 Mon Sep 17 00:00:00 2001 From: John Rose Date: Mon, 25 Jul 2005 10:16:58 -0500 Subject: [PATCH] PCI Hotplug: rpaphp: Export slot enable This patch exports rpaphp_config_pci_adapter() for use by the rpadlpar module. It also changes this function by removing any dependencies on struct slot. The patch also changes the RPA DLPAR-add path to enable newly-added slots in a separate step from that which registers them as hotplug slots. Signed-off-by: John Rose Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index 2ee7eb5..f2a73f7 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -209,9 +209,10 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) return dev; } -static inline int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) +static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) { struct pci_dev *dev; + int rc; /* Add pci bus */ dev = dlpar_pci_add_bus(dn); @@ -221,6 +222,15 @@ static inline int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) return -EIO; } + if (dn->child) { + rc = rpaphp_config_pci_adapter(dev->subordinate); + if (rc < 0) { + printk(KERN_ERR "%s: unable to enable slot %s\n", + __FUNCTION__, drc_name); + return -EIO; + } + } + /* Add hotplug slot */ if (rpaphp_add_slot(dn)) { printk(KERN_ERR "%s: unable to add hotplug slot %s\n", diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h index 8ecff0b..064a0d6 100644 --- a/drivers/pci/hotplug/rpaphp.h +++ b/drivers/pci/hotplug/rpaphp.h @@ -98,6 +98,7 @@ extern int rpaphp_enable_pci_slot(struct slot *slot); extern int register_pci_slot(struct slot *slot); extern int rpaphp_unconfig_pci_adapter(struct slot *slot); extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value); +extern int rpaphp_config_pci_adapter(struct pci_bus *bus); /* rpaphp_core.c */ extern int rpaphp_add_slot(struct device_node *dn); diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index 30a892c..f2f1cd0 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c @@ -219,14 +219,15 @@ static int rpaphp_pci_config_bridge(struct pci_dev *dev) given slot->dn and return the the first pci_dev. *****************************************************************************/ static struct pci_dev * -rpaphp_pci_config_slot(struct device_node *dn, struct pci_bus *bus) +rpaphp_pci_config_slot(struct pci_bus *bus) { + struct device_node *dn = pci_bus_to_OF_node(bus); struct pci_dev *dev = NULL; int slotno; int num; dbg("Enter %s: dn=%s bus=%s\n", __FUNCTION__, dn->full_name, bus->name); - if (!dn->child) + if (!dn || !dn->child) return NULL; slotno = PCI_SLOT(dn->child->devfn); @@ -260,35 +261,44 @@ static void enable_eeh(struct device_node *dn) } -static void print_slot_pci_funcs(struct slot *slot) +static void print_slot_pci_funcs(struct pci_bus *bus) { + struct device_node *dn; struct pci_dev *dev; - dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, slot->name); - list_for_each_entry (dev, slot->pci_devs, bus_list) + dn = pci_bus_to_OF_node(bus); + if (!dn) + return; + + dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, dn->full_name); + list_for_each_entry (dev, &bus->devices, bus_list) dbg("\t%s\n", pci_name(dev)); return; } -static int rpaphp_config_pci_adapter(struct slot *slot) +int rpaphp_config_pci_adapter(struct pci_bus *bus) { + struct device_node *dn = pci_bus_to_OF_node(bus); struct pci_dev *dev; int rc = -ENODEV; - dbg("Entry %s: slot[%s]\n", __FUNCTION__, slot->name); + dbg("Entry %s: slot[%s]\n", __FUNCTION__, dn->full_name); + if (!dn) + goto exit; - enable_eeh(slot->dn); - dev = rpaphp_pci_config_slot(slot->dn, slot->bus); + enable_eeh(dn); + dev = rpaphp_pci_config_slot(bus); if (!dev) { err("%s: can't find any devices.\n", __FUNCTION__); goto exit; } - print_slot_pci_funcs(slot); + print_slot_pci_funcs(bus); rc = 0; exit: dbg("Exit %s: rc=%d\n", __FUNCTION__, rc); return rc; } +EXPORT_SYMBOL_GPL(rpaphp_config_pci_adapter); static void rpaphp_eeh_remove_bus_device(struct pci_dev *dev) { @@ -384,7 +394,7 @@ static int setup_pci_slot(struct slot *slot) if (slot->hotplug_slot->info->adapter_status == NOT_CONFIGURED) { dbg("%s CONFIGURING pci adapter in slot[%s]\n", __FUNCTION__, slot->name); - if (rpaphp_config_pci_adapter(slot)) { + if (rpaphp_config_pci_adapter(slot->bus)) { err("%s: CONFIG pci adapter failed\n", __FUNCTION__); goto exit_rc; } @@ -394,7 +404,7 @@ static int setup_pci_slot(struct slot *slot) __FUNCTION__, slot->name); goto exit_rc; } - print_slot_pci_funcs(slot); + print_slot_pci_funcs(slot->bus); if (!list_empty(slot->pci_devs)) { slot->state = CONFIGURED; } else { @@ -437,7 +447,7 @@ int rpaphp_enable_pci_slot(struct slot *slot) /* if slot is not empty, enable the adapter */ if (state == PRESENT) { dbg("%s : slot[%s] is occupied.\n", __FUNCTION__, slot->name); - retval = rpaphp_config_pci_adapter(slot); + retval = rpaphp_config_pci_adapter(slot->bus); if (!retval) { slot->state = CONFIGURED; dbg("%s: PCI devices in slot[%s] has been configured\n", -- cgit v0.10.2 From 56d8456b06ad1316bff3c75caed5e06e786f20d8 Mon Sep 17 00:00:00 2001 From: John Rose Date: Mon, 25 Jul 2005 10:17:03 -0500 Subject: [PATCH] PCI Hotplug: rpaphp: Purify hotplug Currently rpaphp registers the following bus types as hotplug slots: 1) Actual PCI Hotplug slots 2) Embedded/Internal PCI slots 3) PCI Host Bridges The second and third bus types are not actually direct parents of removable adapters. As such, the rpaphp has special case code to fake results for attributes like power, adapter status, etc. This patch removes types 2 and 3 from the rpaphp module. This patch also changes the DLPAR module so that slots can be DLPAR-added/removed without having been designated as hotplug-capable. Signed-off-by: John Rose Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index f2a73f7..4ada151 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -26,6 +26,8 @@ static DECLARE_MUTEX(rpadlpar_sem); +#define DLPAR_MODULE_NAME "rpadlpar_io" + #define NODE_TYPE_VIO 1 #define NODE_TYPE_SLOT 2 #define NODE_TYPE_PHB 3 @@ -93,14 +95,14 @@ static struct device_node *find_dlpar_node(char *drc_name, int *node_type) return NULL; } -static struct slot *find_slot(char *drc_name) +static struct slot *find_slot(struct device_node *dn) { struct list_head *tmp, *n; struct slot *slot; list_for_each_safe(tmp, n, &rpaphp_slot_head) { slot = list_entry(tmp, struct slot, rpaphp_slot_list); - if (strcmp(slot->location, drc_name) == 0) + if (slot->dn == dn) return slot; } @@ -214,6 +216,9 @@ static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) struct pci_dev *dev; int rc; + if (rpaphp_find_pci_bus(dn)) + return -EINVAL; + /* Add pci bus */ dev = dlpar_pci_add_bus(dn); if (!dev) { @@ -261,36 +266,32 @@ static int dlpar_remove_root_bus(struct pci_controller *phb) return 0; } -static int dlpar_remove_phb(struct slot *slot) +static int dlpar_remove_phb(char *drc_name, struct device_node *dn) { - struct pci_controller *phb; - struct device_node *dn; + struct slot *slot; int rc = 0; - dn = slot->dn; - if (!dn) { - printk(KERN_ERR "%s: unexpected NULL slot device node\n", - __FUNCTION__); - return -EIO; - } - - phb = dn->phb; - if (!phb) { - printk(KERN_ERR "%s: unexpected NULL phb pointer\n", - __FUNCTION__); - return -EIO; - } + if (!rpaphp_find_pci_bus(dn)) + return -EINVAL; - if (rpaphp_remove_slot(slot)) { - printk(KERN_ERR "%s: unable to remove hotplug slot %s\n", - __FUNCTION__, slot->location); - return -EIO; + slot = find_slot(dn); + if (slot) { + /* Remove hotplug slot */ + if (rpaphp_remove_slot(slot)) { + printk(KERN_ERR + "%s: unable to remove hotplug slot %s\n", + __FUNCTION__, drc_name); + return -EIO; + } } - rc = dlpar_remove_root_bus(phb); + BUG_ON(!dn->phb); + rc = dlpar_remove_root_bus(dn->phb); if (rc < 0) return rc; + dn->phb = NULL; + return 0; } @@ -298,9 +299,14 @@ static int dlpar_add_phb(char *drc_name, struct device_node *dn) { struct pci_controller *phb; + if (dn->phb) { + /* PHB already exists */ + return -EINVAL; + } + phb = init_phb_dynamic(dn); if (!phb) - return -EINVAL; + return -EIO; if (rpaphp_add_slot(dn)) { printk(KERN_ERR "%s: unable to add hotplug slot %s\n", @@ -310,6 +316,20 @@ static int dlpar_add_phb(char *drc_name, struct device_node *dn) return 0; } +static int dlpar_add_vio_slot(char *drc_name, struct device_node *dn) +{ + if (vio_find_node(dn)) + return -EINVAL; + + if (!vio_register_device_node(dn)) { + printk(KERN_ERR + "%s: failed to register vio node %s\n", + __FUNCTION__, drc_name); + return -EIO; + } + return 0; +} + /** * dlpar_add_slot - DLPAR add an I/O Slot * @drc_name: drc-name of newly added slot @@ -327,17 +347,11 @@ int dlpar_add_slot(char *drc_name) { struct device_node *dn = NULL; int node_type; - int rc; + int rc = -EIO; if (down_interruptible(&rpadlpar_sem)) return -ERESTARTSYS; - /* Check for existing hotplug slot */ - if (find_slot(drc_name)) { - rc = -EINVAL; - goto exit; - } - /* Find newly added node */ dn = find_dlpar_node(drc_name, &node_type); if (!dn) { @@ -345,32 +359,19 @@ int dlpar_add_slot(char *drc_name) goto exit; } - rc = -EIO; switch (node_type) { case NODE_TYPE_VIO: - if (!vio_register_device_node(dn)) { - printk(KERN_ERR - "%s: failed to register vio node %s\n", - __FUNCTION__, drc_name); - goto exit; - } + rc = dlpar_add_vio_slot(drc_name, dn); break; case NODE_TYPE_SLOT: rc = dlpar_add_pci_slot(drc_name, dn); - if (rc) - goto exit; break; case NODE_TYPE_PHB: rc = dlpar_add_phb(drc_name, dn); - if (rc) - goto exit; break; - default: - printk("%s: unexpected node type\n", __FUNCTION__); - goto exit; } - rc = 0; + printk(KERN_INFO "%s: slot %s added\n", DLPAR_MODULE_NAME, drc_name); exit: up(&rpadlpar_sem); return rc; @@ -384,18 +385,15 @@ exit: * of an I/O Slot. * Return Codes: * 0 Success - * -EIO Internal Error + * -EINVAL Vio dev doesn't exist */ -static int dlpar_remove_vio_slot(struct device_node *dn, char *drc_name) +static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn) { struct vio_dev *vio_dev; vio_dev = vio_find_node(dn); - if (!vio_dev) { - printk(KERN_ERR "%s: %s does not correspond to a vio dev\n", - __FUNCTION__, drc_name); - return -EIO; - } + if (!vio_dev) + return -EINVAL; vio_unregister_device(vio_dev); return 0; @@ -412,15 +410,24 @@ static int dlpar_remove_vio_slot(struct device_node *dn, char *drc_name) * -ENODEV Not a valid drc_name * -EIO Internal PCI Error */ -int dlpar_remove_pci_slot(struct slot *slot, char *drc_name) +int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn) { - struct pci_bus *bus = slot->bus; + struct pci_bus *bus; + struct slot *slot; - /* Remove hotplug slot */ - if (rpaphp_remove_slot(slot)) { - printk(KERN_ERR "%s: unable to remove hotplug slot %s\n", - __FUNCTION__, drc_name); - return -EIO; + bus = rpaphp_find_pci_bus(dn); + if (!bus) + return -EINVAL; + + slot = find_slot(dn); + if (slot) { + /* Remove hotplug slot */ + if (rpaphp_remove_slot(slot)) { + printk(KERN_ERR + "%s: unable to remove hotplug slot %s\n", + __FUNCTION__, drc_name); + return -EIO; + } } if (unmap_bus_range(bus)) { @@ -450,7 +457,6 @@ int dlpar_remove_pci_slot(struct slot *slot, char *drc_name) int dlpar_remove_slot(char *drc_name) { struct device_node *dn; - struct slot *slot; int node_type; int rc = 0; @@ -463,22 +469,18 @@ int dlpar_remove_slot(char *drc_name) goto exit; } - if (node_type == NODE_TYPE_VIO) { - rc = dlpar_remove_vio_slot(dn, drc_name); - } else { - slot = find_slot(drc_name); - if (!slot) { - rc = -EINVAL; - goto exit; - } - - if (node_type == NODE_TYPE_PHB) - rc = dlpar_remove_phb(slot); - else { - /* NODE_TYPE_SLOT */ - rc = dlpar_remove_pci_slot(slot, drc_name); - } + switch (node_type) { + case NODE_TYPE_VIO: + rc = dlpar_remove_vio_slot(drc_name, dn); + break; + case NODE_TYPE_PHB: + rc = dlpar_remove_phb(drc_name, dn); + break; + case NODE_TYPE_SLOT: + rc = dlpar_remove_pci_slot(drc_name, dn); + break; } + printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name); exit: up(&rpadlpar_sem); return rc; diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h index 064a0d6..61d94d1 100644 --- a/drivers/pci/hotplug/rpaphp.h +++ b/drivers/pci/hotplug/rpaphp.h @@ -30,10 +30,6 @@ #include #include "pci_hotplug.h" -#define PHB 2 -#define HOTPLUG 1 -#define EMBEDDED 0 - #define DR_INDICATOR 9002 #define DR_ENTITY_SENSE 9003 @@ -79,7 +75,6 @@ struct slot { u32 power_domain; char *name; char *location; - u8 removable; struct device_node *dn; struct pci_bus *bus; struct list_head *pci_devs; @@ -93,6 +88,7 @@ extern int num_slots; /* function prototypes */ /* rpaphp_pci.c */ +extern struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn); extern int rpaphp_claim_resource(struct pci_dev *dev, int resource); extern int rpaphp_enable_pci_slot(struct slot *slot); extern int register_pci_slot(struct slot *slot); diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index 22ec099..c830ff0 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c @@ -307,34 +307,6 @@ static int is_php_dn(struct device_node *dn, int **indexes, int **names, return 0; } -static int is_dr_dn(struct device_node *dn, int **indexes, int **names, - int **types, int **power_domains, int **my_drc_index) -{ - int rc; - - *my_drc_index = (int *) get_property(dn, "ibm,my-drc-index", NULL); - if(!*my_drc_index) - return (0); - - if (!dn->parent) - return (0); - - rc = get_children_props(dn->parent, indexes, names, types, - power_domains); - return (rc >= 0); -} - -static inline int is_vdevice_root(struct device_node *dn) -{ - return !strcmp(dn->name, "vdevice"); -} - -int is_dlpar_type(const char *type_str) -{ - /* Only register DLPAR-capable nodes of drc-type PHB or SLOT */ - return (!strcmp(type_str, "PHB") || !strcmp(type_str, "SLOT")); -} - /**************************************************************** * rpaphp not only registers PCI hotplug slots(HOTPLUG), * but also logical DR slots(EMBEDDED). @@ -346,7 +318,7 @@ int rpaphp_add_slot(struct device_node *dn) { struct slot *slot; int retval = 0; - int i, *my_drc_index, slot_type; + int i; int *indexes, *names, *types, *power_domains; char *name, *type; @@ -354,40 +326,25 @@ int rpaphp_add_slot(struct device_node *dn) /* register PCI devices */ if (dn->name != 0 && strcmp(dn->name, "pci") == 0) { - if (is_php_dn(dn, &indexes, &names, &types, &power_domains)) - slot_type = HOTPLUG; - else if (is_dr_dn(dn, &indexes, &names, &types, &power_domains, &my_drc_index)) - slot_type = EMBEDDED; - else goto exit; + if (!is_php_dn(dn, &indexes, &names, &types, &power_domains)) + goto exit; name = (char *) &names[1]; type = (char *) &types[1]; for (i = 0; i < indexes[0]; i++, - name += (strlen(name) + 1), type += (strlen(type) + 1)) { - - if (slot_type == HOTPLUG || - (slot_type == EMBEDDED && - indexes[i + 1] == my_drc_index[0] && - is_dlpar_type(type))) { - if (!(slot = alloc_slot_struct(dn, indexes[i + 1], name, - power_domains[i + 1]))) { - retval = -ENOMEM; - goto exit; - } - if (!strcmp(type, "PHB")) - slot->type = PHB; - else if (slot_type == EMBEDDED) - slot->type = EMBEDDED; - else - slot->type = simple_strtoul(type, NULL, 10); + name += (strlen(name) + 1), type += (strlen(type) + 1)) { + + if (!(slot = alloc_slot_struct(dn, indexes[i + 1], name, + power_domains[i + 1]))) { + retval = -ENOMEM; + goto exit; + } + slot->type = simple_strtoul(type, NULL, 10); - dbg(" Found drc-index:0x%x drc-name:%s drc-type:%s\n", + dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n", indexes[i + 1], name, type); - retval = register_pci_slot(slot); - if (slot_type == EMBEDDED) - goto exit; - } + retval = register_pci_slot(slot); } } exit: diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index f2f1cd0..17a0279 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c @@ -49,13 +49,14 @@ static struct pci_bus *find_bus_among_children(struct pci_bus *bus, return child; } -static struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn) +struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn) { if (!dn->phb || !dn->phb->bus) return NULL; return find_bus_among_children(dn->phb->bus, dn); } +EXPORT_SYMBOL_GPL(rpaphp_find_pci_bus); int rpaphp_claim_resource(struct pci_dev *dev, int resource) { @@ -129,10 +130,8 @@ int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value) if (rc) goto exit; - if ((state == EMPTY) || (slot->type == PHB)) { - dbg("slot is empty\n"); + if (state == EMPTY) *value = EMPTY; - } else if (state == PRESENT) { if (!is_init) { /* at run-time slot->state can be changed by */ @@ -423,10 +422,6 @@ int register_pci_slot(struct slot *slot) { int rc = -EINVAL; - if ((slot->type == EMBEDDED) || (slot->type == PHB)) - slot->removable = 0; - else - slot->removable = 1; if (setup_pci_hotplug_slot_info(slot)) goto exit_rc; if (setup_pci_slot(slot)) diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index 8040202..0e88154 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c @@ -30,35 +30,6 @@ #include #include "rpaphp.h" -static ssize_t removable_read_file (struct hotplug_slot *php_slot, char *buf) -{ - u8 value; - int retval = -ENOENT; - struct slot *slot = (struct slot *)php_slot->private; - - if (!slot) - return retval; - - value = slot->removable; - retval = sprintf (buf, "%d\n", value); - return retval; -} - -static struct hotplug_slot_attribute hotplug_slot_attr_removable = { - .attr = {.name = "phy_removable", .mode = S_IFREG | S_IRUGO}, - .show = removable_read_file, -}; - -static void rpaphp_sysfs_add_attr_removable (struct hotplug_slot *slot) -{ - sysfs_create_file(&slot->kobj, &hotplug_slot_attr_removable.attr); -} - -static void rpaphp_sysfs_remove_attr_removable (struct hotplug_slot *slot) -{ - sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_removable.attr); -} - static ssize_t location_read_file (struct hotplug_slot *php_slot, char *buf) { char *value; @@ -176,9 +147,6 @@ int deregister_slot(struct slot *slot) /* remove "phy_location" file */ rpaphp_sysfs_remove_attr_location(php_slot); - /* remove "phy_removable" file */ - rpaphp_sysfs_remove_attr_removable(php_slot); - retval = pci_hp_deregister(php_slot); if (retval) err("Problem unregistering a slot %s\n", slot->name); @@ -212,9 +180,6 @@ int register_slot(struct slot *slot) /* create "phy_locatoin" file */ rpaphp_sysfs_add_attr_location(slot->hotplug_slot); - /* create "phy_removable" file */ - rpaphp_sysfs_add_attr_removable(slot->hotplug_slot); - /* add slot to our internal list */ dbg("%s adding slot[%s] to rpaphp_slot_list\n", __FUNCTION__, slot->name); @@ -230,21 +195,17 @@ int rpaphp_get_power_status(struct slot *slot, u8 * value) { int rc = 0, level; - if (slot->type == HOTPLUG) { - rc = rtas_get_power_level(slot->power_domain, &level); - if (!rc) { - dbg("%s the power level of slot %s(pwd-domain:0x%x) is %d\n", - __FUNCTION__, slot->name, slot->power_domain, level); - *value = level; - } else - err("failed to get power-level for slot(%s), rc=0x%x\n", - slot->location, rc); - } else { - dbg("%s report POWER_ON for EMBEDDED or PHB slot %s\n", - __FUNCTION__, slot->location); - *value = (u8) POWER_ON; + rc = rtas_get_power_level(slot->power_domain, &level); + if (rc < 0) { + err("failed to get power-level for slot(%s), rc=0x%x\n", + slot->location, rc); + return rc; } + dbg("%s the power level of slot %s(pwd-domain:0x%x) is %d\n", + __FUNCTION__, slot->name, slot->power_domain, level); + *value = level; + return rc; } -- cgit v0.10.2 From d42c69972b853fd33a26c8c7405624be41a22136 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Wed, 6 Jul 2005 19:56:03 +0200 Subject: [PATCH] PCI: Run PCI driver initialization on local node Run PCI driver initialization on local node Instead of adding messy kmalloc_node()s everywhere run the PCI driver probe on the node local to the device. This would not have helped for IDE, but should for other more clean drivers that do more initialization in probe(). It won't help for drivers that do most of the work on first open (like many network drivers) Signed-off-by: Andi Kleen Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index e4115a0..414c772 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "pci.h" /* @@ -163,6 +164,34 @@ const struct pci_device_id *pci_match_device(struct pci_driver *drv, return NULL; } +static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, + const struct pci_device_id *id) +{ + int error; +#ifdef CONFIG_NUMA + /* Execute driver initialization on node where the + device's bus is attached to. This way the driver likely + allocates its local memory on the right node without + any need to change it. */ + struct mempolicy *oldpol; + cpumask_t oldmask = current->cpus_allowed; + int node = pcibus_to_node(dev->bus); + if (node >= 0 && node_online(node)) + set_cpus_allowed(current, node_to_cpumask(node)); + /* And set default memory allocation policy */ + oldpol = current->mempolicy; + current->mempolicy = &default_policy; + mpol_get(current->mempolicy); +#endif + error = drv->probe(dev, id); +#ifdef CONFIG_NUMA + set_cpus_allowed(current, oldmask); + mpol_free(current->mempolicy); + current->mempolicy = oldpol; +#endif + return error; +} + /** * __pci_device_probe() * @@ -180,7 +209,7 @@ __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev) id = pci_match_device(drv, pci_dev); if (id) - error = drv->probe(pci_dev, id); + error = pci_call_probe(drv, pci_dev, id); if (error >= 0) { pci_dev->driver = drv; error = 0; diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index 94a46f3..58385ee 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h @@ -155,6 +155,7 @@ struct mempolicy *get_vma_policy(struct task_struct *task, extern void numa_default_policy(void); extern void numa_policy_init(void); +extern struct mempolicy default_policy; #else diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 13492d6..afa06e1 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -88,7 +88,7 @@ static kmem_cache_t *sn_cache; policied. */ static int policy_zone; -static struct mempolicy default_policy = { +struct mempolicy default_policy = { .refcnt = ATOMIC_INIT(1), /* never free it */ .policy = MPOL_DEFAULT, }; -- cgit v0.10.2 From 74d863ee8a9da2b0f31e0f977daf127807b2e9d2 Mon Sep 17 00:00:00 2001 From: "akpm@osdl.org" Date: Mon, 25 Jul 2005 23:28:14 -0700 Subject: [PATCH] PCI: Move PCI fixup data into r/o section Make PCI fixup data const, so it'll end up in a r/o section. This also fixes the conversion into ECOFF which gets broken by too many changes between r/w and r/o sections. Call it a hack but it's a change that's correct by itself. Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/pci.h b/include/linux/pci.h index bc4c400..025bfc3 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1067,7 +1067,7 @@ enum pci_fixup_pass { /* Anonymous variables would be nice... */ #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \ - static struct pci_fixup __pci_fixup_##name __attribute_used__ \ + static const struct pci_fixup __pci_fixup_##name __attribute_used__ \ __attribute__((__section__(#section))) = { vendor, device, hook }; #define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \ -- cgit v0.10.2 From 982245f01734e9d5a3ab98b2b2e9761ae7719094 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sun, 17 Jul 2005 04:22:20 +0200 Subject: [PATCH] PCI: remove CONFIG_PCI_NAMES This patch removes CONFIG_PCI_NAMES. Signed-off-by: Adrian Bunk Signed-off-by: Greg Kroah-Hartman diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index 2e0a01b..5f95d4b 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt @@ -25,15 +25,6 @@ Who: Pavel Machek --------------------------- -What: PCI Name Database (CONFIG_PCI_NAMES) -When: July 2005 -Why: It bloats the kernel unnecessarily, and is handled by userspace better - (pciutils supports it.) Will eliminate the need to try to keep the - pci.ids file in sync with the sf.net database all of the time. -Who: Greg Kroah-Hartman - ---------------------------- - What: io_remap_page_range() (macro or function) When: September 2005 Why: Replaced by io_remap_pfn_range() which allows more memory space diff --git a/MAINTAINERS b/MAINTAINERS index 8e4e829..cb38906 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1813,13 +1813,6 @@ M: hch@infradead.org L: linux-abi-devel@lists.sourceforge.net S: Maintained -PCI ID DATABASE -P: Martin Mares -M: mj@ucw.cz -L: pciids-devel@lists.sourceforge.net -W: http://pciids.sourceforge.net/ -S: Maintained - PCI SOUND DRIVERS (ES1370, ES1371 and SONICVIBES) P: Thomas Sailer M: sailer@ife.ee.ethz.ch diff --git a/arch/alpha/kernel/sys_marvel.c b/arch/alpha/kernel/sys_marvel.c index 8047278..e32fee5 100644 --- a/arch/alpha/kernel/sys_marvel.c +++ b/arch/alpha/kernel/sys_marvel.c @@ -373,12 +373,11 @@ marvel_map_irq(struct pci_dev *dev, u8 slot, u8 pin) irq += 0x80; /* offset for lsi */ #if 1 - printk("PCI:%d:%d:%d (hose %d) [%s] is using MSI\n", + printk("PCI:%d:%d:%d (hose %d) is using MSI\n", dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), - hose->index, - pci_pretty_name (dev)); + hose->index); printk(" %d message(s) from 0x%04x\n", 1 << ((msg_ctl & PCI_MSI_FLAGS_QSIZE) >> 4), msg_dat); diff --git a/arch/ppc64/kernel/eeh.c b/arch/ppc64/kernel/eeh.c index af5272f..4c857a6 100644 --- a/arch/ppc64/kernel/eeh.c +++ b/arch/ppc64/kernel/eeh.c @@ -202,10 +202,9 @@ static void pci_addr_cache_print(struct pci_io_addr_cache *cache) while (n) { struct pci_io_addr_range *piar; piar = rb_entry(n, struct pci_io_addr_range, rb_node); - printk(KERN_DEBUG "PCI: %s addr range %d [%lx-%lx]: %s %s\n", + printk(KERN_DEBUG "PCI: %s addr range %d [%lx-%lx]: %s\n", (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt, - piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev), - pci_pretty_name(piar->pcidev)); + piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev)); cnt++; n = rb_next(n); } @@ -260,8 +259,8 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev) dn = pci_device_to_OF_node(dev); if (!dn) { - printk(KERN_WARNING "PCI: no pci dn found for dev=%s %s\n", - pci_name(dev), pci_pretty_name(dev)); + printk(KERN_WARNING "PCI: no pci dn found for dev=%s\n", + pci_name(dev)); return; } @@ -269,8 +268,8 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev) if (!(dn->eeh_mode & EEH_MODE_SUPPORTED) || dn->eeh_mode & EEH_MODE_NOCHECK) { #ifdef DEBUG - printk(KERN_INFO "PCI: skip building address cache for=%s %s\n", - pci_name(dev), pci_pretty_name(dev)); + printk(KERN_INFO "PCI: skip building address cache for=%s\n", + pci_name(dev)); #endif return; } @@ -447,12 +446,12 @@ static void eeh_panic(struct pci_dev *dev, int reset_state) * in light of potential corruption, we can use it here. */ if (panic_on_oops) - panic("EEH: MMIO failure (%d) on device:%s %s\n", reset_state, - pci_name(dev), pci_pretty_name(dev)); + panic("EEH: MMIO failure (%d) on device:%s\n", reset_state, + pci_name(dev)); else { __get_cpu_var(ignored_failures)++; - printk(KERN_INFO "EEH: Ignored MMIO failure (%d) on device:%s %s\n", - reset_state, pci_name(dev), pci_pretty_name(dev)); + printk(KERN_INFO "EEH: Ignored MMIO failure (%d) on device:%s\n", + reset_state, pci_name(dev)); } } @@ -482,8 +481,8 @@ static void eeh_event_handler(void *dummy) break; printk(KERN_INFO "EEH: MMIO failure (%d), notifiying device " - "%s %s\n", event->reset_state, - pci_name(event->dev), pci_pretty_name(event->dev)); + "%s\n", event->reset_state, + pci_name(event->dev)); atomic_set(&eeh_fail_count, 0); notifier_call_chain (&eeh_notifier_chain, @@ -851,8 +850,7 @@ void eeh_add_device_late(struct pci_dev *dev) return; #ifdef DEBUG - printk(KERN_DEBUG "EEH: adding device %s %s\n", pci_name(dev), - pci_pretty_name(dev)); + printk(KERN_DEBUG "EEH: adding device %s\n", pci_name(dev)); #endif pci_addr_cache_insert_device (dev); @@ -873,8 +871,7 @@ void eeh_remove_device(struct pci_dev *dev) /* Unregister the device with the EEH/PCI address search system */ #ifdef DEBUG - printk(KERN_DEBUG "EEH: remove device %s %s\n", pci_name(dev), - pci_pretty_name(dev)); + printk(KERN_DEBUG "EEH: remove device %s\n", pci_name(dev)); #endif pci_addr_cache_remove_device(dev); } diff --git a/arch/ppc64/kernel/iSeries_VpdInfo.c b/arch/ppc64/kernel/iSeries_VpdInfo.c index d11c732..5d92179 100644 --- a/arch/ppc64/kernel/iSeries_VpdInfo.c +++ b/arch/ppc64/kernel/iSeries_VpdInfo.c @@ -264,8 +264,5 @@ void __init iSeries_Device_Information(struct pci_dev *PciDev, int count) printk("%d. PCI: Bus%3d, Device%3d, Vendor %04X Frame%3d, Card %4s ", count, bus, PCI_SLOT(PciDev->devfn), PciDev->vendor, frame, card); - if (pci_class_name(PciDev->class >> 8) == 0) - printk("0x%04X\n", (int)(PciDev->class >> 8)); - else - printk("%s\n", pci_class_name(PciDev->class >> 8)); + printk("0x%04X\n", (int)(PciDev->class >> 8)); } diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c index d0d55c7..b5ca7d8 100644 --- a/arch/ppc64/kernel/pci.c +++ b/arch/ppc64/kernel/pci.c @@ -84,7 +84,6 @@ static void fixup_broken_pcnet32(struct pci_dev* dev) if ((dev->class>>8 == PCI_CLASS_NETWORK_ETHERNET)) { dev->vendor = PCI_VENDOR_ID_AMD; pci_write_config_word(dev, PCI_VENDOR_ID, PCI_VENDOR_ID_AMD); - pci_name_device(dev); } } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TRIDENT, PCI_ANY_ID, fixup_broken_pcnet32); diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h index 6f98701..121cc85 100644 --- a/drivers/char/drm/drmP.h +++ b/drivers/char/drm/drmP.h @@ -1071,5 +1071,9 @@ extern void *drm_calloc(size_t nmemb, size_t size, int area); extern unsigned long drm_core_get_map_ofs(drm_map_t *map); extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); +#ifndef pci_pretty_name +#define pci_pretty_name(dev) "" +#endif + #endif /* __KERNEL__ */ #endif diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c index 3241d6c..ffbcd40 100644 --- a/drivers/infiniband/hw/mthca/mthca_main.c +++ b/drivers/infiniband/hw/mthca/mthca_main.c @@ -937,12 +937,12 @@ static int __devinit mthca_init_one(struct pci_dev *pdev, ++mthca_version_printed; } - printk(KERN_INFO PFX "Initializing %s (%s)\n", - pci_pretty_name(pdev), pci_name(pdev)); + printk(KERN_INFO PFX "Initializing %s\n", + pci_name(pdev)); if (id->driver_data >= ARRAY_SIZE(mthca_hca_table)) { - printk(KERN_ERR PFX "%s (%s) has invalid driver data %lx\n", - pci_pretty_name(pdev), pci_name(pdev), id->driver_data); + printk(KERN_ERR PFX "%s has invalid driver data %lx\n", + pci_name(pdev), id->driver_data); return -ENODEV; } diff --git a/drivers/infiniband/hw/mthca/mthca_reset.c b/drivers/infiniband/hw/mthca/mthca_reset.c index 8ea8012..4f99539 100644 --- a/drivers/infiniband/hw/mthca/mthca_reset.c +++ b/drivers/infiniband/hw/mthca/mthca_reset.c @@ -71,8 +71,8 @@ int mthca_reset(struct mthca_dev *mdev) bridge)) != NULL) { if (bridge->hdr_type == PCI_HEADER_TYPE_BRIDGE && bridge->subordinate == mdev->pdev->bus) { - mthca_dbg(mdev, "Found bridge: %s (%s)\n", - pci_pretty_name(bridge), pci_name(bridge)); + mthca_dbg(mdev, "Found bridge: %s\n", + pci_name(bridge)); break; } } @@ -83,8 +83,8 @@ int mthca_reset(struct mthca_dev *mdev) * assume we're in no-bridge mode and hope for * the best. */ - mthca_warn(mdev, "No bridge found for %s (%s)\n", - pci_pretty_name(mdev->pdev), pci_name(mdev->pdev)); + mthca_warn(mdev, "No bridge found for %s\n", + pci_name(mdev->pdev)); } } diff --git a/drivers/net/irda/vlsi_ir.h b/drivers/net/irda/vlsi_ir.h index 414694a..741aecc 100644 --- a/drivers/net/irda/vlsi_ir.h +++ b/drivers/net/irda/vlsi_ir.h @@ -69,14 +69,8 @@ typedef void irqreturn_t; #else /* 2.5 or later */ -/* recent 2.5/2.6 stores pci device names at varying places ;-) */ -#ifdef CONFIG_PCI_NAMES -/* human readable name */ -#define PCIDEV_NAME(pdev) ((pdev)->pretty_name) -#else /* whatever we get from the associated struct device - bus:slot:dev.fn id */ #define PCIDEV_NAME(pdev) (pci_name(pdev)) -#endif #endif diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 7f31991..f187fd8 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -30,23 +30,6 @@ config PCI_LEGACY_PROC When in doubt, say N. -config PCI_NAMES - bool "PCI device name database" - depends on PCI - ---help--- - By default, the kernel contains a database of all known PCI device - names to make the information in /proc/pci, /proc/ioports and - similar files comprehensible to the user. - - This database increases size of the kernel image by about 80KB. This - memory is freed after the system boots up if CONFIG_HOTPLUG is not set. - - Anyway, if you are building an installation floppy or kernel for an - embedded system where kernel image size really matters, you can disable - this feature and you'll get device ID numbers instead of names. - - When in doubt, say Y. - config PCI_DEBUG bool "PCI Debugging" depends on PCI && DEBUG_KERNEL diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 3657f61..87cbf2d 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -3,8 +3,7 @@ # obj-y += access.o bus.o probe.o remove.o pci.o quirks.o \ - names.o pci-driver.o search.o pci-sysfs.o \ - rom.o + pci-driver.o search.o pci-sysfs.o rom.o obj-$(CONFIG_PROC_FS) += proc.o ifndef CONFIG_SPARC64 @@ -46,21 +45,6 @@ ifeq ($(CONFIG_PCI_DEBUG),y) EXTRA_CFLAGS += -DDEBUG endif -hostprogs-y := gen-devlist - -# Dependencies on generated files need to be listed explicitly -$(obj)/names.o: $(obj)/devlist.h $(obj)/classlist.h -$(obj)/classlist.h: $(obj)/devlist.h - -# And that's how to generate them -quiet_cmd_devlist = DEVLIST $@ - cmd_devlist = ( cd $(obj); ./gen-devlist ) < $< -$(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist - $(call cmd,devlist) - -# Files generated that shall be removed upon make clean -clean-files := devlist.h classlist.h - # Build PCI Express stuff if needed obj-$(CONFIG_PCIEPORTBUS) += pcie/ diff --git a/drivers/pci/gen-devlist.c b/drivers/pci/gen-devlist.c deleted file mode 100644 index 8abfc49..0000000 --- a/drivers/pci/gen-devlist.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Generate devlist.h and classlist.h from the PCI ID file. - * - * (c) 1999--2002 Martin Mares - */ - -#include -#include - -#define MAX_NAME_SIZE 200 - -static void -pq(FILE *f, const char *c, int len) -{ - int i = 1; - while (*c && i != len) { - if (*c == '"') - fprintf(f, "\\\""); - else { - fputc(*c, f); - if (*c == '?' && c[1] == '?') { - /* Avoid trigraphs */ - fprintf(f, "\" \""); - } - } - c++; - i++; - } -} - -int -main(void) -{ - char line[1024], *c, *bra, vend[8]; - int vendors = 0; - int mode = 0; - int lino = 0; - int vendor_len = 0; - FILE *devf, *clsf; - - devf = fopen("devlist.h", "w"); - clsf = fopen("classlist.h", "w"); - if (!devf || !clsf) { - fprintf(stderr, "Cannot create output file!\n"); - return 1; - } - - while (fgets(line, sizeof(line)-1, stdin)) { - lino++; - if ((c = strchr(line, '\n'))) - *c = 0; - if (!line[0] || line[0] == '#') - continue; - if (line[1] == ' ') { - if (line[0] == 'C' && strlen(line) > 4 && line[4] == ' ') { - vend[0] = line[2]; - vend[1] = line[3]; - vend[2] = 0; - mode = 2; - } else goto err; - } - else if (line[0] == '\t') { - if (line[1] == '\t') - continue; - switch (mode) { - case 1: - if (strlen(line) > 5 && line[5] == ' ') { - c = line + 5; - while (*c == ' ') - *c++ = 0; - if (vendor_len + strlen(c) + 1 > MAX_NAME_SIZE) { - /* Too long, try cutting off long description */ - bra = strchr(c, '['); - if (bra && bra > c && bra[-1] == ' ') - bra[-1] = 0; - if (vendor_len + strlen(c) + 1 > MAX_NAME_SIZE) { - fprintf(stderr, "Line %d: Device name too long. Name truncated.\n", lino); - fprintf(stderr, "%s\n", c); - /*return 1;*/ - } - } - fprintf(devf, "\tDEVICE(%s,%s,\"", vend, line+1); - pq(devf, c, MAX_NAME_SIZE - vendor_len - 1); - fputs("\")\n", devf); - } else goto err; - break; - case 2: - if (strlen(line) > 3 && line[3] == ' ') { - c = line + 3; - while (*c == ' ') - *c++ = 0; - fprintf(clsf, "CLASS(%s%s, \"%s\")\n", vend, line+1, c); - } else goto err; - break; - default: - goto err; - } - } else if (strlen(line) > 4 && line[4] == ' ') { - c = line + 4; - while (*c == ' ') - *c++ = 0; - if (vendors) - fputs("ENDVENDOR()\n\n", devf); - vendors++; - strcpy(vend, line); - vendor_len = strlen(c); - if (vendor_len + 24 > MAX_NAME_SIZE) { - fprintf(stderr, "Line %d: Vendor name too long\n", lino); - return 1; - } - fprintf(devf, "VENDOR(%s,\"", vend); - pq(devf, c, 0); - fputs("\")\n", devf); - mode = 1; - } else { - err: - fprintf(stderr, "Line %d: Syntax error in mode %d: %s\n", lino, mode, line); - return 1; - } - } - fputs("ENDVENDOR()\n\ -\n\ -#undef VENDOR\n\ -#undef DEVICE\n\ -#undef ENDVENDOR\n", devf); - fputs("\n#undef CLASS\n", clsf); - - fclose(devf); - fclose(clsf); - - return 0; -} diff --git a/drivers/pci/names.c b/drivers/pci/names.c deleted file mode 100644 index ad224aa..0000000 --- a/drivers/pci/names.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * PCI Class and Device Name Tables - * - * Copyright 1993--1999 Drew Eckhardt, Frederic Potter, - * David Mosberger-Tang, Martin Mares - */ - -#include -#include -#include -#include -#include - -#ifdef CONFIG_PCI_NAMES - -struct pci_device_info { - unsigned short device; - unsigned short seen; - const char *name; -}; - -struct pci_vendor_info { - unsigned short vendor; - unsigned short nr; - const char *name; - struct pci_device_info *devices; -}; - -/* - * This is ridiculous, but we want the strings in - * the .init section so that they don't take up - * real memory.. Parse the same file multiple times - * to get all the info. - */ -#define VENDOR( vendor, name ) static char __vendorstr_##vendor[] __devinitdata = name; -#define ENDVENDOR() -#define DEVICE( vendor, device, name ) static char __devicestr_##vendor##device[] __devinitdata = name; -#include "devlist.h" - - -#define VENDOR( vendor, name ) static struct pci_device_info __devices_##vendor[] __devinitdata = { -#define ENDVENDOR() }; -#define DEVICE( vendor, device, name ) { 0x##device, 0, __devicestr_##vendor##device }, -#include "devlist.h" - -static struct pci_vendor_info __devinitdata pci_vendor_list[] = { -#define VENDOR( vendor, name ) { 0x##vendor, sizeof(__devices_##vendor) / sizeof(struct pci_device_info), __vendorstr_##vendor, __devices_##vendor }, -#define ENDVENDOR() -#define DEVICE( vendor, device, name ) -#include "devlist.h" -}; - -#define VENDORS (sizeof(pci_vendor_list)/sizeof(struct pci_vendor_info)) - -void __devinit pci_name_device(struct pci_dev *dev) -{ - const struct pci_vendor_info *vendor_p = pci_vendor_list; - int i = VENDORS; - char *name = dev->pretty_name; - - do { - if (vendor_p->vendor == dev->vendor) - goto match_vendor; - vendor_p++; - } while (--i); - - /* Couldn't find either the vendor nor the device */ - sprintf(name, "PCI device %04x:%04x", dev->vendor, dev->device); - return; - - match_vendor: { - struct pci_device_info *device_p = vendor_p->devices; - int i = vendor_p->nr; - - while (i > 0) { - if (device_p->device == dev->device) - goto match_device; - device_p++; - i--; - } - - /* Ok, found the vendor, but unknown device */ - sprintf(name, "PCI device %04x:%04x (%." PCI_NAME_HALF "s)", - dev->vendor, dev->device, vendor_p->name); - return; - - /* Full match */ - match_device: { - char *n = name + sprintf(name, "%s %s", - vendor_p->name, device_p->name); - int nr = device_p->seen + 1; - device_p->seen = nr; - if (nr > 1) - sprintf(n, " (#%d)", nr); - } - } -} - -/* - * Class names. Not in .init section as they are needed in runtime. - */ - -static u16 pci_class_numbers[] = { -#define CLASS(x,y) 0x##x, -#include "classlist.h" -}; - -static char *pci_class_names[] = { -#define CLASS(x,y) y, -#include "classlist.h" -}; - -char * -pci_class_name(u32 class) -{ - int i; - - for(i=0; i and other volunteers from the -# Linux PCI ID's Project at http://pciids.sf.net/. New data are always -# welcome (if they are accurate), we're eagerly expecting new entries, -# so if you have anything to contribute, please visit the home page or -# send a diff -u against the most recent pci.ids to pci-ids@ucw.cz. -# -# Daily snapshot on Tue 2005-03-08 10:11:48 -# - -# Vendors, devices and subsystems. Please keep sorted. - -# Syntax: -# vendor vendor_name -# device device_name <-- single tab -# subvendor subdevice subsystem_name <-- two tabs - -0000 Gammagraphx, Inc. -001a Ascend Communications, Inc. -0033 Paradyne corp. -003d Lockheed Martin-Marietta Corp -# Real TJN ID is e159, but they got it wrong several times --mj -0059 Tiger Jet Network Inc. (Wrong ID) -0070 Hauppauge computer works Inc. - 4000 WinTV PVR-350 - 4001 WinTV PVR-250 (v1) - 4009 WinTV PVR-250 - 4801 WinTV PVR-250 MCE -0071 Nebula Electronics Ltd. -0095 Silicon Image, Inc. (Wrong ID) - 0680 Ultra ATA/133 IDE RAID CONTROLLER CARD -0100 Ncipher Corp Ltd -# 018a is not LevelOne but there is a board misprogrammed -018a LevelOne - 0106 FPC-0106TX misprogrammed [RTL81xx] -# 021b is not Compaq but there is a board misprogrammed -021b Compaq Computer Corporation - 8139 HNE-300 (RealTek RTL8139c) [iPaq Networking] -# http://www.davicom.com.tw/ -0291 Davicom Semiconductor, Inc. - 8212 DM9102A(DM9102AE, SM9102AF) Ethernet 100/10 MBit(Rev 40) -# SpeedStream is Efficient Networks, Inc, a Siemens Company -02ac SpeedStream - 1012 1012 PCMCIA 10/100 Ethernet Card [RTL81xx] -0357 TTTech AG - 000a TTP-Monitoring Card V2.0 -0432 SCM Microsystems, Inc. - 0001 Pluto2 DVB-T Receiver for PCMCIA [EasyWatch MobilSet] -05e3 CyberDoor - 0701 CBD516 -0675 Dynalink - 1700 IS64PH ISDN Adapter - 1702 IS64PH ISDN Adapter -# Wrong ID used in subsystem ID of VIA USB controllers. -0925 VIA Technologies, Inc. (Wrong ID) -09c1 Arris - 0704 CM 200E Cable Modem -0a89 BREA Technologies Inc -0b49 ASCII Corporation -# see http://homepage1.nifty.com/mcn/lab/machines/trance_vibrator/usbview.vib.txt - 064f Trance Vibrator -0e11 Compaq Computer Corporation - 0001 PCI to EISA Bridge - 0002 PCI to ISA Bridge - 0046 Smart Array 64xx - 0e11 409a Smart Array 641 - 0e11 409b Smart Array 642 - 0e11 409c Smart Array 6400 - 0e11 409d Smart Array 6400 EM - 0049 NC7132 Gigabit Upgrade Module - 004a NC6136 Gigabit Server Adapter - 007c NC7770 1000BaseTX - 007d NC6770 1000BaseTX - 0085 NC7780 1000BaseTX - 00bb NC7760 - 00ca NC7771 - 00cb NC7781 - 00cf NC7772 - 00d0 NC7782 - 00d1 NC7783 - 00e3 NC7761 - 0508 Netelligent 4/16 Token Ring - 1000 Triflex/Pentium Bridge, Model 1000 - 2000 Triflex/Pentium Bridge, Model 2000 - 3032 QVision 1280/p - 3033 QVision 1280/p - 3034 QVision 1280/p - 4000 4000 [Triflex] - 4030 SMART-2/P - 4031 SMART-2SL - 4032 Smart Array 3200 - 4033 Smart Array 3100ES - 4034 Smart Array 221 - 4040 Integrated Array - 4048 Compaq Raid LC2 - 4050 Smart Array 4200 - 4051 Smart Array 4250ES - 4058 Smart Array 431 - 4070 Smart Array 5300 - 4080 Smart Array 5i - 4082 Smart Array 532 - 4083 Smart Array 5312 - 4091 Smart Array 6i - 409a Smart Array 641 - 409b Smart Array 642 - 409c Smart Array 6400 - 409d Smart Array 6400 EM - 6010 HotPlug PCI Bridge 6010 - 7020 USB Controller - a0ec Fibre Channel Host Controller - a0f0 Advanced System Management Controller - a0f3 Triflex PCI to ISA Bridge - a0f7 PCI Hotplug Controller - 8086 002a PCI Hotplug Controller A - 8086 002b PCI Hotplug Controller B - a0f8 ZFMicro Chipset USB - a0fc FibreChannel HBA Tachyon - ae10 Smart-2/P RAID Controller - 0e11 4030 Smart-2/P Array Controller - 0e11 4031 Smart-2SL Array Controller - 0e11 4032 Smart Array Controller - 0e11 4033 Smart 3100ES Array Controller - ae29 MIS-L - ae2a MPC - ae2b MIS-E - ae31 System Management Controller - ae32 Netelligent 10/100 TX PCI UTP - ae33 Triflex Dual EIDE Controller - ae34 Netelligent 10 T PCI UTP - ae35 Integrated NetFlex-3/P - ae40 Netelligent Dual 10/100 TX PCI UTP - ae43 Netelligent Integrated 10/100 TX UTP - ae69 CETUS-L - ae6c Northstar - ae6d NorthStar CPU to PCI Bridge - b011 Netelligent 10/100 TX Embedded UTP - b012 Netelligent 10 T/2 PCI UTP/Coax - b01e NC3120 Fast Ethernet NIC - b01f NC3122 Fast Ethernet NIC - b02f NC1120 Ethernet NIC - b030 Netelligent 10/100 TX UTP - b04a 10/100 TX PCI Intel WOL UTP Controller - b060 Smart Array 5300 Controller - b0c6 NC3161 Fast Ethernet NIC - b0c7 NC3160 Fast Ethernet NIC - b0d7 NC3121 Fast Ethernet NIC - b0dd NC3131 Fast Ethernet NIC - b0de NC3132 Fast Ethernet Module - b0df NC6132 Gigabit Module - b0e0 NC6133 Gigabit Module - b0e1 NC3133 Fast Ethernet Module - b123 NC6134 Gigabit NIC - b134 NC3163 Fast Ethernet NIC - b13c NC3162 Fast Ethernet NIC - b144 NC3123 Fast Ethernet NIC - b163 NC3134 Fast Ethernet NIC - b164 NC3165 Fast Ethernet Upgrade Module - b178 Smart Array 5i/532 - 0e11 4080 Smart Array 5i - 0e11 4082 Smart Array 532 - 0e11 4083 Smart Array 5312 - b1a4 NC7131 Gigabit Server Adapter -# HP Memory Hot-Plug Controller - b200 Memory Hot-Plug Controller - b203 Integrated Lights Out Controller - b204 Integrated Lights Out Processor - f130 NetFlex-3/P ThunderLAN 1.0 - f150 NetFlex-3/P ThunderLAN 2.3 -0e55 HaSoTec GmbH -# Formerly NCR -1000 LSI Logic / Symbios Logic - 0001 53c810 - 1000 1000 LSI53C810AE PCI to SCSI I/O Processor - 0002 53c820 - 0003 53c825 - 1000 1000 LSI53C825AE PCI to SCSI I/O Processor (Ultra Wide) - 0004 53c815 - 0005 53c810AP - 0006 53c860 - 1000 1000 LSI53C860E PCI to Ultra SCSI I/O Processor - 000a 53c1510 - 1000 1000 LSI53C1510 PCI to Dual Channel Wide Ultra2 SCSI Controller (Nonintelligent mode) - 000b 53C896/897 - 0e11 6004 EOB003 Series SCSI host adapter - 1000 1000 LSI53C896/7 PCI to Dual Channel Ultra2 SCSI Multifunction Controller - 1000 1010 LSI22910 PCI to Dual Channel Ultra2 SCSI host adapter - 1000 1020 LSI21002 PCI to Dual Channel Ultra2 SCSI host adapter -# multifunction PCI card: Dual U2W SCSI, dual 10/100TX, graphics - 13e9 1000 6221L-4U - 000c 53c895 - 1000 1010 LSI8951U PCI to Ultra2 SCSI host adapter - 1000 1020 LSI8952U PCI to Ultra2 SCSI host adapter - 1de1 3906 DC-390U2B SCSI adapter - 1de1 3907 DC-390U2W - 000d 53c885 - 000f 53c875 - 0e11 7004 Embedded Ultra Wide SCSI Controller - 1000 1000 LSI53C876/E PCI to Dual Channel SCSI Controller - 1000 1010 LSI22801 PCI to Dual Channel Ultra SCSI host adapter - 1000 1020 LSI22802 PCI to Dual Channel Ultra SCSI host adapter - 1092 8760 FirePort 40 Dual SCSI Controller - 1de1 3904 DC390F/U Ultra Wide SCSI Adapter - 4c53 1000 CC7/CR7/CP7/VC7/VP7/VR7 mainboard - 4c53 1050 CT7 mainboard - 0010 53C1510 - 0e11 4040 Integrated Array Controller - 0e11 4048 RAID LC2 Controller - 1000 1000 53C1510 PCI to Dual Channel Wide Ultra2 SCSI Controller (Intelligent mode) - 0012 53c895a - 1000 1000 LSI53C895A PCI to Ultra2 SCSI Controller - 0013 53c875a - 1000 1000 LSI53C875A PCI to Ultra SCSI Controller - 0020 53c1010 Ultra3 SCSI Adapter - 1000 1000 LSI53C1010-33 PCI to Dual Channel Ultra160 SCSI Controller - 1de1 1020 DC-390U3W - 0021 53c1010 66MHz Ultra3 SCSI Adapter - 1000 1000 LSI53C1000/1000R/1010R/1010-66 PCI to Ultra160 SCSI Controller - 1000 1010 Asus TR-DLS onboard 53C1010-66 - 124b 1070 PMC-USCSI3 - 4c53 1080 CT8 mainboard - 4c53 1300 P017 mezzanine (32-bit PMC) - 4c53 1310 P017 mezzanine (64-bit PMC) - 0030 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI - 1028 0123 PowerEdge 2600 - 1028 014a PowerEdge 1750 - 1028 016c PowerEdge 1850 MPT Fusion SCSI/RAID (Perc 4) - 1028 0183 PowerEdge 1800 - 1028 1010 LSI U320 SCSI Controller - 0031 53c1030ZC PCI-X Fusion-MPT Dual Ultra320 SCSI - 0032 53c1035 PCI-X Fusion-MPT Dual Ultra320 SCSI - 1000 1000 LSI53C1020/1030 PCI-X to Ultra320 SCSI Controller - 0033 1030ZC_53c1035 PCI-X Fusion-MPT Dual Ultra320 SCSI - 0040 53c1035 PCI-X Fusion-MPT Dual Ultra320 SCSI - 1000 0033 MegaRAID SCSI 320-2XR - 1000 0066 MegaRAID SCSI 320-2XRWS - 0041 53C1035ZC PCI-X Fusion-MPT Dual Ultra320 SCSI - 008f 53c875J - 1092 8000 FirePort 40 SCSI Controller - 1092 8760 FirePort 40 Dual SCSI Host Adapter - 0407 MegaRAID - 1000 0530 MegaRAID 530 SCSI 320-0X RAID Controller - 1000 0531 MegaRAID 531 SCSI 320-4X RAID Controller - 1000 0532 MegaRAID 532 SCSI 320-2X RAID Controller - 1028 0531 PowerEdge Expandable RAID Controller 4/QC - 1028 0533 PowerEdge Expandable RAID Controller 4/QC - 8086 0530 MegaRAID Intel RAID Controller SRCZCRX - 8086 0532 MegaRAID Intel RAID Controller SRCU42X - 0408 MegaRAID - 1000 0001 MegaRAID SCSI 320-1E RAID Controller - 1000 0002 MegaRAID SCSI 320-2E RAID Controller - 1025 004d MegaRAID ACER ROMB-2E RAID Controller - 1028 0001 PowerEdge RAID Controller PERC4e/SC - 1028 0002 PowerEdge RAID Controller PERC4e/DC - 1734 1065 FSC MegaRAID PCI Express ROMB - 8086 0002 MegaRAID Intel RAID Controller SRCU42E - 0409 MegaRAID - 1000 3004 MegaRAID SATA 300-4X RAID Controller - 1000 3008 MegaRAID SATA 300-8X RAID Controller - 8086 3008 MegaRAID RAID Controller SRCS28X - 8086 3431 MegaRAID RAID Controller Alief SROMBU42E - 8086 3499 MegaRAID RAID Controller Harwich SROMBU42E - 0621 FC909 Fibre Channel Adapter - 0622 FC929 Fibre Channel Adapter - 1000 1020 44929 O Dual Fibre Channel card - 0623 FC929 LAN - 0624 FC919 Fibre Channel Adapter - 0625 FC919 LAN - 0626 FC929X Fibre Channel Adapter - 1000 1010 7202-XP-LC Dual Fibre Channel card - 0627 FC929X LAN - 0628 FC919X Fibre Channel Adapter - 0629 FC919X LAN - 0701 83C885 NT50 DigitalScape Fast Ethernet - 0702 Yellowfin G-NIC gigabit ethernet - 1318 0000 PEI100X - 0804 SA2010 - 0805 SA2010ZC - 0806 SA2020 - 0807 SA2020ZC - 0901 61C102 - 1000 63C815 - 1960 MegaRAID - 1000 0518 MegaRAID 518 SCSI 320-2 Controller - 1000 0520 MegaRAID 520 SCSI 320-1 Controller - 1000 0522 MegaRAID 522 i4 133 RAID Controller - 1000 0523 MegaRAID SATA 150-6 RAID Controller - 1000 4523 MegaRAID SATA 150-4 RAID Controller - 1000 a520 MegaRAID ZCR SCSI 320-0 Controller - 1028 0518 MegaRAID 518 DELL PERC 4/DC RAID Controller - 1028 0520 MegaRAID 520 DELL PERC 4/SC RAID Controller - 1028 0531 PowerEdge Expandable RAID Controller 4/QC - 1028 0533 PowerEdge Expandable RAID Controller 4/QC - 8086 0520 MegaRAIDRAID Controller SRCU41L - 8086 0523 MegaRAID RAID Controller SRCS16 -1001 Kolter Electronic - 0010 PCI 1616 Measurement card with 32 digital I/O lines - 0011 OPTO-PCI Opto-Isolated digital I/O board - 0012 PCI-AD/DA Analogue I/O board - 0013 PCI-OPTO-RELAIS Digital I/O board with relay outputs - 0014 PCI-Counter/Timer Counter Timer board - 0015 PCI-DAC416 Analogue output board - 0016 PCI-MFB Analogue I/O board - 0017 PROTO-3 PCI Prototyping board - 9100 INI-9100/9100W SCSI Host -1002 ATI Technologies Inc - 3150 M24 1P [Radeon Mobility X600] - 3154 M24 1T [FireGL M24 GL] - 3e50 RV380 0x3e50 [Radeon X600] - 3e54 RV380 0x3e54 [FireGL V3200] - 3e70 RV380 [Radeon X600] Secondary - 4136 Radeon IGP 320 M - 4137 Radeon IGP330/340/350 - 4144 R300 AD [Radeon 9500 Pro] -# New PCI ID provided by ATI developer relations (correction to above) - 4145 R300 AE [Radeon 9700 Pro] -# New PCI ID provided by ATI developer relations (oops, correction to above) - 4146 R300 AF [Radeon 9700 Pro] - 4147 R300 AG [FireGL Z1/X1] - 4148 R350 AH [Radeon 9800] - 4149 R350 AI [Radeon 9800] - 414a R350 AJ [Radeon 9800] - 414b R350 AK [Fire GL X2] -# New PCI ID provided by ATI developer relations - 4150 RV350 AP [Radeon 9600] - 1002 0002 R9600 Pro primary (Asus OEM for HP) - 1002 0003 R9600 Pro secondary (Asus OEM for HP) - 1458 4024 Giga-Byte GV-R96128D Primary - 148c 2064 PowerColor R96A-C3N - 148c 2066 PowerColor R96A-C3N - 174b 7c19 Sapphire Atlantis Radeon 9600 Pro - 174b 7c29 GC-R9600PRO Primary [Sapphire] - 17ee 2002 Radeon 9600 256Mb Primary - 18bc 0101 GC-R9600PRO Primary -# New PCI ID provided by ATI developer relations - 4151 RV350 AQ [Radeon 9600] - 1043 c004 A9600SE -# New PCI ID provided by ATI developer relations - 4152 RV350 AR [Radeon 9600] - 1002 0002 Radeon 9600XT - 1043 c002 Radeon 9600 XT TVD - 174b 7c29 Sapphire Radeon 9600XT - 1787 4002 Radeon 9600 XT - 4153 RV350 AS [Radeon 9600 AS] - 4154 RV350 AT [Fire GL T2] - 4155 RV350 AU [Fire GL T2] - 4156 RV350 AV [Fire GL T2] - 4157 RV350 AW [Fire GL T2] - 4158 68800AX [Mach32] -# The PCI ID is unrelated to any DVI output. - 4164 R300 AD [Radeon 9500 Pro] (Secondary) -# New PCI ID info provided by ATI developer relations - 4165 R300 AE [Radeon 9700 Pro] (Secondary) -# New PCI ID info provided by ATI developer relations - 4166 R300 AF [Radeon 9700 Pro] (Secondary) -# New PCI ID provided by ATI developer relations - 4168 Radeon R350 [Radeon 9800] (Secondary) -# New PCI ID provided by ATI developer relations (correction to above) - 4170 RV350 AP [Radeon 9600] (Secondary) - 1458 4025 Giga-Byte GV-R96128D Secondary - 148c 2067 PowerColor R96A-C3N (Secondary) - 174b 7c28 GC-R9600PRO Secondary [Sapphire] - 17ee 2003 Radeon 9600 256Mb Secondary - 18bc 0100 GC-R9600PRO Secondary -# New PCI ID provided by ATI developer relations (correction to above) - 4171 RV350 AQ [Radeon 9600] (Secondary) - 1043 c005 A9600SE (Secondary) -# New PCI ID provided by ATI developer relations (correction to above) - 4172 RV350 AR [Radeon 9600] (Secondary) - 1002 0003 Radeon 9600XT (Secondary) - 1043 c003 A9600XT (Secondary) - 174b 7c28 Sapphire Radeon 9600XT (Secondary) - 1787 4003 Radeon 9600 XT (Secondary) - 4173 RV350 ?? [Radeon 9550] (Secondary) - 4237 Radeon 7000 IGP - 4242 R200 BB [Radeon All in Wonder 8500DV] - 1002 02aa Radeon 8500 AIW DV Edition - 4243 R200 BC [Radeon All in Wonder 8500] - 4336 Radeon Mobility U1 - 103c 0024 Pavilion ze4400 builtin Video - 4337 Radeon IGP 330M/340M/350M - 1014 053a ThinkPad R40e (2684-HVG) builtin VGA controller - 103c 0850 Radeon IGP 345M - 4341 IXP150 AC'97 Audio Controller - 4345 EHCI USB Controller - 4347 OHCI USB Controller #1 - 4348 OHCI USB Controller #2 - 4349 ATI Dual Channel Bus Master PCI IDE Controller - 434d IXP AC'97 Modem - 4353 ATI SMBus - 4354 215CT [Mach64 CT] - 4358 210888CX [Mach64 CX] - 4363 ATI SMBus - 436e ATI 436E Serial ATA Controller - 4372 ATI SMBus - 4376 Standard Dual Channel PCI IDE Controller ATI - 4379 ATI 4379 Serial ATA Controller - 437a ATI 437A Serial ATA Controller - 4437 Radeon Mobility 7000 IGP - 4554 210888ET [Mach64 ET] - 4654 Mach64 VT - 4742 3D Rage Pro AGP 1X/2X - 1002 0040 Rage Pro Turbo AGP 2X - 1002 0044 Rage Pro Turbo AGP 2X - 1002 0061 Rage Pro AIW AGP 2X - 1002 0062 Rage Pro AIW AGP 2X - 1002 0063 Rage Pro AIW AGP 2X - 1002 0080 Rage Pro Turbo AGP 2X - 1002 0084 Rage Pro Turbo AGP 2X - 1002 4742 Rage Pro Turbo AGP 2X - 1002 8001 Rage Pro Turbo AGP 2X - 1028 0082 Rage Pro Turbo AGP 2X - 1028 4082 Optiplex GX1 Onboard Display Adapter - 1028 8082 Rage Pro Turbo AGP 2X - 1028 c082 Rage Pro Turbo AGP 2X - 8086 4152 Xpert 98D AGP 2X - 8086 464a Rage Pro Turbo AGP 2X - 4744 3D Rage Pro AGP 1X - 1002 4744 Rage Pro Turbo AGP - 4747 3D Rage Pro - 4749 3D Rage Pro - 1002 0061 Rage Pro AIW - 1002 0062 Rage Pro AIW - 474c Rage XC - 474d Rage XL AGP 2X - 1002 0004 Xpert 98 RXL AGP 2X - 1002 0008 Xpert 98 RXL AGP 2X - 1002 0080 Rage XL AGP 2X - 1002 0084 Xpert 98 AGP 2X - 1002 474d Rage XL AGP - 1033 806a Rage XL AGP - 474e Rage XC AGP - 1002 474e Rage XC AGP - 474f Rage XL - 1002 0008 Rage XL - 1002 474f Rage XL - 4750 3D Rage Pro 215GP - 1002 0040 Rage Pro Turbo - 1002 0044 Rage Pro Turbo - 1002 0080 Rage Pro Turbo - 1002 0084 Rage Pro Turbo - 1002 4750 Rage Pro Turbo - 4751 3D Rage Pro 215GQ - 4752 Rage XL - 1002 0008 Rage XL - 1002 4752 Rage XL - 1002 8008 Rage XL - 1028 00ce PowerEdge 1400 - 1028 00d1 PowerEdge 2550 - 1028 00d9 PowerEdge 2500 - 8086 3411 SDS2 Mainboard - 8086 3427 S875WP1-E mainboard - 4753 Rage XC - 1002 4753 Rage XC - 4754 3D Rage I/II 215GT [Mach64 GT] - 4755 3D Rage II+ 215GTB [Mach64 GTB] - 4756 3D Rage IIC 215IIC [Mach64 GT IIC] - 1002 4756 Rage IIC - 4757 3D Rage IIC AGP - 1002 4757 Rage IIC AGP - 1028 0089 Rage 3D IIC - 1028 4082 Rage 3D IIC - 1028 8082 Rage 3D IIC - 1028 c082 Rage 3D IIC - 4758 210888GX [Mach64 GX] - 4759 3D Rage IIC - 475a 3D Rage IIC AGP - 1002 0084 Rage 3D Pro AGP 2x XPERT 98 - 1002 0087 Rage 3D IIC - 1002 475a Rage IIC AGP - 4964 Radeon RV250 Id [Radeon 9000] - 4965 Radeon RV250 Ie [Radeon 9000] - 4966 Radeon RV250 If [Radeon 9000] - 10f1 0002 RV250 If [Tachyon G9000 PRO] - 148c 2039 RV250 If [Radeon 9000 Pro "Evil Commando"] - 1509 9a00 RV250 If [Radeon 9000 "AT009"] -# New subdevice - 3D Prophet 9000 PCI by Hercules. AGP version probably would have same ID, so not specified. - 1681 0040 RV250 If [3D prophet 9000] - 174b 7176 RV250 If [Sapphire Radeon 9000 Pro] - 174b 7192 RV250 If [Radeon 9000 "Atlantis"] - 17af 2005 RV250 If [Excalibur Radeon 9000 Pro] - 17af 2006 RV250 If [Excalibur Radeon 9000] - 4967 Radeon RV250 Ig [Radeon 9000] - 496e Radeon RV250 [Radeon 9000] (Secondary) - 4a48 R420 JH [Radeon X800] - 4a49 R420 JI [Radeon X800PRO] - 4a4a R420 JJ [Radeon X800SE] - 4a4b R420 JK [Radeon X800] - 4a4c R420 JL [Radeon X800] - 4a4d R420 JM [FireGL X3] - 4a4e M18 JN [Radeon Mobility 9800] - 4a50 R420 JP [Radeon X800XT] - 4a70 R420 [X800XT-PE] (Secondary) - 4c42 3D Rage LT Pro AGP-133 - 0e11 b0e7 Rage LT Pro (Compaq Presario 5240) - 0e11 b0e8 Rage 3D LT Pro - 0e11 b10e 3D Rage LT Pro (Compaq Armada 1750) - 1002 0040 Rage LT Pro AGP 2X - 1002 0044 Rage LT Pro AGP 2X - 1002 4c42 Rage LT Pro AGP 2X - 1002 8001 Rage LT Pro AGP 2X - 1028 0085 Rage 3D LT Pro - 4c44 3D Rage LT Pro AGP-66 - 4c45 Rage Mobility M3 AGP - 4c46 Rage Mobility M3 AGP 2x - 1028 00b1 Latitude C600 - 4c47 3D Rage LT-G 215LG - 4c49 3D Rage LT Pro - 1002 0004 Rage LT Pro - 1002 0040 Rage LT Pro - 1002 0044 Rage LT Pro - 1002 4c49 Rage LT Pro - 4c4d Rage Mobility P/M AGP 2x - 0e11 b111 Armada M700 - 0e11 b160 Armada E500 - 1002 0084 Xpert 98 AGP 2X (Mobility) - 1014 0154 ThinkPad A20m - 1028 00aa Latitude CPt - 1028 00bb Latitude CPx - 4c4e Rage Mobility L AGP 2x - 4c50 3D Rage LT Pro - 1002 4c50 Rage LT Pro - 4c51 3D Rage LT Pro - 4c52 Rage Mobility P/M - 1033 8112 Versa Note VXi - 4c53 Rage Mobility L - 4c54 264LT [Mach64 LT] - 4c57 Radeon Mobility M7 LW [Radeon Mobility 7500] - 1014 0517 ThinkPad T30 - 1028 00e6 Radeon Mobility M7 LW (Dell Inspiron 8100) - 1028 012a Latitude C640 - 144d c006 Radeon Mobility M7 LW in vpr Matrix 170B4 - 4c58 Radeon RV200 LX [Mobility FireGL 7800 M7] - 4c59 Radeon Mobility M6 LY - 1014 0235 ThinkPad A30/A30p (2652/2653) - 1014 0239 ThinkPad X22/X23/X24 - 104d 80e7 VAIO PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP - 4c5a Radeon Mobility M6 LZ - 4c64 Radeon R250 Ld [Radeon Mobility 9000 M9] - 4c65 Radeon R250 Le [Radeon Mobility 9000 M9] - 4c66 Radeon R250 Lf [FireGL 9000] - 4c67 Radeon R250 Lg [Radeon Mobility 9000 M9] -# Secondary chip to the Lf - 4c6e Radeon R250 Ln [Radeon Mobility 9000 M9] [Secondary] - 4d46 Rage Mobility M4 AGP - 4d4c Rage Mobility M4 AGP - 4e44 Radeon R300 ND [Radeon 9700 Pro] - 4e45 Radeon R300 NE [Radeon 9500 Pro] - 1002 0002 Radeon R300 NE [Radeon 9500 Pro] - 1681 0002 Hercules 3D Prophet 9500 PRO [Radeon 9500 Pro] -# New PCI ID provided by ATI developer relations (correction to above) - 4e46 RV350 NF [Radeon 9600] - 4e47 Radeon R300 NG [FireGL X1] -# (added pro) - 4e48 Radeon R350 [Radeon 9800 Pro] -# New PCI ID provided by ATI developer relations - 4e49 Radeon R350 [Radeon 9800] - 4e4a RV350 NJ [Radeon 9800 XT] - 4e4b R350 NK [Fire GL X2] -# New PCI ID provided by ATI developer relations - 4e50 RV350 [Mobility Radeon 9600 M10] - 1025 005a TravelMate 290 - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 1734 1055 Amilo M1420W - 4e51 M10 NQ [Radeon Mobility 9600] - 4e52 RV350 [Mobility Radeon 9600 M10] - 4e53 M10 NS [Radeon Mobility 9600] - 4e54 M10 NT [FireGL Mobility T2] - 4e56 M11 NV [FireGL Mobility T2e] - 4e64 Radeon R300 [Radeon 9700 Pro] (Secondary) - 4e65 Radeon R300 [Radeon 9500 Pro] (Secondary) - 1002 0003 Radeon R300 NE [Radeon 9500 Pro] - 1681 0003 Hercules 3D Prophet 9500 PRO [Radeon 9500 Pro] (Secondary) -# New PCI ID provided by ATI developer relations (correction to above) - 4e66 RV350 NF [Radeon 9600] (Secondary) - 4e67 Radeon R300 [FireGL X1] (Secondary) -# (added pro) - 4e68 Radeon R350 [Radeon 9800 Pro] (Secondary) -# New PCI ID provided by ATI developer relations - 4e69 Radeon R350 [Radeon 9800] (Secondary) - 4e6a RV350 NJ [Radeon 9800 XT] (Secondary) - 1002 4e71 ATI Technologies Inc M10 NQ [Radeon Mobility 9600] - 5041 Rage 128 PA/PRO - 5042 Rage 128 PB/PRO AGP 2x - 5043 Rage 128 PC/PRO AGP 4x - 5044 Rage 128 PD/PRO TMDS - 1002 0028 Rage 128 AIW - 1002 0029 Rage 128 AIW - 5045 Rage 128 PE/PRO AGP 2x TMDS - 5046 Rage 128 PF/PRO AGP 4x TMDS - 1002 0004 Rage Fury Pro - 1002 0008 Rage Fury Pro/Xpert 2000 Pro - 1002 0014 Rage Fury Pro - 1002 0018 Rage Fury Pro/Xpert 2000 Pro - 1002 0028 Rage 128 Pro AIW AGP - 1002 002a Rage 128 Pro AIW AGP - 1002 0048 Rage Fury Pro - 1002 2000 Rage Fury MAXX AGP 4x (TMDS) (VGA device) - 1002 2001 Rage Fury MAXX AGP 4x (TMDS) (Extra device?!) - 5047 Rage 128 PG/PRO - 5048 Rage 128 PH/PRO AGP 2x - 5049 Rage 128 PI/PRO AGP 4x - 504a Rage 128 PJ/PRO TMDS - 504b Rage 128 PK/PRO AGP 2x TMDS - 504c Rage 128 PL/PRO AGP 4x TMDS - 504d Rage 128 PM/PRO - 504e Rage 128 PN/PRO AGP 2x - 504f Rage 128 PO/PRO AGP 4x - 5050 Rage 128 PP/PRO TMDS [Xpert 128] - 1002 0008 Xpert 128 - 5051 Rage 128 PQ/PRO AGP 2x TMDS - 5052 Rage 128 PR/PRO AGP 4x TMDS - 5053 Rage 128 PS/PRO - 5054 Rage 128 PT/PRO AGP 2x - 5055 Rage 128 PU/PRO AGP 4x - 5056 Rage 128 PV/PRO TMDS - 5057 Rage 128 PW/PRO AGP 2x TMDS - 5058 Rage 128 PX/PRO AGP 4x TMDS - 5144 Radeon R100 QD [Radeon 7200] - 1002 0008 Radeon 7000/Radeon VE - 1002 0009 Radeon 7000/Radeon - 1002 000a Radeon 7000/Radeon - 1002 001a Radeon 7000/Radeon - 1002 0029 Radeon AIW - 1002 0038 Radeon 7000/Radeon - 1002 0039 Radeon 7000/Radeon - 1002 008a Radeon 7000/Radeon - 1002 00ba Radeon 7000/Radeon - 1002 0139 Radeon 7000/Radeon - 1002 028a Radeon 7000/Radeon - 1002 02aa Radeon AIW - 1002 053a Radeon 7000/Radeon - 5145 Radeon R100 QE - 5146 Radeon R100 QF - 5147 Radeon R100 QG - 5148 Radeon R200 QH [Radeon 8500] - 1002 010a FireGL 8800 64Mb - 1002 0152 FireGL 8800 128Mb - 1002 0162 FireGL 8700 32Mb - 1002 0172 FireGL 8700 64Mb - 5149 Radeon R200 QI - 514a Radeon R200 QJ - 514b Radeon R200 QK - 514c Radeon R200 QL [Radeon 8500 LE] - 1002 003a Radeon R200 QL [Radeon 8500 LE] - 1002 013a Radeon 8500 - 148c 2026 R200 QL [Radeon 8500 Evil Master II Multi Display Edition] - 1681 0010 Radeon 8500 [3D Prophet 8500 128Mb] - 174b 7149 Radeon R200 QL [Sapphire Radeon 8500 LE] - 514d Radeon R200 QM [Radeon 9100] - 514e Radeon R200 QN [Radeon 8500LE] - 514f Radeon R200 QO [Radeon 8500LE] - 5154 R200 QT [Radeon 8500] - 5155 R200 QU [Radeon 9100] - 5157 Radeon RV200 QW [Radeon 7500] - 1002 013a Radeon 7500 - 1002 103a Dell Optiplex GX260 - 1458 4000 RV200 QW [RADEON 7500 PRO MAYA AR] - 148c 2024 RV200 QW [Radeon 7500LE Dual Display] - 148c 2025 RV200 QW [Radeon 7500 Evil Master Multi Display Edition] - 148c 2036 RV200 QW [Radeon 7500 PCI Dual Display] - 174b 7146 RV200 QW [Radeon 7500 LE] - 174b 7147 RV200 QW [Sapphire Radeon 7500LE] - 174b 7161 Radeon RV200 QW [Radeon 7500 LE] - 17af 0202 RV200 QW [Excalibur Radeon 7500LE] - 5158 Radeon RV200 QX [Radeon 7500] - 5159 Radeon RV100 QY [Radeon 7000/VE] - 1002 000a Radeon 7000/Radeon VE - 1002 000b Radeon 7000 - 1002 0038 Radeon 7000/Radeon VE - 1002 003a Radeon 7000/Radeon VE - 1002 00ba Radeon 7000/Radeon VE - 1002 013a Radeon 7000/Radeon VE - 1458 4002 RV100 QY [RADEON 7000 PRO MAYA AV Series] - 148c 2003 RV100 QY [Radeon 7000 Multi-Display Edition] - 148c 2023 RV100 QY [Radeon 7000 Evil Master Multi-Display] - 174b 7112 RV100 QY [Sapphire Radeon VE 7000] - 174b 7c28 Sapphire Radeon VE 7000 DDR - 1787 0202 RV100 QY [Excalibur Radeon 7000] - 515a Radeon RV100 QZ [Radeon 7000/VE] - 5168 Radeon R200 Qh - 5169 Radeon R200 Qi - 516a Radeon R200 Qj - 516b Radeon R200 Qk -# This one is not in ATI documentation, but is in XFree86 source code - 516c Radeon R200 Ql - 5245 Rage 128 RE/SG - 1002 0008 Xpert 128 - 1002 0028 Rage 128 AIW - 1002 0029 Rage 128 AIW - 1002 0068 Rage 128 AIW - 5246 Rage 128 RF/SG AGP - 1002 0004 Magnum/Xpert 128/Xpert 99 - 1002 0008 Magnum/Xpert128/X99/Xpert2000 - 1002 0028 Rage 128 AIW AGP - 1002 0044 Rage Fury/Xpert 128/Xpert 2000 - 1002 0068 Rage 128 AIW AGP - 1002 0448 Rage Fury - 5247 Rage 128 RG - 524b Rage 128 RK/VR - 524c Rage 128 RL/VR AGP - 1002 0008 Xpert 99/Xpert 2000 - 1002 0088 Xpert 99 - 5345 Rage 128 SE/4x - 5346 Rage 128 SF/4x AGP 2x - 1002 0048 RAGE 128 16MB VGA TVOUT AMC PAL - 5347 Rage 128 SG/4x AGP 4x - 5348 Rage 128 SH - 534b Rage 128 SK/4x - 534c Rage 128 SL/4x AGP 2x - 534d Rage 128 SM/4x AGP 4x - 1002 0008 Xpert 99/Xpert 2000 - 1002 0018 Xpert 2000 - 534e Rage 128 4x - 5354 Mach 64 VT - 1002 5654 Mach 64 reference - 5446 Rage 128 Pro Ultra TF - 1002 0004 Rage Fury Pro - 1002 0008 Rage Fury Pro/Xpert 2000 Pro - 1002 0018 Rage Fury Pro/Xpert 2000 Pro - 1002 0028 Rage 128 AIW Pro AGP - 1002 0029 Rage 128 AIW - 1002 002a Rage 128 AIW Pro AGP - 1002 002b Rage 128 AIW - 1002 0048 Xpert 2000 Pro - 544c Rage 128 Pro Ultra TL - 5452 Rage 128 Pro Ultra TR - 1002 001c Rage 128 Pro 4XL - 103c 1279 Rage 128 Pro 4XL - 5453 Rage 128 Pro Ultra TS - 5454 Rage 128 Pro Ultra TT - 5455 Rage 128 Pro Ultra TU - 5460 M22 [Radeon Mobility M300] - 5464 M22 [FireGL GL] - 5548 R423 UH [Radeon X800 (PCIE)] - 5549 R423 UI [Radeon X800PRO (PCIE)] - 554a R423 UJ [Radeon X800LE (PCIE)] - 554b R423 UK [Radeon X800SE (PCIE)] - 5551 R423 UQ [FireGL V7200 (PCIE)] - 5552 R423 UR [FireGL V5100 (PCIE)] - 5554 R423 UT [FireGL V7100 (PCIE)] - 556b Radeon R423 UK (PCIE) [X800 SE] (Secondary) - 5654 264VT [Mach64 VT] - 1002 5654 Mach64VT Reference - 5655 264VT3 [Mach64 VT3] - 5656 264VT4 [Mach64 VT4] - 5830 RS300 Host Bridge - 5831 RS300 Host Bridge - 5832 RS300 Host Bridge - 5833 Radeon 9100 IGP Host Bridge - 5834 Radeon 9100 IGP - 5835 RS300M AGP [Radeon Mobility 9100IGP] - 5838 Radeon 9100 IGP AGP Bridge - 5941 RV280 [Radeon 9200] (Secondary) - 1458 4019 Gigabyte Radeon 9200 - 174b 7c12 Sapphire Radeon 9200 -# http://www.hightech.com.hk/html/9200.htm - 17af 200d Excalibur Radeon 9200 - 18bc 0050 GeXcube GC-R9200-C3 (Secondary) - 5944 RV280 [Radeon 9200 SE (PCI)] - 5960 RV280 [Radeon 9200 PRO] - 5961 RV280 [Radeon 9200] - 1002 2f72 All-in-Wonder 9200 Series - 1019 4c30 Radeon 9200 VIVO - 12ab 5961 YUAN SMARTVGA Radeon 9200 - 1458 4018 Gigabyte Radeon 9200 - 174b 7c13 Sapphire Radeon 9200 -# http://www.hightech.com.hk/html/9200.htm - 17af 200c Excalibur Radeon 9200 - 18bc 0050 Radeon 9200 Game Buster - 18bc 0051 GeXcube GC-R9200-C3 - 18bc 0053 Radeon 9200 Game Buster VIVO - 5962 RV280 [Radeon 9200] - 5964 RV280 [Radeon 9200 SE] - 1043 c006 ASUS Radeon 9200 SE / TD / 128M - 1458 4018 Radeon 9200 SE - 148c 2073 CN-AG92E - 174b 7c13 Sapphire Radeon 9200 SE - 1787 5964 Excalibur 9200SE VIVO 128M - 17af 2012 Radeon 9200 SE Excalibur - 18bc 0170 Sapphire Radeon 9200 SE 128MB Game Buster -# 128MB DDR, DVI/VGA/TV out - 18bc 0173 GC-R9200L(SE)-C3H [Radeon 9200 Game Buster] - 5b60 RV370 5B60 [Radeon X300 (PCIE)] - 1043 002a Extreme AX300SE-X - 1043 032e Extreme AX300/TD - 5b62 RV370 5B62 [Radeon X600 (PCIE)] - 5b64 RV370 5B64 [FireGL V3100 (PCIE)] - 5b65 RV370 5B65 [FireGL D1100 (PCIE)] - 5c61 M9+ 5C61 [Radeon Mobility 9200 (AGP)] - 5c63 M9+ 5C63 [Radeon Mobility 9200 (AGP)] - 5d44 RV280 [Radeon 9200 SE] (Secondary) - 1458 4019 Radeon 9200 SE (Secondary) - 174b 7c12 Sapphire Radeon 9200 SE (Secondary) - 1787 5965 Excalibur 9200SE VIVO 128M (Secondary) - 17af 2013 Radeon 9200 SE Excalibur (Secondary) - 18bc 0171 Radeon 9200 SE 128MB Game Buster (Secondary) - 18bc 0172 GC-R9200L(SE)-C3H [Radeon 9200 Game Buster] - 5d4d R480 [Radeon X850XT Platinum] - 5d57 R423 5F57 [Radeon X800XT (PCIE)] - 700f PCI Bridge [IGP 320M] - 7010 PCI Bridge [IGP 340M] - 7834 Radeon 9100 PRO IGP - 7835 Radeon Mobility 9200 IGP - 7c37 RV350 AQ [Radeon 9600 SE] - cab0 AGP Bridge [IGP 320M] - cab2 RS200/RS200M AGP Bridge [IGP 340M] - cbb2 RS200/RS200M AGP Bridge [IGP 340M] -1003 ULSI Systems - 0201 US201 -1004 VLSI Technology Inc - 0005 82C592-FC1 - 0006 82C593-FC1 - 0007 82C594-AFC2 - 0008 82C596/7 [Wildcat] - 0009 82C597-AFC2 - 000c 82C541 [Lynx] - 000d 82C543 [Lynx] - 0101 82C532 - 0102 82C534 [Eagle] - 0103 82C538 - 0104 82C535 - 0105 82C147 - 0200 82C975 - 0280 82C925 - 0304 QSound ThunderBird PCI Audio - 1004 0304 QSound ThunderBird PCI Audio - 122d 1206 DSP368 Audio - 1483 5020 XWave Thunder 3D Audio - 0305 QSound ThunderBird PCI Audio Gameport - 1004 0305 QSound ThunderBird PCI Audio Gameport - 122d 1207 DSP368 Audio Gameport - 1483 5021 XWave Thunder 3D Audio Gameport - 0306 QSound ThunderBird PCI Audio Support Registers - 1004 0306 QSound ThunderBird PCI Audio Support Registers - 122d 1208 DSP368 Audio Support Registers - 1483 5022 XWave Thunder 3D Audio Support Registers - 0307 Thunderbird - 0308 Thunderbird - 0702 VAS96011 [Golden Gate II] - 0703 Tollgate -1005 Avance Logic Inc. [ALI] - 2064 ALG2032/2064 - 2128 ALG2364A - 2301 ALG2301 - 2302 ALG2302 - 2364 ALG2364 - 2464 ALG2364A - 2501 ALG2564A/25128A -1006 Reply Group -1007 NetFrame Systems Inc -1008 Epson -100a Phoenix Technologies -100b National Semiconductor Corporation - 0001 DP83810 - 0002 87415/87560 IDE - 000e 87560 Legacy I/O - 000f FireWire Controller - 0011 NS87560 National PCI System I/O - 0012 USB Controller - 0020 DP83815 (MacPhyter) Ethernet Controller - 103c 0024 Pavilion ze4400 builtin Network - 1385 f311 FA311 / FA312 (FA311 with WoL HW) - 0022 DP83820 10/100/1000 Ethernet Controller - 0028 Geode GX2 Host Bridge - 002a CS5535 South Bridge - 002b CS5535 ISA bridge - 002d CS5535 IDE - 002e CS5535 Audio - 002f CS5535 USB - 0030 Geode GX2 Graphics Processor - 0035 DP83065 [Saturn] 10/100/1000 Ethernet Controller - 0500 SCx200 Bridge - 0501 SCx200 SMI - 0502 SCx200 IDE - 0503 SCx200 Audio - 0504 SCx200 Video - 0505 SCx200 XBus - 0510 SC1100 Bridge - 0511 SC1100 SMI - 0515 SC1100 XBus - d001 87410 IDE -100c Tseng Labs Inc - 3202 ET4000/W32p rev A - 3205 ET4000/W32p rev B - 3206 ET4000/W32p rev C - 3207 ET4000/W32p rev D - 3208 ET6000 - 4702 ET6300 -100d AST Research Inc -100e Weitek - 9000 P9000 Viper - 9001 P9000 Viper - 9002 P9000 Viper - 9100 P9100 Viper Pro/SE -1010 Video Logic, Ltd. -1011 Digital Equipment Corporation - 0001 DECchip 21050 - 0002 DECchip 21040 [Tulip] - 0004 DECchip 21030 [TGA] - 0007 NVRAM [Zephyr NVRAM] - 0008 KZPSA [KZPSA] - 0009 DECchip 21140 [FasterNet] - 1025 0310 21140 Fast Ethernet - 10b8 2001 SMC9332BDT EtherPower 10/100 - 10b8 2002 SMC9332BVT EtherPower T4 10/100 - 10b8 2003 SMC9334BDT EtherPower 10/100 (1-port) - 1109 2400 ANA-6944A/TX Fast Ethernet - 1112 2300 RNS2300 Fast Ethernet - 1112 2320 RNS2320 Fast Ethernet - 1112 2340 RNS2340 Fast Ethernet - 1113 1207 EN-1207-TX Fast Ethernet - 1186 1100 DFE-500TX Fast Ethernet - 1186 1112 DFE-570TX Fast Ethernet - 1186 1140 DFE-660 Cardbus Ethernet 10/100 - 1186 1142 DFE-660 Cardbus Ethernet 10/100 - 11f6 0503 Freedomline Fast Ethernet - 1282 9100 AEF-380TXD Fast Ethernet - 1385 1100 FA310TX Fast Ethernet - 2646 0001 KNE100TX Fast Ethernet - 000a 21230 Video Codec - 000d PBXGB [TGA2] - 000f DEFPA - 0014 DECchip 21041 [Tulip Pass 3] - 1186 0100 DE-530+ - 0016 DGLPB [OPPO] - 0017 PV-PCI Graphics Controller (ZLXp-L) - 0019 DECchip 21142/43 - 1011 500a DE500A Fast Ethernet - 1011 500b DE500B Fast Ethernet - 1014 0001 10/100 EtherJet Cardbus - 1025 0315 ALN315 Fast Ethernet - 1033 800c PC-9821-CS01 100BASE-TX Interface Card - 1033 800d PC-9821NR-B06 100BASE-TX Interface Card - 108d 0016 Rapidfire 2327 10/100 Ethernet - 108d 0017 GoCard 2250 Ethernet 10/100 Cardbus - 10b8 2005 SMC8032DT Extreme Ethernet 10/100 - 10b8 8034 SMC8034 Extreme Ethernet 10/100 - 10ef 8169 Cardbus Fast Ethernet - 1109 2a00 ANA-6911A/TX Fast Ethernet - 1109 2b00 ANA-6911A/TXC Fast Ethernet - 1109 3000 ANA-6922/TX Fast Ethernet - 1113 1207 Cheetah Fast Ethernet - 1113 2220 Cardbus Fast Ethernet - 115d 0002 Cardbus Ethernet 10/100 - 1179 0203 Fast Ethernet - 1179 0204 Cardbus Fast Ethernet - 1186 1100 DFE-500TX Fast Ethernet - 1186 1101 DFE-500TX Fast Ethernet - 1186 1102 DFE-500TX Fast Ethernet - 1186 1112 DFE-570TX Quad Fast Ethernet - 1259 2800 AT-2800Tx Fast Ethernet - 1266 0004 Eagle Fast EtherMAX - 12af 0019 NetFlyer Cardbus Fast Ethernet - 1374 0001 Cardbus Ethernet Card 10/100 - 1374 0002 Cardbus Ethernet Card 10/100 - 1374 0007 Cardbus Ethernet Card 10/100 - 1374 0008 Cardbus Ethernet Card 10/100 - 1385 2100 FA510 - 1395 0001 10/100 Ethernet CardBus PC Card - 13d1 ab01 EtherFast 10/100 Cardbus (PCMPC200) - 14cb 0100 LNDL-100N 100Base-TX Ethernet PC Card - 8086 0001 EtherExpress PRO/100 Mobile CardBus 32 - 001a Farallon PN9000SX Gigabit Ethernet - 0021 DECchip 21052 - 0022 DECchip 21150 - 0023 DECchip 21150 - 0024 DECchip 21152 - 0025 DECchip 21153 - 0026 DECchip 21154 - 0034 56k Modem Cardbus - 1374 0003 56k Modem Cardbus - 0045 DECchip 21553 - 0046 DECchip 21554 - 0e11 4050 Integrated Smart Array - 0e11 4051 Integrated Smart Array - 0e11 4058 Integrated Smart Array - 103c 10c2 Hewlett-Packard NetRAID-4M - 12d9 000a IP Telephony card - 4c53 1050 CT7 mainboard - 4c53 1051 CE7 mainboard - 9005 0364 5400S (Mustang) - 9005 0365 5400S (Mustang) - 9005 1364 Dell PowerEdge RAID Controller 2 - 9005 1365 Dell PowerEdge RAID Controller 2 - e4bf 1000 CC8-1-BLUES - 1065 StrongARM DC21285 - 1069 0020 DAC960P / DAC1164P -1012 Micronics Computers Inc -1013 Cirrus Logic - 0038 GD 7548 - 0040 GD 7555 Flat Panel GUI Accelerator - 004c GD 7556 Video/Graphics LCD/CRT Ctrlr - 00a0 GD 5430/40 [Alpine] - 00a2 GD 5432 [Alpine] - 00a4 GD 5434-4 [Alpine] - 00a8 GD 5434-8 [Alpine] - 00ac GD 5436 [Alpine] - 00b0 GD 5440 - 00b8 GD 5446 - 00bc GD 5480 - 1013 00bc CL-GD5480 - 00d0 GD 5462 - 00d2 GD 5462 [Laguna I] - 00d4 GD 5464 [Laguna] - 00d5 GD 5464 BD [Laguna] - 00d6 GD 5465 [Laguna] - 13ce 8031 Barco Metheus 2 Megapixel, Dual Head - 13cf 8031 Barco Metheus 2 Megapixel, Dual Head - 00e8 GD 5436U - 1100 CL 6729 - 1110 PD 6832 PCMCIA/CardBus Ctrlr - 1112 PD 6834 PCMCIA/CardBus Ctrlr - 1113 PD 6833 PCMCIA/CardBus Ctrlr - 1200 GD 7542 [Nordic] - 1202 GD 7543 [Viking] - 1204 GD 7541 [Nordic Light] - 4000 MD 5620 [CLM Data Fax Voice] - 4400 CD 4400 - 6001 CS 4610/11 [CrystalClear SoundFusion Audio Accelerator] - 1014 1010 CS4610 SoundFusion Audio Accelerator - 6003 CS 4614/22/24 [CrystalClear SoundFusion Audio Accelerator] - 1013 4280 Crystal SoundFusion PCI Audio Accelerator - 153b 1136 SiXPack 5.1+ - 1681 0050 Game Theater XP - 1681 a011 Fortissimo III 7.1 - 6004 CS 4614/22/24 [CrystalClear SoundFusion Audio Accelerator] - 6005 Crystal CS4281 PCI Audio - 1013 4281 Crystal CS4281 PCI Audio - 10cf 10a8 Crystal CS4281 PCI Audio - 10cf 10a9 Crystal CS4281 PCI Audio - 10cf 10aa Crystal CS4281 PCI Audio - 10cf 10ab Crystal CS4281 PCI Audio - 10cf 10ac Crystal CS4281 PCI Audio - 10cf 10ad Crystal CS4281 PCI Audio - 10cf 10b4 Crystal CS4281 PCI Audio - 1179 0001 Crystal CS4281 PCI Audio - 14c0 000c Crystal CS4281 PCI Audio -1014 IBM - 0002 PCI to MCA Bridge - 0005 Alta Lite - 0007 Alta MP - 000a Fire Coral - 0017 CPU to PCI Bridge - 0018 TR Auto LANstreamer - 001b GXT-150P - 001c Carrera - 001d 82G2675 - 0020 GXT1000 Graphics Adapter - 0022 IBM27-82351 - 002d Python -# [official name in AIX 5] - 002e SCSI RAID Adapter [ServeRAID] - 1014 002e ServeRAID-3x - 1014 022e ServeRAID-4H - 0031 2 Port Serial Adapter -# AS400 iSeries PCI sync serial card - 1014 0031 2721 WAN IOA - 2 Port Sync Serial Adapter - 0036 Miami - 0037 82660 CPU to PCI Bridge - 003a CPU to PCI Bridge - 003c GXT250P/GXT255P Graphics Adapter - 003e 16/4 Token ring UTP/STP controller - 1014 003e Token-Ring Adapter - 1014 00cd Token-Ring Adapter + Wake-On-LAN - 1014 00ce 16/4 Token-Ring Adapter 2 - 1014 00cf 16/4 Token-Ring Adapter Special - 1014 00e4 High-Speed 100/16/4 Token-Ring Adapter - 1014 00e5 16/4 Token-Ring Adapter 2 + Wake-On-LAN - 1014 016d iSeries 2744 Card - 0045 SSA Adapter - 0046 MPIC interrupt controller - 0047 PCI to PCI Bridge - 0048 PCI to PCI Bridge - 0049 Warhead SCSI Controller - 004e ATM Controller (14104e00) - 004f ATM Controller (14104f00) - 0050 ATM Controller (14105000) - 0053 25 MBit ATM Controller - 0054 GXT500P/GXT550P Graphics Adapter - 0057 MPEG PCI Bridge - 005c i82557B 10/100 - 005e GXT800P Graphics Adapter - 007c ATM Controller (14107c00) - 007d 3780IDSP [MWave] - 008b EADS PCI to PCI Bridge - 008e GXT3000P Graphics Adapter - 0090 GXT 3000P - 1014 008e GXT-3000P - 0091 SSA Adapter - 0095 20H2999 PCI Docking Bridge - 0096 Chukar chipset SCSI controller - 1014 0097 iSeries 2778 DASD IOA - 1014 0098 iSeries 2763 DASD IOA - 1014 0099 iSeries 2748 DASD IOA - 009f PCI 4758 Cryptographic Accelerator - 00a5 ATM Controller (1410a500) - 00a6 ATM 155MBPS MM Controller (1410a600) - 00b7 256-bit Graphics Rasterizer [Fire GL1] - 1092 00b8 FireGL1 AGP 32Mb - 00b8 GXT2000P Graphics Adapter - 00be ATM 622MBPS Controller (1410be00) - 00dc Advanced Systems Management Adapter (ASMA) - 00fc CPC710 Dual Bridge and Memory Controller (PCI-64) - 0104 Gigabit Ethernet-SX Adapter - 0105 CPC710 Dual Bridge and Memory Controller (PCI-32) - 010f Remote Supervisor Adapter (RSA) - 0142 Yotta Video Compositor Input - 1014 0143 Yotta Input Controller (ytin) - 0144 Yotta Video Compositor Output - 1014 0145 Yotta Output Controller (ytout) - 0156 405GP PLB to PCI Bridge - 015e 622Mbps ATM PCI Adapter - 0160 64bit/66MHz PCI ATM 155 MMF - 016e GXT4000P Graphics Adapter - 0170 GXT6000P Graphics Adapter - 017d GXT300P Graphics Adapter - 0180 Snipe chipset SCSI controller - 1014 0241 iSeries 2757 DASD IOA - 1014 0264 Quad Channel PCI-X U320 SCSI RAID Adapter (2780) - 0188 EADS-X PCI-X to PCI-X Bridge - 01a7 PCI-X to PCI-X Bridge - 01bd ServeRAID Controller - 1014 01be ServeRAID-4M - 1014 01bf ServeRAID-4L - 1014 0208 ServeRAID-4Mx - 1014 020e ServeRAID-4Lx - 1014 022e ServeRAID-4H - 1014 0258 ServeRAID-5i - 1014 0259 ServeRAID-5i - 01c1 64bit/66MHz PCI ATM 155 UTP - 01e6 Cryptographic Accelerator - 01ff 10/100 Mbps Ethernet - 0219 Multiport Serial Adapter - 1014 021a Dual RVX - 1014 0251 Internal Modem/RVX - 1014 0252 Quad Internal Modem - 021b GXT6500P Graphics Adapter - 021c GXT4500P Graphics Adapter - 0233 GXT135P Graphics Adapter - 0266 PCI-X Dual Channel SCSI - 0268 Gigabit Ethernet-SX Adapter (PCI-X) - 0269 10/100/1000 Base-TX Ethernet Adapter (PCI-X) - 028c Citrine chipset SCSI controller - 1014 028D Dual Channel PCI-X DDR SAS RAID Adapter (572E) - 1014 02BE Dual Channel PCI-X DDR U320 SCSI RAID Adapter (571B) - 1014 02C0 Dual Channel PCI-X DDR U320 SCSI Adapter (571A) - 0302 X-Architecture Bridge [Summit] - 0314 ZISC 036 Neural accelerator card - ffff MPIC-2 interrupt controller -1015 LSI Logic Corp of Canada -1016 ICL Personal Systems -1017 SPEA Software AG - 5343 SPEA 3D Accelerator -1018 Unisys Systems -1019 Elitegroup Computer Systems -101a AT&T GIS (NCR) - 0005 100VG ethernet -101b Vitesse Semiconductor -101c Western Digital - 0193 33C193A - 0196 33C196A - 0197 33C197A - 0296 33C296A - 3193 7193 - 3197 7197 - 3296 33C296A - 4296 34C296 - 9710 Pipeline 9710 - 9712 Pipeline 9712 - c24a 90C -101e American Megatrends Inc. - 1960 MegaRAID - 101e 0471 MegaRAID 471 Enterprise 1600 RAID Controller - 101e 0475 MegaRAID 475 Express 500/500LC RAID Controller - 101e 0477 MegaRAID 477 Elite 3100 RAID Controller - 101e 0493 MegaRAID 493 Elite 1600 RAID Controller - 101e 0494 MegaRAID 494 Elite 1650 RAID Controller - 101e 0503 MegaRAID 503 Enterprise 1650 RAID Controller - 101e 0511 MegaRAID 511 i4 IDE RAID Controller - 101e 0522 MegaRAID 522 i4133 RAID Controller - 1028 0471 PowerEdge RAID Controller 3/QC - 1028 0475 PowerEdge RAID Controller 3/SC - 1028 0493 PowerEdge RAID Controller 3/DC - 1028 0511 PowerEdge Cost Effective RAID Controller ATA100/4Ch - 9010 MegaRAID 428 Ultra RAID Controller - 9030 EIDE Controller - 9031 EIDE Controller - 9032 EIDE & SCSI Controller - 9033 SCSI Controller - 9040 Multimedia card - 9060 MegaRAID 434 Ultra GT RAID Controller - 9063 MegaRAC - 101e 0767 Dell Remote Assistant Card 2 -101f PictureTel -1020 Hitachi Computer Products -1021 OKI Electric Industry Co. Ltd. -1022 Advanced Micro Devices [AMD] - 1100 K8 [Athlon64/Opteron] HyperTransport Technology Configuration - 1101 K8 [Athlon64/Opteron] Address Map - 1102 K8 [Athlon64/Opteron] DRAM Controller - 1103 K8 [Athlon64/Opteron] Miscellaneous Control - 2000 79c970 [PCnet32 LANCE] - 1014 2000 NetFinity 10/100 Fast Ethernet - 1022 2000 PCnet - Fast 79C971 - 103c 104c Ethernet with LAN remote power Adapter - 103c 1064 Ethernet with LAN remote power Adapter - 103c 1065 Ethernet with LAN remote power Adapter - 103c 106c Ethernet with LAN remote power Adapter - 103c 106e Ethernet with LAN remote power Adapter - 103c 10ea Ethernet with LAN remote power Adapter - 1113 1220 EN1220 10/100 Fast Ethernet - 1259 2450 AT-2450 10/100 Fast Ethernet - 1259 2454 AT-2450v4 10Mb Ethernet Adapter - 1259 2700 AT-2700TX 10/100 Fast Ethernet - 1259 2701 AT-2700FX 100Mb Ethernet - 4c53 1000 CC7/CR7/CP7/VC7/VP7/VR7 mainboard - 4c53 1010 CP5/CR6 mainboard - 4c53 1020 VR6 mainboard - 4c53 1030 PC5 mainboard - 4c53 1040 CL7 mainboard - 4c53 1060 PC7 mainboard - 2001 79c978 [HomePNA] - 1092 0a78 Multimedia Home Network Adapter - 1668 0299 ActionLink Home Network Adapter - 2003 Am 1771 MBW [Alchemy] - 2020 53c974 [PCscsi] - 2040 79c974 - 3000 ELanSC520 Microcontroller - 7006 AMD-751 [Irongate] System Controller - 7007 AMD-751 [Irongate] AGP Bridge - 700a AMD-IGR4 AGP Host to PCI Bridge - 700b AMD-IGR4 PCI to PCI Bridge - 700c AMD-760 MP [IGD4-2P] System Controller - 700d AMD-760 MP [IGD4-2P] AGP Bridge - 700e AMD-760 [IGD4-1P] System Controller - 700f AMD-760 [IGD4-1P] AGP Bridge - 7400 AMD-755 [Cobra] ISA - 7401 AMD-755 [Cobra] IDE - 7403 AMD-755 [Cobra] ACPI - 7404 AMD-755 [Cobra] USB - 7408 AMD-756 [Viper] ISA - 7409 AMD-756 [Viper] IDE - 740b AMD-756 [Viper] ACPI - 740c AMD-756 [Viper] USB - 7410 AMD-766 [ViperPlus] ISA - 7411 AMD-766 [ViperPlus] IDE - 7413 AMD-766 [ViperPlus] ACPI - 7414 AMD-766 [ViperPlus] USB - 7440 AMD-768 [Opus] ISA - 1043 8044 A7M-D Mainboard - 7441 AMD-768 [Opus] IDE - 7443 AMD-768 [Opus] ACPI - 1043 8044 A7M-D Mainboard - 7445 AMD-768 [Opus] Audio - 7446 AMD-768 [Opus] MC97 Modem (Smart Link HAMR5600 compatible) - 7448 AMD-768 [Opus] PCI - 7449 AMD-768 [Opus] USB - 7450 AMD-8131 PCI-X Bridge - 7451 AMD-8131 PCI-X APIC - 7454 AMD-8151 System Controller - 7455 AMD-8151 AGP Bridge - 7460 AMD-8111 PCI - 161f 3017 HDAMB - 7461 AMD-8111 USB - 7462 AMD-8111 Ethernet - 7464 AMD-8111 USB - 161f 3017 HDAMB - 7468 AMD-8111 LPC - 161f 3017 HDAMB - 7469 AMD-8111 IDE - 161f 3017 HDAMB - 746a AMD-8111 SMBus 2.0 - 746b AMD-8111 ACPI - 161f 3017 HDAMB - 746d AMD-8111 AC97 Audio - 161f 3017 HDAMB - 746e AMD-8111 MC97 Modem - 756b AMD-8111 ACPI -1023 Trident Microsystems - 0194 82C194 - 2000 4DWave DX - 2001 4DWave NX - 122d 1400 Trident PCI288-Q3DII (NX) - 2100 CyberBlade XP4m32 - 2200 XGI Volari XP5 - 8400 CyberBlade/i7 - 1023 8400 CyberBlade i7 AGP - 8420 CyberBlade/i7d - 0e11 b15a CyberBlade i7 AGP - 8500 CyberBlade/i1 - 8520 CyberBlade i1 - 0e11 b16e CyberBlade i1 AGP - 1023 8520 CyberBlade i1 AGP - 8620 CyberBlade/i1 - 1014 0502 ThinkPad R30/T30 - 8820 CyberBlade XPAi1 - 9320 TGUI 9320 - 9350 GUI Accelerator - 9360 Flat panel GUI Accelerator - 9382 Cyber 9382 [Reference design] - 9383 Cyber 9383 [Reference design] - 9385 Cyber 9385 [Reference design] - 9386 Cyber 9386 - 9388 Cyber 9388 - 9397 Cyber 9397 - 939a Cyber 9397DVD - 9420 TGUI 9420 - 9430 TGUI 9430 - 9440 TGUI 9440 - 9460 TGUI 9460 - 9470 TGUI 9470 - 9520 Cyber 9520 - 9525 Cyber 9525 - 10cf 1094 Lifebook C6155 - 9540 Cyber 9540 - 9660 TGUI 9660/938x/968x - 9680 TGUI 9680 - 9682 TGUI 9682 - 9683 TGUI 9683 - 9685 ProVIDIA 9685 - 9750 3DImage 9750 - 1014 9750 3DImage 9750 - 1023 9750 3DImage 9750 - 9753 TGUI 9753 - 9754 TGUI 9754 - 9759 TGUI 975 - 9783 TGUI 9783 - 9785 TGUI 9785 - 9850 3DImage 9850 - 9880 Blade 3D PCI/AGP - 1023 9880 Blade 3D - 9910 CyberBlade/XP - 9930 CyberBlade/XPm -1024 Zenith Data Systems -1025 Acer Incorporated [ALI] - 1435 M1435 - 1445 M1445 - 1449 M1449 - 1451 M1451 - 1461 M1461 - 1489 M1489 - 1511 M1511 - 1512 ALI M1512 Aladdin - 1513 M1513 - 1521 ALI M1521 Aladdin III CPU Bridge - 10b9 1521 ALI M1521 Aladdin III CPU Bridge - 1523 ALI M1523 ISA Bridge - 10b9 1523 ALI M1523 ISA Bridge - 1531 M1531 Northbridge [Aladdin IV/IV+] - 1533 M1533 PCI-to-ISA Bridge - 10b9 1533 ALI M1533 Aladdin IV/V ISA South Bridge - 1535 M1535 PCI Bridge + Super I/O + FIR - 1541 M1541 Northbridge [Aladdin V] - 10b9 1541 ALI M1541 Aladdin V/V+ AGP+PCI North Bridge - 1542 M1542 Northbridge [Aladdin V] - 1543 M1543 PCI-to-ISA Bridge + Super I/O + FIR - 1561 M1561 Northbridge [Aladdin 7] - 1621 M1621 Northbridge [Aladdin-Pro II] - 1631 M1631 Northbridge+3D Graphics [Aladdin TNT2] - 1641 M1641 Northbridge [Aladdin-Pro IV] - 1647 M1647 [MaGiK1] PCI North Bridge - 1671 M1671 Northbridge [ALADDiN-P4] - 1672 Northbridge [CyberALADDiN-P4] - 3141 M3141 - 3143 M3143 - 3145 M3145 - 3147 M3147 - 3149 M3149 - 3151 M3151 - 3307 M3307 MPEG-I Video Controller - 3309 M3309 MPEG-II Video w/ Software Audio Decoder - 3321 M3321 MPEG-II Audio/Video Decoder - 5212 M4803 - 5215 ALI PCI EIDE Controller - 5217 M5217H - 5219 M5219 - 5225 M5225 - 5229 M5229 - 5235 M5235 - 5237 M5237 PCI USB Host Controller - 5240 EIDE Controller - 5241 PCMCIA Bridge - 5242 General Purpose Controller - 5243 PCI to PCI Bridge Controller - 5244 Floppy Disk Controller - 5247 M1541 PCI to PCI Bridge - 5251 M5251 P1394 Controller - 5427 PCI to AGP Bridge - 5451 M5451 PCI AC-Link Controller Audio Device - 5453 M5453 PCI AC-Link Controller Modem Device - 7101 M7101 PCI PMU Power Management Controller - 10b9 7101 M7101 PCI PMU Power Management Controller -1028 Dell - 0001 PowerEdge Expandable RAID Controller 2/Si - 1028 0001 PowerEdge 2400 - 0002 PowerEdge Expandable RAID Controller 3/Di - 1028 0002 PowerEdge 4400 - 0003 PowerEdge Expandable RAID Controller 3/Si - 1028 0003 PowerEdge 2450 - 0006 PowerEdge Expandable RAID Controller 3/Di - 0007 Remote Access Card III - 0008 Remote Access Card III - 0009 Remote Access Card III: BMC/SMIC device not present - 000a PowerEdge Expandable RAID Controller 3/Di - 000c Embedded Remote Access or ERA/O - 000d Embedded Remote Access: BMC/SMIC device - 000e PowerEdge Expandable RAID controller 4/Di - 000f PowerEdge Expandable RAID controller 4/Di - 0010 Remote Access Card 4 - 0011 Remote Access Card 4 Daughter Card - 0012 Remote Access Card 4 Daughter Card Virtual UART - 0013 PowerEdge Expandable RAID controller 4 - 1028 016c PowerEdge Expandable RAID Controller 4e/Si - 1028 016d PowerEdge Expandable RAID Controller 4e/Di - 1028 016e PowerEdge Expandable RAID Controller 4e/Di - 1028 016f PowerEdge Expandable RAID Controller 4e/Di - 1028 0170 PowerEdge Expandable RAID Controller 4e/Di - 0014 Remote Access Card 4 Daughter Card SMIC interface -1029 Siemens Nixdorf IS -102a LSI Logic - 0000 HYDRA - 0010 ASPEN - 001f AHA-2940U2/U2W /7890/7891 SCSI Controllers - 9005 000f 2940U2W SCSI Controller - 9005 0106 2940U2W SCSI Controller - 9005 a180 2940U2W SCSI Controller - 00c5 AIC-7899 U160/m SCSI Controller - 1028 00c5 PowerEdge 2550/2650/4600 - 00cf AIC-7899P U160/m - 1028 0106 PowerEdge 4600 - 1028 0121 PowerEdge 2650 -102b Matrox Graphics, Inc. -# DJ: I've a suspicion that 0010 is a duplicate of 0d10. - 0010 MGA-I [Impression?] - 0100 MGA 1064SG [Mystique] - 0518 MGA-II [Athena] - 0519 MGA 2064W [Millennium] - 051a MGA 1064SG [Mystique] - 102b 0100 MGA-1064SG Mystique - 102b 1100 MGA-1084SG Mystique - 102b 1200 MGA-1084SG Mystique - 1100 102b MGA-1084SG Mystique - 110a 0018 Scenic Pro C5 (D1025) - 051b MGA 2164W [Millennium II] - 102b 051b MGA-2164W Millennium II - 102b 1100 MGA-2164W Millennium II - 102b 1200 MGA-2164W Millennium II - 051e MGA 1064SG [Mystique] AGP - 051f MGA 2164W [Millennium II] AGP - 0520 MGA G200 - 102b dbc2 G200 Multi-Monitor - 102b dbc8 G200 Multi-Monitor - 102b dbe2 G200 Multi-Monitor - 102b dbe8 G200 Multi-Monitor - 102b ff03 Millennium G200 SD - 102b ff04 Marvel G200 - 0521 MGA G200 AGP - 1014 ff03 Millennium G200 AGP - 102b 48e9 Mystique G200 AGP - 102b 48f8 Millennium G200 SD AGP - 102b 4a60 Millennium G200 LE AGP - 102b 4a64 Millennium G200 AGP - 102b c93c Millennium G200 AGP - 102b c9b0 Millennium G200 AGP - 102b c9bc Millennium G200 AGP - 102b ca60 Millennium G250 LE AGP - 102b ca6c Millennium G250 AGP - 102b dbbc Millennium G200 AGP - 102b dbc2 Millennium G200 MMS (Dual G200) - 102b dbc3 G200 Multi-Monitor - 102b dbc8 Millennium G200 MMS (Dual G200) - 102b dbd2 G200 Multi-Monitor - 102b dbd3 G200 Multi-Monitor - 102b dbd4 G200 Multi-Monitor - 102b dbd5 G200 Multi-Monitor - 102b dbd8 G200 Multi-Monitor - 102b dbd9 G200 Multi-Monitor - 102b dbe2 Millennium G200 MMS (Quad G200) - 102b dbe3 G200 Multi-Monitor - 102b dbe8 Millennium G200 MMS (Quad G200) - 102b dbf2 G200 Multi-Monitor - 102b dbf3 G200 Multi-Monitor - 102b dbf4 G200 Multi-Monitor - 102b dbf5 G200 Multi-Monitor - 102b dbf8 G200 Multi-Monitor - 102b dbf9 G200 Multi-Monitor - 102b f806 Mystique G200 Video AGP - 102b ff00 MGA-G200 AGP - 102b ff02 Mystique G200 AGP - 102b ff03 Millennium G200 AGP - 102b ff04 Marvel G200 AGP - 110a 0032 MGA-G200 AGP - 0525 MGA G400 AGP - 0e11 b16f MGA-G400 AGP - 102b 0328 Millennium G400 16Mb SDRAM - 102b 0338 Millennium G400 16Mb SDRAM - 102b 0378 Millennium G400 32Mb SDRAM - 102b 0541 Millennium G450 Dual Head - 102b 0542 Millennium G450 Dual Head LX - 102b 0543 Millennium G450 Single Head LX - 102b 0641 Millennium G450 32Mb SDRAM Dual Head - 102b 0642 Millennium G450 32Mb SDRAM Dual Head LX - 102b 0643 Millennium G450 32Mb SDRAM Single Head LX - 102b 07c0 Millennium G450 Dual Head LE - 102b 07c1 Millennium G450 SDR Dual Head LE - 102b 0d41 Millennium G450 Dual Head PCI - 102b 0d42 Millennium G450 Dual Head LX PCI - 102b 0d43 Millennium G450 32Mb Dual Head PCI - 102b 0e00 Marvel G450 eTV - 102b 0e01 Marvel G450 eTV - 102b 0e02 Marvel G450 eTV - 102b 0e03 Marvel G450 eTV - 102b 0f80 Millennium G450 Low Profile - 102b 0f81 Millennium G450 Low Profile - 102b 0f82 Millennium G450 Low Profile DVI - 102b 0f83 Millennium G450 Low Profile DVI - 102b 19d8 Millennium G400 16Mb SGRAM - 102b 19f8 Millennium G400 32Mb SGRAM - 102b 2159 Millennium G400 Dual Head 16Mb - 102b 2179 Millennium G400 MAX/Dual Head 32Mb - 102b 217d Millennium G400 Dual Head Max - 102b 23c0 Millennium G450 - 102b 23c1 Millennium G450 - 102b 23c2 Millennium G450 DVI - 102b 23c3 Millennium G450 DVI - 102b 2f58 Millennium G400 - 102b 2f78 Millennium G400 - 102b 3693 Marvel G400 AGP - 102b 5dd0 4Sight II - 102b 5f50 4Sight II - 102b 5f51 4Sight II - 102b 5f52 4Sight II - 102b 9010 Millennium G400 Dual Head - 1458 0400 GA-G400 - 1705 0001 Millennium G450 32MB SGRAM - 1705 0002 Millennium G450 16MB SGRAM - 1705 0003 Millennium G450 32MB - 1705 0004 Millennium G450 16MB - 0527 MGA Parhelia AGP - 102b 0840 Parhelia 128Mb - 0d10 MGA Ultima/Impression - 1000 MGA G100 [Productiva] - 102b ff01 Productiva G100 - 102b ff05 Productiva G100 Multi-Monitor - 1001 MGA G100 [Productiva] AGP - 102b 1001 MGA-G100 AGP - 102b ff00 MGA-G100 AGP - 102b ff01 MGA-G100 Productiva AGP - 102b ff03 Millennium G100 AGP - 102b ff04 MGA-G100 AGP - 102b ff05 MGA-G100 Productiva AGP Multi-Monitor - 110a 001e MGA-G100 AGP - 2007 MGA Mistral - 2527 MGA G550 AGP - 102b 0f83 Millennium G550 - 102b 0f84 Millennium G550 Dual Head DDR 32Mb - 102b 1e41 Millennium G550 - 2537 MGA G650 AGP - 4536 VIA Framegrabber - 6573 Shark 10/100 Multiport SwitchNIC -102c Chips and Technologies - 00b8 F64310 - 00c0 F69000 HiQVideo - 102c 00c0 F69000 HiQVideo - 4c53 1000 CC7/CR7/CP7/VC7/VP7/VR7 mainboard - 4c53 1010 CP5/CR6 mainboard - 4c53 1020 VR6 mainboard - 4c53 1030 PC5 mainboard - 4c53 1050 CT7 mainboard - 4c53 1051 CE7 mainboard - 00d0 F65545 - 00d8 F65545 - 00dc F65548 - 00e0 F65550 - 00e4 F65554 - 00e5 F65555 HiQVPro - 0e11 b049 Armada 1700 Laptop Display Controller - 00f0 F68554 - 00f4 F68554 HiQVision - 00f5 F68555 - 0c30 F69030 - 4c53 1000 CC7/CR7/CP7/VC7/VP7/VR7 mainboard - 4c53 1050 CT7 mainboard - 4c53 1051 CE7 mainboard -# C5C project cancelled - 4c53 1080 CT8 mainboard -102d Wyse Technology Inc. - 50dc 3328 Audio -102e Olivetti Advanced Technology -102f Toshiba America - 0009 r4x00 - 000a TX3927 MIPS RISC PCI Controller - 0020 ATM Meteor 155 - 102f 00f8 ATM Meteor 155 - 0030 TC35815CF PCI 10/100 Mbit Ethernet Controller - 0031 TC35815CF PCI 10/100 Mbit Ethernet Controller with WOL - 0105 TC86C001 [goku-s] IDE - 0106 TC86C001 [goku-s] USB 1.1 Host - 0107 TC86C001 [goku-s] USB Device Controller - 0108 TC86C001 [goku-s] I2C/SIO/GPIO Controller - 0180 TX4927/38 MIPS RISC PCI Controller - 0181 TX4925 MIPS RISC PCI Controller - 0182 TX4937 MIPS RISC PCI Controller -1030 TMC Research -1031 Miro Computer Products AG - 5601 DC20 ASIC - 5607 Video I/O & motion JPEG compressor - 5631 Media 3D - 6057 MiroVideo DC10/DC30+ -1032 Compaq -1033 NEC Corporation - 0000 Vr4181A USB Host or Function Control Unit - 0001 PCI to 486-like bus Bridge - 0002 PCI to VL98 Bridge - 0003 ATM Controller - 0004 R4000 PCI Bridge - 0005 PCI to 486-like bus Bridge - 0006 PC-9800 Graphic Accelerator - 0007 PCI to UX-Bus Bridge - 0008 PC-9800 Graphic Accelerator - 0009 PCI to PC9800 Core-Graph Bridge - 0016 PCI to VL Bridge - 001a [Nile II] - 0021 Vrc4373 [Nile I] - 0029 PowerVR PCX1 - 002a PowerVR 3D - 002c Star Alpha 2 - 002d PCI to C-bus Bridge - 0035 USB - 1179 0001 USB - 12ee 7000 Root Hub - 1799 0001 Root Hub - 807d 0035 PCI-USB2 (OHCI subsystem) - 003b PCI to C-bus Bridge - 003e NAPCCARD Cardbus Controller - 0046 PowerVR PCX2 [midas] - 005a Vrc5074 [Nile 4] - 0063 Firewarden - 0067 PowerVR Neon 250 Chipset - 1010 0020 PowerVR Neon 250 AGP 32Mb - 1010 0080 PowerVR Neon 250 AGP 16Mb - 1010 0088 PowerVR Neon 250 16Mb - 1010 0090 PowerVR Neon 250 AGP 16Mb - 1010 0098 PowerVR Neon 250 16Mb - 1010 00a0 PowerVR Neon 250 AGP 32Mb - 1010 00a8 PowerVR Neon 250 32Mb - 1010 0120 PowerVR Neon 250 AGP 32Mb - 0072 uPD72874 IEEE1394 OHCI 1.1 3-port PHY-Link Ctrlr - 0074 56k Voice Modem - 1033 8014 RCV56ACF 56k Voice Modem - 009b Vrc5476 - 00a5 VRC4173 - 00a6 VRC5477 AC97 - 00cd IEEE 1394 [OrangeLink] Host Controller - 12ee 8011 Root hub - 00ce IEEE 1394 Host Controller - 00df Vr4131 - 00e0 USB 2.0 - 0ee4 3383 Sitecom IEEE 1394 / USB2.0 Combo Card - 12ee 7001 Root hub - 1799 0002 Root Hub - 807d 1043 PCI-USB2 (EHCI subsystem) - 00e7 IEEE 1394 Host Controller - 00f2 uPD72874 IEEE1394 OHCI 1.1 3-port PHY-Link Ctrlr - 00f3 uPD6113x Multimedia Decoder/Processor [EMMA2] - 010c VR7701 -1034 Framatome Connectors USA Inc. -1035 Comp. & Comm. Research Lab -1036 Future Domain Corp. - 0000 TMC-18C30 [36C70] -1037 Hitachi Micro Systems -1038 AMP, Inc -1039 Silicon Integrated Systems [SiS] - 0001 Virtual PCI-to-PCI bridge (AGP) - 0002 SG86C202 - 0006 85C501/2/3 - 0008 SiS85C503/5513 (LPC Bridge) - 0009 ACPI -# source: http://members.datafast.net.au/dft0802/downloads/pcidevs.txt - 0016 SiS961/2 SMBus Controller - 0018 SiS85C503/5513 (LPC Bridge) -# Controller for 2 PATA and 2 SATA channels - 0180 RAID bus controller 180 SATA/PATA [SiS] - 0181 SiS SATA - 0200 5597/5598/6326 VGA - 1039 0000 SiS5597 SVGA (Shared RAM) - 0204 82C204 - 0205 SG86C205 - 0300 300/305 PCI/AGP VGA Display Adapter - 107d 2720 Leadtek WinFast VR300 - 0310 315H PCI/AGP VGA Display Adapter - 0315 315 PCI/AGP VGA Display Adapter - 0325 315PRO PCI/AGP VGA Display Adapter - 0330 330 [Xabre] PCI/AGP VGA Display Adapter - 0406 85C501/2 - 0496 85C496 - 0530 530 Host - 0540 540 Host - 0550 550 Host - 0597 5513C - 0601 85C601 - 0620 620 Host - 0630 630 Host - 0633 633 Host - 0635 635 Host - 0645 SiS645 Host & Memory & AGP Controller - 0646 SiS645DX Host & Memory & AGP Controller - 0648 SiS 645xx - 0650 650/M650 Host - 0651 651 Host - 0655 655 Host - 0660 660 Host - 0661 661FX/M661FX/M661MX Host - 0730 730 Host - 0733 733 Host - 0735 735 Host - 0740 740 Host - 0741 741/741GX/M741 Host - 0745 745 Host - 0746 746 Host - 0755 755 Host - 0760 760/M760 Host - 0900 SiS900 PCI Fast Ethernet - 1019 0a14 K7S5A motherboard - 1039 0900 SiS900 10/100 Ethernet Adapter - 1043 8035 CUSI-FX motherboard - 0961 SiS961 [MuTIOL Media IO] - 0962 SiS962 [MuTIOL Media IO] - 0963 SiS963 [MuTIOL Media IO] - 0964 SiS964 [MuTIOL Media IO] - 0965 SiS965 [MuTIOL Media IO] - 3602 83C602 - 5107 5107 - 5300 SiS540 PCI Display Adapter - 5315 550 PCI/AGP VGA Display Adapter - 5401 486 PCI Chipset - 5511 5511/5512 - 5513 5513 [IDE] - 1019 0970 P6STP-FL motherboard - 1039 5513 SiS5513 EIDE Controller (A,B step) - 1043 8035 CUSI-FX motherboard - 5517 5517 - 5571 5571 - 5581 5581 Pentium Chipset - 5582 5582 - 5591 5591/5592 Host - 5596 5596 Pentium Chipset - 5597 5597 [SiS5582] - 5600 5600 Host - 6204 Video decoder & MPEG interface - 6205 VGA Controller - 6236 6236 3D-AGP - 6300 630/730 PCI/AGP VGA Display Adapter - 1019 0970 P6STP-FL motherboard - 1043 8035 CUSI-FX motherboard - 6306 530/620 PCI/AGP VGA Display Adapter - 1039 6306 SiS530,620 GUI Accelerator+3D - 6325 65x/M650/740 PCI/AGP VGA Display Adapter - 6326 86C326 5598/6326 - 1039 6326 SiS6326 GUI Accelerator - 1092 0a50 SpeedStar A50 - 1092 0a70 SpeedStar A70 - 1092 4910 SpeedStar A70 - 1092 4920 SpeedStar A70 - 1569 6326 SiS6326 GUI Accelerator - 6330 661/741/760 PCI/AGP VGA Display Adapter - 1039 6330 [M]661xX/[M]741[GX]/[M]760 PCI/AGP VGA Adapter - 7001 USB 1.0 Controller - 1019 0a14 K7S5A motherboard - 1039 7000 Onboard USB Controller - 7002 USB 2.0 Controller - 1509 7002 Onboard USB Controller - 7007 FireWire Controller - 7012 Sound Controller -# There are may be different modem codecs here (Intel537 compatible and incompatible) - 7013 AC'97 Modem Controller - 7016 SiS7016 PCI Fast Ethernet Adapter - 1039 7016 SiS7016 10/100 Ethernet Adapter - 7018 SiS PCI Audio Accelerator - 1014 01b6 SiS PCI Audio Accelerator - 1014 01b7 SiS PCI Audio Accelerator - 1019 7018 SiS PCI Audio Accelerator - 1025 000e SiS PCI Audio Accelerator - 1025 0018 SiS PCI Audio Accelerator - 1039 7018 SiS PCI Audio Accelerator - 1043 800b SiS PCI Audio Accelerator - 1054 7018 SiS PCI Audio Accelerator - 107d 5330 SiS PCI Audio Accelerator - 107d 5350 SiS PCI Audio Accelerator - 1170 3209 SiS PCI Audio Accelerator - 1462 400a SiS PCI Audio Accelerator - 14a4 2089 SiS PCI Audio Accelerator - 14cd 2194 SiS PCI Audio Accelerator - 14ff 1100 SiS PCI Audio Accelerator - 152d 8808 SiS PCI Audio Accelerator - 1558 1103 SiS PCI Audio Accelerator - 1558 2200 SiS PCI Audio Accelerator - 1563 7018 SiS PCI Audio Accelerator - 15c5 0111 SiS PCI Audio Accelerator - 270f a171 SiS PCI Audio Accelerator - a0a0 0022 SiS PCI Audio Accelerator - 7019 SiS7019 Audio Accelerator -103a Seiko Epson Corporation -103b Tatung Co. of America -103c Hewlett-Packard Company - 1005 A4977A Visualize EG - 1006 Visualize FX6 - 1008 Visualize FX4 - 100a Visualize FX2 - 1028 Tach TL Fibre Channel Host Adapter - 1029 Tach XL2 Fibre Channel Host Adapter - 107e 000f Interphase 5560 Fibre Channel Adapter - 9004 9210 1Gb/2Gb Family Fibre Channel Controller - 9004 9211 1Gb/2Gb Family Fibre Channel Controller - 102a Tach TS Fibre Channel Host Adapter - 107e 000e Interphase 5540/5541 Fibre Channel Adapter - 9004 9110 1Gb/2Gb Family Fibre Channel Controller - 9004 9111 1Gb/2Gb Family Fibre Channel Controller - 1030 J2585A DeskDirect 10/100VG NIC - 1031 J2585B HP 10/100VG PCI LAN Adapter - 103c 1040 J2973A DeskDirect 10BaseT NIC - 103c 1041 J2585B DeskDirect 10/100VG NIC - 103c 1042 J2970A DeskDirect 10BaseT/2 NIC - 1040 J2973A DeskDirect 10BaseT NIC - 1041 J2585B DeskDirect 10/100 NIC - 1042 J2970A DeskDirect 10BaseT/2 NIC - 1048 Diva Serial [GSP] Multiport UART - 103c 1049 Tosca Console - 103c 104a Tosca Secondary - 103c 104b Maestro SP2 - 103c 1223 Superdome Console - 103c 1226 Keystone SP2 - 103c 1227 Powerbar SP2 - 103c 1282 Everest SP2 - 103c 1301 Diva RMP3 - 1054 PCI Local Bus Adapter - 1064 79C970 PCnet Ethernet Controller - 108b Visualize FXe - 10c1 NetServer Smart IRQ Router - 10ed TopTools Remote Control - 10f0 rio System Bus Adapter - 10f1 rio I/O Controller - 1200 82557B 10/100 NIC - 1219 NetServer PCI Hot-Plug Controller - 121a NetServer SMIC Controller - 121b NetServer Legacy COM Port Decoder - 121c NetServer PCI COM Port Decoder - 1229 zx1 System Bus Adapter - 122a zx1 I/O Controller - 122e zx1 Local Bus Adapter - 127c sx1000 I/O Controller - 1290 Auxiliary Diva Serial Port - 12b4 zx1 QuickSilver AGP8x Local Bus Adapter - 2910 E2910A PCIBus Exerciser - 2925 E2925A 32 Bit, 33 MHzPCI Exerciser & Analyzer -103e Solliday Engineering -103f Synopsys/Logic Modeling Group -1040 Accelgraphics Inc. -1041 Computrend -1042 Micron - 1000 PC Tech RZ1000 - 1001 PC Tech RZ1001 - 3000 Samurai_0 - 3010 Samurai_1 - 3020 Samurai_IDE -1043 ASUSTeK Computer Inc. - 0675 ISDNLink P-IN100-ST-D - 4015 v7100 SDRAM [GeForce2 MX] - 4021 v7100 Combo Deluxe [GeForce2 MX + TV tuner] - 4057 v8200 GeForce 3 - 8043 v8240 PAL 128M [P4T] Motherboard - 807b v9280/TD [Geforce4 TI4200 8X With TV-Out and DVI] - 80bb v9180 Magic/T [GeForce4 MX440 AGP 8x 64MB TV-out] - 80c5 nForce3 chipset motherboard [SK8N] - 80df v9520 Magic/T -1044 Adaptec (formerly DPT) - 1012 Domino RAID Engine - a400 SmartCache/Raid I-IV Controller - a500 PCI Bridge - a501 SmartRAID V Controller - 1044 c001 PM1554U2 Ultra2 Single Channel - 1044 c002 PM1654U2 Ultra2 Single Channel - 1044 c003 PM1564U3 Ultra3 Single Channel - 1044 c004 PM1564U3 Ultra3 Dual Channel - 1044 c005 PM1554U2 Ultra2 Single Channel (NON ACPI) - 1044 c00a PM2554U2 Ultra2 Single Channel - 1044 c00b PM2654U2 Ultra2 Single Channel - 1044 c00c PM2664U3 Ultra3 Single Channel - 1044 c00d PM2664U3 Ultra3 Dual Channel - 1044 c00e PM2554U2 Ultra2 Single Channel (NON ACPI) - 1044 c00f PM2654U2 Ultra2 Single Channel (NON ACPI) - 1044 c014 PM3754U2 Ultra2 Single Channel (NON ACPI) - 1044 c015 PM3755U2B Ultra2 Single Channel (NON ACPI) - 1044 c016 PM3755F Fibre Channel (NON ACPI) - 1044 c01e PM3757U2 Ultra2 Single Channel - 1044 c01f PM3757U2 Ultra2 Dual Channel - 1044 c020 PM3767U3 Ultra3 Dual Channel - 1044 c021 PM3767U3 Ultra3 Quad Channel - 1044 c028 PM2865U3 Ultra3 Single Channel - 1044 c029 PM2865U3 Ultra3 Dual Channel - 1044 c02a PM2865F Fibre Channel - 1044 c03c 2000S Ultra3 Single Channel - 1044 c03d 2000S Ultra3 Dual Channel - 1044 c03e 2000F Fibre Channel - 1044 c046 3000S Ultra3 Single Channel - 1044 c047 3000S Ultra3 Dual Channel - 1044 c048 3000F Fibre Channel - 1044 c050 5000S Ultra3 Single Channel - 1044 c051 5000S Ultra3 Dual Channel - 1044 c052 5000F Fibre Channel - 1044 c05a 2400A UDMA Four Channel - 1044 c05b 2400A UDMA Four Channel DAC - 1044 c064 3010S Ultra3 Dual Channel - 1044 c065 3410S Ultra160 Four Channel - 1044 c066 3010S Fibre Channel - a511 SmartRAID V Controller - 1044 c032 ASR-2005S I2O Zero Channel -1045 OPTi Inc. - a0f8 82C750 [Vendetta] USB Controller - c101 92C264 - c178 92C178 - c556 82X556 [Viper] - c557 82C557 [Viper-M] - c558 82C558 [Viper-M ISA+IDE] - c567 82C750 [Vendetta], device 0 - c568 82C750 [Vendetta], device 1 - c569 82C579 [Viper XPress+ Chipset] - c621 82C621 [Viper-M/N+] - c700 82C700 [FireStar] - c701 82C701 [FireStar Plus] - c814 82C814 [Firebridge 1] - c822 82C822 - c824 82C824 - c825 82C825 [Firebridge 2] - c832 82C832 - c861 82C861 - c895 82C895 - c935 EV1935 ECTIVA MachOne PCIAudio - d568 82C825 [Firebridge 2] - d721 IDE [FireStar] -1046 IPC Corporation, Ltd. -1047 Genoa Systems Corp -1048 Elsa AG - 0c60 Gladiac MX - 0d22 Quadro4 900XGL [ELSA GLoria4 900XGL] - 1000 QuickStep 1000 - 3000 QuickStep 3000 - 8901 Gloria XL -1049 Fountain Technologies, Inc. -# # nee SGS Thomson Microelectronics -104a STMicroelectronics - 0008 STG 2000X - 0009 STG 1764X - 0010 STG4000 [3D Prophet Kyro Series] - 0209 STPC Consumer/Industrial North- and Southbridge - 020a STPC Atlas/ConsumerS/Consumer IIA Northbridge -# From - 0210 STPC Atlas ISA Bridge - 021a STPC Consumer S Southbridge - 021b STPC Consumer IIA Southbridge - 0500 ST70137 [Unicorn] ADSL DMT Transceiver - 0564 STPC Client Northbridge - 0981 21x4x DEC-Tulip compatible 10/100 Ethernet - 1746 STG 1764X - 2774 21x4x DEC-Tulip compatible 10/100 Ethernet - 3520 MPEG-II decoder card - 55cc STPC Client Southbridge -104b BusLogic - 0140 BT-946C (old) [multimaster 01] - 1040 BT-946C (BA80C30) [MultiMaster 10] - 8130 Flashpoint LT -104c Texas Instruments - 0500 100 MBit LAN Controller - 0508 TMS380C2X Compressor Interface - 1000 Eagle i/f AS - 104c PCI1510 PC card Cardbus Controller - 3d04 TVP4010 [Permedia] - 3d07 TVP4020 [Permedia 2] - 1011 4d10 Comet - 1040 000f AccelStar II - 1040 0011 AccelStar II - 1048 0a31 WINNER 2000 - 1048 0a32 GLoria Synergy - 1048 0a35 GLoria Synergy - 107d 2633 WinFast 3D L2300 - 1092 0127 FIRE GL 1000 PRO - 1092 0136 FIRE GL 1000 PRO - 1092 0141 FIRE GL 1000 PRO - 1092 0146 FIRE GL 1000 PRO - 1092 0148 FIRE GL 1000 PRO - 1092 0149 FIRE GL 1000 PRO - 1092 0152 FIRE GL 1000 PRO - 1092 0154 FIRE GL 1000 PRO - 1092 0155 FIRE GL 1000 PRO - 1092 0156 FIRE GL 1000 PRO - 1092 0157 FIRE GL 1000 PRO - 1097 3d01 Jeronimo Pro - 1102 100f Graphics Blaster Extreme - 3d3d 0100 Reference Permedia 2 3D - 8000 PCILynx/PCILynx2 IEEE 1394 Link Layer Controller - e4bf 1010 CF1-1-SNARE - e4bf 1020 CF1-2-SNARE - 8009 FireWire Controller - 104d 8032 8032 OHCI i.LINK (IEEE 1394) Controller - 8017 PCI4410 FireWire Controller - 8019 TSB12LV23 IEEE-1394 Controller - 11bd 000a Studio DV500-1394 - 11bd 000e Studio DV - e4bf 1010 CF2-1-CYMBAL - 8020 TSB12LV26 IEEE-1394 Controller (Link) - 11bd 000f Studio DV500-1394 - 8021 TSB43AA22 IEEE-1394 Controller (PHY/Link Integrated) - 104d 80df Vaio PCG-FX403 - 104d 80e7 VAIO PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP - 8022 TSB43AB22 IEEE-1394a-2000 Controller (PHY/Link) - 8023 TSB43AB22/A IEEE-1394a-2000 Controller (PHY/Link) - 103c 088c nc8000 laptop - 8024 TSB43AB23 IEEE-1394a-2000 Controller (PHY/Link) - 8025 TSB82AA2 IEEE-1394b Link Layer Controller - 55aa 55aa FireWire 800 PCI Card - 8026 TSB43AB21 IEEE-1394a-2000 Controller (PHY/Link) - 8027 PCI4451 IEEE-1394 Controller - 1028 00e6 PCI4451 IEEE-1394 Controller (Dell Inspiron 8100) - 8029 PCI4510 IEEE-1394 Controller - 1028 0163 Latitude D505 - 1071 8160 MIM2900 - 802b PCI7410,7510,7610 OHCI-Lynx Controller - 1028 014e PCI7410,7510,7610 OHCI-Lynx Controller (Dell Latitude D800) - 802e PCI7x20 1394a-2000 OHCI Two-Port PHY/Link-Layer Controller - 8031 Texas Instruments PCIxx21/x515 Cardbus Controller - 8032 Texas Instruments OHCI Compliant IEEE 1394 Host Controller - 8033 Texas Instruments PCIxx21 Integrated FlashMedia Controller - 8034 Texas Instruments PCI6411, PCI6421, PCI6611, PCI6621, PCI7411, PCI7421, PCI7611, PCI7621 Secure Digital (SD) Controller - 8035 Texas Instruments PCI6411, PCI6421, PCI6611, PCI6621, PCI7411, PCI7421, PCI7611, PCI7621 Smart Card Controller (SMC) - 8201 PCI1620 Firmware Loading Function - 8204 PCI7410,7510,7610 PCI Firmware Loading Function - 1028 014e Latitude D800 - 8400 ACX 100 22Mbps Wireless Interface - 00fc 16ec U.S. Robotics 22 Mbps Wireless PC Card (model 2210) - 00fd 16ec U.S. Robotics 22Mbps Wireless PCI Adapter (model 2216) - 1186 3b00 DWL-650+ PC Card cardbus 22Mbs Wireless Adapter [AirPlus] - 1186 3b01 DWL-520+ 22Mbps PCI Wireless Adapter - 8401 ACX 100 22Mbps Wireless Interface -# OK, this info is almost useless as is, but at least it's known that it's a wireless card. More info requested from reporter (whi - 9000 Wireless Interface (of unknown type) - 9066 ACX 111 54Mbps Wireless Interface - a001 TDC1570 - a100 TDC1561 - a102 TNETA1575 HyperSAR Plus w/PCI Host i/f & UTOPIA i/f - a106 TMS320C6205 Fixed Point DSP - 175c 5000 ASI50xx Audio Adapter - 175c 8700 ASI87xx Radio Tuner card - ac10 PCI1050 - ac11 PCI1053 - ac12 PCI1130 - ac13 PCI1031 - ac15 PCI1131 - ac16 PCI1250 - 1014 0092 ThinkPad 600 - ac17 PCI1220 - ac18 PCI1260 - ac19 PCI1221 - ac1a PCI1210 - ac1b PCI1450 - 0e11 b113 Armada M700 - ac1c PCI1225 - 0e11 b121 Armada E500 - 1028 0088 Dell Computer Corporation Latitude CPi A400XT - ac1d PCI1251A - ac1e PCI1211 - ac1f PCI1251B - ac20 TI 2030 - ac21 PCI2031 - ac22 PCI2032 PCI Docking Bridge - ac23 PCI2250 PCI-to-PCI Bridge - ac28 PCI2050 PCI-to-PCI Bridge - ac30 PCI1260 PC card Cardbus Controller - ac40 PCI4450 PC card Cardbus Controller - ac41 PCI4410 PC card Cardbus Controller - ac42 PCI4451 PC card Cardbus Controller - 1028 00e6 PCI4451 PC card CardBus Controller (Dell Inspiron 8100) - ac44 PCI4510 PC card Cardbus Controller - 1028 0163 Latitude D505 - 1071 8160 MIM2000 - ac46 PCI4520 PC card Cardbus Controller - ac47 PCI7510 PC card Cardbus Controller - 1028 014e Latitude D800 - ac4a PCI7510,7610 PC card Cardbus Controller - 1028 014e Latitude D800 - ac50 PCI1410 PC card Cardbus Controller - ac51 PCI1420 - 1014 023b ThinkPad T23 (2647-4MG) - 1028 00b1 Latitude C600 - 1028 012a Latitude C640 - 1033 80cd Versa Note VXi - 10cf 1095 Lifebook C6155 - e4bf 1000 CP2-2-HIPHOP - ac52 PCI1451 PC card Cardbus Controller - ac53 PCI1421 PC card Cardbus Controller - ac54 PCI1620 PC Card Controller - ac55 PCI1520 PC card Cardbus Controller - 1014 0512 ThinkPad T30/T40 - ac56 PCI1510 PC card Cardbus Controller - 1014 0528 ThinkPad R40e (2684-HVG) Cardbus Controller - ac60 PCI2040 PCI to DSP Bridge Controller - 175c 5100 ASI51xx Audio Adapter - 175c 6100 ASI61xx Audio Adapter - 175c 6200 ASI62xx Audio Adapter - ac8d PCI 7620 - ac8e PCI7420 CardBus Controller - ac8f PCI7420/PCI7620 Dual Socket CardBus and Smart Card Cont. w/ 1394a-2000 OHCI Two-Port PHY/Link-Layer Cont. and SD/MS-Pro Sockets - fe00 FireWire Host Controller - fe03 12C01A FireWire Host Controller -104d Sony Corporation - 8004 DTL-H2500 [Playstation development board] - 8009 CXD1947Q i.LINK Controller - 8039 CXD3222 i.LINK Controller - 8056 Rockwell HCF 56K modem - 808a Memory Stick Controller -104e Oak Technology, Inc - 0017 OTI-64017 - 0107 OTI-107 [Spitfire] - 0109 Video Adapter - 0111 OTI-64111 [Spitfire] - 0217 OTI-64217 - 0317 OTI-64317 -104f Co-time Computer Ltd -1050 Winbond Electronics Corp - 0000 NE2000 - 0001 W83769F - 0105 W82C105 - 0840 W89C840 - 1050 0001 W89C840 Ethernet Adapter - 1050 0840 W89C840 Ethernet Adapter - 0940 W89C940 - 5a5a W89C940F - 6692 W6692 - 9921 W99200F MPEG-1 Video Encoder - 9922 W99200F/W9922PF MPEG-1/2 Video Encoder - 9970 W9970CF -1051 Anigma, Inc. -1052 ?Young Micro Systems -1053 Young Micro Systems -1054 Hitachi, Ltd -1055 Efar Microsystems - 9130 SLC90E66 [Victory66] IDE - 9460 SLC90E66 [Victory66] ISA - 9462 SLC90E66 [Victory66] USB - 9463 SLC90E66 [Victory66] ACPI -1056 ICL -# Motorola made a mistake and used 1507 instead of 1057 in some chips. Please look at the 1507 entry as well when updating this. -1057 Motorola - 0001 MPC105 [Eagle] - 0002 MPC106 [Grackle] - 0003 MPC8240 [Kahlua] - 0004 MPC107 - 0006 MPC8245 [Unity] - 0008 MPC8540 - 0009 MPC8560 - 0100 MC145575 [HFC-PCI] - 0431 KTI829c 100VG - 1801 DSP56301 Digital Signal Processor - 14fb 0101 Transas Radar Imitator Board [RIM] - 14fb 0102 Transas Radar Imitator Board [RIM-2] - 14fb 0202 Transas Radar Integrator Board [RIB-2] - 14fb 0611 1 channel CAN bus Controller [CanPci-1] - 14fb 0612 2 channels CAN bus Controller [CanPci-2] - 14fb 0613 3 channels CAN bus Controller [CanPci-3] - 14fb 0614 4 channels CAN bus Controller [CanPci-4] - 14fb 0621 1 channel CAN bus Controller [CanPci2-1] - 14fb 0622 2 channels CAN bus Controller [CanPci2-2] - 14fb 0810 Transas VTS Radar Integrator Board [RIB-4] - 175c 4200 ASI4215 Audio Adapter - 175c 4300 ASI43xx Audio Adapter - 175c 4400 ASI4401 Audio Adapter - ecc0 0010 Darla - ecc0 0020 Gina - ecc0 0030 Layla rev.0 - ecc0 0031 Layla rev.1 - ecc0 0040 Darla24 rev.0 - ecc0 0041 Darla24 rev.1 - ecc0 0050 Gina24 rev.0 - ecc0 0051 Gina24 rev.1 - ecc0 0070 Mona rev.0 - ecc0 0071 Mona rev.1 - ecc0 0072 Mona rev.2 - 18c0 MPC8265A/MPC8266 - 18c1 MPC8271/MPC8272 - 3410 DSP56361 Digital Signal Processor - ecc0 0050 Gina24 rev.0 - ecc0 0051 Gina24 rev.1 - ecc0 0060 Layla24 - ecc0 0070 Mona rev.0 - ecc0 0071 Mona rev.1 - ecc0 0072 Mona rev.2 - ecc0 0080 Mia rev.0 - ecc0 0081 Mia rev.1 - ecc0 0090 Indigo - ecc0 00a0 Indigo IO - ecc0 00b0 Indigo DJ - ecc0 0100 3G - 4801 Raven - 4802 Falcon - 4803 Hawk - 4806 CPX8216 - 4d68 20268 - 5600 SM56 PCI Modem - 1057 0300 SM56 PCI Speakerphone Modem - 1057 0301 SM56 PCI Voice Modem - 1057 0302 SM56 PCI Fax Modem - 1057 5600 SM56 PCI Voice modem - 13d2 0300 SM56 PCI Speakerphone Modem - 13d2 0301 SM56 PCI Voice modem - 13d2 0302 SM56 PCI Fax Modem - 1436 0300 SM56 PCI Speakerphone Modem - 1436 0301 SM56 PCI Voice modem - 1436 0302 SM56 PCI Fax Modem - 144f 100c SM56 PCI Fax Modem - 1494 0300 SM56 PCI Speakerphone Modem - 1494 0301 SM56 PCI Voice modem - 14c8 0300 SM56 PCI Speakerphone Modem - 14c8 0302 SM56 PCI Fax Modem - 1668 0300 SM56 PCI Speakerphone Modem - 1668 0302 SM56 PCI Fax Modem - 5803 MPC5200 - 6400 MPC190 Security Processor (S1 family, encryption) - 6405 MPC184 Security Processor (S1 family) -1058 Electronics & Telecommunications RSH -1059 Teknor Industrial Computers Inc -105a Promise Technology, Inc. -# more correct description from promise linux sources - 0d30 PDC20265 (FastTrak100 Lite/Ultra100) - 105a 4d33 Ultra100 - 0d38 20263 - 105a 4d39 Fasttrak66 - 1275 20275 - 3318 PDC20318 (SATA150 TX4) - 3319 PDC20319 (FastTrak S150 TX4) - 8086 3427 S875WP1-E mainboard - 3371 PDC20371 (FastTrak S150 TX2plus) - 3373 PDC20378 (FastTrak 378/SATA 378) - 1043 80f5 K8V Deluxe/PC-DL Deluxe motherboard - 1462 702e K8T NEO FIS2R motherboard - 3375 PDC20375 (SATA150 TX2plus) - 3376 PDC20376 (FastTrak 376) - 1043 809e A7V8X motherboard - 3574 PDC20579 SATAII 150 IDE Controller - 3d18 PDC20518/PDC40518 (SATAII 150 TX4) - 3d75 PDC20575 (SATAII150 TX2plus) - 4d30 PDC20267 (FastTrak100/Ultra100) - 105a 4d33 Ultra100 - 105a 4d39 FastTrak100 - 4d33 20246 - 105a 4d33 20246 IDE Controller - 4d38 PDC20262 (FastTrak66/Ultra66) - 105a 4d30 Ultra Device on SuperTrak - 105a 4d33 Ultra66 - 105a 4d39 FastTrak66 - 4d68 PDC20268 (Ultra100 TX2) - 105a 4d68 Ultra100TX2 - 4d69 20269 - 105a 4d68 Ultra133TX2 - 5275 PDC20276 (MBFastTrak133 Lite) - 105a 0275 SuperTrak SX6000 IDE - 105a 1275 MBFastTrak133 Lite (tm) Controller (RAID mode) - 1458 b001 MBUltra 133 - 5300 DC5300 - 6268 PDC20270 (FastTrak100 LP/TX2/TX4) - 105a 4d68 FastTrak100 TX2 - 6269 PDC20271 (FastTrak TX2000) - 105a 6269 FastTrak TX2/TX2000 - 6621 PDC20621 (FastTrak S150 SX4/FastTrak SX4000 lite) - 6622 PDC20621 [SATA150 SX4] 4 Channel IDE RAID Controller - 6626 PDC20618 (Ultra 618) - 6629 PDC20619 (FastTrak TX4000) - 7275 PDC20277 (SBFastTrak133 Lite) -105b Foxconn International, Inc. -105c Wipro Infotech Limited -105d Number 9 Computer Company - 2309 Imagine 128 - 2339 Imagine 128-II - 105d 0000 Imagine 128 series 2 4Mb VRAM - 105d 0001 Imagine 128 series 2 4Mb VRAM - 105d 0002 Imagine 128 series 2 4Mb VRAM - 105d 0003 Imagine 128 series 2 4Mb VRAM - 105d 0004 Imagine 128 series 2 4Mb VRAM - 105d 0005 Imagine 128 series 2 4Mb VRAM - 105d 0006 Imagine 128 series 2 4Mb VRAM - 105d 0007 Imagine 128 series 2 4Mb VRAM - 105d 0008 Imagine 128 series 2e 4Mb DRAM - 105d 0009 Imagine 128 series 2e 4Mb DRAM - 105d 000a Imagine 128 series 2 8Mb VRAM - 105d 000b Imagine 128 series 2 8Mb H-VRAM - 11a4 000a Barco Metheus 5 Megapixel - 13cc 0000 Barco Metheus 5 Megapixel - 13cc 0004 Barco Metheus 5 Megapixel - 13cc 0005 Barco Metheus 5 Megapixel - 13cc 0006 Barco Metheus 5 Megapixel - 13cc 0008 Barco Metheus 5 Megapixel - 13cc 0009 Barco Metheus 5 Megapixel - 13cc 000a Barco Metheus 5 Megapixel - 13cc 000c Barco Metheus 5 Megapixel - 493d Imagine 128 T2R [Ticket to Ride] - 11a4 000a Barco Metheus 5 Megapixel, Dual Head - 11a4 000b Barco Metheus 5 Megapixel, Dual Head - 13cc 0002 Barco Metheus 4 Megapixel, Dual Head - 13cc 0003 Barco Metheus 5 Megapixel, Dual Head - 13cc 0007 Barco Metheus 5 Megapixel, Dual Head - 13cc 0008 Barco Metheus 5 Megapixel, Dual Head - 13cc 0009 Barco Metheus 5 Megapixel, Dual Head - 13cc 000a Barco Metheus 5 Megapixel, Dual Head - 5348 Revolution 4 - 105d 0037 Revolution IV-FP AGP (For SGI 1600SW) -105e Vtech Computers Ltd -105f Infotronic America Inc -1060 United Microelectronics [UMC] - 0001 UM82C881 - 0002 UM82C886 - 0101 UM8673F - 0881 UM8881 - 0886 UM8886F - 0891 UM8891A - 1001 UM886A - 673a UM8886BF - 673b EIDE Master/DMA - 8710 UM8710 - 886a UM8886A - 8881 UM8881F - 8886 UM8886F - 888a UM8886A - 8891 UM8891A - 9017 UM9017F - 9018 UM9018 - 9026 UM9026 - e881 UM8881N - e886 UM8886N - e88a UM8886N - e891 UM8891N -1061 I.I.T. - 0001 AGX016 - 0002 IIT3204/3501 -1062 Maspar Computer Corp -1063 Ocean Office Automation -1064 Alcatel -1065 Texas Microsystems -1066 PicoPower Technology - 0000 PT80C826 - 0001 PT86C521 [Vesuvius v1] Host Bridge - 0002 PT86C523 [Vesuvius v3] PCI-ISA Bridge Master - 0003 PT86C524 [Nile] PCI-to-PCI Bridge - 0004 PT86C525 [Nile-II] PCI-to-PCI Bridge - 0005 National PC87550 System Controller - 8002 PT86C523 [Vesuvius v3] PCI-ISA Bridge Slave -1067 Mitsubishi Electric - 0301 AccelGraphics AccelECLIPSE - 0304 AccelGALAXY A2100 [OEM Evans & Sutherland] - 0308 Tornado 3000 [OEM Evans & Sutherland] - 1002 VG500 [VolumePro Volume Rendering Accelerator] -1068 Diversified Technology -1069 Mylex Corporation - 0001 DAC960P - 0002 DAC960PD - 0010 DAC960PG - 0020 DAC960LA - 0050 AcceleRAID 352/170/160 support Device - b166 Gemstone chipset SCSI controller - 1014 0242 iSeries 2872 DASD IOA - 1014 0266 Dual Channel PCI-X U320 SCSI Adapter - 1014 0278 Dual Channel PCI-X U320 SCSI RAID Adapter - 1014 02d3 Dual Channel PCI-X U320 SCSI Adapter - 1014 02d4 Dual Channel PCI-X U320 SCSI RAID Adapter - ba55 eXtremeRAID 1100 support Device - ba56 eXtremeRAID 2000/3000 support Device -106a Aten Research Inc -106b Apple Computer Inc. - 0001 Bandit PowerPC host bridge - 0002 Grand Central I/O - 0003 Control Video - 0004 PlanB Video-In - 0007 O'Hare I/O - 000c DOS on Mac - 000e Hydra Mac I/O - 0010 Heathrow Mac I/O - 0017 Paddington Mac I/O - 0018 UniNorth FireWire - 0019 KeyLargo USB - 001e UniNorth Internal PCI - 001f UniNorth PCI - 0020 UniNorth AGP - 0021 UniNorth GMAC (Sun GEM) - 0022 KeyLargo Mac I/O - 0024 UniNorth/Pangea GMAC (Sun GEM) - 0025 KeyLargo/Pangea Mac I/O - 0026 KeyLargo/Pangea USB - 0027 UniNorth/Pangea AGP - 0028 UniNorth/Pangea PCI - 0029 UniNorth/Pangea Internal PCI - 002d UniNorth 1.5 AGP - 002e UniNorth 1.5 PCI - 002f UniNorth 1.5 Internal PCI - 0030 UniNorth/Pangea FireWire - 0031 UniNorth 2 FireWire - 0032 UniNorth 2 GMAC (Sun GEM) - 0033 UniNorth 2 ATA/100 - 0034 UniNorth 2 AGP - 0035 UniNorth 2 PCI - 0036 UniNorth 2 Internal PCI - 003b UniNorth/Intrepid ATA/100 - 003e KeyLargo/Intrepid Mac I/O - 003f KeyLargo/Intrepid USB - 0040 K2 KeyLargo USB - 0041 K2 KeyLargo Mac/IO - 0042 K2 FireWire - 0043 K2 ATA/100 - 0045 K2 HT-PCI Bridge - 0046 K2 HT-PCI Bridge - 0047 K2 HT-PCI Bridge - 0048 K2 HT-PCI Bridge - 0049 K2 HT-PCI Bridge - 004b U3 AGP - 004c K2 GMAC (Sun GEM) - 004f Shasta Mac I/O - 0050 Shasta IDE - 0051 Shasta (Sun GEM) - 0052 Shasta Firewire - 0053 Shasta PCI Bridge - 0054 Shasta PCI Bridge - 0055 Shasta PCI Bridge - 0058 U3L AGP Bridge - 1645 Tigon3 Gigabit Ethernet NIC (BCM5701) -106c Hynix Semiconductor - 8801 Dual Pentium ISA/PCI Motherboard - 8802 PowerPC ISA/PCI Motherboard - 8803 Dual Window Graphics Accelerator - 8804 LAN Controller - 8805 100-BaseT LAN -106d Sequent Computer Systems -106e DFI, Inc -106f City Gate Development Ltd -1070 Daewoo Telecom Ltd -1071 Mitac - 8160 Mitac 8060B Mobile Platform -1072 GIT Co Ltd -1073 Yamaha Corporation - 0001 3D GUI Accelerator - 0002 YGV615 [RPA3 3D-Graphics Controller] - 0003 YMF-740 - 0004 YMF-724 - 1073 0004 YMF724-Based PCI Audio Adapter - 0005 DS1 Audio - 1073 0005 DS-XG PCI Audio CODEC - 0006 DS1 Audio - 0008 DS1 Audio - 1073 0008 DS-XG PCI Audio CODEC - 000a DS1L Audio - 1073 0004 DS-XG PCI Audio CODEC - 1073 000a DS-XG PCI Audio CODEC - 000c YMF-740C [DS-1L Audio Controller] - 107a 000c DS-XG PCI Audio CODEC - 000d YMF-724F [DS-1 Audio Controller] - 1073 000d DS-XG PCI Audio CODEC - 0010 YMF-744B [DS-1S Audio Controller] - 1073 0006 DS-XG PCI Audio CODEC - 1073 0010 DS-XG PCI Audio CODEC - 0012 YMF-754 [DS-1E Audio Controller] - 1073 0012 DS-XG PCI Audio Codec - 0020 DS-1 Audio - 2000 DS2416 Digital Mixing Card - 1073 2000 DS2416 Digital Mixing Card -1074 NexGen Microsystems - 4e78 82c500/1 -1075 Advanced Integrations Research -1076 Chaintech Computer Co. Ltd -1077 QLogic Corp. - 1016 ISP10160 Single Channel Ultra3 SCSI Processor - 1020 ISP1020 Fast-wide SCSI - 1022 ISP1022 Fast-wide SCSI - 1080 ISP1080 SCSI Host Adapter - 1216 ISP12160 Dual Channel Ultra3 SCSI Processor - 101e 8471 QLA12160 on AMI MegaRAID - 101e 8493 QLA12160 on AMI MegaRAID - 1240 ISP1240 SCSI Host Adapter - 1280 ISP1280 SCSI Host Adapter - 2020 ISP2020A Fast!SCSI Basic Adapter - 2100 QLA2100 64-bit Fibre Channel Adapter - 1077 0001 QLA2100 64-bit Fibre Channel Adapter - 2200 QLA2200 64-bit Fibre Channel Adapter - 1077 0002 QLA2200 - 2300 QLA2300 64-bit Fibre Channel Adapter - 2312 QLA2312 Fibre Channel Adapter -1078 Cyrix Corporation - 0000 5510 [Grappa] - 0001 PCI Master - 0002 5520 [Cognac] - 0100 5530 Legacy [Kahlua] - 0101 5530 SMI [Kahlua] - 0102 5530 IDE [Kahlua] - 0103 5530 Audio [Kahlua] - 0104 5530 Video [Kahlua] - 0400 ZFMicro PCI Bridge - 0401 ZFMicro Chipset SMI - 0402 ZFMicro Chipset IDE - 0403 ZFMicro Expansion Bus -1079 I-Bus -107a NetWorth -107b Gateway 2000 -107c LG Electronics [Lucky Goldstar Co. Ltd] -107d LeadTek Research Inc. - 0000 P86C850 - 2134 WinFast 3D S320 II - 2971 [GeForce FX 5900] WinFast A350 TDH MyViVo -107e Interphase Corporation - 0001 5515 ATM Adapter [Flipper] - 0002 100 VG AnyLan Controller - 0004 5526 Fibre Channel Host Adapter - 0005 x526 Fibre Channel Host Adapter - 0008 5525/5575 ATM Adapter (155 Mbit) [Atlantic] - 9003 5535-4P-BRI-ST - 9007 5535-4P-BRI-U - 9008 5535-1P-SR - 900c 5535-1P-SR-ST - 900e 5535-1P-SR-U - 9011 5535-1P-PRI - 9013 5535-2P-PRI - 9023 5536-4P-BRI-ST - 9027 5536-4P-BRI-U - 9031 5536-1P-PRI - 9033 5536-2P-PRI -107f Data Technology Corporation - 0802 SL82C105 -1080 Contaq Microsystems - 0600 82C599 - c691 Cypress CY82C691 - c693 82c693 -1081 Supermac Technology - 0d47 Radius PCI to NuBUS Bridge -1082 EFA Corporation of America -1083 Forex Computer Corporation - 0001 FR710 -1084 Parador -1085 Tulip Computers Int.B.V. -1086 J. Bond Computer Systems -1087 Cache Computer -1088 Microcomputer Systems (M) Son -1089 Data General Corporation -# Formerly Bit3 Computer Corp. -108a SBS Technologies - 0001 VME Bridge Model 617 - 0010 VME Bridge Model 618 - 0040 dataBLIZZARD - 3000 VME Bridge Model 2706 -108c Oakleigh Systems Inc. -108d Olicom - 0001 Token-Ring 16/4 PCI Adapter (3136/3137) - 0002 16/4 Token Ring - 0004 RapidFire 3139 Token-Ring 16/4 PCI Adapter - 108d 0004 OC-3139/3140 RapidFire Token-Ring 16/4 Adapter - 0005 GoCard 3250 Token-Ring 16/4 CardBus PC Card - 0006 OC-3530 RapidFire Token-Ring 100 - 0007 RapidFire 3141 Token-Ring 16/4 PCI Fiber Adapter - 108d 0007 OC-3141 RapidFire Token-Ring 16/4 Adapter - 0008 RapidFire 3540 HSTR 100/16/4 PCI Adapter - 108d 0008 OC-3540 RapidFire HSTR 100/16/4 Adapter - 0011 OC-2315 - 0012 OC-2325 - 0013 OC-2183/2185 - 0014 OC-2326 - 0019 OC-2327/2250 10/100 Ethernet Adapter - 108d 0016 OC-2327 Rapidfire 10/100 Ethernet Adapter - 108d 0017 OC-2250 GoCard 10/100 Ethernet Adapter - 0021 OC-6151/6152 [RapidFire ATM 155] - 0022 ATM Adapter -108e Sun Microsystems Computer Corp. - 0001 EBUS - 1000 EBUS - 1001 Happy Meal - 1100 RIO EBUS - 1101 RIO GEM - 1102 RIO 1394 - 1103 RIO USB - 1648 [bge] Gigabit Ethernet - 2bad GEM - 5000 Simba Advanced PCI Bridge - 5043 SunPCI Co-processor - 8000 Psycho PCI Bus Module - 8001 Schizo PCI Bus Module - 8002 Schizo+ PCI Bus Module - a000 Ultra IIi - a001 Ultra IIe - a801 Tomatillo PCI Bus Module - abba Cassini 10/100/1000 -108f Systemsoft -1090 Encore Computer Corporation -1091 Intergraph Corporation - 0020 3D graphics processor - 0021 3D graphics processor w/Texturing - 0040 3D graphics frame buffer - 0041 3D graphics frame buffer - 0060 Proprietary bus bridge - 00e4 Powerstorm 4D50T - 0720 Motion JPEG codec - 07a0 Sun Expert3D-Lite Graphics Accelerator - 1091 Sun Expert3D Graphics Accelerator -1092 Diamond Multimedia Systems - 00a0 Speedstar Pro SE - 00a8 Speedstar 64 - 0550 Viper V550 - 08d4 Supra 2260 Modem - 094c SupraExpress 56i Pro - 1092 Viper V330 - 6120 Maximum DVD - 8810 Stealth SE - 8811 Stealth 64/SE - 8880 Stealth - 8881 Stealth - 88b0 Stealth 64 - 88b1 Stealth 64 - 88c0 Stealth 64 - 88c1 Stealth 64 - 88d0 Stealth 64 - 88d1 Stealth 64 - 88f0 Stealth 64 - 88f1 Stealth 64 - 9999 DMD-I0928-1 "Monster sound" sound chip -1093 National Instruments - 0160 PCI-DIO-96 - 0162 PCI-MIO-16XE-50 - 1170 PCI-MIO-16XE-10 - 1180 PCI-MIO-16E-1 - 1190 PCI-MIO-16E-4 - 1310 PCI-6602 - 1330 PCI-6031E - 1350 PCI-6071E - 14e0 PCI-6110 - 14f0 PCI-6111 - 17d0 PCI-6503 - 1870 PCI-6713 - 1880 PCI-6711 - 18b0 PCI-6052E - 2410 PCI-6733 - 2890 PCI-6036E - 2a60 PCI-6023E - 2a70 PCI-6024E - 2a80 PCI-6025E - 2c80 PCI-6035E - 2ca0 PCI-6034E - 70b8 PCI-6251 [M Series - High Speed Multifunction DAQ] - b001 IMAQ-PCI-1408 - b011 IMAQ-PXI-1408 - b021 IMAQ-PCI-1424 - b031 IMAQ-PCI-1413 - b041 IMAQ-PCI-1407 - b051 IMAQ-PXI-1407 - b061 IMAQ-PCI-1411 - b071 IMAQ-PCI-1422 - b081 IMAQ-PXI-1422 - b091 IMAQ-PXI-1411 - c801 PCI-GPIB - c831 PCI-GPIB bridge -1094 First International Computers [FIC] -1095 Silicon Image, Inc. (formerly CMD Technology Inc) - 0240 Adaptec AAR-1210SA SATA HostRAID Controller - 0640 PCI0640 - 0643 PCI0643 - 0646 PCI0646 - 0647 PCI0647 - 0648 PCI0648 - 0649 SiI 0649 Ultra ATA/100 PCI to ATA Host Controller - 0e11 005d Integrated Ultra ATA-100 Dual Channel Controller - 0e11 007e Integrated Ultra ATA-100 IDE RAID Controller - 101e 0649 AMI MegaRAID IDE 100 Controller - 0650 PBC0650A - 0670 USB0670 - 1095 0670 USB0670 - 0673 USB0673 - 0680 PCI0680 Ultra ATA-133 Host Controller - 1095 3680 Winic W-680 (Silicon Image 680 based) - 3112 SiI 3112 [SATALink/SATARaid] Serial ATA Controller - 1095 3112 SiI 3112 SATALink Controller - 1095 6112 SiI 3112 SATARaid Controller - 3114 SiI 3114 [SATALink/SATARaid] Serial ATA Controller - 1095 3114 SiI 3114 SATALink Controller - 1095 6114 SiI 3114 SATARaid Controller - 3124 SiI 3124 PCI-X Serial ATA Controller - 1095 3124 SiI 3124 PCI-X Serial ATA Controller - 3512 SiI 3512 [SATALink/SATARaid] Serial ATA Controller - 1095 3512 SiI 3512 SATALink Controller - 1095 6512 SiI 3512 SATARaid Controller -1096 Alacron -1097 Appian Technology -1098 Quantum Designs (H.K.) Ltd - 0001 QD-8500 - 0002 QD-8580 -1099 Samsung Electronics Co., Ltd -109a Packard Bell -109b Gemlight Computer Ltd. -109c Megachips Corporation -109d Zida Technologies Ltd. -109e Brooktree Corporation - 0350 Bt848 Video Capture - 0351 Bt849A Video capture - 0369 Bt878 Video Capture - 1002 0001 TV-Wonder - 1002 0003 TV-Wonder/VE - 036c Bt879(??) Video Capture - 13e9 0070 Win/TV (Video Section) - 036e Bt878 Video Capture - 0070 13eb WinTV Series - 0070 ff01 Viewcast Osprey 200 - 0071 0101 DigiTV PCI - 107d 6606 WinFast TV 2000 - 11bd 0012 PCTV pro (TV + FM stereo receiver) - 11bd 001c PCTV Sat (DBC receiver) - 127a 0001 Bt878 Mediastream Controller NTSC - 127a 0002 Bt878 Mediastream Controller PAL BG - 127a 0003 Bt878a Mediastream Controller PAL BG - 127a 0048 Bt878/832 Mediastream Controller - 144f 3000 MagicTView CPH060 - Video - 1461 0002 TV98 Series (TV/No FM/Remote) - 1461 0003 AverMedia UltraTV PCI 350 - 1461 0004 AVerTV WDM Video Capture - 1461 0761 AverTV DVB-T - 14f1 0001 Bt878 Mediastream Controller NTSC - 14f1 0002 Bt878 Mediastream Controller PAL BG - 14f1 0003 Bt878a Mediastream Controller PAL BG - 14f1 0048 Bt878/832 Mediastream Controller - 1822 0001 VisionPlus DVB card - 1851 1850 FlyVideo'98 - Video - 1851 1851 FlyVideo II - 1852 1852 FlyVideo'98 - Video (with FM Tuner) - 270f fc00 Digitop DTT-1000 - bd11 1200 PCTV pro (TV + FM stereo receiver) - 036f Bt879 Video Capture - 127a 0044 Bt879 Video Capture NTSC - 127a 0122 Bt879 Video Capture PAL I - 127a 0144 Bt879 Video Capture NTSC - 127a 0222 Bt879 Video Capture PAL BG - 127a 0244 Bt879a Video Capture NTSC - 127a 0322 Bt879 Video Capture NTSC - 127a 0422 Bt879 Video Capture NTSC - 127a 1122 Bt879 Video Capture PAL I - 127a 1222 Bt879 Video Capture PAL BG - 127a 1322 Bt879 Video Capture NTSC - 127a 1522 Bt879a Video Capture PAL I - 127a 1622 Bt879a Video Capture PAL BG - 127a 1722 Bt879a Video Capture NTSC - 14f1 0044 Bt879 Video Capture NTSC - 14f1 0122 Bt879 Video Capture PAL I - 14f1 0144 Bt879 Video Capture NTSC - 14f1 0222 Bt879 Video Capture PAL BG - 14f1 0244 Bt879a Video Capture NTSC - 14f1 0322 Bt879 Video Capture NTSC - 14f1 0422 Bt879 Video Capture NTSC - 14f1 1122 Bt879 Video Capture PAL I - 14f1 1222 Bt879 Video Capture PAL BG - 14f1 1322 Bt879 Video Capture NTSC - 14f1 1522 Bt879a Video Capture PAL I - 14f1 1622 Bt879a Video Capture PAL BG - 14f1 1722 Bt879a Video Capture NTSC - 1851 1850 FlyVideo'98 - Video - 1851 1851 FlyVideo II - 1852 1852 FlyVideo'98 - Video (with FM Tuner) - 0370 Bt880 Video Capture - 1851 1850 FlyVideo'98 - 1851 1851 FlyVideo'98 EZ - video - 1852 1852 FlyVideo'98 (with FM Tuner) - 0878 Bt878 Audio Capture - 0070 13eb WinTV Series - 0070 ff01 Viewcast Osprey 200 - 0071 0101 DigiTV PCI - 1002 0001 TV-Wonder - 1002 0003 TV-Wonder/VE - 11bd 0012 PCTV pro (TV + FM stereo receiver, audio section) - 11bd 001c PCTV Sat (DBC receiver) - 127a 0001 Bt878 Video Capture (Audio Section) - 127a 0002 Bt878 Video Capture (Audio Section) - 127a 0003 Bt878 Video Capture (Audio Section) - 127a 0048 Bt878 Video Capture (Audio Section) - 13e9 0070 Win/TV (Audio Section) - 144f 3000 MagicTView CPH060 - Audio - 1461 0004 AVerTV WDM Audio Capture - 1461 0761 AVerTV DVB-T - 14f1 0001 Bt878 Video Capture (Audio Section) - 14f1 0002 Bt878 Video Capture (Audio Section) - 14f1 0003 Bt878 Video Capture (Audio Section) - 14f1 0048 Bt878 Video Capture (Audio Section) - 1822 0001 VisionPlus DVB Card - 270f fc00 Digitop DTT-1000 - bd11 1200 PCTV pro (TV + FM stereo receiver, audio section) - 0879 Bt879 Audio Capture - 127a 0044 Bt879 Video Capture (Audio Section) - 127a 0122 Bt879 Video Capture (Audio Section) - 127a 0144 Bt879 Video Capture (Audio Section) - 127a 0222 Bt879 Video Capture (Audio Section) - 127a 0244 Bt879 Video Capture (Audio Section) - 127a 0322 Bt879 Video Capture (Audio Section) - 127a 0422 Bt879 Video Capture (Audio Section) - 127a 1122 Bt879 Video Capture (Audio Section) - 127a 1222 Bt879 Video Capture (Audio Section) - 127a 1322 Bt879 Video Capture (Audio Section) - 127a 1522 Bt879 Video Capture (Audio Section) - 127a 1622 Bt879 Video Capture (Audio Section) - 127a 1722 Bt879 Video Capture (Audio Section) - 14f1 0044 Bt879 Video Capture (Audio Section) - 14f1 0122 Bt879 Video Capture (Audio Section) - 14f1 0144 Bt879 Video Capture (Audio Section) - 14f1 0222 Bt879 Video Capture (Audio Section) - 14f1 0244 Bt879 Video Capture (Audio Section) - 14f1 0322 Bt879 Video Capture (Audio Section) - 14f1 0422 Bt879 Video Capture (Audio Section) - 14f1 1122 Bt879 Video Capture (Audio Section) - 14f1 1222 Bt879 Video Capture (Audio Section) - 14f1 1322 Bt879 Video Capture (Audio Section) - 14f1 1522 Bt879 Video Capture (Audio Section) - 14f1 1622 Bt879 Video Capture (Audio Section) - 14f1 1722 Bt879 Video Capture (Audio Section) - 0880 Bt880 Audio Capture - 2115 BtV 2115 Mediastream controller - 2125 BtV 2125 Mediastream controller - 2164 BtV 2164 - 2165 BtV 2165 - 8230 Bt8230 ATM Segment/Reassembly Ctrlr (SRC) - 8472 Bt8472 - 8474 Bt8474 -109f Trigem Computer Inc. -10a0 Meidensha Corporation -10a1 Juko Electronics Ind. Co. Ltd -10a2 Quantum Corporation -10a3 Everex Systems Inc -10a4 Globe Manufacturing Sales -10a5 Smart Link Ltd. - 3052 SmartPCI562 56K Modem - 5449 SmartPCI561 modem -10a6 Informtech Industrial Ltd. -10a7 Benchmarq Microelectronics -10a8 Sierra Semiconductor - 0000 STB Horizon 64 -10a9 Silicon Graphics, Inc. - 0001 Crosstalk to PCI Bridge - 0002 Linc I/O controller - 0003 IOC3 I/O controller - 0004 O2 MACE - 0005 RAD Audio - 0006 HPCEX - 0007 RPCEX - 0008 DiVO VIP - 0009 AceNIC Gigabit Ethernet - 10a9 8002 AceNIC Gigabit Ethernet - 0010 AMP Video I/O - 0011 GRIP - 0012 SGH PSHAC GSN - 1001 Magic Carpet - 1002 Lithium - 1003 Dual JPEG 1 - 1004 Dual JPEG 2 - 1005 Dual JPEG 3 - 1006 Dual JPEG 4 - 1007 Dual JPEG 5 - 1008 Cesium - 100a IOC4 I/O controller - 2001 Fibre Channel - 2002 ASDE - 8001 O2 1394 - 8002 G-net NT -10aa ACC Microelectronics - 0000 ACCM 2188 -10ab Digicom -10ac Honeywell IAC -10ad Symphony Labs - 0001 W83769F - 0003 SL82C103 - 0005 SL82C105 - 0103 SL82c103 - 0105 SL82c105 - 0565 W83C553 -10ae Cornerstone Technology -10af Micro Computer Systems Inc -10b0 CardExpert Technology -10b1 Cabletron Systems Inc -10b2 Raytheon Company -10b3 Databook Inc - 3106 DB87144 - b106 DB87144 -10b4 STB Systems Inc - 1b1d Velocity 128 3D - 10b4 237e Velocity 4400 -10b5 PLX Technology, Inc. - 0001 i960 PCI bus interface - 1076 VScom 800 8 port serial adaptor - 1077 VScom 400 4 port serial adaptor - 1078 VScom 210 2 port serial and 1 port parallel adaptor - 1103 VScom 200 2 port serial adaptor - 1146 VScom 010 1 port parallel adaptor - 1147 VScom 020 2 port parallel adaptor - 2724 Thales PCSM Security Card - 8516 PEX 8516 Versatile PCI Express Switch - 8532 PEX 8532 Versatile PCI Express Switch - 9030 PCI <-> IOBus Bridge Hot Swap - 10b5 2862 Alpermann+Velte PCL PCI LV (3V/5V): Timecode Reader Board - 10b5 2906 Alpermann+Velte PCI TS (3V/5V): Time Synchronisation Board - 10b5 2940 Alpermann+Velte PCL PCI D (3V/5V): Timecode Reader Board - 10b5 3025 Alpermann+Velte PCL PCI L (3V/5V): Timecode Reader Board - 10b5 3068 Alpermann+Velte PCL PCI HD (3V/5V): Timecode Reader Board - 15ed 1002 MCCS 8-port Serial Hot Swap - 15ed 1003 MCCS 16-port Serial Hot Swap - 9036 9036 - 9050 PCI <-> IOBus Bridge - 10b5 1067 IXXAT CAN i165 - 10b5 1172 IK220 (Heidenhain) - 10b5 2036 SatPak GPS - 10b5 2221 Alpermann+Velte PCL PCI LV: Timecode Reader Board - 10b5 2273 SH-ARC SoHard ARCnet card - 10b5 2431 Alpermann+Velte PCL PCI D: Timecode Reader Board - 10b5 2905 Alpermann+Velte PCI TS: Time Synchronisation Board - 10b5 9050 MP9050 - 1498 0362 TPMC866 8 Channel Serial Card - 1522 0001 RockForce 4 Port V.90 Data/Fax/Voice Modem - 1522 0002 RockForce 2 Port V.90 Data/Fax/Voice Modem - 1522 0003 RockForce 6 Port V.90 Data/Fax/Voice Modem - 1522 0004 RockForce 8 Port V.90 Data/Fax/Voice Modem - 1522 0010 RockForce2000 4 Port V.90 Data/Fax/Voice Modem - 1522 0020 RockForce2000 2 Port V.90 Data/Fax/Voice Modem - 15ed 1000 Macrolink MCCS 8-port Serial - 15ed 1001 Macrolink MCCS 16-port Serial - 15ed 1002 Macrolink MCCS 8-port Serial Hot Swap - 15ed 1003 Macrolink MCCS 16-port Serial Hot Swap -# Sorry, there was a typo - 5654 2036 OpenSwitch 6 Telephony card -# Sorry, there was a typo - 5654 3132 OpenSwitch 12 Telephony card - 5654 5634 OpenLine4 Telephony Card - d531 c002 PCIntelliCAN 2xSJA1000 CAN bus - d84d 4006 EX-4006 1P - d84d 4008 EX-4008 1P EPP/ECP - d84d 4014 EX-4014 2P - d84d 4018 EX-4018 3P EPP/ECP - d84d 4025 EX-4025 1S(16C550) RS-232 - d84d 4027 EX-4027 1S(16C650) RS-232 - d84d 4028 EX-4028 1S(16C850) RS-232 - d84d 4036 EX-4036 2S(16C650) RS-232 - d84d 4037 EX-4037 2S(16C650) RS-232 - d84d 4038 EX-4038 2S(16C850) RS-232 - d84d 4052 EX-4052 1S(16C550) RS-422/485 - d84d 4053 EX-4053 2S(16C550) RS-422/485 - d84d 4055 EX-4055 4S(16C550) RS-232 - d84d 4058 EX-4055 4S(16C650) RS-232 - d84d 4065 EX-4065 8S(16C550) RS-232 - d84d 4068 EX-4068 8S(16C650) RS-232 - d84d 4078 EX-4078 2S(16C552) RS-232+1P - 9054 PCI <-> IOBus Bridge - 10b5 2455 Wessex Techology PHIL-PCI - 10b5 2696 Innes Corp AM Radcap card - 10b5 2717 Innes Corp Auricon card - 10b5 2844 Innes Corp TVS Encoder card - 12d9 0002 PCI Prosody Card rev 1.5 - 16df 0011 PIKA PrimeNet MM PCI - 16df 0012 PIKA PrimeNet MM cPCI 8 - 16df 0013 PIKA PrimeNet MM cPCI 8 (without CAS Signaling Option) - 16df 0014 PIKA PrimeNet MM cPCI 4 - 16df 0015 PIKA Daytona MM - 16df 0016 PIKA InLine MM - 9056 Francois - 10b5 2979 CellinkBlade 11 - CPCI board VoATM AAL1 - 9060 9060 - 906d 9060SD - 125c 0640 Aries 16000P - 906e 9060ES - 9080 9080 - 103c 10eb (Agilent) E2777B 83K Series PCI based Optical Communication Interface - 103c 10ec (Agilent) E6978-66442 PCI CIC - 10b5 9080 9080 [real subsystem ID not set] - 129d 0002 Aculab PCI Prosidy card - 12d9 0002 PCI Prosody Card - 12df 4422 4422PCI ["Do-All" Telemetry Data Aquisition System] - bb04 B&B 3PCIOSD1A Isolated PCI Serial -10b6 Madge Networks - 0001 Smart 16/4 PCI Ringnode - 0002 Smart 16/4 PCI Ringnode Mk2 - 10b6 0002 Smart 16/4 PCI Ringnode Mk2 - 10b6 0006 16/4 CardBus Adapter - 0003 Smart 16/4 PCI Ringnode Mk3 - 0e11 b0fd Compaq NC4621 PCI, 4/16, WOL - 10b6 0003 Smart 16/4 PCI Ringnode Mk3 - 10b6 0007 Presto PCI Plus Adapter - 0004 Smart 16/4 PCI Ringnode Mk1 - 0006 16/4 Cardbus Adapter - 10b6 0006 16/4 CardBus Adapter - 0007 Presto PCI Adapter - 10b6 0007 Presto PCI - 0009 Smart 100/16/4 PCI-HS Ringnode - 10b6 0009 Smart 100/16/4 PCI-HS Ringnode - 000a Smart 100/16/4 PCI Ringnode - 10b6 000a Smart 100/16/4 PCI Ringnode - 000b 16/4 CardBus Adapter Mk2 - 10b6 0008 16/4 CardBus Adapter Mk2 - 10b6 000b 16/4 Cardbus Adapter Mk2 - 000c RapidFire 3140V2 16/4 TR Adapter - 10b6 000c RapidFire 3140V2 16/4 TR Adapter - 1000 Collage 25/155 ATM Client Adapter - 1001 Collage 155 ATM Server Adapter -10b7 3Com Corporation - 0001 3c985 1000BaseSX (SX/TX) - 0013 AR5212 802.11abg NIC (3CRDAG675) - 10b7 2031 3CRDAG675 11a/b/g Wireless PCI Adapter - 0910 3C910-A01 - 1006 MINI PCI type 3B Data Fax Modem - 1007 Mini PCI 56k Winmodem - 10b7 615c Mini PCI 56K Modem - 1201 3c982-TXM 10/100baseTX Dual Port A [Hydra] - 1202 3c982-TXM 10/100baseTX Dual Port B [Hydra] - 1700 3c940 10/100/1000Base-T [Marvell] - 1043 80eb P4P800/K8V Deluxe motherboard - 10b7 0010 3C940 Gigabit LOM Ethernet Adapter - 10b7 0020 3C941 Gigabit LOM Ethernet Adapter - 147b 1407 KV8-MAX3 motherboard - 3390 3c339 TokenLink Velocity - 3590 3c359 TokenLink Velocity XL - 10b7 3590 TokenLink Velocity XL Adapter (3C359/359B) - 4500 3c450 HomePNA [Tornado] - 5055 3c555 Laptop Hurricane - 5057 3c575 Megahertz 10/100 LAN CardBus [Boomerang] - 10b7 5a57 3C575 Megahertz 10/100 LAN Cardbus PC Card - 5157 3cCFE575BT Megahertz 10/100 LAN CardBus [Cyclone] - 10b7 5b57 3C575 Megahertz 10/100 LAN Cardbus PC Card - 5257 3cCFE575CT CardBus [Cyclone] - 10b7 5c57 FE575C-3Com 10/100 LAN CardBus-Fast Ethernet - 5900 3c590 10BaseT [Vortex] - 5920 3c592 EISA 10mbps Demon/Vortex - 5950 3c595 100BaseTX [Vortex] - 5951 3c595 100BaseT4 [Vortex] - 5952 3c595 100Base-MII [Vortex] - 5970 3c597 EISA Fast Demon/Vortex - 5b57 3c595 Megahertz 10/100 LAN CardBus [Boomerang] - 10b7 5b57 3C575 Megahertz 10/100 LAN Cardbus PC Card - 6000 3CRSHPW796 [OfficeConnect Wireless CardBus] - 6001 3com 3CRWE154G72 [Office Connect Wireless LAN Adapter] - 6055 3c556 Hurricane CardBus [Cyclone] - 6056 3c556B CardBus [Tornado] - 10b7 6556 10/100 Mini PCI Ethernet Adapter - 6560 3cCFE656 CardBus [Cyclone] - 10b7 656a 3CCFEM656 10/100 LAN+56K Modem CardBus - 6561 3cCFEM656 10/100 LAN+56K Modem CardBus - 10b7 656b 3CCFEM656 10/100 LAN+56K Modem CardBus - 6562 3cCFEM656B 10/100 LAN+Winmodem CardBus [Cyclone] - 10b7 656b 3CCFEM656B 10/100 LAN+56K Modem CardBus - 6563 3cCFEM656B 10/100 LAN+56K Modem CardBus - 10b7 656b 3CCFEM656 10/100 LAN+56K Modem CardBus - 6564 3cXFEM656C 10/100 LAN+Winmodem CardBus [Tornado] - 7646 3cSOHO100-TX Hurricane - 7770 3CRWE777 PCI(PLX) Wireless Adaptor [Airconnect] - 7940 3c803 FDDILink UTP Controller - 7980 3c804 FDDILink SAS Controller - 7990 3c805 FDDILink DAS Controller - 80eb 3c940B 10/100/1000Base-T - 8811 Token ring - 9000 3c900 10BaseT [Boomerang] - 9001 3c900 10Mbps Combo [Boomerang] - 9004 3c900B-TPO Etherlink XL [Cyclone] - 10b7 9004 3C900B-TPO Etherlink XL TPO 10Mb - 9005 3c900B-Combo Etherlink XL [Cyclone] - 10b7 9005 3C900B-Combo Etherlink XL Combo - 9006 3c900B-TPC Etherlink XL [Cyclone] - 900a 3c900B-FL 10base-FL [Cyclone] - 9050 3c905 100BaseTX [Boomerang] - 9051 3c905 100BaseT4 [Boomerang] - 9055 3c905B 100BaseTX [Cyclone] - 1028 0080 3C905B Fast Etherlink XL 10/100 - 1028 0081 3C905B Fast Etherlink XL 10/100 - 1028 0082 3C905B Fast Etherlink XL 10/100 - 1028 0083 3C905B Fast Etherlink XL 10/100 - 1028 0084 3C905B Fast Etherlink XL 10/100 - 1028 0085 3C905B Fast Etherlink XL 10/100 - 1028 0086 3C905B Fast Etherlink XL 10/100 - 1028 0087 3C905B Fast Etherlink XL 10/100 - 1028 0088 3C905B Fast Etherlink XL 10/100 - 1028 0089 3C905B Fast Etherlink XL 10/100 - 1028 0090 3C905B Fast Etherlink XL 10/100 - 1028 0091 3C905B Fast Etherlink XL 10/100 - 1028 0092 3C905B Fast Etherlink XL 10/100 - 1028 0093 3C905B Fast Etherlink XL 10/100 - 1028 0094 3C905B Fast Etherlink XL 10/100 - 1028 0095 3C905B Fast Etherlink XL 10/100 - 1028 0096 3C905B Fast Etherlink XL 10/100 - 1028 0097 3C905B Fast Etherlink XL 10/100 - 1028 0098 3C905B Fast Etherlink XL 10/100 - 1028 0099 3C905B Fast Etherlink XL 10/100 - 10b7 9055 3C905B Fast Etherlink XL 10/100 - 9056 3c905B-T4 Fast EtherLink XL [Cyclone] - 9058 3c905B Deluxe Etherlink 10/100/BNC [Cyclone] - 905a 3c905B-FX Fast Etherlink XL FX 100baseFx [Cyclone] - 9200 3c905C-TX/TX-M [Tornado] - 1028 0095 3C920 Integrated Fast Ethernet Controller - 1028 0097 3C920 Integrated Fast Ethernet Controller - 1028 00fe Optiplex GX240 - 1028 012a 3C920 Integrated Fast Ethernet Controller [Latitude C640] - 10b7 1000 3C905C-TX Fast Etherlink for PC Management NIC - 10b7 7000 10/100 Mini PCI Ethernet Adapter - 10f1 2466 Tiger MPX S2466 (3C920 Integrated Fast Ethernet Controller) - 9201 3C920B-EMB Integrated Fast Ethernet Controller [Tornado] - 1043 80ab A7N8X Deluxe onboard 3C920B-EMB Integrated Fast Ethernet Controller - 9202 3Com 3C920B-EMB-WNM Integrated Fast Ethernet Controller - 9210 3C920B-EMB-WNM Integrated Fast Ethernet Controller - 9300 3CSOHO100B-TX 910-A01 [tulip] - 9800 3c980-TX Fast Etherlink XL Server Adapter [Cyclone] - 10b7 9800 3c980-TX Fast Etherlink XL Server Adapter - 9805 3c980-C 10/100baseTX NIC [Python-T] - 10b7 1201 EtherLink Server 10/100 Dual Port A - 10b7 1202 EtherLink Server 10/100 Dual Port B - 10b7 9805 3c980 10/100baseTX NIC [Python-T] - 10f1 2462 Thunder K7 S2462 - 9900 3C990-TX [Typhoon] - 9902 3CR990-TX-95 [Typhoon 56-bit] - 9903 3CR990-TX-97 [Typhoon 168-bit] - 9904 3C990B-TX-M/3C990BSVR [Typhoon2] - 10b7 1000 3CR990B-TX-M [Typhoon2] - 10b7 2000 3CR990BSVR [Typhoon2 Server] - 9905 3CR990-FX-95/97/95 [Typhon Fiber] - 10b7 1101 3CR990-FX-95 [Typhoon Fiber 56-bit] - 10b7 1102 3CR990-FX-97 [Typhoon Fiber 168-bit] - 10b7 2101 3CR990-FX-95 Server [Typhoon Fiber 56-bit] - 10b7 2102 3CR990-FX-97 Server [Typhoon Fiber 168-bit] - 9908 3CR990SVR95 [Typhoon Server 56-bit] - 9909 3CR990SVR97 [Typhoon Server 168-bit] - 990a 3C990SVR [Typhoon Server] - 990b 3C990SVR [Typhoon Server] -10b8 Standard Microsystems Corp [SMC] - 0005 83c170 EPIC/100 Fast Ethernet Adapter - 1055 e000 LANEPIC 10/100 [EVB171Q-PCI] - 1055 e002 LANEPIC 10/100 [EVB171G-PCI] - 10b8 a011 EtherPower II 10/100 - 10b8 a014 EtherPower II 10/100 - 10b8 a015 EtherPower II 10/100 - 10b8 a016 EtherPower II 10/100 - 10b8 a017 EtherPower II 10/100 - 0006 83c175 EPIC/100 Fast Ethernet Adapter - 1055 e100 LANEPIC Cardbus Fast Ethernet Adapter - 1055 e102 LANEPIC Cardbus Fast Ethernet Adapter - 1055 e300 LANEPIC Cardbus Fast Ethernet Adapter - 1055 e302 LANEPIC Cardbus Fast Ethernet Adapter - 10b8 a012 LANEPIC Cardbus Fast Ethernet Adapter - 13a2 8002 LANEPIC Cardbus Fast Ethernet Adapter - 13a2 8006 LANEPIC Cardbus Fast Ethernet Adapter - 1000 FDC 37c665 - 1001 FDC 37C922 -# 802.11g card - 2802 SMC2802W [EZ Connect g] - a011 83C170QF - b106 SMC34C90 -10b9 ALi Corporation - 0101 CMI8338/C3DX PCI Audio Device - 0111 C-Media CMI8738/C3DX Audio Device (OEM) - 10b9 0111 C-Media CMI8738/C3DX Audio Device (OEM) - 0780 Multi-IO Card - 0782 Multi-IO Card - 1435 M1435 - 1445 M1445 - 1449 M1449 - 1451 M1451 - 1461 M1461 - 1489 M1489 - 1511 M1511 [Aladdin] - 1512 M1512 [Aladdin] - 1513 M1513 [Aladdin] - 1521 M1521 [Aladdin III] - 10b9 1521 ALI M1521 Aladdin III CPU Bridge - 1523 M1523 - 10b9 1523 ALI M1523 ISA Bridge - 1531 M1531 [Aladdin IV] - 1533 M1533 PCI to ISA Bridge [Aladdin IV] - 1014 053b ThinkPad R40e (2684-HVG) PCI to ISA Bridge - 10b9 1533 ALI M1533 Aladdin IV ISA Bridge - 1541 M1541 - 10b9 1541 ALI M1541 Aladdin V/V+ AGP System Controller - 1543 M1543 - 1563 M1563 HyperTransport South Bridge - 1621 M1621 - 1631 ALI M1631 PCI North Bridge Aladdin Pro III - 1632 M1632M Northbridge+Trident - 1641 ALI M1641 PCI North Bridge Aladdin Pro IV - 1644 M1644/M1644T Northbridge+Trident - 1646 M1646 Northbridge+Trident - 1647 M1647 Northbridge [MAGiK 1 / MobileMAGiK 1] - 1651 M1651/M1651T Northbridge [Aladdin-Pro 5/5M,Aladdin-Pro 5T/5TM] - 1671 M1671 Super P4 Northbridge [AGP4X,PCI and SDR/DDR] - 1672 M1672 Northbridge [CyberALADDiN-P4] - 1681 M1681 P4 Northbridge [AGP8X,HyperTransport and SDR/DDR] - 1687 M1687 K8 Northbridge [AGP8X and HyperTransport] - 1689 M1689 K8 Northbridge [Super K8 Single Chip] - 3141 M3141 - 3143 M3143 - 3145 M3145 - 3147 M3147 - 3149 M3149 - 3151 M3151 - 3307 M3307 - 3309 M3309 - 3323 M3325 Video/Audio Decoder - 5212 M4803 - 5215 MS4803 - 5217 M5217H - 5219 M5219 - 5225 M5225 - 5228 M5228 ALi ATA/RAID Controller - 5229 M5229 IDE - 1014 050f ThinkPad R30 - 1014 053d ThinkPad R40e (2684-HVG) builtin IDE - 103c 0024 Pavilion ze4400 builtin IDE - 1043 8053 A7A266 Motherboard IDE - 5235 M5225 - 5237 USB 1.1 Controller - 1014 0540 ThinkPad R40e (2684-HVG) builtin USB - 103c 0024 Pavilion ze4400 builtin USB - 5239 USB 2.0 Controller - 5243 M1541 PCI to AGP Controller - 5246 AGP8X Controller - 5247 PCI to AGP Controller - 5249 M5249 HTT to PCI Bridge - 5251 M5251 P1394 OHCI 1.0 Controller - 5253 M5253 P1394 OHCI 1.1 Controller - 5261 M5261 Ethernet Controller - 5263 M5263 Ethernet Controller - 5281 ALi M5281 Serial ATA / RAID Host Controller - 5287 ULi 5287 SATA - 5289 ULi 5289 SATA - 5450 Lucent Technologies Soft Modem AMR - 5451 M5451 PCI AC-Link Controller Audio Device - 1014 0506 ThinkPad R30 - 1014 053e ThinkPad R40e (2684-HVG) builtin Audio - 103c 0024 Pavilion ze4400 builtin Audio - 10b9 5451 HP Compaq nc4010 (DY885AA#ABN) - 5453 M5453 PCI AC-Link Controller Modem Device - 5455 M5455 PCI AC-Link Controller Audio Device - 5457 M5457 AC'97 Modem Controller - 1014 0535 ThinkPad R40e (2684-HVG) builtin modem - 103c 0024 Pavilion ze4400 builtin Modem Device -# Same but more usefull for driver's lookup - 5459 SmartLink SmartPCI561 56K Modem -# SmartLink PCI SoftModem - 545a SmartLink SmartPCI563 56K Modem - 5471 M5471 Memory Stick Controller - 5473 M5473 SD-MMC Controller - 7101 M7101 Power Management Controller [PMU] - 1014 0510 ThinkPad R30 - 1014 053c ThinkPad R40e (2684-HVG) Power Management Controller - 103c 0024 Pavilion ze4400 -10ba Mitsubishi Electric Corp. - 0301 AccelGraphics AccelECLIPSE - 0304 AccelGALAXY A2100 [OEM Evans & Sutherland] - 0308 Tornado 3000 [OEM Evans & Sutherland] - 1002 VG500 [VolumePro Volume Rendering Accelerator] -10bb Dapha Electronics Corporation -10bc Advanced Logic Research -10bd Surecom Technology - 0e34 NE-34 -10be Tseng Labs International Co. -10bf Most Inc -10c0 Boca Research Inc. -10c1 ICM Co., Ltd. -10c2 Auspex Systems Inc. -10c3 Samsung Semiconductors, Inc. - 1100 Smartether100 SC1100 LAN Adapter (i82557B) -10c4 Award Software International Inc. -10c5 Xerox Corporation -10c6 Rambus Inc. -10c7 Media Vision -10c8 Neomagic Corporation - 0001 NM2070 [MagicGraph 128] - 0002 NM2090 [MagicGraph 128V] - 0003 NM2093 [MagicGraph 128ZV] - 0004 NM2160 [MagicGraph 128XD] - 1014 00ba MagicGraph 128XD - 1025 1007 MagicGraph 128XD - 1028 0074 MagicGraph 128XD - 1028 0075 MagicGraph 128XD - 1028 007d MagicGraph 128XD - 1028 007e MagicGraph 128XD - 1033 802f MagicGraph 128XD - 104d 801b MagicGraph 128XD - 104d 802f MagicGraph 128XD - 104d 830b MagicGraph 128XD - 10ba 0e00 MagicGraph 128XD - 10c8 0004 MagicGraph 128XD - 10cf 1029 MagicGraph 128XD - 10f7 8308 MagicGraph 128XD - 10f7 8309 MagicGraph 128XD - 10f7 830b MagicGraph 128XD - 10f7 830d MagicGraph 128XD - 10f7 8312 MagicGraph 128XD - 0005 NM2200 [MagicGraph 256AV] - 1014 00dd ThinkPad 570 - 1028 0088 Latitude CPi A - 0006 NM2360 [MagicMedia 256ZX] - 0016 NM2380 [MagicMedia 256XL+] - 10c8 0016 MagicMedia 256XL+ - 0025 NM2230 [MagicGraph 256AV+] - 0083 NM2093 [MagicGraph 128ZV+] - 8005 NM2200 [MagicMedia 256AV Audio] - 0e11 b0d1 MagicMedia 256AV Audio Device on Discovery - 0e11 b126 MagicMedia 256AV Audio Device on Durango - 1014 00dd MagicMedia 256AV Audio Device on BlackTip Thinkpad - 1025 1003 MagicMedia 256AV Audio Device on TravelMate 720 - 1028 0088 Latitude CPi A - 1028 008f MagicMedia 256AV Audio Device on Colorado Inspiron - 103c 0007 MagicMedia 256AV Audio Device on Voyager II - 103c 0008 MagicMedia 256AV Audio Device on Voyager III - 103c 000d MagicMedia 256AV Audio Device on Omnibook 900 - 10c8 8005 MagicMedia 256AV Audio Device on FireAnt - 110a 8005 MagicMedia 256AV Audio Device - 14c0 0004 MagicMedia 256AV Audio Device - 8006 NM2360 [MagicMedia 256ZX Audio] - 8016 NM2380 [MagicMedia 256XL+ Audio] -10c9 Dataexpert Corporation -10ca Fujitsu Microelectr., Inc. -10cb Omron Corporation -# nee Mentor ARC Inc -10cc Mai Logic Incorporated - 0660 Articia S Host Bridge - 0661 Articia S PCI Bridge -10cd Advanced System Products, Inc - 1100 ASC1100 - 1200 ASC1200 [(abp940) Fast SCSI-II] - 1300 ABP940-U / ABP960-U - 10cd 1310 ASC1300 SCSI Adapter - 2300 ABP940-UW - 2500 ABP940-U2W -10ce Radius -# nee Citicorp TTI -10cf Fujitsu Limited. - 2001 mb86605 -10d1 FuturePlus Systems Corp. -10d2 Molex Incorporated -10d3 Jabil Circuit Inc -10d4 Hualon Microelectronics -10d5 Autologic Inc. -10d6 Cetia -10d7 BCM Advanced Research -10d8 Advanced Peripherals Labs -10d9 Macronix, Inc. [MXIC] - 0431 MX98715 - 0512 MX98713 - 0531 MX987x5 - 1186 1200 DFE-540TX ProFAST 10/100 Adapter - 8625 MX86250 - 8888 MX86200 -10da Compaq IPG-Austin - 0508 TC4048 Token Ring 4/16 - 3390 Tl3c3x9 -10db Rohm LSI Systems, Inc. -10dc CERN/ECP/EDU - 0001 STAR/RD24 SCI-PCI (PMC) - 0002 TAR/RD24 SCI-PCI (PMC) - 0021 HIPPI destination - 0022 HIPPI source - 10dc ATT2C15-3 FPGA -10dd Evans & Sutherland -10de nVidia Corporation - 0008 NV1 [EDGE 3D] - 0009 NV1 [EDGE 3D] - 0010 NV2 [Mutara V08] - 0020 NV4 [RIVA TNT] - 1043 0200 V3400 TNT - 1048 0c18 Erazor II SGRAM - 1048 0c1b Erazor II - 1092 0550 Viper V550 - 1092 0552 Viper V550 - 1092 4804 Viper V550 - 1092 4808 Viper V550 - 1092 4810 Viper V550 - 1092 4812 Viper V550 - 1092 4815 Viper V550 - 1092 4820 Viper V550 with TV out - 1092 4822 Viper V550 - 1092 4904 Viper V550 - 1092 4914 Viper V550 - 1092 8225 Viper V550 - 10b4 273d Velocity 4400 - 10b4 273e Velocity 4400 - 10b4 2740 Velocity 4400 - 10de 0020 Riva TNT - 1102 1015 Graphics Blaster CT6710 - 1102 1016 Graphics Blaster RIVA TNT - 0028 NV5 [RIVA TNT2/TNT2 Pro] - 1043 0200 AGP-V3800 SGRAM - 1043 0201 AGP-V3800 SDRAM - 1043 0205 PCI-V3800 - 1043 4000 AGP-V3800PRO - 1048 0c21 Synergy II - 1048 0c31 Erazor III - 107d 2134 WinFast 3D S320 II + TV-Out - 1092 4804 Viper V770 - 1092 4a00 Viper V770 - 1092 4a02 Viper V770 Ultra - 1092 5a00 RIVA TNT2/TNT2 Pro - 1092 6a02 Viper V770 Ultra - 1092 7a02 Viper V770 Ultra - 10de 0005 RIVA TNT2 Pro - 10de 000f Compaq NVIDIA TNT2 Pro - 1102 1020 3D Blaster RIVA TNT2 - 1102 1026 3D Blaster RIVA TNT2 Digital - 14af 5810 Maxi Gamer Xentor - 0029 NV5 [RIVA TNT2 Ultra] - 1043 0200 AGP-V3800 Deluxe - 1043 0201 AGP-V3800 Ultra SDRAM - 1043 0205 PCI-V3800 Ultra - 1102 1021 3D Blaster RIVA TNT2 Ultra - 1102 1029 3D Blaster RIVA TNT2 Ultra - 1102 102f 3D Blaster RIVA TNT2 Ultra - 14af 5820 Maxi Gamer Xentor 32 - 002a NV5 [Riva TnT2] - 002b NV5 [Riva TnT2] - 002c NV6 [Vanta/Vanta LT] - 1043 0200 AGP-V3800 Combat SDRAM - 1043 0201 AGP-V3800 Combat - 1092 6820 Viper V730 - 1102 1031 CT6938 VANTA 8MB - 1102 1034 CT6894 VANTA 16MB - 14af 5008 Maxi Gamer Phoenix 2 - 002d NV5M64 [RIVA TNT2 Model 64/Model 64 Pro] - 1043 0200 AGP-V3800M - 1043 0201 AGP-V3800M - 1048 0c3a Erazor III LT - 10de 001e M64 AGP4x - 1102 1023 CT6892 RIVA TNT2 Value - 1102 1024 CT6932 RIVA TNT2 Value 32Mb - 1102 102c CT6931 RIVA TNT2 Value [Jumper] - 1462 8808 MSI-8808 - 1554 1041 Pixelview RIVA TNT2 M64 - 1569 002d Palit Microsystems Daytona TNT2 M64 - 002e NV6 [Vanta] - 002f NV6 [Vanta] - 0034 MCP04 SMBus - 0035 MCP04 IDE - 0036 MCP04 Serial ATA Controller - 0037 MCP04 Ethernet Controller - 0038 MCP04 Ethernet Controller - 003a MCP04 AC'97 Audio Controller - 003b MCP04 USB Controller - 003c MCP04 USB Controller - 003d MCP04 PCI Bridge - 003e MCP04 Serial ATA Controller - 0040 nv40 [GeForce 6800 Ultra] - 0041 NV40 [GeForce 6800] - 0042 NV40.2 - 0043 NV40.3 - 0045 NV40 [GeForce 6800 GT] - 0049 NV40GL - 004e NV40GL [Quadro FX 4000] - 0051 CK804 ISA Bridge - 0052 CK804 SMBus - 0053 CK804 IDE - 0054 CK804 Serial ATA Controller - 0055 CK804 Serial ATA Controller - 0056 CK804 Ethernet Controller - 0057 CK804 Ethernet Controller - 0059 CK804 AC'97 Audio Controller - 005a CK804 USB Controller - 005b CK804 USB Controller - 005c CK804 PCI Bridge - 005d CK804 PCIE Bridge - 005e CK804 Memory Controller - 0060 nForce2 ISA Bridge - 1043 80ad A7N8X Mainboard - 0064 nForce2 SMBus (MCP) - 0065 nForce2 IDE - 0066 nForce2 Ethernet Controller - 1043 80a7 A7N8X Mainboard onboard nForce2 Ethernet - 0067 nForce2 USB Controller - 1043 0c11 A7N8X Mainboard - 0068 nForce2 USB Controller - 1043 0c11 A7N8X Mainboard - 006a nForce2 AC97 Audio Controler (MCP) - 006b nForce Audio Processing Unit - 10de 006b nForce2 MCP Audio Processing Unit - 006c nForce2 External PCI Bridge - 006d nForce2 PCI Bridge - 006e nForce2 FireWire (IEEE 1394) Controller - 0084 MCP2A SMBus - 0085 MCP2A IDE - 0086 MCP2A Ethernet Controller - 0087 MCP2A USB Controller - 0088 MCP2A USB Controller - 008a MCP2S AC'97 Audio Controller - 008b MCP2A PCI Bridge - 008c MCP2A Ethernet Controller - 008e nForce2 Serial ATA Controller - 00a0 NV5 [Aladdin TNT2] - 14af 5810 Maxi Gamer Xentor - 00c0 NV41.0 - 00c1 NV41.1 - 00c2 NV41.2 - 00c8 NV41.8 - 00ce NV41GL - 00d0 nForce3 LPC Bridge - 00d1 nForce3 Host Bridge - 00d2 nForce3 AGP Bridge - 00d3 CK804 Memory Controller - 00d4 nForce3 SMBus - 00d5 nForce3 IDE - 00d6 nForce3 Ethernet - 00d7 nForce3 USB 1.1 - 00d8 nForce3 USB 2.0 - 00da nForce3 Audio - 00dd nForce3 PCI Bridge - 00df CK8S Ethernet Controller - 00e0 nForce3 250Gb LPC Bridge - 00e1 nForce3 250Gb Host Bridge - 00e2 nForce3 250Gb AGP Host to PCI Bridge - 00e3 CK8S Serial ATA Controller (v2.5) - 00e4 nForce 250Gb PCI System Management - 00e5 CK8S Parallel ATA Controller (v2.5) - 00e6 CK8S Ethernet Controller - 00e7 CK8S USB Controller - 00e8 nForce3 EHCI USB 2.0 Controller - 00ea nForce3 250Gb AC'97 Audio Controller - 00ed nForce3 250Gb PCI-to-PCI Bridge - 00ee CK8S Serial ATA Controller (v2.5) - 00f0 NV40 [GeForce 6800/GeForce 6800 Ultra] - 00f1 NV43 [GeForce 6600/GeForce 6600 GT] - 00f2 NV43 [GeForce 6600 GT] - 00f8 NV45GL [Quadro FX 3400] - 00f9 NV40 [GeForce 6800 Ultra/GeForce 6800 GT] - 1682 2120 GEFORCE 6800 GT PCI-E - 00fa NV36 [GeForce PCX 5750] - 00fb NV35 [GeForce PCX 5900] - 00fc NV37GL [Quadro FX 330/GeForce PCX 5300] - 00fd NV37GL [Quadro FX 330] - 00fe NV38GL [Quadro FX 1300] - 00ff NV18 [GeForce PCX 4300] - 0100 NV10 [GeForce 256 SDR] - 1043 0200 AGP-V6600 SGRAM - 1043 0201 AGP-V6600 SDRAM - 1043 4008 AGP-V6600 SGRAM - 1043 4009 AGP-V6600 SDRAM - 1102 102d CT6941 GeForce 256 - 14af 5022 3D Prophet SE - 0101 NV10DDR [GeForce 256 DDR] - 1043 0202 AGP-V6800 DDR - 1043 400a AGP-V6800 DDR SGRAM - 1043 400b AGP-V6800 DDR SDRAM - 107d 2822 WinFast GeForce 256 - 1102 102e CT6971 GeForce 256 DDR - 14af 5021 3D Prophet DDR-DVI - 0103 NV10GL [Quadro] - 0110 NV11 [GeForce2 MX/MX 400] - 1043 4015 AGP-V7100 Pro - 1043 4031 V7100 Pro with TV output - 10de 0091 Dell OEM GeForce 2 MX 400 - 1462 8817 MSI GeForce2 MX400 Pro32S [MS-8817] - 14af 7102 3D Prophet II MX - 14af 7103 3D Prophet II MX Dual-Display - 0111 NV11DDR [GeForce2 MX 100 DDR/200 DDR] - 0112 NV11 [GeForce2 Go] - 0113 NV11GL [Quadro2 MXR/EX] - 0140 NV43 [MSI NX6600GT-TD128E] - 014f NV43 [GeForce 6200] - 0150 NV15 [GeForce2 GTS/Pro] - 1043 4016 V7700 AGP Video Card - 107d 2840 WinFast GeForce2 GTS with TV output - 107d 2842 WinFast GeForce 2 Pro - 1462 8831 Creative GeForce2 Pro - 0151 NV15DDR [GeForce2 Ti] - 1043 405f V7700Ti - 1462 5506 Creative 3D Blaster Geforce2 Titanium - 0152 NV15BR [GeForce2 Ultra, Bladerunner] - 1048 0c56 GLADIAC Ultra - 0153 NV15GL [Quadro2 Pro] - 0170 NV17 [GeForce4 MX 460] - 0171 NV17 [GeForce4 MX 440] - 10b0 0002 Gainward Pro/600 TV - 1462 8661 G4MX440-VTP - 1462 8730 MX440SES-T (MS-8873) - 147b 8f00 Abit Siluro GeForce4MX440 - 0172 NV17 [GeForce4 MX 420] - 0173 NV17 [GeForce4 MX 440-SE] - 0174 NV17 [GeForce4 440 Go] - 0175 NV17 [GeForce4 420 Go] - 0176 NV17 [GeForce4 420 Go 32M] - 4c53 1090 Cx9 / Vx9 mainboard - 0177 NV17 [GeForce4 460 Go] - 0178 NV17GL [Quadro4 550 XGL] - 0179 NV17 [GeForce4 440 Go 64M] - 10de 0179 GeForce4 MX (Mac) - 017a NV17GL [Quadro4 200/400 NVS] - 017b NV17GL [Quadro4 550 XGL] - 017c NV17GL [Quadro4 550 GoGL] - 017d NV17 [GeForce4 410 Go 16M] - 0181 NV18 [GeForce4 MX 440 AGP 8x] - 1043 806f V9180 Magic - 1462 8880 MS-StarForce GeForce4 MX 440 with AGP8X - 1462 8900 MS-8890 GeForce 4 MX440 AGP8X - 1462 9350 MSI Geforce4 MX T8X with AGP8X - 147b 8f0d Siluro GF4 MX-8X - 0182 NV18 [GeForce4 MX 440SE AGP 8x] - 0183 NV18 [GeForce4 MX 420 AGP 8x] - 0185 NV18 [GeForce4 MX 4000 AGP 8x] - 0186 NV18M [GeForce4 448 Go] - 0187 NV18M [GeForce4 488 Go] - 0188 NV18GL [Quadro4 580 XGL] - 018a NV18GL [Quadro4 NVS AGP 8x] - 018b NV18GL [Quadro4 380 XGL] - 018d NV18M [GeForce4 448 Go] - 01a0 NVCrush11 [GeForce2 MX Integrated Graphics] - 01a4 nForce CPU bridge - 01ab nForce 420 Memory Controller (DDR) - 01ac nForce 220/420 Memory Controller - 01ad nForce 220/420 Memory Controller - 01b0 nForce Audio - 01b1 nForce Audio - 01b2 nForce ISA Bridge - 01b4 nForce PCI System Management - 01b7 nForce AGP to PCI Bridge - 01b8 nForce PCI-to-PCI bridge - 01bc nForce IDE - 01c1 nForce AC'97 Modem Controller - 01c2 nForce USB Controller - 01c3 nForce Ethernet Controller - 01e0 nForce2 AGP (different version?) - 01e8 nForce2 AGP - 01ea nForce2 Memory Controller 0 - 01eb nForce2 Memory Controller 1 - 01ec nForce2 Memory Controller 2 - 01ed nForce2 Memory Controller 3 - 01ee nForce2 Memory Controller 4 - 01ef nForce2 Memory Controller 5 - 01f0 NV18 [GeForce4 MX - nForce GPU] - 0200 NV20 [GeForce3] - 1043 402f AGP-V8200 DDR - 0201 NV20 [GeForce3 Ti 200] - 0202 NV20 [GeForce3 Ti 500] - 1043 405b V8200 T5 - 1545 002f Xtasy 6964 - 0203 NV20DCC [Quadro DCC] - 0240 C51 PCI Express Bridge - 0241 C51 PCI Express Bridge - 0242 C51 PCI Express Bridge - 0243 C51 PCI Express Bridge - 0244 C51 PCI Express Bridge - 0245 C51 PCI Express Bridge - 0246 C51 PCI Express Bridge - 0247 C51 PCI Express Bridge - 0248 C51 PCI Express Bridge - 0249 C51 PCI Express Bridge - 024a C51 PCI Express Bridge - 024b C51 PCI Express Bridge - 024c C51 PCI Express Bridge - 024d C51 PCI Express Bridge - 024e C51 PCI Express Bridge - 024f C51 PCI Express Bridge - 0250 NV25 [GeForce4 Ti 4600] - 0251 NV25 [GeForce4 Ti 4400] - 1043 8023 v8440 GeForce 4 Ti4400 - 0252 NV25 [GeForce4 Ti] - 0253 NV25 [GeForce4 Ti 4200] - 107d 2896 WinFast A250 LE TD (Dual VGA/TV-out/DVI) - 147b 8f09 Siluro (Dual VGA/TV-out/DVI) - 0258 NV25GL [Quadro4 900 XGL] - 0259 NV25GL [Quadro4 750 XGL] - 025b NV25GL [Quadro4 700 XGL] - 0260 MCP51 LPC Bridge - 0261 MCP51 LPC Bridge - 0262 MCP51 LPC Bridge - 0263 MCP51 LPC Bridge - 0264 MCP51 SMBus - 0265 MCP51 IDE - 0266 MCP51 Serial ATA Controller - 0267 MCP51 Serial ATA Controller - 0268 MCP51 Ethernet Controller - 0269 MCP51 Ethernet Controller - 026a MCP51 MCI - 026b MCP51 AC97 Audio Controller - 026c MCP51 High Definition Audio - 026d MCP51 USB Controller - 026e MCP51 USB Controller - 026f MCP51 PCI Bridge - 0270 MCP51 Host Bridge - 0271 MCP51 PMU - 0272 MCP51 Memory Controller 0 - 027e C51 Memory Controller 2 - 027f C51 Memory Controller 3 - 0280 NV28 [GeForce4 Ti 4800] - 0281 NV28 [GeForce4 Ti 4200 AGP 8x] - 0282 NV28 [GeForce4 Ti 4800 SE] - 0286 NV28 [GeForce4 Ti 4200 Go AGP 8x] - 0288 NV28GL [Quadro4 980 XGL] - 0289 NV28GL [Quadro4 780 XGL] - 028c NV28GLM [Quadro4 700 GoGL] - 02f0 C51 Host Bridge - 02f1 C51 Host Bridge - 02f2 C51 Host Bridge - 02f3 C51 Host Bridge - 02f4 C51 Host Bridge - 02f5 C51 Host Bridge - 02f6 C51 Host Bridge - 02f7 C51 Host Bridge - 02f8 C51 Memory Controller 5 - 02f9 C51 Memory Controller 4 - 02fa C51 Memory Controller 0 - 02fb C51 PCI Express Bridge - 02fc C51 PCI Express Bridge - 02fd C51 PCI Express Bridge - 02fe C51 Memory Controller 1 - 02ff C51 Host Bridge - 0300 NV30 [GeForce FX] - 0301 NV30 [GeForce FX 5800 Ultra] - 0302 NV30 [GeForce FX 5800] - 0308 NV30GL [Quadro FX 2000] - 0309 NV30GL [Quadro FX 1000] - 0311 NV31 [GeForce FX 5600 Ultra] - 0312 NV31 [GeForce FX 5600] - 0313 NV31 - 0314 NV31 [GeForce FX 5600XT] - 1043 814a V9560XT/TD - 0316 NV31 - 0317 NV31 - 031a NV31M [GeForce FX Go 5600] - 031b NV31M [GeForce FX Go5650] - 031c NVIDIA Quadro FX 700 Go - 031d NV31 - 031e NV31 - 031f NV31 - 0320 NV34 [GeForce FX 5200] - 0321 NV34 [GeForce FX 5200 Ultra] - 0322 NV34 [GeForce FX 5200] - 1462 9171 MS-8917 (FX5200-T128) - 0323 NV34 [GeForce FX 5200LE] - 0324 NV34M [GeForce FX Go 5200] - 1071 8160 MIM2000 - 0325 NV34M [GeForce FX Go5250] - 0326 NV34 [GeForce FX 5500] - 0327 NV34 [GeForce FX 5100] - 0328 NV34M [GeForce FX Go 5200] - 0329 NV34M [GeForce FX Go5200] - 032a NV34GL [Quadro NVS 280 PCI] - 032b NV34GL [Quadro FX 500/600 PCI] - 032c NV34GLM [GeForce FX Go 5300] - 032d NV34 [GeForce FX Go5100] - 032f NV34 - 0330 NV35 [GeForce FX 5900 Ultra] - 0331 NV35 [GeForce FX 5900] - 1043 8145 V9950GE - 0332 NV35 [GeForce FX 5900XT] - 0333 NV38 [GeForce FX 5950 Ultra] - 0334 NV35 [GeForce FX 5900ZT] - 0338 NV35GL [Quadro FX 3000] - 033f NV35GL [Quadro FX 700] - 0341 NV36.1 [GeForce FX 5700 Ultra] - 0342 NV36.2 [GeForce FX 5700] - 0343 NV36 [GeForce FX 5700LE] - 0344 NV36.4 [GeForce FX 5700VE] - 0345 NV36.5 - 0347 NV36 [GeForce FX Go5700] - 0348 NV36 [GeForce FX Go5700] - 0349 NV36 - 034b NV36 - 034c NV36 [Quadro FX Go1000] - 034e NV36GL [Quadro FX 1100] - 034f NV36GL -10df Emulex Corporation - 1ae5 LP6000 Fibre Channel Host Adapter - 1ae6 LP 8000 Fibre Channel Host Adapter Alternate ID (JX1:2-3, JX2:1-2) - 1ae7 LP 8000 Fibre Channel Host Adapter Alternate ID (JX1:2-3, JX2:2-3) - f005 LP1150e Fibre Channel Host Adapter - f085 LP850 Fibre Channel Host Adapter - f095 LP952 Fibre Channel Host Adapter - f098 LP982 Fibre Channel Host Adapter - f0a5 LP1050 Fibre Channel Host Adapter - f0d5 LP1150 Fibre Channel Host Adapter - f100 LP11000e Fibre Channel Host Adapter - f700 LP7000 Fibre Channel Host Adapter - f701 LP 7000EFibre Channel Host Adapter Alternate ID (JX1:2-3, JX2:1-2) - f800 LP8000 Fibre Channel Host Adapter - f801 LP 8000 Fibre Channel Host Adapter Alternate ID (JX1:2-3, JX2:1-2) - f900 LP9000 Fibre Channel Host Adapter - f901 LP 9000 Fibre Channel Host Adapter Alternate ID (JX1:2-3, JX2:1-2) - f980 LP9802 Fibre Channel Host Adapter - f981 LP 9802 Fibre Channel Host Adapter Alternate ID - f982 LP 9802 Fibre Channel Host Adapter Alternate ID - fa00 LP10000 Fibre Channel Host Adapter - fa01 LP101 Fibre Channel Host Adapter - fd00 LP11000 Fibre Channel Host Adapter -10e0 Integrated Micro Solutions Inc. - 5026 IMS5026/27/28 - 5027 IMS5027 - 5028 IMS5028 - 8849 IMS8849 - 8853 IMS8853 - 9128 IMS9128 [Twin turbo 128] -10e1 Tekram Technology Co.,Ltd. - 0391 TRM-S1040 - 10e1 0391 DC-315U SCSI-3 Host Adapter - 690c DC-690c - dc29 DC-290 -10e2 Aptix Corporation -10e3 Tundra Semiconductor Corp. - 0000 CA91C042 [Universe] - 0860 CA91C860 [QSpan] - 0862 CA91C862A [QSpan-II] - 8260 CA91L8200B [Dual PCI PowerSpan II] - 8261 CA91L8260B [Single PCI PowerSpan II] -10e4 Tandem Computers -10e5 Micro Industries Corporation -10e6 Gainbery Computer Products Inc. -10e7 Vadem -10e8 Applied Micro Circuits Corp. - 1072 INES GPIB-PCI (AMCC5920 based) - 2011 Q-Motion Video Capture/Edit board - 4750 S5930 [Matchmaker] - 5920 S5920 - 8043 LANai4.x [Myrinet LANai interface chip] - 8062 S5933_PARASTATION - 807d S5933 [Matchmaker] - 8088 Kongsberg Spacetec Format Synchronizer - 8089 Kongsberg Spacetec Serial Output Board - 809c S5933_HEPC3 - 80d7 PCI-9112 - 80d9 PCI-9118 - 80da PCI-9812 - 811a PCI-IEEE1355-DS-DE Interface - 814c Fastcom ESCC-PCI (Commtech, Inc.) - 8170 S5933 [Matchmaker] (Chipset Development Tool) -# sold with Roper Scientifc(Photometrics) CoolSnap HQ camera - 81e6 Multimedia video controller - 8291 Fastcom 232/8-PCI (Commtech, Inc.) - 82c4 Fastcom 422/4-PCI (Commtech, Inc.) - 82c5 Fastcom 422/2-PCI (Commtech, Inc.) - 82c6 Fastcom IG422/1-PCI (Commtech, Inc.) - 82c7 Fastcom IG232/2-PCI (Commtech, Inc.) - 82ca Fastcom 232/4-PCI (Commtech, Inc.) - 82db AJA HDNTV HD SDI Framestore - 82e2 Fastcom DIO24H-PCI (Commtech, Inc.) - 8851 S5933 on Innes Corp FM Radio Capture card -10e9 Alps Electric Co., Ltd. -10ea Intergraphics Systems - 1680 IGA-1680 - 1682 IGA-1682 - 1683 IGA-1683 - 2000 CyberPro 2000 - 2010 CyberPro 2000A - 5000 CyberPro 5000 - 5050 CyberPro 5050 - 5202 CyberPro 5202 -# CyberPro5202 Audio Function - 5252 CyberPro5252 -10eb Artists Graphics - 0101 3GA - 8111 Twist3 Frame Grabber -10ec Realtek Semiconductor Co., Ltd. - 8029 RTL-8029(AS) - 10b8 2011 EZ-Card (SMC1208) - 10ec 8029 RTL-8029(AS) - 1113 1208 EN1208 - 1186 0300 DE-528 - 1259 2400 AT-2400 - 8129 RTL-8129 - 10ec 8129 RT8129 Fast Ethernet Adapter - 8138 RT8139 (B/C) Cardbus Fast Ethernet Adapter - 10ec 8138 RT8139 (B/C) Fast Ethernet Adapter - 8139 RTL-8139/8139C/8139C+ - 0357 000a TTP-Monitoring Card V2.0 - 1025 005a TravelMate 290 - 1025 8920 ALN-325 - 1025 8921 ALN-325 - 1071 8160 MIM2000 - 10bd 0320 EP-320X-R - 10ec 8139 RT8139 - 1113 ec01 FNC-0107TX - 1186 1300 DFE-538TX - 1186 1320 SN5200 - 1186 8139 DRN-32TX - 11f6 8139 FN22-3(A) LinxPRO Ethernet Adapter - 1259 2500 AT-2500TX - 1259 2503 AT-2500TX/ACPI - 1429 d010 ND010 - 1432 9130 EN-9130TX - 1436 8139 RT8139 - 1458 e000 GA-7VM400M/7VT600 Motherboard - 146c 1439 FE-1439TX - 1489 6001 GF100TXRII - 1489 6002 GF100TXRA - 149c 139a LFE-8139ATX - 149c 8139 LFE-8139TX - 14cb 0200 LNR-100 Family 10/100 Base-TX Ethernet - 1799 5000 F5D5000 PCI Card/Desktop Network PCI Card - 2646 0001 EtheRx - 8e2e 7000 KF-230TX - 8e2e 7100 KF-230TX/2 - a0a0 0007 ALN-325C - 8169 RTL-8169 Gigabit Ethernet - 1259 c107 CG-LAPCIGT - 1371 434e ProG-2000L - 1458 e000 GA-K8VT800 Pro Motherboard - 1462 702c K8T NEO 2 motherboard - 8180 RTL8180L 802.11b MAC - 8197 SmartLAN56 56K Modem -10ed Ascii Corporation - 7310 V7310 -10ee Xilinx Corporation - 3fc0 RME Digi96 - 3fc1 RME Digi96/8 - 3fc2 RME Digi96/8 Pro - 3fc3 RME Digi96/8 Pad - 3fc4 RME Digi9652 (Hammerfall) - 3fc5 RME Hammerfall DSP - 3fc6 RME Hammerfall DSP MADI - 8381 Ellips Santos Frame Grabber -10ef Racore Computer Products, Inc. - 8154 M815x Token Ring Adapter -10f0 Peritek Corporation -10f1 Tyan Computer -10f2 Achme Computer, Inc. -10f3 Alaris, Inc. -10f4 S-MOS Systems, Inc. -10f5 NKK Corporation - a001 NDR4000 [NR4600 Bridge] -10f6 Creative Electronic Systems SA -10f7 Matsushita Electric Industrial Co., Ltd. -10f8 Altos India Ltd -10f9 PC Direct -10fa Truevision - 000c TARGA 1000 -10fb Thesys Gesellschaft für Mikroelektronik mbH - 186f TH 6255 -10fc I-O Data Device, Inc. -# What's in the cardbus end of a Sony ACR-A01 card, comes with newer Vaio CD-RW drives - 0003 Cardbus IDE Controller - 0005 Cardbus SCSI CBSC II -10fd Soyo Computer, Inc -10fe Fast Multimedia AG -10ff NCube -1100 Jazz Multimedia -1101 Initio Corporation - 1060 INI-A100U2W - 9100 INI-9100/9100W - 9400 INI-940 - 9401 INI-950 - 9500 360P - 9502 Initio INI-9100UW Ultra Wide SCSI Controller INIC-950P chip -1102 Creative Labs - 0002 SB Live! EMU10k1 - 1102 0020 CT4850 SBLive! Value - 1102 0021 CT4620 SBLive! - 1102 002f SBLive! mainboard implementation - 1102 4001 E-mu APS - 1102 8022 CT4780 SBLive! Value - 1102 8023 CT4790 SoundBlaster PCI512 - 1102 8024 CT4760 SBLive! - 1102 8025 SBLive! Mainboard Implementation - 1102 8026 CT4830 SBLive! Value - 1102 8027 CT4832 SBLive! Value - 1102 8028 CT4760 SBLive! OEM version - 1102 8031 CT4831 SBLive! Value - 1102 8040 CT4760 SBLive! - 1102 8051 CT4850 SBLive! Value - 1102 8061 SBLive! Player 5.1 - 1102 8064 SB Live! 5.1 Model SB0100 - 1102 8065 SBLive! 5.1 Digital Model SB0220 - 1102 8067 SBLive! 5.1 eMicro 28028 - 0004 SB Audigy - 1102 0051 SB0090 Audigy Player - 1102 0053 SB0090 Audigy Player/OEM - 1102 0058 SB0090 Audigy Player/OEM - 1102 1007 SB0240 Audigy 2 Platinum 6.1 - 1102 2002 SB Audigy 2 ZS (SB0350) - 0006 [SB Live! Value] EMU10k1X - 0007 SB Audigy LS - 1102 1001 SB0310 Audigy LS - 1102 1002 SB0312 Audigy LS - 1102 1006 SB0410 SBLive! 24-bit - 0008 SB0400 Audigy2 Value - 4001 SB Audigy FireWire Port - 1102 0010 SB Audigy FireWire Port - 7002 SB Live! MIDI/Game Port - 1102 0020 Gameport Joystick - 7003 SB Audigy MIDI/Game port - 1102 0040 SB Audigy MIDI/Game Port - 7004 [SB Live! Value] Input device controller - 7005 SB Audigy LS MIDI/Game port - 1102 1001 SB0310 Audigy LS MIDI/Game port - 1102 1002 SB0312 Audigy LS MIDI/Game port - 8064 SB0100 [SBLive! 5.1 OEM] - 8938 Ectiva EV1938 - 1033 80e5 SlimTower-Jim (NEC) - 1071 7150 Mitac 7150 - 110a 5938 Siemens Scenic Mobile 510PIII - 13bd 100c Ceres-C (Sharp, Intel BX) - 13bd 100d Sharp, Intel Banister - 13bd 100e TwinHead P09S/P09S3 (Sharp) - 13bd f6f1 Marlin (Sharp) - 14ff 0e70 P88TE (TWINHEAD INTERNATIONAL Corp) - 14ff c401 Notebook 9100/9200/2000 (TWINHEAD INTERNATIONAL Corp) - 156d b400 G400 - Geo (AlphaTop (Taiwan)) - 156d b550 G560 (AlphaTop (Taiwan)) - 156d b560 G560 (AlphaTop (Taiwan)) - 156d b700 G700/U700 (AlphaTop (Taiwan)) - 156d b795 G795 (AlphaTop (Taiwan)) - 156d b797 G797 (AlphaTop (Taiwan)) -1103 Triones Technologies, Inc. - 0003 HPT343 - 0004 HPT366/368/370/370A/372/372N - 1103 0001 HPT370A - 1103 0003 HPT343 / HPT345 / HPT363 UDMA33 - 1103 0004 HPT366 UDMA66 (r1) / HPT368 UDMA66 (r2) / HPT370 UDMA100 (r3) / HPT370 UDMA100 RAID (r4) - 1103 0005 HPT370 UDMA100 - 1103 0006 HPT302 - 1103 0007 HPT371 UDMA133 - 1103 0008 HPT374 UDMA/ATA133 RAID Controller - 0005 HPT372A/372N - 0006 HPT302 - 0007 HPT371/371N - 0008 HPT374 - 0009 HPT372N -1104 RasterOps Corp. -1105 Sigma Designs, Inc. - 1105 REALmagic Xcard MPEG 1/2/3/4 DVD Decoder - 8300 REALmagic Hollywood Plus DVD Decoder - 8400 EM840x REALmagic DVD/MPEG-2 Audio/Video Decoder - 8401 EM8401 REALmagic DVD/MPEG-2 A/V Decoder - 8470 EM8470 REALmagic DVD/MPEG-4 A/V Decoder - 8471 EM8471 REALmagic DVD/MPEG-4 A/V Decoder - 8475 EM8475 REALmagic DVD/MPEG-4 A/V Decoder - 8476 EM8476 REALmagic DVD/MPEG-4 A/V Decoder - 8485 EM8485 REALmagic DVD/MPEG-4 A/V Decoder - 8486 EM8486 REALmagic DVD/MPEG-4 A/V Decoder -1106 VIA Technologies, Inc. - 0102 Embedded VIA Ethernet Controller - 0130 VT6305 1394.A Controller - 0305 VT8363/8365 [KT133/KM133] - 1043 8033 A7V Mainboard - 1043 803e A7V-E Mainboard - 1043 8042 A7V133/A7V133-C Mainboard - 147b a401 KT7/KT7-RAID/KT7A/KT7A-RAID Mainboard - 0391 VT8371 [KX133] - 0501 VT8501 [Apollo MVP4] - 0505 VT82C505 -# Shares chip with :0576. The VT82C576M has :1571 instead of :0561. - 0561 VT82C576MV - 0571 VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE - 1019 0985 P6VXA Motherboard - 1019 0a81 L7VTA v1.0 Motherboard (KT400-8235) - 1043 8052 VT8233A Bus Master ATA100/66/33 IDE - 1043 808c A7V8X motherboard - 1043 80a1 A7V8X-X motherboard rev. 1.01 - 1043 80ed A7V600 motherboard - 1106 0571 VT82C586/B/VT82C686/A/B/VT8233/A/C/VT8235 PIPC Bus Master IDE - 1179 0001 Magnia Z310 - 1297 f641 FX41 motherboard - 1458 5002 GA-7VAX Mainboard - 1462 7020 K8T NEO 2 motherboard - 147b 1407 KV8-MAX3 motherboard - 1849 0571 K7VT2 motherboard - 0576 VT82C576 3V [Apollo Master] - 0585 VT82C585VP [Apollo VP1/VPX] - 0586 VT82C586/A/B PCI-to-ISA [Apollo VP] - 1106 0000 MVP3 ISA Bridge - 0595 VT82C595 [Apollo VP2] - 0596 VT82C596 ISA [Mobile South] - 1106 0000 VT82C596/A/B PCI to ISA Bridge - 1458 0596 VT82C596/A/B PCI to ISA Bridge - 0597 VT82C597 [Apollo VP3] - 0598 VT82C598 [Apollo MVP3] - 0601 VT8601 [Apollo ProMedia] - 0605 VT8605 [ProSavage PM133] - 1043 802c CUV4X mainboard - 0680 VT82C680 [Apollo P6] - 0686 VT82C686 [Apollo Super South] - 1019 0985 P6VXA Motherboard - 1043 802c CUV4X mainboard - 1043 8033 A7V Mainboard - 1043 803e A7V-E Mainboard - 1043 8040 A7M266 Mainboard - 1043 8042 A7V133/A7V133-C Mainboard - 1106 0000 VT82C686/A PCI to ISA Bridge - 1106 0686 VT82C686/A PCI to ISA Bridge - 1179 0001 Magnia Z310 - 147b a702 KG7-Lite Mainboard - 0691 VT82C693A/694x [Apollo PRO133x] - 1019 0985 P6VXA Motherboard - 1179 0001 Magnia Z310 - 1458 0691 VT82C691 Apollo Pro System Controller - 0693 VT82C693 [Apollo Pro Plus] - 0698 VT82C693A [Apollo Pro133 AGP] - 0926 VT82C926 [Amazon] - 1000 VT82C570MV - 1106 VT82C570MV - 1571 VT82C576M/VT82C586 - 1595 VT82C595/97 [Apollo VP2/97] - 3022 CLE266 -# This is *not* USB 2.0 as the existing entry suggests - 3038 VT82xxxxx UHCI USB 1.1 Controller - 0925 1234 USB Controller - 1019 0985 P6VXA Motherboard - 1019 0a81 L7VTA v1.0 Motherboard (KT400-8235) - 1043 808c VT6202 USB2.0 4 port controller - 1043 80a1 A7V8X-X motherboard - 1043 80ed A7V600 motherboard - 1179 0001 Magnia Z310 - 1458 5004 GA-7VAX Mainboard - 1462 7020 K8T NEO 2 motherboard - 147b 1407 KV8-MAX3 motherboard - 182d 201d CN-029 USB2.0 4 port PCI Card - 3040 VT82C586B ACPI - 3043 VT86C100A [Rhine] - 10bd 0000 VT86C100A Fast Ethernet Adapter - 1106 0100 VT86C100A Fast Ethernet Adapter - 1186 1400 DFE-530TX rev A - 3044 IEEE 1394 Host Controller - 1025 005a TravelMate 290 - 1458 1000 GA-7VT600-1394 Motherboard - 1462 702d K8T NEO 2 motherboard - 3050 VT82C596 Power Management - 3051 VT82C596 Power Management - 3053 VT6105M [Rhine-III] - 3057 VT82C686 [Apollo Super ACPI] - 1019 0985 P6VXA Motherboard - 1043 8033 A7V Mainboard - 1043 803e A7V-E Mainboard - 1043 8040 A7M266 Mainboard - 1043 8042 A7V133/A7V133-C Mainboard - 1179 0001 Magnia Z310 - 3058 VT82C686 AC97 Audio Controller - 0e11 0097 SoundMax Digital Integrated Audio - 0e11 b194 Soundmax integrated digital audio - 1019 0985 P6VXA Motherboard - 1043 1106 A7V133/A7V133-C Mainboard - 1106 4511 Onboard Audio on EP7KXA - 1458 7600 Onboard Audio - 1462 3091 MS-6309 Onboard Audio - 1462 3300 MS-6330 Onboard Audio - 15dd 7609 Onboard Audio - 3059 VT8233/A/8235/8237 AC97 Audio Controller - 1019 0a81 L7VTA v1.0 Motherboard (KT400-8235) - 1043 8095 A7V8X Motherboard (Realtek ALC650 codec) - 1043 80a1 A7V8X-X Motherboard - 1043 80b0 A7V600/K8V Deluxe motherboard (ADI AD1980 codec [SoundMAX]) - 1106 3059 L7VMM2 Motherboard - 1106 4161 K7VT2 motherboard - 1297 c160 FX41 motherboard (Realtek ALC650 codec) - 1458 a002 GA-7VAX Onboard Audio (Realtek ALC650) - 1462 0080 K8T NEO 2 motherboard - 1462 3800 KT266 onboard audio - 147b 1407 KV8-MAX3 motherboard - 3065 VT6102 [Rhine-II] - 1043 80a1 A7V8X-X Motherboard - 1106 0102 VT6102 [Rhine II] Embeded Ethernet Controller on VT8235 - 1186 1400 DFE-530TX rev A - 1186 1401 DFE-530TX rev B - 13b9 1421 LD-10/100AL PCI Fast Ethernet Adapter (rev.B) -# This hosts more than just the Intel 537 codec, it also hosts PCtel (SIL33) and SmartLink (SIL34) codecs - 3068 AC'97 Modem Controller - 1462 309e MS-6309 Saturn Motherboard - 3074 VT8233 PCI to ISA Bridge - 1043 8052 VT8233A - 3091 VT8633 [Apollo Pro266] - 3099 VT8366/A/7 [Apollo KT266/A/333] - 1043 8064 A7V266-E Mainboard - 1043 807f A7V333 Mainboard - 1849 3099 K7VT2 motherboard - 3101 VT8653 Host Bridge - 3102 VT8662 Host Bridge - 3103 VT8615 Host Bridge - 3104 USB 2.0 - 1019 0a81 L7VTA v1.0 Motherboard (KT400-8235) - 1043 808c A7V8X motherboard - 1043 80a1 A7V8X-X motherboard rev 1.01 - 1043 80ed A7V600 motherboard - 1297 f641 FX41 motherboard - 1458 5004 GA-7VAX Mainboard - 1462 7020 K8T NEO 2 motherboard - 147b 1407 KV8-MAX3 motherboard - 182d 201d CN-029 USB 2.0 4 port PCI Card - 3106 VT6105 [Rhine-III] - 1186 1403 DFE-530TX rev C - 3108 S3 Unichrome Pro VGA Adapter - 3109 VT8233C PCI to ISA Bridge - 3112 VT8361 [KLE133] Host Bridge - 3116 VT8375 [KM266/KL266] Host Bridge - 1297 f641 FX41 motherboard - 3118 S3 Unichrome Pro VGA Adapter - 3119 VT6120/VT6121/VT6122 Gigabit Ethernet Adapter -# found on EPIA M6000/9000 mainboard - 3122 VT8623 [Apollo CLE266] integrated CastleRock graphics -# found on EPIA M6000/9000 mainboard - 3123 VT8623 [Apollo CLE266] - 3128 VT8753 [P4X266 AGP] - 3133 VT3133 Host Bridge - 3147 VT8233A ISA Bridge - 3148 P4M266 Host Bridge - 3149 VIA VT6420 SATA RAID Controller - 1043 80ed A7V600/K8V Deluxe motherboard - 1458 b003 GA-7VM400AM(F) Motherboard - 1462 7020 K8T Neo 2 Motherboard - 147b 1407 KV8-MAX3 motherboard - 3156 P/KN266 Host Bridge -# on ASUS P4P800 - 3164 VT6410 ATA133 RAID controller - 3168 VT8374 P4X400 Host Controller/AGP Bridge - 3177 VT8235 ISA Bridge - 1019 0a81 L7VTA v1.0 Motherboard (KT400-8235) - 1043 808c A7V8X motherboard - 1043 80a1 A7V8X-X motherboard - 1297 f641 FX41 motherboard - 1458 5001 GA-7VAX Mainboard - 1849 3177 K7VT2 motherboard - 3178 ProSavageDDR P4N333 Host Bridge - 3188 VT8385 [K8T800 AGP] Host Bridge - 1043 80a3 K8V Deluxe motherboard - 147b 1407 KV8-MAX3 motherboard - 3189 VT8377 [KT400/KT600 AGP] Host Bridge - 1043 807f A7V8X motherboard - 1458 5000 GA-7VAX Mainboard - 3204 K8M800 - 3205 VT8378 [KM400/A] Chipset Host Bridge - 1458 5000 GA-7VM400M Motherboard - 3218 K8T800M Host Bridge - 3227 VT8237 ISA bridge [KT600/K8T800 South] - 1043 80ed A7V600 motherboard - 1106 3227 DFI KT600-AL Motherboard - 1458 5001 GA-7VT600 Motherboard - 147b 1407 KV8-MAX3 motherboard - 3249 VT6421 IDE RAID Controller - 4149 VIA VT6420 (ATA133) Controller - 5030 VT82C596 ACPI [Apollo PRO] - 6100 VT85C100A [Rhine II] - 7204 K8M800 -# S3 Graphics UniChromeâ„¢ 2D/3D Graphics with motion compensation - 7205 VT8378 [S3 UniChrome] Integrated Video - 1458 d000 Gigabyte GA-7VM400(A)M(F) Motherboard - 8231 VT8231 [PCI-to-ISA Bridge] - 8235 VT8235 ACPI - 8305 VT8363/8365 [KT133/KM133 AGP] - 8391 VT8371 [KX133 AGP] - 8501 VT8501 [Apollo MVP4 AGP] - 8596 VT82C596 [Apollo PRO AGP] - 8597 VT82C597 [Apollo VP3 AGP] - 8598 VT82C598/694x [Apollo MVP3/Pro133x AGP] - 1019 0985 P6VXA Motherboard - 8601 VT8601 [Apollo ProMedia AGP] - 8605 VT8605 [PM133 AGP] - 8691 VT82C691 [Apollo Pro] - 8693 VT82C693 [Apollo Pro Plus] PCI Bridge - b091 VT8633 [Apollo Pro266 AGP] - b099 VT8366/A/7 [Apollo KT266/A/333 AGP] - b101 VT8653 AGP Bridge - b102 VT8362 AGP Bridge - b103 VT8615 AGP Bridge - b112 VT8361 [KLE133] AGP Bridge - b168 VT8235 PCI Bridge - b188 VT8237 PCI bridge [K8T800 South] - 147b 1407 KV8-MAX3 motherboard - b198 VT8237 PCI Bridge -# 32-Bit PCI bus master Ethernet MAC with standard MII interface - d104 VT8237 Integrated Fast Ethernet Controller -1107 Stratus Computers - 0576 VIA VT82C570MV [Apollo] (Wrong vendor ID!) -1108 Proteon, Inc. - 0100 p1690plus_AA - 0101 p1690plus_AB - 0105 P1690Plus - 0108 P1690Plus - 0138 P1690Plus - 0139 P1690Plus - 013c P1690Plus - 013d P1690Plus -1109 Cogent Data Technologies, Inc. - 1400 EM110TX [EX110TX] -110a Siemens Nixdorf AG - 0002 Pirahna 2-port - 0005 Tulip controller, power management, switch extender - 0006 FSC PINC (I/O-APIC) - 0015 FSC Multiprocessor Interrupt Controller - 001d FSC Copernicus Management Controller - 007b FSC Remote Service Controller, mailbox device - 007c FSC Remote Service Controller, shared memory device - 007d FSC Remote Service Controller, SMIC device -# Superfastcom-PCI (Commtech, Inc.) or DSCC4 WAN Adapter - 2102 DSCC4 PEB/PEF 20534 DMA Supported Serial Communication Controller with 4 Channels - 2104 Eicon Diva 2.02 compatible passive ISDN card - 3142 SIMATIC NET CP 5613A1 (Profibus Adapter) - 4021 SIMATIC NET CP 5512 (Profibus and MPI Cardbus Adapter) - 4029 SIMATIC NET CP 5613A2 (Profibus Adapter) - 4942 FPGA I-Bus Tracer for MBD - 6120 SZB6120 -110b Chromatic Research Inc. - 0001 Mpact Media Processor - 0004 Mpact 2 -110c Mini-Max Technology, Inc. -110d Znyx Advanced Systems -110e CPU Technology -110f Ross Technology -1110 Powerhouse Systems - 6037 Firepower Powerized SMP I/O ASIC - 6073 Firepower Powerized SMP I/O ASIC -1111 Santa Cruz Operation -# Also claimed to be RNS or Rockwell International, current PCISIG records list Osicom -1112 Osicom Technologies Inc - 2200 FDDI Adapter - 2300 Fast Ethernet Adapter - 2340 4 Port Fast Ethernet Adapter - 2400 ATM Adapter -1113 Accton Technology Corporation - 1211 SMC2-1211TX - 103c 1207 EN-1207D Fast Ethernet Adapter - 1113 1211 EN-1207D Fast Ethernet Adapter - 1216 EN-1216 Ethernet Adapter - 1113 2242 EN2242 10/100 Ethernet Mini-PCI Card - 111a 1020 SpeedStream 1020 PCI 10/100 Ethernet Adaptor [EN-1207F-TX ?] - 1217 EN-1217 Ethernet Adapter - 5105 10Mbps Network card - 9211 EN-1207D Fast Ethernet Adapter - 1113 9211 EN-1207D Fast Ethernet Adapter - 9511 21x4x DEC-Tulip compatible Fast Ethernet - d301 CPWNA100 (Philips wireless PCMCIA) - ec02 SMC 1244TX v3 -1114 Atmel Corporation - 0506 802.11b Wireless Network Adaptor (at76c506) -1115 3D Labs -1116 Data Translation - 0022 DT3001 - 0023 DT3002 - 0024 DT3003 - 0025 DT3004 - 0026 DT3005 - 0027 DT3001-PGL - 0028 DT3003-PGL -1117 Datacube, Inc - 9500 Max-1C SVGA card - 9501 Max-1C image processing -1118 Berg Electronics -1119 ICP Vortex Computersysteme GmbH - 0000 GDT 6000/6020/6050 - 0001 GDT 6000B/6010 - 0002 GDT 6110/6510 - 0003 GDT 6120/6520 - 0004 GDT 6530 - 0005 GDT 6550 - 0006 GDT 6117/6517 - 0007 GDT 6127/6527 - 0008 GDT 6537 - 0009 GDT 6557/6557-ECC - 000a GDT 6115/6515 - 000b GDT 6125/6525 - 000c GDT 6535 - 000d GDT 6555 - 0010 GDT 6115/6515 - 0011 GDT 6125/6525 - 0012 GDT 6535 - 0013 GDT 6555/6555-ECC - 0100 GDT 6117RP/6517RP - 0101 GDT 6127RP/6527RP - 0102 GDT 6537RP - 0103 GDT 6557RP - 0104 GDT 6111RP/6511RP - 0105 GDT 6121RP/6521RP - 0110 GDT 6117RD/6517RD - 0111 GDT 6127RD/6527RD - 0112 GDT 6537RD - 0113 GDT 6557RD - 0114 GDT 6111RD/6511RD - 0115 GDT 6121RD/6521RD - 0118 GDT 6118RD/6518RD/6618RD - 0119 GDT 6128RD/6528RD/6628RD - 011a GDT 6538RD/6638RD - 011b GDT 6558RD/6658RD - 0120 GDT 6117RP2/6517RP2 - 0121 GDT 6127RP2/6527RP2 - 0122 GDT 6537RP2 - 0123 GDT 6557RP2 - 0124 GDT 6111RP2/6511RP2 - 0125 GDT 6121RP2/6521RP2 - 0136 GDT 6113RS/6513RS - 0137 GDT 6123RS/6523RS - 0138 GDT 6118RS/6518RS/6618RS - 0139 GDT 6128RS/6528RS/6628RS - 013a GDT 6538RS/6638RS - 013b GDT 6558RS/6658RS - 013c GDT 6533RS/6633RS - 013d GDT 6543RS/6643RS - 013e GDT 6553RS/6653RS - 013f GDT 6563RS/6663RS - 0166 GDT 7113RN/7513RN/7613RN - 0167 GDT 7123RN/7523RN/7623RN - 0168 GDT 7118RN/7518RN/7518RN - 0169 GDT 7128RN/7528RN/7628RN - 016a GDT 7538RN/7638RN - 016b GDT 7558RN/7658RN - 016c GDT 7533RN/7633RN - 016d GDT 7543RN/7643RN - 016e GDT 7553RN/7653RN - 016f GDT 7563RN/7663RN - 01d6 GDT 4x13RZ - 01d7 GDT 4x23RZ - 01f6 GDT 8x13RZ - 01f7 GDT 8x23RZ - 01fc GDT 8x33RZ - 01fd GDT 8x43RZ - 01fe GDT 8x53RZ - 01ff GDT 8x63RZ - 0210 GDT 6519RD/6619RD - 0211 GDT 6529RD/6629RD - 0260 GDT 7519RN/7619RN - 0261 GDT 7529RN/7629RN - 02ff GDT MAXRP - 0300 GDT NEWRX -111a Efficient Networks, Inc - 0000 155P-MF1 (FPGA) - 0002 155P-MF1 (ASIC) - 0003 ENI-25P ATM - 111a 0000 ENI-25p Miniport ATM Adapter - 0005 SpeedStream (LANAI) - 111a 0001 ENI-3010 ATM - 111a 0009 ENI-3060 ADSL (VPI=0) - 111a 0101 ENI-3010 ATM - 111a 0109 ENI-3060CO ADSL (VPI=0) - 111a 0809 ENI-3060 ADSL (VPI=0 or 8) - 111a 0909 ENI-3060CO ADSL (VPI=0 or 8) - 111a 0a09 ENI-3060 ADSL (VPI=<0..15>) - 0007 SpeedStream ADSL - 111a 1001 ENI-3061 ADSL [ASIC] - 1203 SpeedStream 1023 Wireless PCI Adapter -111b Teledyne Electronic Systems -111c Tricord Systems Inc. - 0001 Powerbis Bridge -111d Integrated Device Technology, Inc. - 0001 IDT77201/77211 155Mbps ATM SAR Controller [NICStAR] - 0003 IDT77222/77252 155Mbps ATM MICRO ABR SAR Controller - 0004 IDT77V252 155Mbps ATM MICRO ABR SAR Controller - 0005 IDT77V222 155Mbps ATM MICRO ABR SAR Controller -111e Eldec -111f Precision Digital Images - 4a47 Precision MX Video engine interface - 5243 Frame capture bus interface -1120 EMC Corporation -1121 Zilog -1122 Multi-tech Systems, Inc. -1123 Excellent Design, Inc. -1124 Leutron Vision AG -1125 Eurocore -1126 Vigra -1127 FORE Systems Inc - 0200 ForeRunner PCA-200 ATM - 0210 PCA-200PC - 0250 ATM - 0300 ForeRunner PCA-200EPC ATM - 0310 ATM - 0400 ForeRunnerHE ATM Adapter - 1127 0400 ForeRunnerHE ATM -1129 Firmworks -112a Hermes Electronics Company, Ltd. -112b Linotype - Hell AG -112c Zenith Data Systems -112d Ravicad -112e Infomedia Microelectronics Inc. -112f Imaging Technology Inc - 0000 MVC IC-PCI - 0001 MVC IM-PCI Video frame grabber/processor -1130 Computervision -1131 Philips Semiconductors - 1561 USB 1.1 Host Controller - 1562 USB 2.0 Host Controller - 3400 SmartPCI56(UCB1500) 56K Modem - 5400 TriMedia TM1000/1100 - 5402 TriMedia TM-1300 - 1244 0f00 Fritz!Card DSL - 7130 SAA7130 Video Broadcast Decoder - 5168 0138 LiveView FlyVideo 2000 - 7133 SAA713X Audio+video broadcast decoder - 5168 0138 LifeView FlyVideo 3000 - 5168 0212 LifeView FlyTV Platinum mini - 5168 0502 LifeView FlyDVB-T Duo CardBus -# PCI audio and video broadcast decoder (http://www.semiconductors.philips.com/pip/saa7134hl) - 7134 SAA7134 - 1043 4842 TV-FM Card 7134 - 7135 SAA7135 Audio+video broadcast decoder - 7145 SAA7145 - 7146 SAA7146 - 110a 0000 Fujitsu/Siemens DVB-C card rev1.5 - 110a ffff Fujitsu/Siemens DVB-C card rev1.5 - 1131 4f56 KNC1 DVB-S Budget - 1131 4f61 Fujitsu-Siemens Activy DVB-S Budget - 114b 2003 DVRaptor Video Edit/Capture Card - 11bd 0006 DV500 Overlay - 11bd 000a DV500 Overlay - 11bd 000f DV500 Overlay - 13c2 0000 Siemens/Technotrend/Hauppauge DVB card rev1.3 or rev1.5 - 13c2 0001 Technotrend/Hauppauge DVB card rev1.3 or rev1.6 - 13c2 0002 Technotrend/Hauppauge DVB card rev2.1 - 13c2 0003 Technotrend/Hauppauge DVB card rev2.1 - 13c2 0004 Technotrend/Hauppauge DVB card rev2.1 - 13c2 0006 Technotrend/Hauppauge DVB card rev1.3 or rev1.6 - 13c2 0008 Technotrend/Hauppauge DVB-T - 13c2 000a Octal/Technotrend DVB-C for iTV - 13c2 1003 Technotrend-Budget / Hauppauge WinTV-NOVA-S DVB card - 13c2 1004 Technotrend-Budget / Hauppauge WinTV-NOVA-C DVB card - 13c2 1005 Technotrend-Budget / Hauppauge WinTV-NOVA-T DVB card - 13c2 100c Technotrend-Budget / Hauppauge WinTV-NOVA-CI DVB card - 13c2 100f Technotrend-Budget / Hauppauge WinTV-NOVA-CI DVB card - 13c2 1011 Technotrend-Budget / Hauppauge WinTV-NOVA-T DVB card - 13c2 1013 SATELCO Multimedia DVB - 13c2 1102 Technotrend/Hauppauge DVB card rev2.1 -1132 Mitel Corp. -# This is the new official company name. See disclaimer on www.eicon.com for details! -1133 Eicon Networks Corporation - 7901 EiconCard S90 - 7902 EiconCard S90 - 7911 EiconCard S91 - 7912 EiconCard S91 - 7941 EiconCard S94 - 7942 EiconCard S94 - 7943 EiconCard S94 - 7944 EiconCard S94 - b921 EiconCard P92 - b922 EiconCard P92 - b923 EiconCard P92 - e001 Diva Pro 2.0 S/T - e002 Diva 2.0 S/T PCI - e003 Diva Pro 2.0 U - e004 Diva 2.0 U PCI - e005 Diva 2.01 S/T PCI - e006 Diva CT S/T PCI - e007 Diva CT U PCI - e008 Diva CT Lite S/T PCI - e009 Diva CT Lite U PCI - e00a Diva ISDN+V.90 PCI - e00b Diva 2.02 PCI S/T - e00c Diva 2.02 PCI U - e00d Diva ISDN Pro 3.0 PCI - e00e Diva ISDN+CT S/T PCI Rev 2 - e010 Diva Server BRI-2M PCI - 110a 0021 Fujitsu Siemens ISDN S0 - 8001 0014 Diva Server BRI-2M PCI Cornet NQ - e011 Diva Server BRI S/T Rev 2 - e012 Diva Server 4BRI-8M PCI - 8001 0014 Diva Server 4BRI-8M PCI Cornet NQ - e013 Diva Server 4BRI Rev 2 - 1133 1300 Diva Server V-4BRI-8 - 1133 e013 Diva Server 4BRI-8M 2.0 PCI - 8001 0014 Diva Server 4BRI-8M 2.0 PCI Cornet NQ - e014 Diva Server PRI-30M PCI - 0008 0100 Diva Server PRI-30M PCI - 8001 0014 Diva Server PRI-30M PCI Cornet NQ - e015 DIVA Server PRI Rev 2 - 1133 e015 Diva Server PRI 2.0 PCI - 8001 0014 Diva Server PRI 2.0 PCI Cornet NQ - e016 Diva Server Voice 4BRI PCI - 8001 0014 Diva Server PRI Cornet NQ - e017 Diva Server Voice 4BRI Rev 2 - 1133 e017 Diva Server Voice 4BRI-8M 2.0 PCI - 8001 0014 Diva Server Voice 4BRI-8M 2.0 PCI Cornet NQ - e018 Diva Server BRI-2M 2.0 PCI - 1133 1800 Diva Server V-BRI-2 - 1133 e018 Diva Server BRI-2M 2.0 PCI - 8001 0014 Diva Server BRI-2M 2.0 PCI Cornet NQ - e019 Diva Server Voice PRI Rev 2 - 1133 e019 Diva Server Voice PRI 2.0 PCI - 8001 0014 Diva Server Voice PRI 2.0 PCI Cornet NQ - e01a Diva Server 2FX - e01b Diva Server Voice BRI-2M 2.0 PCI - 1133 e01b Diva Server Voice BRI-2M 2.0 PCI - 8001 0014 Diva Server Voice BRI-2M 2.0 PCI Cornet NQ - e01c Diva Server PRI Rev 3 - 1133 1c01 Diva Server PRI/E1/T1-8 - 1133 1c02 Diva Server PRI/T1-24 - 1133 1c03 Diva Server PRI/E1-30 - 1133 1c04 Diva Server PRI/E1/T1 - 1133 1c05 Diva Server V-PRI/T1-24 - 1133 1c06 Diva Server V-PRI/E1-30 - 1133 1c07 Diva Server PRI/E1/T1-8 Cornet NQ - 1133 1c08 Diva Server PRI/T1-24 Cornet NQ - 1133 1c09 Diva Server PRI/E1-30 Cornet NQ - 1133 1c0a Diva Server PRI/E1/T1 Cornet NQ - 1133 1c0b Diva Server V-PRI/T1-24 Cornet NQ - 1133 1c0c Diva Server V-PRI/E1-30 Cornet NQ - e01e Diva Server 2PRI - 1133 1e00 Diva Server V-2PRI/E1-60 - 1133 1e01 Diva Server V-2PRI/T1-48 - 1133 1e02 Diva Server 2PRI/E1-60 - 1133 1e03 Diva Server 2PRI/T1-48 - e020 Diva Server 4PRI - 1133 2000 Diva Server V-4PRI/E1-120 - 1133 2001 Diva Server V-4PRI/T1-96 - 1133 2002 Diva Server 4PRI/E1-120 - 1133 2003 Diva Server 4PRI/T1-96 - e024 Diva Server Analog-4P - 1133 2400 Diva Server V-Analog-4P - 1133 e024 Diva Server Analog-4P - e028 Diva Server Analog-8P - 1133 2800 Diva Server V-Analog-8P - 1133 e028 Diva Server Analog-8P -1134 Mercury Computer Systems - 0001 Raceway Bridge - 0002 Dual PCI to RapidIO Bridge -1135 Fuji Xerox Co Ltd - 0001 Printer controller -1136 Momentum Data Systems -1137 Cisco Systems Inc -1138 Ziatech Corporation - 8905 8905 [STD 32 Bridge] -1139 Dynamic Pictures, Inc - 0001 VGA Compatable 3D Graphics -113a FWB Inc -113b Network Computing Devices -113c Cyclone Microsystems, Inc. - 0000 PCI-9060 i960 Bridge - 0001 PCI-SDK [PCI i960 Evaluation Platform] - 0911 PCI-911 [i960Jx-based Intelligent I/O Controller] - 0912 PCI-912 [i960CF-based Intelligent I/O Controller] - 0913 PCI-913 - 0914 PCI-914 [I/O Controller w/ secondary PCI bus] -113d Leading Edge Products Inc -113e Sanyo Electric Co - Computer Engineering Dept -113f Equinox Systems, Inc. - 0808 SST-64P Adapter - 1010 SST-128P Adapter - 80c0 SST-16P DB Adapter - 80c4 SST-16P RJ Adapter - 80c8 SST-16P Adapter - 8888 SST-4P Adapter - 9090 SST-8P Adapter -1140 Intervoice Inc -1141 Crest Microsystem Inc -1142 Alliance Semiconductor Corporation - 3210 AP6410 - 6422 ProVideo 6422 - 6424 ProVideo 6424 - 6425 ProMotion AT25 - 643d ProMotion AT3D -1143 NetPower, Inc -1144 Cincinnati Milacron - 0001 Noservo controller -1145 Workbit Corporation - 8007 NinjaSCSI-32 Workbit - f007 NinjaSCSI-32 KME - f010 NinjaSCSI-32 Workbit - f012 NinjaSCSI-32 Logitec - f013 NinjaSCSI-32 Logitec - f015 NinjaSCSI-32 Melco -1146 Force Computers -1147 Interface Corp -# Formerly (Schneider & Koch) -1148 SysKonnect - 4000 FDDI Adapter - 0e11 b03b Netelligent 100 FDDI DAS Fibre SC - 0e11 b03c Netelligent 100 FDDI SAS Fibre SC - 0e11 b03d Netelligent 100 FDDI DAS UTP - 0e11 b03e Netelligent 100 FDDI SAS UTP - 0e11 b03f Netelligent 100 FDDI SAS Fibre MIC - 1148 5521 FDDI SK-5521 (SK-NET FDDI-UP) - 1148 5522 FDDI SK-5522 (SK-NET FDDI-UP DAS) - 1148 5541 FDDI SK-5541 (SK-NET FDDI-FP) - 1148 5543 FDDI SK-5543 (SK-NET FDDI-LP) - 1148 5544 FDDI SK-5544 (SK-NET FDDI-LP DAS) - 1148 5821 FDDI SK-5821 (SK-NET FDDI-UP64) - 1148 5822 FDDI SK-5822 (SK-NET FDDI-UP64 DAS) - 1148 5841 FDDI SK-5841 (SK-NET FDDI-FP64) - 1148 5843 FDDI SK-5843 (SK-NET FDDI-LP64) - 1148 5844 FDDI SK-5844 (SK-NET FDDI-LP64 DAS) - 4200 Token Ring adapter - 4300 SK-98xx Gigabit Ethernet Server Adapter - 1148 9821 SK-9821 Gigabit Ethernet Server Adapter (SK-NET GE-T) - 1148 9822 SK-9822 Gigabit Ethernet Server Adapter (SK-NET GE-T dual link) - 1148 9841 SK-9841 Gigabit Ethernet Server Adapter (SK-NET GE-LX) - 1148 9842 SK-9842 Gigabit Ethernet Server Adapter (SK-NET GE-LX dual link) - 1148 9843 SK-9843 Gigabit Ethernet Server Adapter (SK-NET GE-SX) - 1148 9844 SK-9844 Gigabit Ethernet Server Adapter (SK-NET GE-SX dual link) - 1148 9861 SK-9861 Gigabit Ethernet Server Adapter (SK-NET GE-SX Volition) - 1148 9862 SK-9862 Gigabit Ethernet Server Adapter (SK-NET GE-SX Volition dual link) - 1148 9871 SK-9871 Gigabit Ethernet Server Adapter (SK-NET GE-ZX) - 1148 9872 SK-9872 Gigabit Ethernet Server Adapter (SK-NET GE-ZX dual link) - 1259 2970 AT-2970SX Gigabit Ethernet Adapter - 1259 2971 AT-2970LX Gigabit Ethernet Adapter - 1259 2972 AT-2970TX Gigabit Ethernet Adapter - 1259 2973 AT-2971SX Gigabit Ethernet Adapter - 1259 2974 AT-2971T Gigabit Ethernet Adapter - 1259 2975 AT-2970SX/2SC Gigabit Ethernet Adapter - 1259 2976 AT-2970LX/2SC Gigabit Ethernet Adapter - 1259 2977 AT-2970TX/2TX Gigabit Ethernet Adapter - 4320 SK-98xx V2.0 Gigabit Ethernet Adapter - 1148 0121 Marvell RDK-8001 Adapter - 1148 0221 Marvell RDK-8002 Adapter - 1148 0321 Marvell RDK-8003 Adapter - 1148 0421 Marvell RDK-8004 Adapter - 1148 0621 Marvell RDK-8006 Adapter - 1148 0721 Marvell RDK-8007 Adapter - 1148 0821 Marvell RDK-8008 Adapter - 1148 0921 Marvell RDK-8009 Adapter - 1148 1121 Marvell RDK-8011 Adapter - 1148 1221 Marvell RDK-8012 Adapter - 1148 3221 SK-9521 V2.0 10/100/1000Base-T Adapter - 1148 5021 SK-9821 V2.0 Gigabit Ethernet 10/100/1000Base-T Adapter - 1148 5041 SK-9841 V2.0 Gigabit Ethernet 1000Base-LX Adapter - 1148 5043 SK-9843 V2.0 Gigabit Ethernet 1000Base-SX Adapter - 1148 5051 SK-9851 V2.0 Gigabit Ethernet 1000Base-SX Adapter - 1148 5061 SK-9861 V2.0 Gigabit Ethernet 1000Base-SX Adapter - 1148 5071 SK-9871 V2.0 Gigabit Ethernet 1000Base-ZX Adapter - 1148 9521 SK-9521 10/100/1000Base-T Adapter - 4400 SK-9Dxx Gigabit Ethernet Adapter - 4500 SK-9Mxx Gigabit Ethernet Adapter - 9000 SK-9Sxx Gigabit Ethernet Server Adapter PCI-X - 9843 [Fujitsu] Gigabit Ethernet - 9e00 SK-9Exx 10/100/1000Base-T Adapter - 1148 2100 SK-9E21 Server Adapter - 1148 21d0 SK-9E21D 10/100/1000Base-T Adapter - 1148 2200 SK-9E22 Server Adapter - 1148 8100 SK-9E81 Server Adapter - 1148 8200 SK-9E82 Server Adapter - 1148 9100 SK-9E91 Server Adapter - 1148 9200 SK-9E92 Server Adapter -1149 Win System Corporation -114a VMIC - 5579 VMIPCI-5579 (Reflective Memory Card) - 5587 VMIPCI-5587 (Reflective Memory Card) - 6504 VMIC PCI 7755 FPGA - 7587 VMIVME-7587 -114b Canopus Co., Ltd -114c Annabooks -114d IC Corporation -114e Nikon Systems Inc -114f Digi International - 0002 AccelePort EPC - 0003 RightSwitch SE-6 - 0004 AccelePort Xem - 0005 AccelePort Xr - 0006 AccelePort Xr,C/X - 0009 AccelePort Xr/J - 000a AccelePort EPC/J - 000c DataFirePRIme T1 (1-port) - 000d SyncPort 2-Port (x.25/FR) - 0011 AccelePort 8r EIA-232 (IBM) - 0012 AccelePort 8r EIA-422 - 0013 AccelePort Xr - 0014 AccelePort 8r EIA-422 - 0015 AccelePort Xem - 0016 AccelePort EPC/X - 0017 AccelePort C/X - 001a DataFirePRIme E1 (1-port) - 001b AccelePort C/X (IBM) - 001d DataFire RAS T1/E1/PRI - 114f 0050 DataFire RAS E1 Adapter - 114f 0051 DataFire RAS Dual E1 Adapter - 114f 0052 DataFire RAS T1 Adapter - 114f 0053 DataFire RAS Dual T1 Adapter - 0023 AccelePort RAS - 0024 DataFire RAS B4 ST/U - 114f 0030 DataFire RAS BRI U Adapter - 114f 0031 DataFire RAS BRI S/T Adapter - 0026 AccelePort 4r 920 - 0027 AccelePort Xr 920 - 0028 ClassicBoard 4 - 0029 ClassicBoard 8 - 0034 AccelePort 2r 920 - 0035 DataFire DSP T1/E1/PRI cPCI - 0040 AccelePort Xp - 0042 AccelePort 2p - 0043 AccelePort 4p - 0044 AccelePort 8p - 0045 AccelePort 16p - 004e AccelePort 32p - 0070 Datafire Micro V IOM2 (Europe) - 0071 Datafire Micro V (Europe) - 0072 Datafire Micro V IOM2 (North America) - 0073 Datafire Micro V (North America) - 00b0 Digi Neo 4 - 00b1 Digi Neo 8 - 00c8 Digi Neo 2 DB9 - 00c9 Digi Neo 2 DB9 PRI - 00ca Digi Neo 2 RJ45 - 00cb Digi Neo 2 RJ45 PRI - 00d0 ClassicBoard 4 422 - 00d1 ClassicBoard 8 422 - 6001 Avanstar -1150 Thinking Machines Corp -1151 JAE Electronics Inc. -1152 Megatek -1153 Land Win Electronic Corp -1154 Melco Inc -1155 Pine Technology Ltd -1156 Periscope Engineering -1157 Avsys Corporation -1158 Voarx R & D Inc - 3011 Tokenet/vg 1001/10m anylan - 9050 Lanfleet/Truevalue - 9051 Lanfleet/Truevalue -1159 Mutech Corp - 0001 MV-1000 -115a Harlequin Ltd -115b Parallax Graphics -115c Photron Ltd. -115d Xircom - 0003 Cardbus Ethernet 10/100 - 1014 0181 10/100 EtherJet Cardbus Adapter - 1014 1181 10/100 EtherJet Cardbus Adapter - 1014 8181 10/100 EtherJet Cardbus Adapter - 1014 9181 10/100 EtherJet Cardbus Adapter - 115d 0181 Cardbus Ethernet 10/100 - 115d 1181 Cardbus Ethernet 10/100 - 1179 0181 Cardbus Ethernet 10/100 - 8086 8181 EtherExpress PRO/100 Mobile CardBus 32 Adapter - 8086 9181 EtherExpress PRO/100 Mobile CardBus 32 Adapter - 0005 Cardbus Ethernet 10/100 - 1014 0182 10/100 EtherJet Cardbus Adapter - 1014 1182 10/100 EtherJet Cardbus Adapter - 115d 0182 Cardbus Ethernet 10/100 - 115d 1182 Cardbus Ethernet 10/100 - 0007 Cardbus Ethernet 10/100 - 1014 0182 10/100 EtherJet Cardbus Adapter - 1014 1182 10/100 EtherJet Cardbus Adapter - 115d 0182 Cardbus Ethernet 10/100 - 115d 1182 Cardbus Ethernet 10/100 - 000b Cardbus Ethernet 10/100 - 1014 0183 10/100 EtherJet Cardbus Adapter - 115d 0183 Cardbus Ethernet 10/100 - 000c Mini-PCI V.90 56k Modem - 000f Cardbus Ethernet 10/100 - 1014 0183 10/100 EtherJet Cardbus Adapter - 115d 0183 Cardbus Ethernet 10/100 - 00d4 Mini-PCI K56Flex Modem - 0101 Cardbus 56k modem - 115d 1081 Cardbus 56k Modem - 0103 Cardbus Ethernet + 56k Modem - 1014 9181 Cardbus 56k Modem - 1115 1181 Cardbus Ethernet 100 + 56k Modem - 115d 1181 CBEM56G-100 Ethernet + 56k Modem - 8086 9181 PRO/100 LAN + Modem56 CardBus -115e Peer Protocols Inc -115f Maxtor Corporation -1160 Megasoft Inc -1161 PFU Limited -1162 OA Laboratory Co Ltd -1163 Rendition - 0001 Verite 1000 - 2000 Verite V2000/V2100/V2200 - 1092 2000 Stealth II S220 -1164 Advanced Peripherals Technologies -1165 Imagraph Corporation - 0001 Motion TPEG Recorder/Player with audio -1166 ServerWorks - 0000 CMIC-LE - 0005 CNB20-LE Host Bridge - 0006 CNB20HE Host Bridge - 0007 CNB20-LE Host Bridge - 0008 CNB20HE Host Bridge - 0009 CNB20LE Host Bridge - 0010 CIOB30 - 0011 CMIC-HE - 0012 CMIC-WS Host Bridge (GC-LE chipset) - 0013 CNB20-HE Host Bridge - 0014 CMIC-LE Host Bridge (GC-LE chipset) - 0015 CMIC-GC Host Bridge - 0016 CMIC-GC Host Bridge - 0017 GCNB-LE Host Bridge - 0101 CIOB-X2 PCI-X I/O Bridge - 0110 CIOB-E I/O Bridge with Gigabit Ethernet - 0200 OSB4 South Bridge - 0201 CSB5 South Bridge - 4c53 1080 CT8 mainboard - 0203 CSB6 South Bridge - 0211 OSB4 IDE Controller - 0212 CSB5 IDE Controller - 4c53 1080 CT8 mainboard - 0213 CSB6 RAID/IDE Controller - 0217 CSB6 IDE Controller - 0220 OSB4/CSB5 OHCI USB Controller - 4c53 1080 CT8 mainboard - 0221 CSB6 OHCI USB Controller - 0225 CSB5 LPC bridge -# cancelled - 4c53 1080 CT8 mainboard - 0227 GCLE-2 Host Bridge - 0230 CSB5 LPC bridge - 4c53 1080 CT8 mainboard - 0240 K2 SATA - 0241 K2 SATA - 0242 K2 SATA -1167 Mutoh Industries Inc -1168 Thine Electronics Inc -1169 Centre for Development of Advanced Computing -116a Polaris Communications - 6100 Bus/Tag Channel - 6800 Escon Channel - 7100 Bus/Tag Channel - 7800 Escon Channel -116b Connectware Inc -116c Intelligent Resources Integrated Systems -116d Martin-Marietta -116e Electronics for Imaging -116f Workstation Technology -1170 Inventec Corporation -1171 Loughborough Sound Images Plc -1172 Altera Corporation -1173 Adobe Systems, Inc -1174 Bridgeport Machines -1175 Mitron Computer Inc. -1176 SBE Incorporated -1177 Silicon Engineering -1178 Alfa, Inc. - afa1 Fast Ethernet Adapter -1179 Toshiba America Info Systems - 0103 EX-IDE Type-B - 0404 DVD Decoder card - 0406 Tecra Video Capture device - 0407 DVD Decoder card (Version 2) - 0601 CPU to PCI bridge - 0603 ToPIC95 PCI to CardBus Bridge for Notebooks - 060a ToPIC95 - 060f ToPIC97 - 0617 ToPIC100 PCI to Cardbus Bridge with ZV Support - 0618 CPU to PCI and PCI to ISA bridge -# Claimed to be Lucent DSP1645 [Mars], but that's apparently incorrect. Does anyone know the correct ID? - 0701 FIR Port - 0804 TC6371AF SmartMedia Controller - 0805 SD TypA Controller - 0d01 FIR Port Type-DO - 1179 0001 FIR Port Type-DO -117a A-Trend Technology -117b L G Electronics, Inc. -117c Atto Technology -117d Becton & Dickinson -117e T/R Systems -117f Integrated Circuit Systems -1180 Ricoh Co Ltd - 0465 RL5c465 - 0466 RL5c466 - 0475 RL5c475 - 144d c006 vpr Matrix 170B4 CardBus bridge - 0476 RL5c476 II - 1014 0185 ThinkPad A/T/X Series - 104d 80df Vaio PCG-FX403 - 104d 80e7 VAIO PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP - 14ef 0220 PCD-RP-220S - 0477 RL5c477 - 0478 RL5c478 - 1014 0184 ThinkPad A30p (2653-64G) - 0522 R5C522 IEEE 1394 Controller - 1014 01cf ThinkPad A30p (2653-64G) - 0551 R5C551 IEEE 1394 Controller - 144d c006 vpr Matrix 170B4 - 0552 R5C552 IEEE 1394 Controller - 1014 0511 ThinkPad A/T/X Series - 0576 R5C576 SD Bus Host Adapter - 0592 R5C592 Memory Stick Bus Host Adapter -1181 Telmatics International -1183 Fujikura Ltd -1184 Forks Inc -1185 Dataworld International Ltd -1186 D-Link System Inc - 0100 DC21041 - 1002 DL10050 Sundance Ethernet - 1186 1002 DFE-550TX - 1186 1012 DFE-580TX - 1025 AirPlus Xtreme G DWL-G650 Adapter - 1026 AirXpert DWL-AG650 Wireless Cardbus Adapter - 1043 AirXpert DWL-AG650 Wireless Cardbus Adapter - 1300 RTL8139 Ethernet - 1186 1300 DFE-538TX 10/100 Ethernet Adapter - 1186 1301 DFE-530TX+ 10/100 Ethernet Adapter - 1340 DFE-690TXD CardBus PC Card - 1541 DFE-680TXD CardBus PC Card - 1561 DRP-32TXD Cardbus PC Card - 2027 AirPlus Xtreme G DWL-G520 Adapter - 3203 AirPlus Xtreme G DWL-G520 Adapter - 3300 DWL-510 2.4GHz Wireless PCI Adapter - 3a03 AirPro DWL-A650 Wireless Cardbus Adapter(rev.B) - 3a04 AirPro DWL-AB650 Multimode Wireless Cardbus Adapter - 3a05 AirPro DWL-AB520 Multimode Wireless PCI Adapter - 3a07 AirXpert DWL-AG650 Wireless Cardbus Adapter - 3a08 AirXpert DWL-AG520 Wireless PCI Adapter - 3a10 AirXpert DWL-AG650 Wireless Cardbus Adapter(rev.B) - 3a11 AirXpert DWL-AG520 Wireless PCI Adapter(rev.B) - 3a12 AirPlus DWL-G650 Wireless Cardbus Adapter(rev.C) - 3a13 AirPlus DWL-G520 Wireless PCI Adapter(rev.B) - 3a14 AirPremier DWL-AG530 Wireless PCI Adapter - 3a63 AirXpert DWL-AG660 Wireless Cardbus Adapter - 3b05 DWL-G650+ CardBus PC Card - 4000 DL2000-based Gigabit Ethernet - 4300 DGE-528T Gigabit Ethernet Adapter - 4c00 Gigabit Ethernet Adapter - 1186 4c00 DGE-530T Gigabit Ethernet Adapter - 8400 D-Link DWL-650+ CardBus PC Card -1187 Advanced Technology Laboratories, Inc. -1188 Shima Seiki Manufacturing Ltd. -1189 Matsushita Electronics Co Ltd -118a Hilevel Technology -118b Hypertec Pty Limited -118c Corollary, Inc - 0014 PCIB [C-bus II to PCI bus host bridge chip] - 1117 Intel 8-way XEON Profusion Chipset [Cache Coherency Filter] -118d BitFlow Inc - 0001 Raptor-PCI framegrabber - 0012 Model 12 Road Runner Frame Grabber - 0014 Model 14 Road Runner Frame Grabber - 0024 Model 24 Road Runner Frame Grabber - 0044 Model 44 Road Runner Frame Grabber - 0112 Model 12 Road Runner Frame Grabber - 0114 Model 14 Road Runner Frame Grabber - 0124 Model 24 Road Runner Frame Grabber - 0144 Model 44 Road Runner Frame Grabber - 0212 Model 12 Road Runner Frame Grabber - 0214 Model 14 Road Runner Frame Grabber - 0224 Model 24 Road Runner Frame Grabber - 0244 Model 44 Road Runner Frame Grabber - 0312 Model 12 Road Runner Frame Grabber - 0314 Model 14 Road Runner Frame Grabber - 0324 Model 24 Road Runner Frame Grabber - 0344 Model 44 Road Runner Frame Grabber -118e Hermstedt GmbH -118f Green Logic -1190 Tripace - c731 TP-910/920/940 PCI Ultra(Wide) SCSI Adapter -1191 Artop Electronic Corp - 0003 SCSI Cache Host Adapter - 0004 ATP8400 - 0005 ATP850UF - 0006 ATP860 NO-BIOS - 0007 ATP860 - 0008 ATP865 NO-ROM - 0009 ATP865 - 8002 AEC6710 SCSI-2 Host Adapter - 8010 AEC6712UW SCSI - 8020 AEC6712U SCSI - 8030 AEC6712S SCSI - 8040 AEC6712D SCSI - 8050 AEC6712SUW SCSI - 8060 AEC6712 SCSI - 8080 AEC67160 SCSI - 8081 AEC67160S SCSI - 808a AEC67162 2-ch. LVD SCSI -1192 Densan Company Ltd -1193 Zeitnet Inc. - 0001 1221 - 0002 1225 -1194 Toucan Technology -1195 Ratoc System Inc -1196 Hytec Electronics Ltd -1197 Gage Applied Sciences, Inc. - 010c CompuScope 82G 8bit 2GS/s Analog Input Card -1198 Lambda Systems Inc -1199 Attachmate Corporation -119a Mind Share, Inc. -119b Omega Micro Inc. - 1221 82C092G -119c Information Technology Inst. -119d Bug, Inc. Sapporo Japan -119e Fujitsu Microelectronics Ltd. - 0001 FireStream 155 - 0003 FireStream 50 -119f Bull HN Information Systems -11a0 Convex Computer Corporation -11a1 Hamamatsu Photonics K.K. -11a2 Sierra Research and Technology -11a3 Deuretzbacher GmbH & Co. Eng. KG -11a4 Barco Graphics NV -11a5 Microunity Systems Eng. Inc -11a6 Pure Data Ltd. -11a7 Power Computing Corp. -11a8 Systech Corp. -11a9 InnoSys Inc. - 4240 AMCC S933Q Intelligent Serial Card -11aa Actel -# Formerly Galileo Technology, Inc. -11ab Marvell Technology Group Ltd. - 0146 GT-64010/64010A System Controller - 138f W8300 802.11 Adapter (rev 07) - 1fa6 Marvell W8300 802.11 Adapter - 1fa7 88W8310 and 88W8000G [Libertas] 802.11g client chipset - 4320 Gigabit Ethernet Controller - 1019 0f38 Marvell 88E8001 Gigabit Ethernet Controller (ECS) - 1019 8001 Marvell 88E8001 Gigabit Ethernet Controller (ECS) - 1043 173c Marvell 88E8001 Gigabit Ethernet Controller (Asus) - 1043 811a Marvell 88E8001 Gigabit Ethernet Controller (Asus) - 105b 0c19 Marvell 88E8001 Gigabit Ethernet Controller (Foxconn) - 10b8 b452 SMC EZ Card 1000 (SMC9452TXV.2) - 11ab 0121 Marvell RDK-8001 - 11ab 0321 Marvell RDK-8003 - 11ab 1021 Marvell RDK-8010 - 11ab 5021 Marvell Yukon Gigabit Ethernet 10/100/1000Base-T Controller (64 bit) - 11ab 9521 Marvell Yukon Gigabit Ethernet 10/100/1000Base-T Controller (32 bit) - 1458 e000 Marvell 88E8001 Gigabit Ethernet Controller (Gigabyte) - 147b 1406 Marvell 88E8001 Gigabit Ethernet Controller (Abit) - 15d4 0047 Marvell 88E8001 Gigabit Ethernet Controller (Iwill) - 1695 9025 Marvell 88E8001 Gigabit Ethernet Controller (Epox) - 17f2 1c03 Marvell 88E8001 Gigabit Ethernet Controller (Albatron) - 270f 2803 Marvell 88E8001 Gigabit Ethernet Controller (Chaintech) - 4350 Fast Ethernet Controller - 1179 0001 Marvell 88E8035 Fast Ethernet Controller (Toshiba) - 11ab 3521 Marvell RDK-8035 - 1854 000d Marvell 88E8035 Fast Ethernet Controller (LGE) - 1854 000e Marvell 88E8035 Fast Ethernet Controller (LGE) - 1854 000f Marvell 88E8035 Fast Ethernet Controller (LGE) - 1854 0011 Marvell 88E8035 Fast Ethernet Controller (LGE) - 1854 0012 Marvell 88E8035 Fast Ethernet Controller (LGE) - 1854 0016 Marvell 88E8035 Fast Ethernet Controller (LGE) - 1854 0017 Marvell 88E8035 Fast Ethernet Controller (LGE) - 1854 0018 Marvell 88E8035 Fast Ethernet Controller (LGE) - 1854 0019 Marvell 88E8035 Fast Ethernet Controller (LGE) - 1854 001c Marvell 88E8035 Fast Ethernet Controller (LGE) - 1854 001e Marvell 88E8035 Fast Ethernet Controller (LGE) - 1854 0020 Marvell 88E8035 Fast Ethernet Controller (LGE) - 4351 Fast Ethernet Controller - 107b 4009 Marvell 88E8036 Fast Ethernet Controller (Wistron) - 10f7 8338 Marvell 88E8036 Fast Ethernet Controller (Panasonic) - 1179 0001 Marvell 88E8036 Fast Ethernet Controller (Toshiba) - 1179 ff00 Marvell 88E8036 Fast Ethernet Controller (Compal) - 1179 ff10 Marvell 88E8036 Fast Ethernet Controller (Inventec) - 11ab 3621 Marvell RDK-8036 - 13d1 ac12 Abocom EFE3K - 10/100 Ethernet Expresscard - 161f 203d Marvell 88E8036 Fast Ethernet Controller (Arima) - 1854 000d Marvell 88E8036 Fast Ethernet Controller (LGE) - 1854 000e Marvell 88E8036 Fast Ethernet Controller (LGE) - 1854 000f Marvell 88E8036 Fast Ethernet Controller (LGE) - 1854 0011 Marvell 88E8036 Fast Ethernet Controller (LGE) - 1854 0012 Marvell 88E8036 Fast Ethernet Controller (LGE) - 1854 0016 Marvell 88E8036 Fast Ethernet Controller (LGE) - 1854 0017 Marvell 88E8036 Fast Ethernet Controller (LGE) - 1854 0018 Marvell 88E8036 Fast Ethernet Controller (LGE) - 1854 0019 Marvell 88E8036 Fast Ethernet Controller (LGE) - 1854 001c Marvell 88E8036 Fast Ethernet Controller (LGE) - 1854 001e Marvell 88E8036 Fast Ethernet Controller (LGE) - 1854 0020 Marvell 88E8036 Fast Ethernet Controller (LGE) - 4360 Gigabit Ethernet Controller - 1043 8134 Marvell 88E8052 Gigabit Ethernet Controller (Asus) - 107b 4009 Marvell 88E8052 Gigabit Ethernet Controller (Wistron) - 11ab 5221 Marvell RDK-8052 - 1458 e000 Marvell 88E8052 Gigabit Ethernet Controller (Gigabyte) - 1462 052c Marvell 88E8052 Gigabit Ethernet Controller (MSI) - 1849 8052 Marvell 88E8052 Gigabit Ethernet Controller (ASRock) - 1940 e000 Marvell 88E8052 Gigabit Ethernet Controller (Gigabyte) - a0a0 0509 Marvell 88E8052 Gigabit Ethernet Controller (Aopen) - 4361 Gigabit Ethernet Controller - 107b 3015 Marvell 88E8050 Gigabit Ethernet Controller (Gateway) - 11ab 5021 Marvell 88E8050 Gigabit Ethernet Controller (Intel) - 8086 3063 D925XCVLK mainboard - 4362 Gigabit Ethernet Controller - 103c 2a0d Marvell 88E8053 Gigabit Ethernet Controller (Asus) - 1043 8142 Marvell 88E8053 Gigabit Ethernet Controller (Asus) - 109f 3197 Marvell 88E8053 Gigabit Ethernet Controller (Trigem) - 10f7 8338 Marvell 88E8053 Gigabit Ethernet Controller (Panasonic) - 10fd a430 Marvell 88E8053 Gigabit Ethernet Controller (SOYO) - 1179 0001 Marvell 88E8053 Gigabit Ethernet Controller (Toshiba) - 1179 ff00 Marvell 88E8053 Gigabit Ethernet Controller (Compal) - 1179 ff10 Marvell 88E8053 Gigabit Ethernet Controller (Inventec) - 11ab 5321 Marvell RDK-8053 - 1297 c240 Marvell 88E8053 Gigabit Ethernet Controller (Shuttle) - 1297 c241 Marvell 88E8053 Gigabit Ethernet Controller (Shuttle) - 1297 c242 Marvell 88E8053 Gigabit Ethernet Controller (Shuttle) - 1297 c243 Marvell 88E8053 Gigabit Ethernet Controller (Shuttle) - 1297 c244 Marvell 88E8053 Gigabit Ethernet Controller (Shuttle) - 13d1 ac11 Abocom EGE5K - Giga Ethernet Expresscard - 1458 e000 Marvell 88E8053 Gigabit Ethernet Controller (Gigabyte) - 1462 058c Marvell 88E8053 Gigabit Ethernet Controller (MSI) - 14c0 0012 Marvell 88E8053 Gigabit Ethernet Controller (Compal) - 1558 04a0 Marvell 88E8053 Gigabit Ethernet Controller (Clevo) - 15bd 1003 Marvell 88E8053 Gigabit Ethernet Controller (DFI) - 161f 203c Marvell 88E8053 Gigabit Ethernet Controller (Arima) - 161f 203d Marvell 88E8053 Gigabit Ethernet Controller (Arima) - 1695 9029 Marvell 88E8053 Gigabit Ethernet Controller (Epox) - 17f2 2c08 Marvell 88E8053 Gigabit Ethernet Controller (Albatron) - 17ff 0585 Marvell 88E8053 Gigabit Ethernet Controller (Quanta) - 1849 8053 Marvell 88E8053 Gigabit Ethernet Controller (ASRock) - 1854 000b Marvell 88E8053 Gigabit Ethernet Controller (LGE) - 1854 000c Marvell 88E8053 Gigabit Ethernet Controller (LGE) - 1854 0010 Marvell 88E8053 Gigabit Ethernet Controller (LGE) - 1854 0013 Marvell 88E8053 Gigabit Ethernet Controller (LGE) - 1854 0014 Marvell 88E8053 Gigabit Ethernet Controller (LGE) - 1854 0015 Marvell 88E8053 Gigabit Ethernet Controller (LGE) - 1854 001a Marvell 88E8053 Gigabit Ethernet Controller (LGE) - 1854 001b Marvell 88E8053 Gigabit Ethernet Controller (LGE) - 1854 001d Marvell 88E8053 Gigabit Ethernet Controller (LGE) - 1854 001f Marvell 88E8053 Gigabit Ethernet Controller (LGE) - 1854 0021 Marvell 88E8053 Gigabit Ethernet Controller (LGE) - 1854 0022 Marvell 88E8053 Gigabit Ethernet Controller (LGE) - 1940 e000 Marvell 88E8053 Gigabit Ethernet Controller (Gigabyte) - 270f 2801 Marvell 88E8053 Gigabit Ethernet Controller (Chaintech) - a0a0 0506 Marvell 88E8053 Gigabit Ethernet Controller (Aopen) - 4611 GT-64115 System Controller - 4620 GT-64120/64120A/64121A System Controller - 4801 GT-48001 - 5005 Belkin F5D5005 Gigabit Desktop Network PCI Card - 5040 MV88SX5040 4-port SATA I PCI-X Controller - 5041 MV88SX5041 4-port SATA I PCI-X Controller - 5080 MV88SX5080 8-port SATA I PCI-X Controller - 5081 MV88SX5081 8-port SATA I PCI-X Controller - 6041 MV88SX6041 4-port SATA II PCI-X Controller - 6081 MV88SX6081 8-port SATA II PCI-X Controller - 6460 MV64360/64361/64362 System Controller - f003 GT-64010 Primary Image Piranha Image Generator -11ac Canon Information Systems Research Aust. -11ad Lite-On Communications Inc - 0002 LNE100TX - 11ad 0002 LNE100TX - 11ad 0003 LNE100TX - 11ad f003 LNE100TX - 11ad ffff LNE100TX - 1385 f004 FA310TX - c115 LNE100TX [Linksys EtherFast 10/100] - 11ad c001 LNE100TX [ver 2.0] -11ae Aztech System Ltd -11af Avid Technology Inc. - 0001 [Cinema] -11b0 V3 Semiconductor Inc. - 0002 V300PSC - 0292 V292PBC [Am29030/40 Bridge] - 0960 V96xPBC - c960 V96DPC -11b1 Apricot Computers -11b2 Eastman Kodak -11b3 Barr Systems Inc. -11b4 Leitch Technology International -11b5 Radstone Technology Plc -11b6 United Video Corp -11b7 Motorola -11b8 XPoint Technologies, Inc - 0001 Quad PeerMaster -11b9 Pathlight Technology Inc. - c0ed SSA Controller -11ba Videotron Corp -11bb Pyramid Technology -11bc Network Peripherals Inc - 0001 NP-PCI -11bd Pinnacle Systems Inc. -11be International Microcircuits Inc -11bf Astrodesign, Inc. -11c0 Hewlett Packard -11c1 Agere Systems (former Lucent Microelectronics) - 0440 56k WinModem - 1033 8015 LT WinModem 56k Data+Fax+Voice+Dsvd - 1033 8047 LT WinModem 56k Data+Fax+Voice+Dsvd - 1033 804f LT WinModem 56k Data+Fax+Voice+Dsvd - 10cf 102c LB LT Modem V.90 56k - 10cf 104a BIBLO LT Modem 56k - 10cf 105f LB2 LT Modem V.90 56k - 1179 0001 Internal V.90 Modem - 11c1 0440 LT WinModem 56k Data+Fax+Voice+Dsvd - 122d 4101 MDP7800-U Modem - 122d 4102 MDP7800SP-U Modem - 13e0 0040 LT WinModem 56k Data+Fax+Voice+Dsvd - 13e0 0440 LT WinModem 56k Data+Fax+Voice+Dsvd - 13e0 0441 LT WinModem 56k Data+Fax+Voice+Dsvd - 13e0 0450 LT WinModem 56k Data+Fax+Voice+Dsvd - 13e0 f100 LT WinModem 56k Data+Fax+Voice+Dsvd - 13e0 f101 LT WinModem 56k Data+Fax+Voice+Dsvd - 144d 2101 LT56PV Modem - 149f 0440 LT WinModem 56k Data+Fax+Voice+Dsvd - 0441 56k WinModem - 1033 804d LT WinModem 56k Data+Fax - 1033 8065 LT WinModem 56k Data+Fax - 1092 0440 Supra 56i - 1179 0001 Internal V.90 Modem - 11c1 0440 LT WinModem 56k Data+Fax - 11c1 0441 LT WinModem 56k Data+Fax - 122d 4100 MDP7800-U Modem - 13e0 0040 LT WinModem 56k Data+Fax - 13e0 0100 LT WinModem 56k Data+Fax - 13e0 0410 LT WinModem 56k Data+Fax - 13e0 0420 TelePath Internet 56k WinModem - 13e0 0440 LT WinModem 56k Data+Fax - 13e0 0443 LT WinModem 56k Data+Fax - 13e0 f102 LT WinModem 56k Data+Fax - 1416 9804 CommWave 56k Modem - 141d 0440 LT WinModem 56k Data+Fax - 144f 0441 Lucent 56k V.90 DF Modem - 144f 0449 Lucent 56k V.90 DF Modem - 144f 110d Lucent Win Modem - 1468 0441 Presario 56k V.90 DF Modem - 1668 0440 Lucent Win Modem - 0442 56k WinModem - 11c1 0440 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd - 11c1 0442 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd - 13e0 0412 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd - 13e0 0442 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd - 13fc 2471 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd - 144d 2104 LT56PT Modem - 144f 1104 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd - 149f 0440 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd - 1668 0440 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd - 0443 LT WinModem - 0444 LT WinModem - 0445 LT WinModem - 8086 2203 PRO/100+ MiniPCI (probably an Ambit U98.003.C.00 combo card) - 8086 2204 PRO/100+ MiniPCI on Armada E500 - 0446 LT WinModem - 0447 LT WinModem - 0448 WinModem 56k - 1014 0131 Lucent Win Modem - 1033 8066 LT WinModem 56k Data+Fax+Voice+Dsvd - 13e0 0030 56k Voice Modem - 13e0 0040 LT WinModem 56k Data+Fax+Voice+Dsvd -# Actiontech eth+modem card as used by Dell &c. - 1668 2400 LT WinModem 56k (MiniPCI Ethernet+Modem) - 0449 WinModem 56k - 0e11 b14d 56k V.90 Modem - 13e0 0020 LT WinModem 56k Data+Fax - 13e0 0041 TelePath Internet 56k WinModem - 1436 0440 Lucent Win Modem - 144f 0449 Lucent 56k V.90 DFi Modem - 1468 0410 IBM ThinkPad T23 (2647-4MG) - 1468 0440 Lucent Win Modem - 1468 0449 Presario 56k V.90 DFi Modem - 044a F-1156IV WinModem (V90, 56KFlex) - 10cf 1072 LB Global LT Modem - 13e0 0012 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd - 13e0 0042 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd - 144f 1005 LT WinModem 56k Data+Fax+Voice+VoiceView+Dsvd - 044b LT WinModem - 044c LT WinModem - 044d LT WinModem - 044e LT WinModem - 044f V90 WildWire Modem - 0450 LT WinModem - 1033 80a8 Versa Note Vxi - 144f 4005 Magnia SG20 - 0451 LT WinModem - 0452 LT WinModem - 0453 LT WinModem - 0454 LT WinModem - 0455 LT WinModem - 0456 LT WinModem - 0457 LT WinModem - 0458 LT WinModem - 0459 LT WinModem - 045a LT WinModem - 045c LT WinModem - 0461 V90 WildWire Modem - 0462 V90 WildWire Modem - 0480 Venus Modem (V90, 56KFlex) - 048c V.92 56K WinModem -# InPorte Home Internal 56k Modem/fax/answering machine/SMS Features - 048f V.92 56k WinModem - 5801 USB - 5802 USS-312 USB Controller -# 4 port PCI USB Controller made by Agere (formely Lucent) - 5803 USS-344S USB Controller - 5811 FW323 - 8086 524c D865PERL mainboard - dead 0800 FireWire Host Bus Adapter - ab10 WL60010 Wireless LAN MAC - ab11 WL60040 Multimode Wireles LAN MAC - 11c1 ab12 WaveLAN 11abg Cardbus card (Model 1102) - 11c1 ab13 WaveLAN 11abg MiniPCI card (Model 0512) - 11c1 ab15 WaveLAN 11abg Cardbus card (Model 1106) - 11c1 ab16 WaveLAN 11abg MiniPCI card (Model 0516) - ab20 ORiNOCO PCI Adapter - ab21 Agere Wireless PCI Adapter - ab30 Hermes2 Mini-PCI WaveLAN a/b/g - 14cd 2012 Hermes2 Mini-PCI WaveLAN a/b/g -11c2 Sand Microelectronics -11c3 NEC Corporation -11c4 Document Technologies, Inc -11c5 Shiva Corporation -11c6 Dainippon Screen Mfg. Co. Ltd -11c7 D.C.M. Data Systems -11c8 Dolphin Interconnect Solutions AS - 0658 PSB32 SCI-Adapter D31x - d665 PSB64 SCI-Adapter D32x - d667 PSB66 SCI-Adapter D33x -11c9 Magma - 0010 16-line serial port w/- DMA - 0011 4-line serial port w/- DMA -11ca LSI Systems, Inc -11cb Specialix Research Ltd. - 2000 PCI_9050 - 11cb 0200 SX - 11cb b008 I/O8+ - 4000 SUPI_1 - 8000 T225 -11cc Michels & Kleberhoff Computer GmbH -11cd HAL Computer Systems, Inc. -11ce Netaccess -11cf Pioneer Electronic Corporation -11d0 Lockheed Martin Federal Systems-Manassas -11d1 Auravision - 01f7 VxP524 -11d2 Intercom Inc. -11d3 Trancell Systems Inc -11d4 Analog Devices - 1535 Blackfin BF535 processor - 1805 SM56 PCI modem - 1889 AD1889 sound chip -11d5 Ikon Corporation - 0115 10115 - 0117 10117 -11d6 Tekelec Telecom -11d7 Trenton Technology, Inc. -11d8 Image Technologies Development -11d9 TEC Corporation -11da Novell -11db Sega Enterprises Ltd -11dc Questra Corporation -11dd Crosfield Electronics Limited -11de Zoran Corporation - 6057 ZR36057PQC Video cutting chipset - 1031 7efe DC10 Plus - 1031 fc00 MiroVIDEO DC50, Motion JPEG Capture/CODEC Board - 13ca 4231 JPEG/TV Card - 6120 ZR36120 - 1328 f001 Cinemaster C DVD Decoder -11df New Wave PDG -11e0 Cray Communications A/S -11e1 GEC Plessey Semi Inc. -11e2 Samsung Information Systems America -11e3 Quicklogic Corporation - 5030 PC Watchdog -11e4 Second Wave Inc -11e5 IIX Consulting -11e6 Mitsui-Zosen System Research -11e7 Toshiba America, Elec. Company -11e8 Digital Processing Systems Inc. -11e9 Highwater Designs Ltd. -11ea Elsag Bailey -11eb Formation Inc. -11ec Coreco Inc -11ed Mediamatics -11ee Dome Imaging Systems Inc -11ef Nicolet Technologies B.V. -11f0 Compu-Shack - 4231 FDDI - 4232 FASTline UTP Quattro - 4233 FASTline FO - 4234 FASTline UTP - 4235 FASTline-II UTP - 4236 FASTline-II FO - 4731 GIGAline -11f1 Symbios Logic Inc -11f2 Picture Tel Japan K.K. -11f3 Keithley Metrabyte -11f4 Kinetic Systems Corporation - 2915 CAMAC controller -11f5 Computing Devices International -11f6 Compex - 0112 ENet100VG4 - 0113 FreedomLine 100 - 1401 ReadyLink 2000 - 2011 RL100-ATX 10/100 - 11f6 2011 RL100-ATX - 2201 ReadyLink 100TX (Winbond W89C840) - 11f6 2011 ReadyLink 100TX - 9881 RL100TX Fast Ethernet -11f7 Scientific Atlanta -11f8 PMC-Sierra Inc. - 7375 PM7375 [LASAR-155 ATM SAR] -11f9 I-Cube Inc -11fa Kasan Electronics Company, Ltd. -11fb Datel Inc -11fc Silicon Magic -11fd High Street Consultants -11fe Comtrol Corporation - 0001 RocketPort 32 port w/external I/F - 0002 RocketPort 8 port w/external I/F - 0003 RocketPort 16 port w/external I/F - 0004 RocketPort 4 port w/quad cable - 0005 RocketPort 8 port w/octa cable - 0006 RocketPort 8 port w/RJ11 connectors - 0007 RocketPort 4 port w/RJ11 connectors - 0008 RocketPort 8 port w/ DB78 SNI (Siemens) connector - 0009 RocketPort 16 port w/ DB78 SNI (Siemens) connector - 000a RocketPort Plus 4 port - 000b RocketPort Plus 8 port - 000c RocketModem 6 port - 000d RocketModem 4-port - 000e RocketPort Plus 2 port RS232 - 000f RocketPort Plus 2 port RS422 - 0801 RocketPort UPCI 32 port w/external I/F - 0802 RocketPort UPCI 8 port w/external I/F - 0803 RocketPort UPCI 16 port w/external I/F - 0805 RocketPort UPCI 8 port w/octa cable - 080c RocketModem III 8 port - 080d RocketModem III 4 port - 0903 RocketPort Compact PCI 16 port w/external I/F - 8015 RocketPort 4-port UART 16954 -11ff Scion Corporation - 0003 AG-5 -1200 CSS Corporation -1201 Vista Controls Corp -1202 Network General Corp. - 4300 Gigabit Ethernet Adapter - 1202 9841 SK-9841 LX - 1202 9842 SK-9841 LX dual link - 1202 9843 SK-9843 SX - 1202 9844 SK-9843 SX dual link -1203 Bayer Corporation, Agfa Division -1204 Lattice Semiconductor Corporation -1205 Array Corporation -1206 Amdahl Corporation -1208 Parsytec GmbH - 4853 HS-Link Device -1209 SCI Systems Inc -120a Synaptel -120b Adaptive Solutions -120c Technical Corp. -120d Compression Labs, Inc. -120e Cyclades Corporation - 0100 Cyclom-Y below first megabyte - 0101 Cyclom-Y above first megabyte - 0102 Cyclom-4Y below first megabyte - 0103 Cyclom-4Y above first megabyte - 0104 Cyclom-8Y below first megabyte - 0105 Cyclom-8Y above first megabyte - 0200 Cyclades-Z below first megabyte - 0201 Cyclades-Z above first megabyte - 0300 PC300/RSV or /X21 (2 ports) - 0301 PC300/RSV or /X21 (1 port) - 0310 PC300/TE (2 ports) - 0311 PC300/TE (1 port) - 0320 PC300/TE-M (2 ports) - 0321 PC300/TE-M (1 port) - 0400 PC400 -120f Essential Communications - 0001 Roadrunner serial HIPPI -1210 Hyperparallel Technologies -1211 Braintech Inc -1212 Kingston Technology Corp. -1213 Applied Intelligent Systems, Inc. -1214 Performance Technologies, Inc. -1215 Interware Co., Ltd -1216 Purup Prepress A/S -1217 O2 Micro, Inc. - 6729 OZ6729 - 673a OZ6730 - 6832 OZ6832/6833 CardBus Controller - 6836 OZ6836/6860 CardBus Controller - 6872 OZ6812 CardBus Controller - 6925 OZ6922 CardBus Controller - 6933 OZ6933/711E1 CardBus/SmartCardBus Controller - 1025 1016 Travelmate 612 TX - 6972 OZ601/6912/711E0 CardBus/SmartCardBus Controller - 1014 020c ThinkPad R30 - 1179 0001 Magnia Z310 - 7110 OZ711Mx 4-in-1 MemoryCardBus Accelerator - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 7112 OZ711EC1/M1 SmartCardBus/MemoryCardBus Controller - 7113 OZ711EC1 SmartCardBus Controller - 7114 OZ711M1/MC1 4-in-1 MemoryCardBus Controller - 7134 OZ711MP1/MS1 MemoryCardBus Controller - 71e2 OZ711E2 SmartCardBus Controller - 7212 OZ711M2 4-in-1 MemoryCardBus Controller - 7213 OZ6933E CardBus Controller - 7223 OZ711M3/MC3 4-in-1 MemoryCardBus Controller - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 7233 OZ711MP3/MS3 4-in-1 MemoryCardBus Controller -1218 Hybricon Corp. -1219 First Virtual Corporation -121a 3Dfx Interactive, Inc. - 0001 Voodoo - 0002 Voodoo 2 - 0003 Voodoo Banshee - 1092 0003 Monster Fusion - 1092 4000 Monster Fusion - 1092 4002 Monster Fusion - 1092 4801 Monster Fusion AGP - 1092 4803 Monster Fusion AGP - 1092 8030 Monster Fusion - 1092 8035 Monster Fusion AGP - 10b0 0001 Dragon 4000 - 1102 1018 3D Blaster Banshee VE - 121a 0001 Voodoo Banshee AGP - 121a 0003 Voodoo Banshee AGP SGRAM - 121a 0004 Voodoo Banshee - 139c 0016 Raven - 139c 0017 Raven - 14af 0002 Maxi Gamer Phoenix - 0004 Voodoo Banshee [Velocity 100] - 0005 Voodoo 3 - 121a 0004 Voodoo3 AGP - 121a 0030 Voodoo3 AGP - 121a 0031 Voodoo3 AGP - 121a 0034 Voodoo3 AGP - 121a 0036 Voodoo3 2000 PCI - 121a 0037 Voodoo3 AGP - 121a 0038 Voodoo3 AGP - 121a 003a Voodoo3 AGP - 121a 0044 Voodoo3 - 121a 004b Velocity 100 - 121a 004c Velocity 200 - 121a 004d Voodoo3 AGP - 121a 004e Voodoo3 AGP - 121a 0051 Voodoo3 AGP - 121a 0052 Voodoo3 AGP - 121a 0060 Voodoo3 3500 TV (NTSC) - 121a 0061 Voodoo3 3500 TV (PAL) - 121a 0062 Voodoo3 3500 TV (SECAM) - 0009 Voodoo 4 / Voodoo 5 - 121a 0003 Voodoo5 PCI 5500 - 121a 0009 Voodoo5 AGP 5500/6000 - 0057 Voodoo 3/3000 [Avenger] -121b Advanced Telecommunications Modules -121c Nippon Texaco., Ltd -121d Lippert Automationstechnik GmbH -121e CSPI -121f Arcus Technology, Inc. -1220 Ariel Corporation - 1220 AMCC 5933 TMS320C80 DSP/Imaging board -1221 Contec Co., Ltd -1222 Ancor Communications, Inc. -1223 Artesyn Communication Products - 0003 PM/Link - 0004 PM/T1 - 0005 PM/E1 - 0008 PM/SLS - 0009 BajaSpan Resource Target - 000a BajaSpan Section 0 - 000b BajaSpan Section 1 - 000c BajaSpan Section 2 - 000d BajaSpan Section 3 - 000e PM/PPC -1224 Interactive Images -1225 Power I/O, Inc. -1227 Tech-Source - 0006 Raptor GFX 8P -1228 Norsk Elektro Optikk A/S -1229 Data Kinesis Inc. -122a Integrated Telecom -122b LG Industrial Systems Co., Ltd -122c Sican GmbH -122d Aztech System Ltd - 1206 368DSP - 1400 Trident PCI288-Q3DII (NX) - 50dc 3328 Audio - 122d 0001 3328 Audio - 80da 3328 Audio - 122d 0001 3328 Audio -122e Xyratex -122f Andrew Corporation -1230 Fishcamp Engineering -1231 Woodward McCoach, Inc. -1232 GPT Limited -1233 Bus-Tech, Inc. -1234 Technical Corp. -1235 Risq Modular Systems, Inc. -1236 Sigma Designs Corporation - 0000 RealMagic64/GX - 6401 REALmagic 64/GX (SD 6425) -1237 Alta Technology Corporation -1238 Adtran -1239 3DO Company -123a Visicom Laboratories, Inc. -123b Seeq Technology, Inc. -123c Century Systems, Inc. -123d Engineering Design Team, Inc. - 0000 EasyConnect 8/32 - 0002 EasyConnect 8/64 - 0003 EasyIO -123e Simutech, Inc. -123f C-Cube Microsystems - 00e4 MPEG - 8120 E4? - 11bd 0006 DV500 E4 - 11bd 000a DV500 E4 - 11bd 000f DV500 E4 - 8888 Cinemaster C 3.0 DVD Decoder - 1002 0001 Cinemaster C 3.0 DVD Decoder - 1002 0002 Cinemaster C 3.0 DVD Decoder - 1328 0001 Cinemaster C 3.0 DVD Decoder -1240 Marathon Technologies Corp. -1241 DSC Communications -# Formerly Jaycor Networks, Inc. -1242 JNI Corporation - 1560 JNIC-1560 PCI-X Fibre Channel Controller - 1242 6562 FCX2-6562 Dual Channel PCI-X Fibre Channel Adapter - 1242 656a FCX-6562 PCI-X Fibre Channel Adapter - 4643 FCI-1063 Fibre Channel Adapter - 6562 FCX2-6562 Dual Channel PCI-X Fibre Channel Adapter - 656a FCX-6562 PCI-X Fibre Channel Adapter -1243 Delphax -1244 AVM Audiovisuelles MKTG & Computer System GmbH - 0700 B1 ISDN - 0800 C4 ISDN - 0a00 A1 ISDN [Fritz] - 1244 0a00 FRITZ!Card ISDN Controller - 0e00 Fritz!PCI v2.0 ISDN - 1100 C2 ISDN - 1200 T1 ISDN - 2700 Fritz!Card DSL SL - 2900 Fritz!Card DSL v2.0 -1245 A.P.D., S.A. -1246 Dipix Technologies, Inc. -1247 Xylon Research, Inc. -1248 Central Data Corporation -1249 Samsung Electronics Co., Ltd. -124a AEG Electrocom GmbH -124b SBS/Greenspring Modular I/O - 0040 PCI-40A or cPCI-200 Quad IndustryPack carrier - 124b 9080 PCI9080 Bridge -124c Solitron Technologies, Inc. -124d Stallion Technologies, Inc. - 0000 EasyConnection 8/32 - 0002 EasyConnection 8/64 - 0003 EasyIO - 0004 EasyConnection/RA -124e Cylink -124f Infortrend Technology, Inc. - 0041 IFT-2000 Series RAID Controller -1250 Hitachi Microcomputer System Ltd -1251 VLSI Solutions Oy -1253 Guzik Technical Enterprises -1254 Linear Systems Ltd. -1255 Optibase Ltd - 1110 MPEG Forge - 1210 MPEG Fusion - 2110 VideoPlex - 2120 VideoPlex CC - 2130 VideoQuest -1256 Perceptive Solutions, Inc. - 4201 PCI-2220I - 4401 PCI-2240I - 5201 PCI-2000 -1257 Vertex Networks, Inc. -1258 Gilbarco, Inc. -1259 Allied Telesyn International - 2560 AT-2560 Fast Ethernet Adapter (i82557B) - a117 RTL81xx Fast Ethernet - a120 21x4x DEC-Tulip compatible 10/100 Ethernet -125a ABB Power Systems -125b Asix Electronics Corporation - 1400 ALFA GFC2204 Fast Ethernet -125c Aurora Technologies, Inc. - 0101 Saturn 4520P - 0640 Aries 16000P -125d ESS Technology - 0000 ES336H Fax Modem (Early Model) - 1948 Solo? - 1968 ES1968 Maestro 2 - 1028 0085 ES1968 Maestro-2 PCI - 1033 8051 ES1968 Maestro-2 Audiodrive - 1969 ES1969 Solo-1 Audiodrive - 1014 0166 ES1969 SOLO-1 AudioDrive on IBM Aptiva Mainboard - 125d 8888 Solo-1 Audio Adapter - 153b 111b Terratec 128i PCI - 1978 ES1978 Maestro 2E - 0e11 b112 Armada M700/E500 - 1033 803c ES1978 Maestro-2E Audiodrive - 1033 8058 ES1978 Maestro-2E Audiodrive - 1092 4000 Monster Sound MX400 - 1179 0001 ES1978 Maestro-2E Audiodrive - 1988 ES1988 Allegro-1 - 1092 4100 Sonic Impact S100 - 125d 1988 ESS Allegro-1 Audiodrive - 1989 ESS Modem - 125d 1989 ESS Modem - 1998 ES1983S Maestro-3i PCI Audio Accelerator - 1028 00b1 Latitude C600 - 1028 00e6 ES1983S Maestro-3i (Dell Inspiron 8100) - 1999 ES1983S Maestro-3i PCI Modem Accelerator - 199a ES1983S Maestro-3i PCI Audio Accelerator - 199b ES1983S Maestro-3i PCI Modem Accelerator - 2808 ES336H Fax Modem (Later Model) - 2838 ES2838/2839 SuperLink Modem - 2898 ES2898 Modem - 125d 0424 ES56-PI Data Fax Modem - 125d 0425 ES56T-PI Data Fax Modem - 125d 0426 ES56V-PI Data Fax Modem - 125d 0427 VW-PI Data Fax Modem - 125d 0428 ES56ST-PI Data Fax Modem - 125d 0429 ES56SV-PI Data Fax Modem - 147a c001 ES56-PI Data Fax Modem - 14fe 0428 ES56-PI Data Fax Modem - 14fe 0429 ES56-PI Data Fax Modem -125e Specialvideo Engineering SRL -125f Concurrent Technologies, Inc. -1260 Intersil Corporation - 3872 Prism 2.5 Wavelan chipset - 1468 0202 LAN-Express IEEE 802.11b Wireless LAN - 3873 Prism 2.5 Wavelan chipset - 1186 3501 DWL-520 Wireless PCI Adapter - 1186 3700 DWL-520 Wireless PCI Adapter, Rev E1 - 1385 4105 MA311 802.11b wireless adapter - 1668 0414 HWP01170-01 802.11b PCI Wireless Adapter - 16a5 1601 AIR.mate PC-400 PCI Wireless LAN Adapter - 1737 3874 WMP11 Wireless 802.11b PCI Adapter - 8086 2513 Wireless 802.11b MiniPCI Adapter - 3886 ISL3886 [Prism Javelin/Prism Xbow] - 17cf 0037 Z-Com XG-901 and clones Wireless Adapter - 3890 Intersil ISL3890 [Prism GT/Prism Duette] - 10b8 2802 SMC2802W Wireless PCI Adapter - 10b8 2835 SMC2835W Wireless Cardbus Adapter - 10b8 a835 SMC2835W V2 Wireless Cardbus Adapter - 1113 ee03 SMC2802W V2 Wireless PCI Adapter - 1113 ee08 SMC2835W V3 EU Wireless Cardbus Adapter - 1186 3202 DWL-G650 A1 Wireless Adapter - 1259 c104 CG-WLCB54GT Wireless Adapter - 1385 4800 WG511 Wireless Adapter - 16a5 1605 ALLNET ALL0271 Wireless PCI Adapter - 17cf 0014 Z-Com XG-600 and clones Wireless Adapter - 17cf 0020 Z-Com XG-900 and clones Wireless Adapter - 8130 HMP8130 NTSC/PAL Video Decoder - 8131 HMP8131 NTSC/PAL Video Decoder -1261 Matsushita-Kotobuki Electronics Industries, Ltd. -1262 ES Computer Company, Ltd. -1263 Sonic Solutions -1264 Aval Nagasaki Corporation -1265 Casio Computer Co., Ltd. -1266 Microdyne Corporation - 0001 NE10/100 Adapter (i82557B) - 1910 NE2000Plus (RT8029) Ethernet Adapter - 1266 1910 NE2000Plus Ethernet Adapter -1267 S. A. Telecommunications - 5352 PCR2101 - 5a4b Telsat Turbo -1268 Tektronix -1269 Thomson-CSF/TTM -126a Lexmark International, Inc. -126b Adax, Inc. -126c Northern Telecom - 1211 10/100BaseTX [RTL81xx] - 126c 802.11b Wireless Ethernet Adapter -126d Splash Technology, Inc. -126e Sumitomo Metal Industries, Ltd. -126f Silicon Motion, Inc. - 0501 SM501 VoyagerGX - 0710 SM710 LynxEM - 0712 SM712 LynxEM+ - 0720 SM720 Lynx3DM - 0730 SM731 Cougar3DR - 0810 SM810 LynxE - 0811 SM811 LynxE - 0820 SM820 Lynx3D - 0910 SM910 -1270 Olympus Optical Co., Ltd. -1271 GW Instruments -1272 Telematics International -1273 Hughes Network Systems - 0002 DirecPC -1274 Ensoniq - 1171 ES1373 [AudioPCI] (also Creative Labs CT5803) - 1371 ES1371 [AudioPCI-97] - 0e11 0024 AudioPCI on Motherboard Compaq Deskpro - 0e11 b1a7 ES1371, ES1373 AudioPCI - 1033 80ac ES1371, ES1373 AudioPCI - 1042 1854 Tazer - 107b 8054 Tabor2 - 1274 1371 Creative Sound Blaster AudioPCI64V, AudioPCI128 - 1462 6470 ES1371, ES1373 AudioPCI On Motherboard MS-6147 1.1A - 1462 6560 ES1371, ES1373 AudioPCI On Motherboard MS-6156 1.10 - 1462 6630 ES1371, ES1373 AudioPCI On Motherboard MS-6163BX 1.0A - 1462 6631 ES1371, ES1373 AudioPCI On Motherboard MS-6163VIA 1.0A - 1462 6632 ES1371, ES1373 AudioPCI On Motherboard MS-6163BX 2.0A - 1462 6633 ES1371, ES1373 AudioPCI On Motherboard MS-6163VIA 2.0A - 1462 6820 ES1371, ES1373 AudioPCI On Motherboard MS-6182 1.00 - 1462 6822 ES1371, ES1373 AudioPCI On Motherboard MS-6182 1.00A - 1462 6830 ES1371, ES1373 AudioPCI On Motherboard MS-6183 1.00 - 1462 6880 ES1371, ES1373 AudioPCI On Motherboard MS-6188 1.00 - 1462 6900 ES1371, ES1373 AudioPCI On Motherboard MS-6190 1.00 - 1462 6910 ES1371, ES1373 AudioPCI On Motherboard MS-6191 - 1462 6930 ES1371, ES1373 AudioPCI On Motherboard MS-6193 - 1462 6990 ES1371, ES1373 AudioPCI On Motherboard MS-6199BX 2.0A - 1462 6991 ES1371, ES1373 AudioPCI On Motherboard MS-6199VIA 2.0A - 14a4 2077 ES1371, ES1373 AudioPCI On Motherboard KR639 - 14a4 2105 ES1371, ES1373 AudioPCI On Motherboard MR800 - 14a4 2107 ES1371, ES1373 AudioPCI On Motherboard MR801 - 14a4 2172 ES1371, ES1373 AudioPCI On Motherboard DR739 - 1509 9902 ES1371, ES1373 AudioPCI On Motherboard KW11 - 1509 9903 ES1371, ES1373 AudioPCI On Motherboard KW31 - 1509 9904 ES1371, ES1373 AudioPCI On Motherboard KA11 - 1509 9905 ES1371, ES1373 AudioPCI On Motherboard KC13 - 152d 8801 ES1371, ES1373 AudioPCI On Motherboard CP810E - 152d 8802 ES1371, ES1373 AudioPCI On Motherboard CP810 - 152d 8803 ES1371, ES1373 AudioPCI On Motherboard P3810E - 152d 8804 ES1371, ES1373 AudioPCI On Motherboard P3810-S - 152d 8805 ES1371, ES1373 AudioPCI On Motherboard P3820-S - 270f 2001 ES1371, ES1373 AudioPCI On Motherboard 6CTR - 270f 2200 ES1371, ES1373 AudioPCI On Motherboard 6WTX - 270f 3000 ES1371, ES1373 AudioPCI On Motherboard 6WSV - 270f 3100 ES1371, ES1373 AudioPCI On Motherboard 6WIV2 - 270f 3102 ES1371, ES1373 AudioPCI On Motherboard 6WIV - 270f 7060 ES1371, ES1373 AudioPCI On Motherboard 6ASA2 - 8086 4249 ES1371, ES1373 AudioPCI On Motherboard BI440ZX - 8086 424c ES1371, ES1373 AudioPCI On Motherboard BL440ZX - 8086 425a ES1371, ES1373 AudioPCI On Motherboard BZ440ZX - 8086 4341 ES1371, ES1373 AudioPCI On Motherboard Cayman - 8086 4343 ES1371, ES1373 AudioPCI On Motherboard Cape Cod - 8086 4649 ES1371, ES1373 AudioPCI On Motherboard Fire Island - 8086 464a ES1371, ES1373 AudioPCI On Motherboard FJ440ZX - 8086 4d4f ES1371, ES1373 AudioPCI On Motherboard Montreal - 8086 4f43 ES1371, ES1373 AudioPCI On Motherboard OC440LX - 8086 5243 ES1371, ES1373 AudioPCI On Motherboard RC440BX - 8086 5352 ES1371, ES1373 AudioPCI On Motherboard SunRiver - 8086 5643 ES1371, ES1373 AudioPCI On Motherboard Vancouver - 8086 5753 ES1371, ES1373 AudioPCI On Motherboard WS440BX - 5000 ES1370 [AudioPCI] - 5880 5880 AudioPCI - 1274 2000 Creative Sound Blaster AudioPCI128 - 1274 2003 Creative SoundBlaster AudioPCI 128 - 1274 5880 Creative Sound Blaster AudioPCI128 - 1274 8001 Sound Blaster 16PCI 4.1ch - 1458 a000 5880 AudioPCI On Motherboard 6OXET - 1462 6880 5880 AudioPCI On Motherboard MS-6188 1.00 - 270f 2001 5880 AudioPCI On Motherboard 6CTR - 270f 2200 5880 AudioPCI On Motherboard 6WTX - 270f 7040 5880 AudioPCI On Motherboard 6ATA4 -1275 Network Appliance Corporation -1276 Switched Network Technologies, Inc. -1277 Comstream -1278 Transtech Parallel Systems Ltd. - 0701 TPE3/TM3 PowerPC Node - 0710 TPE5 PowerPC PCI board -1279 Transmeta Corporation - 0295 Northbridge - 0395 LongRun Northbridge - 0396 SDRAM controller - 0397 BIOS scratchpad -127a Rockwell International - 1002 HCF 56k Data/Fax Modem - 1092 094c SupraExpress 56i PRO [Diamond SUP2380] - 122d 4002 HPG / MDP3858-U - 122d 4005 MDP3858-E - 122d 4007 MDP3858-A/-NZ - 122d 4012 MDP3858-SA - 122d 4017 MDP3858-W - 122d 4018 MDP3858-W - 127a 1002 Rockwell 56K D/F HCF Modem - 1003 HCF 56k Data/Fax Modem - 0e11 b0bc 229-DF Zephyr - 0e11 b114 229-DF Cheetah - 1033 802b 229-DF - 13df 1003 PCI56RX Modem - 13e0 0117 IBM - 13e0 0147 IBM F-1156IV+/R3 Spain V.90 Modem - 13e0 0197 IBM - 13e0 01c7 IBM F-1156IV+/R3 WW V.90 Modem - 13e0 01f7 IBM - 1436 1003 IBM - 1436 1103 IBM 5614PM3G V.90 Modem - 1436 1602 Compaq 229-DF Ducati - 1004 HCF 56k Data/Fax/Voice Modem - 1048 1500 MicroLink 56k Modem - 10cf 1059 Fujitsu 229-DFRT - 1005 HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem - 1005 127a AOpen FM56-P - 1033 8029 229-DFSV - 1033 8054 Modem - 10cf 103c Fujitsu - 10cf 1055 Fujitsu 229-DFSV - 10cf 1056 Fujitsu 229-DFSV - 122d 4003 MDP3858SP-U - 122d 4006 Packard Bell MDP3858V-E - 122d 4008 MDP3858SP-A/SP-NZ - 122d 4009 MDP3858SP-E - 122d 4010 MDP3858V-U - 122d 4011 MDP3858SP-SA - 122d 4013 MDP3858V-A/V-NZ - 122d 4015 MDP3858SP-W - 122d 4016 MDP3858V-W - 122d 4019 MDP3858V-SA - 13df 1005 PCI56RVP Modem - 13e0 0187 IBM - 13e0 01a7 IBM - 13e0 01b7 IBM DF-1156IV+/R3 Spain V.90 Modem - 13e0 01d7 IBM DF-1156IV+/R3 WW V.90 Modem - 1436 1005 IBM - 1436 1105 IBM - 1437 1105 IBM 5614PS3G V.90 Modem - 1022 HCF 56k Modem - 1436 1303 M3-5614PM3G V.90 Modem - 1023 HCF 56k Data/Fax Modem - 122d 4020 Packard Bell MDP3858-WE - 122d 4023 MDP3858-UE - 13e0 0247 IBM F-1156IV+/R6 Spain V.90 Modem - 13e0 0297 IBM - 13e0 02c7 IBM F-1156IV+/R6 WW V.90 Modem - 1436 1203 IBM - 1436 1303 IBM - 1024 HCF 56k Data/Fax/Voice Modem - 1025 HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem - 10cf 106a Fujitsu 235-DFSV - 122d 4021 Packard Bell MDP3858V-WE - 122d 4022 MDP3858SP-WE - 122d 4024 MDP3858V-UE - 122d 4025 MDP3858SP-UE - 1026 HCF 56k PCI Speakerphone Modem - 1032 HCF 56k Modem - 1033 HCF 56k Modem - 1034 HCF 56k Modem - 1035 HCF 56k PCI Speakerphone Modem - 1036 HCF 56k Modem - 1085 HCF 56k Volcano PCI Modem - 2005 HCF 56k Data/Fax Modem - 104d 8044 229-DFSV - 104d 8045 229-DFSV - 104d 8055 PBE/Aztech 235W-DFSV - 104d 8056 235-DFSV - 104d 805a Modem - 104d 805f Modem - 104d 8074 Modem - 2013 HSF 56k Data/Fax Modem - 1179 0001 Modem - 1179 ff00 Modem - 2014 HSF 56k Data/Fax/Voice Modem - 10cf 1057 Fujitsu Citicorp III - 122d 4050 MSP3880-U - 122d 4055 MSP3880-W - 2015 HSF 56k Data/Fax/Voice/Spkp (w/Handset) Modem - 10cf 1063 Fujitsu - 10cf 1064 Fujitsu - 1468 2015 Fujitsu - 2016 HSF 56k Data/Fax/Voice/Spkp Modem - 122d 4051 MSP3880V-W - 122d 4052 MSP3880SP-W - 122d 4054 MSP3880V-U - 122d 4056 MSP3880SP-U - 122d 4057 MSP3880SP-A - 4311 Riptide HSF 56k PCI Modem - 127a 4311 Ring Modular? Riptide HSF RT HP Dom - 13e0 0210 HP-GVC - 4320 Riptide PCI Audio Controller - 1235 4320 Riptide PCI Audio Controller - 4321 Riptide HCF 56k PCI Modem - 1235 4321 Hewlett Packard DF - 1235 4324 Hewlett Packard DF - 13e0 0210 Hewlett Packard DF - 144d 2321 Riptide - 4322 Riptide PCI Game Controller - 1235 4322 Riptide PCI Game Controller - 8234 RapidFire 616X ATM155 Adapter - 108d 0022 RapidFire 616X ATM155 Adapter - 108d 0027 RapidFire 616X ATM155 Adapter -127b Pixera Corporation -127c Crosspoint Solutions, Inc. -127d Vela Research -127e Winnov, L.P. -127f Fujifilm -1280 Photoscript Group Ltd. -1281 Yokogawa Electric Corporation -1282 Davicom Semiconductor, Inc. - 9009 Ethernet 100/10 MBit - 9100 21x4x DEC-Tulip compatible 10/100 Ethernet - 9102 21x4x DEC-Tulip compatible 10/100 Ethernet - 9132 Ethernet 100/10 MBit -1283 Integrated Technology Express, Inc. - 673a IT8330G - 8212 IT/ITE8212 Dual channel ATA RAID controller (PCI version seems to be IT8212, embedded seems to be ITE8212) - 1283 0001 IT/ITE8212 Dual channel ATA RAID controller - 8330 IT8330G - 8872 IT8874F PCI Dual Serial Port Controller - 8888 IT8888F PCI to ISA Bridge with SMB - 8889 IT8889F PCI to ISA Bridge - e886 IT8330G -1284 Sahara Networks, Inc. -1285 Platform Technologies, Inc. - 0100 AGOGO sound chip (aka ESS Maestro 1) -1286 Mazet GmbH -1287 M-Pact, Inc. - 001e LS220D DVD Decoder - 001f LS220C DVD Decoder -1288 Timestep Corporation -1289 AVC Technology, Inc. -128a Asante Technologies, Inc. -128b Transwitch Corporation -128c Retix Corporation -128d G2 Networks, Inc. - 0021 ATM155 Adapter -128e Hoontech Corporation/Samho Multi Tech Ltd. - 0008 ST128 WSS/SB - 0009 ST128 SAM9407 - 000a ST128 Game Port - 000b ST128 MPU Port - 000c ST128 Ctrl Port -128f Tateno Dennou, Inc. -1290 Sord Computer Corporation -1291 NCS Computer Italia -1292 Tritech Microelectronics Inc -1293 Media Reality Technology -1294 Rhetorex, Inc. -1295 Imagenation Corporation -1296 Kofax Image Products -1297 Holco Enterprise Co, Ltd/Shuttle Computer -1298 Spellcaster Telecommunications Inc. -1299 Knowledge Technology Lab. -129a VMetro, inc. - 0615 PBT-615 PCI-X Bus Analyzer -129b Image Access -129c Jaycor -129d Compcore Multimedia, Inc. -129e Victor Company of Japan, Ltd. -129f OEC Medical Systems, Inc. -12a0 Allen-Bradley Company -12a1 Simpact Associates, Inc. -12a2 Newgen Systems Corporation -12a3 Lucent Technologies - 8105 T8105 H100 Digital Switch -12a4 NTT Electronics Technology Company -12a5 Vision Dynamics Ltd. -12a6 Scalable Networks, Inc. -12a7 AMO GmbH -12a8 News Datacom -12a9 Xiotech Corporation -12aa SDL Communications, Inc. -12ab Yuan Yuan Enterprise Co., Ltd. - 0002 AU8830 [Vortex2] Based Sound Card With A3D Support - 3000 MPG-200C PCI DVD Decoder Card -12ac Measurex Corporation -12ad Multidata GmbH -12ae Alteon Networks Inc. - 0001 AceNIC Gigabit Ethernet - 1014 0104 Gigabit Ethernet-SX PCI Adapter - 12ae 0001 Gigabit Ethernet-SX (Universal) - 1410 0104 Gigabit Ethernet-SX PCI Adapter - 0002 AceNIC Gigabit Ethernet (Copper) - 10a9 8002 Acenic Gigabit Ethernet - 12ae 0002 Gigabit Ethernet-T (3C986-T) - 00fa Farallon PN9100-T Gigabit Ethernet -12af TDK USA Corp -12b0 Jorge Scientific Corp -12b1 GammaLink -12b2 General Signal Networks -12b3 Inter-Face Co Ltd -12b4 FutureTel Inc -12b5 Granite Systems Inc. -12b6 Natural Microsystems -12b7 Cognex Modular Vision Systems Div. - Acumen Inc. -12b8 Korg -12b9 3Com Corp, Modem Division (formerly US Robotics) - 1006 WinModem - 12b9 005c USR 56k Internal Voice WinModem (Model 3472) - 12b9 005e USR 56k Internal WinModem (Models 662975) - 12b9 0062 USR 56k Internal Voice WinModem (Model 662978) - 12b9 0068 USR 56k Internal Voice WinModem (Model 5690) - 12b9 007a USR 56k Internal Voice WinModem (Model 662974) - 12b9 007f USR 56k Internal WinModem (Models 5698, 5699) - 12b9 0080 USR 56k Internal WinModem (Models 2975, 3528) - 12b9 0081 USR 56k Internal Voice WinModem (Models 2974, 3529) - 12b9 0091 USR 56k Internal Voice WinModem (Model 2978) - 1007 USR 56k Internal WinModem - 12b9 00a3 USR 56k Internal WinModem (Model 3595) - 1008 56K FaxModem Model 5610 - 12b9 00a2 USR 56k Internal FAX Modem (Model 2977) - 12b9 00aa USR 56k Internal Voice Modem (Model 2976) - 12b9 00ab USR 56k Internal Voice Modem (Model 5609) - 12b9 00ac USR 56k Internal Voice Modem (Model 3298) - 12b9 00ad USR 56k Internal FAX Modem (Model 5610) -12ba BittWare, Inc. -12bb Nippon Unisoft Corporation -12bc Array Microsystems -12bd Computerm Corp. -12be Anchor Chips Inc. - 3041 AN3041Q CO-MEM - 3042 AN3042Q CO-MEM Lite - 12be 3042 Anchor Chips Lite Evaluation Board -12bf Fujifilm Microdevices -12c0 Infimed -12c1 GMM Research Corp -12c2 Mentec Limited -12c3 Holtek Microelectronics Inc - 0058 PCI NE2K Ethernet - 5598 PCI NE2K Ethernet -12c4 Connect Tech Inc - 0001 Blue HEAT/PCI 8 (RS232/CL/RJ11) - 0002 Blue HEAT/PCI 4 (RS232) - 0003 Blue HEAT/PCI 2 (RS232) - 0004 Blue HEAT/PCI 8 (UNIV, RS485) - 0005 Blue HEAT/PCI 4+4/6+2 (UNIV, RS232/485) - 0006 Blue HEAT/PCI 4 (OPTO, RS485) - 0007 Blue HEAT/PCI 2+2 (RS232/485) - 0008 Blue HEAT/PCI 2 (OPTO, Tx, RS485) - 0009 Blue HEAT/PCI 2+6 (RS232/485) - 000a Blue HEAT/PCI 8 (Tx, RS485) - 000b Blue HEAT/PCI 4 (Tx, RS485) - 000c Blue HEAT/PCI 2 (20 MHz, RS485) - 000d Blue HEAT/PCI 2 PTM - 0100 NT960/PCI - 0201 cPCI Titan - 2 Port - 0202 cPCI Titan - 4 Port - 0300 CTI PCI UART 2 (RS232) - 0301 CTI PCI UART 4 (RS232) - 0302 CTI PCI UART 8 (RS232) - 0310 CTI PCI UART 1+1 (RS232/485) - 0311 CTI PCI UART 2+2 (RS232/485) - 0312 CTI PCI UART 4+4 (RS232/485) - 0320 CTI PCI UART 2 - 0321 CTI PCI UART 4 - 0322 CTI PCI UART 8 - 0330 CTI PCI UART 2 (RS485) - 0331 CTI PCI UART 4 (RS485) - 0332 CTI PCI UART 8 (RS485) -12c5 Picture Elements Incorporated - 007e Imaging/Scanning Subsystem Engine - 007f Imaging/Scanning Subsystem Engine - 0081 PCIVST [Grayscale Thresholding Engine] - 0085 Video Simulator/Sender - 0086 THR2 Multi-scale Thresholder -12c6 Mitani Corporation -12c7 Dialogic Corp -12c8 G Force Co, Ltd -12c9 Gigi Operations -12ca Integrated Computing Engines -12cb Antex Electronics Corporation -12cc Pluto Technologies International -12cd Aims Lab -12ce Netspeed Inc. -12cf Prophet Systems, Inc. -12d0 GDE Systems, Inc. -12d1 PSITech -12d2 NVidia / SGS Thomson (Joint Venture) - 0008 NV1 - 0009 DAC64 - 0018 Riva128 - 1048 0c10 VICTORY Erazor - 107b 8030 STB Velocity 128 - 1092 0350 Viper V330 - 1092 1092 Viper V330 - 10b4 1b1b STB Velocity 128 - 10b4 1b1d STB Velocity 128 - 10b4 1b1e STB Velocity 128, PAL TV-Out - 10b4 1b20 STB Velocity 128 Sapphire - 10b4 1b21 STB Velocity 128 - 10b4 1b22 STB Velocity 128 AGP, NTSC TV-Out - 10b4 1b23 STB Velocity 128 AGP, PAL TV-Out - 10b4 1b27 STB Velocity 128 DVD - 10b4 1b88 MVP Pro 128 - 10b4 222a STB Velocity 128 AGP - 10b4 2230 STB Velocity 128 - 10b4 2232 STB Velocity 128 - 10b4 2235 STB Velocity 128 AGP - 2a15 54a3 3DVision-SAGP / 3DexPlorer 3000 - 0019 Riva128ZX - 0020 TNT - 0028 TNT2 - 0029 UTNT2 - 002c VTNT2 - 00a0 ITNT2 -12d3 Vingmed Sound A/S -12d4 Ulticom (Formerly DGM&S) - 0200 T1 Card -12d5 Equator Technologies Inc - 0003 BSP16 - 1000 BSP15 -12d6 Analogic Corp -12d7 Biotronic SRL -12d8 Pericom Semiconductor -12d9 Aculab PLC - 0002 PCI Prosody - 0004 cPCI Prosody - 0005 Aculab E1/T1 PCI card -12da True Time Inc. -12db Annapolis Micro Systems, Inc -12dc Symicron Computer Communication Ltd. -12dd Management Graphics -12de Rainbow Technologies - 0200 CryptoSwift CS200 -12df SBS Technologies Inc -12e0 Chase Research - 0010 ST16C654 Quad UART - 0020 ST16C654 Quad UART - 0030 ST16C654 Quad UART -12e1 Nintendo Co, Ltd -12e2 Datum Inc. Bancomm-Timing Division -12e3 Imation Corp - Medical Imaging Systems -12e4 Brooktrout Technology Inc -12e5 Apex Semiconductor Inc -12e6 Cirel Systems -12e7 Sunsgroup Corporation -12e8 Crisc Corp -12e9 GE Spacenet -12ea Zuken -12eb Aureal Semiconductor - 0001 Vortex 1 - 104d 8036 AU8820 Vortex Digital Audio Processor - 1092 2000 Sonic Impact A3D - 1092 2100 Sonic Impact A3D - 1092 2110 Sonic Impact A3D - 1092 2200 Sonic Impact A3D - 122d 1002 AU8820 Vortex Digital Audio Processor - 12eb 0001 AU8820 Vortex Digital Audio Processor - 5053 3355 Montego - 0002 Vortex 2 - 104d 8049 AU8830 Vortex 3D Digital Audio Processor - 104d 807b AU8830 Vortex 3D Digital Audio Processor - 1092 3000 Monster Sound II - 1092 3001 Monster Sound II - 1092 3002 Monster Sound II - 1092 3003 Monster Sound II - 1092 3004 Monster Sound II - 12eb 0001 AU8830 Vortex 3D Digital Audio Processor - 12eb 0002 AU8830 Vortex 3D Digital Audio Processor - 12eb 0088 AU8830 Vortex 3D Digital Audio Processor - 144d 3510 AU8830 Vortex 3D Digital Audio Processor - 5053 3356 Montego II - 0003 AU8810 Vortex Digital Audio Processor - 104d 8049 AU8810 Vortex Digital Audio Processor - 104d 8077 AU8810 Vortex Digital Audio Processor - 109f 1000 AU8810 Vortex Digital Audio Processor - 12eb 0003 AU8810 Vortex Digital Audio Processor - 1462 6780 AU8810 Vortex Digital Audio Processor - 14a4 2073 AU8810 Vortex Digital Audio Processor - 14a4 2091 AU8810 Vortex Digital Audio Processor - 14a4 2104 AU8810 Vortex Digital Audio Processor - 14a4 2106 AU8810 Vortex Digital Audio Processor - 8803 Vortex 56k Software Modem - 12eb 8803 Vortex 56k Software Modem -12ec 3A International, Inc. -12ed Optivision Inc. -12ee Orange Micro -12ef Vienna Systems -12f0 Pentek -12f1 Sorenson Vision Inc -12f2 Gammagraphx, Inc. -12f3 Radstone Technology -12f4 Megatel -12f5 Forks -12f6 Dawson France -12f7 Cognex -12f8 Electronic Design GmbH - 0002 VideoMaker -12f9 Four Fold Ltd -12fb Spectrum Signal Processing -12fc Capital Equipment Corp -12fd I2S -12fe ESD Electronic System Design GmbH -12ff Lexicon -1300 Harman International Industries Inc -1302 Computer Sciences Corp -1303 Innovative Integration -1304 Juniper Networks -1305 Netphone, Inc -1306 Duet Technologies -# Formerly ComputerBoards -1307 Measurement Computing - 0001 PCI-DAS1602/16 - 000b PCI-DIO48H - 000c PCI-PDISO8 - 000d PCI-PDISO16 - 000f PCI-DAS1200 - 0010 PCI-DAS1602/12 - 0014 PCI-DIO24H - 0015 PCI-DIO24H/CTR3 - 0016 PCI-DIO48H/CTR15 - 0017 PCI-DIO96H - 0018 PCI-CTR05 - 0019 PCI-DAS1200/JR - 001a PCI-DAS1001 - 001b PCI-DAS1002 - 001c PCI-DAS1602JR/16 - 001d PCI-DAS6402/16 - 001e PCI-DAS6402/12 - 001f PCI-DAS16/M1 - 0020 PCI-DDA02/12 - 0021 PCI-DDA04/12 - 0022 PCI-DDA08/12 - 0023 PCI-DDA02/16 - 0024 PCI-DDA04/16 - 0025 PCI-DDA08/16 - 0026 PCI-DAC04/12-HS - 0027 PCI-DAC04/16-HS - 0028 PCI-DIO24 - 0029 PCI-DAS08 - 002c PCI-INT32 - 0033 PCI-DUAL-AC5 - 0034 PCI-DAS-TC - 0035 PCI-DAS64/M1/16 - 0036 PCI-DAS64/M2/16 - 0037 PCI-DAS64/M3/16 - 004c PCI-DAS1000 - 004d PCI-QUAD04 - 0052 PCI-DAS4020/12 - 005e PCI-DAS6025 -1308 Jato Technologies Inc. - 0001 NetCelerator Adapter - 1308 0001 NetCelerator Adapter -1309 AB Semiconductor Ltd -130a Mitsubishi Electric Microcomputer -130b Colorgraphic Communications Corp -130c Ambex Technologies, Inc -130d Accelerix Inc -130e Yamatake-Honeywell Co. Ltd -130f Advanet Inc -1310 Gespac -1311 Videoserver, Inc -1312 Acuity Imaging, Inc -1313 Yaskawa Electric Co. -1316 Teradyne Inc -1317 Linksys - 0981 21x4x DEC-Tulip compatible 10/100 Ethernet - 0985 NC100 Network Everywhere Fast Ethernet 10/100 - 1985 21x4x DEC-Tulip compatible 10/100 Ethernet - 2850 HSP MicroModem 56 - 8201 ADMtek ADM8211 802.11b Wireless Interface - 10b8 2635 SMC2635W 802.11b (11Mbps) wireless lan pcmcia (cardbus) card - 1317 8201 SMC2635W 802.11b (11mbps) wireless lan pcmcia (cardbus) card - 8211 ADMtek ADM8211 802.11b Wireless Interface - 9511 21x4x DEC-Tulip compatible 10/100 Ethernet -1318 Packet Engines Inc. - 0911 GNIC-II PCI Gigabit Ethernet [Hamachi] -1319 Fortemedia, Inc - 0801 Xwave QS3000A [FM801] - 0802 Xwave QS3000A [FM801 game port] - 1000 FM801 PCI Audio - 1001 FM801 PCI Joystick -131a Finisar Corp. -131c Nippon Electro-Sensory Devices Corp -131d Sysmic, Inc. -131e Xinex Networks Inc -131f Siig Inc - 1000 CyberSerial (1-port) 16550 - 1001 CyberSerial (1-port) 16650 - 1002 CyberSerial (1-port) 16850 - 1010 Duet 1S(16550)+1P - 1011 Duet 1S(16650)+1P - 1012 Duet 1S(16850)+1P - 1020 CyberParallel (1-port) - 1021 CyberParallel (2-port) - 1030 CyberSerial (2-port) 16550 - 1031 CyberSerial (2-port) 16650 - 1032 CyberSerial (2-port) 16850 - 1034 Trio 2S(16550)+1P - 1035 Trio 2S(16650)+1P - 1036 Trio 2S(16850)+1P - 1050 CyberSerial (4-port) 16550 - 1051 CyberSerial (4-port) 16650 - 1052 CyberSerial (4-port) 16850 - 2000 CyberSerial (1-port) 16550 - 2001 CyberSerial (1-port) 16650 - 2002 CyberSerial (1-port) 16850 - 2010 Duet 1S(16550)+1P - 2011 Duet 1S(16650)+1P - 2012 Duet 1S(16850)+1P - 2020 CyberParallel (1-port) - 2021 CyberParallel (2-port) - 2030 CyberSerial (2-port) 16550 - 131f 2030 PCI Serial Card - 2031 CyberSerial (2-port) 16650 - 2032 CyberSerial (2-port) 16850 - 2040 Trio 1S(16550)+2P - 2041 Trio 1S(16650)+2P - 2042 Trio 1S(16850)+2P - 2050 CyberSerial (4-port) 16550 - 2051 CyberSerial (4-port) 16650 - 2052 CyberSerial (4-port) 16850 - 2060 Trio 2S(16550)+1P - 2061 Trio 2S(16650)+1P - 2062 Trio 2S(16850)+1P - 2081 CyberSerial (8-port) ST16654 -1320 Crypto AG -1321 Arcobel Graphics BV -1322 MTT Co., Ltd -1323 Dome Inc -1324 Sphere Communications -1325 Salix Technologies, Inc -1326 Seachange international -1327 Voss scientific -1328 quadrant international -1329 Productivity Enhancement -132a Microcom Inc. -132b Broadband Technologies -132c Micrel Inc -132d Integrated Silicon Solution, Inc. -1330 MMC Networks -1331 Radisys Corp. - 0030 ENP-2611 - 8200 82600 Host Bridge - 8201 82600 IDE - 8202 82600 USB - 8210 82600 PCI Bridge -1332 Micro Memory - 5415 MM-5415CN PCI Memory Module with Battery Backup - 5425 MM-5425CN PCI 64/66 Memory Module with Battery Backup -1334 Redcreek Communications, Inc -1335 Videomail, Inc -1337 Third Planet Publishing -1338 BT Electronics -133a Vtel Corp -133b Softcom Microsystems -133c Holontech Corp -133d SS Technologies -133e Virtual Computer Corp -133f SCM Microsystems -1340 Atalla Corp -1341 Kyoto Microcomputer Co -1342 Promax Systems Inc -1343 Phylon Communications Inc -1344 Crucial Technology -1345 Arescom Inc -1347 Odetics -1349 Sumitomo Electric Industries, Ltd. -134a DTC Technology Corp. - 0001 Domex 536 - 0002 Domex DMX3194UP SCSI Adapter -134b ARK Research Corp. -134c Chori Joho System Co. Ltd -134d PCTel Inc - 2189 HSP56 MicroModem - 2486 2304WT V.92 MDC Modem - 7890 HSP MicroModem 56 - 134d 0001 PCT789 adapter - 7891 HSP MicroModem 56 - 134d 0001 HSP MicroModem 56 - 7892 HSP MicroModem 56 - 7893 HSP MicroModem 56 - 7894 HSP MicroModem 56 - 7895 HSP MicroModem 56 - 7896 HSP MicroModem 56 - 7897 HSP MicroModem 56 -134e CSTI -134f Algo System Co Ltd -1350 Systec Co. Ltd -1351 Sonix Inc -1353 Thales Idatys - 0002 Proserver - 0003 PCI-FUT - 0004 PCI-S0 - 0005 PCI-FUT-S0 -1354 Dwave System Inc -1355 Kratos Analytical Ltd -1356 The Logical Co -1359 Prisa Networks -135a Brain Boxes -135b Giganet Inc -135c Quatech Inc - 0010 QSC-100 - 0020 DSC-100 - 0030 DSC-200/300 - 0040 QSC-200/300 - 0050 ESC-100D - 0060 ESC-100M - 00f0 MPAC-100 Syncronous Serial Card (Zilog 85230) - 0170 QSCLP-100 - 0180 DSCLP-100 - 0190 SSCLP-100 - 01a0 QSCLP-200/300 - 01b0 DSCLP-200/300 - 01c0 SSCLP-200/300 -135d ABB Network Partner AB -135e Sealevel Systems Inc - 5101 Route 56.PCI - Multi-Protocol Serial Interface (Zilog Z16C32) - 7101 Single Port RS-232/422/485/530 - 7201 Dual Port RS-232/422/485 Interface - 7202 Dual Port RS-232 Interface - 7401 Four Port RS-232 Interface - 7402 Four Port RS-422/485 Interface - 7801 Eight Port RS-232 Interface - 7804 Eight Port RS-232/422/485 Interface - 8001 8001 Digital I/O Adapter -135f I-Data International A-S -1360 Meinberg Funkuhren - 0101 PCI32 DCF77 Radio Clock - 0102 PCI509 DCF77 Radio Clock - 0103 PCI510 DCF77 Radio Clock - 0201 GPS167PCI GPS Receiver - 0202 GPS168PCI GPS Receiver - 0203 GPS169PCI GPS Receiver - 0301 TCR510PCI IRIG Receiver -1361 Soliton Systems K.K. -1362 Fujifacom Corporation -1363 Phoenix Technology Ltd -1364 ATM Communications Inc -1365 Hypercope GmbH -1366 Teijin Seiki Co. Ltd -1367 Hitachi Zosen Corporation -1368 Skyware Corporation -1369 Digigram -136a High Soft Tech -136b Kawasaki Steel Corporation - ff01 KL5A72002 Motion JPEG -136c Adtek System Science Co Ltd -136d Gigalabs Inc -136f Applied Magic Inc -1370 ATL Products -1371 CNet Technology Inc - 434e GigaCard Network Adapter - 1371 434e N-Way PCI-Bus Giga-Card 1000/100/10Mbps(L) -1373 Silicon Vision Inc -1374 Silicom Ltd -1375 Argosystems Inc -1376 LMC -1377 Electronic Equipment Production & Distribution GmbH -1378 Telemann Co. Ltd -1379 Asahi Kasei Microsystems Co Ltd -137a Mark of the Unicorn Inc - 0001 PCI-324 Audiowire Interface -137b PPT Vision -137c Iwatsu Electric Co Ltd -137d Dynachip Corporation -137e Patriot Scientific Corporation -137f Japan Satellite Systems Inc -1380 Sanritz Automation Co Ltd -1381 Brains Co. Ltd -1382 Marian - Electronic & Software - 0001 ARC88 audio recording card - 2008 Prodif 96 Pro sound system - 2088 Marc 8 Midi sound system - 20c8 Marc A sound system - 4008 Marc 2 sound system - 4010 Marc 2 Pro sound system - 4048 Marc 4 MIDI sound system - 4088 Marc 4 Digi sound system - 4248 Marc X sound system -1383 Controlnet Inc -1384 Reality Simulation Systems Inc -1385 Netgear -# Note: This lists as Atheros Communications, Inc. AR5212 802.11abg NIC because of Madwifi - 0013 WG311T - 311a GA511 Gigabit Ethernet - 4100 802.11b Wireless Adapter (MA301) - 4105 MA311 802.11b wireless adapter - 4400 WAG511 802.11a/b/g Dual Band Wireless PC Card - 4600 WAG511 802.11a/b/g Dual Band Wireless PC Card - 4601 WAG511 802.11a/b/g Dual Band Wireless PC Card - 4610 WAG511 802.11a/b/g Dual Band Wireless PC Card - 4a00 WAG311 802.11a/g Wireless PCI Adapter - 4c00 WG311v2 54 Mbps Wireless PCI Adapter - 620a GA620 Gigabit Ethernet - 622a GA622 - 630a GA630 Gigabit Ethernet - f004 FA310TX -1386 Video Domain Technologies -1387 Systran Corp -1388 Hitachi Information Technology Co Ltd -1389 Applicom International - 0001 PCI1500PFB [Intelligent fieldbus adaptor] -138a Fusion Micromedia Corp -138b Tokimec Inc -138c Silicon Reality -138d Future Techno Designs pte Ltd -138e Basler GmbH -138f Patapsco Designs Inc -1390 Concept Development Inc -1391 Development Concepts Inc -1392 Medialight Inc -1393 Moxa Technologies Co Ltd - 1040 Smartio C104H/PCI - 1141 Industrio CP-114 - 1680 Smartio C168H/PCI - 2040 Intellio CP-204J - 2180 Intellio C218 Turbo PCI - 3200 Intellio C320 Turbo PCI -1394 Level One Communications - 0001 LXT1001 Gigabit Ethernet - 1394 0001 NetCelerator Adapter -1395 Ambicom Inc -1396 Cipher Systems Inc -1397 Cologne Chip Designs GmbH - 2bd0 ISDN network controller [HFC-PCI] - 1397 2bd0 ISDN Board - e4bf 1000 CI1-1-Harp -1398 Clarion co. Ltd -1399 Rios systems Co Ltd -139a Alacritech Inc - 0001 Quad Port 10/100 Server Accelerator - 0003 Single Port 10/100 Server Accelerator - 0005 Single Port Gigabit Server Accelerator -139b Mediasonic Multimedia Systems Ltd -139c Quantum 3d Inc -139d EPL limited -139e Media4 -139f Aethra s.r.l. -13a0 Crystal Group Inc -13a1 Kawasaki Heavy Industries Ltd -13a2 Ositech Communications Inc -13a3 Hifn Inc. - 0005 7751 Security Processor - 0006 6500 Public Key Processor - 0007 7811 Security Processor - 0012 7951 Security Processor - 0014 78XX Security Processor - 0016 8065 Security Processor - 0017 8165 Security Processor - 0018 8154 Security Processor - 001d 7956 Security Processor - 0020 7955 Security Processor -13a4 Rascom Inc -13a5 Audio Digital Imaging Inc -13a6 Videonics Inc -13a7 Teles AG -13a8 Exar Corp. - 0154 XR17C154 Quad UART - 0158 XR17C158 Octal UART -13a9 Siemens Medical Systems, Ultrasound Group -13aa Broadband Networks Inc -13ab Arcom Control Systems Ltd -13ac Motion Media Technology Ltd -13ad Nexus Inc -13ae ALD Technology Ltd -13af T.Sqware -13b0 Maxspeed Corp -13b1 Tamura corporation -13b2 Techno Chips Co. Ltd -13b3 Lanart Corporation -13b4 Wellbean Co Inc -13b5 ARM -13b6 Dlog GmbH -13b7 Logic Devices Inc -13b8 Nokia Telecommunications oy -13b9 Elecom Co Ltd -13ba Oxford Instruments -13bb Sanyo Technosound Co Ltd -13bc Bitran Corporation -13bd Sharp corporation -13be Miroku Jyoho Service Co. Ltd -13bf Sharewave Inc -13c0 Microgate Corporation - 0010 SyncLink Adapter v1 - 0020 SyncLink SCC Adapter - 0030 SyncLink Multiport Adapter - 0210 SyncLink Adapter v2 -13c1 3ware Inc - 1000 3ware Inc 3ware 5xxx/6xxx-series PATA-RAID - 1001 3ware Inc 3ware 7xxx/8xxx-series PATA/SATA-RAID - 13c1 1001 3ware Inc 3ware 7xxx/8xxx-series PATA/SATA-RAID - 1002 3ware Inc 3ware 9xxx-series SATA-RAID -13c2 Technotrend Systemtechnik GmbH -13c3 Janz Computer AG -13c4 Phase Metrics -13c5 Alphi Technology Corp -13c6 Condor Engineering Inc - 0520 CEI-520 A429 Card - 0620 CEI-620 A429 Card - 0820 CEI-820 A429 Card -13c7 Blue Chip Technology Ltd -13c8 Apptech Inc -13c9 Eaton Corporation -13ca Iomega Corporation -13cb Yano Electric Co Ltd -13cc Metheus Corporation -13cd Compatible Systems Corporation -13ce Cocom A/S -13cf Studio Audio & Video Ltd -13d0 Techsan Electronics Co Ltd - 2103 B2C2 FlexCopII DVB chip / Technisat SkyStar2 DVB card - 2200 B2C2 FlexCopIII DVB chip / Technisat SkyStar2 DVB card -13d1 Abocom Systems Inc - ab02 ADMtek Centaur-C rev 17 [D-Link DFE-680TX] CardBus Fast Ethernet Adapter - ab03 21x4x DEC-Tulip compatible 10/100 Ethernet - ab06 RTL8139 [FE2000VX] CardBus Fast Ethernet Attached Port Adapter - ab08 21x4x DEC-Tulip compatible 10/100 Ethernet -13d2 Shark Multimedia Inc -13d3 IMC Networks -13d4 Graphics Microsystems Inc -13d5 Media 100 Inc -13d6 K.I. Technology Co Ltd -13d7 Toshiba Engineering Corporation -13d8 Phobos corporation -13d9 Apex PC Solutions Inc -13da Intresource Systems pte Ltd -13db Janich & Klass Computertechnik GmbH -13dc Netboost Corporation -13dd Multimedia Bundle Inc -13de ABB Robotics Products AB -13df E-Tech Inc - 0001 PCI56RVP Modem - 13df 0001 PCI56RVP Modem -13e0 GVC Corporation -13e1 Silicom Multimedia Systems Inc -13e2 Dynamics Research Corporation -13e3 Nest Inc -13e4 Calculex Inc -13e5 Telesoft Design Ltd -13e6 Argosy research Inc -13e7 NAC Incorporated -13e8 Chip Express Corporation -13e9 Intraserver Technology Inc -13ea Dallas Semiconductor -13eb Hauppauge Computer Works Inc -13ec Zydacron Inc -13ed Raytheion E-Systems -13ee Hayes Microcomputer Products Inc -13ef Coppercom Inc -13f0 Sundance Technology Inc - 0201 ST201 Sundance Ethernet -13f1 Oce' - Technologies B.V. -13f2 Ford Microelectronics Inc -13f3 Mcdata Corporation -13f4 Troika Networks, Inc. - 1401 Zentai Fibre Channel Adapter -13f5 Kansai Electric Co. Ltd -13f6 C-Media Electronics Inc - 0011 CMI8738 - 0100 CM8338A - 13f6 ffff CMI8338/C3DX PCI Audio Device - 0101 CM8338B - 13f6 0101 CMI8338-031 PCI Audio Device - 0111 CM8738 - 1019 0970 P6STP-FL motherboard - 1043 8035 CUSI-FX motherboard - 1043 8077 CMI8738 6-channel audio controller - 1043 80e2 CMI8738 6ch-MX - 13f6 0111 CMI8738/C3DX PCI Audio Device - 1681 a000 Gamesurround MUSE XL - 0211 CM8738 -13f7 Wildfire Communications -13f8 Ad Lib Multimedia Inc -13f9 NTT Advanced Technology Corp. -13fa Pentland Systems Ltd -13fb Aydin Corp -13fc Computer Peripherals International -13fd Micro Science Inc -13fe Advantech Co. Ltd - 1240 PCI-1240 4-channel stepper motor controller card w. Nova Electronics MCX314 - 1600 PCI-1612 4-port RS-232/422/485 PCI Communication Card - 1752 PCI-1752 - 1754 PCI-1754 - 1756 PCI-1756 -13ff Silicon Spice Inc -1400 Artx Inc - 1401 9432 TX -1401 CR-Systems A/S -1402 Meilhaus Electronic GmbH -1403 Ascor Inc -1404 Fundamental Software Inc -1405 Excalibur Systems Inc -1406 Oce' Printing Systems GmbH -1407 Lava Computer mfg Inc - 0100 Lava Dual Serial - 0101 Lava Quatro A - 0102 Lava Quatro B - 0110 Lava DSerial-PCI Port A - 0111 Lava DSerial-PCI Port B - 0120 Quattro-PCI A - 0121 Quattro-PCI B - 0180 Lava Octo A - 0181 Lava Octo B - 0200 Lava Port Plus - 0201 Lava Quad A - 0202 Lava Quad B - 0220 Lava Quattro PCI Ports A/B - 0221 Lava Quattro PCI Ports C/D - 0500 Lava Single Serial - 0600 Lava Port 650 - 8000 Lava Parallel - 8001 Dual parallel port controller A - 8002 Lava Dual Parallel port A - 8003 Lava Dual Parallel port B - 8800 BOCA Research IOPPAR -1408 Aloka Co. Ltd -1409 Timedia Technology Co Ltd - 7168 PCI2S550 (Dual 16550 UART) -140a DSP Research Inc -140b Ramix Inc -140c Elmic Systems Inc -140d Matsushita Electric Works Ltd -140e Goepel Electronic GmbH -140f Salient Systems Corp -1410 Midas lab Inc -1411 Ikos Systems Inc -# formerly IC Ensemble Inc. -1412 VIA Technologies Inc. - 1712 ICE1712 [Envy24] PCI Multi-Channel I/O Controller - 1412 1712 Hoontech ST Audio DSP 24 - 1412 d630 M-Audio Delta 1010 - 1412 d631 M-Audio Delta DiO - 1412 d632 M-Audio Delta 66 - 1412 d633 M-Audio Delta 44 - 1412 d634 M-Audio Delta Audiophile - 1412 d635 M-Audio Delta TDIF - 1412 d637 M-Audio Delta RBUS - 1412 d638 M-Audio Delta 410 - 1412 d63b M-Audio Delta 1010LT - 1412 d63c Digigram VX442 - 1416 1712 Hoontech ST Audio DSP 24 Media 7.1 - 153b 1115 EWS88 MT - 153b 1125 EWS88 MT (Master) - 153b 112b EWS88 D - 153b 112c EWS88 D (Master) - 153b 1130 EWX 24/96 - 153b 1138 DMX 6fire 24/96 - 153b 1151 PHASE88 - 16ce 1040 Edirol DA-2496 - 1724 VT1720/24 [Envy24PT/HT] PCI Multi-Channel Audio Controller - 1412 1724 AMP Ltd AUDIO2000 - 1412 3630 M-Audio Revolution 7.1 - 153b 1145 Aureon 7.1 Space - 153b 1147 Aureon 5.1 Sky - 153b 1153 Aureon 7.1 Universe - 270f f641 ZNF3-150 - 270f f645 ZNF3-250 -1413 Addonics -1414 Microsoft Corporation -1415 Oxford Semiconductor Ltd - 8403 VScom 011H-EP1 1 port parallel adaptor - 9501 OX16PCI954 (Quad 16950 UART) function 0 - 131f 2050 CyberPro (4-port) -# Model IO1085, Part No: JJ-P46012 - 131f 2051 CyberSerial 4S Plus - 15ed 2000 MCCR Serial p0-3 of 8 - 15ed 2001 MCCR Serial p0-3 of 16 - 950a EXSYS EX-41092 Dual 16950 Serial adapter - 950b OXCB950 Cardbus 16950 UART - 9510 OX16PCI954 (Quad 16950 UART) function 1 (Disabled) - 9511 OX16PCI954 (Quad 16950 UART) function 1 - 15ed 2000 MCCR Serial p4-7 of 8 - 15ed 2001 MCCR Serial p4-15 of 16 - 9521 OX16PCI952 (Dual 16950 UART) -1416 Multiwave Innovation pte Ltd -1417 Convergenet Technologies Inc -1418 Kyushu electronics systems Inc -1419 Excel Switching Corp -141a Apache Micro Peripherals Inc -141b Zoom Telephonics Inc -141d Digitan Systems Inc -141e Fanuc Ltd -141f Visiontech Ltd -1420 Psion Dacom plc - 8002 Gold Card NetGlobal 56k+10/100Mb CardBus (Ethernet part) - 8003 Gold Card NetGlobal 56k+10/100Mb CardBus (Modem part) -1421 Ads Technologies Inc -1422 Ygrec Systems Co Ltd -1423 Custom Technology Corp. -1424 Videoserver Connections -1425 Chelsio Communications Inc -1426 Storage Technology Corp. -1427 Better On-Line Solutions -1428 Edec Co Ltd -1429 Unex Technology Corp. -142a Kingmax Technology Inc -142b Radiolan -142c Minton Optic Industry Co Ltd -142d Pix stream Inc -142e Vitec Multimedia - 4020 VM2-2 [Video Maker 2] MPEG1/2 Encoder -142f Radicom Research Inc -1430 ITT Aerospace/Communications Division -1431 Gilat Satellite Networks -1432 Edimax Computer Co. - 9130 RTL81xx Fast Ethernet -1433 Eltec Elektronik GmbH -1435 Real Time Devices US Inc. -1436 CIS Technology Inc -1437 Nissin Inc Co -1438 Atmel-dream -1439 Outsource Engineering & Mfg. Inc -143a Stargate Solutions Inc -143b Canon Research Center, America -143c Amlogic Inc -143d Tamarack Microelectronics Inc -143e Jones Futurex Inc -143f Lightwell Co Ltd - Zax Division -1440 ALGOL Corp. -1441 AGIE Ltd -1442 Phoenix Contact GmbH & Co. -1443 Unibrain S.A. -1444 TRW -1445 Logical DO Ltd -1446 Graphin Co Ltd -1447 AIM GmBH -1448 Alesis Studio Electronics -1449 TUT Systems Inc -144a Adlink Technology - 7296 PCI-7296 - 7432 PCI-7432 - 7433 PCI-7433 - 7434 PCI-7434 - 7841 PCI-7841 - 8133 PCI-8133 - 8164 PCI-8164 - 8554 PCI-8554 - 9111 PCI-9111 - 9113 PCI-9113 - 9114 PCI-9114 -144b Loronix Information Systems Inc -144c Catalina Research Inc -144d Samsung Electronics Co Ltd -144e OLITEC -144f Askey Computer Corp. -1450 Octave Communications Ind. -1451 SP3D Chip Design GmBH -1453 MYCOM Inc -1454 Altiga Networks -1455 Logic Plus Plus Inc -1456 Advanced Hardware Architectures -1457 Nuera Communications Inc -1458 Giga-byte Technology - 0c11 K8NS Pro Mainboard -1459 DOOIN Electronics -145a Escalate Networks Inc -145b PRAIM SRL -145c Cryptek -145d Gallant Computer Inc -145e Aashima Technology B.V. -145f Baldor Electric Company - 0001 NextMove PCI -1460 DYNARC INC -1461 Avermedia Technologies Inc -1462 Micro-Star International Co., Ltd. -# MSI CB54G Wireless PC Card that seems to use the Broadcom 4306 Chipset - 6819 Broadcom Corporation BCM4306 802.11b/g Wireless LAN Controller [MSI CB54G] - 6825 PCI Card wireless 11g [PC54G] - 8725 NVIDIA NV25 [GeForce4 Ti 4600] VGA Adapter -# MSI G4Ti4800, 128MB DDR SDRAM, TV-Out, DVI-I - 9000 NVIDIA NV28 [GeForce4 Ti 4800] VGA Adapter - 9110 GeFORCE FX5200 - 9119 NVIDIA NV31 [GeForce FX 5600XT] VGA Adapter - 9591 nVidia Corporation NV36 [GeForce FX 5700LE] -1463 Fast Corporation -1464 Interactive Circuits & Systems Ltd -1465 GN NETTEST Telecom DIV. -1466 Designpro Inc. -1467 DIGICOM SPA -1468 AMBIT Microsystem Corp. -1469 Cleveland Motion Controls -146a IFR -146b Parascan Technologies Ltd -146c Ruby Tech Corp. - 1430 FE-1430TX Fast Ethernet PCI Adapter -146d Tachyon, INC. -146e Williams Electronics Games, Inc. -146f Multi Dimensional Consulting Inc -1470 Bay Networks -1471 Integrated Telecom Express Inc -1472 DAIKIN Industries, Ltd -1473 ZAPEX Technologies Inc -1474 Doug Carson & Associates -1475 PICAZO Communications -1476 MORTARA Instrument Inc -1477 Net Insight -1478 DIATREND Corporation -1479 TORAY Industries Inc -147a FORMOSA Industrial Computing -147b ABIT Computer Corp. -147c AWARE, Inc. -147d Interworks Computer Products -147e Matsushita Graphic Communication Systems, Inc. -147f NIHON UNISYS, Ltd. -1480 SCII Telecom -1481 BIOPAC Systems Inc -1482 ISYTEC - Integrierte Systemtechnik GmBH -1483 LABWAY Corporation -1484 Logic Corporation -1485 ERMA - Electronic GmBH -1486 L3 Communications Telemetry & Instrumentation -1487 MARQUETTE Medical Systems -1488 KONTRON Electronik GmBH -1489 KYE Systems Corporation -148a OPTO -148b INNOMEDIALOGIC Inc. -148c C.P. Technology Co. Ltd -148d DIGICOM Systems, Inc. - 1003 HCF 56k Data/Fax Modem -148e OSI Plus Corporation -148f Plant Equipment, Inc. -1490 Stone Microsystems PTY Ltd. -1491 ZEAL Corporation -1492 Time Logic Corporation -1493 MAKER Communications -1494 WINTOP Technology, Inc. -1495 TOKAI Communications Industry Co. Ltd -1496 JOYTECH Computer Co., Ltd. -1497 SMA Regelsysteme GmBH -1498 TEWS Datentechnik GmBH - 30c8 TPCI200 -1499 EMTEC CO., Ltd -149a ANDOR Technology Ltd -149b SEIKO Instruments Inc -149c OVISLINK Corp. -149d NEWTEK Inc - 0001 Video Toaster for PC -149e Mapletree Networks Inc. -149f LECTRON Co Ltd -14a0 SOFTING GmBH -14a1 Systembase Co Ltd -14a2 Millennium Engineering Inc -14a3 Maverick Networks -14a4 GVC/BCM Advanced Research -14a5 XIONICS Document Technologies Inc -14a6 INOVA Computers GmBH & Co KG -14a7 MYTHOS Systems Inc -14a8 FEATRON Technologies Corporation -14a9 HIVERTEC Inc -14aa Advanced MOS Technology Inc -14ab Mentor Graphics Corp. -14ac Novaweb Technologies Inc -14ad Time Space Radio AB -14ae CTI, Inc -14af Guillemot Corporation - 7102 3D Prophet II MX -14b0 BST Communication Technology Ltd -14b1 Nextcom K.K. -14b2 ENNOVATE Networks Inc -14b3 XPEED Inc - 0000 DSL NIC -14b4 PHILIPS Business Electronics B.V. -14b5 Creamware GmBH - 0200 Scope - 0300 Pulsar - 0400 PulsarSRB - 0600 Pulsar2 - 0800 DSP-Board - 0900 DSP-Board - 0a00 DSP-Board - 0b00 DSP-Board -14b6 Quantum Data Corp. -14b7 PROXIM Inc - 0001 Symphony 4110 -14b8 Techsoft Technology Co Ltd -14b9 AIRONET Wireless Communications - 0001 PC4800 - 0340 PC4800 - 0350 PC4800 - 4500 PC4500 - 4800 Cisco Aironet 340 802.11b Wireless LAN Adapter/Aironet PC4800 - a504 Cisco Aironet Wireless 802.11b - a505 Cisco Aironet CB20a 802.11a Wireless LAN Adapter - a506 Cisco Aironet Mini PCI b/g -14ba INTERNIX Inc. -14bb SEMTECH Corporation -14bc Globespan Semiconductor Inc. -14bd CARDIO Control N.V. -14be L3 Communications -14bf SPIDER Communications Inc. -14c0 COMPAL Electronics Inc -14c1 MYRICOM Inc. - 8043 Myrinet 2000 Scalable Cluster Interconnect -14c2 DTK Computer -14c3 MEDIATEK Corp. -14c4 IWASAKI Information Systems Co Ltd -14c5 Automation Products AB -14c6 Data Race Inc -14c7 Modular Technology Holdings Ltd -14c8 Turbocomm Tech. Inc. -14c9 ODIN Telesystems Inc -14ca PE Logic Corp. -14cb Billionton Systems Inc -14cc NAKAYO Telecommunications Inc -14cd Universal Scientific Ind. -14ce Whistle Communications -14cf TEK Microsystems Inc. -14d0 Ericsson Axe R & D -14d1 Computer Hi-Tech Co Ltd -14d2 Titan Electronics Inc - 8001 VScom 010L 1 port parallel adaptor - 8002 VScom 020L 2 port parallel adaptor - 8010 VScom 100L 1 port serial adaptor - 8011 VScom 110L 1 port serial and 1 port parallel adaptor - 8020 VScom 200L 1 port serial adaptor - 8021 VScom 210L 2 port serial and 1 port parallel adaptor - 8040 VScom 400L 4 port serial adaptor - 8080 VScom 800L 8 port serial adaptor - a000 VScom 010H 1 port parallel adaptor - a001 VScom 100H 1 port serial adaptor - a003 VScom 400H 4 port serial adaptor - a004 VScom 400HF1 4 port serial adaptor - a005 VScom 200H 2 port serial adaptor - e001 VScom 010HV2 1 port parallel adaptor - e010 VScom 100HV2 1 port serial adaptor - e020 VScom 200HV2 2 port serial adaptor -14d3 CIRTECH (UK) Ltd -14d4 Panacom Technology Corp -14d5 Nitsuko Corporation -14d6 Accusys Inc -14d7 Hirakawa Hewtech Corp -14d8 HOPF Elektronik GmBH -# Formerly SiPackets, Inc., formerly API NetWorks, Inc., formerly Alpha Processor, Inc. -14d9 Alliance Semiconductor Corporation - 0010 AP1011/SP1011 HyperTransport-PCI Bridge [Sturgeon] - 9000 AS90L10204/10208 HyperTransport to PCI-X Bridge -14da National Aerospace Laboratories -14db AFAVLAB Technology Inc - 2120 TK9902 -14dc Amplicon Liveline Ltd - 0000 PCI230 - 0001 PCI242 - 0002 PCI244 - 0003 PCI247 - 0004 PCI248 - 0005 PCI249 - 0006 PCI260 - 0007 PCI224 - 0008 PCI234 - 0009 PCI236 - 000a PCI272 - 000b PCI215 -14dd Boulder Design Labs Inc -14de Applied Integration Corporation -14df ASIC Communications Corp -14e1 INVERTEX -14e2 INFOLIBRIA -14e3 AMTELCO -14e4 Broadcom Corporation - 0800 Sentry5 Chipcommon I/O Controller - 0804 Sentry5 PCI Bridge - 0805 Sentry5 MIPS32 CPU - 0806 Sentry5 Ethernet Controller - 080b Sentry5 Crypto Accelerator - 080f Sentry5 DDR/SDR RAM Controller - 0811 Sentry5 External Interface Core - 0816 BCM3302 Sentry5 MIPS32 CPU - 1600 NetXtreme BCM5752 Gigabit Ethernet PCI Express - 1644 NetXtreme BCM5700 Gigabit Ethernet - 1014 0277 Broadcom Vigil B5700 1000Base-T - 1028 00d1 Broadcom BCM5700 - 1028 0106 Broadcom BCM5700 - 1028 0109 Broadcom BCM5700 1000Base-T - 1028 010a Broadcom BCM5700 1000BaseTX - 10b7 1000 3C996-T 1000Base-T - 10b7 1001 3C996B-T 1000Base-T - 10b7 1002 3C996C-T 1000Base-T - 10b7 1003 3C997-T 1000Base-T Dual Port - 10b7 1004 3C996-SX 1000Base-SX - 10b7 1005 3C997-SX 1000Base-SX Dual Port - 10b7 1008 3C942 Gigabit LOM (31X31) - 14e4 0002 NetXtreme 1000Base-SX - 14e4 0003 NetXtreme 1000Base-SX - 14e4 0004 NetXtreme 1000Base-T - 14e4 1028 NetXtreme 1000BaseTX - 14e4 1644 BCM5700 1000Base-T - 1645 NetXtreme BCM5701 Gigabit Ethernet - 0e11 007c NC7770 Gigabit Server Adapter (PCI-X, 10/100/1000-T) - 0e11 007d NC6770 Gigabit Server Adapter (PCI-X, 1000-SX) - 0e11 0085 NC7780 Gigabit Server Adapter (embedded, WOL) - 0e11 0099 NC7780 Gigabit Server Adapter (embedded, WOL) - 0e11 009a NC7770 Gigabit Server Adapter (PCI-X, 10/100/1000-T) - 0e11 00c1 NC6770 Gigabit Server Adapter (PCI-X, 1000-SX) - 1028 0121 Broadcom BCM5701 1000Base-T - 103c 128a HP 1000Base-T (PCI) [A7061A] - 103c 128b HP 1000Base-SX (PCI) [A7073A] - 103c 12a4 HP Core Lan 1000Base-T - 103c 12c1 HP IOX Core Lan 1000Base-T [A7109AX] - 10a9 8010 SGI IO9 Gigabit Ethernet (Copper) - 10a9 8011 SGI Gigabit Ethernet (Copper) - 10a9 8012 SGI Gigabit Ethernet (Fiber) - 10b7 1004 3C996-SX 1000Base-SX - 10b7 1006 3C996B-T 1000Base-T - 10b7 1007 3C1000-T 1000Base-T - 10b7 1008 3C940-BR01 1000Base-T - 14e4 0001 BCM5701 1000Base-T - 14e4 0005 BCM5701 1000Base-T - 14e4 0006 BCM5701 1000Base-T - 14e4 0007 BCM5701 1000Base-SX - 14e4 0008 BCM5701 1000Base-T - 14e4 8008 BCM5701 1000Base-T - 1646 NetXtreme BCM5702 Gigabit Ethernet - 0e11 00bb NC7760 1000BaseTX - 1028 0126 Broadcom BCM5702 1000BaseTX - 14e4 8009 BCM5702 1000BaseTX - 1647 NetXtreme BCM5703 Gigabit Ethernet - 0e11 0099 NC7780 1000BaseTX - 0e11 009a NC7770 1000BaseTX - 10a9 8010 SGI IO9 Gigabit Ethernet (Copper) - 14e4 0009 BCM5703 1000BaseTX - 14e4 000a BCM5703 1000BaseSX - 14e4 000b BCM5703 1000BaseTX - 14e4 8009 BCM5703 1000BaseTX - 14e4 800a BCM5703 1000BaseTX - 1648 NetXtreme BCM5704 Gigabit Ethernet - 0e11 00cf NC7772 Gigabit Server Adapter (PCI-X, 10,100,1000-T) - 0e11 00d0 NC7782 Gigabit Server Adapter (PCI-X, 10,100,1000-T) - 0e11 00d1 NC7783 Gigabit Server Adapter (PCI-X, 10,100,1000-T) - 10b7 2000 3C998-T Dual Port 10/100/1000 PCI-X - 10b7 3000 3C999-T Quad Port 10/100/1000 PCI-X - 1166 1648 NetXtreme CIOB-E 1000Base-T - 164a NetXtreme II BCM5706 Gigabit Ethernet - 164d NetXtreme BCM5702FE Gigabit Ethernet - 1653 NetXtreme BCM5705 Gigabit Ethernet - 0e11 00e3 NC7761 Gigabit Server Adapter - 1654 NetXtreme BCM5705_2 Gigabit Ethernet - 0e11 00e3 NC7761 Gigabit Server Adapter - 103c 3100 NC1020 HP ProLiant Gigabit Server Adapter 32 PCI - 1659 NetXtreme BCM5721 Gigabit Ethernet PCI Express - 165d NetXtreme BCM5705M Gigabit Ethernet - 165e NetXtreme BCM5705M_2 Gigabit Ethernet - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 166e 570x 10/100 Integrated Controller - 1677 NetXtreme BCM5751 Gigabit Ethernet PCI Express - 1028 0179 Optiplex GX280 - 167d NetXtreme BCM5751M Gigabit Ethernet PCI Express - 167e NetXtreme BCM5751F Fast Ethernet PCI Express - 1696 NetXtreme BCM5782 Gigabit Ethernet - 103c 12bc HP d530 CMT (DG746A) - 14e4 000d NetXtreme BCM5782 1000Base-T - 169c NetXtreme BCM5788 Gigabit Ethernet - 169d NetLink BCM5789 Gigabit Ethernet PCI Express - 16a6 NetXtreme BCM5702X Gigabit Ethernet - 0e11 00bb NC7760 Gigabit Server Adapter (PCI-X, 10/100/1000-T) - 1028 0126 BCM5702 1000Base-T - 14e4 000c BCM5702 1000Base-T - 14e4 8009 BCM5702 1000Base-T - 16a7 NetXtreme BCM5703X Gigabit Ethernet - 0e11 00ca NC7771 Gigabit Server Adapter (PCI-X, 10,100,1000-T) - 0e11 00cb NC7781 Gigabit Server Adapter (PCI-X, 10,100,1000-T) - 14e4 0009 NetXtreme BCM5703 1000Base-T - 14e4 000a NetXtreme BCM5703 1000Base-SX - 14e4 000b NetXtreme BCM5703 1000Base-T - 14e4 800a NetXtreme BCM5703 1000Base-T - 16a8 NetXtreme BCM5704S Gigabit Ethernet - 10b7 2001 3C998-SX Dual Port 1000-SX PCI-X - 16aa NetXtreme II BCM5706S Gigabit Ethernet - 16c6 NetXtreme BCM5702A3 Gigabit Ethernet - 10b7 1100 3C1000B-T 10/100/1000 PCI - 14e4 000c BCM5702 1000Base-T - 14e4 8009 BCM5702 1000Base-T - 16c7 NetXtreme BCM5703 Gigabit Ethernet - 0e11 00ca NC7771 Gigabit Server Adapter (PCI-X, 10,100,1000-T) - 0e11 00cb NC7781 Gigabit Server Adapter (PCI-X, 10,100,1000-T) - 103c 12c3 HP Combo FC/GigE-SX [A9782A] - 103c 12ca HP Combo FC/GigE-T [A9784A] - 14e4 0009 NetXtreme BCM5703 1000Base-T - 14e4 000a NetXtreme BCM5703 1000Base-SX - 16dd NetLink BCM5781 Gigabit Ethernet PCI Express - 16f7 NetXtreme BCM5753 Gigabit Ethernet PCI Express - 16fd NetXtreme BCM5753M Gigabit Ethernet PCI Express - 16fe NetXtreme BCM5753F Fast Ethernet PCI Express - 170c BCM4401-B0 100Base-TX - 170d NetXtreme BCM5901 100Base-TX - 1014 0545 ThinkPad R40e (2684-HVG) builtin ethernet controller - 170e NetXtreme BCM5901 100Base-TX - 3352 BCM3352 - 3360 BCM3360 - 4210 BCM4210 iLine10 HomePNA 2.0 - 4211 BCM4211 iLine10 HomePNA 2.0 + V.90 56k modem - 4212 BCM4212 v.90 56k modem - 4301 BCM4303 802.11b Wireless LAN Controller - 1028 0407 TrueMobile 1180 Onboard WLAN - 1043 0120 WL-103b Wireless LAN PC Card - 4305 BCM4307 V.90 56k Modem - 4306 BCM4307 Ethernet Controller - 4307 BCM4307 802.11b Wireless LAN Controller - 4310 BCM4310 Chipcommon I/OController - 4312 BCM4310 UART - 4313 BCM4310 Ethernet Controller - 4315 BCM4310 USB Controller - 4320 BCM4306 802.11b/g Wireless LAN Controller - 1028 0001 TrueMobile 1300 WLAN Mini-PCI Card - 1028 0003 Wireless 1350 WLAN Mini-PCI Card - 1043 100f WL-100G - 14e4 4320 Linksys WMP54G PCI - 1737 4320 WPC54G - 1799 7010 Belkin F5D7010 54g Wireless Network card - 4321 BCM4306 802.11a Wireless LAN Controller - 4322 BCM4306 UART - 4324 BCM4309 802.11a/b/g - 1028 0001 Truemobile 1400 - 1028 0003 Truemobile 1450 MiniPCI - 4325 BCM43xG 802.11b/g - 1414 0003 Wireless Notebook Adapter MN-720 - 1414 0004 Wireless PCI Adapter MN-730 -# probably this is a correct ID... - 4326 BCM4307 Chipcommon I/O Controller? - 4401 BCM4401 100Base-T - 1043 80a8 A7V8X motherboard - 4402 BCM4402 Integrated 10/100BaseT - 4403 BCM4402 V.90 56k Modem - 4410 BCM4413 iLine32 HomePNA 2.0 - 4411 BCM4413 V.90 56k modem - 4412 BCM4412 10/100BaseT - 4430 BCM44xx CardBus iLine32 HomePNA 2.0 - 4432 BCM4432 CardBus 10/100BaseT - 4610 BCM4610 Sentry5 PCI to SB Bridge - 4611 BCM4610 Sentry5 iLine32 HomePNA 1.0 - 4612 BCM4610 Sentry5 V.90 56k Modem - 4613 BCM4610 Sentry5 Ethernet Controller - 4614 BCM4610 Sentry5 External Interface - 4615 BCM4610 Sentry5 USB Controller - 4704 BCM4704 PCI to SB Bridge - 4705 BCM4704 Sentry5 802.11b Wireless LAN Controller - 4706 BCM4704 Sentry5 Ethernet Controller - 4707 BCM4704 Sentry5 USB Controller - 4708 BCM4704 Crypto Accelerator - 4710 BCM4710 Sentry5 PCI to SB Bridge - 4711 BCM47xx Sentry5 iLine32 HomePNA 2.0 - 4712 BCM47xx V.92 56k modem - 4713 Sentry5 Ethernet Controller - 4714 BCM47xx Sentry5 External Interface - 4715 Sentry5 USB Controller - 4716 BCM47xx Sentry5 USB Host Controller - 4717 BCM47xx Sentry5 USB Device Controller - 4718 Sentry5 Crypto Accelerator - 4720 BCM4712 MIPS CPU - 5365 BCM5365P Sentry5 Host Bridge - 5600 BCM5600 StrataSwitch 24+2 Ethernet Switch Controller - 5605 BCM5605 StrataSwitch 24+2 Ethernet Switch Controller - 5615 BCM5615 StrataSwitch 24+2 Ethernet Switch Controller - 5625 BCM5625 StrataSwitch 24+2 Ethernet Switch Controller - 5645 BCM5645 StrataSwitch 24+2 Ethernet Switch Controller - 5670 BCM5670 8-Port 10GE Ethernet Switch Fabric - 5680 BCM5680 G-Switch 8 Port Gigabit Ethernet Switch Controller - 5690 BCM5690 12-port Multi-Layer Gigabit Ethernet Switch - 5691 BCM5691 GE/10GE 8+2 Gigabit Ethernet Switch Controller - 5820 BCM5820 Crypto Accelerator - 5821 BCM5821 Crypto Accelerator - 5822 BCM5822 Crypto Accelerator - 5823 BCM5823 Crypto Accelerator - 5824 BCM5824 Crypto Accelerator - 5840 BCM5840 Crypto Accelerator - 5841 BCM5841 Crypto Accelerator - 5850 BCM5850 Crypto Accelerator -14e5 Pixelfusion Ltd -14e6 SHINING Technology Inc -14e7 3CX -14e8 RAYCER Inc -14e9 GARNETS System CO Ltd -14ea Planex Communications, Inc - ab06 FNW-3603-TX CardBus Fast Ethernet - ab07 RTL81xx RealTek Ethernet -14eb SEIKO EPSON Corp -14ec ACQIRIS -14ed DATAKINETICS Ltd -14ee MASPRO KENKOH Corp -14ef CARRY Computer ENG. CO Ltd -14f0 CANON RESEACH CENTRE FRANCE -14f1 Conexant - 1002 HCF 56k Modem - 1003 HCF 56k Modem - 1004 HCF 56k Modem - 1005 HCF 56k Modem - 1006 HCF 56k Modem - 1022 HCF 56k Modem - 1023 HCF 56k Modem - 1024 HCF 56k Modem - 1025 HCF 56k Modem - 1026 HCF 56k Modem - 1032 HCF 56k Modem - 1033 HCF 56k Data/Fax Modem - 1033 8077 NEC - 122d 4027 Dell Zeus - MDP3880-W(B) Data Fax Modem - 122d 4030 Dell Mercury - MDP3880-U(B) Data Fax Modem - 122d 4034 Dell Thor - MDP3880-W(U) Data Fax Modem - 13e0 020d Dell Copper - 13e0 020e Dell Silver - 13e0 0261 IBM - 13e0 0290 Compaq Goldwing - 13e0 02a0 IBM - 13e0 02b0 IBM - 13e0 02c0 Compaq Scooter - 13e0 02d0 IBM - 144f 1500 IBM P85-DF (1) - 144f 1501 IBM P85-DF (2) - 144f 150a IBM P85-DF (3) - 144f 150b IBM P85-DF Low Profile (1) - 144f 1510 IBM P85-DF Low Profile (2) - 1034 HCF 56k Data/Fax/Voice Modem - 1035 HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem - 10cf 1098 Fujitsu P85-DFSV - 1036 HCF 56k Data/Fax/Voice/Spkp Modem - 104d 8067 HCF 56k Modem - 122d 4029 MDP3880SP-W - 122d 4031 MDP3880SP-U - 13e0 0209 Dell Titanium - 13e0 020a Dell Graphite - 13e0 0260 Gateway Red Owl - 13e0 0270 Gateway White Horse - 1052 HCF 56k Data/Fax Modem (Worldwide) - 1053 HCF 56k Data/Fax Modem (Worldwide) - 1054 HCF 56k Data/Fax/Voice Modem (Worldwide) - 1055 HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem (Worldwide) - 1056 HCF 56k Data/Fax/Voice/Spkp Modem (Worldwide) - 1057 HCF 56k Data/Fax/Voice/Spkp Modem (Worldwide) - 1059 HCF 56k Data/Fax/Voice Modem (Worldwide) - 1063 HCF 56k Data/Fax Modem - 1064 HCF 56k Data/Fax/Voice Modem - 1065 HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem - 1066 HCF 56k Data/Fax/Voice/Spkp Modem - 122d 4033 Dell Athena - MDP3900V-U - 1433 HCF 56k Data/Fax Modem - 1434 HCF 56k Data/Fax/Voice Modem - 1435 HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem - 1436 HCF 56k Data/Fax Modem - 1453 HCF 56k Data/Fax Modem - 13e0 0240 IBM - 13e0 0250 IBM - 144f 1502 IBM P95-DF (1) - 144f 1503 IBM P95-DF (2) - 1454 HCF 56k Data/Fax/Voice Modem - 1455 HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem - 1456 HCF 56k Data/Fax/Voice/Spkp Modem - 122d 4035 Dell Europa - MDP3900V-W - 122d 4302 Dell MP3930V-W(C) MiniPCI - 1610 ADSL AccessRunner PCI Arbitration Device - 1611 AccessRunner PCI ADSL Interface Device - 1620 ADSL AccessRunner V2 PCI Arbitration Device - 1621 AccessRunner V2 PCI ADSL Interface Device - 1622 AccessRunner V2 PCI ADSL Yukon WAN Adapter - 1803 HCF 56k Modem - 0e11 0023 623-LAN Grizzly - 0e11 0043 623-LAN Yogi - 1815 HCF 56k Modem - 0e11 0022 Grizzly - 0e11 0042 Yogi - 2003 HSF 56k Data/Fax Modem - 2004 HSF 56k Data/Fax/Voice Modem - 2005 HSF 56k Data/Fax/Voice/Spkp (w/Handset) Modem - 2006 HSF 56k Data/Fax/Voice/Spkp Modem - 2013 HSF 56k Data/Fax Modem - 0e11 b195 Bear - 0e11 b196 Seminole 1 - 0e11 b1be Seminole 2 - 1025 8013 Acer - 1033 809d NEC - 1033 80bc NEC - 155d 6793 HP - 155d 8850 E Machines - 2014 HSF 56k Data/Fax/Voice Modem - 2015 HSF 56k Data/Fax/Voice/Spkp (w/Handset) Modem - 2016 HSF 56k Data/Fax/Voice/Spkp Modem - 2043 HSF 56k Data/Fax Modem (WorldW SmartDAA) - 2044 HSF 56k Data/Fax/Voice Modem (WorldW SmartDAA) - 2045 HSF 56k Data/Fax/Voice/Spkp (w/Handset) Modem (WorldW SmartDAA) - 2046 HSF 56k Data/Fax/Voice/Spkp Modem (WorldW SmartDAA) - 2063 HSF 56k Data/Fax Modem (SmartDAA) - 2064 HSF 56k Data/Fax/Voice Modem (SmartDAA) - 2065 HSF 56k Data/Fax/Voice/Spkp (w/Handset) Modem (SmartDAA) - 2066 HSF 56k Data/Fax/Voice/Spkp Modem (SmartDAA) - 2093 HSF 56k Modem - 155d 2f07 Legend - 2143 HSF 56k Data/Fax/Cell Modem (Mob WorldW SmartDAA) - 2144 HSF 56k Data/Fax/Voice/Cell Modem (Mob WorldW SmartDAA) - 2145 HSF 56k Data/Fax/Voice/Spkp (w/HS)/Cell Modem (Mob WorldW SmartDAA) - 2146 HSF 56k Data/Fax/Voice/Spkp/Cell Modem (Mob WorldW SmartDAA) - 2163 HSF 56k Data/Fax/Cell Modem (Mob SmartDAA) - 2164 HSF 56k Data/Fax/Voice/Cell Modem (Mob SmartDAA) - 2165 HSF 56k Data/Fax/Voice/Spkp (w/HS)/Cell Modem (Mob SmartDAA) - 2166 HSF 56k Data/Fax/Voice/Spkp/Cell Modem (Mob SmartDAA) - 2343 HSF 56k Data/Fax CardBus Modem (Mob WorldW SmartDAA) - 2344 HSF 56k Data/Fax/Voice CardBus Modem (Mob WorldW SmartDAA) - 2345 HSF 56k Data/Fax/Voice/Spkp (w/HS) CardBus Modem (Mob WorldW SmartDAA) - 2346 HSF 56k Data/Fax/Voice/Spkp CardBus Modem (Mob WorldW SmartDAA) - 2363 HSF 56k Data/Fax CardBus Modem (Mob SmartDAA) - 2364 HSF 56k Data/Fax/Voice CardBus Modem (Mob SmartDAA) - 2365 HSF 56k Data/Fax/Voice/Spkp (w/HS) CardBus Modem (Mob SmartDAA) - 2366 HSF 56k Data/Fax/Voice/Spkp CardBus Modem (Mob SmartDAA) - 2443 HSF 56k Data/Fax Modem (Mob WorldW SmartDAA) - 104d 8075 Modem - 104d 8083 Modem - 104d 8097 Modem - 2444 HSF 56k Data/Fax/Voice Modem (Mob WorldW SmartDAA) - 2445 HSF 56k Data/Fax/Voice/Spkp (w/HS) Modem (Mob WorldW SmartDAA) - 2446 HSF 56k Data/Fax/Voice/Spkp Modem (Mob WorldW SmartDAA) - 2463 HSF 56k Data/Fax Modem (Mob SmartDAA) - 2464 HSF 56k Data/Fax/Voice Modem (Mob SmartDAA) - 2465 HSF 56k Data/Fax/Voice/Spkp (w/HS) Modem (Mob SmartDAA) - 2466 HSF 56k Data/Fax/Voice/Spkp Modem (Mob SmartDAA) - 2f00 HSF 56k HSFi Modem - 13e0 8d84 IBM HSFi V.90 - 13e0 8d85 Compaq Stinger - 14f1 2004 Dynalink 56PMi - 2f02 HSF 56k HSFi Data/Fax - 2f11 HSF 56k HSFi Modem - 8234 RS8234 ATM SAR Controller [ServiceSAR Plus] - 8800 CX22702 DVB-T 2k/8k - 17de 08a1 XPert DVB-T PCI BDA DVBT 23880 Video Capture - 8802 CX23883 Broadcast Decoder - 17de 08a1 Xpert DVB-T PCI 2388x Transport Stream Capture -14f2 MOBILITY Electronics - 0120 EV1000 bridge - 0121 EV1000 Parallel port - 0122 EV1000 Serial port - 0123 EV1000 Keyboard controller - 0124 EV1000 Mouse controller -14f3 BroadLogic - 2030 2030 DVB-S Satellite Reciever - 2050 2050 DVB-T Terrestrial (Cable) Reciever - 2060 2060 ATSC Terrestrial (Cable) Reciever -14f4 TOKYO Electronic Industry CO Ltd -14f5 SOPAC Ltd -14f6 COYOTE Technologies LLC -14f7 WOLF Technology Inc -14f8 AUDIOCODES Inc - 2077 TP-240 dual span E1 VoIP PCI card -14f9 AG COMMUNICATIONS -14fa WANDEL & GOCHERMANN -14fb TRANSAS MARINE (UK) Ltd -14fc Quadrics Ltd - 0000 QsNet Elan3 Network Adapter - 0001 QsNetII Elan4 Network Adapter -14fd JAPAN Computer Industry Inc -14fe ARCHTEK TELECOM Corp -14ff TWINHEAD INTERNATIONAL Corp -1500 DELTA Electronics, Inc - 1360 RTL81xx RealTek Ethernet -1501 BANKSOFT CANADA Ltd -1502 MITSUBISHI ELECTRIC LOGISTICS SUPPORT Co Ltd -1503 KAWASAKI LSI USA Inc -1504 KAISER Electronics -1505 ITA INGENIEURBURO FUR TESTAUFGABEN GmbH -1506 CHAMELEON Systems Inc -# Should be HTEC Ltd, but there are no known HTEC chips and 1507 is already used by mistake by Motorola (see vendor ID 1057). -1507 Motorola ?? / HTEC - 0001 MPC105 [Eagle] - 0002 MPC106 [Grackle] - 0003 MPC8240 [Kahlua] - 0100 MC145575 [HFC-PCI] - 0431 KTI829c 100VG - 4801 Raven - 4802 Falcon - 4803 Hawk - 4806 CPX8216 -1508 HONDA CONNECTORS/MHOTRONICS Inc -1509 FIRST INTERNATIONAL Computer Inc -150a FORVUS RESEARCH Inc -150b YAMASHITA Systems Corp -150c KYOPAL CO Ltd -150d WARPSPPED Inc -150e C-PORT Corp -150f INTEC GmbH -1510 BEHAVIOR TECH Computer Corp -1511 CENTILLIUM Technology Corp -1512 ROSUN Technologies Inc -1513 Raychem -1514 TFL LAN Inc -1515 Advent design -1516 MYSON Technology Inc - 0800 MTD-8xx 100/10M Ethernet PCI Adapter - 0803 SURECOM EP-320X-S 100/10M Ethernet PCI Adapter - 1320 10bd SURECOM EP-320X-S 100/10M Ethernet PCI Adapter - 0891 MTD-8xx 100/10M Ethernet PCI Adapter -1517 ECHOTEK Corp -1518 PEP MODULAR Computers GmbH -1519 TELEFON AKTIEBOLAGET LM Ericsson -151a Globetek - 1002 PCI-1002 - 1004 PCI-1004 - 1008 PCI-1008 -151b COMBOX Ltd -151c DIGITAL AUDIO LABS Inc - 0003 Prodif T 2496 - 4000 Prodif 88 -151d Fujitsu Computer Products Of America -151e MATRIX Corp -151f TOPIC SEMICONDUCTOR Corp - 0000 TP560 Data/Fax/Voice 56k modem -1520 CHAPLET System Inc -1521 BELL Corp -1522 MainPine Ltd - 0100 PCI <-> IOBus Bridge - 1522 0200 RockForceDUO 2 Port V.92/V.44 Data/Fax/Voice Modem - 1522 0300 RockForceQUATRO 4 Port V.92/V.44 Data/Fax/Voice Modem - 1522 0400 RockForceDUO+ 2 Port V.92/V.44 Data/Fax/Voice Modem - 1522 0500 RockForceQUATRO+ 4 Port V.92/V.44 Data/Fax/Voice Modem - 1522 0600 RockForce+ 2 Port V.90 Data/Fax/Voice Modem - 1522 0700 RockForce+ 4 Port V.90 Data/Fax/Voice Modem - 1522 0800 RockForceOCTO+ 8 Port V.92/V.44 Data/Fax/Voice Modem - 1522 0c00 RockForceDUO+ 2 Port V.92/V.44 Data, V.34 Super-G3 Fax, Voice Modem - 1522 0d00 RockForceQUATRO+ 4 Port V.92/V.44 Data, V.34 Super-G3 Fax, Voice Modem -# this is a correction to a recent entry. 1522:0E00 should be 1522:1D00 - 1522 1d00 RockForceOCTO+ 8 Port V.92/V.44 Data, V.34 Super-G3 Fax, Voice Modem -1523 MUSIC Semiconductors -1524 ENE Technology Inc - 0510 CB710 Memory Card Reader Controller - 0610 PCI Smart Card Reader Controller - 1211 CB1211 Cardbus Controller - 1225 CB1225 Cardbus Controller - 1410 CB1410 Cardbus Controller - 1025 005a TravelMate 290 - 1411 CB-710/2/4 Cardbus Controller - 1412 CB-712/4 Cardbus Controller - 1420 CB1420 Cardbus Controller - 1421 CB-720/2/4 Cardbus Controller - 1422 CB-722/4 Cardbus Controller -1525 IMPACT Technologies -1526 ISS, Inc -1527 SOLECTRON -1528 ACKSYS -1529 AMERICAN MICROSystems Inc -152a QUICKTURN DESIGN Systems -152b FLYTECH Technology CO Ltd -152c MACRAIGOR Systems LLC -152d QUANTA Computer Inc -152e MELEC Inc -152f PHILIPS - CRYPTO -1530 ACQIS Technology Inc -1531 CHRYON Corp -1532 ECHELON Corp -1533 BALTIMORE -1534 ROAD Corp -1535 EVERGREEN Technologies Inc -1537 DATALEX COMMUNCATIONS -1538 ARALION Inc - 0303 ARS106S Ultra ATA 133/100/66 Host Controller -1539 ATELIER INFORMATIQUES et ELECTRONIQUE ETUDES S.A. -153a ONO SOKKI -153b TERRATEC Electronic GmbH - 1144 Aureon 5.1 -# Terratec seems to use several IDs for the same card. - 1147 Aureon 5.1 Sky - 1158 Philips Semiconductors SAA7134 (rev 01) [Terratec Cinergy 600 TV] -153c ANTAL Electronic -153d FILANET Corp -153e TECHWELL Inc -153f MIPS DENMARK -1540 PROVIDEO MULTIMEDIA Co Ltd -1541 MACHONE Communications -1542 VIVID Technology Inc -1543 SILICON Laboratories - 3052 Intel 537 [Winmodem] - 4c22 Si3036 MC'97 DAA -1544 DCM DATA Systems -1545 VISIONTEK -1546 IOI Technology Corp -1547 MITUTOYO Corp -1548 JET PROPULSION Laboratory -1549 INTERCONNECT Systems Solutions -154a MAX Technologies Inc -154b COMPUTEX Co Ltd -154c VISUAL Technology Inc -154d PAN INTERNATIONAL Industrial Corp -154e SERVOTEST Ltd -154f STRATABEAM Technology -1550 OPEN NETWORK Co Ltd -1551 SMART Electronic DEVELOPMENT GmBH -1552 RACAL AIRTECH Ltd -1553 CHICONY Electronics Co Ltd -1554 PROLINK Microsystems Corp -1555 GESYTEC GmBH -1556 PLD APPLICATIONS -1557 MEDIASTAR Co Ltd -1558 CLEVO/KAPOK Computer -1559 SI LOGIC Ltd -155a INNOMEDIA Inc -155b PROTAC INTERNATIONAL Corp -155c Cemax-Icon Inc -155d Mac System Co Ltd -155e LP Elektronik GmbH -155f Perle Systems Ltd -1560 Terayon Communications Systems -1561 Viewgraphics Inc -1562 Symbol Technologies -1563 A-Trend Technology Co Ltd -1564 Yamakatsu Electronics Industry Co Ltd -1565 Biostar Microtech Int'l Corp -1566 Ardent Technologies Inc -1567 Jungsoft -1568 DDK Electronics Inc -1569 Palit Microsystems Inc. -156a Avtec Systems -156b 2wire Inc -156c Vidac Electronics GmbH -156d Alpha-Top Corp -156e Alfa Inc -156f M-Systems Flash Disk Pioneers Ltd -1570 Lecroy Corp -1571 Contemporary Controls - a001 CCSI PCI20-485 ARCnet - a002 CCSI PCI20-485D ARCnet - a003 CCSI PCI20-485X ARCnet - a004 CCSI PCI20-CXB ARCnet - a005 CCSI PCI20-CXS ARCnet - a006 CCSI PCI20-FOG-SMA ARCnet - a007 CCSI PCI20-FOG-ST ARCnet - a008 CCSI PCI20-TB5 ARCnet - a009 CCSI PCI20-5-485 5Mbit ARCnet - a00a CCSI PCI20-5-485D 5Mbit ARCnet - a00b CCSI PCI20-5-485X 5Mbit ARCnet - a00c CCSI PCI20-5-FOG-ST 5Mbit ARCnet - a00d CCSI PCI20-5-FOG-SMA 5Mbit ARCnet - a201 CCSI PCI22-485 10Mbit ARCnet - a202 CCSI PCI22-485D 10Mbit ARCnet - a203 CCSI PCI22-485X 10Mbit ARCnet - a204 CCSI PCI22-CHB 10Mbit ARCnet - a205 CCSI PCI22-FOG_ST 10Mbit ARCnet - a206 CCSI PCI22-THB 10Mbit ARCnet -1572 Otis Elevator Company -1573 Lattice - Vantis -1574 Fairchild Semiconductor -1575 Voltaire Advanced Data Security Ltd -1576 Viewcast COM -1578 HITT - 5615 VPMK3 [Video Processor Mk III] -1579 Dual Technology Corp -157a Japan Elecronics Ind Inc -157b Star Multimedia Corp -157c Eurosoft (UK) - 8001 Fix2000 PCI Y2K Compliance Card -157d Gemflex Networks -157e Transition Networks -157f PX Instruments Technology Ltd -1580 Primex Aerospace Co -1581 SEH Computertechnik GmbH -1582 Cytec Corp -1583 Inet Technologies Inc -1584 Uniwill Computer Corp -1585 Logitron -1586 Lancast Inc -1587 Konica Corp -1588 Solidum Systems Corp -1589 Atlantek Microsystems Pty Ltd -158a Digalog Systems Inc -158b Allied Data Technologies -158c Hitachi Semiconductor & Devices Sales Co Ltd -158d Point Multimedia Systems -158e Lara Technology Inc -158f Ditect Coop -1590 3pardata Inc -1591 ARN -1592 Syba Tech Ltd - 0781 Multi-IO Card - 0782 Parallel Port Card 2xEPP - 0783 Multi-IO Card - 0785 Multi-IO Card - 0786 Multi-IO Card - 0787 Multi-IO Card - 0788 Multi-IO Card - 078a Multi-IO Card -1593 Bops Inc -1594 Netgame Ltd -1595 Diva Systems Corp -1596 Folsom Research Inc -1597 Memec Design Services -1598 Granite Microsystems -1599 Delta Electronics Inc -159a General Instrument -159b Faraday Technology Corp -159c Stratus Computer Systems -159d Ningbo Harrison Electronics Co Ltd -159e A-Max Technology Co Ltd -159f Galea Network Security -15a0 Compumaster SRL -15a1 Geocast Network Systems -15a2 Catalyst Enterprises Inc - 0001 TA700 PCI Bus Analyzer/Exerciser -15a3 Italtel -15a4 X-Net OY -15a5 Toyota Macs Inc -15a6 Sunlight Ultrasound Technologies Ltd -15a7 SSE Telecom Inc -15a8 Shanghai Communications Technologies Center -15aa Moreton Bay -15ab Bluesteel Networks Inc -15ac North Atlantic Instruments -15ad VMware Inc - 0405 [VMware SVGA II] PCI Display Adapter - 0710 Virtual SVGA - 0720 VMware High-Speed Virtual NIC [vmxnet] -15ae Amersham Pharmacia Biotech -15b0 Zoltrix International Ltd -15b1 Source Technology Inc -15b2 Mosaid Technologies Inc -15b3 Mellanox Technologies - 5274 MT21108 InfiniBridge - 5a44 MT23108 InfiniHost - 5a45 MT23108 [Infinihost HCA Flash Recovery] - 5a46 MT23108 PCI Bridge - 5e8c MT24204 [InfiniHost III Lx HCA] - 5e8d MT24204 [InfiniHost III Lx HCA Flash Recovery] - 6278 MT25208 InfiniHost III Ex (Tavor compatibility mode) - 6279 MT25208 [InfiniHost III Ex HCA Flash Recovery] - 6282 MT25208 InfiniHost III Ex -15b4 CCI/TRIAD -15b5 Cimetrics Inc -15b6 Texas Memory Systems Inc -15b7 Sandisk Corp -15b8 ADDI-DATA GmbH -15b9 Maestro Digital Communications -15ba Impacct Technology Corp -15bb Portwell Inc -15bc Agilent Technologies - 2922 64 Bit, 133MHz PCI-X Exerciser & Protocol Checker - 2928 64 Bit, 66MHz PCI Exerciser & Analyzer - 2929 64 Bit, 133MHz PCI-X Analyzer & Exerciser -15bd DFI Inc -15be Sola Electronics -15bf High Tech Computer Corp (HTC) -15c0 BVM Ltd -15c1 Quantel -15c2 Newer Technology Inc -15c3 Taiwan Mycomp Co Ltd -15c4 EVSX Inc -15c5 Procomp Informatics Ltd - 8010 1394b - 1394 Firewire 3-Port Host Adapter Card -15c6 Technical University of Budapest -15c7 Tateyama System Laboratory Co Ltd - 0349 Tateyama C-PCI PLC/NC card Rev.01A -15c8 Penta Media Co Ltd -15c9 Serome Technology Inc -15ca Bitboys OY -15cb AG Electronics Ltd -15cc Hotrail Inc -15cd Dreamtech Co Ltd -15ce Genrad Inc -15cf Hilscher GmbH -15d1 Infineon Technologies AG -15d2 FIC (First International Computer Inc) -15d3 NDS Technologies Israel Ltd -15d4 Iwill Corp -15d5 Tatung Co -15d6 Entridia Corp -15d7 Rockwell-Collins Inc -15d8 Cybernetics Technology Co Ltd -15d9 Super Micro Computer Inc -15da Cyberfirm Inc -15db Applied Computing Systems Inc -15dc Litronic Inc - 0001 Argus 300 PCI Cryptography Module -15dd Sigmatel Inc -15de Malleable Technologies Inc -15df Infinilink Corp -15e0 Cacheflow Inc -15e1 Voice Technologies Group Inc -15e2 Quicknet Technologies Inc -15e3 Networth Technologies Inc -15e4 VSN Systemen BV -15e5 Valley technologies Inc -15e6 Agere Inc -15e7 Get Engineering Corp -15e8 National Datacomm Corp - 0130 Wireless PCI Card -15e9 Pacific Digital Corp - 1841 ADMA-100 DiscStaQ ATA Controller -15ea Tokyo Denshi Sekei K.K. -15eb Drsearch GmbH -15ec Beckhoff GmbH - 3101 FC3101 Profibus DP 1 Channel PCI - 5102 FC5102 -15ed Macrolink Inc -15ee In Win Development Inc -15ef Intelligent Paradigm Inc -15f0 B-Tree Systems Inc -15f1 Times N Systems Inc -15f2 Diagnostic Instruments Inc -15f3 Digitmedia Corp -15f4 Valuesoft -15f5 Power Micro Research -15f6 Extreme Packet Device Inc -15f7 Banctec -15f8 Koga Electronics Co -15f9 Zenith Electronics Corp -15fa J.P. Axzam Corp -15fb Zilog Inc -15fc Techsan Electronics Co Ltd -15fd N-CUBED.NET -15fe Kinpo Electronics Inc -15ff Fastpoint Technologies Inc -1600 Northrop Grumman - Canada Ltd -1601 Tenta Technology -1602 Prosys-tec Inc -1603 Nokia Wireless Communications -1604 Central System Research Co Ltd -1605 Pairgain Technologies -1606 Europop AG -1607 Lava Semiconductor Manufacturing Inc -1608 Automated Wagering International -1609 Scimetric Instruments Inc -1612 Telesynergy Research Inc. -1619 FarSite Communications Ltd - 0400 FarSync T2P (2 port X.21/V.35/V.24) - 0440 FarSync T4P (4 port X.21/V.35/V.24) -# www.rioworks.com -161f Rioworks -1626 TDK Semiconductor Corp. - 8410 RTL81xx Fast Ethernet -1629 Kongsberg Spacetec AS - 1003 Format synchronizer v3.0 - 2002 Fast Universal Data Output -# This seems to occur on their 802.11b Wireless card WMP-11 -1637 Linksys - 3874 Linksys 802.11b WMP11 PCI Wireless card -1638 Standard Microsystems Corp [SMC] - 1100 SMC2602W EZConnect / Addtron AWA-100 / Eumitcom PCI WL11000 -163c Smart Link Ltd. - 3052 SmartLink SmartPCI562 56K Modem - 5449 SmartPCI561 Modem -1657 Brocade Communications Systems, Inc. -165a Epix Inc - c100 PIXCI(R) CL1 Camera Link Video Capture Board [custom QL5232] - d200 PIXCI(R) D2X Digital Video Capture Board [custom QL5232] - d300 PIXCI(R) D3X Digital Video Capture Board [custom QL5232] -165d Hsing Tech. Enterprise Co., Ltd. -1661 Worldspace Corp. -1668 Actiontec Electronics Inc - 0100 Mini-PCI bridge -# Formerly SiByte, Inc. -166d Broadcom Corporation - 0001 SiByte BCM1125/1125H/1250 System-on-a-Chip PCI - 0002 SiByte BCM1125H/1250 System-on-a-Chip HyperTransport -1677 Bernecker + Rainer - 104e 5LS172.6 B&R Dual CAN Interface Card - 12d7 5LS172.61 B&R Dual CAN Interface Card -167b ZyDAS Technology Corp. - 2102 ZyDAS ZD1202 - 187e 3406 ZyAIR B-122 CardBus 11Mbs Wireless LAN Card -1681 Hercules -# More specs, more accurate desc. - 0010 Hercules 3d Prophet II Ultra 64MB [ 350 MHz NV15BR core, 128-bit DDR @ 460 MHz, 1.5v AGP4x ] -1682 XFX Pine Group Inc. -1688 CastleNet Technology Inc. - 1170 WLAN 802.11b card -168c Atheros Communications, Inc. - 0007 AR5000 802.11a Wireless Adapter - 0011 AR5210 802.11a NIC - 0012 AR5211 802.11ab NIC - 0013 AR5212 802.11abg NIC - 1113 d301 Philips CPWNA100 Wireless CardBus adapter - 1186 3202 D-link DWL-G650 B3 Wireless cardbus adapter - 1186 3203 DWL-G520 Wireless PCI Adapter - 1186 3a13 DWL-G520 Wireless PCI Adapter rev. B - 1186 3a94 C54C Wireless 801.11g cardbus - 1385 4d00 Netgear WG311T Wireless PCI Adapter - 14b7 0a60 8482-WD ORiNOCO 11a/b/g Wireless PCI Adapter - 168c 0013 WG511T Wireless CardBus Adapter - 168c 1025 DWL-G650B2 Wireless CardBus Adapter - 168c 1027 Netgate NL-3054CB ARIES b/g CardBus Adapter - 168c 2026 Netgate 5354MP ARIES a(108Mb turbo)/b/g MiniPCI Adapter - 168c 2041 Netgate 5354MP Plus ARIES2 b/g MiniPCI Adapter - 168c 2042 Netgate 5354MP Plus ARIES2 a/b/g MiniPCI Adapter - 1014 AR5212 802.11abg NIC -169c Netcell Corporation - 0044 SyncRAID SR3000/5000 Series SATA RAID Controllers -16a5 Tekram Technology Co.,Ltd. -16ab Global Sun Technology Inc - 1100 GL24110P - 1101 PLX9052 PCMCIA-to-PCI Wireless LAN - 1102 PCMCIA-to-PCI Wireless Network Bridge - 8501 WL-8305 Wireless LAN PCI Adapter -16ae Safenet Inc - 1141 SafeXcel-1141 -16b4 Aspex Semiconductor Ltd -16be Creatix Polymedia GmbH -16ca CENATEK Inc - 0001 Rocket Drive DL -16cd Densitron Technologies -16ce Roland Corp. -# www.pikatechnologies.com -16df PIKA Technologies Inc. -16e3 European Space Agency - 1e0f LEON2FT Processor -16ec U.S. Robotics - 00ff USR997900 10/100 Mbps PCI Network Card - 0116 USR997902 10/100/1000 Mbps PCI Network Card - 3685 Wireless Access PCI Adapter Model 022415 -16ed Sycron N. V. - 1001 UMIO communication card -16f3 Jetway Information Co., Ltd. -16f4 Vweb Corp - 8000 VW2010 -16f6 VideoTele.com, Inc. -# www.internetmachines.com -1702 Internet Machines Corporation (IMC) -1705 Digital First, Inc. -170b NetOctave - 0100 NSP2000-SSL crypto accelerator -170c YottaYotta Inc. -# Seems to be a 2nd ID for Vitesse Semiconductor -1725 Vitesse Semiconductor - 7174 VSC7174 PCI/PCI-X Serial ATA Host Bus Controller -172a Accelerated Encryption -1734 Fujitsu Siemens Computer GmbH -1737 Linksys - 0013 WMP54G Wireless Pci Card - 0015 WMP54GS Wireless Pci Card - 1032 Gigabit Network Adapter - 1737 0015 EG1032 v2 Instant Gigabit Network Adapter - 1064 Gigabit Network Adapter - 1737 0016 EG1064 v2 Instant Gigabit Network Adapter - ab08 21x4x DEC-Tulip compatible 10/100 Ethernet - ab09 21x4x DEC-Tulip compatible 10/100 Ethernet -173b Altima (nee Broadcom) - 03e8 AC1000 Gigabit Ethernet - 03e9 AC1001 Gigabit Ethernet - 03ea AC9100 Gigabit Ethernet - 173b 0001 AC1002 - 03eb AC1003 Gigabit Ethernet -1743 Peppercon AG - 8139 ROL/F-100 Fast Ethernet Adapter with ROL -1749 RLX Technologies -174b PC Partner Limited -174d WellX Telecom SA -175c AudioScience Inc -175e Sanera Systems, Inc. -1787 Hightech Information System Ltd. -# also used by Struck Innovative Systeme for joint developments -1796 Research Centre Juelich - 0001 SIS1100 [Gigabit link] - 0002 HOTlink - 0003 Counter Timer - 0004 CAMAC Controller - 0005 PROFIBUS - 0006 AMCC HOTlink -1797 JumpTec h, GMBH -1799 Belkin - 6001 Wireless PCI Card - F5D6001 - 6020 Wireless PCMCIA Card - F5D6020 - 6060 Wireless PDA Card - F5D6060 - 7000 Wireless PCI Card - F5D7000 -17a0 Genesys Logic, Inc - 8033 GL880S USB 1.1 controller - 8034 GL880S USB 2.0 controller -17af Hightech Information System Ltd. -17b3 Hawking Technologies - ab08 PN672TX 10/100 Ethernet -17b4 Indra Networks, Inc. - 0011 WebEnhance 100 GZIP Compression Card -17c0 Wistron Corp. -17c2 Newisys, Inc. -17cc NetChip Technology, Inc - 2280 USB 2.0 -17d3 Areca Technology Corp. - 1110 ARC-1110 4-Port PCI-X to SATA RAID Controller - 1120 ARC-1120 8-Port PCI-X to SATA RAID Controller - 1130 ARC-1130 12-Port PCI-X to SATA RAID Controller - 1160 ARC-1160 16-Port PCI-X to SATA RAID Controller - 1210 ARC-1210 4-Port PCI-Express to SATA RAID Controller - 1220 ARC-1220 8-Port PCI-Express to SATA RAID Controller - 1230 ARC-1230 12-Port PCI-Express to SATA RAID Controller - 1260 ARC-1260 16-Port PCI-Express to SATA RAID Controller -# S2io ships 10Gb PCI-X Ethernet adapters www.s2io.com -17d5 S2io Inc. - 5831 Xframe 10 Gigabit Ethernet PCI-X - 103c 12d5 HP PCI-X 133MHz 10GbE SR Fiber [AB287A] -17de KWorld Computer Co. Ltd. -# http://www.connect3d.com -17ee Connect Components Ltd -17fe Linksys, A Division of Cisco Systems - 2120 WMP11v4 802.11b PCI card - 2220 [AirConn] INPROCOMM IPN 2220 Wireless LAN Adapter (rev 01) -1813 Ambient Technologies Inc - 4000 HaM controllerless modem - 16be 0001 V9x HAM Data Fax Modem - 4100 HaM plus Data Fax Modem - 16be 0002 V9x HAM 1394 -1814 RaLink - 0101 Wireless PCI Adpator RT2400 / RT2460 - 3306 1113 Quidway WL100M - 0201 Ralink RT2500 802.11 Cardbus Reference Card - 1371 001e CWC-854 Wireless-G CardBus Adapter - 1371 001f CWM-854 Wireless-G Mini PCI Adapter - 1371 0020 CWP-854 Wireless-G PCI Adapter - 1458 e381 GN-WMKG 802.11b/g Wireless CardBus Adapter -1820 InfiniCon Systems Inc. -1822 Twinhan Technology Co. Ltd -182d SiteCom Europe BV -# HFC-based ISDN card - 3069 ISDN PCI DC-105V2 - 9790 WL-121 Wireless Network Adapter 100g+ [Ver.3] -1830 Credence Systems Corporation -183b MikroM GmbH - 08a7 MVC100 DVI - 08a8 MVC101 SDI - 08a9 MVC102 DVI+Audio -1849 ASRock Incorporation -1851 Microtune, Inc. -1852 Anritsu Corp. -185f Wistron NeWeb Corp. -1867 Topspin Communications - 5a44 MT23108 PCI-X HCA - 5a45 MT23108 PCI-X HCA flash recovery - 5a46 MT23108 PCI-X HCA bridge - 6278 MT25208 InfiniHost III Ex (Tavor compatibility mode) - 6282 MT25208 InfiniHost III Ex -187e ZyXEL Communication Corporation -1888 Varisys Ltd - 0301 VMFX1 FPGA PMC module - 0601 VSM2 dual PMC carrier - 0710 VS14x series PowerPC PCI board - 0720 VS24x series PowerPC PCI board -# found e.g. on KNC DVB-S card -1894 KNC One -1896 B&B Electronics Manufacturing Company, Inc. -18a1 Astute Networks Inc. -18ac DViCO Corporation - d810 FusionHDTV 3 Gold -18b8 Ammasso - b001 AMSO 1100 iWARP/RDMA Gigabit Ethernet Coprocessor -18bc Info-Tek Corp. -# assigned to Octigabay System, which has been acquired by Cray -18c8 Cray Inc -18c9 ARVOO Engineering BV -18ca XGI - Xabre Graphics Inc - 0040 Volari V8 -18e6 MPL AG - 0001 OSCI [Octal Serial Communication Interface] -18f7 Commtech, Inc. - 0001 Fastcom ESCC-PCI-335 - 0002 Fastcom 422/4-PCI-335 - 0004 Fastcom 422/2-PCI-335 - 0005 Fastcom IGESCC-PCI-ISO/1 - 000a Fastcom 232/4-PCI-335 -18fb Resilience Corporation -1924 Level 5 Networks Inc. -1966 Orad Hi-Tec Systems - 1975 DVG64 family -1993 Innominate Security Technologies AG -# http://www.progeny.net -19ae Progeny Systems Corporation -1a08 Sierra semiconductor - 0000 SC15064 -1b13 Jaton Corp -1c1c Symphony - 0001 82C101 -1d44 DPT - a400 PM2x24/PM3224 -1de1 Tekram Technology Co.,Ltd. - 0391 TRM-S1040 - 2020 DC-390 - 690c 690c - dc29 DC290 -1fc0 Tumsan Oy - 0300 E2200 Dual E1/Rawpipe Card -2000 Smart Link Ltd. -2001 Temporal Research Ltd -2003 Smart Link Ltd. -2004 Smart Link Ltd. -21c3 21st Century Computer Corp. -2348 Racore - 2010 8142 100VG/AnyLAN -2646 Kingston Technologies -270b Xantel Corporation -270f Chaintech Computer Co. Ltd -2711 AVID Technology Inc. -2a15 3D Vision(???) -3000 Hansol Electronics Inc. -3142 Post Impression Systems. -3388 Hint Corp - 0013 HiNT HC4 PCI to ISDN bridge, Multimedia audio controller - 0014 HiNT HC4 PCI to ISDN bridge, Network controller - 0020 HB6 Universal PCI-PCI bridge (transparent mode) - 0021 HB6 Universal PCI-PCI bridge (non-transparent mode) - 4c53 1050 CT7 mainboard - 4c53 1080 CT8 mainboard - 4c53 10a0 CA3/CR3 mainboard - 4c53 3010 PPCI mezzanine (32-bit PMC) - 4c53 3011 PPCI mezzanine (64-bit PMC) - 0022 HiNT HB4 PCI-PCI Bridge (PCI6150) - 0026 HB2 PCI-PCI Bridge - 101a E.Band [AudioTrak Inca88] - 101b E.Band [AudioTrak Inca88] - 8011 VXPro II Chipset - 3388 8011 VXPro II Chipset CPU to PCI Bridge - 8012 VXPro II Chipset - 3388 8012 VXPro II Chipset PCI to ISA Bridge - 8013 VXPro II IDE - 3388 8013 VXPro II Chipset EIDE Controller -3411 Quantum Designs (H.K.) Inc -3513 ARCOM Control Systems Ltd -3842 eVga.com. Corp. -38ef 4Links -3d3d 3DLabs - 0001 GLINT 300SX - 0002 GLINT 500TX - 0003 GLINT Delta - 0004 Permedia - 0005 Permedia - 0006 GLINT MX - 0007 3D Extreme - 0008 GLINT Gamma G1 - 0009 Permedia II 2D+3D - 1040 0011 AccelStar II - 13e9 1000 6221L-4U - 3d3d 0100 AccelStar II 3D Accelerator - 3d3d 0111 Permedia 3:16 - 3d3d 0114 Santa Ana - 3d3d 0116 Oxygen GVX1 - 3d3d 0119 Scirocco - 3d3d 0120 Santa Ana PCL - 3d3d 0125 Oxygen VX1 - 3d3d 0127 Permedia3 Create! - 000a GLINT R3 - 3d3d 0121 Oxygen VX1 - 000c GLINT R3 [Oxygen VX1] - 3d3d 0144 Oxygen VX1-4X AGP [Permedia 4] - 000d GLint R4 rev A - 0011 GLint R4 rev B - 0012 GLint R5 rev A - 0013 GLint R5 rev B - 0020 VP10 visual processor -# P10 generic II - 0022 VP10 visual processor - 0024 VP9 visual processor - 0100 Permedia II 2D+3D - 07a1 Wildcat III 6210 - 07a2 Sun XVR-500 Graphics Accelerator - 07a3 Wildcat IV 7210 - 1004 Permedia - 3d04 Permedia - ffff Glint VGA -4005 Avance Logic Inc. - 0300 ALS300 PCI Audio Device - 0308 ALS300+ PCI Audio Device - 0309 PCI Input Controller - 1064 ALG-2064 - 2064 ALG-2064i - 2128 ALG-2364A GUI Accelerator - 2301 ALG-2301 - 2302 ALG-2302 - 2303 AVG-2302 GUI Accelerator - 2364 ALG-2364A - 2464 ALG-2464 - 2501 ALG-2564A/25128A - 4000 ALS4000 Audio Chipset - 4005 4000 ALS4000 Audio Chipset - 4710 ALC200/200P -4033 Addtron Technology Co, Inc. - 1360 RTL8139 Ethernet -4143 Digital Equipment Corp -4144 Alpha Data - 0044 ADM-XRCIIPro -416c Aladdin Knowledge Systems - 0100 AladdinCARD - 0200 CPC -4444 Internext Compression Inc - 0016 iTVC16 (CX23416) MPEG-2 Encoder - 0070 4009 WinTV PVR 250 - 0070 8003 WinTV PVR 150 - 0803 iTVC15 MPEG-2 Encoder - 0070 4000 WinTV PVR-350 - 0070 4001 WinTV PVR-250 -# video capture card - 1461 a3cf M179 -4468 Bridgeport machines -4594 Cogetec Informatique Inc -45fb Baldor Electric Company -4680 Umax Computer Corp -4843 Hercules Computer Technology Inc -4916 RedCreek Communications Inc - 1960 RedCreek PCI adapter -4943 Growth Networks -494f ACCES I/O Products, Inc. - 10e8 LPCI-COM-8SM -4978 Axil Computer Inc -4a14 NetVin - 5000 NV5000SC - 4a14 5000 RT8029-Based Ethernet Adapter -4b10 Buslogic Inc. -4c48 LUNG HWA Electronics -4c53 SBS Technologies - 0000 PLUSTEST device - 4c53 3000 PLUSTEST card (PC104+) - 4c53 3001 PLUSTEST card (PMC) - 0001 PLUSTEST-MM device - 4c53 3002 PLUSTEST-MM card (PMC) -4ca1 Seanix Technology Inc -4d51 MediaQ Inc. - 0200 MQ-200 -4d54 Microtechnica Co Ltd -4ddc ILC Data Device Corp - 0100 DD-42924I5-300 (ARINC 429 Data Bus) - 0801 BU-65570I1 MIL-STD-1553 Test and Simulation - 0802 BU-65570I2 MIL-STD-1553 Test and Simulation - 0811 BU-65572I1 MIL-STD-1553 Test and Simulation - 0812 BU-65572I2 MIL-STD-1553 Test and Simulation - 0881 BU-65570T1 MIL-STD-1553 Test and Simulation - 0882 BU-65570T2 MIL-STD-1553 Test and Simulation - 0891 BU-65572T1 MIL-STD-1553 Test and Simulation - 0892 BU-65572T2 MIL-STD-1553 Test and Simulation - 0901 BU-65565C1 MIL-STD-1553 Data Bus - 0902 BU-65565C2 MIL-STD-1553 Data Bus - 0903 BU-65565C3 MIL-STD-1553 Data Bus - 0904 BU-65565C4 MIL-STD-1553 Data Bus - 0b01 BU-65569I1 MIL-STD-1553 Data Bus - 0b02 BU-65569I2 MIL-STD-1553 Data Bus - 0b03 BU-65569I3 MIL-STD-1553 Data Bus - 0b04 BU-65569I4 MIL-STD-1553 Data Bus -5046 GemTek Technology Corporation - 1001 PCI Radio -5053 Voyetra Technologies - 2010 Daytona Audio Adapter -5136 S S Technologies -5143 Qualcomm Inc -5145 Ensoniq (Old) - 3031 Concert AudioPCI -5168 Animation Technologies Inc. -5301 Alliance Semiconductor Corp. - 0001 ProMotion aT3D -5333 S3 Inc. - 0551 Plato/PX (system) - 5631 86c325 [ViRGE] - 8800 86c866 [Vision 866] - 8801 86c964 [Vision 964] - 8810 86c764_0 [Trio 32 vers 0] - 8811 86c764/765 [Trio32/64/64V+] - 8812 86cM65 [Aurora64V+] - 8813 86c764_3 [Trio 32/64 vers 3] - 8814 86c767 [Trio 64UV+] - 8815 86cM65 [Aurora 128] - 883d 86c988 [ViRGE/VX] - 8870 FireGL - 8880 86c868 [Vision 868 VRAM] vers 0 - 8881 86c868 [Vision 868 VRAM] vers 1 - 8882 86c868 [Vision 868 VRAM] vers 2 - 8883 86c868 [Vision 868 VRAM] vers 3 - 88b0 86c928 [Vision 928 VRAM] vers 0 - 88b1 86c928 [Vision 928 VRAM] vers 1 - 88b2 86c928 [Vision 928 VRAM] vers 2 - 88b3 86c928 [Vision 928 VRAM] vers 3 - 88c0 86c864 [Vision 864 DRAM] vers 0 - 88c1 86c864 [Vision 864 DRAM] vers 1 - 88c2 86c864 [Vision 864-P DRAM] vers 2 - 88c3 86c864 [Vision 864-P DRAM] vers 3 - 88d0 86c964 [Vision 964 VRAM] vers 0 - 88d1 86c964 [Vision 964 VRAM] vers 1 - 88d2 86c964 [Vision 964-P VRAM] vers 2 - 88d3 86c964 [Vision 964-P VRAM] vers 3 - 88f0 86c968 [Vision 968 VRAM] rev 0 - 88f1 86c968 [Vision 968 VRAM] rev 1 - 88f2 86c968 [Vision 968 VRAM] rev 2 - 88f3 86c968 [Vision 968 VRAM] rev 3 - 8900 86c755 [Trio 64V2/DX] - 5333 8900 86C775 Trio64V2/DX - 8901 86c775/86c785 [Trio 64V2/DX or /GX] - 5333 8901 86C775 Trio64V2/DX, 86C785 Trio64V2/GX - 8902 Plato/PX - 8903 Trio 3D business multimedia - 8904 Trio 64 3D - 1014 00db Integrated Trio3D - 5333 8904 86C365 Trio3D AGP - 8905 Trio 64V+ family - 8906 Trio 64V+ family - 8907 Trio 64V+ family - 8908 Trio 64V+ family - 8909 Trio 64V+ family - 890a Trio 64V+ family - 890b Trio 64V+ family - 890c Trio 64V+ family - 890d Trio 64V+ family - 890e Trio 64V+ family - 890f Trio 64V+ family - 8a01 ViRGE/DX or /GX - 0e11 b032 ViRGE/GX - 10b4 1617 Nitro 3D - 10b4 1717 Nitro 3D - 5333 8a01 ViRGE/DX - 8a10 ViRGE/GX2 - 1092 8a10 Stealth 3D 4000 - 8a13 86c368 [Trio 3D/2X] - 5333 8a13 Trio3D/2X - 8a20 86c794 [Savage 3D] - 5333 8a20 86C391 Savage3D - 8a21 86c390 [Savage 3D/MV] - 5333 8a21 86C390 Savage3D/MV - 8a22 Savage 4 - 1033 8068 Savage 4 - 1033 8069 Savage 4 - 1033 8110 Savage4 LT - 105d 0018 SR9 8Mb SDRAM - 105d 002a SR9 Pro 16Mb SDRAM - 105d 003a SR9 Pro 32Mb SDRAM - 105d 092f SR9 Pro+ 16Mb SGRAM - 1092 4207 Stealth III S540 - 1092 4800 Stealth III S540 - 1092 4807 SpeedStar A90 - 1092 4808 Stealth III S540 - 1092 4809 Stealth III S540 - 1092 480e Stealth III S540 - 1092 4904 Stealth III S520 - 1092 4905 SpeedStar A200 - 1092 4a09 Stealth III S540 - 1092 4a0b Stealth III S540 Xtreme - 1092 4a0f Stealth III S540 - 1092 4e01 Stealth III S540 - 1102 101d 3d Blaster Savage 4 - 1102 101e 3d Blaster Savage 4 - 5333 8100 86C394-397 Savage4 SDRAM 100 - 5333 8110 86C394-397 Savage4 SDRAM 110 - 5333 8125 86C394-397 Savage4 SDRAM 125 - 5333 8143 86C394-397 Savage4 SDRAM 143 - 5333 8a22 86C394-397 Savage4 - 5333 8a2e 86C394-397 Savage4 32bit - 5333 9125 86C394-397 Savage4 SGRAM 125 - 5333 9143 86C394-397 Savage4 SGRAM 143 - 8a23 Savage 4 - 8a25 ProSavage PM133 - 8a26 ProSavage KM133 - 8c00 ViRGE/M3 - 8c01 ViRGE/MX - 1179 0001 ViRGE/MX - 8c02 ViRGE/MX+ - 8c03 ViRGE/MX+MV - 8c10 86C270-294 Savage/MX-MV - 8c11 82C270-294 Savage/MX - 8c12 86C270-294 Savage/IX-MV - 1014 017f ThinkPad T20 - 1179 0001 86C584 SuperSavage/IXC Toshiba - 8c13 86C270-294 Savage/IX - 1179 0001 Magnia Z310 - 8c22 SuperSavage MX/128 - 8c24 SuperSavage MX/64 - 8c26 SuperSavage MX/64C - 8c2a SuperSavage IX/128 SDR - 8c2b SuperSavage IX/128 DDR - 8c2c SuperSavage IX/64 SDR - 8c2d SuperSavage IX/64 DDR - 8c2e SuperSavage IX/C SDR - 1014 01fc ThinkPad T23 (2647-4MG) - 8c2f SuperSavage IX/C DDR - 8d01 86C380 [ProSavageDDR K4M266] - 8d02 VT8636A [ProSavage KN133] AGP4X VGA Controller (TwisterK) - 8d03 VT8751 [ProSavageDDR P4M266] - 8d04 VT8375 [ProSavage8 KM266/KL266] - 9102 86C410 Savage 2000 - 1092 5932 Viper II Z200 - 1092 5934 Viper II Z200 - 1092 5952 Viper II Z200 - 1092 5954 Viper II Z200 - 1092 5a35 Viper II Z200 - 1092 5a37 Viper II Z200 - 1092 5a55 Viper II Z200 - 1092 5a57 Viper II Z200 - ca00 SonicVibes -544c Teralogic Inc - 0350 TL880-based HDTV/ATSC tuner -5455 Technische University Berlin - 4458 S5933 -5519 Cnet Technologies, Inc. -5544 Dunord Technologies - 0001 I-30xx Scanner Interface -5555 Genroco, Inc - 0003 TURBOstor HFP-832 [HiPPI NIC] -5654 VoiceTronix Pty Ltd - 3132 OpenSwitch12 -5700 Netpower -5851 Exacq Technologies -6356 UltraStor -6374 c't Magazin für Computertechnik - 6773 GPPCI -6409 Logitec Corp. -6666 Decision Computer International Co. - 0001 PCCOM4 - 0002 PCCOM8 -7604 O.N. Electronic Co Ltd. -7bde MIDAC Corporation -7fed PowerTV -8008 Quancom Electronic GmbH - 0010 WDOG1 [PCI-Watchdog 1] - 0011 PWDOG2 [PCI-Watchdog 2] -# Wrong ID used in subsystem ID of AsusTek PCI-USB2 PCI card. -807d Asustek Computer, Inc. -8086 Intel Corporation - 0007 82379AB - 0008 Extended Express System Support Controller - 0008 1000 WorldMark 4300 INCA ASIC - 0039 21145 Fast Ethernet - 0122 82437FX - 0309 80303 I/O Processor PCI-to-PCI Bridge - 030d 80312 I/O Companion Chip PCI-to-PCI Bridge - 0326 6700/6702PXH I/OxAPIC Interrupt Controller A - 0327 6700PXH I/OxAPIC Interrupt Controller B - 0329 6700PXH PCI Express-to-PCI Bridge A - 032a 6700PXH PCI Express-to-PCI Bridge B - 032c 6702PXH PCI Express-to-PCI Bridge A -# A-segment bridge - 0330 80332 [Dobson] I/O processor -# A-segment IOAPIC - 0331 80332 [Dobson] I/O processor -# B-segment bridge - 0332 80332 [Dobson] I/O processor -# B-segment IOAPIC - 0333 80332 [Dobson] I/O processor -# Address Translation Unit (ATU) - 0334 80332 [Dobson] I/O processor -# PCI-X bridge - 0335 80331 [Lindsay] I/O processor -# Address Translation Unit (ATU) - 0336 80331 [Lindsay] I/O processor -# A-segment bridge - 0340 41210 [Lanai] Serial to Parallel PCI Bridge -# B-segment bridge - 0341 41210 [Lanai] Serial to Parallel PCI Bridge - 0482 82375EB/SB PCI to EISA Bridge - 0483 82424TX/ZX [Saturn] CPU to PCI bridge - 0484 82378ZB/IB, 82379AB (SIO, SIO.A) PCI to ISA Bridge - 0486 82425EX/ZX [Aries] PCIset with ISA bridge - 04a3 82434LX/NX [Mercury/Neptune] Processor to PCI bridge - 04d0 82437FX [Triton FX] - 0500 E8870 Processor bus control - 0501 E8870 Memory controller -# and registers common to both SPs - 0502 E8870 Scalability Port 0 -# and global performance monitoring - 0503 E8870 Scalability Port 1 - 0510 E8870IO Hub Interface Port 0 registers (8-bit compatibility port) - 0511 E8870IO Hub Interface Port 1 registers - 0512 E8870IO Hub Interface Port 2 registers - 0513 E8870IO Hub Interface Port 3 registers - 0514 E8870IO Hub Interface Port 4 registers - 0515 E8870IO General SIOH registers - 0516 E8870IO RAS registers - 0530 E8870SP Scalability Port 0 registers - 0531 E8870SP Scalability Port 1 registers - 0532 E8870SP Scalability Port 2 registers - 0533 E8870SP Scalability Port 3 registers - 0534 E8870SP Scalability Port 4 registers - 0535 E8870SP Scalability Port 5 registers -# (bi-interleave 0) and global registers that are neither per-port nor per-interleave - 0536 E8870SP Interleave registers 0 and 1 -# (bi-interleave 1) - 0537 E8870SP Interleave registers 2 and 3 - 0600 RAID Controller - 8086 01c1 ICP Vortex GDT8546RZ - 8086 01f7 SCRU32 -# uninitialized SRCU32 RAID Controller - 061f 80303 I/O Processor - 0960 80960RP [i960 RP Microprocessor/Bridge] - 0962 80960RM [i960RM Bridge] - 0964 80960RP [i960 RP Microprocessor/Bridge] - 1000 82542 Gigabit Ethernet Controller - 0e11 b0df NC1632 Gigabit Ethernet Adapter (1000-SX) - 0e11 b0e0 NC1633 Gigabit Ethernet Adapter (1000-LX) - 0e11 b123 NC1634 Gigabit Ethernet Adapter (1000-SX) - 1014 0119 Netfinity Gigabit Ethernet SX Adapter - 8086 1000 PRO/1000 Gigabit Server Adapter - 1001 82543GC Gigabit Ethernet Controller (Fiber) - 0e11 004a NC6136 Gigabit Server Adapter - 1014 01ea Netfinity Gigabit Ethernet SX Adapter - 8086 1002 PRO/1000 F Server Adapter - 8086 1003 PRO/1000 F Server Adapter - 1002 Pro 100 LAN+Modem 56 Cardbus II - 8086 200e Pro 100 LAN+Modem 56 Cardbus II - 8086 2013 Pro 100 SR Mobile Combo Adapter - 8086 2017 Pro 100 S Combo Mobile Adapter - 1004 82543GC Gigabit Ethernet Controller (Copper) - 0e11 0049 NC7132 Gigabit Upgrade Module - 0e11 b1a4 NC7131 Gigabit Server Adapter - 1014 10f2 Gigabit Ethernet Server Adapter - 8086 1004 PRO/1000 T Server Adapter - 8086 2004 PRO/1000 T Server Adapter - 1008 82544EI Gigabit Ethernet Controller (Copper) - 1014 0269 iSeries 1000/100/10 Ethernet Adapter - 1028 011c PRO/1000 XT Network Connection - 8086 1107 PRO/1000 XT Server Adapter - 8086 2107 PRO/1000 XT Server Adapter - 8086 2110 PRO/1000 XT Server Adapter - 8086 3108 PRO/1000 XT Network Connection - 1009 82544EI Gigabit Ethernet Controller (Fiber) - 1014 0268 iSeries Gigabit Ethernet Adapter - 8086 1109 PRO/1000 XF Server Adapter - 8086 2109 PRO/1000 XF Server Adapter - 100c 82544GC Gigabit Ethernet Controller (Copper) - 8086 1112 PRO/1000 T Desktop Adapter - 8086 2112 PRO/1000 T Desktop Adapter - 100d 82544GC Gigabit Ethernet Controller (LOM) - 1028 0123 PRO/1000 XT Network Connection - 1079 891f 82544GC Based Network Connection - 4c53 1080 CT8 mainboard - 8086 110d 82544GC Based Network Connection - 100e 82540EM Gigabit Ethernet Controller - 1014 0265 PRO/1000 MT Network Connection - 1014 0267 PRO/1000 MT Network Connection - 1014 026a PRO/1000 MT Network Connection - 1028 002e Optiplex GX260 - 1028 0151 PRO/1000 MT Network Connection - 107b 8920 PRO/1000 MT Desktop Adapter - 8086 001e PRO/1000 MT Desktop Adapter - 8086 002e PRO/1000 MT Desktop Adapter - 100f 82545EM Gigabit Ethernet Controller (Copper) - 1014 0269 iSeries 1000/100/10 Ethernet Adapter - 1014 028e PRO/1000 MT Network Connection - 8086 1000 PRO/1000 MT Network Connection - 8086 1001 PRO/1000 MT Server Adapter - 1010 82546EB Gigabit Ethernet Controller (Copper) - 1014 027c PRO/1000 MT Dual Port Network Adapter - 18fb 7872 RESlink-X - 4c53 1080 CT8 mainboard - 4c53 10a0 CA3/CR3 mainboard - 8086 1011 PRO/1000 MT Dual Port Server Adapter - 8086 101a PRO/1000 MT Dual Port Network Adapter - 8086 3424 SE7501HG2 Mainboard - 1011 82545EM Gigabit Ethernet Controller (Fiber) - 1014 0268 iSeries Gigabit Ethernet Adapter - 8086 1002 PRO/1000 MF Server Adapter - 8086 1003 PRO/1000 MF Server Adapter (LX) - 1012 82546EB Gigabit Ethernet Controller (Fiber) - 8086 1012 PRO/1000 MF Dual Port Server Adapter - 1013 82541EI Gigabit Ethernet Controller (Copper) - 8086 0013 PRO/1000 MT Network Connection - 8086 1013 IBM ThinkCentre Network Card - 8086 1113 PRO/1000 MT Desktop Adapter - 1014 82541ER Gigabit Ethernet Controller - 1015 82540EM Gigabit Ethernet Controller (LOM) - 1016 82540EP Gigabit Ethernet Controller (LOM) - 1014 052c PRO/1000 MT Mobile Connection - 1179 0001 PRO/1000 MT Mobile Connection - 8086 1016 PRO/1000 MT Mobile Connection - 1017 82540EP Gigabit Ethernet Controller (LOM) - 8086 1017 PR0/1000 MT Desktop Connection -# Update controller name from 82541EP to 82541EI - 1018 82541EI Gigabit Ethernet Controller - 8086 1018 PRO/1000 MT Desktop Adapter - 1019 82547EI Gigabit Ethernet Controller (LOM) - 1458 1019 GA-8IPE1000 Pro2 motherboard (865PE) - 1458 e000 Intel Gigabit Ethernet (Kenai II) - 8086 1019 PRO/1000 CT Desktop Connection - 8086 301f D865PERL mainboard - 8086 3427 S875WP1-E mainboard - 101d 82546EB Gigabit Ethernet Controller - 8086 1000 PRO/1000 MT Quad Port Server Adapter - 101e 82540EP Gigabit Ethernet Controller (Mobile) - 1014 0549 PRO/1000 MT Mobile Connection - 1179 0001 PRO/1000 MT Mobile Connection - 8086 101e PRO/1000 MT Mobile Connection - 1026 82545GM Gigabit Ethernet Controller - 8086 1000 PRO/1000 MT Server Connection - 8086 1001 PRO/1000 MT Server Adapter - 8086 1002 PRO/1000 MT Server Adapter - 8086 1026 PRO/1000 MT Server Connection - 1027 82545GM Gigabit Ethernet Controller - 8086 1001 PRO/1000 MF Server Adapter(LX) - 8086 1002 PRO/1000 MF Server Adapter(LX) - 8086 1003 PRO/1000 MF Server Adapter(LX) - 8086 1027 PRO/1000 MF Server Adapter - 1028 82545GM Gigabit Ethernet Controller - 8086 1028 PRO/1000 MB Server Adapter - 1029 82559 Ethernet Controller - 1030 82559 InBusiness 10/100 - 1031 82801CAM (ICH3) PRO/100 VE (LOM) Ethernet Controller - 1014 0209 ThinkPad A/T/X Series - 104d 80e7 Vaio PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP - 107b 5350 EtherExpress PRO/100 VE - 1179 0001 EtherExpress PRO/100 VE - 144d c000 EtherExpress PRO/100 VE - 144d c001 EtherExpress PRO/100 VE - 144d c003 EtherExpress PRO/100 VE - 144d c006 vpr Matrix 170B4 - 1032 82801CAM (ICH3) PRO/100 VE Ethernet Controller - 1033 82801CAM (ICH3) PRO/100 VM (LOM) Ethernet Controller - 1034 82801CAM (ICH3) PRO/100 VM Ethernet Controller - 1035 82801CAM (ICH3)/82562EH (LOM) Ethernet Controller - 1036 82801CAM (ICH3) 82562EH Ethernet Controller - 1037 82801CAM (ICH3) Chipset Ethernet Controller - 1038 82801CAM (ICH3) PRO/100 VM (KM) Ethernet Controller - 1039 82801DB PRO/100 VE (LOM) Ethernet Controller - 1014 0267 NetVista A30p - 103a 82801DB PRO/100 VE (CNR) Ethernet Controller - 103b 82801DB PRO/100 VM (LOM) Ethernet Controller - 103c 82801DB PRO/100 VM (CNR) Ethernet Controller - 103d 82801DB PRO/100 VE (MOB) Ethernet Controller - 103e 82801DB PRO/100 VM (MOB) Ethernet Controller - 1040 536EP Data Fax Modem - 16be 1040 V.9X DSP Data Fax Modem - 1043 PRO/Wireless LAN 2100 3B Mini PCI Adapter - 8086 2527 MIM2000/Centrino - 1048 PRO/10GbE LR Server Adapter - 8086 a01f PRO/10GbE LR Server Adapter - 8086 a11f PRO/10GbE LR Server Adapter - 1050 82562EZ 10/100 Ethernet Controller - 1462 728c 865PE Neo2 (MS-6728) - 1462 758c MS-6758 (875P Neo) - 8086 3020 D865PERL mainboard - 8086 3427 S875WP1-E mainboard - 1051 82801EB/ER (ICH5/ICH5R) integrated LAN Controller - 1059 82551QM Ethernet Controller -# ICH-6 Component - 1064 82562ET/EZ/GT/GZ - PRO/100 VE (LOM) Ethernet Controller -# ICH-6 Component - 1065 82562ET/EZ/GT/GZ - PRO/100 VE Ethernet Controller -# ICH-6 Component - 1066 82562 EM/EX/GX - PRO/100 VM (LOM) Ethernet Controller -# ICH-6 Component - 1067 82562 EM/EX/GX - PRO/100 VM Ethernet Controller -# ICH-6 Component - 1068 82562ET/EZ/GT/GZ - PRO/100 VE (LOM) Ethernet Controller Mobile -# ICH-6 Component - 1069 82562 EM/EX/GX - PRO/100 VM (LOM) Ethernet Controller Mobile -# ICH-6 Component - 106a 82562G \t- PRO/100 VE (LOM) Ethernet Controller -# ICH-6 Component - 106b 82562G \t- PRO/100 VE Ethernet Controller Mobile - 1075 82547GI Gigabit Ethernet Controller - 1028 0165 PowerEdge 750 - 8086 0075 PRO/1000 CT Network Connection - 8086 1075 PRO/1000 CT Network Connection - 1076 82541GI/PI Gigabit Ethernet Controller - 1028 0165 PowerEdge 750 - 8086 0076 PRO/1000 MT Network Connection - 8086 1076 PRO/1000 MT Network Connection - 8086 1176 PRO/1000 MT Desktop Adapter - 8086 1276 PRO/1000 MT Desktop Adapter - 1077 82541GI Gigabit Ethernet Controller - 1179 0001 PRO/1000 MT Mobile Connection - 8086 0077 PRO/1000 MT Mobile Connection - 8086 1077 PRO/1000 MT Mobile Connection - 1078 82541EI Gigabit Ethernet Controller - 8086 1078 PRO/1000 MT Network Connection - 1079 82546GB Gigabit Ethernet Controller - 103c 12a6 HP Dual Port 1000Base-T [A9900A] - 103c 12cf HP Core Dual Port 1000Base-T [AB352A] - 4c53 1090 Cx9 / Vx9 mainboard - 4c53 10b0 CL9 mainboard - 8086 0079 PRO/1000 MT Dual Port Network Connection - 8086 1079 PRO/1000 MT Dual Port Network Connection - 8086 1179 PRO/1000 MT Dual Port Network Connection - 8086 117a PRO/1000 MT Dual Port Server Adapter - 107a 82546GB Gigabit Ethernet Controller - 103c 12a8 HP Dual Port 1000base-SX [A9899A] - 8086 107a PRO/1000 MF Dual Port Server Adapter - 8086 127a PRO/1000 MF Dual Port Server Adapter - 107b 82546GB Gigabit Ethernet Controller - 8086 007b PRO/1000 MB Dual Port Server Connection - 8086 107b PRO/1000 MB Dual Port Server Connection - 1107 PRO/1000 MF Server Adapter (LX) - 1130 82815 815 Chipset Host Bridge and Memory Controller Hub - 1025 1016 Travelmate 612 TX - 1043 8027 TUSL2-C Mainboard - 104d 80df Vaio PCG-FX403 - 8086 4532 D815EEA2 mainboard - 8086 4557 D815EGEW Mainboard - 1131 82815 815 Chipset AGP Bridge - 1132 82815 CGC [Chipset Graphics Controller] - 1025 1016 Travelmate 612 TX - 104d 80df Vaio PCG-FX403 - 8086 4532 D815EEA2 Mainboard - 8086 4557 D815EGEW Mainboard - 1161 82806AA PCI64 Hub Advanced Programmable Interrupt Controller - 8086 1161 82806AA PCI64 Hub APIC - 1162 Xscale 80200 Big Endian Companion Chip - 1200 Intel IXP1200 Network Processor - 172a 0000 AEP SSL Accelerator - 1209 8255xER/82551IT Fast Ethernet Controller - 4c53 1050 CT7 mainboard - 4c53 1051 CE7 mainboard - 4c53 1070 PC6 mainboard - 1221 82092AA PCI to PCMCIA Bridge - 1222 82092AA IDE Controller - 1223 SAA7116 - 1225 82452KX/GX [Orion] - 1226 82596 PRO/10 PCI - 1227 82865 EtherExpress PRO/100A - 1228 82556 EtherExpress PRO/100 Smart -# the revision field differentiates between them (1-3 is 82557, 4-5 is 82558, 6-8 is 82559, 9 is 82559ER) - 1229 82557/8/9 [Ethernet Pro 100] - 0e11 3001 82559 Fast Ethernet LOM with Alert on LAN* - 0e11 3002 82559 Fast Ethernet LOM with Alert on LAN* - 0e11 3003 82559 Fast Ethernet LOM with Alert on LAN* - 0e11 3004 82559 Fast Ethernet LOM with Alert on LAN* - 0e11 3005 82559 Fast Ethernet LOM with Alert on LAN* - 0e11 3006 82559 Fast Ethernet LOM with Alert on LAN* - 0e11 3007 82559 Fast Ethernet LOM with Alert on LAN* - 0e11 b01e NC3120 Fast Ethernet NIC - 0e11 b01f NC3122 Fast Ethernet NIC (dual port) - 0e11 b02f NC1120 Ethernet NIC - 0e11 b04a Netelligent 10/100TX NIC with Wake on LAN - 0e11 b0c6 NC3161 Fast Ethernet NIC (embedded, WOL) - 0e11 b0c7 NC3160 Fast Ethernet NIC (embedded) - 0e11 b0d7 NC3121 Fast Ethernet NIC (WOL) - 0e11 b0dd NC3131 Fast Ethernet NIC (dual port) - 0e11 b0de NC3132 Fast Ethernet Module (dual port) - 0e11 b0e1 NC3133 Fast Ethernet Module (100-FX) - 0e11 b134 NC3163 Fast Ethernet NIC (embedded, WOL) - 0e11 b13c NC3162 Fast Ethernet NIC (embedded) - 0e11 b144 NC3123 Fast Ethernet NIC (WOL) - 0e11 b163 NC3134 Fast Ethernet NIC (dual port) - 0e11 b164 NC3135 Fast Ethernet Upgrade Module (dual port) - 0e11 b1a4 NC7131 Gigabit Server Adapter - 1014 005c 82558B Ethernet Pro 10/100 - 1014 01bc 82559 Fast Ethernet LAN On Motherboard - 1014 01f1 10/100 Ethernet Server Adapter - 1014 01f2 10/100 Ethernet Server Adapter - 1014 0207 Ethernet Pro/100 S - 1014 0232 10/100 Dual Port Server Adapter - 1014 023a ThinkPad R30 - 1014 105c Netfinity 10/100 - 1014 2205 ThinkPad A22p - 1014 305c 10/100 EtherJet Management Adapter - 1014 405c 10/100 EtherJet Adapter with Alert on LAN - 1014 505c 10/100 EtherJet Secure Management Adapter - 1014 605c 10/100 EtherJet Secure Management Adapter - 1014 705c 10/100 Netfinity 10/100 Ethernet Security Adapter - 1014 805c 10/100 Netfinity 10/100 Ethernet Security Adapter - 1028 009b PowerEdge 2500/2550 - 1028 00ce PowerEdge 1400 - 1033 8000 PC-9821X-B06 - 1033 8016 PK-UG-X006 - 1033 801f PK-UG-X006 - 1033 8026 PK-UG-X006 - 1033 8063 82559-based Fast Ethernet Adapter - 1033 8064 82559-based Fast Ethernet Adapter - 103c 10c0 NetServer 10/100TX - 103c 10c3 NetServer 10/100TX - 103c 10ca NetServer 10/100TX - 103c 10cb NetServer 10/100TX - 103c 10e3 NetServer 10/100TX - 103c 10e4 NetServer 10/100TX - 103c 1200 NetServer 10/100TX - 10c3 1100 SmartEther100 SC1100 - 10cf 1115 8255x-based Ethernet Adapter (10/100) - 10cf 1143 8255x-based Ethernet Adapter (10/100) - 1179 0001 8255x-based Ethernet Adapter (10/100) - 1179 0002 PCI FastEther LAN on Docker - 1179 0003 8255x-based Fast Ethernet - 1259 2560 AT-2560 100 - 1259 2561 AT-2560 100 FX Ethernet Adapter - 1266 0001 NE10/100 Adapter - 13e9 1000 6221L-4U - 144d 2501 SEM-2000 MiniPCI LAN Adapter - 144d 2502 SEM-2100IL MiniPCI LAN Adapter - 1668 1100 EtherExpress PRO/100B (TX) (MiniPCI Ethernet+Modem) - 4c53 1080 CT8 mainboard - 8086 0001 EtherExpress PRO/100B (TX) - 8086 0002 EtherExpress PRO/100B (T4) - 8086 0003 EtherExpress PRO/10+ - 8086 0004 EtherExpress PRO/100 WfM - 8086 0005 82557 10/100 - 8086 0006 82557 10/100 with Wake on LAN - 8086 0007 82558 10/100 Adapter - 8086 0008 82558 10/100 with Wake on LAN - 8086 0009 EtherExpress PRO/100+ - 8086 000a EtherExpress PRO/100+ Management Adapter - 8086 000b EtherExpress PRO/100+ - 8086 000c EtherExpress PRO/100+ Management Adapter - 8086 000d EtherExpress PRO/100+ Alert On LAN II* Adapter - 8086 000e EtherExpress PRO/100+ Management Adapter with Alert On LAN* - 8086 000f EtherExpress PRO/100 Desktop Adapter - 8086 0010 EtherExpress PRO/100 S Management Adapter - 8086 0011 EtherExpress PRO/100 S Management Adapter - 8086 0012 EtherExpress PRO/100 S Advanced Management Adapter (D) - 8086 0013 EtherExpress PRO/100 S Advanced Management Adapter (E) - 8086 0030 EtherExpress PRO/100 Management Adapter with Alert On LAN* GC - 8086 0031 EtherExpress PRO/100 Desktop Adapter - 8086 0040 EtherExpress PRO/100 S Desktop Adapter - 8086 0041 EtherExpress PRO/100 S Desktop Adapter - 8086 0042 EtherExpress PRO/100 Desktop Adapter - 8086 0050 EtherExpress PRO/100 S Desktop Adapter - 8086 1009 EtherExpress PRO/100+ Server Adapter - 8086 100c EtherExpress PRO/100+ Server Adapter (PILA8470B) - 8086 1012 EtherExpress PRO/100 S Server Adapter (D) - 8086 1013 EtherExpress PRO/100 S Server Adapter (E) - 8086 1015 EtherExpress PRO/100 S Dual Port Server Adapter - 8086 1017 EtherExpress PRO/100+ Dual Port Server Adapter - 8086 1030 EtherExpress PRO/100+ Management Adapter with Alert On LAN* G Server - 8086 1040 EtherExpress PRO/100 S Server Adapter - 8086 1041 EtherExpress PRO/100 S Server Adapter - 8086 1042 EtherExpress PRO/100 Server Adapter - 8086 1050 EtherExpress PRO/100 S Server Adapter - 8086 1051 EtherExpress PRO/100 Server Adapter - 8086 1052 EtherExpress PRO/100 Server Adapter - 8086 10f0 EtherExpress PRO/100+ Dual Port Adapter - 8086 2009 EtherExpress PRO/100 S Mobile Adapter - 8086 200d EtherExpress PRO/100 Cardbus - 8086 200e EtherExpress PRO/100 LAN+V90 Cardbus Modem - 8086 200f EtherExpress PRO/100 SR Mobile Adapter - 8086 2010 EtherExpress PRO/100 S Mobile Combo Adapter - 8086 2013 EtherExpress PRO/100 SR Mobile Combo Adapter - 8086 2016 EtherExpress PRO/100 S Mobile Adapter - 8086 2017 EtherExpress PRO/100 S Combo Mobile Adapter - 8086 2018 EtherExpress PRO/100 SR Mobile Adapter - 8086 2019 EtherExpress PRO/100 SR Combo Mobile Adapter - 8086 2101 EtherExpress PRO/100 P Mobile Adapter - 8086 2102 EtherExpress PRO/100 SP Mobile Adapter - 8086 2103 EtherExpress PRO/100 SP Mobile Adapter - 8086 2104 EtherExpress PRO/100 SP Mobile Adapter - 8086 2105 EtherExpress PRO/100 SP Mobile Adapter - 8086 2106 EtherExpress PRO/100 P Mobile Adapter - 8086 2107 EtherExpress PRO/100 Network Connection - 8086 2108 EtherExpress PRO/100 Network Connection - 8086 2200 EtherExpress PRO/100 P Mobile Combo Adapter - 8086 2201 EtherExpress PRO/100 P Mobile Combo Adapter - 8086 2202 EtherExpress PRO/100 SP Mobile Combo Adapter - 8086 2203 EtherExpress PRO/100+ MiniPCI - 8086 2204 EtherExpress PRO/100+ MiniPCI - 8086 2205 EtherExpress PRO/100 SP Mobile Combo Adapter - 8086 2206 EtherExpress PRO/100 SP Mobile Combo Adapter - 8086 2207 EtherExpress PRO/100 SP Mobile Combo Adapter - 8086 2208 EtherExpress PRO/100 P Mobile Combo Adapter - 8086 2402 EtherExpress PRO/100+ MiniPCI - 8086 2407 EtherExpress PRO/100+ MiniPCI - 8086 2408 EtherExpress PRO/100+ MiniPCI - 8086 2409 EtherExpress PRO/100+ MiniPCI - 8086 240f EtherExpress PRO/100+ MiniPCI - 8086 2410 EtherExpress PRO/100+ MiniPCI - 8086 2411 EtherExpress PRO/100+ MiniPCI - 8086 2412 EtherExpress PRO/100+ MiniPCI - 8086 2413 EtherExpress PRO/100+ MiniPCI - 8086 3000 82559 Fast Ethernet LAN on Motherboard - 8086 3001 82559 Fast Ethernet LOM with Basic Alert on LAN* - 8086 3002 82559 Fast Ethernet LOM with Alert on LAN II* - 8086 3006 EtherExpress PRO/100 S Network Connection - 8086 3007 EtherExpress PRO/100 S Network Connection - 8086 3008 EtherExpress PRO/100 Network Connection - 8086 3010 EtherExpress PRO/100 S Network Connection - 8086 3011 EtherExpress PRO/100 S Network Connection - 8086 3012 EtherExpress PRO/100 Network Connection - 8086 3411 SDS2 Mainboard - 122d 430FX - 82437FX TSC [Triton I] - 122e 82371FB PIIX ISA [Triton I] - 1230 82371FB PIIX IDE [Triton I] - 1231 DSVD Modem - 1234 430MX - 82371MX Mobile PCI I/O IDE Xcelerator (MPIIX) - 1235 430MX - 82437MX Mob. System Ctrlr (MTSC) & 82438MX Data Path (MTDP) - 1237 440FX - 82441FX PMC [Natoma] - 1239 82371FB PIIX IDE Interface - 123b 82380PB PCI to PCI Docking Bridge - 123c 82380AB (MISA) Mobile PCI-to-ISA Bridge - 123d 683053 Programmable Interrupt Device -# in" hidden" mode - 123e 82466GX (IHPC) Integrated Hot-Plug Controller - 123f 82466GX Integrated Hot-Plug Controller (IHPC) - 1240 82752 (752) AGP Graphics Accelerator - 124b 82380FB (MPCI2) Mobile Docking Controller - 1250 430HX - 82439HX TXC [Triton II] - 1360 82806AA PCI64 Hub PCI Bridge - 1361 82806AA PCI64 Hub Controller (HRes) - 8086 1361 82806AA PCI64 Hub Controller (HRes) - 8086 8000 82806AA PCI64 Hub Controller (HRes) - 1460 82870P2 P64H2 Hub PCI Bridge - 1461 82870P2 P64H2 I/OxAPIC - 15d9 3480 P4DP6 - 4c53 1090 Cx9 / Vx9 mainboard - 1462 82870P2 P64H2 Hot Plug Controller - 1960 80960RP [i960RP Microprocessor] - 101e 0431 MegaRAID 431 RAID Controller - 101e 0438 MegaRAID 438 Ultra2 LVD RAID Controller - 101e 0466 MegaRAID 466 Express Plus RAID Controller - 101e 0467 MegaRAID 467 Enterprise 1500 RAID Controller - 101e 0490 MegaRAID 490 Express 300 RAID Controller - 101e 0762 MegaRAID 762 Express RAID Controller - 101e 09a0 PowerEdge Expandable RAID Controller 2/SC - 1028 0467 PowerEdge Expandable RAID Controller 2/DC - 1028 1111 PowerEdge Expandable RAID Controller 2/SC - 103c 03a2 MegaRAID - 103c 10c6 MegaRAID 438, HP NetRAID-3Si - 103c 10c7 MegaRAID T5, Integrated HP NetRAID - 103c 10cc MegaRAID, Integrated HP NetRAID - 103c 10cd HP NetRAID-1Si - 105a 0000 SuperTrak - 105a 2168 SuperTrak Pro - 105a 5168 SuperTrak66/100 - 1111 1111 MegaRAID 466, PowerEdge Expandable RAID Controller 2/SC - 1111 1112 PowerEdge Expandable RAID Controller 2/SC - 113c 03a2 MegaRAID - e4bf 1010 CG1-RADIO - e4bf 1020 CU2-QUARTET - e4bf 1040 CU1-CHORUS - e4bf 3100 CX1-BAND - 1962 80960RM [i960RM Microprocessor] - 105a 0000 SuperTrak SX6000 I2O CPU - 1a21 82840 840 (Carmel) Chipset Host Bridge (Hub A) - 1a23 82840 840 (Carmel) Chipset AGP Bridge - 1a24 82840 840 (Carmel) Chipset PCI Bridge (Hub B) - 1a30 82845 845 (Brookdale) Chipset Host Bridge - 1028 010e Optiplex GX240 - 1a31 82845 845 (Brookdale) Chipset AGP Bridge - 2410 82801AA ISA Bridge (LPC) - 2411 82801AA IDE - 2412 82801AA USB - 2413 82801AA SMBus - 2415 82801AA AC'97 Audio - 1028 0095 Precision Workstation 220 Integrated Digital Audio - 11d4 0040 SoundMAX Integrated Digital Audio - 11d4 0048 SoundMAX Integrated Digital Audio - 11d4 5340 SoundMAX Integrated Digital Audio - 2416 82801AA AC'97 Modem - 2418 82801AA PCI Bridge - 2420 82801AB ISA Bridge (LPC) - 2421 82801AB IDE - 2422 82801AB USB - 2423 82801AB SMBus - 2425 82801AB AC'97 Audio - 11d4 0040 SoundMAX Integrated Digital Audio - 11d4 0048 SoundMAX Integrated Digital Audio - 2426 82801AB AC'97 Modem - 2428 82801AB PCI Bridge - 2440 82801BA ISA Bridge (LPC) - 2442 82801BA/BAM USB (Hub #1) - 1014 01c6 Netvista A40/A40p - 1025 1016 Travelmate 612 TX - 1028 010e Optiplex GX240 - 1043 8027 TUSL2-C Mainboard - 104d 80df Vaio PCG-FX403 - 147b 0507 TH7II-RAID - 8086 4532 D815EEA2 mainboard - 8086 4557 D815EGEW Mainboard - 2443 82801BA/BAM SMBus - 1014 01c6 Netvista A40/A40p - 1025 1016 Travelmate 612 TX - 1028 010e Optiplex GX240 - 1043 8027 TUSL2-C Mainboard - 104d 80df Vaio PCG-FX403 - 147b 0507 TH7II-RAID - 8086 4532 D815EEA2 mainboard - 8086 4557 D815EGEW Mainboard - 2444 82801BA/BAM USB (Hub #2) - 1025 1016 Travelmate 612 TX - 1028 010e Optiplex GX240 - 1043 8027 TUSL2-C Mainboard - 104d 80df Vaio PCG-FX403 - 147b 0507 TH7II-RAID - 8086 4532 D815EEA2 mainboard - 2445 82801BA/BAM AC'97 Audio - 1014 01c6 Netvista A40/A40p - 1025 1016 Travelmate 612 TX - 104d 80df Vaio PCG-FX403 - 1462 3370 STAC9721 AC - 147b 0507 TH7II-RAID - 8086 4557 D815EGEW Mainboard - 2446 82801BA/BAM AC'97 Modem - 1025 1016 Travelmate 612 TX - 104d 80df Vaio PCG-FX403 - 2448 82801 Mobile PCI Bridge - 2449 82801BA/BAM/CA/CAM Ethernet Controller - 0e11 0012 EtherExpress PRO/100 VM - 0e11 0091 EtherExpress PRO/100 VE - 1014 01ce EtherExpress PRO/100 VE - 1014 01dc EtherExpress PRO/100 VE - 1014 01eb EtherExpress PRO/100 VE - 1014 01ec EtherExpress PRO/100 VE - 1014 0202 EtherExpress PRO/100 VE - 1014 0205 EtherExpress PRO/100 VE - 1014 0217 EtherExpress PRO/100 VE - 1014 0234 EtherExpress PRO/100 VE - 1014 023d EtherExpress PRO/100 VE - 1014 0244 EtherExpress PRO/100 VE - 1014 0245 EtherExpress PRO/100 VE - 1014 0265 PRO/100 VE Desktop Connection - 1014 0267 PRO/100 VE Desktop Connection - 1014 026a PRO/100 VE Desktop Connection - 109f 315d EtherExpress PRO/100 VE - 109f 3181 EtherExpress PRO/100 VE - 1179 ff01 PRO/100 VE Network Connection - 1186 7801 EtherExpress PRO/100 VE - 144d 2602 HomePNA 1M CNR - 8086 3010 EtherExpress PRO/100 VE - 8086 3011 EtherExpress PRO/100 VM - 8086 3012 82562EH based Phoneline - 8086 3013 EtherExpress PRO/100 VE - 8086 3014 EtherExpress PRO/100 VM - 8086 3015 82562EH based Phoneline - 8086 3016 EtherExpress PRO/100 P Mobile Combo - 8086 3017 EtherExpress PRO/100 P Mobile - 8086 3018 EtherExpress PRO/100 - 244a 82801BAM IDE U100 - 1025 1016 Travelmate 612TX - 104d 80df Vaio PCG-FX403 - 244b 82801BA IDE U100 - 1014 01c6 Netvista A40/A40p - 1028 010e Optiplex GX240 - 1043 8027 TUSL2-C Mainboard - 147b 0507 TH7II-RAID - 8086 4532 D815EEA2 mainboard - 8086 4557 D815EGEW Mainboard - 244c 82801BAM ISA Bridge (LPC) - 244e 82801 PCI Bridge - 1014 0267 NetVista A30p - 2450 82801E ISA Bridge (LPC) - 2452 82801E USB - 2453 82801E SMBus - 2459 82801E Ethernet Controller 0 - 245b 82801E IDE U100 - 245d 82801E Ethernet Controller 1 - 245e 82801E PCI Bridge - 2480 82801CA LPC Interface Controller - 2482 82801CA/CAM USB (Hub #1) - 1014 0220 ThinkPad A/T/X Series - 104d 80e7 VAIO PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP - 15d9 3480 P4DP6 - 8086 1958 vpr Matrix 170B4 - 8086 3424 SE7501HG2 Mainboard - 8086 4541 Latitude C640 - 2483 82801CA/CAM SMBus Controller - 1014 0220 ThinkPad A/T/X Series - 104d 80e7 VAIO PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP - 15d9 3480 P4DP6 - 8086 1958 vpr Matrix 170B4 - 2484 82801CA/CAM USB (Hub #2) - 1014 0220 ThinkPad A/T/X Series - 104d 80e7 VAIO PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP - 15d9 3480 P4DP6 - 8086 1958 vpr Matrix 170B4 - 2485 82801CA/CAM AC'97 Audio Controller - 1013 5959 Crystal WMD Audio Codec - 1014 0222 ThinkPad T23 (2647-4MG) or A30/A30p (2652/2653) - 1014 0508 ThinkPad T30 - 1014 051c ThinkPad A/T/X Series - 104d 80e7 VAIO PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP - 144d c006 vpr Matrix 170B4 - 2486 82801CA/CAM AC'97 Modem Controller - 1014 0223 ThinkPad A/T/X Series - 1014 0503 ThinkPad R31 2656BBG - 1014 051a ThinkPad A/T/X Series - 101f 1025 Acer 620 Series - 104d 80e7 VAIO PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP - 1179 0001 Toshiba Satellite 1110 Z15 internal Modem - 134d 4c21 Dell Inspiron 2100 internal modem - 144d 2115 vpr Matrix 170B4 internal modem - 14f1 5421 MD56ORD V.92 MDC Modem - 2487 82801CA/CAM USB (Hub #3) - 1014 0220 ThinkPad A/T/X Series - 104d 80e7 VAIO PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP - 15d9 3480 P4DP6 - 8086 1958 vpr Matrix 170B4 - 248a 82801CAM IDE U100 - 1014 0220 ThinkPad A/T/X Series - 104d 80e7 VAIO PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP - 8086 1958 vpr Matrix 170B4 - 8086 4541 Latitude C640 - 248b 82801CA Ultra ATA Storage Controller - 15d9 3480 P4DP6 - 248c 82801CAM ISA Bridge (LPC) - 24c0 82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge - 1014 0267 NetVista A30p - 1462 5800 845PE Max (MS-6580) - 24c1 82801DBL (ICH4-L) IDE Controller - 24c2 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #1 - 1014 0267 NetVista A30p - 1025 005a TravelMate 290 - 1028 0126 Optiplex GX260 - 1028 0163 Latitude D505 - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 1071 8160 MIM2000 - 1462 5800 845PE Max (MS-6580) - 1509 2990 Averatec 5110H laptop - 4c53 1090 Cx9 / Vx9 mainboard - 24c3 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) SMBus Controller - 1014 0267 NetVista A30p - 1025 005a TravelMate 290 - 1028 0126 Optiplex GX260 - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 1071 8160 MIM2000 - 1458 24c2 GA-8PE667 Ultra - 1462 5800 845PE Max (MS-6580) - 4c53 1090 Cx9 / Vx9 mainboard - 24c4 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #2 - 1014 0267 NetVista A30p - 1025 005a TravelMate 290 - 1028 0126 Optiplex GX260 - 1028 0163 Latitude D505 - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 1071 8160 MIM2000 - 1462 5800 845PE Max (MS-6580) - 1509 2990 Averatec 5110H - 4c53 1090 Cx9 / Vx9 mainboard - 24c5 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller - 0e11 00b8 Analog Devices Inc. codec [SoundMAX] - 1014 0267 NetVista A30p - 1025 005a TravelMate 290 - 1028 0163 Latitude D505 - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 1071 8160 MIM2000 - 1458 a002 GA-8PE667 Ultra - 1462 5800 845PE Max (MS-6580) - 24c6 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Modem Controller - 1025 005a TravelMate 290 - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 1071 8160 MIM2000 - 24c7 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3 - 1014 0267 NetVista A30p - 1025 005a TravelMate 290 - 1028 0126 Optiplex GX260 - 1028 0163 Latitude D505 - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 1071 8160 MIM2000 - 1462 5800 845PE Max (MS-6580) - 1509 2990 Averatec 5110H - 4c53 1090 Cx9 / Vx9 mainboard - 24ca 82801DBM (ICH4-M) IDE Controller - 1025 005a TravelMate 290 - 1028 0163 Latitude D505 - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 1071 8160 MIM2000 - 24cb 82801DB (ICH4) IDE Controller - 1014 0267 NetVista A30p - 1028 0126 Optiplex GX260 - 1458 24c2 GA-8PE667 Ultra - 1462 5800 845PE Max (MS-6580) - 4c53 1090 Cx9 / Vx9 mainboard - 24cc 82801DBM (ICH4-M) LPC Interface Bridge - 24cd 82801DB/DBM (ICH4/ICH4-M) USB2 EHCI Controller - 1014 0267 NetVista A30p - 1025 005a TravelMate 290 - 1028 0126 Optiplex GX260 - 1028 0163 Latitude D505 - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 1071 8160 MIM2000 - 1462 3981 845PE Max (MS-6580) - 1509 1968 Averatec 5110H - 4c53 1090 Cx9 / Vx9 mainboard - 24d0 82801EB/ER (ICH5/ICH5R) LPC Interface Bridge - 24d1 82801EB (ICH5) SATA Controller - 103c 12bc d530 CMT (DG746A) - 1458 24d1 GA-8IPE1000 Pro2 motherboard (865PE) - 1462 7280 865PE Neo2 (MS-6728) - 8086 3427 S875WP1-E mainboard - 8086 524c D865PERL mainboard - 24d2 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #1 - 1028 0183 PowerEdge 1800 - 103c 12bc d530 CMT (DG746A) - 1043 80a6 P4P800 Mainboard - 1458 24d2 GA-8IPE1000/8KNXP motherboard - 1462 7280 865PE Neo2 (MS-6728) - 8086 3427 S875WP1-E mainboard - 8086 524c D865PERL mainboard - 24d3 82801EB/ER (ICH5/ICH5R) SMBus Controller - 1043 80a6 P4P800 Mainboard - 1458 24d2 GA-8IPE1000 Pro2 motherboard (865PE) - 1462 7280 865PE Neo2 (MS-6728) - 8086 3427 S875WP1-E mainboard - 8086 524c D865PERL mainboard - 24d4 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #2 - 1028 0183 PowerEdge 1800 - 103c 12bc d530 CMT (DG746A) - 1043 80a6 P4P800 Mainboard - 1458 24d2 GA-8IPE1000 Pro2 motherboard (865PE) - 1462 7280 865PE Neo2 (MS-6728) - 8086 3427 S875WP1-E mainboard - 8086 524c D865PERL mainboard - 24d5 82801EB/ER (ICH5/ICH5R) AC'97 Audio Controller - 103c 12bc Analog Devices codec [SoundMAX Integrated Digital Audio] - 1043 80f3 P4P800 Mainboard -# Again, I suppose they use the same in different subsystems - 1458 a002 GA-8IPE1000/8KNXP motherboard - 1462 7280 865PE Neo2 (MS-6728) - 8086 a000 D865PERL mainboard - 8086 e000 D865PERL mainboard - 24d6 82801EB/ER (ICH5/ICH5R) AC'97 Modem Controller - 24d7 82801EB/ER (ICH5/ICH5R) USB UHCI #3 - 1028 0183 PowerEdge 1800 - 103c 12bc d530 CMT (DG746A) - 1043 80a6 P4P800 Mainboard - 1458 24d2 GA-8IPE1000 Pro2 motherboard (865PE) - 1462 7280 865PE Neo2 (MS-6728) - 8086 3427 S875WP1-E mainboard - 8086 524c D865PERL mainboard - 24db 82801EB/ER (ICH5/ICH5R) IDE Controller - 103c 12bc d530 CMT (DG746A) - 1043 80a6 P4P800 Mainboard - 1458 24d2 GA-8IPE1000 Pro2 motherboard (865PE) - 1462 7280 865PE Neo2 (MS-6728) - 1462 7580 MSI 875P - 8086 24db P4C800 Mainboard - 8086 3427 S875WP1-E mainboard - 8086 524c D865PERL mainboard - 24dc 82801EB (ICH5) LPC Interface Bridge - 24dd 82801EB/ER (ICH5/ICH5R) USB2 EHCI Controller - 1028 0183 PowerEdge 1800 - 103c 12bc d530 CMT (DG746A) - 1043 80a6 P4P800 Mainboard - 1458 5006 GA-8IPE1000 Pro2 motherboard (865PE) - 1462 7280 865PE Neo2 (MS-6728) - 8086 3427 S875WP1-E mainboard - 8086 524c D865PERL mainboard - 24de 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #4 - 1043 80a6 P4P800 Mainboard - 1458 24d2 GA-8IPE1000 Pro2 motherboard (865PE) - 1462 7280 865PE Neo2 (MS-6728) - 8086 3427 S875WP1-E mainboard - 8086 524c D865PERL mainboard - 24df 82801ER (ICH5R) SATA Controller - 2500 82820 820 (Camino) Chipset Host Bridge (MCH) - 1028 0095 Precision Workstation 220 Chipset - 1043 801c P3C-2000 system chipset - 2501 82820 820 (Camino) Chipset Host Bridge (MCH) - 1043 801c P3C-2000 system chipset - 250b 82820 820 (Camino) Chipset Host Bridge - 250f 82820 820 (Camino) Chipset AGP Bridge - 2520 82805AA MTH Memory Translator Hub - 2521 82804AA MRH-S Memory Repeater Hub for SDRAM - 2530 82850 850 (Tehama) Chipset Host Bridge (MCH) - 147b 0507 TH7II-RAID - 2531 82860 860 (Wombat) Chipset Host Bridge (MCH) - 2532 82850 850 (Tehama) Chipset AGP Bridge - 2533 82860 860 (Wombat) Chipset AGP Bridge - 2534 82860 860 (Wombat) Chipset PCI Bridge - 2540 E7500 Memory Controller Hub - 15d9 3480 P4DP6 - 2541 E7500/E7501 Host RASUM Controller - 15d9 3480 P4DP6 - 4c53 1090 Cx9 / Vx9 mainboard - 8086 3424 SE7501HG2 Mainboard - 2543 E7500/E7501 Hub Interface B PCI-to-PCI Bridge - 2544 E7500/E7501 Hub Interface B RASUM Controller - 4c53 1090 Cx9 / Vx9 mainboard - 2545 E7500/E7501 Hub Interface C PCI-to-PCI Bridge - 2546 E7500/E7501 Hub Interface C RASUM Controller - 2547 E7500/E7501 Hub Interface D PCI-to-PCI Bridge - 2548 E7500/E7501 Hub Interface D RASUM Controller - 254c E7501 Memory Controller Hub - 4c53 1090 Cx9 / Vx9 mainboard - 8086 3424 SE7501HG2 Mainboard - 2550 E7505 Memory Controller Hub - 2551 E7505/E7205 Series RAS Controller - 2552 E7505/E7205 PCI-to-AGP Bridge - 2553 E7505 Hub Interface B PCI-to-PCI Bridge - 2554 E7505 Hub Interface B PCI-to-PCI Bridge RAS Controller - 255d E7205 Memory Controller Hub - 2560 82845G/GL[Brookdale-G]/GE/PE DRAM Controller/Host-Hub Interface - 1028 0126 Optiplex GX260 - 1458 2560 GA-8PE667 Ultra - 1462 5800 845PE Max (MS-6580) - 2561 82845G/GL[Brookdale-G]/GE/PE Host-to-AGP Bridge - 2562 82845G/GL[Brookdale-G]/GE Chipset Integrated Graphics Device - 1014 0267 NetVista A30p - 2570 82865G/PE/P DRAM Controller/Host-Hub Interface - 1043 80f2 P4P800 Mainboard - 1458 2570 GA-8IPE1000 Pro2 motherboard (865PE) - 2571 82865G/PE/P PCI to AGP Controller - 2572 82865G Integrated Graphics Controller - 2573 82865G/PE/P PCI to CSA Bridge - 2576 82865G/PE/P Processor to I/O Memory Interface - 2578 82875P/E7210 Memory Controller Hub - 1458 2578 GA-8KNXP motherboard (875P) - 1462 7580 MS-6758 (875P Neo) -# Motherboard P4SCE - 15d9 4580 Super Micro Computer Inc. P4SCE - 2579 82875P Processor to AGP Controller - 257b 82875P/E7210 Processor to PCI to CSA Bridge - 257e 82875P/E7210 Processor to I/O Memory Interface - 2580 915G/P/GV/GL/PL/910GL Processor to I/O Controller - 2581 915G/P/GV/GL/PL/910GL PCI Express Root Port - 2582 82915G/GV/910GL Express Chipset Family Graphics Controller - 1028 1079 Optiplex GX280 - 2584 925X/XE Memory Controller Hub - 2585 925X/XE PCI Express Root Port - 2588 E7220/E7221 Memory Controller Hub - 2589 E7220/E7221 PCI Express Root Port - 258a E7221 Integrated Graphics Controller - 2590 Mobile 915GM/PM/GMS/910GML Express Processor to DRAM Controller - 2591 Mobile 915GM/PM Express PCI Express Root Port - 2592 Mobile 915GM/GMS/910GML Express Graphics Controller - 25a1 6300ESB LPC Interface Controller - 25a2 6300ESB PATA Storage Controller - 4c53 10b0 CL9 mainboard - 25a3 6300ESB SATA Storage Controller - 4c53 10b0 CL9 mainboard - 25a4 6300ESB SMBus Controller - 4c53 10b0 CL9 mainboard - 25a6 6300ESB AC'97 Audio Controller - 4c53 10b0 CL9 mainboard - 25a7 6300ESB AC'97 Modem Controller - 25a9 6300ESB USB Universal Host Controller - 4c53 10b0 CL9 mainboard - 25aa 6300ESB USB Universal Host Controller - 4c53 10b0 CL9 mainboard - 25ab 6300ESB Watchdog Timer - 4c53 10b0 CL9 mainboard - 25ac 6300ESB I/O Advanced Programmable Interrupt Controller - 4c53 10b0 CL9 mainboard - 25ad 6300ESB USB2 Enhanced Host Controller - 25ae 6300ESB 64-bit PCI-X Bridge - 25b0 6300ESB SATA RAID Controller - 2600 E8500 Hub Interface - 2601 E8500 PCI Express x4 Port D - 2602 E8500 PCI Express x4 Port C0 - 2603 E8500 PCI Express x4 Port C1 - 2604 E8500 PCI Express x4 Port B0 - 2605 E8500 PCI Express x4 Port B1 - 2606 E8500 PCI Express x4 Port A0 - 2607 E8500 PCI Express x4 Port A1 - 2608 E8500 PCI Express x8 Port C - 2609 E8500 PCI Express x8 Port B - 260a E8500 PCI Express x8 Port A - 260c E8500 IMI Registers - 2610 E8500 System Bus, Boot, and Interrupt Registers - 2611 E8500 Address Mapping Registers - 2612 E8500 RAS Registers - 2613 E8500 Reserved Registers - 2614 E8500 Reserved Registers - 2615 E8500 Miscellaneous Registers - 2617 E8500 Reserved Registers - 2618 E8500 Reserved Registers - 2619 E8500 Reserved Registers - 261a E8500 Reserved Registers - 261b E8500 Reserved Registers - 261c E8500 Reserved Registers - 261d E8500 Reserved Registers - 261e E8500 Reserved Registers - 2620 E8500 eXternal Memory Bridge - 2621 E8500 XMB Miscellaneous Registers - 2622 E8500 XMB Memory Interleaving Registers - 2623 E8500 XMB DDR Initialization and Calibration - 2624 E8500 XMB Reserved Registers - 2625 E8500 XMB Reserved Registers - 2626 E8500 XMB Reserved Registers - 2627 E8500 XMB Reserved Registers - 2640 82801FB/FR (ICH6/ICH6R) LPC Interface Bridge - 2641 82801FBM (ICH6M) LPC Interface Bridge - 2642 82801FW/FRW (ICH6W/ICH6RW) LPC Interface Bridge - 2651 82801FB/FW (ICH6/ICH6W) SATA Controller - 1028 0179 Optiplex GX280 - 2652 82801FR/FRW (ICH6R/ICH6RW) SATA Controller - 2653 82801FBM (ICH6M) SATA Controller - 2658 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #1 - 1028 0179 Optiplex GX280 - 2659 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #2 - 1028 0179 Optiplex GX280 - 265a 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #3 - 1028 0179 Optiplex GX280 - 265b 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #4 - 1028 0179 Optiplex GX280 - 265c 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller - 1028 0179 Optiplex GX280 - 2660 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 1 - 2662 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 2 - 2664 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 3 - 2666 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 4 - 2668 82801FB/FBM/FR/FW/FRW (ICH6 Family) High Definition Audio Controller - 266a 82801FB/FBM/FR/FW/FRW (ICH6 Family) SMBus Controller - 1028 0179 Optiplex GX280 - 266c 82801FB/FBM/FR/FW/FRW (ICH6 Family) LAN Controller - 266d 82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Modem Controller - 266e 82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Audio Controller - 1028 0179 Optiplex GX280 - 266f 82801FB/FBM/FR/FW/FRW (ICH6 Family) IDE Controller - 2770 Memory Controller Hub - 2771 PCI Express Graphics Port - 2772 Integrated Graphics Controller - 2774 Workstation Memory Controller Hub - 2775 PCI Express Graphics Port - 2776 Integrated Graphics Controller - 2778 Server Memory Controller Hub - 2779 PCI Express Root Port - 2782 82915G Express Chipset Family Graphics Controller - 2792 Mobile 915GM/GMS/910GML Express Graphics Controller - 27b8 I/O Controller Hub LPC - 27b9 Mobile I/O Controller Hub LPC - 27c0 I/O Controller Hub SATA cc=IDE - 27c1 I/O Controller Hub SATA cc=AHCI - 27c3 I/O Controller Hub SATA cc=RAID - 27c4 Mobile I/O Controller Hub SATA cc=IDE - 27c5 Mobile I/O Controller Hub SATA cc=AHCI - 27c8 I/O Controller Hub UHCI USB #1 - 27c9 I/O Controller Hub UHCI USB #2 - 27ca I/O Controller Hub UHCI USB #3 - 27cb I/O Controller Hub UHCI USB #4 - 27cc I/O Controller Hub EHCI USB - 27d0 I/O Controller Hub PCI Express Port 1 - 27d2 I/O Controller Hub PCI Express Port 2 - 27d4 I/O Controller Hub PCI Express Port 3 - 27d6 I/O Controller Hub PCI Express Port 4 - 27d8 I/O Controller Hub High Definition Audio - 27da I/O Controller Hub SMBus - 27dc I/O Controller Hub LAN - 27dd I/O Controller Hub AC'97 Modem - 27de I/O Controller Hub AC'97 Audio - 27df I/O Controller Hub PATA - 27e0 I/O Controller Hub PCI Express Port 5 - 27e2 I/O Controller Hub PCI Express Port 6 - 3092 Integrated RAID - 3200 GD31244 PCI-X SATA HBA - 3340 82855PM Processor to I/O Controller - 1025 005a TravelMate 290 - 103c 088c nc8000 laptop - 103c 0890 nc6000 laptop - 3341 82855PM Processor to AGP Controller - 3575 82830 830 Chipset Host Bridge - 1014 021d ThinkPad A/T/X Series - 104d 80e7 VAIO PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP - 3576 82830 830 Chipset AGP Bridge - 3577 82830 CGC [Chipset Graphics Controller] - 1014 0513 ThinkPad A/T/X Series - 3578 82830 830 Chipset Host Bridge - 3580 82852/82855 GM/GME/PM/GMV Processor to I/O Controller - 1028 0163 Latitude D505 - 4c53 10b0 CL9 mainboard - 3581 82852/82855 GM/GME/PM/GMV Processor to AGP Controller - 3582 82852/855GM Integrated Graphics Device - 1028 0163 Latitude D505 - 4c53 10b0 CL9 mainboard - 3584 82852/82855 GM/GME/PM/GMV Processor to I/O Controller - 1028 0163 Latitude D505 - 4c53 10b0 CL9 mainboard - 3585 82852/82855 GM/GME/PM/GMV Processor to I/O Controller - 1028 0163 Latitude D505 - 4c53 10b0 CL9 mainboard - 3590 E7520 Memory Controller Hub - 3591 E7525/E7520 Error Reporting Registers - 3592 E7320 Memory Controller Hub - 3593 E7320 Error Reporting Registers - 3594 E7520 DMA Controller - 3595 E7525/E7520/E7320 PCI Express Port A - 3596 E7525/E7520/E7320 PCI Express Port A1 - 3597 E7525/E7520 PCI Express Port B - 3598 E7520 PCI Express Port B1 - 3599 E7520 PCI Express Port C - 359a E7520 PCI Express Port C1 - 359b E7525/E7520/E7320 Extended Configuration Registers - 359e E7525 Memory Controller Hub - 4220 PRO/Wireless 2200BG - 4223 PRO/Wireless 2915ABG MiniPCI Adapter - 5200 EtherExpress PRO/100 Intelligent Server - 5201 EtherExpress PRO/100 Intelligent Server - 8086 0001 EtherExpress PRO/100 Server Ethernet Adapter - 530d 80310 IOP [IO Processor] - 7000 82371SB PIIX3 ISA [Natoma/Triton II] - 7010 82371SB PIIX3 IDE [Natoma/Triton II] - 7020 82371SB PIIX3 USB [Natoma/Triton II] - 7030 430VX - 82437VX TVX [Triton VX] - 7050 Intel Intercast Video Capture Card - 7100 430TX - 82439TX MTXC - 7110 82371AB/EB/MB PIIX4 ISA - 15ad 1976 virtualHW v3 - 7111 82371AB/EB/MB PIIX4 IDE - 15ad 1976 virtualHW v3 - 7112 82371AB/EB/MB PIIX4 USB - 15ad 1976 virtualHW v3 - 7113 82371AB/EB/MB PIIX4 ACPI - 15ad 1976 virtualHW v3 - 7120 82810 GMCH [Graphics Memory Controller Hub] - 4c53 1040 CL7 mainboard - 4c53 1060 PC7 mainboard - 7121 82810 CGC [Chipset Graphics Controller] - 4c53 1040 CL7 mainboard - 4c53 1060 PC7 mainboard - 8086 4341 Cayman (CA810) Mainboard - 7122 82810 DC-100 GMCH [Graphics Memory Controller Hub] - 7123 82810 DC-100 CGC [Chipset Graphics Controller] - 7124 82810E DC-133 GMCH [Graphics Memory Controller Hub] - 7125 82810E DC-133 CGC [Chipset Graphics Controller] - 7126 82810 DC-133 System and Graphics Controller - 7128 82810-M DC-100 System and Graphics Controller - 712a 82810-M DC-133 System and Graphics Controller - 7180 440LX/EX - 82443LX/EX Host bridge - 7181 440LX/EX - 82443LX/EX AGP bridge - 7190 440BX/ZX/DX - 82443BX/ZX/DX Host bridge - 0e11 0500 Armada 1750 Laptop System Chipset - 0e11 b110 Armada M700/E500 - 1179 0001 Toshiba Tecra 8100 Laptop System Chipset - 15ad 1976 virtualHW v3 - 4c53 1050 CT7 mainboard - 4c53 1051 CE7 mainboard - 7191 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge - 7192 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (AGP disabled) - 0e11 0460 Armada 1700 Laptop System Chipset - 4c53 1000 CC7/CR7/CP7/VC7/VP7/VR7 mainboard - 7194 82440MX Host Bridge - 1033 0000 Versa Note Vxi - 4c53 10a0 CA3/CR3 mainboard - 7195 82440MX AC'97 Audio Controller - 1033 80cc Versa Note VXi - 10cf 1099 QSound_SigmaTel Stac97 PCI Audio - 11d4 0040 SoundMAX Integrated Digital Audio - 11d4 0048 SoundMAX Integrated Digital Audio - 7196 82440MX AC'97 Modem Controller - 7198 82440MX ISA Bridge - 7199 82440MX EIDE Controller - 719a 82440MX USB Universal Host Controller - 719b 82440MX Power Management Controller - 71a0 440GX - 82443GX Host bridge - 4c53 1050 CT7 mainboard - 4c53 1051 CE7 mainboard - 71a1 440GX - 82443GX AGP bridge - 71a2 440GX - 82443GX Host bridge (AGP disabled) - 4c53 1000 CC7/CR7/CP7/VC7/VP7/VR7 mainboard - 7600 82372FB PIIX5 ISA - 7601 82372FB PIIX5 IDE - 7602 82372FB PIIX5 USB - 7603 82372FB PIIX5 SMBus - 7800 82740 (i740) AGP Graphics Accelerator - 003d 0008 Starfighter AGP - 003d 000b Starfighter AGP - 1092 0100 Stealth II G460 - 10b4 201a Lightspeed 740 - 10b4 202f Lightspeed 740 - 8086 0000 Terminator 2x/i - 8086 0100 Intel740 Graphics Accelerator - 84c4 450KX/GX [Orion] - 82454KX/GX PCI bridge - 84c5 450KX/GX [Orion] - 82453KX/GX Memory controller - 84ca 450NX - 82451NX Memory & I/O Controller - 84cb 450NX - 82454NX/84460GX PCI Expander Bridge - 84e0 460GX - 84460GX System Address Controller (SAC) - 84e1 460GX - 84460GX System Data Controller (SDC) - 84e2 460GX - 84460GX AGP Bridge (GXB function 2) - 84e3 460GX - 84460GX Memory Address Controller (MAC) - 84e4 460GX - 84460GX Memory Data Controller (MDC) - 84e6 460GX - 82466GX Wide and fast PCI eXpander Bridge (WXB) - 84ea 460GX - 84460GX AGP Bridge (GXB function 1) - 8500 IXP4XX - Intel Network Processor family. IXP420, IXP421, IXP422, IXP425 and IXC1100 - 1993 0dee mGuard-PCI AV#1 - 1993 0def mGuard-PCI AV#0 - 9000 IXP2000 Family Network Processor - 9001 IXP2400 Network Processor - 9004 IXP2800 Network Processor - 9621 Integrated RAID - 9622 Integrated RAID - 9641 Integrated RAID - 96a1 Integrated RAID -# retail verson - a01f PRO/10GbE LR Server Adapter -# OEM version - a11f PRO/10GbE LR Server Adapter - b152 21152 PCI-to-PCI Bridge -# observed, and documented in Intel revision note; new mask of 1011:0026 - b154 21154 PCI-to-PCI Bridge - b555 21555 Non transparent PCI-to-PCI Bridge - 12d9 000a PCI VoIP Gateway - 4c53 1050 CT7 mainboard - 4c53 1051 CE7 mainboard - e4bf 1000 CC8-1-BLUES - ffff 450NX/GX [Orion] - 82453KX/GX Memory controller [BUG] -8401 TRENDware International Inc. -8800 Trigem Computer Inc. - 2008 Video assistent component -8866 T-Square Design Inc. -8888 Silicon Magic -# 8c4a is not Winbond but there is a board misprogrammed -8c4a Winbond - 1980 W89C940 misprogrammed [ne2k] -8e0e Computone Corporation -8e2e KTI - 3000 ET32P2 -9004 Adaptec - 0078 AHA-2940U_CN - 1078 AIC-7810 - 1160 AIC-1160 [Family Fibre Channel Adapter] - 2178 AIC-7821 - 3860 AHA-2930CU - 3b78 AHA-4844W/4844UW - 5075 AIC-755x - 5078 AHA-7850 - 9004 7850 AHA-2904/Integrated AIC-7850 - 5175 AIC-755x - 5178 AIC-7851 - 5275 AIC-755x - 5278 AIC-7852 - 5375 AIC-755x - 5378 AIC-7850 - 5475 AIC-755x - 5478 AIC-7850 - 5575 AVA-2930 - 5578 AIC-7855 - 5647 ANA-7711 TCP Offload Engine - 9004 7710 ANA-7711F TCP Offload Engine - Optical - 9004 7711 ANA-7711LP TCP Offload Engine - Copper - 5675 AIC-755x - 5678 AIC-7856 - 5775 AIC-755x - 5778 AIC-7850 - 5800 AIC-5800 - 5900 ANA-5910/5930/5940 ATM155 & 25 LAN Adapter - 5905 ANA-5910A/5930A/5940A ATM Adapter - 6038 AIC-3860 - 6075 AIC-1480 / APA-1480 - 9004 7560 AIC-1480 / APA-1480 Cardbus - 6078 AIC-7860 - 6178 AIC-7861 - 9004 7861 AHA-2940AU Single - 6278 AIC-7860 - 6378 AIC-7860 - 6478 AIC-786x - 6578 AIC-786x - 6678 AIC-786x - 6778 AIC-786x - 6915 ANA620xx/ANA69011A - 9004 0008 ANA69011A/TX 10/100 - 9004 0009 ANA69011A/TX 10/100 - 9004 0010 ANA62022 2-port 10/100 - 9004 0018 ANA62044 4-port 10/100 - 9004 0019 ANA62044 4-port 10/100 - 9004 0020 ANA62022 2-port 10/100 - 9004 0028 ANA69011A/TX 10/100 - 9004 8008 ANA69011A/TX 64 bit 10/100 - 9004 8009 ANA69011A/TX 64 bit 10/100 - 9004 8010 ANA62022 2-port 64 bit 10/100 - 9004 8018 ANA62044 4-port 64 bit 10/100 - 9004 8019 ANA62044 4-port 64 bit 10/100 - 9004 8020 ANA62022 2-port 64 bit 10/100 - 9004 8028 ANA69011A/TX 64 bit 10/100 - 7078 AHA-294x / AIC-7870 - 7178 AHA-2940/2940W / AIC-7871 - 7278 AHA-3940/3940W / AIC-7872 - 7378 AHA-3985 / AIC-7873 - 7478 AHA-2944/2944W / AIC-7874 - 7578 AHA-3944/3944W / AIC-7875 - 7678 AHA-4944W/UW / AIC-7876 - 7710 ANA-7711F Network Accelerator Card (NAC) - Optical - 7711 ANA-7711C Network Accelerator Card (NAC) - Copper - 7778 AIC-787x - 7810 AIC-7810 - 7815 AIC-7815 RAID+Memory Controller IC - 9004 7815 ARO-1130U2 RAID Controller - 9004 7840 AIC-7815 RAID+Memory Controller IC - 7850 AIC-7850 - 7855 AHA-2930 - 7860 AIC-7860 - 7870 AIC-7870 - 7871 AHA-2940 - 7872 AHA-3940 - 7873 AHA-3980 - 7874 AHA-2944 - 7880 AIC-7880P - 7890 AIC-7890 - 7891 AIC-789x - 7892 AIC-789x - 7893 AIC-789x - 7894 AIC-789x - 7895 AHA-2940U/UW / AHA-39xx / AIC-7895 - 9004 7890 AHA-2940U/2940UW Dual AHA-394xAU/AUW/AUWD AIC-7895B - 9004 7891 AHA-2940U/2940UW Dual - 9004 7892 AHA-3940AU/AUW/AUWD/UWD - 9004 7894 AHA-3944AUWD - 9004 7895 AHA-2940U/2940UW Dual AHA-394xAU/AUW/AUWD AIC-7895B - 9004 7896 AHA-2940U/2940UW Dual AHA-394xAU/AUW/AUWD AIC-7895B - 9004 7897 AHA-2940U/2940UW Dual AHA-394xAU/AUW/AUWD AIC-7895B - 7896 AIC-789x - 7897 AIC-789x - 8078 AIC-7880U - 9004 7880 AIC-7880P Ultra/Ultra Wide SCSI Chipset - 8178 AHA-2940U/UW/D / AIC-7881U - 9004 7881 AHA-2940UW SCSI Host Adapter - 8278 AHA-3940U/UW/UWD / AIC-7882U - 8378 AHA-3940U/UW / AIC-7883U - 8478 AHA-2944UW / AIC-7884U - 8578 AHA-3944U/UWD / AIC-7885 - 8678 AHA-4944UW / AIC-7886 - 8778 AHA-2940UW Pro / AIC-788x - 9004 7887 2940UW Pro Ultra-Wide SCSI Controller - 8878 AHA-2930UW / AIC-7888 - 9004 7888 AHA-2930UW SCSI Controller - 8b78 ABA-1030 - ec78 AHA-4944W/UW -9005 Adaptec - 0010 AHA-2940U2/U2W - 9005 2180 AHA-2940U2 SCSI Controller - 9005 8100 AHA-2940U2B SCSI Controller - 9005 a100 AHA-2940U2B SCSI Controller - 9005 a180 AHA-2940U2W SCSI Controller - 9005 e100 AHA-2950U2B SCSI Controller - 0011 AHA-2930U2 - 0013 78902 - 9005 0003 AAA-131U2 Array1000 1 Channel RAID Controller - 9005 000f AIC7890_ARO - 001f AHA-2940U2/U2W / 7890/7891 - 9005 000f 2940U2W SCSI Controller - 9005 a180 2940U2W SCSI Controller - 0020 AIC-7890 - 002f AIC-7890 - 0030 AIC-7890 - 003f AIC-7890 - 0050 AHA-3940U2x/395U2x - 9005 f500 AHA-3950U2B - 9005 ffff AHA-3950U2B - 0051 AHA-3950U2D - 9005 b500 AHA-3950U2D - 0053 AIC-7896 SCSI Controller - 9005 ffff AIC-7896 SCSI Controller mainboard implementation - 005f AIC-7896U2/7897U2 - 0080 AIC-7892A U160/m - 0e11 e2a0 Compaq 64-Bit/66MHz Wide Ultra3 SCSI Adapter - 9005 6220 AHA-29160C - 9005 62a0 29160N Ultra160 SCSI Controller - 9005 e220 29160LP Low Profile Ultra160 SCSI Controller - 9005 e2a0 29160 Ultra160 SCSI Controller - 0081 AIC-7892B U160/m - 9005 62a1 19160 Ultra160 SCSI Controller - 0083 AIC-7892D U160/m - 008f AIC-7892P U160/m - 1179 0001 Magnia Z310 - 15d9 9005 Onboard SCSI Host Adapter - 00c0 AHA-3960D / AIC-7899A U160/m - 0e11 f620 Compaq 64-Bit/66MHz Dual Channel Wide Ultra3 SCSI Adapter - 9005 f620 AHA-3960D U160/m - 00c1 AIC-7899B U160/m - 00c3 AIC-7899D U160/m - 00c5 RAID subsystem HBA - 1028 00c5 PowerEdge 2400,2500,2550,4400 - 00cf AIC-7899P U160/m - 1028 00ce PowerEdge 1400 - 1028 00d1 PowerEdge 2550 - 1028 00d9 PowerEdge 2500 - 10f1 2462 Thunder K7 S2462 - 15d9 9005 Onboard SCSI Host Adapter - 8086 3411 SDS2 Mainboard - 0250 ServeRAID Controller - 1014 0279 ServeRAID-xx - 1014 028c ServeRAID-xx -# from kernel sources - 0279 ServeRAID 6M - 0283 AAC-RAID - 9005 0283 Catapult - 0284 AAC-RAID - 9005 0284 Tomcat - 0285 AAC-RAID - 0e11 0295 SATA 6Ch (Bearcat) - 1014 02f2 ServeRAID 8i - 1028 0287 PowerEdge Expandable RAID Controller 320/DC - 1028 0291 CERC SATA RAID 2 PCI SATA 6ch (DellCorsair) - 103c 3227 AAR-2610SA - 17aa 0286 Legend S220 (Legend Crusader) - 17aa 0287 Legend S230 (Legend Vulcan) - 9005 0285 2200S (Vulcan) - 9005 0286 2120S (Crusader) - 9005 0287 2200S (Vulcan-2m) - 9005 0288 3230S (Harrier) - 9005 0289 3240S (Tornado) - 9005 028a ASR-2020S PCI-X ZCR (Skyhawk) - 9005 028b ASR-2020S SO-DIMM PCI-X ZCR (Terminator) - 9005 0290 AAR-2410SA PCI SATA 4ch (Jaguar II) - 9005 0292 AAR-2810SA PCI SATA 8ch (Corsair-8) - 9005 0293 AAR-21610SA PCI SATA 16ch (Corsair-16) - 9005 0294 ESD SO-DIMM PCI-X SATA ZCR (Prowler) - 0286 AAC-RAID (Rocket) - 9005 028c ASR-2230S + ASR-2230SLP PCI-X (Lancer) - 0503 Scamp chipset SCSI controller - 1014 02BF Quad Channel PCI-X DDR U320 SCSI RAID Adapter (571E) - 8000 ASC-29320A U320 - 800f AIC-7901 U320 - 8010 ASC-39320 U320 - 8011 ASC-32320D U320 - 0e11 00ac ASC-39320D U320 - 9005 0041 ASC-39320D U320 - 8012 ASC-29320 U320 - 8013 ASC-29320B U320 - 8014 ASC-29320LP U320 - 8015 ASC-39320B U320 - 8016 ASC-39320A U320 - 8017 ASC-29320ALP U320 - 801c ASC-39320D U320 - 801d AIC-7902B U320 - 801e AIC-7901A U320 - 801f AIC-7902 U320 - 8080 ASC-29320A U320 w/HostRAID - 808f AIC-7901 U320 w/HostRAID - 8090 ASC-39320 U320 w/HostRAID - 8091 ASC-39320D U320 w/HostRAID - 8092 ASC-29320 U320 w/HostRAID - 8093 ASC-29320B U320 w/HostRAID - 8094 ASC-29320LP U320 w/HostRAID - 8095 ASC-39320(B) U320 w/HostRAID - 8096 ASC-39320A U320 w/HostRAID - 8097 ASC-29320ALP U320 w/HostRAID - 809c ASC-39320D(B) U320 w/HostRAID - 809d AIC-7902(B) U320 w/HostRAID - 809e AIC-7901A U320 w/HostRAID - 809f AIC-7902 U320 w/HostRAID -907f Atronics - 2015 IDE-2015PL -919a Gigapixel Corp -9412 Holtek - 6565 6565 -9699 Omni Media Technology Inc - 6565 6565 -9710 NetMos Technology - 7780 USB IRDA-port - 9705 PCI 9705 Parallel Port - 9715 PCI 9715 Dual Parallel Port - 9735 PCI 9735 Multi-I/O Controller - 1000 0002 0P2S (2 serial) - 1000 0012 1P2S (1 parallel + 2 serial) - 9745 PCI 9745 Multi-I/O Controller - 1000 0002 0P2S (2 serial) - 1000 0012 1P2S (1 parallel + 2 serial) - 9755 PCI 9755 Parallel Port and ISA Bridge - 9805 PCI 9805 Parallel Port - 9815 PCI 9815 Dual Parallel Port - 1000 0020 2P0S (2 port parallel adaptor) - 9835 PCI 9835 Multi-I/O Controller - 1000 0002 0P2S (16C550 UART) - 1000 0012 1P2S - 9845 PCI 9845 Multi-I/O Controller - 1000 0004 0P4S (4 port 16550A serial card) - 1000 0006 0P6S (6 port 16550A serial card) - 1000 0014 1P4S (4 port 16550A serial card + parallel) - 9855 PCI 9855 Multi-I/O Controller - 1000 0014 1P4S -9902 Stargen Inc. - 0001 SG2010 PCI over Starfabric Bridge - 0002 SG2010 PCI to Starfabric Gateway - 0003 SG1010 Starfabric Switch and PCI Bridge -a0a0 AOPEN Inc. -a0f1 UNISYS Corporation -a200 NEC Corporation -a259 Hewlett Packard -a25b Hewlett Packard GmbH PL24-MKT -a304 Sony -a727 3Com Corporation - 0013 3CRPAG175 Wireless PC Card -aa42 Scitex Digital Video -ac1e Digital Receiver Technology Inc -ac3d Actuality Systems -aecb Adrienne Electronics Corporation -b1b3 Shiva Europe Limited -# Pinnacle should be 11bd, but they got it wrong several times --mj -bd11 Pinnacle Systems, Inc. (Wrong ID) -c001 TSI Telsys -c0a9 Micron/Crucial Technology -c0de Motorola -c0fe Motion Engineering, Inc. -ca50 Varian Australia Pty Ltd -cafe Chrysalis-ITS -cccc Catapult Communications -cddd Tyzx, Inc. - 0101 DeepSea 1 High Speed Stereo Vision Frame Grabber - 0200 DeepSea 2 High Speed Stereo Vision Frame Grabber -d4d4 Dy4 Systems Inc - 0601 PCI Mezzanine Card -d531 I+ME ACTIA GmbH -d84d Exsys -dead Indigita Corporation -deaf Middle Digital Inc. - 9050 PC Weasel Virtual VGA - 9051 PC Weasel Serial Port - 9052 PC Weasel Watchdog Timer -e000 Winbond - e000 W89C940 -# see also : http://www.schoenfeld.de/inside/Inside_CWMK3.txt maybe a misuse of TJN id or it use the TJN 3XX chip for other applic -e159 Tiger Jet Network Inc. - 0001 Tiger3XX Modem/ISDN interface - 0059 0001 128k ISDN-S/T Adapter - 0059 0003 128k ISDN-U Adapter - 0002 Tiger100APC ISDN chipset -e4bf EKF Elektronik GmbH -# Innovative and scalable network IC vendor -e55e Essence Technology, Inc. -ea01 Eagle Technology -# The main chip of all these devices is by Xilinx -> It could also be a Xilinx ID. -ea60 RME - 9896 Digi32 - 9897 Digi32 Pro - 9898 Digi32/8 -eabb Aashima Technology B.V. -eace Endace Measurement Systems, Ltd - 3100 DAG 3.10 OC-3/OC-12 - 3200 DAG 3.2x OC-3/OC-12 - 320e DAG 3.2E Fast Ethernet - 340e DAG 3.4E Fast Ethernet - 341e DAG 3.41E Fast Ethernet - 3500 DAG 3.5 OC-3/OC-12 - 351c DAG 3.5ECM Fast Ethernet - 4100 DAG 4.10 OC-48 - 4110 DAG 4.11 OC-48 - 4220 DAG 4.2 OC-48 - 422e DAG 4.2E Dual Gigabit Ethernet -ec80 Belkin Corporation - ec00 F5D6000 -ecc0 Echo Digital Audio Corporation -edd8 ARK Logic Inc - a091 1000PV [Stingray] - a099 2000PV [Stingray] - a0a1 2000MT - a0a9 2000MI -f1d0 AJA Video -# All boards I have seen have this ID not efac, though all docs say efac... - cafe KONA SD SMPTE 259M I/O - efac KONA SD SMPTE 259M I/O - facd KONA HD SMPTE 292M I/O -fa57 Interagon AS - 0001 PMC [Pattern Matching Chip] -febd Ultraview Corp. -feda Broadcom Inc (nee Epigram) - a0fa BCM4210 iLine10 HomePNA 2.0 - a10e BCM4230 iLine10 HomePNA 2.0 -# IT & Telecom company, develops PCI Trunk cards -fede Fedetec Inc. - 0003 TABIC PCI v3 -fffe VMWare Inc - 0405 Virtual SVGA 4.0 - 0710 Virtual SVGA -ffff Illegal Vendor ID - - -# List of known device classes, subclasses and programming interfaces - -# Syntax: -# C class class_name -# subclass subclass_name <-- single tab -# prog-if prog-if_name <-- two tabs - -C 00 Unclassified device - 00 Non-VGA unclassified device - 01 VGA compatible unclassified device -C 01 Mass storage controller - 00 SCSI storage controller - 01 IDE interface - 02 Floppy disk controller - 03 IPI bus controller - 04 RAID bus controller - 80 Unknown mass storage controller -C 02 Network controller - 00 Ethernet controller - 01 Token ring network controller - 02 FDDI network controller - 03 ATM network controller - 04 ISDN controller - 80 Network controller -C 03 Display controller - 00 VGA compatible controller - 00 VGA - 01 8514 - 01 XGA compatible controller - 02 3D controller - 80 Display controller -C 04 Multimedia controller - 00 Multimedia video controller - 01 Multimedia audio controller - 02 Computer telephony device - 80 Multimedia controller -C 05 Memory controller - 00 RAM memory - 01 FLASH memory - 80 Memory controller -C 06 Bridge - 00 Host bridge - 01 ISA bridge - 02 EISA bridge - 03 MicroChannel bridge - 04 PCI bridge - 00 Normal decode - 01 Subtractive decode - 05 PCMCIA bridge - 06 NuBus bridge - 07 CardBus bridge - 08 RACEway bridge - 00 Transparent mode - 01 Endpoint mode - 09 Semi-transparent PCI-to-PCI bridge - 40 Primary bus towards host CPU - 80 Secondary bus towards host CPU - 0a InfiniBand to PCI host bridge - 80 Bridge -C 07 Communication controller - 00 Serial controller - 00 8250 - 01 16450 - 02 16550 - 03 16650 - 04 16750 - 05 16850 - 06 16950 - 01 Parallel controller - 00 SPP - 01 BiDir - 02 ECP - 03 IEEE1284 - fe IEEE1284 Target - 02 Multiport serial controller - 03 Modem - 00 Generic - 01 Hayes/16450 - 02 Hayes/16550 - 03 Hayes/16650 - 04 Hayes/16750 - 80 Communication controller -C 08 Generic system peripheral - 00 PIC - 00 8259 - 01 ISA PIC - 02 EISA PIC - 10 IO-APIC - 20 IO(X)-APIC - 01 DMA controller - 00 8237 - 01 ISA DMA - 02 EISA DMA - 02 Timer - 00 8254 - 01 ISA Timer - 02 EISA Timers - 03 RTC - 00 Generic - 01 ISA RTC - 04 PCI Hot-plug controller - 80 System peripheral -C 09 Input device controller - 00 Keyboard controller - 01 Digitizer Pen - 02 Mouse controller - 03 Scanner controller - 04 Gameport controller - 00 Generic - 10 Extended - 80 Input device controller -C 0a Docking station - 00 Generic Docking Station - 80 Docking Station -C 0b Processor - 00 386 - 01 486 - 02 Pentium - 10 Alpha - 20 Power PC - 30 MIPS - 40 Co-processor -C 0c Serial bus controller - 00 FireWire (IEEE 1394) - 00 Generic - 10 OHCI - 01 ACCESS Bus - 02 SSA - 03 USB Controller - 00 UHCI - 10 OHCI - 20 EHCI - 80 Unspecified - fe USB Device - 04 Fibre Channel - 05 SMBus - 06 InfiniBand -C 0d Wireless controller - 00 IRDA controller - 01 Consumer IR controller - 10 RF controller - 80 Wireless controller -C 0e Intelligent controller - 00 I2O -C 0f Satellite communications controller - 00 Satellite TV controller - 01 Satellite audio communication controller - 03 Satellite voice communication controller - 04 Satellite data communication controller -C 10 Encryption controller - 00 Network and computing encryption device - 10 Entertainment encryption device - 80 Encryption controller -C 11 Signal processing controller - 00 DPIO module - 01 Performance counters - 10 Communication synchronizer - 80 Signal processing controller diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 93e8a87..4be1b88 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -757,8 +757,6 @@ pci_scan_device(struct pci_bus *bus, int devfn) dev->dev.release = pci_release_dev; pci_dev_get(dev); - pci_name_device(dev); - dev->dev.dma_mask = &dev->dma_mask; dev->dev.coherent_dma_mask = 0xffffffffull; diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 7988fc8..9613f66 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -474,7 +474,7 @@ static int show_dev_config(struct seq_file *m, void *v) struct pci_dev *first_dev; struct pci_driver *drv; u32 class_rev; - unsigned char latency, min_gnt, max_lat, *class; + unsigned char latency, min_gnt, max_lat; int reg; first_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); @@ -490,16 +490,8 @@ static int show_dev_config(struct seq_file *m, void *v) pci_read_config_byte (dev, PCI_MAX_LAT, &max_lat); seq_printf(m, " Bus %2d, device %3d, function %2d:\n", dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); - class = pci_class_name(class_rev >> 16); - if (class) - seq_printf(m, " %s", class); - else - seq_printf(m, " Class %04x", class_rev >> 16); -#ifdef CONFIG_PCI_NAMES - seq_printf(m, ": %s", dev->pretty_name); -#else + seq_printf(m, " Class %04x", class_rev >> 16); seq_printf(m, ": PCI device %04x:%04x", dev->vendor, dev->device); -#endif seq_printf(m, " (rev %d).\n", class_rev & 0xff); if (dev->irq) diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index fc05606..7b9e54c 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -121,10 +121,6 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) } } -#ifdef CONFIG_PCI_NAMES - hcd->product_desc = dev->pretty_name; -#endif - pci_set_master (dev); retval = usb_add_hcd (hcd, dev->irq, SA_SHIRQ); diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c index 52b1685..30f80c2 100644 --- a/drivers/video/nvidia/nvidia.c +++ b/drivers/video/nvidia/nvidia.c @@ -1473,10 +1473,6 @@ static int __devinit nvidiafb_probe(struct pci_dev *pd, par->Chipset = (pd->vendor << 16) | pd->device; printk(KERN_INFO PFX "nVidia device/chipset %X\n", par->Chipset); -#ifdef CONFIG_PCI_NAMES - printk(KERN_INFO PFX "%s\n", pd->pretty_name); -#endif - if (par->Architecture == 0) { printk(KERN_ERR PFX "unknown NV_ARCH\n"); goto err_out_free_base0; diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c index ae297e2..3e9f96e 100644 --- a/drivers/video/riva/fbdev.c +++ b/drivers/video/riva/fbdev.c @@ -1936,10 +1936,6 @@ static int __devinit rivafb_probe(struct pci_dev *pd, default_par->Chipset = (pd->vendor << 16) | pd->device; printk(KERN_INFO PFX "nVidia device/chipset %X\n",default_par->Chipset); -#ifdef CONFIG_PCI_NAMES - printk(KERN_INFO PFX "%s\n", pd->pretty_name); -#endif - if(default_par->riva.Architecture == 0) { printk(KERN_ERR PFX "unknown NV_ARCH\n"); ret=-ENODEV; diff --git a/include/linux/pci.h b/include/linux/pci.h index 025bfc3..e7a228f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -562,11 +562,6 @@ struct pci_dev { struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */ int rom_attr_enabled; /* has display of the rom attribute been enabled? */ struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */ -#ifdef CONFIG_PCI_NAMES -#define PCI_NAME_SIZE 255 -#define PCI_NAME_HALF __stringify(43) /* less than half to handle slop */ - char pretty_name[PCI_NAME_SIZE]; /* pretty name for users to see */ -#endif }; #define pci_dev_g(n) list_entry(n, struct pci_dev, global_list) @@ -749,8 +744,6 @@ int pci_scan_slot(struct pci_bus *bus, int devfn); struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn); unsigned int pci_scan_child_bus(struct pci_bus *bus); void pci_bus_add_device(struct pci_dev *dev); -void pci_name_device(struct pci_dev *dev); -char *pci_class_name(u32 class); void pci_read_bridge_bases(struct pci_bus *child); struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res); int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); @@ -1025,13 +1018,6 @@ static inline char *pci_name(struct pci_dev *pdev) return pdev->dev.bus_id; } -/* Some archs want to see the pretty pci name, so use this macro */ -#ifdef CONFIG_PCI_NAMES -#define pci_pretty_name(dev) ((dev)->pretty_name) -#else -#define pci_pretty_name(dev) "" -#endif - /* Some archs don't want to expose struct resource to userland as-is * in sysfs and /proc -- cgit v0.10.2 From 8fdc23ee1ab7c1f8f1dd40602f62b9cc84072531 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 27 Jul 2005 00:07:11 -0700 Subject: [PATCH] PCI: fix up pretty-names removal patch Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c index 7b3586a..854e45b 100644 --- a/arch/ppc/kernel/pci.c +++ b/arch/ppc/kernel/pci.c @@ -80,7 +80,6 @@ fixup_broken_pcnet32(struct pci_dev* dev) if ((dev->class>>8 == PCI_CLASS_NETWORK_ETHERNET)) { dev->vendor = PCI_VENDOR_ID_AMD; pci_write_config_word(dev, PCI_VENDOR_ID, PCI_VENDOR_ID_AMD); - pci_name_device(dev); } } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TRIDENT, PCI_ANY_ID, fixup_broken_pcnet32); -- cgit v0.10.2 From 4352dfd5cd9172f1ee425924a463b43e6157b840 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 28 Jul 2005 11:37:33 -0700 Subject: [PATCH] PCI: clean up pci.h and split pci register info to separate header file. This cleans up some of the #ifdef CONFIG_PCI stuff up, and moves the pci register info out to a separate file, where it belongs. Eventually we can stop including this file from within pci.h, but lots of code needs to be audited first. Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/pci.h b/include/linux/pci.h index e7a228f..830c1ba 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -19,436 +19,10 @@ #include -/* - * Under PCI, each device has 256 bytes of configuration address space, - * of which the first 64 bytes are standardized as follows: - */ -#define PCI_VENDOR_ID 0x00 /* 16 bits */ -#define PCI_DEVICE_ID 0x02 /* 16 bits */ -#define PCI_COMMAND 0x04 /* 16 bits */ -#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ -#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ -#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */ -#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */ -#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ -#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ -#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ -#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ -#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ -#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ -#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ - -#define PCI_STATUS 0x06 /* 16 bits */ -#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */ -#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */ -#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */ -#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */ -#define PCI_STATUS_PARITY 0x100 /* Detected parity error */ -#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ -#define PCI_STATUS_DEVSEL_FAST 0x000 -#define PCI_STATUS_DEVSEL_MEDIUM 0x200 -#define PCI_STATUS_DEVSEL_SLOW 0x400 -#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ -#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ -#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ -#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ -#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ - -#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 - revision */ -#define PCI_REVISION_ID 0x08 /* Revision ID */ -#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ -#define PCI_CLASS_DEVICE 0x0a /* Device class */ - -#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ -#define PCI_LATENCY_TIMER 0x0d /* 8 bits */ -#define PCI_HEADER_TYPE 0x0e /* 8 bits */ -#define PCI_HEADER_TYPE_NORMAL 0 -#define PCI_HEADER_TYPE_BRIDGE 1 -#define PCI_HEADER_TYPE_CARDBUS 2 - -#define PCI_BIST 0x0f /* 8 bits */ -#define PCI_BIST_CODE_MASK 0x0f /* Return result */ -#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ -#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ - -/* - * Base addresses specify locations in memory or I/O space. - * Decoded size can be determined by writing a value of - * 0xffffffff to the register, and reading it back. Only - * 1 bits are decoded. - */ -#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ -#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */ -#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */ -#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */ -#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */ -#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ -#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */ -#define PCI_BASE_ADDRESS_SPACE_IO 0x01 -#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00 -#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06 -#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */ -#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */ -#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */ -#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */ -#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL) -#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL) -/* bit 1 is reserved if address_space = 1 */ - -/* Header type 0 (normal devices) */ -#define PCI_CARDBUS_CIS 0x28 -#define PCI_SUBSYSTEM_VENDOR_ID 0x2c -#define PCI_SUBSYSTEM_ID 0x2e -#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */ -#define PCI_ROM_ADDRESS_ENABLE 0x01 -#define PCI_ROM_ADDRESS_MASK (~0x7ffUL) - -#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */ - -/* 0x35-0x3b are reserved */ -#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ -#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ -#define PCI_MIN_GNT 0x3e /* 8 bits */ -#define PCI_MAX_LAT 0x3f /* 8 bits */ - -/* Header type 1 (PCI-to-PCI bridges) */ -#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */ -#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */ -#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */ -#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */ -#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */ -#define PCI_IO_LIMIT 0x1d -#define PCI_IO_RANGE_TYPE_MASK 0x0fUL /* I/O bridging type */ -#define PCI_IO_RANGE_TYPE_16 0x00 -#define PCI_IO_RANGE_TYPE_32 0x01 -#define PCI_IO_RANGE_MASK (~0x0fUL) -#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */ -#define PCI_MEMORY_BASE 0x20 /* Memory range behind */ -#define PCI_MEMORY_LIMIT 0x22 -#define PCI_MEMORY_RANGE_TYPE_MASK 0x0fUL -#define PCI_MEMORY_RANGE_MASK (~0x0fUL) -#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */ -#define PCI_PREF_MEMORY_LIMIT 0x26 -#define PCI_PREF_RANGE_TYPE_MASK 0x0fUL -#define PCI_PREF_RANGE_TYPE_32 0x00 -#define PCI_PREF_RANGE_TYPE_64 0x01 -#define PCI_PREF_RANGE_MASK (~0x0fUL) -#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */ -#define PCI_PREF_LIMIT_UPPER32 0x2c -#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */ -#define PCI_IO_LIMIT_UPPER16 0x32 -/* 0x34 same as for htype 0 */ -/* 0x35-0x3b is reserved */ -#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */ -/* 0x3c-0x3d are same as for htype 0 */ -#define PCI_BRIDGE_CONTROL 0x3e -#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */ -#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */ -#define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */ -#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */ -#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */ -#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */ -#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */ - -/* Header type 2 (CardBus bridges) */ -#define PCI_CB_CAPABILITY_LIST 0x14 -/* 0x15 reserved */ -#define PCI_CB_SEC_STATUS 0x16 /* Secondary status */ -#define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */ -#define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */ -#define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */ -#define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */ -#define PCI_CB_MEMORY_BASE_0 0x1c -#define PCI_CB_MEMORY_LIMIT_0 0x20 -#define PCI_CB_MEMORY_BASE_1 0x24 -#define PCI_CB_MEMORY_LIMIT_1 0x28 -#define PCI_CB_IO_BASE_0 0x2c -#define PCI_CB_IO_BASE_0_HI 0x2e -#define PCI_CB_IO_LIMIT_0 0x30 -#define PCI_CB_IO_LIMIT_0_HI 0x32 -#define PCI_CB_IO_BASE_1 0x34 -#define PCI_CB_IO_BASE_1_HI 0x36 -#define PCI_CB_IO_LIMIT_1 0x38 -#define PCI_CB_IO_LIMIT_1_HI 0x3a -#define PCI_CB_IO_RANGE_MASK (~0x03UL) -/* 0x3c-0x3d are same as for htype 0 */ -#define PCI_CB_BRIDGE_CONTROL 0x3e -#define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */ -#define PCI_CB_BRIDGE_CTL_SERR 0x02 -#define PCI_CB_BRIDGE_CTL_ISA 0x04 -#define PCI_CB_BRIDGE_CTL_VGA 0x08 -#define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20 -#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */ -#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */ -#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */ -#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200 -#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400 -#define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40 -#define PCI_CB_SUBSYSTEM_ID 0x42 -#define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */ -/* 0x48-0x7f reserved */ - -/* Capability lists */ - -#define PCI_CAP_LIST_ID 0 /* Capability ID */ -#define PCI_CAP_ID_PM 0x01 /* Power Management */ -#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ -#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */ -#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */ -#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ -#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ -#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */ -#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */ -#define PCI_CAP_ID_EXP 0x10 /* PCI Express */ -#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */ -#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ -#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ -#define PCI_CAP_SIZEOF 4 - -/* Power Management Registers */ - -#define PCI_PM_PMC 2 /* PM Capabilities Register */ -#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */ -#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */ -#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */ -#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */ -#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxilliary power support mask */ -#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */ -#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */ -#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */ -#define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */ -#define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */ -#define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */ -#define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */ -#define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */ -#define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */ -#define PCI_PM_CTRL 4 /* PM control and status register */ -#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */ -#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */ -#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */ -#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */ -#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */ -#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */ -#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */ -#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */ -#define PCI_PM_DATA_REGISTER 7 /* (??) */ -#define PCI_PM_SIZEOF 8 - -/* AGP registers */ - -#define PCI_AGP_VERSION 2 /* BCD version number */ -#define PCI_AGP_RFU 3 /* Rest of capability flags */ -#define PCI_AGP_STATUS 4 /* Status register */ -#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ -#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ -#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */ -#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */ -#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */ -#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */ -#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */ -#define PCI_AGP_COMMAND 8 /* Control register */ -#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ -#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ -#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ -#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */ -#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */ -#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */ -#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */ -#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */ -#define PCI_AGP_SIZEOF 12 - -/* Vital Product Data */ - -#define PCI_VPD_ADDR 2 /* Address to access (15 bits!) */ -#define PCI_VPD_ADDR_MASK 0x7fff /* Address mask */ -#define PCI_VPD_ADDR_F 0x8000 /* Write 0, 1 indicates completion */ -#define PCI_VPD_DATA 4 /* 32-bits of data returned here */ - -/* Slot Identification */ - -#define PCI_SID_ESR 2 /* Expansion Slot Register */ -#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */ -#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */ -#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */ - -/* Message Signalled Interrupts registers */ - -#define PCI_MSI_FLAGS 2 /* Various flags */ -#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */ -#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */ -#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */ -#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */ -#define PCI_MSI_FLAGS_MASKBIT 0x100 /* 64-bit mask bits allowed */ -#define PCI_MSI_RFU 3 /* Rest of capability flags */ -#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */ -#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */ -#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */ -#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */ -#define PCI_MSI_MASK_BIT 16 /* Mask bits register */ - -/* CompactPCI Hotswap Register */ - -#define PCI_CHSWP_CSR 2 /* Control and Status Register */ -#define PCI_CHSWP_DHA 0x01 /* Device Hiding Arm */ -#define PCI_CHSWP_EIM 0x02 /* ENUM# Signal Mask */ -#define PCI_CHSWP_PIE 0x04 /* Pending Insert or Extract */ -#define PCI_CHSWP_LOO 0x08 /* LED On / Off */ -#define PCI_CHSWP_PI 0x30 /* Programming Interface */ -#define PCI_CHSWP_EXT 0x40 /* ENUM# status - extraction */ -#define PCI_CHSWP_INS 0x80 /* ENUM# status - insertion */ - -/* PCI-X registers */ - -#define PCI_X_CMD 2 /* Modes & Features */ -#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */ -#define PCI_X_CMD_ERO 0x0002 /* Enable Relaxed Ordering */ -#define PCI_X_CMD_MAX_READ 0x000c /* Max Memory Read Byte Count */ -#define PCI_X_CMD_MAX_SPLIT 0x0070 /* Max Outstanding Split Transactions */ -#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3) /* Version */ -#define PCI_X_STATUS 4 /* PCI-X capabilities */ -#define PCI_X_STATUS_DEVFN 0x000000ff /* A copy of devfn */ -#define PCI_X_STATUS_BUS 0x0000ff00 /* A copy of bus nr */ -#define PCI_X_STATUS_64BIT 0x00010000 /* 64-bit device */ -#define PCI_X_STATUS_133MHZ 0x00020000 /* 133 MHz capable */ -#define PCI_X_STATUS_SPL_DISC 0x00040000 /* Split Completion Discarded */ -#define PCI_X_STATUS_UNX_SPL 0x00080000 /* Unexpected Split Completion */ -#define PCI_X_STATUS_COMPLEX 0x00100000 /* Device Complexity */ -#define PCI_X_STATUS_MAX_READ 0x00600000 /* Designed Max Memory Read Count */ -#define PCI_X_STATUS_MAX_SPLIT 0x03800000 /* Designed Max Outstanding Split Transactions */ -#define PCI_X_STATUS_MAX_CUM 0x1c000000 /* Designed Max Cumulative Read Size */ -#define PCI_X_STATUS_SPL_ERR 0x20000000 /* Rcvd Split Completion Error Msg */ -#define PCI_X_STATUS_266MHZ 0x40000000 /* 266 MHz capable */ -#define PCI_X_STATUS_533MHZ 0x80000000 /* 533 MHz capable */ - -/* PCI Express capability registers */ - -#define PCI_EXP_FLAGS 2 /* Capabilities register */ -#define PCI_EXP_FLAGS_VERS 0x000f /* Capability version */ -#define PCI_EXP_FLAGS_TYPE 0x00f0 /* Device/Port type */ -#define PCI_EXP_TYPE_ENDPOINT 0x0 /* Express Endpoint */ -#define PCI_EXP_TYPE_LEG_END 0x1 /* Legacy Endpoint */ -#define PCI_EXP_TYPE_ROOT_PORT 0x4 /* Root Port */ -#define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */ -#define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */ -#define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */ -#define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */ -#define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */ -#define PCI_EXP_DEVCAP 4 /* Device capabilities */ -#define PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */ -#define PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */ -#define PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */ -#define PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */ -#define PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */ -#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */ -#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */ -#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */ -#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */ -#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */ -#define PCI_EXP_DEVCTL 8 /* Device Control */ -#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */ -#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */ -#define PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */ -#define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */ -#define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */ -#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */ -#define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */ -#define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */ -#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */ -#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */ -#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */ -#define PCI_EXP_DEVSTA 10 /* Device Status */ -#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */ -#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */ -#define PCI_EXP_DEVSTA_FED 0x04 /* Fatal Error Detected */ -#define PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */ -#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */ -#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */ -#define PCI_EXP_LNKCAP 12 /* Link Capabilities */ -#define PCI_EXP_LNKCTL 16 /* Link Control */ -#define PCI_EXP_LNKSTA 18 /* Link Status */ -#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */ -#define PCI_EXP_SLTCTL 24 /* Slot Control */ -#define PCI_EXP_SLTSTA 26 /* Slot Status */ -#define PCI_EXP_RTCTL 28 /* Root Control */ -#define PCI_EXP_RTCTL_SECEE 0x01 /* System Error on Correctable Error */ -#define PCI_EXP_RTCTL_SENFEE 0x02 /* System Error on Non-Fatal Error */ -#define PCI_EXP_RTCTL_SEFEE 0x04 /* System Error on Fatal Error */ -#define PCI_EXP_RTCTL_PMEIE 0x08 /* PME Interrupt Enable */ -#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */ -#define PCI_EXP_RTCAP 30 /* Root Capabilities */ -#define PCI_EXP_RTSTA 32 /* Root Status */ - -/* Extended Capabilities (PCI-X 2.0 and Express) */ -#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff) -#define PCI_EXT_CAP_VER(header) ((header >> 16) & 0xf) -#define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc) - -#define PCI_EXT_CAP_ID_ERR 1 -#define PCI_EXT_CAP_ID_VC 2 -#define PCI_EXT_CAP_ID_DSN 3 -#define PCI_EXT_CAP_ID_PWR 4 - -/* Advanced Error Reporting */ -#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */ -#define PCI_ERR_UNC_TRAIN 0x00000001 /* Training */ -#define PCI_ERR_UNC_DLP 0x00000010 /* Data Link Protocol */ -#define PCI_ERR_UNC_POISON_TLP 0x00001000 /* Poisoned TLP */ -#define PCI_ERR_UNC_FCP 0x00002000 /* Flow Control Protocol */ -#define PCI_ERR_UNC_COMP_TIME 0x00004000 /* Completion Timeout */ -#define PCI_ERR_UNC_COMP_ABORT 0x00008000 /* Completer Abort */ -#define PCI_ERR_UNC_UNX_COMP 0x00010000 /* Unexpected Completion */ -#define PCI_ERR_UNC_RX_OVER 0x00020000 /* Receiver Overflow */ -#define PCI_ERR_UNC_MALF_TLP 0x00040000 /* Malformed TLP */ -#define PCI_ERR_UNC_ECRC 0x00080000 /* ECRC Error Status */ -#define PCI_ERR_UNC_UNSUP 0x00100000 /* Unsupported Request */ -#define PCI_ERR_UNCOR_MASK 8 /* Uncorrectable Error Mask */ - /* Same bits as above */ -#define PCI_ERR_UNCOR_SEVER 12 /* Uncorrectable Error Severity */ - /* Same bits as above */ -#define PCI_ERR_COR_STATUS 16 /* Correctable Error Status */ -#define PCI_ERR_COR_RCVR 0x00000001 /* Receiver Error Status */ -#define PCI_ERR_COR_BAD_TLP 0x00000040 /* Bad TLP Status */ -#define PCI_ERR_COR_BAD_DLLP 0x00000080 /* Bad DLLP Status */ -#define PCI_ERR_COR_REP_ROLL 0x00000100 /* REPLAY_NUM Rollover */ -#define PCI_ERR_COR_REP_TIMER 0x00001000 /* Replay Timer Timeout */ -#define PCI_ERR_COR_MASK 20 /* Correctable Error Mask */ - /* Same bits as above */ -#define PCI_ERR_CAP 24 /* Advanced Error Capabilities */ -#define PCI_ERR_CAP_FEP(x) ((x) & 31) /* First Error Pointer */ -#define PCI_ERR_CAP_ECRC_GENC 0x00000020 /* ECRC Generation Capable */ -#define PCI_ERR_CAP_ECRC_GENE 0x00000040 /* ECRC Generation Enable */ -#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */ -#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */ -#define PCI_ERR_HEADER_LOG 28 /* Header Log Register (16 bytes) */ -#define PCI_ERR_ROOT_COMMAND 44 /* Root Error Command */ -#define PCI_ERR_ROOT_STATUS 48 -#define PCI_ERR_ROOT_COR_SRC 52 -#define PCI_ERR_ROOT_SRC 54 - -/* Virtual Channel */ -#define PCI_VC_PORT_REG1 4 -#define PCI_VC_PORT_REG2 8 -#define PCI_VC_PORT_CTRL 12 -#define PCI_VC_PORT_STATUS 14 -#define PCI_VC_RES_CAP 16 -#define PCI_VC_RES_CTRL 20 -#define PCI_VC_RES_STATUS 26 - -/* Power Budgeting */ -#define PCI_PWR_DSR 4 /* Data Select Register */ -#define PCI_PWR_DATA 8 /* Data Register */ -#define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */ -#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */ -#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */ -#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */ -#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */ -#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */ -#define PCI_PWR_CAP 12 /* Capability */ -#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */ +/* Include the pci register defines */ +#include /* Include the ID list */ - #include /* @@ -496,9 +70,9 @@ enum pci_mmap_state { typedef int __bitwise pci_power_t; -#define PCI_D0 ((pci_power_t __force) 0) -#define PCI_D1 ((pci_power_t __force) 1) -#define PCI_D2 ((pci_power_t __force) 2) +#define PCI_D0 ((pci_power_t __force) 0) +#define PCI_D1 ((pci_power_t __force) 1) +#define PCI_D2 ((pci_power_t __force) 2) #define PCI_D3hot ((pci_power_t __force) 3) #define PCI_D3cold ((pci_power_t __force) 4) #define PCI_POWER_ERROR ((pci_power_t __force) -1) @@ -577,15 +151,15 @@ struct pci_dev { * 7-10 bridges: address space assigned to buses behind the bridge */ -#define PCI_ROM_RESOURCE 6 -#define PCI_BRIDGE_RESOURCES 7 -#define PCI_NUM_RESOURCES 11 +#define PCI_ROM_RESOURCE 6 +#define PCI_BRIDGE_RESOURCES 7 +#define PCI_NUM_RESOURCES 11 #ifndef PCI_BUS_NUM_RESOURCES -#define PCI_BUS_NUM_RESOURCES 8 +#define PCI_BUS_NUM_RESOURCES 8 #endif - -#define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */ + +#define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */ struct pci_bus { struct list_head node; /* node in list of buses */ @@ -694,7 +268,7 @@ struct pci_driver { * @dev_class_mask: the class mask for this device * * This macro is used to create a struct pci_device_id that matches a - * specific PCI class. The vendor, device, subvendor, and subdevice + * specific PCI class. The vendor, device, subvendor, and subdevice * fields will be set to PCI_ANY_ID. */ #define PCI_DEVICE_CLASS(dev_class,dev_class_mask) \ @@ -702,7 +276,7 @@ struct pci_driver { .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \ .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID -/* +/* * pci_module_init is obsolete, this stays here till we fix up all usages of it * in the tree. */ @@ -905,18 +479,26 @@ extern void pci_disable_msix(struct pci_dev *dev); extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); #endif -#endif /* CONFIG_PCI */ - -/* Include architecture-dependent settings and functions */ +/* + * PCI domain support. Sometimes called PCI segment (eg by ACPI), + * a PCI domain is defined to be a set of PCI busses which share + * configuration space. + */ +#ifndef CONFIG_PCI_DOMAINS +static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } +static inline int pci_proc_domain(struct pci_bus *bus) +{ + return 0; +} +#endif -#include +#else /* CONFIG_PCI is not enabled */ /* * If the system does not have PCI, clearly these return errors. Define * these as simple inline functions to avoid hair in drivers. */ -#ifndef CONFIG_PCI #define _PCI_NOP(o,s,t) \ static inline int pci_##o##_config_##s (struct pci_dev *dev, int where, t val) \ { return PCIBIOS_FUNC_NOT_SUPPORTED; } @@ -967,21 +549,11 @@ static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int en #define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0) -#else +#endif /* CONFIG_PCI */ -/* - * PCI domain support. Sometimes called PCI segment (eg by ACPI), - * a PCI domain is defined to be a set of PCI busses which share - * configuration space. - */ -#ifndef CONFIG_PCI_DOMAINS -static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } -static inline int pci_proc_domain(struct pci_bus *bus) -{ - return 0; -} -#endif -#endif /* !CONFIG_PCI */ +/* Include architecture-dependent settings and functions */ + +#include /* these helpers provide future and backwards compatibility * for accessing popular PCI BAR info */ diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h new file mode 100644 index 0000000..7dc391c --- /dev/null +++ b/include/linux/pci_regs.h @@ -0,0 +1,447 @@ +/* + * pci_regs.h + * + * PCI standard defines + * Copyright 1994, Drew Eckhardt + * Copyright 1997--1999 Martin Mares + * + * For more information, please consult the following manuals (look at + * http://www.pcisig.com/ for how to get them): + * + * PCI BIOS Specification + * PCI Local Bus Specification + * PCI to PCI Bridge Specification + * PCI System Design Guide + */ + +#ifndef LINUX_PCI_REGS_H +#define LINUX_PCI_REGS_H + +/* + * Under PCI, each device has 256 bytes of configuration address space, + * of which the first 64 bytes are standardized as follows: + */ +#define PCI_VENDOR_ID 0x00 /* 16 bits */ +#define PCI_DEVICE_ID 0x02 /* 16 bits */ +#define PCI_COMMAND 0x04 /* 16 bits */ +#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ +#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ +#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */ +#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */ +#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ +#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ +#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ +#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ +#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ +#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ +#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ + +#define PCI_STATUS 0x06 /* 16 bits */ +#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */ +#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */ +#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */ +#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */ +#define PCI_STATUS_PARITY 0x100 /* Detected parity error */ +#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ +#define PCI_STATUS_DEVSEL_FAST 0x000 +#define PCI_STATUS_DEVSEL_MEDIUM 0x200 +#define PCI_STATUS_DEVSEL_SLOW 0x400 +#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ +#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ +#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ +#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ +#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ + +#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */ +#define PCI_REVISION_ID 0x08 /* Revision ID */ +#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ +#define PCI_CLASS_DEVICE 0x0a /* Device class */ + +#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ +#define PCI_LATENCY_TIMER 0x0d /* 8 bits */ +#define PCI_HEADER_TYPE 0x0e /* 8 bits */ +#define PCI_HEADER_TYPE_NORMAL 0 +#define PCI_HEADER_TYPE_BRIDGE 1 +#define PCI_HEADER_TYPE_CARDBUS 2 + +#define PCI_BIST 0x0f /* 8 bits */ +#define PCI_BIST_CODE_MASK 0x0f /* Return result */ +#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ +#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ + +/* + * Base addresses specify locations in memory or I/O space. + * Decoded size can be determined by writing a value of + * 0xffffffff to the register, and reading it back. Only + * 1 bits are decoded. + */ +#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ +#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */ +#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */ +#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */ +#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */ +#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ +#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */ +#define PCI_BASE_ADDRESS_SPACE_IO 0x01 +#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00 +#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06 +#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */ +#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */ +#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */ +#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */ +#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL) +#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL) +/* bit 1 is reserved if address_space = 1 */ + +/* Header type 0 (normal devices) */ +#define PCI_CARDBUS_CIS 0x28 +#define PCI_SUBSYSTEM_VENDOR_ID 0x2c +#define PCI_SUBSYSTEM_ID 0x2e +#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */ +#define PCI_ROM_ADDRESS_ENABLE 0x01 +#define PCI_ROM_ADDRESS_MASK (~0x7ffUL) + +#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */ + +/* 0x35-0x3b are reserved */ +#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ +#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ +#define PCI_MIN_GNT 0x3e /* 8 bits */ +#define PCI_MAX_LAT 0x3f /* 8 bits */ + +/* Header type 1 (PCI-to-PCI bridges) */ +#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */ +#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */ +#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */ +#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */ +#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */ +#define PCI_IO_LIMIT 0x1d +#define PCI_IO_RANGE_TYPE_MASK 0x0fUL /* I/O bridging type */ +#define PCI_IO_RANGE_TYPE_16 0x00 +#define PCI_IO_RANGE_TYPE_32 0x01 +#define PCI_IO_RANGE_MASK (~0x0fUL) +#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */ +#define PCI_MEMORY_BASE 0x20 /* Memory range behind */ +#define PCI_MEMORY_LIMIT 0x22 +#define PCI_MEMORY_RANGE_TYPE_MASK 0x0fUL +#define PCI_MEMORY_RANGE_MASK (~0x0fUL) +#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */ +#define PCI_PREF_MEMORY_LIMIT 0x26 +#define PCI_PREF_RANGE_TYPE_MASK 0x0fUL +#define PCI_PREF_RANGE_TYPE_32 0x00 +#define PCI_PREF_RANGE_TYPE_64 0x01 +#define PCI_PREF_RANGE_MASK (~0x0fUL) +#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */ +#define PCI_PREF_LIMIT_UPPER32 0x2c +#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */ +#define PCI_IO_LIMIT_UPPER16 0x32 +/* 0x34 same as for htype 0 */ +/* 0x35-0x3b is reserved */ +#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */ +/* 0x3c-0x3d are same as for htype 0 */ +#define PCI_BRIDGE_CONTROL 0x3e +#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */ +#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */ +#define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */ +#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */ +#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */ +#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */ +#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */ + +/* Header type 2 (CardBus bridges) */ +#define PCI_CB_CAPABILITY_LIST 0x14 +/* 0x15 reserved */ +#define PCI_CB_SEC_STATUS 0x16 /* Secondary status */ +#define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */ +#define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */ +#define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */ +#define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */ +#define PCI_CB_MEMORY_BASE_0 0x1c +#define PCI_CB_MEMORY_LIMIT_0 0x20 +#define PCI_CB_MEMORY_BASE_1 0x24 +#define PCI_CB_MEMORY_LIMIT_1 0x28 +#define PCI_CB_IO_BASE_0 0x2c +#define PCI_CB_IO_BASE_0_HI 0x2e +#define PCI_CB_IO_LIMIT_0 0x30 +#define PCI_CB_IO_LIMIT_0_HI 0x32 +#define PCI_CB_IO_BASE_1 0x34 +#define PCI_CB_IO_BASE_1_HI 0x36 +#define PCI_CB_IO_LIMIT_1 0x38 +#define PCI_CB_IO_LIMIT_1_HI 0x3a +#define PCI_CB_IO_RANGE_MASK (~0x03UL) +/* 0x3c-0x3d are same as for htype 0 */ +#define PCI_CB_BRIDGE_CONTROL 0x3e +#define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */ +#define PCI_CB_BRIDGE_CTL_SERR 0x02 +#define PCI_CB_BRIDGE_CTL_ISA 0x04 +#define PCI_CB_BRIDGE_CTL_VGA 0x08 +#define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20 +#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */ +#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */ +#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */ +#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200 +#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400 +#define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40 +#define PCI_CB_SUBSYSTEM_ID 0x42 +#define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */ +/* 0x48-0x7f reserved */ + +/* Capability lists */ + +#define PCI_CAP_LIST_ID 0 /* Capability ID */ +#define PCI_CAP_ID_PM 0x01 /* Power Management */ +#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ +#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */ +#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */ +#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ +#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ +#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */ +#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */ +#define PCI_CAP_ID_EXP 0x10 /* PCI Express */ +#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */ +#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ +#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ +#define PCI_CAP_SIZEOF 4 + +/* Power Management Registers */ + +#define PCI_PM_PMC 2 /* PM Capabilities Register */ +#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */ +#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */ +#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */ +#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */ +#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxilliary power support mask */ +#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */ +#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */ +#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */ +#define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */ +#define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */ +#define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */ +#define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */ +#define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */ +#define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */ +#define PCI_PM_CTRL 4 /* PM control and status register */ +#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */ +#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */ +#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */ +#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */ +#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */ +#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */ +#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */ +#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */ +#define PCI_PM_DATA_REGISTER 7 /* (??) */ +#define PCI_PM_SIZEOF 8 + +/* AGP registers */ + +#define PCI_AGP_VERSION 2 /* BCD version number */ +#define PCI_AGP_RFU 3 /* Rest of capability flags */ +#define PCI_AGP_STATUS 4 /* Status register */ +#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ +#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ +#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */ +#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */ +#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */ +#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */ +#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */ +#define PCI_AGP_COMMAND 8 /* Control register */ +#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ +#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ +#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ +#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */ +#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */ +#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */ +#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */ +#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */ +#define PCI_AGP_SIZEOF 12 + +/* Vital Product Data */ + +#define PCI_VPD_ADDR 2 /* Address to access (15 bits!) */ +#define PCI_VPD_ADDR_MASK 0x7fff /* Address mask */ +#define PCI_VPD_ADDR_F 0x8000 /* Write 0, 1 indicates completion */ +#define PCI_VPD_DATA 4 /* 32-bits of data returned here */ + +/* Slot Identification */ + +#define PCI_SID_ESR 2 /* Expansion Slot Register */ +#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */ +#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */ +#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */ + +/* Message Signalled Interrupts registers */ + +#define PCI_MSI_FLAGS 2 /* Various flags */ +#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */ +#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */ +#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */ +#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */ +#define PCI_MSI_FLAGS_MASKBIT 0x100 /* 64-bit mask bits allowed */ +#define PCI_MSI_RFU 3 /* Rest of capability flags */ +#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */ +#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */ +#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */ +#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */ +#define PCI_MSI_MASK_BIT 16 /* Mask bits register */ + +/* CompactPCI Hotswap Register */ + +#define PCI_CHSWP_CSR 2 /* Control and Status Register */ +#define PCI_CHSWP_DHA 0x01 /* Device Hiding Arm */ +#define PCI_CHSWP_EIM 0x02 /* ENUM# Signal Mask */ +#define PCI_CHSWP_PIE 0x04 /* Pending Insert or Extract */ +#define PCI_CHSWP_LOO 0x08 /* LED On / Off */ +#define PCI_CHSWP_PI 0x30 /* Programming Interface */ +#define PCI_CHSWP_EXT 0x40 /* ENUM# status - extraction */ +#define PCI_CHSWP_INS 0x80 /* ENUM# status - insertion */ + +/* PCI-X registers */ + +#define PCI_X_CMD 2 /* Modes & Features */ +#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */ +#define PCI_X_CMD_ERO 0x0002 /* Enable Relaxed Ordering */ +#define PCI_X_CMD_MAX_READ 0x000c /* Max Memory Read Byte Count */ +#define PCI_X_CMD_MAX_SPLIT 0x0070 /* Max Outstanding Split Transactions */ +#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3) /* Version */ +#define PCI_X_STATUS 4 /* PCI-X capabilities */ +#define PCI_X_STATUS_DEVFN 0x000000ff /* A copy of devfn */ +#define PCI_X_STATUS_BUS 0x0000ff00 /* A copy of bus nr */ +#define PCI_X_STATUS_64BIT 0x00010000 /* 64-bit device */ +#define PCI_X_STATUS_133MHZ 0x00020000 /* 133 MHz capable */ +#define PCI_X_STATUS_SPL_DISC 0x00040000 /* Split Completion Discarded */ +#define PCI_X_STATUS_UNX_SPL 0x00080000 /* Unexpected Split Completion */ +#define PCI_X_STATUS_COMPLEX 0x00100000 /* Device Complexity */ +#define PCI_X_STATUS_MAX_READ 0x00600000 /* Designed Max Memory Read Count */ +#define PCI_X_STATUS_MAX_SPLIT 0x03800000 /* Designed Max Outstanding Split Transactions */ +#define PCI_X_STATUS_MAX_CUM 0x1c000000 /* Designed Max Cumulative Read Size */ +#define PCI_X_STATUS_SPL_ERR 0x20000000 /* Rcvd Split Completion Error Msg */ +#define PCI_X_STATUS_266MHZ 0x40000000 /* 266 MHz capable */ +#define PCI_X_STATUS_533MHZ 0x80000000 /* 533 MHz capable */ + +/* PCI Express capability registers */ + +#define PCI_EXP_FLAGS 2 /* Capabilities register */ +#define PCI_EXP_FLAGS_VERS 0x000f /* Capability version */ +#define PCI_EXP_FLAGS_TYPE 0x00f0 /* Device/Port type */ +#define PCI_EXP_TYPE_ENDPOINT 0x0 /* Express Endpoint */ +#define PCI_EXP_TYPE_LEG_END 0x1 /* Legacy Endpoint */ +#define PCI_EXP_TYPE_ROOT_PORT 0x4 /* Root Port */ +#define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */ +#define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */ +#define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */ +#define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */ +#define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */ +#define PCI_EXP_DEVCAP 4 /* Device capabilities */ +#define PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */ +#define PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */ +#define PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */ +#define PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */ +#define PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */ +#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */ +#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */ +#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */ +#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */ +#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */ +#define PCI_EXP_DEVCTL 8 /* Device Control */ +#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */ +#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */ +#define PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */ +#define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */ +#define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */ +#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */ +#define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */ +#define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */ +#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */ +#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */ +#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */ +#define PCI_EXP_DEVSTA 10 /* Device Status */ +#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */ +#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */ +#define PCI_EXP_DEVSTA_FED 0x04 /* Fatal Error Detected */ +#define PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */ +#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */ +#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */ +#define PCI_EXP_LNKCAP 12 /* Link Capabilities */ +#define PCI_EXP_LNKCTL 16 /* Link Control */ +#define PCI_EXP_LNKSTA 18 /* Link Status */ +#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */ +#define PCI_EXP_SLTCTL 24 /* Slot Control */ +#define PCI_EXP_SLTSTA 26 /* Slot Status */ +#define PCI_EXP_RTCTL 28 /* Root Control */ +#define PCI_EXP_RTCTL_SECEE 0x01 /* System Error on Correctable Error */ +#define PCI_EXP_RTCTL_SENFEE 0x02 /* System Error on Non-Fatal Error */ +#define PCI_EXP_RTCTL_SEFEE 0x04 /* System Error on Fatal Error */ +#define PCI_EXP_RTCTL_PMEIE 0x08 /* PME Interrupt Enable */ +#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */ +#define PCI_EXP_RTCAP 30 /* Root Capabilities */ +#define PCI_EXP_RTSTA 32 /* Root Status */ + +/* Extended Capabilities (PCI-X 2.0 and Express) */ +#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff) +#define PCI_EXT_CAP_VER(header) ((header >> 16) & 0xf) +#define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc) + +#define PCI_EXT_CAP_ID_ERR 1 +#define PCI_EXT_CAP_ID_VC 2 +#define PCI_EXT_CAP_ID_DSN 3 +#define PCI_EXT_CAP_ID_PWR 4 + +/* Advanced Error Reporting */ +#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */ +#define PCI_ERR_UNC_TRAIN 0x00000001 /* Training */ +#define PCI_ERR_UNC_DLP 0x00000010 /* Data Link Protocol */ +#define PCI_ERR_UNC_POISON_TLP 0x00001000 /* Poisoned TLP */ +#define PCI_ERR_UNC_FCP 0x00002000 /* Flow Control Protocol */ +#define PCI_ERR_UNC_COMP_TIME 0x00004000 /* Completion Timeout */ +#define PCI_ERR_UNC_COMP_ABORT 0x00008000 /* Completer Abort */ +#define PCI_ERR_UNC_UNX_COMP 0x00010000 /* Unexpected Completion */ +#define PCI_ERR_UNC_RX_OVER 0x00020000 /* Receiver Overflow */ +#define PCI_ERR_UNC_MALF_TLP 0x00040000 /* Malformed TLP */ +#define PCI_ERR_UNC_ECRC 0x00080000 /* ECRC Error Status */ +#define PCI_ERR_UNC_UNSUP 0x00100000 /* Unsupported Request */ +#define PCI_ERR_UNCOR_MASK 8 /* Uncorrectable Error Mask */ + /* Same bits as above */ +#define PCI_ERR_UNCOR_SEVER 12 /* Uncorrectable Error Severity */ + /* Same bits as above */ +#define PCI_ERR_COR_STATUS 16 /* Correctable Error Status */ +#define PCI_ERR_COR_RCVR 0x00000001 /* Receiver Error Status */ +#define PCI_ERR_COR_BAD_TLP 0x00000040 /* Bad TLP Status */ +#define PCI_ERR_COR_BAD_DLLP 0x00000080 /* Bad DLLP Status */ +#define PCI_ERR_COR_REP_ROLL 0x00000100 /* REPLAY_NUM Rollover */ +#define PCI_ERR_COR_REP_TIMER 0x00001000 /* Replay Timer Timeout */ +#define PCI_ERR_COR_MASK 20 /* Correctable Error Mask */ + /* Same bits as above */ +#define PCI_ERR_CAP 24 /* Advanced Error Capabilities */ +#define PCI_ERR_CAP_FEP(x) ((x) & 31) /* First Error Pointer */ +#define PCI_ERR_CAP_ECRC_GENC 0x00000020 /* ECRC Generation Capable */ +#define PCI_ERR_CAP_ECRC_GENE 0x00000040 /* ECRC Generation Enable */ +#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */ +#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */ +#define PCI_ERR_HEADER_LOG 28 /* Header Log Register (16 bytes) */ +#define PCI_ERR_ROOT_COMMAND 44 /* Root Error Command */ +#define PCI_ERR_ROOT_STATUS 48 +#define PCI_ERR_ROOT_COR_SRC 52 +#define PCI_ERR_ROOT_SRC 54 + +/* Virtual Channel */ +#define PCI_VC_PORT_REG1 4 +#define PCI_VC_PORT_REG2 8 +#define PCI_VC_PORT_CTRL 12 +#define PCI_VC_PORT_STATUS 14 +#define PCI_VC_RES_CAP 16 +#define PCI_VC_RES_CTRL 20 +#define PCI_VC_RES_STATUS 26 + +/* Power Budgeting */ +#define PCI_PWR_DSR 4 /* Data Select Register */ +#define PCI_PWR_DATA 8 /* Data Register */ +#define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */ +#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */ +#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */ +#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */ +#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */ +#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */ +#define PCI_PWR_CAP 12 /* Capability */ +#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */ + +#endif /* LINUX_PCI_REGS_H */ -- cgit v0.10.2 From 346d38823b59d65c3c1365971776b52e0661b7e5 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Sun, 31 Jul 2005 11:51:45 +0300 Subject: [PATCH] arch/386/pci: remap_pfn_range -> io_remap_pfn_range Convert i386/pci to use io_remap_pfn_range instead of remap_pfn_range. This is good for Xen which reuses i386/pci/i386.c for domain 0 code. Signed-off-by: Michael S. Tsirkin Signed-off-by: Greg Kroah-Hartman diff --git a/arch/i386/pci/i386.c b/arch/i386/pci/i386.c index 3cc4809..6d63385 100644 --- a/arch/i386/pci/i386.c +++ b/arch/i386/pci/i386.c @@ -283,9 +283,9 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, /* Write-combine setting is ignored, it is changed via the mtrr * interfaces on this platform. */ - if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, - vma->vm_end - vma->vm_start, - vma->vm_page_prot)) + if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, + vma->vm_end - vma->vm_start, + vma->vm_page_prot)) return -EAGAIN; return 0; -- cgit v0.10.2 From 1248d636122e4ec9d7802b850904e3bb48a0da23 Mon Sep 17 00:00:00 2001 From: Kristen Accardi Date: Fri, 5 Aug 2005 12:16:06 -0700 Subject: [PATCH] PCI Hotplug: use bus_slot number for name For systems with multiple hotplug controllers, you need to use more than just the slot number to uniquely name the slot. Without a unique slot name, the pci_hp_register() will fail. This patch adds the bus number to the name. Signed-off-by: Kristen Carlson Accardi Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 2b92b9e..061ead2 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -302,7 +302,7 @@ static inline void return_resource(struct pci_resource **head, struct pci_resour static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) { - snprintf(buffer, buffer_size, "%d", slot->number); + snprintf(buffer, buffer_size, "%04d_%04d", slot->bus, slot->number); } enum php_ctlr_type { diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h index fe4d653..b7d1c61 100644 --- a/drivers/pci/hotplug/shpchp.h +++ b/drivers/pci/hotplug/shpchp.h @@ -411,7 +411,7 @@ static inline void return_resource(struct pci_resource **head, struct pci_resour static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) { - snprintf(buffer, buffer_size, "%d", slot->number); + snprintf(buffer, buffer_size, "%04d_%04d", slot->bus, slot->number); } enum php_ctlr_type { -- cgit v0.10.2 From 064b53dbcc977dbf2753a67c2b8fc1c061d74f21 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Wed, 27 Jul 2005 10:19:44 -0400 Subject: [PATCH] PCI: restore BAR values after D3hot->D0 for devices that need it Some PCI devices (e.g. 3c905B, 3c556B) lose all configuration (including BARs) when transitioning from D3hot->D0. This leaves such a device in an inaccessible state. The patch below causes the BARs to be restored when enabling such a device, so that its driver will be able to access it. The patch also adds pci_restore_bars as a new global symbol, and adds a correpsonding EXPORT_SYMBOL_GPL for that. Some firmware (e.g. Thinkpad T21) leaves devices in D3hot after a (re)boot. Most drivers call pci_enable_device very early, so devices left in D3hot that lose configuration during the D3hot->D0 transition will be inaccessible to their drivers. Drivers could be modified to account for this, but it would be difficult to know which drivers need modification. This is especially true since often many devices are covered by the same driver. It likely would be necessary to replicate code across dozens of drivers. The patch below should trigger only when transitioning from D3hot->D0 (or at boot), and only for devices that have the "no soft reset" bit cleared in the PM control register. I believe it is safe to include this patch as part of the PCI infrastructure. The cleanest implementation of pci_restore_bars was to call pci_update_resource. Unfortunately, that does not currently exist for the sparc64 architecture. The patch below includes a null implemenation of pci_update_resource for sparc64. Some have expressed interest in making general use of the the pci_restore_bars function, so that has been exported to GPL licensed modules. Signed-off-by: John W. Linville Signed-off-by: Greg Kroah-Hartman diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c index ec8bf40..9c17591 100644 --- a/arch/sparc64/kernel/pci.c +++ b/arch/sparc64/kernel/pci.c @@ -413,6 +413,12 @@ static int pci_assign_bus_resource(const struct pci_bus *bus, return -EBUSY; } +void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno) +{ + /* Not implemented for sparc64... */ + BUG(); +} + int pci_assign_resource(struct pci_dev *pdev, int resource) { struct pcidev_cookie *pcp = pdev->sysdata; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index c62d2f0..93ec158 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -222,6 +222,37 @@ pci_find_parent_resource(const struct pci_dev *dev, struct resource *res) } /** + * pci_restore_bars - restore a devices BAR values (e.g. after wake-up) + * @dev: PCI device to have its BARs restored + * + * Restore the BAR values for a given device, so as to make it + * accessible by its driver. + */ +void +pci_restore_bars(struct pci_dev *dev) +{ + int i, numres; + + switch (dev->hdr_type) { + case PCI_HEADER_TYPE_NORMAL: + numres = 6; + break; + case PCI_HEADER_TYPE_BRIDGE: + numres = 2; + break; + case PCI_HEADER_TYPE_CARDBUS: + numres = 1; + break; + default: + /* Should never get here, but just in case... */ + return; + } + + for (i = 0; i < numres; i ++) + pci_update_resource(dev, &dev->resource[i], i); +} + +/** * pci_set_power_state - Set the power state of a PCI device * @dev: PCI device to be suspended * @state: PCI power state (D0, D1, D2, D3hot, D3cold) we're entering @@ -239,7 +270,7 @@ int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t t); int pci_set_power_state(struct pci_dev *dev, pci_power_t state) { - int pm; + int pm, need_restore = 0; u16 pmcsr, pmc; /* bound the state we're entering */ @@ -278,14 +309,17 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state) return -EIO; } + pci_read_config_word(dev, pm + PCI_PM_CTRL, &pmcsr); + /* If we're in D3, force entire word to 0. * This doesn't affect PME_Status, disables PME_En, and * sets PowerState to 0. */ - if (dev->current_state >= PCI_D3hot) + if (dev->current_state >= PCI_D3hot) { + if (!(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET)) + need_restore = 1; pmcsr = 0; - else { - pci_read_config_word(dev, pm + PCI_PM_CTRL, &pmcsr); + } else { pmcsr &= ~PCI_PM_CTRL_STATE_MASK; pmcsr |= state; } @@ -308,6 +342,22 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state) platform_pci_set_power_state(dev, state); dev->current_state = state; + + /* According to section 5.4.1 of the "PCI BUS POWER MANAGEMENT + * INTERFACE SPECIFICATION, REV. 1.2", a device transitioning + * from D3hot to D0 _may_ perform an internal reset, thereby + * going to "D0 Uninitialized" rather than "D0 Initialized". + * For example, at least some versions of the 3c905B and the + * 3c556B exhibit this behaviour. + * + * At least some laptop BIOSen (e.g. the Thinkpad T21) leave + * devices in a D3hot state at boot. Consequently, we need to + * restore at least the BARs so that the device will be + * accessible to its driver. + */ + if (need_restore) + pci_restore_bars(dev); + return 0; } @@ -809,6 +859,7 @@ struct pci_dev *isa_bridge; EXPORT_SYMBOL(isa_bridge); #endif +EXPORT_SYMBOL_GPL(pci_restore_bars); EXPORT_SYMBOL(pci_enable_device_bars); EXPORT_SYMBOL(pci_enable_device); EXPORT_SYMBOL(pci_disable_device); diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 5598b47..362f933 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -26,7 +26,7 @@ #include "pci.h" -static void +void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno) { struct pci_bus_region region; diff --git a/include/linux/pci.h b/include/linux/pci.h index 830c1ba..8878ccf 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -384,7 +384,9 @@ int pci_set_mwi(struct pci_dev *dev); void pci_clear_mwi(struct pci_dev *dev); int pci_set_dma_mask(struct pci_dev *dev, u64 mask); int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); +void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); int pci_assign_resource(struct pci_dev *dev, int i); +void pci_restore_bars(struct pci_dev *dev); /* ROM control related routines */ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size); diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h index 7dc391c..e2a089b 100644 --- a/include/linux/pci_regs.h +++ b/include/linux/pci_regs.h @@ -222,6 +222,7 @@ #define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */ #define PCI_PM_CTRL 4 /* PM control and status register */ #define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */ +#define PCI_PM_CTRL_NO_SOFT_RESET 0x0004 /* No reset for D3hot->D0 */ #define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */ #define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */ #define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */ -- cgit v0.10.2 From 085ae41f66657a9655ce832b0a61832a06f0e1dc Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Mon, 8 Aug 2005 13:19:08 -0700 Subject: [PATCH] Make sparc64 use setup-res.c There were three changes necessary in order to allow sparc64 to use setup-res.c: 1) Sparc64 roots the PCI I/O and MEM address space using parent resources contained in the PCI controller structure. I'm actually surprised no other platforms do this, especially ones like Alpha and PPC{,64}. These resources get linked into the iomem/ioport tree when PCI controllers are probed. So the hierarchy looks like this: iomem --| PCI controller 1 MEM space --| device 1 device 2 etc. PCI controller 2 MEM space --| ... ioport --| PCI controller 1 IO space --| ... PCI controller 2 IO space --| ... You get the idea. The drivers/pci/setup-res.c code allocates using plain iomem_space and ioport_space as the root, so that wouldn't work with the above setup. So I added a pcibios_select_root() that is used to handle this. It uses the PCI controller struct's io_space and mem_space on sparc64, and io{port,mem}_resource on every other platform to keep current behavior. 2) quirk_io_region() is buggy. It takes in raw BUS view addresses and tries to use them as a PCI resource. pci_claim_resource() expects the resource to be fully formed when it gets called. The sparc64 implementation would do the translation but that's absolutely wrong, because if the same resource gets released then re-claimed we'll adjust things twice. So I fixed up quirk_io_region() to do the proper pcibios_bus_to_resource() conversion before passing it on to pci_claim_resource(). 3) I was mistakedly __init'ing the function methods the PCI controller drivers provide on sparc64 to implement some parts of these routines. This was, of course, easy to fix. So we end up with the following, and that nasty SPARC64 makefile ifdef in drivers/pci/Makefile is finally zapped. Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c index 9c17591..2ff7c32 100644 --- a/arch/sparc64/kernel/pci.c +++ b/arch/sparc64/kernel/pci.c @@ -359,140 +359,17 @@ void pcibios_fixup_bus(struct pci_bus *pbus) pbus->resource[1] = &pbm->mem_space; } -int pci_claim_resource(struct pci_dev *pdev, int resource) +struct resource *pcibios_select_root(struct pci_dev *pdev, struct resource *r) { struct pci_pbm_info *pbm = pdev->bus->sysdata; - struct resource *res = &pdev->resource[resource]; - struct resource *root; - - if (!pbm) - return -EINVAL; + struct resource *root = NULL; - if (res->flags & IORESOURCE_IO) + if (r->flags & IORESOURCE_IO) root = &pbm->io_space; - else + if (r->flags & IORESOURCE_MEM) root = &pbm->mem_space; - pbm->parent->resource_adjust(pdev, res, root); - - return request_resource(root, res); -} - -/* - * Given the PCI bus a device resides on, try to - * find an acceptable resource allocation for a - * specific device resource.. - */ -static int pci_assign_bus_resource(const struct pci_bus *bus, - struct pci_dev *dev, - struct resource *res, - unsigned long size, - unsigned long min, - int resno) -{ - unsigned int type_mask; - int i; - - type_mask = IORESOURCE_IO | IORESOURCE_MEM; - for (i = 0 ; i < 4; i++) { - struct resource *r = bus->resource[i]; - if (!r) - continue; - - /* type_mask must match */ - if ((res->flags ^ r->flags) & type_mask) - continue; - - /* Ok, try it out.. */ - if (allocate_resource(r, res, size, min, -1, size, NULL, NULL) < 0) - continue; - - /* PCI config space updated by caller. */ - return 0; - } - return -EBUSY; -} - -void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno) -{ - /* Not implemented for sparc64... */ - BUG(); -} - -int pci_assign_resource(struct pci_dev *pdev, int resource) -{ - struct pcidev_cookie *pcp = pdev->sysdata; - struct pci_pbm_info *pbm = pcp->pbm; - struct resource *res = &pdev->resource[resource]; - unsigned long min, size; - int err; - - if (res->flags & IORESOURCE_IO) - min = pbm->io_space.start + 0x400UL; - else - min = pbm->mem_space.start; - - size = res->end - res->start + 1; - - err = pci_assign_bus_resource(pdev->bus, pdev, res, size, min, resource); - - if (err < 0) { - printk("PCI: Failed to allocate resource %d for %s\n", - resource, pci_name(pdev)); - } else { - /* Update PCI config space. */ - pbm->parent->base_address_update(pdev, resource); - } - - return err; -} - -/* Sort resources by alignment */ -void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head) -{ - int i; - - for (i = 0; i < PCI_NUM_RESOURCES; i++) { - struct resource *r; - struct resource_list *list, *tmp; - unsigned long r_align; - - r = &dev->resource[i]; - r_align = r->end - r->start; - - if (!(r->flags) || r->parent) - continue; - if (!r_align) { - printk(KERN_WARNING "PCI: Ignore bogus resource %d " - "[%lx:%lx] of %s\n", - i, r->start, r->end, pci_name(dev)); - continue; - } - r_align = (i < PCI_BRIDGE_RESOURCES) ? r_align + 1 : r->start; - for (list = head; ; list = list->next) { - unsigned long align = 0; - struct resource_list *ln = list->next; - int idx; - - if (ln) { - idx = ln->res - &ln->dev->resource[0]; - align = (idx < PCI_BRIDGE_RESOURCES) ? - ln->res->end - ln->res->start + 1 : - ln->res->start; - } - if (r_align > align) { - tmp = kmalloc(sizeof(*tmp), GFP_KERNEL); - if (!tmp) - panic("pdev_sort_resources(): " - "kmalloc() failed!\n"); - tmp->next = ln; - tmp->res = r; - tmp->dev = dev; - list->next = tmp; - break; - } - } - } + return root; } void pcibios_update_irq(struct pci_dev *pdev, int irq) diff --git a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c index 91ab466..6ed1ef2 100644 --- a/arch/sparc64/kernel/pci_psycho.c +++ b/arch/sparc64/kernel/pci_psycho.c @@ -307,7 +307,7 @@ static unsigned char psycho_pil_table[] = { /*0x32*/15, /* Power Management */ }; -static int __init psycho_ino_to_pil(struct pci_dev *pdev, unsigned int ino) +static int psycho_ino_to_pil(struct pci_dev *pdev, unsigned int ino) { int ret; @@ -344,9 +344,9 @@ static int __init psycho_ino_to_pil(struct pci_dev *pdev, unsigned int ino) return ret; } -static unsigned int __init psycho_irq_build(struct pci_pbm_info *pbm, - struct pci_dev *pdev, - unsigned int ino) +static unsigned int psycho_irq_build(struct pci_pbm_info *pbm, + struct pci_dev *pdev, + unsigned int ino) { struct ino_bucket *bucket; unsigned long imap, iclr; @@ -1024,7 +1024,7 @@ static irqreturn_t psycho_pcierr_intr(int irq, void *dev_id, struct pt_regs *reg #define PSYCHO_CE_INO 0x2f #define PSYCHO_PCIERR_A_INO 0x30 #define PSYCHO_PCIERR_B_INO 0x31 -static void __init psycho_register_error_handlers(struct pci_controller_info *p) +static void psycho_register_error_handlers(struct pci_controller_info *p) { struct pci_pbm_info *pbm = &p->pbm_A; /* arbitrary */ unsigned long base = p->pbm_A.controller_regs; @@ -1091,15 +1091,15 @@ static void __init psycho_register_error_handlers(struct pci_controller_info *p) } /* PSYCHO boot time probing and initialization. */ -static void __init psycho_resource_adjust(struct pci_dev *pdev, - struct resource *res, - struct resource *root) +static void psycho_resource_adjust(struct pci_dev *pdev, + struct resource *res, + struct resource *root) { res->start += root->start; res->end += root->start; } -static void __init psycho_base_address_update(struct pci_dev *pdev, int resource) +static void psycho_base_address_update(struct pci_dev *pdev, int resource) { struct pcidev_cookie *pcp = pdev->sysdata; struct pci_pbm_info *pbm = pcp->pbm; @@ -1144,7 +1144,7 @@ static void __init psycho_base_address_update(struct pci_dev *pdev, int resource pci_write_config_dword(pdev, where + 4, 0); } -static void __init pbm_config_busmastering(struct pci_pbm_info *pbm) +static void pbm_config_busmastering(struct pci_pbm_info *pbm) { u8 *addr; @@ -1161,8 +1161,8 @@ static void __init pbm_config_busmastering(struct pci_pbm_info *pbm) pci_config_write8(addr, 64); } -static void __init pbm_scan_bus(struct pci_controller_info *p, - struct pci_pbm_info *pbm) +static void pbm_scan_bus(struct pci_controller_info *p, + struct pci_pbm_info *pbm) { struct pcidev_cookie *cookie = kmalloc(sizeof(*cookie), GFP_KERNEL); @@ -1189,7 +1189,7 @@ static void __init pbm_scan_bus(struct pci_controller_info *p, pci_setup_busmastering(pbm, pbm->pci_bus); } -static void __init psycho_scan_bus(struct pci_controller_info *p) +static void psycho_scan_bus(struct pci_controller_info *p) { pbm_config_busmastering(&p->pbm_B); p->pbm_B.is_66mhz_capable = 0; @@ -1204,7 +1204,7 @@ static void __init psycho_scan_bus(struct pci_controller_info *p) psycho_register_error_handlers(p); } -static void __init psycho_iommu_init(struct pci_controller_info *p) +static void psycho_iommu_init(struct pci_controller_info *p) { struct pci_iommu *iommu = p->pbm_A.iommu; unsigned long tsbbase, i; @@ -1327,8 +1327,8 @@ static void psycho_controller_hwinit(struct pci_controller_info *p) psycho_write(p->pbm_A.controller_regs + PSYCHO_PCIB_DIAG, tmp); } -static void __init pbm_register_toplevel_resources(struct pci_controller_info *p, - struct pci_pbm_info *pbm) +static void pbm_register_toplevel_resources(struct pci_controller_info *p, + struct pci_pbm_info *pbm) { char *name = pbm->name; @@ -1481,7 +1481,7 @@ static void psycho_pbm_init(struct pci_controller_info *p, #define PSYCHO_CONFIGSPACE 0x001000000UL -void __init psycho_init(int node, char *model_name) +void psycho_init(int node, char *model_name) { struct linux_prom64_registers pr_regs[3]; struct pci_controller_info *p; diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c index 52bf343..0ee6bd5 100644 --- a/arch/sparc64/kernel/pci_sabre.c +++ b/arch/sparc64/kernel/pci_sabre.c @@ -554,7 +554,7 @@ static unsigned char sabre_pil_table[] = { /*0x32*/15, /* Power Management */ }; -static int __init sabre_ino_to_pil(struct pci_dev *pdev, unsigned int ino) +static int sabre_ino_to_pil(struct pci_dev *pdev, unsigned int ino) { int ret; @@ -612,9 +612,9 @@ static void sabre_wsync_handler(struct ino_bucket *bucket, void *_arg1, void *_a sabre_read(sync_reg); } -static unsigned int __init sabre_irq_build(struct pci_pbm_info *pbm, - struct pci_dev *pdev, - unsigned int ino) +static unsigned int sabre_irq_build(struct pci_pbm_info *pbm, + struct pci_dev *pdev, + unsigned int ino) { struct ino_bucket *bucket; unsigned long imap, iclr; @@ -1009,7 +1009,7 @@ static irqreturn_t sabre_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs #define SABRE_UE_INO 0x2e #define SABRE_CE_INO 0x2f #define SABRE_PCIERR_INO 0x30 -static void __init sabre_register_error_handlers(struct pci_controller_info *p) +static void sabre_register_error_handlers(struct pci_controller_info *p) { struct pci_pbm_info *pbm = &p->pbm_A; /* arbitrary */ unsigned long base = pbm->controller_regs; @@ -1056,9 +1056,9 @@ static void __init sabre_register_error_handlers(struct pci_controller_info *p) sabre_write(base + SABRE_PCICTRL, tmp); } -static void __init sabre_resource_adjust(struct pci_dev *pdev, - struct resource *res, - struct resource *root) +static void sabre_resource_adjust(struct pci_dev *pdev, + struct resource *res, + struct resource *root) { struct pci_pbm_info *pbm = pdev->bus->sysdata; unsigned long base; @@ -1072,7 +1072,7 @@ static void __init sabre_resource_adjust(struct pci_dev *pdev, res->end += base; } -static void __init sabre_base_address_update(struct pci_dev *pdev, int resource) +static void sabre_base_address_update(struct pci_dev *pdev, int resource) { struct pcidev_cookie *pcp = pdev->sysdata; struct pci_pbm_info *pbm = pcp->pbm; @@ -1118,7 +1118,7 @@ static void __init sabre_base_address_update(struct pci_dev *pdev, int resource) pci_write_config_dword(pdev, where + 4, 0); } -static void __init apb_init(struct pci_controller_info *p, struct pci_bus *sabre_bus) +static void apb_init(struct pci_controller_info *p, struct pci_bus *sabre_bus) { struct pci_dev *pdev; @@ -1181,7 +1181,7 @@ static struct pcidev_cookie *alloc_bridge_cookie(struct pci_pbm_info *pbm) return cookie; } -static void __init sabre_scan_bus(struct pci_controller_info *p) +static void sabre_scan_bus(struct pci_controller_info *p) { static int once; struct pci_bus *sabre_bus, *pbus; @@ -1262,9 +1262,9 @@ static void __init sabre_scan_bus(struct pci_controller_info *p) sabre_register_error_handlers(p); } -static void __init sabre_iommu_init(struct pci_controller_info *p, - int tsbsize, unsigned long dvma_offset, - u32 dma_mask) +static void sabre_iommu_init(struct pci_controller_info *p, + int tsbsize, unsigned long dvma_offset, + u32 dma_mask) { struct pci_iommu *iommu = p->pbm_A.iommu; unsigned long tsbbase, i, order; @@ -1345,8 +1345,8 @@ static void __init sabre_iommu_init(struct pci_controller_info *p, } } -static void __init pbm_register_toplevel_resources(struct pci_controller_info *p, - struct pci_pbm_info *pbm) +static void pbm_register_toplevel_resources(struct pci_controller_info *p, + struct pci_pbm_info *pbm) { char *name = pbm->name; unsigned long ibase = p->pbm_A.controller_regs + SABRE_IOSPACE; @@ -1415,7 +1415,7 @@ static void __init pbm_register_toplevel_resources(struct pci_controller_info *p &pbm->mem_space); } -static void __init sabre_pbm_init(struct pci_controller_info *p, int sabre_node, u32 dma_begin) +static void sabre_pbm_init(struct pci_controller_info *p, int sabre_node, u32 dma_begin) { struct pci_pbm_info *pbm; char namebuf[128]; @@ -1552,7 +1552,7 @@ static void __init sabre_pbm_init(struct pci_controller_info *p, int sabre_node, } } -void __init sabre_init(int pnode, char *model_name) +void sabre_init(int pnode, char *model_name) { struct linux_prom64_registers pr_regs[2]; struct pci_controller_info *p; diff --git a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c index 6a182bb..331382e 100644 --- a/arch/sparc64/kernel/pci_schizo.c +++ b/arch/sparc64/kernel/pci_schizo.c @@ -285,7 +285,7 @@ static unsigned char schizo_pil_table[] = { /*0x3f*/0, /* Reserved for NewLink */ }; -static int __init schizo_ino_to_pil(struct pci_dev *pdev, unsigned int ino) +static int schizo_ino_to_pil(struct pci_dev *pdev, unsigned int ino) { int ret; @@ -1221,7 +1221,7 @@ static irqreturn_t schizo_safarierr_intr(int irq, void *dev_id, struct pt_regs * * PCI bus units of the same Tomatillo. I still have not really * figured this out... */ -static void __init tomatillo_register_error_handlers(struct pci_controller_info *p) +static void tomatillo_register_error_handlers(struct pci_controller_info *p) { struct pci_pbm_info *pbm; unsigned int irq; @@ -1359,7 +1359,7 @@ static void __init tomatillo_register_error_handlers(struct pci_controller_info (SCHIZO_SAFIRQCTRL_EN | (BUS_ERROR_UNMAP))); } -static void __init schizo_register_error_handlers(struct pci_controller_info *p) +static void schizo_register_error_handlers(struct pci_controller_info *p) { struct pci_pbm_info *pbm; unsigned int irq; @@ -1505,7 +1505,7 @@ static void __init schizo_register_error_handlers(struct pci_controller_info *p) (SCHIZO_SAFIRQCTRL_EN | (BUS_ERROR_UNMAP))); } -static void __init pbm_config_busmastering(struct pci_pbm_info *pbm) +static void pbm_config_busmastering(struct pci_pbm_info *pbm) { u8 *addr; @@ -1522,8 +1522,8 @@ static void __init pbm_config_busmastering(struct pci_pbm_info *pbm) pci_config_write8(addr, 64); } -static void __init pbm_scan_bus(struct pci_controller_info *p, - struct pci_pbm_info *pbm) +static void pbm_scan_bus(struct pci_controller_info *p, + struct pci_pbm_info *pbm) { struct pcidev_cookie *cookie = kmalloc(sizeof(*cookie), GFP_KERNEL); @@ -1550,8 +1550,8 @@ static void __init pbm_scan_bus(struct pci_controller_info *p, pci_setup_busmastering(pbm, pbm->pci_bus); } -static void __init __schizo_scan_bus(struct pci_controller_info *p, - int chip_type) +static void __schizo_scan_bus(struct pci_controller_info *p, + int chip_type) { if (!p->pbm_B.prom_node || !p->pbm_A.prom_node) { printk("PCI: Only one PCI bus module of controller found.\n"); @@ -1577,17 +1577,17 @@ static void __init __schizo_scan_bus(struct pci_controller_info *p, schizo_register_error_handlers(p); } -static void __init schizo_scan_bus(struct pci_controller_info *p) +static void schizo_scan_bus(struct pci_controller_info *p) { __schizo_scan_bus(p, PBM_CHIP_TYPE_SCHIZO); } -static void __init tomatillo_scan_bus(struct pci_controller_info *p) +static void tomatillo_scan_bus(struct pci_controller_info *p) { __schizo_scan_bus(p, PBM_CHIP_TYPE_TOMATILLO); } -static void __init schizo_base_address_update(struct pci_dev *pdev, int resource) +static void schizo_base_address_update(struct pci_dev *pdev, int resource) { struct pcidev_cookie *pcp = pdev->sysdata; struct pci_pbm_info *pbm = pcp->pbm; @@ -1632,9 +1632,9 @@ static void __init schizo_base_address_update(struct pci_dev *pdev, int resource pci_write_config_dword(pdev, where + 4, 0); } -static void __init schizo_resource_adjust(struct pci_dev *pdev, - struct resource *res, - struct resource *root) +static void schizo_resource_adjust(struct pci_dev *pdev, + struct resource *res, + struct resource *root) { res->start += root->start; res->end += root->start; @@ -1702,8 +1702,8 @@ static void schizo_determine_mem_io_space(struct pci_pbm_info *pbm) pbm->mem_space.start); } -static void __init pbm_register_toplevel_resources(struct pci_controller_info *p, - struct pci_pbm_info *pbm) +static void pbm_register_toplevel_resources(struct pci_controller_info *p, + struct pci_pbm_info *pbm) { pbm->io_space.name = pbm->mem_space.name = pbm->name; @@ -1932,7 +1932,7 @@ static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm) #define TOMATILLO_PCI_IOC_TDIAG (0x2250UL) #define TOMATILLO_PCI_IOC_DDIAG (0x2290UL) -static void __init schizo_pbm_hw_init(struct pci_pbm_info *pbm) +static void schizo_pbm_hw_init(struct pci_pbm_info *pbm) { u64 tmp; @@ -1986,9 +1986,9 @@ static void __init schizo_pbm_hw_init(struct pci_pbm_info *pbm) } } -static void __init schizo_pbm_init(struct pci_controller_info *p, - int prom_node, u32 portid, - int chip_type) +static void schizo_pbm_init(struct pci_controller_info *p, + int prom_node, u32 portid, + int chip_type) { struct linux_prom64_registers pr_regs[4]; unsigned int busrange[2]; @@ -2145,7 +2145,7 @@ static inline int portid_compare(u32 x, u32 y, int chip_type) return (x == y); } -static void __init __schizo_init(int node, char *model_name, int chip_type) +static void __schizo_init(int node, char *model_name, int chip_type) { struct pci_controller_info *p; struct pci_iommu *iommu; @@ -2213,17 +2213,17 @@ static void __init __schizo_init(int node, char *model_name, int chip_type) schizo_pbm_init(p, node, portid, chip_type); } -void __init schizo_init(int node, char *model_name) +void schizo_init(int node, char *model_name) { __schizo_init(node, model_name, PBM_CHIP_TYPE_SCHIZO); } -void __init schizo_plus_init(int node, char *model_name) +void schizo_plus_init(int node, char *model_name) { __schizo_init(node, model_name, PBM_CHIP_TYPE_SCHIZO_PLUS); } -void __init tomatillo_init(int node, char *model_name) +void tomatillo_init(int node, char *model_name) { __schizo_init(node, model_name, PBM_CHIP_TYPE_TOMATILLO); } diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 87cbf2d..716df015 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -3,13 +3,9 @@ # obj-y += access.o bus.o probe.o remove.o pci.o quirks.o \ - pci-driver.o search.o pci-sysfs.o rom.o + pci-driver.o search.o pci-sysfs.o rom.o setup-res.o obj-$(CONFIG_PROC_FS) += proc.o -ifndef CONFIG_SPARC64 -obj-y += setup-res.o -endif - obj-$(CONFIG_HOTPLUG) += hotplug.o # Build the PCI Hotplug drivers if we were asked to diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 140354a..4f0c1bd 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -245,12 +245,19 @@ static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region, unsi { region &= ~(size-1); if (region) { + struct pci_bus_region bus_region; struct resource *res = dev->resource + nr; res->name = pci_name(dev); res->start = region; res->end = region + size - 1; res->flags = IORESOURCE_IO; + + /* Convert from PCI bus to resource space. */ + bus_region.start = res->start; + bus_region.end = res->end; + pcibios_bus_to_resource(dev, res, &bus_region); + pci_claim_resource(dev, nr); } } diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 362f933..50d6685 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -97,10 +97,7 @@ pci_claim_resource(struct pci_dev *dev, int resource) char *dtype = resource < PCI_BRIDGE_RESOURCES ? "device" : "bridge"; int err; - if (res->flags & IORESOURCE_IO) - root = &ioport_resource; - if (res->flags & IORESOURCE_MEM) - root = &iomem_resource; + root = pcibios_select_root(dev, res); err = -EINVAL; if (root != NULL) diff --git a/include/asm-alpha/pci.h b/include/asm-alpha/pci.h index f681e67..4e115f3 100644 --- a/include/asm-alpha/pci.h +++ b/include/asm-alpha/pci.h @@ -254,6 +254,19 @@ extern void pcibios_resource_to_bus(struct pci_dev *, struct pci_bus_region *, extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, struct pci_bus_region *region); +static inline struct resource * +pcibios_select_root(struct pci_dev *pdev, struct resource *res) +{ + struct resource *root = NULL; + + if (res->flags & IORESOURCE_IO) + root = &ioport_resource; + if (res->flags & IORESOURCE_MEM) + root = &iomem_resource; + + return root; +} + #define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index static inline int pci_proc_domain(struct pci_bus *bus) diff --git a/include/asm-arm/pci.h b/include/asm-arm/pci.h index 38ea589..ead3ced 100644 --- a/include/asm-arm/pci.h +++ b/include/asm-arm/pci.h @@ -64,6 +64,19 @@ extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, struct pci_bus_region *region); +static inline struct resource * +pcibios_select_root(struct pci_dev *pdev, struct resource *res) +{ + struct resource *root = NULL; + + if (res->flags & IORESOURCE_IO) + root = &ioport_resource; + if (res->flags & IORESOURCE_MEM) + root = &iomem_resource; + + return root; +} + static inline void pcibios_add_platform_entries(struct pci_dev *dev) { } diff --git a/include/asm-generic/pci.h b/include/asm-generic/pci.h index ee1d8b5..c36a77d 100644 --- a/include/asm-generic/pci.h +++ b/include/asm-generic/pci.h @@ -30,6 +30,19 @@ pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, res->end = region->end; } +static inline struct resource * +pcibios_select_root(struct pci_dev *pdev, struct resource *res) +{ + struct resource *root = NULL; + + if (res->flags & IORESOURCE_IO) + root = &ioport_resource; + if (res->flags & IORESOURCE_MEM) + root = &iomem_resource; + + return root; +} + #define pcibios_scan_all_fns(a, b) 0 #ifndef HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ diff --git a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h index dba9f22..ef616fd 100644 --- a/include/asm-ia64/pci.h +++ b/include/asm-ia64/pci.h @@ -156,6 +156,19 @@ extern void pcibios_resource_to_bus(struct pci_dev *dev, extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, struct pci_bus_region *region); +static inline struct resource * +pcibios_select_root(struct pci_dev *pdev, struct resource *res) +{ + struct resource *root = NULL; + + if (res->flags & IORESOURCE_IO) + root = &ioport_resource; + if (res->flags & IORESOURCE_MEM) + root = &iomem_resource; + + return root; +} + #define pcibios_scan_all_fns(a, b) 0 #endif /* _ASM_IA64_PCI_H */ diff --git a/include/asm-parisc/pci.h b/include/asm-parisc/pci.h index 98d79a3..d0b761f 100644 --- a/include/asm-parisc/pci.h +++ b/include/asm-parisc/pci.h @@ -257,6 +257,19 @@ extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, struct pci_bus_region *region); +static inline struct resource * +pcibios_select_root(struct pci_dev *pdev, struct resource *res) +{ + struct resource *root = NULL; + + if (res->flags & IORESOURCE_IO) + root = &ioport_resource; + if (res->flags & IORESOURCE_MEM) + root = &iomem_resource; + + return root; +} + static inline void pcibios_add_platform_entries(struct pci_dev *dev) { } diff --git a/include/asm-ppc/pci.h b/include/asm-ppc/pci.h index a811e44..9dd06cd 100644 --- a/include/asm-ppc/pci.h +++ b/include/asm-ppc/pci.h @@ -109,6 +109,19 @@ extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, struct pci_bus_region *region); +static inline struct resource * +pcibios_select_root(struct pci_dev *pdev, struct resource *res) +{ + struct resource *root = NULL; + + if (res->flags & IORESOURCE_IO) + root = &ioport_resource; + if (res->flags & IORESOURCE_MEM) + root = &iomem_resource; + + return root; +} + extern void pcibios_add_platform_entries(struct pci_dev *dev); struct file; diff --git a/include/asm-ppc64/pci.h b/include/asm-ppc64/pci.h index 4d05745..a88bbfc 100644 --- a/include/asm-ppc64/pci.h +++ b/include/asm-ppc64/pci.h @@ -138,6 +138,19 @@ extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, struct pci_bus_region *region); +static inline struct resource * +pcibios_select_root(struct pci_dev *pdev, struct resource *res) +{ + struct resource *root = NULL; + + if (res->flags & IORESOURCE_IO) + root = &ioport_resource; + if (res->flags & IORESOURCE_MEM) + root = &iomem_resource; + + return root; +} + extern int unmap_bus_range(struct pci_bus *bus); diff --git a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h index a4ab0ec..89bd71b 100644 --- a/include/asm-sparc64/pci.h +++ b/include/asm-sparc64/pci.h @@ -269,6 +269,8 @@ extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, struct pci_bus_region *region); +extern struct resource *pcibios_select_root(struct pci_dev *, struct resource *); + static inline void pcibios_add_platform_entries(struct pci_dev *dev) { } -- cgit v0.10.2 From 95a629657dbe28e44a312c47815b3dc3f1ce0970 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 28 Jul 2005 11:37:33 -0700 Subject: [PATCH] PCI: start paying attention to a lot of pci function return values Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index fb9a112..a83ee0b 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -140,10 +140,11 @@ void __devinit pci_bus_add_devices(struct pci_bus *bus) void pci_enable_bridges(struct pci_bus *bus) { struct pci_dev *dev; + int retval; list_for_each_entry(dev, &bus->devices, bus_list) { if (dev->subordinate) { - pci_enable_device(dev); + retval = pci_enable_device(dev); pci_set_master(dev); pci_enable_bridges(dev->subordinate); } diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 414c772..0d0d533 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -272,17 +272,19 @@ static int pci_device_suspend(struct device * dev, pm_message_t state) } -/* +/* * Default resume method for devices that have no driver provided resume, * or not even a driver at all. */ static void pci_default_resume(struct pci_dev *pci_dev) { + int retval; + /* restore the PCI config space */ pci_restore_state(pci_dev); /* if the device was enabled before suspend, reenable */ if (pci_dev->is_enabled) - pci_enable_device(pci_dev); + retval = pci_enable_device(pci_dev); /* if the device was busmaster before the suspend, make it busmaster again */ if (pci_dev->is_busmaster) pci_set_master(pci_dev); diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 93ec158..afee2de 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -444,8 +444,11 @@ pci_enable_device_bars(struct pci_dev *dev, int bars) { int err; - pci_set_power_state(dev, PCI_D0); - if ((err = pcibios_enable_device(dev, bars)) < 0) + err = pci_set_power_state(dev, PCI_D0); + if (err) + return err; + err = pcibios_enable_device(dev, bars); + if (err < 0) return err; return 0; } diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 30bac7e..3c565ce 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c @@ -90,15 +90,19 @@ static void pcie_portdrv_save_config(struct pci_dev *dev) pci_save_msi_state(dev); } -static void pcie_portdrv_restore_config(struct pci_dev *dev) +static int pcie_portdrv_restore_config(struct pci_dev *dev) { struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev); + int retval; pci_restore_state(dev); if (p_ext->interrupt_mode == PCIE_PORT_MSI_MODE) pci_restore_msi_state(dev); - pci_enable_device(dev); + retval = pci_enable_device(dev); + if (retval) + return retval; pci_set_master(dev); + return 0; } /* diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 7b9e54c..cbb451d 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -260,8 +260,10 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) retval = pci_set_power_state (dev, PCI_D3hot); if (retval == 0) { dev_dbg (hcd->self.controller, "--> PCI D3\n"); - pci_enable_wake (dev, PCI_D3hot, hcd->remote_wakeup); - pci_enable_wake (dev, PCI_D3cold, hcd->remote_wakeup); + retval = pci_enable_wake (dev, PCI_D3hot, hcd->remote_wakeup); + if (retval) + break; + retval = pci_enable_wake (dev, PCI_D3cold, hcd->remote_wakeup); } else if (retval < 0) { dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n", retval); @@ -335,8 +337,20 @@ int usb_hcd_pci_resume (struct pci_dev *dev) dev->current_state); } #endif - pci_enable_wake (dev, dev->current_state, 0); - pci_enable_wake (dev, PCI_D3cold, 0); + retval = pci_enable_wake (dev, dev->current_state, 0); + if (retval) { + dev_err(hcd->self.controller, + "can't enable_wake to %d, %d!\n", + dev->current_state, retval); + return retval; + } + retval = pci_enable_wake (dev, PCI_D3cold, 0); + if (retval) { + dev_err(hcd->self.controller, + "can't enable_wake to %d, %d!\n", + PCI_D3cold, retval); + return retval; + } } else { /* Same basic cases: clean (powered/not), dirty */ dev_dbg(hcd->self.controller, "PCI legacy resume\n"); @@ -376,7 +390,7 @@ int usb_hcd_pci_resume (struct pci_dev *dev) usb_hc_died (hcd); } - pci_enable_device(dev); + retval = pci_enable_device(dev); return retval; } EXPORT_SYMBOL (usb_hcd_pci_resume); diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 149b13f..2507e89 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -549,7 +549,9 @@ static int ehci_start (struct usb_hcd *hcd) hcd->can_wakeup = (port_wake & 1) != 0; /* help hc dma work well with cachelines */ - pci_set_mwi (pdev); + retval = pci_set_mwi(pdev); + if (retval) + ehci_dbg(ehci, "unable to enable MWI - not fatal.\n"); } #endif -- cgit v0.10.2 From 11f3859b1e85dd408756c72e228cfb5aa7230c87 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 10 Aug 2005 15:18:44 -0400 Subject: [PATCH] PCI: Fix regression in pci_enable_device_bars This patch (as552) fixes yet another small problem recently added. If an attempt to put a PCI device back into D0 fails because the device doesn't support PCI PM, it shouldn't count as error. Without this patch the UHCI controllers on my Intel motherboard don't work. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index afee2de..3dcb83d 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -445,7 +445,7 @@ pci_enable_device_bars(struct pci_dev *dev, int bars) int err; err = pci_set_power_state(dev, PCI_D0); - if (err) + if (err < 0 && err != -EIO) return err; err = pcibios_enable_device(dev, bars); if (err < 0) -- cgit v0.10.2 From c9d8073fd2a0bcb5df973654e988282b523cf553 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Wed, 10 Aug 2005 02:09:39 +0200 Subject: [PATCH] PCI: remove pci_find_device from parport_pc.c This patch changes pci_find_device to pci_get_device (encapsulated in for_each_pci_dev). Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c index 97f7231..1b938bb 100644 --- a/drivers/parport/parport_pc.c +++ b/drivers/parport/parport_pc.c @@ -3010,7 +3010,7 @@ static int __init parport_pc_init_superio (int autoirq, int autodma) struct pci_dev *pdev = NULL; int ret = 0; - while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) { + for_each_pci_dev(pdev) { id = pci_match_id(parport_pc_pci_tbl, pdev); if (id == NULL || id->driver_data >= last_sio) continue; -- cgit v0.10.2 From 1d2450a4a6eb656798c6282b5ffc8e5f9f52ac14 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Fri, 12 Aug 2005 10:13:34 -0400 Subject: [PATCH] PCI Hotplug: SGI hotplug driver fixes These fixes were suggested by pcihpd-discuss, but were dropped in the initial checkin of the code. These fixes include cleaning up the hotplug driver sysfs filename, and some minor code cleanups. The driver also requires at least PROM 4.30, not 4.20. Signed-off-by: Prarit Bhargava Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c index 323041f..b140944 100644 --- a/drivers/pci/hotplug/sgi_hotplug.c +++ b/drivers/pci/hotplug/sgi_hotplug.c @@ -32,14 +32,15 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("SGI (prarit@sgi.com, dickie@sgi.com, habeck@sgi.com)"); MODULE_DESCRIPTION("SGI Altix Hot Plug PCI Controller Driver"); -#define PCIIO_ASIC_TYPE_TIOCA 4 -#define PCI_SLOT_ALREADY_UP 2 /* slot already up */ -#define PCI_SLOT_ALREADY_DOWN 3 /* slot already down */ -#define PCI_L1_ERR 7 /* L1 console command error */ -#define PCI_EMPTY_33MHZ 15 /* empty 33 MHz bus */ -#define PCI_L1_QSIZE 128 /* our L1 message buffer size */ -#define SN_MAX_HP_SLOTS 32 /* max number of hotplug slots */ -#define SGI_HOTPLUG_PROM_REV 0x0420 /* Min. required PROM version */ +#define PCIIO_ASIC_TYPE_TIOCA 4 +#define PCI_SLOT_ALREADY_UP 2 /* slot already up */ +#define PCI_SLOT_ALREADY_DOWN 3 /* slot already down */ +#define PCI_L1_ERR 7 /* L1 console command error */ +#define PCI_EMPTY_33MHZ 15 /* empty 33 MHz bus */ +#define PCI_L1_QSIZE 128 /* our L1 message buffer size */ +#define SN_MAX_HP_SLOTS 32 /* max hotplug slots */ +#define SGI_HOTPLUG_PROM_REV 0x0430 /* Min. required PROM version */ +#define SN_SLOT_NAME_SIZE 33 /* size of name string */ /* internal list head */ static struct list_head sn_hp_list; @@ -51,6 +52,7 @@ struct slot { /* this struct for glue internal only */ struct hotplug_slot *hotplug_slot; struct list_head hp_list; + char physical_path[SN_SLOT_NAME_SIZE]; }; struct pcibr_slot_enable_resp { @@ -70,7 +72,7 @@ enum sn_pci_req_e { static int enable_slot(struct hotplug_slot *slot); static int disable_slot(struct hotplug_slot *slot); -static int get_power_status(struct hotplug_slot *slot, u8 *value); +static inline int get_power_status(struct hotplug_slot *slot, u8 *value); static struct hotplug_slot_ops sn_hotplug_slot_ops = { .owner = THIS_MODULE, @@ -81,6 +83,21 @@ static struct hotplug_slot_ops sn_hotplug_slot_ops = { static DECLARE_MUTEX(sn_hotplug_sem); +static ssize_t path_show (struct hotplug_slot *bss_hotplug_slot, + char *buf) +{ + int retval = -ENOENT; + struct slot *slot = bss_hotplug_slot->private; + + if (!slot) + return retval; + + retval = sprintf (buf, "%s\n", slot->physical_path); + return retval; +} + +static struct hotplug_slot_attribute sn_slot_path_attr = __ATTR_RO(path); + static int sn_pci_slot_valid(struct pci_bus *pci_bus, int device) { struct pcibus_info *pcibus_info; @@ -120,15 +137,15 @@ static int sn_pci_bus_valid(struct pci_bus *pci_bus) /* Only register slots in I/O Bricks that support hotplug */ bricktype = MODULE_GET_BTYPE(pcibus_info->pbi_moduleid); switch (bricktype) { - case L1_BRICKTYPE_IX: - case L1_BRICKTYPE_PX: - case L1_BRICKTYPE_IA: - case L1_BRICKTYPE_PA: - return 1; - break; - default: - return -EPERM; - break; + case L1_BRICKTYPE_IX: + case L1_BRICKTYPE_PX: + case L1_BRICKTYPE_IA: + case L1_BRICKTYPE_PA: + return 1; + break; + default: + return -EPERM; + break; } return -EIO; @@ -142,13 +159,12 @@ static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot, pcibus_info = SN_PCIBUS_BUSSOFT_INFO(pci_bus); - bss_hotplug_slot->private = kcalloc(1, sizeof(struct slot), - GFP_KERNEL); - if (!bss_hotplug_slot->private) + slot = kcalloc(1, sizeof(*slot), GFP_KERNEL); + if (!slot) return -ENOMEM; - slot = (struct slot *)bss_hotplug_slot->private; + bss_hotplug_slot->private = slot; - bss_hotplug_slot->name = kmalloc(33, GFP_KERNEL); + bss_hotplug_slot->name = kmalloc(SN_SLOT_NAME_SIZE, GFP_KERNEL); if (!bss_hotplug_slot->name) { kfree(bss_hotplug_slot->private); return -ENOMEM; @@ -156,16 +172,16 @@ static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot, slot->device_num = device; slot->pci_bus = pci_bus; - - sprintf(bss_hotplug_slot->name, "module_%c%c%c%c%.2d_b_%d_s_%d", + sprintf(bss_hotplug_slot->name, "%04x:%02x:%02x", + pci_domain_nr(pci_bus), + ((int)pcibus_info->pbi_buscommon.bs_persist_busnum) & 0xf, + device + 1); + sprintf(slot->physical_path, "module_%c%c%c%c%.2d", '0'+RACK_GET_CLASS(MODULE_GET_RACK(pcibus_info->pbi_moduleid)), '0'+RACK_GET_GROUP(MODULE_GET_RACK(pcibus_info->pbi_moduleid)), '0'+RACK_GET_NUM(MODULE_GET_RACK(pcibus_info->pbi_moduleid)), MODULE_GET_BTCHAR(pcibus_info->pbi_moduleid), - MODULE_GET_BPOS(pcibus_info->pbi_moduleid), - ((int)pcibus_info->pbi_buscommon.bs_persist_busnum) & 0xf, - device + 1); - + MODULE_GET_BPOS(pcibus_info->pbi_moduleid)); slot->hotplug_slot = bss_hotplug_slot; list_add(&slot->hp_list, &sn_hp_list); @@ -175,14 +191,14 @@ static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot, static struct hotplug_slot * sn_hp_destroy(void) { struct slot *slot; - struct list_head *list; struct hotplug_slot *bss_hotplug_slot = NULL; - list_for_each(list, &sn_hp_list) { - slot = list_entry(list, struct slot, hp_list); + list_for_each_entry(slot, &sn_hp_list, hp_list) { bss_hotplug_slot = slot->hotplug_slot; list_del(&((struct slot *)bss_hotplug_slot->private)-> hp_list); + sysfs_remove_file(&bss_hotplug_slot->kobj, + &sn_slot_path_attr.attr); break; } return bss_hotplug_slot; @@ -190,7 +206,6 @@ static struct hotplug_slot * sn_hp_destroy(void) static void sn_bus_alloc_data(struct pci_dev *dev) { - struct list_head *node; struct pci_bus *subordinate_bus; struct pci_dev *child; @@ -199,66 +214,29 @@ static void sn_bus_alloc_data(struct pci_dev *dev) /* Recursively sets up the sn_irq_info structs */ if (dev->subordinate) { subordinate_bus = dev->subordinate; - list_for_each(node, &subordinate_bus->devices) { - child = list_entry(node, struct pci_dev, bus_list); + list_for_each_entry(child, &subordinate_bus->devices, bus_list) sn_bus_alloc_data(child); - } } } static void sn_bus_free_data(struct pci_dev *dev) { - struct list_head *node; struct pci_bus *subordinate_bus; struct pci_dev *child; /* Recursively clean up sn_irq_info structs */ if (dev->subordinate) { subordinate_bus = dev->subordinate; - list_for_each(node, &subordinate_bus->devices) { - child = list_entry(node, struct pci_dev, bus_list); + list_for_each_entry(child, &subordinate_bus->devices, bus_list) sn_bus_free_data(child); - } } sn_pci_unfixup_slot(dev); } -static u8 sn_power_status_get(struct hotplug_slot *bss_hotplug_slot) -{ - struct slot *slot = (struct slot *)bss_hotplug_slot->private; - struct pcibus_info *pcibus_info; - u8 retval; - - pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); - retval = pcibus_info->pbi_enabled_devices & (1 << slot->device_num); - - return retval ? 1 : 0; -} - -static void sn_slot_mark_enable(struct hotplug_slot *bss_hotplug_slot, - int device_num) -{ - struct slot *slot = (struct slot *)bss_hotplug_slot->private; - struct pcibus_info *pcibus_info; - - pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); - pcibus_info->pbi_enabled_devices |= (1 << device_num); -} - -static void sn_slot_mark_disable(struct hotplug_slot *bss_hotplug_slot, - int device_num) -{ - struct slot *slot = (struct slot *)bss_hotplug_slot->private; - struct pcibus_info *pcibus_info; - - pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); - pcibus_info->pbi_enabled_devices &= ~(1 << device_num); -} - static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot, int device_num) { - struct slot *slot = (struct slot *)bss_hotplug_slot->private; + struct slot *slot = bss_hotplug_slot->private; struct pcibus_info *pcibus_info; struct pcibr_slot_enable_resp resp; int rc; @@ -273,7 +251,7 @@ static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot, if (rc == PCI_SLOT_ALREADY_UP) { dev_dbg(slot->pci_bus->self, "is already active\n"); - return -EPERM; + return 1; /* return 1 to user */ } if (rc == PCI_L1_ERR) { @@ -290,7 +268,8 @@ static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot, return -EIO; } - sn_slot_mark_enable(bss_hotplug_slot, device_num); + pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); + pcibus_info->pbi_enabled_devices |= (1 << device_num); return 0; } @@ -298,7 +277,7 @@ static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot, static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, int device_num, int action) { - struct slot *slot = (struct slot *)bss_hotplug_slot->private; + struct slot *slot = bss_hotplug_slot->private; struct pcibus_info *pcibus_info; struct pcibr_slot_disable_resp resp; int rc; @@ -307,43 +286,44 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, rc = sal_pcibr_slot_disable(pcibus_info, device_num, action, &resp); - if (action == PCI_REQ_SLOT_ELIGIBLE && rc == PCI_SLOT_ALREADY_DOWN) { + if ((action == PCI_REQ_SLOT_ELIGIBLE) && + (rc == PCI_SLOT_ALREADY_DOWN)) { dev_dbg(slot->pci_bus->self, "Slot %s already inactive\n"); - return -ENODEV; + return 1; /* return 1 to user */ } - if (action == PCI_REQ_SLOT_ELIGIBLE && rc == PCI_EMPTY_33MHZ) { + if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) { dev_dbg(slot->pci_bus->self, "Cannot remove last 33MHz card\n"); return -EPERM; } - if (action == PCI_REQ_SLOT_ELIGIBLE && rc == PCI_L1_ERR) { + if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) { dev_dbg(slot->pci_bus->self, "L1 failure %d with message \n%s\n", resp.resp_sub_errno, resp.resp_l1_msg); return -EPERM; } - if (action == PCI_REQ_SLOT_ELIGIBLE && rc) { + if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) { dev_dbg(slot->pci_bus->self, "remove failed with error %d sub-error %d\n", rc, resp.resp_sub_errno); return -EIO; } - if (action == PCI_REQ_SLOT_ELIGIBLE && !rc) + if ((action == PCI_REQ_SLOT_ELIGIBLE) && !rc) return 0; - if (action == PCI_REQ_SLOT_DISABLE && !rc) { - sn_slot_mark_disable(bss_hotplug_slot, device_num); + if ((action == PCI_REQ_SLOT_DISABLE) && !rc) { + pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); + pcibus_info->pbi_enabled_devices &= ~(1 << device_num); dev_dbg(slot->pci_bus->self, "remove successful\n"); return 0; } - if (action == PCI_REQ_SLOT_DISABLE && rc) { + if ((action == PCI_REQ_SLOT_DISABLE) && rc) { dev_dbg(slot->pci_bus->self,"remove failed rc = %d\n", rc); - return rc; } return rc; @@ -351,7 +331,7 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, static int enable_slot(struct hotplug_slot *bss_hotplug_slot) { - struct slot *slot = (struct slot *)bss_hotplug_slot->private; + struct slot *slot = bss_hotplug_slot->private; struct pci_bus *new_bus = NULL; struct pci_dev *dev; int func, num_funcs; @@ -371,8 +351,8 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) return rc; } - num_funcs = pci_scan_slot(slot->pci_bus, PCI_DEVFN(slot->device_num+1, - PCI_FUNC(0))); + num_funcs = pci_scan_slot(slot->pci_bus, + PCI_DEVFN(slot->device_num + 1, 0)); if (!num_funcs) { dev_dbg(slot->pci_bus->self, "no device in slot\n"); up(&sn_hotplug_sem); @@ -391,8 +371,6 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) dev = pci_get_slot(slot->pci_bus, PCI_DEVFN(slot->device_num + 1, PCI_FUNC(func))); - - if (dev) { if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { unsigned char sec_bus; @@ -431,7 +409,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) static int disable_slot(struct hotplug_slot *bss_hotplug_slot) { - struct slot *slot = (struct slot *)bss_hotplug_slot->private; + struct slot *slot = bss_hotplug_slot->private; struct pci_dev *dev; int func; int rc; @@ -448,7 +426,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot) /* Free the SN resources assigned to the Linux device.*/ for (func = 0; func < 8; func++) { dev = pci_get_slot(slot->pci_bus, - PCI_DEVFN(slot->device_num+1, + PCI_DEVFN(slot->device_num + 1, PCI_FUNC(func))); if (dev) { /* @@ -477,10 +455,15 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot) return rc; } -static int get_power_status(struct hotplug_slot *bss_hotplug_slot, u8 *value) +static inline int get_power_status(struct hotplug_slot *bss_hotplug_slot, + u8 *value) { + struct slot *slot = bss_hotplug_slot->private; + struct pcibus_info *pcibus_info; + + pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); down(&sn_hotplug_sem); - *value = sn_power_status_get(bss_hotplug_slot); + *value = pcibus_info->pbi_enabled_devices & (1 << slot->device_num); up(&sn_hotplug_sem); return 0; } @@ -508,7 +491,7 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) if (sn_pci_slot_valid(pci_bus, device) != 1) continue; - bss_hotplug_slot = kcalloc(1,sizeof(struct hotplug_slot), + bss_hotplug_slot = kcalloc(1, sizeof(*bss_hotplug_slot), GFP_KERNEL); if (!bss_hotplug_slot) { rc = -ENOMEM; @@ -516,7 +499,7 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) } bss_hotplug_slot->info = - kcalloc(1,sizeof(struct hotplug_slot_info), + kcalloc(1, sizeof(struct hotplug_slot_info), GFP_KERNEL); if (!bss_hotplug_slot->info) { rc = -ENOMEM; @@ -535,6 +518,11 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) rc = pci_hp_register(bss_hotplug_slot); if (rc) goto register_err; + + rc = sysfs_create_file(&bss_hotplug_slot->kobj, + &sn_slot_path_attr.attr); + if (rc) + goto register_err; } dev_dbg(pci_bus->self, "Registered bus with hotplug\n"); return rc; @@ -564,14 +552,14 @@ static int sn_pci_hotplug_init(void) int rc; int registered = 0; - INIT_LIST_HEAD(&sn_hp_list); - if (sn_sal_rev() < SGI_HOTPLUG_PROM_REV) { - printk(KERN_ERR "%s: PROM version must be greater than 4.05\n", + printk(KERN_ERR "%s: PROM version must be greater than 4.30\n", __FUNCTION__); return -EPERM; } + INIT_LIST_HEAD(&sn_hp_list); + while ((pci_bus = pci_find_next_bus(pci_bus))) { if (!pci_bus->sysdata) continue; @@ -584,9 +572,9 @@ static int sn_pci_hotplug_init(void) dev_dbg(pci_bus->self, "valid hotplug bus\n"); rc = sn_hotplug_slot_register(pci_bus); - if (!rc) + if (!rc) { registered = 1; - else { + } else { registered = 0; break; } @@ -599,9 +587,8 @@ static void sn_pci_hotplug_exit(void) { struct hotplug_slot *bss_hotplug_slot; - while ((bss_hotplug_slot = sn_hp_destroy())) { + while ((bss_hotplug_slot = sn_hp_destroy())) pci_hp_deregister(bss_hotplug_slot); - } if (!list_empty(&sn_hp_list)) printk(KERN_ERR "%s: internal list is not empty\n", __FILE__); -- cgit v0.10.2 From 7d333d6c739a5cd6d60102ea1a9940cbbb0546ec Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 23:01:16 +0100 Subject: NTFS: 2.1.24 release and some minor final fixes. Signed-off-by: Anton Altaparmakov diff --git a/Documentation/filesystems/ntfs.txt b/Documentation/filesystems/ntfs.txt index eef4aca..a5fbc8e 100644 --- a/Documentation/filesystems/ntfs.txt +++ b/Documentation/filesystems/ntfs.txt @@ -439,6 +439,18 @@ ChangeLog Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog. +2.1.24: + - Support journals ($LogFile) which have been modified by chkdsk. This + means users can boot into Windows after we marked the volume dirty. + The Windows boot will run chkdsk and then reboot. The user can then + immediately boot into Linux rather than having to do a full Windows + boot first before rebooting into Linux and we will recognize such a + journal and empty it as it is clean by definition. + - Support journals ($LogFile) with only one restart page as well as + journals with two different restart pages. We sanity check both and + either use the only sane one or the more recent one of the two in the + case that both are valid. + - Lots of bug fixes and enhancements across the board. 2.1.23: - Stamp the user space journal, aka transaction log, aka $UsnJrnl, if it is present and active thus telling Windows and applications using diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 32a4150..e4fd613 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -22,7 +22,7 @@ ToDo/Notes: - Enable the code for setting the NT4 compatibility flag when we start making NTFS 1.2 specific modifications. -2.1.24-WIP +2.1.24 - Lots of bug fixes and support more clean journal states. - Support journals ($LogFile) which have been modified by chkdsk. This means users can boot into Windows after we marked the volume dirty. @@ -89,6 +89,8 @@ ToDo/Notes: - In fs/ntfs/aops.c::ntfs_end_buffer_async_read(), use a bit spin lock in the first buffer head instead of a driver global spin lock to improve scalability. + - Minor fix to error handling and error message display in + fs/ntfs/aops.c::ntfs_prepare_nonresident_write(). 2.1.23 - Implement extension of resident files and make writing safe as well as many bug fixes, cleanups, and enhancements... diff --git a/fs/ntfs/Makefile b/fs/ntfs/Makefile index ce970da..894b2b8 100644 --- a/fs/ntfs/Makefile +++ b/fs/ntfs/Makefile @@ -6,7 +6,7 @@ ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \ index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \ unistr.o upcase.o -EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.24-WIP\" +EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.24\" ifeq ($(CONFIG_NTFS_DEBUG),y) EXTRA_CFLAGS += -DDEBUG diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 950b686..5452364 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -1727,27 +1727,25 @@ lock_retry_remap: if (likely(!err)) goto lock_retry_remap; rl = NULL; - lcn = err; } else if (!rl) up_read(&ni->runlist.lock); /* * Failed to map the buffer, even after * retrying. */ + if (!err) + err = -EIO; bh->b_blocknr = -1; ntfs_error(vol->sb, "Failed to write to inode " "0x%lx, attribute type 0x%x, " "vcn 0x%llx, offset 0x%x " "because its location on disk " "could not be determined%s " - "(error code %lli).", + "(error code %i).", ni->mft_no, ni->type, (unsigned long long)vcn, vcn_ofs, is_retry ? " even " - "after retrying" : "", - (long long)lcn); - if (!err) - err = -EIO; + "after retrying" : "", err); goto err_out; } /* We now have a successful remap, i.e. lcn >= 0. */ diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index bf8569d..b2b3929 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c @@ -1688,9 +1688,9 @@ static BOOL load_system_files(ntfs_volume *vol) struct super_block *sb = vol->sb; MFT_RECORD *m; VOLUME_INFORMATION *vi; - RESTART_PAGE_HEADER *rp; ntfs_attr_search_ctx *ctx; #ifdef NTFS_RW + RESTART_PAGE_HEADER *rp; int err; #endif /* NTFS_RW */ -- cgit v0.10.2 From cecf4864cf52a4a243a62b2856a6a155edbb55e8 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 18 Aug 2005 14:33:01 +1000 Subject: [PATCH] PCI: Add pci_walk_bus function to PCI core (nonrecursive) The PCI error recovery infrastructure needs to be able to contact all the drivers affected by a PCI error event, which may mean traversing all the devices under a given PCI-PCI bridge. This patch adds a function to the PCI core that traverses all the PCI devices on a PCI bus and under any PCI-PCI bridges on that bus (and so on), calling a given function for each device. This provides a way for the error recovery code to iterate through all devices that are affected by an error event. This version is not implemented as a recursive function. Instead, when we reach a PCI-PCI bridge, we set the pointers to start doing the devices on the bus under the bridge, and when we reach the end of a bus's devices, we use the bus->self pointer to go back up to the next higher bus and continue doing its devices. Signed-off-by: Paul Mackerras Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index a83ee0b..eed67d9 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -151,6 +151,54 @@ void pci_enable_bridges(struct pci_bus *bus) } } +/** pci_walk_bus - walk devices on/under bus, calling callback. + * @top bus whose devices should be walked + * @cb callback to be called for each device found + * @userdata arbitrary pointer to be passed to callback. + * + * Walk the given bus, including any bridged devices + * on buses under this bus. Call the provided callback + * on each device found. + */ +void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), + void *userdata) +{ + struct pci_dev *dev; + struct pci_bus *bus; + struct list_head *next; + + bus = top; + spin_lock(&pci_bus_lock); + next = top->devices.next; + for (;;) { + if (next == &bus->devices) { + /* end of this bus, go up or finish */ + if (bus == top) + break; + next = bus->self->bus_list.next; + bus = bus->self->bus; + continue; + } + dev = list_entry(next, struct pci_dev, bus_list); + pci_dev_get(dev); + if (dev->subordinate) { + /* this is a pci-pci bridge, do its devices next */ + next = dev->subordinate->devices.next; + bus = dev->subordinate; + } else + next = dev->bus_list.next; + spin_unlock(&pci_bus_lock); + + /* Run device routines with the bus unlocked */ + cb(dev, userdata); + + spin_lock(&pci_bus_lock); + pci_dev_put(dev); + } + spin_unlock(&pci_bus_lock); +} +EXPORT_SYMBOL_GPL(pci_walk_bus); + EXPORT_SYMBOL(pci_bus_alloc_resource); EXPORT_SYMBOL_GPL(pci_bus_add_device); EXPORT_SYMBOL(pci_bus_add_devices); diff --git a/include/linux/pci.h b/include/linux/pci.h index 8878ccf..b0e2447 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -434,6 +434,9 @@ const struct pci_device_id *pci_match_device(struct pci_driver *drv, struct pci_ const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, struct pci_dev *dev); int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass); +void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), + void *userdata); + /* kmem_cache style wrapper around pci_alloc_consistent() */ #include -- cgit v0.10.2 From 3fe9d19f9e86a55679f5f2b38ec0a43a1a510cee Mon Sep 17 00:00:00 2001 From: Daniel Ritz Date: Wed, 17 Aug 2005 15:32:19 -0700 Subject: [PATCH] PCI: Support PCM PM CAP version 3 - support PCI PM CAP version 3 (as defined in PCI PM Interface Spec v1.2) - pci/probe.c sets the PM state initially to 4 which is D3cold. add a PCI_UNKNOWN - minor cleanups Signed-off-by: Daniel Ritz Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 3dcb83d..e179af3 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -294,7 +294,7 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state) return -EIO; pci_read_config_word(dev,pm + PCI_PM_PMC,&pmc); - if ((pmc & PCI_PM_CAP_VER_MASK) > 2) { + if ((pmc & PCI_PM_CAP_VER_MASK) > 3) { printk(KERN_DEBUG "PCI: %s has unsupported PM cap regs version (%u)\n", pci_name(dev), pmc & PCI_PM_CAP_VER_MASK); @@ -302,12 +302,10 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state) } /* check if this device supports the desired state */ - if (state == PCI_D1 || state == PCI_D2) { - if (state == PCI_D1 && !(pmc & PCI_PM_CAP_D1)) - return -EIO; - else if (state == PCI_D2 && !(pmc & PCI_PM_CAP_D2)) - return -EIO; - } + if (state == PCI_D1 && !(pmc & PCI_PM_CAP_D1)) + return -EIO; + else if (state == PCI_D2 && !(pmc & PCI_PM_CAP_D2)) + return -EIO; pci_read_config_word(dev, pm + PCI_PM_CTRL, &pmcsr); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4be1b88..b9c9b03 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -584,7 +584,7 @@ static int pci_setup_device(struct pci_dev * dev) dev->vendor, dev->device, class, dev->hdr_type); /* "Unknown power state" */ - dev->current_state = 4; + dev->current_state = PCI_UNKNOWN; /* Early fixups, before probing the BARs */ pci_fixup_device(pci_fixup_early, dev); diff --git a/include/linux/pci.h b/include/linux/pci.h index b0e2447..7004dde 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -75,6 +75,7 @@ typedef int __bitwise pci_power_t; #define PCI_D2 ((pci_power_t __force) 2) #define PCI_D3hot ((pci_power_t __force) 3) #define PCI_D3cold ((pci_power_t __force) 4) +#define PCI_UNKNOWN ((pci_power_t __force) 5) #define PCI_POWER_ERROR ((pci_power_t __force) -1) /* -- cgit v0.10.2 From a04ce0ffcaf561994ecf382cd3caad75556dc499 Mon Sep 17 00:00:00 2001 From: Brett M Russ Date: Mon, 15 Aug 2005 15:23:41 -0400 Subject: [PATCH] PCI/libata INTx cleanup Simple cleanup to eliminate X copies of the pci_enable_intx() function in libata. Moved ahci.c's pci_intx() to pci.c and use it throughout libata and msi.c. Signed-off-by: Brett Russ Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 532f73b..ee8677b 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -439,10 +439,7 @@ static void enable_msi_mode(struct pci_dev *dev, int pos, int type) } if (pci_find_capability(dev, PCI_CAP_ID_EXP)) { /* PCI Express Endpoint device detected */ - u16 cmd; - pci_read_config_word(dev, PCI_COMMAND, &cmd); - cmd |= PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(dev, PCI_COMMAND, cmd); + pci_intx(dev, 0); /* disable intx */ } } @@ -461,10 +458,7 @@ void disable_msi_mode(struct pci_dev *dev, int pos, int type) } if (pci_find_capability(dev, PCI_CAP_ID_EXP)) { /* PCI Express Endpoint device detected */ - u16 cmd; - pci_read_config_word(dev, PCI_COMMAND, &cmd); - cmd &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(dev, PCI_COMMAND, cmd); + pci_intx(dev, 1); /* enable intx */ } } diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e179af3..ccff633 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -798,6 +798,31 @@ pci_clear_mwi(struct pci_dev *dev) } } +/** + * pci_intx - enables/disables PCI INTx for device dev + * @dev: the PCI device to operate on + * @enable: boolean + * + * Enables/disables PCI INTx for device dev + */ +void +pci_intx(struct pci_dev *pdev, int enable) +{ + u16 pci_command, new; + + pci_read_config_word(pdev, PCI_COMMAND, &pci_command); + + if (enable) { + new = pci_command & ~PCI_COMMAND_INTX_DISABLE; + } else { + new = pci_command | PCI_COMMAND_INTX_DISABLE; + } + + if (new != pci_command) { + pci_write_config_word(pdev, PCI_COMMAND, pci_command); + } +} + #ifndef HAVE_ARCH_PCI_SET_DMA_MASK /* * These can be overridden by arch-specific implementations @@ -875,6 +900,7 @@ EXPORT_SYMBOL(pci_request_region); EXPORT_SYMBOL(pci_set_master); EXPORT_SYMBOL(pci_set_mwi); EXPORT_SYMBOL(pci_clear_mwi); +EXPORT_SYMBOL_GPL(pci_intx); EXPORT_SYMBOL(pci_set_dma_mask); EXPORT_SYMBOL(pci_set_consistent_dma_mask); EXPORT_SYMBOL(pci_assign_resource); diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index 320df6c..c2c8fa8 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c @@ -865,22 +865,6 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent) return 0; } -/* move to PCI layer, integrate w/ MSI stuff */ -static void pci_intx(struct pci_dev *pdev, int enable) -{ - u16 pci_command, new; - - pci_read_config_word(pdev, PCI_COMMAND, &pci_command); - - if (enable) - new = pci_command & ~PCI_COMMAND_INTX_DISABLE; - else - new = pci_command | PCI_COMMAND_INTX_DISABLE; - - if (new != pci_command) - pci_write_config_word(pdev, PCI_COMMAND, pci_command); -} - static void ahci_print_info(struct ata_probe_ent *probe_ent) { struct ahci_host_priv *hpriv = probe_ent->private_data; diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 5f86885..87e0c36 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c @@ -568,18 +568,6 @@ static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev) } } -/* move to PCI layer, integrate w/ MSI stuff */ -static void pci_enable_intx(struct pci_dev *pdev) -{ - u16 pci_command; - - pci_read_config_word(pdev, PCI_COMMAND, &pci_command); - if (pci_command & PCI_COMMAND_INTX_DISABLE) { - pci_command &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(pdev, PCI_COMMAND, pci_command); - } -} - #define AHCI_PCI_BAR 5 #define AHCI_GLOBAL_CTL 0x04 #define AHCI_ENABLE (1 << 31) @@ -677,7 +665,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) * message-signalled interrupts currently). */ if (port_info[0]->host_flags & PIIX_FLAG_CHECKINTR) - pci_enable_intx(pdev); + pci_intx(pdev, 1); if (combined) { port_info[sata_chan] = &piix_port_info[ent->driver_data]; diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c index 7d1aaa9..2bd3f11 100644 --- a/drivers/scsi/sata_sis.c +++ b/drivers/scsi/sata_sis.c @@ -233,18 +233,6 @@ static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) } } -/* move to PCI layer, integrate w/ MSI stuff */ -static void pci_enable_intx(struct pci_dev *pdev) -{ - u16 pci_command; - - pci_read_config_word(pdev, PCI_COMMAND, &pci_command); - if (pci_command & PCI_COMMAND_INTX_DISABLE) { - pci_command &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(pdev, PCI_COMMAND, pci_command); - } -} - static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { struct ata_probe_ent *probe_ent = NULL; @@ -319,7 +307,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) } pci_set_master(pdev); - pci_enable_intx(pdev); + pci_intx(pdev, 1); /* FIXME: check ata_device_add return value */ ata_device_add(probe_ent); diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c index 42e13ed..4c9fb8b 100644 --- a/drivers/scsi/sata_uli.c +++ b/drivers/scsi/sata_uli.c @@ -176,18 +176,6 @@ static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) uli_scr_cfg_write(ap, sc_reg, val); } -/* move to PCI layer, integrate w/ MSI stuff */ -static void pci_enable_intx(struct pci_dev *pdev) -{ - u16 pci_command; - - pci_read_config_word(pdev, PCI_COMMAND, &pci_command); - if (pci_command & PCI_COMMAND_INTX_DISABLE) { - pci_command &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(pdev, PCI_COMMAND, pci_command); - } -} - static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { struct ata_probe_ent *probe_ent; @@ -260,7 +248,7 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) } pci_set_master(pdev); - pci_enable_intx(pdev); + pci_intx(pdev, 1); /* FIXME: check ata_device_add return value */ ata_device_add(probe_ent); diff --git a/include/linux/pci.h b/include/linux/pci.h index 7004dde..6caaba0 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -383,6 +383,7 @@ void pci_set_master(struct pci_dev *dev); #define HAVE_PCI_SET_MWI int pci_set_mwi(struct pci_dev *dev); void pci_clear_mwi(struct pci_dev *dev); +void pci_intx(struct pci_dev *dev, int enable); int pci_set_dma_mask(struct pci_dev *dev, u64 mask); int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); -- cgit v0.10.2 From 7c38cf021b42a4297bc8f860ab627734bdd6c8d1 Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Thu, 8 Sep 2005 23:07:38 +0100 Subject: [ARM] 2890/1: OMAP 1/4: Update omap1 specific files, take 2 Patch from Tony Lindgren This patch syncs the mainline kernel with linux-omap tree. The highlights of the patch are: - Convert more drivers to register resources in board-*.c to take advantage of the driver model by David Brownell and Ladislav Michl - Use set_irq_type() for GPIO interrupts instead of omap_set_gpio_edge_ctrl() by David Brownell - Add minimal support for handling optional add-on boards, such as OSK Mistral board with LCD and keypad, by David Brownell - Minimal support for loading functions to SRAM by Tony Lindgren - Wake up from serial port by muxing RX lines temporarily into GPIO interrupts by Tony Lindgren - 32KHz sched_clock by Tony Lindgren and Juha Yrjola Signed-off-by: Tony Lindgren Signed-off-by: Russell King diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig index 7408ac9..27fc2e8 100644 --- a/arch/arm/mach-omap1/Kconfig +++ b/arch/arm/mach-omap1/Kconfig @@ -47,6 +47,14 @@ config MACH_OMAP_OSK TI OMAP 5912 OSK (OMAP Starter Kit) board support. Say Y here if you have such a board. +config OMAP_OSK_MISTRAL + bool "Mistral QVGA board Support" + depends on MACH_OMAP_OSK + help + The OSK supports an optional add-on board with a Quarter-VGA + touchscreen, PDA-ish buttons, a resume button, bicolor LED, + and camera connector. Say Y here if you have this board. + config MACH_OMAP_PERSEUS2 bool "TI Perseus2" depends on ARCH_OMAP1 && ARCH_OMAP730 diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile index d386fd9..181a93d 100644 --- a/arch/arm/mach-omap1/Makefile +++ b/arch/arm/mach-omap1/Makefile @@ -3,7 +3,7 @@ # # Common support -obj-y := io.o id.o irq.o time.o serial.o +obj-y := io.o id.o irq.o time.o serial.o devices.o led-y := leds.o # Specific board support @@ -23,6 +23,7 @@ endif # LEDs support led-$(CONFIG_MACH_OMAP_H2) += leds-h2p2-debug.o +led-$(CONFIG_MACH_OMAP_H3) += leds-h2p2-debug.o led-$(CONFIG_MACH_OMAP_INNOVATOR) += leds-innovator.o led-$(CONFIG_MACH_OMAP_PERSEUS2) += leds-h2p2-debug.o led-$(CONFIG_MACH_OMAP_OSK) += leds-osk.o diff --git a/arch/arm/mach-omap1/board-generic.c b/arch/arm/mach-omap1/board-generic.c index 122796e..c209c71 100644 --- a/arch/arm/mach-omap1/board-generic.c +++ b/arch/arm/mach-omap1/board-generic.c @@ -48,19 +48,43 @@ static struct omap_usb_config generic1510_usb_config __initdata = { #if defined(CONFIG_ARCH_OMAP16XX) static struct omap_usb_config generic1610_usb_config __initdata = { +#ifdef CONFIG_USB_OTG + .otg = 1, +#endif .register_host = 1, .register_dev = 1, .hmc_mode = 16, .pins[0] = 6, }; + +static struct omap_mmc_config generic_mmc_config __initdata = { + .mmc [0] = { + .enabled = 0, + .wire4 = 0, + .wp_pin = -1, + .power_pin = -1, + .switch_pin = -1, + }, + .mmc [1] = { + .enabled = 0, + .wire4 = 0, + .wp_pin = -1, + .power_pin = -1, + .switch_pin = -1, + }, +}; + #endif static struct omap_board_config_kernel generic_config[] = { { OMAP_TAG_USB, NULL }, + { OMAP_TAG_MMC, &generic_mmc_config }, }; static void __init omap_generic_init(void) { + const struct omap_uart_config *uart_conf; + /* * Make sure the serial ports are muxed on at this point. * You have to mux them off in device drivers later on @@ -76,6 +100,18 @@ static void __init omap_generic_init(void) generic_config[0].data = &generic1610_usb_config; } #endif + + uart_conf = omap_get_config(OMAP_TAG_UART, struct omap_uart_config); + if (uart_conf != NULL) { + unsigned int enabled_ports, i; + + enabled_ports = uart_conf->enabled_uarts; + for (i = 0; i < 3; i++) { + if (!(enabled_ports & (1 << i))) + generic_serial_ports[i] = 0; + } + } + omap_board_config = generic_config; omap_board_config_size = ARRAY_SIZE(generic_config); omap_serial_init(generic_serial_ports); @@ -83,7 +119,7 @@ static void __init omap_generic_init(void) static void __init omap_generic_map_io(void) { - omap_map_common_io() + omap_map_common_io(); } MACHINE_START(OMAP_GENERIC, "Generic OMAP1510/1610/1710") diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c index f4983ee..d46a7006 100644 --- a/arch/arm/mach-omap1/board-h2.c +++ b/arch/arm/mach-omap1/board-h2.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -80,8 +81,7 @@ static struct flash_platform_data h2_flash_data = { }; static struct resource h2_flash_resource = { - .start = OMAP_CS2B_PHYS, - .end = OMAP_CS2B_PHYS + OMAP_CS2B_SIZE - 1, + /* This is on CS3, wherever it's mapped */ .flags = IORESOURCE_MEM, }; @@ -126,10 +126,9 @@ static void __init h2_init_smc91x(void) printk("Error requesting gpio 0 for smc91x irq\n"); return; } - omap_set_gpio_edge_ctrl(0, OMAP_GPIO_FALLING_EDGE); } -void h2_init_irq(void) +static void __init h2_init_irq(void) { omap_init_irq(); omap_gpio_init(); @@ -152,9 +151,13 @@ static struct omap_usb_config h2_usb_config __initdata = { }; static struct omap_mmc_config h2_mmc_config __initdata = { - .mmc_blocks = 1, - .mmc1_power_pin = -1, /* tps65010 gpio3 */ - .mmc1_switch_pin = OMAP_MPUIO(1), + .mmc [0] = { + .enabled = 1, + .wire4 = 1, + .wp_pin = OMAP_MPUIO(3), + .power_pin = -1, /* tps65010 gpio3 */ + .switch_pin = OMAP_MPUIO(1), + }, }; static struct omap_board_config_kernel h2_config[] = { @@ -164,6 +167,16 @@ static struct omap_board_config_kernel h2_config[] = { static void __init h2_init(void) { + /* NOTE: revC boards support NAND-boot, which can put NOR on CS2B + * and NAND (either 16bit or 8bit) on CS3. + */ + h2_flash_resource.end = h2_flash_resource.start = omap_cs3_phys(); + h2_flash_resource.end += SZ_32M - 1; + + /* MMC: card detect and WP */ + // omap_cfg_reg(U19_ARMIO1); /* CD */ + omap_cfg_reg(BALLOUT_V8_ARMIO3); /* WP */ + platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices)); omap_board_config = h2_config; omap_board_config_size = ARRAY_SIZE(h2_config); diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c index 7cd419d..2798613 100644 --- a/arch/arm/mach-omap1/board-h3.c +++ b/arch/arm/mach-omap1/board-h3.c @@ -82,8 +82,7 @@ static struct flash_platform_data h3_flash_data = { }; static struct resource h3_flash_resource = { - .start = OMAP_CS2B_PHYS, - .end = OMAP_CS2B_PHYS + OMAP_CS2B_SIZE - 1, + /* This is on CS3, wherever it's mapped */ .flags = IORESOURCE_MEM, }; @@ -161,13 +160,26 @@ static struct omap_usb_config h3_usb_config __initdata = { .pins[1] = 3, }; +static struct omap_mmc_config h3_mmc_config __initdata = { + .mmc[0] = { + .enabled = 1, + .power_pin = -1, /* tps65010 GPIO4 */ + .switch_pin = OMAP_MPUIO(1), + }, +}; + static struct omap_board_config_kernel h3_config[] = { { OMAP_TAG_USB, &h3_usb_config }, + { OMAP_TAG_MMC, &h3_mmc_config }, }; static void __init h3_init(void) { + h3_flash_resource.end = h3_flash_resource.start = omap_cs3_phys(); + h3_flash_resource.end += OMAP_CS3_SIZE - 1; (void) platform_add_devices(devices, ARRAY_SIZE(devices)); + omap_board_config = h3_config; + omap_board_config_size = ARRAY_SIZE(h3_config); } static void __init h3_init_smc91x(void) @@ -177,7 +189,6 @@ static void __init h3_init_smc91x(void) printk("Error requesting gpio 40 for smc91x irq\n"); return; } - omap_set_gpio_edge_ctrl(40, OMAP_GPIO_FALLING_EDGE); } void h3_init_irq(void) diff --git a/arch/arm/mach-omap1/board-innovator.c b/arch/arm/mach-omap1/board-innovator.c index 91de60a..df0312b 100644 --- a/arch/arm/mach-omap1/board-innovator.c +++ b/arch/arm/mach-omap1/board-innovator.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -173,7 +174,6 @@ static void __init innovator_init_smc91x(void) printk("Error requesting gpio 0 for smc91x irq\n"); return; } - omap_set_gpio_edge_ctrl(0, OMAP_GPIO_RISING_EDGE); } } @@ -220,8 +220,19 @@ static struct omap_usb_config h2_usb_config __initdata = { }; #endif +static struct omap_mmc_config innovator_mmc_config __initdata = { + .mmc [0] = { + .enabled = 1, + .wire4 = 1, + .wp_pin = OMAP_MPUIO(3), + .power_pin = -1, /* FPGA F3 UIO42 */ + .switch_pin = -1, /* FPGA F4 UIO43 */ + }, +}; + static struct omap_board_config_kernel innovator_config[] = { { OMAP_TAG_USB, NULL }, + { OMAP_TAG_MMC, &innovator_mmc_config }, }; static void __init innovator_init(void) diff --git a/arch/arm/mach-omap1/board-netstar.c b/arch/arm/mach-omap1/board-netstar.c index 6750b20..d904e64 100644 --- a/arch/arm/mach-omap1/board-netstar.c +++ b/arch/arm/mach-omap1/board-netstar.c @@ -75,16 +75,15 @@ static void __init netstar_init(void) mdelay(50); /* 50ms until PHY ready */ /* smc91x interrupt pin */ omap_request_gpio(8); - omap_set_gpio_edge_ctrl(8, OMAP_GPIO_RISING_EDGE); omap_request_gpio(12); omap_request_gpio(13); omap_request_gpio(14); omap_request_gpio(15); - omap_set_gpio_edge_ctrl(12, OMAP_GPIO_FALLING_EDGE); - omap_set_gpio_edge_ctrl(13, OMAP_GPIO_FALLING_EDGE); - omap_set_gpio_edge_ctrl(14, OMAP_GPIO_FALLING_EDGE); - omap_set_gpio_edge_ctrl(15, OMAP_GPIO_FALLING_EDGE); + set_irq_type(OMAP_GPIO_IRQ(12), IRQT_FALLING); + set_irq_type(OMAP_GPIO_IRQ(13), IRQT_FALLING); + set_irq_type(OMAP_GPIO_IRQ(14), IRQT_FALLING); + set_irq_type(OMAP_GPIO_IRQ(15), IRQT_FALLING); platform_add_devices(netstar_devices, ARRAY_SIZE(netstar_devices)); diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c index 6844e53..21103df 100644 --- a/arch/arm/mach-omap1/board-osk.c +++ b/arch/arm/mach-omap1/board-osk.c @@ -29,11 +29,16 @@ #include #include #include +#include + +#include +#include #include #include #include #include +#include #include #include @@ -41,12 +46,56 @@ #include #include -static struct map_desc osk5912_io_desc[] __initdata = { -{ OMAP_OSK_NOR_FLASH_BASE, OMAP_OSK_NOR_FLASH_START, OMAP_OSK_NOR_FLASH_SIZE, - MT_DEVICE }, +static int __initdata osk_serial_ports[OMAP_MAX_NR_PORTS] = {1, 0, 0}; + +static struct mtd_partition osk_partitions[] = { + /* bootloader (U-Boot, etc) in first sector */ + { + .name = "bootloader", + .offset = 0, + .size = SZ_128K, + .mask_flags = MTD_WRITEABLE, /* force read-only */ + }, + /* bootloader params in the next sector */ + { + .name = "params", + .offset = MTDPART_OFS_APPEND, + .size = SZ_128K, + .mask_flags = 0, + }, { + .name = "kernel", + .offset = MTDPART_OFS_APPEND, + .size = SZ_2M, + .mask_flags = 0 + }, { + .name = "filesystem", + .offset = MTDPART_OFS_APPEND, + .size = MTDPART_SIZ_FULL, + .mask_flags = 0 + } }; -static int __initdata osk_serial_ports[OMAP_MAX_NR_PORTS] = {1, 0, 0}; +static struct flash_platform_data osk_flash_data = { + .map_name = "cfi_probe", + .width = 2, + .parts = osk_partitions, + .nr_parts = ARRAY_SIZE(osk_partitions), +}; + +static struct resource osk_flash_resource = { + /* this is on CS3, wherever it's mapped */ + .flags = IORESOURCE_MEM, +}; + +static struct platform_device osk5912_flash_device = { + .name = "omapflash", + .id = 0, + .dev = { + .platform_data = &osk_flash_data, + }, + .num_resources = 1, + .resource = &osk_flash_resource, +}; static struct resource osk5912_smc91x_resources[] = { [0] = { @@ -86,9 +135,16 @@ static struct platform_device osk5912_cf_device = { .resource = osk5912_cf_resources, }; +static struct platform_device osk5912_mcbsp1_device = { + .name = "omap_mcbsp", + .id = 1, +}; + static struct platform_device *osk5912_devices[] __initdata = { + &osk5912_flash_device, &osk5912_smc91x_device, &osk5912_cf_device, + &osk5912_mcbsp1_device, }; static void __init osk_init_smc91x(void) @@ -97,7 +153,6 @@ static void __init osk_init_smc91x(void) printk("Error requesting gpio 0 for smc91x irq\n"); return; } - omap_set_gpio_edge_ctrl(0, OMAP_GPIO_RISING_EDGE); /* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */ EMIFS_CCS(1) |= 0x2; @@ -110,11 +165,11 @@ static void __init osk_init_cf(void) printk("Error requesting gpio 62 for CF irq\n"); return; } - /* it's really active-low */ - omap_set_gpio_edge_ctrl(62, OMAP_GPIO_FALLING_EDGE); + /* the CF I/O IRQ is really active-low */ + set_irq_type(OMAP_GPIO_IRQ(62), IRQT_FALLING); } -void osk_init_irq(void) +static void __init osk_init_irq(void) { omap_init_irq(); omap_gpio_init(); @@ -142,18 +197,69 @@ static struct omap_board_config_kernel osk_config[] = { { OMAP_TAG_USB, &osk_usb_config }, }; +#ifdef CONFIG_OMAP_OSK_MISTRAL + +#ifdef CONFIG_PM +static irqreturn_t +osk_mistral_wake_interrupt(int irq, void *ignored, struct pt_regs *regs) +{ + return IRQ_HANDLED; +} +#endif + +static void __init osk_mistral_init(void) +{ + /* FIXME here's where to feed in framebuffer, touchpad, and + * keyboard setup ... not in the drivers for those devices! + * + * NOTE: we could actually tell if there's a Mistral board + * attached, e.g. by trying to read something from the ads7846. + * But this is too early for that... + */ + + /* the sideways button (SW1) is for use as a "wakeup" button */ + omap_cfg_reg(N15_1610_MPUIO2); + if (omap_request_gpio(OMAP_MPUIO(2)) == 0) { + int ret = 0; + omap_set_gpio_direction(OMAP_MPUIO(2), 1); + set_irq_type(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), IRQT_RISING); +#ifdef CONFIG_PM + /* share the IRQ in case someone wants to use the + * button for more than wakeup from system sleep. + */ + ret = request_irq(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), + &osk_mistral_wake_interrupt, + SA_SHIRQ, "mistral_wakeup", + &osk_mistral_wake_interrupt); + if (ret != 0) { + omap_free_gpio(OMAP_MPUIO(2)); + printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n", + ret); + } else + enable_irq_wake(OMAP_GPIO_IRQ(OMAP_MPUIO(2))); +#endif + } else + printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n"); +} +#else +static void __init osk_mistral_init(void) { } +#endif + static void __init osk_init(void) { + osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys(); + osk_flash_resource.end += SZ_32M - 1; platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices)); omap_board_config = osk_config; omap_board_config_size = ARRAY_SIZE(osk_config); USB_TRANSCEIVER_CTRL_REG |= (3 << 1); + + osk_mistral_init(); } static void __init osk_map_io(void) { omap_map_common_io(); - iotable_init(osk5912_io_desc, ARRAY_SIZE(osk5912_io_desc)); omap_serial_init(osk_serial_ports); } diff --git a/arch/arm/mach-omap1/board-perseus2.c b/arch/arm/mach-omap1/board-perseus2.c index 2133173..107c68c 100644 --- a/arch/arm/mach-omap1/board-perseus2.c +++ b/arch/arm/mach-omap1/board-perseus2.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -83,8 +84,8 @@ static struct flash_platform_data p2_flash_data = { }; static struct resource p2_flash_resource = { - .start = OMAP_FLASH_0_START, - .end = OMAP_FLASH_0_START + OMAP_FLASH_0_SIZE - 1, + .start = OMAP_CS0_PHYS, + .end = OMAP_CS0_PHYS + SZ_32M - 1, .flags = IORESOURCE_MEM, }; diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c index e4228198..209d79e 100644 --- a/arch/arm/mach-omap1/board-voiceblue.c +++ b/arch/arm/mach-omap1/board-voiceblue.c @@ -25,13 +25,14 @@ #include #include #include +#include #include +#include #include -#include #include +#include #include -#include extern void omap_init_time(void); extern int omap_gpio_init(void); @@ -86,6 +87,27 @@ static int __init ext_uart_init(void) } arch_initcall(ext_uart_init); +static struct flash_platform_data voiceblue_flash_data = { + .map_name = "cfi_probe", + .width = 2, +}; + +static struct resource voiceblue_flash_resource = { + .start = OMAP_CS0_PHYS, + .end = OMAP_CS0_PHYS + SZ_32M - 1, + .flags = IORESOURCE_MEM, +}; + +static struct platform_device voiceblue_flash_device = { + .name = "omapflash", + .id = 0, + .dev = { + .platform_data = &voiceblue_flash_data, + }, + .num_resources = 1, + .resource = &voiceblue_flash_resource, +}; + static struct resource voiceblue_smc91x_resources[] = { [0] = { .start = OMAP_CS2_PHYS + 0x300, @@ -107,6 +129,7 @@ static struct platform_device voiceblue_smc91x_device = { }; static struct platform_device *voiceblue_devices[] __initdata = { + &voiceblue_flash_device, &voiceblue_smc91x_device, }; @@ -119,8 +142,17 @@ static struct omap_usb_config voiceblue_usb_config __initdata = { .pins[2] = 6, }; +static struct omap_mmc_config voiceblue_mmc_config __initdata = { + .mmc[0] = { + .enabled = 1, + .power_pin = 2, + .switch_pin = -1, + }, +}; + static struct omap_board_config_kernel voiceblue_config[] = { { OMAP_TAG_USB, &voiceblue_usb_config }, + { OMAP_TAG_MMC, &voiceblue_mmc_config }, }; static void __init voiceblue_init_irq(void) @@ -131,9 +163,6 @@ static void __init voiceblue_init_irq(void) static void __init voiceblue_init(void) { - /* There is a good chance board is going up, so enable Power LED - * (it is connected through invertor) */ - omap_writeb(0x00, OMAP_LPG1_LCR); /* Watchdog */ omap_request_gpio(0); /* smc91x reset */ @@ -145,7 +174,6 @@ static void __init voiceblue_init(void) mdelay(50); /* 50ms until PHY ready */ /* smc91x interrupt pin */ omap_request_gpio(8); - omap_set_gpio_edge_ctrl(8, OMAP_GPIO_RISING_EDGE); /* 16C554 reset*/ omap_request_gpio(6); omap_set_gpio_direction(6, 0); @@ -155,14 +183,19 @@ static void __init voiceblue_init(void) omap_request_gpio(13); omap_request_gpio(14); omap_request_gpio(15); - omap_set_gpio_edge_ctrl(12, OMAP_GPIO_RISING_EDGE); - omap_set_gpio_edge_ctrl(13, OMAP_GPIO_RISING_EDGE); - omap_set_gpio_edge_ctrl(14, OMAP_GPIO_RISING_EDGE); - omap_set_gpio_edge_ctrl(15, OMAP_GPIO_RISING_EDGE); + set_irq_type(OMAP_GPIO_IRQ(12), IRQT_RISING); + set_irq_type(OMAP_GPIO_IRQ(13), IRQT_RISING); + set_irq_type(OMAP_GPIO_IRQ(14), IRQT_RISING); + set_irq_type(OMAP_GPIO_IRQ(15), IRQT_RISING); platform_add_devices(voiceblue_devices, ARRAY_SIZE(voiceblue_devices)); omap_board_config = voiceblue_config; omap_board_config_size = ARRAY_SIZE(voiceblue_config); + + /* There is a good chance board is going up, so enable power LED + * (it is connected through invertor) */ + omap_writeb(0x00, OMAP_LPG1_LCR); + omap_writeb(0x00, OMAP_LPG1_PMR); /* Disable clock */ } static int __initdata omap_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1}; @@ -184,9 +217,9 @@ static int panic_event(struct notifier_block *this, unsigned long event, if (test_and_set_bit(MACHINE_PANICED, &machine_state)) return NOTIFY_DONE; - /* Flash Power LED - * (TODO: Enable clock right way (enabled in bootloader already)) */ + /* Flash power LED */ omap_writeb(0x78, OMAP_LPG1_LCR); + omap_writeb(0x01, OMAP_LPG1_PMR); /* Enable clock */ return NOTIFY_DONE; } @@ -195,15 +228,14 @@ static struct notifier_block panic_block = { .notifier_call = panic_event, }; -static int __init setup_notifier(void) +static int __init voiceblue_setup(void) { /* Setup panic notifier */ notifier_chain_register(&panic_notifier_list, &panic_block); return 0; } - -postcore_initcall(setup_notifier); +postcore_initcall(voiceblue_setup); static int wdt_gpio_state; diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c new file mode 100644 index 0000000..e8b3981 --- /dev/null +++ b/arch/arm/mach-omap1/devices.c @@ -0,0 +1,351 @@ +/* + * linux/arch/arm/mach-omap1/devices.c + * + * OMAP1 platform device setup/initialization + * + * 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. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + + +static void omap_nop_release(struct device *dev) +{ + /* Nothing */ +} + +/*-------------------------------------------------------------------------*/ + +#if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE) + +#define OMAP_I2C_BASE 0xfffb3800 + +static struct resource i2c_resources[] = { + { + .start = OMAP_I2C_BASE, + .end = OMAP_I2C_BASE + 0x3f, + .flags = IORESOURCE_MEM, + }, + { + .start = INT_I2C, + .flags = IORESOURCE_IRQ, + }, +}; + +/* DMA not used; works around erratum writing to non-empty i2c fifo */ + +static struct platform_device omap_i2c_device = { + .name = "i2c_omap", + .id = -1, + .dev = { + .release = omap_nop_release, + }, + .num_resources = ARRAY_SIZE(i2c_resources), + .resource = i2c_resources, +}; + +static void omap_init_i2c(void) +{ + /* FIXME define and use a boot tag, in case of boards that + * either don't wire up I2C, or chips that mux it differently... + * it can include clocking and address info, maybe more. + */ + omap_cfg_reg(I2C_SCL); + omap_cfg_reg(I2C_SDA); + + (void) platform_device_register(&omap_i2c_device); +} +#else +static inline void omap_init_i2c(void) {} +#endif + +/*-------------------------------------------------------------------------*/ + +#if defined(CONFIG_OMAP1610_IR) || defined(CONFIG_OMAP161O_IR_MODULE) + +static u64 irda_dmamask = 0xffffffff; + +static struct platform_device omap1610ir_device = { + .name = "omap1610-ir", + .id = -1, + .dev = { + .release = omap_nop_release, + .dma_mask = &irda_dmamask, + }, +}; + +static void omap_init_irda(void) +{ + /* FIXME define and use a boot tag, members something like: + * u8 uart; // uart1, or uart3 + * ... but driver only handles uart3 for now + * s16 fir_sel; // gpio for SIR vs FIR + * ... may prefer a callback for SIR/MIR/FIR mode select; + * while h2 uses a GPIO, H3 uses a gpio expander + */ + if (machine_is_omap_h2() + || machine_is_omap_h3()) + (void) platform_device_register(&omap1610ir_device); +} +#else +static inline void omap_init_irda(void) {} +#endif + +/*-------------------------------------------------------------------------*/ + +#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) + +#define OMAP_MMC1_BASE 0xfffb7800 +#define OMAP_MMC2_BASE 0xfffb7c00 /* omap16xx only */ + +static struct omap_mmc_conf mmc1_conf; + +static u64 mmc1_dmamask = 0xffffffff; + +static struct resource mmc1_resources[] = { + { + .start = IO_ADDRESS(OMAP_MMC1_BASE), + .end = IO_ADDRESS(OMAP_MMC1_BASE) + 0x7f, + .flags = IORESOURCE_MEM, + }, + { + .start = INT_MMC, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct platform_device mmc_omap_device1 = { + .name = "mmci-omap", + .id = 1, + .dev = { + .release = omap_nop_release, + .dma_mask = &mmc1_dmamask, + .platform_data = &mmc1_conf, + }, + .num_resources = ARRAY_SIZE(mmc1_resources), + .resource = mmc1_resources, +}; + +#ifdef CONFIG_ARCH_OMAP16XX + +static struct omap_mmc_conf mmc2_conf; + +static u64 mmc2_dmamask = 0xffffffff; + +static struct resource mmc2_resources[] = { + { + .start = IO_ADDRESS(OMAP_MMC2_BASE), + .end = IO_ADDRESS(OMAP_MMC2_BASE) + 0x7f, + .flags = IORESOURCE_MEM, + }, + { + .start = INT_1610_MMC2, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct platform_device mmc_omap_device2 = { + .name = "mmci-omap", + .id = 2, + .dev = { + .release = omap_nop_release, + .dma_mask = &mmc2_dmamask, + .platform_data = &mmc2_conf, + }, + .num_resources = ARRAY_SIZE(mmc2_resources), + .resource = mmc2_resources, +}; +#endif + +static void __init omap_init_mmc(void) +{ + const struct omap_mmc_config *mmc_conf; + const struct omap_mmc_conf *mmc; + + /* NOTE: assumes MMC was never (wrongly) enabled */ + mmc_conf = omap_get_config(OMAP_TAG_MMC, struct omap_mmc_config); + if (!mmc_conf) + return; + + /* block 1 is always available and has just one pinout option */ + mmc = &mmc_conf->mmc[0]; + if (mmc->enabled) { + omap_cfg_reg(MMC_CMD); + omap_cfg_reg(MMC_CLK); + omap_cfg_reg(MMC_DAT0); + if (cpu_is_omap1710()) { + omap_cfg_reg(M15_1710_MMC_CLKI); + omap_cfg_reg(P19_1710_MMC_CMDDIR); + omap_cfg_reg(P20_1710_MMC_DATDIR0); + } + if (mmc->wire4) { + omap_cfg_reg(MMC_DAT1); + /* NOTE: DAT2 can be on W10 (here) or M15 */ + if (!mmc->nomux) + omap_cfg_reg(MMC_DAT2); + omap_cfg_reg(MMC_DAT3); + } + mmc1_conf = *mmc; + (void) platform_device_register(&mmc_omap_device1); + } + +#ifdef CONFIG_ARCH_OMAP16XX + /* block 2 is on newer chips, and has many pinout options */ + mmc = &mmc_conf->mmc[1]; + if (mmc->enabled) { + if (!mmc->nomux) { + omap_cfg_reg(Y8_1610_MMC2_CMD); + omap_cfg_reg(Y10_1610_MMC2_CLK); + omap_cfg_reg(R18_1610_MMC2_CLKIN); + omap_cfg_reg(W8_1610_MMC2_DAT0); + if (mmc->wire4) { + omap_cfg_reg(V8_1610_MMC2_DAT1); + omap_cfg_reg(W15_1610_MMC2_DAT2); + omap_cfg_reg(R10_1610_MMC2_DAT3); + } + + /* These are needed for the level shifter */ + omap_cfg_reg(V9_1610_MMC2_CMDDIR); + omap_cfg_reg(V5_1610_MMC2_DATDIR0); + omap_cfg_reg(W19_1610_MMC2_DATDIR1); + } + + /* Feedback clock must be set on OMAP-1710 MMC2 */ + if (cpu_is_omap1710()) + omap_writel(omap_readl(MOD_CONF_CTRL_1) | (1 << 24), + MOD_CONF_CTRL_1); + mmc2_conf = *mmc; + (void) platform_device_register(&mmc_omap_device2); + } +#endif + return; +} +#else +static inline void omap_init_mmc(void) {} +#endif + +#if defined(CONFIG_OMAP_RTC) || defined(CONFIG_OMAP_RTC) + +#define OMAP_RTC_BASE 0xfffb4800 + +static struct resource rtc_resources[] = { + { + .start = OMAP_RTC_BASE, + .end = OMAP_RTC_BASE + 0x5f, + .flags = IORESOURCE_MEM, + }, + { + .start = INT_RTC_TIMER, + .flags = IORESOURCE_IRQ, + }, + { + .start = INT_RTC_ALARM, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct platform_device omap_rtc_device = { + .name = "omap_rtc", + .id = -1, + .dev = { + .release = omap_nop_release, + }, + .num_resources = ARRAY_SIZE(rtc_resources), + .resource = rtc_resources, +}; + +static void omap_init_rtc(void) +{ + (void) platform_device_register(&omap_rtc_device); +} +#else +static inline void omap_init_rtc(void) {} +#endif + +/*-------------------------------------------------------------------------*/ + +#if defined(CONFIG_OMAP16XX_WATCHDOG) || defined(CONFIG_OMAP16XX_WATCHDOG_MODULE) + +#define OMAP_WDT_BASE 0xfffeb000 + +static struct resource wdt_resources[] = { + { + .start = OMAP_WDT_BASE, + .end = OMAP_WDT_BASE + 0x4f, + .flags = IORESOURCE_MEM, + }, +}; + +static struct platform_device omap_wdt_device = { + .name = "omap1610_wdt", + .id = -1, + .dev = { + .release = omap_nop_release, + }, + .num_resources = ARRAY_SIZE(wdt_resources), + .resource = wdt_resources, +}; + +static void omap_init_wdt(void) +{ + (void) platform_device_register(&omap_wdt_device); +} +#else +static inline void omap_init_wdt(void) {} +#endif + + +/*-------------------------------------------------------------------------*/ + +/* + * This gets called after board-specific INIT_MACHINE, and initializes most + * on-chip peripherals accessible on this board (except for few like USB): + * + * (a) Does any "standard config" pin muxing needed. Board-specific + * code will have muxed GPIO pins and done "nonstandard" setup; + * that code could live in the boot loader. + * (b) Populating board-specific platform_data with the data drivers + * rely on to handle wiring variations. + * (c) Creating platform devices as meaningful on this board and + * with this kernel configuration. + * + * Claiming GPIOs, and setting their direction and initial values, is the + * responsibility of the device drivers. So is responding to probe(). + * + * Board-specific knowlege like creating devices or pin setup is to be + * kept out of drivers as much as possible. In particular, pin setup + * may be handled by the boot loader, and drivers should expect it will + * normally have been done by the time they're probed. + */ +static int __init omap_init_devices(void) +{ + /* please keep these calls, and their implementations above, + * in alphabetical order so they're easier to sort through. + */ + omap_init_i2c(); + omap_init_irda(); + omap_init_mmc(); + omap_init_rtc(); + omap_init_wdt(); + + return 0; +} +arch_initcall(omap_init_devices); + diff --git a/arch/arm/mach-omap1/fpga.c b/arch/arm/mach-omap1/fpga.c index c12a783..aca2a12 100644 --- a/arch/arm/mach-omap1/fpga.c +++ b/arch/arm/mach-omap1/fpga.c @@ -1,5 +1,5 @@ /* - * linux/arch/arm/mach-omap/fpga.c + * linux/arch/arm/mach-omap1/fpga.c * * Interrupt handler for OMAP-1510 Innovator FPGA * @@ -181,7 +181,7 @@ void omap1510_fpga_init_irq(void) */ omap_request_gpio(13); omap_set_gpio_direction(13, 1); - omap_set_gpio_edge_ctrl(13, OMAP_GPIO_RISING_EDGE); + set_irq_type(OMAP_GPIO_IRQ(13), IRQT_RISING); set_irq_chained_handler(OMAP1510_INT_FPGA, innovator_fpga_IRQ_demux); } diff --git a/arch/arm/mach-omap1/io.c b/arch/arm/mach-omap1/io.c index 207df0f..eb8261d 100644 --- a/arch/arm/mach-omap1/io.c +++ b/arch/arm/mach-omap1/io.c @@ -19,6 +19,7 @@ extern int clk_init(void); extern void omap_check_revision(void); +extern void omap_sram_init(void); /* * The machine specific code may provide the extra mapping besides the @@ -32,7 +33,6 @@ static struct map_desc omap_io_desc[] __initdata = { static struct map_desc omap730_io_desc[] __initdata = { { OMAP730_DSP_BASE, OMAP730_DSP_START, OMAP730_DSP_SIZE, MT_DEVICE }, { OMAP730_DSPREG_BASE, OMAP730_DSPREG_START, OMAP730_DSPREG_SIZE, MT_DEVICE }, - { OMAP730_SRAM_BASE, OMAP730_SRAM_START, OMAP730_SRAM_SIZE, MT_DEVICE } }; #endif @@ -40,27 +40,13 @@ static struct map_desc omap730_io_desc[] __initdata = { static struct map_desc omap1510_io_desc[] __initdata = { { OMAP1510_DSP_BASE, OMAP1510_DSP_START, OMAP1510_DSP_SIZE, MT_DEVICE }, { OMAP1510_DSPREG_BASE, OMAP1510_DSPREG_START, OMAP1510_DSPREG_SIZE, MT_DEVICE }, - { OMAP1510_SRAM_BASE, OMAP1510_SRAM_START, OMAP1510_SRAM_SIZE, MT_DEVICE } }; #endif #if defined(CONFIG_ARCH_OMAP16XX) -static struct map_desc omap1610_io_desc[] __initdata = { +static struct map_desc omap16xx_io_desc[] __initdata = { { OMAP16XX_DSP_BASE, OMAP16XX_DSP_START, OMAP16XX_DSP_SIZE, MT_DEVICE }, { OMAP16XX_DSPREG_BASE, OMAP16XX_DSPREG_START, OMAP16XX_DSPREG_SIZE, MT_DEVICE }, - { OMAP16XX_SRAM_BASE, OMAP16XX_SRAM_START, OMAP1610_SRAM_SIZE, MT_DEVICE } -}; - -static struct map_desc omap5912_io_desc[] __initdata = { - { OMAP16XX_DSP_BASE, OMAP16XX_DSP_START, OMAP16XX_DSP_SIZE, MT_DEVICE }, - { OMAP16XX_DSPREG_BASE, OMAP16XX_DSPREG_START, OMAP16XX_DSPREG_SIZE, MT_DEVICE }, -/* - * The OMAP5912 has 250kByte internal SRAM. Because the mapping is baseed on page - * size (4kByte), it seems that the last 2kByte (=0x800) of the 250kByte are not mapped. - * Add additional 2kByte (0x800) so that the last page is mapped and the last 2kByte - * can be used. - */ - { OMAP16XX_SRAM_BASE, OMAP16XX_SRAM_START, OMAP5912_SRAM_SIZE + 0x800, MT_DEVICE } }; #endif @@ -86,14 +72,13 @@ static void __init _omap_map_io(void) } #endif #if defined(CONFIG_ARCH_OMAP16XX) - if (cpu_is_omap1610() || cpu_is_omap1710()) { - iotable_init(omap1610_io_desc, ARRAY_SIZE(omap1610_io_desc)); - } - if (cpu_is_omap5912()) { - iotable_init(omap5912_io_desc, ARRAY_SIZE(omap5912_io_desc)); + if (cpu_is_omap16xx()) { + iotable_init(omap16xx_io_desc, ARRAY_SIZE(omap16xx_io_desc)); } #endif + omap_sram_init(); + /* REVISIT: Refer to OMAP5910 Errata, Advisory SYS_1: "Timeout Abort * on a Posted Write in the TIPB Bridge". */ @@ -108,8 +93,9 @@ static void __init _omap_map_io(void) /* * This should only get called from board specific init */ -void omap_map_common_io(void) +void __init omap_map_common_io(void) { if (!initialized) _omap_map_io(); } + diff --git a/arch/arm/mach-omap1/irq.c b/arch/arm/mach-omap1/irq.c index afd5d67..192ce60 100644 --- a/arch/arm/mach-omap1/irq.c +++ b/arch/arm/mach-omap1/irq.c @@ -1,5 +1,5 @@ /* - * linux/arch/arm/mach-omap/irq.c + * linux/arch/arm/mach-omap1/irq.c * * Interrupt handler for all OMAP boards * diff --git a/arch/arm/mach-omap1/leds-h2p2-debug.c b/arch/arm/mach-omap1/leds-h2p2-debug.c index ec0d828..be283cd 100644 --- a/arch/arm/mach-omap1/leds-h2p2-debug.c +++ b/arch/arm/mach-omap1/leds-h2p2-debug.c @@ -1,5 +1,5 @@ /* - * linux/arch/arm/mach-omap/leds-h2p2-debug.c + * linux/arch/arm/mach-omap1/leds-h2p2-debug.c * * Copyright 2003 by Texas Instruments Incorporated * @@ -13,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/arch/arm/mach-omap1/leds-innovator.c b/arch/arm/mach-omap1/leds-innovator.c index 8043b7d..c8ffd1d 100644 --- a/arch/arm/mach-omap1/leds-innovator.c +++ b/arch/arm/mach-omap1/leds-innovator.c @@ -1,5 +1,5 @@ /* - * linux/arch/arm/mach-omap/leds-innovator.c + * linux/arch/arm/mach-omap1/leds-innovator.c */ #include #include diff --git a/arch/arm/mach-omap1/leds-osk.c b/arch/arm/mach-omap1/leds-osk.c index 4a0e8b9..2c8bda8 100644 --- a/arch/arm/mach-omap1/leds-osk.c +++ b/arch/arm/mach-omap1/leds-osk.c @@ -1,5 +1,5 @@ /* - * linux/arch/arm/mach-omap/leds-osk.c + * linux/arch/arm/mach-omap1/leds-osk.c * * LED driver for OSK, and optionally Mistral QVGA, boards */ @@ -64,7 +64,7 @@ static void tps_work(void *unused) static DECLARE_WORK(work, tps_work, NULL); -#ifdef CONFIG_FB_OMAP +#ifdef CONFIG_OMAP_OSK_MISTRAL /* For now, all system indicators require the Mistral board, since that * LED can be manipulated without a task context. This LED is either red, @@ -127,7 +127,7 @@ void osk_leds_event(led_event_t evt) hw_led_state = 0; break; -#ifdef CONFIG_FB_OMAP +#ifdef CONFIG_OMAP_OSK_MISTRAL case led_timer: hw_led_state ^= TIMER_LED; @@ -144,7 +144,7 @@ void osk_leds_event(led_event_t evt) mistral_setled(); break; -#endif /* CONFIG_FB_OMAP */ +#endif /* CONFIG_OMAP_OSK_MISTRAL */ /* "green" == tps LED1 (leftmost, normally power-good) * works only with DC adapter, not on battery power! diff --git a/arch/arm/mach-omap1/leds.c b/arch/arm/mach-omap1/leds.c index 8ab21fe..5c6b1bb 100644 --- a/arch/arm/mach-omap1/leds.c +++ b/arch/arm/mach-omap1/leds.c @@ -1,5 +1,5 @@ /* - * linux/arch/arm/mach-omap/leds.c + * linux/arch/arm/mach-omap1/leds.c * * OMAP LEDs dispatcher */ @@ -20,7 +20,9 @@ omap_leds_init(void) if (machine_is_omap_innovator()) leds_event = innovator_leds_event; - else if (machine_is_omap_h2() || machine_is_omap_perseus2()) + else if (machine_is_omap_h2() + || machine_is_omap_h3() + || machine_is_omap_perseus2()) leds_event = h2p2_dbg_leds_event; else if (machine_is_omap_osk()) @@ -30,8 +32,12 @@ omap_leds_init(void) return -1; if (machine_is_omap_h2() + || machine_is_omap_h3() || machine_is_omap_perseus2() - || machine_is_omap_osk()) { +#ifdef CONFIG_OMAP_OSK_MISTRAL + || machine_is_omap_osk() +#endif + ) { /* LED1/LED2 pins can be used as GPIO (as done here), or by * the LPG (works even in deep sleep!), to drive a bicolor diff --git a/arch/arm/mach-omap1/serial.c b/arch/arm/mach-omap1/serial.c index 214e5d1..e702e0c 100644 --- a/arch/arm/mach-omap1/serial.c +++ b/arch/arm/mach-omap1/serial.c @@ -24,7 +24,11 @@ #include #include +#include #include +#ifdef CONFIG_PM +#include +#endif static struct clk * uart1_ck = NULL; static struct clk * uart2_ck = NULL; @@ -193,6 +197,86 @@ void __init omap_serial_init(int ports[OMAP_MAX_NR_PORTS]) } } +#ifdef CONFIG_OMAP_SERIAL_WAKE + +static irqreturn_t omap_serial_wake_interrupt(int irq, void *dev_id, + struct pt_regs *regs) +{ + /* Need to do something with serial port right after wake-up? */ + return IRQ_HANDLED; +} + +/* + * Reroutes serial RX lines to GPIO lines for the duration of + * sleep to allow waking up the device from serial port even + * in deep sleep. + */ +void omap_serial_wake_trigger(int enable) +{ + if (!cpu_is_omap16xx()) + return; + + if (uart1_ck != NULL) { + if (enable) + omap_cfg_reg(V14_16XX_GPIO37); + else + omap_cfg_reg(V14_16XX_UART1_RX); + } + if (uart2_ck != NULL) { + if (enable) + omap_cfg_reg(R9_16XX_GPIO18); + else + omap_cfg_reg(R9_16XX_UART2_RX); + } + if (uart3_ck != NULL) { + if (enable) + omap_cfg_reg(L14_16XX_GPIO49); + else + omap_cfg_reg(L14_16XX_UART3_RX); + } +} + +static void __init omap_serial_set_port_wakeup(int gpio_nr) +{ + int ret; + + ret = omap_request_gpio(gpio_nr); + if (ret < 0) { + printk(KERN_ERR "Could not request UART wake GPIO: %i\n", + gpio_nr); + return; + } + omap_set_gpio_direction(gpio_nr, 1); + set_irq_type(OMAP_GPIO_IRQ(gpio_nr), IRQT_RISING); + ret = request_irq(OMAP_GPIO_IRQ(gpio_nr), &omap_serial_wake_interrupt, + 0, "serial wakeup", NULL); + if (ret) { + omap_free_gpio(gpio_nr); + printk(KERN_ERR "No interrupt for UART wake GPIO: %i\n", + gpio_nr); + return; + } + enable_irq_wake(OMAP_GPIO_IRQ(gpio_nr)); +} + +static int __init omap_serial_wakeup_init(void) +{ + if (!cpu_is_omap16xx()) + return 0; + + if (uart1_ck != NULL) + omap_serial_set_port_wakeup(37); + if (uart2_ck != NULL) + omap_serial_set_port_wakeup(18); + if (uart3_ck != NULL) + omap_serial_set_port_wakeup(49); + + return 0; +} +late_initcall(omap_serial_wakeup_init); + +#endif /* CONFIG_OMAP_SERIAL_WAKE */ + static int __init omap_init(void) { return platform_device_register(&serial_device); diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c index d540539..191a9b1 100644 --- a/arch/arm/mach-omap1/time.c +++ b/arch/arm/mach-omap1/time.c @@ -247,13 +247,6 @@ unsigned long long sched_clock(void) #define OMAP_32K_TIMER_TCR 0x04 #define OMAP_32K_TICKS_PER_HZ (32768 / HZ) -#if (32768 % HZ) != 0 -/* We cannot ignore modulo. - * Potential error can be as high as several percent. - */ -#define OMAP_32K_TICK_MODULO (32768 % HZ) -static unsigned modulo_count = 0; /* Counts 1/HZ units */ -#endif /* * TRM says 1 / HZ = ( TVR + 1) / 32768, so TRV = (32768 / HZ) - 1 @@ -296,13 +289,22 @@ static inline void omap_32k_timer_stop(void) } /* - * Rounds down to nearest usec + * Rounds down to nearest usec. Note that this will overflow for larger values. */ static inline unsigned long omap_32k_ticks_to_usecs(unsigned long ticks_32k) { return (ticks_32k * 5*5*5*5*5*5) >> 9; } +/* + * Rounds down to nearest nsec. + */ +static inline unsigned long long +omap_32k_ticks_to_nsecs(unsigned long ticks_32k) +{ + return (unsigned long long) ticks_32k * 1000 * 5*5*5*5*5*5 >> 9; +} + static unsigned long omap_32k_last_tick = 0; /* @@ -315,6 +317,15 @@ static unsigned long omap_32k_timer_gettimeoffset(void) } /* + * Returns current time from boot in nsecs. It's OK for this to wrap + * around for now, as it's just a relative time stamp. + */ +unsigned long long sched_clock(void) +{ + return omap_32k_ticks_to_nsecs(omap_32k_sync_timer_read()); +} + +/* * Timer interrupt for 32KHz timer. When dynamic tick is enabled, this * function is also called from other interrupts to remove latency * issues with dynamic tick. In the dynamic tick case, we need to lock @@ -330,19 +341,6 @@ static irqreturn_t omap_32k_timer_interrupt(int irq, void *dev_id, now = omap_32k_sync_timer_read(); while (now - omap_32k_last_tick >= OMAP_32K_TICKS_PER_HZ) { -#ifdef OMAP_32K_TICK_MODULO - /* Modulo addition may put omap_32k_last_tick ahead of now - * and cause unwanted repetition of the while loop. - */ - if (unlikely(now - omap_32k_last_tick == ~0)) - break; - - modulo_count += OMAP_32K_TICK_MODULO; - if (modulo_count > HZ) { - ++omap_32k_last_tick; - modulo_count -= HZ; - } -#endif omap_32k_last_tick += OMAP_32K_TICKS_PER_HZ; timer_tick(regs); } -- cgit v0.10.2 From 0dffefbf1a26ee0661d47516420d86b485a08e9c Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Thu, 8 Sep 2005 23:07:39 +0100 Subject: [ARM] 2891/1: S3C2410 - update s3c2410_defconfig for 2.6.13 Patch from Ben Dooks Updated the s3c2410_defconfig for the 2.6.13-git8 kernel release, as well as adding the Anubis board to the list of boards built. Signed-off-by: Ben Dooks Signed-off-by: Russell King diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig index 96a794d..756348b 100644 --- a/arch/arm/configs/s3c2410_defconfig +++ b/arch/arm/configs/s3c2410_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Linux kernel version: 2.6.12-git4 -# Wed Jun 22 15:56:42 2005 +# Linux kernel version: 2.6.13-git8 +# Thu Sep 8 19:24:02 2005 # CONFIG_ARM=y CONFIG_MMU=y @@ -22,6 +22,7 @@ CONFIG_INIT_ENV_ARG_LIMIT=32 # General setup # CONFIG_LOCALVERSION="" +CONFIG_LOCALVERSION_AUTO=y CONFIG_SWAP=y CONFIG_SYSVIPC=y # CONFIG_POSIX_MQUEUE is not set @@ -31,6 +32,7 @@ CONFIG_SYSCTL=y # CONFIG_HOTPLUG is not set CONFIG_KOBJECT_UEVENT=y # CONFIG_IKCONFIG is not set +CONFIG_INITRAMFS_SOURCE="" # CONFIG_EMBEDDED is not set CONFIG_KALLSYMS=y # CONFIG_KALLSYMS_ALL is not set @@ -88,7 +90,9 @@ CONFIG_ARCH_S3C2410=y # # S3C24XX Implementations # +CONFIG_MACH_ANUBIS=y CONFIG_ARCH_BAST=y +CONFIG_BAST_PC104_IRQ=y CONFIG_ARCH_H1940=y CONFIG_MACH_N30=y CONFIG_ARCH_SMDK2410=y @@ -112,6 +116,7 @@ CONFIG_S3C2410_DMA=y # CONFIG_S3C2410_DMA_DEBUG is not set # CONFIG_S3C2410_PM_DEBUG is not set # CONFIG_S3C2410_PM_CHECK is not set +CONFIG_PM_SIMTEC=y CONFIG_S3C2410_LOWLEVEL_UART_PORT=0 # @@ -149,7 +154,15 @@ CONFIG_ISA_DMA_API=y # # CONFIG_SMP is not set # CONFIG_PREEMPT is not set -# CONFIG_DISCONTIGMEM is not set +# CONFIG_NO_IDLE_HZ is not set +# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_FLATMEM_MANUAL=y +# CONFIG_DISCONTIGMEM_MANUAL is not set +# CONFIG_SPARSEMEM_MANUAL is not set +CONFIG_FLATMEM=y +CONFIG_FLAT_NODE_MEM_MAP=y +# CONFIG_SPARSEMEM_STATIC is not set CONFIG_ALIGNMENT_TRAP=y # @@ -186,6 +199,74 @@ CONFIG_PM=y CONFIG_APM=y # +# Networking +# +CONFIG_NET=y + +# +# Networking options +# +# CONFIG_PACKET is not set +CONFIG_UNIX=y +# CONFIG_NET_KEY is not set +CONFIG_INET=y +# CONFIG_IP_MULTICAST is not set +# CONFIG_IP_ADVANCED_ROUTER is not set +CONFIG_IP_FIB_HASH=y +CONFIG_IP_PNP=y +# CONFIG_IP_PNP_DHCP is not set +CONFIG_IP_PNP_BOOTP=y +# CONFIG_IP_PNP_RARP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE is not set +# CONFIG_ARPD is not set +# CONFIG_SYN_COOKIES is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_TUNNEL is not set +CONFIG_INET_DIAG=y +CONFIG_INET_TCP_DIAG=y +# CONFIG_TCP_CONG_ADVANCED is not set +CONFIG_TCP_CONG_BIC=y +# CONFIG_IPV6 is not set +# CONFIG_NETFILTER is not set + +# +# DCCP Configuration (EXPERIMENTAL) +# +# CONFIG_IP_DCCP is not set + +# +# SCTP Configuration (EXPERIMENTAL) +# +# CONFIG_IP_SCTP is not set +# CONFIG_ATM is not set +# CONFIG_BRIDGE is not set +# CONFIG_VLAN_8021Q is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_NET_DIVERT is not set +# CONFIG_ECONET is not set +# CONFIG_WAN_ROUTER is not set +# CONFIG_NET_SCHED is not set +# CONFIG_NET_CLS_ROUTE is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_NETFILTER_NETLINK is not set +# CONFIG_HAMRADIO is not set +# CONFIG_IRDA is not set +# CONFIG_BT is not set +# CONFIG_IEEE80211 is not set + +# # Device Drivers # @@ -258,6 +339,7 @@ CONFIG_MTD_ROM=y # CONFIG_MTD_IMPA7 is not set CONFIG_MTD_BAST=y CONFIG_MTD_BAST_MAXSIZE=4 +# CONFIG_MTD_PLATRAM is not set # # Self-contained MTD device drivers @@ -312,7 +394,6 @@ CONFIG_BLK_DEV_RAM=y CONFIG_BLK_DEV_RAM_COUNT=16 CONFIG_BLK_DEV_RAM_SIZE=4096 CONFIG_BLK_DEV_INITRD=y -CONFIG_INITRAMFS_SOURCE="" # CONFIG_CDROM_PKTCDVD is not set # @@ -354,6 +435,7 @@ CONFIG_BLK_DEV_IDE_BAST=y # # SCSI device support # +# CONFIG_RAID_ATTRS is not set # CONFIG_SCSI is not set # @@ -376,70 +458,8 @@ CONFIG_BLK_DEV_IDE_BAST=y # # -# Networking support -# -CONFIG_NET=y - -# -# Networking options +# Network device support # -# CONFIG_PACKET is not set -CONFIG_UNIX=y -# CONFIG_NET_KEY is not set -CONFIG_INET=y -CONFIG_IP_FIB_HASH=y -# CONFIG_IP_FIB_TRIE is not set -# CONFIG_IP_MULTICAST is not set -# CONFIG_IP_ADVANCED_ROUTER is not set -CONFIG_IP_PNP=y -# CONFIG_IP_PNP_DHCP is not set -CONFIG_IP_PNP_BOOTP=y -# CONFIG_IP_PNP_RARP is not set -# CONFIG_NET_IPIP is not set -# CONFIG_NET_IPGRE is not set -# CONFIG_ARPD is not set -# CONFIG_SYN_COOKIES is not set -# CONFIG_INET_AH is not set -# CONFIG_INET_ESP is not set -# CONFIG_INET_IPCOMP is not set -# CONFIG_INET_TUNNEL is not set -CONFIG_IP_TCPDIAG=y -# CONFIG_IP_TCPDIAG_IPV6 is not set -# CONFIG_IPV6 is not set -# CONFIG_NETFILTER is not set - -# -# SCTP Configuration (EXPERIMENTAL) -# -# CONFIG_IP_SCTP is not set -# CONFIG_ATM is not set -# CONFIG_BRIDGE is not set -# CONFIG_VLAN_8021Q is not set -# CONFIG_DECNET is not set -# CONFIG_LLC2 is not set -# CONFIG_IPX is not set -# CONFIG_ATALK is not set -# CONFIG_X25 is not set -# CONFIG_LAPB is not set -# CONFIG_NET_DIVERT is not set -# CONFIG_ECONET is not set -# CONFIG_WAN_ROUTER is not set - -# -# QoS and/or fair queueing -# -# CONFIG_NET_SCHED is not set -# CONFIG_NET_CLS_ROUTE is not set - -# -# Network testing -# -# CONFIG_NET_PKTGEN is not set -# CONFIG_NETPOLL is not set -# CONFIG_NET_POLL_CONTROLLER is not set -# CONFIG_HAMRADIO is not set -# CONFIG_IRDA is not set -# CONFIG_BT is not set CONFIG_NETDEVICES=y # CONFIG_DUMMY is not set # CONFIG_BONDING is not set @@ -447,6 +467,11 @@ CONFIG_NETDEVICES=y # CONFIG_TUN is not set # +# PHY device support +# +# CONFIG_PHYLIB is not set + +# # Ethernet (10 or 100Mbit) # CONFIG_NET_ETHERNET=y @@ -480,6 +505,8 @@ CONFIG_DM9000=m # CONFIG_SLIP is not set # CONFIG_SHAPER is not set # CONFIG_NETCONSOLE is not set +# CONFIG_NETPOLL is not set +# CONFIG_NET_POLL_CONTROLLER is not set # # ISDN subsystem @@ -562,7 +589,6 @@ CONFIG_SERIAL_8250_EXTENDED=y CONFIG_SERIAL_8250_MANY_PORTS=y CONFIG_SERIAL_8250_SHARE_IRQ=y # CONFIG_SERIAL_8250_DETECT_IRQ is not set -# CONFIG_SERIAL_8250_MULTIPORT is not set # CONFIG_SERIAL_8250_RSA is not set # @@ -605,7 +631,6 @@ CONFIG_S3C2410_RTC=y # # Ftape, the floppy tape device driver # -# CONFIG_DRM is not set # CONFIG_RAW_DRIVER is not set # @@ -628,7 +653,7 @@ CONFIG_I2C_ALGOBIT=m # # I2C Hardware Bus support # -# CONFIG_I2C_ISA is not set +CONFIG_I2C_ISA=m # CONFIG_I2C_PARPORT is not set # CONFIG_I2C_PARPORT_LIGHT is not set CONFIG_I2C_S3C2410=y @@ -636,14 +661,33 @@ CONFIG_I2C_S3C2410=y # CONFIG_I2C_PCA_ISA is not set # -# Hardware Sensors Chip support +# Miscellaneous I2C Chip support # -CONFIG_I2C_SENSOR=m +# CONFIG_SENSORS_DS1337 is not set +# CONFIG_SENSORS_DS1374 is not set +CONFIG_SENSORS_EEPROM=m +# CONFIG_SENSORS_PCF8574 is not set +# CONFIG_SENSORS_PCA9539 is not set +# CONFIG_SENSORS_PCF8591 is not set +# CONFIG_SENSORS_RTC8564 is not set +# CONFIG_SENSORS_MAX6875 is not set +# CONFIG_I2C_DEBUG_CORE is not set +# CONFIG_I2C_DEBUG_ALGO is not set +# CONFIG_I2C_DEBUG_BUS is not set +# CONFIG_I2C_DEBUG_CHIP is not set + +# +# Hardware Monitoring support +# +CONFIG_HWMON=y +CONFIG_HWMON_VID=m # CONFIG_SENSORS_ADM1021 is not set # CONFIG_SENSORS_ADM1025 is not set # CONFIG_SENSORS_ADM1026 is not set # CONFIG_SENSORS_ADM1031 is not set +# CONFIG_SENSORS_ADM9240 is not set # CONFIG_SENSORS_ASB100 is not set +# CONFIG_SENSORS_ATXP1 is not set # CONFIG_SENSORS_DS1621 is not set # CONFIG_SENSORS_FSCHER is not set # CONFIG_SENSORS_FSCPOS is not set @@ -662,27 +706,21 @@ CONFIG_SENSORS_LM85=m # CONFIG_SENSORS_LM92 is not set # CONFIG_SENSORS_MAX1619 is not set # CONFIG_SENSORS_PC87360 is not set -# CONFIG_SENSORS_SMSC47B397 is not set # CONFIG_SENSORS_SMSC47M1 is not set +# CONFIG_SENSORS_SMSC47B397 is not set # CONFIG_SENSORS_W83781D is not set +# CONFIG_SENSORS_W83792D is not set # CONFIG_SENSORS_W83L785TS is not set # CONFIG_SENSORS_W83627HF is not set +# CONFIG_SENSORS_W83627EHF is not set +# CONFIG_HWMON_DEBUG_CHIP is not set # -# Other I2C Chip support +# Misc devices # -# CONFIG_SENSORS_DS1337 is not set -CONFIG_SENSORS_EEPROM=m -# CONFIG_SENSORS_PCF8574 is not set -# CONFIG_SENSORS_PCF8591 is not set -# CONFIG_SENSORS_RTC8564 is not set -# CONFIG_I2C_DEBUG_CORE is not set -# CONFIG_I2C_DEBUG_ALGO is not set -# CONFIG_I2C_DEBUG_BUS is not set -# CONFIG_I2C_DEBUG_CHIP is not set # -# Misc devices +# Multimedia Capabilities Port drivers # # @@ -731,7 +769,7 @@ CONFIG_DUMMY_CONSOLE=y # USB support # CONFIG_USB_ARCH_HAS_HCD=y -# CONFIG_USB_ARCH_HAS_OHCI is not set +CONFIG_USB_ARCH_HAS_OHCI=y # CONFIG_USB is not set # @@ -749,6 +787,7 @@ CONFIG_USB_ARCH_HAS_HCD=y # CONFIG_EXT2_FS=y # CONFIG_EXT2_FS_XATTR is not set +# CONFIG_EXT2_FS_XIP is not set CONFIG_EXT3_FS=y CONFIG_EXT3_FS_XATTR=y # CONFIG_EXT3_FS_POSIX_ACL is not set @@ -758,6 +797,7 @@ CONFIG_JBD=y CONFIG_FS_MBCACHE=y # CONFIG_REISERFS_FS is not set # CONFIG_JFS_FS is not set +# CONFIG_FS_POSIX_ACL is not set # # XFS support @@ -765,6 +805,7 @@ CONFIG_FS_MBCACHE=y # CONFIG_XFS_FS is not set # CONFIG_MINIX_FS is not set CONFIG_ROMFS_FS=y +CONFIG_INOTIFY=y # CONFIG_QUOTA is not set CONFIG_DNOTIFY=y # CONFIG_AUTOFS_FS is not set @@ -791,11 +832,11 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" # CONFIG_PROC_FS=y CONFIG_SYSFS=y -# CONFIG_DEVPTS_FS_XATTR is not set # CONFIG_TMPFS is not set # CONFIG_HUGETLBFS is not set # CONFIG_HUGETLB_PAGE is not set CONFIG_RAMFS=y +# CONFIG_RELAYFS_FS is not set # # Miscellaneous filesystems @@ -812,8 +853,7 @@ CONFIG_JFFS_FS_VERBOSE=0 # CONFIG_JFFS_PROC_FS is not set CONFIG_JFFS2_FS=y CONFIG_JFFS2_FS_DEBUG=0 -# CONFIG_JFFS2_FS_NAND is not set -# CONFIG_JFFS2_FS_NOR_ECC is not set +CONFIG_JFFS2_FS_WRITEBUFFER=y # CONFIG_JFFS2_COMPRESSION_OPTIONS is not set CONFIG_JFFS2_ZLIB=y CONFIG_JFFS2_RTIME=y @@ -835,6 +875,7 @@ CONFIG_NFS_FS=y # CONFIG_NFSD is not set CONFIG_ROOT_NFS=y CONFIG_LOCKD=y +CONFIG_NFS_COMMON=y CONFIG_SUNRPC=y # CONFIG_RPCSEC_GSS_KRB5 is not set # CONFIG_RPCSEC_GSS_SPKM3 is not set @@ -920,6 +961,7 @@ CONFIG_NLS_DEFAULT="iso8859-1" CONFIG_DEBUG_KERNEL=y # CONFIG_MAGIC_SYSRQ is not set CONFIG_LOG_BUF_SHIFT=16 +CONFIG_DETECT_SOFTLOCKUP=y # CONFIG_SCHEDSTATS is not set # CONFIG_DEBUG_SLAB is not set # CONFIG_DEBUG_SPINLOCK is not set -- cgit v0.10.2 From 61c8c158c828073cfebf11ca8e340727feafa038 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Thu, 8 Sep 2005 23:07:40 +0100 Subject: [ARM] 2892/1: remove gcc workaround for direct access to absolute memory addresses Patch from Nicolas Pitre It used to make a difference in the gcc-2.95 era. However these days modern gcc apparently got better at not being influenced by such constructs (which is good in general) and therefore such workaround is of no real advantage anymore. The good news is that gcc (from version 4.1.0) is now fixed with regards to the defficiency this workaround was trying to address. For those interested the patch can easily be backported to older gcc versions and can be found here: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/arm/arm.c.diff?r1=1.476&r2=1.478 and also here: http://savannah.gnu.org/cgi-bin/viewcvs/gcc/gcc/gcc/config/arm/arm.c.diff?r1=text&tr1=1.476&r2=text&tr2=1.478&diff_format=u Signed-off-by: Nicolas Pitre Signed-off-by: Russell King diff --git a/include/asm-arm/arch-pxa/hardware.h b/include/asm-arm/arch-pxa/hardware.h index 72b04d8..cf35721 100644 --- a/include/asm-arm/arch-pxa/hardware.h +++ b/include/asm-arm/arch-pxa/hardware.h @@ -44,24 +44,12 @@ #ifndef __ASSEMBLY__ -#if 0 -# define __REG(x) (*((volatile u32 *)io_p2v(x))) -#else -/* - * This __REG() version gives the same results as the one above, except - * that we are fooling gcc somehow so it generates far better and smaller - * assembly code for access to contigous registers. It's a shame that gcc - * doesn't guess this by itself. - */ -#include -typedef struct { volatile u32 offset[4096]; } __regbase; -# define __REGP(x) ((__regbase *)((x)&~4095))->offset[((x)&4095)>>2] -# define __REG(x) __REGP(io_p2v(x)) -#endif +# define __REG(x) (*((volatile unsigned long *)io_p2v(x))) /* With indexed regs we don't want to feed the index through io_p2v() especially if it is a variable, otherwise horrible code will result. */ -# define __REG2(x,y) (*(volatile u32 *)((u32)&__REG(x) + (y))) +# define __REG2(x,y) \ + (*(volatile unsigned long *)((unsigned long)&__REG(x) + (y))) # define __PREG(x) (io_v2p((u32)&(x))) diff --git a/include/asm-arm/arch-sa1100/hardware.h b/include/asm-arm/arch-sa1100/hardware.h index 10c62db..19c3b1e 100644 --- a/include/asm-arm/arch-sa1100/hardware.h +++ b/include/asm-arm/arch-sa1100/hardware.h @@ -49,23 +49,9 @@ ( (((x)&0x00ffffff) | (((x)&(0x30000000>>VIO_SHIFT))< -#if 0 -# define __REG(x) (*((volatile u32 *)io_p2v(x))) -#else -/* - * This __REG() version gives the same results as the one above, except - * that we are fooling gcc somehow so it generates far better and smaller - * assembly code for access to contigous registers. It's a shame that gcc - * doesn't guess this by itself. - */ -typedef struct { volatile u32 offset[4096]; } __regbase; -# define __REGP(x) ((__regbase *)((x)&~4095))->offset[((x)&4095)>>2] -# define __REG(x) __REGP(io_p2v(x)) -#endif - -# define __PREG(x) (io_v2p((u32)&(x))) +# define __REG(x) (*((volatile unsigned long *)io_p2v(x))) +# define __PREG(x) (io_v2p((unsigned long)&(x))) #else -- cgit v0.10.2 From cf0b450cd5176b68ac7d5bbe68aeae6bb6a5a4b8 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Thu, 8 Sep 2005 15:10:52 -0700 Subject: [TCP]: Fix off by one in tcp_fragment() "already sent" test. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 6094db5..15e1134 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -499,7 +499,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss /* If this packet has been sent out already, we must * adjust the various packet counters. */ - if (after(tp->snd_nxt, TCP_SKB_CB(buff)->end_seq)) { + if (!before(tp->snd_nxt, TCP_SKB_CB(buff)->end_seq)) { int diff = old_factor - tcp_skb_pcount(skb) - tcp_skb_pcount(buff); -- cgit v0.10.2 From e104411b82f5c4d19752c335492036abdbf5880d Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 8 Sep 2005 15:11:55 -0700 Subject: [XFRM]: Always release dst_entry on error in xfrm_lookup Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c index f115a84..f057025 100644 --- a/net/ipv4/netfilter/ipt_REJECT.c +++ b/net/ipv4/netfilter/ipt_REJECT.c @@ -92,10 +92,7 @@ static inline struct rtable *route_reverse(struct sk_buff *skb, fl.fl_ip_sport = tcph->dest; fl.fl_ip_dport = tcph->source; - if (xfrm_lookup((struct dst_entry **)&rt, &fl, NULL, 0)) { - dst_release(&rt->u.dst); - rt = NULL; - } + xfrm_lookup((struct dst_entry **)&rt, &fl, NULL, 0); return rt; } diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 157cec6..cc51840 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -175,10 +175,8 @@ ipv4_connected: if (final_p) ipv6_addr_copy(&fl.fl6_dst, final_p); - if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { - dst_release(dst); + if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) goto out; - } /* source address lookup done in ip6_dst_lookup */ diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 34e99c5..b7185fb 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -374,7 +374,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, if (err) goto out; if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) - goto out_dst_release; + goto out; if (ipv6_addr_is_multicast(&fl.fl6_dst)) hlimit = np->mcast_hops; @@ -469,7 +469,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb) if (err) goto out; if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) - goto out_dst_release; + goto out; if (ipv6_addr_is_multicast(&fl.fl6_dst)) hlimit = np->mcast_hops; @@ -505,7 +505,6 @@ static void icmpv6_echo_reply(struct sk_buff *skb) out_put: if (likely(idev != NULL)) in6_dev_put(idev); -out_dst_release: dst_release(dst); out: icmpv6_xmit_unlock(); diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index a7eae30..555a313 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -447,10 +447,8 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh, return; err = xfrm_lookup(&dst, &fl, NULL, 0); - if (err < 0) { - dst_release(dst); + if (err < 0) return; - } if (inc_opt) { if (dev->addr_len) @@ -539,10 +537,8 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh, return; err = xfrm_lookup(&dst, &fl, NULL, 0); - if (err < 0) { - dst_release(dst); + if (err < 0) return; - } len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr); send_llinfo = dev->addr_len && !ipv6_addr_any(saddr); @@ -616,10 +612,8 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr, return; err = xfrm_lookup(&dst, &fl, NULL, 0); - if (err < 0) { - dst_release(dst); + if (err < 0) return; - } len = sizeof(struct icmp6hdr); if (dev->addr_len) @@ -1353,10 +1347,8 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh, return; err = xfrm_lookup(&dst, &fl, NULL, 0); - if (err) { - dst_release(dst); + if (err) return; - } rt = (struct rt6_info *) dst; diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c index 14316c3..b03e87a 100644 --- a/net/ipv6/netfilter/ip6t_REJECT.c +++ b/net/ipv6/netfilter/ip6t_REJECT.c @@ -100,11 +100,8 @@ static void send_reset(struct sk_buff *oldskb) dst = ip6_route_output(NULL, &fl); if (dst == NULL) return; - if (dst->error || - xfrm_lookup(&dst, &fl, NULL, 0)) { - dst_release(dst); + if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0)) return; - } hh_len = (dst->dev->hard_header_len + 15)&~15; nskb = alloc_skb(hh_len + 15 + dst->header_len + sizeof(struct ipv6hdr) diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 2ad3789..5aa3691 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -782,10 +782,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, if (final_p) ipv6_addr_copy(&fl.fl6_dst, final_p); - if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { - dst_release(dst); + if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) goto out; - } if (hlimit < 0) { if (ipv6_addr_is_multicast(&fl.fl6_dst)) diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 246414b..80643e6 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -632,10 +632,8 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, if (final_p) ipv6_addr_copy(&fl.fl6_dst, final_p); - if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { - dst_release(dst); + if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) goto failure; - } if (saddr == NULL) { saddr = &fl.fl6_src; @@ -888,7 +886,6 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req, } done: - dst_release(dst); if (opt && opt != np->opt) sock_kfree_s(sk, opt, opt->tot_len); return err; @@ -1000,10 +997,8 @@ static void tcp_v6_send_reset(struct sk_buff *skb) /* sk = NULL, but it is safe for now. RST socket required. */ if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { - if ((xfrm_lookup(&buff->dst, &fl, NULL, 0)) < 0) { - dst_release(buff->dst); + if ((xfrm_lookup(&buff->dst, &fl, NULL, 0)) < 0) return; - } ip6_xmit(NULL, buff, &fl, NULL, 0); TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); @@ -1067,10 +1062,8 @@ static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 fl.fl_ip_sport = t1->source; if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { - if ((xfrm_lookup(&buff->dst, &fl, NULL, 0)) < 0) { - dst_release(buff->dst); + if ((xfrm_lookup(&buff->dst, &fl, NULL, 0)) < 0) return; - } ip6_xmit(NULL, buff, &fl, NULL, 0); TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); return; @@ -1733,7 +1726,6 @@ static int tcp_v6_rebuild_header(struct sock *sk) if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { sk->sk_err_soft = -err; - dst_release(dst); return err; } @@ -1786,7 +1778,6 @@ static int tcp_v6_xmit(struct sk_buff *skb, int ipfragok) if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { sk->sk_route_caps = 0; - dst_release(dst); return err; } diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index f5ae148..69b1468 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -799,10 +799,8 @@ do_udp_sendmsg: if (final_p) ipv6_addr_copy(&fl->fl6_dst, final_p); - if ((err = xfrm_lookup(&dst, fl, sk, 0)) < 0) { - dst_release(dst); + if ((err = xfrm_lookup(&dst, fl, sk, 0)) < 0) goto out; - } if (hlimit < 0) { if (ipv6_addr_is_multicast(&fl->fl6_dst)) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 83c8135..fda737d 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -765,8 +765,8 @@ restart: switch (policy->action) { case XFRM_POLICY_BLOCK: /* Prohibit the flow */ - xfrm_pol_put(policy); - return -EPERM; + err = -EPERM; + goto error; case XFRM_POLICY_ALLOW: if (policy->xfrm_nr == 0) { @@ -782,8 +782,8 @@ restart: */ dst = xfrm_find_bundle(fl, policy, family); if (IS_ERR(dst)) { - xfrm_pol_put(policy); - return PTR_ERR(dst); + err = PTR_ERR(dst); + goto error; } if (dst) -- cgit v0.10.2 From b9db07fba7f113764d7379b0f68324a9a5450306 Mon Sep 17 00:00:00 2001 From: Lonnie Mendez Date: Tue, 12 Jul 2005 17:21:31 -0500 Subject: [PATCH] USB: whitespace fixes for cypress_m8 driver Reading this driver I noticed some trailing whitespaces and tabs so I removed them with some 80th column fitting and a few more similar things. From: Carlo Perassi Signed-off-by: Lonnie Mendez Signed-off-by: Carlo Perassi Signed-off-by: Domen Puncer Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 012e63e..05c44ae 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -453,8 +453,8 @@ static int generic_startup (struct usb_serial *serial) priv->cbr_mask = B300; usb_set_serial_port_data(serial->port[0], priv); - return (0); -} + return 0; +} static int cypress_earthmate_startup (struct usb_serial *serial) @@ -464,14 +464,15 @@ static int cypress_earthmate_startup (struct usb_serial *serial) dbg("%s", __FUNCTION__); if (generic_startup(serial)) { - dbg("%s - Failed setting up port %d", __FUNCTION__, serial->port[0]->number); + dbg("%s - Failed setting up port %d", __FUNCTION__, + serial->port[0]->number); return 1; } priv = usb_get_serial_port_data(serial->port[0]); priv->chiptype = CT_EARTHMATE; - - return (0); + + return 0; } /* cypress_earthmate_startup */ @@ -482,14 +483,15 @@ static int cypress_hidcom_startup (struct usb_serial *serial) dbg("%s", __FUNCTION__); if (generic_startup(serial)) { - dbg("%s - Failed setting up port %d", __FUNCTION__, serial->port[0]->number); + dbg("%s - Failed setting up port %d", __FUNCTION__, + serial->port[0]->number); return 1; } priv = usb_get_serial_port_data(serial->port[0]); priv->chiptype = CT_CYPHIDCOM; - return (0); + return 0; } /* cypress_hidcom_startup */ @@ -909,7 +911,8 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi } /* cypress_ioctl */ -static void cypress_set_termios (struct usb_serial_port *port, struct termios *old_termios) +static void cypress_set_termios (struct usb_serial_port *port, + struct termios *old_termios) { struct cypress_private *priv = usb_get_serial_port_data(port); struct tty_struct *tty; @@ -918,7 +921,7 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o unsigned long flags; __u8 oldlines; int linechange = 0; - + dbg("%s - port %d", __FUNCTION__, port->number); tty = port->tty; @@ -931,10 +934,12 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o if (!priv->termios_initialized) { if (priv->chiptype == CT_EARTHMATE) { *(tty->termios) = tty_std_termios; - tty->termios->c_cflag = B4800 | CS8 | CREAD | HUPCL | CLOCAL; + tty->termios->c_cflag = B4800 | CS8 | CREAD | HUPCL | + CLOCAL; } else if (priv->chiptype == CT_CYPHIDCOM) { *(tty->termios) = tty_std_termios; - tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; + tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | + CLOCAL; } priv->termios_initialized = 1; } @@ -946,12 +951,15 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o /* check if there are new settings */ if (old_termios) { if ((cflag != old_termios->c_cflag) || - (RELEVANT_IFLAG(iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) { - dbg("%s - attempting to set new termios settings", __FUNCTION__); - /* should make a copy of this in case something goes wrong in the function, we can restore it */ + (RELEVANT_IFLAG(iflag) != + RELEVANT_IFLAG(old_termios->c_iflag))) { + dbg("%s - attempting to set new termios settings", + __FUNCTION__); + /* should make a copy of this in case something goes + * wrong in the function, we can restore it */ spin_lock_irqsave(&priv->lock, flags); priv->tmp_termios = *(tty->termios); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); } else { dbg("%s - nothing to do, exiting", __FUNCTION__); return; @@ -962,21 +970,34 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o /* set number of data bits, parity, stop bits */ /* when parity is disabled the parity type bit is ignored */ - stop_bits = cflag & CSTOPB ? 1 : 0; /* 1 means 2 stop bits, 0 means 1 stop bit */ - + /* 1 means 2 stop bits, 0 means 1 stop bit */ + stop_bits = cflag & CSTOPB ? 1 : 0; + if (cflag & PARENB) { parity_enable = 1; - parity_type = cflag & PARODD ? 1 : 0; /* 1 means odd parity, 0 means even parity */ + /* 1 means odd parity, 0 means even parity */ + parity_type = cflag & PARODD ? 1 : 0; } else parity_enable = parity_type = 0; if (cflag & CSIZE) { switch (cflag & CSIZE) { - case CS5: data_bits = 0; break; - case CS6: data_bits = 1; break; - case CS7: data_bits = 2; break; - case CS8: data_bits = 3; break; - default: err("%s - CSIZE was set, but not CS5-CS8", __FUNCTION__); data_bits = 3; + case CS5: + data_bits = 0; + break; + case CS6: + data_bits = 1; + break; + case CS7: + data_bits = 2; + break; + case CS8: + data_bits = 3; + break; + default: + err("%s - CSIZE was set, but not CS5-CS8", + __FUNCTION__); + data_bits = 3; } } else data_bits = 3; @@ -991,63 +1012,85 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o } else { baud_mask = (cflag & CBAUD); switch(baud_mask) { - case B300: dbg("%s - setting baud 300bps", __FUNCTION__); break; - case B600: dbg("%s - setting baud 600bps", __FUNCTION__); break; - case B1200: dbg("%s - setting baud 1200bps", __FUNCTION__); break; - case B2400: dbg("%s - setting baud 2400bps", __FUNCTION__); break; - case B4800: dbg("%s - setting baud 4800bps", __FUNCTION__); break; - case B9600: dbg("%s - setting baud 9600bps", __FUNCTION__); break; - case B19200: dbg("%s - setting baud 19200bps", __FUNCTION__); break; - case B38400: dbg("%s - setting baud 38400bps", __FUNCTION__); break; - case B57600: dbg("%s - setting baud 57600bps", __FUNCTION__); break; - case B115200: dbg("%s - setting baud 115200bps", __FUNCTION__); break; - default: dbg("%s - unknown masked baud rate", __FUNCTION__); + case B300: + dbg("%s - setting baud 300bps", __FUNCTION__); + break; + case B600: + dbg("%s - setting baud 600bps", __FUNCTION__); + break; + case B1200: + dbg("%s - setting baud 1200bps", __FUNCTION__); + break; + case B2400: + dbg("%s - setting baud 2400bps", __FUNCTION__); + break; + case B4800: + dbg("%s - setting baud 4800bps", __FUNCTION__); + break; + case B9600: + dbg("%s - setting baud 9600bps", __FUNCTION__); + break; + case B19200: + dbg("%s - setting baud 19200bps", __FUNCTION__); + break; + case B38400: + dbg("%s - setting baud 38400bps", __FUNCTION__); + break; + case B57600: + dbg("%s - setting baud 57600bps", __FUNCTION__); + break; + case B115200: + dbg("%s - setting baud 115200bps", __FUNCTION__); + break; + default: + dbg("%s - unknown masked baud rate", __FUNCTION__); } priv->line_control = (CONTROL_DTR | CONTROL_RTS); } spin_unlock_irqrestore(&priv->lock, flags); - - dbg("%s - sending %d stop_bits, %d parity_enable, %d parity_type, %d data_bits (+5)", __FUNCTION__, - stop_bits, parity_enable, parity_type, data_bits); - cypress_serial_control(port, baud_mask, data_bits, stop_bits, parity_enable, - parity_type, 0, CYPRESS_SET_CONFIG); + dbg("%s - sending %d stop_bits, %d parity_enable, %d parity_type, " + "%d data_bits (+5)", __FUNCTION__, stop_bits, + parity_enable, parity_type, data_bits); + + cypress_serial_control(port, baud_mask, data_bits, stop_bits, + parity_enable, parity_type, 0, CYPRESS_SET_CONFIG); - /* we perform a CYPRESS_GET_CONFIG so that the current settings are filled into the private structure - * this should confirm that all is working if it returns what we just set */ + /* we perform a CYPRESS_GET_CONFIG so that the current settings are + * filled into the private structure this should confirm that all is + * working if it returns what we just set */ cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG); - /* Here we can define custom tty settings for devices - * - * the main tty termios flag base comes from empeg.c - */ + /* Here we can define custom tty settings for devices; the main tty + * termios flag base comes from empeg.c */ - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&priv->lock, flags); if ( (priv->chiptype == CT_EARTHMATE) && (priv->baud_rate == 4800) ) { - - dbg("Using custom termios settings for a baud rate of 4800bps."); + dbg("Using custom termios settings for a baud rate of " + "4800bps."); /* define custom termios settings for NMEA protocol */ tty->termios->c_iflag /* input modes - */ - &= ~(IGNBRK /* disable ignore break */ - | BRKINT /* disable break causes interrupt */ - | PARMRK /* disable mark parity errors */ - | ISTRIP /* disable clear high bit of input characters */ - | INLCR /* disable translate NL to CR */ - | IGNCR /* disable ignore CR */ - | ICRNL /* disable translate CR to NL */ - | IXON); /* disable enable XON/XOFF flow control */ - + &= ~(IGNBRK /* disable ignore break */ + | BRKINT /* disable break causes interrupt */ + | PARMRK /* disable mark parity errors */ + | ISTRIP /* disable clear high bit of input char */ + | INLCR /* disable translate NL to CR */ + | IGNCR /* disable ignore CR */ + | ICRNL /* disable translate CR to NL */ + | IXON); /* disable enable XON/XOFF flow control */ + tty->termios->c_oflag /* output modes */ - &= ~OPOST; /* disable postprocess output characters */ - - tty->termios->c_lflag /* line discipline modes */ - &= ~(ECHO /* disable echo input characters */ - | ECHONL /* disable echo new line */ - | ICANON /* disable erase, kill, werase, and rprnt special characters */ - | ISIG /* disable interrupt, quit, and suspend special characters */ - | IEXTEN); /* disable non-POSIX special characters */ + &= ~OPOST; /* disable postprocess output char */ + tty->termios->c_lflag /* line discipline modes */ + &= ~(ECHO /* disable echo input characters */ + | ECHONL /* disable echo new line */ + | ICANON /* disable erase, kill, werase, and rprnt + special characters */ + | ISIG /* disable interrupt, quit, and suspend + special characters */ + | IEXTEN); /* disable non-POSIX special characters */ } /* CT_CYPHIDCOM: Application should handle this for device */ linechange = (priv->line_control != oldlines); @@ -1060,7 +1103,7 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o } } /* cypress_set_termios */ - + /* returns amount of data still left in soft buffer */ static int cypress_chars_in_buffer(struct usb_serial_port *port) { @@ -1088,7 +1131,7 @@ static void cypress_throttle (struct usb_serial_port *port) spin_lock_irqsave(&priv->lock, flags); priv->rx_flags = THROTTLED; - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); } @@ -1110,7 +1153,8 @@ static void cypress_unthrottle (struct usb_serial_port *port) result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); if (result) - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed submitting read urb, " + "error %d\n", __FUNCTION__, result); } } @@ -1122,7 +1166,7 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs) struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; unsigned long flags; - char tty_flag = TTY_NORMAL; + char tty_flag = TTY_NORMAL; int havedata = 0; int bytes = 0; int result; @@ -1131,7 +1175,8 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs) dbg("%s - port %d", __FUNCTION__, port->number); if (urb->status) { - dbg("%s - nonzero read status received: %d", __FUNCTION__, urb->status); + dbg("%s - nonzero read status received: %d", __FUNCTION__, + urb->status); return; } @@ -1155,51 +1200,55 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs) case 32: /* This is for the CY7C64013... */ priv->current_status = data[0] & 0xF8; - bytes = data[1]+2; - i=2; + bytes = data[1] + 2; + i = 2; if (bytes > 2) havedata = 1; break; case 8: /* This is for the CY7C63743... */ priv->current_status = data[0] & 0xF8; - bytes = (data[0] & 0x07)+1; - i=1; + bytes = (data[0] & 0x07) + 1; + i = 1; if (bytes > 1) havedata = 1; break; default: - dbg("%s - wrong packet size - received %d bytes", __FUNCTION__, urb->actual_length); + dbg("%s - wrong packet size - received %d bytes", + __FUNCTION__, urb->actual_length); spin_unlock_irqrestore(&priv->lock, flags); goto continue_read; } spin_unlock_irqrestore(&priv->lock, flags); - usb_serial_debug_data (debug, &port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data (debug, &port->dev, __FUNCTION__, + urb->actual_length, data); spin_lock_irqsave(&priv->lock, flags); /* check to see if status has changed */ if (priv != NULL) { if (priv->current_status != priv->prev_status) { - priv->diff_status |= priv->current_status ^ priv->prev_status; + priv->diff_status |= priv->current_status ^ + priv->prev_status; wake_up_interruptible(&priv->delta_msr_wait); priv->prev_status = priv->current_status; } } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); - /* hangup, as defined in acm.c... this might be a bad place for it though */ - if (tty && !(tty->termios->c_cflag & CLOCAL) && !(priv->current_status & UART_CD)) { + /* hangup, as defined in acm.c... this might be a bad place for it + * though */ + if (tty && !(tty->termios->c_cflag & CLOCAL) && + !(priv->current_status & UART_CD)) { dbg("%s - calling hangup", __FUNCTION__); tty_hangup(tty); goto continue_read; } - /* There is one error bit... I'm assuming it is a parity error indicator - * as the generic firmware will set this bit to 1 if a parity error occurs. - * I can not find reference to any other error events. - * - */ + /* There is one error bit... I'm assuming it is a parity error + * indicator as the generic firmware will set this bit to 1 if a + * parity error occurs. + * I can not find reference to any other error events. */ spin_lock_irqsave(&priv->lock, flags); if (priv->current_status & CYP_ERROR) { spin_unlock_irqrestore(&priv->lock, flags); @@ -1211,7 +1260,8 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs) /* process read if there is data other than line status */ if (tty && (bytes > i)) { for (; i < bytes ; ++i) { - dbg("pushing byte number %d - %d - %c",i,data[i],data[i]); + dbg("pushing byte number %d - %d - %c", i, data[i], + data[i]); if(tty->flip.count >= TTY_FLIPBUF_SIZE) { tty_flip_buffer_push(tty); } @@ -1221,25 +1271,28 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs) } spin_lock_irqsave(&priv->lock, flags); - priv->bytes_in += bytes; /* control and status byte(s) are also counted */ + /* control and status byte(s) are also counted */ + priv->bytes_in += bytes; spin_unlock_irqrestore(&priv->lock, flags); continue_read: - - /* Continue trying to always read... unless the port has closed. */ + + /* Continue trying to always read... unless the port has closed. */ if (port->open_count > 0) { - usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev, - usb_rcvintpipe(port->serial->dev, port->interrupt_in_endpointAddress), - port->interrupt_in_urb->transfer_buffer, - port->interrupt_in_urb->transfer_buffer_length, - cypress_read_int_callback, port, - interval); - result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); - if (result) - dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); + usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev, + usb_rcvintpipe(port->serial->dev, + port->interrupt_in_endpointAddress), + port->interrupt_in_urb->transfer_buffer, + port->interrupt_in_urb->transfer_buffer_length, + cypress_read_int_callback, port, interval); + result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); + if (result) + dev_err(&urb->dev->dev, "%s - failed resubmitting " + "read urb, error %d\n", __FUNCTION__, + result); } - + return; } /* cypress_read_int_callback */ -- cgit v0.10.2 From 7bb75aeeeec7417a961920b3f63a83007475260f Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 27 Jul 2005 01:08:30 -0700 Subject: [PATCH] USB: option card driver coding style tweaks Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index e925640..4f985f4 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -45,29 +45,29 @@ #include "usb-serial.h" /* Function prototypes */ -static int option_open (struct usb_serial_port *port, struct file *filp); -static void option_close (struct usb_serial_port *port, struct file *filp); -static int option_startup (struct usb_serial *serial); -static void option_shutdown (struct usb_serial *serial); -static void option_rx_throttle (struct usb_serial_port *port); -static void option_rx_unthrottle (struct usb_serial_port *port); -static int option_write_room (struct usb_serial_port *port); +static int option_open(struct usb_serial_port *port, struct file *filp); +static void option_close(struct usb_serial_port *port, struct file *filp); +static int option_startup(struct usb_serial *serial); +static void option_shutdown(struct usb_serial *serial); +static void option_rx_throttle(struct usb_serial_port *port); +static void option_rx_unthrottle(struct usb_serial_port *port); +static int option_write_room(struct usb_serial_port *port); static void option_instat_callback(struct urb *urb, struct pt_regs *regs); -static int option_write (struct usb_serial_port *port, - const unsigned char *buf, int count); +static int option_write(struct usb_serial_port *port, + const unsigned char *buf, int count); -static int option_chars_in_buffer (struct usb_serial_port *port); -static int option_ioctl (struct usb_serial_port *port, struct file *file, - unsigned int cmd, unsigned long arg); -static void option_set_termios (struct usb_serial_port *port, - struct termios *old); -static void option_break_ctl (struct usb_serial_port *port, int break_state); -static int option_tiocmget (struct usb_serial_port *port, struct file *file); -static int option_tiocmset (struct usb_serial_port *port, struct file *file, - unsigned int set, unsigned int clear); -static int option_send_setup (struct usb_serial_port *port); +static int option_chars_in_buffer(struct usb_serial_port *port); +static int option_ioctl(struct usb_serial_port *port, struct file *file, + unsigned int cmd, unsigned long arg); +static void option_set_termios(struct usb_serial_port *port, + struct termios *old); +static void option_break_ctl(struct usb_serial_port *port, int break_state); +static int option_tiocmget(struct usb_serial_port *port, struct file *file); +static int option_tiocmset(struct usb_serial_port *port, struct file *file, + unsigned int set, unsigned int clear); +static int option_send_setup(struct usb_serial_port *port); /* Vendor and product IDs */ #define OPTION_VENDOR_ID 0x0AF0 @@ -76,7 +76,6 @@ static int option_send_setup (struct usb_serial_port *port); #define OPTION_PRODUCT_FUSION 0x6000 #define OPTION_PRODUCT_FUSION2 0x6300 - static struct usb_device_id option_ids[] = { { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) }, { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) }, @@ -129,7 +128,6 @@ static int debug; #define debug 0 #endif - /* per port private data */ #define N_IN_URB 4 @@ -156,10 +154,8 @@ struct option_port_private { unsigned long tx_start_time[N_OUT_URB]; }; - /* Functions used by new usb-serial code. */ -static int __init -option_init (void) +static int __init option_init(void) { int retval; retval = usb_serial_register(&option_3port_device); @@ -179,8 +175,7 @@ failed_3port_device_register: return retval; } -static void __exit -option_exit (void) +static void __exit option_exit(void) { usb_deregister (&option_driver); usb_serial_deregister (&option_3port_device); @@ -189,39 +184,31 @@ option_exit (void) module_init(option_init); module_exit(option_exit); -static void -option_rx_throttle (struct usb_serial_port *port) +static void option_rx_throttle(struct usb_serial_port *port) { dbg("%s", __FUNCTION__); } - -static void -option_rx_unthrottle (struct usb_serial_port *port) +static void option_rx_unthrottle(struct usb_serial_port *port) { dbg("%s", __FUNCTION__); } - -static void -option_break_ctl (struct usb_serial_port *port, int break_state) +static void option_break_ctl(struct usb_serial_port *port, int break_state) { /* Unfortunately, I don't know how to send a break */ dbg("%s", __FUNCTION__); } - -static void -option_set_termios (struct usb_serial_port *port, - struct termios *old_termios) +static void option_set_termios(struct usb_serial_port *port, + struct termios *old_termios) { dbg("%s", __FUNCTION__); option_send_setup(port); } -static int -option_tiocmget (struct usb_serial_port *port, struct file *file) +static int option_tiocmget(struct usb_serial_port *port, struct file *file) { unsigned int value; struct option_port_private *portdata; @@ -238,9 +225,8 @@ option_tiocmget (struct usb_serial_port *port, struct file *file) return value; } -static int -option_tiocmset (struct usb_serial_port *port, struct file *file, - unsigned int set, unsigned int clear) +static int option_tiocmset(struct usb_serial_port *port, struct file *file, + unsigned int set, unsigned int clear) { struct option_port_private *portdata; @@ -258,17 +244,15 @@ option_tiocmset (struct usb_serial_port *port, struct file *file, return option_send_setup(port); } -static int -option_ioctl (struct usb_serial_port *port, struct file *file, - unsigned int cmd, unsigned long arg) +static int option_ioctl(struct usb_serial_port *port, struct file *file, + unsigned int cmd, unsigned long arg) { return -ENOIOCTLCMD; } /* Write */ -static int -option_write (struct usb_serial_port *port, - const unsigned char *buf, int count) +static int option_write(struct usb_serial_port *port, + const unsigned char *buf, int count) { struct option_port_private *portdata; int i; @@ -291,16 +275,19 @@ option_write (struct usb_serial_port *port, if (this_urb->status == -EINPROGRESS) { if (this_urb->transfer_flags & URB_ASYNC_UNLINK) continue; - if (time_before(jiffies, portdata->tx_start_time[i] + 10 * HZ)) + if (time_before(jiffies, + portdata->tx_start_time[i] + 10 * HZ)) continue; this_urb->transfer_flags |= URB_ASYNC_UNLINK; usb_unlink_urb(this_urb); continue; } if (this_urb->status != 0) - dbg("usb_write %p failed (err=%d)", this_urb, this_urb->status); + dbg("usb_write %p failed (err=%d)", + this_urb, this_urb->status); - dbg("%s: endpoint %d buf %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe), i); + dbg("%s: endpoint %d buf %d", __FUNCTION__, + usb_pipeendpoint(this_urb->pipe), i); /* send the data */ memcpy (this_urb->transfer_buffer, buf, todo); @@ -310,7 +297,9 @@ option_write (struct usb_serial_port *port, this_urb->dev = port->serial->dev; err = usb_submit_urb(this_urb, GFP_ATOMIC); if (err) { - dbg("usb_submit_urb %p (write bulk) failed (%d, has %d)", this_urb, err, this_urb->status); + dbg("usb_submit_urb %p (write bulk) failed " + "(%d, has %d)", this_urb, + err, this_urb->status); continue; } portdata->tx_start_time[i] = jiffies; @@ -323,8 +312,7 @@ option_write (struct usb_serial_port *port, return count; } -static void -option_indat_callback (struct urb *urb, struct pt_regs *regs) +static void option_indat_callback(struct urb *urb, struct pt_regs *regs) { int i, err; int endpoint; @@ -357,14 +345,14 @@ option_indat_callback (struct urb *urb, struct pt_regs *regs) if (port->open_count && urb->status != -ESHUTDOWN) { err = usb_submit_urb(urb, GFP_ATOMIC); if (err) - printk(KERN_ERR "%s: resubmit read urb failed. (%d)", __FUNCTION__, err); + printk(KERN_ERR "%s: resubmit read urb failed. " + "(%d)", __FUNCTION__, err); } } return; } -static void -option_outdat_callback (struct urb *urb, struct pt_regs *regs) +static void option_outdat_callback(struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port; @@ -376,8 +364,7 @@ option_outdat_callback (struct urb *urb, struct pt_regs *regs) schedule_work(&port->work); } -static void -option_instat_callback (struct urb *urb, struct pt_regs *regs) +static void option_instat_callback(struct urb *urb, struct pt_regs *regs) { int err; struct usb_serial_port *port = (struct usb_serial_port *) urb->context; @@ -395,10 +382,12 @@ option_instat_callback (struct urb *urb, struct pt_regs *regs) dbg("%s: NULL req_pkt\n", __FUNCTION__); return; } - if ((req_pkt->bRequestType == 0xA1) && (req_pkt->bRequest == 0x20)) { + if ((req_pkt->bRequestType == 0xA1) && + (req_pkt->bRequest == 0x20)) { int old_dcd_state; unsigned char signals = *((unsigned char *) - urb->transfer_buffer + sizeof(struct usb_ctrlrequest)); + urb->transfer_buffer + + sizeof(struct usb_ctrlrequest)); dbg("%s: signal x%x", __FUNCTION__, signals); @@ -408,12 +397,13 @@ option_instat_callback (struct urb *urb, struct pt_regs *regs) portdata->dsr_state = ((signals & 0x02) ? 1 : 0); portdata->ri_state = ((signals & 0x08) ? 1 : 0); - if (port->tty && !C_CLOCAL(port->tty) - && old_dcd_state && !portdata->dcd_state) { + if (port->tty && !C_CLOCAL(port->tty) && + old_dcd_state && !portdata->dcd_state) tty_hangup(port->tty); - } - } else - dbg("%s: type %x req %x", __FUNCTION__, req_pkt->bRequestType,req_pkt->bRequest); + } else { + dbg("%s: type %x req %x", __FUNCTION__, + req_pkt->bRequestType,req_pkt->bRequest); + } } else dbg("%s: error %d", __FUNCTION__, urb->status); @@ -422,13 +412,12 @@ option_instat_callback (struct urb *urb, struct pt_regs *regs) urb->dev = serial->dev; err = usb_submit_urb(urb, GFP_ATOMIC); if (err) - dbg("%s: resubmit intr urb failed. (%d)", __FUNCTION__, err); + dbg("%s: resubmit intr urb failed. (%d)", + __FUNCTION__, err); } } - -static int -option_write_room (struct usb_serial_port *port) +static int option_write_room(struct usb_serial_port *port) { struct option_port_private *portdata; int i; @@ -447,9 +436,7 @@ option_write_room (struct usb_serial_port *port) return data_len; } - -static int -option_chars_in_buffer (struct usb_serial_port *port) +static int option_chars_in_buffer(struct usb_serial_port *port) { struct option_port_private *portdata; int i; @@ -467,9 +454,7 @@ option_chars_in_buffer (struct usb_serial_port *port) return data_len; } - -static int -option_open (struct usb_serial_port *port, struct file *filp) +static int option_open(struct usb_serial_port *port, struct file *filp) { struct option_port_private *portdata; struct usb_serial *serial = port->serial; @@ -490,17 +475,21 @@ option_open (struct usb_serial_port *port, struct file *filp) if (! urb) continue; if (urb->dev != serial->dev) { - dbg("%s: dev %p != %p", __FUNCTION__, urb->dev, serial->dev); + dbg("%s: dev %p != %p", __FUNCTION__, + urb->dev, serial->dev); continue; } - /* make sure endpoint data toggle is synchronized with the device */ - + /* + * make sure endpoint data toggle is synchronized with the + * device + */ usb_clear_halt(urb->dev, urb->pipe); err = usb_submit_urb(urb, GFP_KERNEL); if (err) { - dbg("%s: submit urb %d failed (%d) %d", __FUNCTION__, i, err, + dbg("%s: submit urb %d failed (%d) %d", + __FUNCTION__, i, err, urb->transfer_buffer_length); } } @@ -511,7 +500,8 @@ option_open (struct usb_serial_port *port, struct file *filp) if (! urb) continue; urb->dev = serial->dev; - /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */ + /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), + usb_pipeout(urb->pipe), 0); */ } port->tty->low_latency = 1; @@ -521,8 +511,7 @@ option_open (struct usb_serial_port *port, struct file *filp) return (0); } -static inline void -stop_urb (struct urb *urb) +static inline void stop_urb(struct urb *urb) { if (urb && urb->status == -EINPROGRESS) { urb->transfer_flags &= ~URB_ASYNC_UNLINK; @@ -530,8 +519,7 @@ stop_urb (struct urb *urb) } } -static void -option_close (struct usb_serial_port *port, struct file *filp) +static void option_close(struct usb_serial_port *port, struct file *filp) { int i; struct usb_serial *serial = port->serial; @@ -555,12 +543,10 @@ option_close (struct usb_serial_port *port, struct file *filp) port->tty = NULL; } - /* Helper functions used by option_setup_urbs */ -static struct urb * -option_setup_urb (struct usb_serial *serial, int endpoint, - int dir, void *ctx, char *buf, int len, - void (*callback)(struct urb *, struct pt_regs *regs)) +static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint, + int dir, void *ctx, char *buf, int len, + void (*callback)(struct urb *, struct pt_regs *regs)) { struct urb *urb; @@ -582,8 +568,7 @@ option_setup_urb (struct usb_serial *serial, int endpoint, } /* Setup urbs */ -static void -option_setup_urbs (struct usb_serial *serial) +static void option_setup_urbs(struct usb_serial *serial) { int j; struct usb_serial_port *port; @@ -609,9 +594,7 @@ option_setup_urbs (struct usb_serial *serial) } } - -static int -option_send_setup (struct usb_serial_port *port) +static int option_send_setup(struct usb_serial_port *port) { struct usb_serial *serial = port->serial; struct option_port_private *portdata; @@ -627,16 +610,15 @@ option_send_setup (struct usb_serial_port *port) if (portdata->rts_state) val |= 0x02; - return usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), - 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); + return usb_control_msg(serial->dev, + usb_rcvctrlpipe(serial->dev, 0), + 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); } return 0; } - -static int -option_startup (struct usb_serial *serial) +static int option_startup(struct usb_serial *serial) { int i, err; struct usb_serial_port *port; @@ -647,9 +629,10 @@ option_startup (struct usb_serial *serial) /* Now setup per port private data */ for (i = 0; i < serial->num_ports; i++) { port = serial->port[i]; - portdata = kmalloc(sizeof(struct option_port_private), GFP_KERNEL); + portdata = kmalloc(sizeof(*portdata), GFP_KERNEL); if (!portdata) { - dbg("%s: kmalloc for option_port_private (%d) failed!.", __FUNCTION__, i); + dbg("%s: kmalloc for option_port_private (%d) failed!.", + __FUNCTION__, i); return (1); } memset(portdata, 0, sizeof(struct option_port_private)); @@ -660,7 +643,8 @@ option_startup (struct usb_serial *serial) continue; err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (err) - dbg("%s: submit irq_in urb failed %d", __FUNCTION__, err); + dbg("%s: submit irq_in urb failed %d", + __FUNCTION__, err); } option_setup_urbs(serial); @@ -668,8 +652,7 @@ option_startup (struct usb_serial *serial) return (0); } -static void -option_shutdown (struct usb_serial *serial) +static void option_shutdown(struct usb_serial *serial) { int i, j; struct usb_serial_port *port; -- cgit v0.10.2 From 81671ddb7e24e9d1f84812dba8ed810935f77d40 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 4 Jul 2005 19:32:51 +0200 Subject: [PATCH] USB: drivers/serial/usb-serial: Remove unneeded void * casts The following patch removes unneeded casts for the following (void *) pointers: - tty_struct->driver_data - void *private argument of usb_serial_port_softint() Signed-off-by: Tobias Klauser Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 0267b26..e77fbdf 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -531,7 +531,7 @@ bailout_kref_put: static void serial_close(struct tty_struct *tty, struct file * filp) { - struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + struct usb_serial_port *port = tty->driver_data; if (!port) return; @@ -561,7 +561,7 @@ static void serial_close(struct tty_struct *tty, struct file * filp) static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count) { - struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + struct usb_serial_port *port = tty->driver_data; int retval = -EINVAL; dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count); @@ -580,7 +580,7 @@ exit: static int serial_write_room (struct tty_struct *tty) { - struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + struct usb_serial_port *port = tty->driver_data; int retval = -EINVAL; dbg("%s - port %d", __FUNCTION__, port->number); @@ -599,7 +599,7 @@ exit: static int serial_chars_in_buffer (struct tty_struct *tty) { - struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + struct usb_serial_port *port = tty->driver_data; int retval = -EINVAL; dbg("%s = port %d", __FUNCTION__, port->number); @@ -618,7 +618,7 @@ exit: static void serial_throttle (struct tty_struct * tty) { - struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __FUNCTION__, port->number); @@ -634,7 +634,7 @@ static void serial_throttle (struct tty_struct * tty) static void serial_unthrottle (struct tty_struct * tty) { - struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __FUNCTION__, port->number); @@ -650,7 +650,7 @@ static void serial_unthrottle (struct tty_struct * tty) static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) { - struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + struct usb_serial_port *port = tty->driver_data; int retval = -ENODEV; dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); @@ -672,7 +672,7 @@ exit: static void serial_set_termios (struct tty_struct *tty, struct termios * old) { - struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __FUNCTION__, port->number); @@ -688,7 +688,7 @@ static void serial_set_termios (struct tty_struct *tty, struct termios * old) static void serial_break (struct tty_struct *tty, int break_state) { - struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __FUNCTION__, port->number); @@ -749,7 +749,7 @@ done: static int serial_tiocmget (struct tty_struct *tty, struct file *file) { - struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __FUNCTION__, port->number); @@ -768,7 +768,7 @@ exit: static int serial_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { - struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __FUNCTION__, port->number); @@ -786,7 +786,7 @@ exit: void usb_serial_port_softint(void *private) { - struct usb_serial_port *port = (struct usb_serial_port *)private; + struct usb_serial_port *port = private; struct tty_struct *tty; dbg("%s - port %d", __FUNCTION__, port->number); -- cgit v0.10.2 From 91e79c91fab10f5790159d8d0c1d16da2a9653f9 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 13 Jul 2005 15:18:30 -0700 Subject: [PATCH] USB: Gadget library: centralize gadget controller numbers This patch centralizes the assignment of bcdDevice numbers for different gadget controllers. This won't improve the object code at all, but it does save a lot of repetitive and error-prone source code ... and will simplify the work of supporting a new controller driver, since most new gadget drivers will no longer need patches (unless some hardware quirks limit USB protocol messaging). Added minor cleanups and identifer hooks for the UDC in the Freescale iMX series processors. Signed-off-by: Alan Stern Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 8509e95..49459e3 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -2181,6 +2181,7 @@ eth_bind (struct usb_gadget *gadget) u8 cdc = 1, zlp = 1, rndis = 1; struct usb_ep *in_ep, *out_ep, *status_ep = NULL; int status = -ENOMEM; + int gcnum; /* these flags are only ever cleared; compiler take note */ #ifndef DEV_CONFIG_CDC @@ -2194,44 +2195,26 @@ eth_bind (struct usb_gadget *gadget) * standard protocol is _strongly_ preferred for interop purposes. * (By everyone except Microsoft.) */ - if (gadget_is_net2280 (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0201); - } else if (gadget_is_dummy (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0202); - } else if (gadget_is_pxa (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0203); + if (gadget_is_pxa (gadget)) { /* pxa doesn't support altsettings */ cdc = 0; } else if (gadget_is_sh(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0204); /* sh doesn't support multiple interfaces or configs */ cdc = 0; rndis = 0; } else if (gadget_is_sa1100 (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0205); /* hardware can't write zlps */ zlp = 0; /* sa1100 CAN do CDC, without status endpoint ... we use * non-CDC to be compatible with ARM Linux-2.4 "usb-eth". */ cdc = 0; - } else if (gadget_is_goku (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0206); - } else if (gadget_is_mq11xx (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0207); - } else if (gadget_is_omap (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0208); - } else if (gadget_is_lh7a40x(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0209); - } else if (gadget_is_n9604(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0210); - } else if (gadget_is_pxa27x(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0211); - } else if (gadget_is_s3c2410(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0212); - } else if (gadget_is_at91(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0213); - } else { + } + + gcnum = usb_gadget_controller_number (gadget); + if (gcnum >= 0) + device_desc.bcdDevice = cpu_to_le16 (0x0200 + gcnum); + else { /* can't assume CDC works. don't want to default to * anything less functional on CDC-capable hardware, * so we fail in this case. diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 4f57085..a41d9d4 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c @@ -3713,6 +3713,7 @@ static void fsg_unbind(struct usb_gadget *gadget) static int __init check_parameters(struct fsg_dev *fsg) { int prot; + int gcnum; /* Store the default values */ mod_data.transport_type = USB_PR_BULK; @@ -3724,33 +3725,13 @@ static int __init check_parameters(struct fsg_dev *fsg) mod_data.can_stall = 0; if (mod_data.release == 0xffff) { // Parameter wasn't set - if (gadget_is_net2280(fsg->gadget)) - mod_data.release = 0x0301; - else if (gadget_is_dummy(fsg->gadget)) - mod_data.release = 0x0302; - else if (gadget_is_pxa(fsg->gadget)) - mod_data.release = 0x0303; - else if (gadget_is_sh(fsg->gadget)) - mod_data.release = 0x0304; - /* The sa1100 controller is not supported */ - - else if (gadget_is_goku(fsg->gadget)) - mod_data.release = 0x0306; - else if (gadget_is_mq11xx(fsg->gadget)) - mod_data.release = 0x0307; - else if (gadget_is_omap(fsg->gadget)) - mod_data.release = 0x0308; - else if (gadget_is_lh7a40x(fsg->gadget)) - mod_data.release = 0x0309; - else if (gadget_is_n9604(fsg->gadget)) - mod_data.release = 0x0310; - else if (gadget_is_pxa27x(fsg->gadget)) - mod_data.release = 0x0311; - else if (gadget_is_s3c2410(gadget)) - mod_data.release = 0x0312; - else if (gadget_is_at91(fsg->gadget)) - mod_data.release = 0x0313; + if (gadget_is_sa1100(fsg->gadget)) + gcnum = -1; + else + gcnum = usb_gadget_controller_number(fsg->gadget); + if (gcnum >= 0) + mod_data.release = 0x0300 + gcnum; else { WARN(fsg, "controller '%s' not recognized\n", fsg->gadget->name); diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h index ea2eb52..8cbae21 100644 --- a/drivers/usb/gadget/gadget_chips.h +++ b/drivers/usb/gadget/gadget_chips.h @@ -5,6 +5,7 @@ * * This could eventually work like the ARM mach_is_*() stuff, driven by * some config file that gets updated as new hardware is supported. + * (And avoiding the runtime comparisons in typical one-choice cases.) * * NOTE: some of these controller drivers may not be available yet. */ @@ -86,7 +87,61 @@ #define gadget_is_at91(g) 0 #endif +#ifdef CONFIG_USB_GADGET_IMX +#define gadget_is_imx(g) !strcmp("imx_udc", (g)->name) +#else +#define gadget_is_imx(g) 0 +#endif + // CONFIG_USB_GADGET_SX2 // CONFIG_USB_GADGET_AU1X00 // ... + +/** + * usb_gadget_controller_number - support bcdDevice id convention + * @gadget: the controller being driven + * + * Return a 2-digit BCD value associated with the peripheral controller, + * suitable for use as part of a bcdDevice value, or a negative error code. + * + * NOTE: this convention is purely optional, and has no meaning in terms of + * any USB specification. If you want to use a different convention in your + * gadget driver firmware -- maybe a more formal revision ID -- feel free. + * + * Hosts see these bcdDevice numbers, and are allowed (but not encouraged!) + * to change their behavior accordingly. For example it might help avoiding + * some chip bug. + */ +static inline int usb_gadget_controller_number(struct usb_gadget *gadget) +{ + if (gadget_is_net2280(gadget)) + return 0x01; + else if (gadget_is_dummy(gadget)) + return 0x02; + else if (gadget_is_pxa(gadget)) + return 0x03; + else if (gadget_is_sh(gadget)) + return 0x04; + else if (gadget_is_sa1100(gadget)) + return 0x05; + else if (gadget_is_goku(gadget)) + return 0x06; + else if (gadget_is_mq11xx(gadget)) + return 0x07; + else if (gadget_is_omap(gadget)) + return 0x08; + else if (gadget_is_lh7a40x(gadget)) + return 0x09; + else if (gadget_is_n9604(gadget)) + return 0x10; + else if (gadget_is_pxa27x(gadget)) + return 0x11; + else if (gadget_is_s3c2410(gadget)) + return 0x12; + else if (gadget_is_at91(gadget)) + return 0x13; + else if (gadget_is_imx(gadget)) + return 0x14; + return -ENOENT; +} diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 9e4f1c6..c925d92 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c @@ -1422,49 +1422,20 @@ static int gs_bind(struct usb_gadget *gadget) int ret; struct usb_ep *ep; struct gs_dev *dev; + int gcnum; - /* device specific */ - if (gadget_is_net2280(gadget)) { - gs_device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM|0x0001); - } else if (gadget_is_pxa(gadget)) { - gs_device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM|0x0002); - } else if (gadget_is_sh(gadget)) { - gs_device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM|0x0003); - /* sh doesn't support multiple interfaces or configs */ + /* Some controllers can't support CDC ACM: + * - sh doesn't support multiple interfaces or configs; + * - sa1100 doesn't have a third interrupt endpoint + */ + if (gadget_is_sh(gadget) || gadget_is_sa1100(gadget)) use_acm = 0; - } else if (gadget_is_sa1100(gadget)) { - gs_device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM|0x0004); - /* sa1100 doesn't support necessary endpoints */ - use_acm = 0; - } else if (gadget_is_goku(gadget)) { - gs_device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM|0x0005); - } else if (gadget_is_mq11xx(gadget)) { - gs_device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM|0x0006); - } else if (gadget_is_omap(gadget)) { - gs_device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM|0x0007); - } else if (gadget_is_lh7a40x(gadget)) { - gs_device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM|0x0008); - } else if (gadget_is_n9604(gadget)) { - gs_device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM|0x0009); - } else if (gadget_is_pxa27x(gadget)) { - gs_device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM|0x0011); - } else if (gadget_is_s3c2410(gadget)) { - gs_device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM|0x0012); - } else if (gadget_is_at91(gadget)) { + + gcnum = usb_gadget_controller_number(gadget); + if (gcnum >= 0) gs_device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM|0x0013); - } else { + cpu_to_le16(GS_VERSION_NUM | gcnum); + else { printk(KERN_WARNING "gs_bind: controller '%s' not recognized\n", gadget->name); /* unrecognized, but safe unless bulk is REALLY quirky */ diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index bb9b2d9..6890e77 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c @@ -1139,6 +1139,13 @@ zero_bind (struct usb_gadget *gadget) { struct zero_dev *dev; struct usb_ep *ep; + int gcnum; + + /* FIXME this can't yet work right with SH ... it has only + * one configuration, numbered one. + */ + if (gadget_is_sh(gadget)) + return -ENODEV; /* Bulk-only drivers like this one SHOULD be able to * autoconfigure on any sane usb controller driver, @@ -1161,43 +1168,10 @@ autoconf_fail: EP_OUT_NAME = ep->name; ep->driver_data = ep; /* claim */ - - /* - * DRIVER POLICY CHOICE: you may want to do this differently. - * One thing to avoid is reusing a bcdDevice revision code - * with different host-visible configurations or behavior - * restrictions -- using ep1in/ep2out vs ep1out/ep3in, etc - */ - if (gadget_is_net2280 (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0201); - } else if (gadget_is_pxa (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0203); -#if 0 - } else if (gadget_is_sh(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0204); - /* SH has only one configuration; see "loopdefault" */ - device_desc.bNumConfigurations = 1; - /* FIXME make 1 == default.bConfigurationValue */ -#endif - } else if (gadget_is_sa1100 (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0205); - } else if (gadget_is_goku (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0206); - } else if (gadget_is_mq11xx (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0207); - } else if (gadget_is_omap (gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0208); - } else if (gadget_is_lh7a40x(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0209); - } else if (gadget_is_n9604(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0210); - } else if (gadget_is_pxa27x(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0211); - } else if (gadget_is_s3c2410(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0212); - } else if (gadget_is_at91(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0213); - } else { + gcnum = usb_gadget_controller_number (gadget); + if (gcnum >= 0) + device_desc.bcdDevice = cpu_to_le16 (0x0200 + gcnum); + else { /* gadget zero is so simple (for now, no altsettings) that * it SHOULD NOT have problems with bulk-capable hardware. * so warn about unrcognized controllers, don't panic. -- cgit v0.10.2 From ef0840286045fe7ce84cb77e7608f0844c81001c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 27 Jul 2005 01:06:19 -0700 Subject: [PATCH] USB: fix keyspan_remote endian bug on probe Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c index 67dc936..99de1b3 100644 --- a/drivers/usb/input/keyspan_remote.c +++ b/drivers/usb/input/keyspan_remote.c @@ -431,11 +431,6 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic struct usb_endpoint_descriptor *endpoint; struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface)); - /* See if the offered device matches what we can accept */ - if ((udev->descriptor.idVendor != USB_KEYSPAN_VENDOR_ID) || - (udev->descriptor.idProduct != USB_KEYSPAN_PRODUCT_UIA11) ) - return -ENODEV; - /* allocate memory for our device state and initialize it */ remote = kmalloc(sizeof(*remote), GFP_KERNEL); if (remote == NULL) { -- cgit v0.10.2 From 1694899fd1af43636351aac97f415fd3c9cefb1d Mon Sep 17 00:00:00 2001 From: Dariusz M Date: Thu, 28 Jul 2005 18:06:13 +0200 Subject: [PATCH] USB: pl2303 driver, makes pl2303HX chip work correctly This trivial patch makes pl2303 driver work correctly with pl2303HX chip. Apparently some bug in HX version of pl2303 makes the chip loose some transmitted bytes or stop working at all after reception of USB_REQ_CLEAR_FEATURE mesage. Logs generated by UsbSnoop application reveal that windows driver does not send this type of messages to the converter. From: "Dariusz M." Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 7eab5d4..4614741 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -538,8 +538,10 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp) dbg("%s - port %d", __FUNCTION__, port->number); - usb_clear_halt(serial->dev, port->write_urb->pipe); - usb_clear_halt(serial->dev, port->read_urb->pipe); + if (priv->type != HX) { + usb_clear_halt(serial->dev, port->write_urb->pipe); + usb_clear_halt(serial->dev, port->read_urb->pipe); + } buf = kmalloc(10, GFP_KERNEL); if (buf==NULL) -- cgit v0.10.2 From fdcb0a0f1b8b050cbb7ed0ea2e030741ce5bb517 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 28 Jul 2005 18:40:32 +0100 Subject: [PATCH] USB ftdi_sio: user specified VID/PID ftdi_sio: Support one user specified vendor and product ID via a couple of new module parameters. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index d1964a0..01edd62 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -269,6 +269,8 @@ #define DRIVER_DESC "USB FTDI Serial Converters Driver" static int debug; +static __u16 vendor = FTDI_VID; +static __u16 product; /* struct ftdi_sio_quirk is used by devices requiring special attention. */ struct ftdi_sio_quirk { @@ -432,7 +434,8 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) }, { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y8_PID) }, { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, - { } /* Terminating entry */ + { }, /* Optional parameter entry */ + { } /* Terminating entry */ }; MODULE_DEVICE_TABLE (usb, id_table_combined); @@ -2030,6 +2033,15 @@ static int __init ftdi_init (void) int retval; dbg("%s", __FUNCTION__); + if (vendor > 0 && product > 0) { + /* Add user specified VID/PID to reserved element of table. */ + int i; + for (i = 0; id_table_combined[i].idVendor; i++) + ; + id_table_combined[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE; + id_table_combined[i].idVendor = vendor; + id_table_combined[i].idProduct = product; + } retval = usb_serial_register(&ftdi_sio_device); if (retval) goto failed_sio_register; @@ -2066,4 +2078,9 @@ MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "Debug enabled or not"); +module_param(vendor, ushort, 0); +MODULE_PARM_DESC(vendor, "User specified vendor ID (default=" + __MODULE_STRING(FTDI_VID)")"); +module_param(product, ushort, 0); +MODULE_PARM_DESC(vendor, "User specified product ID"); -- cgit v0.10.2 From e6ac4a40e5f5c58f6e1058f6b3fb98be921dc7f4 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 2 Aug 2005 14:01:27 +0100 Subject: [PATCH] USB ftdi_sio: New IDs for ELV, Xsens and Falcom products This patch for the ftdi_sio driver adds a bunch of new devices and fixes an incorrect PID: o Fix PID for ELV UO100 (the PID was in fact for ELV UR100). o Add PID ELV UR100 (see above) and ELV ALC 8500 Expert. o Add a whole bunch of other PIDs for ELV USB devices, commented out for now as they may be used by other drivers eventually. (Christian Abt of ELV.de submitted a full list of devices including an indication of which set of drivers are used by default in the MS Windows world. We decided to comment out the devices that use FTDI's D2XX Windows drivers by default.) o Add PIDs for eight devices from Xsens Technologies BV (submitted in a patch against 2.6.12.2 by Patrick Riphagen). o Add PID for Falcom Samba GPRS modem (submitted by Sebastian Schubert). Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 01edd62..0a6e8b4 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -409,6 +409,34 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88F_PID) }, { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) }, { USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_ELV_UR100_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_ELV_ALC8500_PID) }, + /* + * These will probably use user-space drivers. Uncomment them if + * you need them or use the user-specified vendor/product module + * parameters (see ftdi_sio.h for the numbers). Make a fuss if + * you think the driver should recognize any of them by default. + */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_CLI7000_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PPS7330_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_TFM100_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_UDF77_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_UIO88_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_UAD8_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_UDA7_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_USI2_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_T1100_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCD200_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_ULA200_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1000PC_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_CSI8_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1000DL_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_RFP500_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FS20SIG_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, */ + /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, */ { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, @@ -420,6 +448,7 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) }, { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) }, { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) }, + { USB_DEVICE(FALCOM_VID, FALCOM_SAMBA_PID) }, { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) }, { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) }, { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, @@ -429,6 +458,14 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID) }, { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID) }, { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) }, + { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_0_PID) }, + { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_1_PID) }, + { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_2_PID) }, + { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_3_PID) }, + { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_4_PID) }, + { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) }, + { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) }, + { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) }, { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) }, { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) }, { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) }, diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 9f43420..2c35d74 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -142,10 +142,43 @@ /* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */ #define FTDI_USB_UIRT_PID 0xF850 /* Product Id */ -/* ELV USB Module UO100 (PID sent by Stefan Frings) */ -#define FTDI_ELV_UO100_PID 0xFB58 /* Product Id */ -/* ELV USB Module UM100 (PID sent by Arnim Laeuger) */ -#define FTDI_ELV_UM100_PID 0xFB5A /* Product Id */ +/* + * ELV USB devices submitted by Christian Abt of ELV (www.elv.de). + * All of these devices use FTDI's vendor ID (0x0403). + * + * The previously included PID for the UO 100 module was incorrect. + * In fact, that PID was for ELV's UR 100 USB-RS232 converter (0xFB58). + * + * Armin Laeuger originally sent the PID for the UM 100 module. + */ +#define FTDI_ELV_UR100_PID 0xFB58 /* USB-RS232-Umsetzer (UR 100) */ +#define FTDI_ELV_UM100_PID 0xFB5A /* USB-Modul UM 100 */ +#define FTDI_ELV_UO100_PID 0xFB5B /* USB-Modul UO 100 */ +#define FTDI_ELV_ALC8500_PID 0xF06E /* ALC 8500 Expert */ +/* Additional ELV PIDs that default to using the FTDI D2XX drivers on + * MS Windows, rather than the FTDI Virtual Com Port drivers. + * Maybe these will be easier to use with the libftdi/libusb user-space + * drivers, or possibly the Comedi drivers in some cases. */ +#define FTDI_ELV_CLI7000_PID 0xFB59 /* Computer-Light-Interface (CLI 7000) */ +#define FTDI_ELV_PPS7330_PID 0xFB5C /* Processor-Power-Supply (PPS 7330) */ +#define FTDI_ELV_TFM100_PID 0xFB5D /* Temperartur-Feuchte Messgeraet (TFM 100) */ +#define FTDI_ELV_UDF77_PID 0xFB5E /* USB DCF Funkurh (UDF 77) */ +#define FTDI_ELV_UIO88_PID 0xFB5F /* USB-I/O Interface (UIO 88) */ +#define FTDI_ELV_UAD8_PID 0xF068 /* USB-AD-Wandler (UAD 8) */ +#define FTDI_ELV_UDA7_PID 0xF069 /* USB-DA-Wandler (UDA 7) */ +#define FTDI_ELV_USI2_PID 0xF06A /* USB-Schrittmotoren-Interface (USI 2) */ +#define FTDI_ELV_T1100_PID 0xF06B /* Thermometer (T 1100) */ +#define FTDI_ELV_PCD200_PID 0xF06C /* PC-Datenlogger (PCD 200) */ +#define FTDI_ELV_ULA200_PID 0xF06D /* USB-LCD-Ansteuerung (ULA 200) */ +#define FTDI_ELV_FHZ1000PC_PID 0xF06F /* FHZ 1000 PC */ +#define FTDI_ELV_CSI8_PID 0xE0F0 /* Computer-Schalt-Interface (CSI 8) */ +#define FTDI_ELV_EM1000DL_PID 0xE0F1 /* PC-Datenlogger fuer Energiemonitor (EM 1000 DL) */ +#define FTDI_ELV_PCK100_PID 0xE0F2 /* PC-Kabeltester (PCK 100) */ +#define FTDI_ELV_RFP500_PID 0xE0F3 /* HF-Leistungsmesser (RFP 500) */ +#define FTDI_ELV_FS20SIG_PID 0xE0F4 /* Signalgeber (FS 20 SIG) */ +#define FTDI_ELV_WS300PC_PID 0xE0F6 /* PC-Wetterstation (WS 300 PC) */ +#define FTDI_ELV_FHZ1300PC_PID 0xE0E8 /* FHZ 1300 PC */ +#define FTDI_ELV_WS500_PID 0xE0E9 /* PC-Wetterstation (WS 500) */ /* * Definitions for ID TECH (www.idt-net.com) devices @@ -222,6 +255,7 @@ */ #define FALCOM_VID 0x0F94 /* Vendor Id */ #define FALCOM_TWIST_PID 0x0001 /* Falcom Twist USB GPRS modem */ +#define FALCOM_SAMBA_PID 0x0005 /* Falcom Samba USB GPRS modem */ /* * SUUNTO product ids @@ -277,6 +311,18 @@ #define FTDI_ACTIVE_ROBOTS_PID 0xE548 /* USB comms board */ /* + * Xsens Technologies BV products (http://www.xsens.com). + */ +#define XSENS_CONVERTER_0_PID 0xD388 +#define XSENS_CONVERTER_1_PID 0xD389 +#define XSENS_CONVERTER_2_PID 0xD38A +#define XSENS_CONVERTER_3_PID 0xD38B +#define XSENS_CONVERTER_4_PID 0xD38C +#define XSENS_CONVERTER_5_PID 0xD38D +#define XSENS_CONVERTER_6_PID 0xD38E +#define XSENS_CONVERTER_7_PID 0xD38F + +/* * Evolution Robotics products (http://www.evolution.com/). * Submitted by Shawn M. Lavelle. */ -- cgit v0.10.2 From 22af8878d2d641c6b15fe39fe4de3c05b2c477f0 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Thu, 4 Aug 2005 23:16:12 +0100 Subject: [PATCH] USB: Prevent hid-core claiming Apple Bluetooth device on new G4 powerbooks To recap: My new G4 powerbook has a bluetooth device that boots up in what apppears to be a compatability mode - it looks exactly like an HID keyboard/mouse device. A special command sequence is sent to switch it into full bluetooth mode. When this occurs the original HID device vanishes, and a new (bluetooth HID) USB device appears on the bus with a different product ID. The original thread is here: http://sourceforge.net/mailarchive/message.php?msg_id=12532263 The attached patch adds the device to the hid-core quirks so that hid-core ignores it. Signed-off-by: Andrew de Quincey Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index b2cb2b3..719c031 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1444,6 +1444,8 @@ void hid_init_reports(struct hid_device *hid) #define USB_DEVICE_ID_NETWORKANALYSER 0x2020 #define USB_DEVICE_ID_POWERCONTROL 0x2030 +#define USB_VENDOR_ID_APPLE 0x05ac +#define USB_DEVICE_ID_APPLE_BLUETOOTH 0x1000 /* * Alphabetically sorted blacklist by quirk type. @@ -1462,6 +1464,7 @@ static struct hid_blacklist { { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24, HID_QUIRK_IGNORE }, + { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_BLUETOOTH, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW24, HID_QUIRK_IGNORE }, -- cgit v0.10.2 From fbf82fd2e1f4e679c60516d772d1862c941ca845 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 31 Jul 2005 01:05:53 +0200 Subject: [PATCH] USB: real nodes instead of usbfs This patch introduces a /sys/class/usb_device/ class where every connected usb-device will show up: tree /sys/class/usb_device/ /sys/class/usb_device/ |-- usb1.1 | |-- dev | `-- device -> ../../../devices/pci0000:00/0000:00:1d.0/usb1 |-- usb2.1 | |-- dev | `-- device -> ../../../devices/pci0000:00/0000:00:1d.1/usb2 ... The presence of the "dev" file lets udev create real device nodes. kay@pim:~/src/linux-2.6> tree /dev/bus/usb/ /dev/bus/usb/ |-- 1 | `-- 1 |-- 2 | `-- 1 ... udev rule: SUBSYSTEM="usb_device", PROGRAM="/sbin/usb_device %k", NAME="%c" (echo $1 | /bin/sed 's/usb\([0-9]*\)\.\([0-9]*\)/bus\/usb\/\1\/\2/') This makes libusb pick up the real nodes instead of the mounted usbfs: export USB_DEVFS_PATH=/dev/bus/usb Background: All this makes it possible to manage usb devices with udev instead of the devfs solution. We are currently working on a pam_console/resmgr replacement driven by udev and a pam-helper. It applies ACL's to device nodes, which is required for modern desktop functionalty like "Fast User Switching" or multiple local login support. New patch with its own major. I've succesfully disabled usbfs and use real nodes only on my box. With: "export USB_DEVFS_PATH=/dev/bus/usb" libusb picks up the udev managed nodes instead of reading usbfs files. This makes udev to provide symlinks for libusb to pick up: SUBSYSTEM="usb_device", PROGRAM="/sbin/usbdevice %k", SYMLINK="%c" /sbin/usbdevice: #!/bin/sh echo $1 | /bin/sed 's/usbdev\([0-9]*\)\.\([0-9]*\)/bus\/usb\/\1\/\2/' Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile index 9e8c377..d5503cf 100644 --- a/drivers/usb/core/Makefile +++ b/drivers/usb/core/Makefile @@ -3,14 +3,14 @@ # usbcore-objs := usb.o hub.o hcd.o urb.o message.o \ - config.o file.o buffer.o sysfs.o + config.o file.o buffer.o sysfs.o devio.o ifeq ($(CONFIG_PCI),y) usbcore-objs += hcd-pci.o endif ifeq ($(CONFIG_USB_DEVICEFS),y) - usbcore-objs += devio.o inode.o devices.o + usbcore-objs += inode.o devices.o endif obj-$(CONFIG_USB) += usbcore.o diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index f86bf14..d12bc5e 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,10 @@ #include "hcd.h" /* for usbcore internals */ #include "usb.h" +#define USB_MAXBUS 64 +#define USB_DEVICE_MAX USB_MAXBUS * 128 +static struct class *usb_device_class; + struct async { struct list_head asynclist; struct dev_state *ps; @@ -487,7 +492,7 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, unsig */ static int usbdev_open(struct inode *inode, struct file *file) { - struct usb_device *dev; + struct usb_device *dev = NULL; struct dev_state *ps; int ret; @@ -501,11 +506,16 @@ static int usbdev_open(struct inode *inode, struct file *file) lock_kernel(); ret = -ENOENT; - dev = usb_get_dev(inode->u.generic_ip); + /* check if we are called from a real node or usbfs */ + if (imajor(inode) == USB_DEVICE_MAJOR) + dev = usbdev_lookup_minor(iminor(inode)); + if (!dev) + dev = inode->u.generic_ip; if (!dev) { kfree(ps); goto out; } + usb_get_dev(dev); ret = 0; ps->dev = dev; ps->file = file; @@ -1477,3 +1487,80 @@ struct file_operations usbfs_device_file_operations = { .open = usbdev_open, .release = usbdev_release, }; + +struct usb_device *usbdev_lookup_minor(int minor) +{ + struct class_device *class_dev; + struct usb_device *dev = NULL; + + down(&usb_device_class->sem); + list_for_each_entry(class_dev, &usb_device_class->children, node) { + if (class_dev->devt == MKDEV(USB_DEVICE_MAJOR, minor)) { + dev = class_dev->class_data; + break; + } + } + up(&usb_device_class->sem); + + return dev; +}; + +void usbdev_add(struct usb_device *dev) +{ + int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); + + dev->class_dev = class_device_create(usb_device_class, + MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, + "usbdev%d.%d", dev->bus->busnum, dev->devnum); + + dev->class_dev->class_data = dev; +} + +void usbdev_remove(struct usb_device *dev) +{ + class_device_unregister(dev->class_dev); +} + +static struct cdev usb_device_cdev = { + .kobj = {.name = "usb_device", }, + .owner = THIS_MODULE, +}; + +int __init usbdev_init(void) +{ + int retval; + + retval = register_chrdev_region(MKDEV(USB_DEVICE_MAJOR, 0), + USB_DEVICE_MAX, "usb_device"); + if (retval) { + err("unable to register minors for usb_device"); + goto out; + } + cdev_init(&usb_device_cdev, &usbfs_device_file_operations); + retval = cdev_add(&usb_device_cdev, + MKDEV(USB_DEVICE_MAJOR, 0), USB_DEVICE_MAX); + if (retval) { + err("unable to get usb_device major %d", USB_DEVICE_MAJOR); + unregister_chrdev_region(USB_DEVICE_MAJOR, USB_DEVICE_MAX); + goto out; + } + usb_device_class = class_create(THIS_MODULE, "usb_device"); + if (IS_ERR(usb_device_class)) { + err("unable to register usb_device class"); + retval = PTR_ERR(usb_device_class); + usb_device_class = NULL; + cdev_del(&usb_device_cdev); + unregister_chrdev_region(USB_DEVICE_MAJOR, USB_DEVICE_MAX); + } + +out: + return retval; +} + +void usbdev_cleanup(void) +{ + class_destroy(usb_device_class); + cdev_del(&usb_device_cdev); + unregister_chrdev_region(USB_DEVICE_MAJOR, USB_DEVICE_MAX); +} + diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index c9412da..a220a5e 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1051,6 +1051,7 @@ void usb_disconnect(struct usb_device **pdev) dev_dbg (&udev->dev, "unregistering device\n"); release_address(udev); usbfs_remove_device(udev); + usbdev_remove(udev); usb_remove_sysfs_dev_files(udev); /* Avoid races with recursively_mark_NOTATTACHED() */ @@ -1290,6 +1291,7 @@ int usb_new_device(struct usb_device *udev) /* USB device state == configured ... usable */ /* add a /proc/bus/usb entry */ + usbdev_add(udev); usbfs_add_device(udev); return 0; diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index c3e3a95..640f41e 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c @@ -728,15 +728,9 @@ int __init usbfs_init(void) { int retval; - retval = usb_register(&usbfs_driver); - if (retval) - return retval; - retval = register_filesystem(&usb_fs_type); - if (retval) { - usb_deregister(&usbfs_driver); + if (retval) return retval; - } /* create mount point for usbfs */ usbdir = proc_mkdir("usb", proc_bus); @@ -746,7 +740,6 @@ int __init usbfs_init(void) void usbfs_cleanup(void) { - usb_deregister(&usbfs_driver); unregister_filesystem(&usb_fs_type); if (usbdir) remove_proc_entry("usb", proc_bus); diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 2cddd8a..bc966db 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -1478,13 +1478,18 @@ static int __init usb_init(void) retval = usb_major_init(); if (retval) goto major_init_failed; + retval = usb_register(&usbfs_driver); + if (retval) + goto driver_register_failed; + retval = usbdev_init(); + if (retval) + goto usbdevice_init_failed; retval = usbfs_init(); if (retval) goto fs_init_failed; retval = usb_hub_init(); if (retval) goto hub_init_failed; - retval = driver_register(&usb_generic_driver); if (!retval) goto out; @@ -1493,7 +1498,11 @@ static int __init usb_init(void) hub_init_failed: usbfs_cleanup(); fs_init_failed: - usb_major_cleanup(); + usbdev_cleanup(); +usbdevice_init_failed: + usb_deregister(&usbfs_driver); +driver_register_failed: + usb_major_cleanup(); major_init_failed: usb_host_cleanup(); host_init_failed: @@ -1514,6 +1523,8 @@ static void __exit usb_exit(void) driver_unregister(&usb_generic_driver); usb_major_cleanup(); usbfs_cleanup(); + usb_deregister(&usbfs_driver); + usbdev_cleanup(); usb_hub_cleanup(); usb_host_cleanup(); bus_unregister(&usb_bus_type); diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 2c690f6..83d48c8 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -37,6 +37,11 @@ extern struct file_operations usbfs_devices_fops; extern struct file_operations usbfs_device_file_operations; extern void usbfs_conn_disc_event(void); +extern int usbdev_init(void); +extern void usbdev_cleanup(void); +extern void usbdev_add(struct usb_device *dev); +extern void usbdev_remove(struct usb_device *dev); +extern struct usb_device *usbdev_lookup_minor(int minor); struct dev_state { struct list_head list; /* state list */ diff --git a/include/linux/usb.h b/include/linux/usb.h index 7246377..434e351 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -5,6 +5,7 @@ #include #define USB_MAJOR 180 +#define USB_DEVICE_MAJOR 189 #ifdef __KERNEL__ @@ -349,6 +350,7 @@ struct usb_device { char *manufacturer; char *serial; /* static strings from the device */ struct list_head filelist; + struct class_device *class_dev; struct dentry *usbfs_dentry; /* usbfs dentry entry for the device */ /* -- cgit v0.10.2 From fad21bdf56a25e1cb3e92bba33349de368e8f0b0 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 10 Aug 2005 15:15:57 -0400 Subject: [PATCH] USB: Fix regression in core/devio.c This patch (as551) fixes another little problem recently added to the USB core. Someone didn't fix the type of the first argument to unregister_chrdev_region. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index d12bc5e..56c082f 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -76,6 +76,8 @@ MODULE_PARM_DESC (usbfs_snoop, "true to log all usbfs traffic"); dev_info( dev , format , ## arg); \ } while (0) +#define USB_DEVICE_DEV MKDEV(USB_DEVICE_MAJOR, 0) + #define MAX_USBFS_BUFFER_SIZE 16384 @@ -1530,18 +1532,17 @@ int __init usbdev_init(void) { int retval; - retval = register_chrdev_region(MKDEV(USB_DEVICE_MAJOR, 0), - USB_DEVICE_MAX, "usb_device"); + retval = register_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX, + "usb_device"); if (retval) { err("unable to register minors for usb_device"); goto out; } cdev_init(&usb_device_cdev, &usbfs_device_file_operations); - retval = cdev_add(&usb_device_cdev, - MKDEV(USB_DEVICE_MAJOR, 0), USB_DEVICE_MAX); + retval = cdev_add(&usb_device_cdev, USB_DEVICE_DEV, USB_DEVICE_MAX); if (retval) { err("unable to get usb_device major %d", USB_DEVICE_MAJOR); - unregister_chrdev_region(USB_DEVICE_MAJOR, USB_DEVICE_MAX); + unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX); goto out; } usb_device_class = class_create(THIS_MODULE, "usb_device"); @@ -1550,7 +1551,7 @@ int __init usbdev_init(void) retval = PTR_ERR(usb_device_class); usb_device_class = NULL; cdev_del(&usb_device_cdev); - unregister_chrdev_region(USB_DEVICE_MAJOR, USB_DEVICE_MAX); + unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX); } out: @@ -1561,6 +1562,6 @@ void usbdev_cleanup(void) { class_destroy(usb_device_class); cdev_del(&usb_device_cdev); - unregister_chrdev_region(USB_DEVICE_MAJOR, USB_DEVICE_MAX); + unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX); } -- cgit v0.10.2 From 64be07585893d207d23f8516948222faf746aa43 Mon Sep 17 00:00:00 2001 From: Mihnea-Costin Grigore Date: Fri, 29 Jul 2005 13:48:48 +0300 Subject: [PATCH] usb-storage: Add IGNORE_RESIDUE flag for Mitsumi USB 2.0 card reader (VIA hardware) This patch adds an entry in the unusual_devs.h file for a Mitsumi card reader/floppy combo that uses a VIA chipset. The IGNORE_RESIDUE flag was needed for the second LUN to operate properly. Signed-off-by: Mihnea-Costin Grigore Signed-off-by: Phil Dibowitz Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index bd0ab30..e7ed835 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -79,6 +79,13 @@ UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001, US_SC_8070, US_PR_SCM_ATAPI, init_usbat, 0), #endif +/* Patch submitted by Mihnea-Costin Grigore */ +UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003, + "VIA Technologies Inc.", + "USB 2.0 Card Reader", + US_SC_DEVICE, US_PR_DEVICE, NULL, + US_FL_IGNORE_RESIDUE ), + /* Deduced by Jonathan Woithe * Entry needed for flags: US_FL_FIX_INQUIRY because initial inquiry message * always fails and confuses drive. -- cgit v0.10.2 From ba6abf1352dc83e500a71e3ad9b39de0337f0c6b Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Sat, 30 Jul 2005 22:38:30 -0700 Subject: [PATCH] USB: ub 1/3: Axboe's quasi-S/G This the quasi-S/G patch for ub as suggested by Jens Axboe at OLS and implemented that night before 4 a.m. Surprisingly, it worked right away... Alas, I had to skip some OLS partying, but it was for the good cause. Now the speed of ub is quite acceptable even on partitions with small block size. The ub does not really support S/G. Instead, it just tells the block layer that it does. Then, most of the time, the block layer merges requests and passes single-segmnent requests down to ub; everything works as before. Very rarely ub gets an unmerged S/G request. In such case, it issues several commands to the device. I added a small array of counters to monitor the merging (sg_stat). This may be dropped later. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/block/ub.c b/drivers/block/ub.c index a026567..fb3d1e9 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -16,9 +16,10 @@ * -- verify the 13 conditions and do bulk resets * -- kill last_pipe and simply do two-state clearing on both pipes * -- verify protocol (bulk) from USB descriptors (maybe...) - * -- highmem and sg + * -- highmem * -- move top_sense and work_bcs into separate allocations (if they survive) * for cache purists and esoteric architectures. + * -- Allocate structure for LUN 0 before the first ub_sync_tur, avoid NULL. ? * -- prune comments, they are too volumnous * -- Exterminate P3 printks * -- Resove XXX's @@ -171,7 +172,7 @@ struct bulk_cs_wrap { */ struct ub_dev; -#define UB_MAX_REQ_SG 1 +#define UB_MAX_REQ_SG 4 #define UB_MAX_SECTORS 64 /* @@ -240,13 +241,21 @@ struct ub_scsi_cmd { */ char *data; /* Requested buffer */ unsigned int len; /* Requested length */ - // struct scatterlist sgv[UB_MAX_REQ_SG]; struct ub_lun *lun; void (*done)(struct ub_dev *, struct ub_scsi_cmd *); void *back; }; +struct ub_request { + struct request *rq; + unsigned char dir; + unsigned int current_block; + unsigned int current_sg; + unsigned int nsg; /* sgv[nsg] */ + struct scatterlist sgv[UB_MAX_REQ_SG]; +}; + /* */ struct ub_capacity { @@ -342,6 +351,8 @@ struct ub_lun { int readonly; int first_open; /* Kludge. See ub_bd_open. */ + struct ub_request urq; + /* Use Ingo's mempool if or when we have more than one command. */ /* * Currently we never need more than one command for the whole device. @@ -389,6 +400,7 @@ struct ub_dev { struct bulk_cs_wrap work_bcs; struct usb_ctrlrequest work_cr; + int sg_stat[UB_MAX_REQ_SG+1]; struct ub_scsi_trace tr; }; @@ -398,10 +410,14 @@ static void ub_cleanup(struct ub_dev *sc); static int ub_bd_rq_fn_1(struct ub_lun *lun, struct request *rq); static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, struct ub_scsi_cmd *cmd, struct request *rq); -static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_scsi_cmd *cmd, - struct request *rq); +static void ub_scsi_build_block(struct ub_lun *lun, + struct ub_scsi_cmd *cmd, struct ub_request *urq); +static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, + struct ub_scsi_cmd *cmd, struct request *rq); static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); static void ub_end_rq(struct request *rq, int uptodate); +static int ub_request_advance(struct ub_dev *sc, struct ub_lun *lun, + struct ub_request *urq, struct ub_scsi_cmd *cmd); static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd); static void ub_urb_complete(struct urb *urb, struct pt_regs *pt); static void ub_scsi_action(unsigned long _dev); @@ -523,6 +539,13 @@ static ssize_t ub_diag_show(struct device *dev, struct device_attribute *attr, c cnt += sprintf(page + cnt, "qlen %d qmax %d\n", sc->cmd_queue.qlen, sc->cmd_queue.qmax); + cnt += sprintf(page + cnt, + "sg %d %d %d %d %d\n", + sc->sg_stat[0], + sc->sg_stat[1], + sc->sg_stat[2], + sc->sg_stat[3], + sc->sg_stat[4]); list_for_each (p, &sc->luns) { lun = list_entry(p, struct ub_lun, link); @@ -769,14 +792,15 @@ static int ub_bd_rq_fn_1(struct ub_lun *lun, struct request *rq) return 0; } + if (lun->urq.rq != NULL) + return -1; if ((cmd = ub_get_cmd(lun)) == NULL) return -1; memset(cmd, 0, sizeof(struct ub_scsi_cmd)); blkdev_dequeue_request(rq); - if (blk_pc_request(rq)) { - rc = ub_cmd_build_packet(sc, cmd, rq); + rc = ub_cmd_build_packet(sc, lun, cmd, rq); } else { rc = ub_cmd_build_block(sc, lun, cmd, rq); } @@ -788,10 +812,10 @@ static int ub_bd_rq_fn_1(struct ub_lun *lun, struct request *rq) cmd->state = UB_CMDST_INIT; cmd->lun = lun; cmd->done = ub_rw_cmd_done; - cmd->back = rq; + cmd->back = &lun->urq; cmd->tag = sc->tagcnt++; - if ((rc = ub_submit_scsi(sc, cmd)) != 0) { + if (ub_submit_scsi(sc, cmd) != 0) { ub_put_cmd(lun, cmd); ub_end_rq(rq, 0); return 0; @@ -803,12 +827,12 @@ static int ub_bd_rq_fn_1(struct ub_lun *lun, struct request *rq) static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, struct ub_scsi_cmd *cmd, struct request *rq) { + struct ub_request *urq; int ub_dir; -#if 0 /* We use rq->buffer for now */ - struct scatterlist *sg; int n_elem; -#endif - unsigned int block, nblks; + + urq = &lun->urq; + memset(urq, 0, sizeof(struct ub_request)); if (rq_data_dir(rq) == WRITE) ub_dir = UB_DIR_WRITE; @@ -818,44 +842,19 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, /* * get scatterlist from block layer */ -#if 0 /* We use rq->buffer for now */ - sg = &cmd->sgv[0]; - n_elem = blk_rq_map_sg(q, rq, sg); + n_elem = blk_rq_map_sg(lun->disk->queue, rq, &urq->sgv[0]); if (n_elem <= 0) { - ub_put_cmd(lun, cmd); - ub_end_rq(rq, 0); - blk_start_queue(q); - return 0; /* request with no s/g entries? */ + printk(KERN_INFO "%s: failed request map (%d)\n", + sc->name, n_elem); /* P3 */ + return -1; /* request with no s/g entries? */ } - - if (n_elem != 1) { /* Paranoia */ + if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */ printk(KERN_WARNING "%s: request with %d segments\n", sc->name, n_elem); - ub_put_cmd(lun, cmd); - ub_end_rq(rq, 0); - blk_start_queue(q); - return 0; - } -#endif - - /* - * XXX Unfortunately, this check does not work. It is quite possible - * to get bogus non-null rq->buffer if you allow sg by mistake. - */ - if (rq->buffer == NULL) { - /* - * This must not happen if we set the queue right. - * The block level must create bounce buffers for us. - */ - static int do_print = 1; - if (do_print) { - printk(KERN_WARNING "%s: unmapped block request" - " flags 0x%lx sectors %lu\n", - sc->name, rq->flags, rq->nr_sectors); - do_print = 0; - } return -1; } + urq->nsg = n_elem; + sc->sg_stat[n_elem]++; /* * build the command @@ -863,10 +862,29 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, * The call to blk_queue_hardsect_size() guarantees that request * is aligned, but it is given in terms of 512 byte units, always. */ - block = rq->sector >> lun->capacity.bshift; - nblks = rq->nr_sectors >> lun->capacity.bshift; + urq->current_block = rq->sector >> lun->capacity.bshift; + // nblks = rq->nr_sectors >> lun->capacity.bshift; + + urq->rq = rq; + urq->current_sg = 0; + urq->dir = ub_dir; + + ub_scsi_build_block(lun, cmd, urq); + return 0; +} + +static void ub_scsi_build_block(struct ub_lun *lun, + struct ub_scsi_cmd *cmd, struct ub_request *urq) +{ + struct scatterlist *sg; + unsigned int block, nblks; + + sg = &urq->sgv[urq->current_sg]; + + block = urq->current_block; + nblks = sg->length >> (lun->capacity.bshift + 9); - cmd->cdb[0] = (ub_dir == UB_DIR_READ)? READ_10: WRITE_10; + cmd->cdb[0] = (urq->dir == UB_DIR_READ)? READ_10: WRITE_10; /* 10-byte uses 4 bytes of LBA: 2147483648KB, 2097152MB, 2048GB */ cmd->cdb[2] = block >> 24; cmd->cdb[3] = block >> 16; @@ -876,16 +894,20 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, cmd->cdb[8] = nblks; cmd->cdb_len = 10; - cmd->dir = ub_dir; - cmd->data = rq->buffer; - cmd->len = rq->nr_sectors * 512; - - return 0; + cmd->dir = urq->dir; + cmd->data = page_address(sg->page) + sg->offset; + cmd->len = sg->length; } -static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_scsi_cmd *cmd, - struct request *rq) +static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, + struct ub_scsi_cmd *cmd, struct request *rq) { + struct ub_request *urq; + + urq = &lun->urq; + memset(urq, 0, sizeof(struct ub_request)); + urq->rq = rq; + sc->sg_stat[0]++; if (rq->data_len != 0 && rq->data == NULL) { static int do_print = 1; @@ -917,12 +939,13 @@ static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_scsi_cmd *cmd, static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) { - struct request *rq = cmd->back; struct ub_lun *lun = cmd->lun; - struct gendisk *disk = lun->disk; - request_queue_t *q = disk->queue; + struct ub_request *urq = cmd->back; + struct request *rq; int uptodate; + rq = urq->rq; + if (blk_pc_request(rq)) { /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */ memcpy(rq->sense, sc->top_sense, UB_SENSE_SIZE); @@ -934,9 +957,19 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) else uptodate = 0; + if (cmd->error == 0 && urq->current_sg+1 < urq->nsg) { + if (ub_request_advance(sc, lun, urq, cmd) == 0) { + /* Stay on target... */ + return; + } + uptodate = 0; + } + + urq->rq = NULL; + ub_put_cmd(lun, cmd); ub_end_rq(rq, uptodate); - blk_start_queue(q); + blk_start_queue(lun->disk->queue); } static void ub_end_rq(struct request *rq, int uptodate) @@ -948,6 +981,40 @@ static void ub_end_rq(struct request *rq, int uptodate) end_that_request_last(rq); } +static int ub_request_advance(struct ub_dev *sc, struct ub_lun *lun, + struct ub_request *urq, struct ub_scsi_cmd *cmd) +{ + struct scatterlist *sg; + unsigned int nblks; + + /* XXX This is temporary, until we sort out S/G in packet requests. */ + if (blk_pc_request(urq->rq)) { + printk(KERN_WARNING + "2-segment packet request completed\n"); /* P3 */ + return -1; + } + + sg = &urq->sgv[urq->current_sg]; + nblks = sg->length >> (lun->capacity.bshift + 9); + urq->current_block += nblks; + urq->current_sg++; + sg++; + + memset(cmd, 0, sizeof(struct ub_scsi_cmd)); + ub_scsi_build_block(lun, cmd, urq); + cmd->state = UB_CMDST_INIT; + cmd->lun = lun; + cmd->done = ub_rw_cmd_done; + cmd->back = &lun->urq; + + cmd->tag = sc->tagcnt++; + if (ub_submit_scsi(sc, cmd) != 0) { + return -1; + } + + return 0; +} + /* * Submit a regular SCSI operation (not an auto-sense). * -- cgit v0.10.2 From 07d4fd2566ddbf2a91ff3cde80ddf449ab82c381 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Sat, 30 Jul 2005 22:51:45 -0700 Subject: [PATCH] USB: ub 2/3: Fold one line Evidently, Yani Ioannou's display is wider than mine. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/block/ub.c b/drivers/block/ub.c index fb3d1e9..fe81d2f 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -516,7 +516,8 @@ static void ub_cmdtr_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd, } } -static ssize_t ub_diag_show(struct device *dev, struct device_attribute *attr, char *page) +static ssize_t ub_diag_show(struct device *dev, struct device_attribute *attr, + char *page) { struct usb_interface *intf; struct ub_dev *sc; -- cgit v0.10.2 From 6c1eb8c1c3ec2df00b629ab4fe7fe04a95129f08 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Sat, 30 Jul 2005 22:51:52 -0700 Subject: [PATCH] USB: ub 3/3: death to ub_bd_rq_fn_1 When Al Viro saw the ub.c, he observed that it was a proof positive of Linus not reading patches anymore: names like fo_ob_ar_ba_2 used to cause serious fireworks. In my defence, any good scheme can be pushed to the realm of absurd if pushed far enough. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/block/ub.c b/drivers/block/ub.c index fe81d2f..6925532 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -407,7 +407,7 @@ struct ub_dev { /* */ static void ub_cleanup(struct ub_dev *sc); -static int ub_bd_rq_fn_1(struct ub_lun *lun, struct request *rq); +static int ub_request_fn_1(struct ub_lun *lun, struct request *rq); static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, struct ub_scsi_cmd *cmd, struct request *rq); static void ub_scsi_build_block(struct ub_lun *lun, @@ -768,20 +768,20 @@ static struct ub_scsi_cmd *ub_cmdq_pop(struct ub_dev *sc) * The request function is our main entry point */ -static void ub_bd_rq_fn(request_queue_t *q) +static void ub_request_fn(request_queue_t *q) { struct ub_lun *lun = q->queuedata; struct request *rq; while ((rq = elv_next_request(q)) != NULL) { - if (ub_bd_rq_fn_1(lun, rq) != 0) { + if (ub_request_fn_1(lun, rq) != 0) { blk_stop_queue(q); break; } } } -static int ub_bd_rq_fn_1(struct ub_lun *lun, struct request *rq) +static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) { struct ub_dev *sc = lun->udev; struct ub_scsi_cmd *cmd; @@ -2357,7 +2357,7 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum) disk->driverfs_dev = &sc->intf->dev; /* XXX Many to one ok? */ rc = -ENOMEM; - if ((q = blk_init_queue(ub_bd_rq_fn, &sc->lock)) == NULL) + if ((q = blk_init_queue(ub_request_fn, &sc->lock)) == NULL) goto err_blkqinit; disk->queue = q; -- cgit v0.10.2 From a1cf96efbabac2f8af6f75286ffcefd40b0a466c Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Sun, 14 Aug 2005 21:16:03 -0700 Subject: [PATCH] USB: ub 4: Zaitcev's quasi-S/G Back out Axboe-style quasi-S/G and replace it with one command and repeated URBs. This is similar to what usb-storage does, only instead of a few URBs allocated together, one URB is reused. Jens's idea was very nice, but it collapsed when I had to support packet commads for CD burning. I cannot issue two or more packet commands where application expected only one. However, burning does not work completely yet. The cdrecord starts, recognizes the device, then aborts without writing a TOC. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 6925532..57d3279 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -235,27 +235,16 @@ struct ub_scsi_cmd { int stat_count; /* Retries getting status. */ - /* - * We do not support transfers from highmem pages - * because the underlying USB framework does not do what we need. - */ - char *data; /* Requested buffer */ unsigned int len; /* Requested length */ + unsigned int current_sg; + unsigned int nsg; /* sgv[nsg] */ + struct scatterlist sgv[UB_MAX_REQ_SG]; struct ub_lun *lun; void (*done)(struct ub_dev *, struct ub_scsi_cmd *); void *back; }; -struct ub_request { - struct request *rq; - unsigned char dir; - unsigned int current_block; - unsigned int current_sg; - unsigned int nsg; /* sgv[nsg] */ - struct scatterlist sgv[UB_MAX_REQ_SG]; -}; - /* */ struct ub_capacity { @@ -351,8 +340,6 @@ struct ub_lun { int readonly; int first_open; /* Kludge. See ub_bd_open. */ - struct ub_request urq; - /* Use Ingo's mempool if or when we have more than one command. */ /* * Currently we never need more than one command for the whole device. @@ -410,19 +397,16 @@ static void ub_cleanup(struct ub_dev *sc); static int ub_request_fn_1(struct ub_lun *lun, struct request *rq); static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, struct ub_scsi_cmd *cmd, struct request *rq); -static void ub_scsi_build_block(struct ub_lun *lun, - struct ub_scsi_cmd *cmd, struct ub_request *urq); static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, struct ub_scsi_cmd *cmd, struct request *rq); static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); static void ub_end_rq(struct request *rq, int uptodate); -static int ub_request_advance(struct ub_dev *sc, struct ub_lun *lun, - struct ub_request *urq, struct ub_scsi_cmd *cmd); static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd); static void ub_urb_complete(struct urb *urb, struct pt_regs *pt); static void ub_scsi_action(unsigned long _dev); static void ub_scsi_dispatch(struct ub_dev *sc); static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd); +static void ub_data_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd); static void ub_state_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd, int rc); static int __ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd); static void ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd); @@ -793,8 +777,6 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) return 0; } - if (lun->urq.rq != NULL) - return -1; if ((cmd = ub_get_cmd(lun)) == NULL) return -1; memset(cmd, 0, sizeof(struct ub_scsi_cmd)); @@ -813,7 +795,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) cmd->state = UB_CMDST_INIT; cmd->lun = lun; cmd->done = ub_rw_cmd_done; - cmd->back = &lun->urq; + cmd->back = rq; cmd->tag = sc->tagcnt++; if (ub_submit_scsi(sc, cmd) != 0) { @@ -828,22 +810,20 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, struct ub_scsi_cmd *cmd, struct request *rq) { - struct ub_request *urq; int ub_dir; int n_elem; - - urq = &lun->urq; - memset(urq, 0, sizeof(struct ub_request)); + unsigned int block, nblks; if (rq_data_dir(rq) == WRITE) ub_dir = UB_DIR_WRITE; else ub_dir = UB_DIR_READ; + cmd->dir = ub_dir; /* * get scatterlist from block layer */ - n_elem = blk_rq_map_sg(lun->disk->queue, rq, &urq->sgv[0]); + n_elem = blk_rq_map_sg(lun->disk->queue, rq, &cmd->sgv[0]); if (n_elem <= 0) { printk(KERN_INFO "%s: failed request map (%d)\n", sc->name, n_elem); /* P3 */ @@ -854,7 +834,7 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, sc->name, n_elem); return -1; } - urq->nsg = n_elem; + cmd->nsg = n_elem; sc->sg_stat[n_elem]++; /* @@ -863,29 +843,10 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, * The call to blk_queue_hardsect_size() guarantees that request * is aligned, but it is given in terms of 512 byte units, always. */ - urq->current_block = rq->sector >> lun->capacity.bshift; - // nblks = rq->nr_sectors >> lun->capacity.bshift; - - urq->rq = rq; - urq->current_sg = 0; - urq->dir = ub_dir; + block = rq->sector >> lun->capacity.bshift; + nblks = rq->nr_sectors >> lun->capacity.bshift; - ub_scsi_build_block(lun, cmd, urq); - return 0; -} - -static void ub_scsi_build_block(struct ub_lun *lun, - struct ub_scsi_cmd *cmd, struct ub_request *urq) -{ - struct scatterlist *sg; - unsigned int block, nblks; - - sg = &urq->sgv[urq->current_sg]; - - block = urq->current_block; - nblks = sg->length >> (lun->capacity.bshift + 9); - - cmd->cdb[0] = (urq->dir == UB_DIR_READ)? READ_10: WRITE_10; + cmd->cdb[0] = (ub_dir == UB_DIR_READ)? READ_10: WRITE_10; /* 10-byte uses 4 bytes of LBA: 2147483648KB, 2097152MB, 2048GB */ cmd->cdb[2] = block >> 24; cmd->cdb[3] = block >> 16; @@ -895,34 +856,15 @@ static void ub_scsi_build_block(struct ub_lun *lun, cmd->cdb[8] = nblks; cmd->cdb_len = 10; - cmd->dir = urq->dir; - cmd->data = page_address(sg->page) + sg->offset; - cmd->len = sg->length; + cmd->len = rq->nr_sectors * 512; + + return 0; } static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, struct ub_scsi_cmd *cmd, struct request *rq) { - struct ub_request *urq; - - urq = &lun->urq; - memset(urq, 0, sizeof(struct ub_request)); - urq->rq = rq; - sc->sg_stat[0]++; - - if (rq->data_len != 0 && rq->data == NULL) { - static int do_print = 1; - if (do_print) { - printk(KERN_WARNING "%s: unmapped packet request" - " flags 0x%lx length %d\n", - sc->name, rq->flags, rq->data_len); - do_print = 0; - } - return -1; - } - - memcpy(&cmd->cdb, rq->cmd, rq->cmd_len); - cmd->cdb_len = rq->cmd_len; + int n_elem; if (rq->data_len == 0) { cmd->dir = UB_DIR_NONE; @@ -931,8 +873,29 @@ static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, cmd->dir = UB_DIR_WRITE; else cmd->dir = UB_DIR_READ; + } - cmd->data = rq->data; + + /* + * get scatterlist from block layer + */ + n_elem = blk_rq_map_sg(lun->disk->queue, rq, &cmd->sgv[0]); + if (n_elem < 0) { + printk(KERN_INFO "%s: failed request map (%d)\n", + sc->name, n_elem); /* P3 */ + return -1; + } + if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */ + printk(KERN_WARNING "%s: request with %d segments\n", + sc->name, n_elem); + return -1; + } + cmd->nsg = n_elem; + sc->sg_stat[n_elem]++; + + memcpy(&cmd->cdb, rq->cmd, rq->cmd_len); + cmd->cdb_len = rq->cmd_len; + cmd->len = rq->data_len; return 0; @@ -940,33 +903,32 @@ static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) { + struct request *rq = cmd->back; struct ub_lun *lun = cmd->lun; - struct ub_request *urq = cmd->back; - struct request *rq; int uptodate; - rq = urq->rq; - - if (blk_pc_request(rq)) { - /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */ - memcpy(rq->sense, sc->top_sense, UB_SENSE_SIZE); - rq->sense_len = UB_SENSE_SIZE; - } - - if (cmd->error == 0) + if (cmd->error == 0) { uptodate = 1; - else - uptodate = 0; - if (cmd->error == 0 && urq->current_sg+1 < urq->nsg) { - if (ub_request_advance(sc, lun, urq, cmd) == 0) { - /* Stay on target... */ - return; + if (blk_pc_request(rq)) { + if (cmd->act_len >= rq->data_len) + rq->data_len = 0; + else + rq->data_len -= cmd->act_len; } + } else { uptodate = 0; - } - urq->rq = NULL; + if (blk_pc_request(rq)) { + /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */ + memcpy(rq->sense, sc->top_sense, UB_SENSE_SIZE); + rq->sense_len = UB_SENSE_SIZE; + if (sc->top_sense[0] != 0) + rq->errors = SAM_STAT_CHECK_CONDITION; + else + rq->errors = DID_ERROR << 16; + } + } ub_put_cmd(lun, cmd); ub_end_rq(rq, uptodate); @@ -982,40 +944,6 @@ static void ub_end_rq(struct request *rq, int uptodate) end_that_request_last(rq); } -static int ub_request_advance(struct ub_dev *sc, struct ub_lun *lun, - struct ub_request *urq, struct ub_scsi_cmd *cmd) -{ - struct scatterlist *sg; - unsigned int nblks; - - /* XXX This is temporary, until we sort out S/G in packet requests. */ - if (blk_pc_request(urq->rq)) { - printk(KERN_WARNING - "2-segment packet request completed\n"); /* P3 */ - return -1; - } - - sg = &urq->sgv[urq->current_sg]; - nblks = sg->length >> (lun->capacity.bshift + 9); - urq->current_block += nblks; - urq->current_sg++; - sg++; - - memset(cmd, 0, sizeof(struct ub_scsi_cmd)); - ub_scsi_build_block(lun, cmd, urq); - cmd->state = UB_CMDST_INIT; - cmd->lun = lun; - cmd->done = ub_rw_cmd_done; - cmd->back = &lun->urq; - - cmd->tag = sc->tagcnt++; - if (ub_submit_scsi(sc, cmd) != 0) { - return -1; - } - - return 0; -} - /* * Submit a regular SCSI operation (not an auto-sense). * @@ -1171,7 +1099,6 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) { struct urb *urb = &sc->work_urb; struct bulk_cs_wrap *bcs; - int pipe; int rc; if (atomic_read(&sc->poison)) { @@ -1272,38 +1199,13 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) goto Bad_End; } - if (cmd->dir == UB_DIR_NONE) { + if (cmd->dir == UB_DIR_NONE || cmd->nsg < 1) { ub_state_stat(sc, cmd); return; } - UB_INIT_COMPLETION(sc->work_done); - - if (cmd->dir == UB_DIR_READ) - pipe = sc->recv_bulk_pipe; - else - pipe = sc->send_bulk_pipe; - sc->last_pipe = pipe; - usb_fill_bulk_urb(&sc->work_urb, sc->dev, pipe, - cmd->data, cmd->len, ub_urb_complete, sc); - sc->work_urb.transfer_flags = URB_ASYNC_UNLINK; - sc->work_urb.actual_length = 0; - sc->work_urb.error_count = 0; - sc->work_urb.status = 0; - - if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { - /* XXX Clear stalls */ - printk("ub: data #%d submit failed (%d)\n", cmd->tag, rc); /* P3 */ - ub_complete(&sc->work_done); - ub_state_done(sc, cmd, rc); - return; - } - - sc->work_timer.expires = jiffies + UB_DATA_TIMEOUT; - add_timer(&sc->work_timer); - - cmd->state = UB_CMDST_DATA; - ub_cmdtr_state(sc, cmd); + // udelay(125); // usb-storage has this + ub_data_start(sc, cmd); } else if (cmd->state == UB_CMDST_DATA) { if (urb->status == -EPIPE) { @@ -1325,16 +1227,22 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) if (urb->status == -EOVERFLOW) { /* * A babble? Failure, but we must transfer CSW now. + * XXX This is going to end in perpetual babble. Reset. */ cmd->error = -EOVERFLOW; /* A cheap trick... */ - } else { - if (urb->status != 0) - goto Bad_End; + ub_state_stat(sc, cmd); + return; } + if (urb->status != 0) + goto Bad_End; - cmd->act_len = urb->actual_length; + cmd->act_len += urb->actual_length; ub_cmdtr_act_len(sc, cmd); + if (++cmd->current_sg < cmd->nsg) { + ub_data_start(sc, cmd); + return; + } ub_state_stat(sc, cmd); } else if (cmd->state == UB_CMDST_STAT) { @@ -1469,6 +1377,46 @@ Bad_End: /* Little Excel is dead */ /* * Factorization helper for the command state machine: + * Initiate a data segment transfer. + */ +static void ub_data_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd) +{ + struct scatterlist *sg = &cmd->sgv[cmd->current_sg]; + int pipe; + int rc; + + UB_INIT_COMPLETION(sc->work_done); + + if (cmd->dir == UB_DIR_READ) + pipe = sc->recv_bulk_pipe; + else + pipe = sc->send_bulk_pipe; + sc->last_pipe = pipe; + usb_fill_bulk_urb(&sc->work_urb, sc->dev, pipe, + page_address(sg->page) + sg->offset, sg->length, + ub_urb_complete, sc); + sc->work_urb.transfer_flags = URB_ASYNC_UNLINK; + sc->work_urb.actual_length = 0; + sc->work_urb.error_count = 0; + sc->work_urb.status = 0; + + if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { + /* XXX Clear stalls */ + printk("ub: data #%d submit failed (%d)\n", cmd->tag, rc); /* P3 */ + ub_complete(&sc->work_done); + ub_state_done(sc, cmd, rc); + return; + } + + sc->work_timer.expires = jiffies + UB_DATA_TIMEOUT; + add_timer(&sc->work_timer); + + cmd->state = UB_CMDST_DATA; + ub_cmdtr_state(sc, cmd); +} + +/* + * Factorization helper for the command state machine: * Finish the command. */ static void ub_state_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd, int rc) @@ -1552,6 +1500,7 @@ static void ub_state_stat_counted(struct ub_dev *sc, struct ub_scsi_cmd *cmd) static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd) { struct ub_scsi_cmd *scmd; + struct scatterlist *sg; int rc; if (cmd->cdb[0] == REQUEST_SENSE) { @@ -1560,12 +1509,17 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd) } scmd = &sc->top_rqs_cmd; + memset(scmd, 0, sizeof(struct ub_scsi_cmd)); scmd->cdb[0] = REQUEST_SENSE; scmd->cdb[4] = UB_SENSE_SIZE; scmd->cdb_len = 6; scmd->dir = UB_DIR_READ; scmd->state = UB_CMDST_INIT; - scmd->data = sc->top_sense; + scmd->nsg = 1; + sg = &scmd->sgv[0]; + sg->page = virt_to_page(sc->top_sense); + sg->offset = (unsigned int)sc->top_sense & (PAGE_SIZE-1); + sg->length = UB_SENSE_SIZE; scmd->len = UB_SENSE_SIZE; scmd->lun = cmd->lun; scmd->done = ub_top_sense_done; @@ -1628,7 +1582,7 @@ static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd, */ static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd) { - unsigned char *sense = scmd->data; + unsigned char *sense = sc->top_sense; struct ub_scsi_cmd *cmd; /* @@ -1920,6 +1874,7 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, struct ub_capacity *ret) { struct ub_scsi_cmd *cmd; + struct scatterlist *sg; char *p; enum { ALLOC_SIZE = sizeof(struct ub_scsi_cmd) + 8 }; unsigned long flags; @@ -1940,7 +1895,11 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, cmd->cdb_len = 10; cmd->dir = UB_DIR_READ; cmd->state = UB_CMDST_INIT; - cmd->data = p; + cmd->nsg = 1; + sg = &cmd->sgv[0]; + sg->page = virt_to_page(p); + sg->offset = (unsigned int)p & (PAGE_SIZE-1); + sg->length = 8; cmd->len = 8; cmd->lun = lun; cmd->done = ub_probe_done; -- cgit v0.10.2 From 0bc8e009a2d5106183ea31a2b83035e790778cab Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sun, 31 Jul 2005 20:41:19 -0700 Subject: [PATCH] USB usblp: rate-limit printer status error messages Rate-limit usblp printer error status messages. I unplugged my USB printer and almost instantly got several hundred of these in my kernel message log: drivers/usb/class/usblp.c: usblp0: error -19 reading printer status Signed-off-by: Randy Dunlap Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 7ce43fb..e195709 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -310,8 +310,9 @@ static int usblp_check_status(struct usblp *usblp, int err) error = usblp_read_status (usblp, usblp->statusbuf); if (error < 0) { - err("usblp%d: error %d reading printer status", - usblp->minor, error); + if (printk_ratelimit()) + err("usblp%d: error %d reading printer status", + usblp->minor, error); return 0; } @@ -604,7 +605,9 @@ static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd, case LPGETSTATUS: if (usblp_read_status(usblp, usblp->statusbuf)) { - err("usblp%d: failed reading printer status", usblp->minor); + if (printk_ratelimit()) + err("usblp%d: failed reading printer status", + usblp->minor); retval = -EIO; goto done; } -- cgit v0.10.2 From 0d9899f8139b1e4ee84b97fb61615714fd40be5b Mon Sep 17 00:00:00 2001 From: "david-b@pacbell.net" Date: Thu, 28 Jul 2005 20:46:32 -0700 Subject: [PATCH] USB: usbnet and unsigned gfp_flags This just fixes some gfp flags warnings that joined us recently. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index a2f6724..4682696 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -252,7 +252,7 @@ struct driver_info { /* fixup tx packet (add framing) */ struct sk_buff *(*tx_fixup)(struct usbnet *dev, - struct sk_buff *skb, int flags); + struct sk_buff *skb, unsigned flags); // FIXME -- also an interrupt mechanism // useful for at least PL2301/2302 and GL620USB-A @@ -1144,7 +1144,7 @@ static int ax88772_rx_fixup(struct usbnet *dev, struct sk_buff *skb) } static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb, - int flags) + unsigned flags) { int padlen; int headroom = skb_headroom(skb); @@ -1945,7 +1945,7 @@ static int genelink_rx_fixup (struct usbnet *dev, struct sk_buff *skb) } static struct sk_buff * -genelink_tx_fixup (struct usbnet *dev, struct sk_buff *skb, int flags) +genelink_tx_fixup (struct usbnet *dev, struct sk_buff *skb, unsigned flags) { int padlen; int length = skb->len; @@ -2468,7 +2468,7 @@ static int net1080_rx_fixup (struct usbnet *dev, struct sk_buff *skb) } static struct sk_buff * -net1080_tx_fixup (struct usbnet *dev, struct sk_buff *skb, int flags) +net1080_tx_fixup (struct usbnet *dev, struct sk_buff *skb, unsigned flags) { int padlen; struct sk_buff *skb2; @@ -2662,7 +2662,7 @@ static const struct driver_info blob_info = { *-------------------------------------------------------------------------*/ static struct sk_buff * -zaurus_tx_fixup (struct usbnet *dev, struct sk_buff *skb, int flags) +zaurus_tx_fixup (struct usbnet *dev, struct sk_buff *skb, unsigned flags) { int padlen; struct sk_buff *skb2; @@ -2935,7 +2935,7 @@ static void defer_kevent (struct usbnet *dev, int work) static void rx_complete (struct urb *urb, struct pt_regs *regs); -static void rx_submit (struct usbnet *dev, struct urb *urb, int flags) +static void rx_submit (struct usbnet *dev, struct urb *urb, unsigned flags) { struct sk_buff *skb; struct skb_data *entry; -- cgit v0.10.2 From dc5bed091a7a5fe378055c30a2da874f77228b71 Mon Sep 17 00:00:00 2001 From: Olav Kongas Date: Thu, 4 Aug 2005 16:46:28 +0300 Subject: [PATCH] USB: isp116x-hcd: use fixed power-on-to-power-good-time This patch removes the power-on-to-power-good-time configuration option for isp116x-hcd. Signed-off-by: Olav Kongas Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 75128c3..a7cb134 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -1580,16 +1580,12 @@ static int isp116x_start(struct usb_hcd *hcd) isp116x_write_reg16(isp116x, HCHWCFG, val); /* ----- Root hub conf */ - val = 0; + val = (25 << 24) & RH_A_POTPGT; /* AN10003_1.pdf recommends NPS to be always 1 */ if (board->no_power_switching) val |= RH_A_NPS; if (board->power_switching_mode) val |= RH_A_PSM; - if (board->potpg) - val |= (board->potpg << 24) & RH_A_POTPGT; - else - val |= (25 << 24) & RH_A_POTPGT; isp116x_write_reg32(isp116x, HCRHDESCA, val); isp116x->rhdesca = isp116x_read_reg32(isp116x, HCRHDESCA); diff --git a/include/linux/usb_isp116x.h b/include/linux/usb_isp116x.h index 5f5a9d9..9f4fb56 100644 --- a/include/linux/usb_isp116x.h +++ b/include/linux/usb_isp116x.h @@ -26,8 +26,6 @@ struct isp116x_platform_data { /* Ganged port power switching (0) or individual port power switching (1) */ unsigned power_switching_mode:1; - /* Given port_power, msec/2 after power on till power good */ - u8 potpg; /* Hardware reset set/clear. If implemented, this function must: if set == 0, deassert chip's HW reset pin otherwise, assert chip's HW reset pin */ -- cgit v0.10.2 From d4d62861b5cdb0ecfcae448e4281623284de5d05 Mon Sep 17 00:00:00 2001 From: Olav Kongas Date: Thu, 4 Aug 2005 16:48:19 +0300 Subject: [PATCH] USB: isp116x-hcd: remove unnecessary ClockNotStop configuration option Signed-off-by: Olav Kongas Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index a7cb134..96aaee5 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -1569,7 +1569,7 @@ static int isp116x_start(struct usb_hcd *hcd) if (board->sel15Kres) val |= HCHWCFG_15KRSEL; /* Remote wakeup won't work without working clock */ - if (board->clknotstop || board->remote_wakeup_enable) + if (board->remote_wakeup_enable) val |= HCHWCFG_CLKNOTSTOP; if (board->oc_enable) val |= HCHWCFG_ANALOG_OC; @@ -1615,9 +1615,6 @@ static int isp116x_start(struct usb_hcd *hcd) /* Go operational */ val = HCCONTROL_USB_OPER; - /* Remote wakeup connected - NOT SUPPORTED */ - /* if (board->remote_wakeup_connected) - val |= HCCONTROL_RWC; */ if (board->remote_wakeup_enable) val |= HCCONTROL_RWE; isp116x_write_reg32(isp116x, HCCONTROL, val); diff --git a/include/linux/usb_isp116x.h b/include/linux/usb_isp116x.h index 9f4fb56..0d21407 100644 --- a/include/linux/usb_isp116x.h +++ b/include/linux/usb_isp116x.h @@ -7,19 +7,17 @@ struct isp116x_platform_data { /* Enable internal resistors on downstream ports */ unsigned sel15Kres:1; - /* Chip's internal clock won't be stopped in suspended state. - Setting/unsetting this bit takes effect only if - 'remote_wakeup_enable' below is not set. */ - unsigned clknotstop:1; /* On-chip overcurrent protection */ unsigned oc_enable:1; /* INT output polarity */ unsigned int_act_high:1; /* INT edge or level triggered */ unsigned int_edge_triggered:1; - /* WAKEUP pin connected - NOT SUPPORTED */ - /* unsigned remote_wakeup_connected:1; */ - /* Wakeup by devices on usb bus enabled */ + /* Enable wakeup by devices on usb bus (e.g. wakeup + by attachment/detachment or by device activity + such as moving a mouse). When chosen, this option + prevents stopping internal clock, increasing + thereby power consumption in suspended state. */ unsigned remote_wakeup_enable:1; /* Switch or not to switch (keep always powered) */ unsigned no_power_switching:1; -- cgit v0.10.2 From 165c0f39390212d7a517b80c3bb61cb8f1782fef Mon Sep 17 00:00:00 2001 From: Olav Kongas Date: Thu, 4 Aug 2005 16:52:31 +0300 Subject: [PATCH] USB: isp116x-hcd: support only per-port power switching The isp116x chip will now always be in per-port power switching mode. Remove conf options to set any other mode. Signed-off-by: Olav Kongas Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 96aaee5..a3e881c 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -1581,11 +1581,10 @@ static int isp116x_start(struct usb_hcd *hcd) /* ----- Root hub conf */ val = (25 << 24) & RH_A_POTPGT; - /* AN10003_1.pdf recommends NPS to be always 1 */ - if (board->no_power_switching) - val |= RH_A_NPS; - if (board->power_switching_mode) - val |= RH_A_PSM; + /* AN10003_1.pdf recommends RH_A_NPS (no power switching) to + be always set. Yet, instead, we request individual port + power switching. */ + val |= RH_A_PSM; isp116x_write_reg32(isp116x, HCRHDESCA, val); isp116x->rhdesca = isp116x_read_reg32(isp116x, HCRHDESCA); diff --git a/include/linux/usb_isp116x.h b/include/linux/usb_isp116x.h index 0d21407..c028d72 100644 --- a/include/linux/usb_isp116x.h +++ b/include/linux/usb_isp116x.h @@ -19,11 +19,6 @@ struct isp116x_platform_data { prevents stopping internal clock, increasing thereby power consumption in suspended state. */ unsigned remote_wakeup_enable:1; - /* Switch or not to switch (keep always powered) */ - unsigned no_power_switching:1; - /* Ganged port power switching (0) or individual port - power switching (1) */ - unsigned power_switching_mode:1; /* Hardware reset set/clear. If implemented, this function must: if set == 0, deassert chip's HW reset pin otherwise, assert chip's HW reset pin */ -- cgit v0.10.2 From 9d233d9faedfd8a4ee22288c1fdc698a6f75db21 Mon Sep 17 00:00:00 2001 From: Olav Kongas Date: Thu, 4 Aug 2005 16:54:08 +0300 Subject: [PATCH] USB: isp116x-hcd: per-port overcurrent reporting This patch sets the isp116x to report overcurrent always per-port. Signed-off-by: Olav Kongas Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index a3e881c..aeddef7 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -1585,6 +1585,8 @@ static int isp116x_start(struct usb_hcd *hcd) be always set. Yet, instead, we request individual port power switching. */ val |= RH_A_PSM; + /* Report overcurrent per port */ + val |= RH_A_OCPM; isp116x_write_reg32(isp116x, HCRHDESCA, val); isp116x->rhdesca = isp116x_read_reg32(isp116x, HCRHDESCA); diff --git a/include/linux/usb_isp116x.h b/include/linux/usb_isp116x.h index c028d72..8f0b3c2 100644 --- a/include/linux/usb_isp116x.h +++ b/include/linux/usb_isp116x.h @@ -7,7 +7,7 @@ struct isp116x_platform_data { /* Enable internal resistors on downstream ports */ unsigned sel15Kres:1; - /* On-chip overcurrent protection */ + /* On-chip overcurrent detection */ unsigned oc_enable:1; /* INT output polarity */ unsigned int_act_high:1; -- cgit v0.10.2 From f8d23d309809ae69c763520dababb7e845938272 Mon Sep 17 00:00:00 2001 From: Olav Kongas Date: Thu, 4 Aug 2005 17:02:54 +0300 Subject: [PATCH] USB: isp116x-hcd: remove clock() and reset() This patch removes support for user-provided platform-specific hardware reset and clock starting/stopping functions. Hardware reset was needed earlier as getting the software reset working was tricky due to the lack of documentation. Recently, a number of people using isp116x have said the software reset is working for them. I haven't heard of anybody using the clock starting/stopping. Signed-off-by: Olav Kongas Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index aeddef7..1ed2aba 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -1463,10 +1463,6 @@ static int isp116x_sw_reset(struct isp116x *isp116x) return ret; } -/* - Reset. Tries to perform platform-specific hardware - reset first; falls back to software reset. -*/ static int isp116x_reset(struct usb_hcd *hcd) { struct isp116x *isp116x = hcd_to_isp116x(hcd); @@ -1474,17 +1470,7 @@ static int isp116x_reset(struct usb_hcd *hcd) u16 clkrdy = 0; int ret = 0, timeout = 15 /* ms */ ; - if (isp116x->board && isp116x->board->reset) { - /* Hardware reset */ - isp116x->board->reset(hcd->self.controller, 1); - msleep(10); - if (isp116x->board->clock) - isp116x->board->clock(hcd->self.controller, 1); - msleep(1); - isp116x->board->reset(hcd->self.controller, 0); - } else - ret = isp116x_sw_reset(isp116x); - + ret = isp116x_sw_reset(isp116x); if (ret) return ret; @@ -1501,10 +1487,7 @@ static int isp116x_reset(struct usb_hcd *hcd) ERR("Clock not ready after 20ms\n"); /* After sw_reset the clock won't report to be ready, if H_WAKEUP pin is high. */ - if (!isp116x->board || !isp116x->board->reset) - ERR("The driver does not support hardware wakeup.\n"); - ERR("Please make sure that the H_WAKEUP pin " - "is pulled low!\n"); + ERR("Please make sure that the H_WAKEUP pin is pulled low!\n"); ret = -ENODEV; } return ret; @@ -1527,15 +1510,7 @@ static void isp116x_stop(struct usb_hcd *hcd) isp116x_write_reg32(isp116x, HCRHSTATUS, RH_HS_LPS); spin_unlock_irqrestore(&isp116x->lock, flags); - /* Put the chip into reset state */ - if (isp116x->board && isp116x->board->reset) - isp116x->board->reset(hcd->self.controller, 0); - else - isp116x_sw_reset(isp116x); - - /* Stop the clock */ - if (isp116x->board && isp116x->board->clock) - isp116x->board->clock(hcd->self.controller, 0); + isp116x_sw_reset(isp116x); } /* diff --git a/include/linux/usb_isp116x.h b/include/linux/usb_isp116x.h index 8f0b3c2..436dd8a 100644 --- a/include/linux/usb_isp116x.h +++ b/include/linux/usb_isp116x.h @@ -19,15 +19,6 @@ struct isp116x_platform_data { prevents stopping internal clock, increasing thereby power consumption in suspended state. */ unsigned remote_wakeup_enable:1; - /* Hardware reset set/clear. If implemented, this function must: - if set == 0, deassert chip's HW reset pin - otherwise, assert chip's HW reset pin */ - void (*reset) (struct device * dev, int set); - /* Hardware clock start/stop. If implemented, this function must: - if start == 0, stop the external clock - otherwise, start the external clock - */ - void (*clock) (struct device * dev, int start); /* Inter-io delay (ns). The chip is picky about access timings; it expects at least: 150ns delay between consecutive accesses to DATA_REG, -- cgit v0.10.2 From 9a57116bc9e36c9accc869f666e1d25c5e2cdcbf Mon Sep 17 00:00:00 2001 From: Olav Kongas Date: Fri, 5 Aug 2005 14:23:35 +0300 Subject: [PATCH] USB: Switch isp116x-hcd over to root hub interrupt Switch isp116x-hcd over from root hub polling to interrupt. This change closes also a race that was present with the old polling scheme: status polling could happen in a time window, where root hub status bits were not stable. Signed-off-by: Olav Kongas Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 1ed2aba..41bbae8 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -83,7 +83,7 @@ #include "../core/hcd.h" #include "isp116x.h" -#define DRIVER_VERSION "08 Apr 2005" +#define DRIVER_VERSION "05 Aug 2005" #define DRIVER_DESC "ISP116x USB Host Controller Driver" MODULE_DESCRIPTION(DRIVER_DESC); @@ -629,14 +629,12 @@ static irqreturn_t isp116x_irq(struct usb_hcd *hcd, struct pt_regs *regs) ERR("Unrecoverable error\n"); /* What should we do here? Reset? */ } - if (intstat & HCINT_RHSC) { - isp116x->rhstatus = - isp116x_read_reg32(isp116x, HCRHSTATUS); - isp116x->rhport[0] = - isp116x_read_reg32(isp116x, HCRHPORT1); - isp116x->rhport[1] = - isp116x_read_reg32(isp116x, HCRHPORT2); - } + if (intstat & HCINT_RHSC) + /* When root hub or any of its ports is going + to come out of suspend, it may take more + than 10ms for status bits to stabilize. */ + mod_timer(&hcd->rh_timer, jiffies + + msecs_to_jiffies(20) + 1); if (intstat & HCINT_RD) { DBG("---- remote wakeup\n"); schedule_work(&isp116x->rh_resume); @@ -925,20 +923,27 @@ static int isp116x_hub_status_data(struct usb_hcd *hcd, char *buf) { struct isp116x *isp116x = hcd_to_isp116x(hcd); int ports, i, changed = 0; + unsigned long flags; if (!HC_IS_RUNNING(hcd->state)) return -ESHUTDOWN; - ports = isp116x->rhdesca & RH_A_NDP; + /* Report no status change now, if we are scheduled to be + called later */ + if (timer_pending(&hcd->rh_timer)) + return 0; - /* init status */ + ports = isp116x->rhdesca & RH_A_NDP; + spin_lock_irqsave(&isp116x->lock, flags); + isp116x->rhstatus = isp116x_read_reg32(isp116x, HCRHSTATUS); if (isp116x->rhstatus & (RH_HS_LPSC | RH_HS_OCIC)) buf[0] = changed = 1; else buf[0] = 0; for (i = 0; i < ports; i++) { - u32 status = isp116x->rhport[i]; + u32 status = isp116x->rhport[i] = + isp116x_read_reg32(isp116x, i ? HCRHPORT2 : HCRHPORT1); if (status & (RH_PS_CSC | RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC | RH_PS_PRSC)) { @@ -947,6 +952,7 @@ static int isp116x_hub_status_data(struct usb_hcd *hcd, char *buf) continue; } } + spin_unlock_irqrestore(&isp116x->lock, flags); return changed; } @@ -1536,6 +1542,9 @@ static int isp116x_start(struct usb_hcd *hcd) return -ENODEV; } + /* To be removed in future */ + hcd->uses_new_polling = 1; + isp116x_write_reg16(isp116x, HCITLBUFLEN, ISP116x_ITL_BUFSIZE); isp116x_write_reg16(isp116x, HCATLBUFLEN, ISP116x_ATL_BUFSIZE); @@ -1639,7 +1648,7 @@ static int __init_or_module isp116x_remove(struct device *dev) struct platform_device *pdev; struct resource *res; - if(!hcd) + if (!hcd) return 0; isp116x = hcd_to_isp116x(hcd); pdev = container_of(dev, struct platform_device, dev); -- cgit v0.10.2 From 0f64e078139109d1902e5b1274c23cec9a9ad12e Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Thu, 28 Jul 2005 14:43:08 -0700 Subject: [PATCH] USB Storage: remove dependency on SCSI-provided serial/tag number This patch started life as as531 from Alan Stern. It has been rediffed against the latest tree. The SCSI people have deprecated the use of scsi_cmnd.serial_number for anything other than printk. Worse than that, the SCSI core doesn't always increment the number (when the error handler is running, for example). So this patch creates a locally-stored value for use in bulk-only tags. The net result is a simplification, since we no longer have to save & restore the serial_number value while autosensing. Signed-off-by: Alan Stern Signed-off-by: Matthew Dharm Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index e6b1c6c..e428751 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -611,7 +611,6 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) unsigned char old_sc_data_direction; unsigned char old_cmd_len; unsigned char old_cmnd[MAX_COMMAND_SIZE]; - unsigned long old_serial_number; int old_resid; US_DEBUGP("Issuing auto-REQUEST_SENSE\n"); @@ -648,10 +647,6 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) old_sg = srb->use_sg; srb->use_sg = 0; - /* change the serial number -- toggle the high bit*/ - old_serial_number = srb->serial_number; - srb->serial_number ^= 0x80000000; - /* issue the auto-sense command */ old_resid = srb->resid; srb->resid = 0; @@ -662,7 +657,6 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) srb->request_buffer = old_request_buffer; srb->request_bufflen = old_request_bufflen; srb->use_sg = old_sg; - srb->serial_number = old_serial_number; srb->sc_data_direction = old_sc_data_direction; srb->cmd_len = old_cmd_len; memcpy(srb->cmnd, old_cmnd, MAX_COMMAND_SIZE); @@ -985,7 +979,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); bcb->DataTransferLength = cpu_to_le32(transfer_length); bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? 1 << 7 : 0; - bcb->Tag = srb->serial_number; + bcb->Tag = ++us->tag; bcb->Lun = srb->device->lun; if (us->flags & US_FL_SCM_MULT_TARG) bcb->Lun |= srb->device->id << 4; @@ -1074,7 +1068,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) US_DEBUGP("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", le32_to_cpu(bcs->Signature), bcs->Tag, residue, bcs->Status); - if (bcs->Tag != srb->serial_number || bcs->Status > US_BULK_STAT_PHASE) { + if (bcs->Tag != us->tag || bcs->Status > US_BULK_STAT_PHASE) { US_DEBUGP("Bulk logical error\n"); return USB_STOR_TRANSPORT_ERROR; } diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index 625b7aa9..a195ada 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h @@ -158,6 +158,7 @@ struct us_data { /* SCSI interfaces */ struct scsi_cmnd *srb; /* current srb */ + unsigned int tag; /* current dCBWTag */ /* thread information */ int pid; /* control thread */ -- cgit v0.10.2 From 77f46328fb83b64befd889ebce6d7fb959932509 Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Thu, 28 Jul 2005 14:44:29 -0700 Subject: [PATCH] USB Storage: close a race condition in disconnect near probe This patch started life as as533, and has been re-diffed against the current tree. Disconnect processing in usb-storage naturally divides into two parts: one to quiesce the driver (make sure no commands are executing or queued) and remove the host, and the other to deallocate all the USB and non-USB resources. This patch creates two subroutines to handle those two parts. Mostly it's just code movement, but there is one significant change. If the scsi-scanning thread fails to initialize but the host has successfully been added, we need to quiesce the driver before removing the host. After all, it's possible that scanning could have been initiated from somewhere else, such as userspace -- very low probability, but it's easily handled by calling the new subroutine. Signed-off-by: Alan Stern Signed-off-by: Matthew Dharm Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 77e7fc2..2557711 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -786,6 +786,7 @@ static void usb_stor_release_resources(struct us_data *us) * any more commands. */ US_DEBUGP("-- sending exit command to thread\n"); + set_bit(US_FLIDX_DISCONNECTING, &us->flags); up(&us->sema); /* Call the destructor routine, if it exists */ @@ -816,6 +817,36 @@ static void dissociate_dev(struct us_data *us) usb_set_intfdata(us->pusb_intf, NULL); } +/* First stage of disconnect processing: stop all commands and remove + * the host */ +static void quiesce_and_remove_host(struct us_data *us) +{ + /* Prevent new USB transfers, stop the current command, and + * interrupt a SCSI-scan or device-reset delay */ + set_bit(US_FLIDX_DISCONNECTING, &us->flags); + usb_stor_stop_transport(us); + wake_up(&us->delay_wait); + + /* It doesn't matter if the SCSI-scanning thread is still running. + * The thread will exit when it sees the DISCONNECTING flag. */ + + /* Wait for the current command to finish, then remove the host */ + down(&us->dev_semaphore); + up(&us->dev_semaphore); + scsi_remove_host(us_to_host(us)); +} + +/* Second stage of disconnect processing: deallocate all resources */ +static void release_everything(struct us_data *us) +{ + usb_stor_release_resources(us); + dissociate_dev(us); + + /* Drop our reference to the host; the SCSI core will free it + * (and "us" along with it) when the refcount becomes 0. */ + scsi_host_put(us_to_host(us)); +} + /* Thread to carry out delayed SCSI-device scanning */ static int usb_stor_scan_thread(void * __us) { @@ -956,7 +987,7 @@ static int storage_probe(struct usb_interface *intf, if (result < 0) { printk(KERN_WARNING USB_STORAGE "Unable to start the device-scanning thread\n"); - scsi_remove_host(host); + quiesce_and_remove_host(us); goto BadDevice; } atomic_inc(&total_threads); @@ -969,10 +1000,7 @@ static int storage_probe(struct usb_interface *intf, /* We come here if there are any problems */ BadDevice: US_DEBUGP("storage_probe() failed\n"); - set_bit(US_FLIDX_DISCONNECTING, &us->flags); - usb_stor_release_resources(us); - dissociate_dev(us); - scsi_host_put(host); + release_everything(us); return result; } @@ -982,28 +1010,8 @@ static void storage_disconnect(struct usb_interface *intf) struct us_data *us = usb_get_intfdata(intf); US_DEBUGP("storage_disconnect() called\n"); - - /* Prevent new USB transfers, stop the current command, and - * interrupt a SCSI-scan or device-reset delay */ - set_bit(US_FLIDX_DISCONNECTING, &us->flags); - usb_stor_stop_transport(us); - wake_up(&us->delay_wait); - - /* It doesn't matter if the SCSI-scanning thread is still running. - * The thread will exit when it sees the DISCONNECTING flag. */ - - /* Wait for the current command to finish, then remove the host */ - down(&us->dev_semaphore); - up(&us->dev_semaphore); - scsi_remove_host(us_to_host(us)); - - /* Wait for everything to become idle and release all our resources */ - usb_stor_release_resources(us); - dissociate_dev(us); - - /* Drop our reference to the host; the SCSI core will free it - * (and "us" along with it) when the refcount becomes 0. */ - scsi_host_put(us_to_host(us)); + quiesce_and_remove_host(us); + release_everything(us); } /*********************************************************************** -- cgit v0.10.2 From 26186ba77b493204ae0fadc3c88a67b14f22168f Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Thu, 28 Jul 2005 14:45:50 -0700 Subject: [PATCH] USB Storage: close a race condition in disconnect near queuecommand This patch started life as as534, and has been re-diffed against the latest tree. usb-storage has a small loophole, a window between the time queuecommand accepts a new command and the time the control thread starts to execute it. If disconnect is called during that window, the driver won't cancel the pending command -- we've been relying on the SCSI core to cancel it for us during host removal. But it's better for usb-storage to cancel it; this avoids races and reduces reliance on the SCSI core. Fortunately cancelling these commands is easy to do; the key is to do it _before_ calling scsi_remove_host. Signed-off-by: Alan Stern Signed-off-by: Matthew Dharm Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 2557711..97b9ebb 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -833,6 +833,19 @@ static void quiesce_and_remove_host(struct us_data *us) /* Wait for the current command to finish, then remove the host */ down(&us->dev_semaphore); up(&us->dev_semaphore); + + /* queuecommand won't accept any new commands and the control + * thread won't execute a previously-queued command. If there + * is such a command pending, complete it with an error. */ + if (us->srb) { + us->srb->result = DID_NO_CONNECT << 16; + scsi_lock(us_to_host(us)); + us->srb->scsi_done(us->srb); + us->srb = NULL; + scsi_unlock(us_to_host(us)); + } + + /* Now we own no commands so it's safe to remove the SCSI host */ scsi_remove_host(us_to_host(us)); } -- cgit v0.10.2 From 34008dbfe8c00eca67f97bad484eb5cb03bafe66 Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Thu, 28 Jul 2005 14:49:01 -0700 Subject: [PATCH] USB Storage: add support for Maxtor One-Touch button This patch is originally from Nick Sillik, and has been rediffed against the latest tree. This patch adds usability to the OneTouch Button on Maxtor External USB Hard Drives. Using an unusual device entry it declares an extra init function which claims the interrupt endpoint associated with this button. The button is connected to the input system. Signed-off-by: Nick Sillik Signed-off-by: Matthew Dharm Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index f1f1c06..bb9819c 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig @@ -111,3 +111,15 @@ config USB_STORAGE_JUMPSHOT Say Y here to include additional code to support the Lexar Jumpshot USB CompactFlash reader. + +config USB_STORAGE_ONETOUCH + bool "Support OneTouch Button on Maxtor Hard Drives (EXPERIMENTAL)" + depends on USB_STORAGE && INPUT_EVDEV && EXPERIMENTAL + help + Say Y here to include additional code to support the Maxtor OneTouch + USB hard drive's onetouch button. + + This code registers the button on the front of Maxtor OneTouch USB + hard drive's as an input device. An action can be associated with + this input in any keybinding software. (e.g. gnome's keyboard short- + cuts) diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile index 56652cc..44ab8f9 100644 --- a/drivers/usb/storage/Makefile +++ b/drivers/usb/storage/Makefile @@ -18,6 +18,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_DPCM) += dpcm.o usb-storage-obj-$(CONFIG_USB_STORAGE_ISD200) += isd200.o usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB) += datafab.o usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o +usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ initializers.o $(usb-storage-obj-y) diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c new file mode 100644 index 0000000..07fd29c --- /dev/null +++ b/drivers/usb/storage/onetouch.c @@ -0,0 +1,205 @@ +/* + * Support for the Maxtor OneTouch USB hard drive's button + * + * Current development and maintenance by: + * Copyright (c) 2005 Nick Sillik + * + * Initial work by: + * Copyright (c) 2003 Erik Thyrén + * + * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann) + * + */ + +/* + * 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 +#include +#include +#include +#include +#include +#include +#include "usb.h" +#include "onetouch.h" +#include "debug.h" + +void onetouch_release_input(void *onetouch_); + +struct usb_onetouch { + char name[128]; + char phys[64]; + struct input_dev dev; /* input device interface */ + struct usb_device *udev; /* usb device */ + + struct urb *irq; /* urb for interrupt in report */ + unsigned char *data; /* input data */ + dma_addr_t data_dma; +}; + +static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs) +{ + struct usb_onetouch *onetouch = urb->context; + signed char *data = onetouch->data; + struct input_dev *dev = &onetouch->dev; + int status; + + switch (urb->status) { + case 0: /* success */ + break; + case -ECONNRESET: /* unlink */ + case -ENOENT: + case -ESHUTDOWN: + return; + /* -EPIPE: should clear the halt */ + default: /* error */ + goto resubmit; + } + + input_regs(dev, regs); + + input_report_key(&onetouch->dev, ONETOUCH_BUTTON, + data[0] & 0x02); + + input_sync(dev); +resubmit: + status = usb_submit_urb (urb, SLAB_ATOMIC); + if (status) + err ("can't resubmit intr, %s-%s/input0, status %d", + onetouch->udev->bus->bus_name, + onetouch->udev->devpath, status); +} + +static int usb_onetouch_open(struct input_dev *dev) +{ + struct usb_onetouch *onetouch = dev->private; + + onetouch->irq->dev = onetouch->udev; + if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) { + err("usb_submit_urb failed"); + return -EIO; + } + + return 0; +} + +static void usb_onetouch_close(struct input_dev *dev) +{ + struct usb_onetouch *onetouch = dev->private; + + usb_kill_urb(onetouch->irq); +} + +int onetouch_connect_input(struct us_data *ss) +{ + struct usb_device *udev = ss->pusb_dev; + struct usb_host_interface *interface; + struct usb_endpoint_descriptor *endpoint; + struct usb_onetouch *onetouch; + int pipe, maxp; + char path[64]; + + interface = ss->pusb_intf->cur_altsetting; + + endpoint = &interface->endpoint[2].desc; + if(!(endpoint->bEndpointAddress & 0x80)) + return -ENODEV; + if((endpoint->bmAttributes & 3) != 3) + return -ENODEV; + + pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); + maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); + + if (!(onetouch = kcalloc(1, sizeof(struct usb_onetouch), GFP_KERNEL))) + return -ENOMEM; + + onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, SLAB_ATOMIC, &onetouch->data_dma); + if (!onetouch->data){ + kfree(onetouch); + return -ENOMEM; + } + + onetouch->irq = usb_alloc_urb(0, GFP_KERNEL); + if (!onetouch->irq){ + kfree(onetouch); + usb_buffer_free(udev, ONETOUCH_PKT_LEN, onetouch->data, onetouch->data_dma); + return -ENODEV; + } + + + onetouch->udev = udev; + + set_bit(EV_KEY, onetouch->dev.evbit); + set_bit(ONETOUCH_BUTTON, onetouch->dev.keybit); + clear_bit(0, onetouch->dev.keybit); + + onetouch->dev.private = onetouch; + onetouch->dev.open = usb_onetouch_open; + onetouch->dev.close = usb_onetouch_close; + + usb_make_path(udev, path, 64); + sprintf(onetouch->phys, "%s/input0", path); + + onetouch->dev.name = onetouch->name; + onetouch->dev.phys = onetouch->phys; + + onetouch->dev.id.bustype = BUS_USB; + onetouch->dev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); + onetouch->dev.id.product = le16_to_cpu(udev->descriptor.idProduct); + onetouch->dev.id.version = le16_to_cpu(udev->descriptor.bcdDevice); + + onetouch->dev.dev = &udev->dev; + + if (udev->manufacturer) + strcat(onetouch->name, udev->manufacturer); + if (udev->product) + sprintf(onetouch->name, "%s %s", onetouch->name, + udev->product); + if (!strlen(onetouch->name)) + sprintf(onetouch->name, "Maxtor Onetouch %04x:%04x", + onetouch->dev.id.vendor, onetouch->dev.id.product); + + usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data, + (maxp > 8 ? 8 : maxp), + usb_onetouch_irq, onetouch, endpoint->bInterval); + onetouch->irq->transfer_dma = onetouch->data_dma; + onetouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; + + ss->extra_destructor = onetouch_release_input; + ss->extra = onetouch; + + input_register_device(&onetouch->dev); + printk(KERN_INFO "usb-input: %s on %s\n", onetouch->dev.name, path); + + return 0; +} + +void onetouch_release_input(void *onetouch_) +{ + struct usb_onetouch *onetouch = (struct usb_onetouch *) onetouch_; + + if (onetouch) { + usb_kill_urb(onetouch->irq); + input_unregister_device(&onetouch->dev); + usb_free_urb(onetouch->irq); + usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN, + onetouch->data, onetouch->data_dma); + printk(KERN_INFO "Maxtor Onetouch %04x:%04x Deregistered\n", + onetouch->dev.id.vendor, onetouch->dev.id.product); + } +} diff --git a/drivers/usb/storage/onetouch.h b/drivers/usb/storage/onetouch.h new file mode 100644 index 0000000..41c7aa8 --- /dev/null +++ b/drivers/usb/storage/onetouch.h @@ -0,0 +1,9 @@ +#ifndef _ONETOUCH_H_ +#define _ONETOUCH_H_ + +#define ONETOUCH_PKT_LEN 0x02 +#define ONETOUCH_BUTTON KEY_PROG1 + +int onetouch_connect_input(struct us_data *ss); + +#endif diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index e7ed835..ad0cfd7 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -936,6 +936,18 @@ UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff, US_FL_SINGLE_LUN ), #endif +/* Submitted by: Nick Sillik + * Needed for OneTouch extension to usb-storage + * + */ +#ifdef CONFIG_USB_STORAGE_ONETOUCH + UNUSUAL_DEV( 0x0d49, 0x7010, 0x0000, 0x9999, + "Maxtor", + "OneTouch External Harddrive", + US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input, + 0), +#endif + /* Submitted by Joris Struyve */ UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff, "Medion", diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 97b9ebb..cb4c770 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -90,7 +90,9 @@ #ifdef CONFIG_USB_STORAGE_JUMPSHOT #include "jumpshot.h" #endif - +#ifdef CONFIG_USB_STORAGE_ONETOUCH +#include "onetouch.h" +#endif /* Some informational data */ MODULE_AUTHOR("Matthew Dharm "); -- cgit v0.10.2 From a4e628328ec60873fec9d506d682155391f589ce Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Thu, 28 Jul 2005 14:50:29 -0700 Subject: [PATCH] USB Storage: wedge SCSI revision at 2 for usb-storage devices This patch started life as as479b, and has been rediffed. Please note the order of submission of this latest patch series -- even tho this has an older original number, it is the last patch I'll be sending today. This patch changes the reported SCSI revision level to 2 for all disk-type devices. This is needed in a few cases because the device reports a level of 3 or higher but then crashes when given a REPORT LUNS command (for which support is supposed to be mandatory at those levels). This shouldn't harm us, since it only matters for sparse LUNs and we have separate ways of coping with that. Signed-off-by: Alan Stern Signed-off-by: Matthew Dharm Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index af294bb..d34dc9f 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -156,6 +156,14 @@ static int slave_configure(struct scsi_device *sdev) if (us->flags & US_FL_FIX_CAPACITY) sdev->fix_capacity = 1; + /* Some devices report a SCSI revision level above 2 but are + * unable to handle the REPORT LUNS command (for which + * support is mandatory at level 3). Since we already have + * a Get-Max-LUN request, we won't lose much by setting the + * revision level down to 2. The only devices that would be + * affected are those with sparse LUNs. */ + sdev->scsi_level = SCSI_2; + /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable * Hardware Error) when any low-level error occurs, * recoverable or not. Setting this flag tells the SCSI -- cgit v0.10.2 From b375a0495fd622037560c73c05f23ae6f127bb0c Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Fri, 29 Jul 2005 16:11:07 -0400 Subject: [PATCH] USB: URB_ASYNC_UNLINK flag removed from the kernel 29 July 2005, Cambridge, MA: This afternoon Alan Stern submitted a patch to remove the URB_ASYNC_UNLINK flag from the Linux kernel. Mr. Stern explained, "This flag is a relic from an earlier, less-well-designed system. For over a year it hasn't been used for anything other than printing warning messages." An anonymous spokesman for the Linux kernel development community commented, "This is exactly the sort of thing we see happening all the time. As the kernel evolves, support for old techniques and old code can be jettisoned and replaced by newer, better approaches. Proprietary operating systems do not have the freedom or flexibility to change so quickly." Mr. Stern, a staff member at Harvard University's Rowland Institute who works on Linux only as a hobby, noted that the patch (labelled as548) did not update two files, keyspan.c and option.c, in the USB drivers' "serial" subdirectory. "Those files need more extensive changes," he remarked. "They examine the status field of several URBs at times when they're not supposed to. That will need to be fixed before the URB_ASYNC_UNLINK flag is removed." Greg Kroah-Hartman, the kernel maintainer responsible for overseeing all of Linux's USB drivers, did not respond to our inquiries or return our calls. His only comment was "Applied, thanks." Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 57d3279..aa0bf7e 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -1010,7 +1010,7 @@ static int ub_scsi_cmd_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd) sc->last_pipe = sc->send_bulk_pipe; usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->send_bulk_pipe, bcb, US_BULK_CB_WRAP_LEN, ub_urb_complete, sc); - sc->work_urb.transfer_flags = URB_ASYNC_UNLINK; + sc->work_urb.transfer_flags = 0; /* Fill what we shouldn't be filling, because usb-storage did so. */ sc->work_urb.actual_length = 0; @@ -1395,7 +1395,7 @@ static void ub_data_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd) usb_fill_bulk_urb(&sc->work_urb, sc->dev, pipe, page_address(sg->page) + sg->offset, sg->length, ub_urb_complete, sc); - sc->work_urb.transfer_flags = URB_ASYNC_UNLINK; + sc->work_urb.transfer_flags = 0; sc->work_urb.actual_length = 0; sc->work_urb.error_count = 0; sc->work_urb.status = 0; @@ -1442,7 +1442,7 @@ static int __ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd) sc->last_pipe = sc->recv_bulk_pipe; usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->recv_bulk_pipe, &sc->work_bcs, US_BULK_CS_WRAP_LEN, ub_urb_complete, sc); - sc->work_urb.transfer_flags = URB_ASYNC_UNLINK; + sc->work_urb.transfer_flags = 0; sc->work_urb.actual_length = 0; sc->work_urb.error_count = 0; sc->work_urb.status = 0; @@ -1563,7 +1563,7 @@ static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd, usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe, (unsigned char*) cr, NULL, 0, ub_urb_complete, sc); - sc->work_urb.transfer_flags = URB_ASYNC_UNLINK; + sc->work_urb.transfer_flags = 0; sc->work_urb.actual_length = 0; sc->work_urb.error_count = 0; sc->work_urb.status = 0; diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index 46e0022..6c766fd 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c @@ -267,7 +267,7 @@ static void irda_usb_change_speed_xbofs(struct irda_usb_cb *self) frame, IRDA_USB_SPEED_MTU, speed_bulk_callback, self); urb->transfer_buffer_length = USB_IRDA_HEADER; - urb->transfer_flags = URB_ASYNC_UNLINK; + urb->transfer_flags = 0; /* Irq disabled -> GFP_ATOMIC */ if ((ret = usb_submit_urb(urb, GFP_ATOMIC))) { @@ -401,15 +401,12 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev) skb->data, IRDA_SKB_MAX_MTU, write_bulk_callback, skb); urb->transfer_buffer_length = skb->len; - /* Note : unlink *must* be Asynchronous because of the code in - * irda_usb_net_timeout() -> call in irq - Jean II */ - urb->transfer_flags = URB_ASYNC_UNLINK; /* This flag (URB_ZERO_PACKET) indicates that what we send is not * a continuous stream of data but separate packets. * In this case, the USB layer will insert an empty USB frame (TD) * after each of our packets that is exact multiple of the frame size. * This is how the dongle will detect the end of packet - Jean II */ - urb->transfer_flags |= URB_ZERO_PACKET; + urb->transfer_flags = URB_ZERO_PACKET; /* Generate min turn time. FIXME: can we do better than this? */ /* Trying to a turnaround time at this level is trying to measure @@ -630,8 +627,6 @@ static void irda_usb_net_timeout(struct net_device *netdev) * in completion handler, because urb->status will * be -ENOENT. We will fix that at the next watchdog, * leaving more time to USB to recover... - * Also, we are in interrupt, so we need to have - * URB_ASYNC_UNLINK to work properly... * Jean II */ done = 1; break; @@ -1008,9 +1003,7 @@ static int irda_usb_net_close(struct net_device *netdev) } } /* Cancel Tx and speed URB - need to be synchronous to avoid races */ - self->tx_urb->transfer_flags &= ~URB_ASYNC_UNLINK; usb_kill_urb(self->tx_urb); - self->speed_urb->transfer_flags &= ~URB_ASYNC_UNLINK; usb_kill_urb(self->speed_urb); /* Stop and remove instance of IrLAP */ @@ -1521,9 +1514,7 @@ static void irda_usb_disconnect(struct usb_interface *intf) usb_kill_urb(self->rx_urb[i]); /* Cancel Tx and speed URB. * Toggle flags to make sure it's synchronous. */ - self->tx_urb->transfer_flags &= ~URB_ASYNC_UNLINK; usb_kill_urb(self->tx_urb); - self->speed_urb->transfer_flags &= ~URB_ASYNC_UNLINK; usb_kill_urb(self->speed_urb); } diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index 8e184e2..79861ee 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c @@ -715,13 +715,11 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance, usb_dev, usb_rcvintpipe(usb_dev, CXACRU_EP_CMD), instance->rcv_buf, PAGE_SIZE, cxacru_blocking_completion, &instance->rcv_done, 1); - instance->rcv_urb->transfer_flags |= URB_ASYNC_UNLINK; usb_fill_int_urb(instance->snd_urb, usb_dev, usb_sndintpipe(usb_dev, CXACRU_EP_CMD), instance->snd_buf, PAGE_SIZE, cxacru_blocking_completion, &instance->snd_done, 4); - instance->snd_urb->transfer_flags |= URB_ASYNC_UNLINK; init_MUTEX(&instance->cm_serialize); diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 88d1b37..7419724 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -48,7 +48,6 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int* actual_length) init_completion(&done); urb->context = &done; - urb->transfer_flags |= URB_ASYNC_UNLINK; urb->actual_length = 0; status = usb_submit_urb(urb, GFP_NOIO); @@ -357,8 +356,7 @@ int usb_sg_init ( if (!io->urbs) goto nomem; - urb_flags = URB_ASYNC_UNLINK | URB_NO_TRANSFER_DMA_MAP - | URB_NO_INTERRUPT; + urb_flags = URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; if (usb_pipein (pipe)) urb_flags |= URB_SHORT_NOT_OK; diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index c0feee2..c846fef 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -309,9 +309,8 @@ int usb_submit_urb(struct urb *urb, unsigned mem_flags) unsigned int allowed; /* enforce simple/standard policy */ - allowed = URB_ASYNC_UNLINK; // affects later unlinks - allowed |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); - allowed |= URB_NO_INTERRUPT; + allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | + URB_NO_INTERRUPT); switch (temp) { case PIPE_BULK: if (is_out) @@ -400,14 +399,8 @@ int usb_submit_urb(struct urb *urb, unsigned mem_flags) * canceled (rather than any other code) and will quickly be removed * from host controller data structures. * - * In the past, clearing the URB_ASYNC_UNLINK transfer flag for the - * URB indicated that the request was synchronous. This usage is now - * deprecated; if the flag is clear the call will be forwarded to - * usb_kill_urb() and the return value will be 0. In the future, drivers - * should call usb_kill_urb() directly for synchronous unlinking. - * - * When the URB_ASYNC_UNLINK transfer flag for the URB is set, this - * request is asynchronous. Success is indicated by returning -EINPROGRESS, + * This request is always asynchronous. + * Success is indicated by returning -EINPROGRESS, * at which time the URB will normally have been unlinked but not yet * given back to the device driver. When it is called, the completion * function will see urb->status == -ECONNRESET. Failure is indicated @@ -453,17 +446,6 @@ int usb_unlink_urb(struct urb *urb) { if (!urb) return -EINVAL; - if (!(urb->transfer_flags & URB_ASYNC_UNLINK)) { -#ifdef CONFIG_DEBUG_KERNEL - if (printk_ratelimit()) { - printk(KERN_NOTICE "usb_unlink_urb() is deprecated for " - "synchronous unlinks. Use usb_kill_urb() instead.\n"); - WARN_ON(1); - } -#endif - usb_kill_urb(urb); - return 0; - } if (!(urb->dev && urb->dev->bus && urb->dev->bus->op)) return -ENODEV; return urb->dev->bus->op->unlink_urb(urb, -ECONNRESET); diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 719c031..1ab95d2 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1688,7 +1688,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, 0, hid_irq_in, hid, interval); hid->urbin->transfer_dma = hid->inbuf_dma; - hid->urbin->transfer_flags |=(URB_NO_TRANSFER_DMA_MAP | URB_ASYNC_UNLINK); + hid->urbin->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; } else { if (hid->urbout) continue; @@ -1698,7 +1698,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) usb_fill_int_urb(hid->urbout, dev, pipe, hid->outbuf, 0, hid_irq_out, hid, interval); hid->urbout->transfer_dma = hid->outbuf_dma; - hid->urbout->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_ASYNC_UNLINK); + hid->urbout->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; } } @@ -1750,7 +1750,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) hid->ctrlbuf, 1, hid_ctrl, hid); hid->urbctrl->setup_dma = hid->cr_dma; hid->urbctrl->transfer_dma = hid->ctrlbuf_dma; - hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | URB_ASYNC_UNLINK); + hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); return hid; diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index 6f7994f..ae4681f 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c @@ -426,7 +426,7 @@ static int auerchain_submit_urb (pauerchain_t acp, struct urb * urb) /* cancel an urb which is submitted to the chain the result is 0 if the urb is cancelled, or -EINPROGRESS if - URB_ASYNC_UNLINK is set and the function is successfully started. + the function is successfully started. */ static int auerchain_unlink_urb (pauerchain_t acp, struct urb * urb) { @@ -515,7 +515,6 @@ static void auerchain_unlink_all (pauerchain_t acp) acep = acp->active; if (acep) { urbp = acep->urbp; - urbp->transfer_flags &= ~URB_ASYNC_UNLINK; dbg ("unlink active urb"); usb_kill_urb (urbp); } diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 2fd1226..d63ce6c 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c @@ -229,7 +229,7 @@ sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe, usb_fill_bulk_urb(urb, sisusb->sisusb_dev, pipe, data, len, sisusb_bulk_completeout, &sisusb->urbout_context[index]); - urb->transfer_flags |= (tflags | URB_ASYNC_UNLINK); + urb->transfer_flags |= tflags; urb->actual_length = 0; if ((urb->transfer_dma = transfer_dma)) @@ -295,7 +295,7 @@ sisusb_bulkin_msg(struct sisusb_usb_data *sisusb, unsigned int pipe, void *data, usb_fill_bulk_urb(urb, sisusb->sisusb_dev, pipe, data, len, sisusb_bulk_completein, sisusb); - urb->transfer_flags |= (tflags | URB_ASYNC_UNLINK); + urb->transfer_flags |= tflags; urb->actual_length = 0; if ((urb->transfer_dma = transfer_dma)) diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index fd7fb98..54799eb 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -986,7 +986,6 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) u->context = &context; u->complete = ctrl_complete; - u->transfer_flags |= URB_ASYNC_UNLINK; } /* queue the urbs */ @@ -1052,7 +1051,6 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) urb = simple_alloc_urb (testdev_to_usbdev (dev), pipe, size); if (!urb) return -ENOMEM; - urb->transfer_flags |= URB_ASYNC_UNLINK; urb->context = &completion; urb->complete = unlink1_callback; diff --git a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c index c8be912..37ef365 100644 --- a/drivers/usb/net/catc.c +++ b/drivers/usb/net/catc.c @@ -383,7 +383,6 @@ static void catc_tx_done(struct urb *urb, struct pt_regs *regs) if (urb->status == -ECONNRESET) { dbg("Tx Reset."); - urb->transfer_flags &= ~URB_ASYNC_UNLINK; urb->status = 0; catc->netdev->trans_start = jiffies; catc->stats.tx_errors++; @@ -445,7 +444,6 @@ static void catc_tx_timeout(struct net_device *netdev) struct catc *catc = netdev_priv(netdev); warn("Transmit timed out."); - catc->tx_urb->transfer_flags |= URB_ASYNC_UNLINK; usb_unlink_urb(catc->tx_urb); } diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c index 7ffa99b..e04b0ce 100644 --- a/drivers/usb/net/kaweth.c +++ b/drivers/usb/net/kaweth.c @@ -787,7 +787,6 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net) kaweth_usb_transmit_complete, kaweth); kaweth->end = 0; - kaweth->tx_urb->transfer_flags |= URB_ASYNC_UNLINK; if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) { diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c index fcd6d3c..7484d34 100644 --- a/drivers/usb/net/pegasus.c +++ b/drivers/usb/net/pegasus.c @@ -825,7 +825,6 @@ static void pegasus_tx_timeout(struct net_device *net) pegasus_t *pegasus = netdev_priv(net); if (netif_msg_timer(pegasus)) printk(KERN_WARNING "%s: tx timeout\n", net->name); - pegasus->tx_urb->transfer_flags |= URB_ASYNC_UNLINK; usb_unlink_urb(pegasus->tx_urb); pegasus->stats.tx_errors++; } diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c index 59ab40e..c3d4e35 100644 --- a/drivers/usb/net/rtl8150.c +++ b/drivers/usb/net/rtl8150.c @@ -653,7 +653,6 @@ static void rtl8150_tx_timeout(struct net_device *netdev) { rtl8150_t *dev = netdev_priv(netdev); warn("%s: Tx timeout.", netdev->name); - dev->tx_urb->transfer_flags |= URB_ASYNC_UNLINK; usb_unlink_urb(dev->tx_urb); dev->stats.tx_errors++; } diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 4682696..3c6eef4 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -2987,7 +2987,6 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, unsigned flags) usb_fill_bulk_urb (urb, dev->udev, dev->in, skb->data, size, rx_complete, skb); - urb->transfer_flags |= URB_ASYNC_UNLINK; spin_lock_irqsave (&dev->rxq.lock, lockflags); @@ -3561,7 +3560,6 @@ static int usbnet_start_xmit (struct sk_buff *skb, struct net_device *net) usb_fill_bulk_urb (urb, dev->udev, dev->out, skb->data, skb->len, tx_complete, skb); - urb->transfer_flags |= URB_ASYNC_UNLINK; /* don't assume the hardware handles USB_ZERO_PACKET * NOTE: strictly conforming cdc-ether devices should expect diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c index fc01397..c4e479e 100644 --- a/drivers/usb/net/zd1201.c +++ b/drivers/usb/net/zd1201.c @@ -847,7 +847,6 @@ static void zd1201_tx_timeout(struct net_device *dev) return; dev_warn(&zd->usb->dev, "%s: TX timeout, shooting down urb\n", dev->name); - zd->tx_urb->transfer_flags |= URB_ASYNC_UNLINK; usb_unlink_urb(zd->tx_urb); zd->stats.tx_errors++; /* Restart the timeout to quiet the watchdog: */ diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index e428751..c1ba530 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -96,8 +96,8 @@ * or before the URB_ACTIVE bit was set. If so, it's essential to cancel * the URB if it hasn't been cancelled already (i.e., if the URB_ACTIVE bit * is still set). Either way, the function must then wait for the URB to - * finish. Note that because the URB_ASYNC_UNLINK flag is set, the URB can - * still be in progress even after a call to usb_unlink_urb() returns. + * finish. Note that the URB can still be in progress even after a call to + * usb_unlink_urb() returns. * * The idea is that (1) once the ABORTING or DISCONNECTING bit is set, * either the stop_transport() function or the submitting function @@ -158,8 +158,7 @@ static int usb_stor_msg_common(struct us_data *us, int timeout) * hasn't been mapped for DMA. Yes, this is clunky, but it's * easier than always having the caller tell us whether the * transfer buffer has already been mapped. */ - us->current_urb->transfer_flags = - URB_ASYNC_UNLINK | URB_NO_SETUP_DMA_MAP; + us->current_urb->transfer_flags = URB_NO_SETUP_DMA_MAP; if (us->current_urb->transfer_buffer == us->iobuf) us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; us->current_urb->transfer_dma = us->iobuf_dma; diff --git a/include/linux/usb.h b/include/linux/usb.h index 434e351..4dbe580 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -616,7 +616,6 @@ extern int usb_disabled(void); #define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame ignored */ #define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */ #define URB_NO_SETUP_DMA_MAP 0x0008 /* urb->setup_dma valid on submit */ -#define URB_ASYNC_UNLINK 0x0010 /* usb_unlink_urb() returns asap */ #define URB_NO_FSBR 0x0020 /* UHCI-specific */ #define URB_ZERO_PACKET 0x0040 /* Finish bulk OUTs with short packet */ #define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt needed */ @@ -724,13 +723,7 @@ typedef void (*usb_complete_t)(struct urb *, struct pt_regs *); * Initialization: * * All URBs submitted must initialize the dev, pipe, transfer_flags (may be - * zero), and complete fields. - * The URB_ASYNC_UNLINK transfer flag affects later invocations of - * the usb_unlink_urb() routine. Note: Failure to set URB_ASYNC_UNLINK - * with usb_unlink_urb() is deprecated. For synchronous unlinks use - * usb_kill_urb() instead. - * - * All URBs must also initialize + * zero), and complete fields. All URBs must also initialize * transfer_buffer and transfer_buffer_length. They may provide the * URB_SHORT_NOT_OK transfer flag, indicating that short reads are * to be treated as errors; that flag is invalid for write requests. diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 5aa5fe6..bfbec58 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -735,10 +735,9 @@ static int deactivate_urbs(snd_usb_substream_t *subs, int force, int can_sleep) if (test_bit(i, &subs->active_mask)) { if (! test_and_set_bit(i, &subs->unlink_mask)) { struct urb *u = subs->dataurb[i].urb; - if (async) { - u->transfer_flags |= URB_ASYNC_UNLINK; + if (async) usb_unlink_urb(u); - } else + else usb_kill_urb(u); } } @@ -748,10 +747,9 @@ static int deactivate_urbs(snd_usb_substream_t *subs, int force, int can_sleep) if (test_bit(i+16, &subs->active_mask)) { if (! test_and_set_bit(i+16, &subs->unlink_mask)) { struct urb *u = subs->syncurb[i].urb; - if (async) { - u->transfer_flags |= URB_ASYNC_UNLINK; + if (async) usb_unlink_urb(u); - } else + else usb_kill_urb(u); } } -- cgit v0.10.2 From 242cf670c09c05504ce53dfc27f8331a072f169d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 29 Jul 2005 16:11:07 -0400 Subject: [PATCH] USB: fix up URB_ASYNC_UNLINK usages from the usb-serial drivers Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index fb09262..3b958e6 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -383,11 +383,8 @@ static int keyspan_write(struct usb_serial_port *port, dbg("%s - endpoint %d flip %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe), flip); if (this_urb->status == -EINPROGRESS) { - if (this_urb->transfer_flags & URB_ASYNC_UNLINK) - break; if (time_before(jiffies, p_priv->tx_start_time[flip] + 10 * HZ)) break; - this_urb->transfer_flags |= URB_ASYNC_UNLINK; usb_unlink_urb(this_urb); break; } @@ -402,7 +399,6 @@ static int keyspan_write(struct usb_serial_port *port, /* send the data out the bulk port */ this_urb->transfer_buffer_length = todo + dataOffset; - this_urb->transfer_flags &= ~URB_ASYNC_UNLINK; this_urb->dev = port->serial->dev; if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { dbg("usb_submit_urb(write bulk) failed (%d)", err); @@ -1119,10 +1115,8 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp) static inline void stop_urb(struct urb *urb) { - if (urb && urb->status == -EINPROGRESS) { - urb->transfer_flags &= ~URB_ASYNC_UNLINK; + if (urb && urb->status == -EINPROGRESS) usb_kill_urb(urb); - } } static void keyspan_close(struct usb_serial_port *port, struct file *filp) diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 4f985f4..92d0f92 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -273,12 +273,9 @@ static int option_write(struct usb_serial_port *port, this_urb = portdata->out_urbs[i]; if (this_urb->status == -EINPROGRESS) { - if (this_urb->transfer_flags & URB_ASYNC_UNLINK) - continue; if (time_before(jiffies, portdata->tx_start_time[i] + 10 * HZ)) continue; - this_urb->transfer_flags |= URB_ASYNC_UNLINK; usb_unlink_urb(this_urb); continue; } @@ -293,7 +290,6 @@ static int option_write(struct usb_serial_port *port, memcpy (this_urb->transfer_buffer, buf, todo); this_urb->transfer_buffer_length = todo; - this_urb->transfer_flags &= ~URB_ASYNC_UNLINK; this_urb->dev = port->serial->dev; err = usb_submit_urb(this_urb, GFP_ATOMIC); if (err) { @@ -513,10 +509,8 @@ static int option_open(struct usb_serial_port *port, struct file *filp) static inline void stop_urb(struct urb *urb) { - if (urb && urb->status == -EINPROGRESS) { - urb->transfer_flags &= ~URB_ASYNC_UNLINK; + if (urb && urb->status == -EINPROGRESS) usb_kill_urb(urb); - } } static void option_close(struct usb_serial_port *port, struct file *filp) -- cgit v0.10.2 From 68a6457edb8a64fdcc231a4fc5406f6e3f6c9b33 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Wed, 10 Aug 2005 18:30:04 +0100 Subject: [PATCH] USB: Fix HP8200 detection in shuttle_usbat Adding flash-device support to the shuttle_usbat driver in 2.6.11 introduced the need to detect which type of device we are dealing with: CDRW drive, or flash media reader. The detection routine used turned out to not work for HP8200 CDRW users, who saw their devices being detected as a flash disk. This patch (which has been tested on both flash and cdrom) removes some unnecessary code, moves device detection to much later during initialization, and introduces a new detection routine which appears to work. Signed-off-by: Daniel Drake Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index f3b6028..356342c 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c @@ -839,34 +839,31 @@ static int usbat_identify_device(struct us_data *us, rc = usbat_device_reset(us); if (rc != USB_STOR_TRANSPORT_GOOD) return rc; + msleep(25); /* - * By examining the device signature after a reset, we can identify - * whether the device supports the ATAPI packet interface. - * The flash-devices do not support this, whereas the HP CDRW's obviously - * do. - * - * This method is not ideal, but works because no other devices have been - * produced based on the USBAT/USBAT02. - * - * Section 9.1 of the ATAPI-4 spec states (amongst other things) that - * after a device reset, a Cylinder low of 0x14 indicates that the device - * does support packet commands. + * In attempt to distinguish between HP CDRW's and Flash readers, we now + * execute the IDENTIFY PACKET DEVICE command. On ATA devices (i.e. flash + * readers), this command should fail with error. On ATAPI devices (i.e. + * CDROM drives), it should succeed. */ - rc = usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, &status); - if (rc != USB_STOR_XFER_GOOD) - return USB_STOR_TRANSPORT_ERROR; + rc = usbat_write(us, USBAT_ATA, USBAT_ATA_CMD, 0xA1); + if (rc != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; - US_DEBUGP("usbat_identify_device: Cylinder low is %02X\n", status); + rc = usbat_get_status(us, &status); + if (rc != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; - if (status == 0x14) { + // Check for error bit + if (status & 0x01) { + // Device is a CompactFlash reader/writer + US_DEBUGP("usbat_identify_device: Detected Flash reader/writer\n"); + info->devicetype = USBAT_DEV_FLASH; + } else { // Device is HP 8200 US_DEBUGP("usbat_identify_device: Detected HP8200 CDRW\n"); info->devicetype = USBAT_DEV_HP8200; - } else { - // Device is a CompactFlash reader/writer - US_DEBUGP("usbat_identify_device: Detected Flash reader/writer\n"); - info->devicetype = USBAT_DEV_FLASH; } return USB_STOR_TRANSPORT_GOOD; @@ -1239,16 +1236,10 @@ static int usbat_select_and_test_registers(struct us_data *us) { int selector; unsigned char *status = us->iobuf; - unsigned char max_selector = 0xB0; - if (usbat_get_device_type(us) == USBAT_DEV_FLASH) - max_selector = 0xA0; // try device = master, then device = slave. - - for (selector = 0xA0; selector <= max_selector; selector += 0x10) { - - if (usbat_get_device_type(us) == USBAT_DEV_HP8200 && - usbat_write(us, USBAT_ATA, USBAT_ATA_DEVICE, selector) != + for (selector = 0xA0; selector <= 0xB0; selector += 0x10) { + if (usbat_write(us, USBAT_ATA, USBAT_ATA_DEVICE, selector) != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; @@ -1334,60 +1325,30 @@ int init_usbat(struct us_data *us) US_DEBUGP("INIT 3\n"); - // At this point, we need to detect which device we are using - if (usbat_set_transport(us, info)) - return USB_STOR_TRANSPORT_ERROR; - - US_DEBUGP("INIT 4\n"); - - if (usbat_get_device_type(us) == USBAT_DEV_HP8200) { - msleep(250); - - // Write 0x80 to ISA port 0x3F - rc = usbat_write(us, USBAT_ISA, 0x3F, 0x80); - if (rc != USB_STOR_XFER_GOOD) - return USB_STOR_TRANSPORT_ERROR; - - US_DEBUGP("INIT 5\n"); - - // Read ISA port 0x27 - rc = usbat_read(us, USBAT_ISA, 0x27, status); - if (rc != USB_STOR_XFER_GOOD) - return USB_STOR_TRANSPORT_ERROR; - - US_DEBUGP("INIT 6\n"); - - rc = usbat_read_user_io(us, status); - if (rc != USB_STOR_XFER_GOOD) - return USB_STOR_TRANSPORT_ERROR; - - US_DEBUGP("INIT 7\n"); - } - rc = usbat_select_and_test_registers(us); if (rc != USB_STOR_TRANSPORT_GOOD) return rc; - US_DEBUGP("INIT 8\n"); + US_DEBUGP("INIT 4\n"); rc = usbat_read_user_io(us, status); if (rc != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; - US_DEBUGP("INIT 9\n"); + US_DEBUGP("INIT 5\n"); // Enable peripheral control signals and card detect rc = usbat_device_enable_cdt(us); if (rc != USB_STOR_TRANSPORT_GOOD) return rc; - US_DEBUGP("INIT 10\n"); + US_DEBUGP("INIT 6\n"); rc = usbat_read_user_io(us, status); if (rc != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; - US_DEBUGP("INIT 11\n"); + US_DEBUGP("INIT 7\n"); msleep(1400); @@ -1395,13 +1356,19 @@ int init_usbat(struct us_data *us) if (rc != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; - US_DEBUGP("INIT 12\n"); + US_DEBUGP("INIT 8\n"); rc = usbat_select_and_test_registers(us); if (rc != USB_STOR_TRANSPORT_GOOD) return rc; - US_DEBUGP("INIT 13\n"); + US_DEBUGP("INIT 9\n"); + + // At this point, we need to detect which device we are using + if (usbat_set_transport(us, info)) + return USB_STOR_TRANSPORT_ERROR; + + US_DEBUGP("INIT 10\n"); if (usbat_get_device_type(us) == USBAT_DEV_FLASH) { subcountH = 0x02; @@ -1412,7 +1379,7 @@ int init_usbat(struct us_data *us) if (rc != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; - US_DEBUGP("INIT 14\n"); + US_DEBUGP("INIT 11\n"); return USB_STOR_TRANSPORT_GOOD; } -- cgit v0.10.2 From 8b28c7526a302bbfa618f7eab4ef961edd68c9a0 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 10 Aug 2005 17:04:13 -0400 Subject: [PATCH] USB: Code motion in the hub driver This patch (as553) merely moves some code and deletes an unneeded test in the hub driver. This is in preparation for the patch that follows. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index a220a5e..4a4b41f 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -492,6 +492,23 @@ static int hub_hub_status(struct usb_hub *hub, return ret; } +static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) +{ + struct usb_device *hdev = hub->hdev; + int ret; + + if (hdev->children[port1-1] && set_state) { + usb_set_device_state(hdev->children[port1-1], + USB_STATE_NOTATTACHED); + } + ret = clear_port_feature(hdev, port1, USB_PORT_FEAT_ENABLE); + if (ret) + dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n", + port1, ret); + + return ret; +} + static int hub_configure(struct usb_hub *hub, struct usb_endpoint_descriptor *endpoint) { @@ -717,15 +734,12 @@ static void hub_disconnect(struct usb_interface *intf) struct usb_hub *hub = usb_get_intfdata (intf); struct usb_device *hdev; - if (!hub) - return; + usb_set_intfdata (intf, NULL); hdev = hub->hdev; if (hdev->speed == USB_SPEED_HIGH) highspeed_hubs--; - usb_set_intfdata (intf, NULL); - hub_quiesce(hub); usb_free_urb(hub->urb); hub->urb = NULL; @@ -1430,23 +1444,6 @@ static int hub_port_reset(struct usb_hub *hub, int port1, return status; } -static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) -{ - struct usb_device *hdev = hub->hdev; - int ret; - - if (hdev->children[port1-1] && set_state) { - usb_set_device_state(hdev->children[port1-1], - USB_STATE_NOTATTACHED); - } - ret = clear_port_feature(hdev, port1, USB_PORT_FEAT_ENABLE); - if (ret) - dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n", - port1, ret); - - return ret; -} - /* * Disable a port and mark a logical connnect-change event, so that some * time later khubd will disconnect() any existing usb_device on the port -- cgit v0.10.2 From bf193d3cd2a3b73f2df74f57106114867946c09c Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 10 Aug 2005 17:12:31 -0400 Subject: [PATCH] USB: Disconnect children when unbinding the hub driver This patch (as554) makes the hub driver disconnect any child USB devices when it is unbound from a hub. Normally this will never happen, but there are a few oddball ways to unbind the hub driver while leaving the children intact. For example, the new "unbind" sysfs attribute can be used for this purpose. Given that unbinding hubs with children is now safe, the patch also removes the code that prevented people from doing so using usbfs. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 56c082f..b4265aa 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1238,7 +1238,6 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg) int retval = 0; struct usb_interface *intf = NULL; struct usb_driver *driver = NULL; - int i; /* get input parameters and alloc buffer */ if (copy_from_user(&ctrl, arg, sizeof (ctrl))) @@ -1270,15 +1269,6 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg) /* disconnect kernel driver from interface */ case USBDEVFS_DISCONNECT: - /* don't allow the user to unbind the hub driver from - * a hub with children to manage */ - for (i = 0; i < ps->dev->maxchild; ++i) { - if (ps->dev->children[i]) - retval = -EBUSY; - } - if (retval) - break; - down_write(&usb_bus_type.subsys.rwsem); if (intf->dev.driver) { driver = to_usb_driver(intf->dev.driver); diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 4a4b41f..9f54e83 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -729,10 +729,29 @@ fail: static unsigned highspeed_hubs; +/* Called after the hub driver is unbound from a hub with children */ +static void hub_remove_children_work(void *__hub) +{ + struct usb_hub *hub = __hub; + struct usb_device *hdev = hub->hdev; + int i; + + kfree(hub); + + usb_lock_device(hdev); + for (i = 0; i < hdev->maxchild; ++i) { + if (hdev->children[i]) + usb_disconnect(&hdev->children[i]); + } + usb_unlock_device(hdev); + usb_put_dev(hdev); +} + static void hub_disconnect(struct usb_interface *intf) { struct usb_hub *hub = usb_get_intfdata (intf); struct usb_device *hdev; + int n, port1; usb_set_intfdata (intf, NULL); hdev = hub->hdev; @@ -760,8 +779,27 @@ static void hub_disconnect(struct usb_interface *intf) hub->buffer = NULL; } - /* Free the memory */ - kfree(hub); + /* If there are any children then this is an unbind only, not a + * physical disconnection. The active ports must be disabled + * and later on we must call usb_disconnect(). We can't call + * it now because we may not hold the hub's device lock. + */ + n = 0; + for (port1 = 1; port1 <= hdev->maxchild; ++port1) { + if (hdev->children[port1 - 1]) { + ++n; + hub_port_disable(hub, port1, 1); + } + } + + if (n == 0) + kfree(hub); + else { + /* Reuse the hub->leds work_struct for our own purposes */ + INIT_WORK(&hub->leds, hub_remove_children_work, hub); + schedule_work(&hub->leds); + usb_get_dev(hdev); + } } static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) -- cgit v0.10.2 From ba44e7c407e248ed85d4f510728d0284373cf678 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Tue, 9 Aug 2005 15:04:00 +0100 Subject: [PATCH] USB: S3C24XX port numbering fix Fix the port numbering confusion for the S3C24XX platform device information as reported by Rudy This patch ensurs that the the ports are numbered 0 and 1. Signed-off-by: Ben Dooks Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index e940166..3d9bcf7 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c @@ -129,7 +129,7 @@ static void s3c2410_usb_set_power(struct s3c2410_hcd_info *info, if (info->power_control != NULL) { info->port[port-1].power = to; - (info->power_control)(port, to); + (info->power_control)(port-1, to); } } @@ -339,8 +339,8 @@ int usb_hcd_s3c2410_probe (const struct hc_driver *driver, struct usb_hcd *hcd = NULL; int retval; - s3c2410_usb_set_power(dev->dev.platform_data, 0, 1); s3c2410_usb_set_power(dev->dev.platform_data, 1, 1); + s3c2410_usb_set_power(dev->dev.platform_data, 2, 1); hcd = usb_create_hcd(driver, &dev->dev, "s3c24xx"); if (hcd == NULL) -- cgit v0.10.2 From e52b1d3afe698cb77c080ecbe9e745257ff8c81b Mon Sep 17 00:00:00 2001 From: Dale Farnsworth Date: Tue, 9 Aug 2005 12:13:35 -0700 Subject: [PATCH] USB: Fix typo in ohci-ppc-soc.c: usb_hcd_put => usb_put_hcd Signed-off-by: Dale Farnsworth Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c index 17964c3..7066e63 100644 --- a/drivers/usb/host/ohci-ppc-soc.c +++ b/drivers/usb/host/ohci-ppc-soc.c @@ -123,7 +123,7 @@ static void usb_hcd_ppc_soc_remove(struct usb_hcd *hcd, iounmap(hcd->regs); release_mem_region(hcd->rsrc_start, hcd->rsrc_len); - usb_hcd_put(hcd); + usb_put_hcd(hcd); } static int __devinit -- cgit v0.10.2 From 3ea15966ed59f2bc20928c7b0496b4585f6de206 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Thu, 11 Aug 2005 10:15:39 -0400 Subject: [PATCH] USB: Add timeout to usb_lock_device_for_reset This patch (as555) modifies the already-awkward usb_lock_device_for_reset routine in usbcore by adding a timeout. The whole point of the routine is that the caller wants to acquire some semaphores in the wrong order; protecting against the possibility of deadlock by timing out seems only prudent. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index bc966db..109f755 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -912,7 +912,7 @@ int usb_trylock_device(struct usb_device *udev) * is neither BINDING nor BOUND. Rather than sleeping to wait for the * lock, the routine polls repeatedly. This is to prevent deadlock with * disconnect; in some drivers (such as usb-storage) the disconnect() - * callback will block waiting for a device reset to complete. + * or suspend() method will block waiting for a device reset to complete. * * Returns a negative error code for failure, otherwise 1 or 0 to indicate * that the device will or will not have to be unlocked. (0 can be @@ -922,6 +922,8 @@ int usb_trylock_device(struct usb_device *udev) int usb_lock_device_for_reset(struct usb_device *udev, struct usb_interface *iface) { + unsigned long jiffies_expire = jiffies + HZ; + if (udev->state == USB_STATE_NOTATTACHED) return -ENODEV; if (udev->state == USB_STATE_SUSPENDED) @@ -938,6 +940,12 @@ int usb_lock_device_for_reset(struct usb_device *udev, } while (!usb_trylock_device(udev)) { + + /* If we can't acquire the lock after waiting one second, + * we're probably deadlocked */ + if (time_after(jiffies, jiffies_expire)) + return -EBUSY; + msleep(15); if (udev->state == USB_STATE_NOTATTACHED) return -ENODEV; -- cgit v0.10.2 From 3b4d7f79164853e10342d707e32307e0c8054982 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Thu, 11 Aug 2005 15:50:32 -0400 Subject: [PATCH] USB: Support unbinding of the usb_generic driver This patch (as556) adds support for unbinding the usb_generic "driver". That driver only binds to USB devices, as opposed to interfaces, and it does nothing much besides marking which struct device's go with an overall USB device plus providing suspend/resume methods. Now that users can unbind drivers at will using the sysfs "unbind" attribute, we need a rational way of dealing with USB devices that are no longer under full control of the USB stack. The patch handles this by unconfiguring the device, thereby removing all the interfaces and their associated drivers and children. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 109f755..087af73 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -65,6 +65,16 @@ static int generic_probe (struct device *dev) } static int generic_remove (struct device *dev) { + struct usb_device *udev = to_usb_device(dev); + + /* if this is only an unbind, not a physical disconnect, then + * unconfigure the device */ + if (udev->state == USB_STATE_CONFIGURED) + usb_set_configuration(udev, 0); + + /* in case the call failed or the device was suspended */ + if (udev->state >= USB_STATE_CONFIGURED) + usb_disable_device(udev, 0); return 0; } -- cgit v0.10.2 From f956e7cd9ac4618b98022020e638bbdc01d9d65a Mon Sep 17 00:00:00 2001 From: "david-b@pacbell.net" Date: Thu, 11 Aug 2005 19:37:01 -0700 Subject: [PATCH] USB: tweak highspeed timing calculations Use a more correct calculation for highspeed bit times. http://bugzilla.kernel.org/show_bug.cgi?id=3604 This sort if thing might start to make a difference now that the high speed periodic scheduler is more complete -- and even getting used. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index 28055f9..ac451fa 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h @@ -339,11 +339,11 @@ extern int usb_check_bandwidth (struct usb_device *dev, struct urb *urb); * to preallocate bandwidth) */ #define USB2_HOST_DELAY 5 /* nsec, guess */ -#define HS_NSECS(bytes) ( ((55 * 8 * 2083)/1000) \ - + ((2083UL * (3167 + BitTime (bytes)))/1000) \ +#define HS_NSECS(bytes) ( ((55 * 8 * 2083) \ + + (2083UL * (3 + BitTime(bytes))))/1000 \ + USB2_HOST_DELAY) -#define HS_NSECS_ISO(bytes) ( ((38 * 8 * 2083)/1000) \ - + ((2083UL * (3167 + BitTime (bytes)))/1000) \ +#define HS_NSECS_ISO(bytes) ( ((38 * 8 * 2083) \ + + (2083UL * (3 + BitTime(bytes))))/1000 \ + USB2_HOST_DELAY) #define HS_USECS(bytes) NS_TO_US (HS_NSECS(bytes)) #define HS_USECS_ISO(bytes) NS_TO_US (HS_NSECS_ISO(bytes)) -- cgit v0.10.2 From 8f34c2883b894b9a97f07b23b5b86fd65ecd2f85 Mon Sep 17 00:00:00 2001 From: "david-b@pacbell.net" Date: Thu, 11 Aug 2005 19:36:36 -0700 Subject: [PATCH] USB: remove annoying message Avoid an annoying message that can appear if devices are disconnected in the middle of a USB scatterlist operation. Message noted in http://bugzilla.kernel.org/show_bug.cgi?id=4373 (but the real issue there seems to be a SCSI level hang). Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 7419724..c47c8052 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -265,7 +265,9 @@ static void sg_complete (struct urb *urb, struct pt_regs *regs) continue; if (found) { status = usb_unlink_urb (io->urbs [i]); - if (status != -EINPROGRESS && status != -EBUSY) + if (status != -EINPROGRESS + && status != -ENODEV + && status != -EBUSY) dev_err (&io->dev->dev, "%s, unlink --> %d\n", __FUNCTION__, status); -- cgit v0.10.2 From 4fbd55f03e294d18bd7a5c4c98974e157f6f84e7 Mon Sep 17 00:00:00 2001 From: Dale Farnsworth Date: Wed, 10 Aug 2005 17:25:25 -0700 Subject: [PATCH] USB: remove include of asm/usb.h in ohci-ppc-soc.c ohci-ppc-soc.c provides for a platform-specific callback mechanism for when the HC is successfully probed or removed. It turned out that none of the 3 platforms using it need this facility. Also the required include/asm-ppc/usb.h has never been accepted. This patch removes the callback feature and the include of . Signed-off-by: Dale Farnsworth Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c index 7066e63..2515333 100644 --- a/drivers/usb/host/ohci-ppc-soc.c +++ b/drivers/usb/host/ohci-ppc-soc.c @@ -14,8 +14,6 @@ * This file is licenced under the GPL. */ -#include - /* configure so an HC device and id are always provided */ /* always called with process context; sleeping is OK */ @@ -23,9 +21,7 @@ * usb_hcd_ppc_soc_probe - initialize On-Chip HCDs * Context: !in_interrupt() * - * Allocates basic resources for this USB host controller, and - * then invokes the start() method for the HCD associated with it - * through the hotplug entry's driver_data. + * Allocates basic resources for this USB host controller. * * Store this function in the HCD's struct pci_driver as probe(). */ @@ -37,7 +33,6 @@ static int usb_hcd_ppc_soc_probe(const struct hc_driver *driver, struct ohci_hcd *ohci; struct resource *res; int irq; - struct usb_hcd_platform_data *pd = pdev->dev.platform_data; pr_debug("initializing PPC-SOC USB Controller\n"); @@ -73,9 +68,6 @@ static int usb_hcd_ppc_soc_probe(const struct hc_driver *driver, goto err2; } - if (pd->start && (retval = pd->start(pdev))) - goto err3; - ohci = hcd_to_ohci(hcd); ohci->flags |= OHCI_BIG_ENDIAN; ohci_hcd_init(ohci); @@ -85,9 +77,7 @@ static int usb_hcd_ppc_soc_probe(const struct hc_driver *driver, return retval; pr_debug("Removing PPC-SOC USB Controller\n"); - if (pd && pd->stop) - pd->stop(pdev); - err3: + iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); @@ -105,21 +95,17 @@ static int usb_hcd_ppc_soc_probe(const struct hc_driver *driver, * @pdev: USB Host Controller being removed * Context: !in_interrupt() * - * Reverses the effect of usb_hcd_ppc_soc_probe(), first invoking - * the HCD's stop() method. It is always called from a thread + * Reverses the effect of usb_hcd_ppc_soc_probe(). + * It is always called from a thread * context, normally "rmmod", "apmd", or something similar. * */ static void usb_hcd_ppc_soc_remove(struct usb_hcd *hcd, struct platform_device *pdev) { - struct usb_hcd_platform_data *pd = pdev->dev.platform_data; - usb_remove_hcd(hcd); pr_debug("stopping PPC-SOC USB Controller\n"); - if (pd && pd->stop) - pd->stop(pdev); iounmap(hcd->regs); release_mem_region(hcd->rsrc_start, hcd->rsrc_len); -- cgit v0.10.2 From 9bc45e0c01ae268ad5f9e6d35492bbd8197e32f2 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sun, 14 Aug 2005 13:00:58 +0200 Subject: [PATCH] USB: schedule OSS USB drivers for removal Deprecate the OSS USB drivers. This patch includes spelling fixes by Lee Revell. Signed-off-by: Adrian Bunk Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/class/Kconfig b/drivers/usb/class/Kconfig index 0561d02..333e39b 100644 --- a/drivers/usb/class/Kconfig +++ b/drivers/usb/class/Kconfig @@ -4,9 +4,22 @@ comment "USB Device Class drivers" depends on USB +config OBSOLETE_OSS_USB_DRIVER + bool "Obsolete OSS USB drivers" + depends on USB && SOUND + help + This option enables support for the obsolete USB Audio and Midi + drivers that are scheduled for removal in the near future since + there are ALSA drivers for the same hardware. + + Please contact Adrian Bunk if you had to + say Y here because of missing support in the ALSA drivers. + + If unsure, say N. + config USB_AUDIO tristate "USB Audio support" - depends on USB && SOUND + depends on USB && SOUND && OBSOLETE_OSS_USB_DRIVER help Say Y here if you want to connect USB audio equipment such as speakers to your computer's USB port. You only need this if you use @@ -40,10 +53,12 @@ config USB_BLUETOOTH_TTY config USB_MIDI tristate "USB MIDI support" - depends on USB && SOUND + depends on USB && SOUND && OBSOLETE_OSS_USB_DRIVER ---help--- Say Y here if you want to connect a USB MIDI device to your - computer's USB port. This driver is for devices that comply with + computer's USB port. You only need this if you use the OSS + sound system; USB MIDI devices are supported by ALSA's USB + audio driver. This driver is for devices that comply with 'Universal Serial Bus Device Class Definition for MIDI Device'. The following devices are known to work: -- cgit v0.10.2 From dd7d50081f5dafd9392bd79f1ec90d553a7303c9 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Sun, 14 Aug 2005 17:24:26 +0400 Subject: [PATCH] USB ldusb: fmt warnings fixes for 64-bit platforms Fix drivers/usb/misc/ldusb.c: In function `ld_usb_read': drivers/usb/misc/ldusb.c:467: warning: int format, different type arg (arg 4) drivers/usb/misc/ldusb.c: In function `ld_usb_write': drivers/usb/misc/ldusb.c:531: warning: int format, different type arg (arg 4) drivers/usb/misc/ldusb.c:532: warning: int format, different type arg (arg 5) drivers/usb/misc/ldusb.c:532: warning: int format, different type arg (arg 6) Signed-off-by: Alexey Dobriyan Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index ad17892..7e93ac9 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c @@ -464,7 +464,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count, actual_buffer = (size_t*)(dev->ring_buffer + dev->ring_tail*(sizeof(size_t)+dev->interrupt_in_endpoint_size)); bytes_to_read = min(count, *actual_buffer); if (bytes_to_read < *actual_buffer) - dev_warn(&dev->intf->dev, "Read buffer overflow, %d bytes dropped\n", + dev_warn(&dev->intf->dev, "Read buffer overflow, %zd bytes dropped\n", *actual_buffer-bytes_to_read); /* copy one interrupt_in_buffer from ring_buffer into userspace */ @@ -528,8 +528,8 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, /* write the data into interrupt_out_buffer from userspace */ bytes_to_write = min(count, write_buffer_size*dev->interrupt_out_endpoint_size); if (bytes_to_write < count) - dev_warn(&dev->intf->dev, "Write buffer overflow, %d bytes dropped\n",count-bytes_to_write); - dbg_info(&dev->intf->dev, "%s: count = %d, bytes_to_write = %d\n", __FUNCTION__, count, bytes_to_write); + dev_warn(&dev->intf->dev, "Write buffer overflow, %zd bytes dropped\n",count-bytes_to_write); + dbg_info(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n", __FUNCTION__, count, bytes_to_write); if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) { retval = -EFAULT; -- cgit v0.10.2 From f29fc259976e9f4dd1fe8ed59ccdd50e4ea61db0 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 31 Aug 2005 09:52:31 -0700 Subject: [PATCH] USB: usbnet (1/9) clean up framing This starts to prepare the core of "usbnet" to know less about various framing protocols that map Ethernet packets onto USB, so "minidrivers" can be modules that just plug into the core. - Remove some framing-specific code that cluttered the core: * net->hard_header_len records how much space to preallocate; now drivers that add their own framing (Net1080, GeneLink, Zaurus, and RNDIS) will have smoother TX paths. Even for the drivers (Zaurus, Net1080) that need trailers. * defines new dev->hard_mtu, using this "hardware" limit to check changes to the link's settable "software" mtu. * now net->hard_header_len and dev->hard_mtu are set up in the driver bind() routines, if needed. - Transaction ID is no longer specific to the Net1080 framing; RNDIS needs one too. - Creates a new "usbnet.h" header with declarations that are shared between the core and what will be separate modules. - Plus a couple other minor tweaks, like recognizing -ESHUTDOWN means the keventd work should just shut itself down asap. The core code is only about 1/3 of this large file. Splitting out the minidrivers into separate modules (e.g. ones for ASIX adapters, Zaurii and similar, CDC Ethernet, etc), in later patches, will improve maintainability and shrink typical runtime footprints. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig index b104430..135d508 100644 --- a/drivers/usb/net/Kconfig +++ b/drivers/usb/net/Kconfig @@ -247,6 +247,7 @@ config USB_CDCETHER CDC Ethernet is an implementation option for DOCSIS cable modems that support USB connectivity, used for non-Microsoft USB hosts. + The Linux-USB CDC Ethernet Gadget driver is an open implementation. This driver should work with at least the following devices: * Ericsson PipeRider (all variants) diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 3c6eef4..3f2cad6 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -1,6 +1,6 @@ /* * USB Networking Links - * Copyright (C) 2000-2005 by David Brownell + * Copyright (C) 2000-2005 by David Brownell * Copyright (C) 2002 Pavel Machek * Copyright (C) 2003-2005 David Hollis * Copyright (C) 2005 Phil Chang @@ -126,19 +126,18 @@ #include #include #include -#include #include #include #include -#include -#include #include -#include -#include #include #include -#define DRIVER_VERSION "03-Nov-2004" +#include + +#include "usbnet.h" + +#define DRIVER_VERSION "22-Aug-2005" /*-------------------------------------------------------------------------*/ @@ -149,14 +148,16 @@ * One maximum size Ethernet packet takes twenty four of them. * For high speed, each frame comfortably fits almost 36 max size * Ethernet packets (so queues should be bigger). + * + * REVISIT qlens should be members of 'struct usbnet'; the goal is to + * let the USB host controller be busy for 5msec or more before an irq + * is required, under load. Jumbograms change the equation. */ #define RX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? 60 : 4) #define TX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? 60 : 4) -// packets are always ethernet inside -// ... except they can be bigger (limit of 64K with NetChip framing) +/* packets are always ethernet, sometimes wrapped in other framing */ #define MIN_PACKET sizeof(struct ethhdr) -#define MAX_PACKET 32768 // reawaken network queue this soon after stopping; else watchdog barks #define TX_TIMEOUT_JIFFIES (5*HZ) @@ -166,7 +167,7 @@ #define THROTTLE_JIFFIES (HZ/8) // for vendor-specific control operations -#define CONTROL_TIMEOUT_MS 500 +#define CONTROL_TIMEOUT_MS USB_CTRL_GET_TIMEOUT // between wakeups #define UNLINK_TIMEOUT_MS 3 @@ -176,109 +177,6 @@ // randomly generated ethernet address static u8 node_id [ETH_ALEN]; -// state we keep for each device we handle -struct usbnet { - // housekeeping - struct usb_device *udev; - struct driver_info *driver_info; - wait_queue_head_t *wait; - - // i/o info: pipes etc - unsigned in, out; - struct usb_host_endpoint *status; - unsigned maxpacket; - struct timer_list delay; - - // protocol/interface state - struct net_device *net; - struct net_device_stats stats; - int msg_enable; - unsigned long data [5]; - - struct mii_if_info mii; - - // various kinds of pending driver work - struct sk_buff_head rxq; - struct sk_buff_head txq; - struct sk_buff_head done; - struct urb *interrupt; - struct tasklet_struct bh; - - struct work_struct kevent; - unsigned long flags; -# define EVENT_TX_HALT 0 -# define EVENT_RX_HALT 1 -# define EVENT_RX_MEMORY 2 -# define EVENT_STS_SPLIT 3 -# define EVENT_LINK_RESET 4 -}; - -// device-specific info used by the driver -struct driver_info { - char *description; - - int flags; -/* framing is CDC Ethernet, not writing ZLPs (hw issues), or optionally: */ -#define FLAG_FRAMING_NC 0x0001 /* guard against device dropouts */ -#define FLAG_FRAMING_GL 0x0002 /* genelink batches packets */ -#define FLAG_FRAMING_Z 0x0004 /* zaurus adds a trailer */ -#define FLAG_FRAMING_RN 0x0008 /* RNDIS batches, plus huge header */ - -#define FLAG_NO_SETINT 0x0010 /* device can't set_interface() */ -#define FLAG_ETHER 0x0020 /* maybe use "eth%d" names */ - -#define FLAG_FRAMING_AX 0x0040 /* AX88772/178 packets */ - - /* init device ... can sleep, or cause probe() failure */ - int (*bind)(struct usbnet *, struct usb_interface *); - - /* cleanup device ... can sleep, but can't fail */ - void (*unbind)(struct usbnet *, struct usb_interface *); - - /* reset device ... can sleep */ - int (*reset)(struct usbnet *); - - /* see if peer is connected ... can sleep */ - int (*check_connect)(struct usbnet *); - - /* for status polling */ - void (*status)(struct usbnet *, struct urb *); - - /* link reset handling, called from defer_kevent */ - int (*link_reset)(struct usbnet *); - - /* fixup rx packet (strip framing) */ - int (*rx_fixup)(struct usbnet *dev, struct sk_buff *skb); - - /* fixup tx packet (add framing) */ - struct sk_buff *(*tx_fixup)(struct usbnet *dev, - struct sk_buff *skb, unsigned flags); - - // FIXME -- also an interrupt mechanism - // useful for at least PL2301/2302 and GL620USB-A - // and CDC use them to report 'is it connected' changes - - /* for new devices, use the descriptor-reading code instead */ - int in; /* rx endpoint */ - int out; /* tx endpoint */ - - unsigned long data; /* Misc driver specific data */ -}; - -// we record the state for each of our queued skbs -enum skb_state { - illegal = 0, - tx_start, tx_done, - rx_start, rx_done, rx_cleanup -}; - -struct skb_data { // skb->cb is one of these - struct urb *urb; - struct usbnet *dev; - enum skb_state state; - size_t length; -}; - static const char driver_name [] = "usbnet"; /* use ethtool to change the level for any given device */ @@ -286,22 +184,6 @@ static int msg_level = -1; module_param (msg_level, int, 0); MODULE_PARM_DESC (msg_level, "Override default message level"); - -#ifdef DEBUG -#define devdbg(usbnet, fmt, arg...) \ - printk(KERN_DEBUG "%s: " fmt "\n" , (usbnet)->net->name , ## arg) -#else -#define devdbg(usbnet, fmt, arg...) do {} while(0) -#endif - -#define deverr(usbnet, fmt, arg...) \ - printk(KERN_ERR "%s: " fmt "\n" , (usbnet)->net->name , ## arg) -#define devwarn(usbnet, fmt, arg...) \ - printk(KERN_WARNING "%s: " fmt "\n" , (usbnet)->net->name , ## arg) - -#define devinfo(usbnet, fmt, arg...) \ - printk(KERN_INFO "%s: " fmt "\n" , (usbnet)->net->name , ## arg); \ - /*-------------------------------------------------------------------------*/ static void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *); @@ -921,6 +803,11 @@ static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf) ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); mii_nway_restart(&dev->mii); + if (dev->driver_info->flags & FLAG_FRAMING_AX) { + /* REVISIT: adjust hard_header_len too */ + dev->hard_mtu = 2048; + } + return 0; out2: kfree(buf); @@ -1432,9 +1319,8 @@ static int generic_cdc_bind (struct usbnet *dev, struct usb_interface *intf) info->ether->bLength); goto bad_desc; } - dev->net->mtu = le16_to_cpup ( - &info->ether->wMaxSegmentSize) - - ETH_HLEN; + dev->hard_mtu = le16_to_cpu( + info->ether->wMaxSegmentSize); /* because of Zaurus, we may be ignoring the host * side link address we were given. */ @@ -1988,9 +1874,17 @@ genelink_tx_fixup (struct usbnet *dev, struct sk_buff *skb, unsigned flags) return skb; } +static int genelink_bind (struct usbnet *dev, struct usb_interface *intf) +{ + dev->hard_mtu = GL_RCV_BUF_SIZE; + dev->net->hard_header_len += 4; + return 0; +} + static const struct driver_info genelink_info = { .description = "Genesys GeneLink", .flags = FLAG_FRAMING_GL | FLAG_NO_SETINT, + .bind = genelink_bind, .rx_fixup = genelink_rx_fixup, .tx_fixup = genelink_tx_fixup, @@ -2015,7 +1909,6 @@ static const struct driver_info genelink_info = { * *-------------------------------------------------------------------------*/ -#define dev_packet_id data[0] #define frame_errors data[1] /* @@ -2057,6 +1950,9 @@ struct nc_trailer { #define MIN_FRAMED FRAMED_SIZE(0) +/* packets _could_ be up to 64KB... */ +#define NC_MAX_PACKET 32767 + /* * Zero means no timeout; else, how long a 64 byte bulk packet may be queued @@ -2398,16 +2294,14 @@ static void nc_ensure_sync (struct usbnet *dev) static int net1080_rx_fixup (struct usbnet *dev, struct sk_buff *skb) { struct nc_header *header; + struct net_device *net = dev->net; struct nc_trailer *trailer; u16 hdr_len, packet_len; - if (!(skb->len & 0x01) - || MIN_FRAMED > skb->len - || skb->len > FRAMED_SIZE (dev->net->mtu)) { + if (!(skb->len & 0x01)) { dev->stats.rx_frame_errors++; dbg ("rx framesize %d range %d..%d mtu %d", skb->len, - (int)MIN_FRAMED, (int)FRAMED_SIZE (dev->net->mtu), - dev->net->mtu); + net->hard_header_len, dev->hard_mtu, net->mtu); nc_ensure_sync (dev); return 0; } @@ -2415,7 +2309,7 @@ static int net1080_rx_fixup (struct usbnet *dev, struct sk_buff *skb) header = (struct nc_header *) skb->data; hdr_len = le16_to_cpup (&header->hdr_len); packet_len = le16_to_cpup (&header->packet_len); - if (FRAMED_SIZE (packet_len) > MAX_PACKET) { + if (FRAMED_SIZE (packet_len) > NC_MAX_PACKET) { dev->stats.rx_frame_errors++; dbg ("packet too big, %d", packet_len); nc_ensure_sync (dev); @@ -2505,11 +2399,23 @@ net1080_tx_fixup (struct usbnet *dev, struct sk_buff *skb, unsigned flags) return skb2; } +static int net1080_bind (struct usbnet *dev, struct usb_interface *intf) +{ + unsigned extra = sizeof (struct nc_header) + + 1 + + sizeof (struct nc_trailer); + + dev->net->hard_header_len += extra; + dev->hard_mtu = NC_MAX_PACKET; + return 0; +} + static const struct driver_info net1080_info = { .description = "NetChip TurboCONNECT", .flags = FLAG_FRAMING_NC, + .bind = net1080_bind, .reset = net1080_reset, - .check_connect =net1080_check_connect, + .check_connect = net1080_check_connect, .rx_fixup = net1080_rx_fixup, .tx_fixup = net1080_tx_fixup, }; @@ -2690,11 +2596,20 @@ done: return skb; } +static int zaurus_bind (struct usbnet *dev, struct usb_interface *intf) +{ + /* Belcarra's funky framing has other options; mostly + * TRAILERS (!) with 4 bytes CRC, and maybe 2 pad bytes. + */ + dev->net->hard_header_len += 6; + return generic_cdc_bind(dev, intf); +} + static const struct driver_info zaurus_sl5x00_info = { .description = "Sharp Zaurus SL-5x00", .flags = FLAG_FRAMING_Z, .check_connect = always_connected, - .bind = generic_cdc_bind, + .bind = zaurus_bind, .unbind = cdc_unbind, .tx_fixup = zaurus_tx_fixup, }; @@ -2704,7 +2619,7 @@ static const struct driver_info zaurus_pxa_info = { .description = "Sharp Zaurus, PXA-2xx based", .flags = FLAG_FRAMING_Z, .check_connect = always_connected, - .bind = generic_cdc_bind, + .bind = zaurus_bind, .unbind = cdc_unbind, .tx_fixup = zaurus_tx_fixup, }; @@ -2714,7 +2629,7 @@ static const struct driver_info olympus_mxl_info = { .description = "Olympus R1000", .flags = FLAG_FRAMING_Z, .check_connect = always_connected, - .bind = generic_cdc_bind, + .bind = zaurus_bind, .unbind = cdc_unbind, .tx_fixup = zaurus_tx_fixup, }; @@ -2868,22 +2783,12 @@ static const struct driver_info bogus_mdlm_info = { static int usbnet_change_mtu (struct net_device *net, int new_mtu) { struct usbnet *dev = netdev_priv(net); + int ll_mtu = new_mtu + net->hard_header_len; - if (new_mtu <= MIN_PACKET || new_mtu > MAX_PACKET) - return -EINVAL; -#ifdef CONFIG_USB_NET1080 - if (((dev->driver_info->flags) & FLAG_FRAMING_NC)) { - if (FRAMED_SIZE (new_mtu) > MAX_PACKET) - return -EINVAL; - } -#endif -#ifdef CONFIG_USB_GENESYS - if (((dev->driver_info->flags) & FLAG_FRAMING_GL) - && new_mtu > GL_MAX_PACKET_LEN) + if (new_mtu <= 0 || ll_mtu > dev->hard_mtu) return -EINVAL; -#endif // no second zero-length packet read wanted after mtu-sized packets - if (((new_mtu + sizeof (struct ethhdr)) % dev->maxpacket) == 0) + if ((ll_mtu % dev->maxpacket) == 0) return -EDOM; net->mtu = new_mtu; return 0; @@ -2943,33 +2848,8 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, unsigned flags) unsigned long lockflags; size_t size; -#ifdef CONFIG_USB_NET1080 - if (dev->driver_info->flags & FLAG_FRAMING_NC) - size = FRAMED_SIZE (dev->net->mtu); - else -#endif -#ifdef CONFIG_USB_GENESYS - if (dev->driver_info->flags & FLAG_FRAMING_GL) - size = GL_RCV_BUF_SIZE; - else -#endif -#ifdef CONFIG_USB_ZAURUS - if (dev->driver_info->flags & FLAG_FRAMING_Z) - size = 6 + (sizeof (struct ethhdr) + dev->net->mtu); - else -#endif -#ifdef CONFIG_USB_RNDIS - if (dev->driver_info->flags & FLAG_FRAMING_RN) - size = RNDIS_MAX_TRANSFER; - else -#endif -#ifdef CONFIG_USB_AX8817X - if (dev->driver_info->flags & FLAG_FRAMING_AX) - size = 2048; - else -#endif - size = (sizeof (struct ethhdr) + dev->net->mtu); - + size = max(dev->net->hard_header_len + dev->net->mtu, + (unsigned)ETH_FRAME_LEN); if ((skb = alloc_skb (size + NET_IP_ALIGN, flags)) == NULL) { if (netif_msg_rx_err (dev)) devdbg (dev, "no rx skb"); @@ -3062,7 +2942,7 @@ static void rx_complete (struct urb *urb, struct pt_regs *regs) switch (urb_status) { // success case 0: - if (MIN_PACKET > skb->len || skb->len > MAX_PACKET) { + if (skb->len < dev->net->hard_header_len) { entry->state = rx_cleanup; dev->stats.rx_errors++; dev->stats.rx_length_errors++; @@ -3334,11 +3214,11 @@ static u32 usbnet_get_link (struct net_device *net) { struct usbnet *dev = netdev_priv(net); - /* If a check_connect is defined, return it's results */ + /* If a check_connect is defined, return its result */ if (dev->driver_info->check_connect) return dev->driver_info->check_connect (dev) == 0; - /* Otherwise, we're up to avoid breaking scripts */ + /* Otherwise, say we're up (to avoid breaking scripts) */ return 1; } @@ -3386,19 +3266,24 @@ kevent (void *data) if (test_bit (EVENT_TX_HALT, &dev->flags)) { unlink_urbs (dev, &dev->txq); status = usb_clear_halt (dev->udev, dev->out); - if (status < 0 && status != -EPIPE) { + if (status < 0 + && status != -EPIPE + && status != -ESHUTDOWN) { if (netif_msg_tx_err (dev)) deverr (dev, "can't clear tx halt, status %d", status); } else { clear_bit (EVENT_TX_HALT, &dev->flags); - netif_wake_queue (dev->net); + if (status != -ESHUTDOWN) + netif_wake_queue (dev->net); } } if (test_bit (EVENT_RX_HALT, &dev->flags)) { unlink_urbs (dev, &dev->rxq); status = usb_clear_halt (dev->udev, dev->in); - if (status < 0 && status != -EPIPE) { + if (status < 0 + && status != -EPIPE + && status != -ESHUTDOWN) { if (netif_msg_rx_err (dev)) deverr (dev, "can't clear rx halt, status %d", status); @@ -3574,7 +3459,7 @@ static int usbnet_start_xmit (struct sk_buff *skb, struct net_device *net) #ifdef CONFIG_USB_NET1080 if (info->flags & FLAG_FRAMING_NC) { - header->packet_id = cpu_to_le16 ((u16)dev->dev_packet_id++); + header->packet_id = cpu_to_le16 ((u16)dev->xid++); put_unaligned (header->packet_id, &trailer->packet_id); #if 0 devdbg (dev, "frame >tx h %d p %d id %d", @@ -3776,6 +3661,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) dev->net = net; strcpy (net->name, "usb%d"); memcpy (net->dev_addr, node_id, sizeof node_id); + dev->hard_mtu = net->mtu + net->hard_header_len; #if 0 // dma_supported() is deeply broken on almost all architectures @@ -3804,6 +3690,10 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) if ((dev->driver_info->flags & FLAG_ETHER) != 0 && (net->dev_addr [0] & 0x02) == 0) strcpy (net->name, "eth%d"); + + /* maybe the remote can't receive an Ethernet MTU */ + if (net->mtu > (dev->hard_mtu - net->hard_header_len)) + net->mtu = dev->hard_mtu - net->hard_header_len; } else if (!info->in || info->out) status = get_endpoints (dev, udev); else { @@ -3817,7 +3707,6 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) status = 0; } - if (status == 0 && dev->status) status = init_status (dev, udev); if (status < 0) @@ -4212,7 +4101,7 @@ static struct ethtool_ops usbnet_ethtool_ops = { /*-------------------------------------------------------------------------*/ -static int __init usbnet_init (void) +static int __init usbnet_init(void) { // compiler should optimize these out BUG_ON (sizeof (((struct sk_buff *)0)->cb) @@ -4226,14 +4115,14 @@ static int __init usbnet_init (void) return usb_register(&usbnet_driver); } -module_init (usbnet_init); +module_init(usbnet_init); -static void __exit usbnet_exit (void) +static void __exit usbnet_exit(void) { - usb_deregister (&usbnet_driver); + usb_deregister(&usbnet_driver); } -module_exit (usbnet_exit); +module_exit(usbnet_exit); -MODULE_AUTHOR ("David Brownell "); -MODULE_DESCRIPTION ("USB Host-to-Host Link Drivers (numerous vendors)"); -MODULE_LICENSE ("GPL"); +MODULE_AUTHOR("David Brownell"); +MODULE_DESCRIPTION("USB Host-to-Host Link Drivers (numerous vendors)"); +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h new file mode 100644 index 0000000..4402618 --- /dev/null +++ b/drivers/usb/net/usbnet.h @@ -0,0 +1,150 @@ +/* + * USB Networking Link Interface + * + * Copyright (C) 2000-2005 by David Brownell + * Copyright (C) 2003-2005 David Hollis + * + * 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 + */ + + +#ifndef __USBNET_H +#define __USBNET_H + + +/* interface from usbnet core to each USB networking device we handle */ +struct usbnet { + /* housekeeping */ + struct usb_device *udev; + struct driver_info *driver_info; + wait_queue_head_t *wait; + + /* i/o info: pipes etc */ + unsigned in, out; + struct usb_host_endpoint *status; + unsigned maxpacket; + struct timer_list delay; + + /* protocol/interface state */ + struct net_device *net; + struct net_device_stats stats; + int msg_enable; + unsigned long data [5]; + u32 xid; + u32 hard_mtu; /* count any extra framing */ + struct mii_if_info mii; + + /* various kinds of pending driver work */ + struct sk_buff_head rxq; + struct sk_buff_head txq; + struct sk_buff_head done; + struct urb *interrupt; + struct tasklet_struct bh; + + struct work_struct kevent; + unsigned long flags; +# define EVENT_TX_HALT 0 +# define EVENT_RX_HALT 1 +# define EVENT_RX_MEMORY 2 +# define EVENT_STS_SPLIT 3 +# define EVENT_LINK_RESET 4 +}; + + +/* interface from the device/framing level "minidriver" to core */ +struct driver_info { + char *description; + + int flags; +/* framing is CDC Ethernet, not writing ZLPs (hw issues), or optionally: */ +#define FLAG_FRAMING_NC 0x0001 /* guard against device dropouts */ +#define FLAG_FRAMING_GL 0x0002 /* genelink batches packets */ +#define FLAG_FRAMING_Z 0x0004 /* zaurus adds a trailer */ +#define FLAG_FRAMING_RN 0x0008 /* RNDIS batches, plus huge header */ + +#define FLAG_NO_SETINT 0x0010 /* device can't set_interface() */ +#define FLAG_ETHER 0x0020 /* maybe use "eth%d" names */ + +#define FLAG_FRAMING_AX 0x0040 /* AX88772/178 packets */ + + /* init device ... can sleep, or cause probe() failure */ + int (*bind)(struct usbnet *, struct usb_interface *); + + /* cleanup device ... can sleep, but can't fail */ + void (*unbind)(struct usbnet *, struct usb_interface *); + + /* reset device ... can sleep */ + int (*reset)(struct usbnet *); + + /* see if peer is connected ... can sleep */ + int (*check_connect)(struct usbnet *); + + /* for status polling */ + void (*status)(struct usbnet *, struct urb *); + + /* link reset handling, called from defer_kevent */ + int (*link_reset)(struct usbnet *); + + /* fixup rx packet (strip framing) */ + int (*rx_fixup)(struct usbnet *dev, struct sk_buff *skb); + + /* fixup tx packet (add framing) */ + struct sk_buff *(*tx_fixup)(struct usbnet *dev, + struct sk_buff *skb, unsigned flags); + + /* for new devices, use the descriptor-reading code instead */ + int in; /* rx endpoint */ + int out; /* tx endpoint */ + + unsigned long data; /* Misc driver specific data */ +}; + + +/* we record the state for each of our queued skbs */ +enum skb_state { + illegal = 0, + tx_start, tx_done, + rx_start, rx_done, rx_cleanup +}; + +struct skb_data { /* skb->cb is one of these */ + struct urb *urb; + struct usbnet *dev; + enum skb_state state; + size_t length; +}; + + + +/* messaging support includes the interface name, so it must not be + * used before it has one ... notably, in minidriver bind() calls. + */ +#ifdef DEBUG +#define devdbg(usbnet, fmt, arg...) \ + printk(KERN_DEBUG "%s: " fmt "\n" , (usbnet)->net->name , ## arg) +#else +#define devdbg(usbnet, fmt, arg...) do {} while(0) +#endif + +#define deverr(usbnet, fmt, arg...) \ + printk(KERN_ERR "%s: " fmt "\n" , (usbnet)->net->name , ## arg) +#define devwarn(usbnet, fmt, arg...) \ + printk(KERN_WARNING "%s: " fmt "\n" , (usbnet)->net->name , ## arg) + +#define devinfo(usbnet, fmt, arg...) \ + printk(KERN_INFO "%s: " fmt "\n" , (usbnet)->net->name , ## arg); \ + + +#endif /* __USBNET_H */ -- cgit v0.10.2 From 38bde1d4699af45e6a4167a72e2e512e45c35ca8 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 31 Aug 2005 09:52:45 -0700 Subject: [PATCH] USB: usbnet (2/9) module for simple network links This patch creates the first of several separate "minidriver" modules for "usbnet". This one handles only the very simplest hardware, which can be handled almost entirely by the "usbnet" core. - Move device-specific bits into new "cdc_subset.c" driver, shrinking "usbnet" by a bunch; - Export the functions needed to support this minidriver (with EXPORT_SYMBOL_GPL); - Update Kconfig and kbuild accordingly. This one handles about a dozen different device types, with the most notable ones being Gumstix and most Linux-based PDAs (except Zaurus running that ancient code from Sharp). Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig index 135d508..6399b43 100644 --- a/drivers/usb/net/Kconfig +++ b/drivers/usb/net/Kconfig @@ -128,32 +128,6 @@ config USB_USBNET comment "USB Host-to-Host Cables" depends on USB_USBNET -config USB_ALI_M5632 - boolean "ALi M5632 based 'USB 2.0 Data Link' cables" - depends on USB_USBNET - default y - help - Choose this option if you're using a host-to-host cable - based on this design, which supports USB 2.0 high speed. - -config USB_AN2720 - boolean "AnchorChips 2720 based cables (Xircom PGUNET, ...)" - depends on USB_USBNET - default y - help - Choose this option if you're using a host-to-host cable - based on this design. Note that AnchorChips is now a - Cypress brand. - -config USB_BELKIN - boolean "eTEK based host-to-host cables (Advance, Belkin, ...)" - depends on USB_USBNET - default y - help - Choose this option if you're using a host-to-host cable - based on this design: two NetChip 2890 chips and an Atmel - microcontroller, with LEDs that indicate traffic. - config USB_GENESYS boolean "GeneSys GL620USB-A based cables" default y @@ -182,42 +156,9 @@ config USB_PL2301 Choose this option if you're using a host-to-host cable with one of these chips. -config USB_KC2190 - boolean "KT Technology KC2190 based cables (InstaNet)" - default y - depends on USB_USBNET && EXPERIMENTAL - help - Choose this option if you're using a host-to-host cable - with one of these chips. - comment "Intelligent USB Devices/Gadgets" depends on USB_USBNET -config USB_ARMLINUX - boolean "Embedded ARM Linux links (iPaq, ...)" - depends on USB_USBNET - default y - help - Choose this option to support the "usb-eth" networking driver - used by most of the ARM Linux community with device controllers - such as the SA-11x0 and PXA-25x UDCs, or the tftp capabilities - in some PXA versions of the "blob" boot loader. - - Linux-based "Gumstix" PXA-25x based systems use this protocol - to talk with other Linux systems. - - Although the ROMs shipped with Sharp Zaurus products use a - different link level framing protocol, you can have them use - this simpler protocol by installing a different kernel. - -config USB_EPSON2888 - boolean "Epson 2888 based firmware (DEVELOPMENT)" - depends on USB_USBNET - default y - help - Choose this option to support the usb networking links used - by some sample firmware from Epson. - config USB_ZAURUS boolean "Sharp Zaurus (stock ROMs) and compatible" depends on USB_USBNET @@ -292,6 +233,70 @@ config USB_AX8817X This driver creates an interface named "ethX", where X depends on what other networking devices you have in use. + +config USB_NET_CDC_SUBSET + tristate "Simple USB Network Links (CDC Ethernet subset)" + depends on USB_USBNET + help + This driver module supports USB network devices that can work + without any device-specific information. Select it if you have + one of these drivers. + + Note that while many USB host-to-host cables can work in this mode, + that may mean not being able to talk to Win32 systems or more + commonly not being able to handle certain events (like replugging + the host on the other end) very well. Also, these devices will + not generally have permanently assigned Ethernet addresses. + +config USB_ALI_M5632 + boolean "ALi M5632 based 'USB 2.0 Data Link' cables" + depends on USB_NET_CDC_SUBSET + help + Choose this option if you're using a host-to-host cable + based on this design, which supports USB 2.0 high speed. + +config USB_AN2720 + boolean "AnchorChips 2720 based cables (Xircom PGUNET, ...)" + depends on USB_NET_CDC_SUBSET + help + Choose this option if you're using a host-to-host cable + based on this design. Note that AnchorChips is now a + Cypress brand. + +config USB_BELKIN + boolean "eTEK based host-to-host cables (Advance, Belkin, ...)" + depends on USB_NET_CDC_SUBSET + default y + help + Choose this option if you're using a host-to-host cable + based on this design: two NetChip 2890 chips and an Atmel + microcontroller, with LEDs that indicate traffic. + +config USB_ARMLINUX + boolean "Embedded ARM Linux links (iPaq, ...)" + depends on USB_NET_CDC_SUBSET + default y + help + Choose this option to support the "usb-eth" networking driver + used by most of the ARM Linux community with device controllers + such as the SA-11x0 and PXA-25x UDCs, or the tftp capabilities + in some PXA versions of the "blob" boot loader. + + Linux-based "Gumstix" PXA-25x based systems use this protocol + to talk with other Linux systems. + + Although the ROMs shipped with Sharp Zaurus products use a + different link level framing protocol, you can have them use + this simpler protocol by installing a different kernel. + +config USB_EPSON2888 + boolean "Epson 2888 based firmware (DEVELOPMENT)" + depends on USB_NET_CDC_SUBSET + help + Choose this option to support the usb networking links used + by some sample firmware from Epson. + + config USB_ZD1201 tristate "USB ZD1201 based Wireless device support" depends on NET_RADIO diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile index fe3fd41..23608cc 100644 --- a/drivers/usb/net/Makefile +++ b/drivers/usb/net/Makefile @@ -6,5 +6,6 @@ obj-$(CONFIG_USB_CATC) += catc.o obj-$(CONFIG_USB_KAWETH) += kaweth.o obj-$(CONFIG_USB_PEGASUS) += pegasus.o obj-$(CONFIG_USB_RTL8150) += rtl8150.o +obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o obj-$(CONFIG_USB_USBNET) += usbnet.o obj-$(CONFIG_USB_ZD1201) += zd1201.o diff --git a/drivers/usb/net/cdc_subset.c b/drivers/usb/net/cdc_subset.c new file mode 100644 index 0000000..f1730b6 --- /dev/null +++ b/drivers/usb/net/cdc_subset.c @@ -0,0 +1,335 @@ +/* + * Simple "CDC Subset" USB Networking Links + * Copyright (C) 2000-2005 by David Brownell + * + * 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 +#ifdef CONFIG_USB_DEBUG +# define DEBUG +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "usbnet.h" + + +/* + * This supports simple USB network links that don't require any special + * framing or hardware control operations. The protocol used here is a + * strict subset of CDC Ethernet, with three basic differences reflecting + * the goal that almost any hardware should run it: + * + * - Minimal runtime control: one interface, no altsettings, and + * no vendor or class specific control requests. If a device is + * configured, it is allowed to exchange packets with the host. + * Fancier models would mean not working on some hardware. + * + * - Minimal manufacturing control: no IEEE "Organizationally + * Unique ID" required, or an EEPROMs to store one. Each host uses + * one random "locally assigned" Ethernet address instead, which can + * of course be overridden using standard tools like "ifconfig". + * (With 2^46 such addresses, same-net collisions are quite rare.) + * + * - There is no additional framing data for USB. Packets are written + * exactly as in CDC Ethernet, starting with an Ethernet header and + * terminated by a short packet. However, the host will never send a + * zero length packet; some systems can't handle those robustly. + * + * Anything that can transmit and receive USB bulk packets can implement + * this protocol. That includes both smart peripherals and quite a lot + * of "host-to-host" USB cables (which embed two devices back-to-back). + * + * Note that although Linux may use many of those host-to-host links + * with this "cdc_subset" framing, that doesn't mean there may not be a + * better approach. Handling the "other end unplugs/replugs" scenario + * well tends to require chip-specific vendor requests. Also, Windows + * peers at the other end of host-to-host cables may expect their own + * framing to be used rather than this "cdc_subset" model. + */ + +#if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX) +/* PDA style devices are always connected if present */ +static int always_connected (struct usbnet *dev) +{ + return 0; +} +#endif + +#ifdef CONFIG_USB_ALI_M5632 +#define HAVE_HARDWARE + +/*------------------------------------------------------------------------- + * + * ALi M5632 driver ... does high speed + * + *-------------------------------------------------------------------------*/ + +static const struct driver_info ali_m5632_info = { + .description = "ALi M5632", +}; + + +#endif + + +#ifdef CONFIG_USB_AN2720 +#define HAVE_HARDWARE + +/*------------------------------------------------------------------------- + * + * AnchorChips 2720 driver ... http://www.cypress.com + * + * This doesn't seem to have a way to detect whether the peer is + * connected, or need any reset handshaking. It's got pretty big + * internal buffers (handles most of a frame's worth of data). + * Chip data sheets don't describe any vendor control messages. + * + *-------------------------------------------------------------------------*/ + +static const struct driver_info an2720_info = { + .description = "AnchorChips/Cypress 2720", + // no reset available! + // no check_connect available! + + .in = 2, .out = 2, // direction distinguishes these +}; + +#endif /* CONFIG_USB_AN2720 */ + + +#ifdef CONFIG_USB_BELKIN +#define HAVE_HARDWARE + +/*------------------------------------------------------------------------- + * + * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller + * + * ... also two eTEK designs, including one sold as "Advance USBNET" + * + *-------------------------------------------------------------------------*/ + +static const struct driver_info belkin_info = { + .description = "Belkin, eTEK, or compatible", +}; + +#endif /* CONFIG_USB_BELKIN */ + + + +#ifdef CONFIG_USB_EPSON2888 +#define HAVE_HARDWARE + +/*------------------------------------------------------------------------- + * + * EPSON USB clients + * + * This is the same idea as Linux PDAs (below) except the firmware in the + * device might not be Tux-powered. Epson provides reference firmware that + * implements this interface. Product developers can reuse or modify that + * code, such as by using their own product and vendor codes. + * + * Support was from Juro Bystricky + * + *-------------------------------------------------------------------------*/ + +static const struct driver_info epson2888_info = { + .description = "Epson USB Device", + .check_connect = always_connected, + + .in = 4, .out = 3, +}; + +#endif /* CONFIG_USB_EPSON2888 */ + + +#ifdef CONFIG_USB_KC2190 +#define HAVE_HARDWARE +static const struct driver_info kc2190_info = { + .description = "KC Technology KC-190", +}; +#endif /* CONFIG_USB_KC2190 */ + + +#ifdef CONFIG_USB_ARMLINUX +#define HAVE_HARDWARE + +/*------------------------------------------------------------------------- + * + * Intel's SA-1100 chip integrates basic USB support, and is used + * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more. + * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to + * network using minimal USB framing data. + * + * This describes the driver currently in standard ARM Linux kernels. + * The Zaurus uses a different driver (see later). + * + * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support + * and different USB endpoint numbering than the SA1100 devices. The + * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100 + * so we rely on the endpoint descriptors. + * + *-------------------------------------------------------------------------*/ + +static const struct driver_info linuxdev_info = { + .description = "Linux Device", + .check_connect = always_connected, +}; + +static const struct driver_info yopy_info = { + .description = "Yopy", + .check_connect = always_connected, +}; + +static const struct driver_info blob_info = { + .description = "Boot Loader OBject", + .check_connect = always_connected, +}; + +#endif /* CONFIG_USB_ARMLINUX */ + + +/*-------------------------------------------------------------------------*/ + +#ifndef HAVE_HARDWARE +#error You need to configure some hardware for this driver +#endif + +/* + * chip vendor names won't normally be on the cables, and + * may not be on the device. + */ + +static const struct usb_device_id products [] = { + +#ifdef CONFIG_USB_ALI_M5632 +{ + USB_DEVICE (0x0402, 0x5632), // ALi defaults + .driver_info = (unsigned long) &ali_m5632_info, +}, +#endif + +#ifdef CONFIG_USB_AN2720 +{ + USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults + .driver_info = (unsigned long) &an2720_info, +}, { + USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET + .driver_info = (unsigned long) &an2720_info, +}, +#endif + +#ifdef CONFIG_USB_BELKIN +{ + USB_DEVICE (0x050d, 0x0004), // Belkin + .driver_info = (unsigned long) &belkin_info, +}, { + USB_DEVICE (0x056c, 0x8100), // eTEK + .driver_info = (unsigned long) &belkin_info, +}, { + USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK) + .driver_info = (unsigned long) &belkin_info, +}, +#endif + +#ifdef CONFIG_USB_EPSON2888 +{ + USB_DEVICE (0x0525, 0x2888), // EPSON USB client + .driver_info = (unsigned long) &epson2888_info, +}, +#endif + +#ifdef CONFIG_USB_KC2190 +{ + USB_DEVICE (0x050f, 0x0190), // KC-190 + .driver_info = (unsigned long) &kc2190_info, +}, +#endif + +#ifdef CONFIG_USB_ARMLINUX +/* + * SA-1100 using standard ARM Linux kernels, or compatible. + * Often used when talking to Linux PDAs (iPaq, Yopy, etc). + * The sa-1100 "usb-eth" driver handles the basic framing. + * + * PXA25x or PXA210 ... these use a "usb-eth" driver much like + * the sa1100 one, but hardware uses different endpoint numbers. + * + * Or the Linux "Ethernet" gadget on hardware that can't talk + * CDC Ethernet (e.g., no altsettings), in either of two modes: + * - acting just like the old "usb-eth" firmware, though + * the implementation is different + * - supporting RNDIS as the first/default configuration for + * MS-Windows interop; Linux needs to use the other config + */ +{ + // 1183 = 0x049F, both used as hex values? + // Compaq "Itsy" vendor/product id + USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible + .driver_info = (unsigned long) &linuxdev_info, +}, { + USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy" + .driver_info = (unsigned long) &yopy_info, +}, { + USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader + .driver_info = (unsigned long) &blob_info, +}, { + // Linux Ethernet/RNDIS gadget on pxa210/25x/26x, second config + // e.g. Gumstix, current OpenZaurus, ... + USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203), + .driver_info = (unsigned long) &linuxdev_info, +}, +#endif + + { }, // END +}; +MODULE_DEVICE_TABLE(usb, products); + +/*-------------------------------------------------------------------------*/ + +static struct usb_driver cdc_subset_driver = { + .owner = THIS_MODULE, + .name = "cdc_subset", + .probe = usbnet_probe, + .suspend = usbnet_suspend, + .resume = usbnet_resume, + .disconnect = usbnet_disconnect, + .id_table = products, +}; + +static int __init cdc_subset_init(void) +{ + return usb_register(&cdc_subset_driver); +} +module_init(cdc_subset_init); + +static void __exit cdc_subset_exit(void) +{ + usb_deregister(&cdc_subset_driver); +} +module_exit(cdc_subset_exit); + +MODULE_AUTHOR("David Brownell"); +MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links"); +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 3f2cad6..57b41fb 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -322,48 +322,6 @@ static void skb_return (struct usbnet *dev, struct sk_buff *skb) } -#ifdef CONFIG_USB_ALI_M5632 -#define HAVE_HARDWARE - -/*------------------------------------------------------------------------- - * - * ALi M5632 driver ... does high speed - * - *-------------------------------------------------------------------------*/ - -static const struct driver_info ali_m5632_info = { - .description = "ALi M5632", -}; - - -#endif - - -#ifdef CONFIG_USB_AN2720 -#define HAVE_HARDWARE - -/*------------------------------------------------------------------------- - * - * AnchorChips 2720 driver ... http://www.cypress.com - * - * This doesn't seem to have a way to detect whether the peer is - * connected, or need any reset handshaking. It's got pretty big - * internal buffers (handles most of a frame's worth of data). - * Chip data sheets don't describe any vendor control messages. - * - *-------------------------------------------------------------------------*/ - -static const struct driver_info an2720_info = { - .description = "AnchorChips/Cypress 2720", - // no reset available! - // no check_connect available! - - .in = 2, .out = 2, // direction distinguishes these -}; - -#endif /* CONFIG_USB_AN2720 */ - - #ifdef CONFIG_USB_AX8817X /* ASIX AX8817X based USB 2.0 Ethernet Devices */ @@ -1142,25 +1100,6 @@ static const struct driver_info ax88772_info = { -#ifdef CONFIG_USB_BELKIN -#define HAVE_HARDWARE - -/*------------------------------------------------------------------------- - * - * Belkin F5U104 ... two NetChip 2280 devices + Atmel microcontroller - * - * ... also two eTEK designs, including one sold as "Advance USBNET" - * - *-------------------------------------------------------------------------*/ - -static const struct driver_info belkin_info = { - .description = "Belkin, eTEK, or compatible", -}; - -#endif /* CONFIG_USB_BELKIN */ - - - /*------------------------------------------------------------------------- * * Communications Device Class declarations. @@ -1538,32 +1477,6 @@ static const struct driver_info cdc_info = { -#ifdef CONFIG_USB_EPSON2888 -#define HAVE_HARDWARE - -/*------------------------------------------------------------------------- - * - * EPSON USB clients - * - * This is the same idea as Linux PDAs (below) except the firmware in the - * device might not be Tux-powered. Epson provides reference firmware that - * implements this interface. Product developers can reuse or modify that - * code, such as by using their own product and vendor codes. - * - * Support was from Juro Bystricky - * - *-------------------------------------------------------------------------*/ - -static const struct driver_info epson2888_info = { - .description = "Epson USB Device", - .check_connect = always_connected, - - .in = 4, .out = 3, -}; - -#endif /* CONFIG_USB_EPSON2888 */ - - #ifdef CONFIG_USB_GENESYS #define HAVE_HARDWARE @@ -2495,52 +2408,6 @@ static const struct driver_info prolific_info = { #endif /* CONFIG_USB_PL2301 */ -#ifdef CONFIG_USB_KC2190 -#define HAVE_HARDWARE -static const struct driver_info kc2190_info = { - .description = "KC Technology KC-190", -}; -#endif /* CONFIG_USB_KC2190 */ - - -#ifdef CONFIG_USB_ARMLINUX -#define HAVE_HARDWARE - -/*------------------------------------------------------------------------- - * - * Intel's SA-1100 chip integrates basic USB support, and is used - * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more. - * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to - * network using minimal USB framing data. - * - * This describes the driver currently in standard ARM Linux kernels. - * The Zaurus uses a different driver (see later). - * - * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support - * and different USB endpoint numbering than the SA1100 devices. The - * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100 - * so we rely on the endpoint descriptors. - * - *-------------------------------------------------------------------------*/ - -static const struct driver_info linuxdev_info = { - .description = "Linux Device", - .check_connect = always_connected, -}; - -static const struct driver_info yopy_info = { - .description = "Yopy", - .check_connect = always_connected, -}; - -static const struct driver_info blob_info = { - .description = "Boot Loader OBject", - .check_connect = always_connected, -}; - -#endif /* CONFIG_USB_ARMLINUX */ - - #ifdef CONFIG_USB_ZAURUS #define HAVE_HARDWARE @@ -3575,7 +3442,7 @@ static void usbnet_bh (unsigned long param) // precondition: never called in_interrupt -static void usbnet_disconnect (struct usb_interface *intf) +void usbnet_disconnect (struct usb_interface *intf) { struct usbnet *dev; struct usb_device *xdev; @@ -3589,7 +3456,8 @@ static void usbnet_disconnect (struct usb_interface *intf) xdev = interface_to_usbdev (intf); if (netif_msg_probe (dev)) - devinfo (dev, "unregister usbnet usb-%s-%s, %s", + devinfo (dev, "unregister '%s' usb-%s-%s, %s", + intf->dev.driver->name, xdev->bus->bus_name, xdev->devpath, dev->driver_info->description); @@ -3605,6 +3473,7 @@ static void usbnet_disconnect (struct usb_interface *intf) free_netdev(net); usb_put_dev (xdev); } +EXPORT_SYMBOL_GPL(usbnet_disconnect); /*-------------------------------------------------------------------------*/ @@ -3613,7 +3482,7 @@ static struct ethtool_ops usbnet_ethtool_ops; // precondition: never called in_interrupt -static int +int usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) { struct usbnet *dev; @@ -3719,8 +3588,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) if (status) goto out3; if (netif_msg_probe (dev)) - devinfo (dev, "register usbnet at usb-%s-%s, %s, " + devinfo (dev, "register '%s' at usb-%s-%s, %s, " "%02x:%02x:%02x:%02x:%02x:%02x", + udev->dev.driver->name, xdev->bus->bus_name, xdev->devpath, dev->driver_info->description, net->dev_addr [0], net->dev_addr [1], @@ -3744,12 +3614,15 @@ out: usb_put_dev(xdev); return status; } +EXPORT_SYMBOL_GPL(usbnet_probe); /*-------------------------------------------------------------------------*/ -#ifdef CONFIG_PM +/* FIXME these suspend/resume methods assume non-CDC style + * devices, with only one interface. + */ -static int usbnet_suspend (struct usb_interface *intf, pm_message_t message) +int usbnet_suspend (struct usb_interface *intf, pm_message_t message) { struct usbnet *dev = usb_get_intfdata(intf); @@ -3762,8 +3635,9 @@ static int usbnet_suspend (struct usb_interface *intf, pm_message_t message) intf->dev.power.power_state = PMSG_SUSPEND; return 0; } +EXPORT_SYMBOL_GPL(usbnet_suspend); -static int usbnet_resume (struct usb_interface *intf) +int usbnet_resume (struct usb_interface *intf) { struct usbnet *dev = usb_get_intfdata(intf); @@ -3772,13 +3646,8 @@ static int usbnet_resume (struct usb_interface *intf) tasklet_schedule (&dev->bh); return 0; } +EXPORT_SYMBOL_GPL(usbnet_resume); -#else /* !CONFIG_PM */ - -#define usbnet_suspend NULL -#define usbnet_resume NULL - -#endif /* CONFIG_PM */ /*-------------------------------------------------------------------------*/ @@ -3793,36 +3662,6 @@ static int usbnet_resume (struct usb_interface *intf) static const struct usb_device_id products [] = { -#ifdef CONFIG_USB_ALI_M5632 -{ - USB_DEVICE (0x0402, 0x5632), // ALi defaults - .driver_info = (unsigned long) &ali_m5632_info, -}, -#endif - -#ifdef CONFIG_USB_AN2720 -{ - USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults - .driver_info = (unsigned long) &an2720_info, -}, { - USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET - .driver_info = (unsigned long) &an2720_info, -}, -#endif - -#ifdef CONFIG_USB_BELKIN -{ - USB_DEVICE (0x050d, 0x0004), // Belkin - .driver_info = (unsigned long) &belkin_info, -}, { - USB_DEVICE (0x056c, 0x8100), // eTEK - .driver_info = (unsigned long) &belkin_info, -}, { - USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK) - .driver_info = (unsigned long) &belkin_info, -}, -#endif - #ifdef CONFIG_USB_AX8817X { // Linksys USB200M @@ -3879,13 +3718,6 @@ static const struct usb_device_id products [] = { }, #endif -#ifdef CONFIG_USB_EPSON2888 -{ - USB_DEVICE (0x0525, 0x2888), // EPSON USB client - .driver_info = (unsigned long) &epson2888_info, -}, -#endif - #ifdef CONFIG_USB_GENESYS { USB_DEVICE (0x05e3, 0x0502), // GL620USB-A @@ -3916,13 +3748,6 @@ static const struct usb_device_id products [] = { }, #endif -#ifdef CONFIG_USB_KC2190 -{ - USB_DEVICE (0x050f, 0x0190), // KC-190 - .driver_info = (unsigned long) &kc2190_info, -}, -#endif - #ifdef CONFIG_USB_RNDIS { /* RNDIS is MSFT's un-official variant of CDC ACM */ @@ -3931,41 +3756,6 @@ static const struct usb_device_id products [] = { }, #endif -#ifdef CONFIG_USB_ARMLINUX -/* - * SA-1100 using standard ARM Linux kernels, or compatible. - * Often used when talking to Linux PDAs (iPaq, Yopy, etc). - * The sa-1100 "usb-eth" driver handles the basic framing. - * - * PXA25x or PXA210 ... these use a "usb-eth" driver much like - * the sa1100 one, but hardware uses different endpoint numbers. - * - * Or the Linux "Ethernet" gadget on hardware that can't talk - * CDC Ethernet (e.g., no altsettings), in either of two modes: - * - acting just like the old "usb-eth" firmware, though - * the implementation is different - * - supporting RNDIS as the first/default configuration for - * MS-Windows interop; Linux needs to use the other config - */ -{ - // 1183 = 0x049F, both used as hex values? - // Compaq "Itsy" vendor/product id - USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible - .driver_info = (unsigned long) &linuxdev_info, -}, { - USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy" - .driver_info = (unsigned long) &yopy_info, -}, { - USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader - .driver_info = (unsigned long) &blob_info, -}, { - // Linux Ethernet/RNDIS gadget on pxa210/25x/26x - // e.g. Gumstix, current OpenZaurus, ... - USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203), - .driver_info = (unsigned long) &linuxdev_info, -}, -#endif - #if defined(CONFIG_USB_ZAURUS) || defined(CONFIG_USB_CDCETHER) /* * SA-1100 based Sharp Zaurus ("collie"), or compatible. diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h index 4402618..d903b46 100644 --- a/drivers/usb/net/usbnet.h +++ b/drivers/usb/net/usbnet.h @@ -24,7 +24,7 @@ #define __USBNET_H -/* interface from usbnet core to each USB networking device we handle */ +/* interface from usbnet core to each USB networking link we handle */ struct usbnet { /* housekeeping */ struct usb_device *udev; @@ -62,6 +62,10 @@ struct usbnet { # define EVENT_LINK_RESET 4 }; +static inline struct usb_driver *driver_of(struct usb_interface *intf) +{ + return to_usb_driver(intf->dev.driver); +} /* interface from the device/framing level "minidriver" to core */ struct driver_info { @@ -111,6 +115,15 @@ struct driver_info { unsigned long data; /* Misc driver specific data */ }; +/* Minidrivers are just drivers using the "usbnet" core as a powerful + * network-specific subroutine library ... that happens to do pretty + * much everything except custom framing and chip-specific stuff. + */ +extern int usbnet_probe(struct usb_interface *, const struct usb_device_id *); +extern int usbnet_suspend (struct usb_interface *, pm_message_t ); +extern int usbnet_resume (struct usb_interface *); +extern void usbnet_disconnect(struct usb_interface *); + /* we record the state for each of our queued skbs */ enum skb_state { -- cgit v0.10.2 From 2e55cc7210fef90f88201e860d8767594974574e Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 31 Aug 2005 09:53:10 -0700 Subject: [PATCH] USB: usbnet (3/9) module for ASIX Ethernet adapters This patch moves the ASIX AX8817x driver into its own file, just using the "usbnet" infrastructure as a utility library. - As with "cdc_subset" this involved minor Kconfig/kbuild tweaks, moving code from one file to another, and exporting a few functions. - This includes updates from Jamie Painter to add (and use) a new hook to handle the different maximum transfer sizes for rx and tx sides. - Also from Jamie, some bugfixes: * MDIO byteorder (to address some PPC media negotiation problems); * Force alignment at key spots when using ax88772 framing (on some embedded hardware, the network stack will break otherwise); * Address some link reset problems. It also makes this driver use the standard (5 seconds vs half second) control timeouts used elsewhere in USB; and wraps a few lines before the 80th column (which previously needed it). Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig index 6399b43..4fb51b9 100644 --- a/drivers/usb/net/Kconfig +++ b/drivers/usb/net/Kconfig @@ -202,23 +202,22 @@ config USB_CDCETHER IEEE 802 "local assignment" bit is set in the address, a "usbX" name is used instead. -comment "USB Network Adapters" - depends on USB_USBNET +comment "Drivers built using the usbnet core" -config USB_AX8817X - boolean "ASIX AX88xxx Based USB 2.0 Ethernet Devices" +config USB_NET_AX8817X + tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" depends on USB_USBNET && NET_ETHERNET select CRC32 select MII default y help This option adds support for ASIX AX88xxx based USB 2.0 - 10/100 Ethernet devices. + 10/100 Ethernet adapters. This driver should work with at least the following devices: * Aten UC210T * ASIX AX88172 - * Billionton Systems, USB2AR + * Billionton Systems, USB2AR * Buffalo LUA-U2-KTX * Corega FEther USB2-TX * D-Link DUB-E100 @@ -231,7 +230,7 @@ config USB_AX8817X * TrendNet TU2-ET100 This driver creates an interface named "ethX", where X depends on - what other networking devices you have in use. + what other networking devices you have in use. config USB_NET_CDC_SUBSET diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile index 23608cc..60dc91e 100644 --- a/drivers/usb/net/Makefile +++ b/drivers/usb/net/Makefile @@ -6,6 +6,7 @@ obj-$(CONFIG_USB_CATC) += catc.o obj-$(CONFIG_USB_KAWETH) += kaweth.o obj-$(CONFIG_USB_PEGASUS) += pegasus.o obj-$(CONFIG_USB_RTL8150) += rtl8150.o +obj-$(CONFIG_USB_NET_AX8817X) += asix.o obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o obj-$(CONFIG_USB_USBNET) += usbnet.o obj-$(CONFIG_USB_ZD1201) += zd1201.o diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c new file mode 100644 index 0000000..861f00a --- /dev/null +++ b/drivers/usb/net/asix.c @@ -0,0 +1,948 @@ +/* + * ASIX AX8817X based USB 2.0 Ethernet Devices + * Copyright (C) 2003-2005 David Hollis + * Copyright (C) 2005 Phil Chang + * Copyright (c) 2002-2003 TiVo Inc. + * + * 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 + */ + +// #define DEBUG // error path messages, extra info +// #define VERBOSE // more; success messages + +#include +#ifdef CONFIG_USB_DEBUG +# define DEBUG +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "usbnet.h" + + +/* ASIX AX8817X based USB 2.0 Ethernet Devices */ + +#define AX_CMD_SET_SW_MII 0x06 +#define AX_CMD_READ_MII_REG 0x07 +#define AX_CMD_WRITE_MII_REG 0x08 +#define AX_CMD_SET_HW_MII 0x0a +#define AX_CMD_READ_EEPROM 0x0b +#define AX_CMD_WRITE_EEPROM 0x0c +#define AX_CMD_WRITE_ENABLE 0x0d +#define AX_CMD_WRITE_DISABLE 0x0e +#define AX_CMD_WRITE_RX_CTL 0x10 +#define AX_CMD_READ_IPG012 0x11 +#define AX_CMD_WRITE_IPG0 0x12 +#define AX_CMD_WRITE_IPG1 0x13 +#define AX_CMD_WRITE_IPG2 0x14 +#define AX_CMD_WRITE_MULTI_FILTER 0x16 +#define AX_CMD_READ_NODE_ID 0x17 +#define AX_CMD_READ_PHY_ID 0x19 +#define AX_CMD_READ_MEDIUM_STATUS 0x1a +#define AX_CMD_WRITE_MEDIUM_MODE 0x1b +#define AX_CMD_READ_MONITOR_MODE 0x1c +#define AX_CMD_WRITE_MONITOR_MODE 0x1d +#define AX_CMD_WRITE_GPIOS 0x1f +#define AX_CMD_SW_RESET 0x20 +#define AX_CMD_SW_PHY_STATUS 0x21 +#define AX_CMD_SW_PHY_SELECT 0x22 +#define AX88772_CMD_READ_NODE_ID 0x13 + +#define AX_MONITOR_MODE 0x01 +#define AX_MONITOR_LINK 0x02 +#define AX_MONITOR_MAGIC 0x04 +#define AX_MONITOR_HSFS 0x10 + +/* AX88172 Medium Status Register values */ +#define AX_MEDIUM_FULL_DUPLEX 0x02 +#define AX_MEDIUM_TX_ABORT_ALLOW 0x04 +#define AX_MEDIUM_FLOW_CONTROL_EN 0x10 + +#define AX_MCAST_FILTER_SIZE 8 +#define AX_MAX_MCAST 64 + +#define AX_EEPROM_LEN 0x40 + +#define AX_SWRESET_CLEAR 0x00 +#define AX_SWRESET_RR 0x01 +#define AX_SWRESET_RT 0x02 +#define AX_SWRESET_PRTE 0x04 +#define AX_SWRESET_PRL 0x08 +#define AX_SWRESET_BZ 0x10 +#define AX_SWRESET_IPRL 0x20 +#define AX_SWRESET_IPPD 0x40 + +#define AX88772_IPG0_DEFAULT 0x15 +#define AX88772_IPG1_DEFAULT 0x0c +#define AX88772_IPG2_DEFAULT 0x12 + +#define AX88772_MEDIUM_FULL_DUPLEX 0x0002 +#define AX88772_MEDIUM_RESERVED 0x0004 +#define AX88772_MEDIUM_RX_FC_ENABLE 0x0010 +#define AX88772_MEDIUM_TX_FC_ENABLE 0x0020 +#define AX88772_MEDIUM_PAUSE_FORMAT 0x0080 +#define AX88772_MEDIUM_RX_ENABLE 0x0100 +#define AX88772_MEDIUM_100MB 0x0200 +#define AX88772_MEDIUM_DEFAULT \ + (AX88772_MEDIUM_FULL_DUPLEX | AX88772_MEDIUM_RX_FC_ENABLE | \ + AX88772_MEDIUM_TX_FC_ENABLE | AX88772_MEDIUM_100MB | \ + AX88772_MEDIUM_RESERVED | AX88772_MEDIUM_RX_ENABLE ) + +#define AX_EEPROM_MAGIC 0xdeadbeef + +/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ +struct ax8817x_data { + u8 multi_filter[AX_MCAST_FILTER_SIZE]; +}; + +struct ax88172_int_data { + u16 res1; + u8 link; + u16 res2; + u8 status; + u16 res3; +} __attribute__ ((packed)); + +static int ax8817x_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, + u16 size, void *data) +{ + return usb_control_msg( + dev->udev, + usb_rcvctrlpipe(dev->udev, 0), + cmd, + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + value, + index, + data, + size, + USB_CTRL_GET_TIMEOUT); +} + +static int ax8817x_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, + u16 size, void *data) +{ + return usb_control_msg( + dev->udev, + usb_sndctrlpipe(dev->udev, 0), + cmd, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + value, + index, + data, + size, + USB_CTRL_SET_TIMEOUT); +} + +static void ax8817x_async_cmd_callback(struct urb *urb, struct pt_regs *regs) +{ + struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context; + + if (urb->status < 0) + printk(KERN_DEBUG "ax8817x_async_cmd_callback() failed with %d", + urb->status); + + kfree(req); + usb_free_urb(urb); +} + +static void ax8817x_status(struct usbnet *dev, struct urb *urb) +{ + struct ax88172_int_data *event; + int link; + + if (urb->actual_length < 8) + return; + + event = urb->transfer_buffer; + link = event->link & 0x01; + if (netif_carrier_ok(dev->net) != link) { + if (link) { + netif_carrier_on(dev->net); + usbnet_defer_kevent (dev, EVENT_LINK_RESET ); + } else + netif_carrier_off(dev->net); + devdbg(dev, "ax8817x - Link Status is: %d", link); + } +} + +static void +ax8817x_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, + u16 size, void *data) +{ + struct usb_ctrlrequest *req; + int status; + struct urb *urb; + + if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) { + devdbg(dev, "Error allocating URB in write_cmd_async!"); + return; + } + + if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) { + deverr(dev, "Failed to allocate memory for control request"); + usb_free_urb(urb); + return; + } + + req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; + req->bRequest = cmd; + req->wValue = cpu_to_le16(value); + req->wIndex = cpu_to_le16(index); + req->wLength = cpu_to_le16(size); + + usb_fill_control_urb(urb, dev->udev, + usb_sndctrlpipe(dev->udev, 0), + (void *)req, data, size, + ax8817x_async_cmd_callback, req); + + if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { + deverr(dev, "Error submitting the control message: status=%d", + status); + kfree(req); + usb_free_urb(urb); + } +} + +static void ax8817x_set_multicast(struct net_device *net) +{ + struct usbnet *dev = netdev_priv(net); + struct ax8817x_data *data = (struct ax8817x_data *)&dev->data; + u8 rx_ctl = 0x8c; + + if (net->flags & IFF_PROMISC) { + rx_ctl |= 0x01; + } else if (net->flags & IFF_ALLMULTI + || net->mc_count > AX_MAX_MCAST) { + rx_ctl |= 0x02; + } else if (net->mc_count == 0) { + /* just broadcast and directed */ + } else { + /* We use the 20 byte dev->data + * for our 8 byte filter buffer + * to avoid allocating memory that + * is tricky to free later */ + struct dev_mc_list *mc_list = net->mc_list; + u32 crc_bits; + int i; + + memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); + + /* Build the multicast hash filter. */ + for (i = 0; i < net->mc_count; i++) { + crc_bits = + ether_crc(ETH_ALEN, + mc_list->dmi_addr) >> 26; + data->multi_filter[crc_bits >> 3] |= + 1 << (crc_bits & 7); + mc_list = mc_list->next; + } + + ax8817x_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0, + AX_MCAST_FILTER_SIZE, data->multi_filter); + + rx_ctl |= 0x10; + } + + ax8817x_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL); +} + +static int ax8817x_mdio_read(struct net_device *netdev, int phy_id, int loc) +{ + struct usbnet *dev = netdev_priv(netdev); + u16 res; + u8 buf[1]; + + ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, &buf); + ax8817x_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, + (__u16)loc, 2, (u16 *)&res); + ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf); + + return res & 0xffff; +} + +/* same as above, but converts resulting value to cpu byte order */ +static int ax8817x_mdio_read_le(struct net_device *netdev, int phy_id, int loc) +{ + return le16_to_cpu(ax8817x_mdio_read(netdev,phy_id, loc)); +} + +static void +ax8817x_mdio_write(struct net_device *netdev, int phy_id, int loc, int val) +{ + struct usbnet *dev = netdev_priv(netdev); + u16 res = val; + u8 buf[1]; + + ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, &buf); + ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, + (__u16)loc, 2, (u16 *)&res); + ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf); +} + +/* same as above, but converts new value to le16 byte order before writing */ +static void +ax8817x_mdio_write_le(struct net_device *netdev, int phy_id, int loc, int val) +{ + ax8817x_mdio_write( netdev, phy_id, loc, cpu_to_le16(val) ); +} + +static int ax88172_link_reset(struct usbnet *dev) +{ + u16 lpa; + u16 adv; + u16 res; + u8 mode; + + mode = AX_MEDIUM_TX_ABORT_ALLOW | AX_MEDIUM_FLOW_CONTROL_EN; + lpa = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_LPA); + adv = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_ADVERTISE); + res = mii_nway_result(lpa|adv); + if (res & LPA_DUPLEX) + mode |= AX_MEDIUM_FULL_DUPLEX; + ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL); + + return 0; +} + +static void +ax8817x_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) +{ + struct usbnet *dev = netdev_priv(net); + u8 opt; + + if (ax8817x_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) { + wolinfo->supported = 0; + wolinfo->wolopts = 0; + return; + } + wolinfo->supported = WAKE_PHY | WAKE_MAGIC; + wolinfo->wolopts = 0; + if (opt & AX_MONITOR_MODE) { + if (opt & AX_MONITOR_LINK) + wolinfo->wolopts |= WAKE_PHY; + if (opt & AX_MONITOR_MAGIC) + wolinfo->wolopts |= WAKE_MAGIC; + } +} + +static int +ax8817x_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) +{ + struct usbnet *dev = netdev_priv(net); + u8 opt = 0; + u8 buf[1]; + + if (wolinfo->wolopts & WAKE_PHY) + opt |= AX_MONITOR_LINK; + if (wolinfo->wolopts & WAKE_MAGIC) + opt |= AX_MONITOR_MAGIC; + if (opt != 0) + opt |= AX_MONITOR_MODE; + + if (ax8817x_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE, + opt, 0, 0, &buf) < 0) + return -EINVAL; + + return 0; +} + +static int ax8817x_get_eeprom_len(struct net_device *net) +{ + return AX_EEPROM_LEN; +} + +static int ax8817x_get_eeprom(struct net_device *net, + struct ethtool_eeprom *eeprom, u8 *data) +{ + struct usbnet *dev = netdev_priv(net); + u16 *ebuf = (u16 *)data; + int i; + + /* Crude hack to ensure that we don't overwrite memory + * if an odd length is supplied + */ + if (eeprom->len % 2) + return -EINVAL; + + eeprom->magic = AX_EEPROM_MAGIC; + + /* ax8817x returns 2 bytes from eeprom on read */ + for (i=0; i < eeprom->len / 2; i++) { + if (ax8817x_read_cmd(dev, AX_CMD_READ_EEPROM, + eeprom->offset + i, 0, 2, &ebuf[i]) < 0) + return -EINVAL; + } + return 0; +} + +static void ax8817x_get_drvinfo (struct net_device *net, + struct ethtool_drvinfo *info) +{ + /* Inherit standard device info */ + usbnet_get_drvinfo(net, info); + info->eedump_len = 0x3e; +} + +static int ax8817x_get_settings(struct net_device *net, struct ethtool_cmd *cmd) +{ + struct usbnet *dev = netdev_priv(net); + + return mii_ethtool_gset(&dev->mii,cmd); +} + +static int ax8817x_set_settings(struct net_device *net, struct ethtool_cmd *cmd) +{ + struct usbnet *dev = netdev_priv(net); + + return mii_ethtool_sset(&dev->mii,cmd); +} + +/* We need to override some ethtool_ops so we require our + own structure so we don't interfere with other usbnet + devices that may be connected at the same time. */ +static struct ethtool_ops ax8817x_ethtool_ops = { + .get_drvinfo = ax8817x_get_drvinfo, + .get_link = ethtool_op_get_link, + .get_msglevel = usbnet_get_msglevel, + .set_msglevel = usbnet_set_msglevel, + .get_wol = ax8817x_get_wol, + .set_wol = ax8817x_set_wol, + .get_eeprom_len = ax8817x_get_eeprom_len, + .get_eeprom = ax8817x_get_eeprom, + .get_settings = ax8817x_get_settings, + .set_settings = ax8817x_set_settings, +}; + +static int ax8817x_ioctl (struct net_device *net, struct ifreq *rq, int cmd) +{ + struct usbnet *dev = netdev_priv(net); + + return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); +} + +static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf) +{ + int ret = 0; + void *buf; + int i; + unsigned long gpio_bits = dev->driver_info->data; + + usbnet_get_endpoints(dev,intf); + + buf = kmalloc(ETH_ALEN, GFP_KERNEL); + if(!buf) { + ret = -ENOMEM; + goto out1; + } + + /* Toggle the GPIOs in a manufacturer/model specific way */ + for (i = 2; i >= 0; i--) { + if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS, + (gpio_bits >> (i * 8)) & 0xff, 0, 0, + buf)) < 0) + goto out2; + msleep(5); + } + + if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, + 0x80, 0, 0, buf)) < 0) { + dbg("send AX_CMD_WRITE_RX_CTL failed: %d", ret); + goto out2; + } + + /* Get the MAC address */ + memset(buf, 0, ETH_ALEN); + if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_NODE_ID, + 0, 0, 6, buf)) < 0) { + dbg("read AX_CMD_READ_NODE_ID failed: %d", ret); + goto out2; + } + memcpy(dev->net->dev_addr, buf, ETH_ALEN); + + /* Get the PHY id */ + if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, + 0, 0, 2, buf)) < 0) { + dbg("error on read AX_CMD_READ_PHY_ID: %02x", ret); + goto out2; + } else if (ret < 2) { + /* this should always return 2 bytes */ + dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x", + ret); + ret = -EIO; + goto out2; + } + + /* Initialize MII structure */ + dev->mii.dev = dev->net; + dev->mii.mdio_read = ax8817x_mdio_read; + dev->mii.mdio_write = ax8817x_mdio_write; + dev->mii.phy_id_mask = 0x3f; + dev->mii.reg_num_mask = 0x1f; + dev->mii.phy_id = *((u8 *)buf + 1); + dev->net->do_ioctl = ax8817x_ioctl; + + dev->net->set_multicast_list = ax8817x_set_multicast; + dev->net->ethtool_ops = &ax8817x_ethtool_ops; + + ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); + ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, MII_ADVERTISE, + ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); + mii_nway_restart(&dev->mii); + + return 0; +out2: + kfree(buf); +out1: + return ret; +} + +static struct ethtool_ops ax88772_ethtool_ops = { + .get_drvinfo = ax8817x_get_drvinfo, + .get_link = ethtool_op_get_link, + .get_msglevel = usbnet_get_msglevel, + .set_msglevel = usbnet_set_msglevel, + .get_wol = ax8817x_get_wol, + .set_wol = ax8817x_set_wol, + .get_eeprom_len = ax8817x_get_eeprom_len, + .get_eeprom = ax8817x_get_eeprom, + .get_settings = ax8817x_get_settings, + .set_settings = ax8817x_set_settings, +}; + +static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) +{ + int ret; + void *buf; + + usbnet_get_endpoints(dev,intf); + + buf = kmalloc(6, GFP_KERNEL); + if(!buf) { + dbg ("Cannot allocate memory for buffer"); + ret = -ENOMEM; + goto out1; + } + + if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS, + 0x00B0, 0, 0, buf)) < 0) + goto out2; + + msleep(5); + if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT, + 0x0001, 0, 0, buf)) < 0) { + dbg("Select PHY #1 failed: %d", ret); + goto out2; + } + + if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPPD, + 0, 0, buf)) < 0) { + dbg("Failed to power down internal PHY: %d", ret); + goto out2; + } + + msleep(150); + if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_CLEAR, + 0, 0, buf)) < 0) { + dbg("Failed to perform software reset: %d", ret); + goto out2; + } + + msleep(150); + if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, + AX_SWRESET_IPRL | AX_SWRESET_PRL, + 0, 0, buf)) < 0) { + dbg("Failed to set Internal/External PHY reset control: %d", + ret); + goto out2; + } + + msleep(150); + if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, + 0x0000, 0, 0, buf)) < 0) { + dbg("Failed to reset RX_CTL: %d", ret); + goto out2; + } + + /* Get the MAC address */ + memset(buf, 0, ETH_ALEN); + if ((ret = ax8817x_read_cmd(dev, AX88772_CMD_READ_NODE_ID, + 0, 0, ETH_ALEN, buf)) < 0) { + dbg("Failed to read MAC address: %d", ret); + goto out2; + } + memcpy(dev->net->dev_addr, buf, ETH_ALEN); + + if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, + 0, 0, 0, buf)) < 0) { + dbg("Enabling software MII failed: %d", ret); + goto out2; + } + + if (((ret = ax8817x_read_cmd(dev, AX_CMD_READ_MII_REG, + 0x0010, 2, 2, buf)) < 0) + || (*((u16 *)buf) != 0x003b)) { + dbg("Read PHY register 2 must be 0x3b00: %d", ret); + goto out2; + } + + /* Initialize MII structure */ + dev->mii.dev = dev->net; + dev->mii.mdio_read = ax8817x_mdio_read; + dev->mii.mdio_write = ax8817x_mdio_write; + dev->mii.phy_id_mask = 0xff; + dev->mii.reg_num_mask = 0xff; + dev->net->do_ioctl = ax8817x_ioctl; + + /* Get the PHY id */ + if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, + 0, 0, 2, buf)) < 0) { + dbg("Error reading PHY ID: %02x", ret); + goto out2; + } else if (ret < 2) { + /* this should always return 2 bytes */ + dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x", + ret); + ret = -EIO; + goto out2; + } + dev->mii.phy_id = *((u8 *)buf + 1); + + if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_PRL, + 0, 0, buf)) < 0) { + dbg("Set external PHY reset pin level: %d", ret); + goto out2; + } + msleep(150); + if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, + AX_SWRESET_IPRL | AX_SWRESET_PRL, + 0, 0, buf)) < 0) { + dbg("Set Internal/External PHY reset control: %d", ret); + goto out2; + } + msleep(150); + + + dev->net->set_multicast_list = ax8817x_set_multicast; + dev->net->ethtool_ops = &ax88772_ethtool_ops; + + ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); + ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, MII_ADVERTISE, + ADVERTISE_ALL | ADVERTISE_CSMA); + mii_nway_restart(&dev->mii); + + if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, + AX88772_MEDIUM_DEFAULT, 0, 0, buf)) < 0) { + dbg("Write medium mode register: %d", ret); + goto out2; + } + + if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0, + AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, + AX88772_IPG2_DEFAULT, 0, buf)) < 0) { + dbg("Write IPG,IPG1,IPG2 failed: %d", ret); + goto out2; + } + if ((ret = + ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf)) < 0) { + dbg("Failed to set hardware MII: %02x", ret); + goto out2; + } + + /* Set RX_CTL to default values with 2k buffer, and enable cactus */ + if ((ret = + ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0088, 0, 0, + buf)) < 0) { + dbg("Reset RX_CTL failed: %d", ret); + goto out2; + } + + kfree(buf); + + /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ + if (dev->driver_info->flags & FLAG_FRAMING_AX) { + /* hard_mtu is still the default - the device does not support + jumbo eth frames */ + dev->rx_urb_size = 2048; + } + + return 0; + +out2: + kfree(buf); +out1: + return ret; +} + +static int ax88772_rx_fixup(struct usbnet *dev, struct sk_buff *skb) +{ + u8 *head; + u32 header; + char *packet; + struct sk_buff *ax_skb; + u16 size; + + head = (u8 *) skb->data; + memcpy(&header, head, sizeof(header)); + le32_to_cpus(&header); + packet = head + sizeof(header); + + skb_pull(skb, 4); + + while (skb->len > 0) { + if ((short)(header & 0x0000ffff) != + ~((short)((header & 0xffff0000) >> 16))) { + devdbg(dev,"header length data is error"); + } + /* get the packet length */ + size = (u16) (header & 0x0000ffff); + + if ((skb->len) - ((size + 1) & 0xfffe) == 0) + return 2; + if (size > ETH_FRAME_LEN) { + devdbg(dev,"invalid rx length %d", size); + return 0; + } + ax_skb = skb_clone(skb, GFP_ATOMIC); + if (ax_skb) { + ax_skb->len = size; + ax_skb->data = packet; + ax_skb->tail = packet + size; + usbnet_skb_return(dev, ax_skb); + } else { + return 0; + } + + skb_pull(skb, (size + 1) & 0xfffe); + + if (skb->len == 0) + break; + + head = (u8 *) skb->data; + memcpy(&header, head, sizeof(header)); + le32_to_cpus(&header); + packet = head + sizeof(header); + skb_pull(skb, 4); + } + + if (skb->len < 0) { + devdbg(dev,"invalid rx length %d", skb->len); + return 0; + } + return 1; +} + +static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb, + unsigned flags) +{ + int padlen; + int headroom = skb_headroom(skb); + int tailroom = skb_tailroom(skb); + u32 packet_len; + u32 padbytes = 0xffff0000; + + padlen = ((skb->len + 4) % 512) ? 0 : 4; + + if ((!skb_cloned(skb)) + && ((headroom + tailroom) >= (4 + padlen))) { + if ((headroom < 4) || (tailroom < padlen)) { + skb->data = memmove(skb->head + 4, skb->data, skb->len); + skb->tail = skb->data + skb->len; + } + } else { + struct sk_buff *skb2; + skb2 = skb_copy_expand(skb, 4, padlen, flags); + dev_kfree_skb_any(skb); + skb = skb2; + if (!skb) + return NULL; + } + + skb_push(skb, 4); + packet_len = (((skb->len - 4) ^ 0x0000ffff) << 16) + (skb->len - 4); + memcpy(skb->data, &packet_len, sizeof(packet_len)); + + if ((skb->len % 512) == 0) { + memcpy( skb->tail, &padbytes, sizeof(padbytes)); + skb_put(skb, sizeof(padbytes)); + } + return skb; +} + +static int ax88772_link_reset(struct usbnet *dev) +{ + u16 lpa; + u16 adv; + u16 res; + u16 mode; + + mode = AX88772_MEDIUM_DEFAULT; + lpa = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_LPA); + adv = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_ADVERTISE); + res = mii_nway_result(lpa|adv); + + if ((res & LPA_DUPLEX) == 0) + mode &= ~AX88772_MEDIUM_FULL_DUPLEX; + if ((res & LPA_100) == 0) + mode &= ~AX88772_MEDIUM_100MB; + ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL); + + return 0; +} + +static const struct driver_info ax8817x_info = { + .description = "ASIX AX8817x USB 2.0 Ethernet", + .bind = ax8817x_bind, + .status = ax8817x_status, + .link_reset = ax88172_link_reset, + .reset = ax88172_link_reset, + .flags = FLAG_ETHER, + .data = 0x00130103, +}; + +static const struct driver_info dlink_dub_e100_info = { + .description = "DLink DUB-E100 USB Ethernet", + .bind = ax8817x_bind, + .status = ax8817x_status, + .link_reset = ax88172_link_reset, + .reset = ax88172_link_reset, + .flags = FLAG_ETHER, + .data = 0x009f9d9f, +}; + +static const struct driver_info netgear_fa120_info = { + .description = "Netgear FA-120 USB Ethernet", + .bind = ax8817x_bind, + .status = ax8817x_status, + .link_reset = ax88172_link_reset, + .reset = ax88172_link_reset, + .flags = FLAG_ETHER, + .data = 0x00130103, +}; + +static const struct driver_info hawking_uf200_info = { + .description = "Hawking UF200 USB Ethernet", + .bind = ax8817x_bind, + .status = ax8817x_status, + .link_reset = ax88172_link_reset, + .reset = ax88172_link_reset, + .flags = FLAG_ETHER, + .data = 0x001f1d1f, +}; + +static const struct driver_info ax88772_info = { + .description = "ASIX AX88772 USB 2.0 Ethernet", + .bind = ax88772_bind, + .status = ax8817x_status, + .link_reset = ax88772_link_reset, + .reset = ax88772_link_reset, + .flags = FLAG_ETHER | FLAG_FRAMING_AX, + .rx_fixup = ax88772_rx_fixup, + .tx_fixup = ax88772_tx_fixup, + .data = 0x00130103, +}; + +static const struct usb_device_id products [] = { +{ + // Linksys USB200M + USB_DEVICE (0x077b, 0x2226), + .driver_info = (unsigned long) &ax8817x_info, +}, { + // Netgear FA120 + USB_DEVICE (0x0846, 0x1040), + .driver_info = (unsigned long) &netgear_fa120_info, +}, { + // DLink DUB-E100 + USB_DEVICE (0x2001, 0x1a00), + .driver_info = (unsigned long) &dlink_dub_e100_info, +}, { + // Intellinet, ST Lab USB Ethernet + USB_DEVICE (0x0b95, 0x1720), + .driver_info = (unsigned long) &ax8817x_info, +}, { + // Hawking UF200, TrendNet TU2-ET100 + USB_DEVICE (0x07b8, 0x420a), + .driver_info = (unsigned long) &hawking_uf200_info, +}, { + // Billionton Systems, USB2AR + USB_DEVICE (0x08dd, 0x90ff), + .driver_info = (unsigned long) &ax8817x_info, +}, { + // ATEN UC210T + USB_DEVICE (0x0557, 0x2009), + .driver_info = (unsigned long) &ax8817x_info, +}, { + // Buffalo LUA-U2-KTX + USB_DEVICE (0x0411, 0x003d), + .driver_info = (unsigned long) &ax8817x_info, +}, { + // Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter" + USB_DEVICE (0x6189, 0x182d), + .driver_info = (unsigned long) &ax8817x_info, +}, { + // corega FEther USB2-TX + USB_DEVICE (0x07aa, 0x0017), + .driver_info = (unsigned long) &ax8817x_info, +}, { + // Surecom EP-1427X-2 + USB_DEVICE (0x1189, 0x0893), + .driver_info = (unsigned long) &ax8817x_info, +}, { + // goodway corp usb gwusb2e + USB_DEVICE (0x1631, 0x6200), + .driver_info = (unsigned long) &ax8817x_info, +}, { + // ASIX AX88772 10/100 + USB_DEVICE (0x0b95, 0x7720), + .driver_info = (unsigned long) &ax88772_info, +}, + { }, // END +}; +MODULE_DEVICE_TABLE(usb, products); + +static struct usb_driver asix_driver = { + .owner = THIS_MODULE, + .name = "asix", + .id_table = products, + .probe = usbnet_probe, + .suspend = usbnet_suspend, + .resume = usbnet_resume, + .disconnect = usbnet_disconnect, +}; + +static int __init asix_init(void) +{ + return usb_register(&asix_driver); +} +module_init(asix_init); + +static void __exit asix_exit(void) +{ + usb_deregister(&asix_driver); +} +module_exit(asix_exit); + +MODULE_AUTHOR("David Hollis"); +MODULE_DESCRIPTION("ASIX AX8817X based USB 2.0 Ethernet Devices"); +MODULE_LICENSE("GPL"); + diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 57b41fb..99a4881 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -3,8 +3,6 @@ * Copyright (C) 2000-2005 by David Brownell * Copyright (C) 2002 Pavel Machek * Copyright (C) 2003-2005 David Hollis - * Copyright (C) 2005 Phil Chang - * Copyright (c) 2002-2003 TiVo Inc. * * 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 @@ -156,9 +154,6 @@ #define RX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? 60 : 4) #define TX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? 60 : 4) -/* packets are always ethernet, sometimes wrapped in other framing */ -#define MIN_PACKET sizeof(struct ethhdr) - // reawaken network queue this soon after stopping; else watchdog barks #define TX_TIMEOUT_JIFFIES (5*HZ) @@ -186,11 +181,7 @@ MODULE_PARM_DESC (msg_level, "Override default message level"); /*-------------------------------------------------------------------------*/ -static void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *); static u32 usbnet_get_link (struct net_device *); -static u32 usbnet_get_msglevel (struct net_device *); -static void usbnet_set_msglevel (struct net_device *, u32); -static void defer_kevent (struct usbnet *, int); /* mostly for PDA style devices, which are always connected if present */ static int always_connected (struct usbnet *dev) @@ -199,8 +190,7 @@ static int always_connected (struct usbnet *dev) } /* handles CDC Ethernet and many other network "bulk data" interfaces */ -static int -get_endpoints (struct usbnet *dev, struct usb_interface *intf) +int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf) { int tmp; struct usb_host_interface *alt = NULL; @@ -264,6 +254,7 @@ get_endpoints (struct usbnet *dev, struct usb_interface *intf) dev->status = status; return 0; } +EXPORT_SYMBOL_GPL(usbnet_get_endpoints); static void intr_complete (struct urb *urb, struct pt_regs *regs); @@ -303,7 +294,11 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf) return 0; } -static void skb_return (struct usbnet *dev, struct sk_buff *skb) +/* Passes this packet up the stack, updating its accounting. + * Some link protocols batch packets, so their rx_fixup paths + * can return clones as well as just modify the original skb. + */ +void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) { int status; @@ -320,784 +315,7 @@ static void skb_return (struct usbnet *dev, struct sk_buff *skb) if (status != NET_RX_SUCCESS && netif_msg_rx_err (dev)) devdbg (dev, "netif_rx status %d", status); } - - -#ifdef CONFIG_USB_AX8817X -/* ASIX AX8817X based USB 2.0 Ethernet Devices */ - -#define HAVE_HARDWARE -#define NEED_MII - -#include - -#define AX_CMD_SET_SW_MII 0x06 -#define AX_CMD_READ_MII_REG 0x07 -#define AX_CMD_WRITE_MII_REG 0x08 -#define AX_CMD_SET_HW_MII 0x0a -#define AX_CMD_READ_EEPROM 0x0b -#define AX_CMD_WRITE_EEPROM 0x0c -#define AX_CMD_WRITE_ENABLE 0x0d -#define AX_CMD_WRITE_DISABLE 0x0e -#define AX_CMD_WRITE_RX_CTL 0x10 -#define AX_CMD_READ_IPG012 0x11 -#define AX_CMD_WRITE_IPG0 0x12 -#define AX_CMD_WRITE_IPG1 0x13 -#define AX_CMD_WRITE_IPG2 0x14 -#define AX_CMD_WRITE_MULTI_FILTER 0x16 -#define AX_CMD_READ_NODE_ID 0x17 -#define AX_CMD_READ_PHY_ID 0x19 -#define AX_CMD_READ_MEDIUM_STATUS 0x1a -#define AX_CMD_WRITE_MEDIUM_MODE 0x1b -#define AX_CMD_READ_MONITOR_MODE 0x1c -#define AX_CMD_WRITE_MONITOR_MODE 0x1d -#define AX_CMD_WRITE_GPIOS 0x1f -#define AX_CMD_SW_RESET 0x20 -#define AX_CMD_SW_PHY_STATUS 0x21 -#define AX_CMD_SW_PHY_SELECT 0x22 -#define AX88772_CMD_READ_NODE_ID 0x13 - -#define AX_MONITOR_MODE 0x01 -#define AX_MONITOR_LINK 0x02 -#define AX_MONITOR_MAGIC 0x04 -#define AX_MONITOR_HSFS 0x10 - -/* AX88172 Medium Status Register values */ -#define AX_MEDIUM_FULL_DUPLEX 0x02 -#define AX_MEDIUM_TX_ABORT_ALLOW 0x04 -#define AX_MEDIUM_FLOW_CONTROL_EN 0x10 - -#define AX_MCAST_FILTER_SIZE 8 -#define AX_MAX_MCAST 64 - -#define AX_EEPROM_LEN 0x40 - -#define AX_SWRESET_CLEAR 0x00 -#define AX_SWRESET_RR 0x01 -#define AX_SWRESET_RT 0x02 -#define AX_SWRESET_PRTE 0x04 -#define AX_SWRESET_PRL 0x08 -#define AX_SWRESET_BZ 0x10 -#define AX_SWRESET_IPRL 0x20 -#define AX_SWRESET_IPPD 0x40 - -#define AX88772_IPG0_DEFAULT 0x15 -#define AX88772_IPG1_DEFAULT 0x0c -#define AX88772_IPG2_DEFAULT 0x12 - -#define AX88772_MEDIUM_FULL_DUPLEX 0x0002 -#define AX88772_MEDIUM_RESERVED 0x0004 -#define AX88772_MEDIUM_RX_FC_ENABLE 0x0010 -#define AX88772_MEDIUM_TX_FC_ENABLE 0x0020 -#define AX88772_MEDIUM_PAUSE_FORMAT 0x0080 -#define AX88772_MEDIUM_RX_ENABLE 0x0100 -#define AX88772_MEDIUM_100MB 0x0200 -#define AX88772_MEDIUM_DEFAULT \ - (AX88772_MEDIUM_FULL_DUPLEX | AX88772_MEDIUM_RX_FC_ENABLE | \ - AX88772_MEDIUM_TX_FC_ENABLE | AX88772_MEDIUM_100MB | \ - AX88772_MEDIUM_RESERVED | AX88772_MEDIUM_RX_ENABLE ) - -#define AX_EEPROM_MAGIC 0xdeadbeef - -/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ -struct ax8817x_data { - u8 multi_filter[AX_MCAST_FILTER_SIZE]; -}; - -struct ax88172_int_data { - u16 res1; - u8 link; - u16 res2; - u8 status; - u16 res3; -} __attribute__ ((packed)); - -static int ax8817x_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, - u16 size, void *data) -{ - return usb_control_msg( - dev->udev, - usb_rcvctrlpipe(dev->udev, 0), - cmd, - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - value, - index, - data, - size, - CONTROL_TIMEOUT_MS); -} - -static int ax8817x_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, - u16 size, void *data) -{ - return usb_control_msg( - dev->udev, - usb_sndctrlpipe(dev->udev, 0), - cmd, - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - value, - index, - data, - size, - CONTROL_TIMEOUT_MS); -} - -static void ax8817x_async_cmd_callback(struct urb *urb, struct pt_regs *regs) -{ - struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context; - - if (urb->status < 0) - printk(KERN_DEBUG "ax8817x_async_cmd_callback() failed with %d", - urb->status); - - kfree(req); - usb_free_urb(urb); -} - -static void ax8817x_status(struct usbnet *dev, struct urb *urb) -{ - struct ax88172_int_data *event; - int link; - - if (urb->actual_length < 8) - return; - - event = urb->transfer_buffer; - link = event->link & 0x01; - if (netif_carrier_ok(dev->net) != link) { - if (link) { - netif_carrier_on(dev->net); - defer_kevent (dev, EVENT_LINK_RESET ); - } else - netif_carrier_off(dev->net); - devdbg(dev, "ax8817x - Link Status is: %d", link); - } -} - -static void ax8817x_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, - u16 size, void *data) -{ - struct usb_ctrlrequest *req; - int status; - struct urb *urb; - - if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) { - devdbg(dev, "Error allocating URB in write_cmd_async!"); - return; - } - - if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) { - deverr(dev, "Failed to allocate memory for control request"); - usb_free_urb(urb); - return; - } - - req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; - req->bRequest = cmd; - req->wValue = cpu_to_le16(value); - req->wIndex = cpu_to_le16(index); - req->wLength = cpu_to_le16(size); - - usb_fill_control_urb(urb, dev->udev, - usb_sndctrlpipe(dev->udev, 0), - (void *)req, data, size, - ax8817x_async_cmd_callback, req); - - if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { - deverr(dev, "Error submitting the control message: status=%d", status); - kfree(req); - usb_free_urb(urb); - } -} - -static void ax8817x_set_multicast(struct net_device *net) -{ - struct usbnet *dev = netdev_priv(net); - struct ax8817x_data *data = (struct ax8817x_data *)&dev->data; - u8 rx_ctl = 0x8c; - - if (net->flags & IFF_PROMISC) { - rx_ctl |= 0x01; - } else if (net->flags & IFF_ALLMULTI - || net->mc_count > AX_MAX_MCAST) { - rx_ctl |= 0x02; - } else if (net->mc_count == 0) { - /* just broadcast and directed */ - } else { - /* We use the 20 byte dev->data - * for our 8 byte filter buffer - * to avoid allocating memory that - * is tricky to free later */ - struct dev_mc_list *mc_list = net->mc_list; - u32 crc_bits; - int i; - - memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); - - /* Build the multicast hash filter. */ - for (i = 0; i < net->mc_count; i++) { - crc_bits = - ether_crc(ETH_ALEN, - mc_list->dmi_addr) >> 26; - data->multi_filter[crc_bits >> 3] |= - 1 << (crc_bits & 7); - mc_list = mc_list->next; - } - - ax8817x_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0, - AX_MCAST_FILTER_SIZE, data->multi_filter); - - rx_ctl |= 0x10; - } - - ax8817x_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL); -} - -static int ax8817x_mdio_read(struct net_device *netdev, int phy_id, int loc) -{ - struct usbnet *dev = netdev_priv(netdev); - u16 res; - u8 buf[1]; - - ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, &buf); - ax8817x_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, (u16 *)&res); - ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf); - - return res & 0xffff; -} - -static void ax8817x_mdio_write(struct net_device *netdev, int phy_id, int loc, int val) -{ - struct usbnet *dev = netdev_priv(netdev); - u16 res = val; - u8 buf[1]; - - ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, &buf); - ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, (u16 *)&res); - ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf); -} - -static int ax88172_link_reset(struct usbnet *dev) -{ - u16 lpa; - u8 mode; - - mode = AX_MEDIUM_TX_ABORT_ALLOW | AX_MEDIUM_FLOW_CONTROL_EN; - lpa = ax8817x_mdio_read(dev->net, dev->mii.phy_id, MII_LPA); - if (lpa & LPA_DUPLEX) - mode |= AX_MEDIUM_FULL_DUPLEX; - ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL); - - return 0; -} - -static void ax8817x_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) -{ - struct usbnet *dev = netdev_priv(net); - u8 opt; - - if (ax8817x_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) { - wolinfo->supported = 0; - wolinfo->wolopts = 0; - return; - } - wolinfo->supported = WAKE_PHY | WAKE_MAGIC; - wolinfo->wolopts = 0; - if (opt & AX_MONITOR_MODE) { - if (opt & AX_MONITOR_LINK) - wolinfo->wolopts |= WAKE_PHY; - if (opt & AX_MONITOR_MAGIC) - wolinfo->wolopts |= WAKE_MAGIC; - } -} - -static int ax8817x_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) -{ - struct usbnet *dev = netdev_priv(net); - u8 opt = 0; - u8 buf[1]; - - if (wolinfo->wolopts & WAKE_PHY) - opt |= AX_MONITOR_LINK; - if (wolinfo->wolopts & WAKE_MAGIC) - opt |= AX_MONITOR_MAGIC; - if (opt != 0) - opt |= AX_MONITOR_MODE; - - if (ax8817x_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE, - opt, 0, 0, &buf) < 0) - return -EINVAL; - - return 0; -} - -static int ax8817x_get_eeprom_len(struct net_device *net) -{ - return AX_EEPROM_LEN; -} - -static int ax8817x_get_eeprom(struct net_device *net, - struct ethtool_eeprom *eeprom, u8 *data) -{ - struct usbnet *dev = netdev_priv(net); - u16 *ebuf = (u16 *)data; - int i; - - /* Crude hack to ensure that we don't overwrite memory - * if an odd length is supplied - */ - if (eeprom->len % 2) - return -EINVAL; - - eeprom->magic = AX_EEPROM_MAGIC; - - /* ax8817x returns 2 bytes from eeprom on read */ - for (i=0; i < eeprom->len / 2; i++) { - if (ax8817x_read_cmd(dev, AX_CMD_READ_EEPROM, - eeprom->offset + i, 0, 2, &ebuf[i]) < 0) - return -EINVAL; - } - return 0; -} - -static void ax8817x_get_drvinfo (struct net_device *net, - struct ethtool_drvinfo *info) -{ - /* Inherit standard device info */ - usbnet_get_drvinfo(net, info); - info->eedump_len = 0x3e; -} - -static int ax8817x_get_settings(struct net_device *net, struct ethtool_cmd *cmd) -{ - struct usbnet *dev = netdev_priv(net); - - return mii_ethtool_gset(&dev->mii,cmd); -} - -static int ax8817x_set_settings(struct net_device *net, struct ethtool_cmd *cmd) -{ - struct usbnet *dev = netdev_priv(net); - - return mii_ethtool_sset(&dev->mii,cmd); -} - -/* We need to override some ethtool_ops so we require our - own structure so we don't interfere with other usbnet - devices that may be connected at the same time. */ -static struct ethtool_ops ax8817x_ethtool_ops = { - .get_drvinfo = ax8817x_get_drvinfo, - .get_link = ethtool_op_get_link, - .get_msglevel = usbnet_get_msglevel, - .set_msglevel = usbnet_set_msglevel, - .get_wol = ax8817x_get_wol, - .set_wol = ax8817x_set_wol, - .get_eeprom_len = ax8817x_get_eeprom_len, - .get_eeprom = ax8817x_get_eeprom, - .get_settings = ax8817x_get_settings, - .set_settings = ax8817x_set_settings, -}; - -static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf) -{ - int ret = 0; - void *buf; - int i; - unsigned long gpio_bits = dev->driver_info->data; - - get_endpoints(dev,intf); - - buf = kmalloc(ETH_ALEN, GFP_KERNEL); - if(!buf) { - ret = -ENOMEM; - goto out1; - } - - /* Toggle the GPIOs in a manufacturer/model specific way */ - for (i = 2; i >= 0; i--) { - if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS, - (gpio_bits >> (i * 8)) & 0xff, 0, 0, - buf)) < 0) - goto out2; - msleep(5); - } - - if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x80, 0, 0, buf)) < 0) { - dbg("send AX_CMD_WRITE_RX_CTL failed: %d", ret); - goto out2; - } - - /* Get the MAC address */ - memset(buf, 0, ETH_ALEN); - if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, 6, buf)) < 0) { - dbg("read AX_CMD_READ_NODE_ID failed: %d", ret); - goto out2; - } - memcpy(dev->net->dev_addr, buf, ETH_ALEN); - - /* Get the PHY id */ - if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf)) < 0) { - dbg("error on read AX_CMD_READ_PHY_ID: %02x", ret); - goto out2; - } else if (ret < 2) { - /* this should always return 2 bytes */ - dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x", ret); - ret = -EIO; - goto out2; - } - - /* Initialize MII structure */ - dev->mii.dev = dev->net; - dev->mii.mdio_read = ax8817x_mdio_read; - dev->mii.mdio_write = ax8817x_mdio_write; - dev->mii.phy_id_mask = 0x3f; - dev->mii.reg_num_mask = 0x1f; - dev->mii.phy_id = *((u8 *)buf + 1); - - dev->net->set_multicast_list = ax8817x_set_multicast; - dev->net->ethtool_ops = &ax8817x_ethtool_ops; - - ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); - ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, - ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); - mii_nway_restart(&dev->mii); - - if (dev->driver_info->flags & FLAG_FRAMING_AX) { - /* REVISIT: adjust hard_header_len too */ - dev->hard_mtu = 2048; - } - - return 0; -out2: - kfree(buf); -out1: - return ret; -} - -static struct ethtool_ops ax88772_ethtool_ops = { - .get_drvinfo = ax8817x_get_drvinfo, - .get_link = ethtool_op_get_link, - .get_msglevel = usbnet_get_msglevel, - .set_msglevel = usbnet_set_msglevel, - .get_wol = ax8817x_get_wol, - .set_wol = ax8817x_set_wol, - .get_eeprom_len = ax8817x_get_eeprom_len, - .get_eeprom = ax8817x_get_eeprom, - .get_settings = ax8817x_get_settings, - .set_settings = ax8817x_set_settings, -}; - -static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) -{ - int ret; - void *buf; - - get_endpoints(dev,intf); - - buf = kmalloc(6, GFP_KERNEL); - if(!buf) { - dbg ("Cannot allocate memory for buffer"); - ret = -ENOMEM; - goto out1; - } - - if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS, - 0x00B0, 0, 0, buf)) < 0) - goto out2; - - msleep(5); - if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0x0001, 0, 0, buf)) < 0) { - dbg("Select PHY #1 failed: %d", ret); - goto out2; - } - - if ((ret = - ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPPD, 0, 0, buf)) < 0) { - dbg("Failed to power down internal PHY: %d", ret); - goto out2; - } - - msleep(150); - if ((ret = - ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_CLEAR, 0, 0, buf)) < 0) { - dbg("Failed to perform software reset: %d", ret); - goto out2; - } - - msleep(150); - if ((ret = - ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL | AX_SWRESET_PRL, 0, 0, buf)) < 0) { - dbg("Failed to set Internal/External PHY reset control: %d", ret); - goto out2; - } - - msleep(150); - if ((ret = - ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0000, 0, 0, - buf)) < 0) { - dbg("Failed to reset RX_CTL: %d", ret); - goto out2; - } - - /* Get the MAC address */ - memset(buf, 0, ETH_ALEN); - if ((ret = ax8817x_read_cmd(dev, AX88772_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf)) < 0) { - dbg("Failed to read MAC address: %d", ret); - goto out2; - } - memcpy(dev->net->dev_addr, buf, ETH_ALEN); - - if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, buf)) < 0) { - dbg("Enabling software MII failed: %d", ret); - goto out2; - } - - if (((ret = - ax8817x_read_cmd(dev, AX_CMD_READ_MII_REG, 0x0010, 2, 2, buf)) < 0) - || (*((u16 *)buf) != 0x003b)) { - dbg("Read PHY register 2 must be 0x3b00: %d", ret); - goto out2; - } - - /* Initialize MII structure */ - dev->mii.dev = dev->net; - dev->mii.mdio_read = ax8817x_mdio_read; - dev->mii.mdio_write = ax8817x_mdio_write; - dev->mii.phy_id_mask = 0xff; - dev->mii.reg_num_mask = 0xff; - - /* Get the PHY id */ - if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf)) < 0) { - dbg("Error reading PHY ID: %02x", ret); - goto out2; - } else if (ret < 2) { - /* this should always return 2 bytes */ - dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x", - ret); - ret = -EIO; - goto out2; - } - dev->mii.phy_id = *((u8 *)buf + 1); - - if ((ret = - ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_PRL, 0, 0, buf)) < 0) { - dbg("Set external PHY reset pin level: %d", ret); - goto out2; - } - msleep(150); - if ((ret = - ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL | AX_SWRESET_PRL, 0, 0, buf)) < 0) { - dbg("Set Internal/External PHY reset control: %d", ret); - goto out2; - } - msleep(150); - - - dev->net->set_multicast_list = ax8817x_set_multicast; - dev->net->ethtool_ops = &ax88772_ethtool_ops; - - ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); - ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, - ADVERTISE_ALL | ADVERTISE_CSMA); - mii_nway_restart(&dev->mii); - - if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, AX88772_MEDIUM_DEFAULT, 0, 0, buf)) < 0) { - dbg("Write medium mode register: %d", ret); - goto out2; - } - - if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0, AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,AX88772_IPG2_DEFAULT, 0, buf)) < 0) { - dbg("Write IPG,IPG1,IPG2 failed: %d", ret); - goto out2; - } - if ((ret = - ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf)) < 0) { - dbg("Failed to set hardware MII: %02x", ret); - goto out2; - } - - /* Set RX_CTL to default values with 2k buffer, and enable cactus */ - if ((ret = - ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0088, 0, 0, - buf)) < 0) { - dbg("Reset RX_CTL failed: %d", ret); - goto out2; - } - - kfree(buf); - - return 0; - -out2: - kfree(buf); -out1: - return ret; -} - -static int ax88772_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -{ - u32 *header; - char *packet; - struct sk_buff *ax_skb; - u16 size; - - header = (u32 *) skb->data; - le32_to_cpus(header); - packet = (char *)(header + 1); - - skb_pull(skb, 4); - - while (skb->len > 0) { - if ((short)(*header & 0x0000ffff) != - ~((short)((*header & 0xffff0000) >> 16))) { - devdbg(dev,"header length data is error"); - } - /* get the packet length */ - size = (u16) (*header & 0x0000ffff); - - if ((skb->len) - ((size + 1) & 0xfffe) == 0) - return 2; - if (size > ETH_FRAME_LEN) { - devdbg(dev,"invalid rx length %d", size); - return 0; - } - ax_skb = skb_clone(skb, GFP_ATOMIC); - if (ax_skb) { - ax_skb->len = size; - ax_skb->data = packet; - ax_skb->tail = packet + size; - skb_return(dev, ax_skb); - } else { - return 0; - } - - skb_pull(skb, (size + 1) & 0xfffe); - - if (skb->len == 0) - break; - - header = (u32 *) skb->data; - le32_to_cpus(header); - packet = (char *)(header + 1); - skb_pull(skb, 4); - } - - if (skb->len < 0) { - devdbg(dev,"invalid rx length %d", skb->len); - return 0; - } - return 1; -} - -static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb, - unsigned flags) -{ - int padlen; - int headroom = skb_headroom(skb); - int tailroom = skb_tailroom(skb); - u32 *packet_len; - u32 *padbytes_ptr; - - padlen = ((skb->len + 4) % 512) ? 0 : 4; - - if ((!skb_cloned(skb)) - && ((headroom + tailroom) >= (4 + padlen))) { - if ((headroom < 4) || (tailroom < padlen)) { - skb->data = memmove(skb->head + 4, skb->data, skb->len); - skb->tail = skb->data + skb->len; - } - } else { - struct sk_buff *skb2; - skb2 = skb_copy_expand(skb, 4, padlen, flags); - dev_kfree_skb_any(skb); - skb = skb2; - if (!skb) - return NULL; - } - - packet_len = (u32 *) skb_push(skb, 4); - - packet_len = (u32 *) skb->data; - *packet_len = (((skb->len - 4) ^ 0x0000ffff) << 16) + (skb->len - 4); - - if ((skb->len % 512) == 0) { - padbytes_ptr = (u32 *) skb->tail; - *padbytes_ptr = 0xffff0000; - skb_put(skb, padlen); - } - return skb; -} - -static int ax88772_link_reset(struct usbnet *dev) -{ - u16 lpa; - u16 mode; - - mode = AX88772_MEDIUM_DEFAULT; - lpa = ax8817x_mdio_read(dev->net, dev->mii.phy_id, MII_LPA); - - if ((lpa & LPA_DUPLEX) == 0) - mode &= ~AX88772_MEDIUM_FULL_DUPLEX; - if ((lpa & LPA_100) == 0) - mode &= ~AX88772_MEDIUM_100MB; - ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL); - - return 0; -} - -static const struct driver_info ax8817x_info = { - .description = "ASIX AX8817x USB 2.0 Ethernet", - .bind = ax8817x_bind, - .status = ax8817x_status, - .link_reset = ax88172_link_reset, - .reset = ax88172_link_reset, - .flags = FLAG_ETHER, - .data = 0x00130103, -}; - -static const struct driver_info dlink_dub_e100_info = { - .description = "DLink DUB-E100 USB Ethernet", - .bind = ax8817x_bind, - .status = ax8817x_status, - .link_reset = ax88172_link_reset, - .reset = ax88172_link_reset, - .flags = FLAG_ETHER, - .data = 0x009f9d9f, -}; - -static const struct driver_info netgear_fa120_info = { - .description = "Netgear FA-120 USB Ethernet", - .bind = ax8817x_bind, - .status = ax8817x_status, - .link_reset = ax88172_link_reset, - .reset = ax88172_link_reset, - .flags = FLAG_ETHER, - .data = 0x00130103, -}; - -static const struct driver_info hawking_uf200_info = { - .description = "Hawking UF200 USB Ethernet", - .bind = ax8817x_bind, - .status = ax8817x_status, - .link_reset = ax88172_link_reset, - .reset = ax88172_link_reset, - .flags = FLAG_ETHER, - .data = 0x001f1d1f, -}; - -static const struct driver_info ax88772_info = { - .description = "ASIX AX88772 USB 2.0 Ethernet", - .bind = ax88772_bind, - .status = ax8817x_status, - .link_reset = ax88772_link_reset, - .reset = ax88772_link_reset, - .flags = FLAG_ETHER | FLAG_FRAMING_AX, - .rx_fixup = ax88772_rx_fixup, - .tx_fixup = ax88772_tx_fixup, - .data = 0x00130103, -}; - -#endif /* CONFIG_USB_AX8817X */ - +EXPORT_SYMBOL_GPL(usbnet_skb_return); /*------------------------------------------------------------------------- @@ -1284,7 +502,7 @@ next_desc: status = usb_driver_claim_interface (&usbnet_driver, info->data, dev); if (status < 0) return status; - status = get_endpoints (dev, info->data); + status = usbnet_get_endpoints (dev, info->data); if (status < 0) { /* ensure immediate exit from usbnet_disconnect */ usb_set_intfdata(info->data, NULL); @@ -1721,7 +939,7 @@ static int genelink_rx_fixup (struct usbnet *dev, struct sk_buff *skb) // copy the packet data to the new skb memcpy(skb_put(gl_skb, size), packet->packet_data, size); - skb_return (dev, gl_skb); + usbnet_skb_return (dev, gl_skb); } // advance to the next packet @@ -2616,7 +1834,7 @@ next_desc: * bother to make it unique. Likewise there's no point in tracking * of the CDC event notifications. */ - return get_endpoints (dev, intf); + return usbnet_get_endpoints (dev, intf); bad_desc: dev_info (&dev->udev->dev, "unsupported MDLM descriptors\n"); @@ -2694,7 +1912,7 @@ static void defer_bh(struct usbnet *dev, struct sk_buff *skb, struct sk_buff_hea * NOTE: annoying asymmetry: if it's active, schedule_work() fails, * but tasklet_schedule() doesn't. hope the failure is rare. */ -static void defer_kevent (struct usbnet *dev, int work) +void usbnet_defer_kevent (struct usbnet *dev, int work) { set_bit (work, &dev->flags); if (!schedule_work (&dev->kevent)) @@ -2702,6 +1920,7 @@ static void defer_kevent (struct usbnet *dev, int work) else devdbg (dev, "kevent %d scheduled", work); } +EXPORT_SYMBOL_GPL(usbnet_defer_kevent); /*-------------------------------------------------------------------------*/ @@ -2713,14 +1932,12 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, unsigned flags) struct skb_data *entry; int retval = 0; unsigned long lockflags; - size_t size; + size_t size = dev->rx_urb_size; - size = max(dev->net->hard_header_len + dev->net->mtu, - (unsigned)ETH_FRAME_LEN); if ((skb = alloc_skb (size + NET_IP_ALIGN, flags)) == NULL) { if (netif_msg_rx_err (dev)) devdbg (dev, "no rx skb"); - defer_kevent (dev, EVENT_RX_MEMORY); + usbnet_defer_kevent (dev, EVENT_RX_MEMORY); usb_free_urb (urb); return; } @@ -2742,10 +1959,10 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, unsigned flags) && !test_bit (EVENT_RX_HALT, &dev->flags)) { switch (retval = usb_submit_urb (urb, GFP_ATOMIC)){ case -EPIPE: - defer_kevent (dev, EVENT_RX_HALT); + usbnet_defer_kevent (dev, EVENT_RX_HALT); break; case -ENOMEM: - defer_kevent (dev, EVENT_RX_MEMORY); + usbnet_defer_kevent (dev, EVENT_RX_MEMORY); break; case -ENODEV: if (netif_msg_ifdown (dev)) @@ -2783,7 +2000,7 @@ static inline void rx_process (struct usbnet *dev, struct sk_buff *skb) // else network stack removes extra byte if we forced a short packet if (skb->len) - skb_return (dev, skb); + usbnet_skb_return (dev, skb); else { if (netif_msg_rx_err (dev)) devdbg (dev, "drop"); @@ -2824,7 +2041,7 @@ static void rx_complete (struct urb *urb, struct pt_regs *regs) // storm, recovering as needed. case -EPIPE: dev->stats.rx_errors++; - defer_kevent (dev, EVENT_RX_HALT); + usbnet_defer_kevent (dev, EVENT_RX_HALT); // FALLTHROUGH // software-driven interface shutdown @@ -3066,16 +2283,22 @@ done: /*-------------------------------------------------------------------------*/ -static void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info) +/* ethtool methods; minidrivers may need to add some more, but + * they'll probably want to use this base set. + */ + +void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info) { struct usbnet *dev = netdev_priv(net); + /* REVISIT don't always return "usbnet" */ strncpy (info->driver, driver_name, sizeof info->driver); strncpy (info->version, DRIVER_VERSION, sizeof info->version); strncpy (info->fw_version, dev->driver_info->description, sizeof info->fw_version); usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info); } +EXPORT_SYMBOL_GPL(usbnet_get_drvinfo); static u32 usbnet_get_link (struct net_device *net) { @@ -3089,32 +2312,29 @@ static u32 usbnet_get_link (struct net_device *net) return 1; } -static u32 usbnet_get_msglevel (struct net_device *net) +u32 usbnet_get_msglevel (struct net_device *net) { struct usbnet *dev = netdev_priv(net); return dev->msg_enable; } +EXPORT_SYMBOL_GPL(usbnet_get_msglevel); -static void usbnet_set_msglevel (struct net_device *net, u32 level) +void usbnet_set_msglevel (struct net_device *net, u32 level) { struct usbnet *dev = netdev_priv(net); dev->msg_enable = level; } +EXPORT_SYMBOL_GPL(usbnet_set_msglevel); -static int usbnet_ioctl (struct net_device *net, struct ifreq *rq, int cmd) -{ -#ifdef NEED_MII - { - struct usbnet *dev = netdev_priv(net); - - if (dev->mii.mdio_read != NULL && dev->mii.mdio_write != NULL) - return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); - } -#endif - return -EOPNOTSUPP; -} +/* drivers may override default ethtool_ops in their bind() routine */ +static struct ethtool_ops usbnet_ethtool_ops = { + .get_drvinfo = usbnet_get_drvinfo, + .get_link = usbnet_get_link, + .get_msglevel = usbnet_get_msglevel, + .set_msglevel = usbnet_set_msglevel, +}; /*-------------------------------------------------------------------------*/ @@ -3209,7 +2429,7 @@ static void tx_complete (struct urb *urb, struct pt_regs *regs) switch (urb->status) { case -EPIPE: - defer_kevent (dev, EVENT_TX_HALT); + usbnet_defer_kevent (dev, EVENT_TX_HALT); break; /* software-driven interface shutdown */ @@ -3339,7 +2559,7 @@ static int usbnet_start_xmit (struct sk_buff *skb, struct net_device *net) switch ((retval = usb_submit_urb (urb, GFP_ATOMIC))) { case -EPIPE: netif_stop_queue (net); - defer_kevent (dev, EVENT_TX_HALT); + usbnet_defer_kevent (dev, EVENT_TX_HALT); break; default: if (netif_msg_tx_err (dev)) @@ -3478,8 +2698,6 @@ EXPORT_SYMBOL_GPL(usbnet_disconnect); /*-------------------------------------------------------------------------*/ -static struct ethtool_ops usbnet_ethtool_ops; - // precondition: never called in_interrupt int @@ -3530,8 +2748,11 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) dev->net = net; strcpy (net->name, "usb%d"); memcpy (net->dev_addr, node_id, sizeof node_id); - dev->hard_mtu = net->mtu + net->hard_header_len; + /* rx and tx sides can use different message sizes; + * bind() should set rx_urb_size in that case. + */ + dev->hard_mtu = net->mtu + net->hard_header_len; #if 0 // dma_supported() is deeply broken on almost all architectures // possible with some EHCI controllers @@ -3546,7 +2767,6 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) net->stop = usbnet_stop; net->watchdog_timeo = TX_TIMEOUT_JIFFIES; net->tx_timeout = usbnet_tx_timeout; - net->do_ioctl = usbnet_ioctl; net->ethtool_ops = &usbnet_ethtool_ops; // allow device-specific bind/init procedures @@ -3563,8 +2783,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) /* maybe the remote can't receive an Ethernet MTU */ if (net->mtu > (dev->hard_mtu - net->hard_header_len)) net->mtu = dev->hard_mtu - net->hard_header_len; - } else if (!info->in || info->out) - status = get_endpoints (dev, udev); + } else if (!info->in || !info->out) + status = usbnet_get_endpoints (dev, udev); else { dev->in = usb_rcvbulkpipe (xdev, info->in); dev->out = usb_sndbulkpipe (xdev, info->out); @@ -3581,6 +2801,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) if (status < 0) goto out1; + if (!dev->rx_urb_size) + dev->rx_urb_size = dev->hard_mtu; dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1); SET_NETDEV_DEV(net, &udev->dev); @@ -3662,62 +2884,6 @@ EXPORT_SYMBOL_GPL(usbnet_resume); static const struct usb_device_id products [] = { -#ifdef CONFIG_USB_AX8817X -{ - // Linksys USB200M - USB_DEVICE (0x077b, 0x2226), - .driver_info = (unsigned long) &ax8817x_info, -}, { - // Netgear FA120 - USB_DEVICE (0x0846, 0x1040), - .driver_info = (unsigned long) &netgear_fa120_info, -}, { - // DLink DUB-E100 - USB_DEVICE (0x2001, 0x1a00), - .driver_info = (unsigned long) &dlink_dub_e100_info, -}, { - // Intellinet, ST Lab USB Ethernet - USB_DEVICE (0x0b95, 0x1720), - .driver_info = (unsigned long) &ax8817x_info, -}, { - // Hawking UF200, TrendNet TU2-ET100 - USB_DEVICE (0x07b8, 0x420a), - .driver_info = (unsigned long) &hawking_uf200_info, -}, { - // Billionton Systems, USB2AR - USB_DEVICE (0x08dd, 0x90ff), - .driver_info = (unsigned long) &ax8817x_info, -}, { - // ATEN UC210T - USB_DEVICE (0x0557, 0x2009), - .driver_info = (unsigned long) &ax8817x_info, -}, { - // Buffalo LUA-U2-KTX - USB_DEVICE (0x0411, 0x003d), - .driver_info = (unsigned long) &ax8817x_info, -}, { - // Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter" - USB_DEVICE (0x6189, 0x182d), - .driver_info = (unsigned long) &ax8817x_info, -}, { - // corega FEther USB2-TX - USB_DEVICE (0x07aa, 0x0017), - .driver_info = (unsigned long) &ax8817x_info, -}, { - // Surecom EP-1427X-2 - USB_DEVICE (0x1189, 0x0893), - .driver_info = (unsigned long) &ax8817x_info, -}, { - // goodway corp usb gwusb2e - USB_DEVICE (0x1631, 0x6200), - .driver_info = (unsigned long) &ax8817x_info, -}, { - // ASIX AX88772 10/100 - USB_DEVICE (0x0b95, 0x7720), - .driver_info = (unsigned long) &ax88772_info, -}, -#endif - #ifdef CONFIG_USB_GENESYS { USB_DEVICE (0x05e3, 0x0502), // GL620USB-A @@ -3881,14 +3047,6 @@ static struct usb_driver usbnet_driver = { .resume = usbnet_resume, }; -/* Default ethtool_ops assigned. Devices can override in their bind() routine */ -static struct ethtool_ops usbnet_ethtool_ops = { - .get_drvinfo = usbnet_get_drvinfo, - .get_link = usbnet_get_link, - .get_msglevel = usbnet_get_msglevel, - .set_msglevel = usbnet_set_msglevel, -}; - /*-------------------------------------------------------------------------*/ static int __init usbnet_init(void) diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h index d903b46..21b5feb 100644 --- a/drivers/usb/net/usbnet.h +++ b/drivers/usb/net/usbnet.h @@ -44,6 +44,7 @@ struct usbnet { unsigned long data [5]; u32 xid; u32 hard_mtu; /* count any extra framing */ + size_t rx_urb_size; /* size for rx urbs */ struct mii_if_info mii; /* various kinds of pending driver work */ @@ -140,6 +141,13 @@ struct skb_data { /* skb->cb is one of these */ }; +extern int usbnet_get_endpoints(struct usbnet *, struct usb_interface *); +extern void usbnet_defer_kevent (struct usbnet *, int); +extern void usbnet_skb_return (struct usbnet *, struct sk_buff *); + +extern u32 usbnet_get_msglevel (struct net_device *); +extern void usbnet_set_msglevel (struct net_device *, u32); +extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *); /* messaging support includes the interface name, so it must not be * used before it has one ... notably, in minidriver bind() calls. -- cgit v0.10.2 From 904813cd8a0b334189da285bb05af0b18b062502 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 31 Aug 2005 09:53:26 -0700 Subject: [PATCH] USB: usbnet (4/9) module for net1080 cables As with the "cdc_subset" and "asix" drivers, this just moves the net1080 support into its one driver module. In this case there's a small bit of extra cleanup involved, moving some funky framing logic into the tx_fixup() routine (resolving a long overdue FIXME). Minor historical note: "usbnet" started out as "net1080", then got generalized to make it easier for other network drivers to reuse the urb queueing and fault management code here. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig index 4fb51b9..0aa8637 100644 --- a/drivers/usb/net/Kconfig +++ b/drivers/usb/net/Kconfig @@ -138,15 +138,6 @@ config USB_GENESYS Note that the half-duplex "GL620USB" is not supported. -config USB_NET1080 - boolean "NetChip 1080 based cables (Laplink, ...)" - default y - depends on USB_USBNET - help - Choose this option if you're using a host-to-host cable based - on this design: one NetChip 1080 chips and supporting logic, - supporting LEDs that indicate traffic - config USB_PL2301 boolean "Prolific PL-2301/2302 based cables" default y @@ -233,6 +224,15 @@ config USB_NET_AX8817X what other networking devices you have in use. +config USB_NET_NET1080 + tristate "NetChip 1080 based cables (Laplink, ...)" + default y + depends on USB_USBNET + help + Choose this option if you're using a host-to-host cable based + on this design: one NetChip 1080 chip and supporting logic, + optionally with LEDs that indicate traffic + config USB_NET_CDC_SUBSET tristate "Simple USB Network Links (CDC Ethernet subset)" depends on USB_USBNET diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile index 60dc91e..14d5540 100644 --- a/drivers/usb/net/Makefile +++ b/drivers/usb/net/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_USB_KAWETH) += kaweth.o obj-$(CONFIG_USB_PEGASUS) += pegasus.o obj-$(CONFIG_USB_RTL8150) += rtl8150.o obj-$(CONFIG_USB_NET_AX8817X) += asix.o +obj-$(CONFIG_USB_NET_NET1080) += net1080.o obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o obj-$(CONFIG_USB_USBNET) += usbnet.o obj-$(CONFIG_USB_ZD1201) += zd1201.o diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c new file mode 100644 index 0000000..a4309c4 --- /dev/null +++ b/drivers/usb/net/net1080.c @@ -0,0 +1,622 @@ +/* + * Net1080 based USB host-to-host cables + * Copyright (C) 2000-2005 by David Brownell + * + * 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 + */ + +// #define DEBUG // error path messages, extra info +// #define VERBOSE // more; success messages + +#include +#ifdef CONFIG_USB_DEBUG +# define DEBUG +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "usbnet.h" + + +/* + * Netchip 1080 driver ... http://www.netchip.com + * (Sept 2004: End-of-life announcement has been sent.) + * Used in (some) LapLink cables + */ + +#define frame_errors data[1] + +/* + * NetChip framing of ethernet packets, supporting additional error + * checks for links that may drop bulk packets from inside messages. + * Odd USB length == always short read for last usb packet. + * - nc_header + * - Ethernet header (14 bytes) + * - payload + * - (optional padding byte, if needed so length becomes odd) + * - nc_trailer + * + * This framing is to be avoided for non-NetChip devices. + */ + +struct nc_header { // packed: + __le16 hdr_len; // sizeof nc_header (LE, all) + __le16 packet_len; // payload size (including ethhdr) + __le16 packet_id; // detects dropped packets +#define MIN_HEADER 6 + + // all else is optional, and must start with: + // __le16 vendorId; // from usb-if + // __le16 productId; +} __attribute__((__packed__)); + +#define PAD_BYTE ((unsigned char)0xAC) + +struct nc_trailer { + __le16 packet_id; +} __attribute__((__packed__)); + +// packets may use FLAG_FRAMING_NC and optional pad +#define FRAMED_SIZE(mtu) (sizeof (struct nc_header) \ + + sizeof (struct ethhdr) \ + + (mtu) \ + + 1 \ + + sizeof (struct nc_trailer)) + +#define MIN_FRAMED FRAMED_SIZE(0) + +/* packets _could_ be up to 64KB... */ +#define NC_MAX_PACKET 32767 + + +/* + * Zero means no timeout; else, how long a 64 byte bulk packet may be queued + * before the hardware drops it. If that's done, the driver will need to + * frame network packets to guard against the dropped USB packets. The win32 + * driver sets this for both sides of the link. + */ +#define NC_READ_TTL_MS ((u8)255) // ms + +/* + * We ignore most registers and EEPROM contents. + */ +#define REG_USBCTL ((u8)0x04) +#define REG_TTL ((u8)0x10) +#define REG_STATUS ((u8)0x11) + +/* + * Vendor specific requests to read/write data + */ +#define REQUEST_REGISTER ((u8)0x10) +#define REQUEST_EEPROM ((u8)0x11) + +static int +nc_vendor_read(struct usbnet *dev, u8 req, u8 regnum, u16 *retval_ptr) +{ + int status = usb_control_msg(dev->udev, + usb_rcvctrlpipe(dev->udev, 0), + req, + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + 0, regnum, + retval_ptr, sizeof *retval_ptr, + USB_CTRL_GET_TIMEOUT); + if (status > 0) + status = 0; + if (!status) + le16_to_cpus(retval_ptr); + return status; +} + +static inline int +nc_register_read(struct usbnet *dev, u8 regnum, u16 *retval_ptr) +{ + return nc_vendor_read(dev, REQUEST_REGISTER, regnum, retval_ptr); +} + +// no retval ... can become async, usable in_interrupt() +static void +nc_vendor_write(struct usbnet *dev, u8 req, u8 regnum, u16 value) +{ + usb_control_msg(dev->udev, + usb_sndctrlpipe(dev->udev, 0), + req, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + value, regnum, + NULL, 0, // data is in setup packet + USB_CTRL_SET_TIMEOUT); +} + +static inline void +nc_register_write(struct usbnet *dev, u8 regnum, u16 value) +{ + nc_vendor_write(dev, REQUEST_REGISTER, regnum, value); +} + + +#if 0 +static void nc_dump_registers(struct usbnet *dev) +{ + u8 reg; + u16 *vp = kmalloc(sizeof (u16)); + + if (!vp) { + dbg("no memory?"); + return; + } + + dbg("%s registers:", dev->net->name); + for (reg = 0; reg < 0x20; reg++) { + int retval; + + // reading some registers is trouble + if (reg >= 0x08 && reg <= 0xf) + continue; + if (reg >= 0x12 && reg <= 0x1e) + continue; + + retval = nc_register_read(dev, reg, vp); + if (retval < 0) + dbg("%s reg [0x%x] ==> error %d", + dev->net->name, reg, retval); + else + dbg("%s reg [0x%x] = 0x%x", + dev->net->name, reg, *vp); + } + kfree(vp); +} +#endif + + +/*-------------------------------------------------------------------------*/ + +/* + * Control register + */ + +#define USBCTL_WRITABLE_MASK 0x1f0f +// bits 15-13 reserved, r/o +#define USBCTL_ENABLE_LANG (1 << 12) +#define USBCTL_ENABLE_MFGR (1 << 11) +#define USBCTL_ENABLE_PROD (1 << 10) +#define USBCTL_ENABLE_SERIAL (1 << 9) +#define USBCTL_ENABLE_DEFAULTS (1 << 8) +// bits 7-4 reserved, r/o +#define USBCTL_FLUSH_OTHER (1 << 3) +#define USBCTL_FLUSH_THIS (1 << 2) +#define USBCTL_DISCONN_OTHER (1 << 1) +#define USBCTL_DISCONN_THIS (1 << 0) + +static inline void nc_dump_usbctl(struct usbnet *dev, u16 usbctl) +{ + if (!netif_msg_link(dev)) + return; + devdbg(dev, "net1080 %s-%s usbctl 0x%x:%s%s%s%s%s;" + " this%s%s;" + " other%s%s; r/o 0x%x", + dev->udev->bus->bus_name, dev->udev->devpath, + usbctl, + (usbctl & USBCTL_ENABLE_LANG) ? " lang" : "", + (usbctl & USBCTL_ENABLE_MFGR) ? " mfgr" : "", + (usbctl & USBCTL_ENABLE_PROD) ? " prod" : "", + (usbctl & USBCTL_ENABLE_SERIAL) ? " serial" : "", + (usbctl & USBCTL_ENABLE_DEFAULTS) ? " defaults" : "", + + (usbctl & USBCTL_FLUSH_OTHER) ? " FLUSH" : "", + (usbctl & USBCTL_DISCONN_OTHER) ? " DIS" : "", + (usbctl & USBCTL_FLUSH_THIS) ? " FLUSH" : "", + (usbctl & USBCTL_DISCONN_THIS) ? " DIS" : "", + usbctl & ~USBCTL_WRITABLE_MASK + ); +} + +/*-------------------------------------------------------------------------*/ + +/* + * Status register + */ + +#define STATUS_PORT_A (1 << 15) + +#define STATUS_CONN_OTHER (1 << 14) +#define STATUS_SUSPEND_OTHER (1 << 13) +#define STATUS_MAILBOX_OTHER (1 << 12) +#define STATUS_PACKETS_OTHER(n) (((n) >> 8) && 0x03) + +#define STATUS_CONN_THIS (1 << 6) +#define STATUS_SUSPEND_THIS (1 << 5) +#define STATUS_MAILBOX_THIS (1 << 4) +#define STATUS_PACKETS_THIS(n) (((n) >> 0) && 0x03) + +#define STATUS_UNSPEC_MASK 0x0c8c +#define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK)) + + +static inline void nc_dump_status(struct usbnet *dev, u16 status) +{ + if (!netif_msg_link(dev)) + return; + devdbg(dev, "net1080 %s-%s status 0x%x:" + " this (%c) PKT=%d%s%s%s;" + " other PKT=%d%s%s%s; unspec 0x%x", + dev->udev->bus->bus_name, dev->udev->devpath, + status, + + // XXX the packet counts don't seem right + // (1 at reset, not 0); maybe UNSPEC too + + (status & STATUS_PORT_A) ? 'A' : 'B', + STATUS_PACKETS_THIS(status), + (status & STATUS_CONN_THIS) ? " CON" : "", + (status & STATUS_SUSPEND_THIS) ? " SUS" : "", + (status & STATUS_MAILBOX_THIS) ? " MBOX" : "", + + STATUS_PACKETS_OTHER(status), + (status & STATUS_CONN_OTHER) ? " CON" : "", + (status & STATUS_SUSPEND_OTHER) ? " SUS" : "", + (status & STATUS_MAILBOX_OTHER) ? " MBOX" : "", + + status & STATUS_UNSPEC_MASK + ); +} + +/*-------------------------------------------------------------------------*/ + +/* + * TTL register + */ + +#define TTL_THIS(ttl) (0x00ff & ttl) +#define TTL_OTHER(ttl) (0x00ff & (ttl >> 8)) +#define MK_TTL(this,other) ((u16)(((other)<<8)|(0x00ff&(this)))) + +static inline void nc_dump_ttl(struct usbnet *dev, u16 ttl) +{ + if (netif_msg_link(dev)) + devdbg(dev, "net1080 %s-%s ttl 0x%x this = %d, other = %d", + dev->udev->bus->bus_name, dev->udev->devpath, + ttl, TTL_THIS(ttl), TTL_OTHER(ttl)); +} + +/*-------------------------------------------------------------------------*/ + +static int net1080_reset(struct usbnet *dev) +{ + u16 usbctl, status, ttl; + u16 *vp = kmalloc(sizeof (u16), GFP_KERNEL); + int retval; + + if (!vp) + return -ENOMEM; + + // nc_dump_registers(dev); + + if ((retval = nc_register_read(dev, REG_STATUS, vp)) < 0) { + dbg("can't read %s-%s status: %d", + dev->udev->bus->bus_name, dev->udev->devpath, retval); + goto done; + } + status = *vp; + nc_dump_status(dev, status); + + if ((retval = nc_register_read(dev, REG_USBCTL, vp)) < 0) { + dbg("can't read USBCTL, %d", retval); + goto done; + } + usbctl = *vp; + nc_dump_usbctl(dev, usbctl); + + nc_register_write(dev, REG_USBCTL, + USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER); + + if ((retval = nc_register_read(dev, REG_TTL, vp)) < 0) { + dbg("can't read TTL, %d", retval); + goto done; + } + ttl = *vp; + // nc_dump_ttl(dev, ttl); + + nc_register_write(dev, REG_TTL, + MK_TTL(NC_READ_TTL_MS, TTL_OTHER(ttl)) ); + dbg("%s: assigned TTL, %d ms", dev->net->name, NC_READ_TTL_MS); + + if (netif_msg_link(dev)) + devinfo(dev, "port %c, peer %sconnected", + (status & STATUS_PORT_A) ? 'A' : 'B', + (status & STATUS_CONN_OTHER) ? "" : "dis" + ); + retval = 0; + +done: + kfree(vp); + return retval; +} + +static int net1080_check_connect(struct usbnet *dev) +{ + int retval; + u16 status; + u16 *vp = kmalloc(sizeof (u16), GFP_KERNEL); + + if (!vp) + return -ENOMEM; + retval = nc_register_read(dev, REG_STATUS, vp); + status = *vp; + kfree(vp); + if (retval != 0) { + dbg("%s net1080_check_conn read - %d", dev->net->name, retval); + return retval; + } + if ((status & STATUS_CONN_OTHER) != STATUS_CONN_OTHER) + return -ENOLINK; + return 0; +} + +static void nc_flush_complete(struct urb *urb, struct pt_regs *regs) +{ + kfree(urb->context); + usb_free_urb(urb); +} + +static void nc_ensure_sync(struct usbnet *dev) +{ + dev->frame_errors++; + if (dev->frame_errors > 5) { + struct urb *urb; + struct usb_ctrlrequest *req; + int status; + + /* Send a flush */ + urb = usb_alloc_urb(0, SLAB_ATOMIC); + if (!urb) + return; + + req = kmalloc(sizeof *req, GFP_ATOMIC); + if (!req) { + usb_free_urb(urb); + return; + } + + req->bRequestType = USB_DIR_OUT + | USB_TYPE_VENDOR + | USB_RECIP_DEVICE; + req->bRequest = REQUEST_REGISTER; + req->wValue = cpu_to_le16(USBCTL_FLUSH_THIS + | USBCTL_FLUSH_OTHER); + req->wIndex = cpu_to_le16(REG_USBCTL); + req->wLength = cpu_to_le16(0); + + /* queue an async control request, we don't need + * to do anything when it finishes except clean up. + */ + usb_fill_control_urb(urb, dev->udev, + usb_sndctrlpipe(dev->udev, 0), + (unsigned char *) req, + NULL, 0, + nc_flush_complete, req); + status = usb_submit_urb(urb, GFP_ATOMIC); + if (status) { + kfree(req); + usb_free_urb(urb); + return; + } + + if (netif_msg_rx_err(dev)) + devdbg(dev, "flush net1080; too many framing errors"); + dev->frame_errors = 0; + } +} + +static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb) +{ + struct nc_header *header; + struct nc_trailer *trailer; + u16 hdr_len, packet_len; + + if (!(skb->len & 0x01)) { +#ifdef DEBUG + struct net_device *net = dev->net; + dbg("rx framesize %d range %d..%d mtu %d", skb->len, + net->hard_header_len, dev->hard_mtu, net->mtu); +#endif + dev->stats.rx_frame_errors++; + nc_ensure_sync(dev); + return 0; + } + + header = (struct nc_header *) skb->data; + hdr_len = le16_to_cpup(&header->hdr_len); + packet_len = le16_to_cpup(&header->packet_len); + if (FRAMED_SIZE(packet_len) > NC_MAX_PACKET) { + dev->stats.rx_frame_errors++; + dbg("packet too big, %d", packet_len); + nc_ensure_sync(dev); + return 0; + } else if (hdr_len < MIN_HEADER) { + dev->stats.rx_frame_errors++; + dbg("header too short, %d", hdr_len); + nc_ensure_sync(dev); + return 0; + } else if (hdr_len > MIN_HEADER) { + // out of band data for us? + dbg("header OOB, %d bytes", hdr_len - MIN_HEADER); + nc_ensure_sync(dev); + // switch (vendor/product ids) { ... } + } + skb_pull(skb, hdr_len); + + trailer = (struct nc_trailer *) + (skb->data + skb->len - sizeof *trailer); + skb_trim(skb, skb->len - sizeof *trailer); + + if ((packet_len & 0x01) == 0) { + if (skb->data [packet_len] != PAD_BYTE) { + dev->stats.rx_frame_errors++; + dbg("bad pad"); + return 0; + } + skb_trim(skb, skb->len - 1); + } + if (skb->len != packet_len) { + dev->stats.rx_frame_errors++; + dbg("bad packet len %d (expected %d)", + skb->len, packet_len); + nc_ensure_sync(dev); + return 0; + } + if (header->packet_id != get_unaligned(&trailer->packet_id)) { + dev->stats.rx_fifo_errors++; + dbg("(2+ dropped) rx packet_id mismatch 0x%x 0x%x", + le16_to_cpu(header->packet_id), + le16_to_cpu(trailer->packet_id)); + return 0; + } +#if 0 + devdbg(dev, "frame hdr_len, + header->packet_len, header->packet_id); +#endif + dev->frame_errors = 0; + return 1; +} + +static struct sk_buff * +net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) +{ + int padlen; + struct sk_buff *skb2; + struct nc_header *header = NULL; + struct nc_trailer *trailer = NULL; + int len = skb->len; + + padlen = ((len + sizeof (struct nc_header) + + sizeof (struct nc_trailer)) & 0x01) ? 0 : 1; + if (!skb_cloned(skb)) { + int headroom = skb_headroom(skb); + int tailroom = skb_tailroom(skb); + + if ((padlen + sizeof (struct nc_trailer)) <= tailroom + && sizeof (struct nc_header) <= headroom) + /* There's enough head and tail room */ + goto encapsulate; + + if ((sizeof (struct nc_header) + padlen + + sizeof (struct nc_trailer)) < + (headroom + tailroom)) { + /* There's enough total room, so just readjust */ + skb->data = memmove(skb->head + + sizeof (struct nc_header), + skb->data, skb->len); + skb->tail = skb->data + len; + goto encapsulate; + } + } + + /* Create a new skb to use with the correct size */ + skb2 = skb_copy_expand(skb, + sizeof (struct nc_header), + sizeof (struct nc_trailer) + padlen, + flags); + dev_kfree_skb_any(skb); + if (!skb2) + return skb2; + skb = skb2; + +encapsulate: + /* header first */ + header = (struct nc_header *) skb_push(skb, sizeof *header); + header->hdr_len = cpu_to_le16(sizeof (*header)); + header->packet_len = cpu_to_le16(len); + header->packet_id = cpu_to_le16((u16)dev->xid++); + + /* maybe pad; then trailer */ + if (!((skb->len + sizeof *trailer) & 0x01)) + *skb_put(skb, 1) = PAD_BYTE; + trailer = (struct nc_trailer *) skb_put(skb, sizeof *trailer); + put_unaligned(header->packet_id, &trailer->packet_id); +#if 0 + devdbg(dev, "frame >tx h %d p %d id %d", + header->hdr_len, header->packet_len, + header->packet_id); +#endif + return skb; +} + +static int net1080_bind(struct usbnet *dev, struct usb_interface *intf) +{ + unsigned extra = sizeof (struct nc_header) + + 1 + + sizeof (struct nc_trailer); + + dev->net->hard_header_len += extra; + dev->rx_urb_size = dev->net->hard_header_len + dev->net->mtu; + dev->hard_mtu = NC_MAX_PACKET; + return usbnet_get_endpoints (dev, intf); +} + +static const struct driver_info net1080_info = { + .description = "NetChip TurboCONNECT", + .flags = FLAG_FRAMING_NC, + .bind = net1080_bind, + .reset = net1080_reset, + .check_connect = net1080_check_connect, + .rx_fixup = net1080_rx_fixup, + .tx_fixup = net1080_tx_fixup, +}; + +static const struct usb_device_id products [] = { +{ + USB_DEVICE(0x0525, 0x1080), // NetChip ref design + .driver_info = (unsigned long) &net1080_info, +}, { + USB_DEVICE(0x06D0, 0x0622), // Laplink Gold + .driver_info = (unsigned long) &net1080_info, +}, + { }, // END +}; +MODULE_DEVICE_TABLE(usb, products); + +static struct usb_driver net1080_driver = { + .owner = THIS_MODULE, + .name = "net1080", + .id_table = products, + .probe = usbnet_probe, + .disconnect = usbnet_disconnect, + .suspend = usbnet_suspend, + .resume = usbnet_resume, +}; + +static int __init net1080_init(void) +{ + return usb_register(&net1080_driver); +} +module_init(net1080_init); + +static void __exit net1080_exit(void) +{ + usb_deregister(&net1080_driver); +} +module_exit(net1080_exit); + +MODULE_AUTHOR("David Brownell"); +MODULE_DESCRIPTION("NetChip 1080 based USB Host-to-Host Links"); +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 99a4881..590bf31 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -119,7 +119,6 @@ # define DEBUG #endif #include -#include #include #include #include @@ -128,10 +127,6 @@ #include #include #include -#include -#include - -#include #include "usbnet.h" @@ -1030,531 +1025,6 @@ static const struct driver_info genelink_info = { -#ifdef CONFIG_USB_NET1080 -#define HAVE_HARDWARE - -/*------------------------------------------------------------------------- - * - * Netchip 1080 driver ... http://www.netchip.com - * Used in LapLink cables - * - *-------------------------------------------------------------------------*/ - -#define frame_errors data[1] - -/* - * NetChip framing of ethernet packets, supporting additional error - * checks for links that may drop bulk packets from inside messages. - * Odd USB length == always short read for last usb packet. - * - nc_header - * - Ethernet header (14 bytes) - * - payload - * - (optional padding byte, if needed so length becomes odd) - * - nc_trailer - * - * This framing is to be avoided for non-NetChip devices. - */ - -struct nc_header { // packed: - __le16 hdr_len; // sizeof nc_header (LE, all) - __le16 packet_len; // payload size (including ethhdr) - __le16 packet_id; // detects dropped packets -#define MIN_HEADER 6 - - // all else is optional, and must start with: - // u16 vendorId; // from usb-if - // u16 productId; -} __attribute__((__packed__)); - -#define PAD_BYTE ((unsigned char)0xAC) - -struct nc_trailer { - __le16 packet_id; -} __attribute__((__packed__)); - -// packets may use FLAG_FRAMING_NC and optional pad -#define FRAMED_SIZE(mtu) (sizeof (struct nc_header) \ - + sizeof (struct ethhdr) \ - + (mtu) \ - + 1 \ - + sizeof (struct nc_trailer)) - -#define MIN_FRAMED FRAMED_SIZE(0) - -/* packets _could_ be up to 64KB... */ -#define NC_MAX_PACKET 32767 - - -/* - * Zero means no timeout; else, how long a 64 byte bulk packet may be queued - * before the hardware drops it. If that's done, the driver will need to - * frame network packets to guard against the dropped USB packets. The win32 - * driver sets this for both sides of the link. - */ -#define NC_READ_TTL_MS ((u8)255) // ms - -/* - * We ignore most registers and EEPROM contents. - */ -#define REG_USBCTL ((u8)0x04) -#define REG_TTL ((u8)0x10) -#define REG_STATUS ((u8)0x11) - -/* - * Vendor specific requests to read/write data - */ -#define REQUEST_REGISTER ((u8)0x10) -#define REQUEST_EEPROM ((u8)0x11) - -static int -nc_vendor_read (struct usbnet *dev, u8 req, u8 regnum, u16 *retval_ptr) -{ - int status = usb_control_msg (dev->udev, - usb_rcvctrlpipe (dev->udev, 0), - req, - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - 0, regnum, - retval_ptr, sizeof *retval_ptr, - CONTROL_TIMEOUT_MS); - if (status > 0) - status = 0; - if (!status) - le16_to_cpus (retval_ptr); - return status; -} - -static inline int -nc_register_read (struct usbnet *dev, u8 regnum, u16 *retval_ptr) -{ - return nc_vendor_read (dev, REQUEST_REGISTER, regnum, retval_ptr); -} - -// no retval ... can become async, usable in_interrupt() -static void -nc_vendor_write (struct usbnet *dev, u8 req, u8 regnum, u16 value) -{ - usb_control_msg (dev->udev, - usb_sndctrlpipe (dev->udev, 0), - req, - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - value, regnum, - NULL, 0, // data is in setup packet - CONTROL_TIMEOUT_MS); -} - -static inline void -nc_register_write (struct usbnet *dev, u8 regnum, u16 value) -{ - nc_vendor_write (dev, REQUEST_REGISTER, regnum, value); -} - - -#if 0 -static void nc_dump_registers (struct usbnet *dev) -{ - u8 reg; - u16 *vp = kmalloc (sizeof (u16)); - - if (!vp) { - dbg ("no memory?"); - return; - } - - dbg ("%s registers:", dev->net->name); - for (reg = 0; reg < 0x20; reg++) { - int retval; - - // reading some registers is trouble - if (reg >= 0x08 && reg <= 0xf) - continue; - if (reg >= 0x12 && reg <= 0x1e) - continue; - - retval = nc_register_read (dev, reg, vp); - if (retval < 0) - dbg ("%s reg [0x%x] ==> error %d", - dev->net->name, reg, retval); - else - dbg ("%s reg [0x%x] = 0x%x", - dev->net->name, reg, *vp); - } - kfree (vp); -} -#endif - - -/*-------------------------------------------------------------------------*/ - -/* - * Control register - */ - -#define USBCTL_WRITABLE_MASK 0x1f0f -// bits 15-13 reserved, r/o -#define USBCTL_ENABLE_LANG (1 << 12) -#define USBCTL_ENABLE_MFGR (1 << 11) -#define USBCTL_ENABLE_PROD (1 << 10) -#define USBCTL_ENABLE_SERIAL (1 << 9) -#define USBCTL_ENABLE_DEFAULTS (1 << 8) -// bits 7-4 reserved, r/o -#define USBCTL_FLUSH_OTHER (1 << 3) -#define USBCTL_FLUSH_THIS (1 << 2) -#define USBCTL_DISCONN_OTHER (1 << 1) -#define USBCTL_DISCONN_THIS (1 << 0) - -static inline void nc_dump_usbctl (struct usbnet *dev, u16 usbctl) -{ - if (!netif_msg_link (dev)) - return; - devdbg (dev, "net1080 %s-%s usbctl 0x%x:%s%s%s%s%s;" - " this%s%s;" - " other%s%s; r/o 0x%x", - dev->udev->bus->bus_name, dev->udev->devpath, - usbctl, - (usbctl & USBCTL_ENABLE_LANG) ? " lang" : "", - (usbctl & USBCTL_ENABLE_MFGR) ? " mfgr" : "", - (usbctl & USBCTL_ENABLE_PROD) ? " prod" : "", - (usbctl & USBCTL_ENABLE_SERIAL) ? " serial" : "", - (usbctl & USBCTL_ENABLE_DEFAULTS) ? " defaults" : "", - - (usbctl & USBCTL_FLUSH_OTHER) ? " FLUSH" : "", - (usbctl & USBCTL_DISCONN_OTHER) ? " DIS" : "", - (usbctl & USBCTL_FLUSH_THIS) ? " FLUSH" : "", - (usbctl & USBCTL_DISCONN_THIS) ? " DIS" : "", - usbctl & ~USBCTL_WRITABLE_MASK - ); -} - -/*-------------------------------------------------------------------------*/ - -/* - * Status register - */ - -#define STATUS_PORT_A (1 << 15) - -#define STATUS_CONN_OTHER (1 << 14) -#define STATUS_SUSPEND_OTHER (1 << 13) -#define STATUS_MAILBOX_OTHER (1 << 12) -#define STATUS_PACKETS_OTHER(n) (((n) >> 8) && 0x03) - -#define STATUS_CONN_THIS (1 << 6) -#define STATUS_SUSPEND_THIS (1 << 5) -#define STATUS_MAILBOX_THIS (1 << 4) -#define STATUS_PACKETS_THIS(n) (((n) >> 0) && 0x03) - -#define STATUS_UNSPEC_MASK 0x0c8c -#define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK)) - - -static inline void nc_dump_status (struct usbnet *dev, u16 status) -{ - if (!netif_msg_link (dev)) - return; - devdbg (dev, "net1080 %s-%s status 0x%x:" - " this (%c) PKT=%d%s%s%s;" - " other PKT=%d%s%s%s; unspec 0x%x", - dev->udev->bus->bus_name, dev->udev->devpath, - status, - - // XXX the packet counts don't seem right - // (1 at reset, not 0); maybe UNSPEC too - - (status & STATUS_PORT_A) ? 'A' : 'B', - STATUS_PACKETS_THIS (status), - (status & STATUS_CONN_THIS) ? " CON" : "", - (status & STATUS_SUSPEND_THIS) ? " SUS" : "", - (status & STATUS_MAILBOX_THIS) ? " MBOX" : "", - - STATUS_PACKETS_OTHER (status), - (status & STATUS_CONN_OTHER) ? " CON" : "", - (status & STATUS_SUSPEND_OTHER) ? " SUS" : "", - (status & STATUS_MAILBOX_OTHER) ? " MBOX" : "", - - status & STATUS_UNSPEC_MASK - ); -} - -/*-------------------------------------------------------------------------*/ - -/* - * TTL register - */ - -#define TTL_THIS(ttl) (0x00ff & ttl) -#define TTL_OTHER(ttl) (0x00ff & (ttl >> 8)) -#define MK_TTL(this,other) ((u16)(((other)<<8)|(0x00ff&(this)))) - -static inline void nc_dump_ttl (struct usbnet *dev, u16 ttl) -{ - if (netif_msg_link (dev)) - devdbg (dev, "net1080 %s-%s ttl 0x%x this = %d, other = %d", - dev->udev->bus->bus_name, dev->udev->devpath, - ttl, TTL_THIS (ttl), TTL_OTHER (ttl)); -} - -/*-------------------------------------------------------------------------*/ - -static int net1080_reset (struct usbnet *dev) -{ - u16 usbctl, status, ttl; - u16 *vp = kmalloc (sizeof (u16), GFP_KERNEL); - int retval; - - if (!vp) - return -ENOMEM; - - // nc_dump_registers (dev); - - if ((retval = nc_register_read (dev, REG_STATUS, vp)) < 0) { - dbg ("can't read %s-%s status: %d", - dev->udev->bus->bus_name, dev->udev->devpath, retval); - goto done; - } - status = *vp; - nc_dump_status (dev, status); - - if ((retval = nc_register_read (dev, REG_USBCTL, vp)) < 0) { - dbg ("can't read USBCTL, %d", retval); - goto done; - } - usbctl = *vp; - nc_dump_usbctl (dev, usbctl); - - nc_register_write (dev, REG_USBCTL, - USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER); - - if ((retval = nc_register_read (dev, REG_TTL, vp)) < 0) { - dbg ("can't read TTL, %d", retval); - goto done; - } - ttl = *vp; - // nc_dump_ttl (dev, ttl); - - nc_register_write (dev, REG_TTL, - MK_TTL (NC_READ_TTL_MS, TTL_OTHER (ttl)) ); - dbg ("%s: assigned TTL, %d ms", dev->net->name, NC_READ_TTL_MS); - - if (netif_msg_link (dev)) - devinfo (dev, "port %c, peer %sconnected", - (status & STATUS_PORT_A) ? 'A' : 'B', - (status & STATUS_CONN_OTHER) ? "" : "dis" - ); - retval = 0; - -done: - kfree (vp); - return retval; -} - -static int net1080_check_connect (struct usbnet *dev) -{ - int retval; - u16 status; - u16 *vp = kmalloc (sizeof (u16), GFP_KERNEL); - - if (!vp) - return -ENOMEM; - retval = nc_register_read (dev, REG_STATUS, vp); - status = *vp; - kfree (vp); - if (retval != 0) { - dbg ("%s net1080_check_conn read - %d", dev->net->name, retval); - return retval; - } - if ((status & STATUS_CONN_OTHER) != STATUS_CONN_OTHER) - return -ENOLINK; - return 0; -} - -static void nc_flush_complete (struct urb *urb, struct pt_regs *regs) -{ - kfree (urb->context); - usb_free_urb(urb); -} - -static void nc_ensure_sync (struct usbnet *dev) -{ - dev->frame_errors++; - if (dev->frame_errors > 5) { - struct urb *urb; - struct usb_ctrlrequest *req; - int status; - - /* Send a flush */ - urb = usb_alloc_urb (0, SLAB_ATOMIC); - if (!urb) - return; - - req = kmalloc (sizeof *req, GFP_ATOMIC); - if (!req) { - usb_free_urb (urb); - return; - } - - req->bRequestType = USB_DIR_OUT - | USB_TYPE_VENDOR - | USB_RECIP_DEVICE; - req->bRequest = REQUEST_REGISTER; - req->wValue = cpu_to_le16 (USBCTL_FLUSH_THIS - | USBCTL_FLUSH_OTHER); - req->wIndex = cpu_to_le16 (REG_USBCTL); - req->wLength = cpu_to_le16 (0); - - /* queue an async control request, we don't need - * to do anything when it finishes except clean up. - */ - usb_fill_control_urb (urb, dev->udev, - usb_sndctrlpipe (dev->udev, 0), - (unsigned char *) req, - NULL, 0, - nc_flush_complete, req); - status = usb_submit_urb (urb, GFP_ATOMIC); - if (status) { - kfree (req); - usb_free_urb (urb); - return; - } - - if (netif_msg_rx_err (dev)) - devdbg (dev, "flush net1080; too many framing errors"); - dev->frame_errors = 0; - } -} - -static int net1080_rx_fixup (struct usbnet *dev, struct sk_buff *skb) -{ - struct nc_header *header; - struct net_device *net = dev->net; - struct nc_trailer *trailer; - u16 hdr_len, packet_len; - - if (!(skb->len & 0x01)) { - dev->stats.rx_frame_errors++; - dbg ("rx framesize %d range %d..%d mtu %d", skb->len, - net->hard_header_len, dev->hard_mtu, net->mtu); - nc_ensure_sync (dev); - return 0; - } - - header = (struct nc_header *) skb->data; - hdr_len = le16_to_cpup (&header->hdr_len); - packet_len = le16_to_cpup (&header->packet_len); - if (FRAMED_SIZE (packet_len) > NC_MAX_PACKET) { - dev->stats.rx_frame_errors++; - dbg ("packet too big, %d", packet_len); - nc_ensure_sync (dev); - return 0; - } else if (hdr_len < MIN_HEADER) { - dev->stats.rx_frame_errors++; - dbg ("header too short, %d", hdr_len); - nc_ensure_sync (dev); - return 0; - } else if (hdr_len > MIN_HEADER) { - // out of band data for us? - dbg ("header OOB, %d bytes", hdr_len - MIN_HEADER); - nc_ensure_sync (dev); - // switch (vendor/product ids) { ... } - } - skb_pull (skb, hdr_len); - - trailer = (struct nc_trailer *) - (skb->data + skb->len - sizeof *trailer); - skb_trim (skb, skb->len - sizeof *trailer); - - if ((packet_len & 0x01) == 0) { - if (skb->data [packet_len] != PAD_BYTE) { - dev->stats.rx_frame_errors++; - dbg ("bad pad"); - return 0; - } - skb_trim (skb, skb->len - 1); - } - if (skb->len != packet_len) { - dev->stats.rx_frame_errors++; - dbg ("bad packet len %d (expected %d)", - skb->len, packet_len); - nc_ensure_sync (dev); - return 0; - } - if (header->packet_id != get_unaligned (&trailer->packet_id)) { - dev->stats.rx_fifo_errors++; - dbg ("(2+ dropped) rx packet_id mismatch 0x%x 0x%x", - le16_to_cpu (header->packet_id), - le16_to_cpu (trailer->packet_id)); - return 0; - } -#if 0 - devdbg (dev, "frame hdr_len, - header->packet_len, header->packet_id); -#endif - dev->frame_errors = 0; - return 1; -} - -static struct sk_buff * -net1080_tx_fixup (struct usbnet *dev, struct sk_buff *skb, unsigned flags) -{ - int padlen; - struct sk_buff *skb2; - - padlen = ((skb->len + sizeof (struct nc_header) - + sizeof (struct nc_trailer)) & 0x01) ? 0 : 1; - if (!skb_cloned (skb)) { - int headroom = skb_headroom (skb); - int tailroom = skb_tailroom (skb); - - if ((padlen + sizeof (struct nc_trailer)) <= tailroom - && sizeof (struct nc_header) <= headroom) - /* There's enough head and tail room */ - return skb; - - if ((sizeof (struct nc_header) + padlen - + sizeof (struct nc_trailer)) < - (headroom + tailroom)) { - /* There's enough total room, so just readjust */ - skb->data = memmove (skb->head - + sizeof (struct nc_header), - skb->data, skb->len); - skb->tail = skb->data + skb->len; - return skb; - } - } - - /* Create a new skb to use with the correct size */ - skb2 = skb_copy_expand (skb, - sizeof (struct nc_header), - sizeof (struct nc_trailer) + padlen, - flags); - dev_kfree_skb_any (skb); - return skb2; -} - -static int net1080_bind (struct usbnet *dev, struct usb_interface *intf) -{ - unsigned extra = sizeof (struct nc_header) - + 1 - + sizeof (struct nc_trailer); - - dev->net->hard_header_len += extra; - dev->hard_mtu = NC_MAX_PACKET; - return 0; -} - -static const struct driver_info net1080_info = { - .description = "NetChip TurboCONNECT", - .flags = FLAG_FRAMING_NC, - .bind = net1080_bind, - .reset = net1080_reset, - .check_connect = net1080_check_connect, - .rx_fixup = net1080_rx_fixup, - .tx_fixup = net1080_tx_fixup, -}; - -#endif /* CONFIG_USB_NET1080 */ - - - #ifdef CONFIG_USB_PL2301 #define HAVE_HARDWARE @@ -2486,10 +1956,6 @@ static int usbnet_start_xmit (struct sk_buff *skb, struct net_device *net) struct skb_data *entry; struct driver_info *info = dev->driver_info; unsigned long flags; -#ifdef CONFIG_USB_NET1080 - struct nc_header *header = NULL; - struct nc_trailer *trailer = NULL; -#endif /* CONFIG_USB_NET1080 */ // some devices want funky USB-level framing, for // win32 driver (usually) and/or hardware quirks @@ -2515,21 +1981,6 @@ static int usbnet_start_xmit (struct sk_buff *skb, struct net_device *net) entry->state = tx_start; entry->length = length; - // FIXME: reorganize a bit, so that fixup() fills out NetChip - // framing too. (Packet ID update needs the spinlock...) - // [ BETTER: we already own net->xmit_lock, that's enough ] - -#ifdef CONFIG_USB_NET1080 - if (info->flags & FLAG_FRAMING_NC) { - header = (struct nc_header *) skb_push (skb, sizeof *header); - header->hdr_len = cpu_to_le16 (sizeof (*header)); - header->packet_len = cpu_to_le16 (length); - if (!((skb->len + sizeof *trailer) & 0x01)) - *skb_put (skb, 1) = PAD_BYTE; - trailer = (struct nc_trailer *) skb_put (skb, sizeof *trailer); - } -#endif /* CONFIG_USB_NET1080 */ - usb_fill_bulk_urb (urb, dev->udev, dev->out, skb->data, skb->len, tx_complete, skb); @@ -2544,18 +1995,6 @@ static int usbnet_start_xmit (struct sk_buff *skb, struct net_device *net) spin_lock_irqsave (&dev->txq.lock, flags); -#ifdef CONFIG_USB_NET1080 - if (info->flags & FLAG_FRAMING_NC) { - header->packet_id = cpu_to_le16 ((u16)dev->xid++); - put_unaligned (header->packet_id, &trailer->packet_id); -#if 0 - devdbg (dev, "frame >tx h %d p %d id %d", - header->hdr_len, header->packet_len, - header->packet_id); -#endif - } -#endif /* CONFIG_USB_NET1080 */ - switch ((retval = usb_submit_urb (urb, GFP_ATOMIC))) { case -EPIPE: netif_stop_queue (net); @@ -2894,16 +2333,6 @@ static const struct usb_device_id products [] = { */ #endif -#ifdef CONFIG_USB_NET1080 -{ - USB_DEVICE (0x0525, 0x1080), // NetChip ref design - .driver_info = (unsigned long) &net1080_info, -}, { - USB_DEVICE (0x06D0, 0x0622), // Laplink Gold - .driver_info = (unsigned long) &net1080_info, -}, -#endif - #ifdef CONFIG_USB_PL2301 { USB_DEVICE (0x067b, 0x0000), // PL-2301 -- cgit v0.10.2 From 47ee3051c856cc2aa95d35d577a8cb37279d540f Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 31 Aug 2005 09:53:42 -0700 Subject: [PATCH] USB: usbnet (5/9) module for genesys gl620a cables This moves the GeneSys GL620USB-A support into its own driver file. It also fixes a "return wrong skb" glitch in the rx unbatching, as recently reported, and adds some missing byteswaps in the special "genelink" headers (so it might now work on big-endian Linux). Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig index 0aa8637..0aafd59 100644 --- a/drivers/usb/net/Kconfig +++ b/drivers/usb/net/Kconfig @@ -128,16 +128,6 @@ config USB_USBNET comment "USB Host-to-Host Cables" depends on USB_USBNET -config USB_GENESYS - boolean "GeneSys GL620USB-A based cables" - default y - depends on USB_USBNET - help - Choose this option if you're using a host-to-host cable, - or PC2PC motherboard, with this chip. - - Note that the half-duplex "GL620USB" is not supported. - config USB_PL2301 boolean "Prolific PL-2301/2302 based cables" default y @@ -224,6 +214,15 @@ config USB_NET_AX8817X what other networking devices you have in use. +config USB_NET_GL620A + tristate "GeneSys GL620USB-A based cables" + depends on USB_USBNET + help + Choose this option if you're using a host-to-host cable, + or PC2PC motherboard, with this chip. + + Note that the half-duplex "GL620USB" is not supported. + config USB_NET_NET1080 tristate "NetChip 1080 based cables (Laplink, ...)" default y diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile index 14d5540..f9b181e 100644 --- a/drivers/usb/net/Makefile +++ b/drivers/usb/net/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_USB_KAWETH) += kaweth.o obj-$(CONFIG_USB_PEGASUS) += pegasus.o obj-$(CONFIG_USB_RTL8150) += rtl8150.o obj-$(CONFIG_USB_NET_AX8817X) += asix.o +obj-$(CONFIG_USB_NET_GL620A) += gl620a.o obj-$(CONFIG_USB_NET_NET1080) += net1080.o obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o obj-$(CONFIG_USB_USBNET) += usbnet.o diff --git a/drivers/usb/net/gl620a.c b/drivers/usb/net/gl620a.c new file mode 100644 index 0000000..c8763ae --- /dev/null +++ b/drivers/usb/net/gl620a.c @@ -0,0 +1,407 @@ +/* + * GeneSys GL620USB-A based links + * Copyright (C) 2001 by Jiun-Jie Huang + * Copyright (C) 2001 by Stanislav Brabec + * + * 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 + */ + +// #define DEBUG // error path messages, extra info +// #define VERBOSE // more; success messages + +#include +#ifdef CONFIG_USB_DEBUG +# define DEBUG +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "usbnet.h" + + +/* + * GeneSys GL620USB-A (www.genesyslogic.com.tw) + * + * ... should partially interop with the Win32 driver for this hardware. + * The GeneSys docs imply there's some NDIS issue motivating this framing. + * + * Some info from GeneSys: + * - GL620USB-A is full duplex; GL620USB is only half duplex for bulk. + * (Some cables, like the BAFO-100c, use the half duplex version.) + * - For the full duplex model, the low bit of the version code says + * which side is which ("left/right"). + * - For the half duplex type, a control/interrupt handshake settles + * the transfer direction. (That's disabled here, partially coded.) + * A control URB would block until other side writes an interrupt. + * + * Original code from Jiun-Jie Huang + * and merged into "usbnet" by Stanislav Brabec . + */ + +// control msg write command +#define GENELINK_CONNECT_WRITE 0xF0 +// interrupt pipe index +#define GENELINK_INTERRUPT_PIPE 0x03 +// interrupt read buffer size +#define INTERRUPT_BUFSIZE 0x08 +// interrupt pipe interval value +#define GENELINK_INTERRUPT_INTERVAL 0x10 +// max transmit packet number per transmit +#define GL_MAX_TRANSMIT_PACKETS 32 +// max packet length +#define GL_MAX_PACKET_LEN 1514 +// max receive buffer size +#define GL_RCV_BUF_SIZE \ + (((GL_MAX_PACKET_LEN + 4) * GL_MAX_TRANSMIT_PACKETS) + 4) + +struct gl_packet { + u32 packet_length; + char packet_data [1]; +}; + +struct gl_header { + u32 packet_count; + struct gl_packet packets; +}; + +#ifdef GENELINK_ACK + +// FIXME: this code is incomplete, not debugged; it doesn't +// handle interrupts correctly; it should use the generic +// status IRQ code (which didn't exist back in 2001). + +struct gl_priv { + struct urb *irq_urb; + char irq_buf [INTERRUPT_BUFSIZE]; +}; + +static inline int gl_control_write(struct usbnet *dev, u8 request, u16 value) +{ + int retval; + + retval = usb_control_msg(dev->udev, + usb_sndctrlpipe(dev->udev, 0), + request, + USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, + value, + 0, // index + 0, // data buffer + 0, // size + USB_CTRL_SET_TIMEOUT); + return retval; +} + +static void gl_interrupt_complete(struct urb *urb, struct pt_regs *regs) +{ + int status = urb->status; + + switch (status) { + case 0: + /* success */ + break; + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + /* this urb is terminated, clean up */ + dbg("%s - urb shutting down with status: %d", + __FUNCTION__, status); + return; + default: + dbg("%s - nonzero urb status received: %d", + __FUNCTION__, urb->status); + } + + status = usb_submit_urb(urb, GFP_ATOMIC); + if (status) + err("%s - usb_submit_urb failed with result %d", + __FUNCTION__, status); +} + +static int gl_interrupt_read(struct usbnet *dev) +{ + struct gl_priv *priv = dev->priv_data; + int retval; + + // issue usb interrupt read + if (priv && priv->irq_urb) { + // submit urb + if ((retval = usb_submit_urb(priv->irq_urb, GFP_KERNEL)) != 0) + dbg("gl_interrupt_read: submit fail - %X...", retval); + else + dbg("gl_interrupt_read: submit success..."); + } + + return 0; +} + +// check whether another side is connected +static int genelink_check_connect(struct usbnet *dev) +{ + int retval; + + dbg("genelink_check_connect..."); + + // detect whether another side is connected + if ((retval = gl_control_write(dev, GENELINK_CONNECT_WRITE, 0)) != 0) { + dbg("%s: genelink_check_connect write fail - %X", + dev->net->name, retval); + return retval; + } + + // usb interrupt read to ack another side + if ((retval = gl_interrupt_read(dev)) != 0) { + dbg("%s: genelink_check_connect read fail - %X", + dev->net->name, retval); + return retval; + } + + dbg("%s: genelink_check_connect read success", dev->net->name); + return 0; +} + +// allocate and initialize the private data for genelink +static int genelink_init(struct usbnet *dev) +{ + struct gl_priv *priv; + + // allocate the private data structure + if ((priv = kmalloc(sizeof *priv, GFP_KERNEL)) == 0) { + dbg("%s: cannot allocate private data per device", + dev->net->name); + return -ENOMEM; + } + + // allocate irq urb + if ((priv->irq_urb = usb_alloc_urb(0, GFP_KERNEL)) == 0) { + dbg("%s: cannot allocate private irq urb per device", + dev->net->name); + kfree(priv); + return -ENOMEM; + } + + // fill irq urb + usb_fill_int_urb(priv->irq_urb, dev->udev, + usb_rcvintpipe(dev->udev, GENELINK_INTERRUPT_PIPE), + priv->irq_buf, INTERRUPT_BUFSIZE, + gl_interrupt_complete, 0, + GENELINK_INTERRUPT_INTERVAL); + + // set private data pointer + dev->priv_data = priv; + + return 0; +} + +// release the private data +static int genelink_free(struct usbnet *dev) +{ + struct gl_priv *priv = dev->priv_data; + + if (!priv) + return 0; + +// FIXME: can't cancel here; it's synchronous, and +// should have happened earlier in any case (interrupt +// handling needs to be generic) + + // cancel irq urb first + usb_kill_urb(priv->irq_urb); + + // free irq urb + usb_free_urb(priv->irq_urb); + + // free the private data structure + kfree(priv); + + return 0; +} + +#endif + +static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb) +{ + struct gl_header *header; + struct gl_packet *packet; + struct sk_buff *gl_skb; + u32 size; + + header = (struct gl_header *) skb->data; + + // get the packet count of the received skb + le32_to_cpus(&header->packet_count); + if ((header->packet_count > GL_MAX_TRANSMIT_PACKETS) + || (header->packet_count < 0)) { + dbg("genelink: invalid received packet count %d", + header->packet_count); + return 0; + } + + // set the current packet pointer to the first packet + packet = &header->packets; + + // decrement the length for the packet count size 4 bytes + skb_pull(skb, 4); + + while (header->packet_count > 1) { + // get the packet length + size = le32_to_cpu(packet->packet_length); + + // this may be a broken packet + if (size > GL_MAX_PACKET_LEN) { + dbg("genelink: invalid rx length %d", size); + return 0; + } + + // allocate the skb for the individual packet + gl_skb = alloc_skb(size, GFP_ATOMIC); + if (gl_skb) { + + // copy the packet data to the new skb + memcpy(skb_put(gl_skb, size), + packet->packet_data, size); + usbnet_skb_return(dev, gl_skb); + } + + // advance to the next packet + packet = (struct gl_packet *) + &packet->packet_data [size]; + header->packet_count--; + + // shift the data pointer to the next gl_packet + skb_pull(skb, size + 4); + } + + // skip the packet length field 4 bytes + skb_pull(skb, 4); + + if (skb->len > GL_MAX_PACKET_LEN) { + dbg("genelink: invalid rx length %d", skb->len); + return 0; + } + return 1; +} + +static struct sk_buff * +genelink_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) +{ + int padlen; + int length = skb->len; + int headroom = skb_headroom(skb); + int tailroom = skb_tailroom(skb); + u32 *packet_count; + u32 *packet_len; + + // FIXME: magic numbers, bleech + padlen = ((skb->len + (4 + 4*1)) % 64) ? 0 : 1; + + if ((!skb_cloned(skb)) + && ((headroom + tailroom) >= (padlen + (4 + 4*1)))) { + if ((headroom < (4 + 4*1)) || (tailroom < padlen)) { + skb->data = memmove(skb->head + (4 + 4*1), + skb->data, skb->len); + skb->tail = skb->data + skb->len; + } + } else { + struct sk_buff *skb2; + skb2 = skb_copy_expand(skb, (4 + 4*1) , padlen, flags); + dev_kfree_skb_any(skb); + skb = skb2; + if (!skb) + return NULL; + } + + // attach the packet count to the header + packet_count = (u32 *) skb_push(skb, (4 + 4*1)); + packet_len = packet_count + 1; + + *packet_count = cpu_to_le32(1); + *packet_len = cpu_to_le32(length); + + // add padding byte + if ((skb->len % dev->maxpacket) == 0) + skb_put(skb, 1); + + return skb; +} + +static int genelink_bind(struct usbnet *dev, struct usb_interface *intf) +{ + dev->hard_mtu = GL_RCV_BUF_SIZE; + dev->net->hard_header_len += 4; + dev->in = usb_rcvbulkpipe(dev->udev, dev->driver_info->in); + dev->out = usb_sndbulkpipe(dev->udev, dev->driver_info->out); + return 0; +} + +static const struct driver_info genelink_info = { + .description = "Genesys GeneLink", + .flags = FLAG_FRAMING_GL | FLAG_NO_SETINT, + .bind = genelink_bind, + .rx_fixup = genelink_rx_fixup, + .tx_fixup = genelink_tx_fixup, + + .in = 1, .out = 2, + +#ifdef GENELINK_ACK + .check_connect =genelink_check_connect, +#endif +}; + +static const struct usb_device_id products [] = { + +{ + USB_DEVICE(0x05e3, 0x0502), // GL620USB-A + .driver_info = (unsigned long) &genelink_info, +}, + /* NOT: USB_DEVICE(0x05e3, 0x0501), // GL620USB + * that's half duplex, not currently supported + */ + { }, // END +}; +MODULE_DEVICE_TABLE(usb, products); + +static struct usb_driver gl620a_driver = { + .owner = THIS_MODULE, + .name = "gl620a", + .id_table = products, + .probe = usbnet_probe, + .disconnect = usbnet_disconnect, + .suspend = usbnet_suspend, + .resume = usbnet_resume, +}; + +static int __init usbnet_init(void) +{ + return usb_register(&gl620a_driver); +} +module_init(usbnet_init); + +static void __exit usbnet_exit(void) +{ + usb_deregister(&gl620a_driver); +} +module_exit(usbnet_exit); + +MODULE_AUTHOR("Jiun-Jie Huang"); +MODULE_DESCRIPTION("GL620-USB-A Host-to-Host Link cables"); +MODULE_LICENSE("GPL"); + diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 590bf31..d52480a 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -156,9 +156,6 @@ // us (it polls at HZ/4 usually) before we report too many false errors. #define THROTTLE_JIFFIES (HZ/8) -// for vendor-specific control operations -#define CONTROL_TIMEOUT_MS USB_CTRL_GET_TIMEOUT - // between wakeups #define UNLINK_TIMEOUT_MS 3 @@ -690,341 +687,6 @@ static const struct driver_info cdc_info = { -#ifdef CONFIG_USB_GENESYS -#define HAVE_HARDWARE - -/*------------------------------------------------------------------------- - * - * GeneSys GL620USB-A (www.genesyslogic.com.tw) - * - * ... should partially interop with the Win32 driver for this hardware - * The GeneSys docs imply there's some NDIS issue motivating this framing. - * - * Some info from GeneSys: - * - GL620USB-A is full duplex; GL620USB is only half duplex for bulk. - * (Some cables, like the BAFO-100c, use the half duplex version.) - * - For the full duplex model, the low bit of the version code says - * which side is which ("left/right"). - * - For the half duplex type, a control/interrupt handshake settles - * the transfer direction. (That's disabled here, partially coded.) - * A control URB would block until other side writes an interrupt. - * - * Original code from Jiun-Jie Huang - * and merged into "usbnet" by Stanislav Brabec . - * - *-------------------------------------------------------------------------*/ - -// control msg write command -#define GENELINK_CONNECT_WRITE 0xF0 -// interrupt pipe index -#define GENELINK_INTERRUPT_PIPE 0x03 -// interrupt read buffer size -#define INTERRUPT_BUFSIZE 0x08 -// interrupt pipe interval value -#define GENELINK_INTERRUPT_INTERVAL 0x10 -// max transmit packet number per transmit -#define GL_MAX_TRANSMIT_PACKETS 32 -// max packet length -#define GL_MAX_PACKET_LEN 1514 -// max receive buffer size -#define GL_RCV_BUF_SIZE \ - (((GL_MAX_PACKET_LEN + 4) * GL_MAX_TRANSMIT_PACKETS) + 4) - -struct gl_packet { - u32 packet_length; - char packet_data [1]; -}; - -struct gl_header { - u32 packet_count; - struct gl_packet packets; -}; - -#ifdef GENELINK_ACK - -// FIXME: this code is incomplete, not debugged; it doesn't -// handle interrupts correctly. interrupts should be generic -// code like all other device I/O, anyway. - -struct gl_priv { - struct urb *irq_urb; - char irq_buf [INTERRUPT_BUFSIZE]; -}; - -static inline int gl_control_write (struct usbnet *dev, u8 request, u16 value) -{ - int retval; - - retval = usb_control_msg (dev->udev, - usb_sndctrlpipe (dev->udev, 0), - request, - USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, - value, - 0, // index - 0, // data buffer - 0, // size - CONTROL_TIMEOUT_MS); - return retval; -} - -static void gl_interrupt_complete (struct urb *urb, struct pt_regs *regs) -{ - int status = urb->status; - - switch (status) { - case 0: - /* success */ - break; - case -ECONNRESET: - case -ENOENT: - case -ESHUTDOWN: - /* this urb is terminated, clean up */ - dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); - return; - default: - dbg("%s - nonzero urb status received: %d", - __FUNCTION__, urb->status); - } - - status = usb_submit_urb (urb, GFP_ATOMIC); - if (status) - err ("%s - usb_submit_urb failed with result %d", - __FUNCTION__, status); -} - -static int gl_interrupt_read (struct usbnet *dev) -{ - struct gl_priv *priv = dev->priv_data; - int retval; - - // issue usb interrupt read - if (priv && priv->irq_urb) { - // submit urb - if ((retval = usb_submit_urb (priv->irq_urb, GFP_KERNEL)) != 0) - dbg ("gl_interrupt_read: submit fail - %X...", retval); - else - dbg ("gl_interrupt_read: submit success..."); - } - - return 0; -} - -// check whether another side is connected -static int genelink_check_connect (struct usbnet *dev) -{ - int retval; - - dbg ("genelink_check_connect..."); - - // detect whether another side is connected - if ((retval = gl_control_write (dev, GENELINK_CONNECT_WRITE, 0)) != 0) { - dbg ("%s: genelink_check_connect write fail - %X", - dev->net->name, retval); - return retval; - } - - // usb interrupt read to ack another side - if ((retval = gl_interrupt_read (dev)) != 0) { - dbg ("%s: genelink_check_connect read fail - %X", - dev->net->name, retval); - return retval; - } - - dbg ("%s: genelink_check_connect read success", dev->net->name); - return 0; -} - -// allocate and initialize the private data for genelink -static int genelink_init (struct usbnet *dev) -{ - struct gl_priv *priv; - - // allocate the private data structure - if ((priv = kmalloc (sizeof *priv, GFP_KERNEL)) == 0) { - dbg ("%s: cannot allocate private data per device", - dev->net->name); - return -ENOMEM; - } - - // allocate irq urb - if ((priv->irq_urb = usb_alloc_urb (0, GFP_KERNEL)) == 0) { - dbg ("%s: cannot allocate private irq urb per device", - dev->net->name); - kfree (priv); - return -ENOMEM; - } - - // fill irq urb - usb_fill_int_urb (priv->irq_urb, dev->udev, - usb_rcvintpipe (dev->udev, GENELINK_INTERRUPT_PIPE), - priv->irq_buf, INTERRUPT_BUFSIZE, - gl_interrupt_complete, 0, - GENELINK_INTERRUPT_INTERVAL); - - // set private data pointer - dev->priv_data = priv; - - return 0; -} - -// release the private data -static int genelink_free (struct usbnet *dev) -{ - struct gl_priv *priv = dev->priv_data; - - if (!priv) - return 0; - -// FIXME: can't cancel here; it's synchronous, and -// should have happened earlier in any case (interrupt -// handling needs to be generic) - - // cancel irq urb first - usb_kill_urb (priv->irq_urb); - - // free irq urb - usb_free_urb (priv->irq_urb); - - // free the private data structure - kfree (priv); - - return 0; -} - -#endif - -static int genelink_rx_fixup (struct usbnet *dev, struct sk_buff *skb) -{ - struct gl_header *header; - struct gl_packet *packet; - struct sk_buff *gl_skb; - u32 size; - - header = (struct gl_header *) skb->data; - - // get the packet count of the received skb - le32_to_cpus (&header->packet_count); - if ((header->packet_count > GL_MAX_TRANSMIT_PACKETS) - || (header->packet_count < 0)) { - dbg ("genelink: invalid received packet count %d", - header->packet_count); - return 0; - } - - // set the current packet pointer to the first packet - packet = &header->packets; - - // decrement the length for the packet count size 4 bytes - skb_pull (skb, 4); - - while (header->packet_count > 1) { - // get the packet length - size = packet->packet_length; - - // this may be a broken packet - if (size > GL_MAX_PACKET_LEN) { - dbg ("genelink: invalid rx length %d", size); - return 0; - } - - // allocate the skb for the individual packet - gl_skb = alloc_skb (size, GFP_ATOMIC); - if (gl_skb) { - - // copy the packet data to the new skb - memcpy(skb_put(gl_skb, size), packet->packet_data, size); - usbnet_skb_return (dev, gl_skb); - } - - // advance to the next packet - packet = (struct gl_packet *) - &packet->packet_data [size]; - header->packet_count--; - - // shift the data pointer to the next gl_packet - skb_pull (skb, size + 4); - } - - // skip the packet length field 4 bytes - skb_pull (skb, 4); - - if (skb->len > GL_MAX_PACKET_LEN) { - dbg ("genelink: invalid rx length %d", skb->len); - return 0; - } - return 1; -} - -static struct sk_buff * -genelink_tx_fixup (struct usbnet *dev, struct sk_buff *skb, unsigned flags) -{ - int padlen; - int length = skb->len; - int headroom = skb_headroom (skb); - int tailroom = skb_tailroom (skb); - u32 *packet_count; - u32 *packet_len; - - // FIXME: magic numbers, bleech - padlen = ((skb->len + (4 + 4*1)) % 64) ? 0 : 1; - - if ((!skb_cloned (skb)) - && ((headroom + tailroom) >= (padlen + (4 + 4*1)))) { - if ((headroom < (4 + 4*1)) || (tailroom < padlen)) { - skb->data = memmove (skb->head + (4 + 4*1), - skb->data, skb->len); - skb->tail = skb->data + skb->len; - } - } else { - struct sk_buff *skb2; - skb2 = skb_copy_expand (skb, (4 + 4*1) , padlen, flags); - dev_kfree_skb_any (skb); - skb = skb2; - if (!skb) - return NULL; - } - - // attach the packet count to the header - packet_count = (u32 *) skb_push (skb, (4 + 4*1)); - packet_len = packet_count + 1; - - // FIXME little endian? - *packet_count = 1; - *packet_len = length; - - // add padding byte - if ((skb->len % dev->maxpacket) == 0) - skb_put (skb, 1); - - return skb; -} - -static int genelink_bind (struct usbnet *dev, struct usb_interface *intf) -{ - dev->hard_mtu = GL_RCV_BUF_SIZE; - dev->net->hard_header_len += 4; - return 0; -} - -static const struct driver_info genelink_info = { - .description = "Genesys GeneLink", - .flags = FLAG_FRAMING_GL | FLAG_NO_SETINT, - .bind = genelink_bind, - .rx_fixup = genelink_rx_fixup, - .tx_fixup = genelink_tx_fixup, - - .in = 1, .out = 2, - -#ifdef GENELINK_ACK - .check_connect =genelink_check_connect, -#endif -}; - -#endif /* CONFIG_USB_GENESYS */ - - - #ifdef CONFIG_USB_PL2301 #define HAVE_HARDWARE @@ -1059,7 +721,7 @@ pl_vendor_req (struct usbnet *dev, u8 req, u8 val, u8 index) USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, val, index, NULL, 0, - CONTROL_TIMEOUT_MS); + USB_CTRL_GET_TIMEOUT); } static inline int @@ -2323,16 +1985,6 @@ EXPORT_SYMBOL_GPL(usbnet_resume); static const struct usb_device_id products [] = { -#ifdef CONFIG_USB_GENESYS -{ - USB_DEVICE (0x05e3, 0x0502), // GL620USB-A - .driver_info = (unsigned long) &genelink_info, -}, - /* NOT: USB_DEVICE (0x05e3, 0x0501), // GL620USB - * that's half duplex, not currently supported - */ -#endif - #ifdef CONFIG_USB_PL2301 { USB_DEVICE (0x067b, 0x0000), // PL-2301 -- cgit v0.10.2 From 0aa599c5644fddd3052433c5335260108a8a39a2 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 31 Aug 2005 09:53:58 -0700 Subject: [PATCH] USB: usbnet (6/9) module for Zaurii and compatibles This moves usbnet support for Zaurus and compatibles into its own module. Other than exporting a couple of helper functions, this just involved shuffling some code and updating the comments. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig index 0aafd59..20de109 100644 --- a/drivers/usb/net/Kconfig +++ b/drivers/usb/net/Kconfig @@ -140,23 +140,6 @@ config USB_PL2301 comment "Intelligent USB Devices/Gadgets" depends on USB_USBNET -config USB_ZAURUS - boolean "Sharp Zaurus (stock ROMs) and compatible" - depends on USB_USBNET - select CRC32 - default y - help - Choose this option to support the usb networking links used by - Zaurus models like the SL-5000D, SL-5500, SL-5600, A-300, B-500. - This also supports some related device firmware, as used in some - PDAs from Olympus and some cell phones from Motorola. - - If you install an alternate ROM image, such as the Linux 2.6 based - versions of OpenZaurus, you should no longer need to support this - protocol. Only the "eth-fd" or "net_fd" drivers in these devices - really need this non-conformant variant of CDC Ethernet (or in - some cases CDC MDLM) protocol, not "g_ether". - config USB_CDCETHER boolean "CDC Ethernet support (smart devices such as cable modems)" depends on USB_USBNET @@ -294,6 +277,23 @@ config USB_EPSON2888 Choose this option to support the usb networking links used by some sample firmware from Epson. +config USB_NET_ZAURUS + tristate "Sharp Zaurus (stock ROMs) and compatible" + depends on USB_USBNET + select CRC32 + default y + help + Choose this option to support the usb networking links used by + Zaurus models like the SL-5000D, SL-5500, SL-5600, A-300, B-500. + This also supports some related device firmware, as used in some + PDAs from Olympus and some cell phones from Motorola. + + If you install an alternate ROM image, such as the Linux 2.6 based + versions of OpenZaurus, you should no longer need to support this + protocol. Only the "eth-fd" or "net_fd" drivers in these devices + really need this non-conformant variant of CDC Ethernet (or in + some cases CDC MDLM) protocol, not "g_ether". + config USB_ZD1201 tristate "USB ZD1201 based Wireless device support" diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile index f9b181e..e13d7af 100644 --- a/drivers/usb/net/Makefile +++ b/drivers/usb/net/Makefile @@ -10,5 +10,6 @@ obj-$(CONFIG_USB_NET_AX8817X) += asix.o obj-$(CONFIG_USB_NET_GL620A) += gl620a.o obj-$(CONFIG_USB_NET_NET1080) += net1080.o obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o +obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o obj-$(CONFIG_USB_USBNET) += usbnet.o obj-$(CONFIG_USB_ZD1201) += zd1201.o diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index d52480a..75a05ab 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -1,7 +1,6 @@ /* * USB Networking Links * Copyright (C) 2000-2005 by David Brownell - * Copyright (C) 2002 Pavel Machek * Copyright (C) 2003-2005 David Hollis * * This program is free software; you can redistribute it and/or modify @@ -173,14 +172,6 @@ MODULE_PARM_DESC (msg_level, "Override default message level"); /*-------------------------------------------------------------------------*/ -static u32 usbnet_get_link (struct net_device *); - -/* mostly for PDA style devices, which are always connected if present */ -static int always_connected (struct usbnet *dev) -{ - return 0; -} - /* handles CDC Ethernet and many other network "bulk data" interfaces */ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf) { @@ -321,7 +312,7 @@ EXPORT_SYMBOL_GPL(usbnet_skb_return); #define NEED_GENERIC_CDC #endif -#ifdef CONFIG_USB_ZAURUS +#if defined(CONFIG_USB_ZAURUS) || defined(CONFIG_USB_ZAURUS_MODULE) /* Ethernet variant uses funky framing, broken ethernet addressing */ #define NEED_GENERIC_CDC #endif @@ -336,14 +327,6 @@ EXPORT_SYMBOL_GPL(usbnet_skb_return); #include -struct cdc_state { - struct usb_cdc_header_desc *header; - struct usb_cdc_union_desc *u; - struct usb_cdc_ether_desc *ether; - struct usb_interface *control; - struct usb_interface *data; -}; - static struct usb_driver usbnet_driver; /* @@ -351,7 +334,7 @@ static struct usb_driver usbnet_driver; * endpoints, activates data interface (if needed), maybe sets MTU. * all pure cdc, except for certain firmware workarounds. */ -static int generic_cdc_bind (struct usbnet *dev, struct usb_interface *intf) +int usbnet_generic_cdc_bind (struct usbnet *dev, struct usb_interface *intf) { u8 *buf = intf->cur_altsetting->extra; int len = intf->cur_altsetting->extralen; @@ -530,8 +513,9 @@ bad_desc: dev_info (&dev->udev->dev, "bad CDC descriptors\n"); return -ENODEV; } +EXPORT_SYMBOL_GPL(usbnet_generic_cdc_bind); -static void cdc_unbind (struct usbnet *dev, struct usb_interface *intf) +void usbnet_cdc_unbind (struct usbnet *dev, struct usb_interface *intf) { struct cdc_state *info = (void *) &dev->data; @@ -551,6 +535,7 @@ static void cdc_unbind (struct usbnet *dev, struct usb_interface *intf) info->control = NULL; } } +EXPORT_SYMBOL_GPL(usbnet_cdc_unbind); #endif /* NEED_GENERIC_CDC */ @@ -657,7 +642,7 @@ static int cdc_bind (struct usbnet *dev, struct usb_interface *intf) int status; struct cdc_state *info = (void *) &dev->data; - status = generic_cdc_bind (dev, intf); + status = usbnet_generic_cdc_bind (dev, intf); if (status < 0) return status; @@ -679,7 +664,7 @@ static const struct driver_info cdc_info = { .flags = FLAG_ETHER, // .check_connect = cdc_check_connect, .bind = cdc_bind, - .unbind = cdc_unbind, + .unbind = usbnet_cdc_unbind, .status = cdc_status, }; @@ -758,239 +743,6 @@ static const struct driver_info prolific_info = { #endif /* CONFIG_USB_PL2301 */ -#ifdef CONFIG_USB_ZAURUS -#define HAVE_HARDWARE - -#include - -/*------------------------------------------------------------------------- - * - * Zaurus is also a SA-1110 based PDA, but one using a different driver - * (and framing) for its USB slave/gadget controller than the case above. - * - * For the current version of that driver, the main way that framing is - * nonstandard (also from perspective of the CDC ethernet model!) is a - * crc32, added to help detect when some sa1100 usb-to-memory DMA errata - * haven't been fully worked around. Also, all Zaurii use the same - * default Ethernet address. - * - * PXA based models use the same framing, and also can't implement - * set_interface properly. - * - * All known Zaurii lie about their standards conformance. Most lie by - * saying they support CDC Ethernet. Some lie and say they support CDC - * MDLM (as if for access to cell phone modems). Someone, please beat - * on Sharp (and other such vendors) for a while with a cluestick. - * - *-------------------------------------------------------------------------*/ - -static struct sk_buff * -zaurus_tx_fixup (struct usbnet *dev, struct sk_buff *skb, unsigned flags) -{ - int padlen; - struct sk_buff *skb2; - - padlen = 2; - if (!skb_cloned (skb)) { - int tailroom = skb_tailroom (skb); - if ((padlen + 4) <= tailroom) - goto done; - } - skb2 = skb_copy_expand (skb, 0, 4 + padlen, flags); - dev_kfree_skb_any (skb); - skb = skb2; - if (skb) { - u32 fcs; -done: - fcs = crc32_le (~0, skb->data, skb->len); - fcs = ~fcs; - - *skb_put (skb, 1) = fcs & 0xff; - *skb_put (skb, 1) = (fcs>> 8) & 0xff; - *skb_put (skb, 1) = (fcs>>16) & 0xff; - *skb_put (skb, 1) = (fcs>>24) & 0xff; - } - return skb; -} - -static int zaurus_bind (struct usbnet *dev, struct usb_interface *intf) -{ - /* Belcarra's funky framing has other options; mostly - * TRAILERS (!) with 4 bytes CRC, and maybe 2 pad bytes. - */ - dev->net->hard_header_len += 6; - return generic_cdc_bind(dev, intf); -} - -static const struct driver_info zaurus_sl5x00_info = { - .description = "Sharp Zaurus SL-5x00", - .flags = FLAG_FRAMING_Z, - .check_connect = always_connected, - .bind = zaurus_bind, - .unbind = cdc_unbind, - .tx_fixup = zaurus_tx_fixup, -}; -#define ZAURUS_STRONGARM_INFO ((unsigned long)&zaurus_sl5x00_info) - -static const struct driver_info zaurus_pxa_info = { - .description = "Sharp Zaurus, PXA-2xx based", - .flags = FLAG_FRAMING_Z, - .check_connect = always_connected, - .bind = zaurus_bind, - .unbind = cdc_unbind, - .tx_fixup = zaurus_tx_fixup, -}; -#define ZAURUS_PXA_INFO ((unsigned long)&zaurus_pxa_info) - -static const struct driver_info olympus_mxl_info = { - .description = "Olympus R1000", - .flags = FLAG_FRAMING_Z, - .check_connect = always_connected, - .bind = zaurus_bind, - .unbind = cdc_unbind, - .tx_fixup = zaurus_tx_fixup, -}; -#define OLYMPUS_MXL_INFO ((unsigned long)&olympus_mxl_info) - - -/* Some more recent products using Lineo/Belcarra code will wrongly claim - * CDC MDLM conformance. They aren't conformant: data endpoints live - * in the control interface, there's no data interface, and it's not used - * to talk to a cell phone radio. But at least we can detect these two - * pseudo-classes, rather than growing this product list with entries for - * each new nonconformant product (sigh). - */ -static const u8 safe_guid[16] = { - 0x5d, 0x34, 0xcf, 0x66, 0x11, 0x18, 0x11, 0xd6, - 0xa2, 0x1a, 0x00, 0x01, 0x02, 0xca, 0x9a, 0x7f, -}; -static const u8 blan_guid[16] = { - 0x74, 0xf0, 0x3d, 0xbd, 0x1e, 0xc1, 0x44, 0x70, - 0xa3, 0x67, 0x71, 0x34, 0xc9, 0xf5, 0x54, 0x37, -}; - -static int blan_mdlm_bind (struct usbnet *dev, struct usb_interface *intf) -{ - u8 *buf = intf->cur_altsetting->extra; - int len = intf->cur_altsetting->extralen; - struct usb_cdc_mdlm_desc *desc = NULL; - struct usb_cdc_mdlm_detail_desc *detail = NULL; - - while (len > 3) { - if (buf [1] != USB_DT_CS_INTERFACE) - goto next_desc; - - /* use bDescriptorSubType, and just verify that we get a - * "BLAN" (or "SAFE") descriptor. - */ - switch (buf [2]) { - case USB_CDC_MDLM_TYPE: - if (desc) { - dev_dbg (&intf->dev, "extra MDLM\n"); - goto bad_desc; - } - desc = (void *) buf; - if (desc->bLength != sizeof *desc) { - dev_dbg (&intf->dev, "MDLM len %u\n", - desc->bLength); - goto bad_desc; - } - /* expect bcdVersion 1.0, ignore */ - if (memcmp(&desc->bGUID, blan_guid, 16) - && memcmp(&desc->bGUID, safe_guid, 16) ) { - /* hey, this one might _really_ be MDLM! */ - dev_dbg (&intf->dev, "MDLM guid\n"); - goto bad_desc; - } - break; - case USB_CDC_MDLM_DETAIL_TYPE: - if (detail) { - dev_dbg (&intf->dev, "extra MDLM detail\n"); - goto bad_desc; - } - detail = (void *) buf; - switch (detail->bGuidDescriptorType) { - case 0: /* "SAFE" */ - if (detail->bLength != (sizeof *detail + 2)) - goto bad_detail; - break; - case 1: /* "BLAN" */ - if (detail->bLength != (sizeof *detail + 3)) - goto bad_detail; - break; - default: - goto bad_detail; - } - - /* assuming we either noticed BLAN already, or will - * find it soon, there are some data bytes here: - * - bmNetworkCapabilities (unused) - * - bmDataCapabilities (bits, see below) - * - bPad (ignored, for PADAFTER -- BLAN-only) - * bits are: - * - 0x01 -- Zaurus framing (add CRC) - * - 0x02 -- PADBEFORE (CRC includes some padding) - * - 0x04 -- PADAFTER (some padding after CRC) - * - 0x08 -- "fermat" packet mangling (for hw bugs) - * the PADBEFORE appears not to matter; we interop - * with devices that use it and those that don't. - */ - if ((detail->bDetailData[1] & ~02) != 0x01) { - /* bmDataCapabilites == 0 would be fine too, - * but framing is minidriver-coupled for now. - */ -bad_detail: - dev_dbg (&intf->dev, - "bad MDLM detail, %d %d %d\n", - detail->bLength, - detail->bDetailData[0], - detail->bDetailData[2]); - goto bad_desc; - } - break; - } -next_desc: - len -= buf [0]; /* bLength */ - buf += buf [0]; - } - - if (!desc || !detail) { - dev_dbg (&intf->dev, "missing cdc mdlm %s%sdescriptor\n", - desc ? "" : "func ", - detail ? "" : "detail "); - goto bad_desc; - } - - /* There's probably a CDC Ethernet descriptor there, but we can't - * rely on the Ethernet address it provides since not all vendors - * bother to make it unique. Likewise there's no point in tracking - * of the CDC event notifications. - */ - return usbnet_get_endpoints (dev, intf); - -bad_desc: - dev_info (&dev->udev->dev, "unsupported MDLM descriptors\n"); - return -ENODEV; -} - -static const struct driver_info bogus_mdlm_info = { - .description = "pseudo-MDLM (BLAN) device", - .flags = FLAG_FRAMING_Z, - .check_connect = always_connected, - .tx_fixup = zaurus_tx_fixup, - .bind = blan_mdlm_bind, -}; - -#else - -/* blacklist all those devices */ -#define ZAURUS_STRONGARM_INFO 0 -#define ZAURUS_PXA_INFO 0 -#define OLYMPUS_MXL_INFO 0 - -#endif - - /*------------------------------------------------------------------------- * * Network Device Driver (peer link to "Host Device", from USB host) @@ -2003,101 +1755,6 @@ static const struct usb_device_id products [] = { }, #endif -#if defined(CONFIG_USB_ZAURUS) || defined(CONFIG_USB_CDCETHER) -/* - * SA-1100 based Sharp Zaurus ("collie"), or compatible. - * Same idea as above, but different framing. - * - * PXA-2xx based models are also lying-about-cdc. - * Some models don't even tell the same lies ... - * - * NOTE: OpenZaurus versions with 2.6 kernels won't use these entries, - * unlike the older ones with 2.4 "embedix" kernels. - * - * NOTE: These entries do double-duty, serving as blacklist entries - * whenever Zaurus support isn't enabled, but CDC Ethernet is. - */ -#define ZAURUS_MASTER_INTERFACE \ - .bInterfaceClass = USB_CLASS_COMM, \ - .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \ - .bInterfaceProtocol = USB_CDC_PROTO_NONE -{ - .match_flags = USB_DEVICE_ID_MATCH_INT_INFO - | USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x04DD, - .idProduct = 0x8004, - ZAURUS_MASTER_INTERFACE, - .driver_info = ZAURUS_STRONGARM_INFO, -}, { - .match_flags = USB_DEVICE_ID_MATCH_INT_INFO - | USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x04DD, - .idProduct = 0x8005, /* A-300 */ - ZAURUS_MASTER_INTERFACE, - .driver_info = ZAURUS_PXA_INFO, -}, { - .match_flags = USB_DEVICE_ID_MATCH_INT_INFO - | USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x04DD, - .idProduct = 0x8006, /* B-500/SL-5600 */ - ZAURUS_MASTER_INTERFACE, - .driver_info = ZAURUS_PXA_INFO, -}, { - .match_flags = USB_DEVICE_ID_MATCH_INT_INFO - | USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x04DD, - .idProduct = 0x8007, /* C-700 */ - ZAURUS_MASTER_INTERFACE, - .driver_info = ZAURUS_PXA_INFO, -}, { - .match_flags = USB_DEVICE_ID_MATCH_INT_INFO - | USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x04DD, - .idProduct = 0x9031, /* C-750 C-760 */ - ZAURUS_MASTER_INTERFACE, - .driver_info = ZAURUS_PXA_INFO, -}, { - .match_flags = USB_DEVICE_ID_MATCH_INT_INFO - | USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x04DD, - .idProduct = 0x9032, /* SL-6000 */ - ZAURUS_MASTER_INTERFACE, - .driver_info = ZAURUS_PXA_INFO, -}, { - .match_flags = USB_DEVICE_ID_MATCH_INT_INFO - | USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x04DD, - /* reported with some C860 units */ - .idProduct = 0x9050, /* C-860 */ - ZAURUS_MASTER_INTERFACE, - .driver_info = ZAURUS_PXA_INFO, -}, - -#ifdef CONFIG_USB_ZAURUS - /* At least some (reports vary) PXA units have very different lies - * about their standards support: they claim to be cell phones with - * direct access to their radios. (They don't conform to CDC MDLM.) - */ -{ - USB_INTERFACE_INFO (USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM, - USB_CDC_PROTO_NONE), - .driver_info = (unsigned long) &bogus_mdlm_info, -}, -#endif - -/* Olympus has some models with a Zaurus-compatible option. - * R-1000 uses a FreeScale i.MXL cpu (ARMv4T) - */ -{ - .match_flags = USB_DEVICE_ID_MATCH_INT_INFO - | USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x07B4, - .idProduct = 0x0F02, /* R-1000 */ - ZAURUS_MASTER_INTERFACE, - .driver_info = OLYMPUS_MXL_INFO, -}, -#endif - #ifdef CONFIG_USB_CDCETHER { /* CDC Ether uses two interfaces, not necessarily consecutive. diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h index 21b5feb..7aa0abd 100644 --- a/drivers/usb/net/usbnet.h +++ b/drivers/usb/net/usbnet.h @@ -126,6 +126,28 @@ extern int usbnet_resume (struct usb_interface *); extern void usbnet_disconnect(struct usb_interface *); +/* Drivers that reuse some of the standard USB CDC infrastructure + * (notably, using multiple interfaces according to the the CDC + * union descriptor) get some helper code. + */ +struct cdc_state { + struct usb_cdc_header_desc *header; + struct usb_cdc_union_desc *u; + struct usb_cdc_ether_desc *ether; + struct usb_interface *control; + struct usb_interface *data; +}; + +extern int usbnet_generic_cdc_bind (struct usbnet *, struct usb_interface *); +extern void usbnet_cdc_unbind (struct usbnet *, struct usb_interface *); + +/* CDC and RNDIS support the same host-chosen packet filters for IN transfers */ +#define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \ + |USB_CDC_PACKET_TYPE_ALL_MULTICAST \ + |USB_CDC_PACKET_TYPE_PROMISCUOUS \ + |USB_CDC_PACKET_TYPE_DIRECTED) + + /* we record the state for each of our queued skbs */ enum skb_state { illegal = 0, diff --git a/drivers/usb/net/zaurus.c b/drivers/usb/net/zaurus.c new file mode 100644 index 0000000..ee3b892 --- /dev/null +++ b/drivers/usb/net/zaurus.c @@ -0,0 +1,386 @@ +/* + * Copyright (C) 2002 Pavel Machek + * Copyright (C) 2002-2005 by David Brownell + * + * 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 + */ + +// #define DEBUG // error path messages, extra info +// #define VERBOSE // more; success messages + +#include +#ifdef CONFIG_USB_DEBUG +# define DEBUG +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "usbnet.h" + + +/* + * All known Zaurii lie about their standards conformance. At least + * the earliest SA-1100 models lie by saying they support CDC Ethernet. + * Some later models (especially PXA-25x and PXA-27x based ones) lie + * and say they support CDC MDLM (for access to cell phone modems). + * + * There are non-Zaurus products that use these same protocols too. + * + * The annoying thing is that at the same time Sharp was developing + * that annoying standards-breaking software, the Linux community had + * a simple "CDC Subset" working reliably on the same SA-1100 hardware. + * That is, the same functionality but not violating standards. + * + * The CDC Ethernet nonconformance points are troublesome to hosts + * with a true CDC Ethernet implementation: + * - Framing appends a CRC, which the spec says drivers "must not" do; + * - Transfers data in altsetting zero, instead of altsetting 1; + * - All these peripherals use the same ethernet address. + * + * The CDC MDLM nonconformance is less immediately troublesome, since all + * MDLM implementations are quasi-proprietary anyway. + */ + +static struct sk_buff * +zaurus_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) +{ + int padlen; + struct sk_buff *skb2; + + padlen = 2; + if (!skb_cloned(skb)) { + int tailroom = skb_tailroom(skb); + if ((padlen + 4) <= tailroom) + goto done; + } + skb2 = skb_copy_expand(skb, 0, 4 + padlen, flags); + dev_kfree_skb_any(skb); + skb = skb2; + if (skb) { + u32 fcs; +done: + fcs = crc32_le(~0, skb->data, skb->len); + fcs = ~fcs; + + *skb_put (skb, 1) = fcs & 0xff; + *skb_put (skb, 1) = (fcs>> 8) & 0xff; + *skb_put (skb, 1) = (fcs>>16) & 0xff; + *skb_put (skb, 1) = (fcs>>24) & 0xff; + } + return skb; +} + +static int zaurus_bind(struct usbnet *dev, struct usb_interface *intf) +{ + /* Belcarra's funky framing has other options; mostly + * TRAILERS (!) with 4 bytes CRC, and maybe 2 pad bytes. + */ + dev->net->hard_header_len += 6; + dev->rx_urb_size = dev->net->hard_header_len + dev->net->mtu; + return usbnet_generic_cdc_bind(dev, intf); +} + +/* PDA style devices are always connected if present */ +static int always_connected (struct usbnet *dev) +{ + return 0; +} + +static const struct driver_info zaurus_sl5x00_info = { + .description = "Sharp Zaurus SL-5x00", + .flags = FLAG_FRAMING_Z, + .check_connect = always_connected, + .bind = zaurus_bind, + .unbind = usbnet_cdc_unbind, + .tx_fixup = zaurus_tx_fixup, +}; +#define ZAURUS_STRONGARM_INFO ((unsigned long)&zaurus_sl5x00_info) + +static const struct driver_info zaurus_pxa_info = { + .description = "Sharp Zaurus, PXA-2xx based", + .flags = FLAG_FRAMING_Z, + .check_connect = always_connected, + .bind = zaurus_bind, + .unbind = usbnet_cdc_unbind, + .tx_fixup = zaurus_tx_fixup, +}; +#define ZAURUS_PXA_INFO ((unsigned long)&zaurus_pxa_info) + +static const struct driver_info olympus_mxl_info = { + .description = "Olympus R1000", + .flags = FLAG_FRAMING_Z, + .check_connect = always_connected, + .bind = zaurus_bind, + .unbind = usbnet_cdc_unbind, + .tx_fixup = zaurus_tx_fixup, +}; +#define OLYMPUS_MXL_INFO ((unsigned long)&olympus_mxl_info) + + +/* Some more recent products using Lineo/Belcarra code will wrongly claim + * CDC MDLM conformance. They aren't conformant: data endpoints live + * in the control interface, there's no data interface, and it's not used + * to talk to a cell phone radio. But at least we can detect these two + * pseudo-classes, rather than growing this product list with entries for + * each new nonconformant product (sigh). + */ +static const u8 safe_guid[16] = { + 0x5d, 0x34, 0xcf, 0x66, 0x11, 0x18, 0x11, 0xd6, + 0xa2, 0x1a, 0x00, 0x01, 0x02, 0xca, 0x9a, 0x7f, +}; +static const u8 blan_guid[16] = { + 0x74, 0xf0, 0x3d, 0xbd, 0x1e, 0xc1, 0x44, 0x70, + 0xa3, 0x67, 0x71, 0x34, 0xc9, 0xf5, 0x54, 0x37, +}; + +static int blan_mdlm_bind(struct usbnet *dev, struct usb_interface *intf) +{ + u8 *buf = intf->cur_altsetting->extra; + int len = intf->cur_altsetting->extralen; + struct usb_cdc_mdlm_desc *desc = NULL; + struct usb_cdc_mdlm_detail_desc *detail = NULL; + + while (len > 3) { + if (buf [1] != USB_DT_CS_INTERFACE) + goto next_desc; + + /* use bDescriptorSubType, and just verify that we get a + * "BLAN" (or "SAFE") descriptor. + */ + switch (buf [2]) { + case USB_CDC_MDLM_TYPE: + if (desc) { + dev_dbg(&intf->dev, "extra MDLM\n"); + goto bad_desc; + } + desc = (void *) buf; + if (desc->bLength != sizeof *desc) { + dev_dbg(&intf->dev, "MDLM len %u\n", + desc->bLength); + goto bad_desc; + } + /* expect bcdVersion 1.0, ignore */ + if (memcmp(&desc->bGUID, blan_guid, 16) + && memcmp(&desc->bGUID, safe_guid, 16) ) { + /* hey, this one might _really_ be MDLM! */ + dev_dbg(&intf->dev, "MDLM guid\n"); + goto bad_desc; + } + break; + case USB_CDC_MDLM_DETAIL_TYPE: + if (detail) { + dev_dbg(&intf->dev, "extra MDLM detail\n"); + goto bad_desc; + } + detail = (void *) buf; + switch (detail->bGuidDescriptorType) { + case 0: /* "SAFE" */ + if (detail->bLength != (sizeof *detail + 2)) + goto bad_detail; + break; + case 1: /* "BLAN" */ + if (detail->bLength != (sizeof *detail + 3)) + goto bad_detail; + break; + default: + goto bad_detail; + } + + /* assuming we either noticed BLAN already, or will + * find it soon, there are some data bytes here: + * - bmNetworkCapabilities (unused) + * - bmDataCapabilities (bits, see below) + * - bPad (ignored, for PADAFTER -- BLAN-only) + * bits are: + * - 0x01 -- Zaurus framing (add CRC) + * - 0x02 -- PADBEFORE (CRC includes some padding) + * - 0x04 -- PADAFTER (some padding after CRC) + * - 0x08 -- "fermat" packet mangling (for hw bugs) + * the PADBEFORE appears not to matter; we interop + * with devices that use it and those that don't. + */ + if ((detail->bDetailData[1] & ~0x02) != 0x01) { + /* bmDataCapabilites == 0 would be fine too, + * but framing is minidriver-coupled for now. + */ +bad_detail: + dev_dbg(&intf->dev, + "bad MDLM detail, %d %d %d\n", + detail->bLength, + detail->bDetailData[0], + detail->bDetailData[2]); + goto bad_desc; + } + break; + } +next_desc: + len -= buf [0]; /* bLength */ + buf += buf [0]; + } + + if (!desc || !detail) { + dev_dbg(&intf->dev, "missing cdc mdlm %s%sdescriptor\n", + desc ? "" : "func ", + detail ? "" : "detail "); + goto bad_desc; + } + + /* There's probably a CDC Ethernet descriptor there, but we can't + * rely on the Ethernet address it provides since not all vendors + * bother to make it unique. Likewise there's no point in tracking + * of the CDC event notifications. + */ + return usbnet_get_endpoints(dev, intf); + +bad_desc: + dev_info(&dev->udev->dev, "unsupported MDLM descriptors\n"); + return -ENODEV; +} + +static const struct driver_info bogus_mdlm_info = { + .description = "pseudo-MDLM (BLAN) device", + .flags = FLAG_FRAMING_Z, + .check_connect = always_connected, + .tx_fixup = zaurus_tx_fixup, + .bind = blan_mdlm_bind, +}; + +static const struct usb_device_id products [] = { +#define ZAURUS_MASTER_INTERFACE \ + .bInterfaceClass = USB_CLASS_COMM, \ + .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \ + .bInterfaceProtocol = USB_CDC_PROTO_NONE + +/* SA-1100 based Sharp Zaurus ("collie"), or compatible. */ +{ + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + .idProduct = 0x8004, + ZAURUS_MASTER_INTERFACE, + .driver_info = ZAURUS_STRONGARM_INFO, +}, + +/* PXA-2xx based models are also lying-about-cdc. If you add any + * more devices that claim to be CDC Ethernet, make sure they get + * added to the blacklist in cdc_ether too. + * + * NOTE: OpenZaurus versions with 2.6 kernels won't use these entries, + * unlike the older ones with 2.4 "embedix" kernels. + */ +{ + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + .idProduct = 0x8005, /* A-300 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = ZAURUS_PXA_INFO, +}, { + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + .idProduct = 0x8006, /* B-500/SL-5600 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = ZAURUS_PXA_INFO, +}, { + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + .idProduct = 0x8007, /* C-700 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = ZAURUS_PXA_INFO, +}, { + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + .idProduct = 0x9031, /* C-750 C-760 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = ZAURUS_PXA_INFO, +}, { + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + .idProduct = 0x9032, /* SL-6000 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = ZAURUS_PXA_INFO, +}, { + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + /* reported with some C860 units */ + .idProduct = 0x9050, /* C-860 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = ZAURUS_PXA_INFO, +}, + + +/* At least some of the newest PXA units have very different lies about + * their standards support: they claim to be cell phones offering + * direct access to their radios! (No, they don't conform to CDC MDLM.) + */ +{ + USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM, + USB_CDC_PROTO_NONE), + .driver_info = (unsigned long) &bogus_mdlm_info, +}, + +/* Olympus has some models with a Zaurus-compatible option. + * R-1000 uses a FreeScale i.MXL cpu (ARMv4T) + */ +{ + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x07B4, + .idProduct = 0x0F02, /* R-1000 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = OLYMPUS_MXL_INFO, +}, + { }, // END +}; +MODULE_DEVICE_TABLE(usb, products); + +static struct usb_driver zaurus_driver = { + .owner = THIS_MODULE, + .name = "zaurus", + .id_table = products, + .probe = usbnet_probe, + .disconnect = usbnet_disconnect, + .suspend = usbnet_suspend, + .resume = usbnet_resume, +}; + +static int __init zaurus_init(void) +{ + return usb_register(&zaurus_driver); +} +module_init(zaurus_init); + +static void __exit zaurus_exit(void) +{ + usb_deregister(&zaurus_driver); +} +module_exit(zaurus_exit); + +MODULE_AUTHOR("Pavel Machek, David Brownell"); +MODULE_DESCRIPTION("Sharp Zaurus PDA, and compatible products"); +MODULE_LICENSE("GPL"); -- cgit v0.10.2 From 4324fd493430c0ab99dd7e89d50540b5e70f8098 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 31 Aug 2005 09:54:20 -0700 Subject: [PATCH] USB: usbnet (7/9) module for CDC Ethernet Makes the CDC Ethernet support live in a separate driver module. This module is a bit special since it exports utility functions that are reused by the the Zaurus and RNDIS drivers, but it's not "core" like usbnet itself. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig index 20de109..4921101 100644 --- a/drivers/usb/net/Kconfig +++ b/drivers/usb/net/Kconfig @@ -137,35 +137,6 @@ config USB_PL2301 Choose this option if you're using a host-to-host cable with one of these chips. -comment "Intelligent USB Devices/Gadgets" - depends on USB_USBNET - -config USB_CDCETHER - boolean "CDC Ethernet support (smart devices such as cable modems)" - depends on USB_USBNET - default y - help - This option supports devices conforming to the Communication Device - Class (CDC) Ethernet Control Model, a specification that's easy to - implement in device firmware. The CDC specifications are available - from . - - CDC Ethernet is an implementation option for DOCSIS cable modems - that support USB connectivity, used for non-Microsoft USB hosts. - The Linux-USB CDC Ethernet Gadget driver is an open implementation. - This driver should work with at least the following devices: - - * Ericsson PipeRider (all variants) - * Motorola (DM100 and SB4100) - * Broadcom Cable Modem (reference design) - * Toshiba PCX1100U - * ... - - This driver creates an interface named "ethX", where X depends on - what other networking devices you have in use. However, if the - IEEE 802 "local assignment" bit is set in the address, a "usbX" - name is used instead. - comment "Drivers built using the usbnet core" config USB_NET_AX8817X @@ -197,6 +168,32 @@ config USB_NET_AX8817X what other networking devices you have in use. +config USB_NET_CDCETHER + tristate "CDC Ethernet support (smart devices such as cable modems)" + depends on USB_USBNET + default y + help + This option supports devices conforming to the Communication Device + Class (CDC) Ethernet Control Model, a specification that's easy to + implement in device firmware. The CDC specifications are available + from . + + CDC Ethernet is an implementation option for DOCSIS cable modems + that support USB connectivity, used for non-Microsoft USB hosts. + The Linux-USB CDC Ethernet Gadget driver is an open implementation. + This driver should work with at least the following devices: + + * Ericsson PipeRider (all variants) + * Motorola (DM100 and SB4100) + * Broadcom Cable Modem (reference design) + * Toshiba PCX1100U + * ... + + This driver creates an interface named "ethX", where X depends on + what other networking devices you have in use. However, if the + IEEE 802 "local assignment" bit is set in the address, a "usbX" + name is used instead. + config USB_NET_GL620A tristate "GeneSys GL620USB-A based cables" depends on USB_USBNET @@ -280,6 +277,7 @@ config USB_EPSON2888 config USB_NET_ZAURUS tristate "Sharp Zaurus (stock ROMs) and compatible" depends on USB_USBNET + select USB_NET_CDCETHER select CRC32 default y help diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile index e13d7af..697eb19 100644 --- a/drivers/usb/net/Makefile +++ b/drivers/usb/net/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_USB_KAWETH) += kaweth.o obj-$(CONFIG_USB_PEGASUS) += pegasus.o obj-$(CONFIG_USB_RTL8150) += rtl8150.o obj-$(CONFIG_USB_NET_AX8817X) += asix.o +obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o obj-$(CONFIG_USB_NET_GL620A) += gl620a.o obj-$(CONFIG_USB_NET_NET1080) += net1080.o obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c new file mode 100644 index 0000000..652b04b --- /dev/null +++ b/drivers/usb/net/cdc_ether.c @@ -0,0 +1,509 @@ +/* + * CDC Ethernet based networking peripherals + * Copyright (C) 2003-2005 by David Brownell + * + * 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 + */ + +// #define DEBUG // error path messages, extra info +// #define VERBOSE // more; success messages + +#include +#ifdef CONFIG_USB_DEBUG +# define DEBUG +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "usbnet.h" + + +/* + * probes control interface, claims data interface, collects the bulk + * endpoints, activates data interface (if needed), maybe sets MTU. + * all pure cdc, except for certain firmware workarounds, and knowing + * that rndis uses one different rule. + */ +int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) +{ + u8 *buf = intf->cur_altsetting->extra; + int len = intf->cur_altsetting->extralen; + struct usb_interface_descriptor *d; + struct cdc_state *info = (void *) &dev->data; + int status; + int rndis; + struct usb_driver *driver = driver_of(intf); + + if (sizeof dev->data < sizeof *info) + return -EDOM; + + /* expect strict spec conformance for the descriptors, but + * cope with firmware which stores them in the wrong place + */ + if (len == 0 && dev->udev->actconfig->extralen) { + /* Motorola SB4100 (and others: Brad Hards says it's + * from a Broadcom design) put CDC descriptors here + */ + buf = dev->udev->actconfig->extra; + len = dev->udev->actconfig->extralen; + if (len) + dev_dbg(&intf->dev, + "CDC descriptors on config\n"); + } + + /* this assumes that if there's a non-RNDIS vendor variant + * of cdc-acm, it'll fail RNDIS requests cleanly. + */ + rndis = (intf->cur_altsetting->desc.bInterfaceProtocol == 0xff); + + memset(info, 0, sizeof *info); + info->control = intf; + while (len > 3) { + if (buf [1] != USB_DT_CS_INTERFACE) + goto next_desc; + + /* use bDescriptorSubType to identify the CDC descriptors. + * We expect devices with CDC header and union descriptors. + * For CDC Ethernet we need the ethernet descriptor. + * For RNDIS, ignore two (pointless) CDC modem descriptors + * in favor of a complicated OID-based RPC scheme doing what + * CDC Ethernet achieves with a simple descriptor. + */ + switch (buf [2]) { + case USB_CDC_HEADER_TYPE: + if (info->header) { + dev_dbg(&intf->dev, "extra CDC header\n"); + goto bad_desc; + } + info->header = (void *) buf; + if (info->header->bLength != sizeof *info->header) { + dev_dbg(&intf->dev, "CDC header len %u\n", + info->header->bLength); + goto bad_desc; + } + break; + case USB_CDC_UNION_TYPE: + if (info->u) { + dev_dbg(&intf->dev, "extra CDC union\n"); + goto bad_desc; + } + info->u = (void *) buf; + if (info->u->bLength != sizeof *info->u) { + dev_dbg(&intf->dev, "CDC union len %u\n", + info->u->bLength); + goto bad_desc; + } + + /* we need a master/control interface (what we're + * probed with) and a slave/data interface; union + * descriptors sort this all out. + */ + info->control = usb_ifnum_to_if(dev->udev, + info->u->bMasterInterface0); + info->data = usb_ifnum_to_if(dev->udev, + info->u->bSlaveInterface0); + if (!info->control || !info->data) { + dev_dbg(&intf->dev, + "master #%u/%p slave #%u/%p\n", + info->u->bMasterInterface0, + info->control, + info->u->bSlaveInterface0, + info->data); + goto bad_desc; + } + if (info->control != intf) { + dev_dbg(&intf->dev, "bogus CDC Union\n"); + /* Ambit USB Cable Modem (and maybe others) + * interchanges master and slave interface. + */ + if (info->data == intf) { + info->data = info->control; + info->control = intf; + } else + goto bad_desc; + } + + /* a data interface altsetting does the real i/o */ + d = &info->data->cur_altsetting->desc; + if (d->bInterfaceClass != USB_CLASS_CDC_DATA) { + dev_dbg(&intf->dev, "slave class %u\n", + d->bInterfaceClass); + goto bad_desc; + } + break; + case USB_CDC_ETHERNET_TYPE: + if (info->ether) { + dev_dbg(&intf->dev, "extra CDC ether\n"); + goto bad_desc; + } + info->ether = (void *) buf; + if (info->ether->bLength != sizeof *info->ether) { + dev_dbg(&intf->dev, "CDC ether len %u\n", + info->ether->bLength); + goto bad_desc; + } + dev->hard_mtu = le16_to_cpu( + info->ether->wMaxSegmentSize); + /* because of Zaurus, we may be ignoring the host + * side link address we were given. + */ + break; + } +next_desc: + len -= buf [0]; /* bLength */ + buf += buf [0]; + } + + if (!info->header || !info->u || (!rndis && !info->ether)) { + dev_dbg(&intf->dev, "missing cdc %s%s%sdescriptor\n", + info->header ? "" : "header ", + info->u ? "" : "union ", + info->ether ? "" : "ether "); + goto bad_desc; + } + + /* claim data interface and set it up ... with side effects. + * network traffic can't flow until an altsetting is enabled. + */ + status = usb_driver_claim_interface(driver, info->data, dev); + if (status < 0) + return status; + status = usbnet_get_endpoints(dev, info->data); + if (status < 0) { + /* ensure immediate exit from usbnet_disconnect */ + usb_set_intfdata(info->data, NULL); + usb_driver_release_interface(driver, info->data); + return status; + } + + /* status endpoint: optional for CDC Ethernet, not RNDIS (or ACM) */ + dev->status = NULL; + if (info->control->cur_altsetting->desc.bNumEndpoints == 1) { + struct usb_endpoint_descriptor *desc; + + dev->status = &info->control->cur_altsetting->endpoint [0]; + desc = &dev->status->desc; + if (desc->bmAttributes != USB_ENDPOINT_XFER_INT + || !(desc->bEndpointAddress & USB_DIR_IN) + || (le16_to_cpu(desc->wMaxPacketSize) + < sizeof(struct usb_cdc_notification)) + || !desc->bInterval) { + dev_dbg(&intf->dev, "bad notification endpoint\n"); + dev->status = NULL; + } + } + if (rndis && !dev->status) { + dev_dbg(&intf->dev, "missing RNDIS status endpoint\n"); + usb_set_intfdata(info->data, NULL); + usb_driver_release_interface(driver, info->data); + return -ENODEV; + } + return 0; + +bad_desc: + dev_info(&dev->udev->dev, "bad CDC descriptors\n"); + return -ENODEV; +} +EXPORT_SYMBOL_GPL(usbnet_generic_cdc_bind); + +void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf) +{ + struct cdc_state *info = (void *) &dev->data; + struct usb_driver *driver = driver_of(intf); + + /* disconnect master --> disconnect slave */ + if (intf == info->control && info->data) { + /* ensure immediate exit from usbnet_disconnect */ + usb_set_intfdata(info->data, NULL); + usb_driver_release_interface(driver, info->data); + info->data = NULL; + } + + /* and vice versa (just in case) */ + else if (intf == info->data && info->control) { + /* ensure immediate exit from usbnet_disconnect */ + usb_set_intfdata(info->control, NULL); + usb_driver_release_interface(driver, info->control); + info->control = NULL; + } +} +EXPORT_SYMBOL_GPL(usbnet_cdc_unbind); + + +/*------------------------------------------------------------------------- + * + * Communications Device Class, Ethernet Control model + * + * Takes two interfaces. The DATA interface is inactive till an altsetting + * is selected. Configuration data includes class descriptors. There's + * an optional status endpoint on the control interface. + * + * This should interop with whatever the 2.4 "CDCEther.c" driver + * (by Brad Hards) talked with, with more functionality. + * + *-------------------------------------------------------------------------*/ + +static void dumpspeed(struct usbnet *dev, __le32 *speeds) +{ + if (netif_msg_timer(dev)) + devinfo(dev, "link speeds: %u kbps up, %u kbps down", + __le32_to_cpu(speeds[0]) / 1000, + __le32_to_cpu(speeds[1]) / 1000); +} + +static void cdc_status(struct usbnet *dev, struct urb *urb) +{ + struct usb_cdc_notification *event; + + if (urb->actual_length < sizeof *event) + return; + + /* SPEED_CHANGE can get split into two 8-byte packets */ + if (test_and_clear_bit(EVENT_STS_SPLIT, &dev->flags)) { + dumpspeed(dev, (__le32 *) urb->transfer_buffer); + return; + } + + event = urb->transfer_buffer; + switch (event->bNotificationType) { + case USB_CDC_NOTIFY_NETWORK_CONNECTION: + if (netif_msg_timer(dev)) + devdbg(dev, "CDC: carrier %s", + event->wValue ? "on" : "off"); + if (event->wValue) + netif_carrier_on(dev->net); + else + netif_carrier_off(dev->net); + break; + case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */ + if (netif_msg_timer(dev)) + devdbg(dev, "CDC: speed change (len %d)", + urb->actual_length); + if (urb->actual_length != (sizeof *event + 8)) + set_bit(EVENT_STS_SPLIT, &dev->flags); + else + dumpspeed(dev, (__le32 *) &event[1]); + break; + /* USB_CDC_NOTIFY_RESPONSE_AVAILABLE can happen too (e.g. RNDIS), + * but there are no standard formats for the response data. + */ + default: + deverr(dev, "CDC: unexpected notification %02x!", + event->bNotificationType); + break; + } +} + +static u8 nibble(unsigned char c) +{ + if (likely(isdigit(c))) + return c - '0'; + c = toupper(c); + if (likely(isxdigit(c))) + return 10 + c - 'A'; + return 0; +} + +static inline int +get_ethernet_addr(struct usbnet *dev, struct usb_cdc_ether_desc *e) +{ + int tmp, i; + unsigned char buf [13]; + + tmp = usb_string(dev->udev, e->iMACAddress, buf, sizeof buf); + if (tmp != 12) { + dev_dbg(&dev->udev->dev, + "bad MAC string %d fetch, %d\n", e->iMACAddress, tmp); + if (tmp >= 0) + tmp = -EINVAL; + return tmp; + } + for (i = tmp = 0; i < 6; i++, tmp += 2) + dev->net->dev_addr [i] = + (nibble(buf [tmp]) << 4) + nibble(buf [tmp + 1]); + return 0; +} + +static int cdc_bind(struct usbnet *dev, struct usb_interface *intf) +{ + int status; + struct cdc_state *info = (void *) &dev->data; + + status = usbnet_generic_cdc_bind(dev, intf); + if (status < 0) + return status; + + status = get_ethernet_addr(dev, info->ether); + if (status < 0) { + usb_set_intfdata(info->data, NULL); + usb_driver_release_interface(driver_of(intf), info->data); + return status; + } + + /* FIXME cdc-ether has some multicast code too, though it complains + * in routine cases. info->ether describes the multicast support. + * Implement that here, manipulating the cdc filter as needed. + */ + return 0; +} + +static const struct driver_info cdc_info = { + .description = "CDC Ethernet Device", + .flags = FLAG_ETHER, + // .check_connect = cdc_check_connect, + .bind = cdc_bind, + .unbind = usbnet_cdc_unbind, + .status = cdc_status, +}; + +/*-------------------------------------------------------------------------*/ + + +static const struct usb_device_id products [] = { +/* + * BLACKLIST !! + * + * First blacklist any products that are egregiously nonconformant + * with the CDC Ethernet specs. Minor braindamage we cope with; when + * they're not even trying, needing a separate driver is only the first + * of the differences to show up. + */ + +#define ZAURUS_MASTER_INTERFACE \ + .bInterfaceClass = USB_CLASS_COMM, \ + .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \ + .bInterfaceProtocol = USB_CDC_PROTO_NONE + +/* SA-1100 based Sharp Zaurus ("collie"), or compatible; + * wire-incompatible with true CDC Ethernet implementations. + * (And, it seems, needlessly so...) + */ +{ + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + .idProduct = 0x8004, + ZAURUS_MASTER_INTERFACE, + .driver_info = 0, +}, + +/* PXA-25x based Sharp Zaurii. Note that it seems some of these + * (later models especially) may have shipped only with firmware + * advertising false "CDC MDLM" compatibility ... but we're not + * clear which models did that, so for now let's assume the worst. + */ +{ + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + .idProduct = 0x8005, /* A-300 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = 0, +}, { + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + .idProduct = 0x8006, /* B-500/SL-5600 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = 0, +}, { + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + .idProduct = 0x8007, /* C-700 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = 0, +}, { + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + .idProduct = 0x9031, /* C-750 C-760 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = 0, +}, { + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + .idProduct = 0x9032, /* SL-6000 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = 0, +}, { + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x04DD, + /* reported with some C860 units */ + .idProduct = 0x9050, /* C-860 */ + ZAURUS_MASTER_INTERFACE, + .driver_info = 0, +}, + +/* + * WHITELIST!!! + * + * CDC Ether uses two interfaces, not necessarily consecutive. + * We match the main interface, ignoring the optional device + * class so we could handle devices that aren't exclusively + * CDC ether. + * + * NOTE: this match must come AFTER entries blacklisting devices + * because of bugs/quirks in a given product (like Zaurus, above). + */ +{ + USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET, + USB_CDC_PROTO_NONE), + .driver_info = (unsigned long) &cdc_info, +}, + { }, // END +}; +MODULE_DEVICE_TABLE(usb, products); + +static struct usb_driver cdc_driver = { + .owner = THIS_MODULE, + .name = "cdc_ether", + .id_table = products, + .probe = usbnet_probe, + .disconnect = usbnet_disconnect, + .suspend = usbnet_suspend, + .resume = usbnet_resume, +}; + + +static int __init cdc_init(void) +{ + BUG_ON((sizeof(((struct usbnet *)0)->data) + < sizeof(struct cdc_state))); + + return usb_register(&cdc_driver); +} +module_init(cdc_init); + +static void __exit cdc_exit(void) +{ + usb_deregister(&cdc_driver); +} +module_exit(cdc_exit); + +MODULE_AUTHOR("David Brownell"); +MODULE_DESCRIPTION("USB CDC Ethernet devices"); +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 75a05ab..7703725 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -301,377 +301,6 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) EXPORT_SYMBOL_GPL(usbnet_skb_return); -/*------------------------------------------------------------------------- - * - * Communications Device Class declarations. - * Used by CDC Ethernet, and some CDC variants - * - *-------------------------------------------------------------------------*/ - -#ifdef CONFIG_USB_CDCETHER -#define NEED_GENERIC_CDC -#endif - -#if defined(CONFIG_USB_ZAURUS) || defined(CONFIG_USB_ZAURUS_MODULE) -/* Ethernet variant uses funky framing, broken ethernet addressing */ -#define NEED_GENERIC_CDC -#endif - -#ifdef CONFIG_USB_RNDIS -/* ACM variant uses even funkier framing, complex control RPC scheme */ -#define NEED_GENERIC_CDC -#endif - - -#ifdef NEED_GENERIC_CDC - -#include - -static struct usb_driver usbnet_driver; - -/* - * probes control interface, claims data interface, collects the bulk - * endpoints, activates data interface (if needed), maybe sets MTU. - * all pure cdc, except for certain firmware workarounds. - */ -int usbnet_generic_cdc_bind (struct usbnet *dev, struct usb_interface *intf) -{ - u8 *buf = intf->cur_altsetting->extra; - int len = intf->cur_altsetting->extralen; - struct usb_interface_descriptor *d; - struct cdc_state *info = (void *) &dev->data; - int status; - int rndis; - - if (sizeof dev->data < sizeof *info) - return -EDOM; - - /* expect strict spec conformance for the descriptors, but - * cope with firmware which stores them in the wrong place - */ - if (len == 0 && dev->udev->actconfig->extralen) { - /* Motorola SB4100 (and others: Brad Hards says it's - * from a Broadcom design) put CDC descriptors here - */ - buf = dev->udev->actconfig->extra; - len = dev->udev->actconfig->extralen; - if (len) - dev_dbg (&intf->dev, - "CDC descriptors on config\n"); - } - - /* this assumes that if there's a non-RNDIS vendor variant - * of cdc-acm, it'll fail RNDIS requests cleanly. - */ - rndis = (intf->cur_altsetting->desc.bInterfaceProtocol == 0xff); - - memset (info, 0, sizeof *info); - info->control = intf; - while (len > 3) { - if (buf [1] != USB_DT_CS_INTERFACE) - goto next_desc; - - /* use bDescriptorSubType to identify the CDC descriptors. - * We expect devices with CDC header and union descriptors. - * For CDC Ethernet we need the ethernet descriptor. - * For RNDIS, ignore two (pointless) CDC modem descriptors - * in favor of a complicated OID-based RPC scheme doing what - * CDC Ethernet achieves with a simple descriptor. - */ - switch (buf [2]) { - case USB_CDC_HEADER_TYPE: - if (info->header) { - dev_dbg (&intf->dev, "extra CDC header\n"); - goto bad_desc; - } - info->header = (void *) buf; - if (info->header->bLength != sizeof *info->header) { - dev_dbg (&intf->dev, "CDC header len %u\n", - info->header->bLength); - goto bad_desc; - } - break; - case USB_CDC_UNION_TYPE: - if (info->u) { - dev_dbg (&intf->dev, "extra CDC union\n"); - goto bad_desc; - } - info->u = (void *) buf; - if (info->u->bLength != sizeof *info->u) { - dev_dbg (&intf->dev, "CDC union len %u\n", - info->u->bLength); - goto bad_desc; - } - - /* we need a master/control interface (what we're - * probed with) and a slave/data interface; union - * descriptors sort this all out. - */ - info->control = usb_ifnum_to_if(dev->udev, - info->u->bMasterInterface0); - info->data = usb_ifnum_to_if(dev->udev, - info->u->bSlaveInterface0); - if (!info->control || !info->data) { - dev_dbg (&intf->dev, - "master #%u/%p slave #%u/%p\n", - info->u->bMasterInterface0, - info->control, - info->u->bSlaveInterface0, - info->data); - goto bad_desc; - } - if (info->control != intf) { - dev_dbg (&intf->dev, "bogus CDC Union\n"); - /* Ambit USB Cable Modem (and maybe others) - * interchanges master and slave interface. - */ - if (info->data == intf) { - info->data = info->control; - info->control = intf; - } else - goto bad_desc; - } - - /* a data interface altsetting does the real i/o */ - d = &info->data->cur_altsetting->desc; - if (d->bInterfaceClass != USB_CLASS_CDC_DATA) { - dev_dbg (&intf->dev, "slave class %u\n", - d->bInterfaceClass); - goto bad_desc; - } - break; - case USB_CDC_ETHERNET_TYPE: - if (info->ether) { - dev_dbg (&intf->dev, "extra CDC ether\n"); - goto bad_desc; - } - info->ether = (void *) buf; - if (info->ether->bLength != sizeof *info->ether) { - dev_dbg (&intf->dev, "CDC ether len %u\n", - info->ether->bLength); - goto bad_desc; - } - dev->hard_mtu = le16_to_cpu( - info->ether->wMaxSegmentSize); - /* because of Zaurus, we may be ignoring the host - * side link address we were given. - */ - break; - } -next_desc: - len -= buf [0]; /* bLength */ - buf += buf [0]; - } - - if (!info->header || !info->u || (!rndis && !info->ether)) { - dev_dbg (&intf->dev, "missing cdc %s%s%sdescriptor\n", - info->header ? "" : "header ", - info->u ? "" : "union ", - info->ether ? "" : "ether "); - goto bad_desc; - } - - /* claim data interface and set it up ... with side effects. - * network traffic can't flow until an altsetting is enabled. - */ - status = usb_driver_claim_interface (&usbnet_driver, info->data, dev); - if (status < 0) - return status; - status = usbnet_get_endpoints (dev, info->data); - if (status < 0) { - /* ensure immediate exit from usbnet_disconnect */ - usb_set_intfdata(info->data, NULL); - usb_driver_release_interface (&usbnet_driver, info->data); - return status; - } - - /* status endpoint: optional for CDC Ethernet, not RNDIS (or ACM) */ - dev->status = NULL; - if (info->control->cur_altsetting->desc.bNumEndpoints == 1) { - struct usb_endpoint_descriptor *desc; - - dev->status = &info->control->cur_altsetting->endpoint [0]; - desc = &dev->status->desc; - if (desc->bmAttributes != USB_ENDPOINT_XFER_INT - || !(desc->bEndpointAddress & USB_DIR_IN) - || (le16_to_cpu(desc->wMaxPacketSize) - < sizeof (struct usb_cdc_notification)) - || !desc->bInterval) { - dev_dbg (&intf->dev, "bad notification endpoint\n"); - dev->status = NULL; - } - } - if (rndis && !dev->status) { - dev_dbg (&intf->dev, "missing RNDIS status endpoint\n"); - usb_set_intfdata(info->data, NULL); - usb_driver_release_interface (&usbnet_driver, info->data); - return -ENODEV; - } - return 0; - -bad_desc: - dev_info (&dev->udev->dev, "bad CDC descriptors\n"); - return -ENODEV; -} -EXPORT_SYMBOL_GPL(usbnet_generic_cdc_bind); - -void usbnet_cdc_unbind (struct usbnet *dev, struct usb_interface *intf) -{ - struct cdc_state *info = (void *) &dev->data; - - /* disconnect master --> disconnect slave */ - if (intf == info->control && info->data) { - /* ensure immediate exit from usbnet_disconnect */ - usb_set_intfdata(info->data, NULL); - usb_driver_release_interface (&usbnet_driver, info->data); - info->data = NULL; - } - - /* and vice versa (just in case) */ - else if (intf == info->data && info->control) { - /* ensure immediate exit from usbnet_disconnect */ - usb_set_intfdata(info->control, NULL); - usb_driver_release_interface (&usbnet_driver, info->control); - info->control = NULL; - } -} -EXPORT_SYMBOL_GPL(usbnet_cdc_unbind); - -#endif /* NEED_GENERIC_CDC */ - - -#ifdef CONFIG_USB_CDCETHER -#define HAVE_HARDWARE - -/*------------------------------------------------------------------------- - * - * Communications Device Class, Ethernet Control model - * - * Takes two interfaces. The DATA interface is inactive till an altsetting - * is selected. Configuration data includes class descriptors. - * - * This should interop with whatever the 2.4 "CDCEther.c" driver - * (by Brad Hards) talked with. - * - *-------------------------------------------------------------------------*/ - -#include - - -static void dumpspeed (struct usbnet *dev, __le32 *speeds) -{ - if (netif_msg_timer (dev)) - devinfo (dev, "link speeds: %u kbps up, %u kbps down", - __le32_to_cpu(speeds[0]) / 1000, - __le32_to_cpu(speeds[1]) / 1000); -} - -static void cdc_status (struct usbnet *dev, struct urb *urb) -{ - struct usb_cdc_notification *event; - - if (urb->actual_length < sizeof *event) - return; - - /* SPEED_CHANGE can get split into two 8-byte packets */ - if (test_and_clear_bit (EVENT_STS_SPLIT, &dev->flags)) { - dumpspeed (dev, (__le32 *) urb->transfer_buffer); - return; - } - - event = urb->transfer_buffer; - switch (event->bNotificationType) { - case USB_CDC_NOTIFY_NETWORK_CONNECTION: - if (netif_msg_timer (dev)) - devdbg (dev, "CDC: carrier %s", - event->wValue ? "on" : "off"); - if (event->wValue) - netif_carrier_on(dev->net); - else - netif_carrier_off(dev->net); - break; - case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */ - if (netif_msg_timer (dev)) - devdbg (dev, "CDC: speed change (len %d)", - urb->actual_length); - if (urb->actual_length != (sizeof *event + 8)) - set_bit (EVENT_STS_SPLIT, &dev->flags); - else - dumpspeed (dev, (__le32 *) &event[1]); - break; - // case USB_CDC_NOTIFY_RESPONSE_AVAILABLE: /* RNDIS; or unsolicited */ - default: - deverr (dev, "CDC: unexpected notification %02x!", - event->bNotificationType); - break; - } -} - -static u8 nibble (unsigned char c) -{ - if (likely (isdigit (c))) - return c - '0'; - c = toupper (c); - if (likely (isxdigit (c))) - return 10 + c - 'A'; - return 0; -} - -static inline int -get_ethernet_addr (struct usbnet *dev, struct usb_cdc_ether_desc *e) -{ - int tmp, i; - unsigned char buf [13]; - - tmp = usb_string (dev->udev, e->iMACAddress, buf, sizeof buf); - if (tmp != 12) { - dev_dbg (&dev->udev->dev, - "bad MAC string %d fetch, %d\n", e->iMACAddress, tmp); - if (tmp >= 0) - tmp = -EINVAL; - return tmp; - } - for (i = tmp = 0; i < 6; i++, tmp += 2) - dev->net->dev_addr [i] = - (nibble (buf [tmp]) << 4) + nibble (buf [tmp + 1]); - return 0; -} - -static int cdc_bind (struct usbnet *dev, struct usb_interface *intf) -{ - int status; - struct cdc_state *info = (void *) &dev->data; - - status = usbnet_generic_cdc_bind (dev, intf); - if (status < 0) - return status; - - status = get_ethernet_addr (dev, info->ether); - if (status < 0) { - usb_set_intfdata(info->data, NULL); - usb_driver_release_interface (&usbnet_driver, info->data); - return status; - } - - /* FIXME cdc-ether has some multicast code too, though it complains - * in routine cases. info->ether describes the multicast support. - */ - return 0; -} - -static const struct driver_info cdc_info = { - .description = "CDC Ethernet Device", - .flags = FLAG_ETHER, - // .check_connect = cdc_check_connect, - .bind = cdc_bind, - .unbind = usbnet_cdc_unbind, - .status = cdc_status, -}; - -#endif /* CONFIG_USB_CDCETHER */ - - - #ifdef CONFIG_USB_PL2301 #define HAVE_HARDWARE @@ -1754,23 +1383,6 @@ static const struct usb_device_id products [] = { .driver_info = (unsigned long) &rndis_info, }, #endif - -#ifdef CONFIG_USB_CDCETHER -{ - /* CDC Ether uses two interfaces, not necessarily consecutive. - * We match the main interface, ignoring the optional device - * class so we could handle devices that aren't exclusively - * CDC ether. - * - * NOTE: this match must come AFTER entries working around - * bugs/quirks in a given product (like Zaurus, above). - */ - USB_INTERFACE_INFO (USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET, - USB_CDC_PROTO_NONE), - .driver_info = (unsigned long) &cdc_info, -}, -#endif - { }, // END }; MODULE_DEVICE_TABLE (usb, products); @@ -1792,10 +1404,6 @@ static int __init usbnet_init(void) // compiler should optimize these out BUG_ON (sizeof (((struct sk_buff *)0)->cb) < sizeof (struct skb_data)); -#ifdef CONFIG_USB_CDCETHER - BUG_ON ((sizeof (((struct usbnet *)0)->data) - < sizeof (struct cdc_state))); -#endif random_ether_addr(node_id); -- cgit v0.10.2 From 64e049102d3de3e61409cb6019403a9e689dfda6 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 31 Aug 2005 09:54:36 -0700 Subject: [PATCH] USB: usbnet (8/9) module for RNDIS devices This adds host-side RNDIS support to the "usbnet" driver, so Linux can talk to various devices (often based on WinCE) that otherwise only Windows could talk to. Tested with little-endian Linux talking to a Linux-USB Ethernet/RNDIS based peripheral. This also includes updates from Eddie C. Dost for big-endian SPARC Linux talking to a Nokia 9500 Communicator. It's still marked as EXPERIMENTAL because this code is so young. This ought to let Linux to work with various cable modems that previously would have been "Windows Only". Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig index 4921101..5f3ae1e 100644 --- a/drivers/usb/net/Kconfig +++ b/drivers/usb/net/Kconfig @@ -212,6 +212,19 @@ config USB_NET_NET1080 on this design: one NetChip 1080 chip and supporting logic, optionally with LEDs that indicate traffic +config USB_NET_RNDIS_HOST + tristate "Host for RNDIS devices (EXPERIMENTAL)" + depends on USB_USBNET && EXPERIMENTAL + select USB_NET_CDCETHER + help + This option enables hosting "Remote NDIS" USB networking links, + as encouraged by Microsoft (instead of CDC Ethernet!) for use in + various devices that may only support this protocol. + + Avoid using this protocol unless you have no better options. + The protocol specification is incomplete, and is controlled by + (and for) Microsoft; it isn't an "Open" ecosystem or market. + config USB_NET_CDC_SUBSET tristate "Simple USB Network Links (CDC Ethernet subset)" depends on USB_USBNET diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile index 697eb19..cb789c3d 100644 --- a/drivers/usb/net/Makefile +++ b/drivers/usb/net/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_USB_NET_AX8817X) += asix.o obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o obj-$(CONFIG_USB_NET_GL620A) += gl620a.o obj-$(CONFIG_USB_NET_NET1080) += net1080.o +obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o obj-$(CONFIG_USB_USBNET) += usbnet.o diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c new file mode 100644 index 0000000..2ed2e5f --- /dev/null +++ b/drivers/usb/net/rndis_host.c @@ -0,0 +1,615 @@ +/* + * Host Side support for RNDIS Networking Links + * Copyright (C) 2005 by David Brownell + * + * 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 + */ + +// #define DEBUG // error path messages, extra info +// #define VERBOSE // more; success messages + +#include +#ifdef CONFIG_USB_DEBUG +# define DEBUG +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "usbnet.h" + + +/* + * RNDIS is NDIS remoted over USB. It's a MSFT variant of CDC ACM ... of + * course ACM was intended for modems, not Ethernet links! USB's standard + * for Ethernet links is "CDC Ethernet", which is significantly simpler. + */ + +/* + * CONTROL uses CDC "encapsulated commands" with funky notifications. + * - control-out: SEND_ENCAPSULATED + * - interrupt-in: RESPONSE_AVAILABLE + * - control-in: GET_ENCAPSULATED + * + * We'll try to ignore the RESPONSE_AVAILABLE notifications. + */ +struct rndis_msg_hdr { + __le32 msg_type; /* RNDIS_MSG_* */ + __le32 msg_len; + // followed by data that varies between messages + __le32 request_id; + __le32 status; + // ... and more +} __attribute__ ((packed)); + +/* RNDIS defines this (absurdly huge) control timeout */ +#define RNDIS_CONTROL_TIMEOUT_MS (10 * 1000) + + +#define ccpu2 __constant_cpu_to_le32 + +#define RNDIS_MSG_COMPLETION ccpu2(0x80000000) + +/* codes for "msg_type" field of rndis messages; + * only the data channel uses packet messages (maybe batched); + * everything else goes on the control channel. + */ +#define RNDIS_MSG_PACKET ccpu2(0x00000001) /* 1-N packets */ +#define RNDIS_MSG_INIT ccpu2(0x00000002) +#define RNDIS_MSG_INIT_C (RNDIS_MSG_INIT|RNDIS_MSG_COMPLETION) +#define RNDIS_MSG_HALT ccpu2(0x00000003) +#define RNDIS_MSG_QUERY ccpu2(0x00000004) +#define RNDIS_MSG_QUERY_C (RNDIS_MSG_QUERY|RNDIS_MSG_COMPLETION) +#define RNDIS_MSG_SET ccpu2(0x00000005) +#define RNDIS_MSG_SET_C (RNDIS_MSG_SET|RNDIS_MSG_COMPLETION) +#define RNDIS_MSG_RESET ccpu2(0x00000006) +#define RNDIS_MSG_RESET_C (RNDIS_MSG_RESET|RNDIS_MSG_COMPLETION) +#define RNDIS_MSG_INDICATE ccpu2(0x00000007) +#define RNDIS_MSG_KEEPALIVE ccpu2(0x00000008) +#define RNDIS_MSG_KEEPALIVE_C (RNDIS_MSG_KEEPALIVE|RNDIS_MSG_COMPLETION) + +/* codes for "status" field of completion messages */ +#define RNDIS_STATUS_SUCCESS ccpu2(0x00000000) +#define RNDIS_STATUS_FAILURE ccpu2(0xc0000001) +#define RNDIS_STATUS_INVALID_DATA ccpu2(0xc0010015) +#define RNDIS_STATUS_NOT_SUPPORTED ccpu2(0xc00000bb) +#define RNDIS_STATUS_MEDIA_CONNECT ccpu2(0x4001000b) +#define RNDIS_STATUS_MEDIA_DISCONNECT ccpu2(0x4001000c) + + +struct rndis_data_hdr { + __le32 msg_type; /* RNDIS_MSG_PACKET */ + __le32 msg_len; // rndis_data_hdr + data_len + pad + __le32 data_offset; // 36 -- right after header + __le32 data_len; // ... real packet size + + __le32 oob_data_offset; // zero + __le32 oob_data_len; // zero + __le32 num_oob; // zero + __le32 packet_data_offset; // zero + + __le32 packet_data_len; // zero + __le32 vc_handle; // zero + __le32 reserved; // zero +} __attribute__ ((packed)); + +struct rndis_init { /* OUT */ + // header and: + __le32 msg_type; /* RNDIS_MSG_INIT */ + __le32 msg_len; // 24 + __le32 request_id; + __le32 major_version; // of rndis (1.0) + __le32 minor_version; + __le32 max_transfer_size; +} __attribute__ ((packed)); + +struct rndis_init_c { /* IN */ + // header and: + __le32 msg_type; /* RNDIS_MSG_INIT_C */ + __le32 msg_len; + __le32 request_id; + __le32 status; + __le32 major_version; // of rndis (1.0) + __le32 minor_version; + __le32 device_flags; + __le32 medium; // zero == 802.3 + __le32 max_packets_per_message; + __le32 max_transfer_size; + __le32 packet_alignment; // max 7; (1<actual_length, urb->status); + // FIXME for keepalives, respond immediately (asynchronously) + // if not an RNDIS status, do like cdc_status(dev,urb) does +} + +/* + * RPC done RNDIS-style. Caller guarantees: + * - message is properly byteswapped + * - there's no other request pending + * - buf can hold up to 1KB response (required by RNDIS spec) + * On return, the first few entries are already byteswapped. + * + * Call context is likely probe(), before interface name is known, + * which is why we won't try to use it in the diagnostics. + */ +static int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf) +{ + struct cdc_state *info = (void *) &dev->data; + int retval; + unsigned count; + __le32 rsp; + u32 xid = 0, msg_len, request_id; + + /* REVISIT when this gets called from contexts other than probe() or + * disconnect(): either serialize, or dispatch responses on xid + */ + + /* Issue the request; don't bother byteswapping our xid */ + if (likely(buf->msg_type != RNDIS_MSG_HALT + && buf->msg_type != RNDIS_MSG_RESET)) { + xid = dev->xid++; + if (!xid) + xid = dev->xid++; + buf->request_id = (__force __le32) xid; + } + retval = usb_control_msg(dev->udev, + usb_sndctrlpipe(dev->udev, 0), + USB_CDC_SEND_ENCAPSULATED_COMMAND, + USB_TYPE_CLASS | USB_RECIP_INTERFACE, + 0, info->u->bMasterInterface0, + buf, le32_to_cpu(buf->msg_len), + RNDIS_CONTROL_TIMEOUT_MS); + if (unlikely(retval < 0 || xid == 0)) + return retval; + + // FIXME Seems like some devices discard responses when + // we time out and cancel our "get response" requests... + // so, this is fragile. Probably need to poll for status. + + /* ignore status endpoint, just poll the control channel; + * the request probably completed immediately + */ + rsp = buf->msg_type | RNDIS_MSG_COMPLETION; + for (count = 0; count < 10; count++) { + memset(buf, 0, 1024); + retval = usb_control_msg(dev->udev, + usb_rcvctrlpipe(dev->udev, 0), + USB_CDC_GET_ENCAPSULATED_RESPONSE, + USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, + 0, info->u->bMasterInterface0, + buf, 1024, + RNDIS_CONTROL_TIMEOUT_MS); + if (likely(retval >= 8)) { + msg_len = le32_to_cpu(buf->msg_len); + request_id = (__force u32) buf->request_id; + if (likely(buf->msg_type == rsp)) { + if (likely(request_id == xid)) { + if (unlikely(rsp == RNDIS_MSG_RESET_C)) + return 0; + if (likely(RNDIS_STATUS_SUCCESS + == buf->status)) + return 0; + dev_dbg(&info->control->dev, + "rndis reply status %08x\n", + le32_to_cpu(buf->status)); + return -EL3RST; + } + dev_dbg(&info->control->dev, + "rndis reply id %d expected %d\n", + request_id, xid); + /* then likely retry */ + } else switch (buf->msg_type) { + case RNDIS_MSG_INDICATE: { /* fault */ + // struct rndis_indicate *msg = (void *)buf; + dev_info(&info->control->dev, + "rndis fault indication\n"); + } + break; + case RNDIS_MSG_KEEPALIVE: { /* ping */ + struct rndis_keepalive_c *msg = (void *)buf; + + msg->msg_type = RNDIS_MSG_KEEPALIVE_C; + msg->msg_len = ccpu2(sizeof *msg); + msg->status = RNDIS_STATUS_SUCCESS; + retval = usb_control_msg(dev->udev, + usb_sndctrlpipe(dev->udev, 0), + USB_CDC_SEND_ENCAPSULATED_COMMAND, + USB_TYPE_CLASS | USB_RECIP_INTERFACE, + 0, info->u->bMasterInterface0, + msg, sizeof *msg, + RNDIS_CONTROL_TIMEOUT_MS); + if (unlikely(retval < 0)) + dev_dbg(&info->control->dev, + "rndis keepalive err %d\n", + retval); + } + break; + default: + dev_dbg(&info->control->dev, + "unexpected rndis msg %08x len %d\n", + le32_to_cpu(buf->msg_type), msg_len); + } + } else { + /* device probably issued a protocol stall; ignore */ + dev_dbg(&info->control->dev, + "rndis response error, code %d\n", retval); + } + msleep(2); + } + dev_dbg(&info->control->dev, "rndis response timeout\n"); + return -ETIMEDOUT; +} + +static int rndis_bind(struct usbnet *dev, struct usb_interface *intf) +{ + int retval; + struct net_device *net = dev->net; + union { + void *buf; + struct rndis_msg_hdr *header; + struct rndis_init *init; + struct rndis_init_c *init_c; + struct rndis_query *get; + struct rndis_query_c *get_c; + struct rndis_set *set; + struct rndis_set_c *set_c; + } u; + u32 tmp; + + /* we can't rely on i/o from stack working, or stack allocation */ + u.buf = kmalloc(1024, GFP_KERNEL); + if (!u.buf) + return -ENOMEM; + retval = usbnet_generic_cdc_bind(dev, intf); + if (retval < 0) + goto done; + + net->hard_header_len += sizeof (struct rndis_data_hdr); + + /* initialize; max transfer is 16KB at full speed */ + u.init->msg_type = RNDIS_MSG_INIT; + u.init->msg_len = ccpu2(sizeof *u.init); + u.init->major_version = ccpu2(1); + u.init->minor_version = ccpu2(0); + u.init->max_transfer_size = ccpu2(net->mtu + net->hard_header_len); + + retval = rndis_command(dev, u.header); + if (unlikely(retval < 0)) { + /* it might not even be an RNDIS device!! */ + dev_err(&intf->dev, "RNDIS init failed, %d\n", retval); +fail: + usb_driver_release_interface(driver_of(intf), + ((struct cdc_state *)&(dev->data))->data); + goto done; + } + dev->hard_mtu = le32_to_cpu(u.init_c->max_transfer_size); + /* REVISIT: peripheral "alignment" request is ignored ... */ + dev_dbg(&intf->dev, "hard mtu %u, align %d\n", dev->hard_mtu, + 1 << le32_to_cpu(u.init_c->packet_alignment)); + + /* get designated host ethernet address */ + memset(u.get, 0, sizeof *u.get); + u.get->msg_type = RNDIS_MSG_QUERY; + u.get->msg_len = ccpu2(sizeof *u.get); + u.get->oid = OID_802_3_PERMANENT_ADDRESS; + + retval = rndis_command(dev, u.header); + if (unlikely(retval < 0)) { + dev_err(&intf->dev, "rndis get ethaddr, %d\n", retval); + goto fail; + } + tmp = le32_to_cpu(u.get_c->offset); + if (unlikely((tmp + 8) > (1024 - ETH_ALEN) + || u.get_c->len != ccpu2(ETH_ALEN))) { + dev_err(&intf->dev, "rndis ethaddr off %d len %d ?\n", + tmp, le32_to_cpu(u.get_c->len)); + retval = -EDOM; + goto fail; + } + memcpy(net->dev_addr, tmp + (char *)&u.get_c->request_id, ETH_ALEN); + + /* set a nonzero filter to enable data transfers */ + memset(u.set, 0, sizeof *u.set); + u.set->msg_type = RNDIS_MSG_SET; + u.set->msg_len = ccpu2(4 + sizeof *u.set); + u.set->oid = OID_GEN_CURRENT_PACKET_FILTER; + u.set->len = ccpu2(4); + u.set->offset = ccpu2((sizeof *u.set) - 8); + *(__le32 *)(u.buf + sizeof *u.set) = ccpu2(DEFAULT_FILTER); + + retval = rndis_command(dev, u.header); + if (unlikely(retval < 0)) { + dev_err(&intf->dev, "rndis set packet filter, %d\n", retval); + goto fail; + } + + retval = 0; +done: + kfree(u.buf); + return retval; +} + +static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf) +{ + struct rndis_halt *halt; + + /* try to clear any rndis state/activity (no i/o from stack!) */ + halt = kcalloc(1, sizeof *halt, SLAB_KERNEL); + if (halt) { + halt->msg_type = RNDIS_MSG_HALT; + halt->msg_len = ccpu2(sizeof *halt); + (void) rndis_command(dev, (void *)halt); + kfree(halt); + } + + return usbnet_cdc_unbind(dev, intf); +} + +/* + * DATA -- host must not write zlps + */ +static int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb) +{ + /* peripheral may have batched packets to us... */ + while (likely(skb->len)) { + struct rndis_data_hdr *hdr = (void *)skb->data; + struct sk_buff *skb2; + u32 msg_len, data_offset, data_len; + + msg_len = le32_to_cpu(hdr->msg_len); + data_offset = le32_to_cpu(hdr->data_offset); + data_len = le32_to_cpu(hdr->data_len); + + /* don't choke if we see oob, per-packet data, etc */ + if (unlikely(hdr->msg_type != RNDIS_MSG_PACKET + || skb->len < msg_len + || (data_offset + data_len + 8) > msg_len)) { + dev->stats.rx_frame_errors++; + devdbg(dev, "bad rndis message %d/%d/%d/%d, len %d", + le32_to_cpu(hdr->msg_type), + msg_len, data_offset, data_len, skb->len); + return 0; + } + skb_pull(skb, 8 + data_offset); + + /* at most one packet left? */ + if (likely((data_len - skb->len) <= sizeof *hdr)) { + skb_trim(skb, data_len); + break; + } + + /* try to return all the packets in the batch */ + skb2 = skb_clone(skb, GFP_ATOMIC); + if (unlikely(!skb2)) + break; + skb_pull(skb, msg_len - sizeof *hdr); + skb_trim(skb2, data_len); + usbnet_skb_return(dev, skb2); + } + + /* caller will usbnet_skb_return the remaining packet */ + return 1; +} + +static struct sk_buff * +rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) +{ + struct rndis_data_hdr *hdr; + struct sk_buff *skb2; + unsigned len = skb->len; + + if (likely(!skb_cloned(skb))) { + int room = skb_headroom(skb); + + /* enough head room as-is? */ + if (unlikely((sizeof *hdr) <= room)) + goto fill; + + /* enough room, but needs to be readjusted? */ + room += skb_tailroom(skb); + if (likely((sizeof *hdr) <= room)) { + skb->data = memmove(skb->head + sizeof *hdr, + skb->data, len); + skb->tail = skb->data + len; + goto fill; + } + } + + /* create a new skb, with the correct size (and tailpad) */ + skb2 = skb_copy_expand(skb, sizeof *hdr, 1, flags); + dev_kfree_skb_any(skb); + if (unlikely(!skb2)) + return skb2; + skb = skb2; + + /* fill out the RNDIS header. we won't bother trying to batch + * packets; Linux minimizes wasted bandwidth through tx queues. + */ +fill: + hdr = (void *) __skb_push(skb, sizeof *hdr); + memset(hdr, 0, sizeof *hdr); + hdr->msg_type = RNDIS_MSG_PACKET; + hdr->msg_len = cpu_to_le32(skb->len); + hdr->data_offset = ccpu2(sizeof(*hdr) - 8); + hdr->data_len = cpu_to_le32(len); + + /* FIXME make the last packet always be short ... */ + return skb; +} + + +static const struct driver_info rndis_info = { + .description = "RNDIS device", + .flags = FLAG_ETHER | FLAG_FRAMING_RN, + .bind = rndis_bind, + .unbind = rndis_unbind, + .status = rndis_status, + .rx_fixup = rndis_rx_fixup, + .tx_fixup = rndis_tx_fixup, +}; + +#undef ccpu2 + + +/*-------------------------------------------------------------------------*/ + +static const struct usb_device_id products [] = { +{ + /* RNDIS is MSFT's un-official variant of CDC ACM */ + USB_INTERFACE_INFO(USB_CLASS_COMM, 2 /* ACM */, 0x0ff), + .driver_info = (unsigned long) &rndis_info, +}, + { }, // END +}; +MODULE_DEVICE_TABLE(usb, products); + +static struct usb_driver rndis_driver = { + .owner = THIS_MODULE, + .name = "rndis_host", + .id_table = products, + .probe = usbnet_probe, + .disconnect = usbnet_disconnect, + .suspend = usbnet_suspend, + .resume = usbnet_resume, +}; + +static int __init rndis_init(void) +{ + return usb_register(&rndis_driver); +} +module_init(rndis_init); + +static void __exit rndis_exit(void) +{ + usb_deregister(&rndis_driver); +} +module_exit(rndis_exit); + +MODULE_AUTHOR("David Brownell"); +MODULE_DESCRIPTION("USB Host side RNDIS driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 7703725..6c78a42 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -103,6 +103,7 @@ * disconnect; other cleanups. (db) Flush net1080 fifos * after several sequential framing errors. (Johannes Erdfelt) * 22-aug-2003 AX8817X support (Dave Hollis). + * * 14-jun-2004 Trivial patch for AX8817X based Buffalo LUA-U2-KTX in Japan * (Neil Bortnak) * 03-nov-2004 Trivial patch for KC2190 (KC-190) chip. (Jonathan McDowell) @@ -1375,14 +1376,6 @@ static const struct usb_device_id products [] = { .driver_info = (unsigned long) &prolific_info, }, #endif - -#ifdef CONFIG_USB_RNDIS -{ - /* RNDIS is MSFT's un-official variant of CDC ACM */ - USB_INTERFACE_INFO (USB_CLASS_COMM, 2 /* ACM */, 0x0ff), - .driver_info = (unsigned long) &rndis_info, -}, -#endif { }, // END }; MODULE_DEVICE_TABLE (usb, products); -- cgit v0.10.2 From 090ffa9d0e904e1ed0f86c84dcf20684a8ac1a5a Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 31 Aug 2005 09:54:50 -0700 Subject: [PATCH] USB: usbnet (9/9) module for pl2301/2302 cables This wraps up the conversion of the "usbnet" driver structure, by moving the Prolific PL-2201/2302 minidriver to a module of its own. It also includes some minor cleanups to the remaining "usbnet" file, notably removing that long changelog at the top. Minor historical note: Linux 2.2 first called the driver for this hardware "plusb". Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig index 5f3ae1e..8c010bb 100644 --- a/drivers/usb/net/Kconfig +++ b/drivers/usb/net/Kconfig @@ -99,7 +99,7 @@ config USB_USBNET with "minidrivers" built around a common network driver core that supports deep queues for efficient transfers. (This gives better performance with small packets and at high speeds). - + The USB host runs "usbnet", and the other end of the link might be: - Another USB host, when using USB "network" or "data transfer" @@ -125,20 +125,6 @@ config USB_USBNET To compile this driver as a module, choose M here: the module will be called usbnet. -comment "USB Host-to-Host Cables" - depends on USB_USBNET - -config USB_PL2301 - boolean "Prolific PL-2301/2302 based cables" - default y - # handshake/init/reset problems, from original 'plusb' driver - depends on USB_USBNET && EXPERIMENTAL - help - Choose this option if you're using a host-to-host cable - with one of these chips. - -comment "Drivers built using the usbnet core" - config USB_NET_AX8817X tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" depends on USB_USBNET && NET_ETHERNET @@ -212,6 +198,15 @@ config USB_NET_NET1080 on this design: one NetChip 1080 chip and supporting logic, optionally with LEDs that indicate traffic +config USB_NET_PLUSB + tristate "Prolific PL-2301/2302 based cables" + # if the handshake/init/reset problems, from original 'plusb', + # are ever resolved ... then remove "experimental" + depends on USB_USBNET && EXPERIMENTAL + help + Choose this option if you're using a host-to-host cable + with one of these chips. + config USB_NET_RNDIS_HOST tristate "Host for RNDIS devices (EXPERIMENTAL)" depends on USB_USBNET && EXPERIMENTAL diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile index cb789c3d..222c049 100644 --- a/drivers/usb/net/Makefile +++ b/drivers/usb/net/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_USB_NET_AX8817X) += asix.o obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o obj-$(CONFIG_USB_NET_GL620A) += gl620a.o obj-$(CONFIG_USB_NET_NET1080) += net1080.o +obj-$(CONFIG_USB_NET_PLUSB) += plusb.o obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o diff --git a/drivers/usb/net/plusb.c b/drivers/usb/net/plusb.c new file mode 100644 index 0000000..74c2b35 --- /dev/null +++ b/drivers/usb/net/plusb.c @@ -0,0 +1,156 @@ +/* + * PL-2301/2302 USB host-to-host link cables + * Copyright (C) 2000-2005 by David Brownell + * + * 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 + */ + +// #define DEBUG // error path messages, extra info +// #define VERBOSE // more; success messages + +#include +#ifdef CONFIG_USB_DEBUG +# define DEBUG +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "usbnet.h" + + +/* + * Prolific PL-2301/PL-2302 driver ... http://www.prolifictech.com + * + * The protocol and handshaking used here should be bug-compatible + * with the Linux 2.2 "plusb" driver, by Deti Fliegl. + * + * HEADS UP: this handshaking isn't all that robust. This driver + * gets confused easily if you unplug one end of the cable then + * try to connect it again; you'll need to restart both ends. The + * "naplink" software (used by some PlayStation/2 deveopers) does + * the handshaking much better! Also, sometimes this hardware + * seems to get wedged under load. Prolific docs are weak, and + * don't identify differences between PL2301 and PL2302, much less + * anything to explain the different PL2302 versions observed. + */ + +/* + * Bits 0-4 can be used for software handshaking; they're set from + * one end, cleared from the other, "read" with the interrupt byte. + */ +#define PL_S_EN (1<<7) /* (feature only) suspend enable */ +/* reserved bit -- rx ready (6) ? */ +#define PL_TX_READY (1<<5) /* (interrupt only) transmit ready */ +#define PL_RESET_OUT (1<<4) /* reset output pipe */ +#define PL_RESET_IN (1<<3) /* reset input pipe */ +#define PL_TX_C (1<<2) /* transmission complete */ +#define PL_TX_REQ (1<<1) /* transmission received */ +#define PL_PEER_E (1<<0) /* peer exists */ + +static inline int +pl_vendor_req(struct usbnet *dev, u8 req, u8 val, u8 index) +{ + return usb_control_msg(dev->udev, + usb_rcvctrlpipe(dev->udev, 0), + req, + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + val, index, + NULL, 0, + USB_CTRL_GET_TIMEOUT); +} + +static inline int +pl_clear_QuickLink_features(struct usbnet *dev, int val) +{ + return pl_vendor_req(dev, 1, (u8) val, 0); +} + +static inline int +pl_set_QuickLink_features(struct usbnet *dev, int val) +{ + return pl_vendor_req(dev, 3, (u8) val, 0); +} + +static int pl_reset(struct usbnet *dev) +{ + /* some units seem to need this reset, others reject it utterly. + * FIXME be more like "naplink" or windows drivers. + */ + (void) pl_set_QuickLink_features(dev, + PL_S_EN|PL_RESET_OUT|PL_RESET_IN|PL_PEER_E); + return 0; +} + +static const struct driver_info prolific_info = { + .description = "Prolific PL-2301/PL-2302", + .flags = FLAG_NO_SETINT, + /* some PL-2302 versions seem to fail usb_set_interface() */ + .reset = pl_reset, +}; + + +/*-------------------------------------------------------------------------*/ + +/* + * Proilific's name won't normally be on the cables, and + * may not be on the device. + */ + +static const struct usb_device_id products [] = { + +{ + USB_DEVICE(0x067b, 0x0000), // PL-2301 + .driver_info = (unsigned long) &prolific_info, +}, { + USB_DEVICE(0x067b, 0x0001), // PL-2302 + .driver_info = (unsigned long) &prolific_info, +}, + + { }, // END +}; +MODULE_DEVICE_TABLE(usb, products); + +static struct usb_driver plusb_driver = { + .owner = THIS_MODULE, + .name = "plusb", + .id_table = products, + .probe = usbnet_probe, + .disconnect = usbnet_disconnect, + .suspend = usbnet_suspend, + .resume = usbnet_resume, +}; + +static int __init plusb_init(void) +{ + return usb_register(&plusb_driver); +} +module_init(plusb_init); + +static void __exit plusb_exit(void) +{ + usb_deregister(&plusb_driver); +} +module_exit(plusb_exit); + +MODULE_AUTHOR("David Brownell"); +MODULE_DESCRIPTION("Prolific PL-2301/2302 USB Host to Host Link Driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 6c78a42..6c46091 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -1,5 +1,5 @@ /* - * USB Networking Links + * USB Network driver infrastructure * Copyright (C) 2000-2005 by David Brownell * Copyright (C) 2003-2005 David Hollis * @@ -20,96 +20,15 @@ /* * This is a generic "USB networking" framework that works with several - * kinds of full and high speed networking devices: + * kinds of full and high speed networking devices: host-to-host cables, + * smart usb peripherals, and actual Ethernet adapters. * - * + USB host-to-host "network cables", used for IP-over-USB links. - * These are often used for Laplink style connectivity products. - * - AnchorChip 2720 - * - Belkin, eTEK (interops with Win32 drivers) - * - GeneSys GL620USB-A - * - NetChip 1080 (interoperates with NetChip Win32 drivers) - * - Prolific PL-2301/2302 (replaces "plusb" driver) - * - KC Technology KC2190 - * - * + Smart USB devices can support such links directly, using Internet - * standard protocols instead of proprietary host-to-device links. - * - Linux PDAs like iPaq, Yopy, and Zaurus - * - The BLOB boot loader (for diskless booting) - * - Linux "gadgets", perhaps using PXA-2xx or Net2280 controllers - * - Devices using EPSON's sample USB firmware - * - CDC-Ethernet class devices, such as many cable modems - * - * + Adapters to networks such as Ethernet. - * - AX8817X based USB 2.0 products - * - * Links to these devices can be bridged using Linux Ethernet bridging. - * With minor exceptions, these all use similar USB framing for network - * traffic, but need different protocols for control traffic. - * - * USB devices can implement their side of this protocol at the cost - * of two bulk endpoints; it's not restricted to "cable" applications. - * See the SA1110, Zaurus, or EPSON device/client support in this driver; - * slave/target drivers such as "usb-eth" (on most SA-1100 PDAs) or - * "g_ether" (in the Linux "gadget" framework) implement that behavior - * within devices. - * - * - * CHANGELOG: - * - * 13-sep-2000 experimental, new - * 10-oct-2000 usb_device_id table created. - * 28-oct-2000 misc fixes; mostly, discard more TTL-mangled rx packets. - * 01-nov-2000 usb_device_id table and probing api update by - * Adam J. Richter . - * 18-dec-2000 (db) tx watchdog, "net1080" renaming to "usbnet", device_info - * and prolific support, isolate net1080-specific bits, cleanup. - * fix unlink_urbs oops in D3 PM resume code path. - * - * 02-feb-2001 (db) fix tx skb sharing, packet length, match_flags, ... - * 08-feb-2001 stubbed in "linuxdev", maybe the SA-1100 folk can use it; - * AnchorChips 2720 support (from spec) for testing; - * fix bit-ordering problem with ethernet multicast addr - * 19-feb-2001 Support for clearing halt conditions. SA1100 UDC support - * updates. Oleg Drokin (green@iXcelerator.com) - * 25-mar-2001 More SA-1100 updates, including workaround for ip problem - * expecting cleared skb->cb and framing change to match latest - * handhelds.org version (Oleg). Enable device IDs from the - * Win32 Belkin driver; other cleanups (db). - * 16-jul-2001 Bugfixes for uhci oops-on-unplug, Belkin support, various - * cleanups for problems not yet seen in the field. (db) - * 17-oct-2001 Handle "Advance USBNET" product, like Belkin/eTEK devices, - * from Ioannis Mavroukakis ; - * rx unlinks somehow weren't async; minor cleanup. - * 03-nov-2001 Merged GeneSys driver; original code from Jiun-Jie Huang - * , updated by Stanislav Brabec - * . Made framing options (NetChip/GeneSys) - * tie mostly to (sub)driver info. Workaround some PL-2302 - * chips that seem to reject SET_INTERFACE requests. - * - * 06-apr-2002 Added ethtool support, based on a patch from Brad Hards. - * Level of diagnostics is more configurable; they use device - * location (usb_device->devpath) instead of address (2.5). - * For tx_fixup, memflags can't be NOIO. - * 07-may-2002 Generalize/cleanup keventd support, handling rx stalls (mostly - * for USB 2.0 TTs) and memory shortages (potential) too. (db) - * Use "locally assigned" IEEE802 address space. (Brad Hards) - * 18-oct-2002 Support for Zaurus (Pavel Machek), related cleanup (db). - * 14-dec-2002 Remove Zaurus-private crc32 code (Pavel); 2.5 oops fix, - * cleanups and stubbed PXA-250 support (db), fix for framing - * issues on Z, net1080, and gl620a (Toby Milne) - * - * 31-mar-2003 Use endpoint descriptors: high speed support, simpler sa1100 - * vs pxa25x, and CDC Ethernet. Throttle down log floods on - * disconnect; other cleanups. (db) Flush net1080 fifos - * after several sequential framing errors. (Johannes Erdfelt) - * 22-aug-2003 AX8817X support (Dave Hollis). - * - * 14-jun-2004 Trivial patch for AX8817X based Buffalo LUA-U2-KTX in Japan - * (Neil Bortnak) - * 03-nov-2004 Trivial patch for KC2190 (KC-190) chip. (Jonathan McDowell) - * - * 01-feb-2005 AX88772 support (Phil Chang & Dave Hollis) - *-------------------------------------------------------------------------*/ + * These devices usually differ in terms of control protocols (if they + * even have one!) and sometimes they define new framing to wrap or batch + * Ethernet packets. Otherwise, they talk to USB pretty much the same, + * so interface (un)binding, endpoint I/O queues, fault handling, and other + * issues can usefully be addressed by this framework. + */ // #define DEBUG // error path messages, extra info // #define VERBOSE // more; success messages @@ -302,77 +221,6 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) EXPORT_SYMBOL_GPL(usbnet_skb_return); -#ifdef CONFIG_USB_PL2301 -#define HAVE_HARDWARE - -/*------------------------------------------------------------------------- - * - * Prolific PL-2301/PL-2302 driver ... http://www.prolifictech.com - * - * The protocol and handshaking used here should be bug-compatible - * with the Linux 2.2 "plusb" driver, by Deti Fliegl. - * - *-------------------------------------------------------------------------*/ - -/* - * Bits 0-4 can be used for software handshaking; they're set from - * one end, cleared from the other, "read" with the interrupt byte. - */ -#define PL_S_EN (1<<7) /* (feature only) suspend enable */ -/* reserved bit -- rx ready (6) ? */ -#define PL_TX_READY (1<<5) /* (interrupt only) transmit ready */ -#define PL_RESET_OUT (1<<4) /* reset output pipe */ -#define PL_RESET_IN (1<<3) /* reset input pipe */ -#define PL_TX_C (1<<2) /* transmission complete */ -#define PL_TX_REQ (1<<1) /* transmission received */ -#define PL_PEER_E (1<<0) /* peer exists */ - -static inline int -pl_vendor_req (struct usbnet *dev, u8 req, u8 val, u8 index) -{ - return usb_control_msg (dev->udev, - usb_rcvctrlpipe (dev->udev, 0), - req, - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - val, index, - NULL, 0, - USB_CTRL_GET_TIMEOUT); -} - -static inline int -pl_clear_QuickLink_features (struct usbnet *dev, int val) -{ - return pl_vendor_req (dev, 1, (u8) val, 0); -} - -static inline int -pl_set_QuickLink_features (struct usbnet *dev, int val) -{ - return pl_vendor_req (dev, 3, (u8) val, 0); -} - -/*-------------------------------------------------------------------------*/ - -static int pl_reset (struct usbnet *dev) -{ - /* some units seem to need this reset, others reject it utterly. - * FIXME be more like "naplink" or windows drivers. - */ - (void) pl_set_QuickLink_features (dev, - PL_S_EN|PL_RESET_OUT|PL_RESET_IN|PL_PEER_E); - return 0; -} - -static const struct driver_info prolific_info = { - .description = "Prolific PL-2301/PL-2302", - .flags = FLAG_NO_SETINT, - /* some PL-2302 versions seem to fail usb_set_interface() */ - .reset = pl_reset, -}; - -#endif /* CONFIG_USB_PL2301 */ - - /*------------------------------------------------------------------------- * * Network Device Driver (peer link to "Host Device", from USB host) @@ -1356,60 +1204,22 @@ EXPORT_SYMBOL_GPL(usbnet_resume); /*-------------------------------------------------------------------------*/ -#ifndef HAVE_HARDWARE -#error You need to configure some hardware for this driver -#endif - -/* - * chip vendor names won't normally be on the cables, and - * may not be on the device. - */ - -static const struct usb_device_id products [] = { - -#ifdef CONFIG_USB_PL2301 -{ - USB_DEVICE (0x067b, 0x0000), // PL-2301 - .driver_info = (unsigned long) &prolific_info, -}, { - USB_DEVICE (0x067b, 0x0001), // PL-2302 - .driver_info = (unsigned long) &prolific_info, -}, -#endif - { }, // END -}; -MODULE_DEVICE_TABLE (usb, products); - -static struct usb_driver usbnet_driver = { - .owner = THIS_MODULE, - .name = driver_name, - .id_table = products, - .probe = usbnet_probe, - .disconnect = usbnet_disconnect, - .suspend = usbnet_suspend, - .resume = usbnet_resume, -}; - -/*-------------------------------------------------------------------------*/ - static int __init usbnet_init(void) { - // compiler should optimize these out + /* compiler should optimize this out */ BUG_ON (sizeof (((struct sk_buff *)0)->cb) < sizeof (struct skb_data)); random_ether_addr(node_id); - - return usb_register(&usbnet_driver); + return 0; } module_init(usbnet_init); static void __exit usbnet_exit(void) { - usb_deregister(&usbnet_driver); } module_exit(usbnet_exit); MODULE_AUTHOR("David Brownell"); -MODULE_DESCRIPTION("USB Host-to-Host Link Drivers (numerous vendors)"); +MODULE_DESCRIPTION("USB network driver framework"); MODULE_LICENSE("GPL"); -- cgit v0.10.2 From e09711aef4180002241c7f2eab37390ddf40d6a0 Mon Sep 17 00:00:00 2001 From: "david-b@pacbell.net" Date: Sat, 13 Aug 2005 18:41:04 -0700 Subject: [PATCH] ehci: add think_time This adds think_time to the usb_tt struct and sets it appropriately (measured in ns); this can help us implement better split transaction scheduling. Signed-off-by: Dan Streetman Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 9f54e83..758c7f0 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -627,19 +627,33 @@ static int hub_configure(struct usb_hub *hub, break; } + /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */ switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_TTTT) { - case 0x00: - if (hdev->descriptor.bDeviceProtocol != 0) - dev_dbg(hub_dev, "TT requires at most 8 FS bit times\n"); + case HUB_TTTT_8_BITS: + if (hdev->descriptor.bDeviceProtocol != 0) { + hub->tt.think_time = 666; + dev_dbg(hub_dev, "TT requires at most %d " + "FS bit times (%d ns)\n", + 8, hub->tt.think_time); + } break; - case 0x20: - dev_dbg(hub_dev, "TT requires at most 16 FS bit times\n"); + case HUB_TTTT_16_BITS: + hub->tt.think_time = 666 * 2; + dev_dbg(hub_dev, "TT requires at most %d " + "FS bit times (%d ns)\n", + 16, hub->tt.think_time); break; - case 0x40: - dev_dbg(hub_dev, "TT requires at most 24 FS bit times\n"); + case HUB_TTTT_24_BITS: + hub->tt.think_time = 666 * 3; + dev_dbg(hub_dev, "TT requires at most %d " + "FS bit times (%d ns)\n", + 24, hub->tt.think_time); break; - case 0x60: - dev_dbg(hub_dev, "TT requires at most 32 FS bit times\n"); + case HUB_TTTT_32_BITS: + hub->tt.think_time = 666 * 4; + dev_dbg(hub_dev, "TT requires at most %d " + "FS bit times (%d ns)\n", + 32, hub->tt.think_time); break; } diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index 53bf564..e7fa9b5 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h @@ -157,6 +157,12 @@ enum hub_led_mode { struct usb_device; +/* Transaction Translator Think Times, in bits */ +#define HUB_TTTT_8_BITS 0x00 +#define HUB_TTTT_16_BITS 0x20 +#define HUB_TTTT_24_BITS 0x40 +#define HUB_TTTT_32_BITS 0x60 + /* * As of USB 2.0, full/low speed devices are segregated into trees. * One type grows from USB 1.1 host controllers (OHCI, UHCI etc). @@ -170,6 +176,7 @@ struct usb_device; struct usb_tt { struct usb_device *hub; /* upstream highspeed hub */ int multi; /* true means one TT per port */ + unsigned think_time; /* think time in ns */ /* for control/bulk error recovery (CLEAR_TT_BUFFER) */ spinlock_t lock; -- cgit v0.10.2 From d0384200f6b608e77fb5ddf7dfae1bf0e42c1c6e Mon Sep 17 00:00:00 2001 From: "david-b@pacbell.net" Date: Sat, 13 Aug 2005 18:44:58 -0700 Subject: [PATCH] ehci: add tt_usecs This adds the field tt_usecs to ehci_qh and ehci_iso_stream, and sets it appropriately when setting them up as periodic endpoints. It records the transation translator's think_time (added in last patch) plus the downstream (i.e. low or full speed) bustime of the transfer associated with each interrupt or iso frame, as calculated by usb_calc_bus_time. Signed-off-by: Dan Streetman Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 20df01a..940d38c 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c @@ -677,6 +677,9 @@ qh_make ( goto done; } } else { + struct usb_tt *tt = urb->dev->tt; + int think_time; + /* gap is f(FS/LS transfer times) */ qh->gap_uf = 1 + usb_calc_bus_time (urb->dev->speed, is_input, 0, maxp) / (125 * 1000); @@ -690,6 +693,10 @@ qh_make ( qh->c_usecs = HS_USECS (0); } + think_time = tt ? tt->think_time : 0; + qh->tt_usecs = NS_TO_US (think_time + + usb_calc_bus_time (urb->dev->speed, + is_input, 0, max_packet (maxp))); qh->period = urb->interval; } } diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 4c972b5..ccc7300 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c @@ -700,6 +700,7 @@ iso_stream_init ( } else { u32 addr; + int think_time; addr = dev->ttport << 24; if (!ehci_is_TDI(ehci) @@ -709,6 +710,9 @@ iso_stream_init ( addr |= epnum << 8; addr |= dev->devnum; stream->usecs = HS_USECS_ISO (maxp); + think_time = dev->tt ? dev->tt->think_time : 0; + stream->tt_usecs = NS_TO_US (think_time + usb_calc_bus_time ( + dev->speed, is_input, 1, maxp)); if (is_input) { u32 tmp; diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index a754215..20c9b55 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -421,6 +421,7 @@ struct ehci_qh { u8 usecs; /* intr bandwidth */ u8 gap_uf; /* uframes split/csplit gap */ u8 c_usecs; /* ... split completion bw */ + u16 tt_usecs; /* tt downstream bandwidth */ unsigned short period; /* polling interval */ unsigned short start; /* where polling starts */ #define NO_FRAME ((unsigned short)~0) /* pick new start */ @@ -479,6 +480,7 @@ struct ehci_iso_stream { */ u8 interval; u8 usecs, c_usecs; + u16 tt_usecs; u16 maxp; u16 raw_mask; unsigned bandwidth; -- cgit v0.10.2 From 0256839619d9b1e933cafc83e7f0deaad4216465 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Mon, 15 Aug 2005 16:53:57 -0700 Subject: [PATCH] usbmon in 2.6.13: peeking into DMA areas This code looks at urb->transfer_dma, maps the page and takes the data. I am looking for volunteers to contribute architectures other than i386 or to develop an architecure-neutral API for it (or point me that it was done already). Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/mon/Makefile b/drivers/usb/mon/Makefile index b0015b8..3cf3ea3a 100644 --- a/drivers/usb/mon/Makefile +++ b/drivers/usb/mon/Makefile @@ -2,7 +2,7 @@ # Makefile for USB Core files and filesystem # -usbmon-objs := mon_main.o mon_stat.o mon_text.o +usbmon-objs := mon_main.o mon_stat.o mon_text.o mon_dma.o # This does not use CONFIG_USB_MON because we want this to use a tristate. obj-$(CONFIG_USB) += usbmon.o diff --git a/drivers/usb/mon/mon_dma.c b/drivers/usb/mon/mon_dma.c new file mode 100644 index 0000000..0a1367b --- /dev/null +++ b/drivers/usb/mon/mon_dma.c @@ -0,0 +1,55 @@ +/* + * The USB Monitor, inspired by Dave Harding's USBMon. + * + * mon_dma.c: Library which snoops on DMA areas. + * + * Copyright (C) 2005 Pete Zaitcev (zaitcev@redhat.com) + */ +#include +#include +#include +#include + +#include /* Only needed for declarations in usb_mon.h */ +#include "usb_mon.h" + +#ifdef __i386__ /* CONFIG_ARCH_I386 does not exit */ +#define MON_HAS_UNMAP 1 + +#define phys_to_page(phys) pfn_to_page((phys) >> PAGE_SHIFT) + +char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len) +{ + struct page *pg; + unsigned long flags; + unsigned char *map; + unsigned char *ptr; + + /* + * On i386, a DMA handle is the "physical" address of a page. + * In other words, the bus address is equal to physical address. + * There is no IOMMU. + */ + pg = phys_to_page(dma_addr); + + /* + * We are called from hardware IRQs in case of callbacks. + * But we can be called from softirq or process context in case + * of submissions. In such case, we need to protect KM_IRQ0. + */ + local_irq_save(flags); + map = kmap_atomic(pg, KM_IRQ0); + ptr = map + (dma_addr & (PAGE_SIZE-1)); + memcpy(dst, ptr, len); + kunmap_atomic(map, KM_IRQ0); + local_irq_restore(flags); + return 0; +} +#endif /* __i386__ */ + +#ifndef MON_HAS_UNMAP +char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len) +{ + return 'D'; +} +#endif diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c index 26266b30..417464d 100644 --- a/drivers/usb/mon/mon_text.c +++ b/drivers/usb/mon/mon_text.c @@ -91,25 +91,11 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb, int len, char ev_type) { int pipe = urb->pipe; - unsigned char *data; - - /* - * The check to see if it's safe to poke at data has an enormous - * number of corner cases, but it seems that the following is - * more or less safe. - * - * We do not even try to look transfer_buffer, because it can - * contain non-NULL garbage in case the upper level promised to - * set DMA for the HCD. - */ - if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) - return 'D'; if (len <= 0) return 'L'; - - if ((data = urb->transfer_buffer) == NULL) - return 'Z'; /* '0' would be not as pretty. */ + if (len >= DATA_MAX) + len = DATA_MAX; /* * Bulk is easy to shortcut reliably. @@ -126,8 +112,21 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb, } } - if (len >= DATA_MAX) - len = DATA_MAX; + /* + * The check to see if it's safe to poke at data has an enormous + * number of corner cases, but it seems that the following is + * more or less safe. + * + * We do not even try to look transfer_buffer, because it can + * contain non-NULL garbage in case the upper level promised to + * set DMA for the HCD. + */ + if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) + return mon_dmapeek(ep->data, urb->transfer_dma, len); + + if (urb->transfer_buffer == NULL) + return 'Z'; /* '0' would be not as pretty. */ + memcpy(ep->data, urb->transfer_buffer, len); return 0; } diff --git a/drivers/usb/mon/usb_mon.h b/drivers/usb/mon/usb_mon.h index 9b06784..4be0f93 100644 --- a/drivers/usb/mon/usb_mon.h +++ b/drivers/usb/mon/usb_mon.h @@ -45,6 +45,10 @@ struct mon_reader { void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r); void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r); +/* + */ +extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len); + extern struct semaphore mon_lock; extern struct file_operations mon_fops_text; -- cgit v0.10.2 From d6450e19329c85ac4888c185429094236a650928 Mon Sep 17 00:00:00 2001 From: Nick Sillik Date: Wed, 17 Aug 2005 13:37:34 -0400 Subject: [PATCH] USB Storage: code cleanups for onetouch.c As sugested by Alan Stern here are a few code cleanups for onetouch.c: -Check number of endpoints before directly referencing intf->endpoint[2] -Use defined constants instead of magic numbers -Revmove the non-ascii characters from copyright notice -Make registration and deregistration messages more similar Signed-off-by: Nick Sillik Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index 07fd29c..2c9402d 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c @@ -5,7 +5,7 @@ * Copyright (c) 2005 Nick Sillik * * Initial work by: - * Copyright (c) 2003 Erik Thyrén + * Copyright (c) 2003 Erik Thyren * * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann) * @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include "usb.h" #include "onetouch.h" #include "debug.h" @@ -116,10 +118,14 @@ int onetouch_connect_input(struct us_data *ss) interface = ss->pusb_intf->cur_altsetting; + if (interface->desc.bNumEndpoints != 3) + return -ENODEV; + endpoint = &interface->endpoint[2].desc; - if(!(endpoint->bEndpointAddress & 0x80)) + if(!(endpoint->bEndpointAddress & USB_DIR_IN)) return -ENODEV; - if((endpoint->bmAttributes & 3) != 3) + if((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) + != USB_ENDPOINT_XFER_INT) return -ENODEV; pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); @@ -128,7 +134,8 @@ int onetouch_connect_input(struct us_data *ss) if (!(onetouch = kcalloc(1, sizeof(struct usb_onetouch), GFP_KERNEL))) return -ENOMEM; - onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, SLAB_ATOMIC, &onetouch->data_dma); + onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, + SLAB_ATOMIC, &onetouch->data_dma); if (!onetouch->data){ kfree(onetouch); return -ENOMEM; @@ -137,7 +144,8 @@ int onetouch_connect_input(struct us_data *ss) onetouch->irq = usb_alloc_urb(0, GFP_KERNEL); if (!onetouch->irq){ kfree(onetouch); - usb_buffer_free(udev, ONETOUCH_PKT_LEN, onetouch->data, onetouch->data_dma); + usb_buffer_free(udev, ONETOUCH_PKT_LEN, + onetouch->data, onetouch->data_dma); return -ENODEV; } @@ -152,16 +160,13 @@ int onetouch_connect_input(struct us_data *ss) onetouch->dev.open = usb_onetouch_open; onetouch->dev.close = usb_onetouch_close; - usb_make_path(udev, path, 64); + usb_make_path(udev, path, sizeof(path)); sprintf(onetouch->phys, "%s/input0", path); onetouch->dev.name = onetouch->name; onetouch->dev.phys = onetouch->phys; - onetouch->dev.id.bustype = BUS_USB; - onetouch->dev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); - onetouch->dev.id.product = le16_to_cpu(udev->descriptor.idProduct); - onetouch->dev.id.version = le16_to_cpu(udev->descriptor.bcdDevice); + usb_to_input_id(udev, &onetouch->dev.id); onetouch->dev.dev = &udev->dev; @@ -199,7 +204,7 @@ void onetouch_release_input(void *onetouch_) usb_free_urb(onetouch->irq); usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN, onetouch->data, onetouch->data_dma); - printk(KERN_INFO "Maxtor Onetouch %04x:%04x Deregistered\n", - onetouch->dev.id.vendor, onetouch->dev.id.product); + printk(KERN_INFO "usb-input: deregistering %s\n", + onetouch->dev.name); } } -- cgit v0.10.2 From aca951a22a1d93ebe31b54052b3eb9a8196df2fc Mon Sep 17 00:00:00 2001 From: Henk Date: Tue, 16 Aug 2005 16:17:43 +0200 Subject: [PATCH] input-driver-yealink-P1K-usb-phone This patch aggregates all modifications in the -mm tree and adds complete ringtone support. The following features are supported: - keyboard full support - LCD full support - LED full support - dialtone full support - ringtone full support - audio playback via generic usb audio diver - audio record via generic usb audio diver For driver documentation see: Documentation/input/yealink.txt For vendor documentation see: http://yealink.com Signed-off-by: Henk Signed-off-by: Greg Kroah-Hartman diff --git a/Documentation/input/yealink.txt b/Documentation/input/yealink.txt new file mode 100644 index 0000000..5665c32 --- /dev/null +++ b/Documentation/input/yealink.txt @@ -0,0 +1,187 @@ +yealink - Linux driver for usb-p1k phones + +0. Status +~~~~~~~~~ + +The p1k is a relatively cheap usb 1.1 phone with: + - keyboard full support + - LCD full support + - LED full support + - dialtone full support + - ringtone full support + - audio playback via generic usb audio diver + - audio record via generic usb audio diver + + +1. Compilation (stand alone version) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Currently only kernel 2.6.x.y versions are supported. +In order to build the yealink.ko module do: + + make + +If you encounter problems please check if in the MAKE_OPTS variable in +the Makefile is pointing to the location where your kernel sources +are located, default /usr/src/linux. + + + +2. keyboard features +~~~~~~~~~~~~~~~~~~~~ +The current mapping in the kernel is provided by the map_p1k_to_key +function: + + Physical USB-P1K button layout input events + + + up up + IN OUT left, right + down down + + pickup C hangup enter, backspace, escape + 1 2 3 1, 2, 3 + 4 5 6 4, 5, 6, + 7 8 9 7, 8, 9, + * 0 # *, 0, #, + + The "up" and "down" keys, are symbolised by arrows on the button. + The "pickup" and "hangup" keys are symbolised by a green and red phone + on the button. + + +3. LCD features +~~~~~~~~~~~~~~~ +The LCD is divided and organised as a 3 line display: + + |[] [][] [][] [][] in |[][] + |[] M [][] D [][] : [][] out |[][] + store + + NEW REP SU MO TU WE TH FR SA + + [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] + + +Line 1 Format (see below) : 18.e8.M8.88...188 + Icon names : M D : IN OUT STORE +Line 2 Format : ......... + Icon name : NEW REP SU MO TU WE TH FR SA +Line 3 Format : 888888888888 + + +Format description: + From a user space perspective the world is seperated in "digits" and "icons". + A digit can have a character set, an icon can only be ON or OFF. + + Format specifier + '8' : Generic 7 segment digit with individual addressable segments + + Reduced capabillity 7 segm digit, when segments are hard wired together. + '1' : 2 segments digit only able to produce a 1. + 'e' : Most significant day of the month digit, + able to produce at least 1 2 3. + 'M' : Most significant minute digit, + able to produce at least 0 1 2 3 4 5. + + Icons or pictograms: + '.' : For example like AM, PM, SU, a 'dot' .. or other single segment + elements. + + +4. Driver usage +~~~~~~~~~~~~~~~ +For userland the following interfaces are available using the sysfs interface: + /sys/.../ + line1 Read/Write, lcd line1 + line2 Read/Write, lcd line2 + line3 Read/Write, lcd line3 + + get_icons Read, returns a set of available icons. + hide_icon Write, hide the element by writing the icon name. + show_icon Write, display the element by writing the icon name. + + map_seg7 Read/Write, the 7 segments char set, common for all + yealink phones. (see map_to_7segment.h) + + ringtone Write, upload binary representation of a ringtone, + see yealink.c. status EXPERIMENTAL due to potential + races between async. and sync usb calls. + + +4.1 lineX +~~~~~~~~~ +Reading /sys/../lineX will return the format string with its current value: + + Example: + cat ./line3 + 888888888888 + Linux Rocks! + +Writing to /sys/../lineX will set the coresponding LCD line. + - Excess characters are ignored. + - If less characters are written than allowed, the remaining digits are + unchanged. + - The tab '\t'and '\n' char does not overwrite the original content. + - Writing a space to an icon will always hide its content. + + Example: + date +"%m.%e.%k:%M" | sed 's/^0/ /' > ./line1 + + Will update the LCD with the current date & time. + + +4.2 get_icons +~~~~~~~~~~~~~ +Reading will return all available icon names and its current settings: + + cat ./get_icons + on M + on D + on : + IN + OUT + STORE + NEW + REP + SU + MO + TU + WE + TH + FR + SA + LED + DIALTONE + RINGTONE + + +4.3 show/hide icons +~~~~~~~~~~~~~~~~~~~ +Writing to these files will update the state of the icon. +Only one icon at a time can be updated. + +If an icon is also on a ./lineX the corresponding value is +updated with the first letter of the icon. + + Example - light up the store icon: + echo -n "STORE" > ./show_icon + + cat ./line1 + 18.e8.M8.88...188 + S + + Example - sound the ringtone for 10 seconds: + echo -n RINGTONE > /sys/..../show_icon + sleep 10 + echo -n RINGTONE > /sys/..../hide_icon + + +5. Credits & Acknowledgments +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + - Olivier Vandorpe, for starting the usbb2k-api project doing much of + the reverse engineering. + - Martin Diehl, for pointing out how to handle USB memory allocation. + - Dmitry Torokhov, for the numerous code reviews and suggestions. + diff --git a/MAINTAINERS b/MAINTAINERS index 8e4e829..96ddac7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -116,6 +116,12 @@ M: ajk@iehk.rwth-aachen.de L: linux-hams@vger.kernel.org S: Maintained +YEALINK PHONE DRIVER +P: Henk Vergonet +M: Henk.Vergonet@gmail.com +L: usbb2k-api-dev@nongnu.org +S: Maintained + 8139CP 10/100 FAST ETHERNET DRIVER P: Jeff Garzik M: jgarzik@pobox.com diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig index 298e4a2..482c4be 100644 --- a/drivers/usb/input/Kconfig +++ b/drivers/usb/input/Kconfig @@ -230,6 +230,20 @@ config USB_EGALAX To compile this driver as a module, choose M here: the module will be called touchkitusb. +config USB_YEALINK + tristate "Yealink usb-p1k voip phone" + depends on USB && INPUT && EXPERIMENTAL + ---help--- + Say Y here if you want to enable keyboard and LCD functions of the + Yealink usb-p1k usb phones. The audio part is enabled by the generic + usb sound driver, so you might want to enable that as well. + + For information about how to use these additional functions, see + . + + To compile this driver as a module, choose M here: the module will be + called yealink. + config USB_XPAD tristate "X-Box gamepad support" depends on USB && INPUT diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile index f1547be..43b2f99 100644 --- a/drivers/usb/input/Makefile +++ b/drivers/usb/input/Makefile @@ -39,4 +39,5 @@ obj-$(CONFIG_USB_EGALAX) += touchkitusb.o obj-$(CONFIG_USB_POWERMATE) += powermate.o obj-$(CONFIG_USB_WACOM) += wacom.o obj-$(CONFIG_USB_ACECAD) += acecad.o +obj-$(CONFIG_USB_YEALINK) += yealink.o obj-$(CONFIG_USB_XPAD) += xpad.o diff --git a/drivers/usb/input/map_to_7segment.h b/drivers/usb/input/map_to_7segment.h new file mode 100644 index 0000000..52ff27f --- /dev/null +++ b/drivers/usb/input/map_to_7segment.h @@ -0,0 +1,189 @@ +/* + * drivers/usb/input/map_to_7segment.h + * + * Copyright (c) 2005 Henk Vergonet + * + * 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 + */ + +#ifndef MAP_TO_7SEGMENT_H +#define MAP_TO_7SEGMENT_H + +/* This file provides translation primitives and tables for the conversion + * of (ASCII) characters to a 7-segments notation. + * + * The 7 segment's wikipedia notation below is used as standard. + * See: http://en.wikipedia.org/wiki/Seven_segment_display + * + * Notation: +-a-+ + * f b + * +-g-+ + * e c + * +-d-+ + * + * Usage: + * + * Register a map variable, and fill it with a character set: + * static SEG7_DEFAULT_MAP(map_seg7); + * + * + * Then use for conversion: + * seg7 = map_to_seg7(&map_seg7, some_char); + * ... + * + * In device drivers it is recommended, if required, to make the char map + * accessible via the sysfs interface using the following scheme: + * + * static ssize_t show_map(struct device *dev, char *buf) { + * memcpy(buf, &map_seg7, sizeof(map_seg7)); + * return sizeof(map_seg7); + * } + * static ssize_t store_map(struct device *dev, const char *buf, size_t cnt) { + * if(cnt != sizeof(map_seg7)) + * return -EINVAL; + * memcpy(&map_seg7, buf, cnt); + * return cnt; + * } + * static DEVICE_ATTR(map_seg7, PERMS_RW, show_map, store_map); + * + * History: + * 2005-05-31 RFC linux-kernel@vger.kernel.org + */ +#include + + +#define BIT_SEG7_A 0 +#define BIT_SEG7_B 1 +#define BIT_SEG7_C 2 +#define BIT_SEG7_D 3 +#define BIT_SEG7_E 4 +#define BIT_SEG7_F 5 +#define BIT_SEG7_G 6 +#define BIT_SEG7_RESERVED 7 + +struct seg7_conversion_map { + unsigned char table[128]; +}; + +static inline int map_to_seg7(struct seg7_conversion_map *map, int c) +{ + return c & 0x7f ? map->table[c] : -EINVAL; +} + +#define SEG7_CONVERSION_MAP(_name, _map) \ + struct seg7_conversion_map _name = { .table = { _map } } + +/* + * It is recommended to use a facility that allows user space to redefine + * custom character sets for LCD devices. Please use a sysfs interface + * as described above. + */ +#define MAP_TO_SEG7_SYSFS_FILE "map_seg7" + +/******************************************************************************* + * ASCII conversion table + ******************************************************************************/ + +#define _SEG7(l,a,b,c,d,e,f,g) \ + ( a<',1,1,0,0,0,0,1), _SEG7('?',1,1,1,0,0,1,0),\ + _SEG7('@',1,1,0,1,1,1,1), + +#define _MAP_65_90_ASCII_SEG7_ALPHA_UPPR \ + _SEG7('A',1,1,1,0,1,1,1), _SEG7('B',1,1,1,1,1,1,1), _SEG7('C',1,0,0,1,1,1,0),\ + _SEG7('D',1,1,1,1,1,1,0), _SEG7('E',1,0,0,1,1,1,1), _SEG7('F',1,0,0,0,1,1,1),\ + _SEG7('G',1,1,1,1,0,1,1), _SEG7('H',0,1,1,0,1,1,1), _SEG7('I',0,1,1,0,0,0,0),\ + _SEG7('J',0,1,1,1,0,0,0), _SEG7('K',0,1,1,0,1,1,1), _SEG7('L',0,0,0,1,1,1,0),\ + _SEG7('M',1,1,1,0,1,1,0), _SEG7('N',1,1,1,0,1,1,0), _SEG7('O',1,1,1,1,1,1,0),\ + _SEG7('P',1,1,0,0,1,1,1), _SEG7('Q',1,1,1,1,1,1,0), _SEG7('R',1,1,1,0,1,1,1),\ + _SEG7('S',1,0,1,1,0,1,1), _SEG7('T',0,0,0,1,1,1,1), _SEG7('U',0,1,1,1,1,1,0),\ + _SEG7('V',0,1,1,1,1,1,0), _SEG7('W',0,1,1,1,1,1,1), _SEG7('X',0,1,1,0,1,1,1),\ + _SEG7('Y',0,1,1,0,0,1,1), _SEG7('Z',1,1,0,1,1,0,1), + +#define _MAP_91_96_ASCII_SEG7_SYMBOL \ + _SEG7('[',1,0,0,1,1,1,0), _SEG7('\\',0,0,1,0,0,1,1),_SEG7(']',1,1,1,1,0,0,0),\ + _SEG7('^',1,1,0,0,0,1,0), _SEG7('_',0,0,0,1,0,0,0), _SEG7('`',0,1,0,0,0,0,0), + +#define _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \ + _SEG7('A',1,1,1,0,1,1,1), _SEG7('b',0,0,1,1,1,1,1), _SEG7('c',0,0,0,1,1,0,1),\ + _SEG7('d',0,1,1,1,1,0,1), _SEG7('E',1,0,0,1,1,1,1), _SEG7('F',1,0,0,0,1,1,1),\ + _SEG7('G',1,1,1,1,0,1,1), _SEG7('h',0,0,1,0,1,1,1), _SEG7('i',0,0,1,0,0,0,0),\ + _SEG7('j',0,0,1,1,0,0,0), _SEG7('k',0,0,1,0,1,1,1), _SEG7('L',0,0,0,1,1,1,0),\ + _SEG7('M',1,1,1,0,1,1,0), _SEG7('n',0,0,1,0,1,0,1), _SEG7('o',0,0,1,1,1,0,1),\ + _SEG7('P',1,1,0,0,1,1,1), _SEG7('q',1,1,1,0,0,1,1), _SEG7('r',0,0,0,0,1,0,1),\ + _SEG7('S',1,0,1,1,0,1,1), _SEG7('T',0,0,0,1,1,1,1), _SEG7('u',0,0,1,1,1,0,0),\ + _SEG7('v',0,0,1,1,1,0,0), _SEG7('W',0,1,1,1,1,1,1), _SEG7('X',0,1,1,0,1,1,1),\ + _SEG7('y',0,1,1,1,0,1,1), _SEG7('Z',1,1,0,1,1,0,1), + +#define _MAP_123_126_ASCII_SEG7_SYMBOL \ + _SEG7('{',1,0,0,1,1,1,0), _SEG7('|',0,0,0,0,1,1,0), _SEG7('}',1,1,1,1,0,0,0),\ + _SEG7('~',1,0,0,0,0,0,0), + +/* Maps */ + +/* This set tries to map as close as possible to the visible characteristics + * of the ASCII symbol, lowercase and uppercase letters may differ in + * presentation on the display. + */ +#define MAP_ASCII7SEG_ALPHANUM \ + _MAP_0_32_ASCII_SEG7_NON_PRINTABLE \ + _MAP_33_47_ASCII_SEG7_SYMBOL \ + _MAP_48_57_ASCII_SEG7_NUMERIC \ + _MAP_58_64_ASCII_SEG7_SYMBOL \ + _MAP_65_90_ASCII_SEG7_ALPHA_UPPR \ + _MAP_91_96_ASCII_SEG7_SYMBOL \ + _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \ + _MAP_123_126_ASCII_SEG7_SYMBOL + +/* This set tries to map as close as possible to the symbolic characteristics + * of the ASCII character for maximum discrimination. + * For now this means all alpha chars are in lower case representations. + * (This for example facilitates the use of hex numbers with uppercase input.) + */ +#define MAP_ASCII7SEG_ALPHANUM_LC \ + _MAP_0_32_ASCII_SEG7_NON_PRINTABLE \ + _MAP_33_47_ASCII_SEG7_SYMBOL \ + _MAP_48_57_ASCII_SEG7_NUMERIC \ + _MAP_58_64_ASCII_SEG7_SYMBOL \ + _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \ + _MAP_91_96_ASCII_SEG7_SYMBOL \ + _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \ + _MAP_123_126_ASCII_SEG7_SYMBOL + +#define SEG7_DEFAULT_MAP(_name) \ + SEG7_CONVERSION_MAP(_name,MAP_ASCII7SEG_ALPHANUM) + +#endif /* MAP_TO_7SEGMENT_H */ + diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c new file mode 100644 index 0000000..0748281 --- /dev/null +++ b/drivers/usb/input/yealink.c @@ -0,0 +1,1010 @@ +/* + * drivers/usb/input/yealink.c + * + * Copyright (c) 2005 Henk Vergonet + * + * 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 + */ +/* + * Description: + * Driver for the USB-P1K voip usb phone. + * This device is produced by Yealink Network Technology Co Ltd + * but may be branded under several names: + * - Yealink usb-p1k + * - Tiptel 115 + * - ... + * + * This driver is based on: + * - the usbb2k-api http://savannah.nongnu.org/projects/usbb2k-api/ + * - information from http://memeteau.free.fr/usbb2k + * - the xpad-driver drivers/usb/input/xpad.c + * + * Thanks to: + * - Olivier Vandorpe, for providing the usbb2k-api. + * - Martin Diehl, for spotting my memory allocation bug. + * + * History: + * 20050527 henk First version, functional keyboard. Keyboard events + * will pop-up on the ../input/eventX bus. + * 20050531 henk Added led, LCD, dialtone and sysfs interface. + * 20050610 henk Cleanups, make it ready for public consumption. + * 20050630 henk Cleanups, fixes in response to comments. + * 20050701 henk sysfs write serialisation, fix potential unload races + * 20050801 henk Added ringtone, restructure USB + * 20050816 henk Merge 2.6.13-rc6 + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "map_to_7segment.h" +#include "yealink.h" + +#define DRIVER_VERSION "yld-20050816" +#define DRIVER_AUTHOR "Henk Vergonet" +#define DRIVER_DESC "Yealink phone driver" + +#define YEALINK_POLLING_FREQUENCY 10 /* in [Hz] */ + +struct yld_status { + u8 lcd[24]; + u8 led; + u8 dialtone; + u8 ringtone; + u8 keynum; +} __attribute__ ((packed)); + +/* + * Register the LCD segment and icon map + */ +#define _LOC(k,l) { .a = (k), .m = (l) } +#define _SEG(t, a, am, b, bm, c, cm, d, dm, e, em, f, fm, g, gm) \ + { .type = (t), \ + .u = { .s = { _LOC(a, am), _LOC(b, bm), _LOC(c, cm), \ + _LOC(d, dm), _LOC(e, em), _LOC(g, gm), \ + _LOC(f, fm) } } } +#define _PIC(t, h, hm, n) \ + { .type = (t), \ + .u = { .p = { .name = (n), .a = (h), .m = (hm) } } } + +static const struct lcd_segment_map { + char type; + union { + struct pictogram_map { + u8 a,m; + char name[10]; + } p; + struct segment_map { + u8 a,m; + } s[7]; + } u; +} lcdMap[] = { +#include "yealink.h" +}; + +struct yealink_dev { + struct input_dev idev; /* input device */ + struct usb_device *udev; /* usb device */ + + /* irq input channel */ + struct yld_ctl_packet *irq_data; + dma_addr_t irq_dma; + struct urb *urb_irq; + + /* control output channel */ + struct yld_ctl_packet *ctl_data; + dma_addr_t ctl_dma; + struct usb_ctrlrequest *ctl_req; + dma_addr_t ctl_req_dma; + struct urb *urb_ctl; + + char phys[64]; /* physical device path */ + + u8 lcdMap[ARRAY_SIZE(lcdMap)]; /* state of LCD, LED ... */ + int key_code; /* last reported key */ + + int stat_ix; + union { + struct yld_status s; + u8 b[sizeof(struct yld_status)]; + } master, copy; +}; + + +/******************************************************************************* + * Yealink lcd interface + ******************************************************************************/ + +/* + * Register a default 7 segment character set + */ +static SEG7_DEFAULT_MAP(map_seg7); + + /* Display a char, + * char '\9' and '\n' are placeholders and do not overwrite the original text. + * A space will always hide an icon. + */ +static int setChar(struct yealink_dev *yld, int el, int chr) +{ + int i, a, m, val; + + if (el >= ARRAY_SIZE(lcdMap)) + return -EINVAL; + + if (chr == '\t' || chr == '\n') + return 0; + + yld->lcdMap[el] = chr; + + if (lcdMap[el].type == '.') { + a = lcdMap[el].u.p.a; + m = lcdMap[el].u.p.m; + if (chr != ' ') + yld->master.b[a] |= m; + else + yld->master.b[a] &= ~m; + return 0; + } + + val = map_to_seg7(&map_seg7, chr); + for (i = 0; i < ARRAY_SIZE(lcdMap[0].u.s); i++) { + m = lcdMap[el].u.s[i].m; + + if (m == 0) + continue; + + a = lcdMap[el].u.s[i].a; + if (val & 1) + yld->master.b[a] |= m; + else + yld->master.b[a] &= ~m; + val = val >> 1; + } + return 0; +}; + +/******************************************************************************* + * Yealink key interface + ******************************************************************************/ + +/* Map device buttons to internal key events. + * + * USB-P1K button layout: + * + * up + * IN OUT + * down + * + * pickup C hangup + * 1 2 3 + * 4 5 6 + * 7 8 9 + * * 0 # + * + * The "up" and "down" keys, are symbolised by arrows on the button. + * The "pickup" and "hangup" keys are symbolised by a green and red phone + * on the button. + */ +static int map_p1k_to_key(int scancode) +{ + switch(scancode) { /* phone key: */ + case 0x23: return KEY_LEFT; /* IN */ + case 0x33: return KEY_UP; /* up */ + case 0x04: return KEY_RIGHT; /* OUT */ + case 0x24: return KEY_DOWN; /* down */ + case 0x03: return KEY_ENTER; /* pickup */ + case 0x14: return KEY_BACKSPACE; /* C */ + case 0x13: return KEY_ESC; /* hangup */ + case 0x00: return KEY_1; /* 1 */ + case 0x01: return KEY_2; /* 2 */ + case 0x02: return KEY_3; /* 3 */ + case 0x10: return KEY_4; /* 4 */ + case 0x11: return KEY_5; /* 5 */ + case 0x12: return KEY_6; /* 6 */ + case 0x20: return KEY_7; /* 7 */ + case 0x21: return KEY_8; /* 8 */ + case 0x22: return KEY_9; /* 9 */ + case 0x30: return KEY_KPASTERISK; /* * */ + case 0x31: return KEY_0; /* 0 */ + case 0x32: return KEY_LEFTSHIFT | + KEY_3 << 8; /* # */ + } + return -EINVAL; +} + +/* Completes a request by converting the data into events for the + * input subsystem. + * + * The key parameter can be cascaded: key2 << 8 | key1 + */ +static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs) +{ + struct input_dev *idev = &yld->idev; + + input_regs(idev, regs); + if (yld->key_code >= 0) { + /* old key up */ + input_report_key(idev, yld->key_code & 0xff, 0); + if (yld->key_code >> 8) + input_report_key(idev, yld->key_code >> 8, 0); + } + + yld->key_code = key; + if (key >= 0) { + /* new valid key */ + input_report_key(idev, key & 0xff, 1); + if (key >> 8) + input_report_key(idev, key >> 8, 1); + } + input_sync(idev); +} + +/******************************************************************************* + * Yealink usb communication interface + ******************************************************************************/ + +static int yealink_cmd(struct yealink_dev *yld, struct yld_ctl_packet *p) +{ + u8 *buf = (u8 *)p; + int i; + u8 sum = 0; + + for(i=0; isum = sum; + return usb_control_msg(yld->udev, + usb_sndctrlpipe(yld->udev, 0), + USB_REQ_SET_CONFIGURATION, + USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, + 0x200, 3, + p, sizeof(*p), + USB_CTRL_SET_TIMEOUT); +} + +static u8 default_ringtone[] = { + 0xEF, /* volume [0-255] */ + 0xFB, 0x1E, 0x00, 0x0C, /* 1250 [hz], 12/100 [s] */ + 0xFC, 0x18, 0x00, 0x0C, /* 1000 [hz], 12/100 [s] */ + 0xFB, 0x1E, 0x00, 0x0C, + 0xFC, 0x18, 0x00, 0x0C, + 0xFB, 0x1E, 0x00, 0x0C, + 0xFC, 0x18, 0x00, 0x0C, + 0xFB, 0x1E, 0x00, 0x0C, + 0xFC, 0x18, 0x00, 0x0C, + 0xFF, 0xFF, 0x01, 0x90, /* silent, 400/100 [s] */ + 0x00, 0x00 /* end of sequence */ +}; + +static int yealink_set_ringtone(struct yealink_dev *yld, u8 *buf, size_t size) +{ + struct yld_ctl_packet *p = yld->ctl_data; + int ix, len; + + if (size <= 0) + return -EINVAL; + + /* Set the ringtone volume */ + memset(yld->ctl_data, 0, sizeof(*(yld->ctl_data))); + yld->ctl_data->cmd = CMD_RING_VOLUME; + yld->ctl_data->size = 1; + yld->ctl_data->data[0] = buf[0]; + yealink_cmd(yld, p); + + buf++; + size--; + + p->cmd = CMD_RING_NOTE; + ix = 0; + while (size != ix) { + len = size - ix; + if (len > sizeof(p->data)) + len = sizeof(p->data); + p->size = len; + p->offset = htons(ix); + memcpy(p->data, &buf[ix], len); + yealink_cmd(yld, p); + ix += len; + } + return 0; +} + +/* keep stat_master & stat_copy in sync. + */ +static int yealink_do_idle_tasks(struct yealink_dev *yld) +{ + u8 val; + int i, ix, len; + + ix = yld->stat_ix; + + memset(yld->ctl_data, 0, sizeof(*(yld->ctl_data))); + yld->ctl_data->cmd = CMD_KEYPRESS; + yld->ctl_data->size = 1; + yld->ctl_data->sum = 0xff - CMD_KEYPRESS; + + /* If state update pointer wraps do a KEYPRESS first. */ + if (ix >= sizeof(yld->master)) { + yld->stat_ix = 0; + return 0; + } + + /* find update candidates: copy != master */ + do { + val = yld->master.b[ix]; + if (val != yld->copy.b[ix]) + goto send_update; + } while (++ix < sizeof(yld->master)); + + /* nothing todo, wait a bit and poll for a KEYPRESS */ + yld->stat_ix = 0; + /* TODO how can we wait abit. ?? + * msleep_interruptible(1000 / YEALINK_POLLING_FREQUENCY); + */ + return 0; + +send_update: + + /* Setup an appropriate update request */ + yld->copy.b[ix] = val; + yld->ctl_data->data[0] = val; + + switch(ix) { + case offsetof(struct yld_status, led): + yld->ctl_data->cmd = CMD_LED; + yld->ctl_data->sum = -1 - CMD_LED - val; + break; + case offsetof(struct yld_status, dialtone): + yld->ctl_data->cmd = CMD_DIALTONE; + yld->ctl_data->sum = -1 - CMD_DIALTONE - val; + break; + case offsetof(struct yld_status, ringtone): + yld->ctl_data->cmd = CMD_RINGTONE; + yld->ctl_data->sum = -1 - CMD_RINGTONE - val; + break; + case offsetof(struct yld_status, keynum): + val--; + val &= 0x1f; + yld->ctl_data->cmd = CMD_SCANCODE; + yld->ctl_data->offset = htons(val); + yld->ctl_data->data[0] = 0; + yld->ctl_data->sum = -1 - CMD_SCANCODE - val; + break; + default: + len = sizeof(yld->master.s.lcd) - ix; + if (len > sizeof(yld->ctl_data->data)) + len = sizeof(yld->ctl_data->data); + + /* Combine up to consecutive LCD bytes in a singe request + */ + yld->ctl_data->cmd = CMD_LCD; + yld->ctl_data->offset = htons(ix); + yld->ctl_data->size = len; + yld->ctl_data->sum = -CMD_LCD - ix - val - len; + for(i=1; imaster.b[ix]; + yld->copy.b[ix] = val; + yld->ctl_data->data[i] = val; + yld->ctl_data->sum -= val; + } + } + yld->stat_ix = ix + 1; + return 1; +} + +/* Decide on how to handle responses + * + * The state transition diagram is somethhing like: + * + * syncState<--+ + * | | + * | idle + * \|/ | + * init --ok--> waitForKey --ok--> getKey + * ^ ^ | + * | +-------ok-------+ + * error,start + * + */ +static void urb_irq_callback(struct urb *urb, struct pt_regs *regs) +{ + struct yealink_dev *yld = urb->context; + int ret; + + if (urb->status) + err("%s - urb status %d", __FUNCTION__, urb->status); + + switch (yld->irq_data->cmd) { + case CMD_KEYPRESS: + + yld->master.s.keynum = yld->irq_data->data[0]; + break; + + case CMD_SCANCODE: + dbg("get scancode %x", yld->irq_data->data[0]); + + report_key(yld, map_p1k_to_key(yld->irq_data->data[0]), regs); + break; + + default: + err("unexpected response %x", yld->irq_data->cmd); + } + + yealink_do_idle_tasks(yld); + + ret = usb_submit_urb(yld->urb_ctl, GFP_ATOMIC); + if (ret) + err("%s - usb_submit_urb failed %d", __FUNCTION__, ret); +} + +static void urb_ctl_callback(struct urb *urb, struct pt_regs *regs) +{ + struct yealink_dev *yld = urb->context; + int ret; + + if (urb->status) + err("%s - urb status %d", __FUNCTION__, urb->status); + + switch (yld->ctl_data->cmd) { + case CMD_KEYPRESS: + case CMD_SCANCODE: + /* ask for a response */ + ret = usb_submit_urb(yld->urb_irq, GFP_ATOMIC); + break; + default: + /* send new command */ + yealink_do_idle_tasks(yld); + ret = usb_submit_urb(yld->urb_ctl, GFP_ATOMIC); + } + + if (ret) + err("%s - usb_submit_urb failed %d", __FUNCTION__, ret); +} + +/******************************************************************************* + * input event interface + ******************************************************************************/ + +/* TODO should we issue a ringtone on a SND_BELL event? +static int input_ev(struct input_dev *dev, unsigned int type, + unsigned int code, int value) +{ + + if (type != EV_SND) + return -EINVAL; + + switch (code) { + case SND_BELL: + case SND_TONE: + break; + default: + return -EINVAL; + } + + return 0; +} +*/ + +static int input_open(struct input_dev *dev) +{ + struct yealink_dev *yld = dev->private; + int i, ret; + + dbg("%s", __FUNCTION__); + + /* force updates to device */ + for (i = 0; imaster); i++) + yld->copy.b[i] = ~yld->master.b[i]; + yld->key_code = -1; /* no keys pressed */ + + yealink_set_ringtone(yld, default_ringtone, sizeof(default_ringtone)); + + /* issue INIT */ + memset(yld->ctl_data, 0, sizeof(*(yld->ctl_data))); + yld->ctl_data->cmd = CMD_INIT; + yld->ctl_data->size = 10; + yld->ctl_data->sum = 0x100-CMD_INIT-10; + if ((ret = usb_submit_urb(yld->urb_ctl, GFP_KERNEL)) != 0) { + dbg("%s - usb_submit_urb failed with result %d", + __FUNCTION__, ret); + return ret; + } + return 0; +} + +static void input_close(struct input_dev *dev) +{ + struct yealink_dev *yld = dev->private; + + usb_kill_urb(yld->urb_ctl); + usb_kill_urb(yld->urb_irq); +} + +/******************************************************************************* + * sysfs interface + ******************************************************************************/ + +static DECLARE_RWSEM(sysfs_rwsema); + +/* Interface to the 7-segments translation table aka. char set. + */ +static ssize_t show_map(struct device *dev, struct device_attribute *attr, + char *buf) +{ + memcpy(buf, &map_seg7, sizeof(map_seg7)); + return sizeof(map_seg7); +} + +static ssize_t store_map(struct device *dev, struct device_attribute *attr, + const char *buf, size_t cnt) +{ + if (cnt != sizeof(map_seg7)) + return -EINVAL; + memcpy(&map_seg7, buf, sizeof(map_seg7)); + return sizeof(map_seg7); +} + +/* Interface to the LCD. + */ + +/* Reading /sys/../lineX will return the format string with its settings: + * + * Example: + * cat ./line3 + * 888888888888 + * Linux Rocks! + */ +static ssize_t show_line(struct device *dev, char *buf, int a, int b) +{ + struct yealink_dev *yld; + int i; + + down_read(&sysfs_rwsema); + yld = dev_get_drvdata(dev); + if (yld == NULL) { + up_read(&sysfs_rwsema); + return -ENODEV; + } + + for (i = a; i < b; i++) + *buf++ = lcdMap[i].type; + *buf++ = '\n'; + for (i = a; i < b; i++) + *buf++ = yld->lcdMap[i]; + *buf++ = '\n'; + *buf = 0; + + up_read(&sysfs_rwsema); + return 3 + ((b - a) << 1); +} + +static ssize_t show_line1(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return show_line(dev, buf, LCD_LINE1_OFFSET, LCD_LINE2_OFFSET); +} + +static ssize_t show_line2(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return show_line(dev, buf, LCD_LINE2_OFFSET, LCD_LINE3_OFFSET); +} + +static ssize_t show_line3(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return show_line(dev, buf, LCD_LINE3_OFFSET, LCD_LINE4_OFFSET); +} + +/* Writing to /sys/../lineX will set the coresponding LCD line. + * - Excess characters are ignored. + * - If less characters are written than allowed, the remaining digits are + * unchanged. + * - The '\n' or '\t' char is a placeholder, it does not overwrite the + * original content. + */ +static ssize_t store_line(struct device *dev, const char *buf, size_t count, + int el, size_t len) +{ + struct yealink_dev *yld; + int i; + + down_write(&sysfs_rwsema); + yld = dev_get_drvdata(dev); + if (yld == NULL) { + up_write(&sysfs_rwsema); + return -ENODEV; + } + + if (len > count) + len = count; + for (i = 0; i < len; i++) + setChar(yld, el++, buf[i]); + + up_write(&sysfs_rwsema); + return count; +} + +static ssize_t store_line1(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return store_line(dev, buf, count, LCD_LINE1_OFFSET, LCD_LINE1_SIZE); +} + +static ssize_t store_line2(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return store_line(dev, buf, count, LCD_LINE2_OFFSET, LCD_LINE2_SIZE); +} + +static ssize_t store_line3(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return store_line(dev, buf, count, LCD_LINE3_OFFSET, LCD_LINE3_SIZE); +} + +/* Interface to visible and audible "icons", these include: + * pictures on the LCD, the LED, and the dialtone signal. + */ + +/* Get a list of "switchable elements" with their current state. */ +static ssize_t get_icons(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct yealink_dev *yld; + int i, ret = 1; + + down_read(&sysfs_rwsema); + yld = dev_get_drvdata(dev); + if (yld == NULL) { + up_read(&sysfs_rwsema); + return -ENODEV; + } + + for (i = 0; i < ARRAY_SIZE(lcdMap); i++) { + if (lcdMap[i].type != '.') + continue; + ret += sprintf(&buf[ret], "%s %s\n", + yld->lcdMap[i] == ' ' ? " " : "on", + lcdMap[i].u.p.name); + } + up_read(&sysfs_rwsema); + return ret; +} + +/* Change the visibility of a particular element. */ +static ssize_t set_icon(struct device *dev, const char *buf, size_t count, + int chr) +{ + struct yealink_dev *yld; + int i; + + down_write(&sysfs_rwsema); + yld = dev_get_drvdata(dev); + if (yld == NULL) { + up_write(&sysfs_rwsema); + return -ENODEV; + } + + for (i = 0; i < ARRAY_SIZE(lcdMap); i++) { + if (lcdMap[i].type != '.') + continue; + if (strncmp(buf, lcdMap[i].u.p.name, count) == 0) { + setChar(yld, i, chr); + break; + } + } + + up_write(&sysfs_rwsema); + return count; +} + +static ssize_t show_icon(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return set_icon(dev, buf, count, buf[0]); +} + +static ssize_t hide_icon(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return set_icon(dev, buf, count, ' '); +} + +/* Upload a ringtone to the device. + */ + +/* Stores raw ringtone data in the phone */ +static ssize_t store_ringtone(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct yealink_dev *yld; + + down_write(&sysfs_rwsema); + yld = dev_get_drvdata(dev); + if (yld == NULL) { + up_write(&sysfs_rwsema); + return -ENODEV; + } + + /* TODO locking with async usb control interface??? */ + yealink_set_ringtone(yld, (char *)buf, count); + up_write(&sysfs_rwsema); + return count; +} + +#define _M444 S_IRUGO +#define _M664 S_IRUGO|S_IWUSR|S_IWGRP +#define _M220 S_IWUSR|S_IWGRP + +static DEVICE_ATTR(map_seg7 , _M664, show_map , store_map ); +static DEVICE_ATTR(line1 , _M664, show_line1 , store_line1 ); +static DEVICE_ATTR(line2 , _M664, show_line2 , store_line2 ); +static DEVICE_ATTR(line3 , _M664, show_line3 , store_line3 ); +static DEVICE_ATTR(get_icons , _M444, get_icons , NULL ); +static DEVICE_ATTR(show_icon , _M220, NULL , show_icon ); +static DEVICE_ATTR(hide_icon , _M220, NULL , hide_icon ); +static DEVICE_ATTR(ringtone , _M220, NULL , store_ringtone); + +static struct attribute *yld_attributes[] = { + &dev_attr_line1.attr, + &dev_attr_line2.attr, + &dev_attr_line3.attr, + &dev_attr_get_icons.attr, + &dev_attr_show_icon.attr, + &dev_attr_hide_icon.attr, + &dev_attr_map_seg7.attr, + &dev_attr_ringtone.attr, + NULL +}; + +static struct attribute_group yld_attr_group = { + .attrs = yld_attributes +}; + +/******************************************************************************* + * Linux interface and usb initialisation + ******************************************************************************/ + +static const struct yld_device { + u16 idVendor; + u16 idProduct; + char *name; +} yld_device[] = { + { 0x6993, 0xb001, "Yealink usb-p1k" }, +}; + +static struct usb_device_id usb_table [] = { + { USB_INTERFACE_INFO(USB_CLASS_HID, 0, 0) }, + { } +}; + +static int usb_cleanup(struct yealink_dev *yld, int err) +{ + if (yld == NULL) + return err; + + if (yld->urb_irq) { + usb_kill_urb(yld->urb_irq); + usb_free_urb(yld->urb_irq); + } + if (yld->urb_ctl) + usb_free_urb(yld->urb_ctl); + if (yld->idev.dev) + input_unregister_device(&yld->idev); + if (yld->ctl_req) + usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)), + yld->ctl_req, yld->ctl_req_dma); + if (yld->ctl_data) + usb_buffer_free(yld->udev, USB_PKT_LEN, + yld->ctl_data, yld->ctl_dma); + if (yld->irq_data) + usb_buffer_free(yld->udev, USB_PKT_LEN, + yld->irq_data, yld->irq_dma); + kfree(yld); + return err; +} + +static void usb_disconnect(struct usb_interface *intf) +{ + struct yealink_dev *yld; + + down_write(&sysfs_rwsema); + yld = usb_get_intfdata(intf); + sysfs_remove_group(&intf->dev.kobj, &yld_attr_group); + usb_set_intfdata(intf, NULL); + up_write(&sysfs_rwsema); + + usb_cleanup(yld, 0); +} + +static int usb_match(struct usb_device *udev) +{ + int i; + for (i = 0; i < ARRAY_SIZE(yld_device); i++) { + if ((udev->descriptor.idVendor == yld_device[i].idVendor) && + (udev->descriptor.idProduct == yld_device[i].idProduct)) + return i; + } + return -ENODEV; +} + +static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) +{ + struct usb_device *udev = interface_to_usbdev (intf); + struct usb_host_interface *interface; + struct usb_endpoint_descriptor *endpoint; + struct yealink_dev *yld; + char path[64]; + int ret, pipe, i; + + i = usb_match(udev); + if (i < 0) + return -ENODEV; + + interface = intf->cur_altsetting; + endpoint = &interface->endpoint[0].desc; + if (!(endpoint->bEndpointAddress & 0x80)) + return -EIO; + if ((endpoint->bmAttributes & 3) != 3) + return -EIO; + + if ((yld = kmalloc(sizeof(struct yealink_dev), GFP_KERNEL)) == NULL) + return -ENOMEM; + + memset(yld, 0, sizeof(*yld)); + yld->udev = udev; + + /* allocate usb buffers */ + yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, + SLAB_ATOMIC, &yld->irq_dma); + if (yld->irq_data == NULL) + return usb_cleanup(yld, -ENOMEM); + + yld->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN, + SLAB_ATOMIC, &yld->ctl_dma); + if (!yld->ctl_data) + return usb_cleanup(yld, -ENOMEM); + + yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)), + SLAB_ATOMIC, &yld->ctl_req_dma); + if (yld->ctl_req == NULL) + return usb_cleanup(yld, -ENOMEM); + + /* allocate urb structures */ + yld->urb_irq = usb_alloc_urb(0, GFP_KERNEL); + if (yld->urb_irq == NULL) + return usb_cleanup(yld, -ENOMEM); + + yld->urb_ctl = usb_alloc_urb(0, GFP_KERNEL); + if (yld->urb_ctl == NULL) + return usb_cleanup(yld, -ENOMEM); + + /* get a handle to the interrupt data pipe */ + pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); + ret = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); + if (ret != USB_PKT_LEN) + err("invalid payload size %d, expected %d", ret, USB_PKT_LEN); + + /* initialise irq urb */ + usb_fill_int_urb(yld->urb_irq, udev, pipe, yld->irq_data, + USB_PKT_LEN, + urb_irq_callback, + yld, endpoint->bInterval); + yld->urb_irq->transfer_dma = yld->irq_dma; + yld->urb_irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; + yld->urb_irq->dev = udev; + + /* initialise ctl urb */ + yld->ctl_req->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | + USB_DIR_OUT; + yld->ctl_req->bRequest = USB_REQ_SET_CONFIGURATION; + yld->ctl_req->wValue = cpu_to_le16(0x200); + yld->ctl_req->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); + yld->ctl_req->wLength = cpu_to_le16(USB_PKT_LEN); + + usb_fill_control_urb(yld->urb_ctl, udev, usb_sndctrlpipe(udev, 0), + (void *)yld->ctl_req, yld->ctl_data, USB_PKT_LEN, + urb_ctl_callback, yld); + yld->urb_ctl->setup_dma = yld->ctl_req_dma; + yld->urb_ctl->transfer_dma = yld->ctl_dma; + yld->urb_ctl->transfer_flags |= URB_NO_SETUP_DMA_MAP | + URB_NO_TRANSFER_DMA_MAP; + yld->urb_ctl->dev = udev; + + /* find out the physical bus location */ + if (usb_make_path(udev, path, sizeof(path)) > 0) + snprintf(yld->phys, sizeof(yld->phys)-1, "%s/input0", path); + + /* register settings for the input device */ + init_input_dev(&yld->idev); + yld->idev.private = yld; + yld->idev.id.bustype = BUS_USB; + yld->idev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); + yld->idev.id.product = le16_to_cpu(udev->descriptor.idProduct); + yld->idev.id.version = le16_to_cpu(udev->descriptor.bcdDevice); + yld->idev.dev = &intf->dev; + yld->idev.name = yld_device[i].name; + yld->idev.phys = yld->phys; + /* yld->idev.event = input_ev; TODO */ + yld->idev.open = input_open; + yld->idev.close = input_close; + + /* register available key events */ + yld->idev.evbit[0] = BIT(EV_KEY); + for (i = 0; i < 256; i++) { + int k = map_p1k_to_key(i); + if (k >= 0) { + set_bit(k & 0xff, yld->idev.keybit); + if (k >> 8) + set_bit(k >> 8, yld->idev.keybit); + } + } + + printk(KERN_INFO "input: %s on %s\n", yld->idev.name, path); + + input_register_device(&yld->idev); + + usb_set_intfdata(intf, yld); + + /* clear visible elements */ + for (i=0; idev, NULL, + DRIVER_VERSION, sizeof(DRIVER_VERSION)); + + /* Register sysfs hooks (don't care about failure) */ + sysfs_create_group(&intf->dev.kobj, &yld_attr_group); + return 0; +} + +static struct usb_driver yealink_driver = { + .owner = THIS_MODULE, + .name = "yealink", + .probe = usb_probe, + .disconnect = usb_disconnect, + .id_table = usb_table, +}; + +static int __init yealink_dev_init(void) +{ + int ret = usb_register(&yealink_driver); + if (ret == 0) + info(DRIVER_DESC ":" DRIVER_VERSION); + return ret; +} + +static void __exit yealink_dev_exit(void) +{ + usb_deregister(&yealink_driver); +} + +module_init(yealink_dev_init); +module_exit(yealink_dev_exit); + +MODULE_DEVICE_TABLE (usb, usb_table); + +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/input/yealink.h b/drivers/usb/input/yealink.h new file mode 100644 index 0000000..48af0be --- /dev/null +++ b/drivers/usb/input/yealink.h @@ -0,0 +1,220 @@ +/* + * drivers/usb/input/yealink.h + * + * Copyright (c) 2005 Henk Vergonet + * + * + * 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 + */ +#ifndef INPUT_YEALINK_H +#define INPUT_YEALINK_H + +/* Using the control channel on interface 3 various aspects of the phone + * can be controlled like LCD, LED, dialtone and the ringtone. + */ + +struct yld_ctl_packet { + u8 cmd; /* command code, see below */ + u8 size; /* 1-11, size of used data bytes. */ + u16 offset; /* internal packet offset */ + u8 data[11]; + s8 sum; /* negative sum of 15 preceding bytes */ +} __attribute__ ((packed)); + +#define USB_PKT_LEN sizeof(struct yld_ctl_packet) + +/* The following yld_ctl_packet's are available: */ + +/* Init registers + * + * cmd 0x8e + * size 10 + * offset 0 + * data 0,0,0,0.... + */ +#define CMD_INIT 0x8e + +/* Request key scan + * + * cmd 0x80 + * size 1 + * offset 0 + * data[0] on return returns the key number, if it changes there's a new + * key pressed. + */ +#define CMD_KEYPRESS 0x80 + +/* Request scancode + * + * cmd 0x81 + * size 1 + * offset key number [0-1f] + * data[0] on return returns the scancode + */ +#define CMD_SCANCODE 0x81 + +/* Set LCD + * + * cmd 0x04 + * size 1-11 + * offset 0-23 + * data segment bits + */ +#define CMD_LCD 0x04 + +/* Set led + * + * cmd 0x05 + * size 1 + * offset 0 + * data[0] 0 OFF / 1 ON + */ +#define CMD_LED 0x05 + +/* Set ringtone volume + * + * cmd 0x11 + * size 1 + * offset 0 + * data[0] 0-0xff volume + */ +#define CMD_RING_VOLUME 0x11 + +/* Set ringtone notes + * + * cmd 0x02 + * size 1-11 + * offset 0-> + * data binary representation LE16(-freq), LE16(duration) .... + */ +#define CMD_RING_NOTE 0x02 + +/* Sound ringtone via the speaker on the back + * + * cmd 0x03 + * size 1 + * offset 0 + * data[0] 0 OFF / 0x24 ON + */ +#define CMD_RINGTONE 0x03 + +/* Sound dial tone via the ear speaker + * + * cmd 0x09 + * size 1 + * offset 0 + * data[0] 0 OFF / 1 ON + */ +#define CMD_DIALTONE 0x09 + +#endif /* INPUT_YEALINK_H */ + + +#if defined(_SEG) && defined(_PIC) +/* This table maps the LCD segments onto individual bit positions in the + * yld_status struct. + */ + +/* LCD, each segment must be driven seperately. + * + * Layout: + * + * |[] [][] [][] [][] in |[][] + * |[] M [][] D [][] : [][] out |[][] + * store + * + * NEW REP SU MO TU WE TH FR SA + * + * [] [] [] [] [] [] [] [] [] [] [] [] + * [] [] [] [] [] [] [] [] [] [] [] [] + */ + +/* Line 1 + * Format : 18.e8.M8.88...188 + * Icon names : M D : IN OUT STORE + */ +#define LCD_LINE1_OFFSET 0 +#define LCD_LINE1_SIZE 17 + +/* Note: first g then f => ! ! */ +/* _SEG( type a b c d e g f ) */ + _SEG('1', 0,0 , 22,2 , 22,2 , 0,0 , 0,0 , 0,0 , 0,0 ), + _SEG('8', 20,1 , 20,2 , 20,4 , 20,8 , 21,4 , 21,2 , 21,1 ), + _PIC('.', 22,1 , "M" ), + _SEG('e', 18,1 , 18,2 , 18,4 , 18,1 , 19,2 , 18,1 , 19,1 ), + _SEG('8', 16,1 , 16,2 , 16,4 , 16,8 , 17,4 , 17,2 , 17,1 ), + _PIC('.', 15,8 , "D" ), + _SEG('M', 14,1 , 14,2 , 14,4 , 14,1 , 15,4 , 15,2 , 15,1 ), + _SEG('8', 12,1 , 12,2 , 12,4 , 12,8 , 13,4 , 13,2 , 13,1 ), + _PIC('.', 11,8 , ":" ), + _SEG('8', 10,1 , 10,2 , 10,4 , 10,8 , 11,4 , 11,2 , 11,1 ), + _SEG('8', 8,1 , 8,2 , 8,4 , 8,8 , 9,4 , 9,2 , 9,1 ), + _PIC('.', 7,1 , "IN" ), + _PIC('.', 7,2 , "OUT" ), + _PIC('.', 7,4 , "STORE" ), + _SEG('1', 0,0 , 5,1 , 5,1 , 0,0 , 0,0 , 0,0 , 0,0 ), + _SEG('8', 4,1 , 4,2 , 4,4 , 4,8 , 5,8 , 5,4 , 5,2 ), + _SEG('8', 2,1 , 2,2 , 2,4 , 2,8 , 3,4 , 3,2 , 3,1 ), + +/* Line 2 + * Format : ......... + * Pict. name : NEW REP SU MO TU WE TH FR SA + */ +#define LCD_LINE2_OFFSET LCD_LINE1_OFFSET + LCD_LINE1_SIZE +#define LCD_LINE2_SIZE 9 + + _PIC('.', 23,2 , "NEW" ), + _PIC('.', 23,4 , "REP" ), + _PIC('.', 1,8 , "SU" ), + _PIC('.', 1,4 , "MO" ), + _PIC('.', 1,2 , "TU" ), + _PIC('.', 1,1 , "WE" ), + _PIC('.', 0,1 , "TH" ), + _PIC('.', 0,2 , "FR" ), + _PIC('.', 0,4 , "SA" ), + +/* Line 3 + * Format : 888888888888 + */ +#define LCD_LINE3_OFFSET LCD_LINE2_OFFSET + LCD_LINE2_SIZE +#define LCD_LINE3_SIZE 12 + + _SEG('8', 22,16, 22,32, 22,64, 22,128, 23,128, 23,64, 23,32 ), + _SEG('8', 20,16, 20,32, 20,64, 20,128, 21,128, 21,64, 21,32 ), + _SEG('8', 18,16, 18,32, 18,64, 18,128, 19,128, 19,64, 19,32 ), + _SEG('8', 16,16, 16,32, 16,64, 16,128, 17,128, 17,64, 17,32 ), + _SEG('8', 14,16, 14,32, 14,64, 14,128, 15,128, 15,64, 15,32 ), + _SEG('8', 12,16, 12,32, 12,64, 12,128, 13,128, 13,64, 13,32 ), + _SEG('8', 10,16, 10,32, 10,64, 10,128, 11,128, 11,64, 11,32 ), + _SEG('8', 8,16, 8,32, 8,64, 8,128, 9,128, 9,64, 9,32 ), + _SEG('8', 6,16, 6,32, 6,64, 6,128, 7,128, 7,64, 7,32 ), + _SEG('8', 4,16, 4,32, 4,64, 4,128, 5,128, 5,64, 5,32 ), + _SEG('8', 2,16, 2,32, 2,64, 2,128, 3,128, 3,64, 3,32 ), + _SEG('8', 0,16, 0,32, 0,64, 0,128, 1,128, 1,64, 1,32 ), + +/* Line 4 + * + * The LED, DIALTONE and RINGTONE are implemented as icons and use the same + * sysfs interface. + */ +#define LCD_LINE4_OFFSET LCD_LINE3_OFFSET + LCD_LINE3_SIZE + + _PIC('.', offsetof(struct yld_status, led) , 0x01, "LED" ), + _PIC('.', offsetof(struct yld_status, dialtone) , 0x01, "DIALTONE" ), + _PIC('.', offsetof(struct yld_status, ringtone) , 0x24, "RINGTONE" ), + +#undef _SEG +#undef _PIC +#endif /* _SEG && _PIC */ -- cgit v0.10.2 From d5ae36dd439549305f00a755556f49c9fa7bb237 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 16 Aug 2005 12:33:30 -0700 Subject: [PATCH] USB: fix endian issues in yealink driver. sparse still complains about the htons usage, but I'll leave that for others to fix. Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c index 0748281..e2dd274 100644 --- a/drivers/usb/input/yealink.c +++ b/drivers/usb/input/yealink.c @@ -840,9 +840,12 @@ static void usb_disconnect(struct usb_interface *intf) static int usb_match(struct usb_device *udev) { int i; + u16 idVendor = le16_to_cpu(udev->descriptor.idVendor); + u16 idProduct = le16_to_cpu(udev->descriptor.idProduct); + for (i = 0; i < ARRAY_SIZE(yld_device); i++) { - if ((udev->descriptor.idVendor == yld_device[i].idVendor) && - (udev->descriptor.idProduct == yld_device[i].idProduct)) + if ((idVendor == yld_device[i].idVendor) && + (idProduct == yld_device[i].idProduct)) return i; } return -ENODEV; -- cgit v0.10.2 From b71e318cdb1dc301d734fdd4983dfc6dc167235a Mon Sep 17 00:00:00 2001 From: Henk Date: Wed, 17 Aug 2005 10:40:26 +0200 Subject: [PATCH] USB: yealink: fix htons usage, documentation updates Signed-off-by: Henk Vergonet Signed-off-by: Greg Kroah-Hartman diff --git a/Documentation/input/yealink.txt b/Documentation/input/yealink.txt index 5665c32..85f095a7 100644 --- a/Documentation/input/yealink.txt +++ b/Documentation/input/yealink.txt @@ -1,16 +1,18 @@ -yealink - Linux driver for usb-p1k phones +Driver documentation for yealink usb-p1k phones 0. Status ~~~~~~~~~ The p1k is a relatively cheap usb 1.1 phone with: - - keyboard full support - - LCD full support - - LED full support - - dialtone full support - - ringtone full support - - audio playback via generic usb audio diver - - audio record via generic usb audio diver + - keyboard full support, yealink.ko / input event API + - LCD full support, yealink.ko / sysfs API + - LED full support, yealink.ko / sysfs API + - dialtone full support, yealink.ko / sysfs API + - ringtone full support, yealink.ko / sysfs API + - audio playback full support, snd_usb_audio.ko / alsa API + - audio record full support, snd_usb_audio.ko / alsa API + +For vendor documentation see http://www.yealink.com 1. Compilation (stand alone version) @@ -178,7 +180,21 @@ updated with the first letter of the icon. echo -n RINGTONE > /sys/..../hide_icon -5. Credits & Acknowledgments +5. Sound features +~~~~~~~~~~~~~~~~~ +Sound is supported by the ALSA driver: snd_usb_audio + +One 16-bit channel with sample and playback rates of 8000 Hz is the practical +limit of the device. + + Example - recording test: + arecord -v -d 10 -r 8000 -f S16_LE -t wav foobar.wav + + Example - playback test: + aplay foobar.wav + + +6. Credits & Acknowledgments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Olivier Vandorpe, for starting the usbb2k-api project doing much of the reverse engineering. diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c index e2dd274..58a176e 100644 --- a/drivers/usb/input/yealink.c +++ b/drivers/usb/input/yealink.c @@ -318,7 +318,7 @@ static int yealink_set_ringtone(struct yealink_dev *yld, u8 *buf, size_t size) if (len > sizeof(p->data)) len = sizeof(p->data); p->size = len; - p->offset = htons(ix); + p->offset = cpu_to_be16(ix); memcpy(p->data, &buf[ix], len); yealink_cmd(yld, p); ix += len; @@ -383,7 +383,7 @@ send_update: val--; val &= 0x1f; yld->ctl_data->cmd = CMD_SCANCODE; - yld->ctl_data->offset = htons(val); + yld->ctl_data->offset = cpu_to_be16(val); yld->ctl_data->data[0] = 0; yld->ctl_data->sum = -1 - CMD_SCANCODE - val; break; @@ -395,7 +395,7 @@ send_update: /* Combine up to consecutive LCD bytes in a singe request */ yld->ctl_data->cmd = CMD_LCD; - yld->ctl_data->offset = htons(ix); + yld->ctl_data->offset = cpu_to_be16(ix); yld->ctl_data->size = len; yld->ctl_data->sum = -CMD_LCD - ix - val - len; for(i=1; i Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: ColdFire 523x processor register definitions ColdFire 523x processor hardware register definitions. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/include/asm-m68knommu/m523xsim.h b/include/asm-m68knommu/m523xsim.h new file mode 100644 index 0000000..926cfb8 --- /dev/null +++ b/include/asm-m68knommu/m523xsim.h @@ -0,0 +1,46 @@ +/****************************************************************************/ + +/* + * m523xsim.h -- ColdFire 523x System Integration Module support. + * + * (C) Copyright 2003-2005, Greg Ungerer + */ + +/****************************************************************************/ +#ifndef m523xsim_h +#define m523xsim_h +/****************************************************************************/ + +#include + +/* + * Define the 523x SIM register set addresses. + */ +#define MCFICM_INTC0 0x0c00 /* Base for Interrupt Ctrl 0 */ +#define MCFICM_INTC1 0x0d00 /* Base for Interrupt Ctrl 0 */ +#define MCFINTC_IPRH 0x00 /* Interrupt pending 32-63 */ +#define MCFINTC_IPRL 0x04 /* Interrupt pending 1-31 */ +#define MCFINTC_IMRH 0x08 /* Interrupt mask 32-63 */ +#define MCFINTC_IMRL 0x0c /* Interrupt mask 1-31 */ +#define MCFINTC_INTFRCH 0x10 /* Interrupt force 32-63 */ +#define MCFINTC_INTFRCL 0x14 /* Interrupt force 1-31 */ +#define MCFINTC_IRLR 0x18 /* */ +#define MCFINTC_IACKL 0x19 /* */ +#define MCFINTC_ICR0 0x40 /* Base ICR register */ + +#define MCFINT_VECBASE 64 /* Vector base number */ +#define MCFINT_UART0 13 /* Interrupt number for UART0 */ +#define MCFINT_PIT1 36 /* Interrupt number for PIT1 */ +#define MCFINT_QSPI 18 /* Interrupt number for QSPI */ + +/* + * SDRAM configuration registers. + */ +#define MCFSIM_DCR 0x44 /* SDRAM control */ +#define MCFSIM_DACR0 0x48 /* SDRAM base address 0 */ +#define MCFSIM_DMR0 0x4c /* SDRAM address mask 0 */ +#define MCFSIM_DACR1 0x50 /* SDRAM base address 1 */ +#define MCFSIM_DMR1 0x54 /* SDRAM address mask 1 */ + +/****************************************************************************/ +#endif /* m523xsim_h */ -- cgit v0.10.2 From 1bdd89db117a55c77a854829ff507d6d68ab6485 Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: defines to support the ColdFire 523x processor Add processor level and clock support defines for the ColdFire 523x processor. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/include/asm-m68knommu/coldfire.h b/include/asm-m68knommu/coldfire.h index 16f32cc..1df3f66 100644 --- a/include/asm-m68knommu/coldfire.h +++ b/include/asm-m68knommu/coldfire.h @@ -22,7 +22,7 @@ #define MCF_MBAR2 0x80000000 #define MCF_IPSBAR 0x40000000 -#if defined(CONFIG_M527x) || defined(CONFIG_M528x) +#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) #undef MCF_MBAR #define MCF_MBAR MCF_IPSBAR #endif @@ -54,6 +54,8 @@ #define MCF_CLK 54000000 #elif defined(CONFIG_CLOCK_60MHz) #define MCF_CLK 60000000 +#elif defined(CONFIG_CLOCK_62_5MHz) +#define MCF_CLK 62500000 #elif defined(CONFIG_CLOCK_64MHz) #define MCF_CLK 64000000 #elif defined(CONFIG_CLOCK_66MHz) @@ -76,7 +78,7 @@ * One some ColdFire family members the bus clock (used by internal * peripherals) is not the same as the CPU clock. */ -#if defined(CONFIG_M5249) || defined(CONFIG_M527x) +#if defined(CONFIG_M523x) || defined(CONFIG_M5249) || defined(CONFIG_M527x) #define MCF_BUSCLK (MCF_CLK / 2) #else #define MCF_BUSCLK MCF_CLK -- cgit v0.10.2 From 97591b2c76e3a11d6060b72aa53dc30d3d5478c5 Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: 523x ColdFire processor init/config Makefile Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/arch/m68knommu/platform/523x/Makefile b/arch/m68knommu/platform/523x/Makefile new file mode 100644 index 0000000..c1578b0 --- /dev/null +++ b/arch/m68knommu/platform/523x/Makefile @@ -0,0 +1,19 @@ +# +# Makefile for the m68knommu linux kernel. +# + +# +# If you want to play with the HW breakpoints then you will +# need to add define this, which will give you a stack backtrace +# on the console port whenever a DBG interrupt occurs. You have to +# set up you HW breakpoints to trigger a DBG interrupt: +# +# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT +# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT +# + +ifdef CONFIG_FULLDEBUG +AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1 +endif + +obj-y := config.o -- cgit v0.10.2 From 58201a2d03272b99bdbb5090c0aca517db0702a7 Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: remove uCdimm specific config code Remove uCdimm specific config code. Use common 68VZ328 config code now. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/arch/m68knommu/platform/68VZ328/ucdimm/config.c b/arch/m68knommu/platform/68VZ328/ucdimm/config.c deleted file mode 100644 index 2deadaf..0000000 --- a/arch/m68knommu/platform/68VZ328/ucdimm/config.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * linux/arch/m68knommu/platform/68VZ328/ucdimm/config.c - * - * Copyright (C) 1993 Hamish Macdonald - * Copyright (C) 1999 D. Jeff Dionne - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file COPYING in the main directory of this archive - * for more details. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -void BSP_sched_init(void (*timer_routine)(int, void *, struct pt_regs *)) -{ - /* Restart mode, Enable int, 32KHz, Enable timer */ - TCTL = TCTL_OM | TCTL_IRQEN | TCTL_CLKSOURCE_32KHZ | TCTL_TEN; - /* Set prescaler (Divide 32KHz by 32)*/ - TPRER = 31; - /* Set compare register 32Khz / 32 / 10 = 100 */ - TCMP = 10; - - request_irq(TMR_IRQ_NUM, timer_routine, IRQ_FLG_LOCK, "timer", NULL); -} - -void BSP_tick(void) -{ - /* Reset Timer1 */ - TSTAT &= 0; -} - -unsigned long BSP_gettimeoffset (void) -{ - return 0; -} - -void BSP_gettod (int *yearp, int *monp, int *dayp, - int *hourp, int *minp, int *secp) -{ -} - -int BSP_hwclk(int op, struct hwclk_time *t) -{ - if (!op) { - /* read */ - } else { - /* write */ - } - return 0; -} - -int BSP_set_clock_mmss (unsigned long nowtime) -{ -#if 0 - short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; - - tod->second1 = real_seconds / 10; - tod->second2 = real_seconds % 10; - tod->minute1 = real_minutes / 10; - tod->minute2 = real_minutes % 10; -#endif - return 0; -} - -void BSP_reset (void) -{ - local_irq_disable(); - asm volatile (" - moveal #0x10c00000, %a0; - moveb #0, 0xFFFFF300; - moveal 0(%a0), %sp; - moveal 4(%a0), %a0; - jmp (%a0); - "); -} - -unsigned char *cs8900a_hwaddr; -static int errno; - -_bsc0(char *, getserialnum) -_bsc1(unsigned char *, gethwaddr, int, a) -_bsc1(char *, getbenv, char *, a) - -void config_BSP(char *command, int len) -{ - unsigned char *p; - - printk(KERN_INFO "\n68VZ328 DragonBallVZ support (c) 2001 Lineo, Inc.\n"); - - printk(KERN_INFO "uCdimm serial string [%s]\n",getserialnum()); - p = cs8900a_hwaddr = gethwaddr(0); - printk(KERN_INFO "uCdimm hwaddr %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", - p[0], p[1], p[2], p[3], p[4], p[5]); - p = getbenv("APPEND"); - if (p) strcpy(p,command); - else command[0] = 0; - - mach_sched_init = BSP_sched_init; - mach_tick = BSP_tick; - mach_gettimeoffset = BSP_gettimeoffset; - mach_gettod = BSP_gettod; - mach_reset = BSP_reset; -} -- cgit v0.10.2 From 55f37debf75f34e4fdd42ea1a81c1cea60c7ad9f Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: remove DrangonEngine2 specific config code Remove DragonEngine2 specific config code. Use common 68VZ328 config code now. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/arch/m68knommu/platform/68VZ328/de2/config.c b/arch/m68knommu/platform/68VZ328/de2/config.c deleted file mode 100644 index d058619..0000000 --- a/arch/m68knommu/platform/68VZ328/de2/config.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * linux/arch/m68knommu/platform/MC68VZ328/de2/config.c - * - * Copyright (C) 1993 Hamish Macdonald - * Copyright (C) 1999 D. Jeff Dionne - * Copyright (C) 2001 Georges Menie, Ken Desmet - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file COPYING in the main directory of this archive - * for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_INIT_LCD -#include "screen.h" -#endif - -/* with a 33.16 MHz clock, this will give usec resolution to the time functions */ -#define CLOCK_SOURCE TCTL_CLKSOURCE_SYSCLK -#define CLOCK_PRE 7 -#define TICKS_PER_JIFFY 41450 - -static void -dragen2_sched_init(irqreturn_t (*timer_routine) (int, void *, struct pt_regs *)) -{ - /* disable timer 1 */ - TCTL = 0; - - /* set ISR */ - if (request_irq(TMR_IRQ_NUM, timer_routine, IRQ_FLG_LOCK, "timer", NULL)) - panic("Unable to attach timer interrupt\n"); - - /* Restart mode, Enable int, Set clock source */ - TCTL = TCTL_OM | TCTL_IRQEN | CLOCK_SOURCE; - TPRER = CLOCK_PRE; - TCMP = TICKS_PER_JIFFY; - - /* Enable timer 1 */ - TCTL |= TCTL_TEN; -} - -static void dragen2_tick(void) -{ - /* Reset Timer1 */ - TSTAT &= 0; -} - -static unsigned long dragen2_gettimeoffset(void) -{ - unsigned long ticks = TCN, offset = 0; - - /* check for pending interrupt */ - if (ticks < (TICKS_PER_JIFFY >> 1) && (ISR & (1 << TMR_IRQ_NUM))) - offset = 1000000 / HZ; - - ticks = (ticks * 1000000 / HZ) / TICKS_PER_JIFFY; - - return ticks + offset; -} - -static void dragen2_gettod(int *year, int *mon, int *day, int *hour, - int *min, int *sec) -{ - long now = RTCTIME; - - *year = *mon = *day = 1; - *hour = (now >> 24) % 24; - *min = (now >> 16) % 60; - *sec = now % 60; -} - -static void dragen2_reset(void) -{ - local_irq_disable(); - -#ifdef CONFIG_INIT_LCD - PBDATA |= 0x20; /* disable CCFL light */ - PKDATA |= 0x4; /* disable LCD controller */ - LCKCON = 0; -#endif - - __asm__ __volatile__( - "reset\n\t" - "moveal #0x04000000, %a0\n\t" - "moveal 0(%a0), %sp\n\t" - "moveal 4(%a0), %a0\n\t" - "jmp (%a0)" - ); -} - -static void init_hardware(void) -{ -#ifdef CONFIG_DIRECT_IO_ACCESS - SCR = 0x10; /* allow user access to internal registers */ -#endif - - /* CSGB Init */ - CSGBB = 0x4000; - CSB = 0x1a1; - - /* CS8900 init */ - /* PK3: hardware sleep function pin, active low */ - PKSEL |= PK(3); /* select pin as I/O */ - PKDIR |= PK(3); /* select pin as output */ - PKDATA |= PK(3); /* set pin high */ - - /* PF5: hardware reset function pin, active high */ - PFSEL |= PF(5); /* select pin as I/O */ - PFDIR |= PF(5); /* select pin as output */ - PFDATA &= ~PF(5); /* set pin low */ - - /* cs8900 hardware reset */ - PFDATA |= PF(5); - { int i; for (i = 0; i < 32000; ++i); } - PFDATA &= ~PF(5); - - /* INT1 enable (cs8900 IRQ) */ - PDPOL &= ~PD(1); /* active high signal */ - PDIQEG &= ~PD(1); - PDIRQEN |= PD(1); /* IRQ enabled */ - -#ifdef CONFIG_68328_SERIAL_UART2 - /* Enable RXD TXD port bits to enable UART2 */ - PJSEL &= ~(PJ(5) | PJ(4)); -#endif - -#ifdef CONFIG_INIT_LCD - /* initialize LCD controller */ - LSSA = (long) screen_bits; - LVPW = 0x14; - LXMAX = 0x140; - LYMAX = 0xef; - LRRA = 0; - LPXCD = 3; - LPICF = 0x08; - LPOLCF = 0; - LCKCON = 0x80; - PCPDEN = 0xff; - PCSEL = 0; - - /* Enable LCD controller */ - PKDIR |= 0x4; - PKSEL |= 0x4; - PKDATA &= ~0x4; - - /* Enable CCFL backlighting circuit */ - PBDIR |= 0x20; - PBSEL |= 0x20; - PBDATA &= ~0x20; - - /* contrast control register */ - PFDIR |= 0x1; - PFSEL &= ~0x1; - PWMR = 0x037F; -#endif -} - -void config_BSP(char *command, int size) -{ - printk(KERN_INFO "68VZ328 DragonBallVZ support (c) 2001 Lineo, Inc.\n"); - -#if defined(CONFIG_BOOTPARAM) - strncpy(command, CONFIG_BOOTPARAM_STRING, size); - command[size-1] = 0; -#else - memset(command, 0, size); -#endif - - init_hardware(); - - mach_sched_init = (void *)dragen2_sched_init; - mach_tick = dragen2_tick; - mach_gettimeoffset = dragen2_gettimeoffset; - mach_reset = dragen2_reset; - mach_gettod = dragen2_gettod; -} -- cgit v0.10.2 From 8c2b58ce716112cbba167b0abcb9558c118b8c9a Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: create common config code for all 68VZ328 platforms Create common 68VZ328 config code. It is essentially the same for all boards that use this, so no point having a version of it for each. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/arch/m68knommu/platform/68VZ328/config.c b/arch/m68knommu/platform/68VZ328/config.c new file mode 100644 index 0000000..d926524 --- /dev/null +++ b/arch/m68knommu/platform/68VZ328/config.c @@ -0,0 +1,210 @@ +/***************************************************************************/ + +/* + * linux/arch/m68knommu/platform/68VZ328/config.c + * + * Copyright (C) 1993 Hamish Macdonald + * Copyright (C) 1999 D. Jeff Dionne + * Copyright (C) 2001 Georges Menie, Ken Desmet + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of this archive + * for more details. + */ + +/***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_INIT_LCD +#include "bootlogo.h" +#endif + +/***************************************************************************/ + +void m68328_timer_init(irqreturn_t (*timer_routine) (int, void *, struct pt_regs *)); +void m68328_timer_tick(void); +unsigned long m68328_timer_gettimeoffset(void); +void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec); + +/***************************************************************************/ +/* Init Drangon Engine hardware */ +/***************************************************************************/ +#if defined(CONFIG_DRAGEN2) + +static void m68vz328_reset(void) +{ + local_irq_disable(); + +#ifdef CONFIG_INIT_LCD + PBDATA |= 0x20; /* disable CCFL light */ + PKDATA |= 0x4; /* disable LCD controller */ + LCKCON = 0; +#endif + + __asm__ __volatile__( + "reset\n\t" + "moveal #0x04000000, %a0\n\t" + "moveal 0(%a0), %sp\n\t" + "moveal 4(%a0), %a0\n\t" + "jmp (%a0)" + ); +} + +static void init_hardware(char *command, int size) +{ +#ifdef CONFIG_DIRECT_IO_ACCESS + SCR = 0x10; /* allow user access to internal registers */ +#endif + + /* CSGB Init */ + CSGBB = 0x4000; + CSB = 0x1a1; + + /* CS8900 init */ + /* PK3: hardware sleep function pin, active low */ + PKSEL |= PK(3); /* select pin as I/O */ + PKDIR |= PK(3); /* select pin as output */ + PKDATA |= PK(3); /* set pin high */ + + /* PF5: hardware reset function pin, active high */ + PFSEL |= PF(5); /* select pin as I/O */ + PFDIR |= PF(5); /* select pin as output */ + PFDATA &= ~PF(5); /* set pin low */ + + /* cs8900 hardware reset */ + PFDATA |= PF(5); + { int i; for (i = 0; i < 32000; ++i); } + PFDATA &= ~PF(5); + + /* INT1 enable (cs8900 IRQ) */ + PDPOL &= ~PD(1); /* active high signal */ + PDIQEG &= ~PD(1); + PDIRQEN |= PD(1); /* IRQ enabled */ + +#ifdef CONFIG_68328_SERIAL_UART2 + /* Enable RXD TXD port bits to enable UART2 */ + PJSEL &= ~(PJ(5) | PJ(4)); +#endif + +#ifdef CONFIG_INIT_LCD + /* initialize LCD controller */ + LSSA = (long) screen_bits; + LVPW = 0x14; + LXMAX = 0x140; + LYMAX = 0xef; + LRRA = 0; + LPXCD = 3; + LPICF = 0x08; + LPOLCF = 0; + LCKCON = 0x80; + PCPDEN = 0xff; + PCSEL = 0; + + /* Enable LCD controller */ + PKDIR |= 0x4; + PKSEL |= 0x4; + PKDATA &= ~0x4; + + /* Enable CCFL backlighting circuit */ + PBDIR |= 0x20; + PBSEL |= 0x20; + PBDATA &= ~0x20; + + /* contrast control register */ + PFDIR |= 0x1; + PFSEL &= ~0x1; + PWMR = 0x037F; +#endif +} + +/***************************************************************************/ +/* Init RT-Control uCdimm hardware */ +/***************************************************************************/ +#elif defined(CONFIG_UCDIMM) + +static void m68vz328_reset(void) +{ + local_irq_disable(); + asm volatile (" + moveal #0x10c00000, %a0; + moveb #0, 0xFFFFF300; + moveal 0(%a0), %sp; + moveal 4(%a0), %a0; + jmp (%a0); + "); +} + +unsigned char *cs8900a_hwaddr; +static int errno; + +_bsc0(char *, getserialnum) +_bsc1(unsigned char *, gethwaddr, int, a) +_bsc1(char *, getbenv, char *, a) + +static void init_hardware(char *command, int size) +{ + char *p; + + printk(KERN_INFO "uCdimm serial string [%s]\n", getserialnum()); + p = cs8900a_hwaddr = gethwaddr(0); + printk(KERN_INFO "uCdimm hwaddr %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", + p[0], p[1], p[2], p[3], p[4], p[5]); + p = getbenv("APPEND"); + if (p) + strcpy(p, command); + else + command[0] = 0; +} + +/***************************************************************************/ +#else + +static void m68vz328_reset(void) +{ +} + +static void init_hardware(char *command, int size) +{ +} + +/***************************************************************************/ +#endif +/***************************************************************************/ + +void config_BSP(char *command, int size) +{ + printk(KERN_INFO "68VZ328 DragonBallVZ support (c) 2001 Lineo, Inc.\n"); + +#if defined(CONFIG_BOOTPARAM) + strncpy(command, CONFIG_BOOTPARAM_STRING, size); + command[size-1] = 0; +#else + memset(command, 0, size); +#endif + + init_hardware(command, size); + + mach_sched_init = (void *) m68328_timer_init; + mach_tick = m68328_timer_tick; + mach_gettimeoffset = m68328_timer_gettimeoffset; + mach_gettod = m68328_timer_gettod; + mach_reset = m68vz328_reset; +} + +/***************************************************************************/ -- cgit v0.10.2 From ee721126cae77e66efb470d38cf971ed7b0c506b Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: extract common timer code for 68328 processor Rework the 68x328 configuration and setup code. All 68x328 varient share the same timer hardware, so extract that into its own file, instead of keeping copies in each processors setup code. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/arch/m68knommu/platform/68328/config.c b/arch/m68knommu/platform/68328/config.c index fd7c93f..bcfa5d7 100644 --- a/arch/m68knommu/platform/68328/config.c +++ b/arch/m68knommu/platform/68328/config.c @@ -1,5 +1,7 @@ +/***************************************************************************/ + /* - * linux/arch/$(ARCH)/platform/$(PLATFORM)/config.c + * linux/arch/m68knommu/platform/68328/config.c * * Copyright (C) 1993 Hamish Macdonald * Copyright (C) 1999 D. Jeff Dionne @@ -11,6 +13,8 @@ * VZ Support/Fixes Evan Stawnyczy */ +/***************************************************************************/ + #include #include #include @@ -29,76 +33,16 @@ #include #include +/***************************************************************************/ -void BSP_sched_init(irqreturn_t (*timer_routine)(int, void *, struct pt_regs *)) -{ - -#ifdef CONFIG_XCOPILOT_BUGS - /* - * The only thing I know is that CLK32 is not available on Xcopilot - * I have little idea about what frequency SYSCLK has on Xcopilot. - * The values for prescaler and compare registers were simply - * taken from the original source - */ - - /* Restart mode, Enable int, SYSCLK, Enable timer */ - TCTL2 = TCTL_OM | TCTL_IRQEN | TCTL_CLKSOURCE_SYSCLK | TCTL_TEN; - /* Set prescaler */ - TPRER2 = 2; - /* Set compare register */ - TCMP2 = 0xd7e4; -#else - /* Restart mode, Enable int, 32KHz, Enable timer */ - TCTL2 = TCTL_OM | TCTL_IRQEN | TCTL_CLKSOURCE_32KHZ | TCTL_TEN; - /* Set prescaler (Divide 32KHz by 32)*/ - TPRER2 = 31; - /* Set compare register 32Khz / 32 / 10 = 100 */ - TCMP2 = 10; -#endif - - request_irq(TMR2_IRQ_NUM, timer_routine, IRQ_FLG_LOCK, "timer", NULL); -} - -void BSP_tick(void) -{ - /* Reset Timer2 */ - TSTAT2 &= 0; -} +void m68328_timer_init(irqreturn_t (*timer_routine) (int, void *, struct pt_regs *)); +void m68328_timer_tick(void); +unsigned long m68328_timer_gettimeoffset(void); +void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec); -unsigned long BSP_gettimeoffset (void) -{ - return 0; -} +/***************************************************************************/ -void BSP_gettod (int *yearp, int *monp, int *dayp, - int *hourp, int *minp, int *secp) -{ -} - -int BSP_hwclk(int op, struct hwclk_time *t) -{ - if (!op) { - /* read */ - } else { - /* write */ - } - return 0; -} - -int BSP_set_clock_mmss (unsigned long nowtime) -{ -#if 0 - short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; - - tod->second1 = real_seconds / 10; - tod->second2 = real_seconds % 10; - tod->minute1 = real_minutes / 10; - tod->minute2 = real_minutes % 10; -#endif - return 0; -} - -void BSP_reset (void) +void m68328_reset (void) { local_irq_disable(); asm volatile ("moveal #0x10c00000, %a0;\n\t" @@ -108,18 +52,22 @@ void BSP_reset (void) "jmp (%a0);"); } +/***************************************************************************/ + void config_BSP(char *command, int len) { printk(KERN_INFO "\n68328 support D. Jeff Dionne \n"); printk(KERN_INFO "68328 support Kenneth Albanowski \n"); printk(KERN_INFO "68328/Pilot support Bernhard Kuhn \n"); - mach_sched_init = BSP_sched_init; - mach_tick = BSP_tick; - mach_gettimeoffset = BSP_gettimeoffset; - mach_gettod = BSP_gettod; + mach_sched_init = m68328_timer_init; + mach_tick = m68328_timer_tick; + mach_gettimeoffset = m68328_timer_gettimeoffset; + mach_gettod = m68328_timer_gettod; mach_hwclk = NULL; mach_set_clock_mmss = NULL; - mach_reset = BSP_reset; + mach_reset = m68328_reset; *command = '\0'; } + +/***************************************************************************/ -- cgit v0.10.2 From 7dbdd91fe67e3cd28af36d3853df38b92deec711 Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: include support for the ColdFire 523x processor UARTs Add support definitions for the integrated UARTs on the 523x ColdFire processor family. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/include/asm-m68knommu/mcfuart.h b/include/asm-m68knommu/mcfuart.h index 54d4a85..9c12106 100644 --- a/include/asm-m68knommu/mcfuart.h +++ b/include/asm-m68knommu/mcfuart.h @@ -29,7 +29,7 @@ #define MCFUART_BASE1 0x140 /* Base address of UART1 */ #define MCFUART_BASE2 0x180 /* Base address of UART2 */ #endif -#elif defined(CONFIG_M527x) || defined(CONFIG_M528x) +#elif defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) #define MCFUART_BASE1 0x200 /* Base address of UART1 */ #define MCFUART_BASE2 0x240 /* Base address of UART2 */ #define MCFUART_BASE3 0x280 /* Base address of UART3 */ -- cgit v0.10.2 From a052b7affc193a7937e6791d262addcb82654d5f Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: add timer support for the 523x ColdFire processor family Add timer support for the ColdFire 523x processor family. (It uses the ColdFire PIT timer hardware, so we just build that in). Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/arch/m68knommu/platform/5307/Makefile b/arch/m68knommu/platform/5307/Makefile index 84b6b70..6fe5a2b 100644 --- a/arch/m68knommu/platform/5307/Makefile +++ b/arch/m68knommu/platform/5307/Makefile @@ -19,6 +19,7 @@ endif obj-$(CONFIG_COLDFIRE) += entry.o vectors.o ints.o obj-$(CONFIG_M5206) += timers.o obj-$(CONFIG_M5206e) += timers.o +obj-$(CONFIG_M523x) += pit.o obj-$(CONFIG_M5249) += timers.o obj-$(CONFIG_M527x) += pit.o obj-$(CONFIG_M5272) += timers.o -- cgit v0.10.2 From a79626604bc044cec30bfc6cc3332007588e1a94 Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: register map setup for MOD5272 board The boot loader on the MOD5272 board doesn't set the register maping, so set it in the 5272 init code. There was code in there to support this, but we had never needed to use it before. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/arch/m68knommu/platform/5272/config.c b/arch/m68knommu/platform/5272/config.c index 5cb2869..cf36e7d 100644 --- a/arch/m68knommu/platform/5272/config.c +++ b/arch/m68knommu/platform/5272/config.c @@ -104,11 +104,11 @@ int mcf_timerirqpending(int timer) void config_BSP(char *commandp, int size) { -#if 0 - volatile unsigned long *pivrp; +#if defined (CONFIG_MOD5272) + volatile unsigned char *pivrp; /* Set base of device vectors to be 64 */ - pivrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_PIVR); + pivrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_PIVR); *pivrp = 0x40; #endif -- cgit v0.10.2 From 75003c4812ae23a8a99e9921bbe66ffb0e784c8e Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: create common timer code for 68x328 processor varients Create common timer code for all 68x328 processor varients. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/arch/m68knommu/platform/68328/timers.c b/arch/m68knommu/platform/68328/timers.c new file mode 100644 index 0000000..68c2cd6 --- /dev/null +++ b/arch/m68knommu/platform/68328/timers.c @@ -0,0 +1,106 @@ +/***************************************************************************/ + +/* + * linux/arch/m68knommu/platform/68328/timers.c + * + * Copyright (C) 1993 Hamish Macdonald + * Copyright (C) 1999 D. Jeff Dionne + * Copyright (C) 2001 Georges Menie, Ken Desmet + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of this archive + * for more details. + */ + +/***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/***************************************************************************/ + +#if defined(CONFIG_DRAGEN2) +/* with a 33.16 MHz clock, this will give usec resolution to the time functions */ +#define CLOCK_SOURCE TCTL_CLKSOURCE_SYSCLK +#define CLOCK_PRE 7 +#define TICKS_PER_JIFFY 41450 + +#elif defined(CONFIG_XCOPILOT_BUGS) +/* + * The only thing I know is that CLK32 is not available on Xcopilot + * I have little idea about what frequency SYSCLK has on Xcopilot. + * The values for prescaler and compare registers were simply + * taken from the original source + */ +#define CLOCK_SOURCE TCTL_CLKSOURCE_SYSCLK +#define CLOCK_PRE 2 +#define TICKS_PER_JIFFY 0xd7e4 + +#else +/* default to using the 32Khz clock */ +#define CLOCK_SOURCE TCTL_CLKSOURCE_32KHZ +#define CLOCK_PRE 31 +#define TICKS_PER_JIFFY 10 +#endif + +/***************************************************************************/ + +void m68328_timer_init(irqreturn_t (*timer_routine) (int, void *, struct pt_regs *)) +{ + /* disable timer 1 */ + TCTL = 0; + + /* set ISR */ + if (request_irq(TMR_IRQ_NUM, timer_routine, IRQ_FLG_LOCK, "timer", NULL)) + panic("Unable to attach timer interrupt\n"); + + /* Restart mode, Enable int, Set clock source */ + TCTL = TCTL_OM | TCTL_IRQEN | CLOCK_SOURCE; + TPRER = CLOCK_PRE; + TCMP = TICKS_PER_JIFFY; + + /* Enable timer 1 */ + TCTL |= TCTL_TEN; +} + +/***************************************************************************/ + +void m68328_timer_tick(void) +{ + /* Reset Timer1 */ + TSTAT &= 0; +} +/***************************************************************************/ + +unsigned long m68328_timer_gettimeoffset(void) +{ + unsigned long ticks = TCN, offset = 0; + + /* check for pending interrupt */ + if (ticks < (TICKS_PER_JIFFY >> 1) && (ISR & (1 << TMR_IRQ_NUM))) + offset = 1000000 / HZ; + ticks = (ticks * 1000000 / HZ) / TICKS_PER_JIFFY; + return ticks + offset; +} + +/***************************************************************************/ + +void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec) +{ + long now = RTCTIME; + + *year = *mon = *day = 1; + *hour = (now >> 24) % 24; + *min = (now >> 16) % 60; + *sec = now % 60; +} + +/***************************************************************************/ -- cgit v0.10.2 From d9b9d5ddb827dc36cc1f7214f5818640e1bc22d5 Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: include ColdFire 523x processor register definitions Include the ColdFire 523x register definitions when compiling for that target processor. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/include/asm-m68knommu/mcfsim.h b/include/asm-m68knommu/mcfsim.h index 522e513..b0c7736 100644 --- a/include/asm-m68knommu/mcfsim.h +++ b/include/asm-m68knommu/mcfsim.h @@ -15,13 +15,15 @@ #include /* - * Include 5204, 5206/e, 5249, 5270/5271, 5272, 5280/5282, 5307 or - * 5407 specific addresses. + * Include 5204, 5206/e, 5235, 5249, 5270/5271, 5272, 5280/5282, + * 5307 or 5407 specific addresses. */ #if defined(CONFIG_M5204) #include #elif defined(CONFIG_M5206) || defined(CONFIG_M5206e) #include +#elif defined(CONFIG_M523x) +#include #elif defined(CONFIG_M5249) #include #elif defined(CONFIG_M527x) -- cgit v0.10.2 From 03981f2427c767cfcd917cb51197c43fe68ba5db Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Fri, 9 Sep 2005 09:32:14 +1000 Subject: [PATCH] m68knommu: extract common timer code for 68EZ328 processor Rework the 68x328 configuration and setup code. All 68x328 varients share the same timer hardware. So extract that into its own file, instead of keeping copies in each processors setup code. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds diff --git a/arch/m68knommu/platform/68EZ328/config.c b/arch/m68knommu/platform/68EZ328/config.c index c219719..d8d56e5 100644 --- a/arch/m68knommu/platform/68EZ328/config.c +++ b/arch/m68knommu/platform/68EZ328/config.c @@ -1,5 +1,7 @@ +/***************************************************************************/ + /* - * linux/arch/$(ARCH)/platform/$(PLATFORM)/config.c + * linux/arch/m68knommu/platform/68EZ328/config.c * * Copyright (C) 1993 Hamish Macdonald * Copyright (C) 1999 D. Jeff Dionne @@ -9,6 +11,8 @@ * for more details. */ +/***************************************************************************/ + #include #include #include @@ -20,68 +24,22 @@ #include #include #include -#include #include #include #ifdef CONFIG_UCSIMM #include #endif -#ifdef CONFIG_PILOT -#include "PalmV/romfs.h" -#endif - -void BSP_sched_init(void (*timer_routine)(int, void *, struct pt_regs *)) -{ - /* Restart mode, Enable int, 32KHz, Enable timer */ - TCTL = TCTL_OM | TCTL_IRQEN | TCTL_CLKSOURCE_32KHZ | TCTL_TEN; - /* Set prescaler (Divide 32KHz by 32)*/ - TPRER = 31; - /* Set compare register 32Khz / 32 / 10 = 100 */ - TCMP = 10; - - request_irq(TMR_IRQ_NUM, timer_routine, IRQ_FLG_LOCK, "timer", NULL); -} - -void BSP_tick(void) -{ - /* Reset Timer1 */ - TSTAT &= 0; -} - -unsigned long BSP_gettimeoffset (void) -{ - return 0; -} -void BSP_gettod (int *yearp, int *monp, int *dayp, - int *hourp, int *minp, int *secp) -{ -} +/***************************************************************************/ -int BSP_hwclk(int op, struct hwclk_time *t) -{ - if (!op) { - /* read */ - } else { - /* write */ - } - return 0; -} +void m68328_timer_init(irqreturn_t (*timer_routine) (int, void *, struct pt_regs *)); +void m68328_timer_tick(void); +unsigned long m68328_timer_gettimeoffset(void); +void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec); -int BSP_set_clock_mmss (unsigned long nowtime) -{ -#if 0 - short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; +/***************************************************************************/ - tod->second1 = real_seconds / 10; - tod->second2 = real_seconds % 10; - tod->minute1 = real_minutes / 10; - tod->minute2 = real_minutes % 10; -#endif - return 0; -} - -void BSP_reset (void) +void m68ez328_reset(void) { local_irq_disable(); asm volatile (" @@ -93,6 +51,8 @@ void BSP_reset (void) "); } +/***************************************************************************/ + unsigned char *cs8900a_hwaddr; static int errno; @@ -119,11 +79,13 @@ void config_BSP(char *command, int len) else command[0] = 0; #endif - mach_sched_init = BSP_sched_init; - mach_tick = BSP_tick; - mach_gettimeoffset = BSP_gettimeoffset; - mach_gettod = BSP_gettod; + mach_sched_init = m68328_timer_init; + mach_tick = m68328_timer_tick; + mach_gettimeoffset = m68328_timer_gettimeoffset; + mach_gettod = m68328_timer_gettod; mach_hwclk = NULL; mach_set_clock_mmss = NULL; - mach_reset = BSP_reset; + mach_reset = m68ez328_reset; } + +/***************************************************************************/ -- cgit v0.10.2 From c9fc0d6a6901e7f06c6bbd0061e503d96464266d Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Fri, 9 Sep 2005 11:38:09 +1000 Subject: [XFS] Revert recent quota Makefile change, not in a fit state for merging. Signed-off-by: Nathan Scott diff --git a/fs/xfs/Makefile-linux-2.6 b/fs/xfs/Makefile-linux-2.6 index 8e18ff1..d8c87fa 100644 --- a/fs/xfs/Makefile-linux-2.6 +++ b/fs/xfs/Makefile-linux-2.6 @@ -1,5 +1,5 @@ # -# Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. +# Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of version 2 of the GNU General Public License as @@ -55,7 +55,18 @@ ifeq ($(CONFIG_XFS_TRACE),y) endif obj-$(CONFIG_XFS_FS) += xfs.o -xfs-$(CONFIG_XFS_QUOTA) += quota/ + +xfs-$(CONFIG_XFS_QUOTA) += $(addprefix quota/, \ + xfs_dquot.o \ + xfs_dquot_item.o \ + xfs_trans_dquot.o \ + xfs_qm_syscalls.o \ + xfs_qm_bhv.o \ + xfs_qm.o) + +ifeq ($(CONFIG_XFS_QUOTA),y) +xfs-$(CONFIG_PROC_FS) += quota/xfs_qm_stats.o +endif xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o -- cgit v0.10.2 From 8add788574694c5aed04fcb281a5c999e40cd8f6 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Thu, 8 Sep 2005 23:07:29 -0400 Subject: [libata] minor fixes * sata_mv: remove pci_intx(), now that the same function is in PCI core * sata_sis: fix variable initialization bug, trim trailing whitespace diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c index f97e3af..ea76fe4 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c @@ -699,22 +699,6 @@ static int mv_host_init(struct ata_probe_ent *probe_ent) return rc; } -/* move to PCI layer, integrate w/ MSI stuff */ -static void pci_intx(struct pci_dev *pdev, int enable) -{ - u16 pci_command, new; - - pci_read_config_word(pdev, PCI_COMMAND, &pci_command); - - if (enable) - new = pci_command & ~PCI_COMMAND_INTX_DISABLE; - else - new = pci_command | PCI_COMMAND_INTX_DISABLE; - - if (new != pci_command) - pci_write_config_word(pdev, PCI_COMMAND, pci_command); -} - static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version = 0; diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c index 2bd3f11..a63f931 100644 --- a/drivers/scsi/sata_sis.c +++ b/drivers/scsi/sata_sis.c @@ -55,7 +55,7 @@ enum { SIS180_SATA1_OFS = 0x10, /* offset from sata0->sata1 phy regs */ SIS182_SATA1_OFS = 0x20, /* offset from sata0->sata1 phy regs */ SIS_PMR = 0x90, /* port mapping register */ - SIS_PMR_COMBINED = 0x30, + SIS_PMR_COMBINED = 0x30, /* random bits */ SIS_FLAG_CFGSCR = (1 << 30), /* host flag: SCRs via PCI cfg */ @@ -147,11 +147,13 @@ static unsigned int get_scr_cfg_addr(unsigned int port_no, unsigned int sc_reg, { unsigned int addr = SIS_SCR_BASE + (4 * sc_reg); - if (port_no) + if (port_no) { if (device == 0x182) addr += SIS182_SATA1_OFS; else addr += SIS180_SATA1_OFS; + } + return addr; } @@ -166,10 +168,10 @@ static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) return 0xffffffff; pci_read_config_byte(pdev, SIS_PMR, &pmr); - + pci_read_config_dword(pdev, cfg_addr, &val); - if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED)) + if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED)) pci_read_config_dword(pdev, cfg_addr+0x10, &val2); return val|val2; @@ -185,7 +187,7 @@ static void sis_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val) return; pci_read_config_byte(pdev, SIS_PMR, &pmr); - + pci_write_config_dword(pdev, cfg_addr, val); if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED)) @@ -195,7 +197,7 @@ static void sis_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val) static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg) { struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); - u32 val,val2; + u32 val, val2 = 0; u8 pmr; if (sc_reg > SCR_CONTROL) @@ -209,9 +211,9 @@ static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg) val = inl(ap->ioaddr.scr_addr + (sc_reg * 4)); if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED)) - val2 = inl(ap->ioaddr.scr_addr + (sc_reg * 4)+0x10); + val2 = inl(ap->ioaddr.scr_addr + (sc_reg * 4) + 0x10); - return val|val2; + return val | val2; } static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) @@ -223,7 +225,7 @@ static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) return; pci_read_config_byte(pdev, SIS_PMR, &pmr); - + if (ap->flags & SIS_FLAG_CFGSCR) sis_scr_cfg_write(ap, sc_reg, val); else { -- cgit v0.10.2 From 0ba7a3ba6608de6e0c0bfe3009a63d7e0b7ab0ce Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:28:47 -0300 Subject: [CCID3] Avoid unsigned integer overflows in usecs_div Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 7bf3b3a..ae0500c 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -43,12 +43,22 @@ #include "ccid3.h" /* - * Reason for maths with 10 here is to avoid 32 bit overflow when a is big. + * Reason for maths here is to avoid 32 bit overflow when a is big. + * With this we get close to the limit. */ static inline u32 usecs_div(const u32 a, const u32 b) { - const u32 tmp = a * (USEC_PER_SEC / 10); - return b > 20 ? tmp / (b / 10) : tmp; + const u32 div = a < (UINT_MAX / (USEC_PER_SEC / 10)) ? 10 : + a < (UINT_MAX / (USEC_PER_SEC / 50)) ? 50 : + a < (UINT_MAX / (USEC_PER_SEC / 100)) ? 100 : + a < (UINT_MAX / (USEC_PER_SEC / 500)) ? 500 : + a < (UINT_MAX / (USEC_PER_SEC / 1000)) ? 1000 : + a < (UINT_MAX / (USEC_PER_SEC / 5000)) ? 5000 : + a < (UINT_MAX / (USEC_PER_SEC / 10000)) ? 10000 : + a < (UINT_MAX / (USEC_PER_SEC / 50000)) ? 50000 : + 100000; + const u32 tmp = a * (USEC_PER_SEC / div); + return (b >= 2 * div) ? tmp / (b / div) : tmp; } static int ccid3_debug; -- cgit v0.10.2 From 507d37cf269ebbd1b32bcc435fe577e411f73151 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:30:07 -0300 Subject: [CCID] Only call the HC insert_options methods when requested Signed-off-by: Arnaldo Carvalho de Melo diff --git a/include/linux/dccp.h b/include/linux/dccp.h index 007c290..5e0af0d 100644 --- a/include/linux/dccp.h +++ b/include/linux/dccp.h @@ -433,6 +433,8 @@ struct dccp_sock { struct ccid *dccps_hc_tx_ccid; struct dccp_options_received dccps_options_received; enum dccp_role dccps_role:2; + __u8 dccps_hc_rx_insert_options:1; + __u8 dccps_hc_tx_insert_options:1; }; static inline struct dccp_sock *dccp_sk(const struct sock *sk) diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index ae0500c..37fd9eb 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -358,10 +358,12 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, } /* Can we send? if so add options and add to packet history */ - if (rc == 0) + if (rc == 0) { + dp->dccps_hc_tx_insert_options = 1; new_packet->dccphtx_ccval = DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count; + } out: return rc; } @@ -811,6 +813,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) hcrx->ccid3hcrx_pinv = ~0; else hcrx->ccid3hcrx_pinv = 1000000 / hcrx->ccid3hcrx_p; + dp->dccps_hc_rx_insert_options = 1; dccp_send_ack(sk); } diff --git a/net/dccp/options.c b/net/dccp/options.c index 382c589..7ad2f42 100644 --- a/net/dccp/options.c +++ b/net/dccp/options.c @@ -505,13 +505,18 @@ void dccp_insert_options(struct sock *sk, struct sk_buff *skb) (dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno != DCCP_MAX_SEQNO + 1)) dccp_insert_option_ack_vector(sk, skb); - if (dp->dccps_timestamp_echo != 0) dccp_insert_option_timestamp_echo(sk, skb); } - ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb); - ccid_hc_tx_insert_options(dp->dccps_hc_tx_ccid, sk, skb); + if (dp->dccps_hc_rx_insert_options) { + ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb); + dp->dccps_hc_rx_insert_options = 0; + } + if (dp->dccps_hc_tx_insert_options) { + ccid_hc_tx_insert_options(dp->dccps_hc_tx_ccid, sk, skb); + dp->dccps_hc_tx_insert_options = 0; + } /* XXX: insert other options when appropriate */ -- cgit v0.10.2 From 27ae543e6f116df66e2b19ff0a3aa1053e4784d8 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:31:07 -0300 Subject: [CCID3] Calculate ccid3hcrx_x_recv using usecs_div Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 37fd9eb..63f8973 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -779,11 +779,8 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) case TFRC_RSTATE_DATA: { const u32 delta = timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_feedback); - - hcrx->ccid3hcrx_x_recv = (hcrx->ccid3hcrx_bytes_recv * - USEC_PER_SEC); - if (likely(delta > 1)) - hcrx->ccid3hcrx_x_recv /= delta; + hcrx->ccid3hcrx_x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, + delta); } break; default: -- cgit v0.10.2 From 1c14ac0ae8eb62cbb40af1e31b156994c7d7d3d5 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:32:01 -0300 Subject: [DCCP] Give precedence to the biggest ELAPSED_TIME We can get this value in an TIMESTAMP_ECHO and/or in an ELAPSED_TIME option, if receiving both give precendence to the biggest one. In my tests they are very close if not equal at all times, so we may well think about removing the code in CCID3 that inserts this option and leaving this to the core, and perhaps even use just TIMESTAMP_ECHO including the elapsed time. Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/options.c b/net/dccp/options.c index 7ad2f42..34b230a 100644 --- a/net/dccp/options.c +++ b/net/dccp/options.c @@ -72,6 +72,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) struct dccp_options_received *opt_recv = &dp->dccps_options_received; unsigned char opt, len; unsigned char *value; + u32 elapsed_time; memset(opt_recv, 0, sizeof(*opt_recv)); @@ -159,18 +160,18 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) (unsigned long long) DCCP_SKB_CB(skb)->dccpd_ack_seq); - if (len > 4) { - if (len == 6) - opt_recv->dccpor_elapsed_time = - ntohs(*(u16 *)(value + 4)); - else - opt_recv->dccpor_elapsed_time = - ntohl(*(u32 *)(value + 4)); - dccp_pr_debug("%sTIMESTAMP_ECHO ELAPSED_TIME=%d\n", - debug_prefix, - opt_recv->dccpor_elapsed_time); - } + if (len == 4) + break; + + if (len == 6) + elapsed_time = ntohs(*(u16 *)(value + 4)); + else + elapsed_time = ntohl(*(u32 *)(value + 4)); + + /* Give precedence to the biggest ELAPSED_TIME */ + if (elapsed_time > opt_recv->dccpor_elapsed_time) + opt_recv->dccpor_elapsed_time = elapsed_time; break; case DCCPO_ELAPSED_TIME: if (len != 2 && len != 4) @@ -180,14 +181,15 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) continue; if (len == 2) - opt_recv->dccpor_elapsed_time = - ntohs(*(u16 *)value); + elapsed_time = ntohs(*(u16 *)value); else - opt_recv->dccpor_elapsed_time = - ntohl(*(u32 *)value); + elapsed_time = ntohl(*(u32 *)value); + + if (elapsed_time > opt_recv->dccpor_elapsed_time) + opt_recv->dccpor_elapsed_time = elapsed_time; dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix, - opt_recv->dccpor_elapsed_time); + elapsed_time); break; /* * From draft-ietf-dccp-spec-11.txt: -- cgit v0.10.2 From 1a28599a2c2781dd6af72f4f84175e2db74d3bb1 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:32:56 -0300 Subject: [CCID3] Use ELAPSED_TIME in the HC TX RTT estimation Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 63f8973..86c109e 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -483,7 +483,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) opt_recv = &hctx->ccid3hctx_options_received; - t_elapsed = dp->dccps_options_received.dccpor_elapsed_time; + t_elapsed = dp->dccps_options_received.dccpor_elapsed_time * 10; x_recv = opt_recv->ccid3or_receive_rate; pinv = opt_recv->ccid3or_loss_event_rate; @@ -509,8 +509,12 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) /* Update RTT */ r_sample = timeval_now_delta(&packet->dccphtx_tstamp); - /* FIXME: */ - // r_sample -= usecs_to_jiffies(t_elapsed * 10); + if (unlikely(r_sample <= t_elapsed)) + LIMIT_NETDEBUG(KERN_WARNING + "%s: r_sample=%uus, t_elapsed=%uus\n", + __FUNCTION__, r_sample, t_elapsed); + else + r_sample -= t_elapsed; /* Update RTT estimate by * If (No feedback recv) -- cgit v0.10.2 From b3a3077d963fc54a25be26e2e84fe9f4327c1e12 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:34:10 -0300 Subject: [CCID3] Make the ccid3hcrx_rtt calc look more like the ccid3hctx_rtt one Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 86c109e..0804b3e 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -962,7 +962,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) struct dccp_rx_hist_entry *packet; struct timeval now; u8 win_count; - u32 p_prev; + u32 p_prev, r_sample, t_elapsed; int ins; if (hcrx == NULL) @@ -982,9 +982,23 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) break; p_prev = hcrx->ccid3hcrx_rtt; do_gettimeofday(&now); - hcrx->ccid3hcrx_rtt = timeval_usecs(&now) - - (opt_recv->dccpor_timestamp_echo - - opt_recv->dccpor_elapsed_time) * 10; + timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10); + r_sample = timeval_usecs(&now); + t_elapsed = opt_recv->dccpor_elapsed_time * 10; + + if (unlikely(r_sample <= t_elapsed)) + LIMIT_NETDEBUG(KERN_WARNING + "%s: r_sample=%uus, t_elapsed=%uus\n", + __FUNCTION__, r_sample, t_elapsed); + else + r_sample -= t_elapsed; + + if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) + hcrx->ccid3hcrx_rtt = r_sample; + else + hcrx->ccid3hcrx_rtt = (hcrx->ccid3hcrx_rtt * 9) / 10 + + r_sample / 10; + if (p_prev != hcrx->ccid3hcrx_rtt) ccid3_pr_debug("%s, New RTT=%luus, elapsed time=%u\n", dccp_role(sk), hcrx->ccid3hcrx_rtt, -- cgit v0.10.2 From 954ee31f366fabe53fb450482789258fe552f40b Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:37:05 -0300 Subject: [CCID3] Initialize more fields in ccid3_hc_rx_init The initialization of ccid3hcrx_rtt to 5ms is just a bandaid, I'll continue auditing the CCID3 HC rx codebase to fix this properly, probably I'll add a feedback timer as suggested in the CCID3 draft. Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 0804b3e..145aafa 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -1100,11 +1100,9 @@ static int ccid3_hc_rx_init(struct sock *sk) hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); - /* - * XXX this seems to be paranoid, need to think more about this, for - * now start with something different than zero. -acme - */ - hcrx->ccid3hcrx_rtt = USEC_PER_SEC / 5; + do_gettimeofday(&hcrx->ccid3hcrx_tstamp_last_ack); + hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack; + hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */ return 0; } -- cgit v0.10.2 From b0e567806d16586629468c824dfb2e71155df7da Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:38:35 -0300 Subject: [DCCP] Introduce dccp_timestamp To start the timestamps with 0.0ms, easing the integer maths in the CCIDs, this probably will be reworked to use the to be introduced struct timeval_offset infrastructure out of skb_get_timestamp, etc. Signed-off-by: Arnaldo Carvalho de Melo diff --git a/include/linux/dccp.h b/include/linux/dccp.h index 5e0af0d..8bf4bac 100644 --- a/include/linux/dccp.h +++ b/include/linux/dccp.h @@ -432,6 +432,7 @@ struct dccp_sock { struct ccid *dccps_hc_rx_ccid; struct ccid *dccps_hc_tx_ccid; struct dccp_options_received dccps_options_received; + struct timeval dccps_epoch; enum dccp_role dccps_role:2; __u8 dccps_hc_rx_insert_options:1; __u8 dccps_hc_tx_insert_options:1; diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 145aafa..348e6fb 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -169,7 +169,7 @@ static void ccid3_hc_tx_update_x(struct sock *sk) } else { struct timeval now; - do_gettimeofday(&now); + dccp_timestamp(sk, &now); if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >= hctx->ccid3hctx_rtt) { hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv, @@ -317,7 +317,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); } - do_gettimeofday(&now); + dccp_timestamp(sk, &now); switch (hctx->ccid3hctx_state) { case TFRC_SSTATE_NO_SENT: @@ -382,7 +382,7 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) return; } - do_gettimeofday(&now); + dccp_timestamp(sk, &now); /* check if we have sent a data packet */ if (len > 0) { @@ -461,6 +461,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; struct ccid3_options_received *opt_recv; struct dccp_tx_hist_entry *packet; + struct timeval now; unsigned long next_tmout; u32 t_elapsed; u32 pinv; @@ -508,7 +509,8 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) } /* Update RTT */ - r_sample = timeval_now_delta(&packet->dccphtx_tstamp); + dccp_timestamp(sk, &now); + r_sample = timeval_delta(&now, &packet->dccphtx_tstamp); if (unlikely(r_sample <= t_elapsed)) LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, t_elapsed=%uus\n", @@ -774,7 +776,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); - do_gettimeofday(&now); + dccp_timestamp(sk, &now); switch (hcrx->ccid3hcrx_state) { case TFRC_RSTATE_NO_DATA: @@ -903,10 +905,9 @@ found: if (rtt == 0) rtt = 1; - delta = timeval_now_delta(&hcrx->ccid3hcrx_tstamp_last_feedback); - x_recv = hcrx->ccid3hcrx_bytes_recv * USEC_PER_SEC; - if (likely(delta > 1)) - x_recv /= delta; + dccp_timestamp(sk, &tstamp); + delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback); + x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, delta); tmp1 = (u64)x_recv * (u64)rtt; do_div(tmp1,10000000); @@ -981,7 +982,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) if (opt_recv->dccpor_timestamp_echo == 0) break; p_prev = hcrx->ccid3hcrx_rtt; - do_gettimeofday(&now); + dccp_timestamp(sk, &now); timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10); r_sample = timeval_usecs(&now); t_elapsed = opt_recv->dccpor_elapsed_time * 10; @@ -1013,7 +1014,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) return; } - packet = dccp_rx_hist_entry_new(ccid3_rx_hist, opt_recv->dccpor_ndp, + packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp, skb, SLAB_ATOMIC); if (packet == NULL) { ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet " @@ -1045,7 +1046,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) if (ins != 0) break; - do_gettimeofday(&now); + dccp_timestamp(sk, &now); if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >= hcrx->ccid3hcrx_rtt) { hcrx->ccid3hcrx_tstamp_last_ack = now; @@ -1100,7 +1101,7 @@ static int ccid3_hc_rx_init(struct sock *sk) hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); - do_gettimeofday(&hcrx->ccid3hcrx_tstamp_last_ack); + dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack); hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack; hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */ return 0; diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h index ee8cbac..58be612 100644 --- a/net/dccp/ccids/ccid3.h +++ b/net/dccp/ccids/ccid3.h @@ -115,7 +115,7 @@ struct ccid3_hc_rx_sock { u64 ccid3hcrx_seqno_last_counter:48, ccid3hcrx_state:8, ccid3hcrx_last_counter:4; - unsigned long ccid3hcrx_rtt; + u32 ccid3hcrx_rtt; u32 ccid3hcrx_p; u32 ccid3hcrx_bytes_recv; struct timeval ccid3hcrx_tstamp_last_feedback; diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h index fb90a91..b375ebd 100644 --- a/net/dccp/ccids/lib/packet_history.h +++ b/net/dccp/ccids/lib/packet_history.h @@ -134,6 +134,7 @@ static inline struct dccp_tx_hist_entry * static inline struct dccp_rx_hist_entry * dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, + const struct sock *sk, const u32 ndp, const struct sk_buff *skb, const unsigned int __nocast prio) @@ -148,7 +149,7 @@ static inline struct dccp_rx_hist_entry * entry->dccphrx_ccval = dh->dccph_ccval; entry->dccphrx_type = dh->dccph_type; entry->dccphrx_ndp = ndp; - do_gettimeofday(&(entry->dccphrx_tstamp)); + dccp_timestamp(sk, &entry->dccphrx_tstamp); } return entry; diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 33456c0..95c4630 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h @@ -426,10 +426,13 @@ extern struct dccp_ackpkts * dccp_ackpkts_alloc(unsigned int len, const unsigned int __nocast priority); extern void dccp_ackpkts_free(struct dccp_ackpkts *ap); -extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state); +extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk, + u64 ackno, u8 state); extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, struct sock *sk, u64 ackno); +extern void dccp_timestamp(const struct sock *sk, struct timeval *tv); + static inline suseconds_t timeval_usecs(const struct timeval *tv) { return tv->tv_sec * USEC_PER_SEC + tv->tv_usec; @@ -468,17 +471,6 @@ static inline void timeval_sub_usecs(struct timeval *tv, } } -/* - * Returns the difference in usecs between timeval - * passed in and current time - */ -static inline suseconds_t timeval_now_delta(const struct timeval *tv) -{ - struct timeval now; - do_gettimeofday(&now); - return timeval_delta(&now, tv); -} - #ifdef CONFIG_IP_DCCP_DEBUG extern void dccp_ackvector_print(const u64 ackno, const unsigned char *vector, int len); diff --git a/net/dccp/input.c b/net/dccp/input.c index ef29cef..c60bc34 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c @@ -170,7 +170,7 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, if (dp->dccps_options.dccpo_send_ack_vector) { struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; - if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, + if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk, DCCP_SKB_CB(skb)->dccpd_seq, DCCP_ACKPKTS_STATE_RECEIVED)) { LIMIT_NETDEBUG(KERN_WARNING "DCCP: acknowledgeable " @@ -498,7 +498,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, * DCCP_ACKPKTS_STATE_ECN_MARKED */ if (dp->dccps_options.dccpo_send_ack_vector) { - if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, + if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk, DCCP_SKB_CB(skb)->dccpd_seq, DCCP_ACKPKTS_STATE_RECEIVED)) goto discard; diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 3fc75db..fee9a8c 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -1243,6 +1243,7 @@ static int dccp_v4_init_sock(struct sock *sk) static int dccp_ctl_socket_init = 1; dccp_options_init(&dp->dccps_options); + do_gettimeofday(&dp->dccps_epoch); if (dp->dccps_options.dccpo_send_ack_vector) { dp->dccps_hc_rx_ackpkts = diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index ce5dff4..18461bc 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c @@ -96,6 +96,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk, newdp->dccps_hc_rx_ackpkts = NULL; newdp->dccps_role = DCCP_ROLE_SERVER; newicsk->icsk_rto = DCCP_TIMEOUT_INIT; + do_gettimeofday(&newdp->dccps_epoch); if (newdp->dccps_options.dccpo_send_ack_vector) { newdp->dccps_hc_rx_ackpkts = diff --git a/net/dccp/options.c b/net/dccp/options.c index 34b230a..d4c4242 100644 --- a/net/dccp/options.c +++ b/net/dccp/options.c @@ -140,7 +140,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) opt_recv->dccpor_timestamp = ntohl(*(u32 *)value); dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp; - do_gettimeofday(&dp->dccps_timestamp_time); + dccp_timestamp(sk, &dp->dccps_timestamp_time); dccp_pr_debug("%sTIMESTAMP=%u, ackno=%llu\n", debug_prefix, opt_recv->dccpor_timestamp, @@ -361,9 +361,13 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) #endif struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; int len = ap->dccpap_buf_vector_len + 2; - const u32 elapsed_time = timeval_now_delta(&ap->dccpap_time) / 10; + struct timeval now; + u32 elapsed_time; unsigned char *to, *from; + dccp_timestamp(sk, &now); + elapsed_time = timeval_delta(&now, &ap->dccpap_time) / 10; + if (elapsed_time != 0) dccp_insert_option_elapsed_time(sk, skb, elapsed_time); @@ -428,13 +432,29 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) (unsigned long long) ap->dccpap_ack_ackno); } +void dccp_timestamp(const struct sock *sk, struct timeval *tv) +{ + const struct dccp_sock *dp = dccp_sk(sk); + + do_gettimeofday(tv); + tv->tv_sec -= dp->dccps_epoch.tv_sec; + tv->tv_usec -= dp->dccps_epoch.tv_usec; + + while (tv->tv_usec < 0) { + tv->tv_sec--; + tv->tv_usec += USEC_PER_SEC; + } +} + +EXPORT_SYMBOL_GPL(dccp_timestamp); + void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb) { struct timeval tv; u32 now; - do_gettimeofday(&tv); - now = (tv.tv_sec * USEC_PER_SEC + tv.tv_usec) / 10; + dccp_timestamp(sk, &tv); + now = timeval_usecs(&tv) / 10; /* yes this will overflow but that is the point as we want a * 10 usec 32 bit timer which mean it wraps every 11.9 hours */ @@ -452,13 +472,17 @@ static void dccp_insert_option_timestamp_echo(struct sock *sk, const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT TX opt: " : "server TX opt: "; #endif + struct timeval now; u32 tstamp_echo; - const u32 elapsed_time = - timeval_now_delta(&dp->dccps_timestamp_time) / 10; - const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time); - const int len = 6 + elapsed_time_len; + u32 elapsed_time; + int len, elapsed_time_len; unsigned char *to; + dccp_timestamp(sk, &now); + elapsed_time = timeval_delta(&now, &dp->dccps_timestamp_time) / 10; + elapsed_time_len = dccp_elapsed_time_len(elapsed_time); + len = 6 + elapsed_time_len; + if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert " "timestamp echo!\n"); @@ -623,7 +647,8 @@ static inline int dccp_ackpkts_set_buf_head_state(struct dccp_ackpkts *ap, /* * Implements the draft-ietf-dccp-spec-11.txt Appendix A */ -int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) +int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk, + u64 ackno, u8 state) { /* * Check at the right places if the buffer is full, if it is, tell the @@ -704,7 +729,7 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) } ap->dccpap_buf_ackno = ackno; - do_gettimeofday(&ap->dccpap_time); + dccp_timestamp(sk, &ap->dccpap_time); out: dccp_pr_debug(""); dccp_ackpkts_print(ap); -- cgit v0.10.2 From 59725dc2a2e86a03bbf97976ede3bdc6f95bba92 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:40:58 -0300 Subject: [CCID3] Introduce ccid3_hc_[rt]x_sk() for overal consistency Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 348e6fb..ea30012d 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -112,8 +112,7 @@ static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state) static inline void ccid3_hc_tx_set_state(struct sock *sk, enum ccid3_hc_tx_states state) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state; ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", @@ -154,8 +153,7 @@ static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx) */ static void ccid3_hc_tx_update_x(struct sock *sk) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); /* To avoid large error in calcX */ if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { @@ -184,9 +182,8 @@ static void ccid3_hc_tx_update_x(struct sock *sk) static void ccid3_hc_tx_no_feedback_timer(unsigned long data) { struct sock *sk = (struct sock *)data; - struct dccp_sock *dp = dccp_sk(sk); unsigned long next_tmout = 0; - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); bh_lock_sock(sk); if (sock_owned_by_user(sk)) { @@ -284,7 +281,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb, int len) { struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); struct dccp_tx_hist_entry *new_packet; struct timeval now; long delay; @@ -370,8 +367,8 @@ out: static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + const struct dccp_sock *dp = dccp_sk(sk); + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); struct timeval now; BUG_ON(hctx == NULL); @@ -457,8 +454,8 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + const struct dccp_sock *dp = dccp_sk(sk); + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); struct ccid3_options_received *opt_recv; struct dccp_tx_hist_entry *packet; struct timeval now; @@ -609,8 +606,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) static void ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb) { - const struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); if (hctx == NULL || !(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) @@ -624,8 +620,8 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, unsigned char *value) { int rc = 0; - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + const struct dccp_sock *dp = dccp_sk(sk); + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); struct ccid3_options_received *opt_recv; if (hctx == NULL) @@ -688,11 +684,11 @@ static int ccid3_hc_tx_init(struct sock *sk) ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); - hctx = dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), - gfp_any()); - if (hctx == NULL) + dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), gfp_any()); + if (dp->dccps_hc_tx_ccid_private == NULL) return -ENOMEM; + hctx = ccid3_hc_tx_sk(sk); memset(hctx, 0, sizeof(*hctx)); if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && @@ -714,7 +710,7 @@ static int ccid3_hc_tx_init(struct sock *sk) static void ccid3_hc_tx_exit(struct sock *sk) { struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); BUG_ON(hctx == NULL); @@ -756,8 +752,7 @@ static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state) static inline void ccid3_hc_rx_set_state(struct sock *sk, enum ccid3_hc_rx_states state) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state; ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", @@ -769,8 +764,8 @@ static inline void ccid3_hc_rx_set_state(struct sock *sk, static void ccid3_hc_rx_send_feedback(struct sock *sk) { + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; struct dccp_rx_hist_entry *packet; struct timeval now; @@ -822,9 +817,8 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) { - const struct dccp_sock *dp = dccp_sk(sk); + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); u32 x_recv, pinv; - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; if (hcrx == NULL || !(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) @@ -853,8 +847,7 @@ static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); struct dccp_rx_hist_entry *entry, *next, *tail = NULL; u32 rtt, delta, x_recv, fval, p, tmp2; struct timeval tstamp = { 0, }; @@ -926,8 +919,7 @@ found: static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); if (seq_loss != DCCP_MAX_SEQNO + 1 && list_empty(&hcrx->ccid3hcrx_li_hist)) { @@ -945,8 +937,7 @@ static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) static void ccid3_hc_rx_detect_loss(struct sock *sk) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); u8 win_loss; const u64 seq_loss = dccp_rx_hist_detect_loss(&hcrx->ccid3hcrx_hist, &hcrx->ccid3hcrx_li_hist, @@ -957,8 +948,7 @@ static void ccid3_hc_rx_detect_loss(struct sock *sk) static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); const struct dccp_options_received *opt_recv; struct dccp_rx_hist_entry *packet; struct timeval now; @@ -972,7 +962,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) BUG_ON(!(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA || hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA)); - opt_recv = &dp->dccps_options_received; + opt_recv = &dccp_sk(sk)->dccps_options_received; switch (DCCP_SKB_CB(skb)->dccpd_type) { case DCCP_PKT_ACK: @@ -1085,11 +1075,11 @@ static int ccid3_hc_rx_init(struct sock *sk) ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); - hcrx = dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), - gfp_any()); - if (hcrx == NULL) + dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), gfp_any()); + if (dp->dccps_hc_rx_ccid_private == NULL) return -ENOMEM; + hcrx = ccid3_hc_rx_sk(sk); memset(hcrx, 0, sizeof(*hcrx)); if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && @@ -1109,8 +1099,8 @@ static int ccid3_hc_rx_init(struct sock *sk) static void ccid3_hc_rx_exit(struct sock *sk) { + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); @@ -1131,8 +1121,7 @@ static void ccid3_hc_rx_exit(struct sock *sk) static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) { - const struct dccp_sock *dp = dccp_sk(sk); - const struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; + const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); if (hcrx == NULL) return; @@ -1144,8 +1133,7 @@ static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) { - const struct dccp_sock *dp = dccp_sk(sk); - const struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); if (hctx == NULL) return; diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h index 58be612..d16f00d 100644 --- a/net/dccp/ccids/ccid3.h +++ b/net/dccp/ccids/ccid3.h @@ -128,10 +128,14 @@ struct ccid3_hc_rx_sock { u32 ccid3hcrx_x_recv; }; -#define ccid3_hc_tx_field(s,field) (s->dccps_hc_tx_ccid_private == NULL ? 0 : \ - ((struct ccid3_hc_tx_sock *)s->dccps_hc_tx_ccid_private)->ccid3hctx_##field) +static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) +{ + return dccp_sk(sk)->dccps_hc_tx_ccid_private; +} -#define ccid3_hc_rx_field(s,field) (s->dccps_hc_rx_ccid_private == NULL ? 0 : \ - ((struct ccid3_hc_rx_sock *)s->dccps_hc_rx_ccid_private)->ccid3hcrx_##field) +static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk) +{ + return dccp_sk(sk)->dccps_hc_rx_ccid_private; +} #endif /* _DCCP_CCID3_H_ */ -- cgit v0.10.2 From 9c2c389307c03a35672c80725ccf7968656d87ef Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 9 Sep 2005 11:12:51 +0100 Subject: [ARM] Add memory type based allocation syscalls Add syscall numbers and syscall table entries for mbind, set_mempolicy and get_mempolicy. Signed-off-by: Russell King diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S index db07ce4..cc89a73 100644 --- a/arch/arm/kernel/calls.S +++ b/arch/arm/kernel/calls.S @@ -10,7 +10,7 @@ * This file is included twice in entry-common.S */ #ifndef NR_syscalls -#define NR_syscalls 320 +#define NR_syscalls 328 #else __syscall_start: @@ -333,6 +333,9 @@ __syscall_start: .long sys_inotify_init .long sys_inotify_add_watch .long sys_inotify_rm_watch + .long sys_mbind +/* 320 */ .long sys_get_mempolicy + .long sys_set_mempolicy __syscall_end: .rept NR_syscalls - (__syscall_end - __syscall_start) / 4 diff --git a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h index 278de61..c49df63 100644 --- a/include/asm-arm/unistd.h +++ b/include/asm-arm/unistd.h @@ -355,6 +355,9 @@ #define __NR_inotify_init (__NR_SYSCALL_BASE+316) #define __NR_inotify_add_watch (__NR_SYSCALL_BASE+317) #define __NR_inotify_rm_watch (__NR_SYSCALL_BASE+318) +#define __NR_mbind (__NR_SYSCALL_BASE+319) +#define __NR_get_mempolicy (__NR_SYSCALL_BASE+320) +#define __NR_set_mempolicy (__NR_SYSCALL_BASE+321) /* * The following SWIs are ARM private. -- cgit v0.10.2 From a84195f36e373001e6eed2e95a5dc1994cf30480 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 18 Aug 2005 19:35:21 +0200 Subject: [PATCH] ppc64: fix IPI on bpa_iic This fixes a severe bug in the bpa_iic driver that caused all sorts of problems. We had been using incorrect priority values for inter processor interrupts, which resulted in always doing CALL_FUNCTION instead of RESCHEDULE or DEBUGGER_BREAK. The symptoms cured by this patch include bad performance on SMP systems spurious kernel panics in the IPI code. Signed-off-by: Arnd Bergmann Signed-off-by: Paul Mackerras diff --git a/arch/ppc64/kernel/bpa_iic.c b/arch/ppc64/kernel/bpa_iic.c index c8f3dc3..0aaa878 100644 --- a/arch/ppc64/kernel/bpa_iic.c +++ b/arch/ppc64/kernel/bpa_iic.c @@ -205,6 +205,18 @@ static struct iic_regs __iomem *find_iic(int cpu) } #ifdef CONFIG_SMP + +/* Use the highest interrupt priorities for IPI */ +static inline int iic_ipi_to_irq(int ipi) +{ + return IIC_IPI_OFFSET + IIC_NUM_IPIS - 1 - ipi; +} + +static inline int iic_irq_to_ipi(int irq) +{ + return IIC_NUM_IPIS - 1 - (irq - IIC_IPI_OFFSET); +} + void iic_setup_cpu(void) { out_be64(&__get_cpu_var(iic).regs->prio, 0xff); @@ -212,18 +224,20 @@ void iic_setup_cpu(void) void iic_cause_IPI(int cpu, int mesg) { - out_be64(&per_cpu(iic, cpu).regs->generate, mesg); + out_be64(&per_cpu(iic, cpu).regs->generate, (IIC_NUM_IPIS - 1 - mesg) << 4); } static irqreturn_t iic_ipi_action(int irq, void *dev_id, struct pt_regs *regs) { - - smp_message_recv(irq - IIC_IPI_OFFSET, regs); + smp_message_recv(iic_irq_to_ipi(irq), regs); return IRQ_HANDLED; } -static void iic_request_ipi(int irq, const char *name) +static void iic_request_ipi(int ipi, const char *name) { + int irq; + + irq = iic_ipi_to_irq(ipi); /* IPIs are marked SA_INTERRUPT as they must run with irqs * disabled */ get_irq_desc(irq)->handler = &iic_pic; @@ -233,10 +247,10 @@ static void iic_request_ipi(int irq, const char *name) void iic_request_IPIs(void) { - iic_request_ipi(IIC_IPI_OFFSET + PPC_MSG_CALL_FUNCTION, "IPI-call"); - iic_request_ipi(IIC_IPI_OFFSET + PPC_MSG_RESCHEDULE, "IPI-resched"); + iic_request_ipi(PPC_MSG_CALL_FUNCTION, "IPI-call"); + iic_request_ipi(PPC_MSG_RESCHEDULE, "IPI-resched"); #ifdef CONFIG_DEBUGGER - iic_request_ipi(IIC_IPI_OFFSET + PPC_MSG_DEBUGGER_BREAK, "IPI-debug"); + iic_request_ipi(PPC_MSG_DEBUGGER_BREAK, "IPI-debug"); #endif /* CONFIG_DEBUGGER */ } #endif /* CONFIG_SMP */ -- cgit v0.10.2 From 34b5233f379847097a1925a02b62f129c407c1e4 Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Tue, 6 Sep 2005 21:00:02 +1000 Subject: [PATCH] ppc64: Fix oops for !CONFIG_NUMA The SPARSEMEM EXTREME code (802f192e4a600f7ef84ca25c8b818c8830acef5a) that went in yesterday broke PPC64 for !CONFIG_NUMA. The problem is that (free|reserve)_bootmem don't take a page number as their first argument, they take an address. Ruh roh. Booted on P5 LPAR, iSeries and G5. Signed-off-by: Michael Ellerman Signed-off-by: Paul Mackerras diff --git a/arch/ppc64/mm/init.c b/arch/ppc64/mm/init.c index a14ab87..c2157c9 100644 --- a/arch/ppc64/mm/init.c +++ b/arch/ppc64/mm/init.c @@ -554,12 +554,12 @@ void __init do_init_bootmem(void) * present. */ for (i=0; i < lmb.memory.cnt; i++) - free_bootmem(lmb_start_pfn(&lmb.memory, i), + free_bootmem(lmb.memory.region[i].base, lmb_size_bytes(&lmb.memory, i)); /* reserve the sections we're already using */ for (i=0; i < lmb.reserved.cnt; i++) - reserve_bootmem(lmb_start_pfn(&lmb.reserved, i), + reserve_bootmem(lmb.reserved.region[i].base, lmb_size_bytes(&lmb.reserved, i)); for (i=0; i < lmb.memory.cnt; i++) -- cgit v0.10.2 From 38c0ff06d5ba05b6fbf18652c49747ad320aaeb0 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Wed, 7 Sep 2005 19:52:38 +1000 Subject: [PATCH] ppc64: iSeries early printk breakage The earlier commit 8d9273918635f0301368c01b56c03a6f339e8d51 (Consolidate early console and PPCDBG code) broke iSeries because it caused unregister_console(&udbg_console) to be called unconditionally. iSeries never registers the udbg_console. This just reverts part of the change. Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras diff --git a/arch/ppc64/kernel/udbg.c b/arch/ppc64/kernel/udbg.c index ed6766e..d49c361 100644 --- a/arch/ppc64/kernel/udbg.c +++ b/arch/ppc64/kernel/udbg.c @@ -158,14 +158,20 @@ static struct console udbg_console = { .index = -1, }; +static int early_console_initialized; + void __init disable_early_printk(void) { + if (!early_console_initialized) + return; unregister_console(&udbg_console); + early_console_initialized = 0; } /* called by setup_system */ void register_early_udbg_console(void) { + early_console_initialized = 1; register_console(&udbg_console); } -- cgit v0.10.2 From a37c8875a764b4decf941859f4a2c63e1e86c8fa Mon Sep 17 00:00:00 2001 From: "jdl@freescale.com" Date: Wed, 7 Sep 2005 15:27:09 -0500 Subject: [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix Standardize on _ASM_POWERPC_... prefix for all #include exclusion symbols. Fixup all the non-compilers. Signed-off-by: Jon Loeliger Signed-off-by: Kumar Gala Signed-off-by: Paul Mackerras diff --git a/include/asm-powerpc/8253pit.h b/include/asm-powerpc/8253pit.h index 862708a..b70d6e5 100644 --- a/include/asm-powerpc/8253pit.h +++ b/include/asm-powerpc/8253pit.h @@ -1,10 +1,10 @@ +#ifndef _ASM_POWERPC_8253PIT_H +#define _ASM_POWERPC_8253PIT_H + /* * 8253/8254 Programmable Interval Timer */ -#ifndef _8253PIT_H -#define _8253PIT_H - #define PIT_TICK_RATE 1193182UL -#endif +#endif /* _ASM_POWERPC_8253PIT_H */ diff --git a/include/asm-powerpc/agp.h b/include/asm-powerpc/agp.h index ca9e423..885b463 100644 --- a/include/asm-powerpc/agp.h +++ b/include/asm-powerpc/agp.h @@ -1,10 +1,8 @@ -#ifndef AGP_H -#define AGP_H 1 +#ifndef _ASM_POWERPC_AGP_H +#define _ASM_POWERPC_AGP_H #include -/* nothing much needed here */ - #define map_page_into_agp(page) #define unmap_page_from_agp(page) #define flush_agp_mappings() @@ -20,4 +18,4 @@ #define free_gatt_pages(table, order) \ free_pages((unsigned long)(table), (order)) -#endif +#endif /* _ASM_POWERPC_AGP_H */ diff --git a/include/asm-powerpc/bugs.h b/include/asm-powerpc/bugs.h index 310187d..f5caee8 100644 --- a/include/asm-powerpc/bugs.h +++ b/include/asm-powerpc/bugs.h @@ -1,5 +1,5 @@ -#ifndef _POWERPC_BUGS_H -#define _POWERPC_BUGS_H +#ifndef _ASM_POWERPC_BUGS_H +#define _ASM_POWERPC_BUGS_H /* * This program is free software; you can redistribute it and/or @@ -15,4 +15,4 @@ extern void check_bugs(void); -#endif /* _POWERPC_BUGS_H */ +#endif /* _ASM_POWERPC_BUGS_H */ diff --git a/include/asm-powerpc/errno.h b/include/asm-powerpc/errno.h index 19f20bd..8c145fd 100644 --- a/include/asm-powerpc/errno.h +++ b/include/asm-powerpc/errno.h @@ -1,5 +1,5 @@ -#ifndef _PPC_ERRNO_H -#define _PPC_ERRNO_H +#ifndef _ASM_POWERPC_ERRNO_H +#define _ASM_POWERPC_ERRNO_H #include @@ -8,4 +8,4 @@ #define _LAST_ERRNO 516 -#endif +#endif /* _ASM_POWERPC_ERRNO_H */ diff --git a/include/asm-powerpc/ioctl.h b/include/asm-powerpc/ioctl.h index 93c6acf..8eb9984 100644 --- a/include/asm-powerpc/ioctl.h +++ b/include/asm-powerpc/ioctl.h @@ -1,5 +1,5 @@ -#ifndef _PPC_IOCTL_H -#define _PPC_IOCTL_H +#ifndef _ASM_POWERPC_IOCTL_H +#define _ASM_POWERPC_IOCTL_H /* @@ -66,4 +66,4 @@ extern unsigned int __invalid_size_argument_for_IOC; #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) #define IOCSIZE_SHIFT (_IOC_SIZESHIFT) -#endif +#endif /* _ASM_POWERPC_IOCTL_H */ diff --git a/include/asm-powerpc/ioctls.h b/include/asm-powerpc/ioctls.h index f5b7f2b..5b94ff4 100644 --- a/include/asm-powerpc/ioctls.h +++ b/include/asm-powerpc/ioctls.h @@ -1,5 +1,5 @@ -#ifndef _ASM_PPC_IOCTLS_H -#define _ASM_PPC_IOCTLS_H +#ifndef _ASM_POWERPC_IOCTLS_H +#define _ASM_POWERPC_IOCTLS_H #include @@ -104,4 +104,4 @@ #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ -#endif /* _ASM_PPC_IOCTLS_H */ +#endif /* _ASM_POWERPC_IOCTLS_H */ diff --git a/include/asm-powerpc/linkage.h b/include/asm-powerpc/linkage.h index 291c2d0..e1c4ac1 100644 --- a/include/asm-powerpc/linkage.h +++ b/include/asm-powerpc/linkage.h @@ -1,6 +1,6 @@ -#ifndef __ASM_LINKAGE_H -#define __ASM_LINKAGE_H +#ifndef _ASM_POWERPC_LINKAGE_H +#define _ASM_POWERPC_LINKAGE_H /* Nothing to see here... */ -#endif +#endif /* _ASM_POWERPC_LINKAGE_H */ diff --git a/include/asm-powerpc/mc146818rtc.h b/include/asm-powerpc/mc146818rtc.h index a5619a2..f2741c8 100644 --- a/include/asm-powerpc/mc146818rtc.h +++ b/include/asm-powerpc/mc146818rtc.h @@ -1,5 +1,5 @@ -#ifndef _POWERPC_MC146818RTC_H -#define _POWERPC_MC146818RTC_H +#ifndef _ASM_POWERPC_MC146818RTC_H +#define _ASM_POWERPC_MC146818RTC_H /* * Machine dependent access functions for RTC registers. @@ -33,4 +33,4 @@ outb_p((val),RTC_PORT(1)); \ }) #endif /* __KERNEL__ */ -#endif /* _POWERPC_MC146818RTC_H */ +#endif /* _ASM_POWERPC_MC146818RTC_H */ diff --git a/include/asm-powerpc/mman.h b/include/asm-powerpc/mman.h index f2d5598..f5e5342 100644 --- a/include/asm-powerpc/mman.h +++ b/include/asm-powerpc/mman.h @@ -1,5 +1,5 @@ -#ifndef _POWERPC_MMAN_H -#define _POWERPC_MMAN_H +#ifndef _ASM_POWERPC_MMAN_H +#define _ASM_POWERPC_MMAN_H /* * This program is free software; you can redistribute it and/or @@ -49,4 +49,4 @@ #define MAP_ANON MAP_ANONYMOUS #define MAP_FILE 0 -#endif /* _POWERPC_MMAN_H */ +#endif /* _ASM_POWERPC_MMAN_H */ diff --git a/include/asm-powerpc/module.h b/include/asm-powerpc/module.h index 4438f4f..7ecd05e 100644 --- a/include/asm-powerpc/module.h +++ b/include/asm-powerpc/module.h @@ -1,5 +1,5 @@ -#ifndef _POWERPC_MODULE_H -#define _POWERPC_MODULE_H +#ifndef _ASM_POWERPC_MODULE_H +#define _ASM_POWERPC_MODULE_H /* * This program is free software; you can redistribute it and/or @@ -74,4 +74,4 @@ struct exception_table_entry; void sort_ex_table(struct exception_table_entry *start, struct exception_table_entry *finish); -#endif /* _POWERPC_MODULE_H */ +#endif /* _ASM_POWERPC_MODULE_H */ diff --git a/include/asm-powerpc/namei.h b/include/asm-powerpc/namei.h index 29c9ec8..6574434 100644 --- a/include/asm-powerpc/namei.h +++ b/include/asm-powerpc/namei.h @@ -1,14 +1,14 @@ +#ifndef _ASM_POWERPC_NAMEI_H +#define _ASM_POWERPC_NAMEI_H + +#ifdef __KERNEL__ + /* - * include/asm-ppc/namei.h * Adapted from include/asm-alpha/namei.h * * Included from fs/namei.c */ -#ifdef __KERNEL__ -#ifndef __PPC_NAMEI_H -#define __PPC_NAMEI_H - /* This dummy routine maybe changed to something useful * for /usr/gnemul/ emulation stuff. * Look at asm-sparc/namei.h for details. @@ -16,5 +16,5 @@ #define __emul_prefix() NULL -#endif /* __PPC_NAMEI_H */ -#endif /* __KERNEL__ */ +#endif /* __KERNEL__ */ +#endif /* _ASM_POWERPC_NAMEI_H */ diff --git a/include/asm-powerpc/poll.h b/include/asm-powerpc/poll.h index be50249..edd2054 100644 --- a/include/asm-powerpc/poll.h +++ b/include/asm-powerpc/poll.h @@ -1,5 +1,5 @@ -#ifndef __PPC_POLL_H -#define __PPC_POLL_H +#ifndef _ASM_POWERPC_POLL_H +#define _ASM_POWERPC_POLL_H #define POLLIN 0x0001 #define POLLPRI 0x0002 @@ -20,4 +20,4 @@ struct pollfd { short revents; }; -#endif +#endif /* _ASM_POWERPC_POLL_H */ diff --git a/include/asm-powerpc/sembuf.h b/include/asm-powerpc/sembuf.h index c98fc18..99a4193 100644 --- a/include/asm-powerpc/sembuf.h +++ b/include/asm-powerpc/sembuf.h @@ -1,5 +1,5 @@ -#ifndef _POWERPC_SEMBUF_H -#define _POWERPC_SEMBUF_H +#ifndef _ASM_POWERPC_SEMBUF_H +#define _ASM_POWERPC_SEMBUF_H /* * This program is free software; you can redistribute it and/or @@ -33,4 +33,4 @@ struct semid64_ds { unsigned long __unused4; }; -#endif /* _POWERPC_SEMBUF_H */ +#endif /* _ASM_POWERPC_SEMBUF_H */ diff --git a/include/asm-powerpc/shmbuf.h b/include/asm-powerpc/shmbuf.h index 29632db..dca582a 100644 --- a/include/asm-powerpc/shmbuf.h +++ b/include/asm-powerpc/shmbuf.h @@ -1,5 +1,5 @@ -#ifndef _POWERPC_SHMBUF_H -#define _POWERPC_SHMBUF_H +#ifndef _ASM_POWERPC_SHMBUF_H +#define _ASM_POWERPC_SHMBUF_H /* * This program is free software; you can redistribute it and/or @@ -56,4 +56,4 @@ struct shminfo64 { unsigned long __unused4; }; -#endif /* _POWERPC_SHMBUF_H */ +#endif /* _ASM_POWERPC_SHMBUF_H */ diff --git a/include/asm-powerpc/shmparam.h b/include/asm-powerpc/shmparam.h index d625060..5cda42a 100644 --- a/include/asm-powerpc/shmparam.h +++ b/include/asm-powerpc/shmparam.h @@ -1,6 +1,6 @@ -#ifndef _PPC_SHMPARAM_H -#define _PPC_SHMPARAM_H +#ifndef _ASM_POWERPC_SHMPARAM_H +#define _ASM_POWERPC_SHMPARAM_H #define SHMLBA PAGE_SIZE /* attach addr a multiple of this */ -#endif /* _PPC_SHMPARAM_H */ +#endif /* _ASM_POWERPC_SHMPARAM_H */ diff --git a/include/asm-powerpc/siginfo.h b/include/asm-powerpc/siginfo.h index ae70b80..538ea8e 100644 --- a/include/asm-powerpc/siginfo.h +++ b/include/asm-powerpc/siginfo.h @@ -1,5 +1,5 @@ -#ifndef _POWERPC_SIGINFO_H -#define _POWERPC_SIGINFO_H +#ifndef _ASM_POWERPC_SIGINFO_H +#define _ASM_POWERPC_SIGINFO_H /* * This program is free software; you can redistribute it and/or @@ -15,4 +15,4 @@ #include -#endif /* _POWERPC_SIGINFO_H */ +#endif /* _ASM_POWERPC_SIGINFO_H */ diff --git a/include/asm-powerpc/socket.h b/include/asm-powerpc/socket.h index 51a0cf5..e4b8177 100644 --- a/include/asm-powerpc/socket.h +++ b/include/asm-powerpc/socket.h @@ -1,5 +1,5 @@ -#ifndef _POWERPC_SOCKET_H -#define _POWERPC_SOCKET_H +#ifndef _ASM_POWERPC_SOCKET_H +#define _ASM_POWERPC_SOCKET_H /* * This program is free software; you can redistribute it and/or @@ -56,4 +56,4 @@ #define SO_PEERSEC 31 -#endif /* _POWERPC_SOCKET_H */ +#endif /* _ASM_POWERPC_SOCKET_H */ diff --git a/include/asm-powerpc/sockios.h b/include/asm-powerpc/sockios.h index ef7ff66..590078d 100644 --- a/include/asm-powerpc/sockios.h +++ b/include/asm-powerpc/sockios.h @@ -1,5 +1,5 @@ -#ifndef _POWERPC_SOCKIOS_H -#define _POWERPC_SOCKIOS_H +#ifndef _ASM_POWERPC_SOCKIOS_H +#define _ASM_POWERPC_SOCKIOS_H /* * This program is free software; you can redistribute it and/or @@ -16,4 +16,4 @@ #define SIOCATMARK 0x8905 #define SIOCGSTAMP 0x8906 /* Get stamp */ -#endif /* _POWERPC_SOCKIOS_H */ +#endif /* _ASM_POWERPC_SOCKIOS_H */ diff --git a/include/asm-powerpc/string.h b/include/asm-powerpc/string.h index 2255759..8606a69 100644 --- a/include/asm-powerpc/string.h +++ b/include/asm-powerpc/string.h @@ -1,5 +1,5 @@ -#ifndef _PPC_STRING_H_ -#define _PPC_STRING_H_ +#ifndef _ASM_POWERPC_STRING_H +#define _ASM_POWERPC_STRING_H #ifdef __KERNEL__ @@ -29,4 +29,4 @@ extern void * memchr(const void *,int,__kernel_size_t); #endif /* __KERNEL__ */ -#endif +#endif /* _ASM_POWERPC_STRING_H */ diff --git a/include/asm-powerpc/termbits.h b/include/asm-powerpc/termbits.h index 2c5bf85..ebf6055 100644 --- a/include/asm-powerpc/termbits.h +++ b/include/asm-powerpc/termbits.h @@ -1,5 +1,5 @@ -#ifndef _POWERPC_TERMBITS_H -#define _POWERPC_TERMBITS_H +#ifndef _ASM_POWERPC_TERMBITS_H +#define _ASM_POWERPC_TERMBITS_H /* * This program is free software; you can redistribute it and/or @@ -188,4 +188,4 @@ struct termios { #define TCSADRAIN 1 #define TCSAFLUSH 2 -#endif /* _POWERPC_TERMBITS_H */ +#endif /* _ASM_POWERPC_TERMBITS_H */ diff --git a/include/asm-powerpc/termios.h b/include/asm-powerpc/termios.h index 237533b..c5b8e53 100644 --- a/include/asm-powerpc/termios.h +++ b/include/asm-powerpc/termios.h @@ -1,5 +1,5 @@ -#ifndef _POWERPC_TERMIOS_H -#define _POWERPC_TERMIOS_H +#ifndef _ASM_POWERPC_TERMIOS_H +#define _ASM_POWERPC_TERMIOS_H /* * Liberally adapted from alpha/termios.h. In particular, the c_cc[] @@ -233,4 +233,4 @@ struct termio { #endif /* __KERNEL__ */ -#endif /* _POWERPC_TERMIOS_H */ +#endif /* _ASM_POWERPC_TERMIOS_H */ diff --git a/include/asm-powerpc/unaligned.h b/include/asm-powerpc/unaligned.h index 45520d9..6c95dfa 100644 --- a/include/asm-powerpc/unaligned.h +++ b/include/asm-powerpc/unaligned.h @@ -1,6 +1,7 @@ +#ifndef _ASM_POWERPC_UNALIGNED_H +#define _ASM_POWERPC_UNALIGNED_H + #ifdef __KERNEL__ -#ifndef __PPC_UNALIGNED_H -#define __PPC_UNALIGNED_H /* * The PowerPC can do unaligned accesses itself in big endian mode. @@ -14,5 +15,5 @@ #define put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) -#endif -#endif /* __KERNEL__ */ +#endif /* __KERNEL__ */ +#endif /* _ASM_POWERPC_UNALIGNED_H */ -- cgit v0.10.2 From 64807081e38703617cf9a5d71db14ea2b3e1cb04 Mon Sep 17 00:00:00 2001 From: "jdl@freescale.com" Date: Wed, 7 Sep 2005 15:56:20 -0500 Subject: [PATCH] powerpc: Make check_bugs() static inline Make check_bugs() static inline and remove it from syscalls.c. Signed-off-by: Jon Loeliger Signed-off-by: Kumar Gala Signed-off-by: Paul Mackerras diff --git a/arch/ppc/kernel/syscalls.c b/arch/ppc/kernel/syscalls.c index 124313c..127f040 100644 --- a/arch/ppc/kernel/syscalls.c +++ b/arch/ppc/kernel/syscalls.c @@ -41,10 +41,6 @@ #include #include -void -check_bugs(void) -{ -} /* * sys_ipc() is the de-multiplexer for the SysV IPC calls.. diff --git a/arch/ppc64/kernel/syscalls.c b/arch/ppc64/kernel/syscalls.c index a8cbb20..05f1663 100644 --- a/arch/ppc64/kernel/syscalls.c +++ b/arch/ppc64/kernel/syscalls.c @@ -46,10 +46,6 @@ extern unsigned long wall_jiffies; -void -check_bugs(void) -{ -} /* * sys_ipc() is the de-multiplexer for the SysV IPC calls.. diff --git a/include/asm-powerpc/bugs.h b/include/asm-powerpc/bugs.h index f5caee8..42fdb73 100644 --- a/include/asm-powerpc/bugs.h +++ b/include/asm-powerpc/bugs.h @@ -13,6 +13,6 @@ * architecture-dependent bugs. */ -extern void check_bugs(void); +static inline void check_bugs(void) { } #endif /* _ASM_POWERPC_BUGS_H */ -- cgit v0.10.2 From dd56fdf23dfa0127d512b73d4238dbd2b5a7c1eb Mon Sep 17 00:00:00 2001 From: "jdl@freescale.com" Date: Wed, 7 Sep 2005 15:59:48 -0500 Subject: [PATCH] powerpc: Merge a few more include files Merge a few asm-ppc and asm-ppc64 header files. Note: the merge of setup.h intentionally does not carry forward the m68k cruft. That means this patch continues to break the already broken amiga on the ppc32. Signed-off-by: Jon Loeliger Signed-off-by: Kumar Gala Signed-off-by: Paul Mackerras diff --git a/include/asm-powerpc/msgbuf.h b/include/asm-powerpc/msgbuf.h new file mode 100644 index 0000000..dd76743 --- /dev/null +++ b/include/asm-powerpc/msgbuf.h @@ -0,0 +1,33 @@ +#ifndef _ASM_POWERPC_MSGBUF_H +#define _ASM_POWERPC_MSGBUF_H + +/* + * The msqid64_ds structure for the PowerPC architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + */ + +struct msqid64_ds { + struct ipc64_perm msg_perm; +#ifndef __powerpc64__ + unsigned int __unused1; +#endif + __kernel_time_t msg_stime; /* last msgsnd time */ +#ifndef __powerpc64__ + unsigned int __unused2; +#endif + __kernel_time_t msg_rtime; /* last msgrcv time */ +#ifndef __powerpc64__ + unsigned int __unused3; +#endif + __kernel_time_t msg_ctime; /* last change time */ + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused4; + unsigned long __unused5; +}; + +#endif /* _ASM_POWERPC_MSGBUF_H */ diff --git a/include/asm-powerpc/param.h b/include/asm-powerpc/param.h new file mode 100644 index 0000000..bdc724f --- /dev/null +++ b/include/asm-powerpc/param.h @@ -0,0 +1,24 @@ +#ifndef _ASM_POWERPC_PARAM_H +#define _ASM_POWERPC_PARAM_H + +#include + +#ifdef __KERNEL__ +#define HZ CONFIG_HZ /* internal kernel timer frequency */ +#define USER_HZ 100 /* for user interfaces in "ticks" */ +#define CLOCKS_PER_SEC (USER_HZ) /* frequency at which times() counts */ +#endif /* __KERNEL__ */ + +#ifndef HZ +#define HZ 100 +#endif + +#define EXEC_PAGESIZE 4096 + +#ifndef NOGROUP +#define NOGROUP (-1) +#endif + +#define MAXHOSTNAMELEN 64 /* max length of hostname */ + +#endif /* _ASM_POWERPC_PARAM_H */ diff --git a/include/asm-powerpc/setup.h b/include/asm-powerpc/setup.h new file mode 100644 index 0000000..3d9740a --- /dev/null +++ b/include/asm-powerpc/setup.h @@ -0,0 +1,9 @@ +#ifndef _ASM_POWERPC_SETUP_H +#define _ASM_POWERPC_SETUP_H + +#ifdef __KERNEL__ + +#define COMMAND_LINE_SIZE 512 + +#endif /* __KERNEL__ */ +#endif /* _ASM_POWERPC_SETUP_H */ diff --git a/include/asm-powerpc/timex.h b/include/asm-powerpc/timex.h new file mode 100644 index 0000000..51c5b31 --- /dev/null +++ b/include/asm-powerpc/timex.h @@ -0,0 +1,49 @@ +#ifndef _ASM_POWERPC_TIMEX_H +#define _ASM_POWERPC_TIMEX_H + +#ifdef __KERNEL__ + +/* + * PowerPC architecture timex specifications + */ + +#include +#include + +#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ + +typedef unsigned long cycles_t; + +static inline cycles_t get_cycles(void) +{ + cycles_t ret; + +#ifdef __powerpc64__ + + __asm__ __volatile__("mftb %0" : "=r" (ret) : ); + +#else + /* + * For the "cycle" counter we use the timebase lower half. + * Currently only used on SMP. + */ + + ret = 0; + + __asm__ __volatile__( + "98: mftb %0\n" + "99:\n" + ".section __ftr_fixup,\"a\"\n" + " .long %1\n" + " .long 0\n" + " .long 98b\n" + " .long 99b\n" + ".previous" + : "=r" (ret) : "i" (CPU_FTR_601)); +#endif + + return ret; +} + +#endif /* __KERNEL__ */ +#endif /* _ASM_POWERPC_TIMEX_H */ diff --git a/include/asm-powerpc/topology.h b/include/asm-powerpc/topology.h new file mode 100644 index 0000000..2512e38 --- /dev/null +++ b/include/asm-powerpc/topology.h @@ -0,0 +1,70 @@ +#ifndef _ASM_POWERPC_TOPOLOGY_H +#define _ASM_POWERPC_TOPOLOGY_H + +#include + +#ifdef CONFIG_NUMA + +#include + +static inline int cpu_to_node(int cpu) +{ + int node; + + node = numa_cpu_lookup_table[cpu]; + +#ifdef DEBUG_NUMA + BUG_ON(node == -1); +#endif + + return node; +} + +#define parent_node(node) (node) + +static inline cpumask_t node_to_cpumask(int node) +{ + return numa_cpumask_lookup_table[node]; +} + +static inline int node_to_first_cpu(int node) +{ + cpumask_t tmp; + tmp = node_to_cpumask(node); + return first_cpu(tmp); +} + +#define pcibus_to_node(node) (-1) +#define pcibus_to_cpumask(bus) (cpu_online_map) + +#define nr_cpus_node(node) (nr_cpus_in_node[node]) + +/* sched_domains SD_NODE_INIT for PPC64 machines */ +#define SD_NODE_INIT (struct sched_domain) { \ + .span = CPU_MASK_NONE, \ + .parent = NULL, \ + .groups = NULL, \ + .min_interval = 8, \ + .max_interval = 32, \ + .busy_factor = 32, \ + .imbalance_pct = 125, \ + .cache_hot_time = (10*1000000), \ + .cache_nice_tries = 1, \ + .per_cpu_gain = 100, \ + .flags = SD_LOAD_BALANCE \ + | SD_BALANCE_EXEC \ + | SD_BALANCE_NEWIDLE \ + | SD_WAKE_IDLE \ + | SD_WAKE_BALANCE, \ + .last_balance = jiffies, \ + .balance_interval = 1, \ + .nr_balance_failed = 0, \ +} + +#else + +#include + +#endif /* CONFIG_NUMA */ + +#endif /* _ASM_POWERPC_TOPOLOGY_H */ diff --git a/include/asm-powerpc/user.h b/include/asm-powerpc/user.h new file mode 100644 index 0000000..e59ade4 --- /dev/null +++ b/include/asm-powerpc/user.h @@ -0,0 +1,55 @@ +#ifndef _ASM_POWERPC_USER_H +#define _ASM_POWERPC_USER_H + +#ifdef __KERNEL__ + +#include +#include + +/* + * Adapted from + * + * Core file format: The core file is written in such a way that gdb + * can understand it and provide useful information to the user (under + * linux we use the `trad-core' bfd, NOT the osf-core). The file contents + * are as follows: + * + * upage: 1 page consisting of a user struct that tells gdb + * what is present in the file. Directly after this is a + * copy of the task_struct, which is currently not used by gdb, + * but it may come in handy at some point. All of the registers + * are stored as part of the upage. The upage should always be + * only one page long. + * data: The data segment follows next. We use current->end_text to + * current->brk to pick up all of the user variables, plus any memory + * that may have been sbrk'ed. No attempt is made to determine if a + * page is demand-zero or if a page is totally unused, we just cover + * the entire range. All of the addresses are rounded in such a way + * that an integral number of pages is written. + * stack: We need the stack information in order to get a meaningful + * backtrace. We need to write the data from usp to + * current->start_stack, so we round each of these in order to be able + * to write an integer number of pages. + */ +struct user { + struct pt_regs regs; /* entire machine state */ + size_t u_tsize; /* text size (pages) */ + size_t u_dsize; /* data size (pages) */ + size_t u_ssize; /* stack size (pages) */ + unsigned long start_code; /* text starting address */ + unsigned long start_data; /* data starting address */ + unsigned long start_stack; /* stack starting address */ + long int signal; /* signal causing core dump */ + struct regs * u_ar0; /* help gdb find registers */ + unsigned long magic; /* identifies a core file */ + char u_comm[32]; /* user command name */ +}; + +#define NBPG PAGE_SIZE +#define UPAGES 1 +#define HOST_TEXT_START_ADDR (u.start_code) +#define HOST_DATA_START_ADDR (u.start_data) +#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) + +#endif /* __KERNEL__ */ +#endif /* _ASM_POWERPC_USER_H */ diff --git a/include/asm-ppc/msgbuf.h b/include/asm-ppc/msgbuf.h deleted file mode 100644 index 1053452..0000000 --- a/include/asm-ppc/msgbuf.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _PPC_MSGBUF_H -#define _PPC_MSGBUF_H - -/* - * The msqid64_ds structure for the PPC architecture. - */ - -struct msqid64_ds { - struct ipc64_perm msg_perm; - unsigned int __unused1; - __kernel_time_t msg_stime; /* last msgsnd time */ - unsigned int __unused2; - __kernel_time_t msg_rtime; /* last msgrcv time */ - unsigned int __unused3; - __kernel_time_t msg_ctime; /* last change time */ - unsigned long msg_cbytes; /* current number of bytes on queue */ - unsigned long msg_qnum; /* number of messages in queue */ - unsigned long msg_qbytes; /* max number of bytes on queue */ - __kernel_pid_t msg_lspid; /* pid of last msgsnd */ - __kernel_pid_t msg_lrpid; /* last receive pid */ - unsigned long __unused4; - unsigned long __unused5; -}; - -#endif /* _PPC_MSGBUF_H */ diff --git a/include/asm-ppc/param.h b/include/asm-ppc/param.h deleted file mode 100644 index 6198b16..0000000 --- a/include/asm-ppc/param.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _ASM_PPC_PARAM_H -#define _ASM_PPC_PARAM_H - -#include - -#ifdef __KERNEL__ -#define HZ CONFIG_HZ /* internal timer frequency */ -#define USER_HZ 100 /* for user interfaces in "ticks" */ -#define CLOCKS_PER_SEC (USER_HZ) /* frequency at which times() counts */ -#endif /* __KERNEL__ */ - -#ifndef HZ -#define HZ 100 -#endif - -#define EXEC_PAGESIZE 4096 - -#ifndef NOGROUP -#define NOGROUP (-1) -#endif - -#define MAXHOSTNAMELEN 64 /* max length of hostname */ - -#endif diff --git a/include/asm-ppc/setup.h b/include/asm-ppc/setup.h deleted file mode 100644 index d2d19ee..0000000 --- a/include/asm-ppc/setup.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifdef __KERNEL__ -#ifndef _PPC_SETUP_H -#define _PPC_SETUP_H - -#define m68k_num_memory num_memory -#define m68k_memory memory - -#include -/* We have a bigger command line buffer. */ -#undef COMMAND_LINE_SIZE -#define COMMAND_LINE_SIZE 512 - -#endif /* _PPC_SETUP_H */ -#endif /* __KERNEL__ */ diff --git a/include/asm-ppc/timex.h b/include/asm-ppc/timex.h deleted file mode 100644 index cffc871..0000000 --- a/include/asm-ppc/timex.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * include/asm-ppc/timex.h - * - * ppc architecture timex specifications - */ -#ifdef __KERNEL__ -#ifndef _ASMppc_TIMEX_H -#define _ASMppc_TIMEX_H - -#include -#include - -#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ - -typedef unsigned long cycles_t; - -/* - * For the "cycle" counter we use the timebase lower half. - * Currently only used on SMP. - */ - -static inline cycles_t get_cycles(void) -{ - cycles_t ret = 0; - - __asm__ __volatile__( - "98: mftb %0\n" - "99:\n" - ".section __ftr_fixup,\"a\"\n" - " .long %1\n" - " .long 0\n" - " .long 98b\n" - " .long 99b\n" - ".previous" - : "=r" (ret) : "i" (CPU_FTR_601)); - return ret; -} - -#endif -#endif /* __KERNEL__ */ diff --git a/include/asm-ppc/topology.h b/include/asm-ppc/topology.h deleted file mode 100644 index 6a029bb..0000000 --- a/include/asm-ppc/topology.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _ASM_PPC_TOPOLOGY_H -#define _ASM_PPC_TOPOLOGY_H - -#include - -#endif /* _ASM_PPC_TOPOLOGY_H */ diff --git a/include/asm-ppc/user.h b/include/asm-ppc/user.h deleted file mode 100644 index d662b21..0000000 --- a/include/asm-ppc/user.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifdef __KERNEL__ -#ifndef _PPC_USER_H -#define _PPC_USER_H - -/* Adapted from */ - -#include -#include - -/* - * Core file format: The core file is written in such a way that gdb - * can understand it and provide useful information to the user (under - * linux we use the `trad-core' bfd, NOT the osf-core). The file contents - * are as follows: - * - * upage: 1 page consisting of a user struct that tells gdb - * what is present in the file. Directly after this is a - * copy of the task_struct, which is currently not used by gdb, - * but it may come in handy at some point. All of the registers - * are stored as part of the upage. The upage should always be - * only one page long. - * data: The data segment follows next. We use current->end_text to - * current->brk to pick up all of the user variables, plus any memory - * that may have been sbrk'ed. No attempt is made to determine if a - * page is demand-zero or if a page is totally unused, we just cover - * the entire range. All of the addresses are rounded in such a way - * that an integral number of pages is written. - * stack: We need the stack information in order to get a meaningful - * backtrace. We need to write the data from usp to - * current->start_stack, so we round each of these in order to be able - * to write an integer number of pages. - */ -struct user { - struct pt_regs regs; /* entire machine state */ - size_t u_tsize; /* text size (pages) */ - size_t u_dsize; /* data size (pages) */ - size_t u_ssize; /* stack size (pages) */ - unsigned long start_code; /* text starting address */ - unsigned long start_data; /* data starting address */ - unsigned long start_stack; /* stack starting address */ - long int signal; /* signal causing core dump */ - struct regs * u_ar0; /* help gdb find registers */ - unsigned long magic; /* identifies a core file */ - char u_comm[32]; /* user command name */ -}; - -#define NBPG PAGE_SIZE -#define UPAGES 1 -#define HOST_TEXT_START_ADDR (u.start_code) -#define HOST_DATA_START_ADDR (u.start_data) -#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) - -#endif /* _PPC_USER_H */ -#endif /* __KERNEL__ */ diff --git a/include/asm-ppc64/msgbuf.h b/include/asm-ppc64/msgbuf.h deleted file mode 100644 index 31c1cbf..0000000 --- a/include/asm-ppc64/msgbuf.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _PPC64_MSGBUF_H -#define _PPC64_MSGBUF_H - -/* - * The msqid64_ds structure for the PPC architecture. - * - * 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. - */ - -struct msqid64_ds { - struct ipc64_perm msg_perm; - __kernel_time_t msg_stime; /* last msgsnd time */ - __kernel_time_t msg_rtime; /* last msgrcv time */ - __kernel_time_t msg_ctime; /* last change time */ - unsigned long msg_cbytes; /* current number of bytes on queue */ - unsigned long msg_qnum; /* number of messages in queue */ - unsigned long msg_qbytes; /* max number of bytes on queue */ - __kernel_pid_t msg_lspid; /* pid of last msgsnd */ - __kernel_pid_t msg_lrpid; /* last receive pid */ - unsigned long __unused1; - unsigned long __unused2; -}; - -#endif /* _PPC64_MSGBUF_H */ diff --git a/include/asm-ppc64/param.h b/include/asm-ppc64/param.h deleted file mode 100644 index 76c212d..0000000 --- a/include/asm-ppc64/param.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _ASM_PPC64_PARAM_H -#define _ASM_PPC64_PARAM_H - -#include - -/* - * 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. - */ - -#ifdef __KERNEL__ -# define HZ CONFIG_HZ /* Internal kernel timer frequency */ -# define USER_HZ 100 /* .. some user interfaces are in "ticks" */ -# define CLOCKS_PER_SEC (USER_HZ) /* like times() */ -#endif - -#ifndef HZ -#define HZ 100 -#endif - -#define EXEC_PAGESIZE 4096 - -#ifndef NOGROUP -#define NOGROUP (-1) -#endif - -#define MAXHOSTNAMELEN 64 /* max length of hostname */ - -#endif /* _ASM_PPC64_PARAM_H */ diff --git a/include/asm-ppc64/setup.h b/include/asm-ppc64/setup.h deleted file mode 100644 index b257b83..0000000 --- a/include/asm-ppc64/setup.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _PPC_SETUP_H -#define _PPC_SETUP_H - -#define COMMAND_LINE_SIZE 512 - -#endif /* _PPC_SETUP_H */ diff --git a/include/asm-ppc64/timex.h b/include/asm-ppc64/timex.h deleted file mode 100644 index 8db4da4..0000000 --- a/include/asm-ppc64/timex.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * linux/include/asm-ppc/timex.h - * - * PPC64 architecture timex specifications - * - * 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. - */ -#ifndef _ASMPPC64_TIMEX_H -#define _ASMPPC64_TIMEX_H - -#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ - -typedef unsigned long cycles_t; - -static inline cycles_t get_cycles(void) -{ - cycles_t ret; - - __asm__ __volatile__("mftb %0" : "=r" (ret) : ); - return ret; -} - -#endif diff --git a/include/asm-ppc64/topology.h b/include/asm-ppc64/topology.h deleted file mode 100644 index 1e9b190..0000000 --- a/include/asm-ppc64/topology.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _ASM_PPC64_TOPOLOGY_H -#define _ASM_PPC64_TOPOLOGY_H - -#include -#include - -#ifdef CONFIG_NUMA - -static inline int cpu_to_node(int cpu) -{ - int node; - - node = numa_cpu_lookup_table[cpu]; - -#ifdef DEBUG_NUMA - BUG_ON(node == -1); -#endif - - return node; -} - -#define parent_node(node) (node) - -static inline cpumask_t node_to_cpumask(int node) -{ - return numa_cpumask_lookup_table[node]; -} - -static inline int node_to_first_cpu(int node) -{ - cpumask_t tmp; - tmp = node_to_cpumask(node); - return first_cpu(tmp); -} - -#define pcibus_to_node(node) (-1) -#define pcibus_to_cpumask(bus) (cpu_online_map) - -#define nr_cpus_node(node) (nr_cpus_in_node[node]) - -/* sched_domains SD_NODE_INIT for PPC64 machines */ -#define SD_NODE_INIT (struct sched_domain) { \ - .span = CPU_MASK_NONE, \ - .parent = NULL, \ - .groups = NULL, \ - .min_interval = 8, \ - .max_interval = 32, \ - .busy_factor = 32, \ - .imbalance_pct = 125, \ - .cache_hot_time = (10*1000000), \ - .cache_nice_tries = 1, \ - .per_cpu_gain = 100, \ - .flags = SD_LOAD_BALANCE \ - | SD_BALANCE_EXEC \ - | SD_BALANCE_NEWIDLE \ - | SD_WAKE_IDLE \ - | SD_WAKE_BALANCE, \ - .last_balance = jiffies, \ - .balance_interval = 1, \ - .nr_balance_failed = 0, \ -} - -#else - -#include - -#endif /* CONFIG_NUMA */ - -#endif /* _ASM_PPC64_TOPOLOGY_H */ diff --git a/include/asm-ppc64/user.h b/include/asm-ppc64/user.h deleted file mode 100644 index d7d6554..0000000 --- a/include/asm-ppc64/user.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef _PPC_USER_H -#define _PPC_USER_H - -/* Adapted from - * - * 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. - */ - -#include -#include - -/* - * Core file format: The core file is written in such a way that gdb - * can understand it and provide useful information to the user (under - * linux we use the `trad-core' bfd, NOT the osf-core). The file contents - * are as follows: - * - * upage: 1 page consisting of a user struct that tells gdb - * what is present in the file. Directly after this is a - * copy of the task_struct, which is currently not used by gdb, - * but it may come in handy at some point. All of the registers - * are stored as part of the upage. The upage should always be - * only one page long. - * data: The data segment follows next. We use current->end_text to - * current->brk to pick up all of the user variables, plus any memory - * that may have been sbrk'ed. No attempt is made to determine if a - * page is demand-zero or if a page is totally unused, we just cover - * the entire range. All of the addresses are rounded in such a way - * that an integral number of pages is written. - * stack: We need the stack information in order to get a meaningful - * backtrace. We need to write the data from usp to - * current->start_stack, so we round each of these in order to be able - * to write an integer number of pages. - */ -struct user { - struct pt_regs regs; /* entire machine state */ - size_t u_tsize; /* text size (pages) */ - size_t u_dsize; /* data size (pages) */ - size_t u_ssize; /* stack size (pages) */ - unsigned long start_code; /* text starting address */ - unsigned long start_data; /* data starting address */ - unsigned long start_stack; /* stack starting address */ - long int signal; /* signal causing core dump */ - struct regs * u_ar0; /* help gdb find registers */ - unsigned long magic; /* identifies a core file */ - char u_comm[32]; /* user command name */ -}; - -#define NBPG PAGE_SIZE -#define UPAGES 1 -#define HOST_TEXT_START_ADDR (u.start_code) -#define HOST_DATA_START_ADDR (u.start_data) -#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) - -#endif /* _PPC_USER_H */ -- cgit v0.10.2 From a24c8481b6439cb151a4750cc278ea2df4fb0e53 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 15 Aug 2005 13:59:13 -0700 Subject: [PATCH] ppc64: zimage build fix Signed-off-by: Geoff Levand Signed-off-by: Paul Mackerras diff --git a/arch/ppc64/Makefile b/arch/ppc64/Makefile index 8189953..a91daa3 100644 --- a/arch/ppc64/Makefile +++ b/arch/ppc64/Makefile @@ -89,11 +89,12 @@ drivers-$(CONFIG_OPROFILE) += arch/ppc64/oprofile/ boot := arch/ppc64/boot -boottarget-$(CONFIG_PPC_PSERIES) := zImage zImage.initrd -boottarget-$(CONFIG_PPC_MAPLE) := zImage zImage.initrd -boottarget-$(CONFIG_PPC_ISERIES) := vmlinux.sminitrd vmlinux.initrd vmlinux.sm -boottarget-$(CONFIG_PPC_BPA) := zImage zImage.initrd -$(boottarget-y): vmlinux +boottargets-$(CONFIG_PPC_PSERIES) += zImage zImage.initrd +boottargets-$(CONFIG_PPC_PMAC) += zImage.vmode zImage.initrd.vmode +boottargets-$(CONFIG_PPC_MAPLE) += zImage zImage.initrd +boottargets-$(CONFIG_PPC_ISERIES) += vmlinux.sminitrd vmlinux.initrd vmlinux.sm +boottargets-$(CONFIG_PPC_BPA) += zImage zImage.initrd +$(boottargets-y): vmlinux $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ bootimage-$(CONFIG_PPC_PSERIES) := $(boot)/zImage @@ -131,10 +132,12 @@ include3/asm: $(Q)ln -fsn $(srctree)/include/asm-powerpc include3/asm define archhelp - echo '* zImage - Compressed kernel image (arch/$(ARCH)/boot/zImage)' - echo ' zImage.initrd- Compressed kernel image with initrd attached,' - echo ' sourced from arch/$(ARCH)/boot/ramdisk.image.gz' - echo ' (arch/$(ARCH)/boot/zImage.initrd)' + echo ' zImage.vmode - Compressed kernel image (arch/$(ARCH)/boot/zImage.vmode)' + echo ' zImage.initrd.vmode - Compressed kernel image with initrd attached,' + echo ' sourced from arch/$(ARCH)/boot/ramdisk.image.gz' + echo ' (arch/$(ARCH)/boot/zImage.initrd.vmode)' + echo ' zImage - zImage for pSeries machines' + echo ' zImage.initrd - zImage with initrd for pSeries machines' endef CLEAN_FILES += include/asm-ppc64/offsets.h diff --git a/arch/ppc64/boot/Makefile b/arch/ppc64/boot/Makefile index 2c5f5e7..d3567e4 100644 --- a/arch/ppc64/boot/Makefile +++ b/arch/ppc64/boot/Makefile @@ -37,6 +37,9 @@ quiet_cmd_bootcc = BOOTCC $@ quiet_cmd_bootas = BOOTAS $@ cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< +quiet_cmd_bootld = BOOTLD $@ + cmd_bootld = $(CROSS32LD) $(BOOTLFLAGS) -o $@ $(2) + $(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c $(call if_changed_dep,bootcc) $(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S @@ -53,7 +56,7 @@ src-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.c, $(section))) gz-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.gz, $(section))) hostprogs-y := addnote addRamDisk -targets += zImage zImage.initrd imagesize.c \ +targets += zImage.vmode zImage.initrd.vmode zImage zImage.initrd imagesize.c \ $(patsubst $(obj)/%,%, $(call obj-sec, $(required) $(initrd))) \ $(patsubst $(obj)/%,%, $(call src-sec, $(required) $(initrd))) \ $(patsubst $(obj)/%,%, $(call gz-sec, $(required) $(initrd))) \ @@ -75,8 +78,8 @@ addsection = $(CROSS32OBJCOPY) $(1) \ --add-section=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $(1)))=$(patsubst %.o,%.gz, $(1)) \ --set-section-flags=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $(1)))=$(OBJCOPYFLAGS) -quiet_cmd_addnote = ADDNOTE $@ - cmd_addnote = $(CROSS32LD) $(BOOTLFLAGS) -o $@ $(obj-boot) && $(obj)/addnote $@ +quiet_cmd_addnote = ADDNOTE $@ + cmd_addnote = $(obj)/addnote $@ $(call gz-sec, $(required)): $(obj)/kernel-%.gz: % FORCE $(call if_changed,gzip) @@ -91,12 +94,20 @@ $(call obj-sec, $(required) $(initrd)): $(obj)/kernel-%.o: $(obj)/kernel-%.c FOR $(call if_changed_dep,bootcc) $(call addsection, $@) -$(obj)/zImage: obj-boot += $(call obj-sec, $(required)) -$(obj)/zImage: $(call obj-sec, $(required)) $(obj-boot) $(obj)/addnote FORCE +$(obj)/zImage.vmode: obj-boot += $(call obj-sec, $(required)) +$(obj)/zImage.vmode: $(call obj-sec, $(required)) $(obj-boot) FORCE + $(call cmd,bootld,$(obj-boot)) + +$(obj)/zImage.initrd.vmode: obj-boot += $(call obj-sec, $(required) $(initrd)) +$(obj)/zImage.initrd.vmode: $(call obj-sec, $(required) $(initrd)) $(obj-boot) FORCE + $(call cmd,bootld,$(obj-boot)) + +$(obj)/zImage: $(obj)/zImage.vmode $(obj)/addnote FORCE + @cp -f $< $@ $(call if_changed,addnote) -$(obj)/zImage.initrd: obj-boot += $(call obj-sec, $(required) $(initrd)) -$(obj)/zImage.initrd: $(call obj-sec, $(required) $(initrd)) $(obj-boot) $(obj)/addnote FORCE +$(obj)/zImage.initrd: $(obj)/zImage.initrd.vmode $(obj)/addnote FORCE + @cp -f $< $@ $(call if_changed,addnote) $(obj)/imagesize.c: vmlinux.strip -- cgit v0.10.2 From e4df7671716f1fffb3437a7c1a14e3d2465fefef Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Wed, 10 Aug 2005 17:57:42 -0700 Subject: [PATCH] ppc64: makefile cleanup This patch cleans up the output generated by ppc64 builds. Signed-off-by: Geoff Levand Signed-off-by: Paul Mackerras diff --git a/arch/ppc64/boot/Makefile b/arch/ppc64/boot/Makefile index d3567e4..33fdc87 100644 --- a/arch/ppc64/boot/Makefile +++ b/arch/ppc64/boot/Makefile @@ -66,7 +66,7 @@ extra-y := initrd.o quiet_cmd_ramdisk = RAMDISK $@ cmd_ramdisk = $(obj)/addRamDisk $(obj)/ramdisk.image.gz $< $@ -quiet_cmd_stripvm = STRIP $@ +quiet_cmd_stripvm = STRIP $@ cmd_stripvm = $(STRIP) -s $< -o $@ vmlinux.strip: vmlinux FORCE @@ -74,9 +74,17 @@ vmlinux.strip: vmlinux FORCE $(obj)/vmlinux.initrd: vmlinux.strip $(obj)/addRamDisk $(obj)/ramdisk.image.gz FORCE $(call if_changed,ramdisk) -addsection = $(CROSS32OBJCOPY) $(1) \ - --add-section=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $(1)))=$(patsubst %.o,%.gz, $(1)) \ - --set-section-flags=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $(1)))=$(OBJCOPYFLAGS) +quiet_cmd_addsection = ADDSEC $@ + cmd_addsection = $(CROSS32OBJCOPY) $@ \ + --add-section=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $@))=$(patsubst %.o,%.gz, $@) \ + --set-section-flags=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $@))=$(OBJCOPYFLAGS) + +quiet_cmd_imagesize = GENSIZE $@ + cmd_imagesize = ls -l vmlinux.strip | \ + awk '{printf "/* generated -- do not edit! */\n" "unsigned long vmlinux_filesize = %d;\n", $$5}' \ + > $(obj)/imagesize.c && \ + $(CROSS_COMPILE)nm -n vmlinux | tail -n 1 | \ + awk '{printf "unsigned long vmlinux_memsize = 0x%s;\n", substr($$1,8)}' >> $(obj)/imagesize.c quiet_cmd_addnote = ADDNOTE $@ cmd_addnote = $(obj)/addnote $@ @@ -88,11 +96,11 @@ $(obj)/kernel-initrd.gz: $(obj)/ramdisk.image.gz cp -f $(obj)/ramdisk.image.gz $@ $(call src-sec, $(required) $(initrd)): $(obj)/kernel-%.c: $(obj)/kernel-%.gz FORCE - touch $@ + @touch $@ $(call obj-sec, $(required) $(initrd)): $(obj)/kernel-%.o: $(obj)/kernel-%.c FORCE $(call if_changed_dep,bootcc) - $(call addsection, $@) + $(call cmd,addsection) $(obj)/zImage.vmode: obj-boot += $(call obj-sec, $(required)) $(obj)/zImage.vmode: $(call obj-sec, $(required)) $(obj-boot) FORCE @@ -111,13 +119,7 @@ $(obj)/zImage.initrd: $(obj)/zImage.initrd.vmode $(obj)/addnote FORCE $(call if_changed,addnote) $(obj)/imagesize.c: vmlinux.strip - @echo Generating $@ - ls -l vmlinux.strip | \ - awk '{printf "/* generated -- do not edit! */\n" \ - "unsigned long vmlinux_filesize = %d;\n", $$5}' > $(obj)/imagesize.c - $(CROSS_COMPILE)nm -n vmlinux | tail -n 1 | \ - awk '{printf "unsigned long vmlinux_memsize = 0x%s;\n", substr($$1,8)}' \ - >> $(obj)/imagesize.c + $(call cmd,imagesize) install: $(CONFIGURE) $(BOOTIMAGE) sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" "$(BOOTIMAGE)" -- cgit v0.10.2 From f9526785d8a03fd0e21f9cfc951adc03bde1c395 Mon Sep 17 00:00:00 2001 From: "jdl@freescale.com" Date: Thu, 8 Sep 2005 14:05:49 -0500 Subject: [PATCH] powerpc: Fix __power64__ typos that should be __powerpc64__ Fix __power64__ typo that should be __powerpc64__ instead. Signed-off-by: Jon Loeliger Signed-off-by: Kumar Gala Signed-off-by: Paul Mackerras diff --git a/include/asm-powerpc/shmbuf.h b/include/asm-powerpc/shmbuf.h index dca582a..8efa396 100644 --- a/include/asm-powerpc/shmbuf.h +++ b/include/asm-powerpc/shmbuf.h @@ -21,19 +21,19 @@ struct shmid64_ds { struct ipc64_perm shm_perm; /* operation perms */ -#ifndef __power64__ +#ifndef __powerpc64__ unsigned long __unused1; #endif __kernel_time_t shm_atime; /* last attach time */ -#ifndef __power64__ +#ifndef __powerpc64__ unsigned long __unused2; #endif __kernel_time_t shm_dtime; /* last detach time */ -#ifndef __power64__ +#ifndef __powerpc64__ unsigned long __unused3; #endif __kernel_time_t shm_ctime; /* last change time */ -#ifndef __power64__ +#ifndef __powerpc64__ unsigned long __unused4; #endif size_t shm_segsz; /* size of segment (bytes) */ -- cgit v0.10.2 From 3cc747e96480d4e26560e5bc59f2b9c9204ade0e Mon Sep 17 00:00:00 2001 From: Mark Bellon Date: Tue, 6 Sep 2005 15:50:02 -0700 Subject: [PATCH] PPC64: large INITRD causes kernel not to boot In PPC64 there are number of problems in arch/ppc64/boot/main.c that prevent a kernel from making use of a large (greater than ~16MB) INITRD. This is 64 bit architecture and really large INITRD images should be possible. Simply put the existing code has a fixed reservation (claim) address and once the kernel plus initrd image are large enough to pass this address all sorts of bad things occur. The fix is the dynamically establish the first claim address above the loaded kernel plus initrd (plus some "padding" and rounding). If PROG_START is defined this will be used as the minimum safe address - currently known to be 0x01400000 for the firmwares tested so far. Signed-off-by: Mark Bellon Signed-off-by: Paul Mackerras diff --git a/arch/ppc64/boot/main.c b/arch/ppc64/boot/main.c index 99e68cf..f7ec19a 100644 --- a/arch/ppc64/boot/main.c +++ b/arch/ppc64/boot/main.c @@ -23,7 +23,8 @@ extern void flush_cache(void *, unsigned long); /* Value picked to match that used by yaboot */ #define PROG_START 0x01400000 -#define RAM_END (256<<20) // Fixme: use OF */ +#define RAM_END (512<<20) // Fixme: use OF */ +#define ONE_MB 0x100000 static char *avail_ram; static char *begin_avail, *end_avail; @@ -32,6 +33,7 @@ static unsigned int heap_use; static unsigned int heap_max; extern char _start[]; +extern char _end[]; extern char _vmlinux_start[]; extern char _vmlinux_end[]; extern char _initrd_start[]; @@ -58,13 +60,13 @@ typedef void (*kernel_entry_t)( unsigned long, #undef DEBUG -static unsigned long claim_base = PROG_START; +static unsigned long claim_base; static unsigned long try_claim(unsigned long size) { unsigned long addr = 0; - for(; claim_base < RAM_END; claim_base += 0x100000) { + for(; claim_base < RAM_END; claim_base += ONE_MB) { #ifdef DEBUG printf(" trying: 0x%08lx\n\r", claim_base); #endif @@ -95,7 +97,26 @@ void start(unsigned long a1, unsigned long a2, void *promptr) if (getprop(chosen_handle, "stdin", &stdin, sizeof(stdin)) != 4) exit(); - printf("\n\rzImage starting: loaded at 0x%x\n\r", (unsigned)_start); + printf("\n\rzImage starting: loaded at 0x%lx\n\r", (unsigned long) _start); + + /* + * The first available claim_base must be above the end of the + * the loaded kernel wrapper file (_start to _end includes the + * initrd image if it is present) and rounded up to a nice + * 1 MB boundary for good measure. + */ + + claim_base = _ALIGN_UP((unsigned long)_end, ONE_MB); + +#if defined(PROG_START) + /* + * Maintain a "magic" minimum address. This keeps some older + * firmware platforms running. + */ + + if (claim_base < PROG_START) + claim_base = PROG_START; +#endif /* * Now we try to claim some memory for the kernel itself @@ -105,7 +126,7 @@ void start(unsigned long a1, unsigned long a2, void *promptr) * size... In practice we add 1Mb, that is enough, but we should really * consider fixing the Makefile to put a _raw_ kernel in there ! */ - vmlinux_memsize += 0x100000; + vmlinux_memsize += ONE_MB; printf("Allocating 0x%lx bytes for kernel ...\n\r", vmlinux_memsize); vmlinux.addr = try_claim(vmlinux_memsize); if (vmlinux.addr == 0) { -- cgit v0.10.2 From b28d2582ce8aafe531d909bb9c4dcf29189e786e Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Wed, 24 Aug 2005 11:56:56 -0500 Subject: [PATCH] ppc64: remove use of asm/segment.h Remove asm-ppc64/segment.h now that all users are gone. Signed-off-by: Kumar Gala Signed-off-by: Paul Mackerras diff --git a/include/asm-ppc64/segment.h b/include/asm-ppc64/segment.h deleted file mode 100644 index d80fb68..0000000 --- a/include/asm-ppc64/segment.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __PPC64_SEGMENT_H -#define __PPC64_SEGMENT_H - -/* Only here because we have some old header files that expect it.. */ - -#endif /* __PPC64_SEGMENT_H */ -- cgit v0.10.2 From 1635317facea3094ddf34082cd86797efb1d9f7e Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Tue, 6 Sep 2005 13:17:54 +1000 Subject: [PATCH] Separate pci bits out of struct device_node This patch pulls the PCI-related junk out of struct device_node and puts it in a separate structure, struct pci_dn. The device_node now just has a void * pointer in it, which points to a struct pci_dn for nodes that represent PCI devices. It could potentially be used in future for device-specific data for other sorts of devices, such as virtual I/O devices. Signed-off-by: Paul Mackerras diff --git a/arch/ppc64/kernel/eeh.c b/arch/ppc64/kernel/eeh.c index 4c857a6..ba93fd7 100644 --- a/arch/ppc64/kernel/eeh.c +++ b/arch/ppc64/kernel/eeh.c @@ -254,6 +254,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, static void __pci_addr_cache_insert_device(struct pci_dev *dev) { struct device_node *dn; + struct pci_dn *pdn; int i; int inserted = 0; @@ -265,8 +266,9 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev) } /* Skip any devices for which EEH is not enabled. */ - if (!(dn->eeh_mode & EEH_MODE_SUPPORTED) || - dn->eeh_mode & EEH_MODE_NOCHECK) { + pdn = dn->data; + if (!(pdn->eeh_mode & EEH_MODE_SUPPORTED) || + pdn->eeh_mode & EEH_MODE_NOCHECK) { #ifdef DEBUG printk(KERN_INFO "PCI: skip building address cache for=%s\n", pci_name(dev)); @@ -415,6 +417,7 @@ int eeh_unregister_notifier(struct notifier_block *nb) static int read_slot_reset_state(struct device_node *dn, int rets[]) { int token, outputs; + struct pci_dn *pdn = dn->data; if (ibm_read_slot_reset_state2 != RTAS_UNKNOWN_SERVICE) { token = ibm_read_slot_reset_state2; @@ -424,8 +427,8 @@ static int read_slot_reset_state(struct device_node *dn, int rets[]) outputs = 3; } - return rtas_call(token, 3, outputs, rets, dn->eeh_config_addr, - BUID_HI(dn->phb->buid), BUID_LO(dn->phb->buid)); + return rtas_call(token, 3, outputs, rets, pdn->eeh_config_addr, + BUID_HI(pdn->phb->buid), BUID_LO(pdn->phb->buid)); } /** @@ -534,6 +537,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) unsigned long flags; int rc, reset_state; struct eeh_event *event; + struct pci_dn *pdn; __get_cpu_var(total_mmio_ffs)++; @@ -542,14 +546,15 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) if (!dn) return 0; + pdn = dn->data; /* Access to IO BARs might get this far and still not want checking. */ - if (!(dn->eeh_mode & EEH_MODE_SUPPORTED) || - dn->eeh_mode & EEH_MODE_NOCHECK) { + if (!pdn->eeh_capable || !(pdn->eeh_mode & EEH_MODE_SUPPORTED) || + pdn->eeh_mode & EEH_MODE_NOCHECK) { return 0; } - if (!dn->eeh_config_addr) { + if (!pdn->eeh_config_addr) { return 0; } @@ -557,7 +562,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) * If we already have a pending isolation event for this * slot, we know it's bad already, we don't need to check... */ - if (dn->eeh_mode & EEH_MODE_ISOLATED) { + if (pdn->eeh_mode & EEH_MODE_ISOLATED) { atomic_inc(&eeh_fail_count); if (atomic_read(&eeh_fail_count) >= EEH_MAX_FAILS) { /* re-read the slot reset state */ @@ -582,7 +587,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) } /* prevent repeated reports of this failure */ - dn->eeh_mode |= EEH_MODE_ISOLATED; + pdn->eeh_mode |= EEH_MODE_ISOLATED; reset_state = rets[0]; @@ -590,9 +595,9 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) memset(slot_errbuf, 0, eeh_error_buf_size); rc = rtas_call(ibm_slot_error_detail, - 8, 1, NULL, dn->eeh_config_addr, - BUID_HI(dn->phb->buid), - BUID_LO(dn->phb->buid), NULL, 0, + 8, 1, NULL, pdn->eeh_config_addr, + BUID_HI(pdn->phb->buid), + BUID_LO(pdn->phb->buid), NULL, 0, virt_to_phys(slot_errbuf), eeh_error_buf_size, 1 /* Temporary Error */); @@ -679,8 +684,9 @@ static void *early_enable_eeh(struct device_node *dn, void *data) u32 *device_id = (u32 *)get_property(dn, "device-id", NULL); u32 *regs; int enable; + struct pci_dn *pdn = dn->data; - dn->eeh_mode = 0; + pdn->eeh_mode = 0; if (status && strcmp(status, "ok") != 0) return NULL; /* ignore devices with bad status */ @@ -691,7 +697,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data) /* There is nothing to check on PCI to ISA bridges */ if (dn->type && !strcmp(dn->type, "isa")) { - dn->eeh_mode |= EEH_MODE_NOCHECK; + pdn->eeh_mode |= EEH_MODE_NOCHECK; return NULL; } @@ -708,7 +714,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data) enable = 0; if (!enable) - dn->eeh_mode |= EEH_MODE_NOCHECK; + pdn->eeh_mode |= EEH_MODE_NOCHECK; /* Ok... see if this device supports EEH. Some do, some don't, * and the only way to find out is to check each and every one. */ @@ -721,8 +727,8 @@ static void *early_enable_eeh(struct device_node *dn, void *data) EEH_ENABLE); if (ret == 0) { eeh_subsystem_enabled = 1; - dn->eeh_mode |= EEH_MODE_SUPPORTED; - dn->eeh_config_addr = regs[0]; + pdn->eeh_mode |= EEH_MODE_SUPPORTED; + pdn->eeh_config_addr = regs[0]; #ifdef DEBUG printk(KERN_DEBUG "EEH: %s: eeh enabled\n", dn->full_name); #endif @@ -730,10 +736,11 @@ static void *early_enable_eeh(struct device_node *dn, void *data) /* This device doesn't support EEH, but it may have an * EEH parent, in which case we mark it as supported. */ - if (dn->parent && (dn->parent->eeh_mode & EEH_MODE_SUPPORTED)) { + if (dn->parent && dn->parent->data + && (PCI_DN(dn->parent)->eeh_mode & EEH_MODE_SUPPORTED)) { /* Parent supports EEH. */ - dn->eeh_mode |= EEH_MODE_SUPPORTED; - dn->eeh_config_addr = dn->parent->eeh_config_addr; + pdn->eeh_mode |= EEH_MODE_SUPPORTED; + pdn->eeh_config_addr = PCI_DN(dn->parent)->eeh_config_addr; return NULL; } } @@ -790,11 +797,13 @@ void __init eeh_init(void) for (phb = of_find_node_by_name(NULL, "pci"); phb; phb = of_find_node_by_name(phb, "pci")) { unsigned long buid; + struct pci_dn *pci; buid = get_phb_buid(phb); - if (buid == 0) + if (buid == 0 || phb->data == NULL) continue; + pci = phb->data; info.buid_lo = BUID_LO(buid); info.buid_hi = BUID_HI(buid); traverse_pci_devices(phb, early_enable_eeh, &info); @@ -823,9 +832,9 @@ void eeh_add_device_early(struct device_node *dn) struct pci_controller *phb; struct eeh_early_enable_info info; - if (!dn) + if (!dn || !dn->data) return; - phb = dn->phb; + phb = PCI_DN(dn)->phb; if (NULL == phb || 0 == phb->buid) { printk(KERN_WARNING "EEH: Expected buid but found none\n"); return; diff --git a/arch/ppc64/kernel/iommu.c b/arch/ppc64/kernel/iommu.c index 845eebd..9032b6b 100644 --- a/arch/ppc64/kernel/iommu.c +++ b/arch/ppc64/kernel/iommu.c @@ -438,7 +438,8 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl) void iommu_free_table(struct device_node *dn) { - struct iommu_table *tbl = dn->iommu_table; + struct pci_dn *pdn = dn->data; + struct iommu_table *tbl = pdn->iommu_table; unsigned long bitmap_sz, i; unsigned int order; diff --git a/arch/ppc64/kernel/maple_pci.c b/arch/ppc64/kernel/maple_pci.c index 5399399..5a8b4d8 100644 --- a/arch/ppc64/kernel/maple_pci.c +++ b/arch/ppc64/kernel/maple_pci.c @@ -447,9 +447,9 @@ void __init maple_pci_init(void) */ if (u3_agp) { struct device_node *np = u3_agp->arch_data; - np->busno = 0xf0; + PCI_DN(np)->busno = 0xf0; for (np = np->child; np; np = np->sibling) - np->busno = 0xf0; + PCI_DN(np)->busno = 0xf0; } /* Tell pci.c to use the common resource allocation mecanism */ diff --git a/arch/ppc64/kernel/pSeries_iommu.c b/arch/ppc64/kernel/pSeries_iommu.c index 9d5e1e7..f0fd7fb 100644 --- a/arch/ppc64/kernel/pSeries_iommu.c +++ b/arch/ppc64/kernel/pSeries_iommu.c @@ -295,7 +295,7 @@ static void iommu_table_setparms_lpar(struct pci_controller *phb, struct iommu_table *tbl, unsigned int *dma_window) { - tbl->it_busno = dn->bussubno; + tbl->it_busno = PCI_DN(dn)->bussubno; /* TODO: Parse field size properties properly. */ tbl->it_size = (((unsigned long)dma_window[4] << 32) | @@ -311,6 +311,7 @@ static void iommu_table_setparms_lpar(struct pci_controller *phb, static void iommu_bus_setup_pSeries(struct pci_bus *bus) { struct device_node *dn, *pdn; + struct pci_dn *pci; struct iommu_table *tbl; DBG("iommu_bus_setup_pSeries, bus %p, bus->self %p\n", bus, bus->self); @@ -325,6 +326,7 @@ static void iommu_bus_setup_pSeries(struct pci_bus *bus) */ dn = pci_bus_to_OF_node(bus); + pci = dn->data; if (!bus->self) { /* Root bus */ @@ -341,18 +343,18 @@ static void iommu_bus_setup_pSeries(struct pci_bus *bus) * alltogether. This leaves 768MB for the window. */ DBG("PHB has io-hole, reserving 256MB\n"); - dn->phb->dma_window_size = 3 << 28; - dn->phb->dma_window_base_cur = 1 << 28; + pci->phb->dma_window_size = 3 << 28; + pci->phb->dma_window_base_cur = 1 << 28; } else { /* 1GB window by default */ - dn->phb->dma_window_size = 1 << 30; - dn->phb->dma_window_base_cur = 0; + pci->phb->dma_window_size = 1 << 30; + pci->phb->dma_window_base_cur = 0; } tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL); - iommu_table_setparms(dn->phb, dn, tbl); - dn->iommu_table = iommu_init_table(tbl); + iommu_table_setparms(pci->phb, dn, tbl); + pci->iommu_table = iommu_init_table(tbl); } else { /* Do a 128MB table at root. This is used for the IDE * controller on some SMP-mode POWER4 machines. It @@ -363,16 +365,16 @@ static void iommu_bus_setup_pSeries(struct pci_bus *bus) * Allocate at offset 128MB to avoid having to deal * with ISA holes; 128MB table for IDE is plenty. */ - dn->phb->dma_window_size = 1 << 27; - dn->phb->dma_window_base_cur = 1 << 27; + pci->phb->dma_window_size = 1 << 27; + pci->phb->dma_window_base_cur = 1 << 27; tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL); - iommu_table_setparms(dn->phb, dn, tbl); - dn->iommu_table = iommu_init_table(tbl); + iommu_table_setparms(pci->phb, dn, tbl); + pci->iommu_table = iommu_init_table(tbl); /* All child buses have 256MB tables */ - dn->phb->dma_window_size = 1 << 28; + pci->phb->dma_window_size = 1 << 28; } } else { pdn = pci_bus_to_OF_node(bus->parent); @@ -386,12 +388,12 @@ static void iommu_bus_setup_pSeries(struct pci_bus *bus) tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL); - iommu_table_setparms(dn->phb, dn, tbl); + iommu_table_setparms(pci->phb, dn, tbl); - dn->iommu_table = iommu_init_table(tbl); + pci->iommu_table = iommu_init_table(tbl); } else { /* Lower than first child or under python, use parent table */ - dn->iommu_table = pdn->iommu_table; + pci->iommu_table = PCI_DN(pdn)->iommu_table; } } } @@ -401,6 +403,7 @@ static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus) { struct iommu_table *tbl; struct device_node *dn, *pdn; + struct pci_dn *ppci; unsigned int *dma_window = NULL; DBG("iommu_bus_setup_pSeriesLP, bus %p, bus->self %p\n", bus, bus->self); @@ -419,22 +422,24 @@ static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus) return; } - if (!pdn->iommu_table) { + ppci = pdn->data; + if (!ppci->iommu_table) { /* Bussubno hasn't been copied yet. * Do it now because iommu_table_setparms_lpar needs it. */ - pdn->bussubno = bus->number; + + ppci->bussubno = bus->number; tbl = (struct iommu_table *)kmalloc(sizeof(struct iommu_table), GFP_KERNEL); - iommu_table_setparms_lpar(pdn->phb, pdn, tbl, dma_window); + iommu_table_setparms_lpar(ppci->phb, pdn, tbl, dma_window); - pdn->iommu_table = iommu_init_table(tbl); + ppci->iommu_table = iommu_init_table(tbl); } if (pdn != dn) - dn->iommu_table = pdn->iommu_table; + PCI_DN(dn)->iommu_table = ppci->iommu_table; } @@ -449,11 +454,11 @@ static void iommu_dev_setup_pSeries(struct pci_dev *dev) */ mydn = dn = pci_device_to_OF_node(dev); - while (dn && dn->iommu_table == NULL) + while (dn && dn->data && PCI_DN(dn)->iommu_table == NULL) dn = dn->parent; - if (dn) { - mydn->iommu_table = dn->iommu_table; + if (dn && dn->data) { + PCI_DN(mydn)->iommu_table = PCI_DN(dn)->iommu_table; } else { DBG("iommu_dev_setup_pSeries, dev %p (%s) has no iommu table\n", dev, dev->pretty_name); } @@ -463,10 +468,11 @@ static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long acti { int err = NOTIFY_OK; struct device_node *np = node; + struct pci_dn *pci = np->data; switch (action) { case PSERIES_RECONFIG_REMOVE: - if (np->iommu_table && + if (pci->iommu_table && get_property(np, "ibm,dma-window", NULL)) iommu_free_table(np); break; @@ -486,6 +492,7 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev) struct device_node *pdn, *dn; struct iommu_table *tbl; int *dma_window = NULL; + struct pci_dn *pci; DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, dev->pretty_name); @@ -497,8 +504,10 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev) */ dn = pci_device_to_OF_node(dev); - for (pdn = dn; pdn && !pdn->iommu_table; pdn = pdn->parent) { - dma_window = (unsigned int *)get_property(pdn, "ibm,dma-window", NULL); + for (pdn = dn; pdn && pdn->data && !PCI_DN(pdn)->iommu_table; + pdn = pdn->parent) { + dma_window = (unsigned int *) + get_property(pdn, "ibm,dma-window", NULL); if (dma_window) break; } @@ -515,20 +524,21 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev) DBG("Found DMA window, allocating table\n"); } - if (!pdn->iommu_table) { + pci = pdn->data; + if (!pci->iommu_table) { /* iommu_table_setparms_lpar needs bussubno. */ - pdn->bussubno = pdn->phb->bus->number; + pci->bussubno = pci->phb->bus->number; tbl = (struct iommu_table *)kmalloc(sizeof(struct iommu_table), GFP_KERNEL); - iommu_table_setparms_lpar(pdn->phb, pdn, tbl, dma_window); + iommu_table_setparms_lpar(pci->phb, pdn, tbl, dma_window); - pdn->iommu_table = iommu_init_table(tbl); + pci->iommu_table = iommu_init_table(tbl); } if (pdn != dn) - dn->iommu_table = pdn->iommu_table; + PCI_DN(dn)->iommu_table = pci->iommu_table; } static void iommu_bus_setup_null(struct pci_bus *b) { } diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c index b5ca7d8..446b465 100644 --- a/arch/ppc64/kernel/pci.c +++ b/arch/ppc64/kernel/pci.c @@ -837,9 +837,11 @@ int pcibios_scan_all_fns(struct pci_bus *bus, int devfn) * device tree. If they are then we need to scan all the * functions of this slot. */ - for (dn = busdn->child; dn; dn = dn->sibling) - if ((dn->devfn >> 3) == (devfn >> 3)) + for (dn = busdn->child; dn; dn = dn->sibling) { + struct pci_dn *pdn = dn->data; + if (pdn && (pdn->devfn >> 3) == (devfn >> 3)) return 1; + } return 0; } diff --git a/arch/ppc64/kernel/pci.h b/arch/ppc64/kernel/pci.h index 26be78b..5eb2cc3 100644 --- a/arch/ppc64/kernel/pci.h +++ b/arch/ppc64/kernel/pci.h @@ -34,7 +34,6 @@ void *traverse_pci_devices(struct device_node *start, traverse_func pre, void pci_devs_phb_init(void); void pci_devs_phb_init_dynamic(struct pci_controller *phb); -struct device_node *fetch_dev_dn(struct pci_dev *dev); /* PCI address cache management routines */ void pci_addr_cache_insert_device(struct pci_dev *dev); diff --git a/arch/ppc64/kernel/pci_dn.c b/arch/ppc64/kernel/pci_dn.c index ec34546..a86389d 100644 --- a/arch/ppc64/kernel/pci_dn.c +++ b/arch/ppc64/kernel/pci_dn.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include @@ -40,16 +42,26 @@ static void * __devinit update_dn_pci_info(struct device_node *dn, void *data) struct pci_controller *phb = data; int *type = (int *)get_property(dn, "ibm,pci-config-space-type", NULL); u32 *regs; - - dn->phb = phb; + struct pci_dn *pdn; + + if (phb->is_dynamic) + pdn = kmalloc(sizeof(*pdn), GFP_KERNEL); + else + pdn = alloc_bootmem(sizeof(*pdn)); + if (pdn == NULL) + return NULL; + memset(pdn, 0, sizeof(*pdn)); + dn->data = pdn; + pdn->node = dn; + pdn->phb = phb; regs = (u32 *)get_property(dn, "reg", NULL); if (regs) { /* First register entry is addr (00BBSS00) */ - dn->busno = (regs[0] >> 16) & 0xff; - dn->devfn = (regs[0] >> 8) & 0xff; + pdn->busno = (regs[0] >> 16) & 0xff; + pdn->devfn = (regs[0] >> 8) & 0xff; } - dn->pci_ext_config_space = (type && *type == 1); + pdn->pci_ext_config_space = (type && *type == 1); return NULL; } @@ -112,10 +124,15 @@ void *traverse_pci_devices(struct device_node *start, traverse_func pre, void __devinit pci_devs_phb_init_dynamic(struct pci_controller *phb) { struct device_node * dn = (struct device_node *) phb->arch_data; + struct pci_dn *pdn; /* PHB nodes themselves must not match */ - dn->devfn = dn->busno = -1; - dn->phb = phb; + update_dn_pci_info(dn, phb); + pdn = dn->data; + if (pdn) { + pdn->devfn = pdn->busno = -1; + pdn->phb = phb; + } /* Update dn->phb ptrs for new phb and children devices */ traverse_pci_devices(dn, update_dn_pci_info, phb); @@ -123,14 +140,17 @@ void __devinit pci_devs_phb_init_dynamic(struct pci_controller *phb) /* * Traversal func that looks for a value. - * If found, the device_node is returned (thus terminating the traversal). + * If found, the pci_dn is returned (thus terminating the traversal). */ static void *is_devfn_node(struct device_node *dn, void *data) { int busno = ((unsigned long)data >> 8) & 0xff; int devfn = ((unsigned long)data) & 0xff; + struct pci_dn *pci = dn->data; - return ((devfn == dn->devfn) && (busno == dn->busno)) ? dn : NULL; + if (pci && (devfn == pci->devfn) && (busno == pci->busno)) + return dn; + return NULL; } /* @@ -149,13 +169,10 @@ static void *is_devfn_node(struct device_node *dn, void *data) struct device_node *fetch_dev_dn(struct pci_dev *dev) { struct device_node *orig_dn = dev->sysdata; - struct pci_controller *phb = orig_dn->phb; /* assume same phb as orig_dn */ - struct device_node *phb_dn; struct device_node *dn; unsigned long searchval = (dev->bus->number << 8) | dev->devfn; - phb_dn = phb->arch_data; - dn = traverse_pci_devices(phb_dn, is_devfn_node, (void *)searchval); + dn = traverse_pci_devices(orig_dn, is_devfn_node, (void *)searchval); if (dn) dev->sysdata = dn; return dn; @@ -165,11 +182,13 @@ EXPORT_SYMBOL(fetch_dev_dn); static int pci_dn_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *node) { struct device_node *np = node; + struct pci_dn *pci; int err = NOTIFY_OK; switch (action) { case PSERIES_RECONFIG_ADD: - update_dn_pci_info(np, np->parent->phb); + pci = np->parent->data; + update_dn_pci_info(np, pci->phb); break; default: err = NOTIFY_DONE; diff --git a/arch/ppc64/kernel/pci_iommu.c b/arch/ppc64/kernel/pci_iommu.c index ef0a62b..14647e0 100644 --- a/arch/ppc64/kernel/pci_iommu.c +++ b/arch/ppc64/kernel/pci_iommu.c @@ -66,7 +66,7 @@ static inline struct iommu_table *devnode_table(struct device *dev) #endif /* CONFIG_PPC_ISERIES */ #ifdef CONFIG_PPC_MULTIPLATFORM - return PCI_GET_DN(pdev)->iommu_table; + return PCI_DN(PCI_GET_DN(pdev))->iommu_table; #endif /* CONFIG_PPC_MULTIPLATFORM */ } diff --git a/arch/ppc64/kernel/pmac_feature.c b/arch/ppc64/kernel/pmac_feature.c index 98ed2bc..eb4e6c3 100644 --- a/arch/ppc64/kernel/pmac_feature.c +++ b/arch/ppc64/kernel/pmac_feature.c @@ -674,6 +674,7 @@ void __init pmac_check_ht_link(void) #if 0 /* Disabled for now */ u32 ufreq, freq, ucfg, cfg; struct device_node *pcix_node; + struct pci_dn *pdn; u8 px_bus, px_devfn; struct pci_controller *px_hose; @@ -687,9 +688,10 @@ void __init pmac_check_ht_link(void) printk("No PCI-X bridge found\n"); return; } - px_hose = pcix_node->phb; - px_bus = pcix_node->busno; - px_devfn = pcix_node->devfn; + pdn = pcix_node->data; + px_hose = pdn->phb; + px_bus = pdn->busno; + px_devfn = pdn->devfn; early_read_config_dword(px_hose, px_bus, px_devfn, 0xc4, &cfg); early_read_config_dword(px_hose, px_bus, px_devfn, 0xcc, &freq); diff --git a/arch/ppc64/kernel/pmac_pci.c b/arch/ppc64/kernel/pmac_pci.c index 71fe911..d37bff2 100644 --- a/arch/ppc64/kernel/pmac_pci.c +++ b/arch/ppc64/kernel/pmac_pci.c @@ -242,7 +242,7 @@ static int u3_ht_skip_device(struct pci_controller *hose, else busdn = hose->arch_data; for (dn = busdn->child; dn; dn = dn->sibling) - if (dn->devfn == devfn) + if (dn->data && PCI_DN(dn)->devfn == devfn) break; if (dn == NULL) return -1; @@ -746,9 +746,9 @@ void __init pmac_pci_init(void) */ if (u3_agp) { struct device_node *np = u3_agp->arch_data; - np->busno = 0xf0; + PCI_DN(np)->busno = 0xf0; for (np = np->child; np; np = np->sibling) - np->busno = 0xf0; + PCI_DN(np)->busno = 0xf0; } pmac_check_ht_link(); diff --git a/arch/ppc64/kernel/prom.c b/arch/ppc64/kernel/prom.c index 6ad5a84..7035deb 100644 --- a/arch/ppc64/kernel/prom.c +++ b/arch/ppc64/kernel/prom.c @@ -1733,6 +1733,7 @@ static void of_node_release(struct kref *kref) kfree(node->intrs); kfree(node->addrs); kfree(node->full_name); + kfree(node->data); kfree(node); } diff --git a/arch/ppc64/kernel/rtas_pci.c b/arch/ppc64/kernel/rtas_pci.c index 1dccada..4a9719b 100644 --- a/arch/ppc64/kernel/rtas_pci.c +++ b/arch/ppc64/kernel/rtas_pci.c @@ -48,7 +48,7 @@ static int write_pci_config; static int ibm_read_pci_config; static int ibm_write_pci_config; -static int config_access_valid(struct device_node *dn, int where) +static int config_access_valid(struct pci_dn *dn, int where) { if (where < 256) return 1; @@ -78,15 +78,17 @@ static int rtas_read_config(struct device_node *dn, int where, int size, u32 *va int returnval = -1; unsigned long buid, addr; int ret; + struct pci_dn *pdn; - if (!dn) + if (!dn || !dn->data) return PCIBIOS_DEVICE_NOT_FOUND; - if (!config_access_valid(dn, where)) + pdn = dn->data; + if (!config_access_valid(pdn, where)) return PCIBIOS_BAD_REGISTER_NUMBER; - addr = ((where & 0xf00) << 20) | (dn->busno << 16) | - (dn->devfn << 8) | (where & 0xff); - buid = dn->phb->buid; + addr = ((where & 0xf00) << 20) | (pdn->busno << 16) | + (pdn->devfn << 8) | (where & 0xff); + buid = pdn->phb->buid; if (buid) { ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval, addr, buid >> 32, buid & 0xffffffff, size); @@ -98,8 +100,8 @@ static int rtas_read_config(struct device_node *dn, int where, int size, u32 *va if (ret) return PCIBIOS_DEVICE_NOT_FOUND; - if (returnval == EEH_IO_ERROR_VALUE(size) - && eeh_dn_check_failure (dn, NULL)) + if (returnval == EEH_IO_ERROR_VALUE(size) && + eeh_dn_check_failure (dn, NULL)) return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_SUCCESSFUL; @@ -118,24 +120,28 @@ static int rtas_pci_read_config(struct pci_bus *bus, /* Search only direct children of the bus */ for (dn = busdn->child; dn; dn = dn->sibling) - if (dn->devfn == devfn && of_device_available(dn)) + if (dn->data && PCI_DN(dn)->devfn == devfn + && of_device_available(dn)) return rtas_read_config(dn, where, size, val); + return PCIBIOS_DEVICE_NOT_FOUND; } -static int rtas_write_config(struct device_node *dn, int where, int size, u32 val) +int rtas_write_config(struct device_node *dn, int where, int size, u32 val) { unsigned long buid, addr; int ret; + struct pci_dn *pdn; - if (!dn) + if (!dn || !dn->data) return PCIBIOS_DEVICE_NOT_FOUND; - if (!config_access_valid(dn, where)) + pdn = dn->data; + if (!config_access_valid(pdn, where)) return PCIBIOS_BAD_REGISTER_NUMBER; - addr = ((where & 0xf00) << 20) | (dn->busno << 16) | - (dn->devfn << 8) | (where & 0xff); - buid = dn->phb->buid; + addr = ((where & 0xf00) << 20) | (pdn->busno << 16) | + (pdn->devfn << 8) | (where & 0xff); + buid = pdn->phb->buid; if (buid) { ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr, buid >> 32, buid & 0xffffffff, size, (ulong) val); } else { @@ -161,7 +167,8 @@ static int rtas_pci_write_config(struct pci_bus *bus, /* Search only direct children of the bus */ for (dn = busdn->child; dn; dn = dn->sibling) - if (dn->devfn == devfn && of_device_available(dn)) + if (dn->data && PCI_DN(dn)->devfn == devfn + && of_device_available(dn)) return rtas_write_config(dn, where, size, val); return PCIBIOS_DEVICE_NOT_FOUND; } diff --git a/arch/ppc64/kernel/sys_ppc32.c b/arch/ppc64/kernel/sys_ppc32.c index 214914a..57a6db7 100644 --- a/arch/ppc64/kernel/sys_ppc32.c +++ b/arch/ppc64/kernel/sys_ppc32.c @@ -747,8 +747,8 @@ asmlinkage int sys32_pciconfig_iobase(u32 which, u32 in_bus, u32 in_devfn) if (bus == NULL || bus->sysdata == NULL) return -ENODEV; - hose_node = (struct device_node *)bus->sysdata; - hose = hose_node->phb; + hose_node = bus->sysdata; + hose = PCI_DN(hose_node)->phb; switch (which) { case IOBASE_BRIDGE_NUMBER: diff --git a/arch/ppc64/kernel/u3_iommu.c b/arch/ppc64/kernel/u3_iommu.c index b6e3bca..41ea09c 100644 --- a/arch/ppc64/kernel/u3_iommu.c +++ b/arch/ppc64/kernel/u3_iommu.c @@ -276,7 +276,7 @@ static void iommu_dev_setup_u3(struct pci_dev *dev) dn = pci_device_to_OF_node(dev); if (dn) - dn->iommu_table = &iommu_table_u3; + PCI_DN(dn)->iommu_table = &iommu_table_u3; } static void iommu_bus_setup_u3(struct pci_bus *bus) @@ -291,7 +291,7 @@ static void iommu_bus_setup_u3(struct pci_bus *bus) dn = pci_bus_to_OF_node(bus); if (dn) - dn->iommu_table = &iommu_table_u3; + PCI_DN(dn)->iommu_table = &iommu_table_u3; } static void iommu_dev_setup_null(struct pci_dev *dev) { } diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index 4ada151..ad1017d 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -134,7 +134,8 @@ static void rpadlpar_claim_one_bus(struct pci_bus *b) static int pci_add_secondary_bus(struct device_node *dn, struct pci_dev *bridge_dev) { - struct pci_controller *hose = dn->phb; + struct pci_dn *pdn = dn->data; + struct pci_controller *hose = pdn->phb; struct pci_bus *child; u8 sec_busno; @@ -159,7 +160,7 @@ static int pci_add_secondary_bus(struct device_node *dn, if (hose->last_busno < child->number) hose->last_busno = child->number; - dn->bussubno = child->number; + pdn->bussubno = child->number; /* ioremap() for child bus, which may or may not succeed */ remap_bus_range(child); @@ -183,11 +184,12 @@ static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) { - struct pci_controller *hose = dn->phb; + struct pci_dn *pdn = dn->data; + struct pci_controller *hose = pdn->phb; struct pci_dev *dev = NULL; /* Scan phb bus for EADS device, adding new one to bus->devices */ - if (!pci_scan_single_device(hose->bus, dn->devfn)) { + if (!pci_scan_single_device(hose->bus, pdn->devfn)) { printk(KERN_ERR "%s: found no device on bus\n", __FUNCTION__); return NULL; } @@ -269,6 +271,7 @@ static int dlpar_remove_root_bus(struct pci_controller *phb) static int dlpar_remove_phb(char *drc_name, struct device_node *dn) { struct slot *slot; + struct pci_dn *pdn; int rc = 0; if (!rpaphp_find_pci_bus(dn)) @@ -285,12 +288,13 @@ static int dlpar_remove_phb(char *drc_name, struct device_node *dn) } } - BUG_ON(!dn->phb); - rc = dlpar_remove_root_bus(dn->phb); + pdn = dn->data; + BUG_ON(!pdn || !pdn->phb); + rc = dlpar_remove_root_bus(pdn->phb); if (rc < 0) return rc; - dn->phb = NULL; + pdn->phb = NULL; return 0; } @@ -299,7 +303,7 @@ static int dlpar_add_phb(char *drc_name, struct device_node *dn) { struct pci_controller *phb; - if (dn->phb) { + if (PCI_DN(dn)->phb) { /* PHB already exists */ return -EINVAL; } diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index 17a0279..49e4d10 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c @@ -51,10 +51,12 @@ static struct pci_bus *find_bus_among_children(struct pci_bus *bus, struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn) { - if (!dn->phb || !dn->phb->bus) + struct pci_dn *pdn = dn->data; + + if (!pdn || !pdn->phb || !pdn->phb->bus) return NULL; - return find_bus_among_children(dn->phb->bus, dn); + return find_bus_among_children(pdn->phb->bus, dn); } EXPORT_SYMBOL_GPL(rpaphp_find_pci_bus); @@ -229,7 +231,7 @@ rpaphp_pci_config_slot(struct pci_bus *bus) if (!dn || !dn->child) return NULL; - slotno = PCI_SLOT(dn->child->devfn); + slotno = PCI_SLOT(PCI_DN(dn->child)->devfn); /* pci_scan_slot should find all children */ num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0)); diff --git a/drivers/video/offb.c b/drivers/video/offb.c index 42a6591..611922c 100644 --- a/drivers/video/offb.c +++ b/drivers/video/offb.c @@ -363,7 +363,7 @@ static void __init offb_init_nodriver(struct device_node *dp) address = (u_long) dp->addrs[i].address; #ifdef CONFIG_PPC64 - address += dp->phb->pci_mem_offset; + address += ((struct pci_dn *)dp->data)->phb->pci_mem_offset; #endif /* kludge for valkyrie */ diff --git a/include/asm-ppc64/pci-bridge.h b/include/asm-ppc64/pci-bridge.h index c4f9023..6b4a5b1 100644 --- a/include/asm-ppc64/pci-bridge.h +++ b/include/asm-ppc64/pci-bridge.h @@ -48,19 +48,52 @@ struct pci_controller { unsigned long dma_window_size; }; +/* + * PCI stuff, for nodes representing PCI devices, pointed to + * by device_node->data. + */ +struct pci_controller; +struct iommu_table; + +struct pci_dn { + int busno; /* for pci devices */ + int bussubno; /* for pci devices */ + int devfn; /* for pci devices */ + int eeh_mode; /* See eeh.h for possible EEH_MODEs */ + int eeh_config_addr; + int eeh_capable; /* from firmware */ + int eeh_check_count; /* # times driver ignored error */ + int eeh_freeze_count; /* # times this device froze up. */ + int eeh_is_bridge; /* device is pci-to-pci bridge */ + + int pci_ext_config_space; /* for pci devices */ + struct pci_controller *phb; /* for pci devices */ + struct iommu_table *iommu_table; /* for phb's or bridges */ + struct pci_dev *pcidev; /* back-pointer to the pci device */ + struct device_node *node; /* back-pointer to the device_node */ + u32 config_space[16]; /* saved PCI config space */ +}; + +/* Get the pointer to a device_node's pci_dn */ +#define PCI_DN(dn) ((struct pci_dn *) (dn)->data) + struct device_node *fetch_dev_dn(struct pci_dev *dev); -/* Get a device_node from a pci_dev. This code must be fast except in the case - * where the sysdata is incorrect and needs to be fixed up (hopefully just once) +/* Get a device_node from a pci_dev. This code must be fast except + * in the case where the sysdata is incorrect and needs to be fixed + * up (this will only happen once). + * In this case the sysdata will have been inherited from a PCI host + * bridge or a PCI-PCI bridge further up the tree, so it will point + * to a valid struct pci_dn, just not the one we want. */ static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev) { struct device_node *dn = dev->sysdata; + struct pci_dn *pdn = dn->data; - if (dn->devfn == dev->devfn && dn->busno == dev->bus->number) + if (pdn && pdn->devfn == dev->devfn && pdn->busno == dev->bus->number) return dn; /* fast path. sysdata is good */ - else - return fetch_dev_dn(dev); + return fetch_dev_dn(dev); } static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus) @@ -83,7 +116,7 @@ static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus) struct device_node *busdn = bus->sysdata; BUG_ON(busdn == NULL); - return busdn->phb; + return PCI_DN(busdn)->phb; } #endif diff --git a/include/asm-ppc64/prom.h b/include/asm-ppc64/prom.h index dc5330b..c02ec1d 100644 --- a/include/asm-ppc64/prom.h +++ b/include/asm-ppc64/prom.h @@ -116,14 +116,6 @@ struct property { struct property *next; }; -/* NOTE: the device_node contains PCI specific info for pci devices. - * This perhaps could be hung off the device_node with another struct, - * but for now it is directly in the node. The phb ptr is a good - * indication of a real PCI node. Other nodes leave these fields zeroed. - */ -struct pci_controller; -struct iommu_table; - struct device_node { char *name; char *type; @@ -135,16 +127,6 @@ struct device_node { struct interrupt_info *intrs; char *full_name; - /* PCI stuff probably doesn't belong here */ - int busno; /* for pci devices */ - int bussubno; /* for pci devices */ - int devfn; /* for pci devices */ - int eeh_mode; /* See eeh.h for possible EEH_MODEs */ - int eeh_config_addr; - int pci_ext_config_space; /* for pci devices */ - struct pci_controller *phb; /* for pci devices */ - struct iommu_table *iommu_table; /* for phb's or bridges */ - struct property *properties; struct device_node *parent; struct device_node *child; @@ -154,6 +136,7 @@ struct device_node { struct proc_dir_entry *pde; /* this node's proc directory */ struct kref kref; unsigned long _flags; + void *data; }; extern struct device_node *of_chosen; -- cgit v0.10.2 From 766375362a1dcac63dc0c0fb61ce4143c8de63d9 Mon Sep 17 00:00:00 2001 From: Arthur Othieno Date: Sat, 20 Aug 2005 21:48:47 -0400 Subject: [PATCH] ppc64: Big-endian I/O memory accessors. I/O memory accessors. Big-endian version. For those busses/devices that do export big-endian I/O memory. Of notable relevance/reference: http://lwn.net/Articles/132804/ http://ozlabs.org/pipermail/linuxppc-embedded/2005-August/019798.html http://ozlabs.org/pipermail/linuxppc-embedded/2005-August/019752.html Signed-Off-By: Arthur Othieno Signed-off-by: Paul Mackerras diff --git a/arch/ppc64/kernel/iomap.c b/arch/ppc64/kernel/iomap.c index 153cc8b..95b0baf 100644 --- a/arch/ppc64/kernel/iomap.c +++ b/arch/ppc64/kernel/iomap.c @@ -22,13 +22,23 @@ unsigned int fastcall ioread16(void __iomem *addr) { return readw(addr); } +unsigned int fastcall ioread16be(void __iomem *addr) +{ + return in_be16(addr); +} unsigned int fastcall ioread32(void __iomem *addr) { return readl(addr); } +unsigned int fastcall ioread32be(void __iomem *addr) +{ + return in_be32(addr); +} EXPORT_SYMBOL(ioread8); EXPORT_SYMBOL(ioread16); +EXPORT_SYMBOL(ioread16be); EXPORT_SYMBOL(ioread32); +EXPORT_SYMBOL(ioread32be); void fastcall iowrite8(u8 val, void __iomem *addr) { @@ -38,13 +48,23 @@ void fastcall iowrite16(u16 val, void __iomem *addr) { writew(val, addr); } +void fastcall iowrite16be(u16 val, void __iomem *addr) +{ + out_be16(addr, val); +} void fastcall iowrite32(u32 val, void __iomem *addr) { writel(val, addr); } +void fastcall iowrite32be(u32 val, void __iomem *addr) +{ + out_be32(addr, val); +} EXPORT_SYMBOL(iowrite8); EXPORT_SYMBOL(iowrite16); +EXPORT_SYMBOL(iowrite16be); EXPORT_SYMBOL(iowrite32); +EXPORT_SYMBOL(iowrite32be); /* * These are the "repeat read/write" functions. Note the -- cgit v0.10.2 From b2ad7b5e8115582cdf5bbda065aa516c24d62c21 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Fri, 9 Sep 2005 23:02:36 +1000 Subject: Allow PCI config space syscalls to be used by 64-bit processes. The pciconfig_iobase, pciconfig_read and pciconfig_write system calls were only implemented for 32-bit processes; for 64-bit processes they returned an ENOSYS error. This allows them to be used by 64-bit processes as well. The X server uses pciconfig_iobase at least, and this change is necessary to allow a 64-bit X server to work on my G5. Signed-off-by: Paul Mackerras diff --git a/arch/ppc64/kernel/misc.S b/arch/ppc64/kernel/misc.S index 6d860c1..c047663 100644 --- a/arch/ppc64/kernel/misc.S +++ b/arch/ppc64/kernel/misc.S @@ -1431,9 +1431,9 @@ _GLOBAL(sys_call_table) .llong .sys_ni_syscall /* 195 - 32bit only stat64 */ .llong .sys_ni_syscall /* 32bit only lstat64 */ .llong .sys_ni_syscall /* 32bit only fstat64 */ - .llong .sys_ni_syscall /* 32bit only pciconfig_read */ - .llong .sys_ni_syscall /* 32bit only pciconfig_write */ - .llong .sys_ni_syscall /* 32bit only pciconfig_iobase */ + .llong .sys_pciconfig_read + .llong .sys_pciconfig_write + .llong .sys_pciconfig_iobase /* 200 - pciconfig_iobase */ .llong .sys_ni_syscall /* reserved for MacOnLinux */ .llong .sys_getdents64 .llong .sys_pivot_root diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c index 446b465..8447dcc 100644 --- a/arch/ppc64/kernel/pci.c +++ b/arch/ppc64/kernel/pci.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -984,3 +985,62 @@ void pci_resource_to_user(const struct pci_dev *dev, int bar, } #endif /* CONFIG_PPC_MULTIPLATFORM */ + + +#define IOBASE_BRIDGE_NUMBER 0 +#define IOBASE_MEMORY 1 +#define IOBASE_IO 2 +#define IOBASE_ISA_IO 3 +#define IOBASE_ISA_MEM 4 + +long sys_pciconfig_iobase(long which, unsigned long in_bus, + unsigned long in_devfn) +{ + struct pci_controller* hose; + struct list_head *ln; + struct pci_bus *bus = NULL; + struct device_node *hose_node; + + /* Argh ! Please forgive me for that hack, but that's the + * simplest way to get existing XFree to not lockup on some + * G5 machines... So when something asks for bus 0 io base + * (bus 0 is HT root), we return the AGP one instead. + */ +#ifdef CONFIG_PPC_PMAC + if (systemcfg->platform == PLATFORM_POWERMAC && + machine_is_compatible("MacRISC4")) + if (in_bus == 0) + in_bus = 0xf0; +#endif /* CONFIG_PPC_PMAC */ + + /* That syscall isn't quite compatible with PCI domains, but it's + * used on pre-domains setup. We return the first match + */ + + for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) { + bus = pci_bus_b(ln); + if (in_bus >= bus->number && in_bus < (bus->number + bus->subordinate)) + break; + bus = NULL; + } + if (bus == NULL || bus->sysdata == NULL) + return -ENODEV; + + hose_node = (struct device_node *)bus->sysdata; + hose = PCI_DN(hose_node)->phb; + + switch (which) { + case IOBASE_BRIDGE_NUMBER: + return (long)hose->first_busno; + case IOBASE_MEMORY: + return (long)hose->pci_mem_offset; + case IOBASE_IO: + return (long)hose->io_base_phys; + case IOBASE_ISA_IO: + return (long)isa_io_base; + case IOBASE_ISA_MEM: + return -EINVAL; + } + + return -EOPNOTSUPP; +} diff --git a/arch/ppc64/kernel/sys_ppc32.c b/arch/ppc64/kernel/sys_ppc32.c index 57a6db7..e93c134 100644 --- a/arch/ppc64/kernel/sys_ppc32.c +++ b/arch/ppc64/kernel/sys_ppc32.c @@ -708,62 +708,9 @@ asmlinkage int sys32_pciconfig_write(u32 bus, u32 dfn, u32 off, u32 len, u32 ubu compat_ptr(ubuf)); } -#define IOBASE_BRIDGE_NUMBER 0 -#define IOBASE_MEMORY 1 -#define IOBASE_IO 2 -#define IOBASE_ISA_IO 3 -#define IOBASE_ISA_MEM 4 - asmlinkage int sys32_pciconfig_iobase(u32 which, u32 in_bus, u32 in_devfn) { -#ifdef CONFIG_PCI - struct pci_controller* hose; - struct list_head *ln; - struct pci_bus *bus = NULL; - struct device_node *hose_node; - - /* Argh ! Please forgive me for that hack, but that's the - * simplest way to get existing XFree to not lockup on some - * G5 machines... So when something asks for bus 0 io base - * (bus 0 is HT root), we return the AGP one instead. - */ -#ifdef CONFIG_PPC_PMAC - if (systemcfg->platform == PLATFORM_POWERMAC && - machine_is_compatible("MacRISC4")) - if (in_bus == 0) - in_bus = 0xf0; -#endif /* CONFIG_PPC_PMAC */ - - /* That syscall isn't quite compatible with PCI domains, but it's - * used on pre-domains setup. We return the first match - */ - - for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) { - bus = pci_bus_b(ln); - if (in_bus >= bus->number && in_bus < (bus->number + bus->subordinate)) - break; - bus = NULL; - } - if (bus == NULL || bus->sysdata == NULL) - return -ENODEV; - - hose_node = bus->sysdata; - hose = PCI_DN(hose_node)->phb; - - switch (which) { - case IOBASE_BRIDGE_NUMBER: - return (long)hose->first_busno; - case IOBASE_MEMORY: - return (long)hose->pci_mem_offset; - case IOBASE_IO: - return (long)hose->io_base_phys; - case IOBASE_ISA_IO: - return (long)isa_io_base; - case IOBASE_ISA_MEM: - return -EINVAL; - } -#endif /* CONFIG_PCI */ - return -EOPNOTSUPP; + return sys_pciconfig_iobase(which, in_bus, in_devfn); } -- cgit v0.10.2 From 35efb606e544403835df48cd240441a8e089c80b Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 9 Sep 2005 15:57:17 +0100 Subject: [ARM] Fix typo in arch/arm/Kconfig.debug It's called printch, not printchar Signed-off-by: Russell King diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug index 45a5709..5d3acff 100644 --- a/arch/arm/Kconfig.debug +++ b/arch/arm/Kconfig.debug @@ -53,7 +53,7 @@ config DEBUG_LL bool "Kernel low-level debugging functions" depends on DEBUG_KERNEL help - Say Y here to include definitions of printascii, printchar, printhex + Say Y here to include definitions of printascii, printch, printhex in the kernel. This is helpful if you are debugging code that executes before the console is initialized. -- cgit v0.10.2 From 6f0d618f0e9b8025d1c3531e82d7cc8455e79394 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 9 Sep 2005 16:17:58 +0100 Subject: [SERIAL] Spelling fix in 8250.c Signed-off-by: Russell King diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 5b65e20..4d75cdf 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -864,7 +864,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) /* * We're pretty sure there's a port here. Lets find out what * type of port it is. The IIR top two bits allows us to find - * out if its 8250 or 16450, 16550, 16550A or later. This + * out if it's 8250 or 16450, 16550, 16550A or later. This * determines what we test for next. * * We also initialise the EFR (if any) to zero for later. The -- cgit v0.10.2 From e517d3133f62c27b211f305a6dbd6f6ccac0db1b Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 26 Jul 2005 10:18:45 -0400 Subject: [SCSI] add missing scan mutex to scsi_scan_target() This patch (as543) adds a private entry point to scsi_scan_target, for use when the caller already owns the scan_mutex, and updates the kerneldoc for that routine (which was badly out-of-date). It converts scsi_scan_channel to use the new entry point. Lastly, it modifies scsi_get_host_dev to make it acquire the scan_mutex, necessary since the routine adds a new scsi_device even if it doesn't do any actual scanning. Signed-off-by: Alan Stern Signed-off-by: James Bottomley diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 19c9a23..76577fa 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1276,27 +1276,8 @@ void scsi_rescan_device(struct device *dev) } EXPORT_SYMBOL(scsi_rescan_device); -/** - * scsi_scan_target - scan a target id, possibly including all LUNs on the - * target. - * @sdevsca: Scsi_Device handle for scanning - * @shost: host to scan - * @channel: channel to scan - * @id: target id to scan - * - * Description: - * Scan the target id on @shost, @channel, and @id. Scan at least LUN - * 0, and possibly all LUNs on the target id. - * - * Use the pre-allocated @sdevscan as a handle for the scanning. This - * function sets sdevscan->host, sdevscan->id and sdevscan->lun; the - * scanning functions modify sdevscan->lun. - * - * First try a REPORT LUN scan, if that does not scan the target, do a - * sequential scan of LUNs on the target id. - **/ -void scsi_scan_target(struct device *parent, unsigned int channel, - unsigned int id, unsigned int lun, int rescan) +static void __scsi_scan_target(struct device *parent, unsigned int channel, + unsigned int id, unsigned int lun, int rescan) { struct Scsi_Host *shost = dev_to_shost(parent); int bflags = 0; @@ -1310,9 +1291,7 @@ void scsi_scan_target(struct device *parent, unsigned int channel, */ return; - starget = scsi_alloc_target(parent, channel, id); - if (!starget) return; @@ -1358,6 +1337,33 @@ void scsi_scan_target(struct device *parent, unsigned int channel, put_device(&starget->dev); } + +/** + * scsi_scan_target - scan a target id, possibly including all LUNs on the + * target. + * @parent: host to scan + * @channel: channel to scan + * @id: target id to scan + * @lun: Specific LUN to scan or SCAN_WILD_CARD + * @rescan: passed to LUN scanning routines + * + * Description: + * Scan the target id on @parent, @channel, and @id. Scan at least LUN 0, + * and possibly all LUNs on the target id. + * + * First try a REPORT LUN scan, if that does not scan the target, do a + * sequential scan of LUNs on the target id. + **/ +void scsi_scan_target(struct device *parent, unsigned int channel, + unsigned int id, unsigned int lun, int rescan) +{ + struct Scsi_Host *shost = dev_to_shost(parent); + + down(&shost->scan_mutex); + if (scsi_host_scan_allowed(shost)) + __scsi_scan_target(parent, channel, id, lun, rescan); + up(&shost->scan_mutex); +} EXPORT_SYMBOL(scsi_scan_target); static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel, @@ -1383,10 +1389,12 @@ static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel, order_id = shost->max_id - id - 1; else order_id = id; - scsi_scan_target(&shost->shost_gendev, channel, order_id, lun, rescan); + __scsi_scan_target(&shost->shost_gendev, channel, + order_id, lun, rescan); } else - scsi_scan_target(&shost->shost_gendev, channel, id, lun, rescan); + __scsi_scan_target(&shost->shost_gendev, channel, + id, lun, rescan); } int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel, @@ -1484,12 +1492,15 @@ void scsi_forget_host(struct Scsi_Host *shost) */ struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost) { - struct scsi_device *sdev; + struct scsi_device *sdev = NULL; struct scsi_target *starget; + down(&shost->scan_mutex); + if (!scsi_host_scan_allowed(shost)) + goto out; starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id); if (!starget) - return NULL; + goto out; sdev = scsi_alloc_sdev(starget, 0, NULL); if (sdev) { @@ -1497,6 +1508,8 @@ struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost) sdev->borken = 0; } put_device(&starget->dev); + out: + up(&shost->scan_mutex); return sdev; } EXPORT_SYMBOL(scsi_get_host_dev); -- cgit v0.10.2 From 903f4fed858a7b56b260cbd55d174fe54d188fb7 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 26 Jul 2005 10:20:53 -0400 Subject: [SCSI] fix callers of scsi_remove_device() who already hold the scan muted This patch (as544) adds a private entry point to scsi_remove_device, for use when callers already own the scan_mutex. The appropriate callers are modified to use the new entry point. Signed-off-by: Alan Stern Signed-off-by: James Bottomley diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index ee6de17..d05f778 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h @@ -124,6 +124,7 @@ extern void scsi_sysfs_unregister(void); extern void scsi_sysfs_device_initialize(struct scsi_device *); extern int scsi_sysfs_target_initialize(struct scsi_device *); extern struct scsi_transport_template blank_transport_template; +extern void __scsi_remove_device(struct scsi_device *); extern struct bus_type scsi_bus_type; diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index dae59d1..b8052d5 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -653,7 +653,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) error = attr_add(&sdev->sdev_gendev, sdev->host->hostt->sdev_attrs[i]); if (error) { - scsi_remove_device(sdev); + __scsi_remove_device(sdev); goto out; } } @@ -667,7 +667,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) scsi_sysfs_sdev_attrs[i]); error = device_create_file(&sdev->sdev_gendev, attr); if (error) { - scsi_remove_device(sdev); + __scsi_remove_device(sdev); goto out; } } @@ -687,17 +687,10 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) return error; } -/** - * scsi_remove_device - unregister a device from the scsi bus - * @sdev: scsi_device to unregister - **/ -void scsi_remove_device(struct scsi_device *sdev) +void __scsi_remove_device(struct scsi_device *sdev) { - struct Scsi_Host *shost = sdev->host; - - down(&shost->scan_mutex); if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) - goto out; + return; class_device_unregister(&sdev->sdev_classdev); device_del(&sdev->sdev_gendev); @@ -706,8 +699,17 @@ void scsi_remove_device(struct scsi_device *sdev) sdev->host->hostt->slave_destroy(sdev); transport_unregister_device(&sdev->sdev_gendev); put_device(&sdev->sdev_gendev); -out: - up(&shost->scan_mutex); +} + +/** + * scsi_remove_device - unregister a device from the scsi bus + * @sdev: scsi_device to unregister + **/ +void scsi_remove_device(struct scsi_device *sdev) +{ + down(&sdev->host->scan_mutex); + __scsi_remove_device(sdev); + up(&sdev->host->scan_mutex); } EXPORT_SYMBOL(scsi_remove_device); -- cgit v0.10.2 From 286f3e13a1dc7f32407629fbd7aabc8ea78c62b5 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 2 Sep 2005 13:13:54 +1000 Subject: [SCSI] fix possible deadlock in scsi_lib.c If a filesystem, while writing out data, decides that it is good to issue a cache flush on a SCSI drive (or other 'sd' device), it will call blkdev_issue_flush which calls ->issue_flush_fn which is scsi_issue_flush_fn. This calls sd_issue_flush which calls sd_sync_cache, which calls scsi_execute_request. This will (as sshdr != NULL) call kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL) If memory is tight, the presence of GFP_KERNEL may cause write requests to be sent to some filesystem to free up memory, however if that filesystem is waiting for the issue_flush_fn to complete, you could get a deadlock. I wonder if it might be more appropriate to use GFP_NOIO as in the following patch. I wonder if it might be even more appropriate to cope better with a kmalloc failure, especially as in this use, sd_sync_cache only will use the sense information to print out a more informative error message. Signed-off-by: Neil Brown Signed-off-by: James Bottomley diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 77f2d44..2ad60f1 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -339,7 +339,7 @@ int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, int result; if (sshdr) { - sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); + sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_NOIO); if (!sense) return DRIVER_ERROR << 24; memset(sense, 0, SCSI_SENSE_BUFFERSIZE); -- cgit v0.10.2 From e91442b635be776ea205fba233bdd5bc74b62bc3 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Fri, 9 Sep 2005 10:44:16 -0500 Subject: [SCSI] SCSI core: fix leakage of scsi_cmnd's From: Alan Stern This patch (as559b) adds a new routine, scsi_unprep_request, which gets called every place a request is requeued. (That includes scsi_queue_insert as well as scsi_requeue_command.) It also changes scsi_kill_requests to make it call __scsi_done with result equal to DID_NO_CONNECT << 16. (I'm not sure if it's necessary to call scsi_init_cmd_errh here; maybe you can check on that.) Finally, the patch changes the return value from scsi_end_request, to avoid returning a stale pointer in the case where the request was requeued. Fortunately the return value is used in only place, and the change actually simplified it. Signed-off-by: Alan Stern Rejections fixed up and Signed-off-by: James Bottomley diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 2ad60f1..003f8cf 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -97,6 +97,30 @@ int scsi_insert_special_req(struct scsi_request *sreq, int at_head) } static void scsi_run_queue(struct request_queue *q); +static void scsi_release_buffers(struct scsi_cmnd *cmd); + +/* + * Function: scsi_unprep_request() + * + * Purpose: Remove all preparation done for a request, including its + * associated scsi_cmnd, so that it can be requeued. + * + * Arguments: req - request to unprepare + * + * Lock status: Assumed that no locks are held upon entry. + * + * Returns: Nothing. + */ +static void scsi_unprep_request(struct request *req) +{ + struct scsi_cmnd *cmd = req->special; + + req->flags &= ~REQ_DONTPREP; + req->special = (req->flags & REQ_SPECIAL) ? cmd->sc_request : NULL; + + scsi_release_buffers(cmd); + scsi_put_command(cmd); +} /* * Function: scsi_queue_insert() @@ -116,12 +140,14 @@ static void scsi_run_queue(struct request_queue *q); * commands. * Notes: This could be called either from an interrupt context or a * normal process context. + * Notes: Upon return, cmd is a stale pointer. */ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason) { struct Scsi_Host *host = cmd->device->host; struct scsi_device *device = cmd->device; struct request_queue *q = device->request_queue; + struct request *req = cmd->request; unsigned long flags; SCSI_LOG_MLQUEUE(1, @@ -162,8 +188,9 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason) * function. The SCSI request function detects the blocked condition * and plugs the queue appropriately. */ + scsi_unprep_request(req); spin_lock_irqsave(q->queue_lock, flags); - blk_requeue_request(q, cmd->request); + blk_requeue_request(q, req); spin_unlock_irqrestore(q->queue_lock, flags); scsi_run_queue(q); @@ -552,15 +579,16 @@ static void scsi_run_queue(struct request_queue *q) * I/O errors in the middle of the request, in which case * we need to request the blocks that come after the bad * sector. + * Notes: Upon return, cmd is a stale pointer. */ static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd) { + struct request *req = cmd->request; unsigned long flags; - cmd->request->flags &= ~REQ_DONTPREP; - + scsi_unprep_request(req); spin_lock_irqsave(q->queue_lock, flags); - blk_requeue_request(q, cmd->request); + blk_requeue_request(q, req); spin_unlock_irqrestore(q->queue_lock, flags); scsi_run_queue(q); @@ -595,13 +623,14 @@ void scsi_run_host_queues(struct Scsi_Host *shost) * * Lock status: Assumed that lock is not held upon entry. * - * Returns: cmd if requeue done or required, NULL otherwise + * Returns: cmd if requeue required, NULL otherwise. * * Notes: This is called for block device requests in order to * mark some number of sectors as complete. * * We are guaranteeing that the request queue will be goosed * at some point during this call. + * Notes: If cmd was requeued, upon return it will be a stale pointer. */ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate, int bytes, int requeue) @@ -624,14 +653,15 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate, if (!uptodate && blk_noretry_request(req)) end_that_request_chunk(req, 0, leftover); else { - if (requeue) + if (requeue) { /* * Bleah. Leftovers again. Stick the * leftovers in the front of the * queue, and goose the queue again. */ scsi_requeue_command(q, cmd); - + cmd = NULL; + } return cmd; } } @@ -857,15 +887,13 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes, * requeueing right here - we will requeue down below * when we handle the bad sectors. */ - cmd = scsi_end_request(cmd, 1, good_bytes, result == 0); /* - * If the command completed without error, then either finish off the - * rest of the command, or start a new one. + * If the command completed without error, then either + * finish off the rest of the command, or start a new one. */ - if (result == 0 || cmd == NULL ) { + if (scsi_end_request(cmd, 1, good_bytes, result == 0) == NULL) return; - } } /* * Now, if we were good little boys and girls, Santa left us a request @@ -880,7 +908,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes, * and quietly refuse further access. */ cmd->device->changed = 1; - cmd = scsi_end_request(cmd, 0, + scsi_end_request(cmd, 0, this_count, 1); return; } else { @@ -914,7 +942,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes, scsi_requeue_command(q, cmd); result = 0; } else { - cmd = scsi_end_request(cmd, 0, this_count, 1); + scsi_end_request(cmd, 0, this_count, 1); return; } break; @@ -931,7 +959,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes, dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "Device not ready.\n"); - cmd = scsi_end_request(cmd, 0, this_count, 1); + scsi_end_request(cmd, 0, this_count, 1); return; case VOLUME_OVERFLOW: if (!(req->flags & REQ_QUIET)) { @@ -941,7 +969,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes, __scsi_print_command(cmd->data_cmnd); scsi_print_sense("", cmd); } - cmd = scsi_end_request(cmd, 0, block_bytes, 1); + scsi_end_request(cmd, 0, block_bytes, 1); return; default: break; @@ -972,7 +1000,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes, block_bytes = req->hard_cur_sectors << 9; if (!block_bytes) block_bytes = req->data_len; - cmd = scsi_end_request(cmd, 0, block_bytes, 1); + scsi_end_request(cmd, 0, block_bytes, 1); } } EXPORT_SYMBOL(scsi_io_completion); @@ -1336,19 +1364,24 @@ static inline int scsi_host_queue_ready(struct request_queue *q, } /* - * Kill requests for a dead device + * Kill a request for a dead device */ -static void scsi_kill_requests(request_queue_t *q) +static void scsi_kill_request(struct request *req, request_queue_t *q) { - struct request *req; + struct scsi_cmnd *cmd = req->special; - while ((req = elv_next_request(q)) != NULL) { - blkdev_dequeue_request(req); - req->flags |= REQ_QUIET; - while (end_that_request_first(req, 0, req->nr_sectors)) - ; - end_that_request_last(req); + spin_unlock(q->queue_lock); + if (unlikely(cmd == NULL)) { + printk(KERN_CRIT "impossible request in %s.\n", + __FUNCTION__); + BUG(); } + + scsi_init_cmd_errh(cmd); + cmd->result = DID_NO_CONNECT << 16; + atomic_inc(&cmd->device->iorequest_cnt); + __scsi_done(cmd); + spin_lock(q->queue_lock); } /* @@ -1371,7 +1404,8 @@ static void scsi_request_fn(struct request_queue *q) if (!sdev) { printk("scsi: killing requests for dead queue\n"); - scsi_kill_requests(q); + while ((req = elv_next_request(q)) != NULL) + scsi_kill_request(req, q); return; } @@ -1399,10 +1433,7 @@ static void scsi_request_fn(struct request_queue *q) printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to offline device\n", sdev->host->host_no, sdev->id, sdev->lun); blkdev_dequeue_request(req); - req->flags |= REQ_QUIET; - while (end_that_request_first(req, 0, req->nr_sectors)) - ; - end_that_request_last(req); + scsi_kill_request(req, q); continue; } @@ -1415,6 +1446,14 @@ static void scsi_request_fn(struct request_queue *q) sdev->device_busy++; spin_unlock(q->queue_lock); + cmd = req->special; + if (unlikely(cmd == NULL)) { + printk(KERN_CRIT "impossible request in %s.\n" + "please mail a stack trace to " + "linux-scsi@vger.kernel.org", + __FUNCTION__); + BUG(); + } spin_lock(shost->host_lock); if (!scsi_host_queue_ready(q, shost, sdev)) @@ -1433,15 +1472,6 @@ static void scsi_request_fn(struct request_queue *q) */ spin_unlock_irq(shost->host_lock); - cmd = req->special; - if (unlikely(cmd == NULL)) { - printk(KERN_CRIT "impossible request in %s.\n" - "please mail a stack trace to " - "linux-scsi@vger.kernel.org", - __FUNCTION__); - BUG(); - } - /* * Finally, initialize any error handling parameters, and set up * the timers for timeouts. @@ -1477,6 +1507,7 @@ static void scsi_request_fn(struct request_queue *q) * cases (host limits or settings) should run the queue at some * later time. */ + scsi_unprep_request(req); spin_lock_irq(q->queue_lock); blk_requeue_request(q, req); sdev->device_busy--; -- cgit v0.10.2 From 2fd9d74b35efa9823f1f7d34cb421e2b9eee9650 Mon Sep 17 00:00:00 2001 From: Brett M Russ Date: Fri, 9 Sep 2005 10:02:22 -0700 Subject: [PATCH] PCI: PCI/libata INTx bug fix Previous INTx cleanup patch had a bug that was not caught. I found this last night during testing and can confirm that it is now 100% working. Signed-off-by: Brett Russ Signed-off-by: Greg Kroah-Hartman Acked-by: Jeff Garzik Signed-off-by: Linus Torvalds diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index ccff633..992db89 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -819,7 +819,7 @@ pci_intx(struct pci_dev *pdev, int enable) } if (new != pci_command) { - pci_write_config_word(pdev, PCI_COMMAND, pci_command); + pci_write_config_word(pdev, PCI_COMMAND, new); } } -- cgit v0.10.2 From 86feeaa8120bb1b0ab21efed49e9754039395ef1 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 19:28:28 +0200 Subject: kbuild: full dependency check on asm-offsets.h Building asm-offsets.h has been moved to a seperate Kbuild file located in the top-level directory. This allow us to share the functionality across the architectures. The old rules in architecture specific Makefiles will die in subsequent patches. Furhtermore the usual kbuild dependency tracking is now used when deciding to rebuild asm-offsets.s. So we no longer risk to fail a rebuild caused by asm-offsets.c dependencies being touched. With this common rule-set we now force the same name across all architectures. Following patches will fix the rest. Signed-off-by: Sam Ravnborg diff --git a/Kbuild b/Kbuild new file mode 100644 index 0000000..197ece8 --- /dev/null +++ b/Kbuild @@ -0,0 +1,41 @@ +# +# Kbuild for top-level directory of the kernel +# This file takes care of the following: +# 1) Generate asm-offsets.h + +##### +# 1) Generate asm-offsets.h +# + +offsets-file := include/asm-$(ARCH)/asm-offsets.h + +always := $(offsets-file) +targets := $(offsets-file) +targets += arch/$(ARCH)/kernel/asm-offsets.s + +quiet_cmd_offsets = GEN $@ +define cmd_offsets + cat $< | \ + (set -e; \ + echo "#ifndef __ASM_OFFSETS_H__"; \ + echo "#define __ASM_OFFSETS_H__"; \ + echo "/*"; \ + echo " * DO NOT MODIFY."; \ + echo " *"; \ + echo " * This file was generated by $(srctree)/Kbuild"; \ + echo " *"; \ + echo " */"; \ + echo ""; \ + sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ + echo ""; \ + echo "#endif" ) > $@ +endef + +# We use internal kbuild rules to avoid the "is up to date" message from make +arch/$(ARCH)/kernel/asm-offsets.s: arch/$(ARCH)/kernel/asm-offsets.c FORCE + $(Q)mkdir -p $(dir $@) + $(call if_changed_dep,cc_s_c) + +$(srctree)/$(offsets-file): arch/$(ARCH)/kernel/asm-offsets.s Kbuild + $(call cmd,offsets) + diff --git a/Makefile b/Makefile index 63e5c9f..2402430 100644 --- a/Makefile +++ b/Makefile @@ -776,14 +776,14 @@ $(vmlinux-dirs): prepare-all scripts # A multi level approach is used. prepare1 is updated first, then prepare0. # prepare-all is the collection point for the prepare targets. -.PHONY: prepare-all prepare prepare0 prepare1 prepare2 +.PHONY: prepare-all prepare prepare0 prepare1 prepare2 prepare3 -# prepare2 is used to check if we are building in a separate output directory, +# prepare3 is used to check if we are building in a separate output directory, # and if so do: # 1) Check that make has not been executed in the kernel src $(srctree) # 2) Create the include2 directory, used for the second asm symlink -prepare2: +prepare3: ifneq ($(KBUILD_SRC),) @echo ' Using $(srctree) as source for kernel' $(Q)if [ -f $(srctree)/.config ]; then \ @@ -795,18 +795,21 @@ ifneq ($(KBUILD_SRC),) $(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm endif -# prepare1 creates a makefile if using a separate output directory -prepare1: prepare2 outputmakefile +# prepare2 creates a makefile if using a separate output directory +prepare2: prepare3 outputmakefile -prepare0: prepare1 include/linux/version.h include/asm \ +prepare1: prepare2 include/linux/version.h include/asm \ include/config/MARKER ifneq ($(KBUILD_MODULES),) $(Q)rm -rf $(MODVERDIR) $(Q)mkdir -p $(MODVERDIR) endif +prepare0: prepare prepare1 FORCE + $(Q)$(MAKE) $(build)=$(srctree) + # All the preparing.. -prepare-all: prepare0 prepare +prepare-all: prepare0 # Leave this as default for preprocessing vmlinux.lds.S, which is now # done in arch/$(ARCH)/kernel/Makefile @@ -949,26 +952,6 @@ modules modules_install: FORCE endif # CONFIG_MODULES -# Generate asm-offsets.h -# --------------------------------------------------------------------------- - -define filechk_gen-asm-offsets - (set -e; \ - echo "#ifndef __ASM_OFFSETS_H__"; \ - echo "#define __ASM_OFFSETS_H__"; \ - echo "/*"; \ - echo " * DO NOT MODIFY."; \ - echo " *"; \ - echo " * This file was generated by arch/$(ARCH)/Makefile"; \ - echo " *"; \ - echo " */"; \ - echo ""; \ - sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ - echo ""; \ - echo "#endif" ) -endef - - ### # Cleaning is done on three levels. # make clean Delete most generated files @@ -991,7 +974,7 @@ MRPROPER_FILES += .config .config.old include/asm .version \ # clean: rm-dirs := $(CLEAN_DIRS) clean: rm-files := $(CLEAN_FILES) -clean-dirs := $(addprefix _clean_,$(vmlinux-alldirs)) +clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs)) .PHONY: $(clean-dirs) clean archclean $(clean-dirs): diff --git a/arch/i386/Makefile b/arch/i386/Makefile index bf7c9ba..0995199 100644 --- a/arch/i386/Makefile +++ b/arch/i386/Makefile @@ -156,15 +156,6 @@ install: vmlinux install kernel_install: $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install -prepare: include/asm-$(ARCH)/asm_offsets.h -CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/asm_offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - archclean: $(Q)$(MAKE) $(clean)=arch/i386/boot diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S index 0480ca9..e437fb3 100644 --- a/arch/i386/kernel/head.S +++ b/arch/i386/kernel/head.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include /* diff --git a/arch/i386/kernel/vsyscall-sigreturn.S b/arch/i386/kernel/vsyscall-sigreturn.S index 68afa50..fadb5bc 100644 --- a/arch/i386/kernel/vsyscall-sigreturn.S +++ b/arch/i386/kernel/vsyscall-sigreturn.S @@ -7,7 +7,7 @@ */ #include -#include +#include /* XXX diff --git a/arch/i386/kernel/vsyscall.lds.S b/arch/i386/kernel/vsyscall.lds.S index a797770..98699ca 100644 --- a/arch/i386/kernel/vsyscall.lds.S +++ b/arch/i386/kernel/vsyscall.lds.S @@ -3,7 +3,7 @@ * object prelinked to its virtual address, and with only one read-only * segment (that fits in one page). This script controls its layout. */ -#include +#include SECTIONS { diff --git a/arch/i386/power/swsusp.S b/arch/i386/power/swsusp.S index c410528..c893b89 100644 --- a/arch/i386/power/swsusp.S +++ b/arch/i386/power/swsusp.S @@ -12,7 +12,7 @@ #include #include #include -#include +#include .text diff --git a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h index e2cb9fa..8fbf791 100644 --- a/include/asm-i386/thread_info.h +++ b/include/asm-i386/thread_info.h @@ -48,7 +48,7 @@ struct thread_info { #else /* !__ASSEMBLY__ */ -#include +#include #endif -- cgit v0.10.2 From 6c9afc655d4df902211d00a437e893881cdef588 Mon Sep 17 00:00:00 2001 From: "viro@ZenIV.linux.org.uk" Date: Fri, 9 Sep 2005 16:50:43 +0100 Subject: [PATCH] basic iomem annotations (ppc64) Signed-off-by: Al Viro Signed-off-by: Linus Torvalds diff --git a/arch/ppc64/kernel/iomap.c b/arch/ppc64/kernel/iomap.c index 153cc8b..09a3062 100644 --- a/arch/ppc64/kernel/iomap.c +++ b/arch/ppc64/kernel/iomap.c @@ -56,15 +56,15 @@ EXPORT_SYMBOL(iowrite32); */ void ioread8_rep(void __iomem *addr, void *dst, unsigned long count) { - _insb((u8 __force *) addr, dst, count); + _insb((u8 __iomem *) addr, dst, count); } void ioread16_rep(void __iomem *addr, void *dst, unsigned long count) { - _insw_ns((u16 __force *) addr, dst, count); + _insw_ns((u16 __iomem *) addr, dst, count); } void ioread32_rep(void __iomem *addr, void *dst, unsigned long count) { - _insl_ns((u32 __force *) addr, dst, count); + _insl_ns((u32 __iomem *) addr, dst, count); } EXPORT_SYMBOL(ioread8_rep); EXPORT_SYMBOL(ioread16_rep); @@ -72,15 +72,15 @@ EXPORT_SYMBOL(ioread32_rep); void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count) { - _outsb((u8 __force *) addr, src, count); + _outsb((u8 __iomem *) addr, src, count); } void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count) { - _outsw_ns((u16 __force *) addr, src, count); + _outsw_ns((u16 __iomem *) addr, src, count); } void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count) { - _outsl_ns((u32 __force *) addr, src, count); + _outsl_ns((u32 __iomem *) addr, src, count); } EXPORT_SYMBOL(iowrite8_rep); EXPORT_SYMBOL(iowrite16_rep); diff --git a/include/asm-ppc64/eeh.h b/include/asm-ppc64/eeh.h index 94298b1..40c8eb5 100644 --- a/include/asm-ppc64/eeh.h +++ b/include/asm-ppc64/eeh.h @@ -219,23 +219,24 @@ static inline void eeh_raw_writeq(u64 val, volatile void __iomem *addr) static inline void eeh_memset_io(volatile void __iomem *addr, int c, unsigned long n) { + void *p = (void __force *)addr; u32 lc = c; lc |= lc << 8; lc |= lc << 16; - while(n && !EEH_CHECK_ALIGN(addr, 4)) { - *((volatile u8 *)addr) = c; - addr = (void *)((unsigned long)addr + 1); + while(n && !EEH_CHECK_ALIGN(p, 4)) { + *((volatile u8 *)p) = c; + p++; n--; } while(n >= 4) { - *((volatile u32 *)addr) = lc; - addr = (void *)((unsigned long)addr + 4); + *((volatile u32 *)p) = lc; + p += 4; n -= 4; } while(n) { - *((volatile u8 *)addr) = c; - addr = (void *)((unsigned long)addr + 1); + *((volatile u8 *)p) = c; + p++; n--; } __asm__ __volatile__ ("sync" : : : "memory"); @@ -250,22 +251,22 @@ static inline void eeh_memcpy_fromio(void *dest, const volatile void __iomem *sr while(n && (!EEH_CHECK_ALIGN(vsrc, 4) || !EEH_CHECK_ALIGN(dest, 4))) { *((u8 *)dest) = *((volatile u8 *)vsrc); __asm__ __volatile__ ("eieio" : : : "memory"); - vsrc = (void *)((unsigned long)vsrc + 1); - dest = (void *)((unsigned long)dest + 1); + vsrc++; + dest++; n--; } while(n > 4) { *((u32 *)dest) = *((volatile u32 *)vsrc); __asm__ __volatile__ ("eieio" : : : "memory"); - vsrc = (void *)((unsigned long)vsrc + 4); - dest = (void *)((unsigned long)dest + 4); + vsrc += 4; + dest += 4; n -= 4; } while(n) { *((u8 *)dest) = *((volatile u8 *)vsrc); __asm__ __volatile__ ("eieio" : : : "memory"); - vsrc = (void *)((unsigned long)vsrc + 1); - dest = (void *)((unsigned long)dest + 1); + vsrc++; + dest++; n--; } __asm__ __volatile__ ("sync" : : : "memory"); @@ -286,20 +287,20 @@ static inline void eeh_memcpy_toio(volatile void __iomem *dest, const void *src, while(n && (!EEH_CHECK_ALIGN(vdest, 4) || !EEH_CHECK_ALIGN(src, 4))) { *((volatile u8 *)vdest) = *((u8 *)src); - src = (void *)((unsigned long)src + 1); - vdest = (void *)((unsigned long)vdest + 1); + src++; + vdest++; n--; } while(n > 4) { *((volatile u32 *)vdest) = *((volatile u32 *)src); - src = (void *)((unsigned long)src + 4); - vdest = (void *)((unsigned long)vdest + 4); + src += 4; + vdest += 4; n-=4; } while(n) { *((volatile u8 *)vdest) = *((u8 *)src); - src = (void *)((unsigned long)src + 1); - vdest = (void *)((unsigned long)vdest + 1); + src++; + vdest++; n--; } __asm__ __volatile__ ("sync" : : : "memory"); diff --git a/include/asm-ppc64/io.h b/include/asm-ppc64/io.h index aba1dfa..59c958a 100644 --- a/include/asm-ppc64/io.h +++ b/include/asm-ppc64/io.h @@ -20,10 +20,10 @@ #include -#define __ide_mm_insw(p, a, c) _insw_ns((volatile u16 *)(p), (a), (c)) -#define __ide_mm_insl(p, a, c) _insl_ns((volatile u32 *)(p), (a), (c)) -#define __ide_mm_outsw(p, a, c) _outsw_ns((volatile u16 *)(p), (a), (c)) -#define __ide_mm_outsl(p, a, c) _outsl_ns((volatile u32 *)(p), (a), (c)) +#define __ide_mm_insw(p, a, c) _insw_ns((volatile u16 __iomem *)(p), (a), (c)) +#define __ide_mm_insl(p, a, c) _insl_ns((volatile u32 __iomem *)(p), (a), (c)) +#define __ide_mm_outsw(p, a, c) _outsw_ns((volatile u16 __iomem *)(p), (a), (c)) +#define __ide_mm_outsl(p, a, c) _outsl_ns((volatile u32 __iomem *)(p), (a), (c)) #define SIO_CONFIG_RA 0x398 @@ -71,8 +71,8 @@ extern unsigned long io_page_mask; * Neither do the standard versions now, these are just here * for older code. */ -#define insw_ns(port, buf, ns) _insw_ns((u16 *)((port)+pci_io_base), (buf), (ns)) -#define insl_ns(port, buf, nl) _insl_ns((u32 *)((port)+pci_io_base), (buf), (nl)) +#define insw_ns(port, buf, ns) _insw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns)) +#define insl_ns(port, buf, nl) _insl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl)) #else static inline unsigned char __raw_readb(const volatile void __iomem *addr) @@ -136,9 +136,9 @@ static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr) #define insw_ns(port, buf, ns) eeh_insw_ns((port), (buf), (ns)) #define insl_ns(port, buf, nl) eeh_insl_ns((port), (buf), (nl)) -#define outsb(port, buf, ns) _outsb((u8 *)((port)+pci_io_base), (buf), (ns)) -#define outsw(port, buf, ns) _outsw_ns((u16 *)((port)+pci_io_base), (buf), (ns)) -#define outsl(port, buf, nl) _outsl_ns((u32 *)((port)+pci_io_base), (buf), (nl)) +#define outsb(port, buf, ns) _outsb((u8 __iomem *)((port)+pci_io_base), (buf), (ns)) +#define outsw(port, buf, ns) _outsw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns)) +#define outsl(port, buf, nl) _outsl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl)) #endif @@ -147,16 +147,16 @@ static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr) #define readl_relaxed(addr) readl(addr) #define readq_relaxed(addr) readq(addr) -extern void _insb(volatile u8 *port, void *buf, int ns); -extern void _outsb(volatile u8 *port, const void *buf, int ns); -extern void _insw(volatile u16 *port, void *buf, int ns); -extern void _outsw(volatile u16 *port, const void *buf, int ns); -extern void _insl(volatile u32 *port, void *buf, int nl); -extern void _outsl(volatile u32 *port, const void *buf, int nl); -extern void _insw_ns(volatile u16 *port, void *buf, int ns); -extern void _outsw_ns(volatile u16 *port, const void *buf, int ns); -extern void _insl_ns(volatile u32 *port, void *buf, int nl); -extern void _outsl_ns(volatile u32 *port, const void *buf, int nl); +extern void _insb(volatile u8 __iomem *port, void *buf, int ns); +extern void _outsb(volatile u8 __iomem *port, const void *buf, int ns); +extern void _insw(volatile u16 __iomem *port, void *buf, int ns); +extern void _outsw(volatile u16 __iomem *port, const void *buf, int ns); +extern void _insl(volatile u32 __iomem *port, void *buf, int nl); +extern void _outsl(volatile u32 __iomem *port, const void *buf, int nl); +extern void _insw_ns(volatile u16 __iomem *port, void *buf, int ns); +extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, int ns); +extern void _insl_ns(volatile u32 __iomem *port, void *buf, int nl); +extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, int nl); #define mmiowb() @@ -176,8 +176,8 @@ extern void _outsl_ns(volatile u32 *port, const void *buf, int nl); * Neither do the standard versions now, these are just here * for older code. */ -#define outsw_ns(port, buf, ns) _outsw_ns((u16 *)((port)+pci_io_base), (buf), (ns)) -#define outsl_ns(port, buf, nl) _outsl_ns((u32 *)((port)+pci_io_base), (buf), (nl)) +#define outsw_ns(port, buf, ns) _outsw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns)) +#define outsl_ns(port, buf, nl) _outsl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl)) #define IO_SPACE_LIMIT ~(0UL) -- cgit v0.10.2 From 3f70353ea91ad77c83500e70507a239b2ab0c980 Mon Sep 17 00:00:00 2001 From: "viro@ZenIV.linux.org.uk" Date: Fri, 9 Sep 2005 16:53:56 +0100 Subject: [PATCH] bogus cast in bio.c void * is not the same as void *... Signed-off-by: Al Viro Signed-off-by: Linus Torvalds diff --git a/fs/bio.c b/fs/bio.c index a7d4fd3a..83a3495 100644 --- a/fs/bio.c +++ b/fs/bio.c @@ -683,7 +683,7 @@ struct bio *bio_map_user(request_queue_t *q, struct block_device *bdev, { struct sg_iovec iov; - iov.iov_base = (__user void *)uaddr; + iov.iov_base = (void __user *)uaddr; iov.iov_len = len; return bio_map_user_iov(q, bdev, &iov, 1, write_to_vm); -- cgit v0.10.2 From d310a35a487388859432648daa2ea4fc5e51c049 Mon Sep 17 00:00:00 2001 From: "viro@ZenIV.linux.org.uk" Date: Fri, 9 Sep 2005 16:56:05 +0100 Subject: [PATCH] missing CHECKFLAGS on s390 Signed-off-by: Al Viro Signed-off-by: Linus Torvalds diff --git a/arch/s390/Makefile b/arch/s390/Makefile index 3cd8dd2..c1ea6bc 100644 --- a/arch/s390/Makefile +++ b/arch/s390/Makefile @@ -19,6 +19,7 @@ CFLAGS += -m31 AFLAGS += -m31 UTS_MACHINE := s390 STACK_SIZE := 8192 +CHECKFLAGS += -D__s390__ endif ifdef CONFIG_ARCH_S390X @@ -28,6 +29,7 @@ CFLAGS += -m64 AFLAGS += -m64 UTS_MACHINE := s390x STACK_SIZE := 16384 +CHECKFLAGS += -D__s390__ -D__s390x__ endif cflags-$(CONFIG_MARCH_G5) += $(call cc-option,-march=g5) -- cgit v0.10.2 From f91f4d923f4039bf3460eca299ed5a3f7ecd7b96 Mon Sep 17 00:00:00 2001 From: "viro@ZenIV.linux.org.uk" Date: Fri, 9 Sep 2005 17:02:51 +0100 Subject: [PATCH] gratuitous includes of asm/serial.h Removed gratuitous includes of asm/serial.h in synklinkmp and ip2main. Allows to remove the rest of "broken on sparc32" in drivers/char - this stuff doesn't break the build anymore. Since it got zero testing, it almost certainly won't work there, though... Signed-off-by: Al Viro Acked-by: Russell King Signed-off-by: Linus Torvalds diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 2bc9d64..c29365d 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -80,7 +80,7 @@ config SERIAL_NONSTANDARD config COMPUTONE tristate "Computone IntelliPort Plus serial support" - depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP && (BROKEN || !SPARC32) + depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP ---help--- This driver supports the entire family of Intelliport II/Plus controllers with the exception of the MicroChannel controllers and @@ -208,7 +208,7 @@ config SYNCLINK config SYNCLINKMP tristate "SyncLink Multiport support" - depends on SERIAL_NONSTANDARD && (BROKEN || !SPARC32) + depends on SERIAL_NONSTANDARD help Enable support for the SyncLink Multiport (2 or 4 ports) serial adapter, running asynchronous and HDLC communications up diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c index cf0cd58..066d7b5 100644 --- a/drivers/char/ip2main.c +++ b/drivers/char/ip2main.c @@ -120,7 +120,6 @@ #include #include -#include #include diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index ec949e4..8982eaf 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -55,7 +55,6 @@ #include #include #include -#include #include #include -- cgit v0.10.2 From 2624f124b3b5d550ab2fbef7ee3bc0e1fed09722 Mon Sep 17 00:00:00 2001 From: "viro@ZenIV.linux.org.uk" Date: Fri, 9 Sep 2005 17:14:12 +0100 Subject: [PATCH] sparse on uml (infrastructure bits) Passes -m64 to sparse on uml/amd64, tells sparse to stay out of USER_OBJS. Signed-off-by: Al Viro Signed-off-by: Linus Torvalds diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64 index baddb5d..436abbb 100644 --- a/arch/um/Makefile-x86_64 +++ b/arch/um/Makefile-x86_64 @@ -8,6 +8,7 @@ START := 0x60000000 #it's needed for headers to work! CFLAGS += -U__$(SUBARCH)__ -fno-builtin USER_CFLAGS += -fno-builtin +CHECKFLAGS += -m64 ELF_ARCH := i386:x86-64 ELF_FORMAT := elf64-x86-64 diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules index 17f305b..59a1291 100644 --- a/arch/um/scripts/Makefile.rules +++ b/arch/um/scripts/Makefile.rules @@ -9,6 +9,11 @@ USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) $(USER_OBJS) : c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \ $(CFLAGS_$(notdir $@)) +$(USER_OBJS): cmd_checksrc = +$(USER_OBJS): quiet_cmd_checksrc = +$(USER_OBJS): cmd_force_checksrc = +$(USER_OBJS): quiet_cmd_force_checksrc = + # The stubs and unmap.o can't try to call mcount or update basic block data define unprofile -- cgit v0.10.2 From 85c39206ac556c9dd7345465ea5265c1f33e50d1 Mon Sep 17 00:00:00 2001 From: "viro@ZenIV.linux.org.uk" Date: Fri, 9 Sep 2005 17:15:13 +0100 Subject: [PATCH] uaccess.h annotations (uml) Signed-off-by: Al Viro Signed-off-by: Linus Torvalds diff --git a/arch/um/kernel/skas/include/uaccess-skas.h b/arch/um/kernel/skas/include/uaccess-skas.h index cd6c280..6ee3f39 100644 --- a/arch/um/kernel/skas/include/uaccess-skas.h +++ b/arch/um/kernel/skas/include/uaccess-skas.h @@ -18,18 +18,18 @@ ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))) -static inline int verify_area_skas(int type, const void * addr, +static inline int verify_area_skas(int type, const void __user * addr, unsigned long size) { return(access_ok_skas(type, addr, size) ? 0 : -EFAULT); } -extern int copy_from_user_skas(void *to, const void *from, int n); -extern int copy_to_user_skas(void *to, const void *from, int n); -extern int strncpy_from_user_skas(char *dst, const char *src, int count); -extern int __clear_user_skas(void *mem, int len); -extern int clear_user_skas(void *mem, int len); -extern int strnlen_user_skas(const void *str, int len); +extern int copy_from_user_skas(void *to, const void __user *from, int n); +extern int copy_to_user_skas(void __user *to, const void *from, int n); +extern int strncpy_from_user_skas(char *dst, const char __user *src, int count); +extern int __clear_user_skas(void __user *mem, int len); +extern int clear_user_skas(void __user *mem, int len); +extern int strnlen_user_skas(const void __user *str, int len); #endif diff --git a/arch/um/kernel/tt/include/uaccess-tt.h b/arch/um/kernel/tt/include/uaccess-tt.h index 3fbb5fe..aa6db38 100644 --- a/arch/um/kernel/tt/include/uaccess-tt.h +++ b/arch/um/kernel/tt/include/uaccess-tt.h @@ -33,7 +33,7 @@ extern unsigned long uml_physmem; (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \ (under_task_size(addr, size) || is_stack(addr, size)))) -static inline int verify_area_tt(int type, const void * addr, +static inline int verify_area_tt(int type, const void __user * addr, unsigned long size) { return(access_ok_tt(type, addr, size) ? 0 : -EFAULT); @@ -50,12 +50,12 @@ extern int __do_clear_user(void *mem, size_t len, void **fault_addr, extern int __do_strnlen_user(const char *str, unsigned long n, void **fault_addr, void **fault_catcher); -extern int copy_from_user_tt(void *to, const void *from, int n); -extern int copy_to_user_tt(void *to, const void *from, int n); -extern int strncpy_from_user_tt(char *dst, const char *src, int count); -extern int __clear_user_tt(void *mem, int len); -extern int clear_user_tt(void *mem, int len); -extern int strnlen_user_tt(const void *str, int len); +extern int copy_from_user_tt(void *to, const void __user *from, int n); +extern int copy_to_user_tt(void __user *to, const void *from, int n); +extern int strncpy_from_user_tt(char *dst, const char __user *src, int count); +extern int __clear_user_tt(void __user *mem, int len); +extern int clear_user_tt(void __user *mem, int len); +extern int strnlen_user_tt(const void __user *str, int len); #endif -- cgit v0.10.2 From fc0b1af2571cd56f8f2b218ef72b911135c0e37a Mon Sep 17 00:00:00 2001 From: "viro@ZenIV.linux.org.uk" Date: Fri, 9 Sep 2005 17:18:14 +0100 Subject: [PATCH] __user annotations for pointers in i386 sigframe Signed-off-by: Al Viro Signed-off-by: Linus Torvalds diff --git a/arch/i386/kernel/sigframe.h b/arch/i386/kernel/sigframe.h index d21b14f..0b22217 100644 --- a/arch/i386/kernel/sigframe.h +++ b/arch/i386/kernel/sigframe.h @@ -1,6 +1,6 @@ struct sigframe { - char *pretcode; + char __user *pretcode; int sig; struct sigcontext sc; struct _fpstate fpstate; @@ -10,10 +10,10 @@ struct sigframe struct rt_sigframe { - char *pretcode; + char __user *pretcode; int sig; - struct siginfo *pinfo; - void *puc; + struct siginfo __user *pinfo; + void __user *puc; struct siginfo info; struct ucontext uc; struct _fpstate fpstate; -- cgit v0.10.2 From 9b9eb8c06177f07657ad35440b56cbf68e1d253b Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 9 Sep 2005 18:35:12 +0100 Subject: [ARM] sys_mbind needs wrapping sys_mbind is a 6-arg syscall, hence needs wrapping to save the sixth argument. Signed-off-by: Russell King diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S index cc89a73..949ec44 100644 --- a/arch/arm/kernel/calls.S +++ b/arch/arm/kernel/calls.S @@ -333,7 +333,7 @@ __syscall_start: .long sys_inotify_init .long sys_inotify_add_watch .long sys_inotify_rm_watch - .long sys_mbind + .long sys_mbind_wrapper /* 320 */ .long sys_get_mempolicy .long sys_set_mempolicy __syscall_end: diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index 6281d48..db302c6 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -269,6 +269,10 @@ sys_arm_fadvise64_64_wrapper: str r5, [sp, #4] @ push r5 to stack b sys_arm_fadvise64_64 +sys_mbind_wrapper: + str r5, [sp, #4] + b sys_mbind + /* * Note: off_4k (r5) is always units of 4K. If we can't do the requested * offset, we return EINVAL. -- cgit v0.10.2 From 0b968d23610d65a46299347b141a687e207bd294 Mon Sep 17 00:00:00 2001 From: Karsten Wiese Date: Fri, 9 Sep 2005 12:59:04 +0200 Subject: [PATCH] Fix misspelled i8259 typo in io_apic.c The legacy PIC's name is "i8259". Signed-off-by: Karsten Wiese Signed-off-by: Vojtech Pavlik Signed-off-by: Linus Torvalds diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c index 889eda2..1efdc76 100644 --- a/arch/i386/kernel/io_apic.c +++ b/arch/i386/kernel/io_apic.c @@ -1634,9 +1634,9 @@ void disable_IO_APIC(void) clear_IO_APIC(); /* - * If the i82559 is routed through an IOAPIC + * If the i8259 is routed through an IOAPIC * Put that IOAPIC in virtual wire mode - * so legacy interrups can be delivered. + * so legacy interrupts can be delivered. */ pin = find_isa_irq_pin(0, mp_ExtINT); if (pin != -1) { diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c index 40e0aca..5f1529b 100644 --- a/arch/x86_64/kernel/io_apic.c +++ b/arch/x86_64/kernel/io_apic.c @@ -1167,9 +1167,9 @@ void disable_IO_APIC(void) clear_IO_APIC(); /* - * If the i82559 is routed through an IOAPIC + * If the i8259 is routed through an IOAPIC * Put that IOAPIC in virtual wire mode - * so legacy interrups can be delivered. + * so legacy interrupts can be delivered. */ pin = find_isa_irq_pin(0, mp_ExtINT); if (pin != -1) { -- cgit v0.10.2 From 5dce225bd9ea60e28e17076de63df0dee51b2883 Mon Sep 17 00:00:00 2001 From: "viro@ZenIV.linux.org.uk" Date: Fri, 9 Sep 2005 18:31:38 +0100 Subject: [PATCH] Fix CONFIG_ACPI_BLACKLIST_YEAR This makes ACPI_BLACKLIST_YEAR be consistently defined when ACPI is enabled, regardless of whether we're on x86 or not, and thus avoids bogus -Wundef warnings on ia64. Signed-off-by: Linus Torvalds diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 3998c9d..fe1e812 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -250,8 +250,7 @@ config ACPI_CUSTOM_DSDT_FILE Enter the full path name to the file wich includes the AmlCode declaration. config ACPI_BLACKLIST_YEAR - int "Disable ACPI for systems before Jan 1st this year" - depends on X86 + int "Disable ACPI for systems before Jan 1st this year" if X86 default 0 help enter a 4-digit year, eg. 2001 to disable ACPI by default -- cgit v0.10.2 From aa6c2e794f7e1f54dc52c84471c750327fa21ccd Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 9 Sep 2005 18:54:03 +0100 Subject: [ARM] 2893/1: [MMC] Update corgi to use the new mmc delayed detection function Patch from Richard Purdie We can remove this timer and its associated code from the corgi platform code now mmc_detect_change() and the pxamci code support an optional delay. Signed-off-by: Richard Purdie Signed-off-by: Russell King diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c index 29185ac..07b5dd4 100644 --- a/arch/arm/mach-pxa/corgi.c +++ b/arch/arm/mach-pxa/corgi.c @@ -131,27 +131,12 @@ static struct platform_device corgits_device = { /* * MMC/SD Device * - * The card detect interrupt isn't debounced so we delay it by HZ/4 + * The card detect interrupt isn't debounced so we delay it by 250ms * to give the card a chance to fully insert/eject. */ -static struct mmc_detect { - struct timer_list detect_timer; - void *devid; -} mmc_detect; +static struct pxamci_platform_data corgi_mci_platform_data; -static void mmc_detect_callback(unsigned long data) -{ - mmc_detect_change(mmc_detect.devid); -} - -static irqreturn_t corgi_mmc_detect_int(int irq, void *devid, struct pt_regs *regs) -{ - mmc_detect.devid=devid; - mod_timer(&mmc_detect.detect_timer, jiffies + HZ/4); - return IRQ_HANDLED; -} - -static int corgi_mci_init(struct device *dev, irqreturn_t (*unused_detect_int)(int, void *, struct pt_regs *), void *data) +static int corgi_mci_init(struct device *dev, irqreturn_t (*corgi_detect_int)(int, void *, struct pt_regs *), void *data) { int err; @@ -161,11 +146,9 @@ static int corgi_mci_init(struct device *dev, irqreturn_t (*unused_detect_int)(i pxa_gpio_mode(CORGI_GPIO_nSD_DETECT | GPIO_IN); pxa_gpio_mode(CORGI_GPIO_SD_PWR | GPIO_OUT); - init_timer(&mmc_detect.detect_timer); - mmc_detect.detect_timer.function = mmc_detect_callback; - mmc_detect.detect_timer.data = (unsigned long) &mmc_detect; + corgi_mci_platform_data.detect_delay = msecs_to_jiffies(250); - err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_mmc_detect_int, SA_INTERRUPT, + err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_detect_int, SA_INTERRUPT, "MMC card detect", data); if (err) { printk(KERN_ERR "corgi_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); @@ -198,7 +181,6 @@ static int corgi_mci_get_ro(struct device *dev) static void corgi_mci_exit(struct device *dev, void *data) { free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data); - del_timer(&mmc_detect.detect_timer); } static struct pxamci_platform_data corgi_mci_platform_data = { -- cgit v0.10.2 From daad56661d56cc382948fc95b74e17d3326b901b Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 9 Sep 2005 18:54:04 +0100 Subject: [ARM] 2894/1: Sharp Scoop driver pm_message_t type fix Patch from Richard Purdie Fix a pm_message_t type warning in the Sharp scoop driver Signed-off-by: Richard Purdie Signed-off-by: Russell King diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c index 688a595..d3a04c2 100644 --- a/arch/arm/common/scoop.c +++ b/arch/arm/common/scoop.c @@ -91,7 +91,7 @@ EXPORT_SYMBOL(read_scoop_reg); EXPORT_SYMBOL(write_scoop_reg); #ifdef CONFIG_PM -static int scoop_suspend(struct device *dev, uint32_t state, uint32_t level) +static int scoop_suspend(struct device *dev, pm_message_t state, uint32_t level) { if (level == SUSPEND_POWER_DOWN) { struct scoop_dev *sdev = dev_get_drvdata(dev); -- cgit v0.10.2 From 7bcf5c0e7fd9ab4ddb9e24d7e91bda2ac23e5678 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 18 Aug 2005 14:33:01 +1000 Subject: [PATCH] PCI: move pci core to use add_hotplug_env_var() This fixes a bug in the environment variables for all PCI device hotplug calls. Thanks to Kay Sievers for pointing out the problem. Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c index b844bc9..1044498 100644 --- a/drivers/pci/hotplug.c +++ b/drivers/pci/hotplug.c @@ -20,46 +20,35 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp, scratch = buffer; - /* stuff we want to pass to /sbin/hotplug */ - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, "PCI_CLASS=%04X", - pdev->class); - if ((buffer_size - length <= 0) || (i >= num_envp)) + + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_CLASS=%04X", pdev->class)) return -ENOMEM; - ++length; - scratch += length; - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, "PCI_ID=%04X:%04X", - pdev->vendor, pdev->device); - if ((buffer_size - length <= 0) || (i >= num_envp)) + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_ID=%04X:%04X", pdev->vendor, pdev->device)) return -ENOMEM; - ++length; - scratch += length; - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, - "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, - pdev->subsystem_device); - if ((buffer_size - length <= 0) || (i >= num_envp)) + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, + pdev->subsystem_device)) return -ENOMEM; - ++length; - scratch += length; - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, "PCI_SLOT_NAME=%s", - pci_name(pdev)); - if ((buffer_size - length <= 0) || (i >= num_envp)) + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_SLOT_NAME=%s", pci_name(pdev))) return -ENOMEM; - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, - "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", - pdev->vendor, pdev->device, - pdev->subsystem_vendor, pdev->subsystem_device, - (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), - (u8)(pdev->class)); - if ((buffer_size - length <= 0) || (i >= num_envp)) + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", + pdev->vendor, pdev->device, + pdev->subsystem_vendor, pdev->subsystem_device, + (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), + (u8)(pdev->class))) return -ENOMEM; envp[i] = NULL; -- cgit v0.10.2 From 144a50ea5e1487b8b8e722289b4177713354448a Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Tue, 9 Aug 2005 00:20:10 -0400 Subject: [PATCH] must_check attributes for PCI layer. Self explanatory really. Some newer gcc's print a warning if a function is used and we don't check its result. We do this for a bunch of things in the kernel already, this extends that to the PCI layer. Based on a patch originally from Arjan van de Ven. Signed-off-by: Dave Jones Signed-off-by: Arjan van de Ven Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/pci.h b/include/linux/pci.h index 6caaba0..6094993 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -376,32 +376,32 @@ static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); } -int pci_enable_device(struct pci_dev *dev); -int pci_enable_device_bars(struct pci_dev *dev, int mask); +int __must_check pci_enable_device(struct pci_dev *dev); +int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask); void pci_disable_device(struct pci_dev *dev); void pci_set_master(struct pci_dev *dev); #define HAVE_PCI_SET_MWI -int pci_set_mwi(struct pci_dev *dev); +int __must_check pci_set_mwi(struct pci_dev *dev); void pci_clear_mwi(struct pci_dev *dev); void pci_intx(struct pci_dev *dev, int enable); -int pci_set_dma_mask(struct pci_dev *dev, u64 mask); -int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); +int __must_check pci_set_dma_mask(struct pci_dev *dev, u64 mask); +int __must_check pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); int pci_assign_resource(struct pci_dev *dev, int i); void pci_restore_bars(struct pci_dev *dev); /* ROM control related routines */ -void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size); -void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size); +void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); +void __iomem __must_check *pci_map_rom_copy(struct pci_dev *pdev, size_t *size); void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); void pci_remove_rom(struct pci_dev *pdev); /* Power management related routines */ int pci_save_state(struct pci_dev *dev); int pci_restore_state(struct pci_dev *dev); -int pci_set_power_state(struct pci_dev *dev, pci_power_t state); -pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); -int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); +int __must_check pci_set_power_state(struct pci_dev *dev, pci_power_t state); +pci_power_t __must_check pci_choose_state(struct pci_dev *dev, pm_message_t state); +int __must_check pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ void pci_bus_assign_resources(struct pci_bus *bus); -- cgit v0.10.2 From cca6e6f5f473ec63e85c87dfc77279ce1ca114e6 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 20:28:49 +0200 Subject: kbuild: h8300,m68knommu,sh,sh64 use generic asm-offsets.h support h8300, m68knommu, sh and sh64 all used the name asm-offsets.h so minimal changes required. Signed-off-by: Sam Ravnborg diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile index c9b80cf..40b3f56 100644 --- a/arch/h8300/Makefile +++ b/arch/h8300/Makefile @@ -61,12 +61,6 @@ archmrproper: archclean: $(Q)$(MAKE) $(clean)=$(boot) -prepare: include/asm-$(ARCH)/asm-offsets.h - -include/asm-$(ARCH)/asm-offsets.h: arch/$(ARCH)/kernel/asm-offsets.s \ - include/asm include/linux/version.h - $(call filechk,gen-asm-offsets) - vmlinux.srec vmlinux.bin: vmlinux $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ @@ -74,5 +68,3 @@ define archhelp echo 'vmlinux.bin - Create raw binary' echo 'vmlinux.srec - Create srec binary' endef - -CLEAN_FILES += include/asm-$(ARCH)/asm-offsets.h diff --git a/arch/m68knommu/Makefile b/arch/m68knommu/Makefile index 7ce5e55..b8fdf19 100644 --- a/arch/m68knommu/Makefile +++ b/arch/m68knommu/Makefile @@ -102,21 +102,11 @@ CFLAGS += -DUTS_SYSNAME=\"uClinux\" head-y := arch/m68knommu/platform/$(cpuclass-y)/head.o -CLEAN_FILES := include/asm-$(ARCH)/asm-offsets.h \ - arch/$(ARCH)/kernel/asm-offsets.s - core-y += arch/m68knommu/kernel/ \ arch/m68knommu/mm/ \ $(CLASSDIR) \ arch/m68knommu/platform/$(PLATFORM)/ libs-y += arch/m68knommu/lib/ -prepare: include/asm-$(ARCH)/asm-offsets.h - archclean: $(Q)$(MAKE) $(clean)=arch/m68knommu/boot - -include/asm-$(ARCH)/asm-offsets.h: arch/$(ARCH)/kernel/asm-offsets.s \ - include/asm include/linux/version.h \ - include/config/MARKER - $(call filechk,gen-asm-offsets) diff --git a/arch/sh/Makefile b/arch/sh/Makefile index b563563..19f00d5 100644 --- a/arch/sh/Makefile +++ b/arch/sh/Makefile @@ -155,7 +155,7 @@ endif prepare: maketools include/asm-sh/.cpu include/asm-sh/.mach .PHONY: maketools FORCE -maketools: include/asm-sh/asm-offsets.h include/linux/version.h FORCE +maketools: include/linux/version.h FORCE $(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h all: zImage @@ -168,14 +168,7 @@ compressed: zImage archclean: $(Q)$(MAKE) $(clean)=$(boot) -CLEAN_FILES += include/asm-sh/machtypes.h include/asm-sh/asm-offsets.h - -arch/sh/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/asm-sh/.cpu include/asm-sh/.mach - -include/asm-sh/asm-offsets.h: arch/sh/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - +CLEAN_FILES += include/asm-sh/machtypes.h define archhelp @echo ' zImage - Compressed kernel image (arch/sh/boot/zImage)' diff --git a/arch/sh64/Makefile b/arch/sh64/Makefile index b4fd8e1..3907373 100644 --- a/arch/sh64/Makefile +++ b/arch/sh64/Makefile @@ -73,11 +73,7 @@ compressed: zImage archclean: $(Q)$(MAKE) $(clean)=$(boot) -prepare: include/asm-$(ARCH)/asm-offsets.h arch/$(ARCH)/lib/syscalltab.h - -include/asm-$(ARCH)/asm-offsets.h: arch/$(ARCH)/kernel/asm-offsets.s \ - include/asm include/linux/version.h - $(call filechk,gen-asm-offsets) +prepare: arch/$(ARCH)/lib/syscalltab.h define filechk_gen-syscalltab (set -e; \ @@ -108,7 +104,7 @@ endef arch/$(ARCH)/lib/syscalltab.h: arch/sh64/kernel/syscalls.S $(call filechk,gen-syscalltab) -CLEAN_FILES += include/asm-$(ARCH)/asm-offsets.h arch/$(ARCH)/lib/syscalltab.h +CLEAN_FILES += arch/$(ARCH)/lib/syscalltab.h define archhelp @echo ' zImage - Compressed kernel image (arch/sh64/boot/zImage)' -- cgit v0.10.2 From 47003497dd819b10874a2291e54df7dc5cf8be57 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 20:35:55 +0200 Subject: kbuild: arm26,sparc use generic asm-offset support Rename all includes to use asm-offsets.h to match generic name Signed-off-by: Sam Ravnborg diff --git a/arch/arm26/Makefile b/arch/arm26/Makefile index e9cb8ef..844a9e4 100644 --- a/arch/arm26/Makefile +++ b/arch/arm26/Makefile @@ -49,10 +49,6 @@ all: zImage boot := arch/arm26/boot -prepare: include/asm-$(ARCH)/asm_offsets.h -CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h - - .PHONY: maketools FORCE maketools: FORCE @@ -94,12 +90,6 @@ zi:; $(Q)$(MAKE) $(build)=$(boot) zinstall fi; \ ) -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/asm_offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - define archhelp echo '* zImage - Compressed kernel image (arch/$(ARCH)/boot/zImage)' echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)' diff --git a/arch/arm26/kernel/entry.S b/arch/arm26/kernel/entry.S index a231dd8..6d910ea 100644 --- a/arch/arm26/kernel/entry.S +++ b/arch/arm26/kernel/entry.S @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/arm26/lib/copy_page.S b/arch/arm26/lib/copy_page.S index 2d79ee1..c7511a2 100644 --- a/arch/arm26/lib/copy_page.S +++ b/arch/arm26/lib/copy_page.S @@ -11,7 +11,7 @@ */ #include #include -#include +#include .text .align 5 diff --git a/arch/arm26/lib/csumpartialcopyuser.S b/arch/arm26/lib/csumpartialcopyuser.S index 5b82118..261dd15 100644 --- a/arch/arm26/lib/csumpartialcopyuser.S +++ b/arch/arm26/lib/csumpartialcopyuser.S @@ -11,7 +11,7 @@ #include #include #include -#include +#include .text diff --git a/arch/arm26/lib/getuser.S b/arch/arm26/lib/getuser.S index e6d59b33..2b1de7f 100644 --- a/arch/arm26/lib/getuser.S +++ b/arch/arm26/lib/getuser.S @@ -26,7 +26,7 @@ * Note that ADDR_LIMIT is either 0 or 0xc0000000. * Note also that it is intended that __get_user_bad is not global. */ -#include +#include #include #include diff --git a/arch/arm26/lib/putuser.S b/arch/arm26/lib/putuser.S index 87588cb..46c7f15 100644 --- a/arch/arm26/lib/putuser.S +++ b/arch/arm26/lib/putuser.S @@ -26,7 +26,7 @@ * Note that ADDR_LIMIT is either 0 or 0xc0000000 * Note also that it is intended that __put_user_bad is not global. */ -#include +#include #include #include diff --git a/arch/arm26/mm/proc-funcs.S b/arch/arm26/mm/proc-funcs.S index c3d4cd3..f9fca52 100644 --- a/arch/arm26/mm/proc-funcs.S +++ b/arch/arm26/mm/proc-funcs.S @@ -14,7 +14,7 @@ */ #include #include -#include +#include #include #include diff --git a/arch/arm26/nwfpe/entry.S b/arch/arm26/nwfpe/entry.S index 7d6dfaa..e631200 100644 --- a/arch/arm26/nwfpe/entry.S +++ b/arch/arm26/nwfpe/entry.S @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include +#include /* This is the kernel's entry point into the floating point emulator. It is called from the kernel with code similar to this: diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile index 7b3bbaf..dea48f6 100644 --- a/arch/sparc/Makefile +++ b/arch/sparc/Makefile @@ -59,17 +59,7 @@ image tftpboot.img: vmlinux archclean: $(Q)$(MAKE) $(clean)=$(boot) -prepare: include/asm-$(ARCH)/asm_offsets.h - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/asm_offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - -CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h \ - arch/$(ARCH)/kernel/asm-offsets.s \ - arch/$(ARCH)/boot/System.map +CLEAN_FILES += arch/$(ARCH)/boot/System.map # Don't use tabs in echo arguments. define archhelp diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S index b448166..03ecb4e 100644 --- a/arch/sparc/kernel/entry.S +++ b/arch/sparc/kernel/entry.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/sparc/kernel/sclow.S b/arch/sparc/kernel/sclow.S index 3a867fc..136e37c 100644 --- a/arch/sparc/kernel/sclow.S +++ b/arch/sparc/kernel/sclow.S @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include #include diff --git a/arch/sparc/mm/hypersparc.S b/arch/sparc/mm/hypersparc.S index 54b8e76..a231cca 100644 --- a/arch/sparc/mm/hypersparc.S +++ b/arch/sparc/mm/hypersparc.S @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/sparc/mm/swift.S b/arch/sparc/mm/swift.S index 2dcaa5a..cd90f3f 100644 --- a/arch/sparc/mm/swift.S +++ b/arch/sparc/mm/swift.S @@ -9,7 +9,7 @@ #include #include #include -#include +#include .text .align 4 diff --git a/arch/sparc/mm/tsunami.S b/arch/sparc/mm/tsunami.S index 8acd178..697af61 100644 --- a/arch/sparc/mm/tsunami.S +++ b/arch/sparc/mm/tsunami.S @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/sparc/mm/viking.S b/arch/sparc/mm/viking.S index f58712d..3cbd6de 100644 --- a/arch/sparc/mm/viking.S +++ b/arch/sparc/mm/viking.S @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/asm-sparc/ptrace.h b/include/asm-sparc/ptrace.h index dd9d94d..a8ecb2d 100644 --- a/include/asm-sparc/ptrace.h +++ b/include/asm-sparc/ptrace.h @@ -73,11 +73,11 @@ extern void show_regs(struct pt_regs *); #endif /* - * The asm_offsets.h is a generated file, so we cannot include it. + * The asm-offsets.h is a generated file, so we cannot include it. * It may be OK for glibc headers, but it's utterly pointless for C code. * The assembly code using those offsets has to include it explicitly. */ -/* #include */ +/* #include */ /* These are for pt_regs. */ #define PT_PSR 0x0 -- cgit v0.10.2 From 0013a85454c281faaf064ccb576e373a2881aac8 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 20:57:26 +0200 Subject: kbuild: m68k,parisc,ppc,ppc64,s390,xtensa use generic asm-offsets.h support Delete obsoleted parts form arch makefiles and rename to asm-offsets.h Signed-off-by: Sam Ravnborg diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile index 466e740..34d826d 100644 --- a/arch/m68k/Makefile +++ b/arch/m68k/Makefile @@ -113,14 +113,5 @@ else bzip2 -1c vmlinux >vmlinux.bz2 endif -prepare: include/asm-$(ARCH)/offsets.h -CLEAN_FILES += include/asm-$(ARCH)/offsets.h - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - archclean: rm -f vmlinux.gz vmlinux.bz2 diff --git a/arch/m68k/fpsp040/skeleton.S b/arch/m68k/fpsp040/skeleton.S index dbc1255..9571a21 100644 --- a/arch/m68k/fpsp040/skeleton.S +++ b/arch/m68k/fpsp040/skeleton.S @@ -40,7 +40,7 @@ #include #include -#include +#include |SKELETON idnt 2,1 | Motorola 040 Floating Point Software Package diff --git a/arch/m68k/ifpsp060/iskeleton.S b/arch/m68k/ifpsp060/iskeleton.S index 803a6ec..4ba2c74 100644 --- a/arch/m68k/ifpsp060/iskeleton.S +++ b/arch/m68k/ifpsp060/iskeleton.S @@ -36,7 +36,7 @@ #include #include -#include +#include |################################ diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S index e964015..23ca60a 100644 --- a/arch/m68k/kernel/entry.S +++ b/arch/m68k/kernel/entry.S @@ -42,7 +42,7 @@ #include #include -#include +#include .globl system_call, buserr, trap .globl resume, ret_from_exception diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S index 7cd6de1..d4336d8 100644 --- a/arch/m68k/kernel/head.S +++ b/arch/m68k/kernel/head.S @@ -263,7 +263,7 @@ #include #include #include -#include +#include #ifdef CONFIG_MAC diff --git a/arch/m68k/math-emu/fp_emu.h b/arch/m68k/math-emu/fp_emu.h index 1d6edc9..c1ecfef 100644 --- a/arch/m68k/math-emu/fp_emu.h +++ b/arch/m68k/math-emu/fp_emu.h @@ -39,7 +39,7 @@ #define _FP_EMU_H #ifdef __ASSEMBLY__ -#include +#include #endif #include diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile index 0403d2f..3b339b1 100644 --- a/arch/parisc/Makefile +++ b/arch/parisc/Makefile @@ -100,15 +100,7 @@ kernel_install: vmlinux install: kernel_install modules_install -prepare: include/asm-parisc/offsets.h - -arch/parisc/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-parisc/offsets.h: arch/parisc/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - -CLEAN_FILES += lifimage include/asm-parisc/offsets.h +CLEAN_FILES += lifimage MRPROPER_FILES += palo.conf define archhelp diff --git a/arch/parisc/hpux/gate.S b/arch/parisc/hpux/gate.S index 2680a1c..aaaf330 100644 --- a/arch/parisc/hpux/gate.S +++ b/arch/parisc/hpux/gate.S @@ -9,7 +9,7 @@ */ #include -#include +#include #include #include diff --git a/arch/parisc/hpux/wrappers.S b/arch/parisc/hpux/wrappers.S index 1aa936d..0b0c3a6 100644 --- a/arch/parisc/hpux/wrappers.S +++ b/arch/parisc/hpux/wrappers.S @@ -24,7 +24,7 @@ #warning PA64 support needs more work...did first cut #endif -#include +#include #include #include diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S index ee58d37..be0f07f 100644 --- a/arch/parisc/kernel/entry.S +++ b/arch/parisc/kernel/entry.S @@ -23,7 +23,7 @@ */ #include -#include +#include /* we have the following possibilities to act on an interruption: * - handle in assembly and use shadowed registers only diff --git a/arch/parisc/kernel/head.S b/arch/parisc/kernel/head.S index ddf7e91..28405ed 100644 --- a/arch/parisc/kernel/head.S +++ b/arch/parisc/kernel/head.S @@ -14,7 +14,7 @@ #include /* for CONFIG_SMP */ -#include +#include #include #include diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index 4fc0450..46b7593 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c index c07db9d..f3428e5 100644 --- a/arch/parisc/kernel/ptrace.c +++ b/arch/parisc/kernel/ptrace.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include /* PSW bits we allow the debugger to modify */ #define USER_PSW_BITS (PSW_N | PSW_V | PSW_CB) diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c index 55d71c1..0224651 100644 --- a/arch/parisc/kernel/signal.c +++ b/arch/parisc/kernel/signal.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #ifdef CONFIG_COMPAT #include diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S index 32ea701..8c7a718 100644 --- a/arch/parisc/kernel/syscall.S +++ b/arch/parisc/kernel/syscall.S @@ -7,7 +7,7 @@ * sorry about the wall, puffin.. */ -#include +#include #include #include #include diff --git a/arch/parisc/lib/fixup.S b/arch/parisc/lib/fixup.S index 134f0cd..1b91612 100644 --- a/arch/parisc/lib/fixup.S +++ b/arch/parisc/lib/fixup.S @@ -20,7 +20,7 @@ * Fixup routines for kernel exception handling. */ #include -#include +#include #include #include diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile index d1b6e6d..4b3fe39 100644 --- a/arch/ppc/Makefile +++ b/arch/ppc/Makefile @@ -105,13 +105,7 @@ archclean: $(Q)$(MAKE) $(clean)=arch/ppc/boot $(Q)rm -rf include3 -prepare: include/asm-$(ARCH)/offsets.h checkbin - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) +prepare: checkbin # Temporary hack until we have migrated to asm-powerpc include/asm: include3/asm @@ -143,7 +137,5 @@ checkbin: false ; \ fi -CLEAN_FILES += include/asm-$(ARCH)/offsets.h \ - arch/$(ARCH)/kernel/asm-offsets.s \ - $(TOUT) +CLEAN_FILES += $(TOUT) diff --git a/arch/ppc/kernel/cpu_setup_6xx.S b/arch/ppc/kernel/cpu_setup_6xx.S index bd037ca..1f37b7e 100644 --- a/arch/ppc/kernel/cpu_setup_6xx.S +++ b/arch/ppc/kernel/cpu_setup_6xx.S @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include _GLOBAL(__setup_cpu_601) diff --git a/arch/ppc/kernel/cpu_setup_power4.S b/arch/ppc/kernel/cpu_setup_power4.S index f2ea1a9..304589a 100644 --- a/arch/ppc/kernel/cpu_setup_power4.S +++ b/arch/ppc/kernel/cpu_setup_power4.S @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include _GLOBAL(__970_cpu_preinit) diff --git a/arch/ppc/kernel/entry.S b/arch/ppc/kernel/entry.S index cb83045..03d4886 100644 --- a/arch/ppc/kernel/entry.S +++ b/arch/ppc/kernel/entry.S @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #undef SHOW_SYSCALLS diff --git a/arch/ppc/kernel/fpu.S b/arch/ppc/kernel/fpu.S index 6189b26..665d7d3 100644 --- a/arch/ppc/kernel/fpu.S +++ b/arch/ppc/kernel/fpu.S @@ -18,7 +18,7 @@ #include #include #include -#include +#include /* * This task wants to use the FPU now. diff --git a/arch/ppc/kernel/head.S b/arch/ppc/kernel/head.S index a931d77..55daf12 100644 --- a/arch/ppc/kernel/head.S +++ b/arch/ppc/kernel/head.S @@ -31,7 +31,7 @@ #include #include #include -#include +#include #ifdef CONFIG_APUS #include diff --git a/arch/ppc/kernel/head_44x.S b/arch/ppc/kernel/head_44x.S index 9e68e32..599245b 100644 --- a/arch/ppc/kernel/head_44x.S +++ b/arch/ppc/kernel/head_44x.S @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include "head_booke.h" diff --git a/arch/ppc/kernel/head_4xx.S b/arch/ppc/kernel/head_4xx.S index ca9518b..8562b80 100644 --- a/arch/ppc/kernel/head_4xx.S +++ b/arch/ppc/kernel/head_4xx.S @@ -40,7 +40,7 @@ #include #include #include -#include +#include /* As with the other PowerPC ports, it is expected that when code * execution begins here, the following registers contain valid, yet diff --git a/arch/ppc/kernel/head_8xx.S b/arch/ppc/kernel/head_8xx.S index eb18cad..cb1a3a5 100644 --- a/arch/ppc/kernel/head_8xx.S +++ b/arch/ppc/kernel/head_8xx.S @@ -30,7 +30,7 @@ #include #include #include -#include +#include /* Macro to make the code more readable. */ #ifdef CONFIG_8xx_CPU6 diff --git a/arch/ppc/kernel/head_fsl_booke.S b/arch/ppc/kernel/head_fsl_booke.S index 4028f4c..8e52e84 100644 --- a/arch/ppc/kernel/head_fsl_booke.S +++ b/arch/ppc/kernel/head_fsl_booke.S @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include "head_booke.h" /* As with the other PowerPC ports, it is expected that when code diff --git a/arch/ppc/kernel/idle_6xx.S b/arch/ppc/kernel/idle_6xx.S index 25d009c..1a2194c 100644 --- a/arch/ppc/kernel/idle_6xx.S +++ b/arch/ppc/kernel/idle_6xx.S @@ -20,7 +20,7 @@ #include #include #include -#include +#include #undef DEBUG diff --git a/arch/ppc/kernel/idle_power4.S b/arch/ppc/kernel/idle_power4.S index 73a58ff..cc0d535 100644 --- a/arch/ppc/kernel/idle_power4.S +++ b/arch/ppc/kernel/idle_power4.S @@ -20,7 +20,7 @@ #include #include #include -#include +#include #undef DEBUG diff --git a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S index ce71b4a..90d917d 100644 --- a/arch/ppc/kernel/misc.S +++ b/arch/ppc/kernel/misc.S @@ -23,7 +23,7 @@ #include #include #include -#include +#include .text diff --git a/arch/ppc/kernel/swsusp.S b/arch/ppc/kernel/swsusp.S index 55148bb..69773cc 100644 --- a/arch/ppc/kernel/swsusp.S +++ b/arch/ppc/kernel/swsusp.S @@ -5,7 +5,7 @@ #include #include #include -#include +#include /* diff --git a/arch/ppc/mm/hashtable.S b/arch/ppc/mm/hashtable.S index ab83132..3ec87c9 100644 --- a/arch/ppc/mm/hashtable.S +++ b/arch/ppc/mm/hashtable.S @@ -30,7 +30,7 @@ #include #include #include -#include +#include #ifdef CONFIG_SMP .comm mmu_hash_lock,4 diff --git a/arch/ppc/platforms/pmac_sleep.S b/arch/ppc/platforms/pmac_sleep.S index 016a746..8d67adc 100644 --- a/arch/ppc/platforms/pmac_sleep.S +++ b/arch/ppc/platforms/pmac_sleep.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #define MAGIC 0x4c617273 /* 'Lars' */ diff --git a/arch/ppc64/Makefile b/arch/ppc64/Makefile index 8189953..d795775 100644 --- a/arch/ppc64/Makefile +++ b/arch/ppc64/Makefile @@ -116,13 +116,6 @@ archclean: $(Q)$(MAKE) $(clean)=$(boot) $(Q)rm -rf include3 -prepare: include/asm-ppc64/offsets.h - -arch/ppc64/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-ppc64/offsets.h: arch/ppc64/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) # Temporary hack until we have migrated to asm-powerpc include/asm: include3/asm @@ -136,5 +129,3 @@ define archhelp echo ' sourced from arch/$(ARCH)/boot/ramdisk.image.gz' echo ' (arch/$(ARCH)/boot/zImage.initrd)' endef - -CLEAN_FILES += include/asm-ppc64/offsets.h diff --git a/arch/ppc64/kernel/cpu_setup_power4.S b/arch/ppc64/kernel/cpu_setup_power4.S index 0482c06..bfce609 100644 --- a/arch/ppc64/kernel/cpu_setup_power4.S +++ b/arch/ppc64/kernel/cpu_setup_power4.S @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include _GLOBAL(__970_cpu_preinit) diff --git a/arch/ppc64/kernel/entry.S b/arch/ppc64/kernel/entry.S index bf99b4a..d133a49 100644 --- a/arch/ppc64/kernel/entry.S +++ b/arch/ppc64/kernel/entry.S @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #ifdef CONFIG_PPC_ISERIES diff --git a/arch/ppc64/kernel/head.S b/arch/ppc64/kernel/head.S index b436206..58c3147 100644 --- a/arch/ppc64/kernel/head.S +++ b/arch/ppc64/kernel/head.S @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/ppc64/kernel/idle_power4.S b/arch/ppc64/kernel/idle_power4.S index 97e4a26..ca02afe 100644 --- a/arch/ppc64/kernel/idle_power4.S +++ b/arch/ppc64/kernel/idle_power4.S @@ -20,7 +20,7 @@ #include #include #include -#include +#include #undef DEBUG diff --git a/arch/ppc64/kernel/misc.S b/arch/ppc64/kernel/misc.S index 6d860c1..7579035 100644 --- a/arch/ppc64/kernel/misc.S +++ b/arch/ppc64/kernel/misc.S @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include .text diff --git a/arch/ppc64/kernel/vdso32/cacheflush.S b/arch/ppc64/kernel/vdso32/cacheflush.S index 0ed7ea7..c8db993 100644 --- a/arch/ppc64/kernel/vdso32/cacheflush.S +++ b/arch/ppc64/kernel/vdso32/cacheflush.S @@ -13,7 +13,7 @@ #include #include #include -#include +#include .text diff --git a/arch/ppc64/kernel/vdso32/datapage.S b/arch/ppc64/kernel/vdso32/datapage.S index 29b6bd3..4f4eb0b 100644 --- a/arch/ppc64/kernel/vdso32/datapage.S +++ b/arch/ppc64/kernel/vdso32/datapage.S @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/ppc64/kernel/vdso32/gettimeofday.S b/arch/ppc64/kernel/vdso32/gettimeofday.S index 2b48bf1..07f1c1c 100644 --- a/arch/ppc64/kernel/vdso32/gettimeofday.S +++ b/arch/ppc64/kernel/vdso32/gettimeofday.S @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include .text diff --git a/arch/ppc64/kernel/vdso64/cacheflush.S b/arch/ppc64/kernel/vdso64/cacheflush.S index e0725b7..d4a0ad2 100644 --- a/arch/ppc64/kernel/vdso64/cacheflush.S +++ b/arch/ppc64/kernel/vdso64/cacheflush.S @@ -13,7 +13,7 @@ #include #include #include -#include +#include .text diff --git a/arch/ppc64/kernel/vdso64/datapage.S b/arch/ppc64/kernel/vdso64/datapage.S index 18afd97..ed6e599 100644 --- a/arch/ppc64/kernel/vdso64/datapage.S +++ b/arch/ppc64/kernel/vdso64/datapage.S @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/ppc64/kernel/vdso64/gettimeofday.S b/arch/ppc64/kernel/vdso64/gettimeofday.S index ed3f970..f6df802 100644 --- a/arch/ppc64/kernel/vdso64/gettimeofday.S +++ b/arch/ppc64/kernel/vdso64/gettimeofday.S @@ -14,7 +14,7 @@ #include #include #include -#include +#include .text /* diff --git a/arch/ppc64/mm/hash_low.S b/arch/ppc64/mm/hash_low.S index 35eb49e..ee5a5d3 100644 --- a/arch/ppc64/mm/hash_low.S +++ b/arch/ppc64/mm/hash_low.S @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include .text diff --git a/arch/ppc64/mm/slb_low.S b/arch/ppc64/mm/slb_low.S index 698d6b9..a3a03da 100644 --- a/arch/ppc64/mm/slb_low.S +++ b/arch/ppc64/mm/slb_low.S @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include /* void slb_allocate(unsigned long ea); diff --git a/arch/s390/Makefile b/arch/s390/Makefile index 3cd8dd2..189c8f3 100644 --- a/arch/s390/Makefile +++ b/arch/s390/Makefile @@ -100,16 +100,6 @@ image: vmlinux archclean: $(Q)$(MAKE) $(clean)=$(boot) -prepare: include/asm-$(ARCH)/offsets.h - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - -CLEAN_FILES += include/asm-$(ARCH)/offsets.h - # Don't use tabs in echo arguments define archhelp echo '* image - Kernel image for IPL ($(boot)/image)' diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S index cbe7d6a..58fc7fb 100644 --- a/arch/s390/kernel/entry.S +++ b/arch/s390/kernel/entry.S @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S index fb77b72..d0c9ffa 100644 --- a/arch/s390/kernel/entry64.S +++ b/arch/s390/kernel/entry64.S @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S index 2710e66..55654b6 100644 --- a/arch/s390/kernel/head.S +++ b/arch/s390/kernel/head.S @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S index 9a8263a..c9ff040 100644 --- a/arch/s390/kernel/head64.S +++ b/arch/s390/kernel/head64.S @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/s390/lib/uaccess.S b/arch/s390/lib/uaccess.S index e8029ef..88fc94f 100644 --- a/arch/s390/lib/uaccess.S +++ b/arch/s390/lib/uaccess.S @@ -11,7 +11,7 @@ #include #include -#include +#include .text .align 4 diff --git a/arch/s390/lib/uaccess64.S b/arch/s390/lib/uaccess64.S index 0ca5697..5021978 100644 --- a/arch/s390/lib/uaccess64.S +++ b/arch/s390/lib/uaccess64.S @@ -11,7 +11,7 @@ #include #include -#include +#include .text .align 4 diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile index 27847e4..67ef4cd 100644 --- a/arch/xtensa/Makefile +++ b/arch/xtensa/Makefile @@ -66,13 +66,7 @@ boot := arch/xtensa/boot archinc := include/asm-xtensa -arch/xtensa/kernel/asm-offsets.s: \ - arch/xtensa/kernel/asm-offsets.c $(archinc)/.platform - -include/asm-xtensa/offsets.h: arch/xtensa/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - -prepare: $(archinc)/.platform $(archinc)/offsets.h +prepare: $(archinc)/.platform # Update machine cpu and platform symlinks if something which affects # them changed. @@ -94,7 +88,7 @@ bzImage : zImage zImage zImage.initrd: vmlinux $(Q)$(MAKE) $(build)=$(boot) $@ -CLEAN_FILES += arch/xtensa/vmlinux.lds $(archinc)/offset.h \ +CLEAN_FILES += arch/xtensa/vmlinux.lds \ $(archinc)/platform $(archinc)/xtensa/config \ $(archinc)/.platform diff --git a/arch/xtensa/kernel/align.S b/arch/xtensa/kernel/align.S index 74b1e90..a495657 100644 --- a/arch/xtensa/kernel/align.S +++ b/arch/xtensa/kernel/align.S @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S index c64a01f..5c018c5 100644 --- a/arch/xtensa/kernel/entry.S +++ b/arch/xtensa/kernel/entry.S @@ -14,7 +14,7 @@ */ #include -#include +#include #include #include #include diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c index 4099703..c83bb0d 100644 --- a/arch/xtensa/kernel/process.c +++ b/arch/xtensa/kernel/process.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include extern void ret_from_fork(void); diff --git a/arch/xtensa/kernel/vectors.S b/arch/xtensa/kernel/vectors.S index 81808f0..0e74397 100644 --- a/arch/xtensa/kernel/vectors.S +++ b/arch/xtensa/kernel/vectors.S @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/asm-ia64/ptrace.h b/include/asm-ia64/ptrace.h index 0bef195..c8766de 100644 --- a/include/asm-ia64/ptrace.h +++ b/include/asm-ia64/ptrace.h @@ -57,7 +57,7 @@ #include #include -#include +#include /* * Base-2 logarithm of number of pages to allocate per task structure diff --git a/include/asm-ia64/thread_info.h b/include/asm-ia64/thread_info.h index 7dc8951..b2c79f0 100644 --- a/include/asm-ia64/thread_info.h +++ b/include/asm-ia64/thread_info.h @@ -5,7 +5,7 @@ #ifndef _ASM_IA64_THREAD_INFO_H #define _ASM_IA64_THREAD_INFO_H -#include +#include #include #include diff --git a/include/asm-parisc/assembly.h b/include/asm-parisc/assembly.h index cbc286f..30b0234 100644 --- a/include/asm-parisc/assembly.h +++ b/include/asm-parisc/assembly.h @@ -63,7 +63,7 @@ .level 2.0w #endif -#include +#include #include #include diff --git a/include/asm-xtensa/ptrace.h b/include/asm-xtensa/ptrace.h index 2848a5f..aa4fd7f 100644 --- a/include/asm-xtensa/ptrace.h +++ b/include/asm-xtensa/ptrace.h @@ -127,7 +127,7 @@ extern void show_regs(struct pt_regs *); #else /* __ASSEMBLY__ */ #ifdef __KERNEL__ -# include +# include #define PT_REGS_OFFSET (KERNEL_STACK_SIZE - PT_USER_SIZE) #endif diff --git a/include/asm-xtensa/uaccess.h b/include/asm-xtensa/uaccess.h index fc268ac..06a22b8 100644 --- a/include/asm-xtensa/uaccess.h +++ b/include/asm-xtensa/uaccess.h @@ -25,7 +25,7 @@ #define _ASMLANGUAGE #include -#include +#include #include /* -- cgit v0.10.2 From e6ae744dd2eae8e00af328b11b1fe77cb0931136 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 21:08:59 +0200 Subject: kbuild: arm - use generic asm-offsets.h support Delete obsoleted stuff from arch Makefile and rename constants.h to asm-offsets.h Signed-off-by: Sam Ravnborg diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 67f1453..e625ac6 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -178,7 +178,7 @@ endif prepare: maketools include/asm-arm/.arch .PHONY: maketools FORCE -maketools: include/asm-arm/constants.h include/linux/version.h FORCE +maketools: include/linux/version.h FORCE $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h # Convert bzImage to zImage @@ -190,7 +190,7 @@ zImage Image xipImage bootpImage uImage: vmlinux zinstall install: vmlinux $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@ -CLEAN_FILES += include/asm-arm/constants.h* include/asm-arm/mach-types.h \ +CLEAN_FILES += include/asm-arm/mach-types.h \ include/asm-arm/arch include/asm-arm/.arch # We use MRPROPER_FILES and CLEAN_FILES now @@ -201,11 +201,6 @@ archclean: bp:; $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/bootpImage i zi:; $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@ -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/asm-arm/.arch - -include/asm-$(ARCH)/constants.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) define archhelp echo '* zImage - Compressed kernel image (arch/$(ARCH)/boot/zImage)' diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S index afef212..648cfff 100644 --- a/arch/arm/kernel/entry-header.S +++ b/arch/arm/kernel/entry-header.S @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 1155cf0..5396263 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/arm/kernel/iwmmxt.S b/arch/arm/kernel/iwmmxt.S index 8f74e24..24c7b04 100644 --- a/arch/arm/kernel/iwmmxt.S +++ b/arch/arm/kernel/iwmmxt.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #define MMX_WR0 (0x00) #define MMX_WR1 (0x08) diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S index 4c38abd..6811796 100644 --- a/arch/arm/lib/copy_page.S +++ b/arch/arm/lib/copy_page.S @@ -11,7 +11,7 @@ */ #include #include -#include +#include #define COPY_COUNT (PAGE_SZ/64 PLD( -1 )) diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S index 46a2dc9..333bca2 100644 --- a/arch/arm/lib/csumpartialcopyuser.S +++ b/arch/arm/lib/csumpartialcopyuser.S @@ -13,7 +13,7 @@ #include #include #include -#include +#include .text diff --git a/arch/arm/lib/getuser.S b/arch/arm/lib/getuser.S index 64aa6f4..d204018 100644 --- a/arch/arm/lib/getuser.S +++ b/arch/arm/lib/getuser.S @@ -26,7 +26,7 @@ * Note that ADDR_LIMIT is either 0 or 0xc0000000. * Note also that it is intended that __get_user_bad is not global. */ -#include +#include #include #include diff --git a/arch/arm/lib/putuser.S b/arch/arm/lib/putuser.S index b09398d..4593e9c 100644 --- a/arch/arm/lib/putuser.S +++ b/arch/arm/lib/putuser.S @@ -26,7 +26,7 @@ * Note that ADDR_LIMIT is either 0 or 0xc0000000 * Note also that it is intended that __put_user_bad is not global. */ -#include +#include #include #include diff --git a/arch/arm/mm/copypage-v3.S b/arch/arm/mm/copypage-v3.S index 4940f19..3c58ebb 100644 --- a/arch/arm/mm/copypage-v3.S +++ b/arch/arm/mm/copypage-v3.S @@ -12,7 +12,7 @@ #include #include #include -#include +#include .text .align 5 diff --git a/arch/arm/mm/copypage-v4wb.S b/arch/arm/mm/copypage-v4wb.S index b94c345..8311735 100644 --- a/arch/arm/mm/copypage-v4wb.S +++ b/arch/arm/mm/copypage-v4wb.S @@ -11,7 +11,7 @@ */ #include #include -#include +#include .text .align 5 diff --git a/arch/arm/mm/copypage-v4wt.S b/arch/arm/mm/copypage-v4wt.S index 9767939..e1f2af2 100644 --- a/arch/arm/mm/copypage-v4wt.S +++ b/arch/arm/mm/copypage-v4wt.S @@ -14,7 +14,7 @@ */ #include #include -#include +#include .text .align 5 diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S index 5c0ae52..1d739d2 100644 --- a/arch/arm/mm/proc-arm1020.S +++ b/arch/arm/mm/proc-arm1020.S @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S index d69389c..9b72566 100644 --- a/arch/arm/mm/proc-arm1020e.S +++ b/arch/arm/mm/proc-arm1020e.S @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-arm1022.S b/arch/arm/mm/proc-arm1022.S index 747ed963..37b70fa 100644 --- a/arch/arm/mm/proc-arm1022.S +++ b/arch/arm/mm/proc-arm1022.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-arm1026.S b/arch/arm/mm/proc-arm1026.S index 248110c..931b690 100644 --- a/arch/arm/mm/proc-arm1026.S +++ b/arch/arm/mm/proc-arm1026.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-arm6_7.S b/arch/arm/mm/proc-arm6_7.S index 189ef6a..d0f1bbb 100644 --- a/arch/arm/mm/proc-arm6_7.S +++ b/arch/arm/mm/proc-arm6_7.S @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S index 57cfa6a..c69c9de 100644 --- a/arch/arm/mm/proc-arm720.S +++ b/arch/arm/mm/proc-arm720.S @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S index 9137fe5..7cfc260 100644 --- a/arch/arm/mm/proc-macros.S +++ b/arch/arm/mm/proc-macros.S @@ -4,7 +4,7 @@ * VMA_VM_FLAGS * VM_EXEC */ -#include +#include #include /* diff --git a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S index 360cae9..34f7e7d 100644 --- a/arch/arm/mm/proc-sa110.S +++ b/arch/arm/mm/proc-sa110.S @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S index d447cd5..ca14f80 100644 --- a/arch/arm/mm/proc-sa1100.S +++ b/arch/arm/mm/proc-sa1100.S @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S index 139a386..eb34823 100644 --- a/arch/arm/mm/proc-v6.S +++ b/arch/arm/mm/proc-v6.S @@ -11,7 +11,7 @@ */ #include #include -#include +#include #include #include diff --git a/arch/arm/mm/tlb-v3.S b/arch/arm/mm/tlb-v3.S index 44b0dae..c10786e 100644 --- a/arch/arm/mm/tlb-v3.S +++ b/arch/arm/mm/tlb-v3.S @@ -13,7 +13,7 @@ */ #include #include -#include +#include #include #include "proc-macros.S" diff --git a/arch/arm/mm/tlb-v4.S b/arch/arm/mm/tlb-v4.S index db82ee4..d6c9445 100644 --- a/arch/arm/mm/tlb-v4.S +++ b/arch/arm/mm/tlb-v4.S @@ -14,7 +14,7 @@ */ #include #include -#include +#include #include #include "proc-macros.S" diff --git a/arch/arm/mm/tlb-v4wb.S b/arch/arm/mm/tlb-v4wb.S index 7908d5f..cb829ca 100644 --- a/arch/arm/mm/tlb-v4wb.S +++ b/arch/arm/mm/tlb-v4wb.S @@ -14,7 +14,7 @@ */ #include #include -#include +#include #include #include "proc-macros.S" diff --git a/arch/arm/mm/tlb-v4wbi.S b/arch/arm/mm/tlb-v4wbi.S index efbe94b..60cfc4a 100644 --- a/arch/arm/mm/tlb-v4wbi.S +++ b/arch/arm/mm/tlb-v4wbi.S @@ -14,7 +14,7 @@ */ #include #include -#include +#include #include #include "proc-macros.S" diff --git a/arch/arm/mm/tlb-v6.S b/arch/arm/mm/tlb-v6.S index 99ed26e..6f76b89 100644 --- a/arch/arm/mm/tlb-v6.S +++ b/arch/arm/mm/tlb-v6.S @@ -11,7 +11,7 @@ * These assume a split I/D TLB. */ #include -#include +#include #include #include #include "proc-macros.S" diff --git a/arch/arm/nwfpe/entry26.S b/arch/arm/nwfpe/entry26.S index 0ed38b0..51940a9 100644 --- a/arch/arm/nwfpe/entry26.S +++ b/arch/arm/nwfpe/entry26.S @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include +#include /* This is the kernel's entry point into the floating point emulator. It is called from the kernel with code similar to this: diff --git a/arch/arm/vfp/entry.S b/arch/arm/vfp/entry.S index e73c8de..6f17187 100644 --- a/arch/arm/vfp/entry.S +++ b/arch/arm/vfp/entry.S @@ -17,7 +17,7 @@ */ #include #include -#include +#include #include .globl do_vfp -- cgit v0.10.2 From e2d5df935d8a82cb7a2c50726628fa928aa89b9b Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 21:28:48 +0200 Subject: kbuild: alpha,x86_64 use generic asm-offsets.h support Delete obsolete stuff from arch makefiles Rename .h file to asm-offsets.h Signed-off-by: Sam Ravnborg diff --git a/arch/alpha/Makefile b/arch/alpha/Makefile index 22ebfb2..1b704ee 100644 --- a/arch/alpha/Makefile +++ b/arch/alpha/Makefile @@ -108,20 +108,9 @@ $(boot)/vmlinux.gz: vmlinux bootimage bootpfile bootpzfile: vmlinux $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ - -prepare: include/asm-$(ARCH)/asm_offsets.h - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/asm_offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - archclean: $(Q)$(MAKE) $(clean)=$(boot) -CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h - define archhelp echo '* boot - Compressed kernel image (arch/alpha/boot/vmlinux.gz)' echo ' bootimage - SRM bootable image (arch/alpha/boot/bootimage)' diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S index f0927ee..76cc0cb 100644 --- a/arch/alpha/kernel/entry.S +++ b/arch/alpha/kernel/entry.S @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include diff --git a/arch/alpha/kernel/head.S b/arch/alpha/kernel/head.S index 4ca2e40..0905721 100644 --- a/arch/alpha/kernel/head.S +++ b/arch/alpha/kernel/head.S @@ -9,7 +9,7 @@ #include #include -#include +#include .globl swapper_pg_dir .globl _stext diff --git a/arch/alpha/lib/dbg_stackcheck.S b/arch/alpha/lib/dbg_stackcheck.S index cc5ce3a..3c1f3e6 100644 --- a/arch/alpha/lib/dbg_stackcheck.S +++ b/arch/alpha/lib/dbg_stackcheck.S @@ -5,7 +5,7 @@ * Verify that we have not overflowed the stack. Oops if we have. */ -#include +#include .text .set noat diff --git a/arch/alpha/lib/dbg_stackkill.S b/arch/alpha/lib/dbg_stackkill.S index e09f2ae..e9f6a9d 100644 --- a/arch/alpha/lib/dbg_stackkill.S +++ b/arch/alpha/lib/dbg_stackkill.S @@ -6,7 +6,7 @@ * uninitialized local variables in the act. */ -#include +#include .text .set noat diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile index 4c6ed96..a9cd42e 100644 --- a/arch/x86_64/Makefile +++ b/arch/x86_64/Makefile @@ -86,16 +86,6 @@ install fdimage fdimage144 fdimage288: vmlinux archclean: $(Q)$(MAKE) $(clean)=$(boot) -prepare: include/asm-$(ARCH)/offset.h - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/offset.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - -CLEAN_FILES += include/asm-$(ARCH)/offset.h - define archhelp echo '* bzImage - Compressed kernel image (arch/$(ARCH)/boot/bzImage)' echo ' install - Install kernel using' diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S index f174083..5244f80 100644 --- a/arch/x86_64/ia32/ia32entry.S +++ b/arch/x86_64/ia32/ia32entry.S @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/x86_64/ia32/vsyscall-syscall.S b/arch/x86_64/ia32/vsyscall-syscall.S index e2aaf3d..b024965b 100644 --- a/arch/x86_64/ia32/vsyscall-syscall.S +++ b/arch/x86_64/ia32/vsyscall-syscall.S @@ -3,7 +3,7 @@ */ #include -#include +#include #include .text diff --git a/arch/x86_64/ia32/vsyscall-sysenter.S b/arch/x86_64/ia32/vsyscall-sysenter.S index 8fb8e0f..71f3de5 100644 --- a/arch/x86_64/ia32/vsyscall-sysenter.S +++ b/arch/x86_64/ia32/vsyscall-sysenter.S @@ -3,7 +3,7 @@ */ #include -#include +#include .text .section .text.vsyscall,"ax" diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S index be51dbe..3620508 100644 --- a/arch/x86_64/kernel/entry.S +++ b/arch/x86_64/kernel/entry.S @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/x86_64/kernel/suspend_asm.S b/arch/x86_64/kernel/suspend_asm.S index 53f8e16..4d659e9 100644 --- a/arch/x86_64/kernel/suspend_asm.S +++ b/arch/x86_64/kernel/suspend_asm.S @@ -14,7 +14,7 @@ #include #include #include -#include +#include ENTRY(swsusp_arch_suspend) diff --git a/arch/x86_64/lib/copy_user.S b/arch/x86_64/lib/copy_user.S index bd556c8..dfa358b 100644 --- a/arch/x86_64/lib/copy_user.S +++ b/arch/x86_64/lib/copy_user.S @@ -7,7 +7,7 @@ #define FIX_ALIGNMENT 1 #include - #include + #include #include #include diff --git a/arch/x86_64/lib/getuser.S b/arch/x86_64/lib/getuser.S index f80bafe..3844d5e 100644 --- a/arch/x86_64/lib/getuser.S +++ b/arch/x86_64/lib/getuser.S @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include .text diff --git a/arch/x86_64/lib/putuser.S b/arch/x86_64/lib/putuser.S index 5828b81..7f55939 100644 --- a/arch/x86_64/lib/putuser.S +++ b/arch/x86_64/lib/putuser.S @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include .text diff --git a/include/asm-x86_64/current.h b/include/asm-x86_64/current.h index 7db560e..bc8adec 100644 --- a/include/asm-x86_64/current.h +++ b/include/asm-x86_64/current.h @@ -17,7 +17,7 @@ static inline struct task_struct *get_current(void) #else #ifndef ASM_OFFSET_H -#include +#include #endif #define GET_CURRENT(reg) movq %gs:(pda_pcurrent),reg -- cgit v0.10.2 From fb61a8615fce15f30b1bb1cf265ed05e251b9ed8 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 21:39:46 +0200 Subject: kbuild: v850 use generic asm-offsets.h support Deleted obsolete stuff from arch makefile Renamed .c file to asm-offsets.h Fix include of asm-offsets.h to use new name Signed-off-by: Sam Ravnborg diff --git a/arch/v850/Makefile b/arch/v850/Makefile index bf38ca0..8be9aac 100644 --- a/arch/v850/Makefile +++ b/arch/v850/Makefile @@ -51,16 +51,4 @@ root_fs_image_force: $(ROOT_FS_IMAGE) $(OBJCOPY) $(OBJCOPY_FLAGS_BLOB) --rename-section .data=.root,alloc,load,readonly,data,contents $< root_fs_image.o endif - -prepare: include/asm-$(ARCH)/asm-consts.h - -# Generate constants from C code for use by asm files -arch/$(ARCH)/kernel/asm-consts.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/asm-consts.h: arch/$(ARCH)/kernel/asm-consts.s - $(call filechk,gen-asm-offsets) - -CLEAN_FILES += include/asm-$(ARCH)/asm-consts.h \ - arch/$(ARCH)/kernel/asm-consts.s \ - root_fs_image.o +CLEAN_FILES += root_fs_image.o diff --git a/arch/v850/kernel/asm-consts.c b/arch/v850/kernel/asm-consts.c deleted file mode 100644 index 24f2913..0000000 --- a/arch/v850/kernel/asm-consts.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This program is used to generate definitions needed by - * assembly language modules. - * - * We use the technique used in the OSF Mach kernel code: - * generate asm statements containing #defines, - * compile this file to assembler, and then extract the - * #defines from the assembly-language output. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define DEFINE(sym, val) \ - asm volatile("\n->" #sym " %0 " #val : : "i" (val)) - -#define BLANK() asm volatile("\n->" : : ) - -int main (void) -{ - /* offsets into the task struct */ - DEFINE (TASK_STATE, offsetof (struct task_struct, state)); - DEFINE (TASK_FLAGS, offsetof (struct task_struct, flags)); - DEFINE (TASK_PTRACE, offsetof (struct task_struct, ptrace)); - DEFINE (TASK_BLOCKED, offsetof (struct task_struct, blocked)); - DEFINE (TASK_THREAD, offsetof (struct task_struct, thread)); - DEFINE (TASK_THREAD_INFO, offsetof (struct task_struct, thread_info)); - DEFINE (TASK_MM, offsetof (struct task_struct, mm)); - DEFINE (TASK_ACTIVE_MM, offsetof (struct task_struct, active_mm)); - DEFINE (TASK_PID, offsetof (struct task_struct, pid)); - - /* offsets into the kernel_stat struct */ - DEFINE (STAT_IRQ, offsetof (struct kernel_stat, irqs)); - - - /* signal defines */ - DEFINE (SIGSEGV, SIGSEGV); - DEFINE (SEGV_MAPERR, SEGV_MAPERR); - DEFINE (SIGTRAP, SIGTRAP); - DEFINE (SIGCHLD, SIGCHLD); - DEFINE (SIGILL, SIGILL); - DEFINE (TRAP_TRACE, TRAP_TRACE); - - /* ptrace flag bits */ - DEFINE (PT_PTRACED, PT_PTRACED); - DEFINE (PT_DTRACE, PT_DTRACE); - - /* error values */ - DEFINE (ENOSYS, ENOSYS); - - /* clone flag bits */ - DEFINE (CLONE_VFORK, CLONE_VFORK); - DEFINE (CLONE_VM, CLONE_VM); - - return 0; -} diff --git a/arch/v850/kernel/asm-offsets.c b/arch/v850/kernel/asm-offsets.c new file mode 100644 index 0000000..24f2913 --- /dev/null +++ b/arch/v850/kernel/asm-offsets.c @@ -0,0 +1,61 @@ +/* + * This program is used to generate definitions needed by + * assembly language modules. + * + * We use the technique used in the OSF Mach kernel code: + * generate asm statements containing #defines, + * compile this file to assembler, and then extract the + * #defines from the assembly-language output. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + +int main (void) +{ + /* offsets into the task struct */ + DEFINE (TASK_STATE, offsetof (struct task_struct, state)); + DEFINE (TASK_FLAGS, offsetof (struct task_struct, flags)); + DEFINE (TASK_PTRACE, offsetof (struct task_struct, ptrace)); + DEFINE (TASK_BLOCKED, offsetof (struct task_struct, blocked)); + DEFINE (TASK_THREAD, offsetof (struct task_struct, thread)); + DEFINE (TASK_THREAD_INFO, offsetof (struct task_struct, thread_info)); + DEFINE (TASK_MM, offsetof (struct task_struct, mm)); + DEFINE (TASK_ACTIVE_MM, offsetof (struct task_struct, active_mm)); + DEFINE (TASK_PID, offsetof (struct task_struct, pid)); + + /* offsets into the kernel_stat struct */ + DEFINE (STAT_IRQ, offsetof (struct kernel_stat, irqs)); + + + /* signal defines */ + DEFINE (SIGSEGV, SIGSEGV); + DEFINE (SEGV_MAPERR, SEGV_MAPERR); + DEFINE (SIGTRAP, SIGTRAP); + DEFINE (SIGCHLD, SIGCHLD); + DEFINE (SIGILL, SIGILL); + DEFINE (TRAP_TRACE, TRAP_TRACE); + + /* ptrace flag bits */ + DEFINE (PT_PTRACED, PT_PTRACED); + DEFINE (PT_DTRACE, PT_DTRACE); + + /* error values */ + DEFINE (ENOSYS, ENOSYS); + + /* clone flag bits */ + DEFINE (CLONE_VFORK, CLONE_VFORK); + DEFINE (CLONE_VM, CLONE_VM); + + return 0; +} diff --git a/arch/v850/kernel/entry.S b/arch/v850/kernel/entry.S index 895e27b..d991e45 100644 --- a/arch/v850/kernel/entry.S +++ b/arch/v850/kernel/entry.S @@ -22,7 +22,7 @@ #include #include -#include +#include /* Make a slightly more convenient alias for C_SYMBOL_NAME. */ -- cgit v0.10.2 From 39e01cb874cbf694bd0b0c44f54c4f270e2aa556 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 22:03:13 +0200 Subject: kbuild: ia64 use generic asm-offsets.h support Delete obsolete stuff from arch Makefile Rename file to asm-offsets.h The trick used in the arch Makefile to circumvent the circular dependency is kept. Signed-off-by: Sam Ravnborg diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile index f9bd88a..7ed678c 100644 --- a/arch/ia64/Makefile +++ b/arch/ia64/Makefile @@ -82,25 +82,18 @@ unwcheck: vmlinux archclean: $(Q)$(MAKE) $(clean)=$(boot) -CLEAN_FILES += include/asm-ia64/.offsets.h.stamp vmlinux.gz bootloader - -MRPROPER_FILES += include/asm-ia64/offsets.h - -prepare: include/asm-ia64/offsets.h - -arch/ia64/kernel/asm-offsets.s: include/asm include/linux/version.h include/config/MARKER - -include/asm-ia64/offsets.h: arch/ia64/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - -arch/ia64/kernel/asm-offsets.s: include/asm-ia64/.offsets.h.stamp +prepare: include/asm-ia64/.offsets.h.stamp include/asm-ia64/.offsets.h.stamp: mkdir -p include/asm-ia64 - [ -s include/asm-ia64/offsets.h ] \ - || echo "#define IA64_TASK_SIZE 0" > include/asm-ia64/offsets.h + [ -s include/asm-ia64/asm-offsets.h ] \ + || echo "#define IA64_TASK_SIZE 0" > include/asm-ia64/asm-offsets.h touch $@ + + +CLEAN_FILES += vmlinux.gz bootloader include/asm-ia64/.offsets.h.stamp + boot: lib/lib.a vmlinux $(Q)$(MAKE) $(build)=$(boot) $@ diff --git a/arch/ia64/ia32/ia32_entry.S b/arch/ia64/ia32/ia32_entry.S index 0708edb..494fad6 100644 --- a/arch/ia64/ia32/ia32_entry.S +++ b/arch/ia64/ia32/ia32_entry.S @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S index 9be53e1..6d70fec 100644 --- a/arch/ia64/kernel/entry.S +++ b/arch/ia64/kernel/entry.S @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S index 7d7684a..2ddbac6 100644 --- a/arch/ia64/kernel/fsys.S +++ b/arch/ia64/kernel/fsys.S @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/ia64/kernel/gate.S b/arch/ia64/kernel/gate.S index 86948ce..86064ca 100644 --- a/arch/ia64/kernel/gate.S +++ b/arch/ia64/kernel/gate.S @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S index 8d3a929..bfe65b2 100644 --- a/arch/ia64/kernel/head.S +++ b/arch/ia64/kernel/head.S @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/ia64/kernel/ivt.S b/arch/ia64/kernel/ivt.S index 3bb3a13..3ba8384 100644 --- a/arch/ia64/kernel/ivt.S +++ b/arch/ia64/kernel/ivt.S @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include -- cgit v0.10.2 From 048eb582f3f89737d4a29668de9935e6feea7c36 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 22:32:31 +0200 Subject: kbuild: mips use generic asm-offsets.h support Removed obsolete stuff from arch makefile. mips had a special rule for generating asm-offsets.h so preserved it using an architecture specific hook in top-level Kbuild file. Renamed .h file to asm-offsets.h Signed-off-by: Sam Ravnborg diff --git a/Kbuild b/Kbuild index 197ece8..1880e6f 100644 --- a/Kbuild +++ b/Kbuild @@ -13,6 +13,13 @@ always := $(offsets-file) targets := $(offsets-file) targets += arch/$(ARCH)/kernel/asm-offsets.s +# Default sed regexp - multiline due to syntax constraints +define sed-y + "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}" +endef +# Override default regexp for specific architectures +sed-$(CONFIG_MIPS) := "/^@@@/s///p" + quiet_cmd_offsets = GEN $@ define cmd_offsets cat $< | \ @@ -26,7 +33,7 @@ define cmd_offsets echo " *"; \ echo " */"; \ echo ""; \ - sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ + sed -ne $(sed-y); \ echo ""; \ echo "#endif" ) > $@ endef diff --git a/arch/mips/Makefile b/arch/mips/Makefile index b0fdaee..346e803 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -720,38 +720,7 @@ archclean: @$(MAKE) $(clean)=arch/mips/boot @$(MAKE) $(clean)=arch/mips/lasat -# Generate #include #include -#include +#include #include #define EX(a,b) \ diff --git a/arch/mips/kernel/r2300_switch.S b/arch/mips/kernel/r2300_switch.S index f100196..0d9c4a3 100644 --- a/arch/mips/kernel/r2300_switch.S +++ b/arch/mips/kernel/r2300_switch.S @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/mips/kernel/r4k_fpu.S b/arch/mips/kernel/r4k_fpu.S index aba665b..1a14c6b 100644 --- a/arch/mips/kernel/r4k_fpu.S +++ b/arch/mips/kernel/r4k_fpu.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include .macro EX insn, reg, src diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S index e02b772..d2afbd1 100644 --- a/arch/mips/kernel/r4k_switch.S +++ b/arch/mips/kernel/r4k_switch.S @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/mips/kernel/r6000_fpu.S b/arch/mips/kernel/r6000_fpu.S index d8d3b13..43cda53 100644 --- a/arch/mips/kernel/r6000_fpu.S +++ b/arch/mips/kernel/r6000_fpu.S @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include .set noreorder diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S index 344f2e2..17b5030 100644 --- a/arch/mips/kernel/scall32-o32.S +++ b/arch/mips/kernel/scall32-o32.S @@ -19,7 +19,7 @@ #include #include #include -#include +#include /* Highest syscall used of any syscall flavour */ #define MAX_SYSCALL_NO __NR_O32_Linux + __NR_O32_Linux_syscalls diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S index 32efb88..ffb22a2 100644 --- a/arch/mips/kernel/scall64-64.S +++ b/arch/mips/kernel/scall64-64.S @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c index ae2a131..21e3e13 100644 --- a/arch/mips/kernel/syscall.c +++ b/arch/mips/kernel/syscall.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/mips/lib-32/memset.S b/arch/mips/lib-32/memset.S index ad9ff40..1981485 100644 --- a/arch/mips/lib-32/memset.S +++ b/arch/mips/lib-32/memset.S @@ -7,7 +7,7 @@ * Copyright (C) 1999, 2000 Silicon Graphics, Inc. */ #include -#include +#include #include #define EX(insn,reg,addr,handler) \ diff --git a/arch/mips/lib-64/memset.S b/arch/mips/lib-64/memset.S index 242f197..e2c42c8 100644 --- a/arch/mips/lib-64/memset.S +++ b/arch/mips/lib-64/memset.S @@ -7,7 +7,7 @@ * Copyright (C) 1999, 2000 Silicon Graphics, Inc. */ #include -#include +#include #include #define EX(insn,reg,addr,handler) \ diff --git a/arch/mips/lib/memcpy.S b/arch/mips/lib/memcpy.S index 90ee8d4..a78865f 100644 --- a/arch/mips/lib/memcpy.S +++ b/arch/mips/lib/memcpy.S @@ -14,7 +14,7 @@ */ #include #include -#include +#include #include #define dst a0 diff --git a/arch/mips/lib/strlen_user.S b/arch/mips/lib/strlen_user.S index 07660e8..eca558d 100644 --- a/arch/mips/lib/strlen_user.S +++ b/arch/mips/lib/strlen_user.S @@ -7,7 +7,7 @@ * Copyright (c) 1999 Silicon Graphics, Inc. */ #include -#include +#include #include #define EX(insn,reg,addr,handler) \ diff --git a/arch/mips/lib/strncpy_user.S b/arch/mips/lib/strncpy_user.S index 14bed17..d16c76f 100644 --- a/arch/mips/lib/strncpy_user.S +++ b/arch/mips/lib/strncpy_user.S @@ -7,7 +7,7 @@ */ #include #include -#include +#include #include #define EX(insn,reg,addr,handler) \ diff --git a/arch/mips/lib/strnlen_user.S b/arch/mips/lib/strnlen_user.S index 6e7a8ee..c0ea151 100644 --- a/arch/mips/lib/strnlen_user.S +++ b/arch/mips/lib/strnlen_user.S @@ -7,7 +7,7 @@ * Copyright (c) 1999 Silicon Graphics, Inc. */ #include -#include +#include #include #define EX(insn,reg,addr,handler) \ diff --git a/include/asm-mips/asmmacro-32.h b/include/asm-mips/asmmacro-32.h index ac8823d..11daf5c 100644 --- a/include/asm-mips/asmmacro-32.h +++ b/include/asm-mips/asmmacro-32.h @@ -7,7 +7,7 @@ #ifndef _ASM_ASMMACRO_32_H #define _ASM_ASMMACRO_32_H -#include +#include #include #include #include diff --git a/include/asm-mips/asmmacro-64.h b/include/asm-mips/asmmacro-64.h index bbed355..559c355 100644 --- a/include/asm-mips/asmmacro-64.h +++ b/include/asm-mips/asmmacro-64.h @@ -8,7 +8,7 @@ #ifndef _ASM_ASMMACRO_64_H #define _ASM_ASMMACRO_64_H -#include +#include #include #include #include diff --git a/include/asm-mips/sim.h b/include/asm-mips/sim.h index 3ccfe09..9c2af1b 100644 --- a/include/asm-mips/sim.h +++ b/include/asm-mips/sim.h @@ -11,7 +11,7 @@ #include -#include +#include #define __str2(x) #x #define __str(x) __str2(x) diff --git a/include/asm-mips/stackframe.h b/include/asm-mips/stackframe.h index fb42f99..7b5e646 100644 --- a/include/asm-mips/stackframe.h +++ b/include/asm-mips/stackframe.h @@ -15,7 +15,7 @@ #include #include -#include +#include .macro SAVE_AT .set push -- cgit v0.10.2 From cb7b593c2c808b32a1ea188599713c434b95f849 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Sep 2005 13:35:42 -0700 Subject: [IPV4] fib_trie: fix proc interface Create one iterator for walking over FIB trie, and use it for all the /proc functions. Add a /proc/net/route output for backwards compatibility with old applications. Make initialization of fib_trie same as fib_hash so no #ifdef is needed in af_inet.c Fixes: http://bugzilla.kernel.org/show_bug.cgi?id=5209 Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index bf147f8..a9d84f9 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1248,11 +1248,6 @@ module_init(inet_init); /* ------------------------------------------------------------------------ */ #ifdef CONFIG_PROC_FS -#ifdef CONFIG_IP_FIB_TRIE -extern int fib_stat_proc_init(void); -extern void fib_stat_proc_exit(void); -#endif - static int __init ipv4_proc_init(void) { int rc = 0; @@ -1265,19 +1260,11 @@ static int __init ipv4_proc_init(void) goto out_udp; if (fib_proc_init()) goto out_fib; -#ifdef CONFIG_IP_FIB_TRIE - if (fib_stat_proc_init()) - goto out_fib_stat; -#endif if (ip_misc_proc_init()) goto out_misc; out: return rc; out_misc: -#ifdef CONFIG_IP_FIB_TRIE - fib_stat_proc_exit(); -out_fib_stat: -#endif fib_proc_exit(); out_fib: udp4_proc_exit(); diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index b2dea4e..1b63b48 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -43,7 +43,7 @@ * 2 of the License, or (at your option) any later version. */ -#define VERSION "0.402" +#define VERSION "0.403" #include #include @@ -164,7 +164,6 @@ static struct node *resize(struct trie *t, struct tnode *tn); static struct tnode *inflate(struct trie *t, struct tnode *tn); static struct tnode *halve(struct trie *t, struct tnode *tn); static void tnode_free(struct tnode *tn); -static void trie_dump_seq(struct seq_file *seq, struct trie *t); static kmem_cache_t *fn_alias_kmem __read_mostly; static struct trie *trie_local = NULL, *trie_main = NULL; @@ -1971,558 +1970,525 @@ struct fib_table * __init fib_hash_init(int id) return tb; } -/* Trie dump functions */ +#ifdef CONFIG_PROC_FS +/* Depth first Trie walk iterator */ +struct fib_trie_iter { + struct tnode *tnode; + struct trie *trie; + unsigned index; + unsigned depth; +}; -static void putspace_seq(struct seq_file *seq, int n) +static struct node *fib_trie_get_next(struct fib_trie_iter *iter) { - while (n--) - seq_printf(seq, " "); -} + struct tnode *tn = iter->tnode; + unsigned cindex = iter->index; + struct tnode *p; -static void printbin_seq(struct seq_file *seq, unsigned int v, int bits) -{ - while (bits--) - seq_printf(seq, "%s", (v & (1<tnode, iter->index, iter->depth); +rescan: + while (cindex < (1<bits)) { + struct node *n = tnode_get_child(tn, cindex); -static void printnode_seq(struct seq_file *seq, int indent, struct node *n, - int pend, int cindex, int bits) -{ - putspace_seq(seq, indent); - if (IS_LEAF(n)) - seq_printf(seq, "|"); - else - seq_printf(seq, "+"); - if (bits) { - seq_printf(seq, "%d/", cindex); - printbin_seq(seq, cindex, bits); - seq_printf(seq, ": "); - } else - seq_printf(seq, ": "); - seq_printf(seq, "%s:%p ", IS_LEAF(n)?"Leaf":"Internal node", n); + if (n) { + if (IS_LEAF(n)) { + iter->tnode = tn; + iter->index = cindex + 1; + } else { + /* push down one level */ + iter->tnode = (struct tnode *) n; + iter->index = 0; + ++iter->depth; + } + return n; + } - if (IS_LEAF(n)) { - struct leaf *l = (struct leaf *)n; - struct fib_alias *fa; - int i; + ++cindex; + } - seq_printf(seq, "key=%d.%d.%d.%d\n", - n->key >> 24, (n->key >> 16) % 256, (n->key >> 8) % 256, n->key % 256); - - for (i = 32; i >= 0; i--) - if (find_leaf_info(&l->list, i)) { - struct list_head *fa_head = get_fa_head(l, i); - - if (!fa_head) - continue; - - if (list_empty(fa_head)) - continue; - - putspace_seq(seq, indent+2); - seq_printf(seq, "{/%d...dumping}\n", i); - - list_for_each_entry_rcu(fa, fa_head, fa_list) { - putspace_seq(seq, indent+2); - if (fa->fa_info == NULL) { - seq_printf(seq, "Error fa_info=NULL\n"); - continue; - } - if (fa->fa_info->fib_nh == NULL) { - seq_printf(seq, "Error _fib_nh=NULL\n"); - continue; - } - - seq_printf(seq, "{type=%d scope=%d TOS=%d}\n", - fa->fa_type, - fa->fa_scope, - fa->fa_tos); - } - } - } else { - struct tnode *tn = (struct tnode *)n; - int plen = ((struct tnode *)n)->pos; - t_key prf = MASK_PFX(n->key, plen); - - seq_printf(seq, "key=%d.%d.%d.%d/%d\n", - prf >> 24, (prf >> 16) % 256, (prf >> 8) % 256, prf % 256, plen); - - putspace_seq(seq, indent); seq_printf(seq, "| "); - seq_printf(seq, "{key prefix=%08x/", tn->key & TKEY_GET_MASK(0, tn->pos)); - printbin_seq(seq, tkey_extract_bits(tn->key, 0, tn->pos), tn->pos); - seq_printf(seq, "}\n"); - putspace_seq(seq, indent); seq_printf(seq, "| "); - seq_printf(seq, "{pos=%d", tn->pos); - seq_printf(seq, " (skip=%d bits)", tn->pos - pend); - seq_printf(seq, " bits=%d (%u children)}\n", tn->bits, (1 << tn->bits)); - putspace_seq(seq, indent); seq_printf(seq, "| "); - seq_printf(seq, "{empty=%d full=%d}\n", tn->empty_children, tn->full_children); + /* Current node exhausted, pop back up */ + p = NODE_PARENT(tn); + if (p) { + cindex = tkey_extract_bits(tn->key, p->pos, p->bits)+1; + tn = p; + --iter->depth; + goto rescan; } + + /* got root? */ + return NULL; } -static void trie_dump_seq(struct seq_file *seq, struct trie *t) +static struct node *fib_trie_get_first(struct fib_trie_iter *iter, + struct trie *t) { - struct node *n; - int cindex = 0; - int indent = 1; - int pend = 0; - int depth = 0; - struct tnode *tn; - - rcu_read_lock(); - n = rcu_dereference(t->trie); - seq_printf(seq, "------ trie_dump of t=%p ------\n", t); + struct node *n = rcu_dereference(t->trie); - if (!n) { - seq_printf(seq, "------ trie is empty\n"); - - rcu_read_unlock(); - return; + if (n && IS_TNODE(n)) { + iter->tnode = (struct tnode *) n; + iter->trie = t; + iter->index = 0; + iter->depth = 0; + return n; } + return NULL; +} - printnode_seq(seq, indent, n, pend, cindex, 0); - - if (!IS_TNODE(n)) { - rcu_read_unlock(); - return; - } - - tn = (struct tnode *)n; - pend = tn->pos+tn->bits; - putspace_seq(seq, indent); seq_printf(seq, "\\--\n"); - indent += 3; - depth++; - - while (tn && cindex < (1 << tn->bits)) { - struct node *child = rcu_dereference(tn->child[cindex]); - if (!child) - cindex++; - else { - /* Got a child */ - printnode_seq(seq, indent, child, pend, - cindex, tn->bits); - - if (IS_LEAF(child)) - cindex++; - - else { - /* - * New tnode. Decend one level - */ - - depth++; - n = child; - tn = (struct tnode *)n; - pend = tn->pos+tn->bits; - putspace_seq(seq, indent); - seq_printf(seq, "\\--\n"); - indent += 3; - cindex = 0; - } - } - - /* - * Test if we are done - */ - - while (cindex >= (1 << tn->bits)) { - /* - * Move upwards and test for root - * pop off all traversed nodes - */ +static void trie_collect_stats(struct trie *t, struct trie_stat *s) +{ + struct node *n; + struct fib_trie_iter iter; - if (NODE_PARENT(tn) == NULL) { - tn = NULL; - break; - } + memset(s, 0, sizeof(*s)); - cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); - cindex++; - tn = NODE_PARENT(tn); - pend = tn->pos + tn->bits; - indent -= 3; - depth--; + rcu_read_lock(); + for (n = fib_trie_get_first(&iter, t); n; + n = fib_trie_get_next(&iter)) { + if (IS_LEAF(n)) { + s->leaves++; + s->totdepth += iter.depth; + if (iter.depth > s->maxdepth) + s->maxdepth = iter.depth; + } else { + const struct tnode *tn = (const struct tnode *) n; + int i; + + s->tnodes++; + s->nodesizes[tn->bits]++; + for (i = 0; i < (1<bits); i++) + if (!tn->child[i]) + s->nullpointers++; } } rcu_read_unlock(); } -static struct trie_stat *trie_stat_new(void) +/* + * This outputs /proc/net/fib_triestats + */ +static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat) { - struct trie_stat *s; - int i; + unsigned i, max, pointers, bytes, avdepth; - s = kmalloc(sizeof(struct trie_stat), GFP_KERNEL); - if (!s) - return NULL; + if (stat->leaves) + avdepth = stat->totdepth*100 / stat->leaves; + else + avdepth = 0; - s->totdepth = 0; - s->maxdepth = 0; - s->tnodes = 0; - s->leaves = 0; - s->nullpointers = 0; + seq_printf(seq, "\tAver depth: %d.%02d\n", avdepth / 100, avdepth % 100 ); + seq_printf(seq, "\tMax depth: %u\n", stat->maxdepth); - for (i = 0; i < MAX_CHILDS; i++) - s->nodesizes[i] = 0; + seq_printf(seq, "\tLeaves: %u\n", stat->leaves); - return s; -} + bytes = sizeof(struct leaf) * stat->leaves; + seq_printf(seq, "\tInternal nodes: %d\n\t", stat->tnodes); + bytes += sizeof(struct tnode) * stat->tnodes; -static struct trie_stat *trie_collect_stats(struct trie *t) -{ - struct node *n; - struct trie_stat *s = trie_stat_new(); - int cindex = 0; - int pend = 0; - int depth = 0; + max = MAX_CHILDS-1; + while (max >= 0 && stat->nodesizes[max] == 0) + max--; - if (!s) - return NULL; + pointers = 0; + for (i = 1; i <= max; i++) + if (stat->nodesizes[i] != 0) { + seq_printf(seq, " %d: %d", i, stat->nodesizes[i]); + pointers += (1<nodesizes[i]; + } + seq_putc(seq, '\n'); + seq_printf(seq, "\tPointers: %d\n", pointers); - rcu_read_lock(); - n = rcu_dereference(t->trie); + bytes += sizeof(struct node *) * pointers; + seq_printf(seq, "Null ptrs: %d\n", stat->nullpointers); + seq_printf(seq, "Total size: %d kB\n", (bytes + 1023) / 1024); - if (!n) - return s; +#ifdef CONFIG_IP_FIB_TRIE_STATS + seq_printf(seq, "Counters:\n---------\n"); + seq_printf(seq,"gets = %d\n", t->stats.gets); + seq_printf(seq,"backtracks = %d\n", t->stats.backtrack); + seq_printf(seq,"semantic match passed = %d\n", t->stats.semantic_match_passed); + seq_printf(seq,"semantic match miss = %d\n", t->stats.semantic_match_miss); + seq_printf(seq,"null node hit= %d\n", t->stats.null_node_hit); + seq_printf(seq,"skipped node resize = %d\n", t->stats.resize_node_skipped); +#ifdef CLEAR_STATS + memset(&(t->stats), 0, sizeof(t->stats)); +#endif +#endif /* CONFIG_IP_FIB_TRIE_STATS */ +} - if (IS_TNODE(n)) { - struct tnode *tn = (struct tnode *)n; - pend = tn->pos+tn->bits; - s->nodesizes[tn->bits]++; - depth++; - - while (tn && cindex < (1 << tn->bits)) { - struct node *ch = rcu_dereference(tn->child[cindex]); - if (ch) { - - /* Got a child */ - - if (IS_LEAF(tn->child[cindex])) { - cindex++; - - /* stats */ - if (depth > s->maxdepth) - s->maxdepth = depth; - s->totdepth += depth; - s->leaves++; - } else { - /* - * New tnode. Decend one level - */ - - s->tnodes++; - s->nodesizes[tn->bits]++; - depth++; - - n = ch; - tn = (struct tnode *)n; - pend = tn->pos+tn->bits; - - cindex = 0; - } - } else { - cindex++; - s->nullpointers++; - } +static int fib_triestat_seq_show(struct seq_file *seq, void *v) +{ + struct trie_stat *stat; - /* - * Test if we are done - */ + stat = kmalloc(sizeof(*stat), GFP_KERNEL); + if (!stat) + return -ENOMEM; - while (cindex >= (1 << tn->bits)) { - /* - * Move upwards and test for root - * pop off all traversed nodes - */ + seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n", + sizeof(struct leaf), sizeof(struct tnode)); - if (NODE_PARENT(tn) == NULL) { - tn = NULL; - n = NULL; - break; - } + if (trie_local) { + seq_printf(seq, "Local:\n"); + trie_collect_stats(trie_local, stat); + trie_show_stats(seq, stat); + } - cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); - tn = NODE_PARENT(tn); - cindex++; - n = (struct node *)tn; - pend = tn->pos+tn->bits; - depth--; - } - } + if (trie_main) { + seq_printf(seq, "Main:\n"); + trie_collect_stats(trie_main, stat); + trie_show_stats(seq, stat); } + kfree(stat); - rcu_read_unlock(); - return s; + return 0; } -#ifdef CONFIG_PROC_FS - -static struct fib_alias *fib_triestat_get_first(struct seq_file *seq) +static int fib_triestat_seq_open(struct inode *inode, struct file *file) { - return NULL; + return single_open(file, fib_triestat_seq_show, NULL); } -static struct fib_alias *fib_triestat_get_next(struct seq_file *seq) +static struct file_operations fib_triestat_fops = { + .owner = THIS_MODULE, + .open = fib_triestat_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static struct node *fib_trie_get_idx(struct fib_trie_iter *iter, + loff_t pos) { + loff_t idx = 0; + struct node *n; + + for (n = fib_trie_get_first(iter, trie_local); + n; ++idx, n = fib_trie_get_next(iter)) { + if (pos == idx) + return n; + } + + for (n = fib_trie_get_first(iter, trie_main); + n; ++idx, n = fib_trie_get_next(iter)) { + if (pos == idx) + return n; + } return NULL; } -static void *fib_triestat_seq_start(struct seq_file *seq, loff_t *pos) +static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos) { - if (!ip_fib_main_table) - return NULL; - - if (*pos) - return fib_triestat_get_next(seq); - else + rcu_read_lock(); + if (*pos == 0) return SEQ_START_TOKEN; + return fib_trie_get_idx(seq->private, *pos - 1); } -static void *fib_triestat_seq_next(struct seq_file *seq, void *v, loff_t *pos) +static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) { + struct fib_trie_iter *iter = seq->private; + void *l = v; + ++*pos; if (v == SEQ_START_TOKEN) - return fib_triestat_get_first(seq); - else - return fib_triestat_get_next(seq); -} + return fib_trie_get_idx(iter, 0); -static void fib_triestat_seq_stop(struct seq_file *seq, void *v) -{ + v = fib_trie_get_next(iter); + BUG_ON(v == l); + if (v) + return v; -} + /* continue scan in next trie */ + if (iter->trie == trie_local) + return fib_trie_get_first(iter, trie_main); -/* - * This outputs /proc/net/fib_triestats - * - * It always works in backward compatibility mode. - * The format of the file is not supposed to be changed. - */ + return NULL; +} -static void collect_and_show(struct trie *t, struct seq_file *seq) +static void fib_trie_seq_stop(struct seq_file *seq, void *v) { - int bytes = 0; /* How many bytes are used, a ref is 4 bytes */ - int i, max, pointers; - struct trie_stat *stat; - int avdepth; - - stat = trie_collect_stats(t); - - bytes = 0; - seq_printf(seq, "trie=%p\n", t); - - if (stat) { - if (stat->leaves) - avdepth = stat->totdepth*100 / stat->leaves; - else - avdepth = 0; - seq_printf(seq, "Aver depth: %d.%02d\n", avdepth / 100, avdepth % 100); - seq_printf(seq, "Max depth: %4d\n", stat->maxdepth); + rcu_read_unlock(); +} - seq_printf(seq, "Leaves: %d\n", stat->leaves); - bytes += sizeof(struct leaf) * stat->leaves; - seq_printf(seq, "Internal nodes: %d\n", stat->tnodes); - bytes += sizeof(struct tnode) * stat->tnodes; +static void seq_indent(struct seq_file *seq, int n) +{ + while (n-- > 0) seq_puts(seq, " "); +} - max = MAX_CHILDS-1; +static inline const char *rtn_scope(enum rt_scope_t s) +{ + static char buf[32]; - while (max >= 0 && stat->nodesizes[max] == 0) - max--; - pointers = 0; + switch(s) { + case RT_SCOPE_UNIVERSE: return "universe"; + case RT_SCOPE_SITE: return "site"; + case RT_SCOPE_LINK: return "link"; + case RT_SCOPE_HOST: return "host"; + case RT_SCOPE_NOWHERE: return "nowhere"; + default: + snprintf(buf, sizeof(buf), "scope=%d", s); + return buf; + } +} - for (i = 1; i <= max; i++) - if (stat->nodesizes[i] != 0) { - seq_printf(seq, " %d: %d", i, stat->nodesizes[i]); - pointers += (1<nodesizes[i]; - } - seq_printf(seq, "\n"); - seq_printf(seq, "Pointers: %d\n", pointers); - bytes += sizeof(struct node *) * pointers; - seq_printf(seq, "Null ptrs: %d\n", stat->nullpointers); - seq_printf(seq, "Total size: %d kB\n", bytes / 1024); +static const char *rtn_type_names[__RTN_MAX] = { + [RTN_UNSPEC] = "UNSPEC", + [RTN_UNICAST] = "UNICAST", + [RTN_LOCAL] = "LOCAL", + [RTN_BROADCAST] = "BROADCAST", + [RTN_ANYCAST] = "ANYCAST", + [RTN_MULTICAST] = "MULTICAST", + [RTN_BLACKHOLE] = "BLACKHOLE", + [RTN_UNREACHABLE] = "UNREACHABLE", + [RTN_PROHIBIT] = "PROHIBIT", + [RTN_THROW] = "THROW", + [RTN_NAT] = "NAT", + [RTN_XRESOLVE] = "XRESOLVE", +}; - kfree(stat); - } +static inline const char *rtn_type(unsigned t) +{ + static char buf[32]; -#ifdef CONFIG_IP_FIB_TRIE_STATS - seq_printf(seq, "Counters:\n---------\n"); - seq_printf(seq,"gets = %d\n", t->stats.gets); - seq_printf(seq,"backtracks = %d\n", t->stats.backtrack); - seq_printf(seq,"semantic match passed = %d\n", t->stats.semantic_match_passed); - seq_printf(seq,"semantic match miss = %d\n", t->stats.semantic_match_miss); - seq_printf(seq,"null node hit= %d\n", t->stats.null_node_hit); - seq_printf(seq,"skipped node resize = %d\n", t->stats.resize_node_skipped); -#ifdef CLEAR_STATS - memset(&(t->stats), 0, sizeof(t->stats)); -#endif -#endif /* CONFIG_IP_FIB_TRIE_STATS */ + if (t < __RTN_MAX && rtn_type_names[t]) + return rtn_type_names[t]; + snprintf(buf, sizeof(buf), "type %d", t); + return buf; } -static int fib_triestat_seq_show(struct seq_file *seq, void *v) +/* Pretty print the trie */ +static int fib_trie_seq_show(struct seq_file *seq, void *v) { - char bf[128]; + const struct fib_trie_iter *iter = seq->private; + struct node *n = v; - if (v == SEQ_START_TOKEN) { - seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n", - sizeof(struct leaf), sizeof(struct tnode)); - if (trie_local) - collect_and_show(trie_local, seq); + if (v == SEQ_START_TOKEN) + return 0; - if (trie_main) - collect_and_show(trie_main, seq); - } else { - snprintf(bf, sizeof(bf), "*\t%08X\t%08X", 200, 400); + if (IS_TNODE(n)) { + struct tnode *tn = (struct tnode *) n; + t_key prf = ntohl(MASK_PFX(tn->key, tn->pos)); - seq_printf(seq, "%-127s\n", bf); + if (!NODE_PARENT(n)) { + if (iter->trie == trie_local) + seq_puts(seq, ":\n"); + else + seq_puts(seq, "
:\n"); + } else { + seq_indent(seq, iter->depth-1); + seq_printf(seq, " +-- %d.%d.%d.%d/%d\n", + NIPQUAD(prf), tn->pos); + } + } else { + struct leaf *l = (struct leaf *) n; + int i; + u32 val = ntohl(l->key); + + seq_indent(seq, iter->depth); + seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val)); + for (i = 32; i >= 0; i--) { + struct leaf_info *li = find_leaf_info(&l->list, i); + if (li) { + struct fib_alias *fa; + list_for_each_entry_rcu(fa, &li->falh, fa_list) { + seq_indent(seq, iter->depth+1); + seq_printf(seq, " /%d %s %s", i, + rtn_scope(fa->fa_scope), + rtn_type(fa->fa_type)); + if (fa->fa_tos) + seq_printf(seq, "tos =%d\n", + fa->fa_tos); + seq_putc(seq, '\n'); + } + } + } } + return 0; } -static struct seq_operations fib_triestat_seq_ops = { - .start = fib_triestat_seq_start, - .next = fib_triestat_seq_next, - .stop = fib_triestat_seq_stop, - .show = fib_triestat_seq_show, +static struct seq_operations fib_trie_seq_ops = { + .start = fib_trie_seq_start, + .next = fib_trie_seq_next, + .stop = fib_trie_seq_stop, + .show = fib_trie_seq_show, }; -static int fib_triestat_seq_open(struct inode *inode, struct file *file) +static int fib_trie_seq_open(struct inode *inode, struct file *file) { struct seq_file *seq; int rc = -ENOMEM; + struct fib_trie_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); - rc = seq_open(file, &fib_triestat_seq_ops); + if (!s) + goto out; + + rc = seq_open(file, &fib_trie_seq_ops); if (rc) goto out_kfree; - seq = file->private_data; + seq = file->private_data; + seq->private = s; + memset(s, 0, sizeof(*s)); out: return rc; out_kfree: + kfree(s); goto out; } -static struct file_operations fib_triestat_seq_fops = { - .owner = THIS_MODULE, - .open = fib_triestat_seq_open, - .read = seq_read, - .llseek = seq_lseek, +static struct file_operations fib_trie_fops = { + .owner = THIS_MODULE, + .open = fib_trie_seq_open, + .read = seq_read, + .llseek = seq_lseek, .release = seq_release_private, }; -int __init fib_stat_proc_init(void) -{ - if (!proc_net_fops_create("fib_triestat", S_IRUGO, &fib_triestat_seq_fops)) - return -ENOMEM; - return 0; -} - -void __init fib_stat_proc_exit(void) +static unsigned fib_flag_trans(int type, u32 mask, const struct fib_info *fi) { - proc_net_remove("fib_triestat"); -} + static unsigned type2flags[RTN_MAX + 1] = { + [7] = RTF_REJECT, [8] = RTF_REJECT, + }; + unsigned flags = type2flags[type]; -static struct fib_alias *fib_trie_get_first(struct seq_file *seq) -{ - return NULL; + if (fi && fi->fib_nh->nh_gw) + flags |= RTF_GATEWAY; + if (mask == 0xFFFFFFFF) + flags |= RTF_HOST; + flags |= RTF_UP; + return flags; } -static struct fib_alias *fib_trie_get_next(struct seq_file *seq) +/* + * This outputs /proc/net/route. + * The format of the file is not supposed to be changed + * and needs to be same as fib_hash output to avoid breaking + * legacy utilities + */ +static int fib_route_seq_show(struct seq_file *seq, void *v) { - return NULL; -} + struct leaf *l = v; + int i; + char bf[128]; -static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos) -{ - if (!ip_fib_main_table) - return NULL; + if (v == SEQ_START_TOKEN) { + seq_printf(seq, "%-127s\n", "Iface\tDestination\tGateway " + "\tFlags\tRefCnt\tUse\tMetric\tMask\t\tMTU" + "\tWindow\tIRTT"); + return 0; + } - if (*pos) - return fib_trie_get_next(seq); - else - return SEQ_START_TOKEN; -} + if (IS_TNODE(l)) + return 0; -static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) -{ - ++*pos; - if (v == SEQ_START_TOKEN) - return fib_trie_get_first(seq); - else - return fib_trie_get_next(seq); + for (i=32; i>=0; i--) { + struct leaf_info *li = find_leaf_info(&l->list, i); + struct fib_alias *fa; + u32 mask, prefix; -} + if (!li) + continue; -static void fib_trie_seq_stop(struct seq_file *seq, void *v) -{ -} + mask = inet_make_mask(li->plen); + prefix = htonl(l->key); -/* - * This outputs /proc/net/fib_trie. - * - * It always works in backward compatibility mode. - * The format of the file is not supposed to be changed. - */ + list_for_each_entry_rcu(fa, &li->falh, fa_list) { + const struct fib_info *fi = rcu_dereference(fa->fa_info); + unsigned flags = fib_flag_trans(fa->fa_type, mask, fi); -static int fib_trie_seq_show(struct seq_file *seq, void *v) -{ - char bf[128]; + if (fa->fa_type == RTN_BROADCAST + || fa->fa_type == RTN_MULTICAST) + continue; - if (v == SEQ_START_TOKEN) { - if (trie_local) - trie_dump_seq(seq, trie_local); + if (fi) + snprintf(bf, sizeof(bf), + "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", + fi->fib_dev ? fi->fib_dev->name : "*", + prefix, + fi->fib_nh->nh_gw, flags, 0, 0, + fi->fib_priority, + mask, + (fi->fib_advmss ? fi->fib_advmss + 40 : 0), + fi->fib_window, + fi->fib_rtt >> 3); + else + snprintf(bf, sizeof(bf), + "*\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", + prefix, 0, flags, 0, 0, 0, + mask, 0, 0, 0); - if (trie_main) - trie_dump_seq(seq, trie_main); - } else { - snprintf(bf, sizeof(bf), - "*\t%08X\t%08X", 200, 400); - seq_printf(seq, "%-127s\n", bf); + seq_printf(seq, "%-127s\n", bf); + } } return 0; } -static struct seq_operations fib_trie_seq_ops = { - .start = fib_trie_seq_start, - .next = fib_trie_seq_next, - .stop = fib_trie_seq_stop, - .show = fib_trie_seq_show, +static struct seq_operations fib_route_seq_ops = { + .start = fib_trie_seq_start, + .next = fib_trie_seq_next, + .stop = fib_trie_seq_stop, + .show = fib_route_seq_show, }; -static int fib_trie_seq_open(struct inode *inode, struct file *file) +static int fib_route_seq_open(struct inode *inode, struct file *file) { struct seq_file *seq; int rc = -ENOMEM; + struct fib_trie_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); - rc = seq_open(file, &fib_trie_seq_ops); + if (!s) + goto out; + + rc = seq_open(file, &fib_route_seq_ops); if (rc) goto out_kfree; - seq = file->private_data; + seq = file->private_data; + seq->private = s; + memset(s, 0, sizeof(*s)); out: return rc; out_kfree: + kfree(s); goto out; } -static struct file_operations fib_trie_seq_fops = { - .owner = THIS_MODULE, - .open = fib_trie_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release= seq_release_private, +static struct file_operations fib_route_fops = { + .owner = THIS_MODULE, + .open = fib_route_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release_private, }; int __init fib_proc_init(void) { - if (!proc_net_fops_create("fib_trie", S_IRUGO, &fib_trie_seq_fops)) - return -ENOMEM; + if (!proc_net_fops_create("fib_trie", S_IRUGO, &fib_trie_fops)) + goto out1; + + if (!proc_net_fops_create("fib_triestat", S_IRUGO, &fib_triestat_fops)) + goto out2; + + if (!proc_net_fops_create("route", S_IRUGO, &fib_route_fops)) + goto out3; + return 0; + +out3: + proc_net_remove("fib_triestat"); +out2: + proc_net_remove("fib_trie"); +out1: + return -ENOMEM; } void __init fib_proc_exit(void) { proc_net_remove("fib_trie"); + proc_net_remove("fib_triestat"); + proc_net_remove("route"); } #endif /* CONFIG_PROC_FS */ -- cgit v0.10.2 From 5a0773698c51fdcec7eb361b6b819669ed1d249e Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 22:44:31 +0200 Subject: kbuild: cris use generic asm-offsets.h support Cris has a dedicated asm-offsets.c file per subarchitecture. So a symlink is created to put the desired asm-offsets.c file in $(ARCH)/kernel This is absolutely not good practice, but it was the trick used in the rest of the cris code. Signed-off-by: Sam Ravnborg diff --git a/arch/cris/Makefile b/arch/cris/Makefile index 90ca873..a00043a 100644 --- a/arch/cris/Makefile +++ b/arch/cris/Makefile @@ -107,8 +107,7 @@ archclean: rm -f timage vmlinux.bin decompress.bin rescue.bin cramfs.img rm -rf $(LD_SCRIPT).tmp -prepare: $(SRC_ARCH)/.links $(srctree)/include/asm-$(ARCH)/.arch \ - include/asm-$(ARCH)/$(SARCH)/offset.h +prepare: $(SRC_ARCH)/.links $(srctree)/include/asm-$(ARCH)/.arch # Create some links to make all tools happy $(SRC_ARCH)/.links: @@ -120,6 +119,7 @@ $(SRC_ARCH)/.links: @ln -sfn $(SRC_ARCH)/$(SARCH)/lib $(SRC_ARCH)/lib @ln -sfn $(SRC_ARCH)/$(SARCH) $(SRC_ARCH)/arch @ln -sfn $(SRC_ARCH)/$(SARCH)/vmlinux.lds.S $(SRC_ARCH)/kernel/vmlinux.lds.S + @ln -sfn $(SRC_ARCH)/$(SARCH)/asm-offsets.c $(SRC_ARCH)/kernel/asm-offsets.c @touch $@ # Create link to sub arch includes @@ -128,9 +128,3 @@ $(srctree)/include/asm-$(ARCH)/.arch: $(wildcard include/config/arch/*.h) @rm -f include/asm-$(ARCH)/arch @ln -sf $(srctree)/include/asm-$(ARCH)/$(SARCH) $(srctree)/include/asm-$(ARCH)/arch @touch $@ - -arch/$(ARCH)/$(SARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/$(SARCH)/offset.h: arch/$(ARCH)/$(SARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) diff --git a/arch/cris/arch-v10/kernel/entry.S b/arch/cris/arch-v10/kernel/entry.S index c0163bf..c808005 100644 --- a/arch/cris/arch-v10/kernel/entry.S +++ b/arch/cris/arch-v10/kernel/entry.S @@ -270,7 +270,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/cris/arch-v32/kernel/entry.S b/arch/cris/arch-v32/kernel/entry.S index a8ed55e..3bd8503 100644 --- a/arch/cris/arch-v32/kernel/entry.S +++ b/arch/cris/arch-v32/kernel/entry.S @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include -- cgit v0.10.2 From 1325cc79163058739b70bed9860fccbecac6236b Mon Sep 17 00:00:00 2001 From: Hal Rosenstock Date: Fri, 9 Sep 2005 13:45:51 -0700 Subject: [PATCH] IB: Define more SA methods ib_sa.h: Define more SA methods (initially for madeye decode) Signed-off-by: Hal Rosenstock Signed-off-by: Roland Dreier diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h index c022edf..0f4f5ec 100644 --- a/include/rdma/ib_sa.h +++ b/include/rdma/ib_sa.h @@ -46,7 +46,11 @@ enum { IB_SA_METHOD_GET_TABLE = 0x12, IB_SA_METHOD_GET_TABLE_RESP = 0x92, - IB_SA_METHOD_DELETE = 0x15 + IB_SA_METHOD_DELETE = 0x15, + IB_SA_METHOD_DELETE_RESP = 0x95, + IB_SA_METHOD_GET_MULTI = 0x14, + IB_SA_METHOD_GET_MULTI_RESP = 0x94, + IB_SA_METHOD_GET_TRACE_TBL = 0x13 }; enum ib_sa_selector { -- cgit v0.10.2 From 0037c78a96bb391635bff103d401c24459c5092d Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 22:47:53 +0200 Subject: kbuild: frv,m32r,sparc64 introduce fake asm-offsets.h file Needed to get them to build. And a hint to avoid hardcoding to many constants in assembler. Signed-off-by: Sam Ravnborg diff --git a/arch/frv/kernel/asm-offsets.c b/arch/frv/kernel/asm-offsets.c new file mode 100644 index 0000000..9e26311 --- /dev/null +++ b/arch/frv/kernel/asm-offsets.c @@ -0,0 +1 @@ +/* Dummy asm-offsets.c file. Required by kbuild and ready to be used - hint! */ diff --git a/arch/m32r/kernel/asm-offsets.c b/arch/m32r/kernel/asm-offsets.c new file mode 100644 index 0000000..9e26311 --- /dev/null +++ b/arch/m32r/kernel/asm-offsets.c @@ -0,0 +1 @@ +/* Dummy asm-offsets.c file. Required by kbuild and ready to be used - hint! */ diff --git a/arch/sparc64/kernel/asm-offsets.c b/arch/sparc64/kernel/asm-offsets.c new file mode 100644 index 0000000..9e26311 --- /dev/null +++ b/arch/sparc64/kernel/asm-offsets.c @@ -0,0 +1 @@ +/* Dummy asm-offsets.c file. Required by kbuild and ready to be used - hint! */ -- cgit v0.10.2 From 1299232b5743da454c73853b90b3d2d83dce1737 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 9 Sep 2005 13:01:21 -0700 Subject: [PATCH] x86: MP_processor_info fix Remove the weird and apparently unnecessary logic in MP_processor_info() which assumes that the BSP is the first one to run MP_processor_info(). On one of my boxes that isn't true and cpu_possible_map gets the wrong value. Cc: Zwane Mwaikambo Cc: Alexander Nyberg Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c index cafaeff..15949fd 100644 --- a/arch/i386/kernel/mpparse.c +++ b/arch/i386/kernel/mpparse.c @@ -122,8 +122,8 @@ static int MP_valid_apicid(int apicid, int version) static void __init MP_processor_info (struct mpc_config_processor *m) { - int ver, apicid, cpu, found_bsp = 0; - physid_mask_t tmp; + int ver, apicid; + physid_mask_t phys_cpu; if (!(m->mpc_cpuflag & CPU_ENABLED)) return; @@ -181,7 +181,6 @@ static void __init MP_processor_info (struct mpc_config_processor *m) if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) { Dprintk(" Bootup CPU\n"); boot_cpu_physical_apicid = m->mpc_apicid; - found_bsp = 1; } if (num_processors >= NR_CPUS) { @@ -195,29 +194,26 @@ static void __init MP_processor_info (struct mpc_config_processor *m) " Processor ignored.\n", maxcpus); return; } - num_processors++; ver = m->mpc_apicver; if (!MP_valid_apicid(apicid, ver)) { printk(KERN_WARNING "Processor #%d INVALID. (Max ID: %d).\n", m->mpc_apicid, MAX_APICS); - --num_processors; return; } - if (found_bsp) - cpu = 0; - else - cpu = num_processors - 1; - cpu_set(cpu, cpu_possible_map); - tmp = apicid_to_cpu_present(apicid); - physids_or(phys_cpu_present_map, phys_cpu_present_map, tmp); - + cpu_set(num_processors, cpu_possible_map); + num_processors++; + phys_cpu = apicid_to_cpu_present(apicid); + physids_or(phys_cpu_present_map, phys_cpu_present_map, phys_cpu); + /* * Validate version */ if (ver == 0x0) { - printk(KERN_WARNING "BIOS bug, APIC version is 0 for CPU#%d! fixing up to 0x10. (tell your hw vendor)\n", m->mpc_apicid); + printk(KERN_WARNING "BIOS bug, APIC version is 0 for CPU#%d! " + "fixing up to 0x10. (tell your hw vendor)\n", + m->mpc_apicid); ver = 0x10; } apic_version[m->mpc_apicid] = ver; -- cgit v0.10.2 From 4b5d37ac02954572e80e09255bb5737277aaee8e Mon Sep 17 00:00:00 2001 From: Giancarlo Formicuccia Date: Fri, 9 Sep 2005 13:01:22 -0700 Subject: [PATCH] Clear task_struct->fs_excl on fork() An oversight. We don't want to carry the IO scheduler's "we hold exclusive fs resources" hint over to the child across fork(). Acked-by: Jens Axboe Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/kernel/fork.c b/kernel/fork.c index 7e1ead9..dfeadf4 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -176,6 +176,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) /* One for us, one for whoever does the "release_task()" (usually parent) */ atomic_set(&tsk->usage,2); + atomic_set(&tsk->fs_excl, 0); return tsk; } -- cgit v0.10.2 From abda24528ac3045511fb59291a2d6ccbddf30eda Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Fri, 9 Sep 2005 13:01:23 -0700 Subject: [PATCH] i386: CONFIG_ACPI_SRAT typo fix Fix a typo involving CONFIG_ACPI_SRAT. Signed-off-by: Magnus Damm Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/include/asm-i386/mmzone.h b/include/asm-i386/mmzone.h index 5164213..348fe3a 100644 --- a/include/asm-i386/mmzone.h +++ b/include/asm-i386/mmzone.h @@ -29,7 +29,7 @@ static inline void get_memcfg_numa(void) #ifdef CONFIG_X86_NUMAQ if (get_memcfg_numaq()) return; -#elif CONFIG_ACPI_SRAT +#elif defined(CONFIG_ACPI_SRAT) if (get_memcfg_from_srat()) return; #endif -- cgit v0.10.2 From 7f6fd5db2dbc28d475d67f9a6b041fefe1d6f7c8 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Fri, 9 Sep 2005 13:01:26 -0700 Subject: [PATCH] ppc32: Fix Kconfig mismerge Looks like the help comment for MPC834x got merged incorrectly. Signed-off-by: Kumar Gala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig index 6ab7e5e..e3f1ce3 100644 --- a/arch/ppc/Kconfig +++ b/arch/ppc/Kconfig @@ -499,11 +499,6 @@ config WINCEPT MPC821 PowerPC, introduced in 1998 and designed to be used in thin-client machines. Say Y to support it directly. - Be aware that PCI buses can only function when SYS board is plugged - into the PIB (Platform IO Board) board from Freescale which provide - 3 PCI slots. The PIBs PCI initialization is the bootloader's - responsiblilty. - endchoice choice @@ -680,6 +675,11 @@ config MPC834x_SYS help This option enables support for the MPC 834x SYS evaluation board. + Be aware that PCI buses can only function when SYS board is plugged + into the PIB (Platform IO Board) board from Freescale which provide + 3 PCI slots. The PIBs PCI initialization is the bootloader's + responsiblilty. + config EV64360 bool "Marvell-EV64360BP" help -- cgit v0.10.2 From e85b565233236a2a833adea73fb2f0e0f8fa2a61 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Fri, 9 Sep 2005 13:01:29 -0700 Subject: [PATCH] move truncate_inode_pages() into ->delete_inode() Allow file systems supporting ->delete_inode() to call truncate_inode_pages() on their own. OCFS2 wants this so it can query the cluster before making a final decision on whether to wipe an inode from disk or not. In some corner cases an inode marked on the local node via voting may not actually get orphaned. A good example is node death before the transaction moving the inode to the orphan dir commits to the journal. Without this patch, the truncate_inode_pages() call in generic_delete_inode() would discard valid data for such inodes. During earlier discussion in the 2.6.13 merge plan thread, Christoph Hellwig indicated that other file systems might also find this useful. IMHO, the best solution would be to just allow ->drop_inode() to do the cluster query but it seems that would require a substantial reworking of that section of the code. Assuming it is safe to call write_inode_now() in ocfs2_delete_inode() for those inodes which won't actually get wiped, this solution should get us by for now. Trivial testing of this patch (and a related OCFS2 update) has shown this to avoid the corruption I'm seeing. Signed-off-by: Mark Fasheh Acked-by: Christoph Hellwig Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/inode.c b/fs/inode.c index 71df1b1..f80a79f 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1034,19 +1034,21 @@ void generic_delete_inode(struct inode *inode) inodes_stat.nr_inodes--; spin_unlock(&inode_lock); - if (inode->i_data.nrpages) - truncate_inode_pages(&inode->i_data, 0); - security_inode_delete(inode); if (op->delete_inode) { void (*delete)(struct inode *) = op->delete_inode; if (!is_bad_inode(inode)) DQUOT_INIT(inode); - /* s_op->delete_inode internally recalls clear_inode() */ + /* Filesystems implementing their own + * s_op->delete_inode are required to call + * truncate_inode_pages and clear_inode() + * internally */ delete(inode); - } else + } else { + truncate_inode_pages(&inode->i_data, 0); clear_inode(inode); + } spin_lock(&inode_lock); hlist_del_init(&inode->i_hash); spin_unlock(&inode_lock); -- cgit v0.10.2 From fef266580e5cf897a1b63528fc6b1185e2d6bb87 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Fri, 9 Sep 2005 13:01:31 -0700 Subject: [PATCH] update filesystems for new delete_inode behavior Update the file systems in fs/ implementing a delete_inode() callback to call truncate_inode_pages(). One implementation note: In developing this patch I put the calls to truncate_inode_pages() at the very top of those filesystems delete_inode() callbacks in order to retain the previous behavior. I'm guessing that some of those could probably be optimized. Signed-off-by: Mark Fasheh Acked-by: Christoph Hellwig Signed-off-by: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/affs/inode.c b/fs/affs/inode.c index 7aa6f20..9ebe881 100644 --- a/fs/affs/inode.c +++ b/fs/affs/inode.c @@ -255,6 +255,7 @@ void affs_delete_inode(struct inode *inode) { pr_debug("AFFS: delete_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink); + truncate_inode_pages(&inode->i_data, 0); inode->i_size = 0; if (S_ISREG(inode->i_mode)) affs_truncate(inode); diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index 64e0fb3..628c2c1 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c @@ -143,6 +143,8 @@ static void bfs_delete_inode(struct inode * inode) dprintf("ino=%08lx\n", inode->i_ino); + truncate_inode_pages(&inode->i_data, 0); + if (inode->i_ino < BFS_ROOT_INO || inode->i_ino > info->si_lasti) { printf("invalid ino=%08lx\n", inode->i_ino); return; diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 53dceb0..fdba4d1 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -71,6 +71,8 @@ void ext2_put_inode(struct inode *inode) */ void ext2_delete_inode (struct inode * inode) { + truncate_inode_pages(&inode->i_data, 0); + if (is_bad_inode(inode)) goto no_delete; EXT2_I(inode)->i_dtime = get_seconds(); diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 9989fdc..b5177c9 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c @@ -187,6 +187,8 @@ void ext3_delete_inode (struct inode * inode) { handle_t *handle; + truncate_inode_pages(&inode->i_data, 0); + if (is_bad_inode(inode)) goto no_delete; diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 96ae85b..a7cbe68 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -335,6 +335,8 @@ EXPORT_SYMBOL(fat_build_inode); static void fat_delete_inode(struct inode *inode) { + truncate_inode_pages(&inode->i_data, 0); + if (!is_bad_inode(inode)) { inode->i_size = 0; fat_truncate(inode); diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index b2d1820..59c5062 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -284,6 +284,7 @@ static struct inode *hostfs_alloc_inode(struct super_block *sb) static void hostfs_delete_inode(struct inode *inode) { + truncate_inode_pages(&inode->i_data, 0); if(HOSTFS_I(inode)->fd != -1) { close_file(&HOSTFS_I(inode)->fd); HOSTFS_I(inode)->fd = -1; diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c index 38b1741..e3d17e9 100644 --- a/fs/hpfs/inode.c +++ b/fs/hpfs/inode.c @@ -284,6 +284,7 @@ void hpfs_write_if_changed(struct inode *inode) void hpfs_delete_inode(struct inode *inode) { + truncate_inode_pages(&inode->i_data, 0); lock_kernel(); hpfs_remove_fnode(inode->i_sb, inode->i_ino); unlock_kernel(); diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c index 777b900..3dcc6d2 100644 --- a/fs/jffs/inode-v23.c +++ b/fs/jffs/inode-v23.c @@ -1744,6 +1744,7 @@ jffs_delete_inode(struct inode *inode) D3(printk("jffs_delete_inode(): inode->i_ino == %lu\n", inode->i_ino)); + truncate_inode_pages(&inode->i_data, 0); lock_kernel(); inode->i_size = 0; inode->i_blocks = 0; diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index 767c7ec..cff352f 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c @@ -132,6 +132,8 @@ void jfs_delete_inode(struct inode *inode) (JFS_IP(inode)->fileset != cpu_to_le32(FILESYSTEM_I))) return; + truncate_inode_pages(&inode->i_data, 0); + if (test_cflag(COMMIT_Freewmap, inode)) jfs_free_zero_link(inode); diff --git a/fs/minix/inode.c b/fs/minix/inode.c index 3f18c21..790cc0d 100644 --- a/fs/minix/inode.c +++ b/fs/minix/inode.c @@ -24,6 +24,7 @@ static int minix_remount (struct super_block * sb, int * flags, char * data); static void minix_delete_inode(struct inode *inode) { + truncate_inode_pages(&inode->i_data, 0); inode->i_size = 0; minix_truncate(inode); minix_free_inode(inode); diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c index 44795d2..8c88392 100644 --- a/fs/ncpfs/inode.c +++ b/fs/ncpfs/inode.c @@ -286,6 +286,8 @@ ncp_iget(struct super_block *sb, struct ncp_entry_info *info) static void ncp_delete_inode(struct inode *inode) { + truncate_inode_pages(&inode->i_data, 0); + if (S_ISDIR(inode->i_mode)) { DDPRINTK("ncp_delete_inode: put directory %ld\n", inode->i_ino); } diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 541b418..6922469d 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -146,6 +146,8 @@ nfs_delete_inode(struct inode * inode) { dprintk("NFS: delete_inode(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino); + truncate_inode_pages(&inode->i_data, 0); + nfs_wb_all(inode); /* * The following should never happen... diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 133c286..effa6c0 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -60,6 +60,8 @@ static void proc_delete_inode(struct inode *inode) struct proc_dir_entry *de; struct task_struct *tsk; + truncate_inode_pages(&inode->i_data, 0); + /* Let go of any associated process */ tsk = PROC_I(inode)->task; if (tsk) diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c index b79162a..80f3291 100644 --- a/fs/qnx4/inode.c +++ b/fs/qnx4/inode.c @@ -63,6 +63,7 @@ int qnx4_sync_inode(struct inode *inode) static void qnx4_delete_inode(struct inode *inode) { QNX4DEBUG(("qnx4: deleting inode [%lu]\n", (unsigned long) inode->i_ino)); + truncate_inode_pages(&inode->i_data, 0); inode->i_size = 0; qnx4_truncate(inode); lock_kernel(); diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index ff291c9..1a8a1bf 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c @@ -33,6 +33,8 @@ void reiserfs_delete_inode(struct inode *inode) 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb); struct reiserfs_transaction_handle th; + truncate_inode_pages(&inode->i_data, 0); + reiserfs_write_lock(inode->i_sb); /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */ diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c index 4765aaa..10b9944 100644 --- a/fs/smbfs/inode.c +++ b/fs/smbfs/inode.c @@ -331,6 +331,7 @@ static void smb_delete_inode(struct inode *ino) { DEBUG1("ino=%ld\n", ino->i_ino); + truncate_inode_pages(&ino->i_data, 0); lock_kernel(); if (smb_close(ino)) PARANOIA("could not close inode %ld\n", ino->i_ino); diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c index 0530077..fa33ece 100644 --- a/fs/sysv/inode.c +++ b/fs/sysv/inode.c @@ -292,6 +292,7 @@ int sysv_sync_inode(struct inode * inode) static void sysv_delete_inode(struct inode *inode) { + truncate_inode_pages(&inode->i_data, 0); inode->i_size = 0; sysv_truncate(inode); lock_kernel(); diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 3d68de3..b83890b 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -87,6 +87,8 @@ static int udf_get_block(struct inode *, sector_t, struct buffer_head *, int); */ void udf_delete_inode(struct inode * inode) { + truncate_inode_pages(&inode->i_data, 0); + if (is_bad_inode(inode)) goto no_delete; diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 718627c..55f4aa1 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -804,6 +804,7 @@ int ufs_sync_inode (struct inode *inode) void ufs_delete_inode (struct inode * inode) { + truncate_inode_pages(&inode->i_data, 0); /*UFS_I(inode)->i_dtime = CURRENT_TIME;*/ lock_kernel(); mark_inode_dirty(inode); diff --git a/mm/shmem.c b/mm/shmem.c index db2c9e8d..0d627a3 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -666,6 +666,7 @@ static void shmem_delete_inode(struct inode *inode) struct shmem_inode_info *info = SHMEM_I(inode); if (inode->i_op->truncate == shmem_truncate) { + truncate_inode_pages(inode->i_mapping, 0); shmem_unacct_size(info->flags, inode->i_size); inode->i_size = 0; shmem_truncate(inode); -- cgit v0.10.2 From f5ee56cc184e0944ebc9ff1691985219959596f6 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Fri, 9 Sep 2005 13:01:32 -0700 Subject: [PATCH] txx9 serial update Support for the new RBHMA4500 eval board for the TX4938. General update from the 8250 ancestor of this driver. Replace use of deprecated interfaces. Signed-off-by: Ralf Baechle Signed-off-by: Atsushi Nemoto Acked-by: Russell King Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c index 49afadb..f10c86d 100644 --- a/drivers/serial/serial_txx9.c +++ b/drivers/serial/serial_txx9.c @@ -31,6 +31,8 @@ * 1.01 Set fifosize to make tx_empry called properly. * Use standard uart_get_divisor. * 1.02 Cleanup. (import 8250.c changes) + * 1.03 Fix low-latency mode. (import 8250.c changes) + * 1.04 Remove usage of deprecated functions, cleanup. */ #include @@ -54,7 +56,7 @@ #include #include -static char *serial_version = "1.02"; +static char *serial_version = "1.04"; static char *serial_name = "TX39/49 Serial driver"; #define PASS_LIMIT 256 @@ -86,9 +88,9 @@ static char *serial_name = "TX39/49 Serial driver"; */ #ifdef ENABLE_SERIAL_TXX9_PCI #define NR_PCI_BOARDS 4 -#define UART_NR (2 + NR_PCI_BOARDS) +#define UART_NR (4 + NR_PCI_BOARDS) #else -#define UART_NR 2 +#define UART_NR 4 #endif struct uart_txx9_port { @@ -304,8 +306,11 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status, struct pt_regs *r /* The following is not allowed by the tty layer and unsafe. It should be fixed ASAP */ if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - if(tty->low_latency) + if (tty->low_latency) { + spin_unlock(&up->port.lock); tty_flip_buffer_push(tty); + spin_lock(&up->port.lock); + } /* If this failed then we will throw away the bytes but must do so to clear interrupts */ } @@ -356,7 +361,9 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status, struct pt_regs *r ignore_char: disr = sio_in(up, TXX9_SIDISR); } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0)); + spin_unlock(&up->port.lock); tty_flip_buffer_push(tty); + spin_lock(&up->port.lock); *status = disr; } @@ -667,17 +674,8 @@ serial_txx9_pm(struct uart_port *port, unsigned int state, unsigned int oldstate) { struct uart_txx9_port *up = (struct uart_txx9_port *)port; - if (state) { - /* sleep */ - - if (up->pm) - up->pm(port, state, oldstate); - } else { - /* wake */ - - if (up->pm) - up->pm(port, state, oldstate); - } + if (up->pm) + up->pm(port, state, oldstate); } static int serial_txx9_request_resource(struct uart_txx9_port *up) @@ -979,14 +977,6 @@ static int __init serial_txx9_console_init(void) } console_initcall(serial_txx9_console_init); -static int __init serial_txx9_late_console_init(void) -{ - if (!(serial_txx9_console.flags & CON_ENABLED)) - register_console(&serial_txx9_console); - return 0; -} -late_initcall(serial_txx9_late_console_init); - #define SERIAL_TXX9_CONSOLE &serial_txx9_console #else #define SERIAL_TXX9_CONSOLE NULL @@ -1039,6 +1029,73 @@ static void serial_txx9_resume_port(int line) uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port); } +static DECLARE_MUTEX(serial_txx9_sem); + +/** + * serial_txx9_register_port - register a serial port + * @port: serial port template + * + * Configure the serial port specified by the request. + * + * The port is then probed and if necessary the IRQ is autodetected + * If this fails an error is returned. + * + * On success the port is ready to use and the line number is returned. + */ +static int __devinit serial_txx9_register_port(struct uart_port *port) +{ + int i; + struct uart_txx9_port *uart; + int ret = -ENOSPC; + + down(&serial_txx9_sem); + for (i = 0; i < UART_NR; i++) { + uart = &serial_txx9_ports[i]; + if (uart->port.type == PORT_UNKNOWN) + break; + } + if (i < UART_NR) { + uart_remove_one_port(&serial_txx9_reg, &uart->port); + uart->port.iobase = port->iobase; + uart->port.membase = port->membase; + uart->port.irq = port->irq; + uart->port.uartclk = port->uartclk; + uart->port.iotype = port->iotype; + uart->port.flags = port->flags | UPF_BOOT_AUTOCONF; + uart->port.mapbase = port->mapbase; + if (port->dev) + uart->port.dev = port->dev; + ret = uart_add_one_port(&serial_txx9_reg, &uart->port); + if (ret == 0) + ret = uart->port.line; + } + up(&serial_txx9_sem); + return ret; +} + +/** + * serial_txx9_unregister_port - remove a txx9 serial port at runtime + * @line: serial line number + * + * Remove one serial port. This may not be called from interrupt + * context. We hand the port back to the our control. + */ +static void __devexit serial_txx9_unregister_port(int line) +{ + struct uart_txx9_port *uart = &serial_txx9_ports[line]; + + down(&serial_txx9_sem); + uart_remove_one_port(&serial_txx9_reg, &uart->port); + uart->port.flags = 0; + uart->port.type = PORT_UNKNOWN; + uart->port.iobase = 0; + uart->port.mapbase = 0; + uart->port.membase = 0; + uart->port.dev = NULL; + uart_add_one_port(&serial_txx9_reg, &uart->port); + up(&serial_txx9_sem); +} + /* * Probe one serial board. Unfortunately, there is no rhyme nor reason * to the arrangement of serial ports on a PCI card. @@ -1056,13 +1113,13 @@ pciserial_txx9_init_one(struct pci_dev *dev, const struct pci_device_id *ent) memset(&port, 0, sizeof(port)); port.ops = &serial_txx9_pops; - port.flags |= UPF_BOOT_AUTOCONF; /* uart_ops.config_port will be called */ port.flags |= UPF_TXX9_HAVE_CTS_LINE; port.uartclk = 66670000; port.irq = dev->irq; port.iotype = UPIO_PORT; port.iobase = pci_resource_start(dev, 1); - line = uart_register_port(&serial_txx9_reg, &port); + port.dev = &dev->dev; + line = serial_txx9_register_port(&port); if (line < 0) { printk(KERN_WARNING "Couldn't register serial port %s: %d\n", pci_name(dev), line); } @@ -1078,7 +1135,7 @@ static void __devexit pciserial_txx9_remove_one(struct pci_dev *dev) pci_set_drvdata(dev, NULL); if (line) { - uart_unregister_port(&serial_txx9_reg, line); + serial_txx9_unregister_port(line); pci_disable_device(dev); } } @@ -1089,6 +1146,8 @@ static int pciserial_txx9_suspend_one(struct pci_dev *dev, pm_message_t state) if (line) serial_txx9_suspend_port(line); + pci_save_state(dev); + pci_set_power_state(dev, pci_choose_state(dev, state)); return 0; } @@ -1096,8 +1155,13 @@ static int pciserial_txx9_resume_one(struct pci_dev *dev) { int line = (int)(long)pci_get_drvdata(dev); - if (line) + pci_set_power_state(dev, PCI_D0); + pci_restore_state(dev); + + if (line) { + pci_enable_device(dev); serial_txx9_resume_port(line); + } return 0; } -- cgit v0.10.2 From 5e41ff9e0650f327a6c819841fa412da95d57319 Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Fri, 9 Sep 2005 13:01:35 -0700 Subject: [PATCH] security: enable atomic inode security labeling The following patch set enables atomic security labeling of newly created inodes by altering the fs code to invoke a new LSM hook to obtain the security attribute to apply to a newly created inode and to set up the incore inode security state during the inode creation transaction. This parallels the existing processing for setting ACLs on newly created inodes. Otherwise, it is possible for new inodes to be accessed by another thread via the dcache prior to complete security setup (presently handled by the post_create/mkdir/... LSM hooks in the VFS) and a newly created inode may be left unlabeled on the disk in the event of a crash. SELinux presently works around the issue by ensuring that the incore inode security label is initialized to a special SID that is inaccessible to unprivileged processes (in accordance with policy), thereby preventing inappropriate access but potentially causing false denials on legitimate accesses. A simple test program demonstrates such false denials on SELinux, and the patch solves the problem. Similar such false denials have been encountered in real applications. This patch defines a new inode_init_security LSM hook to obtain the security attribute to apply to a newly created inode and to set up the incore inode security state for it, and adds a corresponding hook function implementation to SELinux. Signed-off-by: Stephen Smalley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/include/linux/security.h b/include/linux/security.h index 7aab6ab..d4f3b7a 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -250,6 +250,25 @@ struct swap_info_struct; * @inode contains the inode structure. * Deallocate the inode security structure and set @inode->i_security to * NULL. + * @inode_init_security: + * Obtain the security attribute name suffix and value to set on a newly + * created inode and set up the incore security field for the new inode. + * This hook is called by the fs code as part of the inode creation + * transaction and provides for atomic labeling of the inode, unlike + * the post_create/mkdir/... hooks called by the VFS. The hook function + * is expected to allocate the name and value via kmalloc, with the caller + * being responsible for calling kfree after using them. + * If the security module does not use security attributes or does + * not wish to put a security attribute on this particular inode, + * then it should return -EOPNOTSUPP to skip this processing. + * @inode contains the inode structure of the newly created inode. + * @dir contains the inode structure of the parent directory. + * @name will be set to the allocated name suffix (e.g. selinux). + * @value will be set to the allocated attribute value. + * @len will be set to the length of the value. + * Returns 0 if @name and @value have been successfully set, + * -EOPNOTSUPP if no security attribute is needed, or + * -ENOMEM on memory allocation failure. * @inode_create: * Check permission to create a regular file. * @dir contains inode structure of the parent of the new file. @@ -1080,6 +1099,8 @@ struct security_operations { int (*inode_alloc_security) (struct inode *inode); void (*inode_free_security) (struct inode *inode); + int (*inode_init_security) (struct inode *inode, struct inode *dir, + char **name, void **value, size_t *len); int (*inode_create) (struct inode *dir, struct dentry *dentry, int mode); void (*inode_post_create) (struct inode *dir, @@ -1442,6 +1463,17 @@ static inline void security_inode_free (struct inode *inode) return; security_ops->inode_free_security (inode); } + +static inline int security_inode_init_security (struct inode *inode, + struct inode *dir, + char **name, + void **value, + size_t *len) +{ + if (unlikely (IS_PRIVATE (inode))) + return -EOPNOTSUPP; + return security_ops->inode_init_security (inode, dir, name, value, len); +} static inline int security_inode_create (struct inode *dir, struct dentry *dentry, @@ -2171,6 +2203,15 @@ static inline int security_inode_alloc (struct inode *inode) static inline void security_inode_free (struct inode *inode) { } + +static inline int security_inode_init_security (struct inode *inode, + struct inode *dir, + char **name, + void **value, + size_t *len) +{ + return -EOPNOTSUPP; +} static inline int security_inode_create (struct inode *dir, struct dentry *dentry, diff --git a/security/dummy.c b/security/dummy.c index 6ff8875..e8a00fa 100644 --- a/security/dummy.c +++ b/security/dummy.c @@ -258,6 +258,12 @@ static void dummy_inode_free_security (struct inode *inode) return; } +static int dummy_inode_init_security (struct inode *inode, struct inode *dir, + char **name, void **value, size_t *len) +{ + return -EOPNOTSUPP; +} + static int dummy_inode_create (struct inode *inode, struct dentry *dentry, int mask) { @@ -886,6 +892,7 @@ void security_fixup_ops (struct security_operations *ops) set_to_dummy_if_null(ops, sb_post_pivotroot); set_to_dummy_if_null(ops, inode_alloc_security); set_to_dummy_if_null(ops, inode_free_security); + set_to_dummy_if_null(ops, inode_init_security); set_to_dummy_if_null(ops, inode_create); set_to_dummy_if_null(ops, inode_post_create); set_to_dummy_if_null(ops, inode_link); diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 8641f88..63701fe 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1274,6 +1274,7 @@ static int post_create(struct inode *dir, struct inode *inode; struct inode_security_struct *dsec; struct superblock_security_struct *sbsec; + struct inode_security_struct *isec; u32 newsid; char *context; unsigned int len; @@ -1293,6 +1294,11 @@ static int post_create(struct inode *dir, return 0; } + isec = inode->i_security; + + if (isec->security_attr_init) + return 0; + if (tsec->create_sid && sbsec->behavior != SECURITY_FS_USE_MNTPOINT) { newsid = tsec->create_sid; } else { @@ -2018,6 +2024,58 @@ static void selinux_inode_free_security(struct inode *inode) inode_free_security(inode); } +static int selinux_inode_init_security(struct inode *inode, struct inode *dir, + char **name, void **value, + size_t *len) +{ + struct task_security_struct *tsec; + struct inode_security_struct *dsec; + struct superblock_security_struct *sbsec; + struct inode_security_struct *isec; + u32 newsid; + int rc; + char *namep, *context; + + tsec = current->security; + dsec = dir->i_security; + sbsec = dir->i_sb->s_security; + isec = inode->i_security; + + if (tsec->create_sid && sbsec->behavior != SECURITY_FS_USE_MNTPOINT) { + newsid = tsec->create_sid; + } else { + rc = security_transition_sid(tsec->sid, dsec->sid, + inode_mode_to_security_class(inode->i_mode), + &newsid); + if (rc) { + printk(KERN_WARNING "%s: " + "security_transition_sid failed, rc=%d (dev=%s " + "ino=%ld)\n", + __FUNCTION__, + -rc, inode->i_sb->s_id, inode->i_ino); + return rc; + } + } + + inode_security_set_sid(inode, newsid); + + namep = kstrdup(XATTR_SELINUX_SUFFIX, GFP_KERNEL); + if (!namep) + return -ENOMEM; + *name = namep; + + rc = security_sid_to_context(newsid, &context, len); + if (rc) { + kfree(namep); + return rc; + } + *value = context; + + isec->security_attr_init = 1; + + return 0; +} + static int selinux_inode_create(struct inode *dir, struct dentry *dentry, int mask) { return may_create(dir, dentry, SECCLASS_FILE); @@ -4298,6 +4356,7 @@ static struct security_operations selinux_ops = { .inode_alloc_security = selinux_inode_alloc_security, .inode_free_security = selinux_inode_free_security, + .inode_init_security = selinux_inode_init_security, .inode_create = selinux_inode_create, .inode_post_create = selinux_inode_post_create, .inode_link = selinux_inode_link, diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h index 887937c..c515bc0 100644 --- a/security/selinux/include/objsec.h +++ b/security/selinux/include/objsec.h @@ -46,6 +46,7 @@ struct inode_security_struct { unsigned char initialized; /* initialization flag */ struct semaphore sem; unsigned char inherit; /* inherit SID from parent entry */ + unsigned char security_attr_init; /* security attributes init flag */ }; struct file_security_struct { -- cgit v0.10.2 From 10f47e6a1b8b276323b652053945c87a63a5812d Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Fri, 9 Sep 2005 13:01:39 -0700 Subject: [PATCH] ext2: Enable atomic inode security labeling This patch modifies ext2 to call the inode_init_security LSM hook to obtain the security attribute for a newly created inode and to set the resulting attribute on the new inode. This parallels the existing processing for setting ACLs on newly created inodes. Signed-off-by: Stephen Smalley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index 161f156..c8d0703 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c @@ -615,6 +615,11 @@ got: DQUOT_DROP(inode); goto fail2; } + err = ext2_init_security(inode,dir); + if (err) { + DQUOT_FREE_INODE(inode); + goto fail2; + } mark_inode_dirty(inode); ext2_debug("allocating inode %lu\n", inode->i_ino); ext2_preread_inode(inode); diff --git a/fs/ext2/xattr.h b/fs/ext2/xattr.h index 5f3bfde..67cfeb6 100644 --- a/fs/ext2/xattr.h +++ b/fs/ext2/xattr.h @@ -116,3 +116,11 @@ exit_ext2_xattr(void) # endif /* CONFIG_EXT2_FS_XATTR */ +#ifdef CONFIG_EXT2_FS_SECURITY +extern int ext2_init_security(struct inode *inode, struct inode *dir); +#else +static inline int ext2_init_security(struct inode *inode, struct inode *dir) +{ + return 0; +} +#endif diff --git a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c index 6a6c59f..a266127 100644 --- a/fs/ext2/xattr_security.c +++ b/fs/ext2/xattr_security.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "xattr.h" static size_t @@ -45,6 +46,27 @@ ext2_xattr_security_set(struct inode *inode, const char *name, value, size, flags); } +int +ext2_init_security(struct inode *inode, struct inode *dir) +{ + int err; + size_t len; + void *value; + char *name; + + err = security_inode_init_security(inode, dir, &name, &value, &len); + if (err) { + if (err == -EOPNOTSUPP) + return 0; + return err; + } + err = ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY, + name, value, len, 0); + kfree(name); + kfree(value); + return err; +} + struct xattr_handler ext2_xattr_security_handler = { .prefix = XATTR_SECURITY_PREFIX, .list = ext2_xattr_security_list, -- cgit v0.10.2 From ac50960afa31877493add6d941d8402fa879c452 Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Fri, 9 Sep 2005 13:01:41 -0700 Subject: [PATCH] ext3: Enable atomic inode security labeling This patch modifies ext3 to call the inode_init_security LSM hook to obtain the security attribute for a newly created inode and to set the resulting attribute on the new inode as part of the same transaction. This parallels the existing processing for setting ACLs on newly created inodes. Signed-off-by: Stephen Smalley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index 6981bd0..9655276 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c @@ -607,6 +607,11 @@ got: DQUOT_DROP(inode); goto fail2; } + err = ext3_init_security(handle,inode, dir); + if (err) { + DQUOT_FREE_INODE(inode); + goto fail2; + } err = ext3_mark_inode_dirty(handle, inode); if (err) { ext3_std_error(sb, err); diff --git a/fs/ext3/xattr.h b/fs/ext3/xattr.h index eb31a69..2ceae38 100644 --- a/fs/ext3/xattr.h +++ b/fs/ext3/xattr.h @@ -133,3 +133,14 @@ exit_ext3_xattr(void) #define ext3_xattr_handlers NULL # endif /* CONFIG_EXT3_FS_XATTR */ + +#ifdef CONFIG_EXT3_FS_SECURITY +extern int ext3_init_security(handle_t *handle, struct inode *inode, + struct inode *dir); +#else +static inline int ext3_init_security(handle_t *handle, struct inode *inode, + struct inode *dir) +{ + return 0; +} +#endif diff --git a/fs/ext3/xattr_security.c b/fs/ext3/xattr_security.c index ddc1c41..b9c40c1 100644 --- a/fs/ext3/xattr_security.c +++ b/fs/ext3/xattr_security.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "xattr.h" static size_t @@ -47,6 +48,27 @@ ext3_xattr_security_set(struct inode *inode, const char *name, value, size, flags); } +int +ext3_init_security(handle_t *handle, struct inode *inode, struct inode *dir) +{ + int err; + size_t len; + void *value; + char *name; + + err = security_inode_init_security(inode, dir, &name, &value, &len); + if (err) { + if (err == -EOPNOTSUPP) + return 0; + return err; + } + err = ext3_xattr_set_handle(handle, inode, EXT3_XATTR_INDEX_SECURITY, + name, value, len, 0); + kfree(name); + kfree(value); + return err; +} + struct xattr_handler ext3_xattr_security_handler = { .prefix = XATTR_SECURITY_PREFIX, .list = ext3_xattr_security_list, -- cgit v0.10.2 From 570bc1c2e5ccdb408081e77507a385dc7ebed7fa Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Fri, 9 Sep 2005 13:01:43 -0700 Subject: [PATCH] tmpfs: Enable atomic inode security labeling This patch modifies tmpfs to call the inode_init_security LSM hook to set up the incore inode security state for new inodes before the inode becomes accessible via the dcache. As there is no underlying storage of security xattrs in this case, it is not necessary for the hook to return the (name, value, len) triple to the tmpfs code, so this patch also modifies the SELinux hook function to correctly handle the case where the (name, value, len) pointers are NULL. The hook call is needed in tmpfs in order to support proper security labeling of tmpfs inodes (e.g. for udev with tmpfs /dev in Fedora). With this change in place, we should then be able to remove the security_inode_post_create/mkdir/... hooks safely. Signed-off-by: Stephen Smalley Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/mm/shmem.c b/mm/shmem.c index 0d627a3..1f7aeb2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1608,6 +1608,15 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) int error = -ENOSPC; if (inode) { + error = security_inode_init_security(inode, dir, NULL, NULL, + NULL); + if (error) { + if (error != -EOPNOTSUPP) { + iput(inode); + return error; + } + error = 0; + } if (dir->i_mode & S_ISGID) { inode->i_gid = dir->i_gid; if (S_ISDIR(mode)) @@ -1617,7 +1626,6 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) dir->i_ctime = dir->i_mtime = CURRENT_TIME; d_instantiate(dentry, inode); dget(dentry); /* Extra count - pin the dentry in core */ - error = 0; } return error; } @@ -1747,6 +1755,16 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s if (!inode) return -ENOSPC; + error = security_inode_init_security(inode, dir, NULL, NULL, + NULL); + if (error) { + if (error != -EOPNOTSUPP) { + iput(inode); + return error; + } + error = 0; + } + info = SHMEM_I(inode); inode->i_size = len-1; if (len <= (char *)inode - (char *)info) { diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 63701fe..265f33d 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2032,9 +2032,9 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, struct inode_security_struct *dsec; struct superblock_security_struct *sbsec; struct inode_security_struct *isec; - u32 newsid; + u32 newsid, clen; int rc; - char *namep, *context; + char *namep = NULL, *context; tsec = current->security; dsec = dir->i_security; @@ -2059,17 +2059,22 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, inode_security_set_sid(inode, newsid); - namep = kstrdup(XATTR_SELINUX_SUFFIX, GFP_KERNEL); - if (!namep) - return -ENOMEM; - *name = namep; + if (name) { + namep = kstrdup(XATTR_SELINUX_SUFFIX, GFP_KERNEL); + if (!namep) + return -ENOMEM; + *name = namep; + } - rc = security_sid_to_context(newsid, &context, len); - if (rc) { - kfree(namep); - return rc; + if (value && len) { + rc = security_sid_to_context(newsid, &context, &clen); + if (rc) { + kfree(namep); + return rc; + } + *value = context; + *len = clen; } - *value = context; isec->security_attr_init = 1; -- cgit v0.10.2 From a74574aafea3a63add3251047601611111f44562 Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Fri, 9 Sep 2005 13:01:44 -0700 Subject: [PATCH] Remove security_inode_post_create/mkdir/symlink/mknod hooks This patch removes the inode_post_create/mkdir/mknod/symlink LSM hooks as they are obsoleted by the new inode_init_security hook that enables atomic inode security labeling. If anyone sees any reason to retain these hooks, please speak now. Also, is anyone using the post_rename/link hooks; if not, those could also be removed. Signed-off-by: Stephen Smalley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/namei.c b/fs/namei.c index 145e852..993a65a 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1316,10 +1316,8 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode, return error; DQUOT_INIT(dir); error = dir->i_op->create(dir, dentry, mode, nd); - if (!error) { + if (!error) fsnotify_create(dir, dentry->d_name.name); - security_inode_post_create(dir, dentry, mode); - } return error; } @@ -1635,10 +1633,8 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) DQUOT_INIT(dir); error = dir->i_op->mknod(dir, dentry, mode, dev); - if (!error) { + if (!error) fsnotify_create(dir, dentry->d_name.name); - security_inode_post_mknod(dir, dentry, mode, dev); - } return error; } @@ -1708,10 +1704,8 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) DQUOT_INIT(dir); error = dir->i_op->mkdir(dir, dentry, mode); - if (!error) { + if (!error) fsnotify_mkdir(dir, dentry->d_name.name); - security_inode_post_mkdir(dir,dentry, mode); - } return error; } @@ -1947,10 +1941,8 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, i DQUOT_INIT(dir); error = dir->i_op->symlink(dir, dentry, oldname); - if (!error) { + if (!error) fsnotify_create(dir, dentry->d_name.name); - security_inode_post_symlink(dir, dentry, oldname); - } return error; } diff --git a/include/linux/security.h b/include/linux/security.h index d4f3b7a..875225b 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -275,12 +275,6 @@ struct swap_info_struct; * @dentry contains the dentry structure for the file to be created. * @mode contains the file mode of the file to be created. * Return 0 if permission is granted. - * @inode_post_create: - * Set the security attributes on a newly created regular file. This hook - * is called after a file has been successfully created. - * @dir contains the inode structure of the parent directory of the new file. - * @dentry contains the the dentry structure for the newly created file. - * @mode contains the file mode. * @inode_link: * Check permission before creating a new hard link to a file. * @old_dentry contains the dentry structure for an existing link to the file. @@ -303,13 +297,6 @@ struct swap_info_struct; * @dentry contains the dentry structure of the symbolic link. * @old_name contains the pathname of file. * Return 0 if permission is granted. - * @inode_post_symlink: - * @dir contains the inode structure of the parent directory of the new link. - * @dentry contains the dentry structure of new symbolic link. - * @old_name contains the pathname of file. - * Set security attributes for a newly created symbolic link. Note that - * @dentry->d_inode may be NULL, since the filesystem might not - * instantiate the dentry (e.g. NFS). * @inode_mkdir: * Check permissions to create a new directory in the existing directory * associated with inode strcture @dir. @@ -317,11 +304,6 @@ struct swap_info_struct; * @dentry contains the dentry structure of new directory. * @mode contains the mode of new directory. * Return 0 if permission is granted. - * @inode_post_mkdir: - * Set security attributes on a newly created directory. - * @dir contains the inode structure of parent of the directory to be created. - * @dentry contains the dentry structure of new directory. - * @mode contains the mode of new directory. * @inode_rmdir: * Check the permission to remove a directory. * @dir contains the inode structure of parent of the directory to be removed. @@ -337,13 +319,6 @@ struct swap_info_struct; * @mode contains the mode of the new file. * @dev contains the the device number. * Return 0 if permission is granted. - * @inode_post_mknod: - * Set security attributes on a newly created special file (or socket or - * fifo file created via the mknod system call). - * @dir contains the inode structure of parent of the new node. - * @dentry contains the dentry structure of the new node. - * @mode contains the mode of the new node. - * @dev contains the the device number. * @inode_rename: * Check for permission to rename a file or directory. * @old_dir contains the inode structure for parent of the old link. @@ -1103,8 +1078,6 @@ struct security_operations { char **name, void **value, size_t *len); int (*inode_create) (struct inode *dir, struct dentry *dentry, int mode); - void (*inode_post_create) (struct inode *dir, - struct dentry *dentry, int mode); int (*inode_link) (struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry); void (*inode_post_link) (struct dentry *old_dentry, @@ -1112,17 +1085,10 @@ struct security_operations { int (*inode_unlink) (struct inode *dir, struct dentry *dentry); int (*inode_symlink) (struct inode *dir, struct dentry *dentry, const char *old_name); - void (*inode_post_symlink) (struct inode *dir, - struct dentry *dentry, - const char *old_name); int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode); - void (*inode_post_mkdir) (struct inode *dir, struct dentry *dentry, - int mode); int (*inode_rmdir) (struct inode *dir, struct dentry *dentry); int (*inode_mknod) (struct inode *dir, struct dentry *dentry, int mode, dev_t dev); - void (*inode_post_mknod) (struct inode *dir, struct dentry *dentry, - int mode, dev_t dev); int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry); void (*inode_post_rename) (struct inode *old_dir, @@ -1484,15 +1450,6 @@ static inline int security_inode_create (struct inode *dir, return security_ops->inode_create (dir, dentry, mode); } -static inline void security_inode_post_create (struct inode *dir, - struct dentry *dentry, - int mode) -{ - if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode))) - return; - security_ops->inode_post_create (dir, dentry, mode); -} - static inline int security_inode_link (struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry) @@ -1528,15 +1485,6 @@ static inline int security_inode_symlink (struct inode *dir, return security_ops->inode_symlink (dir, dentry, old_name); } -static inline void security_inode_post_symlink (struct inode *dir, - struct dentry *dentry, - const char *old_name) -{ - if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode))) - return; - security_ops->inode_post_symlink (dir, dentry, old_name); -} - static inline int security_inode_mkdir (struct inode *dir, struct dentry *dentry, int mode) @@ -1546,15 +1494,6 @@ static inline int security_inode_mkdir (struct inode *dir, return security_ops->inode_mkdir (dir, dentry, mode); } -static inline void security_inode_post_mkdir (struct inode *dir, - struct dentry *dentry, - int mode) -{ - if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode))) - return; - security_ops->inode_post_mkdir (dir, dentry, mode); -} - static inline int security_inode_rmdir (struct inode *dir, struct dentry *dentry) { @@ -1572,15 +1511,6 @@ static inline int security_inode_mknod (struct inode *dir, return security_ops->inode_mknod (dir, dentry, mode, dev); } -static inline void security_inode_post_mknod (struct inode *dir, - struct dentry *dentry, - int mode, dev_t dev) -{ - if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode))) - return; - security_ops->inode_post_mknod (dir, dentry, mode, dev); -} - static inline int security_inode_rename (struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, @@ -2220,11 +2150,6 @@ static inline int security_inode_create (struct inode *dir, return 0; } -static inline void security_inode_post_create (struct inode *dir, - struct dentry *dentry, - int mode) -{ } - static inline int security_inode_link (struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry) @@ -2250,11 +2175,6 @@ static inline int security_inode_symlink (struct inode *dir, return 0; } -static inline void security_inode_post_symlink (struct inode *dir, - struct dentry *dentry, - const char *old_name) -{ } - static inline int security_inode_mkdir (struct inode *dir, struct dentry *dentry, int mode) @@ -2262,11 +2182,6 @@ static inline int security_inode_mkdir (struct inode *dir, return 0; } -static inline void security_inode_post_mkdir (struct inode *dir, - struct dentry *dentry, - int mode) -{ } - static inline int security_inode_rmdir (struct inode *dir, struct dentry *dentry) { @@ -2280,11 +2195,6 @@ static inline int security_inode_mknod (struct inode *dir, return 0; } -static inline void security_inode_post_mknod (struct inode *dir, - struct dentry *dentry, - int mode, dev_t dev) -{ } - static inline int security_inode_rename (struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, diff --git a/security/dummy.c b/security/dummy.c index e8a00fa..5083314e 100644 --- a/security/dummy.c +++ b/security/dummy.c @@ -270,12 +270,6 @@ static int dummy_inode_create (struct inode *inode, struct dentry *dentry, return 0; } -static void dummy_inode_post_create (struct inode *inode, struct dentry *dentry, - int mask) -{ - return; -} - static int dummy_inode_link (struct dentry *old_dentry, struct inode *inode, struct dentry *new_dentry) { @@ -300,24 +294,12 @@ static int dummy_inode_symlink (struct inode *inode, struct dentry *dentry, return 0; } -static void dummy_inode_post_symlink (struct inode *inode, - struct dentry *dentry, const char *name) -{ - return; -} - static int dummy_inode_mkdir (struct inode *inode, struct dentry *dentry, int mask) { return 0; } -static void dummy_inode_post_mkdir (struct inode *inode, struct dentry *dentry, - int mask) -{ - return; -} - static int dummy_inode_rmdir (struct inode *inode, struct dentry *dentry) { return 0; @@ -329,12 +311,6 @@ static int dummy_inode_mknod (struct inode *inode, struct dentry *dentry, return 0; } -static void dummy_inode_post_mknod (struct inode *inode, struct dentry *dentry, - int mode, dev_t dev) -{ - return; -} - static int dummy_inode_rename (struct inode *old_inode, struct dentry *old_dentry, struct inode *new_inode, @@ -894,17 +870,13 @@ void security_fixup_ops (struct security_operations *ops) set_to_dummy_if_null(ops, inode_free_security); set_to_dummy_if_null(ops, inode_init_security); set_to_dummy_if_null(ops, inode_create); - set_to_dummy_if_null(ops, inode_post_create); set_to_dummy_if_null(ops, inode_link); set_to_dummy_if_null(ops, inode_post_link); set_to_dummy_if_null(ops, inode_unlink); set_to_dummy_if_null(ops, inode_symlink); - set_to_dummy_if_null(ops, inode_post_symlink); set_to_dummy_if_null(ops, inode_mkdir); - set_to_dummy_if_null(ops, inode_post_mkdir); set_to_dummy_if_null(ops, inode_rmdir); set_to_dummy_if_null(ops, inode_mknod); - set_to_dummy_if_null(ops, inode_post_mknod); set_to_dummy_if_null(ops, inode_rename); set_to_dummy_if_null(ops, inode_post_rename); set_to_dummy_if_null(ops, inode_readlink); diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 265f33d..c9c2082 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1265,91 +1265,6 @@ static int inode_security_set_sid(struct inode *inode, u32 sid) return 0; } -/* Set the security attributes on a newly created file. */ -static int post_create(struct inode *dir, - struct dentry *dentry) -{ - - struct task_security_struct *tsec; - struct inode *inode; - struct inode_security_struct *dsec; - struct superblock_security_struct *sbsec; - struct inode_security_struct *isec; - u32 newsid; - char *context; - unsigned int len; - int rc; - - tsec = current->security; - dsec = dir->i_security; - sbsec = dir->i_sb->s_security; - - inode = dentry->d_inode; - if (!inode) { - /* Some file system types (e.g. NFS) may not instantiate - a dentry for all create operations (e.g. symlink), - so we have to check to see if the inode is non-NULL. */ - printk(KERN_WARNING "post_create: no inode, dir (dev=%s, " - "ino=%ld)\n", dir->i_sb->s_id, dir->i_ino); - return 0; - } - - isec = inode->i_security; - - if (isec->security_attr_init) - return 0; - - if (tsec->create_sid && sbsec->behavior != SECURITY_FS_USE_MNTPOINT) { - newsid = tsec->create_sid; - } else { - rc = security_transition_sid(tsec->sid, dsec->sid, - inode_mode_to_security_class(inode->i_mode), - &newsid); - if (rc) { - printk(KERN_WARNING "post_create: " - "security_transition_sid failed, rc=%d (dev=%s " - "ino=%ld)\n", - -rc, inode->i_sb->s_id, inode->i_ino); - return rc; - } - } - - rc = inode_security_set_sid(inode, newsid); - if (rc) { - printk(KERN_WARNING "post_create: inode_security_set_sid " - "failed, rc=%d (dev=%s ino=%ld)\n", - -rc, inode->i_sb->s_id, inode->i_ino); - return rc; - } - - if (sbsec->behavior == SECURITY_FS_USE_XATTR && - inode->i_op->setxattr) { - /* Use extended attributes. */ - rc = security_sid_to_context(newsid, &context, &len); - if (rc) { - printk(KERN_WARNING "post_create: sid_to_context " - "failed, rc=%d (dev=%s ino=%ld)\n", - -rc, inode->i_sb->s_id, inode->i_ino); - return rc; - } - down(&inode->i_sem); - rc = inode->i_op->setxattr(dentry, - XATTR_NAME_SELINUX, - context, len, 0); - up(&inode->i_sem); - kfree(context); - if (rc < 0) { - printk(KERN_WARNING "post_create: setxattr failed, " - "rc=%d (dev=%s ino=%ld)\n", - -rc, inode->i_sb->s_id, inode->i_ino); - return rc; - } - } - - return 0; -} - - /* Hook functions begin here. */ static int selinux_ptrace(struct task_struct *parent, struct task_struct *child) @@ -2076,8 +1991,6 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, *len = clen; } - isec->security_attr_init = 1; - return 0; } @@ -2086,11 +1999,6 @@ static int selinux_inode_create(struct inode *dir, struct dentry *dentry, int ma return may_create(dir, dentry, SECCLASS_FILE); } -static void selinux_inode_post_create(struct inode *dir, struct dentry *dentry, int mask) -{ - post_create(dir, dentry); -} - static int selinux_inode_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry) { int rc; @@ -2121,21 +2029,11 @@ static int selinux_inode_symlink(struct inode *dir, struct dentry *dentry, const return may_create(dir, dentry, SECCLASS_LNK_FILE); } -static void selinux_inode_post_symlink(struct inode *dir, struct dentry *dentry, const char *name) -{ - post_create(dir, dentry); -} - static int selinux_inode_mkdir(struct inode *dir, struct dentry *dentry, int mask) { return may_create(dir, dentry, SECCLASS_DIR); } -static void selinux_inode_post_mkdir(struct inode *dir, struct dentry *dentry, int mask) -{ - post_create(dir, dentry); -} - static int selinux_inode_rmdir(struct inode *dir, struct dentry *dentry) { return may_link(dir, dentry, MAY_RMDIR); @@ -2152,11 +2050,6 @@ static int selinux_inode_mknod(struct inode *dir, struct dentry *dentry, int mod return may_create(dir, dentry, inode_mode_to_security_class(mode)); } -static void selinux_inode_post_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) -{ - post_create(dir, dentry); -} - static int selinux_inode_rename(struct inode *old_inode, struct dentry *old_dentry, struct inode *new_inode, struct dentry *new_dentry) { @@ -4363,17 +4256,13 @@ static struct security_operations selinux_ops = { .inode_free_security = selinux_inode_free_security, .inode_init_security = selinux_inode_init_security, .inode_create = selinux_inode_create, - .inode_post_create = selinux_inode_post_create, .inode_link = selinux_inode_link, .inode_post_link = selinux_inode_post_link, .inode_unlink = selinux_inode_unlink, .inode_symlink = selinux_inode_symlink, - .inode_post_symlink = selinux_inode_post_symlink, .inode_mkdir = selinux_inode_mkdir, - .inode_post_mkdir = selinux_inode_post_mkdir, .inode_rmdir = selinux_inode_rmdir, .inode_mknod = selinux_inode_mknod, - .inode_post_mknod = selinux_inode_post_mknod, .inode_rename = selinux_inode_rename, .inode_post_rename = selinux_inode_post_rename, .inode_readlink = selinux_inode_readlink, diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h index c515bc0..887937c 100644 --- a/security/selinux/include/objsec.h +++ b/security/selinux/include/objsec.h @@ -46,7 +46,6 @@ struct inode_security_struct { unsigned char initialized; /* initialization flag */ struct semaphore sem; unsigned char inherit; /* inherit SID from parent entry */ - unsigned char security_attr_init; /* security attributes init flag */ }; struct file_security_struct { -- cgit v0.10.2 From e31e14ec356f36b131576be5bc31d8fef7e95483 Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Fri, 9 Sep 2005 13:01:45 -0700 Subject: [PATCH] remove the inode_post_link and inode_post_rename LSM hooks This patch removes the inode_post_link and inode_post_rename LSM hooks as they are unused (and likely useless). Signed-off-by: Stephen Smalley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/namei.c b/fs/namei.c index 993a65a..21d85f1 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2012,10 +2012,8 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de DQUOT_INIT(dir); error = dir->i_op->link(old_dentry, dir, new_dentry); up(&old_dentry->d_inode->i_sem); - if (!error) { + if (!error) fsnotify_create(dir, new_dentry->d_name.name); - security_inode_post_link(old_dentry, dir, new_dentry); - } return error; } @@ -2134,11 +2132,8 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, d_rehash(new_dentry); dput(new_dentry); } - if (!error) { + if (!error) d_move(old_dentry,new_dentry); - security_inode_post_rename(old_dir, old_dentry, - new_dir, new_dentry); - } return error; } @@ -2164,7 +2159,6 @@ static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry, /* The following d_move() should become unconditional */ if (!(old_dir->i_sb->s_type->fs_flags & FS_ODD_RENAME)) d_move(old_dentry, new_dentry); - security_inode_post_rename(old_dir, old_dentry, new_dir, new_dentry); } if (target) up(&target->i_sem); diff --git a/include/linux/security.h b/include/linux/security.h index 875225b..55b02e1 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -281,11 +281,6 @@ struct swap_info_struct; * @dir contains the inode structure of the parent directory of the new link. * @new_dentry contains the dentry structure for the new link. * Return 0 if permission is granted. - * @inode_post_link: - * Set security attributes for a new hard link to a file. - * @old_dentry contains the dentry structure for the existing link. - * @dir contains the inode structure of the parent directory of the new file. - * @new_dentry contains the dentry structure for the new file link. * @inode_unlink: * Check the permission to remove a hard link to a file. * @dir contains the inode structure of parent directory of the file. @@ -326,12 +321,6 @@ struct swap_info_struct; * @new_dir contains the inode structure for parent of the new link. * @new_dentry contains the dentry structure of the new link. * Return 0 if permission is granted. - * @inode_post_rename: - * Set security attributes on a renamed file or directory. - * @old_dir contains the inode structure for parent of the old link. - * @old_dentry contains the dentry structure of the old link. - * @new_dir contains the inode structure for parent of the new link. - * @new_dentry contains the dentry structure of the new link. * @inode_readlink: * Check the permission to read the symbolic link. * @dentry contains the dentry structure for the file link. @@ -1080,8 +1069,6 @@ struct security_operations { struct dentry *dentry, int mode); int (*inode_link) (struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry); - void (*inode_post_link) (struct dentry *old_dentry, - struct inode *dir, struct dentry *new_dentry); int (*inode_unlink) (struct inode *dir, struct dentry *dentry); int (*inode_symlink) (struct inode *dir, struct dentry *dentry, const char *old_name); @@ -1091,10 +1078,6 @@ struct security_operations { int mode, dev_t dev); int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry); - void (*inode_post_rename) (struct inode *old_dir, - struct dentry *old_dentry, - struct inode *new_dir, - struct dentry *new_dentry); int (*inode_readlink) (struct dentry *dentry); int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd); int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd); @@ -1459,15 +1442,6 @@ static inline int security_inode_link (struct dentry *old_dentry, return security_ops->inode_link (old_dentry, dir, new_dentry); } -static inline void security_inode_post_link (struct dentry *old_dentry, - struct inode *dir, - struct dentry *new_dentry) -{ - if (new_dentry->d_inode && unlikely (IS_PRIVATE (new_dentry->d_inode))) - return; - security_ops->inode_post_link (old_dentry, dir, new_dentry); -} - static inline int security_inode_unlink (struct inode *dir, struct dentry *dentry) { @@ -1523,18 +1497,6 @@ static inline int security_inode_rename (struct inode *old_dir, new_dir, new_dentry); } -static inline void security_inode_post_rename (struct inode *old_dir, - struct dentry *old_dentry, - struct inode *new_dir, - struct dentry *new_dentry) -{ - if (unlikely (IS_PRIVATE (old_dentry->d_inode) || - (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode)))) - return; - security_ops->inode_post_rename (old_dir, old_dentry, - new_dir, new_dentry); -} - static inline int security_inode_readlink (struct dentry *dentry) { if (unlikely (IS_PRIVATE (dentry->d_inode))) @@ -2157,11 +2119,6 @@ static inline int security_inode_link (struct dentry *old_dentry, return 0; } -static inline void security_inode_post_link (struct dentry *old_dentry, - struct inode *dir, - struct dentry *new_dentry) -{ } - static inline int security_inode_unlink (struct inode *dir, struct dentry *dentry) { @@ -2203,12 +2160,6 @@ static inline int security_inode_rename (struct inode *old_dir, return 0; } -static inline void security_inode_post_rename (struct inode *old_dir, - struct dentry *old_dentry, - struct inode *new_dir, - struct dentry *new_dentry) -{ } - static inline int security_inode_readlink (struct dentry *dentry) { return 0; diff --git a/security/dummy.c b/security/dummy.c index 5083314e..9623a61 100644 --- a/security/dummy.c +++ b/security/dummy.c @@ -276,13 +276,6 @@ static int dummy_inode_link (struct dentry *old_dentry, struct inode *inode, return 0; } -static void dummy_inode_post_link (struct dentry *old_dentry, - struct inode *inode, - struct dentry *new_dentry) -{ - return; -} - static int dummy_inode_unlink (struct inode *inode, struct dentry *dentry) { return 0; @@ -319,14 +312,6 @@ static int dummy_inode_rename (struct inode *old_inode, return 0; } -static void dummy_inode_post_rename (struct inode *old_inode, - struct dentry *old_dentry, - struct inode *new_inode, - struct dentry *new_dentry) -{ - return; -} - static int dummy_inode_readlink (struct dentry *dentry) { return 0; @@ -871,14 +856,12 @@ void security_fixup_ops (struct security_operations *ops) set_to_dummy_if_null(ops, inode_init_security); set_to_dummy_if_null(ops, inode_create); set_to_dummy_if_null(ops, inode_link); - set_to_dummy_if_null(ops, inode_post_link); set_to_dummy_if_null(ops, inode_unlink); set_to_dummy_if_null(ops, inode_symlink); set_to_dummy_if_null(ops, inode_mkdir); set_to_dummy_if_null(ops, inode_rmdir); set_to_dummy_if_null(ops, inode_mknod); set_to_dummy_if_null(ops, inode_rename); - set_to_dummy_if_null(ops, inode_post_rename); set_to_dummy_if_null(ops, inode_readlink); set_to_dummy_if_null(ops, inode_follow_link); set_to_dummy_if_null(ops, inode_permission); diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index c9c2082..3f0b533 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2009,11 +2009,6 @@ static int selinux_inode_link(struct dentry *old_dentry, struct inode *dir, stru return may_link(dir, old_dentry, MAY_LINK); } -static void selinux_inode_post_link(struct dentry *old_dentry, struct inode *inode, struct dentry *new_dentry) -{ - return; -} - static int selinux_inode_unlink(struct inode *dir, struct dentry *dentry) { int rc; @@ -2056,12 +2051,6 @@ static int selinux_inode_rename(struct inode *old_inode, struct dentry *old_dent return may_rename(old_inode, old_dentry, new_inode, new_dentry); } -static void selinux_inode_post_rename(struct inode *old_inode, struct dentry *old_dentry, - struct inode *new_inode, struct dentry *new_dentry) -{ - return; -} - static int selinux_inode_readlink(struct dentry *dentry) { return dentry_has_perm(current, NULL, dentry, FILE__READ); @@ -4257,14 +4246,12 @@ static struct security_operations selinux_ops = { .inode_init_security = selinux_inode_init_security, .inode_create = selinux_inode_create, .inode_link = selinux_inode_link, - .inode_post_link = selinux_inode_post_link, .inode_unlink = selinux_inode_unlink, .inode_symlink = selinux_inode_symlink, .inode_mkdir = selinux_inode_mkdir, .inode_rmdir = selinux_inode_rmdir, .inode_mknod = selinux_inode_mknod, .inode_rename = selinux_inode_rename, - .inode_post_rename = selinux_inode_post_rename, .inode_readlink = selinux_inode_readlink, .inode_follow_link = selinux_inode_follow_link, .inode_permission = selinux_inode_permission, -- cgit v0.10.2 From 83f7da8acd81354e921ff12d6efbeae5b1a5d6a4 Mon Sep 17 00:00:00 2001 From: Marcelo Tosatti Date: Fri, 9 Sep 2005 13:01:45 -0700 Subject: [PATCH] ppc32: make perfmon.o CONFIG_E500 specific Subject says it all, there is no need to link perfmon.o on sub-architectures other than CONFIG_E500. Signed-off-by: Marcelo Tosatti Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile index b1457a8..1fb92f1 100644 --- a/arch/ppc/kernel/Makefile +++ b/arch/ppc/kernel/Makefile @@ -15,8 +15,9 @@ extra-y += vmlinux.lds obj-y := entry.o traps.o irq.o idle.o time.o misc.o \ process.o signal.o ptrace.o align.o \ semaphore.o syscalls.o setup.o \ - cputable.o ppc_htab.o perfmon.o + cputable.o ppc_htab.o obj-$(CONFIG_6xx) += l2cr.o cpu_setup_6xx.o +obj-$(CONFIG_E500) += perfmon.o obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o obj-$(CONFIG_POWER4) += cpu_setup_power4.o obj-$(CONFIG_MODULES) += module.o ppc_ksyms.o diff --git a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c index d87423d..8356d54 100644 --- a/arch/ppc/kernel/traps.c +++ b/arch/ppc/kernel/traps.c @@ -849,10 +849,12 @@ void AltivecAssistException(struct pt_regs *regs) } #endif /* CONFIG_ALTIVEC */ +#ifdef CONFIG_E500 void PerformanceMonitorException(struct pt_regs *regs) { perf_irq(regs); } +#endif #ifdef CONFIG_FSL_BOOKE void CacheLockingException(struct pt_regs *regs, unsigned long address, -- cgit v0.10.2 From 99cc2192132ab28c495d015ed2e95dc29e2a27ad Mon Sep 17 00:00:00 2001 From: Frank van Maarseveen Date: Fri, 9 Sep 2005 13:01:46 -0700 Subject: [PATCH] ppc32: Correct an instruction in the boot code In the flush and invalidate bootcode on PPC4xx we were accidentally using the wrong instruction. Use cmplw, which reads from a register like we want. Signed-off-by: Tom Rini Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/ppc/boot/common/util.S b/arch/ppc/boot/common/util.S index 47e6414..c96c9f8 100644 --- a/arch/ppc/boot/common/util.S +++ b/arch/ppc/boot/common/util.S @@ -252,7 +252,7 @@ _GLOBAL(flush_instruction_cache) 1: dcbf r0,r3 # Flush the data cache icbi r0,r3 # Invalidate the instruction cache addi r3,r3,0x10 # Increment by one cache line - cmplwi cr0,r3,r4 # Are we at the end yet? + cmplw cr0,r3,r4 # Are we at the end yet? blt 1b # No, keep flushing and invalidating #else /* Enable, invalidate and then disable the L1 icache/dcache. */ -- cgit v0.10.2 From 66b375bf7d9c995fd6169191c3862071e710f456 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 9 Sep 2005 13:01:47 -0700 Subject: [PATCH] ppc32: In the boot code, don't rely on BASE_BAUD directly Modifies serial_init to get base baud rate from the rs_table entry instead of BAUD_BASE. This patch eliminates duplication between the SERIAL_PORT_DFNS macro and BAUD_BASE. Without the patch, if a port set the baud rate in SERIAL_PORT_DFNS, but did not update BASE_BAUD, the BASE_BAUD value would still be used. Signed-off-by: Grant Likely Signed-off-by: Tom Rini Cc: Russell King Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/ppc/boot/common/ns16550.c b/arch/ppc/boot/common/ns16550.c index 9017c54..26818bb 100644 --- a/arch/ppc/boot/common/ns16550.c +++ b/arch/ppc/boot/common/ns16550.c @@ -23,7 +23,7 @@ static int shift; unsigned long serial_init(int chan, void *ignored) { - unsigned long com_port; + unsigned long com_port, base_baud; unsigned char lcr, dlm; /* We need to find out which type io we're expecting. If it's @@ -43,6 +43,8 @@ unsigned long serial_init(int chan, void *ignored) /* How far apart the registers are. */ shift = rs_table[chan].iomem_reg_shift; + /* Base baud.. */ + base_baud = rs_table[chan].baud_base; /* save the LCR */ lcr = inb(com_port + (UART_LCR << shift)); @@ -62,9 +64,9 @@ unsigned long serial_init(int chan, void *ignored) else { /* Input clock. */ outb(com_port + (UART_DLL << shift), - (BASE_BAUD / SERIAL_BAUD) & 0xFF); + (base_baud / SERIAL_BAUD) & 0xFF); outb(com_port + (UART_DLM << shift), - (BASE_BAUD / SERIAL_BAUD) >> 8); + (base_baud / SERIAL_BAUD) >> 8); /* 8 data, 1 stop, no parity */ outb(com_port + (UART_LCR << shift), 0x03); /* RTS/DTR */ -- cgit v0.10.2 From 95409aaca734700e8dcba9db685b8600b67ba05d Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 9 Sep 2005 13:01:48 -0700 Subject: [PATCH] ppc32: Kill PVR_440* defines The following patch changes the usages of PVR_440* into strcmp's with the cpu_name field, and removes the defines altogether. The Ebony portion was briefly tested long ago. One benefit of moving from PVR-tests to string tests in general is that not all CPUs can be on and be able to do this type of comparison. See http://patchwork.ozlabs.org/linuxppc/patch?id=1250 for the original thread. Signed-off-by: Tom Rini Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/ppc/platforms/4xx/ebony.c b/arch/ppc/platforms/4xx/ebony.c index 0fd3442..d6b2b19 100644 --- a/arch/ppc/platforms/4xx/ebony.c +++ b/arch/ppc/platforms/4xx/ebony.c @@ -91,15 +91,10 @@ ebony_calibrate_decr(void) * on Rev. C silicon then errata forces us to * use the internal clock. */ - switch (PVR_REV(mfspr(SPRN_PVR))) { - case PVR_REV(PVR_440GP_RB): - freq = EBONY_440GP_RB_SYSCLK; - break; - case PVR_REV(PVR_440GP_RC1): - default: - freq = EBONY_440GP_RC_SYSCLK; - break; - } + if (strcmp(cur_cpu_spec[0]->cpu_name, "440GP Rev. B") == 0) + freq = EBONY_440GP_RB_SYSCLK; + else + freq = EBONY_440GP_RC_SYSCLK; ibm44x_calibrate_decr(freq); } diff --git a/arch/ppc/syslib/ibm440gx_common.c b/arch/ppc/syslib/ibm440gx_common.c index d4776af..0bb9198 100644 --- a/arch/ppc/syslib/ibm440gx_common.c +++ b/arch/ppc/syslib/ibm440gx_common.c @@ -236,9 +236,10 @@ void __init ibm440gx_l2c_setup(struct ibm44x_clocks* p) /* Disable L2C on rev.A, rev.B and 800MHz version of rev.C, enable it on all other revisions */ - u32 pvr = mfspr(SPRN_PVR); - if (pvr == PVR_440GX_RA || pvr == PVR_440GX_RB || - (pvr == PVR_440GX_RC && p->cpu > 667000000)) + if (strcmp(cur_cpu_spec[0]->cpu_name, "440GX Rev. A") == 0 || + strcmp(cur_cpu_spec[0]->cpu_name, "440GX Rev. B") == 0 + || (strcmp(cur_cpu_spec[0]->cpu_name, "440GX Rev. C") + == 0 && p->cpu > 667000000)) ibm440gx_l2c_disable(); else ibm440gx_l2c_enable(); diff --git a/include/asm-ppc/reg.h b/include/asm-ppc/reg.h index 88b4222..73c33e3 100644 --- a/include/asm-ppc/reg.h +++ b/include/asm-ppc/reg.h @@ -366,12 +366,6 @@ #define PVR_STB03XXX 0x40310000 #define PVR_NP405H 0x41410000 #define PVR_NP405L 0x41610000 -#define PVR_440GP_RB 0x40120440 -#define PVR_440GP_RC1 0x40120481 -#define PVR_440GP_RC2 0x40200481 -#define PVR_440GX_RA 0x51b21850 -#define PVR_440GX_RB 0x51b21851 -#define PVR_440GX_RC 0x51b21892 #define PVR_601 0x00010000 #define PVR_602 0x00050000 #define PVR_603 0x00030000 -- cgit v0.10.2 From 4d666d7ada2e14d71d463c85b8b5ef2e2e6723f2 Mon Sep 17 00:00:00 2001 From: Yoichi Yuasa Date: Fri, 9 Sep 2005 13:01:49 -0700 Subject: [PATCH] mips: add TANBAC TB0287 support Add TANBAC TB0287 support. Signed-off-by: Yoichi Yuasa Cc: Ralf Baechle Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 8d76eb1..0eb71ac 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -154,6 +154,13 @@ config TANBAC_TB0226 The TANBAC Mbase(TB0226) is a MIPS-based platform manufactured by TANBAC. Please refer to about Mbase. +config TANBAC_TB0287 + bool "Support for TANBAC Mini-ITX DIMM base(TB0287)" + depends on TANBAC_TB022X + help + The TANBAC Mini-ITX DIMM base(TB0287) is a MIPS-based platform manufactured by TANBAC. + Please refer to about Mini-ITX DIMM base. + config VICTOR_MPC30X bool "Support for Victor MP-C303/304" depends on MACH_VR41XX diff --git a/arch/mips/configs/tb0287_defconfig b/arch/mips/configs/tb0287_defconfig new file mode 100644 index 0000000..17b9f2f --- /dev/null +++ b/arch/mips/configs/tb0287_defconfig @@ -0,0 +1,1041 @@ +# +# Automatically generated make config: don't edit +# Linux kernel version: 2.6.13-mm1 +# Thu Sep 1 22:58:34 2005 +# +CONFIG_MIPS=y + +# +# Code maturity level options +# +CONFIG_EXPERIMENTAL=y +CONFIG_CLEAN_COMPILE=y +CONFIG_BROKEN_ON_SMP=y +CONFIG_INIT_ENV_ARG_LIMIT=32 + +# +# General setup +# +CONFIG_LOCALVERSION="" +CONFIG_LOCALVERSION_AUTO=y +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +# CONFIG_POSIX_MQUEUE is not set +# CONFIG_BSD_PROCESS_ACCT is not set +CONFIG_SYSCTL=y +# CONFIG_AUDIT is not set +# CONFIG_HOTPLUG is not set +CONFIG_KOBJECT_UEVENT=y +# CONFIG_IKCONFIG is not set +CONFIG_INITRAMFS_SOURCE="" +CONFIG_EMBEDDED=y +CONFIG_KALLSYMS=y +# CONFIG_KALLSYMS_EXTRA_PASS is not set +CONFIG_PRINTK=y +CONFIG_BUG=y +CONFIG_BASE_FULL=y +CONFIG_FUTEX=y +CONFIG_EPOLL=y +# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set +CONFIG_SHMEM=y +CONFIG_CC_ALIGN_FUNCTIONS=0 +CONFIG_CC_ALIGN_LABELS=0 +CONFIG_CC_ALIGN_LOOPS=0 +CONFIG_CC_ALIGN_JUMPS=0 +# CONFIG_TINY_SHMEM is not set +CONFIG_BASE_SMALL=0 + +# +# Loadable module support +# +CONFIG_MODULES=y +CONFIG_MODULE_UNLOAD=y +# CONFIG_MODULE_FORCE_UNLOAD is not set +CONFIG_OBSOLETE_MODPARM=y +CONFIG_MODVERSIONS=y +CONFIG_MODULE_SRCVERSION_ALL=y +CONFIG_KMOD=y +CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y +CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y +CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y +CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y + +# +# Kernel type +# +CONFIG_32BIT=y +# CONFIG_64BIT is not set + +# +# Machine selection +# +# CONFIG_MACH_JAZZ is not set +CONFIG_MACH_VR41XX=y +# CONFIG_NEC_CMBVR4133 is not set +# CONFIG_CASIO_E55 is not set +# CONFIG_IBM_WORKPAD is not set +CONFIG_TANBAC_TB022X=y +# CONFIG_TANBAC_TB0226 is not set +CONFIG_TANBAC_TB0287=y +# CONFIG_VICTOR_MPC30X is not set +# CONFIG_ZAO_CAPCELLA is not set +CONFIG_PCI_VR41XX=y +# CONFIG_VRC4173 is not set +# CONFIG_TOSHIBA_JMR3927 is not set +# CONFIG_MIPS_COBALT is not set +# CONFIG_MACH_DECSTATION is not set +# CONFIG_MIPS_EV64120 is not set +# CONFIG_MIPS_EV96100 is not set +# CONFIG_MIPS_IVR is not set +# CONFIG_LASAT is not set +# CONFIG_MIPS_ITE8172 is not set +# CONFIG_MIPS_ATLAS is not set +# CONFIG_MIPS_MALTA is not set +# CONFIG_MIPS_SEAD is not set +# CONFIG_MOMENCO_OCELOT is not set +# CONFIG_MOMENCO_OCELOT_G is not set +# CONFIG_MOMENCO_OCELOT_C is not set +# CONFIG_MOMENCO_OCELOT_3 is not set +# CONFIG_MOMENCO_JAGUAR_ATX is not set +# CONFIG_PMC_YOSEMITE is not set +# CONFIG_DDB5074 is not set +# CONFIG_DDB5476 is not set +# CONFIG_DDB5477 is not set +# CONFIG_QEMU is not set +# CONFIG_SGI_IP22 is not set +# CONFIG_SGI_IP27 is not set +# CONFIG_SGI_IP32 is not set +# CONFIG_SOC_AU1X00 is not set +# CONFIG_SIBYTE_SB1xxx_SOC is not set +# CONFIG_SNI_RM200_PCI is not set +# CONFIG_TOSHIBA_RBTX4927 is not set +CONFIG_RWSEM_GENERIC_SPINLOCK=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_HAVE_DEC_LOCK=y +CONFIG_DMA_NONCOHERENT=y +CONFIG_DMA_NEED_PCI_MAP_STATE=y +CONFIG_CPU_LITTLE_ENDIAN=y +CONFIG_IRQ_CPU=y +CONFIG_MIPS_L1_CACHE_SHIFT=5 + +# +# CPU selection +# +# CONFIG_CPU_MIPS32 is not set +# CONFIG_CPU_MIPS64 is not set +# CONFIG_CPU_R3000 is not set +# CONFIG_CPU_TX39XX is not set +CONFIG_CPU_VR41XX=y +# CONFIG_CPU_R4300 is not set +# CONFIG_CPU_R4X00 is not set +# CONFIG_CPU_TX49XX is not set +# CONFIG_CPU_R5000 is not set +# CONFIG_CPU_R5432 is not set +# CONFIG_CPU_R6000 is not set +# CONFIG_CPU_NEVADA is not set +# CONFIG_CPU_R8000 is not set +# CONFIG_CPU_R10000 is not set +# CONFIG_CPU_RM7000 is not set +# CONFIG_CPU_RM9000 is not set +# CONFIG_CPU_SB1 is not set +CONFIG_PAGE_SIZE_4KB=y +# CONFIG_PAGE_SIZE_8KB is not set +# CONFIG_PAGE_SIZE_16KB is not set +# CONFIG_PAGE_SIZE_64KB is not set +# CONFIG_CPU_ADVANCED is not set +CONFIG_CPU_HAS_SYNC=y +CONFIG_ARCH_FLATMEM_ENABLE=y +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_FLATMEM_MANUAL=y +# CONFIG_DISCONTIGMEM_MANUAL is not set +# CONFIG_SPARSEMEM_MANUAL is not set +CONFIG_FLATMEM=y +CONFIG_FLAT_NODE_MEM_MAP=y +# CONFIG_SPARSEMEM_STATIC is not set +# CONFIG_PREEMPT is not set + +# +# Bus options (PCI, PCMCIA, EISA, ISA, TC) +# +CONFIG_HW_HAS_PCI=y +CONFIG_PCI=y +# CONFIG_PCI_LEGACY_PROC is not set +CONFIG_MMU=y + +# +# PCCARD (PCMCIA/CardBus) support +# +# CONFIG_PCCARD is not set + +# +# PCI Hotplug Support +# +# CONFIG_HOTPLUG_PCI is not set + +# +# Executable file formats +# +CONFIG_BINFMT_ELF=y +# CONFIG_BINFMT_MISC is not set +CONFIG_TRAD_SIGNALS=y + +# +# Networking +# +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_MMAP is not set +CONFIG_UNIX=y +CONFIG_XFRM=y +CONFIG_XFRM_USER=m +# CONFIG_NET_KEY is not set +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_ADVANCED_ROUTER=y +CONFIG_ASK_IP_FIB_HASH=y +# CONFIG_IP_FIB_TRIE is not set +CONFIG_IP_FIB_HASH=y +CONFIG_IP_MULTIPLE_TABLES=y +CONFIG_IP_ROUTE_MULTIPATH=y +# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set +CONFIG_IP_ROUTE_VERBOSE=y +CONFIG_IP_PNP=y +# CONFIG_IP_PNP_DHCP is not set +CONFIG_IP_PNP_BOOTP=y +# CONFIG_IP_PNP_RARP is not set +CONFIG_NET_IPIP=m +CONFIG_NET_IPGRE=m +# CONFIG_NET_IPGRE_BROADCAST is not set +# CONFIG_IP_MROUTE is not set +# CONFIG_ARPD is not set +CONFIG_SYN_COOKIES=y +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +CONFIG_INET_TUNNEL=m +CONFIG_INET_DIAG=y +CONFIG_INET_TCP_DIAG=y +CONFIG_TCP_CONG_ADVANCED=y + +# +# TCP congestion control +# +CONFIG_TCP_CONG_BIC=y +CONFIG_TCP_CONG_WESTWOOD=m +CONFIG_TCP_CONG_HTCP=m +# CONFIG_TCP_CONG_HSTCP is not set +# CONFIG_TCP_CONG_HYBLA is not set +# CONFIG_TCP_CONG_VEGAS is not set +# CONFIG_TCP_CONG_SCALABLE is not set +# CONFIG_IPV6 is not set +# CONFIG_NETFILTER is not set + +# +# DCCP Configuration (EXPERIMENTAL) +# +# CONFIG_IP_DCCP is not set + +# +# SCTP Configuration (EXPERIMENTAL) +# +# CONFIG_IP_SCTP is not set +# CONFIG_ATM is not set +# CONFIG_BRIDGE is not set +# CONFIG_VLAN_8021Q is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_NET_DIVERT is not set +# CONFIG_ECONET is not set +# CONFIG_WAN_ROUTER is not set +# CONFIG_NET_SCHED is not set +# CONFIG_NET_CLS_ROUTE is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_NETFILTER_NETLINK is not set +# CONFIG_HAMRADIO is not set +# CONFIG_IRDA is not set +# CONFIG_BT is not set +# CONFIG_IEEE80211 is not set + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_STANDALONE=y +CONFIG_PREVENT_FIRMWARE_BUILD=y +# CONFIG_FW_LOADER is not set + +# +# Memory Technology Devices (MTD) +# +# CONFIG_MTD is not set + +# +# Parallel port support +# +# CONFIG_PARPORT is not set + +# +# Plug and Play support +# + +# +# Block devices +# +# CONFIG_BLK_DEV_FD is not set +# CONFIG_BLK_CPQ_DA is not set +# CONFIG_BLK_CPQ_CISS_DA is not set +# CONFIG_BLK_DEV_DAC960 is not set +# CONFIG_BLK_DEV_UMEM is not set +# CONFIG_BLK_DEV_COW_COMMON is not set +CONFIG_BLK_DEV_LOOP=m +# CONFIG_BLK_DEV_CRYPTOLOOP is not set +CONFIG_BLK_DEV_NBD=m +# CONFIG_BLK_DEV_SX8 is not set +# CONFIG_BLK_DEV_UB is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=4096 +# CONFIG_BLK_DEV_INITRD is not set +# CONFIG_LBD is not set +# CONFIG_CDROM_PKTCDVD is not set + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_AS=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +# CONFIG_ATA_OVER_ETH is not set + +# +# ATA/ATAPI/MFM/RLL support +# +CONFIG_IDE=y +CONFIG_BLK_DEV_IDE=y + +# +# Please see Documentation/ide.txt for help/info on IDE drives +# +# CONFIG_BLK_DEV_IDE_SATA is not set +CONFIG_BLK_DEV_IDEDISK=y +# CONFIG_IDEDISK_MULTI_MODE is not set +# CONFIG_BLK_DEV_IDECD is not set +# CONFIG_BLK_DEV_IDETAPE is not set +# CONFIG_BLK_DEV_IDEFLOPPY is not set +# CONFIG_BLK_DEV_IDESCSI is not set +# CONFIG_IDE_TASK_IOCTL is not set + +# +# IDE chipset support/bugfixes +# +CONFIG_IDE_GENERIC=y +CONFIG_BLK_DEV_IDEPCI=y +# CONFIG_IDEPCI_SHARE_IRQ is not set +# CONFIG_BLK_DEV_OFFBOARD is not set +# CONFIG_BLK_DEV_GENERIC is not set +# CONFIG_BLK_DEV_OPTI621 is not set +CONFIG_BLK_DEV_IDEDMA_PCI=y +# CONFIG_BLK_DEV_IDEDMA_FORCED is not set +# CONFIG_IDEDMA_PCI_AUTO is not set +# CONFIG_BLK_DEV_AEC62XX is not set +# CONFIG_BLK_DEV_ALI15X3 is not set +# CONFIG_BLK_DEV_AMD74XX is not set +# CONFIG_BLK_DEV_CMD64X is not set +# CONFIG_BLK_DEV_TRIFLEX is not set +# CONFIG_BLK_DEV_CY82C693 is not set +# CONFIG_BLK_DEV_CS5520 is not set +# CONFIG_BLK_DEV_CS5530 is not set +# CONFIG_BLK_DEV_HPT34X is not set +# CONFIG_BLK_DEV_HPT366 is not set +# CONFIG_BLK_DEV_SC1200 is not set +# CONFIG_BLK_DEV_PIIX is not set +# CONFIG_BLK_DEV_IT821X is not set +# CONFIG_BLK_DEV_NS87415 is not set +# CONFIG_BLK_DEV_PDC202XX_OLD is not set +# CONFIG_BLK_DEV_PDC202XX_NEW is not set +# CONFIG_BLK_DEV_SVWKS is not set +CONFIG_BLK_DEV_SIIMAGE=y +# CONFIG_BLK_DEV_SLC90E66 is not set +# CONFIG_BLK_DEV_TRM290 is not set +# CONFIG_BLK_DEV_VIA82CXXX is not set +# CONFIG_IDE_ARM is not set +CONFIG_BLK_DEV_IDEDMA=y +# CONFIG_IDEDMA_IVB is not set +# CONFIG_IDEDMA_AUTO is not set +# CONFIG_BLK_DEV_HD is not set + +# +# SCSI device support +# +# CONFIG_RAID_ATTRS is not set +CONFIG_SCSI=y +CONFIG_SCSI_PROC_FS=y + +# +# SCSI support type (disk, tape, CD-ROM) +# +CONFIG_BLK_DEV_SD=y +# CONFIG_CHR_DEV_ST is not set +# CONFIG_CHR_DEV_OSST is not set +# CONFIG_BLK_DEV_SR is not set +# CONFIG_CHR_DEV_SG is not set +# CONFIG_CHR_DEV_SCH is not set + +# +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs +# +# CONFIG_SCSI_MULTI_LUN is not set +# CONFIG_SCSI_CONSTANTS is not set +# CONFIG_SCSI_LOGGING is not set + +# +# SCSI Transport Attributes +# +# CONFIG_SCSI_SPI_ATTRS is not set +# CONFIG_SCSI_FC_ATTRS is not set +# CONFIG_SCSI_ISCSI_ATTRS is not set + +# +# SCSI low-level drivers +# +# CONFIG_BLK_DEV_3W_XXXX_RAID is not set +# CONFIG_SCSI_3W_9XXX is not set +# CONFIG_SCSI_ARCMSR is not set +# CONFIG_SCSI_ACARD is not set +# CONFIG_SCSI_AACRAID is not set +# CONFIG_SCSI_AIC7XXX is not set +# CONFIG_SCSI_AIC7XXX_OLD is not set +# CONFIG_SCSI_AIC79XX is not set +# CONFIG_SCSI_DPT_I2O is not set +# CONFIG_MEGARAID_NEWGEN is not set +# CONFIG_MEGARAID_LEGACY is not set +# CONFIG_SCSI_SATA is not set +# CONFIG_SCSI_BUSLOGIC is not set +# CONFIG_SCSI_DMX3191D is not set +# CONFIG_SCSI_EATA is not set +# CONFIG_SCSI_FUTURE_DOMAIN is not set +# CONFIG_SCSI_GDTH is not set +# CONFIG_SCSI_IPS is not set +# CONFIG_SCSI_INITIO is not set +# CONFIG_SCSI_INIA100 is not set +# CONFIG_SCSI_SYM53C8XX_2 is not set +# CONFIG_SCSI_IPR is not set +# CONFIG_SCSI_QLOGIC_FC is not set +# CONFIG_SCSI_QLOGIC_1280 is not set +CONFIG_SCSI_QLA2XXX=y +# CONFIG_SCSI_QLA21XX is not set +# CONFIG_SCSI_QLA22XX is not set +# CONFIG_SCSI_QLA2300 is not set +# CONFIG_SCSI_QLA2322 is not set +# CONFIG_SCSI_QLA6312 is not set +# CONFIG_SCSI_QLA24XX is not set +# CONFIG_SCSI_LPFC is not set +# CONFIG_SCSI_DC395x is not set +# CONFIG_SCSI_DC390T is not set +# CONFIG_SCSI_NSP32 is not set +# CONFIG_SCSI_DEBUG is not set + +# +# Multi-device support (RAID and LVM) +# +# CONFIG_MD is not set + +# +# Fusion MPT device support +# +# CONFIG_FUSION is not set +# CONFIG_FUSION_SPI is not set +# CONFIG_FUSION_FC is not set + +# +# IEEE 1394 (FireWire) support +# +CONFIG_IEEE1394=m + +# +# Subsystem Options +# +# CONFIG_IEEE1394_VERBOSEDEBUG is not set +# CONFIG_IEEE1394_OUI_DB is not set +CONFIG_IEEE1394_EXTRA_CONFIG_ROMS=y +CONFIG_IEEE1394_CONFIG_ROM_IP1394=y +# CONFIG_IEEE1394_EXPORT_FULL_API is not set + +# +# Device Drivers +# + +# +# Texas Instruments PCILynx requires I2C +# +CONFIG_IEEE1394_OHCI1394=m + +# +# Protocol Drivers +# +CONFIG_IEEE1394_VIDEO1394=m +CONFIG_IEEE1394_SBP2=m +# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set +CONFIG_IEEE1394_ETH1394=m +CONFIG_IEEE1394_DV1394=m +CONFIG_IEEE1394_RAWIO=m +CONFIG_IEEE1394_CMP=m +CONFIG_IEEE1394_AMDTP=m + +# +# I2O device support +# +# CONFIG_I2O is not set + +# +# Network device support +# +CONFIG_NETDEVICES=y +CONFIG_DUMMY=m +# CONFIG_BONDING is not set +# CONFIG_EQUALIZER is not set +# CONFIG_TUN is not set + +# +# ARCnet devices +# +# CONFIG_ARCNET is not set + +# +# PHY device support +# +# CONFIG_PHYLIB is not set + +# +# Ethernet (10 or 100Mbit) +# +CONFIG_NET_ETHERNET=y +CONFIG_MII=y +# CONFIG_HAPPYMEAL is not set +# CONFIG_SUNGEM is not set +# CONFIG_NET_VENDOR_3COM is not set + +# +# Tulip family network device support +# +# CONFIG_NET_TULIP is not set +# CONFIG_HP100 is not set +# CONFIG_NET_PCI is not set + +# +# Ethernet (1000 Mbit) +# +# CONFIG_ACENIC is not set +# CONFIG_DL2K is not set +# CONFIG_E1000 is not set +# CONFIG_NS83820 is not set +# CONFIG_HAMACHI is not set +# CONFIG_YELLOWFIN is not set +CONFIG_R8169=y +# CONFIG_R8169_NAPI is not set +# CONFIG_SIS190 is not set +# CONFIG_SKGE is not set +# CONFIG_SKY2 is not set +# CONFIG_SK98LIN is not set +# CONFIG_TIGON3 is not set +# CONFIG_BNX2 is not set + +# +# Ethernet (10000 Mbit) +# +# CONFIG_CHELSIO_T1 is not set +# CONFIG_IXGB is not set +# CONFIG_S2IO is not set + +# +# Token Ring devices +# +# CONFIG_TR is not set + +# +# Wireless LAN (non-hamradio) +# +# CONFIG_NET_RADIO is not set + +# +# Wan interfaces +# +# CONFIG_WAN is not set +# CONFIG_FDDI is not set +# CONFIG_HIPPI is not set +# CONFIG_PPP is not set +# CONFIG_SLIP is not set +# CONFIG_NET_FC is not set +# CONFIG_SHAPER is not set +# CONFIG_NETCONSOLE is not set +# CONFIG_KGDBOE is not set +# CONFIG_NETPOLL is not set +# CONFIG_NETPOLL_RX is not set +# CONFIG_NETPOLL_TRAP is not set +# CONFIG_NET_POLL_CONTROLLER is not set + +# +# ISDN subsystem +# +# CONFIG_ISDN is not set + +# +# Telephony Support +# +# CONFIG_PHONE is not set + +# +# Input device support +# +CONFIG_INPUT=y + +# +# Userland interfaces +# +# CONFIG_INPUT_MOUSEDEV is not set +# CONFIG_INPUT_JOYDEV is not set +# CONFIG_INPUT_TSDEV is not set +# CONFIG_INPUT_EVDEV is not set +# CONFIG_INPUT_EVBUG is not set + +# +# Input Device Drivers +# +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_INPUT_JOYSTICK is not set +# CONFIG_INPUT_TOUCHSCREEN is not set +# CONFIG_INPUT_MISC is not set + +# +# Hardware I/O ports +# +# CONFIG_SERIO is not set +# CONFIG_GAMEPORT is not set + +# +# Character devices +# +CONFIG_VT=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +# CONFIG_SERIAL_NONSTANDARD is not set + +# +# Serial drivers +# +# CONFIG_SERIAL_8250 is not set + +# +# Non-8250 serial port support +# +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_SERIAL_VR41XX=y +CONFIG_SERIAL_VR41XX_CONSOLE=y +# CONFIG_SERIAL_JSM is not set +CONFIG_UNIX98_PTYS=y +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=256 + +# +# IPMI +# +# CONFIG_IPMI_HANDLER is not set + +# +# Watchdog Cards +# +# CONFIG_WATCHDOG is not set +# CONFIG_RTC is not set +# CONFIG_GEN_RTC is not set +# CONFIG_RTC_VR41XX is not set +# CONFIG_DTLK is not set +# CONFIG_R3964 is not set +# CONFIG_APPLICOM is not set +# CONFIG_TANBAC_TB0219 is not set + +# +# Ftape, the floppy tape device driver +# +# CONFIG_DRM is not set +CONFIG_GPIO_VR41XX=y +# CONFIG_RAW_DRIVER is not set + +# +# TPM devices +# +# CONFIG_TCG_TPM is not set + +# +# I2C support +# +# CONFIG_I2C is not set + +# +# Dallas's 1-wire bus +# +# CONFIG_W1 is not set + +# +# Hardware Monitoring support +# +# CONFIG_HWMON is not set +# CONFIG_HWMON_VID is not set + +# +# Misc devices +# + +# +# Multimedia Capabilities Port drivers +# + +# +# Multimedia devices +# +# CONFIG_VIDEO_DEV is not set + +# +# Digital Video Broadcasting Devices +# +# CONFIG_DVB is not set + +# +# Graphics support +# +# CONFIG_FB is not set + +# +# Console display driver support +# +# CONFIG_VGA_CONSOLE is not set +CONFIG_DUMMY_CONSOLE=y + +# +# Speakup console speech +# +# CONFIG_SPEAKUP is not set + +# +# Sound +# +# CONFIG_SOUND is not set + +# +# USB support +# +CONFIG_USB_ARCH_HAS_HCD=y +CONFIG_USB_ARCH_HAS_OHCI=y +CONFIG_USB=m +# CONFIG_USB_DEBUG is not set + +# +# Miscellaneous USB options +# +# CONFIG_USB_DEVICEFS is not set +# CONFIG_USB_BANDWIDTH is not set +# CONFIG_USB_DYNAMIC_MINORS is not set +# CONFIG_USB_OTG is not set + +# +# USB Host Controller Drivers +# +CONFIG_USB_EHCI_HCD=m +# CONFIG_USB_EHCI_SPLIT_ISO is not set +# CONFIG_USB_EHCI_ROOT_HUB_TT is not set +# CONFIG_USB_ISP116X_HCD is not set +CONFIG_USB_OHCI_HCD=m +# CONFIG_USB_OHCI_BIG_ENDIAN is not set +CONFIG_USB_OHCI_LITTLE_ENDIAN=y +# CONFIG_USB_UHCI_HCD is not set +# CONFIG_USB_SL811_HCD is not set + +# +# USB Device Class drivers +# +# CONFIG_USB_BLUETOOTH_TTY is not set +# CONFIG_USB_ACM is not set +# CONFIG_USB_PRINTER is not set + +# +# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information +# +CONFIG_USB_STORAGE=m +# CONFIG_USB_STORAGE_DEBUG is not set +# CONFIG_USB_STORAGE_DATAFAB is not set +# CONFIG_USB_STORAGE_FREECOM is not set +# CONFIG_USB_STORAGE_ISD200 is not set +# CONFIG_USB_STORAGE_DPCM is not set +# CONFIG_USB_STORAGE_USBAT is not set +# CONFIG_USB_STORAGE_SDDR09 is not set +# CONFIG_USB_STORAGE_SDDR55 is not set +# CONFIG_USB_STORAGE_JUMPSHOT is not set + +# +# USB Input Devices +# +CONFIG_USB_HID=m +CONFIG_USB_HIDINPUT=y +# CONFIG_HID_FF is not set +# CONFIG_USB_HIDDEV is not set + +# +# USB HID Boot Protocol drivers +# +# CONFIG_USB_KBD is not set +# CONFIG_USB_MOUSE is not set +# CONFIG_USB_AIPTEK is not set +# CONFIG_USB_WACOM is not set +# CONFIG_USB_ACECAD is not set +# CONFIG_USB_KBTAB is not set +# CONFIG_USB_POWERMATE is not set +# CONFIG_USB_MTOUCH is not set +# CONFIG_USB_ITMTOUCH is not set +# CONFIG_USB_EGALAX is not set +# CONFIG_USB_YEALINK is not set +# CONFIG_USB_XPAD is not set +# CONFIG_USB_ATI_REMOTE is not set +# CONFIG_USB_KEYSPAN_REMOTE is not set +# CONFIG_USB_APPLETOUCH is not set + +# +# USB Imaging devices +# +# CONFIG_USB_MDC800 is not set +# CONFIG_USB_MICROTEK is not set + +# +# USB Multimedia devices +# +# CONFIG_USB_DABUSB is not set + +# +# Video4Linux support is needed for USB Multimedia device support +# + +# +# USB Network Adapters +# +# CONFIG_USB_CATC is not set +# CONFIG_USB_KAWETH is not set +# CONFIG_USB_PEGASUS is not set +# CONFIG_USB_RTL8150 is not set +# CONFIG_USB_USBNET is not set +CONFIG_USB_MON=y + +# +# USB port drivers +# + +# +# USB Serial Converter support +# +# CONFIG_USB_SERIAL is not set + +# +# USB Miscellaneous drivers +# +# CONFIG_USB_EMI62 is not set +# CONFIG_USB_EMI26 is not set +# CONFIG_USB_AUERSWALD is not set +# CONFIG_USB_RIO500 is not set +# CONFIG_USB_LEGOTOWER is not set +# CONFIG_USB_LCD is not set +# CONFIG_USB_LED is not set +# CONFIG_USB_CYTHERM is not set +# CONFIG_USB_GOTEMP is not set +# CONFIG_USB_PHIDGETKIT is not set +# CONFIG_USB_PHIDGETSERVO is not set +# CONFIG_USB_IDMOUSE is not set +# CONFIG_USB_SISUSBVGA is not set +# CONFIG_USB_LD is not set + +# +# USB DSL modem support +# + +# +# USB Gadget Support +# +# CONFIG_USB_GADGET is not set + +# +# MMC/SD Card support +# +# CONFIG_MMC is not set + +# +# InfiniBand support +# +# CONFIG_INFINIBAND is not set + +# +# SN Devices +# + +# +# Distributed Lock Manager +# +# CONFIG_DLM is not set + +# +# File systems +# +CONFIG_EXT2_FS=y +# CONFIG_EXT2_FS_XATTR is not set +# CONFIG_EXT2_FS_XIP is not set +# CONFIG_EXT3_FS is not set +# CONFIG_REISER4_FS is not set +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +# CONFIG_FS_POSIX_ACL is not set + +# +# XFS support +# +CONFIG_XFS_FS=y +# CONFIG_XFS_RT is not set +CONFIG_XFS_QUOTA=y +# CONFIG_XFS_SECURITY is not set +CONFIG_XFS_POSIX_ACL=y +# CONFIG_OCFS2_FS is not set +# CONFIG_MINIX_FS is not set +CONFIG_ROMFS_FS=m +CONFIG_INOTIFY=y +# CONFIG_QUOTA is not set +CONFIG_QUOTACTL=y +# CONFIG_DNOTIFY is not set +# CONFIG_AUTOFS_FS is not set +CONFIG_AUTOFS4_FS=y +# CONFIG_FUSE_FS is not set + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +# CONFIG_MSDOS_FS is not set +# CONFIG_VFAT_FS is not set +# CONFIG_NTFS_FS is not set + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_PROC_KCORE=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +# CONFIG_HUGETLB_PAGE is not set +CONFIG_RAMFS=y +# CONFIG_CONFIGFS_FS is not set +# CONFIG_RELAYFS_FS is not set + +# +# Miscellaneous filesystems +# +# CONFIG_ADFS_FS is not set +# CONFIG_AFFS_FS is not set +# CONFIG_ASFS_FS is not set +# CONFIG_HFS_FS is not set +# CONFIG_HFSPLUS_FS is not set +# CONFIG_BEFS_FS is not set +# CONFIG_BFS_FS is not set +# CONFIG_EFS_FS is not set +CONFIG_CRAMFS=m +# CONFIG_VXFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set + +# +# Network File Systems +# +CONFIG_NFS_FS=y +CONFIG_NFS_V3=y +# CONFIG_NFS_V3_ACL is not set +# CONFIG_NFS_V4 is not set +# CONFIG_NFS_DIRECTIO is not set +# CONFIG_NFSD is not set +CONFIG_ROOT_NFS=y +CONFIG_LOCKD=y +CONFIG_LOCKD_V4=y +CONFIG_NFS_COMMON=y +CONFIG_SUNRPC=y +# CONFIG_RPCSEC_GSS_KRB5 is not set +# CONFIG_RPCSEC_GSS_SPKM3 is not set +# CONFIG_SMB_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set +# CONFIG_9P_FS is not set + +# +# Partition Types +# +# CONFIG_PARTITION_ADVANCED is not set +CONFIG_MSDOS_PARTITION=y + +# +# Native Language Support +# +# CONFIG_NLS is not set + +# +# Kernel hacking +# +# CONFIG_PRINTK_TIME is not set +# CONFIG_DEBUG_KERNEL is not set +CONFIG_LOG_BUF_SHIFT=14 +CONFIG_CROSSCOMPILE=y +CONFIG_CMDLINE="mem=64M console=ttyVR0,115200 ip=any root=/dev/nfs" + +# +# Security options +# +CONFIG_KEYS=y +CONFIG_KEYS_DEBUG_PROC_KEYS=y +# CONFIG_SECURITY is not set + +# +# Cryptographic options +# +# CONFIG_CRYPTO is not set + +# +# Hardware crypto devices +# + +# +# Library routines +# +# CONFIG_CRC_CCITT is not set +# CONFIG_CRC16 is not set +CONFIG_CRC32=y +# CONFIG_LIBCRC32C is not set +CONFIG_ZLIB_INFLATE=m +CONFIG_GENERIC_HARDIRQS=y +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_ISA_DMA_API=y diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile index c53e4cb..83d81c9 100644 --- a/arch/mips/pci/Makefile +++ b/arch/mips/pci/Makefile @@ -48,6 +48,7 @@ obj-$(CONFIG_SIBYTE_SB1250) += fixup-sb1250.o pci-sb1250.o obj-$(CONFIG_SNI_RM200_PCI) += fixup-sni.o ops-sni.o obj-$(CONFIG_TANBAC_TB0219) += fixup-tb0219.o obj-$(CONFIG_TANBAC_TB0226) += fixup-tb0226.o +obj-$(CONFIG_TANBAC_TB0287) += fixup-tb0287.o obj-$(CONFIG_TOSHIBA_JMR3927) += fixup-jmr3927.o pci-jmr3927.o obj-$(CONFIG_TOSHIBA_RBTX4927) += fixup-rbtx4927.o ops-tx4927.o obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o diff --git a/arch/mips/pci/fixup-tb0287.c b/arch/mips/pci/fixup-tb0287.c new file mode 100644 index 0000000..8436d7f --- /dev/null +++ b/arch/mips/pci/fixup-tb0287.c @@ -0,0 +1,65 @@ +/* + * fixup-tb0287.c, The TANBAC TB0287 specific PCI fixups. + * + * Copyright (C) 2005 Yoichi Yuasa + * + * 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 +#include + +#include + +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) +{ + unsigned char bus; + int irq = -1; + + bus = dev->bus->number; + if (bus == 0) { + switch (slot) { + case 16: + irq = TB0287_SM501_IRQ; + break; + case 17: + irq = TB0287_SIL680A_IRQ; + break; + default: + break; + } + } else if (bus == 1) { + switch (PCI_SLOT(dev->devfn)) { + case 0: + irq = TB0287_PCI_SLOT_IRQ; + break; + case 2: + case 3: + irq = TB0287_RTL8110_IRQ; + break; + default: + break; + } + } else if (bus > 1) { + irq = TB0287_PCI_SLOT_IRQ; + } + + return irq; +} + +/* Do platform specific device initialization at pci_enable_device() time */ +int pcibios_plat_dev_init(struct pci_dev *dev) +{ + return 0; +} diff --git a/include/asm-mips/vr41xx/tb0287.h b/include/asm-mips/vr41xx/tb0287.h new file mode 100644 index 0000000..dd98323 --- /dev/null +++ b/include/asm-mips/vr41xx/tb0287.h @@ -0,0 +1,43 @@ +/* + * tb0287.h, Include file for TANBAC TB0287 mini-ITX board. + * + * Copyright (C) 2005 Media Lab Inc. + * + * This code is largely based on tb0219.h. + * + * 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 + */ +#ifndef __TANBAC_TB0287_H +#define __TANBAC_TB0287_H + +#include + +/* + * General-Purpose I/O Pin Number + */ +#define TB0287_PCI_SLOT_PIN 2 +#define TB0287_SM501_PIN 3 +#define TB0287_SIL680A_PIN 8 +#define TB0287_RTL8110_PIN 13 + +/* + * Interrupt Number + */ +#define TB0287_PCI_SLOT_IRQ GIU_IRQ(TB0287_PCI_SLOT_PIN) +#define TB0287_SM501_IRQ GIU_IRQ(TB0287_SM501_PIN) +#define TB0287_SIL680A_IRQ GIU_IRQ(TB0287_SIL680A_PIN) +#define TB0287_RTL8110_IRQ GIU_IRQ(TB0287_RTL8110_PIN) + +#endif /* __TANBAC_TB0287_H */ -- cgit v0.10.2 From 4c7fc7220f6a3cce9b3f4bd66362176df67df577 Mon Sep 17 00:00:00 2001 From: Andrea Arcangeli Date: Fri, 9 Sep 2005 13:01:51 -0700 Subject: [PATCH] i386: seccomp fix for auditing/ptrace This is the same issue as ppc64 before, when returning to userland we shouldn't re-compute the seccomp check or the task could be killed during sigreturn when orig_eax is overwritten by the sigreturn syscall. This was found by Roland. This was harmless from a security standpoint, but some i686 users reported failures with auditing enabled system wide (some distro surprisingly makes it the default) and I reproduced it too by keeping the whole workload under strace -f. Patch is tested and works for me under strace -f. nobody@athlon:~/cpushare> strace -o /tmp/o -f python seccomp_test.py make: Nothing to be done for `seccomp_test'. Starting computing some malicious bytecode init load start stop receive_data failure kill exit_code 0 signal 9 The malicious bytecode has been killed successfully by seccomp Starting computing some safe bytecode init load start stop 174 counts kill exit_code 0 signal 0 The seccomp_test.py completed successfully, thank you for testing. (akpm: collaterally cleaned up a bit of do_syscall_trace() too) Signed-off-by: Andrea Arcangeli Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c index 34098020..7b6368b 100644 --- a/arch/i386/kernel/ptrace.c +++ b/arch/i386/kernel/ptrace.c @@ -694,17 +694,22 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code) __attribute__((regparm(3))) int do_syscall_trace(struct pt_regs *regs, int entryexit) { - int is_sysemu = test_thread_flag(TIF_SYSCALL_EMU), ret = 0; - /* With TIF_SYSCALL_EMU set we want to ignore TIF_SINGLESTEP for syscall - * interception. */ + int is_sysemu = test_thread_flag(TIF_SYSCALL_EMU); + /* + * With TIF_SYSCALL_EMU set we want to ignore TIF_SINGLESTEP for syscall + * interception + */ int is_singlestep = !is_sysemu && test_thread_flag(TIF_SINGLESTEP); + int ret = 0; /* do the secure computing check first */ - secure_computing(regs->orig_eax); + if (!entryexit) + secure_computing(regs->orig_eax); if (unlikely(current->audit_context)) { if (entryexit) - audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), regs->eax); + audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), + regs->eax); /* Debug traps, when using PTRACE_SINGLESTEP, must be sent only * on the syscall exit path. Normally, when TIF_SYSCALL_AUDIT is * not used, entry.S will call us only on syscall exit, not @@ -738,7 +743,7 @@ int do_syscall_trace(struct pt_regs *regs, int entryexit) /* the 0x80 provides a way for the tracing parent to distinguish between a syscall stop and SIGTRAP delivery */ /* Note that the debugger could change the result of test_thread_flag!*/ - ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0)); + ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) ? 0x80:0)); /* * this isn't the same as continuing with a signal, but it will do @@ -750,7 +755,7 @@ int do_syscall_trace(struct pt_regs *regs, int entryexit) current->exit_code = 0; } ret = is_sysemu; - out: +out: if (unlikely(current->audit_context) && !entryexit) audit_syscall_entry(current, AUDIT_ARCH_I386, regs->orig_eax, regs->ebx, regs->ecx, regs->edx, regs->esi); @@ -759,6 +764,7 @@ int do_syscall_trace(struct pt_regs *regs, int entryexit) regs->orig_eax = -1; /* force skip of syscall restarting */ if (unlikely(current->audit_context)) - audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), regs->eax); + audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), + regs->eax); return 1; } -- cgit v0.10.2 From fdf26d933a8171c2a5bd35b4a5ca3b099a216a35 Mon Sep 17 00:00:00 2001 From: Ashok Raj Date: Fri, 9 Sep 2005 13:01:52 -0700 Subject: [PATCH] x86_64: Don't do broadcast IPIs when hotplug is enabled in flat mode. The use of non-shortcut version of routines breaking CPU hotplug. The option to select this via cmdline also is deleted with the physflat patch, hence directly placing this code under CONFIG_HOTPLUG_CPU. We dont want to use broadcast mode IPI's when hotplug is enabled. This causes bad effects in send IPI to a cpu that is offline which can trip when the cpu is in the process of being kicked alive. Signed-off-by: Ashok Raj Acked-by: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/x86_64/kernel/genapic_flat.c b/arch/x86_64/kernel/genapic_flat.c index adc9628..6d57da9 100644 --- a/arch/x86_64/kernel/genapic_flat.c +++ b/arch/x86_64/kernel/genapic_flat.c @@ -78,8 +78,18 @@ static void flat_send_IPI_mask(cpumask_t cpumask, int vector) static void flat_send_IPI_allbutself(int vector) { +#ifndef CONFIG_HOTPLUG_CPU if (((num_online_cpus()) - 1) >= 1) __send_IPI_shortcut(APIC_DEST_ALLBUT, vector,APIC_DEST_LOGICAL); +#else + cpumask_t allbutme = cpu_online_map; + int me = get_cpu(); /* Ensure we are not preempted when we clear */ + cpu_clear(me, allbutme); + + if (!cpus_empty(allbutme)) + flat_send_IPI_mask(allbutme, vector); + put_cpu(); +#endif } static void flat_send_IPI_all(int vector) -- cgit v0.10.2 From 092c948811359d8715790af0eedefc7dff1cd619 Mon Sep 17 00:00:00 2001 From: Ashok Raj Date: Fri, 9 Sep 2005 13:01:53 -0700 Subject: [PATCH] x86_64: Don't call enforce_max_cpus when hotplug is enabled enforce_max_cpus nukes out cpu_present_map and cpu_possible_map making it impossible to add new cpus in the system. Since it doesnt provide any additional value apart this call and reference is removed. Signed-off-by: Ashok Raj Acked-by: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c index 90aeccd..4fb34b5 100644 --- a/arch/x86_64/kernel/smpboot.c +++ b/arch/x86_64/kernel/smpboot.c @@ -894,23 +894,6 @@ static __init void disable_smp(void) cpu_set(0, cpu_core_map[0]); } -/* - * Handle user cpus=... parameter. - */ -static __init void enforce_max_cpus(unsigned max_cpus) -{ - int i, k; - k = 0; - for (i = 0; i < NR_CPUS; i++) { - if (!cpu_possible(i)) - continue; - if (++k > max_cpus) { - cpu_clear(i, cpu_possible_map); - cpu_clear(i, cpu_present_map); - } - } -} - #ifdef CONFIG_HOTPLUG_CPU /* * cpu_possible_map should be static, it cannot change as cpu's @@ -999,8 +982,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus) current_cpu_data = boot_cpu_data; current_thread_info()->cpu = 0; /* needed? */ - enforce_max_cpus(max_cpus); - #ifdef CONFIG_HOTPLUG_CPU prefill_possible_map(); #endif -- cgit v0.10.2 From 69ac59647e66c1b53fb98fe8b6d0f2099cffad60 Mon Sep 17 00:00:00 2001 From: Chaskiel Grundman Date: Fri, 9 Sep 2005 13:01:54 -0700 Subject: [PATCH] alpha: process_reloc_for_got confuses r_offset and r_addend arch/alpha/kernel/module.c:process_reloc_for_got(), which figures out how big the .got section for a module should be, appears to be confusing r_offset (the file offset that the relocation needs to be applied to) with r_addend (the offset of the relocation's actual target address from the address of the relocation's symbol). Because of this, one .got entry is allocated for each relocation instead of one each unique symbol/addend. In the module I am working with, this causes the .got section to be almost 10 times larger than it needs to be (75544 bytes instead of 7608 bytes). As the .got is accessed with global-pointer-relative instructions, it needs to be within the 64k gp "zone", and a 75544 byte .got clearly does not fit. The result of this is that relocation overflows are detected during module load and the load is aborted. Change struct got_entry/process_reloc_for_got to fix this. Acked-by: Richard Henderson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c index fc271e3..aac6d4b 100644 --- a/arch/alpha/kernel/module.c +++ b/arch/alpha/kernel/module.c @@ -47,7 +47,7 @@ module_free(struct module *mod, void *module_region) struct got_entry { struct got_entry *next; - Elf64_Addr r_offset; + Elf64_Sxword r_addend; int got_offset; }; @@ -57,14 +57,14 @@ process_reloc_for_got(Elf64_Rela *rela, { unsigned long r_sym = ELF64_R_SYM (rela->r_info); unsigned long r_type = ELF64_R_TYPE (rela->r_info); - Elf64_Addr r_offset = rela->r_offset; + Elf64_Sxword r_addend = rela->r_addend; struct got_entry *g; if (r_type != R_ALPHA_LITERAL) return; for (g = chains + r_sym; g ; g = g->next) - if (g->r_offset == r_offset) { + if (g->r_addend == r_addend) { if (g->got_offset == 0) { g->got_offset = *poffset; *poffset += 8; @@ -74,7 +74,7 @@ process_reloc_for_got(Elf64_Rela *rela, g = kmalloc (sizeof (*g), GFP_KERNEL); g->next = chains[r_sym].next; - g->r_offset = r_offset; + g->r_addend = r_addend; g->got_offset = *poffset; *poffset += 8; chains[r_sym].next = g; -- cgit v0.10.2 From ff55fe2075e3901db4dbdc00e0b44a71bef97afd Mon Sep 17 00:00:00 2001 From: Jason Baron Date: Fri, 9 Sep 2005 13:01:57 -0700 Subject: [PATCH] pty_chars_in_buffer oops fix The idea of this patch is to lock both sides of a ptmx/pty pair during line discipline changing. This is needed to ensure that say a poll on one side of the pty doesn't occur while the line discipline is actively being changed. This resulted in an oops reported on lkml, see: http://marc.theaimsgroup.com/?l=linux-kernel&m=111342171410005&w=2 A 'hacky' approach was previously implmemented which served to eliminate the poll vs. line discipline changing race. However, this patch takes a more general approach to the issue. The patch only adds locking on a less often used path, the line-discipline changing path, as opposed to locking the ptmx/pty pair on read/write/poll paths. The patch below, takes both ldisc locks in either order b/c the locks are both taken under the same spinlock(). I thought about locking the ptmx/pty separately, such as master always first but that introduces a 3 way deadlock. For example, process 1 does a blocking read on the slave side. Then, process 2 does an ldisc change on the slave side, which acquires the master ldisc lock but not the slave's. Finally, process 3 does a write which blocks on the process 2's ldisc reference. This patch does introduce some changes in semantics. For example, a line discipline change on side 'a' of a ptmx/pty pair, will now wait for a read/write to complete on the other side, or side 'b'. The current behavior is to simply wait for any read/writes on only side 'a', not both sides 'a' and 'b'. I think this behavior makes sense, but I wanted to point it out. I've tested the patch with a bunch of read/write/poll while changing the line discipline out from underneath. This patch obviates the need for the above "hide the problem" patch. Signed-off-by: Jason Baron Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/char/pty.c b/drivers/char/pty.c index da32889..49f3997 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -149,15 +149,14 @@ static int pty_write_room(struct tty_struct *tty) static int pty_chars_in_buffer(struct tty_struct *tty) { struct tty_struct *to = tty->link; - ssize_t (*chars_in_buffer)(struct tty_struct *); int count; /* We should get the line discipline lock for "tty->link" */ - if (!to || !(chars_in_buffer = to->ldisc.chars_in_buffer)) + if (!to || !to->ldisc.chars_in_buffer) return 0; /* The ldisc must report 0 if no characters available to be read */ - count = chars_in_buffer(to); + count = to->ldisc.chars_in_buffer(to); if (tty->driver->subtype == PTY_TYPE_SLAVE) return count; diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 9d65712..6a56ae4 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -469,21 +469,19 @@ static void tty_ldisc_enable(struct tty_struct *tty) static int tty_set_ldisc(struct tty_struct *tty, int ldisc) { - int retval = 0; - struct tty_ldisc o_ldisc; + int retval = 0; + struct tty_ldisc o_ldisc; char buf[64]; int work; unsigned long flags; struct tty_ldisc *ld; + struct tty_struct *o_tty; if ((ldisc < N_TTY) || (ldisc >= NR_LDISCS)) return -EINVAL; restart: - if (tty->ldisc.num == ldisc) - return 0; /* We are already in the desired discipline */ - ld = tty_ldisc_get(ldisc); /* Eduardo Blanco */ /* Cyrus Durgin */ @@ -494,45 +492,74 @@ restart: if (ld == NULL) return -EINVAL; - o_ldisc = tty->ldisc; - tty_wait_until_sent(tty, 0); + if (tty->ldisc.num == ldisc) { + tty_ldisc_put(ldisc); + return 0; + } + + o_ldisc = tty->ldisc; + o_tty = tty->link; + /* * Make sure we don't change while someone holds a * reference to the line discipline. The TTY_LDISC bit * prevents anyone taking a reference once it is clear. * We need the lock to avoid racing reference takers. */ - + spin_lock_irqsave(&tty_ldisc_lock, flags); - if(tty->ldisc.refcount) - { - /* Free the new ldisc we grabbed. Must drop the lock - first. */ + if (tty->ldisc.refcount || (o_tty && o_tty->ldisc.refcount)) { + if(tty->ldisc.refcount) { + /* Free the new ldisc we grabbed. Must drop the lock + first. */ + spin_unlock_irqrestore(&tty_ldisc_lock, flags); + tty_ldisc_put(ldisc); + /* + * There are several reasons we may be busy, including + * random momentary I/O traffic. We must therefore + * retry. We could distinguish between blocking ops + * and retries if we made tty_ldisc_wait() smarter. That + * is up for discussion. + */ + if (wait_event_interruptible(tty_ldisc_wait, tty->ldisc.refcount == 0) < 0) + return -ERESTARTSYS; + goto restart; + } + if(o_tty && o_tty->ldisc.refcount) { + spin_unlock_irqrestore(&tty_ldisc_lock, flags); + tty_ldisc_put(ldisc); + if (wait_event_interruptible(tty_ldisc_wait, o_tty->ldisc.refcount == 0) < 0) + return -ERESTARTSYS; + goto restart; + } + } + + /* if the TTY_LDISC bit is set, then we are racing against another ldisc change */ + + if (!test_bit(TTY_LDISC, &tty->flags)) { spin_unlock_irqrestore(&tty_ldisc_lock, flags); tty_ldisc_put(ldisc); - /* - * There are several reasons we may be busy, including - * random momentary I/O traffic. We must therefore - * retry. We could distinguish between blocking ops - * and retries if we made tty_ldisc_wait() smarter. That - * is up for discussion. - */ - if(wait_event_interruptible(tty_ldisc_wait, tty->ldisc.refcount == 0) < 0) - return -ERESTARTSYS; + ld = tty_ldisc_ref_wait(tty); + tty_ldisc_deref(ld); goto restart; } - clear_bit(TTY_LDISC, &tty->flags); + + clear_bit(TTY_LDISC, &tty->flags); clear_bit(TTY_DONT_FLIP, &tty->flags); + if (o_tty) { + clear_bit(TTY_LDISC, &o_tty->flags); + clear_bit(TTY_DONT_FLIP, &o_tty->flags); + } spin_unlock_irqrestore(&tty_ldisc_lock, flags); - + /* * From this point on we know nobody has an ldisc * usage reference, nor can they obtain one until * we say so later on. */ - + work = cancel_delayed_work(&tty->flip.work); /* * Wait for ->hangup_work and ->flip.work handlers to terminate @@ -583,10 +610,12 @@ restart: */ tty_ldisc_enable(tty); + if (o_tty) + tty_ldisc_enable(o_tty); /* Restart it in case no characters kick it off. Safe if already running */ - if(work) + if (work) schedule_delayed_work(&tty->flip.work, 1); return retval; } -- cgit v0.10.2 From 28254d439b8c65f93cb331f5aa741efa6a8ec62f Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 9 Sep 2005 13:01:58 -0700 Subject: [PATCH] vga text console and stty cols/rows Some people use 66-cells braille devices for reading the console, and hence would like to reduce the width of the screen by using: stty cols 66 However, the vga text console doesn't behave correctly: the 14 first characters of the second line are put on the right of the first line and so forth. Here is a patch to correct that. It corrects the disp_end and offset registers of the vga board on console resize and console switch. On usual screens, you then correctly get a right and/or bottom blank margin. On some laptop panels, the output is resized so that text actually gets magnified, which can be great for some people (see http://dept-info.labri.fr/~thibault/ls.jpg ). Signed-off-by: Samuel Thibault Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index d27fa91..0705cd7 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -497,6 +497,57 @@ static void vgacon_cursor(struct vc_data *c, int mode) } } +static int vgacon_doresize(struct vc_data *c, + unsigned int width, unsigned int height) +{ + unsigned long flags; + unsigned int scanlines = height * c->vc_font.height; + u8 scanlines_lo, r7, vsync_end, mode; + + spin_lock_irqsave(&vga_lock, flags); + + outb_p(VGA_CRTC_MODE, vga_video_port_reg); + mode = inb_p(vga_video_port_val); + + if (mode & 0x04) + scanlines >>= 1; + + scanlines -= 1; + scanlines_lo = scanlines & 0xff; + + outb_p(VGA_CRTC_OVERFLOW, vga_video_port_reg); + r7 = inb_p(vga_video_port_val) & ~0x42; + + if (scanlines & 0x100) + r7 |= 0x02; + if (scanlines & 0x200) + r7 |= 0x40; + + /* deprotect registers */ + outb_p(VGA_CRTC_V_SYNC_END, vga_video_port_reg); + vsync_end = inb_p(vga_video_port_val); + outb_p(VGA_CRTC_V_SYNC_END, vga_video_port_reg); + outb_p(vsync_end & ~0x80, vga_video_port_val); + + outb_p(VGA_CRTC_H_DISP, vga_video_port_reg); + outb_p(width - 1, vga_video_port_val); + outb_p(VGA_CRTC_OFFSET, vga_video_port_reg); + outb_p(width >> 1, vga_video_port_val); + + outb_p(VGA_CRTC_V_DISP_END, vga_video_port_reg); + outb_p(scanlines_lo, vga_video_port_val); + outb_p(VGA_CRTC_OVERFLOW, vga_video_port_reg); + outb_p(r7,vga_video_port_val); + + /* reprotect registers */ + outb_p(VGA_CRTC_V_SYNC_END, vga_video_port_reg); + outb_p(vsync_end, vga_video_port_val); + + spin_unlock_irqrestore(&vga_lock, flags); + + return 0; +} + static int vgacon_switch(struct vc_data *c) { /* @@ -510,9 +561,13 @@ static int vgacon_switch(struct vc_data *c) /* We can only copy out the size of the video buffer here, * otherwise we get into VGA BIOS */ - if (!vga_is_gfx) + if (!vga_is_gfx) { scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf, - c->vc_screenbuf_size > vga_vram_size ? vga_vram_size : c->vc_screenbuf_size); + c->vc_screenbuf_size > vga_vram_size ? + vga_vram_size : c->vc_screenbuf_size); + vgacon_doresize(c, c->vc_cols, c->vc_rows); + } + return 0; /* Redrawing not needed */ } @@ -962,6 +1017,17 @@ static int vgacon_font_get(struct vc_data *c, struct console_font *font) #endif +static int vgacon_resize(struct vc_data *c, unsigned int width, + unsigned int height) +{ + if (width % 2 || width > ORIG_VIDEO_COLS || height > ORIG_VIDEO_LINES) + return -EINVAL; + + if (CON_IS_VISIBLE(c) && !vga_is_gfx) /* who knows */ + vgacon_doresize(c, width, height); + return 0; +} + static int vgacon_scrolldelta(struct vc_data *c, int lines) { if (!lines) /* Turn scrollback off */ @@ -1103,6 +1169,7 @@ const struct consw vga_con = { .con_blank = vgacon_blank, .con_font_set = vgacon_font_set, .con_font_get = vgacon_font_get, + .con_resize = vgacon_resize, .con_set_palette = vgacon_set_palette, .con_scrolldelta = vgacon_scrolldelta, .con_set_origin = vgacon_set_origin, -- cgit v0.10.2 From f76baf9365bd66216bf0e0ebfc083e22eda6215b Mon Sep 17 00:00:00 2001 From: Alexander Krizhanovsky Date: Fri, 9 Sep 2005 13:01:59 -0700 Subject: [PATCH] autofs: fix "busy inodes after umount..." This patch for old autofs (version 3) cleans dentries which are not putted after killing the automount daemon (it's analogue of recent patch for autofs4). Signed-off-by: Alexander Krizhanovsky Cc: Ian Kent Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h index 6171431..990c28d 100644 --- a/fs/autofs/autofs_i.h +++ b/fs/autofs/autofs_i.h @@ -105,6 +105,7 @@ struct autofs_sb_info { struct file *pipe; pid_t oz_pgrp; int catatonic; + struct super_block *sb; unsigned long exp_timeout; ino_t next_dir_ino; struct autofs_wait_queue *queues; /* Wait queue pointer */ @@ -134,7 +135,7 @@ void autofs_hash_insert(struct autofs_dirhash *,struct autofs_dir_ent *); void autofs_hash_delete(struct autofs_dir_ent *); struct autofs_dir_ent *autofs_hash_enum(const struct autofs_dirhash *,off_t *,struct autofs_dir_ent *); void autofs_hash_dputall(struct autofs_dirhash *); -void autofs_hash_nuke(struct autofs_dirhash *); +void autofs_hash_nuke(struct autofs_sb_info *); /* Expiration-handling functions */ diff --git a/fs/autofs/dirhash.c b/fs/autofs/dirhash.c index 448143f..5ccfcf2 100644 --- a/fs/autofs/dirhash.c +++ b/fs/autofs/dirhash.c @@ -232,13 +232,13 @@ void autofs_hash_dputall(struct autofs_dirhash *dh) /* Delete everything. This is used on filesystem destruction, so we make no attempt to keep the pointers valid */ -void autofs_hash_nuke(struct autofs_dirhash *dh) +void autofs_hash_nuke(struct autofs_sb_info *sbi) { int i; struct autofs_dir_ent *ent, *nent; for ( i = 0 ; i < AUTOFS_HASH_SIZE ; i++ ) { - for ( ent = dh->h[i] ; ent ; ent = nent ) { + for ( ent = sbi->dirhash.h[i] ; ent ; ent = nent ) { nent = ent->next; if ( ent->dentry ) dput(ent->dentry); @@ -246,4 +246,5 @@ void autofs_hash_nuke(struct autofs_dirhash *dh) kfree(ent); } } + shrink_dcache_sb(sbi->sb); } diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 4888c1f..65e5ed4 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -27,7 +27,7 @@ static void autofs_put_super(struct super_block *sb) if ( !sbi->catatonic ) autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */ - autofs_hash_nuke(&sbi->dirhash); + autofs_hash_nuke(sbi); for ( n = 0 ; n < AUTOFS_MAX_SYMLINKS ; n++ ) { if ( test_bit(n, sbi->symlink_bitmap) ) kfree(sbi->symlink[n].data); @@ -148,6 +148,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) s->s_magic = AUTOFS_SUPER_MAGIC; s->s_op = &autofs_sops; s->s_time_gran = 1; + sbi->sb = s; root_inode = iget(s, AUTOFS_ROOT_INO); root = d_alloc_root(root_inode); -- cgit v0.10.2 From b0d62e6d5b3318b6b722121d945afa295f7201b5 Mon Sep 17 00:00:00 2001 From: Jason Baron Date: Fri, 9 Sep 2005 13:02:01 -0700 Subject: [PATCH] fix disassociate_ctty vs. fork race Race is as follows. Process A forks process B, both being part of the same session. Then, A calls disassociate_ctty while B forks C: A B ==== ==== fork() copy_signal() dissasociate_ctty() .... attach_pid(p, PIDTYPE_SID, p->signal->session); Now, C can have current->signal->tty pointing to a freed tty structure, as it hasn't yet been added to the session group (to have its controlling tty cleared on the diassociate_ctty() call). This has shown up as an oops but could be even more serious. I haven't tried to create a test case, but a customer has verified that the patch below resolves the issue, which was occuring quite frequently. I'll try and post the test case if i can. The patch simply checks for a NULL tty *after* it has been attached to the proper session group and clears it as necessary. Alternatively, we could simply do the tty assignment after the the process is added to the proper session group. Signed-off-by: Jason Baron Cc: Roland McGrath Cc: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/kernel/fork.c b/kernel/fork.c index dfeadf4..b258020 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1116,6 +1116,9 @@ static task_t *copy_process(unsigned long clone_flags, __get_cpu_var(process_counts)++; } + if (!current->signal->tty && p->signal->tty) + p->signal->tty = NULL; + nr_threads++; total_forks++; write_unlock_irq(&tasklist_lock); -- cgit v0.10.2 From 383f2835eb9afb723af71850037b2f074ac9db60 Mon Sep 17 00:00:00 2001 From: "Chen, Kenneth W" Date: Fri, 9 Sep 2005 13:02:02 -0700 Subject: [PATCH] Prefetch kernel stacks to speed up context switch For architecture like ia64, the switch stack structure is fairly large (currently 528 bytes). For context switch intensive application, we found that significant amount of cache misses occurs in switch_to() function. The following patch adds a hook in the schedule() function to prefetch switch stack structure as soon as 'next' task is determined. This allows maximum overlap in prefetch cache lines for that structure. Signed-off-by: Ken Chen Cc: Ingo Molnar Cc: "Luck, Tony" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S index 3c88210..915e127 100644 --- a/arch/ia64/kernel/entry.S +++ b/arch/ia64/kernel/entry.S @@ -470,6 +470,29 @@ ENTRY(load_switch_stack) br.cond.sptk.many b7 END(load_switch_stack) +GLOBAL_ENTRY(prefetch_stack) + add r14 = -IA64_SWITCH_STACK_SIZE, sp + add r15 = IA64_TASK_THREAD_KSP_OFFSET, in0 + ;; + ld8 r16 = [r15] // load next's stack pointer + lfetch.fault.excl [r14], 128 + ;; + lfetch.fault.excl [r14], 128 + lfetch.fault [r16], 128 + ;; + lfetch.fault.excl [r14], 128 + lfetch.fault [r16], 128 + ;; + lfetch.fault.excl [r14], 128 + lfetch.fault [r16], 128 + ;; + lfetch.fault.excl [r14], 128 + lfetch.fault [r16], 128 + ;; + lfetch.fault [r16], 128 + br.ret.sptk.many rp +END(prefetch_switch_stack) + GLOBAL_ENTRY(execve) mov r15=__NR_execve // put syscall number in place break __BREAK_SYSCALL diff --git a/include/asm-ia64/system.h b/include/asm-ia64/system.h index 33256db..635235f 100644 --- a/include/asm-ia64/system.h +++ b/include/asm-ia64/system.h @@ -275,6 +275,7 @@ extern void ia64_load_extra (struct task_struct *task); */ #define __ARCH_WANT_UNLOCKED_CTXSW +#define ARCH_HAS_PREFETCH_SWITCH_STACK #define ia64_platform_is(x) (strcmp(x, platform_name) == 0) void cpu_idle_wait(void); diff --git a/include/linux/sched.h b/include/linux/sched.h index ea1b5f3..c551e6a 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -604,6 +604,11 @@ extern int groups_search(struct group_info *group_info, gid_t grp); #define GROUP_AT(gi, i) \ ((gi)->blocks[(i)/NGROUPS_PER_BLOCK][(i)%NGROUPS_PER_BLOCK]) +#ifdef ARCH_HAS_PREFETCH_SWITCH_STACK +extern void prefetch_stack(struct task_struct*); +#else +static inline void prefetch_stack(struct task_struct *t) { } +#endif struct audit_context; /* See audit.c */ struct mempolicy; diff --git a/kernel/sched.c b/kernel/sched.c index 18b9552..2632b81 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -2888,6 +2888,7 @@ switch_tasks: if (next == rq->idle) schedstat_inc(rq, sched_goidle); prefetch(next); + prefetch_stack(next); clear_tsk_need_resched(prev); rcu_qsctr_inc(task_cpu(prev)); -- cgit v0.10.2 From fac92becdaecff64dd91daab0292c5131de92f0d Mon Sep 17 00:00:00 2001 From: Andrew Stribblehill Date: Fri, 9 Sep 2005 13:02:04 -0700 Subject: [PATCH] bfs: fix endianness, signedness; add trivial bugfix * Makes BFS code endianness-clean. * Fixes some signedness warnings. * Fixes a problem in fs/bfs/inode.c:164 where inodes not synced to disk don't get fully marked as clean. Here's how to reproduce it: # mount -o loop -t bfs /bfs.img /mnt # df -i /mnt Filesystem Inodes IUsed IFree IUse% Mounted on /bfs.img 48 1 47 3% /mnt # df -k /mnt Filesystem 1K-blocks Used Available Use% Mounted on /bfs.img 512 5 508 1% /mnt # cp 60k-archive.zip /mnt/mt.zip # df -k /mnt Filesystem 1K-blocks Used Available Use% Mounted on /bfs.img 512 65 447 13% /mnt # df -i /mnt Filesystem Inodes IUsed IFree IUse% Mounted on /bfs.img 48 2 46 5% /mnt # rm /mnt/mt.zip # echo $? 0 [If the unlink happens before the buffers flush, the following happens:] # df -i /mnt Filesystem Inodes IUsed IFree IUse% Mounted on /bfs.img 48 2 46 5% /mnt # df -k /mnt Filesystem 1K-blocks Used Available Use% Mounted on /bfs.img 512 65 447 13% /mnt fs/bfs/bfs.h | 1 Signed-off-by: Andrew Stribblehill Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h index 1020dbc..1fbc53f 100644 --- a/fs/bfs/bfs.h +++ b/fs/bfs/bfs.h @@ -20,7 +20,6 @@ struct bfs_sb_info { unsigned long si_lasti; unsigned long * si_imap; struct buffer_head * si_sbh; /* buffer header w/superblock */ - struct bfs_super_block * si_bfs_sb; /* superblock in si_sbh->b_data */ }; /* diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c index 5a1e5ce..e240c33 100644 --- a/fs/bfs/dir.c +++ b/fs/bfs/dir.c @@ -2,6 +2,7 @@ * fs/bfs/dir.c * BFS directory operations. * Copyright (C) 1999,2000 Tigran Aivazian + * Made endianness-clean by Andrew Stribblehill 2005 */ #include @@ -20,9 +21,9 @@ #define dprintf(x...) #endif -static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int ino); +static int bfs_add_entry(struct inode * dir, const unsigned char * name, int namelen, int ino); static struct buffer_head * bfs_find_entry(struct inode * dir, - const char * name, int namelen, struct bfs_dirent ** res_dir); + const unsigned char * name, int namelen, struct bfs_dirent ** res_dir); static int bfs_readdir(struct file * f, void * dirent, filldir_t filldir) { @@ -53,7 +54,7 @@ static int bfs_readdir(struct file * f, void * dirent, filldir_t filldir) de = (struct bfs_dirent *)(bh->b_data + offset); if (de->ino) { int size = strnlen(de->name, BFS_NAMELEN); - if (filldir(dirent, de->name, size, f->f_pos, de->ino, DT_UNKNOWN) < 0) { + if (filldir(dirent, de->name, size, f->f_pos, le16_to_cpu(de->ino), DT_UNKNOWN) < 0) { brelse(bh); unlock_kernel(); return 0; @@ -107,7 +108,7 @@ static int bfs_create(struct inode * dir, struct dentry * dentry, int mode, inode->i_mapping->a_ops = &bfs_aops; inode->i_mode = mode; inode->i_ino = ino; - BFS_I(inode)->i_dsk_ino = ino; + BFS_I(inode)->i_dsk_ino = cpu_to_le16(ino); BFS_I(inode)->i_sblock = 0; BFS_I(inode)->i_eblock = 0; insert_inode_hash(inode); @@ -139,7 +140,7 @@ static struct dentry * bfs_lookup(struct inode * dir, struct dentry * dentry, st lock_kernel(); bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); if (bh) { - unsigned long ino = le32_to_cpu(de->ino); + unsigned long ino = (unsigned long)le16_to_cpu(de->ino); brelse(bh); inode = iget(dir->i_sb, ino); if (!inode) { @@ -183,7 +184,7 @@ static int bfs_unlink(struct inode * dir, struct dentry * dentry) inode = dentry->d_inode; lock_kernel(); bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); - if (!bh || de->ino != inode->i_ino) + if (!bh || le16_to_cpu(de->ino) != inode->i_ino) goto out_brelse; if (!inode->i_nlink) { @@ -224,7 +225,7 @@ static int bfs_rename(struct inode * old_dir, struct dentry * old_dentry, old_dentry->d_name.name, old_dentry->d_name.len, &old_de); - if (!old_bh || old_de->ino != old_inode->i_ino) + if (!old_bh || le16_to_cpu(old_de->ino) != old_inode->i_ino) goto end_rename; error = -EPERM; @@ -270,7 +271,7 @@ struct inode_operations bfs_dir_inops = { .rename = bfs_rename, }; -static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int ino) +static int bfs_add_entry(struct inode * dir, const unsigned char * name, int namelen, int ino) { struct buffer_head * bh; struct bfs_dirent * de; @@ -304,7 +305,7 @@ static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int } dir->i_mtime = CURRENT_TIME_SEC; mark_inode_dirty(dir); - de->ino = ino; + de->ino = cpu_to_le16((u16)ino); for (i=0; iname[i] = (i < namelen) ? name[i] : 0; mark_buffer_dirty(bh); @@ -317,7 +318,7 @@ static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int return -ENOSPC; } -static inline int bfs_namecmp(int len, const char * name, const char * buffer) +static inline int bfs_namecmp(int len, const unsigned char * name, const char * buffer) { if (len < BFS_NAMELEN && buffer[len]) return 0; @@ -325,7 +326,7 @@ static inline int bfs_namecmp(int len, const char * name, const char * buffer) } static struct buffer_head * bfs_find_entry(struct inode * dir, - const char * name, int namelen, struct bfs_dirent ** res_dir) + const unsigned char * name, int namelen, struct bfs_dirent ** res_dir) { unsigned long block, offset; struct buffer_head * bh; @@ -346,7 +347,7 @@ static struct buffer_head * bfs_find_entry(struct inode * dir, } de = (struct bfs_dirent *)(bh->b_data + offset); offset += BFS_DIRENT_SIZE; - if (de->ino && bfs_namecmp(namelen, name, de->name)) { + if (le16_to_cpu(de->ino) && bfs_namecmp(namelen, name, de->name)) { *res_dir = de; return bh; } diff --git a/fs/bfs/file.c b/fs/bfs/file.c index 747fd1e..807723b 100644 --- a/fs/bfs/file.c +++ b/fs/bfs/file.c @@ -40,8 +40,8 @@ static int bfs_move_block(unsigned long from, unsigned long to, struct super_blo return 0; } -static int bfs_move_blocks(struct super_block *sb, unsigned long start, unsigned long end, - unsigned long where) +static int bfs_move_blocks(struct super_block *sb, unsigned long start, + unsigned long end, unsigned long where) { unsigned long i; @@ -57,20 +57,21 @@ static int bfs_move_blocks(struct super_block *sb, unsigned long start, unsigned static int bfs_get_block(struct inode * inode, sector_t block, struct buffer_head * bh_result, int create) { - long phys; + unsigned long phys; int err; struct super_block *sb = inode->i_sb; struct bfs_sb_info *info = BFS_SB(sb); struct bfs_inode_info *bi = BFS_I(inode); struct buffer_head *sbh = info->si_sbh; - if (block < 0 || block > info->si_blocks) + if (block > info->si_blocks) return -EIO; phys = bi->i_sblock + block; if (!create) { if (phys <= bi->i_eblock) { - dprintf("c=%d, b=%08lx, phys=%08lx (granted)\n", create, block, phys); + dprintf("c=%d, b=%08lx, phys=%09lx (granted)\n", + create, (unsigned long)block, phys); map_bh(bh_result, sb, phys); } return 0; @@ -80,7 +81,7 @@ static int bfs_get_block(struct inode * inode, sector_t block, of blocks allocated for this file, we can grant it */ if (inode->i_size && phys <= bi->i_eblock) { dprintf("c=%d, b=%08lx, phys=%08lx (interim block granted)\n", - create, block, phys); + create, (unsigned long)block, phys); map_bh(bh_result, sb, phys); return 0; } @@ -88,11 +89,12 @@ static int bfs_get_block(struct inode * inode, sector_t block, /* the rest has to be protected against itself */ lock_kernel(); - /* if the last data block for this file is the last allocated block, we can - extend the file trivially, without moving it anywhere */ + /* if the last data block for this file is the last allocated + block, we can extend the file trivially, without moving it + anywhere */ if (bi->i_eblock == info->si_lf_eblk) { dprintf("c=%d, b=%08lx, phys=%08lx (simple extension)\n", - create, block, phys); + create, (unsigned long)block, phys); map_bh(bh_result, sb, phys); info->si_freeb -= phys - bi->i_eblock; info->si_lf_eblk = bi->i_eblock = phys; @@ -114,7 +116,8 @@ static int bfs_get_block(struct inode * inode, sector_t block, } else err = 0; - dprintf("c=%d, b=%08lx, phys=%08lx (moved)\n", create, block, phys); + dprintf("c=%d, b=%08lx, phys=%08lx (moved)\n", + create, (unsigned long)block, phys); bi->i_sblock = phys; phys += block; info->si_lf_eblk = bi->i_eblock = phys; diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index 628c2c1..c7b39aa2 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c @@ -3,6 +3,8 @@ * BFS superblock and inode operations. * Copyright (C) 1999,2000 Tigran Aivazian * From fs/minix, Copyright (C) 1991, 1992 Linus Torvalds. + * + * Made endianness-clean by Andrew Stribblehill , 2005. */ #include @@ -54,46 +56,50 @@ static void bfs_read_inode(struct inode * inode) off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; di = (struct bfs_inode *)bh->b_data + off; - inode->i_mode = 0x0000FFFF & di->i_mode; - if (di->i_vtype == BFS_VDIR) { + inode->i_mode = 0x0000FFFF & le32_to_cpu(di->i_mode); + if (le32_to_cpu(di->i_vtype) == BFS_VDIR) { inode->i_mode |= S_IFDIR; inode->i_op = &bfs_dir_inops; inode->i_fop = &bfs_dir_operations; - } else if (di->i_vtype == BFS_VREG) { + } else if (le32_to_cpu(di->i_vtype) == BFS_VREG) { inode->i_mode |= S_IFREG; inode->i_op = &bfs_file_inops; inode->i_fop = &bfs_file_operations; inode->i_mapping->a_ops = &bfs_aops; } - inode->i_uid = di->i_uid; - inode->i_gid = di->i_gid; - inode->i_nlink = di->i_nlink; + BFS_I(inode)->i_sblock = le32_to_cpu(di->i_sblock); + BFS_I(inode)->i_eblock = le32_to_cpu(di->i_eblock); + inode->i_uid = le32_to_cpu(di->i_uid); + inode->i_gid = le32_to_cpu(di->i_gid); + inode->i_nlink = le32_to_cpu(di->i_nlink); inode->i_size = BFS_FILESIZE(di); inode->i_blocks = BFS_FILEBLOCKS(di); + if (inode->i_size || inode->i_blocks) dprintf("Registered inode with %lld size, %ld blocks\n", inode->i_size, inode->i_blocks); inode->i_blksize = PAGE_SIZE; - inode->i_atime.tv_sec = di->i_atime; - inode->i_mtime.tv_sec = di->i_mtime; - inode->i_ctime.tv_sec = di->i_ctime; + inode->i_atime.tv_sec = le32_to_cpu(di->i_atime); + inode->i_mtime.tv_sec = le32_to_cpu(di->i_mtime); + inode->i_ctime.tv_sec = le32_to_cpu(di->i_ctime); inode->i_atime.tv_nsec = 0; inode->i_mtime.tv_nsec = 0; inode->i_ctime.tv_nsec = 0; - BFS_I(inode)->i_dsk_ino = di->i_ino; /* can be 0 so we store a copy */ - BFS_I(inode)->i_sblock = di->i_sblock; - BFS_I(inode)->i_eblock = di->i_eblock; + BFS_I(inode)->i_dsk_ino = le16_to_cpu(di->i_ino); /* can be 0 so we store a copy */ brelse(bh); } static int bfs_write_inode(struct inode * inode, int unused) { - unsigned long ino = inode->i_ino; + unsigned int ino = (u16)inode->i_ino; + unsigned long i_sblock; struct bfs_inode * di; struct buffer_head * bh; int block, off; + dprintf("ino=%08x\n", ino); + if (ino < BFS_ROOT_INO || ino > BFS_SB(inode->i_sb)->si_lasti) { - printf("Bad inode number %s:%08lx\n", inode->i_sb->s_id, ino); + printf("Bad inode number %s:%08x\n", inode->i_sb->s_id, ino); return -EIO; } @@ -101,7 +107,7 @@ static int bfs_write_inode(struct inode * inode, int unused) block = (ino - BFS_ROOT_INO)/BFS_INODES_PER_BLOCK + 1; bh = sb_bread(inode->i_sb, block); if (!bh) { - printf("Unable to read inode %s:%08lx\n", inode->i_sb->s_id, ino); + printf("Unable to read inode %s:%08x\n", inode->i_sb->s_id, ino); unlock_kernel(); return -EIO; } @@ -109,24 +115,26 @@ static int bfs_write_inode(struct inode * inode, int unused) off = (ino - BFS_ROOT_INO)%BFS_INODES_PER_BLOCK; di = (struct bfs_inode *)bh->b_data + off; - if (inode->i_ino == BFS_ROOT_INO) - di->i_vtype = BFS_VDIR; + if (ino == BFS_ROOT_INO) + di->i_vtype = cpu_to_le32(BFS_VDIR); else - di->i_vtype = BFS_VREG; - - di->i_ino = inode->i_ino; - di->i_mode = inode->i_mode; - di->i_uid = inode->i_uid; - di->i_gid = inode->i_gid; - di->i_nlink = inode->i_nlink; - di->i_atime = inode->i_atime.tv_sec; - di->i_mtime = inode->i_mtime.tv_sec; - di->i_ctime = inode->i_ctime.tv_sec; - di->i_sblock = BFS_I(inode)->i_sblock; - di->i_eblock = BFS_I(inode)->i_eblock; - di->i_eoffset = di->i_sblock * BFS_BSIZE + inode->i_size - 1; + di->i_vtype = cpu_to_le32(BFS_VREG); + + di->i_ino = cpu_to_le16(ino); + di->i_mode = cpu_to_le32(inode->i_mode); + di->i_uid = cpu_to_le32(inode->i_uid); + di->i_gid = cpu_to_le32(inode->i_gid); + di->i_nlink = cpu_to_le32(inode->i_nlink); + di->i_atime = cpu_to_le32(inode->i_atime.tv_sec); + di->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec); + di->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec); + i_sblock = BFS_I(inode)->i_sblock; + di->i_sblock = cpu_to_le32(i_sblock); + di->i_eblock = cpu_to_le32(BFS_I(inode)->i_eblock); + di->i_eoffset = cpu_to_le32(i_sblock * BFS_BSIZE + inode->i_size - 1); mark_buffer_dirty(bh); + dprintf("Written ino=%d into %d:%d\n",le16_to_cpu(di->i_ino),block,off); brelse(bh); unlock_kernel(); return 0; @@ -140,13 +148,14 @@ static void bfs_delete_inode(struct inode * inode) int block, off; struct super_block * s = inode->i_sb; struct bfs_sb_info * info = BFS_SB(s); + struct bfs_inode_info * bi = BFS_I(inode); - dprintf("ino=%08lx\n", inode->i_ino); + dprintf("ino=%08lx\n", ino); truncate_inode_pages(&inode->i_data, 0); - if (inode->i_ino < BFS_ROOT_INO || inode->i_ino > info->si_lasti) { - printf("invalid ino=%08lx\n", inode->i_ino); + if (ino < BFS_ROOT_INO || ino > info->si_lasti) { + printf("invalid ino=%08lx\n", ino); return; } @@ -162,13 +171,13 @@ static void bfs_delete_inode(struct inode * inode) return; } off = (ino - BFS_ROOT_INO)%BFS_INODES_PER_BLOCK; - di = (struct bfs_inode *)bh->b_data + off; - if (di->i_ino) { - info->si_freeb += BFS_FILEBLOCKS(di); + di = (struct bfs_inode *) bh->b_data + off; + if (bi->i_dsk_ino) { + info->si_freeb += 1 + bi->i_eblock - bi->i_sblock; info->si_freei++; - clear_bit(di->i_ino, info->si_imap); + clear_bit(ino, info->si_imap); dump_imap("delete_inode", s); - } + } di->i_ino = 0; di->i_sblock = 0; mark_buffer_dirty(bh); @@ -274,14 +283,14 @@ static struct super_operations bfs_sops = { void dump_imap(const char *prefix, struct super_block * s) { -#if 0 +#ifdef DEBUG int i; char *tmpbuf = (char *)get_zeroed_page(GFP_KERNEL); if (!tmpbuf) return; for (i=BFS_SB(s)->si_lasti; i>=0; i--) { - if (i>PAGE_SIZE-100) break; + if (i > PAGE_SIZE-100) break; if (test_bit(i, BFS_SB(s)->si_imap)) strcat(tmpbuf, "1"); else @@ -297,7 +306,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) struct buffer_head * bh; struct bfs_super_block * bfs_sb; struct inode * inode; - int i, imap_len; + unsigned i, imap_len; struct bfs_sb_info * info; info = kmalloc(sizeof(*info), GFP_KERNEL); @@ -312,19 +321,18 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) if(!bh) goto out; bfs_sb = (struct bfs_super_block *)bh->b_data; - if (bfs_sb->s_magic != BFS_MAGIC) { + if (le32_to_cpu(bfs_sb->s_magic) != BFS_MAGIC) { if (!silent) printf("No BFS filesystem on %s (magic=%08x)\n", - s->s_id, bfs_sb->s_magic); + s->s_id, le32_to_cpu(bfs_sb->s_magic)); goto out; } if (BFS_UNCLEAN(bfs_sb, s) && !silent) printf("%s is unclean, continuing\n", s->s_id); s->s_magic = BFS_MAGIC; - info->si_bfs_sb = bfs_sb; info->si_sbh = bh; - info->si_lasti = (bfs_sb->s_start - BFS_BSIZE)/sizeof(struct bfs_inode) + info->si_lasti = (le32_to_cpu(bfs_sb->s_start) - BFS_BSIZE)/sizeof(struct bfs_inode) + BFS_ROOT_INO - 1; imap_len = info->si_lasti/8 + 1; @@ -348,8 +356,8 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) goto out; } - info->si_blocks = (bfs_sb->s_end + 1)>>BFS_BSIZE_BITS; /* for statfs(2) */ - info->si_freeb = (bfs_sb->s_end + 1 - bfs_sb->s_start)>>BFS_BSIZE_BITS; + info->si_blocks = (le32_to_cpu(bfs_sb->s_end) + 1)>>BFS_BSIZE_BITS; /* for statfs(2) */ + info->si_freeb = (le32_to_cpu(bfs_sb->s_end) + 1 - cpu_to_le32(bfs_sb->s_start))>>BFS_BSIZE_BITS; info->si_freei = 0; info->si_lf_eblk = 0; info->si_lf_sblk = 0; diff --git a/include/linux/bfs_fs.h b/include/linux/bfs_fs.h index f7f0913..c1237aa 100644 --- a/include/linux/bfs_fs.h +++ b/include/linux/bfs_fs.h @@ -14,8 +14,9 @@ #define BFS_INODES_PER_BLOCK 8 /* SVR4 vnode type values (bfs_inode->i_vtype) */ -#define BFS_VDIR 2 -#define BFS_VREG 1 +#define BFS_VDIR 2L +#define BFS_VREG 1L + /* BFS inode layout on disk */ struct bfs_inode { @@ -58,22 +59,22 @@ struct bfs_super_block { __u32 s_padding[118]; }; -#define BFS_NZFILESIZE(ip) \ - (((ip)->i_eoffset + 1) - (ip)->i_sblock * BFS_BSIZE) - -#define BFS_FILESIZE(ip) \ - ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip)) - -#define BFS_FILEBLOCKS(ip) \ - ((ip)->i_sblock == 0 ? 0 : ((ip)->i_eblock + 1) - (ip)->i_sblock) #define BFS_OFF2INO(offset) \ ((((offset) - BFS_BSIZE) / sizeof(struct bfs_inode)) + BFS_ROOT_INO) #define BFS_INO2OFF(ino) \ ((__u32)(((ino) - BFS_ROOT_INO) * sizeof(struct bfs_inode)) + BFS_BSIZE) +#define BFS_NZFILESIZE(ip) \ + ((cpu_to_le32((ip)->i_eoffset) + 1) - cpu_to_le32((ip)->i_sblock) * BFS_BSIZE) + +#define BFS_FILESIZE(ip) \ + ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip)) +#define BFS_FILEBLOCKS(ip) \ + ((ip)->i_sblock == 0 ? 0 : (cpu_to_le32((ip)->i_eblock) + 1) - cpu_to_le32((ip)->i_sblock)) #define BFS_UNCLEAN(bfs_sb, sb) \ - ((bfs_sb->s_from != -1) && (bfs_sb->s_to != -1) && !(sb->s_flags & MS_RDONLY)) + ((cpu_to_le32(bfs_sb->s_from) != -1) && (cpu_to_le32(bfs_sb->s_to) != -1) && !(sb->s_flags & MS_RDONLY)) + #endif /* _LINUX_BFS_FS_H */ -- cgit v0.10.2 From 6f519165a97924ab3eeb99f388718d12ff97f1f4 Mon Sep 17 00:00:00 2001 From: Deepak Saxena Date: Fri, 9 Sep 2005 13:02:07 -0700 Subject: [PATCH] cs89x0: add netpoll support Signed-off-by: Deepak Saxena Cc: Matt Mackall Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c index b780307..cdc07cc 100644 --- a/drivers/net/cs89x0.c +++ b/drivers/net/cs89x0.c @@ -247,6 +247,9 @@ static int get_eeprom_data(struct net_device *dev, int off, int len, int *buffer static int get_eeprom_cksum(int off, int len, int *buffer); static int set_mac_address(struct net_device *dev, void *addr); static void count_rx_errors(int status, struct net_local *lp); +#ifdef CONFIG_NET_POLL_CONTROLLER +static void net_poll_controller(struct net_device *dev); +#endif #if ALLOW_DMA static void get_dma_channel(struct net_device *dev); static void release_dma_buff(struct net_local *lp); @@ -405,6 +408,19 @@ get_eeprom_cksum(int off, int len, int *buffer) return -1; } +#ifdef CONFIG_NET_POLL_CONTROLLER +/* + * Polling receive - used by netconsole and other diagnostic tools + * to allow network i/o with interrupts disabled. + */ +static void net_poll_controller(struct net_device *dev) +{ + disable_irq(dev->irq); + net_interrupt(dev->irq, dev, NULL); + enable_irq(dev->irq); +} +#endif + /* This is the real probe routine. Linux has a history of friendly device probes on the ISA bus. A good device probes avoids doing writes, and verifies that the correct device exists and functions. @@ -760,6 +776,9 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular) dev->get_stats = net_get_stats; dev->set_multicast_list = set_multicast_list; dev->set_mac_address = set_mac_address; +#ifdef CONFIG_NET_POLL_CONTROLLER + dev->poll_controller = net_poll_controller; +#endif printk("\n"); if (net_debug) -- cgit v0.10.2 From 8f58202bf6b915656e116ece3bc4ace14bfe533a Mon Sep 17 00:00:00 2001 From: Wendy Cheng Date: Fri, 9 Sep 2005 13:02:08 -0700 Subject: [PATCH] change io_cancel return code for no cancel case Note that other than few exceptions, most of the current filesystem and/or drivers do not have aio cancel specifically defined (kiob->ki_cancel field is mostly NULL). However, sys_io_cancel system call universally sets return code to -EAGAIN. This gives applications a wrong impression that this call is implemented but just never works. We have customer inquires about this issue. Changed by Benjamin LaHaise to EINVAL instead of ENOSYS Signed-off-by: S. Wendy Cheng Acked-by: Benjamin LaHaise Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/aio.c b/fs/aio.c index 4f641ab..769791d 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1673,7 +1673,7 @@ asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb, ret = -EFAULT; } } else - printk(KERN_DEBUG "iocb has no cancel operation\n"); + ret = -EINVAL; put_ioctx(ctx); -- cgit v0.10.2 From ac0b1bc1edbe81c0cb36cad7e7f5b91f4d9e12ed Mon Sep 17 00:00:00 2001 From: Benjamin LaHaise Date: Fri, 9 Sep 2005 13:02:09 -0700 Subject: [PATCH] aio: kiocb locking to serialise retry and cancel Implement a per-kiocb lock to serialise retry operations and cancel. This is done using wait_on_bit_lock() on the KIF_LOCKED bit of kiocb->ki_flags. Also, make the cancellation path lock the kiocb and subsequently release all references to it if the cancel was successful. This version includes a fix for the deadlock with __aio_run_iocbs. Signed-off-by: Benjamin LaHaise Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/aio.c b/fs/aio.c index 769791d..201c184 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -546,6 +546,24 @@ struct kioctx *lookup_ioctx(unsigned long ctx_id) return ioctx; } +static int lock_kiocb_action(void *param) +{ + schedule(); + return 0; +} + +static inline void lock_kiocb(struct kiocb *iocb) +{ + wait_on_bit_lock(&iocb->ki_flags, KIF_LOCKED, lock_kiocb_action, + TASK_UNINTERRUPTIBLE); +} + +static inline void unlock_kiocb(struct kiocb *iocb) +{ + kiocbClearLocked(iocb); + wake_up_bit(&iocb->ki_flags, KIF_LOCKED); +} + /* * use_mm * Makes the calling kernel thread take on the specified @@ -786,7 +804,9 @@ static int __aio_run_iocbs(struct kioctx *ctx) * Hold an extra reference while retrying i/o. */ iocb->ki_users++; /* grab extra reference */ + lock_kiocb(iocb); aio_run_iocb(iocb); + unlock_kiocb(iocb); if (__aio_put_req(ctx, iocb)) /* drop extra ref */ put_ioctx(ctx); } @@ -1527,10 +1547,9 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, goto out_put_req; spin_lock_irq(&ctx->ctx_lock); - if (likely(list_empty(&ctx->run_list))) { - aio_run_iocb(req); - } else { - list_add_tail(&req->ki_run_list, &ctx->run_list); + aio_run_iocb(req); + unlock_kiocb(req); + if (!list_empty(&ctx->run_list)) { /* drain the run list */ while (__aio_run_iocbs(ctx)) ; @@ -1661,6 +1680,7 @@ asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb, if (NULL != cancel) { struct io_event tmp; pr_debug("calling cancel\n"); + lock_kiocb(kiocb); memset(&tmp, 0, sizeof(tmp)); tmp.obj = (u64)(unsigned long)kiocb->ki_obj.user; tmp.data = kiocb->ki_user_data; @@ -1672,6 +1692,7 @@ asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb, if (copy_to_user(result, &tmp, sizeof(tmp))) ret = -EFAULT; } + unlock_kiocb(kiocb); } else ret = -EINVAL; -- cgit v0.10.2 From 73a358d1892a8233801e3fd54668075b52ec42da Mon Sep 17 00:00:00 2001 From: KUROSAWA Takahiro Date: Fri, 9 Sep 2005 13:02:10 -0700 Subject: [PATCH] fix for cpusets minor problem This patch fixes minor problem that the CPUSETS have when files in the cpuset filesystem are read after lseek()-ed beyond the EOF. Signed-off-by: KUROSAWA Takahiro Acked-by: Paul Jackson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 1f06e76..712d020 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c @@ -972,6 +972,10 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf, *s++ = '\n'; *s = '\0'; + /* Do nothing if *ppos is at the eof or beyond the eof. */ + if (s - page <= *ppos) + return 0; + start = page + *ppos; n = s - start; retval = n - copy_to_user(buf, start, min(n, nbytes)); -- cgit v0.10.2 From 24b20ac6e1c80082889b3d6ae08aadda777519e5 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Fri, 9 Sep 2005 13:02:11 -0700 Subject: [PATCH] remove unnecessary handle_IRQ_event() prototypes The function prototype for handle_IRQ_event() in a few architctures is not needed because they use GENERIC_HARDIRQ. Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/include/asm-mips/irq.h b/include/asm-mips/irq.h index b90b11d..3f2470e 100644 --- a/include/asm-mips/irq.h +++ b/include/asm-mips/irq.h @@ -49,7 +49,4 @@ do { \ extern void arch_init_irq(void); -struct irqaction; -int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *); - #endif /* _ASM_IRQ_H */ diff --git a/include/asm-ppc/irq.h b/include/asm-ppc/irq.h index b4b2704..5575247 100644 --- a/include/asm-ppc/irq.h +++ b/include/asm-ppc/irq.h @@ -404,9 +404,5 @@ extern unsigned long ppc_cached_irq_mask[NR_MASK_WORDS]; extern unsigned long ppc_lost_interrupts[NR_MASK_WORDS]; extern atomic_t ppc_n_lost_interrupts; -struct irqaction; -struct pt_regs; -int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *); - #endif /* _ASM_IRQ_H */ #endif /* __KERNEL__ */ diff --git a/include/asm-sh/irq.h b/include/asm-sh/irq.h index 831e52e..614a8c1 100644 --- a/include/asm-sh/irq.h +++ b/include/asm-sh/irq.h @@ -587,10 +587,6 @@ static inline int generic_irq_demux(int irq) #define irq_canonicalize(irq) (irq) #define irq_demux(irq) __irq_demux(sh_mv.mv_irq_demux(irq)) -struct irqaction; -struct pt_regs; -int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *); - #if defined(CONFIG_CPU_SUBTYPE_SH73180) #include #endif diff --git a/include/asm-x86_64/irq.h b/include/asm-x86_64/irq.h index 4482657..fb724ba 100644 --- a/include/asm-x86_64/irq.h +++ b/include/asm-x86_64/irq.h @@ -48,10 +48,6 @@ static __inline__ int irq_canonicalize(int irq) #define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */ #endif -struct irqaction; -struct pt_regs; -int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *); - #ifdef CONFIG_HOTPLUG_CPU #include extern void fixup_irqs(cpumask_t map); -- cgit v0.10.2 From 9d5c1e1bf2b906966609f8cf4a844e61adb86bcd Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 9 Sep 2005 13:02:12 -0700 Subject: [PATCH] deadline: clean up question mark operator That ?: trick gives us the creeps. Cc: Jens Axboe Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c index 24594c5..52a3ae5 100644 --- a/drivers/block/deadline-iosched.c +++ b/drivers/block/deadline-iosched.c @@ -512,7 +512,10 @@ static int deadline_dispatch_requests(struct deadline_data *dd) /* * batches are currently reads XOR writes */ - drq = dd->next_drq[WRITE] ? : dd->next_drq[READ]; + if (dd->next_drq[WRITE]) + drq = dd->next_drq[WRITE]; + else + drq = dd->next_drq[READ]; if (drq) { /* we have a "next request" */ -- cgit v0.10.2 From 4a918bc233c8b9537fbc05a8bbb33928a4980cc5 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:12 -0700 Subject: [PATCH] synclink.c: compiler optimisation fix Make some fields of DMA descriptor volatile to prevent compiler optimizations. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 37c8bea..747eb8d 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -1,7 +1,7 @@ /* * linux/drivers/char/synclink.c * - * $Id: synclink.c,v 4.28 2004/08/11 19:30:01 paulkf Exp $ + * $Id: synclink.c,v 4.37 2005/09/07 13:13:19 paulkf Exp $ * * Device driver for Microgate SyncLink ISA and PCI * high speed multiprotocol serial adapters. @@ -141,9 +141,9 @@ static MGSL_PARAMS default_params = { typedef struct _DMABUFFERENTRY { u32 phys_addr; /* 32-bit flat physical address of data buffer */ - u16 count; /* buffer size/data count */ - u16 status; /* Control/status field */ - u16 rcc; /* character count field */ + volatile u16 count; /* buffer size/data count */ + volatile u16 status; /* Control/status field */ + volatile u16 rcc; /* character count field */ u16 reserved; /* padding required by 16C32 */ u32 link; /* 32-bit flat link to next buffer entry */ char *virt_addr; /* virtual address of data buffer */ @@ -896,7 +896,7 @@ module_param_array(txdmabufs, int, NULL, 0); module_param_array(txholdbufs, int, NULL, 0); static char *driver_name = "SyncLink serial driver"; -static char *driver_version = "$Revision: 4.28 $"; +static char *driver_version = "$Revision: 4.37 $"; static int synclink_init_one (struct pci_dev *dev, const struct pci_device_id *ent); -- cgit v0.10.2 From 9661239f7f698ba3a79db5e8ab5bb2f4090663d9 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:13 -0700 Subject: [PATCH] synclink.c: add clear stats Add the ability to clear statistics. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 747eb8d..26b421b 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -1814,6 +1814,8 @@ static int startup(struct mgsl_struct * info) info->pending_bh = 0; + memset(&info->icount, 0, sizeof(info->icount)); + init_timer(&info->tx_timer); info->tx_timer.data = (unsigned long)info; info->tx_timer.function = mgsl_tx_timeout; @@ -2470,12 +2472,12 @@ static int mgsl_get_stats(struct mgsl_struct * info, struct mgsl_icount __user * printk("%s(%d):mgsl_get_params(%s)\n", __FILE__,__LINE__, info->device_name); - COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount)); - if (err) { - if ( debug_level >= DEBUG_LEVEL_INFO ) - printk( "%s(%d):mgsl_get_stats(%s) user buffer copy failed\n", - __FILE__,__LINE__,info->device_name); - return -EFAULT; + if (!user_icount) { + memset(&info->icount, 0, sizeof(info->icount)); + } else { + COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); + if (err) + return -EFAULT; } return 0; -- cgit v0.10.2 From 7c1fff58cfaaf1c4b6a31a569e18cb7d2d8db0a6 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:14 -0700 Subject: [PATCH] synclink.c: add loopback to async mode Add internal loopback support for asynchronous mode operation. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 26b421b..ea2d54b 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -6151,6 +6151,11 @@ static void usc_set_async_mode( struct mgsl_struct *info ) usc_OutReg(info, PCR, (u16)((usc_InReg(info, PCR) | BIT13) & ~BIT12)); } + if (info->params.loopback) { + info->loopback_bits = 0x300; + outw(0x0300, info->io_base + CCAR); + } + } /* end of usc_set_async_mode() */ /* usc_loopback_frame() -- cgit v0.10.2 From 7f3edb94564d319cd58cc11c2c986b7ec25643d8 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:14 -0700 Subject: [PATCH] synclinkmp.c: fix double mapping of signals Serial signals were incorrectly mapped twice to events. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index 8982eaf..1bde04d 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -1,5 +1,5 @@ /* - * $Id: synclinkmp.c,v 4.34 2005/03/04 15:07:10 paulkf Exp $ + * $Id: synclinkmp.c,v 4.38 2005/07/15 13:29:44 paulkf Exp $ * * Device driver for Microgate SyncLink Multiport * high speed multiprotocol serial adapter. @@ -486,7 +486,7 @@ module_param_array(maxframe, int, NULL, 0); module_param_array(dosyncppp, int, NULL, 0); static char *driver_name = "SyncLink MultiPort driver"; -static char *driver_version = "$Revision: 4.34 $"; +static char *driver_version = "$Revision: 4.38 $"; static int synclinkmp_init_one(struct pci_dev *dev,const struct pci_device_id *ent); static void synclinkmp_remove_one(struct pci_dev *dev); @@ -555,7 +555,6 @@ static int set_txidle(SLMP_INFO *info, int idle_mode); static int tx_enable(SLMP_INFO *info, int enable); static int tx_abort(SLMP_INFO *info); static int rx_enable(SLMP_INFO *info, int enable); -static int map_status(int signals); static int modem_input_wait(SLMP_INFO *info,int arg); static int wait_mgsl_event(SLMP_INFO *info, int __user *mask_ptr); static int tiocmget(struct tty_struct *tty, struct file *file); @@ -3108,16 +3107,6 @@ static int rx_enable(SLMP_INFO * info, int enable) return 0; } -static int map_status(int signals) -{ - /* Map status bits to API event bits */ - - return ((signals & SerialSignal_DSR) ? MgslEvent_DsrActive : MgslEvent_DsrInactive) + - ((signals & SerialSignal_CTS) ? MgslEvent_CtsActive : MgslEvent_CtsInactive) + - ((signals & SerialSignal_DCD) ? MgslEvent_DcdActive : MgslEvent_DcdInactive) + - ((signals & SerialSignal_RI) ? MgslEvent_RiActive : MgslEvent_RiInactive); -} - /* wait for specified event to occur */ static int wait_mgsl_event(SLMP_INFO * info, int __user *mask_ptr) @@ -3144,7 +3133,7 @@ static int wait_mgsl_event(SLMP_INFO * info, int __user *mask_ptr) /* return immediately if state matches requested events */ get_signals(info); - s = map_status(info->serial_signals); + s = info->serial_signals; events = mask & ( ((s & SerialSignal_DSR) ? MgslEvent_DsrActive:MgslEvent_DsrInactive) + -- cgit v0.10.2 From 761a444d8d059e4e2de326383b1dec4a636e0a92 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:15 -0700 Subject: [PATCH] synclinkmp.c: disable burst transfers Disable burst transfers on adapter local bus. Hardware feature does not work on latest version of adapter. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index 1bde04d..d55dbf1 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -643,7 +643,7 @@ static unsigned char tx_active_fifo_level = 16; // tx request FIFO activation le static unsigned char tx_negate_fifo_level = 32; // tx request FIFO negation level in bytes static u32 misc_ctrl_value = 0x007e4040; -static u32 lcr1_brdr_value = 0x00800029; +static u32 lcr1_brdr_value = 0x00800028; static u32 read_ahead_count = 8; -- cgit v0.10.2 From 166692e4a045348109f66b493e1b41afde6f3769 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:16 -0700 Subject: [PATCH] synclinkmp.c: add statistics clear Add ability to clear statistics. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index d55dbf1..eb31a3b 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -2748,6 +2748,8 @@ static int startup(SLMP_INFO * info) info->pending_bh = 0; + memset(&info->icount, 0, sizeof(info->icount)); + /* program hardware for current parameters */ reset_port(info); @@ -2951,12 +2953,12 @@ static int get_stats(SLMP_INFO * info, struct mgsl_icount __user *user_icount) printk("%s(%d):%s get_params()\n", __FILE__,__LINE__, info->device_name); - COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount)); - if (err) { - if ( debug_level >= DEBUG_LEVEL_INFO ) - printk( "%s(%d):%s get_stats() user buffer copy failed\n", - __FILE__,__LINE__,info->device_name); - return -EFAULT; + if (!user_icount) { + memset(&info->icount, 0, sizeof(info->icount)); + } else { + COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); + if (err) + return -EFAULT; } return 0; -- cgit v0.10.2 From 6e8dcee3e63f5a2cba4affff4bbb6e228f4b258a Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:17 -0700 Subject: [PATCH] synclinkmp.c: fix async internal loopback Fix async internal loopback by not using enable_loopback function which reprograms clocking and should only be used for hdlc mode. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index eb31a3b..6fb165c 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -4479,11 +4479,13 @@ void async_mode(SLMP_INFO *info) /* MD2, Mode Register 2 * * 07..02 Reserved, must be 0 - * 01..00 CNCT<1..0> Channel connection, 0=normal + * 01..00 CNCT<1..0> Channel connection, 00=normal 11=local loopback * * 0000 0000 */ RegValue = 0x00; + if (info->params.loopback) + RegValue |= (BIT1 + BIT0); write_reg(info, MD2, RegValue); /* RXS, Receive clock source @@ -4564,9 +4566,6 @@ void async_mode(SLMP_INFO *info) write_reg(info, IE2, info->ie2_value); set_rate( info, info->params.data_rate * 16 ); - - if (info->params.loopback) - enable_loopback(info,1); } /* Program the SCA for HDLC communications. -- cgit v0.10.2 From 59f4e7d572980a521b7bdba74ab71b21f5995538 Mon Sep 17 00:00:00 2001 From: Truxton Fulton Date: Fri, 9 Sep 2005 13:02:18 -0700 Subject: [PATCH] fix reboot via keyboard controller reset I have a system (Biostar IDEQ210M mini-pc with a VIA chipset) which will not reboot unless a keyboard is plugged in to it. I have tried all combinations of the kernel "reboot=x,y" flags to no avail. Rebooting by any method will leave the system in a wedged state (at the "Restarting system" message). I finally tracked the problem down to the machine's refusal to fully reboot unless the keyboard controller status register had bit 2 set. This is the "System flag" which when set, indicates successful completion of the keyboard controller self-test (Basic Assurance Test, BAT). I suppose that something is trying to protect against sporadic reboots unless the keyboard controller is in a good state (a keyboard is present), but I need this machine to be headless. I found that setting the system flag (via the command byte) before giving the "pulse reset line" command will allow the reboot to proceed. The patch is simple, and I think it should be fine for everybody whether they have this type of machine or not. This affects the "hard" reboot (as done when the kernel boot flags "reboot=c,h" are used). Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/include/asm-i386/mach-default/mach_reboot.h b/include/asm-i386/mach-default/mach_reboot.h index 521e227..06ae4d8 100644 --- a/include/asm-i386/mach-default/mach_reboot.h +++ b/include/asm-i386/mach-default/mach_reboot.h @@ -22,7 +22,15 @@ static inline void mach_reboot(void) for (i = 0; i < 100; i++) { kb_wait(); udelay(50); - outb(0xfe, 0x64); /* pulse reset low */ + outb(0x60, 0x64); /* write Controller Command Byte */ + udelay(50); + kb_wait(); + udelay(50); + outb(0x14, 0x60); /* set "System flag" */ + udelay(50); + kb_wait(); + udelay(50); + outb(0xfe, 0x64); /* pulse reset low */ udelay(50); } } -- cgit v0.10.2 From a8d995c99ef56a3dbcdbe291bb71658bf00e9ad6 Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:19 -0700 Subject: [PATCH] dvb: email address update Update email address of Peter Hettkamp. Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c index 3c5a8e2..3bfbba3 100644 --- a/drivers/media/dvb/bt8xx/bt878.c +++ b/drivers/media/dvb/bt8xx/bt878.c @@ -1,7 +1,7 @@ /* * bt878.c: part of the driver for the Pinnacle PCTV Sat DVB PCI card * - * Copyright (C) 2002 Peter Hettkamp + * Copyright (C) 2002 Peter Hettkamp * * large parts based on the bttv driver * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@metzlerbros.de) diff --git a/drivers/media/dvb/bt8xx/bt878.h b/drivers/media/dvb/bt8xx/bt878.h index 837623f..a73baf0 100644 --- a/drivers/media/dvb/bt8xx/bt878.h +++ b/drivers/media/dvb/bt8xx/bt878.h @@ -1,7 +1,7 @@ /* bt878.h - Bt878 audio module (register offsets) - Copyright (C) 2002 Peter Hettkamp + Copyright (C) 2002 Peter Hettkamp 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 diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.h b/drivers/media/dvb/bt8xx/dvb-bt8xx.h index 2923b3b..9ec8e5b 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.h +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.h @@ -2,7 +2,7 @@ * Bt8xx based DVB adapter driver * * Copyright (C) 2002,2003 Florian Schirmer - * Copyright (C) 2002 Peter Hettkamp + * Copyright (C) 2002 Peter Hettkamp * Copyright (C) 1999-2001 Ralph Metzler & Marcus Metzler for convergence integrated media GmbH * Copyright (C) 1998,1999 Christian Theiss * diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index 8222b88..555d472 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c @@ -1,7 +1,7 @@ /* cx24110 - Single Chip Satellite Channel Receiver driver module - Copyright (C) 2002 Peter Hettkamp based on + Copyright (C) 2002 Peter Hettkamp based on work Copyright (C) 1999 Convergence Integrated Media GmbH diff --git a/drivers/media/dvb/frontends/cx24110.h b/drivers/media/dvb/frontends/cx24110.h index 6b663f4..b63ecf2 100644 --- a/drivers/media/dvb/frontends/cx24110.h +++ b/drivers/media/dvb/frontends/cx24110.h @@ -1,7 +1,7 @@ /* cx24110 - Single Chip Satellite Channel Receiver driver module - Copyright (C) 2002 Peter Hettkamp based on + Copyright (C) 2002 Peter Hettkamp based on work Copyright (C) 1999 Convergence Integrated Media GmbH -- cgit v0.10.2 From 34f7373aaec80564cc87b7829e4e2a0e3c20c4b7 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Fri, 9 Sep 2005 13:02:20 -0700 Subject: [PATCH] dvb: remove version.h dependencies Remove all #include and all references to LINUX_VERSION_CODE and KERNEL_VERSION. Based on patch by Olaf Hering. Signed-off-by: Olaf Hering Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c index c04fd11..3788898 100644 --- a/drivers/media/common/saa7146_fops.c +++ b/drivers/media/common/saa7146_fops.c @@ -1,5 +1,4 @@ #include -#include #define BOARD_CAN_DO_VBI(dev) (dev->revision != 0 && dev->vv_data->vbi_minor != -1) diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c index 6284894..45f8673 100644 --- a/drivers/media/common/saa7146_i2c.c +++ b/drivers/media/common/saa7146_i2c.c @@ -1,4 +1,3 @@ -#include #include static u32 saa7146_i2c_func(struct i2c_adapter *adapter) @@ -402,12 +401,8 @@ int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c saa7146_i2c_reset(dev); if( NULL != i2c_adapter ) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - i2c_adapter->data = dev; -#else BUG_ON(!i2c_adapter->class); i2c_set_adapdata(i2c_adapter,dev); -#endif i2c_adapter->algo = &saa7146_algo; i2c_adapter->algo_data = NULL; i2c_adapter->id = I2C_HW_SAA7146; diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index 9ea5747..c52e9d5 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c index 6a968c3..33a357c 100644 --- a/drivers/media/dvb/dvb-core/dvb_net.c +++ b/drivers/media/dvb/dvb-core/dvb_net.c @@ -62,7 +62,6 @@ #include #include #include -#include #include "dvb_demux.h" #include "dvb_net.h" @@ -171,11 +170,7 @@ static unsigned short dvb_net_eth_type_trans(struct sk_buff *skb, skb->mac.raw=skb->data; skb_pull(skb,dev->hard_header_len); -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,8) - eth = skb->mac.ethernet; -#else eth = eth_hdr(skb); -#endif if (*eth->h_dest & 1) { if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0) diff --git a/drivers/media/dvb/frontends/dib3000mb.c b/drivers/media/dvb/frontends/dib3000mb.c index cd434b7..21433e1 100644 --- a/drivers/media/dvb/frontends/dib3000mb.c +++ b/drivers/media/dvb/frontends/dib3000mb.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c index cd33705..441de66 100644 --- a/drivers/media/dvb/frontends/dib3000mc.c +++ b/drivers/media/dvb/frontends/dib3000mc.c @@ -22,7 +22,6 @@ */ #include #include -#include #include #include #include diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index 45c9a9a..3d08fc8 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include diff --git a/include/media/saa7146.h b/include/media/saa7146.h index 3dfb8d6..2a897c3 100644 --- a/include/media/saa7146.h +++ b/include/media/saa7146.h @@ -1,7 +1,6 @@ #ifndef __SAA7146__ #define __SAA7146__ -#include /* for version macros */ #include /* for module-version */ #include /* for delay-stuff */ #include /* for kmalloc/kfree */ @@ -15,12 +14,7 @@ #include /* for vmalloc() */ #include /* for vmalloc_to_page() */ -/* ugly, but necessary to build the dvb stuff under 2.4. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51) - #include "dvb_functions.h" -#endif - -#define SAA7146_VERSION_CODE KERNEL_VERSION(0,5,0) +#define SAA7146_VERSION_CODE 0x000500 /* 0.5.0 */ #define saa7146_write(sxy,adr,dat) writel((dat),(sxy->mem+(adr))) #define saa7146_read(sxy,adr) readl(sxy->mem+(adr)) @@ -33,13 +27,8 @@ extern unsigned int saa7146_debug; #define DEBUG_VARIABLE saa7146_debug #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51) -#define DEBUG_PROLOG printk("%s: %s(): ",__stringify(KBUILD_BASENAME),__FUNCTION__) -#define INFO(x) { printk("%s: ",__stringify(KBUILD_BASENAME)); printk x; } -#else #define DEBUG_PROLOG printk("%s: %s(): ",__stringify(KBUILD_MODNAME),__FUNCTION__) #define INFO(x) { printk("%s: ",__stringify(KBUILD_MODNAME)); printk x; } -#endif #define ERR(x) { DEBUG_PROLOG; printk x; } -- cgit v0.10.2 From 3cc2176cbbee6adfaceac2df6d77312cf30cee83 Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:20 -0700 Subject: [PATCH] dvb: avoid building empty built-in.o Don't build empty built-in.o when DVB/V4L is not configured. Thanks to Sam Ravnborg and Keith Owens. Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/Makefile b/drivers/media/Makefile index 772d611..c578a52 100644 --- a/drivers/media/Makefile +++ b/drivers/media/Makefile @@ -2,4 +2,7 @@ # Makefile for the kernel multimedia device drivers. # -obj-y := video/ radio/ dvb/ common/ +obj-y := common/ +obj-$(CONFIG_VIDEO_DEV) += video/ +obj-$(CONFIG_VIDEO_DEV) += radio/ +obj-$(CONFIG_DVB) += dvb/ -- cgit v0.10.2 From c05100528efe997a27d841230f9f5b2f4adf3d0f Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:21 -0700 Subject: [PATCH] dvb: core: glue code for DMX_GET_CAPS and DMX_SET_SOURCE Glue code for DMX_GET_CAPS and DMX_SET_SOURCE ioctls. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index fb55eaa..b86d03f 100644 --- a/drivers/media/dvb/dvb-core/demux.h +++ b/drivers/media/dvb/dvb-core/demux.h @@ -30,6 +30,7 @@ #include #include #include +#include /*--------------------------------------------------------------------------*/ /* Common definitions */ @@ -282,6 +283,10 @@ struct dmx_demux { int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids); + int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps); + + int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src); + int (*get_stc) (struct dmx_demux* demux, unsigned int num, u64 *stc, unsigned int *base); }; diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index 68050cd..6059562 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c @@ -929,6 +929,22 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file, dmxdev->demux->get_pes_pids(dmxdev->demux, (u16 *)parg); break; + case DMX_GET_CAPS: + if (!dmxdev->demux->get_caps) { + ret = -EINVAL; + break; + } + ret = dmxdev->demux->get_caps(dmxdev->demux, parg); + break; + + case DMX_SET_SOURCE: + if (!dmxdev->demux->set_source) { + ret = -EINVAL; + break; + } + ret = dmxdev->demux->set_source(dmxdev->demux, parg); + break; + case DMX_GET_STC: if (!dmxdev->demux->get_stc) { ret=-EINVAL; -- cgit v0.10.2 From 1e0ae280e91a4f69b08770c6ab72808711dd4f2b Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:22 -0700 Subject: [PATCH] dvb: core: dvb_demux: fix continuity counter error handling Don't return immediately from dvb_dmx_swfilter_section_packet() if CC is not ok. Otherwise a new feed drops all packets until the first packet with CC=0 arrives. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index ac9889d..3d18d3e 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -336,7 +336,6 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 */ feed->pusi_seen = 0; dvb_dmx_swfilter_section_new(feed); - return 0; } if (buf[1] & 0x40) { -- cgit v0.10.2 From 936534676ef6c6af389eb9e61de7d725ee79a316 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:23 -0700 Subject: [PATCH] dvb: core: dvb_demux: remove unused cruft Removed some useless functions and variables. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index b86d03f..608461f 100644 --- a/drivers/media/dvb/dvb-core/demux.h +++ b/drivers/media/dvb/dvb-core/demux.h @@ -245,7 +245,6 @@ struct dmx_frontend { struct dmx_demux { u32 capabilities; /* Bitfield of capability flags */ struct dmx_frontend* frontend; /* Front-end connected to the demux */ - struct list_head reg_list; /* List of registered demuxes */ void* priv; /* Pointer to private data of the API client */ int users; /* Number of users */ int (*open) (struct dmx_demux* demux); @@ -291,16 +290,4 @@ struct dmx_demux { u64 *stc, unsigned int *base); }; -/*--------------------------------------------------------------------------*/ -/* Demux directory */ -/*--------------------------------------------------------------------------*/ - -/* - * DMX_DIR_ENTRY(): Casts elements in the list of registered - * demuxes from the generic type struct list_head* to the type struct dmx_demux - *. - */ - -#define DMX_DIR_ENTRY(list) list_entry(list, struct dmx_demux, reg_list) - #endif /* #ifndef __DEMUX_H */ diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index 3d18d3e..8774a94 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -39,33 +39,6 @@ // #define DVB_DEMUX_SECTION_LOSS_LOG -static LIST_HEAD(dmx_muxs); - - -static int dmx_register_demux(struct dmx_demux *demux) -{ - demux->users = 0; - list_add(&demux->reg_list, &dmx_muxs); - return 0; -} - -static int dmx_unregister_demux(struct dmx_demux* demux) -{ - struct list_head *pos, *n, *head=&dmx_muxs; - - list_for_each_safe (pos, n, head) { - if (DMX_DIR_ENTRY(pos) == demux) { - if (demux->users>0) - return -EINVAL; - list_del(pos); - return 0; - } - } - - return -ENODEV; -} - - /****************************************************************************** * static inlined helper functions ******************************************************************************/ @@ -1207,7 +1180,7 @@ static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 *pids) int dvb_dmx_init(struct dvb_demux *dvbdemux) { - int i, err; + int i; struct dmx_demux *dmx = &dvbdemux->dmx; dvbdemux->users = 0; @@ -1250,7 +1223,6 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) dvbdemux->memcopy = dvb_dmx_memcopy; dmx->frontend = NULL; - dmx->reg_list.prev = dmx->reg_list.next = &dmx->reg_list; dmx->priv = (void *) dvbdemux; dmx->open = dvbdmx_open; dmx->close = dvbdmx_close; @@ -1273,21 +1245,14 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) sema_init(&dvbdemux->mutex, 1); spin_lock_init(&dvbdemux->lock); - if ((err = dmx_register_demux(dmx)) < 0) - return err; - return 0; } EXPORT_SYMBOL(dvb_dmx_init); -int dvb_dmx_release(struct dvb_demux *dvbdemux) +void dvb_dmx_release(struct dvb_demux *dvbdemux) { - struct dmx_demux *dmx = &dvbdemux->dmx; - - dmx_unregister_demux(dmx); vfree(dvbdemux->filter); vfree(dvbdemux->feed); - return 0; } EXPORT_SYMBOL(dvb_dmx_release); diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h index c09beb3..20275a2 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.h +++ b/drivers/media/dvb/dvb-core/dvb_demux.h @@ -138,7 +138,7 @@ struct dvb_demux { int dvb_dmx_init(struct dvb_demux *dvbdemux); -int dvb_dmx_release(struct dvb_demux *dvbdemux); +void dvb_dmx_release(struct dvb_demux *dvbdemux); void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, size_t count); void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count); void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count); -- cgit v0.10.2 From 218721b8ef334a7c778fe3bc033922edef911a1f Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:24 -0700 Subject: [PATCH] dvb: core: dvb_demux: remove unsused descramble callbacks Removed unused descramble_mac_address and descramble_section_payload callbacks. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index 608461f..ee5be59 100644 --- a/drivers/media/dvb/dvb-core/demux.h +++ b/drivers/media/dvb/dvb-core/demux.h @@ -260,17 +260,6 @@ struct dmx_demux { dmx_section_cb callback); int (*release_section_feed) (struct dmx_demux* demux, struct dmx_section_feed* feed); - int (*descramble_mac_address) (struct dmx_demux* demux, - u8* buffer1, - size_t buffer1_length, - u8* buffer2, - size_t buffer2_length, - u16 pid); - int (*descramble_section_payload) (struct dmx_demux* demux, - u8* buffer1, - size_t buffer1_length, - u8* buffer2, size_t buffer2_length, - u16 pid); int (*add_frontend) (struct dmx_demux* demux, struct dmx_frontend* frontend); int (*remove_frontend) (struct dmx_demux* demux, diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index 8774a94..6488206 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -1232,9 +1232,6 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) dmx->allocate_section_feed = dvbdmx_allocate_section_feed; dmx->release_section_feed = dvbdmx_release_section_feed; - dmx->descramble_mac_address = NULL; - dmx->descramble_section_payload = NULL; - dmx->add_frontend = dvbdmx_add_frontend; dmx->remove_frontend = dvbdmx_remove_frontend; dmx->get_frontends = dvbdmx_get_frontends; -- cgit v0.10.2 From 5d2cd1631e97f5eb9c8666ff9cd8011cd5c12e7d Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:24 -0700 Subject: [PATCH] dvb: core: dvb_demux: remove more unused cruft Removed more unused variables and constants. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index ee5be59..9719a3b 100644 --- a/drivers/media/dvb/dvb-core/demux.h +++ b/drivers/media/dvb/dvb-core/demux.h @@ -125,9 +125,7 @@ struct dmx_ts_feed { u16 pid, int type, enum dmx_ts_pes pes_type, - size_t callback_length, size_t circular_buffer_size, - int descramble, struct timespec timeout); int (*start_filtering) (struct dmx_ts_feed* feed); int (*stop_filtering) (struct dmx_ts_feed* feed); @@ -160,7 +158,6 @@ struct dmx_section_feed { int (*set) (struct dmx_section_feed* feed, u16 pid, size_t circular_buffer_size, - int descramble, int check_crc); int (*allocate_filter) (struct dmx_section_feed* feed, struct dmx_section_filter** filter); @@ -208,7 +205,6 @@ struct dmx_frontend { struct list_head connectivity_list; /* List of front-ends that can be connected to a particular demux */ - void* priv; /* Pointer to private data of the API client */ enum dmx_frontend_source source; }; @@ -226,8 +222,6 @@ struct dmx_frontend { #define DMX_MEMORY_BASED_FILTERING 8 /* write() available */ #define DMX_CRC_CHECKING 16 #define DMX_TS_DESCRAMBLING 32 -#define DMX_SECTION_PAYLOAD_DESCRAMBLING 64 -#define DMX_MAC_ADDRESS_DESCRAMBLING 128 /* * Demux resource type identifier. @@ -246,7 +240,6 @@ struct dmx_demux { u32 capabilities; /* Bitfield of capability flags */ struct dmx_frontend* frontend; /* Front-end connected to the demux */ void* priv; /* Pointer to private data of the API client */ - int users; /* Number of users */ int (*open) (struct dmx_demux* demux); int (*close) (struct dmx_demux* demux); int (*write) (struct dmx_demux* demux, const char* buf, size_t count); diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index 6059562..8028c3a 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c @@ -571,7 +571,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) return ret; } - ret=(*secfeed)->set(*secfeed, para->pid, 32768, 0, + ret=(*secfeed)->set(*secfeed, para->pid, 32768, (para->flags & DMX_CHECK_CRC) ? 1 : 0); if (ret<0) { @@ -654,7 +654,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) (*tsfeed)->priv = (void *) filter; ret = (*tsfeed)->set(*tsfeed, para->pid, ts_type, ts_pes, - 188, 32768, 0, timeout); + 32768, timeout); if (ret < 0) { dmxdev->demux->release_ts_feed(dmxdev->demux, *tsfeed); diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index 6488206..b9cb671 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -577,8 +577,7 @@ out: } static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, - enum dmx_ts_pes pes_type, size_t callback_length, - size_t circular_buffer_size, int descramble, + enum dmx_ts_pes pes_type, size_t circular_buffer_size, struct timespec timeout) { struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; @@ -610,17 +609,10 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, feed->pid = pid; feed->buffer_size = circular_buffer_size; - feed->descramble = descramble; feed->timeout = timeout; - feed->cb_length = callback_length; feed->ts_type = ts_type; feed->pes_type = pes_type; - if (feed->descramble) { - up(&demux->mutex); - return -ENOSYS; - } - if (feed->buffer_size) { #ifdef NOBUFS feed->buffer=NULL; @@ -819,7 +811,7 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed, static int dmx_section_feed_set(struct dmx_section_feed* feed, u16 pid, size_t circular_buffer_size, - int descramble, int check_crc) + int check_crc) { struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; @@ -834,12 +826,6 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed, dvbdmxfeed->pid = pid; dvbdmxfeed->buffer_size = circular_buffer_size; - dvbdmxfeed->descramble = descramble; - if (dvbdmxfeed->descramble) { - up(&dvbdmx->mutex); - return -ENOSYS; - } - dvbdmxfeed->feed.sec.check_crc = check_crc; #ifdef NOBUFS diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h index 20275a2..d149f2a 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.h +++ b/drivers/media/dvb/dvb-core/dvb_demux.h @@ -54,12 +54,9 @@ struct dvb_demux_filter { int index; int state; int type; - int pesto; - u16 handle; u16 hw_handle; struct timer_list timer; - int ts_state; }; @@ -83,11 +80,9 @@ struct dvb_demux_feed { u16 pid; u8 *buffer; int buffer_size; - int descramble; struct timespec timeout; struct dvb_demux_filter *filter; - int cb_length; int ts_type; enum dmx_ts_pes pes_type; @@ -98,7 +93,7 @@ struct dvb_demux_feed { u16 peslen; struct list_head list_head; - int index; /* a unique index for each feed (can be used as hardware pid filter index) */ + unsigned int index; /* a unique index for each feed (can be used as hardware pid filter index) */ }; struct dvb_demux { diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c index 33a357c..8793549 100644 --- a/drivers/media/dvb/dvb-core/dvb_net.c +++ b/drivers/media/dvb/dvb-core/dvb_net.c @@ -903,7 +903,7 @@ static int dvb_net_feed_start(struct net_device *dev) return ret; } - ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 0, 1); + ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1); if (ret<0) { printk("%s: could not set section feed\n", dev->name); @@ -955,9 +955,7 @@ static int dvb_net_feed_start(struct net_device *dev) priv->tsfeed->priv = (void *)dev; ret = priv->tsfeed->set(priv->tsfeed, priv->pid, TS_PACKET, DMX_TS_PES_OTHER, - 188 * 100, /* nr. of bytes delivered per callback */ 32768, /* circular buffer size */ - 0, /* descramble */ timeout); if (ret < 0) { -- cgit v0.10.2 From db574d7d6e38fe37bbb97e2b0a0363b5d2ffa203 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:26 -0700 Subject: [PATCH] dvb: core: dvb_demux: use INIT_LIST_HEAD Use INIT_LIST_HEAD for frontend_list. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index b9cb671..528ca46 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -1188,9 +1188,9 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) dvbdemux->feed[i].state = DMX_STATE_FREE; dvbdemux->feed[i].index = i; } - dvbdemux->frontend_list.next= - dvbdemux->frontend_list.prev= - &dvbdemux->frontend_list; + + INIT_LIST_HEAD(&dvbdemux->frontend_list); + for (i=0; ipesfilter[i] = NULL; dvbdemux->pids[i] = 0xffff; -- cgit v0.10.2 From dad4a73071532448f6cee29791476494a8eb3a58 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:26 -0700 Subject: [PATCH] dvb: core: dvb_demux formatting fixes Formatting fixes (Lindent + some handwork). Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index 528ca46..dc476dd 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -38,55 +38,52 @@ */ // #define DVB_DEMUX_SECTION_LOSS_LOG - /****************************************************************************** * static inlined helper functions ******************************************************************************/ - static inline u16 section_length(const u8 *buf) { - return 3+((buf[1]&0x0f)<<8)+buf[2]; + return 3 + ((buf[1] & 0x0f) << 8) + buf[2]; } - static inline u16 ts_pid(const u8 *buf) { - return ((buf[1]&0x1f)<<8)+buf[2]; + return ((buf[1] & 0x1f) << 8) + buf[2]; } - static inline u8 payload(const u8 *tsp) { - if (!(tsp[3] & 0x10)) // no payload? + if (!(tsp[3] & 0x10)) // no payload? return 0; - if (tsp[3] & 0x20) { // adaptation field? - if (tsp[4] > 183) // corrupted data? + + if (tsp[3] & 0x20) { // adaptation field? + if (tsp[4] > 183) // corrupted data? return 0; else - return 184-1-tsp[4]; + return 184 - 1 - tsp[4]; } + return 184; } - -static u32 dvb_dmx_crc32 (struct dvb_demux_feed *f, const u8 *src, size_t len) +static u32 dvb_dmx_crc32(struct dvb_demux_feed *f, const u8 *src, size_t len) { - return (f->feed.sec.crc_val = crc32_be (f->feed.sec.crc_val, src, len)); + return (f->feed.sec.crc_val = crc32_be(f->feed.sec.crc_val, src, len)); } - -static void dvb_dmx_memcopy (struct dvb_demux_feed *f, u8 *d, const u8 *s, size_t len) +static void dvb_dmx_memcopy(struct dvb_demux_feed *f, u8 *d, const u8 *s, + size_t len) { - memcpy (d, s, len); + memcpy(d, s, len); } - /****************************************************************************** * Software filter functions ******************************************************************************/ -static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u8 *buf) +static inline int dvb_dmx_swfilter_payload(struct dvb_demux_feed *feed, + const u8 *buf) { int count = payload(buf); int p; @@ -96,32 +93,31 @@ static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u if (count == 0) return -1; - p = 188-count; + p = 188 - count; /* - cc=buf[3]&0x0f; - ccok=((dvbdmxfeed->cc+1)&0x0f)==cc ? 1 : 0; - dvbdmxfeed->cc=cc; + cc = buf[3] & 0x0f; + ccok = ((feed->cc + 1) & 0x0f) == cc; + feed->cc = cc; if (!ccok) printk("missed packet!\n"); */ - if (buf[1] & 0x40) // PUSI ? + if (buf[1] & 0x40) // PUSI ? feed->peslen = 0xfffa; feed->peslen += count; - return feed->cb.ts (&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK); + return feed->cb.ts(&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK); } - -static int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed, - struct dvb_demux_filter *f) +static int dvb_dmx_swfilter_sectionfilter(struct dvb_demux_feed *feed, + struct dvb_demux_filter *f) { u8 neq = 0; int i; - for (i=0; ifilter.filter_value[i] ^ feed->feed.sec.secbuf[i]; if (f->maskandmode[i] & xor) @@ -133,12 +129,11 @@ static int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed, if (f->doneq && !neq) return 0; - return feed->cb.sec (feed->feed.sec.secbuf, feed->feed.sec.seclen, - NULL, 0, &f->filter, DMX_OK); + return feed->cb.sec(feed->feed.sec.secbuf, feed->feed.sec.seclen, + NULL, 0, &f->filter, DMX_OK); } - -static inline int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed) +static inline int dvb_dmx_swfilter_section_feed(struct dvb_demux_feed *feed) { struct dvb_demux *demux = feed->demux; struct dvb_demux_filter *f = feed->filter; @@ -168,26 +163,24 @@ static inline int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed) return 0; } - static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) { struct dmx_section_feed *sec = &feed->feed.sec; #ifdef DVB_DEMUX_SECTION_LOSS_LOG - if(sec->secbufp < sec->tsfeedp) - { + if (sec->secbufp < sec->tsfeedp) { int i, n = sec->tsfeedp - sec->secbufp; - /* section padding is done with 0xff bytes entirely. - ** due to speed reasons, we won't check all of them - ** but just first and last - */ - if(sec->secbuf[0] != 0xff || sec->secbuf[n-1] != 0xff) - { + /* + * Section padding is done with 0xff bytes entirely. + * Due to speed reasons, we won't check all of them + * but just first and last. + */ + if (sec->secbuf[0] != 0xff || sec->secbuf[n - 1] != 0xff) { printk("dvb_demux.c section ts padding loss: %d/%d\n", n, sec->tsfeedp); printk("dvb_demux.c pad data:"); - for(i = 0; i < n; i++) + for (i = 0; i < n; i++) printk(" %02x", sec->secbuf[i]); printk("\n"); } @@ -199,82 +192,81 @@ static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) } /* -** Losless Section Demux 1.4.1 by Emard -** Valsecchi Patrick: -** - middle of section A (no PUSI) -** - end of section A and start of section B -** (with PUSI pointing to the start of the second section) -** -** In this case, without feed->pusi_seen you'll receive a garbage section -** consisting of the end of section A. Basically because tsfeedp -** is incemented and the use=0 condition is not raised -** when the second packet arrives. -** -** Fix: -** when demux is started, let feed->pusi_seen = 0 to -** prevent initial feeding of garbage from the end of -** previous section. When you for the first time see PUSI=1 -** then set feed->pusi_seen = 1 -*/ -static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const u8 *buf, u8 len) + * Losless Section Demux 1.4.1 by Emard + * Valsecchi Patrick: + * - middle of section A (no PUSI) + * - end of section A and start of section B + * (with PUSI pointing to the start of the second section) + * + * In this case, without feed->pusi_seen you'll receive a garbage section + * consisting of the end of section A. Basically because tsfeedp + * is incemented and the use=0 condition is not raised + * when the second packet arrives. + * + * Fix: + * when demux is started, let feed->pusi_seen = 0 to + * prevent initial feeding of garbage from the end of + * previous section. When you for the first time see PUSI=1 + * then set feed->pusi_seen = 1 + */ +static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, + const u8 *buf, u8 len) { struct dvb_demux *demux = feed->demux; struct dmx_section_feed *sec = &feed->feed.sec; u16 limit, seclen, n; - if(sec->tsfeedp >= DMX_MAX_SECFEED_SIZE) + if (sec->tsfeedp >= DMX_MAX_SECFEED_SIZE) return 0; - if(sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) - { + if (sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) { #ifdef DVB_DEMUX_SECTION_LOSS_LOG printk("dvb_demux.c section buffer full loss: %d/%d\n", - sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE, DMX_MAX_SECFEED_SIZE); + sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE, + DMX_MAX_SECFEED_SIZE); #endif len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp; } - if(len <= 0) + if (len <= 0) return 0; demux->memcopy(feed, sec->secbuf_base + sec->tsfeedp, buf, len); sec->tsfeedp += len; - /* ----------------------------------------------------- - ** Dump all the sections we can find in the data (Emard) - */ - + /* + * Dump all the sections we can find in the data (Emard) + */ limit = sec->tsfeedp; - if(limit > DMX_MAX_SECFEED_SIZE) - return -1; /* internal error should never happen */ + if (limit > DMX_MAX_SECFEED_SIZE) + return -1; /* internal error should never happen */ /* to be sure always set secbuf */ sec->secbuf = sec->secbuf_base + sec->secbufp; - for(n = 0; sec->secbufp + 2 < limit; n++) - { + for (n = 0; sec->secbufp + 2 < limit; n++) { seclen = section_length(sec->secbuf); - if(seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE - || seclen + sec->secbufp > limit) + if (seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE + || seclen + sec->secbufp > limit) return 0; sec->seclen = seclen; sec->crc_val = ~0; /* dump [secbuf .. secbuf+seclen) */ - if(feed->pusi_seen) + if (feed->pusi_seen) dvb_dmx_swfilter_section_feed(feed); #ifdef DVB_DEMUX_SECTION_LOSS_LOG else printk("dvb_demux.c pusi not seen, discarding section data\n"); #endif - sec->secbufp += seclen; /* secbufp and secbuf moving together is */ - sec->secbuf += seclen; /* redundand but saves pointer arithmetic */ + sec->secbufp += seclen; /* secbufp and secbuf moving together is */ + sec->secbuf += seclen; /* redundant but saves pointer arithmetic */ } return 0; } - -static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf) +static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, + const u8 *buf) { u8 p, count; int ccok, dc_i = 0; @@ -282,10 +274,10 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 count = payload(buf); - if (count == 0) /* count == 0 if no payload or out of range */ + if (count == 0) /* count == 0 if no payload or out of range */ return -1; - p = 188 - count; /* payload start */ + p = 188 - count; /* payload start */ cc = buf[3] & 0x0f; ccok = ((feed->cc + 1) & 0x0f) == cc; @@ -299,51 +291,53 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 if (!ccok || dc_i) { #ifdef DVB_DEMUX_SECTION_LOSS_LOG - printk("dvb_demux.c discontinuity detected %d bytes lost\n", count); - /* those bytes under sume circumstances will again be reported - ** in the following dvb_dmx_swfilter_section_new - */ + printk("dvb_demux.c discontinuity detected %d bytes lost\n", + count); + /* + * those bytes under sume circumstances will again be reported + * in the following dvb_dmx_swfilter_section_new + */ #endif - /* Discontinuity detected. Reset pusi_seen = 0 to - ** stop feeding of suspicious data until next PUSI=1 arrives - */ + /* + * Discontinuity detected. Reset pusi_seen = 0 to + * stop feeding of suspicious data until next PUSI=1 arrives + */ feed->pusi_seen = 0; dvb_dmx_swfilter_section_new(feed); } if (buf[1] & 0x40) { - // PUSI=1 (is set), section boundary is here + /* PUSI=1 (is set), section boundary is here */ if (count > 1 && buf[p] < count) { - const u8 *before = buf+p+1; + const u8 *before = &buf[p + 1]; u8 before_len = buf[p]; - const u8 *after = before+before_len; - u8 after_len = count-1-before_len; + const u8 *after = &before[before_len]; + u8 after_len = count - 1 - before_len; - dvb_dmx_swfilter_section_copy_dump(feed, before, before_len); + dvb_dmx_swfilter_section_copy_dump(feed, before, + before_len); /* before start of new section, set pusi_seen = 1 */ feed->pusi_seen = 1; dvb_dmx_swfilter_section_new(feed); - dvb_dmx_swfilter_section_copy_dump(feed, after, after_len); + dvb_dmx_swfilter_section_copy_dump(feed, after, + after_len); } #ifdef DVB_DEMUX_SECTION_LOSS_LOG - else - if (count > 0) - printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count); + else if (count > 0) + printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count); #endif } else { - // PUSI=0 (is not set), no section boundary - const u8 *entire = buf+p; - u8 entire_len = count; - - dvb_dmx_swfilter_section_copy_dump(feed, entire, entire_len); + /* PUSI=0 (is not set), no section boundary */ + dvb_dmx_swfilter_section_copy_dump(feed, &buf[p], count); } + return 0; } - -static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, const u8 *buf) +static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, + const u8 *buf) { - switch(feed->type) { + switch (feed->type) { case DMX_TYPE_TS: if (!feed->feed.ts.is_filtering) break; @@ -351,7 +345,8 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con if (feed->ts_type & TS_PAYLOAD_ONLY) dvb_dmx_swfilter_payload(feed, buf); else - feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, DMX_OK); + feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, + DMX_OK); } if (feed->ts_type & TS_DECODER) if (feed->demux->write_to_decoder) @@ -362,7 +357,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con if (!feed->feed.sec.is_filtering) break; if (dvb_dmx_swfilter_section_packet(feed, buf) < 0) - feed->feed.sec.seclen = feed->feed.sec.secbufp=0; + feed->feed.sec.seclen = feed->feed.sec.secbufp = 0; break; default: @@ -378,7 +373,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) { struct dvb_demux_feed *feed; - struct list_head *pos, *head=&demux->feed_list; + struct list_head *pos, *head = &demux->feed_list; u16 pid = ts_pid(buf); int dvr_done = 0; @@ -404,21 +399,21 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) } } -void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, size_t count) +void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, + size_t count) { spin_lock(&demux->lock); while (count--) { - if(buf[0] == 0x47) { - dvb_dmx_swfilter_packet(demux, buf); - } + if (buf[0] == 0x47) + dvb_dmx_swfilter_packet(demux, buf); buf += 188; } spin_unlock(&demux->lock); } -EXPORT_SYMBOL(dvb_dmx_swfilter_packets); +EXPORT_SYMBOL(dvb_dmx_swfilter_packets); void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) { @@ -426,8 +421,10 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) spin_lock(&demux->lock); - if ((i = demux->tsbufp)) { - if (count < (j=188-i)) { + if (demux->tsbufp) { + i = demux->tsbufp; + j = 188 - i; + if (count < j) { memcpy(&demux->tsbuf[i], buf, count); demux->tsbufp += count; goto bailout; @@ -441,13 +438,13 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) while (p < count) { if (buf[p] == 0x47) { - if (count-p >= 188) { - dvb_dmx_swfilter_packet(demux, buf+p); + if (count - p >= 188) { + dvb_dmx_swfilter_packet(demux, &buf[p]); p += 188; } else { - i = count-p; - memcpy(demux->tsbuf, buf+p, i); - demux->tsbufp=i; + i = count - p; + memcpy(demux->tsbuf, &buf[p], i); + demux->tsbufp = i; goto bailout; } } else @@ -457,24 +454,29 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) bailout: spin_unlock(&demux->lock); } + EXPORT_SYMBOL(dvb_dmx_swfilter); void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) { - int p = 0,i, j; + int p = 0, i, j; u8 tmppack[188]; + spin_lock(&demux->lock); - if ((i = demux->tsbufp)) { - if (count < (j=204-i)) { + if (demux->tsbufp) { + i = demux->tsbufp; + j = 204 - i; + if (count < j) { memcpy(&demux->tsbuf[i], buf, count); demux->tsbufp += count; goto bailout; } memcpy(&demux->tsbuf[i], buf, j); - if ((demux->tsbuf[0] == 0x47)|(demux->tsbuf[0]==0xB8)) { + if ((demux->tsbuf[0] == 0x47) | (demux->tsbuf[0] == 0xB8)) { memcpy(tmppack, demux->tsbuf, 188); - if (tmppack[0] == 0xB8) tmppack[0] = 0x47; + if (tmppack[0] == 0xB8) + tmppack[0] = 0x47; dvb_dmx_swfilter_packet(demux, tmppack); } demux->tsbufp = 0; @@ -482,16 +484,17 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) } while (p < count) { - if ((buf[p] == 0x47)|(buf[p] == 0xB8)) { - if (count-p >= 204) { - memcpy(tmppack, buf+p, 188); - if (tmppack[0] == 0xB8) tmppack[0] = 0x47; + if ((buf[p] == 0x47) | (buf[p] == 0xB8)) { + if (count - p >= 204) { + memcpy(tmppack, &buf[p], 188); + if (tmppack[0] == 0xB8) + tmppack[0] = 0x47; dvb_dmx_swfilter_packet(demux, tmppack); p += 204; } else { - i = count-p; - memcpy(demux->tsbuf, buf+p, i); - demux->tsbufp=i; + i = count - p; + memcpy(demux->tsbuf, &buf[p], i); + demux->tsbufp = i; goto bailout; } } else { @@ -502,14 +505,14 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) bailout: spin_unlock(&demux->lock); } -EXPORT_SYMBOL(dvb_dmx_swfilter_204); +EXPORT_SYMBOL(dvb_dmx_swfilter_204); -static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux) +static struct dvb_demux_filter *dvb_dmx_filter_alloc(struct dvb_demux *demux) { int i; - for (i=0; ifilternum; i++) + for (i = 0; i < demux->filternum; i++) if (demux->filter[i].state == DMX_STATE_FREE) break; @@ -521,11 +524,11 @@ static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux) return &demux->filter[i]; } -static struct dvb_demux_feed * dvb_dmx_feed_alloc(struct dvb_demux *demux) +static struct dvb_demux_feed *dvb_dmx_feed_alloc(struct dvb_demux *demux) { int i; - for (i=0; ifeednum; i++) + for (i = 0; i < demux->feednum; i++) if (demux->feed[i].state == DMX_STATE_FREE) break; @@ -553,7 +556,7 @@ static void dvb_demux_feed_add(struct dvb_demux_feed *feed) spin_lock_irq(&feed->demux->lock); if (dvb_demux_feed_find(feed)) { printk(KERN_ERR "%s: feed already in list (type=%x state=%x pid=%x)\n", - __FUNCTION__, feed->type, feed->state, feed->pid); + __FUNCTION__, feed->type, feed->state, feed->pid); goto out; } @@ -567,7 +570,7 @@ static void dvb_demux_feed_del(struct dvb_demux_feed *feed) spin_lock_irq(&feed->demux->lock); if (!(dvb_demux_feed_find(feed))) { printk(KERN_ERR "%s: feed not in list (type=%x state=%x pid=%x)\n", - __FUNCTION__, feed->type, feed->state, feed->pid); + __FUNCTION__, feed->type, feed->state, feed->pid); goto out; } @@ -576,17 +579,17 @@ out: spin_unlock_irq(&feed->demux->lock); } -static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, - enum dmx_ts_pes pes_type, size_t circular_buffer_size, - struct timespec timeout) +static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type, + enum dmx_ts_pes pes_type, + size_t circular_buffer_size, struct timespec timeout) { - struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; + struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; struct dvb_demux *demux = feed->demux; if (pid > DMX_MAX_PID) return -EINVAL; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (ts_type & TS_DECODER) { @@ -615,7 +618,7 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, if (feed->buffer_size) { #ifdef NOBUFS - feed->buffer=NULL; + feed->buffer = NULL; #else feed->buffer = vmalloc(feed->buffer_size); if (!feed->buffer) { @@ -631,14 +634,13 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, return 0; } - -static int dmx_ts_feed_start_filtering(struct dmx_ts_feed* ts_feed) +static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed) { - struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; + struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; struct dvb_demux *demux = feed->demux; int ret; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) { @@ -665,13 +667,13 @@ static int dmx_ts_feed_start_filtering(struct dmx_ts_feed* ts_feed) return 0; } -static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed* ts_feed) +static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed) { - struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; + struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; struct dvb_demux *demux = feed->demux; int ret; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (feed->state < DMX_STATE_GO) { @@ -695,13 +697,14 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed* ts_feed) return ret; } -static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed **ts_feed, - dmx_ts_cb callback) +static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx, + struct dmx_ts_feed **ts_feed, + dmx_ts_cb callback) { - struct dvb_demux *demux = (struct dvb_demux *) dmx; + struct dvb_demux *demux = (struct dvb_demux *)dmx; struct dvb_demux_feed *feed; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (!(feed = dvb_dmx_feed_alloc(demux))) { @@ -724,7 +727,6 @@ static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed ** (*ts_feed)->stop_filtering = dmx_ts_feed_stop_filtering; (*ts_feed)->set = dmx_ts_feed_set; - if (!(feed->filter = dvb_dmx_filter_alloc(demux))) { feed->state = DMX_STATE_FREE; up(&demux->mutex); @@ -740,22 +742,22 @@ static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed ** return 0; } -static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_feed) +static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, + struct dmx_ts_feed *ts_feed) { - struct dvb_demux *demux = (struct dvb_demux *) dmx; - struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; + struct dvb_demux *demux = (struct dvb_demux *)dmx; + struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (feed->state == DMX_STATE_FREE) { up(&demux->mutex); return -EINVAL; } - #ifndef NOBUFS vfree(feed->buffer); - feed->buffer=0; + feed->buffer = NULL; #endif feed->state = DMX_STATE_FREE; @@ -772,19 +774,18 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_ return 0; } - /****************************************************************************** * dmx_section_feed API calls ******************************************************************************/ -static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed, - struct dmx_section_filter** filter) +static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed, + struct dmx_section_filter **filter) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdemux = dvbdmxfeed->demux; struct dvb_demux_filter *dvbdmxfilter; - if (down_interruptible (&dvbdemux->mutex)) + if (down_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux); @@ -808,18 +809,17 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed, return 0; } - -static int dmx_section_feed_set(struct dmx_section_feed* feed, - u16 pid, size_t circular_buffer_size, - int check_crc) +static int dmx_section_feed_set(struct dmx_section_feed *feed, + u16 pid, size_t circular_buffer_size, + int check_crc) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; if (pid > 0x1fff) return -EINVAL; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; dvb_demux_feed_add(dvbdmxfeed); @@ -831,7 +831,7 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed, #ifdef NOBUFS dvbdmxfeed->buffer = NULL; #else - dvbdmxfeed->buffer=vmalloc(dvbdmxfeed->buffer_size); + dvbdmxfeed->buffer = vmalloc(dvbdmxfeed->buffer_size); if (!dvbdmxfeed->buffer) { up(&dvbdmx->mutex); return -ENOMEM; @@ -843,7 +843,6 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed, return 0; } - static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) { int i; @@ -851,12 +850,12 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) struct dmx_section_filter *sf; u8 mask, mode, doneq; - if (!(f=dvbdmxfeed->filter)) + if (!(f = dvbdmxfeed->filter)) return; do { sf = &f->filter; doneq = 0; - for (i=0; ifilter_mode[i]; mask = sf->filter_mask[i]; f->maskandmode[i] = mask & mode; @@ -866,14 +865,13 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) } while ((f = f->next)); } - static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; int ret; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (feed->is_filtering) { @@ -912,14 +910,13 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) return 0; } - -static int dmx_section_feed_stop_filtering(struct dmx_section_feed* feed) +static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; int ret; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (!dvbdmx->stop_feed) { @@ -938,15 +935,14 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed* feed) return ret; } - static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, - struct dmx_section_filter* filter) + struct dmx_section_filter *filter) { - struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *) filter, *f; - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *)filter, *f; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (dvbdmxfilter->feed != dvbdmxfeed) { @@ -963,7 +959,7 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, if (f == dvbdmxfilter) { dvbdmxfeed->filter = dvbdmxfilter->next; } else { - while(f->next != dvbdmxfilter) + while (f->next != dvbdmxfilter) f = f->next; f->next = f->next->next; } @@ -978,10 +974,10 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, struct dmx_section_feed **feed, dmx_section_cb callback) { - struct dvb_demux *dvbdmx = (struct dvb_demux *) demux; + struct dvb_demux *dvbdmx = (struct dvb_demux *)demux; struct dvb_demux_feed *dvbdmxfeed; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) { @@ -999,7 +995,7 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, dvbdmxfeed->filter = NULL; dvbdmxfeed->buffer = NULL; - (*feed)=&dvbdmxfeed->feed.sec; + (*feed) = &dvbdmxfeed->feed.sec; (*feed)->is_filtering = 0; (*feed)->parent = demux; (*feed)->priv = NULL; @@ -1017,21 +1013,21 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, static int dvbdmx_release_section_feed(struct dmx_demux *demux, struct dmx_section_feed *feed) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; - struct dvb_demux *dvbdmx = (struct dvb_demux *) demux; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; + struct dvb_demux *dvbdmx = (struct dvb_demux *)demux; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; - if (dvbdmxfeed->state==DMX_STATE_FREE) { + if (dvbdmxfeed->state == DMX_STATE_FREE) { up(&dvbdmx->mutex); return -EINVAL; } #ifndef NOBUFS vfree(dvbdmxfeed->buffer); - dvbdmxfeed->buffer=0; + dvbdmxfeed->buffer = NULL; #endif - dvbdmxfeed->state=DMX_STATE_FREE; + dvbdmxfeed->state = DMX_STATE_FREE; dvb_demux_feed_del(dvbdmxfeed); @@ -1041,14 +1037,13 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux, return 0; } - /****************************************************************************** * dvb_demux kernel data API calls ******************************************************************************/ static int dvbdmx_open(struct dmx_demux *demux) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if (dvbdemux->users >= MAX_DVB_DEMUX_USERS) return -EUSERS; @@ -1057,10 +1052,9 @@ static int dvbdmx_open(struct dmx_demux *demux) return 0; } - static int dvbdmx_close(struct dmx_demux *demux) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if (dvbdemux->users == 0) return -ENODEV; @@ -1070,15 +1064,14 @@ static int dvbdmx_close(struct dmx_demux *demux) return 0; } - static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count) { - struct dvb_demux *dvbdemux=(struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE)) return -EINVAL; - if (down_interruptible (&dvbdemux->mutex)) + if (down_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; dvb_dmx_swfilter(dvbdemux, buf, count); up(&dvbdemux->mutex); @@ -1088,10 +1081,10 @@ static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count) return count; } - -static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) +static int dvbdmx_add_frontend(struct dmx_demux *demux, + struct dmx_frontend *frontend) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; struct list_head *head = &dvbdemux->frontend_list; list_add(&(frontend->connectivity_list), head); @@ -1099,13 +1092,13 @@ static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *fro return 0; } - -static int dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) +static int dvbdmx_remove_frontend(struct dmx_demux *demux, + struct dmx_frontend *frontend) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; struct list_head *pos, *n, *head = &dvbdemux->frontend_list; - list_for_each_safe (pos, n, head) { + list_for_each_safe(pos, n, head) { if (DMX_FE_ENTRY(pos) == frontend) { list_del(pos); return 0; @@ -1115,25 +1108,25 @@ static int dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend * return -ENODEV; } - -static struct list_head * dvbdmx_get_frontends(struct dmx_demux *demux) +static struct list_head *dvbdmx_get_frontends(struct dmx_demux *demux) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if (list_empty(&dvbdemux->frontend_list)) return NULL; + return &dvbdemux->frontend_list; } - -static int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) +static int dvbdmx_connect_frontend(struct dmx_demux *demux, + struct dmx_frontend *frontend) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if (demux->frontend) return -EINVAL; - if (down_interruptible (&dvbdemux->mutex)) + if (down_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; demux->frontend = frontend; @@ -1141,12 +1134,11 @@ static int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend return 0; } - static int dvbdmx_disconnect_frontend(struct dmx_demux *demux) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; - if (down_interruptible (&dvbdemux->mutex)) + if (down_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; demux->frontend = NULL; @@ -1154,44 +1146,42 @@ static int dvbdmx_disconnect_frontend(struct dmx_demux *demux) return 0; } - -static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 *pids) +static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 * pids) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; - memcpy(pids, dvbdemux->pids, 5*sizeof(u16)); + memcpy(pids, dvbdemux->pids, 5 * sizeof(u16)); return 0; } - int dvb_dmx_init(struct dvb_demux *dvbdemux) { int i; struct dmx_demux *dmx = &dvbdemux->dmx; dvbdemux->users = 0; - dvbdemux->filter = vmalloc(dvbdemux->filternum*sizeof(struct dvb_demux_filter)); + dvbdemux->filter = vmalloc(dvbdemux->filternum * sizeof(struct dvb_demux_filter)); if (!dvbdemux->filter) return -ENOMEM; - dvbdemux->feed = vmalloc(dvbdemux->feednum*sizeof(struct dvb_demux_feed)); + dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed)); if (!dvbdemux->feed) { vfree(dvbdemux->filter); return -ENOMEM; } - for (i=0; ifilternum; i++) { + for (i = 0; i < dvbdemux->filternum; i++) { dvbdemux->filter[i].state = DMX_STATE_FREE; dvbdemux->filter[i].index = i; } - for (i=0; ifeednum; i++) { + for (i = 0; i < dvbdemux->feednum; i++) { dvbdemux->feed[i].state = DMX_STATE_FREE; dvbdemux->feed[i].index = i; } INIT_LIST_HEAD(&dvbdemux->frontend_list); - for (i=0; ipesfilter[i] = NULL; dvbdemux->pids[i] = 0xffff; } @@ -1205,11 +1195,11 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) if (!dvbdemux->check_crc32) dvbdemux->check_crc32 = dvb_dmx_crc32; - if (!dvbdemux->memcopy) - dvbdemux->memcopy = dvb_dmx_memcopy; + if (!dvbdemux->memcopy) + dvbdemux->memcopy = dvb_dmx_memcopy; dmx->frontend = NULL; - dmx->priv = (void *) dvbdemux; + dmx->priv = dvbdemux; dmx->open = dvbdmx_open; dmx->close = dvbdmx_close; dmx->write = dvbdmx_write; @@ -1230,12 +1220,13 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) return 0; } -EXPORT_SYMBOL(dvb_dmx_init); +EXPORT_SYMBOL(dvb_dmx_init); void dvb_dmx_release(struct dvb_demux *dvbdemux) { vfree(dvbdemux->filter); vfree(dvbdemux->feed); } + EXPORT_SYMBOL(dvb_dmx_release); diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h index d149f2a..0cc8883 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.h +++ b/drivers/media/dvb/dvb-core/dvb_demux.h @@ -20,7 +20,6 @@ * */ - #ifndef _DVB_DEMUX_H_ #define _DVB_DEMUX_H_ @@ -44,98 +43,98 @@ #define DVB_DEMUX_MASK_MAX 18 struct dvb_demux_filter { - struct dmx_section_filter filter; - u8 maskandmode [DMX_MAX_FILTER_SIZE]; - u8 maskandnotmode [DMX_MAX_FILTER_SIZE]; + struct dmx_section_filter filter; + u8 maskandmode[DMX_MAX_FILTER_SIZE]; + u8 maskandnotmode[DMX_MAX_FILTER_SIZE]; int doneq; - struct dvb_demux_filter *next; - struct dvb_demux_feed *feed; - int index; - int state; - int type; + struct dvb_demux_filter *next; + struct dvb_demux_feed *feed; + int index; + int state; + int type; - u16 hw_handle; - struct timer_list timer; + u16 hw_handle; + struct timer_list timer; }; - #define DMX_FEED_ENTRY(pos) list_entry(pos, struct dvb_demux_feed, list_head) struct dvb_demux_feed { - union { - struct dmx_ts_feed ts; - struct dmx_section_feed sec; + union { + struct dmx_ts_feed ts; + struct dmx_section_feed sec; } feed; - union { - dmx_ts_cb ts; - dmx_section_cb sec; + union { + dmx_ts_cb ts; + dmx_section_cb sec; } cb; - struct dvb_demux *demux; + struct dvb_demux *demux; void *priv; - int type; - int state; - u16 pid; - u8 *buffer; - int buffer_size; + int type; + int state; + u16 pid; + u8 *buffer; + int buffer_size; - struct timespec timeout; - struct dvb_demux_filter *filter; + struct timespec timeout; + struct dvb_demux_filter *filter; - int ts_type; - enum dmx_ts_pes pes_type; + int ts_type; + enum dmx_ts_pes pes_type; - int cc; - int pusi_seen; /* prevents feeding of garbage from previous section */ + int cc; + int pusi_seen; /* prevents feeding of garbage from previous section */ - u16 peslen; + u16 peslen; struct list_head list_head; - unsigned int index; /* a unique index for each feed (can be used as hardware pid filter index) */ + unsigned int index; /* a unique index for each feed (can be used as hardware pid filter index) */ }; struct dvb_demux { - struct dmx_demux dmx; - void *priv; - int filternum; - int feednum; - int (*start_feed) (struct dvb_demux_feed *feed); - int (*stop_feed) (struct dvb_demux_feed *feed); - int (*write_to_decoder) (struct dvb_demux_feed *feed, + struct dmx_demux dmx; + void *priv; + int filternum; + int feednum; + int (*start_feed)(struct dvb_demux_feed *feed); + int (*stop_feed)(struct dvb_demux_feed *feed); + int (*write_to_decoder)(struct dvb_demux_feed *feed, const u8 *buf, size_t len); - u32 (*check_crc32) (struct dvb_demux_feed *feed, + u32 (*check_crc32)(struct dvb_demux_feed *feed, const u8 *buf, size_t len); - void (*memcopy) (struct dvb_demux_feed *feed, u8 *dst, + void (*memcopy)(struct dvb_demux_feed *feed, u8 *dst, const u8 *src, size_t len); - int users; + int users; #define MAX_DVB_DEMUX_USERS 10 - struct dvb_demux_filter *filter; - struct dvb_demux_feed *feed; + struct dvb_demux_filter *filter; + struct dvb_demux_feed *feed; - struct list_head frontend_list; + struct list_head frontend_list; - struct dvb_demux_feed *pesfilter[DMX_TS_PES_OTHER]; - u16 pids[DMX_TS_PES_OTHER]; - int playing; - int recording; + struct dvb_demux_feed *pesfilter[DMX_TS_PES_OTHER]; + u16 pids[DMX_TS_PES_OTHER]; + int playing; + int recording; #define DMX_MAX_PID 0x2000 struct list_head feed_list; - u8 tsbuf[204]; - int tsbufp; + u8 tsbuf[204]; + int tsbufp; struct semaphore mutex; spinlock_t lock; }; - int dvb_dmx_init(struct dvb_demux *dvbdemux); void dvb_dmx_release(struct dvb_demux *dvbdemux); -void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, size_t count); +void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, + size_t count); void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count); -void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count); +void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, + size_t count); #endif /* _DVB_DEMUX_H_ */ -- cgit v0.10.2 From 50b447d5b70dc4021ae3b4eaf8ce98932f61a413 Mon Sep 17 00:00:00 2001 From: Dominique Dumont Date: Fri, 9 Sep 2005 13:02:27 -0700 Subject: [PATCH] dvb: core: CI timeout fix Patch from Dominique Dumont to get the SCM Red Viaccess CAM working with the budget-ci. Signed-off-by: Dominique Dumont Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index 0eb9aa7..88757e2 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c @@ -47,7 +47,7 @@ MODULE_PARM_DESC(cam_debug, "enable verbose debug messages"); #define dprintk if (dvb_ca_en50221_debug) printk -#define INIT_TIMEOUT_SECS 5 +#define INIT_TIMEOUT_SECS 10 #define HOST_LINK_BUF_SIZE 0x200 -- cgit v0.10.2 From 4ff4ac1beae58a2fea7ec2ad43d6c3b60d90ec61 Mon Sep 17 00:00:00 2001 From: Barry Scott Date: Fri, 9 Sep 2005 13:02:29 -0700 Subject: [PATCH] dvb: frontend: mt352: fix signal strength reading Fix two problems with the signal strength value in the mt352.c frontend: 1. the 4 most significant bits are zeroed - shift and mask wrong way round 2. need to align the 12 bits from the registers at the top of the 16 bit returned value - otherwise the range is not 0 to 0xffff its 0xf000 to 0xffff Signed-off-by: Barry Scott Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/frontends/mt352.c b/drivers/media/dvb/frontends/mt352.c index d32dc4d..cc1bc0e 100644 --- a/drivers/media/dvb/frontends/mt352.c +++ b/drivers/media/dvb/frontends/mt352.c @@ -462,9 +462,11 @@ static int mt352_read_signal_strength(struct dvb_frontend* fe, u16* strength) { struct mt352_state* state = fe->demodulator_priv; - u16 signal = ((mt352_read_register(state, AGC_GAIN_1) << 8) & 0x0f) | - (mt352_read_register(state, AGC_GAIN_0)); + /* align the 12 bit AGC gain with the most significant bits */ + u16 signal = ((mt352_read_register(state, AGC_GAIN_1) & 0x0f) << 12) | + (mt352_read_register(state, AGC_GAIN_0) << 4); + /* inverse of gain is signal strength */ *strength = ~signal; return 0; } -- cgit v0.10.2 From cfbfce1566f11c0dbad8a16173f0448b0c78cecb Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:30 -0700 Subject: [PATCH] dvb: frontend: stv0299: pass i2c bus to pll callback Pass a pointer to the i2c bus to the pll callbacks (stv0299 only). It was not possible to tell which i2c bus should be used if an adapter has multiple frontends on multiple i2c buses. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index 0410cc9..a36bec3 100644 --- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c +++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c @@ -164,12 +164,11 @@ static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, return 0; } -static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { u8 buf[4]; u32 div; struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) }; - struct flexcop_device *fc = fe->dvb->priv; div = params->frequency / 125; @@ -180,7 +179,7 @@ static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_fronten if (params->frequency < 1500000) buf[3] |= 0x10; - if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c index cfa3928..db66d41 100644 --- a/drivers/media/dvb/frontends/stv0299.c +++ b/drivers/media/dvb/frontends/stv0299.c @@ -481,7 +481,7 @@ static int stv0299_init (struct dvb_frontend* fe) if (state->config->pll_init) { stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ - state->config->pll_init(fe); + state->config->pll_init(fe, state->i2c); stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ } @@ -603,7 +603,7 @@ static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par } else { /* A "normal" tune is requested */ stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ stv0299_writeregI(state, 0x32, 0x80); @@ -615,7 +615,7 @@ static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par } } else { stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ stv0299_set_FEC (state, p->u.qpsk.fec_inner); diff --git a/drivers/media/dvb/frontends/stv0299.h b/drivers/media/dvb/frontends/stv0299.h index 79457a8..d0c4484 100644 --- a/drivers/media/dvb/frontends/stv0299.h +++ b/drivers/media/dvb/frontends/stv0299.h @@ -92,8 +92,8 @@ struct stv0299_config int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio); /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params); }; extern int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data); diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index e4c6e87..c91cf89 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c @@ -1668,9 +1668,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { - struct av7110* av7110 = (struct av7110*) fe->dvb->priv; int ret; u8 data[4]; u32 div; @@ -1687,7 +1686,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param if (params->frequency > 1530000) data[3] = 0xc0; - ret = i2c_transfer(&av7110->i2c_adap, &msg, 1); + ret = i2c_transfer(i2c, &msg, 1); if (ret != 1) return -EIO; return 0; @@ -1751,9 +1750,8 @@ static u8 alps_bsbe1_inittab[] = { 0xff, 0xff }; -static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { - struct av7110* av7110 = (struct av7110*) fe->dvb->priv; int ret; u8 data[4]; u32 div; @@ -1768,7 +1766,7 @@ static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4; - ret = i2c_transfer(&av7110->i2c_adap, &msg, 1); + ret = i2c_transfer(i2c, &msg, 1); return (ret != 1) ? -EIO : 0; } diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 9746d2b..311be50 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c @@ -453,9 +453,9 @@ static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 sra } static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { - struct budget_av *budget_av = (struct budget_av *) fe->dvb->priv; u32 div; u8 buf[4]; struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; @@ -481,7 +481,7 @@ static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, else if (params->frequency < 2150000) buf[3] |= 0xC0; - if (i2c_transfer(&budget_av->budget.i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index a126705..88f27a5 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c @@ -548,9 +548,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) +static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { - struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; u8 buf[4]; u32 div; struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; @@ -567,7 +566,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_param if (params->frequency > 1530000) buf[3] = 0xc0; - if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } @@ -669,9 +668,9 @@ static int philips_su1278_tt_set_symbol_rate(struct dvb_frontend *fe, u32 srate, } static int philips_su1278_tt_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { - struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; u32 div; u8 buf[4]; struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) }; @@ -697,7 +696,7 @@ static int philips_su1278_tt_pll_set(struct dvb_frontend *fe, else if (params->frequency < 2150000) buf[3] |= 0xC0; - if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c index 8142e26..b1f21ef 100644 --- a/drivers/media/dvb/ttpci/budget-patch.c +++ b/drivers/media/dvb/ttpci/budget-patch.c @@ -353,9 +353,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { - struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv; u8 data[4]; u32 div; struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; @@ -370,7 +369,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param if (params->frequency > 1530000) data[3] = 0xc0; - if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c index 9961917..5552ef5 100644 --- a/drivers/media/dvb/ttpci/budget.c +++ b/drivers/media/dvb/ttpci/budget.c @@ -332,9 +332,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { - struct budget* budget = (struct budget*) fe->dvb->priv; u8 data[4]; u32 div; struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; @@ -349,7 +348,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param if (params->frequency > 1530000) data[3] = 0xc0; - if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 7daf7b1..c1acd4b 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c @@ -1299,7 +1299,7 @@ static int alps_stv0299_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 return 0; } -static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) +static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; u8 buf[4]; @@ -1322,7 +1322,7 @@ static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct dvb_frontend_ if (ttusb->revision == TTUSB_REV_2_2) buf[3] |= 0x20; - if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; -- cgit v0.10.2 From a9d6a80b41c04e8ff4c7442cc35f5df610863841 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 9 Sep 2005 13:02:31 -0700 Subject: [PATCH] dvb: frontend: s5h1420: fixes Misc. fixes. Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c index 4f396ac..c7fe27f 100644 --- a/drivers/media/dvb/frontends/s5h1420.c +++ b/drivers/media/dvb/frontends/s5h1420.c @@ -48,7 +48,8 @@ struct s5h1420_state { }; static u32 s5h1420_getsymbolrate(struct s5h1420_state* state); -static int s5h1420_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings); +static int s5h1420_get_tune_settings(struct dvb_frontend* fe, + struct dvb_frontend_tune_settings* fesettings); static int debug = 0; @@ -91,7 +92,8 @@ static int s5h1420_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag switch(voltage) { case SEC_VOLTAGE_13: - s5h1420_writereg(state, 0x3c, (s5h1420_readreg(state, 0x3c) & 0xfe) | 0x02); + s5h1420_writereg(state, 0x3c, + (s5h1420_readreg(state, 0x3c) & 0xfe) | 0x02); break; case SEC_VOLTAGE_18: @@ -112,18 +114,21 @@ static int s5h1420_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) switch(tone) { case SEC_TONE_ON: - s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x74) | 0x08); + s5h1420_writereg(state, 0x3b, + (s5h1420_readreg(state, 0x3b) & 0x74) | 0x08); break; case SEC_TONE_OFF: - s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01); + s5h1420_writereg(state, 0x3b, + (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01); break; } return 0; } -static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd) +static int s5h1420_send_master_cmd (struct dvb_frontend* fe, + struct dvb_diseqc_master_cmd* cmd) { struct s5h1420_state* state = fe->demodulator_priv; u8 val; @@ -131,6 +136,9 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_m unsigned long timeout; int result = 0; + if (cmd->msg_len > 8) + return -EINVAL; + /* setup for DISEQC */ val = s5h1420_readreg(state, 0x3b); s5h1420_writereg(state, 0x3b, 0x02); @@ -138,16 +146,17 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_m /* write the DISEQC command bytes */ for(i=0; i< cmd->msg_len; i++) { - s5h1420_writereg(state, 0x3c + i, cmd->msg[i]); + s5h1420_writereg(state, 0x3d + i, cmd->msg[i]); } /* kick off transmission */ - s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | ((cmd->msg_len-1) << 4) | 0x08); + s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | + ((cmd->msg_len-1) << 4) | 0x08); /* wait for transmission to complete */ timeout = jiffies + ((100*HZ) / 1000); while(time_before(jiffies, timeout)) { - if (s5h1420_readreg(state, 0x3b) & 0x08) + if (!(s5h1420_readreg(state, 0x3b) & 0x08)) break; msleep(5); @@ -161,7 +170,8 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_m return result; } -static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply) +static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, + struct dvb_diseqc_slave_reply* reply) { struct s5h1420_state* state = fe->demodulator_priv; u8 val; @@ -205,7 +215,7 @@ static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, struct dvb_diseqc_ /* extract data */ for(i=0; i< length; i++) { - reply->msg[i] = s5h1420_readreg(state, 0x3c + i); + reply->msg[i] = s5h1420_readreg(state, 0x3d + i); } exit: @@ -236,7 +246,7 @@ static int s5h1420_send_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t minicm s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | 0x08); /* wait for transmission to complete */ - timeout = jiffies + ((20*HZ) / 1000); + timeout = jiffies + ((100*HZ) / 1000); while(time_before(jiffies, timeout)) { if (!(s5h1420_readreg(state, 0x3b) & 0x08)) break; @@ -259,9 +269,9 @@ static fe_status_t s5h1420_get_status_bits(struct s5h1420_state* state) val = s5h1420_readreg(state, 0x14); if (val & 0x02) - status |= FE_HAS_SIGNAL; // FIXME: not sure if this is right + status |= FE_HAS_SIGNAL; if (val & 0x01) - status |= FE_HAS_CARRIER; // FIXME: not sure if this is right + status |= FE_HAS_CARRIER; val = s5h1420_readreg(state, 0x36); if (val & 0x01) status |= FE_HAS_VITERBI; @@ -284,8 +294,8 @@ static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status) /* determine lock state */ *status = s5h1420_get_status_bits(state); - /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert the inversion, - wait a bit and check again */ + /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert + the inversion, wait a bit and check again */ if (*status == (FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI)) { val = s5h1420_readreg(state, 0x32); if ((val & 0x07) == 0x03) { @@ -330,6 +340,10 @@ static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status) tmp = (tmp * 2 * 7) / 8; break; } + if (tmp == 0) { + printk("s5h1420: avoided division by 0\n"); + tmp = 1; + } tmp = state->fclk / tmp; /* set the MPEG_CLK_INTL for the calculated data rate */ @@ -368,16 +382,21 @@ static int s5h1420_read_ber(struct dvb_frontend* fe, u32* ber) s5h1420_writereg(state, 0x46, 0x1d); mdelay(25); - return (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); + + *ber = (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); + + return 0; } static int s5h1420_read_signal_strength(struct dvb_frontend* fe, u16* strength) { struct s5h1420_state* state = fe->demodulator_priv; - u8 val = 0xff - s5h1420_readreg(state, 0x15); + u8 val = s5h1420_readreg(state, 0x15); - return (int) ((val << 8) | val); + *strength = (u16) ((val << 8) | val); + + return 0; } static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) @@ -386,7 +405,10 @@ static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) s5h1420_writereg(state, 0x46, 0x1f); mdelay(25); - return (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); + + *ucblocks = (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); + + return 0; } static void s5h1420_reset(struct s5h1420_state* state) @@ -396,11 +418,12 @@ static void s5h1420_reset(struct s5h1420_state* state) udelay(10); } -static void s5h1420_setsymbolrate(struct s5h1420_state* state, struct dvb_frontend_parameters *p) +static void s5h1420_setsymbolrate(struct s5h1420_state* state, + struct dvb_frontend_parameters *p) { u64 val; - val = (p->u.qpsk.symbol_rate / 1000) * (1<<24); + val = ((u64) p->u.qpsk.symbol_rate / 1000ULL) * (1ULL<<24); if (p->u.qpsk.symbol_rate <= 21000000) { val *= 2; } @@ -415,7 +438,7 @@ static void s5h1420_setsymbolrate(struct s5h1420_state* state, struct dvb_fronte static u32 s5h1420_getsymbolrate(struct s5h1420_state* state) { - u64 val; + u64 val = 0; int sampling = 2; if (s5h1420_readreg(state, 0x05) & 0x2) @@ -427,10 +450,10 @@ static u32 s5h1420_getsymbolrate(struct s5h1420_state* state) val |= s5h1420_readreg(state, 0x13); s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) & 0xf7); - val *= (state->fclk / 1000); + val *= (state->fclk / 1000ULL); do_div(val, ((1<<24) * sampling)); - return (u32) (val * 1000); + return (u32) (val * 1000ULL); } static void s5h1420_setfreqoffset(struct s5h1420_state* state, int freqoffset) @@ -463,46 +486,55 @@ static int s5h1420_getfreqoffset(struct s5h1420_state* state) /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so * divide fclk by 1000000 to get the correct value. */ - val = - ((val * (state->fclk/1000000)) / (1<<24)); + val = (((-val) * (state->fclk/1000000)) / (1<<24)); return val; } -static void s5h1420_setfec(struct s5h1420_state* state, struct dvb_frontend_parameters *p) +static void s5h1420_setfec_inversion(struct s5h1420_state* state, + struct dvb_frontend_parameters *p) { + u8 inversion = 0; + + if (p->inversion == INVERSION_OFF) { + inversion = state->config->invert ? 0x08 : 0; + } else if (p->inversion == INVERSION_ON) { + inversion = state->config->invert ? 0 : 0x08; + } + if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) { - s5h1420_writereg(state, 0x31, 0x00); s5h1420_writereg(state, 0x30, 0x3f); + s5h1420_writereg(state, 0x31, 0x00 | inversion); } else { switch(p->u.qpsk.fec_inner) { case FEC_1_2: - s5h1420_writereg(state, 0x31, 0x10); s5h1420_writereg(state, 0x30, 0x01); + s5h1420_writereg(state, 0x31, 0x10 | inversion); break; case FEC_2_3: - s5h1420_writereg(state, 0x31, 0x11); s5h1420_writereg(state, 0x30, 0x02); + s5h1420_writereg(state, 0x31, 0x11 | inversion); break; case FEC_3_4: - s5h1420_writereg(state, 0x31, 0x12); s5h1420_writereg(state, 0x30, 0x04); - break; + s5h1420_writereg(state, 0x31, 0x12 | inversion); + break; case FEC_5_6: - s5h1420_writereg(state, 0x31, 0x13); s5h1420_writereg(state, 0x30, 0x08); + s5h1420_writereg(state, 0x31, 0x13 | inversion); break; case FEC_6_7: - s5h1420_writereg(state, 0x31, 0x14); s5h1420_writereg(state, 0x30, 0x10); + s5h1420_writereg(state, 0x31, 0x14 | inversion); break; case FEC_7_8: - s5h1420_writereg(state, 0x31, 0x15); s5h1420_writereg(state, 0x30, 0x20); + s5h1420_writereg(state, 0x31, 0x15 | inversion); break; default: @@ -536,22 +568,6 @@ static fe_code_rate_t s5h1420_getfec(struct s5h1420_state* state) return FEC_NONE; } -static void s5h1420_setinversion(struct s5h1420_state* state, struct dvb_frontend_parameters *p) -{ - if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) { - s5h1420_writereg(state, 0x31, 0x00); - s5h1420_writereg(state, 0x30, 0x3f); - } else { - u8 tmp = s5h1420_readreg(state, 0x31) & 0xf7; - tmp |= 0x10; - - if (p->inversion == INVERSION_ON) - tmp |= 0x80; - - s5h1420_writereg(state, 0x31, tmp); - } -} - static fe_spectral_inversion_t s5h1420_getinversion(struct s5h1420_state* state) { if (s5h1420_readreg(state, 0x32) & 0x08) @@ -560,35 +576,35 @@ static fe_spectral_inversion_t s5h1420_getinversion(struct s5h1420_state* state) return INVERSION_OFF; } -static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) +static int s5h1420_set_frontend(struct dvb_frontend* fe, + struct dvb_frontend_parameters *p) { struct s5h1420_state* state = fe->demodulator_priv; - u32 frequency_delta; + int frequency_delta; struct dvb_frontend_tune_settings fesettings; + u32 tmp; /* check if we should do a fast-tune */ memcpy(&fesettings.parameters, p, sizeof(struct dvb_frontend_parameters)); s5h1420_get_tune_settings(fe, &fesettings); frequency_delta = p->frequency - state->tunedfreq; - if ((frequency_delta > -fesettings.max_drift) && (frequency_delta < fesettings.max_drift) && + if ((frequency_delta > -fesettings.max_drift) && + (frequency_delta < fesettings.max_drift) && (frequency_delta != 0) && (state->fec_inner == p->u.qpsk.fec_inner) && (state->symbol_rate == p->u.qpsk.symbol_rate)) { - s5h1420_setfreqoffset(state, frequency_delta); + if (state->config->pll_set) { + s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); + state->config->pll_set(fe, p, &tmp); + s5h1420_setfreqoffset(state, p->frequency - tmp); + } return 0; } /* first of all, software reset */ s5h1420_reset(state); - /* set tuner PLL */ - if (state->config->pll_set) { - s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); - state->config->pll_set(fe, p, &state->tunedfreq); - s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) & 0xfe); - } - /* set s5h1420 fclk PLL according to desired symbol rate */ if (p->u.qpsk.symbol_rate > 28000000) { state->fclk = 88000000; @@ -609,8 +625,9 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par /* set misc registers */ s5h1420_writereg(state, 0x02, 0x00); + s5h1420_writereg(state, 0x06, 0x00); s5h1420_writereg(state, 0x07, 0xb0); - s5h1420_writereg(state, 0x0a, 0x67); + s5h1420_writereg(state, 0x0a, 0xe7); s5h1420_writereg(state, 0x0b, 0x78); s5h1420_writereg(state, 0x0c, 0x48); s5h1420_writereg(state, 0x0d, 0x6b); @@ -626,21 +643,26 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par /* start QPSK */ s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1); - /* set the frequency offset to adjust for PLL inaccuracy */ - s5h1420_setfreqoffset(state, p->frequency - state->tunedfreq); + /* set tuner PLL */ + if (state->config->pll_set) { + s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); + state->config->pll_set(fe, p, &tmp); + s5h1420_setfreqoffset(state, 0); + } /* set the reset of the parameters */ s5h1420_setsymbolrate(state, p); - s5h1420_setinversion(state, p); - s5h1420_setfec(state, p); + s5h1420_setfec_inversion(state, p); state->fec_inner = p->u.qpsk.fec_inner; state->symbol_rate = p->u.qpsk.symbol_rate; state->postlocked = 0; + state->tunedfreq = p->frequency; return 0; } -static int s5h1420_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) +static int s5h1420_get_frontend(struct dvb_frontend* fe, + struct dvb_frontend_parameters *p) { struct s5h1420_state* state = fe->demodulator_priv; @@ -652,7 +674,8 @@ static int s5h1420_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par return 0; } -static int s5h1420_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) +static int s5h1420_get_tune_settings(struct dvb_frontend* fe, + struct dvb_frontend_tune_settings* fesettings) { if (fesettings->parameters.u.qpsk.symbol_rate > 20000000) { fesettings->min_delay_ms = 50; @@ -717,7 +740,8 @@ static void s5h1420_release(struct dvb_frontend* fe) static struct dvb_frontend_ops s5h1420_ops; -struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, struct i2c_adapter* i2c) +struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, + struct i2c_adapter* i2c) { struct s5h1420_state* state = NULL; u8 identity; diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h index b687fc7..872028d 100644 --- a/drivers/media/dvb/frontends/s5h1420.h +++ b/drivers/media/dvb/frontends/s5h1420.h @@ -30,6 +30,9 @@ struct s5h1420_config /* the demodulator's i2c address */ u8 demod_address; + /* does the inversion require inversion? */ + u8 invert:1; + /* PLL maintenance */ int (*pll_init)(struct dvb_frontend* fe); int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u32* freqout); diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c index 5552ef5..43d6c82 100644 --- a/drivers/media/dvb/ttpci/budget.c +++ b/drivers/media/dvb/ttpci/budget.c @@ -480,6 +480,7 @@ static int s5h1420_pll_set(struct dvb_frontend* fe, struct dvb_frontend_paramete static struct s5h1420_config s5h1420_config = { .demod_address = 0x53, + .invert = 1, .pll_set = s5h1420_pll_set, }; -- cgit v0.10.2 From 78639a3f81d14117d1841476771d7a4736e7b9d1 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 9 Sep 2005 13:02:32 -0700 Subject: [PATCH] dvb: frontend: stv0299: support reading both BER and UCBLOCKS Allow the stv0299 to read the BER and UCBLOCKS. Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c index db66d41..2d62931 100644 --- a/drivers/media/dvb/frontends/stv0299.c +++ b/drivers/media/dvb/frontends/stv0299.c @@ -63,12 +63,8 @@ struct stv0299_state { u32 tuner_frequency; u32 symbol_rate; fe_code_rate_t fec_inner; - int errmode; }; -#define STATUS_BER 0 -#define STATUS_UCBLOCKS 1 - static int debug; static int debug_legacy_dish_switch; #define dprintk(args...) \ @@ -520,7 +516,8 @@ static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber) { struct stv0299_state* state = fe->demodulator_priv; - if (state->errmode != STATUS_BER) return 0; + stv0299_writeregI(state, 0x34, (stv0299_readreg(state, 0x34) & 0xcf) | 0x10); + msleep(100); *ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); return 0; @@ -559,8 +556,9 @@ static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) { struct stv0299_state* state = fe->demodulator_priv; - if (state->errmode != STATUS_UCBLOCKS) *ucblocks = 0; - else *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); + stv0299_writeregI(state, 0x34, (stv0299_readreg(state, 0x34) & 0xcf) | 0x30); + msleep(100); + *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); return 0; } @@ -709,7 +707,6 @@ struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, state->tuner_frequency = 0; state->symbol_rate = 0; state->fec_inner = 0; - state->errmode = STATUS_BER; /* check if the demod is there */ stv0299_writeregI(state, 0x02, 0x34); /* standby off */ -- cgit v0.10.2 From c2026b3af0c8ad33ef253a950c271f2d0da111b6 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 9 Sep 2005 13:02:33 -0700 Subject: [PATCH] dvb: frontend: tda1004x: fix SNR reading Fix SNR reading Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c index ab0c032..74cea9f 100644 --- a/drivers/media/dvb/frontends/tda1004x.c +++ b/drivers/media/dvb/frontends/tda1004x.c @@ -1046,8 +1046,7 @@ static int tda1004x_read_snr(struct dvb_frontend* fe, u16 * snr) tmp = tda1004x_read_byte(state, TDA1004X_SNR); if (tmp < 0) return -EIO; - if (tmp) - tmp = 255 - tmp; + tmp = 255 - tmp; *snr = ((tmp << 8) | tmp); dprintk("%s: snr=0x%x\n", __FUNCTION__, *snr); -- cgit v0.10.2 From 6816a4c183e62bca1fa4812214e483ab503dcb7d Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:34 -0700 Subject: [PATCH] dvb: frontend: ves1820: improve tuning Reset acgconf register after tuning to improve locking, as suggested by Marco Schluessler. Minor cleanups in ves1820_init(). Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c index 70fb44b..c6d2766 100644 --- a/drivers/media/dvb/frontends/ves1820.c +++ b/drivers/media/dvb/frontends/ves1820.c @@ -194,19 +194,18 @@ static int ves1820_init(struct dvb_frontend* fe) { struct ves1820_state* state = fe->demodulator_priv; int i; - int val; ves1820_writereg(state, 0, 0); - for (i = 0; i < 53; i++) { - val = ves1820_inittab[i]; - if ((i == 2) && (state->config->selagc)) val |= 0x08; - ves1820_writereg(state, i, val); - } + for (i = 0; i < sizeof(ves1820_inittab); i++) + ves1820_writereg(state, i, ves1820_inittab[i]); + if (state->config->selagc) + ves1820_writereg(state, 2, ves1820_inittab[2] | 0x08); ves1820_writereg(state, 0x34, state->pwm); - if (state->config->pll_init) state->config->pll_init(fe); + if (state->config->pll_init) + state->config->pll_init(fe); return 0; } @@ -234,7 +233,7 @@ static int ves1820_set_parameters(struct dvb_frontend* fe, struct dvb_frontend_p ves1820_writereg(state, 0x09, reg0x09[real_qam]); ves1820_setup_reg0(state, reg0x00[real_qam], p->inversion); - + ves1820_writereg(state, 2, ves1820_inittab[2] | (state->config->selagc ? 0x08 : 0)); return 0; } -- cgit v0.10.2 From d897275500d8fac919a11073eb587ce0e3fcc36c Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:34 -0700 Subject: [PATCH] dvb: frontend: cx24110: DiSEqC fix Fix DiSEqC switching (one bug fix suggested by Peter Hettkamp, and one experimentally determined msleep(30) suggested by Adam Szalkowski). Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index 555d472..71b5409 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c @@ -398,7 +398,7 @@ static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t return -EINVAL; rv = cx24110_readreg(state, 0x77); - cx24110_writereg(state, 0x77, rv|0x04); + cx24110_writereg(state, 0x77, rv | 0x04); rv = cx24110_readreg(state, 0x76); cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit)); @@ -418,7 +418,8 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe, cx24110_writereg(state, 0x79 + i, cmd->msg[i]); rv = cx24110_readreg(state, 0x77); - cx24110_writereg(state, 0x77, rv|0x04); + cx24110_writereg(state, 0x77, rv & ~0x04); + msleep(30); /* reportedly fixes switching problems */ rv = cx24110_readreg(state, 0x76); -- cgit v0.10.2 From 296c786a0d2122b1e47c80ca717d8a8ac36402c1 Mon Sep 17 00:00:00 2001 From: Adam Szalkowski Date: Fri, 9 Sep 2005 13:02:35 -0700 Subject: [PATCH] dvb: frontend: cx24110: another DiSEqC fix Fix DiSEqC problems. Signed-off-by: Adam Szalkowski Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index 71b5409..eb4833e 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c @@ -398,7 +398,8 @@ static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t return -EINVAL; rv = cx24110_readreg(state, 0x77); - cx24110_writereg(state, 0x77, rv | 0x04); + if (!(rv & 0x04)) + cx24110_writereg(state, 0x77, rv | 0x04); rv = cx24110_readreg(state, 0x76); cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit)); @@ -418,14 +419,16 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe, cx24110_writereg(state, 0x79 + i, cmd->msg[i]); rv = cx24110_readreg(state, 0x77); - cx24110_writereg(state, 0x77, rv & ~0x04); - msleep(30); /* reportedly fixes switching problems */ + if (rv & 0x04) { + cx24110_writereg(state, 0x77, rv & ~0x04); + msleep(30); /* reportedly fixes switching problems */ + } rv = cx24110_readreg(state, 0x76); cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); - for (i=500; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40);) - ; /* wait for LNB ready */ + for (i=100; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40);) + msleep(1); /* wait for LNB ready */ return 0; } -- cgit v0.10.2 From c589ebfce79834a9617c44d7ec0f608fa70eb42d Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:37 -0700 Subject: [PATCH] dvb: frontend: cx24110: clean up timeout handling. Clean up timeout handling. Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index eb4833e..d4b9798 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c @@ -387,8 +387,9 @@ static int cx24110_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) { - int rv, bit, i; + int rv, bit; struct cx24110_state *state = fe->demodulator_priv; + unsigned long timeout; if (burst == SEC_MINI_A) bit = 0x00; @@ -403,8 +404,9 @@ static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t rv = cx24110_readreg(state, 0x76); cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit)); - for (i = 500; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40) ; ) - ; /* wait for LNB ready */ + timeout = jiffies + msecs_to_jiffies(100); + while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40)) + ; /* wait for LNB ready */ return 0; } @@ -414,6 +416,7 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe, { int i, rv; struct cx24110_state *state = fe->demodulator_priv; + unsigned long timeout; for (i = 0; i < cmd->msg_len; i++) cx24110_writereg(state, 0x79 + i, cmd->msg[i]); @@ -427,8 +430,9 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe, rv = cx24110_readreg(state, 0x76); cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); - for (i=100; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40);) - msleep(1); /* wait for LNB ready */ + timeout = jiffies + msecs_to_jiffies(100); + while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40)) + ; /* wait for LNB ready */ return 0; } -- cgit v0.10.2 From 593cbf3dcbffc852cf91a30951eb518b59bf7322 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:38 -0700 Subject: [PATCH] dvb: frontend: stv0297: QAM128 tuning improvement while investigating the QAM_128-issue with the stv0297-driver for the Cablestar (which is not the same as the one in dvb-kernel CVS, yet), I fixed it, not by increasing the timeout, but by disabling the corner-detection for QAM_128 and higher. This patch has been tested on dvb-kernel cvs, and has been reported to work by multiple users. Some cards still need timeout increase on top of this patch. This will be addressed later. Signed-off-by: Patrick Boettcher Signed-off-by: Michael Krufky Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c index 928aca0..01eb419 100644 --- a/drivers/media/dvb/frontends/stv0297.c +++ b/drivers/media/dvb/frontends/stv0297.c @@ -606,7 +606,13 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par stv0297_set_inversion(state, inversion); /* kick off lock */ - stv0297_writereg_mask(state, 0x88, 0x08, 0x08); + /* Disable corner detection for higher QAMs */ + if (p->u.qam.modulation == QAM_128 || + p->u.qam.modulation == QAM_256) + stv0297_writereg_mask(state, 0x88, 0x08, 0x00); + else + stv0297_writereg_mask(state, 0x88, 0x08, 0x08); + stv0297_writereg_mask(state, 0x5a, 0x20, 0x00); stv0297_writereg_mask(state, 0x6a, 0x01, 0x01); stv0297_writereg_mask(state, 0x43, 0x40, 0x40); -- cgit v0.10.2 From 80e27e20619902b11aa255081fd83eab10fc0839 Mon Sep 17 00:00:00 2001 From: Mac Michaels Date: Fri, 9 Sep 2005 13:02:40 -0700 Subject: [PATCH] dvb: frontend: or51132: remove bogus optimization attempt This fix has also been applied to lgdt330x. There is an optimization that keeps track of the frequency tuned by the digital decoder. The digital driver does not set the frequency if it has not changed since it was tuned. The analog tuner driver knows nothing about the frequency saved by the digital driver. When the frequency is set using the video4linux code with tvtime, the hardware get changed but the digital driver's state does not get updated. Switch back to the same digital channel and the driver finds no change in frequency so the tuner is not reset to the digital frequency. The work around is to remove the check and always set the tuner to the specified frequency. Signed-off-by: Mac Michaels Signed-off-by: Michael Krufky Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c index cc0a77c..b6d0eec 100644 --- a/drivers/media/dvb/frontends/or51132.c +++ b/drivers/media/dvb/frontends/or51132.c @@ -370,22 +370,19 @@ static int or51132_set_parameters(struct dvb_frontend* fe, or51132_setmode(fe); } - /* Change only if we are actually changing the channel */ - if (state->current_frequency != param->frequency) { - dvb_pll_configure(state->config->pll_desc, buf, - param->frequency, 0); - dprintk("set_parameters tuner bytes: 0x%02x 0x%02x " - "0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]); - if (i2c_writebytes(state, state->config->pll_address ,buf, 4)) - printk(KERN_WARNING "or51132: set_parameters error " - "writing to tuner\n"); - - /* Set to current mode */ - or51132_setmode(fe); - - /* Update current frequency */ - state->current_frequency = param->frequency; - } + dvb_pll_configure(state->config->pll_desc, buf, + param->frequency, 0); + dprintk("set_parameters tuner bytes: 0x%02x 0x%02x " + "0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]); + if (i2c_writebytes(state, state->config->pll_address ,buf, 4)) + printk(KERN_WARNING "or51132: set_parameters error " + "writing to tuner\n"); + + /* Set to current mode */ + or51132_setmode(fe); + + /* Update current frequency */ + state->current_frequency = param->frequency; return 0; } -- cgit v0.10.2 From 3706a4da2012679631da6d22e86c6a34cde7419a Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:41 -0700 Subject: [PATCH] dvb: usb: add TwinhanDTV StarBox support Add driver for the TwinhanDTV StarBox and clones. Thanks to Ralph Metzler for his initial work on this box and thanks to Twinhan for their support. Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index 612e5b0..54e2b29 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig @@ -93,13 +93,30 @@ config DVB_USB_DIGITV Say Y here to support the Nebula Electronics uDigitV USB2.0 DVB-T receiver. config DVB_USB_VP7045 - tristate "TwinhanDTV Alpha/MagicBoxII and DNTV tinyUSB2 DVB-T USB2.0 support" + tristate "TwinhanDTV Alpha/MagicBoxII, DNTV tinyUSB2, Beetle USB2.0 support" depends on DVB_USB help Say Y here to support the + TwinhanDTV Alpha (stick) (VP-7045), - TwinhanDTV MagicBox II (VP-7046) and - DigitalNow TinyUSB 2 DVB-t DVB-T USB2.0 receivers. + TwinhanDTV MagicBox II (VP-7046), + DigitalNow TinyUSB 2 DVB-t, + DigitalRise USB 2.0 Ter (Beetle) and + TYPHOON DVB-T USB DRIVE + + DVB-T USB2.0 receivers. + +config DVB_USB_VP702X + tristate "TwinhanDTV StarBox and clones DVB-S USB2.0 support" + depends on DVB_USB + help + Say Y here to support the + + TwinhanDTV StarBox, + DigitalRise USB Starbox and + TYPHOON DVB-S USB 2.0 BOX + + DVB-S USB2.0 receivers. config DVB_USB_NOVA_T_USB2 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile index 746d87e..2dc9aad 100644 --- a/drivers/media/dvb/dvb-usb/Makefile +++ b/drivers/media/dvb/dvb-usb/Makefile @@ -4,6 +4,9 @@ obj-$(CONFIG_DVB_USB) += dvb-usb.o dvb-usb-vp7045-objs = vp7045.o vp7045-fe.o obj-$(CONFIG_DVB_USB_VP7045) += dvb-usb-vp7045.o +dvb-usb-vp702x-objs = vp702x.o vp702x-fe.o +obj-$(CONFIG_DVB_USB_VP702X) += dvb-usb-vp702x.o + dvb-usb-dtt200u-objs = dtt200u.o dtt200u-fe.o obj-$(CONFIG_DVB_USB_DTT200U) += dvb-usb-dtt200u.o diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 794d513..2b249c7 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -52,12 +52,14 @@ #define USB_PID_KWORLD_VSTREAM_WARM 0x17df #define USB_PID_TWINHAN_VP7041_COLD 0x3201 #define USB_PID_TWINHAN_VP7041_WARM 0x3202 +#define USB_PID_TWINHAN_VP7020_COLD 0x3203 +#define USB_PID_TWINHAN_VP7020_WARM 0x3204 #define USB_PID_TWINHAN_VP7045_COLD 0x3205 #define USB_PID_TWINHAN_VP7045_WARM 0x3206 -#define USB_PID_DNTV_TINYUSB2_COLD 0x3223 -#define USB_PID_DNTV_TINYUSB2_WARM 0x3224 #define USB_PID_TWINHAN_VP7021_COLD 0x3207 #define USB_PID_TWINHAN_VP7021_WARM 0x3208 +#define USB_PID_DNTV_TINYUSB2_COLD 0x3223 +#define USB_PID_DNTV_TINYUSB2_WARM 0x3224 #define USB_PID_ULTIMA_TVBOX_COLD 0x8105 #define USB_PID_ULTIMA_TVBOX_WARM 0x8106 #define USB_PID_ULTIMA_TVBOX_AN2235_COLD 0x8107 diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c new file mode 100644 index 0000000..f20d8db --- /dev/null +++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c @@ -0,0 +1,339 @@ +/* DVB frontend part of the Linux driver for the TwinhanDTV StarBox USB2.0 + * DVB-S receiver. + * + * Copyright (C) 2005 Ralph Metzler + * Metzler Brothers Systementwicklung GbR + * + * Copyright (C) 2005 Patrick Boettcher + * + * Thanks to Twinhan who kindly provided hardware and information. + * + * This file can be removed soon, after the DST-driver is rewritten to provice + * the frontend-controlling separately. + * + * 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, version 2. + * + * see Documentation/dvb/README.dvb-usb for more information + * + */ +#include "vp702x.h" + +struct vp702x_fe_state { + struct dvb_frontend fe; + struct dvb_usb_device *d; + + fe_sec_voltage_t voltage; + fe_sec_tone_mode_t tone_mode; + + u8 lnb_buf[8]; + + u8 lock; + u8 sig; + u8 snr; + + unsigned long next_status_check; + unsigned long status_check_interval; +}; + +static int vp702x_fe_refresh_state(struct vp702x_fe_state *st) +{ + u8 buf[10]; + if (time_after(jiffies,st->next_status_check)) { + vp702x_usb_in_op(st->d,READ_STATUS,0,0,buf,10); + + st->lock = buf[4]; + vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x11,0,&st->snr,1); + vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x15,0,&st->sig,1); + + st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000; + } + return 0; +} + +static u8 vp702x_chksum(u8 *buf,int f, int count) +{ + u8 s = 0; + int i; + for (i = f; i < f+count; i++) + s += buf[i]; + return ~s+1; +} + +static int vp702x_fe_read_status(struct dvb_frontend* fe, fe_status_t *status) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + deb_fe("%s\n",__FUNCTION__); + + if (st->lock == 0) + *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER; + else + *status = 0; + + deb_fe("real state: %x\n",*status); + *status = 0x1f; + + if (*status & FE_HAS_LOCK) + st->status_check_interval = 1000; + else + st->status_check_interval = 250; + return 0; +} + +/* not supported by this Frontend */ +static int vp702x_fe_read_ber(struct dvb_frontend* fe, u32 *ber) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + *ber = 0; + return 0; +} + +/* not supported by this Frontend */ +static int vp702x_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + *unc = 0; + return 0; +} + +static int vp702x_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + + *strength = (st->sig << 8) | st->sig; + return 0; +} + +static int vp702x_fe_read_snr(struct dvb_frontend* fe, u16 *snr) +{ + u8 _snr; + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + + _snr = (st->snr & 0x1f) * 0xff / 0x1f; + *snr = (_snr << 8) | _snr; + return 0; +} + +static int vp702x_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) +{ + deb_fe("%s\n",__FUNCTION__); + tune->min_delay_ms = 2000; + return 0; +} + +static int vp702x_fe_set_frontend(struct dvb_frontend* fe, + struct dvb_frontend_parameters *fep) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + u32 freq = fep->frequency/1000; + /*CalFrequency*/ +/* u16 frequencyRef[16] = { 2, 4, 8, 16, 32, 64, 128, 256, 24, 5, 10, 20, 40, 80, 160, 320 }; */ + u64 sr; + u8 cmd[8] = { 0 },ibuf[10]; + + cmd[0] = (freq >> 8) & 0x7f; + cmd[1] = freq & 0xff; + cmd[2] = 1; /* divrate == 4 -> frequencyRef[1] -> 1 here */ + + sr = (u64) (fep->u.qpsk.symbol_rate/1000) << 20; + do_div(sr,88000); + cmd[3] = (sr >> 12) & 0xff; + cmd[4] = (sr >> 4) & 0xff; + cmd[5] = (sr << 4) & 0xf0; + + deb_fe("setting frontend to: %u -> %u (%x) LNB-based GHz, symbolrate: %d -> %Lu (%Lx)\n", + fep->frequency,freq,freq, fep->u.qpsk.symbol_rate, sr, sr); + +/* if (fep->inversion == INVERSION_ON) + cmd[6] |= 0x80; */ + + if (st->voltage == SEC_VOLTAGE_18) + cmd[6] |= 0x40; + +/* if (fep->u.qpsk.symbol_rate > 8000000) + cmd[6] |= 0x20; + + if (fep->frequency < 1531000) + cmd[6] |= 0x04; + + if (st->tone_mode == SEC_TONE_ON) + cmd[6] |= 0x01;*/ + + cmd[7] = vp702x_chksum(cmd,0,7); + + st->status_check_interval = 250; + st->next_status_check = jiffies; + + vp702x_usb_in_op(st->d, RESET_TUNER, 0, 0, NULL, 0); + msleep(30); + vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); + + if (ibuf[2] == 0 && ibuf[3] == 0) + deb_fe("tuning failed.\n"); + else + deb_fe("tuning succeeded.\n"); + + return 0; +} + +static int vp702x_fe_get_frontend(struct dvb_frontend* fe, + struct dvb_frontend_parameters *fep) +{ + deb_fe("%s\n",__FUNCTION__); + return 0; +} + +static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, + struct dvb_diseqc_master_cmd *m) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + u8 cmd[8],ibuf[10]; + memset(cmd,0,8); + + deb_fe("%s\n",__FUNCTION__); + + if (m->msg_len > 4) + return -EINVAL; + + cmd[1] = SET_DISEQC_CMD; + cmd[2] = m->msg_len; + memcpy(&cmd[3], m->msg, m->msg_len); + cmd[7] = vp702x_chksum(cmd,0,7); + + vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); + + if (ibuf[2] == 0 && ibuf[3] == 0) + deb_fe("diseqc cmd failed.\n"); + else + deb_fe("diseqc cmd succeeded.\n"); + + return 0; +} + +static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) +{ + deb_fe("%s\n",__FUNCTION__); + return 0; +} + +static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + u8 ibuf[10]; + deb_fe("%s\n",__FUNCTION__); + + st->tone_mode = tone; + + if (tone == SEC_TONE_ON) + st->lnb_buf[2] = 0x02; + else + st->lnb_buf[2] = 0x00; + + st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7); + + vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100); + if (ibuf[2] == 0 && ibuf[3] == 0) + deb_fe("set_tone cmd failed.\n"); + else + deb_fe("set_tone cmd succeeded.\n"); + + return 0; +} + +static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t + voltage) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + u8 ibuf[10]; + deb_fe("%s\n",__FUNCTION__); + + st->voltage = voltage; + + if (voltage != SEC_VOLTAGE_OFF) + st->lnb_buf[4] = 0x01; + else + st->lnb_buf[4] = 0x00; + + st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7); + + vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100); + if (ibuf[2] == 0 && ibuf[3] == 0) + deb_fe("set_voltage cmd failed.\n"); + else + deb_fe("set_voltage cmd succeeded.\n"); + + return 0; +} + +static void vp702x_fe_release(struct dvb_frontend* fe) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + kfree(st); +} + +static struct dvb_frontend_ops vp702x_fe_ops; + +struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d) +{ + struct vp702x_fe_state *s = kmalloc(sizeof(struct vp702x_fe_state), GFP_KERNEL); + if (s == NULL) + goto error; + memset(s,0,sizeof(struct vp702x_fe_state)); + + s->d = d; + s->fe.ops = &vp702x_fe_ops; + s->fe.demodulator_priv = s; + + s->lnb_buf[1] = SET_LNB_POWER; + s->lnb_buf[3] = 0xff; /* 0=tone burst, 2=data burst, ff=off */ + + goto success; +error: + return NULL; +success: + return &s->fe; +} + + +static struct dvb_frontend_ops vp702x_fe_ops = { + .info = { + .name = "Twinhan DST-like frontend (VP7021/VP7020) DVB-S", + .type = FE_QPSK, + .frequency_min = 950000, + .frequency_max = 2150000, + .frequency_stepsize = 1000, /* kHz for QPSK frontends */ + .frequency_tolerance = 0, + .symbol_rate_min = 1000000, + .symbol_rate_max = 45000000, + .symbol_rate_tolerance = 500, /* ppm */ + .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | + FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | + FE_CAN_QPSK | + FE_CAN_FEC_AUTO + }, + .release = vp702x_fe_release, + + .init = NULL, + .sleep = NULL, + + .set_frontend = vp702x_fe_set_frontend, + .get_frontend = vp702x_fe_get_frontend, + .get_tune_settings = vp702x_fe_get_tune_settings, + + .read_status = vp702x_fe_read_status, + .read_ber = vp702x_fe_read_ber, + .read_signal_strength = vp702x_fe_read_signal_strength, + .read_snr = vp702x_fe_read_snr, + .read_ucblocks = vp702x_fe_read_unc_blocks, + + .diseqc_send_master_cmd = vp702x_fe_send_diseqc_msg, + .diseqc_send_burst = vp702x_fe_send_diseqc_burst, + .set_tone = vp702x_fe_set_tone, + .set_voltage = vp702x_fe_set_voltage, +}; diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c new file mode 100644 index 0000000..1f5034c --- /dev/null +++ b/drivers/media/dvb/dvb-usb/vp702x.c @@ -0,0 +1,290 @@ +/* DVB USB compliant Linux driver for the TwinhanDTV StarBox USB2.0 DVB-S + * receiver. + * + * Copyright (C) 2005 Ralph Metzler + * Metzler Brothers Systementwicklung GbR + * + * Copyright (C) 2005 Patrick Boettcher + * + * Thanks to Twinhan who kindly provided hardware and information. + * + * 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, version 2. + * + * see Documentation/dvb/README.dvb-usb for more information + */ +#include "vp702x.h" + +/* debug */ +int dvb_usb_vp702x_debug; +module_param_named(debug,dvb_usb_vp702x_debug, int, 0644); +MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); + +struct vp702x_state { + u8 pid_table[17]; /* [16] controls the pid_table state */ +}; + +/* check for mutex FIXME */ +int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) +{ + int ret = 0,try = 0; + + while (ret >= 0 && ret != blen && try < 3) { + ret = usb_control_msg(d->udev, + usb_rcvctrlpipe(d->udev,0), + req, + USB_TYPE_VENDOR | USB_DIR_IN, + value,index,b,blen, + 2000); + deb_info("reading number %d (ret: %d)\n",try,ret); + try++; + } + + if (ret < 0 || ret != blen) { + warn("usb in operation failed."); + ret = -EIO; + } else + ret = 0; + + deb_xfer("in: req. %x, val: %x, ind: %x, buffer: ",req,value,index); + debug_dump(b,blen,deb_xfer); + + return ret; +} + +int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) +{ + deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index); + debug_dump(b,blen,deb_xfer); + + if (usb_control_msg(d->udev, + usb_sndctrlpipe(d->udev,0), + req, + USB_TYPE_VENDOR | USB_DIR_OUT, + value,index,b,blen, + 2000) != blen) { + warn("usb out operation failed."); + return -EIO; + } else + return 0; +} + +int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec) +{ + int ret; + + if ((ret = down_interruptible(&d->usb_sem))) + return ret; + + if ((ret = vp702x_usb_out_op(d,REQUEST_OUT,0,0,o,olen)) < 0) + goto unlock; + msleep(msec); + ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen); + +unlock: + up(&d->usb_sem); + + return ret; +} + +int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, int olen, u8 *i, int ilen, int msec) +{ + u8 bout[olen+2]; + u8 bin[ilen+1]; + int ret = 0; + + bout[0] = 0x00; + bout[1] = cmd; + memcpy(&bout[2],o,olen); + + ret = vp702x_usb_inout_op(d, bout, olen+2, bin, ilen+1,msec); + + if (ret == 0) + memcpy(i,&bin[1],ilen); + + return ret; +} + +static int vp702x_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) +{ + struct vp702x_state *st = d->priv; + u8 buf[9]; + + if (onoff) { + st->pid_table[16] |= 1 << index; + st->pid_table[index*2] = (pid >> 8) & 0xff; + st->pid_table[index*2+1] = pid & 0xff; + } else { + st->pid_table[16] &= ~(1 << index); + st->pid_table[index*2] = st->pid_table[index*2+1] = 0; + } + + return vp702x_usb_inout_cmd(d,SET_PID_FILTER,st->pid_table,17,buf,9,10); +} + +static int vp702x_power_ctrl(struct dvb_usb_device *d, int onoff) +{ + vp702x_usb_in_op(d,RESET_TUNER,0,0,NULL,0); + + vp702x_usb_in_op(d,SET_TUNER_POWER_REQ,0,onoff,NULL,0); + return vp702x_usb_in_op(d,SET_TUNER_POWER_REQ,0,onoff,NULL,0); +} + +/* keys for the enclosed remote control */ +static struct dvb_usb_rc_key vp702x_rc_keys[] = { + { 0x00, 0x01, KEY_1 }, + { 0x00, 0x02, KEY_2 }, +}; + +/* remote control stuff (does not work with my box) */ +static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) +{ + u8 key[10]; + int i; + +/* remove the following return to enabled remote querying */ + return 0; + + vp702x_usb_in_op(d,READ_REMOTE_REQ,0,0,key,10); + + deb_rc("remote query key: %x %d\n",key[1],key[1]); + + if (key[1] == 0x44) { + *state = REMOTE_NO_KEY_PRESSED; + return 0; + } + + for (i = 0; i < ARRAY_SIZE(vp702x_rc_keys); i++) + if (vp702x_rc_keys[i].custom == key[1]) { + *state = REMOTE_KEY_PRESSED; + *event = vp702x_rc_keys[i].event; + break; + } + return 0; +} + +static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) +{ + u8 macb[9]; + if (vp702x_usb_inout_cmd(d, GET_MAC_ADDRESS, NULL, 0, macb, 9, 10)) + return -EIO; + memcpy(mac,&macb[3],6); + return 0; +} + +static int vp702x_frontend_attach(struct dvb_usb_device *d) +{ + u8 buf[9] = { 0 }; + + if (vp702x_usb_inout_cmd(d, GET_SYSTEM_STRING, NULL, 0, buf, 9, 10)) + return -EIO; + + buf[8] = '\0'; + info("system string: %s",&buf[1]); + + d->fe = vp702x_fe_attach(d); + return 0; +} + +static struct dvb_usb_properties vp702x_properties; + +static int vp702x_usb_probe(struct usb_interface *intf, + const struct usb_device_id *id) +{ + struct usb_device *udev = interface_to_usbdev(intf); + + usb_clear_halt(udev,usb_sndctrlpipe(udev,0)); + usb_clear_halt(udev,usb_rcvctrlpipe(udev,0)); + + return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE); +} + +static struct usb_device_id vp702x_usb_table [] = { + { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_COLD) }, + { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_WARM) }, + { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_COLD) }, + { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_WARM) }, + { 0 }, +}; +MODULE_DEVICE_TABLE(usb, vp702x_usb_table); + +static struct dvb_usb_properties vp702x_properties = { + .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING, + .pid_filter_count = 8, /* !!! */ + + .usb_ctrl = CYPRESS_FX2, + .firmware = "dvb-usb-vp702x-01.fw", + + .pid_filter = vp702x_pid_filter, + .power_ctrl = vp702x_power_ctrl, + .frontend_attach = vp702x_frontend_attach, + .read_mac_address = vp702x_read_mac_addr, + + .rc_key_map = vp702x_rc_keys, + .rc_key_map_size = ARRAY_SIZE(vp702x_rc_keys), + .rc_interval = 400, + .rc_query = vp702x_rc_query, + + .size_of_priv = sizeof(struct vp702x_state), + + /* parameter for the MPEG2-data transfer */ + .urb = { + .type = DVB_USB_BULK, + .count = 7, + .endpoint = 0x02, + .u = { + .bulk = { + .buffersize = 4096, + } + } + }, + + .num_device_descs = 2, + .devices = { + { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7021)", + .cold_ids = { &vp702x_usb_table[0], NULL }, + .warm_ids = { &vp702x_usb_table[1], NULL }, + }, + { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7020)", + .cold_ids = { &vp702x_usb_table[2], NULL }, + .warm_ids = { &vp702x_usb_table[3], NULL }, + }, + { 0 }, + } +}; + +/* usb specific object needed to register this driver with the usb subsystem */ +static struct usb_driver vp702x_usb_driver = { + .owner = THIS_MODULE, + .name = "dvb-usb-vp702x", + .probe = vp702x_usb_probe, + .disconnect = dvb_usb_device_exit, + .id_table = vp702x_usb_table, +}; + +/* module stuff */ +static int __init vp702x_usb_module_init(void) +{ + int result; + if ((result = usb_register(&vp702x_usb_driver))) { + err("usb_register failed. (%d)",result); + return result; + } + + return 0; +} + +static void __exit vp702x_usb_module_exit(void) +{ + /* deregister this driver from the USB subsystem */ + usb_deregister(&vp702x_usb_driver); +} + +module_init(vp702x_usb_module_init); +module_exit(vp702x_usb_module_exit); + +MODULE_AUTHOR("Patrick Boettcher "); +MODULE_DESCRIPTION("Driver for Twinhan StarBox DVB-S USB2.0 and clones"); +MODULE_VERSION("1.0-alpha"); +MODULE_LICENSE("GPL"); diff --git a/drivers/media/dvb/dvb-usb/vp702x.h b/drivers/media/dvb/dvb-usb/vp702x.h new file mode 100644 index 0000000..4a3e8c7 --- /dev/null +++ b/drivers/media/dvb/dvb-usb/vp702x.h @@ -0,0 +1,109 @@ +#ifndef _DVB_USB_VP7021_H_ +#define _DVB_USB_VP7021_H_ + +#define DVB_USB_LOG_PREFIX "vp702x" +#include "dvb-usb.h" + +extern int dvb_usb_vp702x_debug; +#define deb_info(args...) dprintk(dvb_usb_vp702x_debug,0x01,args) +#define deb_xfer(args...) dprintk(dvb_usb_vp702x_debug,0x02,args) +#define deb_rc(args...) dprintk(dvb_usb_vp702x_debug,0x04,args) +#define deb_fe(args...) dprintk(dvb_usb_vp702x_debug,0x08,args) + +/* commands are read and written with USB control messages */ + +/* consecutive read/write operation */ +#define REQUEST_OUT 0xB2 +#define REQUEST_IN 0xB3 + +/* the out-buffer of these consecutive operations contain sub-commands when b[0] = 0 + * request: 0xB2; i: 0; v: 0; b[0] = 0, b[1] = subcmd, additional buffer + * the returning buffer looks as follows + * request: 0xB3; i: 0; v: 0; b[0] = 0xB3, additional buffer */ + +#define GET_TUNER_STATUS 0x05 +/* additional in buffer: + * 0 1 2 3 4 5 6 7 8 + * N/A N/A 0x05 signal-quality N/A N/A signal-strength lock==0 N/A */ + +#define GET_SYSTEM_STRING 0x06 +/* additional in buffer: + * 0 1 2 3 4 5 6 7 8 + * N/A 'U' 'S' 'B' '7' '0' '2' 'X' N/A */ + +#define SET_DISEQC_CMD 0x08 +/* additional out buffer: + * 0 1 2 3 4 + * len X1 X2 X3 X4 + * additional in buffer: + * 0 1 2 + * N/A 0 0 b[1] == b[2] == 0 -> success otherwise not */ + +#define SET_LNB_POWER 0x09 +/* additional out buffer: + * 0 1 2 + * 0x00 0xff 1 = on, 0 = off + * additional in buffer: + * 0 1 2 + * N/A 0 0 b[1] == b[2] == 0 -> success otherwise not */ + +#define GET_MAC_ADDRESS 0x0A +/* #define GET_MAC_ADDRESS 0x0B */ +/* additional in buffer: + * 0 1 2 3 4 5 6 7 8 + * N/A N/A 0x0A or 0x0B MAC0 MAC1 MAC2 MAC3 MAC4 MAC5 */ + +#define SET_PID_FILTER 0x11 +/* additional in buffer: + * 0 1 ... 14 15 16 + * PID0_MSB PID0_LSB ... PID7_MSB PID7_LSB PID_active (bits) */ + +/* request: 0xB2; i: 0; v: 0; + * b[0] != 0 -> tune and lock a channel + * 0 1 2 3 4 5 6 7 + * freq0 freq1 divstep srate0 srate1 srate2 flag chksum + */ + + +/* one direction requests */ +#define READ_REMOTE_REQ 0xB4 +/* IN i: 0; v: 0; b[0] == request, b[1] == key */ + +#define READ_PID_NUMBER_REQ 0xB5 +/* IN i: 0; v: 0; b[0] == request, b[1] == 0, b[2] = pid number */ + +#define WRITE_EEPROM_REQ 0xB6 +/* OUT i: offset; v: value to write; no extra buffer */ + +#define READ_EEPROM_REQ 0xB7 +/* IN i: bufferlen; v: offset; buffer with bufferlen bytes */ + +#define READ_STATUS 0xB8 +/* IN i: 0; v: 0; bufferlen 10 */ + +#define READ_TUNER_REG_REQ 0xB9 +/* IN i: 0; v: register; b[0] = value */ + +#define READ_FX2_REG_REQ 0xBA +/* IN i: offset; v: 0; b[0] = value */ + +#define WRITE_FX2_REG_REQ 0xBB +/* OUT i: offset; v: value to write; 1 byte extra buffer */ + +#define SET_TUNER_POWER_REQ 0xBC +/* IN i: 0 = power off, 1 = power on */ + +#define WRITE_TUNER_REG_REQ 0xBD +/* IN i: register, v: value to write, no extra buffer */ + +#define RESET_TUNER 0xBE +/* IN i: 0, v: 0, no extra buffer */ + +extern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d); + +extern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec); +extern int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, int olen, u8 *i, int ilen, int msec); +extern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); +extern int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); + +#endif -- cgit v0.10.2 From e69339d9a43d4691f6a05c5a54a00d54814aaa68 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:42 -0700 Subject: [PATCH] dvb: usb: dibusb: Kworld Xpert DVB-T USB2.0 support Add USB IDs of the Kworld Xpert DVB-T USB2.0 (clone of the ADStech box). Thanks to Marcus Hagn for testing. Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c index 828b518..c9f3e90 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mb.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c @@ -126,10 +126,12 @@ static struct usb_device_id dibusb_dib3000mb_table [] = { /* 25 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_COLD) }, /* 26 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_WARM) }, +/* 27 */ { USB_DEVICE(USB_VID_KWORLD, USB_PID_KWORLD_VSTREAM_COLD) }, + // #define DVB_USB_DIBUSB_MB_FAULTY_USB_IDs #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs -/* 27 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) }, +/* 28 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) }, #endif { } /* Terminating entry */ }; @@ -262,7 +264,7 @@ static struct dvb_usb_properties dibusb1_1_an2235_properties = { }, #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs { "Artec T1 USB1.1 TVBOX with AN2235 (faulty USB IDs)", - { &dibusb_dib3000mb_table[27], NULL }, + { &dibusb_dib3000mb_table[28], NULL }, { NULL }, }, #endif @@ -306,12 +308,16 @@ static struct dvb_usb_properties dibusb2_0b_properties = { } }, - .num_device_descs = 1, + .num_device_descs = 2, .devices = { - { "KWorld/ADSTech Instant DVB-T USB 2.0", + { "KWorld/ADSTech Instant DVB-T USB2.0", { &dibusb_dib3000mb_table[23], NULL }, { &dibusb_dib3000mb_table[24], NULL }, }, + { "KWorld Xpert DVB-T USB2.0", + { &dibusb_dib3000mb_table[27], NULL }, + { NULL } + }, } }; diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 2b249c7..1b97838 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -24,6 +24,7 @@ #define USB_VID_HANFTEK 0x15f4 #define USB_VID_HAUPPAUGE 0x2040 #define USB_VID_HYPER_PALTEK 0x1025 +#define USB_VID_KWORLD 0xeb2a #define USB_VID_KYE 0x0458 #define USB_VID_MEDION 0x1660 #define USB_VID_VISIONPLUS 0x13d3 -- cgit v0.10.2 From 54127d64d2094207e0e12a4a9eec33573f25f7ac Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:43 -0700 Subject: [PATCH] dvb: usb: removed empty module_init/exit calls Removed empty module_init/exit calls. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c index 65f0c09..ea1098a 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c @@ -196,19 +196,6 @@ void dvb_usb_device_exit(struct usb_interface *intf) } EXPORT_SYMBOL(dvb_usb_device_exit); -/* module stuff */ -static int __init dvb_usb_module_init(void) -{ - return 0; -} - -static void __exit dvb_usb_module_exit(void) -{ -} - -module_init (dvb_usb_module_init); -module_exit (dvb_usb_module_exit); - MODULE_VERSION("0.3"); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices"); -- cgit v0.10.2 From 43bc3f41e4b1bb88adaef593f50c1f032bf0e876 Mon Sep 17 00:00:00 2001 From: "Ye Jianjun (Joey" Date: Fri, 9 Sep 2005 13:02:44 -0700 Subject: [PATCH] dvb: usb: dtt200u: copy frontend_ops before modifying Fix: copy frontend_ops before modifying Signed-off-by: Ye Jianjun (Joey) Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-usb/dtt200u-fe.c b/drivers/media/dvb/dvb-usb/dtt200u-fe.c index b032523..0a94ec2 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u-fe.c +++ b/drivers/media/dvb/dvb-usb/dtt200u-fe.c @@ -18,6 +18,7 @@ struct dtt200u_fe_state { struct dvb_frontend_parameters fep; struct dvb_frontend frontend; + struct dvb_frontend_ops ops; }; static int dtt200u_fe_read_status(struct dvb_frontend* fe, fe_status_t *stat) @@ -163,8 +164,9 @@ struct dvb_frontend* dtt200u_fe_attach(struct dvb_usb_device *d) deb_info("attaching frontend dtt200u\n"); state->d = d; + memcpy(&state->ops,&dtt200u_fe_ops,sizeof(struct dvb_frontend_ops)); - state->frontend.ops = &dtt200u_fe_ops; + state->frontend.ops = &state->ops; state->frontend.demodulator_priv = state; goto success; -- cgit v0.10.2 From 62703b9d72114a563488cd4be6d0827618395589 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:46 -0700 Subject: [PATCH] dvb: usb: dtt200u: add proper device names Added names for clones of the DVB-T stick. Whitespace cleanups. Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c index 47dba6e..9d74f48 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u.c +++ b/drivers/media/dvb/dvb-usb/dtt200u.c @@ -106,12 +106,11 @@ static int dtt200u_usb_probe(struct usb_interface *intf, } static struct usb_device_id dtt200u_usb_table [] = { -// { USB_DEVICE(0x04b4,0x8613) }, - { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) }, - { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) }, - { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) }, - { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) }, - { 0 }, + { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) }, + { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) }, + { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) }, + { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) }, + { 0 }, }; MODULE_DEVICE_TABLE(usb, dtt200u_usb_table); @@ -189,7 +188,7 @@ static struct dvb_usb_properties wt220u_properties = { .num_device_descs = 1, .devices = { - { .name = "WideView WT-220U PenType Receiver (and clones)", + { .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)", .cold_ids = { &dtt200u_usb_table[2], NULL }, .warm_ids = { &dtt200u_usb_table[3], NULL }, }, @@ -201,9 +200,9 @@ static struct dvb_usb_properties wt220u_properties = { static struct usb_driver dtt200u_usb_driver = { .owner = THIS_MODULE, .name = "dvb_usb_dtt200u", - .probe = dtt200u_usb_probe, + .probe = dtt200u_usb_probe, .disconnect = dvb_usb_device_exit, - .id_table = dtt200u_usb_table, + .id_table = dtt200u_usb_table, }; /* module stuff */ -- cgit v0.10.2 From 47dc3d688d04f06d8ef90a06c48930906fbc4a8c Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:47 -0700 Subject: [PATCH] dvb: usb: core: change dvb_usb_device_init() API Change the init call to optionally return the new dvb_usb_device directly. Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c index f2fcc2f..e55322e 100644 --- a/drivers/media/dvb/dvb-usb/a800.c +++ b/drivers/media/dvb/dvb-usb/a800.c @@ -90,7 +90,7 @@ static struct dvb_usb_properties a800_properties; static int a800_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&a800_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&a800_properties,THIS_MODULE,NULL); } /* do not change the order of the ID table */ diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index 9e96a18..d2be035 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c @@ -211,7 +211,7 @@ static struct dvb_usb_properties cxusb_properties; static int cxusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&cxusb_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&cxusb_properties,THIS_MODULE,NULL); } static struct usb_device_id cxusb_table [] = { diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c index c9f3e90..0058505 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mb.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c @@ -86,9 +86,9 @@ static struct dvb_usb_properties dibusb2_0b_properties; static int dibusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE) == 0 || - dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE) == 0 || - dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE) == 0) + if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE,NULL) == 0 || + dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE,NULL) == 0 || + dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE,NULL) == 0) return 0; return -EINVAL; diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c index e9dac43..6a0912e 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mc.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c @@ -20,7 +20,7 @@ static struct dvb_usb_properties dibusb_mc_properties; static int dibusb_mc_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&dibusb_mc_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&dibusb_mc_properties,THIS_MODULE,NULL); } /* do not change the order of the ID table */ diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index f70e0be..24d2bc6 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -173,7 +173,7 @@ static struct dvb_usb_properties digitv_properties; static int digitv_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,NULL); } static struct usb_device_id digitv_table [] = { diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c index 9d74f48..5aa12eb 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u.c +++ b/drivers/media/dvb/dvb-usb/dtt200u.c @@ -98,8 +98,8 @@ static struct dvb_usb_properties wt220u_properties; static int dtt200u_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE) == 0 || - dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE) == 0) + if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE,NULL) == 0 || + dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE,NULL) == 0) return 0; return -ENODEV; diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 1b97838..0818996 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -27,6 +27,7 @@ #define USB_VID_KWORLD 0xeb2a #define USB_VID_KYE 0x0458 #define USB_VID_MEDION 0x1660 +#define USB_VID_PINNACLE 0x2304 #define USB_VID_VISIONPLUS 0x13d3 #define USB_VID_TWINHAN 0x1822 #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 @@ -88,5 +89,7 @@ #define USB_PID_MEDION_MD95700 0x0932 #define USB_PID_KYE_DVB_T_COLD 0x701e #define USB_PID_KYE_DVB_T_WARM 0x701f +#define USB_PID_PCTV_200E 0x020e +#define USB_PID_PCTV_400E 0x020f #endif diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c index ea1098a..a902059 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c @@ -128,7 +128,9 @@ static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device /* * USB */ -int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties *props, struct module *owner) + +int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties + *props, struct module *owner,struct dvb_usb_device **du) { struct usb_device *udev = interface_to_usbdev(intf); struct dvb_usb_device *d = NULL; @@ -170,6 +172,9 @@ int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties *p usb_set_intfdata(intf, d); + if (du != NULL) + *du = d; + ret = dvb_usb_init(d); } diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index a80567c..0e4f103 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h @@ -127,7 +127,7 @@ struct dvb_usb_device; * helper functions. * * @urb: describes the kind of USB transfer used for MPEG2-TS-streaming. - * Currently only BULK is implemented + * (BULK or ISOC) * * @num_device_descs: number of struct dvb_usb_device_description in @devices * @devices: array of struct dvb_usb_device_description compatibles with these @@ -310,7 +310,7 @@ struct dvb_usb_device { void *priv; }; -extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *); +extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *, struct dvb_usb_device **); extern void dvb_usb_device_exit(struct usb_interface *); /* the generic read/write method for device control */ diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c index 258a92b..1841a66 100644 --- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c +++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c @@ -144,7 +144,7 @@ static struct dvb_usb_properties nova_t_properties; static int nova_t_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&nova_t_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&nova_t_properties,THIS_MODULE,NULL); } /* do not change the order of the ID table */ diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c index 2112ac3..6fd6765 100644 --- a/drivers/media/dvb/dvb-usb/umt-010.c +++ b/drivers/media/dvb/dvb-usb/umt-010.c @@ -77,7 +77,7 @@ static struct dvb_usb_properties umt_properties; static int umt_probe(struct usb_interface *intf, const struct usb_device_id *id) { - if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE) == 0) + if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE,NULL) == 0) return 0; return -EINVAL; } diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c index 1f5034c..de13c04 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.c +++ b/drivers/media/dvb/dvb-usb/vp702x.c @@ -197,7 +197,7 @@ static int vp702x_usb_probe(struct usb_interface *intf, usb_clear_halt(udev,usb_sndctrlpipe(udev,0)); usb_clear_halt(udev,usb_rcvctrlpipe(udev,0)); - return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE,NULL); } static struct usb_device_id vp702x_usb_table [] = { diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 9ac95f5..13406a8 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c @@ -199,7 +199,7 @@ static struct dvb_usb_properties vp7045_properties; static int vp7045_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&vp7045_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&vp7045_properties,THIS_MODULE,NULL); } static struct usb_device_id vp7045_usb_table [] = { -- cgit v0.10.2 From 115eea4e91049a42d81e5284cbb0f50acab6eb39 Mon Sep 17 00:00:00 2001 From: Svante Olofsson Date: Fri, 9 Sep 2005 13:02:48 -0700 Subject: [PATCH] dvb: usb: digitv: support for nxt6000 demod Add support for the NXT6000-based digitv-box. Add .get_tune_settings callback for the NXT6000 to have a min_tune_delay of 500ms. Signed-off-by: Svante Olofsson Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index 24d2bc6..74545f8 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -111,31 +111,28 @@ static int digitv_mt352_demod_init(struct dvb_frontend *fe) } static struct mt352_config digitv_mt352_config = { - .demod_address = 0x0, /* ignored by the digitv anyway */ .demod_init = digitv_mt352_demod_init, .pll_set = dvb_usb_pll_set, }; -static struct nxt6000_config digitv_nxt6000_config = { - .demod_address = 0x0, /* ignored by the digitv anyway */ - .clock_inversion = 0x0, +static int digitv_nxt6000_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) +{ + struct dvb_usb_device *d = fe->dvb->priv; + u8 b[5]; + dvb_usb_pll_set(fe,fep,b); + return digitv_ctrl_msg(d,USB_WRITE_TUNER,0,&b[1],4,NULL,0); +} - .pll_init = NULL, - .pll_set = NULL, +static struct nxt6000_config digitv_nxt6000_config = { + .clock_inversion = 1, + .pll_set = digitv_nxt6000_pll_set, }; static int digitv_frontend_attach(struct dvb_usb_device *d) { - if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL) + if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL || + (d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) return 0; - if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) { - - warn("nxt6000 support is not done yet, in fact you are one of the first " - "person who wants to use this device in Linux. Please report to " - "linux-dvb@linuxtv.org"); - - return 0; - } return -EIO; } @@ -173,7 +170,18 @@ static struct dvb_usb_properties digitv_properties; static int digitv_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,NULL); + struct dvb_usb_device *d; + int ret; + if ((ret = dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,&d)) == 0) { + u8 b[4] = { 0 }; + + b[0] = 1; + digitv_ctrl_msg(d,USB_WRITE_REMOTE_TYPE,0,b,4,NULL,0); + + b[0] = 0; + digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0); + } + return ret; } static struct usb_device_id digitv_table [] = { diff --git a/drivers/media/dvb/frontends/nxt6000.c b/drivers/media/dvb/frontends/nxt6000.c index 966de98..88a57b7 100644 --- a/drivers/media/dvb/frontends/nxt6000.c +++ b/drivers/media/dvb/frontends/nxt6000.c @@ -482,6 +482,7 @@ static int nxt6000_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par if ((result = nxt6000_set_inversion(state, param->inversion)) < 0) return result; + msleep(500); return 0; } @@ -525,6 +526,12 @@ static int nxt6000_read_signal_strength(struct dvb_frontend* fe, u16* signal_str return 0; } +static int nxt6000_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) +{ + tune->min_delay_ms = 500; + return 0; +} + static struct dvb_frontend_ops nxt6000_ops; struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, @@ -578,6 +585,8 @@ static struct dvb_frontend_ops nxt6000_ops = { .init = nxt6000_init, + .get_tune_settings = nxt6000_fe_get_tune_settings, + .set_frontend = nxt6000_set_frontend, .read_status = nxt6000_read_status, -- cgit v0.10.2 From 3beab78f8ad5a483fdbdcbb8599fb06da102b8b7 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:50 -0700 Subject: [PATCH] dvb: usb: white space cleanup white space cleanup Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 13406a8..0f57abe 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c @@ -164,7 +164,6 @@ static int vp7045_read_eeprom(struct dvb_usb_device *d,u8 *buf, int len, int off return 0; } - static int vp7045_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) { return vp7045_read_eeprom(d,mac, 6, MAC_0_ADDR); @@ -256,9 +255,9 @@ static struct dvb_usb_properties vp7045_properties = { static struct usb_driver vp7045_usb_driver = { .owner = THIS_MODULE, .name = "dvb_usb_vp7045", - .probe = vp7045_usb_probe, + .probe = vp7045_usb_probe, .disconnect = dvb_usb_device_exit, - .id_table = vp7045_usb_table, + .id_table = vp7045_usb_table, }; /* module stuff */ -- cgit v0.10.2 From e2efeab26b77061ba5418f4c98c3b3ed100fb608 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:51 -0700 Subject: [PATCH] dvb: usb: cxusb: fixes for new firmware This patch changes two things: 1) a firmware update made by the vendor, which has to be done in Windows for now, changes the DVB-data-pipe from isochronous to bulk: it fixes the data distortions (and thus the video-distortions) in DVB-T mode; there is no backwards compatibility with the old firmware as it didn't work anyway 2) with the help of Steve Toth some reverse-engineered functionality is now named correctly, thank you Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index d2be035..3fe383f 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c @@ -48,35 +48,26 @@ static int cxusb_ctrl_msg(struct dvb_usb_device *d, return 0; } -/* I2C */ -static void cxusb_set_i2c_path(struct dvb_usb_device *d, enum cxusb_i2c_pathes path) +/* GPIO */ +static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff) { struct cxusb_state *st = d->priv; u8 o[2],i; - if (path == st->cur_i2c_path) + if (st->gpio_write_state[GPIO_TUNER] == onoff) return; - o[0] = IOCTL_SET_I2C_PATH; - switch (path) { - case PATH_CX22702: - o[1] = 0; - break; - case PATH_TUNER_OTHER: - o[1] = 1; - break; - default: - err("unkown i2c path"); - return; - } - cxusb_ctrl_msg(d,CMD_IOCTL,o,2,&i,1); + o[0] = GPIO_TUNER; + o[1] = onoff; + cxusb_ctrl_msg(d,CMD_GPIO_WRITE,o,2,&i,1); if (i != 0x01) - deb_info("i2c_path setting failed.\n"); + deb_info("gpio_write failed.\n"); - st->cur_i2c_path = path; + st->gpio_write_state[GPIO_TUNER] = onoff; } +/* I2C */ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) { struct dvb_usb_device *d = i2c_get_adapdata(adap); @@ -92,10 +83,10 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) switch (msg[i].addr) { case 0x63: - cxusb_set_i2c_path(d,PATH_CX22702); + cxusb_gpio_tuner(d,0); break; default: - cxusb_set_i2c_path(d,PATH_TUNER_OTHER); + cxusb_gpio_tuner(d,1); break; } @@ -147,16 +138,20 @@ static struct i2c_algorithm cxusb_i2c_algo = { static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff) { - return 0; + u8 b = 0; + if (onoff) + return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0); + else + return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0); } static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) { u8 buf[2] = { 0x03, 0x00 }; if (onoff) - cxusb_ctrl_msg(d,0x36, buf, 2, NULL, 0); + cxusb_ctrl_msg(d,CMD_STREAMING_ON, buf, 2, NULL, 0); else - cxusb_ctrl_msg(d,0x37, NULL, 0, NULL, 0); + cxusb_ctrl_msg(d,CMD_STREAMING_OFF, NULL, 0, NULL, 0); return 0; } @@ -182,22 +177,11 @@ static int cxusb_tuner_attach(struct dvb_usb_device *d) static int cxusb_frontend_attach(struct dvb_usb_device *d) { - u8 buf[2] = { 0x03, 0x00 }; - u8 b = 0; - - if (usb_set_interface(d->udev,0,0) < 0) - err("set interface to alts=0 failed"); - - cxusb_ctrl_msg(d,0xde,&b,0,NULL,0); - cxusb_set_i2c_path(d,PATH_TUNER_OTHER); - cxusb_ctrl_msg(d,CMD_POWER_OFF, NULL, 0, &b, 1); - + u8 b; if (usb_set_interface(d->udev,0,6) < 0) err("set interface failed"); - cxusb_ctrl_msg(d,0x36, buf, 2, NULL, 0); - cxusb_set_i2c_path(d,PATH_CX22702); - cxusb_ctrl_msg(d,CMD_POWER_ON, NULL, 0, &b, 1); + cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, &b, 1); if ((d->fe = cx22702_attach(&cxusb_cx22702_config, &d->i2c_adap)) != NULL) return 0; @@ -237,14 +221,12 @@ static struct dvb_usb_properties cxusb_properties = { .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ .urb = { - .type = DVB_USB_ISOC, + .type = DVB_USB_BULK, .count = 5, .endpoint = 0x02, .u = { - .isoc = { - .framesperurb = 32, - .framesize = 940, - .interval = 5, + .bulk = { + .buffersize = 8192, } } }, diff --git a/drivers/media/dvb/dvb-usb/cxusb.h b/drivers/media/dvb/dvb-usb/cxusb.h index 1d79016..135c2a8 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.h +++ b/drivers/media/dvb/dvb-usb/cxusb.h @@ -1,30 +1,31 @@ #ifndef _DVB_USB_CXUSB_H_ #define _DVB_USB_CXUSB_H_ -#define DVB_USB_LOG_PREFIX "digitv" +#define DVB_USB_LOG_PREFIX "cxusb" #include "dvb-usb.h" extern int dvb_usb_cxusb_debug; #define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args) /* usb commands - some of it are guesses, don't have a reference yet */ -#define CMD_I2C_WRITE 0x08 -#define CMD_I2C_READ 0x09 +#define CMD_I2C_WRITE 0x08 +#define CMD_I2C_READ 0x09 -#define CMD_IOCTL 0x0e -#define IOCTL_SET_I2C_PATH 0x02 +#define CMD_GPIO_READ 0x0d +#define CMD_GPIO_WRITE 0x0e +#define GPIO_TUNER 0x02 -#define CMD_POWER_OFF 0x50 -#define CMD_POWER_ON 0x51 +#define CMD_POWER_OFF 0xdc +#define CMD_POWER_ON 0xde -enum cxusb_i2c_pathes { - PATH_UNDEF = 0x00, - PATH_CX22702 = 0x01, - PATH_TUNER_OTHER = 0x02, -}; +#define CMD_STREAMING_ON 0x36 +#define CMD_STREAMING_OFF 0x37 + +#define CMD_ANALOG 0x50 +#define CMD_DIGITAL 0x51 struct cxusb_state { - enum cxusb_i2c_pathes cur_i2c_path; + u8 gpio_write_state[3]; }; #endif -- cgit v0.10.2 From 5b5b53452be0b1132cfb8e22fbe5fe43c25140a0 Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:52 -0700 Subject: [PATCH] dvb: remove noisy debug print comment out noisy dprintk in dst_get_signal() (why are errors only visible with debug on? this needs to be cleaned up so we can disable debug by default) Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 07a0b0a..6c34ac9c 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -928,7 +928,7 @@ static int dst_get_signal(struct dst_state* state) { int retval; u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; - dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__); + //dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__); if ((state->diseq_flags & ATTEMPT_TUNE) == 0) { state->decode_lock = state->decode_strength = state->decode_snr = 0; return 0; -- cgit v0.10.2 From 466d725ac8d9c58a5de87f72b4fe066c4bad3d9d Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:53 -0700 Subject: [PATCH] dvb: bt8xx: endianness fix Endianness fix for risc DMA start address setting. (reported by Stefan Haubenthal/Peter Hettkamp) Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c index 3bfbba3..f295714 100644 --- a/drivers/media/dvb/bt8xx/bt878.c +++ b/drivers/media/dvb/bt8xx/bt878.c @@ -219,7 +219,7 @@ void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin, controlreg &= ~0x1f; controlreg |= 0x1b; - btwrite(cpu_to_le32(bt->risc_dma), BT878_ARISC_START); + btwrite(bt->risc_dma, BT878_ARISC_START); /* original int mask had : * 6 2 8 4 0 -- cgit v0.10.2 From 1f15ddd0b79d1722049952b7359533a18a72f106 Mon Sep 17 00:00:00 2001 From: David Johnson Date: Fri, 9 Sep 2005 13:02:54 -0700 Subject: [PATCH] dvb: bt8xx: cleanup Indentation fixes and remove unnecessary braces. Signed-off-by: David Johnson Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index 6f857c6..b29b0f5 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c @@ -32,9 +32,7 @@ #include "dvbdev.h" #include "dvb_demux.h" #include "dvb_frontend.h" - #include "dvb-bt8xx.h" - #include "bt878.h" static int debug; @@ -43,9 +41,9 @@ module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); #define dprintk( args... ) \ - do { \ + do \ if (debug) printk(KERN_DEBUG args); \ - } while (0) + while (0) static void dvb_bt8xx_task(unsigned long data) { @@ -119,14 +117,12 @@ static struct bt878 __init *dvb_bt8xx_878_match(unsigned int bttv_nr, struct pci unsigned int card_nr; /* Hmm, n squared. Hope n is small */ - for (card_nr = 0; card_nr < bt878_num; card_nr++) { + for (card_nr = 0; card_nr < bt878_num; card_nr++) if (is_pci_slot_eq(bt878[card_nr].dev, bttv_pci_dev)) return &bt878[card_nr]; - } return NULL; } - static int thomson_dtt7579_demod_init(struct dvb_frontend* fe) { static u8 mt352_clock_config [] = { 0x89, 0x38, 0x38 }; @@ -157,13 +153,19 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; - if (params->frequency < 542000000) cp = 0xb4; - else if (params->frequency < 771000000) cp = 0xbc; - else cp = 0xf4; + if (params->frequency < 542000000) + cp = 0xb4; + else if (params->frequency < 771000000) + cp = 0xbc; + else + cp = 0xf4; - if (params->frequency == 0) bs = 0x03; - else if (params->frequency < 443250000) bs = 0x02; - else bs = 0x08; + if (params->frequency == 0) + bs = 0x03; + else if (params->frequency < 443250000) + bs = 0x02; + else + bs = 0x08; pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address pllbuf[1] = div >> 8; @@ -175,7 +177,6 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ } static struct mt352_config thomson_dtt7579_config = { - .demod_address = 0x0f, .demod_init = thomson_dtt7579_demod_init, .pll_set = thomson_dtt7579_pll_set, @@ -183,25 +184,26 @@ static struct mt352_config thomson_dtt7579_config = { static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { - u32 freq = params->frequency; - - int i, a, n, pump; - u32 band, pll; + u32 freq = params->frequency; + int i, a, n, pump; + u32 band, pll; - u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000, - 1576000,1718000,1856000,2036000,2150000}; - u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000, - 0x00102000,0x00104000,0x00108000,0x00110000, - 0x00120000,0x00140000}; + u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000, + 1576000,1718000,1856000,2036000,2150000}; + u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000, + 0x00102000,0x00104000,0x00108000,0x00110000, + 0x00120000,0x00140000}; -#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */ + #define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */ printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq); /* This is really the bit driving the tuner chip cx24108 */ - if(freq<950000) freq=950000; /* kHz */ - if(freq>2150000) freq=2150000; /* satellite IF is 950..2150MHz */ + if (freq<950000) + freq = 950000; /* kHz */ + else if (freq>2150000) + freq = 2150000; /* satellite IF is 950..2150MHz */ /* decide which VCO to use for the input frequency */ for(i=1;(idvb->priv; @@ -258,15 +257,23 @@ static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_front div = (36000000 + params->frequency + 83333) / 166666; cfg = 0x88; - if (params->frequency < 175000000) cpump = 2; - else if (params->frequency < 390000000) cpump = 1; - else if (params->frequency < 470000000) cpump = 2; - else if (params->frequency < 750000000) cpump = 2; - else cpump = 3; + if (params->frequency < 175000000) + cpump = 2; + else if (params->frequency < 390000000) + cpump = 1; + else if (params->frequency < 470000000) + cpump = 2; + else if (params->frequency < 750000000) + cpump = 2; + else + cpump = 3; - if (params->frequency < 175000000) band_select = 0x0e; - else if (params->frequency < 470000000) band_select = 0x05; - else band_select = 0x03; + if (params->frequency < 175000000) + band_select = 0x0e; + else if (params->frequency < 470000000) + band_select = 0x05; + else + band_select = 0x03; data[0] = (div >> 8) & 0x7f; data[1] = div & 0xff; @@ -285,14 +292,11 @@ static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const s } static struct sp887x_config microtune_mt7202dtf_config = { - .demod_address = 0x70, .pll_set = microtune_mt7202dtf_pll_set, .request_firmware = microtune_mt7202dtf_request_firmware, }; - - static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe) { static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d }; @@ -303,7 +307,6 @@ static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe) static u8 mt352_av771_extra[] = { 0xB5, 0x7A }; static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; - mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); udelay(2000); mt352_write(fe, mt352_reset, sizeof(mt352_reset)); @@ -326,25 +329,43 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; - if (params->frequency < 150000000) cp = 0xB4; - else if (params->frequency < 173000000) cp = 0xBC; - else if (params->frequency < 250000000) cp = 0xB4; - else if (params->frequency < 400000000) cp = 0xBC; - else if (params->frequency < 420000000) cp = 0xF4; - else if (params->frequency < 470000000) cp = 0xFC; - else if (params->frequency < 600000000) cp = 0xBC; - else if (params->frequency < 730000000) cp = 0xF4; - else cp = 0xFC; - - if (params->frequency < 150000000) bs = 0x01; - else if (params->frequency < 173000000) bs = 0x01; - else if (params->frequency < 250000000) bs = 0x02; - else if (params->frequency < 400000000) bs = 0x02; - else if (params->frequency < 420000000) bs = 0x02; - else if (params->frequency < 470000000) bs = 0x02; - else if (params->frequency < 600000000) bs = 0x08; - else if (params->frequency < 730000000) bs = 0x08; - else bs = 0x08; + if (params->frequency < 150000000) + cp = 0xB4; + else if (params->frequency < 173000000) + cp = 0xBC; + else if (params->frequency < 250000000) + cp = 0xB4; + else if (params->frequency < 400000000) + cp = 0xBC; + else if (params->frequency < 420000000) + cp = 0xF4; + else if (params->frequency < 470000000) + cp = 0xFC; + else if (params->frequency < 600000000) + cp = 0xBC; + else if (params->frequency < 730000000) + cp = 0xF4; + else + cp = 0xFC; + + if (params->frequency < 150000000) + bs = 0x01; + else if (params->frequency < 173000000) + bs = 0x01; + else if (params->frequency < 250000000) + bs = 0x02; + else if (params->frequency < 400000000) + bs = 0x02; + else if (params->frequency < 420000000) + bs = 0x02; + else if (params->frequency < 470000000) + bs = 0x02; + else if (params->frequency < 600000000) + bs = 0x08; + else if (params->frequency < 730000000) + bs = 0x08; + else + bs = 0x08; pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address pllbuf[1] = div >> 8; @@ -356,19 +377,15 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct } static struct mt352_config advbt771_samsung_tdtc9251dh0_config = { - .demod_address = 0x0f, .demod_init = advbt771_samsung_tdtc9251dh0_demod_init, .pll_set = advbt771_samsung_tdtc9251dh0_pll_set, }; - static struct dst_config dst_config = { - .demod_address = 0x55, }; - static int or51211_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name) { struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv; @@ -398,10 +415,9 @@ static void or51211_reset(struct dvb_frontend * fe) */ /* reset & PRM1,2&4 are outputs */ int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F); - if (ret != 0) { + if (ret != 0) printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR " "(%i)\n", ret); - } bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */ msleep(20); /* Now set for normal operation */ @@ -417,7 +433,6 @@ static void or51211_sleep(struct dvb_frontend * fe) } static struct or51211_config or51211_config = { - .demod_address = 0x15, .request_firmware = or51211_request_firmware, .setmode = or51211_setmode, @@ -425,7 +440,6 @@ static struct or51211_config or51211_config = { .sleep = or51211_sleep, }; - static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; @@ -454,13 +468,11 @@ static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_fronten } static struct nxt6000_config vp3021_alps_tded4_config = { - .demod_address = 0x0a, .clock_inversion = 1, .pll_set = vp3021_alps_tded4_pll_set, }; - static void frontend_init(struct dvb_bt8xx_card *card, u32 type) { int ret; @@ -468,7 +480,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) switch(type) { #ifdef BTTV_DVICO_DVBT_LITE - case BTTV_DVICO_DVBT_LITE: + case BTTV_DVICO_DVBT_LITE: card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter); if (card->fe != NULL) { card->fe->ops->info.frequency_min = 174000000; @@ -479,24 +491,22 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) #endif #ifdef BTTV_TWINHAN_VP3021 - case BTTV_TWINHAN_VP3021: + case BTTV_TWINHAN_VP3021: #else - case BTTV_NEBULA_DIGITV: + case BTTV_NEBULA_DIGITV: #endif card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); - if (card->fe != NULL) { + if (card->fe != NULL) break; - } break; - case BTTV_AVDVBT_761: + case BTTV_AVDVBT_761: card->fe = sp887x_attach(µtune_mt7202dtf_config, card->i2c_adapter); - if (card->fe != NULL) { + if (card->fe != NULL) break; - } break; - case BTTV_AVDVBT_771: + case BTTV_AVDVBT_771: card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter); if (card->fe != NULL) { card->fe->ops->info.frequency_min = 174000000; @@ -505,7 +515,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) } break; - case BTTV_TWINHAN_DST: + case BTTV_TWINHAN_DST: /* DST is not a frontend driver !!! */ state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL); /* Setup the Card */ @@ -522,54 +532,48 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) /* Attach other DST peripherals if any */ /* Conditional Access device */ - if (state->dst_hw_cap & DST_TYPE_HAS_CA) { + if (state->dst_hw_cap & DST_TYPE_HAS_CA) ret = dst_ca_attach(state, &card->dvb_adapter); - } - if (card->fe != NULL) { + + if (card->fe != NULL) break; - } break; - case BTTV_PINNACLESAT: + case BTTV_PINNACLESAT: card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter); - if (card->fe != NULL) { + if (card->fe != NULL) break; - } break; - case BTTV_PC_HDTV: + case BTTV_PC_HDTV: card->fe = or51211_attach(&or51211_config, card->i2c_adapter); - if (card->fe != NULL) { + if (card->fe != NULL) break; - } break; } - if (card->fe == NULL) { + if (card->fe == NULL) printk("dvb-bt8xx: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n", card->bt->dev->vendor, card->bt->dev->device, card->bt->dev->subsystem_vendor, card->bt->dev->subsystem_device); - } else { + else if (dvb_register_frontend(&card->dvb_adapter, card->fe)) { printk("dvb-bt8xx: Frontend registration failed!\n"); if (card->fe->ops->release) card->fe->ops->release(card->fe); card->fe = NULL; } - } } static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) { int result; - if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, - THIS_MODULE)) < 0) { + if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, THIS_MODULE)) < 0) { printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result); return result; - } card->dvb_adapter.priv = card; @@ -664,9 +668,8 @@ static int dvb_bt8xx_probe(struct device *dev) strncpy(card->card_name, sub->core->name, sizeof(sub->core->name)); card->i2c_adapter = &sub->core->i2c_adap; - switch(sub->core->type) - { - case BTTV_PINNACLESAT: + switch(sub->core->type) { + case BTTV_PINNACLESAT: card->gpio_mode = 0x0400c060; /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR, BT878_DA_IOM=1,BT878_DA_APP to enable serial highspeed mode. */ @@ -675,7 +678,7 @@ static int dvb_bt8xx_probe(struct device *dev) break; #ifdef BTTV_DVICO_DVBT_LITE - case BTTV_DVICO_DVBT_LITE: + case BTTV_DVICO_DVBT_LITE: #endif card->gpio_mode = 0x0400C060; card->op_sync_orin = 0; @@ -686,25 +689,25 @@ static int dvb_bt8xx_probe(struct device *dev) break; #ifdef BTTV_TWINHAN_VP3021 - case BTTV_TWINHAN_VP3021: + case BTTV_TWINHAN_VP3021: #else - case BTTV_NEBULA_DIGITV: + case BTTV_NEBULA_DIGITV: #endif - case BTTV_AVDVBT_761: + case BTTV_AVDVBT_761: card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5); card->op_sync_orin = 0; card->irq_err_ignore = 0; /* A_PWRDN DA_SBR DA_APP (high speed serial) */ break; - case BTTV_AVDVBT_771: //case 0x07711461: + case BTTV_AVDVBT_771: //case 0x07711461: card->gpio_mode = 0x0400402B; card->op_sync_orin = BT878_RISC_SYNC_MASK; card->irq_err_ignore = 0; /* A_PWRDN DA_SBR DA_APP[0] PKTP=10 RISC_ENABLE FIFO_ENABLE*/ break; - case BTTV_TWINHAN_DST: + case BTTV_TWINHAN_DST: card->gpio_mode = 0x2204f2c; card->op_sync_orin = BT878_RISC_SYNC_MASK; card->irq_err_ignore = BT878_APABORT | BT878_ARIPERR | @@ -722,13 +725,13 @@ static int dvb_bt8xx_probe(struct device *dev) * RISC+FIFO ENABLE */ break; - case BTTV_PC_HDTV: + case BTTV_PC_HDTV: card->gpio_mode = 0x0100EC7B; card->op_sync_orin = 0; card->irq_err_ignore = 0; break; - default: + default: printk(KERN_WARNING "dvb_bt8xx: Unknown bttv card type: %d.\n", sub->core->type); kfree(card); @@ -751,7 +754,6 @@ static int dvb_bt8xx_probe(struct device *dev) kfree(card); return -EFAULT; - } init_MUTEX(&card->bt->gpio_lock); @@ -779,7 +781,8 @@ static int dvb_bt8xx_remove(struct device *dev) card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); dvb_dmxdev_release(&card->dmxdev); dvb_dmx_release(&card->demux); - if (card->fe) dvb_unregister_frontend(card->fe); + if (card->fe) + dvb_unregister_frontend(card->fe); dvb_unregister_adapter(&card->dvb_adapter); kfree(card); -- cgit v0.10.2 From 05ade5a5cd32f8393c22fc454b0546df2ed497c5 Mon Sep 17 00:00:00 2001 From: David Johnson Date: Fri, 9 Sep 2005 13:02:55 -0700 Subject: [PATCH] dvb: bt8xx: Nebula DigiTV mt352 support Add support for Nebula DigiTV PCI cards with the MT352 frontend. Signed-off-by: David Johnson Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index b29b0f5..514dff3 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c @@ -45,6 +45,8 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); if (debug) printk(KERN_DEBUG args); \ while (0) +#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ + static void dvb_bt8xx_task(unsigned long data) { struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *)data; @@ -150,7 +152,6 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ unsigned char bs = 0; unsigned char cp = 0; - #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; if (params->frequency < 542000000) @@ -326,7 +327,6 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct unsigned char bs = 0; unsigned char cp = 0; - #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; if (params->frequency < 150000000) @@ -416,8 +416,7 @@ static void or51211_reset(struct dvb_frontend * fe) /* reset & PRM1,2&4 are outputs */ int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F); if (ret != 0) - printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR " - "(%i)\n", ret); + printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR (%i)\n", ret); bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */ msleep(20); /* Now set for normal operation */ @@ -473,6 +472,80 @@ static struct nxt6000_config vp3021_alps_tded4_config = { .pll_set = vp3021_alps_tded4_pll_set, }; +static int digitv_alps_tded4_demod_init(struct dvb_frontend* fe) +{ + static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d }; + static u8 mt352_reset [] = { 0x50, 0x80 }; + static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 }; + static u8 mt352_agc_cfg [] = { 0x67, 0x20, 0xa0 }; + static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; + + mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); + udelay(2000); + mt352_write(fe, mt352_reset, sizeof(mt352_reset)); + mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg)); + mt352_write(fe, mt352_agc_cfg,sizeof(mt352_agc_cfg)); + mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg)); + + return 0; +} + +static int digitv_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf) +{ + u32 div; + struct dvb_ofdm_parameters *op = ¶ms->u.ofdm; + + div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; + + pllbuf[0] = 0xc2; + pllbuf[1] = (div >> 8) & 0x7F; + pllbuf[2] = div & 0xFF; + pllbuf[3] = 0x85; + + dprintk("frequency %u, div %u\n", params->frequency, div); + + if (params->frequency < 470000000) + pllbuf[4] = 0x02; + else if (params->frequency > 823000000) + pllbuf[4] = 0x88; + else + pllbuf[4] = 0x08; + + if (op->bandwidth == 8) + pllbuf[4] |= 0x04; + + return 0; +} + +static void digitv_alps_tded4_reset(struct dvb_bt8xx_card *bt) +{ + /* + * Reset the frontend, must be called before trying + * to initialise the MT352 or mt352_attach + * will fail. + * + * Presumably not required for the NXT6000 frontend. + * + */ + + int ret = bttv_gpio_enable(bt->bttv_nr, 0x08, 0x08); + if (ret != 0) + printk(KERN_WARNING "digitv_alps_tded4: Init Error - Can't Reset DVR (%i)\n", ret); + + /* Pulse the reset line */ + bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */ + bttv_write_gpio(bt->bttv_nr, 0x08, 0x00); /* Low */ + msleep(100); + + bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */ +} + +static struct mt352_config digitv_alps_tded4_config = { + .demod_address = 0x0a, + .demod_init = digitv_alps_tded4_demod_init, + .pll_set = digitv_alps_tded4_pll_set, +}; + static void frontend_init(struct dvb_bt8xx_card *card, u32 type) { int ret; @@ -480,42 +553,51 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) switch(type) { #ifdef BTTV_DVICO_DVBT_LITE - case BTTV_DVICO_DVBT_LITE: + case BTTV_DVICO_DVBT_LITE: card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter); if (card->fe != NULL) { card->fe->ops->info.frequency_min = 174000000; card->fe->ops->info.frequency_max = 862000000; - break; } break; #endif #ifdef BTTV_TWINHAN_VP3021 - case BTTV_TWINHAN_VP3021: + case BTTV_TWINHAN_VP3021: #else - case BTTV_NEBULA_DIGITV: + case BTTV_NEBULA_DIGITV: #endif + /* + * It is possible to determine the correct frontend using the I2C bus (see the Nebula SDK); + * this would be a cleaner solution than trying each frontend in turn. + */ + + /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */ card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); if (card->fe != NULL) - break; + dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n"); + + /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */ + digitv_alps_tded4_reset(card); + card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter); + + if (card->fe != NULL) + dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n"); break; - case BTTV_AVDVBT_761: + case BTTV_AVDVBT_761: card->fe = sp887x_attach(µtune_mt7202dtf_config, card->i2c_adapter); - if (card->fe != NULL) - break; break; - case BTTV_AVDVBT_771: + case BTTV_AVDVBT_771: card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter); if (card->fe != NULL) { card->fe->ops->info.frequency_min = 174000000; card->fe->ops->info.frequency_max = 862000000; - break; } break; - case BTTV_TWINHAN_DST: + case BTTV_TWINHAN_DST: /* DST is not a frontend driver !!! */ state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL); /* Setup the Card */ @@ -534,21 +616,14 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) /* Conditional Access device */ if (state->dst_hw_cap & DST_TYPE_HAS_CA) ret = dst_ca_attach(state, &card->dvb_adapter); - - if (card->fe != NULL) - break; break; - case BTTV_PINNACLESAT: + case BTTV_PINNACLESAT: card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter); - if (card->fe != NULL) - break; break; - case BTTV_PC_HDTV: + case BTTV_PC_HDTV: card->fe = or51211_attach(&or51211_config, card->i2c_adapter); - if (card->fe != NULL) - break; break; } @@ -669,7 +744,7 @@ static int dvb_bt8xx_probe(struct device *dev) card->i2c_adapter = &sub->core->i2c_adap; switch(sub->core->type) { - case BTTV_PINNACLESAT: + case BTTV_PINNACLESAT: card->gpio_mode = 0x0400c060; /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR, BT878_DA_IOM=1,BT878_DA_APP to enable serial highspeed mode. */ @@ -678,7 +753,7 @@ static int dvb_bt8xx_probe(struct device *dev) break; #ifdef BTTV_DVICO_DVBT_LITE - case BTTV_DVICO_DVBT_LITE: + case BTTV_DVICO_DVBT_LITE: #endif card->gpio_mode = 0x0400C060; card->op_sync_orin = 0; @@ -689,25 +764,25 @@ static int dvb_bt8xx_probe(struct device *dev) break; #ifdef BTTV_TWINHAN_VP3021 - case BTTV_TWINHAN_VP3021: + case BTTV_TWINHAN_VP3021: #else - case BTTV_NEBULA_DIGITV: + case BTTV_NEBULA_DIGITV: #endif - case BTTV_AVDVBT_761: + case BTTV_AVDVBT_761: card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5); card->op_sync_orin = 0; card->irq_err_ignore = 0; /* A_PWRDN DA_SBR DA_APP (high speed serial) */ break; - case BTTV_AVDVBT_771: //case 0x07711461: + case BTTV_AVDVBT_771: //case 0x07711461: card->gpio_mode = 0x0400402B; card->op_sync_orin = BT878_RISC_SYNC_MASK; card->irq_err_ignore = 0; /* A_PWRDN DA_SBR DA_APP[0] PKTP=10 RISC_ENABLE FIFO_ENABLE*/ break; - case BTTV_TWINHAN_DST: + case BTTV_TWINHAN_DST: card->gpio_mode = 0x2204f2c; card->op_sync_orin = BT878_RISC_SYNC_MASK; card->irq_err_ignore = BT878_APABORT | BT878_ARIPERR | @@ -725,13 +800,13 @@ static int dvb_bt8xx_probe(struct device *dev) * RISC+FIFO ENABLE */ break; - case BTTV_PC_HDTV: + case BTTV_PC_HDTV: card->gpio_mode = 0x0100EC7B; card->op_sync_orin = 0; card->irq_err_ignore = 0; break; - default: + default: printk(KERN_WARNING "dvb_bt8xx: Unknown bttv card type: %d.\n", sub->core->type); kfree(card); -- cgit v0.10.2 From f30db067a593aeb3fdd97ec0a3e6399ea566f2ad Mon Sep 17 00:00:00 2001 From: Stuart Auchterlonie Date: Fri, 9 Sep 2005 13:02:56 -0700 Subject: [PATCH] dvb: nebula DigiTV nxt6000 fix Fix bug in Nebula DigiTV frontend detection for nxt6000. Signed-off-by: Stuart Auchterlonie Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index 514dff3..c5c7672 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c @@ -574,8 +574,10 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */ card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); - if (card->fe != NULL) + if (card->fe != NULL) { dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n"); + break; + } /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */ digitv_alps_tded4_reset(card); -- cgit v0.10.2 From f612c5793449ac653b2f4531696d8e74e771e3d3 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:02:58 -0700 Subject: [PATCH] dvb: dst: fix symbol rate setting Make the Symbolrate setting card specific. Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 6c34ac9c..66e69b8 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -324,12 +324,12 @@ static int dst_set_polarization(struct dst_state *state) { switch (state->voltage) { case SEC_VOLTAGE_13: // vertical - printk("%s: Polarization=[Vertical]\n", __FUNCTION__); + dprintk("%s: Polarization=[Vertical]\n", __FUNCTION__); state->tx_tuna[8] &= ~0x40; //1 break; case SEC_VOLTAGE_18: // horizontal - printk("%s: Polarization=[Horizontal]\n", __FUNCTION__); + dprintk("%s: Polarization=[Horizontal]\n", __FUNCTION__); state->tx_tuna[8] |= 0x40; // 0 break; @@ -344,7 +344,7 @@ static int dst_set_polarization(struct dst_state *state) static int dst_set_freq(struct dst_state *state, u32 freq) { state->frequency = freq; - if (debug > 4) + if (verbose > 4) dprintk("%s: set Frequency %u\n", __FUNCTION__, freq); if (state->dst_type == DST_TYPE_IS_SAT) { @@ -451,7 +451,6 @@ static fe_code_rate_t dst_get_fec(struct dst_state* state) static int dst_set_symbolrate(struct dst_state* state, u32 srate) { - u8 *val; u32 symcalc; u64 sval; @@ -463,7 +462,6 @@ static int dst_set_symbolrate(struct dst_state* state, u32 srate) if (debug > 4) dprintk("%s: set symrate %u\n", __FUNCTION__, srate); srate /= 1000; - val = &state->tx_tuna[0]; if (state->type_flags & DST_TYPE_HAS_SYMDIV) { sval = srate; @@ -474,17 +472,19 @@ static int dst_set_symbolrate(struct dst_state* state, u32 srate) if (debug > 4) dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc); - val[5] = (u8) (symcalc >> 12); - val[6] = (u8) (symcalc >> 4); - val[7] = (u8) (symcalc << 4); + state->tx_tuna[5] = (u8) (symcalc >> 12); + state->tx_tuna[6] = (u8) (symcalc >> 4); + state->tx_tuna[7] = (u8) (symcalc << 4); } else { - val[5] = (u8) (srate >> 16) & 0x7f; - val[6] = (u8) (srate >> 8); - val[7] = (u8) srate; + state->tx_tuna[5] = (u8) (srate >> 16) & 0x7f; + state->tx_tuna[6] = (u8) (srate >> 8); + state->tx_tuna[7] = (u8) srate; + } + state->tx_tuna[8] &= ~0x20; + if (state->type_flags & DST_TYPE_HAS_OBS_REGS) { + if (srate > 8000) + state->tx_tuna[8] |= 0x20; } - val[8] &= ~0x20; - if (srate > 8000) - val[8] |= 0x20; return 0; } -- cgit v0.10.2 From 94b7410c8a2d23fad5937b326a0a9e8c5a876e2d Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:02:59 -0700 Subject: [PATCH] dvb: dst: remove unnecessary code Code Simplification: CA PMT object is not parsed in the driver anymore. Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c index bfaacd5..d2e0b1c 100644 --- a/drivers/media/dvb/bt8xx/dst_ca.c +++ b/drivers/media/dvb/bt8xx/dst_ca.c @@ -260,8 +260,6 @@ static int ca_get_slot_info(struct dst_state *state, struct ca_slot_info *p_ca_s } - - static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, void *arg) { u8 i = 0; @@ -298,10 +296,14 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u32 length) { if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) { - hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */ - hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ - } - else { + hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */ + hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ + } else { + if (length > 247) { + dprintk("%s: Message too long ! *** Bailing Out *** !\n", __FUNCTION__); + return -1; + } + hw_buffer->msg[0] = (length & 0xff) + 7; hw_buffer->msg[1] = 0x40; hw_buffer->msg[2] = 0x03; @@ -309,6 +311,11 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, hw_buffer->msg[4] = 0x03; hw_buffer->msg[5] = length & 0xff; hw_buffer->msg[6] = 0x00; + /* + * Need to compute length for EN50221 section 8.3.2, for the time being + * assuming 8.3.2 is not applicable + */ + memcpy(&hw_buffer->msg[7], &p_ca_message->msg[4], length); } return 0; } @@ -348,15 +355,6 @@ u32 asn_1_decode(u8 *asn_1_array) return length; } -static int init_buffer(u8 *buffer, u32 length) -{ - u32 i; - for (i = 0; i < length; i++) - buffer[i] = 0; - - return 0; -} - static int debug_string(u8 *msg, u32 length, u32 offset) { u32 i; @@ -369,95 +367,22 @@ static int debug_string(u8 *msg, u32 length, u32 offset) return 0; } -static int copy_string(u8 *destination, u8 *source, u32 dest_offset, u32 source_offset, u32 length) -{ - u32 i; - dprintk("%s: Copying [", __FUNCTION__); - for (i = 0; i < length; i++) { - destination[i + dest_offset] = source[i + source_offset]; - dprintk(" %02x", source[i + source_offset]); - } - dprintk("]\n"); - - return i; -} - -static int modify_4_bits(u8 *message, u32 pos) -{ - message[pos] &= 0x0f; - - return 0; -} - - - static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query) { - u32 length = 0, count = 0; - u8 asn_1_words, program_header_length; - u16 program_info_length = 0, es_info_length = 0; - u32 hw_offset = 0, buf_offset = 0, i; - u8 dst_tag_length; + u32 length = 0; + u8 tag_length = 8; length = asn_1_decode(&p_ca_message->msg[3]); dprintk("%s: CA Message length=[%d]\n", __FUNCTION__, length); dprintk("%s: ASN.1 ", __FUNCTION__); - debug_string(&p_ca_message->msg[4], length, 0); // length does not include tag and length + debug_string(&p_ca_message->msg[4], length, 0); /* length is excluding tag & length */ - init_buffer(hw_buffer->msg, length); + memset(hw_buffer->msg, '\0', length); handle_dst_tag(state, p_ca_message, hw_buffer, length); + put_checksum(hw_buffer->msg, hw_buffer->msg[0]); - hw_offset = 7; - asn_1_words = 1; // just a hack to test, should compute this one - buf_offset = 3; - program_header_length = 6; - dst_tag_length = 7; - -// debug_twinhan_ca_params(state, p_ca_message, hw_buffer, reply, query, length, hw_offset, buf_offset); -// dprintk("%s: Program Header(BUF)", __FUNCTION__); -// debug_string(&p_ca_message->msg[4], program_header_length, 0); -// dprintk("%s: Copying Program header\n", __FUNCTION__); - copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + asn_1_words), program_header_length); - buf_offset += program_header_length, hw_offset += program_header_length; - modify_4_bits(hw_buffer->msg, (hw_offset - 2)); - if (state->type_flags & DST_TYPE_HAS_INC_COUNT) { // workaround - dprintk("%s: Probably an ASIC bug !!!\n", __FUNCTION__); - debug_string(hw_buffer->msg, (hw_offset + program_header_length), 0); - hw_buffer->msg[hw_offset - 1] += 1; - } - -// dprintk("%s: Program Header(HW), Count=[%d]", __FUNCTION__, count); -// debug_string(hw_buffer->msg, hw_offset, 0); - - program_info_length = ((program_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset]; - dprintk("%s: Program info length=[%02x]\n", __FUNCTION__, program_info_length); - if (program_info_length) { - count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + 1), (program_info_length + 1) ); // copy next elem, not current - buf_offset += count, hw_offset += count; -// dprintk("%s: Program level ", __FUNCTION__); -// debug_string(hw_buffer->msg, hw_offset, 0); - } - - buf_offset += 1;// hw_offset += 1; - for (i = buf_offset; i < length; i++) { -// dprintk("%s: Stream Header ", __FUNCTION__); - count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, buf_offset, 5); - modify_4_bits(hw_buffer->msg, (hw_offset + 3)); - - hw_offset += 5, buf_offset += 5, i += 4; -// debug_string(hw_buffer->msg, hw_offset, (hw_offset - 5)); - es_info_length = ((es_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset]; - dprintk("%s: ES info length=[%02x]\n", __FUNCTION__, es_info_length); - if (es_info_length) { - // copy descriptors @ STREAM level - dprintk("%s: Descriptors @ STREAM level...!!! \n", __FUNCTION__); - } - - } - hw_buffer->msg[length + dst_tag_length] = dst_check_sum(hw_buffer->msg, (length + dst_tag_length)); -// dprintk("%s: Total length=[%d], Checksum=[%02x]\n", __FUNCTION__, (length + dst_tag_length), hw_buffer->msg[length + dst_tag_length]); - debug_string(hw_buffer->msg, (length + dst_tag_length + 1), 0); // dst tags also - write_to_8820(state, hw_buffer, (length + dst_tag_length + 1), reply); // checksum + debug_string(hw_buffer->msg, (length + tag_length), 0); /* tags too */ + write_to_8820(state, hw_buffer, (length + tag_length), reply); return 0; } -- cgit v0.10.2 From a427de6f72bc0d83ebb1d87f9003c5e1009f21cd Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:03:00 -0700 Subject: [PATCH] dvb: dst: dprrintk cleanup Code Cleanup: o Remove debug noise o Remove debug module parameter debug level is achieved using the verbosity level o Updated to kernel coding style (case labels should not be indented) Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 66e69b8..39835ed 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -1,5 +1,4 @@ /* - Frontend/Card driver for TwinHan DST Frontend Copyright (C) 2003 Jamie Honan Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com) @@ -19,7 +18,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include #include #include @@ -28,31 +26,45 @@ #include #include #include - #include "dvb_frontend.h" #include "dst_priv.h" #include "dst_common.h" - static unsigned int verbose = 1; module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); -static unsigned int debug = 1; -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "debug messages, default is 0 (yes)"); - static unsigned int dst_addons; module_param(dst_addons, int, 0644); MODULE_PARM_DESC(dst_addons, "CA daughterboard, default is 0 (No addons)"); -#define dprintk if (debug) printk - -#define HAS_LOCK 1 -#define ATTEMPT_TUNE 2 -#define HAS_POWER 4 - -static void dst_packsize(struct dst_state* state, int psize) +#define HAS_LOCK 1 +#define ATTEMPT_TUNE 2 +#define HAS_POWER 4 + +#define DST_ERROR 0 +#define DST_NOTICE 1 +#define DST_INFO 2 +#define DST_DEBUG 3 + +#define dprintk(x, y, z, format, arg...) do { \ + if (z) { \ + if ((x > DST_ERROR) && (x > y)) \ + printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_NOTICE) && (x > y)) \ + printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_INFO) && (x > y)) \ + printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_DEBUG) && (x > y)) \ + printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg); \ + } else { \ + if (x > y) \ + printk(format, ##arg); \ + } \ +} while(0) + + +static void dst_packsize(struct dst_state *state, int psize) { union dst_gpio_packet bits; @@ -60,7 +72,7 @@ static void dst_packsize(struct dst_state* state, int psize) bt878_device_control(state->bt, DST_IG_TS, &bits); } -int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay) +int dst_gpio_outb(struct dst_state *state, u32 mask, u32 enbb, u32 outhigh, int delay) { union dst_gpio_packet enb; union dst_gpio_packet bits; @@ -68,63 +80,55 @@ int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int enb.enb.mask = mask; enb.enb.enable = enbb; - if (verbose > 4) - dprintk("%s: mask=[%04x], enbb=[%04x], outhigh=[%04x]\n", __FUNCTION__, mask, enbb, outhigh); + dprintk(verbose, DST_INFO, 1, "mask=[%04x], enbb=[%04x], outhigh=[%04x]", mask, enbb, outhigh); if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) { - dprintk("%s: dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)\n", __FUNCTION__, err, mask, enbb); + dprintk(verbose, DST_INFO, 1, "dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)", err, mask, enbb); return -EREMOTEIO; } udelay(1000); /* because complete disabling means no output, no need to do output packet */ if (enbb == 0) return 0; - if (delay) msleep(10); - bits.outp.mask = enbb; bits.outp.highvals = outhigh; - if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) { - dprintk("%s: dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)\n", __FUNCTION__, err, enbb, outhigh); + dprintk(verbose, DST_INFO, 1, "dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)", err, enbb, outhigh); return -EREMOTEIO; } + return 0; } EXPORT_SYMBOL(dst_gpio_outb); -int dst_gpio_inb(struct dst_state *state, u8 * result) +int dst_gpio_inb(struct dst_state *state, u8 *result) { union dst_gpio_packet rd_packet; int err; *result = 0; - if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) { - dprintk("%s: dst_gpio_inb error (err == %i)\n", __FUNCTION__, err); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb error (err == %i)\n", err); return -EREMOTEIO; } - *result = (u8) rd_packet.rd.value; + return 0; } EXPORT_SYMBOL(dst_gpio_inb); int rdc_reset_state(struct dst_state *state) { - if (verbose > 1) - dprintk("%s: Resetting state machine\n", __FUNCTION__); - + dprintk(verbose, DST_INFO, 1, "Resetting state machine"); if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } - msleep(10); - if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); msleep(10); return -1; } @@ -135,16 +139,14 @@ EXPORT_SYMBOL(rdc_reset_state); int rdc_8820_reset(struct dst_state *state) { - if (verbose > 1) - dprintk("%s: Resetting DST\n", __FUNCTION__); - + dprintk(verbose, DST_DEBUG, 1, "Resetting DST"); if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } udelay(1000); if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } @@ -155,10 +157,11 @@ EXPORT_SYMBOL(rdc_8820_reset); int dst_pio_enable(struct dst_state *state) { if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } udelay(1000); + return 0; } EXPORT_SYMBOL(dst_pio_enable); @@ -166,7 +169,7 @@ EXPORT_SYMBOL(dst_pio_enable); int dst_pio_disable(struct dst_state *state) { if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } if (state->type_flags & DST_TYPE_HAS_FW_1) @@ -183,19 +186,16 @@ int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode) for (i = 0; i < 200; i++) { if (dst_gpio_inb(state, &reply) < 0) { - dprintk("%s: dst_gpio_inb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb ERROR !"); return -1; } - if ((reply & RDC_8820_PIO_0_ENABLE) == 0) { - if (verbose > 4) - dprintk("%s: dst wait ready after %d\n", __FUNCTION__, i); + dprintk(verbose, DST_INFO, 1, "dst wait ready after %d", i); return 1; } msleep(10); } - if (verbose > 1) - dprintk("%s: dst wait NOT ready after %d\n", __FUNCTION__, i); + dprintk(verbose, DST_NOTICE, 1, "dst wait NOT ready after %d", i); return 0; } @@ -203,7 +203,7 @@ EXPORT_SYMBOL(dst_wait_dst_ready); int dst_error_recovery(struct dst_state *state) { - dprintk("%s: Trying to return from previous errors...\n", __FUNCTION__); + dprintk(verbose, DST_NOTICE, 1, "Trying to return from previous errors."); dst_pio_disable(state); msleep(10); dst_pio_enable(state); @@ -215,7 +215,7 @@ EXPORT_SYMBOL(dst_error_recovery); int dst_error_bailout(struct dst_state *state) { - dprintk("%s: Trying to bailout from previous error...\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Trying to bailout from previous error."); rdc_8820_reset(state); dst_pio_disable(state); msleep(10); @@ -224,17 +224,15 @@ int dst_error_bailout(struct dst_state *state) } EXPORT_SYMBOL(dst_error_bailout); - -int dst_comm_init(struct dst_state* state) +int dst_comm_init(struct dst_state *state) { - if (verbose > 1) - dprintk ("%s: Initializing DST..\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Initializing DST."); if ((dst_pio_enable(state)) < 0) { - dprintk("%s: PIO Enable Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "PIO Enable Failed"); return -1; } if ((rdc_reset_state(state)) < 0) { - dprintk("%s: RDC 8820 State RESET Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "RDC 8820 State RESET Failed."); return -1; } if (state->type_flags & DST_TYPE_HAS_FW_1) @@ -246,36 +244,33 @@ int dst_comm_init(struct dst_state* state) } EXPORT_SYMBOL(dst_comm_init); - int write_dst(struct dst_state *state, u8 *data, u8 len) { struct i2c_msg msg = { - .addr = state->config->demod_address,.flags = 0,.buf = data,.len = len + .addr = state->config->demod_address, + .flags = 0, + .buf = data, + .len = len }; int err; - int cnt; - if (debug && (verbose > 4)) { - u8 i; - if (verbose > 4) { - dprintk("%s writing [ ", __FUNCTION__); - for (i = 0; i < len; i++) - dprintk("%02x ", data[i]); - dprintk("]\n"); - } - } + u8 cnt, i; + + dprintk(verbose, DST_NOTICE, 0, "writing [ "); + for (i = 0; i < len; i++) + dprintk(verbose, DST_NOTICE, 0, "%02x ", data[i]); + dprintk(verbose, DST_NOTICE, 0, "]\n"); + for (cnt = 0; cnt < 2; cnt++) { if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { - dprintk("%s: _write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, data[0]); + dprintk(verbose, DST_INFO, 1, "_write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, data[0]); dst_error_recovery(state); continue; } else break; } - if (cnt >= 2) { - if (verbose > 1) - printk("%s: RDC 8820 RESET...\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET"); dst_error_bailout(state); return -1; @@ -285,36 +280,37 @@ int write_dst(struct dst_state *state, u8 *data, u8 len) } EXPORT_SYMBOL(write_dst); -int read_dst(struct dst_state *state, u8 * ret, u8 len) +int read_dst(struct dst_state *state, u8 *ret, u8 len) { - struct i2c_msg msg = {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = ret,.len = len }; + struct i2c_msg msg = { + .addr = state->config->demod_address, + .flags = I2C_M_RD, + .buf = ret, + .len = len + }; + int err; int cnt; for (cnt = 0; cnt < 2; cnt++) { if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { - - dprintk("%s: read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, ret[0]); + dprintk(verbose, DST_INFO, 1, "read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, ret[0]); dst_error_recovery(state); - continue; } else break; } if (cnt >= 2) { - if (verbose > 1) - printk("%s: RDC 8820 RESET...\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET"); dst_error_bailout(state); return -1; } - if (debug && (verbose > 4)) { - dprintk("%s reply is 0x%x\n", __FUNCTION__, ret[0]); - for (err = 1; err < len; err++) - dprintk(" 0x%x", ret[err]); - if (err > 1) - dprintk("\n"); - } + dprintk(verbose, DST_DEBUG, 1, "reply is 0x%x", ret[0]); + for (err = 1; err < len; err++) + dprintk(verbose, DST_DEBUG, 0, " 0x%x", ret[err]); + if (err > 1) + dprintk(verbose, DST_DEBUG, 0, "\n"); return 0; } @@ -323,19 +319,16 @@ EXPORT_SYMBOL(read_dst); static int dst_set_polarization(struct dst_state *state) { switch (state->voltage) { - case SEC_VOLTAGE_13: // vertical - dprintk("%s: Polarization=[Vertical]\n", __FUNCTION__); - state->tx_tuna[8] &= ~0x40; //1 - break; - - case SEC_VOLTAGE_18: // horizontal - dprintk("%s: Polarization=[Horizontal]\n", __FUNCTION__); - state->tx_tuna[8] |= 0x40; // 0 - break; - - case SEC_VOLTAGE_OFF: - - break; + case SEC_VOLTAGE_13: /* Vertical */ + dprintk(verbose, DST_INFO, 1, "Polarization=[Vertical]"); + state->tx_tuna[8] &= ~0x40; + break; + case SEC_VOLTAGE_18: /* Horizontal */ + dprintk(verbose, DST_INFO, 1, "Polarization=[Horizontal]"); + state->tx_tuna[8] |= 0x40; + break; + case SEC_VOLTAGE_OFF: + break; } return 0; @@ -344,14 +337,12 @@ static int dst_set_polarization(struct dst_state *state) static int dst_set_freq(struct dst_state *state, u32 freq) { state->frequency = freq; - if (verbose > 4) - dprintk("%s: set Frequency %u\n", __FUNCTION__, freq); + dprintk(verbose, DST_INFO, 1, "set Frequency %u", freq); if (state->dst_type == DST_TYPE_IS_SAT) { freq = freq / 1000; if (freq < 950 || freq > 2150) return -EINVAL; - state->tx_tuna[2] = (freq >> 8); state->tx_tuna[3] = (u8) freq; state->tx_tuna[4] = 0x01; @@ -360,27 +351,24 @@ static int dst_set_freq(struct dst_state *state, u32 freq) if (freq < 1531) state->tx_tuna[8] |= 0x04; } - } else if (state->dst_type == DST_TYPE_IS_TERR) { freq = freq / 1000; if (freq < 137000 || freq > 858000) return -EINVAL; - state->tx_tuna[2] = (freq >> 16) & 0xff; state->tx_tuna[3] = (freq >> 8) & 0xff; state->tx_tuna[4] = (u8) freq; - } else if (state->dst_type == DST_TYPE_IS_CABLE) { state->tx_tuna[2] = (freq >> 16) & 0xff; state->tx_tuna[3] = (freq >> 8) & 0xff; state->tx_tuna[4] = (u8) freq; - } else return -EINVAL; + return 0; } -static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) +static int dst_set_bandwidth(struct dst_state *state, fe_bandwidth_t bandwidth) { state->bandwidth = bandwidth; @@ -388,90 +376,82 @@ static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) return 0; switch (bandwidth) { - case BANDWIDTH_6_MHZ: - if (state->dst_hw_cap & DST_TYPE_HAS_CA) - state->tx_tuna[7] = 0x06; - else { - state->tx_tuna[6] = 0x06; - state->tx_tuna[7] = 0x00; - } - break; - - case BANDWIDTH_7_MHZ: - if (state->dst_hw_cap & DST_TYPE_HAS_CA) - state->tx_tuna[7] = 0x07; - else { - state->tx_tuna[6] = 0x07; - state->tx_tuna[7] = 0x00; - } - break; - - case BANDWIDTH_8_MHZ: - if (state->dst_hw_cap & DST_TYPE_HAS_CA) - state->tx_tuna[7] = 0x08; - else { - state->tx_tuna[6] = 0x08; - state->tx_tuna[7] = 0x00; - } - break; - - default: - return -EINVAL; + case BANDWIDTH_6_MHZ: + if (state->dst_hw_cap & DST_TYPE_HAS_CA) + state->tx_tuna[7] = 0x06; + else { + state->tx_tuna[6] = 0x06; + state->tx_tuna[7] = 0x00; + } + break; + case BANDWIDTH_7_MHZ: + if (state->dst_hw_cap & DST_TYPE_HAS_CA) + state->tx_tuna[7] = 0x07; + else { + state->tx_tuna[6] = 0x07; + state->tx_tuna[7] = 0x00; + } + break; + case BANDWIDTH_8_MHZ: + if (state->dst_hw_cap & DST_TYPE_HAS_CA) + state->tx_tuna[7] = 0x08; + else { + state->tx_tuna[6] = 0x08; + state->tx_tuna[7] = 0x00; + } + break; + default: + return -EINVAL; } + return 0; } -static int dst_set_inversion(struct dst_state* state, fe_spectral_inversion_t inversion) +static int dst_set_inversion(struct dst_state *state, fe_spectral_inversion_t inversion) { state->inversion = inversion; switch (inversion) { - case INVERSION_OFF: // Inversion = Normal - state->tx_tuna[8] &= ~0x80; - break; - - case INVERSION_ON: - state->tx_tuna[8] |= 0x80; - break; - default: - return -EINVAL; + case INVERSION_OFF: /* Inversion = Normal */ + state->tx_tuna[8] &= ~0x80; + break; + case INVERSION_ON: + state->tx_tuna[8] |= 0x80; + break; + default: + return -EINVAL; } + return 0; } -static int dst_set_fec(struct dst_state* state, fe_code_rate_t fec) +static int dst_set_fec(struct dst_state *state, fe_code_rate_t fec) { state->fec = fec; return 0; } -static fe_code_rate_t dst_get_fec(struct dst_state* state) +static fe_code_rate_t dst_get_fec(struct dst_state *state) { return state->fec; } -static int dst_set_symbolrate(struct dst_state* state, u32 srate) +static int dst_set_symbolrate(struct dst_state *state, u32 srate) { u32 symcalc; u64 sval; state->symbol_rate = srate; - if (state->dst_type == DST_TYPE_IS_TERR) { return 0; } - if (debug > 4) - dprintk("%s: set symrate %u\n", __FUNCTION__, srate); + dprintk(verbose, DST_INFO, 1, "set symrate %u", srate); srate /= 1000; - if (state->type_flags & DST_TYPE_HAS_SYMDIV) { sval = srate; sval <<= 20; do_div(sval, 88000); symcalc = (u32) sval; - - if (debug > 4) - dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc); - + dprintk(verbose, DST_INFO, 1, "set symcalc %u", symcalc); state->tx_tuna[5] = (u8) (symcalc >> 12); state->tx_tuna[6] = (u8) (symcalc >> 4); state->tx_tuna[7] = (u8) (symcalc << 4); @@ -496,32 +476,27 @@ static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulatio state->modulation = modulation; switch (modulation) { - case QAM_16: - state->tx_tuna[8] = 0x10; - break; - - case QAM_32: - state->tx_tuna[8] = 0x20; - break; - - case QAM_64: - state->tx_tuna[8] = 0x40; - break; - - case QAM_128: - state->tx_tuna[8] = 0x80; - break; - - case QAM_256: - state->tx_tuna[8] = 0x00; - break; - - case QPSK: - case QAM_AUTO: - case VSB_8: - case VSB_16: - default: - return -EINVAL; + case QAM_16: + state->tx_tuna[8] = 0x10; + break; + case QAM_32: + state->tx_tuna[8] = 0x20; + break; + case QAM_64: + state->tx_tuna[8] = 0x40; + break; + case QAM_128: + state->tx_tuna[8] = 0x80; + break; + case QAM_256: + state->tx_tuna[8] = 0x00; + break; + case QPSK: + case QAM_AUTO: + case VSB_8: + case VSB_16: + default: + return -EINVAL; } @@ -534,7 +509,7 @@ static fe_modulation_t dst_get_modulation(struct dst_state *state) } -u8 dst_check_sum(u8 * buf, u32 len) +u8 dst_check_sum(u8 *buf, u32 len) { u32 i; u8 val = 0; @@ -549,26 +524,24 @@ EXPORT_SYMBOL(dst_check_sum); static void dst_type_flags_print(u32 type_flags) { - printk("DST type flags :"); + dprintk(verbose, DST_ERROR, 0, "DST type flags :"); if (type_flags & DST_TYPE_HAS_NEWTUNE) - printk(" 0x%x newtuner", DST_TYPE_HAS_NEWTUNE); + dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner", DST_TYPE_HAS_NEWTUNE); if (type_flags & DST_TYPE_HAS_TS204) - printk(" 0x%x ts204", DST_TYPE_HAS_TS204); + dprintk(verbose, DST_ERROR, 0, " 0x%x ts204", DST_TYPE_HAS_TS204); if (type_flags & DST_TYPE_HAS_SYMDIV) - printk(" 0x%x symdiv", DST_TYPE_HAS_SYMDIV); + dprintk(verbose, DST_ERROR, 0, " 0x%x symdiv", DST_TYPE_HAS_SYMDIV); if (type_flags & DST_TYPE_HAS_FW_1) - printk(" 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); + dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); if (type_flags & DST_TYPE_HAS_FW_2) - printk(" 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); + dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); if (type_flags & DST_TYPE_HAS_FW_3) - printk(" 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); -// if ((type_flags & DST_TYPE_HAS_FW_BUILD) && new_fw) - - printk("\n"); + dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); + dprintk(verbose, DST_ERROR, 0, "\n"); } -static int dst_type_print (u8 type) +static int dst_type_print(u8 type) { char *otype; switch (type) { @@ -585,10 +558,10 @@ static int dst_type_print (u8 type) break; default: - printk("%s: invalid dst type %d\n", __FUNCTION__, type); + dprintk(verbose, DST_INFO, 1, "invalid dst type %d", type); return -EINVAL; } - printk("DST type : %s\n", otype); + dprintk(verbose, DST_INFO, 1, "DST type: %s", otype); return 0; } @@ -772,53 +745,45 @@ static int dst_get_device_id(struct dst_state *state) if (write_dst(state, device_type, FIXED_COMM)) return -1; /* Write failed */ - if ((dst_pio_disable(state)) < 0) return -1; - if (read_dst(state, &reply, GET_ACK)) return -1; /* Read failure */ - if (reply != ACK) { - dprintk("%s: Write not Acknowledged! [Reply=0x%02x]\n", __FUNCTION__, reply); + dprintk(verbose, DST_INFO, 1, "Write not Acknowledged! [Reply=0x%02x]", reply); return -1; /* Unack'd write */ } - if (!dst_wait_dst_ready(state, DEVICE_INIT)) return -1; /* DST not ready yet */ - if (read_dst(state, state->rxbuffer, FIXED_COMM)) return -1; dst_pio_disable(state); - if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { - dprintk("%s: Checksum failure! \n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Checksum failure!"); return -1; /* Checksum failure */ } - state->rxbuffer[7] = '\0'; - for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE (dst_tlist); i++, p_dst_type++) { + for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE(dst_tlist); i++, p_dst_type++) { if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->device_id))) { use_type_flags = p_dst_type->type_flags; use_dst_type = p_dst_type->dst_type; /* Card capabilities */ state->dst_hw_cap = p_dst_type->dst_feature; - printk ("%s: Recognise [%s]\n", __FUNCTION__, p_dst_type->device_id); + dprintk(verbose, DST_ERROR, 1, "Recognise [%s]\n", p_dst_type->device_id); break; } } if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) { - printk("%s: Unable to recognize %s or %s\n", __FUNCTION__, &state->rxbuffer[0], &state->rxbuffer[1]); - printk("%s: please email linux-dvb@linuxtv.org with this type in\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "Unable to recognize %s or %s", &state->rxbuffer[0], &state->rxbuffer[1]); + dprintk(verbose, DST_ERROR, 1, "please email linux-dvb@linuxtv.org with this type in"); use_dst_type = DST_TYPE_IS_SAT; use_type_flags = DST_TYPE_HAS_SYMDIV; } - dst_type_print(use_dst_type); state->type_flags = use_type_flags; state->dst_type = use_dst_type; @@ -834,7 +799,7 @@ static int dst_get_device_id(struct dst_state *state) static int dst_probe(struct dst_state *state) { if ((rdc_8820_reset(state)) < 0) { - dprintk("%s: RDC 8820 RESET Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed."); return -1; } if (dst_addons & DST_TYPE_HAS_CA) @@ -843,80 +808,69 @@ static int dst_probe(struct dst_state *state) msleep(100); if ((dst_comm_init(state)) < 0) { - dprintk("%s: DST Initialization Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "DST Initialization Failed."); return -1; } msleep(100); if (dst_get_device_id(state) < 0) { - dprintk("%s: unknown device.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "unknown device."); return -1; } return 0; } -int dst_command(struct dst_state* state, u8 * data, u8 len) +int dst_command(struct dst_state *state, u8 *data, u8 len) { u8 reply; if ((dst_comm_init(state)) < 0) { - dprintk("%s: DST Communication Initialization Failed.\n", __FUNCTION__); + dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed."); return -1; } - if (write_dst(state, data, len)) { - if (verbose > 1) - dprintk("%s: Tring to recover.. \n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Tring to recover.. "); if ((dst_error_recovery(state)) < 0) { - dprintk("%s: Recovery Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "Recovery Failed."); return -1; } return -1; } if ((dst_pio_disable(state)) < 0) { - dprintk("%s: PIO Disable Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "PIO Disable Failed."); return -1; } if (state->type_flags & DST_TYPE_HAS_FW_1) udelay(3000); - if (read_dst(state, &reply, GET_ACK)) { - if (verbose > 1) - dprintk("%s: Trying to recover.. \n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); if ((dst_error_recovery(state)) < 0) { - dprintk("%s: Recovery Failed.\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Recovery Failed."); return -1; } return -1; } - if (reply != ACK) { - dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); + dprintk(verbose, DST_INFO, 1, "write not acknowledged 0x%02x ", reply); return -1; } if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) return 0; - -// udelay(3000); if (state->type_flags & DST_TYPE_HAS_FW_1) udelay(3000); else udelay(2000); - if (!dst_wait_dst_ready(state, NO_DELAY)) return -1; - if (read_dst(state, state->rxbuffer, FIXED_COMM)) { - if (verbose > 1) - dprintk("%s: Trying to recover.. \n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); if ((dst_error_recovery(state)) < 0) { - dprintk("%s: Recovery failed.\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Recovery failed."); return -1; } return -1; } - if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { - dprintk("%s: checksum failure\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "checksum failure"); return -1; } @@ -924,7 +878,7 @@ int dst_command(struct dst_state* state, u8 * data, u8 len) } EXPORT_SYMBOL(dst_command); -static int dst_get_signal(struct dst_state* state) +static int dst_get_signal(struct dst_state *state) { int retval; u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; @@ -955,13 +909,12 @@ static int dst_get_signal(struct dst_state* state) return 0; } -static int dst_tone_power_cmd(struct dst_state* state) +static int dst_tone_power_cmd(struct dst_state *state) { u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 }; if (state->dst_type == DST_TYPE_IS_TERR) return 0; - paket[4] = state->tx_tuna[4]; paket[2] = state->tx_tuna[2]; paket[3] = state->tx_tuna[3]; @@ -971,61 +924,53 @@ static int dst_tone_power_cmd(struct dst_state* state) return 0; } -static int dst_get_tuna(struct dst_state* state) +static int dst_get_tuna(struct dst_state *state) { int retval; if ((state->diseq_flags & ATTEMPT_TUNE) == 0) return 0; - state->diseq_flags &= ~(HAS_LOCK); if (!dst_wait_dst_ready(state, NO_DELAY)) return 0; - - if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { + if (state->type_flags & DST_TYPE_HAS_NEWTUNE) /* how to get variable length reply ???? */ retval = read_dst(state, state->rx_tuna, 10); - } else { + else retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM); - } - if (retval < 0) { - dprintk("%s: read not successful\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "read not successful"); return 0; } - if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { - dprintk("%s: checksum failure?\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "checksum failure ? "); return 0; } } else { if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) { - dprintk("%s: checksum failure?\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "checksum failure? "); return 0; } } if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0) return 0; state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3]; - state->decode_lock = 1; state->diseq_flags |= HAS_LOCK; return 1; } -static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage); +static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage); -static int dst_write_tuna(struct dvb_frontend* fe) +static int dst_write_tuna(struct dvb_frontend *fe) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; int retval; u8 reply; - if (debug > 4) - dprintk("%s: type_flags 0x%x \n", __FUNCTION__, state->type_flags); - + dprintk(verbose, DST_INFO, 1, "type_flags 0x%x ", state->type_flags); state->decode_freq = 0; state->decode_lock = state->decode_strength = state->decode_snr = 0; if (state->dst_type == DST_TYPE_IS_SAT) { @@ -1035,35 +980,31 @@ static int dst_write_tuna(struct dvb_frontend* fe) state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); if ((dst_comm_init(state)) < 0) { - dprintk("%s: DST Communication initialization failed.\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed."); return -1; } - if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9); retval = write_dst(state, &state->tx_tuna[0], 10); - } else { state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7); retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM); } if (retval < 0) { dst_pio_disable(state); - dprintk("%s: write not successful\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "write not successful"); return retval; } - if ((dst_pio_disable(state)) < 0) { - dprintk("%s: DST PIO disable failed !\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !"); return -1; } - if ((read_dst(state, &reply, GET_ACK) < 0)) { - dprintk("%s: read verify not successful.\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "read verify not successful."); return -1; } if (reply != ACK) { - dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); + dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply); return 0; } state->diseq_flags |= ATTEMPT_TUNE; @@ -1085,14 +1026,13 @@ static int dst_write_tuna(struct dvb_frontend* fe) * Diseqc 4 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0 */ -static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd) +static int dst_set_diseqc(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec }; if (state->dst_type != DST_TYPE_IS_SAT) return 0; - if (cmd->msg_len == 0 || cmd->msg_len > 4) return -EINVAL; memcpy(&paket[3], cmd->msg, cmd->msg_len); @@ -1101,65 +1041,61 @@ static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* return 0; } -static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) +static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) { int need_cmd; - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; state->voltage = voltage; - if (state->dst_type != DST_TYPE_IS_SAT) return 0; need_cmd = 0; - switch (voltage) { - case SEC_VOLTAGE_13: - case SEC_VOLTAGE_18: - if ((state->diseq_flags & HAS_POWER) == 0) - need_cmd = 1; - state->diseq_flags |= HAS_POWER; - state->tx_tuna[4] = 0x01; - break; - case SEC_VOLTAGE_OFF: + switch (voltage) { + case SEC_VOLTAGE_13: + case SEC_VOLTAGE_18: + if ((state->diseq_flags & HAS_POWER) == 0) need_cmd = 1; - state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); - state->tx_tuna[4] = 0x00; - break; - - default: - return -EINVAL; + state->diseq_flags |= HAS_POWER; + state->tx_tuna[4] = 0x01; + break; + case SEC_VOLTAGE_OFF: + need_cmd = 1; + state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); + state->tx_tuna[4] = 0x00; + break; + default: + return -EINVAL; } + if (need_cmd) dst_tone_power_cmd(state); return 0; } -static int dst_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) +static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; state->tone = tone; - if (state->dst_type != DST_TYPE_IS_SAT) return 0; switch (tone) { - case SEC_TONE_OFF: - if (state->type_flags & DST_TYPE_HAS_OBS_REGS) - state->tx_tuna[2] = 0x00; - else - state->tx_tuna[2] = 0xff; - - break; - - case SEC_TONE_ON: - state->tx_tuna[2] = 0x02; - break; + case SEC_TONE_OFF: + if (state->type_flags & DST_TYPE_HAS_OBS_REGS) + state->tx_tuna[2] = 0x00; + else + state->tx_tuna[2] = 0xff; + break; - default: - return -EINVAL; + case SEC_TONE_ON: + state->tx_tuna[2] = 0x02; + break; + default: + return -EINVAL; } dst_tone_power_cmd(state); @@ -1172,16 +1108,14 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd) if (state->dst_type != DST_TYPE_IS_SAT) return 0; - state->minicmd = minicmd; - switch (minicmd) { - case SEC_MINI_A: - state->tx_tuna[3] = 0x02; - break; - case SEC_MINI_B: - state->tx_tuna[3] = 0xff; - break; + case SEC_MINI_A: + state->tx_tuna[3] = 0x02; + break; + case SEC_MINI_B: + state->tx_tuna[3] = 0xff; + break; } dst_tone_power_cmd(state); @@ -1189,42 +1123,37 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd) } -static int dst_init(struct dvb_frontend* fe) +static int dst_init(struct dvb_frontend *fe) { - struct dst_state* state = fe->demodulator_priv; - static u8 ini_satci_tuna[] = { 9, 0, 3, 0xb6, 1, 0, 0x73, 0x21, 0, 0 }; - static u8 ini_satfta_tuna[] = { 0, 0, 3, 0xb6, 1, 0x55, 0xbd, 0x50, 0, 0 }; - static u8 ini_tvfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; - static u8 ini_tvci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; - static u8 ini_cabfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; - static u8 ini_cabci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; -// state->inversion = INVERSION_ON; + struct dst_state *state = fe->demodulator_priv; + + static u8 sat_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x00, 0x73, 0x21, 0x00, 0x00 }; + static u8 sat_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x55, 0xbd, 0x50, 0x00, 0x00 }; + static u8 ter_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; + static u8 ter_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; + static u8 cab_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; + static u8 cab_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; + state->inversion = INVERSION_OFF; state->voltage = SEC_VOLTAGE_13; state->tone = SEC_TONE_OFF; - state->symbol_rate = 29473000; - state->fec = FEC_AUTO; state->diseq_flags = 0; state->k22 = 0x02; state->bandwidth = BANDWIDTH_7_MHZ; state->cur_jiff = jiffies; - if (state->dst_type == DST_TYPE_IS_SAT) { - state->frequency = 950000; - memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_satci_tuna : ini_satfta_tuna), sizeof(ini_satfta_tuna)); - } else if (state->dst_type == DST_TYPE_IS_TERR) { - state->frequency = 137000000; - memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_tvci_tuna : ini_tvfta_tuna), sizeof(ini_tvfta_tuna)); - } else if (state->dst_type == DST_TYPE_IS_CABLE) { - state->frequency = 51000000; - memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_cabci_tuna : ini_cabfta_tuna), sizeof(ini_cabfta_tuna)); - } + if (state->dst_type == DST_TYPE_IS_SAT) + memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? sat_tuna_188 : sat_tuna_204), sizeof (sat_tuna_204)); + else if (state->dst_type == DST_TYPE_IS_TERR) + memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ter_tuna_188 : ter_tuna_204), sizeof (ter_tuna_204)); + else if (state->dst_type == DST_TYPE_IS_CABLE) + memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? cab_tuna_188 : cab_tuna_204), sizeof (cab_tuna_204)); return 0; } -static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status) +static int dst_read_status(struct dvb_frontend *fe, fe_status_t *status) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; *status = 0; if (state->diseq_flags & HAS_LOCK) { @@ -1236,9 +1165,9 @@ static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status) return 0; } -static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength) +static int dst_read_signal_strength(struct dvb_frontend *fe, u16 *strength) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; dst_get_signal(state); *strength = state->decode_strength; @@ -1246,9 +1175,9 @@ static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength) return 0; } -static int dst_read_snr(struct dvb_frontend* fe, u16* snr) +static int dst_read_snr(struct dvb_frontend *fe, u16 *snr) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; dst_get_signal(state); *snr = state->decode_snr; @@ -1256,28 +1185,24 @@ static int dst_read_snr(struct dvb_frontend* fe, u16* snr) return 0; } -static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) +static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; dst_set_freq(state, p->frequency); - if (verbose > 4) - dprintk("Set Frequency=[%d]\n", p->frequency); + dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency); -// dst_set_inversion(state, p->inversion); if (state->dst_type == DST_TYPE_IS_SAT) { if (state->type_flags & DST_TYPE_HAS_OBS_REGS) dst_set_inversion(state, p->inversion); - dst_set_fec(state, p->u.qpsk.fec_inner); dst_set_symbolrate(state, p->u.qpsk.symbol_rate); dst_set_polarization(state); - if (verbose > 4) - dprintk("Set Symbolrate=[%d]\n", p->u.qpsk.symbol_rate); + dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->u.qpsk.symbol_rate); - } else if (state->dst_type == DST_TYPE_IS_TERR) { + } else if (state->dst_type == DST_TYPE_IS_TERR) dst_set_bandwidth(state, p->u.ofdm.bandwidth); - } else if (state->dst_type == DST_TYPE_IS_CABLE) { + else if (state->dst_type == DST_TYPE_IS_CABLE) { dst_set_fec(state, p->u.qam.fec_inner); dst_set_symbolrate(state, p->u.qam.symbol_rate); dst_set_modulation(state, p->u.qam.modulation); @@ -1287,16 +1212,14 @@ static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet return 0; } -static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) +static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; p->frequency = state->decode_freq; -// p->inversion = state->inversion; if (state->dst_type == DST_TYPE_IS_SAT) { if (state->type_flags & DST_TYPE_HAS_OBS_REGS) p->inversion = state->inversion; - p->u.qpsk.symbol_rate = state->symbol_rate; p->u.qpsk.fec_inner = dst_get_fec(state); } else if (state->dst_type == DST_TYPE_IS_TERR) { @@ -1304,16 +1227,15 @@ static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet } else if (state->dst_type == DST_TYPE_IS_CABLE) { p->u.qam.symbol_rate = state->symbol_rate; p->u.qam.fec_inner = dst_get_fec(state); -// p->u.qam.modulation = QAM_AUTO; p->u.qam.modulation = dst_get_modulation(state); } return 0; } -static void dst_release(struct dvb_frontend* fe) +static void dst_release(struct dvb_frontend *fe) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; kfree(state); } @@ -1321,9 +1243,8 @@ static struct dvb_frontend_ops dst_dvbt_ops; static struct dvb_frontend_ops dst_dvbs_ops; static struct dvb_frontend_ops dst_dvbc_ops; -struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) +struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) { - /* check if the ASIC is there */ if (dst_probe(state) < 0) { if (state) @@ -1336,17 +1257,14 @@ struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad case DST_TYPE_IS_TERR: memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops)); break; - case DST_TYPE_IS_CABLE: memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops)); break; - case DST_TYPE_IS_SAT: memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops)); break; - default: - printk("%s: unknown DST type. please report to the LinuxTV.org DVB mailinglist.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist."); if (state) kfree(state); @@ -1374,12 +1292,9 @@ static struct dvb_frontend_ops dst_dvbt_ops = { }, .release = dst_release, - .init = dst_init, - .set_frontend = dst_set_frontend, .get_frontend = dst_get_frontend, - .read_status = dst_read_status, .read_signal_strength = dst_read_signal_strength, .read_snr = dst_read_snr, @@ -1401,16 +1316,12 @@ static struct dvb_frontend_ops dst_dvbs_ops = { }, .release = dst_release, - .init = dst_init, - .set_frontend = dst_set_frontend, .get_frontend = dst_get_frontend, - .read_status = dst_read_status, .read_signal_strength = dst_read_signal_strength, .read_snr = dst_read_snr, - .diseqc_send_burst = dst_send_burst, .diseqc_send_master_cmd = dst_set_diseqc, .set_voltage = dst_set_voltage, @@ -1432,18 +1343,14 @@ static struct dvb_frontend_ops dst_dvbc_ops = { }, .release = dst_release, - .init = dst_init, - .set_frontend = dst_set_frontend, .get_frontend = dst_get_frontend, - .read_status = dst_read_status, .read_signal_strength = dst_read_signal_strength, .read_snr = dst_read_snr, }; - MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver"); MODULE_AUTHOR("Jamie Honan, Manu Abraham"); MODULE_LICENSE("GPL"); diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c index d2e0b1c..6776a59 100644 --- a/drivers/media/dvb/bt8xx/dst_ca.c +++ b/drivers/media/dvb/bt8xx/dst_ca.c @@ -18,30 +18,42 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - #include #include #include #include - #include #include "dvbdev.h" #include "dvb_frontend.h" - #include "dst_ca.h" #include "dst_common.h" +#define DST_CA_ERROR 0 +#define DST_CA_NOTICE 1 +#define DST_CA_INFO 2 +#define DST_CA_DEBUG 3 + +#define dprintk(x, y, z, format, arg...) do { \ + if (z) { \ + if ((x > DST_CA_ERROR) && (x > y)) \ + printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_CA_NOTICE) && (x > y)) \ + printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_CA_INFO) && (x > y)) \ + printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_CA_DEBUG) && (x > y)) \ + printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg); \ + } else { \ + if (x > y) \ + printk(format, ## arg); \ + } \ +} while(0) + + static unsigned int verbose = 5; module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); -static unsigned int debug = 1; -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "debug messages, default is 1 (yes)"); - -#define dprintk if (debug) printk - /* Need some more work */ static int ca_set_slot_descr(void) { @@ -61,27 +73,20 @@ static int put_checksum(u8 *check_string, int length) { u8 i = 0, checksum = 0; - if (verbose > 3) { - dprintk("%s: ========================= Checksum calculation ===========================\n", __FUNCTION__); - dprintk("%s: String Length=[0x%02x]\n", __FUNCTION__, length); + dprintk(verbose, DST_CA_DEBUG, 1, " ========================= Checksum calculation ==========================="); + dprintk(verbose, DST_CA_DEBUG, 1, " String Length=[0x%02x]", length); + dprintk(verbose, DST_CA_DEBUG, 1, " String=["); - dprintk("%s: String=[", __FUNCTION__); - } while (i < length) { - if (verbose > 3) - dprintk(" %02x", check_string[i]); + dprintk(verbose, DST_CA_DEBUG, 0, " %02x", check_string[i]); checksum += check_string[i]; i++; } - if (verbose > 3) { - dprintk(" ]\n"); - dprintk("%s: Sum=[%02x]\n", __FUNCTION__, checksum); - } + dprintk(verbose, DST_CA_DEBUG, 0, " ]\n"); + dprintk(verbose, DST_CA_DEBUG, 1, "Sum=[%02x]\n", checksum); check_string[length] = ~checksum + 1; - if (verbose > 3) { - dprintk("%s: Checksum=[%02x]\n", __FUNCTION__, check_string[length]); - dprintk("%s: ==========================================================================\n", __FUNCTION__); - } + dprintk(verbose, DST_CA_DEBUG, 1, " Checksum=[%02x]", check_string[length]); + dprintk(verbose, DST_CA_DEBUG, 1, " =========================================================================="); return 0; } @@ -94,30 +99,26 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8 msleep(65); if (write_dst(state, data, len)) { - dprintk("%s: Write not successful, trying to recover\n", __FUNCTION__); + dprintk(verbose, DST_CA_INFO, 1, " Write not successful, trying to recover"); dst_error_recovery(state); return -1; } - if ((dst_pio_disable(state)) < 0) { - dprintk("%s: DST PIO disable failed.\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " DST PIO disable failed."); return -1; } - if (read_dst(state, &reply, GET_ACK) < 0) { - dprintk("%s: Read not successful, trying to recover\n", __FUNCTION__); + dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover"); dst_error_recovery(state); return -1; } - if (read) { if (! dst_wait_dst_ready(state, LONG_DELAY)) { - dprintk("%s: 8820 not ready\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " 8820 not ready"); return -1; } - if (read_dst(state, ca_string, 128) < 0) { /* Try to make this dynamic */ - dprintk("%s: Read not successful, trying to recover\n", __FUNCTION__); + dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover"); dst_error_recovery(state); return -1; } @@ -133,8 +134,7 @@ static int dst_put_ci(struct dst_state *state, u8 *data, int len, u8 *ca_string, while (dst_ca_comm_err < RETRIES) { dst_comm_init(state); - if (verbose > 2) - dprintk("%s: Put Command\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " Put Command"); if (dst_ci_command(state, data, ca_string, len, read)) { // If error dst_error_recovery(state); dst_ca_comm_err++; // work required here. @@ -153,18 +153,15 @@ static int ca_get_app_info(struct dst_state *state) put_checksum(&command[0], command[0]); if ((dst_put_ci(state, command, sizeof(command), state->messages, GET_REPLY)) < 0) { - dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); return -1; } - if (verbose > 1) { - dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); - - dprintk("%s: ================================ CI Module Application Info ======================================\n", __FUNCTION__); - dprintk("%s: Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]\n", - __FUNCTION__, state->messages[7], (state->messages[8] << 8) | state->messages[9], - (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12])); - dprintk("%s: ==================================================================================================\n", __FUNCTION__); - } + dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !"); + dprintk(verbose, DST_CA_INFO, 1, " ================================ CI Module Application Info ======================================"); + dprintk(verbose, DST_CA_INFO, 1, " Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]", + state->messages[7], (state->messages[8] << 8) | state->messages[9], + (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12])); + dprintk(verbose, DST_CA_INFO, 1, " =================================================================================================="); return 0; } @@ -177,31 +174,26 @@ static int ca_get_slot_caps(struct dst_state *state, struct ca_caps *p_ca_caps, put_checksum(&slot_command[0], slot_command[0]); if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_cap, GET_REPLY)) < 0) { - dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); return -1; } - if (verbose > 1) - dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !"); /* Will implement the rest soon */ - if (verbose > 1) { - dprintk("%s: Slot cap = [%d]\n", __FUNCTION__, slot_cap[7]); - dprintk("===================================\n"); - for (i = 0; i < 8; i++) - dprintk(" %d", slot_cap[i]); - dprintk("\n"); - } + dprintk(verbose, DST_CA_INFO, 1, " Slot cap = [%d]", slot_cap[7]); + dprintk(verbose, DST_CA_INFO, 0, "===================================\n"); + for (i = 0; i < 8; i++) + dprintk(verbose, DST_CA_INFO, 0, " %d", slot_cap[i]); + dprintk(verbose, DST_CA_INFO, 0, "\n"); p_ca_caps->slot_num = 1; p_ca_caps->slot_type = 1; p_ca_caps->descr_num = slot_cap[7]; p_ca_caps->descr_type = 1; - - if (copy_to_user((struct ca_caps *)arg, p_ca_caps, sizeof (struct ca_caps))) { + if (copy_to_user((struct ca_caps *)arg, p_ca_caps, sizeof (struct ca_caps))) return -EFAULT; - } return 0; } @@ -222,39 +214,32 @@ static int ca_get_slot_info(struct dst_state *state, struct ca_slot_info *p_ca_s put_checksum(&slot_command[0], 7); if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_info, GET_REPLY)) < 0) { - dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); return -1; } - if (verbose > 1) - dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); + dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !"); /* Will implement the rest soon */ - if (verbose > 1) { - dprintk("%s: Slot info = [%d]\n", __FUNCTION__, slot_info[3]); - dprintk("===================================\n"); - for (i = 0; i < 8; i++) - dprintk(" %d", slot_info[i]); - dprintk("\n"); - } + dprintk(verbose, DST_CA_INFO, 1, " Slot info = [%d]", slot_info[3]); + dprintk(verbose, DST_CA_INFO, 0, "===================================\n"); + for (i = 0; i < 8; i++) + dprintk(verbose, DST_CA_INFO, 0, " %d", slot_info[i]); + dprintk(verbose, DST_CA_INFO, 0, "\n"); if (slot_info[4] & 0x80) { p_ca_slot_info->flags = CA_CI_MODULE_PRESENT; p_ca_slot_info->num = 1; p_ca_slot_info->type = CA_CI; - } - else if (slot_info[4] & 0x40) { + } else if (slot_info[4] & 0x40) { p_ca_slot_info->flags = CA_CI_MODULE_READY; p_ca_slot_info->num = 1; p_ca_slot_info->type = CA_CI; - } - else { + } else p_ca_slot_info->flags = 0; - } - if (copy_to_user((struct ca_slot_info *)arg, p_ca_slot_info, sizeof (struct ca_slot_info))) { + if (copy_to_user((struct ca_slot_info *)arg, p_ca_slot_info, sizeof (struct ca_slot_info))) return -EFAULT; - } return 0; } @@ -268,24 +253,21 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) return -EFAULT; - if (p_ca_message->msg) { - if (verbose > 3) - dprintk("Message = [%02x %02x %02x]\n", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]); + dprintk(verbose, DST_CA_NOTICE, 1, " Message = [%02x %02x %02x]", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]); for (i = 0; i < 3; i++) { command = command | p_ca_message->msg[i]; if (i < 2) command = command << 8; } - if (verbose > 3) - dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command); + dprintk(verbose, DST_CA_NOTICE, 1, " Command=[0x%x]", command); switch (command) { - case CA_APP_INFO: - memcpy(p_ca_message->msg, state->messages, 128); - if (copy_to_user((void *)arg, p_ca_message, sizeof (struct ca_msg)) ) - return -EFAULT; + case CA_APP_INFO: + memcpy(p_ca_message->msg, state->messages, 128); + if (copy_to_user((void *)arg, p_ca_message, sizeof (struct ca_msg)) ) + return -EFAULT; break; } } @@ -300,10 +282,9 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ } else { if (length > 247) { - dprintk("%s: Message too long ! *** Bailing Out *** !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Message too long ! *** Bailing Out *** !"); return -1; } - hw_buffer->msg[0] = (length & 0xff) + 7; hw_buffer->msg[1] = 0x40; hw_buffer->msg[2] = 0x03; @@ -324,13 +305,12 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply) { if ((dst_put_ci(state, hw_buffer->msg, length, hw_buffer->msg, reply)) < 0) { - dprintk("%s: DST-CI Command failed.\n", __FUNCTION__); - dprintk("%s: Resetting DST.\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " DST-CI Command failed."); + dprintk(verbose, DST_CA_NOTICE, 1, " Resetting DST."); rdc_reset_state(state); return -1; } - if (verbose > 2) - dprintk("%s: DST-CI Command succes.\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " DST-CI Command succes."); return 0; } @@ -341,15 +321,15 @@ u32 asn_1_decode(u8 *asn_1_array) u32 length = 0; length_field = asn_1_array[0]; - dprintk("%s: Length field=[%02x]\n", __FUNCTION__, length_field); + dprintk(verbose, DST_CA_DEBUG, 1, " Length field=[%02x]", length_field); if (length_field < 0x80) { length = length_field & 0x7f; - dprintk("%s: Length=[%02x]\n", __FUNCTION__, length); + dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%02x]\n", length); } else { word_count = length_field & 0x7f; for (count = 0; count < word_count; count++) { length = (length | asn_1_array[count + 1]) << 8; - dprintk("%s: Length=[%04x]\n", __FUNCTION__, length); + dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%04x]", length); } } return length; @@ -359,10 +339,10 @@ static int debug_string(u8 *msg, u32 length, u32 offset) { u32 i; - dprintk(" String=[ "); + dprintk(verbose, DST_CA_DEBUG, 0, " String=[ "); for (i = offset; i < length; i++) - dprintk("%02x ", msg[i]); - dprintk("]\n"); + dprintk(verbose, DST_CA_DEBUG, 0, "%02x ", msg[i]); + dprintk(verbose, DST_CA_DEBUG, 0, "]\n"); return 0; } @@ -373,8 +353,7 @@ static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, stru u8 tag_length = 8; length = asn_1_decode(&p_ca_message->msg[3]); - dprintk("%s: CA Message length=[%d]\n", __FUNCTION__, length); - dprintk("%s: ASN.1 ", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " CA Message length=[%d]", length); debug_string(&p_ca_message->msg[4], length, 0); /* length is excluding tag & length */ memset(hw_buffer->msg, '\0', length); @@ -396,26 +375,24 @@ static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message /* Do test board */ /* Not there yet but soon */ - /* CA PMT Reply capable */ if (ca_pmt_reply_test) { if ((ca_set_pmt(state, p_ca_message, hw_buffer, 1, GET_REPLY)) < 0) { - dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !"); return -1; } /* Process CA PMT Reply */ /* will implement soon */ - dprintk("%s: Not there yet\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Not there yet"); } /* CA PMT Reply not capable */ if (!ca_pmt_reply_test) { if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, NO_REPLY)) < 0) { - dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !"); return -1; } - if (verbose > 3) - dprintk("%s: ca_set_pmt.. success !\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " ca_set_pmt.. success !"); /* put a dummy message */ } @@ -431,11 +408,10 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer; if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { - dprintk("%s: Memory allocation failure\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } - if (verbose > 3) - dprintk("%s\n", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " "); if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) return -EFAULT; @@ -450,51 +426,35 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, if (i < 2) command = command << 8; } - if (verbose > 3) - dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command); + dprintk(verbose, DST_CA_DEBUG, 1, " Command=[0x%x]\n", command); switch (command) { - case CA_PMT: - if (verbose > 3) -// dprintk("Command = SEND_CA_PMT\n"); - dprintk("Command = SEND_CA_PMT\n"); -// if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { - if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started - dprintk("%s: -->CA_PMT Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 3) - dprintk("%s: -->CA_PMT Success !\n", __FUNCTION__); -// retval = dummy_set_pmt(state, p_ca_message, hw_buffer, 0, 0); - - break; - - case CA_PMT_REPLY: - if (verbose > 3) - dprintk("Command = CA_PMT_REPLY\n"); - /* Have to handle the 2 basic types of cards here */ - if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) { - dprintk("%s: -->CA_PMT_REPLY Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 3) - dprintk("%s: -->CA_PMT_REPLY Success !\n", __FUNCTION__); - - /* Certain boards do behave different ? */ -// retval = ca_set_pmt(state, p_ca_message, hw_buffer, 1, 1); - - case CA_APP_INFO_ENQUIRY: // only for debugging - if (verbose > 3) - dprintk("%s: Getting Cam Application information\n", __FUNCTION__); - - if ((ca_get_app_info(state)) < 0) { - dprintk("%s: -->CA_APP_INFO_ENQUIRY Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 3) - dprintk("%s: -->CA_APP_INFO_ENQUIRY Success !\n", __FUNCTION__); - - break; + case CA_PMT: + dprintk(verbose, DST_CA_DEBUG, 1, "Command = SEND_CA_PMT"); + if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT Success !"); + break; + case CA_PMT_REPLY: + dprintk(verbose, DST_CA_INFO, 1, "Command = CA_PMT_REPLY"); + /* Have to handle the 2 basic types of cards here */ + if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT_REPLY Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT_REPLY Success !"); + break; + case CA_APP_INFO_ENQUIRY: // only for debugging + dprintk(verbose, DST_CA_INFO, 1, " Getting Cam Application information"); + + if ((ca_get_app_info(state)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_APP_INFO_ENQUIRY Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_APP_INFO_ENQUIRY Success !"); + break; } } return 0; @@ -509,121 +469,88 @@ static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd struct ca_msg *p_ca_message; if ((p_ca_message = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { - dprintk("%s: Memory allocation failure\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } - if ((p_ca_slot_info = (struct ca_slot_info *) kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL)) == NULL) { - dprintk("%s: Memory allocation failure\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } - if ((p_ca_caps = (struct ca_caps *) kmalloc(sizeof (struct ca_caps), GFP_KERNEL)) == NULL) { - dprintk("%s: Memory allocation failure\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } - /* We have now only the standard ioctl's, the driver is upposed to handle internals. */ switch (cmd) { - case CA_SEND_MSG: - if (verbose > 1) - dprintk("%s: Sending message\n", __FUNCTION__); - if ((ca_send_message(state, p_ca_message, arg)) < 0) { - dprintk("%s: -->CA_SEND_MSG Failed !\n", __FUNCTION__); - return -1; - } - - break; - - case CA_GET_MSG: - if (verbose > 1) - dprintk("%s: Getting message\n", __FUNCTION__); - if ((ca_get_message(state, p_ca_message, arg)) < 0) { - dprintk("%s: -->CA_GET_MSG Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_GET_MSG Success !\n", __FUNCTION__); - - break; - - case CA_RESET: - if (verbose > 1) - dprintk("%s: Resetting DST\n", __FUNCTION__); - dst_error_bailout(state); - msleep(4000); - - break; - - case CA_GET_SLOT_INFO: - if (verbose > 1) - dprintk("%s: Getting Slot info\n", __FUNCTION__); - if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) { - dprintk("%s: -->CA_GET_SLOT_INFO Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_GET_SLOT_INFO Success !\n", __FUNCTION__); - - break; - - case CA_GET_CAP: - if (verbose > 1) - dprintk("%s: Getting Slot capabilities\n", __FUNCTION__); - if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) { - dprintk("%s: -->CA_GET_CAP Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_GET_CAP Success !\n", __FUNCTION__); - - break; - - case CA_GET_DESCR_INFO: - if (verbose > 1) - dprintk("%s: Getting descrambler description\n", __FUNCTION__); - if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) { - dprintk("%s: -->CA_GET_DESCR_INFO Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_GET_DESCR_INFO Success !\n", __FUNCTION__); - - break; - - case CA_SET_DESCR: - if (verbose > 1) - dprintk("%s: Setting descrambler\n", __FUNCTION__); - if ((ca_set_slot_descr()) < 0) { - dprintk("%s: -->CA_SET_DESCR Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_SET_DESCR Success !\n", __FUNCTION__); - - break; - - case CA_SET_PID: - if (verbose > 1) - dprintk("%s: Setting PID\n", __FUNCTION__); - if ((ca_set_pid()) < 0) { - dprintk("%s: -->CA_SET_PID Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_SET_PID Success !\n", __FUNCTION__); - - default: - return -EOPNOTSUPP; - }; + case CA_SEND_MSG: + dprintk(verbose, DST_CA_INFO, 1, " Sending message"); + if ((ca_send_message(state, p_ca_message, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SEND_MSG Failed !"); + return -1; + } + break; + case CA_GET_MSG: + dprintk(verbose, DST_CA_INFO, 1, " Getting message"); + if ((ca_get_message(state, p_ca_message, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_MSG Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_MSG Success !"); + break; + case CA_RESET: + dprintk(verbose, DST_CA_ERROR, 1, " Resetting DST"); + dst_error_bailout(state); + msleep(4000); + break; + case CA_GET_SLOT_INFO: + dprintk(verbose, DST_CA_INFO, 1, " Getting Slot info"); + if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_SLOT_INFO Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_SLOT_INFO Success !"); + break; + case CA_GET_CAP: + dprintk(verbose, DST_CA_INFO, 1, " Getting Slot capabilities"); + if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_CAP Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_CAP Success !"); + break; + case CA_GET_DESCR_INFO: + dprintk(verbose, DST_CA_INFO, 1, " Getting descrambler description"); + if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_DESCR_INFO Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_DESCR_INFO Success !"); + break; + case CA_SET_DESCR: + dprintk(verbose, DST_CA_INFO, 1, " Setting descrambler"); + if ((ca_set_slot_descr()) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_DESCR Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_DESCR Success !"); + break; + case CA_SET_PID: + dprintk(verbose, DST_CA_INFO, 1, " Setting PID"); + if ((ca_set_pid()) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_PID Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_PID Success !"); + default: + return -EOPNOTSUPP; + }; return 0; } static int dst_ca_open(struct inode *inode, struct file *file) { - if (verbose > 4) - dprintk("%s:Device opened [%p]\n", __FUNCTION__, file); + dprintk(verbose, DST_CA_DEBUG, 1, " Device opened [%p] ", file); try_module_get(THIS_MODULE); return 0; @@ -631,27 +558,24 @@ static int dst_ca_open(struct inode *inode, struct file *file) static int dst_ca_release(struct inode *inode, struct file *file) { - if (verbose > 4) - dprintk("%s:Device closed.\n", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " Device closed."); module_put(THIS_MODULE); return 0; } -static int dst_ca_read(struct file *file, char __user * buffer, size_t length, loff_t * offset) +static int dst_ca_read(struct file *file, char __user *buffer, size_t length, loff_t *offset) { int bytes_read = 0; - if (verbose > 4) - dprintk("%s:Device read.\n", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " Device read."); return bytes_read; } -static int dst_ca_write(struct file *file, const char __user * buffer, size_t length, loff_t * offset) +static int dst_ca_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset) { - if (verbose > 4) - dprintk("%s:Device write.\n", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " Device write."); return 0; } @@ -676,8 +600,7 @@ static struct dvb_device dvbdev_ca = { int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter) { struct dvb_device *dvbdev; - if (verbose > 4) - dprintk("%s:registering DST-CA device\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device"); dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA); return 0; } diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h index ef532a6..c0ee0b19 100644 --- a/drivers/media/dvb/bt8xx/dst_common.h +++ b/drivers/media/dvb/bt8xx/dst_common.h @@ -61,7 +61,6 @@ #define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */ #define DST_TYPE_HAS_SESSION 128 - #define RDC_8820_PIO_0_DISABLE 0 #define RDC_8820_PIO_0_ENABLE 1 #define RDC_8820_INT 2 @@ -124,15 +123,12 @@ struct dst_types { u32 dst_feature; }; - - struct dst_config { /* the ASIC i2c address */ u8 demod_address; }; - int rdc_reset_state(struct dst_state *state); int rdc_8820_reset(struct dst_state *state); -- cgit v0.10.2 From 62121b1f9e25377ff50121f8c34a4aa92c47f465 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:03:01 -0700 Subject: [PATCH] dvb: dst: identify boards Identify board properly: Add functions to retrieve MAC Address, FW details, Card type and Vendor Information. Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 39835ed..eef3448 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -673,7 +673,7 @@ struct dst_types dst_tlist[] = { .offset = 1, .dst_type = DST_TYPE_IS_CABLE, .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1 - | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD, + | DST_TYPE_HAS_FW_2, .dst_feature = DST_TYPE_HAS_CA }, @@ -681,7 +681,7 @@ struct dst_types dst_tlist[] = { .device_id = "DCTNEW", .offset = 1, .dst_type = DST_TYPE_IS_CABLE, - .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3, + .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3 | DST_TYPE_HAS_FW_BUILD, .dst_feature = 0 }, @@ -689,7 +689,7 @@ struct dst_types dst_tlist[] = { .device_id = "DTT-CI", .offset = 1, .dst_type = DST_TYPE_IS_TERR, - .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD, + .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2, .dst_feature = 0 }, @@ -729,6 +729,71 @@ struct dst_types dst_tlist[] = { }; +static int dst_get_mac(struct dst_state *state) +{ + u8 get_mac[] = { 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + get_mac[7] = dst_check_sum(get_mac, 7); + if (dst_command(state, get_mac, 8) < 0) { + dprintk(verbose, DST_INFO, 1, "Unsupported Command"); + return -1; + } + memset(&state->mac_address, '\0', 8); + memcpy(&state->mac_address, &state->rxbuffer, 6); + dprintk(verbose, DST_ERROR, 1, "MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]", + state->mac_address[0], state->mac_address[1], state->mac_address[2], + state->mac_address[4], state->mac_address[5], state->mac_address[6]); + + return 0; +} + +static int dst_fw_ver(struct dst_state *state) +{ + u8 get_ver[] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + get_ver[7] = dst_check_sum(get_ver, 7); + if (dst_command(state, get_ver, 8) < 0) { + dprintk(verbose, DST_INFO, 1, "Unsupported Command"); + return -1; + } + memset(&state->fw_version, '\0', 8); + memcpy(&state->fw_version, &state->rxbuffer, 8); + dprintk(verbose, DST_ERROR, 1, "Firmware Ver = %x.%x Build = %02x, on %x:%x, %x-%x-20%02x", + state->fw_version[0] >> 4, state->fw_version[0] & 0x0f, + state->fw_version[1], + state->fw_version[5], state->fw_version[6], + state->fw_version[4], state->fw_version[3], state->fw_version[2]); + + return 0; +} + +static int dst_card_type(struct dst_state *state) +{ + u8 get_type[] = { 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + get_type[7] = dst_check_sum(get_type, 7); + if (dst_command(state, get_type, 8) < 0) { + dprintk(verbose, DST_INFO, 1, "Unsupported Command"); + return -1; + } + memset(&state->card_info, '\0', 8); + memcpy(&state->card_info, &state->rxbuffer, 8); + dprintk(verbose, DST_ERROR, 1, "Device Model=[%s]", &state->card_info[0]); + + return 0; +} + +static int dst_get_vendor(struct dst_state *state) +{ + u8 get_vendor[] = { 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + get_vendor[7] = dst_check_sum(get_vendor, 7); + if (dst_command(state, get_vendor, 8) < 0) { + dprintk(verbose, DST_INFO, 1, "Unsupported Command"); + return -1; + } + memset(&state->vendor, '\0', 8); + memcpy(&state->vendor, &state->rxbuffer, 8); + dprintk(verbose, DST_ERROR, 1, "Vendor=[%s]", &state->vendor[0]); + + return 0; +} static int dst_get_device_id(struct dst_state *state) { @@ -816,6 +881,24 @@ static int dst_probe(struct dst_state *state) dprintk(verbose, DST_ERROR, 1, "unknown device."); return -1; } + if (dst_get_mac(state) < 0) { + dprintk(verbose, DST_INFO, 1, "MAC: Unsupported command"); + return 0; + } + if (state->type_flags & DST_TYPE_HAS_FW_BUILD) { + if (dst_fw_ver(state) < 0) { + dprintk(verbose, DST_INFO, 1, "FW: Unsupported command"); + return 0; + } + if (dst_card_type(state) < 0) { + dprintk(verbose, DST_INFO, 1, "Card: Unsupported command"); + return 0; + } + if (dst_get_vendor(state) < 0) { + dprintk(verbose, DST_INFO, 1, "Vendor: Unsupported command"); + return 0; + } + } return 0; } diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h index c0ee0b19..3281a6c 100644 --- a/drivers/media/dvb/bt8xx/dst_common.h +++ b/drivers/media/dvb/bt8xx/dst_common.h @@ -113,6 +113,10 @@ struct dst_state { fe_sec_mini_cmd_t minicmd; fe_modulation_t modulation; u8 messages[256]; + u8 mac_address[8]; + u8 fw_version[8]; + u8 card_info[8]; + u8 vendor[8]; }; struct dst_types { -- cgit v0.10.2 From 62867429d0d79e47e19ceedc3133efe74993932f Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:03:02 -0700 Subject: [PATCH] dvb: dst: fix DVB-C tuning Fix BUG in DVB-C frequency setting. Thanks to Peng Cao Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index eef3448..34a837a 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -359,6 +359,7 @@ static int dst_set_freq(struct dst_state *state, u32 freq) state->tx_tuna[3] = (freq >> 8) & 0xff; state->tx_tuna[4] = (u8) freq; } else if (state->dst_type == DST_TYPE_IS_CABLE) { + freq = freq / 1000; state->tx_tuna[2] = (freq >> 16) & 0xff; state->tx_tuna[3] = (freq >> 8) & 0xff; state->tx_tuna[4] = (u8) freq; -- cgit v0.10.2 From 9dea88514c476d303f59e19b27ef26bb52dc193a Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:03:03 -0700 Subject: [PATCH] dvb: dst: ci doc update Updated documentation Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/dvb/ci.txt b/Documentation/dvb/ci.txt index 62e0701..95f0e73 100644 --- a/Documentation/dvb/ci.txt +++ b/Documentation/dvb/ci.txt @@ -23,7 +23,6 @@ This application requires the following to function properly as of now. eg: $ szap -c channels.conf -r "TMC" -x (b) a channels.conf containing a valid PMT PID - eg: TMC:11996:h:0:27500:278:512:650:321 here 278 is a valid PMT PID. the rest of the values are the @@ -31,13 +30,7 @@ This application requires the following to function properly as of now. (c) after running a szap, you have to run ca_zap, for the descrambler to function, - - eg: $ ca_zap patched_channels.conf "TMC" - - The patched means a patch to apply to scan, such that scan can - generate a channels.conf_with pmt, which has this PMT PID info - (NOTE: szap cannot use this channels.conf with the PMT_PID) - + eg: $ ca_zap channels.conf "TMC" (d) Hopeflly Enjoy your favourite subscribed channel as you do with a FTA card. -- cgit v0.10.2 From 2d6e7322b5f63d62ec8785c5fbf469c9a233baff Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:03:04 -0700 Subject: [PATCH] dvb: dst: Updated Documentation Updated Documentation Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/dvb/bt8xx.txt b/Documentation/dvb/bt8xx.txt index 4b8c326..cb63b7a 100644 --- a/Documentation/dvb/bt8xx.txt +++ b/Documentation/dvb/bt8xx.txt @@ -1,55 +1,74 @@ -How to get the Nebula Electronics DigiTV, Pinnacle PCTV Sat, Twinhan DST + clones working -========================================================================================= +How to get the Nebula, PCTV and Twinhan DST cards working +========================================================= -1) General information -====================== +This class of cards has a bt878a as the PCI interface, and +require the bttv driver. -This class of cards has a bt878a chip as the PCI interface. -The different card drivers require the bttv driver to provide the means -to access the i2c bus and the gpio pins of the bt8xx chipset. +Please pay close attention to the warning about the bttv module +options below for the DST card. -2) Compilation rules for Kernel >= 2.6.12 -========================================= +1) General informations +======================= -Enable the following options: +These drivers require the bttv driver to provide the means to access +the i2c bus and the gpio pins of the bt8xx chipset. +Because of this, you need to enable "Device drivers" => "Multimedia devices" - => "Video For Linux" => "BT848 Video For Linux" + => "Video For Linux" => "BT848 Video For Linux" + +Furthermore you need to enable "Device drivers" => "Multimedia devices" => "Digital Video Broadcasting Devices" - => "DVB for Linux" "DVB Core Support" "BT8xx based PCI cards" + => "DVB for Linux" "DVB Core Support" "BT8xx based PCI cards" -3) Loading Modules, described by two approaches -=============================================== +2) Loading Modules +================== In general you need to load the bttv driver, which will handle the gpio and -i2c communication for us, plus the common dvb-bt8xx device driver, -which is called the backend. -The frontends for Nebula DigiTV (nxt6000), Pinnacle PCTV Sat (cx24110), -TwinHan DST + clones (dst and dst-ca) are loaded automatically by the backend. -For further details about TwinHan DST + clones see /Documentation/dvb/ci.txt. +i2c communication for us, plus the common dvb-bt8xx device driver. +The frontends for Nebula (nxt6000), Pinnacle PCTV (cx24110) and +TwinHan (dst) are loaded automatically by the dvb-bt8xx device driver. -3a) The manual approach ------------------------ +3a) Nebula / Pinnacle PCTV +-------------------------- -Loading modules: -modprobe bttv -modprobe dvb-bt8xx + $ modprobe bttv (normally bttv is being loaded automatically by kmod) + $ modprobe dvb-bt8xx (or just place dvb-bt8xx in /etc/modules for automatic loading) -Unloading modules: -modprobe -r dvb-bt8xx -modprobe -r bttv -3b) The automatic approach +3b) TwinHan and Clones -------------------------- -If not already done by installation, place a line either in -/etc/modules.conf or in /etc/modprobe.conf containing this text: -alias char-major-81 bttv + $ modprobe bttv i2c_hw=1 card=0x71 + $ modprobe dvb-bt8xx + $ modprobe dst + +The value 0x71 will override the PCI type detection for dvb-bt8xx, +which is necessary for TwinHan cards. + +If you're having an older card (blue color circuit) and card=0x71 locks +your machine, try using 0x68, too. If that does not work, ask on the +mailing list. + +The DST module takes a couple of useful parameters. + +verbose takes values 0 to 4. These values control the verbosity level, +and can be used to debug also. + +verbose=0 means complete disabling of messages + 1 only error messages are displayed + 2 notifications are also displayed + 3 informational messages are also displayed + 4 debug setting + +dst_addons takes values 0 and 0x20. A value of 0 means it is a FTA card. +0x20 means it has a Conditional Access slot. + +The autodected values are determined bythe cards 'response +string' which you can see in your logs e.g. -Then place a line in /etc/modules containing this text: -dvb-bt8xx +dst_get_device_id: Recognise [DSTMCI] -Reboot your system and have fun! -- -Authors: Richard Walker, Jamie Honan, Michael Hunold, Manu Abraham, Uwe Bugla +Authors: Richard Walker, Jamie Honan, Michael Hunold, Manu Abraham -- cgit v0.10.2 From 6d78933c291bd0b6292e2c631e2f5e346c14d3fa Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:03:05 -0700 Subject: [PATCH] dvb: cinergyT2: remote control fixes IR RC fixes: - EVIOCSKEYCODE is not supported by this driver, fix potential crash when it is used by not setting rc_input_dev->keycodesize - fix key repeat handling (hopefully) - reduce default poll internal to 50msec (necessary for key repeat handling) Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/cinergyT2/Kconfig b/drivers/media/dvb/cinergyT2/Kconfig index 2267140..7cf4c4a 100644 --- a/drivers/media/dvb/cinergyT2/Kconfig +++ b/drivers/media/dvb/cinergyT2/Kconfig @@ -77,7 +77,7 @@ config DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE config DVB_CINERGYT2_RC_QUERY_INTERVAL int "Infrared Remote Controller update interval [milliseconds]" depends on DVB_CINERGYT2_TUNING && DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE - default "100" + default "50" help If you have a very fast-repeating remote control you can try lower values, for normal consumer receivers the default value should be diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index c52e9d5..6db0929 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c @@ -35,7 +35,6 @@ #include "dvb_demux.h" #include "dvb_net.h" - #ifdef CONFIG_DVB_CINERGYT2_TUNING #define STREAM_URB_COUNT (CONFIG_DVB_CINERGYT2_STREAM_URB_COUNT) #define STREAM_BUF_SIZE (CONFIG_DVB_CINERGYT2_STREAM_BUF_SIZE) @@ -48,7 +47,7 @@ #define STREAM_URB_COUNT (32) #define STREAM_BUF_SIZE (512) /* bytes */ #define ENABLE_RC (1) - #define RC_QUERY_INTERVAL (100) /* milliseconds */ + #define RC_QUERY_INTERVAL (50) /* milliseconds */ #define QUERY_INTERVAL (333) /* milliseconds */ #endif @@ -141,6 +140,8 @@ struct cinergyt2 { struct input_dev rc_input_dev; struct work_struct rc_query_work; int rc_input_event; + u32 rc_last_code; + unsigned long last_event_jiffies; #endif }; @@ -155,7 +156,7 @@ struct cinergyt2_rc_event { uint32_t value; } __attribute__((packed)); -static const uint32_t rc_keys [] = { +static const uint32_t rc_keys[] = { CINERGYT2_RC_EVENT_TYPE_NEC, 0xfe01eb04, KEY_POWER, CINERGYT2_RC_EVENT_TYPE_NEC, 0xfd02eb04, KEY_1, CINERGYT2_RC_EVENT_TYPE_NEC, 0xfc03eb04, KEY_2, @@ -684,52 +685,68 @@ static struct dvb_device cinergyt2_fe_template = { #ifdef ENABLE_RC static void cinergyt2_query_rc (void *data) { - struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data; - char buf [1] = { CINERGYT2_EP1_GET_RC_EVENTS }; + struct cinergyt2 *cinergyt2 = data; + char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS }; struct cinergyt2_rc_event rc_events[12]; - int n, len; + int n, len, i; if (down_interruptible(&cinergyt2->sem)) return; len = cinergyt2_command(cinergyt2, buf, sizeof(buf), - (char *) rc_events, sizeof(rc_events)); - - for (n=0; len>0 && n<(len/sizeof(rc_events[0])); n++) { - int i; + (char *) rc_events, sizeof(rc_events)); + if (len < 0) + goto out; + if (len == 0) { + if (time_after(jiffies, cinergyt2->last_event_jiffies + + msecs_to_jiffies(150))) { + /* stop key repeat */ + if (cinergyt2->rc_input_event != KEY_MAX) { + dprintk(1, "rc_input_event=%d Up\n", cinergyt2->rc_input_event); + input_report_key(&cinergyt2->rc_input_dev, + cinergyt2->rc_input_event, 0); + cinergyt2->rc_input_event = KEY_MAX; + } + cinergyt2->rc_last_code = ~0; + } + goto out; + } + cinergyt2->last_event_jiffies = jiffies; -/* dprintk(1,"rc_events[%d].value = %x, type=%x\n",n,le32_to_cpu(rc_events[n].value),rc_events[n].type);*/ + for (n = 0; n < (len / sizeof(rc_events[0])); n++) { + dprintk(1, "rc_events[%d].value = %x, type=%x\n", + n, le32_to_cpu(rc_events[n].value), rc_events[n].type); if (rc_events[n].type == CINERGYT2_RC_EVENT_TYPE_NEC && - rc_events[n].value == ~0) - { - /** - * keyrepeat bit. If we would handle this properly - * we would need to emit down events as long the - * keyrepeat goes, a up event if no further - * repeat bits occur. Would need a timer to implement - * and no other driver does this, so we simply - * emit the last key up/down sequence again. - */ + rc_events[n].value == ~0) { + /* keyrepeat bit -> just repeat last rc_input_event */ } else { cinergyt2->rc_input_event = KEY_MAX; - for (i=0; irc_input_event = rc_keys[i+2]; + for (i = 0; i < sizeof(rc_keys) / sizeof(rc_keys[0]); i += 3) { + if (rc_keys[i + 0] == rc_events[n].type && + rc_keys[i + 1] == le32_to_cpu(rc_events[n].value)) { + cinergyt2->rc_input_event = rc_keys[i + 2]; break; } } } if (cinergyt2->rc_input_event != KEY_MAX) { - input_report_key(&cinergyt2->rc_input_dev, cinergyt2->rc_input_event, 1); - input_report_key(&cinergyt2->rc_input_dev, cinergyt2->rc_input_event, 0); - input_sync(&cinergyt2->rc_input_dev); + if (rc_events[n].value == cinergyt2->rc_last_code && + cinergyt2->rc_last_code != ~0) { + /* emit a key-up so the double event is recognized */ + dprintk(1, "rc_input_event=%d UP\n", cinergyt2->rc_input_event); + input_report_key(&cinergyt2->rc_input_dev, + cinergyt2->rc_input_event, 0); + } + dprintk(1, "rc_input_event=%d\n", cinergyt2->rc_input_event); + input_report_key(&cinergyt2->rc_input_dev, + cinergyt2->rc_input_event, 1); + cinergyt2->rc_last_code = rc_events[n].value; } } +out: schedule_delayed_work(&cinergyt2->rc_query_work, msecs_to_jiffies(RC_QUERY_INTERVAL)); @@ -771,7 +788,10 @@ static int cinergyt2_probe (struct usb_interface *intf, const struct usb_device_id *id) { struct cinergyt2 *cinergyt2; - int i, err; + int err; +#ifdef ENABLE_RC + int i; +#endif if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) { dprintk(1, "out of memory?!?\n"); @@ -827,19 +847,18 @@ static int cinergyt2_probe (struct usb_interface *intf, DVB_DEVICE_FRONTEND); #ifdef ENABLE_RC - init_input_dev(&cinergyt2->rc_input_dev); - - cinergyt2->rc_input_dev.evbit[0] = BIT(EV_KEY); - cinergyt2->rc_input_dev.keycodesize = sizeof(unsigned char); - cinergyt2->rc_input_dev.keycodemax = KEY_MAX; + cinergyt2->rc_input_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); + cinergyt2->rc_input_dev.keycodesize = 0; + cinergyt2->rc_input_dev.keycodemax = 0; cinergyt2->rc_input_dev.name = DRIVER_NAME " remote control"; - for (i=0; irc_input_dev.keybit); + for (i = 0; i < sizeof(rc_keys) / sizeof(rc_keys[0]); i += 3) + set_bit(rc_keys[i + 2], cinergyt2->rc_input_dev.keybit); input_register_device(&cinergyt2->rc_input_dev); cinergyt2->rc_input_event = KEY_MAX; + cinergyt2->rc_last_code = ~0; INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2); schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2); -- cgit v0.10.2 From f63f5346c943008fe8f6ac66a9026f6c35e24947 Mon Sep 17 00:00:00 2001 From: thomas schorpp Date: Fri, 9 Sep 2005 13:03:06 -0700 Subject: [PATCH] dvb: av7110: Siemens DVB-C analog video input support Add support for analog video inputs (CVBS and Y/C) of the analog module for the Siemens DVB-C card. Signed-off-by: thomas schorpp Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c index e65fc36..6af74f7 100644 --- a/drivers/media/dvb/ttpci/av7110_v4l.c +++ b/drivers/media/dvb/ttpci/av7110_v4l.c @@ -70,7 +70,7 @@ static int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val) return 0; } -static struct v4l2_input inputs[2] = { +static struct v4l2_input inputs[4] = { { .index = 0, .name = "DVB", @@ -87,6 +87,22 @@ static struct v4l2_input inputs[2] = { .tuner = 0, .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, .status = 0, + }, { + .index = 2, + .name = "Video", + .type = V4L2_INPUT_TYPE_CAMERA, + .audioset = 0, + .tuner = 0, + .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, + .status = 0, + }, { + .index = 3, + .name = "Y/C", + .type = V4L2_INPUT_TYPE_CAMERA, + .audioset = 0, + .tuner = 0, + .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, + .status = 0, } }; @@ -212,24 +228,44 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh) } if (0 != av7110->current_input) { + dprintk(1, "switching to analog TV:\n"); adswitch = 1; source = SAA7146_HPS_SOURCE_PORT_B; sync = SAA7146_HPS_SYNC_PORT_B; memcpy(standard, analog_standard, sizeof(struct saa7146_standard) * 2); - dprintk(1, "switching to analog TV\n"); - msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source - msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source - msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source - msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono - msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone - msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume - if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) { - if (ves1820_writereg(dev, 0x09, 0x0f, 0x60)) - dprintk(1, "setting band in demodulator failed.\n"); - } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) { - saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD) - saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF) + switch (av7110->current_input) { + case 1: + dprintk(1, "switching SAA7113 to Analog Tuner Input.\n"); + msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source + msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source + msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source + msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono + msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone + msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume + + if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) { + if (ves1820_writereg(dev, 0x09, 0x0f, 0x60)) + dprintk(1, "setting band in demodulator failed.\n"); + } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) { + saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD) + saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF) + } + if (i2c_writereg(av7110, 0x48, 0x02, 0xd0) != 1) + dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); + break; + case 2: + dprintk(1, "switching SAA7113 to Video AV CVBS Input.\n"); + if (i2c_writereg(av7110, 0x48, 0x02, 0xd2) != 1) + dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); + break; + case 3: + dprintk(1, "switching SAA7113 to Video AV Y/C Input.\n"); + if (i2c_writereg(av7110, 0x48, 0x02, 0xd9) != 1) + dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); + break; + default: + dprintk(1, "switching SAA7113 to Input: AV7110: SAA7113: invalid input.\n"); } } else { adswitch = 0; @@ -300,7 +336,6 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) // FIXME: standard / stereo detection is still broken msp_readreg(av7110, MSP_RD_DEM, 0x007e, &stereo_det); dprintk(1, "VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det); - msp_readreg(av7110, MSP_RD_DSP, 0x0018, &stereo_det); dprintk(1, "VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det); stereo = (s8)(stereo_det >> 8); @@ -310,7 +345,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) t->audmode = V4L2_TUNER_MODE_STEREO; } else if (stereo < -0x10) { - /* bilingual*/ + /* bilingual */ t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; t->audmode = V4L2_TUNER_MODE_LANG1; } @@ -344,7 +379,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) fm_matrix = 0x3000; // mono src = 0x0010; break; - default: /* case V4L2_TUNER_MODE_MONO: {*/ + default: /* case V4L2_TUNER_MODE_MONO: */ dprintk(2, "VIDIOC_S_TUNER: TDA9840_SET_MONO\n"); fm_matrix = 0x3000; // mono src = 0x0030; @@ -406,7 +441,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index); if (av7110->analog_tuner_flags) { - if (i->index < 0 || i->index >= 2) + if (i->index < 0 || i->index >= 4) return -EINVAL; } else { if (i->index != 0) @@ -433,10 +468,9 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) if (!av7110->analog_tuner_flags) return 0; - if (input < 0 || input >= 2) + if (input < 0 || input >= 4) return -EINVAL; - /* FIXME: switch inputs here */ av7110->current_input = input; return av7110_dvb_c_switch(fh); } -- cgit v0.10.2 From dc27a1696089a9a9d317fc815915e6761e22eeb5 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 9 Sep 2005 13:03:07 -0700 Subject: [PATCH] dvb: budget-ci: add support for TT DVB-C CI card Add support for TT DVB-C CI card. Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index a36bec3..47e28b0 100644 --- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c +++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c @@ -334,8 +334,103 @@ static struct mt312_config skystar23_samsung_tbdu18132_config = { .pll_set = skystar23_samsung_tbdu18132_pll_set, }; + +static u8 alps_tdee4_stv0297_inittab[] = { + 0x80, 0x01, + 0x80, 0x00, + 0x81, 0x01, + 0x81, 0x00, + 0x00, 0x09, + 0x01, 0x69, + 0x03, 0x00, + 0x04, 0x00, + 0x07, 0x00, + 0x08, 0x00, + 0x20, 0x00, + 0x21, 0x40, + 0x22, 0x00, + 0x23, 0x00, + 0x24, 0x40, + 0x25, 0x88, + 0x30, 0xff, + 0x31, 0x00, + 0x32, 0xff, + 0x33, 0x00, + 0x34, 0x50, + 0x35, 0x7f, + 0x36, 0x00, + 0x37, 0x20, + 0x38, 0x00, + 0x40, 0x1c, + 0x41, 0xff, + 0x42, 0x29, + 0x43, 0x00, + 0x44, 0xff, + 0x45, 0x00, + 0x46, 0x00, + 0x49, 0x04, + 0x4a, 0x00, + 0x4b, 0xf8, + 0x52, 0x30, + 0x55, 0xae, + 0x56, 0x47, + 0x57, 0xe1, + 0x58, 0x3a, + 0x5a, 0x1e, + 0x5b, 0x34, + 0x60, 0x00, + 0x63, 0x00, + 0x64, 0x00, + 0x65, 0x00, + 0x66, 0x00, + 0x67, 0x00, + 0x68, 0x00, + 0x69, 0x00, + 0x6a, 0x02, + 0x6b, 0x00, + 0x70, 0xff, + 0x71, 0x00, + 0x72, 0x00, + 0x73, 0x00, + 0x74, 0x0c, + 0x80, 0x00, + 0x81, 0x00, + 0x82, 0x00, + 0x83, 0x00, + 0x84, 0x04, + 0x85, 0x80, + 0x86, 0x24, + 0x87, 0x78, + 0x88, 0x10, + 0x89, 0x00, + 0x90, 0x01, + 0x91, 0x01, + 0xa0, 0x04, + 0xa1, 0x00, + 0xa2, 0x00, + 0xb0, 0x91, + 0xb1, 0x0b, + 0xc0, 0x53, + 0xc1, 0x70, + 0xc2, 0x12, + 0xd0, 0x00, + 0xd1, 0x00, + 0xd2, 0x00, + 0xd3, 0x00, + 0xd4, 0x00, + 0xd5, 0x00, + 0xde, 0x00, + 0xdf, 0x00, + 0x61, 0x49, + 0x62, 0x0b, + 0x53, 0x08, + 0x59, 0x08, + 0xff, 0xff, +}; + static struct stv0297_config alps_tdee4_stv0297_config = { .demod_address = 0x1c, + .inittab = alps_tdee4_stv0297_inittab, // .invert = 1, // .pll_set = alps_tdee4_stv0297_pll_set, }; @@ -369,7 +464,7 @@ int flexcop_frontend_init(struct flexcop_device *fc) info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address); } else /* try the cable dvb (stv0297) */ - if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap, 0xf8)) != NULL) { + if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) { fc->dev_type = FC_CABLE; info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); } else diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c index 01eb419..8d09afd 100644 --- a/drivers/media/dvb/frontends/stv0297.c +++ b/drivers/media/dvb/frontends/stv0297.c @@ -35,7 +35,6 @@ struct stv0297_state { struct dvb_frontend frontend; unsigned long base_freq; - u8 pwm; }; #if 1 @@ -46,94 +45,6 @@ struct stv0297_state { #define STV0297_CLOCK_KHZ 28900 -static u8 init_tab[] = { - 0x00, 0x09, - 0x01, 0x69, - 0x03, 0x00, - 0x04, 0x00, - 0x07, 0x00, - 0x08, 0x00, - 0x20, 0x00, - 0x21, 0x40, - 0x22, 0x00, - 0x23, 0x00, - 0x24, 0x40, - 0x25, 0x88, - 0x30, 0xff, - 0x31, 0x00, - 0x32, 0xff, - 0x33, 0x00, - 0x34, 0x50, - 0x35, 0x7f, - 0x36, 0x00, - 0x37, 0x20, - 0x38, 0x00, - 0x40, 0x1c, - 0x41, 0xff, - 0x42, 0x29, - 0x43, 0x00, - 0x44, 0xff, - 0x45, 0x00, - 0x46, 0x00, - 0x49, 0x04, - 0x4a, 0xff, - 0x4b, 0x7f, - 0x52, 0x30, - 0x55, 0xae, - 0x56, 0x47, - 0x57, 0xe1, - 0x58, 0x3a, - 0x5a, 0x1e, - 0x5b, 0x34, - 0x60, 0x00, - 0x63, 0x00, - 0x64, 0x00, - 0x65, 0x00, - 0x66, 0x00, - 0x67, 0x00, - 0x68, 0x00, - 0x69, 0x00, - 0x6a, 0x02, - 0x6b, 0x00, - 0x70, 0xff, - 0x71, 0x00, - 0x72, 0x00, - 0x73, 0x00, - 0x74, 0x0c, - 0x80, 0x00, - 0x81, 0x00, - 0x82, 0x00, - 0x83, 0x00, - 0x84, 0x04, - 0x85, 0x80, - 0x86, 0x24, - 0x87, 0x78, - 0x88, 0x00, - 0x89, 0x00, - 0x90, 0x01, - 0x91, 0x01, - 0xa0, 0x00, - 0xa1, 0x00, - 0xa2, 0x00, - 0xb0, 0x91, - 0xb1, 0x0b, - 0xc0, 0x53, - 0xc1, 0x70, - 0xc2, 0x12, - 0xd0, 0x00, - 0xd1, 0x00, - 0xd2, 0x00, - 0xd3, 0x00, - 0xd4, 0x00, - 0xd5, 0x00, - 0xde, 0x00, - 0xdf, 0x00, - 0x61, 0x49, - 0x62, 0x0b, - 0x53, 0x08, - 0x59, 0x08, -}; - static int stv0297_writereg(struct stv0297_state *state, u8 reg, u8 data) { @@ -378,34 +289,9 @@ static int stv0297_init(struct dvb_frontend *fe) struct stv0297_state *state = fe->demodulator_priv; int i; - /* soft reset */ - stv0297_writereg_mask(state, 0x80, 1, 1); - stv0297_writereg_mask(state, 0x80, 1, 0); - - /* reset deinterleaver */ - stv0297_writereg_mask(state, 0x81, 1, 1); - stv0297_writereg_mask(state, 0x81, 1, 0); - /* load init table */ - for (i = 0; i < sizeof(init_tab); i += 2) { - stv0297_writereg(state, init_tab[i], init_tab[i + 1]); - } - - /* set a dummy symbol rate */ - stv0297_set_symbolrate(state, 6900); - - /* invert AGC1 polarity */ - stv0297_writereg_mask(state, 0x88, 0x10, 0x10); - - /* setup bit error counting */ - stv0297_writereg_mask(state, 0xA0, 0x80, 0x00); - stv0297_writereg_mask(state, 0xA0, 0x10, 0x00); - stv0297_writereg_mask(state, 0xA0, 0x08, 0x00); - stv0297_writereg_mask(state, 0xA0, 0x07, 0x04); - - /* min + max PWM */ - stv0297_writereg(state, 0x4a, 0x00); - stv0297_writereg(state, 0x4b, state->pwm); + for (i=0; !(state->config->inittab[i] == 0xff && state->config->inittab[i+1] == 0xff); i+=2) + stv0297_writereg(state, state->config->inittab[i], state->config->inittab[i+1]); msleep(200); if (state->config->pll_init) @@ -738,7 +624,7 @@ static void stv0297_release(struct dvb_frontend *fe) static struct dvb_frontend_ops stv0297_ops; struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, - struct i2c_adapter *i2c, int pwm) + struct i2c_adapter *i2c) { struct stv0297_state *state = NULL; @@ -752,7 +638,6 @@ struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, state->i2c = i2c; memcpy(&state->ops, &stv0297_ops, sizeof(struct dvb_frontend_ops)); state->base_freq = 0; - state->pwm = pwm; /* check if the demod is there */ if ((stv0297_readreg(state, 0x80) & 0x70) != 0x20) diff --git a/drivers/media/dvb/frontends/stv0297.h b/drivers/media/dvb/frontends/stv0297.h index 3be5359..9e53f01 100644 --- a/drivers/media/dvb/frontends/stv0297.h +++ b/drivers/media/dvb/frontends/stv0297.h @@ -29,6 +29,12 @@ struct stv0297_config /* the demodulator's i2c address */ u8 demod_address; + /* inittab - array of pairs of values. + * First of each pair is the register, second is the value. + * List should be terminated with an 0xff, 0xff pair. + */ + u8* inittab; + /* does the "inversion" need inverted? */ u8 invert:1; @@ -38,7 +44,7 @@ struct stv0297_config }; extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, - struct i2c_adapter* i2c, int pwm); + struct i2c_adapter* i2c); extern int stv0297_enable_plli2c(struct dvb_frontend* fe); #endif // STV0297_H diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index c91cf89..48e8097 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c @@ -1934,6 +1934,98 @@ static struct sp8870_config alps_tdlb7_config = { }; +static u8 nexusca_stv0297_inittab[] = { + 0x80, 0x01, + 0x80, 0x00, + 0x81, 0x01, + 0x81, 0x00, + 0x00, 0x09, + 0x01, 0x69, + 0x03, 0x00, + 0x04, 0x00, + 0x07, 0x00, + 0x08, 0x00, + 0x20, 0x00, + 0x21, 0x40, + 0x22, 0x00, + 0x23, 0x00, + 0x24, 0x40, + 0x25, 0x88, + 0x30, 0xff, + 0x31, 0x00, + 0x32, 0xff, + 0x33, 0x00, + 0x34, 0x50, + 0x35, 0x7f, + 0x36, 0x00, + 0x37, 0x20, + 0x38, 0x00, + 0x40, 0x1c, + 0x41, 0xff, + 0x42, 0x29, + 0x43, 0x00, + 0x44, 0xff, + 0x45, 0x00, + 0x46, 0x00, + 0x49, 0x04, + 0x4a, 0x00, + 0x4b, 0x7b, + 0x52, 0x30, + 0x55, 0xae, + 0x56, 0x47, + 0x57, 0xe1, + 0x58, 0x3a, + 0x5a, 0x1e, + 0x5b, 0x34, + 0x60, 0x00, + 0x63, 0x00, + 0x64, 0x00, + 0x65, 0x00, + 0x66, 0x00, + 0x67, 0x00, + 0x68, 0x00, + 0x69, 0x00, + 0x6a, 0x02, + 0x6b, 0x00, + 0x70, 0xff, + 0x71, 0x00, + 0x72, 0x00, + 0x73, 0x00, + 0x74, 0x0c, + 0x80, 0x00, + 0x81, 0x00, + 0x82, 0x00, + 0x83, 0x00, + 0x84, 0x04, + 0x85, 0x80, + 0x86, 0x24, + 0x87, 0x78, + 0x88, 0x10, + 0x89, 0x00, + 0x90, 0x01, + 0x91, 0x01, + 0xa0, 0x04, + 0xa1, 0x00, + 0xa2, 0x00, + 0xb0, 0x91, + 0xb1, 0x0b, + 0xc0, 0x53, + 0xc1, 0x70, + 0xc2, 0x12, + 0xd0, 0x00, + 0xd1, 0x00, + 0xd2, 0x00, + 0xd3, 0x00, + 0xd4, 0x00, + 0xd5, 0x00, + 0xde, 0x00, + 0xdf, 0x00, + 0x61, 0x49, + 0x62, 0x0b, + 0x53, 0x08, + 0x59, 0x08, + 0xff, 0xff, +}; static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { @@ -1982,6 +2074,7 @@ static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ static struct stv0297_config nexusca_stv0297_config = { .demod_address = 0x1C, + .inittab = nexusca_stv0297_inittab, .invert = 1, .pll_set = nexusca_stv0297_pll_set, }; @@ -2259,7 +2352,7 @@ static int frontend_init(struct av7110 *av7110) case 0x000A: // Hauppauge/TT Nexus-CA rev1.X - av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap, 0x7b); + av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap); if (av7110->fe) { /* set TDA9819 into DVB mode */ saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9198 pin9(STD) diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 88f27a5..2980db3 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c @@ -40,6 +40,7 @@ #include "dvb_ca_en50221.h" #include "stv0299.h" +#include "stv0297.h" #include "tda1004x.h" #define DEBIADDR_IR 0x1234 @@ -847,6 +848,180 @@ static struct tda1004x_config philips_tdm1316l_config = { .request_firmware = philips_tdm1316l_request_firmware, }; +static int dvbc_philips_tdm1316l_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) +{ + struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; + u8 tuner_buf[5]; + struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address, + .flags = 0, + .buf = tuner_buf, + .len = sizeof(tuner_buf) }; + int tuner_frequency = 0; + u8 band, cp, filter; + + // determine charge pump + tuner_frequency = params->frequency + 36125000; + if (tuner_frequency < 87000000) + return -EINVAL; + else if (tuner_frequency < 130000000) { + cp = 3; + band = 1; + } else if (tuner_frequency < 160000000) { + cp = 5; + band = 1; + } else if (tuner_frequency < 200000000) { + cp = 6; + band = 1; + } else if (tuner_frequency < 290000000) { + cp = 3; + band = 2; + } else if (tuner_frequency < 420000000) { + cp = 5; + band = 2; + } else if (tuner_frequency < 480000000) { + cp = 6; + band = 2; + } else if (tuner_frequency < 620000000) { + cp = 3; + band = 4; + } else if (tuner_frequency < 830000000) { + cp = 5; + band = 4; + } else if (tuner_frequency < 895000000) { + cp = 7; + band = 4; + } else + return -EINVAL; + + // assume PLL filter should always be 8MHz for the moment. + filter = 1; + + // calculate divisor + tuner_frequency = (params->frequency + 36125000 + (62500/2)) / 62500; + + // setup tuner buffer + tuner_buf[0] = tuner_frequency >> 8; + tuner_buf[1] = tuner_frequency & 0xff; + tuner_buf[2] = 0xc8; + tuner_buf[3] = (cp << 5) | (filter << 3) | band; + tuner_buf[4] = 0x80; + + stv0297_enable_plli2c(fe); + if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) + return -EIO; + + msleep(50); + + stv0297_enable_plli2c(fe); + if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) + return -EIO; + + msleep(1); + + return 0; +} + +static u8 dvbc_philips_tdm1316l_inittab[] = { + 0x80, 0x01, + 0x80, 0x00, + 0x81, 0x01, + 0x81, 0x00, + 0x00, 0x09, + 0x01, 0x69, + 0x03, 0x00, + 0x04, 0x00, + 0x07, 0x00, + 0x08, 0x00, + 0x20, 0x00, + 0x21, 0x40, + 0x22, 0x00, + 0x23, 0x00, + 0x24, 0x40, + 0x25, 0x88, + 0x30, 0xff, + 0x31, 0x00, + 0x32, 0xff, + 0x33, 0x00, + 0x34, 0x50, + 0x35, 0x7f, + 0x36, 0x00, + 0x37, 0x20, + 0x38, 0x00, + 0x40, 0x1c, + 0x41, 0xff, + 0x42, 0x29, + 0x43, 0x20, + 0x44, 0xff, + 0x45, 0x00, + 0x46, 0x00, + 0x49, 0x04, + 0x4a, 0x00, + 0x4b, 0x7b, + 0x52, 0x30, + 0x55, 0xae, + 0x56, 0x47, + 0x57, 0xe1, + 0x58, 0x3a, + 0x5a, 0x1e, + 0x5b, 0x34, + 0x60, 0x00, + 0x63, 0x00, + 0x64, 0x00, + 0x65, 0x00, + 0x66, 0x00, + 0x67, 0x00, + 0x68, 0x00, + 0x69, 0x00, + 0x6a, 0x02, + 0x6b, 0x00, + 0x70, 0xff, + 0x71, 0x00, + 0x72, 0x00, + 0x73, 0x00, + 0x74, 0x0c, + 0x80, 0x00, + 0x81, 0x00, + 0x82, 0x00, + 0x83, 0x00, + 0x84, 0x04, + 0x85, 0x80, + 0x86, 0x24, + 0x87, 0x78, + 0x88, 0x10, + 0x89, 0x00, + 0x90, 0x01, + 0x91, 0x01, + 0xa0, 0x04, + 0xa1, 0x00, + 0xa2, 0x00, + 0xb0, 0x91, + 0xb1, 0x0b, + 0xc0, 0x53, + 0xc1, 0x70, + 0xc2, 0x12, + 0xd0, 0x00, + 0xd1, 0x00, + 0xd2, 0x00, + 0xd3, 0x00, + 0xd4, 0x00, + 0xd5, 0x00, + 0xde, 0x00, + 0xdf, 0x00, + 0x61, 0x38, + 0x62, 0x0a, + 0x53, 0x13, + 0x59, 0x08, + 0xff, 0xff, +}; + +static struct stv0297_config dvbc_philips_tdm1316l_config = { + .demod_address = 0x1c, + .inittab = dvbc_philips_tdm1316l_inittab, + .invert = 0, + .pll_set = dvbc_philips_tdm1316l_pll_set, +}; + + static void frontend_init(struct budget_ci *budget_ci) @@ -868,6 +1043,15 @@ static void frontend_init(struct budget_ci *budget_ci) } break; + case 0x1010: // TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt)) + budget_ci->tuner_pll_address = 0x61; + budget_ci->budget.dvb_frontend = + stv0297_attach(&dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap); + if (budget_ci->budget.dvb_frontend) { + break; + } + break; + case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) budget_ci->tuner_pll_address = 0x63; budget_ci->budget.dvb_frontend = @@ -877,7 +1061,7 @@ static void frontend_init(struct budget_ci *budget_ci) } break; - case 0x1012: // Hauppauge/TT Nova-T CI budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) + case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt)) budget_ci->tuner_pll_address = 0x60; budget_ci->budget.dvb_frontend = tda10046_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap); @@ -965,10 +1149,12 @@ static struct saa7146_extension budget_extension; MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC); MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT); MAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT); +MAKE_BUDGET_INFO(ttbcci, "TT-Budget-C-CI PCI", BUDGET_TT); static struct pci_device_id pci_tbl[] = { MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c), MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f), + MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010), MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011), MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012), { -- cgit v0.10.2 From b548747d78f8840024ac3439b7149348a282e086 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 9 Sep 2005 13:03:08 -0700 Subject: [PATCH] dvb: budget-av: fixes for CI interface Fixes for CI interface. Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 311be50..8c2a290 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c @@ -192,7 +192,7 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot) { struct budget_av *budget_av = (struct budget_av *) ca->data; struct saa7146_dev *saa = budget_av->budget.dev; - int timeout = 50; // 5 seconds (4.4.6 Ready) + int timeout = 500; // 5 seconds (4.4.6 Ready) if (slot != 0) return -EINVAL; @@ -217,7 +217,6 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot) { printk(KERN_ERR "budget-av: cam reset failed (timeout).\n"); saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ - saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */ return -ETIMEDOUT; } @@ -276,7 +275,6 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open { printk(KERN_INFO "budget-av: cam ejected\n"); saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ - saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */ budget_av->slot_status = 0; } } -- cgit v0.10.2 From 87b2ecaebceb35c6f6199edd29ae24963d3f9c35 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 9 Sep 2005 13:03:09 -0700 Subject: [PATCH] dvb: budget-av: enable frontend on KNC1 Plus cards Enable frontend on KNC plus cards. Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 8c2a290..7692cd2 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c @@ -743,6 +743,7 @@ static void frontend_init(struct budget_av *budget_av) case SUBID_DVBC_KNC1_PLUS: case SUBID_DVBT_KNC1_PLUS: // Enable / PowerON Frontend + saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO); saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI); break; } -- cgit v0.10.2 From ce7d3c11aee415c76bcbd5f43cace16132b48a21 Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:03:10 -0700 Subject: [PATCH] dvb: av7110: disable superflous firmware handshake Disable superflous firmware handshake. Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c index 1220826..456d529 100644 --- a/drivers/media/dvb/ttpci/av7110_hw.c +++ b/drivers/media/dvb/ttpci/av7110_hw.c @@ -41,6 +41,8 @@ #include "av7110.h" #include "av7110_hw.h" +#define _NOHANDSHAKE + /**************************************************************************** * DEBI functions ****************************************************************************/ -- cgit v0.10.2 From 9a7b102e7f5ccb2826a81315abc89f95adaf4421 Mon Sep 17 00:00:00 2001 From: Oliver Endriss Date: Fri, 9 Sep 2005 13:03:11 -0700 Subject: [PATCH] dvb: av7110: conditionally disable workaround for broken firmware Disable COM_IF_LOCK workaround for firmware > 0x261f. Signed-off-by: Oliver Endriss Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c index 456d529..7442f56 100644 --- a/drivers/media/dvb/ttpci/av7110_hw.c +++ b/drivers/media/dvb/ttpci/av7110_hw.c @@ -366,7 +366,8 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) msleep(1); } - wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); + if (FW_VERSION(av7110->arm_app) <= 0x261f) + wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); #ifndef _NOHANDSHAKE start = jiffies; @@ -439,7 +440,8 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2); - wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2); + if (FW_VERSION(av7110->arm_app) <= 0x261f) + wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2); #ifdef COM_DEBUG start = jiffies; -- cgit v0.10.2 From 03388ae30260475650bab24223151397afb72ec9 Mon Sep 17 00:00:00 2001 From: Oliver Endriss Date: Fri, 9 Sep 2005 13:03:12 -0700 Subject: [PATCH] dvb: ttpci: av7110: RC5+ remote control support Improved remote control support for av7110-based cards: o extended rc5 protocol, firmware >= 0x2620 required o key-up timer slightly adjusted o completely moved remote control code to av7110_ir.c o support for multiple ir receivers o for now, all av7110 cards share the same ir configuration and event device Signed-off-by: Oliver Endriss Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index 48e8097..b5d40d4 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c @@ -177,9 +177,6 @@ static void init_av7110_av(struct av7110 *av7110) ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right); if (ret < 0) printk("dvb-ttpci:cannot set volume :%d\n",ret); - ret = av7110_setup_irc_config(av7110, 0); - if (ret < 0) - printk("dvb-ttpci:cannot setup irc config :%d\n",ret); } static void recover_arm(struct av7110 *av7110) @@ -265,60 +262,6 @@ static int arm_thread(void *data) } -/** - * Hack! we save the last av7110 ptr. This should be ok, since - * you rarely will use more then one IR control. - * - * If we want to support multiple controls we would have to do much more... - */ -int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config) -{ - int ret = 0; - static struct av7110 *last; - - dprintk(4, "%p\n", av7110); - - if (!av7110) - av7110 = last; - else - last = av7110; - - if (av7110) { - ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config); - av7110->ir_config = ir_config; - } - return ret; -} - -static void (*irc_handler)(u32); - -void av7110_register_irc_handler(void (*func)(u32)) -{ - dprintk(4, "registering %p\n", func); - irc_handler = func; -} - -void av7110_unregister_irc_handler(void (*func)(u32)) -{ - dprintk(4, "unregistering %p\n", func); - irc_handler = NULL; -} - -static void run_handlers(unsigned long ircom) -{ - if (irc_handler != NULL) - (*irc_handler)((u32) ircom); -} - -static DECLARE_TASKLET(irtask, run_handlers, 0); - -static void IR_handle(struct av7110 *av7110, u32 ircom) -{ - dprintk(4, "ircommand = %08x\n", ircom); - irtask.data = (unsigned long) ircom; - tasklet_schedule(&irtask); -} - /**************************************************************************** * IRQ handling ****************************************************************************/ @@ -711,8 +654,9 @@ static void gpioirq(unsigned long data) return; case DATA_IRCOMMAND: - IR_handle(av7110, - swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4))); + if (av7110->ir_handler) + av7110->ir_handler(av7110, + swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4))); iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); break; @@ -2783,7 +2727,7 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d goto err_av7110_exit_v4l_12; #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) - av7110_ir_init(); + av7110_ir_init(av7110); #endif printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num); av7110_num++; @@ -2825,6 +2769,9 @@ static int av7110_detach(struct saa7146_dev* saa) struct av7110 *av7110 = saa->ext_priv; dprintk(4, "%p\n", av7110); +#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) + av7110_ir_exit(av7110); +#endif if (budgetpatch) { /* Disable RPS1 */ saa7146_write(saa, MC1, MASK_29); @@ -2980,9 +2927,6 @@ static int __init av7110_init(void) static void __exit av7110_exit(void) { -#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) - av7110_ir_exit(); -#endif saa7146_unregister_extension(&av7110_extension); } diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h index 508b773..cce00ef 100644 --- a/drivers/media/dvb/ttpci/av7110.h +++ b/drivers/media/dvb/ttpci/av7110.h @@ -228,7 +228,10 @@ struct av7110 { struct dvb_video_events video_events; video_size_t video_size; - u32 ir_config; + u32 ir_config; + u32 ir_command; + void (*ir_handler)(struct av7110 *av7110, u32 ircom); + struct tasklet_struct ir_tasklet; /* firmware stuff */ unsigned char *bin_fw; @@ -257,12 +260,10 @@ struct av7110 { extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, u16 subpid, u16 pcrpid); -extern void av7110_register_irc_handler(void (*func)(u32)); -extern void av7110_unregister_irc_handler(void (*func)(u32)); extern int av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config); -extern int av7110_ir_init (void); -extern void av7110_ir_exit (void); +extern int av7110_ir_init(struct av7110 *av7110); +extern void av7110_ir_exit(struct av7110 *av7110); /* msp3400 i2c subaddresses */ #define MSP_WR_DEM 0x10 diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c index 665cdb8..357a372 100644 --- a/drivers/media/dvb/ttpci/av7110_ir.c +++ b/drivers/media/dvb/ttpci/av7110_ir.c @@ -7,16 +7,16 @@ #include #include "av7110.h" +#include "av7110_hw.h" -#define UP_TIMEOUT (HZ/4) +#define UP_TIMEOUT (HZ*7/25) /* enable ir debugging by or'ing debug with 16 */ -static int ir_initialized; +static int av_cnt; +static struct av7110 *av_list[4]; static struct input_dev input_dev; -static u32 ir_config; - static u16 key_map [256] = { KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_BACK, 0, KEY_POWER, KEY_MUTE, 0, KEY_INFO, @@ -53,8 +53,11 @@ static void av7110_emit_keyup(unsigned long data) static struct timer_list keyup_timer = { .function = av7110_emit_keyup }; -static void av7110_emit_key(u32 ircom) +static void av7110_emit_key(unsigned long parm) { + struct av7110 *av7110 = (struct av7110 *) parm; + u32 ir_config = av7110->ir_config; + u32 ircom = av7110->ir_command; u8 data; u8 addr; static u16 old_toggle = 0; @@ -62,19 +65,33 @@ static void av7110_emit_key(u32 ircom) u16 keycode; /* extract device address and data */ - if (ir_config & 0x0001) { - /* TODO RCMM: ? bits device address, 8 bits data */ + switch (ir_config & 0x0003) { + case 0: /* RC5: 5 bits device address, 6 bits data */ + data = ircom & 0x3f; + addr = (ircom >> 6) & 0x1f; + break; + + case 1: /* RCMM: 8(?) bits device address, 8(?) bits data */ data = ircom & 0xff; addr = (ircom >> 8) & 0xff; - } else { - /* RC5: 5 bits device address, 6 bits data */ + break; + + case 2: /* extended RC5: 5 bits device address, 7 bits data */ data = ircom & 0x3f; addr = (ircom >> 6) & 0x1f; + /* invert 7th data bit for backward compatibility with RC5 keymaps */ + if (!(ircom & 0x1000)) + data |= 0x40; + break; + + default: + printk("invalid ir_config %x\n", ir_config); + return; } keycode = key_map[data]; - dprintk(16, "#########%08x######### addr %i data 0x%02x (keycode %i)\n", + dprintk(16, "code %08x -> addr %i data 0x%02x -> keycode %i\n", ircom, addr, data, keycode); /* check device address (if selected) */ @@ -87,10 +104,10 @@ static void av7110_emit_key(u32 ircom) return; } - if (ir_config & 0x0001) + if ((ir_config & 0x0003) == 1) new_toggle = 0; /* RCMM */ else - new_toggle = (ircom & 0x800); /* RC5 */ + new_toggle = (ircom & 0x800); /* RC5, extended RC5 */ if (timer_pending(&keyup_timer)) { del_timer(&keyup_timer); @@ -137,6 +154,8 @@ static int av7110_ir_write_proc(struct file *file, const char __user *buffer, { char *page; int size = 4 + 256 * sizeof(u16); + u32 ir_config; + int i; if (count < size) return -EINVAL; @@ -153,60 +172,95 @@ static int av7110_ir_write_proc(struct file *file, const char __user *buffer, memcpy(&ir_config, page, 4); memcpy(&key_map, page + 4, 256 * sizeof(u16)); vfree(page); - av7110_setup_irc_config(NULL, ir_config); + if (FW_VERSION(av_list[0]->arm_app) >= 0x2620 && !(ir_config & 0x0001)) + ir_config |= 0x0002; /* enable extended RC5 */ + for (i = 0; i < av_cnt; i++) + av7110_setup_irc_config(av_list[i], ir_config); input_register_keys(); return count; } -int __init av7110_ir_init(void) +int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config) { - static struct proc_dir_entry *e; + int ret = 0; - if (ir_initialized) - return 0; + dprintk(4, "%p\n", av7110); + if (av7110) { + ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config); + av7110->ir_config = ir_config; + } + return ret; +} - init_timer(&keyup_timer); - keyup_timer.data = 0; - input_dev.name = "DVB on-card IR receiver"; +static void ir_handler(struct av7110 *av7110, u32 ircom) +{ + dprintk(4, "ircommand = %08x\n", ircom); + av7110->ir_command = ircom; + tasklet_schedule(&av7110->ir_tasklet); +} - /** - * enable keys - */ - set_bit(EV_KEY, input_dev.evbit); - set_bit(EV_REP, input_dev.evbit); - input_register_keys(); +int __init av7110_ir_init(struct av7110 *av7110) +{ + static struct proc_dir_entry *e; - input_register_device(&input_dev); - input_dev.timer.function = input_repeat_key; + if (av_cnt >= sizeof av_list/sizeof av_list[0]) + return -ENOSPC; - av7110_setup_irc_config(NULL, 0x0001); - av7110_register_irc_handler(av7110_emit_key); + av7110_setup_irc_config(av7110, 0x0001); + av_list[av_cnt++] = av7110; - e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL); - if (e) { - e->write_proc = av7110_ir_write_proc; - e->size = 4 + 256 * sizeof(u16); + if (av_cnt == 1) { + init_timer(&keyup_timer); + keyup_timer.data = 0; + + input_dev.name = "DVB on-card IR receiver"; + set_bit(EV_KEY, input_dev.evbit); + set_bit(EV_REP, input_dev.evbit); + input_register_keys(); + input_register_device(&input_dev); + input_dev.timer.function = input_repeat_key; + + e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL); + if (e) { + e->write_proc = av7110_ir_write_proc; + e->size = 4 + 256 * sizeof(u16); + } } - ir_initialized = 1; + tasklet_init(&av7110->ir_tasklet, av7110_emit_key, (unsigned long) av7110); + av7110->ir_handler = ir_handler; + return 0; } -void __exit av7110_ir_exit(void) +void __exit av7110_ir_exit(struct av7110 *av7110) { - if (ir_initialized == 0) + int i; + + if (av_cnt == 0) return; - del_timer_sync(&keyup_timer); - remove_proc_entry("av7110_ir", NULL); - av7110_unregister_irc_handler(av7110_emit_key); - input_unregister_device(&input_dev); - ir_initialized = 0; + + av7110->ir_handler = NULL; + tasklet_kill(&av7110->ir_tasklet); + for (i = 0; i < av_cnt; i++) + if (av_list[i] == av7110) { + av_list[i] = av_list[av_cnt-1]; + av_list[av_cnt-1] = NULL; + break; + } + + if (av_cnt == 1) { + del_timer_sync(&keyup_timer); + remove_proc_entry("av7110_ir", NULL); + input_unregister_device(&input_dev); + } + + av_cnt--; } //MODULE_AUTHOR("Holger Waechtler "); //MODULE_LICENSE("GPL"); - -- cgit v0.10.2 From 6af4ee10f0b2bec2b8c40150298a9f7c1e9e46c6 Mon Sep 17 00:00:00 2001 From: Karl Herz Date: Fri, 9 Sep 2005 13:03:13 -0700 Subject: [PATCH] dvb: ttpci: add PCI ids for old Siemens/TT DVB-C card Add PCI-ids of Siemens-DVB-C card with Technotrend manufacturer id. Signed-off-by: Karl Herz Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index b5d40d4..22b203f 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c @@ -168,7 +168,9 @@ static void init_av7110_av(struct av7110 *av7110) if (ret < 0) printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret); if (rgb_on && - (av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) { + ((av7110->dev->pci->subsystem_vendor == 0x110a) || + (av7110->dev->pci->subsystem_vendor == 0x13c2)) && + (av7110->dev->pci->subsystem_device == 0x0000)) { saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16 //saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8 } @@ -2868,7 +2870,7 @@ static struct saa7146_pci_extension_data x_var = { \ .ext_priv = x_name, \ .ext = &av7110_extension } -MAKE_AV7110_INFO(tts_1_X, "Technotrend/Hauppauge WinTV DVB-S rev1.X"); +MAKE_AV7110_INFO(tts_1_X_fsc,"Technotrend/Hauppauge WinTV DVB-S rev1.X or Fujitsu Siemens DVB-C"); MAKE_AV7110_INFO(ttt_1_X, "Technotrend/Hauppauge WinTV DVB-T rev1.X"); MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X"); MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X"); @@ -2880,16 +2882,16 @@ MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C"); MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6"); static struct pci_device_id pci_tbl[] = { - MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000), - MAKE_EXTENSION_PCI(tts_1_X, 0x13c2, 0x0000), - MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), - MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002), - MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003), - MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006), - MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008), - MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a), - MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e), - MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002), + MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000), + MAKE_EXTENSION_PCI(tts_1_X_fsc, 0x13c2, 0x0000), + MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), + MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002), + MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003), + MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006), + MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008), + MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a), + MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e), + MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002), /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1 -- cgit v0.10.2 From 1ac2854cbc637de7e958cfa8d153ccf9e6668dda Mon Sep 17 00:00:00 2001 From: Philipp Matthias Hahn Date: Fri, 9 Sep 2005 13:03:13 -0700 Subject: [PATCH] dvb: saa7146: i2c vs. sysfs fix Integrate saa7146_i2c adapter into device model: Moves entries from /sys/device/platform to /sys/device/pci*. Signed-off-by: Philipp Hahn Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c index 45f8673..fec6bea 100644 --- a/drivers/media/common/saa7146_i2c.c +++ b/drivers/media/common/saa7146_i2c.c @@ -403,6 +403,7 @@ int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c if( NULL != i2c_adapter ) { BUG_ON(!i2c_adapter->class); i2c_set_adapdata(i2c_adapter,dev); + i2c_adapter->dev.parent = &dev->pci->dev; i2c_adapter->algo = &saa7146_algo; i2c_adapter->algo_data = NULL; i2c_adapter->id = I2C_HW_SAA7146; -- cgit v0.10.2 From 4da006c63fb4758ee2d688aa65a461337b3ed065 Mon Sep 17 00:00:00 2001 From: Marcelo Feitoza Parisi Date: Fri, 9 Sep 2005 13:03:15 -0700 Subject: [PATCH] dvb: ttusb-budget: use time_after_eq() Use of the time_after_eq() macro, defined at linux/jiffies.h, which deal with wrapping correctly and are nicer to read. Signed-off-by: Marcelo Feitoza Parisi Signed-off-by: Domen Puncer Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index c1acd4b..d200ab0 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "dvb_frontend.h" @@ -570,7 +571,8 @@ static void ttusb_handle_sec_data(struct ttusb_channel *channel, const u8 * data, int len); #endif -static int numpkt = 0, lastj, numts, numstuff, numsec, numinvalid; +static int numpkt = 0, numts, numstuff, numsec, numinvalid; +static unsigned long lastj; static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack, int len) @@ -779,7 +781,7 @@ static void ttusb_iso_irq(struct urb *urb, struct pt_regs *ptregs) u8 *data; int len; numpkt++; - if ((jiffies - lastj) >= HZ) { + if (time_after_eq(jiffies, lastj + HZ)) { #if DEBUG > 2 printk ("frames/s: %d (ts: %d, stuff %d, sec: %d, invalid: %d, all: %d)\n", -- cgit v0.10.2 From 76fa82fb7156aa7191dfd1fdede1fc0da51d45dd Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Fri, 9 Sep 2005 13:03:21 -0700 Subject: [PATCH] pcmcia: reduce ds.c stack footprint This patch reduces the stack footprint of pcmcia_device_query() from 416 bytes to 36 bytes. Signed-off-by: Ingo Molnar Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 43da2e9..398146e 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -424,9 +424,13 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) { cistpl_manfid_t manf_id; cistpl_funcid_t func_id; - cistpl_vers_1_t vers1; + cistpl_vers_1_t *vers1; unsigned int i; + vers1 = kmalloc(sizeof(*vers1), GFP_KERNEL); + if (!vers1) + return -ENOMEM; + if (!pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_MANFID, &manf_id)) { p_dev->manf_id = manf_id.manf; @@ -443,23 +447,30 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) /* rule of thumb: cards with no FUNCID, but with * common memory device geometry information, are * probably memory cards (from pcmcia-cs) */ - cistpl_device_geo_t devgeo; + cistpl_device_geo_t *devgeo; + + devgeo = kmalloc(sizeof(*devgeo), GFP_KERNEL); + if (!devgeo) { + kfree(vers1); + return -ENOMEM; + } if (!pccard_read_tuple(p_dev->socket, p_dev->func, - CISTPL_DEVICE_GEO, &devgeo)) { + CISTPL_DEVICE_GEO, devgeo)) { ds_dbg(0, "mem device geometry probably means " "FUNCID_MEMORY\n"); p_dev->func_id = CISTPL_FUNCID_MEMORY; p_dev->has_func_id = 1; } + kfree(devgeo); } if (!pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_VERS_1, - &vers1)) { - for (i=0; i < vers1.ns; i++) { + vers1)) { + for (i=0; i < vers1->ns; i++) { char *tmp; unsigned int length; - tmp = vers1.str + vers1.ofs[i]; + tmp = vers1->str + vers1->ofs[i]; length = strlen(tmp) + 1; if ((length < 3) || (length > 255)) @@ -475,6 +486,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) } } + kfree(vers1); return 0; } -- cgit v0.10.2 From b3743fa4442fc172e950ff0eaf6aa96e7d5ce9be Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 9 Sep 2005 13:03:23 -0700 Subject: [PATCH] yenta: share code with PCI core Share code between setup-bus.c and yenta_socket.c: use the write-out code of resources to the bridge also in yenta_socket.c, as it provides useful debug output. In addition, it fixes the bug that the CPU-centric resource view might need to be transferred to the PCI-centric view: setup-bus.c does that, while yenta-socket.c did not. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 6b0e646..657be94 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -77,8 +77,7 @@ pbus_assign_resources_sorted(struct pci_bus *bus) } } -static void __devinit -pci_setup_cardbus(struct pci_bus *bus) +void pci_setup_cardbus(struct pci_bus *bus) { struct pci_dev *bridge = bus->self; struct pci_bus_region region; @@ -130,6 +129,7 @@ pci_setup_cardbus(struct pci_bus *bus) region.end); } } +EXPORT_SYMBOL(pci_setup_cardbus); /* Initialize bridges with base/limit values we have collected. PCI-to-PCI Bridge Architecture Specification rev. 1.1 (1998) diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 0347a29..271a52b 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -667,7 +667,7 @@ static int yenta_search_res(struct yenta_socket *socket, struct resource *res, return 0; } -static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end) +static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end) { struct resource *root, *res; struct pci_bus_region region; @@ -676,7 +676,7 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr; /* Already allocated? */ if (res->parent) - return; + return 0; /* The granularity of the memory limit is 4kB, on IO it's 4 bytes */ mask = ~0xfff; @@ -692,7 +692,7 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ pcibios_bus_to_resource(socket->dev, res, ®ion); root = pci_find_parent_resource(socket->dev, res); if (root && (request_resource(root, res) == 0)) - return; + return 0; printk(KERN_INFO "yenta %s: Preassigned resource %d busy or not available, reconfiguring...\n", pci_name(socket->dev), nr); } @@ -700,35 +700,27 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ if (type & IORESOURCE_IO) { if ((yenta_search_res(socket, res, BRIDGE_IO_MAX)) || (yenta_search_res(socket, res, BRIDGE_IO_ACC)) || - (yenta_search_res(socket, res, BRIDGE_IO_MIN))) { - config_writel(socket, addr_start, res->start); - config_writel(socket, addr_end, res->end); - return; - } + (yenta_search_res(socket, res, BRIDGE_IO_MIN))) + return 1; } else { if (type & IORESOURCE_PREFETCH) { if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) || (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) || - (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) { - config_writel(socket, addr_start, res->start); - config_writel(socket, addr_end, res->end); - return; - } + (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) + return 1; /* Approximating prefetchable by non-prefetchable */ res->flags = IORESOURCE_MEM; } if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) || (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) || - (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) { - config_writel(socket, addr_start, res->start); - config_writel(socket, addr_end, res->end); - return; - } + (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) + return 1; } printk(KERN_INFO "yenta %s: no resource of type %x available, trying to continue...\n", pci_name(socket->dev), type); res->start = res->end = res->flags = 0; + return 0; } /* @@ -736,14 +728,17 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ */ static void yenta_allocate_resources(struct yenta_socket *socket) { - yenta_allocate_res(socket, 0, IORESOURCE_IO, + int program = 0; + program += yenta_allocate_res(socket, 0, IORESOURCE_IO, PCI_CB_IO_BASE_0, PCI_CB_IO_LIMIT_0); - yenta_allocate_res(socket, 1, IORESOURCE_IO, + program += yenta_allocate_res(socket, 1, IORESOURCE_IO, PCI_CB_IO_BASE_1, PCI_CB_IO_LIMIT_1); - yenta_allocate_res(socket, 2, IORESOURCE_MEM|IORESOURCE_PREFETCH, + program += yenta_allocate_res(socket, 2, IORESOURCE_MEM|IORESOURCE_PREFETCH, PCI_CB_MEMORY_BASE_0, PCI_CB_MEMORY_LIMIT_0); - yenta_allocate_res(socket, 3, IORESOURCE_MEM, + program += yenta_allocate_res(socket, 3, IORESOURCE_MEM, PCI_CB_MEMORY_BASE_1, PCI_CB_MEMORY_LIMIT_1); + if (program) + pci_setup_cardbus(socket->dev->subordinate); } @@ -758,7 +753,7 @@ static void yenta_free_resources(struct yenta_socket *socket) res = socket->dev->resource + PCI_BRIDGE_RESOURCES + i; if (res->start != 0 && res->end != 0) release_resource(res); - res->start = res->end = 0; + res->start = res->end = res->flags = 0; } } diff --git a/include/linux/pci.h b/include/linux/pci.h index 6caaba0..c62e892 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -326,6 +326,7 @@ extern struct pci_dev *pci_dev_get(struct pci_dev *dev); extern void pci_dev_put(struct pci_dev *dev); extern void pci_remove_bus(struct pci_bus *b); extern void pci_remove_bus_device(struct pci_dev *dev); +void pci_setup_cardbus(struct pci_bus *bus); /* Generic PCI functions exported to card drivers */ -- cgit v0.10.2 From bf4de6f2db79f3c396bd884f546cd2ea91a686f2 Mon Sep 17 00:00:00 2001 From: Daniel Ritz Date: Fri, 9 Sep 2005 13:03:23 -0700 Subject: [PATCH] pcmcia/cs: fix possible missed wakeup - thread_done should only be completed when the wait_queue is installed. - all wake up conditions should be checked before schedule() this fixes a hang of rmmod in the sequence modprobe yenta_socket; rmmod yenta_socket as reported by Andreas Steinmetz. w/o this rmmod yenta_socket can hang on wait_for_completion() in pcmcia_unregister_socket() Signed-off-by: Daniel Ritz Cc: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index e39178f..fabd352 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -654,9 +654,10 @@ static int pccardd(void *__skt) skt->thread = NULL; complete_and_exit(&skt->thread_done, 0); } - complete(&skt->thread_done); add_wait_queue(&skt->thread_wait, &wait); + complete(&skt->thread_done); + for (;;) { unsigned long flags; unsigned int events; @@ -682,11 +683,11 @@ static int pccardd(void *__skt) continue; } - schedule(); - try_to_freeze(); - if (!skt->thread) break; + + schedule(); + try_to_freeze(); } remove_wait_queue(&skt->thread_wait, &wait); -- cgit v0.10.2 From c181e0e00ff778623c7fda055fd404a06d2c7845 Mon Sep 17 00:00:00 2001 From: Daniel Ritz Date: Fri, 9 Sep 2005 13:03:25 -0700 Subject: [PATCH] fix pcmcia_request_irq() for multifunction card multifunction cards need to have the same irq assigned to both functions. the code tries that but fails because ret is still set to CS_IN_USE which results in the function having the CB irq assigned. yenta_set_socket then just changes the irq routing to use the PCI interrupt but the first functions irq handler is registered on an ISA interrupt. boom. Signed-off-by: Daniel Ritz Cc: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 599b116..c0f4eb4 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -832,7 +832,8 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) } } #endif - if (ret) { + /* only assign PCI irq if no IRQ already assigned */ + if (ret && !s->irq.AssignedIRQ) { if (!s->pci_irq) return ret; irq = s->pci_irq; -- cgit v0.10.2 From c8751e4c0bd32ecb76434240a56a087fa223280c Mon Sep 17 00:00:00 2001 From: Daniel Ritz Date: Fri, 9 Sep 2005 13:03:25 -0700 Subject: [PATCH] pcmcia/yenta: avoid PCI write posting problem extend cb_writel(), exca_writeb(), exca_writel() to do a read[lb]() after the write[lb]() to avoid possible problem with PCI write posting. Seems to fix Bug #5061. Signed-off-by: Daniel Ritz Cc: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 271a52b..f0997c3 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -72,6 +72,7 @@ static inline void cb_writel(struct yenta_socket *socket, unsigned reg, u32 val) { debug("%p %04x %08x\n", socket, reg, val); writel(val, socket->base + reg); + readl(socket->base + reg); /* avoid problems with PCI write posting */ } static inline u8 config_readb(struct yenta_socket *socket, unsigned offset) @@ -136,6 +137,7 @@ static inline void exca_writeb(struct yenta_socket *socket, unsigned reg, u8 val { debug("%p %04x %02x\n", socket, reg, val); writeb(val, socket->base + 0x800 + reg); + readb(socket->base + 0x800 + reg); /* PCI write posting... */ } static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) @@ -143,6 +145,10 @@ static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) debug("%p %04x %04x\n", socket, reg, val); writeb(val, socket->base + 0x800 + reg); writeb(val >> 8, socket->base + 0x800 + reg + 1); + + /* PCI write posting... */ + readb(socket->base + 0x800 + reg); + readb(socket->base + 0x800 + reg + 1); } /* -- cgit v0.10.2 From 76d82ec526b0549cedf332d80929c8c225b653fa Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 9 Sep 2005 13:03:26 -0700 Subject: [PATCH] pcmcia: remove unused client_t client_t and CLIENT_MAGIC are unused, so remove them Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 6bbfbd0..4d5ffdc 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -17,9 +17,6 @@ #include -#define CLIENT_MAGIC 0x51E6 -typedef struct client_t client_t; - /* Flags in client state */ #define CLIENT_CONFIG_LOCKED 0x0001 #define CLIENT_IRQ_REQ 0x0002 -- cgit v0.10.2 From 71ed90d89eff51a1137cbef727f11b8f7d5b20f1 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 9 Sep 2005 13:03:27 -0700 Subject: [PATCH] pcmcia: remove unused Vpp1, Vpp2 and Vcc config_t->Vpp1, Vpp2 and Vcc are never read, so remove them. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 4d5ffdc..55867bc 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -42,7 +42,6 @@ typedef struct region_t { typedef struct config_t { u_int state; u_int Attributes; - u_int Vcc, Vpp1, Vpp2; u_int IntType; u_int ConfigBase; u_char Status, Pin, Copy, Option, ExtStatus; diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index c0f4eb4..deb6d00 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -447,7 +447,7 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { if (mod->Vpp1 != mod->Vpp2) return CS_BAD_VPP; - c->Vpp1 = c->Vpp2 = s->socket.Vpp = mod->Vpp1; + s->socket.Vpp = mod->Vpp1; if (s->ops->set_socket(s, &s->socket)) return CS_BAD_VPP; } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || @@ -623,8 +623,6 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, if (s->ops->set_socket(s, &s->socket)) return CS_BAD_VPP; - c->Vcc = req->Vcc; c->Vpp1 = c->Vpp2 = req->Vpp1; - /* Pick memory or I/O card, DMA mode, interrupt */ c->IntType = req->IntType; c->Attributes = req->Attributes; -- cgit v0.10.2 From f74e48a51c38f54fa26eb86a7a42f592156eccc2 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Fri, 9 Sep 2005 13:03:28 -0700 Subject: [PATCH] pcmcia: OMAP CF controller This adds a socket driver for the OMAP CF controller; it's currently in use on OSK boards. Signed-off-by: David Brownell Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 6485f75..ddc741e 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -221,6 +221,13 @@ config PCMCIA_VRC4173 tristate "NEC VRC4173 CARDU support" depends on CPU_VR41XX && PCI && PCMCIA +config OMAP_CF + tristate "OMAP CompactFlash Controller" + depends on PCMCIA && ARCH_OMAP16XX + help + Say Y here to support the CompactFlash controller on OMAP. + Note that this doesn't support "True IDE" mode. + config PCCARD_NONSTATIC tristate diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index ef694c7..a41fbb3 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_M32R_CFC) += m32r_cfc.o obj-$(CONFIG_PCMCIA_AU1X00) += au1x00_ss.o obj-$(CONFIG_PCMCIA_VRC4171) += vrc4171_card.o obj-$(CONFIG_PCMCIA_VRC4173) += vrc4173_cardu.o +obj-$(CONFIG_OMAP_CF) += omap_cf.o sa11xx_core-y += soc_common.o sa11xx_base.o pxa2xx_core-y += soc_common.o pxa2xx_base.o diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c new file mode 100644 index 0000000..08d1c92 --- /dev/null +++ b/drivers/pcmcia/omap_cf.c @@ -0,0 +1,373 @@ +/* + * omap_cf.c -- OMAP 16xx CompactFlash controller driver + * + * Copyright (c) 2005 David Brownell + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + + +/* NOTE: don't expect this to support many I/O cards. The 16xx chips have + * hard-wired timings to support Compact Flash memory cards; they won't work + * with various other devices (like WLAN adapters) without some external + * logic to help out. + * + * NOTE: CF controller docs disagree with address space docs as to where + * CF_BASE really lives; this is a doc erratum. + */ +#define CF_BASE 0xfffe2800 + +/* status; read after IRQ */ +#define CF_STATUS_REG __REG16(CF_BASE + 0x00) +# define CF_STATUS_BAD_READ (1 << 2) +# define CF_STATUS_BAD_WRITE (1 << 1) +# define CF_STATUS_CARD_DETECT (1 << 0) + +/* which chipselect (CS0..CS3) is used for CF (active low) */ +#define CF_CFG_REG __REG16(CF_BASE + 0x02) + +/* card reset */ +#define CF_CONTROL_REG __REG16(CF_BASE + 0x04) +# define CF_CONTROL_RESET (1 << 0) + +#define omap_cf_present() (!(CF_STATUS_REG & CF_STATUS_CARD_DETECT)) + +/*--------------------------------------------------------------------------*/ + +static const char driver_name[] = "omap_cf"; + +struct omap_cf_socket { + struct pcmcia_socket socket; + + struct timer_list timer; + unsigned present:1; + unsigned active:1; + + struct platform_device *pdev; + unsigned long phys_cf; + u_int irq; +}; + +#define POLL_INTERVAL (2 * HZ) + +#define SZ_2K (2 * SZ_1K) + +/*--------------------------------------------------------------------------*/ + +static int omap_cf_ss_init(struct pcmcia_socket *s) +{ + return 0; +} + +/* the timer is primarily to kick this socket's pccardd */ +static void omap_cf_timer(unsigned long _cf) +{ + struct omap_cf_socket *cf = (void *) _cf; + unsigned present = omap_cf_present(); + + if (present != cf->present) { + cf->present = present; + pr_debug("%s: card %s\n", driver_name, + present ? "present" : "gone"); + pcmcia_parse_events(&cf->socket, SS_DETECT); + } + + if (cf->active) + mod_timer(&cf->timer, jiffies + POLL_INTERVAL); +} + +/* This irq handler prevents "irqNNN: nobody cared" messages as drivers + * claim the card's IRQ. It may also detect some card insertions, but + * not removals; it can't always eliminate timer irqs. + */ +static irqreturn_t omap_cf_irq(int irq, void *_cf, struct pt_regs *r) +{ + omap_cf_timer((unsigned long)_cf); + return IRQ_HANDLED; +} + +static int omap_cf_get_status(struct pcmcia_socket *s, u_int *sp) +{ + if (!sp) + return -EINVAL; + + /* FIXME power management should probably be board-specific: + * - 3VCARD vs XVCARD (OSK only handles 3VCARD) + * - POWERON (switched on/off by set_socket) + */ + if (omap_cf_present()) { + struct omap_cf_socket *cf; + + *sp = SS_READY | SS_DETECT | SS_POWERON | SS_3VCARD; + cf = container_of(s, struct omap_cf_socket, socket); + s->irq.AssignedIRQ = cf->irq; + } else + *sp = 0; + return 0; +} + +static int +omap_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s) +{ + u16 control; + + /* FIXME some non-OSK boards will support power switching */ + switch (s->Vcc) { + case 0: + case 33: + break; + default: + return -EINVAL; + } + + control = CF_CONTROL_REG; + if (s->flags & SS_RESET) + CF_CONTROL_REG = CF_CONTROL_RESET; + else + CF_CONTROL_REG = 0; + + pr_debug("%s: Vcc %d, io_irq %d, flags %04x csc %04x\n", + driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask); + + return 0; +} + +static int omap_cf_ss_suspend(struct pcmcia_socket *s) +{ + pr_debug("%s: %s\n", driver_name, __FUNCTION__); + return omap_cf_set_socket(s, &dead_socket); +} + +/* regions are 2K each: mem, attrib, io (and reserved-for-ide) */ + +static int +omap_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io) +{ + struct omap_cf_socket *cf; + + cf = container_of(s, struct omap_cf_socket, socket); + io->flags &= MAP_ACTIVE|MAP_ATTRIB|MAP_16BIT; + io->start = cf->phys_cf + SZ_4K; + io->stop = io->start + SZ_2K - 1; + return 0; +} + +static int +omap_cf_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *map) +{ + struct omap_cf_socket *cf; + + if (map->card_start) + return -EINVAL; + cf = container_of(s, struct omap_cf_socket, socket); + map->static_start = cf->phys_cf; + map->flags &= MAP_ACTIVE|MAP_ATTRIB|MAP_16BIT; + if (map->flags & MAP_ATTRIB) + map->static_start += SZ_2K; + return 0; +} + +static struct pccard_operations omap_cf_ops = { + .init = omap_cf_ss_init, + .suspend = omap_cf_ss_suspend, + .get_status = omap_cf_get_status, + .set_socket = omap_cf_set_socket, + .set_io_map = omap_cf_set_io_map, + .set_mem_map = omap_cf_set_mem_map, +}; + +/*--------------------------------------------------------------------------*/ + +/* + * NOTE: right now the only board-specific platform_data is + * "what chipselect is used". Boards could want more. + */ + +static int __init omap_cf_probe(struct device *dev) +{ + unsigned seg; + struct omap_cf_socket *cf; + struct platform_device *pdev = to_platform_device(dev); + int irq; + int status; + + seg = (int) dev->platform_data; + if (seg == 0 || seg > 3) + return -ENODEV; + + /* either CFLASH.IREQ (INT_1610_CF) or some GPIO */ + irq = platform_get_irq(pdev, 0); + if (!irq) + return -EINVAL; + + cf = kcalloc(1, sizeof *cf, GFP_KERNEL); + if (!cf) + return -ENOMEM; + init_timer(&cf->timer); + cf->timer.function = omap_cf_timer; + cf->timer.data = (unsigned long) cf; + + cf->pdev = pdev; + dev_set_drvdata(dev, cf); + + /* this primarily just shuts up irq handling noise */ + status = request_irq(irq, omap_cf_irq, SA_SHIRQ, + driver_name, cf); + if (status < 0) + goto fail0; + cf->irq = irq; + cf->socket.pci_irq = irq; + + switch (seg) { + /* NOTE: CS0 could be configured too ... */ + case 1: + cf->phys_cf = OMAP_CS1_PHYS; + break; + case 2: + cf->phys_cf = OMAP_CS2_PHYS; + break; + case 3: + cf->phys_cf = omap_cs3_phys(); + break; + default: + goto fail1; + } + + /* pcmcia layer only remaps "real" memory */ + cf->socket.io_offset = (unsigned long) + ioremap(cf->phys_cf + SZ_4K, SZ_2K); + if (!cf->socket.io_offset) + goto fail1; + + if (!request_mem_region(cf->phys_cf, SZ_8K, driver_name)) + goto fail1; + + /* NOTE: CF conflicts with MMC1 */ + omap_cfg_reg(W11_1610_CF_CD1); + omap_cfg_reg(P11_1610_CF_CD2); + omap_cfg_reg(R11_1610_CF_IOIS16); + omap_cfg_reg(V10_1610_CF_IREQ); + omap_cfg_reg(W10_1610_CF_RESET); + + CF_CFG_REG = ~(1 << seg); + + pr_info("%s: cs%d on irq %d\n", driver_name, seg, irq); + + /* NOTE: better EMIFS setup might support more cards; but the + * TRM only shows how to affect regular flash signals, not their + * CF/PCMCIA variants... + */ + pr_debug("%s: cs%d, previous ccs %08x acs %08x\n", driver_name, + seg, EMIFS_CCS(seg), EMIFS_ACS(seg)); + EMIFS_CCS(seg) = 0x0004a1b3; /* synch mode 4 etc */ + EMIFS_ACS(seg) = 0x00000000; /* OE hold/setup */ + + /* CF uses armxor_ck, which is "always" available */ + + pr_debug("%s: sts %04x cfg %04x control %04x %s\n", driver_name, + CF_STATUS_REG, CF_CFG_REG, CF_CONTROL_REG, + omap_cf_present() ? "present" : "(not present)"); + + cf->socket.owner = THIS_MODULE; + cf->socket.dev.dev = dev; + cf->socket.ops = &omap_cf_ops; + cf->socket.resource_ops = &pccard_static_ops; + cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP + | SS_CAP_MEM_ALIGN; + cf->socket.map_size = SZ_2K; + + status = pcmcia_register_socket(&cf->socket); + if (status < 0) + goto fail2; + + cf->active = 1; + mod_timer(&cf->timer, jiffies + POLL_INTERVAL); + return 0; + +fail2: + iounmap((void __iomem *) cf->socket.io_offset); + release_mem_region(cf->phys_cf, SZ_8K); +fail1: + free_irq(irq, cf); +fail0: + kfree(cf); + return status; +} + +static int __devexit omap_cf_remove(struct device *dev) +{ + struct omap_cf_socket *cf = dev_get_drvdata(dev); + + cf->active = 0; + pcmcia_unregister_socket(&cf->socket); + del_timer_sync(&cf->timer); + iounmap((void __iomem *) cf->socket.io_offset); + release_mem_region(cf->phys_cf, SZ_8K); + free_irq(cf->irq, cf); + kfree(cf); + return 0; +} + +static int omap_cf_suspend(struct device *dev, pm_message_t mesg, u32 level) +{ + if (level != SUSPEND_SAVE_STATE) + return 0; + return pcmcia_socket_dev_suspend(dev, mesg); +} + +static int omap_cf_resume(struct device *dev, u32 level) +{ + if (level != RESUME_RESTORE_STATE) + return 0; + return pcmcia_socket_dev_resume(dev); +} + +static struct device_driver omap_cf_driver = { + .name = (char *) driver_name, + .bus = &platform_bus_type, + .probe = omap_cf_probe, + .remove = __devexit_p(omap_cf_remove), + .suspend = omap_cf_suspend, + .resume = omap_cf_resume, +}; + +static int __init omap_cf_init(void) +{ + if (cpu_is_omap16xx()) + driver_register(&omap_cf_driver); + return 0; +} + +static void __exit omap_cf_exit(void) +{ + if (cpu_is_omap16xx()) + driver_unregister(&omap_cf_driver); +} + +module_init(omap_cf_init); +module_exit(omap_cf_exit); + +MODULE_DESCRIPTION("OMAP CF Driver"); +MODULE_LICENSE("GPL"); -- cgit v0.10.2 From d3feb1844ad33911ab1fe9df1ead66082b3bce9b Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 9 Sep 2005 13:03:28 -0700 Subject: [PATCH] pcmcia: more IDs for ide_cs (Partly From: David Brownell ) Make ID-CS recognize the CF card manufacturer records for Samsung, Lexar and STI. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index f1d1ec4..dc0841b 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -454,9 +454,12 @@ int ide_event(event_t event, int priority, static struct pcmcia_device_id ide_ids[] = { PCMCIA_DEVICE_FUNC_ID(4), PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), + PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), + PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), + PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), - PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), + PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar */ PCMCIA_DEVICE_PROD_ID123("Caravelle", "PSC-IDE ", "PSC000", 0x8c36137c, 0xd0693ab8, 0x2768a9f0), PCMCIA_DEVICE_PROD_ID123("CDROM", "IDE", "MCD-601p", 0x1b9179ca, 0xede88951, 0x0d902f74), PCMCIA_DEVICE_PROD_ID123("PCMCIA", "IDE CARD", "F1", 0x281f1c5d, 0x1907960c, 0xf7fde8b9), @@ -481,6 +484,7 @@ static struct pcmcia_device_id ide_ids[] = { PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), + PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e), PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), PCMCIA_DEVICE_NULL, }; -- cgit v0.10.2 From bd65a68574b787304a0cd90f22cfd44540ce3695 Mon Sep 17 00:00:00 2001 From: Brice Goglin Date: Fri, 9 Sep 2005 13:03:29 -0700 Subject: [PATCH] pcmcia: add pcmcia to IRQ information Add a devname parameter to the pcmcia_device structure, fills it with "pcmcia" in pcmcia_device_add, and passes it to request_irq in pcmcia_request_irq. Signed-off-by: Brice Goglin Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 398146e..080608c 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -354,6 +354,7 @@ static void pcmcia_release_dev(struct device *dev) struct pcmcia_device *p_dev = to_pcmcia_dev(dev); ds_dbg(1, "releasing dev %p\n", p_dev); pcmcia_put_socket(p_dev->socket); + kfree(p_dev->devname); kfree(p_dev); } @@ -504,6 +505,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f { struct pcmcia_device *p_dev; unsigned long flags; + int bus_id_len; s = pcmcia_get_socket(s); if (!s) @@ -527,7 +529,12 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f p_dev->dev.bus = &pcmcia_bus_type; p_dev->dev.parent = s->dev.dev; p_dev->dev.release = pcmcia_release_dev; - sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no); + bus_id_len = sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no); + + p_dev->devname = kmalloc(6 + bus_id_len + 1, GFP_KERNEL); + if (!p_dev->devname) + goto err_free; + sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); /* compat */ p_dev->state = CLIENT_UNBOUND; @@ -552,6 +559,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f return p_dev; err_free: + kfree(p_dev->devname); kfree(p_dev); s->device_count--; err_put: diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index deb6d00..89022ad 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -820,7 +820,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || (s->functions > 1) || (irq == s->pci_irq)) ? SA_SHIRQ : 0, - p_dev->dev.bus_id, + p_dev->devname, (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Instance : data); if (!ret) { if (!(req->Attributes & IRQ_HANDLE_PRESENT)) @@ -842,7 +842,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || (s->functions > 1) || (irq == s->pci_irq)) ? SA_SHIRQ : 0, - p_dev->dev.bus_id, req->Instance)) + p_dev->devname, req->Instance)) return CS_IN_USE; } diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index b707a60..cb8b6e6 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -151,6 +151,8 @@ struct pcmcia_device { uniquely define a pcmcia_device */ struct pcmcia_socket *socket; + char *devname; + u8 device_no; /* the hardware "function" device; certain subdevices can -- cgit v0.10.2 From e498be7dafd72fd68848c1eef1575aa7c5d658df Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 9 Sep 2005 13:03:32 -0700 Subject: [PATCH] Numa-aware slab allocator V5 The NUMA API change that introduced kmalloc_node was accepted for 2.6.12-rc3. Now it is possible to do slab allocations on a node to localize memory structures. This API was used by the pageset localization patch and the block layer localization patch now in mm. The existing kmalloc_node is slow since it simply searches through all pages of the slab to find a page that is on the node requested. The two patches do a one time allocation of slab structures at initialization and therefore the speed of kmalloc node does not matter. This patch allows kmalloc_node to be as fast as kmalloc by introducing node specific page lists for partial, free and full slabs. Slab allocation improves in a NUMA system so that we are seeing a performance gain in AIM7 of about 5% with this patch alone. More NUMA localizations are possible if kmalloc_node operates in an fast way like kmalloc. Test run on a 32p systems with 32G Ram. w/o patch Tasks jobs/min jti jobs/min/task real cpu 1 485.36 100 485.3640 11.99 1.91 Sat Apr 30 14:01:51 2005 100 26582.63 88 265.8263 21.89 144.96 Sat Apr 30 14:02:14 2005 200 29866.83 81 149.3342 38.97 286.08 Sat Apr 30 14:02:53 2005 300 33127.16 78 110.4239 52.71 426.54 Sat Apr 30 14:03:46 2005 400 34889.47 80 87.2237 66.72 568.90 Sat Apr 30 14:04:53 2005 500 35654.34 76 71.3087 81.62 714.55 Sat Apr 30 14:06:15 2005 600 36460.83 75 60.7681 95.77 853.42 Sat Apr 30 14:07:51 2005 700 35957.00 75 51.3671 113.30 990.67 Sat Apr 30 14:09:45 2005 800 33380.65 73 41.7258 139.48 1140.86 Sat Apr 30 14:12:05 2005 900 35095.01 76 38.9945 149.25 1281.30 Sat Apr 30 14:14:35 2005 1000 36094.37 74 36.0944 161.24 1419.66 Sat Apr 30 14:17:17 2005 w/patch Tasks jobs/min jti jobs/min/task real cpu 1 484.27 100 484.2736 12.02 1.93 Sat Apr 30 15:59:45 2005 100 28262.03 90 282.6203 20.59 143.57 Sat Apr 30 16:00:06 2005 200 32246.45 82 161.2322 36.10 282.89 Sat Apr 30 16:00:42 2005 300 37945.80 83 126.4860 46.01 418.75 Sat Apr 30 16:01:28 2005 400 40000.69 81 100.0017 58.20 561.48 Sat Apr 30 16:02:27 2005 500 40976.10 78 81.9522 71.02 696.95 Sat Apr 30 16:03:38 2005 600 41121.54 78 68.5359 84.92 834.86 Sat Apr 30 16:05:04 2005 700 44052.77 78 62.9325 92.48 971.53 Sat Apr 30 16:06:37 2005 800 41066.89 79 51.3336 113.38 1111.15 Sat Apr 30 16:08:31 2005 900 38918.77 79 43.2431 134.59 1252.57 Sat Apr 30 16:10:46 2005 1000 41842.21 76 41.8422 139.09 1392.33 Sat Apr 30 16:13:05 2005 These are measurement taken directly after boot and show a greater improvement than 5%. However, the performance improvements become less over time if the AIM7 runs are repeated and settle down at around 5%. Links to earlier discussions: http://marc.theaimsgroup.com/?t=111094594500003&r=1&w=2 http://marc.theaimsgroup.com/?t=111603406600002&r=1&w=2 Changelog V4-V5: - alloc_arraycache and alloc_aliencache take node parameter instead of cpu - fix initialization so that nodes without cpus are properly handled. - simplify code in kmem_cache_init - patch against Andrews temp mm3 release - Add Shai to credits - fallback to __cache_alloc from __cache_alloc_node if the node's cache is not available yet. Changelog V3-V4: - Patch against 2.6.12-rc5-mm1 - Cleanup patch integrated - More and better use of for_each_node and for_each_cpu - GCC 2.95 fix (do not use [] use [0]) - Correct determination of INDEX_AC - Remove hack to cause an error on platforms that have no CONFIG_NUMA but nodes. - Remove list3_data and list3_data_ptr macros for better readability Changelog V2-V3: - Made to patch against 2.6.12-rc4-mm1 - Revised bootstrap mechanism so that larger size kmem_list3 structs can be supported. Do a generic solution so that the right slab can be found for the internal structs. - use for_each_online_node Changelog V1-V2: - Batching for freeing of wrong-node objects (alien caches) - Locking changes and NUMA #ifdefs as requested by Manfred Signed-off-by: Alok N Kataria Signed-off-by: Shobhit Dayal Signed-off-by: Shai Fultheim Signed-off-by: Christoph Lameter Cc: Manfred Spraul Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/mm/slab.c b/mm/slab.c index d7c4443..a041c53 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -75,6 +75,15 @@ * * At present, each engine can be growing a cache. This should be blocked. * + * 15 March 2005. NUMA slab allocator. + * Shai Fultheim . + * Shobhit Dayal + * Alok N Kataria + * Christoph Lameter + * + * Modified the slab allocator to be node aware on NUMA systems. + * Each node has its own list of partial, free and full slabs. + * All object allocations for a node occur from node specific slab lists. */ #include @@ -93,6 +102,7 @@ #include #include #include +#include #include #include @@ -212,6 +222,7 @@ struct slab { void *s_mem; /* including colour offset */ unsigned int inuse; /* num of objs active in slab */ kmem_bufctl_t free; + unsigned short nodeid; }; /* @@ -239,7 +250,6 @@ struct slab_rcu { /* * struct array_cache * - * Per cpu structures * Purpose: * - LIFO ordering, to hand out cache-warm objects from _alloc * - reduce the number of linked list operations @@ -254,6 +264,13 @@ struct array_cache { unsigned int limit; unsigned int batchcount; unsigned int touched; + spinlock_t lock; + void *entry[0]; /* + * Must have this definition in here for the proper + * alignment of array_cache. Also simplifies accessing + * the entries. + * [0] is for gcc 2.95. It should really be []. + */ }; /* bootstrap: The caches do not work without cpuarrays anymore, @@ -266,34 +283,83 @@ struct arraycache_init { }; /* - * The slab lists of all objects. - * Hopefully reduce the internal fragmentation - * NUMA: The spinlock could be moved from the kmem_cache_t - * into this structure, too. Figure out what causes - * fewer cross-node spinlock operations. + * The slab lists for all objects. */ struct kmem_list3 { struct list_head slabs_partial; /* partial list first, better asm code */ struct list_head slabs_full; struct list_head slabs_free; unsigned long free_objects; - int free_touched; unsigned long next_reap; - struct array_cache *shared; + int free_touched; + unsigned int free_limit; + spinlock_t list_lock; + struct array_cache *shared; /* shared per node */ + struct array_cache **alien; /* on other nodes */ }; -#define LIST3_INIT(parent) \ - { \ - .slabs_full = LIST_HEAD_INIT(parent.slabs_full), \ - .slabs_partial = LIST_HEAD_INIT(parent.slabs_partial), \ - .slabs_free = LIST_HEAD_INIT(parent.slabs_free) \ +/* + * Need this for bootstrapping a per node allocator. + */ +#define NUM_INIT_LISTS (2 * MAX_NUMNODES + 1) +struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS]; +#define CACHE_CACHE 0 +#define SIZE_AC 1 +#define SIZE_L3 (1 + MAX_NUMNODES) + +/* + * This function may be completely optimized away if + * a constant is passed to it. Mostly the same as + * what is in linux/slab.h except it returns an + * index. + */ +static inline int index_of(const size_t size) +{ + if (__builtin_constant_p(size)) { + int i = 0; + +#define CACHE(x) \ + if (size <=x) \ + return i; \ + else \ + i++; +#include "linux/kmalloc_sizes.h" +#undef CACHE + { + extern void __bad_size(void); + __bad_size(); + } } -#define list3_data(cachep) \ - (&(cachep)->lists) + return 0; +} + +#define INDEX_AC index_of(sizeof(struct arraycache_init)) +#define INDEX_L3 index_of(sizeof(struct kmem_list3)) + +static inline void kmem_list3_init(struct kmem_list3 *parent) +{ + INIT_LIST_HEAD(&parent->slabs_full); + INIT_LIST_HEAD(&parent->slabs_partial); + INIT_LIST_HEAD(&parent->slabs_free); + parent->shared = NULL; + parent->alien = NULL; + spin_lock_init(&parent->list_lock); + parent->free_objects = 0; + parent->free_touched = 0; +} -/* NUMA: per-node */ -#define list3_data_ptr(cachep, ptr) \ - list3_data(cachep) +#define MAKE_LIST(cachep, listp, slab, nodeid) \ + do { \ + INIT_LIST_HEAD(listp); \ + list_splice(&(cachep->nodelists[nodeid]->slab), listp); \ + } while (0) + +#define MAKE_ALL_LISTS(cachep, ptr, nodeid) \ + do { \ + MAKE_LIST((cachep), (&(ptr)->slabs_full), slabs_full, nodeid); \ + MAKE_LIST((cachep), (&(ptr)->slabs_partial), slabs_partial, nodeid); \ + MAKE_LIST((cachep), (&(ptr)->slabs_free), slabs_free, nodeid); \ + } while (0) /* * kmem_cache_t @@ -306,13 +372,12 @@ struct kmem_cache_s { struct array_cache *array[NR_CPUS]; unsigned int batchcount; unsigned int limit; -/* 2) touched by every alloc & free from the backend */ - struct kmem_list3 lists; - /* NUMA: kmem_3list_t *nodelists[MAX_NUMNODES] */ + unsigned int shared; unsigned int objsize; +/* 2) touched by every alloc & free from the backend */ + struct kmem_list3 *nodelists[MAX_NUMNODES]; unsigned int flags; /* constant flags */ unsigned int num; /* # of objs per slab */ - unsigned int free_limit; /* upper limit of objects in the lists */ spinlock_t spinlock; /* 3) cache_grow/shrink */ @@ -349,6 +414,7 @@ struct kmem_cache_s { unsigned long errors; unsigned long max_freeable; unsigned long node_allocs; + unsigned long node_frees; atomic_t allochit; atomic_t allocmiss; atomic_t freehit; @@ -384,6 +450,7 @@ struct kmem_cache_s { } while (0) #define STATS_INC_ERR(x) ((x)->errors++) #define STATS_INC_NODEALLOCS(x) ((x)->node_allocs++) +#define STATS_INC_NODEFREES(x) ((x)->node_frees++) #define STATS_SET_FREEABLE(x, i) \ do { if ((x)->max_freeable < i) \ (x)->max_freeable = i; \ @@ -402,6 +469,7 @@ struct kmem_cache_s { #define STATS_SET_HIGH(x) do { } while (0) #define STATS_INC_ERR(x) do { } while (0) #define STATS_INC_NODEALLOCS(x) do { } while (0) +#define STATS_INC_NODEFREES(x) do { } while (0) #define STATS_SET_FREEABLE(x, i) \ do { } while (0) @@ -534,9 +602,9 @@ static struct arraycache_init initarray_generic = /* internal cache of cache description objs */ static kmem_cache_t cache_cache = { - .lists = LIST3_INIT(cache_cache.lists), .batchcount = 1, .limit = BOOT_CPUCACHE_ENTRIES, + .shared = 1, .objsize = sizeof(kmem_cache_t), .flags = SLAB_NO_REAP, .spinlock = SPIN_LOCK_UNLOCKED, @@ -557,7 +625,6 @@ static struct list_head cache_chain; * SLAB_RECLAIM_ACCOUNT turns this on per-slab */ atomic_t slab_reclaim_pages; -EXPORT_SYMBOL(slab_reclaim_pages); /* * chicken and egg problem: delay the per-cpu array allocation @@ -565,7 +632,8 @@ EXPORT_SYMBOL(slab_reclaim_pages); */ static enum { NONE, - PARTIAL, + PARTIAL_AC, + PARTIAL_L3, FULL } g_cpucache_up; @@ -574,11 +642,7 @@ static DEFINE_PER_CPU(struct work_struct, reap_work); static void free_block(kmem_cache_t* cachep, void** objpp, int len); static void enable_cpucache (kmem_cache_t *cachep); static void cache_reap (void *unused); - -static inline void **ac_entry(struct array_cache *ac) -{ - return (void**)(ac+1); -} +static int __node_shrink(kmem_cache_t *cachep, int node); static inline struct array_cache *ac_data(kmem_cache_t *cachep) { @@ -676,48 +740,160 @@ static void __devinit start_cpu_timer(int cpu) } } -static struct array_cache *alloc_arraycache(int cpu, int entries, +static struct array_cache *alloc_arraycache(int node, int entries, int batchcount) { int memsize = sizeof(void*)*entries+sizeof(struct array_cache); struct array_cache *nc = NULL; - if (cpu == -1) - nc = kmalloc(memsize, GFP_KERNEL); - else - nc = kmalloc_node(memsize, GFP_KERNEL, cpu_to_node(cpu)); - + nc = kmalloc_node(memsize, GFP_KERNEL, node); if (nc) { nc->avail = 0; nc->limit = entries; nc->batchcount = batchcount; nc->touched = 0; + spin_lock_init(&nc->lock); } return nc; } +#ifdef CONFIG_NUMA +static inline struct array_cache **alloc_alien_cache(int node, int limit) +{ + struct array_cache **ac_ptr; + int memsize = sizeof(void*)*MAX_NUMNODES; + int i; + + if (limit > 1) + limit = 12; + ac_ptr = kmalloc_node(memsize, GFP_KERNEL, node); + if (ac_ptr) { + for_each_node(i) { + if (i == node || !node_online(i)) { + ac_ptr[i] = NULL; + continue; + } + ac_ptr[i] = alloc_arraycache(node, limit, 0xbaadf00d); + if (!ac_ptr[i]) { + for (i--; i <=0; i--) + kfree(ac_ptr[i]); + kfree(ac_ptr); + return NULL; + } + } + } + return ac_ptr; +} + +static inline void free_alien_cache(struct array_cache **ac_ptr) +{ + int i; + + if (!ac_ptr) + return; + + for_each_node(i) + kfree(ac_ptr[i]); + + kfree(ac_ptr); +} + +static inline void __drain_alien_cache(kmem_cache_t *cachep, struct array_cache *ac, int node) +{ + struct kmem_list3 *rl3 = cachep->nodelists[node]; + + if (ac->avail) { + spin_lock(&rl3->list_lock); + free_block(cachep, ac->entry, ac->avail); + ac->avail = 0; + spin_unlock(&rl3->list_lock); + } +} + +static void drain_alien_cache(kmem_cache_t *cachep, struct kmem_list3 *l3) +{ + int i=0; + struct array_cache *ac; + unsigned long flags; + + for_each_online_node(i) { + ac = l3->alien[i]; + if (ac) { + spin_lock_irqsave(&ac->lock, flags); + __drain_alien_cache(cachep, ac, i); + spin_unlock_irqrestore(&ac->lock, flags); + } + } +} +#else +#define alloc_alien_cache(node, limit) do { } while (0) +#define free_alien_cache(ac_ptr) do { } while (0) +#define drain_alien_cache(cachep, l3) do { } while (0) +#endif + static int __devinit cpuup_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { long cpu = (long)hcpu; kmem_cache_t* cachep; + struct kmem_list3 *l3 = NULL; + int node = cpu_to_node(cpu); + int memsize = sizeof(struct kmem_list3); + struct array_cache *nc = NULL; switch (action) { case CPU_UP_PREPARE: down(&cache_chain_sem); + /* we need to do this right in the beginning since + * alloc_arraycache's are going to use this list. + * kmalloc_node allows us to add the slab to the right + * kmem_list3 and not this cpu's kmem_list3 + */ + list_for_each_entry(cachep, &cache_chain, next) { - struct array_cache *nc; + /* setup the size64 kmemlist for cpu before we can + * begin anything. Make sure some other cpu on this + * node has not already allocated this + */ + if (!cachep->nodelists[node]) { + if (!(l3 = kmalloc_node(memsize, + GFP_KERNEL, node))) + goto bad; + kmem_list3_init(l3); + l3->next_reap = jiffies + REAPTIMEOUT_LIST3 + + ((unsigned long)cachep)%REAPTIMEOUT_LIST3; + + cachep->nodelists[node] = l3; + } + + spin_lock_irq(&cachep->nodelists[node]->list_lock); + cachep->nodelists[node]->free_limit = + (1 + nr_cpus_node(node)) * + cachep->batchcount + cachep->num; + spin_unlock_irq(&cachep->nodelists[node]->list_lock); + } - nc = alloc_arraycache(cpu, cachep->limit, cachep->batchcount); + /* Now we can go ahead with allocating the shared array's + & array cache's */ + list_for_each_entry(cachep, &cache_chain, next) { + nc = alloc_arraycache(node, cachep->limit, + cachep->batchcount); if (!nc) goto bad; - - spin_lock_irq(&cachep->spinlock); cachep->array[cpu] = nc; - cachep->free_limit = (1+num_online_cpus())*cachep->batchcount - + cachep->num; - spin_unlock_irq(&cachep->spinlock); + l3 = cachep->nodelists[node]; + BUG_ON(!l3); + if (!l3->shared) { + if (!(nc = alloc_arraycache(node, + cachep->shared*cachep->batchcount, + 0xbaadf00d))) + goto bad; + + /* we are serialised from CPU_DEAD or + CPU_UP_CANCELLED by the cpucontrol lock */ + l3->shared = nc; + } } up(&cache_chain_sem); break; @@ -732,13 +908,51 @@ static int __devinit cpuup_callback(struct notifier_block *nfb, list_for_each_entry(cachep, &cache_chain, next) { struct array_cache *nc; + cpumask_t mask; + mask = node_to_cpumask(node); spin_lock_irq(&cachep->spinlock); /* cpu is dead; no one can alloc from it. */ nc = cachep->array[cpu]; cachep->array[cpu] = NULL; - cachep->free_limit -= cachep->batchcount; - free_block(cachep, ac_entry(nc), nc->avail); + l3 = cachep->nodelists[node]; + + if (!l3) + goto unlock_cache; + + spin_lock(&l3->list_lock); + + /* Free limit for this kmem_list3 */ + l3->free_limit -= cachep->batchcount; + if (nc) + free_block(cachep, nc->entry, nc->avail); + + if (!cpus_empty(mask)) { + spin_unlock(&l3->list_lock); + goto unlock_cache; + } + + if (l3->shared) { + free_block(cachep, l3->shared->entry, + l3->shared->avail); + kfree(l3->shared); + l3->shared = NULL; + } + if (l3->alien) { + drain_alien_cache(cachep, l3); + free_alien_cache(l3->alien); + l3->alien = NULL; + } + + /* free slabs belonging to this node */ + if (__node_shrink(cachep, node)) { + cachep->nodelists[node] = NULL; + spin_unlock(&l3->list_lock); + kfree(l3); + } else { + spin_unlock(&l3->list_lock); + } +unlock_cache: spin_unlock_irq(&cachep->spinlock); kfree(nc); } @@ -754,6 +968,25 @@ bad: static struct notifier_block cpucache_notifier = { &cpuup_callback, NULL, 0 }; +/* + * swap the static kmem_list3 with kmalloced memory + */ +static void init_list(kmem_cache_t *cachep, struct kmem_list3 *list, + int nodeid) +{ + struct kmem_list3 *ptr; + + BUG_ON(cachep->nodelists[nodeid] != list); + ptr = kmalloc_node(sizeof(struct kmem_list3), GFP_KERNEL, nodeid); + BUG_ON(!ptr); + + local_irq_disable(); + memcpy(ptr, list, sizeof(struct kmem_list3)); + MAKE_ALL_LISTS(cachep, ptr, nodeid); + cachep->nodelists[nodeid] = ptr; + local_irq_enable(); +} + /* Initialisation. * Called after the gfp() functions have been enabled, and before smp_init(). */ @@ -762,6 +995,13 @@ void __init kmem_cache_init(void) size_t left_over; struct cache_sizes *sizes; struct cache_names *names; + int i; + + for (i = 0; i < NUM_INIT_LISTS; i++) { + kmem_list3_init(&initkmem_list3[i]); + if (i < MAX_NUMNODES) + cache_cache.nodelists[i] = NULL; + } /* * Fragmentation resistance on low memory - only use bigger @@ -770,21 +1010,24 @@ void __init kmem_cache_init(void) if (num_physpages > (32 << 20) >> PAGE_SHIFT) slab_break_gfp_order = BREAK_GFP_ORDER_HI; - /* Bootstrap is tricky, because several objects are allocated * from caches that do not exist yet: * 1) initialize the cache_cache cache: it contains the kmem_cache_t * structures of all caches, except cache_cache itself: cache_cache * is statically allocated. - * Initially an __init data area is used for the head array, it's - * replaced with a kmalloc allocated array at the end of the bootstrap. + * Initially an __init data area is used for the head array and the + * kmem_list3 structures, it's replaced with a kmalloc allocated + * array at the end of the bootstrap. * 2) Create the first kmalloc cache. - * The kmem_cache_t for the new cache is allocated normally. An __init - * data area is used for the head array. - * 3) Create the remaining kmalloc caches, with minimally sized head arrays. + * The kmem_cache_t for the new cache is allocated normally. + * An __init data area is used for the head array. + * 3) Create the remaining kmalloc caches, with minimally sized + * head arrays. * 4) Replace the __init data head arrays for cache_cache and the first * kmalloc cache with kmalloc allocated arrays. - * 5) Resize the head arrays of the kmalloc caches to their final sizes. + * 5) Replace the __init data for kmem_list3 for cache_cache and + * the other cache's with kmalloc allocated memory. + * 6) Resize the head arrays of the kmalloc caches to their final sizes. */ /* 1) create the cache_cache */ @@ -793,6 +1036,7 @@ void __init kmem_cache_init(void) list_add(&cache_cache.next, &cache_chain); cache_cache.colour_off = cache_line_size(); cache_cache.array[smp_processor_id()] = &initarray_cache.cache; + cache_cache.nodelists[numa_node_id()] = &initkmem_list3[CACHE_CACHE]; cache_cache.objsize = ALIGN(cache_cache.objsize, cache_line_size()); @@ -810,15 +1054,33 @@ void __init kmem_cache_init(void) sizes = malloc_sizes; names = cache_names; + /* Initialize the caches that provide memory for the array cache + * and the kmem_list3 structures first. + * Without this, further allocations will bug + */ + + sizes[INDEX_AC].cs_cachep = kmem_cache_create(names[INDEX_AC].name, + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_MINALIGN, + (ARCH_KMALLOC_FLAGS | SLAB_PANIC), NULL, NULL); + + if (INDEX_AC != INDEX_L3) + sizes[INDEX_L3].cs_cachep = + kmem_cache_create(names[INDEX_L3].name, + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_MINALIGN, + (ARCH_KMALLOC_FLAGS | SLAB_PANIC), NULL, NULL); + while (sizes->cs_size != ULONG_MAX) { - /* For performance, all the general caches are L1 aligned. + /* + * For performance, all the general caches are L1 aligned. * This should be particularly beneficial on SMP boxes, as it * eliminates "false sharing". * Note for systems short on memory removing the alignment will - * allow tighter packing of the smaller caches. */ - sizes->cs_cachep = kmem_cache_create(names->name, - sizes->cs_size, ARCH_KMALLOC_MINALIGN, - (ARCH_KMALLOC_FLAGS | SLAB_PANIC), NULL, NULL); + * allow tighter packing of the smaller caches. + */ + if(!sizes->cs_cachep) + sizes->cs_cachep = kmem_cache_create(names->name, + sizes->cs_size, ARCH_KMALLOC_MINALIGN, + (ARCH_KMALLOC_FLAGS | SLAB_PANIC), NULL, NULL); /* Inc off-slab bufctl limit until the ceiling is hit. */ if (!(OFF_SLAB(sizes->cs_cachep))) { @@ -837,24 +1099,47 @@ void __init kmem_cache_init(void) /* 4) Replace the bootstrap head arrays */ { void * ptr; - + ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); + local_irq_disable(); BUG_ON(ac_data(&cache_cache) != &initarray_cache.cache); - memcpy(ptr, ac_data(&cache_cache), sizeof(struct arraycache_init)); + memcpy(ptr, ac_data(&cache_cache), + sizeof(struct arraycache_init)); cache_cache.array[smp_processor_id()] = ptr; local_irq_enable(); - + ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); + local_irq_disable(); - BUG_ON(ac_data(malloc_sizes[0].cs_cachep) != &initarray_generic.cache); - memcpy(ptr, ac_data(malloc_sizes[0].cs_cachep), + BUG_ON(ac_data(malloc_sizes[INDEX_AC].cs_cachep) + != &initarray_generic.cache); + memcpy(ptr, ac_data(malloc_sizes[INDEX_AC].cs_cachep), sizeof(struct arraycache_init)); - malloc_sizes[0].cs_cachep->array[smp_processor_id()] = ptr; + malloc_sizes[INDEX_AC].cs_cachep->array[smp_processor_id()] = + ptr; local_irq_enable(); } + /* 5) Replace the bootstrap kmem_list3's */ + { + int node; + /* Replace the static kmem_list3 structures for the boot cpu */ + init_list(&cache_cache, &initkmem_list3[CACHE_CACHE], + numa_node_id()); + + for_each_online_node(node) { + init_list(malloc_sizes[INDEX_AC].cs_cachep, + &initkmem_list3[SIZE_AC+node], node); + + if (INDEX_AC != INDEX_L3) { + init_list(malloc_sizes[INDEX_L3].cs_cachep, + &initkmem_list3[SIZE_L3+node], + node); + } + } + } - /* 5) resize the head arrays to their final sizes */ + /* 6) resize the head arrays to their final sizes */ { kmem_cache_t *cachep; down(&cache_chain_sem); @@ -870,7 +1155,6 @@ void __init kmem_cache_init(void) * that initializes ac_data for all new cpus */ register_cpu_notifier(&cpucache_notifier); - /* The reap timers are started later, with a module init call: * That part of the kernel is not yet operational. @@ -885,10 +1169,8 @@ static int __init cpucache_init(void) * Register the timers that return unneeded * pages to gfp. */ - for (cpu = 0; cpu < NR_CPUS; cpu++) { - if (cpu_online(cpu)) - start_cpu_timer(cpu); - } + for_each_online_cpu(cpu) + start_cpu_timer(cpu); return 0; } @@ -1167,6 +1449,20 @@ static void slab_destroy (kmem_cache_t *cachep, struct slab *slabp) } } +/* For setting up all the kmem_list3s for cache whose objsize is same + as size of kmem_list3. */ +static inline void set_up_list3s(kmem_cache_t *cachep, int index) +{ + int node; + + for_each_online_node(node) { + cachep->nodelists[node] = &initkmem_list3[index+node]; + cachep->nodelists[node]->next_reap = jiffies + + REAPTIMEOUT_LIST3 + + ((unsigned long)cachep)%REAPTIMEOUT_LIST3; + } +} + /** * kmem_cache_create - Create a cache. * @name: A string which is used in /proc/slabinfo to identify this cache. @@ -1320,7 +1616,7 @@ kmem_cache_create (const char *name, size_t size, size_t align, size += BYTES_PER_WORD; } #if FORCED_DEBUG && defined(CONFIG_DEBUG_PAGEALLOC) - if (size > 128 && cachep->reallen > cache_line_size() && size < PAGE_SIZE) { + if (size >= malloc_sizes[INDEX_L3+1].cs_size && cachep->reallen > cache_line_size() && size < PAGE_SIZE) { cachep->dbghead += PAGE_SIZE - size; size = PAGE_SIZE; } @@ -1422,10 +1718,6 @@ next: cachep->gfpflags |= GFP_DMA; spin_lock_init(&cachep->spinlock); cachep->objsize = size; - /* NUMA */ - INIT_LIST_HEAD(&cachep->lists.slabs_full); - INIT_LIST_HEAD(&cachep->lists.slabs_partial); - INIT_LIST_HEAD(&cachep->lists.slabs_free); if (flags & CFLGS_OFF_SLAB) cachep->slabp_cache = kmem_find_general_cachep(slab_size,0); @@ -1444,11 +1736,43 @@ next: * the cache that's used by kmalloc(24), otherwise * the creation of further caches will BUG(). */ - cachep->array[smp_processor_id()] = &initarray_generic.cache; - g_cpucache_up = PARTIAL; + cachep->array[smp_processor_id()] = + &initarray_generic.cache; + + /* If the cache that's used by + * kmalloc(sizeof(kmem_list3)) is the first cache, + * then we need to set up all its list3s, otherwise + * the creation of further caches will BUG(). + */ + set_up_list3s(cachep, SIZE_AC); + if (INDEX_AC == INDEX_L3) + g_cpucache_up = PARTIAL_L3; + else + g_cpucache_up = PARTIAL_AC; } else { - cachep->array[smp_processor_id()] = kmalloc(sizeof(struct arraycache_init),GFP_KERNEL); + cachep->array[smp_processor_id()] = + kmalloc(sizeof(struct arraycache_init), + GFP_KERNEL); + + if (g_cpucache_up == PARTIAL_AC) { + set_up_list3s(cachep, SIZE_L3); + g_cpucache_up = PARTIAL_L3; + } else { + int node; + for_each_online_node(node) { + + cachep->nodelists[node] = + kmalloc_node(sizeof(struct kmem_list3), + GFP_KERNEL, node); + BUG_ON(!cachep->nodelists[node]); + kmem_list3_init(cachep->nodelists[node]); + } + } } + cachep->nodelists[numa_node_id()]->next_reap = + jiffies + REAPTIMEOUT_LIST3 + + ((unsigned long)cachep)%REAPTIMEOUT_LIST3; + BUG_ON(!ac_data(cachep)); ac_data(cachep)->avail = 0; ac_data(cachep)->limit = BOOT_CPUCACHE_ENTRIES; @@ -1456,13 +1780,8 @@ next: ac_data(cachep)->touched = 0; cachep->batchcount = 1; cachep->limit = BOOT_CPUCACHE_ENTRIES; - cachep->free_limit = (1+num_online_cpus())*cachep->batchcount - + cachep->num; } - cachep->lists.next_reap = jiffies + REAPTIMEOUT_LIST3 + - ((unsigned long)cachep)%REAPTIMEOUT_LIST3; - /* Need the semaphore to access the chain. */ down(&cache_chain_sem); { @@ -1519,13 +1838,23 @@ static void check_spinlock_acquired(kmem_cache_t *cachep) { #ifdef CONFIG_SMP check_irq_off(); - BUG_ON(spin_trylock(&cachep->spinlock)); + assert_spin_locked(&cachep->nodelists[numa_node_id()]->list_lock); #endif } + +static inline void check_spinlock_acquired_node(kmem_cache_t *cachep, int node) +{ +#ifdef CONFIG_SMP + check_irq_off(); + assert_spin_locked(&cachep->nodelists[node]->list_lock); +#endif +} + #else #define check_irq_off() do { } while(0) #define check_irq_on() do { } while(0) #define check_spinlock_acquired(x) do { } while(0) +#define check_spinlock_acquired_node(x, y) do { } while(0) #endif /* @@ -1547,7 +1876,7 @@ static void smp_call_function_all_cpus(void (*func) (void *arg), void *arg) } static void drain_array_locked(kmem_cache_t* cachep, - struct array_cache *ac, int force); + struct array_cache *ac, int force, int node); static void do_drain(void *arg) { @@ -1556,59 +1885,82 @@ static void do_drain(void *arg) check_irq_off(); ac = ac_data(cachep); - spin_lock(&cachep->spinlock); - free_block(cachep, &ac_entry(ac)[0], ac->avail); - spin_unlock(&cachep->spinlock); + spin_lock(&cachep->nodelists[numa_node_id()]->list_lock); + free_block(cachep, ac->entry, ac->avail); + spin_unlock(&cachep->nodelists[numa_node_id()]->list_lock); ac->avail = 0; } static void drain_cpu_caches(kmem_cache_t *cachep) { + struct kmem_list3 *l3; + int node; + smp_call_function_all_cpus(do_drain, cachep); check_irq_on(); spin_lock_irq(&cachep->spinlock); - if (cachep->lists.shared) - drain_array_locked(cachep, cachep->lists.shared, 1); + for_each_online_node(node) { + l3 = cachep->nodelists[node]; + if (l3) { + spin_lock(&l3->list_lock); + drain_array_locked(cachep, l3->shared, 1, node); + spin_unlock(&l3->list_lock); + if (l3->alien) + drain_alien_cache(cachep, l3); + } + } spin_unlock_irq(&cachep->spinlock); } - -/* NUMA shrink all list3s */ -static int __cache_shrink(kmem_cache_t *cachep) +static int __node_shrink(kmem_cache_t *cachep, int node) { struct slab *slabp; + struct kmem_list3 *l3 = cachep->nodelists[node]; int ret; - drain_cpu_caches(cachep); - - check_irq_on(); - spin_lock_irq(&cachep->spinlock); - - for(;;) { + for (;;) { struct list_head *p; - p = cachep->lists.slabs_free.prev; - if (p == &cachep->lists.slabs_free) + p = l3->slabs_free.prev; + if (p == &l3->slabs_free) break; - slabp = list_entry(cachep->lists.slabs_free.prev, struct slab, list); + slabp = list_entry(l3->slabs_free.prev, struct slab, list); #if DEBUG if (slabp->inuse) BUG(); #endif list_del(&slabp->list); - cachep->lists.free_objects -= cachep->num; - spin_unlock_irq(&cachep->spinlock); + l3->free_objects -= cachep->num; + spin_unlock_irq(&l3->list_lock); slab_destroy(cachep, slabp); - spin_lock_irq(&cachep->spinlock); + spin_lock_irq(&l3->list_lock); } - ret = !list_empty(&cachep->lists.slabs_full) || - !list_empty(&cachep->lists.slabs_partial); - spin_unlock_irq(&cachep->spinlock); + ret = !list_empty(&l3->slabs_full) || + !list_empty(&l3->slabs_partial); return ret; } +static int __cache_shrink(kmem_cache_t *cachep) +{ + int ret = 0, i = 0; + struct kmem_list3 *l3; + + drain_cpu_caches(cachep); + + check_irq_on(); + for_each_online_node(i) { + l3 = cachep->nodelists[i]; + if (l3) { + spin_lock_irq(&l3->list_lock); + ret += __node_shrink(cachep, i); + spin_unlock_irq(&l3->list_lock); + } + } + return (ret ? 1 : 0); +} + /** * kmem_cache_shrink - Shrink a cache. * @cachep: The cache to shrink. @@ -1645,6 +1997,7 @@ EXPORT_SYMBOL(kmem_cache_shrink); int kmem_cache_destroy(kmem_cache_t * cachep) { int i; + struct kmem_list3 *l3; if (!cachep || in_interrupt()) BUG(); @@ -1672,15 +2025,17 @@ int kmem_cache_destroy(kmem_cache_t * cachep) if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) synchronize_rcu(); - /* no cpu_online check required here since we clear the percpu - * array on cpu offline and set this to NULL. - */ - for (i = 0; i < NR_CPUS; i++) + for_each_online_cpu(i) kfree(cachep->array[i]); /* NUMA: free the list3 structures */ - kfree(cachep->lists.shared); - cachep->lists.shared = NULL; + for_each_online_node(i) { + if ((l3 = cachep->nodelists[i])) { + kfree(l3->shared); + free_alien_cache(l3->alien); + kfree(l3); + } + } kmem_cache_free(&cache_cache, cachep); unlock_cpu_hotplug(); @@ -1690,8 +2045,8 @@ int kmem_cache_destroy(kmem_cache_t * cachep) EXPORT_SYMBOL(kmem_cache_destroy); /* Get the memory for a slab management obj. */ -static struct slab* alloc_slabmgmt(kmem_cache_t *cachep, - void *objp, int colour_off, unsigned int __nocast local_flags) +static struct slab* alloc_slabmgmt(kmem_cache_t *cachep, void *objp, + int colour_off, unsigned int __nocast local_flags) { struct slab *slabp; @@ -1722,7 +2077,7 @@ static void cache_init_objs(kmem_cache_t *cachep, int i; for (i = 0; i < cachep->num; i++) { - void* objp = slabp->s_mem+cachep->objsize*i; + void *objp = slabp->s_mem+cachep->objsize*i; #if DEBUG /* need to poison the objs? */ if (cachep->flags & SLAB_POISON) @@ -1799,6 +2154,7 @@ static int cache_grow(kmem_cache_t *cachep, unsigned int __nocast flags, int nod size_t offset; unsigned int local_flags; unsigned long ctor_flags; + struct kmem_list3 *l3; /* Be lazy and only check for valid flags here, * keeping it out of the critical path in kmem_cache_alloc(). @@ -1830,6 +2186,7 @@ static int cache_grow(kmem_cache_t *cachep, unsigned int __nocast flags, int nod spin_unlock(&cachep->spinlock); + check_irq_off(); if (local_flags & __GFP_WAIT) local_irq_enable(); @@ -1841,8 +2198,9 @@ static int cache_grow(kmem_cache_t *cachep, unsigned int __nocast flags, int nod */ kmem_flagcheck(cachep, flags); - - /* Get mem for the objs. */ + /* Get mem for the objs. + * Attempt to allocate a physical page from 'nodeid', + */ if (!(objp = kmem_getpages(cachep, flags, nodeid))) goto failed; @@ -1850,6 +2208,7 @@ static int cache_grow(kmem_cache_t *cachep, unsigned int __nocast flags, int nod if (!(slabp = alloc_slabmgmt(cachep, objp, offset, local_flags))) goto opps1; + slabp->nodeid = nodeid; set_slab_attr(cachep, slabp, objp); cache_init_objs(cachep, slabp, ctor_flags); @@ -1857,13 +2216,14 @@ static int cache_grow(kmem_cache_t *cachep, unsigned int __nocast flags, int nod if (local_flags & __GFP_WAIT) local_irq_disable(); check_irq_off(); - spin_lock(&cachep->spinlock); + l3 = cachep->nodelists[nodeid]; + spin_lock(&l3->list_lock); /* Make slab active. */ - list_add_tail(&slabp->list, &(list3_data(cachep)->slabs_free)); + list_add_tail(&slabp->list, &(l3->slabs_free)); STATS_INC_GROWN(cachep); - list3_data(cachep)->free_objects += cachep->num; - spin_unlock(&cachep->spinlock); + l3->free_objects += cachep->num; + spin_unlock(&l3->list_lock); return 1; opps1: kmem_freepages(cachep, objp); @@ -1969,7 +2329,6 @@ static void check_slabp(kmem_cache_t *cachep, struct slab *slabp) kmem_bufctl_t i; int entries = 0; - check_spinlock_acquired(cachep); /* Check slab's freelist to see if this obj is there. */ for (i = slabp->free; i != BUFCTL_END; i = slab_bufctl(slabp)[i]) { entries++; @@ -2012,10 +2371,11 @@ retry: */ batchcount = BATCHREFILL_LIMIT; } - l3 = list3_data(cachep); + l3 = cachep->nodelists[numa_node_id()]; + + BUG_ON(ac->avail > 0 || !l3); + spin_lock(&l3->list_lock); - BUG_ON(ac->avail > 0); - spin_lock(&cachep->spinlock); if (l3->shared) { struct array_cache *shared_array = l3->shared; if (shared_array->avail) { @@ -2023,8 +2383,9 @@ retry: batchcount = shared_array->avail; shared_array->avail -= batchcount; ac->avail = batchcount; - memcpy(ac_entry(ac), &ac_entry(shared_array)[shared_array->avail], - sizeof(void*)*batchcount); + memcpy(ac->entry, + &(shared_array->entry[shared_array->avail]), + sizeof(void*)*batchcount); shared_array->touched = 1; goto alloc_done; } @@ -2051,7 +2412,8 @@ retry: STATS_SET_HIGH(cachep); /* get obj pointer */ - ac_entry(ac)[ac->avail++] = slabp->s_mem + slabp->free*cachep->objsize; + ac->entry[ac->avail++] = slabp->s_mem + + slabp->free*cachep->objsize; slabp->inuse++; next = slab_bufctl(slabp)[slabp->free]; @@ -2073,12 +2435,12 @@ retry: must_grow: l3->free_objects -= ac->avail; alloc_done: - spin_unlock(&cachep->spinlock); + spin_unlock(&l3->list_lock); if (unlikely(!ac->avail)) { int x; - x = cache_grow(cachep, flags, -1); - + x = cache_grow(cachep, flags, numa_node_id()); + // cache_grow can reenable interrupts, then ac could change. ac = ac_data(cachep); if (!x && ac->avail == 0) // no objects in sight? abort @@ -2088,7 +2450,7 @@ alloc_done: goto retry; } ac->touched = 1; - return ac_entry(ac)[--ac->avail]; + return ac->entry[--ac->avail]; } static inline void @@ -2160,7 +2522,7 @@ static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast fl if (likely(ac->avail)) { STATS_INC_ALLOCHIT(cachep); ac->touched = 1; - objp = ac_entry(ac)[--ac->avail]; + objp = ac->entry[--ac->avail]; } else { STATS_INC_ALLOCMISS(cachep); objp = cache_alloc_refill(cachep, flags); @@ -2172,33 +2534,104 @@ static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast fl return objp; } -/* - * NUMA: different approach needed if the spinlock is moved into - * the l3 structure +#ifdef CONFIG_NUMA +/* + * A interface to enable slab creation on nodeid */ +static void *__cache_alloc_node(kmem_cache_t *cachep, int flags, int nodeid) +{ + struct list_head *entry; + struct slab *slabp; + struct kmem_list3 *l3; + void *obj; + kmem_bufctl_t next; + int x; + + l3 = cachep->nodelists[nodeid]; + BUG_ON(!l3); + +retry: + spin_lock(&l3->list_lock); + entry = l3->slabs_partial.next; + if (entry == &l3->slabs_partial) { + l3->free_touched = 1; + entry = l3->slabs_free.next; + if (entry == &l3->slabs_free) + goto must_grow; + } + + slabp = list_entry(entry, struct slab, list); + check_spinlock_acquired_node(cachep, nodeid); + check_slabp(cachep, slabp); + + STATS_INC_NODEALLOCS(cachep); + STATS_INC_ACTIVE(cachep); + STATS_SET_HIGH(cachep); + + BUG_ON(slabp->inuse == cachep->num); + + /* get obj pointer */ + obj = slabp->s_mem + slabp->free*cachep->objsize; + slabp->inuse++; + next = slab_bufctl(slabp)[slabp->free]; +#if DEBUG + slab_bufctl(slabp)[slabp->free] = BUFCTL_FREE; +#endif + slabp->free = next; + check_slabp(cachep, slabp); + l3->free_objects--; + /* move slabp to correct slabp list: */ + list_del(&slabp->list); + + if (slabp->free == BUFCTL_END) { + list_add(&slabp->list, &l3->slabs_full); + } else { + list_add(&slabp->list, &l3->slabs_partial); + } + + spin_unlock(&l3->list_lock); + goto done; + +must_grow: + spin_unlock(&l3->list_lock); + x = cache_grow(cachep, flags, nodeid); + if (!x) + return NULL; + + goto retry; +done: + return obj; +} +#endif + +/* + * Caller needs to acquire correct kmem_list's list_lock + */ static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects) { int i; - - check_spinlock_acquired(cachep); - - /* NUMA: move add into loop */ - cachep->lists.free_objects += nr_objects; + struct kmem_list3 *l3; for (i = 0; i < nr_objects; i++) { void *objp = objpp[i]; struct slab *slabp; unsigned int objnr; + int nodeid = 0; slabp = GET_PAGE_SLAB(virt_to_page(objp)); + nodeid = slabp->nodeid; + l3 = cachep->nodelists[nodeid]; list_del(&slabp->list); objnr = (objp - slabp->s_mem) / cachep->objsize; + check_spinlock_acquired_node(cachep, nodeid); check_slabp(cachep, slabp); + + #if DEBUG if (slab_bufctl(slabp)[objnr] != BUFCTL_FREE) { - printk(KERN_ERR "slab: double free detected in cache '%s', objp %p.\n", - cachep->name, objp); + printk(KERN_ERR "slab: double free detected in cache " + "'%s', objp %p\n", cachep->name, objp); BUG(); } #endif @@ -2206,24 +2639,23 @@ static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects) slabp->free = objnr; STATS_DEC_ACTIVE(cachep); slabp->inuse--; + l3->free_objects++; check_slabp(cachep, slabp); /* fixup slab chains */ if (slabp->inuse == 0) { - if (cachep->lists.free_objects > cachep->free_limit) { - cachep->lists.free_objects -= cachep->num; + if (l3->free_objects > l3->free_limit) { + l3->free_objects -= cachep->num; slab_destroy(cachep, slabp); } else { - list_add(&slabp->list, - &list3_data_ptr(cachep, objp)->slabs_free); + list_add(&slabp->list, &l3->slabs_free); } } else { /* Unconditionally move a slab to the end of the * partial list on free - maximum time for the * other objects to be freed, too. */ - list_add_tail(&slabp->list, - &list3_data_ptr(cachep, objp)->slabs_partial); + list_add_tail(&slabp->list, &l3->slabs_partial); } } } @@ -2231,36 +2663,38 @@ static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects) static void cache_flusharray(kmem_cache_t *cachep, struct array_cache *ac) { int batchcount; + struct kmem_list3 *l3; batchcount = ac->batchcount; #if DEBUG BUG_ON(!batchcount || batchcount > ac->avail); #endif check_irq_off(); - spin_lock(&cachep->spinlock); - if (cachep->lists.shared) { - struct array_cache *shared_array = cachep->lists.shared; + l3 = cachep->nodelists[numa_node_id()]; + spin_lock(&l3->list_lock); + if (l3->shared) { + struct array_cache *shared_array = l3->shared; int max = shared_array->limit-shared_array->avail; if (max) { if (batchcount > max) batchcount = max; - memcpy(&ac_entry(shared_array)[shared_array->avail], - &ac_entry(ac)[0], + memcpy(&(shared_array->entry[shared_array->avail]), + ac->entry, sizeof(void*)*batchcount); shared_array->avail += batchcount; goto free_done; } } - free_block(cachep, &ac_entry(ac)[0], batchcount); + free_block(cachep, ac->entry, batchcount); free_done: #if STATS { int i = 0; struct list_head *p; - p = list3_data(cachep)->slabs_free.next; - while (p != &(list3_data(cachep)->slabs_free)) { + p = l3->slabs_free.next; + while (p != &(l3->slabs_free)) { struct slab *slabp; slabp = list_entry(p, struct slab, list); @@ -2272,12 +2706,13 @@ free_done: STATS_SET_FREEABLE(cachep, i); } #endif - spin_unlock(&cachep->spinlock); + spin_unlock(&l3->list_lock); ac->avail -= batchcount; - memmove(&ac_entry(ac)[0], &ac_entry(ac)[batchcount], + memmove(ac->entry, &(ac->entry[batchcount]), sizeof(void*)*ac->avail); } + /* * __cache_free * Release an obj back to its cache. If the obj has a constructed @@ -2292,14 +2727,46 @@ static inline void __cache_free(kmem_cache_t *cachep, void *objp) check_irq_off(); objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0)); + /* Make sure we are not freeing a object from another + * node to the array cache on this cpu. + */ +#ifdef CONFIG_NUMA + { + struct slab *slabp; + slabp = GET_PAGE_SLAB(virt_to_page(objp)); + if (unlikely(slabp->nodeid != numa_node_id())) { + struct array_cache *alien = NULL; + int nodeid = slabp->nodeid; + struct kmem_list3 *l3 = cachep->nodelists[numa_node_id()]; + + STATS_INC_NODEFREES(cachep); + if (l3->alien && l3->alien[nodeid]) { + alien = l3->alien[nodeid]; + spin_lock(&alien->lock); + if (unlikely(alien->avail == alien->limit)) + __drain_alien_cache(cachep, + alien, nodeid); + alien->entry[alien->avail++] = objp; + spin_unlock(&alien->lock); + } else { + spin_lock(&(cachep->nodelists[nodeid])-> + list_lock); + free_block(cachep, &objp, 1); + spin_unlock(&(cachep->nodelists[nodeid])-> + list_lock); + } + return; + } + } +#endif if (likely(ac->avail < ac->limit)) { STATS_INC_FREEHIT(cachep); - ac_entry(ac)[ac->avail++] = objp; + ac->entry[ac->avail++] = objp; return; } else { STATS_INC_FREEMISS(cachep); cache_flusharray(cachep, ac); - ac_entry(ac)[ac->avail++] = objp; + ac->entry[ac->avail++] = objp; } } @@ -2369,81 +2836,30 @@ out: * Identical to kmem_cache_alloc, except that this function is slow * and can sleep. And it will allocate memory on the given node, which * can improve the performance for cpu bound structures. + * New and improved: it will now make sure that the object gets + * put on the correct node list so that there is no false sharing. */ void *kmem_cache_alloc_node(kmem_cache_t *cachep, int flags, int nodeid) { - int loop; - void *objp; - struct slab *slabp; - kmem_bufctl_t next; - - if (nodeid == -1) - return kmem_cache_alloc(cachep, flags); - - for (loop = 0;;loop++) { - struct list_head *q; - - objp = NULL; - check_irq_on(); - spin_lock_irq(&cachep->spinlock); - /* walk through all partial and empty slab and find one - * from the right node */ - list_for_each(q,&cachep->lists.slabs_partial) { - slabp = list_entry(q, struct slab, list); - - if (page_to_nid(virt_to_page(slabp->s_mem)) == nodeid || - loop > 2) - goto got_slabp; - } - list_for_each(q, &cachep->lists.slabs_free) { - slabp = list_entry(q, struct slab, list); + unsigned long save_flags; + void *ptr; - if (page_to_nid(virt_to_page(slabp->s_mem)) == nodeid || - loop > 2) - goto got_slabp; - } - spin_unlock_irq(&cachep->spinlock); + if (nodeid == numa_node_id() || nodeid == -1) + return __cache_alloc(cachep, flags); - local_irq_disable(); - if (!cache_grow(cachep, flags, nodeid)) { - local_irq_enable(); - return NULL; - } - local_irq_enable(); + if (unlikely(!cachep->nodelists[nodeid])) { + /* Fall back to __cache_alloc if we run into trouble */ + printk(KERN_WARNING "slab: not allocating in inactive node %d for cache %s\n", nodeid, cachep->name); + return __cache_alloc(cachep,flags); } -got_slabp: - /* found one: allocate object */ - check_slabp(cachep, slabp); - check_spinlock_acquired(cachep); - STATS_INC_ALLOCED(cachep); - STATS_INC_ACTIVE(cachep); - STATS_SET_HIGH(cachep); - STATS_INC_NODEALLOCS(cachep); - - objp = slabp->s_mem + slabp->free*cachep->objsize; - - slabp->inuse++; - next = slab_bufctl(slabp)[slabp->free]; -#if DEBUG - slab_bufctl(slabp)[slabp->free] = BUFCTL_FREE; -#endif - slabp->free = next; - check_slabp(cachep, slabp); - - /* move slabp to correct slabp list: */ - list_del(&slabp->list); - if (slabp->free == BUFCTL_END) - list_add(&slabp->list, &cachep->lists.slabs_full); - else - list_add(&slabp->list, &cachep->lists.slabs_partial); - - list3_data(cachep)->free_objects--; - spin_unlock_irq(&cachep->spinlock); + cache_alloc_debugcheck_before(cachep, flags); + local_irq_save(save_flags); + ptr = __cache_alloc_node(cachep, flags, nodeid); + local_irq_restore(save_flags); + ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, __builtin_return_address(0)); - objp = cache_alloc_debugcheck_after(cachep, GFP_KERNEL, objp, - __builtin_return_address(0)); - return objp; + return ptr; } EXPORT_SYMBOL(kmem_cache_alloc_node); @@ -2513,11 +2929,18 @@ void *__alloc_percpu(size_t size, size_t align) if (!pdata) return NULL; - for (i = 0; i < NR_CPUS; i++) { - if (!cpu_possible(i)) - continue; - pdata->ptrs[i] = kmalloc_node(size, GFP_KERNEL, - cpu_to_node(i)); + /* + * Cannot use for_each_online_cpu since a cpu may come online + * and we have no way of figuring out how to fix the array + * that we have allocated then.... + */ + for_each_cpu(i) { + int node = cpu_to_node(i); + + if (node_online(node)) + pdata->ptrs[i] = kmalloc_node(size, GFP_KERNEL, node); + else + pdata->ptrs[i] = kmalloc(size, GFP_KERNEL); if (!pdata->ptrs[i]) goto unwind_oom; @@ -2607,11 +3030,11 @@ free_percpu(const void *objp) int i; struct percpu_data *p = (struct percpu_data *) (~(unsigned long) objp); - for (i = 0; i < NR_CPUS; i++) { - if (!cpu_possible(i)) - continue; + /* + * We allocate for all cpus so we cannot use for online cpu here. + */ + for_each_cpu(i) kfree(p->ptrs[i]); - } kfree(p); } EXPORT_SYMBOL(free_percpu); @@ -2629,6 +3052,64 @@ const char *kmem_cache_name(kmem_cache_t *cachep) } EXPORT_SYMBOL_GPL(kmem_cache_name); +/* + * This initializes kmem_list3 for all nodes. + */ +static int alloc_kmemlist(kmem_cache_t *cachep) +{ + int node; + struct kmem_list3 *l3; + int err = 0; + + for_each_online_node(node) { + struct array_cache *nc = NULL, *new; + struct array_cache **new_alien = NULL; +#ifdef CONFIG_NUMA + if (!(new_alien = alloc_alien_cache(node, cachep->limit))) + goto fail; +#endif + if (!(new = alloc_arraycache(node, (cachep->shared* + cachep->batchcount), 0xbaadf00d))) + goto fail; + if ((l3 = cachep->nodelists[node])) { + + spin_lock_irq(&l3->list_lock); + + if ((nc = cachep->nodelists[node]->shared)) + free_block(cachep, nc->entry, + nc->avail); + + l3->shared = new; + if (!cachep->nodelists[node]->alien) { + l3->alien = new_alien; + new_alien = NULL; + } + l3->free_limit = (1 + nr_cpus_node(node))* + cachep->batchcount + cachep->num; + spin_unlock_irq(&l3->list_lock); + kfree(nc); + free_alien_cache(new_alien); + continue; + } + if (!(l3 = kmalloc_node(sizeof(struct kmem_list3), + GFP_KERNEL, node))) + goto fail; + + kmem_list3_init(l3); + l3->next_reap = jiffies + REAPTIMEOUT_LIST3 + + ((unsigned long)cachep)%REAPTIMEOUT_LIST3; + l3->shared = new; + l3->alien = new_alien; + l3->free_limit = (1 + nr_cpus_node(node))* + cachep->batchcount + cachep->num; + cachep->nodelists[node] = l3; + } + return err; +fail: + err = -ENOMEM; + return err; +} + struct ccupdate_struct { kmem_cache_t *cachep; struct array_cache *new[NR_CPUS]; @@ -2641,7 +3122,7 @@ static void do_ccupdate_local(void *info) check_irq_off(); old = ac_data(new->cachep); - + new->cachep->array[smp_processor_id()] = new->new[smp_processor_id()]; new->new[smp_processor_id()] = old; } @@ -2651,54 +3132,43 @@ static int do_tune_cpucache(kmem_cache_t *cachep, int limit, int batchcount, int shared) { struct ccupdate_struct new; - struct array_cache *new_shared; - int i; + int i, err; memset(&new.new,0,sizeof(new.new)); - for (i = 0; i < NR_CPUS; i++) { - if (cpu_online(i)) { - new.new[i] = alloc_arraycache(i, limit, batchcount); - if (!new.new[i]) { - for (i--; i >= 0; i--) kfree(new.new[i]); - return -ENOMEM; - } - } else { - new.new[i] = NULL; + for_each_online_cpu(i) { + new.new[i] = alloc_arraycache(cpu_to_node(i), limit, batchcount); + if (!new.new[i]) { + for (i--; i >= 0; i--) kfree(new.new[i]); + return -ENOMEM; } } new.cachep = cachep; smp_call_function_all_cpus(do_ccupdate_local, (void *)&new); - + check_irq_on(); spin_lock_irq(&cachep->spinlock); cachep->batchcount = batchcount; cachep->limit = limit; - cachep->free_limit = (1+num_online_cpus())*cachep->batchcount + cachep->num; + cachep->shared = shared; spin_unlock_irq(&cachep->spinlock); - for (i = 0; i < NR_CPUS; i++) { + for_each_online_cpu(i) { struct array_cache *ccold = new.new[i]; if (!ccold) continue; - spin_lock_irq(&cachep->spinlock); - free_block(cachep, ac_entry(ccold), ccold->avail); - spin_unlock_irq(&cachep->spinlock); + spin_lock_irq(&cachep->nodelists[cpu_to_node(i)]->list_lock); + free_block(cachep, ccold->entry, ccold->avail); + spin_unlock_irq(&cachep->nodelists[cpu_to_node(i)]->list_lock); kfree(ccold); } - new_shared = alloc_arraycache(-1, batchcount*shared, 0xbaadf00d); - if (new_shared) { - struct array_cache *old; - spin_lock_irq(&cachep->spinlock); - old = cachep->lists.shared; - cachep->lists.shared = new_shared; - if (old) - free_block(cachep, ac_entry(old), old->avail); - spin_unlock_irq(&cachep->spinlock); - kfree(old); + err = alloc_kmemlist(cachep); + if (err) { + printk(KERN_ERR "alloc_kmemlist failed for %s, error %d.\n", + cachep->name, -err); + BUG(); } - return 0; } @@ -2756,11 +3226,11 @@ static void enable_cpucache(kmem_cache_t *cachep) } static void drain_array_locked(kmem_cache_t *cachep, - struct array_cache *ac, int force) + struct array_cache *ac, int force, int node) { int tofree; - check_spinlock_acquired(cachep); + check_spinlock_acquired_node(cachep, node); if (ac->touched && !force) { ac->touched = 0; } else if (ac->avail) { @@ -2768,9 +3238,9 @@ static void drain_array_locked(kmem_cache_t *cachep, if (tofree > ac->avail) { tofree = (ac->avail+1)/2; } - free_block(cachep, ac_entry(ac), tofree); + free_block(cachep, ac->entry, tofree); ac->avail -= tofree; - memmove(&ac_entry(ac)[0], &ac_entry(ac)[tofree], + memmove(ac->entry, &(ac->entry[tofree]), sizeof(void*)*ac->avail); } } @@ -2789,6 +3259,7 @@ static void drain_array_locked(kmem_cache_t *cachep, static void cache_reap(void *unused) { struct list_head *walk; + struct kmem_list3 *l3; if (down_trylock(&cache_chain_sem)) { /* Give up. Setup the next iteration. */ @@ -2809,27 +3280,32 @@ static void cache_reap(void *unused) check_irq_on(); - spin_lock_irq(&searchp->spinlock); + l3 = searchp->nodelists[numa_node_id()]; + if (l3->alien) + drain_alien_cache(searchp, l3); + spin_lock_irq(&l3->list_lock); - drain_array_locked(searchp, ac_data(searchp), 0); + drain_array_locked(searchp, ac_data(searchp), 0, + numa_node_id()); - if(time_after(searchp->lists.next_reap, jiffies)) + if (time_after(l3->next_reap, jiffies)) goto next_unlock; - searchp->lists.next_reap = jiffies + REAPTIMEOUT_LIST3; + l3->next_reap = jiffies + REAPTIMEOUT_LIST3; - if (searchp->lists.shared) - drain_array_locked(searchp, searchp->lists.shared, 0); + if (l3->shared) + drain_array_locked(searchp, l3->shared, 0, + numa_node_id()); - if (searchp->lists.free_touched) { - searchp->lists.free_touched = 0; + if (l3->free_touched) { + l3->free_touched = 0; goto next_unlock; } - tofree = (searchp->free_limit+5*searchp->num-1)/(5*searchp->num); + tofree = (l3->free_limit+5*searchp->num-1)/(5*searchp->num); do { - p = list3_data(searchp)->slabs_free.next; - if (p == &(list3_data(searchp)->slabs_free)) + p = l3->slabs_free.next; + if (p == &(l3->slabs_free)) break; slabp = list_entry(p, struct slab, list); @@ -2842,13 +3318,13 @@ static void cache_reap(void *unused) * searchp cannot disappear, we hold * cache_chain_lock */ - searchp->lists.free_objects -= searchp->num; - spin_unlock_irq(&searchp->spinlock); + l3->free_objects -= searchp->num; + spin_unlock_irq(&l3->list_lock); slab_destroy(searchp, slabp); - spin_lock_irq(&searchp->spinlock); + spin_lock_irq(&l3->list_lock); } while(--tofree > 0); next_unlock: - spin_unlock_irq(&searchp->spinlock); + spin_unlock_irq(&l3->list_lock); next: cond_resched(); } @@ -2882,7 +3358,7 @@ static void *s_start(struct seq_file *m, loff_t *pos) seq_puts(m, " : slabdata "); #if STATS seq_puts(m, " : globalstat " - " "); + " "); seq_puts(m, " : cpustat "); #endif seq_putc(m, '\n'); @@ -2917,39 +3393,53 @@ static int s_show(struct seq_file *m, void *p) unsigned long active_objs; unsigned long num_objs; unsigned long active_slabs = 0; - unsigned long num_slabs; - const char *name; + unsigned long num_slabs, free_objects = 0, shared_avail = 0; + const char *name; char *error = NULL; + int node; + struct kmem_list3 *l3; check_irq_on(); spin_lock_irq(&cachep->spinlock); active_objs = 0; num_slabs = 0; - list_for_each(q,&cachep->lists.slabs_full) { - slabp = list_entry(q, struct slab, list); - if (slabp->inuse != cachep->num && !error) - error = "slabs_full accounting error"; - active_objs += cachep->num; - active_slabs++; - } - list_for_each(q,&cachep->lists.slabs_partial) { - slabp = list_entry(q, struct slab, list); - if (slabp->inuse == cachep->num && !error) - error = "slabs_partial inuse accounting error"; - if (!slabp->inuse && !error) - error = "slabs_partial/inuse accounting error"; - active_objs += slabp->inuse; - active_slabs++; - } - list_for_each(q,&cachep->lists.slabs_free) { - slabp = list_entry(q, struct slab, list); - if (slabp->inuse && !error) - error = "slabs_free/inuse accounting error"; - num_slabs++; + for_each_online_node(node) { + l3 = cachep->nodelists[node]; + if (!l3) + continue; + + spin_lock(&l3->list_lock); + + list_for_each(q,&l3->slabs_full) { + slabp = list_entry(q, struct slab, list); + if (slabp->inuse != cachep->num && !error) + error = "slabs_full accounting error"; + active_objs += cachep->num; + active_slabs++; + } + list_for_each(q,&l3->slabs_partial) { + slabp = list_entry(q, struct slab, list); + if (slabp->inuse == cachep->num && !error) + error = "slabs_partial inuse accounting error"; + if (!slabp->inuse && !error) + error = "slabs_partial/inuse accounting error"; + active_objs += slabp->inuse; + active_slabs++; + } + list_for_each(q,&l3->slabs_free) { + slabp = list_entry(q, struct slab, list); + if (slabp->inuse && !error) + error = "slabs_free/inuse accounting error"; + num_slabs++; + } + free_objects += l3->free_objects; + shared_avail += l3->shared->avail; + + spin_unlock(&l3->list_lock); } num_slabs+=active_slabs; num_objs = num_slabs*cachep->num; - if (num_objs - active_objs != cachep->lists.free_objects && !error) + if (num_objs - active_objs != free_objects && !error) error = "free_objects accounting error"; name = cachep->name; @@ -2961,9 +3451,9 @@ static int s_show(struct seq_file *m, void *p) cachep->num, (1<gfporder)); seq_printf(m, " : tunables %4u %4u %4u", cachep->limit, cachep->batchcount, - cachep->lists.shared->limit/cachep->batchcount); - seq_printf(m, " : slabdata %6lu %6lu %6u", - active_slabs, num_slabs, cachep->lists.shared->avail); + cachep->shared); + seq_printf(m, " : slabdata %6lu %6lu %6lu", + active_slabs, num_slabs, shared_avail); #if STATS { /* list3 stats */ unsigned long high = cachep->high_mark; @@ -2972,12 +3462,13 @@ static int s_show(struct seq_file *m, void *p) unsigned long reaped = cachep->reaped; unsigned long errors = cachep->errors; unsigned long max_freeable = cachep->max_freeable; - unsigned long free_limit = cachep->free_limit; unsigned long node_allocs = cachep->node_allocs; + unsigned long node_frees = cachep->node_frees; - seq_printf(m, " : globalstat %7lu %6lu %5lu %4lu %4lu %4lu %4lu %4lu", - allocs, high, grown, reaped, errors, - max_freeable, free_limit, node_allocs); + seq_printf(m, " : globalstat %7lu %6lu %5lu %4lu \ + %4lu %4lu %4lu %4lu", + allocs, high, grown, reaped, errors, + max_freeable, node_allocs, node_frees); } /* cpu stats */ { @@ -3056,9 +3547,10 @@ ssize_t slabinfo_write(struct file *file, const char __user *buffer, batchcount < 1 || batchcount > limit || shared < 0) { - res = -EINVAL; + res = 0; } else { - res = do_tune_cpucache(cachep, limit, batchcount, shared); + res = do_tune_cpucache(cachep, limit, + batchcount, shared); } break; } -- cgit v0.10.2 From a1938038dd7e4188a8663e49242fa77dd2adb7ed Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 9 Sep 2005 13:03:34 -0700 Subject: [PATCH] VIDEO_BT848: remove not required part of the help text Things that are already expressed through the dependencies don't have to be mentioned in the help text. Signed-off-by: Adrian Bunk Cc: Mauro Carvalho Chehab Cc: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 16c85c0..077720c 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -22,9 +22,6 @@ config VIDEO_BT848 the Miro, Hauppauge and STB boards. Please read the material in for more information. - If you say Y or M here, you need to say Y or M to "I2C support" and - "I2C bit-banging interfaces" in the device drivers section. - To compile this driver as a module, choose M here: the module will be called bttv. -- cgit v0.10.2 From 793cf9e6a54c698e109a599c8b8e303658fcaae6 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:37 -0700 Subject: [PATCH] v4l: common part Updates and tuner additions - Remove $Id CVS logs for V4L files - Included newer cards. - Added a new NEC protocol for ir based on pulse distance. - Enable ATSC support for DViCO FusionHDTV5 Gold. - Added tuner LG NTSC (TALN mini series). - Fixed tea5767 autodetection. - Resolve more tuner types. - Commented debug function removed from mainstream. - Remove comments from mainstream. Still on development tree. - linux/version dependencies removed. - BTSC Lang1 now is set to auto_stereo mode. - New tuner standby API. - i2c-core.c uses hexadecimal for the i2c address, so it should stay consistent. Signed-off-by: Uli Luckas Signed-off-by: Mac Michaels Signed-off-by: Michael Krufky Signed-off-by: Hermann Pitton Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/video4linux/CARDLIST.tuner b/Documentation/video4linux/CARDLIST.tuner index f3302e1..f5876be 100644 --- a/Documentation/video4linux/CARDLIST.tuner +++ b/Documentation/video4linux/CARDLIST.tuner @@ -64,3 +64,4 @@ tuner=62 - Philips TEA5767HN FM Radio tuner=63 - Philips FMD1216ME MK3 Hybrid Tuner tuner=64 - LG TDVS-H062F/TUA6034 tuner=65 - Ymec TVF66T5-B/DFF +tuner=66 - LG NTSC (TALN mini series) diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c index ab7a1fb..a0e700d 100644 --- a/drivers/media/common/ir-common.c +++ b/drivers/media/common/ir-common.c @@ -1,5 +1,4 @@ /* - * $Id: ir-common.c,v 1.11 2005/07/07 14:44:43 mchehab Exp $ * * some common structs and functions to handle infrared remotes via * input layer ... @@ -335,6 +334,72 @@ int ir_dump_samples(u32 *samples, int count) return 0; } +/* decode raw samples, pulse distance coding used by NEC remotes */ +int ir_decode_pulsedistance(u32 *samples, int count, int low, int high) +{ + int i,last,bit,len; + u32 curBit; + u32 value; + + /* find start burst */ + for (i = len = 0; i < count * 32; i++) { + bit = getbit(samples,i); + if (bit) { + len++; + } else { + if (len >= 29) + break; + len = 0; + } + } + + /* start burst to short */ + if (len < 29) + return 0xffffffff; + + /* find start silence */ + for (len = 0; i < count * 32; i++) { + bit = getbit(samples,i); + if (bit) { + break; + } else { + len++; + } + } + + /* silence to short */ + if (len < 7) + return 0xffffffff; + + /* go decoding */ + len = 0; + last = 1; + value = 0; curBit = 1; + for (; i < count * 32; i++) { + bit = getbit(samples,i); + if (last) { + if(bit) { + continue; + } else { + len = 1; + } + } else { + if (bit) { + if (len > (low + high) /2) + value |= curBit; + curBit <<= 1; + if (curBit == 1) + break; + } else { + len++; + } + } + last = bit; + } + + return value; +} + /* decode raw samples, biphase coding, used by rc5 for example */ int ir_decode_biphase(u32 *samples, int count, int low, int high) { @@ -383,6 +448,7 @@ EXPORT_SYMBOL_GPL(ir_input_keydown); EXPORT_SYMBOL_GPL(ir_extract_bits); EXPORT_SYMBOL_GPL(ir_dump_samples); EXPORT_SYMBOL_GPL(ir_decode_biphase); +EXPORT_SYMBOL_GPL(ir_decode_pulsedistance); /* * Local variables: diff --git a/drivers/media/video/btcx-risc.c b/drivers/media/video/btcx-risc.c index 7f2d515..a48de3c 100644 --- a/drivers/media/video/btcx-risc.c +++ b/drivers/media/video/btcx-risc.c @@ -1,5 +1,4 @@ /* - $Id: btcx-risc.c,v 1.6 2005/02/21 13:57:59 kraxel Exp $ btcx-risc.c diff --git a/drivers/media/video/btcx-risc.h b/drivers/media/video/btcx-risc.h index 41f6039..503e6c6 100644 --- a/drivers/media/video/btcx-risc.h +++ b/drivers/media/video/btcx-risc.h @@ -1,5 +1,4 @@ /* - * $Id: btcx-risc.h,v 1.2 2004/09/15 16:15:24 kraxel Exp $ */ struct btcx_riscmem { unsigned int size; diff --git a/drivers/media/video/ir-kbd-gpio.c b/drivers/media/video/ir-kbd-gpio.c index a565823..eddadc7 100644 --- a/drivers/media/video/ir-kbd-gpio.c +++ b/drivers/media/video/ir-kbd-gpio.c @@ -1,5 +1,4 @@ /* - * $Id: ir-kbd-gpio.c,v 1.13 2005/05/15 19:01:26 mchehab Exp $ * * Copyright (c) 2003 Gerd Knorr * Copyright (c) 2003 Pavel Machek diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index 1e273ff..67105b9 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c @@ -1,5 +1,4 @@ /* - * $Id: ir-kbd-i2c.c,v 1.11 2005/07/07 16:42:11 mchehab Exp $ * * keyboard input driver for i2c IR remote controls * diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h index 023f330..2d9ff40 100644 --- a/drivers/media/video/msp3400.h +++ b/drivers/media/video/msp3400.h @@ -1,5 +1,4 @@ /* - * $Id: msp3400.h,v 1.3 2005/06/12 04:19:19 mchehab Exp $ */ #ifndef MSP3400_H diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c index 2fb7c2d..972aa5e 100644 --- a/drivers/media/video/mt20xx.c +++ b/drivers/media/video/mt20xx.c @@ -1,5 +1,4 @@ /* - * $Id: mt20xx.c,v 1.5 2005/06/16 08:29:49 nsh Exp $ * * i2c tv tuner chip device driver * controls microtune tuners, mt2032 + mt2050 at the moment. @@ -494,6 +493,7 @@ int microtune_init(struct i2c_client *c) memset(buf,0,sizeof(buf)); t->tv_freq = NULL; t->radio_freq = NULL; + t->standby = NULL; name = "unknown"; i2c_master_send(c,buf,1); diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c index a8b6a8d..c65f0c7 100644 --- a/drivers/media/video/tda8290.c +++ b/drivers/media/video/tda8290.c @@ -1,5 +1,4 @@ /* - * $Id: tda8290.c,v 1.15 2005/07/08 20:21:33 mchehab Exp $ * * i2c tv tuner chip device driver * controls the philips tda8290+75 tuner chip combo. @@ -9,6 +8,9 @@ #include #include +#define I2C_ADDR_TDA8290 0x4b +#define I2C_ADDR_TDA8275 0x61 + /* ---------------------------------------------------------------------- */ struct freq_entry { @@ -75,10 +77,12 @@ static unsigned char i2c_init_tda8275[14] = { 0x00, 0x00, 0x00, 0x00, static unsigned char i2c_set_VS[2] = { 0x30, 0x6F }; static unsigned char i2c_set_GP01_CF[2] = { 0x20, 0x0B }; static unsigned char i2c_tda8290_reset[2] = { 0x00, 0x00 }; +static unsigned char i2c_tda8290_standby[2] = { 0x00, 0x02 }; static unsigned char i2c_gainset_off[2] = { 0x28, 0x14 }; static unsigned char i2c_gainset_on[2] = { 0x28, 0x54 }; static unsigned char i2c_agc3_00[2] = { 0x80, 0x00 }; static unsigned char i2c_agc2_BF[2] = { 0x60, 0xBF }; +static unsigned char i2c_cb1_D0[2] = { 0x30, 0xD0 }; static unsigned char i2c_cb1_D2[2] = { 0x30, 0xD2 }; static unsigned char i2c_cb1_56[2] = { 0x30, 0x56 }; static unsigned char i2c_cb1_52[2] = { 0x30, 0x52 }; @@ -117,6 +121,13 @@ static struct i2c_msg i2c_msg_epilog[] = { { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_gainset_on), i2c_gainset_on }, }; +static struct i2c_msg i2c_msg_standby[] = { + { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_enable_bridge), i2c_enable_bridge }, + { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_D0), i2c_cb1_D0 }, + { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_disable_bridge), i2c_disable_bridge }, + { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_tda8290_standby), i2c_tda8290_standby }, +}; + static int tda8290_tune(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); @@ -205,6 +216,11 @@ static int has_signal(struct i2c_client *c) return (afc & 0x80)? 65535:0; } +static void standby(struct i2c_client *c) +{ + i2c_transfer(c->adapter, i2c_msg_standby, ARRAY_SIZE(i2c_msg_standby)); +} + int tda8290_init(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); @@ -214,6 +230,7 @@ int tda8290_init(struct i2c_client *c) t->tv_freq = set_tv_freq; t->radio_freq = set_radio_freq; t->has_signal = has_signal; + t->standby = standby; i2c_master_send(c, i2c_enable_bridge, ARRAY_SIZE(i2c_enable_bridge)); i2c_transfer(c->adapter, i2c_msg_init, ARRAY_SIZE(i2c_msg_init)); diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index d60fc56..79e0bd1 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -49,7 +49,7 @@ MODULE_LICENSE("GPL"); struct tda9887 { struct i2c_client client; v4l2_std_id std; - unsigned int radio; + enum tuner_mode mode; unsigned int config; unsigned int pinnacle_id; unsigned int using_v4l2; @@ -196,7 +196,7 @@ static struct tvnorm tvnorms[] = { .b = ( cNegativeFmTV | cQSS ), .c = ( cDeemphasisON | - cDeemphasis50 ), + cDeemphasis75 ), .e = ( cGating_36 | cAudioIF_4_5 | cVideoIF_45_75 ), @@ -364,7 +364,7 @@ static int tda9887_set_tvnorm(struct tda9887 *t, char *buf) struct tvnorm *norm = NULL; int i; - if (t->radio) { + if (t->mode == T_RADIO) { if (t->radio_mode == V4L2_TUNER_MODE_MONO) norm = &radio_mono; else @@ -378,7 +378,7 @@ static int tda9887_set_tvnorm(struct tda9887 *t, char *buf) } } if (NULL == norm) { - dprintk(PREFIX "Oops: no tvnorm entry found\n"); + dprintk(PREFIX "Unsupported tvnorm entry - audio muted\n"); return -1; } @@ -569,6 +569,10 @@ static int tda9887_configure(struct tda9887 *t) tda9887_set_config(t,buf); tda9887_set_insmod(t,buf); + if (t->mode == T_STANDBY) { + buf[1] |= cForcedMuteAudioON; + } + dprintk(PREFIX "writing: b=0x%02x c=0x%02x e=0x%02x\n", buf[1],buf[2],buf[3]); @@ -653,10 +657,17 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) /* --- configuration --- */ case AUDC_SET_RADIO: - t->radio = 1; + { + t->mode = T_RADIO; tda9887_configure(t); break; - + } + case TUNER_SET_STANDBY: + { + t->mode = T_STANDBY; + tda9887_configure(t); + break; + } case AUDC_CONFIG_PINNACLE: { int *i = arg; @@ -689,7 +700,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) struct video_channel *vc = arg; CHECK_V4L2; - t->radio = 0; + t->mode = T_ANALOG_TV; if (vc->norm < ARRAY_SIZE(map)) t->std = map[vc->norm]; tda9887_fixup_std(t); @@ -701,7 +712,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) v4l2_std_id *id = arg; SWITCH_V4L2; - t->radio = 0; + t->mode = T_ANALOG_TV; t->std = *id; tda9887_fixup_std(t); tda9887_configure(t); @@ -713,14 +724,14 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) SWITCH_V4L2; if (V4L2_TUNER_ANALOG_TV == f->type) { - if (t->radio == 0) + if (t->mode == T_ANALOG_TV) return 0; - t->radio = 0; + t->mode = T_ANALOG_TV; } if (V4L2_TUNER_RADIO == f->type) { - if (t->radio == 1) + if (t->mode == T_RADIO) return 0; - t->radio = 1; + t->mode = T_RADIO; } tda9887_configure(t); break; @@ -735,7 +746,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) }; struct v4l2_tuner* tuner = arg; - if (t->radio) { + if (t->mode == T_RADIO) { __u8 reg = 0; tuner->afc=0; if (1 == i2c_master_recv(&t->client,®,1)) @@ -747,7 +758,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) { struct v4l2_tuner* tuner = arg; - if (t->radio) { + if (t->mode == T_RADIO) { t->radio_mode = tuner->audmode; tda9887_configure (t); } diff --git a/drivers/media/video/tea5767.c b/drivers/media/video/tea5767.c index cebcc1f..38bf509 100644 --- a/drivers/media/video/tea5767.c +++ b/drivers/media/video/tea5767.c @@ -2,7 +2,6 @@ * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview * I2C address is allways 0xC0. * - * $Id: tea5767.c,v 1.27 2005/07/31 12:10:56 mchehab Exp $ * * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br) * This code is placed under the terms of the GNU General Public License @@ -205,11 +204,6 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq) TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND; buffer[4] = 0; - if (t->mode == T_STANDBY) { - tuner_dbg("TEA5767 set to standby mode\n"); - buffer[3] |= TEA5767_STDBY; - } - if (t->audmode == V4L2_TUNER_MODE_MONO) { tuner_dbg("TEA5767 set to mono\n"); buffer[2] |= TEA5767_MONO; @@ -290,13 +284,31 @@ static int tea5767_stereo(struct i2c_client *c) return ((buffer[2] & TEA5767_STEREO_MASK) ? V4L2_TUNER_SUB_STEREO : 0); } +static void tea5767_standby(struct i2c_client *c) +{ + unsigned char buffer[5]; + struct tuner *t = i2c_get_clientdata(c); + unsigned div, rc; + + div = (87500 * 4 + 700 + 225 + 25) / 50; /* Set frequency to 87.5 MHz */ + buffer[0] = (div >> 8) & 0x3f; + buffer[1] = div & 0xff; + buffer[2] = TEA5767_PORT1_HIGH; + buffer[3] = TEA5767_PORT2_HIGH | TEA5767_HIGH_CUT_CTRL | + TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND | TEA5767_STDBY; + buffer[4] = 0; + + if (5 != (rc = i2c_master_send(c, buffer, 5))) + tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); +} + int tea5767_autodetection(struct i2c_client *c) { unsigned char buffer[7] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; int rc; struct tuner *t = i2c_get_clientdata(c); - if (7 != (rc = i2c_master_recv(c, buffer, 7))) { + if ((rc = i2c_master_recv(c, buffer, 7))< 5) { tuner_warn("It is not a TEA5767. Received %i bytes.\n", rc); return EINVAL; } @@ -313,15 +325,10 @@ int tea5767_autodetection(struct i2c_client *c) * bit 0 : internally set to 0 * Byte 5: bit 7:0 : == 0 */ - if (!((buffer[3] & 0x0f) == 0x00) && (buffer[4] == 0x00)) { + if (((buffer[3] & 0x0f) != 0x00) || (buffer[4] != 0x00)) { tuner_warn("Chip ID is not zero. It is not a TEA5767\n"); return EINVAL; } - /* It seems that tea5767 returns 0xff after the 5th byte */ - if ((buffer[5] != 0xff) || (buffer[6] != 0xff)) { - tuner_warn("Returned more than 5 bytes. It is not a TEA5767\n"); - return EINVAL; - } /* It seems that tea5767 returns 0xff after the 5th byte */ if ((buffer[5] != 0xff) || (buffer[6] != 0xff)) { @@ -337,14 +344,14 @@ int tea5767_tuner_init(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); - tuner_info("type set to %d (%s)\n", t->type, - "Philips TEA5767HN FM Radio"); + tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5767HN FM Radio"); strlcpy(c->name, "tea5767", sizeof(c->name)); t->tv_freq = set_tv_freq; t->radio_freq = set_radio_freq; t->has_signal = tea5767_signal; t->is_stereo = tea5767_stereo; + t->standby = tea5767_standby; return (0); } diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 3b1893c..afc96bb 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -1,5 +1,4 @@ /* - * $Id: tuner-core.c,v 1.63 2005/07/28 18:19:55 mchehab Exp $ * * i2c tv tuner chip device driver * core core, i.e. kernel interfaces, registering and so on @@ -182,6 +181,14 @@ static void set_type(struct i2c_client *c, unsigned int type, i2c_master_send(c, buffer, 4); default_tuner_init(c); break; + case TUNER_LG_TDVS_H062F: + /* Set the Auxiliary Byte. */ + buffer[2] &= ~0x20; + buffer[2] |= 0x18; + buffer[3] = 0x20; + i2c_master_send(c, buffer, 4); + default_tuner_init(c); + break; default: default_tuner_init(c); break; @@ -208,31 +215,31 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup) { struct tuner *t = i2c_get_clientdata(c); - if (tun_setup->addr == ADDR_UNSET) { - if (t->mode_mask & tun_setup->mode_mask) + if ((tun_setup->addr == ADDR_UNSET && + (t->mode_mask & tun_setup->mode_mask)) || + tun_setup->addr == c->addr) { set_type(c, tun_setup->type, tun_setup->mode_mask); - } else if (tun_setup->addr == c->addr) { - set_type(c, tun_setup->type, tun_setup->mode_mask); } } static inline int check_mode(struct tuner *t, char *cmd) { - if (1 << t->mode & t->mode_mask) { - switch (t->mode) { - case V4L2_TUNER_RADIO: - tuner_dbg("Cmd %s accepted for radio\n", cmd); - break; - case V4L2_TUNER_ANALOG_TV: - tuner_dbg("Cmd %s accepted for analog TV\n", cmd); - break; - case V4L2_TUNER_DIGITAL_TV: - tuner_dbg("Cmd %s accepted for digital TV\n", cmd); - break; - } - return 0; + if ((1 << t->mode & t->mode_mask) == 0) { + return EINVAL; + } + + switch (t->mode) { + case V4L2_TUNER_RADIO: + tuner_dbg("Cmd %s accepted for radio\n", cmd); + break; + case V4L2_TUNER_ANALOG_TV: + tuner_dbg("Cmd %s accepted for analog TV\n", cmd); + break; + case V4L2_TUNER_DIGITAL_TV: + tuner_dbg("Cmd %s accepted for digital TV\n", cmd); + break; } - return EINVAL; + return 0; } static char pal[] = "-"; @@ -406,20 +413,18 @@ static int tuner_detach(struct i2c_client *client) static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, char *cmd) { - if (mode != t->mode) { - - t->mode = mode; - if (check_mode(t, cmd) == EINVAL) { - t->mode = T_STANDBY; - if (V4L2_TUNER_RADIO == mode) { - set_tv_freq(client, 400 * 16); - } else { - set_radio_freq(client, 87.5 * 16000); - } - return EINVAL; - } - } - return 0; + if (mode == t->mode) + return 0; + + t->mode = mode; + + if (check_mode(t, cmd) == EINVAL) { + t->mode = T_STANDBY; + if (t->standby) + t->standby (client); + return EINVAL; + } + return 0; } #define switch_v4l2() if (!t->using_v4l2) \ @@ -453,6 +458,14 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) case AUDC_SET_RADIO: set_mode(client,t,V4L2_TUNER_RADIO, "AUDC_SET_RADIO"); break; + case TUNER_SET_STANDBY: + { + if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL) + return 0; + if (t->standby) + t->standby (client); + break; + } case AUDC_CONFIG_PINNACLE: if (check_mode(t, "AUDC_CONFIG_PINNACLE") == EINVAL) return 0; diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index de0c93a..2603440 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -1,5 +1,4 @@ /* - * $Id: tuner-simple.c,v 1.43 2005/07/28 18:41:21 mchehab Exp $ * * i2c tv tuner chip device driver * controls all those simple 4-control-bytes style tuners. @@ -248,9 +247,10 @@ static struct tunertype tuners[] = { { "LG TDVS-H062F/TUA6034", LGINNOTEK, NTSC, 16*160.00,16*455.00,0x01,0x02,0x04,0x8e,732}, - { "Ymec TVF66T5-B/DFF", Philips, PAL, 16*160.25,16*464.25,0x01,0x02,0x08,0x8e,623}, + { "LG NTSC (TALN mini series)", LGINNOTEK, NTSC, + 16*150.00,16*425.00,0x01,0x02,0x08,0x8e,732 }, }; unsigned const int tuner_count = ARRAY_SIZE(tuners); @@ -497,6 +497,7 @@ int default_tuner_init(struct i2c_client *c) t->radio_freq = default_set_radio_freq; t->has_signal = tuner_signal; t->is_stereo = tuner_stereo; + t->standby = NULL; return 0; } diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index 3c3356a..d0a00d3 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -155,10 +155,10 @@ hauppauge_tuner[] = { TUNER_ABSENT, "Philips FQ1216ME MK3"}, { TUNER_ABSENT, "Philips FI1236 MK3"}, { TUNER_PHILIPS_FM1216ME_MK3, "Philips FM1216 ME MK3"}, - { TUNER_ABSENT, "Philips FM1236 MK3"}, + { TUNER_PHILIPS_FM1236_MK3, "Philips FM1236 MK3"}, { TUNER_ABSENT, "Philips FM1216MP MK3"}, /* 60-69 */ - { TUNER_ABSENT, "LG S001D MK3"}, + { TUNER_PHILIPS_FM1216ME_MK3, "LG S001D MK3"}, { TUNER_ABSENT, "LG M001D MK3"}, { TUNER_ABSENT, "LG S701D MK3"}, { TUNER_ABSENT, "LG M701D MK3"}, @@ -183,8 +183,8 @@ hauppauge_tuner[] = { TUNER_ABSENT, "Philips FQ1216LME MK3"}, { TUNER_ABSENT, "LG TAPC G701D"}, { TUNER_LG_NTSC_NEW_TAPC, "LG TAPC H791F"}, - { TUNER_ABSENT, "TCL 2002MB 3"}, - { TUNER_ABSENT, "TCL 2002MI 3"}, + { TUNER_LG_PAL_NEW_TAPC, "TCL 2002MB 3"}, + { TUNER_LG_PAL_NEW_TAPC, "TCL 2002MI 3"}, { TUNER_TCL_2002N, "TCL 2002N 6A"}, { TUNER_ABSENT, "Philips FQ1236 MK3"}, { TUNER_ABSENT, "Samsung TCPN 2121P30A"}, @@ -445,23 +445,6 @@ int tveeprom_read(struct i2c_client *c, unsigned char *eedata, int len) } EXPORT_SYMBOL(tveeprom_read); -#if 0 -int tveeprom_dump(unsigned char *eedata, int len) -{ - int i; - - dprintk(1, "%s\n",__FUNCTION__); - for (i = 0; i < len; i++) { - if (0 == (i % 16)) - printk(KERN_INFO "tveeprom: %02x:",i); - printk(" %02x",eedata[i]); - if (15 == (i % 16)) - printk("\n"); - } - return 0; -} -EXPORT_SYMBOL(tveeprom_dump); -#endif /* 0 */ /* ----------------------------------------------------------------------- */ /* needed for ivtv.sf.net at the moment. Should go away in the long */ diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index a43301a..d86e08e 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c @@ -1,5 +1,4 @@ /* - * $Id: tvmixer.c,v 1.8 2005/06/12 04:19:19 mchehab Exp $ */ #include diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c index 70ecbdb..59bb713 100644 --- a/drivers/media/video/v4l1-compat.c +++ b/drivers/media/video/v4l1-compat.c @@ -1,5 +1,4 @@ /* - * $Id: v4l1-compat.c,v 1.9 2005/06/12 04:19:19 mchehab Exp $ * * Video for Linux Two * Backward Compatibility Layer @@ -604,9 +603,6 @@ v4l_compat_translate_ioctl(struct inode *inode, dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %d\n",err); break; } -#if 0 /* FIXME */ - pict->depth = fmt2->fmt.pix.depth; -#endif pict->palette = pixelformat_to_palette( fmt2->fmt.pix.pixelformat); break; @@ -707,13 +703,7 @@ v4l_compat_translate_ioctl(struct inode *inode, } case VIDIOCSTUNER: /* select a tuner input */ { -#if 0 /* FIXME */ - err = drv(inode, file, VIDIOC_S_INPUT, &i); - if (err < 0) - dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %d\n",err); -#else err = 0; -#endif break; } case VIDIOCGFREQ: /* get frequency */ @@ -852,12 +842,6 @@ v4l_compat_translate_ioctl(struct inode *inode, err = 0; break; } -#if 0 - case VIDIOCGMBUF: - /* v4l2 drivers must implement that themself. The - mmap() differences can't be translated fully - transparent, thus there is no point to try that */ -#endif case VIDIOCMCAPTURE: /* capture a frame */ { struct video_mmap *mm = arg; diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index b5e0cf3..597b8db 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c @@ -84,20 +84,6 @@ MODULE_LICENSE("GPL"); * Video Standard Operations (contributed by Michael Schimek) */ -#if 0 /* seems to have no users */ -/* This is the recommended method to deal with the framerate fields. More - sophisticated drivers will access the fields directly. */ -unsigned int -v4l2_video_std_fps(struct v4l2_standard *vs) -{ - if (vs->frameperiod.numerator > 0) - return (((vs->frameperiod.denominator << 8) / - vs->frameperiod.numerator) + - (1 << 7)) / (1 << 8); - return 0; -} -EXPORT_SYMBOL(v4l2_video_std_fps); -#endif /* Fill in the fields of a v4l2_standard structure according to the 'id' and 'transmission' parameters. Returns negative on error. */ @@ -213,10 +199,6 @@ char *v4l2_ioctl_names[256] = { [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT", [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT", [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT", -#if 0 - [_IOC_NR(VIDIOC_G_COMP)] = "VIDIOC_G_COMP", - [_IOC_NR(VIDIOC_S_COMP)] = "VIDIOC_S_COMP", -#endif [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS", [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF", [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF", diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c index 15f5bb4..55f129e 100644 --- a/drivers/media/video/video-buf-dvb.c +++ b/drivers/media/video/video-buf-dvb.c @@ -1,5 +1,4 @@ /* - * $Id: video-buf-dvb.c,v 1.7 2004/12/09 12:51:35 kraxel Exp $ * * some helper function for simple DVB cards which simply DMA the * complete transport stream and let the computer sort everything else diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c index 5afdc78..97354f2 100644 --- a/drivers/media/video/video-buf.c +++ b/drivers/media/video/video-buf.c @@ -1,5 +1,4 @@ /* - * $Id: video-buf.c,v 1.18 2005/02/24 13:32:30 kraxel Exp $ * * generic helper functions for video4linux capture buffers, to handle * memory management and PCI DMA. Right now bttv + saa7134 use it. diff --git a/include/linux/videodev.h b/include/linux/videodev.h index 9d6fbde..1cc8c31 100644 --- a/include/linux/videodev.h +++ b/include/linux/videodev.h @@ -3,7 +3,6 @@ #include #include -#include #define HAVE_V4L2 1 #include @@ -29,7 +28,6 @@ struct video_device void (*release)(struct video_device *vfd); -#if 1 /* to be removed in 2.7.x */ /* obsolete -- fops->owner is used instead */ struct module *owner; /* dev->driver_data will be used instead some day. @@ -37,7 +35,6 @@ struct video_device * so the switch over will be transparent for you. * Or use {pci|usb}_{get|set}_drvdata() directly. */ void *priv; -#endif /* for videodev.c intenal usage -- please don't touch */ int users; /* video_exclusive_{open|close} ... */ diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index acbfc52..f623a33 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -270,7 +270,6 @@ struct v4l2_timecode /* The above is based on SMPTE timecodes */ -#if 1 /* * M P E G C O M P R E S S I O N P A R A M E T E R S * @@ -357,7 +356,6 @@ struct v4l2_mpeg_compression { /* I don't expect the above being perfect yet ;) */ __u32 reserved_5[8]; }; -#endif struct v4l2_jpegcompression { @@ -871,10 +869,8 @@ struct v4l2_streamparm #define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) #define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) #define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) -#if 1 /* experimental */ #define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression) #define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression) -#endif #define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) #define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) #define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) diff --git a/include/media/audiochip.h b/include/media/audiochip.h index cd83116..a7ceee9 100644 --- a/include/media/audiochip.h +++ b/include/media/audiochip.h @@ -1,5 +1,4 @@ /* - * $Id: audiochip.h,v 1.5 2005/06/16 22:59:16 hhackmann Exp $ */ #ifndef AUDIOCHIP_H diff --git a/include/media/id.h b/include/media/id.h index 801ddef..6d02c94 100644 --- a/include/media/id.h +++ b/include/media/id.h @@ -1,5 +1,4 @@ /* - * $Id: id.h,v 1.4 2005/06/12 04:19:19 mchehab Exp $ */ /* FIXME: this temporarely, until these are included in linux/i2c-id.h */ diff --git a/include/media/ir-common.h b/include/media/ir-common.h index 6986705..01b5682 100644 --- a/include/media/ir-common.h +++ b/include/media/ir-common.h @@ -1,5 +1,4 @@ /* - * $Id: ir-common.h,v 1.9 2005/05/15 19:01:26 mchehab Exp $ * * some common structs and functions to handle infrared remotes via * input layer ... @@ -21,11 +20,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #define IR_TYPE_RC5 1 +#define IR_TYPE_PD 2 /* Pulse distance encoded IR */ #define IR_TYPE_OTHER 99 #define IR_KEYTAB_TYPE u32 @@ -60,6 +59,7 @@ void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir, u32 ir_extract_bits(u32 data, u32 mask); int ir_dump_samples(u32 *samples, int count); int ir_decode_biphase(u32 *samples, int count, int low, int high); +int ir_decode_pulsedistance(u32 *samples, int count, int low, int high); /* * Local variables: diff --git a/include/media/tuner.h b/include/media/tuner.h index eeaa15d..252673b 100644 --- a/include/media/tuner.h +++ b/include/media/tuner.h @@ -1,5 +1,3 @@ - -/* $Id: tuner.h,v 1.45 2005/07/28 18:41:21 mchehab Exp $ * tuner.h - definition for different tuners @@ -111,6 +109,8 @@ #define TUNER_LG_TDVS_H062F 64 /* DViCO FusionHDTV 5 */ #define TUNER_YMEC_TVF66T5_B_DFF 65 /* Acorp Y878F */ +#define TUNER_LG_NTSC_TALN_MINI 66 + #define NOTUNER 0 #define PAL 1 /* PAL_BG */ #define PAL_I 2 @@ -134,6 +134,7 @@ #define THOMSON 12 #define TUNER_SET_TYPE_ADDR _IOW('T',3,int) +#define TUNER_SET_STANDBY _IOW('T',4,int) #define TDA9887_SET_CONFIG _IOW('t',5,int) /* tv card specific */ @@ -153,9 +154,6 @@ #ifdef __KERNEL__ -#define I2C_ADDR_TDA8290 0x4b -#define I2C_ADDR_TDA8275 0x61 - enum tuner_mode { T_UNINITIALIZED = 0, T_RADIO = 1 << V4L2_TUNER_RADIO, @@ -198,6 +196,7 @@ struct tuner { void (*radio_freq)(struct i2c_client *c, unsigned int freq); int (*has_signal)(struct i2c_client *c); int (*is_stereo)(struct i2c_client *c); + void (*standby)(struct i2c_client *c); }; extern unsigned int tuner_debug; @@ -209,12 +208,16 @@ extern int tea5767_tuner_init(struct i2c_client *c); extern int default_tuner_init(struct i2c_client *c); extern int tea5767_autodetection(struct i2c_client *c); -#define tuner_warn(fmt, arg...) \ - dev_printk(KERN_WARNING , &t->i2c.dev , fmt , ## arg) -#define tuner_info(fmt, arg...) \ - dev_printk(KERN_INFO , &t->i2c.dev , fmt , ## arg) -#define tuner_dbg(fmt, arg...) \ - if (tuner_debug) dev_printk(KERN_DEBUG , &t->i2c.dev , fmt , ## arg) +#define tuner_warn(fmt, arg...) do {\ + printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c.driver->name, \ + t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0) +#define tuner_info(fmt, arg...) do {\ + printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.driver->name, \ + t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0) +#define tuner_dbg(fmt, arg...) do {\ + if (tuner_debug) \ + printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c.driver->name, \ + t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0) #endif /* __KERNEL__ */ diff --git a/include/media/tveeprom.h b/include/media/tveeprom.h index 854a2c2..e24e841 100644 --- a/include/media/tveeprom.h +++ b/include/media/tveeprom.h @@ -1,5 +1,4 @@ /* - * $Id: tveeprom.h,v 1.2 2005/06/12 04:19:19 mchehab Exp $ */ struct tveeprom { diff --git a/include/media/video-buf.h b/include/media/video-buf.h index ae6da6d..ae8d7a0 100644 --- a/include/media/video-buf.h +++ b/include/media/video-buf.h @@ -1,5 +1,4 @@ /* - * $Id: video-buf.h,v 1.9 2004/11/07 13:17:15 kraxel Exp $ * * generic helper functions for video4linux capture buffers, to handle * memory management and PCI DMA. Right now bttv + saa7134 use it. -- cgit v0.10.2 From 24a70fdce872d70171b1f49dcd1a7c3a4e8396b2 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:39 -0700 Subject: [PATCH] v4l: BTTV updates and card additions - Remove $Id CVS logs for V4L files - Added DVICO FusionHDTV 5 Lite card. - Added Acorp Y878F. - CodingStyle fixes. - Added tuner_addr to bttv cards structure. - linux/version.h replaced by linux/utsname.h on bttvp.h - kernel module for acquiring RDS data from a SAA6588. - Allow multiple open() and reading calls to /dev/radio on bttv-driver.c - added i2c address for lgdt330x. Signed-off-by: Hans J. Koch Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/video4linux/CARDLIST.bttv b/Documentation/video4linux/CARDLIST.bttv index 62a12a0..7979c06 100644 --- a/Documentation/video4linux/CARDLIST.bttv +++ b/Documentation/video4linux/CARDLIST.bttv @@ -133,3 +133,5 @@ card=131 - Tibet Systems 'Progress DVR' CS16 card=132 - Kodicom 4400R (master) card=133 - Kodicom 4400R (slave) card=134 - Adlink RTV24 +card=135 - DVICO FusionHDTV 5 Lite +card=136 - Acorp Y878F diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index a97b9b9..3cb398b 100644 --- a/drivers/media/video/bttv-cards.c +++ b/drivers/media/video/bttv-cards.c @@ -1,5 +1,4 @@ /* - $Id: bttv-cards.c,v 1.54 2005/07/19 18:26:46 mkrufky Exp $ bttv-cards.c @@ -169,10 +168,10 @@ static struct CARD { { 0xd01810fc, BTTV_GVBCTV5PCI, "I-O Data Co. GV-BCTV5/PCI" }, { 0x001211bd, BTTV_PINNACLE, "Pinnacle PCTV" }, - // some cards ship with byteswapped IDs ... + /* some cards ship with byteswapped IDs ... */ { 0x1200bd11, BTTV_PINNACLE, "Pinnacle PCTV [bswap]" }, { 0xff00bd11, BTTV_PINNACLE, "Pinnacle PCTV [bswap]" }, - // this seems to happen as well ... + /* this seems to happen as well ... */ { 0xff1211bd, BTTV_PINNACLE, "Pinnacle PCTV" }, { 0x3000121a, BTTV_VOODOOTV_FM, "3Dfx VoodooTV FM/ VoodooTV 200" }, @@ -200,12 +199,12 @@ static struct CARD { { 0x1123153b, BTTV_TERRATVRADIO, "Terratec TV Radio+" }, { 0x1127153b, BTTV_TERRATV, "Terratec TV+ (V1.05)" }, - // clashes with FlyVideo - //{ 0x18521852, BTTV_TERRATV, "Terratec TV+ (V1.10)" }, + /* clashes with FlyVideo + *{ 0x18521852, BTTV_TERRATV, "Terratec TV+ (V1.10)" }, */ { 0x1134153b, BTTV_TERRATVALUE, "Terratec TValue (LR102)" }, - { 0x1135153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, // LR102 - { 0x5018153b, BTTV_TERRATVALUE, "Terratec TValue" }, // ?? - { 0xff3b153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, // ?? + { 0x1135153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, /* LR102 */ + { 0x5018153b, BTTV_TERRATVALUE, "Terratec TValue" }, /* ?? */ + { 0xff3b153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, /* ?? */ { 0x400015b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" }, { 0x400a15b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" }, @@ -287,10 +286,12 @@ static struct CARD { { 0x01071805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #3" }, { 0x01081805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #4" }, - // likely broken, vendor id doesn't match the other magic views ... - //{ 0xa0fca04f, BTTV_MAGICTVIEW063, "Guillemot Maxi TV Video 3" }, + { 0x15409511, BTTV_ACORP_Y878F, "Acorp Y878F" }, - // DVB cards (using pci function .1 for mpeg data xfer) + /* likely broken, vendor id doesn't match the other magic views ... + * { 0xa0fca04f, BTTV_MAGICTVIEW063, "Guillemot Maxi TV Video 3" }, */ + + /* DVB cards (using pci function .1 for mpeg data xfer) */ { 0x01010071, BTTV_NEBULA_DIGITV, "Nebula Electronics DigiTV" }, { 0x07611461, BTTV_AVDVBT_761, "AverMedia AverTV DVB-T 761" }, { 0x001c11bd, BTTV_PINNACLESAT, "Pinnacle PCTV Sat" }, @@ -299,6 +300,7 @@ static struct CARD { { 0xfc00270f, BTTV_TWINHAN_DST, "ChainTech digitop DST-1000 DVB-S" }, { 0x07711461, BTTV_AVDVBT_771, "AVermedia AverTV DVB-T 771" }, { 0xdb1018ac, BTTV_DVICO_DVBT_LITE, "DVICO FusionHDTV DVB-T Lite" }, + { 0xd50018ac, BTTV_DVICO_FUSIONHDTV_5_LITE, "DVICO FusionHDTV 5 Lite" }, { 0, -1, NULL } }; @@ -316,6 +318,7 @@ struct tvcard bttv_tvcards[] = { .svhs = 2, .muxsel = { 2, 3, 1, 0}, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "MIRO PCTV", .video_inputs = 4, @@ -327,6 +330,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 2, 0, 0, 0, 10}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Hauppauge (bt848)", .video_inputs = 4, @@ -338,6 +342,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 1, 2, 3, 4}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "STB, Gateway P/N 6000699 (bt848)", .video_inputs = 3, @@ -350,6 +355,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .needs_tvaudio = 1, .tuner_type = TUNER_PHILIPS_NTSC, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .has_radio = 1, },{ @@ -365,6 +371,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .needs_tvaudio = 0, .tuner_type = 4, + .tuner_addr = ADDR_UNSET, },{ .name = "Diamond DTV2000", .video_inputs = 4, @@ -376,6 +383,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 1, 0, 1, 3}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "AVerMedia TVPhone", .video_inputs = 3, @@ -388,6 +396,7 @@ struct tvcard bttv_tvcards[] = { /* 0x04 for some cards ?? */ .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .audio_hook = avermedia_tvphone_audio, .has_remote = 1, },{ @@ -401,6 +410,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = {0 }, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x08 ---------------------------------- */ @@ -415,6 +425,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "IMS/IXmicro TurboTV", .video_inputs = 3, @@ -427,6 +438,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_TEMIC_PAL, + .tuner_addr = ADDR_UNSET, },{ .name = "Hauppauge (bt878)", .video_inputs = 4, @@ -439,6 +451,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "MIRO PCTV pro", .video_inputs = 3, @@ -450,6 +463,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0x20001,0x10001, 0, 0,10}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x0c ---------------------------------- */ @@ -463,6 +477,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 13, 14, 11, 7, 0, 0}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "AVerMedia TVCapture 98", .video_inputs = 3, @@ -476,6 +491,7 @@ struct tvcard bttv_tvcards[] = { .msp34xx_alt = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .audio_hook = avermedia_tv_stereo_audio, },{ .name = "Aimslab Video Highway Xtreme (VHX)", @@ -489,6 +505,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Zoltrix TV-Max", .video_inputs = 3, @@ -500,6 +517,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = {0 , 0, 1 , 0, 10}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x10 ---------------------------------- */ @@ -510,7 +528,7 @@ struct tvcard bttv_tvcards[] = { .svhs = 2, .gpiomask = 0x01fe00, .muxsel = { 2, 3, 1, 1}, - // 2003-10-20 by "Anton A. Arapov" + /* 2003-10-20 by "Anton A. Arapov" */ .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 }, .needs_tvaudio = 1, .pll = PLL_28, @@ -526,6 +544,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0x4fa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .audio_hook = winview_audio, .has_radio = 1, },{ @@ -539,6 +558,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = {1, 0, 0, 0, 0}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Lifeview FlyVideo II EZ /FlyKit LR38 Bt848 (capture only)", .video_inputs = 4, @@ -550,6 +570,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .no_msp34xx = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x14 ---------------------------------- */ @@ -560,10 +581,11 @@ struct tvcard bttv_tvcards[] = { .svhs = 2, .muxsel = {2, 3, 1, 1}, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Lifeview FlyVideo 98/ Lucky Star Image World ConferenceTV LR50", .video_inputs = 4, - .audio_inputs = 2, // tuner, line in + .audio_inputs = 2, /* tuner, line in */ .tuner = 0, .svhs = 2, .gpiomask = 0x1800, @@ -571,6 +593,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800}, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL_I, + .tuner_addr = ADDR_UNSET, },{ .name = "Askey CPH050/ Phoebe Tv Master + FM", .video_inputs = 3, @@ -583,6 +606,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV, bt878", .video_inputs = 3, @@ -591,11 +615,12 @@ struct tvcard bttv_tvcards[] = { .svhs = -1, .gpiomask = 7, .muxsel = { 2, 3, -1 }, - .digital_mode = DIGITAL_MODE_CAMERA, + .digital_mode = DIGITAL_MODE_CAMERA, .audiomux = { 0, 0, 0, 0, 0 }, .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_ALPS_TSBB5_PAL_I, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x18 ---------------------------------- */ @@ -610,6 +635,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_remote = 1, },{ .name = "Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar", @@ -622,6 +648,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000}, .needs_tvaudio = 0, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .audio_hook = terratv_audio, },{ .name = "Hauppauge WinCam newer (bt878)", @@ -634,6 +661,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 1, 2, 3, 4}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Lifeview FlyVideo 98/ MAXI TV Video PCI2 LR50", .video_inputs = 4, @@ -645,6 +673,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800}, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_SECAM, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x1c ---------------------------------- */ @@ -658,37 +687,38 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0x20000, 0x30000, 0x10000, 0x00000, 0x40000}, .needs_tvaudio = 0, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .audio_hook = terratv_audio, /* GPIO wiring: - External 20 pin connector (for Active Radio Upgrade board) - gpio00: i2c-sda - gpio01: i2c-scl - gpio02: om5610-data - gpio03: om5610-clk - gpio04: om5610-wre - gpio05: om5610-stereo - gpio06: rds6588-davn - gpio07: Pin 7 n.c. - gpio08: nIOW - gpio09+10: nIOR, nSEL ?? (bt878) - gpio09: nIOR (bt848) - gpio10: nSEL (bt848) - Sound Routing: - gpio16: u2-A0 (1st 4052bt) - gpio17: u2-A1 - gpio18: u2-nEN - gpio19: u4-A0 (2nd 4052) - gpio20: u4-A1 - u4-nEN - GND - Btspy: - 00000 : Cdrom (internal audio input) + External 20 pin connector (for Active Radio Upgrade board) + gpio00: i2c-sda + gpio01: i2c-scl + gpio02: om5610-data + gpio03: om5610-clk + gpio04: om5610-wre + gpio05: om5610-stereo + gpio06: rds6588-davn + gpio07: Pin 7 n.c. + gpio08: nIOW + gpio09+10: nIOR, nSEL ?? (bt878) + gpio09: nIOR (bt848) + gpio10: nSEL (bt848) + Sound Routing: + gpio16: u2-A0 (1st 4052bt) + gpio17: u2-A1 + gpio18: u2-nEN + gpio19: u4-A0 (2nd 4052) + gpio20: u4-A1 + u4-nEN - GND + Btspy: + 00000 : Cdrom (internal audio input) 10000 : ext. Video audio input 20000 : TV Mono a0000 : TV Mono/2 - 1a0000 : TV Stereo + 1a0000 : TV Stereo 30000 : Radio 40000 : Mute - */ +*/ },{ /* Jannik Fritsch */ @@ -702,6 +732,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .muxsel_hook = PXC200_muxsel, },{ @@ -710,11 +741,12 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 1, .tuner = 0, .svhs = 2, - .gpiomask = 0x1800, //0x8dfe00 + .gpiomask = 0x1800, /* 0x8dfe00 */ .muxsel = { 2, 3, 1, 1}, .audiomux = { 0, 0x0800, 0x1000, 0x1000, 0x1800, 0 }, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Formac iProTV, Formac ProTV I (bt848)", .video_inputs = 4, @@ -726,6 +758,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 1, 0, 0, 0, 0 }, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x20 ---------------------------------- */ @@ -739,6 +772,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .needs_tvaudio = 0, .tuner_type = 4, + .tuner_addr = ADDR_UNSET, },{ .name = "Terratec TerraTValue Version Bt878", .video_inputs = 3, @@ -751,31 +785,33 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, },{ .name = "Leadtek WinFast 2000/ WinFast 2000 XP", .video_inputs = 4, .audio_inputs = 1, .tuner = 0, .svhs = 2, - .muxsel = { 2, 3, 1, 1, 0}, // TV, CVid, SVid, CVid over SVid connector + .muxsel = { 2, 3, 1, 1, 0}, /* TV, CVid, SVid, CVid over SVid connector */ /* Alexander Varakin [stereo version] */ .gpiomask = 0xb33000, .audiomux = { 0x122000,0x1000,0x0000,0x620000,0x800000 }, /* Audio Routing for "WinFast 2000 XP" (no tv stereo !) gpio23 -- hef4052:nEnable (0x800000) gpio12 -- hef4052:A1 - gpio13 -- hef4052:A0 - 0x0000: external audio - 0x1000: FM - 0x2000: TV - 0x3000: n.c. - Note: There exists another variant "Winfast 2000" with tv stereo !? - Note: eeprom only contains FF and pci subsystem id 107d:6606 - */ + gpio13 -- hef4052:A0 + 0x0000: external audio + 0x1000: FM + 0x2000: TV + 0x3000: n.c. + Note: There exists another variant "Winfast 2000" with tv stereo !? + Note: eeprom only contains FF and pci subsystem id 107d:6606 + */ .needs_tvaudio = 0, .pll = PLL_28, .has_radio = 1, - .tuner_type = 5, // default for now, gpio reads BFFF06 for Pal bg+dk + .tuner_type = 5, /* default for now, gpio reads BFFF06 for Pal bg+dk */ + .tuner_addr = ADDR_UNSET, .audio_hook = winfast2000_audio, .has_remote = 1, },{ @@ -789,6 +825,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800}, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x24 ---------------------------------- */ @@ -802,6 +839,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 }, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_radio = 1, },{ .name = "Prolink PixelView PlayTV pro", @@ -815,6 +853,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Askey CPH06X TView99", .video_inputs = 4, @@ -827,6 +866,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = 1, + .tuner_addr = ADDR_UNSET, .has_remote = 1, },{ .name = "Pinnacle PCTV Studio/Rave", @@ -840,6 +880,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x28 ---------------------------------- */ @@ -854,6 +895,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .needs_tvaudio = 1, .tuner_type = TUNER_PHILIPS_NTSC, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .has_radio = 1, },{ @@ -868,6 +910,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_radio = 1, .audio_hook = avermedia_tvphone_audio, },{ @@ -883,6 +926,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = 1, + .tuner_addr = ADDR_UNSET, },{ .name = "Little OnAir TV", .video_inputs = 3, @@ -894,6 +938,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = {0xff9ff6, 0xff9ff6, 0xff1ff7, 0, 0xff3ffc}, .no_msp34xx = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x2c ---------------------------------- */ @@ -908,6 +953,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_NONE, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "MATRIX-Vision MV-Delta 2", .video_inputs = 5, @@ -920,6 +966,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Zoltrix Genie TV/FM", .video_inputs = 3, @@ -932,6 +979,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = 21, + .tuner_addr = ADDR_UNSET, },{ .name = "Terratec TV/Radio+", .video_inputs = 3, @@ -945,6 +993,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_35, .tuner_type = 1, + .tuner_addr = ADDR_UNSET, .has_radio = 1, },{ @@ -960,6 +1009,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "IODATA GV-BCTV3/PCI", .video_inputs = 3, @@ -972,6 +1022,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_ALPS_TSHC6_NTSC, + .tuner_addr = ADDR_UNSET, .audio_hook = gvbctv3pci_audio, },{ .name = "Prolink PV-BT878P+4E / PixelView PlayTV PAK / Lenco MXTV-9578 CP", @@ -986,6 +1037,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL_I, + .tuner_addr = ADDR_UNSET, .has_remote = 1, /* GPIO wiring: (different from Rev.4C !) GPIO17: U4.A0 (first hef4052bt) @@ -994,8 +1046,8 @@ struct tvcard bttv_tvcards[] = { GPIO21: U4.nEN GPIO22: BT832 Reset Line GPIO23: A5,A0, U5,nEN - Note: At i2c=0x8a is a Bt832 chip, which changes to 0x88 after being reset via GPIO22 - */ + Note: At i2c=0x8a is a Bt832 chip, which changes to 0x88 after being reset via GPIO22 + */ },{ .name = "Eagle Wireless Capricorn2 (bt878A)", .video_inputs = 4, @@ -1007,6 +1059,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 1, 2, 3, 4}, .pll = PLL_28, .tuner_type = -1 /* TUNER_ALPS_TMDH2_NTSC */, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x34 ---------------------------------- */ @@ -1020,20 +1073,21 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 2, 3, 1, 1}, .audiomux = { 1, 0xd0001, 0, 0, 10}, /* sound path (5 sources): - MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable) + MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable) 0= ext. Audio IN 1= from MUX2 2= Mono TV sound from Tuner 3= not connected - MUX2 (mask 0x30000): + MUX2 (mask 0x30000): 0,2,3= from MSP34xx 1= FM stereo Radio from Tuner */ .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Claas Langbehn , - Sven Grothklags */ + Sven Grothklags */ .name = "Typhoon TView RDS + FM Stereo / KNC1 TV Station RDS", .video_inputs = 4, .audio_inputs = 3, @@ -1045,10 +1099,11 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .has_radio = 1, },{ /* Tim Röstermundt - in de.comp.os.unix.linux.hardware: + in de.comp.os.unix.linux.hardware: options bttv card=0 pll=1 radio=1 gpiomask=0x18e0 audiomux=0x44c71f,0x44d71f,0,0x44d71f,0x44dfff options tuner type=5 */ @@ -1060,15 +1115,16 @@ struct tvcard bttv_tvcards[] = { .gpiomask = 0x18e0, .muxsel = { 2, 3, 1, 1}, .audiomux = { 0x0000,0x0800,0x1000,0x1000,0x18e0 }, - /* For cards with tda9820/tda9821: - 0x0000: Tuner normal stereo - 0x0080: Tuner A2 SAP (second audio program = Zweikanalton) - 0x0880: Tuner A2 stereo */ + /* For cards with tda9820/tda9821: + 0x0000: Tuner normal stereo + 0x0080: Tuner A2 SAP (second audio program = Zweikanalton) + 0x0880: Tuner A2 stereo */ .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Miguel Angel Alvarez - old Easy TV BT848 version (model CPH031) */ + old Easy TV BT848 version (model CPH031) */ .name = "Askey CPH031/ BESTBUY Easy TV", .video_inputs = 4, .audio_inputs = 1, @@ -1080,6 +1136,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_TEMIC_PAL, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x38 ---------------------------------- */ @@ -1094,10 +1151,11 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 }, .pll = PLL_28, .tuner_type = 5, + .tuner_addr = ADDR_UNSET, },{ /* This is the ultimate cheapo capture card - * just a BT848A on a small PCB! - * Steve Hosgood */ + * just a BT848A on a small PCB! + * Steve Hosgood */ .name = "GrandTec 'Grand Video Capture' (Bt848)", .video_inputs = 2, .audio_inputs = 0, @@ -1110,19 +1168,21 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_35, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ - /* Daniel Herrington */ - .name = "Askey CPH060/ Phoebe TV Master Only (No FM)", - .video_inputs = 3, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .gpiomask = 0xe00, - .muxsel = { 2, 3, 1, 1}, - .audiomux = { 0x400, 0x400, 0x400, 0x400, 0x800, 0x400 }, - .needs_tvaudio = 1, - .pll = PLL_28, - .tuner_type = TUNER_TEMIC_4036FY5_NTSC, + /* Daniel Herrington */ + .name = "Askey CPH060/ Phoebe TV Master Only (No FM)", + .video_inputs = 3, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .gpiomask = 0xe00, + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 0x400, 0x400, 0x400, 0x400, 0x800, 0x400 }, + .needs_tvaudio = 1, + .pll = PLL_28, + .tuner_type = TUNER_TEMIC_4036FY5_NTSC, + .tuner_addr = ADDR_UNSET, },{ /* Matti Mottus */ .name = "Askey CPH03x TV Capturer", @@ -1130,11 +1190,12 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 1, .tuner = 0, .svhs = 2, - .gpiomask = 0x03000F, + .gpiomask = 0x03000F, .muxsel = { 2, 3, 1, 0}, - .audiomux = { 2,0,0,0,1 }, + .audiomux = { 2,0,0,0,1 }, .pll = PLL_28, .tuner_type = 0, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x3c ---------------------------------- */ @@ -1149,7 +1210,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 2, 0, 0, 1, 8}, .pll = PLL_35, .tuner_type = TUNER_TEMIC_PAL, - + .tuner_addr = ADDR_UNSET, },{ /* Adrian Cox - new Easy TV BT878 version (model CPH061) - special thanks to Informatica Mieres for providing the card */ + new Easy TV BT878 version (model CPH061) + special thanks to Informatica Mieres for providing the card */ .name = "Askey CPH061/ BESTBUY Easy TV (bt878)", .video_inputs = 3, .audio_inputs = 2, @@ -1179,6 +1241,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, },{ /* Lukas Gebauer */ .name = "ATI TV-Wonder", @@ -1191,6 +1254,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0xbffe, 0, 0xbfff, 0, 0xbffe}, .pll = PLL_28, .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x40 ---------------------------------- */ @@ -1206,6 +1270,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL, + .tuner_addr = ADDR_UNSET, },{ /* DeeJay */ @@ -1251,25 +1318,27 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_SHARP_2U5JF5540_NTSC, + .tuner_addr = ADDR_UNSET, .audio_hook = gvbctv3pci_audio, },{ /* ---- card 0x44 ---------------------------------- */ - .name = "3Dfx VoodooTV FM (Euro), VoodooTV 200 (USA)", - // try "insmod msp3400 simple=0" if you have - // sound problems with this card. - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = -1, - .gpiomask = 0x4f8a00, - // 0x100000: 1=MSP enabled (0=disable again) - // 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC) - .audiomux = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff}, - // tvtuner, radio, external,internal, mute, stereo - /* tuner, Composit, SVid, Composit-on-Svid-adapter*/ - .muxsel = { 2, 3 ,0 ,1}, - .tuner_type = TUNER_MT2032, + .name = "3Dfx VoodooTV FM (Euro), VoodooTV 200 (USA)", + /* try "insmod msp3400 simple=0" if you have + * sound problems with this card. */ + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = -1, + .gpiomask = 0x4f8a00, + /* 0x100000: 1=MSP enabled (0=disable again) + * 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC) */ + .audiomux = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff}, + /* tvtuner, radio, external,internal, mute, stereo + * tuner, Composit, SVid, Composit-on-Svid-adapter */ + .muxsel = { 2, 3 ,0 ,1}, + .tuner_type = TUNER_MT2032, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .has_radio = 1, },{ @@ -1279,22 +1348,24 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 0, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .muxsel = { 2 }, .gpiomask = 0 },{ - /* Tomasz Pyra */ - .name = "Prolink Pixelview PV-BT878P+ (Rev.4C,8E)", - .video_inputs = 3, - .audio_inputs = 4, - .tuner = 0, - .svhs = 2, - .gpiomask = 15, - .muxsel = { 2, 3, 1, 1}, - .audiomux = { 0, 0, 11, 7, 13, 0}, // TV and Radio with same GPIO ! - .needs_tvaudio = 1, - .pll = PLL_28, - .tuner_type = 25, + /* Tomasz Pyra */ + .name = "Prolink Pixelview PV-BT878P+ (Rev.4C,8E)", + .video_inputs = 3, + .audio_inputs = 4, + .tuner = 0, + .svhs = 2, + .gpiomask = 15, + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 0, 0, 11, 7, 13, 0}, /* TV and Radio with same GPIO ! */ + .needs_tvaudio = 1, + .pll = PLL_28, + .tuner_type = 25, + .tuner_addr = ADDR_UNSET, .has_remote = 1, /* GPIO wiring: GPIO0: U4.A0 (hef4052bt) @@ -1302,16 +1373,18 @@ struct tvcard bttv_tvcards[] = { GPIO2: U4.A1 (second hef4052bt) GPIO3: U4.nEN, U5.A0, A5.nEN GPIO8-15: vrd866b ? - */ + */ },{ .name = "Lifeview FlyVideo 98EZ (capture only) LR51", .video_inputs = 4, .audio_inputs = 0, .tuner = -1, .svhs = 2, - .muxsel = { 2, 3, 1, 1}, // AV1, AV2, SVHS, CVid adapter on SVHS + .muxsel = { 2, 3, 1, 1}, /* AV1, AV2, SVHS, CVid adapter on SVHS */ .pll = PLL_28, .no_msp34xx = 1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x48 ---------------------------------- */ @@ -1329,8 +1402,9 @@ struct tvcard bttv_tvcards[] = { .no_tda9875 = 1, .pll = PLL_28, .tuner_type = 5, - .audio_hook = pvbt878p9b_audio, // Note: not all cards have stereo - .has_radio = 1, // Note: not all cards have radio + .tuner_addr = ADDR_UNSET, + .audio_hook = pvbt878p9b_audio, /* Note: not all cards have stereo */ + .has_radio = 1, /* Note: not all cards have radio */ .has_remote = 1, /* GPIO wiring: GPIO0: A0 hef4052 @@ -1338,7 +1412,7 @@ struct tvcard bttv_tvcards[] = { GPIO3: nEN hef4052 GPIO8-15: vrd866b GPIO20,22,23: R30,R29,R28 - */ + */ },{ /* Clay Kunz */ /* you must jumper JP5 for the card to work */ @@ -1352,6 +1426,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .needs_tvaudio = 0, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Miguel Freitas */ .name = "RemoteVision MX (RV605)", @@ -1362,71 +1437,78 @@ struct tvcard bttv_tvcards[] = { .gpiomask = 0x00, .gpiomask2 = 0x07ff, .muxsel = { 0x33, 0x13, 0x23, 0x43, 0xf3, 0x73, 0xe3, 0x03, - 0xd3, 0xb3, 0xc3, 0x63, 0x93, 0x53, 0x83, 0xa3 }, + 0xd3, 0xb3, 0xc3, 0x63, 0x93, 0x53, 0x83, 0xa3 }, .no_msp34xx = 1, .no_tda9875 = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .muxsel_hook = rv605_muxsel, },{ - .name = "Powercolor MTV878/ MTV878R/ MTV878F", - .video_inputs = 3, - .audio_inputs = 2, + .name = "Powercolor MTV878/ MTV878R/ MTV878F", + .video_inputs = 3, + .audio_inputs = 2, .tuner = 0, - .svhs = 2, - .gpiomask = 0x1C800F, // Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset - .muxsel = { 2, 1, 1, }, - .audiomux = { 0, 1, 2, 2, 4 }, - .needs_tvaudio = 0, - .tuner_type = TUNER_PHILIPS_PAL, + .svhs = 2, + .gpiomask = 0x1C800F, /* Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset */ + .muxsel = { 2, 1, 1, }, + .audiomux = { 0, 1, 2, 2, 4 }, + .needs_tvaudio = 0, + .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .has_radio = 1, },{ /* ---- card 0x4c ---------------------------------- */ - /* Masaki Suzuki */ - .name = "Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP)", - .video_inputs = 3, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .gpiomask = 0x140007, - .muxsel = { 2, 3, 1, 1 }, - .audiomux = { 0, 1, 2, 3, 4, 0 }, - .tuner_type = TUNER_PHILIPS_NTSC, - .audio_hook = windvr_audio, -},{ - .name = "GrandTec Multi Capture Card (Bt878)", - .video_inputs = 4, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .gpiomask = 0, - .muxsel = { 2, 3, 1, 0 }, - .audiomux = { 0 }, - .needs_tvaudio = 0, - .no_msp34xx = 1, - .pll = PLL_28, - .tuner_type = -1, -},{ - .name = "Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF", - .video_inputs = 4, - .audio_inputs = 3, - .tuner = 0, - .svhs = 2, - .gpiomask = 7, - .muxsel = { 2, 3, 1, 1 }, // Tuner, SVid, SVHS, SVid to SVHS connector - .audiomux = { 0 ,0 ,4, 4,4,4},// Yes, this tuner uses the same audio output for TV and FM radio! - // This card lacks external Audio In, so we mute it on Ext. & Int. - // The PCB can take a sbx1637/sbx1673, wiring unknown. - // This card lacks PCI subsystem ID, sigh. - // audiomux=1: lower volume, 2+3: mute - // btwincap uses 0x80000/0x80003 - .needs_tvaudio = 0, - .no_msp34xx = 1, - .pll = PLL_28, - .tuner_type = 5, // Samsung TCPA9095PC27A (BG+DK), philips compatible, w/FM, stereo and - // radio signal strength indicators work fine. - .has_radio = 1, + /* Masaki Suzuki */ + .name = "Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP)", + .video_inputs = 3, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .gpiomask = 0x140007, + .muxsel = { 2, 3, 1, 1 }, + .audiomux = { 0, 1, 2, 3, 4, 0 }, + .tuner_type = TUNER_PHILIPS_NTSC, + .tuner_addr = ADDR_UNSET, + .audio_hook = windvr_audio, +},{ + .name = "GrandTec Multi Capture Card (Bt878)", + .video_inputs = 4, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .gpiomask = 0, + .muxsel = { 2, 3, 1, 0 }, + .audiomux = { 0 }, + .needs_tvaudio = 0, + .no_msp34xx = 1, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, +},{ + .name = "Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF", + .video_inputs = 4, + .audio_inputs = 3, + .tuner = 0, + .svhs = 2, + .gpiomask = 7, + .muxsel = { 2, 3, 1, 1 }, /* Tuner, SVid, SVHS, SVid to SVHS connector */ + .audiomux = { 0 ,0 ,4, 4,4,4},/* Yes, this tuner uses the same audio output for TV and FM radio! + * This card lacks external Audio In, so we mute it on Ext. & Int. + * The PCB can take a sbx1637/sbx1673, wiring unknown. + * This card lacks PCI subsystem ID, sigh. + * audiomux=1: lower volume, 2+3: mute + * btwincap uses 0x80000/0x80003 + */ + .needs_tvaudio = 0, + .no_msp34xx = 1, + .pll = PLL_28, + .tuner_type = 5, + .tuner_addr = ADDR_UNSET, + /* Samsung TCPA9095PC27A (BG+DK), philips compatible, w/FM, stereo and + radio signal strength indicators work fine. */ + .has_radio = 1, /* GPIO Info: GPIO0,1: HEF4052 A0,A1 GPIO2: HEF4052 nENABLE @@ -1437,25 +1519,27 @@ struct tvcard bttv_tvcards[] = { GPIO22,23: ?? ?? : mtu8b56ep microcontroller for IR (GPIO wiring unknown)*/ },{ - /* Arthur Tetzlaff-Deas, DSP Design Ltd */ - .name = "DSP Design TCVIDEO", - .video_inputs = 4, - .svhs = -1, - .muxsel = { 2, 3, 1, 0}, - .pll = PLL_28, - .tuner_type = -1, + /* Arthur Tetzlaff-Deas, DSP Design Ltd */ + .name = "DSP Design TCVIDEO", + .video_inputs = 4, + .svhs = -1, + .muxsel = { 2, 3, 1, 0}, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ - /* ---- card 0x50 ---------------------------------- */ + /* ---- card 0x50 ---------------------------------- */ .name = "Hauppauge WinTV PVR", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .muxsel = { 2, 0, 1, 1}, - .needs_tvaudio = 1, - .pll = PLL_28, - .tuner_type = -1, + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .muxsel = { 2, 0, 1, 1}, + .needs_tvaudio = 1, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .gpiomask = 7, .audiomux = {7}, @@ -1471,6 +1555,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_NTSC_M, + .tuner_addr = ADDR_UNSET, .audio_hook = gvbctv5pci_audio, .has_radio = 1, },{ @@ -1482,9 +1567,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 3, 2, 0, 1 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 100/150 (848)", /* 0x04-54C0-C1 & older boards */ .video_inputs = 3, @@ -1494,9 +1580,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 2, 3, 1 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ /* ---- card 0x54 ---------------------------------- */ @@ -1508,9 +1595,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 3, 1 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 101/151", /* 0x1(4|5)-0004-C4 */ .video_inputs = 1, @@ -1520,9 +1608,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 0 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 101/151 w/ svid", /* 0x(16|17|20)-00C4-C1 */ .video_inputs = 2, @@ -1532,9 +1621,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 0, 1 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 200/201/250/251", /* 0x1(8|9|E|F)-0004-C4 */ .video_inputs = 1, @@ -1543,10 +1633,11 @@ struct tvcard bttv_tvcards[] = { .svhs = -1, .muxsel = { 0 }, .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ /* ---- card 0x58 ---------------------------------- */ @@ -1557,10 +1648,11 @@ struct tvcard bttv_tvcards[] = { .svhs = 1, .muxsel = { 0, 1 }, .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 210/220", /* 0x1(A|B)-04C0-C1 */ .video_inputs = 2, @@ -1569,10 +1661,11 @@ struct tvcard bttv_tvcards[] = { .svhs = 1, .muxsel = { 2, 3 }, .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 500", /* 500 */ .video_inputs = 2, @@ -1582,19 +1675,21 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 2, 3 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ - .name = "Osprey 540", /* 540 */ - .video_inputs = 4, - .audio_inputs = 1, - .tuner = -1, - .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .name = "Osprey 540", /* 540 */ + .video_inputs = 4, + .audio_inputs = 1, + .tuner = -1, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ /* ---- card 0x5C ---------------------------------- */ @@ -1605,10 +1700,11 @@ struct tvcard bttv_tvcards[] = { .svhs = 1, .muxsel = { 2, 3 }, .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, /* must avoid, conflicts with the bt860 */ + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, /* must avoid, conflicts with the bt860 */ },{ /* M G Berberich */ .name = "IDS Eagle", @@ -1616,6 +1712,7 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 0, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .svhs = -1, .gpiomask = 0, .muxsel = { 0, 1, 2, 3 }, @@ -1630,6 +1727,7 @@ struct tvcard bttv_tvcards[] = { .svhs = 1, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .no_msp34xx = 1, .no_tda9875 = 1, .no_tda7432 = 1, @@ -1641,38 +1739,40 @@ struct tvcard bttv_tvcards[] = { .no_gpioirq = 1, .has_dvb = 1, },{ - .name = "Formac ProTV II (bt878)", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 3, - .gpiomask = 2, - // TV, Comp1, Composite over SVID con, SVID - .muxsel = { 2, 3, 1, 1}, - .audiomux = { 2, 2, 0, 0, 0 }, - .pll = PLL_28, + .name = "Formac ProTV II (bt878)", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 3, + .gpiomask = 2, + /* TV, Comp1, Composite over SVID con, SVID */ + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 2, 2, 0, 0, 0 }, + .pll = PLL_28, .has_radio = 1, - .tuner_type = TUNER_PHILIPS_PAL, - /* sound routing: - GPIO=0x00,0x01,0x03: mute (?) - 0x02: both TV and radio (tuner: FM1216/I) - The card has onboard audio connectors labeled "cdrom" and "board", - not soldered here, though unknown wiring. - Card lacks: external audio in, pci subsystem id. - */ + .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, +/* sound routing: + GPIO=0x00,0x01,0x03: mute (?) + 0x02: both TV and radio (tuner: FM1216/I) + The card has onboard audio connectors labeled "cdrom" and "board", + not soldered here, though unknown wiring. + Card lacks: external audio in, pci subsystem id. +*/ },{ /* ---- card 0x60 ---------------------------------- */ .name = "MachTV", - .video_inputs = 3, - .audio_inputs = 1, - .tuner = 0, - .svhs = -1, - .gpiomask = 7, - .muxsel = { 2, 3, 1, 1}, - .audiomux = { 0, 1, 2, 3, 4}, - .needs_tvaudio = 1, - .tuner_type = 5, + .video_inputs = 3, + .audio_inputs = 1, + .tuner = 0, + .svhs = -1, + .gpiomask = 7, + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 0, 1, 2, 3, 4}, + .needs_tvaudio = 1, + .tuner_type = 5, + .tuner_addr = ADDR_UNSET, .pll = 1, },{ .name = "Euresys Picolo", @@ -1686,6 +1786,8 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .muxsel = { 2, 0, 1}, .pll = PLL_28, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, },{ /* Luc Van Hoeylandt */ .name = "ProVideo PV150", /* 0x4f */ @@ -1699,7 +1801,8 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .no_msp34xx = 1, .pll = PLL_28, - .tuner_type = -1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, },{ /* Hiroshi Takekawa */ /* This card lacks subsystem ID */ @@ -1716,78 +1819,85 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = 2, + .tuner_addr = ADDR_UNSET, .audio_hook = adtvk503_audio, },{ /* ---- card 0x64 ---------------------------------- */ - .name = "Hercules Smart TV Stereo", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .gpiomask = 0x00, - .muxsel = { 2, 3, 1, 1 }, - .needs_tvaudio = 1, - .no_msp34xx = 1, - .pll = PLL_28, - .tuner_type = 5, + .name = "Hercules Smart TV Stereo", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .gpiomask = 0x00, + .muxsel = { 2, 3, 1, 1 }, + .needs_tvaudio = 1, + .no_msp34xx = 1, + .pll = PLL_28, + .tuner_type = 5, + .tuner_addr = ADDR_UNSET, /* Notes: - - card lacks subsystem ID - - stereo variant w/ daughter board with tda9874a @0xb0 - - Audio Routing: + - card lacks subsystem ID + - stereo variant w/ daughter board with tda9874a @0xb0 + - Audio Routing: always from tda9874 independent of GPIO (?) external line in: unknown - - Other chips: em78p156elp @ 0x96 (probably IR remote control) - hef4053 (instead 4052) for unknown function + - Other chips: em78p156elp @ 0x96 (probably IR remote control) + hef4053 (instead 4052) for unknown function */ },{ - .name = "Pace TV & Radio Card", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .muxsel = { 2, 3, 1, 1}, // Tuner, CVid, SVid, CVid over SVid connector - .gpiomask = 0, - .no_tda9875 = 1, - .no_tda7432 = 1, - .tuner_type = 1, - .has_radio = 1, - .pll = PLL_28, - /* Bt878, Bt832, FI1246 tuner; no pci subsystem id - only internal line out: (4pin header) RGGL - Radio must be decoded by msp3410d (not routed through)*/ - // .digital_mode = DIGITAL_MODE_CAMERA, // todo! -},{ - /* Chris Willing */ - .name = "IVC-200", - .video_inputs = 1, - .audio_inputs = 0, - .tuner = -1, - .tuner_type = -1, - .svhs = -1, - .gpiomask = 0xdf, - .muxsel = { 2 }, - .pll = PLL_28, + .name = "Pace TV & Radio Card", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .muxsel = { 2, 3, 1, 1}, /* Tuner, CVid, SVid, CVid over SVid connector */ + .gpiomask = 0, + .no_tda9875 = 1, + .no_tda7432 = 1, + .tuner_type = 1, + .tuner_addr = ADDR_UNSET, + .has_radio = 1, + .pll = PLL_28, + /* Bt878, Bt832, FI1246 tuner; no pci subsystem id + only internal line out: (4pin header) RGGL + Radio must be decoded by msp3410d (not routed through)*/ + /* + .digital_mode = DIGITAL_MODE_CAMERA, todo! + */ +},{ + /* Chris Willing */ + .name = "IVC-200", + .video_inputs = 1, + .audio_inputs = 0, + .tuner = -1, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .svhs = -1, + .gpiomask = 0xdf, + .muxsel = { 2 }, + .pll = PLL_28, },{ .name = "Grand X-Guard / Trust 814PCI", .video_inputs = 16, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, .tuner_type = 4, - .gpiomask2 = 0xff, + .tuner_addr = ADDR_UNSET, + .gpiomask2 = 0xff, .muxsel = { 2,2,2,2, 3,3,3,3, 1,1,1,1, 0,0,0,0 }, .muxsel_hook = xguard_muxsel, .no_msp34xx = 1, .no_tda9875 = 1, - .no_tda7432 = 1, + .no_tda7432 = 1, .pll = PLL_28, },{ /* ---- card 0x68 ---------------------------------- */ .name = "Nebula Electronics DigiTV", .video_inputs = 1, - .tuner = -1, + .tuner = -1, .svhs = -1, .muxsel = { 2, 3, 1, 0}, .no_msp34xx = 1, @@ -1795,22 +1905,24 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_dvb = 1, .no_gpioirq = 1, },{ /* Jorge Boncompte - DTI2 */ .name = "ProVideo PV143", - .video_inputs = 4, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .gpiomask = 0, - .muxsel = { 2, 3, 1, 0 }, - .audiomux = { 0 }, - .needs_tvaudio = 0, - .no_msp34xx = 1, - .pll = PLL_28, - .tuner_type = -1, + .video_inputs = 4, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .gpiomask = 0, + .muxsel = { 2, 3, 1, 0 }, + .audiomux = { 0 }, + .needs_tvaudio = 0, + .no_msp34xx = 1, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* M.Klahr@phytec.de */ .name = "PHYTEC VD-009-X1 MiniDIN (bt878)", @@ -1824,6 +1936,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "PHYTEC VD-009-X1 Combi (bt878)", .video_inputs = 4, @@ -1836,6 +1949,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x6c ---------------------------------- */ @@ -1846,13 +1960,14 @@ struct tvcard bttv_tvcards[] = { .svhs = 9, .gpiomask = 0x00, .gpiomask2 = 0x03, /* gpiomask2 defines the bits used to switch audio - via the upper nibble of muxsel. here: used for - xternal video-mux */ + via the upper nibble of muxsel. here: used for + xternal video-mux */ .muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x00 }, .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "PHYTEC VD-009 Combi (bt878)", .video_inputs = 10, @@ -1861,23 +1976,25 @@ struct tvcard bttv_tvcards[] = { .svhs = 9, .gpiomask = 0x00, .gpiomask2 = 0x03, /* gpiomask2 defines the bits used to switch audio - via the upper nibble of muxsel. here: used for - xternal video-mux */ + via the upper nibble of muxsel. here: used for + xternal video-mux */ .muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x01 }, .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ - .name = "IVC-100", - .video_inputs = 4, - .audio_inputs = 0, - .tuner = -1, - .tuner_type = -1, - .svhs = -1, - .gpiomask = 0xdf, - .muxsel = { 2, 3, 1, 0 }, - .pll = PLL_28, + .name = "IVC-100", + .video_inputs = 4, + .audio_inputs = 0, + .tuner = -1, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .svhs = -1, + .gpiomask = 0xdf, + .muxsel = { 2, 3, 1, 0 }, + .pll = PLL_28, },{ /* IVC-120G - Alan Garfield */ .name = "IVC-120G", @@ -1885,6 +2002,7 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 0, /* card has no audio */ .tuner = -1, /* card has no tuner */ .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .svhs = -1, /* card has no svhs */ .needs_tvaudio = 0, .no_msp34xx = 1, @@ -1892,7 +2010,7 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .gpiomask = 0x00, .muxsel = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }, .muxsel_hook = ivc120_muxsel, .pll = PLL_28, },{ @@ -1905,6 +2023,7 @@ struct tvcard bttv_tvcards[] = { .svhs = 2, .muxsel = { 2, 3, 1, 0}, .tuner_type = TUNER_PHILIPS_ATSC, + .tuner_addr = ADDR_UNSET, .has_dvb = 1, },{ .name = "Twinhan DST + clones", @@ -1912,19 +2031,21 @@ struct tvcard bttv_tvcards[] = { .no_tda9875 = 1, .no_tda7432 = 1, .tuner_type = TUNER_ABSENT, + .tuner_addr = ADDR_UNSET, .no_video = 1, .has_dvb = 1, },{ - .name = "Winfast VC100", + .name = "Winfast VC100", .video_inputs = 3, .audio_inputs = 0, .svhs = 1, - .tuner = -1, // no tuner - .muxsel = { 3, 1, 1, 3}, // Vid In, SVid In, Vid over SVid in connector - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, - .tuner_type = TUNER_ABSENT, + .tuner = -1, + .muxsel = { 3, 1, 1, 3}, /* Vid In, SVid In, Vid over SVid in connector */ + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, + .tuner_type = TUNER_ABSENT, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, },{ .name = "Teppro TEV-560/InterVision IV-560", @@ -1937,44 +2058,49 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 1, 1, 1, 1, 0}, .needs_tvaudio = 1, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .pll = PLL_35, },{ /* ---- card 0x74 ---------------------------------- */ - .name = "SIMUS GVC1100", - .video_inputs = 4, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .tuner_type = -1, - .pll = PLL_28, - .muxsel = { 2, 2, 2, 2}, - .gpiomask = 0x3F, + .name = "SIMUS GVC1100", + .video_inputs = 4, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .pll = PLL_28, + .muxsel = { 2, 2, 2, 2}, + .gpiomask = 0x3F, .muxsel_hook = gvc1100_muxsel, },{ - /* Carlos Silva r3pek@r3pek.homelinux.org || card 0x75 */ - .name = "NGS NGSTV+", - .video_inputs = 3, - .tuner = 0, - .svhs = 2, - .gpiomask = 0x008007, - .muxsel = {2, 3, 0, 0}, - .audiomux = {0, 0, 0, 0, 0x000003, 0}, - .pll = PLL_28, - .tuner_type = TUNER_PHILIPS_PAL, - .has_remote = 1, -},{ - /* http://linuxmedialabs.com */ - .name = "LMLBT4", - .video_inputs = 4, /* IN1,IN2,IN3,IN4 */ - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .muxsel = { 2, 3, 1, 0 }, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, - .needs_tvaudio = 0, + /* Carlos Silva r3pek@r3pek.homelinux.org || card 0x75 */ + .name = "NGS NGSTV+", + .video_inputs = 3, + .tuner = 0, + .svhs = 2, + .gpiomask = 0x008007, + .muxsel = {2, 3, 0, 0}, + .audiomux = {0, 0, 0, 0, 0x000003, 0}, + .pll = PLL_28, + .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, + .has_remote = 1, +},{ + /* http://linuxmedialabs.com */ + .name = "LMLBT4", + .video_inputs = 4, /* IN1,IN2,IN3,IN4 */ + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .muxsel = { 2, 3, 1, 0 }, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, + .needs_tvaudio = 0, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Helmroos Harri */ .name = "Tekram M205 PRO", @@ -1982,6 +2108,7 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 1, .tuner = 0, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .svhs = 2, .needs_tvaudio = 0, .gpiomask = 0x68, @@ -2004,6 +2131,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .has_remote = 1, .has_radio = 1, },{ @@ -2026,6 +2154,8 @@ struct tvcard bttv_tvcards[] = { .pll = PLL_28, .needs_tvaudio = 0, .muxsel_hook = picolo_tetra_muxsel,/*Required as it doesn't follow the classic input selection policy*/ + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Spirit TV Tuner from http://spiritmodems.com.au */ /* Stafford Goodsell */ @@ -2038,23 +2168,25 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 2, 1, 1 }, .audiomux = { 0x02, 0x00, 0x00, 0x00, 0x00}, .tuner_type = TUNER_TEMIC_PAL, + .tuner_addr = ADDR_UNSET, .no_msp34xx = 1, .no_tda9875 = 1, },{ /* Wolfram Joost */ - .name = "AVerMedia AVerTV DVB-T 771", - .video_inputs = 2, - .svhs = 1, - .tuner = -1, - .tuner_type = TUNER_ABSENT, - .muxsel = { 3 , 3 }, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, - .pll = PLL_28, - .has_dvb = 1, - .no_gpioirq = 1, - .has_remote = 1, + .name = "AVerMedia AVerTV DVB-T 771", + .video_inputs = 2, + .svhs = 1, + .tuner = -1, + .tuner_type = TUNER_ABSENT, + .tuner_addr = ADDR_UNSET, + .muxsel = { 3 , 3 }, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, + .pll = PLL_28, + .has_dvb = 1, + .no_gpioirq = 1, + .has_remote = 1, },{ /* ---- card 0x7c ---------------------------------- */ /* Matt Jesson */ @@ -2069,6 +2201,7 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_dvb = 1, .no_gpioirq = 1, .has_remote = 1, @@ -2081,12 +2214,13 @@ struct tvcard bttv_tvcards[] = { .svhs = -1, .gpiomask = 0x0, .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3 }, + 3, 3, 3, 3, 3, 3, 3, 3 }, .muxsel_hook = sigmaSQ_muxsel, .audiomux = { 0 }, .no_msp34xx = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* andre.schwarz@matrix-vision.de */ .name = "MATRIX Vision Sigma-SLC", @@ -2101,6 +2235,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* BTTV_APAC_VIEWCOMP */ /* Attila Kondoros */ @@ -2116,6 +2251,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .has_remote = 1, /* miniremote works, see ir-kbd-gpio.c */ .has_radio = 1, /* not every card has radio */ },{ @@ -2131,6 +2267,7 @@ struct tvcard bttv_tvcards[] = { .no_video = 1, .has_dvb = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Steven */ .name = "V-Gear MyVCD", @@ -2144,62 +2281,65 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_NTSC_M, + .tuner_addr = ADDR_UNSET, .has_radio = 0, - // .has_remote = 1, },{ /* Rick C */ - .name = "Super TV Tuner", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .muxsel = { 2, 3, 1, 0}, - .tuner_type = TUNER_PHILIPS_NTSC, - .gpiomask = 0x008007, - .audiomux = { 0, 0x000001,0,0, 0}, - .needs_tvaudio = 1, - .has_radio = 1, -},{ - /* Chris Fanning */ - .name = "Tibet Systems 'Progress DVR' CS16", - .video_inputs = 16, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, - .pll = PLL_28, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, - .tuner_type = -1, - .muxsel_hook = tibetCS16_muxsel, + .name = "Super TV Tuner", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .muxsel = { 2, 3, 1, 0}, + .tuner_type = TUNER_PHILIPS_NTSC, + .tuner_addr = ADDR_UNSET, + .gpiomask = 0x008007, + .audiomux = { 0, 0x000001,0,0, 0}, + .needs_tvaudio = 1, + .has_radio = 1, +},{ + /* Chris Fanning */ + .name = "Tibet Systems 'Progress DVR' CS16", + .video_inputs = 16, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, + .pll = PLL_28, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .muxsel_hook = tibetCS16_muxsel, }, { /* Bill Brack */ /* - * Note that, because of the card's wiring, the "master" - * BT878A chip (i.e. the one which controls the analog switch - * and must use this card type) is the 2nd one detected. The - * other 3 chips should use card type 0x85, whose description - * follows this one. There is a EEPROM on the card (which is - * connected to the I2C of one of those other chips), but is - * not currently handled. There is also a facility for a - * "monitor", which is also not currently implemented. - */ - .name = "Kodicom 4400R (master)", + * Note that, because of the card's wiring, the "master" + * BT878A chip (i.e. the one which controls the analog switch + * and must use this card type) is the 2nd one detected. The + * other 3 chips should use card type 0x85, whose description + * follows this one. There is a EEPROM on the card (which is + * connected to the I2C of one of those other chips), but is + * not currently handled. There is also a facility for a + * "monitor", which is also not currently implemented. + */ + .name = "Kodicom 4400R (master)", .video_inputs = 16, .audio_inputs = 0, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .svhs = -1, /* GPIO bits 0-9 used for analog switch: - * 00 - 03: camera selector - * 04 - 06: channel (controller) selector - * 07: data (1->on, 0->off) - * 08: strobe - * 09: reset - * bit 16 is input from sync separator for the channel - */ + * 00 - 03: camera selector + * 04 - 06: channel (controller) selector + * 07: data (1->on, 0->off) + * 08: strobe + * 09: reset + * bit 16 is input from sync separator for the channel + */ .gpiomask = 0x0003ff, .no_gpioirq = 1, .muxsel = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, @@ -2212,15 +2352,16 @@ struct tvcard bttv_tvcards[] = { { /* Bill Brack */ /* Note that, for reasons unknown, the "master" BT878A chip (i.e. the - * one which controls the analog switch, and must use the card type) - * is the 2nd one detected. The other 3 chips should use this card - * type - */ + * one which controls the analog switch, and must use the card type) + * is the 2nd one detected. The other 3 chips should use this card + * type + */ .name = "Kodicom 4400R (slave)", .video_inputs = 16, .audio_inputs = 0, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .svhs = -1, .gpiomask = 0x010000, .no_gpioirq = 1, @@ -2232,18 +2373,51 @@ struct tvcard bttv_tvcards[] = { .muxsel_hook = kodicom4400r_muxsel, }, { - /* ---- card 0x85---------------------------------- */ - /* Michael Henson */ - /* Adlink RTV24 with special unlock codes */ - .name = "Adlink RTV24", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .muxsel = { 2, 3, 1, 0}, - .tuner_type = -1, - .pll = PLL_28, - + /* ---- card 0x86---------------------------------- */ + /* Michael Henson */ + /* Adlink RTV24 with special unlock codes */ + .name = "Adlink RTV24", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .muxsel = { 2, 3, 1, 0}, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .pll = PLL_28, +}, +{ + /* ---- card 0x87---------------------------------- */ + /* Michael Krufky */ + .name = "DVICO FusionHDTV 5 Lite", + .tuner = 0, + .tuner_type = TUNER_LG_TDVS_H062F, + .tuner_addr = ADDR_UNSET, + .video_inputs = 2, + .audio_inputs = 1, + .svhs = 2, + .muxsel = { 2, 3 }, + .gpiomask = 0x00e00007, + .audiomux = { 0x00400005, 0, 0, 0, 0, 0 }, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, +},{ + /* ---- card 0x88---------------------------------- */ + /* Mauro Carvalho Chehab */ + .name = "Acorp Y878F", + .video_inputs = 3, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .gpiomask = 0x01fe00, + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 }, + .needs_tvaudio = 1, + .pll = PLL_28, + .tuner_type = TUNER_YMEC_TVF66T5_B_DFF, + .tuner_addr = 0xc1 >>1, + .has_radio = 1, }}; static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards); @@ -2355,32 +2529,32 @@ static void flyvideo_gpio(struct bttv *btv) int tuner=-1,ttype; gpio_inout(0xffffff, 0); - udelay(8); // without this we would see the 0x1800 mask + udelay(8); /* without this we would see the 0x1800 mask */ gpio = gpio_read(); /* FIXME: must restore OUR_EN ??? */ - // all cards provide GPIO info, some have an additional eeprom - // LR50: GPIO coding can be found lower right CP1 .. CP9 - // CP9=GPIO23 .. CP1=GPIO15; when OPEN, the corresponding GPIO reads 1. - // GPIO14-12: n.c. - // LR90: GP9=GPIO23 .. GP1=GPIO15 (right above the bt878) - - // lowest 3 bytes are remote control codes (no handshake needed) - // xxxFFF: No remote control chip soldered - // xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered - // Note: Some bits are Audio_Mask ! + /* all cards provide GPIO info, some have an additional eeprom + * LR50: GPIO coding can be found lower right CP1 .. CP9 + * CP9=GPIO23 .. CP1=GPIO15; when OPEN, the corresponding GPIO reads 1. + * GPIO14-12: n.c. + * LR90: GP9=GPIO23 .. GP1=GPIO15 (right above the bt878) + * lowest 3 bytes are remote control codes (no handshake needed) + * xxxFFF: No remote control chip soldered + * xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered + * Note: Some bits are Audio_Mask ! + */ ttype=(gpio&0x0f0000)>>16; switch(ttype) { - case 0x0: tuner=2; // NTSC, e.g. TPI8NSR11P + case 0x0: tuner=2; /* NTSC, e.g. TPI8NSR11P */ break; - case 0x2: tuner=39;// LG NTSC (newer TAPC series) TAPC-H701P + case 0x2: tuner=39;/* LG NTSC (newer TAPC series) TAPC-H701P */ break; - case 0x4: tuner=5; // Philips PAL TPI8PSB02P, TPI8PSB12P, TPI8PSB12D or FI1216, FM1216 + case 0x4: tuner=5; /* Philips PAL TPI8PSB02P, TPI8PSB12P, TPI8PSB12D or FI1216, FM1216 */ break; - case 0x6: tuner=37; // LG PAL (newer TAPC series) TAPC-G702P + case 0x6: tuner=37;/* LG PAL (newer TAPC series) TAPC-G702P */ break; - case 0xC: tuner=3; // Philips SECAM(+PAL) FQ1216ME or FI1216MF + case 0xC: tuner=3; /* Philips SECAM(+PAL) FQ1216ME or FI1216MF */ break; default: printk(KERN_INFO "bttv%d: FlyVideo_gpio: unknown tuner type.\n", btv->c.nr); @@ -2388,15 +2562,16 @@ static void flyvideo_gpio(struct bttv *btv) has_remote = gpio & 0x800000; has_radio = gpio & 0x400000; - // unknown 0x200000; - // unknown2 0x100000; - is_capture_only = !(gpio & 0x008000); //GPIO15 + /* unknown 0x200000; + * unknown2 0x100000; */ + is_capture_only = !(gpio & 0x008000); /* GPIO15 */ has_tda9820_tda9821 = !(gpio & 0x004000); - is_lr90 = !(gpio & 0x002000); // else LR26/LR50 (LR38/LR51 f. capture only) - // gpio & 0x001000 // output bit for audio routing + is_lr90 = !(gpio & 0x002000); /* else LR26/LR50 (LR38/LR51 f. capture only) */ + /* + * gpio & 0x001000 output bit for audio routing */ if(is_capture_only) - tuner=4; // No tuner present + tuner=4; /* No tuner present */ printk(KERN_INFO "bttv%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n", btv->c.nr, has_radio? "yes":"no ", has_remote? "yes":"no ", tuner, gpio); @@ -2404,15 +2579,15 @@ static void flyvideo_gpio(struct bttv *btv) btv->c.nr, is_lr90?"yes":"no ", has_tda9820_tda9821?"yes":"no ", is_capture_only?"yes":"no "); - if(tuner!= -1) // only set if known tuner autodetected, else let insmod option through + if(tuner!= -1) /* only set if known tuner autodetected, else let insmod option through */ btv->tuner_type = tuner; btv->has_radio = has_radio; - // LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80 - // LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00 - // Audio options: from tuner, from tda9821/tda9821(mono,stereo,sap), from tda9874, ext., mute + /* LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80 + * LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00 + * Audio options: from tuner, from tda9821/tda9821(mono,stereo,sap), from tda9874, ext., mute */ if(has_tda9820_tda9821) btv->audio_hook = lt9415_audio; - //todo: if(has_tda9874) btv->audio_hook = fv2000s_audio; + /* todo: if(has_tda9874) btv->audio_hook = fv2000s_audio; */ } static int miro_tunermap[] = { 0,6,2,3, 4,5,6,0, 3,0,4,5, 5,2,16,1, @@ -2633,6 +2808,8 @@ void __devinit bttv_init_card1(struct bttv *btv) void __devinit bttv_init_card2(struct bttv *btv) { int tda9887; + int addr=ADDR_UNSET; + btv->tuner_type = -1; if (BTTV_UNKNOWN == btv->c.type) { @@ -2773,9 +2950,12 @@ void __devinit bttv_init_card2(struct bttv *btv) btv->pll.pll_current = -1; /* tuner configuration (from card list / autodetect / insmod option) */ - if (UNSET != bttv_tvcards[btv->c.type].tuner_type) + if (ADDR_UNSET != bttv_tvcards[btv->c.type].tuner_addr) + addr = bttv_tvcards[btv->c.type].tuner_addr; + + if (UNSET != bttv_tvcards[btv->c.type].tuner_type) if(UNSET == btv->tuner_type) - btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type; + btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type; if (UNSET != tuner[btv->c.nr]) btv->tuner_type = tuner[btv->c.nr]; printk("bttv%d: using tuner=%d\n",btv->c.nr,btv->tuner_type); @@ -2787,7 +2967,7 @@ void __devinit bttv_init_card2(struct bttv *btv) tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; tun_setup.type = btv->tuner_type; - tun_setup.addr = ADDR_UNSET; + tun_setup.addr = addr; bttv_call_i2c_clients(btv, TUNER_SET_TYPE_ADDR, &tun_setup); } @@ -2902,7 +3082,7 @@ static int terratec_active_radio_upgrade(struct bttv *btv) btv->mbox_csel = 1 << 10; freq=88000/62.5; - tea5757_write(btv, 5 * freq + 0x358); // write 0x1ed8 + tea5757_write(btv, 5 * freq + 0x358); /* write 0x1ed8 */ if (0x1ed8 == tea5757_read(btv)) { printk("bttv%d: Terratec Active Radio Upgrade found.\n", btv->c.nr); @@ -3073,7 +3253,7 @@ static void __devinit osprey_eeprom(struct bttv *btv) case 0x0060: case 0x0070: btv->c.type = BTTV_OSPREY2x0; - //enable output on select control lines + /* enable output on select control lines */ gpio_inout(0xffffff,0x000303); break; default: @@ -3105,7 +3285,7 @@ static int tuner_1_table[] = { TUNER_TEMIC_NTSC, TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, - TUNER_TEMIC_4012FY5, TUNER_TEMIC_4012FY5, //TUNER_TEMIC_SECAM + TUNER_TEMIC_4012FY5, TUNER_TEMIC_4012FY5, /* TUNER_TEMIC_SECAM */ TUNER_TEMIC_4012FY5, TUNER_TEMIC_PAL}; static void __devinit avermedia_eeprom(struct bttv *btv) @@ -3126,7 +3306,7 @@ static void __devinit avermedia_eeprom(struct bttv *btv) if (tuner_make == 4) if(tuner_format == 0x09) - tuner = TUNER_LG_NTSC_NEW_TAPC; // TAPC-G702P + tuner = TUNER_LG_NTSC_NEW_TAPC; /* TAPC-G702P */ printk(KERN_INFO "bttv%d: Avermedia eeprom[0x%02x%02x]: tuner=", btv->c.nr,eeprom_data[0x41],eeprom_data[0x42]); @@ -3143,7 +3323,7 @@ static void __devinit avermedia_eeprom(struct bttv *btv) /* used on Voodoo TV/FM (Voodoo 200), S0 wired to 0x10000 */ void bttv_tda9880_setnorm(struct bttv *btv, int norm) { - // fix up our card entry + /* fix up our card entry */ if(norm==VIDEO_MODE_NTSC) { bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[0]=0x957fff; bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[4]=0x957fff; @@ -3154,7 +3334,7 @@ void bttv_tda9880_setnorm(struct bttv *btv, int norm) bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[4]=0x947fff; dprintk("bttv_tda9880_setnorm to PAL\n"); } - // set GPIO according + /* set GPIO according */ gpio_bits(bttv_tvcards[btv->c.type].gpiomask, bttv_tvcards[btv->c.type].audiomux[btv->audio]); } @@ -3447,7 +3627,7 @@ static int tea5757_read(struct bttv *btv) udelay(10); timeout= jiffies + HZ; - // wait for DATA line to go low; error if it doesn't + /* wait for DATA line to go low; error if it doesn't */ while (bus_in(btv,btv->mbox_data) && time_before(jiffies, timeout)) schedule(); if (bus_in(btv,btv->mbox_data)) { @@ -3574,8 +3754,8 @@ gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set) con = 0x300; if (v->mode & VIDEO_SOUND_STEREO) con = 0x200; -// if (v->mode & VIDEO_SOUND_MONO) -// con = 0x100; +/* if (v->mode & VIDEO_SOUND_MONO) + * con = 0x100; */ gpio_bits(0x300, con); } else { v->mode = VIDEO_SOUND_STEREO | @@ -3718,7 +3898,7 @@ lt9415_audio(struct bttv *btv, struct video_audio *v, int set) } } -// TDA9821 on TerraTV+ Bt848, Bt878 +/* TDA9821 on TerraTV+ Bt848, Bt878 */ static void terratv_audio(struct bttv *btv, struct video_audio *v, int set) { @@ -3818,7 +3998,7 @@ fv2000s_audio(struct bttv *btv, struct video_audio *v, int set) } if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2)) || (v->mode & VIDEO_SOUND_STEREO)) { - val = 0x1080; //-dk-???: 0x0880, 0x0080, 0x1800 ... + val = 0x1080; /*-dk-???: 0x0880, 0x0080, 0x1800 ... */ } if (val != 0xffff) { gpio_bits(0x1800, val); @@ -3869,10 +4049,10 @@ adtvk503_audio(struct bttv *btv, struct video_audio *v, int set) { unsigned int con = 0xffffff; - //btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN); + /* btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN); */ if (set) { - //btor(***, BT848_GPIO_OUT_EN); + /* btor(***, BT848_GPIO_OUT_EN); */ if (v->mode & VIDEO_SOUND_LANG1) con = 0x00000000; if (v->mode & VIDEO_SOUND_LANG2) @@ -4079,14 +4259,14 @@ static void kodicom4400r_init(struct bttv *btv) master[btv->c.nr+2] = btv; } -// The Grandtec X-Guard framegrabber card uses two Dual 4-channel -// video multiplexers to provide up to 16 video inputs. These -// multiplexers are controlled by the lower 8 GPIO pins of the -// bt878. The multiplexers probably Pericom PI5V331Q or similar. - -// xxx0 is pin xxx of multiplexer U5, -// yyy1 is pin yyy of multiplexer U2 +/* The Grandtec X-Guard framegrabber card uses two Dual 4-channel + * video multiplexers to provide up to 16 video inputs. These + * multiplexers are controlled by the lower 8 GPIO pins of the + * bt878. The multiplexers probably Pericom PI5V331Q or similar. + * xxx0 is pin xxx of multiplexer U5, + * yyy1 is pin yyy of multiplexer U2 + */ #define ENA0 0x01 #define ENB0 0x02 #define ENA1 0x04 @@ -4157,14 +4337,14 @@ static void picolo_tetra_muxsel (struct bttv* btv, unsigned int input) static void ivc120_muxsel(struct bttv *btv, unsigned int input) { - // Simple maths + /* Simple maths */ int key = input % 4; int matrix = input / 4; dprintk("bttv%d: ivc120_muxsel: Input - %02d | TDA - %02d | In - %02d\n", btv->c.nr, input, matrix, key); - // Handles the input selection on the TDA8540's + /* Handles the input selection on the TDA8540's */ bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x00, ((matrix == 3) ? (key | key << 2) : 0x00), 1); bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x00, @@ -4174,17 +4354,17 @@ static void ivc120_muxsel(struct bttv *btv, unsigned int input) bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x00, ((matrix == 2) ? (key | key << 2) : 0x00), 1); - // Handles the output enables on the TDA8540's + /* Handles the output enables on the TDA8540's */ bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x02, - ((matrix == 3) ? 0x03 : 0x00), 1); // 13 - 16 + ((matrix == 3) ? 0x03 : 0x00), 1); /* 13 - 16 */ bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x02, - ((matrix == 0) ? 0x03 : 0x00), 1); // 1-4 + ((matrix == 0) ? 0x03 : 0x00), 1); /* 1-4 */ bttv_I2CWrite(btv, I2C_TDA8540_ALT5, 0x02, - ((matrix == 1) ? 0x03 : 0x00), 1); // 5-8 + ((matrix == 1) ? 0x03 : 0x00), 1); /* 5-8 */ bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x02, - ((matrix == 2) ? 0x03 : 0x00), 1); // 9-12 + ((matrix == 2) ? 0x03 : 0x00), 1); /* 9-12 */ - // Selects MUX0 for input on the 878 + /* Selects MUX0 for input on the 878 */ btaor((0)<<5, ~(3<<5), BT848_IFORM); } @@ -4305,7 +4485,6 @@ void __devinit bttv_check_chipset(void) } if (UNSET != latency) printk(KERN_INFO "bttv: pci latency fixup [%d]\n",latency); - while ((dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, dev))) { unsigned char b; diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index 087efb4..53ecdbf 100644 --- a/drivers/media/video/bttv-driver.c +++ b/drivers/media/video/bttv-driver.c @@ -1,5 +1,4 @@ /* - $Id: bttv-driver.c,v 1.52 2005/08/04 00:55:16 mchehab Exp $ bttv - Bt848 frame grabber driver @@ -42,6 +41,9 @@ #include "bttvp.h" +#include "rds.h" + + unsigned int bttv_num; /* number of Bt848s in use */ struct bttv bttvs[BTTV_MAX]; @@ -3128,15 +3130,12 @@ static int radio_open(struct inode *inode, struct file *file) dprintk("bttv%d: open called (radio)\n",btv->c.nr); down(&btv->lock); - if (btv->radio_user) { - up(&btv->lock); - return -EBUSY; - } + btv->radio_user++; + file->private_data = btv; - i2c_vidiocschan(btv); - bttv_call_i2c_clients(btv,AUDC_SET_RADIO,&btv->tuner_type); + bttv_call_i2c_clients(btv,AUDC_SET_RADIO,&btv->tuner_type); audio_mux(btv,AUDIO_RADIO); up(&btv->lock); @@ -3145,9 +3144,13 @@ static int radio_open(struct inode *inode, struct file *file) static int radio_release(struct inode *inode, struct file *file) { - struct bttv *btv = file->private_data; + struct bttv *btv = file->private_data; + struct rds_command cmd; btv->radio_user--; + + bttv_call_i2c_clients(btv, RDS_CMD_CLOSE, &cmd); + return 0; } @@ -3203,13 +3206,42 @@ static int radio_ioctl(struct inode *inode, struct file *file, return video_usercopy(inode, file, cmd, arg, radio_do_ioctl); } +static ssize_t radio_read(struct file *file, char __user *data, + size_t count, loff_t *ppos) +{ + struct bttv *btv = file->private_data; + struct rds_command cmd; + cmd.block_count = count/3; + cmd.buffer = data; + cmd.instance = file; + cmd.result = -ENODEV; + + bttv_call_i2c_clients(btv, RDS_CMD_READ, &cmd); + + return cmd.result; +} + +static unsigned int radio_poll(struct file *file, poll_table *wait) +{ + struct bttv *btv = file->private_data; + struct rds_command cmd; + cmd.instance = file; + cmd.event_list = wait; + cmd.result = -ENODEV; + bttv_call_i2c_clients(btv, RDS_CMD_POLL, &cmd); + + return cmd.result; +} + static struct file_operations radio_fops = { .owner = THIS_MODULE, .open = radio_open, + .read = radio_read, .release = radio_release, .ioctl = radio_ioctl, .llseek = no_llseek, + .poll = radio_poll, }; static struct video_device radio_template = diff --git a/drivers/media/video/bttv-gpio.c b/drivers/media/video/bttv-gpio.c index 77320cd..6b280c0 100644 --- a/drivers/media/video/bttv-gpio.c +++ b/drivers/media/video/bttv-gpio.c @@ -1,5 +1,4 @@ /* - $Id: bttv-gpio.c,v 1.7 2005/02/16 12:14:10 kraxel Exp $ bttv-gpio.c -- gpio sub drivers diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c index 706dc48..e684df3 100644 --- a/drivers/media/video/bttv-i2c.c +++ b/drivers/media/video/bttv-i2c.c @@ -1,5 +1,4 @@ /* - $Id: bttv-i2c.c,v 1.25 2005/07/05 17:37:35 nsh Exp $ bttv-i2c.c -- all the i2c code is here @@ -381,6 +380,7 @@ void __devinit bttv_readee(struct bttv *btv, unsigned char *eedata, int addr) } static char *i2c_devs[128] = { + [ 0x1c >> 1 ] = "lgdt330x", [ 0x30 >> 1 ] = "IR (hauppauge)", [ 0x80 >> 1 ] = "msp34xx", [ 0x86 >> 1 ] = "tda9887", diff --git a/drivers/media/video/bttv-if.c b/drivers/media/video/bttv-if.c index f7b5543..e8aada7 100644 --- a/drivers/media/video/bttv-if.c +++ b/drivers/media/video/bttv-if.c @@ -1,5 +1,4 @@ /* - $Id: bttv-if.c,v 1.4 2004/11/17 18:47:47 kraxel Exp $ bttv-if.c -- old gpio interface to other kernel modules don't use in new code, will go away in 2.7 diff --git a/drivers/media/video/bttv-risc.c b/drivers/media/video/bttv-risc.c index 9ed21fd..a5ed99b 100644 --- a/drivers/media/video/bttv-risc.c +++ b/drivers/media/video/bttv-risc.c @@ -1,5 +1,4 @@ /* - $Id: bttv-risc.c,v 1.10 2004/11/19 18:07:12 kraxel Exp $ bttv-risc.c -- interfaces to other kernel modules diff --git a/drivers/media/video/bttv-vbi.c b/drivers/media/video/bttv-vbi.c index 06f3e62..f4f58c6 100644 --- a/drivers/media/video/bttv-vbi.c +++ b/drivers/media/video/bttv-vbi.c @@ -1,5 +1,4 @@ /* - $Id: bttv-vbi.c,v 1.9 2005/01/13 17:22:33 kraxel Exp $ bttv - Bt848 frame grabber driver vbi interface diff --git a/drivers/media/video/bttv.h b/drivers/media/video/bttv.h index f2af9e1..d254e90 100644 --- a/drivers/media/video/bttv.h +++ b/drivers/media/video/bttv.h @@ -1,5 +1,4 @@ /* - * $Id: bttv.h,v 1.22 2005/07/28 18:41:21 mchehab Exp $ * * bttv - Bt848 frame grabber driver * @@ -218,6 +217,8 @@ struct tvcard #define PLL_35 2 unsigned int tuner_type; + unsigned int tuner_addr; + unsigned int has_radio; void (*audio_hook)(struct bttv *btv, struct video_audio *v, int set); void (*muxsel_hook)(struct bttv *btv, unsigned int input); diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h index aab094b..a0eb0ce 100644 --- a/drivers/media/video/bttvp.h +++ b/drivers/media/video/bttvp.h @@ -1,5 +1,4 @@ /* - $Id: bttvp.h,v 1.21 2005/07/15 21:44:14 mchehab Exp $ bttv - Bt848 frame grabber driver @@ -26,7 +25,7 @@ #ifndef _BTTVP_H_ #define _BTTVP_H_ -#include +#include #define BTTV_VERSION_CODE KERNEL_VERSION(0,9,16) #include -- cgit v0.10.2 From e52e98a7eccfb0e7e91630d01690fb11d77db77d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:41 -0700 Subject: [PATCH] v4l: CX88 updates and card additions - Remove $Id CVS logs for V4L files - add ioctl indirection via cx88_ioctl_hook and cx88_ioctl_translator to cx88-blackbird.c. - declare the indirection hooks from cx88-blackbird.c. - dcprintk macro which uses core instead of dev->core on cx88-video.c. - replace dev->core occurances with core on cx88-video.c. - CodingStyle fixes. - MaxInput replaced by a define. - cx8801 structures moved from cx88.h. - The output_mode needs to be set for the Hauppauge Nova-T DVB-T for versions after 2.6.12. - Corrected GPIO values for cx88 cards #28 & #31 for s-video and composite. - Updated DViCO FusionHDTV5 Gold & added DVB support. - Fixed DViCO FusionHDTV 3 Gold-Q GPIO. - Some clean up in cx88-tvaudio.c - replaced hex values when writing to AUD_CTL to EN_xx for better reading. - Allow select by hand between Mono, Lang1, Lang2 and Stereo for BTSC. - Support for stereo NICAM and BTSC improved. - Broken stereo check removed. - Added support for remote control to Cinergy DVBT-1400. - local var renamed from rc5 to a better name (ircode). - LGDT330X QAM lock bug fixes. - Some reorg: move some bits to struct cx88_core, factor out common ioctl's to cx88_do_ioctl. - Get rid of '//' comments, replace them with #if 0 and /**/. - Minor clean-ups: remove dcprintk and replace all instances of "dev->core" with "core". - Added some registers to control PCI controller at CX2388x chips. - New tuner standby API. - Small mpeg fixes and cleanups for blackbird. - fix mpeg packet size & count - add VIDIOC_QUERYCAP ioctl for the mpeg stream - return more information in struct v4l2_format - fix default window height - small cleanups Signed-off-by: Uli Luckas Signed-off-by: Torsten Seeboth Signed-off-by: Nickolay V. Shmyrev Signed-off-by: Michael Krufky Signed-off-by: Patrick Boettcher Signed-off-by: Catalin Climov Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index 4f39688..0c0c59e 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-blackbird.c,v 1.27 2005/06/03 13:31:50 mchehab Exp $ * * Support for a cx23416 mpeg encoder via cx2388x host port. * "blackbird" reference design. @@ -62,7 +61,6 @@ static LIST_HEAD(cx8802_devlist); #define IVTV_CMD_HW_BLOCKS_RST 0xFFFFFFFF /* Firmware API commands */ -/* #define IVTV_API_STD_TIMEOUT 0x00010000 // 65536, units?? */ #define IVTV_API_STD_TIMEOUT 500 #define BLACKBIRD_API_PING 0x80 @@ -696,7 +694,6 @@ static void blackbird_codec_settings(struct cx8802_dev *dev) /* assign stream type */ blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, BLACKBIRD_STREAM_PROGRAM); - /* blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, BLACKBIRD_STREAM_TRANSPORT); */ /* assign output port */ blackbird_api_cmd(dev, BLACKBIRD_API_SET_OUTPUT_PORT, 1, 0, BLACKBIRD_OUTPUT_PORT_STREAMING); /* Host */ @@ -824,7 +821,8 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) BLACKBIRD_CUSTOM_EXTENSION_USR_DATA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - blackbird_api_cmd(dev, BLACKBIRD_API_INIT_VIDEO_INPUT, 0, 0); /* initialize the video input */ + /* initialize the video input */ + blackbird_api_cmd(dev, BLACKBIRD_API_INIT_VIDEO_INPUT, 0, 0); msleep(1); @@ -833,11 +831,12 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) blackbird_api_cmd(dev, BLACKBIRD_API_MUTE_AUDIO, 1, 0, BLACKBIRD_UNMUTE); msleep(1); - /* blackbird_api_cmd(dev, BLACKBIRD_API_BEGIN_CAPTURE, 2, 0, 0, 0x13); // start capturing to the host interface */ + /* start capturing to the host interface */ + /* blackbird_api_cmd(dev, BLACKBIRD_API_BEGIN_CAPTURE, 2, 0, 0, 0x13); */ blackbird_api_cmd(dev, BLACKBIRD_API_BEGIN_CAPTURE, 2, 0, BLACKBIRD_MPEG_CAPTURE, BLACKBIRD_RAW_BITS_NONE - ); /* start capturing to the host interface */ + ); msleep(10); blackbird_api_cmd(dev, BLACKBIRD_API_REFRESH_INPUT, 0,0); @@ -851,8 +850,8 @@ static int bb_buf_setup(struct videobuf_queue *q, { struct cx8802_fh *fh = q->priv_data; - fh->dev->ts_packet_size = 512; - fh->dev->ts_packet_count = 100; + fh->dev->ts_packet_size = 188 * 4; /* was: 512 */ + fh->dev->ts_packet_count = 32; /* was: 100 */ *size = fh->dev->ts_packet_size * fh->dev->ts_packet_count; if (0 == *count) @@ -900,12 +899,36 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, { struct cx8802_fh *fh = file->private_data; struct cx8802_dev *dev = fh->dev; + struct cx88_core *core = dev->core; if (debug > 1) - cx88_print_ioctl(dev->core->name,cmd); + cx88_print_ioctl(core->name,cmd); switch (cmd) { + /* --- capabilities ------------------------------------------ */ + case VIDIOC_QUERYCAP: + { + struct v4l2_capability *cap = arg; + + memset(cap,0,sizeof(*cap)); + strcpy(cap->driver, "cx88_blackbird"); + strlcpy(cap->card, cx88_boards[core->board].name,sizeof(cap->card)); + sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci)); + cap->version = CX88_VERSION_CODE; + cap->capabilities = + V4L2_CAP_VIDEO_CAPTURE | + V4L2_CAP_READWRITE | + V4L2_CAP_STREAMING | + V4L2_CAP_VBI_CAPTURE | + V4L2_CAP_VIDEO_OVERLAY | + 0; + if (UNSET != core->tuner_type) + cap->capabilities |= V4L2_CAP_TUNER; + + return 0; + } + /* --- capture ioctls ---------------------------------------- */ case VIDIOC_ENUM_FMT: { @@ -935,7 +958,11 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, f->fmt.pix.width = dev->width; f->fmt.pix.height = dev->height; f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; - f->fmt.pix.sizeimage = 1024 * 512 /* FIXME: BUFFER_SIZE */; + f->fmt.pix.field = V4L2_FIELD_NONE; + f->fmt.pix.bytesperline = 0; + f->fmt.pix.sizeimage = 188 * 4 * 1024; /* 1024 * 512 */ /* FIXME: BUFFER_SIZE */; + f->fmt.pix.colorspace = 0; + return 0; } /* --- streaming capture ------------------------------------- */ @@ -959,15 +986,25 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, return videobuf_streamoff(&fh->mpegq); default: - return -EINVAL; + return cx88_do_ioctl( inode, file, 0, dev->core, cmd, arg, cx88_ioctl_hook ); } return 0; } +int (*cx88_ioctl_hook)(struct inode *inode, struct file *file, + unsigned int cmd, void *arg); +unsigned int (*cx88_ioctl_translator)(unsigned int cmd); + +static unsigned int mpeg_translate_ioctl(unsigned int cmd) +{ + return cmd; +} + static int mpeg_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { - return video_usercopy(inode, file, cmd, arg, mpeg_do_ioctl); + cmd = cx88_ioctl_translator( cmd ); + return video_usercopy(inode, file, cmd, arg, cx88_ioctl_hook); } static int mpeg_open(struct inode *inode, struct file *file) @@ -1135,7 +1172,7 @@ static int __devinit blackbird_probe(struct pci_dev *pci_dev, dev->pci = pci_dev; dev->core = core; dev->width = 720; - dev->height = 480; + dev->height = 576; err = cx8802_init_common(dev); if (0 != err) @@ -1148,6 +1185,9 @@ static int __devinit blackbird_probe(struct pci_dev *pci_dev, list_add_tail(&dev->devlist,&cx8802_devlist); blackbird_register_video(dev); + + /* initial device configuration: needed ? */ + return 0; fail_free: @@ -1202,6 +1242,8 @@ static int blackbird_init(void) printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n", SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100); #endif + cx88_ioctl_hook = mpeg_do_ioctl; + cx88_ioctl_translator = mpeg_translate_ioctl; return pci_register_driver(&blackbird_pci_driver); } @@ -1213,6 +1255,9 @@ static void blackbird_fini(void) module_init(blackbird_init); module_exit(blackbird_fini); +EXPORT_SYMBOL(cx88_ioctl_hook); +EXPORT_SYMBOL(cx88_ioctl_translator); + /* ----------------------------------------------------------- */ /* * Local variables: diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c index ebf02a7..9262323 100644 --- a/drivers/media/video/cx88/cx88-cards.c +++ b/drivers/media/video/cx88/cx88-cards.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-cards.c,v 1.90 2005/07/28 02:47:42 mkrufky Exp $ * * device driver for Conexant 2388x based TV cards * card-specific stuff. @@ -499,9 +498,6 @@ struct cx88_board cx88_boards[] = { .input = {{ .type = CX88_VMUX_DVB, .vmux = 0, - },{ - .type = CX88_VMUX_SVIDEO, - .vmux = 2, }}, .dvb = 1, }, @@ -614,12 +610,12 @@ struct cx88_board cx88_boards[] = { .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, - .gpio0 = 0xed12, // internal decoder + .gpio0 = 0xed12, /* internal decoder */ .gpio2 = 0x00ff, },{ .type = CX88_VMUX_DEBUG, .vmux = 0, - .gpio0 = 0xff01, // mono from tuner chip + .gpio0 = 0xff01, /* mono from tuner chip */ },{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, @@ -715,19 +711,18 @@ struct cx88_board cx88_boards[] = { .radio_type = UNSET, .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, - /* See DViCO FusionHDTV 3 Gold-Q for GPIO documentation. */ .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, - .gpio0 = 0x0f0d, + .gpio0 = 0x97ed, },{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, - .gpio0 = 0x0f00, + .gpio0 = 0x97e9, },{ .type = CX88_VMUX_SVIDEO, .vmux = 2, - .gpio0 = 0x0f00, + .gpio0 = 0x97e9, }}, .dvb = 1, }, @@ -765,20 +760,21 @@ struct cx88_board cx88_boards[] = { .radio_type = UNSET, .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, - /* See DViCO FusionHDTV 3 Gold-Q for GPIO documentation. */ + .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, - .gpio0 = 0x0f0d, + .gpio0 = 0x87fd, },{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, - .gpio0 = 0x0f00, + .gpio0 = 0x87f9, },{ .type = CX88_VMUX_SVIDEO, .vmux = 2, - .gpio0 = 0x0f00, + .gpio0 = 0x87f9, }}, + .dvb = 1, }, }; const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards); diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c index 5e868f5..dc5c5c1 100644 --- a/drivers/media/video/cx88/cx88-core.c +++ b/drivers/media/video/cx88/cx88-core.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-core.c,v 1.33 2005/07/07 14:17:47 mchehab Exp $ * * device driver for Conexant 2388x based TV cards * driver core @@ -876,7 +875,7 @@ static int set_tvaudio(struct cx88_core *core) cx_andor(MO_AFECFG_IO, 0x1f, 0x0); cx88_set_tvaudio(core); - // cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); + /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */ cx_write(MO_AUDD_LNGTH, 128); /* fifo size */ cx_write(MO_AUDR_LNGTH, 128); /* fifo size */ @@ -1087,10 +1086,17 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci) core->pci_bus = pci->bus->number; core->pci_slot = PCI_SLOT(pci->devfn); core->pci_irqmask = 0x00fc00; + init_MUTEX(&core->lock); core->nr = cx88_devcount++; sprintf(core->name,"cx88[%d]",core->nr); if (0 != get_ressources(core,pci)) { + printk(KERN_ERR "CORE %s No more PCI ressources for " + "subsystem: %04x:%04x, board: %s\n", + core->name,pci->subsystem_vendor, + pci->subsystem_device, + cx88_boards[core->board].name); + cx88_devcount--; goto fail_free; } @@ -1114,11 +1120,11 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci) core->board = CX88_BOARD_UNKNOWN; cx88_card_list(core,pci); } - printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n", - core->name,pci->subsystem_vendor, - pci->subsystem_device,cx88_boards[core->board].name, - core->board, card[core->nr] == core->board ? - "insmod option" : "autodetected"); + printk(KERN_INFO "CORE %s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n", + core->name,pci->subsystem_vendor, + pci->subsystem_device,cx88_boards[core->board].name, + core->board, card[core->nr] == core->board ? + "insmod option" : "autodetected"); core->tuner_type = tuner[core->nr]; core->radio_type = radio[core->nr]; @@ -1202,4 +1208,5 @@ EXPORT_SYMBOL(cx88_core_put); * Local variables: * c-basic-offset: 8 * End: + * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off */ diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index 78d2232..cc71caf 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-dvb.c,v 1.58 2005/08/07 09:24:08 mkrufky Exp $ * * device driver for Conexant 2388x based TV cards * MPEG Transport Stream (DVB) routines @@ -31,6 +30,7 @@ #include #include + #include "cx88.h" #include "dvb-pll.h" @@ -210,16 +210,26 @@ static struct or51132_config pchdtv_hd3000 = { static int lgdt330x_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { + /* FIXME make this routine use the tuner-simple code. + * It could probably be shared with a number of ATSC + * frontends. Many share the same tuner with analog TV. */ + struct cx8802_dev *dev= fe->dvb->priv; + struct cx88_core *core = dev->core; u8 buf[4]; struct i2c_msg msg = { .addr = dev->core->pll_addr, .flags = 0, .buf = buf, .len = 4 }; int err; - dvb_pll_configure(dev->core->pll_desc, buf, params->frequency, 0); + /* Put the analog decoder in standby to keep it quiet */ + if (core->tda9887_conf) { + cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); + } + + dvb_pll_configure(core->pll_desc, buf, params->frequency, 0); dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n", __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]); - if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { + if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) { printk(KERN_WARNING "cx88-dvb: %s error " "(addr %02x <- %02x, err = %i)\n", __FUNCTION__, buf[0], buf[1], err); @@ -228,6 +238,13 @@ static int lgdt330x_pll_set(struct dvb_frontend* fe, else return -EREMOTEIO; } + if (core->tuner_type == TUNER_LG_TDVS_H062F) { + /* Set the Auxiliary Byte. */ + buf[2] &= ~0x20; + buf[2] |= 0x18; + buf[3] = 0x50; + i2c_transfer(&core->i2c_adap, &msg, 1); + } return 0; } @@ -261,6 +278,14 @@ static struct lgdt330x_config fusionhdtv_3_gold = { .pll_set = lgdt330x_pll_set, .set_ts_params = lgdt330x_set_ts_param, }; + +static struct lgdt330x_config fusionhdtv_5_gold = { + .demod_address = 0x0e, + .demod_chip = LGDT3303, + .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */ + .pll_set = lgdt330x_pll_set, + .set_ts_params = lgdt330x_set_ts_param, +}; #endif static int dvb_register(struct cx8802_dev *dev) @@ -346,6 +371,22 @@ static int dvb_register(struct cx8802_dev *dev) &dev->core->i2c_adap); } break; + case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: + dev->ts_gen_cntrl = 0x08; + { + /* Do a hardware reset of chip before using it. */ + struct cx88_core *core = dev->core; + + cx_clear(MO_GP0_IO, 1); + mdelay(100); + cx_set(MO_GP0_IO, 1); + mdelay(200); + dev->core->pll_addr = 0x61; + dev->core->pll_desc = &dvb_pll_tdvs_tua6034; + dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_5_gold, + &dev->core->i2c_adap); + } + break; #endif default: printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n", diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c index 7f59803..761cebd 100644 --- a/drivers/media/video/cx88/cx88-i2c.c +++ b/drivers/media/video/cx88/cx88-i2c.c @@ -1,5 +1,4 @@ /* - $Id: cx88-i2c.c,v 1.30 2005/07/25 05:10:13 mkrufky Exp $ cx88-i2c.c -- all the i2c code is here diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c index 2148877..d7980c5 100644 --- a/drivers/media/video/cx88/cx88-input.c +++ b/drivers/media/video/cx88/cx88-input.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-input.c,v 1.15 2005/07/07 13:58:38 mchehab Exp $ * * Device driver for GPIO attached remote control interfaces * on Conexant 2388x based TV/DVB cards. @@ -212,6 +211,53 @@ static IR_KEYTAB_TYPE ir_codes_msi_tvanywhere[IR_KEYTAB_SIZE] = { /* ---------------------------------------------------------------------- */ +/* Cinergy 1400 DVB-T */ +static IR_KEYTAB_TYPE ir_codes_cinergy_1400[IR_KEYTAB_SIZE] = { + [0x01] = KEY_POWER, + [0x02] = KEY_1, + [0x03] = KEY_2, + [0x04] = KEY_3, + [0x05] = KEY_4, + [0x06] = KEY_5, + [0x07] = KEY_6, + [0x08] = KEY_7, + [0x09] = KEY_8, + [0x0a] = KEY_9, + [0x0c] = KEY_0, + + [0x0b] = KEY_VIDEO, + [0x0d] = KEY_REFRESH, + [0x0e] = KEY_SELECT, + [0x0f] = KEY_EPG, + [0x10] = KEY_UP, + [0x11] = KEY_LEFT, + [0x12] = KEY_OK, + [0x13] = KEY_RIGHT, + [0x14] = KEY_DOWN, + [0x15] = KEY_TEXT, + [0x16] = KEY_INFO, + + [0x17] = KEY_RED, + [0x18] = KEY_GREEN, + [0x19] = KEY_YELLOW, + [0x1a] = KEY_BLUE, + + [0x1b] = KEY_CHANNELUP, + [0x1c] = KEY_VOLUMEUP, + [0x1d] = KEY_MUTE, + [0x1e] = KEY_VOLUMEDOWN, + [0x1f] = KEY_CHANNELDOWN, + + [0x40] = KEY_PAUSE, + [0x4c] = KEY_PLAY, + [0x58] = KEY_RECORD, + [0x54] = KEY_PREVIOUS, + [0x48] = KEY_STOP, + [0x5c] = KEY_NEXT, +}; + +/* ---------------------------------------------------------------------- */ + struct cx88_IR { struct cx88_core *core; struct input_dev input; @@ -241,7 +287,7 @@ module_param(ir_debug, int, 0644); /* debug level [IR] */ MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); #define ir_dprintk(fmt, arg...) if (ir_debug) \ - printk(KERN_DEBUG "%s IR: " fmt , ir->core->name, ## arg) + printk(KERN_DEBUG "%s IR: " fmt , ir->core->name , ##arg) /* ---------------------------------------------------------------------- */ @@ -329,6 +375,11 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) ir->mask_keyup = 0x60; ir->polling = 50; /* ms */ break; + case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: + ir_codes = ir_codes_cinergy_1400; + ir_type = IR_TYPE_PD; + ir->sampling = 1; + break; case CX88_BOARD_HAUPPAUGE: case CX88_BOARD_HAUPPAUGE_DVB_T1: ir_codes = ir_codes_hauppauge_new; @@ -445,7 +496,7 @@ int cx88_ir_fini(struct cx88_core *core) void cx88_ir_irq(struct cx88_core *core) { struct cx88_IR *ir = core->ir; - u32 samples, rc5; + u32 samples, ircode; int i; if (NULL == ir) @@ -477,13 +528,44 @@ void cx88_ir_irq(struct cx88_core *core) /* decode it */ switch (core->board) { + case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: + ircode = ir_decode_pulsedistance(ir->samples, ir->scount, 1, 4); + + if (ircode == 0xffffffff) { /* decoding error */ + ir_dprintk("pulse distance decoding error\n"); + break; + } + + ir_dprintk("pulse distance decoded: %x\n", ircode); + + if (ircode == 0) { /* key still pressed */ + ir_dprintk("pulse distance decoded repeat code\n"); + ir->release = jiffies + msecs_to_jiffies(120); + break; + } + + if ((ircode & 0xffff) != 0xeb04) { /* wrong address */ + ir_dprintk("pulse distance decoded wrong address\n"); + break; + } + + if (((~ircode >> 24) & 0xff) != ((ircode >> 16) & 0xff)) { /* wrong checksum */ + ir_dprintk("pulse distance decoded wrong check sum\n"); + break; + } + + ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f); + + ir_input_keydown(&ir->input, &ir->ir, (ircode >> 16) & 0x7f, (ircode >> 16) & 0xff); + ir->release = jiffies + msecs_to_jiffies(120); + break; case CX88_BOARD_HAUPPAUGE: case CX88_BOARD_HAUPPAUGE_DVB_T1: - rc5 = ir_decode_biphase(ir->samples, ir->scount, 5, 7); - ir_dprintk("biphase decoded: %x\n", rc5); - if ((rc5 & 0xfffff000) != 0x3000) + ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7); + ir_dprintk("biphase decoded: %x\n", ircode); + if ((ircode & 0xfffff000) != 0x3000) break; - ir_input_keydown(&ir->input, &ir->ir, rc5 & 0x3f, rc5); + ir_input_keydown(&ir->input, &ir->ir, ircode & 0x3f, ircode); ir->release = jiffies + msecs_to_jiffies(120); break; } diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index fe2767c..6d0d15c 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-mpeg.c,v 1.31 2005/07/07 14:17:47 mchehab Exp $ * * Support for the mpeg transport stream transfers * PCI function #2 of the cx2388x. @@ -73,11 +72,15 @@ static int cx8802_start_dma(struct cx8802_dev *dev, udelay(100); cx_write(MO_PINMUX_IO, 0x00); cx_write(TS_HW_SOP_CNTRL,0x47<<16|188<<4|0x01); - if ((core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q) || - (core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T)) { + switch (core->board) { + case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: + case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: + case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: cx_write(TS_SOP_STAT, 1<<13); - } else { + break; + default: cx_write(TS_SOP_STAT, 0x00); + break; } cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl); udelay(100); @@ -86,12 +89,10 @@ static int cx8802_start_dma(struct cx8802_dev *dev, if (cx88_boards[core->board].blackbird) { cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */ - // cx_write(TS_F2_CMD_STAT_MM, 0x2900106); /* F2_CMD_STAT_MM defaults + master + memory space */ cx_write(TS_GEN_CNTRL, 0x46); /* punctured clock TS & posedge driven & software reset */ udelay(100); cx_write(TS_HW_SOP_CNTRL, 0x408); /* mpeg start byte */ - //cx_write(TS_HW_SOP_CNTRL, 0x2F0BC0); /* mpeg start byte ts: 0x2F0BC0 ? */ cx_write(TS_VALERR_CNTRL, 0x2000); cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */ @@ -106,7 +107,6 @@ static int cx8802_start_dma(struct cx8802_dev *dev, dprintk( 0, "setting the interrupt mask\n" ); cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x04); cx_set(MO_TS_INTMSK, 0x1f0011); - //cx_write(MO_TS_INTMSK, 0x0f0011); /* start dma */ cx_set(MO_DEV_CNTRL2, (1<<5)); @@ -206,7 +206,6 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); dprintk(0,"[%p/%d] %s - first active\n", buf, buf->vb.i, __FUNCTION__); - //udelay(100); } else { dprintk( 1, "queue is not empty - append to active\n" ); @@ -217,7 +216,6 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); dprintk( 1, "[%p/%d] %s - append to active\n", buf, buf->vb.i, __FUNCTION__); - //udelay(100); } } @@ -387,7 +385,6 @@ int cx8802_init_common(struct cx8802_dev *dev) dev->pci_lat,pci_resource_start(dev->pci,0)); /* initialize driver struct */ - init_MUTEX(&dev->lock); spin_lock_init(&dev->slock); /* init dma queue */ diff --git a/drivers/media/video/cx88/cx88-reg.h b/drivers/media/video/cx88/cx88-reg.h index 37f8266..0a3a62f 100644 --- a/drivers/media/video/cx88/cx88-reg.h +++ b/drivers/media/video/cx88/cx88-reg.h @@ -1,5 +1,4 @@ /* - $Id: cx88-reg.h,v 1.8 2005/07/07 13:58:38 mchehab Exp $ cx88x-hw.h - CX2388x register offsets @@ -40,6 +39,29 @@ #define CX88X_EN_TBFX 0x02 #define CX88X_EN_VSFX 0x04 +/* ---------------------------------------------------------------------- */ +/* PCI controller registers */ + +/* Command and Status Register */ +#define F0_CMD_STAT_MM 0x2f0004 +#define F1_CMD_STAT_MM 0x2f0104 +#define F2_CMD_STAT_MM 0x2f0204 +#define F3_CMD_STAT_MM 0x2f0304 +#define F4_CMD_STAT_MM 0x2f0404 + +/* Device Control #1 */ +#define F0_DEV_CNTRL1_MM 0x2f0040 +#define F1_DEV_CNTRL1_MM 0x2f0140 +#define F2_DEV_CNTRL1_MM 0x2f0240 +#define F3_DEV_CNTRL1_MM 0x2f0340 +#define F4_DEV_CNTRL1_MM 0x2f0440 + +/* Device Control #1 */ +#define F0_BAR0_MM 0x2f0010 +#define F1_BAR0_MM 0x2f0110 +#define F2_BAR0_MM 0x2f0210 +#define F3_BAR0_MM 0x2f0310 +#define F4_BAR0_MM 0x2f0410 /* ---------------------------------------------------------------------- */ /* DMA Controller registers */ diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c index 91207f1..2765ace 100644 --- a/drivers/media/video/cx88/cx88-tvaudio.c +++ b/drivers/media/video/cx88/cx88-tvaudio.c @@ -1,5 +1,4 @@ /* - $Id: cx88-tvaudio.c,v 1.37 2005/07/07 13:58:38 mchehab Exp $ cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver @@ -121,25 +120,19 @@ static void set_audio_registers(struct cx88_core *core, } static void set_audio_start(struct cx88_core *core, - u32 mode, u32 ctl) + u32 mode) { // mute cx_write(AUD_VOL_CTL, (1 << 6)); - // increase level of input by 12dB -// cx_write(AUD_AFE_12DB_EN, 0x0001); - cx_write(AUD_AFE_12DB_EN, 0x0000); - // start programming cx_write(AUD_CTL, 0x0000); cx_write(AUD_INIT, mode); cx_write(AUD_INIT_LD, 0x0001); cx_write(AUD_SOFT_RESET, 0x0001); - - cx_write(AUD_CTL, ctl); } -static void set_audio_finish(struct cx88_core *core) +static void set_audio_finish(struct cx88_core *core, u32 ctl) { u32 volume; @@ -154,25 +147,25 @@ static void set_audio_finish(struct cx88_core *core) cx_write(AUD_I2SOUTPUTCNTL, 1); cx_write(AUD_I2SCNTL, 0); //cx_write(AUD_APB_IN_RATE_ADJ, 0); + } else { + ctl |= EN_DAC_ENABLE; + cx_write(AUD_CTL, ctl); } - // finish programming + /* finish programming */ cx_write(AUD_SOFT_RESET, 0x0000); - // start audio processing - cx_set(AUD_CTL, EN_DAC_ENABLE); - - // unmute + /* unmute */ volume = cx_sread(SHADOW_AUD_VOL_CTL); cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, volume); } /* ----------------------------------------------------------- */ -static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap) +static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap, u32 mode) { static const struct rlist btsc[] = { - /* from dscaler */ + { AUD_AFE_12DB_EN, 0x00000001 }, { AUD_OUT1_SEL, 0x00000013 }, { AUD_OUT1_SHIFT, 0x00000000 }, { AUD_POLY0_DDS_CONSTANT, 0x0012010c }, @@ -206,9 +199,10 @@ static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap) { AUD_RDSI_SHIFT, 0x00000000 }, { AUD_RDSQ_SHIFT, 0x00000000 }, { AUD_POLYPH80SCALEFAC, 0x00000003 }, - { /* end of list */ }, + { /* end of list */ }, }; static const struct rlist btsc_sap[] = { + { AUD_AFE_12DB_EN, 0x00000001 }, { AUD_DBX_IN_GAIN, 0x00007200 }, { AUD_DBX_WBE_GAIN, 0x00006200 }, { AUD_DBX_SE_GAIN, 0x00006200 }, @@ -259,371 +253,400 @@ static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap) { AUD_RDSI_SHIFT, 0x00000000 }, { AUD_RDSQ_SHIFT, 0x00000000 }, { AUD_POLYPH80SCALEFAC, 0x00000003 }, - { /* end of list */ }, + { /* end of list */ }, }; - // dscaler: exactly taken from driver, - // dscaler: don't know why to set EN_FMRADIO_EN_RDS + mode |= EN_FMRADIO_EN_RDS; + if (sap) { dprintk("%s SAP (status: unknown)\n",__FUNCTION__); - set_audio_start(core, 0x0001, - EN_FMRADIO_EN_RDS | EN_BTSC_FORCE_SAP); + set_audio_start(core, SEL_SAP); set_audio_registers(core, btsc_sap); + set_audio_finish(core, mode); } else { dprintk("%s (status: known-good)\n",__FUNCTION__); - set_audio_start(core, 0x0001, - EN_FMRADIO_EN_RDS | EN_BTSC_AUTO_STEREO); + set_audio_start(core, SEL_BTSC); set_audio_registers(core, btsc); + set_audio_finish(core, mode); } - set_audio_finish(core); } static void set_audio_standard_NICAM_L(struct cx88_core *core, int stereo) { - /* This is probably weird.. - * Let's operate and find out. */ - - static const struct rlist nicam_l_mono[] = { - { AUD_ERRLOGPERIOD_R, 0x00000064 }, - { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF }, - { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F }, - { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F }, - - { AUD_PDF_DDS_CNST_BYTE2, 0x48 }, - { AUD_PDF_DDS_CNST_BYTE1, 0x3D }, - { AUD_QAM_MODE, 0x00 }, - { AUD_PDF_DDS_CNST_BYTE0, 0xf5 }, - { AUD_PHACC_FREQ_8MSB, 0x3a }, - { AUD_PHACC_FREQ_8LSB, 0x4a }, - - { AUD_DEEMPHGAIN_R, 0x6680 }, - { AUD_DEEMPHNUMER1_R, 0x353DE }, - { AUD_DEEMPHNUMER2_R, 0x1B1 }, - { AUD_DEEMPHDENOM1_R, 0x0F3D0 }, - { AUD_DEEMPHDENOM2_R, 0x0 }, - { AUD_FM_MODE_ENABLE, 0x7 }, - { AUD_POLYPH80SCALEFAC, 0x3 }, - { AUD_AFE_12DB_EN, 0x1 }, - { AAGC_GAIN, 0x0 }, - { AAGC_HYST, 0x18 }, - { AAGC_DEF, 0x20 }, - { AUD_DN0_FREQ, 0x0 }, - { AUD_POLY0_DDS_CONSTANT, 0x0E4DB2 }, - { AUD_DCOC_0_SRC, 0x21 }, - { AUD_IIR1_0_SEL, 0x0 }, - { AUD_IIR1_0_SHIFT, 0x7 }, - { AUD_IIR1_1_SEL, 0x2 }, - { AUD_IIR1_1_SHIFT, 0x0 }, - { AUD_DCOC_1_SRC, 0x3 }, - { AUD_DCOC1_SHIFT, 0x0 }, - { AUD_DCOC_PASS_IN, 0x0 }, - { AUD_IIR1_2_SEL, 0x23 }, - { AUD_IIR1_2_SHIFT, 0x0 }, - { AUD_IIR1_3_SEL, 0x4 }, - { AUD_IIR1_3_SHIFT, 0x7 }, - { AUD_IIR1_4_SEL, 0x5 }, - { AUD_IIR1_4_SHIFT, 0x7 }, - { AUD_IIR3_0_SEL, 0x7 }, - { AUD_IIR3_0_SHIFT, 0x0 }, - { AUD_DEEMPH0_SRC_SEL, 0x11 }, - { AUD_DEEMPH0_SHIFT, 0x0 }, - { AUD_DEEMPH0_G0, 0x7000 }, - { AUD_DEEMPH0_A0, 0x0 }, - { AUD_DEEMPH0_B0, 0x0 }, - { AUD_DEEMPH0_A1, 0x0 }, - { AUD_DEEMPH0_B1, 0x0 }, - { AUD_DEEMPH1_SRC_SEL, 0x11 }, - { AUD_DEEMPH1_SHIFT, 0x0 }, - { AUD_DEEMPH1_G0, 0x7000 }, - { AUD_DEEMPH1_A0, 0x0 }, - { AUD_DEEMPH1_B0, 0x0 }, - { AUD_DEEMPH1_A1, 0x0 }, - { AUD_DEEMPH1_B1, 0x0 }, - { AUD_OUT0_SEL, 0x3F }, - { AUD_OUT1_SEL, 0x3F }, - { AUD_DMD_RA_DDS, 0x0F5C285 }, - { AUD_PLL_INT, 0x1E }, - { AUD_PLL_DDS, 0x0 }, - { AUD_PLL_FRAC, 0x0E542 }, - - // setup QAM registers - { AUD_RATE_ADJ1, 0x00000100 }, - { AUD_RATE_ADJ2, 0x00000200 }, - { AUD_RATE_ADJ3, 0x00000300 }, - { AUD_RATE_ADJ4, 0x00000400 }, - { AUD_RATE_ADJ5, 0x00000500 }, - { AUD_RATE_THRES_DMD, 0x000000C0 }, - { /* end of list */ }, - }; - - static const struct rlist nicam_l[] = { - // setup QAM registers - { AUD_RATE_ADJ1, 0x00000060 }, - { AUD_RATE_ADJ2, 0x000000F9 }, - { AUD_RATE_ADJ3, 0x000001CC }, - { AUD_RATE_ADJ4, 0x000002B3 }, - { AUD_RATE_ADJ5, 0x00000726 }, - { AUD_DEEMPHDENOM1_R, 0x0000F3D0 }, - { AUD_DEEMPHDENOM2_R, 0x00000000 }, - { AUD_ERRLOGPERIOD_R, 0x00000064 }, - { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF }, - { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F }, - { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F }, - { AUD_POLYPH80SCALEFAC, 0x00000003 }, - { AUD_DMD_RA_DDS, 0x00C00000 }, - { AUD_PLL_INT, 0x0000001E }, - { AUD_PLL_DDS, 0x00000000 }, - { AUD_PLL_FRAC, 0x0000E542 }, - { AUD_START_TIMER, 0x00000000 }, - { AUD_DEEMPHNUMER1_R, 0x000353DE }, - { AUD_DEEMPHNUMER2_R, 0x000001B1 }, - { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, - { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, - { AUD_QAM_MODE, 0x05 }, - { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, - { AUD_PHACC_FREQ_8MSB, 0x34 }, - { AUD_PHACC_FREQ_8LSB, 0x4C }, - { AUD_DEEMPHGAIN_R, 0x00006680 }, - { AUD_RATE_THRES_DMD, 0x000000C0 }, - { /* end of list */ }, - } ; - dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo); - - if (!stereo) { - /* AM mono sound */ - set_audio_start(core, 0x0004, - 0x100c /* FIXME again */); - set_audio_registers(core, nicam_l_mono); - } else { - set_audio_start(core, 0x0010, - 0x1924 /* FIXME again */); - set_audio_registers(core, nicam_l); - } - set_audio_finish(core); + /* This is probably weird.. + * Let's operate and find out. */ + + static const struct rlist nicam_l_mono[] = { + { AUD_ERRLOGPERIOD_R, 0x00000064 }, + { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF }, + { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F }, + { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F }, + + { AUD_PDF_DDS_CNST_BYTE2, 0x48 }, + { AUD_PDF_DDS_CNST_BYTE1, 0x3D }, + { AUD_QAM_MODE, 0x00 }, + { AUD_PDF_DDS_CNST_BYTE0, 0xf5 }, + { AUD_PHACC_FREQ_8MSB, 0x3a }, + { AUD_PHACC_FREQ_8LSB, 0x4a }, + + { AUD_DEEMPHGAIN_R, 0x6680 }, + { AUD_DEEMPHNUMER1_R, 0x353DE }, + { AUD_DEEMPHNUMER2_R, 0x1B1 }, + { AUD_DEEMPHDENOM1_R, 0x0F3D0 }, + { AUD_DEEMPHDENOM2_R, 0x0 }, + { AUD_FM_MODE_ENABLE, 0x7 }, + { AUD_POLYPH80SCALEFAC, 0x3 }, + { AUD_AFE_12DB_EN, 0x1 }, + { AAGC_GAIN, 0x0 }, + { AAGC_HYST, 0x18 }, + { AAGC_DEF, 0x20 }, + { AUD_DN0_FREQ, 0x0 }, + { AUD_POLY0_DDS_CONSTANT, 0x0E4DB2 }, + { AUD_DCOC_0_SRC, 0x21 }, + { AUD_IIR1_0_SEL, 0x0 }, + { AUD_IIR1_0_SHIFT, 0x7 }, + { AUD_IIR1_1_SEL, 0x2 }, + { AUD_IIR1_1_SHIFT, 0x0 }, + { AUD_DCOC_1_SRC, 0x3 }, + { AUD_DCOC1_SHIFT, 0x0 }, + { AUD_DCOC_PASS_IN, 0x0 }, + { AUD_IIR1_2_SEL, 0x23 }, + { AUD_IIR1_2_SHIFT, 0x0 }, + { AUD_IIR1_3_SEL, 0x4 }, + { AUD_IIR1_3_SHIFT, 0x7 }, + { AUD_IIR1_4_SEL, 0x5 }, + { AUD_IIR1_4_SHIFT, 0x7 }, + { AUD_IIR3_0_SEL, 0x7 }, + { AUD_IIR3_0_SHIFT, 0x0 }, + { AUD_DEEMPH0_SRC_SEL, 0x11 }, + { AUD_DEEMPH0_SHIFT, 0x0 }, + { AUD_DEEMPH0_G0, 0x7000 }, + { AUD_DEEMPH0_A0, 0x0 }, + { AUD_DEEMPH0_B0, 0x0 }, + { AUD_DEEMPH0_A1, 0x0 }, + { AUD_DEEMPH0_B1, 0x0 }, + { AUD_DEEMPH1_SRC_SEL, 0x11 }, + { AUD_DEEMPH1_SHIFT, 0x0 }, + { AUD_DEEMPH1_G0, 0x7000 }, + { AUD_DEEMPH1_A0, 0x0 }, + { AUD_DEEMPH1_B0, 0x0 }, + { AUD_DEEMPH1_A1, 0x0 }, + { AUD_DEEMPH1_B1, 0x0 }, + { AUD_OUT0_SEL, 0x3F }, + { AUD_OUT1_SEL, 0x3F }, + { AUD_DMD_RA_DDS, 0x0F5C285 }, + { AUD_PLL_INT, 0x1E }, + { AUD_PLL_DDS, 0x0 }, + { AUD_PLL_FRAC, 0x0E542 }, + + // setup QAM registers + { AUD_RATE_ADJ1, 0x00000100 }, + { AUD_RATE_ADJ2, 0x00000200 }, + { AUD_RATE_ADJ3, 0x00000300 }, + { AUD_RATE_ADJ4, 0x00000400 }, + { AUD_RATE_ADJ5, 0x00000500 }, + { AUD_RATE_THRES_DMD, 0x000000C0 }, + { /* end of list */ }, + }; + static const struct rlist nicam_l[] = { + // setup QAM registers + { AUD_RATE_ADJ1, 0x00000060 }, + { AUD_RATE_ADJ2, 0x000000F9 }, + { AUD_RATE_ADJ3, 0x000001CC }, + { AUD_RATE_ADJ4, 0x000002B3 }, + { AUD_RATE_ADJ5, 0x00000726 }, + { AUD_DEEMPHDENOM1_R, 0x0000F3D0 }, + { AUD_DEEMPHDENOM2_R, 0x00000000 }, + { AUD_ERRLOGPERIOD_R, 0x00000064 }, + { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF }, + { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F }, + { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F }, + { AUD_POLYPH80SCALEFAC, 0x00000003 }, + { AUD_DMD_RA_DDS, 0x00C00000 }, + { AUD_PLL_INT, 0x0000001E }, + { AUD_PLL_DDS, 0x00000000 }, + { AUD_PLL_FRAC, 0x0000E542 }, + { AUD_START_TIMER, 0x00000000 }, + { AUD_DEEMPHNUMER1_R, 0x000353DE }, + { AUD_DEEMPHNUMER2_R, 0x000001B1 }, + { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, + { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, + { AUD_QAM_MODE, 0x05 }, + { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, + { AUD_PHACC_FREQ_8MSB, 0x34 }, + { AUD_PHACC_FREQ_8LSB, 0x4C }, + { AUD_DEEMPHGAIN_R, 0x00006680 }, + { AUD_RATE_THRES_DMD, 0x000000C0 }, + { /* end of list */ }, + } ; + dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo); + + if (!stereo) { + /* AM Mono */ + set_audio_start(core, SEL_A2); + set_audio_registers(core, nicam_l_mono); + set_audio_finish(core, EN_A2_FORCE_MONO1); + } else { + /* Nicam Stereo */ + set_audio_start(core, SEL_NICAM); + set_audio_registers(core, nicam_l); + set_audio_finish(core, 0x1924); /* FIXME */ + } } static void set_audio_standard_PAL_I(struct cx88_core *core, int stereo) { static const struct rlist pal_i_fm_mono[] = { - {AUD_ERRLOGPERIOD_R, 0x00000064}, - {AUD_ERRINTRPTTHSHLD1_R, 0x00000fff}, - {AUD_ERRINTRPTTHSHLD2_R, 0x0000001f}, - {AUD_ERRINTRPTTHSHLD3_R, 0x0000000f}, - {AUD_PDF_DDS_CNST_BYTE2, 0x06}, - {AUD_PDF_DDS_CNST_BYTE1, 0x82}, - {AUD_PDF_DDS_CNST_BYTE0, 0x12}, - {AUD_QAM_MODE, 0x05}, - {AUD_PHACC_FREQ_8MSB, 0x3a}, - {AUD_PHACC_FREQ_8LSB, 0x93}, - {AUD_DMD_RA_DDS, 0x002a4f2f}, - {AUD_PLL_INT, 0x0000001e}, - {AUD_PLL_DDS, 0x00000004}, - {AUD_PLL_FRAC, 0x0000e542}, - {AUD_RATE_ADJ1, 0x00000100}, - {AUD_RATE_ADJ2, 0x00000200}, - {AUD_RATE_ADJ3, 0x00000300}, - {AUD_RATE_ADJ4, 0x00000400}, - {AUD_RATE_ADJ5, 0x00000500}, - {AUD_THR_FR, 0x00000000}, - {AUD_PILOT_BQD_1_K0, 0x0000755b}, - {AUD_PILOT_BQD_1_K1, 0x00551340}, - {AUD_PILOT_BQD_1_K2, 0x006d30be}, - {AUD_PILOT_BQD_1_K3, 0xffd394af}, - {AUD_PILOT_BQD_1_K4, 0x00400000}, - {AUD_PILOT_BQD_2_K0, 0x00040000}, - {AUD_PILOT_BQD_2_K1, 0x002a4841}, - {AUD_PILOT_BQD_2_K2, 0x00400000}, - {AUD_PILOT_BQD_2_K3, 0x00000000}, - {AUD_PILOT_BQD_2_K4, 0x00000000}, - {AUD_MODE_CHG_TIMER, 0x00000060}, - {AUD_AFE_12DB_EN, 0x00000001}, - {AAGC_HYST, 0x0000000a}, - {AUD_CORDIC_SHIFT_0, 0x00000007}, - {AUD_CORDIC_SHIFT_1, 0x00000007}, - {AUD_C1_UP_THR, 0x00007000}, - {AUD_C1_LO_THR, 0x00005400}, - {AUD_C2_UP_THR, 0x00005400}, - {AUD_C2_LO_THR, 0x00003000}, - {AUD_DCOC_0_SRC, 0x0000001a}, - {AUD_DCOC0_SHIFT, 0x00000000}, - {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, - {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, - {AUD_DCOC_PASS_IN, 0x00000003}, - {AUD_IIR3_0_SEL, 0x00000021}, - {AUD_DN2_AFC, 0x00000002}, - {AUD_DCOC_1_SRC, 0x0000001b}, - {AUD_DCOC1_SHIFT, 0x00000000}, - {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, - {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, - {AUD_IIR3_1_SEL, 0x00000023}, - {AUD_DN0_FREQ, 0x000035a3}, - {AUD_DN2_FREQ, 0x000029c7}, - {AUD_CRDC0_SRC_SEL, 0x00000511}, - {AUD_IIR1_0_SEL, 0x00000001}, - {AUD_IIR1_1_SEL, 0x00000000}, - {AUD_IIR3_2_SEL, 0x00000003}, - {AUD_IIR3_2_SHIFT, 0x00000000}, - {AUD_IIR3_0_SEL, 0x00000002}, - {AUD_IIR2_0_SEL, 0x00000021}, - {AUD_IIR2_0_SHIFT, 0x00000002}, - {AUD_DEEMPH0_SRC_SEL, 0x0000000b}, - {AUD_DEEMPH1_SRC_SEL, 0x0000000b}, - {AUD_POLYPH80SCALEFAC, 0x00000001}, - {AUD_START_TIMER, 0x00000000}, - { /* end of list */ }, + {AUD_ERRLOGPERIOD_R, 0x00000064}, + {AUD_ERRINTRPTTHSHLD1_R, 0x00000fff}, + {AUD_ERRINTRPTTHSHLD2_R, 0x0000001f}, + {AUD_ERRINTRPTTHSHLD3_R, 0x0000000f}, + {AUD_PDF_DDS_CNST_BYTE2, 0x06}, + {AUD_PDF_DDS_CNST_BYTE1, 0x82}, + {AUD_PDF_DDS_CNST_BYTE0, 0x12}, + {AUD_QAM_MODE, 0x05}, + {AUD_PHACC_FREQ_8MSB, 0x3a}, + {AUD_PHACC_FREQ_8LSB, 0x93}, + {AUD_DMD_RA_DDS, 0x002a4f2f}, + {AUD_PLL_INT, 0x0000001e}, + {AUD_PLL_DDS, 0x00000004}, + {AUD_PLL_FRAC, 0x0000e542}, + {AUD_RATE_ADJ1, 0x00000100}, + {AUD_RATE_ADJ2, 0x00000200}, + {AUD_RATE_ADJ3, 0x00000300}, + {AUD_RATE_ADJ4, 0x00000400}, + {AUD_RATE_ADJ5, 0x00000500}, + {AUD_THR_FR, 0x00000000}, + {AUD_PILOT_BQD_1_K0, 0x0000755b}, + {AUD_PILOT_BQD_1_K1, 0x00551340}, + {AUD_PILOT_BQD_1_K2, 0x006d30be}, + {AUD_PILOT_BQD_1_K3, 0xffd394af}, + {AUD_PILOT_BQD_1_K4, 0x00400000}, + {AUD_PILOT_BQD_2_K0, 0x00040000}, + {AUD_PILOT_BQD_2_K1, 0x002a4841}, + {AUD_PILOT_BQD_2_K2, 0x00400000}, + {AUD_PILOT_BQD_2_K3, 0x00000000}, + {AUD_PILOT_BQD_2_K4, 0x00000000}, + {AUD_MODE_CHG_TIMER, 0x00000060}, + {AUD_AFE_12DB_EN, 0x00000001}, + {AAGC_HYST, 0x0000000a}, + {AUD_CORDIC_SHIFT_0, 0x00000007}, + {AUD_CORDIC_SHIFT_1, 0x00000007}, + {AUD_C1_UP_THR, 0x00007000}, + {AUD_C1_LO_THR, 0x00005400}, + {AUD_C2_UP_THR, 0x00005400}, + {AUD_C2_LO_THR, 0x00003000}, + {AUD_DCOC_0_SRC, 0x0000001a}, + {AUD_DCOC0_SHIFT, 0x00000000}, + {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, + {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, + {AUD_DCOC_PASS_IN, 0x00000003}, + {AUD_IIR3_0_SEL, 0x00000021}, + {AUD_DN2_AFC, 0x00000002}, + {AUD_DCOC_1_SRC, 0x0000001b}, + {AUD_DCOC1_SHIFT, 0x00000000}, + {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, + {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, + {AUD_IIR3_1_SEL, 0x00000023}, + {AUD_DN0_FREQ, 0x000035a3}, + {AUD_DN2_FREQ, 0x000029c7}, + {AUD_CRDC0_SRC_SEL, 0x00000511}, + {AUD_IIR1_0_SEL, 0x00000001}, + {AUD_IIR1_1_SEL, 0x00000000}, + {AUD_IIR3_2_SEL, 0x00000003}, + {AUD_IIR3_2_SHIFT, 0x00000000}, + {AUD_IIR3_0_SEL, 0x00000002}, + {AUD_IIR2_0_SEL, 0x00000021}, + {AUD_IIR2_0_SHIFT, 0x00000002}, + {AUD_DEEMPH0_SRC_SEL, 0x0000000b}, + {AUD_DEEMPH1_SRC_SEL, 0x0000000b}, + {AUD_POLYPH80SCALEFAC, 0x00000001}, + {AUD_START_TIMER, 0x00000000}, + { /* end of list */ }, }; static const struct rlist pal_i_nicam[] = { - { AUD_RATE_ADJ1, 0x00000010 }, - { AUD_RATE_ADJ2, 0x00000040 }, - { AUD_RATE_ADJ3, 0x00000100 }, - { AUD_RATE_ADJ4, 0x00000400 }, - { AUD_RATE_ADJ5, 0x00001000 }, - // { AUD_DMD_RA_DDS, 0x00c0d5ce }, - { AUD_DEEMPHGAIN_R, 0x000023c2 }, - { AUD_DEEMPHNUMER1_R, 0x0002a7bc }, - { AUD_DEEMPHNUMER2_R, 0x0003023e }, - { AUD_DEEMPHDENOM1_R, 0x0000f3d0 }, - { AUD_DEEMPHDENOM2_R, 0x00000000 }, - { AUD_DEEMPHDENOM2_R, 0x00000000 }, - { AUD_ERRLOGPERIOD_R, 0x00000fff }, - { AUD_ERRINTRPTTHSHLD1_R, 0x000003ff }, - { AUD_ERRINTRPTTHSHLD2_R, 0x000000ff }, - { AUD_ERRINTRPTTHSHLD3_R, 0x0000003f }, - { AUD_POLYPH80SCALEFAC, 0x00000003 }, - { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, - { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, - { AUD_PDF_DDS_CNST_BYTE0, 0x16 }, - { AUD_QAM_MODE, 0x05 }, - { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, - { AUD_PHACC_FREQ_8MSB, 0x3a }, - { AUD_PHACC_FREQ_8LSB, 0x93 }, - { /* end of list */ }, - }; - - dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo); - - if (!stereo) { - // FM mono - set_audio_start(core, 0x0004, EN_DMTRX_SUMDIFF | EN_A2_FORCE_MONO1); + { AUD_RATE_ADJ1, 0x00000010 }, + { AUD_RATE_ADJ2, 0x00000040 }, + { AUD_RATE_ADJ3, 0x00000100 }, + { AUD_RATE_ADJ4, 0x00000400 }, + { AUD_RATE_ADJ5, 0x00001000 }, + // { AUD_DMD_RA_DDS, 0x00c0d5ce }, + { AUD_DEEMPHGAIN_R, 0x000023c2 }, + { AUD_DEEMPHNUMER1_R, 0x0002a7bc }, + { AUD_DEEMPHNUMER2_R, 0x0003023e }, + { AUD_DEEMPHDENOM1_R, 0x0000f3d0 }, + { AUD_DEEMPHDENOM2_R, 0x00000000 }, + { AUD_DEEMPHDENOM2_R, 0x00000000 }, + { AUD_ERRLOGPERIOD_R, 0x00000fff }, + { AUD_ERRINTRPTTHSHLD1_R, 0x000003ff }, + { AUD_ERRINTRPTTHSHLD2_R, 0x000000ff }, + { AUD_ERRINTRPTTHSHLD3_R, 0x0000003f }, + { AUD_POLYPH80SCALEFAC, 0x00000003 }, + { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, + { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, + { AUD_PDF_DDS_CNST_BYTE0, 0x16 }, + { AUD_QAM_MODE, 0x05 }, + { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, + { AUD_PHACC_FREQ_8MSB, 0x3a }, + { AUD_PHACC_FREQ_8LSB, 0x93 }, + { /* end of list */ }, + }; + + dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo); + + if (!stereo) { + /* FM Mono */ + set_audio_start(core, SEL_A2); set_audio_registers(core, pal_i_fm_mono); - } else { - // Nicam Stereo - set_audio_start(core, 0x0010, EN_DMTRX_LR | EN_DMTRX_BYPASS | EN_NICAM_AUTO_STEREO); + set_audio_finish(core, EN_DMTRX_SUMDIFF | EN_A2_FORCE_MONO1); + } else { + /* Nicam Stereo */ + set_audio_start(core, SEL_NICAM); set_audio_registers(core, pal_i_nicam); - } - set_audio_finish(core); + set_audio_finish(core, EN_DMTRX_LR | EN_DMTRX_BYPASS | EN_NICAM_AUTO_STEREO); + } } -static void set_audio_standard_A2(struct cx88_core *core) +static void set_audio_standard_A2(struct cx88_core *core, u32 mode) { - /* from dscaler cvs */ static const struct rlist a2_common[] = { - { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, - { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, - { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, - { AUD_QAM_MODE, 0x05 }, - { AUD_PHACC_FREQ_8MSB, 0x34 }, - { AUD_PHACC_FREQ_8LSB, 0x4c }, - - { AUD_RATE_ADJ1, 0x00001000 }, - { AUD_RATE_ADJ2, 0x00002000 }, - { AUD_RATE_ADJ3, 0x00003000 }, - { AUD_RATE_ADJ4, 0x00004000 }, - { AUD_RATE_ADJ5, 0x00005000 }, - { AUD_THR_FR, 0x00000000 }, - { AAGC_HYST, 0x0000001a }, - { AUD_PILOT_BQD_1_K0, 0x0000755b }, - { AUD_PILOT_BQD_1_K1, 0x00551340 }, - { AUD_PILOT_BQD_1_K2, 0x006d30be }, - { AUD_PILOT_BQD_1_K3, 0xffd394af }, - { AUD_PILOT_BQD_1_K4, 0x00400000 }, - { AUD_PILOT_BQD_2_K0, 0x00040000 }, - { AUD_PILOT_BQD_2_K1, 0x002a4841 }, - { AUD_PILOT_BQD_2_K2, 0x00400000 }, - { AUD_PILOT_BQD_2_K3, 0x00000000 }, - { AUD_PILOT_BQD_2_K4, 0x00000000 }, - { AUD_MODE_CHG_TIMER, 0x00000040 }, - { AUD_START_TIMER, 0x00000200 }, - { AUD_AFE_12DB_EN, 0x00000000 }, - { AUD_CORDIC_SHIFT_0, 0x00000007 }, - { AUD_CORDIC_SHIFT_1, 0x00000007 }, - { AUD_DEEMPH0_G0, 0x00000380 }, - { AUD_DEEMPH1_G0, 0x00000380 }, - { AUD_DCOC_0_SRC, 0x0000001a }, - { AUD_DCOC0_SHIFT, 0x00000000 }, - { AUD_DCOC_0_SHIFT_IN0, 0x0000000a }, - { AUD_DCOC_0_SHIFT_IN1, 0x00000008 }, - { AUD_DCOC_PASS_IN, 0x00000003 }, - { AUD_IIR3_0_SEL, 0x00000021 }, - { AUD_DN2_AFC, 0x00000002 }, - { AUD_DCOC_1_SRC, 0x0000001b }, - { AUD_DCOC1_SHIFT, 0x00000000 }, - { AUD_DCOC_1_SHIFT_IN0, 0x0000000a }, - { AUD_DCOC_1_SHIFT_IN1, 0x00000008 }, - { AUD_IIR3_1_SEL, 0x00000023 }, - { AUD_RDSI_SEL, 0x00000017 }, - { AUD_RDSI_SHIFT, 0x00000000 }, - { AUD_RDSQ_SEL, 0x00000017 }, - { AUD_RDSQ_SHIFT, 0x00000000 }, - { AUD_POLYPH80SCALEFAC, 0x00000001 }, + {AUD_ERRLOGPERIOD_R, 0x00000064}, + {AUD_ERRINTRPTTHSHLD1_R, 0x00000fff}, + {AUD_ERRINTRPTTHSHLD2_R, 0x0000001f}, + {AUD_ERRINTRPTTHSHLD3_R, 0x0000000f}, + {AUD_PDF_DDS_CNST_BYTE2, 0x06}, + {AUD_PDF_DDS_CNST_BYTE1, 0x82}, + {AUD_PDF_DDS_CNST_BYTE0, 0x12}, + {AUD_QAM_MODE, 0x05}, + {AUD_PHACC_FREQ_8MSB, 0x34}, + {AUD_PHACC_FREQ_8LSB, 0x4c}, + {AUD_RATE_ADJ1, 0x00000100}, + {AUD_RATE_ADJ2, 0x00000200}, + {AUD_RATE_ADJ3, 0x00000300}, + {AUD_RATE_ADJ4, 0x00000400}, + {AUD_RATE_ADJ5, 0x00000500}, + {AUD_THR_FR, 0x00000000}, + {AAGC_HYST, 0x0000001a}, + {AUD_PILOT_BQD_1_K0, 0x0000755b}, + {AUD_PILOT_BQD_1_K1, 0x00551340}, + {AUD_PILOT_BQD_1_K2, 0x006d30be}, + {AUD_PILOT_BQD_1_K3, 0xffd394af}, + {AUD_PILOT_BQD_1_K4, 0x00400000}, + {AUD_PILOT_BQD_2_K0, 0x00040000}, + {AUD_PILOT_BQD_2_K1, 0x002a4841}, + {AUD_PILOT_BQD_2_K2, 0x00400000}, + {AUD_PILOT_BQD_2_K3, 0x00000000}, + {AUD_PILOT_BQD_2_K4, 0x00000000}, + {AUD_MODE_CHG_TIMER, 0x00000040}, + {AUD_AFE_12DB_EN, 0x00000001}, + {AUD_CORDIC_SHIFT_0, 0x00000007}, + {AUD_CORDIC_SHIFT_1, 0x00000007}, + {AUD_DEEMPH0_G0, 0x00000380}, + {AUD_DEEMPH1_G0, 0x00000380}, + {AUD_DCOC_0_SRC, 0x0000001a}, + {AUD_DCOC0_SHIFT, 0x00000000}, + {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, + {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, + {AUD_DCOC_PASS_IN, 0x00000003}, + {AUD_IIR3_0_SEL, 0x00000021}, + {AUD_DN2_AFC, 0x00000002}, + {AUD_DCOC_1_SRC, 0x0000001b}, + {AUD_DCOC1_SHIFT, 0x00000000}, + {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, + {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, + {AUD_IIR3_1_SEL, 0x00000023}, + {AUD_RDSI_SEL, 0x00000017}, + {AUD_RDSI_SHIFT, 0x00000000}, + {AUD_RDSQ_SEL, 0x00000017}, + {AUD_RDSQ_SHIFT, 0x00000000}, + {AUD_PLL_INT, 0x0000001e}, + {AUD_PLL_DDS, 0x00000000}, + {AUD_PLL_FRAC, 0x0000e542}, + {AUD_POLYPH80SCALEFAC, 0x00000001}, + {AUD_START_TIMER, 0x00000000}, + { /* end of list */ }, + }; + static const struct rlist a2_bg[] = { + {AUD_DMD_RA_DDS, 0x002a4f2f}, + {AUD_C1_UP_THR, 0x00007000}, + {AUD_C1_LO_THR, 0x00005400}, + {AUD_C2_UP_THR, 0x00005400}, + {AUD_C2_LO_THR, 0x00003000}, { /* end of list */ }, }; - static const struct rlist a2_table1[] = { - // PAL-BG - { AUD_DMD_RA_DDS, 0x002a73bd }, - { AUD_C1_UP_THR, 0x00007000 }, - { AUD_C1_LO_THR, 0x00005400 }, - { AUD_C2_UP_THR, 0x00005400 }, - { AUD_C2_LO_THR, 0x00003000 }, + static const struct rlist a2_dk[] = { + {AUD_DMD_RA_DDS, 0x002a4f2f}, + {AUD_C1_UP_THR, 0x00007000}, + {AUD_C1_LO_THR, 0x00005400}, + {AUD_C2_UP_THR, 0x00005400}, + {AUD_C2_LO_THR, 0x00003000}, + {AUD_DN0_FREQ, 0x00003a1c}, + {AUD_DN2_FREQ, 0x0000d2e0}, { /* end of list */ }, }; - static const struct rlist a2_table2[] = { - // PAL-DK - { AUD_DMD_RA_DDS, 0x002a73bd }, - { AUD_C1_UP_THR, 0x00007000 }, - { AUD_C1_LO_THR, 0x00005400 }, - { AUD_C2_UP_THR, 0x00005400 }, - { AUD_C2_LO_THR, 0x00003000 }, - { AUD_DN0_FREQ, 0x00003a1c }, - { AUD_DN2_FREQ, 0x0000d2e0 }, +/* unknown, probably NTSC-M */ + static const struct rlist a2_m[] = { + {AUD_DMD_RA_DDS, 0x002a0425}, + {AUD_C1_UP_THR, 0x00003c00}, + {AUD_C1_LO_THR, 0x00003000}, + {AUD_C2_UP_THR, 0x00006000}, + {AUD_C2_LO_THR, 0x00003c00}, + {AUD_DEEMPH0_A0, 0x00007a80}, + {AUD_DEEMPH1_A0, 0x00007a80}, + {AUD_DEEMPH0_G0, 0x00001200}, + {AUD_DEEMPH1_G0, 0x00001200}, + {AUD_DN0_FREQ, 0x0000283b}, + {AUD_DN1_FREQ, 0x00003418}, + {AUD_DN2_FREQ, 0x000029c7}, + {AUD_POLY0_DDS_CONSTANT, 0x000a7540}, { /* end of list */ }, }; - static const struct rlist a2_table3[] = { - // unknown, probably NTSC-M - { AUD_DMD_RA_DDS, 0x002a2873 }, - { AUD_C1_UP_THR, 0x00003c00 }, - { AUD_C1_LO_THR, 0x00003000 }, - { AUD_C2_UP_THR, 0x00006000 }, - { AUD_C2_LO_THR, 0x00003c00 }, - { AUD_DN0_FREQ, 0x00002836 }, - { AUD_DN1_FREQ, 0x00003418 }, - { AUD_DN2_FREQ, 0x000029c7 }, - { AUD_POLY0_DDS_CONSTANT, 0x000a7540 }, + + static const struct rlist a2_deemph50[] = { + {AUD_DEEMPH0_G0, 0x00000380}, + {AUD_DEEMPH1_G0, 0x00000380}, + {AUD_DEEMPHGAIN_R, 0x000011e1}, + {AUD_DEEMPHNUMER1_R, 0x0002a7bc}, + {AUD_DEEMPHNUMER2_R, 0x0003023c}, + { /* end of list */ }, + }; + + static const struct rlist a2_deemph75[] = { + {AUD_DEEMPH0_G0, 0x00000480}, + {AUD_DEEMPH1_G0, 0x00000480}, + {AUD_DEEMPHGAIN_R, 0x00009000}, + {AUD_DEEMPHNUMER1_R, 0x000353de}, + {AUD_DEEMPHNUMER2_R, 0x000001b1}, { /* end of list */ }, }; - set_audio_start(core, 0x0004, EN_DMTRX_SUMDIFF | EN_A2_AUTO_STEREO); + set_audio_start(core, SEL_A2); set_audio_registers(core, a2_common); switch (core->tvaudio) { case WW_A2_BG: dprintk("%s PAL-BG A2 (status: known-good)\n",__FUNCTION__); - set_audio_registers(core, a2_table1); + set_audio_registers(core, a2_bg); + set_audio_registers(core, a2_deemph50); break; case WW_A2_DK: dprintk("%s PAL-DK A2 (status: known-good)\n",__FUNCTION__); - set_audio_registers(core, a2_table2); + set_audio_registers(core, a2_dk); + set_audio_registers(core, a2_deemph50); break; case WW_A2_M: dprintk("%s NTSC-M A2 (status: unknown)\n",__FUNCTION__); - set_audio_registers(core, a2_table3); + set_audio_registers(core, a2_m); + set_audio_registers(core, a2_deemph75); break; }; - set_audio_finish(core); + + mode |= EN_FMRADIO_EN_RDS | EN_DMTRX_SUMDIFF; + set_audio_finish(core, mode); } static void set_audio_standard_EIAJ(struct cx88_core *core) @@ -635,9 +658,9 @@ static void set_audio_standard_EIAJ(struct cx88_core *core) }; dprintk("%s (status: unknown)\n",__FUNCTION__); - set_audio_start(core, 0x0002, EN_EIAJ_AUTO_STEREO); + set_audio_start(core, SEL_EIAJ); set_audio_registers(core, eiaj); - set_audio_finish(core); + set_audio_finish(core, EN_EIAJ_AUTO_STEREO); } static void set_audio_standard_FM(struct cx88_core *core, enum cx88_deemph_type deemph) @@ -683,7 +706,7 @@ static void set_audio_standard_FM(struct cx88_core *core, enum cx88_deemph_type }; dprintk("%s (status: unknown)\n",__FUNCTION__); - set_audio_start(core, 0x0020, EN_FMRADIO_AUTO_STEREO); + set_audio_start(core, SEL_FMRADIO); switch (deemph) { @@ -700,7 +723,7 @@ static void set_audio_standard_FM(struct cx88_core *core, enum cx88_deemph_type break; } - set_audio_finish(core); + set_audio_finish(core, EN_FMRADIO_AUTO_STEREO); } /* ----------------------------------------------------------- */ @@ -709,7 +732,7 @@ void cx88_set_tvaudio(struct cx88_core *core) { switch (core->tvaudio) { case WW_BTSC: - set_audio_standard_BTSC(core,0); + set_audio_standard_BTSC(core, 0, EN_BTSC_AUTO_STEREO); break; case WW_NICAM_BGDKL: set_audio_standard_NICAM_L(core,0); @@ -720,7 +743,7 @@ void cx88_set_tvaudio(struct cx88_core *core) case WW_A2_BG: case WW_A2_DK: case WW_A2_M: - set_audio_standard_A2(core); + set_audio_standard_A2(core, EN_A2_FORCE_MONO1); break; case WW_EIAJ: set_audio_standard_EIAJ(core); @@ -734,7 +757,7 @@ void cx88_set_tvaudio(struct cx88_core *core) case WW_NONE: default: printk("%s/0: unknown tv audio mode [%d]\n", - core->name, core->tvaudio); + core->name, core->tvaudio); break; } return; @@ -769,6 +792,13 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) aud_ctl_names[cx_read(AUD_CTL) & 63]); core->astat = reg; +/* TODO + Reading from AUD_STATUS is not enough + for auto-detecting sap/dual-fm/nicam. + Add some code here later. +*/ + +# if 0 t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; t->rxsubchans = V4L2_TUNER_SUB_MONO; @@ -779,7 +809,7 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP; t->rxsubchans = V4L2_TUNER_SUB_STEREO; - if (1 == pilot) { + if (1 == pilot) { /* SAP */ t->rxsubchans |= V4L2_TUNER_SUB_SAP; } @@ -787,13 +817,13 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) case WW_A2_BG: case WW_A2_DK: case WW_A2_M: - if (1 == pilot) { + if (1 == pilot) { /* stereo */ t->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; if (0 == mode) t->audmode = V4L2_TUNER_MODE_STEREO; } - if (2 == pilot) { + if (2 == pilot) { /* dual language -- FIXME */ t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; t->audmode = V4L2_TUNER_MODE_LANG1; @@ -805,16 +835,17 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) t->rxsubchans |= V4L2_TUNER_SUB_STEREO; } break; - case WW_SYSTEM_L_AM: - if (0x0 == mode && !(cx_read(AUD_INIT) & 0x04)) { - t->audmode = V4L2_TUNER_MODE_STEREO; + case WW_SYSTEM_L_AM: + if (0x0 == mode && !(cx_read(AUD_INIT) & 0x04)) { + t->audmode = V4L2_TUNER_MODE_STEREO; t->rxsubchans |= V4L2_TUNER_SUB_STEREO; } - break ; + break ; default: /* nothing */ break; } +# endif return; } @@ -835,16 +866,16 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual) case WW_BTSC: switch (mode) { case V4L2_TUNER_MODE_MONO: - ctl = EN_BTSC_FORCE_MONO; - mask = 0x3f; + set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_MONO); break; - case V4L2_TUNER_MODE_SAP: - ctl = EN_BTSC_FORCE_SAP; - mask = 0x3f; + case V4L2_TUNER_MODE_LANG1: + set_audio_standard_BTSC(core, 0, EN_BTSC_AUTO_STEREO); + break; + case V4L2_TUNER_MODE_LANG2: + set_audio_standard_BTSC(core, 1, EN_BTSC_FORCE_SAP); break; case V4L2_TUNER_MODE_STEREO: - ctl = EN_BTSC_AUTO_STEREO; - mask = 0x3f; + set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_STEREO); break; } break; @@ -854,16 +885,13 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual) switch (mode) { case V4L2_TUNER_MODE_MONO: case V4L2_TUNER_MODE_LANG1: - ctl = EN_A2_FORCE_MONO1; - mask = 0x3f; + set_audio_standard_A2(core, EN_A2_FORCE_MONO1); break; case V4L2_TUNER_MODE_LANG2: - ctl = EN_A2_AUTO_MONO2; - mask = 0x3f; + set_audio_standard_A2(core, EN_A2_FORCE_MONO2); break; case V4L2_TUNER_MODE_STEREO: - ctl = EN_A2_AUTO_STEREO | EN_DMTRX_SUMR; - mask = 0x8bf; + set_audio_standard_A2(core, EN_A2_FORCE_STEREO); break; } break; diff --git a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c index 320d578..9bc6c89 100644 --- a/drivers/media/video/cx88/cx88-vbi.c +++ b/drivers/media/video/cx88/cx88-vbi.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-vbi.c,v 1.17 2005/06/12 04:19:19 mchehab Exp $ */ #include #include diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 5f58c10..61d4b29 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-video.c,v 1.82 2005/07/22 05:13:34 mkrufky Exp $ * * device driver for Conexant 2388x based TV cards * video4linux video interface @@ -66,7 +65,7 @@ module_param(vid_limit,int,0644); MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes"); #define dprintk(level,fmt, arg...) if (video_debug >= level) \ - printk(KERN_DEBUG "%s/0: " fmt, dev->core->name , ## arg) + printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) /* ------------------------------------------------------------------ */ @@ -326,22 +325,23 @@ static const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls); static int res_get(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bit) { + struct cx88_core *core = dev->core; if (fh->resources & bit) /* have it already allocated */ return 1; /* is it free? */ - down(&dev->lock); + down(&core->lock); if (dev->resources & bit) { /* no, someone else uses it */ - up(&dev->lock); + up(&core->lock); return 0; } /* it's free, grab it */ fh->resources |= bit; dev->resources |= bit; dprintk(1,"res: get %d\n",bit); - up(&dev->lock); + up(&core->lock); return 1; } @@ -360,27 +360,29 @@ int res_locked(struct cx8800_dev *dev, unsigned int bit) static void res_free(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bits) { + struct cx88_core *core = dev->core; if ((fh->resources & bits) != bits) BUG(); - down(&dev->lock); + down(&core->lock); fh->resources &= ~bits; dev->resources &= ~bits; dprintk(1,"res: put %d\n",bits); - up(&dev->lock); + up(&core->lock); } /* ------------------------------------------------------------------ */ -static int video_mux(struct cx8800_dev *dev, unsigned int input) +/* static int video_mux(struct cx8800_dev *dev, unsigned int input) */ +static int video_mux(struct cx88_core *core, unsigned int input) { - struct cx88_core *core = dev->core; + /* struct cx88_core *core = dev->core; */ dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n", input, INPUT(input)->vmux, INPUT(input)->gpio0,INPUT(input)->gpio1, INPUT(input)->gpio2,INPUT(input)->gpio3); - dev->core->input = input; + core->input = input; cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input)->vmux << 14); cx_write(MO_GP3_IO, INPUT(input)->gpio3); cx_write(MO_GP0_IO, INPUT(input)->gpio0); @@ -413,9 +415,9 @@ static int start_video_dma(struct cx8800_dev *dev, struct cx88_core *core = dev->core; /* setup fifo + format */ - cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH21], + cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21], buf->bpl, buf->risc.dma); - cx88_set_scale(dev->core, buf->vb.width, buf->vb.height, buf->vb.field); + cx88_set_scale(core, buf->vb.width, buf->vb.height, buf->vb.field); cx_write(MO_COLOR_CTRL, buf->fmt->cxformat | ColorFormatGamma); /* reset counter */ @@ -424,6 +426,14 @@ static int start_video_dma(struct cx8800_dev *dev, /* enable irqs */ cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x01); + + /* Enables corresponding bits at PCI_INT_STAT: + bits 0 to 4: video, audio, transport stream, VIP, Host + bit 7: timer + bits 8 and 9: DMA complete for: SRC, DST + bits 10 and 11: BERR signal asserted for RISC: RD, WR + bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB + */ cx_set(MO_VID_INTMSK, 0x0f0011); /* enable capture */ @@ -431,7 +441,7 @@ static int start_video_dma(struct cx8800_dev *dev, /* start dma */ cx_set(MO_DEV_CNTRL2, (1<<5)); - cx_set(MO_VID_DMACNTRL, 0x11); + cx_set(MO_VID_DMACNTRL, 0x11); /* Planar Y and packed FIFO and RISC enable */ return 0; } @@ -455,6 +465,7 @@ static int stop_video_dma(struct cx8800_dev *dev) static int restart_video_queue(struct cx8800_dev *dev, struct cx88_dmaqueue *q) { + struct cx88_core *core = dev->core; struct cx88_buffer *buf, *prev; struct list_head *item; @@ -524,12 +535,13 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, { struct cx8800_fh *fh = q->priv_data; struct cx8800_dev *dev = fh->dev; + struct cx88_core *core = dev->core; struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); int rc, init_buffer = 0; BUG_ON(NULL == fh->fmt); - if (fh->width < 48 || fh->width > norm_maxw(dev->core->tvnorm) || - fh->height < 32 || fh->height > norm_maxh(dev->core->tvnorm)) + if (fh->width < 48 || fh->width > norm_maxw(core->tvnorm) || + fh->height < 32 || fh->height > norm_maxh(core->tvnorm)) return -EINVAL; buf->vb.size = (fh->width * fh->height * fh->fmt->depth) >> 3; if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) @@ -609,6 +621,7 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) struct cx88_buffer *prev; struct cx8800_fh *fh = vq->priv_data; struct cx8800_dev *dev = fh->dev; + struct cx88_core *core = dev->core; struct cx88_dmaqueue *q = &dev->vidq; /* add jump to stopper */ @@ -701,6 +714,7 @@ static int video_open(struct inode *inode, struct file *file) { int minor = iminor(inode); struct cx8800_dev *h,*dev = NULL; + struct cx88_core *core; struct cx8800_fh *fh; struct list_head *list; enum v4l2_buf_type type = 0; @@ -725,6 +739,8 @@ static int video_open(struct inode *inode, struct file *file) if (NULL == dev) return -ENODEV; + core = dev->core; + dprintk(1,"open minor=%d radio=%d type=%s\n", minor,radio,v4l2_type_names[type]); @@ -755,17 +771,16 @@ static int video_open(struct inode *inode, struct file *file) fh); if (fh->radio) { - struct cx88_core *core = dev->core; int board = core->board; dprintk(1,"video_open: setting radio device\n"); cx_write(MO_GP3_IO, cx88_boards[board].radio.gpio3); cx_write(MO_GP0_IO, cx88_boards[board].radio.gpio0); cx_write(MO_GP1_IO, cx88_boards[board].radio.gpio1); cx_write(MO_GP2_IO, cx88_boards[board].radio.gpio2); - dev->core->tvaudio = WW_FM; + core->tvaudio = WW_FM; cx88_set_tvaudio(core); cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); - cx88_call_i2c_clients(dev->core,AUDC_SET_RADIO,NULL); + cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL); } return 0; @@ -857,6 +872,9 @@ static int video_release(struct inode *inode, struct file *file) videobuf_mmap_free(&fh->vbiq); file->private_data = NULL; kfree(fh); + + cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); + return 0; } @@ -870,9 +888,10 @@ video_mmap(struct file *file, struct vm_area_struct * vma) /* ------------------------------------------------------------------ */ -static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl) +/* static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl) */ +static int get_control(struct cx88_core *core, struct v4l2_control *ctl) { - struct cx88_core *core = dev->core; + /* struct cx88_core *core = dev->core; */ struct cx88_ctrl *c = NULL; u32 value; int i; @@ -898,9 +917,10 @@ static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl) return 0; } -static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) +/* static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) */ +static int set_control(struct cx88_core *core, struct v4l2_control *ctl) { - struct cx88_core *core = dev->core; + /* struct cx88_core *core = dev->core; */ struct cx88_ctrl *c = NULL; u32 v_sat_value; u32 value; @@ -913,9 +933,9 @@ static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) return -EINVAL; if (ctl->value < c->v.minimum) - return -ERANGE; + ctl->value = c->v.minimum; if (ctl->value > c->v.maximum) - return -ERANGE; + ctl->value = c->v.maximum; switch (ctl->id) { case V4L2_CID_AUDIO_BALANCE: value = (ctl->value < 0x40) ? (0x40 - ctl->value) : ctl->value; @@ -946,7 +966,8 @@ static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) return 0; } -static void init_controls(struct cx8800_dev *dev) +/* static void init_controls(struct cx8800_dev *dev) */ +static void init_controls(struct cx88_core *core) { static struct v4l2_control mute = { .id = V4L2_CID_AUDIO_MUTE, @@ -969,11 +990,11 @@ static void init_controls(struct cx8800_dev *dev) .value = 0x80, }; - set_control(dev,&mute); - set_control(dev,&volume); - set_control(dev,&hue); - set_control(dev,&contrast); - set_control(dev,&brightness); + set_control(core,&mute); + set_control(core,&volume); + set_control(core,&hue); + set_control(core,&contrast); + set_control(core,&brightness); } /* ------------------------------------------------------------------ */ @@ -1004,6 +1025,8 @@ static int cx8800_g_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, static int cx8800_try_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, struct v4l2_format *f) { + struct cx88_core *core = dev->core; + switch (f->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: { @@ -1016,8 +1039,8 @@ static int cx8800_try_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, return -EINVAL; field = f->fmt.pix.field; - maxw = norm_maxw(dev->core->tvnorm); - maxh = norm_maxh(dev->core->tvnorm); + maxw = norm_maxw(core->tvnorm); + maxh = norm_maxh(core->tvnorm); if (V4L2_FIELD_ANY == field) { field = (f->fmt.pix.height > maxh/2) @@ -1101,12 +1124,14 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (video_debug > 1) cx88_print_ioctl(core->name,cmd); switch (cmd) { + + /* --- capabilities ------------------------------------------ */ case VIDIOC_QUERYCAP: { struct v4l2_capability *cap = arg; memset(cap,0,sizeof(*cap)); - strcpy(cap->driver, "cx8800"); + strcpy(cap->driver, "cx8800"); strlcpy(cap->card, cx88_boards[core->board].name, sizeof(cap->card)); sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci)); @@ -1116,12 +1141,128 @@ static int video_do_ioctl(struct inode *inode, struct file *file, V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_VBI_CAPTURE | + V4L2_CAP_VIDEO_OVERLAY | 0; if (UNSET != core->tuner_type) cap->capabilities |= V4L2_CAP_TUNER; return 0; } + /* --- capture ioctls ---------------------------------------- */ + case VIDIOC_ENUM_FMT: + { + struct v4l2_fmtdesc *f = arg; + enum v4l2_buf_type type; + unsigned int index; + + index = f->index; + type = f->type; + switch (type) { + case V4L2_BUF_TYPE_VIDEO_CAPTURE: + if (index >= ARRAY_SIZE(formats)) + return -EINVAL; + memset(f,0,sizeof(*f)); + f->index = index; + f->type = type; + strlcpy(f->description,formats[index].name,sizeof(f->description)); + f->pixelformat = formats[index].fourcc; + break; + default: + return -EINVAL; + } + return 0; + } + case VIDIOC_G_FMT: + { + struct v4l2_format *f = arg; + return cx8800_g_fmt(dev,fh,f); + } + case VIDIOC_S_FMT: + { + struct v4l2_format *f = arg; + return cx8800_s_fmt(dev,fh,f); + } + case VIDIOC_TRY_FMT: + { + struct v4l2_format *f = arg; + return cx8800_try_fmt(dev,fh,f); + } + + /* --- streaming capture ------------------------------------- */ + case VIDIOCGMBUF: + { + struct video_mbuf *mbuf = arg; + struct videobuf_queue *q; + struct v4l2_requestbuffers req; + unsigned int i; + + q = get_queue(fh); + memset(&req,0,sizeof(req)); + req.type = q->type; + req.count = 8; + req.memory = V4L2_MEMORY_MMAP; + err = videobuf_reqbufs(q,&req); + if (err < 0) + return err; + memset(mbuf,0,sizeof(*mbuf)); + mbuf->frames = req.count; + mbuf->size = 0; + for (i = 0; i < mbuf->frames; i++) { + mbuf->offsets[i] = q->bufs[i]->boff; + mbuf->size += q->bufs[i]->bsize; + } + return 0; + } + case VIDIOC_REQBUFS: + return videobuf_reqbufs(get_queue(fh), arg); + + case VIDIOC_QUERYBUF: + return videobuf_querybuf(get_queue(fh), arg); + + case VIDIOC_QBUF: + return videobuf_qbuf(get_queue(fh), arg); + + case VIDIOC_DQBUF: + return videobuf_dqbuf(get_queue(fh), arg, + file->f_flags & O_NONBLOCK); + + case VIDIOC_STREAMON: + { + int res = get_ressource(fh); + + if (!res_get(dev,fh,res)) + return -EBUSY; + return videobuf_streamon(get_queue(fh)); + } + case VIDIOC_STREAMOFF: + { + int res = get_ressource(fh); + + err = videobuf_streamoff(get_queue(fh)); + if (err < 0) + return err; + res_free(dev,fh,res); + return 0; + } + + default: + return cx88_do_ioctl( inode, file, fh->radio, core, cmd, arg, video_do_ioctl ); + } + return 0; +} + +int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, + struct cx88_core *core, unsigned int cmd, void *arg, v4l2_kioctl driver_ioctl) +{ + int err; + + if (video_debug > 1) + cx88_print_ioctl(core->name,cmd); + printk( KERN_INFO "CORE IOCTL: 0x%x\n", cmd ); + cx88_print_ioctl(core->name,cmd); + dprintk( 1, "CORE IOCTL: 0x%x\n", cmd ); + + switch (cmd) { /* ---------- tv norms ---------- */ case VIDIOC_ENUMSTD: { @@ -1156,9 +1297,9 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (i == ARRAY_SIZE(tvnorms)) return -EINVAL; - down(&dev->lock); - cx88_set_tvnorm(dev->core,&tvnorms[i]); - up(&dev->lock); + down(&core->lock); + cx88_set_tvnorm(core,&tvnorms[i]); + up(&core->lock); return 0; } @@ -1199,7 +1340,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file, { unsigned int *i = arg; - *i = dev->core->input; + *i = core->input; return 0; } case VIDIOC_S_INPUT: @@ -1208,55 +1349,15 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (*i >= 4) return -EINVAL; - down(&dev->lock); + down(&core->lock); cx88_newstation(core); - video_mux(dev,*i); - up(&dev->lock); + video_mux(core,*i); + up(&core->lock); return 0; } - /* --- capture ioctls ---------------------------------------- */ - case VIDIOC_ENUM_FMT: - { - struct v4l2_fmtdesc *f = arg; - enum v4l2_buf_type type; - unsigned int index; - - index = f->index; - type = f->type; - switch (type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - if (index >= ARRAY_SIZE(formats)) - return -EINVAL; - memset(f,0,sizeof(*f)); - f->index = index; - f->type = type; - strlcpy(f->description,formats[index].name,sizeof(f->description)); - f->pixelformat = formats[index].fourcc; - break; - default: - return -EINVAL; - } - return 0; - } - case VIDIOC_G_FMT: - { - struct v4l2_format *f = arg; - return cx8800_g_fmt(dev,fh,f); - } - case VIDIOC_S_FMT: - { - struct v4l2_format *f = arg; - return cx8800_s_fmt(dev,fh,f); - } - case VIDIOC_TRY_FMT: - { - struct v4l2_format *f = arg; - return cx8800_try_fmt(dev,fh,f); - } - /* --- controls ---------------------------------------------- */ case VIDIOC_QUERYCTRL: { @@ -1277,9 +1378,9 @@ static int video_do_ioctl(struct inode *inode, struct file *file, return 0; } case VIDIOC_G_CTRL: - return get_control(dev,arg); + return get_control(core,arg); case VIDIOC_S_CTRL: - return set_control(dev,arg); + return set_control(core,arg); /* --- tuner ioctls ------------------------------------------ */ case VIDIOC_G_TUNER: @@ -1323,10 +1424,11 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (UNSET == core->tuner_type) return -EINVAL; - f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; - f->frequency = dev->freq; + /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */ + f->type = radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; + f->frequency = core->freq; - cx88_call_i2c_clients(dev->core,VIDIOC_G_FREQUENCY,f); + cx88_call_i2c_clients(core,VIDIOC_G_FREQUENCY,f); return 0; } @@ -1338,83 +1440,26 @@ static int video_do_ioctl(struct inode *inode, struct file *file, return -EINVAL; if (f->tuner != 0) return -EINVAL; - if (0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV) + if (0 == radio && f->type != V4L2_TUNER_ANALOG_TV) return -EINVAL; - if (1 == fh->radio && f->type != V4L2_TUNER_RADIO) + if (1 == radio && f->type != V4L2_TUNER_RADIO) return -EINVAL; - down(&dev->lock); - dev->freq = f->frequency; + down(&core->lock); + core->freq = f->frequency; cx88_newstation(core); - cx88_call_i2c_clients(dev->core,VIDIOC_S_FREQUENCY,f); + cx88_call_i2c_clients(core,VIDIOC_S_FREQUENCY,f); /* When changing channels it is required to reset TVAUDIO */ msleep (10); cx88_set_tvaudio(core); - up(&dev->lock); - return 0; - } - - /* --- streaming capture ------------------------------------- */ - case VIDIOCGMBUF: - { - struct video_mbuf *mbuf = arg; - struct videobuf_queue *q; - struct v4l2_requestbuffers req; - unsigned int i; - - q = get_queue(fh); - memset(&req,0,sizeof(req)); - req.type = q->type; - req.count = 8; - req.memory = V4L2_MEMORY_MMAP; - err = videobuf_reqbufs(q,&req); - if (err < 0) - return err; - memset(mbuf,0,sizeof(*mbuf)); - mbuf->frames = req.count; - mbuf->size = 0; - for (i = 0; i < mbuf->frames; i++) { - mbuf->offsets[i] = q->bufs[i]->boff; - mbuf->size += q->bufs[i]->bsize; - } - return 0; - } - case VIDIOC_REQBUFS: - return videobuf_reqbufs(get_queue(fh), arg); - - case VIDIOC_QUERYBUF: - return videobuf_querybuf(get_queue(fh), arg); - - case VIDIOC_QBUF: - return videobuf_qbuf(get_queue(fh), arg); - - case VIDIOC_DQBUF: - return videobuf_dqbuf(get_queue(fh), arg, - file->f_flags & O_NONBLOCK); - - case VIDIOC_STREAMON: - { - int res = get_ressource(fh); - - if (!res_get(dev,fh,res)) - return -EBUSY; - return videobuf_streamon(get_queue(fh)); - } - case VIDIOC_STREAMOFF: - { - int res = get_ressource(fh); - - err = videobuf_streamoff(get_queue(fh)); - if (err < 0) - return err; - res_free(dev,fh,res); + up(&core->lock); return 0; } default: return v4l_compat_translate_ioctl(inode,file,cmd,arg, - video_do_ioctl); + driver_ioctl); } return 0; } @@ -1461,7 +1506,7 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, memset(t,0,sizeof(*t)); strcpy(t->name, "Radio"); - cx88_call_i2c_clients(dev->core,VIDIOC_G_TUNER,t); + cx88_call_i2c_clients(core,VIDIOC_G_TUNER,t); return 0; } case VIDIOC_ENUMINPUT: @@ -1501,8 +1546,8 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, if (v->tuner) /* Only tuner 0 */ return -EINVAL; - cx88_call_i2c_clients(dev->core,VIDIOCSTUNER,v); - return 0; + cx88_call_i2c_clients(core,VIDIOCSTUNER,v); + return 0; } case VIDIOC_S_TUNER: { @@ -1511,7 +1556,7 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, if (0 != t->index) return -EINVAL; - cx88_call_i2c_clients(dev->core,VIDIOC_S_TUNER,t); + cx88_call_i2c_clients(core,VIDIOC_S_TUNER,t); return 0; } @@ -1569,7 +1614,7 @@ static void cx8800_vid_timeout(unsigned long data) struct cx88_buffer *buf; unsigned long flags; - cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH21]); + cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]); cx_clear(MO_VID_DMACNTRL, 0x11); cx_clear(VID_CAPTURE_CONTROL, 0x06); @@ -1614,14 +1659,14 @@ static void cx8800_vid_irq(struct cx8800_dev *dev) printk(KERN_WARNING "%s/0: video risc op code error\n",core->name); cx_clear(MO_VID_DMACNTRL, 0x11); cx_clear(VID_CAPTURE_CONTROL, 0x06); - cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH21]); + cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]); } /* risc1 y */ if (status & 0x01) { spin_lock(&dev->slock); count = cx_read(MO_VIDY_GPCNT); - cx88_wakeup(dev->core, &dev->vidq, count); + cx88_wakeup(core, &dev->vidq, count); spin_unlock(&dev->slock); } @@ -1629,7 +1674,7 @@ static void cx8800_vid_irq(struct cx8800_dev *dev) if (status & 0x08) { spin_lock(&dev->slock); count = cx_read(MO_VBI_GPCNT); - cx88_wakeup(dev->core, &dev->vbiq, count); + cx88_wakeup(core, &dev->vbiq, count); spin_unlock(&dev->slock); } @@ -1798,7 +1843,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, } /* initialize driver struct */ - init_MUTEX(&dev->lock); spin_lock_init(&dev->slock); core->tvnorm = tvnorms; @@ -1835,6 +1879,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, request_module("tuner"); if (core->tda9887_conf) request_module("tda9887"); + /* register v4l devices */ dev->video_dev = cx88_vdev_init(core,dev->pci, &cx8800_video_template,"video"); @@ -1878,11 +1923,11 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, pci_set_drvdata(pci_dev,dev); /* initial device configuration */ - down(&dev->lock); - init_controls(dev); - cx88_set_tvnorm(dev->core,tvnorms); - video_mux(dev,0); - up(&dev->lock); + down(&core->lock); + init_controls(core); + cx88_set_tvnorm(core,tvnorms); + video_mux(core,0); + up(&core->lock); /* start tvaudio thread */ if (core->tuner_type != TUNER_ABSENT) @@ -1902,14 +1947,15 @@ fail_free: static void __devexit cx8800_finidev(struct pci_dev *pci_dev) { struct cx8800_dev *dev = pci_get_drvdata(pci_dev); + struct cx88_core *core = dev->core; /* stop thread */ - if (dev->core->kthread) { - kthread_stop(dev->core->kthread); - dev->core->kthread = NULL; + if (core->kthread) { + kthread_stop(core->kthread); + core->kthread = NULL; } - cx88_shutdown(dev->core); /* FIXME */ + cx88_shutdown(core); /* FIXME */ pci_disable_device(pci_dev); /* unregister stuff */ @@ -1921,7 +1967,7 @@ static void __devexit cx8800_finidev(struct pci_dev *pci_dev) /* free memory */ btcx_riscmem_free(dev->pci,&dev->vidq.stopper); list_del(&dev->devlist); - cx88_core_put(dev->core,dev->pci); + cx88_core_put(core,dev->pci); kfree(dev); } @@ -1945,7 +1991,7 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state) spin_unlock(&dev->slock); /* FIXME -- shutdown device */ - cx88_shutdown(dev->core); + cx88_shutdown(core); pci_save_state(pci_dev); if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { @@ -1968,7 +2014,7 @@ static int cx8800_resume(struct pci_dev *pci_dev) pci_restore_state(pci_dev); /* FIXME: re-initialize hardware */ - cx88_reset(dev->core); + cx88_reset(core); /* restart video+vbi capture */ spin_lock(&dev->slock); @@ -2030,6 +2076,8 @@ static void cx8800_fini(void) module_init(cx8800_init); module_exit(cx8800_fini); +EXPORT_SYMBOL(cx88_do_ioctl); + /* ----------------------------------------------------------- */ /* * Local variables: diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index da65dc9..13b8fb7 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h @@ -1,5 +1,4 @@ /* - * $Id: cx88.h,v 1.70 2005/07/24 17:44:09 mkrufky Exp $ * * v4l2 device driver for cx2388x based TV cards * @@ -48,6 +47,9 @@ #define CX88_MAXBOARDS 8 +/* Max number of inputs by card */ +#define MAX_CX88_INPUT 8 + /* ----------------------------------------------------------- */ /* defines and enums */ @@ -199,7 +201,7 @@ struct cx88_board { unsigned char tuner_addr; unsigned char radio_addr; int tda9887_conf; - struct cx88_input input[8]; + struct cx88_input input[MAX_CX88_INPUT]; struct cx88_input radio; int blackbird:1; int dvb:1; @@ -288,6 +290,11 @@ struct cx88_core { /* IR remote control state */ struct cx88_IR *ir; + + struct semaphore lock; + + /* various v4l controls */ + u32 freq; }; struct cx8800_dev; @@ -323,8 +330,7 @@ struct cx8800_suspend_state { struct cx8800_dev { struct cx88_core *core; struct list_head devlist; - struct semaphore lock; - spinlock_t slock; + spinlock_t slock; /* various device info */ unsigned int resources; @@ -342,7 +348,6 @@ struct cx8800_dev { struct cx88_dmaqueue vbiq; /* various v4l controls */ - u32 freq; /* other global state info */ struct cx8800_suspend_state state; @@ -350,14 +355,8 @@ struct cx8800_dev { /* ----------------------------------------------------------- */ /* function 1: audio/alsa stuff */ +/* =============> moved to cx88-alsa.c <====================== */ -struct cx8801_dev { - struct cx88_core *core; - - /* pci i/o */ - struct pci_dev *pci; - unsigned char pci_rev,pci_lat; -}; /* ----------------------------------------------------------- */ /* function 2: mpeg stuff */ @@ -373,8 +372,7 @@ struct cx8802_suspend_state { struct cx8802_dev { struct cx88_core *core; - struct semaphore lock; - spinlock_t slock; + spinlock_t slock; /* pci i/o */ struct pci_dev *pci; @@ -553,8 +551,21 @@ void cx8802_fini_common(struct cx8802_dev *dev); int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state); int cx8802_resume_common(struct pci_dev *pci_dev); +/* ----------------------------------------------------------- */ +/* cx88-video.c */ +extern int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, + struct cx88_core *core, unsigned int cmd, + void *arg, v4l2_kioctl driver_ioctl); + +/* ----------------------------------------------------------- */ +/* cx88-blackbird.c */ +extern int (*cx88_ioctl_hook)(struct inode *inode, struct file *file, + unsigned int cmd, void *arg); +extern unsigned int (*cx88_ioctl_translator)(unsigned int cmd); + /* * Local variables: * c-basic-offset: 8 * End: + * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off */ -- cgit v0.10.2 From 2f1807102a3a5c9b9782b6e8d271fc8ccef91f0a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:46 -0700 Subject: [PATCH] v4l: SAA7134 updates and board additions - Remove $Id CVS logs for V4L files - linux/version.h replaced by linux/utsname.h - Add new Digimatrix card and LG TAPC Mini tuner for it Signed-off-by: Hermann Pitton Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134 index 1b5a3a9..9c8b1ca 100644 --- a/Documentation/video4linux/CARDLIST.saa7134 +++ b/Documentation/video4linux/CARDLIST.saa7134 @@ -62,3 +62,4 @@ 61 -> Philips TOUGH DVB-T reference design [1131:2004] 62 -> Compro VideoMate TV Gold+II 63 -> Kworld Xpert TV PVR7134 + 64 -> FlyTV mini Asus Digimatrix [1043:0210,1043:0210] diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 88b71a2..c277b3b 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-cards.c,v 1.80 2005/07/07 01:49:30 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * card-specific stuff. @@ -2001,6 +2000,41 @@ struct saa7134_board saa7134_boards[] = { .gpio = 0x000, }, }, + [SAA7134_BOARD_FLYTV_DIGIMATRIX] = { + .name = "FlyTV mini Asus Digimatrix", + .audio_clock = 0x00200000, + .tuner_type = TUNER_LG_NTSC_TALN_MINI, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, + .inputs = {{ + .name = name_tv, + .vmux = 1, + .amux = TV, + .tv = 1, + },{ + .name = name_tv_mono, + .vmux = 1, + .amux = LINE2, + .tv = 1, + },{ + .name = name_comp1, + .vmux = 0, + .amux = LINE2, + },{ + .name = name_comp2, + .vmux = 3, + .amux = LINE2, + },{ + .name = name_svideo, + .vmux = 8, + .amux = LINE2, + }}, + .radio = { + .name = name_radio, /* radio unconfirmed */ + .amux = LINE2, + }, + }, }; @@ -2346,6 +2380,18 @@ struct pci_device_id saa7134_pci_tbl[] = { .subvendor = 0x4e42, .subdevice = 0x0502, .driver_data = SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS, + },{ + .vendor = PCI_VENDOR_ID_PHILIPS, + .device = PCI_DEVICE_ID_PHILIPS_SAA7133, + .subvendor = 0x1043, + .subdevice = 0x0210, /* mini pci NTSC version */ + .driver_data = SAA7134_BOARD_FLYTV_DIGIMATRIX, + },{ + .vendor = PCI_VENDOR_ID_PHILIPS, + .device = PCI_DEVICE_ID_PHILIPS_SAA7134, + .subvendor = 0x1043, + .subdevice = 0x0210, /* mini pci PAL/SECAM version */ + .driver_data = SAA7134_BOARD_FLYTV_DIGIMATRIX, },{ /* --- boards without eeprom + subsystem ID --- */ diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 1dbe617..e5e36f3 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-core.c,v 1.39 2005/07/05 17:37:35 nsh Exp $ * * device driver for philips saa7134 based TV cards * driver core diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index 8be6a90..fa29dd5 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-dvb.c,v 1.23 2005/07/24 22:12:47 mkrufky Exp $ * * (c) 2004 Gerd Knorr [SuSE Labs] * diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index c85348d0..77b627e 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-empress.c,v 1.11 2005/05/22 19:23:39 nsh Exp $ * * (c) 2004 Gerd Knorr [SuSE Labs] * diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index eae6b52..711aa8e 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-i2c.c,v 1.22 2005/07/22 04:09:41 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * i2c interface support diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 2137401..0e97b1e 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-input.c,v 1.21 2005/06/22 23:37:34 nsh Exp $ * * handle saa7134 IR remotes via linux kernel input layer. * diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c index b5bede9..c20630c 100644 --- a/drivers/media/video/saa7134/saa7134-oss.c +++ b/drivers/media/video/saa7134/saa7134-oss.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-oss.c,v 1.17 2005/06/28 23:41:47 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * oss dsp interface diff --git a/drivers/media/video/saa7134/saa7134-reg.h b/drivers/media/video/saa7134/saa7134-reg.h index 87734f2..ae0c7a1 100644 --- a/drivers/media/video/saa7134/saa7134-reg.h +++ b/drivers/media/video/saa7134/saa7134-reg.h @@ -1,5 +1,4 @@ /* - * $Id: saa7134-reg.h,v 1.2 2004/09/15 16:15:24 kraxel Exp $ * * philips saa7134 registers */ diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c index 4dd9f1b..4638856 100644 --- a/drivers/media/video/saa7134/saa7134-ts.c +++ b/drivers/media/video/saa7134/saa7134-ts.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-ts.c,v 1.15 2005/06/14 22:48:18 hhackmann Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c index eeafa5a..badf2f9 100644 --- a/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-tvaudio.c,v 1.30 2005/06/28 23:41:47 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * tv audio decoder (fm stereo, nicam, ...) diff --git a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c index 29e51ca..f4aee0a 100644 --- a/drivers/media/video/saa7134/saa7134-vbi.c +++ b/drivers/media/video/saa7134/saa7134-vbi.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-vbi.c,v 1.7 2005/05/24 23:13:06 nsh Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index a4c2f75..35e5e85 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-video.c,v 1.36 2005/06/28 23:41:47 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface @@ -1368,29 +1367,7 @@ static int video_release(struct inode *inode, struct file *file) saa_andorb(SAA7134_OFMT_DATA_A, 0x1f, 0); saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0); - if (dev->tuner_type == TUNER_PHILIPS_TDA8290) { - u8 data[2]; - int ret; - struct i2c_msg msg = {.addr=I2C_ADDR_TDA8290, .flags=0, .buf=data, .len = 2}; - data[0] = 0x21; - data[1] = 0xc0; - ret = i2c_transfer(&dev->i2c_adap, &msg, 1); - if (ret != 1) - printk(KERN_ERR "TDA8290 access failure\n"); - msg.addr = I2C_ADDR_TDA8275; - data[0] = 0x30; - data[1] = 0xd0; - ret = i2c_transfer(&dev->i2c_adap, &msg, 1); - if (ret != 1) - printk(KERN_ERR "TDA8275 access failure\n"); - msg.addr = I2C_ADDR_TDA8290; - data[0] = 0x21; - data[1] = 0x80; - i2c_transfer(&dev->i2c_adap, &msg, 1); - data[0] = 0x00; - data[1] = 0x02; - i2c_transfer(&dev->i2c_adap, &msg, 1); - } + saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); /* free stuff */ videobuf_mmap_free(&fh->cap); diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 2af0cb2..7a7fa42 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h @@ -1,5 +1,4 @@ /* - * $Id: saa7134.h,v 1.49 2005/07/13 17:25:25 mchehab Exp $ * * v4l2 device driver for philips saa7134 based TV cards * @@ -20,7 +19,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include +#include #define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,14) #include @@ -185,6 +184,7 @@ struct saa7134_format { #define SAA7134_BOARD_PHILIPS_TOUGH 61 #define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII 62 #define SAA7134_BOARD_KWORLD_XPERT 63 +#define SAA7134_BOARD_FLYTV_DIGIMATRIX 64 #define SAA7134_MAXBOARDS 8 #define SAA7134_INPUT_MAX 8 -- cgit v0.10.2 From c0e9eae60e8f1a18e2e6502b3e738dd2886d18ff Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:47 -0700 Subject: [PATCH] v4l: change the prefix of msp34xx and error while reading chip version - Changes the prefix to 'msp34xx' instead of 'msp3400'. - Changes the message 'error while reading chip version' to a debug printk at msp3400.c Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index ca02f6f..01d567c 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c @@ -1452,7 +1452,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) client_template.addr = addr; if (-1 == msp3400c_reset(&client_template)) { - dprintk("msp3400: no chip found\n"); + dprintk("msp34xx: no chip found\n"); return -1; } @@ -1478,7 +1478,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) if (-1 == msp3400c_reset(c)) { kfree(msp); kfree(c); - dprintk("msp3400: no chip found\n"); + dprintk("msp34xx: no chip found\n"); return -1; } @@ -1488,7 +1488,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) if ((-1 == msp->rev1) || (0 == msp->rev1 && 0 == msp->rev2)) { kfree(msp); kfree(c); - printk("msp3400: error while reading chip version\n"); + dprintk("msp34xx: error while reading chip version\n"); return -1; } -- cgit v0.10.2 From 272435dc44f7254c7174d69b41eb430a50583d1a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:47 -0700 Subject: [PATCH] v4l: syncs tveeprom tuners list with the list from ivtv - Syncs tveeprom tuners list with the list from ivtv. - Fixes the incorrect reporting of the radio presence. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index d0a00d3..3674014 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -152,7 +152,7 @@ hauppauge_tuner[] = { TUNER_MICROTUNE_4049FM5, "Microtune 4049 FM5"}, { TUNER_ABSENT, "LG TPI8NSR11F"}, { TUNER_ABSENT, "Microtune 4049 FM5 Alt I2C"}, - { TUNER_ABSENT, "Philips FQ1216ME MK3"}, + { TUNER_PHILIPS_FM1216ME_MK3, "Philips FQ1216ME MK3"}, { TUNER_ABSENT, "Philips FI1236 MK3"}, { TUNER_PHILIPS_FM1216ME_MK3, "Philips FM1216 ME MK3"}, { TUNER_PHILIPS_FM1236_MK3, "Philips FM1236 MK3"}, @@ -167,7 +167,7 @@ hauppauge_tuner[] = { TUNER_ABSENT, "Temic 4106FH5"}, { TUNER_ABSENT, "Philips FQ1216LMP MK3"}, { TUNER_LG_NTSC_TAPE, "LG TAPE H001F MK3"}, - { TUNER_ABSENT, "LG TAPE H701F MK3"}, + { TUNER_LG_NTSC_TAPE, "LG TAPE H701F MK3"}, /* 70-79 */ { TUNER_ABSENT, "LG TALN H200T"}, { TUNER_ABSENT, "LG TALN H250T"}, @@ -199,6 +199,13 @@ hauppauge_tuner[] = { TUNER_ABSENT, "Philips FQ1236 MK5"}, { TUNER_ABSENT, "Unspecified"}, { TUNER_LG_PAL_TAPE, "LG PAL (TAPE Series)"}, + { TUNER_ABSENT, "Unspecified"}, + { TUNER_TCL_2002N, "TCL 2002N 5H"}, + /* 100-103 */ + { TUNER_ABSENT, "Unspecified"}, + { TUNER_ABSENT, "Unspecified"}, + { TUNER_ABSENT, "Unspecified"}, + { TUNER_PHILIPS_FM1236_MK3, "TCL MFNM05 4"}, }; static char *sndtype[] = { @@ -484,6 +491,7 @@ tveeprom_command(struct i2c_client *client, eeprom_props[1] = eeprom.tuner_formats; eeprom_props[2] = eeprom.model; eeprom_props[3] = eeprom.revision; + eeprom_props[4] = eeprom.has_radio; break; default: return -EINVAL; -- cgit v0.10.2 From 5adc1c306b1ce5b297bd8ee010a62f39cd32b9e4 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:48 -0700 Subject: [PATCH] v4l: correct LG NTSC TALN mini tuner takeover - correct LG NTSC TALN mini tuner takeover as far we can empirically determine for now. Signed-off-by: Hermann Pitton Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 2603440..6f153ca 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -250,7 +250,7 @@ static struct tunertype tuners[] = { { "Ymec TVF66T5-B/DFF", Philips, PAL, 16*160.25,16*464.25,0x01,0x02,0x08,0x8e,623}, { "LG NTSC (TALN mini series)", LGINNOTEK, NTSC, - 16*150.00,16*425.00,0x01,0x02,0x08,0x8e,732 }, + 16*137.25,16*373.25,0x01,0x02,0x08,0x8e,732 }, }; unsigned const int tuner_count = ARRAY_SIZE(tuners); -- cgit v0.10.2 From 260784dcca44b5a526cece1f275cb81ccd186a3e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:49 -0700 Subject: [PATCH] v4l: add saa713x card #65 Kworld V-Stream Studio TV Terminator - Add saa713x card #65 Kworld V-Stream Studio TV Terminator Signed-off-by: James R Webb Signed-off-by: Peter Missel Signed-off-by: Nickolay V. Shmyrev Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134 index 9c8b1ca..0351282 100644 --- a/Documentation/video4linux/CARDLIST.saa7134 +++ b/Documentation/video4linux/CARDLIST.saa7134 @@ -63,3 +63,4 @@ 62 -> Compro VideoMate TV Gold+II 63 -> Kworld Xpert TV PVR7134 64 -> FlyTV mini Asus Digimatrix [1043:0210,1043:0210] + 65 -> V-Stream Studio TV Terminator diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index c277b3b..ea0237a 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -2035,6 +2035,39 @@ struct saa7134_board saa7134_boards[] = { .amux = LINE2, }, }, + [SAA7134_BOARD_KWORLD_TERMINATOR] = { + /* Kworld V-Stream Studio TV Terminator */ + /* "James Webb */ + .name = "V-Stream Studio TV Terminator", + .audio_clock = 0x00187de7, + .tuner_type = TUNER_PHILIPS_TDA8290, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, + .gpiomask = 1 << 21, + .inputs = {{ + .name = name_tv, + .vmux = 1, + .amux = TV, + .gpio = 0x0000000, + .tv = 1, + },{ + .name = name_comp1, /* Composite input */ + .vmux = 3, + .amux = LINE2, + .gpio = 0x0000000, + },{ + .name = name_svideo, /* S-Video input */ + .vmux = 8, + .amux = LINE2, + .gpio = 0x0000000, + }}, + .radio = { + .name = name_radio, + .amux = TV, + .gpio = 0x0200000, + }, + }, }; diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 7a7fa42..26ec944 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h @@ -185,6 +185,7 @@ struct saa7134_format { #define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII 62 #define SAA7134_BOARD_KWORLD_XPERT 63 #define SAA7134_BOARD_FLYTV_DIGIMATRIX 64 +#define SAA7134_BOARD_KWORLD_TERMINATOR 65 #define SAA7134_MAXBOARDS 8 #define SAA7134_INPUT_MAX 8 -- cgit v0.10.2 From 4279f02478c2c4f106ec9efb80ca152e8d406844 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:51 -0700 Subject: [PATCH] v4l: add saa713x card #66: Yuan TUN-900 (saa7135) - Add saa713x card #66: Yuan TUN-900 (saa7135) Signed-off-by: De Greef Sebastien Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134 index 0351282..dc57225 100644 --- a/Documentation/video4linux/CARDLIST.saa7134 +++ b/Documentation/video4linux/CARDLIST.saa7134 @@ -64,3 +64,4 @@ 63 -> Kworld Xpert TV PVR7134 64 -> FlyTV mini Asus Digimatrix [1043:0210,1043:0210] 65 -> V-Stream Studio TV Terminator + 66 -> Yuan TUN-900 (saa7135) diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index ea0237a..f991f23 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -2068,6 +2068,47 @@ struct saa7134_board saa7134_boards[] = { .gpio = 0x0200000, }, }, + [SAA7134_BOARD_YUAN_TUN900] = { + /* FIXME: + * S-Video and composite sources untested. + * Radio not working. + * Remote control not yet implemented. + * From : codemaster@webgeeks.be */ + .name = "Yuan TUN-900 (saa7135)", + .audio_clock = 0x00187de7, + .tuner_type = TUNER_PHILIPS_TDA8290, + .radio_type = UNSET, + .tuner_addr= ADDR_UNSET, + .radio_addr= ADDR_UNSET, + .gpiomask = 0x00010003, + .inputs = {{ + .name = name_tv, + .vmux = 1, + .amux = TV, + .tv = 1, + .gpio = 0x01, + },{ + .name = name_comp1, + .vmux = 0, + .amux = LINE2, + .gpio = 0x02, + },{ + .name = name_svideo, + .vmux = 6, + .amux = LINE2, + .gpio = 0x02, + }}, + .radio = { + .name = name_radio, + .amux = LINE1, + .gpio = 0x00010003, + }, + .mute = { + .name = name_mute, + .amux = TV, + .gpio = 0x01, + }, + }, }; diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 26ec944..1d70f34 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h @@ -186,6 +186,7 @@ struct saa7134_format { #define SAA7134_BOARD_KWORLD_XPERT 63 #define SAA7134_BOARD_FLYTV_DIGIMATRIX 64 #define SAA7134_BOARD_KWORLD_TERMINATOR 65 +#define SAA7134_BOARD_YUAN_TUN900 66 #define SAA7134_MAXBOARDS 8 #define SAA7134_INPUT_MAX 8 -- cgit v0.10.2 From 10c35cf8fd89e166d13bc93175f2b05d9cb85e07 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:52 -0700 Subject: [PATCH] v4l: cx88-dvb incorrect reporting fixed and remove bad PCI ID for Sabrent - cx88-dvb has been incorrectly reporting the card name instead of frontend name - Removes a bad PCI subsystem ID for saa713x Sabrent card - Renames DVICO --> DViCO for bttv. - #include no longer needed. Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/video4linux/CARDLIST.bttv b/Documentation/video4linux/CARDLIST.bttv index 7979c06..ec785f9 100644 --- a/Documentation/video4linux/CARDLIST.bttv +++ b/Documentation/video4linux/CARDLIST.bttv @@ -126,12 +126,12 @@ card=124 - AverMedia AverTV DVB-T 761 card=125 - MATRIX Vision Sigma-SQ card=126 - MATRIX Vision Sigma-SLC card=127 - APAC Viewcomp 878(AMAX) -card=128 - DVICO FusionHDTV DVB-T Lite +card=128 - DViCO FusionHDTV DVB-T Lite card=129 - V-Gear MyVCD card=130 - Super TV Tuner card=131 - Tibet Systems 'Progress DVR' CS16 card=132 - Kodicom 4400R (master) card=133 - Kodicom 4400R (slave) card=134 - Adlink RTV24 -card=135 - DVICO FusionHDTV 5 Lite +card=135 - DViCO FusionHDTV 5 Lite card=136 - Acorp Y878F diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index 3cb398b..64785d3 100644 --- a/drivers/media/video/bttv-cards.c +++ b/drivers/media/video/bttv-cards.c @@ -2258,7 +2258,7 @@ struct tvcard bttv_tvcards[] = { /* ---- card 0x80 ---------------------------------- */ /* Chris Pascoe */ - .name = "DVICO FusionHDTV DVB-T Lite", + .name = "DViCO FusionHDTV DVB-T Lite", .tuner = -1, .no_msp34xx = 1, .no_tda9875 = 1, @@ -2389,7 +2389,7 @@ struct tvcard bttv_tvcards[] = { { /* ---- card 0x87---------------------------------- */ /* Michael Krufky */ - .name = "DVICO FusionHDTV 5 Lite", + .name = "DViCO FusionHDTV 5 Lite", .tuner = 0, .tuner_type = TUNER_LG_TDVS_H062F, .tuner_addr = ADDR_UNSET, diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index cc71caf..c9106b1 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "cx88.h" @@ -403,11 +402,6 @@ static int dvb_register(struct cx8802_dev *dev) dev->dvb.frontend->ops->info.frequency_max = dev->core->pll_desc->max; } - /* Copy the board name into the DVB structure */ - strlcpy(dev->dvb.frontend->ops->info.name, - cx88_boards[dev->core->board].name, - sizeof(dev->dvb.frontend->ops->info.name)); - /* register everything */ return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev); } diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index f991f23..07d3ee0 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -2380,12 +2380,6 @@ struct pci_device_id saa7134_pci_tbl[] = { .driver_data = SAA7134_BOARD_VIDEOMATE_TV_PVR, },{ .vendor = PCI_VENDOR_ID_PHILIPS, - .device = PCI_DEVICE_ID_PHILIPS_SAA7130, - .subvendor = 0x1131, - .subdevice = 0, - .driver_data = SAA7134_BOARD_SABRENT_SBTTVFM, - },{ - .vendor = PCI_VENDOR_ID_PHILIPS, .device = PCI_DEVICE_ID_PHILIPS_SAA7134, .subvendor = 0x1461, /* Avermedia Technologies Inc */ .subdevice = 0x9715, -- cgit v0.10.2 From 1c94aeecd3fd2aed66d9a1135f5329df622e6137 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:52 -0700 Subject: [PATCH] v4l: normalize whitespace and comments in tuner lists - normalize whitespace and comments in tuner lists Signed-off-by: Philip Rowlands Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 6f153ca..5e99b24 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -101,6 +101,7 @@ struct tunertype * "no float in kernel" rule. */ static struct tunertype tuners[] = { + /* 0-9 */ { "Temic PAL (4002 FH5)", TEMIC, PAL, 16*140.25,16*463.25,0x02,0x04,0x01,0x8e,623}, { "Philips PAL_I (FI1246 and compatibles)", Philips, PAL_I, @@ -109,7 +110,6 @@ static struct tunertype tuners[] = { 16*157.25,16*451.25,0xA0,0x90,0x30,0x8e,732}, { "Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)", Philips, SECAM, 16*168.25,16*447.25,0xA7,0x97,0x37,0x8e,623}, - { "NoTuner", NoTuner, NOTUNER, 0,0,0x00,0x00,0x00,0x00,0x00}, { "Philips PAL_BG (FI1216 and compatibles)", Philips, PAL, @@ -118,34 +118,34 @@ static struct tunertype tuners[] = { 16*157.25,16*463.25,0x02,0x04,0x01,0x8e,732}, { "Temic PAL_I (4062 FY5)", TEMIC, PAL_I, 16*170.00,16*450.00,0x02,0x04,0x01,0x8e,623}, - { "Temic NTSC (4036 FY5)", TEMIC, NTSC, 16*157.25,16*463.25,0xa0,0x90,0x30,0x8e,732}, { "Alps HSBH1", TEMIC, NTSC, 16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732}, - { "Alps TSBE1",TEMIC,PAL, + + /* 10-19 */ + { "Alps TSBE1", TEMIC, PAL, 16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732}, { "Alps TSBB5", Alps, PAL_I, /* tested (UK UHF) with Modulartech MM205 */ 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,632}, - { "Alps TSBE5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */ 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,622}, { "Alps TSBC5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */ 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,608}, { "Temic PAL_BG (4006FH5)", TEMIC, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, - { "Alps TSCH6",Alps,NTSC, + { "Alps TSCH6", Alps, NTSC, 16*137.25,16*385.25,0x14,0x12,0x11,0x8e,732}, - - { "Temic PAL_DK (4016 FY5)",TEMIC,PAL, + { "Temic PAL_DK (4016 FY5)", TEMIC, PAL, 16*168.25,16*456.25,0xa0,0x90,0x30,0x8e,623}, - { "Philips NTSC_M (MK2)",Philips,NTSC, + { "Philips NTSC_M (MK2)", Philips, NTSC, 16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732}, { "Temic PAL_I (4066 FY5)", TEMIC, PAL_I, 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623}, { "Temic PAL* auto (4006 FN5)", TEMIC, PAL, 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623}, + /* 20-29 */ { "Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5)", TEMIC, PAL, 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623}, { "Temic NTSC (4039 FR5)", TEMIC, NTSC, @@ -154,7 +154,6 @@ static struct tunertype tuners[] = { 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623}, { "Philips PAL_DK (FI1256 and compatibles)", Philips, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, - { "Philips PAL/SECAM multi (FQ1216ME)", Philips, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, { "LG PAL_I+FM (TAPC-I001D)", LGINNOTEK, PAL_I, @@ -163,25 +162,24 @@ static struct tunertype tuners[] = { 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, { "LG NTSC+FM (TPI8NSR01F)", LGINNOTEK, NTSC, 16*210.00,16*497.00,0xa0,0x90,0x30,0x8e,732}, - { "LG PAL_BG+FM (TPI8PSB01D)", LGINNOTEK, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, { "LG PAL_BG (TPI8PSB11D)", LGINNOTEK, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, + + /* 30-39 */ { "Temic PAL* auto + FM (4009 FN5)", TEMIC, PAL, 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623}, { "SHARP NTSC_JP (2U5JF5540)", SHARP, NTSC, /* 940=16*58.75 NTSC@Japan */ 16*137.25,16*317.25,0x01,0x02,0x08,0x8e,940 }, - - { "Samsung PAL TCPM9091PD27", Samsung, PAL, /* from sourceforge v3tv */ + { "Samsung PAL TCPM9091PD27", Samsung, PAL, /* from sourceforge v3tv */ 16*169,16*464,0xA0,0x90,0x30,0x8e,623}, - { "MT20xx universal", Microtune,PAL|NTSC, + { "MT20xx universal", Microtune, PAL|NTSC, /* see mt20xx.c for details */ }, { "Temic PAL_BG (4106 FH5)", TEMIC, PAL, 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623}, { "Temic PAL_DK/SECAM_L (4012 FY5)", TEMIC, PAL, 16*140.25, 16*463.25, 0x02,0x04,0x01,0x8e,623}, - { "Temic NTSC (4136 FY5)", TEMIC, NTSC, 16*158.00, 16*453.00, 0xa0,0x90,0x30,0x8e,732}, { "LG PAL (newer TAPC series)", LGINNOTEK, PAL, @@ -191,42 +189,41 @@ static struct tunertype tuners[] = { { "LG NTSC (newer TAPC series)", LGINNOTEK, NTSC, 16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,732}, + /* 40-49 */ { "HITACHI V7-J180AT", HITACHI, NTSC, 16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,940 }, { "Philips PAL_MK (FI1216 MK)", Philips, PAL, 16*140.25,16*463.25,0x01,0xc2,0xcf,0x8e,623}, - { "Philips 1236D ATSC/NTSC daul in",Philips,ATSC, + { "Philips 1236D ATSC/NTSC daul in", Philips, ATSC, 16*157.25,16*454.00,0xa0,0x90,0x30,0x8e,732}, { "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", Philips, NTSC, 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732}, - { "Philips 4 in 1 (ATI TV Wonder Pro/Conexant)", Philips, NTSC, 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732}, - { "Microtune 4049 FM5",Microtune,PAL, + { "Microtune 4049 FM5", Microtune, PAL, 16*141.00,16*464.00,0xa0,0x90,0x30,0x8e,623}, { "Panasonic VP27s/ENGE4324D", Panasonic, NTSC, 16*160.00,16*454.00,0x01,0x02,0x08,0xce,940}, { "LG NTSC (TAPE series)", LGINNOTEK, NTSC, 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 }, - { "Tenna TNF 8831 BGFF)", Philips, PAL, 16*161.25,16*463.25,0xa0,0x90,0x30,0x8e,623}, { "Microtune 4042 FI5 ATSC/NTSC dual in", Microtune, NTSC, 16*162.00,16*457.00,0xa2,0x94,0x31,0x8e,732}, + + /* 50-59 */ { "TCL 2002N", TCL, NTSC, 16*172.00,16*448.00,0x01,0x02,0x08,0x8e,732}, { "Philips PAL/SECAM_D (FM 1256 I-H3)", Philips, PAL, 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,623 }, - { "Thomson DDT 7610 (ATSC/NTSC)", THOMSON, ATSC, 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, { "Philips FQ1286", Philips, NTSC, - 16*160.00,16*454.00,0x41,0x42,0x04,0x8e,940}, // UHF band untested - { "tda8290+75", Philips,PAL|NTSC, + 16*160.00,16*454.00,0x41,0x42,0x04,0x8e,940}, /* UHF band untested */ + { "tda8290+75", Philips, PAL|NTSC, /* see tda8290.c for details */ }, { "LG PAL (TAPE series)", LGINNOTEK, PAL, 16*170.00, 16*450.00, 0x01,0x02,0x08,0xce,623}, - { "Philips PAL/SECAM multi (FQ1216AME MK4)", Philips, PAL, 16*160.00,16*442.00,0x01,0x02,0x04,0xce,623 }, { "Philips FQ1236A MK4", Philips, NTSC, @@ -236,6 +233,7 @@ static struct tunertype tuners[] = { { "Ymec TVision TVF-5533MF", Philips, NTSC, 16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732}, + /* 60-66 */ { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC, 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, { "Tena TNF9533-D/IF/TNF9533-B/DF", Philips, PAL, @@ -244,7 +242,6 @@ static struct tunertype tuners[] = { /* see tea5767.c for details */}, { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL, 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 }, - { "LG TDVS-H062F/TUA6034", LGINNOTEK, NTSC, 16*160.00,16*455.00,0x01,0x02,0x04,0x8e,732}, { "Ymec TVF66T5-B/DFF", Philips, PAL, diff --git a/include/media/tuner.h b/include/media/tuner.h index 252673b..5b01ee6 100644 --- a/include/media/tuner.h +++ b/include/media/tuner.h @@ -26,90 +26,90 @@ #define ADDR_UNSET (255) -#define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */ -#define TUNER_PHILIPS_PAL_I 1 -#define TUNER_PHILIPS_NTSC 2 -#define TUNER_PHILIPS_SECAM 3 /* you must actively select B/G, L, L` */ - -#define TUNER_ABSENT 4 -#define TUNER_PHILIPS_PAL 5 -#define TUNER_TEMIC_NTSC 6 /* 4032 FY5 (3X 7004, 9498, 9789) */ -#define TUNER_TEMIC_PAL_I 7 /* 4062 FY5 (3X 8501, 9957) */ - -#define TUNER_TEMIC_4036FY5_NTSC 8 /* 4036 FY5 (3X 1223, 1981, 7686) */ -#define TUNER_ALPS_TSBH1_NTSC 9 -#define TUNER_ALPS_TSBE1_PAL 10 -#define TUNER_ALPS_TSBB5_PAL_I 11 - -#define TUNER_ALPS_TSBE5_PAL 12 -#define TUNER_ALPS_TSBC5_PAL 13 -#define TUNER_TEMIC_4006FH5_PAL 14 /* 4006 FH5 (3X 9500, 9501, 7291) */ -#define TUNER_ALPS_TSHC6_NTSC 15 - -#define TUNER_TEMIC_PAL_DK 16 /* 4016 FY5 (3X 1392, 1393) */ -#define TUNER_PHILIPS_NTSC_M 17 -#define TUNER_TEMIC_4066FY5_PAL_I 18 /* 4066 FY5 (3X 7032, 7035) */ -#define TUNER_TEMIC_4006FN5_MULTI_PAL 19 /* B/G, I and D/K autodetected (3X 7595, 7606, 7657)*/ - -#define TUNER_TEMIC_4009FR5_PAL 20 /* incl. FM radio (3X 7607, 7488, 7711)*/ -#define TUNER_TEMIC_4039FR5_NTSC 21 /* incl. FM radio (3X 7246, 7578, 7732)*/ -#define TUNER_TEMIC_4046FM5 22 /* you must actively select B/G, D/K, I, L, L` ! (3X 7804, 7806, 8103, 8104)*/ +#define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */ +#define TUNER_PHILIPS_PAL_I 1 +#define TUNER_PHILIPS_NTSC 2 +#define TUNER_PHILIPS_SECAM 3 /* you must actively select B/G, L, L` */ + +#define TUNER_ABSENT 4 +#define TUNER_PHILIPS_PAL 5 +#define TUNER_TEMIC_NTSC 6 /* 4032 FY5 (3X 7004, 9498, 9789) */ +#define TUNER_TEMIC_PAL_I 7 /* 4062 FY5 (3X 8501, 9957) */ + +#define TUNER_TEMIC_4036FY5_NTSC 8 /* 4036 FY5 (3X 1223, 1981, 7686) */ +#define TUNER_ALPS_TSBH1_NTSC 9 +#define TUNER_ALPS_TSBE1_PAL 10 +#define TUNER_ALPS_TSBB5_PAL_I 11 + +#define TUNER_ALPS_TSBE5_PAL 12 +#define TUNER_ALPS_TSBC5_PAL 13 +#define TUNER_TEMIC_4006FH5_PAL 14 /* 4006 FH5 (3X 9500, 9501, 7291) */ +#define TUNER_ALPS_TSHC6_NTSC 15 + +#define TUNER_TEMIC_PAL_DK 16 /* 4016 FY5 (3X 1392, 1393) */ +#define TUNER_PHILIPS_NTSC_M 17 +#define TUNER_TEMIC_4066FY5_PAL_I 18 /* 4066 FY5 (3X 7032, 7035) */ +#define TUNER_TEMIC_4006FN5_MULTI_PAL 19 /* B/G, I and D/K autodetected (3X 7595, 7606, 7657) */ + +#define TUNER_TEMIC_4009FR5_PAL 20 /* incl. FM radio (3X 7607, 7488, 7711) */ +#define TUNER_TEMIC_4039FR5_NTSC 21 /* incl. FM radio (3X 7246, 7578, 7732) */ +#define TUNER_TEMIC_4046FM5 22 /* you must actively select B/G, D/K, I, L, L` ! (3X 7804, 7806, 8103, 8104) */ #define TUNER_PHILIPS_PAL_DK 23 -#define TUNER_PHILIPS_FQ1216ME 24 /* you must actively select B/G/D/K, I, L, L` */ -#define TUNER_LG_PAL_I_FM 25 -#define TUNER_LG_PAL_I 26 -#define TUNER_LG_NTSC_FM 27 +#define TUNER_PHILIPS_FQ1216ME 24 /* you must actively select B/G/D/K, I, L, L` */ +#define TUNER_LG_PAL_I_FM 25 +#define TUNER_LG_PAL_I 26 +#define TUNER_LG_NTSC_FM 27 -#define TUNER_LG_PAL_FM 28 -#define TUNER_LG_PAL 29 -#define TUNER_TEMIC_4009FN5_MULTI_PAL_FM 30 /* B/G, I and D/K autodetected (3X 8155, 8160, 8163)*/ -#define TUNER_SHARP_2U5JF5540_NTSC 31 +#define TUNER_LG_PAL_FM 28 +#define TUNER_LG_PAL 29 +#define TUNER_TEMIC_4009FN5_MULTI_PAL_FM 30 /* B/G, I and D/K autodetected (3X 8155, 8160, 8163) */ +#define TUNER_SHARP_2U5JF5540_NTSC 31 -#define TUNER_Samsung_PAL_TCPM9091PD27 32 -#define TUNER_MT2032 33 -#define TUNER_TEMIC_4106FH5 34 /* 4106 FH5 (3X 7808, 7865)*/ -#define TUNER_TEMIC_4012FY5 35 /* 4012 FY5 (3X 0971, 1099)*/ +#define TUNER_Samsung_PAL_TCPM9091PD27 32 +#define TUNER_MT2032 33 +#define TUNER_TEMIC_4106FH5 34 /* 4106 FH5 (3X 7808, 7865) */ +#define TUNER_TEMIC_4012FY5 35 /* 4012 FY5 (3X 0971, 1099) */ -#define TUNER_TEMIC_4136FY5 36 /* 4136 FY5 (3X 7708, 7746)*/ -#define TUNER_LG_PAL_NEW_TAPC 37 -#define TUNER_PHILIPS_FM1216ME_MK3 38 -#define TUNER_LG_NTSC_NEW_TAPC 39 +#define TUNER_TEMIC_4136FY5 36 /* 4136 FY5 (3X 7708, 7746) */ +#define TUNER_LG_PAL_NEW_TAPC 37 +#define TUNER_PHILIPS_FM1216ME_MK3 38 +#define TUNER_LG_NTSC_NEW_TAPC 39 -#define TUNER_HITACHI_NTSC 40 -#define TUNER_PHILIPS_PAL_MK 41 -#define TUNER_PHILIPS_ATSC 42 -#define TUNER_PHILIPS_FM1236_MK3 43 +#define TUNER_HITACHI_NTSC 40 +#define TUNER_PHILIPS_PAL_MK 41 +#define TUNER_PHILIPS_ATSC 42 +#define TUNER_PHILIPS_FM1236_MK3 43 -#define TUNER_PHILIPS_4IN1 44 /* ATI TV Wonder Pro - Conexant */ +#define TUNER_PHILIPS_4IN1 44 /* ATI TV Wonder Pro - Conexant */ /* Microtune mergeged with Temic 12/31/1999 partially financed by Alps - these may be similar to Temic */ -#define TUNER_MICROTUNE_4049FM5 45 -#define TUNER_LG_NTSC_TAPE 47 - -#define TUNER_TNF_8831BGFF 48 -#define TUNER_MICROTUNE_4042FI5 49 /* DViCO FusionHDTV 3 Gold-Q - 4042 FI5 (3X 8147) */ -#define TUNER_TCL_2002N 50 -#define TUNER_PHILIPS_FM1256_IH3 51 - -#define TUNER_THOMSON_DTT7610 52 -#define TUNER_PHILIPS_FQ1286 53 -#define TUNER_PHILIPS_TDA8290 54 -#define TUNER_LG_PAL_TAPE 55 /* Hauppauge PVR-150 PAL */ - -#define TUNER_PHILIPS_FQ1216AME_MK4 56 /* Hauppauge PVR-150 PAL */ -#define TUNER_PHILIPS_FQ1236A_MK4 57 /* Hauppauge PVR-500MCE NTSC */ - -#define TUNER_YMEC_TVF_8531MF 58 -#define TUNER_YMEC_TVF_5533MF 59 /* Pixelview Pro Ultra NTSC */ -#define TUNER_THOMSON_DTT7611 60 /* DViCO FusionHDTV 3 Gold-T */ -#define TUNER_TENA_9533_DI 61 - -#define TUNER_TEA5767 62 /* Only FM Radio Tuner */ -#define TUNER_PHILIPS_FMD1216ME_MK3 63 -#define TUNER_LG_TDVS_H062F 64 /* DViCO FusionHDTV 5 */ -#define TUNER_YMEC_TVF66T5_B_DFF 65 /* Acorp Y878F */ - -#define TUNER_LG_NTSC_TALN_MINI 66 +#define TUNER_MICROTUNE_4049FM5 45 +#define TUNER_MICROTUNE_4042_FI5 46 +#define TUNER_LG_NTSC_TAPE 47 + +#define TUNER_TNF_8831BGFF 48 +#define TUNER_MICROTUNE_4042FI5 49 /* DViCO FusionHDTV 3 Gold-Q - 4042 FI5 (3X 8147) */ +#define TUNER_TCL_2002N 50 +#define TUNER_PHILIPS_FM1256_IH3 51 + +#define TUNER_THOMSON_DTT7610 52 +#define TUNER_PHILIPS_FQ1286 53 +#define TUNER_PHILIPS_TDA8290 54 +#define TUNER_LG_PAL_TAPE 55 /* Hauppauge PVR-150 PAL */ + +#define TUNER_PHILIPS_FQ1216AME_MK4 56 /* Hauppauge PVR-150 PAL */ +#define TUNER_PHILIPS_FQ1236A_MK4 57 /* Hauppauge PVR-500MCE NTSC */ +#define TUNER_YMEC_TVF_8531MF 58 +#define TUNER_YMEC_TVF_5533MF 59 /* Pixelview Pro Ultra NTSC */ + +#define TUNER_THOMSON_DTT7611 60 /* DViCO FusionHDTV 3 Gold-T */ +#define TUNER_TENA_9533_DI 61 +#define TUNER_TEA5767 62 /* Only FM Radio Tuner */ +#define TUNER_PHILIPS_FMD1216ME_MK3 63 + +#define TUNER_LG_TDVS_H062F 64 /* DViCO FusionHDTV 5 */ +#define TUNER_YMEC_TVF66T5_B_DFF 65 /* Acorp Y878F */ +#define TUNER_LG_NTSC_TALN_MINI 66 #define NOTUNER 0 #define PAL 1 /* PAL_BG */ @@ -117,7 +117,7 @@ #define NTSC 3 #define SECAM 4 #define ATSC 5 -#define RADIO 6 +#define RADIO 6 #define NoTuner 0 #define Philips 1 @@ -163,21 +163,21 @@ enum tuner_mode { }; struct tuner_setup { - unsigned short addr; - unsigned int type; - unsigned int mode_mask; + unsigned short addr; + unsigned int type; + unsigned int mode_mask; }; struct tuner { /* device */ struct i2c_client i2c; - unsigned int type; /* chip type */ + unsigned int type; /* chip type */ - unsigned int mode; - unsigned int mode_mask; /* Combination of allowable modes */ + unsigned int mode; + unsigned int mode_mask; /* Combination of allowable modes */ - unsigned int freq; /* keep track of the current settings */ + unsigned int freq; /* keep track of the current settings */ unsigned int audmode; v4l2_std_id std; @@ -221,7 +221,7 @@ extern int tea5767_autodetection(struct i2c_client *c); #endif /* __KERNEL__ */ -#endif +#endif /* _TUNER_H */ /* * Overrides for Emacs so that we follow Linus's tabbing style. -- cgit v0.10.2 From 4c93b07a48039cee1d845f38294abec0f803e05e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:54 -0700 Subject: [PATCH] v4l: change LG TDVS H062F from NTSC to ATSC - Change LG TDVS H062F from NTSC to ATSC. Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 5e99b24..61dee53 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -242,7 +242,7 @@ static struct tunertype tuners[] = { /* see tea5767.c for details */}, { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL, 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 }, - { "LG TDVS-H062F/TUA6034", LGINNOTEK, NTSC, + { "LG TDVS-H062F/TUA6034", LGINNOTEK, ATSC, 16*160.00,16*455.00,0x01,0x02,0x04,0x8e,732}, { "Ymec TVF66T5-B/DFF", Philips, PAL, 16*160.25,16*464.25,0x01,0x02,0x08,0x8e,623}, -- cgit v0.10.2 From 08adb9e20be83bb4c5322bf15b966c537038f6d9 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:55 -0700 Subject: [PATCH] v4l: some error treatment implemented at resume functions. - Some error treatment implemented at resume functions. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index 53ecdbf..b35c586 100644 --- a/drivers/media/video/bttv-driver.c +++ b/drivers/media/video/bttv-driver.c @@ -4111,15 +4111,29 @@ static int bttv_resume(struct pci_dev *pci_dev) { struct bttv *btv = pci_get_drvdata(pci_dev); unsigned long flags; + int err; dprintk("bttv%d: resume\n", btv->c.nr); /* restore pci state */ if (btv->state.disabled) { - pci_enable_device(pci_dev); + err=pci_enable_device(pci_dev); + if (err) { + printk(KERN_WARNING "bttv%d: Can't enable device.\n", + btv->c.nr); + return err; + } btv->state.disabled = 0; } - pci_set_power_state(pci_dev, PCI_D0); + err=pci_set_power_state(pci_dev, PCI_D0); + if (err) { + pci_disable_device(pci_dev); + printk(KERN_WARNING "bttv%d: Can't enable device.\n", + btv->c.nr); + btv->state.disabled = 1; + return err; + } + pci_restore_state(pci_dev); /* restore bt878 state */ diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index 6d0d15c..ee2300e 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c @@ -455,14 +455,28 @@ int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state) int cx8802_resume_common(struct pci_dev *pci_dev) { - struct cx8802_dev *dev = pci_get_drvdata(pci_dev); + struct cx8802_dev *dev = pci_get_drvdata(pci_dev); struct cx88_core *core = dev->core; + int err; if (dev->state.disabled) { - pci_enable_device(pci_dev); + err=pci_enable_device(pci_dev); + if (err) { + printk(KERN_ERR "%s: can't enable device\n", + dev->core->name); + return err; + } dev->state.disabled = 0; } - pci_set_power_state(pci_dev, PCI_D0); + err=pci_set_power_state(pci_dev, PCI_D0); + if (err) { + printk(KERN_ERR "%s: can't enable device\n", + dev->core->name); + pci_disable_device(pci_dev); + dev->state.disabled = 1; + + return err; + } pci_restore_state(pci_dev); /* FIXME: re-initialize hardware */ diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 61d4b29..3dbc074 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c @@ -2005,12 +2005,28 @@ static int cx8800_resume(struct pci_dev *pci_dev) { struct cx8800_dev *dev = pci_get_drvdata(pci_dev); struct cx88_core *core = dev->core; + int err; if (dev->state.disabled) { - pci_enable_device(pci_dev); + err=pci_enable_device(pci_dev); + if (err) { + printk(KERN_ERR "%s: can't enable device\n", + core->name); + return err; + } + dev->state.disabled = 0; } - pci_set_power_state(pci_dev, PCI_D0); + err= pci_set_power_state(pci_dev, PCI_D0); + if (err) { + printk(KERN_ERR "%s: can't enable device\n", + core->name); + + pci_disable_device(pci_dev); + dev->state.disabled = 1; + + return err; + } pci_restore_state(pci_dev); /* FIXME: re-initialize hardware */ -- cgit v0.10.2 From 33ac6b52679743c3dbb7c7245f1df90588ee1097 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:56 -0700 Subject: [PATCH] v4l: the Microtune 4049FM5 uses an IF frequency of 33.3 MHz for FM radio. - The Microtune 4049FM5 uses an IF frequency of 33.3 MHz for FM radio. Signed-off-by: Hans Verkuil Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index 64785d3..10ab12b 100644 --- a/drivers/media/video/bttv-cards.c +++ b/drivers/media/video/bttv-cards.c @@ -299,8 +299,8 @@ static struct CARD { { 0x00011822, BTTV_TWINHAN_DST, "Twinhan VisionPlus DVB" }, { 0xfc00270f, BTTV_TWINHAN_DST, "ChainTech digitop DST-1000 DVB-S" }, { 0x07711461, BTTV_AVDVBT_771, "AVermedia AverTV DVB-T 771" }, - { 0xdb1018ac, BTTV_DVICO_DVBT_LITE, "DVICO FusionHDTV DVB-T Lite" }, - { 0xd50018ac, BTTV_DVICO_FUSIONHDTV_5_LITE, "DVICO FusionHDTV 5 Lite" }, + { 0xdb1018ac, BTTV_DVICO_DVBT_LITE, "DViCO FusionHDTV DVB-T Lite" }, + { 0xd50018ac, BTTV_DVICO_FUSIONHDTV_5_LITE, "DViCO FusionHDTV 5 Lite" }, { 0, -1, NULL } }; diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 61dee53..8edd73ab 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -468,6 +468,10 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) case TUNER_LG_PAL_FM: buffer[3] = 0xa5; break; + case TUNER_MICROTUNE_4049FM5: + div = (20 * freq) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */ + buffer[3] = 0xa4; + break; default: buffer[3] = 0xa4; break; -- cgit v0.10.2 From fccdf1bd362452d5e2bc0a1874b2b504b481e367 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:57 -0700 Subject: [PATCH] v4l: #include no longer needed. - #include no longer needed. Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index fa29dd5..639ae51 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "saa7134-reg.h" -- cgit v0.10.2 From 6a989d7328aa4a0b4793ea05b13871bf1b500b1e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:57 -0700 Subject: [PATCH] v4l: correct the amux for composite and s-video inputs on the Sabrent SBT-TVFM card. - correct the amux for composite and s-video inputs on the Sabrent SBT-TVFM card. Signed-off-by: Michael Rodriquez-Torrent Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 07d3ee0..acc7a43 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -1372,7 +1372,7 @@ struct saa7134_board saa7134_boards[] = { .inputs = {{ .name = name_comp1, .vmux = 1, - .amux = LINE2, + .amux = LINE1, },{ .name = name_tv, .vmux = 3, @@ -1381,7 +1381,7 @@ struct saa7134_board saa7134_boards[] = { },{ .name = name_svideo, .vmux = 8, - .amux = LINE2, + .amux = LINE1, }}, .radio = { .name = name_radio, -- cgit v0.10.2 From 21d4df375be2c9e5f1002800036fbfb793cf031f Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:59 -0700 Subject: [PATCH] v4l: print warning if pal= or secam= argument is unrecognized - print warning if pal= or secam= argument is unrecognized Signed-off-by: Philip Rowlands Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index 79e0bd1..0456dda 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -23,6 +23,7 @@ TDA9887 (world), TDA9885 (USA) Note: OP2 of tda988x must be set to 1, else MT2032 is disabled! - KNC One TV-Station RDS (saa7134) + - Hauppauge PVR-150/500 (possibly more) */ @@ -519,6 +520,12 @@ static int tda9887_fixup_std(struct tda9887 *t) dprintk(PREFIX "insmod fixup: PAL => PAL-DK\n"); t->std = V4L2_STD_PAL_DK; break; + case '-': + /* default parameter, do nothing */ + break; + default: + printk(PREFIX "pal= argument not recognised\n"); + break; } } if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) { @@ -535,6 +542,12 @@ static int tda9887_fixup_std(struct tda9887 *t) dprintk(PREFIX "insmod fixup: SECAM => SECAM-L\n"); t->std = V4L2_STD_SECAM_L; break; + case '-': + /* default parameter, do nothing */ + break; + default: + printk(PREFIX "secam= argument not recognised\n"); + break; } } return 0; diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index afc96bb..0557202 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -281,6 +281,12 @@ static int tuner_fixup_std(struct tuner *t) tuner_dbg ("insmod fixup: PAL => PAL-N\n"); t->std = V4L2_STD_PAL_N; break; + case '-': + /* default parameter, do nothing */ + break; + default: + tuner_warn ("pal= argument not recognised\n"); + break; } } if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) { @@ -297,6 +303,12 @@ static int tuner_fixup_std(struct tuner *t) tuner_dbg ("insmod fixup: SECAM => SECAM-L\n"); t->std = V4L2_STD_SECAM_L; break; + case '-': + /* default parameter, do nothing */ + break; + default: + tuner_warn ("secam= argument not recognised\n"); + break; } } -- cgit v0.10.2 From 5129b1589883d6eaa54886f3e0c5d918dafe329e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:04:00 -0700 Subject: [PATCH] v4l: add some missing parameter descriptions in msp3400.c - added some missing parameter descriptions at msp3400.c Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index 01d567c..f0d43fc 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c @@ -124,10 +124,14 @@ module_param(standard, int, 0644); module_param(amsound, int, 0644); module_param(dolby, int, 0644); +MODULE_PARM_DESC(opmode, "Forces a MSP3400 opmode. 0=Manual, 1=Simple, 2=Simpler"); MODULE_PARM_DESC(once, "No continuous stereo monitoring"); MODULE_PARM_DESC(debug, "Enable debug messages"); +MODULE_PARM_DESC(stereo_threshold, "Sets signal threshold to activate stereo"); MODULE_PARM_DESC(standard, "Specify audio standard: 32 = NTSC, 64 = radio, Default: Autodetect"); MODULE_PARM_DESC(amsound, "Hardwire AM sound at 6.5Hz (France), FM can autoscan"); +MODULE_PARM_DESC(dolby, "Activates Dolby processsing"); + MODULE_DESCRIPTION("device driver for msp34xx TV sound processor"); MODULE_AUTHOR("Gerd Knorr"); -- cgit v0.10.2 From 67e49a1abe3e9458c7ffba66775b350b5ceffae0 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:04:00 -0700 Subject: [PATCH] v4l: make the input event device for IR matchable by udev rules. - Makes the input event device created by the V4L drivers for the infrared remote matchable by udev rules. Signed-off-by: Rudo Thomas Signed-off-by: Michael Fair Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c index d7980c5..d81b21d 100644 --- a/drivers/media/video/cx88/cx88-input.c +++ b/drivers/media/video/cx88/cx88-input.c @@ -445,6 +445,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) ir->input.id.vendor = pci->vendor; ir->input.id.product = pci->device; } + ir->input.dev = &pci->dev; /* record handles to ourself */ ir->core = core; diff --git a/drivers/media/video/ir-kbd-gpio.c b/drivers/media/video/ir-kbd-gpio.c index eddadc7..cf292da 100644 --- a/drivers/media/video/ir-kbd-gpio.c +++ b/drivers/media/video/ir-kbd-gpio.c @@ -353,6 +353,7 @@ static int ir_probe(struct device *dev) ir->input.id.vendor = sub->core->pci->vendor; ir->input.id.product = sub->core->pci->device; } + ir->input.dev = &sub->core->pci->dev; if (ir->polling) { INIT_WORK(&ir->work, ir_work, ir); diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 0e97b1e..1f456c4 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c @@ -564,6 +564,7 @@ int saa7134_input_init1(struct saa7134_dev *dev) ir->dev.id.vendor = dev->pci->vendor; ir->dev.id.product = dev->pci->device; } + ir->dev.dev = &dev->pci->dev; /* all done */ dev->remote = ir; -- cgit v0.10.2 From 10b89ee387fd6cc38532a881f64b3d35f338ea0b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:04:03 -0700 Subject: [PATCH] v4l: include saa6588 compiler option and files / fixes comments on tuner.h - Include saa6588 compiler option and files. - Fix comment on tuner.h - linux/utsname.h replaced by linux/version.h to compile on vanilla 2.6.13 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 077720c..9357035 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -25,6 +25,18 @@ config VIDEO_BT848 To compile this driver as a module, choose M here: the module will be called bttv. +config VIDEO_SAA6588 + tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards" + depends on VIDEO_DEV && I2C && VIDEO_BT848 + + help + Support for Radio Data System (RDS) decoder. This allows seeing + radio station identification transmitted using this standard. + Currentlly, it works only with bt8x8 chips. + + To compile this driver as a module, choose M here: the + module will be called saa6588. + config VIDEO_PMS tristate "Mediavision Pro Movie Studio Video For Linux" depends on VIDEO_DEV && ISA diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 3e6f534..046b82d 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -5,6 +5,7 @@ bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \ bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o zoran-objs := zr36120.o zr36120_i2c.o zr36120_mem.o +rds-objs := saa6588.o zr36067-objs := zoran_procfs.o zoran_device.o \ zoran_driver.o zoran_card.o tuner-objs := tuner-core.o tuner-simple.o mt20xx.o tda8290.o tea5767.o @@ -15,6 +16,7 @@ obj-$(CONFIG_VIDEO_BT848) += bttv.o msp3400.o tvaudio.o \ obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o obj-$(CONFIG_VIDEO_ZR36120) += zoran.o +obj-$(CONFIG_VIDEO_SAA6588) += rds.o obj-$(CONFIG_VIDEO_SAA5246A) += saa5246a.o obj-$(CONFIG_VIDEO_SAA5249) += saa5249.o obj-$(CONFIG_VIDEO_CQCAM) += c-qcam.o diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h index a0eb0ce..9b0b7ca 100644 --- a/drivers/media/video/bttvp.h +++ b/drivers/media/video/bttvp.h @@ -25,7 +25,7 @@ #ifndef _BTTVP_H_ #define _BTTVP_H_ -#include +#include #define BTTV_VERSION_CODE KERNEL_VERSION(0,9,16) #include diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 13b8fb7..f48dd43 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h @@ -34,7 +34,7 @@ #include "btcx-risc.h" #include "cx88-reg.h" -#include +#include #define CX88_VERSION_CODE KERNEL_VERSION(0,0,5) #ifndef TRUE diff --git a/drivers/media/video/rds.h b/drivers/media/video/rds.h new file mode 100644 index 0000000..30337d0 --- /dev/null +++ b/drivers/media/video/rds.h @@ -0,0 +1,48 @@ +/* + + Types and defines needed for RDS. This is included by + saa6588.c and every driver (e.g. bttv-driver.c) that wants + to use the saa6588 module. + + Instead of having a seperate rds.h, I'd prefer to include + this stuff in one of the already existing files like tuner.h + + (c) 2005 by Hans J. Koch + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef _RDS_H +#define _RDS_H + +struct rds_command { + unsigned int block_count; + int result; + unsigned char *buffer; + struct file *instance; + poll_table *event_list; +}; + +#define RDS_CMD_OPEN _IOW('R',1,int) +#define RDS_CMD_CLOSE _IOW('R',2,int) +#define RDS_CMD_READ _IOR('R',3,int) +#define RDS_CMD_POLL _IOR('R',4,int) + +#endif + + + + diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c new file mode 100644 index 0000000..1a657a7 --- /dev/null +++ b/drivers/media/video/saa6588.c @@ -0,0 +1,534 @@ +/* + Driver for SAA6588 RDS decoder + + (c) 2005 Hans J. Koch + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "rds.h" + +/* Addresses to scan */ +static unsigned short normal_i2c[] = { + 0x20 >> 1, + 0x22 >> 1, + I2C_CLIENT_END, +}; + +I2C_CLIENT_INSMOD; + +/* insmod options */ +static unsigned int debug = 0; +static unsigned int xtal = 0; +static unsigned int rbds = 0; +static unsigned int plvl = 0; +static unsigned int bufblocks = 100; + +MODULE_PARM(debug, "i"); +MODULE_PARM_DESC(debug, "enable debug messages"); +MODULE_PARM(xtal, "i"); +MODULE_PARM_DESC(xtal, "select oscillator frequency (0..3), default 0"); +MODULE_PARM(rbds, "i"); +MODULE_PARM_DESC(rbds, "select mode, 0=RDS, 1=RBDS, default 0"); +MODULE_PARM(plvl, "i"); +MODULE_PARM_DESC(plvl, "select pause level (0..3), default 0"); +MODULE_PARM(bufblocks, "i"); +MODULE_PARM_DESC(bufblocks, "number of buffered blocks, default 100"); + +MODULE_DESCRIPTION("v4l2 driver module for SAA6588 RDS decoder"); +MODULE_AUTHOR("Hans J. Koch "); + +MODULE_LICENSE("GPL"); + +/* ---------------------------------------------------------------------- */ + +#define UNSET (-1U) +#define PREFIX "saa6588: " +#define dprintk if (debug) printk + +struct saa6588 { + struct i2c_client client; + struct work_struct work; + struct timer_list timer; + spinlock_t lock; + unsigned char *buffer; + unsigned int buf_size; + unsigned int rd_index; + unsigned int wr_index; + unsigned int block_count; + unsigned char last_blocknum; + wait_queue_head_t read_queue; + int data_available_for_read; +}; + +static struct i2c_driver driver; +static struct i2c_client client_template; + +/* ---------------------------------------------------------------------- */ + +/* + * SAA6588 defines + */ + +/* Initialization and mode control byte (0w) */ + +/* bit 0+1 (DAC0/DAC1) */ +#define cModeStandard 0x00 +#define cModeFastPI 0x01 +#define cModeReducedRequest 0x02 +#define cModeInvalid 0x03 + +/* bit 2 (RBDS) */ +#define cProcessingModeRDS 0x00 +#define cProcessingModeRBDS 0x04 + +/* bit 3+4 (SYM0/SYM1) */ +#define cErrCorrectionNone 0x00 +#define cErrCorrection2Bits 0x08 +#define cErrCorrection5Bits 0x10 +#define cErrCorrectionNoneRBDS 0x18 + +/* bit 5 (NWSY) */ +#define cSyncNormal 0x00 +#define cSyncRestart 0x20 + +/* bit 6 (TSQD) */ +#define cSigQualityDetectOFF 0x00 +#define cSigQualityDetectON 0x40 + +/* bit 7 (SQCM) */ +#define cSigQualityTriggered 0x00 +#define cSigQualityContinous 0x80 + +/* Pause level and flywheel control byte (1w) */ + +/* bits 0..5 (FEB0..FEB5) */ +#define cFlywheelMaxBlocksMask 0x3F +#define cFlywheelDefault 0x20 + +/* bits 6+7 (PL0/PL1) */ +#define cPauseLevel_11mV 0x00 +#define cPauseLevel_17mV 0x40 +#define cPauseLevel_27mV 0x80 +#define cPauseLevel_43mV 0xC0 + +/* Pause time/oscillator frequency/quality detector control byte (1w) */ + +/* bits 0..4 (SQS0..SQS4) */ +#define cQualityDetectSensMask 0x1F +#define cQualityDetectDefault 0x0F + +/* bit 5 (SOSC) */ +#define cSelectOscFreqOFF 0x00 +#define cSelectOscFreqON 0x20 + +/* bit 6+7 (PTF0/PTF1) */ +#define cOscFreq_4332kHz 0x00 +#define cOscFreq_8664kHz 0x40 +#define cOscFreq_12996kHz 0x80 +#define cOscFreq_17328kHz 0xC0 + +/* ---------------------------------------------------------------------- */ + +static int block_to_user_buf(struct saa6588 *s, unsigned char *user_buf) +{ + int i; + + if (s->rd_index == s->wr_index) { + if (debug > 2) + dprintk(PREFIX "Read: buffer empty.\n"); + return 0; + } + + if (debug > 2) { + dprintk(PREFIX "Read: "); + for (i = s->rd_index; i < s->rd_index + 3; i++) + dprintk("0x%02x ", s->buffer[i]); + } + + if (copy_to_user(user_buf, &s->buffer[s->rd_index], 3)) + return -EFAULT; + + s->rd_index += 3; + if (s->rd_index >= s->buf_size) + s->rd_index = 0; + s->block_count--; + + if (debug > 2) + dprintk("%d blocks total.\n", s->block_count); + + return 1; +} + +static void read_from_buf(struct saa6588 *s, struct rds_command *a) +{ + unsigned long flags; + + unsigned char *buf_ptr = a->buffer; /* This is a user space buffer! */ + unsigned int i; + unsigned int rd_blocks; + + a->result = 0; + if (!a->buffer) + return; + + while (!s->data_available_for_read) { + int ret = wait_event_interruptible(s->read_queue, + s->data_available_for_read); + if (ret == -ERESTARTSYS) { + a->result = -EINTR; + return; + } + } + + spin_lock_irqsave(&s->lock, flags); + rd_blocks = a->block_count; + if (rd_blocks > s->block_count) + rd_blocks = s->block_count; + + if (!rd_blocks) + return; + + for (i = 0; i < rd_blocks; i++) { + if (block_to_user_buf(s, buf_ptr)) { + buf_ptr += 3; + a->result++; + } else + break; + } + a->result *= 3; + s->data_available_for_read = (s->block_count > 0); + spin_unlock_irqrestore(&s->lock, flags); +} + +static void block_to_buf(struct saa6588 *s, unsigned char *blockbuf) +{ + unsigned int i; + + if (debug > 3) + dprintk(PREFIX "New block: "); + + for (i = 0; i < 3; ++i) { + if (debug > 3) + dprintk("0x%02x ", blockbuf[i]); + s->buffer[s->wr_index] = blockbuf[i]; + s->wr_index++; + } + + if (s->wr_index >= s->buf_size) + s->wr_index = 0; + + if (s->wr_index == s->rd_index) { + s->rd_index++; + if (s->rd_index >= s->buf_size) + s->rd_index = 0; + } else + s->block_count++; + + if (debug > 3) + dprintk("%d blocks total.\n", s->block_count); +} + +static void saa6588_i2c_poll(struct saa6588 *s) +{ + unsigned long flags; + unsigned char tmpbuf[6]; + unsigned char blocknum; + unsigned char tmp; + + /* Although we only need 3 bytes, we have to read at least 6. + SAA6588 returns garbage otherwise */ + if (6 != i2c_master_recv(&s->client, &tmpbuf[0], 6)) { + if (debug > 1) + dprintk(PREFIX "read error!\n"); + return; + } + + blocknum = tmpbuf[0] >> 5; + if (blocknum == s->last_blocknum) { + if (debug > 3) + dprintk("Saw block %d again.\n", blocknum); + return; + } + + s->last_blocknum = blocknum; + + /* + Byte order according to v4l2 specification: + + Byte 0: Least Significant Byte of RDS Block + Byte 1: Most Significant Byte of RDS Block + Byte 2 Bit 7: Error bit. Indicates that an uncorrectable error + occurred during reception of this block. + Bit 6: Corrected bit. Indicates that an error was + corrected for this data block. + Bits 5-3: Received Offset. Indicates the offset received + by the sync system. + Bits 2-0: Offset Name. Indicates the offset applied to this data. + + SAA6588 byte order is Status-MSB-LSB, so we have to swap the + first and the last of the 3 bytes block. + */ + + tmp = tmpbuf[2]; + tmpbuf[2] = tmpbuf[0]; + tmpbuf[0] = tmp; + + tmp = blocknum; + tmp |= blocknum << 3; /* Received offset == Offset Name (OK ?) */ + if ((tmpbuf[2] & 0x03) == 0x03) + tmp |= 0x80; /* uncorrectable error */ + else if ((tmpbuf[2] & 0x03) != 0x00) + tmp |= 0x40; /* corrected error */ + tmpbuf[2] = tmp; /* Is this enough ? Should we also check other bits ? */ + + spin_lock_irqsave(&s->lock, flags); + block_to_buf(s, tmpbuf); + spin_unlock_irqrestore(&s->lock, flags); + s->data_available_for_read = 1; + wake_up_interruptible(&s->read_queue); +} + +static void saa6588_timer(unsigned long data) +{ + struct saa6588 *s = (struct saa6588 *)data; + + schedule_work(&s->work); +} + +static void saa6588_work(void *data) +{ + struct saa6588 *s = (struct saa6588 *)data; + + saa6588_i2c_poll(s); + mod_timer(&s->timer, jiffies + HZ / 50); /* 20 msec */ +} + +static int saa6588_configure(struct saa6588 *s) +{ + unsigned char buf[3]; + int rc; + + buf[0] = cSyncRestart; + if (rbds) + buf[0] |= cProcessingModeRBDS; + + buf[1] = cFlywheelDefault; + switch (plvl) { + case 0: + buf[1] |= cPauseLevel_11mV; + break; + case 1: + buf[1] |= cPauseLevel_17mV; + break; + case 2: + buf[1] |= cPauseLevel_27mV; + break; + case 3: + buf[1] |= cPauseLevel_43mV; + break; + default: /* nothing */ + break; + } + + buf[2] = cQualityDetectDefault | cSelectOscFreqON; + + switch (xtal) { + case 0: + buf[2] |= cOscFreq_4332kHz; + break; + case 1: + buf[2] |= cOscFreq_8664kHz; + break; + case 2: + buf[2] |= cOscFreq_12996kHz; + break; + case 3: + buf[2] |= cOscFreq_17328kHz; + break; + default: /* nothing */ + break; + } + + dprintk(PREFIX "writing: 0w=0x%02x 1w=0x%02x 2w=0x%02x\n", + buf[0], buf[1], buf[2]); + + if (3 != (rc = i2c_master_send(&s->client, buf, 3))) + printk(PREFIX "i2c i/o error: rc == %d (should be 3)\n", rc); + + return 0; +} + +/* ---------------------------------------------------------------------- */ + +static int saa6588_attach(struct i2c_adapter *adap, int addr, int kind) +{ + struct saa6588 *s; + client_template.adapter = adap; + client_template.addr = addr; + + printk(PREFIX "chip found @ 0x%x\n", addr << 1); + + if (NULL == (s = kmalloc(sizeof(*s), GFP_KERNEL))) + return -ENOMEM; + + s->buf_size = bufblocks * 3; + + if (NULL == (s->buffer = kmalloc(s->buf_size, GFP_KERNEL))) { + kfree(s); + return -ENOMEM; + } + s->client = client_template; + s->block_count = 0; + s->wr_index = 0; + s->rd_index = 0; + s->last_blocknum = 0xff; + init_waitqueue_head(&s->read_queue); + s->data_available_for_read = 0; + i2c_set_clientdata(&s->client, s); + i2c_attach_client(&s->client); + + saa6588_configure(s); + + /* start polling via eventd */ + INIT_WORK(&s->work, saa6588_work, s); + init_timer(&s->timer); + s->timer.function = saa6588_timer; + s->timer.data = (unsigned long)s; + schedule_work(&s->work); + + return 0; +} + +static int saa6588_probe(struct i2c_adapter *adap) +{ +#ifdef I2C_CLASS_TV_ANALOG + if (adap->class & I2C_CLASS_TV_ANALOG) + return i2c_probe(adap, &addr_data, saa6588_attach); +#else + switch (adap->id) { + case I2C_ALGO_BIT | I2C_HW_B_BT848: + case I2C_ALGO_BIT | I2C_HW_B_RIVA: + case I2C_ALGO_SAA7134: + return i2c_probe(adap, &addr_data, saa6588_attach); + break; + } +#endif + return 0; +} + +static int saa6588_detach(struct i2c_client *client) +{ + struct saa6588 *s = i2c_get_clientdata(client); + + del_timer_sync(&s->timer); + flush_scheduled_work(); + + i2c_detach_client(client); + kfree(s->buffer); + kfree(s); + return 0; +} + +static int saa6588_command(struct i2c_client *client, unsigned int cmd, + void *arg) +{ + struct saa6588 *s = i2c_get_clientdata(client); + struct rds_command *a = (struct rds_command *)arg; + + switch (cmd) { + /* --- open() for /dev/radio --- */ + case RDS_CMD_OPEN: + a->result = 0; /* return error if chip doesn't work ??? */ + break; + /* --- close() for /dev/radio --- */ + case RDS_CMD_CLOSE: + s->data_available_for_read = 1; + wake_up_interruptible(&s->read_queue); + a->result = 0; + break; + /* --- read() for /dev/radio --- */ + case RDS_CMD_READ: + read_from_buf(s, a); + break; + /* --- poll() for /dev/radio --- */ + case RDS_CMD_POLL: + a->result = 0; + if (s->data_available_for_read) { + a->result |= POLLIN | POLLRDNORM; + } + poll_wait(a->instance, &s->read_queue, a->event_list); + break; + + default: + /* nothing */ + break; + } + return 0; +} + +/* ----------------------------------------------------------------------- */ + +static struct i2c_driver driver = { + .owner = THIS_MODULE, + .name = "i2c saa6588 driver", + .id = -1, /* FIXME */ + .flags = I2C_DF_NOTIFY, + .attach_adapter = saa6588_probe, + .detach_client = saa6588_detach, + .command = saa6588_command, +}; + +static struct i2c_client client_template = { + .name = "saa6588", + .flags = I2C_CLIENT_ALLOW_USE, + .driver = &driver, +}; + +static int __init saa6588_init_module(void) +{ + return i2c_add_driver(&driver); +} + +static void __exit saa6588_cleanup_module(void) +{ + i2c_del_driver(&driver); +} + +module_init(saa6588_init_module); +module_exit(saa6588_cleanup_module); + +/* + * Overrides for Emacs so that we follow Linus's tabbing style. + * --------------------------------------------------------------------------- + * Local variables: + * c-basic-offset: 8 + * End: + */ diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 1d70f34..3ea0914 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h @@ -19,7 +19,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include +#include #define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,14) #include diff --git a/include/media/tuner.h b/include/media/tuner.h index 5b01ee6..4ad08e2 100644 --- a/include/media/tuner.h +++ b/include/media/tuner.h @@ -1,4 +1,4 @@ - * +/* tuner.h - definition for different tuners Copyright (C) 1997 Markus Schroeder (schroedm@uni-duesseldorf.de) -- cgit v0.10.2 From dc75fc1b924ccf44ca9f0446701acc0081605b49 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:04:04 -0700 Subject: [PATCH] v4l: Remove kernel version dependency from tea575x-tuner.h - Removed kernel version dependency from tea575x-tuner.h Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/include/sound/tea575x-tuner.h b/include/sound/tea575x-tuner.h index ad3c3be..b82e408 100644 --- a/include/sound/tea575x-tuner.h +++ b/include/sound/tea575x-tuner.h @@ -34,9 +34,7 @@ struct snd_tea575x_ops { struct snd_tea575x { snd_card_t *card; struct video_device vd; /* video device */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) struct file_operations fops; -#endif int dev_nr; /* requested device number + 1 */ int vd_registered; /* video device is registered */ int tea5759; /* 5759 chip is present */ -- cgit v0.10.2 From 18fc59e230bbda9725736f8f526ef88aab212348 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:04:05 -0700 Subject: [PATCH] v4l: TVaudio cleanup and better debug messages - adds the adapter number + i2c address to printk msgs. - Some CodingStyle cleanups. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 258724b..1c31ef5 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c @@ -46,7 +46,17 @@ MODULE_AUTHOR("Eric Sandeen, Steve VanDeBogart, Greg Alexander, Gerd Knorr"); MODULE_LICENSE("GPL"); #define UNSET (-1U) -#define dprintk if (debug) printk + +#define tvaudio_info(fmt, arg...) do {\ + printk(KERN_INFO "tvaudio %d-%04x: " fmt, \ + chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) +#define tvaudio_warn(fmt, arg...) do {\ + printk(KERN_WARNING "tvaudio %d-%04x: " fmt, \ + chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) +#define tvaudio_dbg(fmt, arg...) do {\ + if (debug) \ + printk(KERN_INFO "tvaudio %d-%04x: " fmt, \ + chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) /* ---------------------------------------------------------------------- */ /* our structs */ @@ -162,23 +172,24 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) unsigned char buffer[2]; if (-1 == subaddr) { - dprintk("%s: chip_write: 0x%x\n", chip->c.name, val); + tvaudio_dbg("%s: chip_write: 0x%x\n", + chip->c.name, val); chip->shadow.bytes[1] = val; buffer[0] = val; if (1 != i2c_master_send(&chip->c,buffer,1)) { - printk(KERN_WARNING "%s: I/O error (write 0x%x)\n", - chip->c.name, val); + tvaudio_warn("%s: I/O error (write 0x%x)\n", + chip->c.name, val); return -1; } } else { - dprintk("%s: chip_write: reg%d=0x%x\n", + tvaudio_dbg("%s: chip_write: reg%d=0x%x\n", chip->c.name, subaddr, val); chip->shadow.bytes[subaddr+1] = val; buffer[0] = subaddr; buffer[1] = val; if (2 != i2c_master_send(&chip->c,buffer,2)) { - printk(KERN_WARNING "%s: I/O error (write reg%d=0x%x)\n", - chip->c.name, subaddr, val); + tvaudio_warn("%s: I/O error (write reg%d=0x%x)\n", + chip->c.name, subaddr, val); return -1; } } @@ -202,29 +213,30 @@ static int chip_read(struct CHIPSTATE *chip) unsigned char buffer; if (1 != i2c_master_recv(&chip->c,&buffer,1)) { - printk(KERN_WARNING "%s: I/O error (read)\n", chip->c.name); + tvaudio_warn("%s: I/O error (read)\n", + chip->c.name); return -1; } - dprintk("%s: chip_read: 0x%x\n", chip->c.name, buffer); + tvaudio_dbg("%s: chip_read: 0x%x\n",chip->c.name,buffer); return buffer; } static int chip_read2(struct CHIPSTATE *chip, int subaddr) { - unsigned char write[1]; - unsigned char read[1]; - struct i2c_msg msgs[2] = { - { chip->c.addr, 0, 1, write }, - { chip->c.addr, I2C_M_RD, 1, read } - }; - write[0] = subaddr; + unsigned char write[1]; + unsigned char read[1]; + struct i2c_msg msgs[2] = { + { chip->c.addr, 0, 1, write }, + { chip->c.addr, I2C_M_RD, 1, read } + }; + write[0] = subaddr; if (2 != i2c_transfer(chip->c.adapter,msgs,2)) { - printk(KERN_WARNING "%s: I/O error (read2)\n", chip->c.name); + tvaudio_warn("%s: I/O error (read2)\n", chip->c.name); return -1; } - dprintk("%s: chip_read2: reg%d=0x%x\n", - chip->c.name, subaddr, read[0]); + tvaudio_dbg("%s: chip_read2: reg%d=0x%x\n", + chip->c.name,subaddr,read[0]); return read[0]; } @@ -236,17 +248,19 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) return 0; /* update our shadow register set; print bytes if (debug > 0) */ - dprintk("%s: chip_cmd(%s): reg=%d, data:", - chip->c.name, name, cmd->bytes[0]); + tvaudio_dbg("%s: chip_cmd(%s): reg=%d, data:", + chip->c.name,name,cmd->bytes[0]); for (i = 1; i < cmd->count; i++) { - dprintk(" 0x%x",cmd->bytes[i]); + if (debug) + printk(" 0x%x",cmd->bytes[i]); chip->shadow.bytes[i+cmd->bytes[0]] = cmd->bytes[i]; } - dprintk("\n"); + if (debug) + printk("\n"); /* send data to the chip */ if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) { - printk(KERN_WARNING "%s: I/O error (%s)\n", chip->c.name, name); + tvaudio_warn("%s: I/O error (%s)\n", chip->c.name, name); return -1; } return 0; @@ -261,19 +275,19 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) static void chip_thread_wake(unsigned long data) { - struct CHIPSTATE *chip = (struct CHIPSTATE*)data; + struct CHIPSTATE *chip = (struct CHIPSTATE*)data; wake_up_interruptible(&chip->wq); } static int chip_thread(void *data) { DECLARE_WAITQUEUE(wait, current); - struct CHIPSTATE *chip = data; + struct CHIPSTATE *chip = data; struct CHIPDESC *desc = chiplist + chip->type; daemonize("%s", chip->c.name); allow_signal(SIGTERM); - dprintk("%s: thread started\n", chip->c.name); + tvaudio_dbg("%s: thread started\n", chip->c.name); for (;;) { add_wait_queue(&chip->wq, &wait); @@ -285,7 +299,7 @@ static int chip_thread(void *data) try_to_freeze(); if (chip->done || signal_pending(current)) break; - dprintk("%s: thread wakeup\n", chip->c.name); + tvaudio_dbg("%s: thread wakeup\n", chip->c.name); /* don't do anything for radio or if mode != auto */ if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0) @@ -298,8 +312,8 @@ static int chip_thread(void *data) mod_timer(&chip->wt, jiffies+2*HZ); } - dprintk("%s: thread exiting\n", chip->c.name); - complete_and_exit(&chip->texit, 0); + tvaudio_dbg("%s: thread exiting\n", chip->c.name); + complete_and_exit(&chip->texit, 0); return 0; } @@ -309,9 +323,9 @@ static void generic_checkmode(struct CHIPSTATE *chip) int mode = desc->getmode(chip); if (mode == chip->prevmode) - return; + return; - dprintk("%s: thread checkmode\n", chip->c.name); + tvaudio_dbg("%s: thread checkmode\n", chip->c.name); chip->prevmode = mode; if (mode & VIDEO_SOUND_STEREO) @@ -358,8 +372,8 @@ static int tda9840_getmode(struct CHIPSTATE *chip) if (val & TDA9840_ST_STEREO) mode |= VIDEO_SOUND_STEREO; - dprintk ("tda9840_getmode(): raw chip read: %d, return: %d\n", - val, mode); + tvaudio_dbg ("tda9840_getmode(): raw chip read: %d, return: %d\n", + val, mode); return mode; } @@ -654,8 +668,8 @@ static int tda9873_getmode(struct CHIPSTATE *chip) mode |= VIDEO_SOUND_STEREO; if (val & TDA9873_DUAL) mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; - dprintk ("tda9873_getmode(): raw chip read: %d, return: %d\n", - val, mode); + tvaudio_dbg ("tda9873_getmode(): raw chip read: %d, return: %d\n", + val, mode); return mode; } @@ -665,12 +679,12 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { - dprintk("tda9873_setmode(): external input\n"); + tvaudio_dbg("tda9873_setmode(): external input\n"); return; } - dprintk("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); - dprintk("tda9873_setmode(): sw_data = %d\n", sw_data); + tvaudio_dbg("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); + tvaudio_dbg("tda9873_setmode(): sw_data = %d\n", sw_data); switch (mode) { case VIDEO_SOUND_MONO: @@ -691,7 +705,7 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) } chip_write(chip, TDA9873_SW, sw_data); - dprintk("tda9873_setmode(): req. mode %d; chip_write: %d\n", + tvaudio_dbg("tda9873_setmode(): req. mode %d; chip_write: %d\n", mode, sw_data); } @@ -828,9 +842,9 @@ static int tda9874a_setup(struct CHIPSTATE *chip) } else { /* dic == 0x07 */ chip_write(chip, TDA9874A_AMCONR, 0xfb); chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80); - chip_write(chip, TDA9874A_AOSR, 0x00); // or 0x10 + chip_write(chip, TDA9874A_AOSR, 0x00); /* or 0x10 */ } - dprintk("tda9874a_setup(): %s [0x%02X].\n", + tvaudio_dbg("tda9874a_setup(): %s [0x%02X].\n", tda9874a_modelist[tda9874a_STD].name,tda9874a_STD); return 1; } @@ -873,7 +887,7 @@ static int tda9874a_getmode(struct CHIPSTATE *chip) mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; } - dprintk("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", + tvaudio_dbg("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", dsr, nsr, necr, mode); return mode; } @@ -919,7 +933,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) chip_write(chip, TDA9874A_AOSR, aosr); chip_write(chip, TDA9874A_MDACOSR, mdacosr); - dprintk("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", + tvaudio_dbg("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", mode, aosr, mdacosr); } else { /* dic == 0x07 */ @@ -954,7 +968,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) chip_write(chip, TDA9874A_FMMR, fmmr); chip_write(chip, TDA9874A_AOSR, aosr); - dprintk("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", + tvaudio_dbg("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", mode, fmmr, aosr); } } @@ -968,10 +982,10 @@ static int tda9874a_checkit(struct CHIPSTATE *chip) if(-1 == (sic = chip_read2(chip,TDA9874A_SIC))) return 0; - dprintk("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); + tvaudio_dbg("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); if((dic == 0x11)||(dic == 0x07)) { - printk("tvaudio: found tda9874%s.\n", (dic == 0x11) ? "a":"h"); + tvaudio_info("found tda9874%s.\n", (dic == 0x11) ? "a":"h"); tda9874a_dic = dic; /* remember device id. */ return 1; } @@ -1146,7 +1160,7 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode) /* ---------------------------------------------------------------------- */ /* audio chip descriptions - defines+functions for TA8874Z */ -// write 1st byte +/* write 1st byte */ #define TA8874Z_LED_STE 0x80 #define TA8874Z_LED_BIL 0x40 #define TA8874Z_LED_EXT 0x20 @@ -1156,21 +1170,22 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode) #define TA8874Z_MODE_SUB 0x02 #define TA8874Z_MODE_MAIN 0x01 -// write 2nd byte -//#define TA8874Z_TI 0x80 // test mode +/* write 2nd byte */ +/*#define TA8874Z_TI 0x80 */ /* test mode */ #define TA8874Z_SEPARATION 0x3f #define TA8874Z_SEPARATION_DEFAULT 0x10 -// read +/* read */ #define TA8874Z_B1 0x80 #define TA8874Z_B0 0x40 #define TA8874Z_CHAG_FLAG 0x20 -// B1 B0 -// mono L H -// stereo L L -// BIL H L - +/* + * B1 B0 + * mono L H + * stereo L L + * BIL H L + */ static int ta8874z_getmode(struct CHIPSTATE *chip) { int val, mode; @@ -1182,7 +1197,7 @@ static int ta8874z_getmode(struct CHIPSTATE *chip) }else if (!(val & TA8874Z_B0)){ mode |= VIDEO_SOUND_STEREO; } - //dprintk ("ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); + /* tvaudio_dbg ("ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */ return mode; } @@ -1195,7 +1210,7 @@ static void ta8874z_setmode(struct CHIPSTATE *chip, int mode) { int update = 1; audiocmd *t = NULL; - dprintk("ta8874z_setmode(): mode: 0x%02x\n", mode); + tvaudio_dbg("ta8874z_setmode(): mode: 0x%02x\n", mode); switch(mode){ case VIDEO_SOUND_MONO: @@ -1235,11 +1250,11 @@ static int tda9850 = 1; static int tda9855 = 1; static int tda9873 = 1; static int tda9874a = 1; -static int tea6300 = 0; // address clash with msp34xx -static int tea6320 = 0; // address clash with msp34xx +static int tea6300 = 0; /* address clash with msp34xx */ +static int tea6320 = 0; /* address clash with msp34xx */ static int tea6420 = 1; static int pic16c54 = 1; -static int ta8874z = 0; // address clash with tda9840 +static int ta8874z = 0; /* address clash with tda9840 */ module_param(tda8425, int, 0444); module_param(tda9840, int, 0444); @@ -1441,7 +1456,7 @@ static struct CHIPDESC chiplist[] = { { .name = "ta8874z", .id = -1, - //.id = I2C_DRIVERID_TA8874Z, + /*.id = I2C_DRIVERID_TA8874Z, */ .checkit = ta8874z_checkit, .insmodopt = &ta8874z, .addr_lo = I2C_TDA9840 >> 1, @@ -1476,7 +1491,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) i2c_set_clientdata(&chip->c, chip); /* find description for the chip */ - dprintk("tvaudio: chip found @ i2c-addr=0x%x\n", addr<<1); + tvaudio_dbg("chip found @ 0x%x\n", addr<<1); for (desc = chiplist; desc->name != NULL; desc++) { if (0 == *(desc->insmodopt)) continue; @@ -1488,17 +1503,19 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) break; } if (desc->name == NULL) { - dprintk("tvaudio: no matching chip description found\n"); + tvaudio_dbg("no matching chip description found\n"); return -EIO; } - printk("tvaudio: found %s @ 0x%x\n", desc->name, addr<<1); - dprintk("tvaudio: matches:%s%s%s.\n", - (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", - (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", - (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); + tvaudio_info("%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name); + if (desc->flags) { + tvaudio_dbg("matches:%s%s%s.\n", + (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", + (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", + (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); + } /* fill required data structures */ - strcpy(chip->c.name, desc->name); + strcpy(chip->c.name,desc->name); chip->type = desc-chiplist; chip->shadow.count = desc->registers+1; chip->prevmode = -1; @@ -1534,7 +1551,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) init_completion(&chip->texit); chip->tpid = kernel_thread(chip_thread,(void *)chip,0); if (chip->tpid < 0) - printk(KERN_WARNING "%s: kernel_thread() failed\n", + tvaudio_warn("%s: kernel_thread() failed\n", chip->c.name); wake_up_interruptible(&chip->wq); } @@ -1545,7 +1562,7 @@ static int chip_probe(struct i2c_adapter *adap) { /* don't attach on saa7146 based cards, because dedicated drivers are used */ - if (adap->id == I2C_HW_SAA7146) + if ((adap->id == I2C_HW_SAA7146)) return 0; #ifdef I2C_CLASS_TV_ANALOG if (adap->class & I2C_CLASS_TV_ANALOG) @@ -1584,11 +1601,11 @@ static int chip_detach(struct i2c_client *client) static int chip_command(struct i2c_client *client, unsigned int cmd, void *arg) { - __u16 *sarg = arg; + __u16 *sarg = arg; struct CHIPSTATE *chip = i2c_get_clientdata(client); struct CHIPDESC *desc = chiplist + chip->type; - dprintk("%s: chip_command 0x%x\n", chip->c.name, cmd); + tvaudio_dbg("%s: chip_command 0x%x\n",chip->c.name,cmd); switch (cmd) { case AUDC_SET_INPUT: @@ -1601,7 +1618,6 @@ static int chip_command(struct i2c_client *client, break; case AUDC_SET_RADIO: - dprintk(KERN_DEBUG "tvaudio: AUDC_SET_RADIO\n"); chip->norm = VIDEO_MODE_RADIO; chip->watch_stereo = 0; /* del_timer(&chip->wt); */ @@ -1609,7 +1625,7 @@ static int chip_command(struct i2c_client *client, /* --- v4l ioctls --- */ /* take care: bttv does userspace copying, we'll get a - kernel pointer here... */ + kernel pointer here... */ case VIDIOCGAUDIO: { struct video_audio *va = arg; @@ -1643,9 +1659,9 @@ static int chip_command(struct i2c_client *client, if (desc->flags & CHIP_HAS_VOLUME) { chip->left = (min(65536 - va->balance,32768) * - va->volume) / 32768; + va->volume) / 32768; chip->right = (min(va->balance,(__u16)32768) * - va->volume) / 32768; + va->volume) / 32768; chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); } @@ -1667,17 +1683,16 @@ static int chip_command(struct i2c_client *client, { struct video_channel *vc = arg; - dprintk(KERN_DEBUG "tvaudio: VIDIOCSCHAN\n"); chip->norm = vc->norm; break; } case VIDIOCSFREQ: { - chip->mode = 0; /* automatic */ + chip->mode = 0; /* automatic */ if (desc->checkmode) { desc->setmode(chip,VIDEO_SOUND_MONO); - if (chip->prevmode != VIDEO_SOUND_MONO) - chip->prevmode = -1; /* reset previous mode */ + if (chip->prevmode != VIDEO_SOUND_MONO) + chip->prevmode = -1; /* reset previous mode */ mod_timer(&chip->wt, jiffies+2*HZ); /* the thread will call checkmode() later */ } @@ -1689,29 +1704,32 @@ static int chip_command(struct i2c_client *client, static struct i2c_driver driver = { .owner = THIS_MODULE, - .name = "generic i2c audio driver", - .id = I2C_DRIVERID_TVAUDIO, - .flags = I2C_DF_NOTIFY, - .attach_adapter = chip_probe, - .detach_client = chip_detach, - .command = chip_command, + .name = "generic i2c audio driver", + .id = I2C_DRIVERID_TVAUDIO, + .flags = I2C_DF_NOTIFY, + .attach_adapter = chip_probe, + .detach_client = chip_detach, + .command = chip_command, }; static struct i2c_client client_template = { .name = "(unset)", .flags = I2C_CLIENT_ALLOW_USE, - .driver = &driver, + .driver = &driver, }; static int __init audiochip_init_module(void) { struct CHIPDESC *desc; - printk(KERN_INFO "tvaudio: TV audio decoder + audio/video mux driver\n"); - printk(KERN_INFO "tvaudio: known chips: "); - for (desc = chiplist; desc->name != NULL; desc++) - printk("%s%s", (desc == chiplist) ? "" : ",",desc->name); - printk("\n"); + + if (debug) { + printk(KERN_INFO "tvaudio: TV audio decoder + audio/video mux driver\n"); + printk(KERN_INFO "tvaudio: known chips: "); + for (desc = chiplist; desc->name != NULL; desc++) + printk("%s%s", (desc == chiplist) ? "" : ", ", desc->name); + printk("\n"); + } return i2c_add_driver(&driver); } -- cgit v0.10.2 From 0f97a931b337e4662e736ca67f1fab0a187f5852 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:04:05 -0700 Subject: [PATCH] v4l: tveeprom improved to support newer Hauppage cards - tveeprom improved and updated to reflect newer Hauppage cards. - CodingStyle fixes. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index 10ab12b..190977a 100644 --- a/drivers/media/video/bttv-cards.c +++ b/drivers/media/video/bttv-cards.c @@ -3060,7 +3060,7 @@ static void __devinit hauppauge_eeprom(struct bttv *btv) { struct tveeprom tv; - tveeprom_hauppauge_analog(&tv, eeprom_data); + tveeprom_hauppauge_analog(&btv->i2c_client, &tv, eeprom_data); btv->tuner_type = tv.tuner_type; btv->has_radio = tv.has_radio; } @@ -4485,6 +4485,7 @@ void __devinit bttv_check_chipset(void) } if (UNSET != latency) printk(KERN_INFO "bttv: pci latency fixup [%d]\n",latency); + while ((dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, dev))) { unsigned char b; diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index b35c586..a564321 100644 --- a/drivers/media/video/bttv-driver.c +++ b/drivers/media/video/bttv-driver.c @@ -4079,6 +4079,7 @@ static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state) struct bttv_buffer_set idle; unsigned long flags; + dprintk("bttv%d: suspend %d\n", btv->c.nr, state.event); /* stop dma + irqs */ spin_lock_irqsave(&btv->s_lock,flags); diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c index 9262323..4da91d5 100644 --- a/drivers/media/video/cx88/cx88-cards.c +++ b/drivers/media/video/cx88/cx88-cards.c @@ -945,7 +945,7 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data) { struct tveeprom tv; - tveeprom_hauppauge_analog(&tv, eeprom_data); + tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data); core->tuner_type = tv.tuner_type; core->has_radio = tv.has_radio; } diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index 3674014..5344d55 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -47,18 +47,21 @@ MODULE_LICENSE("GPL"); static int debug = 0; module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "Debug level (0-2)"); +MODULE_PARM_DESC(debug, "Debug level (0-1)"); #define STRM(array,i) (i < sizeof(array)/sizeof(char*) ? array[i] : "unknown") -#define dprintk(num, args...) \ - do { \ - if (debug >= num) \ - printk(KERN_INFO "tveeprom: " args); \ - } while (0) +#define tveeprom_info(fmt, arg...) do {\ + printk(KERN_INFO "tveeprom %d-%04x: " fmt, \ + c->adapter->nr, c->addr , ##arg); } while (0) +#define tveeprom_warn(fmt, arg...) do {\ + printk(KERN_WARNING "tveeprom %d-%04x: " fmt, \ + c->adapter->nr, c->addr , ##arg); } while (0) +#define tveeprom_dbg(fmt, arg...) do {\ + if (debug) \ + printk(KERN_INFO "tveeprom %d-%04x: " fmt, \ + c->adapter->nr, c->addr , ##arg); } while (0) -#define TVEEPROM_KERN_ERR(args...) printk(KERN_ERR "tveeprom: " args); -#define TVEEPROM_KERN_INFO(args...) printk(KERN_INFO "tveeprom: " args); /* ----------------------------------------------------------------------- */ /* some hauppauge specific stuff */ @@ -70,14 +73,14 @@ static struct HAUPPAUGE_TUNER_FMT } hauppauge_tuner_fmt[] = { - { 0x00000000, "unknown1" }, - { 0x00000000, "unknown2" }, - { 0x00000007, "PAL(B/G)" }, - { 0x00001000, "NTSC(M)" }, - { 0x00000010, "PAL(I)" }, - { 0x00400000, "SECAM(L/L´)" }, - { 0x00000e00, "PAL(D/K)" }, - { 0x03000000, "ATSC Digital" }, + { 0x00000000, " unknown1" }, + { 0x00000000, " unknown2" }, + { 0x00000007, " PAL(B/G)" }, + { 0x00001000, " NTSC(M)" }, + { 0x00000010, " PAL(I)" }, + { 0x00400000, " SECAM(L/L')" }, + { 0x00000e00, " PAL(D/K)" }, + { 0x03000000, " ATSC Digital" }, }; /* This is the full list of possible tuners. Many thanks to Hauppauge for @@ -203,20 +206,47 @@ hauppauge_tuner[] = { TUNER_TCL_2002N, "TCL 2002N 5H"}, /* 100-103 */ { TUNER_ABSENT, "Unspecified"}, - { TUNER_ABSENT, "Unspecified"}, + { TUNER_TEA5767, "Philips TEA5767HN FM Radio"}, { TUNER_ABSENT, "Unspecified"}, { TUNER_PHILIPS_FM1236_MK3, "TCL MFNM05 4"}, }; -static char *sndtype[] = { - "None", "TEA6300", "TEA6320", "TDA9850", "MSP3400C", "MSP3410D", - "MSP3415", "MSP3430", "MSP3438", "CS5331", "MSP3435", "MSP3440", - "MSP3445", "MSP3411", "MSP3416", "MSP3425", +/* This list is supplied by Hauppauge. Thanks! */ +static const char *audioIC[] = { + /* 0-4 */ + "None", "TEA6300", "TEA6320", "TDA9850", "MSP3400C", + /* 5-9 */ + "MSP3410D", "MSP3415", "MSP3430", "MSP3438", "CS5331", + /* 10-14 */ + "MSP3435", "MSP3440", "MSP3445", "MSP3411", "MSP3416", + /* 15-19 */ + "MSP3425", "MSP3451", "MSP3418", "Type 0x12", "OKI7716", + /* 20-24 */ + "MSP4410", "MSP4420", "MSP4440", "MSP4450", "MSP4408", + /* 25-29 */ + "MSP4418", "MSP4428", "MSP4448", "MSP4458", "Type 0x1d", + /* 30-34 */ + "CX880", "CX881", "CX883", "CX882", "CX25840", + /* 35-38 */ + "CX25841", "CX25842", "CX25843", "CX23418", +}; - "Type 0x10","Type 0x11","Type 0x12","Type 0x13", - "Type 0x14","Type 0x15","Type 0x16","Type 0x17", - "Type 0x18","MSP4418","Type 0x1a","MSP4448", - "Type 0x1c","Type 0x1d","Type 0x1e","Type 0x1f", +/* This list is supplied by Hauppauge. Thanks! */ +static const char *decoderIC[] = { + /* 0-4 */ + "None", "BT815", "BT817", "BT819", "BT815A", + /* 5-9 */ + "BT817A", "BT819A", "BT827", "BT829", "BT848", + /* 10-14 */ + "BT848A", "BT849A", "BT829A", "BT827A", "BT878", + /* 15-19 */ + "BT879", "BT880", "VPX3226E", "SAA7114", "SAA7115", + /* 20-24 */ + "CX880", "CX881", "CX883", "SAA7111", "SAA7113", + /* 25-29 */ + "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842", + /* 30-31 */ + "CX25843", "CX23418", }; static int hasRadioTuner(int tunerType) @@ -257,7 +287,8 @@ static int hasRadioTuner(int tunerType) return 0; } -void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data) +void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, + unsigned char *eeprom_data) { /* ---------------------------------------------- ** The hauppauge eeprom format is tagged @@ -267,10 +298,11 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data ** if packet[0] & f8 == f8, then EOD and packet[1] == checksum ** ** In our (ivtv) case we're interested in the following: - ** tuner type: tag [00].05 or [0a].01 (index into hauppauge_tuner) - ** tuner fmts: tag [00].04 or [0a].00 (bitmask index into hauppauge_tuner_fmt) - ** radio: tag [00].{last} or [0e].00 (bitmask. bit2=FM) - ** audio proc: tag [02].01 or [05].00 (lower nibble indexes lut?) + ** tuner type: tag [00].05 or [0a].01 (index into hauppauge_tuner) + ** tuner fmts: tag [00].04 or [0a].00 (bitmask index into hauppauge_tuner_fmt) + ** radio: tag [00].{last} or [0e].00 (bitmask. bit2=FM) + ** audio proc: tag [02].01 or [05].00 (mask with 0x7f) + ** decoder proc: tag [09].01) ** Fun info: ** model: tag [00].07-08 or [06].00-01 @@ -280,20 +312,24 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data ** # of inputs/outputs ??? */ - int i, j, len, done, beenhere, tag, tuner = 0, t_format = 0; - char *t_name = NULL, *t_fmt_name = NULL; + int i, j, len, done, beenhere, tag; - dprintk(1, "%s\n",__FUNCTION__); - tvee->revision = done = len = beenhere = 0; - for (i = 0; !done && i < 256; i += len) { - dprintk(2, "processing pos = %02x (%02x, %02x)\n", - i, eeprom_data[i], eeprom_data[i + 1]); + int tuner1 = 0, t_format1 = 0; + char *t_name1 = NULL; + const char *t_fmt_name1[8] = { " none", "", "", "", "", "", "", "" }; + int tuner2 = 0, t_format2 = 0; + char *t_name2 = NULL; + const char *t_fmt_name2[8] = { " none", "", "", "", "", "", "", "" }; + + memset(tvee, 0, sizeof(*tvee)); + done = len = beenhere = 0; + for (i = 0; !done && i < 256; i += len) { if (eeprom_data[i] == 0x84) { len = eeprom_data[i + 1] + (eeprom_data[i + 2] << 8); - i+=3; + i += 3; } else if ((eeprom_data[i] & 0xf0) == 0x70) { - if ((eeprom_data[i] & 0x08)) { + if (eeprom_data[i] & 0x08) { /* verify checksum! */ done = 1; break; @@ -301,24 +337,30 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data len = eeprom_data[i] & 0x07; ++i; } else { - TVEEPROM_KERN_ERR("Encountered bad packet header [%02x]. " + tveeprom_warn("Encountered bad packet header [%02x]. " "Corrupt or not a Hauppauge eeprom.\n", eeprom_data[i]); return; } - dprintk(1, "%3d [%02x] ", len, eeprom_data[i]); - for(j = 1; j < len; j++) { - dprintk(1, "%02x ", eeprom_data[i + j]); - } - dprintk(1, "\n"); + if (debug) { + tveeprom_info("Tag [%02x] + %d bytes:", eeprom_data[i], len - 1); + for(j = 1; j < len; j++) { + printk(" %02x", eeprom_data[i + j]); + } + printk("\n"); + } /* process by tag */ tag = eeprom_data[i]; switch (tag) { case 0x00: - tuner = eeprom_data[i+6]; - t_format = eeprom_data[i+5]; + /* tag: 'Comprehensive' */ + tuner1 = eeprom_data[i+6]; + t_format1 = eeprom_data[i+5]; tvee->has_radio = eeprom_data[i+len-1]; + /* old style tag, don't know how to detect + IR presence, mark as unknown. */ + tvee->has_ir = 2; tvee->model = eeprom_data[i+8] + (eeprom_data[i+9] << 8); @@ -326,25 +368,43 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data (eeprom_data[i+11] << 8) + (eeprom_data[i+12] << 16); break; + case 0x01: + /* tag: 'SerialID' */ tvee->serial_number = eeprom_data[i+6] + (eeprom_data[i+7] << 8) + (eeprom_data[i+8] << 16); break; + case 0x02: - tvee->audio_processor = eeprom_data[i+2] & 0x0f; + /* tag 'AudioInfo' + Note mask with 0x7F, high bit used on some older models + to indicate 4052 mux was removed in favor of using MSP + inputs directly. */ + tvee->audio_processor = eeprom_data[i+2] & 0x7f; break; + + /* case 0x03: tag 'EEInfo' */ + case 0x04: + /* tag 'SerialID2' */ tvee->serial_number = eeprom_data[i+5] + (eeprom_data[i+6] << 8) + (eeprom_data[i+7] << 16); break; + case 0x05: - tvee->audio_processor = eeprom_data[i+1] & 0x0f; + /* tag 'Audio2' + Note mask with 0x7F, high bit used on some older models + to indicate 4052 mux was removed in favor of using MSP + inputs directly. */ + tvee->audio_processor = eeprom_data[i+1] & 0x7f; break; + case 0x06: + /* tag 'ModelRev' */ tvee->model = eeprom_data[i+1] + (eeprom_data[i+2] << 8); @@ -352,27 +412,66 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data (eeprom_data[i+6] << 8) + (eeprom_data[i+7] << 16); break; + + case 0x07: + /* tag 'Details': according to Hauppauge not interesting + on any PCI-era or later boards. */ + break; + + /* there is no tag 0x08 defined */ + + case 0x09: + /* tag 'Video' */ + tvee->decoder_processor = eeprom_data[i + 1]; + break; + case 0x0a: - if(beenhere == 0) { - tuner = eeprom_data[i+2]; - t_format = eeprom_data[i+1]; + /* tag 'Tuner' */ + if (beenhere == 0) { + tuner1 = eeprom_data[i+2]; + t_format1 = eeprom_data[i+1]; beenhere = 1; - break; } else { - break; - } + /* a second (radio) tuner may be present */ + tuner2 = eeprom_data[i+2]; + t_format2 = eeprom_data[i+1]; + if (t_format2 == 0) { /* not a TV tuner? */ + tvee->has_radio = 1; /* must be radio */ + } + } + break; + + case 0x0b: + /* tag 'Inputs': according to Hauppauge this is specific + to each driver family, so no good assumptions can be + made. */ + break; + + /* case 0x0c: tag 'Balun' */ + /* case 0x0d: tag 'Teletext' */ + case 0x0e: + /* tag: 'Radio' */ tvee->has_radio = eeprom_data[i+1]; break; + + case 0x0f: + /* tag 'IRInfo' */ + tvee->has_ir = eeprom_data[i+1]; + break; + + /* case 0x10: tag 'VBIInfo' */ + /* case 0x11: tag 'QCInfo' */ + /* case 0x12: tag 'InfoBits' */ + default: - dprintk(1, "Not sure what to do with tag [%02x]\n", tag); + tveeprom_dbg("Not sure what to do with tag [%02x]\n", tag); /* dump the rest of the packet? */ } - } if (!done) { - TVEEPROM_KERN_ERR("Ran out of data!\n"); + tveeprom_warn("Ran out of data!\n"); return; } @@ -384,47 +483,72 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data tvee->rev_str[4] = 0; } - if (hasRadioTuner(tuner) && !tvee->has_radio) { - TVEEPROM_KERN_INFO("The eeprom says no radio is present, but the tuner type\n"); - TVEEPROM_KERN_INFO("indicates otherwise. I will assume that radio is present.\n"); + if (hasRadioTuner(tuner1) && !tvee->has_radio) { + tveeprom_info("The eeprom says no radio is present, but the tuner type\n"); + tveeprom_info("indicates otherwise. I will assume that radio is present.\n"); tvee->has_radio = 1; } - if (tuner < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { - tvee->tuner_type = hauppauge_tuner[tuner].id; - t_name = hauppauge_tuner[tuner].name; + if (tuner1 < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { + tvee->tuner_type = hauppauge_tuner[tuner1].id; + t_name1 = hauppauge_tuner[tuner1].name; } else { - t_name = ""; + t_name1 = "unknown"; + } + + if (tuner2 < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { + tvee->tuner2_type = hauppauge_tuner[tuner2].id; + t_name2 = hauppauge_tuner[tuner2].name; + } else { + t_name2 = "unknown"; } tvee->tuner_formats = 0; - t_fmt_name = ""; - for (i = 0; i < 8; i++) { - if (t_format & (1<tuner2_formats = 0; + for (i = j = 0; i < 8; i++) { + if (t_format1 & (1 << i)) { tvee->tuner_formats |= hauppauge_tuner_fmt[i].id; - /* yuck */ - t_fmt_name = hauppauge_tuner_fmt[i].name; + t_fmt_name1[j++] = hauppauge_tuner_fmt[i].name; } + if (t_format2 & (1 << i)) { + tvee->tuner2_formats |= hauppauge_tuner_fmt[i].id; + t_fmt_name2[j++] = hauppauge_tuner_fmt[i].name; + } } - - TVEEPROM_KERN_INFO("Hauppauge: model = %d, rev = %s, serial# = %d\n", - tvee->model, - tvee->rev_str, - tvee->serial_number); - TVEEPROM_KERN_INFO("tuner = %s (idx = %d, type = %d)\n", - t_name, - tuner, - tvee->tuner_type); - TVEEPROM_KERN_INFO("tuner fmt = %s (eeprom = 0x%02x, v4l2 = 0x%08x)\n", - t_fmt_name, - t_format, - tvee->tuner_formats); - - TVEEPROM_KERN_INFO("audio_processor = %s (type = %d)\n", - STRM(sndtype,tvee->audio_processor), + tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n", + tvee->model, tvee->rev_str, tvee->serial_number); + tveeprom_info("tuner model is %s (idx %d, type %d)\n", + t_name1, tuner1, tvee->tuner_type); + tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", + t_fmt_name1[0], t_fmt_name1[1], t_fmt_name1[2], t_fmt_name1[3], + t_fmt_name1[4], t_fmt_name1[5], t_fmt_name1[6], t_fmt_name1[7], + t_format1); + if (tuner2) { + tveeprom_info("second tuner model is %s (idx %d, type %d)\n", + t_name2, tuner2, tvee->tuner2_type); + } + if (t_format2) { + tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", + t_fmt_name2[0], t_fmt_name2[1], t_fmt_name2[2], t_fmt_name2[3], + t_fmt_name2[4], t_fmt_name2[5], t_fmt_name2[6], t_fmt_name2[7], + t_format2); + } + tveeprom_info("audio processor is %s (idx %d)\n", + STRM(audioIC, tvee->audio_processor), tvee->audio_processor); - + if (tvee->decoder_processor) { + tveeprom_info("decoder processor is %s (idx %d)\n", + STRM(decoderIC, tvee->decoder_processor), + tvee->decoder_processor); + } + if (tvee->has_ir == 2) + tveeprom_info("has %sradio\n", + tvee->has_radio ? "" : "no "); + else + tveeprom_info("has %sradio, has %sIR remote\n", + tvee->has_radio ? "" : "no ", + tvee->has_ir ? "" : "no "); } EXPORT_SYMBOL(tveeprom_hauppauge_analog); @@ -436,23 +560,31 @@ int tveeprom_read(struct i2c_client *c, unsigned char *eedata, int len) unsigned char buf; int err; - dprintk(1, "%s\n",__FUNCTION__); buf = 0; - if (1 != (err = i2c_master_send(c,&buf,1))) { - printk(KERN_INFO "tveeprom(%s): Huh, no eeprom present (err=%d)?\n", - c->name,err); + if (1 != (err = i2c_master_send(c, &buf, 1))) { + tveeprom_info("Huh, no eeprom present (err=%d)?\n", err); return -1; } - if (len != (err = i2c_master_recv(c,eedata,len))) { - printk(KERN_WARNING "tveeprom(%s): i2c eeprom read error (err=%d)\n", - c->name,err); + if (len != (err = i2c_master_recv(c, eedata, len))) { + tveeprom_warn("i2c eeprom read error (err=%d)\n", err); return -1; } + if (debug) { + int i; + + tveeprom_info("full 256-byte eeprom dump:\n"); + for (i = 0; i < len; i++) { + if (0 == (i % 16)) + tveeprom_info("%02x:", i); + printk(" %02x", eedata[i]); + if (15 == (i % 16)) + printk("\n"); + } + } return 0; } EXPORT_SYMBOL(tveeprom_read); - /* ----------------------------------------------------------------------- */ /* needed for ivtv.sf.net at the moment. Should go away in the long */ /* run, just call the exported tveeprom_* directly, there is no point in */ @@ -485,7 +617,7 @@ tveeprom_command(struct i2c_client *client, buf = kmalloc(256,GFP_KERNEL); memset(buf,0,256); tveeprom_read(client,buf,256); - tveeprom_hauppauge_analog(&eeprom,buf); + tveeprom_hauppauge_analog(client, &eeprom,buf); kfree(buf); eeprom_props[0] = eeprom.tuner_type; eeprom_props[1] = eeprom.tuner_formats; @@ -506,8 +638,6 @@ tveeprom_detect_client(struct i2c_adapter *adapter, { struct i2c_client *client; - dprintk(1,"%s: id 0x%x @ 0x%x\n",__FUNCTION__, - adapter->id, address << 1); client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); if (NULL == client) return -ENOMEM; @@ -524,7 +654,6 @@ tveeprom_detect_client(struct i2c_adapter *adapter, static int tveeprom_attach_adapter (struct i2c_adapter *adapter) { - dprintk(1,"%s: id 0x%x\n",__FUNCTION__,adapter->id); if (adapter->id != I2C_HW_B_BT848) return 0; return i2c_probe(adapter, &addr_data, tveeprom_detect_client); diff --git a/include/media/tveeprom.h b/include/media/tveeprom.h index e24e841..e2035c7 100644 --- a/include/media/tveeprom.h +++ b/include/media/tveeprom.h @@ -3,15 +3,19 @@ struct tveeprom { u32 has_radio; + u32 has_ir; /* 0: no IR, 1: IR present, 2: unknown */ u32 tuner_type; u32 tuner_formats; + u32 tuner2_type; + u32 tuner2_formats; + u32 digitizer; u32 digitizer_formats; u32 audio_processor; - /* a_p_fmts? */ + u32 decoder_processor; u32 model; u32 revision; @@ -19,7 +23,7 @@ struct tveeprom { char rev_str[5]; }; -void tveeprom_hauppauge_analog(struct tveeprom *tvee, +void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, unsigned char *eeprom_data); int tveeprom_read(struct i2c_client *c, unsigned char *eedata, int len); -- cgit v0.10.2 From 8b6490e5faafb3a16ea45654fb55f9ff086f1495 Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:07 -0700 Subject: [PATCH] files: fix rcu initializers First of a number of files_lock scaability patches. Here are the x86 numbers - tiobench on a 4(8)-way (HT) P4 system on ramdisk : (lockfree) Test 2.6.10-vanilla Stdev 2.6.10-fd Stdev ------------------------------------------------------------- Seqread 1400.8 11.52 1465.4 34.27 Randread 1594 8.86 2397.2 29.21 Seqwrite 242.72 3.47 238.46 6.53 Randwrite 445.74 9.15 446.4 9.75 The performance improvement is very significant. We are getting killed by the cacheline bouncing of the files_struct lock here. Writes on ramdisk (ext2) seems to vary just too much to get any meaningful number. Also, With Tridge's thread_perf test on a 4(8)-way (HT) P4 xeon system : 2.6.12-rc5-vanilla : Running test 'readwrite' with 8 tasks Threads 0.34 +/- 0.01 seconds Processes 0.16 +/- 0.00 seconds 2.6.12-rc5-fd : Running test 'readwrite' with 8 tasks Threads 0.17 +/- 0.02 seconds Processes 0.17 +/- 0.02 seconds I repeated the measurements on ramfs (as opposed to ext2 on ramdisk in the earlier measurement) and I got more consistent results from tiobench : 4(8) way xeon P4 ----------------- (lock-free) Test 2.6.12-rc5 Stdev 2.6.12-rc5-fd Stdev ------------------------------------------------------------- Seqread 1282 18.59 1343.6 26.37 Randread 1517 7 2415 34.27 Seqwrite 702.2 5.27 709.46 5.9 Randwrite 846.86 15.15 919.68 21.4 4-way ppc64 ------------ (lock-free) Test 2.6.12-rc5 Stdev 2.6.12-rc5-fd Stdev ------------------------------------------------------------- Seqread 1549 91.16 1569.6 47.2 Randread 1473.6 25.11 1585.4 69.99 Seqwrite 1096.8 20.03 1136 29.61 Randwrite 1189.6 4.04 1275.2 32.96 Also running Tridge's thread_perf test on ppc64 : 2.6.12-rc5-vanilla -------------------- Running test 'readwrite' with 4 tasks Threads 0.20 +/- 0.02 seconds Processes 0.16 +/- 0.01 seconds 2.6.12-rc5-fd -------------------- Running test 'readwrite' with 4 tasks Threads 0.18 +/- 0.04 seconds Processes 0.16 +/- 0.01 seconds The benefits are huge (upto ~60%) in some cases on x86 primarily due to the atomic operations during acquisition of ->file_lock and cache line bouncing in fast path. ppc64 benefits are modest due to LL/SC based locking, but still statistically significant. This patch: RCU head initilizer no longer needs the head varible name since we don't use list.h lists anymore. Signed-off-by: Dipankar Sarma Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index fd276ad..4e65eb4 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -52,8 +52,8 @@ struct rcu_head { void (*func)(struct rcu_head *head); }; -#define RCU_HEAD_INIT(head) { .next = NULL, .func = NULL } -#define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT(head) +#define RCU_HEAD_INIT { .next = NULL, .func = NULL } +#define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT #define INIT_RCU_HEAD(ptr) do { \ (ptr)->next = NULL; (ptr)->func = NULL; \ } while (0) -- cgit v0.10.2 From c0dfb2905126e9e94edebbce8d3e05001301f52d Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:09 -0700 Subject: [PATCH] files: rcuref APIs Adds a set of primitives to do reference counting for objects that are looked up without locks using RCU. Signed-off-by: Ravikiran Thirumalai Signed-off-by: Dipankar Sarma Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/RCU/rcuref.txt b/Documentation/RCU/rcuref.txt new file mode 100644 index 0000000..a23fee6 --- /dev/null +++ b/Documentation/RCU/rcuref.txt @@ -0,0 +1,74 @@ +Refcounter framework for elements of lists/arrays protected by +RCU. + +Refcounting on elements of lists which are protected by traditional +reader/writer spinlocks or semaphores are straight forward as in: + +1. 2. +add() search_and_reference() +{ { + alloc_object read_lock(&list_lock); + ... search_for_element + atomic_set(&el->rc, 1); atomic_inc(&el->rc); + write_lock(&list_lock); ... + add_element read_unlock(&list_lock); + ... ... + write_unlock(&list_lock); } +} + +3. 4. +release_referenced() delete() +{ { + ... write_lock(&list_lock); + atomic_dec(&el->rc, relfunc) ... + ... delete_element +} write_unlock(&list_lock); + ... + if (atomic_dec_and_test(&el->rc)) + kfree(el); + ... + } + +If this list/array is made lock free using rcu as in changing the +write_lock in add() and delete() to spin_lock and changing read_lock +in search_and_reference to rcu_read_lock(), the rcuref_get in +search_and_reference could potentially hold reference to an element which +has already been deleted from the list/array. rcuref_lf_get_rcu takes +care of this scenario. search_and_reference should look as; + +1. 2. +add() search_and_reference() +{ { + alloc_object rcu_read_lock(); + ... search_for_element + atomic_set(&el->rc, 1); if (rcuref_inc_lf(&el->rc)) { + write_lock(&list_lock); rcu_read_unlock(); + return FAIL; + add_element } + ... ... + write_unlock(&list_lock); rcu_read_unlock(); +} } +3. 4. +release_referenced() delete() +{ { + ... write_lock(&list_lock); + rcuref_dec(&el->rc, relfunc) ... + ... delete_element +} write_unlock(&list_lock); + ... + if (rcuref_dec_and_test(&el->rc)) + call_rcu(&el->head, el_free); + ... + } + +Sometimes, reference to the element need to be obtained in the +update (write) stream. In such cases, rcuref_inc_lf might be an overkill +since the spinlock serialising list updates are held. rcuref_inc +is to be used in such cases. +For arches which do not have cmpxchg rcuref_inc_lf +api uses a hashed spinlock implementation and the same hashed spinlock +is acquired in all rcuref_xxx primitives to preserve atomicity. +Note: Use rcuref_inc api only if you need to use rcuref_inc_lf on the +refcounter atleast at one place. Mixing rcuref_inc and atomic_xxx api +might lead to races. rcuref_inc_lf() must be used in lockfree +RCU critical sections only. diff --git a/include/linux/rcuref.h b/include/linux/rcuref.h new file mode 100644 index 0000000..e1adbba --- /dev/null +++ b/include/linux/rcuref.h @@ -0,0 +1,220 @@ +/* + * rcuref.h + * + * Reference counting for elements of lists/arrays protected by + * RCU. + * + * 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. + * + * Copyright (C) IBM Corporation, 2005 + * + * Author: Dipankar Sarma + * Ravikiran Thirumalai + * + * See Documentation/RCU/rcuref.txt for detailed user guide. + * + */ + +#ifndef _RCUREF_H_ +#define _RCUREF_H_ + +#ifdef __KERNEL__ + +#include +#include +#include +#include + +/* + * These APIs work on traditional atomic_t counters used in the + * kernel for reference counting. Under special circumstances + * where a lock-free get() operation races with a put() operation + * these APIs can be used. See Documentation/RCU/rcuref.txt. + */ + +#ifdef __HAVE_ARCH_CMPXCHG + +/** + * rcuref_inc - increment refcount for object. + * @rcuref: reference counter in the object in question. + * + * This should be used only for objects where we use RCU and + * use the rcuref_inc_lf() api to acquire a reference + * in a lock-free reader-side critical section. + */ +static inline void rcuref_inc(atomic_t *rcuref) +{ + atomic_inc(rcuref); +} + +/** + * rcuref_dec - decrement refcount for object. + * @rcuref: reference counter in the object in question. + * + * This should be used only for objects where we use RCU and + * use the rcuref_inc_lf() api to acquire a reference + * in a lock-free reader-side critical section. + */ +static inline void rcuref_dec(atomic_t *rcuref) +{ + atomic_dec(rcuref); +} + +/** + * rcuref_dec_and_test - decrement refcount for object and test + * @rcuref: reference counter in the object. + * @release: pointer to the function that will clean up the object + * when the last reference to the object is released. + * This pointer is required. + * + * Decrement the refcount, and if 0, return 1. Else return 0. + * + * This should be used only for objects where we use RCU and + * use the rcuref_inc_lf() api to acquire a reference + * in a lock-free reader-side critical section. + */ +static inline int rcuref_dec_and_test(atomic_t *rcuref) +{ + return atomic_dec_and_test(rcuref); +} + +/* + * cmpxchg is needed on UP too, if deletions to the list/array can happen + * in interrupt context. + */ + +/** + * rcuref_inc_lf - Take reference to an object in a read-side + * critical section protected by RCU. + * @rcuref: reference counter in the object in question. + * + * Try and increment the refcount by 1. The increment might fail if + * the reference counter has been through a 1 to 0 transition and + * is no longer part of the lock-free list. + * Returns non-zero on successful increment and zero otherwise. + */ +static inline int rcuref_inc_lf(atomic_t *rcuref) +{ + int c, old; + c = atomic_read(rcuref); + while (c && (old = cmpxchg(&rcuref->counter, c, c + 1)) != c) + c = old; + return c; +} + +#else /* !__HAVE_ARCH_CMPXCHG */ + +extern spinlock_t __rcuref_hash[]; + +/* + * Use a hash table of locks to protect the reference count + * since cmpxchg is not available in this arch. + */ +#ifdef CONFIG_SMP +#define RCUREF_HASH_SIZE 4 +#define RCUREF_HASH(k) \ + (&__rcuref_hash[(((unsigned long)k)>>8) & (RCUREF_HASH_SIZE-1)]) +#else +#define RCUREF_HASH_SIZE 1 +#define RCUREF_HASH(k) &__rcuref_hash[0] +#endif /* CONFIG_SMP */ + +/** + * rcuref_inc - increment refcount for object. + * @rcuref: reference counter in the object in question. + * + * This should be used only for objects where we use RCU and + * use the rcuref_inc_lf() api to acquire a reference in a lock-free + * reader-side critical section. + */ +static inline void rcuref_inc(atomic_t *rcuref) +{ + unsigned long flags; + spin_lock_irqsave(RCUREF_HASH(rcuref), flags); + rcuref->counter += 1; + spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); +} + +/** + * rcuref_dec - decrement refcount for object. + * @rcuref: reference counter in the object in question. + * + * This should be used only for objects where we use RCU and + * use the rcuref_inc_lf() api to acquire a reference in a lock-free + * reader-side critical section. + */ +static inline void rcuref_dec(atomic_t *rcuref) +{ + unsigned long flags; + spin_lock_irqsave(RCUREF_HASH(rcuref), flags); + rcuref->counter -= 1; + spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); +} + +/** + * rcuref_dec_and_test - decrement refcount for object and test + * @rcuref: reference counter in the object. + * @release: pointer to the function that will clean up the object + * when the last reference to the object is released. + * This pointer is required. + * + * Decrement the refcount, and if 0, return 1. Else return 0. + * + * This should be used only for objects where we use RCU and + * use the rcuref_inc_lf() api to acquire a reference in a lock-free + * reader-side critical section. + */ +static inline int rcuref_dec_and_test(atomic_t *rcuref) +{ + unsigned long flags; + spin_lock_irqsave(RCUREF_HASH(rcuref), flags); + rcuref->counter--; + if (!rcuref->counter) { + spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); + return 1; + } else { + spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); + return 0; + } +} + +/** + * rcuref_inc_lf - Take reference to an object of a lock-free collection + * by traversing a lock-free list/array. + * @rcuref: reference counter in the object in question. + * + * Try and increment the refcount by 1. The increment might fail if + * the reference counter has been through a 1 to 0 transition and + * object is no longer part of the lock-free list. + * Returns non-zero on successful increment and zero otherwise. + */ +static inline int rcuref_inc_lf(atomic_t *rcuref) +{ + int ret; + unsigned long flags; + spin_lock_irqsave(RCUREF_HASH(rcuref), flags); + if (rcuref->counter) + ret = rcuref->counter++; + else + ret = 0; + spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); + return ret; +} + + +#endif /* !__HAVE_ARCH_CMPXCHG */ + +#endif /* __KERNEL__ */ +#endif /* _RCUREF_H_ */ diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c index f436993..bef3b69 100644 --- a/kernel/rcupdate.c +++ b/kernel/rcupdate.c @@ -45,6 +45,7 @@ #include #include #include +#include #include /* Definition for rcupdate control block. */ @@ -72,6 +73,19 @@ DEFINE_PER_CPU(struct rcu_data, rcu_bh_data) = { 0L }; static DEFINE_PER_CPU(struct tasklet_struct, rcu_tasklet) = {NULL}; static int maxbatch = 10; +#ifndef __HAVE_ARCH_CMPXCHG +/* + * We use an array of spinlocks for the rcurefs -- similar to ones in sparc + * 32 bit atomic_t implementations, and a hash function similar to that + * for our refcounting needs. + * Can't help multiprocessors which donot have cmpxchg :( + */ + +spinlock_t __rcuref_hash[RCUREF_HASH_SIZE] = { + [0 ... (RCUREF_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED +}; +#endif + /** * call_rcu - Queue an RCU callback for invocation after a grace period. * @head: structure to be used for queueing the RCU updates. -- cgit v0.10.2 From badf16621c1f9d1ac753be056fce11b43d6e0be5 Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:10 -0700 Subject: [PATCH] files: break up files struct In order for the RCU to work, the file table array, sets and their sizes must be updated atomically. Instead of ensuring this through too many memory barriers, we put the arrays and their sizes in a separate structure. This patch takes the first step of putting the file table elements in a separate structure fdtable that is embedded withing files_struct. It also changes all the users to refer to the file table using files_fdtable() macro. Subsequent applciation of RCU becomes easier after this. Signed-off-by: Dipankar Sarma Signed-Off-By: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 167fd89f..2b03418 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -974,6 +974,7 @@ osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, size_t size; long timeout; int ret = -EINVAL; + struct fdtable *fdt; timeout = MAX_SCHEDULE_TIMEOUT; if (tvp) { @@ -995,7 +996,8 @@ osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, } } - if (n < 0 || n > current->files->max_fdset) + fdt = files_fdtable(current->files); + if (n < 0 || n > fdt->max_fdset) goto out_nofds; /* diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index f1201ac..4ad97b3 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -2217,15 +2218,17 @@ static void pfm_free_fd(int fd, struct file *file) { struct files_struct *files = current->files; + struct fdtable *fdt = files_fdtable(files); /* * there ie no fd_uninstall(), so we do it here */ spin_lock(&files->file_lock); - files->fd[fd] = NULL; + rcu_assign_pointer(fdt->fd[fd], NULL); spin_unlock(&files->file_lock); - if (file) put_filp(file); + if (file) + put_filp(file); put_unused_fd(fd); } diff --git a/arch/sparc64/solaris/ioctl.c b/arch/sparc64/solaris/ioctl.c index cac0a1c..3747664 100644 --- a/arch/sparc64/solaris/ioctl.c +++ b/arch/sparc64/solaris/ioctl.c @@ -293,11 +293,13 @@ static struct module_info { static inline int solaris_sockmod(unsigned int fd, unsigned int cmd, u32 arg) { struct inode *ino; + struct fdtable *fdt; /* I wonder which of these tests are superfluous... --patrik */ spin_lock(¤t->files->file_lock); - if (! current->files->fd[fd] || - ! current->files->fd[fd]->f_dentry || - ! (ino = current->files->fd[fd]->f_dentry->d_inode) || + fdt = files_fdtable(current->files); + if (! fdt->fd[fd] || + ! fdt->fd[fd]->f_dentry || + ! (ino = fdt->fd[fd]->f_dentry->d_inode) || ! S_ISSOCK(ino->i_mode)) { spin_unlock(¤t->files->file_lock); return TBADF; diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 6a56ae4..0bfc7af 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -2454,6 +2454,7 @@ static void __do_SAK(void *arg) int i; struct file *filp; struct tty_ldisc *disc; + struct fdtable *fdt; if (!tty) return; @@ -2480,7 +2481,8 @@ static void __do_SAK(void *arg) task_lock(p); if (p->files) { spin_lock(&p->files->file_lock); - for (i=0; i < p->files->max_fds; i++) { + fdt = files_fdtable(p->files); + for (i=0; i < fdt->max_fds; i++) { filp = fcheck_files(p->files, i); if (!filp) continue; diff --git a/fs/exec.c b/fs/exec.c index 222ab1c..14dd039 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -798,6 +798,7 @@ no_thread_group: static inline void flush_old_files(struct files_struct * files) { long j = -1; + struct fdtable *fdt; spin_lock(&files->file_lock); for (;;) { @@ -805,12 +806,13 @@ static inline void flush_old_files(struct files_struct * files) j++; i = j * __NFDBITS; - if (i >= files->max_fds || i >= files->max_fdset) + fdt = files_fdtable(files); + if (i >= fdt->max_fds || i >= fdt->max_fdset) break; - set = files->close_on_exec->fds_bits[j]; + set = fdt->close_on_exec->fds_bits[j]; if (!set) continue; - files->close_on_exec->fds_bits[j] = 0; + fdt->close_on_exec->fds_bits[j] = 0; spin_unlock(&files->file_lock); for ( ; set ; i++,set >>= 1) { if (set & 1) { diff --git a/fs/fcntl.c b/fs/fcntl.c index 6fbc9d8..bfecc62 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -24,20 +24,24 @@ void fastcall set_close_on_exec(unsigned int fd, int flag) { struct files_struct *files = current->files; + struct fdtable *fdt; spin_lock(&files->file_lock); + fdt = files_fdtable(files); if (flag) - FD_SET(fd, files->close_on_exec); + FD_SET(fd, fdt->close_on_exec); else - FD_CLR(fd, files->close_on_exec); + FD_CLR(fd, fdt->close_on_exec); spin_unlock(&files->file_lock); } static inline int get_close_on_exec(unsigned int fd) { struct files_struct *files = current->files; + struct fdtable *fdt; int res; spin_lock(&files->file_lock); - res = FD_ISSET(fd, files->close_on_exec); + fdt = files_fdtable(files); + res = FD_ISSET(fd, fdt->close_on_exec); spin_unlock(&files->file_lock); return res; } @@ -54,24 +58,26 @@ static int locate_fd(struct files_struct *files, unsigned int newfd; unsigned int start; int error; + struct fdtable *fdt; error = -EINVAL; if (orig_start >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) goto out; + fdt = files_fdtable(files); repeat: /* * Someone might have closed fd's in the range - * orig_start..files->next_fd + * orig_start..fdt->next_fd */ start = orig_start; - if (start < files->next_fd) - start = files->next_fd; + if (start < fdt->next_fd) + start = fdt->next_fd; newfd = start; - if (start < files->max_fdset) { - newfd = find_next_zero_bit(files->open_fds->fds_bits, - files->max_fdset, start); + if (start < fdt->max_fdset) { + newfd = find_next_zero_bit(fdt->open_fds->fds_bits, + fdt->max_fdset, start); } error = -EMFILE; @@ -89,8 +95,8 @@ repeat: if (error) goto repeat; - if (start <= files->next_fd) - files->next_fd = newfd + 1; + if (start <= fdt->next_fd) + fdt->next_fd = newfd + 1; error = newfd; @@ -101,13 +107,16 @@ out: static int dupfd(struct file *file, unsigned int start) { struct files_struct * files = current->files; + struct fdtable *fdt; int fd; spin_lock(&files->file_lock); fd = locate_fd(files, file, start); if (fd >= 0) { - FD_SET(fd, files->open_fds); - FD_CLR(fd, files->close_on_exec); + /* locate_fd() may have expanded fdtable, load the ptr */ + fdt = files_fdtable(files); + FD_SET(fd, fdt->open_fds); + FD_CLR(fd, fdt->close_on_exec); spin_unlock(&files->file_lock); fd_install(fd, file); } else { @@ -123,6 +132,7 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd) int err = -EBADF; struct file * file, *tofree; struct files_struct * files = current->files; + struct fdtable *fdt; spin_lock(&files->file_lock); if (!(file = fcheck(oldfd))) @@ -148,13 +158,14 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd) /* Yes. It's a race. In user space. Nothing sane to do */ err = -EBUSY; - tofree = files->fd[newfd]; - if (!tofree && FD_ISSET(newfd, files->open_fds)) + fdt = files_fdtable(files); + tofree = fdt->fd[newfd]; + if (!tofree && FD_ISSET(newfd, fdt->open_fds)) goto out_fput; - files->fd[newfd] = file; - FD_SET(newfd, files->open_fds); - FD_CLR(newfd, files->close_on_exec); + fdt->fd[newfd] = file; + FD_SET(newfd, fdt->open_fds); + FD_CLR(newfd, fdt->close_on_exec); spin_unlock(&files->file_lock); if (tofree) diff --git a/fs/file.c b/fs/file.c index 92b5f25..f5926ce 100644 --- a/fs/file.c +++ b/fs/file.c @@ -59,13 +59,15 @@ static int expand_fd_array(struct files_struct *files, int nr) { struct file **new_fds; int error, nfds; + struct fdtable *fdt; error = -EMFILE; - if (files->max_fds >= NR_OPEN || nr >= NR_OPEN) + fdt = files_fdtable(files); + if (fdt->max_fds >= NR_OPEN || nr >= NR_OPEN) goto out; - nfds = files->max_fds; + nfds = fdt->max_fds; spin_unlock(&files->file_lock); /* @@ -95,13 +97,14 @@ static int expand_fd_array(struct files_struct *files, int nr) goto out; /* Copy the existing array and install the new pointer */ + fdt = files_fdtable(files); - if (nfds > files->max_fds) { + if (nfds > fdt->max_fds) { struct file **old_fds; int i; - old_fds = xchg(&files->fd, new_fds); - i = xchg(&files->max_fds, nfds); + old_fds = xchg(&fdt->fd, new_fds); + i = xchg(&fdt->max_fds, nfds); /* Don't copy/clear the array if we are creating a new fd array for fork() */ @@ -164,12 +167,14 @@ static int expand_fdset(struct files_struct *files, int nr) { fd_set *new_openset = NULL, *new_execset = NULL; int error, nfds = 0; + struct fdtable *fdt; error = -EMFILE; - if (files->max_fdset >= NR_OPEN || nr >= NR_OPEN) + fdt = files_fdtable(files); + if (fdt->max_fdset >= NR_OPEN || nr >= NR_OPEN) goto out; - nfds = files->max_fdset; + nfds = fdt->max_fdset; spin_unlock(&files->file_lock); /* Expand to the max in easy steps */ @@ -193,24 +198,25 @@ static int expand_fdset(struct files_struct *files, int nr) error = 0; /* Copy the existing tables and install the new pointers */ - if (nfds > files->max_fdset) { - int i = files->max_fdset / (sizeof(unsigned long) * 8); - int count = (nfds - files->max_fdset) / 8; + fdt = files_fdtable(files); + if (nfds > fdt->max_fdset) { + int i = fdt->max_fdset / (sizeof(unsigned long) * 8); + int count = (nfds - fdt->max_fdset) / 8; /* * Don't copy the entire array if the current fdset is * not yet initialised. */ if (i) { - memcpy (new_openset, files->open_fds, files->max_fdset/8); - memcpy (new_execset, files->close_on_exec, files->max_fdset/8); + memcpy (new_openset, fdt->open_fds, fdt->max_fdset/8); + memcpy (new_execset, fdt->close_on_exec, fdt->max_fdset/8); memset (&new_openset->fds_bits[i], 0, count); memset (&new_execset->fds_bits[i], 0, count); } - nfds = xchg(&files->max_fdset, nfds); - new_openset = xchg(&files->open_fds, new_openset); - new_execset = xchg(&files->close_on_exec, new_execset); + nfds = xchg(&fdt->max_fdset, nfds); + new_openset = xchg(&fdt->open_fds, new_openset); + new_execset = xchg(&fdt->close_on_exec, new_execset); spin_unlock(&files->file_lock); free_fdset (new_openset, nfds); free_fdset (new_execset, nfds); @@ -237,13 +243,15 @@ out: int expand_files(struct files_struct *files, int nr) { int err, expand = 0; + struct fdtable *fdt; - if (nr >= files->max_fdset) { + fdt = files_fdtable(files); + if (nr >= fdt->max_fdset) { expand = 1; if ((err = expand_fdset(files, nr))) goto out; } - if (nr >= files->max_fds) { + if (nr >= fdt->max_fds) { expand = 1; if ((err = expand_fd_array(files, nr))) goto out; diff --git a/fs/locks.c b/fs/locks.c index 11956b6..c2c09b4 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -2198,21 +2198,23 @@ void steal_locks(fl_owner_t from) { struct files_struct *files = current->files; int i, j; + struct fdtable *fdt; if (from == files) return; lock_kernel(); j = 0; + fdt = files_fdtable(files); for (;;) { unsigned long set; i = j * __NFDBITS; - if (i >= files->max_fdset || i >= files->max_fds) + if (i >= fdt->max_fdset || i >= fdt->max_fds) break; - set = files->open_fds->fds_bits[j++]; + set = fdt->open_fds->fds_bits[j++]; while (set) { if (set & 1) { - struct file *file = files->fd[i]; + struct file *file = fdt->fd[i]; if (file) __steal_locks(file, from); } diff --git a/fs/open.c b/fs/open.c index 4ee2dcc..b654251 100644 --- a/fs/open.c +++ b/fs/open.c @@ -842,14 +842,16 @@ int get_unused_fd(void) { struct files_struct * files = current->files; int fd, error; + struct fdtable *fdt; error = -EMFILE; spin_lock(&files->file_lock); repeat: - fd = find_next_zero_bit(files->open_fds->fds_bits, - files->max_fdset, - files->next_fd); + fdt = files_fdtable(files); + fd = find_next_zero_bit(fdt->open_fds->fds_bits, + fdt->max_fdset, + fdt->next_fd); /* * N.B. For clone tasks sharing a files structure, this test @@ -872,14 +874,14 @@ repeat: goto repeat; } - FD_SET(fd, files->open_fds); - FD_CLR(fd, files->close_on_exec); - files->next_fd = fd + 1; + FD_SET(fd, fdt->open_fds); + FD_CLR(fd, fdt->close_on_exec); + fdt->next_fd = fd + 1; #if 1 /* Sanity check */ - if (files->fd[fd] != NULL) { + if (fdt->fd[fd] != NULL) { printk(KERN_WARNING "get_unused_fd: slot %d not NULL!\n", fd); - files->fd[fd] = NULL; + fdt->fd[fd] = NULL; } #endif error = fd; @@ -893,9 +895,10 @@ EXPORT_SYMBOL(get_unused_fd); static inline void __put_unused_fd(struct files_struct *files, unsigned int fd) { - __FD_CLR(fd, files->open_fds); - if (fd < files->next_fd) - files->next_fd = fd; + struct fdtable *fdt = files_fdtable(files); + __FD_CLR(fd, fdt->open_fds); + if (fd < fdt->next_fd) + fdt->next_fd = fd; } void fastcall put_unused_fd(unsigned int fd) @@ -924,10 +927,12 @@ EXPORT_SYMBOL(put_unused_fd); void fastcall fd_install(unsigned int fd, struct file * file) { struct files_struct *files = current->files; + struct fdtable *fdt; spin_lock(&files->file_lock); - if (unlikely(files->fd[fd] != NULL)) + fdt = files_fdtable(files); + if (unlikely(fdt->fd[fd] != NULL)) BUG(); - files->fd[fd] = file; + fdt->fd[fd] = file; spin_unlock(&files->file_lock); } @@ -1010,15 +1015,17 @@ asmlinkage long sys_close(unsigned int fd) { struct file * filp; struct files_struct *files = current->files; + struct fdtable *fdt; spin_lock(&files->file_lock); - if (fd >= files->max_fds) + fdt = files_fdtable(files); + if (fd >= fdt->max_fds) goto out_unlock; - filp = files->fd[fd]; + filp = fdt->fd[fd]; if (!filp) goto out_unlock; - files->fd[fd] = NULL; - FD_CLR(fd, files->close_on_exec); + fdt->fd[fd] = NULL; + FD_CLR(fd, fdt->close_on_exec); __put_unused_fd(files, fd); spin_unlock(&files->file_lock); return filp_close(filp, files); diff --git a/fs/proc/array.c b/fs/proc/array.c index 37668fe..d88d518 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -159,6 +159,7 @@ static inline char * task_state(struct task_struct *p, char *buffer) { struct group_info *group_info; int g; + struct fdtable *fdt = NULL; read_lock(&tasklist_lock); buffer += sprintf(buffer, @@ -179,10 +180,12 @@ static inline char * task_state(struct task_struct *p, char *buffer) p->gid, p->egid, p->sgid, p->fsgid); read_unlock(&tasklist_lock); task_lock(p); + if (p->files) + fdt = files_fdtable(p->files); buffer += sprintf(buffer, "FDSize:\t%d\n" "Groups:\t", - p->files ? p->files->max_fds : 0); + fdt ? fdt->max_fds : 0); group_info = p->group_info; get_group_info(group_info); diff --git a/fs/proc/base.c b/fs/proc/base.c index 84751f3..d0087a0 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1039,6 +1039,7 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) int retval; char buf[NUMBUF]; struct files_struct * files; + struct fdtable *fdt; retval = -ENOENT; if (!pid_alive(p)) @@ -1062,8 +1063,9 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) if (!files) goto out; spin_lock(&files->file_lock); + fdt = files_fdtable(files); for (fd = filp->f_pos-2; - fd < files->max_fds; + fd < fdt->max_fds; fd++, filp->f_pos++) { unsigned int i,j; diff --git a/fs/select.c b/fs/select.c index b80e7eb..2e56325 100644 --- a/fs/select.c +++ b/fs/select.c @@ -132,11 +132,13 @@ static int max_select_fd(unsigned long n, fd_set_bits *fds) unsigned long *open_fds; unsigned long set; int max; + struct fdtable *fdt; /* handle last in-complete long-word first */ set = ~(~0UL << (n & (__NFDBITS-1))); n /= __NFDBITS; - open_fds = current->files->open_fds->fds_bits+n; + fdt = files_fdtable(current->files); + open_fds = fdt->open_fds->fds_bits+n; max = 0; if (set) { set &= BITS(fds, n); @@ -299,6 +301,7 @@ sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s char *bits; long timeout; int ret, size, max_fdset; + struct fdtable *fdt; timeout = MAX_SCHEDULE_TIMEOUT; if (tvp) { @@ -326,7 +329,8 @@ sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s goto out_nofds; /* max_fdset can increase, so grab it once to avoid race */ - max_fdset = current->files->max_fdset; + fdt = files_fdtable(current->files); + max_fdset = fdt->max_fdset; if (n > max_fdset) n = max_fdset; @@ -464,9 +468,11 @@ asmlinkage long sys_poll(struct pollfd __user * ufds, unsigned int nfds, long ti unsigned int i; struct poll_list *head; struct poll_list *walk; + struct fdtable *fdt; /* Do a sanity check on nfds ... */ - if (nfds > current->files->max_fdset && nfds > OPEN_MAX) + fdt = files_fdtable(current->files); + if (nfds > fdt->max_fdset && nfds > OPEN_MAX) return -EINVAL; if (timeout) { diff --git a/include/linux/file.h b/include/linux/file.h index 5206beb..db37223 100644 --- a/include/linux/file.h +++ b/include/linux/file.h @@ -16,23 +16,29 @@ */ #define NR_OPEN_DEFAULT BITS_PER_LONG +struct fdtable { + unsigned int max_fds; + int max_fdset; + int next_fd; + struct file ** fd; /* current fd array */ + fd_set *close_on_exec; + fd_set *open_fds; +}; + /* * Open file table structure */ struct files_struct { atomic_t count; spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */ - int max_fds; - int max_fdset; - int next_fd; - struct file ** fd; /* current fd array */ - fd_set *close_on_exec; - fd_set *open_fds; + struct fdtable fdtab; fd_set close_on_exec_init; fd_set open_fds_init; struct file * fd_array[NR_OPEN_DEFAULT]; }; +#define files_fdtable(files) (&(files)->fdtab) + extern void FASTCALL(__fput(struct file *)); extern void FASTCALL(fput(struct file *)); @@ -63,9 +69,10 @@ extern int expand_files(struct files_struct *, int nr); static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) { struct file * file = NULL; + struct fdtable *fdt = files_fdtable(files); - if (fd < files->max_fds) - file = files->fd[fd]; + if (fd < fdt->max_fds) + file = fdt->fd[fd]; return file; } diff --git a/include/linux/init_task.h b/include/linux/init_task.h index c727c195..94aefa5 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h @@ -3,16 +3,21 @@ #include -#define INIT_FILES \ -{ \ - .count = ATOMIC_INIT(1), \ - .file_lock = SPIN_LOCK_UNLOCKED, \ +#define INIT_FDTABLE \ +{ \ .max_fds = NR_OPEN_DEFAULT, \ .max_fdset = __FD_SETSIZE, \ .next_fd = 0, \ .fd = &init_files.fd_array[0], \ .close_on_exec = &init_files.close_on_exec_init, \ .open_fds = &init_files.open_fds_init, \ +} + +#define INIT_FILES \ +{ \ + .count = ATOMIC_INIT(1), \ + .file_lock = SPIN_LOCK_UNLOCKED, \ + .fdtab = INIT_FDTABLE, \ .close_on_exec_init = { { 0, } }, \ .open_fds_init = { { 0, } }, \ .fd_array = { NULL, } \ diff --git a/kernel/exit.c b/kernel/exit.c index 5b0fb9f..83beb1e 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -368,17 +368,19 @@ EXPORT_SYMBOL(daemonize); static inline void close_files(struct files_struct * files) { int i, j; + struct fdtable *fdt; j = 0; + fdt = files_fdtable(files); for (;;) { unsigned long set; i = j * __NFDBITS; - if (i >= files->max_fdset || i >= files->max_fds) + if (i >= fdt->max_fdset || i >= fdt->max_fds) break; - set = files->open_fds->fds_bits[j++]; + set = fdt->open_fds->fds_bits[j++]; while (set) { if (set & 1) { - struct file * file = xchg(&files->fd[i], NULL); + struct file * file = xchg(&fdt->fd[i], NULL); if (file) filp_close(file, files); } @@ -403,16 +405,19 @@ struct files_struct *get_files_struct(struct task_struct *task) void fastcall put_files_struct(struct files_struct *files) { + struct fdtable *fdt; + if (atomic_dec_and_test(&files->count)) { close_files(files); /* * Free the fd and fdset arrays if we expanded them. */ - if (files->fd != &files->fd_array[0]) - free_fd_array(files->fd, files->max_fds); - if (files->max_fdset > __FD_SETSIZE) { - free_fdset(files->open_fds, files->max_fdset); - free_fdset(files->close_on_exec, files->max_fdset); + fdt = files_fdtable(files); + if (fdt->fd != &files->fd_array[0]) + free_fd_array(fdt->fd, fdt->max_fds); + if (fdt->max_fdset > __FD_SETSIZE) { + free_fdset(fdt->open_fds, fdt->max_fdset); + free_fdset(fdt->close_on_exec, fdt->max_fdset); } kmem_cache_free(files_cachep, files); } diff --git a/kernel/fork.c b/kernel/fork.c index b258020..ecc694d 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -568,21 +568,47 @@ static inline int copy_fs(unsigned long clone_flags, struct task_struct * tsk) static int count_open_files(struct files_struct *files, int size) { int i; + struct fdtable *fdt; /* Find the last open fd */ + fdt = files_fdtable(files); for (i = size/(8*sizeof(long)); i > 0; ) { - if (files->open_fds->fds_bits[--i]) + if (fdt->open_fds->fds_bits[--i]) break; } i = (i+1) * 8 * sizeof(long); return i; } +static struct files_struct *alloc_files(void) +{ + struct files_struct *newf; + struct fdtable *fdt; + + newf = kmem_cache_alloc(files_cachep, SLAB_KERNEL); + if (!newf) + goto out; + + atomic_set(&newf->count, 1); + + spin_lock_init(&newf->file_lock); + fdt = files_fdtable(newf); + fdt->next_fd = 0; + fdt->max_fds = NR_OPEN_DEFAULT; + fdt->max_fdset = __FD_SETSIZE; + fdt->close_on_exec = &newf->close_on_exec_init; + fdt->open_fds = &newf->open_fds_init; + fdt->fd = &newf->fd_array[0]; +out: + return newf; +} + static int copy_files(unsigned long clone_flags, struct task_struct * tsk) { struct files_struct *oldf, *newf; struct file **old_fds, **new_fds; int open_files, size, i, error = 0, expand; + struct fdtable *old_fdt, *new_fdt; /* * A background process may not have any files ... @@ -603,35 +629,27 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) */ tsk->files = NULL; error = -ENOMEM; - newf = kmem_cache_alloc(files_cachep, SLAB_KERNEL); - if (!newf) + newf = alloc_files(); + if (!newf) goto out; - atomic_set(&newf->count, 1); - - spin_lock_init(&newf->file_lock); - newf->next_fd = 0; - newf->max_fds = NR_OPEN_DEFAULT; - newf->max_fdset = __FD_SETSIZE; - newf->close_on_exec = &newf->close_on_exec_init; - newf->open_fds = &newf->open_fds_init; - newf->fd = &newf->fd_array[0]; - spin_lock(&oldf->file_lock); - - open_files = count_open_files(oldf, oldf->max_fdset); + old_fdt = files_fdtable(oldf); + new_fdt = files_fdtable(newf); + size = old_fdt->max_fdset; + open_files = count_open_files(oldf, old_fdt->max_fdset); expand = 0; /* * Check whether we need to allocate a larger fd array or fd set. * Note: we're not a clone task, so the open count won't change. */ - if (open_files > newf->max_fdset) { - newf->max_fdset = 0; + if (open_files > new_fdt->max_fdset) { + new_fdt->max_fdset = 0; expand = 1; } - if (open_files > newf->max_fds) { - newf->max_fds = 0; + if (open_files > new_fdt->max_fds) { + new_fdt->max_fds = 0; expand = 1; } @@ -646,11 +664,11 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) spin_lock(&oldf->file_lock); } - old_fds = oldf->fd; - new_fds = newf->fd; + old_fds = old_fdt->fd; + new_fds = new_fdt->fd; - memcpy(newf->open_fds->fds_bits, oldf->open_fds->fds_bits, open_files/8); - memcpy(newf->close_on_exec->fds_bits, oldf->close_on_exec->fds_bits, open_files/8); + memcpy(new_fdt->open_fds->fds_bits, old_fdt->open_fds->fds_bits, open_files/8); + memcpy(new_fdt->close_on_exec->fds_bits, old_fdt->close_on_exec->fds_bits, open_files/8); for (i = open_files; i != 0; i--) { struct file *f = *old_fds++; @@ -663,24 +681,24 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) * is partway through open(). So make sure that this * fd is available to the new process. */ - FD_CLR(open_files - i, newf->open_fds); + FD_CLR(open_files - i, new_fdt->open_fds); } *new_fds++ = f; } spin_unlock(&oldf->file_lock); /* compute the remainder to be cleared */ - size = (newf->max_fds - open_files) * sizeof(struct file *); + size = (new_fdt->max_fds - open_files) * sizeof(struct file *); /* This is long word aligned thus could use a optimized version */ memset(new_fds, 0, size); - if (newf->max_fdset > open_files) { - int left = (newf->max_fdset-open_files)/8; + if (new_fdt->max_fdset > open_files) { + int left = (new_fdt->max_fdset-open_files)/8; int start = open_files / (8 * sizeof(unsigned long)); - memset(&newf->open_fds->fds_bits[start], 0, left); - memset(&newf->close_on_exec->fds_bits[start], 0, left); + memset(&new_fdt->open_fds->fds_bits[start], 0, left); + memset(&new_fdt->close_on_exec->fds_bits[start], 0, left); } tsk->files = newf; @@ -689,9 +707,9 @@ out: return error; out_release: - free_fdset (newf->close_on_exec, newf->max_fdset); - free_fdset (newf->open_fds, newf->max_fdset); - free_fd_array(newf->fd, newf->max_fds); + free_fdset (new_fdt->close_on_exec, new_fdt->max_fdset); + free_fdset (new_fdt->open_fds, new_fdt->max_fdset); + free_fd_array(new_fdt->fd, new_fdt->max_fds); kmem_cache_free(files_cachep, newf); goto out; } diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 3f0b533..acb5a49 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1594,6 +1594,7 @@ static inline void flush_unauthorized_files(struct files_struct * files) struct avc_audit_data ad; struct file *file, *devnull = NULL; struct tty_struct *tty = current->signal->tty; + struct fdtable *fdt; long j = -1; if (tty) { @@ -1627,9 +1628,10 @@ static inline void flush_unauthorized_files(struct files_struct * files) j++; i = j * __NFDBITS; - if (i >= files->max_fds || i >= files->max_fdset) + fdt = files_fdtable(files); + if (i >= fdt->max_fds || i >= fdt->max_fdset) break; - set = files->open_fds->fds_bits[j]; + set = fdt->open_fds->fds_bits[j]; if (!set) continue; spin_unlock(&files->file_lock); -- cgit v0.10.2 From 6e72ad2c581de121cc7e772469e2a8f6b1fd4379 Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:12 -0700 Subject: [PATCH] files-sparc64-fix 2 Fix sparc64 timod to use the new files_fdtable() api to get the fd table. This is necessary for RCUification. Signed-off-by: Dipankar Sarma Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/sparc64/solaris/timod.c b/arch/sparc64/solaris/timod.c index 022c80f..aaad29c 100644 --- a/arch/sparc64/solaris/timod.c +++ b/arch/sparc64/solaris/timod.c @@ -143,9 +143,11 @@ static struct T_primsg *timod_mkctl(int size) static void timod_wake_socket(unsigned int fd) { struct socket *sock; + struct fdtable *fdt; SOLD("wakeing socket"); - sock = SOCKET_I(current->files->fd[fd]->f_dentry->d_inode); + fdt = files_fdtable(current->files); + sock = SOCKET_I(fdt->fd[fd]->f_dentry->d_inode); wake_up_interruptible(&sock->wait); read_lock(&sock->sk->sk_callback_lock); if (sock->fasync_list && !test_bit(SOCK_ASYNC_WAITDATA, &sock->flags)) @@ -157,9 +159,11 @@ static void timod_wake_socket(unsigned int fd) static void timod_queue(unsigned int fd, struct T_primsg *it) { struct sol_socket_struct *sock; + struct fdtable *fdt; SOLD("queuing primsg"); - sock = (struct sol_socket_struct *)current->files->fd[fd]->private_data; + fdt = files_fdtable(current->files); + sock = (struct sol_socket_struct *)fdt->fd[fd]->private_data; it->next = sock->pfirst; sock->pfirst = it; if (!sock->plast) @@ -171,9 +175,11 @@ static void timod_queue(unsigned int fd, struct T_primsg *it) static void timod_queue_end(unsigned int fd, struct T_primsg *it) { struct sol_socket_struct *sock; + struct fdtable *fdt; SOLD("queuing primsg at end"); - sock = (struct sol_socket_struct *)current->files->fd[fd]->private_data; + fdt = files_fdtable(current->files); + sock = (struct sol_socket_struct *)fdt->fd[fd]->private_data; it->next = NULL; if (sock->plast) sock->plast->next = it; @@ -344,6 +350,7 @@ int timod_putmsg(unsigned int fd, char __user *ctl_buf, int ctl_len, char *buf; struct file *filp; struct inode *ino; + struct fdtable *fdt; struct sol_socket_struct *sock; mm_segment_t old_fs = get_fs(); long args[6]; @@ -351,7 +358,9 @@ int timod_putmsg(unsigned int fd, char __user *ctl_buf, int ctl_len, (int (*)(int, unsigned long __user *))SYS(socketcall); int (*sys_sendto)(int, void __user *, size_t, unsigned, struct sockaddr __user *, int) = (int (*)(int, void __user *, size_t, unsigned, struct sockaddr __user *, int))SYS(sendto); - filp = current->files->fd[fd]; + + fdt = files_fdtable(current->files); + filp = fdt->fd[fd]; ino = filp->f_dentry->d_inode; sock = (struct sol_socket_struct *)filp->private_data; SOLD("entry"); @@ -620,6 +629,7 @@ int timod_getmsg(unsigned int fd, char __user *ctl_buf, int ctl_maxlen, s32 __us int oldflags; struct file *filp; struct inode *ino; + struct fdtable *fdt; struct sol_socket_struct *sock; struct T_unitdata_ind udi; mm_segment_t old_fs = get_fs(); @@ -632,7 +642,8 @@ int timod_getmsg(unsigned int fd, char __user *ctl_buf, int ctl_maxlen, s32 __us SOLD("entry"); SOLDD(("%u %p %d %p %p %d %p %d\n", fd, ctl_buf, ctl_maxlen, ctl_len, data_buf, data_maxlen, data_len, *flags_p)); - filp = current->files->fd[fd]; + fdt = files_fdtable(current->files); + filp = fdt->fd[fd]; ino = filp->f_dentry->d_inode; sock = (struct sol_socket_struct *)filp->private_data; SOLDD(("%p %p\n", sock->pfirst, sock->pfirst ? sock->pfirst->next : NULL)); @@ -844,12 +855,14 @@ asmlinkage int solaris_getmsg(unsigned int fd, u32 arg1, u32 arg2, u32 arg3) int __user *flgptr; int flags; int error = -EBADF; + struct fdtable *fdt; SOLD("entry"); lock_kernel(); if(fd >= NR_OPEN) goto out; - filp = current->files->fd[fd]; + fdt = files_fdtable(current->files); + filp = fdt->fd[fd]; if(!filp) goto out; ino = filp->f_dentry->d_inode; @@ -910,12 +923,14 @@ asmlinkage int solaris_putmsg(unsigned int fd, u32 arg1, u32 arg2, u32 arg3) struct strbuf ctl, dat; int flags = (int) arg3; int error = -EBADF; + struct fdtable *fdt; SOLD("entry"); lock_kernel(); if(fd >= NR_OPEN) goto out; - filp = current->files->fd[fd]; + fdt = files_fdtable(current->files); + filp = fdt->fd[fd]; if(!filp) goto out; ino = filp->f_dentry->d_inode; -- cgit v0.10.2 From ab2af1f5005069321c5d130f09cce577b03f43ef Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:13 -0700 Subject: [PATCH] files: files struct with RCU Patch to eliminate struct files_struct.file_lock spinlock on the reader side and use rcu refcounting rcuref_xxx api for the f_count refcounter. The updates to the fdtable are done by allocating a new fdtable structure and setting files->fdt to point to the new structure. The fdtable structure is protected by RCU thereby allowing lock-free lookup. For fd arrays/sets that are vmalloced, we use keventd to free them since RCU callbacks can't sleep. A global list of fdtable to be freed is not scalable, so we use a per-cpu list. If keventd is already handling the current cpu's work, we use a timer to defer queueing of that work. Since the last publication, this patch has been re-written to avoid using explicit memory barriers and use rcu_assign_pointer(), rcu_dereference() premitives instead. This required that the fd information is kept in a separate structure (fdtable) and updated atomically. Signed-off-by: Dipankar Sarma Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/aio.c b/fs/aio.c index 201c184..38f6268 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -499,7 +500,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) /* Must be done under the lock to serialise against cancellation. * Call this aio_fput as it duplicates fput via the fput_work. */ - if (unlikely(atomic_dec_and_test(&req->ki_filp->f_count))) { + if (unlikely(rcuref_dec_and_test(&req->ki_filp->f_count))) { get_ioctx(ctx); spin_lock(&fput_lock); list_add(&req->ki_list, &fput_head); diff --git a/fs/fcntl.c b/fs/fcntl.c index bfecc62..d2f3ed8 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -64,8 +65,8 @@ static int locate_fd(struct files_struct *files, if (orig_start >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) goto out; - fdt = files_fdtable(files); repeat: + fdt = files_fdtable(files); /* * Someone might have closed fd's in the range * orig_start..fdt->next_fd @@ -95,9 +96,15 @@ repeat: if (error) goto repeat; + /* + * We reacquired files_lock, so we are safe as long as + * we reacquire the fdtable pointer and use it while holding + * the lock, no one can free it during that time. + */ + fdt = files_fdtable(files); if (start <= fdt->next_fd) fdt->next_fd = newfd + 1; - + error = newfd; out: @@ -163,7 +170,7 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd) if (!tofree && FD_ISSET(newfd, fdt->open_fds)) goto out_fput; - fdt->fd[newfd] = file; + rcu_assign_pointer(fdt->fd[newfd], file); FD_SET(newfd, fdt->open_fds); FD_CLR(newfd, fdt->close_on_exec); spin_unlock(&files->file_lock); diff --git a/fs/file.c b/fs/file.c index f5926ce..2127a7b 100644 --- a/fs/file.c +++ b/fs/file.c @@ -13,6 +13,25 @@ #include #include #include +#include +#include +#include +#include + +struct fdtable_defer { + spinlock_t lock; + struct work_struct wq; + struct timer_list timer; + struct fdtable *next; +}; + +/* + * We use this list to defer free fdtables that have vmalloced + * sets/arrays. By keeping a per-cpu list, we avoid having to embed + * the work_struct in fdtable itself which avoids a 64 byte (i386) increase in + * this per-task structure. + */ +static DEFINE_PER_CPU(struct fdtable_defer, fdtable_defer_list); /* @@ -48,85 +67,143 @@ void free_fd_array(struct file **array, int num) vfree(array); } -/* - * Expand the fd array in the files_struct. Called with the files - * spinlock held for write. - */ - -static int expand_fd_array(struct files_struct *files, int nr) - __releases(files->file_lock) - __acquires(files->file_lock) +static void __free_fdtable(struct fdtable *fdt) { - struct file **new_fds; - int error, nfds; - struct fdtable *fdt; + int fdset_size, fdarray_size; - - error = -EMFILE; - fdt = files_fdtable(files); - if (fdt->max_fds >= NR_OPEN || nr >= NR_OPEN) - goto out; + fdset_size = fdt->max_fdset / 8; + fdarray_size = fdt->max_fds * sizeof(struct file *); + free_fdset(fdt->open_fds, fdset_size); + free_fdset(fdt->close_on_exec, fdset_size); + free_fd_array(fdt->fd, fdarray_size); + kfree(fdt); +} - nfds = fdt->max_fds; - spin_unlock(&files->file_lock); +static void fdtable_timer(unsigned long data) +{ + struct fdtable_defer *fddef = (struct fdtable_defer *)data; - /* - * Expand to the max in easy steps, and keep expanding it until - * we have enough for the requested fd array size. + spin_lock(&fddef->lock); + /* + * If someone already emptied the queue return. */ + if (!fddef->next) + goto out; + if (!schedule_work(&fddef->wq)) + mod_timer(&fddef->timer, 5); +out: + spin_unlock(&fddef->lock); +} - do { -#if NR_OPEN_DEFAULT < 256 - if (nfds < 256) - nfds = 256; - else -#endif - if (nfds < (PAGE_SIZE / sizeof(struct file *))) - nfds = PAGE_SIZE / sizeof(struct file *); - else { - nfds = nfds * 2; - if (nfds > NR_OPEN) - nfds = NR_OPEN; - } - } while (nfds <= nr); +static void free_fdtable_work(struct fdtable_defer *f) +{ + struct fdtable *fdt; - error = -ENOMEM; - new_fds = alloc_fd_array(nfds); - spin_lock(&files->file_lock); - if (!new_fds) - goto out; + spin_lock_bh(&f->lock); + fdt = f->next; + f->next = NULL; + spin_unlock_bh(&f->lock); + while(fdt) { + struct fdtable *next = fdt->next; + __free_fdtable(fdt); + fdt = next; + } +} - /* Copy the existing array and install the new pointer */ - fdt = files_fdtable(files); +static void free_fdtable_rcu(struct rcu_head *rcu) +{ + struct fdtable *fdt = container_of(rcu, struct fdtable, rcu); + int fdset_size, fdarray_size; + struct fdtable_defer *fddef; - if (nfds > fdt->max_fds) { - struct file **old_fds; - int i; - - old_fds = xchg(&fdt->fd, new_fds); - i = xchg(&fdt->max_fds, nfds); - - /* Don't copy/clear the array if we are creating a new - fd array for fork() */ - if (i) { - memcpy(new_fds, old_fds, i * sizeof(struct file *)); - /* clear the remainder of the array */ - memset(&new_fds[i], 0, - (nfds-i) * sizeof(struct file *)); - - spin_unlock(&files->file_lock); - free_fd_array(old_fds, i); - spin_lock(&files->file_lock); - } + BUG_ON(!fdt); + fdset_size = fdt->max_fdset / 8; + fdarray_size = fdt->max_fds * sizeof(struct file *); + + if (fdt->free_files) { + /* + * The this fdtable was embedded in the files structure + * and the files structure itself was getting destroyed. + * It is now safe to free the files structure. + */ + kmem_cache_free(files_cachep, fdt->free_files); + return; + } + if (fdt->max_fdset <= __FD_SETSIZE && fdt->max_fds <= NR_OPEN_DEFAULT) { + /* + * The fdtable was embedded + */ + return; + } + if (fdset_size <= PAGE_SIZE && fdarray_size <= PAGE_SIZE) { + kfree(fdt->open_fds); + kfree(fdt->close_on_exec); + kfree(fdt->fd); + kfree(fdt); } else { - /* Somebody expanded the array while we slept ... */ - spin_unlock(&files->file_lock); - free_fd_array(new_fds, nfds); - spin_lock(&files->file_lock); + fddef = &get_cpu_var(fdtable_defer_list); + spin_lock(&fddef->lock); + fdt->next = fddef->next; + fddef->next = fdt; + /* + * vmallocs are handled from the workqueue context. + * If the per-cpu workqueue is running, then we + * defer work scheduling through a timer. + */ + if (!schedule_work(&fddef->wq)) + mod_timer(&fddef->timer, 5); + spin_unlock(&fddef->lock); + put_cpu_var(fdtable_defer_list); } - error = 0; -out: - return error; +} + +void free_fdtable(struct fdtable *fdt) +{ + if (fdt->free_files || fdt->max_fdset > __FD_SETSIZE || + fdt->max_fds > NR_OPEN_DEFAULT) + call_rcu(&fdt->rcu, free_fdtable_rcu); +} + +/* + * Expand the fdset in the files_struct. Called with the files spinlock + * held for write. + */ +static void copy_fdtable(struct fdtable *nfdt, struct fdtable *fdt) +{ + int i; + int count; + + BUG_ON(nfdt->max_fdset < fdt->max_fdset); + BUG_ON(nfdt->max_fds < fdt->max_fds); + /* Copy the existing tables and install the new pointers */ + + i = fdt->max_fdset / (sizeof(unsigned long) * 8); + count = (nfdt->max_fdset - fdt->max_fdset) / 8; + + /* + * Don't copy the entire array if the current fdset is + * not yet initialised. + */ + if (i) { + memcpy (nfdt->open_fds, fdt->open_fds, + fdt->max_fdset/8); + memcpy (nfdt->close_on_exec, fdt->close_on_exec, + fdt->max_fdset/8); + memset (&nfdt->open_fds->fds_bits[i], 0, count); + memset (&nfdt->close_on_exec->fds_bits[i], 0, count); + } + + /* Don't copy/clear the array if we are creating a new + fd array for fork() */ + if (fdt->max_fds) { + memcpy(nfdt->fd, fdt->fd, + fdt->max_fds * sizeof(struct file *)); + /* clear the remainder of the array */ + memset(&nfdt->fd[fdt->max_fds], 0, + (nfdt->max_fds - fdt->max_fds) * + sizeof(struct file *)); + } + nfdt->next_fd = fdt->next_fd; } /* @@ -157,28 +234,21 @@ void free_fdset(fd_set *array, int num) vfree(array); } -/* - * Expand the fdset in the files_struct. Called with the files spinlock - * held for write. - */ -static int expand_fdset(struct files_struct *files, int nr) - __releases(file->file_lock) - __acquires(file->file_lock) +static struct fdtable *alloc_fdtable(int nr) { - fd_set *new_openset = NULL, *new_execset = NULL; - int error, nfds = 0; - struct fdtable *fdt; - - error = -EMFILE; - fdt = files_fdtable(files); - if (fdt->max_fdset >= NR_OPEN || nr >= NR_OPEN) - goto out; + struct fdtable *fdt = NULL; + int nfds = 0; + fd_set *new_openset = NULL, *new_execset = NULL; + struct file **new_fds; - nfds = fdt->max_fdset; - spin_unlock(&files->file_lock); + fdt = kmalloc(sizeof(*fdt), GFP_KERNEL); + if (!fdt) + goto out; + memset(fdt, 0, sizeof(*fdt)); - /* Expand to the max in easy steps */ - do { + nfds = __FD_SETSIZE; + /* Expand to the max in easy steps */ + do { if (nfds < (PAGE_SIZE * 8)) nfds = PAGE_SIZE * 8; else { @@ -188,50 +258,88 @@ static int expand_fdset(struct files_struct *files, int nr) } } while (nfds <= nr); - error = -ENOMEM; - new_openset = alloc_fdset(nfds); - new_execset = alloc_fdset(nfds); - spin_lock(&files->file_lock); - if (!new_openset || !new_execset) + new_openset = alloc_fdset(nfds); + new_execset = alloc_fdset(nfds); + if (!new_openset || !new_execset) + goto out; + fdt->open_fds = new_openset; + fdt->close_on_exec = new_execset; + fdt->max_fdset = nfds; + + nfds = NR_OPEN_DEFAULT; + /* + * Expand to the max in easy steps, and keep expanding it until + * we have enough for the requested fd array size. + */ + do { +#if NR_OPEN_DEFAULT < 256 + if (nfds < 256) + nfds = 256; + else +#endif + if (nfds < (PAGE_SIZE / sizeof(struct file *))) + nfds = PAGE_SIZE / sizeof(struct file *); + else { + nfds = nfds * 2; + if (nfds > NR_OPEN) + nfds = NR_OPEN; + } + } while (nfds <= nr); + new_fds = alloc_fd_array(nfds); + if (!new_fds) goto out; + fdt->fd = new_fds; + fdt->max_fds = nfds; + fdt->free_files = NULL; + return fdt; +out: + if (new_openset) + free_fdset(new_openset, nfds); + if (new_execset) + free_fdset(new_execset, nfds); + kfree(fdt); + return NULL; +} - error = 0; - - /* Copy the existing tables and install the new pointers */ +/* + * Expands the file descriptor table - it will allocate a new fdtable and + * both fd array and fdset. It is expected to be called with the + * files_lock held. + */ +static int expand_fdtable(struct files_struct *files, int nr) + __releases(files->file_lock) + __acquires(files->file_lock) +{ + int error = 0; + struct fdtable *fdt; + struct fdtable *nfdt = NULL; + + spin_unlock(&files->file_lock); + nfdt = alloc_fdtable(nr); + if (!nfdt) { + error = -ENOMEM; + spin_lock(&files->file_lock); + goto out; + } + + spin_lock(&files->file_lock); fdt = files_fdtable(files); - if (nfds > fdt->max_fdset) { - int i = fdt->max_fdset / (sizeof(unsigned long) * 8); - int count = (nfds - fdt->max_fdset) / 8; - - /* - * Don't copy the entire array if the current fdset is - * not yet initialised. - */ - if (i) { - memcpy (new_openset, fdt->open_fds, fdt->max_fdset/8); - memcpy (new_execset, fdt->close_on_exec, fdt->max_fdset/8); - memset (&new_openset->fds_bits[i], 0, count); - memset (&new_execset->fds_bits[i], 0, count); - } - - nfds = xchg(&fdt->max_fdset, nfds); - new_openset = xchg(&fdt->open_fds, new_openset); - new_execset = xchg(&fdt->close_on_exec, new_execset); + /* + * Check again since another task may have expanded the + * fd table while we dropped the lock + */ + if (nr >= fdt->max_fds || nr >= fdt->max_fdset) { + copy_fdtable(nfdt, fdt); + } else { + /* Somebody expanded while we dropped file_lock */ spin_unlock(&files->file_lock); - free_fdset (new_openset, nfds); - free_fdset (new_execset, nfds); + __free_fdtable(nfdt); spin_lock(&files->file_lock); - return 0; - } - /* Somebody expanded the array while we slept ... */ - + goto out; + } + rcu_assign_pointer(files->fdt, nfdt); + free_fdtable(fdt); out: - spin_unlock(&files->file_lock); - if (new_openset) - free_fdset(new_openset, nfds); - if (new_execset) - free_fdset(new_execset, nfds); - spin_lock(&files->file_lock); return error; } @@ -246,17 +354,36 @@ int expand_files(struct files_struct *files, int nr) struct fdtable *fdt; fdt = files_fdtable(files); - if (nr >= fdt->max_fdset) { - expand = 1; - if ((err = expand_fdset(files, nr))) + if (nr >= fdt->max_fdset || nr >= fdt->max_fds) { + if (fdt->max_fdset >= NR_OPEN || + fdt->max_fds >= NR_OPEN || nr >= NR_OPEN) { + err = -EMFILE; goto out; - } - if (nr >= fdt->max_fds) { + } expand = 1; - if ((err = expand_fd_array(files, nr))) + if ((err = expand_fdtable(files, nr))) goto out; } err = expand; out: return err; } + +static void __devinit fdtable_defer_list_init(int cpu) +{ + struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu); + spin_lock_init(&fddef->lock); + INIT_WORK(&fddef->wq, (void (*)(void *))free_fdtable_work, fddef); + init_timer(&fddef->timer); + fddef->timer.data = (unsigned long)fddef; + fddef->timer.function = fdtable_timer; + fddef->next = NULL; +} + +void __init files_defer_init(void) +{ + int i; + /* Really early - can't use for_each_cpu */ + for (i = 0; i < NR_CPUS; i++) + fdtable_defer_list_init(i); +} diff --git a/fs/file_table.c b/fs/file_table.c index 43e9e17..86ec8ae 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -53,11 +54,17 @@ void filp_dtor(void * objp, struct kmem_cache_s *cachep, unsigned long dflags) spin_unlock_irqrestore(&filp_count_lock, flags); } -static inline void file_free(struct file *f) +static inline void file_free_rcu(struct rcu_head *head) { + struct file *f = container_of(head, struct file, f_rcuhead); kmem_cache_free(filp_cachep, f); } +static inline void file_free(struct file *f) +{ + call_rcu(&f->f_rcuhead, file_free_rcu); +} + /* Find an unused file structure and return a pointer to it. * Returns NULL, if there are no more free file structures or * we run out of memory. @@ -110,7 +117,7 @@ EXPORT_SYMBOL(get_empty_filp); void fastcall fput(struct file *file) { - if (atomic_dec_and_test(&file->f_count)) + if (rcuref_dec_and_test(&file->f_count)) __fput(file); } @@ -156,11 +163,17 @@ struct file fastcall *fget(unsigned int fd) struct file *file; struct files_struct *files = current->files; - spin_lock(&files->file_lock); + rcu_read_lock(); file = fcheck_files(files, fd); - if (file) - get_file(file); - spin_unlock(&files->file_lock); + if (file) { + if (!rcuref_inc_lf(&file->f_count)) { + /* File object ref couldn't be taken */ + rcu_read_unlock(); + return NULL; + } + } + rcu_read_unlock(); + return file; } @@ -182,21 +195,25 @@ struct file fastcall *fget_light(unsigned int fd, int *fput_needed) if (likely((atomic_read(&files->count) == 1))) { file = fcheck_files(files, fd); } else { - spin_lock(&files->file_lock); + rcu_read_lock(); file = fcheck_files(files, fd); if (file) { - get_file(file); - *fput_needed = 1; + if (rcuref_inc_lf(&file->f_count)) + *fput_needed = 1; + else + /* Didn't get the reference, someone's freed */ + file = NULL; } - spin_unlock(&files->file_lock); + rcu_read_unlock(); } + return file; } void put_filp(struct file *file) { - if (atomic_dec_and_test(&file->f_count)) { + if (rcuref_dec_and_test(&file->f_count)) { security_file_free(file); file_kill(file); file_free(file); @@ -257,4 +274,5 @@ void __init files_init(unsigned long mempages) files_stat.max_files = n; if (files_stat.max_files < NR_FILE) files_stat.max_files = NR_FILE; + files_defer_init(); } diff --git a/fs/open.c b/fs/open.c index b654251..2fac58c 100644 --- a/fs/open.c +++ b/fs/open.c @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -930,9 +931,8 @@ void fastcall fd_install(unsigned int fd, struct file * file) struct fdtable *fdt; spin_lock(&files->file_lock); fdt = files_fdtable(files); - if (unlikely(fdt->fd[fd] != NULL)) - BUG(); - fdt->fd[fd] = file; + BUG_ON(fdt->fd[fd] != NULL); + rcu_assign_pointer(fdt->fd[fd], file); spin_unlock(&files->file_lock); } @@ -1024,7 +1024,7 @@ asmlinkage long sys_close(unsigned int fd) filp = fdt->fd[fd]; if (!filp) goto out_unlock; - fdt->fd[fd] = NULL; + rcu_assign_pointer(fdt->fd[fd], NULL); FD_CLR(fd, fdt->close_on_exec); __put_unused_fd(files, fd); spin_unlock(&files->file_lock); diff --git a/include/linux/file.h b/include/linux/file.h index db37223..f5bbd4c 100644 --- a/include/linux/file.h +++ b/include/linux/file.h @@ -9,6 +9,7 @@ #include #include #include +#include /* * The default fd array needs to be at least BITS_PER_LONG, @@ -23,6 +24,9 @@ struct fdtable { struct file ** fd; /* current fd array */ fd_set *close_on_exec; fd_set *open_fds; + struct rcu_head rcu; + struct files_struct *free_files; + struct fdtable *next; }; /* @@ -31,13 +35,14 @@ struct fdtable { struct files_struct { atomic_t count; spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */ + struct fdtable *fdt; struct fdtable fdtab; fd_set close_on_exec_init; fd_set open_fds_init; struct file * fd_array[NR_OPEN_DEFAULT]; }; -#define files_fdtable(files) (&(files)->fdtab) +#define files_fdtable(files) (rcu_dereference((files)->fdt)) extern void FASTCALL(__fput(struct file *)); extern void FASTCALL(fput(struct file *)); @@ -65,6 +70,8 @@ extern fd_set *alloc_fdset(int); extern void free_fdset(fd_set *, int); extern int expand_files(struct files_struct *, int nr); +extern void free_fdtable(struct fdtable *fdt); +extern void __init files_defer_init(void); static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) { @@ -72,7 +79,7 @@ static inline struct file * fcheck_files(struct files_struct *files, unsigned in struct fdtable *fdt = files_fdtable(files); if (fd < fdt->max_fds) - file = fdt->fd[fd]; + file = rcu_dereference(fdt->fd[fd]); return file; } diff --git a/include/linux/fs.h b/include/linux/fs.h index fd93ab7..7f61227 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -9,6 +9,7 @@ #include #include #include +#include /* * It's silly to have NR_OPEN bigger than NR_FILE, but you can change @@ -597,12 +598,13 @@ struct file { spinlock_t f_ep_lock; #endif /* #ifdef CONFIG_EPOLL */ struct address_space *f_mapping; + struct rcu_head f_rcuhead; }; extern spinlock_t files_lock; #define file_list_lock() spin_lock(&files_lock); #define file_list_unlock() spin_unlock(&files_lock); -#define get_file(x) atomic_inc(&(x)->f_count) +#define get_file(x) rcuref_inc(&(x)->f_count) #define file_count(x) atomic_read(&(x)->f_count) #define MAX_NON_LFS ((1UL<<31) - 1) diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 94aefa5..68ab5f2 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h @@ -2,6 +2,7 @@ #define _LINUX__INIT_TASK_H #include +#include #define INIT_FDTABLE \ { \ @@ -11,12 +12,16 @@ .fd = &init_files.fd_array[0], \ .close_on_exec = &init_files.close_on_exec_init, \ .open_fds = &init_files.open_fds_init, \ + .rcu = RCU_HEAD_INIT, \ + .free_files = NULL, \ + .next = NULL, \ } #define INIT_FILES \ { \ .count = ATOMIC_INIT(1), \ .file_lock = SPIN_LOCK_UNLOCKED, \ + .fdt = &init_files.fdtab, \ .fdtab = INIT_FDTABLE, \ .close_on_exec_init = { { 0, } }, \ .open_fds_init = { { 0, } }, \ diff --git a/kernel/exit.c b/kernel/exit.c index 83beb1e..6d2089a 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -411,15 +411,16 @@ void fastcall put_files_struct(struct files_struct *files) close_files(files); /* * Free the fd and fdset arrays if we expanded them. + * If the fdtable was embedded, pass files for freeing + * at the end of the RCU grace period. Otherwise, + * you can free files immediately. */ fdt = files_fdtable(files); - if (fdt->fd != &files->fd_array[0]) - free_fd_array(fdt->fd, fdt->max_fds); - if (fdt->max_fdset > __FD_SETSIZE) { - free_fdset(fdt->open_fds, fdt->max_fdset); - free_fdset(fdt->close_on_exec, fdt->max_fdset); - } - kmem_cache_free(files_cachep, files); + if (fdt == &files->fdtab) + fdt->free_files = files; + else + kmem_cache_free(files_cachep, files); + free_fdtable(fdt); } } diff --git a/kernel/fork.c b/kernel/fork.c index ecc694d..8149f36 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -565,13 +566,12 @@ static inline int copy_fs(unsigned long clone_flags, struct task_struct * tsk) return 0; } -static int count_open_files(struct files_struct *files, int size) +static int count_open_files(struct fdtable *fdt) { + int size = fdt->max_fdset; int i; - struct fdtable *fdt; /* Find the last open fd */ - fdt = files_fdtable(files); for (i = size/(8*sizeof(long)); i > 0; ) { if (fdt->open_fds->fds_bits[--i]) break; @@ -592,13 +592,17 @@ static struct files_struct *alloc_files(void) atomic_set(&newf->count, 1); spin_lock_init(&newf->file_lock); - fdt = files_fdtable(newf); + fdt = &newf->fdtab; fdt->next_fd = 0; fdt->max_fds = NR_OPEN_DEFAULT; fdt->max_fdset = __FD_SETSIZE; fdt->close_on_exec = &newf->close_on_exec_init; fdt->open_fds = &newf->open_fds_init; fdt->fd = &newf->fd_array[0]; + INIT_RCU_HEAD(&fdt->rcu); + fdt->free_files = NULL; + fdt->next = NULL; + rcu_assign_pointer(newf->fdt, fdt); out: return newf; } @@ -637,7 +641,7 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) old_fdt = files_fdtable(oldf); new_fdt = files_fdtable(newf); size = old_fdt->max_fdset; - open_files = count_open_files(oldf, old_fdt->max_fdset); + open_files = count_open_files(old_fdt); expand = 0; /* @@ -661,7 +665,14 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) spin_unlock(&newf->file_lock); if (error < 0) goto out_release; + new_fdt = files_fdtable(newf); + /* + * Reacquire the oldf lock and a pointer to its fd table + * who knows it may have a new bigger fd table. We need + * the latest pointer. + */ spin_lock(&oldf->file_lock); + old_fdt = files_fdtable(oldf); } old_fds = old_fdt->fd; @@ -683,7 +694,7 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) */ FD_CLR(open_files - i, new_fdt->open_fds); } - *new_fds++ = f; + rcu_assign_pointer(*new_fds++, f); } spin_unlock(&oldf->file_lock); -- cgit v0.10.2 From b835996f628eadb55c5fb222ba46fe9395bf73c7 Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:14 -0700 Subject: [PATCH] files: lock-free fd look-up With the use of RCU in files structure, the look-up of files using fds can now be lock-free. The lookup is protected by rcu_read_lock()/rcu_read_unlock(). This patch changes the readers to use lock-free lookup. Signed-off-by: Maneesh Soni Signed-off-by: Ravikiran Thirumalai Signed-off-by: Dipankar Sarma Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/mips/kernel/irixioctl.c b/arch/mips/kernel/irixioctl.c index 4cd3d38..3cdc223 100644 --- a/arch/mips/kernel/irixioctl.c +++ b/arch/mips/kernel/irixioctl.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -33,7 +34,7 @@ static struct tty_struct *get_tty(int fd) struct file *filp; struct tty_struct *ttyp = NULL; - spin_lock(¤t->files->file_lock); + rcu_read_lock(); filp = fcheck(fd); if(filp && filp->private_data) { ttyp = (struct tty_struct *) filp->private_data; @@ -41,7 +42,7 @@ static struct tty_struct *get_tty(int fd) if(ttyp->magic != TTY_MAGIC) ttyp =NULL; } - spin_unlock(¤t->files->file_lock); + rcu_read_unlock(); return ttyp; } diff --git a/arch/sparc64/solaris/ioctl.c b/arch/sparc64/solaris/ioctl.c index 3747664..be0a054 100644 --- a/arch/sparc64/solaris/ioctl.c +++ b/arch/sparc64/solaris/ioctl.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -295,16 +296,16 @@ static inline int solaris_sockmod(unsigned int fd, unsigned int cmd, u32 arg) struct inode *ino; struct fdtable *fdt; /* I wonder which of these tests are superfluous... --patrik */ - spin_lock(¤t->files->file_lock); + rcu_read_lock(); fdt = files_fdtable(current->files); if (! fdt->fd[fd] || ! fdt->fd[fd]->f_dentry || ! (ino = fdt->fd[fd]->f_dentry->d_inode) || ! S_ISSOCK(ino->i_mode)) { - spin_unlock(¤t->files->file_lock); + rcu_read_unlock(); return TBADF; } - spin_unlock(¤t->files->file_lock); + rcu_read_unlock(); switch (cmd & 0xff) { case 109: /* SI_SOCKPARAMS */ diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 0bfc7af..e5953f3 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -2480,7 +2480,7 @@ static void __do_SAK(void *arg) } task_lock(p); if (p->files) { - spin_lock(&p->files->file_lock); + rcu_read_lock(); fdt = files_fdtable(p->files); for (i=0; i < fdt->max_fds; i++) { filp = fcheck_files(p->files, i); @@ -2495,7 +2495,7 @@ static void __do_SAK(void *arg) break; } } - spin_unlock(&p->files->file_lock); + rcu_read_unlock(); } task_unlock(p); } while_each_task_pid(session, PIDTYPE_SID, p); diff --git a/fs/fcntl.c b/fs/fcntl.c index d2f3ed8..863b46e 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -40,10 +40,10 @@ static inline int get_close_on_exec(unsigned int fd) struct files_struct *files = current->files; struct fdtable *fdt; int res; - spin_lock(&files->file_lock); + rcu_read_lock(); fdt = files_fdtable(files); res = FD_ISSET(fd, fdt->close_on_exec); - spin_unlock(&files->file_lock); + rcu_read_unlock(); return res; } diff --git a/fs/proc/base.c b/fs/proc/base.c index d0087a0..23db452 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -283,16 +284,16 @@ static int proc_fd_link(struct inode *inode, struct dentry **dentry, struct vfsm files = get_files_struct(task); if (files) { - spin_lock(&files->file_lock); + rcu_read_lock(); file = fcheck_files(files, fd); if (file) { *mnt = mntget(file->f_vfsmnt); *dentry = dget(file->f_dentry); - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); return 0; } - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); } return -ENOENT; @@ -1062,7 +1063,7 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) files = get_files_struct(p); if (!files) goto out; - spin_lock(&files->file_lock); + rcu_read_lock(); fdt = files_fdtable(files); for (fd = filp->f_pos-2; fd < fdt->max_fds; @@ -1071,7 +1072,7 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) if (!fcheck_files(files, fd)) continue; - spin_unlock(&files->file_lock); + rcu_read_unlock(); j = NUMBUF; i = fd; @@ -1083,12 +1084,12 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) ino = fake_ino(tid, PROC_TID_FD_DIR + fd); if (filldir(dirent, buf+j, NUMBUF-j, fd+2, ino, DT_LNK) < 0) { - spin_lock(&files->file_lock); + rcu_read_lock(); break; } - spin_lock(&files->file_lock); + rcu_read_lock(); } - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); } out: @@ -1263,9 +1264,9 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd) files = get_files_struct(task); if (files) { - spin_lock(&files->file_lock); + rcu_read_lock(); if (fcheck_files(files, fd)) { - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); if (task_dumpable(task)) { inode->i_uid = task->euid; @@ -1277,7 +1278,7 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd) security_task_to_inode(task, inode); return 1; } - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); } d_drop(dentry); @@ -1369,7 +1370,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry, if (!files) goto out_unlock; inode->i_mode = S_IFLNK; - spin_lock(&files->file_lock); + rcu_read_lock(); file = fcheck_files(files, fd); if (!file) goto out_unlock2; @@ -1377,7 +1378,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry, inode->i_mode |= S_IRUSR | S_IXUSR; if (file->f_mode & 2) inode->i_mode |= S_IWUSR | S_IXUSR; - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); inode->i_op = &proc_pid_link_inode_operations; inode->i_size = 64; @@ -1387,7 +1388,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry, return NULL; out_unlock2: - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); out_unlock: iput(inode); diff --git a/fs/select.c b/fs/select.c index 2e56325..f10a103 100644 --- a/fs/select.c +++ b/fs/select.c @@ -22,6 +22,7 @@ #include /* for STICKY_TIMEOUTS */ #include #include +#include #include @@ -185,9 +186,9 @@ int do_select(int n, fd_set_bits *fds, long *timeout) int retval, i; long __timeout = *timeout; - spin_lock(¤t->files->file_lock); + rcu_read_lock(); retval = max_select_fd(n, fds); - spin_unlock(¤t->files->file_lock); + rcu_read_unlock(); if (retval < 0) return retval; @@ -329,8 +330,10 @@ sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s goto out_nofds; /* max_fdset can increase, so grab it once to avoid race */ + rcu_read_lock(); fdt = files_fdtable(current->files); max_fdset = fdt->max_fdset; + rcu_read_unlock(); if (n > max_fdset) n = max_fdset; @@ -469,10 +472,14 @@ asmlinkage long sys_poll(struct pollfd __user * ufds, unsigned int nfds, long ti struct poll_list *head; struct poll_list *walk; struct fdtable *fdt; + int max_fdset; /* Do a sanity check on nfds ... */ + rcu_read_lock(); fdt = files_fdtable(current->files); - if (nfds > fdt->max_fdset && nfds > OPEN_MAX) + max_fdset = fdt->max_fdset; + rcu_read_unlock(); + if (nfds > max_fdset && nfds > OPEN_MAX) return -EINVAL; if (timeout) { diff --git a/net/ipv4/netfilter/ipt_owner.c b/net/ipv4/netfilter/ipt_owner.c index c1889f8..0cee286 100644 --- a/net/ipv4/netfilter/ipt_owner.c +++ b/net/ipv4/netfilter/ipt_owner.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/net/ipv6/netfilter/ip6t_owner.c b/net/ipv6/netfilter/ip6t_owner.c index 9b91dec..4de4cda 100644 --- a/net/ipv6/netfilter/ip6t_owner.c +++ b/net/ipv6/netfilter/ip6t_owner.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index acb5a49..f40c822 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1652,7 +1652,7 @@ static inline void flush_unauthorized_files(struct files_struct * files) continue; } if (devnull) { - atomic_inc(&devnull->f_count); + rcuref_inc(&devnull->f_count); } else { devnull = dentry_open(dget(selinux_null), mntget(selinuxfs_mount), O_RDWR); if (!devnull) { -- cgit v0.10.2 From 2822541893d88f84dd4f1525108d73effecd9d39 Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:15 -0700 Subject: [PATCH] files: files locking doc Add documentation describing the new locking scheme for file descriptor table. Signed-off-by: Dipankar Sarma Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/filesystems/files.txt b/Documentation/filesystems/files.txt new file mode 100644 index 0000000..8c206f4 --- /dev/null +++ b/Documentation/filesystems/files.txt @@ -0,0 +1,123 @@ +File management in the Linux kernel +----------------------------------- + +This document describes how locking for files (struct file) +and file descriptor table (struct files) works. + +Up until 2.6.12, the file descriptor table has been protected +with a lock (files->file_lock) and reference count (files->count). +->file_lock protected accesses to all the file related fields +of the table. ->count was used for sharing the file descriptor +table between tasks cloned with CLONE_FILES flag. Typically +this would be the case for posix threads. As with the common +refcounting model in the kernel, the last task doing +a put_files_struct() frees the file descriptor (fd) table. +The files (struct file) themselves are protected using +reference count (->f_count). + +In the new lock-free model of file descriptor management, +the reference counting is similar, but the locking is +based on RCU. The file descriptor table contains multiple +elements - the fd sets (open_fds and close_on_exec, the +array of file pointers, the sizes of the sets and the array +etc.). In order for the updates to appear atomic to +a lock-free reader, all the elements of the file descriptor +table are in a separate structure - struct fdtable. +files_struct contains a pointer to struct fdtable through +which the actual fd table is accessed. Initially the +fdtable is embedded in files_struct itself. On a subsequent +expansion of fdtable, a new fdtable structure is allocated +and files->fdtab points to the new structure. The fdtable +structure is freed with RCU and lock-free readers either +see the old fdtable or the new fdtable making the update +appear atomic. Here are the locking rules for +the fdtable structure - + +1. All references to the fdtable must be done through + the files_fdtable() macro : + + struct fdtable *fdt; + + rcu_read_lock(); + + fdt = files_fdtable(files); + .... + if (n <= fdt->max_fds) + .... + ... + rcu_read_unlock(); + + files_fdtable() uses rcu_dereference() macro which takes care of + the memory barrier requirements for lock-free dereference. + The fdtable pointer must be read within the read-side + critical section. + +2. Reading of the fdtable as described above must be protected + by rcu_read_lock()/rcu_read_unlock(). + +3. For any update to the the fd table, files->file_lock must + be held. + +4. To look up the file structure given an fd, a reader + must use either fcheck() or fcheck_files() APIs. These + take care of barrier requirements due to lock-free lookup. + An example : + + struct file *file; + + rcu_read_lock(); + file = fcheck(fd); + if (file) { + ... + } + .... + rcu_read_unlock(); + +5. Handling of the file structures is special. Since the look-up + of the fd (fget()/fget_light()) are lock-free, it is possible + that look-up may race with the last put() operation on the + file structure. This is avoided using the rcuref APIs + on ->f_count : + + rcu_read_lock(); + file = fcheck_files(files, fd); + if (file) { + if (rcuref_inc_lf(&file->f_count)) + *fput_needed = 1; + else + /* Didn't get the reference, someone's freed */ + file = NULL; + } + rcu_read_unlock(); + .... + return file; + + rcuref_inc_lf() detects if refcounts is already zero or + goes to zero during increment. If it does, we fail + fget()/fget_light(). + +6. Since both fdtable and file structures can be looked up + lock-free, they must be installed using rcu_assign_pointer() + API. If they are looked up lock-free, rcu_dereference() + must be used. However it is advisable to use files_fdtable() + and fcheck()/fcheck_files() which take care of these issues. + +7. While updating, the fdtable pointer must be looked up while + holding files->file_lock. If ->file_lock is dropped, then + another thread expand the files thereby creating a new + fdtable and making the earlier fdtable pointer stale. + For example : + + spin_lock(&files->file_lock); + fd = locate_fd(files, file, start); + if (fd >= 0) { + /* locate_fd() may have expanded fdtable, load the ptr */ + fdt = files_fdtable(files); + FD_SET(fd, fdt->open_fds); + FD_CLR(fd, fdt->close_on_exec); + spin_unlock(&files->file_lock); + ..... + + Since locate_fd() can drop ->file_lock (and reacquire ->file_lock), + the fdtable pointer (fdt) must be loaded after locate_fd(). + -- cgit v0.10.2 From 93fa58cb831337fdf5d36b3b913441100a484dae Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:18 -0700 Subject: [PATCH] v9fs: Documentation, Makefiles, Configuration OVERVIEW V9FS is a distributed file system for Linux which provides an implementation of the Plan 9 resource sharing protocol 9P. It can be used to share all sorts of resources: static files, synthetic file servers (such as /proc or /sys), devices, and application file servers (such as FUSE). BACKGROUND Plan 9 (http://plan9.bell-labs.com/plan9) is a research operating system and associated applications suite developed by the Computing Science Research Center of AT&T Bell Laboratories (now a part of Lucent Technologies), the same group that developed UNIX , C, and C++. Plan 9 was initially released in 1993 to universities, and then made generally available in 1995. Its core operating systems code laid the foundation for the Inferno Operating System released as a product by Lucent Bell-Labs in 1997. The Inferno venture was the only commercial embodiment of Plan 9 and is currently maintained as a product by Vita Nuova (http://www.vitanuova.com). After updated releases in 2000 and 2002, Plan 9 was open-sourced under the OSI approved Lucent Public License in 2003. The Plan 9 project was started by Ken Thompson and Rob Pike in 1985. Their intent was to explore potential solutions to some of the shortcomings of UNIX in the face of the widespread use of high-speed networks to connect machines. In UNIX, networking was an afterthought and UNIX clusters became little more than a network of stand-alone systems. Plan 9 was designed from first principles as a seamless distributed system with integrated secure network resource sharing. Applications and services were architected in such a way as to allow for implicit distribution across a cluster of systems. Configuring an environment to use remote application components or services in place of their local equivalent could be achieved with a few simple command line instructions. For the most part, application implementations operated independent of the location of their actual resources. Commercial operating systems haven't changed much in the 20 years since Plan 9 was conceived. Network and distributed systems support is provided by a patchwork of middle-ware, with an endless number of packages supplying pieces of the puzzle. Matters are complicated by the use of different complicated protocols for individual services, and separate implementations for kernel and application resources. The V9FS project (http://v9fs.sourceforge.net) is an attempt to bring Plan 9's unified approach to resource sharing to Linux and other operating systems via support for the 9P2000 resource sharing protocol. V9FS HISTORY V9FS was originally developed by Ron Minnich and Maya Gokhale at Los Alamos National Labs (LANL) in 1997. In November of 2001, Greg Watson setup a SourceForge project as a public repository for the code which supported the Linux 2.4 kernel. About a year ago, I picked up the initial attempt Ron Minnich had made to provide 2.6 support and got the code integrated into a 2.6.5 kernel. I then went through a line-for-line re-write attempting to clean-up the code while more closely following the Linux Kernel style guidelines. I co-authored a paper with Ron Minnich on the V9FS Linux support including performance comparisons to NFSv3 using Bonnie and PostMark - this paper appeared at the USENIX/FREENIX 2005 conference in April 2005: ( http://www.usenix.org/events/usenix05/tech/freenix/hensbergen.html ). CALL FOR PARTICIPATION/REQUEST FOR COMMENTS Our 2.6 kernel support is stabilizing and we'd like to begin pursuing its integration into the official kernel tree. We would appreciate any review, comments, critiques, and additions from this community and are actively seeking people to join our project and help us produce something that would be acceptable and useful to the Linux community. STATUS The code is reasonably stable, although there are no doubt corner cases our regression tests haven't discovered yet. It is in regular use by several of the developers and has been tested on x86 and PowerPC (32-bit and 64-bit) in both small and large (LANL cluster) deployments. Our current regression tests include fsx, bonnie, and postmark. It was our intention to keep things as simple as possible for this release -- trying to focus on correctness within the core of the protocol support versus a rich set of features. For example: a more complete security model and cache layer are in the road map, but excluded from this release. Additionally, we have removed support for mmap operations at Al Viro's request. PERFORMANCE Detailed performance numbers and analysis are included in the FREENIX paper, but we show comparable performance to NFSv3 for large file operations based on the Bonnie benchmark, and superior performance for many small file operations based on the PostMark benchmark. Somewhat preliminary graphs (from the FREENIX paper) are available (http://v9fs.sourceforge.net/perf/index.html). RESOURCES The source code is available in a few different forms: tarballs: http://v9fs.sf.net CVSweb: http://cvs.sourceforge.net/viewcvs.py/v9fs/linux-9p/ CVS: :pserver:anonymous@cvs.sourceforge.net:/cvsroot/v9fs/linux-9p Git: rsync://v9fs.graverobber.org/v9fs (webgit: http://v9fs.graverobber.org) 9P: tcp!v9fs.graverobber.org!6564 The user-level server is available from either the Plan 9 distribution or from http://v9fs.sf.net Other support applications are still being developed, but preliminary version can be downloaded from sourceforge. Documentation on the protocol has historically been the Plan 9 Man pages (http://plan9.bell-labs.com/sys/man/5/INDEX.html), but there is an effort under way to write a more complete Internet-Draft style specification (http://v9fs.sf.net/rfc). There are a couple of mailing lists supporting v9fs, but the most used is v9fs-developer@lists.sourceforge.net -- please direct/cc your comments there so the other v9fs contibutors can participate in the conversation. There is also an IRC channel: irc://freenode.net/#v9fs This part of the patch contains Documentation, Makefiles, and configuration file changes. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/filesystems/v9fs.txt b/Documentation/filesystems/v9fs.txt new file mode 100644 index 0000000..4e92feb --- /dev/null +++ b/Documentation/filesystems/v9fs.txt @@ -0,0 +1,95 @@ + V9FS: 9P2000 for Linux + ====================== + +ABOUT +===== + +v9fs is a Unix implementation of the Plan 9 9p remote filesystem protocol. + +This software was originally developed by Ron Minnich +and Maya Gokhale . Additional development by Greg Watson + and most recently Eric Van Hensbergen + and Latchesar Ionkov . + +USAGE +===== + +For remote file server: + + mount -t 9P 10.10.1.2 /mnt/9 + +For Plan 9 From User Space applications (http://swtch.com/plan9) + + mount -t 9P `namespace`/acme /mnt/9 -o proto=unix,name=$USER + +OPTIONS +======= + + proto=name select an alternative transport. Valid options are + currently: + unix - specifying a named pipe mount point + tcp - specifying a normal TCP/IP connection + fd - used passed file descriptors for connection + (see rfdno and wfdno) + + name=name user name to attempt mount as on the remote server. The + server may override or ignore this value. Certain user + names may require authentication. + + aname=name aname specifies the file tree to access when the server is + offering several exported file systems. + + debug=n specifies debug level. The debug level is a bitmask. + 0x01 = display verbose error messages + 0x02 = developer debug (DEBUG_CURRENT) + 0x04 = display 9P trace + 0x08 = display VFS trace + 0x10 = display Marshalling debug + 0x20 = display RPC debug + 0x40 = display transport debug + 0x80 = display allocation debug + + rfdno=n the file descriptor for reading with proto=fd + + wfdno=n the file descriptor for writing with proto=fd + + maxdata=n the number of bytes to use for 9P packet payload (msize) + + port=n port to connect to on the remote server + + timeout=n request timeouts (in ms) (default 60000ms) + + noextend force legacy mode (no 9P2000.u semantics) + + uid attempt to mount as a particular uid + + gid attempt to mount with a particular gid + + afid security channel - used by Plan 9 authentication protocols + + nodevmap do not map special files - represent them as normal files. + This can be used to share devices/named pipes/sockets between + hosts. This functionality will be expanded in later versions. + +RESOURCES +========= + +The Linux version of the 9P server, along with some client-side utilities +can be found at http://v9fs.sf.net (along with a CVS repository of the +development branch of this module). There are user and developer mailing +lists here, as well as a bug-tracker. + +For more information on the Plan 9 Operating System check out +http://plan9.bell-labs.com/plan9 + +For information on Plan 9 from User Space (Plan 9 applications and libraries +ported to Linux/BSD/OSX/etc) check out http://swtch.com/plan9 + + +STATUS +====== + +The 2.6 kernel support is working on PPC and x86. + +PLEASE USE THE SOURCEFORGE BUG-TRACKER TO REPORT PROBLEMS. + diff --git a/MAINTAINERS b/MAINTAINERS index eaa4659..8429bdb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2684,6 +2684,17 @@ L: rio500-users@lists.sourceforge.net W: http://rio500.sourceforge.net S: Maintained +V9FS FILE SYSTEM +P: Eric Van Hensbergen +M: ericvh@gmail.com +P: Ron Minnich +M: rminnich@lanl.gov +P: Latchesar Ionkov +M: lucho@ionkov.net +L: v9fs-developer@lists.sourceforge.net +W: http://v9fs.sf.net +S: Maintained + VIDEO FOR LINUX P: Mauro Carvalho Chehab M: mchehab@brturbo.com.br diff --git a/fs/9p/Makefile b/fs/9p/Makefile new file mode 100644 index 0000000..e4e4ffe --- /dev/null +++ b/fs/9p/Makefile @@ -0,0 +1,17 @@ +obj-$(CONFIG_9P_FS) := 9p2000.o + +9p2000-objs := \ + vfs_super.o \ + vfs_inode.o \ + vfs_file.o \ + vfs_dir.o \ + vfs_dentry.o \ + error.o \ + mux.o \ + trans_fd.o \ + trans_sock.o \ + 9p.o \ + conv.o \ + v9fs.o \ + fid.o + diff --git a/fs/Kconfig b/fs/Kconfig index 5e81790..443aed4 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -1703,6 +1703,17 @@ config AFS_FS config RXRPC tristate +config 9P_FS + tristate "Plan 9 Resource Sharing Support (9P2000) (Experimental)" + depends on INET && EXPERIMENTAL + help + If you say Y here, you will get experimental support for + Plan 9 resource sharing via the 9P2000 protocol. + + See for more information. + + If unsure, say N. + endmenu menu "Partition Types" diff --git a/fs/Makefile b/fs/Makefile index 1515830..d646502 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -94,6 +94,7 @@ obj-$(CONFIG_RELAYFS_FS) += relayfs/ obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/ obj-$(CONFIG_JFS_FS) += jfs/ obj-$(CONFIG_XFS_FS) += xfs/ +obj-$(CONFIG_9P_FS) += 9p/ obj-$(CONFIG_AFS_FS) += afs/ obj-$(CONFIG_BEFS_FS) += befs/ obj-$(CONFIG_HOSTFS) += hostfs/ -- cgit v0.10.2 From e69e7fe5b0c86b7271045444a3a681136234c659 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:18 -0700 Subject: [PATCH] v9fs: VFS file, dentry, and directory operations This part of the patch contains the VFS file, dentry & directory interfaces. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c new file mode 100644 index 0000000..306c967 --- /dev/null +++ b/fs/9p/vfs_dentry.c @@ -0,0 +1,126 @@ +/* + * linux/fs/9p/vfs_dentry.c + * + * This file contians vfs dentry ops for the 9P2000 protocol. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "conv.h" +#include "fid.h" + +/** + * v9fs_dentry_validate - VFS dcache hook to validate cache + * @dentry: dentry that is being validated + * @nd: path data + * + * dcache really shouldn't be used for 9P2000 as at all due to + * potential attached semantics to directory traversal (walk). + * + * FUTURE: look into how to use dcache to allow multi-stage + * walks in Plan 9 & potential for better dcache operation which + * would remain valid for Plan 9 semantics. Older versions + * had validation via stat for those interested. However, since + * stat has the same approximate overhead as walk there really + * is no difference. The only improvement would be from a + * time-decay cache like NFS has and that undermines the + * synchronous nature of 9P2000. + * + */ + +static int v9fs_dentry_validate(struct dentry *dentry, struct nameidata *nd) +{ + struct dentry *dc = current->fs->pwd; + + dprintk(DEBUG_VFS, "dentry: %s (%p)\n", dentry->d_iname, dentry); + if (v9fs_fid_lookup(dentry, FID_OP)) { + dprintk(DEBUG_VFS, "VALID\n"); + return 1; + } + + while (dc != NULL) { + if (dc == dentry) { + dprintk(DEBUG_VFS, "VALID\n"); + return 1; + } + if (dc == dc->d_parent) + break; + + dc = dc->d_parent; + } + + dprintk(DEBUG_VFS, "INVALID\n"); + return 0; +} + +/** + * v9fs_dentry_release - called when dentry is going to be freed + * @dentry: dentry that is being release + * + */ + +void v9fs_dentry_release(struct dentry *dentry) +{ + dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry); + + if (dentry->d_fsdata != NULL) { + struct list_head *fid_list = dentry->d_fsdata; + struct v9fs_fid *temp = NULL; + struct v9fs_fid *current_fid = NULL; + struct v9fs_fcall *fcall = NULL; + + list_for_each_entry_safe(current_fid, temp, fid_list, list) { + if (v9fs_t_clunk + (current_fid->v9ses, current_fid->fid, &fcall)) + dprintk(DEBUG_ERROR, "clunk failed: %s\n", + FCALL_ERROR(fcall)); + + v9fs_put_idpool(current_fid->fid, + ¤t_fid->v9ses->fidpool); + + kfree(fcall); + v9fs_fid_destroy(current_fid); + } + + kfree(dentry->d_fsdata); /* free the list_head */ + } +} + +struct dentry_operations v9fs_dentry_operations = { + .d_revalidate = v9fs_dentry_validate, + .d_release = v9fs_dentry_release, +}; diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c new file mode 100644 index 0000000..c478a73 --- /dev/null +++ b/fs/9p/vfs_dir.c @@ -0,0 +1,226 @@ +/* + * linux/fs/9p/vfs_dir.c + * + * This file contains vfs directory ops for the 9P2000 protocol. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "conv.h" +#include "fid.h" + +/** + * dt_type - return file type + * @mistat: mistat structure + * + */ + +static inline int dt_type(struct v9fs_stat *mistat) +{ + unsigned long perm = mistat->mode; + int rettype = DT_REG; + + if (perm & V9FS_DMDIR) + rettype = DT_DIR; + if (perm & V9FS_DMSYMLINK) + rettype = DT_LNK; + + return rettype; +} + +/** + * v9fs_dir_readdir - read a directory + * @filep: opened file structure + * @dirent: directory structure ??? + * @filldir: function to populate directory structure ??? + * + */ + +static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir) +{ + struct v9fs_fcall *fcall = NULL; + struct inode *inode = filp->f_dentry->d_inode; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); + struct v9fs_fid *file = filp->private_data; + unsigned int i, n; + int fid = -1; + int ret = 0; + struct v9fs_stat *mi = NULL; + int over = 0; + + dprintk(DEBUG_VFS, "name %s\n", filp->f_dentry->d_name.name); + + fid = file->fid; + + mi = kmalloc(v9ses->maxdata, GFP_KERNEL); + if (!mi) + return -ENOMEM; + + if (file->rdir_fcall && (filp->f_pos != file->rdir_pos)) { + kfree(file->rdir_fcall); + file->rdir_fcall = NULL; + } + + if (file->rdir_fcall) { + n = file->rdir_fcall->params.rread.count; + i = file->rdir_fpos; + while (i < n) { + int s = v9fs_deserialize_stat(v9ses, + file->rdir_fcall->params.rread.data + i, + n - i, mi, v9ses->maxdata); + + if (s == 0) { + dprintk(DEBUG_ERROR, + "error while deserializing mistat\n"); + ret = -EIO; + goto FreeStructs; + } + + over = filldir(dirent, mi->name, strlen(mi->name), + filp->f_pos, v9fs_qid2ino(&mi->qid), + dt_type(mi)); + + if (over) { + file->rdir_fpos = i; + file->rdir_pos = filp->f_pos; + break; + } + + i += s; + filp->f_pos += s; + } + + if (!over) { + kfree(file->rdir_fcall); + file->rdir_fcall = NULL; + } + } + + while (!over) { + ret = v9fs_t_read(v9ses, fid, filp->f_pos, + v9ses->maxdata-V9FS_IOHDRSZ, &fcall); + if (ret < 0) { + dprintk(DEBUG_ERROR, "error while reading: %d: %p\n", + ret, fcall); + goto FreeStructs; + } else if (ret == 0) + break; + + n = ret; + i = 0; + while (i < n) { + int s = v9fs_deserialize_stat(v9ses, + fcall->params.rread.data + i, n - i, mi, + v9ses->maxdata); + + if (s == 0) { + dprintk(DEBUG_ERROR, + "error while deserializing mistat\n"); + return -EIO; + } + + over = filldir(dirent, mi->name, strlen(mi->name), + filp->f_pos, v9fs_qid2ino(&mi->qid), + dt_type(mi)); + + if (over) { + file->rdir_fcall = fcall; + file->rdir_fpos = i; + file->rdir_pos = filp->f_pos; + fcall = NULL; + break; + } + + i += s; + filp->f_pos += s; + } + + kfree(fcall); + } + + FreeStructs: + kfree(fcall); + kfree(mi); + return ret; +} + +/** + * v9fs_dir_release - close a directory + * @inode: inode of the directory + * @filp: file pointer to a directory + * + */ + +int v9fs_dir_release(struct inode *inode, struct file *filp) +{ + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); + struct v9fs_fid *fid = filp->private_data; + int fidnum = -1; + + dprintk(DEBUG_VFS, "inode: %p filp: %p fid: %d\n", inode, filp, + fid->fid); + fidnum = fid->fid; + + filemap_fdatawrite(inode->i_mapping); + filemap_fdatawait(inode->i_mapping); + + if (fidnum >= 0) { + fid->fidopen--; + dprintk(DEBUG_VFS, "fidopen: %d v9f->fid: %d\n", fid->fidopen, + fid->fid); + + if (fid->fidopen == 0) { + if (v9fs_t_clunk(v9ses, fidnum, NULL)) + dprintk(DEBUG_ERROR, "clunk failed\n"); + + v9fs_put_idpool(fid->fid, &v9ses->fidpool); + } + + kfree(fid->rdir_fcall); + + filp->private_data = NULL; + v9fs_fid_destroy(fid); + } + + d_drop(filp->f_dentry); + return 0; +} + +struct file_operations v9fs_dir_operations = { + .read = generic_read_dir, + .readdir = v9fs_dir_readdir, + .open = v9fs_file_open, + .release = v9fs_dir_release, +}; diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c new file mode 100644 index 0000000..1f8ae7d --- /dev/null +++ b/fs/9p/vfs_file.c @@ -0,0 +1,401 @@ +/* + * linux/fs/9p/vfs_file.c + * + * This file contians vfs file ops for 9P2000. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "fid.h" + +/** + * v9fs_file_open - open a file (or directory) + * @inode: inode to be opened + * @file: file being opened + * + */ + +int v9fs_file_open(struct inode *inode, struct file *file) +{ + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); + struct v9fs_fid *v9fid = v9fs_fid_lookup(file->f_dentry, FID_WALK); + struct v9fs_fid *v9newfid = NULL; + struct v9fs_fcall *fcall = NULL; + int open_mode = 0; + unsigned int iounit = 0; + int newfid = -1; + long result = -1; + + dprintk(DEBUG_VFS, "inode: %p file: %p v9fid= %p\n", inode, file, + v9fid); + + if (!v9fid) { + struct dentry *dentry = file->f_dentry; + dprintk(DEBUG_ERROR, "Couldn't resolve fid from dentry\n"); + + /* XXX - some duplication from lookup, generalize later */ + /* basically vfs_lookup is too heavy weight */ + v9fid = v9fs_fid_lookup(file->f_dentry, FID_OP); + if (!v9fid) + return -EBADF; + + v9fid = v9fs_fid_lookup(dentry->d_parent, FID_WALK); + if (!v9fid) + return -EBADF; + + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "newfid fails!\n"); + return -ENOSPC; + } + + result = + v9fs_t_walk(v9ses, v9fid->fid, newfid, + (char *)file->f_dentry->d_name.name, NULL); + if (result < 0) { + v9fs_put_idpool(newfid, &v9ses->fidpool); + dprintk(DEBUG_ERROR, "rewalk didn't work\n"); + return -EBADF; + } + + v9fid = v9fs_fid_create(dentry); + if (v9fid == NULL) { + dprintk(DEBUG_ERROR, "couldn't insert\n"); + return -ENOMEM; + } + v9fid->fid = newfid; + } + + if (v9fid->fidcreate) { + /* create case */ + newfid = v9fid->fid; + iounit = v9fid->iounit; + v9fid->fidcreate = 0; + } else { + if (!S_ISDIR(inode->i_mode)) + newfid = v9fid->fid; + else { + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "allocation failed\n"); + return -ENOSPC; + } + /* This would be a somewhat critical clone */ + result = + v9fs_t_walk(v9ses, v9fid->fid, newfid, NULL, + &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, "clone error: %s\n", + FCALL_ERROR(fcall)); + kfree(fcall); + return result; + } + + v9newfid = v9fs_fid_create(file->f_dentry); + v9newfid->fid = newfid; + v9newfid->qid = v9fid->qid; + v9newfid->iounit = v9fid->iounit; + v9newfid->fidopen = 0; + v9newfid->fidclunked = 0; + v9newfid->v9ses = v9ses; + v9fid = v9newfid; + kfree(fcall); + } + + /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */ + /* translate open mode appropriately */ + open_mode = file->f_flags & 0x3; + + if (file->f_flags & O_EXCL) + open_mode |= V9FS_OEXCL; + + if (v9ses->extended) { + if (file->f_flags & O_TRUNC) + open_mode |= V9FS_OTRUNC; + + if (file->f_flags & O_APPEND) + open_mode |= V9FS_OAPPEND; + } + + result = v9fs_t_open(v9ses, newfid, open_mode, &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, + "open failed, open_mode 0x%x: %s\n", open_mode, + FCALL_ERROR(fcall)); + kfree(fcall); + return result; + } + + iounit = fcall->params.ropen.iounit; + kfree(fcall); + } + + + file->private_data = v9fid; + + v9fid->rdir_pos = 0; + v9fid->rdir_fcall = NULL; + v9fid->fidopen = 1; + v9fid->filp = file; + v9fid->iounit = iounit; + + return 0; +} + +/** + * v9fs_file_lock - lock a file (or directory) + * @inode: inode to be opened + * @file: file being opened + * + * XXX - this looks like a local only lock, we should extend into 9P + * by using open exclusive + */ + +static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl) +{ + int res = 0; + struct inode *inode = filp->f_dentry->d_inode; + + dprintk(DEBUG_VFS, "filp: %p lock: %p\n", filp, fl); + + /* No mandatory locks */ + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) + return -ENOLCK; + + if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) { + filemap_fdatawrite(inode->i_mapping); + filemap_fdatawait(inode->i_mapping); + invalidate_inode_pages(&inode->i_data); + } + + return res; +} + +/** + * v9fs_read - read from a file (internal) + * @filep: file pointer to read + * @data: data buffer to read data into + * @count: size of buffer + * @offset: offset at which to read data + * + */ + +static ssize_t +v9fs_read(struct file *filp, char *buffer, size_t count, loff_t * offset) +{ + struct inode *inode = filp->f_dentry->d_inode; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); + struct v9fs_fid *v9f = filp->private_data; + struct v9fs_fcall *fcall = NULL; + int fid = v9f->fid; + int rsize = 0; + int result = 0; + int total = 0; + + dprintk(DEBUG_VFS, "\n"); + + rsize = v9ses->maxdata - V9FS_IOHDRSZ; + if (v9f->iounit != 0 && rsize > v9f->iounit) + rsize = v9f->iounit; + + do { + if (count < rsize) + rsize = count; + + result = v9fs_t_read(v9ses, fid, *offset, rsize, &fcall); + + if (result < 0) { + printk(KERN_ERR "9P2000: v9fs_t_read returned %d\n", + result); + + kfree(fcall); + return total; + } else + *offset += result; + + /* XXX - extra copy */ + memcpy(buffer, fcall->params.rread.data, result); + count -= result; + buffer += result; + total += result; + + kfree(fcall); + + if (result < rsize) + break; + } while (count); + + return total; +} + +/** + * v9fs_file_read - read from a file + * @filep: file pointer to read + * @data: data buffer to read data into + * @count: size of buffer + * @offset: offset at which to read data + * + */ + +static ssize_t +v9fs_file_read(struct file *filp, char __user * data, size_t count, + loff_t * offset) +{ + int retval = -1; + int ret = 0; + char *buffer; + + buffer = kmalloc(count, GFP_KERNEL); + if (!buffer) + return -ENOMEM; + + retval = v9fs_read(filp, buffer, count, offset); + if (retval > 0) { + if ((ret = copy_to_user(data, buffer, retval)) != 0) { + dprintk(DEBUG_ERROR, "Problem copying to user %d\n", + ret); + retval = ret; + } + } + + kfree(buffer); + + return retval; +} + +/** + * v9fs_write - write to a file + * @filep: file pointer to write + * @data: data buffer to write data from + * @count: size of buffer + * @offset: offset at which to write data + * + */ + +static ssize_t +v9fs_write(struct file *filp, char *buffer, size_t count, loff_t * offset) +{ + struct inode *inode = filp->f_dentry->d_inode; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); + struct v9fs_fid *v9fid = filp->private_data; + struct v9fs_fcall *fcall; + int fid = v9fid->fid; + int result = -EIO; + int rsize = 0; + int total = 0; + + dprintk(DEBUG_VFS, "data %p count %d offset %x\n", buffer, (int)count, + (int)*offset); + rsize = v9ses->maxdata - V9FS_IOHDRSZ; + if (v9fid->iounit != 0 && rsize > v9fid->iounit) + rsize = v9fid->iounit; + + dump_data(buffer, count); + + do { + if (count < rsize) + rsize = count; + + result = + v9fs_t_write(v9ses, fid, *offset, rsize, buffer, &fcall); + if (result < 0) { + eprintk(KERN_ERR, "error while writing: %s(%d)\n", + FCALL_ERROR(fcall), result); + kfree(fcall); + return result; + } else + *offset += result; + + kfree(fcall); + + if (result != rsize) { + eprintk(KERN_ERR, + "short write: v9fs_t_write returned %d\n", + result); + break; + } + + count -= result; + buffer += result; + total += result; + } while (count); + + return total; +} + +/** + * v9fs_file_write - write to a file + * @filep: file pointer to write + * @data: data buffer to write data from + * @count: size of buffer + * @offset: offset at which to write data + * + */ + +static ssize_t +v9fs_file_write(struct file *filp, const char __user * data, + size_t count, loff_t * offset) +{ + int ret = -1; + char *buffer; + + buffer = kmalloc(count, GFP_KERNEL); + if (buffer == NULL) + return -ENOMEM; + + ret = copy_from_user(buffer, data, count); + if (ret) { + dprintk(DEBUG_ERROR, "Problem copying from user\n"); + ret = -EFAULT; + } else { + ret = v9fs_write(filp, buffer, count, offset); + } + + kfree(buffer); + + return ret; +} + +struct file_operations v9fs_file_operations = { + .llseek = generic_file_llseek, + .read = v9fs_file_read, + .write = v9fs_file_write, + .open = v9fs_file_open, + .release = v9fs_dir_release, + .lock = v9fs_file_lock, +}; -- cgit v0.10.2 From 2bad8471511ce5cc3ea90d0940622bd4b56b9cce Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:19 -0700 Subject: [PATCH] v9fs: VFS inode operations This part of the patch contains the VFS inode interfaces. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c new file mode 100644 index 0000000..ef78af7 --- /dev/null +++ b/fs/9p/vfs_inode.c @@ -0,0 +1,1371 @@ +/* + * linux/fs/9p/vfs_inode.c + * + * This file contians vfs inode ops for the 9P2000 protocol. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "conv.h" +#include "fid.h" + +static struct inode_operations v9fs_dir_inode_operations; +static struct inode_operations v9fs_file_inode_operations; +static struct inode_operations v9fs_symlink_inode_operations; + +/** + * unixmode2p9mode - convert unix mode bits to plan 9 + * @v9ses: v9fs session information + * @mode: mode to convert + * + */ + +static inline int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) +{ + int res; + res = mode & 0777; + if (S_ISDIR(mode)) + res |= V9FS_DMDIR; + if (v9ses->extended) { + if (S_ISLNK(mode)) + res |= V9FS_DMSYMLINK; + if (v9ses->nodev == 0) { + if (S_ISSOCK(mode)) + res |= V9FS_DMSOCKET; + if (S_ISFIFO(mode)) + res |= V9FS_DMNAMEDPIPE; + if (S_ISBLK(mode)) + res |= V9FS_DMDEVICE; + if (S_ISCHR(mode)) + res |= V9FS_DMDEVICE; + } + + if ((mode & S_ISUID) == S_ISUID) + res |= V9FS_DMSETUID; + if ((mode & S_ISGID) == S_ISGID) + res |= V9FS_DMSETGID; + if ((mode & V9FS_DMLINK)) + res |= V9FS_DMLINK; + } + + return res; +} + +/** + * p9mode2unixmode- convert plan9 mode bits to unix mode bits + * @v9ses: v9fs session information + * @mode: mode to convert + * + */ + +static inline int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) +{ + int res; + + res = mode & 0777; + + if ((mode & V9FS_DMDIR) == V9FS_DMDIR) + res |= S_IFDIR; + else if ((mode & V9FS_DMSYMLINK) && (v9ses->extended)) + res |= S_IFLNK; + else if ((mode & V9FS_DMSOCKET) && (v9ses->extended) + && (v9ses->nodev == 0)) + res |= S_IFSOCK; + else if ((mode & V9FS_DMNAMEDPIPE) && (v9ses->extended) + && (v9ses->nodev == 0)) + res |= S_IFIFO; + else if ((mode & V9FS_DMDEVICE) && (v9ses->extended) + && (v9ses->nodev == 0)) + res |= S_IFBLK; + else + res |= S_IFREG; + + if (v9ses->extended) { + if ((mode & V9FS_DMSETUID) == V9FS_DMSETUID) + res |= S_ISUID; + + if ((mode & V9FS_DMSETGID) == V9FS_DMSETGID) + res |= S_ISGID; + } + + return res; +} + +/** + * v9fs_blank_mistat - helper function to setup a 9P stat structure + * @v9ses: 9P session info (for determining extended mode) + * @mistat: structure to initialize + * + */ + +static inline void +v9fs_blank_mistat(struct v9fs_session_info *v9ses, struct v9fs_stat *mistat) +{ + mistat->type = ~0; + mistat->dev = ~0; + mistat->qid.type = ~0; + mistat->qid.version = ~0; + *((long long *)&mistat->qid.path) = ~0; + mistat->mode = ~0; + mistat->atime = ~0; + mistat->mtime = ~0; + mistat->length = ~0; + mistat->name = mistat->data; + mistat->uid = mistat->data; + mistat->gid = mistat->data; + mistat->muid = mistat->data; + if (v9ses->extended) { + mistat->n_uid = ~0; + mistat->n_gid = ~0; + mistat->n_muid = ~0; + mistat->extension = mistat->data; + } + *mistat->data = 0; +} + +/** + * v9fs_mistat2unix - convert mistat to unix stat + * @mistat: Plan 9 metadata (mistat) structure + * @stat: unix metadata (stat) structure to populate + * @sb: superblock + * + */ + +static void +v9fs_mistat2unix(struct v9fs_stat *mistat, struct stat *buf, + struct super_block *sb) +{ + struct v9fs_session_info *v9ses = sb ? sb->s_fs_info : NULL; + + buf->st_nlink = 1; + + buf->st_atime = mistat->atime; + buf->st_mtime = mistat->mtime; + buf->st_ctime = mistat->mtime; + + if (v9ses && v9ses->extended) { + /* TODO: string to uid mapping via user-space daemon */ + buf->st_uid = mistat->n_uid; + buf->st_gid = mistat->n_gid; + + sscanf(mistat->uid, "%x", (unsigned int *)&buf->st_uid); + sscanf(mistat->gid, "%x", (unsigned int *)&buf->st_gid); + } else { + buf->st_uid = v9ses->uid; + buf->st_gid = v9ses->gid; + } + + buf->st_uid = (unsigned short)-1; + buf->st_gid = (unsigned short)-1; + + if (v9ses && v9ses->extended) { + if (mistat->n_uid != -1) + sscanf(mistat->uid, "%x", (unsigned int *)&buf->st_uid); + + if (mistat->n_gid != -1) + sscanf(mistat->gid, "%x", (unsigned int *)&buf->st_gid); + } + + if (buf->st_uid == (unsigned short)-1) + buf->st_uid = v9ses->uid; + if (buf->st_gid == (unsigned short)-1) + buf->st_gid = v9ses->gid; + + buf->st_mode = p9mode2unixmode(v9ses, mistat->mode); + if ((S_ISBLK(buf->st_mode)) || (S_ISCHR(buf->st_mode))) { + char type = 0; + int major = -1; + int minor = -1; + sscanf(mistat->extension, "%c %u %u", &type, &major, &minor); + switch (type) { + case 'c': + buf->st_mode &= ~S_IFBLK; + buf->st_mode |= S_IFCHR; + break; + case 'b': + break; + default: + dprintk(DEBUG_ERROR, "Unknown special type %c (%s)\n", + type, mistat->extension); + }; + buf->st_rdev = MKDEV(major, minor); + } else + buf->st_rdev = 0; + + buf->st_size = mistat->length; + + buf->st_blksize = sb->s_blocksize; + buf->st_blocks = + (buf->st_size + buf->st_blksize - 1) >> sb->s_blocksize_bits; +} + +/** + * v9fs_get_inode - helper function to setup an inode + * @sb: superblock + * @mode: mode to setup inode with + * + */ + +struct inode *v9fs_get_inode(struct super_block *sb, int mode) +{ + struct inode *inode = NULL; + + dprintk(DEBUG_VFS, "super block: %p mode: %o\n", sb, mode); + + inode = new_inode(sb); + if (inode) { + inode->i_mode = mode; + inode->i_uid = current->fsuid; + inode->i_gid = current->fsgid; + inode->i_blksize = sb->s_blocksize; + inode->i_blocks = 0; + inode->i_rdev = 0; + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + + switch (mode & S_IFMT) { + case S_IFIFO: + case S_IFBLK: + case S_IFCHR: + case S_IFSOCK: + case S_IFREG: + inode->i_op = &v9fs_file_inode_operations; + inode->i_fop = &v9fs_file_operations; + break; + case S_IFDIR: + inode->i_nlink++; + inode->i_op = &v9fs_dir_inode_operations; + inode->i_fop = &v9fs_dir_operations; + break; + case S_IFLNK: + inode->i_op = &v9fs_symlink_inode_operations; + break; + default: + dprintk(DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n", + mode, mode & S_IFMT); + return ERR_PTR(-EINVAL); + } + } else { + eprintk(KERN_WARNING, "Problem allocating inode\n"); + return ERR_PTR(-ENOMEM); + } + return inode; +} + +/** + * v9fs_create - helper function to create files and directories + * @dir: directory inode file is being created in + * @file_dentry: dentry file is being created in + * @perm: permissions file is being created with + * @open_mode: resulting open mode for file ??? + * + */ + +static int +v9fs_create(struct inode *dir, + struct dentry *file_dentry, + unsigned int perm, unsigned int open_mode) +{ + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); + struct super_block *sb = dir->i_sb; + struct v9fs_fid *dirfid = + v9fs_fid_lookup(file_dentry->d_parent, FID_WALK); + struct v9fs_fid *fid = NULL; + struct inode *file_inode = NULL; + struct v9fs_fcall *fcall = NULL; + struct v9fs_qid qid; + struct stat newstat; + int dirfidnum = -1; + long newfid = -1; + int result = 0; + unsigned int iounit = 0; + + perm = unixmode2p9mode(v9ses, perm); + + dprintk(DEBUG_VFS, "dir: %p dentry: %p perm: %o mode: %o\n", dir, + file_dentry, perm, open_mode); + + if (!dirfid) + return -EBADF; + + dirfidnum = dirfid->fid; + if (dirfidnum < 0) { + dprintk(DEBUG_ERROR, "No fid for the directory #%lu\n", + dir->i_ino); + return -EBADF; + } + + if (file_dentry->d_inode) { + dprintk(DEBUG_ERROR, + "Odd. There is an inode for dir %lu, name :%s:\n", + dir->i_ino, file_dentry->d_name.name); + return -EEXIST; + } + + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "no free fids available\n"); + return -ENOSPC; + } + + result = v9fs_t_walk(v9ses, dirfidnum, newfid, NULL, &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, "clone error: %s\n", FCALL_ERROR(fcall)); + v9fs_put_idpool(newfid, &v9ses->fidpool); + newfid = 0; + goto CleanUpFid; + } + + kfree(fcall); + + result = v9fs_t_create(v9ses, newfid, (char *)file_dentry->d_name.name, + perm, open_mode, &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, "create fails: %s(%d)\n", + FCALL_ERROR(fcall), result); + + goto CleanUpFid; + } + + iounit = fcall->params.rcreate.iounit; + qid = fcall->params.rcreate.qid; + kfree(fcall); + + fid = v9fs_fid_create(file_dentry); + if (!fid) { + result = -ENOMEM; + goto CleanUpFid; + } + + fid->fid = newfid; + fid->fidopen = 0; + fid->fidcreate = 1; + fid->qid = qid; + fid->iounit = iounit; + fid->rdir_pos = 0; + fid->rdir_fcall = NULL; + fid->v9ses = v9ses; + + if ((perm & V9FS_DMSYMLINK) || (perm & V9FS_DMLINK) || + (perm & V9FS_DMNAMEDPIPE) || (perm & V9FS_DMSOCKET) || + (perm & V9FS_DMDEVICE)) + return 0; + + result = v9fs_t_stat(v9ses, newfid, &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, "stat error: %s(%d)\n", FCALL_ERROR(fcall), + result); + goto CleanUpFid; + } + + v9fs_mistat2unix(fcall->params.rstat.stat, &newstat, sb); + + file_inode = v9fs_get_inode(sb, newstat.st_mode); + if ((!file_inode) || IS_ERR(file_inode)) { + dprintk(DEBUG_ERROR, "create inode failed\n"); + result = -EBADF; + goto CleanUpFid; + } + + v9fs_mistat2inode(fcall->params.rstat.stat, file_inode, sb); + kfree(fcall); + d_instantiate(file_dentry, file_inode); + + if (perm & V9FS_DMDIR) { + if (v9fs_t_clunk(v9ses, newfid, &fcall)) + dprintk(DEBUG_ERROR, "clunk for mkdir failed: %s\n", + FCALL_ERROR(fcall)); + + v9fs_put_idpool(newfid, &v9ses->fidpool); + kfree(fcall); + fid->fidopen = 0; + fid->fidcreate = 0; + d_drop(file_dentry); + } + + return 0; + + CleanUpFid: + kfree(fcall); + + if (newfid) { + if (v9fs_t_clunk(v9ses, newfid, &fcall)) + dprintk(DEBUG_ERROR, "clunk failed: %s\n", + FCALL_ERROR(fcall)); + + v9fs_put_idpool(newfid, &v9ses->fidpool); + kfree(fcall); + } + return result; +} + +/** + * v9fs_remove - helper function to remove files and directories + * @inode: directory inode that is being deleted + * @dentry: dentry that is being deleted + * @rmdir: where we are a file or a directory + * + */ + +static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir) +{ + struct v9fs_fcall *fcall = NULL; + struct super_block *sb = NULL; + struct v9fs_session_info *v9ses = NULL; + struct v9fs_fid *v9fid = NULL; + struct inode *file_inode = NULL; + int fid = -1; + int result = 0; + + dprintk(DEBUG_VFS, "inode: %p dentry: %p rmdir: %d\n", dir, file, + rmdir); + + file_inode = file->d_inode; + sb = file_inode->i_sb; + v9ses = v9fs_inode2v9ses(file_inode); + v9fid = v9fs_fid_lookup(file, FID_OP); + + if (!v9fid) { + dprintk(DEBUG_ERROR, + "no v9fs_fid\n"); + return -EBADF; + } + + fid = v9fid->fid; + if (fid < 0) { + dprintk(DEBUG_ERROR, "inode #%lu, no fid!\n", + file_inode->i_ino); + return -EBADF; + } + + result = v9fs_t_remove(v9ses, fid, &fcall); + if (result < 0) + dprintk(DEBUG_ERROR, "remove of file fails: %s(%d)\n", + FCALL_ERROR(fcall), result); + else { + v9fs_put_idpool(fid, &v9ses->fidpool); + v9fs_fid_destroy(v9fid); + } + + kfree(fcall); + return result; +} + +/** + * v9fs_vfs_create - VFS hook to create files + * @inode: directory inode that is being deleted + * @dentry: dentry that is being deleted + * @perm: create permissions + * @nd: path information + * + */ + +static int +v9fs_vfs_create(struct inode *inode, struct dentry *dentry, int perm, + struct nameidata *nd) +{ + return v9fs_create(inode, dentry, perm, O_RDWR); +} + +/** + * v9fs_vfs_mkdir - VFS mkdir hook to create a directory + * @i: inode that is being unlinked + * @dentry: dentry that is being unlinked + * @mode: mode for new directory + * + */ + +static int v9fs_vfs_mkdir(struct inode *inode, struct dentry *dentry, int mode) +{ + return v9fs_create(inode, dentry, mode | S_IFDIR, O_RDONLY); +} + +/** + * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode + * @dir: inode that is being walked from + * @dentry: dentry that is being walked to? + * @nameidata: path data + * + */ + +static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, + struct nameidata *nameidata) +{ + struct super_block *sb; + struct v9fs_session_info *v9ses; + struct v9fs_fid *dirfid; + struct v9fs_fid *fid; + struct inode *inode; + struct v9fs_fcall *fcall = NULL; + struct stat newstat; + int dirfidnum = -1; + int newfid = -1; + int result = 0; + + dprintk(DEBUG_VFS, "dir: %p dentry: (%s) %p nameidata: %p\n", + dir, dentry->d_iname, dentry, nameidata); + + sb = dir->i_sb; + v9ses = v9fs_inode2v9ses(dir); + dirfid = v9fs_fid_lookup(dentry->d_parent, FID_WALK); + + if (!dirfid) { + dprintk(DEBUG_ERROR, "no dirfid\n"); + return ERR_PTR(-EINVAL); + } + + dirfidnum = dirfid->fid; + + if (dirfidnum < 0) { + dprintk(DEBUG_ERROR, "no dirfid for inode %p, #%lu\n", + dir, dir->i_ino); + return ERR_PTR(-EBADF); + } + + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "newfid fails!\n"); + return ERR_PTR(-ENOSPC); + } + + result = + v9fs_t_walk(v9ses, dirfidnum, newfid, (char *)dentry->d_name.name, + NULL); + if (result < 0) { + v9fs_put_idpool(newfid, &v9ses->fidpool); + if (result == -ENOENT) { + d_add(dentry, NULL); + dprintk(DEBUG_ERROR, + "Return negative dentry %p count %d\n", + dentry, atomic_read(&dentry->d_count)); + return NULL; + } + dprintk(DEBUG_ERROR, "walk error:%d\n", result); + goto FreeFcall; + } + + result = v9fs_t_stat(v9ses, newfid, &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, "stat error\n"); + goto FreeFcall; + } + + v9fs_mistat2unix(fcall->params.rstat.stat, &newstat, sb); + inode = v9fs_get_inode(sb, newstat.st_mode); + + if (IS_ERR(inode) && (PTR_ERR(inode) == -ENOSPC)) { + eprintk(KERN_WARNING, "inode alloc failes, returns %ld\n", + PTR_ERR(inode)); + + result = -ENOSPC; + goto FreeFcall; + } + + inode->i_ino = v9fs_qid2ino(&fcall->params.rstat.stat->qid); + + fid = v9fs_fid_create(dentry); + if (fid == NULL) { + dprintk(DEBUG_ERROR, "couldn't insert\n"); + result = -ENOMEM; + goto FreeFcall; + } + + fid->fid = newfid; + fid->fidopen = 0; + fid->v9ses = v9ses; + fid->qid = fcall->params.rstat.stat->qid; + + dentry->d_op = &v9fs_dentry_operations; + v9fs_mistat2inode(fcall->params.rstat.stat, inode, inode->i_sb); + + d_add(dentry, inode); + kfree(fcall); + + return NULL; + + FreeFcall: + kfree(fcall); + return ERR_PTR(result); +} + +/** + * v9fs_vfs_unlink - VFS unlink hook to delete an inode + * @i: inode that is being unlinked + * @dentry: dentry that is being unlinked + * + */ + +static int v9fs_vfs_unlink(struct inode *i, struct dentry *d) +{ + return v9fs_remove(i, d, 0); +} + +/** + * v9fs_vfs_rmdir - VFS unlink hook to delete a directory + * @i: inode that is being unlinked + * @dentry: dentry that is being unlinked + * + */ + +static int v9fs_vfs_rmdir(struct inode *i, struct dentry *d) +{ + return v9fs_remove(i, d, 1); +} + +/** + * v9fs_vfs_rename - VFS hook to rename an inode + * @old_dir: old dir inode + * @old_dentry: old dentry + * @new_dir: new dir inode + * @new_dentry: new dentry + * + */ + +static int +v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry) +{ + struct inode *old_inode = old_dentry->d_inode; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(old_inode); + struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry, FID_WALK); + struct v9fs_fid *olddirfid = + v9fs_fid_lookup(old_dentry->d_parent, FID_WALK); + struct v9fs_fid *newdirfid = + v9fs_fid_lookup(new_dentry->d_parent, FID_WALK); + struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); + struct v9fs_fcall *fcall = NULL; + int fid = -1; + int olddirfidnum = -1; + int newdirfidnum = -1; + int retval = 0; + + dprintk(DEBUG_VFS, "\n"); + + if ((!oldfid) || (!olddirfid) || (!newdirfid)) { + dprintk(DEBUG_ERROR, "problem with arguments\n"); + return -EBADF; + } + + /* 9P can only handle file rename in the same directory */ + if (memcmp(&olddirfid->qid, &newdirfid->qid, sizeof(newdirfid->qid))) { + dprintk(DEBUG_ERROR, "old dir and new dir are different\n"); + retval = -EPERM; + goto FreeFcallnBail; + } + + fid = oldfid->fid; + olddirfidnum = olddirfid->fid; + newdirfidnum = newdirfid->fid; + + if (fid < 0) { + dprintk(DEBUG_ERROR, "no fid for old file #%lu\n", + old_inode->i_ino); + retval = -EBADF; + goto FreeFcallnBail; + } + + v9fs_blank_mistat(v9ses, mistat); + + strcpy(mistat->data + 1, v9ses->name); + mistat->name = mistat->data + 1 + strlen(v9ses->name); + + if (new_dentry->d_name.len > + (v9ses->maxdata - strlen(v9ses->name) - sizeof(struct v9fs_stat))) { + dprintk(DEBUG_ERROR, "new name too long\n"); + goto FreeFcallnBail; + } + + strcpy(mistat->name, new_dentry->d_name.name); + retval = v9fs_t_wstat(v9ses, fid, mistat, &fcall); + + FreeFcallnBail: + kfree(mistat); + + if (retval < 0) + dprintk(DEBUG_ERROR, "v9fs_t_wstat error: %s\n", + FCALL_ERROR(fcall)); + + kfree(fcall); + return retval; +} + +/** + * v9fs_vfs_getattr - retreive file metadata + * @mnt - mount information + * @dentry - file to get attributes on + * @stat - metadata structure to populate + * + */ + +static int +v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, + struct kstat *stat) +{ + struct v9fs_fcall *fcall = NULL; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); + struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); + int err = -EPERM; + + dprintk(DEBUG_VFS, "dentry: %p\n", dentry); + if (!fid) { + dprintk(DEBUG_ERROR, + "couldn't find fid associated with dentry\n"); + return -EBADF; + } + + err = v9fs_t_stat(v9ses, fid->fid, &fcall); + + if (err < 0) + dprintk(DEBUG_ERROR, "stat error\n"); + else { + v9fs_mistat2inode(fcall->params.rstat.stat, dentry->d_inode, + dentry->d_inode->i_sb); + generic_fillattr(dentry->d_inode, stat); + } + + kfree(fcall); + return err; +} + +/** + * v9fs_vfs_setattr - set file metadata + * @dentry: file whose metadata to set + * @iattr: metadata assignment structure + * + */ + +static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) +{ + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); + struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); + struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); + struct v9fs_fcall *fcall = NULL; + int res = -EPERM; + + dprintk(DEBUG_VFS, "\n"); + if (!fid) { + dprintk(DEBUG_ERROR, + "Couldn't find fid associated with dentry\n"); + return -EBADF; + } + + if (!mistat) + return -ENOMEM; + + v9fs_blank_mistat(v9ses, mistat); + if (iattr->ia_valid & ATTR_MODE) + mistat->mode = unixmode2p9mode(v9ses, iattr->ia_mode); + + if (iattr->ia_valid & ATTR_MTIME) + mistat->mtime = iattr->ia_mtime.tv_sec; + + if (iattr->ia_valid & ATTR_ATIME) + mistat->atime = iattr->ia_atime.tv_sec; + + if (iattr->ia_valid & ATTR_SIZE) + mistat->length = iattr->ia_size; + + if (v9ses->extended) { + char *uid = kmalloc(strlen(mistat->uid), GFP_KERNEL); + char *gid = kmalloc(strlen(mistat->gid), GFP_KERNEL); + char *muid = kmalloc(strlen(mistat->muid), GFP_KERNEL); + char *name = kmalloc(strlen(mistat->name), GFP_KERNEL); + char *extension = kmalloc(strlen(mistat->extension), + GFP_KERNEL); + + if ((!uid) || (!gid) || (!muid) || (!name) || (!extension)) { + kfree(uid); + kfree(gid); + kfree(muid); + kfree(name); + kfree(extension); + + return -ENOMEM; + } + + strcpy(uid, mistat->uid); + strcpy(gid, mistat->gid); + strcpy(muid, mistat->muid); + strcpy(name, mistat->name); + strcpy(extension, mistat->extension); + + if (iattr->ia_valid & ATTR_UID) { + if (strlen(uid) != 8) { + dprintk(DEBUG_ERROR, "uid strlen is %u not 8\n", + (unsigned int)strlen(uid)); + sprintf(uid, "%08x", iattr->ia_uid); + } else { + kfree(uid); + uid = kmalloc(9, GFP_KERNEL); + } + + sprintf(uid, "%08x", iattr->ia_uid); + mistat->n_uid = iattr->ia_uid; + } + + if (iattr->ia_valid & ATTR_GID) { + if (strlen(gid) != 8) + dprintk(DEBUG_ERROR, "gid strlen is %u not 8\n", + (unsigned int)strlen(gid)); + else { + kfree(gid); + gid = kmalloc(9, GFP_KERNEL); + } + + sprintf(gid, "%08x", iattr->ia_gid); + mistat->n_gid = iattr->ia_gid; + } + + mistat->uid = mistat->data; + strcpy(mistat->uid, uid); + mistat->gid = mistat->data + strlen(uid) + 1; + strcpy(mistat->gid, gid); + mistat->muid = mistat->gid + strlen(gid) + 1; + strcpy(mistat->muid, muid); + mistat->name = mistat->muid + strlen(muid) + 1; + strcpy(mistat->name, name); + mistat->extension = mistat->name + strlen(name) + 1; + strcpy(mistat->extension, extension); + + kfree(uid); + kfree(gid); + kfree(muid); + kfree(name); + kfree(extension); + } + + res = v9fs_t_wstat(v9ses, fid->fid, mistat, &fcall); + + if (res < 0) + dprintk(DEBUG_ERROR, "wstat error: %s\n", FCALL_ERROR(fcall)); + + kfree(mistat); + kfree(fcall); + + if (res >= 0) + res = inode_setattr(dentry->d_inode, iattr); + + return res; +} + +/** + * v9fs_mistat2inode - populate an inode structure with mistat info + * @mistat: Plan 9 metadata (mistat) structure + * @inode: inode to populate + * @sb: superblock of filesystem + * + */ + +void +v9fs_mistat2inode(struct v9fs_stat *mistat, struct inode *inode, + struct super_block *sb) +{ + struct v9fs_session_info *v9ses = sb->s_fs_info; + + inode->i_nlink = 1; + + inode->i_atime.tv_sec = mistat->atime; + inode->i_mtime.tv_sec = mistat->mtime; + inode->i_ctime.tv_sec = mistat->mtime; + + inode->i_uid = -1; + inode->i_gid = -1; + + if (v9ses->extended) { + /* TODO: string to uid mapping via user-space daemon */ + inode->i_uid = mistat->n_uid; + inode->i_gid = mistat->n_gid; + + if (mistat->n_uid == -1) + sscanf(mistat->uid, "%x", &inode->i_uid); + + if (mistat->n_gid == -1) + sscanf(mistat->gid, "%x", &inode->i_gid); + } + + if (inode->i_uid == -1) + inode->i_uid = v9ses->uid; + if (inode->i_gid == -1) + inode->i_gid = v9ses->gid; + + inode->i_mode = p9mode2unixmode(v9ses, mistat->mode); + if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) { + char type = 0; + int major = -1; + int minor = -1; + sscanf(mistat->extension, "%c %u %u", &type, &major, &minor); + switch (type) { + case 'c': + inode->i_mode &= ~S_IFBLK; + inode->i_mode |= S_IFCHR; + break; + case 'b': + break; + default: + dprintk(DEBUG_ERROR, "Unknown special type %c (%s)\n", + type, mistat->extension); + }; + inode->i_rdev = MKDEV(major, minor); + } else + inode->i_rdev = 0; + + inode->i_size = mistat->length; + + inode->i_blksize = sb->s_blocksize; + inode->i_blocks = + (inode->i_size + inode->i_blksize - 1) >> sb->s_blocksize_bits; +} + +/** + * v9fs_qid2ino - convert qid into inode number + * @qid: qid to hash + * + * BUG: potential for inode number collisions? + */ + +ino_t v9fs_qid2ino(struct v9fs_qid *qid) +{ + u64 path = qid->path + 2; + ino_t i = 0; + + if (sizeof(ino_t) == sizeof(path)) + memcpy(&i, &path, sizeof(ino_t)); + else + i = (ino_t) (path ^ (path >> 32)); + + return i; +} + +/** + * v9fs_vfs_symlink - helper function to create symlinks + * @dir: directory inode containing symlink + * @dentry: dentry for symlink + * @symname: symlink data + * + * See 9P2000.u RFC for more information + * + */ + +static int +v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) +{ + int retval = -EPERM; + struct v9fs_fid *newfid; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); + struct super_block *sb = dir ? dir->i_sb : NULL; + struct v9fs_fcall *fcall = NULL; + struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); + + dprintk(DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name, + symname); + + if ((!dentry) || (!sb) || (!v9ses)) { + dprintk(DEBUG_ERROR, "problem with arguments\n"); + return -EBADF; + } + + if (!v9ses->extended) { + dprintk(DEBUG_ERROR, "not extended\n"); + goto FreeFcall; + } + + /* issue a create */ + retval = v9fs_create(dir, dentry, S_IFLNK, 0); + if (retval != 0) + goto FreeFcall; + + newfid = v9fs_fid_lookup(dentry, FID_OP); + + /* issue a twstat */ + v9fs_blank_mistat(v9ses, mistat); + strcpy(mistat->data + 1, symname); + mistat->extension = mistat->data + 1; + retval = v9fs_t_wstat(v9ses, newfid->fid, mistat, &fcall); + if (retval < 0) { + dprintk(DEBUG_ERROR, "v9fs_t_wstat error: %s\n", + FCALL_ERROR(fcall)); + goto FreeFcall; + } + + kfree(fcall); + + if (v9fs_t_clunk(v9ses, newfid->fid, &fcall)) { + dprintk(DEBUG_ERROR, "clunk for symlink failed: %s\n", + FCALL_ERROR(fcall)); + goto FreeFcall; + } + + d_drop(dentry); /* FID - will this also clunk? */ + + FreeFcall: + kfree(mistat); + kfree(fcall); + + return retval; +} + +/** + * v9fs_readlink - read a symlink's location (internal version) + * @dentry: dentry for symlink + * @buf: buffer to load symlink location into + * @buflen: length of buffer + * + */ + +static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen) +{ + int retval = -EPERM; + + struct v9fs_fcall *fcall = NULL; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); + struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); + + if (!fid) { + dprintk(DEBUG_ERROR, "could not resolve fid from dentry\n"); + retval = -EBADF; + goto FreeFcall; + } + + if (!v9ses->extended) { + retval = -EBADF; + dprintk(DEBUG_ERROR, "not extended\n"); + goto FreeFcall; + } + + dprintk(DEBUG_VFS, " %s\n", dentry->d_name.name); + retval = v9fs_t_stat(v9ses, fid->fid, &fcall); + + if (retval < 0) { + dprintk(DEBUG_ERROR, "stat error\n"); + goto FreeFcall; + } + + if (!fcall) + return -EIO; + + if (!(fcall->params.rstat.stat->mode & V9FS_DMSYMLINK)) { + retval = -EINVAL; + goto FreeFcall; + } + + /* copy extension buffer into buffer */ + if (strlen(fcall->params.rstat.stat->extension) < buflen) + buflen = strlen(fcall->params.rstat.stat->extension); + + memcpy(buffer, fcall->params.rstat.stat->extension, buflen + 1); + + retval = buflen; + + FreeFcall: + kfree(fcall); + + return retval; +} + +/** + * v9fs_vfs_readlink - read a symlink's location + * @dentry: dentry for symlink + * @buf: buffer to load symlink location into + * @buflen: length of buffer + * + */ + +static int v9fs_vfs_readlink(struct dentry *dentry, char __user * buffer, + int buflen) +{ + int retval; + int ret; + char *link = __getname(); + + if (strlen(link) < buflen) + buflen = strlen(link); + + dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry); + + retval = v9fs_readlink(dentry, link, buflen); + + if (retval > 0) { + if ((ret = copy_to_user(buffer, link, retval)) != 0) { + dprintk(DEBUG_ERROR, "problem copying to user: %d\n", + ret); + retval = ret; + } + } + + putname(link); + return retval; +} + +/** + * v9fs_vfs_follow_link - follow a symlink path + * @dentry: dentry for symlink + * @nd: nameidata + * + */ + +static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd) +{ + int len = 0; + char *link = __getname(); + + dprintk(DEBUG_VFS, "%s n", dentry->d_name.name); + + if (!link) + link = ERR_PTR(-ENOMEM); + else { + len = v9fs_readlink(dentry, link, strlen(link)); + + if (len < 0) { + putname(link); + link = ERR_PTR(len); + } else + link[len] = 0; + } + nd_set_link(nd, link); + + return NULL; +} + +/** + * v9fs_vfs_put_link - release a symlink path + * @dentry: dentry for symlink + * @nd: nameidata + * + */ + +static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p) +{ + char *s = nd_get_link(nd); + + dprintk(DEBUG_VFS, " %s %s\n", dentry->d_name.name, s); + if (!IS_ERR(s)) + putname(s); +} + +/** + * v9fs_vfs_link - create a hardlink + * @old_dentry: dentry for file to link to + * @dir: inode destination for new link + * @new_dentry: dentry for link + * + */ + +/* XXX - lots of code dup'd from symlink and creates, + * figure out a better reuse strategy + */ + +static int +v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir, + struct dentry *dentry) +{ + int retval = -EPERM; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); + struct v9fs_fcall *fcall = NULL; + struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); + struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry, FID_OP); + struct v9fs_fid *newfid = NULL; + char *symname = __getname(); + + dprintk(DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name, + old_dentry->d_name.name); + + if (!v9ses->extended) { + dprintk(DEBUG_ERROR, "not extended\n"); + goto FreeMem; + } + + /* get fid of old_dentry */ + sprintf(symname, "hardlink(%d)\n", oldfid->fid); + + /* issue a create */ + retval = v9fs_create(dir, dentry, V9FS_DMLINK, 0); + if (retval != 0) + goto FreeMem; + + newfid = v9fs_fid_lookup(dentry, FID_OP); + if (!newfid) { + dprintk(DEBUG_ERROR, "couldn't resolve fid from dentry\n"); + goto FreeMem; + } + + /* issue a twstat */ + v9fs_blank_mistat(v9ses, mistat); + strcpy(mistat->data + 1, symname); + mistat->extension = mistat->data + 1; + retval = v9fs_t_wstat(v9ses, newfid->fid, mistat, &fcall); + if (retval < 0) { + dprintk(DEBUG_ERROR, "v9fs_t_wstat error: %s\n", + FCALL_ERROR(fcall)); + goto FreeMem; + } + + kfree(fcall); + + if (v9fs_t_clunk(v9ses, newfid->fid, &fcall)) { + dprintk(DEBUG_ERROR, "clunk for symlink failed: %s\n", + FCALL_ERROR(fcall)); + goto FreeMem; + } + + d_drop(dentry); /* FID - will this also clunk? */ + + kfree(fcall); + fcall = NULL; + + FreeMem: + kfree(mistat); + kfree(fcall); + putname(symname); + return retval; +} + +/** + * v9fs_vfs_mknod - create a special file + * @dir: inode destination for new link + * @dentry: dentry for file + * @mode: mode for creation + * @dev_t: device associated with special file + * + */ + +static int +v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) +{ + int retval = -EPERM; + struct v9fs_fid *newfid; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); + struct v9fs_fcall *fcall = NULL; + struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); + char *symname = __getname(); + + dprintk(DEBUG_VFS, " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, + dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev)); + + if (!new_valid_dev(rdev)) { + retval = -EINVAL; + goto FreeMem; + } + + if (!v9ses->extended) { + dprintk(DEBUG_ERROR, "not extended\n"); + goto FreeMem; + } + + /* issue a create */ + retval = v9fs_create(dir, dentry, mode, 0); + + if (retval != 0) + goto FreeMem; + + newfid = v9fs_fid_lookup(dentry, FID_OP); + if (!newfid) { + dprintk(DEBUG_ERROR, "coudn't resove fid from dentry\n"); + retval = -EINVAL; + goto FreeMem; + } + + /* build extension */ + if (S_ISBLK(mode)) + sprintf(symname, "b %u %u", MAJOR(rdev), MINOR(rdev)); + else if (S_ISCHR(mode)) + sprintf(symname, "c %u %u", MAJOR(rdev), MINOR(rdev)); + else if (S_ISFIFO(mode)) ; /* DO NOTHING */ + else { + retval = -EINVAL; + goto FreeMem; + } + + if (!S_ISFIFO(mode)) { + /* issue a twstat */ + v9fs_blank_mistat(v9ses, mistat); + strcpy(mistat->data + 1, symname); + mistat->extension = mistat->data + 1; + retval = v9fs_t_wstat(v9ses, newfid->fid, mistat, &fcall); + if (retval < 0) { + dprintk(DEBUG_ERROR, "v9fs_t_wstat error: %s\n", + FCALL_ERROR(fcall)); + goto FreeMem; + } + + kfree(fcall); + } + + /* need to update dcache so we show up */ + kfree(fcall); + + if (v9fs_t_clunk(v9ses, newfid->fid, &fcall)) { + dprintk(DEBUG_ERROR, "clunk for symlink failed: %s\n", + FCALL_ERROR(fcall)); + goto FreeMem; + } + + d_drop(dentry); /* FID - will this also clunk? */ + + FreeMem: + kfree(mistat); + kfree(fcall); + putname(symname); + + return retval; +} + +static struct inode_operations v9fs_dir_inode_operations = { + .create = v9fs_vfs_create, + .lookup = v9fs_vfs_lookup, + .symlink = v9fs_vfs_symlink, + .link = v9fs_vfs_link, + .unlink = v9fs_vfs_unlink, + .mkdir = v9fs_vfs_mkdir, + .rmdir = v9fs_vfs_rmdir, + .mknod = v9fs_vfs_mknod, + .rename = v9fs_vfs_rename, + .readlink = v9fs_vfs_readlink, + .getattr = v9fs_vfs_getattr, + .setattr = v9fs_vfs_setattr, +}; + +static struct inode_operations v9fs_file_inode_operations = { + .getattr = v9fs_vfs_getattr, + .setattr = v9fs_vfs_setattr, +}; + +static struct inode_operations v9fs_symlink_inode_operations = { + .readlink = v9fs_vfs_readlink, + .follow_link = v9fs_vfs_follow_link, + .put_link = v9fs_vfs_put_link, + .getattr = v9fs_vfs_getattr, + .setattr = v9fs_vfs_setattr, +}; -- cgit v0.10.2 From 9e82cf6a802a72f0f447eb4c76d6a3fc8736a31d Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:20 -0700 Subject: [PATCH] v9fs: VFS superblock operations and glue This part of the patch contains VFS superblock and mapping code. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c new file mode 100644 index 0000000..14d663e --- /dev/null +++ b/fs/9p/v9fs.c @@ -0,0 +1,448 @@ +/* + * linux/fs/9p/v9fs.c + * + * This file contains functions assisting in mapping VFS to 9P2000 + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "transport.h" +#include "mux.h" +#include "conv.h" + +/* TODO: sysfs or debugfs interface */ +int v9fs_debug_level = 0; /* feature-rific global debug level */ + +/* + * Option Parsing (code inspired by NFS code) + * + */ + +enum { + /* Options that take integer arguments */ + Opt_port, Opt_msize, Opt_uid, Opt_gid, Opt_afid, Opt_debug, + Opt_rfdno, Opt_wfdno, + /* String options */ + Opt_name, Opt_remotename, + /* Options that take no arguments */ + Opt_legacy, Opt_nodevmap, Opt_unix, Opt_tcp, Opt_fd, + /* Error token */ + Opt_err +}; + +static match_table_t tokens = { + {Opt_port, "port=%u"}, + {Opt_msize, "msize=%u"}, + {Opt_uid, "uid=%u"}, + {Opt_gid, "gid=%u"}, + {Opt_afid, "afid=%u"}, + {Opt_rfdno, "rfdno=%u"}, + {Opt_wfdno, "wfdno=%u"}, + {Opt_debug, "debug=%u"}, + {Opt_name, "name=%s"}, + {Opt_remotename, "aname=%s"}, + {Opt_unix, "proto=unix"}, + {Opt_tcp, "proto=tcp"}, + {Opt_fd, "proto=fd"}, + {Opt_tcp, "tcp"}, + {Opt_unix, "unix"}, + {Opt_fd, "fd"}, + {Opt_legacy, "noextend"}, + {Opt_nodevmap, "nodevmap"}, + {Opt_err, NULL} +}; + +/* + * Parse option string. + */ + +/** + * v9fs_parse_options - parse mount options into session structure + * @options: options string passed from mount + * @v9ses: existing v9fs session information + * + */ + +static void v9fs_parse_options(char *options, struct v9fs_session_info *v9ses) +{ + char *p; + substring_t args[MAX_OPT_ARGS]; + int option; + int ret; + + /* setup defaults */ + v9ses->port = V9FS_PORT; + v9ses->maxdata = 9000; + v9ses->proto = PROTO_TCP; + v9ses->extended = 1; + v9ses->afid = ~0; + v9ses->debug = 0; + v9ses->rfdno = ~0; + v9ses->wfdno = ~0; + + if (!options) + return; + + while ((p = strsep(&options, ",")) != NULL) { + int token; + if (!*p) + continue; + token = match_token(p, tokens, args); + if (token < Opt_name) { + if ((ret = match_int(&args[0], &option)) < 0) { + dprintk(DEBUG_ERROR, + "integer field, but no integer?\n"); + continue; + } + + } + switch (token) { + case Opt_port: + v9ses->port = option; + break; + case Opt_msize: + v9ses->maxdata = option; + break; + case Opt_uid: + v9ses->uid = option; + break; + case Opt_gid: + v9ses->gid = option; + break; + case Opt_afid: + v9ses->afid = option; + break; + case Opt_rfdno: + v9ses->rfdno = option; + break; + case Opt_wfdno: + v9ses->wfdno = option; + break; + case Opt_debug: + v9ses->debug = option; + break; + case Opt_tcp: + v9ses->proto = PROTO_TCP; + break; + case Opt_unix: + v9ses->proto = PROTO_UNIX; + break; + case Opt_fd: + v9ses->proto = PROTO_FD; + break; + case Opt_name: + match_strcpy(v9ses->name, &args[0]); + break; + case Opt_remotename: + match_strcpy(v9ses->remotename, &args[0]); + break; + case Opt_legacy: + v9ses->extended = 0; + break; + case Opt_nodevmap: + v9ses->nodev = 1; + break; + default: + continue; + } + } +} + +/** + * v9fs_inode2v9ses - safely extract v9fs session info from super block + * @inode: inode to extract information from + * + * Paranoid function to extract v9ses information from superblock, + * if anything is missing it will report an error. + * + */ + +struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode) +{ + return (inode->i_sb->s_fs_info); +} + +/** + * v9fs_get_idpool - allocate numeric id from pool + * @p - pool to allocate from + * + * XXX - This seems to be an awful generic function, should it be in idr.c with + * the lock included in struct idr? + */ + +int v9fs_get_idpool(struct v9fs_idpool *p) +{ + int i = 0; + int error; + +retry: + if (idr_pre_get(&p->pool, GFP_KERNEL) == 0) + return 0; + + if (down_interruptible(&p->lock) == -EINTR) { + eprintk(KERN_WARNING, "Interrupted while locking\n"); + return -1; + } + + error = idr_get_new(&p->pool, NULL, &i); + up(&p->lock); + + if (error == -EAGAIN) + goto retry; + else if (error) + return -1; + + return i; +} + +/** + * v9fs_put_idpool - release numeric id from pool + * @p - pool to allocate from + * + * XXX - This seems to be an awful generic function, should it be in idr.c with + * the lock included in struct idr? + */ + +void v9fs_put_idpool(int id, struct v9fs_idpool *p) +{ + if (down_interruptible(&p->lock) == -EINTR) { + eprintk(KERN_WARNING, "Interrupted while locking\n"); + return; + } + idr_remove(&p->pool, id); + up(&p->lock); +} + +/** + * v9fs_session_init - initialize session + * @v9ses: session information structure + * @dev_name: device being mounted + * @data: options + * + */ + +int +v9fs_session_init(struct v9fs_session_info *v9ses, + const char *dev_name, char *data) +{ + struct v9fs_fcall *fcall = NULL; + struct v9fs_transport *trans_proto; + int n = 0; + int newfid = -1; + int retval = -EINVAL; + + v9ses->name = __getname(); + if (!v9ses->name) + return -ENOMEM; + + v9ses->remotename = __getname(); + if (!v9ses->remotename) { + putname(v9ses->name); + return -ENOMEM; + } + + strcpy(v9ses->name, V9FS_DEFUSER); + strcpy(v9ses->remotename, V9FS_DEFANAME); + + v9fs_parse_options(data, v9ses); + + /* set global debug level */ + v9fs_debug_level = v9ses->debug; + + /* id pools that are session-dependent: FIDs and TIDs */ + idr_init(&v9ses->fidpool.pool); + init_MUTEX(&v9ses->fidpool.lock); + idr_init(&v9ses->tidpool.pool); + init_MUTEX(&v9ses->tidpool.lock); + + + switch (v9ses->proto) { + case PROTO_TCP: + trans_proto = &v9fs_trans_tcp; + break; + case PROTO_UNIX: + trans_proto = &v9fs_trans_unix; + *v9ses->remotename = 0; + break; + case PROTO_FD: + trans_proto = &v9fs_trans_fd; + *v9ses->remotename = 0; + if((v9ses->wfdno == ~0) || (v9ses->rfdno == ~0)) { + printk(KERN_ERR "v9fs: Insufficient options for proto=fd\n"); + retval = -ENOPROTOOPT; + goto SessCleanUp; + } + break; + default: + printk(KERN_ERR "v9fs: Bad mount protocol %d\n", v9ses->proto); + retval = -ENOPROTOOPT; + goto SessCleanUp; + }; + + v9ses->transport = trans_proto; + + if ((retval = v9ses->transport->init(v9ses, dev_name, data)) < 0) { + eprintk(KERN_ERR, "problem initializing transport\n"); + goto SessCleanUp; + } + + v9ses->inprogress = 0; + v9ses->shutdown = 0; + v9ses->session_hung = 0; + + if ((retval = v9fs_mux_init(v9ses, dev_name)) < 0) { + dprintk(DEBUG_ERROR, "problem initializing mux\n"); + goto SessCleanUp; + } + + if (v9ses->afid == ~0) { + if (v9ses->extended) + retval = + v9fs_t_version(v9ses, v9ses->maxdata, "9P2000.u", + &fcall); + else + retval = v9fs_t_version(v9ses, v9ses->maxdata, "9P2000", + &fcall); + + if (retval < 0) { + dprintk(DEBUG_ERROR, "v9fs_t_version failed\n"); + goto FreeFcall; + } + + /* Really should check for 9P1 and report error */ + if (!strcmp(fcall->params.rversion.version, "9P2000.u")) { + dprintk(DEBUG_9P, "9P2000 UNIX extensions enabled\n"); + v9ses->extended = 1; + } else { + dprintk(DEBUG_9P, "9P2000 legacy mode enabled\n"); + v9ses->extended = 0; + } + + n = fcall->params.rversion.msize; + kfree(fcall); + + if (n < v9ses->maxdata) + v9ses->maxdata = n; + } + + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "couldn't allocate FID\n"); + retval = -ENOMEM; + goto SessCleanUp; + } + /* it is a little bit ugly, but we have to prevent newfid */ + /* being the same as afid, so if it is, get a new fid */ + if (v9ses->afid != ~0 && newfid == v9ses->afid) { + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "couldn't allocate FID\n"); + retval = -ENOMEM; + goto SessCleanUp; + } + } + + if ((retval = + v9fs_t_attach(v9ses, v9ses->name, v9ses->remotename, newfid, + v9ses->afid, NULL)) + < 0) { + dprintk(DEBUG_ERROR, "cannot attach\n"); + goto SessCleanUp; + } + + if (v9ses->afid != ~0) { + if (v9fs_t_clunk(v9ses, v9ses->afid, NULL)) + dprintk(DEBUG_ERROR, "clunk failed\n"); + } + + return newfid; + + FreeFcall: + kfree(fcall); + + SessCleanUp: + v9fs_session_close(v9ses); + return retval; +} + +/** + * v9fs_session_close - shutdown a session + * @v9ses: session information structure + * + */ + +void v9fs_session_close(struct v9fs_session_info *v9ses) +{ + if (v9ses->recvproc) { + send_sig(SIGKILL, v9ses->recvproc, 1); + wait_for_completion(&v9ses->proccmpl); + } + + if (v9ses->transport) + v9ses->transport->close(v9ses->transport); + + putname(v9ses->name); + putname(v9ses->remotename); +} + +extern int v9fs_error_init(void); + +/** + * v9fs_init - Initialize module + * + */ + +static int __init init_v9fs(void) +{ + v9fs_error_init(); + + printk(KERN_INFO "Installing v9fs 9P2000 file system support\n"); + + return register_filesystem(&v9fs_fs_type); +} + +/** + * v9fs_init - shutdown module + * + */ + +static void __exit exit_v9fs(void) +{ + unregister_filesystem(&v9fs_fs_type); +} + +module_init(init_v9fs) +module_exit(exit_v9fs) + +MODULE_AUTHOR("Eric Van Hensbergen "); +MODULE_AUTHOR("Ron Minnich "); +MODULE_LICENSE("GPL"); diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h new file mode 100644 index 0000000..5220302 --- /dev/null +++ b/fs/9p/v9fs.h @@ -0,0 +1,105 @@ +/* + * V9FS definitions. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +/* + * Idpool structure provides lock and id management + * + */ + +struct v9fs_idpool { + struct semaphore lock; + struct idr pool; +}; + +/* + * Session structure provides information for an opened session + * + */ + +struct v9fs_session_info { + /* options */ + unsigned int maxdata; + unsigned char extended; /* set to 1 if we are using UNIX extensions */ + unsigned char nodev; /* set to 1 if no disable device mapping */ + unsigned short port; /* port to connect to */ + unsigned short debug; /* debug level */ + unsigned short proto; /* protocol to use */ + unsigned int afid; /* authentication fid */ + unsigned int rfdno; /* read file descriptor number */ + unsigned int wfdno; /* write file descriptor number */ + + + char *name; /* user name to mount as */ + char *remotename; /* name of remote hierarchy being mounted */ + unsigned int uid; /* default uid/muid for legacy support */ + unsigned int gid; /* default gid for legacy support */ + + /* book keeping */ + struct v9fs_idpool fidpool; /* The FID pool for file descriptors */ + struct v9fs_idpool tidpool; /* The TID pool for transactions ids */ + + /* transport information */ + struct v9fs_transport *transport; + + int inprogress; /* session in progress => true */ + int shutdown; /* session shutting down. no more attaches. */ + unsigned char session_hung; + + /* mux private data */ + struct v9fs_fcall *curfcall; + wait_queue_head_t read_wait; + struct completion fcread; + struct completion proccmpl; + struct task_struct *recvproc; + + spinlock_t muxlock; + struct list_head mux_fcalls; +}; + +/* possible values of ->proto */ +enum { + PROTO_TCP, + PROTO_UNIX, + PROTO_FD, +}; + +int v9fs_session_init(struct v9fs_session_info *, const char *, char *); +struct v9fs_session_info *v9fs_inode2v9ses(struct inode *); +void v9fs_session_close(struct v9fs_session_info *v9ses); +int v9fs_get_idpool(struct v9fs_idpool *p); +void v9fs_put_idpool(int id, struct v9fs_idpool *p); +int v9fs_get_option(char *opts, char *name, char *buf, int buflen); +long long v9fs_get_int_option(char *opts, char *name, long long dflt); +int v9fs_parse_tcp_devname(const char *devname, char **addr, char **remotename); + +#define V9FS_MAGIC 0x01021997 + +/* other default globals */ +#define V9FS_PORT 564 +#define V9FS_DEFUSER "nobody" +#define V9FS_DEFANAME "" + +/* inital pool sizes for fids and tags */ +#define V9FS_START_FIDS 8192 +#define V9FS_START_TIDS 256 diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h new file mode 100644 index 0000000..2f2cea7 --- /dev/null +++ b/fs/9p/v9fs_vfs.h @@ -0,0 +1,53 @@ +/* + * V9FS VFS extensions. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +/* plan9 semantics are that created files are implicitly opened. + * But linux semantics are that you call create, then open. + * the plan9 approach is superior as it provides an atomic + * open. + * we track the create fid here. When the file is opened, if fidopen is + * non-zero, we use the fid and can skip some steps. + * there may be a better way to do this, but I don't know it. + * one BAD way is to clunk the fid on create, then open it again: + * you lose the atomicity of file open + */ + +/* special case: + * unlink calls remove, which is an implicit clunk. So we have to track + * that kind of thing so that we don't try to clunk a dead fid. + */ + +extern struct file_system_type v9fs_fs_type; +extern struct file_operations v9fs_file_operations; +extern struct file_operations v9fs_dir_operations; +extern struct dentry_operations v9fs_dentry_operations; + +struct inode *v9fs_get_inode(struct super_block *sb, int mode); +ino_t v9fs_qid2ino(struct v9fs_qid *qid); +void v9fs_mistat2inode(struct v9fs_stat *, struct inode *, + struct super_block *); +int v9fs_dir_release(struct inode *inode, struct file *filp); +int v9fs_file_open(struct inode *inode, struct file *file); +void v9fs_inode2mistat(struct inode *inode, struct v9fs_stat *mistat); +void v9fs_dentry_release(struct dentry *); diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c new file mode 100644 index 0000000..ce0778a --- /dev/null +++ b/fs/9p/vfs_super.c @@ -0,0 +1,271 @@ +/* + * linux/fs/9p/vfs_super.c + * + * This file contians superblock ops for 9P2000. It is intended that + * you mount this file system on directories. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "conv.h" +#include "fid.h" + +static void v9fs_clear_inode(struct inode *); +static struct super_operations v9fs_super_ops; + +/** + * v9fs_clear_inode - release an inode + * @inode: inode to release + * + */ + +static void v9fs_clear_inode(struct inode *inode) +{ + filemap_fdatawrite(inode->i_mapping); +} + +/** + * v9fs_set_super - set the superblock + * @s: super block + * @data: file system specific data + * + */ + +static int v9fs_set_super(struct super_block *s, void *data) +{ + s->s_fs_info = data; + return set_anon_super(s, data); +} + +/** + * v9fs_fill_super - populate superblock with info + * @sb: superblock + * @v9ses: session information + * + */ + +static void +v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses, + int flags) +{ + sb->s_maxbytes = MAX_LFS_FILESIZE; + sb->s_blocksize_bits = fls(v9ses->maxdata - 1); + sb->s_blocksize = 1 << sb->s_blocksize_bits; + sb->s_magic = V9FS_MAGIC; + sb->s_op = &v9fs_super_ops; + + sb->s_flags = flags | MS_ACTIVE | MS_SYNCHRONOUS | MS_DIRSYNC | + MS_NODIRATIME | MS_NOATIME; +} + +/** + * v9fs_get_sb - mount a superblock + * @fs_type: file system type + * @flags: mount flags + * @dev_name: device name that was mounted + * @data: mount options + * + */ + +static struct super_block *v9fs_get_sb(struct file_system_type + *fs_type, int flags, + const char *dev_name, void *data) +{ + struct super_block *sb = NULL; + struct v9fs_fcall *fcall = NULL; + struct inode *inode = NULL; + struct dentry *root = NULL; + struct v9fs_session_info *v9ses = NULL; + struct v9fs_fid *root_fid = NULL; + int mode = S_IRWXUGO | S_ISVTX; + uid_t uid = current->fsuid; + gid_t gid = current->fsgid; + int stat_result = 0; + int newfid = 0; + int retval = 0; + + dprintk(DEBUG_VFS, " \n"); + + v9ses = kcalloc(1, sizeof(struct v9fs_session_info), GFP_KERNEL); + if (!v9ses) + return ERR_PTR(-ENOMEM); + + if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) { + dprintk(DEBUG_ERROR, "problem initiating session\n"); + retval = newfid; + goto free_session; + } + + sb = sget(fs_type, NULL, v9fs_set_super, v9ses); + + v9fs_fill_super(sb, v9ses, flags); + + inode = v9fs_get_inode(sb, S_IFDIR | mode); + if (IS_ERR(inode)) { + retval = PTR_ERR(inode); + goto put_back_sb; + } + + inode->i_uid = uid; + inode->i_gid = gid; + + root = d_alloc_root(inode); + + if (!root) { + retval = -ENOMEM; + goto release_inode; + } + + sb->s_root = root; + + /* Setup the Root Inode */ + root_fid = v9fs_fid_create(root); + if (root_fid == NULL) { + retval = -ENOMEM; + goto release_dentry; + } + + root_fid->fidopen = 0; + root_fid->v9ses = v9ses; + + stat_result = v9fs_t_stat(v9ses, newfid, &fcall); + if (stat_result < 0) { + dprintk(DEBUG_ERROR, "stat error\n"); + v9fs_t_clunk(v9ses, newfid, NULL); + v9fs_put_idpool(newfid, &v9ses->fidpool); + } else { + root_fid->fid = newfid; + root_fid->qid = fcall->params.rstat.stat->qid; + root->d_inode->i_ino = + v9fs_qid2ino(&fcall->params.rstat.stat->qid); + v9fs_mistat2inode(fcall->params.rstat.stat, root->d_inode, sb); + } + + kfree(fcall); + + if (stat_result < 0) { + retval = stat_result; + goto release_dentry; + } + + return sb; + + release_dentry: + dput(sb->s_root); + + release_inode: + iput(inode); + + put_back_sb: + up_write(&sb->s_umount); + deactivate_super(sb); + v9fs_session_close(v9ses); + + free_session: + kfree(v9ses); + + return ERR_PTR(retval); +} + +/** + * v9fs_kill_super - Kill Superblock + * @s: superblock + * + */ + +static void v9fs_kill_super(struct super_block *s) +{ + struct v9fs_session_info *v9ses = s->s_fs_info; + + dprintk(DEBUG_VFS, " %p\n", s); + + v9fs_dentry_release(s->s_root); /* clunk root */ + + kill_anon_super(s); + + v9fs_session_close(v9ses); + kfree(v9ses); + dprintk(DEBUG_VFS, "exiting kill_super\n"); +} + +/** + * v9fs_show_options - Show mount options in /proc/mounts + * @m: seq_file to write to + * @mnt: mount descriptor + * + */ + +static int v9fs_show_options(struct seq_file *m, struct vfsmount *mnt) +{ + struct v9fs_session_info *v9ses = mnt->mnt_sb->s_fs_info; + + if (v9ses->debug != 0) + seq_printf(m, ",debug=%u", v9ses->debug); + if (v9ses->port != V9FS_PORT) + seq_printf(m, ",port=%u", v9ses->port); + if (v9ses->maxdata != 9000) + seq_printf(m, ",msize=%u", v9ses->maxdata); + if (v9ses->afid != ~0) + seq_printf(m, ",afid=%u", v9ses->afid); + if (v9ses->proto == PROTO_UNIX) + seq_puts(m, ",proto=unix"); + if (v9ses->extended == 0) + seq_puts(m, ",noextend"); + if (v9ses->nodev == 1) + seq_puts(m, ",nodevmap"); + seq_printf(m, ",name=%s", v9ses->name); + seq_printf(m, ",aname=%s", v9ses->remotename); + seq_printf(m, ",uid=%u", v9ses->uid); + seq_printf(m, ",gid=%u", v9ses->gid); + return 0; +} + +static struct super_operations v9fs_super_ops = { + .statfs = simple_statfs, + .clear_inode = v9fs_clear_inode, + .show_options = v9fs_show_options, +}; + +struct file_system_type v9fs_fs_type = { + .name = "9P", + .get_sb = v9fs_get_sb, + .kill_sb = v9fs_kill_super, + .owner = THIS_MODULE, +}; -- cgit v0.10.2 From b8cf945b3166c4394386f162a527c9950f396ce2 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:21 -0700 Subject: [PATCH] v9fs: 9P protocol implementation This part of the patch contains the 9P protocol functions. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/9p.c b/fs/9p/9p.c new file mode 100644 index 0000000..e847f50 --- /dev/null +++ b/fs/9p/9p.c @@ -0,0 +1,359 @@ +/* + * linux/fs/9p/9p.c + * + * This file contains functions 9P2000 functions + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "mux.h" + +/** + * v9fs_t_version - negotiate protocol parameters with sever + * @v9ses: 9P2000 session information + * @msize: requested max size packet + * @version: requested version.extension string + * @fcall: pointer to response fcall pointer + * + */ + +int +v9fs_t_version(struct v9fs_session_info *v9ses, u32 msize, + char *version, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "msize: %d version: %s\n", msize, version); + msg.id = TVERSION; + msg.params.tversion.msize = msize; + msg.params.tversion.version = version; + + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_attach - mount the server + * @v9ses: 9P2000 session information + * @uname: user name doing the attach + * @aname: remote name being attached to + * @fid: mount fid to attatch to root node + * @afid: authentication fid (in this case result key) + * @fcall: pointer to response fcall pointer + * + */ + +int +v9fs_t_attach(struct v9fs_session_info *v9ses, char *uname, char *aname, + u32 fid, u32 afid, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "uname '%s' aname '%s' fid %d afid %d\n", uname, + aname, fid, afid); + msg.id = TATTACH; + msg.params.tattach.fid = fid; + msg.params.tattach.afid = afid; + msg.params.tattach.uname = uname; + msg.params.tattach.aname = aname; + + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_clunk - release a fid (finish a transaction) + * @v9ses: 9P2000 session information + * @fid: fid to release + * @fcall: pointer to response fcall pointer + * + */ + +int +v9fs_t_clunk(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "fid %d\n", fid); + msg.id = TCLUNK; + msg.params.tclunk.fid = fid; + + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_v9fs_t_flush - flush a pending transaction + * @v9ses: 9P2000 session information + * @tag: tid to release + * + */ + +int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 tag) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "oldtag %d\n", tag); + msg.id = TFLUSH; + msg.params.tflush.oldtag = tag; + return v9fs_mux_rpc(v9ses, &msg, NULL); +} + +/** + * v9fs_t_stat - read a file's meta-data + * @v9ses: 9P2000 session information + * @fid: fid pointing to file or directory to get info about + * @fcall: pointer to response fcall + * + */ + +int +v9fs_t_stat(struct v9fs_session_info *v9ses, u32 fid, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "fid %d\n", fid); + if (fcall) + *fcall = NULL; + + msg.id = TSTAT; + msg.params.tstat.fid = fid; + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_wstat - write a file's meta-data + * @v9ses: 9P2000 session information + * @fid: fid pointing to file or directory to write info about + * @stat: metadata + * @fcall: pointer to response fcall + * + */ + +int +v9fs_t_wstat(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_stat *stat, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "fid %d length %d\n", fid, (int)stat->length); + msg.id = TWSTAT; + msg.params.twstat.fid = fid; + msg.params.twstat.stat = stat; + + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_walk - walk a fid to a new file or directory + * @v9ses: 9P2000 session information + * @fid: fid to walk + * @newfid: new fid (for clone operations) + * @name: path to walk fid to + * @fcall: pointer to response fcall + * + */ + +/* TODO: support multiple walk */ + +int +v9fs_t_walk(struct v9fs_session_info *v9ses, u32 fid, u32 newfid, + char *name, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "fid %d newfid %d wname '%s'\n", fid, newfid, name); + msg.id = TWALK; + msg.params.twalk.fid = fid; + msg.params.twalk.newfid = newfid; + + if (name) { + msg.params.twalk.nwname = 1; + msg.params.twalk.wnames = &name; + } else { + msg.params.twalk.nwname = 0; + } + + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_open - open a file + * + * @v9ses - 9P2000 session information + * @fid - fid to open + * @mode - mode to open file (R, RW, etc) + * @fcall - pointer to response fcall + * + */ + +int +v9fs_t_open(struct v9fs_session_info *v9ses, u32 fid, u8 mode, + struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + long errorno = -1; + + dprintk(DEBUG_9P, "fid %d mode %d\n", fid, mode); + msg.id = TOPEN; + msg.params.topen.fid = fid; + msg.params.topen.mode = mode; + + errorno = v9fs_mux_rpc(v9ses, &msg, fcall); + + return errorno; +} + +/** + * v9fs_t_remove - remove a file or directory + * @v9ses: 9P2000 session information + * @fid: fid to remove + * @fcall: pointer to response fcall + * + */ + +int +v9fs_t_remove(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "fid %d\n", fid); + msg.id = TREMOVE; + msg.params.tremove.fid = fid; + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_create - create a file or directory + * @v9ses: 9P2000 session information + * @fid: fid to create + * @name: name of the file or directory to create + * @perm: permissions to create with + * @mode: mode to open file (R, RW, etc) + * @fcall: pointer to response fcall + * + */ + +int +v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name, + u32 perm, u8 mode, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "fid %d name '%s' perm %x mode %d\n", + fid, name, perm, mode); + + msg.id = TCREATE; + msg.params.tcreate.fid = fid; + msg.params.tcreate.name = name; + msg.params.tcreate.perm = perm; + msg.params.tcreate.mode = mode; + + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_read - read data + * @v9ses: 9P2000 session information + * @fid: fid to read from + * @offset: offset to start read at + * @count: how many bytes to read + * @fcall: pointer to response fcall (with data) + * + */ + +int +v9fs_t_read(struct v9fs_session_info *v9ses, u32 fid, u64 offset, + u32 count, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + struct v9fs_fcall *rc = NULL; + long errorno = -1; + + dprintk(DEBUG_9P, "fid %d offset 0x%lx count 0x%x\n", fid, + (long unsigned int)offset, count); + msg.id = TREAD; + msg.params.tread.fid = fid; + msg.params.tread.offset = offset; + msg.params.tread.count = count; + errorno = v9fs_mux_rpc(v9ses, &msg, &rc); + + if (!errorno) { + errorno = rc->params.rread.count; + dump_data(rc->params.rread.data, rc->params.rread.count); + } + + if (fcall) + *fcall = rc; + else + kfree(rc); + + return errorno; +} + +/** + * v9fs_t_write - write data + * @v9ses: 9P2000 session information + * @fid: fid to write to + * @offset: offset to start write at + * @count: how many bytes to write + * @fcall: pointer to response fcall + * + */ + +int +v9fs_t_write(struct v9fs_session_info *v9ses, u32 fid, + u64 offset, u32 count, void *data, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + struct v9fs_fcall *rc = NULL; + long errorno = -1; + + dprintk(DEBUG_9P, "fid %d offset 0x%llx count 0x%x\n", fid, + (unsigned long long)offset, count); + dump_data(data, count); + + msg.id = TWRITE; + msg.params.twrite.fid = fid; + msg.params.twrite.offset = offset; + msg.params.twrite.count = count; + msg.params.twrite.data = data; + + errorno = v9fs_mux_rpc(v9ses, &msg, &rc); + + if (!errorno) + errorno = rc->params.rwrite.count; + + if (fcall) + *fcall = rc; + else + kfree(rc); + + return errorno; +} diff --git a/fs/9p/9p.h b/fs/9p/9p.h new file mode 100644 index 0000000..f554242 --- /dev/null +++ b/fs/9p/9p.h @@ -0,0 +1,341 @@ +/* + * linux/fs/9p/9p.h + * + * 9P protocol definitions. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +/* Message Types */ +enum { + TVERSION = 100, + RVERSION, + TAUTH = 102, + RAUTH, + TATTACH = 104, + RATTACH, + TERROR = 106, + RERROR, + TFLUSH = 108, + RFLUSH, + TWALK = 110, + RWALK, + TOPEN = 112, + ROPEN, + TCREATE = 114, + RCREATE, + TREAD = 116, + RREAD, + TWRITE = 118, + RWRITE, + TCLUNK = 120, + RCLUNK, + TREMOVE = 122, + RREMOVE, + TSTAT = 124, + RSTAT, + TWSTAT = 126, + RWSTAT, +}; + +/* modes */ +enum { + V9FS_OREAD = 0x00, + V9FS_OWRITE = 0x01, + V9FS_ORDWR = 0x02, + V9FS_OEXEC = 0x03, + V9FS_OEXCL = 0x04, + V9FS_OTRUNC = 0x10, + V9FS_OREXEC = 0x20, + V9FS_ORCLOSE = 0x40, + V9FS_OAPPEND = 0x80, +}; + +/* permissions */ +enum { + V9FS_DMDIR = 0x80000000, + V9FS_DMAPPEND = 0x40000000, + V9FS_DMEXCL = 0x20000000, + V9FS_DMMOUNT = 0x10000000, + V9FS_DMAUTH = 0x08000000, + V9FS_DMTMP = 0x04000000, + V9FS_DMSYMLINK = 0x02000000, + V9FS_DMLINK = 0x01000000, + /* 9P2000.u extensions */ + V9FS_DMDEVICE = 0x00800000, + V9FS_DMNAMEDPIPE = 0x00200000, + V9FS_DMSOCKET = 0x00100000, + V9FS_DMSETUID = 0x00080000, + V9FS_DMSETGID = 0x00040000, +}; + +/* qid.types */ +enum { + V9FS_QTDIR = 0x80, + V9FS_QTAPPEND = 0x40, + V9FS_QTEXCL = 0x20, + V9FS_QTMOUNT = 0x10, + V9FS_QTAUTH = 0x08, + V9FS_QTTMP = 0x04, + V9FS_QTSYMLINK = 0x02, + V9FS_QTLINK = 0x01, + V9FS_QTFILE = 0x00, +}; + +/* ample room for Twrite/Rread header (iounit) */ +#define V9FS_IOHDRSZ 24 + +/* qids are the unique ID for a file (like an inode */ +struct v9fs_qid { + u8 type; + u32 version; + u64 path; +}; + +/* Plan 9 file metadata (stat) structure */ +struct v9fs_stat { + u16 size; + u16 type; + u32 dev; + struct v9fs_qid qid; + u32 mode; + u32 atime; + u32 mtime; + u64 length; + char *name; + char *uid; + char *gid; + char *muid; + char *extension; /* 9p2000.u extensions */ + u32 n_uid; /* 9p2000.u extensions */ + u32 n_gid; /* 9p2000.u extensions */ + u32 n_muid; /* 9p2000.u extensions */ + char data[0]; +}; + +/* Structures for Protocol Operations */ + +struct Tversion { + u32 msize; + char *version; +}; + +struct Rversion { + u32 msize; + char *version; +}; + +struct Tauth { + u32 afid; + char *uname; + char *aname; +}; + +struct Rauth { + struct v9fs_qid qid; +}; + +struct Rerror { + char *error; + u32 errno; /* 9p2000.u extension */ +}; + +struct Tflush { + u32 oldtag; +}; + +struct Rflush { +}; + +struct Tattach { + u32 fid; + u32 afid; + char *uname; + char *aname; +}; + +struct Rattach { + struct v9fs_qid qid; +}; + +struct Twalk { + u32 fid; + u32 newfid; + u32 nwname; + char **wnames; +}; + +struct Rwalk { + u32 nwqid; + struct v9fs_qid *wqids; +}; + +struct Topen { + u32 fid; + u8 mode; +}; + +struct Ropen { + struct v9fs_qid qid; + u32 iounit; +}; + +struct Tcreate { + u32 fid; + char *name; + u32 perm; + u8 mode; +}; + +struct Rcreate { + struct v9fs_qid qid; + u32 iounit; +}; + +struct Tread { + u32 fid; + u64 offset; + u32 count; +}; + +struct Rread { + u32 count; + u8 *data; +}; + +struct Twrite { + u32 fid; + u64 offset; + u32 count; + u8 *data; +}; + +struct Rwrite { + u32 count; +}; + +struct Tclunk { + u32 fid; +}; + +struct Rclunk { +}; + +struct Tremove { + u32 fid; +}; + +struct Rremove { +}; + +struct Tstat { + u32 fid; +}; + +struct Rstat { + struct v9fs_stat *stat; +}; + +struct Twstat { + u32 fid; + struct v9fs_stat *stat; +}; + +struct Rwstat { +}; + +/* + * fcall is the primary packet structure + * + */ + +struct v9fs_fcall { + u32 size; + u8 id; + u16 tag; + + union { + struct Tversion tversion; + struct Rversion rversion; + struct Tauth tauth; + struct Rauth rauth; + struct Rerror rerror; + struct Tflush tflush; + struct Rflush rflush; + struct Tattach tattach; + struct Rattach rattach; + struct Twalk twalk; + struct Rwalk rwalk; + struct Topen topen; + struct Ropen ropen; + struct Tcreate tcreate; + struct Rcreate rcreate; + struct Tread tread; + struct Rread rread; + struct Twrite twrite; + struct Rwrite rwrite; + struct Tclunk tclunk; + struct Rclunk rclunk; + struct Tremove tremove; + struct Rremove rremove; + struct Tstat tstat; + struct Rstat rstat; + struct Twstat twstat; + struct Rwstat rwstat; + } params; +}; + +#define FCALL_ERROR(fcall) (fcall ? fcall->params.rerror.error : "") + +int v9fs_t_version(struct v9fs_session_info *v9ses, u32 msize, + char *version, struct v9fs_fcall **rcall); + +int v9fs_t_attach(struct v9fs_session_info *v9ses, char *uname, char *aname, + u32 fid, u32 afid, struct v9fs_fcall **rcall); + +int v9fs_t_clunk(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_fcall **rcall); + +int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 oldtag); + +int v9fs_t_stat(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_fcall **rcall); + +int v9fs_t_wstat(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_stat *stat, struct v9fs_fcall **rcall); + +int v9fs_t_walk(struct v9fs_session_info *v9ses, u32 fid, u32 newfid, + char *name, struct v9fs_fcall **rcall); + +int v9fs_t_open(struct v9fs_session_info *v9ses, u32 fid, u8 mode, + struct v9fs_fcall **rcall); + +int v9fs_t_remove(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_fcall **rcall); + +int v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name, + u32 perm, u8 mode, struct v9fs_fcall **rcall); + +int v9fs_t_read(struct v9fs_session_info *v9ses, u32 fid, + u64 offset, u32 count, struct v9fs_fcall **rcall); + +int v9fs_t_write(struct v9fs_session_info *v9ses, u32 fid, u64 offset, + u32 count, void *data, struct v9fs_fcall **rcall); diff --git a/fs/9p/conv.c b/fs/9p/conv.c new file mode 100644 index 0000000..1554731 --- /dev/null +++ b/fs/9p/conv.c @@ -0,0 +1,693 @@ +/* + * linux/fs/9p/conv.c + * + * 9P protocol conversion functions + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "conv.h" + +/* + * Buffer to help with string parsing + */ +struct cbuf { + unsigned char *sp; + unsigned char *p; + unsigned char *ep; +}; + +static inline void buf_init(struct cbuf *buf, void *data, int datalen) +{ + buf->sp = buf->p = data; + buf->ep = data + datalen; +} + +static inline int buf_check_overflow(struct cbuf *buf) +{ + return buf->p > buf->ep; +} + +static inline void buf_check_size(struct cbuf *buf, int len) +{ + if (buf->p+len > buf->ep) { + if (buf->p < buf->ep) { + eprintk(KERN_ERR, "buffer overflow\n"); + buf->p = buf->ep + 1; + } + } +} + +static inline void *buf_alloc(struct cbuf *buf, int len) +{ + void *ret = NULL; + + buf_check_size(buf, len); + ret = buf->p; + buf->p += len; + + return ret; +} + +static inline void buf_put_int8(struct cbuf *buf, u8 val) +{ + buf_check_size(buf, 1); + + buf->p[0] = val; + buf->p++; +} + +static inline void buf_put_int16(struct cbuf *buf, u16 val) +{ + buf_check_size(buf, 2); + + *(__le16 *) buf->p = cpu_to_le16(val); + buf->p += 2; +} + +static inline void buf_put_int32(struct cbuf *buf, u32 val) +{ + buf_check_size(buf, 4); + + *(__le32 *)buf->p = cpu_to_le32(val); + buf->p += 4; +} + +static inline void buf_put_int64(struct cbuf *buf, u64 val) +{ + buf_check_size(buf, 8); + + *(__le64 *)buf->p = cpu_to_le64(val); + buf->p += 8; +} + +static inline void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) +{ + buf_check_size(buf, slen + 2); + + buf_put_int16(buf, slen); + memcpy(buf->p, s, slen); + buf->p += slen; +} + +static inline void buf_put_string(struct cbuf *buf, const char *s) +{ + buf_put_stringn(buf, s, strlen(s)); +} + +static inline void buf_put_data(struct cbuf *buf, void *data, u32 datalen) +{ + buf_check_size(buf, datalen); + + memcpy(buf->p, data, datalen); + buf->p += datalen; +} + +static inline u8 buf_get_int8(struct cbuf *buf) +{ + u8 ret = 0; + + buf_check_size(buf, 1); + ret = buf->p[0]; + + buf->p++; + + return ret; +} + +static inline u16 buf_get_int16(struct cbuf *buf) +{ + u16 ret = 0; + + buf_check_size(buf, 2); + ret = le16_to_cpu(*(__le16 *)buf->p); + + buf->p += 2; + + return ret; +} + +static inline u32 buf_get_int32(struct cbuf *buf) +{ + u32 ret = 0; + + buf_check_size(buf, 4); + ret = le32_to_cpu(*(__le32 *)buf->p); + + buf->p += 4; + + return ret; +} + +static inline u64 buf_get_int64(struct cbuf *buf) +{ + u64 ret = 0; + + buf_check_size(buf, 8); + ret = le64_to_cpu(*(__le64 *)buf->p); + + buf->p += 8; + + return ret; +} + +static inline int +buf_get_string(struct cbuf *buf, char *data, unsigned int datalen) +{ + + u16 len = buf_get_int16(buf); + buf_check_size(buf, len); + if (len + 1 > datalen) + return 0; + + memcpy(data, buf->p, len); + data[len] = 0; + buf->p += len; + + return len + 1; +} + +static inline char *buf_get_stringb(struct cbuf *buf, struct cbuf *sbuf) +{ + char *ret = NULL; + int n = buf_get_string(buf, sbuf->p, sbuf->ep - sbuf->p); + + if (n > 0) { + ret = sbuf->p; + sbuf->p += n; + } + + return ret; +} + +static inline int buf_get_data(struct cbuf *buf, void *data, int datalen) +{ + buf_check_size(buf, datalen); + + memcpy(data, buf->p, datalen); + buf->p += datalen; + + return datalen; +} + +static inline void *buf_get_datab(struct cbuf *buf, struct cbuf *dbuf, + int datalen) +{ + char *ret = NULL; + int n = 0; + + buf_check_size(dbuf, datalen); + + n = buf_get_data(buf, dbuf->p, datalen); + + if (n > 0) { + ret = dbuf->p; + dbuf->p += n; + } + + return ret; +} + +/** + * v9fs_size_stat - calculate the size of a variable length stat struct + * @v9ses: session information + * @stat: metadata (stat) structure + * + */ + +static int v9fs_size_stat(struct v9fs_session_info *v9ses, + struct v9fs_stat *stat) +{ + int size = 0; + + if (stat == NULL) { + eprintk(KERN_ERR, "v9fs_size_stat: got a NULL stat pointer\n"); + return 0; + } + + size = /* 2 + *//* size[2] */ + 2 + /* type[2] */ + 4 + /* dev[4] */ + 1 + /* qid.type[1] */ + 4 + /* qid.vers[4] */ + 8 + /* qid.path[8] */ + 4 + /* mode[4] */ + 4 + /* atime[4] */ + 4 + /* mtime[4] */ + 8 + /* length[8] */ + 8; /* minimum sum of string lengths */ + + if (stat->name) + size += strlen(stat->name); + if (stat->uid) + size += strlen(stat->uid); + if (stat->gid) + size += strlen(stat->gid); + if (stat->muid) + size += strlen(stat->muid); + + if (v9ses->extended) { + size += 4 + /* n_uid[4] */ + 4 + /* n_gid[4] */ + 4 + /* n_muid[4] */ + 2; /* string length of extension[4] */ + if (stat->extension) + size += strlen(stat->extension); + } + + return size; +} + +/** + * serialize_stat - safely format a stat structure for transmission + * @v9ses: session info + * @stat: metadata (stat) structure + * @bufp: buffer to serialize structure into + * + */ + +static int +serialize_stat(struct v9fs_session_info *v9ses, struct v9fs_stat *stat, + struct cbuf *bufp) +{ + buf_put_int16(bufp, stat->size); + buf_put_int16(bufp, stat->type); + buf_put_int32(bufp, stat->dev); + buf_put_int8(bufp, stat->qid.type); + buf_put_int32(bufp, stat->qid.version); + buf_put_int64(bufp, stat->qid.path); + buf_put_int32(bufp, stat->mode); + buf_put_int32(bufp, stat->atime); + buf_put_int32(bufp, stat->mtime); + buf_put_int64(bufp, stat->length); + + buf_put_string(bufp, stat->name); + buf_put_string(bufp, stat->uid); + buf_put_string(bufp, stat->gid); + buf_put_string(bufp, stat->muid); + + if (v9ses->extended) { + buf_put_string(bufp, stat->extension); + buf_put_int32(bufp, stat->n_uid); + buf_put_int32(bufp, stat->n_gid); + buf_put_int32(bufp, stat->n_muid); + } + + if (buf_check_overflow(bufp)) + return 0; + + return stat->size; +} + +/** + * deserialize_stat - safely decode a recieved metadata (stat) structure + * @v9ses: session info + * @bufp: buffer to deserialize + * @stat: metadata (stat) structure + * @dbufp: buffer to deserialize variable strings into + * + */ + +static inline int +deserialize_stat(struct v9fs_session_info *v9ses, struct cbuf *bufp, + struct v9fs_stat *stat, struct cbuf *dbufp) +{ + + stat->size = buf_get_int16(bufp); + stat->type = buf_get_int16(bufp); + stat->dev = buf_get_int32(bufp); + stat->qid.type = buf_get_int8(bufp); + stat->qid.version = buf_get_int32(bufp); + stat->qid.path = buf_get_int64(bufp); + stat->mode = buf_get_int32(bufp); + stat->atime = buf_get_int32(bufp); + stat->mtime = buf_get_int32(bufp); + stat->length = buf_get_int64(bufp); + stat->name = buf_get_stringb(bufp, dbufp); + stat->uid = buf_get_stringb(bufp, dbufp); + stat->gid = buf_get_stringb(bufp, dbufp); + stat->muid = buf_get_stringb(bufp, dbufp); + + if (v9ses->extended) { + stat->extension = buf_get_stringb(bufp, dbufp); + stat->n_uid = buf_get_int32(bufp); + stat->n_gid = buf_get_int32(bufp); + stat->n_muid = buf_get_int32(bufp); + } + + if (buf_check_overflow(bufp) || buf_check_overflow(dbufp)) + return 0; + + return stat->size + 2; +} + +/** + * deserialize_statb - wrapper for decoding a received metadata structure + * @v9ses: session info + * @bufp: buffer to deserialize + * @dbufp: buffer to deserialize variable strings into + * + */ + +static inline struct v9fs_stat *deserialize_statb(struct v9fs_session_info + *v9ses, struct cbuf *bufp, + struct cbuf *dbufp) +{ + struct v9fs_stat *ret = buf_alloc(dbufp, sizeof(struct v9fs_stat)); + + if (ret) { + int n = deserialize_stat(v9ses, bufp, ret, dbufp); + if (n <= 0) + return NULL; + } + + return ret; +} + +/** + * v9fs_deserialize_stat - decode a received metadata structure + * @v9ses: session info + * @buf: buffer to deserialize + * @buflen: length of received buffer + * @stat: metadata structure to decode into + * @statlen: length of destination metadata structure + * + */ + +int +v9fs_deserialize_stat(struct v9fs_session_info *v9ses, void *buf, + u32 buflen, struct v9fs_stat *stat, u32 statlen) +{ + struct cbuf buffer; + struct cbuf *bufp = &buffer; + struct cbuf dbuffer; + struct cbuf *dbufp = &dbuffer; + + buf_init(bufp, buf, buflen); + buf_init(dbufp, (char *)stat + sizeof(struct v9fs_stat), + statlen - sizeof(struct v9fs_stat)); + + return deserialize_stat(v9ses, bufp, stat, dbufp); +} + +static inline int +v9fs_size_fcall(struct v9fs_session_info *v9ses, struct v9fs_fcall *fcall) +{ + int size = 4 + 1 + 2; /* size[4] msg[1] tag[2] */ + int i = 0; + + switch (fcall->id) { + default: + eprintk(KERN_ERR, "bad msg type %d\n", fcall->id); + return 0; + case TVERSION: /* msize[4] version[s] */ + size += 4 + 2 + strlen(fcall->params.tversion.version); + break; + case TAUTH: /* afid[4] uname[s] aname[s] */ + size += 4 + 2 + strlen(fcall->params.tauth.uname) + + 2 + strlen(fcall->params.tauth.aname); + break; + case TFLUSH: /* oldtag[2] */ + size += 2; + break; + case TATTACH: /* fid[4] afid[4] uname[s] aname[s] */ + size += 4 + 4 + 2 + strlen(fcall->params.tattach.uname) + + 2 + strlen(fcall->params.tattach.aname); + break; + case TWALK: /* fid[4] newfid[4] nwname[2] nwname*(wname[s]) */ + size += 4 + 4 + 2; + /* now compute total for the array of names */ + for (i = 0; i < fcall->params.twalk.nwname; i++) + size += 2 + strlen(fcall->params.twalk.wnames[i]); + break; + case TOPEN: /* fid[4] mode[1] */ + size += 4 + 1; + break; + case TCREATE: /* fid[4] name[s] perm[4] mode[1] */ + size += 4 + 2 + strlen(fcall->params.tcreate.name) + 4 + 1; + break; + case TREAD: /* fid[4] offset[8] count[4] */ + size += 4 + 8 + 4; + break; + case TWRITE: /* fid[4] offset[8] count[4] data[count] */ + size += 4 + 8 + 4 + fcall->params.twrite.count; + break; + case TCLUNK: /* fid[4] */ + size += 4; + break; + case TREMOVE: /* fid[4] */ + size += 4; + break; + case TSTAT: /* fid[4] */ + size += 4; + break; + case TWSTAT: /* fid[4] stat[n] */ + fcall->params.twstat.stat->size = + v9fs_size_stat(v9ses, fcall->params.twstat.stat); + size += 4 + 2 + 2 + fcall->params.twstat.stat->size; + } + return size; +} + +/* + * v9fs_serialize_fcall - marshall fcall struct into a packet + * @v9ses: session information + * @fcall: structure to convert + * @data: buffer to serialize fcall into + * @datalen: length of buffer to serialize fcall into + * + */ + +int +v9fs_serialize_fcall(struct v9fs_session_info *v9ses, struct v9fs_fcall *fcall, + void *data, u32 datalen) +{ + int i = 0; + struct v9fs_stat *stat = NULL; + struct cbuf buffer; + struct cbuf *bufp = &buffer; + + buf_init(bufp, data, datalen); + + if (!fcall) { + eprintk(KERN_ERR, "no fcall\n"); + return -EINVAL; + } + + fcall->size = v9fs_size_fcall(v9ses, fcall); + + buf_put_int32(bufp, fcall->size); + buf_put_int8(bufp, fcall->id); + buf_put_int16(bufp, fcall->tag); + + dprintk(DEBUG_CONV, "size %d id %d tag %d\n", fcall->size, fcall->id, + fcall->tag); + + /* now encode it */ + switch (fcall->id) { + default: + eprintk(KERN_ERR, "bad msg type: %d\n", fcall->id); + return -EPROTO; + case TVERSION: + buf_put_int32(bufp, fcall->params.tversion.msize); + buf_put_string(bufp, fcall->params.tversion.version); + break; + case TAUTH: + buf_put_int32(bufp, fcall->params.tauth.afid); + buf_put_string(bufp, fcall->params.tauth.uname); + buf_put_string(bufp, fcall->params.tauth.aname); + break; + case TFLUSH: + buf_put_int16(bufp, fcall->params.tflush.oldtag); + break; + case TATTACH: + buf_put_int32(bufp, fcall->params.tattach.fid); + buf_put_int32(bufp, fcall->params.tattach.afid); + buf_put_string(bufp, fcall->params.tattach.uname); + buf_put_string(bufp, fcall->params.tattach.aname); + break; + case TWALK: + buf_put_int32(bufp, fcall->params.twalk.fid); + buf_put_int32(bufp, fcall->params.twalk.newfid); + buf_put_int16(bufp, fcall->params.twalk.nwname); + for (i = 0; i < fcall->params.twalk.nwname; i++) + buf_put_string(bufp, fcall->params.twalk.wnames[i]); + break; + case TOPEN: + buf_put_int32(bufp, fcall->params.topen.fid); + buf_put_int8(bufp, fcall->params.topen.mode); + break; + case TCREATE: + buf_put_int32(bufp, fcall->params.tcreate.fid); + buf_put_string(bufp, fcall->params.tcreate.name); + buf_put_int32(bufp, fcall->params.tcreate.perm); + buf_put_int8(bufp, fcall->params.tcreate.mode); + break; + case TREAD: + buf_put_int32(bufp, fcall->params.tread.fid); + buf_put_int64(bufp, fcall->params.tread.offset); + buf_put_int32(bufp, fcall->params.tread.count); + break; + case TWRITE: + buf_put_int32(bufp, fcall->params.twrite.fid); + buf_put_int64(bufp, fcall->params.twrite.offset); + buf_put_int32(bufp, fcall->params.twrite.count); + buf_put_data(bufp, fcall->params.twrite.data, + fcall->params.twrite.count); + break; + case TCLUNK: + buf_put_int32(bufp, fcall->params.tclunk.fid); + break; + case TREMOVE: + buf_put_int32(bufp, fcall->params.tremove.fid); + break; + case TSTAT: + buf_put_int32(bufp, fcall->params.tstat.fid); + break; + case TWSTAT: + buf_put_int32(bufp, fcall->params.twstat.fid); + stat = fcall->params.twstat.stat; + + buf_put_int16(bufp, stat->size + 2); + serialize_stat(v9ses, stat, bufp); + break; + } + + if (buf_check_overflow(bufp)) + return -EIO; + + return fcall->size; +} + +/** + * deserialize_fcall - unmarshal a response + * @v9ses: session information + * @msgsize: size of rcall message + * @buf: recieved buffer + * @buflen: length of received buffer + * @rcall: fcall structure to populate + * @rcalllen: length of fcall structure to populate + * + */ + +int +v9fs_deserialize_fcall(struct v9fs_session_info *v9ses, u32 msgsize, + void *buf, u32 buflen, struct v9fs_fcall *rcall, + int rcalllen) +{ + + struct cbuf buffer; + struct cbuf *bufp = &buffer; + struct cbuf dbuffer; + struct cbuf *dbufp = &dbuffer; + int i = 0; + + buf_init(bufp, buf, buflen); + buf_init(dbufp, (char *)rcall + sizeof(struct v9fs_fcall), + rcalllen - sizeof(struct v9fs_fcall)); + + rcall->size = msgsize; + rcall->id = buf_get_int8(bufp); + rcall->tag = buf_get_int16(bufp); + + dprintk(DEBUG_CONV, "size %d id %d tag %d\n", rcall->size, rcall->id, + rcall->tag); + switch (rcall->id) { + default: + eprintk(KERN_ERR, "unknown message type: %d\n", rcall->id); + return -EPROTO; + case RVERSION: + rcall->params.rversion.msize = buf_get_int32(bufp); + rcall->params.rversion.version = buf_get_stringb(bufp, dbufp); + break; + case RFLUSH: + break; + case RATTACH: + rcall->params.rattach.qid.type = buf_get_int8(bufp); + rcall->params.rattach.qid.version = buf_get_int32(bufp); + rcall->params.rattach.qid.path = buf_get_int64(bufp); + break; + case RWALK: + rcall->params.rwalk.nwqid = buf_get_int16(bufp); + rcall->params.rwalk.wqids = buf_alloc(bufp, + rcall->params.rwalk.nwqid * sizeof(struct v9fs_qid)); + if (rcall->params.rwalk.wqids) + for (i = 0; i < rcall->params.rwalk.nwqid; i++) { + rcall->params.rwalk.wqids[i].type = + buf_get_int8(bufp); + rcall->params.rwalk.wqids[i].version = + buf_get_int16(bufp); + rcall->params.rwalk.wqids[i].path = + buf_get_int64(bufp); + } + break; + case ROPEN: + rcall->params.ropen.qid.type = buf_get_int8(bufp); + rcall->params.ropen.qid.version = buf_get_int32(bufp); + rcall->params.ropen.qid.path = buf_get_int64(bufp); + rcall->params.ropen.iounit = buf_get_int32(bufp); + break; + case RCREATE: + rcall->params.rcreate.qid.type = buf_get_int8(bufp); + rcall->params.rcreate.qid.version = buf_get_int32(bufp); + rcall->params.rcreate.qid.path = buf_get_int64(bufp); + rcall->params.rcreate.iounit = buf_get_int32(bufp); + break; + case RREAD: + rcall->params.rread.count = buf_get_int32(bufp); + rcall->params.rread.data = buf_get_datab(bufp, dbufp, + rcall->params.rread.count); + break; + case RWRITE: + rcall->params.rwrite.count = buf_get_int32(bufp); + break; + case RCLUNK: + break; + case RREMOVE: + break; + case RSTAT: + buf_get_int16(bufp); + rcall->params.rstat.stat = + deserialize_statb(v9ses, bufp, dbufp); + break; + case RWSTAT: + break; + case RERROR: + rcall->params.rerror.error = buf_get_stringb(bufp, dbufp); + if (v9ses->extended) + rcall->params.rerror.errno = buf_get_int16(bufp); + break; + } + + if (buf_check_overflow(bufp) || buf_check_overflow(dbufp)) + return -EIO; + + return rcall->size; +} diff --git a/fs/9p/conv.h b/fs/9p/conv.h new file mode 100644 index 0000000..ee84961 --- /dev/null +++ b/fs/9p/conv.h @@ -0,0 +1,36 @@ +/* + * linux/fs/9p/conv.h + * + * 9P protocol conversion definitions + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +int v9fs_deserialize_stat(struct v9fs_session_info *, void *buf, + u32 buflen, struct v9fs_stat *stat, u32 statlen); +int v9fs_serialize_fcall(struct v9fs_session_info *, struct v9fs_fcall *tcall, + void *buf, u32 buflen); +int v9fs_deserialize_fcall(struct v9fs_session_info *, u32 msglen, + void *buf, u32 buflen, struct v9fs_fcall *rcall, + int rcalllen); + +/* this one is actually in error.c right now */ +int v9fs_errstr2errno(char *errstr); -- cgit v0.10.2 From 426cc91aa651b50713d06d45e5c3c3e90cfd40d9 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:22 -0700 Subject: [PATCH] v9fs: transport modules This part of the patch contains transport routines. Signed-off-by: Eric Van Hensbergen Signed-off-by: Latchesar Ionkov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/mux.c b/fs/9p/mux.c new file mode 100644 index 0000000..8ebc1af --- /dev/null +++ b/fs/9p/mux.c @@ -0,0 +1,440 @@ +/* + * linux/fs/9p/mux.c + * + * Protocol Multiplexer + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2004 by Latchesar Ionkov + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "transport.h" +#include "conv.h" +#include "mux.h" + +/** + * dprintcond - print condition of session info + * @v9ses: session info structure + * @req: RPC request structure + * + */ + +static inline int +dprintcond(struct v9fs_session_info *v9ses, struct v9fs_rpcreq *req) +{ + dprintk(DEBUG_MUX, "condition: %d, %p\n", v9ses->transport->status, + req->rcall); + return 0; +} + +/** + * xread - force read of a certain number of bytes + * @v9ses: session info structure + * @ptr: pointer to buffer + * @sz: number of bytes to read + * + * Chuck Cranor CS-533 project1 + */ + +static int xread(struct v9fs_session_info *v9ses, void *ptr, unsigned long sz) +{ + int rd = 0; + int ret = 0; + while (rd < sz) { + ret = v9ses->transport->read(v9ses->transport, ptr, sz - rd); + if (ret <= 0) { + dprintk(DEBUG_ERROR, "xread errno %d\n", ret); + return ret; + } + rd += ret; + ptr += ret; + } + return (rd); +} + +/** + * read_message - read a full 9P2000 fcall packet + * @v9ses: session info structure + * @rcall: fcall structure to read into + * @rcalllen: size of fcall buffer + * + */ + +static int +read_message(struct v9fs_session_info *v9ses, + struct v9fs_fcall *rcall, int rcalllen) +{ + unsigned char buf[4]; + void *data; + int size = 0; + int res = 0; + + res = xread(v9ses, buf, sizeof(buf)); + if (res < 0) { + dprintk(DEBUG_ERROR, + "Reading of count field failed returned: %d\n", res); + return res; + } + + if (res < 4) { + dprintk(DEBUG_ERROR, + "Reading of count field failed returned: %d\n", res); + return -EIO; + } + + size = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); + dprintk(DEBUG_MUX, "got a packet count: %d\n", size); + + /* adjust for the four bytes of size */ + size -= 4; + + if (size > v9ses->maxdata) { + dprintk(DEBUG_ERROR, "packet too big: %d\n", size); + return -E2BIG; + } + + data = kmalloc(size, GFP_KERNEL); + if (!data) { + eprintk(KERN_WARNING, "out of memory\n"); + return -ENOMEM; + } + + res = xread(v9ses, data, size); + if (res < size) { + dprintk(DEBUG_ERROR, "Reading of fcall failed returned: %d\n", + res); + kfree(data); + return res; + } + + /* we now have an in-memory string that is the reply. + * deserialize it. There is very little to go wrong at this point + * save for v9fs_alloc errors. + */ + res = v9fs_deserialize_fcall(v9ses, size, data, v9ses->maxdata, + rcall, rcalllen); + + kfree(data); + + if (res < 0) + return res; + + return 0; +} + +/** + * v9fs_recv - receive an RPC response for a particular tag + * @v9ses: session info structure + * @req: RPC request structure + * + */ + +static int v9fs_recv(struct v9fs_session_info *v9ses, struct v9fs_rpcreq *req) +{ + int ret = 0; + + dprintk(DEBUG_MUX, "waiting for response: %d\n", req->tcall->tag); + ret = wait_event_interruptible(v9ses->read_wait, + ((v9ses->transport->status != Connected) || + (req->rcall != 0) || dprintcond(v9ses, req))); + + dprintk(DEBUG_MUX, "got it: rcall %p\n", req->rcall); + if (v9ses->transport->status == Disconnected) + return -ECONNRESET; + + if (ret == 0) { + spin_lock(&v9ses->muxlock); + list_del(&req->next); + spin_unlock(&v9ses->muxlock); + } + + return ret; +} + +/** + * v9fs_send - send a 9P request + * @v9ses: session info structure + * @req: RPC request to send + * + */ + +static int v9fs_send(struct v9fs_session_info *v9ses, struct v9fs_rpcreq *req) +{ + int ret = -1; + void *data = NULL; + struct v9fs_fcall *tcall = req->tcall; + + data = kmalloc(v9ses->maxdata + V9FS_IOHDRSZ, GFP_KERNEL); + if (!data) + return -ENOMEM; + + tcall->size = 0; /* enforce size recalculation */ + ret = + v9fs_serialize_fcall(v9ses, tcall, data, + v9ses->maxdata + V9FS_IOHDRSZ); + if (ret < 0) + goto free_data; + + spin_lock(&v9ses->muxlock); + list_add(&req->next, &v9ses->mux_fcalls); + spin_unlock(&v9ses->muxlock); + + dprintk(DEBUG_MUX, "sending message: tag %d size %d\n", tcall->tag, + tcall->size); + ret = v9ses->transport->write(v9ses->transport, data, tcall->size); + + if (ret != tcall->size) { + spin_lock(&v9ses->muxlock); + list_del(&req->next); + kfree(req->rcall); + + spin_unlock(&v9ses->muxlock); + if (ret >= 0) + ret = -EREMOTEIO; + } else + ret = 0; + + free_data: + kfree(data); + return ret; +} + +/** + * v9fs_mux_rpc - send a request, receive a response + * @v9ses: session info structure + * @tcall: fcall to send + * @rcall: buffer to place response into + * + */ + +long +v9fs_mux_rpc(struct v9fs_session_info *v9ses, struct v9fs_fcall *tcall, + struct v9fs_fcall **rcall) +{ + int tid = -1; + struct v9fs_fcall *fcall = NULL; + struct v9fs_rpcreq req; + int ret = -1; + + if (!v9ses) + return -EINVAL; + + if (rcall) + *rcall = NULL; + + if (tcall->id != TVERSION) { + tid = v9fs_get_idpool(&v9ses->tidpool); + if (tid < 0) + return -ENOMEM; + } + + tcall->tag = tid; + + req.tcall = tcall; + req.rcall = NULL; + + ret = v9fs_send(v9ses, &req); + + if (ret < 0) { + if (tcall->id != TVERSION) + v9fs_put_idpool(tid, &v9ses->tidpool); + dprintk(DEBUG_MUX, "error %d\n", ret); + return ret; + } + + ret = v9fs_recv(v9ses, &req); + + fcall = req.rcall; + + dprintk(DEBUG_MUX, "received: tag=%x, ret=%d\n", tcall->tag, ret); + if (ret == -ERESTARTSYS) { + if (v9ses->transport->status != Disconnected + && tcall->id != TFLUSH) { + unsigned long flags; + + dprintk(DEBUG_MUX, "flushing the tag: %d\n", + tcall->tag); + clear_thread_flag(TIF_SIGPENDING); + v9fs_t_flush(v9ses, tcall->tag); + spin_lock_irqsave(¤t->sighand->siglock, flags); + recalc_sigpending(); + spin_unlock_irqrestore(¤t->sighand->siglock, + flags); + dprintk(DEBUG_MUX, "flushing done\n"); + } + + goto release_req; + } else if (ret < 0) + goto release_req; + + if (!fcall) + ret = -EIO; + else { + if (fcall->id == RERROR) { + ret = v9fs_errstr2errno(fcall->params.rerror.error); + if (ret == 0) { /* string match failed */ + if (fcall->params.rerror.errno) + ret = -(fcall->params.rerror.errno); + else + ret = -ESERVERFAULT; + } + } else if (fcall->id != tcall->id + 1) { + dprintk(DEBUG_ERROR, + "fcall mismatch: expected %d, got %d\n", + tcall->id + 1, fcall->id); + ret = -EIO; + } + } + + release_req: + if (tcall->id != TVERSION) + v9fs_put_idpool(tid, &v9ses->tidpool); + if (rcall) + *rcall = fcall; + else + kfree(fcall); + + return ret; +} + +/** + * v9fs_recvproc - kproc to handle demultiplexing responses + * @data: session info structure + * + */ + +static int v9fs_recvproc(void *data) +{ + struct v9fs_session_info *v9ses = (struct v9fs_session_info *)data; + struct v9fs_fcall *rcall = NULL; + struct v9fs_rpcreq *rptr; + struct v9fs_rpcreq *req; + struct v9fs_rpcreq *rreq; + int err = 0; + + allow_signal(SIGKILL); + set_current_state(TASK_INTERRUPTIBLE); + complete(&v9ses->proccmpl); + while (!kthread_should_stop() && err >= 0) { + req = rptr = rreq = NULL; + + rcall = kmalloc(v9ses->maxdata + V9FS_IOHDRSZ, GFP_KERNEL); + if (!rcall) { + eprintk(KERN_ERR, "no memory for buffers\n"); + break; + } + + err = read_message(v9ses, rcall, v9ses->maxdata + V9FS_IOHDRSZ); + if (err < 0) { + kfree(rcall); + break; + } + spin_lock(&v9ses->muxlock); + list_for_each_entry_safe(rreq, rptr, &v9ses->mux_fcalls, next) { + if (rreq->tcall->tag == rcall->tag) { + req = rreq; + req->rcall = rcall; + break; + } + } + + if (req && (req->tcall->id == TFLUSH)) { + struct v9fs_rpcreq *treq = NULL; + list_for_each_entry_safe(treq, rptr, &v9ses->mux_fcalls, next) { + if (treq->tcall->tag == + req->tcall->params.tflush.oldtag) { + list_del(&rptr->next); + kfree(treq->rcall); + break; + } + } + } + + spin_unlock(&v9ses->muxlock); + + if (!req) { + dprintk(DEBUG_ERROR, + "unexpected response: id %d tag %d\n", + rcall->id, rcall->tag); + + kfree(rcall); + } + + wake_up_all(&v9ses->read_wait); + set_current_state(TASK_INTERRUPTIBLE); + } + + /* Inform all pending processes about the failure */ + wake_up_all(&v9ses->read_wait); + + if (signal_pending(current)) + complete(&v9ses->proccmpl); + + dprintk(DEBUG_MUX, "recvproc: end\n"); + v9ses->recvproc = NULL; + + return err >= 0; +} + +/** + * v9fs_mux_init - initialize multiplexer (spawn kproc) + * @v9ses: session info structure + * @dev_name: mount device information (to create unique kproc) + * + */ + +int v9fs_mux_init(struct v9fs_session_info *v9ses, const char *dev_name) +{ + char procname[60]; + + strncpy(procname, dev_name, sizeof(procname)); + procname[sizeof(procname) - 1] = 0; + + init_waitqueue_head(&v9ses->read_wait); + init_completion(&v9ses->fcread); + init_completion(&v9ses->proccmpl); + spin_lock_init(&v9ses->muxlock); + INIT_LIST_HEAD(&v9ses->mux_fcalls); + v9ses->recvproc = NULL; + v9ses->curfcall = NULL; + + v9ses->recvproc = kthread_create(v9fs_recvproc, v9ses, + "v9fs_recvproc %s", procname); + + if (IS_ERR(v9ses->recvproc)) { + eprintk(KERN_ERR, "cannot create receiving thread\n"); + v9fs_session_close(v9ses); + return -ECONNABORTED; + } + + wake_up_process(v9ses->recvproc); + wait_for_completion(&v9ses->proccmpl); + + return 0; +} diff --git a/fs/9p/mux.h b/fs/9p/mux.h new file mode 100644 index 0000000..d7d8fa1 --- /dev/null +++ b/fs/9p/mux.h @@ -0,0 +1,39 @@ +/* + * linux/fs/9p/mux.h + * + * Multiplexer Definitions + * + * Copyright (C) 2004 by Eric Van Hensbergen + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +/* structure to manage each RPC transaction */ + +struct v9fs_rpcreq { + struct v9fs_fcall *tcall; + struct v9fs_fcall *rcall; + + /* XXX - could we put scatter/gather buffers here? */ + + struct list_head next; +}; + +int v9fs_mux_init(struct v9fs_session_info *v9ses, const char *dev_name); +long v9fs_mux_rpc(struct v9fs_session_info *v9ses, + struct v9fs_fcall *tcall, struct v9fs_fcall **rcall); diff --git a/fs/9p/trans_fd.c b/fs/9p/trans_fd.c new file mode 100644 index 0000000..63b58ce --- /dev/null +++ b/fs/9p/trans_fd.c @@ -0,0 +1,172 @@ +/* + * linux/fs/9p/trans_fd.c + * + * File Descriptor Transport Layer + * + * Copyright (C) 2005 by Eric Van Hensbergen + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "transport.h" + +struct v9fs_trans_fd { + struct file *in_file; + struct file *out_file; +}; + +/** + * v9fs_fd_recv - receive from a socket + * @v9ses: session information + * @v: buffer to receive data into + * @len: size of receive buffer + * + */ + +static int v9fs_fd_recv(struct v9fs_transport *trans, void *v, int len) +{ + struct v9fs_trans_fd *ts = trans ? trans->priv : NULL; + + if (!trans || trans->status != Connected || !ts) + return -EIO; + + return kernel_read(ts->in_file, ts->in_file->f_pos, v, len); +} + +/** + * v9fs_fd_send - send to a socket + * @v9ses: session information + * @v: buffer to send data from + * @len: size of send buffer + * + */ + +static int v9fs_fd_send(struct v9fs_transport *trans, void *v, int len) +{ + struct v9fs_trans_fd *ts = trans ? trans->priv : NULL; + mm_segment_t oldfs = get_fs(); + int ret = 0; + + if (!trans || trans->status != Connected || !ts) + return -EIO; + + set_fs(get_ds()); + /* The cast to a user pointer is valid due to the set_fs() */ + ret = vfs_write(ts->out_file, (void __user *)v, len, &ts->out_file->f_pos); + set_fs(oldfs); + + return ret; +} + +/** + * v9fs_fd_init - initialize file descriptor transport + * @v9ses: session information + * @addr: address of server to mount + * @data: mount options + * + */ + +static int +v9fs_fd_init(struct v9fs_session_info *v9ses, const char *addr, char *data) +{ + struct v9fs_trans_fd *ts = NULL; + struct v9fs_transport *trans = v9ses->transport; + + if((v9ses->wfdno == ~0) || (v9ses->rfdno == ~0)) { + printk(KERN_ERR "v9fs: Insufficient options for proto=fd\n"); + return -ENOPROTOOPT; + } + + sema_init(&trans->writelock, 1); + sema_init(&trans->readlock, 1); + + ts = kmalloc(sizeof(struct v9fs_trans_fd), GFP_KERNEL); + + if (!ts) + return -ENOMEM; + + ts->in_file = fget( v9ses->rfdno ); + ts->out_file = fget( v9ses->wfdno ); + + if (!ts->in_file || !ts->out_file) { + if (ts->in_file) + fput(ts->in_file); + + if (ts->out_file) + fput(ts->out_file); + + kfree(ts); + return -EIO; + } + + trans->priv = ts; + trans->status = Connected; + + return 0; +} + + +/** + * v9fs_fd_close - shutdown file descriptor + * @trans: private socket structure + * + */ + +static void v9fs_fd_close(struct v9fs_transport *trans) +{ + struct v9fs_trans_fd *ts; + + if (!trans) + return; + + trans->status = Disconnected; + ts = trans->priv; + + if (!ts) + return; + + if (ts->in_file) + fput(ts->in_file); + + if (ts->out_file) + fput(ts->out_file); + + kfree(ts); +} + +struct v9fs_transport v9fs_trans_fd = { + .init = v9fs_fd_init, + .write = v9fs_fd_send, + .read = v9fs_fd_recv, + .close = v9fs_fd_close, +}; + diff --git a/fs/9p/trans_sock.c b/fs/9p/trans_sock.c new file mode 100644 index 0000000..081d1c8 --- /dev/null +++ b/fs/9p/trans_sock.c @@ -0,0 +1,282 @@ +/* + * linux/fs/9p/trans_socket.c + * + * Socket Transport Layer + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 1997-2002 by Ron Minnich + * Copyright (C) 1995, 1996 by Olaf Kirch + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "transport.h" + +#define V9FS_PORT 564 + +struct v9fs_trans_sock { + struct socket *s; +}; + +/** + * v9fs_sock_recv - receive from a socket + * @v9ses: session information + * @v: buffer to receive data into + * @len: size of receive buffer + * + */ + +static int v9fs_sock_recv(struct v9fs_transport *trans, void *v, int len) +{ + struct msghdr msg; + struct kvec iov; + int result; + mm_segment_t oldfs; + struct v9fs_trans_sock *ts = trans ? trans->priv : NULL; + + if (trans->status == Disconnected) + return -EREMOTEIO; + + result = -EINVAL; + + oldfs = get_fs(); + set_fs(get_ds()); + + iov.iov_base = v; + iov.iov_len = len; + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iovlen = 1; + msg.msg_control = NULL; + msg.msg_controllen = 0; + msg.msg_namelen = 0; + msg.msg_flags = MSG_NOSIGNAL; + + result = kernel_recvmsg(ts->s, &msg, &iov, 1, len, 0); + + dprintk(DEBUG_TRANS, "socket state %d\n", ts->s->state); + set_fs(oldfs); + + if (result <= 0) { + if (result != -ERESTARTSYS) + trans->status = Disconnected; + } + + return result; +} + +/** + * v9fs_sock_send - send to a socket + * @v9ses: session information + * @v: buffer to send data from + * @len: size of send buffer + * + */ + +static int v9fs_sock_send(struct v9fs_transport *trans, void *v, int len) +{ + struct kvec iov; + struct msghdr msg; + int result = -1; + mm_segment_t oldfs; + struct v9fs_trans_sock *ts = trans ? trans->priv : NULL; + + dprintk(DEBUG_TRANS, "Sending packet size %d (%x)\n", len, len); + dump_data(v, len); + + down(&trans->writelock); + + oldfs = get_fs(); + set_fs(get_ds()); + iov.iov_base = v; + iov.iov_len = len; + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iovlen = 1; + msg.msg_control = NULL; + msg.msg_controllen = 0; + msg.msg_namelen = 0; + msg.msg_flags = MSG_NOSIGNAL; + result = kernel_sendmsg(ts->s, &msg, &iov, 1, len); + set_fs(oldfs); + + if (result < 0) { + if (result != -ERESTARTSYS) + trans->status = Disconnected; + } + + up(&trans->writelock); + return result; +} + +/** + * v9fs_tcp_init - initialize TCP socket + * @v9ses: session information + * @addr: address of server to mount + * @data: mount options + * + */ + +static int +v9fs_tcp_init(struct v9fs_session_info *v9ses, const char *addr, char *data) +{ + struct socket *csocket = NULL; + struct sockaddr_in sin_server; + int rc = 0; + struct v9fs_trans_sock *ts = NULL; + struct v9fs_transport *trans = v9ses->transport; + + sema_init(&trans->writelock, 1); + sema_init(&trans->readlock, 1); + + ts = kmalloc(sizeof(struct v9fs_trans_sock), GFP_KERNEL); + + if (!ts) + return -ENOMEM; + + trans->priv = ts; + ts->s = NULL; + + if (!addr) + return -EINVAL; + + dprintk(DEBUG_TRANS, "Connecting to %s\n", addr); + + sin_server.sin_family = AF_INET; + sin_server.sin_addr.s_addr = in_aton(addr); + sin_server.sin_port = htons(v9ses->port); + sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket); + rc = csocket->ops->connect(csocket, + (struct sockaddr *)&sin_server, + sizeof(struct sockaddr_in), 0); + if (rc < 0) { + eprintk(KERN_ERR, + "v9fs_trans_tcp: problem connecting socket to %s\n", + addr); + return rc; + } + csocket->sk->sk_allocation = GFP_NOIO; + ts->s = csocket; + trans->status = Connected; + + return 0; +} + +/** + * v9fs_unix_init - initialize UNIX domain socket + * @v9ses: session information + * @dev_name: path to named pipe + * @data: mount options + * + */ + +static int +v9fs_unix_init(struct v9fs_session_info *v9ses, const char *dev_name, + char *data) +{ + int rc; + struct socket *csocket; + struct sockaddr_un sun_server; + struct v9fs_transport *trans; + struct v9fs_trans_sock *ts; + + rc = 0; + csocket = NULL; + trans = v9ses->transport; + + if (strlen(dev_name) > UNIX_PATH_MAX) { + eprintk(KERN_ERR, "v9fs_trans_unix: address too long: %s\n", + dev_name); + return -ENOMEM; + } + + ts = kmalloc(sizeof(struct v9fs_trans_sock), GFP_KERNEL); + if (!ts) + return -ENOMEM; + + trans->priv = ts; + ts->s = NULL; + + sema_init(&trans->writelock, 1); + sema_init(&trans->readlock, 1); + + sun_server.sun_family = PF_UNIX; + strcpy(sun_server.sun_path, dev_name); + sock_create_kern(PF_UNIX, SOCK_STREAM, 0, &csocket); + rc = csocket->ops->connect(csocket, (struct sockaddr *)&sun_server, + sizeof(struct sockaddr_un) - 1, 0); /* -1 *is* important */ + if (rc < 0) { + eprintk(KERN_ERR, + "v9fs_trans_unix: problem connecting socket: %s: %d\n", + dev_name, rc); + return rc; + } + csocket->sk->sk_allocation = GFP_NOIO; + ts->s = csocket; + trans->status = Connected; + + return 0; +} + +/** + * v9fs_sock_close - shutdown socket + * @trans: private socket structure + * + */ + +static void v9fs_sock_close(struct v9fs_transport *trans) +{ + struct v9fs_trans_sock *ts = trans ? trans->priv : NULL; + + if ((ts) && (ts->s)) { + dprintk(DEBUG_TRANS, "closing the socket %p\n", ts->s); + sock_release(ts->s); + ts->s = NULL; + trans->status = Disconnected; + dprintk(DEBUG_TRANS, "socket closed\n"); + } + + kfree(ts); +} + +struct v9fs_transport v9fs_trans_tcp = { + .init = v9fs_tcp_init, + .write = v9fs_sock_send, + .read = v9fs_sock_recv, + .close = v9fs_sock_close, +}; + +struct v9fs_transport v9fs_trans_unix = { + .init = v9fs_unix_init, + .write = v9fs_sock_send, + .read = v9fs_sock_recv, + .close = v9fs_sock_close, +}; diff --git a/fs/9p/transport.h b/fs/9p/transport.h new file mode 100644 index 0000000..9e9cd41 --- /dev/null +++ b/fs/9p/transport.h @@ -0,0 +1,46 @@ +/* + * linux/fs/9p/transport.h + * + * Transport Definition + * + * Copyright (C) 2004 by Eric Van Hensbergen + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +enum v9fs_transport_status { + Connected, + Disconnected, + Hung, +}; + +struct v9fs_transport { + enum v9fs_transport_status status; + struct semaphore writelock; + struct semaphore readlock; + void *priv; + + int (*init) (struct v9fs_session_info *, const char *, char *); + int (*write) (struct v9fs_transport *, void *, int); + int (*read) (struct v9fs_transport *, void *, int); + void (*close) (struct v9fs_transport *); +}; + +extern struct v9fs_transport v9fs_trans_tcp; +extern struct v9fs_transport v9fs_trans_unix; +extern struct v9fs_transport v9fs_trans_fd; diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 14d663e..a573b75 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -296,11 +296,6 @@ v9fs_session_init(struct v9fs_session_info *v9ses, case PROTO_FD: trans_proto = &v9fs_trans_fd; *v9ses->remotename = 0; - if((v9ses->wfdno == ~0) || (v9ses->rfdno == ~0)) { - printk(KERN_ERR "v9fs: Insufficient options for proto=fd\n"); - retval = -ENOPROTOOPT; - goto SessCleanUp; - } break; default: printk(KERN_ERR "v9fs: Bad mount protocol %d\n", v9ses->proto); -- cgit v0.10.2 From 322b329ab787de5f45abca9c9eabfd33bc5927e8 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:23 -0700 Subject: [PATCH] v9fs: Support to force umount Support for force umount Signed-off-by: Latchesar Ionkov Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/mux.c b/fs/9p/mux.c index 8ebc1af..0854bef 100644 --- a/fs/9p/mux.c +++ b/fs/9p/mux.c @@ -324,6 +324,26 @@ v9fs_mux_rpc(struct v9fs_session_info *v9ses, struct v9fs_fcall *tcall, } /** + * v9fs_mux_cancel_requests - cancels all pending requests + * + * @v9ses: session info structure + * @err: error code to return to the requests + */ +void v9fs_mux_cancel_requests(struct v9fs_session_info *v9ses, int err) +{ + struct v9fs_rpcreq *rptr; + struct v9fs_rpcreq *rreq; + + dprintk(DEBUG_MUX, " %d\n", err); + spin_lock(&v9ses->muxlock); + list_for_each_entry_safe(rreq, rptr, &v9ses->mux_fcalls, next) { + rreq->err = err; + } + spin_unlock(&v9ses->muxlock); + wake_up_all(&v9ses->read_wait); +} + +/** * v9fs_recvproc - kproc to handle demultiplexing responses * @data: session info structure * diff --git a/fs/9p/mux.h b/fs/9p/mux.h index d7d8fa1..82ce793 100644 --- a/fs/9p/mux.h +++ b/fs/9p/mux.h @@ -37,3 +37,4 @@ struct v9fs_rpcreq { int v9fs_mux_init(struct v9fs_session_info *v9ses, const char *dev_name); long v9fs_mux_rpc(struct v9fs_session_info *v9ses, struct v9fs_fcall *tcall, struct v9fs_fcall **rcall); +void v9fs_mux_cancel_requests(struct v9fs_session_info *v9ses, int err); diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index a573b75..13bdbba 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -409,6 +409,15 @@ void v9fs_session_close(struct v9fs_session_info *v9ses) putname(v9ses->remotename); } +/** + * v9fs_session_cancel - mark transport as disconnected + * and cancel all pending requests. + */ +void v9fs_session_cancel(struct v9fs_session_info *v9ses) { + v9ses->transport->status = Disconnected; + v9fs_mux_cancel_requests(v9ses, -EIO); +} + extern int v9fs_error_init(void); /** diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index 5220302..45dcef4 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -89,9 +89,7 @@ struct v9fs_session_info *v9fs_inode2v9ses(struct inode *); void v9fs_session_close(struct v9fs_session_info *v9ses); int v9fs_get_idpool(struct v9fs_idpool *p); void v9fs_put_idpool(int id, struct v9fs_idpool *p); -int v9fs_get_option(char *opts, char *name, char *buf, int buflen); -long long v9fs_get_int_option(char *opts, char *name, long long dflt); -int v9fs_parse_tcp_devname(const char *devname, char **addr, char **remotename); +void v9fs_session_cancel(struct v9fs_session_info *v9ses); #define V9FS_MAGIC 0x01021997 diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index ce0778a..868f350 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c @@ -257,10 +257,19 @@ static int v9fs_show_options(struct seq_file *m, struct vfsmount *mnt) return 0; } +static void +v9fs_umount_begin(struct super_block *sb) +{ + struct v9fs_session_info *v9ses = sb->s_fs_info; + + v9fs_session_cancel(v9ses); +} + static struct super_operations v9fs_super_ops = { .statfs = simple_statfs, .clear_inode = v9fs_clear_inode, .show_options = v9fs_show_options, + .umount_begin = v9fs_umount_begin, }; struct file_system_type v9fs_fs_type = { -- cgit v0.10.2 From 3ed8491c8a75cefe95b57f7f428a3e2ddd421e97 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:24 -0700 Subject: [PATCH] v9fs: debug and support routines This part of the patch contains debug and other misc routines. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/debug.h b/fs/9p/debug.h new file mode 100644 index 0000000..4445f06 --- /dev/null +++ b/fs/9p/debug.h @@ -0,0 +1,70 @@ +/* + * linux/fs/9p/debug.h - V9FS Debug Definitions + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#define DEBUG_ERROR (1<<0) +#define DEBUG_CURRENT (1<<1) +#define DEBUG_9P (1<<2) +#define DEBUG_VFS (1<<3) +#define DEBUG_CONV (1<<4) +#define DEBUG_MUX (1<<5) +#define DEBUG_TRANS (1<<6) +#define DEBUG_SLABS (1<<7) + +#define DEBUG_DUMP_PKT 0 + +extern int v9fs_debug_level; + +#define dprintk(level, format, arg...) \ +do { \ + if((v9fs_debug_level & level)==level) \ + printk(KERN_NOTICE "-- %s (%d): " \ + format , __FUNCTION__, current->pid , ## arg); \ +} while(0) + +#define eprintk(level, format, arg...) \ +do { \ + printk(level "v9fs: %s (%d): " \ + format , __FUNCTION__, current->pid , ## arg); \ +} while(0) + +#if DEBUG_DUMP_PKT +static inline void dump_data(const unsigned char *data, unsigned int datalen) +{ + int i, j; + int len = datalen; + + printk(KERN_DEBUG "data "); + for (i = 0; i < len; i += 4) { + for (j = 0; (j < 4) && (i + j < len); j++) + printk(KERN_DEBUG "%02x", data[i + j]); + printk(KERN_DEBUG " "); + } + printk(KERN_DEBUG "\n"); +} +#else /* DEBUG_DUMP_PKT */ +static inline void dump_data(const unsigned char *data, unsigned int datalen) +{ + +} +#endif /* DEBUG_DUMP_PKT */ diff --git a/fs/9p/error.c b/fs/9p/error.c new file mode 100644 index 0000000..fee5d19 --- /dev/null +++ b/fs/9p/error.c @@ -0,0 +1,93 @@ +/* + * linux/fs/9p/error.c + * + * Error string handling + * + * Plan 9 uses error strings, Unix uses error numbers. These functions + * try to help manage that and provide for dynamically adding error + * mappings. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include + +#include +#include + +#include "debug.h" +#include "error.h" + +/** + * v9fs_error_init - preload + * @errstr: error string + * + */ + +int v9fs_error_init(void) +{ + struct errormap *c; + int bucket; + + /* initialize hash table */ + for (bucket = 0; bucket < ERRHASHSZ; bucket++) + INIT_HLIST_HEAD(&hash_errmap[bucket]); + + /* load initial error map into hash table */ + for (c = errmap; c->name != NULL; c++) { + bucket = jhash(c->name, strlen(c->name), 0) % ERRHASHSZ; + INIT_HLIST_NODE(&c->list); + hlist_add_head(&c->list, &hash_errmap[bucket]); + } + + return 1; +} + +/** + * errstr2errno - convert error string to error number + * @errstr: error string + * + */ + +int v9fs_errstr2errno(char *errstr) +{ + int errno = 0; + struct hlist_node *p = NULL; + struct errormap *c = NULL; + int bucket = jhash(errstr, strlen(errstr), 0) % ERRHASHSZ; + + hlist_for_each_entry(c, p, &hash_errmap[bucket], list) { + if (!strcmp(c->name, errstr)) { + errno = c->val; + break; + } + } + + if (errno == 0) { + /* TODO: if error isn't found, add it dynamically */ + printk(KERN_ERR "%s: errstr :%s: not found\n", __FUNCTION__, + errstr); + errno = 1; + } + + return -errno; +} diff --git a/fs/9p/error.h b/fs/9p/error.h new file mode 100644 index 0000000..4bf2cf5 --- /dev/null +++ b/fs/9p/error.h @@ -0,0 +1,181 @@ +/* + * linux/fs/9p/error.h + * + * Huge Nasty Error Table + * + * Plan 9 uses error strings, Unix uses error numbers. This table tries to + * match UNIX strings and Plan 9 strings to unix error numbers. It is used + * to preload the dynamic error table which can also track user-specific error + * strings. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include + +struct errormap { + char *name; + int val; + + struct hlist_node list; +}; + +#define ERRHASHSZ 32 +static struct hlist_head hash_errmap[ERRHASHSZ]; + +/* FixMe - reduce to a reasonable size */ +static struct errormap errmap[] = { + {"Operation not permitted", 1}, + {"wstat prohibited", 1}, + {"No such file or directory", 2}, + {"file not found", 2}, + {"Interrupted system call", 4}, + {"Input/output error", 5}, + {"No such device or address", 6}, + {"Argument list too long", 7}, + {"Bad file descriptor", 9}, + {"Resource temporarily unavailable", 11}, + {"Cannot allocate memory", 12}, + {"Permission denied", 13}, + {"Bad address", 14}, + {"Block device required", 15}, + {"Device or resource busy", 16}, + {"File exists", 17}, + {"Invalid cross-device link", 18}, + {"No such device", 19}, + {"Not a directory", 20}, + {"Is a directory", 21}, + {"Invalid argument", 22}, + {"Too many open files in system", 23}, + {"Too many open files", 24}, + {"Text file busy", 26}, + {"File too large", 27}, + {"No space left on device", 28}, + {"Illegal seek", 29}, + {"Read-only file system", 30}, + {"Too many links", 31}, + {"Broken pipe", 32}, + {"Numerical argument out of domain", 33}, + {"Numerical result out of range", 34}, + {"Resource deadlock avoided", 35}, + {"File name too long", 36}, + {"No locks available", 37}, + {"Function not implemented", 38}, + {"Directory not empty", 39}, + {"Too many levels of symbolic links", 40}, + {"Unknown error 41", 41}, + {"No message of desired type", 42}, + {"Identifier removed", 43}, + {"File locking deadlock error", 58}, + {"No data available", 61}, + {"Machine is not on the network", 64}, + {"Package not installed", 65}, + {"Object is remote", 66}, + {"Link has been severed", 67}, + {"Communication error on send", 70}, + {"Protocol error", 71}, + {"Bad message", 74}, + {"File descriptor in bad state", 77}, + {"Streams pipe error", 86}, + {"Too many users", 87}, + {"Socket operation on non-socket", 88}, + {"Message too long", 90}, + {"Protocol not available", 92}, + {"Protocol not supported", 93}, + {"Socket type not supported", 94}, + {"Operation not supported", 95}, + {"Protocol family not supported", 96}, + {"Network is down", 100}, + {"Network is unreachable", 101}, + {"Network dropped connection on reset", 102}, + {"Software caused connection abort", 103}, + {"Connection reset by peer", 104}, + {"No buffer space available", 105}, + {"Transport endpoint is already connected", 106}, + {"Transport endpoint is not connected", 107}, + {"Cannot send after transport endpoint shutdown", 108}, + {"Connection timed out", 110}, + {"Connection refused", 111}, + {"Host is down", 112}, + {"No route to host", 113}, + {"Operation already in progress", 114}, + {"Operation now in progress", 115}, + {"Is a named type file", 120}, + {"Remote I/O error", 121}, + {"Disk quota exceeded", 122}, + {"Operation canceled", 125}, + {"Unknown error 126", 126}, + {"Unknown error 127", 127}, +/* errors from fossil, vacfs, and u9fs */ + {"fid unknown or out of range", EBADF}, + {"permission denied", EACCES}, + {"file does not exist", ENOENT}, + {"authentication failed", ECONNREFUSED}, + {"bad offset in directory read", ESPIPE}, + {"bad use of fid", EBADF}, + {"wstat can't convert between files and directories", EPERM}, + {"directory is not empty", ENOTEMPTY}, + {"file exists", EEXIST}, + {"file already exists", EEXIST}, + {"file or directory already exists", EEXIST}, + {"fid already in use", EBADF}, + {"file in use", ETXTBSY}, + {"i/o error", EIO}, + {"file already open for I/O", ETXTBSY}, + {"illegal mode", EINVAL}, + {"illegal name", ENAMETOOLONG}, + {"not a directory", ENOTDIR}, + {"not a member of proposed group", EINVAL}, + {"not owner", EACCES}, + {"only owner can change group in wstat", EACCES}, + {"read only file system", EROFS}, + {"no access to special file", EPERM}, + {"i/o count too large", EIO}, + {"unknown group", EINVAL}, + {"unknown user", EINVAL}, + {"bogus wstat buffer", EPROTO}, + {"exclusive use file already open", EAGAIN}, + {"corrupted directory entry", EIO}, + {"corrupted file entry", EIO}, + {"corrupted block label", EIO}, + {"corrupted meta data", EIO}, + {"illegal offset", EINVAL}, + {"illegal path element", ENOENT}, + {"root of file system is corrupted", EIO}, + {"corrupted super block", EIO}, + {"protocol botch", EPROTO}, + {"file system is full", ENOSPC}, + {"file is in use", EAGAIN}, + {"directory entry is not allocated", ENOENT}, + {"file is read only", EROFS}, + {"file has been removed", EIDRM}, + {"only support truncation to zero length", EPERM}, + {"cannot remove root", EPERM}, + {"file too big", EFBIG}, + {"venti i/o error", EIO}, + /* these are not errors */ + {"u9fs rhostsauth: no authentication required", 0}, + {"u9fs authnone: no authentication required", 0}, + {NULL, -1} +}; + +extern int v9fs_error_init(void); +extern int v9fs_errstr2errno(char *errstr); diff --git a/fs/9p/fid.c b/fs/9p/fid.c new file mode 100644 index 0000000..821c9c4 --- /dev/null +++ b/fs/9p/fid.c @@ -0,0 +1,241 @@ +/* + * V9FS FID Management + * + * Copyright (C) 2005 by Eric Van Hensbergen + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "transport.h" +#include "mux.h" +#include "conv.h" +#include "fid.h" + +/** + * v9fs_fid_insert - add a fid to a dentry + * @fid: fid to add + * @dentry: dentry that it is being added to + * + */ + +static int v9fs_fid_insert(struct v9fs_fid *fid, struct dentry *dentry) +{ + struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; + dprintk(DEBUG_9P, "fid %d (%p) dentry %s (%p)\n", fid->fid, fid, + dentry->d_iname, dentry); + if (dentry->d_fsdata == NULL) { + dentry->d_fsdata = + kmalloc(sizeof(struct list_head), GFP_KERNEL); + if (dentry->d_fsdata == NULL) { + dprintk(DEBUG_ERROR, "Out of memory\n"); + return -ENOMEM; + } + fid_list = (struct list_head *)dentry->d_fsdata; + INIT_LIST_HEAD(fid_list); /* Initialize list head */ + } + + fid->uid = current->uid; + fid->pid = current->pid; + list_add(&fid->list, fid_list); + return 0; +} + +/** + * v9fs_fid_create - allocate a FID structure + * @dentry - dentry to link newly created fid to + * + */ + +struct v9fs_fid *v9fs_fid_create(struct dentry *dentry) +{ + struct v9fs_fid *new; + + new = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); + if (new == NULL) { + dprintk(DEBUG_ERROR, "Out of Memory\n"); + return ERR_PTR(-ENOMEM); + } + + new->fid = -1; + new->fidopen = 0; + new->fidcreate = 0; + new->fidclunked = 0; + new->iounit = 0; + + if (v9fs_fid_insert(new, dentry) == 0) + return new; + else { + dprintk(DEBUG_ERROR, "Problems inserting to dentry\n"); + kfree(new); + return NULL; + } +} + +/** + * v9fs_fid_destroy - deallocate a FID structure + * @fid: fid to destroy + * + */ + +void v9fs_fid_destroy(struct v9fs_fid *fid) +{ + list_del(&fid->list); + kfree(fid); +} + +/** + * v9fs_fid_lookup - retrieve the right fid from a particular dentry + * @dentry: dentry to look for fid in + * @type: intent of lookup (operation or traversal) + * + * search list of fids associated with a dentry for a fid with a matching + * thread id or uid. If that fails, look up the dentry's parents to see if you + * can find a matching fid. + * + */ + +struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry, int type) +{ + struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; + struct v9fs_fid *current_fid = NULL; + struct v9fs_fid *temp = NULL; + struct v9fs_fid *return_fid = NULL; + int found_parent = 0; + int found_user = 0; + + dprintk(DEBUG_9P, " dentry: %s (%p) type %d\n", dentry->d_iname, dentry, + type); + + if (fid_list && !list_empty(fid_list)) { + list_for_each_entry_safe(current_fid, temp, fid_list, list) { + if (current_fid->uid == current->uid) { + if (return_fid == NULL) { + if ((type == FID_OP) + || (!current_fid->fidopen)) { + return_fid = current_fid; + found_user = 1; + } + } + } + if (current_fid->pid == current->real_parent->pid) { + if ((return_fid == NULL) || (found_parent) + || (found_user)) { + if ((type == FID_OP) + || (!current_fid->fidopen)) { + return_fid = current_fid; + found_parent = 1; + found_user = 0; + } + } + } + if (current_fid->pid == current->pid) { + if ((type == FID_OP) || + (!current_fid->fidopen)) { + return_fid = current_fid; + found_parent = 0; + found_user = 0; + } + } + } + } + + /* we are at the root but didn't match */ + if ((!return_fid) && (dentry->d_parent == dentry)) { + /* TODO: clone attach with new uid */ + return_fid = current_fid; + } + + if (!return_fid) { + struct dentry *par = current->fs->pwd->d_parent; + int count = 1; + while (par != NULL) { + if (par == dentry) + break; + count++; + if (par == par->d_parent) { + dprintk(DEBUG_ERROR, + "got to root without finding dentry\n"); + break; + } + par = par->d_parent; + } + +/* XXX - there may be some duplication we can get rid of */ + if (par == dentry) { + /* we need to fid_lookup the starting point */ + int fidnum = -1; + int oldfid = -1; + int result = -1; + struct v9fs_session_info *v9ses = + v9fs_inode2v9ses(current->fs->pwd->d_inode); + + current_fid = + v9fs_fid_lookup(current->fs->pwd, FID_WALK); + if (current_fid == NULL) { + dprintk(DEBUG_ERROR, + "process cwd doesn't have a fid\n"); + return return_fid; + } + oldfid = current_fid->fid; + par = current->fs->pwd; + /* TODO: take advantage of multiwalk */ + + fidnum = v9fs_get_idpool(&v9ses->fidpool); + if (fidnum < 0) { + dprintk(DEBUG_ERROR, + "could not get a new fid num\n"); + return return_fid; + } + + while (par != dentry) { + result = + v9fs_t_walk(v9ses, oldfid, fidnum, "..", + NULL); + if (result < 0) { + dprintk(DEBUG_ERROR, + "problem walking to parent\n"); + + break; + } + oldfid = fidnum; + if (par == par->d_parent) { + dprintk(DEBUG_ERROR, + "can't find dentry\n"); + break; + } + par = par->d_parent; + } + if (par == dentry) { + return_fid = v9fs_fid_create(dentry); + return_fid->fid = fidnum; + } + } + } + + return return_fid; +} diff --git a/fs/9p/fid.h b/fs/9p/fid.h new file mode 100644 index 0000000..7db478c --- /dev/null +++ b/fs/9p/fid.h @@ -0,0 +1,57 @@ +/* + * V9FS FID Management + * + * Copyright (C) 2005 by Eric Van Hensbergen + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include + +#define FID_OP 0 +#define FID_WALK 1 + +struct v9fs_fid { + struct list_head list; /* list of fids associated with a dentry */ + struct list_head active; /* XXX - debug */ + + u32 fid; + unsigned char fidopen; /* set when fid is opened */ + unsigned char fidcreate; /* set when fid was just created */ + unsigned char fidclunked; /* set when fid has already been clunked */ + + struct v9fs_qid qid; + u32 iounit; + + /* readdir stuff */ + int rdir_fpos; + loff_t rdir_pos; + struct v9fs_fcall *rdir_fcall; + + /* management stuff */ + pid_t pid; /* thread associated with this fid */ + uid_t uid; /* user associated with this fid */ + + /* private data */ + struct file *filp; /* backpointer to File struct for open files */ + struct v9fs_session_info *v9ses; /* session info for this FID */ +}; + +struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry, int type); +void v9fs_fid_destroy(struct v9fs_fid *fid); +struct v9fs_fid *v9fs_fid_create(struct dentry *); -- cgit v0.10.2 From 1346f51ede71fc1e5021062898d150e192dc4dc8 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:25 -0700 Subject: [PATCH] v9fs: Change error magic numbers to defined constants Change magic error numbers to system defined constants in v9fs error.h As suggested by Jan-Benedict Glaw. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/error.h b/fs/9p/error.h index 4bf2cf5..6dbb66f 100644 --- a/fs/9p/error.h +++ b/fs/9p/error.h @@ -30,6 +30,7 @@ */ #include +#include struct errormap { char *name; @@ -43,87 +44,82 @@ static struct hlist_head hash_errmap[ERRHASHSZ]; /* FixMe - reduce to a reasonable size */ static struct errormap errmap[] = { - {"Operation not permitted", 1}, - {"wstat prohibited", 1}, - {"No such file or directory", 2}, - {"file not found", 2}, - {"Interrupted system call", 4}, - {"Input/output error", 5}, - {"No such device or address", 6}, - {"Argument list too long", 7}, - {"Bad file descriptor", 9}, - {"Resource temporarily unavailable", 11}, - {"Cannot allocate memory", 12}, - {"Permission denied", 13}, - {"Bad address", 14}, - {"Block device required", 15}, - {"Device or resource busy", 16}, - {"File exists", 17}, - {"Invalid cross-device link", 18}, - {"No such device", 19}, - {"Not a directory", 20}, - {"Is a directory", 21}, - {"Invalid argument", 22}, - {"Too many open files in system", 23}, - {"Too many open files", 24}, - {"Text file busy", 26}, - {"File too large", 27}, - {"No space left on device", 28}, - {"Illegal seek", 29}, - {"Read-only file system", 30}, - {"Too many links", 31}, - {"Broken pipe", 32}, - {"Numerical argument out of domain", 33}, - {"Numerical result out of range", 34}, - {"Resource deadlock avoided", 35}, - {"File name too long", 36}, - {"No locks available", 37}, - {"Function not implemented", 38}, - {"Directory not empty", 39}, - {"Too many levels of symbolic links", 40}, - {"Unknown error 41", 41}, - {"No message of desired type", 42}, - {"Identifier removed", 43}, - {"File locking deadlock error", 58}, - {"No data available", 61}, - {"Machine is not on the network", 64}, - {"Package not installed", 65}, - {"Object is remote", 66}, - {"Link has been severed", 67}, - {"Communication error on send", 70}, - {"Protocol error", 71}, - {"Bad message", 74}, - {"File descriptor in bad state", 77}, - {"Streams pipe error", 86}, - {"Too many users", 87}, - {"Socket operation on non-socket", 88}, - {"Message too long", 90}, - {"Protocol not available", 92}, - {"Protocol not supported", 93}, - {"Socket type not supported", 94}, - {"Operation not supported", 95}, - {"Protocol family not supported", 96}, - {"Network is down", 100}, - {"Network is unreachable", 101}, - {"Network dropped connection on reset", 102}, - {"Software caused connection abort", 103}, - {"Connection reset by peer", 104}, - {"No buffer space available", 105}, - {"Transport endpoint is already connected", 106}, - {"Transport endpoint is not connected", 107}, - {"Cannot send after transport endpoint shutdown", 108}, - {"Connection timed out", 110}, - {"Connection refused", 111}, - {"Host is down", 112}, - {"No route to host", 113}, - {"Operation already in progress", 114}, - {"Operation now in progress", 115}, - {"Is a named type file", 120}, - {"Remote I/O error", 121}, - {"Disk quota exceeded", 122}, - {"Operation canceled", 125}, - {"Unknown error 126", 126}, - {"Unknown error 127", 127}, + {"Operation not permitted", EPERM}, + {"wstat prohibited", EPERM}, + {"No such file or directory", ENOENT}, + {"file not found", ENOENT}, + {"Interrupted system call", EINTR}, + {"Input/output error", EIO}, + {"No such device or address", ENXIO}, + {"Argument list too long", E2BIG}, + {"Bad file descriptor", EBADF}, + {"Resource temporarily unavailable", EAGAIN}, + {"Cannot allocate memory", ENOMEM}, + {"Permission denied", EACCES}, + {"Bad address", EFAULT}, + {"Block device required", ENOTBLK}, + {"Device or resource busy", EBUSY}, + {"File exists", EEXIST}, + {"Invalid cross-device link", EXDEV}, + {"No such device", ENODEV}, + {"Not a directory", ENOTDIR}, + {"Is a directory", EISDIR}, + {"Invalid argument", EINVAL}, + {"Too many open files in system", ENFILE}, + {"Too many open files", EMFILE}, + {"Text file busy", ETXTBSY}, + {"File too large", EFBIG}, + {"No space left on device", ENOSPC}, + {"Illegal seek", ESPIPE}, + {"Read-only file system", EROFS}, + {"Too many links", EMLINK}, + {"Broken pipe", EPIPE}, + {"Numerical argument out of domain", EDOM}, + {"Numerical result out of range", ERANGE}, + {"Resource deadlock avoided", EDEADLK}, + {"File name too long", ENAMETOOLONG}, + {"No locks available", ENOLCK}, + {"Function not implemented", ENOSYS}, + {"Directory not empty", ENOTEMPTY}, + {"Too many levels of symbolic links", ELOOP}, + {"No message of desired type", ENOMSG}, + {"Identifier removed", EIDRM}, + {"No data available", ENODATA}, + {"Machine is not on the network", ENONET}, + {"Package not installed", ENOPKG}, + {"Object is remote", EREMOTE}, + {"Link has been severed", ENOLINK}, + {"Communication error on send", ECOMM}, + {"Protocol error", EPROTO}, + {"Bad message", EBADMSG}, + {"File descriptor in bad state", EBADFD}, + {"Streams pipe error", ESTRPIPE}, + {"Too many users", EUSERS}, + {"Socket operation on non-socket", ENOTSOCK}, + {"Message too long", EMSGSIZE}, + {"Protocol not available", ENOPROTOOPT}, + {"Protocol not supported", EPROTONOSUPPORT}, + {"Socket type not supported", ESOCKTNOSUPPORT}, + {"Operation not supported", EOPNOTSUPP}, + {"Protocol family not supported", EPFNOSUPPORT}, + {"Network is down", ENETDOWN}, + {"Network is unreachable", ENETUNREACH}, + {"Network dropped connection on reset", ENETRESET}, + {"Software caused connection abort", ECONNABORTED}, + {"Connection reset by peer", ECONNRESET}, + {"No buffer space available", ENOBUFS}, + {"Transport endpoint is already connected", EISCONN}, + {"Transport endpoint is not connected", ENOTCONN}, + {"Cannot send after transport endpoint shutdown", ESHUTDOWN}, + {"Connection timed out", ETIMEDOUT}, + {"Connection refused", ECONNREFUSED}, + {"Host is down", EHOSTDOWN}, + {"No route to host", EHOSTUNREACH}, + {"Operation already in progress", EALREADY}, + {"Operation now in progress", EINPROGRESS}, + {"Is a named type file", EISNAM}, + {"Remote I/O error", EREMOTEIO}, + {"Disk quota exceeded", EDQUOT}, /* errors from fossil, vacfs, and u9fs */ {"fid unknown or out of range", EBADF}, {"permission denied", EACCES}, -- cgit v0.10.2 From 73c592b9b844cc353bbaea690fb4aa652ac168a6 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:26 -0700 Subject: [PATCH] v9fs: Clean-up vfs_inode and setattr functions Cleanup code in v9fs vfs_inode as suggested by Alexey Dobriyan. Did some major revamping of the v9fs setattr code to remove unnecessary allocations and clean up some dead-code. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/error.h b/fs/9p/error.h index 6dbb66f..2eb5927 100644 --- a/fs/9p/error.h +++ b/fs/9p/error.h @@ -139,7 +139,7 @@ static struct errormap errmap[] = { {"illegal mode", EINVAL}, {"illegal name", ENAMETOOLONG}, {"not a directory", ENOTDIR}, - {"not a member of proposed group", EINVAL}, + {"not a member of proposed group", EPERM}, {"not owner", EACCES}, {"only owner can change group in wstat", EACCES}, {"read only file system", EROFS}, diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index ef78af7..6d2357d 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -1,7 +1,7 @@ /* * linux/fs/9p/vfs_inode.c * - * This file contians vfs inode ops for the 9P2000 protocol. + * This file contains vfs inode ops for the 9P2000 protocol. * * Copyright (C) 2004 by Eric Van Hensbergen * Copyright (C) 2002 by Ron Minnich @@ -54,7 +54,7 @@ static struct inode_operations v9fs_symlink_inode_operations; * */ -static inline int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) +static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) { int res; res = mode & 0777; @@ -92,7 +92,7 @@ static inline int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) * */ -static inline int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) +static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) { int res; @@ -132,7 +132,7 @@ static inline int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) * */ -static inline void +static void v9fs_blank_mistat(struct v9fs_session_info *v9ses, struct v9fs_stat *mistat) { mistat->type = ~0; @@ -160,7 +160,7 @@ v9fs_blank_mistat(struct v9fs_session_info *v9ses, struct v9fs_stat *mistat) /** * v9fs_mistat2unix - convert mistat to unix stat * @mistat: Plan 9 metadata (mistat) structure - * @stat: unix metadata (stat) structure to populate + * @buf: unix metadata (stat) structure to populate * @sb: superblock * */ @@ -177,22 +177,11 @@ v9fs_mistat2unix(struct v9fs_stat *mistat, struct stat *buf, buf->st_mtime = mistat->mtime; buf->st_ctime = mistat->mtime; - if (v9ses && v9ses->extended) { - /* TODO: string to uid mapping via user-space daemon */ - buf->st_uid = mistat->n_uid; - buf->st_gid = mistat->n_gid; - - sscanf(mistat->uid, "%x", (unsigned int *)&buf->st_uid); - sscanf(mistat->gid, "%x", (unsigned int *)&buf->st_gid); - } else { - buf->st_uid = v9ses->uid; - buf->st_gid = v9ses->gid; - } - buf->st_uid = (unsigned short)-1; buf->st_gid = (unsigned short)-1; if (v9ses && v9ses->extended) { + /* TODO: string to uid mapping via user-space daemon */ if (mistat->n_uid != -1) sscanf(mistat->uid, "%x", (unsigned int *)&buf->st_uid); @@ -290,7 +279,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) * @dir: directory inode file is being created in * @file_dentry: dentry file is being created in * @perm: permissions file is being created with - * @open_mode: resulting open mode for file ??? + * @open_mode: resulting open mode for file * */ @@ -434,9 +423,9 @@ v9fs_create(struct inode *dir, /** * v9fs_remove - helper function to remove files and directories - * @inode: directory inode that is being deleted - * @dentry: dentry that is being deleted - * @rmdir: where we are a file or a directory + * @dir: directory inode that is being deleted + * @file: dentry that is being deleted + * @rmdir: removing a directory * */ @@ -502,7 +491,7 @@ v9fs_vfs_create(struct inode *inode, struct dentry *dentry, int perm, /** * v9fs_vfs_mkdir - VFS mkdir hook to create a directory - * @i: inode that is being unlinked + * @inode: inode that is being unlinked * @dentry: dentry that is being unlinked * @mode: mode for new directory * @@ -624,7 +613,7 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, /** * v9fs_vfs_unlink - VFS unlink hook to delete an inode * @i: inode that is being unlinked - * @dentry: dentry that is being unlinked + * @d: dentry that is being unlinked * */ @@ -636,7 +625,7 @@ static int v9fs_vfs_unlink(struct inode *i, struct dentry *d) /** * v9fs_vfs_rmdir - VFS unlink hook to delete a directory * @i: inode that is being unlinked - * @dentry: dentry that is being unlinked + * @d: dentry that is being unlinked * */ @@ -674,6 +663,9 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry, dprintk(DEBUG_VFS, "\n"); + if (!mistat) + return -ENOMEM; + if ((!oldfid) || (!olddirfid) || (!newdirfid)) { dprintk(DEBUG_ERROR, "problem with arguments\n"); return -EBADF; @@ -771,20 +763,21 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) { struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); - struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); struct v9fs_fcall *fcall = NULL; + struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); int res = -EPERM; dprintk(DEBUG_VFS, "\n"); + + if (!mistat) + return -ENOMEM; + if (!fid) { dprintk(DEBUG_ERROR, "Couldn't find fid associated with dentry\n"); return -EBADF; } - if (!mistat) - return -ENOMEM; - v9fs_blank_mistat(v9ses, mistat); if (iattr->ia_valid & ATTR_MODE) mistat->mode = unixmode2p9mode(v9ses, iattr->ia_mode); @@ -799,72 +792,19 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) mistat->length = iattr->ia_size; if (v9ses->extended) { - char *uid = kmalloc(strlen(mistat->uid), GFP_KERNEL); - char *gid = kmalloc(strlen(mistat->gid), GFP_KERNEL); - char *muid = kmalloc(strlen(mistat->muid), GFP_KERNEL); - char *name = kmalloc(strlen(mistat->name), GFP_KERNEL); - char *extension = kmalloc(strlen(mistat->extension), - GFP_KERNEL); - - if ((!uid) || (!gid) || (!muid) || (!name) || (!extension)) { - kfree(uid); - kfree(gid); - kfree(muid); - kfree(name); - kfree(extension); - - return -ENOMEM; - } - - strcpy(uid, mistat->uid); - strcpy(gid, mistat->gid); - strcpy(muid, mistat->muid); - strcpy(name, mistat->name); - strcpy(extension, mistat->extension); + char *ptr = mistat->data+1; if (iattr->ia_valid & ATTR_UID) { - if (strlen(uid) != 8) { - dprintk(DEBUG_ERROR, "uid strlen is %u not 8\n", - (unsigned int)strlen(uid)); - sprintf(uid, "%08x", iattr->ia_uid); - } else { - kfree(uid); - uid = kmalloc(9, GFP_KERNEL); - } - - sprintf(uid, "%08x", iattr->ia_uid); + mistat->uid = ptr; + ptr += 1+sprintf(ptr, "%08x", iattr->ia_uid); mistat->n_uid = iattr->ia_uid; } if (iattr->ia_valid & ATTR_GID) { - if (strlen(gid) != 8) - dprintk(DEBUG_ERROR, "gid strlen is %u not 8\n", - (unsigned int)strlen(gid)); - else { - kfree(gid); - gid = kmalloc(9, GFP_KERNEL); - } - - sprintf(gid, "%08x", iattr->ia_gid); + mistat->gid = ptr; + ptr += 1+sprintf(ptr, "%08x", iattr->ia_gid); mistat->n_gid = iattr->ia_gid; } - - mistat->uid = mistat->data; - strcpy(mistat->uid, uid); - mistat->gid = mistat->data + strlen(uid) + 1; - strcpy(mistat->gid, gid); - mistat->muid = mistat->gid + strlen(gid) + 1; - strcpy(mistat->muid, muid); - mistat->name = mistat->muid + strlen(muid) + 1; - strcpy(mistat->name, name); - mistat->extension = mistat->name + strlen(name) + 1; - strcpy(mistat->extension, extension); - - kfree(uid); - kfree(gid); - kfree(muid); - kfree(name); - kfree(extension); } res = v9fs_t_wstat(v9ses, fid->fid, mistat, &fcall); @@ -985,17 +925,14 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) int retval = -EPERM; struct v9fs_fid *newfid; struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); - struct super_block *sb = dir ? dir->i_sb : NULL; struct v9fs_fcall *fcall = NULL; struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); dprintk(DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name, symname); - if ((!dentry) || (!sb) || (!v9ses)) { - dprintk(DEBUG_ERROR, "problem with arguments\n"); - return -EBADF; - } + if (!mistat) + return -ENOMEM; if (!v9ses->extended) { dprintk(DEBUG_ERROR, "not extended\n"); @@ -1040,7 +977,7 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) /** * v9fs_readlink - read a symlink's location (internal version) * @dentry: dentry for symlink - * @buf: buffer to load symlink location into + * @buffer: buffer to load symlink location into * @buflen: length of buffer * */ @@ -1179,7 +1116,7 @@ static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void * v9fs_vfs_link - create a hardlink * @old_dentry: dentry for file to link to * @dir: inode destination for new link - * @new_dentry: dentry for link + * @dentry: dentry for link * */ @@ -1274,6 +1211,9 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) dprintk(DEBUG_VFS, " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev)); + if (!mistat) + return -ENOMEM; + if (!new_valid_dev(rdev)) { retval = -EINVAL; goto FreeMem; @@ -1302,7 +1242,8 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) sprintf(symname, "b %u %u", MAJOR(rdev), MINOR(rdev)); else if (S_ISCHR(mode)) sprintf(symname, "c %u %u", MAJOR(rdev), MINOR(rdev)); - else if (S_ISFIFO(mode)) ; /* DO NOTHING */ + else if (S_ISFIFO(mode)) + ; /* DO NOTHING */ else { retval = -EINVAL; goto FreeMem; @@ -1319,8 +1260,6 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) FCALL_ERROR(fcall)); goto FreeMem; } - - kfree(fcall); } /* need to update dcache so we show up */ -- cgit v0.10.2 From 5d58bec5b7a8b8303df0a4dcb9a18feeefac6091 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:27 -0700 Subject: [PATCH] v9fs: Fix support for special files (devices, named pipes, etc.) Fix v9fs special files (block, char devices) support. Signed-off-by: Latchesar Ionkov Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 6d2357d..36fff08 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -250,6 +250,9 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) case S_IFBLK: case S_IFCHR: case S_IFSOCK: + init_special_inode(inode, inode->i_mode, + inode->i_rdev); + break; case S_IFREG: inode->i_op = &v9fs_file_inode_operations; inode->i_fop = &v9fs_file_operations; -- cgit v0.10.2 From b501611a6f78558eafcf09b228abd866d4ea5d9f Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:27 -0700 Subject: [PATCH] v9fs: readlink extended mode check LANL reported some issues with random crashes during mount of legacy protocol servers (9P2000 versus 9P2000.u) -- crash was always happening in readlink (which should never happen in legacy mode). Added some sanity conditionals to the get_inode code which should prevent the errors LANL was seeing. Code tested benign through regression. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 36fff08..0c13fc6 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -44,6 +44,7 @@ #include "fid.h" static struct inode_operations v9fs_dir_inode_operations; +static struct inode_operations v9fs_dir_inode_operations_ext; static struct inode_operations v9fs_file_inode_operations; static struct inode_operations v9fs_symlink_inode_operations; @@ -232,6 +233,7 @@ v9fs_mistat2unix(struct v9fs_stat *mistat, struct stat *buf, struct inode *v9fs_get_inode(struct super_block *sb, int mode) { struct inode *inode = NULL; + struct v9fs_session_info *v9ses = sb->s_fs_info; dprintk(DEBUG_VFS, "super block: %p mode: %o\n", sb, mode); @@ -250,6 +252,10 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) case S_IFBLK: case S_IFCHR: case S_IFSOCK: + if(!v9ses->extended) { + dprintk(DEBUG_ERROR, "special files without extended mode\n"); + return ERR_PTR(-EINVAL); + } init_special_inode(inode, inode->i_mode, inode->i_rdev); break; @@ -257,14 +263,21 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) inode->i_op = &v9fs_file_inode_operations; inode->i_fop = &v9fs_file_operations; break; + case S_IFLNK: + if(!v9ses->extended) { + dprintk(DEBUG_ERROR, "extended modes used w/o 9P2000.u\n"); + return ERR_PTR(-EINVAL); + } + inode->i_op = &v9fs_symlink_inode_operations; + break; case S_IFDIR: inode->i_nlink++; - inode->i_op = &v9fs_dir_inode_operations; + if(v9ses->extended) + inode->i_op = &v9fs_dir_inode_operations_ext; + else + inode->i_op = &v9fs_dir_inode_operations; inode->i_fop = &v9fs_dir_operations; break; - case S_IFLNK: - inode->i_op = &v9fs_symlink_inode_operations; - break; default: dprintk(DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n", mode, mode & S_IFMT); @@ -1284,7 +1297,7 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) return retval; } -static struct inode_operations v9fs_dir_inode_operations = { +static struct inode_operations v9fs_dir_inode_operations_ext = { .create = v9fs_vfs_create, .lookup = v9fs_vfs_lookup, .symlink = v9fs_vfs_symlink, @@ -1299,6 +1312,18 @@ static struct inode_operations v9fs_dir_inode_operations = { .setattr = v9fs_vfs_setattr, }; +static struct inode_operations v9fs_dir_inode_operations = { + .create = v9fs_vfs_create, + .lookup = v9fs_vfs_lookup, + .unlink = v9fs_vfs_unlink, + .mkdir = v9fs_vfs_mkdir, + .rmdir = v9fs_vfs_rmdir, + .mknod = v9fs_vfs_mknod, + .rename = v9fs_vfs_rename, + .getattr = v9fs_vfs_getattr, + .setattr = v9fs_vfs_setattr, +}; + static struct inode_operations v9fs_file_inode_operations = { .getattr = v9fs_vfs_getattr, .setattr = v9fs_vfs_setattr, -- cgit v0.10.2 From cb2e87a65d6cd735eb06fa595bf90497af28c37b Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:28 -0700 Subject: [PATCH] v9fs: fix handling of malformed 9P messages This patch attempts to do a better job of cleaning up after detecting errors on the transport. This should also improve error reporting on broken connections to servers. Signed-off-by: Latchesar Ionkov Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/error.h b/fs/9p/error.h index 2eb5927..78f89ac 100644 --- a/fs/9p/error.h +++ b/fs/9p/error.h @@ -47,6 +47,7 @@ static struct errormap errmap[] = { {"Operation not permitted", EPERM}, {"wstat prohibited", EPERM}, {"No such file or directory", ENOENT}, + {"directory entry not found", ENOENT}, {"file not found", ENOENT}, {"Interrupted system call", EINTR}, {"Input/output error", EIO}, diff --git a/fs/9p/mux.c b/fs/9p/mux.c index 0854bef..8835b57 100644 --- a/fs/9p/mux.c +++ b/fs/9p/mux.c @@ -162,18 +162,21 @@ static int v9fs_recv(struct v9fs_session_info *v9ses, struct v9fs_rpcreq *req) dprintk(DEBUG_MUX, "waiting for response: %d\n", req->tcall->tag); ret = wait_event_interruptible(v9ses->read_wait, ((v9ses->transport->status != Connected) || - (req->rcall != 0) || dprintcond(v9ses, req))); + (req->rcall != 0) || (req->err < 0) || + dprintcond(v9ses, req))); dprintk(DEBUG_MUX, "got it: rcall %p\n", req->rcall); + + spin_lock(&v9ses->muxlock); + list_del(&req->next); + spin_unlock(&v9ses->muxlock); + + if (req->err < 0) + return req->err; + if (v9ses->transport->status == Disconnected) return -ECONNRESET; - if (ret == 0) { - spin_lock(&v9ses->muxlock); - list_del(&req->next); - spin_unlock(&v9ses->muxlock); - } - return ret; } @@ -245,6 +248,9 @@ v9fs_mux_rpc(struct v9fs_session_info *v9ses, struct v9fs_fcall *tcall, if (!v9ses) return -EINVAL; + if (!v9ses->transport || v9ses->transport->status != Connected) + return -EIO; + if (rcall) *rcall = NULL; @@ -257,6 +263,7 @@ v9fs_mux_rpc(struct v9fs_session_info *v9ses, struct v9fs_fcall *tcall, tcall->tag = tid; req.tcall = tcall; + req.err = 0; req.rcall = NULL; ret = v9fs_send(v9ses, &req); @@ -371,16 +378,21 @@ static int v9fs_recvproc(void *data) } err = read_message(v9ses, rcall, v9ses->maxdata + V9FS_IOHDRSZ); - if (err < 0) { - kfree(rcall); - break; - } spin_lock(&v9ses->muxlock); - list_for_each_entry_safe(rreq, rptr, &v9ses->mux_fcalls, next) { - if (rreq->tcall->tag == rcall->tag) { - req = rreq; - req->rcall = rcall; - break; + if (err < 0) { + list_for_each_entry_safe(rreq, rptr, &v9ses->mux_fcalls, next) { + rreq->err = err; + } + if(err != -ERESTARTSYS) + eprintk(KERN_ERR, + "Transport error while reading message %d\n", err); + } else { + list_for_each_entry_safe(rreq, rptr, &v9ses->mux_fcalls, next) { + if (rreq->tcall->tag == rcall->tag) { + req = rreq; + req->rcall = rcall; + break; + } } } @@ -399,9 +411,10 @@ static int v9fs_recvproc(void *data) spin_unlock(&v9ses->muxlock); if (!req) { - dprintk(DEBUG_ERROR, - "unexpected response: id %d tag %d\n", - rcall->id, rcall->tag); + if (err >= 0) + dprintk(DEBUG_ERROR, + "unexpected response: id %d tag %d\n", + rcall->id, rcall->tag); kfree(rcall); } @@ -410,6 +423,8 @@ static int v9fs_recvproc(void *data) set_current_state(TASK_INTERRUPTIBLE); } + v9ses->transport->close(v9ses->transport); + /* Inform all pending processes about the failure */ wake_up_all(&v9ses->read_wait); diff --git a/fs/9p/mux.h b/fs/9p/mux.h index 82ce793..4994cb1 100644 --- a/fs/9p/mux.h +++ b/fs/9p/mux.h @@ -28,6 +28,7 @@ struct v9fs_rpcreq { struct v9fs_fcall *tcall; struct v9fs_fcall *rcall; + int err; /* error code if response failed */ /* XXX - could we put scatter/gather buffers here? */ diff --git a/fs/9p/trans_sock.c b/fs/9p/trans_sock.c index 081d1c8..01e26f0 100644 --- a/fs/9p/trans_sock.c +++ b/fs/9p/trans_sock.c @@ -254,7 +254,12 @@ v9fs_unix_init(struct v9fs_session_info *v9ses, const char *dev_name, static void v9fs_sock_close(struct v9fs_transport *trans) { - struct v9fs_trans_sock *ts = trans ? trans->priv : NULL; + struct v9fs_trans_sock *ts; + + if (!trans) + return; + + ts = trans->priv; if ((ts) && (ts->s)) { dprintk(DEBUG_TRANS, "closing the socket %p\n", ts->s); @@ -264,7 +269,10 @@ static void v9fs_sock_close(struct v9fs_transport *trans) dprintk(DEBUG_TRANS, "socket closed\n"); } - kfree(ts); + if (ts) + kfree(ts); + + trans->priv = NULL; } struct v9fs_transport v9fs_trans_tcp = { -- cgit v0.10.2 From 7726e9e10fc6e026ed2dc00e48f4a3ffc1254ad2 Mon Sep 17 00:00:00 2001 From: "Antonino A. Daplas" Date: Fri, 9 Sep 2005 13:04:29 -0700 Subject: [PATCH] fbdev: Add fbset -a support Add capability to fbdev to listen to the FB_ACTIVATE_ALL flag. If set, it notifies fbcon that all consoles must be set to the current var. Signed-off-by: Antonino Daplas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 35c88bd..751890a 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c @@ -2593,6 +2593,51 @@ static void fbcon_modechanged(struct fb_info *info) } } +static void fbcon_set_all_vcs(struct fb_info *info) +{ + struct fbcon_ops *ops = info->fbcon_par; + struct vc_data *vc; + struct display *p; + int i, rows, cols; + + if (!ops || ops->currcon < 0) + return; + + for (i = 0; i < MAX_NR_CONSOLES; i++) { + vc = vc_cons[i].d; + if (!vc || vc->vc_mode != KD_TEXT || + registered_fb[con2fb_map[i]] != info) + continue; + + p = &fb_display[vc->vc_num]; + + info->var.xoffset = info->var.yoffset = p->yscroll = 0; + var_to_display(p, &info->var, info); + cols = info->var.xres / vc->vc_font.width; + rows = info->var.yres / vc->vc_font.height; + vc_resize(vc, cols, rows); + + if (CON_IS_VISIBLE(vc)) { + updatescrollmode(p, info, vc); + scrollback_max = 0; + scrollback_current = 0; + update_var(vc->vc_num, info); + fbcon_set_palette(vc, color_table); + update_screen(vc); + if (softback_buf) { + int l = fbcon_softback_size / vc->vc_size_row; + if (l > 5) + softback_end = softback_buf + l * vc->vc_size_row; + else { + /* Smaller scrollback makes no sense, and 0 + would screw the operation totally */ + softback_top = 0; + } + } + } + } +} + static int fbcon_mode_deleted(struct fb_info *info, struct fb_videomode *mode) { @@ -2708,6 +2753,9 @@ static int fbcon_event_notify(struct notifier_block *self, case FB_EVENT_MODE_CHANGE: fbcon_modechanged(info); break; + case FB_EVENT_MODE_CHANGE_ALL: + fbcon_set_all_vcs(info); + break; case FB_EVENT_MODE_DELETE: mode = event->data; ret = fbcon_mode_deleted(info, mode); diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 4ff853f..a8eee79 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c @@ -684,11 +684,13 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) if (!err && (flags & FBINFO_MISC_USEREVENT)) { struct fb_event event; + int evnt = (var->activate & FB_ACTIVATE_ALL) ? + FB_EVENT_MODE_CHANGE_ALL : + FB_EVENT_MODE_CHANGE; info->flags &= ~FBINFO_MISC_USEREVENT; event.info = info; - notifier_call_chain(&fb_notifier_list, - FB_EVENT_MODE_CHANGE, + notifier_call_chain(&fb_notifier_list, evnt, &event); } } diff --git a/include/linux/fb.h b/include/linux/fb.h index bc24bee..70da819 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -495,6 +495,9 @@ struct fb_cursor_user { #define FB_EVENT_BLANK 0x08 /* Private modelist is to be replaced */ #define FB_EVENT_NEW_MODELIST 0x09 +/* The resolution of the passed in fb_info about to change and + all vc's should be changed */ +#define FB_EVENT_MODE_CHANGE_ALL 0x0A struct fb_event { struct fb_info *info; -- cgit v0.10.2 From d2d58384fc5d4c0fe2d8e34bc2d15a90a9bb372a Mon Sep 17 00:00:00 2001 From: "Antonino A. Daplas" Date: Fri, 9 Sep 2005 13:04:31 -0700 Subject: [PATCH] vesafb: Add blanking support Add rudimentary support by manipulating the VGA registers. However, not all vesa modes are VGA compatible, so VGA compatiblity is checked first. Only 2 levels are supported, powerup and powerdown. Signed-off-by: Antonino Daplas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/i386/boot/video.S b/arch/i386/boot/video.S index 0587477..02bf625a 100644 --- a/arch/i386/boot/video.S +++ b/arch/i386/boot/video.S @@ -97,6 +97,7 @@ #define PARAM_VESAPM_OFF 0x30 #define PARAM_LFB_PAGES 0x32 #define PARAM_VESA_ATTRIB 0x34 +#define PARAM_CAPABILITIES 0x36 /* Define DO_STORE according to CONFIG_VIDEO_RETAIN */ #ifdef CONFIG_VIDEO_RETAIN @@ -233,6 +234,10 @@ mopar_gr: movw 18(%di), %ax movl %eax, %fs:(PARAM_LFB_SIZE) +# store mode capabilities + movl 10(%di), %eax + movl %eax, %fs:(PARAM_CAPABILITIES) + # switching the DAC to 8-bit is for <= 8 bpp only movw %fs:(PARAM_LFB_DEPTH), %ax cmpw $8, %ax diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c index a272592..1ca80264 100644 --- a/drivers/video/vesafb.c +++ b/drivers/video/vesafb.c @@ -19,6 +19,7 @@ #include #include #include +#include