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 --- drivers/i2c/busses/Kconfig | 16 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-pxa.c | 1031 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1048 insertions(+) create mode 100644 drivers/i2c/busses/i2c-pxa.c (limited to 'drivers') diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index a0018de3bef..a3bec8d65cf 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 42d6d814da7..980b3e98367 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 00000000000..a72d2836529 --- /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); -- cgit v1.2.3-18-g5258 From df46b9a44ceb5af2ea2351ce8e28ae7bd840b00f Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Mon, 20 Jun 2005 14:04:44 +0200 Subject: [PATCH] Add blk_rq_map_kern() Add blk_rq_map_kern which takes a kernel buffer and maps it into a request and bio. This can be used by the dm hw_handlers, old sg_scsi_ioctl, and one day scsi special requests so all requests comming into scsi will have bios. All requests having bios should allow scsi to use scatter lists for all IO and allow it to use block layer functions. Signed-off-by: Jens Axboe --- drivers/block/ll_rw_blk.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'drivers') diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index f20eba22b14..e30a3c93b70 100644 --- a/drivers/block/ll_rw_blk.c +++ b/drivers/block/ll_rw_blk.c @@ -281,6 +281,7 @@ static inline void rq_init(request_queue_t *q, struct request *rq) rq->special = NULL; rq->data_len = 0; rq->data = NULL; + rq->nr_phys_segments = 0; rq->sense = NULL; rq->end_io = NULL; rq->end_io_data = NULL; @@ -2176,6 +2177,61 @@ int blk_rq_unmap_user(struct request *rq, struct bio *bio, unsigned int ulen) EXPORT_SYMBOL(blk_rq_unmap_user); +static int blk_rq_map_kern_endio(struct bio *bio, unsigned int bytes_done, + int error) +{ + if (bio->bi_size) + return 1; + + bio_put(bio); + return 0; +} + +/** + * blk_rq_map_kern - map kernel data to a request, for REQ_BLOCK_PC usage + * @q: request queue where request should be inserted + * @rw: READ or WRITE data + * @kbuf: the kernel buffer + * @len: length of user data + */ +struct request *blk_rq_map_kern(request_queue_t *q, int rw, void *kbuf, + unsigned int len, unsigned int gfp_mask) +{ + struct request *rq; + struct bio *bio; + + if (len > (q->max_sectors << 9)) + return ERR_PTR(-EINVAL); + if ((!len && kbuf) || (len && !kbuf)) + return ERR_PTR(-EINVAL); + + rq = blk_get_request(q, rw, gfp_mask); + if (!rq) + return ERR_PTR(-ENOMEM); + + bio = bio_map_kern(q, kbuf, len, gfp_mask); + if (!IS_ERR(bio)) { + if (rw) + bio->bi_rw |= (1 << BIO_RW); + bio->bi_end_io = blk_rq_map_kern_endio; + + rq->bio = rq->biotail = bio; + blk_rq_bio_prep(q, rq, bio); + + rq->buffer = rq->data = NULL; + rq->data_len = len; + return rq; + } + + /* + * bio is the err-ptr + */ + blk_put_request(rq); + return (struct request *) bio; +} + +EXPORT_SYMBOL(blk_rq_map_kern); + /** * blk_execute_rq - insert a request into queue for execution * @q: queue to insert the request in -- cgit v1.2.3-18-g5258 From b823825e8e09aac6dc1ca362cd5639a87329d636 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 20 Jun 2005 14:05:27 +0200 Subject: [PATCH] Keep the bio end_io parts inside of bio.c for blk_rq_map_kern() Signed-off-by: Jens Axboe --- drivers/block/ll_rw_blk.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'drivers') diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index e30a3c93b70..1471aca6fa1 100644 --- a/drivers/block/ll_rw_blk.c +++ b/drivers/block/ll_rw_blk.c @@ -2177,16 +2177,6 @@ int blk_rq_unmap_user(struct request *rq, struct bio *bio, unsigned int ulen) EXPORT_SYMBOL(blk_rq_unmap_user); -static int blk_rq_map_kern_endio(struct bio *bio, unsigned int bytes_done, - int error) -{ - if (bio->bi_size) - return 1; - - bio_put(bio); - return 0; -} - /** * blk_rq_map_kern - map kernel data to a request, for REQ_BLOCK_PC usage * @q: request queue where request should be inserted @@ -2213,7 +2203,6 @@ struct request *blk_rq_map_kern(request_queue_t *q, int rw, void *kbuf, if (!IS_ERR(bio)) { if (rw) bio->bi_rw |= (1 << BIO_RW); - bio->bi_end_io = blk_rq_map_kern_endio; rq->bio = rq->biotail = bio; blk_rq_bio_prep(q, rq, bio); -- cgit v1.2.3-18-g5258 From dd1cab95f356f1395278633565f198463cf6bd24 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 20 Jun 2005 14:06:01 +0200 Subject: [PATCH] Cleanup blk_rq_map_* interfaces Change the blk_rq_map_user() and blk_rq_map_kern() interface to require a previously allocated request to be passed in. This is both more efficient for multiple iterations of mapping data to the same request, and it is also a much nicer API. Signed-off-by: Jens Axboe --- drivers/block/ll_rw_blk.c | 68 ++++++++++++++++++---------------------------- drivers/block/scsi_ioctl.c | 23 ++++++++++------ drivers/cdrom/cdrom.c | 13 ++++++--- 3 files changed, 50 insertions(+), 54 deletions(-) (limited to 'drivers') diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index 1471aca6fa1..42c4f3651cf 100644 --- a/drivers/block/ll_rw_blk.c +++ b/drivers/block/ll_rw_blk.c @@ -2107,21 +2107,19 @@ EXPORT_SYMBOL(blk_insert_request); * original bio must be passed back in to blk_rq_unmap_user() for proper * unmapping. */ -struct request *blk_rq_map_user(request_queue_t *q, int rw, void __user *ubuf, - unsigned int len) +int blk_rq_map_user(request_queue_t *q, struct request *rq, void __user *ubuf, + unsigned int len) { unsigned long uaddr; - struct request *rq; struct bio *bio; + int reading; if (len > (q->max_sectors << 9)) - return ERR_PTR(-EINVAL); - if ((!len && ubuf) || (len && !ubuf)) - return ERR_PTR(-EINVAL); + return -EINVAL; + if (!len || !ubuf) + return -EINVAL; - rq = blk_get_request(q, rw, __GFP_WAIT); - if (!rq) - return ERR_PTR(-ENOMEM); + reading = rq_data_dir(rq) == READ; /* * if alignment requirement is satisfied, map in user pages for @@ -2129,9 +2127,9 @@ struct request *blk_rq_map_user(request_queue_t *q, int rw, void __user *ubuf, */ uaddr = (unsigned long) ubuf; if (!(uaddr & queue_dma_alignment(q)) && !(len & queue_dma_alignment(q))) - bio = bio_map_user(q, NULL, uaddr, len, rw == READ); + bio = bio_map_user(q, NULL, uaddr, len, reading); else - bio = bio_copy_user(q, uaddr, len, rw == READ); + bio = bio_copy_user(q, uaddr, len, reading); if (!IS_ERR(bio)) { rq->bio = rq->biotail = bio; @@ -2139,14 +2137,13 @@ struct request *blk_rq_map_user(request_queue_t *q, int rw, void __user *ubuf, rq->buffer = rq->data = NULL; rq->data_len = len; - return rq; + return 0; } /* * bio is the err-ptr */ - blk_put_request(rq); - return (struct request *) bio; + return PTR_ERR(bio); } EXPORT_SYMBOL(blk_rq_map_user); @@ -2160,7 +2157,7 @@ EXPORT_SYMBOL(blk_rq_map_user); * Description: * Unmap a request previously mapped by blk_rq_map_user(). */ -int blk_rq_unmap_user(struct request *rq, struct bio *bio, unsigned int ulen) +int blk_rq_unmap_user(struct bio *bio, unsigned int ulen) { int ret = 0; @@ -2171,8 +2168,7 @@ int blk_rq_unmap_user(struct request *rq, struct bio *bio, unsigned int ulen) ret = bio_uncopy_user(bio); } - blk_put_request(rq); - return ret; + return 0; } EXPORT_SYMBOL(blk_rq_unmap_user); @@ -2184,39 +2180,29 @@ EXPORT_SYMBOL(blk_rq_unmap_user); * @kbuf: the kernel buffer * @len: length of user data */ -struct request *blk_rq_map_kern(request_queue_t *q, int rw, void *kbuf, - unsigned int len, unsigned int gfp_mask) +int blk_rq_map_kern(request_queue_t *q, struct request *rq, void *kbuf, + unsigned int len, unsigned int gfp_mask) { - struct request *rq; struct bio *bio; if (len > (q->max_sectors << 9)) - return ERR_PTR(-EINVAL); - if ((!len && kbuf) || (len && !kbuf)) - return ERR_PTR(-EINVAL); - - rq = blk_get_request(q, rw, gfp_mask); - if (!rq) - return ERR_PTR(-ENOMEM); + return -EINVAL; + if (!len || !kbuf) + return -EINVAL; bio = bio_map_kern(q, kbuf, len, gfp_mask); - if (!IS_ERR(bio)) { - if (rw) - bio->bi_rw |= (1 << BIO_RW); + if (IS_ERR(bio)) + return PTR_ERR(bio); - rq->bio = rq->biotail = bio; - blk_rq_bio_prep(q, rq, bio); + if (rq_data_dir(rq) == WRITE) + bio->bi_rw |= (1 << BIO_RW); - rq->buffer = rq->data = NULL; - rq->data_len = len; - return rq; - } + rq->bio = rq->biotail = bio; + blk_rq_bio_prep(q, rq, bio); - /* - * bio is the err-ptr - */ - blk_put_request(rq); - return (struct request *) bio; + rq->buffer = rq->data = NULL; + rq->data_len = len; + return 0; } EXPORT_SYMBOL(blk_rq_map_kern); diff --git a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c index 681871ca5d6..93c4ca874be 100644 --- a/drivers/block/scsi_ioctl.c +++ b/drivers/block/scsi_ioctl.c @@ -216,7 +216,7 @@ static int sg_io(struct file *file, request_queue_t *q, struct gendisk *bd_disk, struct sg_io_hdr *hdr) { unsigned long start_time; - int reading, writing; + int reading, writing, ret; struct request *rq; struct bio *bio; char sense[SCSI_SENSE_BUFFERSIZE]; @@ -255,14 +255,17 @@ static int sg_io(struct file *file, request_queue_t *q, reading = 1; break; } + } - rq = blk_rq_map_user(q, writing ? WRITE : READ, hdr->dxferp, - hdr->dxfer_len); + rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL); + if (!rq) + return -ENOMEM; - if (IS_ERR(rq)) - return PTR_ERR(rq); - } else - rq = blk_get_request(q, READ, __GFP_WAIT); + if (reading || writing) { + ret = blk_rq_map_user(q, rq, hdr->dxferp, hdr->dxfer_len); + if (ret) + goto out; + } /* * fill in request structure @@ -321,11 +324,13 @@ static int sg_io(struct file *file, request_queue_t *q, } if (blk_rq_unmap_user(rq, bio, hdr->dxfer_len)) - return -EFAULT; + ret = -EFAULT; /* may not have succeeded, but output values written to control * structure (struct sg_io_hdr). */ - return 0; +out: + blk_put_request(rq); + return ret; } #define OMAX_SB_LEN 16 /* For backward compatibility */ diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index beaa561f2ed..6a7d926774a 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -2097,6 +2097,10 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, if (!q) return -ENXIO; + rq = blk_get_request(q, READ, GFP_KERNEL); + if (!rq) + return -ENOMEM; + cdi->last_sense = 0; while (nframes) { @@ -2108,9 +2112,9 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, len = nr * CD_FRAMESIZE_RAW; - rq = blk_rq_map_user(q, READ, ubuf, len); - if (IS_ERR(rq)) - return PTR_ERR(rq); + ret = blk_rq_map_user(q, rq, ubuf, len); + if (ret) + break; memset(rq->cmd, 0, sizeof(rq->cmd)); rq->cmd[0] = GPCMD_READ_CD; @@ -2138,7 +2142,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, cdi->last_sense = s->sense_key; } - if (blk_rq_unmap_user(rq, bio, len)) + if (blk_rq_unmap_user(bio, len)) ret = -EFAULT; if (ret) @@ -2149,6 +2153,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, ubuf += len; } + blk_put_request(rq); return ret; } -- cgit v1.2.3-18-g5258 From f1970baf6d74e03bd32072ab453f2fc01bc1b8d3 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Mon, 20 Jun 2005 14:06:52 +0200 Subject: [PATCH] Add scatter-gather support for the block layer SG_IO Signed-off-by: Jens Axboe --- drivers/block/ll_rw_blk.c | 64 +++++++++++++++++++++++++++++++++++++++++----- drivers/block/scsi_ioctl.c | 34 ++++++++++++++++-------- 2 files changed, 81 insertions(+), 17 deletions(-) (limited to 'drivers') diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index 42c4f3651cf..874e46fc374 100644 --- a/drivers/block/ll_rw_blk.c +++ b/drivers/block/ll_rw_blk.c @@ -2148,6 +2148,50 @@ int blk_rq_map_user(request_queue_t *q, struct request *rq, void __user *ubuf, EXPORT_SYMBOL(blk_rq_map_user); +/** + * blk_rq_map_user_iov - map user data to a request, for REQ_BLOCK_PC usage + * @q: request queue where request should be inserted + * @rq: request to map data to + * @iov: pointer to the iovec + * @iov_count: number of elements in the iovec + * + * Description: + * Data will be mapped directly for zero copy io, if possible. Otherwise + * a kernel bounce buffer is used. + * + * A matching blk_rq_unmap_user() must be issued at the end of io, while + * still in process context. + * + * Note: The mapped bio may need to be bounced through blk_queue_bounce() + * before being submitted to the device, as pages mapped may be out of + * reach. It's the callers responsibility to make sure this happens. The + * original bio must be passed back in to blk_rq_unmap_user() for proper + * unmapping. + */ +int blk_rq_map_user_iov(request_queue_t *q, struct request *rq, + struct sg_iovec *iov, int iov_count) +{ + struct bio *bio; + + if (!iov || iov_count <= 0) + return -EINVAL; + + /* we don't allow misaligned data like bio_map_user() does. If the + * user is using sg, they're expected to know the alignment constraints + * and respect them accordingly */ + bio = bio_map_user_iov(q, NULL, iov, iov_count, rq_data_dir(rq)== READ); + if (IS_ERR(bio)) + return PTR_ERR(bio); + + rq->bio = rq->biotail = bio; + blk_rq_bio_prep(q, rq, bio); + rq->buffer = rq->data = NULL; + rq->data_len = bio->bi_size; + return 0; +} + +EXPORT_SYMBOL(blk_rq_map_user_iov); + /** * blk_rq_unmap_user - unmap a request with user data * @rq: request to be unmapped @@ -2207,6 +2251,19 @@ int blk_rq_map_kern(request_queue_t *q, struct request *rq, void *kbuf, EXPORT_SYMBOL(blk_rq_map_kern); +void blk_execute_rq_nowait(request_queue_t *q, struct gendisk *bd_disk, + struct request *rq, int at_head, + void (*done)(struct request *)) +{ + int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK; + + rq->rq_disk = bd_disk; + rq->flags |= REQ_NOMERGE; + rq->end_io = done; + elv_add_request(q, rq, where, 1); + generic_unplug_device(q); +} + /** * blk_execute_rq - insert a request into queue for execution * @q: queue to insert the request in @@ -2224,8 +2281,6 @@ int blk_execute_rq(request_queue_t *q, struct gendisk *bd_disk, char sense[SCSI_SENSE_BUFFERSIZE]; int err = 0; - rq->rq_disk = bd_disk; - /* * we need an extra reference to the request, so we can look at * it after io completion @@ -2238,11 +2293,8 @@ int blk_execute_rq(request_queue_t *q, struct gendisk *bd_disk, rq->sense_len = 0; } - rq->flags |= REQ_NOMERGE; rq->waiting = &wait; - rq->end_io = blk_end_sync_rq; - elv_add_request(q, rq, ELEVATOR_INSERT_BACK, 1); - generic_unplug_device(q); + blk_execute_rq_nowait(q, bd_disk, rq, 0, blk_end_sync_rq); wait_for_completion(&wait); rq->waiting = NULL; diff --git a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c index 93c4ca874be..09a7e73a081 100644 --- a/drivers/block/scsi_ioctl.c +++ b/drivers/block/scsi_ioctl.c @@ -231,17 +231,11 @@ static int sg_io(struct file *file, request_queue_t *q, if (verify_command(file, cmd)) return -EPERM; - /* - * we'll do that later - */ - if (hdr->iovec_count) - return -EOPNOTSUPP; - if (hdr->dxfer_len > (q->max_sectors << 9)) return -EIO; reading = writing = 0; - if (hdr->dxfer_len) { + if (hdr->dxfer_len) switch (hdr->dxfer_direction) { default: return -EINVAL; @@ -261,11 +255,29 @@ static int sg_io(struct file *file, request_queue_t *q, if (!rq) return -ENOMEM; - if (reading || writing) { - ret = blk_rq_map_user(q, rq, hdr->dxferp, hdr->dxfer_len); - if (ret) + if (hdr->iovec_count) { + const int size = sizeof(struct sg_iovec) * hdr->iovec_count; + struct sg_iovec *iov; + + iov = kmalloc(size, GFP_KERNEL); + if (!iov) { + ret = -ENOMEM; goto out; - } + } + + if (copy_from_user(iov, hdr->dxferp, size)) { + kfree(iov); + ret = -EFAULT; + goto out; + } + + ret = blk_rq_map_user_iov(q, rq, iov, hdr->iovec_count); + kfree(iov); + } else if (hdr->dxfer_len) + ret = blk_rq_map_user(q, rq, hdr->dxferp, hdr->dxfer_len); + + if (ret) + goto out; /* * fill in request structure -- cgit v1.2.3-18-g5258 From e1f546e185e9d8cb9303d74d1cd5bc704f265384 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Mon, 20 Jun 2005 14:07:17 +0200 Subject: [PATCH] The blk_rq_map_user() change missed an update in scsi_ioctl.c Signed-off-by: Jens Axboe --- drivers/block/scsi_ioctl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c index 09a7e73a081..b35cb75c752 100644 --- a/drivers/block/scsi_ioctl.c +++ b/drivers/block/scsi_ioctl.c @@ -216,7 +216,7 @@ static int sg_io(struct file *file, request_queue_t *q, struct gendisk *bd_disk, struct sg_io_hdr *hdr) { unsigned long start_time; - int reading, writing, ret; + int reading, writing, ret = 0; struct request *rq; struct bio *bio; char sense[SCSI_SENSE_BUFFERSIZE]; @@ -249,7 +249,6 @@ static int sg_io(struct file *file, request_queue_t *q, reading = 1; break; } - } rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL); if (!rq) @@ -335,7 +334,7 @@ static int sg_io(struct file *file, request_queue_t *q, hdr->sb_len_wr = len; } - if (blk_rq_unmap_user(rq, bio, hdr->dxfer_len)) + if (blk_rq_unmap_user(bio, hdr->dxfer_len)) ret = -EFAULT; /* may not have succeeded, but output values written to control -- cgit v1.2.3-18-g5258 From f63eb21b4f32028755b6b9d47e5eb13c18ba0cae Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 20 Jun 2005 14:10:25 +0200 Subject: [PATCH] kill 'reading' variable in sg_io(), it isn't used anymore. Signed-off-by: Jens Axboe --- drivers/block/scsi_ioctl.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c index b35cb75c752..7717b76f7f2 100644 --- a/drivers/block/scsi_ioctl.c +++ b/drivers/block/scsi_ioctl.c @@ -216,7 +216,7 @@ static int sg_io(struct file *file, request_queue_t *q, struct gendisk *bd_disk, struct sg_io_hdr *hdr) { unsigned long start_time; - int reading, writing, ret = 0; + int writing = 0, ret = 0; struct request *rq; struct bio *bio; char sense[SCSI_SENSE_BUFFERSIZE]; @@ -234,19 +234,15 @@ static int sg_io(struct file *file, request_queue_t *q, if (hdr->dxfer_len > (q->max_sectors << 9)) return -EIO; - reading = writing = 0; if (hdr->dxfer_len) switch (hdr->dxfer_direction) { default: return -EINVAL; case SG_DXFER_TO_FROM_DEV: - reading = 1; - /* fall through */ case SG_DXFER_TO_DEV: writing = 1; break; case SG_DXFER_FROM_DEV: - reading = 1; break; } -- cgit v1.2.3-18-g5258 From 994ca9a19616f0d4161a9e825f0835925d522426 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Mon, 20 Jun 2005 14:11:09 +0200 Subject: [PATCH] update blk_execute_rq to take an at_head parameter Original From: Mike Christie Modified to split out block changes (this patch) and SCSI pieces. Signed-off-by: Jens Axboe Signed-off-by: James Bottomley --- drivers/block/ll_rw_blk.c | 7 ++++--- drivers/block/scsi_ioctl.c | 6 +++--- drivers/cdrom/cdrom.c | 2 +- drivers/ide/ide-disk.c | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index 874e46fc374..d260a2ce9a7 100644 --- a/drivers/block/ll_rw_blk.c +++ b/drivers/block/ll_rw_blk.c @@ -2269,13 +2269,14 @@ void blk_execute_rq_nowait(request_queue_t *q, struct gendisk *bd_disk, * @q: queue to insert the request in * @bd_disk: matching gendisk * @rq: request to insert + * @at_head: insert request at head or tail of queue * * Description: * Insert a fully prepared request at the back of the io scheduler queue * for execution. */ int blk_execute_rq(request_queue_t *q, struct gendisk *bd_disk, - struct request *rq) + struct request *rq, int at_head) { DECLARE_COMPLETION(wait); char sense[SCSI_SENSE_BUFFERSIZE]; @@ -2294,7 +2295,7 @@ int blk_execute_rq(request_queue_t *q, struct gendisk *bd_disk, } rq->waiting = &wait; - blk_execute_rq_nowait(q, bd_disk, rq, 0, blk_end_sync_rq); + blk_execute_rq_nowait(q, bd_disk, rq, at_head, blk_end_sync_rq); wait_for_completion(&wait); rq->waiting = NULL; @@ -2361,7 +2362,7 @@ int blkdev_scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk, rq->data_len = 0; rq->timeout = 60 * HZ; - ret = blk_execute_rq(q, disk, rq); + ret = blk_execute_rq(q, disk, rq, 0); if (ret && error_sector) *error_sector = rq->sector; diff --git a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c index 7717b76f7f2..abb2df249fd 100644 --- a/drivers/block/scsi_ioctl.c +++ b/drivers/block/scsi_ioctl.c @@ -308,7 +308,7 @@ static int sg_io(struct file *file, request_queue_t *q, * (if he doesn't check that is his problem). * N.B. a non-zero SCSI status is _not_ necessarily an error. */ - blk_execute_rq(q, bd_disk, rq); + blk_execute_rq(q, bd_disk, rq, 0); /* write to all output members */ hdr->status = 0xff & rq->errors; @@ -420,7 +420,7 @@ static int sg_scsi_ioctl(struct file *file, request_queue_t *q, rq->data_len = bytes; rq->flags |= REQ_BLOCK_PC; - blk_execute_rq(q, bd_disk, rq); + blk_execute_rq(q, bd_disk, rq, 0); err = rq->errors & 0xff; /* only 8 bit SCSI status */ if (err) { if (rq->sense_len && rq->sense) { @@ -573,7 +573,7 @@ int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd, rq->cmd[0] = GPCMD_START_STOP_UNIT; rq->cmd[4] = 0x02 + (close != 0); rq->cmd_len = 6; - err = blk_execute_rq(q, bd_disk, rq); + err = blk_execute_rq(q, bd_disk, rq, 0); blk_put_request(rq); break; default: diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 6a7d926774a..15396034841 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -2136,7 +2136,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, if (rq->bio) blk_queue_bounce(q, &rq->bio); - if (blk_execute_rq(q, cdi->disk, rq)) { + if (blk_execute_rq(q, cdi->disk, rq, 0)) { struct request_sense *s = rq->sense; ret = -EIO; cdi->last_sense = s->sense_key; diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 3302cd8eab4..9176da7a985 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -750,7 +750,7 @@ static int idedisk_issue_flush(request_queue_t *q, struct gendisk *disk, idedisk_prepare_flush(q, rq); - ret = blk_execute_rq(q, disk, rq); + ret = blk_execute_rq(q, disk, rq, 0); /* * if we failed and caller wants error offset, get it -- cgit v1.2.3-18-g5258 From 73747aed04d3b3fb694961d025f81863b99c6898 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 20 Jun 2005 14:21:01 +0200 Subject: [PATCH] ll_rw_blk.c kerneldoc updates The recent mapping changes didn't update the kerneldoc appropriately. Original from Christoph Hellwig Signed-off-by: Jens Axboe --- drivers/block/ll_rw_blk.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index d260a2ce9a7..f6fda036b4a 100644 --- a/drivers/block/ll_rw_blk.c +++ b/drivers/block/ll_rw_blk.c @@ -2090,7 +2090,7 @@ EXPORT_SYMBOL(blk_insert_request); /** * blk_rq_map_user - map user data to a request, for REQ_BLOCK_PC usage * @q: request queue where request should be inserted - * @rw: READ or WRITE data + * @rq: request structure to fill * @ubuf: the user buffer * @len: length of user data * @@ -2194,12 +2194,11 @@ EXPORT_SYMBOL(blk_rq_map_user_iov); /** * blk_rq_unmap_user - unmap a request with user data - * @rq: request to be unmapped - * @bio: bio for the request + * @bio: bio to be unmapped * @ulen: length of user buffer * * Description: - * Unmap a request previously mapped by blk_rq_map_user(). + * Unmap a bio previously mapped by blk_rq_map_user(). */ int blk_rq_unmap_user(struct bio *bio, unsigned int ulen) { @@ -2220,9 +2219,10 @@ EXPORT_SYMBOL(blk_rq_unmap_user); /** * blk_rq_map_kern - map kernel data to a request, for REQ_BLOCK_PC usage * @q: request queue where request should be inserted - * @rw: READ or WRITE data + * @rq: request to fill * @kbuf: the kernel buffer * @len: length of user data + * @gfp_mask: memory allocation flags */ int blk_rq_map_kern(request_queue_t *q, struct request *rq, void *kbuf, unsigned int len, unsigned int gfp_mask) @@ -2251,6 +2251,18 @@ int blk_rq_map_kern(request_queue_t *q, struct request *rq, void *kbuf, EXPORT_SYMBOL(blk_rq_map_kern); +/** + * blk_execute_rq_nowait - insert a request into queue for execution + * @q: queue to insert the request in + * @bd_disk: matching gendisk + * @rq: request to insert + * @at_head: insert request at head or tail of queue + * @done: I/O completion handler + * + * Description: + * Insert a fully prepared request at the back of the io scheduler queue + * for execution. Don't wait for completion. + */ void blk_execute_rq_nowait(request_queue_t *q, struct gendisk *bd_disk, struct request *rq, int at_head, void (*done)(struct request *)) @@ -2273,7 +2285,7 @@ void blk_execute_rq_nowait(request_queue_t *q, struct gendisk *bd_disk, * * Description: * Insert a fully prepared request at the back of the io scheduler queue - * for execution. + * for execution and wait for completion. */ int blk_execute_rq(request_queue_t *q, struct gendisk *bd_disk, struct request *rq, int at_head) -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/dispatcher/dsobject.c | 3 +++ drivers/acpi/dispatcher/dswstate.c | 4 ++-- drivers/acpi/events/evgpeblk.c | 36 ++++++++++++++--------------- drivers/acpi/events/evrgnini.c | 10 ++++++--- drivers/acpi/events/evxfevnt.c | 6 ++--- drivers/acpi/executer/exdump.c | 14 ++++++------ drivers/acpi/executer/exstore.c | 4 ++-- drivers/acpi/executer/exstoren.c | 4 ---- drivers/acpi/namespace/nsdump.c | 31 +++++++++++++------------ drivers/acpi/parser/psopcode.c | 2 +- drivers/acpi/resources/rsdump.c | 4 +++- drivers/acpi/utilities/utcopy.c | 46 ++++++++++++++++---------------------- 12 files changed, 80 insertions(+), 84 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c index bfbae4e4c66..1eee2d54180 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 9cd3db652b3..4ef0e85c677 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 84186a7d17b..ee5419b8f1b 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 95bc09c73a6..f2d53af9761 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 f337dc2cc56..c5f74d7b64d 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 40850064811..ae6cad85e01 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 2725db0901b..763ffeea850 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 120f30ed0bd..433588ab432 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 6c2aef0e0dd..05af95322a6 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 5744673568c..95ef5e8947a 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 1935dab2ab5..2c3bb8c3574 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 11e88495716..31c30a32e5c 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); } -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/dispatcher/dsmethod.c | 8 ++- drivers/acpi/dispatcher/dsopcode.c | 15 +++-- drivers/acpi/dispatcher/dswload.c | 56 ++++++++++++------- drivers/acpi/dispatcher/dswstate.c | 1 + drivers/acpi/executer/exconfig.c | 27 +++++---- drivers/acpi/executer/exfield.c | 5 +- drivers/acpi/executer/exnames.c | 7 +++ drivers/acpi/executer/exoparg1.c | 11 ++-- drivers/acpi/namespace/nsparse.c | 2 + drivers/acpi/parser/psparse.c | 109 ++++++++++++++++++++++++++++--------- drivers/acpi/tables/tbxfroot.c | 6 +- drivers/acpi/utilities/utmisc.c | 38 +++++++------ 12 files changed, 196 insertions(+), 89 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 9fc3f4c033e..c9d9a6c45ae 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 ba13bca28be..750bdb1ac34 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 1ac197ccfc8..e2e0a855be2 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 4ef0e85c677..cc45d52225d 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 734b2f24af4..8bfa6effaa0 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 22c8fa480f6..a690c925099 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 639f0bd3f6d..b6ba1a7a677 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 dbdf8262ba0..ffc61ddeb65 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 a0e13e8d376..f81b836e77f 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 bbfdc1a58c2..bdbe0d99486 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 dc3c3f6a9f6..198997aa7fb 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 f6de4ed3d52..bb658777fa8 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 */ -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/dispatcher/dsmthdat.c | 15 +- drivers/acpi/dispatcher/dswload.c | 6 +- drivers/acpi/dispatcher/dswstate.c | 33 +- drivers/acpi/events/evgpe.c | 5 +- drivers/acpi/events/evgpeblk.c | 27 +- drivers/acpi/events/evmisc.c | 4 +- drivers/acpi/events/evxface.c | 10 +- drivers/acpi/executer/exconvrt.c | 2 +- drivers/acpi/executer/exdump.c | 174 +++++++-- drivers/acpi/executer/exmisc.c | 2 +- drivers/acpi/executer/exoparg1.c | 3 +- drivers/acpi/executer/exoparg3.c | 63 ++- drivers/acpi/executer/exstore.c | 2 +- drivers/acpi/executer/exutils.c | 2 +- drivers/acpi/hardware/hwgpe.c | 20 +- drivers/acpi/hardware/hwregs.c | 2 +- drivers/acpi/hardware/hwsleep.c | 12 +- drivers/acpi/namespace/nsaccess.c | 2 +- drivers/acpi/namespace/nsalloc.c | 6 +- drivers/acpi/namespace/nsdump.c | 30 +- drivers/acpi/osl.c | 196 +++++++--- drivers/acpi/parser/Makefile | 2 +- drivers/acpi/parser/psloop.c | 775 +++++++++++++++++++++++++++++++++++++ drivers/acpi/parser/psopcode.c | 28 +- drivers/acpi/parser/psparse.c | 728 +--------------------------------- drivers/acpi/parser/psutils.c | 37 +- drivers/acpi/tables/tbconvrt.c | 8 +- drivers/acpi/tables/tbrsdt.c | 34 +- drivers/acpi/tables/tbxfroot.c | 8 +- drivers/acpi/utilities/Makefile | 2 +- drivers/acpi/utilities/utalloc.c | 304 ++++++--------- drivers/acpi/utilities/utcache.c | 322 +++++++++++++++ drivers/acpi/utilities/utdebug.c | 4 +- drivers/acpi/utilities/utglobal.c | 38 +- drivers/acpi/utilities/utinit.c | 2 +- drivers/acpi/utilities/utmisc.c | 689 +-------------------------------- drivers/acpi/utilities/utmutex.c | 380 ++++++++++++++++++ drivers/acpi/utilities/utobject.c | 34 +- drivers/acpi/utilities/utstate.c | 376 ++++++++++++++++++ drivers/acpi/utilities/utxface.c | 23 +- 40 files changed, 2469 insertions(+), 1941 deletions(-) create mode 100644 drivers/acpi/parser/psloop.c create mode 100644 drivers/acpi/utilities/utcache.c create mode 100644 drivers/acpi/utilities/utmutex.c create mode 100644 drivers/acpi/utilities/utstate.c (limited to 'drivers') diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c index f7998306f75..c83d53fd639 100644 --- a/drivers/acpi/dispatcher/dsmthdat.c +++ b/drivers/acpi/dispatcher/dsmthdat.c @@ -632,23 +632,12 @@ acpi_ds_store_object_to_local ( * Weird, but true. */ 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 e2e0a855be2..d2c603f54fd 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 cc45d52225d..d360d8e8954 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 081120b109b..ede834df4f6 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 ee5419b8f1b..dfc54692b12 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 659e9095611..38d7ab8aef3 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 4092d47f675..4c1c25e316a 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 97856c48bd7..21331625e66 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 ae6cad85e01..7007abb6051 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 @@ -563,11 +573,146 @@ 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 022f281345b..237ef28c813 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 ffc61ddeb65..131f49acb1d 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 23b068adbf5..197890f443b 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 763ffeea850..59dbfeaa54c 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 5c7ec0c0417..d00b0dcba96 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 8daeabb2fc7..3536bbb990c 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 6d9e4eb8483..04a058565d8 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 415d342aeab..cedee0c43b5 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 ece7a9dedd5..9df0a64ba9e 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 5653a19d717..3f94b0806ec 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 05af95322a6..c9f35dd7a43 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 bdd9f37f810..56e7cedba91 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 bbdd286c660..db24ee09cf1 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 00000000000..decb2e9a049 --- /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 95ef5e8947a..6f7594a516d 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 bdbe0d99486..16b84a3d043 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, @@ -439,706 +419,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 diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c index a10f88715d4..19a27020eee 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 92e0c31539b..d4ff71f5fe5 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 b7ffe39c362..13c6ddb2f54 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 198997aa7fb..fe9c8317df4 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 939c447dd52..e87108b7338 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 c4e7f989a2b..5061c6f0ee6 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 00000000000..07588812e72 --- /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 794c7df3f2a..08362f686ec 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 4146019b543..8653dda4f81 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 7f3713889ff..fd7ceba8322 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 bb658777fa8..207c836aec6 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++) { @@ -541,326 +535,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 @@ -903,361 +577,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 diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c new file mode 100644 index 00000000000..a80b97cb2e5 --- /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 cd3899b9cc5..19178e14295 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 00000000000..192e7ac9569 --- /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 e8803d81065..850da681742 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); } -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/utilities/utdelete.c | 42 +++------------------------------------ 1 file changed, 3 insertions(+), 39 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index bc540302268..be97ada23c3 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 v1.2.3-18-g5258 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 --- drivers/acpi/dispatcher/dsinit.c | 6 +- drivers/acpi/dispatcher/dsmethod.c | 35 +++++--- drivers/acpi/executer/exconfig.c | 2 +- drivers/acpi/executer/exdump.c | 2 +- drivers/acpi/executer/exoparg1.c | 15 +--- drivers/acpi/executer/exresop.c | 16 ++++ drivers/acpi/namespace/nsaccess.c | 2 +- drivers/acpi/namespace/nsalloc.c | 5 +- drivers/acpi/namespace/nsdump.c | 8 +- drivers/acpi/namespace/nsparse.c | 2 +- drivers/acpi/parser/psloop.c | 9 +- drivers/acpi/parser/psxface.c | 7 +- drivers/acpi/tables/tbinstal.c | 12 ++- drivers/acpi/tables/tbrsdt.c | 25 +----- drivers/acpi/tables/tbxface.c | 3 +- drivers/acpi/tables/tbxfroot.c | 106 +++++++++++++---------- drivers/acpi/utilities/utcache.c | 12 ++- drivers/acpi/utilities/utdebug.c | 169 +++++++++++++++++++++---------------- drivers/acpi/utilities/utdelete.c | 98 +++++++-------------- drivers/acpi/utilities/utglobal.c | 72 +--------------- drivers/acpi/utilities/utmisc.c | 94 +++++++++++++++++++++ drivers/acpi/utilities/utmutex.c | 10 +-- 22 files changed, 377 insertions(+), 333 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c index d7790db5017..ebc07aab710 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 c9d9a6c45ae..1b90813cbde 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 8bfa6effaa0..76c6ebd0231 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 7007abb6051..6158f5193f4 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 131f49acb1d..c1ba8b48228 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 d8b470eefe7..aaba7abcb52 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 9df0a64ba9e..0bda88d1868 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 3f94b0806ec..edbf1db36b6 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 c9f35dd7a43..d86ccbc8a13 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 f81b836e77f..64e0b2b9f55 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 decb2e9a049..095672a1a72 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 dba893648e8..5279b51e778 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 629b64c8193..2ad72f20455 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 13c6ddb2f54..069d498465d 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 0c0b9085dbe..ca2dbdd23ed 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 fe9c8317df4..abb4c934656 100644 --- a/drivers/acpi/tables/tbxfroot.c +++ b/drivers/acpi/tables/tbxfroot.c @@ -63,6 +63,51 @@ acpi_tb_scan_memory_for_rsdp ( u32 length); +/******************************************************************************* + * + * 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 @@ -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 07588812e72..c0df0585c68 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 08362f686ec..3d5fbc810b0 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 be97ada23c3..eeafb324c50 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 8653dda4f81..0e4161c8107 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -736,73 +736,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 @@ -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 207c836aec6..df715cd8910 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -50,6 +50,100 @@ ACPI_MODULE_NAME ("utmisc") +/******************************************************************************* + * + * 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) diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c index a80b97cb2e5..0699b6be62b 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); -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/executer/exdump.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index 6158f5193f4..fd13cc3db01 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 v1.2.3-18-g5258 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 --- drivers/acpi/parser/psloop.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c index 095672a1a72..edf8aa5f86c 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 v1.2.3-18-g5258 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 --- drivers/acpi/dispatcher/dsinit.c | 24 ++-- drivers/acpi/dispatcher/dsmethod.c | 34 +++--- drivers/acpi/dispatcher/dswstate.c | 4 +- drivers/acpi/events/evmisc.c | 3 + drivers/acpi/executer/exconfig.c | 19 ++- drivers/acpi/executer/exdump.c | 2 +- drivers/acpi/executer/exoparg1.c | 2 +- drivers/acpi/namespace/nsaccess.c | 13 +- drivers/acpi/namespace/nsalloc.c | 121 ++----------------- drivers/acpi/namespace/nsdump.c | 11 +- drivers/acpi/namespace/nseval.c | 10 +- drivers/acpi/namespace/nsload.c | 42 ++----- drivers/acpi/namespace/nsparse.c | 2 +- drivers/acpi/parser/psloop.c | 9 +- drivers/acpi/parser/psutils.c | 4 +- drivers/acpi/parser/psxface.c | 242 +++++++++++++++++++++---------------- drivers/acpi/tables/tbinstal.c | 22 +++- drivers/acpi/tables/tbutils.c | 67 +++++++++- drivers/acpi/tables/tbxface.c | 14 +++ drivers/acpi/tables/tbxfroot.c | 4 +- drivers/acpi/utilities/utalloc.c | 4 +- drivers/acpi/utilities/utdebug.c | 77 +++++++++--- drivers/acpi/utilities/utmisc.c | 58 ++++++--- 23 files changed, 426 insertions(+), 362 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c index ebc07aab710..bcd1d472b90 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 1b90813cbde..e344c06ed33 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 d360d8e8954..5621665991b 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 38d7ab8aef3..3df3ada4b9e 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 76c6ebd0231..d11e9ec827f 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 fd13cc3db01..4f98dceed39 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 c1ba8b48228..48c30f80008 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 0bda88d1868..7589e1fdf25 100644 --- a/drivers/acpi/namespace/nsaccess.c +++ b/drivers/acpi/namespace/nsaccess.c @@ -159,18 +159,19 @@ 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; diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c index edbf1db36b6..21d560decbf 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 d86ccbc8a13..5d25add6b03 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 1ae89a1c882..908cffd5e72 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 34e49701660..1428a84a31e 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 64e0b2b9f55..24bed931d39 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 edf8aa5f86c..551d54bdbec 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 19a27020eee..4221b41ae1a 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 5279b51e778..d1541fabaf0 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 2ad72f20455..698799901f5 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 e69d01d443d..6fc1e36e604 100644 --- a/drivers/acpi/tables/tbutils.c +++ b/drivers/acpi/tables/tbutils.c @@ -59,6 +59,67 @@ acpi_tb_handle_to_object ( #endif +/******************************************************************************* + * + * 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 @@ -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 ca2dbdd23ed..e18a05d1b9b 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 abb4c934656..87dccdda9ae 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 5061c6f0ee6..78270f50e62 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 3d5fbc810b0..c27cbb7f5c5 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); @@ -110,6 +116,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 @@ -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 df715cd8910..1d350b302a3 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; } -- cgit v1.2.3-18-g5258 From 0a637a2cec724eeb4649f6d1c07026b72c39ad84 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Tue, 19 Jul 2005 22:04:24 +0200 Subject: [SCSI] aic byteorder fixes after recent cleanup aic doesnt work anymore after this change which appeared int 2.6.13-rc1: [SCSI] aic7xxx/aic79xx: remove useless byte order macro cruft 2 files did not include byteorder.h, aic died with panic "Unknown opcode encountered in seq program" This patch fixes it for me. Signed-off-by: Olaf Hering Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aicasm/aicasm.c | 4 ++-- drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm.c b/drivers/scsi/aic7xxx/aicasm/aicasm.c index c3463948190..f936b691232 100644 --- a/drivers/scsi/aic7xxx/aicasm/aicasm.c +++ b/drivers/scsi/aic7xxx/aicasm/aicasm.c @@ -369,7 +369,7 @@ output_code() fprintf(ofile, "%s\t0x%02x, 0x%02x, 0x%02x, 0x%02x", cur_instr == STAILQ_FIRST(&seq_program) ? "" : ",\n", -#if BYTE_ORDER == LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN cur_instr->format.bytes[0], cur_instr->format.bytes[1], cur_instr->format.bytes[2], @@ -613,7 +613,7 @@ output_listing(char *ifilename) line++; } fprintf(listfile, "%03x %02x%02x%02x%02x", instrptr, -#if BYTE_ORDER == LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN cur_instr->format.bytes[0], cur_instr->format.bytes[1], cur_instr->format.bytes[2], diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h b/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h index 3e80f07df49..e64f802bbaa 100644 --- a/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h +++ b/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h @@ -42,8 +42,10 @@ * $FreeBSD$ */ +#include + struct ins_format1 { -#if BYTE_ORDER == LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN uint32_t immediate : 8, source : 9, destination : 9, @@ -61,7 +63,7 @@ struct ins_format1 { }; struct ins_format2 { -#if BYTE_ORDER == LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN uint32_t shift_control : 8, source : 9, destination : 9, @@ -79,7 +81,7 @@ struct ins_format2 { }; struct ins_format3 { -#if BYTE_ORDER == LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN uint32_t immediate : 8, source : 9, address : 10, -- cgit v1.2.3-18-g5258 From 5dbffcd83d826a9b42a10afb89b13156dc5b9539 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 27 Jul 2005 01:07:42 -0700 Subject: [SCSI] git-scsi-misc: drivers/scsi/ch.c: remove devfs stuff It seems very unlikely that this driver will go into any stable kernel before devfs will be removed. Signed-off-by: Adrian Bunk Cc: James Bottomley Signed-off-by: Andrew Morton Signed-off-by: James Bottomley --- drivers/scsi/ch.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 3900e28ac7d..53b39553431 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include /* here are all the ioctls */ @@ -940,8 +939,6 @@ static int ch_probe(struct device *dev) if (init) ch_init_elem(ch); - devfs_mk_cdev(MKDEV(SCSI_CHANGER_MAJOR,ch->minor), - S_IFCHR | S_IRUGO | S_IWUGO, ch->name); class_device_create(ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR,ch->minor), dev, "s%s", ch->name); @@ -974,7 +971,6 @@ static int ch_remove(struct device *dev) class_device_destroy(ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR,ch->minor)); - devfs_remove(ch->name); kfree(ch->dt); kfree(ch); ch_devcount--; -- cgit v1.2.3-18-g5258 From d3301874083874f8a0ac88aa1bb7da6b62df34d2 Mon Sep 17 00:00:00 2001 From: Mike Anderson Date: Thu, 16 Jun 2005 11:12:38 -0700 Subject: [SCSI] host state model update: replace old host bitmap state Migrate the current SCSI host state model to a model like SCSI device is using. Signed-off-by: Mike Anderson Rejections fixed up and Signed-off-by: James Bottomley --- drivers/scsi/hosts.c | 88 +++++++++++++++++++++++++++++++++++++++++++---- drivers/scsi/scsi.c | 2 +- drivers/scsi/scsi_error.c | 7 ++-- drivers/scsi/scsi_ioctl.c | 3 +- drivers/scsi/scsi_lib.c | 4 +-- drivers/scsi/scsi_sysfs.c | 62 +++++++++++++++++++++++++++++++++ drivers/scsi/sg.c | 3 +- 7 files changed, 153 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 5feb886c339..6828ca305c2 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -51,6 +51,82 @@ static struct class shost_class = { .release = scsi_host_cls_release, }; +/** + * scsi_host_set_state - Take the given host through the host + * state model. + * @shost: scsi host to change the state of. + * @state: state to change to. + * + * Returns zero if unsuccessful or an error if the requested + * transition is illegal. + **/ +int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state) +{ + enum scsi_host_state oldstate = shost->shost_state; + + if (state == oldstate) + return 0; + + switch (state) { + case SHOST_CREATED: + /* There are no legal states that come back to + * created. This is the manually initialised start + * state */ + goto illegal; + + case SHOST_RUNNING: + switch (oldstate) { + case SHOST_CREATED: + case SHOST_RECOVERY: + break; + default: + goto illegal; + } + break; + + case SHOST_RECOVERY: + switch (oldstate) { + case SHOST_RUNNING: + break; + default: + goto illegal; + } + break; + + case SHOST_CANCEL: + switch (oldstate) { + case SHOST_CREATED: + case SHOST_RUNNING: + break; + default: + goto illegal; + } + break; + + case SHOST_DEL: + switch (oldstate) { + case SHOST_CANCEL: + break; + default: + goto illegal; + } + break; + + } + shost->shost_state = state; + return 0; + + illegal: + SCSI_LOG_ERROR_RECOVERY(1, + dev_printk(KERN_ERR, &shost->shost_gendev, + "Illegal host state transition" + "%s->%s\n", + scsi_host_state_name(oldstate), + scsi_host_state_name(state))); + return -EINVAL; +} +EXPORT_SYMBOL(scsi_host_set_state); + /** * scsi_host_cancel - cancel outstanding IO to this host * @shost: pointer to struct Scsi_Host @@ -60,12 +136,11 @@ static void scsi_host_cancel(struct Scsi_Host *shost, int recovery) { struct scsi_device *sdev; - set_bit(SHOST_CANCEL, &shost->shost_state); + scsi_host_set_state(shost, SHOST_CANCEL); shost_for_each_device(sdev, shost) { scsi_device_cancel(sdev, recovery); } - wait_event(shost->host_wait, (!test_bit(SHOST_RECOVERY, - &shost->shost_state))); + wait_event(shost->host_wait, (shost->shost_state != SHOST_RECOVERY)); } /** @@ -78,7 +153,7 @@ void scsi_remove_host(struct Scsi_Host *shost) scsi_host_cancel(shost, 0); scsi_proc_host_rm(shost); - set_bit(SHOST_DEL, &shost->shost_state); + scsi_host_set_state(shost, SHOST_DEL); transport_unregister_device(&shost->shost_gendev); class_device_unregister(&shost->shost_classdev); @@ -115,7 +190,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev) if (error) goto out; - set_bit(SHOST_ADD, &shost->shost_state); + scsi_host_set_state(shost, SHOST_RUNNING); get_device(shost->shost_gendev.parent); error = class_device_add(&shost->shost_classdev); @@ -226,6 +301,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) spin_lock_init(&shost->default_lock); scsi_assign_lock(shost, &shost->default_lock); + shost->shost_state = SHOST_CREATED; INIT_LIST_HEAD(&shost->__devices); INIT_LIST_HEAD(&shost->__targets); INIT_LIST_HEAD(&shost->eh_cmd_q); @@ -382,7 +458,7 @@ EXPORT_SYMBOL(scsi_host_lookup); **/ struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost) { - if (test_bit(SHOST_DEL, &shost->shost_state) || + if ((shost->shost_state == SHOST_DEL) || !get_device(&shost->shost_gendev)) return NULL; return shost; diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index d14523d7e44..fb85b3ced7b 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -627,7 +627,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) spin_lock_irqsave(host->host_lock, flags); scsi_cmd_get_serial(host, cmd); - if (unlikely(test_bit(SHOST_CANCEL, &host->shost_state))) { + if (unlikely(host->shost_state == SHOST_CANCEL)) { cmd->result = (DID_NO_CONNECT << 16); scsi_done(cmd); } else { diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 0fc8b48f052..e9c451ba71f 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -75,7 +75,7 @@ int scsi_eh_scmd_add(struct scsi_cmnd *scmd, int eh_flag) scmd->eh_eflags |= eh_flag; list_add_tail(&scmd->eh_entry, &shost->eh_cmd_q); - set_bit(SHOST_RECOVERY, &shost->shost_state); + scsi_host_set_state(shost, SHOST_RECOVERY); shost->host_failed++; scsi_eh_wakeup(shost); spin_unlock_irqrestore(shost->host_lock, flags); @@ -197,7 +197,8 @@ int scsi_block_when_processing_errors(struct scsi_device *sdev) { int online; - wait_event(sdev->host->host_wait, (!test_bit(SHOST_RECOVERY, &sdev->host->shost_state))); + wait_event(sdev->host->host_wait, (sdev->host->shost_state != + SHOST_RECOVERY)); online = scsi_device_online(sdev); @@ -1458,7 +1459,7 @@ static void scsi_restart_operations(struct Scsi_Host *shost) SCSI_LOG_ERROR_RECOVERY(3, printk("%s: waking up host to restart\n", __FUNCTION__)); - clear_bit(SHOST_RECOVERY, &shost->shost_state); + scsi_host_set_state(shost, SHOST_RUNNING); wake_up(&shost->host_wait); diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 7a6b530115a..f5bf5c07be9 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -475,8 +475,7 @@ int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd, * error processing, as long as the device was opened * non-blocking */ if (filp && filp->f_flags & O_NONBLOCK) { - if (test_bit(SHOST_RECOVERY, - &sdev->host->shost_state)) + if (sdev->host->shost_state == SHOST_RECOVERY) return -ENODEV; } else if (!scsi_block_when_processing_errors(sdev)) return -ENODEV; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 7a91ca3d32a..060010bccab 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -348,7 +348,7 @@ void scsi_device_unbusy(struct scsi_device *sdev) spin_lock_irqsave(shost->host_lock, flags); shost->host_busy--; - if (unlikely(test_bit(SHOST_RECOVERY, &shost->shost_state) && + if (unlikely((shost->shost_state == SHOST_RECOVERY) && shost->host_failed)) scsi_eh_wakeup(shost); spin_unlock(shost->host_lock); @@ -1207,7 +1207,7 @@ static inline int scsi_host_queue_ready(struct request_queue *q, struct Scsi_Host *shost, struct scsi_device *sdev) { - if (test_bit(SHOST_RECOVERY, &shost->shost_state)) + if (shost->shost_state == SHOST_RECOVERY) return 0; if (shost->host_busy == 0 && shost->host_blocked) { /* diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index beed7fbe1cb..dae59d1da07 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -48,6 +48,30 @@ const char *scsi_device_state_name(enum scsi_device_state state) return name; } +static struct { + enum scsi_host_state value; + char *name; +} shost_states[] = { + { SHOST_CREATED, "created" }, + { SHOST_RUNNING, "running" }, + { SHOST_CANCEL, "cancel" }, + { SHOST_DEL, "deleted" }, + { SHOST_RECOVERY, "recovery" }, +}; +const char *scsi_host_state_name(enum scsi_host_state state) +{ + int i; + char *name = NULL; + + for (i = 0; i < sizeof(shost_states)/sizeof(shost_states[0]); i++) { + if (shost_states[i].value == state) { + name = shost_states[i].name; + break; + } + } + return name; +} + static int check_set(unsigned int *val, char *src) { char *last; @@ -124,6 +148,43 @@ static ssize_t store_scan(struct class_device *class_dev, const char *buf, }; static CLASS_DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan); +static ssize_t +store_shost_state(struct class_device *class_dev, const char *buf, size_t count) +{ + int i; + struct Scsi_Host *shost = class_to_shost(class_dev); + enum scsi_host_state state = 0; + + for (i = 0; i < sizeof(shost_states)/sizeof(shost_states[0]); i++) { + const int len = strlen(shost_states[i].name); + if (strncmp(shost_states[i].name, buf, len) == 0 && + buf[len] == '\n') { + state = shost_states[i].value; + break; + } + } + if (!state) + return -EINVAL; + + if (scsi_host_set_state(shost, state)) + return -EINVAL; + return count; +} + +static ssize_t +show_shost_state(struct class_device *class_dev, char *buf) +{ + struct Scsi_Host *shost = class_to_shost(class_dev); + const char *name = scsi_host_state_name(shost->shost_state); + + if (!name) + return -EINVAL; + + return snprintf(buf, 20, "%s\n", name); +} + +static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); + shost_rd_attr(unique_id, "%u\n"); shost_rd_attr(host_busy, "%hu\n"); shost_rd_attr(cmd_per_lun, "%hd\n"); @@ -139,6 +200,7 @@ static struct class_device_attribute *scsi_sysfs_shost_attrs[] = { &class_device_attr_unchecked_isa_dma, &class_device_attr_proc_name, &class_device_attr_scan, + &class_device_attr_state, NULL }; diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 51292f269ce..14fb179b384 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1027,8 +1027,7 @@ sg_ioctl(struct inode *inode, struct file *filp, if (sdp->detached) return -ENODEV; if (filp->f_flags & O_NONBLOCK) { - if (test_bit(SHOST_RECOVERY, - &sdp->device->host->shost_state)) + if (sdp->device->host->shost_state == SHOST_RECOVERY) return -EBUSY; } else if (!scsi_block_when_processing_errors(sdp->device)) return -EBUSY; -- cgit v1.2.3-18-g5258 From d2c9d9eafa03dbd08a8a439e6c5addb8b1f03b9b Mon Sep 17 00:00:00 2001 From: Mike Anderson Date: Thu, 16 Jun 2005 11:13:42 -0700 Subject: [SCSI] host state model update: reimplement scsi_host_cancel Remove the old scsi_host_cancel function as it has not been working for sometime do to the device list possibly being empty when it is called and possible race issues. Add setting of SHOST_CANCEL at the state of beginning of scsi_remove_host. Signed-off-by: Mike Anderson Signed-off-by: James Bottomley --- drivers/scsi/hosts.c | 18 +----------------- drivers/scsi/scsi.c | 2 +- 2 files changed, 2 insertions(+), 18 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 6828ca305c2..67c4c0c3aa5 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -127,30 +127,14 @@ int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state) } EXPORT_SYMBOL(scsi_host_set_state); -/** - * scsi_host_cancel - cancel outstanding IO to this host - * @shost: pointer to struct Scsi_Host - * recovery: recovery requested to run. - **/ -static void scsi_host_cancel(struct Scsi_Host *shost, int recovery) -{ - struct scsi_device *sdev; - - scsi_host_set_state(shost, SHOST_CANCEL); - shost_for_each_device(sdev, shost) { - scsi_device_cancel(sdev, recovery); - } - wait_event(shost->host_wait, (shost->shost_state != SHOST_RECOVERY)); -} - /** * scsi_remove_host - remove a scsi host * @shost: a pointer to a scsi host to remove **/ void scsi_remove_host(struct Scsi_Host *shost) { + scsi_host_set_state(shost, SHOST_CANCEL); scsi_forget_host(shost); - scsi_host_cancel(shost, 0); scsi_proc_host_rm(shost); scsi_host_set_state(shost, SHOST_DEL); diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index fb85b3ced7b..d1aa95d45a7 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -627,7 +627,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) spin_lock_irqsave(host->host_lock, flags); scsi_cmd_get_serial(host, cmd); - if (unlikely(host->shost_state == SHOST_CANCEL)) { + if (unlikely(host->shost_state == SHOST_DEL)) { cmd->result = (DID_NO_CONNECT << 16); scsi_done(cmd); } else { -- cgit v1.2.3-18-g5258 From 82f29467a025f6a2192d281e97fca0be46e905cc Mon Sep 17 00:00:00 2001 From: Mike Anderson Date: Thu, 16 Jun 2005 11:14:33 -0700 Subject: [SCSI] host state model update: mediate host add/remove race Add support to not allow additions to a host when it is being removed. Signed-off-by: Mike Anderson Signed-off-by: James Bottomley --- drivers/scsi/hosts.c | 2 ++ drivers/scsi/scsi_scan.c | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 67c4c0c3aa5..8640ad1c17e 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -133,7 +133,9 @@ EXPORT_SYMBOL(scsi_host_set_state); **/ void scsi_remove_host(struct Scsi_Host *shost) { + down(&shost->scan_mutex); scsi_host_set_state(shost, SHOST_CANCEL); + up(&shost->scan_mutex); scsi_forget_host(shost); scsi_proc_host_rm(shost); diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 2d3c4ac475f..076cbe3b5a0 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1251,9 +1251,12 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, get_device(&starget->dev); down(&shost->scan_mutex); - res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); - if (res != SCSI_SCAN_LUN_PRESENT) - sdev = ERR_PTR(-ENODEV); + if (scsi_host_scan_allowed(shost)) { + res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, + hostdata); + if (res != SCSI_SCAN_LUN_PRESENT) + sdev = ERR_PTR(-ENODEV); + } up(&shost->scan_mutex); scsi_target_reap(starget); put_device(&starget->dev); @@ -1403,11 +1406,15 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel, return -EINVAL; down(&shost->scan_mutex); - if (channel == SCAN_WILD_CARD) - for (channel = 0; channel <= shost->max_channel; channel++) + if (scsi_host_scan_allowed(shost)) { + if (channel == SCAN_WILD_CARD) + for (channel = 0; channel <= shost->max_channel; + channel++) + scsi_scan_channel(shost, channel, id, lun, + rescan); + else scsi_scan_channel(shost, channel, id, lun, rescan); - else - scsi_scan_channel(shost, channel, id, lun, rescan); + } up(&shost->scan_mutex); return 0; -- cgit v1.2.3-18-g5258 From a6c42741ace2fee235b6902e76f3c86a01d32146 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 4 Jul 2005 17:48:13 +0200 Subject: [SCSI] qla1280: remove dead per-host flag variables Signed-off-by: Christoph Hellwig Signed-off-by: Thiemo Seufer Signed-off-by: James Bottomley --- drivers/scsi/qla1280.c | 7 ------- drivers/scsi/qla1280.h | 4 ---- 2 files changed, 11 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index b993652bfa2..eb5543ef513 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -996,7 +996,6 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action) break; case ABORT_DEVICE: - ha->flags.in_reset = 1; if (qla1280_verbose) printk(KERN_INFO "scsi(%ld:%d:%d:%d): Queueing abort device " @@ -1010,7 +1009,6 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action) printk(KERN_INFO "scsi(%ld:%d:%d:%d): Queueing device reset " "command.\n", ha->host_no, bus, target, lun); - ha->flags.in_reset = 1; if (qla1280_device_reset(ha, bus, target) == 0) result = SUCCESS; break; @@ -1019,7 +1017,6 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action) if (qla1280_verbose) printk(KERN_INFO "qla1280(%ld:%d): Issuing BUS " "DEVICE RESET\n", ha->host_no, bus); - ha->flags.in_reset = 1; if (qla1280_bus_reset(ha, bus == 0)) result = SUCCESS; @@ -1047,7 +1044,6 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action) if (!list_empty(&ha->done_q)) qla1280_done(ha); - ha->flags.in_reset = 0; /* If we didn't manage to issue the action, or we have no * command to wait for, exit here */ @@ -1636,7 +1632,6 @@ qla1280_enable_intrs(struct scsi_qla_host *ha) /* enable risc and host interrupts */ WRT_REG_WORD(®->ictrl, (ISP_EN_INT | ISP_EN_RISC)); RD_REG_WORD(®->ictrl); /* PCI Posted Write flush */ - ha->flags.ints_enabled = 1; } static inline void @@ -1648,7 +1643,6 @@ qla1280_disable_intrs(struct scsi_qla_host *ha) /* disable risc and host interrupts */ WRT_REG_WORD(®->ictrl, 0); RD_REG_WORD(®->ictrl); /* PCI Posted Write flush */ - ha->flags.ints_enabled = 0; } /* @@ -1679,7 +1673,6 @@ qla1280_initialize_adapter(struct scsi_qla_host *ha) ha->flags.reset_active = 0; ha->flags.abort_isp_active = 0; - ha->flags.ints_enabled = 0; #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) if (ia64_platform_is("sn2")) { printk(KERN_INFO "scsi(%li): Enabling SN2 PCI DMA " diff --git a/drivers/scsi/qla1280.h b/drivers/scsi/qla1280.h index d245ae07518..1c1cf3a5af0 100644 --- a/drivers/scsi/qla1280.h +++ b/drivers/scsi/qla1280.h @@ -1082,10 +1082,6 @@ struct scsi_qla_host { uint32_t reset_active:1; /* 3 */ uint32_t abort_isp_active:1; /* 4 */ uint32_t disable_risc_code_load:1; /* 5 */ - uint32_t enable_64bit_addressing:1; /* 6 */ - uint32_t in_reset:1; /* 7 */ - uint32_t ints_enabled:1; - uint32_t ignore_nvram:1; #ifdef __ia64__ uint32_t use_pci_vchannel:1; #endif -- cgit v1.2.3-18-g5258 From 8af50dcd22aa0a5840f18276ff10a6977abc3853 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 4 Jul 2005 17:48:19 +0200 Subject: [SCSI] qla1280: interupt posting for irq disabling/enabling Signed-off-by: Christoph Hellwig Signed-off-by: Thiemo Seufer Signed-off-by: James Bottomley --- drivers/scsi/qla1280.c | 57 ++++++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 37 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index eb5543ef513..58ecdc69667 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -1265,6 +1265,22 @@ qla1280_biosparam_old(Disk * disk, kdev_t dev, int geom[]) return qla1280_biosparam(disk->device, NULL, disk->capacity, geom); } #endif + +/* disable risc and host interrupts */ +static inline void +qla1280_disable_intrs(struct scsi_qla_host *ha) +{ + WRT_REG_WORD(&ha->iobase->ictrl, 0); + RD_REG_WORD(&ha->iobase->ictrl); /* PCI Posted Write flush */ +} + +/* enable risc and host interrupts */ +static inline void +qla1280_enable_intrs(struct scsi_qla_host *ha) +{ + WRT_REG_WORD(&ha->iobase->ictrl, (ISP_EN_INT | ISP_EN_RISC)); + RD_REG_WORD(&ha->iobase->ictrl); /* PCI Posted Write flush */ +} /************************************************************************** * qla1280_intr_handler @@ -1286,7 +1302,7 @@ qla1280_intr_handler(int irq, void *dev_id, struct pt_regs *regs) ha->isr_count++; reg = ha->iobase; - WRT_REG_WORD(®->ictrl, 0); /* disable our interrupt. */ + qla1280_disable_intrs(ha); data = qla1280_debounce_register(®->istatus); /* Check for pending interrupts. */ @@ -1299,8 +1315,7 @@ qla1280_intr_handler(int irq, void *dev_id, struct pt_regs *regs) spin_unlock(HOST_LOCK); - /* enable our interrupt. */ - WRT_REG_WORD(®->ictrl, (ISP_EN_INT | ISP_EN_RISC)); + qla1280_enable_intrs(ha); LEAVE_INTR("qla1280_intr_handler"); return IRQ_RETVAL(handled); @@ -1613,38 +1628,6 @@ qla1280_return_status(struct response * sts, struct scsi_cmnd *cp) /* QLogic ISP1280 Hardware Support Functions. */ /****************************************************************************/ - /* - * qla2100_enable_intrs - * qla2100_disable_intrs - * - * Input: - * ha = adapter block pointer. - * - * Returns: - * None - */ -static inline void -qla1280_enable_intrs(struct scsi_qla_host *ha) -{ - struct device_reg __iomem *reg; - - reg = ha->iobase; - /* enable risc and host interrupts */ - WRT_REG_WORD(®->ictrl, (ISP_EN_INT | ISP_EN_RISC)); - RD_REG_WORD(®->ictrl); /* PCI Posted Write flush */ -} - -static inline void -qla1280_disable_intrs(struct scsi_qla_host *ha) -{ - struct device_reg __iomem *reg; - - reg = ha->iobase; - /* disable risc and host interrupts */ - WRT_REG_WORD(®->ictrl, 0); - RD_REG_WORD(®->ictrl); /* PCI Posted Write flush */ -} - /* * qla1280_initialize_adapter * Initialize board. @@ -4751,7 +4734,7 @@ qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) #if LINUX_VERSION_CODE >= 0x020600 error_disable_adapter: - WRT_REG_WORD(&ha->iobase->ictrl, 0); + qla1280_disable_intrs(ha); #endif error_free_irq: free_irq(pdev->irq, ha); @@ -4788,7 +4771,7 @@ qla1280_remove_one(struct pci_dev *pdev) scsi_remove_host(host); #endif - WRT_REG_WORD(&ha->iobase->ictrl, 0); + qla1280_disable_intrs(ha); free_irq(pdev->irq, ha); -- cgit v1.2.3-18-g5258 From 2b55cac3d2d9f545c141748d00eae86e2c042ca5 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 4 Jul 2005 17:48:30 +0200 Subject: [SCSI] qla1280: misc cleanups print message tidy ups and some excess brace removal. Signed-off-by: Christoph Hellwig Signed-off-by: Thiemo Seufer Signed-off-by: James Bottomley --- drivers/scsi/qla1280.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 58ecdc69667..e5354550d76 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -1459,7 +1459,6 @@ qla1280_select_queue_depth(struct Scsi_Host *host, struct scsi_device *sdev_q) * * Input: * ha = adapter block pointer. - * done_q = done queue. */ static void qla1280_done(struct scsi_qla_host *ha) @@ -1593,7 +1592,7 @@ qla1280_return_status(struct response * sts, struct scsi_cmnd *cp) case CS_DATA_OVERRUN: dprintk(2, "Data overrun 0x%x\n", residual_length); - dprintk(2, "qla1280_isr: response packet data\n"); + dprintk(2, "qla1280_return_status: response packet data\n"); qla1280_dump_buffer(2, (char *)sts, RESPONSE_ENTRY_SIZE); host_status = DID_ERROR; break; @@ -2061,7 +2060,7 @@ qla1280_start_firmware(struct scsi_qla_host *ha) mb[1] = *ql1280_board_tbl[ha->devnum].fwstart; err = qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); if (err) { - printk(KERN_ERR "scsi(%li): Failed checksum\n", ha->host_no); + printk(KERN_ERR "scsi(%li): RISC checksum failed.\n", ha->host_no); return err; } @@ -3080,10 +3079,13 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt); } + dprintk(3, "Number of free entries=(%d) seg_cnt=0x%x\n", + ha->req_q_cnt, seg_cnt); + /* If room for request in request ring. */ if ((req_cnt + 2) >= ha->req_q_cnt) { status = 1; - dprintk(2, "qla1280_64bit_start_scsi: in-ptr=0x%x req_q_cnt=" + dprintk(2, "qla1280_start_scsi: in-ptr=0x%x req_q_cnt=" "0x%xreq_cnt=0x%x", ha->req_ring_index, ha->req_q_cnt, req_cnt); goto out; @@ -3095,7 +3097,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) if (cnt >= MAX_OUTSTANDING_COMMANDS) { status = 1; - dprintk(2, "qla1280_64bit_start_scsi: NO ROOM IN " + dprintk(2, "qla1280_start_scsi: NO ROOM IN " "OUTSTANDING ARRAY, req_q_cnt=0x%x", ha->req_q_cnt); goto out; } @@ -3104,7 +3106,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) ha->req_q_cnt -= req_cnt; CMD_HANDLE(sp->cmd) = (unsigned char *)(unsigned long)(cnt + 1); - dprintk(2, "64bit_start: cmd=%p sp=%p CDB=%xm, handle %lx\n", cmd, sp, + dprintk(2, "start: cmd=%p sp=%p CDB=%xm, handle %lx\n", cmd, sp, cmd->cmnd[0], (long)CMD_HANDLE(sp->cmd)); dprintk(2, " bus %i, target %i, lun %i\n", SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), SCSI_LUN_32(cmd)); @@ -4626,7 +4628,7 @@ qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) if (pci_set_dma_mask(ha->pdev, (dma_addr_t) ~ 0ULL)) { if (pci_set_dma_mask(ha->pdev, 0xffffffff)) { printk(KERN_WARNING "scsi(%li): Unable to set a " - " suitable DMA mask - aboring\n", ha->host_no); + "suitable DMA mask - aborting\n", ha->host_no); error = -ENODEV; goto error_free_irq; } @@ -4636,14 +4638,14 @@ qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) #else if (pci_set_dma_mask(ha->pdev, 0xffffffff)) { printk(KERN_WARNING "scsi(%li): Unable to set a " - " suitable DMA mask - aboring\n", ha->host_no); + "suitable DMA mask - aborting\n", ha->host_no); error = -ENODEV; goto error_free_irq; } #endif ha->request_ring = pci_alloc_consistent(ha->pdev, - ((REQUEST_ENTRY_CNT + 1) * (sizeof(request_t))), + ((REQUEST_ENTRY_CNT + 1) * sizeof(request_t)), &ha->request_dma); if (!ha->request_ring) { printk(KERN_INFO "qla1280: Failed to get request memory\n"); @@ -4651,7 +4653,7 @@ qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) } ha->response_ring = pci_alloc_consistent(ha->pdev, - ((RESPONSE_ENTRY_CNT + 1) * (sizeof(struct response))), + ((RESPONSE_ENTRY_CNT + 1) * sizeof(struct response)), &ha->response_dma); if (!ha->response_ring) { printk(KERN_INFO "qla1280: Failed to get response memory\n"); @@ -4746,11 +4748,11 @@ qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) #endif error_free_response_ring: pci_free_consistent(ha->pdev, - ((RESPONSE_ENTRY_CNT + 1) * (sizeof(struct response))), + ((RESPONSE_ENTRY_CNT + 1) * sizeof(struct response)), ha->response_ring, ha->response_dma); error_free_request_ring: pci_free_consistent(ha->pdev, - ((REQUEST_ENTRY_CNT + 1) * (sizeof(request_t))), + ((REQUEST_ENTRY_CNT + 1) * sizeof(request_t)), ha->request_ring, ha->request_dma); error_put_host: scsi_host_put(host); -- cgit v1.2.3-18-g5258 From d6db3e8d5fe3178776d0a0314e612c3f55e55fb4 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 4 Jul 2005 17:48:36 +0200 Subject: [SCSI] qla1280: use SAM_ constants Signed-off-by: Christoph Hellwig Signed-off-by: Thiemo Seufer Signed-off-by: James Bottomley --- drivers/scsi/qla1280.c | 2 +- drivers/scsi/qla1280.h | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index e5354550d76..3732230b2e3 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -4049,7 +4049,7 @@ qla1280_status_entry(struct scsi_qla_host *ha, struct response *pkt, /* Save ISP completion status */ CMD_RESULT(cmd) = qla1280_return_status(pkt, cmd); - if (scsi_status & SS_CHECK_CONDITION) { + if (scsi_status & SAM_STAT_CHECK_CONDITION) { if (comp_status != CS_ARS_FAILED) { uint16_t req_sense_length = le16_to_cpu(pkt->req_sense_length); diff --git a/drivers/scsi/qla1280.h b/drivers/scsi/qla1280.h index 1c1cf3a5af0..0d430d63be4 100644 --- a/drivers/scsi/qla1280.h +++ b/drivers/scsi/qla1280.h @@ -978,14 +978,6 @@ struct ctio_a64_ret_entry { #define CS_UNKNOWN 0x81 /* Driver defined */ #define CS_RETRY 0x82 /* Driver defined */ -/* - * ISP status entry - SCSI status byte bit definitions. - */ -#define SS_CHECK_CONDITION BIT_1 -#define SS_CONDITION_MET BIT_2 -#define SS_BUSY_CONDITION BIT_3 -#define SS_RESERVE_CONFLICT (BIT_4 | BIT_3) - /* * ISP target entries - Option flags bit definitions. */ -- cgit v1.2.3-18-g5258 From 748422d92a55faadf3184e5aa8487da88c1ee849 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 4 Jul 2005 17:48:41 +0200 Subject: [SCSI] qla1280: remove SG_SEGMENTS Signed-off-by: Christoph Hellwig Signed-off-by: Thiemo Seufer Signed-off-by: James Bottomley --- drivers/scsi/qla1280.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla1280.h b/drivers/scsi/qla1280.h index 0d430d63be4..18c20cf371a 100644 --- a/drivers/scsi/qla1280.h +++ b/drivers/scsi/qla1280.h @@ -94,9 +94,6 @@ #define REQUEST_ENTRY_CNT 256 /* Number of request entries. */ #define RESPONSE_ENTRY_CNT 16 /* Number of response entries. */ -/* Number of segments 1 - 65535 */ -#define SG_SEGMENTS 32 /* Cmd entry + 6 continuations */ - /* * SCSI Request Block structure (sp) that is placed * on cmd->SCp location of every I/O -- cgit v1.2.3-18-g5258 From 5c79d6154f335543ea4c4a555f645a1f76b5d117 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 4 Jul 2005 17:48:46 +0200 Subject: [SCSI] qla1280: always load microcode we have the most recent microcode, make sure to always load it. Signed-off-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/qla1280.c | 72 +------------------------------------------------- 1 file changed, 1 insertion(+), 71 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 3732230b2e3..9f975f7c1ea 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -1733,69 +1733,6 @@ qla1280_initialize_adapter(struct scsi_qla_host *ha) return status; } - -/* - * ISP Firmware Test - * Checks if present version of RISC firmware is older than - * driver firmware. - * - * Input: - * ha = adapter block pointer. - * - * Returns: - * 0 = firmware does not need to be loaded. - */ -static int -qla1280_isp_firmware(struct scsi_qla_host *ha) -{ - struct nvram *nv = (struct nvram *) ha->response_ring; - int status = 0; /* dg 2/27 always loads RISC */ - uint16_t mb[MAILBOX_REGISTER_COUNT]; - - ENTER("qla1280_isp_firmware"); - - dprintk(1, "scsi(%li): Determining if RISC is loaded\n", ha->host_no); - - /* Bad NVRAM data, load RISC code. */ - if (!ha->nvram_valid) { - ha->flags.disable_risc_code_load = 0; - } else - ha->flags.disable_risc_code_load = - nv->cntr_flags_1.disable_loading_risc_code; - - if (ha->flags.disable_risc_code_load) { - dprintk(3, "qla1280_isp_firmware: Telling RISC to verify " - "checksum of loaded BIOS code.\n"); - - /* Verify checksum of loaded RISC code. */ - mb[0] = MBC_VERIFY_CHECKSUM; - /* mb[1] = ql12_risc_code_addr01; */ - mb[1] = *ql1280_board_tbl[ha->devnum].fwstart; - - if (!(status = - qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]))) { - /* Start firmware execution. */ - dprintk(3, "qla1280_isp_firmware: Startng F/W " - "execution.\n"); - - mb[0] = MBC_EXECUTE_FIRMWARE; - /* mb[1] = ql12_risc_code_addr01; */ - mb[1] = *ql1280_board_tbl[ha->devnum].fwstart; - qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]); - } else - printk(KERN_INFO "qla1280: RISC checksum failed.\n"); - } else { - dprintk(1, "qla1280: NVRAM configured to load RISC load.\n"); - status = 1; - } - - if (status) - dprintk(2, "qla1280_isp_firmware: **** Load RISC code ****\n"); - - LEAVE("qla1280_isp_firmware"); - return status; -} - /* * Chip diagnostics * Test chip for proper operation. @@ -2080,14 +2017,7 @@ qla1280_start_firmware(struct scsi_qla_host *ha) static int qla1280_load_firmware(struct scsi_qla_host *ha) { - int err = -ENODEV; - - /* If firmware needs to be loaded */ - if (!qla1280_isp_firmware(ha)) { - printk(KERN_ERR "scsi(%li): isp_firmware() failed!\n", - ha->host_no); - goto out; - } + int err; err = qla1280_chip_diag(ha); if (err) -- cgit v1.2.3-18-g5258 From 0888f4c3312847eec4814a6d7cdcaaaa9fbd3345 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 4 Jul 2005 17:48:55 +0200 Subject: [SCSI] qla1280: don't use bitfields for hardware access in isp_config Signed-off-by: Christoph Hellwig Signed-off-by: Thiemo Seufer Signed-off-by: James Bottomley --- drivers/scsi/qla1280.c | 44 +++++++++++++++++++++++++++++--------------- drivers/scsi/qla1280.h | 30 ++++++++++++------------------ 2 files changed, 41 insertions(+), 33 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 9f975f7c1ea..1a8b1147821 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -2189,9 +2189,9 @@ qla1280_set_defaults(struct scsi_qla_host *ha) /* nv->cntr_flags_1.disable_loading_risc_code = 1; */ nv->firmware_feature.f.enable_fast_posting = 1; nv->firmware_feature.f.disable_synchronous_backoff = 1; - nv->termination.f.scsi_bus_0_control = 3; - nv->termination.f.scsi_bus_1_control = 3; - nv->termination.f.auto_term_support = 1; + nv->termination.scsi_bus_0_control = 3; + nv->termination.scsi_bus_1_control = 3; + nv->termination.auto_term_support = 1; /* * Set default FIFO magic - What appropriate values would be here @@ -2201,7 +2201,12 @@ qla1280_set_defaults(struct scsi_qla_host *ha) * header file provided by QLogic seems to be bogus or incomplete * at best. */ - nv->isp_config.c = ISP_CFG1_BENAB|ISP_CFG1_F128; + nv->isp_config.burst_enable = 1; + if (IS_ISP1040(ha)) + nv->isp_config.fifo_threshold |= 3; + else + nv->isp_config.fifo_threshold |= 4; + if (IS_ISP1x160(ha)) nv->isp_parameter = 0x01; /* fast memory enable */ @@ -2362,31 +2367,40 @@ qla1280_nvram_config(struct scsi_qla_host *ha) hwrev = RD_REG_WORD(®->cfg_0) & ISP_CFG0_HWMSK; - cfg1 = RD_REG_WORD(®->cfg_1); + cfg1 = RD_REG_WORD(®->cfg_1) & ~(BIT_4 | BIT_5 | BIT_6); cdma_conf = RD_REG_WORD(®->cdma_cfg); ddma_conf = RD_REG_WORD(®->ddma_cfg); /* Busted fifo, says mjacob. */ - if (hwrev == ISP_CFG0_1040A) - WRT_REG_WORD(®->cfg_1, cfg1 | ISP_CFG1_F64); - else - WRT_REG_WORD(®->cfg_1, cfg1 | ISP_CFG1_F64 | ISP_CFG1_BENAB); + if (hwrev != ISP_CFG0_1040A) + cfg1 |= nv->isp_config.fifo_threshold << 4; + + cfg1 |= nv->isp_config.burst_enable << 2; + WRT_REG_WORD(®->cfg_1, cfg1); WRT_REG_WORD(®->cdma_cfg, cdma_conf | CDMA_CONF_BENAB); WRT_REG_WORD(®->ddma_cfg, cdma_conf | DDMA_CONF_BENAB); } else { + uint16_t cfg1, term; + /* Set ISP hardware DMA burst */ - mb[0] = nv->isp_config.c; + cfg1 = nv->isp_config.fifo_threshold << 4; + cfg1 |= nv->isp_config.burst_enable << 2; /* Enable DMA arbitration on dual channel controllers */ if (ha->ports > 1) - mb[0] |= BIT_13; - WRT_REG_WORD(®->cfg_1, mb[0]); + cfg1 |= BIT_13; + WRT_REG_WORD(®->cfg_1, cfg1); /* Set SCSI termination. */ - WRT_REG_WORD(®->gpio_enable, (BIT_3 + BIT_2 + BIT_1 + BIT_0)); - mb[0] = nv->termination.c & (BIT_3 + BIT_2 + BIT_1 + BIT_0); - WRT_REG_WORD(®->gpio_data, mb[0]); + WRT_REG_WORD(®->gpio_enable, + BIT_7 | BIT_3 | BIT_2 | BIT_1 | BIT_0); + term = nv->termination.scsi_bus_1_control; + term |= nv->termination.scsi_bus_0_control << 2; + term |= nv->termination.auto_term_support << 7; + RD_REG_WORD(®->id_l); /* Flush PCI write */ + WRT_REG_WORD(®->gpio_data, term); } + RD_REG_WORD(®->id_l); /* Flush PCI write */ /* ISP parameter word. */ mb[0] = MBC_SET_SYSTEM_PARAMETER; diff --git a/drivers/scsi/qla1280.h b/drivers/scsi/qla1280.h index 18c20cf371a..4032ea3f2b9 100644 --- a/drivers/scsi/qla1280.h +++ b/drivers/scsi/qla1280.h @@ -375,29 +375,23 @@ struct nvram { uint16_t unused_12; /* 12, 13 */ uint16_t unused_14; /* 14, 15 */ - union { - uint8_t c; - struct { - uint8_t reserved:2; - uint8_t burst_enable:1; - uint8_t reserved_1:1; - uint8_t fifo_threshold:4; - } f; + struct { + uint8_t reserved:2; + uint8_t burst_enable:1; + uint8_t reserved_1:1; + uint8_t fifo_threshold:4; } isp_config; /* 16 */ /* Termination * 0 = Disable, 1 = high only, 3 = Auto term */ - union { - uint8_t c; - struct { - uint8_t scsi_bus_1_control:2; - uint8_t scsi_bus_0_control:2; - uint8_t unused_0:1; - uint8_t unused_1:1; - uint8_t unused_2:1; - uint8_t auto_term_support:1; - } f; + struct { + uint8_t scsi_bus_1_control:2; + uint8_t scsi_bus_0_control:2; + uint8_t unused_0:1; + uint8_t unused_1:1; + uint8_t unused_2:1; + uint8_t auto_term_support:1; } termination; /* 17 */ uint16_t isp_parameter; /* 18, 19 */ -- cgit v1.2.3-18-g5258 From 7a34766fdcec0c619aa68ace203b934dd7cf9dbc Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 4 Jul 2005 17:49:22 +0200 Subject: [SCSI] qla1280: don't use bitfields for hardware access, parameters Signed-off-by: Christoph Hellwig Signed-off-by: Thiemo Seufer Signed-off-by: James Bottomley --- drivers/scsi/qla1280.c | 143 +++++++++++++++++++++++++------------------------ drivers/scsi/qla1280.h | 21 ++++---- 2 files changed, 81 insertions(+), 83 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 1a8b1147821..6481deb5704 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -1328,7 +1328,7 @@ qla1280_set_target_parameters(struct scsi_qla_host *ha, int bus, int target) uint8_t mr; uint16_t mb[MAILBOX_REGISTER_COUNT]; struct nvram *nv; - int status; + int status, lun; nv = &ha->nvram; @@ -1336,24 +1336,38 @@ qla1280_set_target_parameters(struct scsi_qla_host *ha, int bus, int target) /* Set Target Parameters. */ mb[0] = MBC_SET_TARGET_PARAMETERS; - mb[1] = (uint16_t) (bus ? target | BIT_7 : target); - mb[1] <<= 8; - - mb[2] = (nv->bus[bus].target[target].parameter.c << 8); + mb[1] = (uint16_t)((bus ? target | BIT_7 : target) << 8); + mb[2] = nv->bus[bus].target[target].parameter.renegotiate_on_error << 8; + mb[2] |= nv->bus[bus].target[target].parameter.stop_queue_on_check << 9; + mb[2] |= nv->bus[bus].target[target].parameter.auto_request_sense << 10; + mb[2] |= nv->bus[bus].target[target].parameter.tag_queuing << 11; + mb[2] |= nv->bus[bus].target[target].parameter.enable_sync << 12; + mb[2] |= nv->bus[bus].target[target].parameter.enable_wide << 13; + mb[2] |= nv->bus[bus].target[target].parameter.parity_checking << 14; + mb[2] |= nv->bus[bus].target[target].parameter.disconnect_allowed << 15; if (IS_ISP1x160(ha)) { mb[2] |= nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr << 5; - mb[3] = (nv->bus[bus].target[target].flags.flags1x160.sync_offset << 8) | - nv->bus[bus].target[target].sync_period; + mb[3] = (nv->bus[bus].target[target].flags.flags1x160.sync_offset << 8); mb[6] = (nv->bus[bus].target[target].ppr_1x160.flags.ppr_options << 8) | nv->bus[bus].target[target].ppr_1x160.flags.ppr_bus_width; mr |= BIT_6; } else { - mb[3] = (nv->bus[bus].target[target].flags.flags1x80.sync_offset << 8) | - nv->bus[bus].target[target].sync_period; + mb[3] = (nv->bus[bus].target[target].flags.flags1x80.sync_offset << 8); } + mb[3] |= nv->bus[bus].target[target].sync_period; + + status = qla1280_mailbox_command(ha, mr, mb); - status = qla1280_mailbox_command(ha, mr, &mb[0]); + /* Set Device Queue Parameters. */ + for (lun = 0; lun < MAX_LUNS; lun++) { + mb[0] = MBC_SET_DEVICE_QUEUE; + mb[1] = (uint16_t)((bus ? target | BIT_7 : target) << 8); + mb[1] |= lun; + mb[2] = nv->bus[bus].max_queue_depth; + mb[3] = nv->bus[bus].target[target].execution_throttle; + status |= qla1280_mailbox_command(ha, 0x0f, mb); + } if (status) printk(KERN_WARNING "scsi(%ld:%i:%i): " @@ -1400,19 +1414,19 @@ qla1280_slave_configure(struct scsi_device *device) } #if LINUX_VERSION_CODE > 0x020500 - nv->bus[bus].target[target].parameter.f.enable_sync = device->sdtr; - nv->bus[bus].target[target].parameter.f.enable_wide = device->wdtr; + nv->bus[bus].target[target].parameter.enable_sync = device->sdtr; + nv->bus[bus].target[target].parameter.enable_wide = device->wdtr; nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = device->ppr; #endif if (driver_setup.no_sync || (driver_setup.sync_mask && (~driver_setup.sync_mask & (1 << target)))) - nv->bus[bus].target[target].parameter.f.enable_sync = 0; + nv->bus[bus].target[target].parameter.enable_sync = 0; if (driver_setup.no_wide || (driver_setup.wide_mask && (~driver_setup.wide_mask & (1 << target)))) - nv->bus[bus].target[target].parameter.f.enable_wide = 0; + nv->bus[bus].target[target].parameter.enable_wide = 0; if (IS_ISP1x160(ha)) { if (driver_setup.no_ppr || (driver_setup.ppr_mask && @@ -1421,7 +1435,7 @@ qla1280_slave_configure(struct scsi_device *device) } spin_lock_irqsave(HOST_LOCK, flags); - if (nv->bus[bus].target[target].parameter.f.enable_sync) + if (nv->bus[bus].target[target].parameter.enable_sync) status = qla1280_set_target_parameters(ha, bus, target); qla1280_get_target_parameters(ha, device); spin_unlock_irqrestore(HOST_LOCK, flags); @@ -2151,17 +2165,17 @@ qla1280_set_target_defaults(struct scsi_qla_host *ha, int bus, int target) { struct nvram *nv = &ha->nvram; - nv->bus[bus].target[target].parameter.f.renegotiate_on_error = 1; - nv->bus[bus].target[target].parameter.f.auto_request_sense = 1; - nv->bus[bus].target[target].parameter.f.tag_queuing = 1; - nv->bus[bus].target[target].parameter.f.enable_sync = 1; + nv->bus[bus].target[target].parameter.renegotiate_on_error = 1; + nv->bus[bus].target[target].parameter.auto_request_sense = 1; + nv->bus[bus].target[target].parameter.tag_queuing = 1; + nv->bus[bus].target[target].parameter.enable_sync = 1; #if 1 /* Some SCSI Processors do not seem to like this */ - nv->bus[bus].target[target].parameter.f.enable_wide = 1; + nv->bus[bus].target[target].parameter.enable_wide = 1; #endif - nv->bus[bus].target[target].parameter.f.parity_checking = 1; - nv->bus[bus].target[target].parameter.f.disconnect_allowed = 1; nv->bus[bus].target[target].execution_throttle = nv->bus[bus].max_queue_depth - 1; + nv->bus[bus].target[target].parameter.parity_checking = 1; + nv->bus[bus].target[target].parameter.disconnect_allowed = 1; if (IS_ISP1x160(ha)) { nv->bus[bus].target[target].flags.flags1x160.device_enable = 1; @@ -2237,66 +2251,53 @@ qla1280_config_target(struct scsi_qla_host *ha, int bus, int target) struct nvram *nv = &ha->nvram; uint16_t mb[MAILBOX_REGISTER_COUNT]; int status, lun; + uint16_t flag; /* Set Target Parameters. */ mb[0] = MBC_SET_TARGET_PARAMETERS; - mb[1] = (uint16_t) (bus ? target | BIT_7 : target); - mb[1] <<= 8; - - /* - * Do not enable wide, sync, and ppr for the initial - * INQUIRY run. We enable this later if we determine - * the target actually supports it. - */ - nv->bus[bus].target[target].parameter.f. - auto_request_sense = 1; - nv->bus[bus].target[target].parameter.f. - stop_queue_on_check = 0; - - if (IS_ISP1x160(ha)) - nv->bus[bus].target[target].ppr_1x160. - flags.enable_ppr = 0; + mb[1] = (uint16_t)((bus ? target | BIT_7 : target) << 8); /* - * No sync, wide, etc. while probing + * Do not enable sync and ppr for the initial INQUIRY run. We + * enable this later if we determine the target actually + * supports it. */ - mb[2] = (nv->bus[bus].target[target].parameter.c << 8) & - ~(TP_SYNC /*| TP_WIDE | TP_PPR*/); + mb[2] = (TP_RENEGOTIATE | TP_AUTO_REQUEST_SENSE | TP_TAGGED_QUEUE + | TP_WIDE | TP_PARITY | TP_DISCONNECT); if (IS_ISP1x160(ha)) mb[3] = nv->bus[bus].target[target].flags.flags1x160.sync_offset << 8; else mb[3] = nv->bus[bus].target[target].flags.flags1x80.sync_offset << 8; mb[3] |= nv->bus[bus].target[target].sync_period; - - status = qla1280_mailbox_command(ha, BIT_3 | BIT_2 | BIT_1 | BIT_0, &mb[0]); + status = qla1280_mailbox_command(ha, 0x0f, mb); /* Save Tag queuing enable flag. */ - mb[0] = BIT_0 << target; - if (nv->bus[bus].target[target].parameter.f.tag_queuing) - ha->bus_settings[bus].qtag_enables |= mb[0]; + flag = (BIT_0 << target) & mb[0]; + if (nv->bus[bus].target[target].parameter.tag_queuing) + ha->bus_settings[bus].qtag_enables |= flag; /* Save Device enable flag. */ if (IS_ISP1x160(ha)) { if (nv->bus[bus].target[target].flags.flags1x160.device_enable) - ha->bus_settings[bus].device_enables |= mb[0]; + ha->bus_settings[bus].device_enables |= flag; ha->bus_settings[bus].lun_disables |= 0; } else { if (nv->bus[bus].target[target].flags.flags1x80.device_enable) - ha->bus_settings[bus].device_enables |= mb[0]; + ha->bus_settings[bus].device_enables |= flag; /* Save LUN disable flag. */ if (nv->bus[bus].target[target].flags.flags1x80.lun_disable) - ha->bus_settings[bus].lun_disables |= mb[0]; + ha->bus_settings[bus].lun_disables |= flag; } /* Set Device Queue Parameters. */ for (lun = 0; lun < MAX_LUNS; lun++) { mb[0] = MBC_SET_DEVICE_QUEUE; - mb[1] = (uint16_t)(bus ? target | BIT_7 : target); - mb[1] = mb[1] << 8 | lun; + mb[1] = (uint16_t)((bus ? target | BIT_7 : target) << 8); + mb[1] |= lun; mb[2] = nv->bus[bus].max_queue_depth; mb[3] = nv->bus[bus].target[target].execution_throttle; - status |= qla1280_mailbox_command(ha, 0x0f, &mb[0]); + status |= qla1280_mailbox_command(ha, 0x0f, mb); } return status; @@ -2341,7 +2342,6 @@ qla1280_nvram_config(struct scsi_qla_host *ha) struct nvram *nv = &ha->nvram; int bus, target, status = 0; uint16_t mb[MAILBOX_REGISTER_COUNT]; - uint16_t mask; ENTER("qla1280_nvram_config"); @@ -2349,7 +2349,7 @@ qla1280_nvram_config(struct scsi_qla_host *ha) /* Always force AUTO sense for LINUX SCSI */ for (bus = 0; bus < MAX_BUSES; bus++) for (target = 0; target < MAX_TARGETS; target++) { - nv->bus[bus].target[target].parameter.f. + nv->bus[bus].target[target].parameter. auto_request_sense = 1; } } else { @@ -2416,16 +2416,17 @@ qla1280_nvram_config(struct scsi_qla_host *ha) /* Firmware feature word. */ mb[0] = MBC_SET_FIRMWARE_FEATURES; - mask = BIT_5 | BIT_1 | BIT_0; - mb[1] = le16_to_cpu(nv->firmware_feature.w) & (mask); + mb[1] = nv->firmware_feature.f.enable_fast_posting; + mb[1] |= nv->firmware_feature.f.report_lvd_bus_transition << 1; + mb[1] |= nv->firmware_feature.f.disable_synchronous_backoff << 5; #if defined(CONFIG_IA64_GENERIC) || defined (CONFIG_IA64_SGI_SN2) if (ia64_platform_is("sn2")) { printk(KERN_INFO "scsi(%li): Enabling SN2 PCI DMA " "workaround\n", ha->host_no); - mb[1] |= BIT_9; + mb[1] |= nv->firmware_feature.f.unused_9 << 9; /* XXX */ } #endif - status |= qla1280_mailbox_command(ha, mask, &mb[0]); + status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); /* Retry count and delay. */ mb[0] = MBC_SET_RETRY_COUNT; @@ -2454,27 +2455,27 @@ qla1280_nvram_config(struct scsi_qla_host *ha) mb[2] |= BIT_5; if (nv->bus[1].config_2.data_line_active_negation) mb[2] |= BIT_4; - status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]); + status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, mb); mb[0] = MBC_SET_DATA_OVERRUN_RECOVERY; mb[1] = 2; /* Reset SCSI bus and return all outstanding IO */ - status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]); + status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); /* thingy */ mb[0] = MBC_SET_PCI_CONTROL; - mb[1] = 2; /* Data DMA Channel Burst Enable */ - mb[2] = 2; /* Command DMA Channel Burst Enable */ - status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]); + mb[1] = BIT_1; /* Data DMA Channel Burst Enable */ + mb[2] = BIT_1; /* Command DMA Channel Burst Enable */ + status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, mb); mb[0] = MBC_SET_TAG_AGE_LIMIT; mb[1] = 8; - status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]); + status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); /* Selection timeout. */ mb[0] = MBC_SET_SELECTION_TIMEOUT; mb[1] = nv->bus[0].selection_timeout; mb[2] = nv->bus[1].selection_timeout; - status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]); + status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, mb); for (bus = 0; bus < ha->ports; bus++) status |= qla1280_config_bus(ha, bus); @@ -3915,21 +3916,21 @@ qla1280_get_target_options(struct scsi_cmnd *cmd, struct scsi_qla_host *ha) result = cmd->request_buffer; n = &ha->nvram; - n->bus[bus].target[target].parameter.f.enable_wide = 0; - n->bus[bus].target[target].parameter.f.enable_sync = 0; + n->bus[bus].target[target].parameter.enable_wide = 0; + n->bus[bus].target[target].parameter.enable_sync = 0; n->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 0; if (result[7] & 0x60) - n->bus[bus].target[target].parameter.f.enable_wide = 1; + n->bus[bus].target[target].parameter.enable_wide = 1; if (result[7] & 0x10) - n->bus[bus].target[target].parameter.f.enable_sync = 1; + n->bus[bus].target[target].parameter.enable_sync = 1; if ((result[2] >= 3) && (result[4] + 5 > 56) && (result[56] & 0x4)) n->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 1; dprintk(2, "get_target_options(): wide %i, sync %i, ppr %i\n", - n->bus[bus].target[target].parameter.f.enable_wide, - n->bus[bus].target[target].parameter.f.enable_sync, + n->bus[bus].target[target].parameter.enable_wide, + n->bus[bus].target[target].parameter.enable_sync, n->bus[bus].target[target].ppr_1x160.flags.enable_ppr); } #endif diff --git a/drivers/scsi/qla1280.h b/drivers/scsi/qla1280.h index 4032ea3f2b9..7c919db97a4 100644 --- a/drivers/scsi/qla1280.h +++ b/drivers/scsi/qla1280.h @@ -451,18 +451,15 @@ struct nvram { uint16_t unused_38; /* 38, 39 */ struct { - union { - uint8_t c; - struct { - uint8_t renegotiate_on_error:1; - uint8_t stop_queue_on_check:1; - uint8_t auto_request_sense:1; - uint8_t tag_queuing:1; - uint8_t enable_sync:1; - uint8_t enable_wide:1; - uint8_t parity_checking:1; - uint8_t disconnect_allowed:1; - } f; + struct { + uint8_t renegotiate_on_error:1; + uint8_t stop_queue_on_check:1; + uint8_t auto_request_sense:1; + uint8_t tag_queuing:1; + uint8_t enable_sync:1; + uint8_t enable_wide:1; + uint8_t parity_checking:1; + uint8_t disconnect_allowed:1; } parameter; /* 40 */ uint8_t execution_throttle; /* 41 */ -- cgit v1.2.3-18-g5258 From 8d6810d33e5e43b11675190318a81303c601a568 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 4 Jul 2005 17:49:26 +0200 Subject: [SCSI] qla1280: endianess annotations Signed-off-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/qla1280.c | 8 +- drivers/scsi/qla1280.h | 270 ++++++++++++++++++++++++------------------------- 2 files changed, 139 insertions(+), 139 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 6481deb5704..637fb6565d2 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -1546,7 +1546,7 @@ qla1280_return_status(struct response * sts, struct scsi_cmnd *cp) int host_status = DID_ERROR; uint16_t comp_status = le16_to_cpu(sts->comp_status); uint16_t state_flags = le16_to_cpu(sts->state_flags); - uint16_t residual_length = le16_to_cpu(sts->residual_length); + uint16_t residual_length = le32_to_cpu(sts->residual_length); uint16_t scsi_status = le16_to_cpu(sts->scsi_status); #if DEBUG_QLA1280_INTR static char *reason[] = { @@ -1932,7 +1932,7 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha) "%d,%d(0x%x)\n", risc_code_address, cnt, num, risc_address); for(i = 0; i < cnt; i++) - ((uint16_t *)ha->request_ring)[i] = + ((__le16 *)ha->request_ring)[i] = cpu_to_le16(risc_code_address[i]); mb[0] = MBC_LOAD_RAM; @@ -2986,7 +2986,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) struct scsi_cmnd *cmd = sp->cmd; cmd_a64_entry_t *pkt; struct scatterlist *sg = NULL; - u32 *dword_ptr; + __le32 *dword_ptr; dma_addr_t dma_handle; int status = 0; int cnt; @@ -3273,7 +3273,7 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) struct scsi_cmnd *cmd = sp->cmd; struct cmd_entry *pkt; struct scatterlist *sg = NULL; - uint32_t *dword_ptr; + __le32 *dword_ptr; int status = 0; int cnt; int req_cnt; diff --git a/drivers/scsi/qla1280.h b/drivers/scsi/qla1280.h index 7c919db97a4..59915fb7030 100644 --- a/drivers/scsi/qla1280.h +++ b/drivers/scsi/qla1280.h @@ -516,23 +516,23 @@ struct cmd_entry { uint8_t entry_count; /* Entry count. */ uint8_t sys_define; /* System defined. */ uint8_t entry_status; /* Entry Status. */ - uint32_t handle; /* System handle. */ + __le32 handle; /* System handle. */ uint8_t lun; /* SCSI LUN */ uint8_t target; /* SCSI ID */ - uint16_t cdb_len; /* SCSI command length. */ - uint16_t control_flags; /* Control flags. */ - uint16_t reserved; - uint16_t timeout; /* Command timeout. */ - uint16_t dseg_count; /* Data segment count. */ + __le16 cdb_len; /* SCSI command length. */ + __le16 control_flags; /* Control flags. */ + __le16 reserved; + __le16 timeout; /* Command timeout. */ + __le16 dseg_count; /* Data segment count. */ uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */ - uint32_t dseg_0_address; /* Data segment 0 address. */ - uint32_t dseg_0_length; /* Data segment 0 length. */ - uint32_t dseg_1_address; /* Data segment 1 address. */ - uint32_t dseg_1_length; /* Data segment 1 length. */ - uint32_t dseg_2_address; /* Data segment 2 address. */ - uint32_t dseg_2_length; /* Data segment 2 length. */ - uint32_t dseg_3_address; /* Data segment 3 address. */ - uint32_t dseg_3_length; /* Data segment 3 length. */ + __le32 dseg_0_address; /* Data segment 0 address. */ + __le32 dseg_0_length; /* Data segment 0 length. */ + __le32 dseg_1_address; /* Data segment 1 address. */ + __le32 dseg_1_length; /* Data segment 1 length. */ + __le32 dseg_2_address; /* Data segment 2 address. */ + __le32 dseg_2_length; /* Data segment 2 length. */ + __le32 dseg_3_address; /* Data segment 3 address. */ + __le32 dseg_3_length; /* Data segment 3 length. */ }; /* @@ -544,21 +544,21 @@ struct cont_entry { uint8_t entry_count; /* Entry count. */ uint8_t sys_define; /* System defined. */ uint8_t entry_status; /* Entry Status. */ - uint32_t reserved; /* Reserved */ - uint32_t dseg_0_address; /* Data segment 0 address. */ - uint32_t dseg_0_length; /* Data segment 0 length. */ - uint32_t dseg_1_address; /* Data segment 1 address. */ - uint32_t dseg_1_length; /* Data segment 1 length. */ - uint32_t dseg_2_address; /* Data segment 2 address. */ - uint32_t dseg_2_length; /* Data segment 2 length. */ - uint32_t dseg_3_address; /* Data segment 3 address. */ - uint32_t dseg_3_length; /* Data segment 3 length. */ - uint32_t dseg_4_address; /* Data segment 4 address. */ - uint32_t dseg_4_length; /* Data segment 4 length. */ - uint32_t dseg_5_address; /* Data segment 5 address. */ - uint32_t dseg_5_length; /* Data segment 5 length. */ - uint32_t dseg_6_address; /* Data segment 6 address. */ - uint32_t dseg_6_length; /* Data segment 6 length. */ + __le32 reserved; /* Reserved */ + __le32 dseg_0_address; /* Data segment 0 address. */ + __le32 dseg_0_length; /* Data segment 0 length. */ + __le32 dseg_1_address; /* Data segment 1 address. */ + __le32 dseg_1_length; /* Data segment 1 length. */ + __le32 dseg_2_address; /* Data segment 2 address. */ + __le32 dseg_2_length; /* Data segment 2 length. */ + __le32 dseg_3_address; /* Data segment 3 address. */ + __le32 dseg_3_length; /* Data segment 3 length. */ + __le32 dseg_4_address; /* Data segment 4 address. */ + __le32 dseg_4_length; /* Data segment 4 length. */ + __le32 dseg_5_address; /* Data segment 5 address. */ + __le32 dseg_5_length; /* Data segment 5 length. */ + __le32 dseg_6_address; /* Data segment 6 address. */ + __le32 dseg_6_length; /* Data segment 6 length. */ }; /* @@ -574,22 +574,22 @@ struct response { #define RF_FULL BIT_1 /* Full */ #define RF_BAD_HEADER BIT_2 /* Bad header. */ #define RF_BAD_PAYLOAD BIT_3 /* Bad payload. */ - uint32_t handle; /* System handle. */ - uint16_t scsi_status; /* SCSI status. */ - uint16_t comp_status; /* Completion status. */ - uint16_t state_flags; /* State flags. */ -#define SF_TRANSFER_CMPL BIT_14 /* Transfer Complete. */ -#define SF_GOT_SENSE BIT_13 /* Got Sense */ -#define SF_GOT_STATUS BIT_12 /* Got Status */ -#define SF_TRANSFERRED_DATA BIT_11 /* Transferred data */ -#define SF_SENT_CDB BIT_10 /* Send CDB */ -#define SF_GOT_TARGET BIT_9 /* */ -#define SF_GOT_BUS BIT_8 /* */ - uint16_t status_flags; /* Status flags. */ - uint16_t time; /* Time. */ - uint16_t req_sense_length; /* Request sense data length. */ - uint32_t residual_length; /* Residual transfer length. */ - uint16_t reserved[4]; + __le32 handle; /* System handle. */ + __le16 scsi_status; /* SCSI status. */ + __le16 comp_status; /* Completion status. */ + __le16 state_flags; /* State flags. */ +#define SF_TRANSFER_CMPL BIT_14 /* Transfer Complete. */ +#define SF_GOT_SENSE BIT_13 /* Got Sense */ +#define SF_GOT_STATUS BIT_12 /* Got Status */ +#define SF_TRANSFERRED_DATA BIT_11 /* Transferred data */ +#define SF_SENT_CDB BIT_10 /* Send CDB */ +#define SF_GOT_TARGET BIT_9 /* */ +#define SF_GOT_BUS BIT_8 /* */ + __le16 status_flags; /* Status flags. */ + __le16 time; /* Time. */ + __le16 req_sense_length;/* Request sense data length. */ + __le32 residual_length; /* Residual transfer length. */ + __le16 reserved[4]; uint8_t req_sense_data[32]; /* Request sense data. */ }; @@ -602,7 +602,7 @@ struct mrk_entry { uint8_t entry_count; /* Entry count. */ uint8_t sys_define; /* System defined. */ uint8_t entry_status; /* Entry Status. */ - uint32_t reserved; + __le32 reserved; uint8_t lun; /* SCSI LUN */ uint8_t target; /* SCSI ID */ uint8_t modifier; /* Modifier (7-0). */ @@ -626,11 +626,11 @@ struct ecmd_entry { uint32_t handle; /* System handle. */ uint8_t lun; /* SCSI LUN */ uint8_t target; /* SCSI ID */ - uint16_t cdb_len; /* SCSI command length. */ - uint16_t control_flags; /* Control flags. */ - uint16_t reserved; - uint16_t timeout; /* Command timeout. */ - uint16_t dseg_count; /* Data segment count. */ + __le16 cdb_len; /* SCSI command length. */ + __le16 control_flags; /* Control flags. */ + __le16 reserved; + __le16 timeout; /* Command timeout. */ + __le16 dseg_count; /* Data segment count. */ uint8_t scsi_cdb[88]; /* SCSI command words. */ }; @@ -643,20 +643,20 @@ typedef struct { uint8_t entry_count; /* Entry count. */ uint8_t sys_define; /* System defined. */ uint8_t entry_status; /* Entry Status. */ - uint32_t handle; /* System handle. */ + __le32 handle; /* System handle. */ uint8_t lun; /* SCSI LUN */ uint8_t target; /* SCSI ID */ - uint16_t cdb_len; /* SCSI command length. */ - uint16_t control_flags; /* Control flags. */ - uint16_t reserved; - uint16_t timeout; /* Command timeout. */ - uint16_t dseg_count; /* Data segment count. */ + __le16 cdb_len; /* SCSI command length. */ + __le16 control_flags; /* Control flags. */ + __le16 reserved; + __le16 timeout; /* Command timeout. */ + __le16 dseg_count; /* Data segment count. */ uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */ - uint32_t reserved_1[2]; /* unused */ - uint32_t dseg_0_address[2]; /* Data segment 0 address. */ - uint32_t dseg_0_length; /* Data segment 0 length. */ - uint32_t dseg_1_address[2]; /* Data segment 1 address. */ - uint32_t dseg_1_length; /* Data segment 1 length. */ + __le32 reserved_1[2]; /* unused */ + __le32 dseg_0_address[2]; /* Data segment 0 address. */ + __le32 dseg_0_length; /* Data segment 0 length. */ + __le32 dseg_1_address[2]; /* Data segment 1 address. */ + __le32 dseg_1_length; /* Data segment 1 length. */ } cmd_a64_entry_t, request_t; /* @@ -668,16 +668,16 @@ struct cont_a64_entry { uint8_t entry_count; /* Entry count. */ uint8_t sys_define; /* System defined. */ uint8_t entry_status; /* Entry Status. */ - uint32_t dseg_0_address[2]; /* Data segment 0 address. */ - uint32_t dseg_0_length; /* Data segment 0 length. */ - uint32_t dseg_1_address[2]; /* Data segment 1 address. */ - uint32_t dseg_1_length; /* Data segment 1 length. */ - uint32_t dseg_2_address[2]; /* Data segment 2 address. */ - uint32_t dseg_2_length; /* Data segment 2 length. */ - uint32_t dseg_3_address[2]; /* Data segment 3 address. */ - uint32_t dseg_3_length; /* Data segment 3 length. */ - uint32_t dseg_4_address[2]; /* Data segment 4 address. */ - uint32_t dseg_4_length; /* Data segment 4 length. */ + __le32 dseg_0_address[2]; /* Data segment 0 address. */ + __le32 dseg_0_length; /* Data segment 0 length. */ + __le32 dseg_1_address[2]; /* Data segment 1 address. */ + __le32 dseg_1_length; /* Data segment 1 length. */ + __le32 dseg_2_address[2]; /* Data segment 2 address. */ + __le32 dseg_2_length; /* Data segment 2 length. */ + __le32 dseg_3_address[2]; /* Data segment 3 address. */ + __le32 dseg_3_length; /* Data segment 3 length. */ + __le32 dseg_4_address[2]; /* Data segment 4 address. */ + __le32 dseg_4_length; /* Data segment 4 length. */ }; /* @@ -689,10 +689,10 @@ struct elun_entry { uint8_t entry_count; /* Entry count. */ uint8_t reserved_1; uint8_t entry_status; /* Entry Status not used. */ - uint32_t reserved_2; - uint16_t lun; /* Bit 15 is bus number. */ - uint16_t reserved_4; - uint32_t option_flags; + __le32 reserved_2; + __le16 lun; /* Bit 15 is bus number. */ + __le16 reserved_4; + __le32 option_flags; uint8_t status; uint8_t reserved_5; uint8_t command_count; /* Number of ATIOs allocated. */ @@ -702,8 +702,8 @@ struct elun_entry { /* commands (2-26). */ uint8_t group_7_length; /* SCSI CDB length for group 7 */ /* commands (2-26). */ - uint16_t timeout; /* 0 = 30 seconds, 0xFFFF = disable */ - uint16_t reserved_6[20]; + __le16 timeout; /* 0 = 30 seconds, 0xFFFF = disable */ + __le16 reserved_6[20]; }; /* @@ -717,20 +717,20 @@ struct modify_lun_entry { uint8_t entry_count; /* Entry count. */ uint8_t reserved_1; uint8_t entry_status; /* Entry Status. */ - uint32_t reserved_2; + __le32 reserved_2; uint8_t lun; /* SCSI LUN */ uint8_t reserved_3; uint8_t operators; uint8_t reserved_4; - uint32_t option_flags; + __le32 option_flags; uint8_t status; uint8_t reserved_5; uint8_t command_count; /* Number of ATIOs allocated. */ uint8_t immed_notify_count; /* Number of Immediate Notify */ /* entries allocated. */ - uint16_t reserved_6; - uint16_t timeout; /* 0 = 30 seconds, 0xFFFF = disable */ - uint16_t reserved_7[20]; + __le16 reserved_6; + __le16 timeout; /* 0 = 30 seconds, 0xFFFF = disable */ + __le16 reserved_7[20]; }; /* @@ -742,20 +742,20 @@ struct notify_entry { uint8_t entry_count; /* Entry count. */ uint8_t reserved_1; uint8_t entry_status; /* Entry Status. */ - uint32_t reserved_2; + __le32 reserved_2; uint8_t lun; uint8_t initiator_id; uint8_t reserved_3; uint8_t target_id; - uint32_t option_flags; + __le32 option_flags; uint8_t status; uint8_t reserved_4; uint8_t tag_value; /* Received queue tag message value */ uint8_t tag_type; /* Received queue tag message type */ /* entries allocated. */ - uint16_t seq_id; + __le16 seq_id; uint8_t scsi_msg[8]; /* SCSI message not handled by ISP */ - uint16_t reserved_5[8]; + __le16 reserved_5[8]; uint8_t sense_data[18]; }; @@ -768,16 +768,16 @@ struct nack_entry { uint8_t entry_count; /* Entry count. */ uint8_t reserved_1; uint8_t entry_status; /* Entry Status. */ - uint32_t reserved_2; + __le32 reserved_2; uint8_t lun; uint8_t initiator_id; uint8_t reserved_3; uint8_t target_id; - uint32_t option_flags; + __le32 option_flags; uint8_t status; uint8_t event; - uint16_t seq_id; - uint16_t reserved_4[22]; + __le16 seq_id; + __le16 reserved_4[22]; }; /* @@ -789,12 +789,12 @@ struct atio_entry { uint8_t entry_count; /* Entry count. */ uint8_t reserved_1; uint8_t entry_status; /* Entry Status. */ - uint32_t reserved_2; + __le32 reserved_2; uint8_t lun; uint8_t initiator_id; uint8_t cdb_len; uint8_t target_id; - uint32_t option_flags; + __le32 option_flags; uint8_t status; uint8_t scsi_status; uint8_t tag_value; /* Received queue tag message value */ @@ -812,28 +812,28 @@ struct ctio_entry { uint8_t entry_count; /* Entry count. */ uint8_t reserved_1; uint8_t entry_status; /* Entry Status. */ - uint32_t reserved_2; + __le32 reserved_2; uint8_t lun; /* SCSI LUN */ uint8_t initiator_id; uint8_t reserved_3; uint8_t target_id; - uint32_t option_flags; + __le32 option_flags; uint8_t status; uint8_t scsi_status; uint8_t tag_value; /* Received queue tag message value */ uint8_t tag_type; /* Received queue tag message type */ - uint32_t transfer_length; - uint32_t residual; - uint16_t timeout; /* 0 = 30 seconds, 0xFFFF = disable */ - uint16_t dseg_count; /* Data segment count. */ - uint32_t dseg_0_address; /* Data segment 0 address. */ - uint32_t dseg_0_length; /* Data segment 0 length. */ - uint32_t dseg_1_address; /* Data segment 1 address. */ - uint32_t dseg_1_length; /* Data segment 1 length. */ - uint32_t dseg_2_address; /* Data segment 2 address. */ - uint32_t dseg_2_length; /* Data segment 2 length. */ - uint32_t dseg_3_address; /* Data segment 3 address. */ - uint32_t dseg_3_length; /* Data segment 3 length. */ + __le32 transfer_length; + __le32 residual; + __le16 timeout; /* 0 = 30 seconds, 0xFFFF = disable */ + __le16 dseg_count; /* Data segment count. */ + __le32 dseg_0_address; /* Data segment 0 address. */ + __le32 dseg_0_length; /* Data segment 0 length. */ + __le32 dseg_1_address; /* Data segment 1 address. */ + __le32 dseg_1_length; /* Data segment 1 length. */ + __le32 dseg_2_address; /* Data segment 2 address. */ + __le32 dseg_2_length; /* Data segment 2 length. */ + __le32 dseg_3_address; /* Data segment 3 address. */ + __le32 dseg_3_length; /* Data segment 3 length. */ }; /* @@ -845,24 +845,24 @@ struct ctio_ret_entry { uint8_t entry_count; /* Entry count. */ uint8_t reserved_1; uint8_t entry_status; /* Entry Status. */ - uint32_t reserved_2; + __le32 reserved_2; uint8_t lun; /* SCSI LUN */ uint8_t initiator_id; uint8_t reserved_3; uint8_t target_id; - uint32_t option_flags; + __le32 option_flags; uint8_t status; uint8_t scsi_status; uint8_t tag_value; /* Received queue tag message value */ uint8_t tag_type; /* Received queue tag message type */ - uint32_t transfer_length; - uint32_t residual; - uint16_t timeout; /* 0 = 30 seconds, 0xFFFF = disable */ - uint16_t dseg_count; /* Data segment count. */ - uint32_t dseg_0_address; /* Data segment 0 address. */ - uint32_t dseg_0_length; /* Data segment 0 length. */ - uint32_t dseg_1_address; /* Data segment 1 address. */ - uint16_t dseg_1_length; /* Data segment 1 length. */ + __le32 transfer_length; + __le32 residual; + __le16 timeout; /* 0 = 30 seconds, 0xFFFF = disable */ + __le16 dseg_count; /* Data segment count. */ + __le32 dseg_0_address; /* Data segment 0 address. */ + __le32 dseg_0_length; /* Data segment 0 length. */ + __le32 dseg_1_address; /* Data segment 1 address. */ + __le16 dseg_1_length; /* Data segment 1 length. */ uint8_t sense_data[18]; }; @@ -875,25 +875,25 @@ struct ctio_a64_entry { uint8_t entry_count; /* Entry count. */ uint8_t reserved_1; uint8_t entry_status; /* Entry Status. */ - uint32_t reserved_2; + __le32 reserved_2; uint8_t lun; /* SCSI LUN */ uint8_t initiator_id; uint8_t reserved_3; uint8_t target_id; - uint32_t option_flags; + __le32 option_flags; uint8_t status; uint8_t scsi_status; uint8_t tag_value; /* Received queue tag message value */ uint8_t tag_type; /* Received queue tag message type */ - uint32_t transfer_length; - uint32_t residual; - uint16_t timeout; /* 0 = 30 seconds, 0xFFFF = disable */ - uint16_t dseg_count; /* Data segment count. */ - uint32_t reserved_4[2]; - uint32_t dseg_0_address[2]; /* Data segment 0 address. */ - uint32_t dseg_0_length; /* Data segment 0 length. */ - uint32_t dseg_1_address[2]; /* Data segment 1 address. */ - uint32_t dseg_1_length; /* Data segment 1 length. */ + __le32 transfer_length; + __le32 residual; + __le16 timeout; /* 0 = 30 seconds, 0xFFFF = disable */ + __le16 dseg_count; /* Data segment count. */ + __le32 reserved_4[2]; + __le32 dseg_0_address[2];/* Data segment 0 address. */ + __le32 dseg_0_length; /* Data segment 0 length. */ + __le32 dseg_1_address[2];/* Data segment 1 address. */ + __le32 dseg_1_length; /* Data segment 1 length. */ }; /* @@ -905,21 +905,21 @@ struct ctio_a64_ret_entry { uint8_t entry_count; /* Entry count. */ uint8_t reserved_1; uint8_t entry_status; /* Entry Status. */ - uint32_t reserved_2; + __le32 reserved_2; uint8_t lun; /* SCSI LUN */ uint8_t initiator_id; uint8_t reserved_3; uint8_t target_id; - uint32_t option_flags; + __le32 option_flags; uint8_t status; uint8_t scsi_status; uint8_t tag_value; /* Received queue tag message value */ uint8_t tag_type; /* Received queue tag message type */ - uint32_t transfer_length; - uint32_t residual; - uint16_t timeout; /* 0 = 30 seconds, 0xFFFF = disable */ - uint16_t dseg_count; /* Data segment count. */ - uint16_t reserved_4[7]; + __le32 transfer_length; + __le32 residual; + __le16 timeout; /* 0 = 30 seconds, 0xFFFF = disable */ + __le16 dseg_count; /* Data segment count. */ + __le16 reserved_4[7]; uint8_t sense_data[18]; }; -- cgit v1.2.3-18-g5258 From 60a13213840296b1e32d6781653a0eaa83d04382 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 22 Jul 2005 16:42:28 +0200 Subject: [SCSI] aic79xx: Remove busyq From: Jeff Garzik This patch removes the busyq in aic79xx and uses the command-queue from the midlayer instead. Additionally some dead code is removed. Signed-off-by: Hannes Reinecke Fixed rejections Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_core.c | 1 - drivers/scsi/aic7xxx/aic79xx_osm.c | 824 ++++++------------------------------ drivers/scsi/aic7xxx/aic79xx_osm.h | 26 +- drivers/scsi/aic7xxx/aic79xx_proc.c | 12 - 4 files changed, 139 insertions(+), 724 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c index 137fb1a37dd..d69bbffb34a 100644 --- a/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/drivers/scsi/aic7xxx/aic79xx_core.c @@ -9039,7 +9039,6 @@ ahd_dump_card_state(struct ahd_softc *ahd) ahd_outb(ahd, STACK, (ahd->saved_stack[i] >> 8) & 0xFF); } printf("\n<<<<<<<<<<<<<<<<< Dump Card State Ends >>>>>>>>>>>>>>>>>>\n"); - ahd_platform_dump_card_state(ahd); ahd_restore_modes(ahd, saved_modes); if (paused == 0) ahd_unpause(ahd); diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 329cb233133..7463dd515d1 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -53,11 +53,6 @@ #include "aiclib.c" #include /* __setup */ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#include "sd.h" /* For geometry detection */ -#endif - #include /* For fetching system memory size */ #include /* For ssleep/msleep */ @@ -66,11 +61,6 @@ */ spinlock_t ahd_list_spinlock; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -/* For dynamic sglist size calculation. */ -u_int ahd_linux_nseg; -#endif - /* * Bucket size for counting good commands in between bad ones. */ @@ -457,7 +447,6 @@ static void ahd_linux_filter_inquiry(struct ahd_softc *ahd, static void ahd_linux_dev_timed_unfreeze(u_long arg); static void ahd_linux_sem_timeout(u_long arg); static void ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd); -static void ahd_linux_size_nseg(void); static void ahd_linux_thread_run_complete_queue(struct ahd_softc *ahd); static void ahd_linux_start_dv(struct ahd_softc *ahd); static void ahd_linux_dv_timeout(struct scsi_cmnd *cmd); @@ -516,31 +505,23 @@ static struct ahd_linux_device* ahd_linux_alloc_device(struct ahd_softc*, u_int); static void ahd_linux_free_device(struct ahd_softc*, struct ahd_linux_device*); -static void ahd_linux_run_device_queue(struct ahd_softc*, - struct ahd_linux_device*); +static int ahd_linux_run_command(struct ahd_softc*, + struct ahd_linux_device*, + struct scsi_cmnd *); static void ahd_linux_setup_tag_info_global(char *p); static aic_option_callback_t ahd_linux_setup_tag_info; static aic_option_callback_t ahd_linux_setup_rd_strm_info; static aic_option_callback_t ahd_linux_setup_dv; static aic_option_callback_t ahd_linux_setup_iocell_info; static int ahd_linux_next_unit(void); -static void ahd_runq_tasklet(unsigned long data); static int aic79xx_setup(char *c); /****************************** Inlines ***************************************/ static __inline void ahd_schedule_completeq(struct ahd_softc *ahd); -static __inline void ahd_schedule_runq(struct ahd_softc *ahd); -static __inline void ahd_setup_runq_tasklet(struct ahd_softc *ahd); -static __inline void ahd_teardown_runq_tasklet(struct ahd_softc *ahd); static __inline struct ahd_linux_device* ahd_linux_get_device(struct ahd_softc *ahd, u_int channel, u_int target, u_int lun, int alloc); static struct ahd_cmd *ahd_linux_run_complete_queue(struct ahd_softc *ahd); -static __inline void ahd_linux_check_device_queue(struct ahd_softc *ahd, - struct ahd_linux_device *dev); -static __inline struct ahd_linux_device * - ahd_linux_next_device_to_run(struct ahd_softc *ahd); -static __inline void ahd_linux_run_device_queues(struct ahd_softc *ahd); static __inline void ahd_linux_unmap_scb(struct ahd_softc*, struct scb*); static __inline void @@ -553,28 +534,6 @@ ahd_schedule_completeq(struct ahd_softc *ahd) } } -/* - * Must be called with our lock held. - */ -static __inline void -ahd_schedule_runq(struct ahd_softc *ahd) -{ - tasklet_schedule(&ahd->platform_data->runq_tasklet); -} - -static __inline -void ahd_setup_runq_tasklet(struct ahd_softc *ahd) -{ - tasklet_init(&ahd->platform_data->runq_tasklet, ahd_runq_tasklet, - (unsigned long)ahd); -} - -static __inline void -ahd_teardown_runq_tasklet(struct ahd_softc *ahd) -{ - tasklet_kill(&ahd->platform_data->runq_tasklet); -} - static __inline struct ahd_linux_device* ahd_linux_get_device(struct ahd_softc *ahd, u_int channel, u_int target, u_int lun, int alloc) @@ -640,46 +599,6 @@ ahd_linux_run_complete_queue(struct ahd_softc *ahd) return (acmd); } -static __inline void -ahd_linux_check_device_queue(struct ahd_softc *ahd, - struct ahd_linux_device *dev) -{ - if ((dev->flags & AHD_DEV_FREEZE_TIL_EMPTY) != 0 - && dev->active == 0) { - dev->flags &= ~AHD_DEV_FREEZE_TIL_EMPTY; - dev->qfrozen--; - } - - if (TAILQ_FIRST(&dev->busyq) == NULL - || dev->openings == 0 || dev->qfrozen != 0) - return; - - ahd_linux_run_device_queue(ahd, dev); -} - -static __inline struct ahd_linux_device * -ahd_linux_next_device_to_run(struct ahd_softc *ahd) -{ - - if ((ahd->flags & AHD_RESOURCE_SHORTAGE) != 0 - || (ahd->platform_data->qfrozen != 0 - && AHD_DV_SIMQ_FROZEN(ahd) == 0)) - return (NULL); - return (TAILQ_FIRST(&ahd->platform_data->device_runq)); -} - -static __inline void -ahd_linux_run_device_queues(struct ahd_softc *ahd) -{ - struct ahd_linux_device *dev; - - while ((dev = ahd_linux_next_device_to_run(ahd)) != NULL) { - TAILQ_REMOVE(&ahd->platform_data->device_runq, dev, links); - dev->flags &= ~AHD_DEV_ON_RUN_LIST; - ahd_linux_check_device_queue(ahd, dev); - } -} - static __inline void ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb) { @@ -709,7 +628,6 @@ ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb) static int ahd_linux_detect(Scsi_Host_Template *); static const char *ahd_linux_info(struct Scsi_Host *); static int ahd_linux_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *)); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) static int ahd_linux_slave_alloc(Scsi_Device *); static int ahd_linux_slave_configure(Scsi_Device *); static void ahd_linux_slave_destroy(Scsi_Device *); @@ -717,78 +635,10 @@ static void ahd_linux_slave_destroy(Scsi_Device *); static int ahd_linux_biosparam(struct scsi_device*, struct block_device*, sector_t, int[]); #endif -#else -static int ahd_linux_release(struct Scsi_Host *); -static void ahd_linux_select_queue_depth(struct Scsi_Host *host, - Scsi_Device *scsi_devs); -#if defined(__i386__) -static int ahd_linux_biosparam(Disk *, kdev_t, int[]); -#endif -#endif static int ahd_linux_bus_reset(Scsi_Cmnd *); static int ahd_linux_dev_reset(Scsi_Cmnd *); static int ahd_linux_abort(Scsi_Cmnd *); -/* - * Calculate a safe value for AHD_NSEG (as expressed through ahd_linux_nseg). - * - * In pre-2.5.X... - * The midlayer allocates an S/G array dynamically when a command is issued - * using SCSI malloc. This array, which is in an OS dependent format that - * must later be copied to our private S/G list, is sized to house just the - * number of segments needed for the current transfer. Since the code that - * sizes the SCSI malloc pool does not take into consideration fragmentation - * of the pool, executing transactions numbering just a fraction of our - * concurrent transaction limit with SG list lengths aproaching AHC_NSEG will - * quickly depleat the SCSI malloc pool of usable space. Unfortunately, the - * mid-layer does not properly handle this scsi malloc failures for the S/G - * array and the result can be a lockup of the I/O subsystem. We try to size - * our S/G list so that it satisfies our drivers allocation requirements in - * addition to avoiding fragmentation of the SCSI malloc pool. - */ -static void -ahd_linux_size_nseg(void) -{ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - u_int cur_size; - u_int best_size; - - /* - * The SCSI allocator rounds to the nearest 512 bytes - * an cannot allocate across a page boundary. Our algorithm - * is to start at 1K of scsi malloc space per-command and - * loop through all factors of the PAGE_SIZE and pick the best. - */ - best_size = 0; - for (cur_size = 1024; cur_size <= PAGE_SIZE; cur_size *= 2) { - u_int nseg; - - nseg = cur_size / sizeof(struct scatterlist); - if (nseg < AHD_LINUX_MIN_NSEG) - continue; - - if (best_size == 0) { - best_size = cur_size; - ahd_linux_nseg = nseg; - } else { - u_int best_rem; - u_int cur_rem; - - /* - * Compare the traits of the current "best_size" - * with the current size to determine if the - * current size is a better size. - */ - best_rem = best_size % sizeof(struct scatterlist); - cur_rem = cur_size % sizeof(struct scatterlist); - if (cur_rem < best_rem) { - best_size = cur_size; - ahd_linux_nseg = nseg; - } - } - } -#endif -} /* * Try to detect an Adaptec 79XX controller. @@ -800,14 +650,6 @@ ahd_linux_detect(Scsi_Host_Template *template) int found; int error = 0; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - /* - * It is a bug that the upper layer takes - * this lock just prior to calling us. - */ - spin_unlock_irq(&io_request_lock); -#endif - /* * Sanity checking of Linux SCSI data structures so * that some of our hacks^H^H^H^H^Hassumptions aren't @@ -819,10 +661,7 @@ ahd_linux_detect(Scsi_Host_Template *template) printf("ahd_linux_detect: Unable to attach\n"); return (0); } - /* - * Determine an appropriate size for our Scatter Gatther lists. - */ - ahd_linux_size_nseg(); + #ifdef MODULE /* * If we've been passed any parameters, process them now. @@ -855,47 +694,10 @@ ahd_linux_detect(Scsi_Host_Template *template) if (ahd_linux_register_host(ahd, template) == 0) found++; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - spin_lock_irq(&io_request_lock); -#endif aic79xx_detect_complete++; return 0; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -/* - * Free the passed in Scsi_Host memory structures prior to unloading the - * module. - */ -static int -ahd_linux_release(struct Scsi_Host * host) -{ - struct ahd_softc *ahd; - u_long l; - - ahd_list_lock(&l); - if (host != NULL) { - - /* - * We should be able to just perform - * the free directly, but check our - * list for extra sanity. - */ - ahd = ahd_find_softc(*(struct ahd_softc **)host->hostdata); - if (ahd != NULL) { - u_long s; - - ahd_lock(ahd, &s); - ahd_intr_enable(ahd, FALSE); - ahd_unlock(ahd, &s); - ahd_free(ahd); - } - } - ahd_list_unlock(&l); - return (0); -} -#endif - /* * Return a string describing the driver. */ @@ -932,17 +734,9 @@ ahd_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *)) { struct ahd_softc *ahd; struct ahd_linux_device *dev; - u_long flags; ahd = *(struct ahd_softc **)cmd->device->host->hostdata; - /* - * Save the callback on completion function. - */ - cmd->scsi_done = scsi_done; - - ahd_midlayer_entrypoint_lock(ahd, &flags); - /* * Close the race of a command that was in the process of * being queued to us just as our simq was frozen. Let @@ -951,39 +745,26 @@ ahd_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *)) */ if (ahd->platform_data->qfrozen != 0 && AHD_DV_CMD(cmd) == 0) { + printf("%s: queue frozen\n", ahd_name(ahd)); - ahd_cmd_set_transaction_status(cmd, CAM_REQUEUE_REQ); - ahd_linux_queue_cmd_complete(ahd, cmd); - ahd_schedule_completeq(ahd); - ahd_midlayer_entrypoint_unlock(ahd, &flags); - return (0); + return SCSI_MLQUEUE_HOST_BUSY; } + + /* + * Save the callback on completion function. + */ + cmd->scsi_done = scsi_done; + dev = ahd_linux_get_device(ahd, cmd->device->channel, cmd->device->id, cmd->device->lun, /*alloc*/TRUE); - if (dev == NULL) { - ahd_cmd_set_transaction_status(cmd, CAM_RESRC_UNAVAIL); - ahd_linux_queue_cmd_complete(ahd, cmd); - ahd_schedule_completeq(ahd); - ahd_midlayer_entrypoint_unlock(ahd, &flags); - printf("%s: aic79xx_linux_queue - Unable to allocate device!\n", - ahd_name(ahd)); - return (0); - } - if (cmd->cmd_len > MAX_CDB_LEN) - return (-EINVAL); + BUG_ON(dev == NULL); + cmd->result = CAM_REQ_INPROG << 16; - TAILQ_INSERT_TAIL(&dev->busyq, (struct ahd_cmd *)cmd, acmd_links.tqe); - if ((dev->flags & AHD_DEV_ON_RUN_LIST) == 0) { - TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq, dev, links); - dev->flags |= AHD_DEV_ON_RUN_LIST; - ahd_linux_run_device_queues(ahd); - } - ahd_midlayer_entrypoint_unlock(ahd, &flags); - return (0); + + return ahd_linux_run_command(ahd, dev, cmd); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) static int ahd_linux_slave_alloc(Scsi_Device *device) { @@ -1049,99 +830,22 @@ ahd_linux_slave_destroy(Scsi_Device *device) if (dev != NULL && (dev->flags & AHD_DEV_SLAVE_CONFIGURED) != 0) { dev->flags |= AHD_DEV_UNCONFIGURED; - if (TAILQ_EMPTY(&dev->busyq) - && dev->active == 0 + if (dev->active == 0 && (dev->flags & AHD_DEV_TIMER_ACTIVE) == 0) ahd_linux_free_device(ahd, dev); } ahd_midlayer_entrypoint_unlock(ahd, &flags); } -#else -/* - * Sets the queue depth for each SCSI device hanging - * off the input host adapter. - */ -static void -ahd_linux_select_queue_depth(struct Scsi_Host * host, - Scsi_Device * scsi_devs) -{ - Scsi_Device *device; - Scsi_Device *ldev; - struct ahd_softc *ahd; - u_long flags; - - ahd = *((struct ahd_softc **)host->hostdata); - ahd_lock(ahd, &flags); - for (device = scsi_devs; device != NULL; device = device->next) { - - /* - * Watch out for duplicate devices. This works around - * some quirks in how the SCSI scanning code does its - * device management. - */ - for (ldev = scsi_devs; ldev != device; ldev = ldev->next) { - if (ldev->host == device->host - && ldev->channel == device->channel - && ldev->id == device->id - && ldev->lun == device->lun) - break; - } - /* Skip duplicate. */ - if (ldev != device) - continue; - - if (device->host == host) { - struct ahd_linux_device *dev; - - /* - * Since Linux has attached to the device, configure - * it so we don't free and allocate the device - * structure on every command. - */ - dev = ahd_linux_get_device(ahd, device->channel, - device->id, device->lun, - /*alloc*/TRUE); - if (dev != NULL) { - dev->flags &= ~AHD_DEV_UNCONFIGURED; - dev->scsi_device = device; - ahd_linux_device_queue_depth(ahd, dev); - device->queue_depth = dev->openings - + dev->active; - if ((dev->flags & (AHD_DEV_Q_BASIC - | AHD_DEV_Q_TAGGED)) == 0) { - /* - * We allow the OS to queue 2 untagged - * transactions to us at any time even - * though we can only execute them - * serially on the controller/device. - * This should remove some latency. - */ - device->queue_depth = 2; - } - } - } - } - ahd_unlock(ahd, &flags); -} -#endif #if defined(__i386__) /* * Return the disk geometry for the given SCSI device. */ static int -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) ahd_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int geom[]) { uint8_t *bh; -#else -ahd_linux_biosparam(Disk *disk, kdev_t dev, int geom[]) -{ - struct scsi_device *sdev = disk->device; - u_long capacity = disk->capacity; - struct buffer_head *bh; -#endif int heads; int sectors; int cylinders; @@ -1151,22 +855,11 @@ ahd_linux_biosparam(Disk *disk, kdev_t dev, int geom[]) ahd = *((struct ahd_softc **)sdev->host->hostdata); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) bh = scsi_bios_ptable(bdev); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17) - bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, block_size(dev)); -#else - bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, 1024); -#endif - if (bh) { ret = scsi_partsize(bh, capacity, &geom[2], &geom[0], &geom[1]); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) kfree(bh); -#else - brelse(bh); -#endif if (ret != -1) return (ret); } @@ -1198,7 +891,6 @@ ahd_linux_abort(Scsi_Cmnd *cmd) { struct ahd_softc *ahd; struct ahd_cmd *acmd; - struct ahd_cmd *list_acmd; struct ahd_linux_device *dev; struct scb *pending_scb; u_long s; @@ -1265,22 +957,6 @@ ahd_linux_abort(Scsi_Cmnd *cmd) goto no_cmd; } - TAILQ_FOREACH(list_acmd, &dev->busyq, acmd_links.tqe) { - if (list_acmd == acmd) - break; - } - - if (list_acmd != NULL) { - printf("%s:%d:%d:%d: Command found on device queue\n", - ahd_name(ahd), cmd->device->channel, cmd->device->id, - cmd->device->lun); - TAILQ_REMOVE(&dev->busyq, list_acmd, acmd_links.tqe); - cmd->result = DID_ABORT << 16; - ahd_linux_queue_cmd_complete(ahd, cmd); - retval = SUCCESS; - goto done; - } - /* * See if we can find a matching cmd in the pending list. */ @@ -1468,7 +1144,6 @@ done: } spin_lock_irq(&ahd->platform_data->spin_lock); } - ahd_schedule_runq(ahd); ahd_linux_run_complete_queue(ahd); ahd_midlayer_entrypoint_unlock(ahd, &s); return (retval); @@ -1568,7 +1243,6 @@ ahd_linux_dev_reset(Scsi_Cmnd *cmd) retval = FAILED; } ahd_lock(ahd, &s); - ahd_schedule_runq(ahd); ahd_linux_run_complete_queue(ahd); ahd_unlock(ahd, &s); printf("%s: Device reset returning 0x%x\n", ahd_name(ahd), retval); @@ -1625,35 +1299,6 @@ Scsi_Host_Template aic79xx_driver_template = { .slave_destroy = ahd_linux_slave_destroy, }; -/**************************** Tasklet Handler *********************************/ - -/* - * In 2.4.X and above, this routine is called from a tasklet, - * so we must re-acquire our lock prior to executing this code. - * In all prior kernels, ahd_schedule_runq() calls this routine - * directly and ahd_schedule_runq() is called with our lock held. - */ -static void -ahd_runq_tasklet(unsigned long data) -{ - struct ahd_softc* ahd; - struct ahd_linux_device *dev; - u_long flags; - - ahd = (struct ahd_softc *)data; - ahd_lock(ahd, &flags); - while ((dev = ahd_linux_next_device_to_run(ahd)) != NULL) { - - TAILQ_REMOVE(&ahd->platform_data->device_runq, dev, links); - dev->flags &= ~AHD_DEV_ON_RUN_LIST; - ahd_linux_check_device_queue(ahd, dev); - /* Yeild to our interrupt handler */ - ahd_unlock(ahd, &flags); - ahd_lock(ahd, &flags); - } - ahd_unlock(ahd, &flags); -} - /******************************** Bus DMA *************************************/ int ahd_dma_tag_create(struct ahd_softc *ahd, bus_dma_tag_t parent, @@ -1997,11 +1642,7 @@ ahd_linux_register_host(struct ahd_softc *ahd, Scsi_Host_Template *template) *((struct ahd_softc **)host->hostdata) = ahd; ahd_lock(ahd, &s); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) scsi_assign_lock(host, &ahd->platform_data->spin_lock); -#elif AHD_SCSI_HAS_HOST_LOCK != 0 - host->lock = &ahd->platform_data->spin_lock; -#endif ahd->platform_data->host = host; host->can_queue = AHD_MAX_QUEUE; host->cmd_per_lun = 2; @@ -2020,9 +1661,6 @@ ahd_linux_register_host(struct ahd_softc *ahd, Scsi_Host_Template *template) ahd_set_name(ahd, new_name); } host->unique_id = ahd->unit; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - scsi_set_pci_device(host, ahd->dev_softc); -#endif ahd_linux_setup_user_rd_strm_settings(ahd); ahd_linux_initialize_scsi_bus(ahd); ahd_unlock(ahd, &s); @@ -2064,10 +1702,8 @@ ahd_linux_register_host(struct ahd_softc *ahd, Scsi_Host_Template *template) ahd_linux_start_dv(ahd); ahd_unlock(ahd, &s); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) scsi_add_host(host, &ahd->dev_softc->dev); /* XXX handle failure */ scsi_scan_host(host); -#endif return (0); } @@ -2163,7 +1799,6 @@ ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg) return (ENOMEM); memset(ahd->platform_data, 0, sizeof(struct ahd_platform_data)); TAILQ_INIT(&ahd->platform_data->completeq); - TAILQ_INIT(&ahd->platform_data->device_runq); ahd->platform_data->irq = AHD_LINUX_NOIRQ; ahd->platform_data->hw_dma_mask = 0xFFFFFFFF; ahd_lockinit(ahd); @@ -2175,7 +1810,6 @@ ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg) init_MUTEX_LOCKED(&ahd->platform_data->eh_sem); init_MUTEX_LOCKED(&ahd->platform_data->dv_sem); init_MUTEX_LOCKED(&ahd->platform_data->dv_cmd_sem); - ahd_setup_runq_tasklet(ahd); ahd->seltime = (aic79xx_seltime & 0x3) << 4; return (0); } @@ -2190,11 +1824,8 @@ ahd_platform_free(struct ahd_softc *ahd) if (ahd->platform_data != NULL) { del_timer_sync(&ahd->platform_data->completeq_timer); ahd_linux_kill_dv_thread(ahd); - ahd_teardown_runq_tasklet(ahd); if (ahd->platform_data->host != NULL) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) scsi_remove_host(ahd->platform_data->host); -#endif scsi_host_put(ahd->platform_data->host); } @@ -2233,16 +1864,6 @@ ahd_platform_free(struct ahd_softc *ahd) release_mem_region(ahd->platform_data->mem_busaddr, 0x1000); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - /* - * In 2.4 we detach from the scsi midlayer before the PCI - * layer invokes our remove callback. No per-instance - * detach is provided, so we must reach inside the PCI - * subsystem's internals and detach our driver manually. - */ - if (ahd->dev_softc != NULL) - ahd->dev_softc->driver = NULL; -#endif free(ahd->platform_data, M_DEVBUF); } } @@ -2339,7 +1960,7 @@ ahd_platform_set_tags(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, dev->maxtags = 0; dev->openings = 1 - dev->active; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) + if (dev->scsi_device != NULL) { switch ((dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED))) { case AHD_DEV_Q_BASIC: @@ -2365,65 +1986,13 @@ ahd_platform_set_tags(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, break; } } -#endif } int ahd_platform_abort_scbs(struct ahd_softc *ahd, int target, char channel, int lun, u_int tag, role_t role, uint32_t status) { - int targ; - int maxtarg; - int maxlun; - int clun; - int count; - - if (tag != SCB_LIST_NULL) - return (0); - - targ = 0; - if (target != CAM_TARGET_WILDCARD) { - targ = target; - maxtarg = targ + 1; - } else { - maxtarg = (ahd->features & AHD_WIDE) ? 16 : 8; - } - clun = 0; - if (lun != CAM_LUN_WILDCARD) { - clun = lun; - maxlun = clun + 1; - } else { - maxlun = AHD_NUM_LUNS; - } - - count = 0; - for (; targ < maxtarg; targ++) { - - for (; clun < maxlun; clun++) { - struct ahd_linux_device *dev; - struct ahd_busyq *busyq; - struct ahd_cmd *acmd; - - dev = ahd_linux_get_device(ahd, /*chan*/0, targ, - clun, /*alloc*/FALSE); - if (dev == NULL) - continue; - - busyq = &dev->busyq; - while ((acmd = TAILQ_FIRST(busyq)) != NULL) { - Scsi_Cmnd *cmd; - - cmd = &acmd_scsi_cmd(acmd); - TAILQ_REMOVE(busyq, acmd, - acmd_links.tqe); - count++; - cmd->result = status << 16; - ahd_linux_queue_cmd_complete(ahd, cmd); - } - } - } - - return (count); + return 0; } static void @@ -2478,18 +2047,10 @@ ahd_linux_dv_thread(void *data) * Complete thread creation. */ lock_kernel(); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,60) - /* - * Don't care about any signals. - */ - siginitsetinv(¤t->blocked, 0); - daemonize(); - sprintf(current->comm, "ahd_dv_%d", ahd->unit); -#else daemonize("ahd_dv_%d", ahd->unit); - current->flags |= PF_NOFREEZE; -#endif + current->flags |= PF_FREEZE; + unlock_kernel(); while (1) { @@ -3685,8 +3246,6 @@ ahd_linux_dv_timeout(struct scsi_cmnd *cmd) ahd->platform_data->reset_timer.function = (ahd_linux_callback_t *)ahd_release_simq; add_timer(&ahd->platform_data->reset_timer); - if (ahd_linux_next_device_to_run(ahd) != NULL) - ahd_schedule_runq(ahd); ahd_linux_run_complete_queue(ahd); ahd_unlock(ahd, &flags); } @@ -3903,11 +3462,10 @@ ahd_linux_device_queue_depth(struct ahd_softc *ahd, } } -static void -ahd_linux_run_device_queue(struct ahd_softc *ahd, struct ahd_linux_device *dev) +static int +ahd_linux_run_command(struct ahd_softc *ahd, struct ahd_linux_device *dev, + struct scsi_cmnd *cmd) { - struct ahd_cmd *acmd; - struct scsi_cmnd *cmd; struct scb *scb; struct hardware_scb *hscb; struct ahd_initiator_tinfo *tinfo; @@ -3915,157 +3473,132 @@ ahd_linux_run_device_queue(struct ahd_softc *ahd, struct ahd_linux_device *dev) u_int col_idx; uint16_t mask; - if ((dev->flags & AHD_DEV_ON_RUN_LIST) != 0) - panic("running device on run list"); - - while ((acmd = TAILQ_FIRST(&dev->busyq)) != NULL - && dev->openings > 0 && dev->qfrozen == 0) { - - /* - * Schedule us to run later. The only reason we are not - * running is because the whole controller Q is frozen. - */ - if (ahd->platform_data->qfrozen != 0 - && AHD_DV_SIMQ_FROZEN(ahd) == 0) { - - TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq, - dev, links); - dev->flags |= AHD_DEV_ON_RUN_LIST; - return; - } + /* + * Get an scb to use. + */ + tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, + cmd->device->id, &tstate); + if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) == 0 + || (tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) { + col_idx = AHD_NEVER_COL_IDX; + } else { + col_idx = AHD_BUILD_COL_IDX(cmd->device->id, + cmd->device->lun); + } + if ((scb = ahd_get_scb(ahd, col_idx)) == NULL) { + ahd->flags |= AHD_RESOURCE_SHORTAGE; + return SCSI_MLQUEUE_HOST_BUSY; + } - cmd = &acmd_scsi_cmd(acmd); + scb->io_ctx = cmd; + scb->platform_data->dev = dev; + hscb = scb->hscb; + cmd->host_scribble = (char *)scb; - /* - * Get an scb to use. - */ - tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, - cmd->device->id, &tstate); - if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) == 0 - || (tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) { - col_idx = AHD_NEVER_COL_IDX; - } else { - col_idx = AHD_BUILD_COL_IDX(cmd->device->id, - cmd->device->lun); - } - if ((scb = ahd_get_scb(ahd, col_idx)) == NULL) { - TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq, - dev, links); - dev->flags |= AHD_DEV_ON_RUN_LIST; - ahd->flags |= AHD_RESOURCE_SHORTAGE; - return; - } - TAILQ_REMOVE(&dev->busyq, acmd, acmd_links.tqe); - scb->io_ctx = cmd; - scb->platform_data->dev = dev; - hscb = scb->hscb; - cmd->host_scribble = (char *)scb; + /* + * Fill out basics of the HSCB. + */ + hscb->control = 0; + hscb->scsiid = BUILD_SCSIID(ahd, cmd); + hscb->lun = cmd->device->lun; + scb->hscb->task_management = 0; + mask = SCB_GET_TARGET_MASK(ahd, scb); - /* - * Fill out basics of the HSCB. - */ - hscb->control = 0; - hscb->scsiid = BUILD_SCSIID(ahd, cmd); - hscb->lun = cmd->device->lun; - scb->hscb->task_management = 0; - mask = SCB_GET_TARGET_MASK(ahd, scb); + if ((ahd->user_discenable & mask) != 0) + hscb->control |= DISCENB; - if ((ahd->user_discenable & mask) != 0) - hscb->control |= DISCENB; + if (AHD_DV_CMD(cmd) != 0) + scb->flags |= SCB_SILENT; - if (AHD_DV_CMD(cmd) != 0) - scb->flags |= SCB_SILENT; + if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) + scb->flags |= SCB_PACKETIZED; - if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) - scb->flags |= SCB_PACKETIZED; + if ((tstate->auto_negotiate & mask) != 0) { + scb->flags |= SCB_AUTO_NEGOTIATE; + scb->hscb->control |= MK_MESSAGE; + } - if ((tstate->auto_negotiate & mask) != 0) { - scb->flags |= SCB_AUTO_NEGOTIATE; - scb->hscb->control |= MK_MESSAGE; - } + if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) != 0) { + int msg_bytes; + uint8_t tag_msgs[2]; - if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) != 0) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) - int msg_bytes; - uint8_t tag_msgs[2]; - - msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs); - if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) { - hscb->control |= tag_msgs[0]; - if (tag_msgs[0] == MSG_ORDERED_TASK) - dev->commands_since_idle_or_otag = 0; - } else -#endif - if (dev->commands_since_idle_or_otag == AHD_OTAG_THRESH - && (dev->flags & AHD_DEV_Q_TAGGED) != 0) { - hscb->control |= MSG_ORDERED_TASK; + msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs); + if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) { + hscb->control |= tag_msgs[0]; + if (tag_msgs[0] == MSG_ORDERED_TASK) dev->commands_since_idle_or_otag = 0; - } else { - hscb->control |= MSG_SIMPLE_TASK; - } + } else + if (dev->commands_since_idle_or_otag == AHD_OTAG_THRESH + && (dev->flags & AHD_DEV_Q_TAGGED) != 0) { + hscb->control |= MSG_ORDERED_TASK; + dev->commands_since_idle_or_otag = 0; + } else { + hscb->control |= MSG_SIMPLE_TASK; } + } - hscb->cdb_len = cmd->cmd_len; - memcpy(hscb->shared_data.idata.cdb, cmd->cmnd, hscb->cdb_len); - - scb->sg_count = 0; - ahd_set_residual(scb, 0); - ahd_set_sense_residual(scb, 0); - if (cmd->use_sg != 0) { - void *sg; - struct scatterlist *cur_seg; - u_int nseg; - int dir; - - cur_seg = (struct scatterlist *)cmd->request_buffer; - dir = cmd->sc_data_direction; - nseg = pci_map_sg(ahd->dev_softc, cur_seg, - cmd->use_sg, dir); - scb->platform_data->xfer_len = 0; - for (sg = scb->sg_list; nseg > 0; nseg--, cur_seg++) { - dma_addr_t addr; - bus_size_t len; - - addr = sg_dma_address(cur_seg); - len = sg_dma_len(cur_seg); - scb->platform_data->xfer_len += len; - sg = ahd_sg_setup(ahd, scb, sg, addr, len, - /*last*/nseg == 1); - } - } else if (cmd->request_bufflen != 0) { - void *sg; + hscb->cdb_len = cmd->cmd_len; + memcpy(hscb->shared_data.idata.cdb, cmd->cmnd, hscb->cdb_len); + + scb->sg_count = 0; + ahd_set_residual(scb, 0); + ahd_set_sense_residual(scb, 0); + if (cmd->use_sg != 0) { + void *sg; + struct scatterlist *cur_seg; + u_int nseg; + int dir; + + cur_seg = (struct scatterlist *)cmd->request_buffer; + dir = cmd->sc_data_direction; + nseg = pci_map_sg(ahd->dev_softc, cur_seg, + cmd->use_sg, dir); + scb->platform_data->xfer_len = 0; + for (sg = scb->sg_list; nseg > 0; nseg--, cur_seg++) { dma_addr_t addr; - int dir; - - sg = scb->sg_list; - dir = cmd->sc_data_direction; - addr = pci_map_single(ahd->dev_softc, - cmd->request_buffer, - cmd->request_bufflen, dir); - scb->platform_data->xfer_len = cmd->request_bufflen; - scb->platform_data->buf_busaddr = addr; - sg = ahd_sg_setup(ahd, scb, sg, addr, - cmd->request_bufflen, /*last*/TRUE); - } + bus_size_t len; - LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links); - dev->openings--; - dev->active++; - dev->commands_issued++; - - /* Update the error counting bucket and dump if needed */ - if (dev->target->cmds_since_error) { - dev->target->cmds_since_error++; - if (dev->target->cmds_since_error > - AHD_LINUX_ERR_THRESH) - dev->target->cmds_since_error = 0; + addr = sg_dma_address(cur_seg); + len = sg_dma_len(cur_seg); + scb->platform_data->xfer_len += len; + sg = ahd_sg_setup(ahd, scb, sg, addr, len, + /*last*/nseg == 1); } + } else if (cmd->request_bufflen != 0) { + void *sg; + dma_addr_t addr; + int dir; + + sg = scb->sg_list; + dir = cmd->sc_data_direction; + addr = pci_map_single(ahd->dev_softc, + cmd->request_buffer, + cmd->request_bufflen, dir); + scb->platform_data->xfer_len = cmd->request_bufflen; + scb->platform_data->buf_busaddr = addr; + sg = ahd_sg_setup(ahd, scb, sg, addr, + cmd->request_bufflen, /*last*/TRUE); + } - if ((dev->flags & AHD_DEV_PERIODIC_OTAG) != 0) - dev->commands_since_idle_or_otag++; - scb->flags |= SCB_ACTIVE; - ahd_queue_scb(ahd, scb); + LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links); + dev->openings--; + dev->active++; + dev->commands_issued++; + + /* Update the error counting bucket and dump if needed */ + if (dev->target->cmds_since_error) { + dev->target->cmds_since_error++; + if (dev->target->cmds_since_error > + AHD_LINUX_ERR_THRESH) + dev->target->cmds_since_error = 0; } + + if ((dev->flags & AHD_DEV_PERIODIC_OTAG) != 0) + dev->commands_since_idle_or_otag++; + scb->flags |= SCB_ACTIVE; + ahd_queue_scb(ahd, scb); + + return 0; } /* @@ -4081,8 +3614,6 @@ ahd_linux_isr(int irq, void *dev_id, struct pt_regs * regs) ahd = (struct ahd_softc *) dev_id; ahd_lock(ahd, &flags); ours = ahd_intr(ahd); - if (ahd_linux_next_device_to_run(ahd) != NULL) - ahd_schedule_runq(ahd); ahd_linux_run_complete_queue(ahd); ahd_unlock(ahd, &flags); return IRQ_RETVAL(ours); @@ -4161,7 +3692,6 @@ ahd_linux_alloc_device(struct ahd_softc *ahd, return (NULL); memset(dev, 0, sizeof(*dev)); init_timer(&dev->timer); - TAILQ_INIT(&dev->busyq); dev->flags = AHD_DEV_UNCONFIGURED; dev->lun = lun; dev->target = targ; @@ -4264,28 +3794,9 @@ ahd_send_async(struct ahd_softc *ahd, char channel, } case AC_SENT_BDR: { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) WARN_ON(lun != CAM_LUN_WILDCARD); scsi_report_device_reset(ahd->platform_data->host, channel - 'A', target); -#else - Scsi_Device *scsi_dev; - - /* - * Find the SCSI device associated with this - * request and indicate that a UA is expected. - */ - for (scsi_dev = ahd->platform_data->host->host_queue; - scsi_dev != NULL; scsi_dev = scsi_dev->next) { - if (channel - 'A' == scsi_dev->channel - && target == scsi_dev->id - && (lun == CAM_LUN_WILDCARD - || lun == scsi_dev->lun)) { - scsi_dev->was_reset = 1; - scsi_dev->expecting_cc_ua = 1; - } - } -#endif break; } case AC_BUS_RESET: @@ -4406,15 +3917,10 @@ ahd_done(struct ahd_softc *ahd, struct scb *scb) if (dev->active == 0) dev->commands_since_idle_or_otag = 0; - if (TAILQ_EMPTY(&dev->busyq)) { - if ((dev->flags & AHD_DEV_UNCONFIGURED) != 0 - && dev->active == 0 - && (dev->flags & AHD_DEV_TIMER_ACTIVE) == 0) - ahd_linux_free_device(ahd, dev); - } else if ((dev->flags & AHD_DEV_ON_RUN_LIST) == 0) { - TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq, dev, links); - dev->flags |= AHD_DEV_ON_RUN_LIST; - } + if ((dev->flags & AHD_DEV_UNCONFIGURED) != 0 + && dev->active == 0 + && (dev->flags & AHD_DEV_TIMER_ACTIVE) == 0) + ahd_linux_free_device(ahd, dev); if ((scb->flags & SCB_RECOVERY_SCB) != 0) { printf("Recovery SCB completes\n"); @@ -4887,7 +4393,6 @@ ahd_release_simq(struct ahd_softc *ahd) ahd->platform_data->flags &= ~AHD_DV_WAIT_SIMQ_RELEASE; up(&ahd->platform_data->dv_sem); } - ahd_schedule_runq(ahd); ahd_unlock(ahd, &s); /* * There is still a race here. The mid-layer @@ -4929,61 +4434,16 @@ ahd_linux_dev_timed_unfreeze(u_long arg) dev->flags &= ~AHD_DEV_TIMER_ACTIVE; if (dev->qfrozen > 0) dev->qfrozen--; - if (dev->qfrozen == 0 - && (dev->flags & AHD_DEV_ON_RUN_LIST) == 0) - ahd_linux_run_device_queue(ahd, dev); if ((dev->flags & AHD_DEV_UNCONFIGURED) != 0 && dev->active == 0) ahd_linux_free_device(ahd, dev); ahd_unlock(ahd, &s); } -void -ahd_platform_dump_card_state(struct ahd_softc *ahd) -{ - struct ahd_linux_device *dev; - int target; - int maxtarget; - int lun; - int i; - - maxtarget = (ahd->features & AHD_WIDE) ? 15 : 7; - for (target = 0; target <=maxtarget; target++) { - - for (lun = 0; lun < AHD_NUM_LUNS; lun++) { - struct ahd_cmd *acmd; - - dev = ahd_linux_get_device(ahd, 0, target, - lun, /*alloc*/FALSE); - if (dev == NULL) - continue; - - printf("DevQ(%d:%d:%d): ", 0, target, lun); - i = 0; - TAILQ_FOREACH(acmd, &dev->busyq, acmd_links.tqe) { - if (i++ > AHD_SCB_MAX) - break; - } - printf("%d waiting\n", i); - } - } -} - static int __init ahd_linux_init(void) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) return ahd_linux_detect(&aic79xx_driver_template); -#else - scsi_register_module(MODULE_SCSI_HA, &aic79xx_driver_template); - if (aic79xx_driver_template.present == 0) { - scsi_unregister_module(MODULE_SCSI_HA, - &aic79xx_driver_template); - return (-ENODEV); - } - - return (0); -#endif } static void __exit @@ -5002,14 +4462,6 @@ ahd_linux_exit(void) ahd_linux_kill_dv_thread(ahd); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - /* - * In 2.4 we have to unregister from the PCI core _after_ - * unregistering from the scsi midlayer to avoid dangling - * references. - */ - scsi_unregister_module(MODULE_SCSI_HA, &aic79xx_driver_template); -#endif ahd_linux_pci_exit(); } diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h index 7823e52e99a..792e97fef5b 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.h +++ b/drivers/scsi/aic7xxx/aic79xx_osm.h @@ -252,11 +252,7 @@ ahd_scb_timer_reset(struct scb *scb, u_int usec) /***************************** SMP support ************************************/ #include -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) || defined(SCSI_HAS_HOST_LOCK)) #define AHD_SCSI_HAS_HOST_LOCK 1 -#else -#define AHD_SCSI_HAS_HOST_LOCK 0 -#endif #define AIC79XX_DRIVER_VERSION "1.3.11" @@ -297,12 +293,11 @@ struct ahd_cmd { * after a successfully completed inquiry command to the target when * that inquiry data indicates a lun is present. */ -TAILQ_HEAD(ahd_busyq, ahd_cmd); + typedef enum { AHD_DEV_UNCONFIGURED = 0x01, AHD_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */ AHD_DEV_TIMER_ACTIVE = 0x04, /* Our timer is active */ - AHD_DEV_ON_RUN_LIST = 0x08, /* Queued to be run later */ AHD_DEV_Q_BASIC = 0x10, /* Allow basic device queuing */ AHD_DEV_Q_TAGGED = 0x20, /* Allow full SCSI2 command queueing */ AHD_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */ @@ -312,7 +307,6 @@ typedef enum { struct ahd_linux_target; struct ahd_linux_device { TAILQ_ENTRY(ahd_linux_device) links; - struct ahd_busyq busyq; /* * The number of transactions currently @@ -453,18 +447,7 @@ struct ahd_linux_target { * manner and are allocated below 4GB, the number of S/G segments is * unrestricted. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -/* - * We dynamically adjust the number of segments in pre-2.5 kernels to - * avoid fragmentation issues in the SCSI mid-layer's private memory - * allocator. See aic79xx_osm.c ahd_linux_size_nseg() for details. - */ -extern u_int ahd_linux_nseg; -#define AHD_NSEG ahd_linux_nseg -#define AHD_LINUX_MIN_NSEG 64 -#else #define AHD_NSEG 128 -#endif /* * Per-SCB OSM storage. @@ -502,11 +485,9 @@ struct ahd_platform_data { * Fields accessed from interrupt context. */ struct ahd_linux_target *targets[AHD_NUM_TARGETS]; - TAILQ_HEAD(, ahd_linux_device) device_runq; struct ahd_completeq completeq; spinlock_t spin_lock; - struct tasklet_struct runq_tasklet; u_int qfrozen; pid_t dv_pid; struct timer_list completeq_timer; @@ -925,12 +906,8 @@ ahd_flush_device_writes(struct ahd_softc *ahd) } /**************************** Proc FS Support *********************************/ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -int ahd_linux_proc_info(char *, char **, off_t, int, int, int); -#else int ahd_linux_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int); -#endif /*************************** Domain Validation ********************************/ #define AHD_DV_CMD(cmd) ((cmd)->scsi_done == ahd_linux_dv_complete) @@ -1117,7 +1094,6 @@ void ahd_done(struct ahd_softc*, struct scb*); void ahd_send_async(struct ahd_softc *, char channel, u_int target, u_int lun, ac_code, void *); void ahd_print_path(struct ahd_softc *, struct scb *); -void ahd_platform_dump_card_state(struct ahd_softc *ahd); #ifdef CONFIG_PCI #define AHD_PCI_CONFIG 1 diff --git a/drivers/scsi/aic7xxx/aic79xx_proc.c b/drivers/scsi/aic7xxx/aic79xx_proc.c index e01cd6175e3..9c631a494ed 100644 --- a/drivers/scsi/aic7xxx/aic79xx_proc.c +++ b/drivers/scsi/aic7xxx/aic79xx_proc.c @@ -278,13 +278,8 @@ done: * Return information to handle /proc support for the driver. */ int -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -ahd_linux_proc_info(char *buffer, char **start, off_t offset, - int length, int hostno, int inout) -#else ahd_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset, int length, int inout) -#endif { struct ahd_softc *ahd; struct info_str info; @@ -296,14 +291,7 @@ ahd_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, retval = -EINVAL; ahd_list_lock(&l); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - TAILQ_FOREACH(ahd, &ahd_tailq, links) { - if (ahd->platform_data->host->host_no == hostno) - break; - } -#else ahd = ahd_find_softc(*(struct ahd_softc **)shost->hostdata); -#endif if (ahd == NULL) goto done; -- cgit v1.2.3-18-g5258 From 73a25462100772b72a5d62fd66dff01b53018618 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 22 Jul 2005 16:44:04 +0200 Subject: [SCSI] aic79xx: update to use scsi_transport_spi This patch updates the aic79xx driver to take advantage of the scsi_transport_spi infrastructure. Patch is quite a mess as some procedures have been reshuffled to be closer to the aic7xxx driver. Rejections fixed and Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_osm.c | 5253 +++++++++++------------------------ drivers/scsi/aic7xxx/aic79xx_osm.h | 197 +- drivers/scsi/aic7xxx/aic79xx_proc.c | 18 +- 3 files changed, 1715 insertions(+), 3753 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 7463dd515d1..70997ca28ba 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -46,6 +46,8 @@ #include "aic79xx_inline.h" #include +static struct scsi_transport_template *ahd_linux_transport_template = NULL; + /* * Include aiclib.c as part of our * "module dependencies are hard" work around. @@ -54,6 +56,7 @@ #include /* __setup */ #include /* For fetching system memory size */ +#include /* For block_size() */ #include /* For ssleep/msleep */ /* @@ -177,71 +180,6 @@ static adapter_tag_info_t aic79xx_tag_info[] = {AIC79XX_CONFIGED_TAG_COMMANDS} }; -/* - * By default, read streaming is disabled. In theory, - * read streaming should enhance performance, but early - * U320 drive firmware actually performs slower with - * read streaming enabled. - */ -#ifdef CONFIG_AIC79XX_ENABLE_RD_STRM -#define AIC79XX_CONFIGED_RD_STRM 0xFFFF -#else -#define AIC79XX_CONFIGED_RD_STRM 0 -#endif - -static uint16_t aic79xx_rd_strm_info[] = -{ - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM, - AIC79XX_CONFIGED_RD_STRM -}; - -/* - * DV option: - * - * positive value = DV Enabled - * zero = DV Disabled - * negative value = DV Default for adapter type/seeprom - */ -#ifdef CONFIG_AIC79XX_DV_SETTING -#define AIC79XX_CONFIGED_DV CONFIG_AIC79XX_DV_SETTING -#else -#define AIC79XX_CONFIGED_DV -1 -#endif - -static int8_t aic79xx_dv_settings[] = -{ - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV, - AIC79XX_CONFIGED_DV -}; - /* * The I/O cell on the chip is very configurable in respect to its analog * characteristics. Set the defaults here; they can be overriden with @@ -402,7 +340,7 @@ MODULE_AUTHOR("Maintainer: Justin T. Gibbs "); MODULE_DESCRIPTION("Adaptec Aic790X U320 SCSI Host Bus Adapter driver"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_VERSION(AIC79XX_DRIVER_VERSION); -module_param(aic79xx, charp, 0); +module_param(aic79xx, charp, 0444); MODULE_PARM_DESC(aic79xx, "period delimited, options string.\n" " verbose Enable verbose/diagnostic logging\n" @@ -417,8 +355,6 @@ MODULE_PARM_DESC(aic79xx, " reverse_scan Sort PCI devices highest Bus/Slot to lowest\n" " tag_info: Set per-target tag depth\n" " global_tag_depth: Global tag depth for all targets on all buses\n" -" rd_strm: Set per-target read streaming setting.\n" -" dv: Set per-controller Domain Validation Setting.\n" " slewrate:Set the signal slew rate (0-15).\n" " precomp: Set the signal precompensation (0-7).\n" " amplitude: Set the signal amplitude (0-7).\n" @@ -431,178 +367,35 @@ MODULE_PARM_DESC(aic79xx, " Shorten the selection timeout to 128ms\n" "\n" " options aic79xx 'aic79xx=verbose.tag_info:{{}.{}.{..10}}.seltime:1'\n" -"\n" -" Sample /etc/modprobe.conf line:\n" -" Change Read Streaming for Controller's 2 and 3\n" -"\n" -" options aic79xx 'aic79xx=rd_strm:{..0xFFF0.0xC0F0}'"); +"\n"); static void ahd_linux_handle_scsi_status(struct ahd_softc *, - struct ahd_linux_device *, + struct scsi_device *, struct scb *); static void ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, - Scsi_Cmnd *cmd); -static void ahd_linux_filter_inquiry(struct ahd_softc *ahd, - struct ahd_devinfo *devinfo); -static void ahd_linux_dev_timed_unfreeze(u_long arg); + struct scsi_cmnd *cmd); static void ahd_linux_sem_timeout(u_long arg); +static int ahd_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag); static void ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd); -static void ahd_linux_thread_run_complete_queue(struct ahd_softc *ahd); -static void ahd_linux_start_dv(struct ahd_softc *ahd); -static void ahd_linux_dv_timeout(struct scsi_cmnd *cmd); -static int ahd_linux_dv_thread(void *data); -static void ahd_linux_kill_dv_thread(struct ahd_softc *ahd); -static void ahd_linux_dv_target(struct ahd_softc *ahd, u_int target); -static void ahd_linux_dv_transition(struct ahd_softc *ahd, - struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo, - struct ahd_linux_target *targ); -static void ahd_linux_dv_fill_cmd(struct ahd_softc *ahd, - struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo); -static void ahd_linux_dv_inq(struct ahd_softc *ahd, - struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo, - struct ahd_linux_target *targ, - u_int request_length); -static void ahd_linux_dv_tur(struct ahd_softc *ahd, - struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo); -static void ahd_linux_dv_rebd(struct ahd_softc *ahd, - struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo, - struct ahd_linux_target *targ); -static void ahd_linux_dv_web(struct ahd_softc *ahd, - struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo, - struct ahd_linux_target *targ); -static void ahd_linux_dv_reb(struct ahd_softc *ahd, - struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo, - struct ahd_linux_target *targ); -static void ahd_linux_dv_su(struct ahd_softc *ahd, - struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo, - struct ahd_linux_target *targ); -static int ahd_linux_fallback(struct ahd_softc *ahd, - struct ahd_devinfo *devinfo); -static __inline int ahd_linux_dv_fallback(struct ahd_softc *ahd, - struct ahd_devinfo *devinfo); -static void ahd_linux_dv_complete(Scsi_Cmnd *cmd); -static void ahd_linux_generate_dv_pattern(struct ahd_linux_target *targ); static u_int ahd_linux_user_tagdepth(struct ahd_softc *ahd, struct ahd_devinfo *devinfo); -static u_int ahd_linux_user_dv_setting(struct ahd_softc *ahd); -static void ahd_linux_setup_user_rd_strm_settings(struct ahd_softc *ahd); -static void ahd_linux_device_queue_depth(struct ahd_softc *ahd, - struct ahd_linux_device *dev); -static struct ahd_linux_target* ahd_linux_alloc_target(struct ahd_softc*, - u_int, u_int); -static void ahd_linux_free_target(struct ahd_softc*, - struct ahd_linux_target*); -static struct ahd_linux_device* ahd_linux_alloc_device(struct ahd_softc*, - struct ahd_linux_target*, - u_int); -static void ahd_linux_free_device(struct ahd_softc*, - struct ahd_linux_device*); +static void ahd_linux_device_queue_depth(struct scsi_device *); static int ahd_linux_run_command(struct ahd_softc*, - struct ahd_linux_device*, + struct ahd_linux_device *, struct scsi_cmnd *); static void ahd_linux_setup_tag_info_global(char *p); static aic_option_callback_t ahd_linux_setup_tag_info; -static aic_option_callback_t ahd_linux_setup_rd_strm_info; -static aic_option_callback_t ahd_linux_setup_dv; static aic_option_callback_t ahd_linux_setup_iocell_info; -static int ahd_linux_next_unit(void); -static int aic79xx_setup(char *c); +static int aic79xx_setup(char *c); +static int ahd_linux_next_unit(void); /****************************** Inlines ***************************************/ -static __inline void ahd_schedule_completeq(struct ahd_softc *ahd); -static __inline struct ahd_linux_device* - ahd_linux_get_device(struct ahd_softc *ahd, u_int channel, - u_int target, u_int lun, int alloc); -static struct ahd_cmd *ahd_linux_run_complete_queue(struct ahd_softc *ahd); static __inline void ahd_linux_unmap_scb(struct ahd_softc*, struct scb*); -static __inline void -ahd_schedule_completeq(struct ahd_softc *ahd) -{ - if ((ahd->platform_data->flags & AHD_RUN_CMPLT_Q_TIMER) == 0) { - ahd->platform_data->flags |= AHD_RUN_CMPLT_Q_TIMER; - ahd->platform_data->completeq_timer.expires = jiffies; - add_timer(&ahd->platform_data->completeq_timer); - } -} - -static __inline struct ahd_linux_device* -ahd_linux_get_device(struct ahd_softc *ahd, u_int channel, u_int target, - u_int lun, int alloc) -{ - struct ahd_linux_target *targ; - struct ahd_linux_device *dev; - u_int target_offset; - - target_offset = target; - if (channel != 0) - target_offset += 8; - targ = ahd->platform_data->targets[target_offset]; - if (targ == NULL) { - if (alloc != 0) { - targ = ahd_linux_alloc_target(ahd, channel, target); - if (targ == NULL) - return (NULL); - } else - return (NULL); - } - dev = targ->devices[lun]; - if (dev == NULL && alloc != 0) - dev = ahd_linux_alloc_device(ahd, targ, lun); - return (dev); -} - -#define AHD_LINUX_MAX_RETURNED_ERRORS 4 -static struct ahd_cmd * -ahd_linux_run_complete_queue(struct ahd_softc *ahd) -{ - struct ahd_cmd *acmd; - u_long done_flags; - int with_errors; - - with_errors = 0; - ahd_done_lock(ahd, &done_flags); - while ((acmd = TAILQ_FIRST(&ahd->platform_data->completeq)) != NULL) { - Scsi_Cmnd *cmd; - - if (with_errors > AHD_LINUX_MAX_RETURNED_ERRORS) { - /* - * Linux uses stack recursion to requeue - * commands that need to be retried. Avoid - * blowing out the stack by "spoon feeding" - * commands that completed with error back - * the operating system in case they are going - * to be retried. "ick" - */ - ahd_schedule_completeq(ahd); - break; - } - TAILQ_REMOVE(&ahd->platform_data->completeq, - acmd, acmd_links.tqe); - cmd = &acmd_scsi_cmd(acmd); - cmd->host_scribble = NULL; - if (ahd_cmd_get_transaction_status(cmd) != DID_OK - || (cmd->result & 0xFF) != SCSI_STATUS_OK) - with_errors++; - - cmd->scsi_done(cmd); - } - ahd_done_unlock(ahd, &done_flags); - return (acmd); -} - static __inline void ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb) { - Scsi_Cmnd *cmd; + struct scsi_cmnd *cmd; int direction; cmd = scb->io_ctx; @@ -624,51 +417,21 @@ ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb) #define BUILD_SCSIID(ahd, cmd) \ ((((cmd)->device->id << TID_SHIFT) & TID) | (ahd)->our_id) -/************************ Host template entry points *************************/ -static int ahd_linux_detect(Scsi_Host_Template *); -static const char *ahd_linux_info(struct Scsi_Host *); -static int ahd_linux_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *)); -static int ahd_linux_slave_alloc(Scsi_Device *); -static int ahd_linux_slave_configure(Scsi_Device *); -static void ahd_linux_slave_destroy(Scsi_Device *); -#if defined(__i386__) -static int ahd_linux_biosparam(struct scsi_device*, - struct block_device*, sector_t, int[]); -#endif -static int ahd_linux_bus_reset(Scsi_Cmnd *); -static int ahd_linux_dev_reset(Scsi_Cmnd *); -static int ahd_linux_abort(Scsi_Cmnd *); - - /* * Try to detect an Adaptec 79XX controller. */ static int -ahd_linux_detect(Scsi_Host_Template *template) +ahd_linux_detect(struct scsi_host_template *template) { struct ahd_softc *ahd; int found; int error = 0; - /* - * Sanity checking of Linux SCSI data structures so - * that some of our hacks^H^H^H^H^Hassumptions aren't - * violated. - */ - if (offsetof(struct ahd_cmd_internal, end) - > offsetof(struct scsi_cmnd, host_scribble)) { - printf("ahd_linux_detect: SCSI data structures changed.\n"); - printf("ahd_linux_detect: Unable to attach\n"); - return (0); - } - -#ifdef MODULE /* * If we've been passed any parameters, process them now. */ if (aic79xx) aic79xx_setup(aic79xx); -#endif template->proc_name = "aic79xx"; @@ -695,7 +458,7 @@ ahd_linux_detect(Scsi_Host_Template *template) found++; } aic79xx_detect_complete++; - return 0; + return found; } /* @@ -730,10 +493,10 @@ ahd_linux_info(struct Scsi_Host *host) * Queue an SCB to the controller. */ static int -ahd_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *)) +ahd_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *)) { struct ahd_softc *ahd; - struct ahd_linux_device *dev; + struct ahd_linux_device *dev = scsi_transport_device_data(cmd->device); ahd = *(struct ahd_softc **)cmd->device->host->hostdata; @@ -743,8 +506,7 @@ ahd_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *)) * DV commands through so long as we are only frozen to * perform DV. */ - if (ahd->platform_data->qfrozen != 0 - && AHD_DV_CMD(cmd) == 0) { + if (ahd->platform_data->qfrozen != 0) { printf("%s: queue frozen\n", ahd_name(ahd)); return SCSI_MLQUEUE_HOST_BUSY; @@ -755,86 +517,142 @@ ahd_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *)) */ cmd->scsi_done = scsi_done; - dev = ahd_linux_get_device(ahd, cmd->device->channel, - cmd->device->id, cmd->device->lun, - /*alloc*/TRUE); - BUG_ON(dev == NULL); - cmd->result = CAM_REQ_INPROG << 16; return ahd_linux_run_command(ahd, dev, cmd); } +static inline struct scsi_target ** +ahd_linux_target_in_softc(struct scsi_target *starget) +{ + struct ahd_softc *ahd = + *((struct ahd_softc **)dev_to_shost(&starget->dev)->hostdata); + unsigned int target_offset; + + target_offset = starget->id; + if (starget->channel != 0) + target_offset += 8; + + return &ahd->platform_data->starget[target_offset]; +} + static int -ahd_linux_slave_alloc(Scsi_Device *device) +ahd_linux_target_alloc(struct scsi_target *starget) { - struct ahd_softc *ahd; + struct ahd_softc *ahd = + *((struct ahd_softc **)dev_to_shost(&starget->dev)->hostdata); + unsigned long flags; + struct scsi_target **ahd_targp = ahd_linux_target_in_softc(starget); + struct ahd_linux_target *targ = scsi_transport_target_data(starget); + struct ahd_devinfo devinfo; + struct ahd_initiator_tinfo *tinfo; + struct ahd_tmode_tstate *tstate; + char channel = starget->channel + 'A'; - ahd = *((struct ahd_softc **)device->host->hostdata); - if (bootverbose) - printf("%s: Slave Alloc %d\n", ahd_name(ahd), device->id); - return (0); + ahd_lock(ahd, &flags); + + BUG_ON(*ahd_targp != NULL); + + *ahd_targp = starget; + memset(targ, 0, sizeof(*targ)); + + tinfo = ahd_fetch_transinfo(ahd, channel, ahd->our_id, + starget->id, &tstate); + ahd_compile_devinfo(&devinfo, ahd->our_id, starget->id, + CAM_LUN_WILDCARD, channel, + ROLE_INITIATOR); + spi_min_period(starget) = AHD_SYNCRATE_MAX; /* We can do U320 */ + if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) + spi_max_offset(starget) = MAX_OFFSET_PACED_BUG; + else + spi_max_offset(starget) = MAX_OFFSET_PACED; + spi_max_width(starget) = ahd->features & AHD_WIDE; + + ahd_set_syncrate(ahd, &devinfo, 0, 0, 0, + AHD_TRANS_GOAL, /*paused*/FALSE); + ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, + AHD_TRANS_GOAL, /*paused*/FALSE); + ahd_unlock(ahd, &flags); + + return 0; +} + +static void +ahd_linux_target_destroy(struct scsi_target *starget) +{ + struct scsi_target **ahd_targp = ahd_linux_target_in_softc(starget); + + *ahd_targp = NULL; } static int -ahd_linux_slave_configure(Scsi_Device *device) +ahd_linux_slave_alloc(struct scsi_device *sdev) { - struct ahd_softc *ahd; - struct ahd_linux_device *dev; - u_long flags; + struct ahd_softc *ahd = + *((struct ahd_softc **)sdev->host->hostdata); + struct scsi_target *starget = sdev->sdev_target; + struct ahd_linux_target *targ = scsi_transport_target_data(starget); + struct ahd_linux_device *dev; - ahd = *((struct ahd_softc **)device->host->hostdata); if (bootverbose) - printf("%s: Slave Configure %d\n", ahd_name(ahd), device->id); - ahd_midlayer_entrypoint_lock(ahd, &flags); + printf("%s: Slave Alloc %d\n", ahd_name(ahd), sdev->id); + + BUG_ON(targ->sdev[sdev->lun] != NULL); + + dev = scsi_transport_device_data(sdev); + memset(dev, 0, sizeof(*dev)); + + /* + * We start out life using untagged + * transactions of which we allow one. + */ + dev->openings = 1; + /* - * Since Linux has attached to the device, configure - * it so we don't free and allocate the device - * structure on every command. + * Set maxtags to 0. This will be changed if we + * later determine that we are dealing with + * a tagged queuing capable device. */ - dev = ahd_linux_get_device(ahd, device->channel, - device->id, device->lun, - /*alloc*/TRUE); - if (dev != NULL) { - dev->flags &= ~AHD_DEV_UNCONFIGURED; - dev->flags |= AHD_DEV_SLAVE_CONFIGURED; - dev->scsi_device = device; - ahd_linux_device_queue_depth(ahd, dev); - } - ahd_midlayer_entrypoint_unlock(ahd, &flags); + dev->maxtags = 0; + + targ->sdev[sdev->lun] = sdev; + return (0); } +static int +ahd_linux_slave_configure(struct scsi_device *sdev) +{ + struct ahd_softc *ahd; + + ahd = *((struct ahd_softc **)sdev->host->hostdata); + if (bootverbose) + printf("%s: Slave Configure %d\n", ahd_name(ahd), sdev->id); + + ahd_linux_device_queue_depth(sdev); + + /* Initial Domain Validation */ + if (!spi_initial_dv(sdev->sdev_target)) + spi_dv_device(sdev); + + return 0; +} + static void -ahd_linux_slave_destroy(Scsi_Device *device) +ahd_linux_slave_destroy(struct scsi_device *sdev) { struct ahd_softc *ahd; - struct ahd_linux_device *dev; - u_long flags; + struct ahd_linux_device *dev = scsi_transport_device_data(sdev); + struct ahd_linux_target *targ = scsi_transport_target_data(sdev->sdev_target); - ahd = *((struct ahd_softc **)device->host->hostdata); + ahd = *((struct ahd_softc **)sdev->host->hostdata); if (bootverbose) - printf("%s: Slave Destroy %d\n", ahd_name(ahd), device->id); - ahd_midlayer_entrypoint_lock(ahd, &flags); - dev = ahd_linux_get_device(ahd, device->channel, - device->id, device->lun, - /*alloc*/FALSE); + printf("%s: Slave Destroy %d\n", ahd_name(ahd), sdev->id); + + BUG_ON(dev->active); + + targ->sdev[sdev->lun] = NULL; - /* - * Filter out "silly" deletions of real devices by only - * deleting devices that have had slave_configure() - * called on them. All other devices that have not - * been configured will automatically be deleted by - * the refcounting process. - */ - if (dev != NULL - && (dev->flags & AHD_DEV_SLAVE_CONFIGURED) != 0) { - dev->flags |= AHD_DEV_UNCONFIGURED; - if (dev->active == 0 - && (dev->flags & AHD_DEV_TIMER_ACTIVE) == 0) - ahd_linux_free_device(ahd, dev); - } - ahd_midlayer_entrypoint_unlock(ahd, &flags); } #if defined(__i386__) @@ -887,3582 +705,1861 @@ ahd_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev, * Abort the current SCSI command(s). */ static int -ahd_linux_abort(Scsi_Cmnd *cmd) +ahd_linux_abort(struct scsi_cmnd *cmd) +{ + int error; + + error = ahd_linux_queue_recovery_cmd(cmd, SCB_ABORT); + if (error != 0) + printf("aic79xx_abort returns 0x%x\n", error); + return error; +} + +/* + * Attempt to send a target reset message to the device that timed out. + */ +static int +ahd_linux_dev_reset(struct scsi_cmnd *cmd) +{ + int error; + + error = ahd_linux_queue_recovery_cmd(cmd, SCB_DEVICE_RESET); + if (error != 0) + printf("aic79xx_dev_reset returns 0x%x\n", error); + return error; +} + +/* + * Reset the SCSI bus. + */ +static int +ahd_linux_bus_reset(struct scsi_cmnd *cmd) { struct ahd_softc *ahd; - struct ahd_cmd *acmd; - struct ahd_linux_device *dev; - struct scb *pending_scb; u_long s; - u_int saved_scbptr; - u_int active_scbptr; - u_int last_phase; - u_int cdb_byte; - int retval; - int was_paused; - int paused; - int wait; - int disconnected; - ahd_mode_state saved_modes; + int found; - pending_scb = NULL; - paused = FALSE; - wait = FALSE; ahd = *(struct ahd_softc **)cmd->device->host->hostdata; - acmd = (struct ahd_cmd *)cmd; +#ifdef AHD_DEBUG + if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) + printf("%s: Bus reset called for cmd %p\n", + ahd_name(ahd), cmd); +#endif + ahd_lock(ahd, &s); + found = ahd_reset_channel(ahd, cmd->device->channel + 'A', + /*initiate reset*/TRUE); + ahd_unlock(ahd, &s); - printf("%s:%d:%d:%d: Attempting to abort cmd %p:", - ahd_name(ahd), cmd->device->channel, cmd->device->id, - cmd->device->lun, cmd); - for (cdb_byte = 0; cdb_byte < cmd->cmd_len; cdb_byte++) - printf(" 0x%x", cmd->cmnd[cdb_byte]); - printf("\n"); + if (bootverbose) + printf("%s: SCSI bus reset delivered. " + "%d SCBs aborted.\n", ahd_name(ahd), found); - /* - * In all versions of Linux, we have to work around - * a major flaw in how the mid-layer is locked down - * if we are to sleep successfully in our error handler - * while allowing our interrupt handler to run. Since - * the midlayer acquires either the io_request_lock or - * our lock prior to calling us, we must use the - * spin_unlock_irq() method for unlocking our lock. - * This will force interrupts to be enabled on the - * current CPU. Since the EH thread should not have - * been running with CPU interrupts disabled other than - * by acquiring either the io_request_lock or our own - * lock, this *should* be safe. - */ - ahd_midlayer_entrypoint_lock(ahd, &s); + return (SUCCESS); +} - /* - * First determine if we currently own this command. - * Start by searching the device queue. If not found - * there, check the pending_scb list. If not found - * at all, and the system wanted us to just abort the - * command, return success. - */ - dev = ahd_linux_get_device(ahd, cmd->device->channel, - cmd->device->id, cmd->device->lun, - /*alloc*/FALSE); +struct scsi_host_template aic79xx_driver_template = { + .module = THIS_MODULE, + .name = "aic79xx", + .proc_info = ahd_linux_proc_info, + .info = ahd_linux_info, + .queuecommand = ahd_linux_queue, + .eh_abort_handler = ahd_linux_abort, + .eh_device_reset_handler = ahd_linux_dev_reset, + .eh_bus_reset_handler = ahd_linux_bus_reset, +#if defined(__i386__) + .bios_param = ahd_linux_biosparam, +#endif + .can_queue = AHD_MAX_QUEUE, + .this_id = -1, + .cmd_per_lun = 2, + .use_clustering = ENABLE_CLUSTERING, + .slave_alloc = ahd_linux_slave_alloc, + .slave_configure = ahd_linux_slave_configure, + .slave_destroy = ahd_linux_slave_destroy, + .target_alloc = ahd_linux_target_alloc, + .target_destroy = ahd_linux_target_destroy, +}; - if (dev == NULL) { - /* - * No target device for this command exists, - * so we must not still own the command. - */ - printf("%s:%d:%d:%d: Is not an active device\n", - ahd_name(ahd), cmd->device->channel, cmd->device->id, - cmd->device->lun); - retval = SUCCESS; - goto no_cmd; - } +/******************************** Bus DMA *************************************/ +int +ahd_dma_tag_create(struct ahd_softc *ahd, bus_dma_tag_t parent, + bus_size_t alignment, bus_size_t boundary, + dma_addr_t lowaddr, dma_addr_t highaddr, + bus_dma_filter_t *filter, void *filterarg, + bus_size_t maxsize, int nsegments, + bus_size_t maxsegsz, int flags, bus_dma_tag_t *ret_tag) +{ + bus_dma_tag_t dmat; + + dmat = malloc(sizeof(*dmat), M_DEVBUF, M_NOWAIT); + if (dmat == NULL) + return (ENOMEM); /* - * See if we can find a matching cmd in the pending list. + * Linux is very simplistic about DMA memory. For now don't + * maintain all specification information. Once Linux supplies + * better facilities for doing these operations, or the + * needs of this particular driver change, we might need to do + * more here. */ - LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) { - if (pending_scb->io_ctx == cmd) - break; - } + dmat->alignment = alignment; + dmat->boundary = boundary; + dmat->maxsize = maxsize; + *ret_tag = dmat; + return (0); +} - if (pending_scb == NULL) { - printf("%s:%d:%d:%d: Command not found\n", - ahd_name(ahd), cmd->device->channel, cmd->device->id, - cmd->device->lun); - goto no_cmd; - } +void +ahd_dma_tag_destroy(struct ahd_softc *ahd, bus_dma_tag_t dmat) +{ + free(dmat, M_DEVBUF); +} - if ((pending_scb->flags & SCB_RECOVERY_SCB) != 0) { - /* - * We can't queue two recovery actions using the same SCB - */ - retval = FAILED; - goto done; - } +int +ahd_dmamem_alloc(struct ahd_softc *ahd, bus_dma_tag_t dmat, void** vaddr, + int flags, bus_dmamap_t *mapp) +{ + *vaddr = pci_alloc_consistent(ahd->dev_softc, + dmat->maxsize, mapp); + if (*vaddr == NULL) + return (ENOMEM); + return(0); +} +void +ahd_dmamem_free(struct ahd_softc *ahd, bus_dma_tag_t dmat, + void* vaddr, bus_dmamap_t map) +{ + pci_free_consistent(ahd->dev_softc, dmat->maxsize, + vaddr, map); +} + +int +ahd_dmamap_load(struct ahd_softc *ahd, bus_dma_tag_t dmat, bus_dmamap_t map, + void *buf, bus_size_t buflen, bus_dmamap_callback_t *cb, + void *cb_arg, int flags) +{ /* - * Ensure that the card doesn't do anything - * behind our back. Also make sure that we - * didn't "just" miss an interrupt that would - * affect this cmd. + * Assume for now that this will only be used during + * initialization and not for per-transaction buffer mapping. */ - was_paused = ahd_is_paused(ahd); - ahd_pause_and_flushwork(ahd); - paused = TRUE; - - if ((pending_scb->flags & SCB_ACTIVE) == 0) { - printf("%s:%d:%d:%d: Command already completed\n", - ahd_name(ahd), cmd->device->channel, cmd->device->id, - cmd->device->lun); - goto no_cmd; - } + bus_dma_segment_t stack_sg; - printf("%s: At time of recovery, card was %spaused\n", - ahd_name(ahd), was_paused ? "" : "not "); - ahd_dump_card_state(ahd); + stack_sg.ds_addr = map; + stack_sg.ds_len = dmat->maxsize; + cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0); + return (0); +} - disconnected = TRUE; - if (ahd_search_qinfifo(ahd, cmd->device->id, cmd->device->channel + 'A', - cmd->device->lun, SCB_GET_TAG(pending_scb), - ROLE_INITIATOR, CAM_REQ_ABORTED, - SEARCH_COMPLETE) > 0) { - printf("%s:%d:%d:%d: Cmd aborted from QINFIFO\n", - ahd_name(ahd), cmd->device->channel, cmd->device->id, - cmd->device->lun); - retval = SUCCESS; - goto done; - } +void +ahd_dmamap_destroy(struct ahd_softc *ahd, bus_dma_tag_t dmat, bus_dmamap_t map) +{ +} - saved_modes = ahd_save_modes(ahd); - ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); - last_phase = ahd_inb(ahd, LASTPHASE); - saved_scbptr = ahd_get_scbptr(ahd); - active_scbptr = saved_scbptr; - if (disconnected && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) == 0) { - struct scb *bus_scb; +int +ahd_dmamap_unload(struct ahd_softc *ahd, bus_dma_tag_t dmat, bus_dmamap_t map) +{ + /* Nothing to do */ + return (0); +} - bus_scb = ahd_lookup_scb(ahd, active_scbptr); - if (bus_scb == pending_scb) - disconnected = FALSE; - } +/********************* Platform Dependent Functions ***************************/ +/* + * Compare "left hand" softc with "right hand" softc, returning: + * < 0 - lahd has a lower priority than rahd + * 0 - Softcs are equal + * > 0 - lahd has a higher priority than rahd + */ +int +ahd_softc_comp(struct ahd_softc *lahd, struct ahd_softc *rahd) +{ + int value; /* - * At this point, pending_scb is the scb associated with the - * passed in command. That command is currently active on the - * bus or is in the disconnected state. + * Under Linux, cards are ordered as follows: + * 1) PCI devices that are marked as the boot controller. + * 2) PCI devices with BIOS enabled sorted by bus/slot/func. + * 3) All remaining PCI devices sorted by bus/slot/func. */ - if (last_phase != P_BUSFREE - && SCB_GET_TAG(pending_scb) == active_scbptr) { +#if 0 + value = (lahd->flags & AHD_BOOT_CHANNEL) + - (rahd->flags & AHD_BOOT_CHANNEL); + if (value != 0) + /* Controllers set for boot have a *higher* priority */ + return (value); +#endif - /* - * We're active on the bus, so assert ATN - * and hope that the target responds. - */ - pending_scb = ahd_lookup_scb(ahd, active_scbptr); - pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT; - ahd_outb(ahd, MSG_OUT, HOST_MSG); - ahd_outb(ahd, SCSISIGO, last_phase|ATNO); - printf("%s:%d:%d:%d: Device is active, asserting ATN\n", - ahd_name(ahd), cmd->device->channel, - cmd->device->id, cmd->device->lun); - wait = TRUE; - } else if (disconnected) { + value = (lahd->flags & AHD_BIOS_ENABLED) + - (rahd->flags & AHD_BIOS_ENABLED); + if (value != 0) + /* Controllers with BIOS enabled have a *higher* priority */ + return (value); - /* - * Actually re-queue this SCB in an attempt - * to select the device before it reconnects. - */ - pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT; - ahd_set_scbptr(ahd, SCB_GET_TAG(pending_scb)); - pending_scb->hscb->cdb_len = 0; - pending_scb->hscb->task_attribute = 0; - pending_scb->hscb->task_management = SIU_TASKMGMT_ABORT_TASK; + /* Still equal. Sort by bus/slot/func. */ + if (aic79xx_reverse_scan != 0) + value = ahd_get_pci_bus(lahd->dev_softc) + - ahd_get_pci_bus(rahd->dev_softc); + else + value = ahd_get_pci_bus(rahd->dev_softc) + - ahd_get_pci_bus(lahd->dev_softc); + if (value != 0) + return (value); + if (aic79xx_reverse_scan != 0) + value = ahd_get_pci_slot(lahd->dev_softc) + - ahd_get_pci_slot(rahd->dev_softc); + else + value = ahd_get_pci_slot(rahd->dev_softc) + - ahd_get_pci_slot(lahd->dev_softc); + if (value != 0) + return (value); - if ((pending_scb->flags & SCB_PACKETIZED) != 0) { - /* - * Mark the SCB has having an outstanding - * task management function. Should the command - * complete normally before the task management - * function can be sent, the host will be notified - * to abort our requeued SCB. - */ - ahd_outb(ahd, SCB_TASK_MANAGEMENT, - pending_scb->hscb->task_management); - } else { - /* - * If non-packetized, set the MK_MESSAGE control - * bit indicating that we desire to send a message. - * We also set the disconnected flag since there is - * no guarantee that our SCB control byte matches - * the version on the card. We don't want the - * sequencer to abort the command thinking an - * unsolicited reselection occurred. - */ - pending_scb->hscb->control |= MK_MESSAGE|DISCONNECTED; + value = rahd->channel - lahd->channel; + return (value); +} - /* - * The sequencer will never re-reference the - * in-core SCB. To make sure we are notified - * during reslection, set the MK_MESSAGE flag in - * the card's copy of the SCB. - */ - ahd_outb(ahd, SCB_CONTROL, - ahd_inb(ahd, SCB_CONTROL)|MK_MESSAGE); - } +static void +ahd_linux_setup_iocell_info(u_long index, int instance, int targ, int32_t value) +{ - /* - * Clear out any entries in the QINFIFO first - * so we are the next SCB for this target - * to run. - */ - ahd_search_qinfifo(ahd, cmd->device->id, - cmd->device->channel + 'A', cmd->device->lun, - SCB_LIST_NULL, ROLE_INITIATOR, - CAM_REQUEUE_REQ, SEARCH_COMPLETE); - ahd_qinfifo_requeue_tail(ahd, pending_scb); - ahd_set_scbptr(ahd, saved_scbptr); - ahd_print_path(ahd, pending_scb); - printf("Device is disconnected, re-queuing SCB\n"); - wait = TRUE; - } else { - printf("%s:%d:%d:%d: Unable to deliver message\n", - ahd_name(ahd), cmd->device->channel, - cmd->device->id, cmd->device->lun); - retval = FAILED; - goto done; + if ((instance >= 0) + && (instance < NUM_ELEMENTS(aic79xx_iocell_info))) { + uint8_t *iocell_info; + + iocell_info = (uint8_t*)&aic79xx_iocell_info[instance]; + iocell_info[index] = value & 0xFFFF; + if (bootverbose) + printf("iocell[%d:%ld] = %d\n", instance, index, value); } +} -no_cmd: - /* - * Our assumption is that if we don't have the command, no - * recovery action was required, so we return success. Again, - * the semantics of the mid-layer recovery engine are not - * well defined, so this may change in time. - */ - retval = SUCCESS; -done: - if (paused) - ahd_unpause(ahd); - if (wait) { - struct timer_list timer; - int ret; +static void +ahd_linux_setup_tag_info_global(char *p) +{ + int tags, i, j; - pending_scb->platform_data->flags |= AHD_SCB_UP_EH_SEM; - spin_unlock_irq(&ahd->platform_data->spin_lock); - init_timer(&timer); - timer.data = (u_long)pending_scb; - timer.expires = jiffies + (5 * HZ); - timer.function = ahd_linux_sem_timeout; - add_timer(&timer); - printf("Recovery code sleeping\n"); - down(&ahd->platform_data->eh_sem); - printf("Recovery code awake\n"); - ret = del_timer_sync(&timer); - if (ret == 0) { - printf("Timer Expired\n"); - retval = FAILED; + tags = simple_strtoul(p + 1, NULL, 0) & 0xff; + printf("Setting Global Tags= %d\n", tags); + + for (i = 0; i < NUM_ELEMENTS(aic79xx_tag_info); i++) { + for (j = 0; j < AHD_NUM_TARGETS; j++) { + aic79xx_tag_info[i].tag_commands[j] = tags; } - spin_lock_irq(&ahd->platform_data->spin_lock); } - ahd_linux_run_complete_queue(ahd); - ahd_midlayer_entrypoint_unlock(ahd, &s); - return (retval); } - static void -ahd_linux_dev_reset_complete(Scsi_Cmnd *cmd) +ahd_linux_setup_tag_info(u_long arg, int instance, int targ, int32_t value) { - free(cmd, M_DEVBUF); -} -/* - * Attempt to send a target reset message to the device that timed out. - */ -static int -ahd_linux_dev_reset(Scsi_Cmnd *cmd) -{ - struct ahd_softc *ahd; - struct scsi_cmnd *recovery_cmd; - struct ahd_linux_device *dev; - struct ahd_initiator_tinfo *tinfo; - struct ahd_tmode_tstate *tstate; - struct scb *scb; - struct hardware_scb *hscb; - u_long s; - struct timer_list timer; - int retval; - - ahd = *(struct ahd_softc **)cmd->device->host->hostdata; - recovery_cmd = malloc(sizeof(struct scsi_cmnd), M_DEVBUF, M_WAITOK); - if (!recovery_cmd) - return (FAILED); - memset(recovery_cmd, 0, sizeof(struct scsi_cmnd)); - recovery_cmd->device = cmd->device; - recovery_cmd->scsi_done = ahd_linux_dev_reset_complete; -#ifdef AHD_DEBUG - if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) - printf("%s:%d:%d:%d: Device reset called for cmd %p\n", - ahd_name(ahd), cmd->device->channel, cmd->device->id, - cmd->device->lun, cmd); -#endif - ahd_lock(ahd, &s); - - dev = ahd_linux_get_device(ahd, cmd->device->channel, cmd->device->id, - cmd->device->lun, /*alloc*/FALSE); - if (dev == NULL) { - ahd_unlock(ahd, &s); - kfree(recovery_cmd); - return (FAILED); - } - if ((scb = ahd_get_scb(ahd, AHD_NEVER_COL_IDX)) == NULL) { - ahd_unlock(ahd, &s); - kfree(recovery_cmd); - return (FAILED); - } - tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, - cmd->device->id, &tstate); - recovery_cmd->result = CAM_REQ_INPROG << 16; - recovery_cmd->host_scribble = (char *)scb; - scb->io_ctx = recovery_cmd; - scb->platform_data->dev = dev; - scb->sg_count = 0; - ahd_set_residual(scb, 0); - ahd_set_sense_residual(scb, 0); - hscb = scb->hscb; - hscb->control = 0; - hscb->scsiid = BUILD_SCSIID(ahd, cmd); - hscb->lun = cmd->device->lun; - hscb->cdb_len = 0; - hscb->task_management = SIU_TASKMGMT_LUN_RESET; - scb->flags |= SCB_DEVICE_RESET|SCB_RECOVERY_SCB|SCB_ACTIVE; - if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) { - scb->flags |= SCB_PACKETIZED; - } else { - hscb->control |= MK_MESSAGE; - } - dev->openings--; - dev->active++; - dev->commands_issued++; - LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links); - ahd_queue_scb(ahd, scb); - - scb->platform_data->flags |= AHD_SCB_UP_EH_SEM; - ahd_unlock(ahd, &s); - init_timer(&timer); - timer.data = (u_long)scb; - timer.expires = jiffies + (5 * HZ); - timer.function = ahd_linux_sem_timeout; - add_timer(&timer); - printf("Recovery code sleeping\n"); - down(&ahd->platform_data->eh_sem); - printf("Recovery code awake\n"); - retval = SUCCESS; - if (del_timer_sync(&timer) == 0) { - printf("Timer Expired\n"); - retval = FAILED; + if ((instance >= 0) && (targ >= 0) + && (instance < NUM_ELEMENTS(aic79xx_tag_info)) + && (targ < AHD_NUM_TARGETS)) { + aic79xx_tag_info[instance].tag_commands[targ] = value & 0x1FF; + if (bootverbose) + printf("tag_info[%d:%d] = %d\n", instance, targ, value); } - ahd_lock(ahd, &s); - ahd_linux_run_complete_queue(ahd); - ahd_unlock(ahd, &s); - printf("%s: Device reset returning 0x%x\n", ahd_name(ahd), retval); - return (retval); } /* - * Reset the SCSI bus. + * Handle Linux boot parameters. This routine allows for assigning a value + * to a parameter with a ':' between the parameter and the value. + * ie. aic79xx=stpwlev:1,extended */ static int -ahd_linux_bus_reset(Scsi_Cmnd *cmd) +aic79xx_setup(char *s) { - struct ahd_softc *ahd; - u_long s; - int found; + int i, n; + char *p; + char *end; - ahd = *(struct ahd_softc **)cmd->device->host->hostdata; + static struct { + const char *name; + uint32_t *flag; + } options[] = { + { "extended", &aic79xx_extended }, + { "no_reset", &aic79xx_no_reset }, + { "verbose", &aic79xx_verbose }, + { "allow_memio", &aic79xx_allow_memio}, #ifdef AHD_DEBUG - if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) - printf("%s: Bus reset called for cmd %p\n", - ahd_name(ahd), cmd); + { "debug", &ahd_debug }, #endif - ahd_lock(ahd, &s); - found = ahd_reset_channel(ahd, cmd->device->channel + 'A', - /*initiate reset*/TRUE); - ahd_linux_run_complete_queue(ahd); - ahd_unlock(ahd, &s); + { "reverse_scan", &aic79xx_reverse_scan }, + { "periodic_otag", &aic79xx_periodic_otag }, + { "pci_parity", &aic79xx_pci_parity }, + { "seltime", &aic79xx_seltime }, + { "tag_info", NULL }, + { "global_tag_depth", NULL}, + { "slewrate", NULL }, + { "precomp", NULL }, + { "amplitude", NULL }, + }; - if (bootverbose) - printf("%s: SCSI bus reset delivered. " - "%d SCBs aborted.\n", ahd_name(ahd), found); + end = strchr(s, '\0'); - return (SUCCESS); + /* + * XXX ia64 gcc isn't smart enough to know that NUM_ELEMENTS + * will never be 0 in this case. + */ + n = 0; + + while ((p = strsep(&s, ",.")) != NULL) { + if (*p == '\0') + continue; + for (i = 0; i < NUM_ELEMENTS(options); i++) { + + n = strlen(options[i].name); + if (strncmp(options[i].name, p, n) == 0) + break; + } + if (i == NUM_ELEMENTS(options)) + continue; + + if (strncmp(p, "global_tag_depth", n) == 0) { + ahd_linux_setup_tag_info_global(p + n); + } else if (strncmp(p, "tag_info", n) == 0) { + s = aic_parse_brace_option("tag_info", p + n, end, + 2, ahd_linux_setup_tag_info, 0); + } else if (strncmp(p, "slewrate", n) == 0) { + s = aic_parse_brace_option("slewrate", + p + n, end, 1, ahd_linux_setup_iocell_info, + AIC79XX_SLEWRATE_INDEX); + } else if (strncmp(p, "precomp", n) == 0) { + s = aic_parse_brace_option("precomp", + p + n, end, 1, ahd_linux_setup_iocell_info, + AIC79XX_PRECOMP_INDEX); + } else if (strncmp(p, "amplitude", n) == 0) { + s = aic_parse_brace_option("amplitude", + p + n, end, 1, ahd_linux_setup_iocell_info, + AIC79XX_AMPLITUDE_INDEX); + } else if (p[n] == ':') { + *(options[i].flag) = simple_strtoul(p + n + 1, NULL, 0); + } else if (!strncmp(p, "verbose", n)) { + *(options[i].flag) = 1; + } else { + *(options[i].flag) ^= 0xFFFFFFFF; + } + } + return 1; } -Scsi_Host_Template aic79xx_driver_template = { - .module = THIS_MODULE, - .name = "aic79xx", - .proc_info = ahd_linux_proc_info, - .info = ahd_linux_info, - .queuecommand = ahd_linux_queue, - .eh_abort_handler = ahd_linux_abort, - .eh_device_reset_handler = ahd_linux_dev_reset, - .eh_bus_reset_handler = ahd_linux_bus_reset, -#if defined(__i386__) - .bios_param = ahd_linux_biosparam, -#endif - .can_queue = AHD_MAX_QUEUE, - .this_id = -1, - .cmd_per_lun = 2, - .use_clustering = ENABLE_CLUSTERING, - .slave_alloc = ahd_linux_slave_alloc, - .slave_configure = ahd_linux_slave_configure, - .slave_destroy = ahd_linux_slave_destroy, -}; +__setup("aic79xx=", aic79xx_setup); + +uint32_t aic79xx_verbose; -/******************************** Bus DMA *************************************/ int -ahd_dma_tag_create(struct ahd_softc *ahd, bus_dma_tag_t parent, - bus_size_t alignment, bus_size_t boundary, - dma_addr_t lowaddr, dma_addr_t highaddr, - bus_dma_filter_t *filter, void *filterarg, - bus_size_t maxsize, int nsegments, - bus_size_t maxsegsz, int flags, bus_dma_tag_t *ret_tag) +ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *template) { - bus_dma_tag_t dmat; + char buf[80]; + struct Scsi_Host *host; + char *new_name; + u_long s; - dmat = malloc(sizeof(*dmat), M_DEVBUF, M_NOWAIT); - if (dmat == NULL) + template->name = ahd->description; + host = scsi_host_alloc(template, sizeof(struct ahd_softc *)); + if (host == NULL) return (ENOMEM); - /* - * Linux is very simplistic about DMA memory. For now don't - * maintain all specification information. Once Linux supplies - * better facilities for doing these operations, or the - * needs of this particular driver change, we might need to do - * more here. - */ - dmat->alignment = alignment; - dmat->boundary = boundary; - dmat->maxsize = maxsize; - *ret_tag = dmat; + *((struct ahd_softc **)host->hostdata) = ahd; + ahd_lock(ahd, &s); + scsi_assign_lock(host, &ahd->platform_data->spin_lock); + ahd->platform_data->host = host; + host->can_queue = AHD_MAX_QUEUE; + host->cmd_per_lun = 2; + host->sg_tablesize = AHD_NSEG; + host->this_id = ahd->our_id; + host->irq = ahd->platform_data->irq; + host->max_id = (ahd->features & AHD_WIDE) ? 16 : 8; + host->max_lun = AHD_NUM_LUNS; + host->max_channel = 0; + host->sg_tablesize = AHD_NSEG; + ahd_set_unit(ahd, ahd_linux_next_unit()); + sprintf(buf, "scsi%d", host->host_no); + new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT); + if (new_name != NULL) { + strcpy(new_name, buf); + ahd_set_name(ahd, new_name); + } + host->unique_id = ahd->unit; + ahd_linux_initialize_scsi_bus(ahd); + ahd_intr_enable(ahd, TRUE); + ahd_unlock(ahd, &s); + + host->transportt = ahd_linux_transport_template; + + scsi_add_host(host, &ahd->dev_softc->dev); /* XXX handle failure */ + scsi_scan_host(host); return (0); } -void -ahd_dma_tag_destroy(struct ahd_softc *ahd, bus_dma_tag_t dmat) +uint64_t +ahd_linux_get_memsize(void) { - free(dmat, M_DEVBUF); + struct sysinfo si; + + si_meminfo(&si); + return ((uint64_t)si.totalram << PAGE_SHIFT); } -int -ahd_dmamem_alloc(struct ahd_softc *ahd, bus_dma_tag_t dmat, void** vaddr, - int flags, bus_dmamap_t *mapp) +/* + * Find the smallest available unit number to use + * for a new device. We don't just use a static + * count to handle the "repeated hot-(un)plug" + * scenario. + */ +static int +ahd_linux_next_unit(void) { - bus_dmamap_t map; + struct ahd_softc *ahd; + int unit; - map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT); - if (map == NULL) - return (ENOMEM); - /* - * Although we can dma data above 4GB, our - * "consistent" memory is below 4GB for - * space efficiency reasons (only need a 4byte - * address). For this reason, we have to reset - * our dma mask when doing allocations. - */ - if (ahd->dev_softc != NULL) - if (pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF)) { - printk(KERN_WARNING "aic79xx: No suitable DMA available.\n"); - kfree(map); - return (ENODEV); - } - *vaddr = pci_alloc_consistent(ahd->dev_softc, - dmat->maxsize, &map->bus_addr); - if (ahd->dev_softc != NULL) - if (pci_set_dma_mask(ahd->dev_softc, - ahd->platform_data->hw_dma_mask)) { - printk(KERN_WARNING "aic79xx: No suitable DMA available.\n"); - kfree(map); - return (ENODEV); + unit = 0; +retry: + TAILQ_FOREACH(ahd, &ahd_tailq, links) { + if (ahd->unit == unit) { + unit++; + goto retry; } - if (*vaddr == NULL) - return (ENOMEM); - *mapp = map; - return(0); + } + return (unit); } -void -ahd_dmamem_free(struct ahd_softc *ahd, bus_dma_tag_t dmat, - void* vaddr, bus_dmamap_t map) -{ - pci_free_consistent(ahd->dev_softc, dmat->maxsize, - vaddr, map->bus_addr); -} - -int -ahd_dmamap_load(struct ahd_softc *ahd, bus_dma_tag_t dmat, bus_dmamap_t map, - void *buf, bus_size_t buflen, bus_dmamap_callback_t *cb, - void *cb_arg, int flags) +/* + * Place the SCSI bus into a known state by either resetting it, + * or forcing transfer negotiations on the next command to any + * target. + */ +static void +ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd) { - /* - * Assume for now that this will only be used during - * initialization and not for per-transaction buffer mapping. - */ - bus_dma_segment_t stack_sg; + u_int target_id; + u_int numtarg; - stack_sg.ds_addr = map->bus_addr; - stack_sg.ds_len = dmat->maxsize; - cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0); - return (0); -} + target_id = 0; + numtarg = 0; + + if (aic79xx_no_reset != 0) + ahd->flags &= ~AHD_RESET_BUS_A; + + if ((ahd->flags & AHD_RESET_BUS_A) != 0) + ahd_reset_channel(ahd, 'A', /*initiate_reset*/TRUE); + else + numtarg = (ahd->features & AHD_WIDE) ? 16 : 8; -void -ahd_dmamap_destroy(struct ahd_softc *ahd, bus_dma_tag_t dmat, bus_dmamap_t map) -{ /* - * The map may is NULL in our < 2.3.X implementation. + * Force negotiation to async for all targets that + * will not see an initial bus reset. */ - if (map != NULL) - free(map, M_DEVBUF); + for (; target_id < numtarg; target_id++) { + struct ahd_devinfo devinfo; + struct ahd_initiator_tinfo *tinfo; + struct ahd_tmode_tstate *tstate; + + tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, + target_id, &tstate); + ahd_compile_devinfo(&devinfo, ahd->our_id, target_id, + CAM_LUN_WILDCARD, 'A', ROLE_INITIATOR); + ahd_update_neg_request(ahd, &devinfo, tstate, + tinfo, AHD_NEG_ALWAYS); + } + /* Give the bus some time to recover */ + if ((ahd->flags & AHD_RESET_BUS_A) != 0) { + ahd_freeze_simq(ahd); + init_timer(&ahd->platform_data->reset_timer); + ahd->platform_data->reset_timer.data = (u_long)ahd; + ahd->platform_data->reset_timer.expires = + jiffies + (AIC79XX_RESET_DELAY * HZ)/1000; + ahd->platform_data->reset_timer.function = + (ahd_linux_callback_t *)ahd_release_simq; + add_timer(&ahd->platform_data->reset_timer); + } } int -ahd_dmamap_unload(struct ahd_softc *ahd, bus_dma_tag_t dmat, bus_dmamap_t map) +ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg) { - /* Nothing to do */ + ahd->platform_data = + malloc(sizeof(struct ahd_platform_data), M_DEVBUF, M_NOWAIT); + if (ahd->platform_data == NULL) + return (ENOMEM); + memset(ahd->platform_data, 0, sizeof(struct ahd_platform_data)); + ahd->platform_data->irq = AHD_LINUX_NOIRQ; + ahd_lockinit(ahd); + init_MUTEX_LOCKED(&ahd->platform_data->eh_sem); + ahd->seltime = (aic79xx_seltime & 0x3) << 4; return (0); } -/********************* Platform Dependent Functions ***************************/ -/* - * Compare "left hand" softc with "right hand" softc, returning: - * < 0 - lahd has a lower priority than rahd - * 0 - Softcs are equal - * > 0 - lahd has a higher priority than rahd - */ -int -ahd_softc_comp(struct ahd_softc *lahd, struct ahd_softc *rahd) +void +ahd_platform_free(struct ahd_softc *ahd) { - int value; - - /* - * Under Linux, cards are ordered as follows: - * 1) PCI devices that are marked as the boot controller. - * 2) PCI devices with BIOS enabled sorted by bus/slot/func. - * 3) All remaining PCI devices sorted by bus/slot/func. - */ -#if 0 - value = (lahd->flags & AHD_BOOT_CHANNEL) - - (rahd->flags & AHD_BOOT_CHANNEL); - if (value != 0) - /* Controllers set for boot have a *higher* priority */ - return (value); -#endif + struct scsi_target *starget; + int i, j; - value = (lahd->flags & AHD_BIOS_ENABLED) - - (rahd->flags & AHD_BIOS_ENABLED); - if (value != 0) - /* Controllers with BIOS enabled have a *higher* priority */ - return (value); + if (ahd->platform_data != NULL) { + if (ahd->platform_data->host != NULL) { + scsi_remove_host(ahd->platform_data->host); + scsi_host_put(ahd->platform_data->host); + } - /* Still equal. Sort by bus/slot/func. */ - if (aic79xx_reverse_scan != 0) - value = ahd_get_pci_bus(lahd->dev_softc) - - ahd_get_pci_bus(rahd->dev_softc); - else - value = ahd_get_pci_bus(rahd->dev_softc) - - ahd_get_pci_bus(lahd->dev_softc); - if (value != 0) - return (value); - if (aic79xx_reverse_scan != 0) - value = ahd_get_pci_slot(lahd->dev_softc) - - ahd_get_pci_slot(rahd->dev_softc); - else - value = ahd_get_pci_slot(rahd->dev_softc) - - ahd_get_pci_slot(lahd->dev_softc); - if (value != 0) - return (value); + /* destroy all of the device and target objects */ + for (i = 0; i < AHD_NUM_TARGETS; i++) { + starget = ahd->platform_data->starget[i]; + if (starget != NULL) { + for (j = 0; j < AHD_NUM_LUNS; j++) { + struct ahd_linux_target *targ = + scsi_transport_target_data(starget); + if (targ->sdev[j] == NULL) + continue; + targ->sdev[j] = NULL; + } + ahd->platform_data->starget[i] = NULL; + } + } - value = rahd->channel - lahd->channel; - return (value); + if (ahd->platform_data->irq != AHD_LINUX_NOIRQ) + free_irq(ahd->platform_data->irq, ahd); + if (ahd->tags[0] == BUS_SPACE_PIO + && ahd->bshs[0].ioport != 0) + release_region(ahd->bshs[0].ioport, 256); + if (ahd->tags[1] == BUS_SPACE_PIO + && ahd->bshs[1].ioport != 0) + release_region(ahd->bshs[1].ioport, 256); + if (ahd->tags[0] == BUS_SPACE_MEMIO + && ahd->bshs[0].maddr != NULL) { + iounmap(ahd->bshs[0].maddr); + release_mem_region(ahd->platform_data->mem_busaddr, + 0x1000); + } + free(ahd->platform_data, M_DEVBUF); + } } -static void -ahd_linux_setup_tag_info(u_long arg, int instance, int targ, int32_t value) +void +ahd_platform_init(struct ahd_softc *ahd) { + /* + * Lookup and commit any modified IO Cell options. + */ + if (ahd->unit < NUM_ELEMENTS(aic79xx_iocell_info)) { + struct ahd_linux_iocell_opts *iocell_opts; - if ((instance >= 0) && (targ >= 0) - && (instance < NUM_ELEMENTS(aic79xx_tag_info)) - && (targ < AHD_NUM_TARGETS)) { - aic79xx_tag_info[instance].tag_commands[targ] = value & 0x1FF; - if (bootverbose) - printf("tag_info[%d:%d] = %d\n", instance, targ, value); + iocell_opts = &aic79xx_iocell_info[ahd->unit]; + if (iocell_opts->precomp != AIC79XX_DEFAULT_PRECOMP) + AHD_SET_PRECOMP(ahd, iocell_opts->precomp); + if (iocell_opts->slewrate != AIC79XX_DEFAULT_SLEWRATE) + AHD_SET_SLEWRATE(ahd, iocell_opts->slewrate); + if (iocell_opts->amplitude != AIC79XX_DEFAULT_AMPLITUDE) + AHD_SET_AMPLITUDE(ahd, iocell_opts->amplitude); } -} -static void -ahd_linux_setup_rd_strm_info(u_long arg, int instance, int targ, int32_t value) -{ - if ((instance >= 0) - && (instance < NUM_ELEMENTS(aic79xx_rd_strm_info))) { - aic79xx_rd_strm_info[instance] = value & 0xFFFF; - if (bootverbose) - printf("rd_strm[%d] = 0x%x\n", instance, value); - } } -static void -ahd_linux_setup_dv(u_long arg, int instance, int targ, int32_t value) +void +ahd_platform_freeze_devq(struct ahd_softc *ahd, struct scb *scb) { - if ((instance >= 0) - && (instance < NUM_ELEMENTS(aic79xx_dv_settings))) { - aic79xx_dv_settings[instance] = value; - if (bootverbose) - printf("dv[%d] = %d\n", instance, value); - } + ahd_platform_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), + SCB_GET_CHANNEL(ahd, scb), + SCB_GET_LUN(scb), SCB_LIST_NULL, + ROLE_UNKNOWN, CAM_REQUEUE_REQ); } -static void -ahd_linux_setup_iocell_info(u_long index, int instance, int targ, int32_t value) +void +ahd_platform_set_tags(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, + ahd_queue_alg alg) { + struct scsi_target *starget; + struct ahd_linux_target *targ; + struct ahd_linux_device *dev; + struct scsi_device *sdev; + int was_queuing; + int now_queuing; - if ((instance >= 0) - && (instance < NUM_ELEMENTS(aic79xx_iocell_info))) { - uint8_t *iocell_info; - - iocell_info = (uint8_t*)&aic79xx_iocell_info[instance]; - iocell_info[index] = value & 0xFFFF; - if (bootverbose) - printf("iocell[%d:%ld] = %d\n", instance, index, value); - } -} - -static void -ahd_linux_setup_tag_info_global(char *p) -{ - int tags, i, j; + starget = ahd->platform_data->starget[devinfo->target]; + targ = scsi_transport_target_data(starget); + BUG_ON(targ == NULL); + sdev = targ->sdev[devinfo->lun]; + if (sdev == NULL) + return; - tags = simple_strtoul(p + 1, NULL, 0) & 0xff; - printf("Setting Global Tags= %d\n", tags); + dev = scsi_transport_device_data(sdev); - for (i = 0; i < NUM_ELEMENTS(aic79xx_tag_info); i++) { - for (j = 0; j < AHD_NUM_TARGETS; j++) { - aic79xx_tag_info[i].tag_commands[j] = tags; - } + if (dev == NULL) + return; + was_queuing = dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED); + switch (alg) { + default: + case AHD_QUEUE_NONE: + now_queuing = 0; + break; + case AHD_QUEUE_BASIC: + now_queuing = AHD_DEV_Q_BASIC; + break; + case AHD_QUEUE_TAGGED: + now_queuing = AHD_DEV_Q_TAGGED; + break; + } + if ((dev->flags & AHD_DEV_FREEZE_TIL_EMPTY) == 0 + && (was_queuing != now_queuing) + && (dev->active != 0)) { + dev->flags |= AHD_DEV_FREEZE_TIL_EMPTY; + dev->qfrozen++; } -} -/* - * Handle Linux boot parameters. This routine allows for assigning a value - * to a parameter with a ':' between the parameter and the value. - * ie. aic79xx=stpwlev:1,extended - */ -static int -aic79xx_setup(char *s) -{ - int i, n; - char *p; - char *end; + dev->flags &= ~(AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED|AHD_DEV_PERIODIC_OTAG); + if (now_queuing) { + u_int usertags; - static struct { - const char *name; - uint32_t *flag; - } options[] = { - { "extended", &aic79xx_extended }, - { "no_reset", &aic79xx_no_reset }, - { "verbose", &aic79xx_verbose }, - { "allow_memio", &aic79xx_allow_memio}, -#ifdef AHD_DEBUG - { "debug", &ahd_debug }, -#endif - { "reverse_scan", &aic79xx_reverse_scan }, - { "periodic_otag", &aic79xx_periodic_otag }, - { "pci_parity", &aic79xx_pci_parity }, - { "seltime", &aic79xx_seltime }, - { "tag_info", NULL }, - { "global_tag_depth", NULL}, - { "rd_strm", NULL }, - { "dv", NULL }, - { "slewrate", NULL }, - { "precomp", NULL }, - { "amplitude", NULL }, - }; - - end = strchr(s, '\0'); - - /* - * XXX ia64 gcc isn't smart enough to know that NUM_ELEMENTS - * will never be 0 in this case. - */ - n = 0; - - while ((p = strsep(&s, ",.")) != NULL) { - if (*p == '\0') - continue; - for (i = 0; i < NUM_ELEMENTS(options); i++) { - - n = strlen(options[i].name); - if (strncmp(options[i].name, p, n) == 0) - break; - } - if (i == NUM_ELEMENTS(options)) - continue; - - if (strncmp(p, "global_tag_depth", n) == 0) { - ahd_linux_setup_tag_info_global(p + n); - } else if (strncmp(p, "tag_info", n) == 0) { - s = aic_parse_brace_option("tag_info", p + n, end, - 2, ahd_linux_setup_tag_info, 0); - } else if (strncmp(p, "rd_strm", n) == 0) { - s = aic_parse_brace_option("rd_strm", p + n, end, - 1, ahd_linux_setup_rd_strm_info, 0); - } else if (strncmp(p, "dv", n) == 0) { - s = aic_parse_brace_option("dv", p + n, end, 1, - ahd_linux_setup_dv, 0); - } else if (strncmp(p, "slewrate", n) == 0) { - s = aic_parse_brace_option("slewrate", - p + n, end, 1, ahd_linux_setup_iocell_info, - AIC79XX_SLEWRATE_INDEX); - } else if (strncmp(p, "precomp", n) == 0) { - s = aic_parse_brace_option("precomp", - p + n, end, 1, ahd_linux_setup_iocell_info, - AIC79XX_PRECOMP_INDEX); - } else if (strncmp(p, "amplitude", n) == 0) { - s = aic_parse_brace_option("amplitude", - p + n, end, 1, ahd_linux_setup_iocell_info, - AIC79XX_AMPLITUDE_INDEX); - } else if (p[n] == ':') { - *(options[i].flag) = simple_strtoul(p + n + 1, NULL, 0); - } else if (!strncmp(p, "verbose", n)) { - *(options[i].flag) = 1; - } else { - *(options[i].flag) ^= 0xFFFFFFFF; + usertags = ahd_linux_user_tagdepth(ahd, devinfo); + if (!was_queuing) { + /* + * Start out agressively and allow our + * dynamic queue depth algorithm to take + * care of the rest. + */ + dev->maxtags = usertags; + dev->openings = dev->maxtags - dev->active; } + if (dev->maxtags == 0) { + /* + * Queueing is disabled by the user. + */ + dev->openings = 1; + } else if (alg == AHD_QUEUE_TAGGED) { + dev->flags |= AHD_DEV_Q_TAGGED; + if (aic79xx_periodic_otag != 0) + dev->flags |= AHD_DEV_PERIODIC_OTAG; + } else + dev->flags |= AHD_DEV_Q_BASIC; + } else { + /* We can only have one opening. */ + dev->maxtags = 0; + dev->openings = 1 - dev->active; } - return 1; -} - -__setup("aic79xx=", aic79xx_setup); - -uint32_t aic79xx_verbose; - -int -ahd_linux_register_host(struct ahd_softc *ahd, Scsi_Host_Template *template) -{ - char buf[80]; - struct Scsi_Host *host; - char *new_name; - u_long s; - u_long target; - - template->name = ahd->description; - host = scsi_host_alloc(template, sizeof(struct ahd_softc *)); - if (host == NULL) - return (ENOMEM); - - *((struct ahd_softc **)host->hostdata) = ahd; - ahd_lock(ahd, &s); - scsi_assign_lock(host, &ahd->platform_data->spin_lock); - ahd->platform_data->host = host; - host->can_queue = AHD_MAX_QUEUE; - host->cmd_per_lun = 2; - host->sg_tablesize = AHD_NSEG; - host->this_id = ahd->our_id; - host->irq = ahd->platform_data->irq; - host->max_id = (ahd->features & AHD_WIDE) ? 16 : 8; - host->max_lun = AHD_NUM_LUNS; - host->max_channel = 0; - host->sg_tablesize = AHD_NSEG; - ahd_set_unit(ahd, ahd_linux_next_unit()); - sprintf(buf, "scsi%d", host->host_no); - new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT); - if (new_name != NULL) { - strcpy(new_name, buf); - ahd_set_name(ahd, new_name); - } - host->unique_id = ahd->unit; - ahd_linux_setup_user_rd_strm_settings(ahd); - ahd_linux_initialize_scsi_bus(ahd); - ahd_unlock(ahd, &s); - ahd->platform_data->dv_pid = kernel_thread(ahd_linux_dv_thread, ahd, 0); - ahd_lock(ahd, &s); - if (ahd->platform_data->dv_pid < 0) { - printf("%s: Failed to create DV thread, error= %d\n", - ahd_name(ahd), ahd->platform_data->dv_pid); - return (-ahd->platform_data->dv_pid); - } - /* - * Initially allocate *all* of our linux target objects - * so that the DV thread will scan them all in parallel - * just after driver initialization. Any device that - * does not exist will have its target object destroyed - * by the selection timeout handler. In the case of a - * device that appears after the initial DV scan, async - * negotiation will occur for the first command, and DV - * will comence should that first command be successful. - */ - for (target = 0; target < host->max_id; target++) { + switch ((dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED))) { + case AHD_DEV_Q_BASIC: + scsi_adjust_queue_depth(sdev, + MSG_SIMPLE_TASK, + dev->openings + dev->active); + break; + case AHD_DEV_Q_TAGGED: + scsi_adjust_queue_depth(sdev, + MSG_ORDERED_TASK, + dev->openings + dev->active); + break; + default: /* - * Skip our own ID. Some Compaq/HP storage devices - * have enclosure management devices that respond to - * single bit selection (i.e. selecting ourselves). - * It is expected that either an external application - * or a modified kernel will be used to probe this - * ID if it is appropriate. To accommodate these - * installations, ahc_linux_alloc_target() will allocate - * for our ID if asked to do so. + * We allow the OS to queue 2 untagged transactions to + * us at any time even though we can only execute them + * serially on the controller/device. This should + * remove some latency. */ - if (target == ahd->our_id) - continue; - - ahd_linux_alloc_target(ahd, 0, target); + scsi_adjust_queue_depth(sdev, + /*NON-TAGGED*/0, + /*queue depth*/2); + break; } - ahd_intr_enable(ahd, TRUE); - ahd_linux_start_dv(ahd); - ahd_unlock(ahd, &s); - - scsi_add_host(host, &ahd->dev_softc->dev); /* XXX handle failure */ - scsi_scan_host(host); - return (0); } -uint64_t -ahd_linux_get_memsize(void) +int +ahd_platform_abort_scbs(struct ahd_softc *ahd, int target, char channel, + int lun, u_int tag, role_t role, uint32_t status) { - struct sysinfo si; - - si_meminfo(&si); - return ((uint64_t)si.totalram << PAGE_SHIFT); + return 0; } -/* - * Find the smallest available unit number to use - * for a new device. We don't just use a static - * count to handle the "repeated hot-(un)plug" - * scenario. - */ -static int -ahd_linux_next_unit(void) +static u_int +ahd_linux_user_tagdepth(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) { - struct ahd_softc *ahd; - int unit; + static int warned_user; + u_int tags; - unit = 0; -retry: - TAILQ_FOREACH(ahd, &ahd_tailq, links) { - if (ahd->unit == unit) { - unit++; - goto retry; + tags = 0; + if ((ahd->user_discenable & devinfo->target_mask) != 0) { + if (ahd->unit >= NUM_ELEMENTS(aic79xx_tag_info)) { + + if (warned_user == 0) { + printf(KERN_WARNING +"aic79xx: WARNING: Insufficient tag_info instances\n" +"aic79xx: for installed controllers. Using defaults\n" +"aic79xx: Please update the aic79xx_tag_info array in\n" +"aic79xx: the aic79xx_osm.c source file.\n"); + warned_user++; + } + tags = AHD_MAX_QUEUE; + } else { + adapter_tag_info_t *tag_info; + + tag_info = &aic79xx_tag_info[ahd->unit]; + tags = tag_info->tag_commands[devinfo->target_offset]; + if (tags > AHD_MAX_QUEUE) + tags = AHD_MAX_QUEUE; } } - return (unit); + return (tags); } /* - * Place the SCSI bus into a known state by either resetting it, - * or forcing transfer negotiations on the next command to any - * target. + * Determines the queue depth for a given device. */ static void -ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd) +ahd_linux_device_queue_depth(struct scsi_device *sdev) { - u_int target_id; - u_int numtarg; + struct ahd_devinfo devinfo; + u_int tags; + struct ahd_softc *ahd = *((struct ahd_softc **)sdev->host->hostdata); - target_id = 0; - numtarg = 0; + ahd_compile_devinfo(&devinfo, + ahd->our_id, + sdev->sdev_target->id, sdev->lun, + sdev->sdev_target->channel == 0 ? 'A' : 'B', + ROLE_INITIATOR); + tags = ahd_linux_user_tagdepth(ahd, &devinfo); + if (tags != 0 && sdev->tagged_supported != 0) { - if (aic79xx_no_reset != 0) - ahd->flags &= ~AHD_RESET_BUS_A; + ahd_set_tags(ahd, &devinfo, AHD_QUEUE_TAGGED); + ahd_print_devinfo(ahd, &devinfo); + printf("Tagged Queuing enabled. Depth %d\n", tags); + } else { + ahd_set_tags(ahd, &devinfo, AHD_QUEUE_NONE); + } +} - if ((ahd->flags & AHD_RESET_BUS_A) != 0) - ahd_reset_channel(ahd, 'A', /*initiate_reset*/TRUE); - else - numtarg = (ahd->features & AHD_WIDE) ? 16 : 8; +static int +ahd_linux_run_command(struct ahd_softc *ahd, struct ahd_linux_device *dev, + struct scsi_cmnd *cmd) +{ + struct scb *scb; + struct hardware_scb *hscb; + struct ahd_initiator_tinfo *tinfo; + struct ahd_tmode_tstate *tstate; + u_int col_idx; + uint16_t mask; /* - * Force negotiation to async for all targets that - * will not see an initial bus reset. + * Get an scb to use. */ - for (; target_id < numtarg; target_id++) { - struct ahd_devinfo devinfo; - struct ahd_initiator_tinfo *tinfo; - struct ahd_tmode_tstate *tstate; - - tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, - target_id, &tstate); - ahd_compile_devinfo(&devinfo, ahd->our_id, target_id, - CAM_LUN_WILDCARD, 'A', ROLE_INITIATOR); - ahd_update_neg_request(ahd, &devinfo, tstate, - tinfo, AHD_NEG_ALWAYS); - } - /* Give the bus some time to recover */ - if ((ahd->flags & AHD_RESET_BUS_A) != 0) { - ahd_freeze_simq(ahd); - init_timer(&ahd->platform_data->reset_timer); - ahd->platform_data->reset_timer.data = (u_long)ahd; - ahd->platform_data->reset_timer.expires = - jiffies + (AIC79XX_RESET_DELAY * HZ)/1000; - ahd->platform_data->reset_timer.function = - (ahd_linux_callback_t *)ahd_release_simq; - add_timer(&ahd->platform_data->reset_timer); + tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, + cmd->device->id, &tstate); + if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) == 0 + || (tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) { + col_idx = AHD_NEVER_COL_IDX; + } else { + col_idx = AHD_BUILD_COL_IDX(cmd->device->id, + cmd->device->lun); + } + if ((scb = ahd_get_scb(ahd, col_idx)) == NULL) { + ahd->flags |= AHD_RESOURCE_SHORTAGE; + return SCSI_MLQUEUE_HOST_BUSY; } -} -int -ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg) -{ - ahd->platform_data = - malloc(sizeof(struct ahd_platform_data), M_DEVBUF, M_NOWAIT); - if (ahd->platform_data == NULL) - return (ENOMEM); - memset(ahd->platform_data, 0, sizeof(struct ahd_platform_data)); - TAILQ_INIT(&ahd->platform_data->completeq); - ahd->platform_data->irq = AHD_LINUX_NOIRQ; - ahd->platform_data->hw_dma_mask = 0xFFFFFFFF; - ahd_lockinit(ahd); - ahd_done_lockinit(ahd); - init_timer(&ahd->platform_data->completeq_timer); - ahd->platform_data->completeq_timer.data = (u_long)ahd; - ahd->platform_data->completeq_timer.function = - (ahd_linux_callback_t *)ahd_linux_thread_run_complete_queue; - init_MUTEX_LOCKED(&ahd->platform_data->eh_sem); - init_MUTEX_LOCKED(&ahd->platform_data->dv_sem); - init_MUTEX_LOCKED(&ahd->platform_data->dv_cmd_sem); - ahd->seltime = (aic79xx_seltime & 0x3) << 4; - return (0); -} + scb->io_ctx = cmd; + scb->platform_data->dev = dev; + hscb = scb->hscb; + cmd->host_scribble = (char *)scb; -void -ahd_platform_free(struct ahd_softc *ahd) -{ - struct ahd_linux_target *targ; - struct ahd_linux_device *dev; - int i, j; + /* + * Fill out basics of the HSCB. + */ + hscb->control = 0; + hscb->scsiid = BUILD_SCSIID(ahd, cmd); + hscb->lun = cmd->device->lun; + scb->hscb->task_management = 0; + mask = SCB_GET_TARGET_MASK(ahd, scb); - if (ahd->platform_data != NULL) { - del_timer_sync(&ahd->platform_data->completeq_timer); - ahd_linux_kill_dv_thread(ahd); - if (ahd->platform_data->host != NULL) { - scsi_remove_host(ahd->platform_data->host); - scsi_host_put(ahd->platform_data->host); - } + if ((ahd->user_discenable & mask) != 0) + hscb->control |= DISCENB; - /* destroy all of the device and target objects */ - for (i = 0; i < AHD_NUM_TARGETS; i++) { - targ = ahd->platform_data->targets[i]; - if (targ != NULL) { - /* Keep target around through the loop. */ - targ->refcount++; - for (j = 0; j < AHD_NUM_LUNS; j++) { + if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) + scb->flags |= SCB_PACKETIZED; - if (targ->devices[j] == NULL) - continue; - dev = targ->devices[j]; - ahd_linux_free_device(ahd, dev); - } - /* - * Forcibly free the target now that - * all devices are gone. - */ - ahd_linux_free_target(ahd, targ); - } + if ((tstate->auto_negotiate & mask) != 0) { + scb->flags |= SCB_AUTO_NEGOTIATE; + scb->hscb->control |= MK_MESSAGE; + } + + if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) != 0) { + int msg_bytes; + uint8_t tag_msgs[2]; + + msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs); + if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) { + hscb->control |= tag_msgs[0]; + if (tag_msgs[0] == MSG_ORDERED_TASK) + dev->commands_since_idle_or_otag = 0; + } else + if (dev->commands_since_idle_or_otag == AHD_OTAG_THRESH + && (dev->flags & AHD_DEV_Q_TAGGED) != 0) { + hscb->control |= MSG_ORDERED_TASK; + dev->commands_since_idle_or_otag = 0; + } else { + hscb->control |= MSG_SIMPLE_TASK; } + } - if (ahd->platform_data->irq != AHD_LINUX_NOIRQ) - free_irq(ahd->platform_data->irq, ahd); - if (ahd->tags[0] == BUS_SPACE_PIO - && ahd->bshs[0].ioport != 0) - release_region(ahd->bshs[0].ioport, 256); - if (ahd->tags[1] == BUS_SPACE_PIO - && ahd->bshs[1].ioport != 0) - release_region(ahd->bshs[1].ioport, 256); - if (ahd->tags[0] == BUS_SPACE_MEMIO - && ahd->bshs[0].maddr != NULL) { - iounmap(ahd->bshs[0].maddr); - release_mem_region(ahd->platform_data->mem_busaddr, - 0x1000); + hscb->cdb_len = cmd->cmd_len; + memcpy(hscb->shared_data.idata.cdb, cmd->cmnd, hscb->cdb_len); + + scb->platform_data->xfer_len = 0; + ahd_set_residual(scb, 0); + ahd_set_sense_residual(scb, 0); + scb->sg_count = 0; + if (cmd->use_sg != 0) { + void *sg; + struct scatterlist *cur_seg; + u_int nseg; + int dir; + + cur_seg = (struct scatterlist *)cmd->request_buffer; + dir = cmd->sc_data_direction; + nseg = pci_map_sg(ahd->dev_softc, cur_seg, + cmd->use_sg, dir); + scb->platform_data->xfer_len = 0; + for (sg = scb->sg_list; nseg > 0; nseg--, cur_seg++) { + dma_addr_t addr; + bus_size_t len; + + addr = sg_dma_address(cur_seg); + len = sg_dma_len(cur_seg); + scb->platform_data->xfer_len += len; + sg = ahd_sg_setup(ahd, scb, sg, addr, len, + /*last*/nseg == 1); } - free(ahd->platform_data, M_DEVBUF); + } else if (cmd->request_bufflen != 0) { + void *sg; + dma_addr_t addr; + int dir; + + sg = scb->sg_list; + dir = cmd->sc_data_direction; + addr = pci_map_single(ahd->dev_softc, + cmd->request_buffer, + cmd->request_bufflen, dir); + scb->platform_data->xfer_len = cmd->request_bufflen; + scb->platform_data->buf_busaddr = addr; + sg = ahd_sg_setup(ahd, scb, sg, addr, + cmd->request_bufflen, /*last*/TRUE); } + + LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links); + dev->openings--; + dev->active++; + dev->commands_issued++; + + if ((dev->flags & AHD_DEV_PERIODIC_OTAG) != 0) + dev->commands_since_idle_or_otag++; + scb->flags |= SCB_ACTIVE; + ahd_queue_scb(ahd, scb); + + return 0; } -void -ahd_platform_init(struct ahd_softc *ahd) +/* + * SCSI controller interrupt handler. + */ +irqreturn_t +ahd_linux_isr(int irq, void *dev_id, struct pt_regs * regs) { - /* - * Lookup and commit any modified IO Cell options. - */ - if (ahd->unit < NUM_ELEMENTS(aic79xx_iocell_info)) { - struct ahd_linux_iocell_opts *iocell_opts; - - iocell_opts = &aic79xx_iocell_info[ahd->unit]; - if (iocell_opts->precomp != AIC79XX_DEFAULT_PRECOMP) - AHD_SET_PRECOMP(ahd, iocell_opts->precomp); - if (iocell_opts->slewrate != AIC79XX_DEFAULT_SLEWRATE) - AHD_SET_SLEWRATE(ahd, iocell_opts->slewrate); - if (iocell_opts->amplitude != AIC79XX_DEFAULT_AMPLITUDE) - AHD_SET_AMPLITUDE(ahd, iocell_opts->amplitude); - } + struct ahd_softc *ahd; + u_long flags; + int ours; + ahd = (struct ahd_softc *) dev_id; + ahd_lock(ahd, &flags); + ours = ahd_intr(ahd); + ahd_unlock(ahd, &flags); + return IRQ_RETVAL(ours); } void -ahd_platform_freeze_devq(struct ahd_softc *ahd, struct scb *scb) +ahd_platform_flushwork(struct ahd_softc *ahd) { - ahd_platform_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), - SCB_GET_CHANNEL(ahd, scb), - SCB_GET_LUN(scb), SCB_LIST_NULL, - ROLE_UNKNOWN, CAM_REQUEUE_REQ); + } void -ahd_platform_set_tags(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, - ahd_queue_alg alg) +ahd_send_async(struct ahd_softc *ahd, char channel, + u_int target, u_int lun, ac_code code, void *arg) { - struct ahd_linux_device *dev; - int was_queuing; - int now_queuing; + switch (code) { + case AC_TRANSFER_NEG: + { + char buf[80]; + struct scsi_target *starget; + struct ahd_linux_target *targ; + struct info_str info; + struct ahd_initiator_tinfo *tinfo; + struct ahd_tmode_tstate *tstate; + unsigned int target_ppr_options; - dev = ahd_linux_get_device(ahd, devinfo->channel - 'A', - devinfo->target, - devinfo->lun, /*alloc*/FALSE); - if (dev == NULL) - return; - was_queuing = dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED); - switch (alg) { - default: - case AHD_QUEUE_NONE: - now_queuing = 0; - break; - case AHD_QUEUE_BASIC: - now_queuing = AHD_DEV_Q_BASIC; + BUG_ON(target == CAM_TARGET_WILDCARD); + + info.buffer = buf; + info.length = sizeof(buf); + info.offset = 0; + info.pos = 0; + tinfo = ahd_fetch_transinfo(ahd, channel, ahd->our_id, + target, &tstate); + + /* + * Don't bother reporting results while + * negotiations are still pending. + */ + if (tinfo->curr.period != tinfo->goal.period + || tinfo->curr.width != tinfo->goal.width + || tinfo->curr.offset != tinfo->goal.offset + || tinfo->curr.ppr_options != tinfo->goal.ppr_options) + if (bootverbose == 0) + break; + + /* + * Don't bother reporting results that + * are identical to those last reported. + */ + starget = ahd->platform_data->starget[target]; + targ = scsi_transport_target_data(starget); + if (targ == NULL) + break; + + target_ppr_options = + (spi_dt(starget) ? MSG_EXT_PPR_DT_REQ : 0) + + (spi_qas(starget) ? MSG_EXT_PPR_QAS_REQ : 0) + + (spi_iu(starget) ? MSG_EXT_PPR_IU_REQ : 0); + + if (tinfo->curr.period == spi_period(starget) + && tinfo->curr.width == spi_width(starget) + && tinfo->curr.offset == spi_offset(starget) + && tinfo->curr.ppr_options == target_ppr_options) + if (bootverbose == 0) + break; + + spi_period(starget) = tinfo->curr.period; + spi_width(starget) = tinfo->curr.width; + spi_offset(starget) = tinfo->curr.offset; + spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_DT_REQ; + spi_qas(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_QAS_REQ; + spi_iu(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ; + spi_display_xfer_agreement(starget); break; - case AHD_QUEUE_TAGGED: - now_queuing = AHD_DEV_Q_TAGGED; + } + case AC_SENT_BDR: + { + WARN_ON(lun != CAM_LUN_WILDCARD); + scsi_report_device_reset(ahd->platform_data->host, + channel - 'A', target); break; } - if ((dev->flags & AHD_DEV_FREEZE_TIL_EMPTY) == 0 - && (was_queuing != now_queuing) - && (dev->active != 0)) { - dev->flags |= AHD_DEV_FREEZE_TIL_EMPTY; - dev->qfrozen++; - } - - dev->flags &= ~(AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED|AHD_DEV_PERIODIC_OTAG); - if (now_queuing) { - u_int usertags; - - usertags = ahd_linux_user_tagdepth(ahd, devinfo); - if (!was_queuing) { - /* - * Start out agressively and allow our - * dynamic queue depth algorithm to take - * care of the rest. - */ - dev->maxtags = usertags; - dev->openings = dev->maxtags - dev->active; - } - if (dev->maxtags == 0) { - /* - * Queueing is disabled by the user. - */ - dev->openings = 1; - } else if (alg == AHD_QUEUE_TAGGED) { - dev->flags |= AHD_DEV_Q_TAGGED; - if (aic79xx_periodic_otag != 0) - dev->flags |= AHD_DEV_PERIODIC_OTAG; - } else - dev->flags |= AHD_DEV_Q_BASIC; - } else { - /* We can only have one opening. */ - dev->maxtags = 0; - dev->openings = 1 - dev->active; - } - - if (dev->scsi_device != NULL) { - switch ((dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED))) { - case AHD_DEV_Q_BASIC: - scsi_adjust_queue_depth(dev->scsi_device, - MSG_SIMPLE_TASK, - dev->openings + dev->active); - break; - case AHD_DEV_Q_TAGGED: - scsi_adjust_queue_depth(dev->scsi_device, - MSG_ORDERED_TASK, - dev->openings + dev->active); - break; - default: - /* - * We allow the OS to queue 2 untagged transactions to - * us at any time even though we can only execute them - * serially on the controller/device. This should - * remove some latency. - */ - scsi_adjust_queue_depth(dev->scsi_device, - /*NON-TAGGED*/0, - /*queue depth*/2); - break; + case AC_BUS_RESET: + if (ahd->platform_data->host != NULL) { + scsi_report_bus_reset(ahd->platform_data->host, + channel - 'A'); } - } -} - -int -ahd_platform_abort_scbs(struct ahd_softc *ahd, int target, char channel, - int lun, u_int tag, role_t role, uint32_t status) -{ - return 0; -} - -static void -ahd_linux_thread_run_complete_queue(struct ahd_softc *ahd) -{ - u_long flags; - - ahd_lock(ahd, &flags); - del_timer(&ahd->platform_data->completeq_timer); - ahd->platform_data->flags &= ~AHD_RUN_CMPLT_Q_TIMER; - ahd_linux_run_complete_queue(ahd); - ahd_unlock(ahd, &flags); + break; + default: + panic("ahd_send_async: Unexpected async event"); + } } -static void -ahd_linux_start_dv(struct ahd_softc *ahd) +/* + * Calls the higher level scsi done function and frees the scb. + */ +void +ahd_done(struct ahd_softc *ahd, struct scb *scb) { + struct scsi_cmnd *cmd; + struct ahd_linux_device *dev; - /* - * Freeze the simq and signal ahd_linux_queue to not let any - * more commands through - */ - if ((ahd->platform_data->flags & AHD_DV_ACTIVE) == 0) { -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) - printf("%s: Starting DV\n", ahd_name(ahd)); -#endif - - ahd->platform_data->flags |= AHD_DV_ACTIVE; - ahd_freeze_simq(ahd); - - /* Wake up the DV kthread */ - up(&ahd->platform_data->dv_sem); + if ((scb->flags & SCB_ACTIVE) == 0) { + printf("SCB %d done'd twice\n", SCB_GET_TAG(scb)); + ahd_dump_card_state(ahd); + panic("Stopping for safety"); } -} - -static int -ahd_linux_dv_thread(void *data) -{ - struct ahd_softc *ahd; - int target; - u_long s; - - ahd = (struct ahd_softc *)data; - -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) - printf("In DV Thread\n"); -#endif + LIST_REMOVE(scb, pending_links); + cmd = scb->io_ctx; + dev = scb->platform_data->dev; + dev->active--; + dev->openings++; + if ((cmd->result & (CAM_DEV_QFRZN << 16)) != 0) { + cmd->result &= ~(CAM_DEV_QFRZN << 16); + dev->qfrozen--; + } + ahd_linux_unmap_scb(ahd, scb); /* - * Complete thread creation. + * Guard against stale sense data. + * The Linux mid-layer assumes that sense + * was retrieved anytime the first byte of + * the sense buffer looks "sane". */ - lock_kernel(); - - daemonize("ahd_dv_%d", ahd->unit); - current->flags |= PF_FREEZE; - - unlock_kernel(); - - while (1) { - /* - * Use down_interruptible() rather than down() to - * avoid inclusion in the load average. - */ - down_interruptible(&ahd->platform_data->dv_sem); - - /* Check to see if we've been signaled to exit */ - ahd_lock(ahd, &s); - if ((ahd->platform_data->flags & AHD_DV_SHUTDOWN) != 0) { - ahd_unlock(ahd, &s); - break; - } - ahd_unlock(ahd, &s); + cmd->sense_buffer[0] = 0; + if (ahd_get_transaction_status(scb) == CAM_REQ_INPROG) { + uint32_t amount_xferred; + amount_xferred = + ahd_get_transfer_length(scb) - ahd_get_residual(scb); + if ((scb->flags & SCB_TRANSMISSION_ERROR) != 0) { #ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) - printf("%s: Beginning Domain Validation\n", - ahd_name(ahd)); + if ((ahd_debug & AHD_SHOW_MISC) != 0) { + ahd_print_path(ahd, scb); + printf("Set CAM_UNCOR_PARITY\n"); + } #endif - + ahd_set_transaction_status(scb, CAM_UNCOR_PARITY); +#ifdef AHD_REPORT_UNDERFLOWS /* - * Wait for any pending commands to drain before proceeding. + * This code is disabled by default as some + * clients of the SCSI system do not properly + * initialize the underflow parameter. This + * results in spurious termination of commands + * that complete as expected (e.g. underflow is + * allowed as command can return variable amounts + * of data. */ - ahd_lock(ahd, &s); - while (LIST_FIRST(&ahd->pending_scbs) != NULL) { - ahd->platform_data->flags |= AHD_DV_WAIT_SIMQ_EMPTY; - ahd_unlock(ahd, &s); - down_interruptible(&ahd->platform_data->dv_sem); - ahd_lock(ahd, &s); - } + } else if (amount_xferred < scb->io_ctx->underflow) { + u_int i; - /* - * Wait for the SIMQ to be released so that DV is the - * only reason the queue is frozen. - */ - while (AHD_DV_SIMQ_FROZEN(ahd) == 0) { - ahd->platform_data->flags |= AHD_DV_WAIT_SIMQ_RELEASE; - ahd_unlock(ahd, &s); - down_interruptible(&ahd->platform_data->dv_sem); - ahd_lock(ahd, &s); + ahd_print_path(ahd, scb); + printf("CDB:"); + for (i = 0; i < scb->io_ctx->cmd_len; i++) + printf(" 0x%x", scb->io_ctx->cmnd[i]); + printf("\n"); + ahd_print_path(ahd, scb); + printf("Saw underflow (%ld of %ld bytes). " + "Treated as error\n", + ahd_get_residual(scb), + ahd_get_transfer_length(scb)); + ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR); +#endif + } else { + ahd_set_transaction_status(scb, CAM_REQ_CMP); } - ahd_unlock(ahd, &s); + } else if (ahd_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) { + ahd_linux_handle_scsi_status(ahd, cmd->device, scb); + } - for (target = 0; target < AHD_NUM_TARGETS; target++) - ahd_linux_dv_target(ahd, target); + if (dev->openings == 1 + && ahd_get_transaction_status(scb) == CAM_REQ_CMP + && ahd_get_scsi_status(scb) != SCSI_STATUS_QUEUE_FULL) + dev->tag_success_count++; + /* + * Some devices deal with temporary internal resource + * shortages by returning queue full. When the queue + * full occurrs, we throttle back. Slowly try to get + * back to our previous queue depth. + */ + if ((dev->openings + dev->active) < dev->maxtags + && dev->tag_success_count > AHD_TAG_SUCCESS_INTERVAL) { + dev->tag_success_count = 0; + dev->openings++; + } - ahd_lock(ahd, &s); - ahd->platform_data->flags &= ~AHD_DV_ACTIVE; - ahd_unlock(ahd, &s); + if (dev->active == 0) + dev->commands_since_idle_or_otag = 0; - /* - * Release the SIMQ so that normal commands are - * allowed to continue on the bus. - */ - ahd_release_simq(ahd); + if ((scb->flags & SCB_RECOVERY_SCB) != 0) { + printf("Recovery SCB completes\n"); + if (ahd_get_transaction_status(scb) == CAM_BDR_SENT + || ahd_get_transaction_status(scb) == CAM_REQ_ABORTED) + ahd_set_transaction_status(scb, CAM_CMD_TIMEOUT); + if ((ahd->platform_data->flags & AHD_SCB_UP_EH_SEM) != 0) { + ahd->platform_data->flags &= ~AHD_SCB_UP_EH_SEM; + up(&ahd->platform_data->eh_sem); + } } - up(&ahd->platform_data->eh_sem); - return (0); + + ahd_free_scb(ahd, scb); + ahd_linux_queue_cmd_complete(ahd, cmd); } static void -ahd_linux_kill_dv_thread(struct ahd_softc *ahd) +ahd_linux_handle_scsi_status(struct ahd_softc *ahd, + struct scsi_device *sdev, struct scb *scb) { - u_long s; - - ahd_lock(ahd, &s); - if (ahd->platform_data->dv_pid != 0) { - ahd->platform_data->flags |= AHD_DV_SHUTDOWN; - ahd_unlock(ahd, &s); - up(&ahd->platform_data->dv_sem); + struct ahd_devinfo devinfo; + struct ahd_linux_device *dev = scsi_transport_device_data(sdev); - /* - * Use the eh_sem as an indicator that the - * dv thread is exiting. Note that the dv - * thread must still return after performing - * the up on our semaphore before it has - * completely exited this module. Unfortunately, - * there seems to be no easy way to wait for the - * exit of a thread for which you are not the - * parent (dv threads are parented by init). - * Cross your fingers... - */ - down(&ahd->platform_data->eh_sem); + ahd_compile_devinfo(&devinfo, + ahd->our_id, + sdev->sdev_target->id, sdev->lun, + sdev->sdev_target->channel == 0 ? 'A' : 'B', + ROLE_INITIATOR); + + /* + * We don't currently trust the mid-layer to + * properly deal with queue full or busy. So, + * when one occurs, we tell the mid-layer to + * unconditionally requeue the command to us + * so that we can retry it ourselves. We also + * implement our own throttling mechanism so + * we don't clobber the device with too many + * commands. + */ + switch (ahd_get_scsi_status(scb)) { + default: + break; + case SCSI_STATUS_CHECK_COND: + case SCSI_STATUS_CMD_TERMINATED: + { + struct scsi_cmnd *cmd; /* - * Mark the dv thread as already dead. This - * avoids attempting to kill it a second time. - * This is necessary because we must kill the - * DV thread before calling ahd_free() in the - * module shutdown case to avoid bogus locking - * in the SCSI mid-layer, but we ahd_free() is - * called without killing the DV thread in the - * instance detach case, so ahd_platform_free() - * calls us again to verify that the DV thread - * is dead. + * Copy sense information to the OS's cmd + * structure if it is available. */ - ahd->platform_data->dv_pid = 0; - } else { - ahd_unlock(ahd, &s); - } -} - -#define AHD_LINUX_DV_INQ_SHORT_LEN 36 -#define AHD_LINUX_DV_INQ_LEN 256 -#define AHD_LINUX_DV_TIMEOUT (HZ / 4) + cmd = scb->io_ctx; + if ((scb->flags & (SCB_SENSE|SCB_PKT_SENSE)) != 0) { + struct scsi_status_iu_header *siu; + u_int sense_size; + u_int sense_offset; -#define AHD_SET_DV_STATE(ahd, targ, newstate) \ - ahd_set_dv_state(ahd, targ, newstate, __LINE__) + if (scb->flags & SCB_SENSE) { + sense_size = MIN(sizeof(struct scsi_sense_data) + - ahd_get_sense_residual(scb), + sizeof(cmd->sense_buffer)); + sense_offset = 0; + } else { + /* + * Copy only the sense data into the provided + * buffer. + */ + siu = (struct scsi_status_iu_header *) + scb->sense_data; + sense_size = MIN(scsi_4btoul(siu->sense_length), + sizeof(cmd->sense_buffer)); + sense_offset = SIU_SENSE_OFFSET(siu); + } -static __inline void -ahd_set_dv_state(struct ahd_softc *ahd, struct ahd_linux_target *targ, - ahd_dv_state newstate, u_int line) -{ - ahd_dv_state oldstate; + memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer)); + memcpy(cmd->sense_buffer, + ahd_get_sense_buf(ahd, scb) + + sense_offset, sense_size); + cmd->result |= (DRIVER_SENSE << 24); - oldstate = targ->dv_state; #ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) - printf("%s:%d: Going from state %d to state %d\n", - ahd_name(ahd), line, oldstate, newstate); -#endif - - if (oldstate == newstate) - targ->dv_state_retry++; - else - targ->dv_state_retry = 0; - targ->dv_state = newstate; -} + if (ahd_debug & AHD_SHOW_SENSE) { + int i; -static void -ahd_linux_dv_target(struct ahd_softc *ahd, u_int target_offset) -{ - struct ahd_devinfo devinfo; - struct ahd_linux_target *targ; - struct scsi_cmnd *cmd; - struct scsi_device *scsi_dev; - struct scsi_sense_data *sense; - uint8_t *buffer; - u_long s; - u_int timeout; - int echo_size; - - sense = NULL; - buffer = NULL; - echo_size = 0; - ahd_lock(ahd, &s); - targ = ahd->platform_data->targets[target_offset]; - if (targ == NULL || (targ->flags & AHD_DV_REQUIRED) == 0) { - ahd_unlock(ahd, &s); - return; - } - ahd_compile_devinfo(&devinfo, ahd->our_id, targ->target, /*lun*/0, - targ->channel + 'A', ROLE_INITIATOR); -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, &devinfo); - printf("Performing DV\n"); - } -#endif - - ahd_unlock(ahd, &s); - - cmd = malloc(sizeof(struct scsi_cmnd), M_DEVBUF, M_WAITOK); - scsi_dev = malloc(sizeof(struct scsi_device), M_DEVBUF, M_WAITOK); - scsi_dev->host = ahd->platform_data->host; - scsi_dev->id = devinfo.target; - scsi_dev->lun = devinfo.lun; - scsi_dev->channel = devinfo.channel - 'A'; - ahd->platform_data->dv_scsi_dev = scsi_dev; - - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_INQ_SHORT_ASYNC); - - while (targ->dv_state != AHD_DV_STATE_EXIT) { - timeout = AHD_LINUX_DV_TIMEOUT; - switch (targ->dv_state) { - case AHD_DV_STATE_INQ_SHORT_ASYNC: - case AHD_DV_STATE_INQ_ASYNC: - case AHD_DV_STATE_INQ_ASYNC_VERIFY: - /* - * Set things to async narrow to reduce the - * chance that the INQ will fail. - */ - ahd_lock(ahd, &s); - ahd_set_syncrate(ahd, &devinfo, 0, 0, 0, - AHD_TRANS_GOAL, /*paused*/FALSE); - ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, - AHD_TRANS_GOAL, /*paused*/FALSE); - ahd_unlock(ahd, &s); - timeout = 10 * HZ; - targ->flags &= ~AHD_INQ_VALID; - /* FALLTHROUGH */ - case AHD_DV_STATE_INQ_VERIFY: - { - u_int inq_len; - - if (targ->dv_state == AHD_DV_STATE_INQ_SHORT_ASYNC) - inq_len = AHD_LINUX_DV_INQ_SHORT_LEN; - else - inq_len = targ->inq_data->additional_length + 5; - ahd_linux_dv_inq(ahd, cmd, &devinfo, targ, inq_len); - break; - } - case AHD_DV_STATE_TUR: - case AHD_DV_STATE_BUSY: - timeout = 5 * HZ; - ahd_linux_dv_tur(ahd, cmd, &devinfo); - break; - case AHD_DV_STATE_REBD: - ahd_linux_dv_rebd(ahd, cmd, &devinfo, targ); - break; - case AHD_DV_STATE_WEB: - ahd_linux_dv_web(ahd, cmd, &devinfo, targ); - break; - - case AHD_DV_STATE_REB: - ahd_linux_dv_reb(ahd, cmd, &devinfo, targ); - break; - - case AHD_DV_STATE_SU: - ahd_linux_dv_su(ahd, cmd, &devinfo, targ); - timeout = 50 * HZ; - break; - - default: - ahd_print_devinfo(ahd, &devinfo); - printf("Unknown DV state %d\n", targ->dv_state); - goto out; - } - - /* Queue the command and wait for it to complete */ - /* Abuse eh_timeout in the scsi_cmnd struct for our purposes */ - init_timer(&cmd->eh_timeout); -#ifdef AHD_DEBUG - if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) - /* - * All of the printfs during negotiation - * really slow down the negotiation. - * Add a bit of time just to be safe. - */ - timeout += HZ; -#endif - scsi_add_timer(cmd, timeout, ahd_linux_dv_timeout); - /* - * In 2.5.X, it is assumed that all calls from the - * "midlayer" (which we are emulating) will have the - * ahd host lock held. For other kernels, the - * io_request_lock must be held. - */ -#if AHD_SCSI_HAS_HOST_LOCK != 0 - ahd_lock(ahd, &s); -#else - spin_lock_irqsave(&io_request_lock, s); -#endif - ahd_linux_queue(cmd, ahd_linux_dv_complete); -#if AHD_SCSI_HAS_HOST_LOCK != 0 - ahd_unlock(ahd, &s); -#else - spin_unlock_irqrestore(&io_request_lock, s); -#endif - down_interruptible(&ahd->platform_data->dv_cmd_sem); - /* - * Wait for the SIMQ to be released so that DV is the - * only reason the queue is frozen. - */ - ahd_lock(ahd, &s); - while (AHD_DV_SIMQ_FROZEN(ahd) == 0) { - ahd->platform_data->flags |= AHD_DV_WAIT_SIMQ_RELEASE; - ahd_unlock(ahd, &s); - down_interruptible(&ahd->platform_data->dv_sem); - ahd_lock(ahd, &s); - } - ahd_unlock(ahd, &s); - - ahd_linux_dv_transition(ahd, cmd, &devinfo, targ); - } - -out: - if ((targ->flags & AHD_INQ_VALID) != 0 - && ahd_linux_get_device(ahd, devinfo.channel - 'A', - devinfo.target, devinfo.lun, - /*alloc*/FALSE) == NULL) { - /* - * The DV state machine failed to configure this device. - * This is normal if DV is disabled. Since we have inquiry - * data, filter it and use the "optimistic" negotiation - * parameters found in the inquiry string. - */ - ahd_linux_filter_inquiry(ahd, &devinfo); - if ((targ->flags & (AHD_BASIC_DV|AHD_ENHANCED_DV)) != 0) { - ahd_print_devinfo(ahd, &devinfo); - printf("DV failed to configure device. " - "Please file a bug report against " - "this driver.\n"); - } - } - - if (cmd != NULL) - free(cmd, M_DEVBUF); - - if (ahd->platform_data->dv_scsi_dev != NULL) { - free(ahd->platform_data->dv_scsi_dev, M_DEVBUF); - ahd->platform_data->dv_scsi_dev = NULL; - } - - ahd_lock(ahd, &s); - if (targ->dv_buffer != NULL) { - free(targ->dv_buffer, M_DEVBUF); - targ->dv_buffer = NULL; - } - if (targ->dv_buffer1 != NULL) { - free(targ->dv_buffer1, M_DEVBUF); - targ->dv_buffer1 = NULL; - } - targ->flags &= ~AHD_DV_REQUIRED; - if (targ->refcount == 0) - ahd_linux_free_target(ahd, targ); - ahd_unlock(ahd, &s); -} - -static __inline int -ahd_linux_dv_fallback(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) -{ - u_long s; - int retval; - - ahd_lock(ahd, &s); - retval = ahd_linux_fallback(ahd, devinfo); - ahd_unlock(ahd, &s); - - return (retval); -} - -static void -ahd_linux_dv_transition(struct ahd_softc *ahd, struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo, - struct ahd_linux_target *targ) -{ - u_int32_t status; - - status = aic_error_action(cmd, targ->inq_data, - ahd_cmd_get_transaction_status(cmd), - ahd_cmd_get_scsi_status(cmd)); - - -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("Entering ahd_linux_dv_transition, state= %d, " - "status= 0x%x, cmd->result= 0x%x\n", targ->dv_state, - status, cmd->result); - } -#endif - - switch (targ->dv_state) { - case AHD_DV_STATE_INQ_SHORT_ASYNC: - case AHD_DV_STATE_INQ_ASYNC: - switch (status & SS_MASK) { - case SS_NOP: - { - AHD_SET_DV_STATE(ahd, targ, targ->dv_state+1); - break; - } - case SS_INQ_REFRESH: - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_INQ_SHORT_ASYNC); - break; - case SS_TUR: - case SS_RETRY: - AHD_SET_DV_STATE(ahd, targ, targ->dv_state); - if (ahd_cmd_get_transaction_status(cmd) - == CAM_REQUEUE_REQ) - targ->dv_state_retry--; - if ((status & SS_ERRMASK) == EBUSY) - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_BUSY); - if (targ->dv_state_retry < 10) - break; - /* FALLTHROUGH */ - default: - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("Failed DV inquiry, skipping\n"); - } -#endif - break; - } - break; - case AHD_DV_STATE_INQ_ASYNC_VERIFY: - switch (status & SS_MASK) { - case SS_NOP: - { - u_int xportflags; - u_int spi3data; - - if (memcmp(targ->inq_data, targ->dv_buffer, - AHD_LINUX_DV_INQ_LEN) != 0) { - /* - * Inquiry data must have changed. - * Try from the top again. - */ - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_INQ_SHORT_ASYNC); - break; - } - - AHD_SET_DV_STATE(ahd, targ, targ->dv_state+1); - targ->flags |= AHD_INQ_VALID; - if (ahd_linux_user_dv_setting(ahd) == 0) - break; - - xportflags = targ->inq_data->flags; - if ((xportflags & (SID_Sync|SID_WBus16)) == 0) - break; - - spi3data = targ->inq_data->spi3data; - switch (spi3data & SID_SPI_CLOCK_DT_ST) { - default: - case SID_SPI_CLOCK_ST: - /* Assume only basic DV is supported. */ - targ->flags |= AHD_BASIC_DV; - break; - case SID_SPI_CLOCK_DT: - case SID_SPI_CLOCK_DT_ST: - targ->flags |= AHD_ENHANCED_DV; - break; - } - break; - } - case SS_INQ_REFRESH: - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_INQ_SHORT_ASYNC); - break; - case SS_TUR: - case SS_RETRY: - AHD_SET_DV_STATE(ahd, targ, targ->dv_state); - if (ahd_cmd_get_transaction_status(cmd) - == CAM_REQUEUE_REQ) - targ->dv_state_retry--; - - if ((status & SS_ERRMASK) == EBUSY) - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_BUSY); - if (targ->dv_state_retry < 10) - break; - /* FALLTHROUGH */ - default: - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("Failed DV inquiry, skipping\n"); - } -#endif - break; - } - break; - case AHD_DV_STATE_INQ_VERIFY: - switch (status & SS_MASK) { - case SS_NOP: - { - - if (memcmp(targ->inq_data, targ->dv_buffer, - AHD_LINUX_DV_INQ_LEN) == 0) { - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); - break; - } - -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - int i; - - ahd_print_devinfo(ahd, devinfo); - printf("Inquiry buffer mismatch:"); - for (i = 0; i < AHD_LINUX_DV_INQ_LEN; i++) { + printf("Copied %d bytes of sense data at %d:", + sense_size, sense_offset); + for (i = 0; i < sense_size; i++) { if ((i & 0xF) == 0) - printf("\n "); - printf("0x%x:0x0%x ", - ((uint8_t *)targ->inq_data)[i], - targ->dv_buffer[i]); + printf("\n"); + printf("0x%x ", cmd->sense_buffer[i]); } printf("\n"); } #endif - - if (ahd_linux_dv_fallback(ahd, devinfo) != 0) { - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); - break; - } - /* - * Do not count "falling back" - * against our retries. - */ - targ->dv_state_retry = 0; - AHD_SET_DV_STATE(ahd, targ, targ->dv_state); - break; - } - case SS_INQ_REFRESH: - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_INQ_SHORT_ASYNC); - break; - case SS_TUR: - case SS_RETRY: - AHD_SET_DV_STATE(ahd, targ, targ->dv_state); - if (ahd_cmd_get_transaction_status(cmd) - == CAM_REQUEUE_REQ) { - targ->dv_state_retry--; - } else if ((status & SSQ_FALLBACK) != 0) { - if (ahd_linux_dv_fallback(ahd, devinfo) != 0) { - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_EXIT); - break; - } - /* - * Do not count "falling back" - * against our retries. - */ - targ->dv_state_retry = 0; - } else if ((status & SS_ERRMASK) == EBUSY) - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_BUSY); - if (targ->dv_state_retry < 10) - break; - /* FALLTHROUGH */ - default: - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("Failed DV inquiry, skipping\n"); - } -#endif - break; - } - break; - - case AHD_DV_STATE_TUR: - switch (status & SS_MASK) { - case SS_NOP: - if ((targ->flags & AHD_BASIC_DV) != 0) { - ahd_linux_filter_inquiry(ahd, devinfo); - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_INQ_VERIFY); - } else if ((targ->flags & AHD_ENHANCED_DV) != 0) { - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_REBD); - } else { - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); - } - break; - case SS_RETRY: - case SS_TUR: - if ((status & SS_ERRMASK) == EBUSY) { - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_BUSY); - break; - } - AHD_SET_DV_STATE(ahd, targ, targ->dv_state); - if (ahd_cmd_get_transaction_status(cmd) - == CAM_REQUEUE_REQ) { - targ->dv_state_retry--; - } else if ((status & SSQ_FALLBACK) != 0) { - if (ahd_linux_dv_fallback(ahd, devinfo) != 0) { - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_EXIT); - break; - } - /* - * Do not count "falling back" - * against our retries. - */ - targ->dv_state_retry = 0; - } - if (targ->dv_state_retry >= 10) { -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("DV TUR reties exhausted\n"); - } -#endif - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); - break; - } - if (status & SSQ_DELAY) - ssleep(1); - - break; - case SS_START: - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_SU); - break; - case SS_INQ_REFRESH: - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_INQ_SHORT_ASYNC); - break; - default: - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); - break; } break; - - case AHD_DV_STATE_REBD: - switch (status & SS_MASK) { - case SS_NOP: - { - uint32_t echo_size; - - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_WEB); - echo_size = scsi_3btoul(&targ->dv_buffer[1]); - echo_size &= 0x1FFF; -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("Echo buffer size= %d\n", echo_size); - } -#endif - if (echo_size == 0) { - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); - break; - } - - /* Generate the buffer pattern */ - targ->dv_echo_size = echo_size; - ahd_linux_generate_dv_pattern(targ); + } + case SCSI_STATUS_QUEUE_FULL: + /* + * By the time the core driver has returned this + * command, all other commands that were queued + * to us but not the device have been returned. + * This ensures that dev->active is equal to + * the number of commands actually queued to + * the device. + */ + dev->tag_success_count = 0; + if (dev->active != 0) { /* - * Setup initial negotiation values. + * Drop our opening count to the number + * of commands currently outstanding. */ - ahd_linux_filter_inquiry(ahd, devinfo); - break; - } - case SS_INQ_REFRESH: - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_INQ_SHORT_ASYNC); - break; - case SS_RETRY: - AHD_SET_DV_STATE(ahd, targ, targ->dv_state); - if (ahd_cmd_get_transaction_status(cmd) - == CAM_REQUEUE_REQ) - targ->dv_state_retry--; - if (targ->dv_state_retry <= 10) - break; + dev->openings = 0; #ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("DV REBD reties exhausted\n"); + if ((ahd_debug & AHD_SHOW_QFULL) != 0) { + ahd_print_path(ahd, scb); + printf("Dropping tag count to %d\n", + dev->active); } #endif - /* FALLTHROUGH */ - case SS_FATAL: - default: - /* - * Setup initial negotiation values - * and try level 1 DV. - */ - ahd_linux_filter_inquiry(ahd, devinfo); - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_INQ_VERIFY); - targ->dv_echo_size = 0; - break; - } - break; + if (dev->active == dev->tags_on_last_queuefull) { - case AHD_DV_STATE_WEB: - switch (status & SS_MASK) { - case SS_NOP: - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_REB); - break; - case SS_INQ_REFRESH: - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_INQ_SHORT_ASYNC); - break; - case SS_RETRY: - AHD_SET_DV_STATE(ahd, targ, targ->dv_state); - if (ahd_cmd_get_transaction_status(cmd) - == CAM_REQUEUE_REQ) { - targ->dv_state_retry--; - } else if ((status & SSQ_FALLBACK) != 0) { - if (ahd_linux_dv_fallback(ahd, devinfo) != 0) { - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_EXIT); - break; - } + dev->last_queuefull_same_count++; /* - * Do not count "falling back" - * against our retries. + * If we repeatedly see a queue full + * at the same queue depth, this + * device has a fixed number of tag + * slots. Lock in this tag depth + * so we stop seeing queue fulls from + * this device. */ - targ->dv_state_retry = 0; - } - if (targ->dv_state_retry <= 10) - break; - /* FALLTHROUGH */ -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("DV WEB reties exhausted\n"); - } -#endif - default: - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); - break; - } - break; - - case AHD_DV_STATE_REB: - switch (status & SS_MASK) { - case SS_NOP: - if (memcmp(targ->dv_buffer, targ->dv_buffer1, - targ->dv_echo_size) != 0) { - if (ahd_linux_dv_fallback(ahd, devinfo) != 0) - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_EXIT); - else - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_WEB); - break; - } - - if (targ->dv_buffer != NULL) { - free(targ->dv_buffer, M_DEVBUF); - targ->dv_buffer = NULL; - } - if (targ->dv_buffer1 != NULL) { - free(targ->dv_buffer1, M_DEVBUF); - targ->dv_buffer1 = NULL; - } - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); - break; - case SS_INQ_REFRESH: - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_INQ_SHORT_ASYNC); - break; - case SS_RETRY: - AHD_SET_DV_STATE(ahd, targ, targ->dv_state); - if (ahd_cmd_get_transaction_status(cmd) - == CAM_REQUEUE_REQ) { - targ->dv_state_retry--; - } else if ((status & SSQ_FALLBACK) != 0) { - if (ahd_linux_dv_fallback(ahd, devinfo) != 0) { - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_EXIT); - break; + if (dev->last_queuefull_same_count + == AHD_LOCK_TAGS_COUNT) { + dev->maxtags = dev->active; + ahd_print_path(ahd, scb); + printf("Locking max tag count at %d\n", + dev->active); } - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_WEB); - } - if (targ->dv_state_retry <= 10) { - if ((status & (SSQ_DELAY_RANDOM|SSQ_DELAY))!= 0) - msleep(ahd->our_id*1000/10); - break; - } -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("DV REB reties exhausted\n"); + } else { + dev->tags_on_last_queuefull = dev->active; + dev->last_queuefull_same_count = 0; } -#endif - /* FALLTHROUGH */ - default: - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); - break; - } - break; - - case AHD_DV_STATE_SU: - switch (status & SS_MASK) { - case SS_NOP: - case SS_INQ_REFRESH: - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_INQ_SHORT_ASYNC); - break; - default: - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); + ahd_set_transaction_status(scb, CAM_REQUEUE_REQ); + ahd_set_scsi_status(scb, SCSI_STATUS_OK); + ahd_platform_set_tags(ahd, &devinfo, + (dev->flags & AHD_DEV_Q_BASIC) + ? AHD_QUEUE_BASIC : AHD_QUEUE_TAGGED); break; } - break; - - case AHD_DV_STATE_BUSY: - switch (status & SS_MASK) { - case SS_NOP: - case SS_INQ_REFRESH: - AHD_SET_DV_STATE(ahd, targ, - AHD_DV_STATE_INQ_SHORT_ASYNC); - break; - case SS_TUR: - case SS_RETRY: - AHD_SET_DV_STATE(ahd, targ, targ->dv_state); - if (ahd_cmd_get_transaction_status(cmd) - == CAM_REQUEUE_REQ) { - targ->dv_state_retry--; - } else if (targ->dv_state_retry < 60) { - if ((status & SSQ_DELAY) != 0) - ssleep(1); - } else { -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("DV BUSY reties exhausted\n"); - } -#endif - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); - } - break; - default: - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); - break; - } - break; - - default: - printf("%s: Invalid DV completion state %d\n", ahd_name(ahd), - targ->dv_state); - AHD_SET_DV_STATE(ahd, targ, AHD_DV_STATE_EXIT); - break; - } -} - -static void -ahd_linux_dv_fill_cmd(struct ahd_softc *ahd, struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo) -{ - memset(cmd, 0, sizeof(struct scsi_cmnd)); - cmd->device = ahd->platform_data->dv_scsi_dev; - cmd->scsi_done = ahd_linux_dv_complete; -} - -/* - * Synthesize an inquiry command. On the return trip, it'll be - * sniffed and the device transfer settings set for us. - */ -static void -ahd_linux_dv_inq(struct ahd_softc *ahd, struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo, struct ahd_linux_target *targ, - u_int request_length) -{ - -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("Sending INQ\n"); - } -#endif - if (targ->inq_data == NULL) - targ->inq_data = malloc(AHD_LINUX_DV_INQ_LEN, - M_DEVBUF, M_WAITOK); - if (targ->dv_state > AHD_DV_STATE_INQ_ASYNC) { - if (targ->dv_buffer != NULL) - free(targ->dv_buffer, M_DEVBUF); - targ->dv_buffer = malloc(AHD_LINUX_DV_INQ_LEN, - M_DEVBUF, M_WAITOK); - } - - ahd_linux_dv_fill_cmd(ahd, cmd, devinfo); - cmd->sc_data_direction = DMA_FROM_DEVICE; - cmd->cmd_len = 6; - cmd->cmnd[0] = INQUIRY; - cmd->cmnd[4] = request_length; - cmd->request_bufflen = request_length; - if (targ->dv_state > AHD_DV_STATE_INQ_ASYNC) - cmd->request_buffer = targ->dv_buffer; - else - cmd->request_buffer = targ->inq_data; - memset(cmd->request_buffer, 0, AHD_LINUX_DV_INQ_LEN); -} - -static void -ahd_linux_dv_tur(struct ahd_softc *ahd, struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo) -{ - -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("Sending TUR\n"); - } -#endif - /* Do a TUR to clear out any non-fatal transitional state */ - ahd_linux_dv_fill_cmd(ahd, cmd, devinfo); - cmd->sc_data_direction = DMA_NONE; - cmd->cmd_len = 6; - cmd->cmnd[0] = TEST_UNIT_READY; -} - -#define AHD_REBD_LEN 4 - -static void -ahd_linux_dv_rebd(struct ahd_softc *ahd, struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo, struct ahd_linux_target *targ) -{ - -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("Sending REBD\n"); - } -#endif - if (targ->dv_buffer != NULL) - free(targ->dv_buffer, M_DEVBUF); - targ->dv_buffer = malloc(AHD_REBD_LEN, M_DEVBUF, M_WAITOK); - ahd_linux_dv_fill_cmd(ahd, cmd, devinfo); - cmd->sc_data_direction = DMA_FROM_DEVICE; - cmd->cmd_len = 10; - cmd->cmnd[0] = READ_BUFFER; - cmd->cmnd[1] = 0x0b; - scsi_ulto3b(AHD_REBD_LEN, &cmd->cmnd[6]); - cmd->request_bufflen = AHD_REBD_LEN; - cmd->underflow = cmd->request_bufflen; - cmd->request_buffer = targ->dv_buffer; -} - -static void -ahd_linux_dv_web(struct ahd_softc *ahd, struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo, struct ahd_linux_target *targ) -{ - -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("Sending WEB\n"); - } -#endif - ahd_linux_dv_fill_cmd(ahd, cmd, devinfo); - cmd->sc_data_direction = DMA_TO_DEVICE; - cmd->cmd_len = 10; - cmd->cmnd[0] = WRITE_BUFFER; - cmd->cmnd[1] = 0x0a; - scsi_ulto3b(targ->dv_echo_size, &cmd->cmnd[6]); - cmd->request_bufflen = targ->dv_echo_size; - cmd->underflow = cmd->request_bufflen; - cmd->request_buffer = targ->dv_buffer; -} - -static void -ahd_linux_dv_reb(struct ahd_softc *ahd, struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo, struct ahd_linux_target *targ) -{ - -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("Sending REB\n"); - } -#endif - ahd_linux_dv_fill_cmd(ahd, cmd, devinfo); - cmd->sc_data_direction = DMA_FROM_DEVICE; - cmd->cmd_len = 10; - cmd->cmnd[0] = READ_BUFFER; - cmd->cmnd[1] = 0x0a; - scsi_ulto3b(targ->dv_echo_size, &cmd->cmnd[6]); - cmd->request_bufflen = targ->dv_echo_size; - cmd->underflow = cmd->request_bufflen; - cmd->request_buffer = targ->dv_buffer1; -} - -static void -ahd_linux_dv_su(struct ahd_softc *ahd, struct scsi_cmnd *cmd, - struct ahd_devinfo *devinfo, - struct ahd_linux_target *targ) -{ - u_int le; - - le = SID_IS_REMOVABLE(targ->inq_data) ? SSS_LOEJ : 0; - -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("Sending SU\n"); - } -#endif - ahd_linux_dv_fill_cmd(ahd, cmd, devinfo); - cmd->sc_data_direction = DMA_NONE; - cmd->cmd_len = 6; - cmd->cmnd[0] = START_STOP_UNIT; - cmd->cmnd[4] = le | SSS_START; -} - -static int -ahd_linux_fallback(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) -{ - struct ahd_linux_target *targ; - struct ahd_initiator_tinfo *tinfo; - struct ahd_transinfo *goal; - struct ahd_tmode_tstate *tstate; - u_int width; - u_int period; - u_int offset; - u_int ppr_options; - u_int cur_speed; - u_int wide_speed; - u_int narrow_speed; - u_int fallback_speed; - -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - ahd_print_devinfo(ahd, devinfo); - printf("Trying to fallback\n"); - } -#endif - targ = ahd->platform_data->targets[devinfo->target_offset]; - tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, - devinfo->our_scsiid, - devinfo->target, &tstate); - goal = &tinfo->goal; - width = goal->width; - period = goal->period; - offset = goal->offset; - ppr_options = goal->ppr_options; - if (offset == 0) - period = AHD_ASYNC_XFER_PERIOD; - if (targ->dv_next_narrow_period == 0) - targ->dv_next_narrow_period = MAX(period, AHD_SYNCRATE_ULTRA2); - if (targ->dv_next_wide_period == 0) - targ->dv_next_wide_period = period; - if (targ->dv_max_width == 0) - targ->dv_max_width = width; - if (targ->dv_max_ppr_options == 0) - targ->dv_max_ppr_options = ppr_options; - if (targ->dv_last_ppr_options == 0) - targ->dv_last_ppr_options = ppr_options; - - cur_speed = aic_calc_speed(width, period, offset, AHD_SYNCRATE_MIN); - wide_speed = aic_calc_speed(MSG_EXT_WDTR_BUS_16_BIT, - targ->dv_next_wide_period, - MAX_OFFSET, AHD_SYNCRATE_MIN); - narrow_speed = aic_calc_speed(MSG_EXT_WDTR_BUS_8_BIT, - targ->dv_next_narrow_period, - MAX_OFFSET, AHD_SYNCRATE_MIN); - fallback_speed = aic_calc_speed(width, period+1, offset, - AHD_SYNCRATE_MIN); -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - printf("cur_speed= %d, wide_speed= %d, narrow_speed= %d, " - "fallback_speed= %d\n", cur_speed, wide_speed, - narrow_speed, fallback_speed); - } -#endif - - if (cur_speed > 160000) { - /* - * Paced/DT/IU_REQ only transfer speeds. All we - * can do is fallback in terms of syncrate. - */ - period++; - } else if (cur_speed > 80000) { - if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) { - /* - * Try without IU_REQ as it may be confusing - * an expander. - */ - ppr_options &= ~MSG_EXT_PPR_IU_REQ; - } else { - /* - * Paced/DT only transfer speeds. All we - * can do is fallback in terms of syncrate. - */ - period++; - ppr_options = targ->dv_max_ppr_options; - } - } else if (cur_speed > 3300) { - - /* - * In this range we the following - * options ordered from highest to - * lowest desireability: - * - * o Wide/DT - * o Wide/non-DT - * o Narrow at a potentally higher sync rate. - * - * All modes are tested with and without IU_REQ - * set since using IUs may confuse an expander. - */ - if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) { - - ppr_options &= ~MSG_EXT_PPR_IU_REQ; - } else if ((ppr_options & MSG_EXT_PPR_DT_REQ) != 0) { - /* - * Try going non-DT. - */ - ppr_options = targ->dv_max_ppr_options; - ppr_options &= ~MSG_EXT_PPR_DT_REQ; - } else if (targ->dv_last_ppr_options != 0) { - /* - * Try without QAS or any other PPR options. - * We may need a non-PPR message to work with - * an expander. We look at the "last PPR options" - * so we will perform this fallback even if the - * target responded to our PPR negotiation with - * no option bits set. - */ - ppr_options = 0; - } else if (width == MSG_EXT_WDTR_BUS_16_BIT) { - /* - * If the next narrow speed is greater than - * the next wide speed, fallback to narrow. - * Otherwise fallback to the next DT/Wide setting. - * The narrow async speed will always be smaller - * than the wide async speed, so handle this case - * specifically. - */ - ppr_options = targ->dv_max_ppr_options; - if (narrow_speed > fallback_speed - || period >= AHD_ASYNC_XFER_PERIOD) { - targ->dv_next_wide_period = period+1; - width = MSG_EXT_WDTR_BUS_8_BIT; - period = targ->dv_next_narrow_period; - } else { - period++; - } - } else if ((ahd->features & AHD_WIDE) != 0 - && targ->dv_max_width != 0 - && wide_speed >= fallback_speed - && (targ->dv_next_wide_period <= AHD_ASYNC_XFER_PERIOD - || period >= AHD_ASYNC_XFER_PERIOD)) { - - /* - * We are narrow. Try falling back - * to the next wide speed with - * all supported ppr options set. - */ - targ->dv_next_narrow_period = period+1; - width = MSG_EXT_WDTR_BUS_16_BIT; - period = targ->dv_next_wide_period; - ppr_options = targ->dv_max_ppr_options; - } else { - /* Only narrow fallback is allowed. */ - period++; - ppr_options = targ->dv_max_ppr_options; - } - } else { - return (-1); - } - offset = MAX_OFFSET; - ahd_find_syncrate(ahd, &period, &ppr_options, AHD_SYNCRATE_PACED); - ahd_set_width(ahd, devinfo, width, AHD_TRANS_GOAL, FALSE); - if (period == 0) { - period = 0; - offset = 0; - ppr_options = 0; - if (width == MSG_EXT_WDTR_BUS_8_BIT) - targ->dv_next_narrow_period = AHD_ASYNC_XFER_PERIOD; - else - targ->dv_next_wide_period = AHD_ASYNC_XFER_PERIOD; - } - ahd_set_syncrate(ahd, devinfo, period, offset, - ppr_options, AHD_TRANS_GOAL, FALSE); - targ->dv_last_ppr_options = ppr_options; - return (0); -} - -static void -ahd_linux_dv_timeout(struct scsi_cmnd *cmd) -{ - struct ahd_softc *ahd; - struct scb *scb; - u_long flags; - - ahd = *((struct ahd_softc **)cmd->device->host->hostdata); - ahd_lock(ahd, &flags); - -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) { - printf("%s: Timeout while doing DV command %x.\n", - ahd_name(ahd), cmd->cmnd[0]); - ahd_dump_card_state(ahd); - } -#endif - - /* - * Guard against "done race". No action is - * required if we just completed. - */ - if ((scb = (struct scb *)cmd->host_scribble) == NULL) { - ahd_unlock(ahd, &flags); - return; - } - - /* - * Command has not completed. Mark this - * SCB as having failing status prior to - * resetting the bus, so we get the correct - * error code. - */ - if ((scb->flags & SCB_SENSE) != 0) - ahd_set_transaction_status(scb, CAM_AUTOSENSE_FAIL); - else - ahd_set_transaction_status(scb, CAM_CMD_TIMEOUT); - ahd_reset_channel(ahd, cmd->device->channel + 'A', /*initiate*/TRUE); - - /* - * Add a minimal bus settle delay for devices that are slow to - * respond after bus resets. - */ - ahd_freeze_simq(ahd); - init_timer(&ahd->platform_data->reset_timer); - ahd->platform_data->reset_timer.data = (u_long)ahd; - ahd->platform_data->reset_timer.expires = jiffies + HZ / 2; - ahd->platform_data->reset_timer.function = - (ahd_linux_callback_t *)ahd_release_simq; - add_timer(&ahd->platform_data->reset_timer); - ahd_linux_run_complete_queue(ahd); - ahd_unlock(ahd, &flags); -} - -static void -ahd_linux_dv_complete(struct scsi_cmnd *cmd) -{ - struct ahd_softc *ahd; - - ahd = *((struct ahd_softc **)cmd->device->host->hostdata); - - /* Delete the DV timer before it goes off! */ - scsi_delete_timer(cmd); - -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_DV) - printf("%s:%c:%d: Command completed, status= 0x%x\n", - ahd_name(ahd), cmd->device->channel, cmd->device->id, - cmd->result); -#endif - - /* Wake up the state machine */ - up(&ahd->platform_data->dv_cmd_sem); -} - -static void -ahd_linux_generate_dv_pattern(struct ahd_linux_target *targ) -{ - uint16_t b; - u_int i; - u_int j; - - if (targ->dv_buffer != NULL) - free(targ->dv_buffer, M_DEVBUF); - targ->dv_buffer = malloc(targ->dv_echo_size, M_DEVBUF, M_WAITOK); - if (targ->dv_buffer1 != NULL) - free(targ->dv_buffer1, M_DEVBUF); - targ->dv_buffer1 = malloc(targ->dv_echo_size, M_DEVBUF, M_WAITOK); - - i = 0; - - b = 0x0001; - for (j = 0 ; i < targ->dv_echo_size; j++) { - if (j < 32) { - /* - * 32bytes of sequential numbers. - */ - targ->dv_buffer[i++] = j & 0xff; - } else if (j < 48) { - /* - * 32bytes of repeating 0x0000, 0xffff. - */ - targ->dv_buffer[i++] = (j & 0x02) ? 0xff : 0x00; - } else if (j < 64) { - /* - * 32bytes of repeating 0x5555, 0xaaaa. - */ - targ->dv_buffer[i++] = (j & 0x02) ? 0xaa : 0x55; - } else { - /* - * Remaining buffer is filled with a repeating - * patter of: - * - * 0xffff - * ~0x0001 << shifted once in each loop. - */ - if (j & 0x02) { - if (j & 0x01) { - targ->dv_buffer[i++] = ~(b >> 8) & 0xff; - b <<= 1; - if (b == 0x0000) - b = 0x0001; - } else { - targ->dv_buffer[i++] = (~b & 0xff); - } - } else { - targ->dv_buffer[i++] = 0xff; - } - } - } -} - -static u_int -ahd_linux_user_tagdepth(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) -{ - static int warned_user; - u_int tags; - - tags = 0; - if ((ahd->user_discenable & devinfo->target_mask) != 0) { - if (ahd->unit >= NUM_ELEMENTS(aic79xx_tag_info)) { - - if (warned_user == 0) { - printf(KERN_WARNING -"aic79xx: WARNING: Insufficient tag_info instances\n" -"aic79xx: for installed controllers. Using defaults\n" -"aic79xx: Please update the aic79xx_tag_info array in\n" -"aic79xx: the aic79xx_osm.c source file.\n"); - warned_user++; - } - tags = AHD_MAX_QUEUE; - } else { - adapter_tag_info_t *tag_info; - - tag_info = &aic79xx_tag_info[ahd->unit]; - tags = tag_info->tag_commands[devinfo->target_offset]; - if (tags > AHD_MAX_QUEUE) - tags = AHD_MAX_QUEUE; - } - } - return (tags); -} - -static u_int -ahd_linux_user_dv_setting(struct ahd_softc *ahd) -{ - static int warned_user; - int dv; - - if (ahd->unit >= NUM_ELEMENTS(aic79xx_dv_settings)) { - - if (warned_user == 0) { - printf(KERN_WARNING -"aic79xx: WARNING: Insufficient dv settings instances\n" -"aic79xx: for installed controllers. Using defaults\n" -"aic79xx: Please update the aic79xx_dv_settings array in" -"aic79xx: the aic79xx_osm.c source file.\n"); - warned_user++; - } - dv = -1; - } else { - - dv = aic79xx_dv_settings[ahd->unit]; - } - - if (dv < 0) { /* - * Apply the default. + * Drop down to a single opening, and treat this + * as if the target returned BUSY SCSI status. */ - dv = 1; - if (ahd->seep_config != 0) - dv = (ahd->seep_config->bios_control & CFENABLEDV); - } - return (dv); -} - -static void -ahd_linux_setup_user_rd_strm_settings(struct ahd_softc *ahd) -{ - static int warned_user; - u_int rd_strm_mask; - u_int target_id; - - /* - * If we have specific read streaming info for this controller, - * apply it. Otherwise use the defaults. - */ - if (ahd->unit >= NUM_ELEMENTS(aic79xx_rd_strm_info)) { - - if (warned_user == 0) { - - printf(KERN_WARNING -"aic79xx: WARNING: Insufficient rd_strm instances\n" -"aic79xx: for installed controllers. Using defaults\n" -"aic79xx: Please update the aic79xx_rd_strm_info array\n" -"aic79xx: in the aic79xx_osm.c source file.\n"); - warned_user++; - } - rd_strm_mask = AIC79XX_CONFIGED_RD_STRM; - } else { - - rd_strm_mask = aic79xx_rd_strm_info[ahd->unit]; - } - for (target_id = 0; target_id < 16; target_id++) { - struct ahd_devinfo devinfo; - struct ahd_initiator_tinfo *tinfo; - struct ahd_tmode_tstate *tstate; - - tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, - target_id, &tstate); - ahd_compile_devinfo(&devinfo, ahd->our_id, target_id, - CAM_LUN_WILDCARD, 'A', ROLE_INITIATOR); - tinfo->user.ppr_options &= ~MSG_EXT_PPR_RD_STRM; - if ((rd_strm_mask & devinfo.target_mask) != 0) - tinfo->user.ppr_options |= MSG_EXT_PPR_RD_STRM; - } -} - -/* - * Determines the queue depth for a given device. - */ -static void -ahd_linux_device_queue_depth(struct ahd_softc *ahd, - struct ahd_linux_device *dev) -{ - struct ahd_devinfo devinfo; - u_int tags; - - ahd_compile_devinfo(&devinfo, - ahd->our_id, - dev->target->target, dev->lun, - dev->target->channel == 0 ? 'A' : 'B', - ROLE_INITIATOR); - tags = ahd_linux_user_tagdepth(ahd, &devinfo); - if (tags != 0 - && dev->scsi_device != NULL - && dev->scsi_device->tagged_supported != 0) { - - ahd_set_tags(ahd, &devinfo, AHD_QUEUE_TAGGED); - ahd_print_devinfo(ahd, &devinfo); - printf("Tagged Queuing enabled. Depth %d\n", tags); - } else { - ahd_set_tags(ahd, &devinfo, AHD_QUEUE_NONE); - } -} - -static int -ahd_linux_run_command(struct ahd_softc *ahd, struct ahd_linux_device *dev, - struct scsi_cmnd *cmd) -{ - struct scb *scb; - struct hardware_scb *hscb; - struct ahd_initiator_tinfo *tinfo; - struct ahd_tmode_tstate *tstate; - u_int col_idx; - uint16_t mask; - - /* - * Get an scb to use. - */ - tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, - cmd->device->id, &tstate); - if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) == 0 - || (tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) { - col_idx = AHD_NEVER_COL_IDX; - } else { - col_idx = AHD_BUILD_COL_IDX(cmd->device->id, - cmd->device->lun); - } - if ((scb = ahd_get_scb(ahd, col_idx)) == NULL) { - ahd->flags |= AHD_RESOURCE_SHORTAGE; - return SCSI_MLQUEUE_HOST_BUSY; - } - - scb->io_ctx = cmd; - scb->platform_data->dev = dev; - hscb = scb->hscb; - cmd->host_scribble = (char *)scb; - - /* - * Fill out basics of the HSCB. - */ - hscb->control = 0; - hscb->scsiid = BUILD_SCSIID(ahd, cmd); - hscb->lun = cmd->device->lun; - scb->hscb->task_management = 0; - mask = SCB_GET_TARGET_MASK(ahd, scb); - - if ((ahd->user_discenable & mask) != 0) - hscb->control |= DISCENB; - - if (AHD_DV_CMD(cmd) != 0) - scb->flags |= SCB_SILENT; - - if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) - scb->flags |= SCB_PACKETIZED; - - if ((tstate->auto_negotiate & mask) != 0) { - scb->flags |= SCB_AUTO_NEGOTIATE; - scb->hscb->control |= MK_MESSAGE; - } - - if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) != 0) { - int msg_bytes; - uint8_t tag_msgs[2]; - - msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs); - if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) { - hscb->control |= tag_msgs[0]; - if (tag_msgs[0] == MSG_ORDERED_TASK) - dev->commands_since_idle_or_otag = 0; - } else - if (dev->commands_since_idle_or_otag == AHD_OTAG_THRESH - && (dev->flags & AHD_DEV_Q_TAGGED) != 0) { - hscb->control |= MSG_ORDERED_TASK; - dev->commands_since_idle_or_otag = 0; - } else { - hscb->control |= MSG_SIMPLE_TASK; - } - } - - hscb->cdb_len = cmd->cmd_len; - memcpy(hscb->shared_data.idata.cdb, cmd->cmnd, hscb->cdb_len); - - scb->sg_count = 0; - ahd_set_residual(scb, 0); - ahd_set_sense_residual(scb, 0); - if (cmd->use_sg != 0) { - void *sg; - struct scatterlist *cur_seg; - u_int nseg; - int dir; - - cur_seg = (struct scatterlist *)cmd->request_buffer; - dir = cmd->sc_data_direction; - nseg = pci_map_sg(ahd->dev_softc, cur_seg, - cmd->use_sg, dir); - scb->platform_data->xfer_len = 0; - for (sg = scb->sg_list; nseg > 0; nseg--, cur_seg++) { - dma_addr_t addr; - bus_size_t len; - - addr = sg_dma_address(cur_seg); - len = sg_dma_len(cur_seg); - scb->platform_data->xfer_len += len; - sg = ahd_sg_setup(ahd, scb, sg, addr, len, - /*last*/nseg == 1); - } - } else if (cmd->request_bufflen != 0) { - void *sg; - dma_addr_t addr; - int dir; - - sg = scb->sg_list; - dir = cmd->sc_data_direction; - addr = pci_map_single(ahd->dev_softc, - cmd->request_buffer, - cmd->request_bufflen, dir); - scb->platform_data->xfer_len = cmd->request_bufflen; - scb->platform_data->buf_busaddr = addr; - sg = ahd_sg_setup(ahd, scb, sg, addr, - cmd->request_bufflen, /*last*/TRUE); - } - - LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links); - dev->openings--; - dev->active++; - dev->commands_issued++; - - /* Update the error counting bucket and dump if needed */ - if (dev->target->cmds_since_error) { - dev->target->cmds_since_error++; - if (dev->target->cmds_since_error > - AHD_LINUX_ERR_THRESH) - dev->target->cmds_since_error = 0; - } - - if ((dev->flags & AHD_DEV_PERIODIC_OTAG) != 0) - dev->commands_since_idle_or_otag++; - scb->flags |= SCB_ACTIVE; - ahd_queue_scb(ahd, scb); - - return 0; -} - -/* - * SCSI controller interrupt handler. - */ -irqreturn_t -ahd_linux_isr(int irq, void *dev_id, struct pt_regs * regs) -{ - struct ahd_softc *ahd; - u_long flags; - int ours; - - ahd = (struct ahd_softc *) dev_id; - ahd_lock(ahd, &flags); - ours = ahd_intr(ahd); - ahd_linux_run_complete_queue(ahd); - ahd_unlock(ahd, &flags); - return IRQ_RETVAL(ours); -} - -void -ahd_platform_flushwork(struct ahd_softc *ahd) -{ - - while (ahd_linux_run_complete_queue(ahd) != NULL) - ; -} - -static struct ahd_linux_target* -ahd_linux_alloc_target(struct ahd_softc *ahd, u_int channel, u_int target) -{ - struct ahd_linux_target *targ; - - targ = malloc(sizeof(*targ), M_DEVBUF, M_NOWAIT); - if (targ == NULL) - return (NULL); - memset(targ, 0, sizeof(*targ)); - targ->channel = channel; - targ->target = target; - targ->ahd = ahd; - targ->flags = AHD_DV_REQUIRED; - ahd->platform_data->targets[target] = targ; - return (targ); -} - -static void -ahd_linux_free_target(struct ahd_softc *ahd, struct ahd_linux_target *targ) -{ - struct ahd_devinfo devinfo; - struct ahd_initiator_tinfo *tinfo; - struct ahd_tmode_tstate *tstate; - u_int our_id; - u_int target_offset; - char channel; - - /* - * Force a negotiation to async/narrow on any - * future command to this device unless a bus - * reset occurs between now and that command. - */ - channel = 'A' + targ->channel; - our_id = ahd->our_id; - target_offset = targ->target; - tinfo = ahd_fetch_transinfo(ahd, channel, our_id, - targ->target, &tstate); - ahd_compile_devinfo(&devinfo, our_id, targ->target, CAM_LUN_WILDCARD, - channel, ROLE_INITIATOR); - ahd_set_syncrate(ahd, &devinfo, 0, 0, 0, - AHD_TRANS_GOAL, /*paused*/FALSE); - ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, - AHD_TRANS_GOAL, /*paused*/FALSE); - ahd_update_neg_request(ahd, &devinfo, tstate, tinfo, AHD_NEG_ALWAYS); - ahd->platform_data->targets[target_offset] = NULL; - if (targ->inq_data != NULL) - free(targ->inq_data, M_DEVBUF); - if (targ->dv_buffer != NULL) - free(targ->dv_buffer, M_DEVBUF); - if (targ->dv_buffer1 != NULL) - free(targ->dv_buffer1, M_DEVBUF); - free(targ, M_DEVBUF); + dev->openings = 1; + ahd_platform_set_tags(ahd, &devinfo, + (dev->flags & AHD_DEV_Q_BASIC) + ? AHD_QUEUE_BASIC : AHD_QUEUE_TAGGED); + ahd_set_scsi_status(scb, SCSI_STATUS_BUSY); + } } -static struct ahd_linux_device* -ahd_linux_alloc_device(struct ahd_softc *ahd, - struct ahd_linux_target *targ, u_int lun) +static void +ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, struct scsi_cmnd *cmd) { - struct ahd_linux_device *dev; - - dev = malloc(sizeof(*dev), M_DEVBUG, M_NOWAIT); - if (dev == NULL) - return (NULL); - memset(dev, 0, sizeof(*dev)); - init_timer(&dev->timer); - dev->flags = AHD_DEV_UNCONFIGURED; - dev->lun = lun; - dev->target = targ; - /* - * We start out life using untagged - * transactions of which we allow one. + * Map CAM error codes into Linux Error codes. We + * avoid the conversion so that the DV code has the + * full error information available when making + * state change decisions. */ - dev->openings = 1; + { + uint32_t status; + u_int new_status; - /* - * Set maxtags to 0. This will be changed if we - * later determine that we are dealing with - * a tagged queuing capable device. - */ - dev->maxtags = 0; - - targ->refcount++; - targ->devices[lun] = dev; - return (dev); + status = ahd_cmd_get_transaction_status(cmd); + switch (status) { + case CAM_REQ_INPROG: + case CAM_REQ_CMP: + case CAM_SCSI_STATUS_ERROR: + new_status = DID_OK; + break; + case CAM_REQ_ABORTED: + new_status = DID_ABORT; + break; + case CAM_BUSY: + new_status = DID_BUS_BUSY; + break; + case CAM_REQ_INVALID: + case CAM_PATH_INVALID: + new_status = DID_BAD_TARGET; + break; + case CAM_SEL_TIMEOUT: + new_status = DID_NO_CONNECT; + break; + case CAM_SCSI_BUS_RESET: + case CAM_BDR_SENT: + new_status = DID_RESET; + break; + case CAM_UNCOR_PARITY: + new_status = DID_PARITY; + break; + case CAM_CMD_TIMEOUT: + new_status = DID_TIME_OUT; + break; + case CAM_UA_ABORT: + case CAM_REQ_CMP_ERR: + case CAM_AUTOSENSE_FAIL: + case CAM_NO_HBA: + case CAM_DATA_RUN_ERR: + case CAM_UNEXP_BUSFREE: + case CAM_SEQUENCE_FAIL: + case CAM_CCB_LEN_ERR: + case CAM_PROVIDE_FAIL: + case CAM_REQ_TERMIO: + case CAM_UNREC_HBA_ERROR: + case CAM_REQ_TOO_BIG: + new_status = DID_ERROR; + break; + case CAM_REQUEUE_REQ: + new_status = DID_REQUEUE; + break; + default: + /* We should never get here */ + new_status = DID_ERROR; + break; + } + + ahd_cmd_set_transaction_status(cmd, new_status); + } + + cmd->scsi_done(cmd); } static void -ahd_linux_free_device(struct ahd_softc *ahd, struct ahd_linux_device *dev) +ahd_linux_sem_timeout(u_long arg) { - struct ahd_linux_target *targ; + struct ahd_softc *ahd; + u_long s; - del_timer(&dev->timer); - targ = dev->target; - targ->devices[dev->lun] = NULL; - free(dev, M_DEVBUF); - targ->refcount--; - if (targ->refcount == 0 - && (targ->flags & AHD_DV_REQUIRED) == 0) - ahd_linux_free_target(ahd, targ); + ahd = (struct ahd_softc *)arg; + + ahd_lock(ahd, &s); + if ((ahd->platform_data->flags & AHD_SCB_UP_EH_SEM) != 0) { + ahd->platform_data->flags &= ~AHD_SCB_UP_EH_SEM; + up(&ahd->platform_data->eh_sem); + } + ahd_unlock(ahd, &s); } void -ahd_send_async(struct ahd_softc *ahd, char channel, - u_int target, u_int lun, ac_code code, void *arg) +ahd_freeze_simq(struct ahd_softc *ahd) { - switch (code) { - case AC_TRANSFER_NEG: - { - char buf[80]; - struct ahd_linux_target *targ; - struct info_str info; - struct ahd_initiator_tinfo *tinfo; - struct ahd_tmode_tstate *tstate; - - info.buffer = buf; - info.length = sizeof(buf); - info.offset = 0; - info.pos = 0; - tinfo = ahd_fetch_transinfo(ahd, channel, ahd->our_id, - target, &tstate); - - /* - * Don't bother reporting results while - * negotiations are still pending. - */ - if (tinfo->curr.period != tinfo->goal.period - || tinfo->curr.width != tinfo->goal.width - || tinfo->curr.offset != tinfo->goal.offset - || tinfo->curr.ppr_options != tinfo->goal.ppr_options) - if (bootverbose == 0) - break; - - /* - * Don't bother reporting results that - * are identical to those last reported. - */ - targ = ahd->platform_data->targets[target]; - if (targ == NULL) - break; - if (tinfo->curr.period == targ->last_tinfo.period - && tinfo->curr.width == targ->last_tinfo.width - && tinfo->curr.offset == targ->last_tinfo.offset - && tinfo->curr.ppr_options == targ->last_tinfo.ppr_options) - if (bootverbose == 0) - break; - - targ->last_tinfo.period = tinfo->curr.period; - targ->last_tinfo.width = tinfo->curr.width; - targ->last_tinfo.offset = tinfo->curr.offset; - targ->last_tinfo.ppr_options = tinfo->curr.ppr_options; - - printf("(%s:%c:", ahd_name(ahd), channel); - if (target == CAM_TARGET_WILDCARD) - printf("*): "); - else - printf("%d): ", target); - ahd_format_transinfo(&info, &tinfo->curr); - if (info.pos < info.length) - *info.buffer = '\0'; - else - buf[info.length - 1] = '\0'; - printf("%s", buf); - break; - } - case AC_SENT_BDR: - { - WARN_ON(lun != CAM_LUN_WILDCARD); - scsi_report_device_reset(ahd->platform_data->host, - channel - 'A', target); - break; + ahd->platform_data->qfrozen++; + if (ahd->platform_data->qfrozen == 1) { + scsi_block_requests(ahd->platform_data->host); + ahd_platform_abort_scbs(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS, + CAM_LUN_WILDCARD, SCB_LIST_NULL, + ROLE_INITIATOR, CAM_REQUEUE_REQ); } - case AC_BUS_RESET: - if (ahd->platform_data->host != NULL) { - scsi_report_bus_reset(ahd->platform_data->host, - channel - 'A'); - } - break; - default: - panic("ahd_send_async: Unexpected async event"); - } } -/* - * Calls the higher level scsi done function and frees the scb. - */ void -ahd_done(struct ahd_softc *ahd, struct scb *scb) +ahd_release_simq(struct ahd_softc *ahd) { - Scsi_Cmnd *cmd; - struct ahd_linux_device *dev; + u_long s; + int unblock_reqs; - if ((scb->flags & SCB_ACTIVE) == 0) { - printf("SCB %d done'd twice\n", SCB_GET_TAG(scb)); - ahd_dump_card_state(ahd); - panic("Stopping for safety"); - } - LIST_REMOVE(scb, pending_links); - cmd = scb->io_ctx; - dev = scb->platform_data->dev; - dev->active--; - dev->openings++; - if ((cmd->result & (CAM_DEV_QFRZN << 16)) != 0) { - cmd->result &= ~(CAM_DEV_QFRZN << 16); - dev->qfrozen--; + unblock_reqs = 0; + ahd_lock(ahd, &s); + if (ahd->platform_data->qfrozen > 0) + ahd->platform_data->qfrozen--; + if (ahd->platform_data->qfrozen == 0) { + unblock_reqs = 1; } - ahd_linux_unmap_scb(ahd, scb); - + ahd_unlock(ahd, &s); /* - * Guard against stale sense data. - * The Linux mid-layer assumes that sense - * was retrieved anytime the first byte of - * the sense buffer looks "sane". + * There is still a race here. The mid-layer + * should keep its own freeze count and use + * a bottom half handler to run the queues + * so we can unblock with our own lock held. */ - cmd->sense_buffer[0] = 0; - if (ahd_get_transaction_status(scb) == CAM_REQ_INPROG) { - uint32_t amount_xferred; + if (unblock_reqs) + scsi_unblock_requests(ahd->platform_data->host); +} - amount_xferred = - ahd_get_transfer_length(scb) - ahd_get_residual(scb); - if ((scb->flags & SCB_TRANSMISSION_ERROR) != 0) { -#ifdef AHD_DEBUG - if ((ahd_debug & AHD_SHOW_MISC) != 0) { - ahd_print_path(ahd, scb); - printf("Set CAM_UNCOR_PARITY\n"); - } -#endif - ahd_set_transaction_status(scb, CAM_UNCOR_PARITY); -#ifdef AHD_REPORT_UNDERFLOWS - /* - * This code is disabled by default as some - * clients of the SCSI system do not properly - * initialize the underflow parameter. This - * results in spurious termination of commands - * that complete as expected (e.g. underflow is - * allowed as command can return variable amounts - * of data. - */ - } else if (amount_xferred < scb->io_ctx->underflow) { - u_int i; +static int +ahd_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) +{ + struct ahd_softc *ahd; + struct ahd_linux_device *dev; + struct scb *pending_scb; + u_int saved_scbptr; + u_int active_scbptr; + u_int last_phase; + u_int saved_scsiid; + u_int cdb_byte; + int retval; + int was_paused; + int paused; + int wait; + int disconnected; + ahd_mode_state saved_modes; + + pending_scb = NULL; + paused = FALSE; + wait = FALSE; + ahd = *(struct ahd_softc **)cmd->device->host->hostdata; + + printf("%s:%d:%d:%d: Attempting to queue a%s message:", + ahd_name(ahd), cmd->device->channel, + cmd->device->id, cmd->device->lun, + flag == SCB_ABORT ? "n ABORT" : " TARGET RESET"); + + printf("CDB:"); + for (cdb_byte = 0; cdb_byte < cmd->cmd_len; cdb_byte++) + printf(" 0x%x", cmd->cmnd[cdb_byte]); + printf("\n"); + + spin_lock_irq(&ahd->platform_data->spin_lock); - ahd_print_path(ahd, scb); - printf("CDB:"); - for (i = 0; i < scb->io_ctx->cmd_len; i++) - printf(" 0x%x", scb->io_ctx->cmnd[i]); - printf("\n"); - ahd_print_path(ahd, scb); - printf("Saw underflow (%ld of %ld bytes). " - "Treated as error\n", - ahd_get_residual(scb), - ahd_get_transfer_length(scb)); - ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR); -#endif - } else { - ahd_set_transaction_status(scb, CAM_REQ_CMP); - } - } else if (ahd_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) { - ahd_linux_handle_scsi_status(ahd, dev, scb); - } else if (ahd_get_transaction_status(scb) == CAM_SEL_TIMEOUT) { - dev->flags |= AHD_DEV_UNCONFIGURED; - if (AHD_DV_CMD(cmd) == FALSE) - dev->target->flags &= ~AHD_DV_REQUIRED; - } /* - * Start DV for devices that require it assuming the first command - * sent does not result in a selection timeout. + * First determine if we currently own this command. + * Start by searching the device queue. If not found + * there, check the pending_scb list. If not found + * at all, and the system wanted us to just abort the + * command, return success. */ - if (ahd_get_transaction_status(scb) != CAM_SEL_TIMEOUT - && (dev->target->flags & AHD_DV_REQUIRED) != 0) - ahd_linux_start_dv(ahd); + dev = scsi_transport_device_data(cmd->device); + + if (dev == NULL) { + /* + * No target device for this command exists, + * so we must not still own the command. + */ + printf("%s:%d:%d:%d: Is not an active device\n", + ahd_name(ahd), cmd->device->channel, cmd->device->id, + cmd->device->lun); + retval = SUCCESS; + goto no_cmd; + } - if (dev->openings == 1 - && ahd_get_transaction_status(scb) == CAM_REQ_CMP - && ahd_get_scsi_status(scb) != SCSI_STATUS_QUEUE_FULL) - dev->tag_success_count++; /* - * Some devices deal with temporary internal resource - * shortages by returning queue full. When the queue - * full occurrs, we throttle back. Slowly try to get - * back to our previous queue depth. + * See if we can find a matching cmd in the pending list. */ - if ((dev->openings + dev->active) < dev->maxtags - && dev->tag_success_count > AHD_TAG_SUCCESS_INTERVAL) { - dev->tag_success_count = 0; - dev->openings++; + LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) { + if (pending_scb->io_ctx == cmd) + break; } - if (dev->active == 0) - dev->commands_since_idle_or_otag = 0; - - if ((dev->flags & AHD_DEV_UNCONFIGURED) != 0 - && dev->active == 0 - && (dev->flags & AHD_DEV_TIMER_ACTIVE) == 0) - ahd_linux_free_device(ahd, dev); + if (pending_scb == NULL && flag == SCB_DEVICE_RESET) { - if ((scb->flags & SCB_RECOVERY_SCB) != 0) { - printf("Recovery SCB completes\n"); - if (ahd_get_transaction_status(scb) == CAM_BDR_SENT - || ahd_get_transaction_status(scb) == CAM_REQ_ABORTED) - ahd_set_transaction_status(scb, CAM_CMD_TIMEOUT); - if ((scb->platform_data->flags & AHD_SCB_UP_EH_SEM) != 0) { - scb->platform_data->flags &= ~AHD_SCB_UP_EH_SEM; - up(&ahd->platform_data->eh_sem); + /* Any SCB for this device will do for a target reset */ + LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) { + if (ahd_match_scb(ahd, pending_scb, cmd->device->id, + cmd->device->channel + 'A', + CAM_LUN_WILDCARD, + SCB_LIST_NULL, ROLE_INITIATOR) == 0) + break; } } - ahd_free_scb(ahd, scb); - ahd_linux_queue_cmd_complete(ahd, cmd); - - if ((ahd->platform_data->flags & AHD_DV_WAIT_SIMQ_EMPTY) != 0 - && LIST_FIRST(&ahd->pending_scbs) == NULL) { - ahd->platform_data->flags &= ~AHD_DV_WAIT_SIMQ_EMPTY; - up(&ahd->platform_data->dv_sem); + if (pending_scb == NULL) { + printf("%s:%d:%d:%d: Command not found\n", + ahd_name(ahd), cmd->device->channel, cmd->device->id, + cmd->device->lun); + goto no_cmd; } -} -static void -ahd_linux_handle_scsi_status(struct ahd_softc *ahd, - struct ahd_linux_device *dev, struct scb *scb) -{ - struct ahd_devinfo devinfo; + if ((pending_scb->flags & SCB_RECOVERY_SCB) != 0) { + /* + * We can't queue two recovery actions using the same SCB + */ + retval = FAILED; + goto done; + } - ahd_compile_devinfo(&devinfo, - ahd->our_id, - dev->target->target, dev->lun, - dev->target->channel == 0 ? 'A' : 'B', - ROLE_INITIATOR); - /* - * We don't currently trust the mid-layer to - * properly deal with queue full or busy. So, - * when one occurs, we tell the mid-layer to - * unconditionally requeue the command to us - * so that we can retry it ourselves. We also - * implement our own throttling mechanism so - * we don't clobber the device with too many - * commands. + * Ensure that the card doesn't do anything + * behind our back. Also make sure that we + * didn't "just" miss an interrupt that would + * affect this cmd. */ - switch (ahd_get_scsi_status(scb)) { - default: - break; - case SCSI_STATUS_CHECK_COND: - case SCSI_STATUS_CMD_TERMINATED: - { - Scsi_Cmnd *cmd; + was_paused = ahd_is_paused(ahd); + ahd_pause_and_flushwork(ahd); + paused = TRUE; - /* - * Copy sense information to the OS's cmd - * structure if it is available. - */ - cmd = scb->io_ctx; - if ((scb->flags & (SCB_SENSE|SCB_PKT_SENSE)) != 0) { - struct scsi_status_iu_header *siu; - u_int sense_size; - u_int sense_offset; + if ((pending_scb->flags & SCB_ACTIVE) == 0) { + printf("%s:%d:%d:%d: Command already completed\n", + ahd_name(ahd), cmd->device->channel, cmd->device->id, + cmd->device->lun); + goto no_cmd; + } - if (scb->flags & SCB_SENSE) { - sense_size = MIN(sizeof(struct scsi_sense_data) - - ahd_get_sense_residual(scb), - sizeof(cmd->sense_buffer)); - sense_offset = 0; - } else { - /* - * Copy only the sense data into the provided - * buffer. - */ - siu = (struct scsi_status_iu_header *) - scb->sense_data; - sense_size = MIN(scsi_4btoul(siu->sense_length), - sizeof(cmd->sense_buffer)); - sense_offset = SIU_SENSE_OFFSET(siu); - } + printf("%s: At time of recovery, card was %spaused\n", + ahd_name(ahd), was_paused ? "" : "not "); + ahd_dump_card_state(ahd); - memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer)); - memcpy(cmd->sense_buffer, - ahd_get_sense_buf(ahd, scb) - + sense_offset, sense_size); - cmd->result |= (DRIVER_SENSE << 24); + disconnected = TRUE; + if (flag == SCB_ABORT) { + if (ahd_search_qinfifo(ahd, cmd->device->id, + cmd->device->channel + 'A', + cmd->device->lun, + pending_scb->hscb->tag, + ROLE_INITIATOR, CAM_REQ_ABORTED, + SEARCH_COMPLETE) > 0) { + printf("%s:%d:%d:%d: Cmd aborted from QINFIFO\n", + ahd_name(ahd), cmd->device->channel, + cmd->device->id, cmd->device->lun); + retval = SUCCESS; + goto done; + } + } else if (ahd_search_qinfifo(ahd, cmd->device->id, + cmd->device->channel + 'A', + cmd->device->lun, pending_scb->hscb->tag, + ROLE_INITIATOR, /*status*/0, + SEARCH_COUNT) > 0) { + disconnected = FALSE; + } -#ifdef AHD_DEBUG - if (ahd_debug & AHD_SHOW_SENSE) { - int i; + saved_modes = ahd_save_modes(ahd); + ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); + last_phase = ahd_inb(ahd, LASTPHASE); + saved_scbptr = ahd_get_scbptr(ahd); + active_scbptr = saved_scbptr; + if (disconnected && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) == 0) { + struct scb *bus_scb; - printf("Copied %d bytes of sense data at %d:", - sense_size, sense_offset); - for (i = 0; i < sense_size; i++) { - if ((i & 0xF) == 0) - printf("\n"); - printf("0x%x ", cmd->sense_buffer[i]); - } - printf("\n"); - } -#endif - } - break; + bus_scb = ahd_lookup_scb(ahd, active_scbptr); + if (bus_scb == pending_scb) + disconnected = FALSE; + else if (flag != SCB_ABORT + && ahd_inb(ahd, SAVED_SCSIID) == pending_scb->hscb->scsiid + && ahd_inb(ahd, SAVED_LUN) == SCB_GET_LUN(pending_scb)) + disconnected = FALSE; } - case SCSI_STATUS_QUEUE_FULL: - { + + /* + * At this point, pending_scb is the scb associated with the + * passed in command. That command is currently active on the + * bus or is in the disconnected state. + */ + saved_scsiid = ahd_inb(ahd, SAVED_SCSIID); + if (last_phase != P_BUSFREE + && (SCB_GET_TAG(pending_scb) == active_scbptr + || (flag == SCB_DEVICE_RESET + && SCSIID_TARGET(ahd, saved_scsiid) == cmd->device->id))) { + /* - * By the time the core driver has returned this - * command, all other commands that were queued - * to us but not the device have been returned. - * This ensures that dev->active is equal to - * the number of commands actually queued to - * the device. + * We're active on the bus, so assert ATN + * and hope that the target responds. */ - dev->tag_success_count = 0; - if (dev->active != 0) { + pending_scb = ahd_lookup_scb(ahd, active_scbptr); + pending_scb->flags |= SCB_RECOVERY_SCB|flag; + ahd_outb(ahd, MSG_OUT, HOST_MSG); + ahd_outb(ahd, SCSISIGO, last_phase|ATNO); + printf("%s:%d:%d:%d: Device is active, asserting ATN\n", + ahd_name(ahd), cmd->device->channel, + cmd->device->id, cmd->device->lun); + wait = TRUE; + } else if (disconnected) { + + /* + * Actually re-queue this SCB in an attempt + * to select the device before it reconnects. + */ + pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT; + ahd_set_scbptr(ahd, SCB_GET_TAG(pending_scb)); + pending_scb->hscb->cdb_len = 0; + pending_scb->hscb->task_attribute = 0; + pending_scb->hscb->task_management = SIU_TASKMGMT_ABORT_TASK; + + if ((pending_scb->flags & SCB_PACKETIZED) != 0) { /* - * Drop our opening count to the number - * of commands currently outstanding. + * Mark the SCB has having an outstanding + * task management function. Should the command + * complete normally before the task management + * function can be sent, the host will be notified + * to abort our requeued SCB. */ - dev->openings = 0; -#ifdef AHD_DEBUG - if ((ahd_debug & AHD_SHOW_QFULL) != 0) { - ahd_print_path(ahd, scb); - printf("Dropping tag count to %d\n", - dev->active); - } -#endif - if (dev->active == dev->tags_on_last_queuefull) { - - dev->last_queuefull_same_count++; - /* - * If we repeatedly see a queue full - * at the same queue depth, this - * device has a fixed number of tag - * slots. Lock in this tag depth - * so we stop seeing queue fulls from - * this device. - */ - if (dev->last_queuefull_same_count - == AHD_LOCK_TAGS_COUNT) { - dev->maxtags = dev->active; - ahd_print_path(ahd, scb); - printf("Locking max tag count at %d\n", - dev->active); - } - } else { - dev->tags_on_last_queuefull = dev->active; - dev->last_queuefull_same_count = 0; - } - ahd_set_transaction_status(scb, CAM_REQUEUE_REQ); - ahd_set_scsi_status(scb, SCSI_STATUS_OK); - ahd_platform_set_tags(ahd, &devinfo, - (dev->flags & AHD_DEV_Q_BASIC) - ? AHD_QUEUE_BASIC : AHD_QUEUE_TAGGED); - break; + ahd_outb(ahd, SCB_TASK_MANAGEMENT, + pending_scb->hscb->task_management); + } else { + /* + * If non-packetized, set the MK_MESSAGE control + * bit indicating that we desire to send a message. + * We also set the disconnected flag since there is + * no guarantee that our SCB control byte matches + * the version on the card. We don't want the + * sequencer to abort the command thinking an + * unsolicited reselection occurred. + */ + pending_scb->hscb->control |= MK_MESSAGE|DISCONNECTED; + + /* + * The sequencer will never re-reference the + * in-core SCB. To make sure we are notified + * during reslection, set the MK_MESSAGE flag in + * the card's copy of the SCB. + */ + ahd_outb(ahd, SCB_CONTROL, + ahd_inb(ahd, SCB_CONTROL)|MK_MESSAGE); } + /* - * Drop down to a single opening, and treat this - * as if the target returned BUSY SCSI status. - */ - dev->openings = 1; - ahd_platform_set_tags(ahd, &devinfo, - (dev->flags & AHD_DEV_Q_BASIC) - ? AHD_QUEUE_BASIC : AHD_QUEUE_TAGGED); - ahd_set_scsi_status(scb, SCSI_STATUS_BUSY); - /* FALLTHROUGH */ - } - case SCSI_STATUS_BUSY: - /* - * Set a short timer to defer sending commands for - * a bit since Linux will not delay in this case. + * Clear out any entries in the QINFIFO first + * so we are the next SCB for this target + * to run. */ - if ((dev->flags & AHD_DEV_TIMER_ACTIVE) != 0) { - printf("%s:%c:%d: Device Timer still active during " - "busy processing\n", ahd_name(ahd), - dev->target->channel, dev->target->target); - break; - } - dev->flags |= AHD_DEV_TIMER_ACTIVE; - dev->qfrozen++; - init_timer(&dev->timer); - dev->timer.data = (u_long)dev; - dev->timer.expires = jiffies + (HZ/2); - dev->timer.function = ahd_linux_dev_timed_unfreeze; - add_timer(&dev->timer); - break; + ahd_search_qinfifo(ahd, cmd->device->id, + cmd->device->channel + 'A', cmd->device->lun, + SCB_LIST_NULL, ROLE_INITIATOR, + CAM_REQUEUE_REQ, SEARCH_COMPLETE); + ahd_qinfifo_requeue_tail(ahd, pending_scb); + ahd_set_scbptr(ahd, saved_scbptr); + ahd_print_path(ahd, pending_scb); + printf("Device is disconnected, re-queuing SCB\n"); + wait = TRUE; + } else { + printf("%s:%d:%d:%d: Unable to deliver message\n", + ahd_name(ahd), cmd->device->channel, + cmd->device->id, cmd->device->lun); + retval = FAILED; + goto done; } -} - -static void -ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, Scsi_Cmnd *cmd) -{ - /* - * Typically, the complete queue has very few entries - * queued to it before the queue is emptied by - * ahd_linux_run_complete_queue, so sorting the entries - * by generation number should be inexpensive. - * We perform the sort so that commands that complete - * with an error are retuned in the order origionally - * queued to the controller so that any subsequent retries - * are performed in order. The underlying ahd routines do - * not guarantee the order that aborted commands will be - * returned to us. - */ - struct ahd_completeq *completeq; - struct ahd_cmd *list_cmd; - struct ahd_cmd *acmd; +no_cmd: /* - * Map CAM error codes into Linux Error codes. We - * avoid the conversion so that the DV code has the - * full error information available when making - * state change decisions. + * Our assumption is that if we don't have the command, no + * recovery action was required, so we return success. Again, + * the semantics of the mid-layer recovery engine are not + * well defined, so this may change in time. */ - if (AHD_DV_CMD(cmd) == FALSE) { - uint32_t status; - u_int new_status; + retval = SUCCESS; +done: + if (paused) + ahd_unpause(ahd); + if (wait) { + struct timer_list timer; + int ret; - status = ahd_cmd_get_transaction_status(cmd); - if (status != CAM_REQ_CMP) { - struct ahd_linux_device *dev; - struct ahd_devinfo devinfo; - cam_status cam_status; - uint32_t action; - u_int scsi_status; - - dev = ahd_linux_get_device(ahd, cmd->device->channel, - cmd->device->id, - cmd->device->lun, - /*alloc*/FALSE); - - if (dev == NULL) - goto no_fallback; - - ahd_compile_devinfo(&devinfo, - ahd->our_id, - dev->target->target, dev->lun, - dev->target->channel == 0 ? 'A':'B', - ROLE_INITIATOR); - - scsi_status = ahd_cmd_get_scsi_status(cmd); - cam_status = ahd_cmd_get_transaction_status(cmd); - action = aic_error_action(cmd, dev->target->inq_data, - cam_status, scsi_status); - if ((action & SSQ_FALLBACK) != 0) { - - /* Update stats */ - dev->target->errors_detected++; - if (dev->target->cmds_since_error == 0) - dev->target->cmds_since_error++; - else { - dev->target->cmds_since_error = 0; - ahd_linux_fallback(ahd, &devinfo); - } - } - } -no_fallback: - switch (status) { - case CAM_REQ_INPROG: - case CAM_REQ_CMP: - case CAM_SCSI_STATUS_ERROR: - new_status = DID_OK; - break; - case CAM_REQ_ABORTED: - new_status = DID_ABORT; - break; - case CAM_BUSY: - new_status = DID_BUS_BUSY; - break; - case CAM_REQ_INVALID: - case CAM_PATH_INVALID: - new_status = DID_BAD_TARGET; - break; - case CAM_SEL_TIMEOUT: - new_status = DID_NO_CONNECT; - break; - case CAM_SCSI_BUS_RESET: - case CAM_BDR_SENT: - new_status = DID_RESET; - break; - case CAM_UNCOR_PARITY: - new_status = DID_PARITY; - break; - case CAM_CMD_TIMEOUT: - new_status = DID_TIME_OUT; - break; - case CAM_UA_ABORT: - case CAM_REQ_CMP_ERR: - case CAM_AUTOSENSE_FAIL: - case CAM_NO_HBA: - case CAM_DATA_RUN_ERR: - case CAM_UNEXP_BUSFREE: - case CAM_SEQUENCE_FAIL: - case CAM_CCB_LEN_ERR: - case CAM_PROVIDE_FAIL: - case CAM_REQ_TERMIO: - case CAM_UNREC_HBA_ERROR: - case CAM_REQ_TOO_BIG: - new_status = DID_ERROR; - break; - case CAM_REQUEUE_REQ: - /* - * If we want the request requeued, make sure there - * are sufficent retries. In the old scsi error code, - * we used to be able to specify a result code that - * bypassed the retry count. Now we must use this - * hack. We also "fake" a check condition with - * a sense code of ABORTED COMMAND. This seems to - * evoke a retry even if this command is being sent - * via the eh thread. Ick! Ick! Ick! - */ - if (cmd->retries > 0) - cmd->retries--; - new_status = DID_OK; - ahd_cmd_set_scsi_status(cmd, SCSI_STATUS_CHECK_COND); - cmd->result |= (DRIVER_SENSE << 24); - memset(cmd->sense_buffer, 0, - sizeof(cmd->sense_buffer)); - cmd->sense_buffer[0] = SSD_ERRCODE_VALID - | SSD_CURRENT_ERROR; - cmd->sense_buffer[2] = SSD_KEY_ABORTED_COMMAND; - break; - default: - /* We should never get here */ - new_status = DID_ERROR; - break; + ahd->platform_data->flags |= AHD_SCB_UP_EH_SEM; + spin_unlock_irq(&ahd->platform_data->spin_lock); + init_timer(&timer); + timer.data = (u_long)ahd; + timer.expires = jiffies + (5 * HZ); + timer.function = ahd_linux_sem_timeout; + add_timer(&timer); + printf("Recovery code sleeping\n"); + down(&ahd->platform_data->eh_sem); + printf("Recovery code awake\n"); + ret = del_timer_sync(&timer); + if (ret == 0) { + printf("Timer Expired\n"); + retval = FAILED; } - - ahd_cmd_set_transaction_status(cmd, new_status); + spin_lock_irq(&ahd->platform_data->spin_lock); } - - completeq = &ahd->platform_data->completeq; - list_cmd = TAILQ_FIRST(completeq); - acmd = (struct ahd_cmd *)cmd; - while (list_cmd != NULL - && acmd_scsi_cmd(list_cmd).serial_number - < acmd_scsi_cmd(acmd).serial_number) - list_cmd = TAILQ_NEXT(list_cmd, acmd_links.tqe); - if (list_cmd != NULL) - TAILQ_INSERT_BEFORE(list_cmd, acmd, acmd_links.tqe); - else - TAILQ_INSERT_TAIL(completeq, acmd, acmd_links.tqe); + spin_unlock_irq(&ahd->platform_data->spin_lock); + return (retval); } -static void -ahd_linux_filter_inquiry(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) +static void ahd_linux_exit(void); + +static void ahd_linux_set_width(struct scsi_target *starget, int width) { - struct scsi_inquiry_data *sid; - struct ahd_initiator_tinfo *tinfo; - struct ahd_transinfo *user; - struct ahd_transinfo *goal; - struct ahd_transinfo *curr; - struct ahd_tmode_tstate *tstate; - struct ahd_linux_device *dev; - u_int width; - u_int period; - u_int offset; - u_int ppr_options; - u_int trans_version; - u_int prot_version; + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct ahd_softc *ahd = *((struct ahd_softc **)shost->hostdata); + struct ahd_devinfo devinfo; + unsigned long flags; - /* - * Determine if this lun actually exists. If so, - * hold on to its corresponding device structure. - * If not, make sure we release the device and - * don't bother processing the rest of this inquiry - * command. - */ - dev = ahd_linux_get_device(ahd, devinfo->channel - 'A', - devinfo->target, devinfo->lun, - /*alloc*/TRUE); + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, + starget->channel + 'A', ROLE_INITIATOR); + ahd_lock(ahd, &flags); + ahd_set_width(ahd, &devinfo, width, AHD_TRANS_GOAL, FALSE); + ahd_unlock(ahd, &flags); +} + +static void ahd_linux_set_period(struct scsi_target *starget, int period) +{ + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct ahd_softc *ahd = *((struct ahd_softc **)shost->hostdata); + struct ahd_tmode_tstate *tstate; + struct ahd_initiator_tinfo *tinfo + = ahd_fetch_transinfo(ahd, + starget->channel + 'A', + shost->this_id, starget->id, &tstate); + struct ahd_devinfo devinfo; + unsigned int ppr_options = tinfo->goal.ppr_options; + unsigned long flags; + unsigned long offset = tinfo->goal.offset; - sid = (struct scsi_inquiry_data *)dev->target->inq_data; - if (SID_QUAL(sid) == SID_QUAL_LU_CONNECTED) { + if (offset == 0) + offset = MAX_OFFSET; - dev->flags &= ~AHD_DEV_UNCONFIGURED; - } else { - dev->flags |= AHD_DEV_UNCONFIGURED; - return; + if (period < 8) + period = 8; + if (period < 10) { + ppr_options |= MSG_EXT_PPR_DT_REQ; + if (period == 8) + ppr_options |= MSG_EXT_PPR_IU_REQ; } - /* - * Update our notion of this device's transfer - * negotiation capabilities. - */ - tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, - devinfo->our_scsiid, - devinfo->target, &tstate); - user = &tinfo->user; - goal = &tinfo->goal; - curr = &tinfo->curr; - width = user->width; - period = user->period; - offset = user->offset; - ppr_options = user->ppr_options; - trans_version = user->transport_version; - prot_version = MIN(user->protocol_version, SID_ANSI_REV(sid)); + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, + starget->channel + 'A', ROLE_INITIATOR); - /* - * Only attempt SPI3/4 once we've verified that - * the device claims to support SPI3/4 features. - */ - if (prot_version < SCSI_REV_2) - trans_version = SID_ANSI_REV(sid); - else - trans_version = SCSI_REV_2; - - if ((sid->flags & SID_WBus16) == 0) - width = MSG_EXT_WDTR_BUS_8_BIT; - if ((sid->flags & SID_Sync) == 0) { - period = 0; - offset = 0; - ppr_options = 0; + /* all PPR requests apart from QAS require wide transfers */ + if (ppr_options & ~MSG_EXT_PPR_QAS_REQ) { + if (spi_width(starget) == 0) + ppr_options &= MSG_EXT_PPR_QAS_REQ; } - if ((sid->spi3data & SID_SPI_QAS) == 0) - ppr_options &= ~MSG_EXT_PPR_QAS_REQ; - if ((sid->spi3data & SID_SPI_CLOCK_DT) == 0) - ppr_options &= MSG_EXT_PPR_QAS_REQ; - if ((sid->spi3data & SID_SPI_IUS) == 0) - ppr_options &= (MSG_EXT_PPR_DT_REQ - | MSG_EXT_PPR_QAS_REQ); - - if (prot_version > SCSI_REV_2 - && ppr_options != 0) - trans_version = user->transport_version; - - ahd_validate_width(ahd, /*tinfo limit*/NULL, &width, ROLE_UNKNOWN); + ahd_find_syncrate(ahd, &period, &ppr_options, AHD_SYNCRATE_MAX); - ahd_validate_offset(ahd, /*tinfo limit*/NULL, period, - &offset, width, ROLE_UNKNOWN); - if (offset == 0 || period == 0) { - period = 0; - offset = 0; - ppr_options = 0; - } - /* Apply our filtered user settings. */ - curr->transport_version = trans_version; - curr->protocol_version = prot_version; - ahd_set_width(ahd, devinfo, width, AHD_TRANS_GOAL, /*paused*/FALSE); - ahd_set_syncrate(ahd, devinfo, period, offset, ppr_options, - AHD_TRANS_GOAL, /*paused*/FALSE); + ahd_lock(ahd, &flags); + ahd_set_syncrate(ahd, &devinfo, period, offset, + ppr_options, AHD_TRANS_GOAL, FALSE); + ahd_unlock(ahd, &flags); } -void -ahd_freeze_simq(struct ahd_softc *ahd) +static void ahd_linux_set_offset(struct scsi_target *starget, int offset) { - ahd->platform_data->qfrozen++; - if (ahd->platform_data->qfrozen == 1) { - scsi_block_requests(ahd->platform_data->host); - ahd_platform_abort_scbs(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS, - CAM_LUN_WILDCARD, SCB_LIST_NULL, - ROLE_INITIATOR, CAM_REQUEUE_REQ); + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct ahd_softc *ahd = *((struct ahd_softc **)shost->hostdata); + struct ahd_tmode_tstate *tstate; + struct ahd_initiator_tinfo *tinfo + = ahd_fetch_transinfo(ahd, + starget->channel + 'A', + shost->this_id, starget->id, &tstate); + struct ahd_devinfo devinfo; + unsigned int ppr_options = 0; + unsigned int period = 0; + unsigned long flags; + + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, + starget->channel + 'A', ROLE_INITIATOR); + if (offset != 0) { + period = tinfo->goal.period; + ppr_options = tinfo->goal.ppr_options; + ahd_find_syncrate(ahd, &period, &ppr_options, AHD_SYNCRATE_MAX); } + ahd_lock(ahd, &flags); + ahd_set_syncrate(ahd, &devinfo, period, offset, ppr_options, + AHD_TRANS_GOAL, FALSE); + ahd_unlock(ahd, &flags); } -void -ahd_release_simq(struct ahd_softc *ahd) +static void ahd_linux_set_dt(struct scsi_target *starget, int dt) { - u_long s; - int unblock_reqs; - - unblock_reqs = 0; - ahd_lock(ahd, &s); - if (ahd->platform_data->qfrozen > 0) - ahd->platform_data->qfrozen--; - if (ahd->platform_data->qfrozen == 0) { - unblock_reqs = 1; - } - if (AHD_DV_SIMQ_FROZEN(ahd) - && ((ahd->platform_data->flags & AHD_DV_WAIT_SIMQ_RELEASE) != 0)) { - ahd->platform_data->flags &= ~AHD_DV_WAIT_SIMQ_RELEASE; - up(&ahd->platform_data->dv_sem); - } - ahd_unlock(ahd, &s); - /* - * There is still a race here. The mid-layer - * should keep its own freeze count and use - * a bottom half handler to run the queues - * so we can unblock with our own lock held. - */ - if (unblock_reqs) - scsi_unblock_requests(ahd->platform_data->host); + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct ahd_softc *ahd = *((struct ahd_softc **)shost->hostdata); + struct ahd_tmode_tstate *tstate; + struct ahd_initiator_tinfo *tinfo + = ahd_fetch_transinfo(ahd, + starget->channel + 'A', + shost->this_id, starget->id, &tstate); + struct ahd_devinfo devinfo; + unsigned int ppr_options = tinfo->goal.ppr_options + & ~MSG_EXT_PPR_DT_REQ; + unsigned int period = tinfo->goal.period; + unsigned long flags; + + if (dt) { + ppr_options |= MSG_EXT_PPR_DT_REQ; + if (period > 9) + period = 9; /* at least 12.5ns for DT */ + } else if (period <= 9) + period = 10; /* If resetting DT, period must be >= 25ns */ + + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, + starget->channel + 'A', ROLE_INITIATOR); + ahd_find_syncrate(ahd, &period, &ppr_options, + dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + ahd_lock(ahd, &flags); + ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, + ppr_options, AHD_TRANS_GOAL, FALSE); + ahd_unlock(ahd, &flags); } -static void -ahd_linux_sem_timeout(u_long arg) +static void ahd_linux_set_qas(struct scsi_target *starget, int qas) { - struct scb *scb; - struct ahd_softc *ahd; - u_long s; - - scb = (struct scb *)arg; - ahd = scb->ahd_softc; - ahd_lock(ahd, &s); - if ((scb->platform_data->flags & AHD_SCB_UP_EH_SEM) != 0) { - scb->platform_data->flags &= ~AHD_SCB_UP_EH_SEM; - up(&ahd->platform_data->eh_sem); - } - ahd_unlock(ahd, &s); + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct ahd_softc *ahd = *((struct ahd_softc **)shost->hostdata); + struct ahd_tmode_tstate *tstate; + struct ahd_initiator_tinfo *tinfo + = ahd_fetch_transinfo(ahd, + starget->channel + 'A', + shost->this_id, starget->id, &tstate); + struct ahd_devinfo devinfo; + unsigned int ppr_options = tinfo->goal.ppr_options + & ~MSG_EXT_PPR_QAS_REQ; + unsigned int period = tinfo->goal.period; + unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; + unsigned long flags; + + if (qas) + ppr_options |= MSG_EXT_PPR_QAS_REQ; + + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, + starget->channel + 'A', ROLE_INITIATOR); + ahd_find_syncrate(ahd, &period, &ppr_options, + dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + ahd_lock(ahd, &flags); + ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, + ppr_options, AHD_TRANS_GOAL, FALSE); + ahd_unlock(ahd, &flags); } -static void -ahd_linux_dev_timed_unfreeze(u_long arg) +static void ahd_linux_set_iu(struct scsi_target *starget, int iu) { - struct ahd_linux_device *dev; - struct ahd_softc *ahd; - u_long s; + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct ahd_softc *ahd = *((struct ahd_softc **)shost->hostdata); + struct ahd_tmode_tstate *tstate; + struct ahd_initiator_tinfo *tinfo + = ahd_fetch_transinfo(ahd, + starget->channel + 'A', + shost->this_id, starget->id, &tstate); + struct ahd_devinfo devinfo; + unsigned int ppr_options = tinfo->goal.ppr_options + & ~MSG_EXT_PPR_IU_REQ; + unsigned int period = tinfo->goal.period; + unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; + unsigned long flags; + + if (iu) + ppr_options |= MSG_EXT_PPR_IU_REQ; + + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, + starget->channel + 'A', ROLE_INITIATOR); + ahd_find_syncrate(ahd, &period, &ppr_options, + dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + ahd_lock(ahd, &flags); + ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, + ppr_options, AHD_TRANS_GOAL, FALSE); + ahd_unlock(ahd, &flags); +} - dev = (struct ahd_linux_device *)arg; - ahd = dev->target->ahd; - ahd_lock(ahd, &s); - dev->flags &= ~AHD_DEV_TIMER_ACTIVE; - if (dev->qfrozen > 0) - dev->qfrozen--; - if ((dev->flags & AHD_DEV_UNCONFIGURED) != 0 - && dev->active == 0) - ahd_linux_free_device(ahd, dev); - ahd_unlock(ahd, &s); +static void ahd_linux_set_rd_strm(struct scsi_target *starget, int rdstrm) +{ + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct ahd_softc *ahd = *((struct ahd_softc **)shost->hostdata); + struct ahd_tmode_tstate *tstate; + struct ahd_initiator_tinfo *tinfo + = ahd_fetch_transinfo(ahd, + starget->channel + 'A', + shost->this_id, starget->id, &tstate); + struct ahd_devinfo devinfo; + unsigned int ppr_options = tinfo->goal.ppr_options + & ~MSG_EXT_PPR_RD_STRM; + unsigned int period = tinfo->goal.period; + unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; + unsigned long flags; + + if (rdstrm) + ppr_options |= MSG_EXT_PPR_RD_STRM; + + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, + starget->channel + 'A', ROLE_INITIATOR); + ahd_find_syncrate(ahd, &period, &ppr_options, + dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + ahd_lock(ahd, &flags); + ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, + ppr_options, AHD_TRANS_GOAL, FALSE); + ahd_unlock(ahd, &flags); } +static struct spi_function_template ahd_linux_transport_functions = { + .set_offset = ahd_linux_set_offset, + .show_offset = 1, + .set_period = ahd_linux_set_period, + .show_period = 1, + .set_width = ahd_linux_set_width, + .show_width = 1, + .set_dt = ahd_linux_set_dt, + .show_dt = 1, + .set_iu = ahd_linux_set_iu, + .show_iu = 1, + .set_qas = ahd_linux_set_qas, + .show_qas = 1, + .set_rd_strm = ahd_linux_set_rd_strm, + .show_rd_strm = 1, +}; + + + static int __init ahd_linux_init(void) { - return ahd_linux_detect(&aic79xx_driver_template); + ahd_linux_transport_template = spi_attach_transport(&ahd_linux_transport_functions); + if (!ahd_linux_transport_template) + return -ENODEV; + scsi_transport_reserve_target(ahd_linux_transport_template, + sizeof(struct ahd_linux_target)); + scsi_transport_reserve_device(ahd_linux_transport_template, + sizeof(struct ahd_linux_device)); + if (ahd_linux_detect(&aic79xx_driver_template) > 0) + return 0; + spi_release_transport(ahd_linux_transport_template); + ahd_linux_exit(); + return -ENODEV; } static void __exit ahd_linux_exit(void) { - struct ahd_softc *ahd; - - /* - * Shutdown DV threads before going into the SCSI mid-layer. - * This avoids situations where the mid-layer locks the entire - * kernel so that waiting for our DV threads to exit leads - * to deadlock. - */ - TAILQ_FOREACH(ahd, &ahd_tailq, links) { - - ahd_linux_kill_dv_thread(ahd); - } - ahd_linux_pci_exit(); + spi_release_transport(ahd_linux_transport_template); } module_init(ahd_linux_init); diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h index 792e97fef5b..46edcf3e4e6 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.h +++ b/drivers/scsi/aic7xxx/aic79xx_osm.h @@ -42,6 +42,7 @@ #ifndef _AIC79XX_LINUX_H_ #define _AIC79XX_LINUX_H_ +#include #include #include #include @@ -49,18 +50,23 @@ #include #include #include +#include #include +#include #include #include -#include /* For tasklet support. */ -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include /* Core SCSI definitions */ #define AIC_LIB_PREFIX ahd -#include "scsi.h" -#include /* Name space conflict with BSD queue macros */ #ifdef LIST_HEAD @@ -95,7 +101,7 @@ /************************* Forward Declarations *******************************/ struct ahd_softc; typedef struct pci_dev *ahd_dev_softc_t; -typedef Scsi_Cmnd *ahd_io_ctx_t; +typedef struct scsi_cmnd *ahd_io_ctx_t; /******************************* Byte Order ***********************************/ #define ahd_htobe16(x) cpu_to_be16(x) @@ -115,7 +121,7 @@ typedef Scsi_Cmnd *ahd_io_ctx_t; /************************* Configuration Data *********************************/ extern uint32_t aic79xx_allow_memio; extern int aic79xx_detect_complete; -extern Scsi_Host_Template aic79xx_driver_template; +extern struct scsi_host_template aic79xx_driver_template; /***************************** Bus Space/DMA **********************************/ @@ -145,11 +151,7 @@ struct ahd_linux_dma_tag }; typedef struct ahd_linux_dma_tag* bus_dma_tag_t; -struct ahd_linux_dmamap -{ - dma_addr_t bus_addr; -}; -typedef struct ahd_linux_dmamap* bus_dmamap_t; +typedef dma_addr_t bus_dmamap_t; typedef int bus_dma_filter_t(void*, dma_addr_t); typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); @@ -226,12 +228,12 @@ typedef struct timer_list ahd_timer_t; #define ahd_timer_init init_timer #define ahd_timer_stop del_timer_sync typedef void ahd_linux_callback_t (u_long); -static __inline void ahd_timer_reset(ahd_timer_t *timer, u_int usec, +static __inline void ahd_timer_reset(ahd_timer_t *timer, int usec, ahd_callback_t *func, void *arg); static __inline void ahd_scb_timer_reset(struct scb *scb, u_int usec); static __inline void -ahd_timer_reset(ahd_timer_t *timer, u_int usec, ahd_callback_t *func, void *arg) +ahd_timer_reset(ahd_timer_t *timer, int usec, ahd_callback_t *func, void *arg) { struct ahd_softc *ahd; @@ -382,62 +384,12 @@ struct ahd_linux_device { */ u_int commands_since_idle_or_otag; #define AHD_OTAG_THRESH 500 - - int lun; - Scsi_Device *scsi_device; - struct ahd_linux_target *target; }; -typedef enum { - AHD_DV_REQUIRED = 0x01, - AHD_INQ_VALID = 0x02, - AHD_BASIC_DV = 0x04, - AHD_ENHANCED_DV = 0x08 -} ahd_linux_targ_flags; - -/* DV States */ -typedef enum { - AHD_DV_STATE_EXIT = 0, - AHD_DV_STATE_INQ_SHORT_ASYNC, - AHD_DV_STATE_INQ_ASYNC, - AHD_DV_STATE_INQ_ASYNC_VERIFY, - AHD_DV_STATE_TUR, - AHD_DV_STATE_REBD, - AHD_DV_STATE_INQ_VERIFY, - AHD_DV_STATE_WEB, - AHD_DV_STATE_REB, - AHD_DV_STATE_SU, - AHD_DV_STATE_BUSY -} ahd_dv_state; - struct ahd_linux_target { - struct ahd_linux_device *devices[AHD_NUM_LUNS]; - int channel; - int target; - int refcount; + struct scsi_device *sdev[AHD_NUM_LUNS]; struct ahd_transinfo last_tinfo; struct ahd_softc *ahd; - ahd_linux_targ_flags flags; - struct scsi_inquiry_data *inq_data; - /* - * The next "fallback" period to use for narrow/wide transfers. - */ - uint8_t dv_next_narrow_period; - uint8_t dv_next_wide_period; - uint8_t dv_max_width; - uint8_t dv_max_ppr_options; - uint8_t dv_last_ppr_options; - u_int dv_echo_size; - ahd_dv_state dv_state; - u_int dv_state_retry; - uint8_t *dv_buffer; - uint8_t *dv_buffer1; - - /* - * Cumulative counter of errors. - */ - u_long errors_detected; - u_long cmds_since_error; }; /********************* Definitions Required by the Core ***********************/ @@ -452,16 +404,11 @@ struct ahd_linux_target { /* * Per-SCB OSM storage. */ -typedef enum { - AHD_SCB_UP_EH_SEM = 0x1 -} ahd_linux_scb_flags; - struct scb_platform_data { struct ahd_linux_device *dev; dma_addr_t buf_busaddr; uint32_t xfer_len; uint32_t sense_resid; /* Auto-Sense residual */ - ahd_linux_scb_flags flags; }; /* @@ -470,42 +417,24 @@ struct scb_platform_data { * alignment restrictions of the various platforms supported by * this driver. */ -typedef enum { - AHD_DV_WAIT_SIMQ_EMPTY = 0x01, - AHD_DV_WAIT_SIMQ_RELEASE = 0x02, - AHD_DV_ACTIVE = 0x04, - AHD_DV_SHUTDOWN = 0x08, - AHD_RUN_CMPLT_Q_TIMER = 0x10 -} ahd_linux_softc_flags; - -TAILQ_HEAD(ahd_completeq, ahd_cmd); - struct ahd_platform_data { /* * Fields accessed from interrupt context. */ - struct ahd_linux_target *targets[AHD_NUM_TARGETS]; - struct ahd_completeq completeq; + struct scsi_target *starget[AHD_NUM_TARGETS]; spinlock_t spin_lock; u_int qfrozen; - pid_t dv_pid; - struct timer_list completeq_timer; struct timer_list reset_timer; - struct timer_list stats_timer; struct semaphore eh_sem; - struct semaphore dv_sem; - struct semaphore dv_cmd_sem; /* XXX This needs to be in - * the target struct - */ - struct scsi_device *dv_scsi_dev; struct Scsi_Host *host; /* pointer to scsi host */ #define AHD_LINUX_NOIRQ ((uint32_t)~0) uint32_t irq; /* IRQ for this adapter */ uint32_t bios_address; uint32_t mem_busaddr; /* Mem Base Addr */ uint64_t hw_dma_mask; - ahd_linux_softc_flags flags; +#define AHD_SCB_UP_EH_SEM 0x1 + uint32_t flags; }; /************************** OS Utility Wrappers *******************************/ @@ -622,7 +551,7 @@ ahd_insb(struct ahd_softc * ahd, long port, uint8_t *array, int count) /**************************** Initialization **********************************/ int ahd_linux_register_host(struct ahd_softc *, - Scsi_Host_Template *); + struct scsi_host_template *); uint64_t ahd_linux_get_memsize(void); @@ -643,17 +572,6 @@ static __inline void ahd_lockinit(struct ahd_softc *); static __inline void ahd_lock(struct ahd_softc *, unsigned long *flags); static __inline void ahd_unlock(struct ahd_softc *, unsigned long *flags); -/* Lock acquisition and release of the above lock in midlayer entry points. */ -static __inline void ahd_midlayer_entrypoint_lock(struct ahd_softc *, - unsigned long *flags); -static __inline void ahd_midlayer_entrypoint_unlock(struct ahd_softc *, - unsigned long *flags); - -/* Lock held during command compeletion to the upper layer */ -static __inline void ahd_done_lockinit(struct ahd_softc *); -static __inline void ahd_done_lock(struct ahd_softc *, unsigned long *flags); -static __inline void ahd_done_unlock(struct ahd_softc *, unsigned long *flags); - /* Lock held during ahd_list manipulation and ahd softc frees */ extern spinlock_t ahd_list_spinlock; static __inline void ahd_list_lockinit(void); @@ -678,57 +596,6 @@ ahd_unlock(struct ahd_softc *ahd, unsigned long *flags) spin_unlock_irqrestore(&ahd->platform_data->spin_lock, *flags); } -static __inline void -ahd_midlayer_entrypoint_lock(struct ahd_softc *ahd, unsigned long *flags) -{ - /* - * In 2.5.X and some 2.4.X versions, the midlayer takes our - * lock just before calling us, so we avoid locking again. - * For other kernel versions, the io_request_lock is taken - * just before our entry point is called. In this case, we - * trade the io_request_lock for our per-softc lock. - */ -#if AHD_SCSI_HAS_HOST_LOCK == 0 - spin_unlock(&io_request_lock); - spin_lock(&ahd->platform_data->spin_lock); -#endif -} - -static __inline void -ahd_midlayer_entrypoint_unlock(struct ahd_softc *ahd, unsigned long *flags) -{ -#if AHD_SCSI_HAS_HOST_LOCK == 0 - spin_unlock(&ahd->platform_data->spin_lock); - spin_lock(&io_request_lock); -#endif -} - -static __inline void -ahd_done_lockinit(struct ahd_softc *ahd) -{ - /* - * In 2.5.X, our own lock is held during completions. - * In previous versions, the io_request_lock is used. - * In either case, we can't initialize this lock again. - */ -} - -static __inline void -ahd_done_lock(struct ahd_softc *ahd, unsigned long *flags) -{ -#if AHD_SCSI_HAS_HOST_LOCK == 0 - spin_lock(&io_request_lock); -#endif -} - -static __inline void -ahd_done_unlock(struct ahd_softc *ahd, unsigned long *flags) -{ -#if AHD_SCSI_HAS_HOST_LOCK == 0 - spin_unlock(&io_request_lock); -#endif -} - static __inline void ahd_list_lockinit(void) { @@ -909,20 +776,14 @@ ahd_flush_device_writes(struct ahd_softc *ahd) int ahd_linux_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int); -/*************************** Domain Validation ********************************/ -#define AHD_DV_CMD(cmd) ((cmd)->scsi_done == ahd_linux_dv_complete) -#define AHD_DV_SIMQ_FROZEN(ahd) \ - ((((ahd)->platform_data->flags & AHD_DV_ACTIVE) != 0) \ - && (ahd)->platform_data->qfrozen == 1) - /*********************** Transaction Access Wrappers **************************/ -static __inline void ahd_cmd_set_transaction_status(Scsi_Cmnd *, uint32_t); +static __inline void ahd_cmd_set_transaction_status(struct scsi_cmnd *, uint32_t); static __inline void ahd_set_transaction_status(struct scb *, uint32_t); -static __inline void ahd_cmd_set_scsi_status(Scsi_Cmnd *, uint32_t); +static __inline void ahd_cmd_set_scsi_status(struct scsi_cmnd *, uint32_t); static __inline void ahd_set_scsi_status(struct scb *, uint32_t); -static __inline uint32_t ahd_cmd_get_transaction_status(Scsi_Cmnd *cmd); +static __inline uint32_t ahd_cmd_get_transaction_status(struct scsi_cmnd *cmd); static __inline uint32_t ahd_get_transaction_status(struct scb *); -static __inline uint32_t ahd_cmd_get_scsi_status(Scsi_Cmnd *cmd); +static __inline uint32_t ahd_cmd_get_scsi_status(struct scsi_cmnd *cmd); static __inline uint32_t ahd_get_scsi_status(struct scb *); static __inline void ahd_set_transaction_tag(struct scb *, int, u_int); static __inline u_long ahd_get_transfer_length(struct scb *); @@ -941,7 +802,7 @@ static __inline void ahd_platform_scb_free(struct ahd_softc *ahd, static __inline void ahd_freeze_scb(struct scb *scb); static __inline -void ahd_cmd_set_transaction_status(Scsi_Cmnd *cmd, uint32_t status) +void ahd_cmd_set_transaction_status(struct scsi_cmnd *cmd, uint32_t status) { cmd->result &= ~(CAM_STATUS_MASK << 16); cmd->result |= status << 16; @@ -954,7 +815,7 @@ void ahd_set_transaction_status(struct scb *scb, uint32_t status) } static __inline -void ahd_cmd_set_scsi_status(Scsi_Cmnd *cmd, uint32_t status) +void ahd_cmd_set_scsi_status(struct scsi_cmnd *cmd, uint32_t status) { cmd->result &= ~0xFFFF; cmd->result |= status; @@ -967,7 +828,7 @@ void ahd_set_scsi_status(struct scb *scb, uint32_t status) } static __inline -uint32_t ahd_cmd_get_transaction_status(Scsi_Cmnd *cmd) +uint32_t ahd_cmd_get_transaction_status(struct scsi_cmnd *cmd) { return ((cmd->result >> 16) & CAM_STATUS_MASK); } @@ -979,7 +840,7 @@ uint32_t ahd_get_transaction_status(struct scb *scb) } static __inline -uint32_t ahd_cmd_get_scsi_status(Scsi_Cmnd *cmd) +uint32_t ahd_cmd_get_scsi_status(struct scsi_cmnd *cmd) { return (cmd->result & 0xFFFF); } diff --git a/drivers/scsi/aic7xxx/aic79xx_proc.c b/drivers/scsi/aic7xxx/aic79xx_proc.c index 9c631a494ed..2058aa9b5c8 100644 --- a/drivers/scsi/aic7xxx/aic79xx_proc.c +++ b/drivers/scsi/aic7xxx/aic79xx_proc.c @@ -49,7 +49,7 @@ static void ahd_dump_target_state(struct ahd_softc *ahd, u_int our_id, char channel, u_int target_id, u_int target_offset); static void ahd_dump_device_state(struct info_str *info, - struct ahd_linux_device *dev); + struct scsi_device *sdev); static int ahd_proc_write_seeprom(struct ahd_softc *ahd, char *buffer, int length); @@ -167,6 +167,7 @@ ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info, u_int target_offset) { struct ahd_linux_target *targ; + struct scsi_target *starget; struct ahd_initiator_tinfo *tinfo; struct ahd_tmode_tstate *tstate; int lun; @@ -176,7 +177,8 @@ ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info, copy_info(info, "Target %d Negotiation Settings\n", target_id); copy_info(info, "\tUser: "); ahd_format_transinfo(info, &tinfo->user); - targ = ahd->platform_data->targets[target_offset]; + starget = ahd->platform_data->starget[target_offset]; + targ = scsi_transport_target_data(starget); if (targ == NULL) return; @@ -184,12 +186,11 @@ ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info, ahd_format_transinfo(info, &tinfo->goal); copy_info(info, "\tCurr: "); ahd_format_transinfo(info, &tinfo->curr); - copy_info(info, "\tTransmission Errors %ld\n", targ->errors_detected); for (lun = 0; lun < AHD_NUM_LUNS; lun++) { - struct ahd_linux_device *dev; + struct scsi_device *dev; - dev = targ->devices[lun]; + dev = targ->sdev[lun]; if (dev == NULL) continue; @@ -199,10 +200,13 @@ ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info, } static void -ahd_dump_device_state(struct info_str *info, struct ahd_linux_device *dev) +ahd_dump_device_state(struct info_str *info, struct scsi_device *sdev) { + struct ahd_linux_device *dev = scsi_transport_device_data(sdev); + copy_info(info, "\tChannel %c Target %d Lun %d Settings\n", - dev->target->channel + 'A', dev->target->target, dev->lun); + sdev->sdev_target->channel + 'A', + sdev->sdev_target->id, sdev->lun); copy_info(info, "\t\tCommands Queued %ld\n", dev->commands_issued); copy_info(info, "\t\tCommands Active %d\n", dev->active); -- cgit v1.2.3-18-g5258 From a4b53a11806f5c0824eb4115b1de8206ed7bb89a Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Mon, 1 Aug 2005 09:52:56 +0200 Subject: [SCSI] aic79xx: DV parameter settings This patch updates various scsi_transport_spi parameters with the actual parameters used by the driver internally. Domain Validation for all devices should now work properly. Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_osm.c | 231 ++++++++++++++++++++++++++++++++++--- 1 file changed, 218 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 70997ca28ba..cf8e0ca830a 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -1636,9 +1636,9 @@ ahd_send_async(struct ahd_softc *ahd, char channel, spi_period(starget) = tinfo->curr.period; spi_width(starget) = tinfo->curr.width; spi_offset(starget) = tinfo->curr.offset; - spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_DT_REQ; - spi_qas(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_QAS_REQ; - spi_iu(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ; + spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_DT_REQ ? 1 : 0; + spi_qas(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_QAS_REQ ? 1 : 0; + spi_iu(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ ? 1 : 0; spi_display_xfer_agreement(starget); break; } @@ -2318,6 +2318,18 @@ done: static void ahd_linux_exit(void); +static void ahd_linux_set_xferflags(struct scsi_target *starget, unsigned int ppr_options, unsigned int period) +{ + spi_qas(starget) = (ppr_options & MSG_EXT_PPR_QAS_REQ)? 1 : 0; + spi_dt(starget) = (ppr_options & MSG_EXT_PPR_DT_REQ)? 1 : 0; + spi_iu(starget) = (ppr_options & MSG_EXT_PPR_IU_REQ) ? 1 : 0; + spi_rd_strm(starget) = (ppr_options & MSG_EXT_PPR_RD_STRM) ? 1 : 0; + spi_wr_flow(starget) = (ppr_options & MSG_EXT_PPR_WR_FLOW) ? 1 : 0; + spi_pcomp_en(starget) = (ppr_options & MSG_EXT_PPR_PCOMP_EN) ? 1 : 0; + spi_rti(starget) = (ppr_options & MSG_EXT_PPR_RTI) ? 1 : 0; + spi_period(starget) = period; +} + static void ahd_linux_set_width(struct scsi_target *starget, int width) { struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); @@ -2343,9 +2355,14 @@ static void ahd_linux_set_period(struct scsi_target *starget, int period) shost->this_id, starget->id, &tstate); struct ahd_devinfo devinfo; unsigned int ppr_options = tinfo->goal.ppr_options; + unsigned int dt; unsigned long flags; unsigned long offset = tinfo->goal.offset; +#ifdef AHD_DEBUG + if ((ahd_debug & AHD_SHOW_DV) != 0) + printf("%s: set period to %d\n", ahd_name(ahd), period); +#endif if (offset == 0) offset = MAX_OFFSET; @@ -2357,6 +2374,8 @@ static void ahd_linux_set_period(struct scsi_target *starget, int period) ppr_options |= MSG_EXT_PPR_IU_REQ; } + dt = ppr_options & MSG_EXT_PPR_DT_REQ; + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, starget->channel + 'A', ROLE_INITIATOR); @@ -2366,7 +2385,11 @@ static void ahd_linux_set_period(struct scsi_target *starget, int period) ppr_options &= MSG_EXT_PPR_QAS_REQ; } - ahd_find_syncrate(ahd, &period, &ppr_options, AHD_SYNCRATE_MAX); + ahd_find_syncrate(ahd, &period, &ppr_options, + dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + + ahd_linux_set_xferflags(starget, ppr_options, period); + ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2385,15 +2408,24 @@ static void ahd_linux_set_offset(struct scsi_target *starget, int offset) struct ahd_devinfo devinfo; unsigned int ppr_options = 0; unsigned int period = 0; + unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; unsigned long flags; +#ifdef AHD_DEBUG + if ((ahd_debug & AHD_SHOW_DV) != 0) + printf("%s: set offset to %d\n", ahd_name(ahd), offset); +#endif + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, starget->channel + 'A', ROLE_INITIATOR); if (offset != 0) { period = tinfo->goal.period; ppr_options = tinfo->goal.ppr_options; - ahd_find_syncrate(ahd, &period, &ppr_options, AHD_SYNCRATE_MAX); + ahd_find_syncrate(ahd, &period, &ppr_options, + dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); } + ahd_linux_set_xferflags(starget, ppr_options, period); + ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2415,17 +2447,28 @@ static void ahd_linux_set_dt(struct scsi_target *starget, int dt) unsigned int period = tinfo->goal.period; unsigned long flags; +#ifdef AHD_DEBUG + if ((ahd_debug & AHD_SHOW_DV) != 0) + printf("%s: %s DT\n", ahd_name(ahd), + dt ? "enabling" : "disabling"); +#endif if (dt) { ppr_options |= MSG_EXT_PPR_DT_REQ; if (period > 9) period = 9; /* at least 12.5ns for DT */ - } else if (period <= 9) - period = 10; /* If resetting DT, period must be >= 25ns */ - + } else { + if (period <= 9) + period = 10; /* If resetting DT, period must be >= 25ns */ + /* IU is invalid without DT set */ + ppr_options &= ~MSG_EXT_PPR_IU_REQ; + } ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, starget->channel + 'A', ROLE_INITIATOR); ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + + ahd_linux_set_xferflags(starget, ppr_options, period); + ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2445,16 +2488,28 @@ static void ahd_linux_set_qas(struct scsi_target *starget, int qas) unsigned int ppr_options = tinfo->goal.ppr_options & ~MSG_EXT_PPR_QAS_REQ; unsigned int period = tinfo->goal.period; - unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; + unsigned int dt; unsigned long flags; - if (qas) - ppr_options |= MSG_EXT_PPR_QAS_REQ; +#ifdef AHD_DEBUG + if ((ahd_debug & AHD_SHOW_DV) != 0) + printf("%s: %s QAS\n", ahd_name(ahd), + qas ? "enabling" : "disabling"); +#endif + + if (qas) { + ppr_options |= MSG_EXT_PPR_QAS_REQ; + } + + dt = ppr_options & MSG_EXT_PPR_DT_REQ; ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, starget->channel + 'A', ROLE_INITIATOR); ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + + spi_qas(starget) = (ppr_options & MSG_EXT_PPR_QAS_REQ)? 1 : 0; + ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2474,16 +2529,29 @@ static void ahd_linux_set_iu(struct scsi_target *starget, int iu) unsigned int ppr_options = tinfo->goal.ppr_options & ~MSG_EXT_PPR_IU_REQ; unsigned int period = tinfo->goal.period; - unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; + unsigned int dt; unsigned long flags; - if (iu) +#ifdef AHD_DEBUG + if ((ahd_debug & AHD_SHOW_DV) != 0) + printf("%s: %s IU\n", ahd_name(ahd), + iu ? "enabling" : "disabling"); +#endif + + if (iu) { ppr_options |= MSG_EXT_PPR_IU_REQ; + ppr_options |= MSG_EXT_PPR_DT_REQ; /* IU requires DT */ + } + + dt = ppr_options & MSG_EXT_PPR_DT_REQ; ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, starget->channel + 'A', ROLE_INITIATOR); ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + + ahd_linux_set_xferflags(starget, ppr_options, period); + ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2506,6 +2574,12 @@ static void ahd_linux_set_rd_strm(struct scsi_target *starget, int rdstrm) unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; unsigned long flags; +#ifdef AHD_DEBUG + if ((ahd_debug & AHD_SHOW_DV) != 0) + printf("%s: %s Read Streaming\n", ahd_name(ahd), + rdstrm ? "enabling" : "disabling"); +#endif + if (rdstrm) ppr_options |= MSG_EXT_PPR_RD_STRM; @@ -2513,6 +2587,131 @@ static void ahd_linux_set_rd_strm(struct scsi_target *starget, int rdstrm) starget->channel + 'A', ROLE_INITIATOR); ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + + spi_rd_strm(starget) = (ppr_options & MSG_EXT_PPR_RD_STRM) ? 1 : 0; + + ahd_lock(ahd, &flags); + ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, + ppr_options, AHD_TRANS_GOAL, FALSE); + ahd_unlock(ahd, &flags); +} + +static void ahd_linux_set_wr_flow(struct scsi_target *starget, int wrflow) +{ + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct ahd_softc *ahd = *((struct ahd_softc **)shost->hostdata); + struct ahd_tmode_tstate *tstate; + struct ahd_initiator_tinfo *tinfo + = ahd_fetch_transinfo(ahd, + starget->channel + 'A', + shost->this_id, starget->id, &tstate); + struct ahd_devinfo devinfo; + unsigned int ppr_options = tinfo->goal.ppr_options + & ~MSG_EXT_PPR_WR_FLOW; + unsigned int period = tinfo->goal.period; + unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; + unsigned long flags; + +#ifdef AHD_DEBUG + if ((ahd_debug & AHD_SHOW_DV) != 0) + printf("%s: %s Write Flow Control\n", ahd_name(ahd), + wrflow ? "enabling" : "disabling"); +#endif + + if (wrflow) + ppr_options |= MSG_EXT_PPR_WR_FLOW; + + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, + starget->channel + 'A', ROLE_INITIATOR); + ahd_find_syncrate(ahd, &period, &ppr_options, + dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + + spi_wr_flow(starget) = (ppr_options & MSG_EXT_PPR_WR_FLOW) ? 1 : 0; + + ahd_lock(ahd, &flags); + ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, + ppr_options, AHD_TRANS_GOAL, FALSE); + ahd_unlock(ahd, &flags); +} + +static void ahd_linux_set_rti(struct scsi_target *starget, int rti) +{ + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct ahd_softc *ahd = *((struct ahd_softc **)shost->hostdata); + struct ahd_tmode_tstate *tstate; + struct ahd_initiator_tinfo *tinfo + = ahd_fetch_transinfo(ahd, + starget->channel + 'A', + shost->this_id, starget->id, &tstate); + struct ahd_devinfo devinfo; + unsigned int ppr_options = tinfo->goal.ppr_options + & ~MSG_EXT_PPR_RTI; + unsigned int period = tinfo->goal.period; + unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; + unsigned long flags; + + if ((ahd->features & AHD_RTI) == 0) { +#ifdef AHD_DEBUG + if ((ahd_debug & AHD_SHOW_DV) != 0) + printf("%s: RTI not available\n", ahd_name(ahd)); +#endif + return; + } + +#ifdef AHD_DEBUG + if ((ahd_debug & AHD_SHOW_DV) != 0) + printf("%s: %s RTI\n", ahd_name(ahd), + rti ? "enabling" : "disabling"); +#endif + + if (rti) + ppr_options |= MSG_EXT_PPR_RTI; + + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, + starget->channel + 'A', ROLE_INITIATOR); + ahd_find_syncrate(ahd, &period, &ppr_options, + dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + + spi_rti(starget) = (ppr_options & MSG_EXT_PPR_RTI) ? 1 : 0; + + ahd_lock(ahd, &flags); + ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, + ppr_options, AHD_TRANS_GOAL, FALSE); + ahd_unlock(ahd, &flags); +} + +static void ahd_linux_set_pcomp_en(struct scsi_target *starget, int pcomp) +{ + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct ahd_softc *ahd = *((struct ahd_softc **)shost->hostdata); + struct ahd_tmode_tstate *tstate; + struct ahd_initiator_tinfo *tinfo + = ahd_fetch_transinfo(ahd, + starget->channel + 'A', + shost->this_id, starget->id, &tstate); + struct ahd_devinfo devinfo; + unsigned int ppr_options = tinfo->goal.ppr_options + & ~MSG_EXT_PPR_PCOMP_EN; + unsigned int period = tinfo->goal.period; + unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; + unsigned long flags; + +#ifdef AHD_DEBUG + if ((ahd_debug & AHD_SHOW_DV) != 0) + printf("%s: %s Precompensation\n", ahd_name(ahd), + pcomp ? "Enable" : "Disable"); +#endif + + if (pcomp) + ppr_options |= MSG_EXT_PPR_PCOMP_EN; + + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, + starget->channel + 'A', ROLE_INITIATOR); + ahd_find_syncrate(ahd, &period, &ppr_options, + dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + + spi_pcomp_en(starget) = (ppr_options & MSG_EXT_PPR_PCOMP_EN) ? 1 : 0; + ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2534,6 +2733,12 @@ static struct spi_function_template ahd_linux_transport_functions = { .show_qas = 1, .set_rd_strm = ahd_linux_set_rd_strm, .show_rd_strm = 1, + .set_wr_flow = ahd_linux_set_wr_flow, + .show_wr_flow = 1, + .set_rti = ahd_linux_set_rti, + .show_rti = 1, + .set_pcomp_en = ahd_linux_set_pcomp_en, + .show_pcomp_en = 1, }; -- cgit v1.2.3-18-g5258 From 3f40d7d6eaadecd48f6d1c0c4a5ad414b992260e Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Wed, 3 Aug 2005 13:25:10 -0500 Subject: [SCSI] aic79xx: fix up transport settings There's a slight problem in the way you've done the transport parameters; reading from the variables actually produces the current settings, not the ones you just set (and there's usually a lag because devices don't renegotiate until the next command goes over the bus). If you set the bit immediately, you get into the situation where the transport parameters report something as being set even if the drive cannot support it. I patched the driver to do it this way and also corrected a panic in the proc routines. Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_osm.c | 39 +++++++++---------------------------- drivers/scsi/aic7xxx/aic79xx_proc.c | 4 ++-- 2 files changed, 11 insertions(+), 32 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index cf8e0ca830a..10a2570ca38 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -1624,7 +1624,11 @@ ahd_send_async(struct ahd_softc *ahd, char channel, target_ppr_options = (spi_dt(starget) ? MSG_EXT_PPR_DT_REQ : 0) + (spi_qas(starget) ? MSG_EXT_PPR_QAS_REQ : 0) - + (spi_iu(starget) ? MSG_EXT_PPR_IU_REQ : 0); + + (spi_iu(starget) ? MSG_EXT_PPR_IU_REQ : 0) + + (spi_rd_strm(starget) ? MSG_EXT_PPR_RD_STRM : 0) + + (spi_pcomp_en(starget) ? MSG_EXT_PPR_PCOMP_EN : 0) + + (spi_rti(starget) ? MSG_EXT_PPR_RTI : 0) + + (spi_wr_flow(starget) ? MSG_EXT_PPR_WR_FLOW : 0); if (tinfo->curr.period == spi_period(starget) && tinfo->curr.width == spi_width(starget) @@ -1639,6 +1643,10 @@ ahd_send_async(struct ahd_softc *ahd, char channel, spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_DT_REQ ? 1 : 0; spi_qas(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_QAS_REQ ? 1 : 0; spi_iu(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ ? 1 : 0; + spi_rd_strm(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_RD_STRM ? 1 : 0; + spi_pcomp_en(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_PCOMP_EN ? 1 : 0; + spi_rti(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_RTI ? 1 : 0; + spi_wr_flow(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_WR_FLOW ? 1 : 0; spi_display_xfer_agreement(starget); break; } @@ -2318,18 +2326,6 @@ done: static void ahd_linux_exit(void); -static void ahd_linux_set_xferflags(struct scsi_target *starget, unsigned int ppr_options, unsigned int period) -{ - spi_qas(starget) = (ppr_options & MSG_EXT_PPR_QAS_REQ)? 1 : 0; - spi_dt(starget) = (ppr_options & MSG_EXT_PPR_DT_REQ)? 1 : 0; - spi_iu(starget) = (ppr_options & MSG_EXT_PPR_IU_REQ) ? 1 : 0; - spi_rd_strm(starget) = (ppr_options & MSG_EXT_PPR_RD_STRM) ? 1 : 0; - spi_wr_flow(starget) = (ppr_options & MSG_EXT_PPR_WR_FLOW) ? 1 : 0; - spi_pcomp_en(starget) = (ppr_options & MSG_EXT_PPR_PCOMP_EN) ? 1 : 0; - spi_rti(starget) = (ppr_options & MSG_EXT_PPR_RTI) ? 1 : 0; - spi_period(starget) = period; -} - static void ahd_linux_set_width(struct scsi_target *starget, int width) { struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); @@ -2388,8 +2384,6 @@ static void ahd_linux_set_period(struct scsi_target *starget, int period) ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); - ahd_linux_set_xferflags(starget, ppr_options, period); - ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2424,7 +2418,6 @@ static void ahd_linux_set_offset(struct scsi_target *starget, int offset) ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); } - ahd_linux_set_xferflags(starget, ppr_options, period); ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, offset, ppr_options, @@ -2467,8 +2460,6 @@ static void ahd_linux_set_dt(struct scsi_target *starget, int dt) ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); - ahd_linux_set_xferflags(starget, ppr_options, period); - ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2508,8 +2499,6 @@ static void ahd_linux_set_qas(struct scsi_target *starget, int qas) ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); - spi_qas(starget) = (ppr_options & MSG_EXT_PPR_QAS_REQ)? 1 : 0; - ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2550,8 +2539,6 @@ static void ahd_linux_set_iu(struct scsi_target *starget, int iu) ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); - ahd_linux_set_xferflags(starget, ppr_options, period); - ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2588,8 +2575,6 @@ static void ahd_linux_set_rd_strm(struct scsi_target *starget, int rdstrm) ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); - spi_rd_strm(starget) = (ppr_options & MSG_EXT_PPR_RD_STRM) ? 1 : 0; - ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2626,8 +2611,6 @@ static void ahd_linux_set_wr_flow(struct scsi_target *starget, int wrflow) ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); - spi_wr_flow(starget) = (ppr_options & MSG_EXT_PPR_WR_FLOW) ? 1 : 0; - ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2672,8 +2655,6 @@ static void ahd_linux_set_rti(struct scsi_target *starget, int rti) ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); - spi_rti(starget) = (ppr_options & MSG_EXT_PPR_RTI) ? 1 : 0; - ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, ppr_options, AHD_TRANS_GOAL, FALSE); @@ -2710,8 +2691,6 @@ static void ahd_linux_set_pcomp_en(struct scsi_target *starget, int pcomp) ahd_find_syncrate(ahd, &period, &ppr_options, dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); - spi_pcomp_en(starget) = (ppr_options & MSG_EXT_PPR_PCOMP_EN) ? 1 : 0; - ahd_lock(ahd, &flags); ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, ppr_options, AHD_TRANS_GOAL, FALSE); diff --git a/drivers/scsi/aic7xxx/aic79xx_proc.c b/drivers/scsi/aic7xxx/aic79xx_proc.c index 2058aa9b5c8..cffdd104f9e 100644 --- a/drivers/scsi/aic7xxx/aic79xx_proc.c +++ b/drivers/scsi/aic7xxx/aic79xx_proc.c @@ -178,9 +178,9 @@ ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info, copy_info(info, "\tUser: "); ahd_format_transinfo(info, &tinfo->user); starget = ahd->platform_data->starget[target_offset]; - targ = scsi_transport_target_data(starget); - if (targ == NULL) + if (starget == NULL) return; + targ = scsi_transport_target_data(starget); copy_info(info, "\tGoal: "); ahd_format_transinfo(info, &tinfo->goal); -- cgit v1.2.3-18-g5258 From d872ebe4549576e7aab60ed7c746193196381dd0 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Wed, 3 Aug 2005 15:43:52 -0500 Subject: [SCSI] add missing hold_mcs parameter to the spi transport class This parameter is important only to people who take the time to tune the margin control settings, otherwise it's completely irrelevant. However, just in case anyone should want to do this, it's appropriate to include the parameter. I don't do anything with it in DV by design, so the parameter will come up as off by default, so if anyone actually wants to play with the margin control settings they'll have to enable it under the spi_transport class first. I also updated the transfer settings display to report all of the PPR settings instead of only DT, IU and QAS Signed-off-by: James Bottomley --- drivers/scsi/scsi_transport_spi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 7670919a087..e7b9570c818 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -35,7 +35,7 @@ #define SPI_PRINTK(x, l, f, a...) dev_printk(l, &(x)->dev, f , ##a) -#define SPI_NUM_ATTRS 13 /* increase this if you add attributes */ +#define SPI_NUM_ATTRS 14 /* increase this if you add attributes */ #define SPI_OTHER_ATTRS 1 /* Increase this if you add "always * on" attributes */ #define SPI_HOST_ATTRS 1 @@ -231,6 +231,7 @@ static int spi_setup_transport_attrs(struct device *dev) spi_rd_strm(starget) = 0; spi_rti(starget) = 0; spi_pcomp_en(starget) = 0; + spi_hold_mcs(starget) = 0; spi_dv_pending(starget) = 0; spi_initial_dv(starget) = 0; init_MUTEX(&spi_dv_sem(starget)); @@ -347,6 +348,7 @@ spi_transport_rd_attr(wr_flow, "%d\n"); spi_transport_rd_attr(rd_strm, "%d\n"); spi_transport_rd_attr(rti, "%d\n"); spi_transport_rd_attr(pcomp_en, "%d\n"); +spi_transport_rd_attr(hold_mcs, "%d\n"); /* we only care about the first child device so we return 1 */ static int child_iter(struct device *dev, void *data) @@ -1028,10 +1030,17 @@ void spi_display_xfer_agreement(struct scsi_target *starget) sprint_frac(tmp, picosec, 1000); dev_info(&starget->dev, - "%s %sSCSI %d.%d MB/s %s%s%s (%s ns, offset %d)\n", - scsi, tp->width ? "WIDE " : "", kb100/10, kb100 % 10, - tp->dt ? "DT" : "ST", tp->iu ? " IU" : "", - tp->qas ? " QAS" : "", tmp, tp->offset); + "%s %sSCSI %d.%d MB/s %s%s%s%s%s%s%s%s (%s ns, offset %d)\n", + scsi, tp->width ? "WIDE " : "", kb100/10, kb100 % 10, + tp->dt ? "DT" : "ST", + tp->iu ? " IU" : "", + tp->qas ? " QAS" : "", + tp->rd_strm ? " RDSTRM" : "", + tp->rti ? " RTI" : "", + tp->wr_flow ? " WRFLOW" : "", + tp->pcomp_en ? " PCOMP" : "", + tp->hold_mcs ? " HMCS" : "", + tmp, tp->offset); } else { dev_info(&starget->dev, "%sasynchronous.\n", tp->width ? "wide " : ""); @@ -1154,6 +1163,7 @@ spi_attach_transport(struct spi_function_template *ft) SETUP_ATTRIBUTE(rd_strm); SETUP_ATTRIBUTE(rti); SETUP_ATTRIBUTE(pcomp_en); + SETUP_ATTRIBUTE(hold_mcs); /* if you add an attribute but forget to increase SPI_NUM_ATTRS * this bug will trigger */ -- cgit v1.2.3-18-g5258 From 88ff29a4a5a8c4e0ecf375f783be071d1e7e264d Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Wed, 3 Aug 2005 15:59:04 -0500 Subject: [SCSI] aic79xx: add hold_mcs to the transport parameters since this card can support the setting, add it to the parameter list. Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_osm.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 10a2570ca38..982a74a145f 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -1628,7 +1628,8 @@ ahd_send_async(struct ahd_softc *ahd, char channel, + (spi_rd_strm(starget) ? MSG_EXT_PPR_RD_STRM : 0) + (spi_pcomp_en(starget) ? MSG_EXT_PPR_PCOMP_EN : 0) + (spi_rti(starget) ? MSG_EXT_PPR_RTI : 0) - + (spi_wr_flow(starget) ? MSG_EXT_PPR_WR_FLOW : 0); + + (spi_wr_flow(starget) ? MSG_EXT_PPR_WR_FLOW : 0) + + (spi_hold_mcs(starget) ? MSG_EXT_PPR_HOLD_MCS : 0); if (tinfo->curr.period == spi_period(starget) && tinfo->curr.width == spi_width(starget) @@ -1647,6 +1648,7 @@ ahd_send_async(struct ahd_softc *ahd, char channel, spi_pcomp_en(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_PCOMP_EN ? 1 : 0; spi_rti(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_RTI ? 1 : 0; spi_wr_flow(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_WR_FLOW ? 1 : 0; + spi_hold_mcs(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_HOLD_MCS ? 1 : 0; spi_display_xfer_agreement(starget); break; } @@ -2697,6 +2699,38 @@ static void ahd_linux_set_pcomp_en(struct scsi_target *starget, int pcomp) ahd_unlock(ahd, &flags); } +static void ahd_linux_set_hold_mcs(struct scsi_target *starget, int hold) +{ + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct ahd_softc *ahd = *((struct ahd_softc **)shost->hostdata); + struct ahd_tmode_tstate *tstate; + struct ahd_initiator_tinfo *tinfo + = ahd_fetch_transinfo(ahd, + starget->channel + 'A', + shost->this_id, starget->id, &tstate); + struct ahd_devinfo devinfo; + unsigned int ppr_options = tinfo->goal.ppr_options + & ~MSG_EXT_PPR_HOLD_MCS; + unsigned int period = tinfo->goal.period; + unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; + unsigned long flags; + + if (hold) + ppr_options |= MSG_EXT_PPR_HOLD_MCS; + + ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, + starget->channel + 'A', ROLE_INITIATOR); + ahd_find_syncrate(ahd, &period, &ppr_options, + dt ? AHD_SYNCRATE_MAX : AHD_SYNCRATE_ULTRA2); + + ahd_lock(ahd, &flags); + ahd_set_syncrate(ahd, &devinfo, period, tinfo->goal.offset, + ppr_options, AHD_TRANS_GOAL, FALSE); + ahd_unlock(ahd, &flags); +} + + + static struct spi_function_template ahd_linux_transport_functions = { .set_offset = ahd_linux_set_offset, .show_offset = 1, @@ -2718,6 +2752,8 @@ static struct spi_function_template ahd_linux_transport_functions = { .show_rti = 1, .set_pcomp_en = ahd_linux_set_pcomp_en, .show_pcomp_en = 1, + .set_hold_mcs = ahd_linux_set_hold_mcs, + .show_hold_mcs = 1, }; -- cgit v1.2.3-18-g5258 From 52b5cfb355b2b3274979d25490f190d478ab1fad Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Thu, 4 Aug 2005 09:16:59 +0200 Subject: [SCSI] aic79xx: fixup DT setting this patch is just a cross-port of the fixup for aic7xxx DT settings. As the same restrictions apply for aic79xx also (DT requires wide transfers) the dt setting routine should be modified equivalently. And an invalid period setting will be caught by ahd_find_syncrate() anyway. Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_osm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 982a74a145f..40f32bb2397 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -2440,6 +2440,7 @@ static void ahd_linux_set_dt(struct scsi_target *starget, int dt) unsigned int ppr_options = tinfo->goal.ppr_options & ~MSG_EXT_PPR_DT_REQ; unsigned int period = tinfo->goal.period; + unsigned int width = tinfo->goal.width; unsigned long flags; #ifdef AHD_DEBUG @@ -2449,8 +2450,8 @@ static void ahd_linux_set_dt(struct scsi_target *starget, int dt) #endif if (dt) { ppr_options |= MSG_EXT_PPR_DT_REQ; - if (period > 9) - period = 9; /* at least 12.5ns for DT */ + if (!width) + ahd_linux_set_width(starget, 1); } else { if (period <= 9) period = 10; /* If resetting DT, period must be >= 25ns */ -- cgit v1.2.3-18-g5258 From 79778a27be4c704552a18cf2a3e8b9e30623acd1 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Thu, 4 Aug 2005 17:33:22 -0500 Subject: [SCSI] aic7xxx: upport all sequencer and core fixes from adaptec version 6.3.9 This patch upports all relevant code fixes and bumps the driver version to 7.0 to signify starting a new tree. Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic7xxx.h | 4 +- drivers/scsi/aic7xxx/aic7xxx.reg | 4 +- drivers/scsi/aic7xxx/aic7xxx.seq | 5 +- drivers/scsi/aic7xxx/aic7xxx_93cx6.c | 36 +- drivers/scsi/aic7xxx/aic7xxx_core.c | 60 +- drivers/scsi/aic7xxx/aic7xxx_osm.c | 2 + drivers/scsi/aic7xxx/aic7xxx_osm.h | 2 +- drivers/scsi/aic7xxx/aic7xxx_reg.h_shipped | 6 +- drivers/scsi/aic7xxx/aic7xxx_reg_print.c_shipped | 4 +- drivers/scsi/aic7xxx/aic7xxx_seq.h_shipped | 933 ++++++++++++----------- 10 files changed, 544 insertions(+), 512 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic7xxx.h b/drivers/scsi/aic7xxx/aic7xxx.h index 088cbc23743..91d294c6334 100644 --- a/drivers/scsi/aic7xxx/aic7xxx.h +++ b/drivers/scsi/aic7xxx/aic7xxx.h @@ -37,7 +37,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * - * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.h#79 $ + * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.h#85 $ * * $FreeBSD$ */ @@ -243,7 +243,7 @@ typedef enum { */ AHC_AIC7850_FE = AHC_SPIOCAP|AHC_AUTOPAUSE|AHC_TARGETMODE|AHC_ULTRA, AHC_AIC7860_FE = AHC_AIC7850_FE, - AHC_AIC7870_FE = AHC_TARGETMODE, + AHC_AIC7870_FE = AHC_TARGETMODE|AHC_AUTOPAUSE, AHC_AIC7880_FE = AHC_AIC7870_FE|AHC_ULTRA, /* * Although we have space for both the initiator and diff --git a/drivers/scsi/aic7xxx/aic7xxx.reg b/drivers/scsi/aic7xxx/aic7xxx.reg index 810ec700d9f..e196d83b93c 100644 --- a/drivers/scsi/aic7xxx/aic7xxx.reg +++ b/drivers/scsi/aic7xxx/aic7xxx.reg @@ -39,7 +39,7 @@ * * $FreeBSD$ */ -VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#39 $" +VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#40 $" /* * This file is processed by the aic7xxx_asm utility for use in assembling @@ -1306,7 +1306,6 @@ scratch_ram { */ MWI_RESIDUAL { size 1 - alias TARG_IMMEDIATE_SCB } /* * SCBID of the next SCB to be started by the controller. @@ -1461,6 +1460,7 @@ scratch_ram { */ LAST_MSG { size 1 + alias TARG_IMMEDIATE_SCB } /* diff --git a/drivers/scsi/aic7xxx/aic7xxx.seq b/drivers/scsi/aic7xxx/aic7xxx.seq index d84b741fbab..15196390e28 100644 --- a/drivers/scsi/aic7xxx/aic7xxx.seq +++ b/drivers/scsi/aic7xxx/aic7xxx.seq @@ -40,7 +40,7 @@ * $FreeBSD$ */ -VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#56 $" +VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#58 $" PATCH_ARG_LIST = "struct ahc_softc *ahc" PREFIX = "ahc_" @@ -679,6 +679,7 @@ await_busfree: clr SCSIBUSL; /* Prevent bit leakage durint SELTO */ } and SXFRCTL0, ~SPIOEN; + mvi SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT; test SSTAT1,REQINIT|BUSFREE jz .; test SSTAT1, BUSFREE jnz poll_for_work; mvi MISSED_BUSFREE call set_seqint; @@ -1097,7 +1098,7 @@ ultra2_dmahalt: test SCB_RESIDUAL_DATACNT[3], SG_LAST_SEG jz dma_mid_sg; if ((ahc->flags & AHC_TARGETROLE) != 0) { test SSTAT0, TARGET jz dma_last_sg; - if ((ahc->flags & AHC_TMODE_WIDEODD_BUG) != 0) { + if ((ahc->bugs & AHC_TMODE_WIDEODD_BUG) != 0) { test DMAPARAMS, DIRECTION jz dma_mid_sg; } } diff --git a/drivers/scsi/aic7xxx/aic7xxx_93cx6.c b/drivers/scsi/aic7xxx/aic7xxx_93cx6.c index 468d612a44f..3cb07e114e8 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_93cx6.c +++ b/drivers/scsi/aic7xxx/aic7xxx_93cx6.c @@ -28,9 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#17 $ - * - * $FreeBSD$ + * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#19 $ */ /* @@ -64,7 +62,6 @@ * is preceded by an initial zero (leading 0, followed by 16-bits, MSB * first). The clock cycling from low to high initiates the next data * bit to be sent from the chip. - * */ #ifdef __linux__ @@ -81,14 +78,22 @@ * Right now, we only have to read the SEEPROM. But we make it easier to * add other 93Cx6 functions. */ -static struct seeprom_cmd { +struct seeprom_cmd { uint8_t len; - uint8_t bits[9]; -} seeprom_read = {3, {1, 1, 0}}; + uint8_t bits[11]; +}; +/* Short opcodes for the c46 */ static struct seeprom_cmd seeprom_ewen = {9, {1, 0, 0, 1, 1, 0, 0, 0, 0}}; static struct seeprom_cmd seeprom_ewds = {9, {1, 0, 0, 0, 0, 0, 0, 0, 0}}; + +/* Long opcodes for the C56/C66 */ +static struct seeprom_cmd seeprom_long_ewen = {11, {1, 0, 0, 1, 1, 0, 0, 0, 0}}; +static struct seeprom_cmd seeprom_long_ewds = {11, {1, 0, 0, 0, 0, 0, 0, 0, 0}}; + +/* Common opcodes */ static struct seeprom_cmd seeprom_write = {3, {1, 0, 1}}; +static struct seeprom_cmd seeprom_read = {3, {1, 1, 0}}; /* * Wait for the SEERDY to go high; about 800 ns. @@ -222,12 +227,25 @@ int ahc_write_seeprom(struct seeprom_descriptor *sd, uint16_t *buf, u_int start_addr, u_int count) { + struct seeprom_cmd *ewen, *ewds; uint16_t v; uint8_t temp; int i, k; /* Place the chip into write-enable mode */ - send_seeprom_cmd(sd, &seeprom_ewen); + if (sd->sd_chip == C46) { + ewen = &seeprom_ewen; + ewds = &seeprom_ewds; + } else if (sd->sd_chip == C56_66) { + ewen = &seeprom_long_ewen; + ewds = &seeprom_long_ewds; + } else { + printf("ahc_write_seeprom: unsupported seeprom type %d\n", + sd->sd_chip); + return (0); + } + + send_seeprom_cmd(sd, ewen); reset_seeprom(sd); /* Write all requested data out to the seeprom. */ @@ -277,7 +295,7 @@ ahc_write_seeprom(struct seeprom_descriptor *sd, uint16_t *buf, } /* Put the chip back into write-protect mode */ - send_seeprom_cmd(sd, &seeprom_ewds); + send_seeprom_cmd(sd, ewds); reset_seeprom(sd); return (1); diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c index 7bc01e41bcc..58ac46103eb 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_core.c +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c @@ -37,9 +37,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * - * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.c#134 $ - * - * $FreeBSD$ + * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.c#155 $ */ #ifdef __linux__ @@ -287,10 +285,19 @@ ahc_restart(struct ahc_softc *ahc) ahc_outb(ahc, SEQ_FLAGS2, ahc_inb(ahc, SEQ_FLAGS2) & ~SCB_DMA); } + + /* + * Clear any pending sequencer interrupt. It is no + * longer relevant since we're resetting the Program + * Counter. + */ + ahc_outb(ahc, CLRINT, CLRSEQINT); + ahc_outb(ahc, MWI_RESIDUAL, 0); ahc_outb(ahc, SEQCTL, ahc->seqctl); ahc_outb(ahc, SEQADDR0, 0); ahc_outb(ahc, SEQADDR1, 0); + ahc_unpause(ahc); } @@ -1174,19 +1181,20 @@ ahc_handle_scsiint(struct ahc_softc *ahc, u_int intstat) scb_index); } #endif - /* - * Force a renegotiation with this target just in - * case the cable was pulled and will later be - * re-attached. The target may forget its negotiation - * settings with us should it attempt to reselect - * during the interruption. The target will not issue - * a unit attention in this case, so we must always - * renegotiate. - */ ahc_scb_devinfo(ahc, &devinfo, scb); - ahc_force_renegotiation(ahc, &devinfo); ahc_set_transaction_status(scb, CAM_SEL_TIMEOUT); ahc_freeze_devq(ahc, scb); + + /* + * Cancel any pending transactions on the device + * now that it seems to be missing. This will + * also revert us to async/narrow transfers until + * we can renegotiate with the device. + */ + ahc_handle_devreset(ahc, &devinfo, + CAM_SEL_TIMEOUT, + "Selection Timeout", + /*verbose_level*/1); } ahc_outb(ahc, CLRINT, CLRSCSIINT); ahc_restart(ahc); @@ -3763,8 +3771,9 @@ ahc_handle_devreset(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, /*period*/0, /*offset*/0, /*ppr_options*/0, AHC_TRANS_CUR, /*paused*/TRUE); - ahc_send_async(ahc, devinfo->channel, devinfo->target, - CAM_LUN_WILDCARD, AC_SENT_BDR, NULL); + if (status != CAM_SEL_TIMEOUT) + ahc_send_async(ahc, devinfo->channel, devinfo->target, + CAM_LUN_WILDCARD, AC_SENT_BDR, NULL); if (message != NULL && (verbose_level <= bootverbose)) @@ -4003,14 +4012,6 @@ ahc_reset(struct ahc_softc *ahc, int reinit) * to disturb the integrity of the bus. */ ahc_pause(ahc); - if ((ahc_inb(ahc, HCNTRL) & CHIPRST) != 0) { - /* - * The chip has not been initialized since - * PCI/EISA/VLB bus reset. Don't trust - * "left over BIOS data". - */ - ahc->flags |= AHC_NO_BIOS_INIT; - } sxfrctl1_b = 0; if ((ahc->chip & AHC_CHIPID_MASK) == AHC_AIC7770) { u_int sblkctl; @@ -5036,14 +5037,23 @@ ahc_pause_and_flushwork(struct ahc_softc *ahc) ahc->flags |= AHC_ALL_INTERRUPTS; paused = FALSE; do { - if (paused) + if (paused) { ahc_unpause(ahc); + /* + * Give the sequencer some time to service + * any active selections. + */ + ahc_delay(500); + } ahc_intr(ahc); ahc_pause(ahc); paused = TRUE; ahc_outb(ahc, SCSISEQ, ahc_inb(ahc, SCSISEQ) & ~ENSELO); - ahc_clear_critical_section(ahc); intstat = ahc_inb(ahc, INTSTAT); + if ((intstat & INT_PEND) == 0) { + ahc_clear_critical_section(ahc); + intstat = ahc_inb(ahc, INTSTAT); + } } while (--maxloops && (intstat != 0xFF || (ahc->features & AHC_REMOVABLE) == 0) && ((intstat & INT_PEND) != 0 diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 116d0f51ca2..e39361ac6a4 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -635,6 +635,8 @@ ahc_linux_slave_alloc(struct scsi_device *sdev) targ->sdev[sdev->lun] = sdev; + spi_period(starget) = 0; + return 0; } diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h index 0e47ac21754..c5299626924 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.h +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h @@ -265,7 +265,7 @@ ahc_scb_timer_reset(struct scb *scb, u_int usec) /***************************** SMP support ************************************/ #include -#define AIC7XXX_DRIVER_VERSION "6.2.36" +#define AIC7XXX_DRIVER_VERSION "7.0" /*************************** Device Data Structures ***************************/ /* diff --git a/drivers/scsi/aic7xxx/aic7xxx_reg.h_shipped b/drivers/scsi/aic7xxx/aic7xxx_reg.h_shipped index 7c1390ed117..2ce1febca20 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_reg.h_shipped +++ b/drivers/scsi/aic7xxx/aic7xxx_reg.h_shipped @@ -2,8 +2,8 @@ * DO NOT EDIT - This file is automatically generated * from the following source files: * - * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#56 $ - * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#39 $ + * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#58 $ + * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#40 $ */ typedef int (ahc_reg_print_t)(u_int, u_int *, u_int); typedef struct ahc_reg_parse_entry { @@ -1298,7 +1298,6 @@ ahc_reg_print_t ahc_sg_cache_pre_print; #define CMDSIZE_TABLE_TAIL 0x34 #define MWI_RESIDUAL 0x38 -#define TARG_IMMEDIATE_SCB 0x38 #define NEXT_QUEUED_SCB 0x39 @@ -1380,6 +1379,7 @@ ahc_reg_print_t ahc_sg_cache_pre_print; #define RETURN_2 0x52 #define LAST_MSG 0x53 +#define TARG_IMMEDIATE_SCB 0x53 #define SCSISEQ_TEMPLATE 0x54 #define ENSELO 0x40 diff --git a/drivers/scsi/aic7xxx/aic7xxx_reg_print.c_shipped b/drivers/scsi/aic7xxx/aic7xxx_reg_print.c_shipped index 9c713775d44..88bfd767c51 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_reg_print.c_shipped +++ b/drivers/scsi/aic7xxx/aic7xxx_reg_print.c_shipped @@ -2,8 +2,8 @@ * DO NOT EDIT - This file is automatically generated * from the following source files: * - * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#56 $ - * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#39 $ + * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#58 $ + * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#40 $ */ #include "aic7xxx_osm.h" diff --git a/drivers/scsi/aic7xxx/aic7xxx_seq.h_shipped b/drivers/scsi/aic7xxx/aic7xxx_seq.h_shipped index cf411368a87..4cee08521e7 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_seq.h_shipped +++ b/drivers/scsi/aic7xxx/aic7xxx_seq.h_shipped @@ -2,13 +2,13 @@ * DO NOT EDIT - This file is automatically generated * from the following source files: * - * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#56 $ - * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#39 $ + * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#58 $ + * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#40 $ */ static uint8_t seqprog[] = { 0xb2, 0x00, 0x00, 0x08, 0xf7, 0x11, 0x22, 0x08, - 0x00, 0x65, 0xec, 0x59, + 0x00, 0x65, 0xee, 0x59, 0xf7, 0x01, 0x02, 0x08, 0xff, 0x6a, 0x24, 0x08, 0x40, 0x00, 0x40, 0x68, @@ -21,15 +21,15 @@ static uint8_t seqprog[] = { 0x01, 0x4d, 0xc8, 0x30, 0x00, 0x4c, 0x12, 0x70, 0x01, 0x39, 0xa2, 0x30, - 0x00, 0x6a, 0xc0, 0x5e, + 0x00, 0x6a, 0xc2, 0x5e, 0x01, 0x51, 0x20, 0x31, 0x01, 0x57, 0xae, 0x00, 0x0d, 0x6a, 0x76, 0x00, - 0x00, 0x51, 0x12, 0x5e, + 0x00, 0x51, 0x14, 0x5e, 0x01, 0x51, 0xc8, 0x30, 0x00, 0x39, 0xc8, 0x60, 0x00, 0xbb, 0x30, 0x70, - 0xc1, 0x6a, 0xd8, 0x5e, + 0xc1, 0x6a, 0xda, 0x5e, 0x01, 0xbf, 0x72, 0x30, 0x01, 0x40, 0x7e, 0x31, 0x01, 0x90, 0x80, 0x30, @@ -49,10 +49,10 @@ static uint8_t seqprog[] = { 0x08, 0x6a, 0x78, 0x00, 0x01, 0x50, 0xc8, 0x30, 0xe0, 0x6a, 0xcc, 0x00, - 0x48, 0x6a, 0xfc, 0x5d, + 0x48, 0x6a, 0xfe, 0x5d, 0x01, 0x6a, 0xdc, 0x01, 0x88, 0x6a, 0xcc, 0x00, - 0x48, 0x6a, 0xfc, 0x5d, + 0x48, 0x6a, 0xfe, 0x5d, 0x01, 0x6a, 0x26, 0x01, 0xf0, 0x19, 0x7a, 0x08, 0x0f, 0x18, 0xc8, 0x08, @@ -93,7 +93,7 @@ static uint8_t seqprog[] = { 0x00, 0x65, 0x20, 0x41, 0x02, 0x57, 0xae, 0x00, 0x00, 0x65, 0x9e, 0x40, - 0x61, 0x6a, 0xd8, 0x5e, + 0x61, 0x6a, 0xda, 0x5e, 0x08, 0x51, 0x20, 0x71, 0x02, 0x0b, 0xb2, 0x78, 0x00, 0x65, 0xae, 0x40, @@ -106,7 +106,7 @@ static uint8_t seqprog[] = { 0x80, 0x3d, 0x7a, 0x00, 0x20, 0x6a, 0x16, 0x00, 0x00, 0x65, 0xcc, 0x41, - 0x00, 0x65, 0xb2, 0x5e, + 0x00, 0x65, 0xb4, 0x5e, 0x00, 0x65, 0x12, 0x40, 0x20, 0x11, 0xd2, 0x68, 0x20, 0x6a, 0x18, 0x00, @@ -140,27 +140,27 @@ static uint8_t seqprog[] = { 0x80, 0x0b, 0xc4, 0x79, 0x12, 0x01, 0x02, 0x00, 0x01, 0xab, 0xac, 0x30, - 0xe4, 0x6a, 0x6e, 0x5d, + 0xe4, 0x6a, 0x70, 0x5d, 0x40, 0x6a, 0x16, 0x00, - 0x80, 0x3e, 0x84, 0x5d, + 0x80, 0x3e, 0x86, 0x5d, 0x20, 0xb8, 0x18, 0x79, - 0x20, 0x6a, 0x84, 0x5d, - 0x00, 0xab, 0x84, 0x5d, + 0x20, 0x6a, 0x86, 0x5d, + 0x00, 0xab, 0x86, 0x5d, 0x01, 0xa9, 0x78, 0x30, 0x10, 0xb8, 0x20, 0x79, - 0xe4, 0x6a, 0x6e, 0x5d, + 0xe4, 0x6a, 0x70, 0x5d, 0x00, 0x65, 0xae, 0x40, 0x10, 0x03, 0x3c, 0x69, 0x08, 0x3c, 0x5a, 0x69, 0x04, 0x3c, 0x92, 0x69, 0x02, 0x3c, 0x98, 0x69, 0x01, 0x3c, 0x44, 0x79, - 0xff, 0x6a, 0x70, 0x00, + 0xff, 0x6a, 0xa6, 0x00, 0x00, 0x65, 0xa4, 0x59, - 0x00, 0x6a, 0xc0, 0x5e, - 0xff, 0x38, 0x30, 0x71, + 0x00, 0x6a, 0xc2, 0x5e, + 0xff, 0x53, 0x30, 0x71, 0x0d, 0x6a, 0x76, 0x00, - 0x00, 0x38, 0x12, 0x5e, + 0x00, 0x53, 0x14, 0x5e, 0x00, 0x65, 0xea, 0x58, 0x12, 0x01, 0x02, 0x00, 0x00, 0x65, 0x18, 0x41, @@ -168,10 +168,10 @@ static uint8_t seqprog[] = { 0x00, 0x65, 0xf2, 0x58, 0xfd, 0x57, 0xae, 0x08, 0x00, 0x65, 0xae, 0x40, - 0xe4, 0x6a, 0x6e, 0x5d, + 0xe4, 0x6a, 0x70, 0x5d, 0x20, 0x3c, 0x4a, 0x79, - 0x02, 0x6a, 0x84, 0x5d, - 0x04, 0x6a, 0x84, 0x5d, + 0x02, 0x6a, 0x86, 0x5d, + 0x04, 0x6a, 0x86, 0x5d, 0x01, 0x03, 0x4c, 0x69, 0xf7, 0x11, 0x22, 0x08, 0xff, 0x6a, 0x24, 0x08, @@ -182,13 +182,13 @@ static uint8_t seqprog[] = { 0x80, 0x86, 0xc8, 0x08, 0x01, 0x4f, 0xc8, 0x30, 0x00, 0x50, 0x6c, 0x61, - 0xc4, 0x6a, 0x6e, 0x5d, + 0xc4, 0x6a, 0x70, 0x5d, 0x40, 0x3c, 0x68, 0x79, - 0x28, 0x6a, 0x84, 0x5d, + 0x28, 0x6a, 0x86, 0x5d, 0x00, 0x65, 0x4c, 0x41, - 0x08, 0x6a, 0x84, 0x5d, + 0x08, 0x6a, 0x86, 0x5d, 0x00, 0x65, 0x4c, 0x41, - 0x84, 0x6a, 0x6e, 0x5d, + 0x84, 0x6a, 0x70, 0x5d, 0x00, 0x65, 0xf2, 0x58, 0x01, 0x66, 0xc8, 0x30, 0x01, 0x64, 0xd8, 0x31, @@ -208,16 +208,16 @@ static uint8_t seqprog[] = { 0xf7, 0x3c, 0x78, 0x08, 0x00, 0x65, 0x20, 0x41, 0x40, 0xaa, 0x7e, 0x10, - 0x04, 0xaa, 0x6e, 0x5d, - 0x00, 0x65, 0x56, 0x42, - 0xc4, 0x6a, 0x6e, 0x5d, + 0x04, 0xaa, 0x70, 0x5d, + 0x00, 0x65, 0x58, 0x42, + 0xc4, 0x6a, 0x70, 0x5d, 0xc0, 0x6a, 0x7e, 0x00, - 0x00, 0xa8, 0x84, 0x5d, + 0x00, 0xa8, 0x86, 0x5d, 0xe4, 0x6a, 0x06, 0x00, - 0x00, 0x6a, 0x84, 0x5d, + 0x00, 0x6a, 0x86, 0x5d, 0x00, 0x65, 0x4c, 0x41, 0x10, 0x3c, 0xa8, 0x69, - 0x00, 0xbb, 0x8a, 0x44, + 0x00, 0xbb, 0x8c, 0x44, 0x18, 0x6a, 0xda, 0x01, 0x01, 0x69, 0xd8, 0x31, 0x1c, 0x6a, 0xd0, 0x01, @@ -227,31 +227,32 @@ static uint8_t seqprog[] = { 0x01, 0x93, 0x26, 0x01, 0x03, 0x6a, 0x2a, 0x01, 0x01, 0x69, 0x32, 0x31, - 0x1c, 0x6a, 0xe0, 0x5d, + 0x1c, 0x6a, 0xe2, 0x5d, 0x0a, 0x93, 0x26, 0x01, - 0x00, 0x65, 0xa8, 0x5e, + 0x00, 0x65, 0xaa, 0x5e, 0x01, 0x50, 0xa0, 0x18, 0x02, 0x6a, 0x22, 0x05, 0x1a, 0x01, 0x02, 0x00, 0x80, 0x6a, 0x74, 0x00, 0x40, 0x6a, 0x78, 0x00, 0x40, 0x6a, 0x16, 0x00, - 0x00, 0x65, 0xd8, 0x5d, + 0x00, 0x65, 0xda, 0x5d, 0x01, 0x3f, 0xc8, 0x30, - 0xbf, 0x64, 0x56, 0x7a, - 0x80, 0x64, 0x9e, 0x73, - 0xa0, 0x64, 0x00, 0x74, - 0xc0, 0x64, 0xf4, 0x73, - 0xe0, 0x64, 0x30, 0x74, - 0x01, 0x6a, 0xd8, 0x5e, + 0xbf, 0x64, 0x58, 0x7a, + 0x80, 0x64, 0xa0, 0x73, + 0xa0, 0x64, 0x02, 0x74, + 0xc0, 0x64, 0xf6, 0x73, + 0xe0, 0x64, 0x32, 0x74, + 0x01, 0x6a, 0xda, 0x5e, 0x00, 0x65, 0xcc, 0x41, 0xf7, 0x11, 0x22, 0x08, 0x01, 0x06, 0xd4, 0x30, 0xff, 0x6a, 0x24, 0x08, 0xf7, 0x01, 0x02, 0x08, - 0x09, 0x0c, 0xe6, 0x79, + 0xc0, 0x6a, 0x78, 0x00, + 0x09, 0x0c, 0xe8, 0x79, 0x08, 0x0c, 0x04, 0x68, - 0xb1, 0x6a, 0xd8, 0x5e, + 0xb1, 0x6a, 0xda, 0x5e, 0xff, 0x6a, 0x26, 0x09, 0x12, 0x01, 0x02, 0x00, 0x02, 0x6a, 0x08, 0x30, @@ -264,29 +265,29 @@ static uint8_t seqprog[] = { 0x00, 0xa5, 0x4a, 0x21, 0x00, 0xa6, 0x4c, 0x21, 0x00, 0xa7, 0x4e, 0x25, - 0x08, 0xeb, 0xdc, 0x7e, - 0x80, 0xeb, 0x06, 0x7a, + 0x08, 0xeb, 0xde, 0x7e, + 0x80, 0xeb, 0x08, 0x7a, 0xff, 0x6a, 0xd6, 0x09, - 0x08, 0xeb, 0x0a, 0x6a, + 0x08, 0xeb, 0x0c, 0x6a, 0xff, 0x6a, 0xd4, 0x0c, - 0x80, 0xa3, 0xdc, 0x6e, - 0x88, 0xeb, 0x20, 0x72, - 0x08, 0xeb, 0xdc, 0x6e, - 0x04, 0xea, 0x24, 0xe2, - 0x08, 0xee, 0xdc, 0x6e, + 0x80, 0xa3, 0xde, 0x6e, + 0x88, 0xeb, 0x22, 0x72, + 0x08, 0xeb, 0xde, 0x6e, + 0x04, 0xea, 0x26, 0xe2, + 0x08, 0xee, 0xde, 0x6e, 0x04, 0x6a, 0xd0, 0x81, 0x05, 0xa4, 0xc0, 0x89, 0x03, 0xa5, 0xc2, 0x31, 0x09, 0x6a, 0xd6, 0x05, - 0x00, 0x65, 0x08, 0x5a, + 0x00, 0x65, 0x0a, 0x5a, 0x06, 0xa4, 0xd4, 0x89, - 0x80, 0x94, 0xdc, 0x7e, + 0x80, 0x94, 0xde, 0x7e, 0x07, 0xe9, 0x10, 0x31, 0x01, 0xe9, 0x46, 0x31, - 0x00, 0xa3, 0xba, 0x5e, - 0x00, 0x65, 0xfa, 0x59, + 0x00, 0xa3, 0xbc, 0x5e, + 0x00, 0x65, 0xfc, 0x59, 0x01, 0xa4, 0xca, 0x30, - 0x80, 0xa3, 0x34, 0x7a, + 0x80, 0xa3, 0x36, 0x7a, 0x02, 0x65, 0xca, 0x00, 0x01, 0x65, 0xf8, 0x31, 0x80, 0x93, 0x26, 0x01, @@ -294,162 +295,162 @@ static uint8_t seqprog[] = { 0x01, 0x8c, 0xc8, 0x30, 0x00, 0x88, 0xc8, 0x18, 0x02, 0x64, 0xc8, 0x88, - 0xff, 0x64, 0xdc, 0x7e, - 0xff, 0x8d, 0x4a, 0x6a, - 0xff, 0x8e, 0x4a, 0x6a, + 0xff, 0x64, 0xde, 0x7e, + 0xff, 0x8d, 0x4c, 0x6a, + 0xff, 0x8e, 0x4c, 0x6a, 0x03, 0x8c, 0xd4, 0x98, - 0x00, 0x65, 0xdc, 0x56, + 0x00, 0x65, 0xde, 0x56, 0x01, 0x64, 0x70, 0x30, 0xff, 0x64, 0xc8, 0x10, 0x01, 0x64, 0xc8, 0x18, 0x00, 0x8c, 0x18, 0x19, 0xff, 0x8d, 0x1a, 0x21, 0xff, 0x8e, 0x1c, 0x25, - 0xc0, 0x3c, 0x5a, 0x7a, - 0x21, 0x6a, 0xd8, 0x5e, + 0xc0, 0x3c, 0x5c, 0x7a, + 0x21, 0x6a, 0xda, 0x5e, 0xa8, 0x6a, 0x76, 0x00, 0x79, 0x6a, 0x76, 0x00, - 0x40, 0x3f, 0x62, 0x6a, + 0x40, 0x3f, 0x64, 0x6a, 0x04, 0x3b, 0x76, 0x00, 0x04, 0x6a, 0xd4, 0x81, - 0x20, 0x3c, 0x6a, 0x7a, - 0x51, 0x6a, 0xd8, 0x5e, - 0x00, 0x65, 0x82, 0x42, + 0x20, 0x3c, 0x6c, 0x7a, + 0x51, 0x6a, 0xda, 0x5e, + 0x00, 0x65, 0x84, 0x42, 0x20, 0x3c, 0x78, 0x00, - 0x00, 0xb3, 0xba, 0x5e, + 0x00, 0xb3, 0xbc, 0x5e, 0x07, 0xac, 0x10, 0x31, 0x05, 0xb3, 0x46, 0x31, 0x88, 0x6a, 0xcc, 0x00, - 0xac, 0x6a, 0xee, 0x5d, + 0xac, 0x6a, 0xf0, 0x5d, 0xa3, 0x6a, 0xcc, 0x00, - 0xb3, 0x6a, 0xf2, 0x5d, - 0x00, 0x65, 0x3a, 0x5a, + 0xb3, 0x6a, 0xf4, 0x5d, + 0x00, 0x65, 0x3c, 0x5a, 0xfd, 0xa4, 0x48, 0x09, 0x03, 0x8c, 0x10, 0x30, - 0x00, 0x65, 0xe6, 0x5d, - 0x01, 0xa4, 0x94, 0x7a, + 0x00, 0x65, 0xe8, 0x5d, + 0x01, 0xa4, 0x96, 0x7a, 0x04, 0x3b, 0x76, 0x08, 0x01, 0x3b, 0x26, 0x31, 0x80, 0x02, 0x04, 0x00, - 0x10, 0x0c, 0x8a, 0x7a, - 0x03, 0x9e, 0x8c, 0x6a, + 0x10, 0x0c, 0x8c, 0x7a, + 0x03, 0x9e, 0x8e, 0x6a, 0x7f, 0x02, 0x04, 0x08, - 0x91, 0x6a, 0xd8, 0x5e, + 0x91, 0x6a, 0xda, 0x5e, 0x00, 0x65, 0xcc, 0x41, 0x01, 0xa4, 0xca, 0x30, - 0x80, 0xa3, 0x9a, 0x7a, + 0x80, 0xa3, 0x9c, 0x7a, 0x02, 0x65, 0xca, 0x00, 0x01, 0x65, 0xf8, 0x31, 0x01, 0x3b, 0x26, 0x31, - 0x00, 0x65, 0x0e, 0x5a, - 0x01, 0xfc, 0xa8, 0x6a, - 0x80, 0x0b, 0x9e, 0x6a, - 0x10, 0x0c, 0x9e, 0x7a, - 0x20, 0x93, 0x9e, 0x6a, + 0x00, 0x65, 0x10, 0x5a, + 0x01, 0xfc, 0xaa, 0x6a, + 0x80, 0x0b, 0xa0, 0x6a, + 0x10, 0x0c, 0xa0, 0x7a, + 0x20, 0x93, 0xa0, 0x6a, 0x02, 0x93, 0x26, 0x01, - 0x02, 0xfc, 0xb2, 0x7a, - 0x40, 0x0d, 0xc6, 0x6a, + 0x02, 0xfc, 0xb4, 0x7a, + 0x40, 0x0d, 0xc8, 0x6a, 0x01, 0xa4, 0x48, 0x01, - 0x00, 0x65, 0xc6, 0x42, - 0x40, 0x0d, 0xb8, 0x6a, - 0x00, 0x65, 0x0e, 0x5a, - 0x00, 0x65, 0xaa, 0x42, - 0x80, 0xfc, 0xc2, 0x7a, - 0x80, 0xa4, 0xc2, 0x6a, + 0x00, 0x65, 0xc8, 0x42, + 0x40, 0x0d, 0xba, 0x6a, + 0x00, 0x65, 0x10, 0x5a, + 0x00, 0x65, 0xac, 0x42, + 0x80, 0xfc, 0xc4, 0x7a, + 0x80, 0xa4, 0xc4, 0x6a, 0xff, 0xa5, 0x4a, 0x19, 0xff, 0xa6, 0x4c, 0x21, 0xff, 0xa7, 0x4e, 0x21, 0xf8, 0xfc, 0x48, 0x09, 0x7f, 0xa3, 0x46, 0x09, - 0x04, 0x3b, 0xe2, 0x6a, + 0x04, 0x3b, 0xe4, 0x6a, 0x02, 0x93, 0x26, 0x01, - 0x01, 0x94, 0xc8, 0x7a, - 0x01, 0x94, 0xc8, 0x7a, - 0x01, 0x94, 0xc8, 0x7a, - 0x01, 0x94, 0xc8, 0x7a, - 0x01, 0x94, 0xc8, 0x7a, - 0x01, 0xa4, 0xe0, 0x7a, - 0x01, 0xfc, 0xd6, 0x7a, - 0x01, 0x94, 0xe2, 0x6a, - 0x01, 0x94, 0xe2, 0x6a, - 0x01, 0x94, 0xe2, 0x6a, - 0x00, 0x65, 0x82, 0x42, - 0x01, 0x94, 0xe0, 0x7a, - 0x10, 0x94, 0xe2, 0x6a, + 0x01, 0x94, 0xca, 0x7a, + 0x01, 0x94, 0xca, 0x7a, + 0x01, 0x94, 0xca, 0x7a, + 0x01, 0x94, 0xca, 0x7a, + 0x01, 0x94, 0xca, 0x7a, + 0x01, 0xa4, 0xe2, 0x7a, + 0x01, 0xfc, 0xd8, 0x7a, + 0x01, 0x94, 0xe4, 0x6a, + 0x01, 0x94, 0xe4, 0x6a, + 0x01, 0x94, 0xe4, 0x6a, + 0x00, 0x65, 0x84, 0x42, + 0x01, 0x94, 0xe2, 0x7a, + 0x10, 0x94, 0xe4, 0x6a, 0xd7, 0x93, 0x26, 0x09, - 0x28, 0x93, 0xe6, 0x6a, + 0x28, 0x93, 0xe8, 0x6a, 0x01, 0x85, 0x0a, 0x01, - 0x02, 0xfc, 0xee, 0x6a, + 0x02, 0xfc, 0xf0, 0x6a, 0x01, 0x14, 0x46, 0x31, 0xff, 0x6a, 0x10, 0x09, 0xfe, 0x85, 0x0a, 0x09, - 0xff, 0x38, 0xfc, 0x6a, - 0x80, 0xa3, 0xfc, 0x7a, - 0x80, 0x0b, 0xfa, 0x7a, - 0x04, 0x3b, 0xfc, 0x7a, + 0xff, 0x38, 0xfe, 0x6a, + 0x80, 0xa3, 0xfe, 0x7a, + 0x80, 0x0b, 0xfc, 0x7a, + 0x04, 0x3b, 0xfe, 0x7a, 0xbf, 0x3b, 0x76, 0x08, 0x01, 0x3b, 0x26, 0x31, - 0x00, 0x65, 0x0e, 0x5a, - 0x01, 0x0b, 0x0a, 0x6b, - 0x10, 0x0c, 0xfe, 0x7a, - 0x04, 0x93, 0x08, 0x6b, - 0x01, 0x94, 0x06, 0x7b, - 0x10, 0x94, 0x08, 0x6b, + 0x00, 0x65, 0x10, 0x5a, + 0x01, 0x0b, 0x0c, 0x6b, + 0x10, 0x0c, 0x00, 0x7b, + 0x04, 0x93, 0x0a, 0x6b, + 0x01, 0x94, 0x08, 0x7b, + 0x10, 0x94, 0x0a, 0x6b, 0xc7, 0x93, 0x26, 0x09, 0x01, 0x99, 0xd4, 0x30, - 0x38, 0x93, 0x0c, 0x6b, - 0xff, 0x08, 0x5a, 0x6b, - 0xff, 0x09, 0x5a, 0x6b, - 0xff, 0x0a, 0x5a, 0x6b, - 0xff, 0x38, 0x28, 0x7b, + 0x38, 0x93, 0x0e, 0x6b, + 0xff, 0x08, 0x5c, 0x6b, + 0xff, 0x09, 0x5c, 0x6b, + 0xff, 0x0a, 0x5c, 0x6b, + 0xff, 0x38, 0x2a, 0x7b, 0x04, 0x14, 0x10, 0x31, 0x01, 0x38, 0x18, 0x31, 0x02, 0x6a, 0x1a, 0x31, 0x88, 0x6a, 0xcc, 0x00, - 0x14, 0x6a, 0xf4, 0x5d, - 0x00, 0x38, 0xe0, 0x5d, + 0x14, 0x6a, 0xf6, 0x5d, + 0x00, 0x38, 0xe2, 0x5d, 0xff, 0x6a, 0x70, 0x08, - 0x00, 0x65, 0x54, 0x43, - 0x80, 0xa3, 0x2e, 0x7b, + 0x00, 0x65, 0x56, 0x43, + 0x80, 0xa3, 0x30, 0x7b, 0x01, 0xa4, 0x48, 0x01, - 0x00, 0x65, 0x5a, 0x43, - 0x08, 0xeb, 0x34, 0x7b, - 0x00, 0x65, 0x0e, 0x5a, - 0x08, 0xeb, 0x30, 0x6b, + 0x00, 0x65, 0x5c, 0x43, + 0x08, 0xeb, 0x36, 0x7b, + 0x00, 0x65, 0x10, 0x5a, + 0x08, 0xeb, 0x32, 0x6b, 0x07, 0xe9, 0x10, 0x31, 0x01, 0xe9, 0xca, 0x30, 0x01, 0x65, 0x46, 0x31, - 0x00, 0x6a, 0xba, 0x5e, + 0x00, 0x6a, 0xbc, 0x5e, 0x88, 0x6a, 0xcc, 0x00, - 0xa4, 0x6a, 0xf4, 0x5d, - 0x08, 0x6a, 0xe0, 0x5d, + 0xa4, 0x6a, 0xf6, 0x5d, + 0x08, 0x6a, 0xe2, 0x5d, 0x0d, 0x93, 0x26, 0x01, - 0x00, 0x65, 0xa8, 0x5e, + 0x00, 0x65, 0xaa, 0x5e, 0x88, 0x6a, 0xcc, 0x00, - 0x00, 0x65, 0x8a, 0x5e, + 0x00, 0x65, 0x8c, 0x5e, 0x01, 0x99, 0x46, 0x31, - 0x00, 0xa3, 0xba, 0x5e, + 0x00, 0xa3, 0xbc, 0x5e, 0x01, 0x88, 0x10, 0x31, - 0x00, 0x65, 0x3a, 0x5a, - 0x00, 0x65, 0xfa, 0x59, + 0x00, 0x65, 0x3c, 0x5a, + 0x00, 0x65, 0xfc, 0x59, 0x03, 0x8c, 0x10, 0x30, - 0x00, 0x65, 0xe6, 0x5d, - 0x80, 0x0b, 0x82, 0x6a, - 0x80, 0x0b, 0x62, 0x6b, - 0x01, 0x0c, 0x5c, 0x7b, - 0x10, 0x0c, 0x82, 0x7a, - 0x03, 0x9e, 0x82, 0x6a, - 0x00, 0x65, 0x04, 0x5a, - 0x00, 0x6a, 0xba, 0x5e, - 0x01, 0xa4, 0x82, 0x6b, - 0xff, 0x38, 0x78, 0x7b, + 0x00, 0x65, 0xe8, 0x5d, + 0x80, 0x0b, 0x84, 0x6a, + 0x80, 0x0b, 0x64, 0x6b, + 0x01, 0x0c, 0x5e, 0x7b, + 0x10, 0x0c, 0x84, 0x7a, + 0x03, 0x9e, 0x84, 0x6a, + 0x00, 0x65, 0x06, 0x5a, + 0x00, 0x6a, 0xbc, 0x5e, + 0x01, 0xa4, 0x84, 0x6b, + 0xff, 0x38, 0x7a, 0x7b, 0x01, 0x38, 0xc8, 0x30, 0x00, 0x08, 0x40, 0x19, 0xff, 0x6a, 0xc8, 0x08, 0x00, 0x09, 0x42, 0x21, 0x00, 0x0a, 0x44, 0x21, 0xff, 0x6a, 0x70, 0x08, - 0x00, 0x65, 0x7a, 0x43, + 0x00, 0x65, 0x7c, 0x43, 0x03, 0x08, 0x40, 0x31, 0x03, 0x08, 0x40, 0x31, 0x01, 0x08, 0x40, 0x31, @@ -461,16 +462,16 @@ static uint8_t seqprog[] = { 0x04, 0x3c, 0xcc, 0x79, 0xfb, 0x3c, 0x78, 0x08, 0x04, 0x93, 0x20, 0x79, - 0x01, 0x0c, 0x8e, 0x6b, + 0x01, 0x0c, 0x90, 0x6b, 0x80, 0xba, 0x20, 0x79, 0x80, 0x04, 0x20, 0x79, - 0xe4, 0x6a, 0x6e, 0x5d, - 0x23, 0x6a, 0x84, 0x5d, - 0x01, 0x6a, 0x84, 0x5d, + 0xe4, 0x6a, 0x70, 0x5d, + 0x23, 0x6a, 0x86, 0x5d, + 0x01, 0x6a, 0x86, 0x5d, 0x00, 0x65, 0x20, 0x41, 0x00, 0x65, 0xcc, 0x41, - 0x80, 0x3c, 0xa2, 0x7b, - 0x21, 0x6a, 0xd8, 0x5e, + 0x80, 0x3c, 0xa4, 0x7b, + 0x21, 0x6a, 0xda, 0x5e, 0x01, 0xbc, 0x18, 0x31, 0x02, 0x6a, 0x1a, 0x31, 0x02, 0x6a, 0xf8, 0x01, @@ -480,16 +481,16 @@ static uint8_t seqprog[] = { 0xff, 0x6a, 0x12, 0x08, 0xff, 0x6a, 0x14, 0x08, 0xf3, 0xbc, 0xd4, 0x18, - 0xa0, 0x6a, 0xc8, 0x53, + 0xa0, 0x6a, 0xca, 0x53, 0x04, 0xa0, 0x10, 0x31, 0xac, 0x6a, 0x26, 0x01, 0x04, 0xa0, 0x10, 0x31, 0x03, 0x08, 0x18, 0x31, 0x88, 0x6a, 0xcc, 0x00, - 0xa0, 0x6a, 0xf4, 0x5d, - 0x00, 0xbc, 0xe0, 0x5d, + 0xa0, 0x6a, 0xf6, 0x5d, + 0x00, 0xbc, 0xe2, 0x5d, 0x3d, 0x6a, 0x26, 0x01, - 0x00, 0x65, 0xe0, 0x43, + 0x00, 0x65, 0xe2, 0x43, 0xff, 0x6a, 0x10, 0x09, 0xa4, 0x6a, 0x26, 0x01, 0x0c, 0xa0, 0x32, 0x31, @@ -499,128 +500,128 @@ static uint8_t seqprog[] = { 0x36, 0x6a, 0x26, 0x01, 0x02, 0x93, 0x26, 0x01, 0x35, 0x6a, 0x26, 0x01, - 0x00, 0x65, 0x9c, 0x5e, - 0x00, 0x65, 0x9c, 0x5e, + 0x00, 0x65, 0x9e, 0x5e, + 0x00, 0x65, 0x9e, 0x5e, 0x02, 0x93, 0x26, 0x01, 0xbf, 0x3c, 0x78, 0x08, - 0x04, 0x0b, 0xe6, 0x6b, - 0x10, 0x0c, 0xe2, 0x7b, - 0x01, 0x03, 0xe6, 0x6b, - 0x20, 0x93, 0xe8, 0x6b, - 0x04, 0x0b, 0xee, 0x6b, + 0x04, 0x0b, 0xe8, 0x6b, + 0x10, 0x0c, 0xe4, 0x7b, + 0x01, 0x03, 0xe8, 0x6b, + 0x20, 0x93, 0xea, 0x6b, + 0x04, 0x0b, 0xf0, 0x6b, 0x40, 0x3c, 0x78, 0x00, 0xc7, 0x93, 0x26, 0x09, - 0x38, 0x93, 0xf0, 0x6b, + 0x38, 0x93, 0xf2, 0x6b, 0x00, 0x65, 0xcc, 0x41, - 0x80, 0x3c, 0x56, 0x6c, + 0x80, 0x3c, 0x58, 0x6c, 0x01, 0x06, 0x50, 0x31, 0x80, 0xb8, 0x70, 0x01, 0x00, 0x65, 0xcc, 0x41, 0x10, 0x3f, 0x06, 0x00, 0x10, 0x6a, 0x06, 0x00, 0x01, 0x3a, 0xca, 0x30, - 0x80, 0x65, 0x1c, 0x64, - 0x10, 0xb8, 0x40, 0x6c, + 0x80, 0x65, 0x1e, 0x64, + 0x10, 0xb8, 0x42, 0x6c, 0xc0, 0x3e, 0xca, 0x00, - 0x40, 0xb8, 0x0c, 0x6c, + 0x40, 0xb8, 0x0e, 0x6c, 0xbf, 0x65, 0xca, 0x08, - 0x20, 0xb8, 0x20, 0x7c, + 0x20, 0xb8, 0x22, 0x7c, 0x01, 0x65, 0x0c, 0x30, - 0x00, 0x65, 0xd8, 0x5d, - 0xa0, 0x3f, 0x28, 0x64, + 0x00, 0x65, 0xda, 0x5d, + 0xa0, 0x3f, 0x2a, 0x64, 0x23, 0xb8, 0x0c, 0x08, - 0x00, 0x65, 0xd8, 0x5d, - 0xa0, 0x3f, 0x28, 0x64, - 0x00, 0xbb, 0x20, 0x44, - 0xff, 0x65, 0x20, 0x64, - 0x00, 0x65, 0x40, 0x44, + 0x00, 0x65, 0xda, 0x5d, + 0xa0, 0x3f, 0x2a, 0x64, + 0x00, 0xbb, 0x22, 0x44, + 0xff, 0x65, 0x22, 0x64, + 0x00, 0x65, 0x42, 0x44, 0x40, 0x6a, 0x18, 0x00, 0x01, 0x65, 0x0c, 0x30, - 0x00, 0x65, 0xd8, 0x5d, - 0xa0, 0x3f, 0xfc, 0x73, + 0x00, 0x65, 0xda, 0x5d, + 0xa0, 0x3f, 0xfe, 0x73, 0x40, 0x6a, 0x18, 0x00, 0x01, 0x3a, 0xa6, 0x30, 0x08, 0x6a, 0x74, 0x00, 0x00, 0x65, 0xcc, 0x41, - 0x64, 0x6a, 0x68, 0x5d, - 0x80, 0x64, 0xd8, 0x6c, - 0x04, 0x64, 0x9a, 0x74, - 0x02, 0x64, 0xaa, 0x74, - 0x00, 0x6a, 0x60, 0x74, - 0x03, 0x64, 0xc8, 0x74, - 0x23, 0x64, 0x48, 0x74, - 0x08, 0x64, 0x5c, 0x74, - 0x61, 0x6a, 0xd8, 0x5e, - 0x00, 0x65, 0xd8, 0x5d, + 0x64, 0x6a, 0x6a, 0x5d, + 0x80, 0x64, 0xda, 0x6c, + 0x04, 0x64, 0x9c, 0x74, + 0x02, 0x64, 0xac, 0x74, + 0x00, 0x6a, 0x62, 0x74, + 0x03, 0x64, 0xca, 0x74, + 0x23, 0x64, 0x4a, 0x74, + 0x08, 0x64, 0x5e, 0x74, + 0x61, 0x6a, 0xda, 0x5e, + 0x00, 0x65, 0xda, 0x5d, 0x08, 0x51, 0xce, 0x71, - 0x00, 0x65, 0x40, 0x44, - 0x80, 0x04, 0x5a, 0x7c, - 0x51, 0x6a, 0x5e, 0x5d, - 0x01, 0x51, 0x5a, 0x64, - 0x01, 0xa4, 0x52, 0x7c, - 0x80, 0xba, 0x5c, 0x6c, - 0x41, 0x6a, 0xd8, 0x5e, - 0x00, 0x65, 0x5c, 0x44, - 0x21, 0x6a, 0xd8, 0x5e, - 0x00, 0x65, 0x5c, 0x44, - 0x07, 0x6a, 0x54, 0x5d, + 0x00, 0x65, 0x42, 0x44, + 0x80, 0x04, 0x5c, 0x7c, + 0x51, 0x6a, 0x60, 0x5d, + 0x01, 0x51, 0x5c, 0x64, + 0x01, 0xa4, 0x54, 0x7c, + 0x80, 0xba, 0x5e, 0x6c, + 0x41, 0x6a, 0xda, 0x5e, + 0x00, 0x65, 0x5e, 0x44, + 0x21, 0x6a, 0xda, 0x5e, + 0x00, 0x65, 0x5e, 0x44, + 0x07, 0x6a, 0x56, 0x5d, 0x01, 0x06, 0xd4, 0x30, 0x00, 0x65, 0xcc, 0x41, - 0x80, 0xb8, 0x56, 0x7c, - 0xc0, 0x3c, 0x6a, 0x7c, - 0x80, 0x3c, 0x56, 0x6c, - 0xff, 0xa8, 0x6a, 0x6c, - 0x40, 0x3c, 0x56, 0x6c, - 0x10, 0xb8, 0x6e, 0x7c, - 0xa1, 0x6a, 0xd8, 0x5e, - 0x01, 0xb4, 0x74, 0x6c, - 0x02, 0xb4, 0x76, 0x6c, - 0x01, 0xa4, 0x76, 0x7c, - 0xff, 0xa8, 0x86, 0x7c, + 0x80, 0xb8, 0x58, 0x7c, + 0xc0, 0x3c, 0x6c, 0x7c, + 0x80, 0x3c, 0x58, 0x6c, + 0xff, 0xa8, 0x6c, 0x6c, + 0x40, 0x3c, 0x58, 0x6c, + 0x10, 0xb8, 0x70, 0x7c, + 0xa1, 0x6a, 0xda, 0x5e, + 0x01, 0xb4, 0x76, 0x6c, + 0x02, 0xb4, 0x78, 0x6c, + 0x01, 0xa4, 0x78, 0x7c, + 0xff, 0xa8, 0x88, 0x7c, 0x04, 0xb4, 0x68, 0x01, 0x01, 0x6a, 0x76, 0x00, - 0x00, 0xbb, 0x12, 0x5e, - 0xff, 0xa8, 0x86, 0x7c, - 0x71, 0x6a, 0xd8, 0x5e, - 0x40, 0x51, 0x86, 0x64, - 0x00, 0x65, 0xb2, 0x5e, + 0x00, 0xbb, 0x14, 0x5e, + 0xff, 0xa8, 0x88, 0x7c, + 0x71, 0x6a, 0xda, 0x5e, + 0x40, 0x51, 0x88, 0x64, + 0x00, 0x65, 0xb4, 0x5e, 0x00, 0x65, 0xde, 0x41, - 0x00, 0xbb, 0x8a, 0x5c, + 0x00, 0xbb, 0x8c, 0x5c, 0x00, 0x65, 0xde, 0x41, - 0x00, 0x65, 0xb2, 0x5e, + 0x00, 0x65, 0xb4, 0x5e, 0x01, 0x65, 0xa2, 0x30, 0x01, 0xf8, 0xc8, 0x30, 0x01, 0x4e, 0xc8, 0x30, - 0x00, 0x6a, 0xb6, 0xdd, - 0x00, 0x51, 0xc8, 0x5d, + 0x00, 0x6a, 0xb8, 0xdd, + 0x00, 0x51, 0xca, 0x5d, 0x01, 0x4e, 0x9c, 0x18, 0x02, 0x6a, 0x22, 0x05, - 0xc0, 0x3c, 0x56, 0x6c, + 0xc0, 0x3c, 0x58, 0x6c, 0x04, 0xb8, 0x70, 0x01, - 0x00, 0x65, 0xd4, 0x5e, + 0x00, 0x65, 0xd6, 0x5e, 0x20, 0xb8, 0xde, 0x69, 0x01, 0xbb, 0xa2, 0x30, 0x3f, 0xba, 0x7c, 0x08, - 0x00, 0xb9, 0xce, 0x5c, + 0x00, 0xb9, 0xd0, 0x5c, 0x00, 0x65, 0xde, 0x41, 0x01, 0x06, 0xd4, 0x30, 0x20, 0x3c, 0xcc, 0x79, - 0x20, 0x3c, 0x5c, 0x7c, - 0x01, 0xa4, 0xb8, 0x7c, + 0x20, 0x3c, 0x5e, 0x7c, + 0x01, 0xa4, 0xba, 0x7c, 0x01, 0xb4, 0x68, 0x01, 0x00, 0x65, 0xcc, 0x41, - 0x00, 0x65, 0x5c, 0x44, + 0x00, 0x65, 0x5e, 0x44, 0x04, 0x14, 0x58, 0x31, 0x01, 0x06, 0xd4, 0x30, 0x08, 0xa0, 0x60, 0x31, 0xac, 0x6a, 0xcc, 0x00, - 0x14, 0x6a, 0xf4, 0x5d, + 0x14, 0x6a, 0xf6, 0x5d, 0x01, 0x06, 0xd4, 0x30, - 0xa0, 0x6a, 0xec, 0x5d, + 0xa0, 0x6a, 0xee, 0x5d, 0x00, 0x65, 0xcc, 0x41, 0xdf, 0x3c, 0x78, 0x08, 0x12, 0x01, 0x02, 0x00, - 0x00, 0x65, 0x5c, 0x44, + 0x00, 0x65, 0x5e, 0x44, 0x4c, 0x65, 0xcc, 0x28, 0x01, 0x3e, 0x20, 0x31, 0xd0, 0x66, 0xcc, 0x18, @@ -631,102 +632,102 @@ static uint8_t seqprog[] = { 0xd0, 0x65, 0xca, 0x18, 0x01, 0x3e, 0x20, 0x31, 0x30, 0x65, 0xd4, 0x18, - 0x00, 0x65, 0xe6, 0x4c, + 0x00, 0x65, 0xe8, 0x4c, 0xe1, 0x6a, 0x22, 0x01, 0xff, 0x6a, 0xd4, 0x08, 0x20, 0x65, 0xd4, 0x18, - 0x00, 0x65, 0xee, 0x54, + 0x00, 0x65, 0xf0, 0x54, 0xe1, 0x6a, 0x22, 0x01, 0xff, 0x6a, 0xd4, 0x08, 0x20, 0x65, 0xca, 0x18, 0xe0, 0x65, 0xd4, 0x18, - 0x00, 0x65, 0xf8, 0x4c, + 0x00, 0x65, 0xfa, 0x4c, 0xe1, 0x6a, 0x22, 0x01, 0xff, 0x6a, 0xd4, 0x08, 0xd0, 0x65, 0xd4, 0x18, - 0x00, 0x65, 0x00, 0x55, + 0x00, 0x65, 0x02, 0x55, 0xe1, 0x6a, 0x22, 0x01, 0xff, 0x6a, 0xd4, 0x08, 0x01, 0x6c, 0xa2, 0x30, - 0xff, 0x51, 0x12, 0x75, - 0x00, 0x51, 0x8e, 0x5d, + 0xff, 0x51, 0x14, 0x75, + 0x00, 0x51, 0x90, 0x5d, 0x01, 0x51, 0x20, 0x31, - 0x00, 0x65, 0x34, 0x45, + 0x00, 0x65, 0x36, 0x45, 0x3f, 0xba, 0xc8, 0x08, - 0x00, 0x3e, 0x34, 0x75, - 0x00, 0x65, 0xb0, 0x5e, + 0x00, 0x3e, 0x36, 0x75, + 0x00, 0x65, 0xb2, 0x5e, 0x80, 0x3c, 0x78, 0x00, 0x01, 0x06, 0xd4, 0x30, - 0x00, 0x65, 0xd8, 0x5d, + 0x00, 0x65, 0xda, 0x5d, 0x01, 0x3c, 0x78, 0x00, - 0xe0, 0x3f, 0x50, 0x65, + 0xe0, 0x3f, 0x52, 0x65, 0x02, 0x3c, 0x78, 0x00, - 0x20, 0x12, 0x50, 0x65, - 0x51, 0x6a, 0x5e, 0x5d, - 0x00, 0x51, 0x8e, 0x5d, - 0x51, 0x6a, 0x5e, 0x5d, + 0x20, 0x12, 0x52, 0x65, + 0x51, 0x6a, 0x60, 0x5d, + 0x00, 0x51, 0x90, 0x5d, + 0x51, 0x6a, 0x60, 0x5d, 0x01, 0x51, 0x20, 0x31, 0x04, 0x3c, 0x78, 0x00, 0x01, 0xb9, 0xc8, 0x30, - 0x00, 0x3d, 0x4e, 0x65, + 0x00, 0x3d, 0x50, 0x65, 0x08, 0x3c, 0x78, 0x00, 0x3f, 0xba, 0xc8, 0x08, - 0x00, 0x3e, 0x4e, 0x65, + 0x00, 0x3e, 0x50, 0x65, 0x10, 0x3c, 0x78, 0x00, - 0x04, 0xb8, 0x4e, 0x7d, + 0x04, 0xb8, 0x50, 0x7d, 0xfb, 0xb8, 0x70, 0x09, - 0x20, 0xb8, 0x44, 0x6d, + 0x20, 0xb8, 0x46, 0x6d, 0x01, 0x90, 0xc8, 0x30, 0xff, 0x6a, 0xa2, 0x00, - 0x00, 0x3d, 0xce, 0x5c, + 0x00, 0x3d, 0xd0, 0x5c, 0x01, 0x64, 0x20, 0x31, 0xff, 0x6a, 0x78, 0x08, 0x00, 0x65, 0xea, 0x58, - 0x10, 0xb8, 0x5c, 0x7c, - 0xff, 0x6a, 0x54, 0x5d, - 0x00, 0x65, 0x5c, 0x44, - 0x00, 0x65, 0xb0, 0x5e, - 0x31, 0x6a, 0xd8, 0x5e, - 0x00, 0x65, 0x5c, 0x44, + 0x10, 0xb8, 0x5e, 0x7c, + 0xff, 0x6a, 0x56, 0x5d, + 0x00, 0x65, 0x5e, 0x44, + 0x00, 0x65, 0xb2, 0x5e, + 0x31, 0x6a, 0xda, 0x5e, + 0x00, 0x65, 0x5e, 0x44, 0x10, 0x3f, 0x06, 0x00, 0x10, 0x6a, 0x06, 0x00, 0x01, 0x65, 0x74, 0x34, - 0x81, 0x6a, 0xd8, 0x5e, - 0x00, 0x65, 0x60, 0x45, + 0x81, 0x6a, 0xda, 0x5e, + 0x00, 0x65, 0x62, 0x45, 0x01, 0x06, 0xd4, 0x30, - 0x01, 0x0c, 0x60, 0x7d, - 0x04, 0x0c, 0x5a, 0x6d, + 0x01, 0x0c, 0x62, 0x7d, + 0x04, 0x0c, 0x5c, 0x6d, 0xe0, 0x03, 0x7e, 0x08, 0xe0, 0x3f, 0xcc, 0x61, 0x01, 0x65, 0xcc, 0x30, 0x01, 0x12, 0xda, 0x34, 0x01, 0x06, 0xd4, 0x34, - 0x01, 0x03, 0x6e, 0x6d, + 0x01, 0x03, 0x70, 0x6d, 0x40, 0x03, 0xcc, 0x08, 0x01, 0x65, 0x06, 0x30, 0x40, 0x65, 0xc8, 0x08, - 0x00, 0x66, 0x7c, 0x75, - 0x40, 0x65, 0x7c, 0x7d, - 0x00, 0x65, 0x7c, 0x5d, + 0x00, 0x66, 0x7e, 0x75, + 0x40, 0x65, 0x7e, 0x7d, + 0x00, 0x65, 0x7e, 0x5d, 0xff, 0x6a, 0xd4, 0x08, 0xff, 0x6a, 0xd4, 0x08, 0xff, 0x6a, 0xd4, 0x08, 0xff, 0x6a, 0xd4, 0x0c, 0x08, 0x01, 0x02, 0x00, - 0x02, 0x0b, 0x86, 0x7d, + 0x02, 0x0b, 0x88, 0x7d, 0x01, 0x65, 0x0c, 0x30, - 0x02, 0x0b, 0x8a, 0x7d, + 0x02, 0x0b, 0x8c, 0x7d, 0xf7, 0x01, 0x02, 0x0c, 0x01, 0x65, 0xc8, 0x30, - 0xff, 0x41, 0xae, 0x75, + 0xff, 0x41, 0xb0, 0x75, 0x01, 0x41, 0x20, 0x31, 0xff, 0x6a, 0xa4, 0x00, - 0x00, 0x65, 0x9e, 0x45, - 0xff, 0xbf, 0xae, 0x75, + 0x00, 0x65, 0xa0, 0x45, + 0xff, 0xbf, 0xb0, 0x75, 0x01, 0x90, 0xa4, 0x30, 0x01, 0xbf, 0x20, 0x31, - 0x00, 0xbb, 0x98, 0x65, - 0xff, 0x52, 0xac, 0x75, + 0x00, 0xbb, 0x9a, 0x65, + 0xff, 0x52, 0xae, 0x75, 0x01, 0xbf, 0xcc, 0x30, 0x01, 0x90, 0xca, 0x30, 0x01, 0x52, 0x20, 0x31, @@ -734,28 +735,28 @@ static uint8_t seqprog[] = { 0x01, 0x65, 0x20, 0x35, 0x01, 0xbf, 0x82, 0x34, 0x01, 0x64, 0xa2, 0x30, - 0x00, 0x6a, 0xc0, 0x5e, + 0x00, 0x6a, 0xc2, 0x5e, 0x0d, 0x6a, 0x76, 0x00, - 0x00, 0x51, 0x12, 0x46, + 0x00, 0x51, 0x14, 0x46, 0x01, 0x65, 0xa4, 0x30, 0xe0, 0x6a, 0xcc, 0x00, - 0x48, 0x6a, 0x06, 0x5e, + 0x48, 0x6a, 0x08, 0x5e, 0x01, 0x6a, 0xd0, 0x01, 0x01, 0x6a, 0xdc, 0x05, 0x88, 0x6a, 0xcc, 0x00, - 0x48, 0x6a, 0x06, 0x5e, - 0x01, 0x6a, 0xe0, 0x5d, + 0x48, 0x6a, 0x08, 0x5e, + 0x01, 0x6a, 0xe2, 0x5d, 0x01, 0x6a, 0x26, 0x05, 0x01, 0x65, 0xd8, 0x31, 0x09, 0xee, 0xdc, 0x01, - 0x80, 0xee, 0xcc, 0x7d, + 0x80, 0xee, 0xce, 0x7d, 0xff, 0x6a, 0xdc, 0x0d, 0x01, 0x65, 0x32, 0x31, 0x0a, 0x93, 0x26, 0x01, - 0x00, 0x65, 0xa8, 0x46, - 0x81, 0x6a, 0xd8, 0x5e, - 0x01, 0x0c, 0xd8, 0x7d, - 0x04, 0x0c, 0xd6, 0x6d, + 0x00, 0x65, 0xaa, 0x46, + 0x81, 0x6a, 0xda, 0x5e, + 0x01, 0x0c, 0xda, 0x7d, + 0x04, 0x0c, 0xd8, 0x6d, 0xe0, 0x03, 0x06, 0x08, 0xe0, 0x03, 0x7e, 0x0c, 0x01, 0x65, 0x18, 0x31, @@ -774,7 +775,7 @@ static uint8_t seqprog[] = { 0x01, 0x6c, 0xda, 0x34, 0x3d, 0x64, 0xa4, 0x28, 0x55, 0x64, 0xc8, 0x28, - 0x00, 0x65, 0x06, 0x46, + 0x00, 0x65, 0x08, 0x46, 0x2e, 0x64, 0xa4, 0x28, 0x66, 0x64, 0xc8, 0x28, 0x00, 0x6c, 0xda, 0x18, @@ -785,63 +786,63 @@ static uint8_t seqprog[] = { 0x00, 0x6c, 0xda, 0x24, 0x01, 0x65, 0xc8, 0x30, 0xe0, 0x6a, 0xcc, 0x00, - 0x44, 0x6a, 0x02, 0x5e, + 0x44, 0x6a, 0x04, 0x5e, 0x01, 0x90, 0xe2, 0x31, - 0x04, 0x3b, 0x26, 0x7e, + 0x04, 0x3b, 0x28, 0x7e, 0x30, 0x6a, 0xd0, 0x01, 0x20, 0x6a, 0xd0, 0x01, 0x1d, 0x6a, 0xdc, 0x01, - 0xdc, 0xee, 0x22, 0x66, - 0x00, 0x65, 0x3e, 0x46, + 0xdc, 0xee, 0x24, 0x66, + 0x00, 0x65, 0x40, 0x46, 0x20, 0x6a, 0xd0, 0x01, 0x01, 0x6a, 0xdc, 0x01, 0x20, 0xa0, 0xd8, 0x31, 0x09, 0xee, 0xdc, 0x01, - 0x80, 0xee, 0x2e, 0x7e, + 0x80, 0xee, 0x30, 0x7e, 0x11, 0x6a, 0xdc, 0x01, - 0x50, 0xee, 0x32, 0x66, + 0x50, 0xee, 0x34, 0x66, 0x20, 0x6a, 0xd0, 0x01, 0x09, 0x6a, 0xdc, 0x01, - 0x88, 0xee, 0x38, 0x66, + 0x88, 0xee, 0x3a, 0x66, 0x19, 0x6a, 0xdc, 0x01, - 0xd8, 0xee, 0x3c, 0x66, + 0xd8, 0xee, 0x3e, 0x66, 0xff, 0x6a, 0xdc, 0x09, - 0x18, 0xee, 0x40, 0x6e, + 0x18, 0xee, 0x42, 0x6e, 0xff, 0x6a, 0xd4, 0x0c, 0x88, 0x6a, 0xcc, 0x00, - 0x44, 0x6a, 0x02, 0x5e, - 0x20, 0x6a, 0xe0, 0x5d, + 0x44, 0x6a, 0x04, 0x5e, + 0x20, 0x6a, 0xe2, 0x5d, 0x01, 0x3b, 0x26, 0x31, - 0x04, 0x3b, 0x5a, 0x6e, + 0x04, 0x3b, 0x5c, 0x6e, 0xa0, 0x6a, 0xca, 0x00, 0x20, 0x65, 0xc8, 0x18, - 0x00, 0x65, 0x98, 0x5e, - 0x00, 0x65, 0x52, 0x66, + 0x00, 0x65, 0x9a, 0x5e, + 0x00, 0x65, 0x54, 0x66, 0x0a, 0x93, 0x26, 0x01, - 0x00, 0x65, 0xa8, 0x46, + 0x00, 0x65, 0xaa, 0x46, 0xa0, 0x6a, 0xcc, 0x00, 0xff, 0x6a, 0xc8, 0x08, - 0x20, 0x94, 0x5e, 0x6e, - 0x10, 0x94, 0x60, 0x6e, - 0x08, 0x94, 0x7a, 0x6e, - 0x08, 0x94, 0x7a, 0x6e, - 0x08, 0x94, 0x7a, 0x6e, + 0x20, 0x94, 0x60, 0x6e, + 0x10, 0x94, 0x62, 0x6e, + 0x08, 0x94, 0x7c, 0x6e, + 0x08, 0x94, 0x7c, 0x6e, + 0x08, 0x94, 0x7c, 0x6e, 0xff, 0x8c, 0xc8, 0x10, 0xc1, 0x64, 0xc8, 0x18, 0xf8, 0x64, 0xc8, 0x08, 0x01, 0x99, 0xda, 0x30, - 0x00, 0x66, 0x6e, 0x66, - 0xc0, 0x66, 0xaa, 0x76, + 0x00, 0x66, 0x70, 0x66, + 0xc0, 0x66, 0xac, 0x76, 0x60, 0x66, 0xc8, 0x18, 0x3d, 0x64, 0xc8, 0x28, - 0x00, 0x65, 0x5e, 0x46, + 0x00, 0x65, 0x60, 0x46, 0xf7, 0x93, 0x26, 0x09, - 0x08, 0x93, 0x7c, 0x6e, + 0x08, 0x93, 0x7e, 0x6e, 0x00, 0x62, 0xc4, 0x18, - 0x00, 0x65, 0xa8, 0x5e, - 0x00, 0x65, 0x88, 0x5e, - 0x00, 0x65, 0x88, 0x5e, - 0x00, 0x65, 0x88, 0x5e, + 0x00, 0x65, 0xaa, 0x5e, + 0x00, 0x65, 0x8a, 0x5e, + 0x00, 0x65, 0x8a, 0x5e, + 0x00, 0x65, 0x8a, 0x5e, 0x01, 0x99, 0xda, 0x30, 0x01, 0x99, 0xda, 0x30, 0x01, 0x99, 0xda, 0x30, @@ -858,11 +859,11 @@ static uint8_t seqprog[] = { 0x01, 0x6c, 0x32, 0x31, 0x01, 0x6c, 0x32, 0x31, 0x01, 0x6c, 0x32, 0x35, - 0x08, 0x94, 0xa8, 0x7e, + 0x08, 0x94, 0xaa, 0x7e, 0xf7, 0x93, 0x26, 0x09, - 0x08, 0x93, 0xac, 0x6e, + 0x08, 0x93, 0xae, 0x6e, 0xff, 0x6a, 0xd4, 0x0c, - 0x04, 0xb8, 0xd4, 0x6e, + 0x04, 0xb8, 0xd6, 0x6e, 0x01, 0x42, 0x7e, 0x31, 0xff, 0x6a, 0x76, 0x01, 0x01, 0x90, 0x84, 0x34, @@ -870,14 +871,14 @@ static uint8_t seqprog[] = { 0x01, 0x85, 0x0a, 0x01, 0x7f, 0x65, 0x10, 0x09, 0xfe, 0x85, 0x0a, 0x0d, - 0xff, 0x42, 0xd0, 0x66, - 0xff, 0x41, 0xc8, 0x66, - 0xd1, 0x6a, 0xd8, 0x5e, + 0xff, 0x42, 0xd2, 0x66, + 0xff, 0x41, 0xca, 0x66, + 0xd1, 0x6a, 0xda, 0x5e, 0xff, 0x6a, 0xca, 0x04, 0x01, 0x41, 0x20, 0x31, 0x01, 0xbf, 0x82, 0x30, 0x01, 0x6a, 0x76, 0x00, - 0x00, 0xbb, 0x12, 0x46, + 0x00, 0xbb, 0x14, 0x46, 0x01, 0x42, 0x20, 0x31, 0x01, 0xbf, 0x84, 0x34, 0x01, 0x41, 0x7e, 0x31, @@ -941,7 +942,7 @@ static ahc_patch_func_t ahc_patch17_func; static int ahc_patch17_func(struct ahc_softc *ahc) { - return ((ahc->flags & AHC_TMODE_WIDEODD_BUG) != 0); + return ((ahc->bugs & AHC_TMODE_WIDEODD_BUG) != 0); } static ahc_patch_func_t ahc_patch16_func; @@ -1142,152 +1143,152 @@ static struct patch { { ahc_patch0_func, 196, 1, 1 }, { ahc_patch9_func, 212, 6, 2 }, { ahc_patch0_func, 218, 6, 1 }, - { ahc_patch8_func, 226, 20, 2 }, + { ahc_patch8_func, 226, 21, 2 }, { ahc_patch1_func, 241, 1, 1 }, - { ahc_patch1_func, 248, 1, 2 }, - { ahc_patch0_func, 249, 2, 2 }, - { ahc_patch11_func, 250, 1, 1 }, - { ahc_patch9_func, 258, 27, 3 }, - { ahc_patch1_func, 274, 10, 2 }, - { ahc_patch13_func, 277, 1, 1 }, - { ahc_patch14_func, 285, 14, 1 }, - { ahc_patch1_func, 301, 1, 2 }, - { ahc_patch0_func, 302, 1, 1 }, - { ahc_patch9_func, 305, 1, 1 }, - { ahc_patch13_func, 310, 1, 1 }, - { ahc_patch9_func, 311, 2, 2 }, - { ahc_patch0_func, 313, 4, 1 }, - { ahc_patch14_func, 317, 1, 1 }, - { ahc_patch15_func, 319, 2, 3 }, - { ahc_patch9_func, 319, 1, 2 }, - { ahc_patch0_func, 320, 1, 1 }, - { ahc_patch6_func, 325, 1, 2 }, - { ahc_patch0_func, 326, 1, 1 }, - { ahc_patch1_func, 330, 47, 11 }, - { ahc_patch6_func, 337, 2, 4 }, - { ahc_patch7_func, 337, 1, 1 }, - { ahc_patch8_func, 338, 1, 1 }, - { ahc_patch0_func, 339, 1, 1 }, - { ahc_patch16_func, 340, 1, 1 }, - { ahc_patch6_func, 356, 6, 3 }, - { ahc_patch16_func, 356, 5, 1 }, - { ahc_patch0_func, 362, 7, 1 }, - { ahc_patch13_func, 372, 5, 1 }, - { ahc_patch0_func, 377, 52, 17 }, - { ahc_patch14_func, 377, 1, 1 }, - { ahc_patch7_func, 379, 2, 2 }, - { ahc_patch17_func, 380, 1, 1 }, - { ahc_patch9_func, 383, 1, 1 }, - { ahc_patch18_func, 390, 1, 1 }, - { ahc_patch14_func, 395, 9, 3 }, - { ahc_patch9_func, 396, 3, 2 }, - { ahc_patch0_func, 399, 3, 1 }, - { ahc_patch9_func, 407, 6, 2 }, - { ahc_patch0_func, 413, 9, 2 }, - { ahc_patch13_func, 413, 1, 1 }, - { ahc_patch13_func, 422, 2, 1 }, - { ahc_patch14_func, 424, 1, 1 }, - { ahc_patch9_func, 426, 1, 2 }, - { ahc_patch0_func, 427, 1, 1 }, - { ahc_patch7_func, 428, 1, 1 }, + { ahc_patch1_func, 249, 1, 2 }, + { ahc_patch0_func, 250, 2, 2 }, + { ahc_patch11_func, 251, 1, 1 }, + { ahc_patch9_func, 259, 27, 3 }, + { ahc_patch1_func, 275, 10, 2 }, + { ahc_patch13_func, 278, 1, 1 }, + { ahc_patch14_func, 286, 14, 1 }, + { ahc_patch1_func, 302, 1, 2 }, + { ahc_patch0_func, 303, 1, 1 }, + { ahc_patch9_func, 306, 1, 1 }, + { ahc_patch13_func, 311, 1, 1 }, + { ahc_patch9_func, 312, 2, 2 }, + { ahc_patch0_func, 314, 4, 1 }, + { ahc_patch14_func, 318, 1, 1 }, + { ahc_patch15_func, 320, 2, 3 }, + { ahc_patch9_func, 320, 1, 2 }, + { ahc_patch0_func, 321, 1, 1 }, + { ahc_patch6_func, 326, 1, 2 }, + { ahc_patch0_func, 327, 1, 1 }, + { ahc_patch1_func, 331, 47, 11 }, + { ahc_patch6_func, 338, 2, 4 }, + { ahc_patch7_func, 338, 1, 1 }, + { ahc_patch8_func, 339, 1, 1 }, + { ahc_patch0_func, 340, 1, 1 }, + { ahc_patch16_func, 341, 1, 1 }, + { ahc_patch6_func, 357, 6, 3 }, + { ahc_patch16_func, 357, 5, 1 }, + { ahc_patch0_func, 363, 7, 1 }, + { ahc_patch13_func, 373, 5, 1 }, + { ahc_patch0_func, 378, 52, 17 }, + { ahc_patch14_func, 378, 1, 1 }, + { ahc_patch7_func, 380, 2, 2 }, + { ahc_patch17_func, 381, 1, 1 }, + { ahc_patch9_func, 384, 1, 1 }, + { ahc_patch18_func, 391, 1, 1 }, + { ahc_patch14_func, 396, 9, 3 }, + { ahc_patch9_func, 397, 3, 2 }, + { ahc_patch0_func, 400, 3, 1 }, + { ahc_patch9_func, 408, 6, 2 }, + { ahc_patch0_func, 414, 9, 2 }, + { ahc_patch13_func, 414, 1, 1 }, + { ahc_patch13_func, 423, 2, 1 }, + { ahc_patch14_func, 425, 1, 1 }, + { ahc_patch9_func, 427, 1, 2 }, + { ahc_patch0_func, 428, 1, 1 }, { ahc_patch7_func, 429, 1, 1 }, - { ahc_patch8_func, 430, 3, 3 }, - { ahc_patch6_func, 431, 1, 2 }, - { ahc_patch0_func, 432, 1, 1 }, - { ahc_patch9_func, 433, 1, 1 }, - { ahc_patch15_func, 434, 1, 2 }, - { ahc_patch13_func, 434, 1, 1 }, - { ahc_patch14_func, 436, 9, 4 }, - { ahc_patch9_func, 436, 1, 1 }, - { ahc_patch9_func, 443, 2, 1 }, - { ahc_patch0_func, 445, 4, 3 }, - { ahc_patch9_func, 445, 1, 2 }, - { ahc_patch0_func, 446, 3, 1 }, - { ahc_patch1_func, 450, 2, 1 }, - { ahc_patch7_func, 452, 10, 2 }, - { ahc_patch0_func, 462, 1, 1 }, - { ahc_patch8_func, 463, 118, 22 }, - { ahc_patch1_func, 465, 3, 2 }, - { ahc_patch0_func, 468, 5, 3 }, - { ahc_patch9_func, 468, 2, 2 }, - { ahc_patch0_func, 470, 3, 1 }, - { ahc_patch1_func, 475, 2, 2 }, - { ahc_patch0_func, 477, 6, 3 }, - { ahc_patch9_func, 477, 2, 2 }, - { ahc_patch0_func, 479, 3, 1 }, - { ahc_patch1_func, 485, 2, 2 }, - { ahc_patch0_func, 487, 9, 7 }, - { ahc_patch9_func, 487, 5, 6 }, - { ahc_patch19_func, 487, 1, 2 }, - { ahc_patch0_func, 488, 1, 1 }, - { ahc_patch19_func, 490, 1, 2 }, - { ahc_patch0_func, 491, 1, 1 }, - { ahc_patch0_func, 492, 4, 1 }, - { ahc_patch6_func, 497, 3, 2 }, - { ahc_patch0_func, 500, 1, 1 }, - { ahc_patch6_func, 510, 1, 2 }, - { ahc_patch0_func, 511, 1, 1 }, - { ahc_patch20_func, 548, 7, 1 }, - { ahc_patch3_func, 583, 1, 2 }, - { ahc_patch0_func, 584, 1, 1 }, - { ahc_patch21_func, 587, 1, 1 }, - { ahc_patch8_func, 589, 106, 33 }, - { ahc_patch4_func, 591, 1, 1 }, - { ahc_patch1_func, 597, 2, 2 }, - { ahc_patch0_func, 599, 1, 1 }, - { ahc_patch1_func, 602, 1, 2 }, - { ahc_patch0_func, 603, 1, 1 }, - { ahc_patch9_func, 604, 3, 3 }, - { ahc_patch15_func, 605, 1, 1 }, - { ahc_patch0_func, 607, 4, 1 }, - { ahc_patch19_func, 616, 2, 2 }, - { ahc_patch0_func, 618, 1, 1 }, - { ahc_patch19_func, 622, 10, 3 }, - { ahc_patch5_func, 624, 8, 1 }, - { ahc_patch0_func, 632, 9, 2 }, - { ahc_patch5_func, 633, 8, 1 }, - { ahc_patch4_func, 643, 1, 2 }, - { ahc_patch0_func, 644, 1, 1 }, - { ahc_patch19_func, 645, 1, 2 }, - { ahc_patch0_func, 646, 3, 2 }, - { ahc_patch4_func, 648, 1, 1 }, - { ahc_patch5_func, 649, 1, 1 }, - { ahc_patch5_func, 652, 1, 1 }, - { ahc_patch5_func, 654, 1, 1 }, - { ahc_patch4_func, 656, 2, 2 }, - { ahc_patch0_func, 658, 2, 1 }, - { ahc_patch5_func, 660, 1, 1 }, - { ahc_patch5_func, 663, 1, 1 }, - { ahc_patch5_func, 666, 1, 1 }, - { ahc_patch19_func, 670, 1, 1 }, - { ahc_patch19_func, 673, 1, 1 }, - { ahc_patch4_func, 679, 1, 1 }, - { ahc_patch6_func, 682, 1, 2 }, - { ahc_patch0_func, 683, 1, 1 }, - { ahc_patch7_func, 695, 16, 1 }, - { ahc_patch4_func, 711, 20, 1 }, - { ahc_patch9_func, 732, 4, 2 }, - { ahc_patch0_func, 736, 4, 1 }, - { ahc_patch9_func, 740, 4, 2 }, - { ahc_patch0_func, 744, 3, 1 }, - { ahc_patch6_func, 750, 1, 1 }, - { ahc_patch22_func, 752, 14, 1 }, - { ahc_patch7_func, 766, 3, 1 }, - { ahc_patch9_func, 778, 24, 8 }, - { ahc_patch19_func, 782, 1, 2 }, - { ahc_patch0_func, 783, 1, 1 }, - { ahc_patch15_func, 788, 4, 2 }, - { ahc_patch0_func, 792, 7, 3 }, - { ahc_patch23_func, 792, 5, 2 }, - { ahc_patch0_func, 797, 2, 1 }, - { ahc_patch0_func, 802, 42, 3 }, - { ahc_patch18_func, 814, 18, 2 }, - { ahc_patch0_func, 832, 1, 1 }, - { ahc_patch4_func, 856, 1, 1 }, - { ahc_patch4_func, 857, 3, 2 }, - { ahc_patch0_func, 860, 1, 1 }, - { ahc_patch13_func, 861, 3, 1 }, - { ahc_patch4_func, 864, 12, 1 } + { ahc_patch7_func, 430, 1, 1 }, + { ahc_patch8_func, 431, 3, 3 }, + { ahc_patch6_func, 432, 1, 2 }, + { ahc_patch0_func, 433, 1, 1 }, + { ahc_patch9_func, 434, 1, 1 }, + { ahc_patch15_func, 435, 1, 2 }, + { ahc_patch13_func, 435, 1, 1 }, + { ahc_patch14_func, 437, 9, 4 }, + { ahc_patch9_func, 437, 1, 1 }, + { ahc_patch9_func, 444, 2, 1 }, + { ahc_patch0_func, 446, 4, 3 }, + { ahc_patch9_func, 446, 1, 2 }, + { ahc_patch0_func, 447, 3, 1 }, + { ahc_patch1_func, 451, 2, 1 }, + { ahc_patch7_func, 453, 10, 2 }, + { ahc_patch0_func, 463, 1, 1 }, + { ahc_patch8_func, 464, 118, 22 }, + { ahc_patch1_func, 466, 3, 2 }, + { ahc_patch0_func, 469, 5, 3 }, + { ahc_patch9_func, 469, 2, 2 }, + { ahc_patch0_func, 471, 3, 1 }, + { ahc_patch1_func, 476, 2, 2 }, + { ahc_patch0_func, 478, 6, 3 }, + { ahc_patch9_func, 478, 2, 2 }, + { ahc_patch0_func, 480, 3, 1 }, + { ahc_patch1_func, 486, 2, 2 }, + { ahc_patch0_func, 488, 9, 7 }, + { ahc_patch9_func, 488, 5, 6 }, + { ahc_patch19_func, 488, 1, 2 }, + { ahc_patch0_func, 489, 1, 1 }, + { ahc_patch19_func, 491, 1, 2 }, + { ahc_patch0_func, 492, 1, 1 }, + { ahc_patch0_func, 493, 4, 1 }, + { ahc_patch6_func, 498, 3, 2 }, + { ahc_patch0_func, 501, 1, 1 }, + { ahc_patch6_func, 511, 1, 2 }, + { ahc_patch0_func, 512, 1, 1 }, + { ahc_patch20_func, 549, 7, 1 }, + { ahc_patch3_func, 584, 1, 2 }, + { ahc_patch0_func, 585, 1, 1 }, + { ahc_patch21_func, 588, 1, 1 }, + { ahc_patch8_func, 590, 106, 33 }, + { ahc_patch4_func, 592, 1, 1 }, + { ahc_patch1_func, 598, 2, 2 }, + { ahc_patch0_func, 600, 1, 1 }, + { ahc_patch1_func, 603, 1, 2 }, + { ahc_patch0_func, 604, 1, 1 }, + { ahc_patch9_func, 605, 3, 3 }, + { ahc_patch15_func, 606, 1, 1 }, + { ahc_patch0_func, 608, 4, 1 }, + { ahc_patch19_func, 617, 2, 2 }, + { ahc_patch0_func, 619, 1, 1 }, + { ahc_patch19_func, 623, 10, 3 }, + { ahc_patch5_func, 625, 8, 1 }, + { ahc_patch0_func, 633, 9, 2 }, + { ahc_patch5_func, 634, 8, 1 }, + { ahc_patch4_func, 644, 1, 2 }, + { ahc_patch0_func, 645, 1, 1 }, + { ahc_patch19_func, 646, 1, 2 }, + { ahc_patch0_func, 647, 3, 2 }, + { ahc_patch4_func, 649, 1, 1 }, + { ahc_patch5_func, 650, 1, 1 }, + { ahc_patch5_func, 653, 1, 1 }, + { ahc_patch5_func, 655, 1, 1 }, + { ahc_patch4_func, 657, 2, 2 }, + { ahc_patch0_func, 659, 2, 1 }, + { ahc_patch5_func, 661, 1, 1 }, + { ahc_patch5_func, 664, 1, 1 }, + { ahc_patch5_func, 667, 1, 1 }, + { ahc_patch19_func, 671, 1, 1 }, + { ahc_patch19_func, 674, 1, 1 }, + { ahc_patch4_func, 680, 1, 1 }, + { ahc_patch6_func, 683, 1, 2 }, + { ahc_patch0_func, 684, 1, 1 }, + { ahc_patch7_func, 696, 16, 1 }, + { ahc_patch4_func, 712, 20, 1 }, + { ahc_patch9_func, 733, 4, 2 }, + { ahc_patch0_func, 737, 4, 1 }, + { ahc_patch9_func, 741, 4, 2 }, + { ahc_patch0_func, 745, 3, 1 }, + { ahc_patch6_func, 751, 1, 1 }, + { ahc_patch22_func, 753, 14, 1 }, + { ahc_patch7_func, 767, 3, 1 }, + { ahc_patch9_func, 779, 24, 8 }, + { ahc_patch19_func, 783, 1, 2 }, + { ahc_patch0_func, 784, 1, 1 }, + { ahc_patch15_func, 789, 4, 2 }, + { ahc_patch0_func, 793, 7, 3 }, + { ahc_patch23_func, 793, 5, 2 }, + { ahc_patch0_func, 798, 2, 1 }, + { ahc_patch0_func, 803, 42, 3 }, + { ahc_patch18_func, 815, 18, 2 }, + { ahc_patch0_func, 833, 1, 1 }, + { ahc_patch4_func, 857, 1, 1 }, + { ahc_patch4_func, 858, 3, 2 }, + { ahc_patch0_func, 861, 1, 1 }, + { ahc_patch13_func, 862, 3, 1 }, + { ahc_patch4_func, 865, 12, 1 } }; static struct cs { @@ -1296,11 +1297,11 @@ static struct cs { } critical_sections[] = { { 11, 18 }, { 21, 30 }, - { 711, 727 }, - { 857, 860 }, - { 864, 870 }, - { 872, 874 }, - { 874, 876 } + { 712, 728 }, + { 858, 861 }, + { 865, 871 }, + { 873, 875 }, + { 875, 877 } }; static const int num_critical_sections = sizeof(critical_sections) -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/pci_irq.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index c536ccfc541..7ed4b2ef265 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 v1.2.3-18-g5258 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 --- drivers/char/hpet.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index 5ec732e6ca9..a8d4c47f7ad 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 v1.2.3-18-g5258 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 --- drivers/pnp/pnpacpi/rsparser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 75575f6c349..1e296cbef00 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 v1.2.3-18-g5258 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 --- drivers/serial/8250_acpi.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/serial/8250_acpi.c b/drivers/serial/8250_acpi.c index 6b9ead28851..a802bdce6e5 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 v1.2.3-18-g5258 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 --- drivers/acpi/video.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 2cf264fd52e..7b10a7b070c 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 v1.2.3-18-g5258 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 --- drivers/acpi/pci_link.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 0091dbdf7ef..a0df2f3606d 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 v1.2.3-18-g5258 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 --- drivers/acpi/Kconfig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 281a64040f3..eded2e81cc1 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 v1.2.3-18-g5258 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 --- drivers/acpi/event.c | 18 ++++++------------ drivers/acpi/fan.c | 37 +++++++++++++------------------------ drivers/acpi/pci_link.c | 10 +++------- drivers/acpi/sleep/proc.c | 34 ++++++++++------------------------ 4 files changed, 32 insertions(+), 67 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index 43c49f66a32..ce8d3eec391 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 14192ee55f8..2ee1d061013 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 26aa3829f1d..e8334ce84d8 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 1be99f0996d..a962fc24f70 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 v1.2.3-18-g5258 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 --- drivers/acpi/ac.c | 138 ++--- drivers/acpi/acpi_memhotplug.c | 176 +++--- drivers/acpi/asus_acpi.c | 690 +++++++++++----------- drivers/acpi/battery.c | 400 ++++++------- drivers/acpi/blacklist.c | 122 ++-- drivers/acpi/bus.c | 310 +++++----- drivers/acpi/button.c | 274 ++++----- drivers/acpi/container.c | 128 ++--- drivers/acpi/debug.c | 115 ++-- drivers/acpi/dispatcher/dsfield.c | 346 ++++++----- drivers/acpi/dispatcher/dsinit.c | 123 ++-- drivers/acpi/dispatcher/dsmethod.c | 354 ++++++------ drivers/acpi/dispatcher/dsmthdat.c | 413 +++++++------- drivers/acpi/dispatcher/dsobject.c | 329 +++++------ drivers/acpi/dispatcher/dsopcode.c | 710 +++++++++++------------ drivers/acpi/dispatcher/dsutils.c | 421 +++++++------- drivers/acpi/dispatcher/dswexec.c | 519 +++++++++-------- drivers/acpi/dispatcher/dswload.c | 488 ++++++++-------- drivers/acpi/dispatcher/dswscope.c | 139 ++--- drivers/acpi/dispatcher/dswstate.c | 640 ++++++++++----------- drivers/acpi/ec.c | 957 ++++++++++++++----------------- drivers/acpi/event.c | 62 +- drivers/acpi/events/evevent.c | 168 +++--- drivers/acpi/events/evgpe.c | 428 +++++++------- drivers/acpi/events/evgpeblk.c | 756 ++++++++++++------------- drivers/acpi/events/evmisc.c | 294 +++++----- drivers/acpi/events/evregion.c | 582 +++++++++---------- drivers/acpi/events/evrgnini.c | 311 +++++----- drivers/acpi/events/evsci.c | 77 +-- drivers/acpi/events/evxface.c | 446 +++++++-------- drivers/acpi/events/evxfevnt.c | 463 +++++++-------- drivers/acpi/events/evxfregn.c | 114 ++-- drivers/acpi/executer/exconfig.c | 319 +++++------ drivers/acpi/executer/exconvrt.c | 311 +++++----- drivers/acpi/executer/excreate.c | 342 +++++------ drivers/acpi/executer/exdump.c | 744 ++++++++++++------------ drivers/acpi/executer/exfield.c | 252 ++++----- drivers/acpi/executer/exfldio.c | 644 ++++++++++----------- drivers/acpi/executer/exmisc.c | 358 ++++++------ drivers/acpi/executer/exmutex.c | 160 +++--- drivers/acpi/executer/exnames.c | 235 ++++---- drivers/acpi/executer/exoparg1.c | 555 +++++++++--------- drivers/acpi/executer/exoparg2.c | 317 +++++------ drivers/acpi/executer/exoparg3.c | 116 ++-- drivers/acpi/executer/exoparg6.c | 127 ++--- drivers/acpi/executer/exprep.c | 381 ++++++------- drivers/acpi/executer/exregion.c | 280 ++++----- drivers/acpi/executer/exresnte.c | 172 +++--- drivers/acpi/executer/exresolv.c | 284 +++++----- drivers/acpi/executer/exresop.c | 390 ++++++------- drivers/acpi/executer/exstore.c | 415 +++++++------- drivers/acpi/executer/exstoren.c | 121 ++-- drivers/acpi/executer/exstorob.c | 86 ++- drivers/acpi/executer/exsystem.c | 183 +++--- drivers/acpi/executer/exutils.c | 171 ++---- drivers/acpi/fan.c | 125 ++-- drivers/acpi/glue.c | 6 +- drivers/acpi/hardware/hwacpi.c | 116 ++-- drivers/acpi/hardware/hwgpe.c | 197 +++---- drivers/acpi/hardware/hwregs.c | 600 ++++++++++---------- drivers/acpi/hardware/hwsleep.c | 415 +++++++------- drivers/acpi/hardware/hwtimer.c | 77 +-- drivers/acpi/hotkey.c | 233 ++++---- drivers/acpi/ibm_acpi.c | 322 +++++------ drivers/acpi/motherboard.c | 108 ++-- drivers/acpi/namespace/nsaccess.c | 342 +++++------ drivers/acpi/namespace/nsalloc.c | 232 +++----- drivers/acpi/namespace/nsdump.c | 429 +++++++------- drivers/acpi/namespace/nsdumpdv.c | 74 +-- drivers/acpi/namespace/nseval.c | 270 ++++----- drivers/acpi/namespace/nsinit.c | 257 ++++----- drivers/acpi/namespace/nsload.c | 228 ++++---- drivers/acpi/namespace/nsnames.c | 118 ++-- drivers/acpi/namespace/nsobject.c | 209 +++---- drivers/acpi/namespace/nsparse.c | 86 ++- drivers/acpi/namespace/nssearch.c | 205 ++++--- drivers/acpi/namespace/nsutils.c | 502 +++++++--------- drivers/acpi/namespace/nswalk.c | 105 ++-- drivers/acpi/namespace/nsxfeval.c | 430 +++++++------- drivers/acpi/namespace/nsxfname.c | 173 +++--- drivers/acpi/namespace/nsxfobj.c | 91 ++- drivers/acpi/numa.c | 125 ++-- drivers/acpi/osl.c | 567 ++++++++----------- drivers/acpi/parser/psargs.c | 376 ++++++------ drivers/acpi/parser/psloop.c | 511 ++++++++++------- drivers/acpi/parser/psopcode.c | 719 ++++++++++++++++------- drivers/acpi/parser/psparse.c | 362 ++++++------ drivers/acpi/parser/psscope.c | 130 ++--- drivers/acpi/parser/pstree.c | 92 +-- drivers/acpi/parser/psutils.c | 105 ++-- drivers/acpi/parser/pswalk.c | 26 +- drivers/acpi/parser/psxface.c | 142 ++--- drivers/acpi/pci_bind.c | 219 ++++--- drivers/acpi/pci_irq.c | 263 ++++----- drivers/acpi/pci_link.c | 477 ++++++++-------- drivers/acpi/pci_root.c | 130 ++--- drivers/acpi/power.c | 271 ++++----- drivers/acpi/processor_core.c | 437 +++++++------- drivers/acpi/processor_idle.c | 315 ++++++----- drivers/acpi/processor_perflib.c | 297 +++++----- drivers/acpi/processor_thermal.c | 153 +++-- drivers/acpi/processor_throttling.c | 133 ++--- drivers/acpi/resources/rsaddr.c | 503 ++++++++-------- drivers/acpi/resources/rscalc.c | 314 +++++----- drivers/acpi/resources/rscreate.c | 297 +++++----- drivers/acpi/resources/rsdump.c | 847 +++++++++++++-------------- drivers/acpi/resources/rsio.c | 172 +++--- drivers/acpi/resources/rsirq.c | 236 ++++---- drivers/acpi/resources/rslist.c | 279 ++++----- drivers/acpi/resources/rsmemory.c | 218 ++++--- drivers/acpi/resources/rsmisc.c | 230 +++----- drivers/acpi/resources/rsutils.c | 159 +++--- drivers/acpi/resources/rsxface.c | 182 +++--- drivers/acpi/scan.c | 437 +++++++------- drivers/acpi/sleep/poweroff.c | 2 +- drivers/acpi/sleep/proc.c | 243 ++++---- drivers/acpi/sleep/wakeup.c | 115 ++-- drivers/acpi/system.c | 76 ++- drivers/acpi/tables.c | 434 +++++++------- drivers/acpi/tables/tbconvrt.c | 402 ++++++------- drivers/acpi/tables/tbget.c | 275 ++++----- drivers/acpi/tables/tbgetall.c | 189 +++---- drivers/acpi/tables/tbinstal.c | 256 ++++----- drivers/acpi/tables/tbrsdt.c | 190 +++---- drivers/acpi/tables/tbutils.c | 147 ++--- drivers/acpi/tables/tbxface.c | 246 ++++---- drivers/acpi/tables/tbxfroot.c | 431 +++++++------- drivers/acpi/thermal.c | 801 +++++++++++++------------- drivers/acpi/toshiba_acpi.c | 174 +++--- drivers/acpi/utilities/utalloc.c | 505 +++++++---------- drivers/acpi/utilities/utcache.c | 149 +++-- drivers/acpi/utilities/utcopy.c | 556 +++++++++--------- drivers/acpi/utilities/utdebug.c | 330 +++++------ drivers/acpi/utilities/utdelete.c | 325 +++++------ drivers/acpi/utilities/uteval.c | 396 ++++++------- drivers/acpi/utilities/utglobal.c | 557 +++++++++--------- drivers/acpi/utilities/utinit.c | 135 ++--- drivers/acpi/utilities/utmath.c | 144 ++--- drivers/acpi/utilities/utmisc.c | 431 ++++++-------- drivers/acpi/utilities/utmutex.c | 220 ++++--- drivers/acpi/utilities/utobject.c | 324 +++++------ drivers/acpi/utilities/utstate.c | 159 ++---- drivers/acpi/utilities/utxface.c | 267 ++++----- drivers/acpi/utils.c | 195 ++++--- drivers/acpi/video.c | 1070 ++++++++++++++++------------------- 145 files changed, 20549 insertions(+), 23325 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 23ab761dd72..7839b831df9 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 77285ffe41c..01a1bd23926 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 a560b1e2da7..fec895af6ae 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 c55feca9b7d..702e857e98c 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 4c010e7f11b..9824f679a91 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 d77c2307883..6a4da417c16 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 8162fd0c21a..4b6d9f0096a 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 97013ddfa20..10dd695a1dd 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 2c0dac559f1..263322b7d11 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 84193983d6b..2022aeaecfb 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 bcd1d472b90..8693c704aea 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 e344c06ed33..77fcfc3070d 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 c83d53fd639..4095ce70982 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 1eee2d54180..8ac0cd93adb 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 750bdb1ac34..939d167bf87 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 9613349ac31..83ae1c1aa28 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 10f71318e23..e522763bb69 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 9100c0bda47..362bbcfc171 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 21f4548ff32..defe956ef75 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 5621665991b..7d68a5aaf3c 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 1ac5731d45e..b15f5ec81d0 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 ce8d3eec391..bfa8b76de40 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 dd3a72a869f..842d1e3fb37 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 ede834df4f6..b2f232df13d 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 dfc54692b12..b312eb33c43 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 3df3ada4b9e..7e57b8470f5 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 a1d7276c574..84fad082d80 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 f2d53af9761..a1bd2da27c4 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 f3123c26ae9..14183597700 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 4c1c25e316a..43b33d19cdf 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 c5f74d7b64d..887ff9f28a0 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 d058587b342..6f28ea2db5b 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 d11e9ec827f..1ce365d651d 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 21331625e66..04e5194989a 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 812cdcb2e37..91c49188fb0 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 4f98dceed39..bc2fa996047 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 a690c925099..ab1ba399aa2 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 3c2f89e00f7..ba6e08843c2 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 237ef28c813..a3f4d72bedc 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 c3cb714d2cb..ab47f6d8b5c 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 b6ba1a7a677..239d8473e9a 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 48c30f80008..97e34542f5e 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 7429032c2b6..8d70c6beef0 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 197890f443b..48336577767 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 17f81d42ee4..5dee7713957 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 c9e3c68b554..7476c363e40 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 723aaef4bb4..9a2f5bea3af 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 21d5c74fa30..ff5d8f97e8e 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 3de45672379..97eecbd3242 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 aaba7abcb52..ff064e79ab9 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 59dbfeaa54c..a7d8eea305c 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 433588ab432..382f63c14ea 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 12d1527669c..c4ff654a669 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 cafa702108d..8a88b841237 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 d00b0dcba96..1ee79d8c8f8 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 2ee1d061013..e8165c4f162 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 770cfc8b17e..1943461489c 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 b51001e74ee..1bb3463d704 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 3536bbb990c..5c8e5dfd024 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 04a058565d8..536a7aea80c 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 cedee0c43b5..34519069050 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 49d7b395322..aff6dc14178 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 1f76a40bade..2e2e4051dfa 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 ad85e10001f..62233bd7147 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 7589e1fdf25..edfbe34600f 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 21d560decbf..cc7a85f8cfe 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 5d25add6b03..9faf1d5c86e 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 27c4f7cd2a4..55de883943d 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 908cffd5e72..0191c7d9282 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 362802ae29a..0a08d2f04a0 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 1428a84a31e..c28849de465 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 d8ce7e39795..d5e8dea61c2 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 27258c1ca4f..fc9be946ebe 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 24bed931d39..433442a9ec7 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 af8aaa9cc4f..50a3ca5470e 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 c53b82e94ce..ebec036423c 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 f9a7277dca6..5f164c0df33 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 12ea202257f..c07b046659f 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 8d097914c49..6b5f8d4481d 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 363e1f6cfb1..0856d42e690 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 a82834b3275..64b98e82feb 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 f3a807c342c..9127760d36c 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 b7ac68cc9e1..5858188f94a 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 551d54bdbec..088d33999d9 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 6f7594a516d..229ae86afe8 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 16b84a3d043..3248051d77e 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 8dcd1b1e713..1c953b6f1af 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 d5aafe73fca..f0e755884ee 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 4221b41ae1a..2075efbb432 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 9d20cb2ceb5..08f2321b6de 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 d1541fabaf0..80c67f2d3dd 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 5148f3c10b5..a4955685e4c 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 c885300579e..2bbfba8e8c6 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 e8334ce84d8..82292b77e5c 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 5d2f77fcd50..0fd9988c283 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 373a3a95bb4..62a5595ed8b 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 d56a439ac61..819cb0b453f 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 2c04740c654..26a3a401611 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 1f0d6256302..22c7bb66c20 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 12bd980a12e..37528c3b64b 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 be9f569d39d..74a52d4e79a 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 55d264771c4..4cf46e1ee01 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 98176f2fcb5..378f58390fc 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 8e0eae0d50b..0911526b7ad 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 2c3bb8c3574..75bd34d1783 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 23a4d149fac..d53bbe89e85 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 8a2b630be45..7179b6243f5 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 db7bcb4e60e..103eb31c284 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 91d0207f01a..daba1a1ed46 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 a1f1741f0d8..7a8a34e757f 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 700cf7d65d7..4446778eaf7 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 83c944b8b09..ee5a5c50919 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 cbcda30c172..8a3ea41063e 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 186b182c582..f8538b5b893 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 a962fc24f70..09a603f3523 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 d9b199969d5..4134ed43d02 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 8925a6ca5f8..e4308c7a674 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 fb64bd5d2e1..a2bf25b05e1 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 d4ff71f5fe5..a03939399fa 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 4ab2aadc613..6acd5aeb093 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 eea5b8cb5eb..8d72343537e 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 698799901f5..10db8484e46 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 069d498465d..ad0252c2f7d 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 6fc1e36e604..5bcafebb9dd 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 e18a05d1b9b..3f96a4909aa 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 87dccdda9ae..3b8a7e063e8 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 79c3a686bc4..a24847c08f7 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 73b1d8aeae9..7fe0b7ae973 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 78270f50e62..068450b3647 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 c0df0585c68..93d48681d27 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 31c30a32e5c..5442b32de61 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 c27cbb7f5c5..081a778aba8 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 eeafb324c50..2bc878f7a12 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 00046dd5d92..7b81d5ef3c3 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 0e4161c8107..399e64b5188 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 fd7ceba8322..9dde82b0bea 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 0d527c91543..68a0a6f9412 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 1d350b302a3..474fe7cb6c0 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 0699b6be62b..90134c56ece 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 19178e14295..3015e154005 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 192e7ac9569..c1cb27583be 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 850da681742..f06bd5e5e9d 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 1ce2047c380..6458c47f7ac 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 7b10a7b070c..b9132b5ac0f 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"); -- cgit v1.2.3-18-g5258 From fc789a93994858b5e5a46afb96d0dcf6cc1b6f08 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Fri, 5 Aug 2005 16:24:54 -0500 Subject: [SCSI] aic7xxx/79xx: fix another potential panic due to a non existent target I ran into this one sending bus resets across the hardware. Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_osm.c | 4 ++-- drivers/scsi/aic7xxx/aic7xxx_osm.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 40f32bb2397..acaeebd5046 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -1617,9 +1617,9 @@ ahd_send_async(struct ahd_softc *ahd, char channel, * are identical to those last reported. */ starget = ahd->platform_data->starget[target]; - targ = scsi_transport_target_data(starget); - if (targ == NULL) + if (starget == NULL) break; + targ = scsi_transport_target_data(starget); target_ppr_options = (spi_dt(starget) ? MSG_EXT_PPR_DT_REQ : 0) diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index e39361ac6a4..3fbc10e58cc 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -1618,9 +1618,9 @@ ahc_send_async(struct ahc_softc *ahc, char channel, if (channel == 'B') target_offset += 8; starget = ahc->platform_data->starget[target_offset]; - targ = scsi_transport_target_data(starget); - if (targ == NULL) + if (starget == NULL) break; + targ = scsi_transport_target_data(starget); target_ppr_options = (spi_dt(starget) ? MSG_EXT_PPR_DT_REQ : 0) -- cgit v1.2.3-18-g5258 From bed30de47b034b5f28fb7db2fae4860b9d9c0622 Mon Sep 17 00:00:00 2001 From: Mark Haverkamp Date: Wed, 3 Aug 2005 15:38:51 -0700 Subject: [SCSI] aacraid: interupt mitigation Received from Mark Salyzyn from Adaptec: If more than two commands are outstanding to the controller, there is no need to notify the adapter via a PCI bus transaction of additional commands added into the queue; it will get to them when it works through the produce/consumer indexes. This reduced the PCI traffic in the driver to submit a command to the queue to near zero allowing a significant number of commands to be turned around with no need to block for the PCI bridge to flush the notify request to the adapter. Interrupt mitigation has always been present in the driver; it was turned off because of a bug that prevented one from realizing the usefulness of the feature. This bug is fixed in this patch. Signed-off-by: Mark Haverkamp Signed-off-by: James Bottomley --- drivers/scsi/aacraid/comminit.c | 4 +++- drivers/scsi/aacraid/commsup.c | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 43557bf661f..75abd045328 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -44,7 +44,9 @@ #include "aacraid.h" -struct aac_common aac_config; +struct aac_common aac_config = { + .irq_mod = 1 +}; static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long commsize, unsigned long commalign) { diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 5322865942e..a1d303f0348 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -254,6 +254,7 @@ static void fib_dealloc(struct fib * fibptr) static int aac_get_entry (struct aac_dev * dev, u32 qid, struct aac_entry **entry, u32 * index, unsigned long *nonotify) { struct aac_queue * q; + unsigned long idx; /* * All of the queues wrap when they reach the end, so we check @@ -263,10 +264,23 @@ static int aac_get_entry (struct aac_dev * dev, u32 qid, struct aac_entry **entr */ q = &dev->queues->queue[qid]; - - *index = le32_to_cpu(*(q->headers.producer)); - if ((*index - 2) == le32_to_cpu(*(q->headers.consumer))) + + idx = *index = le32_to_cpu(*(q->headers.producer)); + /* Interrupt Moderation, only interrupt for first two entries */ + if (idx != le32_to_cpu(*(q->headers.consumer))) { + if (--idx == 0) { + if (qid == AdapHighCmdQueue) + idx = ADAP_HIGH_CMD_ENTRIES; + else if (qid == AdapNormCmdQueue) + idx = ADAP_NORM_CMD_ENTRIES; + else if (qid == AdapHighRespQueue) + idx = ADAP_HIGH_RESP_ENTRIES; + else if (qid == AdapNormRespQueue) + idx = ADAP_NORM_RESP_ENTRIES; + } + if (idx != le32_to_cpu(*(q->headers.consumer))) *nonotify = 1; + } if (qid == AdapHighCmdQueue) { if (*index >= ADAP_HIGH_CMD_ENTRIES) -- cgit v1.2.3-18-g5258 From c7f476023f57145357df32346b7de9202ce47d5f Mon Sep 17 00:00:00 2001 From: Mark Haverkamp Date: Wed, 3 Aug 2005 15:38:55 -0700 Subject: [SCSI] aacraid: driver version update Received from Mark Salyzyn from Adaptec. Fixes a bug in check_revision. It should return the driver version not the firmware version. Update driver version number. Update driver version string. Signed-off-by: Mark Haverkamp Signed-off-by: James Bottomley --- drivers/scsi/aacraid/aacraid.h | 8 +++++--- drivers/scsi/aacraid/commctrl.c | 18 ++++++++++++++---- drivers/scsi/aacraid/linit.c | 21 ++++++++++++++++----- 3 files changed, 35 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 3a11a536c0d..ddbbb85b3a7 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -1512,11 +1512,12 @@ struct fib_ioctl struct revision { - u32 compat; - u32 version; - u32 build; + __le32 compat; + __le32 version; + __le32 build; }; + /* * Ugly - non Linux like ioctl coding for back compat. */ @@ -1737,3 +1738,4 @@ int aac_get_adapter_info(struct aac_dev* dev); int aac_send_shutdown(struct aac_dev *dev); extern int numacb; extern int acbsize; +extern char aac_driver_version[]; diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 85387099aab..8fceff9be1b 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -405,10 +405,20 @@ static int close_getadapter_fib(struct aac_dev * dev, void __user *arg) static int check_revision(struct aac_dev *dev, void __user *arg) { struct revision response; - - response.compat = 1; - response.version = le32_to_cpu(dev->adapter_info.kernelrev); - response.build = le32_to_cpu(dev->adapter_info.kernelbuild); + char *driver_version = aac_driver_version; + u32 version; + + response.compat = cpu_to_le32(1); + version = (simple_strtol(driver_version, + &driver_version, 10) << 24) | 0x00000400; + version += simple_strtol(driver_version + 1, &driver_version, 10) << 16; + version += simple_strtol(driver_version + 1, NULL, 10); + response.version = cpu_to_le32(version); +# if (defined(AAC_DRIVER_BUILD)) + response.build = cpu_to_le32(AAC_DRIVER_BUILD); +# else + response.build = cpu_to_le32(9999); +# endif if (copy_to_user(arg, &response, sizeof(response))) return -EFAULT; diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index c1a4f978fcb..b6dda99f508 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -27,8 +27,11 @@ * Abstract: Linux Driver entry module for Adaptec RAID Array Controller */ -#define AAC_DRIVER_VERSION "1.1.2-lk2" -#define AAC_DRIVER_BUILD_DATE __DATE__ +#define AAC_DRIVER_VERSION "1.1-4" +#ifndef AAC_DRIVER_BRANCH +#define AAC_DRIVER_BRANCH "" +#endif +#define AAC_DRIVER_BUILD_DATE __DATE__ " " __TIME__ #define AAC_DRIVERNAME "aacraid" #include @@ -58,16 +61,24 @@ #include "aacraid.h" +#ifdef AAC_DRIVER_BUILD +#define _str(x) #x +#define str(x) _str(x) +#define AAC_DRIVER_FULL_VERSION AAC_DRIVER_VERSION "[" str(AAC_DRIVER_BUILD) "]" AAC_DRIVER_BRANCH +#else +#define AAC_DRIVER_FULL_VERSION AAC_DRIVER_VERSION AAC_DRIVER_BRANCH " " AAC_DRIVER_BUILD_DATE +#endif MODULE_AUTHOR("Red Hat Inc and Adaptec"); MODULE_DESCRIPTION("Dell PERC2, 2/Si, 3/Si, 3/Di, " "Adaptec Advanced Raid Products, " "and HP NetRAID-4M SCSI driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(AAC_DRIVER_VERSION); +MODULE_VERSION(AAC_DRIVER_FULL_VERSION); static LIST_HEAD(aac_devices); static int aac_cfg_major = -1; +char aac_driver_version[] = AAC_DRIVER_FULL_VERSION; /* * Because of the way Linux names scsi devices, the order in this table has @@ -896,8 +907,8 @@ static int __init aac_init(void) { int error; - printk(KERN_INFO "Red Hat/Adaptec aacraid driver (%s %s)\n", - AAC_DRIVER_VERSION, AAC_DRIVER_BUILD_DATE); + printk(KERN_INFO "Adaptec %s driver (%s)\n", + AAC_DRIVERNAME, aac_driver_version); error = pci_module_init(&aac_pci_driver); if (error) -- cgit v1.2.3-18-g5258 From bd1aac809ddbcf7772cfd809d8cfb29c729c6cf9 Mon Sep 17 00:00:00 2001 From: Mark Haverkamp Date: Wed, 3 Aug 2005 15:39:01 -0700 Subject: [SCSI] aacraid: driver shutdown method Add in pci shutdown method so that the adapter shuts down correctly and flushes its cache. Shutdown should also disable the adapter's interrupt when shutdown (in particularly if the driver is rmmod'd) to prevent spurious hardware activities. Signed-off-by: Mark Haverkamp Signed-off-by: James Bottomley --- drivers/scsi/aacraid/aacraid.h | 4 ++++ drivers/scsi/aacraid/linit.c | 13 ++++++++++++- drivers/scsi/aacraid/rkt.c | 20 ++++++++++++++++++++ drivers/scsi/aacraid/rx.c | 20 ++++++++++++++++++++ drivers/scsi/aacraid/sa.c | 22 ++++++++++++++++++++-- 5 files changed, 76 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index ddbbb85b3a7..6f4906ee9a5 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -460,6 +460,7 @@ struct adapter_ops { void (*adapter_interrupt)(struct aac_dev *dev); void (*adapter_notify)(struct aac_dev *dev, u32 event); + void (*adapter_disable_int)(struct aac_dev *dev); int (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6, u32 *status, u32 *r1, u32 *r2, u32 *r3, u32 *r4); int (*adapter_check_health)(struct aac_dev *dev); }; @@ -994,6 +995,9 @@ struct aac_dev #define aac_adapter_notify(dev, event) \ (dev)->a_ops.adapter_notify(dev, event) +#define aac_adapter_disable_int(dev) \ + (dev)->a_ops.adapter_disable_int(dev) + #define aac_adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4) \ (dev)->a_ops.adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index b6dda99f508..41255f7893d 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -849,11 +849,12 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, return 0; -out_deinit: + out_deinit: kill_proc(aac->thread_pid, SIGKILL, 0); wait_for_completion(&aac->aif_completion); aac_send_shutdown(aac); + aac_adapter_disable_int(aac); fib_map_free(aac); pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr, aac->comm_phys); kfree(aac->queues); @@ -870,6 +871,13 @@ out_deinit: return error; } +static void aac_shutdown(struct pci_dev *dev) +{ + struct Scsi_Host *shost = pci_get_drvdata(dev); + struct aac_dev *aac = (struct aac_dev *)shost->hostdata; + aac_send_shutdown(aac); +} + static void __devexit aac_remove_one(struct pci_dev *pdev) { struct Scsi_Host *shost = pci_get_drvdata(pdev); @@ -881,6 +889,7 @@ static void __devexit aac_remove_one(struct pci_dev *pdev) wait_for_completion(&aac->aif_completion); aac_send_shutdown(aac); + aac_adapter_disable_int(aac); fib_map_free(aac); pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr, aac->comm_phys); @@ -901,6 +910,7 @@ static struct pci_driver aac_pci_driver = { .id_table = aac_pci_tbl, .probe = aac_probe_one, .remove = __devexit_p(aac_remove_one), + .shutdown = aac_shutdown, }; static int __init aac_init(void) @@ -919,6 +929,7 @@ static int __init aac_init(void) printk(KERN_WARNING "aacraid: unable to register \"aac\" device.\n"); } + return 0; } diff --git a/drivers/scsi/aacraid/rkt.c b/drivers/scsi/aacraid/rkt.c index 7d68b782513..557287a0b80 100644 --- a/drivers/scsi/aacraid/rkt.c +++ b/drivers/scsi/aacraid/rkt.c @@ -87,6 +87,16 @@ static irqreturn_t aac_rkt_intr(int irq, void *dev_id, struct pt_regs *regs) return IRQ_NONE; } +/** + * aac_rkt_disable_interrupt - Disable interrupts + * @dev: Adapter + */ + +static void aac_rkt_disable_interrupt(struct aac_dev *dev) +{ + rkt_writeb(dev, MUnit.OIMR, dev->OIMR = 0xff); +} + /** * rkt_sync_cmd - send a command and wait * @dev: Adapter @@ -412,10 +422,19 @@ int aac_rkt_init(struct aac_dev *dev) * Fill in the function dispatch table. */ dev->a_ops.adapter_interrupt = aac_rkt_interrupt_adapter; + dev->a_ops.adapter_disable_int = aac_rkt_disable_interrupt; dev->a_ops.adapter_notify = aac_rkt_notify_adapter; dev->a_ops.adapter_sync_cmd = rkt_sync_cmd; dev->a_ops.adapter_check_health = aac_rkt_check_health; + /* + * First clear out all interrupts. Then enable the one's that we + * can handle. + */ + rkt_writeb(dev, MUnit.OIMR, 0xff); + rkt_writel(dev, MUnit.ODR, 0xffffffff); + rkt_writeb(dev, MUnit.OIMR, dev->OIMR = 0xfb); + if (aac_init_adapter(dev) == NULL) goto error_irq; /* @@ -438,6 +457,7 @@ error_kfree: kfree(dev->queues); error_irq: + rkt_writeb(dev, MUnit.OIMR, dev->OIMR = 0xff); free_irq(dev->scsi_host_ptr->irq, (void *)dev); error_iounmap: diff --git a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c index 1ff25f49fad..a8459faf87c 100644 --- a/drivers/scsi/aacraid/rx.c +++ b/drivers/scsi/aacraid/rx.c @@ -87,6 +87,16 @@ static irqreturn_t aac_rx_intr(int irq, void *dev_id, struct pt_regs *regs) return IRQ_NONE; } +/** + * aac_rx_disable_interrupt - Disable interrupts + * @dev: Adapter + */ + +static void aac_rx_disable_interrupt(struct aac_dev *dev) +{ + rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xff); +} + /** * rx_sync_cmd - send a command and wait * @dev: Adapter @@ -412,10 +422,19 @@ int aac_rx_init(struct aac_dev *dev) * Fill in the function dispatch table. */ dev->a_ops.adapter_interrupt = aac_rx_interrupt_adapter; + dev->a_ops.adapter_disable_int = aac_rx_disable_interrupt; dev->a_ops.adapter_notify = aac_rx_notify_adapter; dev->a_ops.adapter_sync_cmd = rx_sync_cmd; dev->a_ops.adapter_check_health = aac_rx_check_health; + /* + * First clear out all interrupts. Then enable the one's that we + * can handle. + */ + rx_writeb(dev, MUnit.OIMR, 0xff); + rx_writel(dev, MUnit.ODR, 0xffffffff); + rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xfb); + if (aac_init_adapter(dev) == NULL) goto error_irq; /* @@ -438,6 +457,7 @@ error_kfree: kfree(dev->queues); error_irq: + rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xff); free_irq(dev->scsi_host_ptr->irq, (void *)dev); error_iounmap: diff --git a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c index 0680249ab86..3900abc5850 100644 --- a/drivers/scsi/aacraid/sa.c +++ b/drivers/scsi/aacraid/sa.c @@ -81,6 +81,16 @@ static irqreturn_t aac_sa_intr(int irq, void *dev_id, struct pt_regs *regs) return IRQ_NONE; } +/** + * aac_sa_disable_interrupt - disable interrupt + * @dev: Which adapter to enable. + */ + +static void aac_sa_disable_interrupt (struct aac_dev *dev) +{ + sa_writew(dev, SaDbCSR.PRISETIRQMASK, 0xffff); +} + /** * aac_sa_notify_adapter - handle adapter notification * @dev: Adapter that notification is for @@ -214,9 +224,8 @@ static int sa_sync_cmd(struct aac_dev *dev, u32 command, static void aac_sa_interrupt_adapter (struct aac_dev *dev) { - u32 ret; sa_sync_cmd(dev, BREAKPOINT_REQUEST, 0, 0, 0, 0, 0, 0, - &ret, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL); } /** @@ -352,10 +361,18 @@ int aac_sa_init(struct aac_dev *dev) */ dev->a_ops.adapter_interrupt = aac_sa_interrupt_adapter; + dev->a_ops.adapter_disable_int = aac_sa_disable_interrupt; dev->a_ops.adapter_notify = aac_sa_notify_adapter; dev->a_ops.adapter_sync_cmd = sa_sync_cmd; dev->a_ops.adapter_check_health = aac_sa_check_health; + /* + * First clear out all interrupts. Then enable the one's that + * we can handle. + */ + sa_writew(dev, SaDbCSR.PRISETIRQMASK, 0xffff); + sa_writew(dev, SaDbCSR.PRICLEARIRQMASK, (PrintfReady | DOORBELL_1 | + DOORBELL_2 | DOORBELL_3 | DOORBELL_4)); if(aac_init_adapter(dev) == NULL) goto error_irq; @@ -381,6 +398,7 @@ error_kfree: kfree(dev->queues); error_irq: + sa_writew(dev, SaDbCSR.PRISETIRQMASK, 0xffff); free_irq(dev->scsi_host_ptr->irq, (void *)dev); error_iounmap: -- cgit v1.2.3-18-g5258 From e53cb35aaefb83de695e3fd305b9cfabd5bf8c86 Mon Sep 17 00:00:00 2001 From: Mark Haverkamp Date: Wed, 3 Aug 2005 15:39:09 -0700 Subject: [SCSI] aacraid: remove duplicate io callback code Received from Mark Salyzyn from Adaptec: This patch removes the duplicate code in the write_callback command completion handler, and renames read_callback to io_callback. Optimized the lba calculation into the debug print routine macro to optimize the i/o code path. Signed-off-by: Mark Haverkamp Signed-off-by: James Bottomley --- drivers/scsi/aacraid/aachba.c | 63 +++++-------------------------------------- 1 file changed, 7 insertions(+), 56 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index ccdf440021f..b03c8dee76b 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -814,12 +814,11 @@ int aac_get_adapter_info(struct aac_dev* dev) } -static void read_callback(void *context, struct fib * fibptr) +static void io_callback(void *context, struct fib * fibptr) { struct aac_dev *dev; struct aac_read_reply *readreply; struct scsi_cmnd *scsicmd; - u32 lba; u32 cid; scsicmd = (struct scsi_cmnd *) context; @@ -827,8 +826,7 @@ static void read_callback(void *context, struct fib * fibptr) dev = (struct aac_dev *)scsicmd->device->host->hostdata; cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun); - lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; - dprintk((KERN_DEBUG "read_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), lba, jiffies)); + dprintk((KERN_DEBUG "io_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3], jiffies)); if (fibptr == NULL) BUG(); @@ -847,7 +845,7 @@ static void read_callback(void *context, struct fib * fibptr) scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; else { #ifdef AAC_DETAILED_STATUS_INFO - printk(KERN_WARNING "read_callback: io failed, status = %d\n", + printk(KERN_WARNING "io_callback: io failed, status = %d\n", le32_to_cpu(readreply->status)); #endif scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; @@ -867,53 +865,6 @@ static void read_callback(void *context, struct fib * fibptr) aac_io_done(scsicmd); } -static void write_callback(void *context, struct fib * fibptr) -{ - struct aac_dev *dev; - struct aac_write_reply *writereply; - struct scsi_cmnd *scsicmd; - u32 lba; - u32 cid; - - scsicmd = (struct scsi_cmnd *) context; - dev = (struct aac_dev *)scsicmd->device->host->hostdata; - cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun); - - lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; - dprintk((KERN_DEBUG "write_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), lba, jiffies)); - if (fibptr == NULL) - BUG(); - - if(scsicmd->use_sg) - pci_unmap_sg(dev->pdev, - (struct scatterlist *)scsicmd->buffer, - scsicmd->use_sg, - scsicmd->sc_data_direction); - else if(scsicmd->request_bufflen) - pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle, - scsicmd->request_bufflen, - scsicmd->sc_data_direction); - - writereply = (struct aac_write_reply *) fib_data(fibptr); - if (le32_to_cpu(writereply->status) == ST_OK) - scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; - else { - printk(KERN_WARNING "write_callback: write failed, status = %d\n", writereply->status); - scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; - set_sense((u8 *) &dev->fsa_dev[cid].sense_data, - HARDWARE_ERROR, - SENCODE_INTERNAL_TARGET_FAILURE, - ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, - 0, 0); - memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, - sizeof(struct sense_data)); - } - - fib_complete(fibptr); - fib_free(fibptr); - aac_io_done(scsicmd); -} - static int aac_read(struct scsi_cmnd * scsicmd, int cid) { u32 lba; @@ -978,7 +929,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid) fibsize, FsaNormal, 0, 1, - (fib_callback) read_callback, + (fib_callback) io_callback, (void *) scsicmd); } else { struct aac_read *readcmd; @@ -1002,7 +953,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid) fibsize, FsaNormal, 0, 1, - (fib_callback) read_callback, + (fib_callback) io_callback, (void *) scsicmd); } @@ -1085,7 +1036,7 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid) fibsize, FsaNormal, 0, 1, - (fib_callback) write_callback, + (fib_callback) io_callback, (void *) scsicmd); } else { struct aac_write *writecmd; @@ -1111,7 +1062,7 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid) fibsize, FsaNormal, 0, 1, - (fib_callback) write_callback, + (fib_callback) io_callback, (void *) scsicmd); } -- cgit v1.2.3-18-g5258 From 12a26d0879d8a4502425037e9013b1f64ed669b7 Mon Sep 17 00:00:00 2001 From: Mark Haverkamp Date: Wed, 3 Aug 2005 15:39:25 -0700 Subject: [SCSI] aacraid: aif registration timeout fix Received from Mark Salyzyn from Adaptec: If the Adapter is quiet and does not produce an AIF event packets to be picked up by the management applications for longer than the timeout interval of two minutes, the cleanup code that deals with aging out registrants could erroneously drop the registration. The timeout is there to clean up should the management application die and fail to poll for updated AIF event packets. Moving the timer update from the ioctl code that delivers an AIF to the polling registrant to the bottom of the ioctl means the timeout is reset with any management application polling activity regardless if an AIF is delivered or not removing the erroneous timeout cleanups. Signed-off-by: Mark Haverkamp Signed-off-by: James Bottomley --- drivers/scsi/aacraid/commctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 8fceff9be1b..71f1cad9b5f 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -287,7 +287,6 @@ return_fib: kfree(fib->hw_fib); kfree(fib); status = 0; - fibctx->jiffies = jiffies/HZ; } else { spin_unlock_irqrestore(&dev->fib_lock, flags); if (f.wait) { @@ -302,6 +301,7 @@ return_fib: status = -EAGAIN; } } + fibctx->jiffies = jiffies/HZ; return status; } -- cgit v1.2.3-18-g5258 From 0e68c00373f61fcdee453f6c9878e3390fc0f0ce Mon Sep 17 00:00:00 2001 From: Mark Haverkamp Date: Wed, 3 Aug 2005 15:39:49 -0700 Subject: [SCSI] aacraid: sgraw command support Received from Mark Salyzyn from Adaptec: This patch adds support for the new raw io command. This new command offers much larger io commands, is more friendly to the internal firmware structure requiring less translation efforts by the firmware and offers support for targets greater than 2TB (patch to support >2TB will be sent in the future). Signed-off-by: Mark Haverkamp Signed-off-by: James Bottomley --- drivers/scsi/aacraid/aachba.c | 181 ++++++++++++++++++++++++++++++++++------- drivers/scsi/aacraid/aacraid.h | 43 +++++++++- 2 files changed, 194 insertions(+), 30 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index b03c8dee76b..d6c999cd7f7 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -133,6 +133,7 @@ struct inquiry_data { static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* sgmap); static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* psg); +static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw* psg); static int aac_send_srb_fib(struct scsi_cmnd* scsicmd); #ifdef AAC_DETAILED_STATUS_INFO static char *aac_get_status_string(u32 status); @@ -777,34 +778,36 @@ int aac_get_adapter_info(struct aac_dev* dev) /* * 57 scatter gather elements */ - dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size - - sizeof(struct aac_fibhdr) - - sizeof(struct aac_write) + sizeof(struct sgmap)) / - sizeof(struct sgmap); - if (dev->dac_support) { - /* - * 38 scatter gather elements - */ - dev->scsi_host_ptr->sg_tablesize = - (dev->max_fib_size - + if (!(dev->raw_io_interface)) { + dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size - sizeof(struct aac_fibhdr) - - sizeof(struct aac_write64) + - sizeof(struct sgmap64)) / - sizeof(struct sgmap64); - } - dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT; - if(!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) { - /* - * Worst case size that could cause sg overflow when - * we break up SG elements that are larger than 64KB. - * Would be nice if we could tell the SCSI layer what - * the maximum SG element size can be. Worst case is - * (sg_tablesize-1) 4KB elements with one 64KB - * element. - * 32bit -> 468 or 238KB 64bit -> 424 or 212KB - */ - dev->scsi_host_ptr->max_sectors = - (dev->scsi_host_ptr->sg_tablesize * 8) + 112; + sizeof(struct aac_write) + sizeof(struct sgmap)) / + sizeof(struct sgmap); + if (dev->dac_support) { + /* + * 38 scatter gather elements + */ + dev->scsi_host_ptr->sg_tablesize = + (dev->max_fib_size - + sizeof(struct aac_fibhdr) - + sizeof(struct aac_write64) + + sizeof(struct sgmap64)) / + sizeof(struct sgmap64); + } + dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT; + if(!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) { + /* + * Worst case size that could cause sg overflow when + * we break up SG elements that are larger than 64KB. + * Would be nice if we could tell the SCSI layer what + * the maximum SG element size can be. Worst case is + * (sg_tablesize-1) 4KB elements with one 64KB + * element. + * 32bit -> 468 or 238KB 64bit -> 424 or 212KB + */ + dev->scsi_host_ptr->max_sectors = + (dev->scsi_host_ptr->sg_tablesize * 8) + 112; + } } fib_complete(fibptr); @@ -905,7 +908,32 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid) fib_init(cmd_fibcontext); - if (dev->dac_support == 1) { + if (dev->raw_io_interface) { + struct aac_raw_io *readcmd; + readcmd = (struct aac_raw_io *) fib_data(cmd_fibcontext); + readcmd->block[0] = cpu_to_le32(lba); + readcmd->block[1] = 0; + readcmd->count = cpu_to_le32(count<<9); + readcmd->cid = cpu_to_le16(cid); + readcmd->flags = cpu_to_le16(1); + readcmd->bpTotal = 0; + readcmd->bpComplete = 0; + + aac_build_sgraw(scsicmd, &readcmd->sg); + fibsize = sizeof(struct aac_raw_io) + ((le32_to_cpu(readcmd->sg.count) - 1) * sizeof (struct sgentryraw)); + if (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))) + BUG(); + /* + * Now send the Fib to the adapter + */ + status = fib_send(ContainerRawIo, + cmd_fibcontext, + fibsize, + FsaNormal, + 0, 1, + (fib_callback) io_callback, + (void *) scsicmd); + } else if (dev->dac_support == 1) { struct aac_read64 *readcmd; readcmd = (struct aac_read64 *) fib_data(cmd_fibcontext); readcmd->command = cpu_to_le32(VM_CtHostRead64); @@ -1012,7 +1040,32 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid) } fib_init(cmd_fibcontext); - if(dev->dac_support == 1) { + if (dev->raw_io_interface) { + struct aac_raw_io *writecmd; + writecmd = (struct aac_raw_io *) fib_data(cmd_fibcontext); + writecmd->block[0] = cpu_to_le32(lba); + writecmd->block[1] = 0; + writecmd->count = cpu_to_le32(count<<9); + writecmd->cid = cpu_to_le16(cid); + writecmd->flags = 0; + writecmd->bpTotal = 0; + writecmd->bpComplete = 0; + + aac_build_sgraw(scsicmd, &writecmd->sg); + fibsize = sizeof(struct aac_raw_io) + ((le32_to_cpu(writecmd->sg.count) - 1) * sizeof (struct sgentryraw)); + if (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))) + BUG(); + /* + * Now send the Fib to the adapter + */ + status = fib_send(ContainerRawIo, + cmd_fibcontext, + fibsize, + FsaNormal, + 0, 1, + (fib_callback) io_callback, + (void *) scsicmd); + } else if (dev->dac_support == 1) { struct aac_write64 *writecmd; writecmd = (struct aac_write64 *) fib_data(cmd_fibcontext); writecmd->command = cpu_to_le32(VM_CtHostWrite64); @@ -2028,6 +2081,76 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p return byte_count; } +static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw* psg) +{ + struct Scsi_Host *host = scsicmd->device->host; + struct aac_dev *dev = (struct aac_dev *)host->hostdata; + unsigned long byte_count = 0; + + // Get rid of old data + psg->count = 0; + psg->sg[0].next = 0; + psg->sg[0].prev = 0; + psg->sg[0].addr[0] = 0; + psg->sg[0].addr[1] = 0; + psg->sg[0].count = 0; + psg->sg[0].flags = 0; + if (scsicmd->use_sg) { + struct scatterlist *sg; + int i; + int sg_count; + sg = (struct scatterlist *) scsicmd->request_buffer; + + sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg, + scsicmd->sc_data_direction); + + for (i = 0; i < sg_count; i++) { + int count = sg_dma_len(sg); + u64 addr = sg_dma_address(sg); + psg->sg[i].next = 0; + psg->sg[i].prev = 0; + psg->sg[i].addr[1] = cpu_to_le32((u32)(addr>>32)); + psg->sg[i].addr[0] = cpu_to_le32((u32)(addr & 0xffffffff)); + psg->sg[i].count = cpu_to_le32(count); + psg->sg[i].flags = 0; + byte_count += count; + sg++; + } + psg->count = cpu_to_le32(sg_count); + /* hba wants the size to be exact */ + if(byte_count > scsicmd->request_bufflen){ + u32 temp = le32_to_cpu(psg->sg[i-1].count) - + (byte_count - scsicmd->request_bufflen); + psg->sg[i-1].count = cpu_to_le32(temp); + byte_count = scsicmd->request_bufflen; + } + /* Check for command underflow */ + if(scsicmd->underflow && (byte_count < scsicmd->underflow)){ + printk(KERN_WARNING"aacraid: cmd len %08lX cmd underflow %08X\n", + byte_count, scsicmd->underflow); + } + } + else if(scsicmd->request_bufflen) { + int count; + u64 addr; + scsicmd->SCp.dma_handle = pci_map_single(dev->pdev, + scsicmd->request_buffer, + scsicmd->request_bufflen, + scsicmd->sc_data_direction); + addr = scsicmd->SCp.dma_handle; + count = scsicmd->request_bufflen; + psg->count = cpu_to_le32(1); + psg->sg[0].next = 0; + psg->sg[0].prev = 0; + psg->sg[0].addr[1] = cpu_to_le32((u32)(addr>>32)); + psg->sg[0].addr[0] = cpu_to_le32((u32)(addr & 0xffffffff)); + psg->sg[0].count = cpu_to_le32(count); + psg->sg[0].flags = 0; + byte_count = scsicmd->request_bufflen; + } + return byte_count; +} + #ifdef AAC_DETAILED_STATUS_INFO struct aac_srb_status_info { diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 6f4906ee9a5..bc91e7ce5e5 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -114,6 +114,22 @@ struct user_sgentry64 { u32 count; /* Length. */ }; +struct sgentryraw { + __le32 next; /* reserved for F/W use */ + __le32 prev; /* reserved for F/W use */ + __le32 addr[2]; + __le32 count; + __le32 flags; /* reserved for F/W use */ +}; + +struct user_sgentryraw { + u32 next; /* reserved for F/W use */ + u32 prev; /* reserved for F/W use */ + u32 addr[2]; + u32 count; + u32 flags; /* reserved for F/W use */ +}; + /* * SGMAP * @@ -141,6 +157,16 @@ struct user_sgmap64 { struct user_sgentry64 sg[1]; }; +struct sgmapraw { + __le32 count; + struct sgentryraw sg[1]; +}; + +struct user_sgmapraw { + u32 count; + struct user_sgentryraw sg[1]; +}; + struct creation_info { u8 buildnum; /* e.g., 588 */ @@ -355,6 +381,7 @@ struct hw_fib { */ #define ContainerCommand 500 #define ContainerCommand64 501 +#define ContainerRawIo 502 /* * Cluster Commands */ @@ -986,6 +1013,9 @@ struct aac_dev u8 nondasd_support; u8 dac_support; u8 raid_scsi_mode; + /* macro side-effects BEWARE */ +# define raw_io_interface \ + init->InitStructRevision==cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION_4) u8 printf_enabled; }; @@ -1164,6 +1194,17 @@ struct aac_write_reply __le32 committed; }; +struct aac_raw_io +{ + __le32 block[2]; + __le32 count; + __le16 cid; + __le16 flags; /* 00 W, 01 R */ + __le16 bpTotal; /* reserved for F/W use */ + __le16 bpComplete; /* reserved for F/W use */ + struct sgmapraw sg; +}; + #define CT_FLUSH_CACHE 129 struct aac_synchronize { __le32 command; /* VM_ContainerConfig */ @@ -1204,7 +1245,7 @@ struct aac_srb }; /* - * This and assocated data structs are used by the + * This and associated data structs are used by the * ioctl caller and are in cpu order. */ struct user_aac_srb -- cgit v1.2.3-18-g5258 From a2ae85df80a5b996a05d6d2ffc9bf97797e93ec6 Mon Sep 17 00:00:00 2001 From: "akpm@osdl.org" Date: Sat, 6 Aug 2005 23:32:07 -0700 Subject: [SCSI] aic79xx: needs to select SPI_TRANSPORT_ATTRS without it you get this failure: drivers/built-in.o(.text+0xdcccd): In function `ahd_linux_slave_configure': drivers/scsi/aic7xxx/aic79xx_osm.c:636: undefined reference to `spi_dv_device' drivers/built-in.o(.text+0xdd7b1): In function `ahd_send_async': drivers/scsi/aic7xxx/aic79xx_osm.c:1652: undefined reference to `spi_display_xfer_agreement' drivers/built-in.o(.init.text+0x7b4d): In function `ahd_linux_init': drivers/scsi/aic7xxx/aic79xx_osm.c:2765: undefined reference to `spi_attach_transport' drivers/built-in.o(.init.text+0x7c94):drivers/scsi/aic7xxx/aic79xx_osm.c:2774: undefined reference to `spi_release_transport' drivers/built-in.o(.exit.text+0x72c): In function `ahd_linux_exit': drivers/scsi/aic7xxx/aic79xx_osm.c:2783: undefined reference to `spi_release_transport' Signed-off-by: Andrew Morton Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/Kconfig.aic79xx | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/Kconfig.aic79xx b/drivers/scsi/aic7xxx/Kconfig.aic79xx index c2523a30a7f..69ed77fcb71 100644 --- a/drivers/scsi/aic7xxx/Kconfig.aic79xx +++ b/drivers/scsi/aic7xxx/Kconfig.aic79xx @@ -5,6 +5,7 @@ config SCSI_AIC79XX tristate "Adaptec AIC79xx U320 support" depends on PCI && SCSI + select SCSI_SPI_ATTRS help This driver supports all of Adaptec's Ultra 320 PCI-X based SCSI controllers. -- cgit v1.2.3-18-g5258 From 5262d0851cc6692390ee1aa2c55f57f3bfd0a7c7 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Fri, 5 Aug 2005 16:31:35 -0500 Subject: [SCSI] aacraid: correct use of cmd->timeout field The cmd->timeout field has been obsolete for a while now. While looking to remove it, I came across this use in the aacraid driver. It looks like you want to initialise the firmware with the current timeout of the command (in seconds), so the value I think you should be using is cmd->timeout_per_command. Acked by: Mark Haverkamp Acked by: Mark Salyzyn Signed-off-by: James Bottomley --- drivers/scsi/aacraid/aachba.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index d6c999cd7f7..8e349358729 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1898,7 +1898,7 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd) srbcmd->id = cpu_to_le32(scsicmd->device->id); srbcmd->lun = cpu_to_le32(scsicmd->device->lun); srbcmd->flags = cpu_to_le32(flag); - timeout = (scsicmd->timeout-jiffies)/HZ; + timeout = scsicmd->timeout_per_command/HZ; if(timeout == 0){ timeout = 1; } -- cgit v1.2.3-18-g5258 From f03a567054fea4f9d43c50ec91338266c0bd588d Mon Sep 17 00:00:00 2001 From: Kai Makisara Date: Tue, 2 Aug 2005 13:40:47 +0300 Subject: [SCSI] drivers/scsi/st.c: add reference count and related fixes I have rediffed the patch against 2.6.13-rc5, done a couple of cosmetic cleanups, and run some tests. Brian King has acknowledged that it fixes the problems he has seen. Seems mature enough for inclusion into 2.6.14 (or later)? Nate's explanation of the changes: I've attached patches against 2.6.13rc2. These are basically identical to my earlier patches, as I found that all issues I'd seen in earlier kernels still existed in this kernel. To summarize, the changes are: (more details in my original email) - add a kref to the scsi_tape structure, and associate reference counting stuff - set sr_request->end_io = blk_end_sync_rq so we get notified when an IO is rejected when the device goes away - check rq_status when IOs complete, else we don't know that IOs rejected for a dead device in fact did not complete - change last_SRpnt so it's set before an async IO is issued (in case st_sleep_done is bypassed) - fix a bogus use of last_SRpnt in st_chk_result Signed-off-by: Nate Dailey Signed-off-by: Kai Makisara Signed-off-by: James Bottomley --- drivers/scsi/st.c | 150 +++++++++++++++++++++++++++++++++++++++++++----------- drivers/scsi/st.h | 3 +- 2 files changed, 123 insertions(+), 30 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 0291a8fb654..47a5698a712 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -17,7 +17,7 @@ Last modified: 18-JAN-1998 Richard Gooch Devfs support */ -static char *verstr = "20050501"; +static char *verstr = "20050802"; #include @@ -219,6 +219,12 @@ static int switch_partition(struct scsi_tape *); static int st_int_ioctl(struct scsi_tape *, unsigned int, unsigned long); +static void scsi_tape_release(struct kref *); + +#define to_scsi_tape(obj) container_of(obj, struct scsi_tape, kref) + +static DECLARE_MUTEX(st_ref_sem); + #include "osst_detect.h" #ifndef SIGS_FROM_OSST @@ -230,6 +236,46 @@ static int st_int_ioctl(struct scsi_tape *, unsigned int, unsigned long); {"OnStream", "FW-", "", "osst"} #endif +static struct scsi_tape *scsi_tape_get(int dev) +{ + struct scsi_tape *STp = NULL; + + down(&st_ref_sem); + write_lock(&st_dev_arr_lock); + + if (dev < st_dev_max && scsi_tapes != NULL) + STp = scsi_tapes[dev]; + if (!STp) goto out; + + kref_get(&STp->kref); + + if (!STp->device) + goto out_put; + + if (scsi_device_get(STp->device)) + goto out_put; + + goto out; + +out_put: + kref_put(&STp->kref, scsi_tape_release); + STp = NULL; +out: + write_unlock(&st_dev_arr_lock); + up(&st_ref_sem); + return STp; +} + +static void scsi_tape_put(struct scsi_tape *STp) +{ + struct scsi_device *sdev = STp->device; + + down(&st_ref_sem); + kref_put(&STp->kref, scsi_tape_release); + scsi_device_put(sdev); + up(&st_ref_sem); +} + struct st_reject_data { char *vendor; char *model; @@ -311,7 +357,7 @@ static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt) return 0; cmdstatp = &STp->buffer->cmdstat; - st_analyze_sense(STp->buffer->last_SRpnt, cmdstatp); + st_analyze_sense(SRpnt, cmdstatp); if (cmdstatp->have_sense) scode = STp->buffer->cmdstat.sense_hdr.sense_key; @@ -399,10 +445,10 @@ static void st_sleep_done(struct scsi_cmnd * SCpnt) (STp->buffer)->cmdstat.midlevel_result = SCpnt->result; SCpnt->request->rq_status = RQ_SCSI_DONE; - (STp->buffer)->last_SRpnt = SCpnt->sc_request; DEB( STp->write_pending = 0; ) - complete(SCpnt->request->waiting); + if (SCpnt->request->waiting) + complete(SCpnt->request->waiting); } /* Do the scsi command. Waits until command performed if do_wait is true. @@ -412,8 +458,20 @@ static struct scsi_request * st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd, int bytes, int direction, int timeout, int retries, int do_wait) { + struct completion *waiting; unsigned char *bp; + /* if async, make sure there's no command outstanding */ + if (!do_wait && ((STp->buffer)->last_SRpnt)) { + printk(KERN_ERR "%s: Async command already active.\n", + tape_name(STp)); + if (signal_pending(current)) + (STp->buffer)->syscall_result = (-EINTR); + else + (STp->buffer)->syscall_result = (-EBUSY); + return NULL; + } + if (SRpnt == NULL) { SRpnt = scsi_allocate_request(STp->device, GFP_ATOMIC); if (SRpnt == NULL) { @@ -427,7 +485,13 @@ st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *c } } - init_completion(&STp->wait); + /* If async IO, set last_SRpnt. This ptr tells write_behind_check + which IO is outstanding. It's nulled out when the IO completes. */ + if (!do_wait) + (STp->buffer)->last_SRpnt = SRpnt; + + waiting = &STp->wait; + init_completion(waiting); SRpnt->sr_use_sg = STp->buffer->do_dio || (bytes > (STp->buffer)->frp[0].length); if (SRpnt->sr_use_sg) { if (!STp->buffer->do_dio) @@ -438,17 +502,20 @@ st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *c bp = (STp->buffer)->b_data; SRpnt->sr_data_direction = direction; SRpnt->sr_cmd_len = 0; - SRpnt->sr_request->waiting = &(STp->wait); + SRpnt->sr_request->waiting = waiting; SRpnt->sr_request->rq_status = RQ_SCSI_BUSY; SRpnt->sr_request->rq_disk = STp->disk; + SRpnt->sr_request->end_io = blk_end_sync_rq; STp->buffer->cmdstat.have_sense = 0; scsi_do_req(SRpnt, (void *) cmd, bp, bytes, st_sleep_done, timeout, retries); if (do_wait) { - wait_for_completion(SRpnt->sr_request->waiting); + wait_for_completion(waiting); SRpnt->sr_request->waiting = NULL; + if (SRpnt->sr_request->rq_status != RQ_SCSI_DONE) + SRpnt->sr_result |= (DRIVER_ERROR << 24); (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt); } return SRpnt; @@ -465,6 +532,7 @@ static int write_behind_check(struct scsi_tape * STp) struct st_buffer *STbuffer; struct st_partstat *STps; struct st_cmdstatus *cmdstatp; + struct scsi_request *SRpnt; STbuffer = STp->buffer; if (!STbuffer->writing) @@ -478,10 +546,14 @@ static int write_behind_check(struct scsi_tape * STp) ) /* end DEB */ wait_for_completion(&(STp->wait)); - (STp->buffer)->last_SRpnt->sr_request->waiting = NULL; + SRpnt = STbuffer->last_SRpnt; + STbuffer->last_SRpnt = NULL; + SRpnt->sr_request->waiting = NULL; + if (SRpnt->sr_request->rq_status != RQ_SCSI_DONE) + SRpnt->sr_result |= (DRIVER_ERROR << 24); - (STp->buffer)->syscall_result = st_chk_result(STp, (STp->buffer)->last_SRpnt); - scsi_release_request((STp->buffer)->last_SRpnt); + (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt); + scsi_release_request(SRpnt); STbuffer->buffer_bytes -= STbuffer->writing; STps = &(STp->ps[STp->partition]); @@ -1055,25 +1127,20 @@ static int st_open(struct inode *inode, struct file *filp) */ filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); + if (!(STp = scsi_tape_get(dev))) + return -ENXIO; + write_lock(&st_dev_arr_lock); - if (dev >= st_dev_max || scsi_tapes == NULL || - ((STp = scsi_tapes[dev]) == NULL)) { - write_unlock(&st_dev_arr_lock); - return (-ENXIO); - } filp->private_data = STp; name = tape_name(STp); if (STp->in_use) { write_unlock(&st_dev_arr_lock); + scsi_tape_put(STp); DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) return (-EBUSY); } - if(scsi_device_get(STp->device)) { - write_unlock(&st_dev_arr_lock); - return (-ENXIO); - } STp->in_use = 1; write_unlock(&st_dev_arr_lock); STp->rew_at_close = STp->autorew_dev = (iminor(inode) & 0x80) == 0; @@ -1118,7 +1185,7 @@ static int st_open(struct inode *inode, struct file *filp) err_out: normalize_buffer(STp->buffer); STp->in_use = 0; - scsi_device_put(STp->device); + scsi_tape_put(STp); return retval; } @@ -1250,7 +1317,7 @@ static int st_release(struct inode *inode, struct file *filp) write_lock(&st_dev_arr_lock); STp->in_use = 0; write_unlock(&st_dev_arr_lock); - scsi_device_put(STp->device); + scsi_tape_put(STp); return result; } @@ -3887,6 +3954,7 @@ static int st_probe(struct device *dev) goto out_put_disk; } memset(tpnt, 0, sizeof(struct scsi_tape)); + kref_init(&tpnt->kref); tpnt->disk = disk; sprintf(disk->disk_name, "st%d", i); disk->private_data = &tpnt->driver; @@ -3902,6 +3970,7 @@ static int st_probe(struct device *dev) tpnt->tape_type = MT_ISSCSI2; tpnt->buffer = buffer; + tpnt->buffer->last_SRpnt = NULL; tpnt->inited = 0; tpnt->dirty = 0; @@ -4076,15 +4145,10 @@ static int st_remove(struct device *dev) tpnt->modes[mode].cdevs[j] = NULL; } } - tpnt->device = NULL; - if (tpnt->buffer) { - tpnt->buffer->orig_frp_segs = 0; - normalize_buffer(tpnt->buffer); - kfree(tpnt->buffer); - } - put_disk(tpnt->disk); - kfree(tpnt); + down(&st_ref_sem); + kref_put(&tpnt->kref, scsi_tape_release); + up(&st_ref_sem); return 0; } } @@ -4093,6 +4157,34 @@ static int st_remove(struct device *dev) return 0; } +/** + * scsi_tape_release - Called to free the Scsi_Tape structure + * @kref: pointer to embedded kref + * + * st_ref_sem must be held entering this routine. Because it is + * called on last put, you should always use the scsi_tape_get() + * scsi_tape_put() helpers which manipulate the semaphore directly + * and never do a direct kref_put(). + **/ +static void scsi_tape_release(struct kref *kref) +{ + struct scsi_tape *tpnt = to_scsi_tape(kref); + struct gendisk *disk = tpnt->disk; + + tpnt->device = NULL; + + if (tpnt->buffer) { + tpnt->buffer->orig_frp_segs = 0; + normalize_buffer(tpnt->buffer); + kfree(tpnt->buffer); + } + + disk->private_data = NULL; + put_disk(disk); + kfree(tpnt); + return; +} + static void st_intr(struct scsi_cmnd *SCpnt) { scsi_io_completion(SCpnt, (SCpnt->result ? 0: SCpnt->bufflen), 1); diff --git a/drivers/scsi/st.h b/drivers/scsi/st.h index 061da111398..790acac160b 100644 --- a/drivers/scsi/st.h +++ b/drivers/scsi/st.h @@ -3,7 +3,7 @@ #define _ST_H #include - +#include /* Descriptor for analyzed sense data */ struct st_cmdstatus { @@ -156,6 +156,7 @@ struct scsi_tape { unsigned char last_sense[16]; #endif struct gendisk *disk; + struct kref kref; }; /* Bit masks for use_pf */ -- cgit v1.2.3-18-g5258 From b21a41385118f9a6af3cd96ce71090c5ada52eb5 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Fri, 5 Aug 2005 21:45:40 -0500 Subject: [SCSI] add global timeout to the scsi mid-layer There are certain rogue devices (and the aic7xxx driver) that return BUSY or QUEUE_FULL forever. This code will apply a global timeout (of the total number of retries times the per command timer) to a given command. If it is exceeded, the command is completed regardless of its state. The patch also removes the unused field in the command: timeout and timeout_total. This solves the problem of detecting an endless loop in the mid-layer because of BUSY/QUEUE_FULL bouncing, but will not recover the device. In the aic7xxx case, the driver can be recovered by sending a bus reset, so possibly this should be tied into the error handler? Signed-off-by: James Bottomley --- drivers/scsi/advansys.c | 4 ++-- drivers/scsi/scsi.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index 0fb93363eb2..37ec5411e32 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -9200,8 +9200,8 @@ asc_prt_scsi_cmnd(struct scsi_cmnd *s) (unsigned) s->serial_number, s->retries, s->allowed); printk( -" timeout_per_command %d, timeout_total %d, timeout %d\n", - s->timeout_per_command, s->timeout_total, s->timeout); +" timeout_per_command %d\n", + s->timeout_per_command); printk( " scsi_done 0x%lx, done 0x%lx, host_scribble 0x%lx, result 0x%x\n", diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index d1aa95d45a7..4befbc275f9 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -268,6 +268,7 @@ struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, int gfp_mask) } else put_device(&dev->sdev_gendev); + cmd->jiffies_at_alloc = jiffies; return cmd; } EXPORT_SYMBOL(scsi_get_command); @@ -798,9 +799,23 @@ static void scsi_softirq(struct softirq_action *h) while (!list_empty(&local_q)) { struct scsi_cmnd *cmd = list_entry(local_q.next, struct scsi_cmnd, eh_entry); + /* The longest time any command should be outstanding is the + * per command timeout multiplied by the number of retries. + * + * For a typical command, this is 2.5 minutes */ + unsigned long wait_for + = cmd->allowed * cmd->timeout_per_command; list_del_init(&cmd->eh_entry); disposition = scsi_decide_disposition(cmd); + if (disposition != SUCCESS && + time_before(cmd->jiffies_at_alloc + wait_for, jiffies)) { + dev_printk(KERN_ERR, &cmd->device->sdev_gendev, + "timing out command, waited %ds\n", + wait_for/HZ); + disposition = SUCCESS; + } + scsi_log_completion(cmd, disposition); switch (disposition) { case SUCCESS: -- cgit v1.2.3-18-g5258 From 8e87c2f118d40d2dc2f5d0140818e8cd023b13e1 Mon Sep 17 00:00:00 2001 From: Mark Haverkamp Date: Mon, 8 Aug 2005 14:20:43 -0700 Subject: [SCSI] aacraid: adapter support update Received from Mark Salyzyn This patch adds the product ID for the ICP9067MA adapter. The entries for the ICP9085LI, ICP5085BR, IBM8k & ASR4810SAS were incorrect and would not initialize the adapters correctly. Signed-off-by: Mark Haverkamp Signed-off-by: James Bottomley --- drivers/scsi/aacraid/linit.c | 72 ++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 33 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 41255f7893d..2bd59426788 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -120,36 +120,39 @@ static struct pci_device_id aac_pci_tbl[] = { { 0x9005, 0x0286, 0x9005, 0x02a3, 0, 0, 29 }, /* ICP5085AU (Hurricane) */ { 0x9005, 0x0285, 0x9005, 0x02a4, 0, 0, 30 }, /* ICP9085LI (Marauder-X) */ { 0x9005, 0x0285, 0x9005, 0x02a5, 0, 0, 31 }, /* ICP5085BR (Marauder-E) */ - { 0x9005, 0x0287, 0x9005, 0x0800, 0, 0, 32 }, /* Themisto Jupiter Platform */ - { 0x9005, 0x0200, 0x9005, 0x0200, 0, 0, 32 }, /* Themisto Jupiter Platform */ - { 0x9005, 0x0286, 0x9005, 0x0800, 0, 0, 33 }, /* Callisto Jupiter Platform */ - { 0x9005, 0x0285, 0x9005, 0x028e, 0, 0, 34 }, /* ASR-2020SA SATA PCI-X ZCR (Skyhawk) */ - { 0x9005, 0x0285, 0x9005, 0x028f, 0, 0, 35 }, /* ASR-2025SA SATA SO-DIMM PCI-X ZCR (Terminator) */ - { 0x9005, 0x0285, 0x9005, 0x0290, 0, 0, 36 }, /* AAR-2410SA PCI SATA 4ch (Jaguar II) */ - { 0x9005, 0x0285, 0x1028, 0x0291, 0, 0, 37 }, /* CERC SATA RAID 2 PCI SATA 6ch (DellCorsair) */ - { 0x9005, 0x0285, 0x9005, 0x0292, 0, 0, 38 }, /* AAR-2810SA PCI SATA 8ch (Corsair-8) */ - { 0x9005, 0x0285, 0x9005, 0x0293, 0, 0, 39 }, /* AAR-21610SA PCI SATA 16ch (Corsair-16) */ - { 0x9005, 0x0285, 0x9005, 0x0294, 0, 0, 40 }, /* ESD SO-DIMM PCI-X SATA ZCR (Prowler) */ - { 0x9005, 0x0285, 0x103C, 0x3227, 0, 0, 41 }, /* AAR-2610SA PCI SATA 6ch */ - { 0x9005, 0x0285, 0x9005, 0x0296, 0, 0, 42 }, /* ASR-2240S (SabreExpress) */ - { 0x9005, 0x0285, 0x9005, 0x0297, 0, 0, 43 }, /* ASR-4005SAS */ - { 0x9005, 0x0285, 0x1014, 0x02F2, 0, 0, 44 }, /* IBM 8i (AvonPark) */ - { 0x9005, 0x0285, 0x1014, 0x0312, 0, 0, 44 }, /* IBM 8i (AvonPark Lite) */ - { 0x9005, 0x0285, 0x9005, 0x0298, 0, 0, 45 }, /* ASR-4000SAS (BlackBird) */ - { 0x9005, 0x0285, 0x9005, 0x0299, 0, 0, 46 }, /* ASR-4800SAS (Marauder-X) */ - { 0x9005, 0x0285, 0x9005, 0x029a, 0, 0, 47 }, /* ASR-4805SAS (Marauder-E) */ - { 0x9005, 0x0286, 0x9005, 0x02a2, 0, 0, 48 }, /* ASR-4810SAS (Hurricane */ - - { 0x9005, 0x0285, 0x1028, 0x0287, 0, 0, 49 }, /* Perc 320/DC*/ - { 0x1011, 0x0046, 0x9005, 0x0365, 0, 0, 50 }, /* Adaptec 5400S (Mustang)*/ - { 0x1011, 0x0046, 0x9005, 0x0364, 0, 0, 51 }, /* Adaptec 5400S (Mustang)*/ - { 0x1011, 0x0046, 0x9005, 0x1364, 0, 0, 52 }, /* Dell PERC2/QC */ - { 0x1011, 0x0046, 0x103c, 0x10c2, 0, 0, 53 }, /* HP NetRAID-4M */ - - { 0x9005, 0x0285, 0x1028, PCI_ANY_ID, 0, 0, 54 }, /* Dell Catchall */ - { 0x9005, 0x0285, 0x17aa, PCI_ANY_ID, 0, 0, 55 }, /* Legend Catchall */ - { 0x9005, 0x0285, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 56 }, /* Adaptec Catch All */ - { 0x9005, 0x0286, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 57 }, /* Adaptec Rocket Catch All */ + { 0x9005, 0x0286, 0x9005, 0x02a6, 0, 0, 32 }, /* ICP9067MA (Intruder-6) */ + { 0x9005, 0x0287, 0x9005, 0x0800, 0, 0, 33 }, /* Themisto Jupiter Platform */ + { 0x9005, 0x0200, 0x9005, 0x0200, 0, 0, 33 }, /* Themisto Jupiter Platform */ + { 0x9005, 0x0286, 0x9005, 0x0800, 0, 0, 34 }, /* Callisto Jupiter Platform */ + { 0x9005, 0x0285, 0x9005, 0x028e, 0, 0, 35 }, /* ASR-2020SA SATA PCI-X ZCR (Skyhawk) */ + { 0x9005, 0x0285, 0x9005, 0x028f, 0, 0, 36 }, /* ASR-2025SA SATA SO-DIMM PCI-X ZCR (Terminator) */ + { 0x9005, 0x0285, 0x9005, 0x0290, 0, 0, 37 }, /* AAR-2410SA PCI SATA 4ch (Jaguar II) */ + { 0x9005, 0x0285, 0x1028, 0x0291, 0, 0, 38 }, /* CERC SATA RAID 2 PCI SATA 6ch (DellCorsair) */ + { 0x9005, 0x0285, 0x9005, 0x0292, 0, 0, 39 }, /* AAR-2810SA PCI SATA 8ch (Corsair-8) */ + { 0x9005, 0x0285, 0x9005, 0x0293, 0, 0, 40 }, /* AAR-21610SA PCI SATA 16ch (Corsair-16) */ + { 0x9005, 0x0285, 0x9005, 0x0294, 0, 0, 41 }, /* ESD SO-DIMM PCI-X SATA ZCR (Prowler) */ + { 0x9005, 0x0285, 0x103C, 0x3227, 0, 0, 42 }, /* AAR-2610SA PCI SATA 6ch */ + { 0x9005, 0x0285, 0x9005, 0x0296, 0, 0, 43 }, /* ASR-2240S (SabreExpress) */ + { 0x9005, 0x0285, 0x9005, 0x0297, 0, 0, 44 }, /* ASR-4005SAS */ + { 0x9005, 0x0285, 0x1014, 0x02F2, 0, 0, 45 }, /* IBM 8i (AvonPark) */ + { 0x9005, 0x0285, 0x1014, 0x0312, 0, 0, 45 }, /* IBM 8i (AvonPark Lite) */ + { 0x9005, 0x0286, 0x1014, 0x9580, 0, 0, 46 }, /* IBM 8k/8k-l8 (Aurora) */ + { 0x9005, 0x0286, 0x1014, 0x9540, 0, 0, 47 }, /* IBM 8k/8k-l4 (Aurora Lite) */ + { 0x9005, 0x0285, 0x9005, 0x0298, 0, 0, 48 }, /* ASR-4000SAS (BlackBird) */ + { 0x9005, 0x0285, 0x9005, 0x0299, 0, 0, 49 }, /* ASR-4800SAS (Marauder-X) */ + { 0x9005, 0x0285, 0x9005, 0x029a, 0, 0, 50 }, /* ASR-4805SAS (Marauder-E) */ + { 0x9005, 0x0286, 0x9005, 0x02a2, 0, 0, 51 }, /* ASR-4810SAS (Hurricane */ + + { 0x9005, 0x0285, 0x1028, 0x0287, 0, 0, 52 }, /* Perc 320/DC*/ + { 0x1011, 0x0046, 0x9005, 0x0365, 0, 0, 53 }, /* Adaptec 5400S (Mustang)*/ + { 0x1011, 0x0046, 0x9005, 0x0364, 0, 0, 54 }, /* Adaptec 5400S (Mustang)*/ + { 0x1011, 0x0046, 0x9005, 0x1364, 0, 0, 55 }, /* Dell PERC2/QC */ + { 0x1011, 0x0046, 0x103c, 0x10c2, 0, 0, 56 }, /* HP NetRAID-4M */ + + { 0x9005, 0x0285, 0x1028, PCI_ANY_ID, 0, 0, 57 }, /* Dell Catchall */ + { 0x9005, 0x0285, 0x17aa, PCI_ANY_ID, 0, 0, 58 }, /* Legend Catchall */ + { 0x9005, 0x0285, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 59 }, /* Adaptec Catch All */ + { 0x9005, 0x0286, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 60 }, /* Adaptec Rocket Catch All */ { 0,} }; MODULE_DEVICE_TABLE(pci, aac_pci_tbl); @@ -191,8 +194,9 @@ static struct aac_driver_ident aac_drivers[] = { { aac_rkt_init, "aacraid", "ICP ", "ICP9047MA ", 1 }, /* ICP9047MA (Lancer) */ { aac_rkt_init, "aacraid", "ICP ", "ICP9087MA ", 1 }, /* ICP9087MA (Lancer) */ { aac_rkt_init, "aacraid", "ICP ", "ICP5085AU ", 1 }, /* ICP5085AU (Hurricane) */ - { aac_rkt_init, "aacraid", "ICP ", "ICP9085LI ", 1 }, /* ICP9085LI (Marauder-X) */ - { aac_rkt_init, "aacraid", "ICP ", "ICP5085BR ", 1 }, /* ICP5085BR (Marauder-E) */ + { aac_rx_init, "aacraid", "ICP ", "ICP9085LI ", 1 }, /* ICP9085LI (Marauder-X) */ + { aac_rx_init, "aacraid", "ICP ", "ICP5085BR ", 1 }, /* ICP5085BR (Marauder-E) */ + { aac_rkt_init, "aacraid", "ICP ", "ICP9067MA ", 1 }, /* ICP9067MA (Intruder-6) */ { NULL , "aacraid", "ADAPTEC ", "Themisto ", 0, AAC_QUIRK_SLAVE }, /* Jupiter Platform */ { aac_rkt_init, "aacraid", "ADAPTEC ", "Callisto ", 2, AAC_QUIRK_MASTER }, /* Jupiter Platform */ { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2020SA ", 1 }, /* ASR-2020SA SATA PCI-X ZCR (Skyhawk) */ @@ -206,10 +210,12 @@ static struct aac_driver_ident aac_drivers[] = { { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2240S ", 1 }, /* ASR-2240S (SabreExpress) */ { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-4005SAS ", 1 }, /* ASR-4005SAS */ { aac_rx_init, "ServeRAID","IBM ", "ServeRAID 8i ", 1 }, /* IBM 8i (AvonPark) */ + { aac_rkt_init, "ServeRAID","IBM ", "ServeRAID 8k-l8 ", 1 }, /* IBM 8k/8k-l8 (Aurora) */ + { aac_rkt_init, "ServeRAID","IBM ", "ServeRAID 8k-l4 ", 1 }, /* IBM 8k/8k-l4 (Aurora Lite) */ { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-4000SAS ", 1 }, /* ASR-4000SAS (BlackBird & AvonPark) */ { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-4800SAS ", 1 }, /* ASR-4800SAS (Marauder-X) */ { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-4805SAS ", 1 }, /* ASR-4805SAS (Marauder-E) */ - { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-4810SAS ", 1 }, /* ASR-4810SAS (Hurricane) */ + { aac_rkt_init, "aacraid", "ADAPTEC ", "ASR-4810SAS ", 1 }, /* ASR-4810SAS (Hurricane) */ { aac_rx_init, "percraid", "DELL ", "PERC 320/DC ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Perc 320/DC*/ { aac_sa_init, "aacraid", "ADAPTEC ", "Adaptec 5400S ", 4, AAC_QUIRK_34SG }, /* Adaptec 5400S (Mustang)*/ -- cgit v1.2.3-18-g5258 From 0d7323c865608dffb1ed39ec2f3841697ec3e009 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Mon, 8 Aug 2005 19:01:43 -0400 Subject: [SCSI] blacklist addition. When run on a kernel that scans all LUNs, a certain crappy scsi scanner reports the same LUN over and over.. https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=155457 Aparently they were so shamed by this, they chose to remain anonymous. Though it seems the blacklist code handles anonymous vendors just fine. Signed-off-by: Dave Jones Signed-off-by: James Bottomley --- drivers/scsi/scsi_devinfo.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index 6121dc1bfad..d9963a848d9 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -114,6 +114,7 @@ static struct { {"YAMAHA", "CDR102", "1.00", BLIST_NOLUN}, /* locks up */ {"YAMAHA", "CRW8424S", "1.0", BLIST_NOLUN}, /* locks up */ {"YAMAHA", "CRW6416S", "1.0c", BLIST_NOLUN}, /* locks up */ + {"", "Scanner", "1.80", BLIST_NOLUN}, /* responds to all lun */ /* * Other types of devices that have special flags. -- cgit v1.2.3-18-g5258 From a80b3424d9fde3c4b6d62adaf6dda78128dc5c27 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Mon, 8 Aug 2005 19:06:50 -0500 Subject: [SCSI] aic79xx: fix boot panic with no hardware There's a spurious (and illegal since it's marked __exit) call to ahc_linux_exit() in ahc_linux_init() which causes a double list deletion of the transport class; remove it. Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_osm.c | 4 +--- drivers/scsi/aic7xxx/aic7xxx_osm.c | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index acaeebd5046..2f158624c5d 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -2326,8 +2326,6 @@ done: return (retval); } -static void ahd_linux_exit(void); - static void ahd_linux_set_width(struct scsi_target *starget, int width) { struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); @@ -2772,7 +2770,7 @@ ahd_linux_init(void) if (ahd_linux_detect(&aic79xx_driver_template) > 0) return 0; spi_release_transport(ahd_linux_transport_template); - ahd_linux_exit(); + return -ENODEV; } diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 3fbc10e58cc..22434849de4 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -2335,8 +2335,6 @@ ahc_platform_dump_card_state(struct ahc_softc *ahc) { } -static void ahc_linux_exit(void); - static void ahc_linux_set_width(struct scsi_target *starget, int width) { struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); -- cgit v1.2.3-18-g5258 From dbec486632d2303f5c0e75af7a8473fa4c4a145a Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 10 Aug 2005 20:44:50 +0200 Subject: kconfig: move initramfs options to General Setup Move initramfs options from Device Drivers | Block Drivers to General Setup This is a more natural place for this option. Furthermore separate out intramfs options to usr/Kconfig Signed-off-by: Sam Ravnborg --- drivers/block/Kconfig | 42 ------------------------------------------ 1 file changed, 42 deletions(-) (limited to 'drivers') diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index b594768b024..7cd7bf35d02 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -408,48 +408,6 @@ config BLK_DEV_INITRD "real" root file system, etc. See for details. -config INITRAMFS_SOURCE - string "Initramfs source file(s)" - default "" - help - This can be either a single cpio archive with a .cpio suffix or a - space-separated list of directories and files for building the - initramfs image. A cpio archive should contain a filesystem archive - to be used as an initramfs image. Directories should contain a - filesystem layout to be included in the initramfs image. Files - should contain entries according to the format described by the - "usr/gen_init_cpio" program in the kernel tree. - - When multiple directories and files are specified then the - initramfs image will be the aggregate of all of them. - - See 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 --- drivers/acpi/ec.c | 169 +++++++++++++++++++----------------------------------- 1 file changed, 59 insertions(+), 110 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 1ac5731d45e..31067a0a367 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 v1.2.3-18-g5258 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 --- drivers/acpi/ec.c | 869 ++++++++++++++++++++++++------------------------------ 1 file changed, 389 insertions(+), 480 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 31067a0a367..7e1a445955b 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 v1.2.3-18-g5258 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 --- drivers/char/agp/generic.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index f0079e991bd..eb052427670 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 v1.2.3-18-g5258 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 --- drivers/acpi/glue.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 1943461489c..e36c5da2b31 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 v1.2.3-18-g5258 From 507caac75e86bd041c5462e5e988fb7138e21d79 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Tue, 9 Aug 2005 12:57:11 -0500 Subject: [SCSI] Make the HSG80 a REPORTLUN2 device From: Steve Wilcox In order to properly report LUN's > 7, the DEC HSG80 definition in scsi_devinfo.c needs to include BLIST_REPORTLUN2 rather than BLIST_SPARSELUN. I've tested this change with several HSG firmware revisions and with both Emulex and Qlogic HBA's. Signed-off-by: James Bottomley --- drivers/scsi/scsi_devinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index d9963a848d9..b444ec2e1c6 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -136,7 +136,7 @@ static struct { {"COMPAQ", "MSA1000 VOLUME", NULL, BLIST_SPARSELUN | BLIST_NOSTARTONADD}, {"COMPAQ", "HSV110", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD}, {"DDN", "SAN DataDirector", "*", BLIST_SPARSELUN}, - {"DEC", "HSG80", NULL, BLIST_SPARSELUN | BLIST_NOSTARTONADD}, + {"DEC", "HSG80", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD}, {"DELL", "PV660F", NULL, BLIST_SPARSELUN}, {"DELL", "PV660F PSEUDO", NULL, BLIST_SPARSELUN}, {"DELL", "PSEUDO DEVICE .", NULL, BLIST_SPARSELUN}, /* Dell PV 530F */ -- cgit v1.2.3-18-g5258 From 483f05f0134e60b724bc3678507c1def860c56d5 Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Wed, 10 Aug 2005 15:02:45 -0400 Subject: [SCSI] lpfc driver 8.0.30 : fix iocb reuse initialization IOCB BDE not getting fully initialized during reuse Symptoms: Driver gets Status 3 and Reason 0x13 on IOCB completions. Cause: The IOCB bpl.bdeSize and bdeFlags are not getting initialized on reuse. Fix: Reinitialize these fields in prep_dma each time an IOCB is used. Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_scsi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 17e4974d444..7cb1e467734 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -238,6 +238,8 @@ lpfc_scsi_prep_dma_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * lpfc_cmd) bpl->tus.f.bdeSize = scsi_cmnd->request_bufflen; if (datadir == DMA_TO_DEVICE) bpl->tus.f.bdeFlags = 0; + else + bpl->tus.f.bdeFlags = BUFF_USE_RCV; bpl->tus.w = le32_to_cpu(bpl->tus.w); num_bde = 1; bpl++; @@ -245,8 +247,11 @@ lpfc_scsi_prep_dma_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * lpfc_cmd) /* * Finish initializing those IOCB fields that are dependent on the - * scsi_cmnd request_buffer + * scsi_cmnd request_buffer. Note that the bdeSize is explicitly + * reinitialized since all iocb memory resources are used many times + * for transmit, receive, and continuation bpl's. */ + iocb_cmd->un.fcpi64.bdl.bdeSize = (2 * sizeof (struct ulp_bde64)); iocb_cmd->un.fcpi64.bdl.bdeSize += (num_bde * sizeof (struct ulp_bde64)); iocb_cmd->ulpBdeCount = 1; -- cgit v1.2.3-18-g5258 From 8cbdc5fffa15d5c573e2531c6f533822d08b6b0f Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Wed, 10 Aug 2005 15:02:50 -0400 Subject: [SCSI] lpfc driver 8.0.30 : fix lip/cablepull panic Fix panic on lip and cable pull Symptoms: Panic on lip or cable pull Cause: Use after free of nlp in lpfc_nlp_remove() Fix: Do not make FC transport calls after a node is removed. Transport calls are disabled by ignoring the initial delete transition. Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_hbadisc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 233901e9dfd..2e44824a3bd 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -1135,6 +1135,8 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list) switch(list) { case NLP_NO_LIST: /* No list, just remove it */ lpfc_nlp_remove(phba, nlp); + /* as node removed - stop further transport calls */ + rport_del = none; break; case NLP_UNUSED_LIST: spin_lock_irq(phba->host->host_lock); -- cgit v1.2.3-18-g5258 From 69859dc47744430ecda16522b0791b6d17e3fa93 Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Wed, 10 Aug 2005 15:02:37 -0400 Subject: [SCSI] lpfc driver 8.0.30 : task mgmt bit clearing Clear task management bits when preparing SCSI commands In lpfc_scsi_prep_cmnd, clear the task management bits (fcpCntl2 member in the fcp_cmd structure) when preparing regular SCSI commands. Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_scsi.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 7cb1e467734..15e747faaa5 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -450,6 +450,8 @@ lpfc_scsi_prep_cmnd(struct lpfc_hba * phba, struct lpfc_scsi_buf * lpfc_cmd, int datadir = scsi_cmnd->sc_data_direction; lpfc_cmd->fcp_rsp->rspSnsLen = 0; + /* clear task management bits */ + lpfc_cmd->fcp_cmnd->fcpCntl2 = 0; lpfc_put_lun(lpfc_cmd->fcp_cmnd, lpfc_cmd->pCmd->device->lun); -- cgit v1.2.3-18-g5258 From f888ba3ce77c66bece3d804caf7d559838209a4a Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Wed, 10 Aug 2005 15:03:01 -0400 Subject: [SCSI] lpfc driver 8.0.30 : fix get_stats panic Fix panic in lpfc_get_stats() Symptoms: Panic on sysfs stats access Cause: In lpfc_get_stats() we are writing to memory that we do not own. Fix: Fix our stats structure allocation. Embed phba->link_stats in struct lpfc_hba and stop treating it like rogue structure. Note: Embedding midlayer/transport structure in our structure caused need for more files to include midlayer/transport headers. Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc.h | 5 ++--- drivers/scsi/lpfc/lpfc_attr.c | 5 +++-- drivers/scsi/lpfc/lpfc_ct.c | 1 + drivers/scsi/lpfc/lpfc_init.c | 4 +--- drivers/scsi/lpfc/lpfc_mbox.c | 3 +++ drivers/scsi/lpfc/lpfc_mem.c | 3 +++ drivers/scsi/lpfc/lpfc_sli.c | 1 + 7 files changed, 14 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index 3bb82aae432..adb95674823 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -342,9 +342,6 @@ struct lpfc_hba { #define VPD_MASK 0xf /* mask for any vpd data */ struct timer_list els_tmofunc; - - void *link_stats; - /* * stat counters */ @@ -370,6 +367,8 @@ struct lpfc_hba { struct list_head freebufList; struct list_head ctrspbuflist; struct list_head rnidrspbuflist; + + struct fc_host_statistics link_stats; }; diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 3cea9288301..f37b7642c59 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -988,8 +988,7 @@ lpfc_get_stats(struct Scsi_Host *shost) { struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0]; struct lpfc_sli *psli = &phba->sli; - struct fc_host_statistics *hs = - (struct fc_host_statistics *)phba->link_stats; + struct fc_host_statistics *hs = &phba->link_stats; LPFC_MBOXQ_t *pmboxq; MAILBOX_t *pmb; int rc=0; @@ -1020,6 +1019,8 @@ lpfc_get_stats(struct Scsi_Host *shost) return NULL; } + memset(hs, 0, sizeof (struct fc_host_statistics)); + hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; hs->tx_words = (pmb->un.varRdStatus.xmitByteCnt * 256); hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index 78adee4699a..b3880eca2f3 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -29,6 +29,7 @@ #include #include +#include #include "lpfc_hw.h" #include "lpfc_sli.h" diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 34d416d2b00..1b6d1dcdabb 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -1339,14 +1339,12 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) if (pci_request_regions(pdev, LPFC_DRIVER_NAME)) goto out_disable_device; - host = scsi_host_alloc(&lpfc_template, - sizeof (struct lpfc_hba) + sizeof (unsigned long)); + host = scsi_host_alloc(&lpfc_template, sizeof (struct lpfc_hba)); if (!host) goto out_release_regions; phba = (struct lpfc_hba*)host->hostdata; memset(phba, 0, sizeof (struct lpfc_hba)); - phba->link_stats = (void *)&phba[1]; phba->host = host; phba->fc_flag |= FC_LOADING; diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c index c27cf94795d..afcd54d51f1 100644 --- a/drivers/scsi/lpfc/lpfc_mbox.c +++ b/drivers/scsi/lpfc/lpfc_mbox.c @@ -23,6 +23,9 @@ #include #include +#include +#include + #include "lpfc_hw.h" #include "lpfc_sli.h" #include "lpfc_disc.h" diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c index a5cfb6421fa..034a8bfa9ac 100644 --- a/drivers/scsi/lpfc/lpfc_mem.c +++ b/drivers/scsi/lpfc/lpfc_mem.c @@ -23,6 +23,9 @@ #include #include +#include +#include + #include "lpfc_hw.h" #include "lpfc_sli.h" #include "lpfc_disc.h" diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 1775508ed27..e027f470810 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "lpfc_hw.h" #include "lpfc_sli.h" -- cgit v1.2.3-18-g5258 From ea84c3f74df646a0897e95c78147190517a751a9 Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Wed, 10 Aug 2005 15:02:30 -0400 Subject: [SCSI] lpfc driver 8.0.30 : dev_loss and nodev timeouts Fix handling of the dev_loss and nodev timeouts. Symptoms: when remote port disappears for a period of time longer then either nodev_tmo or dev_loss_tmo, the lpfc driver worker thread will stall removing that remote port. Cause: removing remote port involves un-blocking and sync-ing corresponding block device queue. But corresponding node in the lpfc driver is still in the NPR(?node port recovery?) state and mid-layer gets SCSI_MLQUEUE_HOST_BUSY as a return value when it is trying to call queuecommand() with command for that node (AKA remote port) Fix: Instead of returning SCSI_MLQUEUE_HOST_BUS from queuecommand() for nodes in NPR states complete it with retry-able error code DID_BUS_BUSY Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_scsi.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 15e747faaa5..4be506a33a2 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -753,6 +753,10 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) cmnd->result = ScsiResult(DID_NO_CONNECT, 0); goto out_fail_command; } + else if (ndlp->nlp_state == NLP_STE_NPR_NODE) { + cmnd->result = ScsiResult(DID_BUS_BUSY, 0); + goto out_fail_command; + } /* * The device is most likely recovered and the driver * needs a bit more time to finish. Ask the midlayer -- cgit v1.2.3-18-g5258 From 918865230e55b1fece2d8edec39d46c00626590b Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Wed, 10 Aug 2005 15:03:09 -0400 Subject: [SCSI] lpfc driver 8.0.30 : convert to use of int_to_scsilun() Replace use of lpfc_put_lun with midlayer's int_to_scsilun Remove driver's local definition of lpfc_put_lun (which converts an int back to a 64-bit LUN) and replace it's use with the recently added int_to_scsilun function provided by the midlayer. Note: Embedding midlayer structure in our structure caused need for more files to include midlayer headers. Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_attr.c | 1 + drivers/scsi/lpfc/lpfc_ct.c | 1 + drivers/scsi/lpfc/lpfc_els.c | 1 + drivers/scsi/lpfc/lpfc_hbadisc.c | 1 + drivers/scsi/lpfc/lpfc_init.c | 1 + drivers/scsi/lpfc/lpfc_mbox.c | 2 ++ drivers/scsi/lpfc/lpfc_mem.c | 2 ++ drivers/scsi/lpfc/lpfc_nportdisc.c | 1 + drivers/scsi/lpfc/lpfc_scsi.c | 11 ++++------- drivers/scsi/lpfc/lpfc_scsi.h | 13 +------------ drivers/scsi/lpfc/lpfc_sli.c | 1 + 11 files changed, 16 insertions(+), 19 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index f37b7642c59..0e089a42c03 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index b3880eca2f3..1280f0e5463 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 2b1c9572dae..63caf7fe972 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 2e44824a3bd..0a8269d6b13 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 1b6d1dcdabb..6f3cb59bf9e 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c index afcd54d51f1..73eb89f9159 100644 --- a/drivers/scsi/lpfc/lpfc_mbox.c +++ b/drivers/scsi/lpfc/lpfc_mbox.c @@ -26,6 +26,8 @@ #include #include +#include + #include "lpfc_hw.h" #include "lpfc_sli.h" #include "lpfc_disc.h" diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c index 034a8bfa9ac..0aba13ceaac 100644 --- a/drivers/scsi/lpfc/lpfc_mem.c +++ b/drivers/scsi/lpfc/lpfc_mem.c @@ -26,6 +26,8 @@ #include #include +#include + #include "lpfc_hw.h" #include "lpfc_sli.h" #include "lpfc_disc.h" diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c index 45dc0210fc4..9b35eaac781 100644 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 4be506a33a2..b5ad1871d34 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -40,11 +40,6 @@ #define LPFC_RESET_WAIT 2 #define LPFC_ABORT_WAIT 2 -static inline void lpfc_put_lun(struct fcp_cmnd *fcmd, unsigned int lun) -{ - fcmd->fcpLunLsl = 0; - fcmd->fcpLunMsl = swab16((uint16_t)lun); -} /* * This routine allocates a scsi buffer, which contains all the necessary @@ -453,7 +448,8 @@ lpfc_scsi_prep_cmnd(struct lpfc_hba * phba, struct lpfc_scsi_buf * lpfc_cmd, /* clear task management bits */ lpfc_cmd->fcp_cmnd->fcpCntl2 = 0; - lpfc_put_lun(lpfc_cmd->fcp_cmnd, lpfc_cmd->pCmd->device->lun); + int_to_scsilun(lpfc_cmd->pCmd->device->lun, + &lpfc_cmd->fcp_cmnd->fcp_lun); memcpy(&fcp_cmnd->fcpCdb[0], scsi_cmnd->cmnd, 16); @@ -552,7 +548,8 @@ lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_hba *phba, piocb = &piocbq->iocb; fcp_cmnd = lpfc_cmd->fcp_cmnd; - lpfc_put_lun(lpfc_cmd->fcp_cmnd, lpfc_cmd->pCmd->device->lun); + int_to_scsilun(lpfc_cmd->pCmd->device->lun, + &lpfc_cmd->fcp_cmnd->fcp_lun); fcp_cmnd->fcpCntl2 = task_mgmt_cmd; piocb->ulpCommand = CMD_FCP_ICMND64_CR; diff --git a/drivers/scsi/lpfc/lpfc_scsi.h b/drivers/scsi/lpfc/lpfc_scsi.h index 0fd9ba14e1b..acd64c49e84 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.h +++ b/drivers/scsi/lpfc/lpfc_scsi.h @@ -78,18 +78,7 @@ struct fcp_rsp { }; struct fcp_cmnd { - uint32_t fcpLunMsl; /* most significant lun word (32 bits) */ - uint32_t fcpLunLsl; /* least significant lun word (32 bits) */ - /* # of bits to shift lun id to end up in right - * payload word, little endian = 8, big = 16. - */ -#ifdef __BIG_ENDIAN -#define FC_LUN_SHIFT 16 -#define FC_ADDR_MODE_SHIFT 24 -#else /* __LITTLE_ENDIAN */ -#define FC_LUN_SHIFT 8 -#define FC_ADDR_MODE_SHIFT 0 -#endif + struct scsi_lun fcp_lun; uint8_t fcpCntl0; /* FCP_CNTL byte 0 (reserved) */ uint8_t fcpCntl1; /* FCP_CNTL byte 1 task codes */ diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index e027f470810..e74e224fd77 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include -- cgit v1.2.3-18-g5258 From 9909b79e3d533b422c6c72945da35aef124dbce1 Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Wed, 10 Aug 2005 15:03:17 -0400 Subject: [SCSI] lpfc driver 8.0.30 : update version to 8.0.30 Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h index 47dea48ee0e..7e6747b06f9 100644 --- a/drivers/scsi/lpfc/lpfc_version.h +++ b/drivers/scsi/lpfc/lpfc_version.h @@ -18,7 +18,7 @@ * included with this package. * *******************************************************************/ -#define LPFC_DRIVER_VERSION "8.0.29" +#define LPFC_DRIVER_VERSION "8.0.30" #define LPFC_DRIVER_NAME "lpfc" -- cgit v1.2.3-18-g5258 From 6becdff3bcaff1b89c392cf0630dcb5759704492 Mon Sep 17 00:00:00 2001 From: "akpm@osdl.org" Date: Tue, 9 Aug 2005 00:17:03 -0700 Subject: [SCSI] fix warning in scsi_softirq From: Andrew Morton drivers/scsi/scsi.c: In function `scsi_softirq': drivers/scsi/scsi.c:814: warning: int format, long int arg (arg 4) Signed-off-by: Andrew Morton Signed-off-by: James Bottomley --- drivers/scsi/scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 4befbc275f9..a780546eda9 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -811,7 +811,7 @@ static void scsi_softirq(struct softirq_action *h) if (disposition != SUCCESS && time_before(cmd->jiffies_at_alloc + wait_for, jiffies)) { dev_printk(KERN_ERR, &cmd->device->sdev_gendev, - "timing out command, waited %ds\n", + "timing out command, waited %lus\n", wait_for/HZ); disposition = SUCCESS; } -- cgit v1.2.3-18-g5258 From 0336ee5aed1f9a5a6a04e3deabd7797dc193ccd3 Mon Sep 17 00:00:00 2001 From: "akpm@osdl.org" Date: Mon, 8 Aug 2005 21:49:48 -0700 Subject: [SCSI] fix warning in aic7770.c From: "Martin J. Bligh" drivers/scsi/aic7xxx/aic7770.c: In function `aic7770_config': drivers/scsi/aic7xxx/aic7770.c:129: warning: unused variable `l' Signed-off-by: Andrew Morton Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic7770.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic7770.c b/drivers/scsi/aic7xxx/aic7770.c index 00f3bd1e181..527efd36f5c 100644 --- a/drivers/scsi/aic7xxx/aic7770.c +++ b/drivers/scsi/aic7xxx/aic7770.c @@ -126,7 +126,6 @@ aic7770_find_device(uint32_t id) int aic7770_config(struct ahc_softc *ahc, struct aic7770_identity *entry, u_int io) { - u_long l; int error; int have_seeprom; u_int hostconf; -- cgit v1.2.3-18-g5258 From 3a4f5c60dbe1978580ea03c1aff353d1e63d1638 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sat, 13 Aug 2005 09:42:45 -0500 Subject: [SCSI] aic7xxx: lost multifunction flags handling From: Christoph Hellwig Multi-function cards need to inherit the PCI flags from the master PCI device. Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic7xxx_osm_pci.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c index 9d318ce2c99..0d44a6907dd 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c @@ -149,6 +149,27 @@ ahc_linux_pci_dev_remove(struct pci_dev *pdev) ahc_free(ahc); } +static void +ahc_linux_pci_inherit_flags(struct ahc_softc *ahc) +{ + struct pci_dev *pdev = ahc->dev_softc, *master_pdev; + unsigned int master_devfn = PCI_DEVFN(PCI_SLOT(pdev->devfn), 0); + + master_pdev = pci_get_slot(pdev->bus, master_devfn); + if (master_pdev) { + struct ahc_softc *master = pci_get_drvdata(master_pdev); + if (master) { + ahc->flags &= ~AHC_BIOS_ENABLED; + ahc->flags |= master->flags & AHC_BIOS_ENABLED; + + ahc->flags &= ~AHC_PRIMARY_CHANNEL; + ahc->flags |= master->flags & AHC_PRIMARY_CHANNEL; + } else + printk(KERN_ERR "aic7xxx: no multichannel peer found!\n"); + pci_dev_put(master_pdev); + } +} + static int ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -203,6 +224,14 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ahc_free(ahc); return (-error); } + + /* + * Second Function PCI devices need to inherit some + * settings from function 0. + */ + if ((ahc->features & AHC_MULTI_FUNC) && PCI_FUNC(pdev->devfn) != 0) + ahc_linux_pci_inherit_flags(ahc); + pci_set_drvdata(pdev, ahc); ahc_linux_register_host(ahc, &aic7xxx_driver_template); return (0); -- cgit v1.2.3-18-g5258 From 10c1b88987d618f4f89c10e11e574c76de73b5e7 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 14 Aug 2005 14:34:06 -0500 Subject: [SCSI] add ability to deny binding to SPI transport class This patch is necessary if we begin exposing underlying physical disks (which can attach to the SPI transport class) of the hardware RAID cards, since we don't want any SPI parameters binding to the RAID devices. Signed-off-by: James Bottomley --- drivers/scsi/scsi_transport_spi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index e7b9570c818..02134fce217 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -1082,6 +1082,7 @@ static int spi_device_match(struct attribute_container *cont, { struct scsi_device *sdev; struct Scsi_Host *shost; + struct spi_internal *i; if (!scsi_is_sdev_device(dev)) return 0; @@ -1094,6 +1095,9 @@ static int spi_device_match(struct attribute_container *cont, /* Note: this class has no device attributes, so it has * no per-HBA allocation and thus we don't need to distinguish * the attribute containers for the device */ + i = to_spi_internal(shost->transportt); + if (i->f->deny_binding && i->f->deny_binding(sdev->sdev_target)) + return 0; return 1; } @@ -1101,6 +1105,7 @@ static int spi_target_match(struct attribute_container *cont, struct device *dev) { struct Scsi_Host *shost; + struct scsi_target *starget; struct spi_internal *i; if (!scsi_is_target_device(dev)) @@ -1112,7 +1117,11 @@ static int spi_target_match(struct attribute_container *cont, return 0; i = to_spi_internal(shost->transportt); - + starget = to_scsi_target(dev); + + if (i->f->deny_binding && i->f->deny_binding(starget)) + return 0; + return &i->t.target_attrs.ac == cont; } -- cgit v1.2.3-18-g5258 From d0a7e574007fd547d72ec693bfa35778623d0738 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 14 Aug 2005 17:09:01 -0500 Subject: [SCSI] correct transport class abstraction to work outside SCSI I recently tried to construct a totally generic transport class and found there were certain features missing from the current abstract transport class. Most notable is that you have to hang the data on the class_device but most of the API is framed in terms of the generic device, not the class_device. These changes are two fold - Provide the class_device to all of the setup and configure APIs - Provide and extra API to take the device and the attribute class and return the corresponding class_device Signed-off-by: James Bottomley --- drivers/base/attribute_container.c | 38 ++++++++++++++++++++++++++++++++++++++ drivers/base/transport_class.c | 17 +++++++++++------ drivers/scsi/scsi_transport_fc.c | 6 ++++-- drivers/scsi/scsi_transport_spi.c | 11 ++++++++--- 4 files changed, 61 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c index ec615d854be..62c093db11e 100644 --- a/drivers/base/attribute_container.c +++ b/drivers/base/attribute_container.c @@ -58,6 +58,7 @@ attribute_container_register(struct attribute_container *cont) { INIT_LIST_HEAD(&cont->node); INIT_LIST_HEAD(&cont->containers); + spin_lock_init(&cont->containers_lock); down(&attribute_container_mutex); list_add_tail(&cont->node, &attribute_container_list); @@ -77,11 +78,13 @@ attribute_container_unregister(struct attribute_container *cont) { int retval = -EBUSY; down(&attribute_container_mutex); + spin_lock(&cont->containers_lock); if (!list_empty(&cont->containers)) goto out; retval = 0; list_del(&cont->node); out: + spin_unlock(&cont->containers_lock); up(&attribute_container_mutex); return retval; @@ -151,7 +154,9 @@ attribute_container_add_device(struct device *dev, fn(cont, dev, &ic->classdev); else attribute_container_add_class_device(&ic->classdev); + spin_lock(&cont->containers_lock); list_add_tail(&ic->node, &cont->containers); + spin_unlock(&cont->containers_lock); } up(&attribute_container_mutex); } @@ -189,6 +194,7 @@ attribute_container_remove_device(struct device *dev, if (!cont->match(cont, dev)) continue; + spin_lock(&cont->containers_lock); list_for_each_entry_safe(ic, tmp, &cont->containers, node) { if (dev != ic->classdev.dev) continue; @@ -200,6 +206,7 @@ attribute_container_remove_device(struct device *dev, class_device_unregister(&ic->classdev); } } + spin_unlock(&cont->containers_lock); } up(&attribute_container_mutex); } @@ -230,10 +237,12 @@ attribute_container_device_trigger(struct device *dev, if (!cont->match(cont, dev)) continue; + spin_lock(&cont->containers_lock); list_for_each_entry_safe(ic, tmp, &cont->containers, node) { if (dev == ic->classdev.dev) fn(cont, dev, &ic->classdev); } + spin_unlock(&cont->containers_lock); } up(&attribute_container_mutex); } @@ -368,6 +377,35 @@ attribute_container_class_device_del(struct class_device *classdev) } EXPORT_SYMBOL_GPL(attribute_container_class_device_del); +/** + * attribute_container_find_class_device - find the corresponding class_device + * + * @cont: the container + * @dev: the generic device + * + * Looks up the device in the container's list of class devices and returns + * the corresponding class_device. + */ +struct class_device * +attribute_container_find_class_device(struct attribute_container *cont, + struct device *dev) +{ + struct class_device *cdev = NULL; + struct internal_container *ic; + + spin_lock(&cont->containers_lock); + list_for_each_entry(ic, &cont->containers, node) { + if (ic->classdev.dev == dev) { + cdev = &ic->classdev; + break; + } + } + spin_unlock(&cont->containers_lock); + + return cdev; +} +EXPORT_SYMBOL_GPL(attribute_container_find_class_device); + int __init attribute_container_init(void) { diff --git a/drivers/base/transport_class.c b/drivers/base/transport_class.c index 6c2b447a333..4fb4c5de847 100644 --- a/drivers/base/transport_class.c +++ b/drivers/base/transport_class.c @@ -64,7 +64,9 @@ void transport_class_unregister(struct transport_class *tclass) } EXPORT_SYMBOL_GPL(transport_class_unregister); -static int anon_transport_dummy_function(struct device *dev) +static int anon_transport_dummy_function(struct transport_container *tc, + struct device *dev, + struct class_device *cdev) { /* do nothing */ return 0; @@ -115,9 +117,10 @@ static int transport_setup_classdev(struct attribute_container *cont, struct class_device *classdev) { struct transport_class *tclass = class_to_transport_class(cont->class); + struct transport_container *tcont = attribute_container_to_transport_container(cont); if (tclass->setup) - tclass->setup(dev); + tclass->setup(tcont, dev, classdev); return 0; } @@ -178,12 +181,14 @@ void transport_add_device(struct device *dev) EXPORT_SYMBOL_GPL(transport_add_device); static int transport_configure(struct attribute_container *cont, - struct device *dev) + struct device *dev, + struct class_device *cdev) { struct transport_class *tclass = class_to_transport_class(cont->class); + struct transport_container *tcont = attribute_container_to_transport_container(cont); if (tclass->configure) - tclass->configure(dev); + tclass->configure(tcont, dev, cdev); return 0; } @@ -202,7 +207,7 @@ static int transport_configure(struct attribute_container *cont, */ void transport_configure_device(struct device *dev) { - attribute_container_trigger(dev, transport_configure); + attribute_container_device_trigger(dev, transport_configure); } EXPORT_SYMBOL_GPL(transport_configure_device); @@ -215,7 +220,7 @@ static int transport_remove_classdev(struct attribute_container *cont, struct transport_class *tclass = class_to_transport_class(cont->class); if (tclass->remove) - tclass->remove(dev); + tclass->remove(tcont, dev, classdev); if (tclass->remove != anon_transport_dummy_function) { if (tcont->statistics) diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 35d1c1e8e34..96243c7fe11 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c @@ -252,7 +252,8 @@ struct fc_internal { #define to_fc_internal(tmpl) container_of(tmpl, struct fc_internal, t) -static int fc_target_setup(struct device *dev) +static int fc_target_setup(struct transport_container *tc, struct device *dev, + struct class_device *cdev) { struct scsi_target *starget = to_scsi_target(dev); struct fc_rport *rport = starget_to_rport(starget); @@ -281,7 +282,8 @@ static DECLARE_TRANSPORT_CLASS(fc_transport_class, NULL, NULL); -static int fc_host_setup(struct device *dev) +static int fc_host_setup(struct transport_container *tc, struct device *dev, + struct class_device *cdev) { struct Scsi_Host *shost = dev_to_shost(dev); diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 02134fce217..89f6b7feb9c 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -162,7 +162,8 @@ static inline enum spi_signal_type spi_signal_to_value(const char *name) return SPI_SIGNAL_UNKNOWN; } -static int spi_host_setup(struct device *dev) +static int spi_host_setup(struct transport_container *tc, struct device *dev, + struct class_device *cdev) { struct Scsi_Host *shost = dev_to_shost(dev); @@ -196,7 +197,9 @@ static int spi_host_match(struct attribute_container *cont, return &i->t.host_attrs.ac == cont; } -static int spi_device_configure(struct device *dev) +static int spi_device_configure(struct transport_container *tc, + struct device *dev, + struct class_device *cdev) { struct scsi_device *sdev = to_scsi_device(dev); struct scsi_target *starget = sdev->sdev_target; @@ -214,7 +217,9 @@ static int spi_device_configure(struct device *dev) return 0; } -static int spi_setup_transport_attrs(struct device *dev) +static int spi_setup_transport_attrs(struct transport_container *tc, + struct device *dev, + struct class_device *cdev) { struct scsi_target *starget = to_scsi_target(dev); -- cgit v1.2.3-18-g5258 From d46b1d549e1414d673e0ec18219f4f5e30d5f3f5 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 15 Aug 2005 13:27:39 +0200 Subject: [SCSI] aic79xx: remove some dead code remove some dead cruft, as done already in aic7xxx Signed-off-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_osm.h | 35 ---------------------------------- drivers/scsi/aic7xxx/aic79xx_osm_pci.c | 3 --- 2 files changed, 38 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h index 46edcf3e4e6..296d3a59efe 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.h +++ b/drivers/scsi/aic7xxx/aic79xx_osm.h @@ -254,39 +254,8 @@ ahd_scb_timer_reset(struct scb *scb, u_int usec) /***************************** SMP support ************************************/ #include -#define AHD_SCSI_HAS_HOST_LOCK 1 - #define AIC79XX_DRIVER_VERSION "1.3.11" -/**************************** Front End Queues ********************************/ -/* - * Data structure used to cast the Linux struct scsi_cmnd to something - * that allows us to use the queue macros. The linux structure has - * plenty of space to hold the links fields as required by the queue - * macros, but the queue macors require them to have the correct type. - */ -struct ahd_cmd_internal { - /* Area owned by the Linux scsi layer. */ - uint8_t private[offsetof(struct scsi_cmnd, SCp.Status)]; - union { - STAILQ_ENTRY(ahd_cmd) ste; - LIST_ENTRY(ahd_cmd) le; - TAILQ_ENTRY(ahd_cmd) tqe; - } links; - uint32_t end; -}; - -struct ahd_cmd { - union { - struct ahd_cmd_internal icmd; - struct scsi_cmnd scsi_cmd; - } un; -}; - -#define acmd_icmd(cmd) ((cmd)->un.icmd) -#define acmd_scsi_cmd(cmd) ((cmd)->un.scsi_cmd) -#define acmd_links un.icmd.links - /*************************** Device Data Structures ***************************/ /* * A per probed device structure used to deal with some error recovery @@ -297,13 +266,10 @@ struct ahd_cmd { */ typedef enum { - AHD_DEV_UNCONFIGURED = 0x01, AHD_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */ - AHD_DEV_TIMER_ACTIVE = 0x04, /* Our timer is active */ AHD_DEV_Q_BASIC = 0x10, /* Allow basic device queuing */ AHD_DEV_Q_TAGGED = 0x20, /* Allow full SCSI2 command queueing */ AHD_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */ - AHD_DEV_SLAVE_CONFIGURED = 0x80 /* slave_configure() has been called */ } ahd_linux_dev_flags; struct ahd_linux_target; @@ -432,7 +398,6 @@ struct ahd_platform_data { uint32_t irq; /* IRQ for this adapter */ uint32_t bios_address; uint32_t mem_busaddr; /* Mem Base Addr */ - uint64_t hw_dma_mask; #define AHD_SCB_UP_EH_SEM 0x1 uint32_t flags; }; diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c index 91daf0c7fb1..7cfb2eb2b86 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c @@ -177,15 +177,12 @@ ahd_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (memsize >= 0x8000000000ULL && pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) { ahd->flags |= AHD_64BIT_ADDRESSING; - ahd->platform_data->hw_dma_mask = DMA_64BIT_MASK; } else if (memsize > 0x80000000 && pci_set_dma_mask(pdev, mask_39bit) == 0) { ahd->flags |= AHD_39BIT_ADDRESSING; - ahd->platform_data->hw_dma_mask = mask_39bit; } } else { pci_set_dma_mask(pdev, DMA_32BIT_MASK); - ahd->platform_data->hw_dma_mask = DMA_32BIT_MASK; } ahd->dev_softc = pci; error = ahd_pci_config(ahd, entry); -- cgit v1.2.3-18-g5258 From 85a46523ff68aa0e4d2477c51075ffd9fc7e7a14 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 15 Aug 2005 13:28:46 +0200 Subject: [SCSI] aic79xx: sane pci probing remove ahd_tailq and do sane pci probing. ported over from aic7xxx. Signed-off-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx.h | 6 -- drivers/scsi/aic7xxx/aic79xx_core.c | 103 +------------------------------ drivers/scsi/aic7xxx/aic79xx_osm.c | 108 ++++++--------------------------- drivers/scsi/aic7xxx/aic79xx_osm.h | 30 --------- drivers/scsi/aic7xxx/aic79xx_osm_pci.c | 79 +++++++++++------------- drivers/scsi/aic7xxx/aic79xx_pci.c | 14 +---- drivers/scsi/aic7xxx/aic79xx_proc.c | 11 +--- 7 files changed, 60 insertions(+), 291 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h index fd4b2f3eb0c..653fb0b42ae 100644 --- a/drivers/scsi/aic7xxx/aic79xx.h +++ b/drivers/scsi/aic7xxx/aic79xx.h @@ -1247,9 +1247,6 @@ struct ahd_softc { uint16_t user_tagenable;/* Tagged Queuing allowed */ }; -TAILQ_HEAD(ahd_softc_tailq, ahd_softc); -extern struct ahd_softc_tailq ahd_tailq; - /*************************** IO Cell Configuration ****************************/ #define AHD_PRECOMP_SLEW_INDEX \ (AHD_ANNEXCOL_PRECOMP_SLEW - AHD_ANNEXCOL_PER_DEV0) @@ -1374,8 +1371,6 @@ void ahd_enable_coalescing(struct ahd_softc *ahd, void ahd_pause_and_flushwork(struct ahd_softc *ahd); int ahd_suspend(struct ahd_softc *ahd); int ahd_resume(struct ahd_softc *ahd); -void ahd_softc_insert(struct ahd_softc *); -struct ahd_softc *ahd_find_softc(struct ahd_softc *ahd); void ahd_set_unit(struct ahd_softc *, int); void ahd_set_name(struct ahd_softc *, char *); struct scb *ahd_get_scb(struct ahd_softc *ahd, u_int col_idx); @@ -1524,7 +1519,6 @@ void ahd_print_scb(struct scb *scb); void ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo); void ahd_dump_sglist(struct scb *scb); -void ahd_dump_all_cards_state(void); void ahd_dump_card_state(struct ahd_softc *ahd); int ahd_print_register(ahd_reg_parse_entry_t *table, u_int num_entries, diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c index d69bbffb34a..4e8f00df978 100644 --- a/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/drivers/scsi/aic7xxx/aic79xx_core.c @@ -52,8 +52,6 @@ #include #endif -/******************************** Globals *************************************/ -struct ahd_softc_tailq ahd_tailq = TAILQ_HEAD_INITIALIZER(ahd_tailq); /***************************** Lookup Tables **********************************/ char *ahd_chip_names[] = @@ -5179,74 +5177,6 @@ ahd_softc_init(struct ahd_softc *ahd) return (0); } -void -ahd_softc_insert(struct ahd_softc *ahd) -{ - struct ahd_softc *list_ahd; - -#if AHD_PCI_CONFIG > 0 - /* - * Second Function PCI devices need to inherit some - * settings from function 0. - */ - if ((ahd->features & AHD_MULTI_FUNC) != 0) { - TAILQ_FOREACH(list_ahd, &ahd_tailq, links) { - ahd_dev_softc_t list_pci; - ahd_dev_softc_t pci; - - list_pci = list_ahd->dev_softc; - pci = ahd->dev_softc; - if (ahd_get_pci_slot(list_pci) == ahd_get_pci_slot(pci) - && ahd_get_pci_bus(list_pci) == ahd_get_pci_bus(pci)) { - struct ahd_softc *master; - struct ahd_softc *slave; - - if (ahd_get_pci_function(list_pci) == 0) { - master = list_ahd; - slave = ahd; - } else { - master = ahd; - slave = list_ahd; - } - slave->flags &= ~AHD_BIOS_ENABLED; - slave->flags |= - master->flags & AHD_BIOS_ENABLED; - break; - } - } - } -#endif - - /* - * Insertion sort into our list of softcs. - */ - list_ahd = TAILQ_FIRST(&ahd_tailq); - while (list_ahd != NULL - && ahd_softc_comp(ahd, list_ahd) <= 0) - list_ahd = TAILQ_NEXT(list_ahd, links); - if (list_ahd != NULL) - TAILQ_INSERT_BEFORE(list_ahd, ahd, links); - else - TAILQ_INSERT_TAIL(&ahd_tailq, ahd, links); - ahd->init_level++; -} - -/* - * Verify that the passed in softc pointer is for a - * controller that is still configured. - */ -struct ahd_softc * -ahd_find_softc(struct ahd_softc *ahd) -{ - struct ahd_softc *list_ahd; - - TAILQ_FOREACH(list_ahd, &ahd_tailq, links) { - if (list_ahd == ahd) - return (ahd); - } - return (NULL); -} - void ahd_set_unit(struct ahd_softc *ahd, int unit) { @@ -7902,18 +7832,10 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset) static void ahd_reset_poll(void *arg) { - struct ahd_softc *ahd; + struct ahd_softc *ahd = arg; u_int scsiseq1; - u_long l; u_long s; - ahd_list_lock(&l); - ahd = ahd_find_softc((struct ahd_softc *)arg); - if (ahd == NULL) { - printf("ahd_reset_poll: Instance %p no longer exists\n", arg); - ahd_list_unlock(&l); - return; - } ahd_lock(ahd, &s); ahd_pause(ahd); ahd_update_modes(ahd); @@ -7924,7 +7846,6 @@ ahd_reset_poll(void *arg) ahd_reset_poll, ahd); ahd_unpause(ahd); ahd_unlock(ahd, &s); - ahd_list_unlock(&l); return; } @@ -7936,25 +7857,16 @@ ahd_reset_poll(void *arg) ahd->flags &= ~AHD_RESET_POLL_ACTIVE; ahd_unlock(ahd, &s); ahd_release_simq(ahd); - ahd_list_unlock(&l); } /**************************** Statistics Processing ***************************/ static void ahd_stat_timer(void *arg) { - struct ahd_softc *ahd; - u_long l; + struct ahd_softc *ahd = arg; u_long s; int enint_coal; - ahd_list_lock(&l); - ahd = ahd_find_softc((struct ahd_softc *)arg); - if (ahd == NULL) { - printf("ahd_stat_timer: Instance %p no longer exists\n", arg); - ahd_list_unlock(&l); - return; - } ahd_lock(ahd, &s); enint_coal = ahd->hs_mailbox & ENINT_COALESCE; @@ -7981,7 +7893,6 @@ ahd_stat_timer(void *arg) ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US, ahd_stat_timer, ahd); ahd_unlock(ahd, &s); - ahd_list_unlock(&l); } /****************************** Status Processing *****************************/ @@ -8745,16 +8656,6 @@ sized: return (last_probe); } -void -ahd_dump_all_cards_state(void) -{ - struct ahd_softc *list_ahd; - - TAILQ_FOREACH(list_ahd, &ahd_tailq, links) { - ahd_dump_card_state(list_ahd); - } -} - int ahd_print_register(ahd_reg_parse_entry_t *table, u_int num_entries, const char *name, u_int address, u_int value, diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 2f158624c5d..3feb739cd55 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -59,11 +59,6 @@ static struct scsi_transport_template *ahd_linux_transport_template = NULL; #include /* For block_size() */ #include /* For ssleep/msleep */ -/* - * Lock protecting manipulation of the ahd softc list. - */ -spinlock_t ahd_list_spinlock; - /* * Bucket size for counting good commands in between bad ones. */ @@ -302,13 +297,6 @@ static uint32_t aic79xx_pci_parity = ~0; */ uint32_t aic79xx_allow_memio = ~0; -/* - * aic79xx_detect() has been run, so register all device arrivals - * immediately with the system rather than deferring to the sorted - * attachment performed by aic79xx_detect(). - */ -int aic79xx_detect_complete; - /* * So that we can set how long each device is given as a selection timeout. * The table of values goes like this: @@ -387,7 +375,9 @@ static void ahd_linux_setup_tag_info_global(char *p); static aic_option_callback_t ahd_linux_setup_tag_info; static aic_option_callback_t ahd_linux_setup_iocell_info; static int aic79xx_setup(char *c); -static int ahd_linux_next_unit(void); + +static int ahd_linux_unit; + /****************************** Inlines ***************************************/ static __inline void ahd_linux_unmap_scb(struct ahd_softc*, struct scb*); @@ -417,50 +407,6 @@ ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb) #define BUILD_SCSIID(ahd, cmd) \ ((((cmd)->device->id << TID_SHIFT) & TID) | (ahd)->our_id) -/* - * Try to detect an Adaptec 79XX controller. - */ -static int -ahd_linux_detect(struct scsi_host_template *template) -{ - struct ahd_softc *ahd; - int found; - int error = 0; - - /* - * If we've been passed any parameters, process them now. - */ - if (aic79xx) - aic79xx_setup(aic79xx); - - template->proc_name = "aic79xx"; - - /* - * Initialize our softc list lock prior to - * probing for any adapters. - */ - ahd_list_lockinit(); - -#ifdef CONFIG_PCI - error = ahd_linux_pci_init(); - if (error) - return error; -#endif - - /* - * Register with the SCSI layer all - * controllers we've found. - */ - found = 0; - TAILQ_FOREACH(ahd, &ahd_tailq, links) { - - if (ahd_linux_register_host(ahd, template) == 0) - found++; - } - aic79xx_detect_complete++; - return found; -} - /* * Return a string describing the driver. */ @@ -760,6 +706,7 @@ ahd_linux_bus_reset(struct scsi_cmnd *cmd) struct scsi_host_template aic79xx_driver_template = { .module = THIS_MODULE, .name = "aic79xx", + .proc_name = "aic79xx", .proc_info = ahd_linux_proc_info, .info = ahd_linux_info, .queuecommand = ahd_linux_queue, @@ -1072,7 +1019,7 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa host->max_lun = AHD_NUM_LUNS; host->max_channel = 0; host->sg_tablesize = AHD_NSEG; - ahd_set_unit(ahd, ahd_linux_next_unit()); + ahd_set_unit(ahd, ahd_linux_unit++); sprintf(buf, "scsi%d", host->host_no); new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT); if (new_name != NULL) { @@ -1100,29 +1047,6 @@ ahd_linux_get_memsize(void) return ((uint64_t)si.totalram << PAGE_SHIFT); } -/* - * Find the smallest available unit number to use - * for a new device. We don't just use a static - * count to handle the "repeated hot-(un)plug" - * scenario. - */ -static int -ahd_linux_next_unit(void) -{ - struct ahd_softc *ahd; - int unit; - - unit = 0; -retry: - TAILQ_FOREACH(ahd, &ahd_tailq, links) { - if (ahd->unit == unit) { - unit++; - goto retry; - } - } - return (unit); -} - /* * Place the SCSI bus into a known state by either resetting it, * or forcing transfer negotiations on the next command to any @@ -2755,23 +2679,31 @@ static struct spi_function_template ahd_linux_transport_functions = { .show_hold_mcs = 1, }; - - static int __init ahd_linux_init(void) { - ahd_linux_transport_template = spi_attach_transport(&ahd_linux_transport_functions); + int error = 0; + + /* + * If we've been passed any parameters, process them now. + */ + if (aic79xx) + aic79xx_setup(aic79xx); + + ahd_linux_transport_template = + spi_attach_transport(&ahd_linux_transport_functions); if (!ahd_linux_transport_template) return -ENODEV; + scsi_transport_reserve_target(ahd_linux_transport_template, sizeof(struct ahd_linux_target)); scsi_transport_reserve_device(ahd_linux_transport_template, sizeof(struct ahd_linux_device)); - if (ahd_linux_detect(&aic79xx_driver_template) > 0) - return 0; - spi_release_transport(ahd_linux_transport_template); - return -ENODEV; + error = ahd_linux_pci_init(); + if (error) + spi_release_transport(ahd_linux_transport_template); + return error; } static void __exit diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h index 296d3a59efe..052c6619acc 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.h +++ b/drivers/scsi/aic7xxx/aic79xx_osm.h @@ -120,7 +120,6 @@ typedef struct scsi_cmnd *ahd_io_ctx_t; /************************* Configuration Data *********************************/ extern uint32_t aic79xx_allow_memio; -extern int aic79xx_detect_complete; extern struct scsi_host_template aic79xx_driver_template; /***************************** Bus Space/DMA **********************************/ @@ -532,17 +531,6 @@ void ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo); /******************************** Locking *************************************/ -/* Lock protecting internal data structures */ -static __inline void ahd_lockinit(struct ahd_softc *); -static __inline void ahd_lock(struct ahd_softc *, unsigned long *flags); -static __inline void ahd_unlock(struct ahd_softc *, unsigned long *flags); - -/* Lock held during ahd_list manipulation and ahd softc frees */ -extern spinlock_t ahd_list_spinlock; -static __inline void ahd_list_lockinit(void); -static __inline void ahd_list_lock(unsigned long *flags); -static __inline void ahd_list_unlock(unsigned long *flags); - static __inline void ahd_lockinit(struct ahd_softc *ahd) { @@ -561,24 +549,6 @@ ahd_unlock(struct ahd_softc *ahd, unsigned long *flags) spin_unlock_irqrestore(&ahd->platform_data->spin_lock, *flags); } -static __inline void -ahd_list_lockinit(void) -{ - spin_lock_init(&ahd_list_spinlock); -} - -static __inline void -ahd_list_lock(unsigned long *flags) -{ - spin_lock_irqsave(&ahd_list_spinlock, *flags); -} - -static __inline void -ahd_list_unlock(unsigned long *flags) -{ - spin_unlock_irqrestore(&ahd_list_spinlock, *flags); -} - /******************************* PCI Definitions ******************************/ /* * PCIM_xxx: mask to locate subfield in register diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c index 7cfb2eb2b86..390b53852d4 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c @@ -92,27 +92,31 @@ struct pci_driver aic79xx_pci_driver = { static void ahd_linux_pci_dev_remove(struct pci_dev *pdev) { - struct ahd_softc *ahd; - u_long l; + struct ahd_softc *ahd = pci_get_drvdata(pdev); + u_long s; - /* - * We should be able to just perform - * the free directly, but check our - * list for extra sanity. - */ - ahd_list_lock(&l); - ahd = ahd_find_softc((struct ahd_softc *)pci_get_drvdata(pdev)); - if (ahd != NULL) { - u_long s; - - TAILQ_REMOVE(&ahd_tailq, ahd, links); - ahd_list_unlock(&l); - ahd_lock(ahd, &s); - ahd_intr_enable(ahd, FALSE); - ahd_unlock(ahd, &s); - ahd_free(ahd); - } else - ahd_list_unlock(&l); + ahd_lock(ahd, &s); + ahd_intr_enable(ahd, FALSE); + ahd_unlock(ahd, &s); + ahd_free(ahd); +} + +static void +ahd_linux_pci_inherit_flags(struct ahd_softc *ahd) +{ + struct pci_dev *pdev = ahd->dev_softc, *master_pdev; + unsigned int master_devfn = PCI_DEVFN(PCI_SLOT(pdev->devfn), 0); + + master_pdev = pci_get_slot(pdev->bus, master_devfn); + if (master_pdev) { + struct ahd_softc *master = pci_get_drvdata(master_pdev); + if (master) { + ahd->flags &= ~AHD_BIOS_ENABLED; + ahd->flags |= master->flags & AHD_BIOS_ENABLED; + } else + printk(KERN_ERR "aic79xx: no multichannel peer found!\n"); + pci_dev_put(master_pdev); + } } static int @@ -125,22 +129,6 @@ ahd_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent) char *name; int error; - /* - * Some BIOSen report the same device multiple times. - */ - TAILQ_FOREACH(ahd, &ahd_tailq, links) { - struct pci_dev *probed_pdev; - - probed_pdev = ahd->dev_softc; - if (probed_pdev->bus->number == pdev->bus->number - && probed_pdev->devfn == pdev->devfn) - break; - } - if (ahd != NULL) { - /* Skip duplicate. */ - return (-ENODEV); - } - pci = pdev; entry = ahd_find_pci_device(pci); if (entry == NULL) @@ -190,16 +178,17 @@ ahd_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ahd_free(ahd); return (-error); } + + /* + * Second Function PCI devices need to inherit some + * * settings from function 0. + */ + if ((ahd->features & AHD_MULTI_FUNC) && PCI_FUNC(pdev->devfn) != 0) + ahd_linux_pci_inherit_flags(ahd); + pci_set_drvdata(pdev, ahd); - if (aic79xx_detect_complete) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) - ahd_linux_register_host(ahd, &aic79xx_driver_template); -#else - printf("aic79xx: ignoring PCI device found after " - "initialization\n"); - return (-ENODEV); -#endif - } + + ahd_linux_register_host(ahd, &aic79xx_driver_template); return (0); } diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c index 703f6e44889..2131db60018 100644 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c @@ -283,7 +283,6 @@ int ahd_pci_config(struct ahd_softc *ahd, struct ahd_pci_identity *entry) { struct scb_data *shared_scb_data; - u_long l; u_int command; uint32_t devconfig; uint16_t subvendor; @@ -373,16 +372,9 @@ ahd_pci_config(struct ahd_softc *ahd, struct ahd_pci_identity *entry) * Allow interrupts now that we are completely setup. */ error = ahd_pci_map_int(ahd); - if (error != 0) - return (error); - - ahd_list_lock(&l); - /* - * Link this softc in with all other ahd instances. - */ - ahd_softc_insert(ahd); - ahd_list_unlock(&l); - return (0); + if (!error) + ahd->init_level++; + return error; } /* diff --git a/drivers/scsi/aic7xxx/aic79xx_proc.c b/drivers/scsi/aic7xxx/aic79xx_proc.c index cffdd104f9e..32be1f55998 100644 --- a/drivers/scsi/aic7xxx/aic79xx_proc.c +++ b/drivers/scsi/aic7xxx/aic79xx_proc.c @@ -285,21 +285,13 @@ int ahd_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset, int length, int inout) { - struct ahd_softc *ahd; + struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata; struct info_str info; char ahd_info[256]; - u_long l; u_int max_targ; u_int i; int retval; - retval = -EINVAL; - ahd_list_lock(&l); - ahd = ahd_find_softc(*(struct ahd_softc **)shost->hostdata); - - if (ahd == NULL) - goto done; - /* Has data been written to the file? */ if (inout == TRUE) { retval = ahd_proc_write_seeprom(ahd, buffer, length); @@ -349,6 +341,5 @@ ahd_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, } retval = info.pos > info.offset ? info.pos - info.offset : 0; done: - ahd_list_unlock(&l); return (retval); } -- cgit v1.2.3-18-g5258 From 975f24bdc7d3833875309509abbc7da2b2a28234 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 15 Aug 2005 13:29:55 +0200 Subject: [SCSI] aiclib remove dead remove lots of completely dead code from aiclib, there's not a lot left and even what's left is rather useless. Signed-off-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aiclib.c | 1256 ----------------------------------------- drivers/scsi/aic7xxx/aiclib.h | 868 ---------------------------- 2 files changed, 2124 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aiclib.c b/drivers/scsi/aic7xxx/aiclib.c index 7c5a6db0e67..4d44a921118 100644 --- a/drivers/scsi/aic7xxx/aiclib.c +++ b/drivers/scsi/aic7xxx/aiclib.c @@ -30,1162 +30,8 @@ * $Id$ */ -#include -#include -#include - -/* Core SCSI definitions */ -#include #include "aiclib.h" -#include "cam.h" - -#ifndef FALSE -#define FALSE 0 -#endif /* FALSE */ -#ifndef TRUE -#define TRUE 1 -#endif /* TRUE */ -#ifndef ERESTART -#define ERESTART -1 /* restart syscall */ -#endif -#ifndef EJUSTRETURN -#define EJUSTRETURN -2 /* don't modify regs, just return */ -#endif - -static int ascentrycomp(const void *key, const void *member); -static int senseentrycomp(const void *key, const void *member); -static void fetchtableentries(int sense_key, int asc, int ascq, - struct scsi_inquiry_data *, - const struct sense_key_table_entry **, - const struct asc_table_entry **); -static void * scsibsearch(const void *key, const void *base, size_t nmemb, - size_t size, - int (*compar)(const void *, const void *)); -typedef int (cam_quirkmatch_t)(caddr_t, caddr_t); -static int cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, - int str_len); -static caddr_t cam_quirkmatch(caddr_t target, caddr_t quirk_table, - int num_entries, int entry_size, - cam_quirkmatch_t *comp_func); - -#define SCSI_NO_SENSE_STRINGS 1 -#if !defined(SCSI_NO_SENSE_STRINGS) -#define SST(asc, ascq, action, desc) \ - asc, ascq, action, desc -#else -static const char empty_string[] = ""; - -#define SST(asc, ascq, action, desc) \ - asc, ascq, action, empty_string -#endif - -static const struct sense_key_table_entry sense_key_table[] = -{ - { SSD_KEY_NO_SENSE, SS_NOP, "NO SENSE" }, - { SSD_KEY_RECOVERED_ERROR, SS_NOP|SSQ_PRINT_SENSE, "RECOVERED ERROR" }, - { - SSD_KEY_NOT_READY, SS_TUR|SSQ_MANY|SSQ_DECREMENT_COUNT|EBUSY, - "NOT READY" - }, - { SSD_KEY_MEDIUM_ERROR, SS_RDEF, "MEDIUM ERROR" }, - { SSD_KEY_HARDWARE_ERROR, SS_RDEF, "HARDWARE FAILURE" }, - { SSD_KEY_ILLEGAL_REQUEST, SS_FATAL|EINVAL, "ILLEGAL REQUEST" }, - { SSD_KEY_UNIT_ATTENTION, SS_FATAL|ENXIO, "UNIT ATTENTION" }, - { SSD_KEY_DATA_PROTECT, SS_FATAL|EACCES, "DATA PROTECT" }, - { SSD_KEY_BLANK_CHECK, SS_FATAL|ENOSPC, "BLANK CHECK" }, - { SSD_KEY_Vendor_Specific, SS_FATAL|EIO, "Vendor Specific" }, - { SSD_KEY_COPY_ABORTED, SS_FATAL|EIO, "COPY ABORTED" }, - { SSD_KEY_ABORTED_COMMAND, SS_RDEF, "ABORTED COMMAND" }, - { SSD_KEY_EQUAL, SS_NOP, "EQUAL" }, - { SSD_KEY_VOLUME_OVERFLOW, SS_FATAL|EIO, "VOLUME OVERFLOW" }, - { SSD_KEY_MISCOMPARE, SS_NOP, "MISCOMPARE" }, - { SSD_KEY_RESERVED, SS_FATAL|EIO, "RESERVED" } -}; - -static const int sense_key_table_size = - sizeof(sense_key_table)/sizeof(sense_key_table[0]); - -static struct asc_table_entry quantum_fireball_entries[] = { - {SST(0x04, 0x0b, SS_START|SSQ_DECREMENT_COUNT|ENXIO, - "Logical unit not ready, initializing cmd. required")} -}; - -static struct asc_table_entry sony_mo_entries[] = { - {SST(0x04, 0x00, SS_START|SSQ_DECREMENT_COUNT|ENXIO, - "Logical unit not ready, cause not reportable")} -}; - -static struct scsi_sense_quirk_entry sense_quirk_table[] = { - { - /* - * The Quantum Fireball ST and SE like to return 0x04 0x0b when - * they really should return 0x04 0x02. 0x04,0x0b isn't - * defined in any SCSI spec, and it isn't mentioned in the - * hardware manual for these drives. - */ - {T_DIRECT, SIP_MEDIA_FIXED, "QUANTUM", "FIREBALL S*", "*"}, - /*num_sense_keys*/0, - sizeof(quantum_fireball_entries)/sizeof(struct asc_table_entry), - /*sense key entries*/NULL, - quantum_fireball_entries - }, - { - /* - * This Sony MO drive likes to return 0x04, 0x00 when it - * isn't spun up. - */ - {T_DIRECT, SIP_MEDIA_REMOVABLE, "SONY", "SMO-*", "*"}, - /*num_sense_keys*/0, - sizeof(sony_mo_entries)/sizeof(struct asc_table_entry), - /*sense key entries*/NULL, - sony_mo_entries - } -}; - -static const int sense_quirk_table_size = - sizeof(sense_quirk_table)/sizeof(sense_quirk_table[0]); - -static struct asc_table_entry asc_table[] = { -/* - * From File: ASC-NUM.TXT - * SCSI ASC/ASCQ Assignments - * Numeric Sorted Listing - * as of 5/12/97 - * - * D - DIRECT ACCESS DEVICE (SBC) device column key - * .T - SEQUENTIAL ACCESS DEVICE (SSC) ------------------- - * . L - PRINTER DEVICE (SSC) blank = reserved - * . P - PROCESSOR DEVICE (SPC) not blank = allowed - * . .W - WRITE ONCE READ MULTIPLE DEVICE (SBC) - * . . R - CD DEVICE (MMC) - * . . S - SCANNER DEVICE (SGC) - * . . .O - OPTICAL MEMORY DEVICE (SBC) - * . . . M - MEDIA CHANGER DEVICE (SMC) - * . . . C - COMMUNICATION DEVICE (SSC) - * . . . .A - STORAGE ARRAY DEVICE (SCC) - * . . . . E - ENCLOSURE SERVICES DEVICE (SES) - * DTLPWRSOMCAE ASC ASCQ Action Description - * ------------ ---- ---- ------ -----------------------------------*/ -/* DTLPWRSOMCAE */{SST(0x00, 0x00, SS_NOP, - "No additional sense information") }, -/* T S */{SST(0x00, 0x01, SS_RDEF, - "Filemark detected") }, -/* T S */{SST(0x00, 0x02, SS_RDEF, - "End-of-partition/medium detected") }, -/* T */{SST(0x00, 0x03, SS_RDEF, - "Setmark detected") }, -/* T S */{SST(0x00, 0x04, SS_RDEF, - "Beginning-of-partition/medium detected") }, -/* T S */{SST(0x00, 0x05, SS_RDEF, - "End-of-data detected") }, -/* DTLPWRSOMCAE */{SST(0x00, 0x06, SS_RDEF, - "I/O process terminated") }, -/* R */{SST(0x00, 0x11, SS_FATAL|EBUSY, - "Audio play operation in progress") }, -/* R */{SST(0x00, 0x12, SS_NOP, - "Audio play operation paused") }, -/* R */{SST(0x00, 0x13, SS_NOP, - "Audio play operation successfully completed") }, -/* R */{SST(0x00, 0x14, SS_RDEF, - "Audio play operation stopped due to error") }, -/* R */{SST(0x00, 0x15, SS_NOP, - "No current audio status to return") }, -/* DTLPWRSOMCAE */{SST(0x00, 0x16, SS_FATAL|EBUSY, - "Operation in progress") }, -/* DTL WRSOM AE */{SST(0x00, 0x17, SS_RDEF, - "Cleaning requested") }, -/* D W O */{SST(0x01, 0x00, SS_RDEF, - "No index/sector signal") }, -/* D WR OM */{SST(0x02, 0x00, SS_RDEF, - "No seek complete") }, -/* DTL W SO */{SST(0x03, 0x00, SS_RDEF, - "Peripheral device write fault") }, -/* T */{SST(0x03, 0x01, SS_RDEF, - "No write current") }, -/* T */{SST(0x03, 0x02, SS_RDEF, - "Excessive write errors") }, -/* DTLPWRSOMCAE */{SST(0x04, 0x00, - SS_TUR|SSQ_DELAY|SSQ_MANY|SSQ_DECREMENT_COUNT|EIO, - "Logical unit not ready, cause not reportable") }, -/* DTLPWRSOMCAE */{SST(0x04, 0x01, - SS_TUR|SSQ_DELAY|SSQ_MANY|SSQ_DECREMENT_COUNT|EBUSY, - "Logical unit is in process of becoming ready") }, -/* DTLPWRSOMCAE */{SST(0x04, 0x02, SS_START|SSQ_DECREMENT_COUNT|ENXIO, - "Logical unit not ready, initializing cmd. required") }, -/* DTLPWRSOMCAE */{SST(0x04, 0x03, SS_FATAL|ENXIO, - "Logical unit not ready, manual intervention required")}, -/* DTL O */{SST(0x04, 0x04, SS_FATAL|EBUSY, - "Logical unit not ready, format in progress") }, -/* DT W OMCA */{SST(0x04, 0x05, SS_FATAL|EBUSY, - "Logical unit not ready, rebuild in progress") }, -/* DT W OMCA */{SST(0x04, 0x06, SS_FATAL|EBUSY, - "Logical unit not ready, recalculation in progress") }, -/* DTLPWRSOMCAE */{SST(0x04, 0x07, SS_FATAL|EBUSY, - "Logical unit not ready, operation in progress") }, -/* R */{SST(0x04, 0x08, SS_FATAL|EBUSY, - "Logical unit not ready, long write in progress") }, -/* DTL WRSOMCAE */{SST(0x05, 0x00, SS_RDEF, - "Logical unit does not respond to selection") }, -/* D WR OM */{SST(0x06, 0x00, SS_RDEF, - "No reference position found") }, -/* DTL WRSOM */{SST(0x07, 0x00, SS_RDEF, - "Multiple peripheral devices selected") }, -/* DTL WRSOMCAE */{SST(0x08, 0x00, SS_RDEF, - "Logical unit communication failure") }, -/* DTL WRSOMCAE */{SST(0x08, 0x01, SS_RDEF, - "Logical unit communication time-out") }, -/* DTL WRSOMCAE */{SST(0x08, 0x02, SS_RDEF, - "Logical unit communication parity error") }, -/* DT R OM */{SST(0x08, 0x03, SS_RDEF, - "Logical unit communication crc error (ultra-dma/32)")}, -/* DT WR O */{SST(0x09, 0x00, SS_RDEF, - "Track following error") }, -/* WR O */{SST(0x09, 0x01, SS_RDEF, - "Tracking servo failure") }, -/* WR O */{SST(0x09, 0x02, SS_RDEF, - "Focus servo failure") }, -/* WR O */{SST(0x09, 0x03, SS_RDEF, - "Spindle servo failure") }, -/* DT WR O */{SST(0x09, 0x04, SS_RDEF, - "Head select fault") }, -/* DTLPWRSOMCAE */{SST(0x0A, 0x00, SS_FATAL|ENOSPC, - "Error log overflow") }, -/* DTLPWRSOMCAE */{SST(0x0B, 0x00, SS_RDEF, - "Warning") }, -/* DTLPWRSOMCAE */{SST(0x0B, 0x01, SS_RDEF, - "Specified temperature exceeded") }, -/* DTLPWRSOMCAE */{SST(0x0B, 0x02, SS_RDEF, - "Enclosure degraded") }, -/* T RS */{SST(0x0C, 0x00, SS_RDEF, - "Write error") }, -/* D W O */{SST(0x0C, 0x01, SS_NOP|SSQ_PRINT_SENSE, - "Write error - recovered with auto reallocation") }, -/* D W O */{SST(0x0C, 0x02, SS_RDEF, - "Write error - auto reallocation failed") }, -/* D W O */{SST(0x0C, 0x03, SS_RDEF, - "Write error - recommend reassignment") }, -/* DT W O */{SST(0x0C, 0x04, SS_RDEF, - "Compression check miscompare error") }, -/* DT W O */{SST(0x0C, 0x05, SS_RDEF, - "Data expansion occurred during compression") }, -/* DT W O */{SST(0x0C, 0x06, SS_RDEF, - "Block not compressible") }, -/* R */{SST(0x0C, 0x07, SS_RDEF, - "Write error - recovery needed") }, -/* R */{SST(0x0C, 0x08, SS_RDEF, - "Write error - recovery failed") }, -/* R */{SST(0x0C, 0x09, SS_RDEF, - "Write error - loss of streaming") }, -/* R */{SST(0x0C, 0x0A, SS_RDEF, - "Write error - padding blocks added") }, -/* D W O */{SST(0x10, 0x00, SS_RDEF, - "ID CRC or ECC error") }, -/* DT WRSO */{SST(0x11, 0x00, SS_RDEF, - "Unrecovered read error") }, -/* DT W SO */{SST(0x11, 0x01, SS_RDEF, - "Read retries exhausted") }, -/* DT W SO */{SST(0x11, 0x02, SS_RDEF, - "Error too long to correct") }, -/* DT W SO */{SST(0x11, 0x03, SS_RDEF, - "Multiple read errors") }, -/* D W O */{SST(0x11, 0x04, SS_RDEF, - "Unrecovered read error - auto reallocate failed") }, -/* WR O */{SST(0x11, 0x05, SS_RDEF, - "L-EC uncorrectable error") }, -/* WR O */{SST(0x11, 0x06, SS_RDEF, - "CIRC unrecovered error") }, -/* W O */{SST(0x11, 0x07, SS_RDEF, - "Data re-synchronization error") }, -/* T */{SST(0x11, 0x08, SS_RDEF, - "Incomplete block read") }, -/* T */{SST(0x11, 0x09, SS_RDEF, - "No gap found") }, -/* DT O */{SST(0x11, 0x0A, SS_RDEF, - "Miscorrected error") }, -/* D W O */{SST(0x11, 0x0B, SS_RDEF, - "Unrecovered read error - recommend reassignment") }, -/* D W O */{SST(0x11, 0x0C, SS_RDEF, - "Unrecovered read error - recommend rewrite the data")}, -/* DT WR O */{SST(0x11, 0x0D, SS_RDEF, - "De-compression CRC error") }, -/* DT WR O */{SST(0x11, 0x0E, SS_RDEF, - "Cannot decompress using declared algorithm") }, -/* R */{SST(0x11, 0x0F, SS_RDEF, - "Error reading UPC/EAN number") }, -/* R */{SST(0x11, 0x10, SS_RDEF, - "Error reading ISRC number") }, -/* R */{SST(0x11, 0x11, SS_RDEF, - "Read error - loss of streaming") }, -/* D W O */{SST(0x12, 0x00, SS_RDEF, - "Address mark not found for id field") }, -/* D W O */{SST(0x13, 0x00, SS_RDEF, - "Address mark not found for data field") }, -/* DTL WRSO */{SST(0x14, 0x00, SS_RDEF, - "Recorded entity not found") }, -/* DT WR O */{SST(0x14, 0x01, SS_RDEF, - "Record not found") }, -/* T */{SST(0x14, 0x02, SS_RDEF, - "Filemark or setmark not found") }, -/* T */{SST(0x14, 0x03, SS_RDEF, - "End-of-data not found") }, -/* T */{SST(0x14, 0x04, SS_RDEF, - "Block sequence error") }, -/* DT W O */{SST(0x14, 0x05, SS_RDEF, - "Record not found - recommend reassignment") }, -/* DT W O */{SST(0x14, 0x06, SS_RDEF, - "Record not found - data auto-reallocated") }, -/* DTL WRSOM */{SST(0x15, 0x00, SS_RDEF, - "Random positioning error") }, -/* DTL WRSOM */{SST(0x15, 0x01, SS_RDEF, - "Mechanical positioning error") }, -/* DT WR O */{SST(0x15, 0x02, SS_RDEF, - "Positioning error detected by read of medium") }, -/* D W O */{SST(0x16, 0x00, SS_RDEF, - "Data synchronization mark error") }, -/* D W O */{SST(0x16, 0x01, SS_RDEF, - "Data sync error - data rewritten") }, -/* D W O */{SST(0x16, 0x02, SS_RDEF, - "Data sync error - recommend rewrite") }, -/* D W O */{SST(0x16, 0x03, SS_NOP|SSQ_PRINT_SENSE, - "Data sync error - data auto-reallocated") }, -/* D W O */{SST(0x16, 0x04, SS_RDEF, - "Data sync error - recommend reassignment") }, -/* DT WRSO */{SST(0x17, 0x00, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data with no error correction applied") }, -/* DT WRSO */{SST(0x17, 0x01, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data with retries") }, -/* DT WR O */{SST(0x17, 0x02, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data with positive head offset") }, -/* DT WR O */{SST(0x17, 0x03, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data with negative head offset") }, -/* WR O */{SST(0x17, 0x04, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data with retries and/or CIRC applied") }, -/* D WR O */{SST(0x17, 0x05, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data using previous sector id") }, -/* D W O */{SST(0x17, 0x06, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data without ECC - data auto-reallocated") }, -/* D W O */{SST(0x17, 0x07, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data without ECC - recommend reassignment")}, -/* D W O */{SST(0x17, 0x08, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data without ECC - recommend rewrite") }, -/* D W O */{SST(0x17, 0x09, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data without ECC - data rewritten") }, -/* D W O */{SST(0x18, 0x00, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data with error correction applied") }, -/* D WR O */{SST(0x18, 0x01, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data with error corr. & retries applied") }, -/* D WR O */{SST(0x18, 0x02, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data - data auto-reallocated") }, -/* R */{SST(0x18, 0x03, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data with CIRC") }, -/* R */{SST(0x18, 0x04, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data with L-EC") }, -/* D WR O */{SST(0x18, 0x05, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data - recommend reassignment") }, -/* D WR O */{SST(0x18, 0x06, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data - recommend rewrite") }, -/* D W O */{SST(0x18, 0x07, SS_NOP|SSQ_PRINT_SENSE, - "Recovered data with ECC - data rewritten") }, -/* D O */{SST(0x19, 0x00, SS_RDEF, - "Defect list error") }, -/* D O */{SST(0x19, 0x01, SS_RDEF, - "Defect list not available") }, -/* D O */{SST(0x19, 0x02, SS_RDEF, - "Defect list error in primary list") }, -/* D O */{SST(0x19, 0x03, SS_RDEF, - "Defect list error in grown list") }, -/* DTLPWRSOMCAE */{SST(0x1A, 0x00, SS_RDEF, - "Parameter list length error") }, -/* DTLPWRSOMCAE */{SST(0x1B, 0x00, SS_RDEF, - "Synchronous data transfer error") }, -/* D O */{SST(0x1C, 0x00, SS_RDEF, - "Defect list not found") }, -/* D O */{SST(0x1C, 0x01, SS_RDEF, - "Primary defect list not found") }, -/* D O */{SST(0x1C, 0x02, SS_RDEF, - "Grown defect list not found") }, -/* D W O */{SST(0x1D, 0x00, SS_FATAL, - "Miscompare during verify operation" )}, -/* D W O */{SST(0x1E, 0x00, SS_NOP|SSQ_PRINT_SENSE, - "Recovered id with ecc correction") }, -/* D O */{SST(0x1F, 0x00, SS_RDEF, - "Partial defect list transfer") }, -/* DTLPWRSOMCAE */{SST(0x20, 0x00, SS_FATAL|EINVAL, - "Invalid command operation code") }, -/* DT WR OM */{SST(0x21, 0x00, SS_FATAL|EINVAL, - "Logical block address out of range" )}, -/* DT WR OM */{SST(0x21, 0x01, SS_FATAL|EINVAL, - "Invalid element address") }, -/* D */{SST(0x22, 0x00, SS_FATAL|EINVAL, - "Illegal function") }, /* Deprecated. Use 20 00, 24 00, or 26 00 instead */ -/* DTLPWRSOMCAE */{SST(0x24, 0x00, SS_FATAL|EINVAL, - "Invalid field in CDB") }, -/* DTLPWRSOMCAE */{SST(0x25, 0x00, SS_FATAL|ENXIO, - "Logical unit not supported") }, -/* DTLPWRSOMCAE */{SST(0x26, 0x00, SS_FATAL|EINVAL, - "Invalid field in parameter list") }, -/* DTLPWRSOMCAE */{SST(0x26, 0x01, SS_FATAL|EINVAL, - "Parameter not supported") }, -/* DTLPWRSOMCAE */{SST(0x26, 0x02, SS_FATAL|EINVAL, - "Parameter value invalid") }, -/* DTLPWRSOMCAE */{SST(0x26, 0x03, SS_FATAL|EINVAL, - "Threshold parameters not supported") }, -/* DTLPWRSOMCAE */{SST(0x26, 0x04, SS_FATAL|EINVAL, - "Invalid release of active persistent reservation") }, -/* DT W O */{SST(0x27, 0x00, SS_FATAL|EACCES, - "Write protected") }, -/* DT W O */{SST(0x27, 0x01, SS_FATAL|EACCES, - "Hardware write protected") }, -/* DT W O */{SST(0x27, 0x02, SS_FATAL|EACCES, - "Logical unit software write protected") }, -/* T */{SST(0x27, 0x03, SS_FATAL|EACCES, - "Associated write protect") }, -/* T */{SST(0x27, 0x04, SS_FATAL|EACCES, - "Persistent write protect") }, -/* T */{SST(0x27, 0x05, SS_FATAL|EACCES, - "Permanent write protect") }, -/* DTLPWRSOMCAE */{SST(0x28, 0x00, SS_RDEF, - "Not ready to ready change, medium may have changed") }, -/* DTLPWRSOMCAE */{SST(0x28, 0x01, SS_FATAL|ENXIO, - "Import or export element accessed") }, -/* - * XXX JGibbs - All of these should use the same errno, but I don't think - * ENXIO is the correct choice. Should we borrow from the networking - * errnos? ECONNRESET anyone? - */ -/* DTLPWRSOMCAE */{SST(0x29, 0x00, SS_RDEF, - "Power on, reset, or bus device reset occurred") }, -/* DTLPWRSOMCAE */{SST(0x29, 0x01, SS_RDEF, - "Power on occurred") }, -/* DTLPWRSOMCAE */{SST(0x29, 0x02, SS_RDEF, - "Scsi bus reset occurred") }, -/* DTLPWRSOMCAE */{SST(0x29, 0x03, SS_RDEF, - "Bus device reset function occurred") }, -/* DTLPWRSOMCAE */{SST(0x29, 0x04, SS_RDEF, - "Device internal reset") }, -/* DTLPWRSOMCAE */{SST(0x29, 0x05, SS_RDEF, - "Transceiver mode changed to single-ended") }, -/* DTLPWRSOMCAE */{SST(0x29, 0x06, SS_RDEF, - "Transceiver mode changed to LVD") }, -/* DTL WRSOMCAE */{SST(0x2A, 0x00, SS_RDEF, - "Parameters changed") }, -/* DTL WRSOMCAE */{SST(0x2A, 0x01, SS_RDEF, - "Mode parameters changed") }, -/* DTL WRSOMCAE */{SST(0x2A, 0x02, SS_RDEF, - "Log parameters changed") }, -/* DTLPWRSOMCAE */{SST(0x2A, 0x03, SS_RDEF, - "Reservations preempted") }, -/* DTLPWRSO C */{SST(0x2B, 0x00, SS_RDEF, - "Copy cannot execute since host cannot disconnect") }, -/* DTLPWRSOMCAE */{SST(0x2C, 0x00, SS_RDEF, - "Command sequence error") }, -/* S */{SST(0x2C, 0x01, SS_RDEF, - "Too many windows specified") }, -/* S */{SST(0x2C, 0x02, SS_RDEF, - "Invalid combination of windows specified") }, -/* R */{SST(0x2C, 0x03, SS_RDEF, - "Current program area is not empty") }, -/* R */{SST(0x2C, 0x04, SS_RDEF, - "Current program area is empty") }, -/* T */{SST(0x2D, 0x00, SS_RDEF, - "Overwrite error on update in place") }, -/* DTLPWRSOMCAE */{SST(0x2F, 0x00, SS_RDEF, - "Commands cleared by another initiator") }, -/* DT WR OM */{SST(0x30, 0x00, SS_RDEF, - "Incompatible medium installed") }, -/* DT WR O */{SST(0x30, 0x01, SS_RDEF, - "Cannot read medium - unknown format") }, -/* DT WR O */{SST(0x30, 0x02, SS_RDEF, - "Cannot read medium - incompatible format") }, -/* DT */{SST(0x30, 0x03, SS_RDEF, - "Cleaning cartridge installed") }, -/* DT WR O */{SST(0x30, 0x04, SS_RDEF, - "Cannot write medium - unknown format") }, -/* DT WR O */{SST(0x30, 0x05, SS_RDEF, - "Cannot write medium - incompatible format") }, -/* DT W O */{SST(0x30, 0x06, SS_RDEF, - "Cannot format medium - incompatible medium") }, -/* DTL WRSOM AE */{SST(0x30, 0x07, SS_RDEF, - "Cleaning failure") }, -/* R */{SST(0x30, 0x08, SS_RDEF, - "Cannot write - application code mismatch") }, -/* R */{SST(0x30, 0x09, SS_RDEF, - "Current session not fixated for append") }, -/* DT WR O */{SST(0x31, 0x00, SS_RDEF, - "Medium format corrupted") }, -/* D L R O */{SST(0x31, 0x01, SS_RDEF, - "Format command failed") }, -/* D W O */{SST(0x32, 0x00, SS_RDEF, - "No defect spare location available") }, -/* D W O */{SST(0x32, 0x01, SS_RDEF, - "Defect list update failure") }, -/* T */{SST(0x33, 0x00, SS_RDEF, - "Tape length error") }, -/* DTLPWRSOMCAE */{SST(0x34, 0x00, SS_RDEF, - "Enclosure failure") }, -/* DTLPWRSOMCAE */{SST(0x35, 0x00, SS_RDEF, - "Enclosure services failure") }, -/* DTLPWRSOMCAE */{SST(0x35, 0x01, SS_RDEF, - "Unsupported enclosure function") }, -/* DTLPWRSOMCAE */{SST(0x35, 0x02, SS_RDEF, - "Enclosure services unavailable") }, -/* DTLPWRSOMCAE */{SST(0x35, 0x03, SS_RDEF, - "Enclosure services transfer failure") }, -/* DTLPWRSOMCAE */{SST(0x35, 0x04, SS_RDEF, - "Enclosure services transfer refused") }, -/* L */{SST(0x36, 0x00, SS_RDEF, - "Ribbon, ink, or toner failure") }, -/* DTL WRSOMCAE */{SST(0x37, 0x00, SS_RDEF, - "Rounded parameter") }, -/* DTL WRSOMCAE */{SST(0x39, 0x00, SS_RDEF, - "Saving parameters not supported") }, -/* DTL WRSOM */{SST(0x3A, 0x00, SS_NOP, - "Medium not present") }, -/* DT WR OM */{SST(0x3A, 0x01, SS_NOP, - "Medium not present - tray closed") }, -/* DT WR OM */{SST(0x3A, 0x01, SS_NOP, - "Medium not present - tray open") }, -/* DT WR OM */{SST(0x3A, 0x03, SS_NOP, - "Medium not present - Loadable") }, -/* DT WR OM */{SST(0x3A, 0x04, SS_NOP, - "Medium not present - medium auxiliary " - "memory accessible") }, -/* DT WR OM */{SST(0x3A, 0xFF, SS_NOP, NULL) },/* Range 0x05->0xFF */ -/* TL */{SST(0x3B, 0x00, SS_RDEF, - "Sequential positioning error") }, -/* T */{SST(0x3B, 0x01, SS_RDEF, - "Tape position error at beginning-of-medium") }, -/* T */{SST(0x3B, 0x02, SS_RDEF, - "Tape position error at end-of-medium") }, -/* L */{SST(0x3B, 0x03, SS_RDEF, - "Tape or electronic vertical forms unit not ready") }, -/* L */{SST(0x3B, 0x04, SS_RDEF, - "Slew failure") }, -/* L */{SST(0x3B, 0x05, SS_RDEF, - "Paper jam") }, -/* L */{SST(0x3B, 0x06, SS_RDEF, - "Failed to sense top-of-form") }, -/* L */{SST(0x3B, 0x07, SS_RDEF, - "Failed to sense bottom-of-form") }, -/* T */{SST(0x3B, 0x08, SS_RDEF, - "Reposition error") }, -/* S */{SST(0x3B, 0x09, SS_RDEF, - "Read past end of medium") }, -/* S */{SST(0x3B, 0x0A, SS_RDEF, - "Read past beginning of medium") }, -/* S */{SST(0x3B, 0x0B, SS_RDEF, - "Position past end of medium") }, -/* T S */{SST(0x3B, 0x0C, SS_RDEF, - "Position past beginning of medium") }, -/* DT WR OM */{SST(0x3B, 0x0D, SS_FATAL|ENOSPC, - "Medium destination element full") }, -/* DT WR OM */{SST(0x3B, 0x0E, SS_RDEF, - "Medium source element empty") }, -/* R */{SST(0x3B, 0x0F, SS_RDEF, - "End of medium reached") }, -/* DT WR OM */{SST(0x3B, 0x11, SS_RDEF, - "Medium magazine not accessible") }, -/* DT WR OM */{SST(0x3B, 0x12, SS_RDEF, - "Medium magazine removed") }, -/* DT WR OM */{SST(0x3B, 0x13, SS_RDEF, - "Medium magazine inserted") }, -/* DT WR OM */{SST(0x3B, 0x14, SS_RDEF, - "Medium magazine locked") }, -/* DT WR OM */{SST(0x3B, 0x15, SS_RDEF, - "Medium magazine unlocked") }, -/* DTLPWRSOMCAE */{SST(0x3D, 0x00, SS_RDEF, - "Invalid bits in identify message") }, -/* DTLPWRSOMCAE */{SST(0x3E, 0x00, SS_RDEF, - "Logical unit has not self-configured yet") }, -/* DTLPWRSOMCAE */{SST(0x3E, 0x01, SS_RDEF, - "Logical unit failure") }, -/* DTLPWRSOMCAE */{SST(0x3E, 0x02, SS_RDEF, - "Timeout on logical unit") }, -/* DTLPWRSOMCAE */{SST(0x3F, 0x00, SS_RDEF, - "Target operating conditions have changed") }, -/* DTLPWRSOMCAE */{SST(0x3F, 0x01, SS_RDEF, - "Microcode has been changed") }, -/* DTLPWRSOMC */{SST(0x3F, 0x02, SS_RDEF, - "Changed operating definition") }, -/* DTLPWRSOMCAE */{SST(0x3F, 0x03, SS_INQ_REFRESH|SSQ_DECREMENT_COUNT, - "Inquiry data has changed") }, -/* DT WR OMCAE */{SST(0x3F, 0x04, SS_RDEF, - "Component device attached") }, -/* DT WR OMCAE */{SST(0x3F, 0x05, SS_RDEF, - "Device identifier changed") }, -/* DT WR OMCAE */{SST(0x3F, 0x06, SS_RDEF, - "Redundancy group created or modified") }, -/* DT WR OMCAE */{SST(0x3F, 0x07, SS_RDEF, - "Redundancy group deleted") }, -/* DT WR OMCAE */{SST(0x3F, 0x08, SS_RDEF, - "Spare created or modified") }, -/* DT WR OMCAE */{SST(0x3F, 0x09, SS_RDEF, - "Spare deleted") }, -/* DT WR OMCAE */{SST(0x3F, 0x0A, SS_RDEF, - "Volume set created or modified") }, -/* DT WR OMCAE */{SST(0x3F, 0x0B, SS_RDEF, - "Volume set deleted") }, -/* DT WR OMCAE */{SST(0x3F, 0x0C, SS_RDEF, - "Volume set deassigned") }, -/* DT WR OMCAE */{SST(0x3F, 0x0D, SS_RDEF, - "Volume set reassigned") }, -/* DTLPWRSOMCAE */{SST(0x3F, 0x0E, SS_RDEF, - "Reported luns data has changed") }, -/* DTLPWRSOMCAE */{SST(0x3F, 0x0F, SS_RETRY|SSQ_DECREMENT_COUNT - | SSQ_DELAY_RANDOM|EBUSY, - "Echo buffer overwritten") }, -/* DT WR OM B*/{SST(0x3F, 0x0F, SS_RDEF, "Medium Loadable") }, -/* DT WR OM B*/{SST(0x3F, 0x0F, SS_RDEF, - "Medium auxiliary memory accessible") }, -/* D */{SST(0x40, 0x00, SS_RDEF, - "Ram failure") }, /* deprecated - use 40 NN instead */ -/* DTLPWRSOMCAE */{SST(0x40, 0x80, SS_RDEF, - "Diagnostic failure: ASCQ = Component ID") }, -/* DTLPWRSOMCAE */{SST(0x40, 0xFF, SS_RDEF|SSQ_RANGE, - NULL) },/* Range 0x80->0xFF */ -/* D */{SST(0x41, 0x00, SS_RDEF, - "Data path failure") }, /* deprecated - use 40 NN instead */ -/* D */{SST(0x42, 0x00, SS_RDEF, - "Power-on or self-test failure") }, /* deprecated - use 40 NN instead */ -/* DTLPWRSOMCAE */{SST(0x43, 0x00, SS_RDEF, - "Message error") }, -/* DTLPWRSOMCAE */{SST(0x44, 0x00, SS_RDEF, - "Internal target failure") }, -/* DTLPWRSOMCAE */{SST(0x45, 0x00, SS_RDEF, - "Select or reselect failure") }, -/* DTLPWRSOMC */{SST(0x46, 0x00, SS_RDEF, - "Unsuccessful soft reset") }, -/* DTLPWRSOMCAE */{SST(0x47, 0x00, SS_RDEF|SSQ_FALLBACK, - "SCSI parity error") }, -/* DTLPWRSOMCAE */{SST(0x47, 0x01, SS_RDEF|SSQ_FALLBACK, - "Data Phase CRC error detected") }, -/* DTLPWRSOMCAE */{SST(0x47, 0x02, SS_RDEF|SSQ_FALLBACK, - "SCSI parity error detected during ST data phase") }, -/* DTLPWRSOMCAE */{SST(0x47, 0x03, SS_RDEF|SSQ_FALLBACK, - "Information Unit iuCRC error") }, -/* DTLPWRSOMCAE */{SST(0x47, 0x04, SS_RDEF|SSQ_FALLBACK, - "Asynchronous information protection error detected") }, -/* DTLPWRSOMCAE */{SST(0x47, 0x05, SS_RDEF|SSQ_FALLBACK, - "Protocol server CRC error") }, -/* DTLPWRSOMCAE */{SST(0x48, 0x00, SS_RDEF|SSQ_FALLBACK, - "Initiator detected error message received") }, -/* DTLPWRSOMCAE */{SST(0x49, 0x00, SS_RDEF, - "Invalid message error") }, -/* DTLPWRSOMCAE */{SST(0x4A, 0x00, SS_RDEF, - "Command phase error") }, -/* DTLPWRSOMCAE */{SST(0x4B, 0x00, SS_RDEF, - "Data phase error") }, -/* DTLPWRSOMCAE */{SST(0x4C, 0x00, SS_RDEF, - "Logical unit failed self-configuration") }, -/* DTLPWRSOMCAE */{SST(0x4D, 0x00, SS_RDEF, - "Tagged overlapped commands: ASCQ = Queue tag ID") }, -/* DTLPWRSOMCAE */{SST(0x4D, 0xFF, SS_RDEF|SSQ_RANGE, - NULL)}, /* Range 0x00->0xFF */ -/* DTLPWRSOMCAE */{SST(0x4E, 0x00, SS_RDEF, - "Overlapped commands attempted") }, -/* T */{SST(0x50, 0x00, SS_RDEF, - "Write append error") }, -/* T */{SST(0x50, 0x01, SS_RDEF, - "Write append position error") }, -/* T */{SST(0x50, 0x02, SS_RDEF, - "Position error related to timing") }, -/* T O */{SST(0x51, 0x00, SS_RDEF, - "Erase failure") }, -/* T */{SST(0x52, 0x00, SS_RDEF, - "Cartridge fault") }, -/* DTL WRSOM */{SST(0x53, 0x00, SS_RDEF, - "Media load or eject failed") }, -/* T */{SST(0x53, 0x01, SS_RDEF, - "Unload tape failure") }, -/* DT WR OM */{SST(0x53, 0x02, SS_RDEF, - "Medium removal prevented") }, -/* P */{SST(0x54, 0x00, SS_RDEF, - "Scsi to host system interface failure") }, -/* P */{SST(0x55, 0x00, SS_RDEF, - "System resource failure") }, -/* D O */{SST(0x55, 0x01, SS_FATAL|ENOSPC, - "System buffer full") }, -/* R */{SST(0x57, 0x00, SS_RDEF, - "Unable to recover table-of-contents") }, -/* O */{SST(0x58, 0x00, SS_RDEF, - "Generation does not exist") }, -/* O */{SST(0x59, 0x00, SS_RDEF, - "Updated block read") }, -/* DTLPWRSOM */{SST(0x5A, 0x00, SS_RDEF, - "Operator request or state change input") }, -/* DT WR OM */{SST(0x5A, 0x01, SS_RDEF, - "Operator medium removal request") }, -/* DT W O */{SST(0x5A, 0x02, SS_RDEF, - "Operator selected write protect") }, -/* DT W O */{SST(0x5A, 0x03, SS_RDEF, - "Operator selected write permit") }, -/* DTLPWRSOM */{SST(0x5B, 0x00, SS_RDEF, - "Log exception") }, -/* DTLPWRSOM */{SST(0x5B, 0x01, SS_RDEF, - "Threshold condition met") }, -/* DTLPWRSOM */{SST(0x5B, 0x02, SS_RDEF, - "Log counter at maximum") }, -/* DTLPWRSOM */{SST(0x5B, 0x03, SS_RDEF, - "Log list codes exhausted") }, -/* D O */{SST(0x5C, 0x00, SS_RDEF, - "RPL status change") }, -/* D O */{SST(0x5C, 0x01, SS_NOP|SSQ_PRINT_SENSE, - "Spindles synchronized") }, -/* D O */{SST(0x5C, 0x02, SS_RDEF, - "Spindles not synchronized") }, -/* DTLPWRSOMCAE */{SST(0x5D, 0x00, SS_RDEF, - "Failure prediction threshold exceeded") }, -/* DTLPWRSOMCAE */{SST(0x5D, 0xFF, SS_RDEF, - "Failure prediction threshold exceeded (false)") }, -/* DTLPWRSO CA */{SST(0x5E, 0x00, SS_RDEF, - "Low power condition on") }, -/* DTLPWRSO CA */{SST(0x5E, 0x01, SS_RDEF, - "Idle condition activated by timer") }, -/* DTLPWRSO CA */{SST(0x5E, 0x02, SS_RDEF, - "Standby condition activated by timer") }, -/* DTLPWRSO CA */{SST(0x5E, 0x03, SS_RDEF, - "Idle condition activated by command") }, -/* DTLPWRSO CA */{SST(0x5E, 0x04, SS_RDEF, - "Standby condition activated by command") }, -/* S */{SST(0x60, 0x00, SS_RDEF, - "Lamp failure") }, -/* S */{SST(0x61, 0x00, SS_RDEF, - "Video acquisition error") }, -/* S */{SST(0x61, 0x01, SS_RDEF, - "Unable to acquire video") }, -/* S */{SST(0x61, 0x02, SS_RDEF, - "Out of focus") }, -/* S */{SST(0x62, 0x00, SS_RDEF, - "Scan head positioning error") }, -/* R */{SST(0x63, 0x00, SS_RDEF, - "End of user area encountered on this track") }, -/* R */{SST(0x63, 0x01, SS_FATAL|ENOSPC, - "Packet does not fit in available space") }, -/* R */{SST(0x64, 0x00, SS_RDEF, - "Illegal mode for this track") }, -/* R */{SST(0x64, 0x01, SS_RDEF, - "Invalid packet size") }, -/* DTLPWRSOMCAE */{SST(0x65, 0x00, SS_RDEF, - "Voltage fault") }, -/* S */{SST(0x66, 0x00, SS_RDEF, - "Automatic document feeder cover up") }, -/* S */{SST(0x66, 0x01, SS_RDEF, - "Automatic document feeder lift up") }, -/* S */{SST(0x66, 0x02, SS_RDEF, - "Document jam in automatic document feeder") }, -/* S */{SST(0x66, 0x03, SS_RDEF, - "Document miss feed automatic in document feeder") }, -/* A */{SST(0x67, 0x00, SS_RDEF, - "Configuration failure") }, -/* A */{SST(0x67, 0x01, SS_RDEF, - "Configuration of incapable logical units failed") }, -/* A */{SST(0x67, 0x02, SS_RDEF, - "Add logical unit failed") }, -/* A */{SST(0x67, 0x03, SS_RDEF, - "Modification of logical unit failed") }, -/* A */{SST(0x67, 0x04, SS_RDEF, - "Exchange of logical unit failed") }, -/* A */{SST(0x67, 0x05, SS_RDEF, - "Remove of logical unit failed") }, -/* A */{SST(0x67, 0x06, SS_RDEF, - "Attachment of logical unit failed") }, -/* A */{SST(0x67, 0x07, SS_RDEF, - "Creation of logical unit failed") }, -/* A */{SST(0x68, 0x00, SS_RDEF, - "Logical unit not configured") }, -/* A */{SST(0x69, 0x00, SS_RDEF, - "Data loss on logical unit") }, -/* A */{SST(0x69, 0x01, SS_RDEF, - "Multiple logical unit failures") }, -/* A */{SST(0x69, 0x02, SS_RDEF, - "Parity/data mismatch") }, -/* A */{SST(0x6A, 0x00, SS_RDEF, - "Informational, refer to log") }, -/* A */{SST(0x6B, 0x00, SS_RDEF, - "State change has occurred") }, -/* A */{SST(0x6B, 0x01, SS_RDEF, - "Redundancy level got better") }, -/* A */{SST(0x6B, 0x02, SS_RDEF, - "Redundancy level got worse") }, -/* A */{SST(0x6C, 0x00, SS_RDEF, - "Rebuild failure occurred") }, -/* A */{SST(0x6D, 0x00, SS_RDEF, - "Recalculate failure occurred") }, -/* A */{SST(0x6E, 0x00, SS_RDEF, - "Command to logical unit failed") }, -/* T */{SST(0x70, 0x00, SS_RDEF, - "Decompression exception short: ASCQ = Algorithm ID") }, -/* T */{SST(0x70, 0xFF, SS_RDEF|SSQ_RANGE, - NULL) }, /* Range 0x00 -> 0xFF */ -/* T */{SST(0x71, 0x00, SS_RDEF, - "Decompression exception long: ASCQ = Algorithm ID") }, -/* T */{SST(0x71, 0xFF, SS_RDEF|SSQ_RANGE, - NULL) }, /* Range 0x00 -> 0xFF */ -/* R */{SST(0x72, 0x00, SS_RDEF, - "Session fixation error") }, -/* R */{SST(0x72, 0x01, SS_RDEF, - "Session fixation error writing lead-in") }, -/* R */{SST(0x72, 0x02, SS_RDEF, - "Session fixation error writing lead-out") }, -/* R */{SST(0x72, 0x03, SS_RDEF, - "Session fixation error - incomplete track in session") }, -/* R */{SST(0x72, 0x04, SS_RDEF, - "Empty or partially written reserved track") }, -/* R */{SST(0x73, 0x00, SS_RDEF, - "CD control error") }, -/* R */{SST(0x73, 0x01, SS_RDEF, - "Power calibration area almost full") }, -/* R */{SST(0x73, 0x02, SS_FATAL|ENOSPC, - "Power calibration area is full") }, -/* R */{SST(0x73, 0x03, SS_RDEF, - "Power calibration area error") }, -/* R */{SST(0x73, 0x04, SS_RDEF, - "Program memory area update failure") }, -/* R */{SST(0x73, 0x05, SS_RDEF, - "program memory area is full") } -}; - -static const int asc_table_size = sizeof(asc_table)/sizeof(asc_table[0]); - -struct asc_key -{ - int asc; - int ascq; -}; - -static int -ascentrycomp(const void *key, const void *member) -{ - int asc; - int ascq; - const struct asc_table_entry *table_entry; - - asc = ((const struct asc_key *)key)->asc; - ascq = ((const struct asc_key *)key)->ascq; - table_entry = (const struct asc_table_entry *)member; - - if (asc >= table_entry->asc) { - - if (asc > table_entry->asc) - return (1); - - if (ascq <= table_entry->ascq) { - /* Check for ranges */ - if (ascq == table_entry->ascq - || ((table_entry->action & SSQ_RANGE) != 0 - && ascq >= (table_entry - 1)->ascq)) - return (0); - return (-1); - } - return (1); - } - return (-1); -} - -static int -senseentrycomp(const void *key, const void *member) -{ - int sense_key; - const struct sense_key_table_entry *table_entry; - - sense_key = *((const int *)key); - table_entry = (const struct sense_key_table_entry *)member; - - if (sense_key >= table_entry->sense_key) { - if (sense_key == table_entry->sense_key) - return (0); - return (1); - } - return (-1); -} - -static void -fetchtableentries(int sense_key, int asc, int ascq, - struct scsi_inquiry_data *inq_data, - const struct sense_key_table_entry **sense_entry, - const struct asc_table_entry **asc_entry) -{ - void *match; - const struct asc_table_entry *asc_tables[2]; - const struct sense_key_table_entry *sense_tables[2]; - struct asc_key asc_ascq; - size_t asc_tables_size[2]; - size_t sense_tables_size[2]; - int num_asc_tables; - int num_sense_tables; - int i; - - /* Default to failure */ - *sense_entry = NULL; - *asc_entry = NULL; - match = NULL; - if (inq_data != NULL) - match = cam_quirkmatch((void *)inq_data, - (void *)sense_quirk_table, - sense_quirk_table_size, - sizeof(*sense_quirk_table), - aic_inquiry_match); - - if (match != NULL) { - struct scsi_sense_quirk_entry *quirk; - - quirk = (struct scsi_sense_quirk_entry *)match; - asc_tables[0] = quirk->asc_info; - asc_tables_size[0] = quirk->num_ascs; - asc_tables[1] = asc_table; - asc_tables_size[1] = asc_table_size; - num_asc_tables = 2; - sense_tables[0] = quirk->sense_key_info; - sense_tables_size[0] = quirk->num_sense_keys; - sense_tables[1] = sense_key_table; - sense_tables_size[1] = sense_key_table_size; - num_sense_tables = 2; - } else { - asc_tables[0] = asc_table; - asc_tables_size[0] = asc_table_size; - num_asc_tables = 1; - sense_tables[0] = sense_key_table; - sense_tables_size[0] = sense_key_table_size; - num_sense_tables = 1; - } - - asc_ascq.asc = asc; - asc_ascq.ascq = ascq; - for (i = 0; i < num_asc_tables; i++) { - void *found_entry; - - found_entry = scsibsearch(&asc_ascq, asc_tables[i], - asc_tables_size[i], - sizeof(**asc_tables), - ascentrycomp); - - if (found_entry) { - *asc_entry = (struct asc_table_entry *)found_entry; - break; - } - } - - for (i = 0; i < num_sense_tables; i++) { - void *found_entry; - - found_entry = scsibsearch(&sense_key, sense_tables[i], - sense_tables_size[i], - sizeof(**sense_tables), - senseentrycomp); - - if (found_entry) { - *sense_entry = - (struct sense_key_table_entry *)found_entry; - break; - } - } -} - -static void * -scsibsearch(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar)(const void *, const void *)) -{ - const void *entry; - u_int l; - u_int u; - u_int m; - - l = -1; - u = nmemb; - while (l + 1 != u) { - m = (l + u) / 2; - entry = base + m * size; - if (compar(key, entry) > 0) - l = m; - else - u = m; - } - - entry = base + u * size; - if (u == nmemb - || compar(key, entry) != 0) - return (NULL); - return ((void *)entry); -} - -/* - * Compare string with pattern, returning 0 on match. - * Short pattern matches trailing blanks in name, - * wildcard '*' in pattern matches rest of name, - * wildcard '?' matches a single non-space character. - */ -static int -cam_strmatch(const uint8_t *str, const uint8_t *pattern, int str_len) -{ - - while (*pattern != '\0'&& str_len > 0) { - - if (*pattern == '*') { - return (0); - } - if ((*pattern != *str) - && (*pattern != '?' || *str == ' ')) { - return (1); - } - pattern++; - str++; - str_len--; - } - while (str_len > 0 && *str++ == ' ') - str_len--; - - return (str_len); -} - -static caddr_t -cam_quirkmatch(caddr_t target, caddr_t quirk_table, int num_entries, - int entry_size, cam_quirkmatch_t *comp_func) -{ - for (; num_entries > 0; num_entries--, quirk_table += entry_size) { - if ((*comp_func)(target, quirk_table) == 0) - return (quirk_table); - } - return (NULL); -} - -void -aic_sense_desc(int sense_key, int asc, int ascq, - struct scsi_inquiry_data *inq_data, - const char **sense_key_desc, const char **asc_desc) -{ - const struct asc_table_entry *asc_entry; - const struct sense_key_table_entry *sense_entry; - - fetchtableentries(sense_key, asc, ascq, - inq_data, - &sense_entry, - &asc_entry); - - *sense_key_desc = sense_entry->desc; - - if (asc_entry != NULL) - *asc_desc = asc_entry->desc; - else if (asc >= 0x80 && asc <= 0xff) - *asc_desc = "Vendor Specific ASC"; - else if (ascq >= 0x80 && ascq <= 0xff) - *asc_desc = "Vendor Specific ASCQ"; - else - *asc_desc = "Reserved ASC/ASCQ pair"; -} - -/* - * Given sense and device type information, return the appropriate action. - * If we do not understand the specific error as identified by the ASC/ASCQ - * pair, fall back on the more generic actions derived from the sense key. - */ -aic_sense_action -aic_sense_error_action(struct scsi_sense_data *sense_data, - struct scsi_inquiry_data *inq_data, uint32_t sense_flags) -{ - const struct asc_table_entry *asc_entry; - const struct sense_key_table_entry *sense_entry; - int error_code, sense_key, asc, ascq; - aic_sense_action action; - - scsi_extract_sense(sense_data, &error_code, &sense_key, &asc, &ascq); - - if (error_code == SSD_DEFERRED_ERROR) { - /* - * XXX dufault@FreeBSD.org - * This error doesn't relate to the command associated - * with this request sense. A deferred error is an error - * for a command that has already returned GOOD status - * (see SCSI2 8.2.14.2). - * - * By my reading of that section, it looks like the current - * command has been cancelled, we should now clean things up - * (hopefully recovering any lost data) and then retry the - * current command. There are two easy choices, both wrong: - * - * 1. Drop through (like we had been doing), thus treating - * this as if the error were for the current command and - * return and stop the current command. - * - * 2. Issue a retry (like I made it do) thus hopefully - * recovering the current transfer, and ignoring the - * fact that we've dropped a command. - * - * These should probably be handled in a device specific - * sense handler or punted back up to a user mode daemon - */ - action = SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE; - } else { - fetchtableentries(sense_key, asc, ascq, - inq_data, - &sense_entry, - &asc_entry); - - /* - * Override the 'No additional Sense' entry (0,0) - * with the error action of the sense key. - */ - if (asc_entry != NULL - && (asc != 0 || ascq != 0)) - action = asc_entry->action; - else - action = sense_entry->action; - - if (sense_key == SSD_KEY_RECOVERED_ERROR) { - /* - * The action succeeded but the device wants - * the user to know that some recovery action - * was required. - */ - action &= ~(SS_MASK|SSQ_MASK|SS_ERRMASK); - action |= SS_NOP|SSQ_PRINT_SENSE; - } else if (sense_key == SSD_KEY_ILLEGAL_REQUEST) { - if ((sense_flags & SF_QUIET_IR) != 0) - action &= ~SSQ_PRINT_SENSE; - } else if (sense_key == SSD_KEY_UNIT_ATTENTION) { - if ((sense_flags & SF_RETRY_UA) != 0 - && (action & SS_MASK) == SS_FAIL) { - action &= ~(SS_MASK|SSQ_MASK); - action |= SS_RETRY|SSQ_DECREMENT_COUNT| - SSQ_PRINT_SENSE; - } - } - } - - if ((sense_flags & SF_PRINT_ALWAYS) != 0) - action |= SSQ_PRINT_SENSE; - else if ((sense_flags & SF_NO_PRINT) != 0) - action &= ~SSQ_PRINT_SENSE; - - return (action); -} - -/* - * Try make as good a match as possible with - * available sub drivers - */ -int -aic_inquiry_match(caddr_t inqbuffer, caddr_t table_entry) -{ - struct scsi_inquiry_pattern *entry; - struct scsi_inquiry_data *inq; - - entry = (struct scsi_inquiry_pattern *)table_entry; - inq = (struct scsi_inquiry_data *)inqbuffer; - - if (((SID_TYPE(inq) == entry->type) - || (entry->type == T_ANY)) - && (SID_IS_REMOVABLE(inq) ? entry->media_type & SIP_MEDIA_REMOVABLE - : entry->media_type & SIP_MEDIA_FIXED) - && (cam_strmatch(inq->vendor, entry->vendor, sizeof(inq->vendor)) == 0) - && (cam_strmatch(inq->product, entry->product, - sizeof(inq->product)) == 0) - && (cam_strmatch(inq->revision, entry->revision, - sizeof(inq->revision)) == 0)) { - return (0); - } - return (-1); -} /* * Table of syncrates that don't follow the "divisible by 4" @@ -1229,108 +75,6 @@ aic_calc_syncsrate(u_int period_factor) return (10000000 / (period_factor * 4 * 10)); } -/* - * Return speed in KB/s. - */ -u_int -aic_calc_speed(u_int width, u_int period, u_int offset, u_int min_rate) -{ - u_int freq; - - if (offset != 0 && period < min_rate) - freq = aic_calc_syncsrate(period); - else - /* Roughly 3.3MB/s for async */ - freq = 3300; - freq <<= width; - return (freq); -} - -uint32_t -aic_error_action(struct scsi_cmnd *cmd, struct scsi_inquiry_data *inq_data, - cam_status status, u_int scsi_status) -{ - aic_sense_action err_action; - int sense; - - sense = (cmd->result >> 24) == DRIVER_SENSE; - - switch (status) { - case CAM_REQ_CMP: - err_action = SS_NOP; - break; - case CAM_AUTOSENSE_FAIL: - case CAM_SCSI_STATUS_ERROR: - - switch (scsi_status) { - case SCSI_STATUS_OK: - case SCSI_STATUS_COND_MET: - case SCSI_STATUS_INTERMED: - case SCSI_STATUS_INTERMED_COND_MET: - err_action = SS_NOP; - break; - case SCSI_STATUS_CMD_TERMINATED: - case SCSI_STATUS_CHECK_COND: - if (sense != 0) { - struct scsi_sense_data *sense; - - sense = (struct scsi_sense_data *) - &cmd->sense_buffer; - err_action = - aic_sense_error_action(sense, inq_data, 0); - - } else { - err_action = SS_RETRY|SSQ_FALLBACK - | SSQ_DECREMENT_COUNT|EIO; - } - break; - case SCSI_STATUS_QUEUE_FULL: - case SCSI_STATUS_BUSY: - err_action = SS_RETRY|SSQ_DELAY|SSQ_MANY - | SSQ_DECREMENT_COUNT|EBUSY; - break; - case SCSI_STATUS_RESERV_CONFLICT: - default: - err_action = SS_FAIL|EBUSY; - break; - } - break; - case CAM_CMD_TIMEOUT: - case CAM_REQ_CMP_ERR: - case CAM_UNEXP_BUSFREE: - case CAM_UNCOR_PARITY: - case CAM_DATA_RUN_ERR: - err_action = SS_RETRY|SSQ_FALLBACK|EIO; - break; - case CAM_UA_ABORT: - case CAM_UA_TERMIO: - case CAM_MSG_REJECT_REC: - case CAM_SEL_TIMEOUT: - err_action = SS_FAIL|EIO; - break; - case CAM_REQ_INVALID: - case CAM_PATH_INVALID: - case CAM_DEV_NOT_THERE: - case CAM_NO_HBA: - case CAM_PROVIDE_FAIL: - case CAM_REQ_TOO_BIG: - case CAM_RESRC_UNAVAIL: - case CAM_BUSY: - default: - /* panic?? These should never occur in our application. */ - err_action = SS_FAIL|EIO; - break; - case CAM_SCSI_BUS_RESET: - case CAM_BDR_SENT: - case CAM_REQUEUE_REQ: - /* Unconditional requeue */ - err_action = SS_RETRY; - break; - } - - return (err_action); -} - char * aic_parse_brace_option(char *opt_name, char *opt_arg, char *end, int depth, aic_option_callback_t *callback, u_long callback_arg) diff --git a/drivers/scsi/aic7xxx/aiclib.h b/drivers/scsi/aic7xxx/aiclib.h index bfe6f954d3c..e7d94cbaf2a 100644 --- a/drivers/scsi/aic7xxx/aiclib.h +++ b/drivers/scsi/aic7xxx/aiclib.h @@ -57,121 +57,6 @@ #ifndef _AICLIB_H #define _AICLIB_H -/* - * Linux Interrupt Support. - */ -#ifndef IRQ_RETVAL -typedef void irqreturn_t; -#define IRQ_RETVAL(x) -#endif - -/* - * SCSI command format - */ - -/* - * Define dome bits that are in ALL (or a lot of) scsi commands - */ -#define SCSI_CTL_LINK 0x01 -#define SCSI_CTL_FLAG 0x02 -#define SCSI_CTL_VENDOR 0xC0 -#define SCSI_CMD_LUN 0xA0 /* these two should not be needed */ -#define SCSI_CMD_LUN_SHIFT 5 /* LUN in the cmd is no longer SCSI */ - -#define SCSI_MAX_CDBLEN 16 /* - * 16 byte commands are in the - * SCSI-3 spec - */ -/* 6byte CDBs special case 0 length to be 256 */ -#define SCSI_CDB6_LEN(len) ((len) == 0 ? 256 : len) - -/* - * This type defines actions to be taken when a particular sense code is - * received. Right now, these flags are only defined to take up 16 bits, - * but can be expanded in the future if necessary. - */ -typedef enum { - SS_NOP = 0x000000, /* Do nothing */ - SS_RETRY = 0x010000, /* Retry the command */ - SS_FAIL = 0x020000, /* Bail out */ - SS_START = 0x030000, /* Send a Start Unit command to the device, - * then retry the original command. - */ - SS_TUR = 0x040000, /* Send a Test Unit Ready command to the - * device, then retry the original command. - */ - SS_REQSENSE = 0x050000, /* Send a RequestSense command to the - * device, then retry the original command. - */ - SS_INQ_REFRESH = 0x060000, - SS_MASK = 0xff0000 -} aic_sense_action; - -typedef enum { - SSQ_NONE = 0x0000, - SSQ_DECREMENT_COUNT = 0x0100, /* Decrement the retry count */ - SSQ_MANY = 0x0200, /* send lots of recovery commands */ - SSQ_RANGE = 0x0400, /* - * This table entry represents the - * end of a range of ASCQs that - * have identical error actions - * and text. - */ - SSQ_PRINT_SENSE = 0x0800, - SSQ_DELAY = 0x1000, /* Delay before retry. */ - SSQ_DELAY_RANDOM = 0x2000, /* Randomized delay before retry. */ - SSQ_FALLBACK = 0x4000, /* Do a speed fallback to recover */ - SSQ_MASK = 0xff00 -} aic_sense_action_qualifier; - -/* Mask for error status values */ -#define SS_ERRMASK 0xff - -/* The default, retyable, error action */ -#define SS_RDEF SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE|EIO - -/* The retyable, error action, with table specified error code */ -#define SS_RET SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE - -/* Fatal error action, with table specified error code */ -#define SS_FATAL SS_FAIL|SSQ_PRINT_SENSE - -struct scsi_generic -{ - uint8_t opcode; - uint8_t bytes[11]; -}; - -struct scsi_request_sense -{ - uint8_t opcode; - uint8_t byte2; - uint8_t unused[2]; - uint8_t length; - uint8_t control; -}; - -struct scsi_test_unit_ready -{ - uint8_t opcode; - uint8_t byte2; - uint8_t unused[3]; - uint8_t control; -}; - -struct scsi_send_diag -{ - uint8_t opcode; - uint8_t byte2; -#define SSD_UOL 0x01 -#define SSD_DOL 0x02 -#define SSD_SELFTEST 0x04 -#define SSD_PF 0x10 - uint8_t unused[1]; - uint8_t paramlen[2]; - uint8_t control; -}; - struct scsi_sense { uint8_t opcode; @@ -181,537 +66,12 @@ struct scsi_sense uint8_t control; }; -struct scsi_inquiry -{ - uint8_t opcode; - uint8_t byte2; -#define SI_EVPD 0x01 - uint8_t page_code; - uint8_t reserved; - uint8_t length; - uint8_t control; -}; - -struct scsi_mode_sense_6 -{ - uint8_t opcode; - uint8_t byte2; -#define SMS_DBD 0x08 - uint8_t page; -#define SMS_PAGE_CODE 0x3F -#define SMS_VENDOR_SPECIFIC_PAGE 0x00 -#define SMS_DISCONNECT_RECONNECT_PAGE 0x02 -#define SMS_PERIPHERAL_DEVICE_PAGE 0x09 -#define SMS_CONTROL_MODE_PAGE 0x0A -#define SMS_ALL_PAGES_PAGE 0x3F -#define SMS_PAGE_CTRL_MASK 0xC0 -#define SMS_PAGE_CTRL_CURRENT 0x00 -#define SMS_PAGE_CTRL_CHANGEABLE 0x40 -#define SMS_PAGE_CTRL_DEFAULT 0x80 -#define SMS_PAGE_CTRL_SAVED 0xC0 - uint8_t unused; - uint8_t length; - uint8_t control; -}; - -struct scsi_mode_sense_10 -{ - uint8_t opcode; - uint8_t byte2; /* same bits as small version */ - uint8_t page; /* same bits as small version */ - uint8_t unused[4]; - uint8_t length[2]; - uint8_t control; -}; - -struct scsi_mode_select_6 -{ - uint8_t opcode; - uint8_t byte2; -#define SMS_SP 0x01 -#define SMS_PF 0x10 - uint8_t unused[2]; - uint8_t length; - uint8_t control; -}; - -struct scsi_mode_select_10 -{ - uint8_t opcode; - uint8_t byte2; /* same bits as small version */ - uint8_t unused[5]; - uint8_t length[2]; - uint8_t control; -}; - -/* - * When sending a mode select to a tape drive, the medium type must be 0. - */ -struct scsi_mode_hdr_6 -{ - uint8_t datalen; - uint8_t medium_type; - uint8_t dev_specific; - uint8_t block_descr_len; -}; - -struct scsi_mode_hdr_10 -{ - uint8_t datalen[2]; - uint8_t medium_type; - uint8_t dev_specific; - uint8_t reserved[2]; - uint8_t block_descr_len[2]; -}; - -struct scsi_mode_block_descr -{ - uint8_t density_code; - uint8_t num_blocks[3]; - uint8_t reserved; - uint8_t block_len[3]; -}; - -struct scsi_log_sense -{ - uint8_t opcode; - uint8_t byte2; -#define SLS_SP 0x01 -#define SLS_PPC 0x02 - uint8_t page; -#define SLS_PAGE_CODE 0x3F -#define SLS_ALL_PAGES_PAGE 0x00 -#define SLS_OVERRUN_PAGE 0x01 -#define SLS_ERROR_WRITE_PAGE 0x02 -#define SLS_ERROR_READ_PAGE 0x03 -#define SLS_ERROR_READREVERSE_PAGE 0x04 -#define SLS_ERROR_VERIFY_PAGE 0x05 -#define SLS_ERROR_NONMEDIUM_PAGE 0x06 -#define SLS_ERROR_LASTN_PAGE 0x07 -#define SLS_PAGE_CTRL_MASK 0xC0 -#define SLS_PAGE_CTRL_THRESHOLD 0x00 -#define SLS_PAGE_CTRL_CUMULATIVE 0x40 -#define SLS_PAGE_CTRL_THRESH_DEFAULT 0x80 -#define SLS_PAGE_CTRL_CUMUL_DEFAULT 0xC0 - uint8_t reserved[2]; - uint8_t paramptr[2]; - uint8_t length[2]; - uint8_t control; -}; - -struct scsi_log_select -{ - uint8_t opcode; - uint8_t byte2; -/* SLS_SP 0x01 */ -#define SLS_PCR 0x02 - uint8_t page; -/* SLS_PAGE_CTRL_MASK 0xC0 */ -/* SLS_PAGE_CTRL_THRESHOLD 0x00 */ -/* SLS_PAGE_CTRL_CUMULATIVE 0x40 */ -/* SLS_PAGE_CTRL_THRESH_DEFAULT 0x80 */ -/* SLS_PAGE_CTRL_CUMUL_DEFAULT 0xC0 */ - uint8_t reserved[4]; - uint8_t length[2]; - uint8_t control; -}; - -struct scsi_log_header -{ - uint8_t page; - uint8_t reserved; - uint8_t datalen[2]; -}; - -struct scsi_log_param_header { - uint8_t param_code[2]; - uint8_t param_control; -#define SLP_LP 0x01 -#define SLP_LBIN 0x02 -#define SLP_TMC_MASK 0x0C -#define SLP_TMC_ALWAYS 0x00 -#define SLP_TMC_EQUAL 0x04 -#define SLP_TMC_NOTEQUAL 0x08 -#define SLP_TMC_GREATER 0x0C -#define SLP_ETC 0x10 -#define SLP_TSD 0x20 -#define SLP_DS 0x40 -#define SLP_DU 0x80 - uint8_t param_len; -}; - -struct scsi_control_page { - uint8_t page_code; - uint8_t page_length; - uint8_t rlec; -#define SCB_RLEC 0x01 /*Report Log Exception Cond*/ - uint8_t queue_flags; -#define SCP_QUEUE_ALG_MASK 0xF0 -#define SCP_QUEUE_ALG_RESTRICTED 0x00 -#define SCP_QUEUE_ALG_UNRESTRICTED 0x10 -#define SCP_QUEUE_ERR 0x02 /*Queued I/O aborted for CACs*/ -#define SCP_QUEUE_DQUE 0x01 /*Queued I/O disabled*/ - uint8_t eca_and_aen; -#define SCP_EECA 0x80 /*Enable Extended CA*/ -#define SCP_RAENP 0x04 /*Ready AEN Permission*/ -#define SCP_UAAENP 0x02 /*UA AEN Permission*/ -#define SCP_EAENP 0x01 /*Error AEN Permission*/ - uint8_t reserved; - uint8_t aen_holdoff_period[2]; -}; - -struct scsi_reserve -{ - uint8_t opcode; - uint8_t byte2; - uint8_t unused[2]; - uint8_t length; - uint8_t control; -}; - -struct scsi_release -{ - uint8_t opcode; - uint8_t byte2; - uint8_t unused[2]; - uint8_t length; - uint8_t control; -}; - -struct scsi_prevent -{ - uint8_t opcode; - uint8_t byte2; - uint8_t unused[2]; - uint8_t how; - uint8_t control; -}; -#define PR_PREVENT 0x01 -#define PR_ALLOW 0x00 - -struct scsi_sync_cache -{ - uint8_t opcode; - uint8_t byte2; - uint8_t begin_lba[4]; - uint8_t reserved; - uint8_t lb_count[2]; - uint8_t control; -}; - - -struct scsi_changedef -{ - uint8_t opcode; - uint8_t byte2; - uint8_t unused1; - uint8_t how; - uint8_t unused[4]; - uint8_t datalen; - uint8_t control; -}; - -struct scsi_read_buffer -{ - uint8_t opcode; - uint8_t byte2; -#define RWB_MODE 0x07 -#define RWB_MODE_HDR_DATA 0x00 -#define RWB_MODE_DATA 0x02 -#define RWB_MODE_DOWNLOAD 0x04 -#define RWB_MODE_DOWNLOAD_SAVE 0x05 - uint8_t buffer_id; - uint8_t offset[3]; - uint8_t length[3]; - uint8_t control; -}; - -struct scsi_write_buffer -{ - uint8_t opcode; - uint8_t byte2; - uint8_t buffer_id; - uint8_t offset[3]; - uint8_t length[3]; - uint8_t control; -}; - -struct scsi_rw_6 -{ - uint8_t opcode; - uint8_t addr[3]; -/* only 5 bits are valid in the MSB address byte */ -#define SRW_TOPADDR 0x1F - uint8_t length; - uint8_t control; -}; - -struct scsi_rw_10 -{ - uint8_t opcode; -#define SRW10_RELADDR 0x01 -#define SRW10_FUA 0x08 -#define SRW10_DPO 0x10 - uint8_t byte2; - uint8_t addr[4]; - uint8_t reserved; - uint8_t length[2]; - uint8_t control; -}; - -struct scsi_rw_12 -{ - uint8_t opcode; -#define SRW12_RELADDR 0x01 -#define SRW12_FUA 0x08 -#define SRW12_DPO 0x10 - uint8_t byte2; - uint8_t addr[4]; - uint8_t length[4]; - uint8_t reserved; - uint8_t control; -}; - -struct scsi_start_stop_unit -{ - uint8_t opcode; - uint8_t byte2; -#define SSS_IMMED 0x01 - uint8_t reserved[2]; - uint8_t how; -#define SSS_START 0x01 -#define SSS_LOEJ 0x02 - uint8_t control; -}; - -#define SC_SCSI_1 0x01 -#define SC_SCSI_2 0x03 - -/* - * Opcodes - */ - -#define TEST_UNIT_READY 0x00 -#define REQUEST_SENSE 0x03 -#define READ_6 0x08 -#define WRITE_6 0x0a -#define INQUIRY 0x12 -#define MODE_SELECT_6 0x15 -#define MODE_SENSE_6 0x1a -#define START_STOP_UNIT 0x1b -#define START_STOP 0x1b -#define RESERVE 0x16 -#define RELEASE 0x17 -#define RECEIVE_DIAGNOSTIC 0x1c -#define SEND_DIAGNOSTIC 0x1d -#define PREVENT_ALLOW 0x1e -#define READ_CAPACITY 0x25 -#define READ_10 0x28 -#define WRITE_10 0x2a -#define POSITION_TO_ELEMENT 0x2b -#define SYNCHRONIZE_CACHE 0x35 -#define WRITE_BUFFER 0x3b -#define READ_BUFFER 0x3c -#define CHANGE_DEFINITION 0x40 -#define LOG_SELECT 0x4c -#define LOG_SENSE 0x4d -#ifdef XXXCAM -#define MODE_SENSE_10 0x5A -#endif -#define MODE_SELECT_10 0x55 -#define MOVE_MEDIUM 0xa5 -#define READ_12 0xa8 -#define WRITE_12 0xaa -#define READ_ELEMENT_STATUS 0xb8 - - -/* - * Device Types - */ -#define T_DIRECT 0x00 -#define T_SEQUENTIAL 0x01 -#define T_PRINTER 0x02 -#define T_PROCESSOR 0x03 -#define T_WORM 0x04 -#define T_CDROM 0x05 -#define T_SCANNER 0x06 -#define T_OPTICAL 0x07 -#define T_CHANGER 0x08 -#define T_COMM 0x09 -#define T_ASC0 0x0a -#define T_ASC1 0x0b -#define T_STORARRAY 0x0c -#define T_ENCLOSURE 0x0d -#define T_RBC 0x0e -#define T_OCRW 0x0f -#define T_NODEVICE 0x1F -#define T_ANY 0xFF /* Used in Quirk table matches */ - -#define T_REMOV 1 -#define T_FIXED 0 - -/* - * This length is the initial inquiry length used by the probe code, as - * well as the legnth necessary for aic_print_inquiry() to function - * correctly. If either use requires a different length in the future, - * the two values should be de-coupled. - */ -#define SHORT_INQUIRY_LENGTH 36 - -struct scsi_inquiry_data -{ - uint8_t device; -#define SID_TYPE(inq_data) ((inq_data)->device & 0x1f) -#define SID_QUAL(inq_data) (((inq_data)->device & 0xE0) >> 5) -#define SID_QUAL_LU_CONNECTED 0x00 /* - * The specified peripheral device - * type is currently connected to - * logical unit. If the target cannot - * determine whether or not a physical - * device is currently connected, it - * shall also use this peripheral - * qualifier when returning the INQUIRY - * data. This peripheral qualifier - * does not mean that the device is - * ready for access by the initiator. - */ -#define SID_QUAL_LU_OFFLINE 0x01 /* - * The target is capable of supporting - * the specified peripheral device type - * on this logical unit; however, the - * physical device is not currently - * connected to this logical unit. - */ -#define SID_QUAL_RSVD 0x02 -#define SID_QUAL_BAD_LU 0x03 /* - * The target is not capable of - * supporting a physical device on - * this logical unit. For this - * peripheral qualifier the peripheral - * device type shall be set to 1Fh to - * provide compatibility with previous - * versions of SCSI. All other - * peripheral device type values are - * reserved for this peripheral - * qualifier. - */ -#define SID_QUAL_IS_VENDOR_UNIQUE(inq_data) ((SID_QUAL(inq_data) & 0x08) != 0) - uint8_t dev_qual2; -#define SID_QUAL2 0x7F -#define SID_IS_REMOVABLE(inq_data) (((inq_data)->dev_qual2 & 0x80) != 0) - uint8_t version; -#define SID_ANSI_REV(inq_data) ((inq_data)->version & 0x07) #define SCSI_REV_0 0 #define SCSI_REV_CCS 1 #define SCSI_REV_2 2 #define SCSI_REV_SPC 3 #define SCSI_REV_SPC2 4 -#define SID_ECMA 0x38 -#define SID_ISO 0xC0 - uint8_t response_format; -#define SID_AENC 0x80 -#define SID_TrmIOP 0x40 - uint8_t additional_length; - uint8_t reserved[2]; - uint8_t flags; -#define SID_SftRe 0x01 -#define SID_CmdQue 0x02 -#define SID_Linked 0x08 -#define SID_Sync 0x10 -#define SID_WBus16 0x20 -#define SID_WBus32 0x40 -#define SID_RelAdr 0x80 -#define SID_VENDOR_SIZE 8 - char vendor[SID_VENDOR_SIZE]; -#define SID_PRODUCT_SIZE 16 - char product[SID_PRODUCT_SIZE]; -#define SID_REVISION_SIZE 4 - char revision[SID_REVISION_SIZE]; - /* - * The following fields were taken from SCSI Primary Commands - 2 - * (SPC-2) Revision 14, Dated 11 November 1999 - */ -#define SID_VENDOR_SPECIFIC_0_SIZE 20 - uint8_t vendor_specific0[SID_VENDOR_SPECIFIC_0_SIZE]; - /* - * An extension of SCSI Parallel Specific Values - */ -#define SID_SPI_IUS 0x01 -#define SID_SPI_QAS 0x02 -#define SID_SPI_CLOCK_ST 0x00 -#define SID_SPI_CLOCK_DT 0x04 -#define SID_SPI_CLOCK_DT_ST 0x0C -#define SID_SPI_MASK 0x0F - uint8_t spi3data; - uint8_t reserved2; - /* - * Version Descriptors, stored 2 byte values. - */ - uint8_t version1[2]; - uint8_t version2[2]; - uint8_t version3[2]; - uint8_t version4[2]; - uint8_t version5[2]; - uint8_t version6[2]; - uint8_t version7[2]; - uint8_t version8[2]; - - uint8_t reserved3[22]; - -#define SID_VENDOR_SPECIFIC_1_SIZE 160 - uint8_t vendor_specific1[SID_VENDOR_SPECIFIC_1_SIZE]; -}; - -struct scsi_vpd_unit_serial_number -{ - uint8_t device; - uint8_t page_code; -#define SVPD_UNIT_SERIAL_NUMBER 0x80 - uint8_t reserved; - uint8_t length; /* serial number length */ -#define SVPD_SERIAL_NUM_SIZE 251 - uint8_t serial_num[SVPD_SERIAL_NUM_SIZE]; -}; - -struct scsi_read_capacity -{ - uint8_t opcode; - uint8_t byte2; - uint8_t addr[4]; - uint8_t unused[3]; - uint8_t control; -}; - -struct scsi_read_capacity_data -{ - uint8_t addr[4]; - uint8_t length[4]; -}; - -struct scsi_report_luns -{ - uint8_t opcode; - uint8_t byte2; - uint8_t unused[3]; - uint8_t addr[4]; - uint8_t control; -}; - -struct scsi_report_luns_data { - uint8_t length[4]; /* length of LUN inventory, in bytes */ - uint8_t reserved[4]; /* unused */ - /* - * LUN inventory- we only support the type zero form for now. - */ - struct { - uint8_t lundata[8]; - } luns[1]; -}; -#define RPL_LUNDATA_ATYP_MASK 0xc0 /* MBZ for type 0 lun */ -#define RPL_LUNDATA_T0LUN 1 /* @ lundata[1] */ - - struct scsi_sense_data { uint8_t error_code; @@ -757,41 +117,6 @@ struct scsi_sense_data #define SSD_FULL_SIZE sizeof(struct scsi_sense_data) }; -struct scsi_mode_header_6 -{ - uint8_t data_length; /* Sense data length */ - uint8_t medium_type; - uint8_t dev_spec; - uint8_t blk_desc_len; -}; - -struct scsi_mode_header_10 -{ - uint8_t data_length[2];/* Sense data length */ - uint8_t medium_type; - uint8_t dev_spec; - uint8_t unused[2]; - uint8_t blk_desc_len[2]; -}; - -struct scsi_mode_page_header -{ - uint8_t page_code; - uint8_t page_length; -}; - -struct scsi_mode_blk_desc -{ - uint8_t density; - uint8_t nblocks[3]; - uint8_t reserved; - uint8_t blklen[3]; -}; - -#define SCSI_DEFAULT_DENSITY 0x00 /* use 'default' density */ -#define SCSI_SAME_DENSITY 0x7f /* use 'same' density- >= SCSI-2 only */ - - /* * Status Byte */ @@ -807,76 +132,7 @@ struct scsi_mode_blk_desc #define SCSI_STATUS_ACA_ACTIVE 0x30 #define SCSI_STATUS_TASK_ABORTED 0x40 -struct scsi_inquiry_pattern { - uint8_t type; - uint8_t media_type; -#define SIP_MEDIA_REMOVABLE 0x01 -#define SIP_MEDIA_FIXED 0x02 - const char *vendor; - const char *product; - const char *revision; -}; - -struct scsi_static_inquiry_pattern { - uint8_t type; - uint8_t media_type; - char vendor[SID_VENDOR_SIZE+1]; - char product[SID_PRODUCT_SIZE+1]; - char revision[SID_REVISION_SIZE+1]; -}; - -struct scsi_sense_quirk_entry { - struct scsi_inquiry_pattern inq_pat; - int num_sense_keys; - int num_ascs; - struct sense_key_table_entry *sense_key_info; - struct asc_table_entry *asc_info; -}; - -struct sense_key_table_entry { - uint8_t sense_key; - uint32_t action; - const char *desc; -}; - -struct asc_table_entry { - uint8_t asc; - uint8_t ascq; - uint32_t action; - const char *desc; -}; - -struct op_table_entry { - uint8_t opcode; - uint16_t opmask; - const char *desc; -}; - -struct scsi_op_quirk_entry { - struct scsi_inquiry_pattern inq_pat; - int num_ops; - struct op_table_entry *op_table; -}; - -typedef enum { - SSS_FLAG_NONE = 0x00, - SSS_FLAG_PRINT_COMMAND = 0x01 -} scsi_sense_string_flags; - -extern const char *scsi_sense_key_text[]; - /************************* Large Disk Handling ********************************/ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -static __inline int aic_sector_div(u_long capacity, int heads, int sectors); - -static __inline int -aic_sector_div(u_long capacity, int heads, int sectors) -{ - return (capacity / (heads * sectors)); -} -#else -static __inline int aic_sector_div(sector_t capacity, int heads, int sectors); - static __inline int aic_sector_div(sector_t capacity, int heads, int sectors) { @@ -884,7 +140,6 @@ aic_sector_div(sector_t capacity, int heads, int sectors) sector_div(capacity, (heads * sectors)); return (int)capacity; } -#endif /**************************** Module Library Hack *****************************/ /* @@ -899,138 +154,15 @@ aic_sector_div(sector_t capacity, int heads, int sectors) #define AIC_LIB_ENTRY_EXPAND(x, prefix) AIC_LIB_ENTRY_CONCAT(x, prefix) #define AIC_LIB_ENTRY(x) AIC_LIB_ENTRY_EXPAND(x, AIC_LIB_PREFIX) -#define aic_sense_desc AIC_LIB_ENTRY(_sense_desc) -#define aic_sense_error_action AIC_LIB_ENTRY(_sense_error_action) -#define aic_error_action AIC_LIB_ENTRY(_error_action) -#define aic_op_desc AIC_LIB_ENTRY(_op_desc) -#define aic_cdb_string AIC_LIB_ENTRY(_cdb_string) -#define aic_print_inquiry AIC_LIB_ENTRY(_print_inquiry) #define aic_calc_syncsrate AIC_LIB_ENTRY(_calc_syncrate) -#define aic_calc_syncparam AIC_LIB_ENTRY(_calc_syncparam) -#define aic_calc_speed AIC_LIB_ENTRY(_calc_speed) -#define aic_inquiry_match AIC_LIB_ENTRY(_inquiry_match) -#define aic_static_inquiry_match AIC_LIB_ENTRY(_static_inquiry_match) -#define aic_parse_brace_option AIC_LIB_ENTRY(_parse_brace_option) - -/******************************************************************************/ - -void aic_sense_desc(int /*sense_key*/, int /*asc*/, - int /*ascq*/, struct scsi_inquiry_data*, - const char** /*sense_key_desc*/, - const char** /*asc_desc*/); -aic_sense_action aic_sense_error_action(struct scsi_sense_data*, - struct scsi_inquiry_data*, - uint32_t /*sense_flags*/); -uint32_t aic_error_action(struct scsi_cmnd *, - struct scsi_inquiry_data *, - cam_status, u_int); - -#define SF_RETRY_UA 0x01 -#define SF_NO_PRINT 0x02 -#define SF_QUIET_IR 0x04 /* Be quiet about Illegal Request reponses */ -#define SF_PRINT_ALWAYS 0x08 - - -const char * aic_op_desc(uint16_t /*opcode*/, struct scsi_inquiry_data*); -char * aic_cdb_string(uint8_t* /*cdb_ptr*/, char* /*cdb_string*/, - size_t /*len*/); -void aic_print_inquiry(struct scsi_inquiry_data*); u_int aic_calc_syncsrate(u_int /*period_factor*/); -u_int aic_calc_syncparam(u_int /*period*/); -u_int aic_calc_speed(u_int width, u_int period, u_int offset, - u_int min_rate); - -int aic_inquiry_match(caddr_t /*inqbuffer*/, - caddr_t /*table_entry*/); -int aic_static_inquiry_match(caddr_t /*inqbuffer*/, - caddr_t /*table_entry*/); typedef void aic_option_callback_t(u_long, int, int, int32_t); char * aic_parse_brace_option(char *opt_name, char *opt_arg, char *end, int depth, aic_option_callback_t *, u_long); -static __inline void scsi_extract_sense(struct scsi_sense_data *sense, - int *error_code, int *sense_key, - int *asc, int *ascq); -static __inline void scsi_ulto2b(uint32_t val, uint8_t *bytes); -static __inline void scsi_ulto3b(uint32_t val, uint8_t *bytes); -static __inline void scsi_ulto4b(uint32_t val, uint8_t *bytes); -static __inline uint32_t scsi_2btoul(uint8_t *bytes); -static __inline uint32_t scsi_3btoul(uint8_t *bytes); -static __inline int32_t scsi_3btol(uint8_t *bytes); -static __inline uint32_t scsi_4btoul(uint8_t *bytes); - -static __inline void scsi_extract_sense(struct scsi_sense_data *sense, - int *error_code, int *sense_key, - int *asc, int *ascq) -{ - *error_code = sense->error_code & SSD_ERRCODE; - *sense_key = sense->flags & SSD_KEY; - *asc = (sense->extra_len >= 5) ? sense->add_sense_code : 0; - *ascq = (sense->extra_len >= 6) ? sense->add_sense_code_qual : 0; -} - -static __inline void -scsi_ulto2b(uint32_t val, uint8_t *bytes) -{ - - bytes[0] = (val >> 8) & 0xff; - bytes[1] = val & 0xff; -} - -static __inline void -scsi_ulto3b(uint32_t val, uint8_t *bytes) -{ - - bytes[0] = (val >> 16) & 0xff; - bytes[1] = (val >> 8) & 0xff; - bytes[2] = val & 0xff; -} - -static __inline void -scsi_ulto4b(uint32_t val, uint8_t *bytes) -{ - - bytes[0] = (val >> 24) & 0xff; - bytes[1] = (val >> 16) & 0xff; - bytes[2] = (val >> 8) & 0xff; - bytes[3] = val & 0xff; -} - -static __inline uint32_t -scsi_2btoul(uint8_t *bytes) -{ - uint32_t rv; - - rv = (bytes[0] << 8) | - bytes[1]; - return (rv); -} - -static __inline uint32_t -scsi_3btoul(uint8_t *bytes) -{ - uint32_t rv; - - rv = (bytes[0] << 16) | - (bytes[1] << 8) | - bytes[2]; - return (rv); -} - -static __inline int32_t -scsi_3btol(uint8_t *bytes) -{ - uint32_t rc = scsi_3btoul(bytes); - - if (rc & 0x00800000) - rc |= 0xff000000; - - return (int32_t) rc; -} - static __inline uint32_t scsi_4btoul(uint8_t *bytes) { -- cgit v1.2.3-18-g5258 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 --- drivers/char/agp/generic.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index eb052427670..ac9da0ca36b 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 v1.2.3-18-g5258 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 --- drivers/Makefile | 2 +- drivers/acpi/Kconfig | 6 +----- drivers/acpi/Makefile | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/Makefile b/drivers/Makefile index 126a851d565..784b93c8888 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 66c60982ba4..14b70c259f3 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 ad67e8f61e6..952ab352af9 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 # -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/Kconfig | 10 ---------- drivers/acpi/Makefile | 4 ++-- drivers/char/ipmi/ipmi_si_intf.c | 6 +++--- 3 files changed, 5 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 14b70c259f3..f023a88ca39 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 952ab352af9..060afaf962a 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 a44b97304e9..c51b02d9dfd 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); } -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/Kconfig | 4 ---- drivers/acpi/Makefile | 6 +++--- drivers/char/tpm/Kconfig | 2 +- drivers/pci/hotplug/Kconfig | 4 ++-- drivers/pci/hotplug/Makefile | 4 ++-- drivers/pnp/Kconfig | 2 +- drivers/pnp/pnpacpi/Kconfig | 2 +- drivers/serial/Kconfig | 2 +- 8 files changed, 11 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index f023a88ca39..8cafa4adcf4 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 060afaf962a..b6a3c919238 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 79e9832ef1f..b58adfe3ed1 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 9c4a39ee89b..2f1289eebb3 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 31a307004b9..246586a3d91 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 6776308a1fe..c5143201419 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 0782cdc5009..b1854171b96 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 97034d3937f..56de409f486 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. -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 8cafa4adcf4..5e8f15ffe99 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 -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/Kconfig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 5e8f15ffe99..1117358256b 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 v1.2.3-18-g5258 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 --- drivers/acpi/Kconfig | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 1117358256b..83cac52308d 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 v1.2.3-18-g5258 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 --- drivers/acpi/Kconfig | 7 ++----- drivers/acpi/Makefile | 2 +- drivers/acpi/osl.c | 28 ---------------------------- 3 files changed, 3 insertions(+), 34 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 83cac52308d..3998c9d35fe 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 b6a3c919238..a18243488c6 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 81f0eb863a7..dc69d8760a5 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; -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/ibm_acpi.c | 1598 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 1159 insertions(+), 439 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c index ad85e10001f..5cc090326dd 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 v1.2.3-18-g5258 From e537a36d528053f6b9dbe6c88e763e835c0d3517 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 5 Jun 2005 02:07:14 -0500 Subject: [SCSI] use scatter lists for all block pc requests and simplify hw handlers Here's the proof of concept for this one. It converts scsi_wait_req to do correct REQ_BLOCK_PC submission (and works nicely in my setup). The final goal should be to eliminate struct scsi_request, but that can't be done until the character submission paths of sg and st are also modified. There's some loss of functionality to this: retries are no longer controllable (except by setting REQ_FASTFAIL) and the wait_req API needs to be altered, but it looks very nice. Signed-off-by: James Bottomley --- drivers/scsi/scsi_lib.c | 96 ++++++++++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 37 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 7a91ca3d32a..253c1a98d15 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -232,23 +232,6 @@ void scsi_do_req(struct scsi_request *sreq, const void *cmnd, } EXPORT_SYMBOL(scsi_do_req); -static void scsi_wait_done(struct scsi_cmnd *cmd) -{ - struct request *req = cmd->request; - struct request_queue *q = cmd->device->request_queue; - unsigned long flags; - - req->rq_status = RQ_SCSI_DONE; /* Busy, but indicate request done */ - - spin_lock_irqsave(q->queue_lock, flags); - if (blk_rq_tagged(req)) - blk_queue_end_tag(q, req); - spin_unlock_irqrestore(q->queue_lock, flags); - - if (req->waiting) - complete(req->waiting); -} - /* This is the end routine we get to if a command was never attached * to the request. Simply complete the request without changing * rq_status; this will cause a DRIVER_ERROR. */ @@ -263,19 +246,36 @@ void scsi_wait_req(struct scsi_request *sreq, const void *cmnd, void *buffer, unsigned bufflen, int timeout, int retries) { DECLARE_COMPLETION(wait); - - sreq->sr_request->waiting = &wait; - sreq->sr_request->rq_status = RQ_SCSI_BUSY; - sreq->sr_request->end_io = scsi_wait_req_end_io; - scsi_do_req(sreq, cmnd, buffer, bufflen, scsi_wait_done, - timeout, retries); + struct request *req; + + if (bufflen) + req = blk_rq_map_kern(sreq->sr_device->request_queue, + sreq->sr_data_direction == DMA_TO_DEVICE, + buffer, bufflen, __GFP_WAIT); + else + req = blk_get_request(sreq->sr_device->request_queue, READ, + __GFP_WAIT); + req->flags |= REQ_NOMERGE; + req->waiting = &wait; + req->end_io = scsi_wait_req_end_io; + req->cmd_len = COMMAND_SIZE(((u8 *)cmnd)[0]); + req->sense = sreq->sr_sense_buffer; + req->sense_len = 0; + memcpy(req->cmd, cmnd, req->cmd_len); + req->timeout = timeout; + req->flags |= REQ_BLOCK_PC; + req->rq_disk = NULL; + blk_insert_request(sreq->sr_device->request_queue, req, + sreq->sr_data_direction == DMA_TO_DEVICE, NULL); wait_for_completion(&wait); sreq->sr_request->waiting = NULL; - if (sreq->sr_request->rq_status != RQ_SCSI_DONE) + sreq->sr_result = req->errors; + if (req->errors) sreq->sr_result |= (DRIVER_ERROR << 24); - __scsi_release_request(sreq); + blk_put_request(req); } + EXPORT_SYMBOL(scsi_wait_req); /* @@ -878,11 +878,12 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes, return; } if (result) { - printk(KERN_INFO "SCSI error : <%d %d %d %d> return code " - "= 0x%x\n", cmd->device->host->host_no, - cmd->device->channel, - cmd->device->id, - cmd->device->lun, result); + if (!(req->flags & REQ_SPECIAL)) + printk(KERN_INFO "SCSI error : <%d %d %d %d> return code " + "= 0x%x\n", cmd->device->host->host_no, + cmd->device->channel, + cmd->device->id, + cmd->device->lun, result); if (driver_byte(result) & DRIVER_SENSE) scsi_print_sense("", cmd); @@ -1020,6 +1021,12 @@ static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk, return -EOPNOTSUPP; } +static void scsi_generic_done(struct scsi_cmnd *cmd) +{ + BUG_ON(!blk_pc_request(cmd->request)); + scsi_io_completion(cmd, cmd->result == 0 ? cmd->bufflen : 0, 0); +} + static int scsi_prep_fn(struct request_queue *q, struct request *req) { struct scsi_device *sdev = q->queuedata; @@ -1061,7 +1068,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) * these two cases differently. We differentiate by looking * at request->cmd, as this tells us the real story. */ - if (req->flags & REQ_SPECIAL) { + if (req->flags & REQ_SPECIAL && req->special) { struct scsi_request *sreq = req->special; if (sreq->sr_magic == SCSI_REQ_MAGIC) { @@ -1073,7 +1080,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) cmd = req->special; } else if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) { - if(unlikely(specials_only)) { + if(unlikely(specials_only) && !(req->flags & REQ_SPECIAL)) { if(specials_only == SDEV_QUIESCE || specials_only == SDEV_BLOCK) return BLKPREP_DEFER; @@ -1142,11 +1149,26 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) /* * Initialize the actual SCSI command for this request. */ - drv = *(struct scsi_driver **)req->rq_disk->private_data; - if (unlikely(!drv->init_command(cmd))) { - scsi_release_buffers(cmd); - scsi_put_command(cmd); - return BLKPREP_KILL; + if (req->rq_disk) { + drv = *(struct scsi_driver **)req->rq_disk->private_data; + if (unlikely(!drv->init_command(cmd))) { + scsi_release_buffers(cmd); + scsi_put_command(cmd); + return BLKPREP_KILL; + } + } else { + memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); + if (rq_data_dir(req) == WRITE) + cmd->sc_data_direction = DMA_TO_DEVICE; + else if (req->data_len) + cmd->sc_data_direction = DMA_FROM_DEVICE; + else + cmd->sc_data_direction = DMA_NONE; + + cmd->transfersize = req->data_len; + cmd->allowed = 3; + cmd->timeout_per_command = req->timeout; + cmd->done = scsi_generic_done; } } -- cgit v1.2.3-18-g5258 From 8e6401187ef7fb1edc2740832b48bf47ed2c90f2 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Wed, 15 Jun 2005 18:16:09 -0500 Subject: update scsi_wait_req to new format for blk_rq_map_kern() Signed-off-by: James Bottomley --- drivers/scsi/scsi_lib.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 253c1a98d15..60f07b6a5ff 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -246,15 +246,18 @@ void scsi_wait_req(struct scsi_request *sreq, const void *cmnd, void *buffer, unsigned bufflen, int timeout, int retries) { DECLARE_COMPLETION(wait); + int write = sreq->sr_data_direction == DMA_TO_DEVICE; struct request *req; - if (bufflen) - req = blk_rq_map_kern(sreq->sr_device->request_queue, - sreq->sr_data_direction == DMA_TO_DEVICE, - buffer, bufflen, __GFP_WAIT); - else - req = blk_get_request(sreq->sr_device->request_queue, READ, - __GFP_WAIT); + req = blk_get_request(sreq->sr_device->request_queue, write, + __GFP_WAIT); + if (bufflen && blk_rq_map_kern(sreq->sr_device->request_queue, req, + buffer, bufflen, __GFP_WAIT)) { + sreq->sr_result = DRIVER_ERROR << 24; + blk_put_request(req); + return; + } + req->flags |= REQ_NOMERGE; req->waiting = &wait; req->end_io = scsi_wait_req_end_io; -- cgit v1.2.3-18-g5258 From 392160335c798bbe94ab3aae6ea0c85d32b81bbc Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Wed, 15 Jun 2005 18:48:29 -0500 Subject: [SCSI] use scatter lists for all block pc requests and simplify hw handlers Original From: Mike Christie Add scsi_execute_req() as a replacement for scsi_wait_req() Fixed up various pieces (added REQ_SPECIAL and caught req use after free) Signed-off-by: James Bottomley --- drivers/scsi/scsi_lib.c | 51 ++++++++++++++++++++- drivers/scsi/scsi_scan.c | 112 +++++++++++++++++++++-------------------------- 2 files changed, 99 insertions(+), 64 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 60f07b6a5ff..b8212c563fe 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -246,7 +246,7 @@ void scsi_wait_req(struct scsi_request *sreq, const void *cmnd, void *buffer, unsigned bufflen, int timeout, int retries) { DECLARE_COMPLETION(wait); - int write = sreq->sr_data_direction == DMA_TO_DEVICE; + int write = (sreq->sr_data_direction == DMA_TO_DEVICE); struct request *req; req = blk_get_request(sreq->sr_device->request_queue, write, @@ -281,6 +281,55 @@ void scsi_wait_req(struct scsi_request *sreq, const void *cmnd, void *buffer, EXPORT_SYMBOL(scsi_wait_req); +/** + * scsi_execute_req - insert request and wait for the result + * @sdev: scsi device + * @cmd: scsi command + * @data_direction: data direction + * @buffer: data buffer + * @bufflen: len of buffer + * @sense: optional sense buffer + * @timeout: request timeout in seconds + * @retries: number of times to retry request + * + * scsi_execute_req returns the req->errors value which is the + * the scsi_cmnd result field. + **/ +int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd, + int data_direction, void *buffer, unsigned bufflen, + unsigned char *sense, int timeout, int retries) +{ + struct request *req; + int write = (data_direction == DMA_TO_DEVICE); + int ret = DRIVER_ERROR << 24; + + req = blk_get_request(sdev->request_queue, write, __GFP_WAIT); + + if (bufflen && blk_rq_map_kern(sdev->request_queue, req, + buffer, bufflen, __GFP_WAIT)) + goto out; + + req->cmd_len = COMMAND_SIZE(cmd[0]); + memcpy(req->cmd, cmd, req->cmd_len); + req->sense = sense; + req->sense_len = 0; + req->timeout = timeout; + req->flags |= REQ_BLOCK_PC | REQ_SPECIAL; + + /* + * head injection *required* here otherwise quiesce won't work + */ + blk_execute_rq(req->q, NULL, req, 1); + + ret = req->errors; + out: + blk_put_request(req); + + return ret; +} + +EXPORT_SYMBOL(scsi_execute_req); + /* * Function: scsi_init_cmd_errh() * diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 48edd67982a..d2ca4b8fbc1 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -111,15 +111,14 @@ MODULE_PARM_DESC(inq_timeout, /** * scsi_unlock_floptical - unlock device via a special MODE SENSE command - * @sreq: used to send the command + * @sdev: scsi device to send command to * @result: area to store the result of the MODE SENSE * * Description: - * Send a vendor specific MODE SENSE (not a MODE SELECT) command using - * @sreq to unlock a device, storing the (unused) results into result. + * Send a vendor specific MODE SENSE (not a MODE SELECT) command. * Called for BLIST_KEY devices. **/ -static void scsi_unlock_floptical(struct scsi_request *sreq, +static void scsi_unlock_floptical(struct scsi_device *sdev, unsigned char *result) { unsigned char scsi_cmd[MAX_COMMAND_SIZE]; @@ -129,11 +128,10 @@ static void scsi_unlock_floptical(struct scsi_request *sreq, scsi_cmd[1] = 0; scsi_cmd[2] = 0x2e; scsi_cmd[3] = 0; - scsi_cmd[4] = 0x2a; /* size */ + scsi_cmd[4] = 0x2a; /* size */ scsi_cmd[5] = 0; - sreq->sr_cmd_len = 0; - sreq->sr_data_direction = DMA_FROM_DEVICE; - scsi_wait_req(sreq, scsi_cmd, result, 0x2a /* size */, SCSI_TIMEOUT, 3); + scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, result, 0x2a, NULL, + SCSI_TIMEOUT, 3); } /** @@ -433,26 +431,26 @@ void scsi_target_reap(struct scsi_target *starget) /** * scsi_probe_lun - probe a single LUN using a SCSI INQUIRY - * @sreq: used to send the INQUIRY + * @sdev: scsi_device to probe * @inq_result: area to store the INQUIRY result + * @result_len: len of inq_result * @bflags: store any bflags found here * * Description: - * Probe the lun associated with @sreq using a standard SCSI INQUIRY; + * Probe the lun associated with @req using a standard SCSI INQUIRY; * - * If the INQUIRY is successful, sreq->sr_result is zero and: the + * If the INQUIRY is successful, zero is returned and the * INQUIRY data is in @inq_result; the scsi_level and INQUIRY length - * are copied to the Scsi_Device at @sreq->sr_device (sdev); - * any flags value is stored in *@bflags. + * are copied to the Scsi_Device any flags value is stored in *@bflags. **/ -static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result, - int *bflags) +static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result, + int result_len, int *bflags) { - struct scsi_device *sdev = sreq->sr_device; /* a bit ugly */ + char sense[SCSI_SENSE_BUFFERSIZE]; unsigned char scsi_cmd[MAX_COMMAND_SIZE]; int first_inquiry_len, try_inquiry_len, next_inquiry_len; int response_len = 0; - int pass, count; + int pass, count, result; struct scsi_sense_hdr sshdr; *bflags = 0; @@ -475,28 +473,28 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result, memset(scsi_cmd, 0, 6); scsi_cmd[0] = INQUIRY; scsi_cmd[4] = (unsigned char) try_inquiry_len; - sreq->sr_cmd_len = 0; - sreq->sr_data_direction = DMA_FROM_DEVICE; + memset(sense, 0, sizeof(sense)); memset(inq_result, 0, try_inquiry_len); - scsi_wait_req(sreq, (void *) scsi_cmd, (void *) inq_result, - try_inquiry_len, - HZ/2 + HZ*scsi_inq_timeout, 3); + + result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, + inq_result, try_inquiry_len, sense, + HZ / 2 + HZ * scsi_inq_timeout, 3); SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: INQUIRY %s " "with code 0x%x\n", - sreq->sr_result ? "failed" : "successful", - sreq->sr_result)); + result ? "failed" : "successful", result)); - if (sreq->sr_result) { + if (result) { /* * not-ready to ready transition [asc/ascq=0x28/0x0] * or power-on, reset [asc/ascq=0x29/0x0], continue. * INQUIRY should not yield UNIT_ATTENTION * but many buggy devices do so anyway. */ - if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) && - scsi_request_normalize_sense(sreq, &sshdr)) { + if ((driver_byte(result) & DRIVER_SENSE) && + scsi_normalize_sense(sense, sizeof(sense), + &sshdr)) { if ((sshdr.sense_key == UNIT_ATTENTION) && ((sshdr.asc == 0x28) || (sshdr.asc == 0x29)) && @@ -507,7 +505,7 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result, break; } - if (sreq->sr_result == 0) { + if (result == 0) { response_len = (unsigned char) inq_result[4] + 5; if (response_len > 255) response_len = first_inquiry_len; /* sanity */ @@ -556,8 +554,8 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result, /* If the last transfer attempt got an error, assume the * peripheral doesn't exist or is dead. */ - if (sreq->sr_result) - return; + if (result) + return -EIO; /* Don't report any more data than the device says is valid */ sdev->inquiry_len = min(try_inquiry_len, response_len); @@ -593,7 +591,7 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result, (sdev->scsi_level == 1 && (inq_result[3] & 0x0f) == 1)) sdev->scsi_level++; - return; + return 0; } /** @@ -800,9 +798,8 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget, void *hostdata) { struct scsi_device *sdev; - struct scsi_request *sreq; unsigned char *result; - int bflags, res = SCSI_SCAN_NO_RESPONSE; + int bflags, res = SCSI_SCAN_NO_RESPONSE, result_len = 256; struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); /* @@ -831,16 +828,13 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget, sdev = scsi_alloc_sdev(starget, lun, hostdata); if (!sdev) goto out; - sreq = scsi_allocate_request(sdev, GFP_ATOMIC); - if (!sreq) - goto out_free_sdev; - result = kmalloc(256, GFP_ATOMIC | + + result = kmalloc(result_len, GFP_ATOMIC | ((shost->unchecked_isa_dma) ? __GFP_DMA : 0)); if (!result) - goto out_free_sreq; + goto out_free_sdev; - scsi_probe_lun(sreq, result, &bflags); - if (sreq->sr_result) + if (scsi_probe_lun(sdev, result, result_len, &bflags)) goto out_free_result; /* @@ -868,7 +862,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget, if (res == SCSI_SCAN_LUN_PRESENT) { if (bflags & BLIST_KEY) { sdev->lockable = 0; - scsi_unlock_floptical(sreq, result); + scsi_unlock_floptical(sdev, result); } if (bflagsp) *bflagsp = bflags; @@ -876,8 +870,6 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget, out_free_result: kfree(result); - out_free_sreq: - scsi_release_request(sreq); out_free_sdev: if (res == SCSI_SCAN_LUN_PRESENT) { if (sdevp) { @@ -1065,13 +1057,14 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, int rescan) { char devname[64]; + char sense[SCSI_SENSE_BUFFERSIZE]; unsigned char scsi_cmd[MAX_COMMAND_SIZE]; unsigned int length; unsigned int lun; unsigned int num_luns; unsigned int retries; + int result; struct scsi_lun *lunp, *lun_data; - struct scsi_request *sreq; u8 *data; struct scsi_sense_hdr sshdr; struct scsi_target *starget = scsi_target(sdev); @@ -1089,10 +1082,6 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, if (bflags & BLIST_NOLUN) return 0; - sreq = scsi_allocate_request(sdev, GFP_ATOMIC); - if (!sreq) - goto out; - sprintf(devname, "host %d channel %d id %d", sdev->host->host_no, sdev->channel, sdev->id); @@ -1110,7 +1099,7 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, lun_data = kmalloc(length, GFP_ATOMIC | (sdev->host->unchecked_isa_dma ? __GFP_DMA : 0)); if (!lun_data) - goto out_release_request; + goto out; scsi_cmd[0] = REPORT_LUNS; @@ -1129,8 +1118,6 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, scsi_cmd[10] = 0; /* reserved */ scsi_cmd[11] = 0; /* control */ - sreq->sr_cmd_len = 0; - sreq->sr_data_direction = DMA_FROM_DEVICE; /* * We can get a UNIT ATTENTION, for example a power on/reset, so @@ -1146,29 +1133,30 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: Sending" " REPORT LUNS to %s (try %d)\n", devname, retries)); - scsi_wait_req(sreq, scsi_cmd, lun_data, length, - SCSI_TIMEOUT + 4*HZ, 3); + + memset(sense, 0, sizeof(sense)); + result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, + lun_data, length, sense, + SCSI_TIMEOUT + 4 * HZ, 3); + SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: REPORT LUNS" - " %s (try %d) result 0x%x\n", sreq->sr_result - ? "failed" : "successful", retries, - sreq->sr_result)); - if (sreq->sr_result == 0) + " %s (try %d) result 0x%x\n", result + ? "failed" : "successful", retries, result)); + if (result == 0) break; - else if (scsi_request_normalize_sense(sreq, &sshdr)) { + else if (scsi_normalize_sense(sense, sizeof(sense), &sshdr)) { if (sshdr.sense_key != UNIT_ATTENTION) break; } } - if (sreq->sr_result) { + if (result) { /* * The device probably does not support a REPORT LUN command */ kfree(lun_data); - scsi_release_request(sreq); return 1; } - scsi_release_request(sreq); /* * Get the length from the first four bytes of lun_data. @@ -1242,8 +1230,6 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, kfree(lun_data); return 0; - out_release_request: - scsi_release_request(sreq); out: /* * We are out of memory, don't try scanning any further. -- cgit v1.2.3-18-g5258 From ebd8bb7647e908e8654e565fa289b0300f9f8fa7 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Mon, 15 Aug 2005 16:13:19 -0500 Subject: [SCSI] fix transport class corner case after rework If your transport class sets the ATTRIBUTE_CONTAINER_NO_CLASSDEVS flag, then its configure method never gets called. This patch fixes that so that the configure method is called with a NULL classdev. Also remove a spurious inverted comma in the transport_class comments. Signed-off-by: James Bottomley --- drivers/base/attribute_container.c | 5 +++++ drivers/base/transport_class.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c index 62c093db11e..ebcae5c3413 100644 --- a/drivers/base/attribute_container.c +++ b/drivers/base/attribute_container.c @@ -237,6 +237,11 @@ attribute_container_device_trigger(struct device *dev, if (!cont->match(cont, dev)) continue; + if (attribute_container_no_classdevs(cont)) { + fn(cont, dev, NULL); + continue; + } + spin_lock(&cont->containers_lock); list_for_each_entry_safe(ic, tmp, &cont->containers, node) { if (dev == ic->classdev.dev) diff --git a/drivers/base/transport_class.c b/drivers/base/transport_class.c index 4fb4c5de847..f25e7c6b2d2 100644 --- a/drivers/base/transport_class.c +++ b/drivers/base/transport_class.c @@ -7,7 +7,7 @@ * This file is licensed under GPLv2 * * The basic idea here is to allow any "device controller" (which - * would most often be a Host Bus Adapter" to use the services of one + * would most often be a Host Bus Adapter to use the services of one * or more tranport classes for performing transport specific * services. Transport specific services are things that the generic * command layer doesn't want to know about (speed settings, line -- cgit v1.2.3-18-g5258 From 3b2946cc96bfafa90a555c70b2e876cbbd0fae98 Mon Sep 17 00:00:00 2001 From: Mark Haverkamp Date: Mon, 15 Aug 2005 10:50:24 -0700 Subject: [SCSI] aacraid: Fix aacraid probe breakage (updated) This patch fixes the bad assumption of the aacraid driver with use_sg. I used the 3w-xxxx driver fix as a guide for this. Signed-off-by: Mark Haverkamp Signed-off-by: James Bottomley --- drivers/scsi/aacraid/aachba.c | 79 +++++++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 26 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 8e349358729..83bfab73ff6 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -349,6 +349,27 @@ static void aac_io_done(struct scsi_cmnd * scsicmd) spin_unlock_irqrestore(host->host_lock, cpu_flags); } +static void aac_internal_transfer(struct scsi_cmnd *scsicmd, void *data, unsigned int offset, unsigned int len) +{ + void *buf; + unsigned int transfer_len; + struct scatterlist *sg = scsicmd->request_buffer; + + if (scsicmd->use_sg) { + buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; + transfer_len = min(sg->length, len + offset); + } else { + buf = scsicmd->request_buffer; + transfer_len = min(scsicmd->request_bufflen, len + offset); + } + + memcpy(buf + offset, data, transfer_len - offset); + + if (scsicmd->use_sg) + kunmap_atomic(buf - sg->offset, KM_IRQ0); + +} + static void get_container_name_callback(void *context, struct fib * fibptr) { struct aac_get_name_resp * get_name_reply; @@ -364,18 +385,22 @@ static void get_container_name_callback(void *context, struct fib * fibptr) /* Failure is irrelevant, using default value instead */ if ((le32_to_cpu(get_name_reply->status) == CT_OK) && (get_name_reply->data[0] != '\0')) { - int count; - char * dp; - char * sp = get_name_reply->data; + char *sp = get_name_reply->data; sp[sizeof(((struct aac_get_name_resp *)NULL)->data)-1] = '\0'; while (*sp == ' ') ++sp; - count = sizeof(((struct inquiry_data *)NULL)->inqd_pid); - dp = ((struct inquiry_data *)scsicmd->request_buffer)->inqd_pid; - if (*sp) do { - *dp++ = (*sp) ? *sp++ : ' '; - } while (--count > 0); + if (*sp) { + char d[sizeof(((struct inquiry_data *)NULL)->inqd_pid)]; + int count = sizeof(d); + char *dp = d; + do { + *dp++ = (*sp) ? *sp++ : ' '; + } while (--count > 0); + aac_internal_transfer(scsicmd, d, + offsetof(struct inquiry_data, inqd_pid), sizeof(d)); + } } + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; fib_complete(fibptr); @@ -1344,44 +1369,45 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) switch (scsicmd->cmnd[0]) { case INQUIRY: { - struct inquiry_data *inq_data_ptr; + struct inquiry_data inq_data; dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", scsicmd->device->id)); - inq_data_ptr = (struct inquiry_data *)scsicmd->request_buffer; - memset(inq_data_ptr, 0, sizeof (struct inquiry_data)); + memset(&inq_data, 0, sizeof (struct inquiry_data)); - inq_data_ptr->inqd_ver = 2; /* claim compliance to SCSI-2 */ - inq_data_ptr->inqd_dtq = 0x80; /* set RMB bit to one indicating that the medium is removable */ - inq_data_ptr->inqd_rdf = 2; /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */ - inq_data_ptr->inqd_len = 31; + inq_data.inqd_ver = 2; /* claim compliance to SCSI-2 */ + inq_data.inqd_dtq = 0x80; /* set RMB bit to one indicating that the medium is removable */ + inq_data.inqd_rdf = 2; /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */ + inq_data.inqd_len = 31; /*Format for "pad2" is RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */ - inq_data_ptr->inqd_pad2= 0x32 ; /*WBus16|Sync|CmdQue */ + inq_data.inqd_pad2= 0x32 ; /*WBus16|Sync|CmdQue */ /* * Set the Vendor, Product, and Revision Level * see: .c i.e. aac.c */ if (scsicmd->device->id == host->this_id) { - setinqstr(cardtype, (void *) (inq_data_ptr->inqd_vid), (sizeof(container_types)/sizeof(char *))); - inq_data_ptr->inqd_pdt = INQD_PDT_PROC; /* Processor device */ + setinqstr(cardtype, (void *) (inq_data.inqd_vid), (sizeof(container_types)/sizeof(char *))); + inq_data.inqd_pdt = INQD_PDT_PROC; /* Processor device */ + aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data)); scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; scsicmd->scsi_done(scsicmd); return 0; } - setinqstr(cardtype, (void *) (inq_data_ptr->inqd_vid), fsa_dev_ptr[cid].type); - inq_data_ptr->inqd_pdt = INQD_PDT_DA; /* Direct/random access device */ + setinqstr(cardtype, (void *) (inq_data.inqd_vid), fsa_dev_ptr[cid].type); + inq_data.inqd_pdt = INQD_PDT_DA; /* Direct/random access device */ + aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data)); return aac_get_container_name(scsicmd, cid); } case READ_CAPACITY: { u32 capacity; - char *cp; + char cp[8]; dprintk((KERN_DEBUG "READ CAPACITY command.\n")); if (fsa_dev_ptr[cid].size <= 0x100000000LL) capacity = fsa_dev_ptr[cid].size - 1; else capacity = (u32)-1; - cp = scsicmd->request_buffer; + cp[0] = (capacity >> 24) & 0xff; cp[1] = (capacity >> 16) & 0xff; cp[2] = (capacity >> 8) & 0xff; @@ -1390,6 +1416,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) cp[5] = 0; cp[6] = 2; cp[7] = 0; + aac_internal_transfer(scsicmd, cp, 0, sizeof(cp)); scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; scsicmd->scsi_done(scsicmd); @@ -1399,15 +1426,15 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) case MODE_SENSE: { - char *mode_buf; + char mode_buf[4]; dprintk((KERN_DEBUG "MODE SENSE command.\n")); - mode_buf = scsicmd->request_buffer; mode_buf[0] = 3; /* Mode data length */ mode_buf[1] = 0; /* Medium type - default */ mode_buf[2] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */ mode_buf[3] = 0; /* Block descriptor length */ + aac_internal_transfer(scsicmd, mode_buf, 0, sizeof(mode_buf)); scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; scsicmd->scsi_done(scsicmd); @@ -1415,10 +1442,9 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) } case MODE_SENSE_10: { - char *mode_buf; + char mode_buf[8]; dprintk((KERN_DEBUG "MODE SENSE 10 byte command.\n")); - mode_buf = scsicmd->request_buffer; mode_buf[0] = 0; /* Mode data length (MSB) */ mode_buf[1] = 6; /* Mode data length (LSB) */ mode_buf[2] = 0; /* Medium type - default */ @@ -1427,6 +1453,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) mode_buf[5] = 0; /* reserved */ mode_buf[6] = 0; /* Block descriptor length (MSB) */ mode_buf[7] = 0; /* Block descriptor length (LSB) */ + aac_internal_transfer(scsicmd, mode_buf, 0, sizeof(mode_buf)); scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; scsicmd->scsi_done(scsicmd); -- cgit v1.2.3-18-g5258 From be042f240a8528b8f6b741a484cdbbf515698388 Mon Sep 17 00:00:00 2001 From: Dave C Boutcher Date: Mon, 15 Aug 2005 16:52:58 -0500 Subject: [SCSI] ibmvscsi eh locking With the removal of the spinlocking around eh calls, we need to add a little more locking back in, otherwise we do some naked list manipulation. Signed-off-by: Dave Boutcher Signed-off-by: James Bottomley --- drivers/scsi/ibmvscsi/ibmvscsi.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index fe09d145542..1ae800ae93d 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -826,11 +826,13 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) struct srp_event_struct *tmp_evt, *found_evt; union viosrp_iu srp_rsp; int rsp_rc; + unsigned long flags; u16 lun = lun_from_dev(cmd->device); /* First, find this command in our sent list so we can figure * out the correct tag */ + spin_lock_irqsave(hostdata->host->host_lock, flags); found_evt = NULL; list_for_each_entry(tmp_evt, &hostdata->sent, list) { if (tmp_evt->cmnd == cmd) { @@ -839,11 +841,14 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) } } - if (!found_evt) + if (!found_evt) { + spin_unlock_irqrestore(hostdata->host->host_lock, flags); return FAILED; + } evt = get_event_struct(&hostdata->pool); if (evt == NULL) { + spin_unlock_irqrestore(hostdata->host->host_lock, flags); printk(KERN_ERR "ibmvscsi: failed to allocate abort event\n"); return FAILED; } @@ -867,7 +872,9 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) evt->sync_srp = &srp_rsp; init_completion(&evt->comp); - if (ibmvscsi_send_srp_event(evt, hostdata) != 0) { + rsp_rc = ibmvscsi_send_srp_event(evt, hostdata); + spin_unlock_irqrestore(hostdata->host->host_lock, flags); + if (rsp_rc != 0) { printk(KERN_ERR "ibmvscsi: failed to send abort() event\n"); return FAILED; } @@ -901,6 +908,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) * The event is no longer in our list. Make sure it didn't * complete while we were aborting */ + spin_lock_irqsave(hostdata->host->host_lock, flags); found_evt = NULL; list_for_each_entry(tmp_evt, &hostdata->sent, list) { if (tmp_evt->cmnd == cmd) { @@ -910,6 +918,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) } if (found_evt == NULL) { + spin_unlock_irqrestore(hostdata->host->host_lock, flags); printk(KERN_INFO "ibmvscsi: aborted task tag 0x%lx completed\n", tsk_mgmt->managed_task_tag); @@ -924,6 +933,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) list_del(&found_evt->list); unmap_cmd_data(&found_evt->iu.srp.cmd, found_evt->hostdata->dev); free_event_struct(&found_evt->hostdata->pool, found_evt); + spin_unlock_irqrestore(hostdata->host->host_lock, flags); atomic_inc(&hostdata->request_limit); return SUCCESS; } @@ -943,10 +953,13 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) struct srp_event_struct *tmp_evt, *pos; union viosrp_iu srp_rsp; int rsp_rc; + unsigned long flags; u16 lun = lun_from_dev(cmd->device); + spin_lock_irqsave(hostdata->host->host_lock, flags); evt = get_event_struct(&hostdata->pool); if (evt == NULL) { + spin_unlock_irqrestore(hostdata->host->host_lock, flags); printk(KERN_ERR "ibmvscsi: failed to allocate reset event\n"); return FAILED; } @@ -969,7 +982,9 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) evt->sync_srp = &srp_rsp; init_completion(&evt->comp); - if (ibmvscsi_send_srp_event(evt, hostdata) != 0) { + rsp_rc = ibmvscsi_send_srp_event(evt, hostdata); + spin_unlock_irqrestore(hostdata->host->host_lock, flags); + if (rsp_rc != 0) { printk(KERN_ERR "ibmvscsi: failed to send reset event\n"); return FAILED; } @@ -1002,6 +1017,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) /* We need to find all commands for this LUN that have not yet been * responded to, and fail them with DID_RESET */ + spin_lock_irqsave(hostdata->host->host_lock, flags); list_for_each_entry_safe(tmp_evt, pos, &hostdata->sent, list) { if ((tmp_evt->cmnd) && (tmp_evt->cmnd->device == cmd->device)) { if (tmp_evt->cmnd) @@ -1017,6 +1033,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) tmp_evt->done(tmp_evt); } } + spin_unlock_irqrestore(hostdata->host->host_lock, flags); return SUCCESS; } -- cgit v1.2.3-18-g5258 From de540a53f2f7b68a48c3021e5ab78ea49f6cf21c Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sat, 20 Aug 2005 21:27:27 +0200 Subject: [SCSI] drivers/scsi/constants.c should include scsi_dbg.h C files should include the files with the prototypes for their global functions. Signed-off-by: Adrian Bunk Signed-off-by: James Bottomley --- drivers/scsi/constants.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index ec161733a82..0d58d3538bd 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -17,6 +17,7 @@ #include #include #include +#include -- cgit v1.2.3-18-g5258 From 8224bfa84d510630b40ea460b2bb380c91acb8ae Mon Sep 17 00:00:00 2001 From: Dave C Boutcher Date: Mon, 22 Aug 2005 14:38:26 -0500 Subject: [SCSI] ibmvscsi timeout fix This patch fixes a long term borkenness in ibmvscsi where we were using the wrong timeout field from the scsi command (and using the wrong units.) Now broken by the fact that the scsi_cmnd timeout field is gone entirely. This only worked before because all the SCSI targets assumed that 0 was default. Signed-off-by: Dave Boutcher Signed-off-by: James Bottomley --- drivers/scsi/ibmvscsi/ibmvscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 1ae800ae93d..e3e6752c410 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -594,7 +594,7 @@ static int ibmvscsi_queuecommand(struct scsi_cmnd *cmnd, init_event_struct(evt_struct, handle_cmd_rsp, VIOSRP_SRP_FORMAT, - cmnd->timeout); + cmnd->timeout_per_command/HZ); evt_struct->cmnd = cmnd; evt_struct->cmnd_done = done; -- cgit v1.2.3-18-g5258 From 51490c89f95b8581782e9baa855da166441852be Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Tue, 5 Jul 2005 18:18:08 -0700 Subject: [SCSI] sr.c: Fix getting wrong size Here's the problem. Try to do this on 2.6.12: - Kill udev and HAL - Insert a CD-ROM into a SCSI or USB CD-ROM drive - Run dd if=/dev/scd0 - cat /sys/block/sr0/size - Eject the CD, insert a different one - Run dd if=/dev/scd0 This is likely to do "access beyond the end of device", if you let it - cat /sys/block/sr0/size This shows the size of a previous CD, even though dd was supposed to revalidate the device. - Run dd if=/dev/scd0 The second run of dd works correctly! The bug was introduced in 2.5.31, when Al fixes the recursive opens in partitioning. Before, the code worked like this: - Block layer called cdrom_open directly - cdrom_open called sr_open - sr_open called check_disk_change - check_disk_change called sr_media_change - sr_media_change did cd->needs_disk_change=1 - before returning sr_open tested cd->needs_disk_change and called get_sector_size. In 2.6.12, the check_disk_change is called from cdrom_open only. Thus: - Block layer calls sr_bd_open - sr_bd_open calls cdrom_open - cdrom_open calls sr_open - sr_open tests cd->needs_disk_change, which wasn't set yet; returns - cdrom_open calls check_disk_change - check_disk_change calls sr_media_change - sr_media_change does cd->needs_disk_change=1, but nobody cares Acked by: Alexander Viro Signed-off-by: James Bottomley --- drivers/scsi/sr.c | 24 ++---------------------- drivers/scsi/sr.h | 1 - 2 files changed, 2 insertions(+), 23 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 2f259f24952..f63d8c6c2a3 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -199,15 +199,7 @@ int sr_media_change(struct cdrom_device_info *cdi, int slot) /* check multisession offset etc */ sr_cd_check(cdi); - /* - * If the disk changed, the capacity will now be different, - * so we force a re-read of this information - * Force 2048 for the sector size so that filesystems won't - * be trying to use something that is too small if the disc - * has changed. - */ - cd->needs_sector_size = 1; - cd->device->sector_size = 2048; + get_sectorsize(cd); } return retval; } @@ -538,13 +530,6 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose) if (!scsi_block_when_processing_errors(sdev)) goto error_out; - /* - * If this device did not have media in the drive at boot time, then - * we would have been unable to get the sector size. Check to see if - * this is the case, and try again. - */ - if (cd->needs_sector_size) - get_sectorsize(cd); return 0; error_out: @@ -604,7 +589,6 @@ static int sr_probe(struct device *dev) cd->driver = &sr_template; cd->disk = disk; cd->capacity = 0x1fffff; - cd->needs_sector_size = 1; cd->device->changed = 1; /* force recheck CD type */ cd->use = 1; cd->readcd_known = 0; @@ -694,7 +678,6 @@ static void get_sectorsize(struct scsi_cd *cd) if (the_result) { cd->capacity = 0x1fffff; sector_size = 2048; /* A guess, just in case */ - cd->needs_sector_size = 1; } else { #if 0 if (cdrom_get_last_written(&cd->cdi, @@ -727,7 +710,6 @@ static void get_sectorsize(struct scsi_cd *cd) printk("%s: unsupported sector size %d.\n", cd->cdi.name, sector_size); cd->capacity = 0; - cd->needs_sector_size = 1; } cd->device->sector_size = sector_size; @@ -736,7 +718,6 @@ static void get_sectorsize(struct scsi_cd *cd) * Add this so that we have the ability to correctly gauge * what the device is capable of. */ - cd->needs_sector_size = 0; set_capacity(cd->disk, cd->capacity); } @@ -748,8 +729,7 @@ out: Enomem: cd->capacity = 0x1fffff; - sector_size = 2048; /* A guess, just in case */ - cd->needs_sector_size = 1; + cd->device->sector_size = 2048; /* A guess, just in case */ if (SRpnt) scsi_release_request(SRpnt); goto out; diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h index 0b317800720..d2bcd99c272 100644 --- a/drivers/scsi/sr.h +++ b/drivers/scsi/sr.h @@ -33,7 +33,6 @@ typedef struct scsi_cd { struct scsi_device *device; unsigned int vendor; /* vendor code, see sr_vendor.c */ unsigned long ms_offset; /* for reading multisession-CD's */ - unsigned needs_sector_size:1; /* needs to get sector size */ unsigned use:1; /* is this device still supportable */ unsigned xa_flag:1; /* CD has XA sectors ? */ unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */ -- cgit v1.2.3-18-g5258 From 1cf72699c1530c3e4ac3d58344f6a6a40a2f46d3 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 28 Aug 2005 11:27:01 -0500 Subject: [SCSI] convert the remaining mid-layer pieces to scsi_execute_req After this, we just have some drivers, all the ULDs and the SPI transport class using scsi_wait_req(). Signed-off-by: James Bottomley --- drivers/scsi/scsi_ioctl.c | 46 ++++++++--------------- drivers/scsi/scsi_lib.c | 94 +++++++++++++++++------------------------------ drivers/scsi/sd.c | 5 ++- drivers/scsi/sr.c | 2 +- 4 files changed, 53 insertions(+), 94 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index f5bf5c07be9..5f399c9c68e 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -88,25 +88,21 @@ static int ioctl_probe(struct Scsi_Host *host, void __user *buffer) static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, int timeout, int retries) { - struct scsi_request *sreq; int result; struct scsi_sense_hdr sshdr; + char sense[SCSI_SENSE_BUFFERSIZE]; SCSI_LOG_IOCTL(1, printk("Trying ioctl with scsi command %d\n", *cmd)); - sreq = scsi_allocate_request(sdev, GFP_KERNEL); - if (!sreq) { - printk(KERN_WARNING "SCSI internal ioctl failed, no memory\n"); - return -ENOMEM; - } - sreq->sr_data_direction = DMA_NONE; - scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries); + memset(sense, 0, sizeof(*sense)); + result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, + sense, timeout, retries); - SCSI_LOG_IOCTL(2, printk("Ioctl returned 0x%x\n", sreq->sr_result)); + SCSI_LOG_IOCTL(2, printk("Ioctl returned 0x%x\n", result)); - if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) && - (scsi_request_normalize_sense(sreq, &sshdr))) { + if ((driver_byte(result) & DRIVER_SENSE) && + (scsi_normalize_sense(sense, sizeof(*sense), &sshdr))) { switch (sshdr.sense_key) { case ILLEGAL_REQUEST: if (cmd[0] == ALLOW_MEDIUM_REMOVAL) @@ -125,7 +121,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, case UNIT_ATTENTION: if (sdev->removable) { sdev->changed = 1; - sreq->sr_result = 0; /* This is no longer considered an error */ + result = 0; /* This is no longer considered an error */ break; } default: /* Fall through for non-removable media */ @@ -135,15 +131,13 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, sdev->channel, sdev->id, sdev->lun, - sreq->sr_result); - scsi_print_req_sense(" ", sreq); + result); + __scsi_print_sense(" ", sense, sizeof(*sense)); break; } } - result = sreq->sr_result; SCSI_LOG_IOCTL(2, printk("IOCTL Releasing command\n")); - scsi_release_request(sreq); return result; } @@ -208,8 +202,8 @@ int scsi_ioctl_send_command(struct scsi_device *sdev, { char *buf; unsigned char cmd[MAX_COMMAND_SIZE]; + unsigned char sense[SCSI_SENSE_BUFFERSIZE]; char __user *cmd_in; - struct scsi_request *sreq; unsigned char opcode; unsigned int inlen, outlen, cmdlen; unsigned int needed, buf_needed; @@ -321,31 +315,23 @@ int scsi_ioctl_send_command(struct scsi_device *sdev, break; } - sreq = scsi_allocate_request(sdev, GFP_KERNEL); - if (!sreq) { - result = -EINTR; - goto error; - } - - sreq->sr_data_direction = data_direction; - scsi_wait_req(sreq, cmd, buf, needed, timeout, retries); - + result = scsi_execute_req(sdev, cmd, data_direction, buf, needed, + sense, timeout, retries); + /* * If there was an error condition, pass the info back to the user. */ - result = sreq->sr_result; if (result) { - int sb_len = sizeof(sreq->sr_sense_buffer); + int sb_len = sizeof(*sense); sb_len = (sb_len > OMAX_SB_LEN) ? OMAX_SB_LEN : sb_len; - if (copy_to_user(cmd_in, sreq->sr_sense_buffer, sb_len)) + if (copy_to_user(cmd_in, sense, sb_len)) result = -EFAULT; } else { if (copy_to_user(cmd_in, buf, outlen)) result = -EFAULT; } - scsi_release_request(sreq); error: kfree(buf); return result; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 278e0c99b2a..3f3accd6cd4 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1615,7 +1615,7 @@ void scsi_exit_queue(void) /** * __scsi_mode_sense - issue a mode sense, falling back from 10 to * six bytes if necessary. - * @sreq: SCSI request to fill in with the MODE_SENSE + * @sdev: SCSI device to be queried * @dbd: set if mode sense will allow block descriptors to be returned * @modepage: mode page being requested * @buffer: request buffer (may not be smaller than eight bytes) @@ -1623,26 +1623,38 @@ void scsi_exit_queue(void) * @timeout: command timeout * @retries: number of retries before failing * @data: returns a structure abstracting the mode header data + * @sense: place to put sense data (or NULL if no sense to be collected). + * must be SCSI_SENSE_BUFFERSIZE big. * * Returns zero if unsuccessful, or the header offset (either 4 * or 8 depending on whether a six or ten byte command was * issued) if successful. **/ int -__scsi_mode_sense(struct scsi_request *sreq, int dbd, int modepage, +scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, unsigned char *buffer, int len, int timeout, int retries, - struct scsi_mode_data *data) { + struct scsi_mode_data *data, char *sense) { unsigned char cmd[12]; int use_10_for_ms; int header_length; + int result; + char *sense_buffer = NULL; memset(data, 0, sizeof(*data)); memset(&cmd[0], 0, 12); cmd[1] = dbd & 0x18; /* allows DBD and LLBA bits */ cmd[2] = modepage; + if (!sense) { + sense_buffer = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); + if (!sense_buffer) { + dev_printk(KERN_ERR, &sdev->sdev_gendev, "failed to allocate sense buffer\n"); + return 0; + } + sense = sense_buffer; + } retry: - use_10_for_ms = sreq->sr_device->use_10_for_ms; + use_10_for_ms = sdev->use_10_for_ms; if (use_10_for_ms) { if (len < 8) @@ -1660,36 +1672,35 @@ __scsi_mode_sense(struct scsi_request *sreq, int dbd, int modepage, header_length = 4; } - sreq->sr_cmd_len = 0; - memset(sreq->sr_sense_buffer, 0, sizeof(sreq->sr_sense_buffer)); - sreq->sr_data_direction = DMA_FROM_DEVICE; + memset(sense, 0, SCSI_SENSE_BUFFERSIZE); memset(buffer, 0, len); - scsi_wait_req(sreq, cmd, buffer, len, timeout, retries); + result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, + sense, timeout, retries); /* This code looks awful: what it's doing is making sure an * ILLEGAL REQUEST sense return identifies the actual command * byte as the problem. MODE_SENSE commands can return * ILLEGAL REQUEST if the code page isn't supported */ - if (use_10_for_ms && !scsi_status_is_good(sreq->sr_result) && - (driver_byte(sreq->sr_result) & DRIVER_SENSE)) { + if (use_10_for_ms && !scsi_status_is_good(result) && + (driver_byte(result) & DRIVER_SENSE)) { struct scsi_sense_hdr sshdr; - if (scsi_request_normalize_sense(sreq, &sshdr)) { + if (scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, &sshdr)) { if ((sshdr.sense_key == ILLEGAL_REQUEST) && (sshdr.asc == 0x20) && (sshdr.ascq == 0)) { /* * Invalid command operation code */ - sreq->sr_device->use_10_for_ms = 0; + sdev->use_10_for_ms = 0; goto retry; } } } - if(scsi_status_is_good(sreq->sr_result)) { + if(scsi_status_is_good(result)) { data->header_length = header_length; if(use_10_for_ms) { data->length = buffer[0]*256 + buffer[1] + 2; @@ -1706,73 +1717,34 @@ __scsi_mode_sense(struct scsi_request *sreq, int dbd, int modepage, } } - return sreq->sr_result; -} -EXPORT_SYMBOL(__scsi_mode_sense); - -/** - * scsi_mode_sense - issue a mode sense, falling back from 10 to - * six bytes if necessary. - * @sdev: scsi device to send command to. - * @dbd: set if mode sense will disable block descriptors in the return - * @modepage: mode page being requested - * @buffer: request buffer (may not be smaller than eight bytes) - * @len: length of request buffer. - * @timeout: command timeout - * @retries: number of retries before failing - * - * Returns zero if unsuccessful, or the header offset (either 4 - * or 8 depending on whether a six or ten byte command was - * issued) if successful. - **/ -int -scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, - unsigned char *buffer, int len, int timeout, int retries, - struct scsi_mode_data *data) -{ - struct scsi_request *sreq = scsi_allocate_request(sdev, GFP_KERNEL); - int ret; - - if (!sreq) - return -1; - - ret = __scsi_mode_sense(sreq, dbd, modepage, buffer, len, - timeout, retries, data); - - scsi_release_request(sreq); - - return ret; + kfree(sense_buffer); + return result; } EXPORT_SYMBOL(scsi_mode_sense); int scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries) { - struct scsi_request *sreq; char cmd[] = { TEST_UNIT_READY, 0, 0, 0, 0, 0, }; + char sense[SCSI_SENSE_BUFFERSIZE]; int result; - sreq = scsi_allocate_request(sdev, GFP_KERNEL); - if (!sreq) - return -ENOMEM; - - sreq->sr_data_direction = DMA_NONE; - scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries); + result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sense, + timeout, retries); - if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) && sdev->removable) { + if ((driver_byte(result) & DRIVER_SENSE) && sdev->removable) { struct scsi_sense_hdr sshdr; - if ((scsi_request_normalize_sense(sreq, &sshdr)) && + if ((scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, + &sshdr)) && ((sshdr.sense_key == UNIT_ATTENTION) || (sshdr.sense_key == NOT_READY))) { sdev->changed = 1; - sreq->sr_result = 0; + result = 0; } } - result = sreq->sr_result; - scsi_release_request(sreq); return result; } EXPORT_SYMBOL(scsi_test_unit_ready); diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 0410e1bf109..15c2039059c 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1299,8 +1299,9 @@ static inline int sd_do_mode_sense(struct scsi_request *SRpnt, int dbd, int modepage, unsigned char *buffer, int len, struct scsi_mode_data *data) { - return __scsi_mode_sense(SRpnt, dbd, modepage, buffer, len, - SD_TIMEOUT, SD_MAX_RETRIES, data); + return scsi_mode_sense(SRpnt->sr_device, dbd, modepage, buffer, len, + SD_TIMEOUT, SD_MAX_RETRIES, data, + SRpnt->sr_sense_buffer); } /* diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 2f259f24952..8cbe6e00418 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -817,7 +817,7 @@ static void get_capabilities(struct scsi_cd *cd) /* ask for mode page 0x2a */ rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128, - SR_TIMEOUT, 3, &data); + SR_TIMEOUT, 3, &data, NULL); if (!scsi_status_is_good(rc)) { /* failed, drive doesn't have capabilities mode page */ -- cgit v1.2.3-18-g5258 From 33aa687db90dd8541bd5e9a762eebf880eaee767 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 28 Aug 2005 11:31:14 -0500 Subject: [SCSI] convert SPI transport class to scsi_execute This one's slightly more difficult. The transport class uses REQ_FAILFAST, so another interface (scsi_execute) had to be invented to take the extra flag. Also, the sense functions are shifted around to allow spi_execute to place data directly into a struct scsi_sense_hdr. With this change, there's probably a lot of unnecessary sense buffer allocation going on which we can fix later. Signed-off-by: James Bottomley --- drivers/scsi/scsi_error.c | 6 +- drivers/scsi/scsi_lib.c | 13 ++-- drivers/scsi/scsi_transport_spi.c | 124 ++++++++++++++++++-------------------- 3 files changed, 69 insertions(+), 74 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index e9c451ba71f..2686d5672e5 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1847,12 +1847,16 @@ EXPORT_SYMBOL(scsi_reset_provider); int scsi_normalize_sense(const u8 *sense_buffer, int sb_len, struct scsi_sense_hdr *sshdr) { - if (!sense_buffer || !sb_len || (sense_buffer[0] & 0x70) != 0x70) + if (!sense_buffer || !sb_len) return 0; memset(sshdr, 0, sizeof(struct scsi_sense_hdr)); sshdr->response_code = (sense_buffer[0] & 0x7f); + + if (!scsi_sense_valid(sshdr)) + return 0; + if (sshdr->response_code >= 0x72) { /* * descriptor format diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 3f3accd6cd4..42edf29223a 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -282,7 +282,7 @@ void scsi_wait_req(struct scsi_request *sreq, const void *cmnd, void *buffer, EXPORT_SYMBOL(scsi_wait_req); /** - * scsi_execute_req - insert request and wait for the result + * scsi_execute - insert request and wait for the result * @sdev: scsi device * @cmd: scsi command * @data_direction: data direction @@ -291,13 +291,14 @@ EXPORT_SYMBOL(scsi_wait_req); * @sense: optional sense buffer * @timeout: request timeout in seconds * @retries: number of times to retry request + * @flags: or into request flags; * * scsi_execute_req returns the req->errors value which is the * the scsi_cmnd result field. **/ -int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd, - int data_direction, void *buffer, unsigned bufflen, - unsigned char *sense, int timeout, int retries) +int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, + int data_direction, void *buffer, unsigned bufflen, + unsigned char *sense, int timeout, int retries, int flags) { struct request *req; int write = (data_direction == DMA_TO_DEVICE); @@ -314,7 +315,7 @@ int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd, req->sense = sense; req->sense_len = 0; req->timeout = timeout; - req->flags |= REQ_BLOCK_PC | REQ_SPECIAL; + req->flags |= flags | REQ_BLOCK_PC | REQ_SPECIAL; /* * head injection *required* here otherwise quiesce won't work @@ -328,7 +329,7 @@ int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd, return ret; } -EXPORT_SYMBOL(scsi_execute_req); +EXPORT_SYMBOL(scsi_execute); /* * Function: scsi_init_cmd_errh() diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 89f6b7feb9c..874042f1899 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -28,7 +28,7 @@ #include "scsi_priv.h" #include #include -#include +#include #include #include #include @@ -108,25 +108,33 @@ static int sprint_frac(char *dest, int value, int denom) /* Modification of scsi_wait_req that will clear UNIT ATTENTION conditions * resulting from (likely) bus and device resets */ -static void spi_wait_req(struct scsi_request *sreq, const void *cmd, - void *buffer, unsigned bufflen) +static int spi_execute(struct scsi_device *sdev, const void *cmd, + enum dma_data_direction dir, + void *buffer, unsigned bufflen, + struct scsi_sense_hdr *sshdr) { - int i; + int i, result; + unsigned char sense[SCSI_SENSE_BUFFERSIZE]; for(i = 0; i < DV_RETRIES; i++) { - sreq->sr_request->flags |= REQ_FAILFAST; - - scsi_wait_req(sreq, cmd, buffer, bufflen, - DV_TIMEOUT, /* retries */ 1); - if (sreq->sr_result & DRIVER_SENSE) { - struct scsi_sense_hdr sshdr; - if (scsi_request_normalize_sense(sreq, &sshdr) - && sshdr.sense_key == UNIT_ATTENTION) + /* FIXME: need to set REQ_FAILFAST */ + result = scsi_execute(sdev, cmd, dir, buffer, bufflen, + sense, DV_TIMEOUT, /* retries */ 1, + REQ_FAILFAST); + if (result & DRIVER_SENSE) { + struct scsi_sense_hdr sshdr_tmp; + if (!sshdr) + sshdr = &sshdr_tmp; + + if (scsi_normalize_sense(sense, sizeof(*sense), + sshdr) + && sshdr->sense_key == UNIT_ATTENTION) continue; } break; } + return result; } static struct { @@ -546,13 +554,13 @@ enum spi_compare_returns { /* This is for read/write Domain Validation: If the device supports * an echo buffer, we do read/write tests to it */ static enum spi_compare_returns -spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer, +spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer, u8 *ptr, const int retries) { - struct scsi_device *sdev = sreq->sr_device; int len = ptr - buffer; - int j, k, r; + int j, k, r, result; unsigned int pattern = 0x0000ffff; + struct scsi_sense_hdr sshdr; const char spi_write_buffer[] = { WRITE_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0 @@ -597,14 +605,12 @@ spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer, } for (r = 0; r < retries; r++) { - sreq->sr_cmd_len = 0; /* wait_req to fill in */ - sreq->sr_data_direction = DMA_TO_DEVICE; - spi_wait_req(sreq, spi_write_buffer, buffer, len); - if(sreq->sr_result || !scsi_device_online(sdev)) { - struct scsi_sense_hdr sshdr; + result = spi_execute(sdev, spi_write_buffer, DMA_TO_DEVICE, + buffer, len, &sshdr); + if(result || !scsi_device_online(sdev)) { scsi_device_set_state(sdev, SDEV_QUIESCE); - if (scsi_request_normalize_sense(sreq, &sshdr) + if (scsi_sense_valid(&sshdr) && sshdr.sense_key == ILLEGAL_REQUEST /* INVALID FIELD IN CDB */ && sshdr.asc == 0x24 && sshdr.ascq == 0x00) @@ -616,14 +622,13 @@ spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer, return SPI_COMPARE_SKIP_TEST; - SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Write Buffer failure %x\n", sreq->sr_result); + SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Write Buffer failure %x\n", result); return SPI_COMPARE_FAILURE; } memset(ptr, 0, len); - sreq->sr_cmd_len = 0; /* wait_req to fill in */ - sreq->sr_data_direction = DMA_FROM_DEVICE; - spi_wait_req(sreq, spi_read_buffer, ptr, len); + spi_execute(sdev, spi_read_buffer, DMA_FROM_DEVICE, + ptr, len, NULL); scsi_device_set_state(sdev, SDEV_QUIESCE); if (memcmp(buffer, ptr, len) != 0) @@ -635,25 +640,22 @@ spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer, /* This is for the simplest form of Domain Validation: a read test * on the inquiry data from the device */ static enum spi_compare_returns -spi_dv_device_compare_inquiry(struct scsi_request *sreq, u8 *buffer, +spi_dv_device_compare_inquiry(struct scsi_device *sdev, u8 *buffer, u8 *ptr, const int retries) { - int r; - const int len = sreq->sr_device->inquiry_len; - struct scsi_device *sdev = sreq->sr_device; + int r, result; + const int len = sdev->inquiry_len; const char spi_inquiry[] = { INQUIRY, 0, 0, 0, len, 0 }; for (r = 0; r < retries; r++) { - sreq->sr_cmd_len = 0; /* wait_req to fill in */ - sreq->sr_data_direction = DMA_FROM_DEVICE; - memset(ptr, 0, len); - spi_wait_req(sreq, spi_inquiry, ptr, len); + result = spi_execute(sdev, spi_inquiry, DMA_FROM_DEVICE, + ptr, len, NULL); - if(sreq->sr_result || !scsi_device_online(sdev)) { + if(result || !scsi_device_online(sdev)) { scsi_device_set_state(sdev, SDEV_QUIESCE); return SPI_COMPARE_FAILURE; } @@ -674,12 +676,11 @@ spi_dv_device_compare_inquiry(struct scsi_request *sreq, u8 *buffer, } static enum spi_compare_returns -spi_dv_retrain(struct scsi_request *sreq, u8 *buffer, u8 *ptr, +spi_dv_retrain(struct scsi_device *sdev, u8 *buffer, u8 *ptr, enum spi_compare_returns - (*compare_fn)(struct scsi_request *, u8 *, u8 *, int)) + (*compare_fn)(struct scsi_device *, u8 *, u8 *, int)) { - struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt); - struct scsi_device *sdev = sreq->sr_device; + struct spi_internal *i = to_spi_internal(sdev->host->transportt); struct scsi_target *starget = sdev->sdev_target; int period = 0, prevperiod = 0; enum spi_compare_returns retval; @@ -687,7 +688,7 @@ spi_dv_retrain(struct scsi_request *sreq, u8 *buffer, u8 *ptr, for (;;) { int newperiod; - retval = compare_fn(sreq, buffer, ptr, DV_LOOPS); + retval = compare_fn(sdev, buffer, ptr, DV_LOOPS); if (retval == SPI_COMPARE_SUCCESS || retval == SPI_COMPARE_SKIP_TEST) @@ -733,9 +734,9 @@ spi_dv_retrain(struct scsi_request *sreq, u8 *buffer, u8 *ptr, } static int -spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer) +spi_dv_device_get_echo_buffer(struct scsi_device *sdev, u8 *buffer) { - int l; + int l, result; /* first off do a test unit ready. This can error out * because of reservations or some other reason. If it @@ -751,18 +752,16 @@ spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer) }; - sreq->sr_cmd_len = 0; - sreq->sr_data_direction = DMA_NONE; - /* We send a set of three TURs to clear any outstanding * unit attention conditions if they exist (Otherwise the * buffer tests won't be happy). If the TUR still fails * (reservation conflict, device not ready, etc) just * skip the write tests */ for (l = 0; ; l++) { - spi_wait_req(sreq, spi_test_unit_ready, NULL, 0); + result = spi_execute(sdev, spi_test_unit_ready, DMA_NONE, + NULL, 0, NULL); - if(sreq->sr_result) { + if(result) { if(l >= 3) return 0; } else { @@ -771,12 +770,10 @@ spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer) } } - sreq->sr_cmd_len = 0; - sreq->sr_data_direction = DMA_FROM_DEVICE; + result = spi_execute(sdev, spi_read_buffer_descriptor, + DMA_FROM_DEVICE, buffer, 4, NULL); - spi_wait_req(sreq, spi_read_buffer_descriptor, buffer, 4); - - if (sreq->sr_result) + if (result) /* Device has no echo buffer */ return 0; @@ -784,17 +781,16 @@ spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer) } static void -spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer) +spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer) { - struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt); - struct scsi_device *sdev = sreq->sr_device; + struct spi_internal *i = to_spi_internal(sdev->host->transportt); struct scsi_target *starget = sdev->sdev_target; int len = sdev->inquiry_len; /* first set us up for narrow async */ DV_SET(offset, 0); DV_SET(width, 0); - if (spi_dv_device_compare_inquiry(sreq, buffer, buffer, DV_LOOPS) + if (spi_dv_device_compare_inquiry(sdev, buffer, buffer, DV_LOOPS) != SPI_COMPARE_SUCCESS) { SPI_PRINTK(starget, KERN_ERR, "Domain Validation Initial Inquiry Failed\n"); /* FIXME: should probably offline the device here? */ @@ -806,7 +802,7 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer) scsi_device_wide(sdev)) { i->f->set_width(starget, 1); - if (spi_dv_device_compare_inquiry(sreq, buffer, + if (spi_dv_device_compare_inquiry(sdev, buffer, buffer + len, DV_LOOPS) != SPI_COMPARE_SUCCESS) { @@ -827,7 +823,7 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer) len = 0; if (scsi_device_dt(sdev)) - len = spi_dv_device_get_echo_buffer(sreq, buffer); + len = spi_dv_device_get_echo_buffer(sdev, buffer); retry: @@ -853,7 +849,7 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer) if (len == 0) { SPI_PRINTK(starget, KERN_INFO, "Domain Validation skipping write tests\n"); - spi_dv_retrain(sreq, buffer, buffer + len, + spi_dv_retrain(sdev, buffer, buffer + len, spi_dv_device_compare_inquiry); return; } @@ -863,7 +859,7 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer) len = SPI_MAX_ECHO_BUFFER_SIZE; } - if (spi_dv_retrain(sreq, buffer, buffer + len, + if (spi_dv_retrain(sdev, buffer, buffer + len, spi_dv_device_echo_buffer) == SPI_COMPARE_SKIP_TEST) { /* OK, the stupid drive can't do a write echo buffer @@ -886,16 +882,12 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer) void spi_dv_device(struct scsi_device *sdev) { - struct scsi_request *sreq = scsi_allocate_request(sdev, GFP_KERNEL); struct scsi_target *starget = sdev->sdev_target; u8 *buffer; const int len = SPI_MAX_ECHO_BUFFER_SIZE*2; - if (unlikely(!sreq)) - return; - if (unlikely(scsi_device_get(sdev))) - goto out_free_req; + return; buffer = kmalloc(len, GFP_KERNEL); @@ -916,7 +908,7 @@ spi_dv_device(struct scsi_device *sdev) SPI_PRINTK(starget, KERN_INFO, "Beginning Domain Validation\n"); - spi_dv_device_internal(sreq, buffer); + spi_dv_device_internal(sdev, buffer); SPI_PRINTK(starget, KERN_INFO, "Ending Domain Validation\n"); @@ -931,8 +923,6 @@ spi_dv_device(struct scsi_device *sdev) kfree(buffer); out_put: scsi_device_put(sdev); - out_free_req: - scsi_release_request(sreq); } EXPORT_SYMBOL(spi_dv_device); -- cgit v1.2.3-18-g5258 From ea73a9f23906c374b697cd5b0d64f6dceced63de Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 28 Aug 2005 11:33:52 -0500 Subject: [SCSI] convert sd to scsi_execute_req (and update the scsi_execute_req API) This one removes struct scsi_request entirely from sd. In the process, I noticed we have no callers of scsi_wait_req who don't immediately normalise the sense, so I updated the API to make it take a struct scsi_sense_hdr instead of simply a big sense buffer. Signed-off-by: James Bottomley --- drivers/scsi/constants.c | 48 +++++++------- drivers/scsi/scsi_ioctl.c | 15 ++--- drivers/scsi/scsi_lib.c | 67 +++++++++++-------- drivers/scsi/scsi_scan.c | 13 ++-- drivers/scsi/sd.c | 160 +++++++++++++++++++--------------------------- 5 files changed, 139 insertions(+), 164 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 0d58d3538bd..f6be2c1c394 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1156,6 +1156,31 @@ scsi_show_extd_sense(unsigned char asc, unsigned char ascq) } } +void +scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr) +{ + const char *sense_txt; + /* An example of deferred is when an earlier write to disk cache + * succeeded, but now the disk discovers that it cannot write the + * data to the magnetic media. + */ + const char *error = scsi_sense_is_deferred(sshdr) ? + "<>" : "Current"; + printk(KERN_INFO "%s: %s", name, error); + if (sshdr->response_code >= 0x72) + printk(" [descriptor]"); + + sense_txt = scsi_sense_key_string(sshdr->sense_key); + if (sense_txt) + printk(": sense key: %s\n", sense_txt); + else + printk(": sense key=0x%x\n", sshdr->sense_key); + printk(KERN_INFO " "); + scsi_show_extd_sense(sshdr->asc, sshdr->ascq); + printk("\n"); +} +EXPORT_SYMBOL(scsi_print_sense_hdr); + /* Print sense information */ void __scsi_print_sense(const char *name, const unsigned char *sense_buffer, @@ -1163,8 +1188,6 @@ __scsi_print_sense(const char *name, const unsigned char *sense_buffer, { int k, num, res; unsigned int info; - const char *error; - const char *sense_txt; struct scsi_sense_hdr ssh; res = scsi_normalize_sense(sense_buffer, sense_len, &ssh); @@ -1182,26 +1205,7 @@ __scsi_print_sense(const char *name, const unsigned char *sense_buffer, printk("\n"); return; } - - /* An example of deferred is when an earlier write to disk cache - * succeeded, but now the disk discovers that it cannot write the - * data to the magnetic media. - */ - error = scsi_sense_is_deferred(&ssh) ? - "<>" : "Current"; - printk(KERN_INFO "%s: %s", name, error); - if (ssh.response_code >= 0x72) - printk(" [descriptor]"); - - sense_txt = scsi_sense_key_string(ssh.sense_key); - if (sense_txt) - printk(": sense key: %s\n", sense_txt); - else - printk(": sense key=0x%x\n", ssh.sense_key); - printk(KERN_INFO " "); - scsi_show_extd_sense(ssh.asc, ssh.ascq); - printk("\n"); - + scsi_print_sense_hdr(name, &ssh); if (ssh.response_code < 0x72) { /* only decode extras for "fixed" format now */ char buff[80]; diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 5f399c9c68e..179a767d221 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -90,19 +90,16 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, { int result; struct scsi_sense_hdr sshdr; - char sense[SCSI_SENSE_BUFFERSIZE]; SCSI_LOG_IOCTL(1, printk("Trying ioctl with scsi command %d\n", *cmd)); - - memset(sense, 0, sizeof(*sense)); result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, - sense, timeout, retries); + &sshdr, timeout, retries); SCSI_LOG_IOCTL(2, printk("Ioctl returned 0x%x\n", result)); if ((driver_byte(result) & DRIVER_SENSE) && - (scsi_normalize_sense(sense, sizeof(*sense), &sshdr))) { + (scsi_sense_valid(&sshdr))) { switch (sshdr.sense_key) { case ILLEGAL_REQUEST: if (cmd[0] == ALLOW_MEDIUM_REMOVAL) @@ -132,7 +129,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, sdev->id, sdev->lun, result); - __scsi_print_sense(" ", sense, sizeof(*sense)); + scsi_print_sense_hdr(" ", &sshdr); break; } } @@ -315,9 +312,9 @@ int scsi_ioctl_send_command(struct scsi_device *sdev, break; } - result = scsi_execute_req(sdev, cmd, data_direction, buf, needed, - sense, timeout, retries); - + result = scsi_execute(sdev, cmd, data_direction, buf, needed, + sense, timeout, retries, 0); + /* * If there was an error condition, pass the info back to the user. */ diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 42edf29223a..bdea26b56dc 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -293,8 +293,8 @@ EXPORT_SYMBOL(scsi_wait_req); * @retries: number of times to retry request * @flags: or into request flags; * - * scsi_execute_req returns the req->errors value which is the - * the scsi_cmnd result field. + * returns the req->errors value which is the the scsi_cmnd result + * field. **/ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, int data_direction, void *buffer, unsigned bufflen, @@ -328,9 +328,31 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, return ret; } - EXPORT_SYMBOL(scsi_execute); + +int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, + int data_direction, void *buffer, unsigned bufflen, + struct scsi_sense_hdr *sshdr, int timeout, int retries) +{ + char *sense = NULL; + + if (sshdr) { + sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); + if (!sense) + return DRIVER_ERROR << 24; + memset(sense, 0, sizeof(*sense)); + } + int result = scsi_execute(sdev, cmd, data_direction, buffer, bufflen, + sense, timeout, retries, 0); + if (sshdr) + scsi_normalize_sense(sense, sizeof(*sense), sshdr); + + kfree(sense); + return result; +} +EXPORT_SYMBOL(scsi_execute_req); + /* * Function: scsi_init_cmd_errh() * @@ -1614,7 +1636,7 @@ void scsi_exit_queue(void) } } /** - * __scsi_mode_sense - issue a mode sense, falling back from 10 to + * scsi_mode_sense - issue a mode sense, falling back from 10 to * six bytes if necessary. * @sdev: SCSI device to be queried * @dbd: set if mode sense will allow block descriptors to be returned @@ -1634,26 +1656,22 @@ void scsi_exit_queue(void) int scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, unsigned char *buffer, int len, int timeout, int retries, - struct scsi_mode_data *data, char *sense) { + struct scsi_mode_data *data, struct scsi_sense_hdr *sshdr) { unsigned char cmd[12]; int use_10_for_ms; int header_length; int result; - char *sense_buffer = NULL; + struct scsi_sense_hdr my_sshdr; memset(data, 0, sizeof(*data)); memset(&cmd[0], 0, 12); cmd[1] = dbd & 0x18; /* allows DBD and LLBA bits */ cmd[2] = modepage; - if (!sense) { - sense_buffer = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); - if (!sense_buffer) { - dev_printk(KERN_ERR, &sdev->sdev_gendev, "failed to allocate sense buffer\n"); - return 0; - } - sense = sense_buffer; - } + /* caller might not be interested in sense, but we need it */ + if (!sshdr) + sshdr = &my_sshdr; + retry: use_10_for_ms = sdev->use_10_for_ms; @@ -1673,12 +1691,10 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, header_length = 4; } - memset(sense, 0, SCSI_SENSE_BUFFERSIZE); - memset(buffer, 0, len); result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, - sense, timeout, retries); + sshdr, timeout, retries); /* This code looks awful: what it's doing is making sure an * ILLEGAL REQUEST sense return identifies the actual command @@ -1687,11 +1703,9 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, if (use_10_for_ms && !scsi_status_is_good(result) && (driver_byte(result) & DRIVER_SENSE)) { - struct scsi_sense_hdr sshdr; - - if (scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, &sshdr)) { - if ((sshdr.sense_key == ILLEGAL_REQUEST) && - (sshdr.asc == 0x20) && (sshdr.ascq == 0)) { + if (scsi_sense_valid(sshdr)) { + if ((sshdr->sense_key == ILLEGAL_REQUEST) && + (sshdr->asc == 0x20) && (sshdr->ascq == 0)) { /* * Invalid command operation code */ @@ -1718,7 +1732,6 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, } } - kfree(sense_buffer); return result; } EXPORT_SYMBOL(scsi_mode_sense); @@ -1729,17 +1742,15 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries) char cmd[] = { TEST_UNIT_READY, 0, 0, 0, 0, 0, }; - char sense[SCSI_SENSE_BUFFERSIZE]; + struct scsi_sense_hdr sshdr; int result; - result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sense, + result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, &sshdr, timeout, retries); if ((driver_byte(result) & DRIVER_SENSE) && sdev->removable) { - struct scsi_sense_hdr sshdr; - if ((scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, - &sshdr)) && + if ((scsi_sense_valid(&sshdr)) && ((sshdr.sense_key == UNIT_ATTENTION) || (sshdr.sense_key == NOT_READY))) { sdev->changed = 1; diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 0048beaffc9..19c9a232a75 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -446,7 +446,6 @@ void scsi_target_reap(struct scsi_target *starget) static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result, int result_len, int *bflags) { - char sense[SCSI_SENSE_BUFFERSIZE]; unsigned char scsi_cmd[MAX_COMMAND_SIZE]; int first_inquiry_len, try_inquiry_len, next_inquiry_len; int response_len = 0; @@ -474,11 +473,10 @@ static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result, scsi_cmd[0] = INQUIRY; scsi_cmd[4] = (unsigned char) try_inquiry_len; - memset(sense, 0, sizeof(sense)); memset(inq_result, 0, try_inquiry_len); result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, - inq_result, try_inquiry_len, sense, + inq_result, try_inquiry_len, &sshdr, HZ / 2 + HZ * scsi_inq_timeout, 3); SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: INQUIRY %s " @@ -493,8 +491,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result, * but many buggy devices do so anyway. */ if ((driver_byte(result) & DRIVER_SENSE) && - scsi_normalize_sense(sense, sizeof(sense), - &sshdr)) { + scsi_sense_valid(&sshdr)) { if ((sshdr.sense_key == UNIT_ATTENTION) && ((sshdr.asc == 0x28) || (sshdr.asc == 0x29)) && @@ -1057,7 +1054,6 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, int rescan) { char devname[64]; - char sense[SCSI_SENSE_BUFFERSIZE]; unsigned char scsi_cmd[MAX_COMMAND_SIZE]; unsigned int length; unsigned int lun; @@ -1134,9 +1130,8 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, " REPORT LUNS to %s (try %d)\n", devname, retries)); - memset(sense, 0, sizeof(sense)); result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, - lun_data, length, sense, + lun_data, length, &sshdr, SCSI_TIMEOUT + 4 * HZ, 3); SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: REPORT LUNS" @@ -1144,7 +1139,7 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, ? "failed" : "successful", retries, result)); if (result == 0) break; - else if (scsi_normalize_sense(sense, sizeof(sense), &sshdr)) { + else if (scsi_sense_valid(&sshdr)) { if (sshdr.sense_key != UNIT_ATTENTION) break; } diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 15c2039059c..611ccde8477 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -59,7 +59,6 @@ #include #include #include -#include #include #include "scsi_logging.h" @@ -125,7 +124,7 @@ static int sd_issue_flush(struct device *, sector_t *); static void sd_end_flush(request_queue_t *, struct request *); static int sd_prepare_flush(request_queue_t *, struct request *); static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, - struct scsi_request *SRpnt, unsigned char *buffer); + unsigned char *buffer); static struct scsi_driver sd_template = { .owner = THIS_MODULE, @@ -682,19 +681,13 @@ not_present: static int sd_sync_cache(struct scsi_device *sdp) { - struct scsi_request *sreq; int retries, res; + struct scsi_sense_hdr sshdr; if (!scsi_device_online(sdp)) return -ENODEV; - sreq = scsi_allocate_request(sdp, GFP_KERNEL); - if (!sreq) { - printk("FAILED\n No memory for request\n"); - return -ENOMEM; - } - sreq->sr_data_direction = DMA_NONE; for (retries = 3; retries > 0; --retries) { unsigned char cmd[10] = { 0 }; @@ -703,22 +696,20 @@ static int sd_sync_cache(struct scsi_device *sdp) * Leave the rest of the command zero to indicate * flush everything. */ - scsi_wait_req(sreq, cmd, NULL, 0, SD_TIMEOUT, SD_MAX_RETRIES); - if (sreq->sr_result == 0) + res = scsi_execute_req(sdp, cmd, DMA_NONE, NULL, 0, &sshdr, + SD_TIMEOUT, SD_MAX_RETRIES); + if (res == 0) break; } - res = sreq->sr_result; - if (res) { - printk(KERN_WARNING "FAILED\n status = %x, message = %02x, " + if (res) { printk(KERN_WARNING "FAILED\n status = %x, message = %02x, " "host = %d, driver = %02x\n ", status_byte(res), msg_byte(res), host_byte(res), driver_byte(res)); if (driver_byte(res) & DRIVER_SENSE) - scsi_print_req_sense("sd", sreq); + scsi_print_sense_hdr("sd", &sshdr); } - scsi_release_request(sreq); return res; } @@ -957,22 +948,19 @@ static void sd_rw_intr(struct scsi_cmnd * SCpnt) scsi_io_completion(SCpnt, good_bytes, block_sectors << 9); } -static int media_not_present(struct scsi_disk *sdkp, struct scsi_request *srp) +static int media_not_present(struct scsi_disk *sdkp, + struct scsi_sense_hdr *sshdr) { - struct scsi_sense_hdr sshdr; - if (!srp->sr_result) - return 0; - if (!(driver_byte(srp->sr_result) & DRIVER_SENSE)) + if (!scsi_sense_valid(sshdr)) return 0; /* not invoked for commands that could return deferred errors */ - if (scsi_request_normalize_sense(srp, &sshdr)) { - if (sshdr.sense_key != NOT_READY && - sshdr.sense_key != UNIT_ATTENTION) - return 0; - if (sshdr.asc != 0x3A) /* medium not present */ - return 0; - } + if (sshdr->sense_key != NOT_READY && + sshdr->sense_key != UNIT_ATTENTION) + return 0; + if (sshdr->asc != 0x3A) /* medium not present */ + return 0; + set_media_not_present(sdkp); return 1; } @@ -981,8 +969,8 @@ static int media_not_present(struct scsi_disk *sdkp, struct scsi_request *srp) * spinup disk - called only in sd_revalidate_disk() */ static void -sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, - struct scsi_request *SRpnt, unsigned char *buffer) { +sd_spinup_disk(struct scsi_disk *sdkp, char *diskname) +{ unsigned char cmd[10]; unsigned long spintime_value = 0; int retries, spintime; @@ -1001,18 +989,13 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, cmd[0] = TEST_UNIT_READY; memset((void *) &cmd[1], 0, 9); - SRpnt->sr_cmd_len = 0; - memset(SRpnt->sr_sense_buffer, 0, - SCSI_SENSE_BUFFERSIZE); - SRpnt->sr_data_direction = DMA_NONE; + the_result = scsi_execute_req(sdkp->device, cmd, + DMA_NONE, NULL, 0, + &sshdr, SD_TIMEOUT, + SD_MAX_RETRIES); - scsi_wait_req (SRpnt, (void *) cmd, (void *) buffer, - 0/*512*/, SD_TIMEOUT, SD_MAX_RETRIES); - - the_result = SRpnt->sr_result; if (the_result) - sense_valid = scsi_request_normalize_sense( - SRpnt, &sshdr); + sense_valid = scsi_sense_valid(&sshdr); retries++; } while (retries < 3 && (!scsi_status_is_good(the_result) || @@ -1024,7 +1007,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, * any media in it, don't bother with any of the rest of * this crap. */ - if (media_not_present(sdkp, SRpnt)) + if (media_not_present(sdkp, &sshdr)) return; if ((driver_byte(the_result) & DRIVER_SENSE) == 0) { @@ -1063,14 +1046,9 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, cmd[1] = 1; /* Return immediately */ memset((void *) &cmd[2], 0, 8); cmd[4] = 1; /* Start spin cycle */ - SRpnt->sr_cmd_len = 0; - memset(SRpnt->sr_sense_buffer, 0, - SCSI_SENSE_BUFFERSIZE); - - SRpnt->sr_data_direction = DMA_NONE; - scsi_wait_req(SRpnt, (void *)cmd, - (void *) buffer, 0/*512*/, - SD_TIMEOUT, SD_MAX_RETRIES); + scsi_execute_req(sdkp->device, cmd, DMA_NONE, + NULL, 0, &sshdr, + SD_TIMEOUT, SD_MAX_RETRIES); spintime_value = jiffies; } spintime = 1; @@ -1083,7 +1061,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, if(!spintime) { printk(KERN_NOTICE "%s: Unit Not Ready, " "sense:\n", diskname); - scsi_print_req_sense("", SRpnt); + scsi_print_sense_hdr("", &sshdr); } break; } @@ -1104,14 +1082,15 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, */ static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, - struct scsi_request *SRpnt, unsigned char *buffer) { + unsigned char *buffer) +{ unsigned char cmd[16]; - struct scsi_device *sdp = sdkp->device; int the_result, retries; int sector_size = 0; int longrc = 0; struct scsi_sense_hdr sshdr; int sense_valid = 0; + struct scsi_device *sdp = sdkp->device; repeat: retries = 3; @@ -1128,20 +1107,15 @@ repeat: memset((void *) buffer, 0, 8); } - SRpnt->sr_cmd_len = 0; - memset(SRpnt->sr_sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); - SRpnt->sr_data_direction = DMA_FROM_DEVICE; - - scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer, - longrc ? 12 : 8, SD_TIMEOUT, SD_MAX_RETRIES); + the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE, + buffer, longrc ? 12 : 8, &sshdr, + SD_TIMEOUT, SD_MAX_RETRIES); - if (media_not_present(sdkp, SRpnt)) + if (media_not_present(sdkp, &sshdr)) return; - the_result = SRpnt->sr_result; if (the_result) - sense_valid = scsi_request_normalize_sense(SRpnt, - &sshdr); + sense_valid = scsi_sense_valid(&sshdr); retries--; } while (the_result && retries); @@ -1156,7 +1130,7 @@ repeat: driver_byte(the_result)); if (driver_byte(the_result) & DRIVER_SENSE) - scsi_print_req_sense("sd", SRpnt); + scsi_print_sense_hdr("sd", &sshdr); else printk("%s : sense not available. \n", diskname); @@ -1296,12 +1270,13 @@ got_data: /* called with buffer of length 512 */ static inline int -sd_do_mode_sense(struct scsi_request *SRpnt, int dbd, int modepage, - unsigned char *buffer, int len, struct scsi_mode_data *data) +sd_do_mode_sense(struct scsi_device *sdp, int dbd, int modepage, + unsigned char *buffer, int len, struct scsi_mode_data *data, + struct scsi_sense_hdr *sshdr) { - return scsi_mode_sense(SRpnt->sr_device, dbd, modepage, buffer, len, + return scsi_mode_sense(sdp, dbd, modepage, buffer, len, SD_TIMEOUT, SD_MAX_RETRIES, data, - SRpnt->sr_sense_buffer); + sshdr); } /* @@ -1310,25 +1285,27 @@ sd_do_mode_sense(struct scsi_request *SRpnt, int dbd, int modepage, */ static void sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, - struct scsi_request *SRpnt, unsigned char *buffer) { + unsigned char *buffer) +{ int res; + struct scsi_device *sdp = sdkp->device; struct scsi_mode_data data; set_disk_ro(sdkp->disk, 0); - if (sdkp->device->skip_ms_page_3f) { + if (sdp->skip_ms_page_3f) { printk(KERN_NOTICE "%s: assuming Write Enabled\n", diskname); return; } - if (sdkp->device->use_192_bytes_for_3f) { - res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 192, &data); + if (sdp->use_192_bytes_for_3f) { + res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 192, &data, NULL); } else { /* * First attempt: ask for all pages (0x3F), but only 4 bytes. * We have to start carefully: some devices hang if we ask * for more than is available. */ - res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 4, &data); + res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 4, &data, NULL); /* * Second attempt: ask for page 0 When only page 0 is @@ -1337,14 +1314,14 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, * CDB. */ if (!scsi_status_is_good(res)) - res = sd_do_mode_sense(SRpnt, 0, 0, buffer, 4, &data); + res = sd_do_mode_sense(sdp, 0, 0, buffer, 4, &data, NULL); /* * Third attempt: ask 255 bytes, as we did earlier. */ if (!scsi_status_is_good(res)) - res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 255, - &data); + res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 255, + &data, NULL); } if (!scsi_status_is_good(res)) { @@ -1366,19 +1343,20 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, */ static void sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, - struct scsi_request *SRpnt, unsigned char *buffer) + unsigned char *buffer) { int len = 0, res; + struct scsi_device *sdp = sdkp->device; int dbd; int modepage; struct scsi_mode_data data; struct scsi_sense_hdr sshdr; - if (sdkp->device->skip_ms_page_8) + if (sdp->skip_ms_page_8) goto defaults; - if (sdkp->device->type == TYPE_RBC) { + if (sdp->type == TYPE_RBC) { modepage = 6; dbd = 8; } else { @@ -1387,7 +1365,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, } /* cautiously ask */ - res = sd_do_mode_sense(SRpnt, dbd, modepage, buffer, 4, &data); + res = sd_do_mode_sense(sdp, dbd, modepage, buffer, 4, &data, &sshdr); if (!scsi_status_is_good(res)) goto bad_sense; @@ -1408,7 +1386,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, len += data.header_length + data.block_descriptor_length; /* Get the data */ - res = sd_do_mode_sense(SRpnt, dbd, modepage, buffer, len, &data); + res = sd_do_mode_sense(sdp, dbd, modepage, buffer, len, &data, &sshdr); if (scsi_status_is_good(res)) { const char *types[] = { @@ -1440,7 +1418,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, } bad_sense: - if (scsi_request_normalize_sense(SRpnt, &sshdr) && + if (scsi_sense_valid(&sshdr) && sshdr.sense_key == ILLEGAL_REQUEST && sshdr.asc == 0x24 && sshdr.ascq == 0x0) printk(KERN_NOTICE "%s: cache data unavailable\n", @@ -1465,7 +1443,6 @@ static int sd_revalidate_disk(struct gendisk *disk) { struct scsi_disk *sdkp = scsi_disk(disk); struct scsi_device *sdp = sdkp->device; - struct scsi_request *sreq; unsigned char *buffer; SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); @@ -1477,18 +1454,11 @@ static int sd_revalidate_disk(struct gendisk *disk) if (!scsi_device_online(sdp)) goto out; - sreq = scsi_allocate_request(sdp, GFP_KERNEL); - if (!sreq) { - printk(KERN_WARNING "(sd_revalidate_disk:) Request allocation " - "failure.\n"); - goto out; - } - buffer = kmalloc(512, GFP_KERNEL | __GFP_DMA); if (!buffer) { printk(KERN_WARNING "(sd_revalidate_disk:) Memory allocation " "failure.\n"); - goto out_release_request; + goto out; } /* defaults, until the device tells us otherwise */ @@ -1499,25 +1469,23 @@ static int sd_revalidate_disk(struct gendisk *disk) sdkp->WCE = 0; sdkp->RCD = 0; - sd_spinup_disk(sdkp, disk->disk_name, sreq, buffer); + sd_spinup_disk(sdkp, disk->disk_name); /* * Without media there is no reason to ask; moreover, some devices * react badly if we do. */ if (sdkp->media_present) { - sd_read_capacity(sdkp, disk->disk_name, sreq, buffer); + sd_read_capacity(sdkp, disk->disk_name, buffer); if (sdp->removable) sd_read_write_protect_flag(sdkp, disk->disk_name, - sreq, buffer); - sd_read_cache_type(sdkp, disk->disk_name, sreq, buffer); + buffer); + sd_read_cache_type(sdkp, disk->disk_name, buffer); } set_capacity(disk, sdkp->capacity); kfree(buffer); - out_release_request: - scsi_release_request(sreq); out: return 0; } -- cgit v1.2.3-18-g5258 From 820732b501a5bbdd3bde1263f391891e21b5ed8c Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 12 Jun 2005 22:21:29 -0500 Subject: [SCSI] convert sr to scsi_execute_req This follows almost the identical model to sd, except that there's one ioctl which returns raw sense data, so it had to use scsi_execute() instead. Signed-off-by: James Bottomley --- drivers/scsi/sr.c | 49 ++++++++------------------------------ drivers/scsi/sr_ioctl.c | 62 +++++++++++++++++++++---------------------------- 2 files changed, 37 insertions(+), 74 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 8cbe6e00418..39fc5b0fbc1 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -50,10 +50,10 @@ #include #include #include +#include #include #include #include /* For the door lock/unlock commands */ -#include #include "scsi_logging.h" #include "sr.h" @@ -658,39 +658,27 @@ static void get_sectorsize(struct scsi_cd *cd) unsigned char *buffer; int the_result, retries = 3; int sector_size; - struct scsi_request *SRpnt = NULL; request_queue_t *queue; buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); if (!buffer) goto Enomem; - SRpnt = scsi_allocate_request(cd->device, GFP_KERNEL); - if (!SRpnt) - goto Enomem; do { cmd[0] = READ_CAPACITY; memset((void *) &cmd[1], 0, 9); - /* Mark as really busy */ - SRpnt->sr_request->rq_status = RQ_SCSI_BUSY; - SRpnt->sr_cmd_len = 0; - memset(buffer, 0, 8); /* Do the command and wait.. */ - SRpnt->sr_data_direction = DMA_FROM_DEVICE; - scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer, - 8, SR_TIMEOUT, MAX_RETRIES); + the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE, + buffer, 8, NULL, SR_TIMEOUT, + MAX_RETRIES); - the_result = SRpnt->sr_result; retries--; } while (the_result && retries); - scsi_release_request(SRpnt); - SRpnt = NULL; - if (the_result) { cd->capacity = 0x1fffff; sector_size = 2048; /* A guess, just in case */ @@ -750,8 +738,6 @@ Enomem: cd->capacity = 0x1fffff; sector_size = 2048; /* A guess, just in case */ cd->needs_sector_size = 1; - if (SRpnt) - scsi_release_request(SRpnt); goto out; } @@ -759,8 +745,8 @@ static void get_capabilities(struct scsi_cd *cd) { unsigned char *buffer; struct scsi_mode_data data; - struct scsi_request *SRpnt; unsigned char cmd[MAX_COMMAND_SIZE]; + struct scsi_sense_hdr sshdr; unsigned int the_result; int retries, rc, n; @@ -776,19 +762,11 @@ static void get_capabilities(struct scsi_cd *cd) "" }; - /* allocate a request for the TEST_UNIT_READY */ - SRpnt = scsi_allocate_request(cd->device, GFP_KERNEL); - if (!SRpnt) { - printk(KERN_WARNING "(get_capabilities:) Request allocation " - "failure.\n"); - return; - } /* allocate transfer buffer */ buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); if (!buffer) { printk(KERN_ERR "sr: out of memory.\n"); - scsi_release_request(SRpnt); return; } @@ -800,20 +778,15 @@ static void get_capabilities(struct scsi_cd *cd) memset((void *)cmd, 0, MAX_COMMAND_SIZE); cmd[0] = TEST_UNIT_READY; - SRpnt->sr_cmd_len = 0; - SRpnt->sr_sense_buffer[0] = 0; - SRpnt->sr_sense_buffer[2] = 0; - SRpnt->sr_data_direction = DMA_NONE; - - scsi_wait_req (SRpnt, (void *) cmd, buffer, - 0, SR_TIMEOUT, MAX_RETRIES); + the_result = scsi_execute_req (cd->device, cmd, DMA_NONE, NULL, + 0, &sshdr, SR_TIMEOUT, + MAX_RETRIES); - the_result = SRpnt->sr_result; retries++; } while (retries < 5 && (!scsi_status_is_good(the_result) || - ((driver_byte(the_result) & DRIVER_SENSE) && - SRpnt->sr_sense_buffer[2] == UNIT_ATTENTION))); + (scsi_sense_valid(&sshdr) && + sshdr.sense_key == UNIT_ATTENTION))); /* ask for mode page 0x2a */ rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128, @@ -825,7 +798,6 @@ static void get_capabilities(struct scsi_cd *cd) cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R | CDC_DVD | CDC_DVD_RAM | CDC_SELECT_DISC | CDC_SELECT_SPEED); - scsi_release_request(SRpnt); kfree(buffer); printk("%s: scsi-1 drive\n", cd->cdi.name); return; @@ -885,7 +857,6 @@ static void get_capabilities(struct scsi_cd *cd) cd->device->writeable = 1; } - scsi_release_request(SRpnt); kfree(buffer); } diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index 82d68fdb154..6e45ac3c43c 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include "sr.h" @@ -84,41 +84,37 @@ static int sr_fake_playtrkind(struct cdrom_device_info *cdi, struct cdrom_ti *ti int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) { - struct scsi_request *SRpnt; struct scsi_device *SDev; - struct request *req; + struct scsi_sense_hdr sshdr; int result, err = 0, retries = 0; + struct request_sense *sense = cgc->sense; SDev = cd->device; - SRpnt = scsi_allocate_request(SDev, GFP_KERNEL); - if (!SRpnt) { - printk(KERN_ERR "Unable to allocate SCSI request in sr_do_ioctl"); - err = -ENOMEM; - goto out; - } - SRpnt->sr_data_direction = cgc->data_direction; + + if (!sense) { + sense = kmalloc(sizeof(*sense), GFP_KERNEL); + if (!sense) { + err = -ENOMEM; + goto out; + } + } retry: if (!scsi_block_when_processing_errors(SDev)) { err = -ENODEV; - goto out_free; + goto out; } - scsi_wait_req(SRpnt, cgc->cmd, cgc->buffer, cgc->buflen, - cgc->timeout, IOCTL_RETRIES); - - req = SRpnt->sr_request; - if (SRpnt->sr_buffer && req->buffer && SRpnt->sr_buffer != req->buffer) { - memcpy(req->buffer, SRpnt->sr_buffer, SRpnt->sr_bufflen); - kfree(SRpnt->sr_buffer); - SRpnt->sr_buffer = req->buffer; - } + memset(sense, 0, sizeof(*sense)); + result = scsi_execute(SDev, cgc->cmd, cgc->data_direction, + cgc->buffer, cgc->buflen, (char *)sense, + cgc->timeout, IOCTL_RETRIES, 0); - result = SRpnt->sr_result; + scsi_normalize_sense((char *)sense, sizeof(*sense), &sshdr); /* Minimal error checking. Ignore cases we know about, and report the rest. */ if (driver_byte(result) != 0) { - switch (SRpnt->sr_sense_buffer[2] & 0xf) { + switch (sshdr.sense_key) { case UNIT_ATTENTION: SDev->changed = 1; if (!cgc->quiet) @@ -128,8 +124,8 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) err = -ENOMEDIUM; break; case NOT_READY: /* This happens if there is no disc in drive */ - if (SRpnt->sr_sense_buffer[12] == 0x04 && - SRpnt->sr_sense_buffer[13] == 0x01) { + if (sshdr.asc == 0x04 && + sshdr.ascq == 0x01) { /* sense: Logical unit is in process of becoming ready */ if (!cgc->quiet) printk(KERN_INFO "%s: CDROM not ready yet.\n", cd->cdi.name); @@ -146,37 +142,33 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) if (!cgc->quiet) printk(KERN_INFO "%s: CDROM not ready. Make sure there is a disc in the drive.\n", cd->cdi.name); #ifdef DEBUG - scsi_print_req_sense("sr", SRpnt); + scsi_print_sense_hdr("sr", &sshdr); #endif err = -ENOMEDIUM; break; case ILLEGAL_REQUEST: err = -EIO; - if (SRpnt->sr_sense_buffer[12] == 0x20 && - SRpnt->sr_sense_buffer[13] == 0x00) + if (sshdr.asc == 0x20 && + sshdr.ascq == 0x00) /* sense: Invalid command operation code */ err = -EDRIVE_CANT_DO_THIS; #ifdef DEBUG __scsi_print_command(cgc->cmd); - scsi_print_req_sense("sr", SRpnt); + scsi_print_sense_hdr("sr", &sshdr); #endif break; default: printk(KERN_ERR "%s: CDROM (ioctl) error, command: ", cd->cdi.name); __scsi_print_command(cgc->cmd); - scsi_print_req_sense("sr", SRpnt); + scsi_print_sense_hdr("sr", &sshdr); err = -EIO; } } - if (cgc->sense) - memcpy(cgc->sense, SRpnt->sr_sense_buffer, sizeof(*cgc->sense)); - /* Wake up a process waiting for device */ - out_free: - scsi_release_request(SRpnt); - SRpnt = NULL; out: + if (!cgc->sense) + kfree(sense); cgc->stat = err; return err; } -- cgit v1.2.3-18-g5258 From 84743bbcf9fc3767aa33f769898432538281e6dc Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 12 Jun 2005 22:37:10 -0500 Subject: [SCSI] convert ch to use scsi_execute_req I also tinkered with it's sense recognition routines to make them take scsi_sense_hdr structures instead of raw sense data. Signed-off-by: James Bottomley --- drivers/scsi/ch.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 53b39553431..bd0e1b6be1e 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #define CH_DT_MAX 16 @@ -180,17 +180,17 @@ static struct { /* ------------------------------------------------------------------- */ -static int ch_find_errno(unsigned char *sense_buffer) +static int ch_find_errno(struct scsi_sense_hdr *sshdr) { int i,errno = 0; /* Check to see if additional sense information is available */ - if (sense_buffer[7] > 5 && - sense_buffer[12] != 0) { + if (scsi_sense_valid(sshdr) && + sshdr->asc != 0) { for (i = 0; err[i].errno != 0; i++) { - if (err[i].sense == sense_buffer[ 2] && - err[i].asc == sense_buffer[12] && - err[i].ascq == sense_buffer[13]) { + if (err[i].sense == sshdr->sense_key && + err[i].asc == sshdr->asc && + err[i].ascq == sshdr->ascq) { errno = -err[i].errno; break; } @@ -206,13 +206,9 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, void *buffer, unsigned buflength, enum dma_data_direction direction) { - int errno, retries = 0, timeout; - struct scsi_request *sr; + int errno, retries = 0, timeout, result; + struct scsi_sense_hdr sshdr; - sr = scsi_allocate_request(ch->device, GFP_KERNEL); - if (NULL == sr) - return -ENOMEM; - timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS) ? timeout_init : timeout_move; @@ -223,16 +219,17 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, __scsi_print_command(cmd); } - scsi_wait_req(sr, cmd, buffer, buflength, - timeout * HZ, MAX_RETRIES); + result = scsi_execute_req(ch->device, cmd, direction, buffer, + buflength, &sshdr, timeout * HZ, + MAX_RETRIES); - dprintk("result: 0x%x\n",sr->sr_result); - if (driver_byte(sr->sr_result) & DRIVER_SENSE) { + dprintk("result: 0x%x\n",result); + if (driver_byte(result) & DRIVER_SENSE) { if (debug) - scsi_print_req_sense(ch->name, sr); - errno = ch_find_errno(sr->sr_sense_buffer); + scsi_print_sense_hdr(ch->name, &sshdr); + errno = ch_find_errno(&sshdr); - switch(sr->sr_sense_buffer[2] & 0xf) { + switch(sshdr.sense_key) { case UNIT_ATTENTION: ch->unit_attention = 1; if (retries++ < 3) @@ -240,7 +237,6 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, break; } } - scsi_release_request(sr); return errno; } -- cgit v1.2.3-18-g5258 From 1ccb48bb163853c24840c0a50c2a6df1affe029c Mon Sep 17 00:00:00 2001 From: "akpm@osdl.org" Date: Sun, 26 Jun 2005 00:12:51 -0700 Subject: [SCSI] fix C syntax problem in scsi_lib.c Older gcc's require variable definitions at the beginning of a block. Signed-off-by: Andrew Morton Signed-off-by: James Bottomley --- drivers/scsi/scsi_lib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index bdea26b56dc..58da7f64c22 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -336,14 +336,15 @@ int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, struct scsi_sense_hdr *sshdr, int timeout, int retries) { char *sense = NULL; - + int result; + if (sshdr) { sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); if (!sense) return DRIVER_ERROR << 24; memset(sense, 0, sizeof(*sense)); } - int result = scsi_execute(sdev, cmd, data_direction, buffer, bufflen, + result = scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, timeout, retries, 0); if (sshdr) scsi_normalize_sense(sense, sizeof(*sense), sshdr); -- cgit v1.2.3-18-g5258 From f189c5cb8ddde0c01838f2b3bc7650e86c097a14 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 19 Jun 2005 11:32:53 +0200 Subject: [SCSI] comment cleanup for spi_execute Signed-off-by: James Bottomley --- drivers/scsi/scsi_transport_spi.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 874042f1899..ef577c8c218 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -106,8 +106,6 @@ static int sprint_frac(char *dest, int value, int denom) return result; } -/* Modification of scsi_wait_req that will clear UNIT ATTENTION conditions - * resulting from (likely) bus and device resets */ static int spi_execute(struct scsi_device *sdev, const void *cmd, enum dma_data_direction dir, void *buffer, unsigned bufflen, @@ -117,8 +115,6 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd, unsigned char sense[SCSI_SENSE_BUFFERSIZE]; for(i = 0; i < DV_RETRIES; i++) { - - /* FIXME: need to set REQ_FAILFAST */ result = scsi_execute(sdev, cmd, dir, buffer, bufflen, sense, DV_TIMEOUT, /* retries */ 1, REQ_FAILFAST); -- cgit v1.2.3-18-g5258 From c9d297c543f379a27a34082070ed03a8ef846fc2 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Tue, 28 Jun 2005 09:18:21 -0500 Subject: [SCSI] fix 3ware raid emulated commands The 3ware emulated commands all expect they are executing in the use_sg == 0 case, which isn't true either in the block layer rework or an SG_IO ioctl. Fix this by adding the correct kmapping of the first element in the sg list. Signed-off-by: James Bottomley --- drivers/scsi/3w-xxxx.c | 57 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 18 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 973c51fb0fe..ae9e0203e9d 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -1499,22 +1499,43 @@ static int tw_scsiop_inquiry(TW_Device_Extension *tw_dev, int request_id) return 0; } /* End tw_scsiop_inquiry() */ +static void tw_transfer_internal(TW_Device_Extension *tw_dev, int request_id, + void *data, unsigned int len) +{ + struct scsi_cmnd *cmd = tw_dev->srb[request_id]; + void *buf; + unsigned int transfer_len; + + if (cmd->use_sg) { + struct scatterlist *sg = + (struct scatterlist *)cmd->request_buffer; + buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; + transfer_len = min(sg->length, len); + } else { + buf = cmd->request_buffer; + transfer_len = min(cmd->request_bufflen, len); + } + + memcpy(buf, data, transfer_len); + + if (cmd->use_sg) { + struct scatterlist *sg; + + sg = (struct scatterlist *)cmd->request_buffer; + kunmap_atomic(buf - sg->offset, KM_IRQ0); + } +} + /* This function is called by the isr to complete an inquiry command */ static int tw_scsiop_inquiry_complete(TW_Device_Extension *tw_dev, int request_id) { unsigned char *is_unit_present; - unsigned char *request_buffer; + unsigned char request_buffer[36]; TW_Param *param; dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_inquiry_complete()\n"); - /* Fill request buffer */ - if (tw_dev->srb[request_id]->request_buffer == NULL) { - printk(KERN_WARNING "3w-xxxx: tw_scsiop_inquiry_complete(): Request buffer NULL.\n"); - return 1; - } - request_buffer = tw_dev->srb[request_id]->request_buffer; - memset(request_buffer, 0, tw_dev->srb[request_id]->request_bufflen); + memset(request_buffer, 0, sizeof(request_buffer)); request_buffer[0] = TYPE_DISK; /* Peripheral device type */ request_buffer[1] = 0; /* Device type modifier */ request_buffer[2] = 0; /* No ansi/iso compliance */ @@ -1522,6 +1543,8 @@ static int tw_scsiop_inquiry_complete(TW_Device_Extension *tw_dev, int request_i memcpy(&request_buffer[8], "3ware ", 8); /* Vendor ID */ sprintf(&request_buffer[16], "Logical Disk %-2d ", tw_dev->srb[request_id]->device->id); memcpy(&request_buffer[32], TW_DRIVER_VERSION, 3); + tw_transfer_internal(tw_dev, request_id, request_buffer, + sizeof(request_buffer)); param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; if (param == NULL) { @@ -1612,7 +1635,7 @@ static int tw_scsiop_mode_sense_complete(TW_Device_Extension *tw_dev, int reques { TW_Param *param; unsigned char *flags; - unsigned char *request_buffer; + unsigned char request_buffer[8]; dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_mode_sense_complete()\n"); @@ -1622,8 +1645,7 @@ static int tw_scsiop_mode_sense_complete(TW_Device_Extension *tw_dev, int reques return 1; } flags = (char *)&(param->data[0]); - request_buffer = tw_dev->srb[request_id]->buffer; - memset(request_buffer, 0, tw_dev->srb[request_id]->request_bufflen); + memset(request_buffer, 0, sizeof(request_buffer)); request_buffer[0] = 0xf; /* mode data length */ request_buffer[1] = 0; /* default medium type */ @@ -1635,6 +1657,8 @@ static int tw_scsiop_mode_sense_complete(TW_Device_Extension *tw_dev, int reques request_buffer[6] = 0x4; /* WCE on */ else request_buffer[6] = 0x0; /* WCE off */ + tw_transfer_internal(tw_dev, request_id, request_buffer, + sizeof(request_buffer)); return 0; } /* End tw_scsiop_mode_sense_complete() */ @@ -1701,17 +1725,12 @@ static int tw_scsiop_read_capacity_complete(TW_Device_Extension *tw_dev, int req { unsigned char *param_data; u32 capacity; - char *buff; + char buff[8]; TW_Param *param; dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_read_capacity_complete()\n"); - buff = tw_dev->srb[request_id]->request_buffer; - if (buff == NULL) { - printk(KERN_WARNING "3w-xxxx: tw_scsiop_read_capacity_complete(): Request buffer NULL.\n"); - return 1; - } - memset(buff, 0, tw_dev->srb[request_id]->request_bufflen); + memset(buff, 0, sizeof(buff)); param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; if (param == NULL) { printk(KERN_WARNING "3w-xxxx: tw_scsiop_read_capacity_complete(): Bad alignment virtual address.\n"); @@ -1739,6 +1758,8 @@ static int tw_scsiop_read_capacity_complete(TW_Device_Extension *tw_dev, int req buff[6] = (TW_BLOCK_SIZE >> 8) & 0xff; buff[7] = TW_BLOCK_SIZE & 0xff; + tw_transfer_internal(tw_dev, request_id, buff, sizeof(buff)); + return 0; } /* End tw_scsiop_read_capacity_complete() */ -- cgit v1.2.3-18-g5258 From e514385be2b355c1f3fc6385a98a6a0fc04235ae Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Tue, 9 Aug 2005 11:55:36 -0500 Subject: [SCSI] fix sense buffer length handling problem The new bio code was incorrectly converted from stack allocated to kmalloc'd buffer handling. There are two places where it incorrectly uses sizeof(*sense) to get the size of the sense buffer. This actually produces one, so no sense data was ever getting back, causing failure in things like disk spin up. Signed-off-by: James Bottomley --- drivers/scsi/scsi_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 58da7f64c22..72a47ce7a1d 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -342,12 +342,12 @@ int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); if (!sense) return DRIVER_ERROR << 24; - memset(sense, 0, sizeof(*sense)); + memset(sense, 0, SCSI_SENSE_BUFFERSIZE); } result = scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, timeout, retries, 0); if (sshdr) - scsi_normalize_sense(sense, sizeof(*sense), sshdr); + scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, sshdr); kfree(sense); return result; -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/tables/tbutils.c | 24 +++++++++++++++++------- drivers/acpi/utilities/utdebug.c | 4 ++-- drivers/acpi/utilities/utmisc.c | 6 +++++- 3 files changed, 24 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index 5bcafebb9dd..4b2fbb592f4 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 081a778aba8..d80e9263993 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 474fe7cb6c0..f0275025b71 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) */ -- cgit v1.2.3-18-g5258 From 1623c81eece58740279b8de802fa5895221f2044 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Tue, 30 Aug 2005 03:37:42 -0400 Subject: [libata] allow ATAPI to be enabled with new atapi_enabled module option ATAPI is getting close to being ready. To increase exposure, we enable the code in the upstream kernel, but default it to off (present behavior). Users must pass atapi_enabled=1 as a module option (if module) or on the kernel command line (if built in) to turn on discovery of their ATAPI devices. --- drivers/scsi/libata-core.c | 4 ++++ drivers/scsi/libata-scsi.c | 8 ++++---- drivers/scsi/libata.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index dee4b12b034..d824938d05c 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -75,6 +75,10 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc); static unsigned int ata_unique_id = 1; static struct workqueue_struct *ata_wq; +int atapi_enabled = 0; +module_param(atapi_enabled, int, 0444); +MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); + MODULE_AUTHOR("Jeff Garzik"); MODULE_DESCRIPTION("Library module for ATA devices"); MODULE_LICENSE("GPL"); diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 346eb36b1e3..55823765425 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c @@ -1470,10 +1470,10 @@ ata_scsi_find_dev(struct ata_port *ap, struct scsi_device *scsidev) if (unlikely(!ata_dev_present(dev))) return NULL; -#ifndef ATA_ENABLE_ATAPI - if (unlikely(dev->class == ATA_DEV_ATAPI)) - return NULL; -#endif + if (atapi_enabled) { + if (unlikely(dev->class == ATA_DEV_ATAPI)) + return NULL; + } return dev; } diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index 809c634afbc..d608b3a0f6f 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h @@ -38,6 +38,7 @@ struct ata_scsi_args { }; /* libata-core.c */ +extern int atapi_enabled; extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, struct ata_device *dev); extern void ata_qc_free(struct ata_queued_cmd *qc); -- cgit v1.2.3-18-g5258 From e005f01de32f22be8af255f2761018e9766000d2 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Tue, 30 Aug 2005 04:18:28 -0400 Subject: [libata ahci] minor remove/unplug path cleanup Don't bother calling a hook, to call our own module, to call a helper than simply calls ionumap(). If you unroll all that convolution, you get a simple kfree()+iounmap() pair of calls. --- drivers/scsi/ahci.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index 179c95c878a..46e5f186d55 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c @@ -189,7 +189,6 @@ static void ahci_irq_clear(struct ata_port *ap); static void ahci_eng_timeout(struct ata_port *ap); static int ahci_port_start(struct ata_port *ap); static void ahci_port_stop(struct ata_port *ap); -static void ahci_host_stop(struct ata_host_set *host_set); static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf); static void ahci_qc_prep(struct ata_queued_cmd *qc); static u8 ahci_check_status(struct ata_port *ap); @@ -242,7 +241,6 @@ static struct ata_port_operations ahci_ops = { .port_start = ahci_port_start, .port_stop = ahci_port_stop, - .host_stop = ahci_host_stop, }; static struct ata_port_info ahci_port_info[] = { @@ -301,14 +299,6 @@ static inline void *ahci_port_base (void *base, unsigned int port) return (void *) ahci_port_base_ul((unsigned long)base, port); } -static void ahci_host_stop(struct ata_host_set *host_set) -{ - struct ahci_host_priv *hpriv = host_set->private_data; - kfree(hpriv); - - ata_host_stop(host_set); -} - static int ahci_port_start(struct ata_port *ap) { struct device *dev = ap->host_set->dev; @@ -1089,7 +1079,8 @@ static void ahci_remove_one (struct pci_dev *pdev) scsi_host_put(ap->host); } - host_set->ops->host_stop(host_set); + kfree(hpriv); + iounmap(host_set->mmio_base); kfree(host_set); if (have_msi) @@ -1106,7 +1097,6 @@ static int __init ahci_init(void) return pci_module_init(&ahci_pci_driver); } - static void __exit ahci_exit(void) { pci_unregister_driver(&ahci_pci_driver); -- cgit v1.2.3-18-g5258 From ea6ba10bbb88e106f9e2db7dc253993bb3bbbe3b Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Tue, 30 Aug 2005 05:18:18 -0400 Subject: [libata] __iomem annotations for various drivers --- drivers/scsi/ahci.c | 33 +++++++++++++++++---------------- drivers/scsi/ata_piix.c | 2 +- drivers/scsi/sata_promise.c | 12 ++++++------ drivers/scsi/sata_sil.c | 5 +++-- drivers/scsi/sata_svw.c | 2 +- drivers/scsi/sata_sx4.c | 39 ++++++++++++++++++++------------------- 6 files changed, 48 insertions(+), 45 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index 46e5f186d55..4cfb257a0f6 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c @@ -294,9 +294,9 @@ static inline unsigned long ahci_port_base_ul (unsigned long base, unsigned int return base + 0x100 + (port * 0x80); } -static inline void *ahci_port_base (void *base, unsigned int port) +static inline void __iomem *ahci_port_base (void __iomem *base, unsigned int port) { - return (void *) ahci_port_base_ul((unsigned long)base, port); + return (void __iomem *) ahci_port_base_ul((unsigned long)base, port); } static int ahci_port_start(struct ata_port *ap) @@ -304,8 +304,9 @@ static int ahci_port_start(struct ata_port *ap) struct device *dev = ap->host_set->dev; struct ahci_host_priv *hpriv = ap->host_set->private_data; struct ahci_port_priv *pp; - void *mem, *mmio = ap->host_set->mmio_base; - void *port_mmio = ahci_port_base(mmio, ap->port_no); + void __iomem *mmio = ap->host_set->mmio_base; + void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); + void *mem; dma_addr_t mem_dma; pp = kmalloc(sizeof(*pp), GFP_KERNEL); @@ -373,8 +374,8 @@ static void ahci_port_stop(struct ata_port *ap) { struct device *dev = ap->host_set->dev; struct ahci_port_priv *pp = ap->private_data; - void *mmio = ap->host_set->mmio_base; - void *port_mmio = ahci_port_base(mmio, ap->port_no); + void __iomem *mmio = ap->host_set->mmio_base; + void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); u32 tmp; tmp = readl(port_mmio + PORT_CMD); @@ -536,8 +537,8 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc) static void ahci_intr_error(struct ata_port *ap, u32 irq_stat) { - void *mmio = ap->host_set->mmio_base; - void *port_mmio = ahci_port_base(mmio, ap->port_no); + void __iomem *mmio = ap->host_set->mmio_base; + void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); u32 tmp; int work; @@ -585,8 +586,8 @@ static void ahci_intr_error(struct ata_port *ap, u32 irq_stat) static void ahci_eng_timeout(struct ata_port *ap) { struct ata_host_set *host_set = ap->host_set; - void *mmio = host_set->mmio_base; - void *port_mmio = ahci_port_base(mmio, ap->port_no); + void __iomem *mmio = host_set->mmio_base; + void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); struct ata_queued_cmd *qc; unsigned long flags; @@ -616,8 +617,8 @@ static void ahci_eng_timeout(struct ata_port *ap) static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) { - void *mmio = ap->host_set->mmio_base; - void *port_mmio = ahci_port_base(mmio, ap->port_no); + void __iomem *mmio = ap->host_set->mmio_base; + void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); u32 status, serr, ci; serr = readl(port_mmio + PORT_SCR_ERR); @@ -653,7 +654,7 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * struct ata_host_set *host_set = dev_instance; struct ahci_host_priv *hpriv; unsigned int i, handled = 0; - void *mmio; + void __iomem *mmio; u32 irq_stat, irq_ack = 0; VPRINTK("ENTER\n"); @@ -699,7 +700,7 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * static int ahci_qc_issue(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; - void *port_mmio = (void *) ap->ioaddr.cmd_addr; + void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr; writel(1, port_mmio + PORT_CMD_ISSUE); readl(port_mmio + PORT_CMD_ISSUE); /* flush */ @@ -884,7 +885,7 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent) { struct ahci_host_priv *hpriv = probe_ent->private_data; struct pci_dev *pdev = to_pci_dev(probe_ent->dev); - void *mmio = probe_ent->mmio_base; + void __iomem *mmio = probe_ent->mmio_base; u32 vers, cap, impl, speed; const char *speed_s; u16 cc; @@ -957,7 +958,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) struct ata_probe_ent *probe_ent = NULL; struct ahci_host_priv *hpriv; unsigned long base; - void *mmio_base; + void __iomem *mmio_base; unsigned int board_idx = (unsigned int) ent->driver_data; int have_msi, pci_dev_busy = 0; int rc; diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index fb28c126184..90c53b88a1e 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c @@ -583,7 +583,7 @@ static void pci_enable_intx(struct pci_dev *pdev) #define AHCI_ENABLE (1 << 31) static int piix_disable_ahci(struct pci_dev *pdev) { - void *mmio; + void __iomem *mmio; unsigned long addr; u32 tmp; int rc = 0; diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index 7c4f6ecc1cc..ed54f281060 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c @@ -282,7 +282,7 @@ static void pdc_port_stop(struct ata_port *ap) static void pdc_reset_port(struct ata_port *ap) { - void *mmio = (void *) ap->ioaddr.cmd_addr + PDC_CTLSTAT; + void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_CTLSTAT; unsigned int i; u32 tmp; @@ -418,7 +418,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap, u8 status; unsigned int handled = 0, have_err = 0; u32 tmp; - void *mmio = (void *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; + void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; tmp = readl(mmio); if (tmp & PDC_ERR_MASK) { @@ -447,7 +447,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap, static void pdc_irq_clear(struct ata_port *ap) { struct ata_host_set *host_set = ap->host_set; - void *mmio = host_set->mmio_base; + void __iomem *mmio = host_set->mmio_base; readl(mmio + PDC_INT_SEQMASK); } @@ -459,7 +459,7 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r u32 mask = 0; unsigned int i, tmp; unsigned int handled = 0; - void *mmio_base; + void __iomem *mmio_base; VPRINTK("ENTER\n"); @@ -581,7 +581,7 @@ static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base) static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) { - void *mmio = pe->mmio_base; + void __iomem *mmio = pe->mmio_base; u32 tmp; /* @@ -624,7 +624,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e static int printed_version; struct ata_probe_ent *probe_ent = NULL; unsigned long base; - void *mmio_base; + void __iomem *mmio_base; unsigned int board_idx = (unsigned int) ent->driver_data; int pci_dev_busy = 0; int rc; diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index 71d49548f0a..b1a696fcec8 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c @@ -242,7 +242,8 @@ static void sil_post_set_mode (struct ata_port *ap) { struct ata_host_set *host_set = ap->host_set; struct ata_device *dev; - void *addr = host_set->mmio_base + sil_port[ap->port_no].xfer_mode; + void __iomem *addr = + host_set->mmio_base + sil_port[ap->port_no].xfer_mode; u32 tmp, dev_mode[2]; unsigned int i; @@ -375,7 +376,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) static int printed_version; struct ata_probe_ent *probe_ent = NULL; unsigned long base; - void *mmio_base; + void __iomem *mmio_base; int rc; unsigned int i; int pci_dev_busy = 0; diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c index 19d3bb3b0fb..d48de9547fb 100644 --- a/drivers/scsi/sata_svw.c +++ b/drivers/scsi/sata_svw.c @@ -346,7 +346,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e static int printed_version; struct ata_probe_ent *probe_ent = NULL; unsigned long base; - void *mmio_base; + void __iomem *mmio_base; int pci_dev_busy = 0; int rc; int i; diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index c72fcc46f0f..38b3dd2d750 100644 --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c @@ -451,9 +451,9 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc) struct scatterlist *sg = qc->sg; struct ata_port *ap = qc->ap; struct pdc_port_priv *pp = ap->private_data; - void *mmio = ap->host_set->mmio_base; + void __iomem *mmio = ap->host_set->mmio_base; struct pdc_host_priv *hpriv = ap->host_set->private_data; - void *dimm_mmio = hpriv->dimm_mmio; + void __iomem *dimm_mmio = hpriv->dimm_mmio; unsigned int portno = ap->port_no; unsigned int i, last, idx, total_len = 0, sgt_len; u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ]; @@ -513,9 +513,9 @@ static void pdc20621_nodata_prep(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; struct pdc_port_priv *pp = ap->private_data; - void *mmio = ap->host_set->mmio_base; + void __iomem *mmio = ap->host_set->mmio_base; struct pdc_host_priv *hpriv = ap->host_set->private_data; - void *dimm_mmio = hpriv->dimm_mmio; + void __iomem *dimm_mmio = hpriv->dimm_mmio; unsigned int portno = ap->port_no; unsigned int i; @@ -565,7 +565,7 @@ static void __pdc20621_push_hdma(struct ata_queued_cmd *qc, { struct ata_port *ap = qc->ap; struct ata_host_set *host_set = ap->host_set; - void *mmio = host_set->mmio_base; + void __iomem *mmio = host_set->mmio_base; /* hard-code chip #0 */ mmio += PDC_CHIP0_OFS; @@ -639,7 +639,7 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc) struct ata_port *ap = qc->ap; struct ata_host_set *host_set = ap->host_set; unsigned int port_no = ap->port_no; - void *mmio = host_set->mmio_base; + void __iomem *mmio = host_set->mmio_base; unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); u8 seq = (u8) (port_no + 1); unsigned int port_ofs; @@ -699,7 +699,7 @@ static int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc) static inline unsigned int pdc20621_host_intr( struct ata_port *ap, struct ata_queued_cmd *qc, unsigned int doing_hdma, - void *mmio) + void __iomem *mmio) { unsigned int port_no = ap->port_no; unsigned int port_ofs = @@ -778,7 +778,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, static void pdc20621_irq_clear(struct ata_port *ap) { struct ata_host_set *host_set = ap->host_set; - void *mmio = host_set->mmio_base; + void __iomem *mmio = host_set->mmio_base; mmio += PDC_CHIP0_OFS; @@ -792,7 +792,7 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re u32 mask = 0; unsigned int i, tmp, port_no; unsigned int handled = 0; - void *mmio_base; + void __iomem *mmio_base; VPRINTK("ENTER\n"); @@ -940,9 +940,9 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource, u16 idx; u8 page_mask; long dist; - void *mmio = pe->mmio_base; + void __iomem *mmio = pe->mmio_base; struct pdc_host_priv *hpriv = pe->private_data; - void *dimm_mmio = hpriv->dimm_mmio; + void __iomem *dimm_mmio = hpriv->dimm_mmio; /* hard-code chip #0 */ mmio += PDC_CHIP0_OFS; @@ -996,9 +996,9 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource, u16 idx; u8 page_mask; long dist; - void *mmio = pe->mmio_base; + void __iomem *mmio = pe->mmio_base; struct pdc_host_priv *hpriv = pe->private_data; - void *dimm_mmio = hpriv->dimm_mmio; + void __iomem *dimm_mmio = hpriv->dimm_mmio; /* hard-code chip #0 */ mmio += PDC_CHIP0_OFS; @@ -1044,7 +1044,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource, static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device, u32 subaddr, u32 *pdata) { - void *mmio = pe->mmio_base; + void __iomem *mmio = pe->mmio_base; u32 i2creg = 0; u32 status; u32 count =0; @@ -1103,7 +1103,7 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe) u32 data = 0; int size, i; u8 bdimmsize; - void *mmio = pe->mmio_base; + void __iomem *mmio = pe->mmio_base; static const struct { unsigned int reg; unsigned int ofs; @@ -1166,7 +1166,7 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe) { u32 data, spd0; int error, i; - void *mmio = pe->mmio_base; + void __iomem *mmio = pe->mmio_base; /* hard-code chip #0 */ mmio += PDC_CHIP0_OFS; @@ -1220,7 +1220,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe) u32 ticks=0; u32 clock=0; u32 fparam=0; - void *mmio = pe->mmio_base; + void __iomem *mmio = pe->mmio_base; /* hard-code chip #0 */ mmio += PDC_CHIP0_OFS; @@ -1344,7 +1344,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe) static void pdc_20621_init(struct ata_probe_ent *pe) { u32 tmp; - void *mmio = pe->mmio_base; + void __iomem *mmio = pe->mmio_base; /* hard-code chip #0 */ mmio += PDC_CHIP0_OFS; @@ -1377,7 +1377,8 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * static int printed_version; struct ata_probe_ent *probe_ent = NULL; unsigned long base; - void *mmio_base, *dimm_mmio = NULL; + void __iomem *mmio_base; + void __iomem *dimm_mmio = NULL; struct pdc_host_priv *hpriv = NULL; unsigned int board_idx = (unsigned int) ent->driver_data; int pci_dev_busy = 0; -- cgit v1.2.3-18-g5258 From 374b1873571bf80dc0c1fcceaaad067980f3b9de Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Tue, 30 Aug 2005 05:42:52 -0400 Subject: [libata] update several drivers to use pci_iomap()/pci_iounmap() --- drivers/scsi/ahci.c | 7 +++---- drivers/scsi/ata_piix.c | 9 ++++----- drivers/scsi/libata-core.c | 11 ++++++++++- drivers/scsi/sata_nv.c | 9 +++++---- drivers/scsi/sata_promise.c | 8 ++++---- drivers/scsi/sata_qstor.c | 8 ++++---- drivers/scsi/sata_sil.c | 7 ++++--- drivers/scsi/sata_svw.c | 5 ++--- drivers/scsi/sata_sx4.c | 15 +++++++-------- drivers/scsi/sata_vsc.c | 5 ++--- 10 files changed, 45 insertions(+), 39 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index 4cfb257a0f6..31065261de8 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c @@ -995,8 +995,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) probe_ent->dev = pci_dev_to_dev(pdev); INIT_LIST_HEAD(&probe_ent->node); - mmio_base = ioremap(pci_resource_start(pdev, AHCI_PCI_BAR), - pci_resource_len(pdev, AHCI_PCI_BAR)); + mmio_base = pci_iomap(pdev, AHCI_PCI_BAR, 0); if (mmio_base == NULL) { rc = -ENOMEM; goto err_out_free_ent; @@ -1040,7 +1039,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) err_out_hpriv: kfree(hpriv); err_out_iounmap: - iounmap(mmio_base); + pci_iounmap(pdev, mmio_base); err_out_free_ent: kfree(probe_ent); err_out_msi: @@ -1081,7 +1080,7 @@ static void ahci_remove_one (struct pci_dev *pdev) } kfree(hpriv); - iounmap(host_set->mmio_base); + pci_iounmap(pdev, host_set->mmio_base); kfree(host_set); if (have_msi) diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 90c53b88a1e..deec0cef88d 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c @@ -584,7 +584,6 @@ static void pci_enable_intx(struct pci_dev *pdev) static int piix_disable_ahci(struct pci_dev *pdev) { void __iomem *mmio; - unsigned long addr; u32 tmp; int rc = 0; @@ -592,11 +591,11 @@ static int piix_disable_ahci(struct pci_dev *pdev) * works because this device is usually set up by BIOS. */ - addr = pci_resource_start(pdev, AHCI_PCI_BAR); - if (!addr || !pci_resource_len(pdev, AHCI_PCI_BAR)) + if (!pci_resource_start(pdev, AHCI_PCI_BAR) || + !pci_resource_len(pdev, AHCI_PCI_BAR)) return 0; - mmio = ioremap(addr, 64); + mmio = pci_iomap(pdev, AHCI_PCI_BAR, 64); if (!mmio) return -ENOMEM; @@ -610,7 +609,7 @@ static int piix_disable_ahci(struct pci_dev *pdev) rc = -EIO; } - iounmap(mmio); + pci_iounmap(pdev, mmio); return rc; } diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index dee4b12b034..1fe20f76fb5 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -4200,6 +4200,15 @@ ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port) +#ifdef CONFIG_PCI + +void ata_pci_host_stop (struct ata_host_set *host_set) +{ + struct pci_dev *pdev = to_pci_dev(host_set->dev); + + pci_iounmap(pdev, host_set->mmio_base); +} + /** * ata_pci_init_native_mode - Initialize native-mode driver * @pdev: pci device to be initialized @@ -4212,7 +4221,6 @@ ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port) * ata_probe_ent structure should then be freed with kfree(). */ -#ifdef CONFIG_PCI struct ata_probe_ent * ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port) { @@ -4595,6 +4603,7 @@ EXPORT_SYMBOL_GPL(ata_scsi_simulate); #ifdef CONFIG_PCI EXPORT_SYMBOL_GPL(pci_test_config_bits); +EXPORT_SYMBOL_GPL(ata_pci_host_stop); EXPORT_SYMBOL_GPL(ata_pci_init_native_mode); EXPORT_SYMBOL_GPL(ata_pci_init_one); EXPORT_SYMBOL_GPL(ata_pci_remove_one); diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c index 03d9bc6e69d..a1d62dee3be 100644 --- a/drivers/scsi/sata_nv.c +++ b/drivers/scsi/sata_nv.c @@ -351,6 +351,7 @@ static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) static void nv_host_stop (struct ata_host_set *host_set) { struct nv_host *host = host_set->private_data; + struct pci_dev *pdev = to_pci_dev(host_set->dev); // Disable hotplug event interrupts. if (host->host_desc->disable_hotplug) @@ -358,7 +359,8 @@ static void nv_host_stop (struct ata_host_set *host_set) kfree(host); - ata_host_stop(host_set); + if (host_set->mmio_base) + pci_iounmap(pdev, host_set->mmio_base); } static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) @@ -420,8 +422,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) { unsigned long base; - probe_ent->mmio_base = ioremap(pci_resource_start(pdev, 5), - pci_resource_len(pdev, 5)); + probe_ent->mmio_base = pci_iomap(pdev, 5, 0); if (probe_ent->mmio_base == NULL) { rc = -EIO; goto err_out_free_host; @@ -457,7 +458,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) err_out_iounmap: if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) - iounmap(probe_ent->mmio_base); + pci_iounmap(pdev, probe_ent->mmio_base); err_out_free_host: kfree(host); err_out_free_ent: diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index ed54f281060..538ad727bd2 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c @@ -92,6 +92,7 @@ static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf); static void pdc_irq_clear(struct ata_port *ap); static int pdc_qc_issue_prot(struct ata_queued_cmd *qc); + static Scsi_Host_Template pdc_ata_sht = { .module = THIS_MODULE, .name = DRV_NAME, @@ -132,7 +133,7 @@ static struct ata_port_operations pdc_sata_ops = { .scr_write = pdc_sata_scr_write, .port_start = pdc_port_start, .port_stop = pdc_port_stop, - .host_stop = ata_host_stop, + .host_stop = ata_pci_host_stop, }; static struct ata_port_operations pdc_pata_ops = { @@ -153,7 +154,7 @@ static struct ata_port_operations pdc_pata_ops = { .port_start = pdc_port_start, .port_stop = pdc_port_stop, - .host_stop = ata_host_stop, + .host_stop = ata_pci_host_stop, }; static struct ata_port_info pdc_port_info[] = { @@ -663,8 +664,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e probe_ent->dev = pci_dev_to_dev(pdev); INIT_LIST_HEAD(&probe_ent->node); - mmio_base = ioremap(pci_resource_start(pdev, 3), - pci_resource_len(pdev, 3)); + mmio_base = pci_iomap(pdev, 3, 0); if (mmio_base == NULL) { rc = -ENOMEM; goto err_out_free_ent; diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c index 9c99ab433bd..029c2482e12 100644 --- a/drivers/scsi/sata_qstor.c +++ b/drivers/scsi/sata_qstor.c @@ -538,11 +538,12 @@ static void qs_port_stop(struct ata_port *ap) static void qs_host_stop(struct ata_host_set *host_set) { void __iomem *mmio_base = host_set->mmio_base; + struct pci_dev *pdev = to_pci_dev(host_set->dev); writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */ writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */ - ata_host_stop(host_set); + pci_iounmap(pdev, mmio_base); } static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe) @@ -646,8 +647,7 @@ static int qs_ata_init_one(struct pci_dev *pdev, goto err_out_regions; } - mmio_base = ioremap(pci_resource_start(pdev, 4), - pci_resource_len(pdev, 4)); + mmio_base = pci_iomap(pdev, 4, 0); if (mmio_base == NULL) { rc = -ENOMEM; goto err_out_regions; @@ -697,7 +697,7 @@ static int qs_ata_init_one(struct pci_dev *pdev, return 0; err_out_iounmap: - iounmap(mmio_base); + pci_iounmap(pdev, mmio_base); err_out_regions: pci_release_regions(pdev); err_out: diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index b1a696fcec8..ba98a175ee3 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c @@ -86,6 +86,7 @@ static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg); static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); static void sil_post_set_mode (struct ata_port *ap); + static struct pci_device_id sil_pci_tbl[] = { { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, @@ -172,7 +173,7 @@ static struct ata_port_operations sil_ops = { .scr_write = sil_scr_write, .port_start = ata_port_start, .port_stop = ata_port_stop, - .host_stop = ata_host_stop, + .host_stop = ata_pci_host_stop, }; static struct ata_port_info sil_port_info[] = { @@ -231,6 +232,7 @@ MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, sil_pci_tbl); MODULE_VERSION(DRV_VERSION); + static unsigned char sil_get_device_cache_line(struct pci_dev *pdev) { u8 cache_line = 0; @@ -426,8 +428,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) probe_ent->irq_flags = SA_SHIRQ; probe_ent->host_flags = sil_port_info[ent->driver_data].host_flags; - mmio_base = ioremap(pci_resource_start(pdev, 5), - pci_resource_len(pdev, 5)); + mmio_base = pci_iomap(pdev, 5, 0); if (mmio_base == NULL) { rc = -ENOMEM; goto err_out_free_ent; diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c index d48de9547fb..d89d968beda 100644 --- a/drivers/scsi/sata_svw.c +++ b/drivers/scsi/sata_svw.c @@ -318,7 +318,7 @@ static struct ata_port_operations k2_sata_ops = { .scr_write = k2_sata_scr_write, .port_start = ata_port_start, .port_stop = ata_port_stop, - .host_stop = ata_host_stop, + .host_stop = ata_pci_host_stop, }; static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base) @@ -392,8 +392,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e probe_ent->dev = pci_dev_to_dev(pdev); INIT_LIST_HEAD(&probe_ent->node); - mmio_base = ioremap(pci_resource_start(pdev, 5), - pci_resource_len(pdev, 5)); + mmio_base = pci_iomap(pdev, 5, 0); if (mmio_base == NULL) { rc = -ENOMEM; goto err_out_free_ent; diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index 38b3dd2d750..540a8519117 100644 --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c @@ -245,13 +245,14 @@ static struct pci_driver pdc_sata_pci_driver = { static void pdc20621_host_stop(struct ata_host_set *host_set) { + struct pci_dev *pdev = to_pci_dev(host_set->dev); struct pdc_host_priv *hpriv = host_set->private_data; void *dimm_mmio = hpriv->dimm_mmio; - iounmap(dimm_mmio); + pci_iounmap(pdev, dimm_mmio); kfree(hpriv); - ata_host_stop(host_set); + pci_iounmap(pdev, host_set->mmio_base); } static int pdc_port_start(struct ata_port *ap) @@ -1418,8 +1419,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * probe_ent->dev = pci_dev_to_dev(pdev); INIT_LIST_HEAD(&probe_ent->node); - mmio_base = ioremap(pci_resource_start(pdev, 3), - pci_resource_len(pdev, 3)); + mmio_base = pci_iomap(pdev, 3, 0); if (mmio_base == NULL) { rc = -ENOMEM; goto err_out_free_ent; @@ -1433,8 +1433,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * } memset(hpriv, 0, sizeof(*hpriv)); - dimm_mmio = ioremap(pci_resource_start(pdev, 4), - pci_resource_len(pdev, 4)); + dimm_mmio = pci_iomap(pdev, 4, 0); if (!dimm_mmio) { kfree(hpriv); rc = -ENOMEM; @@ -1481,9 +1480,9 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * err_out_iounmap_dimm: /* only get to this label if 20621 */ kfree(hpriv); - iounmap(dimm_mmio); + pci_iounmap(pdev, dimm_mmio); err_out_iounmap: - iounmap(mmio_base); + pci_iounmap(pdev, mmio_base); err_out_free_ent: kfree(probe_ent); err_out_regions: diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c index 3985f344da4..cf94e0158a8 100644 --- a/drivers/scsi/sata_vsc.c +++ b/drivers/scsi/sata_vsc.c @@ -252,7 +252,7 @@ static struct ata_port_operations vsc_sata_ops = { .scr_write = vsc_sata_scr_write, .port_start = ata_port_start, .port_stop = ata_port_stop, - .host_stop = ata_host_stop, + .host_stop = ata_pci_host_stop, }; static void __devinit vsc_sata_setup_port(struct ata_ioports *port, unsigned long base) @@ -326,8 +326,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d probe_ent->dev = pci_dev_to_dev(pdev); INIT_LIST_HEAD(&probe_ent->node); - mmio_base = ioremap(pci_resource_start(pdev, 0), - pci_resource_len(pdev, 0)); + mmio_base = pci_iomap(pdev, 0, 0); if (mmio_base == NULL) { rc = -ENOMEM; goto err_out_free_ent; -- cgit v1.2.3-18-g5258 From 6f1062330499cee10396bf3fc66a03eb228c5fad Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Tue, 30 Aug 2005 21:52:18 -0400 Subject: [libata] fix ATAPI-enable typo Dumb typo spotted by Mark Lord. --- drivers/scsi/libata-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 55823765425..104fd9a63e7 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c @@ -1470,7 +1470,7 @@ ata_scsi_find_dev(struct ata_port *ap, struct scsi_device *scsidev) if (unlikely(!ata_dev_present(dev))) return NULL; - if (atapi_enabled) { + if (!atapi_enabled) { if (unlikely(dev->class == ATA_DEV_ATAPI)) return NULL; } -- cgit v1.2.3-18-g5258 From 53c165e0a6c8a4ff7df316557528fa7a52d20711 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Mon, 22 Aug 2005 10:06:19 -0500 Subject: [SCSI] correct attribute_container list usage One of the changes in the attribute_container code in the scsi-misc tree was to add a lock to protect the list of devices per container. This, unfortunately, leads to potential scheduling while atomic problems if there's a sleep in the function called by a trigger. The correct solution is to use the kernel klist infrastructure instead which allows lockless traversal of a list. Signed-off-by: James Bottomley --- drivers/base/attribute_container.c | 51 ++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 22 deletions(-) (limited to 'drivers') diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c index ebcae5c3413..6c0f49340eb 100644 --- a/drivers/base/attribute_container.c +++ b/drivers/base/attribute_container.c @@ -22,7 +22,7 @@ /* This is a private structure used to tie the classdev and the * container .. it should never be visible outside this file */ struct internal_container { - struct list_head node; + struct klist_node node; struct attribute_container *cont; struct class_device classdev; }; @@ -57,8 +57,7 @@ int attribute_container_register(struct attribute_container *cont) { INIT_LIST_HEAD(&cont->node); - INIT_LIST_HEAD(&cont->containers); - spin_lock_init(&cont->containers_lock); + klist_init(&cont->containers); down(&attribute_container_mutex); list_add_tail(&cont->node, &attribute_container_list); @@ -78,13 +77,13 @@ attribute_container_unregister(struct attribute_container *cont) { int retval = -EBUSY; down(&attribute_container_mutex); - spin_lock(&cont->containers_lock); - if (!list_empty(&cont->containers)) + spin_lock(&cont->containers.k_lock); + if (!list_empty(&cont->containers.k_list)) goto out; retval = 0; list_del(&cont->node); out: - spin_unlock(&cont->containers_lock); + spin_unlock(&cont->containers.k_lock); up(&attribute_container_mutex); return retval; @@ -143,7 +142,6 @@ attribute_container_add_device(struct device *dev, continue; } memset(ic, 0, sizeof(struct internal_container)); - INIT_LIST_HEAD(&ic->node); ic->cont = cont; class_device_initialize(&ic->classdev); ic->classdev.dev = get_device(dev); @@ -154,13 +152,22 @@ attribute_container_add_device(struct device *dev, fn(cont, dev, &ic->classdev); else attribute_container_add_class_device(&ic->classdev); - spin_lock(&cont->containers_lock); - list_add_tail(&ic->node, &cont->containers); - spin_unlock(&cont->containers_lock); + klist_add_tail(&ic->node, &cont->containers); } up(&attribute_container_mutex); } +/* FIXME: can't break out of this unless klist_iter_exit is also + * called before doing the break + */ +#define klist_for_each_entry(pos, head, member, iter) \ + for (klist_iter_init(head, iter); (pos = ({ \ + struct klist_node *n = klist_next(iter); \ + n ? ({ klist_iter_exit(iter) ; NULL; }) : \ + container_of(n, typeof(*pos), member);\ + }) ) != NULL; ) + + /** * attribute_container_remove_device - make device eligible for removal. * @@ -187,18 +194,19 @@ attribute_container_remove_device(struct device *dev, down(&attribute_container_mutex); list_for_each_entry(cont, &attribute_container_list, node) { - struct internal_container *ic, *tmp; + struct internal_container *ic; + struct klist_iter iter; if (attribute_container_no_classdevs(cont)) continue; if (!cont->match(cont, dev)) continue; - spin_lock(&cont->containers_lock); - list_for_each_entry_safe(ic, tmp, &cont->containers, node) { + + klist_for_each_entry(ic, &cont->containers, node, &iter) { if (dev != ic->classdev.dev) continue; - list_del(&ic->node); + klist_remove(&ic->node); if (fn) fn(cont, dev, &ic->classdev); else { @@ -206,7 +214,6 @@ attribute_container_remove_device(struct device *dev, class_device_unregister(&ic->classdev); } } - spin_unlock(&cont->containers_lock); } up(&attribute_container_mutex); } @@ -232,7 +239,8 @@ attribute_container_device_trigger(struct device *dev, down(&attribute_container_mutex); list_for_each_entry(cont, &attribute_container_list, node) { - struct internal_container *ic, *tmp; + struct internal_container *ic; + struct klist_iter iter; if (!cont->match(cont, dev)) continue; @@ -242,12 +250,10 @@ attribute_container_device_trigger(struct device *dev, continue; } - spin_lock(&cont->containers_lock); - list_for_each_entry_safe(ic, tmp, &cont->containers, node) { + klist_for_each_entry(ic, &cont->containers, node, &iter) { if (dev == ic->classdev.dev) fn(cont, dev, &ic->classdev); } - spin_unlock(&cont->containers_lock); } up(&attribute_container_mutex); } @@ -397,15 +403,16 @@ attribute_container_find_class_device(struct attribute_container *cont, { struct class_device *cdev = NULL; struct internal_container *ic; + struct klist_iter iter; - spin_lock(&cont->containers_lock); - list_for_each_entry(ic, &cont->containers, node) { + klist_for_each_entry(ic, &cont->containers, node, &iter) { if (ic->classdev.dev == dev) { cdev = &ic->classdev; + /* FIXME: must exit iterator then break */ + klist_iter_exit(&iter); break; } } - spin_unlock(&cont->containers_lock); return cdev; } -- cgit v1.2.3-18-g5258 From 2b7d6a8cb9718fc1d9e826201b64909c44a915f4 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 28 Aug 2005 09:13:17 -0500 Subject: [SCSI] attribute container final klist fixes Since the attribute container deletes from a klist while it's walking it, it is vulnerable to the problem (and fix) here: http://marc.theaimsgroup.com/?l=linux-scsi&m=112485448830217 The attached fixes this (but won't compile without the above). It also fixes the logical reversal in the traversal loop which meant that we were never actually traversing the loop to hit this bug in the first place. Signed-off-by: James Bottomley --- drivers/base/attribute_container.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c index 6c0f49340eb..373e7b728fa 100644 --- a/drivers/base/attribute_container.c +++ b/drivers/base/attribute_container.c @@ -27,6 +27,21 @@ struct internal_container { struct class_device classdev; }; +static void internal_container_klist_get(struct klist_node *n) +{ + struct internal_container *ic = + container_of(n, struct internal_container, node); + class_device_get(&ic->classdev); +} + +static void internal_container_klist_put(struct klist_node *n) +{ + struct internal_container *ic = + container_of(n, struct internal_container, node); + class_device_put(&ic->classdev); +} + + /** * attribute_container_classdev_to_container - given a classdev, return the container * @@ -57,7 +72,8 @@ int attribute_container_register(struct attribute_container *cont) { INIT_LIST_HEAD(&cont->node); - klist_init(&cont->containers); + klist_init(&cont->containers,internal_container_klist_get, + internal_container_klist_put); down(&attribute_container_mutex); list_add_tail(&cont->node, &attribute_container_list); @@ -163,8 +179,8 @@ attribute_container_add_device(struct device *dev, #define klist_for_each_entry(pos, head, member, iter) \ for (klist_iter_init(head, iter); (pos = ({ \ struct klist_node *n = klist_next(iter); \ - n ? ({ klist_iter_exit(iter) ; NULL; }) : \ - container_of(n, typeof(*pos), member);\ + n ? container_of(n, typeof(*pos), member) : \ + ({ klist_iter_exit(iter) ; NULL; }); \ }) ) != NULL; ) @@ -206,7 +222,7 @@ attribute_container_remove_device(struct device *dev, klist_for_each_entry(ic, &cont->containers, node, &iter) { if (dev != ic->classdev.dev) continue; - klist_remove(&ic->node); + klist_del(&ic->node); if (fn) fn(cont, dev, &ic->classdev); else { -- cgit v1.2.3-18-g5258 From 61a7afa2c476a3be261cf88a95b0dea0c3bd29d4 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Tue, 16 Aug 2005 18:27:34 -0500 Subject: [SCSI] embryonic RAID class The idea behind a RAID class is to provide a uniform interface to all RAID subsystems (both hardware and software) in the kernel. To do that, I've made this class a transport class that's entirely subsystem independent (although the matching routines have to match per subsystem, as you'll see looking at the code). I put it in the scsi subdirectory purely because I needed somewhere to play with it, but it's not a scsi specific module. I used a fusion raid card as the test bed for this; with that kind of card, this is the type of class output you get: jejb@titanic> ls -l /sys/class/raid_devices/20\:0\:0\:0/ total 0 lrwxrwxrwx 1 root root 0 Aug 16 17:21 component-0 -> ../../../devices/pci0000:80/0000:80:04.0/host20/target20:1:0/20:1:0:0/ lrwxrwxrwx 1 root root 0 Aug 16 17:21 component-1 -> ../../../devices/pci0000:80/0000:80:04.0/host20/target20:1:1/20:1:1:0/ lrwxrwxrwx 1 root root 0 Aug 16 17:21 device -> ../../../devices/pci0000:80/0000:80:04.0/host20/target20:0:0/20:0:0:0/ -r--r--r-- 1 root root 16384 Aug 16 17:21 level -r--r--r-- 1 root root 16384 Aug 16 17:21 resync -r--r--r-- 1 root root 16384 Aug 16 17:21 state So it's really simple: for a SCSI device representing a hardware raid, it shows the raid level, the array state, the resync % complete (if the state is resyncing) and the underlying components of the RAID (these are exposed in fusion on the virtual channel 1). As you can see, this type of information can be exported by almost anything, including software raid. The more difficult trick, of course, is going to be getting it to perform configuration type actions with writable attributes. Signed-off-by: James Bottomley --- drivers/scsi/Kconfig | 6 ++ drivers/scsi/Makefile | 2 + drivers/scsi/raid_class.c | 250 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 258 insertions(+) create mode 100644 drivers/scsi/raid_class.c (limited to 'drivers') diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 96df148ed96..68adc3cc8ad 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -1,5 +1,11 @@ menu "SCSI device support" +config RAID_ATTRS + tristate "RAID Transport Class" + default n + ---help--- + Provides RAID + config SCSI tristate "SCSI device support" ---help--- diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 3746fb9fa2f..85f9e6bb34b 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -22,6 +22,8 @@ subdir-$(CONFIG_PCMCIA) += pcmcia obj-$(CONFIG_SCSI) += scsi_mod.o +obj-$(CONFIG_RAID_ATTRS) += raid_class.o + # --- NOTE ORDERING HERE --- # For kernel non-modular link, transport attributes need to # be initialised before drivers diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c new file mode 100644 index 00000000000..f1ea5027865 --- /dev/null +++ b/drivers/scsi/raid_class.c @@ -0,0 +1,250 @@ +/* + * RAID Attributes + */ +#include +#include +#include +#include +#include +#include + +#define RAID_NUM_ATTRS 3 + +struct raid_internal { + struct raid_template r; + struct raid_function_template *f; + /* The actual attributes */ + struct class_device_attribute private_attrs[RAID_NUM_ATTRS]; + /* The array of null terminated pointers to attributes + * needed by scsi_sysfs.c */ + struct class_device_attribute *attrs[RAID_NUM_ATTRS + 1]; +}; + +struct raid_component { + struct list_head node; + struct device *dev; + int num; +}; + +#define to_raid_internal(tmpl) container_of(tmpl, struct raid_internal, r) + +#define tc_to_raid_internal(tcont) ({ \ + struct raid_template *r = \ + container_of(tcont, struct raid_template, raid_attrs); \ + to_raid_internal(r); \ +}) + +#define ac_to_raid_internal(acont) ({ \ + struct transport_container *tc = \ + container_of(acont, struct transport_container, ac); \ + tc_to_raid_internal(tc); \ +}) + +#define class_device_to_raid_internal(cdev) ({ \ + struct attribute_container *ac = \ + attribute_container_classdev_to_container(cdev); \ + ac_to_raid_internal(ac); \ +}) + + +static int raid_match(struct attribute_container *cont, struct device *dev) +{ + /* We have to look for every subsystem that could house + * emulated RAID devices, so start with SCSI */ + struct raid_internal *i = ac_to_raid_internal(cont); + + if (scsi_is_sdev_device(dev)) { + struct scsi_device *sdev = to_scsi_device(dev); + + if (i->f->cookie != sdev->host->hostt) + return 0; + + return i->f->is_raid(dev); + } + /* FIXME: look at other subsystems too */ + return 0; +} + +static int raid_setup(struct transport_container *tc, struct device *dev, + struct class_device *cdev) +{ + struct raid_data *rd; + + BUG_ON(class_get_devdata(cdev)); + + rd = kmalloc(sizeof(*rd), GFP_KERNEL); + if (!rd) + return -ENOMEM; + + memset(rd, 0, sizeof(*rd)); + INIT_LIST_HEAD(&rd->component_list); + class_set_devdata(cdev, rd); + + return 0; +} + +static int raid_remove(struct transport_container *tc, struct device *dev, + struct class_device *cdev) +{ + struct raid_data *rd = class_get_devdata(cdev); + struct raid_component *rc, *next; + class_set_devdata(cdev, NULL); + list_for_each_entry_safe(rc, next, &rd->component_list, node) { + char buf[40]; + snprintf(buf, sizeof(buf), "component-%d", rc->num); + list_del(&rc->node); + sysfs_remove_link(&cdev->kobj, buf); + kfree(rc); + } + kfree(class_get_devdata(cdev)); + return 0; +} + +static DECLARE_TRANSPORT_CLASS(raid_class, + "raid_devices", + raid_setup, + raid_remove, + NULL); + +static struct { + enum raid_state value; + char *name; +} raid_states[] = { + { RAID_ACTIVE, "active" }, + { RAID_DEGRADED, "degraded" }, + { RAID_RESYNCING, "resyncing" }, + { RAID_OFFLINE, "offline" }, +}; + +static const char *raid_state_name(enum raid_state state) +{ + int i; + char *name = NULL; + + for (i = 0; i < sizeof(raid_states)/sizeof(raid_states[0]); i++) { + if (raid_states[i].value == state) { + name = raid_states[i].name; + break; + } + } + return name; +} + + +#define raid_attr_show_internal(attr, fmt, var, code) \ +static ssize_t raid_show_##attr(struct class_device *cdev, char *buf) \ +{ \ + struct raid_data *rd = class_get_devdata(cdev); \ + code \ + return snprintf(buf, 20, #fmt "\n", var); \ +} + +#define raid_attr_ro_states(attr, states, code) \ +raid_attr_show_internal(attr, %s, name, \ + const char *name; \ + code \ + name = raid_##states##_name(rd->attr); \ +) \ +static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) + + +#define raid_attr_ro_internal(attr, code) \ +raid_attr_show_internal(attr, %d, rd->attr, code) \ +static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) + +#define ATTR_CODE(attr) \ + struct raid_internal *i = class_device_to_raid_internal(cdev); \ + if (i->f->get_##attr) \ + i->f->get_##attr(cdev->dev); + +#define raid_attr_ro(attr) raid_attr_ro_internal(attr, ) +#define raid_attr_ro_fn(attr) raid_attr_ro_internal(attr, ATTR_CODE(attr)) +#define raid_attr_ro_state(attr) raid_attr_ro_states(attr, attr, ATTR_CODE(attr)) + +raid_attr_ro(level); +raid_attr_ro_fn(resync); +raid_attr_ro_state(state); + +void raid_component_add(struct raid_template *r,struct device *raid_dev, + struct device *component_dev) +{ + struct class_device *cdev = + attribute_container_find_class_device(&r->raid_attrs.ac, + raid_dev); + struct raid_component *rc; + struct raid_data *rd = class_get_devdata(cdev); + char buf[40]; + + rc = kmalloc(sizeof(*rc), GFP_KERNEL); + if (!rc) + return; + + INIT_LIST_HEAD(&rc->node); + rc->dev = component_dev; + rc->num = rd->component_count++; + + snprintf(buf, sizeof(buf), "component-%d", rc->num); + list_add_tail(&rc->node, &rd->component_list); + sysfs_create_link(&cdev->kobj, &component_dev->kobj, buf); +} +EXPORT_SYMBOL(raid_component_add); + +struct raid_template * +raid_class_attach(struct raid_function_template *ft) +{ + struct raid_internal *i = kmalloc(sizeof(struct raid_internal), + GFP_KERNEL); + int count = 0; + + if (unlikely(!i)) + return NULL; + + memset(i, 0, sizeof(*i)); + + i->f = ft; + + i->r.raid_attrs.ac.class = &raid_class.class; + i->r.raid_attrs.ac.match = raid_match; + i->r.raid_attrs.ac.attrs = &i->attrs[0]; + + attribute_container_register(&i->r.raid_attrs.ac); + + i->attrs[count++] = &class_device_attr_level; + i->attrs[count++] = &class_device_attr_resync; + i->attrs[count++] = &class_device_attr_state; + + i->attrs[count] = NULL; + BUG_ON(count > RAID_NUM_ATTRS); + + return &i->r; +} +EXPORT_SYMBOL(raid_class_attach); + +void +raid_class_release(struct raid_template *r) +{ + struct raid_internal *i = to_raid_internal(r); + + attribute_container_unregister(&i->r.raid_attrs.ac); + + kfree(i); +} +EXPORT_SYMBOL(raid_class_release); + +static __init int raid_init(void) +{ + return transport_class_register(&raid_class); +} + +static __exit void raid_exit(void) +{ + transport_class_unregister(&raid_class); +} + +MODULE_AUTHOR("James Bottomley"); +MODULE_DESCRIPTION("RAID device class"); +MODULE_LICENSE("GPL"); + +module_init(raid_init); +module_exit(raid_exit); + -- cgit v1.2.3-18-g5258 From 5843e37e24d7cf32f7996dd015245633e0790595 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 30 Aug 2005 21:46:19 -0700 Subject: [SPARC64]: Use drivers/Kconfig And move some other stuff into drivers/sbus/char/Kconfig. Signed-off-by: David S. Miller --- drivers/sbus/char/Kconfig | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/sbus/char/Kconfig b/drivers/sbus/char/Kconfig index a41778a490d..3a8152906bf 100644 --- a/drivers/sbus/char/Kconfig +++ b/drivers/sbus/char/Kconfig @@ -69,11 +69,40 @@ config SUN_JSFLASH If you say Y here, you will be able to boot from your JavaStation's Flash memory. -# XXX Why don't we do "source drivers/char/Config.in" somewhere? -# no shit -config RTC - tristate "PC-style Real Time Clock Support" - depends on PCI && EXPERIMENTAL && SPARC32 +config BBC_I2C + tristate "UltraSPARC-III bootbus i2c controller driver" + depends on PCI && SPARC64 + help + The BBC devices on the UltraSPARC III have two I2C controllers. The + first I2C controller connects mainly to configuration PROMs (NVRAM, + CPU configuration, DIMM types, etc.). The second I2C controller + connects to environmental control devices such as fans and + temperature sensors. The second controller also connects to the + smartcard reader, if present. Say Y to enable support for these. + +config ENVCTRL + tristate "SUNW, envctrl support" + depends on PCI && SPARC64 + help + Kernel support for temperature and fan monitoring on Sun SME + machines. + + To compile this driver as a module, choose M here: the + module will be called envctrl. + +config DISPLAY7SEG + tristate "7-Segment Display support" + depends on PCI && SPARC64 + ---help--- + This is the driver for the 7-segment display and LED present on + Sun Microsystems CompactPCI models CP1400 and CP1500. + + To compile this driver as a module, choose M here: the + module will be called display7seg. + + If you do not have a CompactPCI model CP1400 or CP1500, or + another UltraSPARC-IIi-cEngine boardset with a 7-segment display, + you should say N to this option. endmenu -- cgit v1.2.3-18-g5258 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 --- drivers/char/ipmi/ipmi_si_intf.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index c51b02d9dfd..adbec73b80a 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 v1.2.3-18-g5258 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 --- drivers/acpi/dispatcher/dsmethod.c | 52 +++++++++++++++++++------------------- drivers/acpi/parser/psparse.c | 21 +++++---------- drivers/acpi/parser/psxface.c | 13 ---------- drivers/acpi/utilities/utmisc.c | 2 ++ 4 files changed, 34 insertions(+), 54 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 77fcfc3070d..8b67a918341 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 3248051d77e..36771309c62 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 80c67f2d3dd..f6904bdf573 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -98,16 +98,6 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info) return_ACPI_STATUS(status); } - /* - * 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 f0275025b71..c2f5b2adb5d 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); -- cgit v1.2.3-18-g5258 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 --- drivers/cpufreq/cpufreq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 10b01498238..109d62ccf65 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 v1.2.3-18-g5258 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 --- drivers/char/agp/amd64-agp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index 59f589d733f..0a7624a9b1c 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 v1.2.3-18-g5258 From ff4cc3ac93e1d0369928fd60ec1fe82417afc576 Mon Sep 17 00:00:00 2001 From: Mike Kershaw Date: Thu, 1 Sep 2005 17:40:05 -0700 Subject: [TUNTAP]: Allow setting the linktype of the tap device from userspace Currently tun/tap only supports the EN10MB ARP type. For use with wireless and other networking types it should be possible to set the ARP type via an ioctl. Patch v2: Included check that the tap interface is down before changing the link type out from underneath it Signed-off-by: Mike Kershaw Signed-off-by: David S. Miller --- drivers/net/tun.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'drivers') diff --git a/drivers/net/tun.c b/drivers/net/tun.c index effab0b9adc..50b8c6754b1 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -18,6 +18,9 @@ /* * Changes: * + * Mike Kershaw 2005/08/14 + * Add TUNSETLINK ioctl to set the link encapsulation + * * Mark Smith * Use random_ether_addr() for tap MAC address. * @@ -612,6 +615,18 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file, DBG(KERN_INFO "%s: owner set to %d\n", tun->dev->name, tun->owner); break; + case TUNSETLINK: + /* Only allow setting the type when the interface is down */ + if (tun->dev->flags & IFF_UP) { + DBG(KERN_INFO "%s: Linktype set failed because interface is up\n", + tun->dev->name); + return -EBUSY; + } else { + tun->dev->type = (int) arg; + DBG(KERN_INFO "%s: linktype set to %d\n", tun->dev->name, tun->dev->type); + } + break; + #ifdef TUN_DEBUG case TUNSETDEBUG: tun->debug = arg; -- cgit v1.2.3-18-g5258 From 0014c6156f9e7d034d20742d164d7d4da289b42a Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Thu, 1 Sep 2005 17:40:46 -0700 Subject: [SUNGEM]: fix minor bug in sungem.h This changes the Sun Gem Ether driver's tx ring buffer length to the proper constant. Currently TX_RING_SIZE and RX_RING_SIZE are equal, so no malfunction occurs. Signed-off-by: Geoff Levand Signed-off-by: David S. Miller --- drivers/net/sungem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/sungem.h b/drivers/net/sungem.h index 7143fd7cf3f..ff8ae5f7997 100644 --- a/drivers/net/sungem.h +++ b/drivers/net/sungem.h @@ -1020,7 +1020,7 @@ struct gem { struct gem_init_block *init_block; struct sk_buff *rx_skbs[RX_RING_SIZE]; - struct sk_buff *tx_skbs[RX_RING_SIZE]; + struct sk_buff *tx_skbs[TX_RING_SIZE]; dma_addr_t gblock_dvma; struct pci_dev *pdev; -- cgit v1.2.3-18-g5258 From 86d9f7f0c9cf06d7d3cfa2a9f0514cf21fa5fda1 Mon Sep 17 00:00:00 2001 From: Eric Lemoine Date: Thu, 1 Sep 2005 17:41:07 -0700 Subject: [SUNGEM]: Fix netpoll bug in Sun GEM Ether driver From: Eric Lemoine To me the bug is that __LINK_STATE_RX_SCHED can be set while __netif_rx_schedule() hasen't be called. Why don't fix it in the simplest way ? See attached patch (absolutely untested). Signed-off-by: Geoff Levand Signed-off-by: David S. Miller --- drivers/net/sungem.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index 2608e7a3d21..3f67a42e850 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c @@ -948,6 +948,7 @@ static irqreturn_t gem_interrupt(int irq, void *dev_id, struct pt_regs *regs) u32 gem_status = readl(gp->regs + GREG_STAT); if (gem_status == 0) { + netif_poll_enable(dev); spin_unlock_irqrestore(&gp->lock, flags); return IRQ_NONE; } -- cgit v1.2.3-18-g5258 From 51b9146869ab9492da785c5c9321d85f01655ab6 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Thu, 1 Sep 2005 17:41:28 -0700 Subject: [TG3]: Minimize locking in TX path. This is similar to Eric Dumazet's tx_lock patch for tg3 but takes it one step further to eliminate the tx_lock in the tx_completion path when the tx queue is not stopped. Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index af8263a1580..e877579aab3 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -121,12 +121,9 @@ TG3_RX_RCB_RING_SIZE(tp)) #define TG3_TX_RING_BYTES (sizeof(struct tg3_tx_buffer_desc) * \ TG3_TX_RING_SIZE) -#define TX_RING_GAP(TP) \ - (TG3_TX_RING_SIZE - (TP)->tx_pending) #define TX_BUFFS_AVAIL(TP) \ - (((TP)->tx_cons <= (TP)->tx_prod) ? \ - (TP)->tx_cons + (TP)->tx_pending - (TP)->tx_prod : \ - (TP)->tx_cons - (TP)->tx_prod - TX_RING_GAP(TP)) + ((TP)->tx_pending - \ + (((TP)->tx_prod - (TP)->tx_cons) & (TG3_TX_RING_SIZE - 1))) #define NEXT_TX(N) (((N) + 1) & (TG3_TX_RING_SIZE - 1)) #define RX_PKT_BUF_SZ (1536 + tp->rx_offset + 64) @@ -2880,9 +2877,13 @@ static void tg3_tx(struct tg3 *tp) tp->tx_cons = sw_idx; - if (netif_queue_stopped(tp->dev) && - (TX_BUFFS_AVAIL(tp) > TG3_TX_WAKEUP_THRESH)) - netif_wake_queue(tp->dev); + if (unlikely(netif_queue_stopped(tp->dev))) { + spin_lock(&tp->tx_lock); + if (netif_queue_stopped(tp->dev) && + (TX_BUFFS_AVAIL(tp) > TG3_TX_WAKEUP_THRESH)) + netif_wake_queue(tp->dev); + spin_unlock(&tp->tx_lock); + } } /* Returns size of skb allocated or < 0 on error. @@ -3198,9 +3199,7 @@ static int tg3_poll(struct net_device *netdev, int *budget) /* run TX completion thread */ if (sblk->idx[0].tx_consumer != tp->tx_cons) { - spin_lock(&tp->tx_lock); tg3_tx(tp); - spin_unlock(&tp->tx_lock); } /* run RX thread, within the bounds set by NAPI. @@ -3716,8 +3715,11 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) tw32_tx_mbox((MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW), entry); tp->tx_prod = entry; - if (TX_BUFFS_AVAIL(tp) <= (MAX_SKB_FRAGS + 1)) + if (TX_BUFFS_AVAIL(tp) <= (MAX_SKB_FRAGS + 1)) { netif_stop_queue(dev); + if (TX_BUFFS_AVAIL(tp) > TG3_TX_WAKEUP_THRESH) + netif_wake_queue(tp->dev); + } out_unlock: mmiowb(); -- cgit v1.2.3-18-g5258 From 75c80c382fbd08acf06fbef9d54c9844e806a8b4 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 1 Sep 2005 17:42:23 -0700 Subject: [TG3]: Update driver version and release date. Signed-off-by: David S. Miller --- drivers/net/tg3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index e877579aab3..3faf62310f8 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -66,8 +66,8 @@ #define DRV_MODULE_NAME "tg3" #define PFX DRV_MODULE_NAME ": " -#define DRV_MODULE_VERSION "3.37" -#define DRV_MODULE_RELDATE "August 25, 2005" +#define DRV_MODULE_VERSION "3.38" +#define DRV_MODULE_RELDATE "September 1, 2005" #define TG3_DEF_MAC_MODE 0 #define TG3_DEF_RX_MODE 0 -- cgit v1.2.3-18-g5258 From eb6f1160ddb2fdadf50f350da79d0796c37f17e2 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Thu, 1 Sep 2005 17:43:25 -0700 Subject: [CRYPTO]: Use CRYPTO_TFM_REQ_MAY_SLEEP where appropriate This patch goes through the current users of the crypto layer and sets CRYPTO_TFM_REQ_MAY_SLEEP at crypto_alloc_tfm() where all crypto operations are performed in process context. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- drivers/block/cryptoloop.c | 6 ++++-- drivers/md/dm-crypt.c | 7 ++++--- drivers/net/wireless/airo.c | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c index 5be6f998d8c..3d4261c39f1 100644 --- a/drivers/block/cryptoloop.c +++ b/drivers/block/cryptoloop.c @@ -57,9 +57,11 @@ cryptoloop_init(struct loop_device *lo, const struct loop_info64 *info) mode = strsep(&cmsp, "-"); if (mode == NULL || strcmp(mode, "cbc") == 0) - tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_CBC); + tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_CBC | + CRYPTO_TFM_REQ_MAY_SLEEP); else if (strcmp(mode, "ecb") == 0) - tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_ECB); + tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_ECB | + CRYPTO_TFM_REQ_MAY_SLEEP); if (tfm == NULL) return -EINVAL; diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index d0a4bab220e..b82bc315047 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -144,7 +144,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, } /* Hash the cipher key with the given hash algorithm */ - hash_tfm = crypto_alloc_tfm(opts, 0); + hash_tfm = crypto_alloc_tfm(opts, CRYPTO_TFM_REQ_MAY_SLEEP); if (hash_tfm == NULL) { ti->error = PFX "Error initializing ESSIV hash"; return -EINVAL; @@ -172,7 +172,8 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, /* Setup the essiv_tfm with the given salt */ essiv_tfm = crypto_alloc_tfm(crypto_tfm_alg_name(cc->tfm), - CRYPTO_TFM_MODE_ECB); + CRYPTO_TFM_MODE_ECB | + CRYPTO_TFM_REQ_MAY_SLEEP); if (essiv_tfm == NULL) { ti->error = PFX "Error allocating crypto tfm for ESSIV"; kfree(salt); @@ -587,7 +588,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) goto bad1; } - tfm = crypto_alloc_tfm(cipher, crypto_flags); + tfm = crypto_alloc_tfm(cipher, crypto_flags | CRYPTO_TFM_REQ_MAY_SLEEP); if (!tfm) { ti->error = PFX "Error allocating crypto tfm"; goto bad1; diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index df20adcd073..7fdb85dda4e 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -1301,7 +1301,7 @@ static int micsetup(struct airo_info *ai) { int i; if (ai->tfm == NULL) - ai->tfm = crypto_alloc_tfm("aes", 0); + ai->tfm = crypto_alloc_tfm("aes", CRYPTO_TFM_REQ_MAY_SLEEP); if (ai->tfm == NULL) { printk(KERN_ERR "airo: failed to load transform for AES\n"); -- cgit v1.2.3-18-g5258 From 573dbd95964b01a942aa0c68e92b06f2c9536964 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Thu, 1 Sep 2005 17:44:29 -0700 Subject: [CRYPTO]: crypto_free_tfm() callers no longer need to check for NULL Since the patch to add a NULL short-circuit to crypto_free_tfm() went in, there's no longer any need for callers of that function to check for NULL. This patch removes the redundant NULL checks and also a few similar checks for NULL before calls to kfree() that I ran into while doing the crypto_free_tfm bits. I've succesfuly compile tested this patch, and a kernel with the patch applied boots and runs just fine. When I posted the patch to LKML (and other lists/people on Cc) it drew the following comments : J. Bruce Fields commented "I've no problem with the auth_gss or nfsv4 bits.--b." Sridhar Samudrala said "sctp change looks fine." Herbert Xu signed off on the patch. So, I guess this is ready to be dropped into -mm and eventually mainline. Signed-off-by: Jesper Juhl Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- drivers/net/wireless/airo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 7fdb85dda4e..2bb8170cf6f 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -2403,8 +2403,7 @@ void stop_airo_card( struct net_device *dev, int freeres ) } } #ifdef MICSUPPORT - if (ai->tfm) - crypto_free_tfm(ai->tfm); + crypto_free_tfm(ai->tfm); #endif del_airo_dev( dev ); free_netdev( dev ); -- cgit v1.2.3-18-g5258 From d27400746189f3b5194b49575833ea660c430118 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 2 Sep 2005 16:58:06 +0100 Subject: [SERIAL] crisv10: Remove {,un}register_serial dummies It seems we can simply kill these dummies with this patch. Signed-off-by: Adrian Bunk Signed-off-by: Russell King --- drivers/serial/crisv10.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'drivers') diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c index 23b8871e74c..5690594b257 100644 --- a/drivers/serial/crisv10.c +++ b/drivers/serial/crisv10.c @@ -5041,17 +5041,3 @@ rs_init(void) /* this makes sure that rs_init is called during kernel boot */ module_init(rs_init); - -/* - * register_serial and unregister_serial allows for serial ports to be - * configured at run-time, to support PCMCIA modems. - */ -int -register_serial(struct serial_struct *req) -{ - return -1; -} - -void unregister_serial(int line) -{ -} -- cgit v1.2.3-18-g5258 From d70063c4634af060a5387337b7632f6334ca3458 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 2 Sep 2005 12:18:03 -0700 Subject: [ATM]: Fix dereference of uninitialized pointer in zatm Fixing breakage from [NET]: Kill skb->list - original was assign vcc do a bunch of stuff using ZATM_VCC(vcc)->pool as common subexpression Now we do int pos = ZATM_VCC(vcc)->pool; assign vcc do a bunch of stuff even though vcc is not even initialized when we enter that block... Signed-off-by: Al Viro Signed-off-by: David S. Miller --- drivers/atm/zatm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c index c4b75ecf946..55959e4d1cb 100644 --- a/drivers/atm/zatm.c +++ b/drivers/atm/zatm.c @@ -417,9 +417,9 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]); chan = (here[3] & uPD98401_AAL5_CHAN) >> uPD98401_AAL5_CHAN_SHIFT; if (chan < zatm_dev->chans && zatm_dev->rx_map[chan]) { - int pos = ZATM_VCC(vcc)->pool; - + int pos; vcc = zatm_dev->rx_map[chan]; + pos = ZATM_VCC(vcc)->pool; if (skb == zatm_dev->last_free[pos]) zatm_dev->last_free[pos] = NULL; skb_unlink(skb, zatm_dev->pool + pos); -- cgit v1.2.3-18-g5258 From ebede60741e2cec6d210f137fd22a30e37abc0be Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 2 Sep 2005 12:20:18 -0700 Subject: [SPARC32]: More dependencies fallout More stuff that got exposed to sparc32 build due to inclusion of drivers/char/Kconfig in arch/sparc/Kconfig needs to be excluded. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- drivers/char/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 7333b41d422..d6adc2614f6 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -175,7 +175,7 @@ config MOXA_INTELLIO config MOXA_SMARTIO tristate "Moxa SmartIO support" - depends on SERIAL_NONSTANDARD + depends on SERIAL_NONSTANDARD && (BROKEN || !SPARC32) help Say Y here if you have a Moxa SmartIO multiport serial card. -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/dispatcher/dsmethod.c | 52 +++++++++++++++++++------------------- drivers/acpi/parser/psparse.c | 21 ++++++++++----- drivers/acpi/parser/psxface.c | 13 ++++++++++ drivers/acpi/utilities/utmisc.c | 2 -- 4 files changed, 54 insertions(+), 34 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 8b67a918341..77fcfc3070d 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 36771309c62..3248051d77e 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 f6904bdf573..80c67f2d3dd 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -98,6 +98,16 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info) return_ACPI_STATUS(status); } + /* + * 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 c2f5b2adb5d..f0275025b71 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); -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/dispatcher/dsmethod.c | 69 ++--- drivers/acpi/dispatcher/dswload.c | 5 + drivers/acpi/parser/psparse.c | 23 +- drivers/acpi/parser/psxface.c | 14 - drivers/acpi/resources/rsaddr.c | 542 ++++++++++++++++++------------------- drivers/acpi/resources/rsirq.c | 21 +- drivers/acpi/utilities/utmisc.c | 15 +- 7 files changed, 331 insertions(+), 358 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 77fcfc3070d..36c1ca0b9ad 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. @@ -236,6 +243,18 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, ACPI_WAIT_FOREVER); } + /* + * 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 362bbcfc171..411731261c2 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) || @@ -745,6 +749,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) status = acpi_ds_exec_end_op(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 3248051d77e..76d4d640d83 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 80c67f2d3dd..4dcbd443160 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -98,16 +98,6 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info) return_ACPI_STATUS(status); } - /* - * 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 4cf46e1ee01..23b54baa0cb 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 7179b6243f5..56043fee96c 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 f0275025b71..0c5abc536c7 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 */ -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/osl.c | 2 +- drivers/acpi/pci_bind.c | 3 ++- drivers/acpi/processor_core.c | 2 +- drivers/acpi/scan.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index dc69d8760a5..d528c750a38 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 a4955685e4c..2a718df769b 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 819cb0b453f..42179256264 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 8a3ea41063e..c6db591479d 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 v1.2.3-18-g5258 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 --- drivers/acpi/pci_irq.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 2bbfba8e8c6..09567c2edcf 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 v1.2.3-18-g5258 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 --- drivers/pnp/pnpacpi/rsparser.c | 75 ++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 32 deletions(-) (limited to 'drivers') diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 1e296cbef00..6db549c9480 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 v1.2.3-18-g5258 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 --- drivers/acpi/processor_core.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 42179256264..ac2dfa63646 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 v1.2.3-18-g5258 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 --- drivers/acpi/video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index b9132b5ac0f..e383d6109ae 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 v1.2.3-18-g5258 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 --- drivers/acpi/processor_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index ac2dfa63646..40d4e624414 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 v1.2.3-18-g5258 From be3df0f94d77ba3cff40c14c3e21a753c40ba6f2 Mon Sep 17 00:00:00 2001 From: Wim Van Sebroeck Date: Wed, 17 Aug 2005 01:49:24 +0200 Subject: [WATCHDOG] Makefile-probe_order-patch Re-arrange Makefile according to what we want to probe first. Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/Makefile | 69 ++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 23 deletions(-) (limited to 'drivers') diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index c1838834ea7..d9b0ed53dae 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile @@ -2,42 +2,65 @@ # Makefile for the WatchDog device drivers. # +# Only one watchdog can succeed. We probe the ISA/PCI/USB based +# watchdog-cards first, then the architecture specific watchdog +# drivers and then the architecture independant "softdog" driver. +# This means that if your ISA/PCI/USB card isn't detected that +# you can fall back to an architecture specific driver and if +# that also fails then you can fall back to the software watchdog +# to give you some cover. + +# ISA-based Watchdog Cards obj-$(CONFIG_PCWATCHDOG) += pcwd.o -obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o -obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o -obj-$(CONFIG_IB700_WDT) += ib700wdt.o obj-$(CONFIG_MIXCOMWD) += mixcomwd.o -obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o -obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o obj-$(CONFIG_WDT) += wdt.o + +# PCI-based Watchdog Cards +obj-$(CONFIG_PCIPCWATCHDOG) += pcwd_pci.o obj-$(CONFIG_WDTPCI) += wdt_pci.o + +# USB-based Watchdog Cards +obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o + +# ARM Architecture obj-$(CONFIG_21285_WATCHDOG) += wdt285.o obj-$(CONFIG_977_WATCHDOG) += wdt977.o -obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o -obj-$(CONFIG_MACHZ_WDT) += machzwd.o -obj-$(CONFIG_SH_WDT) += shwdt.o +obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o +obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o -obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o -obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o -obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o -obj-$(CONFIG_SC520_WDT) += sc520_wdt.o -obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o + +# X86 (i386 + ia64 + x86_64) Architecture +obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o +obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o obj-$(CONFIG_ALIM1535_WDT) += alim1535_wdt.o -obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o +obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o +obj-$(CONFIG_SC520_WDT) += sc520_wdt.o +obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o +obj-$(CONFIG_IB700_WDT) += ib700wdt.o obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o +obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o +obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o +obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o +obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o -obj-$(CONFIG_INDYDOG) += indydog.o -obj-$(CONFIG_PCIPCWATCHDOG) += pcwd_pci.o -obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o -obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o -obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o +obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o +obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o +obj-$(CONFIG_MACHZ_WDT) += machzwd.o + +# PowerPC Architecture obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o -# Only one watchdog can succeed. We probe the hardware watchdog -# drivers first, then the softdog driver. This means if your hardware -# watchdog dies or is 'borrowed' for some reason the software watchdog -# still gives you some cover. +# MIPS Architecture +obj-$(CONFIG_INDYDOG) += indydog.o + +# S390 Architecture + +# SUPERH Architecture +obj-$(CONFIG_SH_WDT) += shwdt.o + +# SPARC64 Architecture +# Architecture Independant obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o -- cgit v1.2.3-18-g5258 From 09c8a9a0c0fe5b3182b6ecfa556fa77a55892c93 Mon Sep 17 00:00:00 2001 From: Wim Van Sebroeck Date: Sat, 3 Sep 2005 13:46:56 +0200 Subject: [WATCHDOG] Kconfig+Makefile-clean Clean the Kconfig+Makefile according to a sorted list of the drivers of each architecture (and sub-architecture). Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/Kconfig | 43 +++++++++++++++++++++--------------------- drivers/char/watchdog/Makefile | 4 +++- 2 files changed, 25 insertions(+), 22 deletions(-) (limited to 'drivers') diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index b53e2e2b5ae..f4bf6c39901 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig @@ -84,6 +84,17 @@ config 977_WATCHDOG Not sure? It's safe to say N. +config IXP2000_WATCHDOG + tristate "IXP2000 Watchdog" + depends on WATCHDOG && ARCH_IXP2000 + help + Say Y here if to include support for the watchdog timer + in the Intel IXP2000(2400, 2800, 2850) network processors. + This driver can be built as a module by choosing M. The module + will be called ixp2000_wdt. + + Say N if you are unsure. + config IXP4XX_WATCHDOG tristate "IXP4xx Watchdog" depends on WATCHDOG && ARCH_IXP4XX @@ -100,17 +111,6 @@ config IXP4XX_WATCHDOG Say N if you are unsure. -config IXP2000_WATCHDOG - tristate "IXP2000 Watchdog" - depends on WATCHDOG && ARCH_IXP2000 - help - Say Y here if to include support for the watchdog timer - in the Intel IXP2000(2400, 2800, 2850) network processors. - This driver can be built as a module by choosing M. The module - will be called ixp2000_wdt. - - Say N if you are unsure. - config S3C2410_WATCHDOG tristate "S3C2410 Watchdog" depends on WATCHDOG && ARCH_S3C2410 @@ -346,6 +346,17 @@ config 8xx_WDT tristate "MPC8xx Watchdog Timer" depends on WATCHDOG && 8xx +# PPC64 Architecture + +config WATCHDOG_RTAS + tristate "RTAS watchdog" + depends on WATCHDOG && PPC_RTAS + help + This driver adds watchdog support for the RTAS watchdog. + + To compile this driver as a module, choose M here. The module + will be called wdrtas. + # MIPS Architecture config INDYDOG @@ -414,16 +425,6 @@ config WATCHDOG_RIO machines. The watchdog timeout period is normally one minute but can be changed with a boot-time parameter. -# ppc64 RTAS watchdog -config WATCHDOG_RTAS - tristate "RTAS watchdog" - depends on WATCHDOG && PPC_RTAS - help - This driver adds watchdog support for the RTAS watchdog. - - To compile this driver as a module, choose M here. The module - will be called wdrtas. - # # ISA-based Watchdog Cards # diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index d9b0ed53dae..6f02f4ce453 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile @@ -25,8 +25,8 @@ obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o # ARM Architecture obj-$(CONFIG_21285_WATCHDOG) += wdt285.o obj-$(CONFIG_977_WATCHDOG) += wdt977.o -obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o +obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o @@ -50,6 +50,8 @@ obj-$(CONFIG_MACHZ_WDT) += machzwd.o # PowerPC Architecture obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o + +# PPC64 Architecture obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o # MIPS Architecture -- cgit v1.2.3-18-g5258 From 2dab3cabc4b3c1ef53965233dc8a05e0ddeeb38e Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Wed, 17 Aug 2005 08:58:34 +0200 Subject: [WATCHDOG] correct sysfs name for watchdog devices While looking for possible candidates for our udev.rules package, I found a few odd ->name properties. /dev/watchdog has minor 130 according to devices.txt. Since all watchdog drivers use the misc_register() call, they will end up in /sys/class/misc/$foo. udev may create the /dev/watchdog node if the driver is loaded. I dont have such a device, so I cant test it. The drivers below provide names with spaces and even with / in it. Not a big deal, but apps may expect /dev/watchdog. Signed-off-by: Olaf Hering Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/ixp2000_wdt.c | 2 +- drivers/char/watchdog/ixp4xx_wdt.c | 2 +- drivers/char/watchdog/scx200_wdt.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/char/watchdog/ixp2000_wdt.c b/drivers/char/watchdog/ixp2000_wdt.c index e7640bc4904..0cfb9b9c4a4 100644 --- a/drivers/char/watchdog/ixp2000_wdt.c +++ b/drivers/char/watchdog/ixp2000_wdt.c @@ -182,7 +182,7 @@ static struct file_operations ixp2000_wdt_fops = static struct miscdevice ixp2000_wdt_miscdev = { .minor = WATCHDOG_MINOR, - .name = "IXP2000 Watchdog", + .name = "watchdog", .fops = &ixp2000_wdt_fops, }; diff --git a/drivers/char/watchdog/ixp4xx_wdt.c b/drivers/char/watchdog/ixp4xx_wdt.c index 8d916afbf4f..b5be8b11104 100644 --- a/drivers/char/watchdog/ixp4xx_wdt.c +++ b/drivers/char/watchdog/ixp4xx_wdt.c @@ -176,7 +176,7 @@ static struct file_operations ixp4xx_wdt_fops = static struct miscdevice ixp4xx_wdt_miscdev = { .minor = WATCHDOG_MINOR, - .name = "IXP4xx Watchdog", + .name = "watchdog", .fops = &ixp4xx_wdt_fops, }; diff --git a/drivers/char/watchdog/scx200_wdt.c b/drivers/char/watchdog/scx200_wdt.c index c4568569f3a..b4a102a2d7e 100644 --- a/drivers/char/watchdog/scx200_wdt.c +++ b/drivers/char/watchdog/scx200_wdt.c @@ -206,7 +206,7 @@ static struct file_operations scx200_wdt_fops = { static struct miscdevice scx200_wdt_miscdev = { .minor = WATCHDOG_MINOR, - .name = NAME, + .name = "watchdog", .fops = &scx200_wdt_fops, }; -- cgit v1.2.3-18-g5258 From af4bb822bc65efb087cd36b83789f22161a6515b Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Wed, 17 Aug 2005 09:03:23 +0200 Subject: [WATCHDOG] s3c2410 watchdog power management Patch from Dimitry Andric , updated by Ben Dooks . Patch is against 2.6.11-mm2 Add power management support to the s3c2410 watchdog, so that it is shut-down over suspend, and re-initialised on resume. Also add Dimitry to the list of authors. Signed-off-by: Dimitry Andric Signed-off-by: Ben Dooks Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/s3c2410_wdt.c | 51 ++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index f85ac898a49..522435782e7 100644 --- a/drivers/char/watchdog/s3c2410_wdt.c +++ b/drivers/char/watchdog/s3c2410_wdt.c @@ -27,7 +27,9 @@ * Fixed tmr_count / wdt_count confusion * Added configurable debug * - * 11-Jan-2004 BJD Fixed divide-by-2 in timeout code + * 11-Jan-2005 BJD Fixed divide-by-2 in timeout code + * + * 25-Jan-2005 DA Added suspend/resume support * * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA */ @@ -479,15 +481,57 @@ static int s3c2410wdt_remove(struct device *dev) return 0; } +#ifdef CONFIG_PM + +static unsigned long wtcon_save; +static unsigned long wtdat_save; + +static int s3c2410wdt_suspend(struct device *dev, u32 state, u32 level) +{ + if (level == SUSPEND_POWER_DOWN) { + /* Save watchdog state, and turn it off. */ + wtcon_save = readl(wdt_base + S3C2410_WTCON); + wtdat_save = readl(wdt_base + S3C2410_WTDAT); + + /* Note that WTCNT doesn't need to be saved. */ + s3c2410wdt_stop(); + } + + return 0; +} + +static int s3c2410wdt_resume(struct device *dev, u32 level) +{ + if (level == RESUME_POWER_ON) { + /* Restore watchdog state. */ + + writel(wtdat_save, wdt_base + S3C2410_WTDAT); + writel(wtdat_save, wdt_base + S3C2410_WTCNT); /* Reset count */ + writel(wtcon_save, wdt_base + S3C2410_WTCON); + + printk(KERN_INFO PFX "watchdog %sabled\n", + (wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis"); + } + + return 0; +} + +#else +#define s3c2410wdt_suspend NULL +#define s3c2410wdt_resume NULL +#endif /* CONFIG_PM */ + + static struct device_driver s3c2410wdt_driver = { .name = "s3c2410-wdt", .bus = &platform_bus_type, .probe = s3c2410wdt_probe, .remove = s3c2410wdt_remove, + .suspend = s3c2410wdt_suspend, + .resume = s3c2410wdt_resume, }; - static char banner[] __initdata = KERN_INFO "S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics\n"; static int __init watchdog_init(void) @@ -505,7 +549,8 @@ static void __exit watchdog_exit(void) module_init(watchdog_init); module_exit(watchdog_exit); -MODULE_AUTHOR("Ben Dooks "); +MODULE_AUTHOR("Ben Dooks , " + "Dimitry Andric "); MODULE_DESCRIPTION("S3C2410 Watchdog Device Driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); -- cgit v1.2.3-18-g5258 From 94f1e9f316b10972b77a64344006c3bf8a4929b4 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Wed, 17 Aug 2005 09:04:52 +0200 Subject: [WATCHDOG] s3c2410 watchdog - replace reboot notifier Patch from Dimitry Andric Change to using platfrom driver's .shutdown method instead of an reboot notifier Signed-off-by: Dimitry Andric Signed-off-by: Ben Dooks Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/s3c2410_wdt.c | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) (limited to 'drivers') diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index 522435782e7..8b292bf343c 100644 --- a/drivers/char/watchdog/s3c2410_wdt.c +++ b/drivers/char/watchdog/s3c2410_wdt.c @@ -30,6 +30,7 @@ * 11-Jan-2005 BJD Fixed divide-by-2 in timeout code * * 25-Jan-2005 DA Added suspend/resume support + * Replaced reboot notifier with .shutdown method * * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA */ @@ -42,8 +43,6 @@ #include #include #include -#include -#include #include #include #include @@ -319,20 +318,6 @@ static int s3c2410wdt_ioctl(struct inode *inode, struct file *file, } } -/* - * Notifier for system down - */ - -static int s3c2410wdt_notify_sys(struct notifier_block *this, unsigned long code, - void *unused) -{ - if(code==SYS_DOWN || code==SYS_HALT) { - /* Turn the WDT off */ - s3c2410wdt_stop(); - } - return NOTIFY_DONE; -} - /* kernel interface */ static struct file_operations s3c2410wdt_fops = { @@ -350,10 +335,6 @@ static struct miscdevice s3c2410wdt_miscdev = { .fops = &s3c2410wdt_fops, }; -static struct notifier_block s3c2410wdt_notifier = { - .notifier_call = s3c2410wdt_notify_sys, -}; - /* interrupt handler code */ static irqreturn_t s3c2410wdt_irq(int irqno, void *param, @@ -434,18 +415,10 @@ static int s3c2410wdt_probe(struct device *dev) } } - ret = register_reboot_notifier(&s3c2410wdt_notifier); - if (ret) { - printk (KERN_ERR PFX "cannot register reboot notifier (%d)\n", - ret); - return ret; - } - ret = misc_register(&s3c2410wdt_miscdev); if (ret) { printk (KERN_ERR PFX "cannot register miscdev on minor=%d (%d)\n", WATCHDOG_MINOR, ret); - unregister_reboot_notifier(&s3c2410wdt_notifier); return ret; } @@ -481,6 +454,11 @@ static int s3c2410wdt_remove(struct device *dev) return 0; } +static void s3c2410wdt_shutdown(struct device *dev) +{ + s3c2410wdt_stop(); +} + #ifdef CONFIG_PM static unsigned long wtcon_save; @@ -527,6 +505,7 @@ static struct device_driver s3c2410wdt_driver = { .bus = &platform_bus_type, .probe = s3c2410wdt_probe, .remove = s3c2410wdt_remove, + .shutdown = s3c2410wdt_shutdown, .suspend = s3c2410wdt_suspend, .resume = s3c2410wdt_resume, }; @@ -543,7 +522,6 @@ static int __init watchdog_init(void) static void __exit watchdog_exit(void) { driver_unregister(&s3c2410wdt_driver); - unregister_reboot_notifier(&s3c2410wdt_notifier); } module_init(watchdog_init); -- cgit v1.2.3-18-g5258 From 93642ecd463df30d032da8ac37c2676cee4ad876 Mon Sep 17 00:00:00 2001 From: "P@Draig Brady" Date: Wed, 17 Aug 2005 09:06:07 +0200 Subject: [WATCHDOG] w83627hf_wdt.c-initialized_bios_bug Attached is a small update to the w83627hf watchdog driver to initialise appropriately if it was already initialised in the BIOS. On tyan motherboards for e.g. you can init the watchdog to 4 mins, then when the driver is loaded it sets the watchdog to "seconds" mode, and then machine will reboot within 4 seconds. So this patch resets the timeout to the configured value if the watchdog is already running. Signed-off-by: P@draig Brady Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/w83627hf_wdt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers') diff --git a/drivers/char/watchdog/w83627hf_wdt.c b/drivers/char/watchdog/w83627hf_wdt.c index 465e0fd0423..b5d82101542 100644 --- a/drivers/char/watchdog/w83627hf_wdt.c +++ b/drivers/char/watchdog/w83627hf_wdt.c @@ -93,6 +93,12 @@ w83627hf_init(void) w83627hf_select_wd_register(); + outb_p(0xF6, WDT_EFER); /* Select CRF6 */ + t=inb_p(WDT_EFDR); /* read CRF6 */ + if (t != 0) { + printk (KERN_INFO PFX "Watchdog already running. Resetting timeout to %d sec\n", timeout); + outb_p(timeout, WDT_EFDR); /* Write back to CRF6 */ + } outb_p(0xF5, WDT_EFER); /* Select CRF5 */ t=inb_p(WDT_EFDR); /* read CRF5 */ t&=~0x0C; /* set second mode & disable keyboard turning off watchdog */ -- cgit v1.2.3-18-g5258 From 1cc77248106aafc12ba529953f652d6f8db2c84d Mon Sep 17 00:00:00 2001 From: Chuck Ebbert <76306.1226@compuserve.com> Date: Fri, 19 Aug 2005 14:14:07 +0200 Subject: [WATCHDOG] softdog-timer-running-oops.patch The softdog watchdog timer has a bug that can create an oops: 1. Load the module without the nowayout option. 2. Open the driver and close it without writing 'V' before close. 3. Unload the module. The timer will continue to run... 4. Oops happens when timer fires. Reported Sun, 10 Oct 2004, by Michael Schierl Fix is easy: always take a reference on the module on open. Release it only when the device is closed and no timer is running. Tested on 2.6.13-rc6 using the soft_noboot option. While the timer is running and the device is closed, the module use count stays at 1. After the timer fires, it drops to 0. Repeatedly opening and closing the driver caused no problems. Please apply. Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com> Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/softdog.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/char/watchdog/softdog.c b/drivers/char/watchdog/softdog.c index 4d7ed931f5c..20e5eb8667f 100644 --- a/drivers/char/watchdog/softdog.c +++ b/drivers/char/watchdog/softdog.c @@ -77,7 +77,7 @@ static void watchdog_fire(unsigned long); static struct timer_list watchdog_ticktock = TIMER_INITIALIZER(watchdog_fire, 0, 0); -static unsigned long timer_alive; +static unsigned long driver_open, orphan_timer; static char expect_close; @@ -87,6 +87,9 @@ static char expect_close; static void watchdog_fire(unsigned long data) { + if (test_and_clear_bit(0, &orphan_timer)) + module_put(THIS_MODULE); + if (soft_noboot) printk(KERN_CRIT PFX "Triggered - Reboot ignored.\n"); else @@ -128,9 +131,9 @@ static int softdog_set_heartbeat(int t) static int softdog_open(struct inode *inode, struct file *file) { - if(test_and_set_bit(0, &timer_alive)) + if (test_and_set_bit(0, &driver_open)) return -EBUSY; - if (nowayout) + if (!test_and_clear_bit(0, &orphan_timer)) __module_get(THIS_MODULE); /* * Activate timer @@ -147,11 +150,13 @@ static int softdog_release(struct inode *inode, struct file *file) */ if (expect_close == 42) { softdog_stop(); + module_put(THIS_MODULE); } else { printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); + set_bit(0, &orphan_timer); softdog_keepalive(); } - clear_bit(0, &timer_alive); + clear_bit(0, &driver_open); expect_close = 0; return 0; } -- cgit v1.2.3-18-g5258 From 30b7a3bc133c5b4a723163be35157ed709fca91c Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 3 Sep 2005 15:30:21 +0100 Subject: [SERIAL] Prefix serial printks with KERN_INFO and pre-format Pre-format the IO part of the ttyS printks, and prefix them with KERN_INFO to avoid bootsplash corruption. Signed-off-by: Russell King --- drivers/serial/serial_core.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index dea156a62d0..2d8622eef70 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c @@ -1947,21 +1947,29 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port) static inline void uart_report_port(struct uart_driver *drv, struct uart_port *port) { - printk("%s%d", drv->dev_name, port->line); - printk(" at "); + char address[64]; + switch (port->iotype) { case UPIO_PORT: - printk("I/O 0x%x", port->iobase); + snprintf(address, sizeof(address), + "I/O 0x%x", port->iobase); break; case UPIO_HUB6: - printk("I/O 0x%x offset 0x%x", port->iobase, port->hub6); + snprintf(address, sizeof(address), + "I/O 0x%x offset 0x%x", port->iobase, port->hub6); break; case UPIO_MEM: case UPIO_MEM32: - printk("MMIO 0x%lx", port->mapbase); + snprintf(address, sizeof(address), + "MMIO 0x%lx", port->mapbase); + break; + default: + strlcpy(address, "*unknown*", sizeof(address)); break; } - printk(" (irq = %d) is a %s\n", port->irq, uart_type(port)); + + printk(KERN_INFO "%s%d at %s (irq = %d) is a %s\n", + drv->dev_name, port->line, address, port->irq, uart_type(port)); } static void -- cgit v1.2.3-18-g5258 From 9b4e3b13b147e9b737de63188a9ae740eaa8c36d Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Sat, 3 Sep 2005 16:26:49 +0100 Subject: [SERIAL] Fix moxa tty driver name The moxa driver was named "ttya", which is wrong: 1) Documentation/devices.txt says that the name should be "ttyMX". 2) First 10 ports (ttya0...ttya9) clash with the legacy pty driver. This patch changes the driver name to "ttyMX". http://bugme.osdl.org/show_bug.cgi?id=5012 Signed-off-by: Sergey Vlasov Signed-off-by: Russell King --- drivers/char/moxa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 95f7046ff05..79e490ef2cf 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c @@ -339,7 +339,7 @@ static int __init moxa_init(void) init_MUTEX(&moxaBuffSem); moxaDriver->owner = THIS_MODULE; - moxaDriver->name = "ttya"; + moxaDriver->name = "ttyMX"; moxaDriver->devfs_name = "tts/a"; moxaDriver->major = ttymajor; moxaDriver->minor_start = 0; -- cgit v1.2.3-18-g5258 From 865e9f13c94891daed4f6a5f69c5d6ec04d4932f Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sat, 3 Sep 2005 16:45:02 +0100 Subject: [MMC] ios for mmc chip select Adds a new ios for setting the chip select pin on MMC cards. Needed on SD controllers which use this pin for other things and therefore cannot have it pulled high at all times. Signed-off-by: Pierre Ossman Signed-off-by: Russell King --- drivers/mmc/mmc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers') diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 3c5904834fe..0a8165974ba 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -457,6 +457,11 @@ static void mmc_idle_cards(struct mmc_host *host) { struct mmc_command cmd; + host->ios.chip_select = MMC_CS_HIGH; + host->ops->set_ios(host, &host->ios); + + mmc_delay(1); + cmd.opcode = MMC_GO_IDLE_STATE; cmd.arg = 0; cmd.flags = MMC_RSP_NONE; @@ -464,6 +469,11 @@ static void mmc_idle_cards(struct mmc_host *host) mmc_wait_for_cmd(host, &cmd, 0); mmc_delay(1); + + host->ios.chip_select = MMC_CS_DONTCARE; + host->ops->set_ios(host, &host->ios); + + mmc_delay(1); } /* @@ -475,6 +485,7 @@ static void mmc_power_up(struct mmc_host *host) host->ios.vdd = bit; host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; + host->ios.chip_select = MMC_CS_DONTCARE; host->ios.power_mode = MMC_POWER_UP; host->ops->set_ios(host, &host->ios); @@ -492,6 +503,7 @@ static void mmc_power_off(struct mmc_host *host) host->ios.clock = 0; host->ios.vdd = 0; host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; + host->ios.chip_select = MMC_CS_DONTCARE; host->ios.power_mode = MMC_POWER_OFF; host->ops->set_ios(host, &host->ios); } -- cgit v1.2.3-18-g5258 From 1656fa579e44691a860b095016eee910bc0b2793 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sat, 3 Sep 2005 16:45:49 +0100 Subject: [MMC] support for mmc chip select in wbsd Use the chip select ios in the wbsd driver. Signed-off-by: Pierre Ossman Signed-off-by: Russell King --- drivers/mmc/wbsd.c | 64 ++++++++++++++++++++++++++++++++++++++++++------------ drivers/mmc/wbsd.h | 3 ++- 2 files changed, 52 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c index 402c2d661fb..08ae22aed9e 100644 --- a/drivers/mmc/wbsd.c +++ b/drivers/mmc/wbsd.c @@ -42,7 +42,7 @@ #include "wbsd.h" #define DRIVER_NAME "wbsd" -#define DRIVER_VERSION "1.3" +#define DRIVER_VERSION "1.4" #ifdef CONFIG_MMC_DEBUG #define DBG(x...) \ @@ -960,8 +960,9 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios) struct wbsd_host* host = mmc_priv(mmc); u8 clk, setup, pwr; - DBGF("clock %uHz busmode %u powermode %u Vdd %u\n", - ios->clock, ios->bus_mode, ios->power_mode, ios->vdd); + DBGF("clock %uHz busmode %u powermode %u cs %u Vdd %u\n", + ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select, + ios->vdd); spin_lock_bh(&host->lock); @@ -1003,13 +1004,11 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios) /* * MMC cards need to have pin 1 high during init. - * Init time corresponds rather nicely with the bus mode. * It wreaks havoc with the card detection though so - * that needs to be disabed. + * that needs to be disabled. */ setup = wbsd_read_index(host, WBSD_IDX_SETUP); - if ((ios->power_mode == MMC_POWER_ON) && - (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)) + if (ios->chip_select == MMC_CS_HIGH) { setup |= WBSD_DAT3_H; host->flags |= WBSD_FIGNORE_DETECT; @@ -1017,7 +1016,12 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios) else { setup &= ~WBSD_DAT3_H; - host->flags &= ~WBSD_FIGNORE_DETECT; + + /* + * We cannot resume card detection immediatly + * because of capacitance and delays in the chip. + */ + mod_timer(&host->ignore_timer, jiffies + HZ/100); } wbsd_write_index(host, WBSD_IDX_SETUP, setup); @@ -1035,6 +1039,31 @@ static struct mmc_host_ops wbsd_ops = { * * \*****************************************************************************/ +/* + * Helper function to reset detection ignore + */ + +static void wbsd_reset_ignore(unsigned long data) +{ + struct wbsd_host *host = (struct wbsd_host*)data; + + BUG_ON(host == NULL); + + DBG("Resetting card detection ignore\n"); + + spin_lock_bh(&host->lock); + + host->flags &= ~WBSD_FIGNORE_DETECT; + + /* + * Card status might have changed during the + * blackout. + */ + tasklet_schedule(&host->card_tasklet); + + spin_unlock_bh(&host->lock); +} + /* * Helper function for card detection */ @@ -1097,7 +1126,7 @@ static void wbsd_tasklet_card(unsigned long param) * Delay card detection to allow electrical connections * to stabilise. */ - mod_timer(&host->timer, jiffies + HZ/2); + mod_timer(&host->detect_timer, jiffies + HZ/2); } spin_unlock(&host->lock); @@ -1124,6 +1153,8 @@ static void wbsd_tasklet_card(unsigned long param) mmc_detect_change(host->mmc); } + else + spin_unlock(&host->lock); } static void wbsd_tasklet_fifo(unsigned long param) @@ -1328,11 +1359,15 @@ static int __devinit wbsd_alloc_mmc(struct device* dev) spin_lock_init(&host->lock); /* - * Set up detection timer + * Set up timers */ - init_timer(&host->timer); - host->timer.data = (unsigned long)host; - host->timer.function = wbsd_detect_card; + init_timer(&host->detect_timer); + host->detect_timer.data = (unsigned long)host; + host->detect_timer.function = wbsd_detect_card; + + init_timer(&host->ignore_timer); + host->ignore_timer.data = (unsigned long)host; + host->ignore_timer.function = wbsd_reset_ignore; /* * Maximum number of segments. Worst case is one sector per segment @@ -1370,7 +1405,8 @@ static void __devexit wbsd_free_mmc(struct device* dev) host = mmc_priv(mmc); BUG_ON(host == NULL); - del_timer_sync(&host->timer); + del_timer_sync(&host->ignore_timer); + del_timer_sync(&host->detect_timer); mmc_free_host(mmc); diff --git a/drivers/mmc/wbsd.h b/drivers/mmc/wbsd.h index 661a9f6a6e6..8af43549f5d 100644 --- a/drivers/mmc/wbsd.h +++ b/drivers/mmc/wbsd.h @@ -181,5 +181,6 @@ struct wbsd_host struct tasklet_struct finish_tasklet; struct tasklet_struct block_tasklet; - struct timer_list timer; /* Card detection timer */ + struct timer_list detect_timer; /* Card detection timer */ + struct timer_list ignore_timer; /* Ignore detection timer */ }; -- cgit v1.2.3-18-g5258 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 --- drivers/acpi/processor_core.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 40d4e624414..42179256264 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 v1.2.3-18-g5258 From f36598aeca4c2dbaa607bf6f774e38eb965402f2 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 3 Sep 2005 19:39:25 +0100 Subject: [ARM] 2873/1: PCMCIA soc: Allow access to filesystems on CF at boot time Patch from Richard Purdie This change makes the soc pcmcia interfaces available earlier in the boot process meaning devices like CF microdrives can be used for the root filesystem. Signed-off-by: Richard Purdie Signed-off-by: Russell King --- drivers/pcmcia/pxa2xx_base.c | 2 +- drivers/pcmcia/pxa2xx_mainstone.c | 2 +- drivers/pcmcia/pxa2xx_sharpsl.c | 2 +- drivers/pcmcia/sa1100_generic.c | 2 +- drivers/pcmcia/sa1111_generic.c | 2 +- drivers/pcmcia/sa11xx_base.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c index 3e23cd461fb..325c992f7d8 100644 --- a/drivers/pcmcia/pxa2xx_base.c +++ b/drivers/pcmcia/pxa2xx_base.c @@ -246,7 +246,7 @@ static void __exit pxa2xx_pcmcia_exit(void) driver_unregister(&pxa2xx_pcmcia_driver); } -module_init(pxa2xx_pcmcia_init); +fs_initcall(pxa2xx_pcmcia_init); module_exit(pxa2xx_pcmcia_exit); MODULE_AUTHOR("Stefan Eletzhofer and Ian Molton "); diff --git a/drivers/pcmcia/pxa2xx_mainstone.c b/drivers/pcmcia/pxa2xx_mainstone.c index 5309734e168..bbe69b07ce5 100644 --- a/drivers/pcmcia/pxa2xx_mainstone.c +++ b/drivers/pcmcia/pxa2xx_mainstone.c @@ -196,7 +196,7 @@ static void __exit mst_pcmcia_exit(void) platform_device_unregister(mst_pcmcia_device); } -module_init(mst_pcmcia_init); +fs_initcall(mst_pcmcia_init); module_exit(mst_pcmcia_exit); MODULE_LICENSE("GPL"); diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c index 42efe218867..7bac2f7d8b3 100644 --- a/drivers/pcmcia/pxa2xx_sharpsl.c +++ b/drivers/pcmcia/pxa2xx_sharpsl.c @@ -257,7 +257,7 @@ static void __exit sharpsl_pcmcia_exit(void) platform_device_unregister(sharpsl_pcmcia_device); } -module_init(sharpsl_pcmcia_init); +fs_initcall(sharpsl_pcmcia_init); module_exit(sharpsl_pcmcia_exit); MODULE_DESCRIPTION("Sharp SL Series PCMCIA Support"); diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c index e98bb3d80e7..d4ed508b38b 100644 --- a/drivers/pcmcia/sa1100_generic.c +++ b/drivers/pcmcia/sa1100_generic.c @@ -126,5 +126,5 @@ MODULE_AUTHOR("John Dorsey "); MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11x0 Socket Controller"); MODULE_LICENSE("Dual MPL/GPL"); -module_init(sa11x0_pcmcia_init); +fs_initcall(sa11x0_pcmcia_init); module_exit(sa11x0_pcmcia_exit); diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c index b441f43a6a5..bb90a1448a5 100644 --- a/drivers/pcmcia/sa1111_generic.c +++ b/drivers/pcmcia/sa1111_generic.c @@ -189,7 +189,7 @@ static void __exit sa1111_drv_pcmcia_exit(void) sa1111_driver_unregister(&pcmcia_driver); } -module_init(sa1111_drv_pcmcia_init); +fs_initcall(sa1111_drv_pcmcia_init); module_exit(sa1111_drv_pcmcia_exit); MODULE_DESCRIPTION("SA1111 PCMCIA card socket driver"); diff --git a/drivers/pcmcia/sa11xx_base.c b/drivers/pcmcia/sa11xx_base.c index db04ffb6f68..59c5d968e9f 100644 --- a/drivers/pcmcia/sa11xx_base.c +++ b/drivers/pcmcia/sa11xx_base.c @@ -189,7 +189,7 @@ static int __init sa11xx_pcmcia_init(void) { return 0; } -module_init(sa11xx_pcmcia_init); +fs_initcall(sa11xx_pcmcia_init); static void __exit sa11xx_pcmcia_exit(void) {} -- cgit v1.2.3-18-g5258 From 07542b832309b93a2741cd162a391ab909f66438 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Wed, 31 Aug 2005 20:27:22 -0400 Subject: This patch fixes in st.c the bug in the signed/unsigned int comparison reported by Doug Gilbert and fixed by him in sg.c (see [PATCH] sg direct io/mmap oops). Doug fixed the comparison in sg.c. This fix for st.c does not touch the comparison but makes both arguments signed to remove the problem. The new code is adapted from linux/fs/bio.c. Signed-off-by: Kai Makisara Rejections fixed up and Signed-off-by: James Bottomley --- drivers/scsi/st.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 47a5698a712..5325cf0ab19 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -17,7 +17,7 @@ Last modified: 18-JAN-1998 Richard Gooch Devfs support */ -static char *verstr = "20050802"; +static char *verstr = "20050830"; #include @@ -4444,12 +4444,12 @@ static int st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pag static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, unsigned long uaddr, size_t count, int rw) { + unsigned long end = (uaddr + count + PAGE_SIZE - 1) >> PAGE_SHIFT; + unsigned long start = uaddr >> PAGE_SHIFT; + const int nr_pages = end - start; int res, i, j; - unsigned int nr_pages; struct page **pages; - nr_pages = ((uaddr & ~PAGE_MASK) + count + ~PAGE_MASK) >> PAGE_SHIFT; - /* User attempted Overflow! */ if ((uaddr + count) < uaddr) return -EINVAL; -- cgit v1.2.3-18-g5258 From deb92b7ee98e8e580cafaa63bd1edbe6646877bc Mon Sep 17 00:00:00 2001 From: Douglas Gilbert Date: Thu, 1 Sep 2005 21:50:02 +1000 Subject: [SCSI] sg direct io/mmap oops, st sync This patch adopts the same solution as proposed by Kai M. in a post titled: "[PATCH] SCSI tape signed/unsigned fix". The fix is in a function that the sg driver borrowed from the st driver so its maintenance is a little easier if the functions remain the same after the fix. - change nr_pages type from unsigned to signed so errors from get_user_pages() call are properly handled Signed-off-by: Douglas Gilbert Signed-off-by: James Bottomley --- drivers/scsi/sg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 14fb179b384..616c3f3e62f 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -61,7 +61,7 @@ static int sg_version_num = 30533; /* 2 digits for each component */ #ifdef CONFIG_SCSI_PROC_FS #include -static char *sg_version_date = "20050328"; +static char *sg_version_date = "20050901"; static int sg_proc_init(void); static void sg_proc_cleanup(void); @@ -1794,12 +1794,12 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, unsigned long uaddr, size_t count, int rw, unsigned long max_pfn) { + unsigned long end = (uaddr + count + PAGE_SIZE - 1) >> PAGE_SHIFT; + unsigned long start = uaddr >> PAGE_SHIFT; + const int nr_pages = end - start; int res, i, j; - unsigned int nr_pages; struct page **pages; - nr_pages = ((uaddr & ~PAGE_MASK) + count + ~PAGE_MASK) >> PAGE_SHIFT; - /* User attempted Overflow! */ if ((uaddr + count) < uaddr) return -EINVAL; -- cgit v1.2.3-18-g5258 From 77d71d222e871670300f3e3092e2a06f20c842f0 Mon Sep 17 00:00:00 2001 From: Mark Haverkamp Date: Thu, 1 Sep 2005 08:19:23 -0700 Subject: [SCSI] aacraid: bad BUG_ON fix This was noticed by Doug Bazamic and the fix found by Mark Salyzyn at Adaptec. There was an error in the BUG_ON() statement that validated the calculated fib size which can cause the driver to panic. Signed-off-by: Mark Haverkamp Signed-off-by: James Bottomley --- drivers/scsi/aacraid/aachba.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 83bfab73ff6..a8e3dfcd0dc 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -972,7 +972,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid) fibsize = sizeof(struct aac_read64) + ((le32_to_cpu(readcmd->sg.count) - 1) * sizeof (struct sgentry64)); - BUG_ON (fibsize > (sizeof(struct hw_fib) - + BUG_ON (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))); /* * Now send the Fib to the adapter -- cgit v1.2.3-18-g5258 From 1ff927306e08b356d764e605eff7c50079550bd2 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 19 Aug 2005 18:57:13 +0200 Subject: [SCSI] aic7xxx: remove aiclib.c #include of C files and macro tricks to rename symbols are evil and just cause trouble. Let's doublicate the two functions as they're going to go away soon enough anyway. Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_osm.c | 96 ++++++++++++++++++++++++---- drivers/scsi/aic7xxx/aic79xx_proc.c | 45 +++++++++++++- drivers/scsi/aic7xxx/aic7xxx_osm.c | 89 +++++++++++++++++++++++--- drivers/scsi/aic7xxx/aic7xxx_proc.c | 45 +++++++++++++- drivers/scsi/aic7xxx/aiclib.c | 121 ------------------------------------ drivers/scsi/aic7xxx/aiclib.h | 22 ------- 6 files changed, 253 insertions(+), 165 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 3feb739cd55..6b6d4e28779 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -48,12 +48,6 @@ static struct scsi_transport_template *ahd_linux_transport_template = NULL; -/* - * Include aiclib.c as part of our - * "module dependencies are hard" work around. - */ -#include "aiclib.c" - #include /* __setup */ #include /* For fetching system memory size */ #include /* For block_size() */ @@ -372,8 +366,6 @@ static int ahd_linux_run_command(struct ahd_softc*, struct ahd_linux_device *, struct scsi_cmnd *); static void ahd_linux_setup_tag_info_global(char *p); -static aic_option_callback_t ahd_linux_setup_tag_info; -static aic_option_callback_t ahd_linux_setup_iocell_info; static int aic79xx_setup(char *c); static int ahd_linux_unit; @@ -907,6 +899,86 @@ ahd_linux_setup_tag_info(u_long arg, int instance, int targ, int32_t value) } } +static char * +ahd_parse_brace_option(char *opt_name, char *opt_arg, char *end, int depth, + void (*callback)(u_long, int, int, int32_t), + u_long callback_arg) +{ + char *tok_end; + char *tok_end2; + int i; + int instance; + int targ; + int done; + char tok_list[] = {'.', ',', '{', '}', '\0'}; + + /* All options use a ':' name/arg separator */ + if (*opt_arg != ':') + return (opt_arg); + opt_arg++; + instance = -1; + targ = -1; + done = FALSE; + /* + * Restore separator that may be in + * the middle of our option argument. + */ + tok_end = strchr(opt_arg, '\0'); + if (tok_end < end) + *tok_end = ','; + while (!done) { + switch (*opt_arg) { + case '{': + if (instance == -1) { + instance = 0; + } else { + if (depth > 1) { + if (targ == -1) + targ = 0; + } else { + printf("Malformed Option %s\n", + opt_name); + done = TRUE; + } + } + opt_arg++; + break; + case '}': + if (targ != -1) + targ = -1; + else if (instance != -1) + instance = -1; + opt_arg++; + break; + case ',': + case '.': + if (instance == -1) + done = TRUE; + else if (targ >= 0) + targ++; + else if (instance >= 0) + instance++; + opt_arg++; + break; + case '\0': + done = TRUE; + break; + default: + tok_end = end; + for (i = 0; tok_list[i]; i++) { + tok_end2 = strchr(opt_arg, tok_list[i]); + if ((tok_end2) && (tok_end2 < tok_end)) + tok_end = tok_end2; + } + callback(callback_arg, instance, targ, + simple_strtol(opt_arg, NULL, 0)); + opt_arg = tok_end; + break; + } + } + return (opt_arg); +} + /* * Handle Linux boot parameters. This routine allows for assigning a value * to a parameter with a ':' between the parameter and the value. @@ -964,18 +1036,18 @@ aic79xx_setup(char *s) if (strncmp(p, "global_tag_depth", n) == 0) { ahd_linux_setup_tag_info_global(p + n); } else if (strncmp(p, "tag_info", n) == 0) { - s = aic_parse_brace_option("tag_info", p + n, end, + s = ahd_parse_brace_option("tag_info", p + n, end, 2, ahd_linux_setup_tag_info, 0); } else if (strncmp(p, "slewrate", n) == 0) { - s = aic_parse_brace_option("slewrate", + s = ahd_parse_brace_option("slewrate", p + n, end, 1, ahd_linux_setup_iocell_info, AIC79XX_SLEWRATE_INDEX); } else if (strncmp(p, "precomp", n) == 0) { - s = aic_parse_brace_option("precomp", + s = ahd_parse_brace_option("precomp", p + n, end, 1, ahd_linux_setup_iocell_info, AIC79XX_PRECOMP_INDEX); } else if (strncmp(p, "amplitude", n) == 0) { - s = aic_parse_brace_option("amplitude", + s = ahd_parse_brace_option("amplitude", p + n, end, 1, ahd_linux_setup_iocell_info, AIC79XX_AMPLITUDE_INDEX); } else if (p[n] == ':') { diff --git a/drivers/scsi/aic7xxx/aic79xx_proc.c b/drivers/scsi/aic7xxx/aic79xx_proc.c index 32be1f55998..39a27840fce 100644 --- a/drivers/scsi/aic7xxx/aic79xx_proc.c +++ b/drivers/scsi/aic7xxx/aic79xx_proc.c @@ -53,6 +53,49 @@ static void ahd_dump_device_state(struct info_str *info, static int ahd_proc_write_seeprom(struct ahd_softc *ahd, char *buffer, int length); +/* + * Table of syncrates that don't follow the "divisible by 4" + * rule. This table will be expanded in future SCSI specs. + */ +static struct { + u_int period_factor; + u_int period; /* in 100ths of ns */ +} scsi_syncrates[] = { + { 0x08, 625 }, /* FAST-160 */ + { 0x09, 1250 }, /* FAST-80 */ + { 0x0a, 2500 }, /* FAST-40 40MHz */ + { 0x0b, 3030 }, /* FAST-40 33MHz */ + { 0x0c, 5000 } /* FAST-20 */ +}; + +/* + * Return the frequency in kHz corresponding to the given + * sync period factor. + */ +static u_int +ahd_calc_syncsrate(u_int period_factor) +{ + int i; + int num_syncrates; + + num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]); + /* See if the period is in the "exception" table */ + for (i = 0; i < num_syncrates; i++) { + + if (period_factor == scsi_syncrates[i].period_factor) { + /* Period in kHz */ + return (100000000 / scsi_syncrates[i].period); + } + } + + /* + * Wasn't in the table, so use the standard + * 4 times conversion. + */ + return (10000000 / (period_factor * 4 * 10)); +} + + static void copy_mem_info(struct info_str *info, char *data, int len) { @@ -109,7 +152,7 @@ ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo) speed = 3300; freq = 0; if (tinfo->offset != 0) { - freq = aic_calc_syncsrate(tinfo->period); + freq = ahd_calc_syncsrate(tinfo->period); speed = freq; } speed *= (0x01 << tinfo->width); diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 22434849de4..4096d523d08 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -125,12 +125,6 @@ static struct scsi_transport_template *ahc_linux_transport_template = NULL; -/* - * Include aiclib.c as part of our - * "module dependencies are hard" work around. - */ -#include "aiclib.c" - #include /* __setup */ #include /* For fetching system memory size */ #include /* For block_size() */ @@ -391,7 +385,6 @@ static int ahc_linux_run_command(struct ahc_softc*, struct ahc_linux_device *, struct scsi_cmnd *); static void ahc_linux_setup_tag_info_global(char *p); -static aic_option_callback_t ahc_linux_setup_tag_info; static int aic7xxx_setup(char *s); static int ahc_linux_unit; @@ -920,6 +913,86 @@ ahc_linux_setup_tag_info(u_long arg, int instance, int targ, int32_t value) } } +static char * +ahc_parse_brace_option(char *opt_name, char *opt_arg, char *end, int depth, + void (*callback)(u_long, int, int, int32_t), + u_long callback_arg) +{ + char *tok_end; + char *tok_end2; + int i; + int instance; + int targ; + int done; + char tok_list[] = {'.', ',', '{', '}', '\0'}; + + /* All options use a ':' name/arg separator */ + if (*opt_arg != ':') + return (opt_arg); + opt_arg++; + instance = -1; + targ = -1; + done = FALSE; + /* + * Restore separator that may be in + * the middle of our option argument. + */ + tok_end = strchr(opt_arg, '\0'); + if (tok_end < end) + *tok_end = ','; + while (!done) { + switch (*opt_arg) { + case '{': + if (instance == -1) { + instance = 0; + } else { + if (depth > 1) { + if (targ == -1) + targ = 0; + } else { + printf("Malformed Option %s\n", + opt_name); + done = TRUE; + } + } + opt_arg++; + break; + case '}': + if (targ != -1) + targ = -1; + else if (instance != -1) + instance = -1; + opt_arg++; + break; + case ',': + case '.': + if (instance == -1) + done = TRUE; + else if (targ >= 0) + targ++; + else if (instance >= 0) + instance++; + opt_arg++; + break; + case '\0': + done = TRUE; + break; + default: + tok_end = end; + for (i = 0; tok_list[i]; i++) { + tok_end2 = strchr(opt_arg, tok_list[i]); + if ((tok_end2) && (tok_end2 < tok_end)) + tok_end = tok_end2; + } + callback(callback_arg, instance, targ, + simple_strtol(opt_arg, NULL, 0)); + opt_arg = tok_end; + break; + } + } + return (opt_arg); +} + /* * Handle Linux boot parameters. This routine allows for assigning a value * to a parameter with a ':' between the parameter and the value. @@ -974,7 +1047,7 @@ aic7xxx_setup(char *s) if (strncmp(p, "global_tag_depth", n) == 0) { ahc_linux_setup_tag_info_global(p + n); } else if (strncmp(p, "tag_info", n) == 0) { - s = aic_parse_brace_option("tag_info", p + n, end, + s = ahc_parse_brace_option("tag_info", p + n, end, 2, ahc_linux_setup_tag_info, 0); } else if (p[n] == ':') { *(options[i].flag) = simple_strtoul(p + n + 1, NULL, 0); diff --git a/drivers/scsi/aic7xxx/aic7xxx_proc.c b/drivers/scsi/aic7xxx/aic7xxx_proc.c index 3802c91f0b0..04a3506cf34 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_proc.c +++ b/drivers/scsi/aic7xxx/aic7xxx_proc.c @@ -54,6 +54,49 @@ static void ahc_dump_device_state(struct info_str *info, static int ahc_proc_write_seeprom(struct ahc_softc *ahc, char *buffer, int length); +/* + * Table of syncrates that don't follow the "divisible by 4" + * rule. This table will be expanded in future SCSI specs. + */ +static struct { + u_int period_factor; + u_int period; /* in 100ths of ns */ +} scsi_syncrates[] = { + { 0x08, 625 }, /* FAST-160 */ + { 0x09, 1250 }, /* FAST-80 */ + { 0x0a, 2500 }, /* FAST-40 40MHz */ + { 0x0b, 3030 }, /* FAST-40 33MHz */ + { 0x0c, 5000 } /* FAST-20 */ +}; + +/* + * Return the frequency in kHz corresponding to the given + * sync period factor. + */ +static u_int +ahc_calc_syncsrate(u_int period_factor) +{ + int i; + int num_syncrates; + + num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]); + /* See if the period is in the "exception" table */ + for (i = 0; i < num_syncrates; i++) { + + if (period_factor == scsi_syncrates[i].period_factor) { + /* Period in kHz */ + return (100000000 / scsi_syncrates[i].period); + } + } + + /* + * Wasn't in the table, so use the standard + * 4 times conversion. + */ + return (10000000 / (period_factor * 4 * 10)); +} + + static void copy_mem_info(struct info_str *info, char *data, int len) { @@ -106,7 +149,7 @@ ahc_format_transinfo(struct info_str *info, struct ahc_transinfo *tinfo) speed = 3300; freq = 0; if (tinfo->offset != 0) { - freq = aic_calc_syncsrate(tinfo->period); + freq = ahc_calc_syncsrate(tinfo->period); speed = freq; } speed *= (0x01 << tinfo->width); diff --git a/drivers/scsi/aic7xxx/aiclib.c b/drivers/scsi/aic7xxx/aiclib.c index 4d44a921118..828ae3d9a51 100644 --- a/drivers/scsi/aic7xxx/aiclib.c +++ b/drivers/scsi/aic7xxx/aiclib.c @@ -32,124 +32,3 @@ #include "aiclib.h" - -/* - * Table of syncrates that don't follow the "divisible by 4" - * rule. This table will be expanded in future SCSI specs. - */ -static struct { - u_int period_factor; - u_int period; /* in 100ths of ns */ -} scsi_syncrates[] = { - { 0x08, 625 }, /* FAST-160 */ - { 0x09, 1250 }, /* FAST-80 */ - { 0x0a, 2500 }, /* FAST-40 40MHz */ - { 0x0b, 3030 }, /* FAST-40 33MHz */ - { 0x0c, 5000 } /* FAST-20 */ -}; - -/* - * Return the frequency in kHz corresponding to the given - * sync period factor. - */ -u_int -aic_calc_syncsrate(u_int period_factor) -{ - int i; - int num_syncrates; - - num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]); - /* See if the period is in the "exception" table */ - for (i = 0; i < num_syncrates; i++) { - - if (period_factor == scsi_syncrates[i].period_factor) { - /* Period in kHz */ - return (100000000 / scsi_syncrates[i].period); - } - } - - /* - * Wasn't in the table, so use the standard - * 4 times conversion. - */ - return (10000000 / (period_factor * 4 * 10)); -} - -char * -aic_parse_brace_option(char *opt_name, char *opt_arg, char *end, int depth, - aic_option_callback_t *callback, u_long callback_arg) -{ - char *tok_end; - char *tok_end2; - int i; - int instance; - int targ; - int done; - char tok_list[] = {'.', ',', '{', '}', '\0'}; - - /* All options use a ':' name/arg separator */ - if (*opt_arg != ':') - return (opt_arg); - opt_arg++; - instance = -1; - targ = -1; - done = FALSE; - /* - * Restore separator that may be in - * the middle of our option argument. - */ - tok_end = strchr(opt_arg, '\0'); - if (tok_end < end) - *tok_end = ','; - while (!done) { - switch (*opt_arg) { - case '{': - if (instance == -1) { - instance = 0; - } else { - if (depth > 1) { - if (targ == -1) - targ = 0; - } else { - printf("Malformed Option %s\n", - opt_name); - done = TRUE; - } - } - opt_arg++; - break; - case '}': - if (targ != -1) - targ = -1; - else if (instance != -1) - instance = -1; - opt_arg++; - break; - case ',': - case '.': - if (instance == -1) - done = TRUE; - else if (targ >= 0) - targ++; - else if (instance >= 0) - instance++; - opt_arg++; - break; - case '\0': - done = TRUE; - break; - default: - tok_end = end; - for (i = 0; tok_list[i]; i++) { - tok_end2 = strchr(opt_arg, tok_list[i]); - if ((tok_end2) && (tok_end2 < tok_end)) - tok_end = tok_end2; - } - callback(callback_arg, instance, targ, - simple_strtol(opt_arg, NULL, 0)); - opt_arg = tok_end; - break; - } - } - return (opt_arg); -} diff --git a/drivers/scsi/aic7xxx/aiclib.h b/drivers/scsi/aic7xxx/aiclib.h index e7d94cbaf2a..3bfbf0fe1ec 100644 --- a/drivers/scsi/aic7xxx/aiclib.h +++ b/drivers/scsi/aic7xxx/aiclib.h @@ -141,28 +141,6 @@ aic_sector_div(sector_t capacity, int heads, int sectors) return (int)capacity; } -/**************************** Module Library Hack *****************************/ -/* - * What we'd like to do is have a single "scsi library" module that both the - * aic7xxx and aic79xx drivers could load and depend on. A cursory examination - * of implementing module dependencies in Linux (handling the install and - * initrd cases) does not look promissing. For now, we just duplicate this - * code in both drivers using a simple symbol renaming scheme that hides this - * hack from the drivers. - */ -#define AIC_LIB_ENTRY_CONCAT(x, prefix) prefix ## x -#define AIC_LIB_ENTRY_EXPAND(x, prefix) AIC_LIB_ENTRY_CONCAT(x, prefix) -#define AIC_LIB_ENTRY(x) AIC_LIB_ENTRY_EXPAND(x, AIC_LIB_PREFIX) - -#define aic_calc_syncsrate AIC_LIB_ENTRY(_calc_syncrate) - -u_int aic_calc_syncsrate(u_int /*period_factor*/); - -typedef void aic_option_callback_t(u_long, int, int, int32_t); -char * aic_parse_brace_option(char *opt_name, char *opt_arg, - char *end, int depth, - aic_option_callback_t *, u_long); - static __inline uint32_t scsi_4btoul(uint8_t *bytes) { -- cgit v1.2.3-18-g5258 From 69218ee5186aded6c78e12e083e073d000ff2e9b Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 18 Aug 2005 16:26:15 +0200 Subject: [SCSI] fusion: extended config header support Acked by: Moore, Eric Dean Signed-off-by: James Bottomley --- drivers/message/fusion/mptbase.c | 90 +++++++++++++++++++++++++++------------ drivers/message/fusion/mptbase.h | 5 ++- drivers/message/fusion/mptctl.c | 12 +++--- drivers/message/fusion/mptscsih.c | 18 ++++---- 4 files changed, 81 insertions(+), 44 deletions(-) (limited to 'drivers') diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index ffbe6f4720e..28420276680 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c @@ -491,10 +491,21 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply) pCfg->status = status; if (status == MPI_IOCSTATUS_SUCCESS) { - pCfg->hdr->PageVersion = pReply->Header.PageVersion; - pCfg->hdr->PageLength = pReply->Header.PageLength; - pCfg->hdr->PageNumber = pReply->Header.PageNumber; - pCfg->hdr->PageType = pReply->Header.PageType; + if ((pReply->Header.PageType & + MPI_CONFIG_PAGETYPE_MASK) == + MPI_CONFIG_PAGETYPE_EXTENDED) { + pCfg->cfghdr.ehdr->ExtPageLength = + le16_to_cpu(pReply->ExtPageLength); + pCfg->cfghdr.ehdr->ExtPageType = + pReply->ExtPageType; + } + pCfg->cfghdr.hdr->PageVersion = pReply->Header.PageVersion; + + /* If this is a regular header, save PageLength. */ + /* LMP Do this better so not using a reserved field! */ + pCfg->cfghdr.hdr->PageLength = pReply->Header.PageLength; + pCfg->cfghdr.hdr->PageNumber = pReply->Header.PageNumber; + pCfg->cfghdr.hdr->PageType = pReply->Header.PageType; } } @@ -3819,7 +3830,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc) hdr.PageLength = 0; hdr.PageNumber = 0; hdr.PageType = MPI_CONFIG_PAGETYPE_LAN; - cfg.hdr = &hdr; + cfg.cfghdr.hdr = &hdr; cfg.physAddr = -1; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; cfg.dir = 0; @@ -3863,7 +3874,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc) hdr.PageLength = 0; hdr.PageNumber = 1; hdr.PageType = MPI_CONFIG_PAGETYPE_LAN; - cfg.hdr = &hdr; + cfg.cfghdr.hdr = &hdr; cfg.physAddr = -1; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; cfg.dir = 0; @@ -3930,7 +3941,7 @@ GetFcPortPage0(MPT_ADAPTER *ioc, int portnum) hdr.PageLength = 0; hdr.PageNumber = 0; hdr.PageType = MPI_CONFIG_PAGETYPE_FC_PORT; - cfg.hdr = &hdr; + cfg.cfghdr.hdr = &hdr; cfg.physAddr = -1; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; cfg.dir = 0; @@ -4012,7 +4023,7 @@ GetIoUnitPage2(MPT_ADAPTER *ioc) hdr.PageLength = 0; hdr.PageNumber = 2; hdr.PageType = MPI_CONFIG_PAGETYPE_IO_UNIT; - cfg.hdr = &hdr; + cfg.cfghdr.hdr = &hdr; cfg.physAddr = -1; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; cfg.dir = 0; @@ -4102,7 +4113,7 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum) header.PageLength = 0; header.PageNumber = 0; header.PageType = MPI_CONFIG_PAGETYPE_SCSI_PORT; - cfg.hdr = &header; + cfg.cfghdr.hdr = &header; cfg.physAddr = -1; cfg.pageAddr = portnum; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; @@ -4168,7 +4179,7 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum) header.PageLength = 0; header.PageNumber = 2; header.PageType = MPI_CONFIG_PAGETYPE_SCSI_PORT; - cfg.hdr = &header; + cfg.cfghdr.hdr = &header; cfg.physAddr = -1; cfg.pageAddr = portnum; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; @@ -4236,7 +4247,7 @@ mpt_readScsiDevicePageHeaders(MPT_ADAPTER *ioc, int portnum) header.PageLength = 0; header.PageNumber = 1; header.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE; - cfg.hdr = &header; + cfg.cfghdr.hdr = &header; cfg.physAddr = -1; cfg.pageAddr = portnum; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; @@ -4245,8 +4256,8 @@ mpt_readScsiDevicePageHeaders(MPT_ADAPTER *ioc, int portnum) if (mpt_config(ioc, &cfg) != 0) return -EFAULT; - ioc->spi_data.sdp1version = cfg.hdr->PageVersion; - ioc->spi_data.sdp1length = cfg.hdr->PageLength; + ioc->spi_data.sdp1version = cfg.cfghdr.hdr->PageVersion; + ioc->spi_data.sdp1length = cfg.cfghdr.hdr->PageLength; header.PageVersion = 0; header.PageLength = 0; @@ -4255,8 +4266,8 @@ mpt_readScsiDevicePageHeaders(MPT_ADAPTER *ioc, int portnum) if (mpt_config(ioc, &cfg) != 0) return -EFAULT; - ioc->spi_data.sdp0version = cfg.hdr->PageVersion; - ioc->spi_data.sdp0length = cfg.hdr->PageLength; + ioc->spi_data.sdp0version = cfg.cfghdr.hdr->PageVersion; + ioc->spi_data.sdp0length = cfg.cfghdr.hdr->PageLength; dcprintk((MYIOC_s_INFO_FMT "Headers: 0: version %d length %d\n", ioc->name, ioc->spi_data.sdp0version, ioc->spi_data.sdp0length)); @@ -4298,7 +4309,7 @@ mpt_findImVolumes(MPT_ADAPTER *ioc) header.PageLength = 0; header.PageNumber = 2; header.PageType = MPI_CONFIG_PAGETYPE_IOC; - cfg.hdr = &header; + cfg.cfghdr.hdr = &header; cfg.physAddr = -1; cfg.pageAddr = 0; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; @@ -4394,7 +4405,7 @@ mpt_read_ioc_pg_3(MPT_ADAPTER *ioc) header.PageLength = 0; header.PageNumber = 3; header.PageType = MPI_CONFIG_PAGETYPE_IOC; - cfg.hdr = &header; + cfg.cfghdr.hdr = &header; cfg.physAddr = -1; cfg.pageAddr = 0; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; @@ -4446,7 +4457,7 @@ mpt_read_ioc_pg_4(MPT_ADAPTER *ioc) header.PageLength = 0; header.PageNumber = 4; header.PageType = MPI_CONFIG_PAGETYPE_IOC; - cfg.hdr = &header; + cfg.cfghdr.hdr = &header; cfg.physAddr = -1; cfg.pageAddr = 0; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; @@ -4498,7 +4509,7 @@ mpt_read_ioc_pg_1(MPT_ADAPTER *ioc) header.PageLength = 0; header.PageNumber = 1; header.PageType = MPI_CONFIG_PAGETYPE_IOC; - cfg.hdr = &header; + cfg.cfghdr.hdr = &header; cfg.physAddr = -1; cfg.pageAddr = 0; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; @@ -4647,10 +4658,11 @@ int mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg) { Config_t *pReq; + ConfigExtendedPageHeader_t *pExtHdr = NULL; MPT_FRAME_HDR *mf; unsigned long flags; int ii, rc; - u32 flagsLength; + int flagsLength; int in_isr; /* Prevent calling wait_event() (below), if caller happens @@ -4675,16 +4687,30 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg) pReq->Reserved = 0; pReq->ChainOffset = 0; pReq->Function = MPI_FUNCTION_CONFIG; + + /* Assume page type is not extended and clear "reserved" fields. */ pReq->ExtPageLength = 0; pReq->ExtPageType = 0; pReq->MsgFlags = 0; + for (ii=0; ii < 8; ii++) pReq->Reserved2[ii] = 0; - pReq->Header.PageVersion = pCfg->hdr->PageVersion; - pReq->Header.PageLength = pCfg->hdr->PageLength; - pReq->Header.PageNumber = pCfg->hdr->PageNumber; - pReq->Header.PageType = (pCfg->hdr->PageType & MPI_CONFIG_PAGETYPE_MASK); + pReq->Header.PageVersion = pCfg->cfghdr.hdr->PageVersion; + pReq->Header.PageLength = pCfg->cfghdr.hdr->PageLength; + pReq->Header.PageNumber = pCfg->cfghdr.hdr->PageNumber; + pReq->Header.PageType = (pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK); + + if ((pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK) == MPI_CONFIG_PAGETYPE_EXTENDED) { + pExtHdr = (ConfigExtendedPageHeader_t *)pCfg->cfghdr.ehdr; + pReq->ExtPageLength = cpu_to_le16(pExtHdr->ExtPageLength); + pReq->ExtPageType = pExtHdr->ExtPageType; + pReq->Header.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; + + /* Page Length must be treated as a reserved field for the extended header. */ + pReq->Header.PageLength = 0; + } + pReq->PageAddress = cpu_to_le32(pCfg->pageAddr); /* Add a SGE to the config request. @@ -4694,12 +4720,20 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg) else flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ; - flagsLength |= pCfg->hdr->PageLength * 4; + if ((pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK) == MPI_CONFIG_PAGETYPE_EXTENDED) { + flagsLength |= pExtHdr->ExtPageLength * 4; - mpt_add_sge((char *)&pReq->PageBufferSGE, flagsLength, pCfg->physAddr); + dcprintk((MYIOC_s_INFO_FMT "Sending Config request type %d, page %d and action %d\n", + ioc->name, pReq->ExtPageType, pReq->Header.PageNumber, pReq->Action)); + } + else { + flagsLength |= pCfg->cfghdr.hdr->PageLength * 4; - dcprintk((MYIOC_s_INFO_FMT "Sending Config request type %d, page %d and action %d\n", - ioc->name, pReq->Header.PageType, pReq->Header.PageNumber, pReq->Action)); + dcprintk((MYIOC_s_INFO_FMT "Sending Config request type %d, page %d and action %d\n", + ioc->name, pReq->Header.PageType, pReq->Header.PageNumber, pReq->Action)); + } + + mpt_add_sge((char *)&pReq->PageBufferSGE, flagsLength, pCfg->physAddr); /* Append pCfg pointer to end of mf */ diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h index 848fb236b17..f4827d92373 100644 --- a/drivers/message/fusion/mptbase.h +++ b/drivers/message/fusion/mptbase.h @@ -915,7 +915,10 @@ struct scsi_cmnd; typedef struct _x_config_parms { struct list_head linkage; /* linked list */ struct timer_list timer; /* timer function for this request */ - ConfigPageHeader_t *hdr; + union { + ConfigExtendedPageHeader_t *ehdr; + ConfigPageHeader_t *hdr; + } cfghdr; dma_addr_t physAddr; int wait_done; /* wait for this request */ u32 pageAddr; /* properly formatted */ diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index 05ea5944c48..e63a3fd6b70 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c @@ -2324,7 +2324,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) hdr.PageLength = 0; hdr.PageNumber = 0; hdr.PageType = MPI_CONFIG_PAGETYPE_MANUFACTURING; - cfg.hdr = &hdr; + cfg.cfghdr.hdr = &hdr; cfg.physAddr = -1; cfg.pageAddr = 0; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; @@ -2333,7 +2333,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) strncpy(karg.serial_number, " ", 24); if (mpt_config(ioc, &cfg) == 0) { - if (cfg.hdr->PageLength > 0) { + if (cfg.cfghdr.hdr->PageLength > 0) { /* Issue the second config page request */ cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; @@ -2479,7 +2479,7 @@ mptctl_hp_targetinfo(unsigned long arg) hdr.PageNumber = 0; hdr.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE; - cfg.hdr = &hdr; + cfg.cfghdr.hdr = &hdr; cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; cfg.dir = 0; cfg.timeout = 0; @@ -2527,15 +2527,15 @@ mptctl_hp_targetinfo(unsigned long arg) hdr.PageNumber = 3; hdr.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE; - cfg.hdr = &hdr; + cfg.cfghdr.hdr = &hdr; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; cfg.dir = 0; cfg.timeout = 0; cfg.physAddr = -1; - if ((mpt_config(ioc, &cfg) == 0) && (cfg.hdr->PageLength > 0)) { + if ((mpt_config(ioc, &cfg) == 0) && (cfg.cfghdr.hdr->PageLength > 0)) { /* Issue the second config page request */ cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; - data_sz = (int) cfg.hdr->PageLength * 4; + data_sz = (int) cfg.cfghdr.hdr->PageLength * 4; pg3_alloc = (SCSIDevicePage3_t *) pci_alloc_consistent( ioc->pcidev, data_sz, &page_dma); if (pg3_alloc) { diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index b9d4f78725b..b774f45dfde 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -3955,7 +3955,7 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum) header1.PageLength = ioc->spi_data.sdp1length; header1.PageNumber = 1; header1.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE; - cfg.hdr = &header1; + cfg.cfghdr.hdr = &header1; cfg.physAddr = cfg1_dma_addr; cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT; cfg.dir = 1; @@ -4353,7 +4353,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) /* Prep cfg structure */ cfg.pageAddr = (bus<<8) | id; - cfg.hdr = NULL; + cfg.cfghdr.hdr = NULL; /* Prep SDP0 header */ @@ -4399,7 +4399,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) pcfg1Data = (SCSIDevicePage1_t *) (pDvBuf + sz); cfg1_dma_addr = dvbuf_dma + sz; - /* Skip this ID? Set cfg.hdr to force config page write + /* Skip this ID? Set cfg.cfghdr.hdr to force config page write */ { ScsiCfgData *pspi_data = &hd->ioc->spi_data; @@ -4417,7 +4417,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) dv.cmd = MPT_SET_MAX; mptscsih_dv_parms(hd, &dv, (void *)pcfg1Data); - cfg.hdr = &header1; + cfg.cfghdr.hdr = &header1; /* Save the final negotiated settings to * SCSI device page 1. @@ -4483,7 +4483,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) dv.cmd = MPT_SET_MIN; mptscsih_dv_parms(hd, &dv, (void *)pcfg1Data); - cfg.hdr = &header1; + cfg.cfghdr.hdr = &header1; cfg.physAddr = cfg1_dma_addr; cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT; cfg.dir = 1; @@ -4637,7 +4637,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) u32 sdp0_info; u32 sdp0_nego; - cfg.hdr = &header0; + cfg.cfghdr.hdr = &header0; cfg.physAddr = cfg0_dma_addr; cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; cfg.dir = 0; @@ -4722,7 +4722,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) * 4) release * 5) update nego parms to target struct */ - cfg.hdr = &header1; + cfg.cfghdr.hdr = &header1; cfg.physAddr = cfg1_dma_addr; cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT; cfg.dir = 1; @@ -5121,7 +5121,7 @@ target_done: /* Set if cfg1_dma_addr contents is valid */ - if ((cfg.hdr != NULL) && (retcode == 0)){ + if ((cfg.cfghdr.hdr != NULL) && (retcode == 0)){ /* If disk, not U320, disable QAS */ if ((inq0 == 0) && (dv.now.factor > MPT_ULTRA320)) { @@ -5137,7 +5137,7 @@ target_done: * skip save of the final negotiated settings to * SCSI device page 1. * - cfg.hdr = &header1; + cfg.cfghdr.hdr = &header1; cfg.physAddr = cfg1_dma_addr; cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT; cfg.dir = 1; -- cgit v1.2.3-18-g5258 From ccf3b7bd26b242b39d54148ea2117295721681d3 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 18 Aug 2005 16:24:26 +0200 Subject: [SCSI] fusion: update LSI headers Acked by: Moore, Eric Dean Signed-off-by: James Bottomley --- drivers/message/fusion/lsi/mpi.h | 19 ++- drivers/message/fusion/lsi/mpi_cnfg.h | 85 +++++++++--- drivers/message/fusion/lsi/mpi_history.txt | 67 +++++++--- drivers/message/fusion/lsi/mpi_init.h | 203 ++++++++++++++++++++++++++++- drivers/message/fusion/lsi/mpi_ioc.h | 11 +- drivers/message/fusion/lsi/mpi_targ.h | 74 ++++++++++- 6 files changed, 415 insertions(+), 44 deletions(-) (limited to 'drivers') diff --git a/drivers/message/fusion/lsi/mpi.h b/drivers/message/fusion/lsi/mpi.h index 9f98334e507..b61e3d17507 100644 --- a/drivers/message/fusion/lsi/mpi.h +++ b/drivers/message/fusion/lsi/mpi.h @@ -6,7 +6,7 @@ * Title: MPI Message independent structures and definitions * Creation Date: July 27, 2000 * - * mpi.h Version: 01.05.07 + * mpi.h Version: 01.05.08 * * Version History * --------------- @@ -71,6 +71,9 @@ * 03-11-05 01.05.07 Removed function codes for SCSI IO 32 and * TargetAssistExtended requests. * Removed EEDP IOCStatus codes. + * 06-24-05 01.05.08 Added function codes for SCSI IO 32 and + * TargetAssistExtended requests. + * Added EEDP IOCStatus codes. * -------------------------------------------------------------------------- */ @@ -101,7 +104,7 @@ /* Note: The major versions of 0xe0 through 0xff are reserved */ /* versioning for this MPI header set */ -#define MPI_HEADER_VERSION_UNIT (0x09) +#define MPI_HEADER_VERSION_UNIT (0x0A) #define MPI_HEADER_VERSION_DEV (0x00) #define MPI_HEADER_VERSION_UNIT_MASK (0xFF00) #define MPI_HEADER_VERSION_UNIT_SHIFT (8) @@ -292,10 +295,13 @@ #define MPI_FUNCTION_DIAG_BUFFER_POST (0x1D) #define MPI_FUNCTION_DIAG_RELEASE (0x1E) +#define MPI_FUNCTION_SCSI_IO_32 (0x1F) + #define MPI_FUNCTION_LAN_SEND (0x20) #define MPI_FUNCTION_LAN_RECEIVE (0x21) #define MPI_FUNCTION_LAN_RESET (0x22) +#define MPI_FUNCTION_TARGET_ASSIST_EXTENDED (0x23) #define MPI_FUNCTION_TARGET_CMD_BUF_BASE_POST (0x24) #define MPI_FUNCTION_TARGET_CMD_BUF_LIST_POST (0x25) @@ -680,6 +686,15 @@ typedef struct _MSG_DEFAULT_REPLY #define MPI_IOCSTATUS_SCSI_IOC_TERMINATED (0x004B) #define MPI_IOCSTATUS_SCSI_EXT_TERMINATED (0x004C) +/****************************************************************************/ +/* For use by SCSI Initiator and SCSI Target end-to-end data protection */ +/****************************************************************************/ + +#define MPI_IOCSTATUS_EEDP_GUARD_ERROR (0x004D) +#define MPI_IOCSTATUS_EEDP_REF_TAG_ERROR (0x004E) +#define MPI_IOCSTATUS_EEDP_APP_TAG_ERROR (0x004F) + + /****************************************************************************/ /* SCSI Target values */ /****************************************************************************/ diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h index 15b12b06799..d8339896f73 100644 --- a/drivers/message/fusion/lsi/mpi_cnfg.h +++ b/drivers/message/fusion/lsi/mpi_cnfg.h @@ -6,7 +6,7 @@ * Title: MPI Config message, structures, and Pages * Creation Date: July 27, 2000 * - * mpi_cnfg.h Version: 01.05.08 + * mpi_cnfg.h Version: 01.05.09 * * Version History * --------------- @@ -232,6 +232,23 @@ * New physical mapping mode in SAS IO Unit Page 2. * Added CONFIG_PAGE_SAS_ENCLOSURE_0. * Added Slot and Enclosure fields to SAS Device Page 0. + * 06-24-05 01.05.09 Added EEDP defines to IOC Page 1. + * Added more RAID type defines to IOC Page 2. + * Added Port Enable Delay settings to BIOS Page 1. + * Added Bad Block Table Full define to RAID Volume Page 0. + * Added Previous State defines to RAID Physical Disk + * Page 0. + * Added Max Sata Targets define for DiscoveryStatus field + * of SAS IO Unit Page 0. + * Added Device Self Test to Control Flags of SAS IO Unit + * Page 1. + * Added Direct Attach Starting Slot Number define for SAS + * IO Unit Page 2. + * Added new fields in SAS Device Page 2 for enclosure + * mapping. + * Added OwnerDevHandle and Flags field to SAS PHY Page 0. + * Added IOC GPIO Flags define to SAS Enclosure Page 0. + * Fixed the value for MPI_SAS_IOUNIT1_CONTROL_DEV_SATA_SUPPORT. * -------------------------------------------------------------------------- */ @@ -477,6 +494,7 @@ typedef struct _MSG_CONFIG_REPLY #define MPI_MANUFACTPAGE_DEVICEID_FC929X (0x0626) #define MPI_MANUFACTPAGE_DEVICEID_FC939X (0x0642) #define MPI_MANUFACTPAGE_DEVICEID_FC949X (0x0640) +#define MPI_MANUFACTPAGE_DEVICEID_FC949ES (0x0646) /* SCSI */ #define MPI_MANUFACTPAGE_DEVID_53C1030 (0x0030) #define MPI_MANUFACTPAGE_DEVID_53C1030ZC (0x0031) @@ -769,9 +787,13 @@ typedef struct _CONFIG_PAGE_IOC_1 } CONFIG_PAGE_IOC_1, MPI_POINTER PTR_CONFIG_PAGE_IOC_1, IOCPage1_t, MPI_POINTER pIOCPage1_t; -#define MPI_IOCPAGE1_PAGEVERSION (0x02) +#define MPI_IOCPAGE1_PAGEVERSION (0x03) /* defines for the Flags field */ +#define MPI_IOCPAGE1_EEDP_MODE_MASK (0x07000000) +#define MPI_IOCPAGE1_EEDP_MODE_OFF (0x00000000) +#define MPI_IOCPAGE1_EEDP_MODE_T10 (0x01000000) +#define MPI_IOCPAGE1_EEDP_MODE_LSI_1 (0x02000000) #define MPI_IOCPAGE1_INITIATOR_CONTEXT_REPLY_DISABLE (0x00000010) #define MPI_IOCPAGE1_REPLY_COALESCING (0x00000001) @@ -795,6 +817,11 @@ typedef struct _CONFIG_PAGE_IOC_2_RAID_VOL #define MPI_RAID_VOL_TYPE_IS (0x00) #define MPI_RAID_VOL_TYPE_IME (0x01) #define MPI_RAID_VOL_TYPE_IM (0x02) +#define MPI_RAID_VOL_TYPE_RAID_5 (0x03) +#define MPI_RAID_VOL_TYPE_RAID_6 (0x04) +#define MPI_RAID_VOL_TYPE_RAID_10 (0x05) +#define MPI_RAID_VOL_TYPE_RAID_50 (0x06) +#define MPI_RAID_VOL_TYPE_UNKNOWN (0xFF) /* IOC Page 2 Volume Flags values */ @@ -820,13 +847,17 @@ typedef struct _CONFIG_PAGE_IOC_2 } CONFIG_PAGE_IOC_2, MPI_POINTER PTR_CONFIG_PAGE_IOC_2, IOCPage2_t, MPI_POINTER pIOCPage2_t; -#define MPI_IOCPAGE2_PAGEVERSION (0x02) +#define MPI_IOCPAGE2_PAGEVERSION (0x03) /* IOC Page 2 Capabilities flags */ #define MPI_IOCPAGE2_CAP_FLAGS_IS_SUPPORT (0x00000001) #define MPI_IOCPAGE2_CAP_FLAGS_IME_SUPPORT (0x00000002) #define MPI_IOCPAGE2_CAP_FLAGS_IM_SUPPORT (0x00000004) +#define MPI_IOCPAGE2_CAP_FLAGS_RAID_5_SUPPORT (0x00000008) +#define MPI_IOCPAGE2_CAP_FLAGS_RAID_6_SUPPORT (0x00000010) +#define MPI_IOCPAGE2_CAP_FLAGS_RAID_10_SUPPORT (0x00000020) +#define MPI_IOCPAGE2_CAP_FLAGS_RAID_50_SUPPORT (0x00000040) #define MPI_IOCPAGE2_CAP_FLAGS_SES_SUPPORT (0x20000000) #define MPI_IOCPAGE2_CAP_FLAGS_SAFTE_SUPPORT (0x40000000) #define MPI_IOCPAGE2_CAP_FLAGS_CROSS_CHANNEL_SUPPORT (0x80000000) @@ -945,7 +976,7 @@ typedef struct _CONFIG_PAGE_BIOS_1 } CONFIG_PAGE_BIOS_1, MPI_POINTER PTR_CONFIG_PAGE_BIOS_1, BIOSPage1_t, MPI_POINTER pBIOSPage1_t; -#define MPI_BIOSPAGE1_PAGEVERSION (0x01) +#define MPI_BIOSPAGE1_PAGEVERSION (0x02) /* values for the BiosOptions field */ #define MPI_BIOSPAGE1_OPTIONS_SPI_ENABLE (0x00000400) @@ -954,6 +985,8 @@ typedef struct _CONFIG_PAGE_BIOS_1 #define MPI_BIOSPAGE1_OPTIONS_DISABLE_BIOS (0x00000001) /* values for the IOCSettings field */ +#define MPI_BIOSPAGE1_IOCSET_MASK_PORT_ENABLE_DELAY (0x00F00000) +#define MPI_BIOSPAGE1_IOCSET_SHIFT_PORT_ENABLE_DELAY (20) #define MPI_BIOSPAGE1_IOCSET_MASK_BOOT_PREFERENCE (0x00030000) #define MPI_BIOSPAGE1_IOCSET_ENCLOSURE_SLOT_BOOT (0x00000000) #define MPI_BIOSPAGE1_IOCSET_SAS_ADDRESS_BOOT (0x00010000) @@ -1167,6 +1200,7 @@ typedef struct _CONFIG_PAGE_BIOS_2 #define MPI_BIOSPAGE2_FORM_PCI_SLOT_NUMBER (0x03) #define MPI_BIOSPAGE2_FORM_FC_WWN (0x04) #define MPI_BIOSPAGE2_FORM_SAS_WWN (0x05) +#define MPI_BIOSPAGE2_FORM_ENCLOSURE_SLOT (0x06) /**************************************************************************** @@ -1957,11 +1991,11 @@ typedef struct _RAID_VOL0_STATUS RaidVol0Status_t, MPI_POINTER pRaidVol0Status_t; /* RAID Volume Page 0 VolumeStatus defines */ - #define MPI_RAIDVOL0_STATUS_FLAG_ENABLED (0x01) #define MPI_RAIDVOL0_STATUS_FLAG_QUIESCED (0x02) #define MPI_RAIDVOL0_STATUS_FLAG_RESYNC_IN_PROGRESS (0x04) #define MPI_RAIDVOL0_STATUS_FLAG_VOLUME_INACTIVE (0x08) +#define MPI_RAIDVOL0_STATUS_FLAG_BAD_BLOCK_TABLE_FULL (0x10) #define MPI_RAIDVOL0_STATUS_STATE_OPTIMAL (0x00) #define MPI_RAIDVOL0_STATUS_STATE_DEGRADED (0x01) @@ -2025,7 +2059,7 @@ typedef struct _CONFIG_PAGE_RAID_VOL_0 } CONFIG_PAGE_RAID_VOL_0, MPI_POINTER PTR_CONFIG_PAGE_RAID_VOL_0, RaidVolumePage0_t, MPI_POINTER pRaidVolumePage0_t; -#define MPI_RAIDVOLPAGE0_PAGEVERSION (0x04) +#define MPI_RAIDVOLPAGE0_PAGEVERSION (0x05) /* values for RAID Volume Page 0 InactiveStatus field */ #define MPI_RAIDVOLPAGE0_UNKNOWN_INACTIVE (0x00) @@ -2104,6 +2138,8 @@ typedef struct _RAID_PHYS_DISK0_STATUS #define MPI_PHYSDISK0_STATUS_FLAG_OUT_OF_SYNC (0x01) #define MPI_PHYSDISK0_STATUS_FLAG_QUIESCED (0x02) #define MPI_PHYSDISK0_STATUS_FLAG_INACTIVE_VOLUME (0x04) +#define MPI_PHYSDISK0_STATUS_FLAG_OPTIMAL_PREVIOUS (0x00) +#define MPI_PHYSDISK0_STATUS_FLAG_NOT_OPTIMAL_PREVIOUS (0x08) #define MPI_PHYSDISK0_STATUS_ONLINE (0x00) #define MPI_PHYSDISK0_STATUS_MISSING (0x01) @@ -2132,7 +2168,7 @@ typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_0 } CONFIG_PAGE_RAID_PHYS_DISK_0, MPI_POINTER PTR_CONFIG_PAGE_RAID_PHYS_DISK_0, RaidPhysDiskPage0_t, MPI_POINTER pRaidPhysDiskPage0_t; -#define MPI_RAIDPHYSDISKPAGE0_PAGEVERSION (0x01) +#define MPI_RAIDPHYSDISKPAGE0_PAGEVERSION (0x02) typedef struct _RAID_PHYS_DISK1_PATH @@ -2263,7 +2299,7 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0 } CONFIG_PAGE_SAS_IO_UNIT_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_0, SasIOUnitPage0_t, MPI_POINTER pSasIOUnitPage0_t; -#define MPI_SASIOUNITPAGE0_PAGEVERSION (0x02) +#define MPI_SASIOUNITPAGE0_PAGEVERSION (0x03) /* values for SAS IO Unit Page 0 PortFlags */ #define MPI_SAS_IOUNIT0_PORT_FLAGS_DISCOVERY_IN_PROGRESS (0x08) @@ -2299,6 +2335,7 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0 #define MPI_SAS_IOUNIT0_DS_SUBTRACTIVE_LINK (0x00000200) #define MPI_SAS_IOUNIT0_DS_TABLE_LINK (0x00000400) #define MPI_SAS_IOUNIT0_DS_UNSUPPORTED_DEVICE (0x00000800) +#define MPI_SAS_IOUNIT0_DS_MAX_SATA_TARGETS (0x00001000) typedef struct _MPI_SAS_IO_UNIT1_PHY_DATA @@ -2336,6 +2373,7 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_1 #define MPI_SASIOUNITPAGE1_PAGEVERSION (0x04) /* values for SAS IO Unit Page 1 ControlFlags */ +#define MPI_SAS_IOUNIT1_CONTROL_DEVICE_SELF_TEST (0x8000) #define MPI_SAS_IOUNIT1_CONTROL_SATA_3_0_MAX (0x4000) #define MPI_SAS_IOUNIT1_CONTROL_SATA_1_5_MAX (0x2000) #define MPI_SAS_IOUNIT1_CONTROL_SATA_SW_PRESERVE (0x1000) @@ -2345,9 +2383,8 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_1 #define MPI_SAS_IOUNIT1_CONTROL_SHIFT_DEV_SUPPORT (9) #define MPI_SAS_IOUNIT1_CONTROL_DEV_SUPPORT_BOTH (0x00) #define MPI_SAS_IOUNIT1_CONTROL_DEV_SAS_SUPPORT (0x01) -#define MPI_SAS_IOUNIT1_CONTROL_DEV_SATA_SUPPORT (0x10) +#define MPI_SAS_IOUNIT1_CONTROL_DEV_SATA_SUPPORT (0x02) -#define MPI_SAS_IOUNIT1_CONTROL_AUTO_PORT_SAME_SAS_ADDR (0x0100) #define MPI_SAS_IOUNIT1_CONTROL_SATA_48BIT_LBA_REQUIRED (0x0080) #define MPI_SAS_IOUNIT1_CONTROL_SATA_SMART_REQUIRED (0x0040) #define MPI_SAS_IOUNIT1_CONTROL_SATA_NCQ_REQUIRED (0x0020) @@ -2390,7 +2427,7 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_2 } CONFIG_PAGE_SAS_IO_UNIT_2, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_2, SasIOUnitPage2_t, MPI_POINTER pSasIOUnitPage2_t; -#define MPI_SASIOUNITPAGE2_PAGEVERSION (0x03) +#define MPI_SASIOUNITPAGE2_PAGEVERSION (0x04) /* values for SAS IO Unit Page 2 Status field */ #define MPI_SAS_IOUNIT2_STATUS_DISABLED_PERSISTENT_MAPPINGS (0x02) @@ -2406,6 +2443,7 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_2 #define MPI_SAS_IOUNIT2_FLAGS_ENCLOSURE_SLOT_PHYS_MAP (0x02) #define MPI_SAS_IOUNIT2_FLAGS_RESERVE_ID_0_FOR_BOOT (0x10) +#define MPI_SAS_IOUNIT2_FLAGS_DA_STARTING_SLOT (0x20) typedef struct _CONFIG_PAGE_SAS_IO_UNIT_3 @@ -2584,11 +2622,19 @@ typedef struct _CONFIG_PAGE_SAS_DEVICE_2 { CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */ U64 PhysicalIdentifier; /* 08h */ - U32 Reserved1; /* 10h */ + U32 EnclosureMapping; /* 10h */ } CONFIG_PAGE_SAS_DEVICE_2, MPI_POINTER PTR_CONFIG_PAGE_SAS_DEVICE_2, SasDevicePage2_t, MPI_POINTER pSasDevicePage2_t; -#define MPI_SASDEVICE2_PAGEVERSION (0x00) +#define MPI_SASDEVICE2_PAGEVERSION (0x01) + +/* defines for SAS Device Page 2 EnclosureMapping field */ +#define MPI_SASDEVICE2_ENC_MAP_MASK_MISSING_COUNT (0x0000000F) +#define MPI_SASDEVICE2_ENC_MAP_SHIFT_MISSING_COUNT (0) +#define MPI_SASDEVICE2_ENC_MAP_MASK_NUM_SLOTS (0x000007F0) +#define MPI_SASDEVICE2_ENC_MAP_SHIFT_NUM_SLOTS (4) +#define MPI_SASDEVICE2_ENC_MAP_MASK_START_INDEX (0x001FF800) +#define MPI_SASDEVICE2_ENC_MAP_SHIFT_START_INDEX (11) /**************************************************************************** @@ -2598,7 +2644,8 @@ typedef struct _CONFIG_PAGE_SAS_DEVICE_2 typedef struct _CONFIG_PAGE_SAS_PHY_0 { CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */ - U32 Reserved1; /* 08h */ + U16 OwnerDevHandle; /* 08h */ + U16 Reserved1; /* 0Ah */ U64 SASAddress; /* 0Ch */ U16 AttachedDevHandle; /* 14h */ U8 AttachedPhyIdentifier; /* 16h */ @@ -2607,12 +2654,12 @@ typedef struct _CONFIG_PAGE_SAS_PHY_0 U8 ProgrammedLinkRate; /* 20h */ U8 HwLinkRate; /* 21h */ U8 ChangeCount; /* 22h */ - U8 Reserved3; /* 23h */ + U8 Flags; /* 23h */ U32 PhyInfo; /* 24h */ } CONFIG_PAGE_SAS_PHY_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_PHY_0, SasPhyPage0_t, MPI_POINTER pSasPhyPage0_t; -#define MPI_SASPHY0_PAGEVERSION (0x00) +#define MPI_SASPHY0_PAGEVERSION (0x01) /* values for SAS PHY Page 0 ProgrammedLinkRate field */ #define MPI_SAS_PHY0_PRATE_MAX_RATE_MASK (0xF0) @@ -2632,6 +2679,9 @@ typedef struct _CONFIG_PAGE_SAS_PHY_0 #define MPI_SAS_PHY0_HWRATE_MIN_RATE_1_5 (0x08) #define MPI_SAS_PHY0_HWRATE_MIN_RATE_3_0 (0x09) +/* values for SAS PHY Page 0 Flags field */ +#define MPI_SAS_PHY0_FLAGS_SGPIO_DIRECT_ATTACH_ENC (0x01) + /* values for SAS PHY Page 0 PhyInfo field */ #define MPI_SAS_PHY0_PHYINFO_SATA_PORT_ACTIVE (0x00004000) #define MPI_SAS_PHY0_PHYINFO_SATA_PORT_SELECTOR (0x00002000) @@ -2690,7 +2740,7 @@ typedef struct _CONFIG_PAGE_SAS_ENCLOSURE_0 } CONFIG_PAGE_SAS_ENCLOSURE_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_ENCLOSURE_0, SasEnclosurePage0_t, MPI_POINTER pSasEnclosurePage0_t; -#define MPI_SASENCLOSURE0_PAGEVERSION (0x00) +#define MPI_SASENCLOSURE0_PAGEVERSION (0x01) /* values for SAS Enclosure Page 0 Flags field */ #define MPI_SAS_ENCLS0_FLAGS_SEP_BUS_ID_VALID (0x0020) @@ -2702,6 +2752,7 @@ typedef struct _CONFIG_PAGE_SAS_ENCLOSURE_0 #define MPI_SAS_ENCLS0_FLAGS_MNG_IOC_SGPIO (0x0002) #define MPI_SAS_ENCLS0_FLAGS_MNG_EXP_SGPIO (0x0003) #define MPI_SAS_ENCLS0_FLAGS_MNG_SES_ENCLOSURE (0x0004) +#define MPI_SAS_ENCLS0_FLAGS_MNG_IOC_GPIO (0x0005) /**************************************************************************** diff --git a/drivers/message/fusion/lsi/mpi_history.txt b/drivers/message/fusion/lsi/mpi_history.txt index c9edbee41ed..1a30ef16adb 100644 --- a/drivers/message/fusion/lsi/mpi_history.txt +++ b/drivers/message/fusion/lsi/mpi_history.txt @@ -6,17 +6,17 @@ Copyright (c) 2000-2005 LSI Logic Corporation. --------------------------------------- - Header Set Release Version: 01.05.09 + Header Set Release Version: 01.05.10 Header Set Release Date: 03-11-05 --------------------------------------- Filename Current version Prior version ---------- --------------- ------------- - mpi.h 01.05.07 01.05.06 - mpi_ioc.h 01.05.08 01.05.07 - mpi_cnfg.h 01.05.08 01.05.07 - mpi_init.h 01.05.04 01.05.03 - mpi_targ.h 01.05.04 01.05.03 + mpi.h 01.05.08 01.05.07 + mpi_ioc.h 01.05.09 01.05.08 + mpi_cnfg.h 01.05.09 01.05.08 + mpi_init.h 01.05.05 01.05.04 + mpi_targ.h 01.05.05 01.05.04 mpi_fc.h 01.05.01 01.05.01 mpi_lan.h 01.05.01 01.05.01 mpi_raid.h 01.05.02 01.05.02 @@ -24,7 +24,7 @@ mpi_inb.h 01.05.01 01.05.01 mpi_sas.h 01.05.01 01.05.01 mpi_type.h 01.05.01 01.05.01 - mpi_history.txt 01.05.09 01.05.08 + mpi_history.txt 01.05.09 01.05.09 * Date Version Description @@ -88,6 +88,9 @@ mpi.h * 03-11-05 01.05.07 Removed function codes for SCSI IO 32 and * TargetAssistExtended requests. * Removed EEDP IOCStatus codes. + * 06-24-05 01.05.08 Added function codes for SCSI IO 32 and + * TargetAssistExtended requests. + * Added EEDP IOCStatus codes. * -------------------------------------------------------------------------- mpi_ioc.h @@ -159,6 +162,8 @@ mpi_ioc.h * Reply and IOC Init Request. * 03-11-05 01.05.08 Added family code for 1068E family. * Removed IOCFacts Reply EEDP Capability bit. + * 06-24-05 01.05.09 Added 5 new IOCFacts Reply IOCCapabilities bits. + * Added Max SATA Targets to SAS Discovery Error event. * -------------------------------------------------------------------------- mpi_cnfg.h @@ -380,6 +385,23 @@ mpi_cnfg.h * New physical mapping mode in SAS IO Unit Page 2. * Added CONFIG_PAGE_SAS_ENCLOSURE_0. * Added Slot and Enclosure fields to SAS Device Page 0. + * 06-24-05 01.05.09 Added EEDP defines to IOC Page 1. + * Added more RAID type defines to IOC Page 2. + * Added Port Enable Delay settings to BIOS Page 1. + * Added Bad Block Table Full define to RAID Volume Page 0. + * Added Previous State defines to RAID Physical Disk + * Page 0. + * Added Max Sata Targets define for DiscoveryStatus field + * of SAS IO Unit Page 0. + * Added Device Self Test to Control Flags of SAS IO Unit + * Page 1. + * Added Direct Attach Starting Slot Number define for SAS + * IO Unit Page 2. + * Added new fields in SAS Device Page 2 for enclosure + * mapping. + * Added OwnerDevHandle and Flags field to SAS PHY Page 0. + * Added IOC GPIO Flags define to SAS Enclosure Page 0. + * Fixed the value for MPI_SAS_IOUNIT1_CONTROL_DEV_SATA_SUPPORT. * -------------------------------------------------------------------------- mpi_init.h @@ -418,6 +440,8 @@ mpi_init.h * Modified SCSI Enclosure Processor Request and Reply to * support Enclosure/Slot addressing rather than WWID * addressing. + * 06-24-05 01.05.05 Added SCSI IO 32 structures and defines. + * Added four new defines for SEP SlotStatus. * -------------------------------------------------------------------------- mpi_targ.h @@ -461,6 +485,7 @@ mpi_targ.h * 10-05-04 01.05.02 MSG_TARGET_CMD_BUFFER_POST_BASE_LIST_REPLY added. * 02-22-05 01.05.03 Changed a comment. * 03-11-05 01.05.04 Removed TargetAssistExtended Request. + * 06-24-05 01.05.05 Added TargetAssistExtended structures and defines. * -------------------------------------------------------------------------- mpi_fc.h @@ -571,20 +596,20 @@ mpi_type.h mpi_history.txt Parts list history -Filename 01.05.09 ----------- -------- -mpi.h 01.05.07 -mpi_ioc.h 01.05.08 -mpi_cnfg.h 01.05.08 -mpi_init.h 01.05.04 -mpi_targ.h 01.05.04 -mpi_fc.h 01.05.01 -mpi_lan.h 01.05.01 -mpi_raid.h 01.05.02 -mpi_tool.h 01.05.03 -mpi_inb.h 01.05.01 -mpi_sas.h 01.05.01 -mpi_type.h 01.05.01 +Filename 01.05.10 01.05.09 +---------- -------- -------- +mpi.h 01.05.08 01.05.07 +mpi_ioc.h 01.05.09 01.05.08 +mpi_cnfg.h 01.05.09 01.05.08 +mpi_init.h 01.05.05 01.05.04 +mpi_targ.h 01.05.05 01.05.04 +mpi_fc.h 01.05.01 01.05.01 +mpi_lan.h 01.05.01 01.05.01 +mpi_raid.h 01.05.02 01.05.02 +mpi_tool.h 01.05.03 01.05.03 +mpi_inb.h 01.05.01 01.05.01 +mpi_sas.h 01.05.01 01.05.01 +mpi_type.h 01.05.01 01.05.01 Filename 01.05.08 01.05.07 01.05.06 01.05.05 01.05.04 01.05.03 ---------- -------- -------- -------- -------- -------- -------- diff --git a/drivers/message/fusion/lsi/mpi_init.h b/drivers/message/fusion/lsi/mpi_init.h index aca035801a8..d5af75afbd9 100644 --- a/drivers/message/fusion/lsi/mpi_init.h +++ b/drivers/message/fusion/lsi/mpi_init.h @@ -6,7 +6,7 @@ * Title: MPI initiator mode messages and structures * Creation Date: June 8, 2000 * - * mpi_init.h Version: 01.05.04 + * mpi_init.h Version: 01.05.05 * * Version History * --------------- @@ -48,6 +48,8 @@ * Modified SCSI Enclosure Processor Request and Reply to * support Enclosure/Slot addressing rather than WWID * addressing. + * 06-24-05 01.05.05 Added SCSI IO 32 structures and defines. + * Added four new defines for SEP SlotStatus. * -------------------------------------------------------------------------- */ @@ -202,6 +204,197 @@ typedef struct _MSG_SCSI_IO_REPLY #define MPI_SCSI_TASKTAG_UNKNOWN (0xFFFF) +/****************************************************************************/ +/* SCSI IO 32 messages and associated structures */ +/****************************************************************************/ + +typedef struct +{ + U8 CDB[20]; /* 00h */ + U32 PrimaryReferenceTag; /* 14h */ + U16 PrimaryApplicationTag; /* 18h */ + U16 PrimaryApplicationTagMask; /* 1Ah */ + U32 TransferLength; /* 1Ch */ +} MPI_SCSI_IO32_CDB_EEDP32, MPI_POINTER PTR_MPI_SCSI_IO32_CDB_EEDP32, + MpiScsiIo32CdbEedp32_t, MPI_POINTER pMpiScsiIo32CdbEedp32_t; + +typedef struct +{ + U8 CDB[16]; /* 00h */ + U32 DataLength; /* 10h */ + U32 PrimaryReferenceTag; /* 14h */ + U16 PrimaryApplicationTag; /* 18h */ + U16 PrimaryApplicationTagMask; /* 1Ah */ + U32 TransferLength; /* 1Ch */ +} MPI_SCSI_IO32_CDB_EEDP16, MPI_POINTER PTR_MPI_SCSI_IO32_CDB_EEDP16, + MpiScsiIo32CdbEedp16_t, MPI_POINTER pMpiScsiIo32CdbEedp16_t; + +typedef union +{ + U8 CDB32[32]; + MPI_SCSI_IO32_CDB_EEDP32 EEDP32; + MPI_SCSI_IO32_CDB_EEDP16 EEDP16; + SGE_SIMPLE_UNION SGE; +} MPI_SCSI_IO32_CDB_UNION, MPI_POINTER PTR_MPI_SCSI_IO32_CDB_UNION, + MpiScsiIo32Cdb_t, MPI_POINTER pMpiScsiIo32Cdb_t; + +typedef struct +{ + U8 TargetID; /* 00h */ + U8 Bus; /* 01h */ + U16 Reserved1; /* 02h */ + U32 Reserved2; /* 04h */ +} MPI_SCSI_IO32_BUS_TARGET_ID_FORM, MPI_POINTER PTR_MPI_SCSI_IO32_BUS_TARGET_ID_FORM, + MpiScsiIo32BusTargetIdForm_t, MPI_POINTER pMpiScsiIo32BusTargetIdForm_t; + +typedef union +{ + MPI_SCSI_IO32_BUS_TARGET_ID_FORM SCSIID; + U64 WWID; +} MPI_SCSI_IO32_ADDRESS, MPI_POINTER PTR_MPI_SCSI_IO32_ADDRESS, + MpiScsiIo32Address_t, MPI_POINTER pMpiScsiIo32Address_t; + +typedef struct _MSG_SCSI_IO32_REQUEST +{ + U8 Port; /* 00h */ + U8 Reserved1; /* 01h */ + U8 ChainOffset; /* 02h */ + U8 Function; /* 03h */ + U8 CDBLength; /* 04h */ + U8 SenseBufferLength; /* 05h */ + U8 Flags; /* 06h */ + U8 MsgFlags; /* 07h */ + U32 MsgContext; /* 08h */ + U8 LUN[8]; /* 0Ch */ + U32 Control; /* 14h */ + MPI_SCSI_IO32_CDB_UNION CDB; /* 18h */ + U32 DataLength; /* 38h */ + U32 BidirectionalDataLength; /* 3Ch */ + U32 SecondaryReferenceTag; /* 40h */ + U16 SecondaryApplicationTag; /* 44h */ + U16 Reserved2; /* 46h */ + U16 EEDPFlags; /* 48h */ + U16 ApplicationTagTranslationMask; /* 4Ah */ + U32 EEDPBlockSize; /* 4Ch */ + MPI_SCSI_IO32_ADDRESS DeviceAddress; /* 50h */ + U8 SGLOffset0; /* 58h */ + U8 SGLOffset1; /* 59h */ + U8 SGLOffset2; /* 5Ah */ + U8 SGLOffset3; /* 5Bh */ + U32 Reserved3; /* 5Ch */ + U32 Reserved4; /* 60h */ + U32 SenseBufferLowAddr; /* 64h */ + SGE_IO_UNION SGL; /* 68h */ +} MSG_SCSI_IO32_REQUEST, MPI_POINTER PTR_MSG_SCSI_IO32_REQUEST, + SCSIIO32Request_t, MPI_POINTER pSCSIIO32Request_t; + +/* SCSI IO 32 MsgFlags bits */ +#define MPI_SCSIIO32_MSGFLGS_SENSE_WIDTH (0x01) +#define MPI_SCSIIO32_MSGFLGS_SENSE_WIDTH_32 (0x00) +#define MPI_SCSIIO32_MSGFLGS_SENSE_WIDTH_64 (0x01) + +#define MPI_SCSIIO32_MSGFLGS_SENSE_LOCATION (0x02) +#define MPI_SCSIIO32_MSGFLGS_SENSE_LOC_HOST (0x00) +#define MPI_SCSIIO32_MSGFLGS_SENSE_LOC_IOC (0x02) + +#define MPI_SCSIIO32_MSGFLGS_CMD_DETERMINES_DATA_DIR (0x04) +#define MPI_SCSIIO32_MSGFLGS_SGL_OFFSETS_CHAINS (0x08) +#define MPI_SCSIIO32_MSGFLGS_MULTICAST (0x10) +#define MPI_SCSIIO32_MSGFLGS_BIDIRECTIONAL (0x20) +#define MPI_SCSIIO32_MSGFLGS_LARGE_CDB (0x40) + +/* SCSI IO 32 Flags bits */ +#define MPI_SCSIIO32_FLAGS_FORM_MASK (0x03) +#define MPI_SCSIIO32_FLAGS_FORM_SCSIID (0x00) +#define MPI_SCSIIO32_FLAGS_FORM_WWID (0x01) + +/* SCSI IO 32 LUN fields */ +#define MPI_SCSIIO32_LUN_FIRST_LEVEL_ADDRESSING (0x0000FFFF) +#define MPI_SCSIIO32_LUN_SECOND_LEVEL_ADDRESSING (0xFFFF0000) +#define MPI_SCSIIO32_LUN_THIRD_LEVEL_ADDRESSING (0x0000FFFF) +#define MPI_SCSIIO32_LUN_FOURTH_LEVEL_ADDRESSING (0xFFFF0000) +#define MPI_SCSIIO32_LUN_LEVEL_1_WORD (0xFF00) +#define MPI_SCSIIO32_LUN_LEVEL_1_DWORD (0x0000FF00) + +/* SCSI IO 32 Control bits */ +#define MPI_SCSIIO32_CONTROL_DATADIRECTION_MASK (0x03000000) +#define MPI_SCSIIO32_CONTROL_NODATATRANSFER (0x00000000) +#define MPI_SCSIIO32_CONTROL_WRITE (0x01000000) +#define MPI_SCSIIO32_CONTROL_READ (0x02000000) +#define MPI_SCSIIO32_CONTROL_BIDIRECTIONAL (0x03000000) + +#define MPI_SCSIIO32_CONTROL_ADDCDBLEN_MASK (0xFC000000) +#define MPI_SCSIIO32_CONTROL_ADDCDBLEN_SHIFT (26) + +#define MPI_SCSIIO32_CONTROL_TASKATTRIBUTE_MASK (0x00000700) +#define MPI_SCSIIO32_CONTROL_SIMPLEQ (0x00000000) +#define MPI_SCSIIO32_CONTROL_HEADOFQ (0x00000100) +#define MPI_SCSIIO32_CONTROL_ORDEREDQ (0x00000200) +#define MPI_SCSIIO32_CONTROL_ACAQ (0x00000400) +#define MPI_SCSIIO32_CONTROL_UNTAGGED (0x00000500) +#define MPI_SCSIIO32_CONTROL_NO_DISCONNECT (0x00000700) + +#define MPI_SCSIIO32_CONTROL_TASKMANAGE_MASK (0x00FF0000) +#define MPI_SCSIIO32_CONTROL_OBSOLETE (0x00800000) +#define MPI_SCSIIO32_CONTROL_CLEAR_ACA_RSV (0x00400000) +#define MPI_SCSIIO32_CONTROL_TARGET_RESET (0x00200000) +#define MPI_SCSIIO32_CONTROL_LUN_RESET_RSV (0x00100000) +#define MPI_SCSIIO32_CONTROL_RESERVED (0x00080000) +#define MPI_SCSIIO32_CONTROL_CLR_TASK_SET_RSV (0x00040000) +#define MPI_SCSIIO32_CONTROL_ABORT_TASK_SET (0x00020000) +#define MPI_SCSIIO32_CONTROL_RESERVED2 (0x00010000) + +/* SCSI IO 32 EEDPFlags */ +#define MPI_SCSIIO32_EEDPFLAGS_MASK_OP (0x0007) +#define MPI_SCSIIO32_EEDPFLAGS_NOOP_OP (0x0000) +#define MPI_SCSIIO32_EEDPFLAGS_CHK_OP (0x0001) +#define MPI_SCSIIO32_EEDPFLAGS_STRIP_OP (0x0002) +#define MPI_SCSIIO32_EEDPFLAGS_CHKRM_OP (0x0003) +#define MPI_SCSIIO32_EEDPFLAGS_INSERT_OP (0x0004) +#define MPI_SCSIIO32_EEDPFLAGS_REPLACE_OP (0x0006) +#define MPI_SCSIIO32_EEDPFLAGS_CHKREGEN_OP (0x0007) + +#define MPI_SCSIIO32_EEDPFLAGS_PASS_REF_TAG (0x0008) +#define MPI_SCSIIO32_EEDPFLAGS_8_9THS_MODE (0x0010) + +#define MPI_SCSIIO32_EEDPFLAGS_T10_CHK_MASK (0x0700) +#define MPI_SCSIIO32_EEDPFLAGS_T10_CHK_GUARD (0x0100) +#define MPI_SCSIIO32_EEDPFLAGS_T10_CHK_REFTAG (0x0200) +#define MPI_SCSIIO32_EEDPFLAGS_T10_CHK_LBATAG (0x0400) +#define MPI_SCSIIO32_EEDPFLAGS_T10_CHK_SHIFT (8) + +#define MPI_SCSIIO32_EEDPFLAGS_INC_SEC_APPTAG (0x1000) +#define MPI_SCSIIO32_EEDPFLAGS_INC_PRI_APPTAG (0x2000) +#define MPI_SCSIIO32_EEDPFLAGS_INC_SEC_REFTAG (0x4000) +#define MPI_SCSIIO32_EEDPFLAGS_INC_PRI_REFTAG (0x8000) + + +/* SCSIIO32 IO reply structure */ +typedef struct _MSG_SCSIIO32_IO_REPLY +{ + U8 Port; /* 00h */ + U8 Reserved1; /* 01h */ + U8 MsgLength; /* 02h */ + U8 Function; /* 03h */ + U8 CDBLength; /* 04h */ + U8 SenseBufferLength; /* 05h */ + U8 Flags; /* 06h */ + U8 MsgFlags; /* 07h */ + U32 MsgContext; /* 08h */ + U8 SCSIStatus; /* 0Ch */ + U8 SCSIState; /* 0Dh */ + U16 IOCStatus; /* 0Eh */ + U32 IOCLogInfo; /* 10h */ + U32 TransferCount; /* 14h */ + U32 SenseCount; /* 18h */ + U32 ResponseInfo; /* 1Ch */ + U16 TaskTag; /* 20h */ + U16 Reserved2; /* 22h */ + U32 BidirectionalTransferCount; /* 24h */ +} MSG_SCSIIO32_IO_REPLY, MPI_POINTER PTR_MSG_SCSIIO32_IO_REPLY, + SCSIIO32Reply_t, MPI_POINTER pSCSIIO32Reply_t; + + /****************************************************************************/ /* SCSI Task Management messages */ /****************************************************************************/ @@ -310,10 +503,14 @@ typedef struct _MSG_SEP_REQUEST #define MPI_SEP_REQ_SLOTSTATUS_UNCONFIGURED (0x00000080) #define MPI_SEP_REQ_SLOTSTATUS_HOT_SPARE (0x00000100) #define MPI_SEP_REQ_SLOTSTATUS_REBUILD_STOPPED (0x00000200) +#define MPI_SEP_REQ_SLOTSTATUS_REQ_CONSISTENCY_CHECK (0x00001000) +#define MPI_SEP_REQ_SLOTSTATUS_DISABLE (0x00002000) +#define MPI_SEP_REQ_SLOTSTATUS_REQ_RESERVED_DEVICE (0x00004000) #define MPI_SEP_REQ_SLOTSTATUS_IDENTIFY_REQUEST (0x00020000) #define MPI_SEP_REQ_SLOTSTATUS_REQUEST_REMOVE (0x00040000) #define MPI_SEP_REQ_SLOTSTATUS_REQUEST_INSERT (0x00080000) #define MPI_SEP_REQ_SLOTSTATUS_DO_NOT_MOVE (0x00400000) +#define MPI_SEP_REQ_SLOTSTATUS_ACTIVE (0x00800000) #define MPI_SEP_REQ_SLOTSTATUS_B_ENABLE_BYPASS (0x04000000) #define MPI_SEP_REQ_SLOTSTATUS_A_ENABLE_BYPASS (0x08000000) #define MPI_SEP_REQ_SLOTSTATUS_DEV_OFF (0x10000000) @@ -352,11 +549,15 @@ typedef struct _MSG_SEP_REPLY #define MPI_SEP_REPLY_SLOTSTATUS_UNCONFIGURED (0x00000080) #define MPI_SEP_REPLY_SLOTSTATUS_HOT_SPARE (0x00000100) #define MPI_SEP_REPLY_SLOTSTATUS_REBUILD_STOPPED (0x00000200) +#define MPI_SEP_REPLY_SLOTSTATUS_CONSISTENCY_CHECK (0x00001000) +#define MPI_SEP_REPLY_SLOTSTATUS_DISABLE (0x00002000) +#define MPI_SEP_REPLY_SLOTSTATUS_RESERVED_DEVICE (0x00004000) #define MPI_SEP_REPLY_SLOTSTATUS_REPORT (0x00010000) #define MPI_SEP_REPLY_SLOTSTATUS_IDENTIFY_REQUEST (0x00020000) #define MPI_SEP_REPLY_SLOTSTATUS_REMOVE_READY (0x00040000) #define MPI_SEP_REPLY_SLOTSTATUS_INSERT_READY (0x00080000) #define MPI_SEP_REPLY_SLOTSTATUS_DO_NOT_REMOVE (0x00400000) +#define MPI_SEP_REPLY_SLOTSTATUS_ACTIVE (0x00800000) #define MPI_SEP_REPLY_SLOTSTATUS_B_BYPASS_ENABLED (0x01000000) #define MPI_SEP_REPLY_SLOTSTATUS_A_BYPASS_ENABLED (0x02000000) #define MPI_SEP_REPLY_SLOTSTATUS_B_ENABLE_BYPASS (0x04000000) diff --git a/drivers/message/fusion/lsi/mpi_ioc.h b/drivers/message/fusion/lsi/mpi_ioc.h index f91eb4efe8c..93b70e2b426 100644 --- a/drivers/message/fusion/lsi/mpi_ioc.h +++ b/drivers/message/fusion/lsi/mpi_ioc.h @@ -6,7 +6,7 @@ * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages * Creation Date: August 11, 2000 * - * mpi_ioc.h Version: 01.05.08 + * mpi_ioc.h Version: 01.05.09 * * Version History * --------------- @@ -81,6 +81,8 @@ * Reply and IOC Init Request. * 03-11-05 01.05.08 Added family code for 1068E family. * Removed IOCFacts Reply EEDP Capability bit. + * 06-24-05 01.05.09 Added 5 new IOCFacts Reply IOCCapabilities bits. + * Added Max SATA Targets to SAS Discovery Error event. * -------------------------------------------------------------------------- */ @@ -261,7 +263,11 @@ typedef struct _MSG_IOC_FACTS_REPLY #define MPI_IOCFACTS_CAPABILITY_DIAG_TRACE_BUFFER (0x00000008) #define MPI_IOCFACTS_CAPABILITY_SNAPSHOT_BUFFER (0x00000010) #define MPI_IOCFACTS_CAPABILITY_EXTENDED_BUFFER (0x00000020) - +#define MPI_IOCFACTS_CAPABILITY_EEDP (0x00000040) +#define MPI_IOCFACTS_CAPABILITY_BIDIRECTIONAL (0x00000080) +#define MPI_IOCFACTS_CAPABILITY_MULTICAST (0x00000100) +#define MPI_IOCFACTS_CAPABILITY_SCSIIO32 (0x00000200) +#define MPI_IOCFACTS_CAPABILITY_NO_SCSIIO16 (0x00000400) /***************************************************************************** @@ -677,6 +683,7 @@ typedef struct _EVENT_DATA_DISCOVERY_ERROR #define MPI_EVENT_DSCVRY_ERR_DS_MULTPL_SUBTRACTIVE (0x00000200) #define MPI_EVENT_DSCVRY_ERR_DS_TABLE_TO_TABLE (0x00000400) #define MPI_EVENT_DSCVRY_ERR_DS_MULTPL_PATHS (0x00000800) +#define MPI_EVENT_DSCVRY_ERR_DS_MAX_SATA_TARGETS (0x00001000) /***************************************************************************** diff --git a/drivers/message/fusion/lsi/mpi_targ.h b/drivers/message/fusion/lsi/mpi_targ.h index 623901fd82b..3f462859cee 100644 --- a/drivers/message/fusion/lsi/mpi_targ.h +++ b/drivers/message/fusion/lsi/mpi_targ.h @@ -6,7 +6,7 @@ * Title: MPI Target mode messages and structures * Creation Date: June 22, 2000 * - * mpi_targ.h Version: 01.05.04 + * mpi_targ.h Version: 01.05.05 * * Version History * --------------- @@ -53,6 +53,7 @@ * 10-05-04 01.05.02 MSG_TARGET_CMD_BUFFER_POST_BASE_LIST_REPLY added. * 02-22-05 01.05.03 Changed a comment. * 03-11-05 01.05.04 Removed TargetAssistExtended Request. + * 06-24-05 01.05.05 Added TargetAssistExtended structures and defines. * -------------------------------------------------------------------------- */ @@ -370,6 +371,77 @@ typedef struct _MSG_TARGET_ERROR_REPLY TargetErrorReply_t, MPI_POINTER pTargetErrorReply_t; +/****************************************************************************/ +/* Target Assist Extended Request */ +/****************************************************************************/ + +typedef struct _MSG_TARGET_ASSIST_EXT_REQUEST +{ + U8 StatusCode; /* 00h */ + U8 TargetAssistFlags; /* 01h */ + U8 ChainOffset; /* 02h */ + U8 Function; /* 03h */ + U16 QueueTag; /* 04h */ + U8 Reserved1; /* 06h */ + U8 MsgFlags; /* 07h */ + U32 MsgContext; /* 08h */ + U32 ReplyWord; /* 0Ch */ + U8 LUN[8]; /* 10h */ + U32 RelativeOffset; /* 18h */ + U32 Reserved2; /* 1Ch */ + U32 Reserved3; /* 20h */ + U32 PrimaryReferenceTag; /* 24h */ + U16 PrimaryApplicationTag; /* 28h */ + U16 PrimaryApplicationTagMask; /* 2Ah */ + U32 Reserved4; /* 2Ch */ + U32 DataLength; /* 30h */ + U32 BidirectionalDataLength; /* 34h */ + U32 SecondaryReferenceTag; /* 38h */ + U16 SecondaryApplicationTag; /* 3Ch */ + U16 Reserved5; /* 3Eh */ + U16 EEDPFlags; /* 40h */ + U16 ApplicationTagTranslationMask; /* 42h */ + U32 EEDPBlockSize; /* 44h */ + U8 SGLOffset0; /* 48h */ + U8 SGLOffset1; /* 49h */ + U8 SGLOffset2; /* 4Ah */ + U8 SGLOffset3; /* 4Bh */ + U32 Reserved6; /* 4Ch */ + SGE_IO_UNION SGL[1]; /* 50h */ +} MSG_TARGET_ASSIST_EXT_REQUEST, MPI_POINTER PTR_MSG_TARGET_ASSIST_EXT_REQUEST, + TargetAssistExtRequest_t, MPI_POINTER pTargetAssistExtRequest_t; + +/* see the defines after MSG_TARGET_ASSIST_REQUEST for TargetAssistFlags */ + +/* defines for the MsgFlags field */ +#define TARGET_ASSIST_EXT_MSGFLAGS_BIDIRECTIONAL (0x20) +#define TARGET_ASSIST_EXT_MSGFLAGS_MULTICAST (0x10) +#define TARGET_ASSIST_EXT_MSGFLAGS_SGL_OFFSET_CHAINS (0x08) + +/* defines for the EEDPFlags field */ +#define TARGET_ASSIST_EXT_EEDP_MASK_OP (0x0007) +#define TARGET_ASSIST_EXT_EEDP_NOOP_OP (0x0000) +#define TARGET_ASSIST_EXT_EEDP_CHK_OP (0x0001) +#define TARGET_ASSIST_EXT_EEDP_STRIP_OP (0x0002) +#define TARGET_ASSIST_EXT_EEDP_CHKRM_OP (0x0003) +#define TARGET_ASSIST_EXT_EEDP_INSERT_OP (0x0004) +#define TARGET_ASSIST_EXT_EEDP_REPLACE_OP (0x0006) +#define TARGET_ASSIST_EXT_EEDP_CHKREGEN_OP (0x0007) + +#define TARGET_ASSIST_EXT_EEDP_PASS_REF_TAG (0x0008) + +#define TARGET_ASSIST_EXT_EEDP_T10_CHK_MASK (0x0700) +#define TARGET_ASSIST_EXT_EEDP_T10_CHK_GUARD (0x0100) +#define TARGET_ASSIST_EXT_EEDP_T10_CHK_APPTAG (0x0200) +#define TARGET_ASSIST_EXT_EEDP_T10_CHK_REFTAG (0x0400) +#define TARGET_ASSIST_EXT_EEDP_T10_CHK_SHIFT (8) + +#define TARGET_ASSIST_EXT_EEDP_INC_SEC_APPTAG (0x1000) +#define TARGET_ASSIST_EXT_EEDP_INC_PRI_APPTAG (0x2000) +#define TARGET_ASSIST_EXT_EEDP_INC_SEC_REFTAG (0x4000) +#define TARGET_ASSIST_EXT_EEDP_INC_PRI_REFTAG (0x8000) + + /****************************************************************************/ /* Target Status Send Request */ /****************************************************************************/ -- cgit v1.2.3-18-g5258 From 637fa99b86a00a0b5767a982b83a512ff48ad6d2 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 18 Aug 2005 16:25:44 +0200 Subject: [SCSI] fusion: endianess fixes Assorted endianess fixes. I'll work on full endianess annotations later. Acked by: Moore, Eric Dean Signed-off-by: James Bottomley --- drivers/message/fusion/mptbase.c | 6 +++--- drivers/message/fusion/mptctl.c | 2 +- drivers/message/fusion/mptscsih.c | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index 28420276680..35444ba4e78 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c @@ -2185,7 +2185,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason) facts->IOCExceptions = le16_to_cpu(facts->IOCExceptions); facts->IOCStatus = le16_to_cpu(facts->IOCStatus); facts->IOCLogInfo = le32_to_cpu(facts->IOCLogInfo); - status = facts->IOCStatus & MPI_IOCSTATUS_MASK; + status = le16_to_cpu(facts->IOCStatus) & MPI_IOCSTATUS_MASK; /* CHECKME! IOCStatus, IOCLogInfo */ facts->ReplyQueueDepth = le16_to_cpu(facts->ReplyQueueDepth); @@ -4823,8 +4823,8 @@ mpt_toolbox(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg) pReq->Reserved3 = 0; pReq->NumAddressBytes = 0x01; pReq->Reserved4 = 0; - pReq->DataLength = 0x04; - pdev = (struct pci_dev *) ioc->pcidev; + pReq->DataLength = cpu_to_le16(0x04); + pdev = ioc->pcidev; if (pdev->devfn & 1) pReq->DeviceAddr = 0xB2; else diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index e63a3fd6b70..7577c2417e2 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c @@ -242,7 +242,7 @@ mptctl_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply) /* Set the command status to GOOD if IOC Status is GOOD * OR if SCSI I/O cmd and data underrun or recovered error. */ - iocStatus = reply->u.reply.IOCStatus & MPI_IOCSTATUS_MASK; + iocStatus = le16_to_cpu(reply->u.reply.IOCStatus) & MPI_IOCSTATUS_MASK; if (iocStatus == MPI_IOCSTATUS_SUCCESS) ioc->ioctl->status |= MPT_IOCTL_STATUS_COMMAND_GOOD; diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index b774f45dfde..cd4e8c0853d 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -3447,7 +3447,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) * some type of error occurred. */ MpiRaidActionReply_t *pr = (MpiRaidActionReply_t *)mr; - if (pr->ActionStatus == MPI_RAID_ACTION_ASTATUS_SUCCESS) + if (le16_to_cpu(pr->ActionStatus) == MPI_RAID_ACTION_ASTATUS_SUCCESS) completionCode = MPT_SCANDV_GOOD; else completionCode = MPT_SCANDV_SOME_ERROR; @@ -3996,9 +3996,9 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum) dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC " "offset=0 negoFlags=%x request=%x config=%x\n", id, flags, requested, configuration)); - pcfg1Data->RequestedParameters = le32_to_cpu(requested); + pcfg1Data->RequestedParameters = cpu_to_le32(requested); pcfg1Data->Reserved = 0; - pcfg1Data->Configuration = le32_to_cpu(configuration); + pcfg1Data->Configuration = cpu_to_le32(configuration); cfg.pageAddr = (bus<<8) | id; mpt_config(hd->ioc, &cfg); } @@ -5248,7 +5248,7 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage) /* Update tmax values with those from Device Page 0.*/ pPage0 = (SCSIDevicePage0_t *) pPage; if (pPage0) { - val = cpu_to_le32(pPage0->NegotiatedParameters); + val = le32_to_cpu(pPage0->NegotiatedParameters); dv->max.width = val & MPI_SCSIDEVPAGE0_NP_WIDE ? 1 : 0; dv->max.offset = (val&MPI_SCSIDEVPAGE0_NP_NEG_SYNC_OFFSET_MASK) >> 16; dv->max.factor = (val&MPI_SCSIDEVPAGE0_NP_NEG_SYNC_PERIOD_MASK) >> 8; @@ -5276,12 +5276,12 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage) dv->now.offset, &val, &configuration, dv->now.flags); dnegoprintk(("Setting Max: id=%d width=%d factor=%x offset=%x negoFlags=%x request=%x config=%x\n", id, dv->now.width, dv->now.factor, dv->now.offset, dv->now.flags, val, configuration)); - pPage1->RequestedParameters = le32_to_cpu(val); + pPage1->RequestedParameters = cpu_to_le32(val); pPage1->Reserved = 0; - pPage1->Configuration = le32_to_cpu(configuration); + pPage1->Configuration = cpu_to_le32(configuration); } - ddvprintk(("id=%d width=%d factor=%x offset=%x flags=%x request=%x configuration=%x\n", + ddvprintk(("id=%d width=%d factor=%x offset=%x negoFlags=%x request=%x configuration=%x\n", id, dv->now.width, dv->now.factor, dv->now.offset, dv->now.flags, val, configuration)); break; @@ -5301,9 +5301,9 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage) offset, &val, &configuration, negoFlags); dnegoprintk(("Setting Min: id=%d width=%d factor=%x offset=%x negoFlags=%x request=%x config=%x\n", id, width, factor, offset, negoFlags, val, configuration)); - pPage1->RequestedParameters = le32_to_cpu(val); + pPage1->RequestedParameters = cpu_to_le32(val); pPage1->Reserved = 0; - pPage1->Configuration = le32_to_cpu(configuration); + pPage1->Configuration = cpu_to_le32(configuration); } ddvprintk(("id=%d width=%d factor=%x offset=%x request=%x config=%x negoFlags=%x\n", id, width, factor, offset, val, configuration, negoFlags)); @@ -5377,12 +5377,12 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage) if (pPage1) { mptscsih_setDevicePage1Flags (width, factor, offset, &val, &configuration, dv->now.flags); - dnegoprintk(("Finish: id=%d width=%d offset=%d factor=%x flags=%x request=%x config=%x\n", + dnegoprintk(("Finish: id=%d width=%d offset=%d factor=%x negoFlags=%x request=%x config=%x\n", id, width, offset, factor, dv->now.flags, val, configuration)); - pPage1->RequestedParameters = le32_to_cpu(val); + pPage1->RequestedParameters = cpu_to_le32(val); pPage1->Reserved = 0; - pPage1->Configuration = le32_to_cpu(configuration); + pPage1->Configuration = cpu_to_le32(configuration); } ddvprintk(("Finish: id=%d offset=%d factor=%x width=%d request=%x config=%x\n", -- cgit v1.2.3-18-g5258 From c6678e0cfb41b029c3600c54b5bb65954de1230a Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 18 Aug 2005 16:24:53 +0200 Subject: [SCSI] fusion: whitespace fixes Acked by: Moore, Eric Dean Signed-off-by: James Bottomley --- drivers/message/fusion/mptbase.c | 225 ++++++++++++++++++++------------------ drivers/message/fusion/mptscsih.c | 98 +++++++++-------- drivers/message/fusion/mptspi.c | 6 +- 3 files changed, 174 insertions(+), 155 deletions(-) (limited to 'drivers') diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index 35444ba4e78..f517d0692d5 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c @@ -218,8 +218,7 @@ pci_enable_io_access(struct pci_dev *pdev) * (also referred to as a IO Controller or IOC). * This routine must clear the interrupt from the adapter and does * so by reading the reply FIFO. Multiple replies may be processed - * per single call to this routine; up to MPT_MAX_REPLIES_PER_ISR - * which is currently set to 32 in mptbase.h. + * per single call to this routine. * * This routine handles register-level access of the adapter but * dispatches (calls) a protocol-specific callback routine to handle @@ -279,11 +278,11 @@ mpt_interrupt(int irq, void *bus_id, struct pt_regs *r) cb_idx = mr->u.frame.hwhdr.msgctxu.fld.cb_idx; mf = MPT_INDEX_2_MFPTR(ioc, req_idx); - dmfprintk((MYIOC_s_INFO_FMT "Got non-TURBO reply=%p req_idx=%x\n", - ioc->name, mr, req_idx)); + dmfprintk((MYIOC_s_INFO_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n", + ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function)); DBG_DUMP_REPLY_FRAME(mr) - /* Check/log IOC log info + /* Check/log IOC log info */ ioc_stat = le16_to_cpu(mr->u.reply.IOCStatus); if (ioc_stat & MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE) { @@ -345,7 +344,7 @@ mpt_interrupt(int irq, void *bus_id, struct pt_regs *r) if ((mf) && ((mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth)) || (mf < ioc->req_frames)) ) { printk(MYIOC_s_WARN_FMT - "mpt_interrupt: Invalid mf (%p) req_idx (%d)!\n", ioc->name, (void *)mf, req_idx); + "mpt_interrupt: Invalid mf (%p)!\n", ioc->name, (void *)mf); cb_idx = 0; pa = 0; freeme = 0; @@ -399,7 +398,7 @@ mpt_interrupt(int irq, void *bus_id, struct pt_regs *r) * @mf: Pointer to original MPT request frame * @reply: Pointer to MPT reply frame (NULL if TurboReply) * - * Returns 1 indicating original alloc'd request frame ptr + * Returns 1 indicating original alloc'd request frame ptr * should be freed, or 0 if it shouldn't. */ static int @@ -408,28 +407,17 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply) int freereq = 1; u8 func; - dprintk((MYIOC_s_INFO_FMT "mpt_base_reply() called\n", ioc->name)); - - if ((mf == NULL) || - (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) { - printk(MYIOC_s_ERR_FMT "NULL or BAD request frame ptr! (=%p)\n", - ioc->name, (void *)mf); - return 1; - } - - if (reply == NULL) { - dprintk((MYIOC_s_ERR_FMT "Unexpected NULL Event (turbo?) reply!\n", - ioc->name)); - return 1; - } + dmfprintk((MYIOC_s_INFO_FMT "mpt_base_reply() called\n", ioc->name)); +#if defined(MPT_DEBUG_MSG_FRAME) if (!(reply->u.hdr.MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY)) { dmfprintk((KERN_INFO MYNAM ": Original request frame (@%p) header\n", mf)); DBG_DUMP_REQUEST_FRAME_HDR(mf) } +#endif func = reply->u.hdr.Function; - dprintk((MYIOC_s_INFO_FMT "mpt_base_reply, Function=%02Xh\n", + dmfprintk((MYIOC_s_INFO_FMT "mpt_base_reply, Function=%02Xh\n", ioc->name, func)); if (func == MPI_FUNCTION_EVENT_NOTIFICATION) { @@ -448,8 +436,14 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply) * Hmmm... It seems that EventNotificationReply is an exception * to the rule of one reply per request. */ - if (pEvReply->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) + if (pEvReply->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) { freereq = 0; + devtprintk((MYIOC_s_WARN_FMT "EVENT_NOTIFICATION reply %p does not return Request frame\n", + ioc->name, pEvReply)); + } else { + devtprintk((MYIOC_s_WARN_FMT "EVENT_NOTIFICATION reply %p returns Request frame\n", + ioc->name, pEvReply)); + } #ifdef CONFIG_PROC_FS // LogEvent(ioc, pEvReply); @@ -716,7 +710,7 @@ mpt_device_driver_deregister(int cb_idx) if (dd_cbfunc->remove) dd_cbfunc->remove(ioc->pcidev); } - + MptDeviceDriverHandlers[cb_idx] = NULL; } @@ -829,7 +823,7 @@ mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf) } #endif - mf_dma_addr = (ioc->req_frames_low_dma + req_offset) | ioc->RequestNB[req_idx]; + mf_dma_addr = (ioc->req_frames_low_dma + req_offset) | ioc->RequestNB[req_idx]; dsgprintk((MYIOC_s_INFO_FMT "mf_dma_addr=%x req_idx=%d RequestNB=%x\n", ioc->name, mf_dma_addr, req_idx, ioc->RequestNB[req_idx])); CHIPREG_WRITE32(&ioc->chip->RequestFifo, mf_dma_addr); } @@ -931,7 +925,7 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req, /* Make sure there are no doorbells */ CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); - + CHIPREG_WRITE32(&ioc->chip->Doorbell, ((MPI_FUNCTION_HANDSHAKE<name, ii)); + ioc->name, ii)); CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); if ((r = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) { return -2; } - + /* Send request via doorbell handshake */ req_as_bytes = (u8 *) req; for (ii = 0; ii < reqBytes/4; ii++) { @@ -999,9 +993,9 @@ mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp) if (ioc->id == iocid) { *iocpp =ioc; return iocid; - } + } } - + *iocpp = NULL; return -1; } @@ -1043,9 +1037,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) if (pci_enable_device(pdev)) return r; - + dinitprintk((KERN_WARNING MYNAM ": mpt_adapter_install\n")); - + if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { dprintk((KERN_INFO MYNAM ": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n")); @@ -1070,7 +1064,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) ioc->alloc_total = sizeof(MPT_ADAPTER); ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */ ioc->reply_sz = MPT_REPLY_FRAME_SIZE; - + ioc->pcidev = pdev; ioc->diagPending = 0; spin_lock_init(&ioc->diagLock); @@ -1099,7 +1093,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) /* Find lookup slot. */ INIT_LIST_HEAD(&ioc->list); ioc->id = mpt_ids++; - + mem_phys = msize = 0; port = psize = 0; for (ii=0; ii < DEVICE_COUNT_RESOURCE; ii++) { @@ -1154,7 +1148,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) ioc->prod_name = "LSIFC909"; ioc->bus_type = FC; } - if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC929) { + else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC929) { ioc->prod_name = "LSIFC929"; ioc->bus_type = FC; } @@ -1333,7 +1327,7 @@ mpt_detach(struct pci_dev *pdev) remove_proc_entry(pname, NULL); sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s", ioc->name); remove_proc_entry(pname, NULL); - + /* call per device driver remove entry point */ for(ii=0; iiremove(pdev); } } - + /* Disable interrupts! */ CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); @@ -1414,7 +1408,7 @@ mpt_resume(struct pci_dev *pdev) u32 device_state = pdev->current_state; int recovery_state; int ii; - + printk(MYIOC_s_INFO_FMT "pci-resume: pdev=0x%p, slot=%s, Previous operating state [D%d]\n", ioc->name, pdev, pci_name(pdev), device_state); @@ -1545,7 +1539,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) if ((rc = GetIocFacts(ioc, sleepFlag, reason)) == 0) break; } - + if (ii == 5) { dinitprintk((MYIOC_s_INFO_FMT "Retry IocFacts failed rc=%x\n", ioc->name, rc)); @@ -1553,7 +1547,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { MptDisplayIocCapabilities(ioc); } - + if (alt_ioc_ready) { if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) { dinitprintk((MYIOC_s_INFO_FMT "Initial Alt IocFacts failed rc=%x\n", ioc->name, rc)); @@ -1624,7 +1618,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) if (reset_alt_ioc_active && ioc->alt_ioc) { /* (re)Enable alt-IOC! (reply interrupt) */ - dprintk((KERN_INFO MYNAM ": alt-%s reply irq re-enabled\n", + dinitprintk((KERN_INFO MYNAM ": alt-%s reply irq re-enabled\n", ioc->alt_ioc->name)); CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, ~(MPI_HIM_RIM)); ioc->alt_ioc->active = 1; @@ -1681,7 +1675,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) /* Find IM volumes */ - if (ioc->facts.MsgVersion >= 0x0102) + if (ioc->facts.MsgVersion >= MPI_VERSION_01_02) mpt_findImVolumes(ioc); /* Check, and possibly reset, the coalescing value @@ -1711,7 +1705,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) } if (alt_ioc_ready && MptResetHandlers[ii]) { - dprintk((MYIOC_s_INFO_FMT "Calling alt-%s post_reset handler #%d\n", + drsprintk((MYIOC_s_INFO_FMT "Calling alt-%s post_reset handler #%d\n", ioc->name, ioc->alt_ioc->name, ii)); rc += (*(MptResetHandlers[ii]))(ioc->alt_ioc, MPT_IOC_POST_RESET); handlers++; @@ -1744,8 +1738,8 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev) dprintk((MYIOC_s_INFO_FMT "PCI device %s devfn=%x/%x," " searching for devfn match on %x or %x\n", - ioc->name, pci_name(pdev), pdev->devfn, - func-1, func+1)); + ioc->name, pci_name(pdev), pdev->bus->number, + pdev->devfn, func-1, func+1)); peer = pci_get_slot(pdev->bus, PCI_DEVFN(slot,func-1)); if (!peer) { @@ -1872,36 +1866,39 @@ mpt_adapter_disable(MPT_ADAPTER *ioc) static void mpt_adapter_dispose(MPT_ADAPTER *ioc) { - if (ioc != NULL) { - int sz_first, sz_last; + int sz_first, sz_last; - sz_first = ioc->alloc_total; + if (ioc == NULL) + return; - mpt_adapter_disable(ioc); + sz_first = ioc->alloc_total; - if (ioc->pci_irq != -1) { - free_irq(ioc->pci_irq, ioc); - ioc->pci_irq = -1; - } + mpt_adapter_disable(ioc); - if (ioc->memmap != NULL) - iounmap(ioc->memmap); + if (ioc->pci_irq != -1) { + free_irq(ioc->pci_irq, ioc); + ioc->pci_irq = -1; + } + + if (ioc->memmap != NULL) { + iounmap(ioc->memmap); + ioc->memmap = NULL; + } #if defined(CONFIG_MTRR) && 0 - if (ioc->mtrr_reg > 0) { - mtrr_del(ioc->mtrr_reg, 0, 0); - dprintk((KERN_INFO MYNAM ": %s: MTRR region de-registered\n", ioc->name)); - } + if (ioc->mtrr_reg > 0) { + mtrr_del(ioc->mtrr_reg, 0, 0); + dprintk((KERN_INFO MYNAM ": %s: MTRR region de-registered\n", ioc->name)); + } #endif - /* Zap the adapter lookup ptr! */ - list_del(&ioc->list); + /* Zap the adapter lookup ptr! */ + list_del(&ioc->list); - sz_last = ioc->alloc_total; - dprintk((KERN_INFO MYNAM ": %s: free'd %d of %d bytes\n", - ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first)); - kfree(ioc); - } + sz_last = ioc->alloc_total; + dprintk((KERN_INFO MYNAM ": %s: free'd %d of %d bytes\n", + ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first)); + kfree(ioc); } /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ @@ -1988,7 +1985,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag) } /* Is it already READY? */ - if (!statefault && (ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_READY) + if (!statefault && (ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_READY) return 0; /* @@ -2006,7 +2003,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag) * Hmmm... Did it get left operational? */ if ((ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_OPERATIONAL) { - dinitprintk((MYIOC_s_WARN_FMT "IOC operational unexpected\n", + dinitprintk((MYIOC_s_INFO_FMT "IOC operational unexpected\n", ioc->name)); /* Check WhoInit. @@ -2015,8 +2012,8 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag) * Else, fall through to KickStart case */ whoinit = (ioc_state & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT; - dprintk((KERN_WARNING MYNAM - ": whoinit 0x%x\n statefault %d force %d\n", + dinitprintk((KERN_INFO MYNAM + ": whoinit 0x%x statefault %d force %d\n", whoinit, statefault, force)); if (whoinit == MPI_WHOINIT_PCI_PEER) return -4; @@ -2151,8 +2148,8 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason) get_facts.Function = MPI_FUNCTION_IOC_FACTS; /* Assert: All other get_facts fields are zero! */ - dinitprintk((MYIOC_s_INFO_FMT - "Sending get IocFacts request req_sz=%d reply_sz=%d\n", + dinitprintk((MYIOC_s_INFO_FMT + "Sending get IocFacts request req_sz=%d reply_sz=%d\n", ioc->name, req_sz, reply_sz)); /* No non-zero fields in the get_facts request are greater than @@ -2232,7 +2229,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason) if ( sz & 0x02 ) sz += 2; facts->FWImageSize = sz; - + if (!facts->RequestFrameSize) { /* Something is wrong! */ printk(MYIOC_s_ERR_FMT "IOC reported invalid 0 request size!\n", @@ -2251,7 +2248,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason) ioc->NBShiftFactor = shiftFactor; dinitprintk((MYIOC_s_INFO_FMT "NB_for_64_byte_frame=%x NBShiftFactor=%x BlockSize=%x\n", ioc->name, vv, shiftFactor, r)); - + if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { /* * Set values for this IOC's request & reply frame sizes, @@ -2272,7 +2269,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason) return r; } } else { - printk(MYIOC_s_ERR_FMT + printk(MYIOC_s_ERR_FMT "Invalid IOC facts reply, msgLength=%d offsetof=%zd!\n", ioc->name, facts->MsgLength, (offsetof(IOCFactsReply_t, RequestFrameSize)/sizeof(u32))); @@ -2424,9 +2421,11 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag) dhsprintk((MYIOC_s_INFO_FMT "Sending PortEnable (req @ %p)\n", ioc->name, &ioc_init)); - - if ((r = SendPortEnable(ioc, 0, sleepFlag)) != 0) + + if ((r = SendPortEnable(ioc, 0, sleepFlag)) != 0) { + printk(MYIOC_s_ERR_FMT "Sending PortEnable failed(%d)!\n",ioc->name, r); return r; + } /* YIKES! SUPER IMPORTANT!!! * Poll IocState until _OPERATIONAL while IOC is doing @@ -2451,7 +2450,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag) state = mpt_GetIocState(ioc, 1); count++; } - dhsprintk((MYIOC_s_INFO_FMT "INFO - Wait IOC_OPERATIONAL state (cnt=%d)\n", + dinitprintk((MYIOC_s_INFO_FMT "INFO - Wait IOC_OPERATIONAL state (cnt=%d)\n", ioc->name, count)); return r; @@ -2540,7 +2539,7 @@ mpt_free_fw_memory(MPT_ADAPTER *ioc) int sz; sz = ioc->facts.FWImageSize; - dinitprintk((KERN_WARNING MYNAM "free_fw_memory: FW Image @ %p[%p], sz=%d[%x] bytes\n", + dinitprintk((KERN_INFO MYNAM "free_fw_memory: FW Image @ %p[%p], sz=%d[%x] bytes\n", ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); pci_free_consistent(ioc->pcidev, sz, ioc->cached_fw, ioc->cached_fw_dma); @@ -2584,9 +2583,9 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) mpt_alloc_fw_memory(ioc, sz); - dinitprintk((KERN_WARNING MYNAM ": FW Image @ %p[%p], sz=%d[%x] bytes\n", + dinitprintk((KERN_INFO MYNAM ": FW Image @ %p[%p], sz=%d[%x] bytes\n", ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); - + if (ioc->cached_fw == NULL) { /* Major Failure. */ @@ -2616,14 +2615,14 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) mpt_add_sge(&request[sgeoffset], flagsLength, ioc->cached_fw_dma); sgeoffset += sizeof(u32) + sizeof(dma_addr_t); - dinitprintk((KERN_WARNING MYNAM "Sending FW Upload (req @ %p) sgeoffset=%d \n", + dinitprintk((KERN_INFO MYNAM ": Sending FW Upload (req @ %p) sgeoffset=%d \n", prequest, sgeoffset)); DBG_DUMP_FW_REQUEST_FRAME(prequest) ii = mpt_handshake_req_reply_wait(ioc, sgeoffset, (u32*)prequest, reply_sz, (u16*)preply, 65 /*seconds*/, sleepFlag); - dinitprintk((KERN_WARNING MYNAM "FW Upload completed rc=%x \n", ii)); + dinitprintk((KERN_INFO MYNAM ": FW Upload completed rc=%x \n", ii)); cmdStatus = -EFAULT; if (ii == 0) { @@ -2638,10 +2637,10 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) cmdStatus = 0; } } - dinitprintk((MYIOC_s_INFO_FMT ": do_upload status %d \n", + dinitprintk((MYIOC_s_INFO_FMT ": do_upload cmdStatus=%d \n", ioc->name, cmdStatus)); - + if (cmdStatus) { ddlprintk((MYIOC_s_INFO_FMT ": fw upload failed, freeing image \n", @@ -2772,8 +2771,8 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag) fwSize = (pExtImage->ImageSize + 3) >> 2; ptrFw = (u32 *)pExtImage; - ddlprintk((MYIOC_s_INFO_FMT "Write Ext Image: 0x%x bytes @ %p load_addr=%x\n", - ioc->name, fwSize*4, ptrFw, load_addr)); + ddlprintk((MYIOC_s_INFO_FMT "Write Ext Image: 0x%x (%d) bytes @ %p load_addr=%x\n", + ioc->name, fwSize*4, fwSize*4, ptrFw, load_addr)); CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, load_addr); while (fwSize--) { @@ -2856,9 +2855,9 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag) * 0 else * * Returns: - * 1 - hard reset, READY - * 0 - no reset due to History bit, READY - * -1 - no reset due to History bit but not READY + * 1 - hard reset, READY + * 0 - no reset due to History bit, READY + * -1 - no reset due to History bit but not READY * OR reset but failed to come READY * -2 - no reset, could not enter DIAG mode * -3 - reset but bad FW bit @@ -3001,7 +3000,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag) * */ CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_DISABLE_ARM); - mdelay (1); + mdelay(1); /* * Now hit the reset bit in the Diagnostic register @@ -3181,7 +3180,7 @@ SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag) u32 state; int cntdn, count; - drsprintk((KERN_WARNING MYNAM ": %s: Sending IOC reset(0x%02x)!\n", + drsprintk((KERN_INFO MYNAM ": %s: Sending IOC reset(0x%02x)!\n", ioc->name, reset_type)); CHIPREG_WRITE32(&ioc->chip->Doorbell, reset_type<reply_frames = (MPT_FRAME_HDR *) mem; ioc->reply_frames_low_dma = (u32) (alloc_dma & 0xFFFFFFFF); + dinitprintk((KERN_INFO MYNAM ": %s ReplyBuffers @ %p[%p]\n", + ioc->name, ioc->reply_frames, (void *)(ulong)alloc_dma)); + alloc_dma += reply_sz; mem += reply_sz; @@ -3393,7 +3395,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc) ioc->req_frames = (MPT_FRAME_HDR *) mem; ioc->req_frames_dma = alloc_dma; - dinitprintk((KERN_INFO MYNAM ": %s.RequestBuffers @ %p[%p]\n", + dinitprintk((KERN_INFO MYNAM ": %s RequestBuffers @ %p[%p]\n", ioc->name, mem, (void *)(ulong)alloc_dma)); ioc->req_frames_low_dma = (u32) (alloc_dma & 0xFFFFFFFF); @@ -3419,7 +3421,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc) ioc->ChainBuffer = mem; ioc->ChainBufferDMA = alloc_dma; - dinitprintk((KERN_INFO MYNAM " :%s.ChainBuffers @ %p(%p)\n", + dinitprintk((KERN_INFO MYNAM " :%s ChainBuffers @ %p(%p)\n", ioc->name, ioc->ChainBuffer, (void *)(ulong)ioc->ChainBufferDMA)); /* Initialize the free chain Q. @@ -3524,7 +3526,7 @@ out_fail: */ static int mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req, - int replyBytes, u16 *u16reply, int maxwait, int sleepFlag) + int replyBytes, u16 *u16reply, int maxwait, int sleepFlag) { MPIDefaultReply_t *mptReply; int failcnt = 0; @@ -3599,7 +3601,7 @@ mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req, */ if (!failcnt && (t = WaitForDoorbellReply(ioc, maxwait, sleepFlag)) < 0) failcnt++; - + dhsprintk((MYIOC_s_INFO_FMT "HandShake reply count=%d%s\n", ioc->name, t, failcnt ? " - MISSING DOORBELL REPLY!" : "")); @@ -3758,7 +3760,7 @@ WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag) } dhsprintk((MYIOC_s_INFO_FMT "WaitCnt=%d First handshake reply word=%08x%s\n", - ioc->name, t, le32_to_cpu(*(u32 *)hs_reply), + ioc->name, t, le32_to_cpu(*(u32 *)hs_reply), failcnt ? " - MISSING DOORBELL HANDSHAKE!" : "")); /* @@ -4133,6 +4135,8 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum) ioc->spi_data.minSyncFactor = MPT_ASYNC; ioc->spi_data.busType = MPT_HOST_BUS_UNKNOWN; rc = 1; + ddvprintk((MYIOC_s_INFO_FMT "Unable to read PortPage0 minSyncFactor=%x\n", + ioc->name, ioc->spi_data.minSyncFactor)); } else { /* Save the Port Page 0 data */ @@ -4142,7 +4146,7 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum) if ( (pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_QAS) == 0 ) { ioc->spi_data.noQas |= MPT_TARGET_NO_NEGO_QAS; - dinitprintk((KERN_INFO MYNAM " :%s noQas due to Capabilities=%x\n", + ddvprintk((KERN_INFO MYNAM " :%s noQas due to Capabilities=%x\n", ioc->name, pPP0->Capabilities)); } ioc->spi_data.maxBusWidth = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_WIDE ? 1 : 0; @@ -4151,6 +4155,8 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum) ioc->spi_data.maxSyncOffset = (u8) (data >> 16); data = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_MIN_SYNC_PERIOD_MASK; ioc->spi_data.minSyncFactor = (u8) (data >> 8); + ddvprintk((MYIOC_s_INFO_FMT "PortPage0 minSyncFactor=%x\n", + ioc->name, ioc->spi_data.minSyncFactor)); } else { ioc->spi_data.maxSyncOffset = 0; ioc->spi_data.minSyncFactor = MPT_ASYNC; @@ -4163,8 +4169,11 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum) if ((ioc->spi_data.busType == MPI_SCSIPORTPAGE0_PHY_SIGNAL_HVD) || (ioc->spi_data.busType == MPI_SCSIPORTPAGE0_PHY_SIGNAL_SE)) { - if (ioc->spi_data.minSyncFactor < MPT_ULTRA) + if (ioc->spi_data.minSyncFactor < MPT_ULTRA) { ioc->spi_data.minSyncFactor = MPT_ULTRA; + ddvprintk((MYIOC_s_INFO_FMT "HVD or SE detected, minSyncFactor=%x\n", + ioc->name, ioc->spi_data.minSyncFactor)); + } } } if (pbuf) { @@ -4591,13 +4600,13 @@ SendEventNotification(MPT_ADAPTER *ioc, u8 EvSwitch) evnp = (EventNotification_t *) mpt_get_msg_frame(mpt_base_index, ioc); if (evnp == NULL) { - dprintk((MYIOC_s_WARN_FMT "Unable to allocate event request frame!\n", + devtprintk((MYIOC_s_WARN_FMT "Unable to allocate event request frame!\n", ioc->name)); return 0; } memset(evnp, 0, sizeof(*evnp)); - dprintk((MYIOC_s_INFO_FMT "Sending EventNotification(%d)\n", ioc->name, EvSwitch)); + devtprintk((MYIOC_s_INFO_FMT "Sending EventNotification (%d) request %p\n", ioc->name, EvSwitch, evnp)); evnp->Function = MPI_FUNCTION_EVENT_NOTIFICATION; evnp->ChainOffset = 0; @@ -4621,8 +4630,10 @@ SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp) EventAck_t *pAck; if ((pAck = (EventAck_t *) mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) { - printk(MYIOC_s_WARN_FMT "Unable to allocate event ACK request frame!\n", - ioc->name); + printk(MYIOC_s_WARN_FMT "Unable to allocate event ACK " + "request frame for Event=%x EventContext=%x EventData=%x!\n", + ioc->name, evnp->Event, le32_to_cpu(evnp->EventContext), + le32_to_cpu(evnp->Data[0])); return -1; } memset(pAck, 0, sizeof(*pAck)); @@ -5538,6 +5549,8 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply * If needed, send (a single) EventAck. */ if (pEventReply->AckRequired == MPI_EVENT_NOTIFICATION_ACK_REQUIRED) { + devtprintk((MYIOC_s_WARN_FMT + "EventAck required\n",ioc->name)); if ((ii = SendEventAck(ioc, pEventReply)) != 0) { devtprintk((MYIOC_s_WARN_FMT "SendEventAck returned %d\n", ioc->name, ii)); @@ -5618,7 +5631,7 @@ mpt_sp_log_info(MPT_ADAPTER *ioc, u32 log_info) case 0x00080000: desc = "Outbound DMA Overrun"; break; - + case 0x00090000: desc = "Task Management"; break; @@ -5634,7 +5647,7 @@ mpt_sp_log_info(MPT_ADAPTER *ioc, u32 log_info) case 0x000C0000: desc = "Untagged Table Size"; break; - + } printk(MYIOC_s_INFO_FMT "LogInfo(0x%08x): F/W: %s\n", ioc->name, log_info, desc); @@ -5726,7 +5739,7 @@ mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf) break; case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: /* 0x0045 */ - /* This error is checked in scsi_io_done(). Skip. + /* This error is checked in scsi_io_done(). Skip. desc = "SCSI Data Underrun"; */ break; diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index cd4e8c0853d..4a003dc5fde 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -281,12 +281,12 @@ mptscsih_getFreeChainBuffer(MPT_ADAPTER *ioc, int *retIndex) offset = (u8 *)chainBuf - (u8 *)ioc->ChainBuffer; chain_idx = offset / ioc->req_sz; rc = SUCCESS; - dsgprintk((MYIOC_s_INFO_FMT "getFreeChainBuffer (index %d), got buf=%p\n", - ioc->name, *retIndex, chainBuf)); + dsgprintk((MYIOC_s_ERR_FMT "getFreeChainBuffer chainBuf=%p ChainBuffer=%p offset=%d chain_idx=%d\n", + ioc->name, chainBuf, ioc->ChainBuffer, offset, chain_idx)); } else { rc = FAILED; chain_idx = MPT_HOST_NO_CHAIN; - dfailprintk((MYIOC_s_ERR_FMT "getFreeChainBuffer failed\n", + dfailprintk((MYIOC_s_INFO_FMT "getFreeChainBuffer failed\n", ioc->name)); } spin_unlock_irqrestore(&ioc->FreeQlock, flags); @@ -432,7 +432,7 @@ nextSGEset: */ pReq->ChainOffset = 0; RequestNB = (((sgeOffset - 1) >> ioc->NBShiftFactor) + 1) & 0x03; - dsgprintk((MYIOC_s_ERR_FMT + dsgprintk((MYIOC_s_INFO_FMT "Single Buffer RequestNB=%x, sgeOffset=%d\n", ioc->name, RequestNB, sgeOffset)); ioc->RequestNB[req_idx] = RequestNB; } @@ -491,11 +491,12 @@ nextSGEset: /* NOTE: psge points to the beginning of the chain element * in current buffer. Get a chain buffer. */ - dsgprintk((MYIOC_s_INFO_FMT - "calling getFreeChainBuffer SCSI cmd=%02x (%p)\n", - ioc->name, pReq->CDB[0], SCpnt)); - if ((mptscsih_getFreeChainBuffer(ioc, &newIndex)) == FAILED) + if ((mptscsih_getFreeChainBuffer(ioc, &newIndex)) == FAILED) { + dfailprintk((MYIOC_s_INFO_FMT + "getFreeChainBuffer FAILED SCSI cmd=%02x (%p)\n", + ioc->name, pReq->CDB[0], SCpnt)); return FAILED; + } /* Update the tracking arrays. * If chainSge == NULL, update ReqToChain, else ChainToChain @@ -577,14 +578,20 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) return 1; } - dmfprintk((MYIOC_s_INFO_FMT - "ScsiDone (mf=%p,mr=%p,sc=%p,idx=%d)\n", - ioc->name, mf, mr, sc, req_idx)); - sc->result = DID_OK << 16; /* Set default reply as OK */ pScsiReq = (SCSIIORequest_t *) mf; pScsiReply = (SCSIIOReply_t *) mr; + if((ioc->facts.MsgVersion >= MPI_VERSION_01_05) && pScsiReply){ + dmfprintk((MYIOC_s_INFO_FMT + "ScsiDone (mf=%p,mr=%p,sc=%p,idx=%d,task-tag=%d)\n", + ioc->name, mf, mr, sc, req_idx, pScsiReply->TaskTag)); + }else{ + dmfprintk((MYIOC_s_INFO_FMT + "ScsiDone (mf=%p,mr=%p,sc=%p,idx=%d)\n", + ioc->name, mf, mr, sc, req_idx)); + } + if (pScsiReply == NULL) { /* special context reply handling */ ; @@ -658,8 +665,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) /* Sufficient data transfer occurred */ sc->result = (DID_OK << 16) | scsi_status; } else if ( xfer_cnt == 0 ) { - /* A CRC Error causes this condition; retry */ - sc->result = (DRIVER_SENSE << 24) | (DID_OK << 16) | + /* A CRC Error causes this condition; retry */ + sc->result = (DRIVER_SENSE << 24) | (DID_OK << 16) | (CHECK_CONDITION << 1); sc->sense_buffer[0] = 0x70; sc->sense_buffer[2] = NO_SENSE; @@ -668,7 +675,9 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) } else { sc->result = DID_SOFT_ERROR << 16; } - dreplyprintk((KERN_NOTICE "RESIDUAL_MISMATCH: result=%x on id=%d\n", sc->result, sc->target)); + dreplyprintk((KERN_NOTICE + "RESIDUAL_MISMATCH: result=%x on id=%d\n", + sc->result, sc->device->id)); break; case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: /* 0x0045 */ @@ -796,7 +805,6 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) return 1; } - /* * mptscsih_flush_running_cmds - For each command found, search * Scsi_Host instance taskQ and reply to OS. @@ -1017,7 +1025,7 @@ mptscsih_remove(struct pci_dev *pdev) scsi_host_put(host); mpt_detach(pdev); - + } /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ @@ -1072,7 +1080,7 @@ mptscsih_resume(struct pci_dev *pdev) MPT_SCSI_HOST *hd; mpt_resume(pdev); - + if(!host) return 0; @@ -1214,8 +1222,8 @@ mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t off int size = 0; if (func) { - /* - * write is not supported + /* + * write is not supported */ } else { if (start) @@ -1535,17 +1543,17 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, in */ if (mptscsih_tm_pending_wait(hd) == FAILED) { if (type == MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK) { - dtmprintk((KERN_WARNING MYNAM ": %s: TMHandler abort: " + dtmprintk((KERN_INFO MYNAM ": %s: TMHandler abort: " "Timed out waiting for last TM (%d) to complete! \n", hd->ioc->name, hd->tmPending)); return FAILED; } else if (type == MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET) { - dtmprintk((KERN_WARNING MYNAM ": %s: TMHandler target reset: " + dtmprintk((KERN_INFO MYNAM ": %s: TMHandler target reset: " "Timed out waiting for last TM (%d) to complete! \n", hd->ioc->name, hd->tmPending)); return FAILED; } else if (type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS) { - dtmprintk((KERN_WARNING MYNAM ": %s: TMHandler bus reset: " + dtmprintk((KERN_INFO MYNAM ": %s: TMHandler bus reset: " "Timed out waiting for last TM (%d) to complete! \n", hd->ioc->name, hd->tmPending)); if (hd->tmPending & (1 << MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS)) @@ -1631,8 +1639,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun if ((mf = mpt_get_msg_frame(hd->ioc->TaskCtx, hd->ioc)) == NULL) { dfailprintk((MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n", hd->ioc->name)); - //return FAILED; - return -999; + return FAILED; } dtmprintk((MYIOC_s_INFO_FMT "IssueTaskMgmt request @ %p\n", hd->ioc->name, mf)); @@ -1661,9 +1668,8 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun pScsiTm->TaskMsgContext = ctx2abort; - dtmprintk((MYIOC_s_INFO_FMT - "IssueTaskMgmt: ctx2abort (0x%08x) type=%d\n", - hd->ioc->name, ctx2abort, type)); + dtmprintk((MYIOC_s_INFO_FMT "IssueTaskMgmt: ctx2abort (0x%08x) type=%d\n", + hd->ioc->name, ctx2abort, type)); DBG_DUMP_TM_REQUEST_FRAME((u32 *)pScsiTm); @@ -1902,13 +1908,13 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt) /* If we can't locate the host to reset, then we failed. */ if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ - dtmprintk( ( KERN_WARNING MYNAM ": mptscsih_host_reset: " + dtmprintk( ( KERN_INFO MYNAM ": mptscsih_host_reset: " "Can't locate host! (sc=%p)\n", SCpnt ) ); return FAILED; } - printk(KERN_WARNING MYNAM ": %s: >> Attempting host reset! (sc=%p)\n", + printk(KERN_WARNING MYNAM ": %s: Attempting host reset! (sc=%p)\n", hd->ioc->name, SCpnt); /* If our attempts to reset the host failed, then return a failed @@ -1924,7 +1930,7 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt) hd->tmState = TM_STATE_NONE; } - dtmprintk( ( KERN_WARNING MYNAM ": mptscsih_host_reset: " + dtmprintk( ( KERN_INFO MYNAM ": mptscsih_host_reset: " "Status = %s\n", (status == SUCCESS) ? "SUCCESS" : "FAILED" ) ); @@ -1951,8 +1957,8 @@ mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd) if (hd->tmState == TM_STATE_NONE) { hd->tmState = TM_STATE_IN_PROGRESS; hd->tmPending = 1; - status = SUCCESS; spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); + status = SUCCESS; break; } spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); @@ -1980,7 +1986,7 @@ mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ) spin_lock_irqsave(&hd->ioc->FreeQlock, flags); if(hd->tmPending == 0) { status = SUCCESS; - spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); + spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); break; } spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); @@ -2318,10 +2324,10 @@ mptscsih_slave_configure(struct scsi_device *device) if (pTarget == NULL) { /* Driver doesn't know about this device. * Kernel may generate a "Dummy Lun 0" which - * may become a real Lun if a + * may become a real Lun if a * "scsi add-single-device" command is executed - * while the driver is active (hot-plug a - * device). LSI Raid controllers need + * while the driver is active (hot-plug a + * device). LSI Raid controllers need * queue_depth set to DEV_HIGH for this reason. */ scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG, @@ -2691,7 +2697,7 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char * * If the peripheral qualifier filter is enabled then if the target reports a 0x1 * (i.e. The targer is capable of supporting the specified peripheral device type * on this logical unit; however, the physical device is not currently connected - * to this logical unit) it will be converted to a 0x3 (i.e. The target is not + * to this logical unit) it will be converted to a 0x3 (i.e. The target is not * capable of supporting a physical device on this logical unit). This is to work * around a bug in th emid-layer in some distributions in which the mid-layer will * continue to try to communicate to the LUN and evntually create a dummy LUN. @@ -3194,8 +3200,8 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags) /* Get a MF for this command. */ if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) { - dprintk((MYIOC_s_WARN_FMT "write SDP1: no msg frames!\n", - ioc->name)); + dfailprintk((MYIOC_s_WARN_FMT "write SDP1: no msg frames!\n", + ioc->name)); return -EAGAIN; } @@ -3289,7 +3295,7 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus) /* Get a MF for this command. */ if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) { - dprintk((MYIOC_s_WARN_FMT "writeIOCPage4 : no msg frames!\n", + dfailprintk((MYIOC_s_WARN_FMT "writeIOCPage4 : no msg frames!\n", ioc->name)); return -EAGAIN; } @@ -4596,8 +4602,8 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) if ((pbuf1[56] & 0x02) == 0) { pTarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS; hd->ioc->spi_data.noQas = MPT_TARGET_NO_NEGO_QAS; - ddvprintk((MYIOC_s_NOTE_FMT - "DV: Start Basic noQas on id=%d due to pbuf1[56]=%x\n", + ddvprintk((MYIOC_s_NOTE_FMT + "DV: Start Basic noQas on id=%d due to pbuf1[56]=%x\n", ioc->name, id, pbuf1[56])); } } @@ -4673,7 +4679,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) if (!firstPass) doFallback = 1; } else { - ddvprintk((MYIOC_s_NOTE_FMT + ddvprintk((MYIOC_s_NOTE_FMT "DV:Inquiry compared id=%d, calling initTarget\n", ioc->name, id)); hd->ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_DV_NOT_DONE; mptscsih_initTarget(hd, @@ -4689,8 +4695,8 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) } else if (rc == MPT_SCANDV_ISSUE_SENSE) doFallback = 1; /* set fallback flag */ - else if ((rc == MPT_SCANDV_DID_RESET) || - (rc == MPT_SCANDV_SENSE) || + else if ((rc == MPT_SCANDV_DID_RESET) || + (rc == MPT_SCANDV_SENSE) || (rc == MPT_SCANDV_FALLBACK)) doFallback = 1; /* set fallback flag */ else @@ -5126,7 +5132,7 @@ target_done: */ if ((inq0 == 0) && (dv.now.factor > MPT_ULTRA320)) { hd->ioc->spi_data.noQas = MPT_TARGET_NO_NEGO_QAS; - ddvprintk((MYIOC_s_NOTE_FMT + ddvprintk((MYIOC_s_NOTE_FMT "noQas set due to id=%d has factor=%x\n", ioc->name, id, dv.now.factor)); } diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index dfa8806b1e1..587d1274fd7 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c @@ -162,15 +162,15 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) u8 *mem; int error=0; int r; - + if ((r = mpt_attach(pdev,id)) != 0) return r; - + ioc = pci_get_drvdata(pdev); ioc->DoneCtx = mptspiDoneCtx; ioc->TaskCtx = mptspiTaskCtx; ioc->InternalCtx = mptspiInternalCtx; - + /* Added sanity check on readiness of the MPT adapter. */ if (ioc->last_state != MPI_IOC_STATE_OPERATIONAL) { -- cgit v1.2.3-18-g5258 From 7524f9b9e72cd36f0a70defcd424eba81c180f42 Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:08:00 -0700 Subject: [SCSI] qla2xxx: Use dma_get_required_mask() in determining the 'ideal' DMA mask. In order to efficiently utilise the ISP's IOCB request-queue, use the dma_get_required_mask() function to determine the use of command-type 2 or 3 IOCBs when queueing SCSI commands. This applies to ISP2[123]xx chips only, as the ISP24xx uses command-type 7 IOCBs which use 64bit DSDs. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_os.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 9000659bfbc..995e521b07d 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1113,36 +1113,23 @@ qla2xxx_slave_destroy(struct scsi_device *sdev) static void qla2x00_config_dma_addressing(scsi_qla_host_t *ha) { - /* Assume 32bit DMA address */ + /* Assume a 32bit DMA mask. */ ha->flags.enable_64bit_addressing = 0; - /* - * Given the two variants pci_set_dma_mask(), allow the compiler to - * assist in setting the proper dma mask. - */ - if (sizeof(dma_addr_t) > 4) { - if (pci_set_dma_mask(ha->pdev, DMA_64BIT_MASK) == 0) { + if (!dma_set_mask(&ha->pdev->dev, DMA_64BIT_MASK)) { + /* Any upper-dword bits set? */ + if (MSD(dma_get_required_mask(&ha->pdev->dev)) && + !pci_set_consistent_dma_mask(ha->pdev, DMA_64BIT_MASK)) { + /* Ok, a 64bit DMA mask is applicable. */ ha->flags.enable_64bit_addressing = 1; ha->isp_ops.calc_req_entries = qla2x00_calc_iocbs_64; ha->isp_ops.build_iocbs = qla2x00_build_scsi_iocbs_64; - - if (pci_set_consistent_dma_mask(ha->pdev, - DMA_64BIT_MASK)) { - qla_printk(KERN_DEBUG, ha, - "Failed to set 64 bit PCI consistent mask; " - "using 32 bit.\n"); - pci_set_consistent_dma_mask(ha->pdev, - DMA_32BIT_MASK); - } - } else { - qla_printk(KERN_DEBUG, ha, - "Failed to set 64 bit PCI DMA mask, falling back " - "to 32 bit MASK.\n"); - pci_set_dma_mask(ha->pdev, DMA_32BIT_MASK); + return; } - } else { - pci_set_dma_mask(ha->pdev, DMA_32BIT_MASK); } + + dma_set_mask(&ha->pdev->dev, DMA_32BIT_MASK); + pci_set_consistent_dma_mask(ha->pdev, DMA_32BIT_MASK); } static int -- cgit v1.2.3-18-g5258 From ad3e0edaceb9771be7ffbd7aa24fb444a7ed85bf Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:08:10 -0700 Subject: [SCSI] qla2xxx: Export class-of-service (COS) information. Export COS information for the fc_host and fc_remote_port objects added by the driver. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_attr.c | 4 ++++ drivers/scsi/qla2xxx/qla_def.h | 1 + drivers/scsi/qla2xxx/qla_init.c | 7 +++++++ drivers/scsi/qla2xxx/qla_mbx.c | 14 ++++++++++++++ 4 files changed, 26 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 659a5d63467..d05280eecc6 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -304,10 +304,13 @@ struct fc_function_template qla2xxx_transport_functions = { .show_host_node_name = 1, .show_host_port_name = 1, + .show_host_supported_classes = 1, + .get_host_port_id = qla2x00_get_host_port_id, .show_host_port_id = 1, .dd_fcrport_size = sizeof(struct fc_port *), + .show_rport_supported_classes = 1, .get_starget_node_name = qla2x00_get_starget_node_name, .show_starget_node_name = 1, @@ -329,4 +332,5 @@ qla2x00_init_host_attr(scsi_qla_host_t *ha) be64_to_cpu(*(uint64_t *)ha->init_cb->node_name); fc_host_port_name(ha->host) = be64_to_cpu(*(uint64_t *)ha->init_cb->port_name); + fc_host_supported_classes(ha->host) = FC_COS_CLASS3; } diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 1c6d366f4fa..38848c38ad8 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -1673,6 +1673,7 @@ typedef struct fc_port { uint8_t cur_path; /* current path id */ struct fc_rport *rport; + u32 supported_classes; } fc_port_t; /* diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index a6d2559217c..09b23f70fd6 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -1697,6 +1697,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, int flags) fcport->iodesc_idx_sent = IODESC_INVALID_INDEX; atomic_set(&fcport->state, FCS_UNCONFIGURED); fcport->flags = FCF_RLC_SUPPORT; + fcport->supported_classes = FC_COS_UNSPECIFIED; return (fcport); } @@ -2075,6 +2076,7 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) return; } rport->dd_data = fcport; + rport->supported_classes = fcport->supported_classes; rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; if (fcport->port_type == FCT_INITIATOR) @@ -2794,6 +2796,11 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport, } } + if (mb[10] & BIT_0) + fcport->supported_classes |= FC_COS_CLASS2; + if (mb[10] & BIT_1) + fcport->supported_classes |= FC_COS_CLASS3; + rval = QLA_SUCCESS; break; } else if (mb[0] == MBS_LOOP_ID_USED) { diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 409ea0ac403..774309a77c0 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -19,6 +19,7 @@ #include "qla_def.h" #include +#include static void qla2x00_mbx_sem_timeout(unsigned long data) @@ -1326,6 +1327,10 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt) fcport->port_type = FCT_INITIATOR; else fcport->port_type = FCT_TARGET; + + /* Passback COS information. */ + fcport->supported_classes = (pd->options & BIT_4) ? + FC_COS_CLASS2: FC_COS_CLASS3; } gpd_error_out: @@ -1661,6 +1666,13 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain, mb[1] |= BIT_1; } else mb[1] = BIT_0; + + /* Passback COS information. */ + mb[10] = 0; + if (lg->io_parameter[7] || lg->io_parameter[8]) + mb[10] |= BIT_0; /* Class 2. */ + if (lg->io_parameter[9] || lg->io_parameter[10]) + mb[10] |= BIT_1; /* Class 3. */ } dma_pool_free(ha->s_dma_pool, lg, lg_dma); @@ -1723,6 +1735,8 @@ qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain, mb[2] = mcp->mb[2]; mb[6] = mcp->mb[6]; mb[7] = mcp->mb[7]; + /* COS retrieved from Get-Port-Database mailbox command. */ + mb[10] = 0; } if (rval != QLA_SUCCESS) { -- cgit v1.2.3-18-g5258 From cca5335caf2d19ef8bd6b833445d2c6ca652a89b Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:08:30 -0700 Subject: [SCSI] qla2xxx: Add FDMI support. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_dbg.h | 7 + drivers/scsi/qla2xxx/qla_def.h | 151 ++++++++++- drivers/scsi/qla2xxx/qla_gbl.h | 4 + drivers/scsi/qla2xxx/qla_gs.c | 564 ++++++++++++++++++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_init.c | 6 + drivers/scsi/qla2xxx/qla_isr.c | 2 + drivers/scsi/qla2xxx/qla_mbx.c | 2 +- drivers/scsi/qla2xxx/qla_os.c | 10 + 8 files changed, 741 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_dbg.h b/drivers/scsi/qla2xxx/qla_dbg.h index b8d90e97e01..9684e7a91fa 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.h +++ b/drivers/scsi/qla2xxx/qla_dbg.h @@ -81,6 +81,7 @@ #define DEBUG2_3_11(x) do {x;} while (0); #define DEBUG2_9_10(x) do {x;} while (0); #define DEBUG2_11(x) do {x;} while (0); +#define DEBUG2_13(x) do {x;} while (0); #else #define DEBUG2(x) do {} while (0); #endif @@ -169,8 +170,14 @@ #if defined(QL_DEBUG_LEVEL_13) #define DEBUG13(x) do {x;} while (0) +#if !defined(DEBUG2_13) +#define DEBUG2_13(x) do {x;} while(0) +#endif #else #define DEBUG13(x) do {} while (0) +#if !defined(QL_DEBUG_LEVEL_2) +#define DEBUG2_13(x) do {} while(0) +#endif #endif #if defined(QL_DEBUG_LEVEL_14) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 38848c38ad8..cdef86e49c6 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -214,6 +214,7 @@ * valid range of an N-PORT id is 0 through 0x7ef. */ #define NPH_LAST_HANDLE 0x7ef +#define NPH_MGMT_SERVER 0x7fa /* FFFFFA */ #define NPH_SNS 0x7fc /* FFFFFC */ #define NPH_FABRIC_CONTROLLER 0x7fd /* FFFFFD */ #define NPH_F_PORT 0x7fe /* FFFFFE */ @@ -1131,10 +1132,7 @@ typedef struct { uint8_t link_down_timeout; - uint8_t adapter_id_0[4]; - uint8_t adapter_id_1[4]; - uint8_t adapter_id_2[4]; - uint8_t adapter_id_3[4]; + uint8_t adapter_id[16]; uint8_t alt1_boot_node_name[WWN_SIZE]; uint16_t alt1_boot_lun_number; @@ -1728,6 +1726,8 @@ typedef struct fc_port { #define CT_REJECT_RESPONSE 0x8001 #define CT_ACCEPT_RESPONSE 0x8002 +#define CT_REASON_CANNOT_PERFORM 0x09 +#define CT_EXPL_ALREADY_REGISTERED 0x10 #define NS_N_PORT_TYPE 0x01 #define NS_NL_PORT_TYPE 0x02 @@ -1769,6 +1769,100 @@ typedef struct fc_port { #define RSNN_NN_REQ_SIZE (16 + 8 + 1 + 255) #define RSNN_NN_RSP_SIZE 16 +/* + * HBA attribute types. + */ +#define FDMI_HBA_ATTR_COUNT 9 +#define FDMI_HBA_NODE_NAME 1 +#define FDMI_HBA_MANUFACTURER 2 +#define FDMI_HBA_SERIAL_NUMBER 3 +#define FDMI_HBA_MODEL 4 +#define FDMI_HBA_MODEL_DESCRIPTION 5 +#define FDMI_HBA_HARDWARE_VERSION 6 +#define FDMI_HBA_DRIVER_VERSION 7 +#define FDMI_HBA_OPTION_ROM_VERSION 8 +#define FDMI_HBA_FIRMWARE_VERSION 9 +#define FDMI_HBA_OS_NAME_AND_VERSION 0xa +#define FDMI_HBA_MAXIMUM_CT_PAYLOAD_LENGTH 0xb + +struct ct_fdmi_hba_attr { + uint16_t type; + uint16_t len; + union { + uint8_t node_name[WWN_SIZE]; + uint8_t manufacturer[32]; + uint8_t serial_num[8]; + uint8_t model[16]; + uint8_t model_desc[80]; + uint8_t hw_version[16]; + uint8_t driver_version[32]; + uint8_t orom_version[16]; + uint8_t fw_version[16]; + uint8_t os_version[128]; + uint8_t max_ct_len[4]; + } a; +}; + +struct ct_fdmi_hba_attributes { + uint32_t count; + struct ct_fdmi_hba_attr entry[FDMI_HBA_ATTR_COUNT]; +}; + +/* + * Port attribute types. + */ +#define FDMI_PORT_ATTR_COUNT 5 +#define FDMI_PORT_FC4_TYPES 1 +#define FDMI_PORT_SUPPORT_SPEED 2 +#define FDMI_PORT_CURRENT_SPEED 3 +#define FDMI_PORT_MAX_FRAME_SIZE 4 +#define FDMI_PORT_OS_DEVICE_NAME 5 +#define FDMI_PORT_HOST_NAME 6 + +struct ct_fdmi_port_attr { + uint16_t type; + uint16_t len; + union { + uint8_t fc4_types[32]; + uint32_t sup_speed; + uint32_t cur_speed; + uint32_t max_frame_size; + uint8_t os_dev_name[32]; + uint8_t host_name[32]; + } a; +}; + +/* + * Port Attribute Block. + */ +struct ct_fdmi_port_attributes { + uint32_t count; + struct ct_fdmi_port_attr entry[FDMI_PORT_ATTR_COUNT]; +}; + +/* FDMI definitions. */ +#define GRHL_CMD 0x100 +#define GHAT_CMD 0x101 +#define GRPL_CMD 0x102 +#define GPAT_CMD 0x110 + +#define RHBA_CMD 0x200 +#define RHBA_RSP_SIZE 16 + +#define RHAT_CMD 0x201 +#define RPRT_CMD 0x210 + +#define RPA_CMD 0x211 +#define RPA_RSP_SIZE 16 + +#define DHBA_CMD 0x300 +#define DHBA_REQ_SIZE (16 + 8) +#define DHBA_RSP_SIZE 16 + +#define DHAT_CMD 0x301 +#define DPRT_CMD 0x310 +#define DPA_CMD 0x311 + /* CT command header -- request/response common fields */ struct ct_cmd_hdr { uint8_t revision; @@ -1826,6 +1920,43 @@ struct ct_sns_req { uint8_t name_len; uint8_t sym_node_name[255]; } rsnn_nn; + + struct { + uint8_t hba_indentifier[8]; + } ghat; + + struct { + uint8_t hba_identifier[8]; + uint32_t entry_count; + uint8_t port_name[8]; + struct ct_fdmi_hba_attributes attrs; + } rhba; + + struct { + uint8_t hba_identifier[8]; + struct ct_fdmi_hba_attributes attrs; + } rhat; + + struct { + uint8_t port_name[8]; + struct ct_fdmi_port_attributes attrs; + } rpa; + + struct { + uint8_t port_name[8]; + } dhba; + + struct { + uint8_t port_name[8]; + } dhat; + + struct { + uint8_t port_name[8]; + } dprt; + + struct { + uint8_t port_name[8]; + } dpa; } req; }; @@ -1883,6 +2014,12 @@ struct ct_sns_rsp { struct { uint8_t fc4_types[32]; } gft_id; + + struct { + uint32_t entry_count; + uint8_t port_name[8]; + struct ct_fdmi_hba_attributes attrs; + } ghat; } rsp; }; @@ -2033,6 +2170,8 @@ struct isp_operations { uint16_t (*calc_req_entries) (uint16_t); void (*build_iocbs) (srb_t *, cmd_entry_t *, uint16_t); void * (*prep_ms_iocb) (struct scsi_qla_host *, uint32_t, uint32_t); + void * (*prep_ms_fdmi_iocb) (struct scsi_qla_host *, uint32_t, + uint32_t); uint8_t * (*read_nvram) (struct scsi_qla_host *, uint8_t *, uint32_t, uint32_t); @@ -2112,6 +2251,7 @@ typedef struct scsi_qla_host { #define IOCTL_ERROR_RECOVERY 23 #define LOOP_RESET_NEEDED 24 #define BEACON_BLINK_NEEDED 25 +#define REGISTER_FDMI_NEEDED 26 uint32_t device_flags; #define DFLG_LOCAL_DEVICES BIT_0 @@ -2205,6 +2345,7 @@ typedef struct scsi_qla_host { int port_down_retry_count; uint8_t mbx_count; uint16_t last_loop_id; + uint16_t mgmt_svr_loop_id; uint32_t login_retry_count; @@ -2319,6 +2460,7 @@ typedef struct scsi_qla_host { uint8_t model_number[16+1]; #define BINZERO "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" char *model_desc; + uint8_t adapter_id[16+1]; uint8_t *node_name; uint8_t *port_name; @@ -2378,6 +2520,7 @@ typedef struct scsi_qla_host { #define QLA_SUSPENDED 0x106 #define QLA_BUSY 0x107 #define QLA_RSCNS_HANDLED 0x108 +#define QLA_ALREADY_REGISTERED 0x109 /* * Stat info for all adpaters diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 665c203e067..3e1e5fe850a 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -79,6 +79,7 @@ extern int ql2xplogiabsentdevice; extern int ql2xenablezio; extern int ql2xintrdelaytimer; extern int ql2xloginretrycount; +extern int ql2xfdmienable; extern void qla2x00_sp_compl(scsi_qla_host_t *, srb_t *); @@ -269,6 +270,9 @@ extern int qla2x00_rft_id(scsi_qla_host_t *); extern int qla2x00_rff_id(scsi_qla_host_t *); extern int qla2x00_rnn_id(scsi_qla_host_t *); extern int qla2x00_rsnn_nn(scsi_qla_host_t *); +extern void *qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *, uint32_t, uint32_t); +extern void *qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *, uint32_t, uint32_t); +extern int qla2x00_fdmi_register(scsi_qla_host_t *); /* * Global Function Prototypes in qla_rscn.c source file. diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index 31ce4f62da1..e7b138c2e33 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -1099,3 +1099,567 @@ qla2x00_sns_rnn_id(scsi_qla_host_t *ha) return (rval); } + +/** + * qla2x00_mgmt_svr_login() - Login to fabric Managment Service. + * @ha: HA context + * + * Returns 0 on success. + */ +static int +qla2x00_mgmt_svr_login(scsi_qla_host_t *ha) +{ + int ret; + uint16_t mb[MAILBOX_REGISTER_COUNT]; + + ret = QLA_SUCCESS; + if (ha->flags.management_server_logged_in) + return ret; + + ha->isp_ops.fabric_login(ha, ha->mgmt_svr_loop_id, 0xff, 0xff, 0xfa, + mb, BIT_1); + if (mb[0] != MBS_COMMAND_COMPLETE) { + DEBUG2_13(printk("%s(%ld): Failed MANAGEMENT_SERVER login: " + "loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x\n", + __func__, ha->host_no, ha->mgmt_svr_loop_id, mb[0], mb[1], + mb[2], mb[6], mb[7])); + ret = QLA_FUNCTION_FAILED; + } else + ha->flags.management_server_logged_in = 1; + + return ret; +} + +/** + * qla2x00_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query. + * @ha: HA context + * @req_size: request size in bytes + * @rsp_size: response size in bytes + * + * Returns a pointer to the @ha's ms_iocb. + */ +void * +qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size, + uint32_t rsp_size) +{ + ms_iocb_entry_t *ms_pkt; + + ms_pkt = ha->ms_iocb; + memset(ms_pkt, 0, sizeof(ms_iocb_entry_t)); + + ms_pkt->entry_type = MS_IOCB_TYPE; + ms_pkt->entry_count = 1; + SET_TARGET_ID(ha, ms_pkt->loop_id, ha->mgmt_svr_loop_id); + ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG); + ms_pkt->timeout = __constant_cpu_to_le16(59); + ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); + ms_pkt->total_dsd_count = __constant_cpu_to_le16(2); + ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size); + ms_pkt->req_bytecount = cpu_to_le32(req_size); + + ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); + ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); + ms_pkt->dseg_req_length = ms_pkt->req_bytecount; + + ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); + ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); + ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount; + + return ms_pkt; +} + +/** + * qla24xx_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query. + * @ha: HA context + * @req_size: request size in bytes + * @rsp_size: response size in bytes + * + * Returns a pointer to the @ha's ms_iocb. + */ +void * +qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size, + uint32_t rsp_size) +{ + struct ct_entry_24xx *ct_pkt; + + ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; + memset(ct_pkt, 0, sizeof(struct ct_entry_24xx)); + + ct_pkt->entry_type = CT_IOCB_TYPE; + ct_pkt->entry_count = 1; + ct_pkt->nport_handle = cpu_to_le16(ha->mgmt_svr_loop_id); + ct_pkt->timeout = __constant_cpu_to_le16(59); + ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); + ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1); + ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size); + ct_pkt->cmd_byte_count = cpu_to_le32(req_size); + + ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); + ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); + ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; + + ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); + ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); + ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; + + return ct_pkt; +} + +static inline ms_iocb_entry_t * +qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size) +{ + ms_iocb_entry_t *ms_pkt = ha->ms_iocb; + struct ct_entry_24xx *ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; + + if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) { + ct_pkt->cmd_byte_count = cpu_to_le32(req_size); + ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; + } else { + ms_pkt->req_bytecount = cpu_to_le32(req_size); + ms_pkt->dseg_req_length = ms_pkt->req_bytecount; + } + + return ms_pkt; +} + +/** + * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query. + * @ct_req: CT request buffer + * @cmd: GS command + * @rsp_size: response size in bytes + * + * Returns a pointer to the intitialized @ct_req. + */ +static inline struct ct_sns_req * +qla2x00_prep_ct_fdmi_req(struct ct_sns_req *ct_req, uint16_t cmd, + uint16_t rsp_size) +{ + memset(ct_req, 0, sizeof(struct ct_sns_pkt)); + + ct_req->header.revision = 0x01; + ct_req->header.gs_type = 0xFA; + ct_req->header.gs_subtype = 0x10; + ct_req->command = cpu_to_be16(cmd); + ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); + + return ct_req; +} + +/** + * qla2x00_fdmi_rhba() - + * @ha: HA context + * + * Returns 0 on success. + */ +static int +qla2x00_fdmi_rhba(scsi_qla_host_t *ha) +{ + int rval, alen; + uint32_t size, sn; + + ms_iocb_entry_t *ms_pkt; + struct ct_sns_req *ct_req; + struct ct_sns_rsp *ct_rsp; + uint8_t *entries; + struct ct_fdmi_hba_attr *eiter; + + /* Issue RHBA */ + /* Prepare common MS IOCB */ + /* Request size adjusted after CT preparation */ + ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, 0, RHBA_RSP_SIZE); + + /* Prepare CT request */ + ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD, + RHBA_RSP_SIZE); + ct_rsp = &ha->ct_sns->p.rsp; + + /* Prepare FDMI command arguments -- attribute block, attributes. */ + memcpy(ct_req->req.rhba.hba_identifier, ha->port_name, WWN_SIZE); + ct_req->req.rhba.entry_count = __constant_cpu_to_be32(1); + memcpy(ct_req->req.rhba.port_name, ha->port_name, WWN_SIZE); + size = 2 * WWN_SIZE + 4 + 4; + + /* Attributes */ + ct_req->req.rhba.attrs.count = + __constant_cpu_to_be32(FDMI_HBA_ATTR_COUNT); + entries = ct_req->req.rhba.hba_identifier; + + /* Nodename. */ + eiter = (struct ct_fdmi_hba_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_HBA_NODE_NAME); + eiter->len = __constant_cpu_to_be16(4 + WWN_SIZE); + memcpy(eiter->a.node_name, ha->node_name, WWN_SIZE); + size += 4 + WWN_SIZE; + + DEBUG13(printk("%s(%ld): NODENAME=%02x%02x%02x%02x%02x%02x%02x%02x.\n", + __func__, ha->host_no, + eiter->a.node_name[0], eiter->a.node_name[1], eiter->a.node_name[2], + eiter->a.node_name[3], eiter->a.node_name[4], eiter->a.node_name[5], + eiter->a.node_name[6], eiter->a.node_name[7])); + + /* Manufacturer. */ + eiter = (struct ct_fdmi_hba_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER); + strcpy(eiter->a.manufacturer, "QLogic Corporation"); + alen = strlen(eiter->a.manufacturer); + alen += (alen & 3) ? (4 - (alen & 3)) : 4; + eiter->len = cpu_to_be16(4 + alen); + size += 4 + alen; + + DEBUG13(printk("%s(%ld): MANUFACTURER=%s.\n", __func__, ha->host_no, + eiter->a.manufacturer)); + + /* Serial number. */ + eiter = (struct ct_fdmi_hba_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_HBA_SERIAL_NUMBER); + sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; + sprintf(eiter->a.serial_num, "%c%05d", 'A' + sn / 100000, sn % 100000); + alen = strlen(eiter->a.serial_num); + alen += (alen & 3) ? (4 - (alen & 3)) : 4; + eiter->len = cpu_to_be16(4 + alen); + size += 4 + alen; + + DEBUG13(printk("%s(%ld): SERIALNO=%s.\n", __func__, ha->host_no, + eiter->a.serial_num)); + + /* Model name. */ + eiter = (struct ct_fdmi_hba_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL); + strcpy(eiter->a.model, ha->model_number); + alen = strlen(eiter->a.model); + alen += (alen & 3) ? (4 - (alen & 3)) : 4; + eiter->len = cpu_to_be16(4 + alen); + size += 4 + alen; + + DEBUG13(printk("%s(%ld): MODEL_NAME=%s.\n", __func__, ha->host_no, + eiter->a.model)); + + /* Model description. */ + eiter = (struct ct_fdmi_hba_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); + if (ha->model_desc) + strncpy(eiter->a.model_desc, ha->model_desc, 80); + alen = strlen(eiter->a.model_desc); + alen += (alen & 3) ? (4 - (alen & 3)) : 4; + eiter->len = cpu_to_be16(4 + alen); + size += 4 + alen; + + DEBUG13(printk("%s(%ld): MODEL_DESC=%s.\n", __func__, ha->host_no, + eiter->a.model_desc)); + + /* Hardware version. */ + eiter = (struct ct_fdmi_hba_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_HBA_HARDWARE_VERSION); + strcpy(eiter->a.hw_version, ha->adapter_id); + alen = strlen(eiter->a.hw_version); + alen += (alen & 3) ? (4 - (alen & 3)) : 4; + eiter->len = cpu_to_be16(4 + alen); + size += 4 + alen; + + DEBUG13(printk("%s(%ld): HARDWAREVER=%s.\n", __func__, ha->host_no, + eiter->a.hw_version)); + + /* Driver version. */ + eiter = (struct ct_fdmi_hba_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_HBA_DRIVER_VERSION); + strcpy(eiter->a.driver_version, qla2x00_version_str); + alen = strlen(eiter->a.driver_version); + alen += (alen & 3) ? (4 - (alen & 3)) : 4; + eiter->len = cpu_to_be16(4 + alen); + size += 4 + alen; + + DEBUG13(printk("%s(%ld): DRIVERVER=%s.\n", __func__, ha->host_no, + eiter->a.driver_version)); + + /* Option ROM version. */ + eiter = (struct ct_fdmi_hba_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION); + strcpy(eiter->a.orom_version, "0.00"); + alen = strlen(eiter->a.orom_version); + alen += (alen & 3) ? (4 - (alen & 3)) : 4; + eiter->len = cpu_to_be16(4 + alen); + size += 4 + alen; + + DEBUG13(printk("%s(%ld): OPTROMVER=%s.\n", __func__, ha->host_no, + eiter->a.orom_version)); + + /* Firmware version */ + eiter = (struct ct_fdmi_hba_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION); + ha->isp_ops.fw_version_str(ha, eiter->a.fw_version); + alen = strlen(eiter->a.fw_version); + alen += (alen & 3) ? (4 - (alen & 3)) : 4; + eiter->len = cpu_to_be16(4 + alen); + size += 4 + alen; + + DEBUG13(printk("%s(%ld): FIRMWAREVER=%s.\n", __func__, ha->host_no, + eiter->a.fw_version)); + + /* Update MS request size. */ + qla2x00_update_ms_fdmi_iocb(ha, size + 16); + + DEBUG13(printk("%s(%ld): RHBA identifier=" + "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__, + ha->host_no, ct_req->req.rhba.hba_identifier[0], + ct_req->req.rhba.hba_identifier[1], + ct_req->req.rhba.hba_identifier[2], + ct_req->req.rhba.hba_identifier[3], + ct_req->req.rhba.hba_identifier[4], + ct_req->req.rhba.hba_identifier[5], + ct_req->req.rhba.hba_identifier[6], + ct_req->req.rhba.hba_identifier[7], size)); + DEBUG13(qla2x00_dump_buffer(entries, size)); + + /* Execute MS IOCB */ + rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, + sizeof(ms_iocb_entry_t)); + if (rval != QLA_SUCCESS) { + /*EMPTY*/ + DEBUG2_3(printk("scsi(%ld): RHBA issue IOCB failed (%d).\n", + ha->host_no, rval)); + } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RHBA") != + QLA_SUCCESS) { + rval = QLA_FUNCTION_FAILED; + if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM && + ct_rsp->header.explanation_code == + CT_EXPL_ALREADY_REGISTERED) { + DEBUG2_13(printk("%s(%ld): HBA already registered.\n", + __func__, ha->host_no)); + rval = QLA_ALREADY_REGISTERED; + } + } else { + DEBUG2(printk("scsi(%ld): RHBA exiting normally.\n", + ha->host_no)); + } + + return rval; +} + +/** + * qla2x00_fdmi_dhba() - + * @ha: HA context + * + * Returns 0 on success. + */ +static int +qla2x00_fdmi_dhba(scsi_qla_host_t *ha) +{ + int rval; + + ms_iocb_entry_t *ms_pkt; + struct ct_sns_req *ct_req; + struct ct_sns_rsp *ct_rsp; + + /* Issue RPA */ + /* Prepare common MS IOCB */ + ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, DHBA_REQ_SIZE, + DHBA_RSP_SIZE); + + /* Prepare CT request */ + ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, DHBA_CMD, + DHBA_RSP_SIZE); + ct_rsp = &ha->ct_sns->p.rsp; + + /* Prepare FDMI command arguments -- portname. */ + memcpy(ct_req->req.dhba.port_name, ha->port_name, WWN_SIZE); + + DEBUG13(printk("%s(%ld): DHBA portname=" + "%02x%02x%02x%02x%02x%02x%02x%02x.\n", __func__, ha->host_no, + ct_req->req.dhba.port_name[0], ct_req->req.dhba.port_name[1], + ct_req->req.dhba.port_name[2], ct_req->req.dhba.port_name[3], + ct_req->req.dhba.port_name[4], ct_req->req.dhba.port_name[5], + ct_req->req.dhba.port_name[6], ct_req->req.dhba.port_name[7])); + + /* Execute MS IOCB */ + rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, + sizeof(ms_iocb_entry_t)); + if (rval != QLA_SUCCESS) { + /*EMPTY*/ + DEBUG2_3(printk("scsi(%ld): DHBA issue IOCB failed (%d).\n", + ha->host_no, rval)); + } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "DHBA") != + QLA_SUCCESS) { + rval = QLA_FUNCTION_FAILED; + } else { + DEBUG2(printk("scsi(%ld): DHBA exiting normally.\n", + ha->host_no)); + } + + return rval; +} + +/** + * qla2x00_fdmi_rpa() - + * @ha: HA context + * + * Returns 0 on success. + */ +static int +qla2x00_fdmi_rpa(scsi_qla_host_t *ha) +{ + int rval, alen; + uint32_t size, max_frame_size; + + ms_iocb_entry_t *ms_pkt; + struct ct_sns_req *ct_req; + struct ct_sns_rsp *ct_rsp; + uint8_t *entries; + struct ct_fdmi_port_attr *eiter; + struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb; + + /* Issue RPA */ + /* Prepare common MS IOCB */ + /* Request size adjusted after CT preparation */ + ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, 0, RPA_RSP_SIZE); + + /* Prepare CT request */ + ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD, + RPA_RSP_SIZE); + ct_rsp = &ha->ct_sns->p.rsp; + + /* Prepare FDMI command arguments -- attribute block, attributes. */ + memcpy(ct_req->req.rpa.port_name, ha->port_name, WWN_SIZE); + size = WWN_SIZE + 4; + + /* Attributes */ + ct_req->req.rpa.attrs.count = + __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT); + entries = ct_req->req.rpa.port_name; + + /* FC4 types. */ + eiter = (struct ct_fdmi_port_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_PORT_FC4_TYPES); + eiter->len = __constant_cpu_to_be16(4 + 32); + eiter->a.fc4_types[2] = 0x01; + size += 4 + 32; + + DEBUG13(printk("%s(%ld): FC4_TYPES=%02x %02x.\n", __func__, ha->host_no, + eiter->a.fc4_types[2], eiter->a.fc4_types[1])); + + /* Supported speed. */ + eiter = (struct ct_fdmi_port_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED); + eiter->len = __constant_cpu_to_be16(4 + 4); + if (IS_QLA25XX(ha)) + eiter->a.sup_speed = __constant_cpu_to_be32(4); + else if (IS_QLA24XX(ha)) + eiter->a.sup_speed = __constant_cpu_to_be32(8); + else if (IS_QLA23XX(ha)) + eiter->a.sup_speed = __constant_cpu_to_be32(2); + else + eiter->a.sup_speed = __constant_cpu_to_be32(1); + size += 4 + 4; + + DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__, ha->host_no, + eiter->a.sup_speed)); + + /* Current speed. */ + eiter = (struct ct_fdmi_port_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED); + eiter->len = __constant_cpu_to_be16(4 + 4); + switch (ha->link_data_rate) { + case 0: + eiter->a.cur_speed = __constant_cpu_to_be32(1); + break; + case 1: + eiter->a.cur_speed = __constant_cpu_to_be32(2); + break; + case 3: + eiter->a.cur_speed = __constant_cpu_to_be32(8); + break; + case 4: + eiter->a.cur_speed = __constant_cpu_to_be32(4); + break; + } + size += 4 + 4; + + DEBUG13(printk("%s(%ld): CURRENT_SPEED=%x.\n", __func__, ha->host_no, + eiter->a.cur_speed)); + + /* Max frame size. */ + eiter = (struct ct_fdmi_port_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE); + eiter->len = __constant_cpu_to_be16(4 + 4); + max_frame_size = IS_QLA24XX(ha) || IS_QLA25XX(ha) ? + (uint32_t) icb24->frame_payload_size: + (uint32_t) ha->init_cb->frame_payload_size; + eiter->a.max_frame_size = cpu_to_be32(max_frame_size); + size += 4 + 4; + + DEBUG13(printk("%s(%ld): MAX_FRAME_SIZE=%x.\n", __func__, ha->host_no, + eiter->a.max_frame_size)); + + /* OS device name. */ + eiter = (struct ct_fdmi_port_attr *) (entries + size); + eiter->type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME); + sprintf(eiter->a.os_dev_name, "/proc/scsi/qla2xxx/%ld", ha->host_no); + alen = strlen(eiter->a.os_dev_name); + alen += (alen & 3) ? (4 - (alen & 3)) : 4; + eiter->len = cpu_to_be16(4 + alen); + size += 4 + alen; + + DEBUG13(printk("%s(%ld): OS_DEVICE_NAME=%s.\n", __func__, ha->host_no, + eiter->a.os_dev_name)); + + /* Update MS request size. */ + qla2x00_update_ms_fdmi_iocb(ha, size + 16); + + DEBUG13(printk("%s(%ld): RPA portname=" + "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__, + ha->host_no, ct_req->req.rpa.port_name[0], + ct_req->req.rpa.port_name[1], ct_req->req.rpa.port_name[2], + ct_req->req.rpa.port_name[3], ct_req->req.rpa.port_name[4], + ct_req->req.rpa.port_name[5], ct_req->req.rpa.port_name[6], + ct_req->req.rpa.port_name[7], size)); + DEBUG13(qla2x00_dump_buffer(entries, size)); + + /* Execute MS IOCB */ + rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, + sizeof(ms_iocb_entry_t)); + if (rval != QLA_SUCCESS) { + /*EMPTY*/ + DEBUG2_3(printk("scsi(%ld): RPA issue IOCB failed (%d).\n", + ha->host_no, rval)); + } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RPA") != + QLA_SUCCESS) { + rval = QLA_FUNCTION_FAILED; + } else { + DEBUG2(printk("scsi(%ld): RPA exiting normally.\n", + ha->host_no)); + } + + return rval; +} + +/** + * qla2x00_fdmi_register() - + * @ha: HA context + * + * Returns 0 on success. + */ +int +qla2x00_fdmi_register(scsi_qla_host_t *ha) +{ + int rval; + + rval = qla2x00_mgmt_svr_login(ha); + if (rval) + return rval; + + rval = qla2x00_fdmi_rhba(ha); + if (rval) { + if (rval != QLA_ALREADY_REGISTERED) + return rval; + + rval = qla2x00_fdmi_dhba(ha); + if (rval) + return rval; + + rval = qla2x00_fdmi_rhba(ha); + if (rval) + return rval; + } + rval = qla2x00_fdmi_rpa(ha); + + return rval; +} diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 09b23f70fd6..e38d0cf7363 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -88,6 +88,7 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha) ha->mbx_flags = 0; ha->isp_abort_cnt = 0; ha->beacon_blink_led = 0; + set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags); qla_printk(KERN_INFO, ha, "Configuring PCI space...\n"); rval = ha->isp_ops.pci_config(ha); @@ -2132,6 +2133,11 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) return (QLA_SUCCESS); } do { + /* FDMI support. */ + if (ql2xfdmienable && + test_and_clear_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags)) + qla2x00_fdmi_register(ha); + /* Ensure we are logged into the SNS. */ if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) loop_id = NPH_SNS; diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index f910de6dd43..c255bb0268a 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -451,6 +451,8 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb) ha->flags.management_server_logged_in = 0; ha->link_data_rate = 0; + if (ql2xfdmienable) + set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags); /* Update AEN queue. */ qla2x00_enqueue_aen(ha, MBA_LOOP_DOWN, NULL); diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 774309a77c0..284eb847e50 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -252,7 +252,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp) mb0 = RD_REG_WORD(®->isp24.mailbox0); ictrl = RD_REG_DWORD(®->isp24.ictrl); } else { - mb0 = RD_MAILBOX_REG(ha, reg->isp, 0); + mb0 = RD_MAILBOX_REG(ha, ®->isp, 0); ictrl = RD_REG_WORD(®->isp.ictrl); } printk("%s(%ld): **** MB Command Timeout for cmd %x ****\n", diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 995e521b07d..0fc37d810e0 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -88,6 +88,12 @@ static void qla2x00_free_device(scsi_qla_host_t *); static void qla2x00_config_dma_addressing(scsi_qla_host_t *ha); +int ql2xfdmienable; +module_param(ql2xfdmienable, int, S_IRUGO|S_IRUSR); +MODULE_PARM_DESC(ql2xfdmienable, + "Enables FDMI registratons " + "Default is 0 - no FDMI. 1 - perfom FDMI."); + /* * SCSI host template entry points */ @@ -1303,6 +1309,7 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info) ha->prev_topology = 0; ha->ports = MAX_BUSES; ha->init_cb_size = sizeof(init_cb_t); + ha->mgmt_svr_loop_id = MANAGEMENT_SERVER; /* Assign ISP specific operations. */ ha->isp_ops.pci_config = qla2100_pci_config; @@ -1325,6 +1332,7 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info) ha->isp_ops.calc_req_entries = qla2x00_calc_iocbs_32; ha->isp_ops.build_iocbs = qla2x00_build_scsi_iocbs_32; ha->isp_ops.prep_ms_iocb = qla2x00_prep_ms_iocb; + ha->isp_ops.prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb; ha->isp_ops.read_nvram = qla2x00_read_nvram_data; ha->isp_ops.write_nvram = qla2x00_write_nvram_data; ha->isp_ops.fw_dump = qla2100_fw_dump; @@ -1362,6 +1370,7 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info) ha->response_q_length = RESPONSE_ENTRY_CNT_2300; ha->last_loop_id = SNS_LAST_LOOP_ID_2300; ha->init_cb_size = sizeof(struct init_cb_24xx); + ha->mgmt_svr_loop_id = 10; ha->isp_ops.pci_config = qla24xx_pci_config; ha->isp_ops.reset_chip = qla24xx_reset_chip; ha->isp_ops.chip_diag = qla24xx_chip_diag; @@ -1382,6 +1391,7 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info) ha->isp_ops.fabric_login = qla24xx_login_fabric; ha->isp_ops.fabric_logout = qla24xx_fabric_logout; ha->isp_ops.prep_ms_iocb = qla24xx_prep_ms_iocb; + ha->isp_ops.prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb; ha->isp_ops.read_nvram = qla24xx_read_nvram_data; ha->isp_ops.write_nvram = qla24xx_write_nvram_data; ha->isp_ops.fw_dump = qla24xx_fw_dump; -- cgit v1.2.3-18-g5258 From f7d289f62e2ea911ecb710015efd45c687fa81ce Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:08:40 -0700 Subject: [SCSI] qla2xxx: Correct domain/area exclusion logic. In an FL topology, limit port recognition to those devices not within the same area and domain of the ISP. The firmware will recogonize such devices during local-loop discovery. Some devices may respond to a PLOGI before they have completed their fabric login or they may not be a public device. In this case they will report: domain == 00 area == 00 alpa == which is valid. Exclude such devices from local loop discovery. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_init.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index e38d0cf7363..d12255fb938 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -1900,7 +1900,8 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha) continue; /* Bypass if not same domain and area of adapter. */ - if (area != ha->d_id.b.area || domain != ha->d_id.b.domain) + if (area && domain && + (area != ha->d_id.b.area || domain != ha->d_id.b.domain)) continue; /* Bypass invalid local loop ID. */ @@ -2400,6 +2401,12 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports) if (new_fcport->d_id.b24 == ha->d_id.b24) continue; + /* Bypass if same domain and area of adapter. */ + if (((new_fcport->d_id.b24 & 0xffff00) == + (ha->d_id.b24 & 0xffff00)) && ha->current_topology == + ISP_CFG_FL) + continue; + /* Bypass reserved domain fields. */ if ((new_fcport->d_id.b.domain & 0xf0) == 0xf0) continue; -- cgit v1.2.3-18-g5258 From c00c72ae01c03d3d172150392419040f8d55ab04 Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:08:50 -0700 Subject: [SCSI] qla2xxx: Simplify redundant target/device reset logic. Remove redundant qla2x00_target_reset() function in favour of the equivalent qla2x00_device_reset(). Update callers of old function. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_gbl.h | 3 --- drivers/scsi/qla2xxx/qla_mbx.c | 52 ------------------------------------------ drivers/scsi/qla2xxx/qla_os.c | 2 +- 3 files changed, 1 insertion(+), 56 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 3e1e5fe850a..5deaa7e6ee6 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -147,9 +147,6 @@ extern int qla2x00_abort_target(fc_port_t *); #endif -extern int -qla2x00_target_reset(scsi_qla_host_t *, struct fc_port *); - extern int qla2x00_get_adapter_id(scsi_qla_host_t *, uint16_t *, uint8_t *, uint8_t *, uint8_t *, uint16_t *); diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 284eb847e50..953156faafd 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -983,58 +983,6 @@ qla2x00_abort_target(fc_port_t *fcport) } #endif -/* - * qla2x00_target_reset - * Issue target reset mailbox command. - * - * Input: - * ha = adapter block pointer. - * TARGET_QUEUE_LOCK must be released. - * ADAPTER_STATE_LOCK must be released. - * - * Returns: - * qla2x00 local function return status code. - * - * Context: - * Kernel context. - */ -int -qla2x00_target_reset(scsi_qla_host_t *ha, struct fc_port *fcport) -{ - int rval; - mbx_cmd_t mc; - mbx_cmd_t *mcp = &mc; - - DEBUG11(printk("qla2x00_target_reset(%ld): entered.\n", ha->host_no);) - - if (atomic_read(&fcport->state) != FCS_ONLINE) - return 0; - - mcp->mb[0] = MBC_TARGET_RESET; - if (HAS_EXTENDED_IDS(ha)) - mcp->mb[1] = fcport->loop_id; - else - mcp->mb[1] = fcport->loop_id << 8; - mcp->mb[2] = ha->loop_reset_delay; - mcp->out_mb = MBX_2|MBX_1|MBX_0; - mcp->in_mb = MBX_0; - mcp->tov = 30; - mcp->flags = 0; - rval = qla2x00_mailbox_command(ha, mcp); - - if (rval != QLA_SUCCESS) { - /*EMPTY*/ - DEBUG2_3_11(printk("qla2x00_target_reset(%ld): failed=%x.\n", - ha->host_no, rval);) - } else { - /*EMPTY*/ - DEBUG11(printk("qla2x00_target_reset(%ld): done.\n", - ha->host_no);) - } - - return rval; -} - /* * qla2x00_get_adapter_id * Get adapter ID and topology. diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 0fc37d810e0..29cf3f51093 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1022,7 +1022,7 @@ qla2x00_loop_reset(scsi_qla_host_t *ha) if (fcport->port_type != FCT_TARGET) continue; - status = qla2x00_target_reset(ha, fcport); + status = qla2x00_device_reset(ha, fcport); if (status != QLA_SUCCESS) break; } -- cgit v1.2.3-18-g5258 From 06c22bd13f4eb55e291d5a31280b2ae5a70ad00d Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:09:00 -0700 Subject: [SCSI] qla2xxx: Correct LED scheme definition. Original implementation used an overloaded bit in the EFI parameters. The correct bit is BIT_4 of the special_options section of NVRAM. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_def.h | 4 ++-- drivers/scsi/qla2xxx/qla_init.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index cdef86e49c6..b7f82b757cb 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -914,7 +914,7 @@ typedef struct { * MSB BIT 1 = * MSB BIT 2 = * MSB BIT 3 = - * MSB BIT 4 = + * MSB BIT 4 = LED mode * MSB BIT 5 = enable 50 ohm termination * MSB BIT 6 = Data Rate (2300 only) * MSB BIT 7 = Data Rate (2300 only) @@ -1036,7 +1036,7 @@ typedef struct { * MSB BIT 1 = * MSB BIT 2 = * MSB BIT 3 = - * MSB BIT 4 = + * MSB BIT 4 = LED mode * MSB BIT 5 = enable 50 ohm termination * MSB BIT 6 = Data Rate (2300 only) * MSB BIT 7 = Data Rate (2300 only) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index d12255fb938..c619583e646 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -1564,7 +1564,7 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) ha->flags.enable_lip_reset = ((nv->host_p[1] & BIT_1) ? 1 : 0); ha->flags.enable_lip_full_login = ((nv->host_p[1] & BIT_2) ? 1 : 0); ha->flags.enable_target_reset = ((nv->host_p[1] & BIT_3) ? 1 : 0); - ha->flags.enable_led_scheme = ((nv->efi_parameters & BIT_3) ? 1 : 0); + ha->flags.enable_led_scheme = (nv->special_options[1] & BIT_4) ? 1 : 0; ha->operating_mode = (icb->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) >> 4; -- cgit v1.2.3-18-g5258 From c32c4cb9fbe3bdc2a90c6eaae5ae30521d4ba9fc Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:09:10 -0700 Subject: [SCSI] qla2xxx: Remove RISC pause/release barriers during flash manipulation. Remove unnecessary RISC pause/release barriers during ISP24xx flash manipulation. The ISP24xx can arbitrate flash access requests during RISC executions. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_sup.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c index d7f5c608009..c14abf743b7 100644 --- a/drivers/scsi/qla2xxx/qla_sup.c +++ b/drivers/scsi/qla2xxx/qla_sup.c @@ -468,21 +468,12 @@ qla24xx_read_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, uint32_t dwords) { uint32_t i; - struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; - - /* Pause RISC. */ - WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_PAUSE); - RD_REG_DWORD(®->hccr); /* PCI Posting. */ /* Dword reads to flash. */ for (i = 0; i < dwords; i++, faddr++) dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(ha, flash_data_to_access_addr(faddr))); - /* Release RISC pause. */ - WRT_REG_DWORD(®->hccr, HCCRX_REL_RISC_PAUSE); - RD_REG_DWORD(®->hccr); /* PCI Posting. */ - return dwptr; } @@ -532,10 +523,6 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, ret = QLA_SUCCESS; - /* Pause RISC. */ - WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_PAUSE); - RD_REG_DWORD(®->hccr); /* PCI Posting. */ - qla24xx_get_flash_manufacturer(ha, &man_id, &flash_id); DEBUG9(printk("%s(%ld): Flash man_id=%d flash_id=%d\n", __func__, ha->host_no, man_id, flash_id)); @@ -599,10 +586,6 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, RD_REG_DWORD(®->ctrl_status) & ~CSRX_FLASH_ENABLE); RD_REG_DWORD(®->ctrl_status); /* PCI Posting. */ - /* Release RISC pause. */ - WRT_REG_DWORD(®->hccr, HCCRX_REL_RISC_PAUSE); - RD_REG_DWORD(®->hccr); /* PCI Posting. */ - return ret; } @@ -630,11 +613,6 @@ qla24xx_read_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, { uint32_t i; uint32_t *dwptr; - struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; - - /* Pause RISC. */ - WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_PAUSE); - RD_REG_DWORD(®->hccr); /* PCI Posting. */ /* Dword reads to flash. */ dwptr = (uint32_t *)buf; @@ -642,10 +620,6 @@ qla24xx_read_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(ha, nvram_data_to_access_addr(naddr))); - /* Release RISC pause. */ - WRT_REG_DWORD(®->hccr, HCCRX_REL_RISC_PAUSE); - RD_REG_DWORD(®->hccr); /* PCI Posting. */ - return buf; } @@ -690,10 +664,6 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, ret = QLA_SUCCESS; - /* Pause RISC. */ - WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_PAUSE); - RD_REG_DWORD(®->hccr); /* PCI Posting. */ - /* Enable flash write. */ WRT_REG_DWORD(®->ctrl_status, RD_REG_DWORD(®->ctrl_status) | CSRX_FLASH_ENABLE); @@ -728,9 +698,5 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, RD_REG_DWORD(®->ctrl_status) & ~CSRX_FLASH_ENABLE); RD_REG_DWORD(®->ctrl_status); /* PCI Posting. */ - /* Release RISC pause. */ - WRT_REG_DWORD(®->hccr, HCCRX_REL_RISC_PAUSE); - RD_REG_DWORD(®->hccr); /* PCI Posting. */ - return ret; } -- cgit v1.2.3-18-g5258 From 131736d34ebc3251d79ddfd08a5e57a3e86decd4 Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:09:20 -0700 Subject: [SCSI] qla2xxx: Remove redundant call to pci_unmap_sg(). In a corner-case failure where the request-q does not contain enough entries for a given request, pci_unmap_sg() would be called twice. Remove direct call and let the failure-path logic handle the unmapping. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_iocb.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index ebdc3c54d15..37f82e2cd7f 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -810,12 +810,8 @@ qla24xx_start_scsi(srb_t *sp) ha->req_q_cnt = ha->request_q_length - (ha->req_ring_index - cnt); } - if (ha->req_q_cnt < (req_cnt + 2)) { - if (cmd->use_sg) - pci_unmap_sg(ha->pdev, sg, cmd->use_sg, - cmd->sc_data_direction); + if (ha->req_q_cnt < (req_cnt + 2)) goto queuing_error; - } /* Build command packet. */ ha->current_outstanding_cmd = handle; -- cgit v1.2.3-18-g5258 From ce7e4af7f507c156c3fd3dbb41ffe4a77c700b54 Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:09:30 -0700 Subject: [SCSI] qla2xxx: Add change_queue_depth/type() API support. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_os.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 29cf3f51093..413ccc152de 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -111,6 +111,9 @@ static int qla2xxx_eh_host_reset(struct scsi_cmnd *); static int qla2x00_loop_reset(scsi_qla_host_t *ha); static int qla2x00_device_reset(scsi_qla_host_t *, fc_port_t *); +static int qla2x00_change_queue_depth(struct scsi_device *, int); +static int qla2x00_change_queue_type(struct scsi_device *, int); + static struct scsi_host_template qla2x00_driver_template = { .module = THIS_MODULE, .name = "qla2xxx", @@ -125,6 +128,8 @@ static struct scsi_host_template qla2x00_driver_template = { .slave_alloc = qla2xxx_slave_alloc, .slave_destroy = qla2xxx_slave_destroy, + .change_queue_depth = qla2x00_change_queue_depth, + .change_queue_type = qla2x00_change_queue_type, .this_id = -1, .cmd_per_lun = 3, .use_clustering = ENABLE_CLUSTERING, @@ -151,6 +156,8 @@ static struct scsi_host_template qla24xx_driver_template = { .slave_alloc = qla2xxx_slave_alloc, .slave_destroy = qla2xxx_slave_destroy, + .change_queue_depth = qla2x00_change_queue_depth, + .change_queue_type = qla2x00_change_queue_type, .this_id = -1, .cmd_per_lun = 3, .use_clustering = ENABLE_CLUSTERING, @@ -1109,6 +1116,28 @@ qla2xxx_slave_destroy(struct scsi_device *sdev) sdev->hostdata = NULL; } +static int +qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth) +{ + scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + return sdev->queue_depth; +} + +static int +qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type) +{ + if (sdev->tagged_supported) { + scsi_set_tag_type(sdev, tag_type); + if (tag_type) + scsi_activate_tcq(sdev, sdev->queue_depth); + else + scsi_deactivate_tcq(sdev, sdev->queue_depth); + } else + tag_type = 0; + + return tag_type; +} + /** * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. * @ha: HA context -- cgit v1.2.3-18-g5258 From afb046e2be724a90f21f7cf0ba50e328005bd038 Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:09:40 -0700 Subject: [SCSI] qla2xxx: Add host attributes. Export additional host information via the shost_attrs member in the scsi_host template. Attributes include: driver version, firmware version, ISP serial number, ISP type, ISP product ID, HBA model name, HBA model description, PCI interconnect information, and HBA port state. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_attr.c | 132 ++++++++++++++++++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_gbl.h | 2 + drivers/scsi/qla2xxx/qla_os.c | 2 + 3 files changed, 136 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index d05280eecc6..fe0fce71adc 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -211,6 +211,138 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *ha) sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); } +/* Scsi_Host attributes. */ + +static ssize_t +qla2x00_drvr_version_show(struct class_device *cdev, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str); +} + +static ssize_t +qla2x00_fw_version_show(struct class_device *cdev, char *buf) +{ + scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); + char fw_str[30]; + + return snprintf(buf, PAGE_SIZE, "%s\n", + ha->isp_ops.fw_version_str(ha, fw_str)); +} + +static ssize_t +qla2x00_serial_num_show(struct class_device *cdev, char *buf) +{ + scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); + uint32_t sn; + + sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; + return snprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000, + sn % 100000); +} + +static ssize_t +qla2x00_isp_name_show(struct class_device *cdev, char *buf) +{ + scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); + return snprintf(buf, PAGE_SIZE, "%s\n", ha->brd_info->isp_name); +} + +static ssize_t +qla2x00_isp_id_show(struct class_device *cdev, char *buf) +{ + scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); + return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n", + ha->product_id[0], ha->product_id[1], ha->product_id[2], + ha->product_id[3]); +} + +static ssize_t +qla2x00_model_name_show(struct class_device *cdev, char *buf) +{ + scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); + return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number); +} + +static ssize_t +qla2x00_model_desc_show(struct class_device *cdev, char *buf) +{ + scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); + return snprintf(buf, PAGE_SIZE, "%s\n", + ha->model_desc ? ha->model_desc: ""); +} + +static ssize_t +qla2x00_pci_info_show(struct class_device *cdev, char *buf) +{ + scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); + char pci_info[30]; + + return snprintf(buf, PAGE_SIZE, "%s\n", + ha->isp_ops.pci_info_str(ha, pci_info)); +} + +static ssize_t +qla2x00_state_show(struct class_device *cdev, char *buf) +{ + scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); + int len = 0; + + if (atomic_read(&ha->loop_state) == LOOP_DOWN || + atomic_read(&ha->loop_state) == LOOP_DEAD) + len = snprintf(buf, PAGE_SIZE, "Link Down\n"); + else if (atomic_read(&ha->loop_state) != LOOP_READY || + test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) || + test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) + len = snprintf(buf, PAGE_SIZE, "Unknown Link State\n"); + else { + len = snprintf(buf, PAGE_SIZE, "Link Up - "); + + switch (ha->current_topology) { + case ISP_CFG_NL: + len += snprintf(buf + len, PAGE_SIZE-len, "Loop\n"); + break; + case ISP_CFG_FL: + len += snprintf(buf + len, PAGE_SIZE-len, "FL_Port\n"); + break; + case ISP_CFG_N: + len += snprintf(buf + len, PAGE_SIZE-len, + "N_Port to N_Port\n"); + break; + case ISP_CFG_F: + len += snprintf(buf + len, PAGE_SIZE-len, "F_Port\n"); + break; + default: + len += snprintf(buf + len, PAGE_SIZE-len, "Loop\n"); + break; + } + } + return len; +} + +static CLASS_DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, + NULL); +static CLASS_DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); +static CLASS_DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); +static CLASS_DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL); +static CLASS_DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL); +static CLASS_DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL); +static CLASS_DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL); +static CLASS_DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL); +static CLASS_DEVICE_ATTR(state, S_IRUGO, qla2x00_state_show, NULL); + +struct class_device_attribute *qla2x00_host_attrs[] = { + &class_device_attr_driver_version, + &class_device_attr_fw_version, + &class_device_attr_serial_num, + &class_device_attr_isp_name, + &class_device_attr_isp_id, + &class_device_attr_model_name, + &class_device_attr_model_desc, + &class_device_attr_pci_info, + &class_device_attr_state, + NULL, +}; + /* Host attributes. */ static void diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 5deaa7e6ee6..95fb0c4941a 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -290,6 +290,8 @@ extern void qla2x00_cancel_io_descriptors(scsi_qla_host_t *); /* * Global Function Prototypes in qla_attr.c source file. */ +struct class_device_attribute; +extern struct class_device_attribute *qla2x00_host_attrs[]; struct fc_function_template; extern struct fc_function_template qla2xxx_transport_functions; extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *); diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 413ccc152de..14f2f9077c8 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -140,6 +140,7 @@ static struct scsi_host_template qla2x00_driver_template = { * which equates to 0x800000 sectors. */ .max_sectors = 0xFFFF, + .shost_attrs = qla2x00_host_attrs, }; static struct scsi_host_template qla24xx_driver_template = { @@ -164,6 +165,7 @@ static struct scsi_host_template qla24xx_driver_template = { .sg_tablesize = SG_ALL, .max_sectors = 0xFFFF, + .shost_attrs = qla2x00_host_attrs, }; static struct scsi_transport_template *qla2xxx_transport_template = NULL; -- cgit v1.2.3-18-g5258 From 86cd6baa8294dc5b2cedd84fb5cf3944eaf5271f Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:10:00 -0700 Subject: [SCSI] qla2xxx: Remove bad call to fc_remove_host() during probe failure. fc_remove_host() should only be called after a scsi_host has been successfully added via scsi_add_host() -- any failures while qla2xxx probing would result in an incorrect call to fc_remove_host() during cleanup. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_os.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 14f2f9077c8..5a542655d44 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1586,8 +1586,6 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info) return 0; probe_failed: - fc_remove_host(ha->host); - qla2x00_free_device(ha); scsi_host_put(host); -- cgit v1.2.3-18-g5258 From fe74c71f6bb63376d92bc606597f0818f5b11c2e Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:10:10 -0700 Subject: [SCSI] qla2xxx: Replace schedule_timeout(). From: Nishanth Aravamudan Replace schedule_timeout() with msleep()/msleep_interruptible() as appropriate, to guarantee the task delays as expected. Signed-off-by: Nishanth Aravamudan Signed-off-by: Domen Puncer Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_os.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 5a542655d44..af9b4e77cbf 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -502,14 +502,13 @@ qc24_fail_command: static int qla2x00_eh_wait_on_command(scsi_qla_host_t *ha, struct scsi_cmnd *cmd) { -#define ABORT_POLLING_PERIOD HZ -#define ABORT_WAIT_ITER ((10 * HZ) / (ABORT_POLLING_PERIOD)) +#define ABORT_POLLING_PERIOD 1000 +#define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD)) unsigned long wait_iter = ABORT_WAIT_ITER; int ret = QLA_SUCCESS; while (CMD_SP(cmd)) { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(ABORT_POLLING_PERIOD); + msleep(ABORT_POLLING_PERIOD); if (--wait_iter) break; @@ -1960,7 +1959,7 @@ qla2x00_mem_free(scsi_qla_host_t *ha) { struct list_head *fcpl, *fcptemp; fc_port_t *fcport; - unsigned long wtime;/* max wait time if mbx cmd is busy. */ + unsigned int wtime;/* max wait time if mbx cmd is busy. */ if (ha == NULL) { /* error */ @@ -1969,11 +1968,9 @@ qla2x00_mem_free(scsi_qla_host_t *ha) } /* Make sure all other threads are stopped. */ - wtime = 60 * HZ; - while (ha->dpc_wait && wtime) { - set_current_state(TASK_INTERRUPTIBLE); - wtime = schedule_timeout(wtime); - } + wtime = 60 * 1000; + while (ha->dpc_wait && wtime) + wtime = msleep_interruptible(wtime); /* free ioctl memory */ qla2x00_free_ioctl_mem(ha); @@ -2504,15 +2501,15 @@ qla2x00_timer(scsi_qla_host_t *ha) int qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout) { - const unsigned int step = HZ/10; + const unsigned int step = 100; /* msecs */ + unsigned int iterations = jiffies_to_msecs(timeout)/100; do { if (!down_trylock(sema)) return 0; - set_current_state(TASK_INTERRUPTIBLE); - if (schedule_timeout(step)) + if (msleep_interruptible(step)) break; - } while ((timeout -= step) > 0); + } while (--iterations >= 0); return -ETIMEDOUT; } -- cgit v1.2.3-18-g5258 From f6ef3b1872915c6d69ca36cf4ca16269cb9a73ad Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:10:20 -0700 Subject: [SCSI] qla2xxx: Stop firmware execution at unintialization time. On ISP24xx parts, stop execution of firmware during ISP tear-down. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_def.h | 1 + drivers/scsi/qla2xxx/qla_gbl.h | 3 +++ drivers/scsi/qla2xxx/qla_mbx.c | 29 +++++++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_os.c | 14 ++++++++------ 4 files changed, 41 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index b7f82b757cb..b455c31405e 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -631,6 +631,7 @@ typedef struct { #define MBC_WRITE_RAM_WORD_EXTENDED 0xd /* Write RAM word extended */ #define MBC_READ_RAM_EXTENDED 0xf /* Read RAM extended. */ #define MBC_IOCB_COMMAND 0x12 /* Execute IOCB command. */ +#define MBC_STOP_FIRMWARE 0x14 /* Stop firmware. */ #define MBC_ABORT_COMMAND 0x15 /* Abort IOCB command. */ #define MBC_ABORT_DEVICE 0x16 /* Abort device (ID/LUN). */ #define MBC_ABORT_TARGET 0x17 /* Abort target (ID). */ diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 95fb0c4941a..1ed32e7b547 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -213,6 +213,9 @@ qla2x00_get_serdes_params(scsi_qla_host_t *, uint16_t *, uint16_t *, extern int qla2x00_set_serdes_params(scsi_qla_host_t *, uint16_t, uint16_t, uint16_t); +extern int +qla2x00_stop_firmware(scsi_qla_host_t *); + /* * Global Function Prototypes in qla_isr.c source file. */ diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 953156faafd..13e1c904707 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -2427,3 +2427,32 @@ qla2x00_set_serdes_params(scsi_qla_host_t *ha, uint16_t sw_em_1g, return rval; } + +int +qla2x00_stop_firmware(scsi_qla_host_t *ha) +{ + int rval; + mbx_cmd_t mc; + mbx_cmd_t *mcp = &mc; + + if (!IS_QLA24XX(ha) && !IS_QLA25XX(ha)) + return QLA_FUNCTION_FAILED; + + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); + + mcp->mb[0] = MBC_STOP_FIRMWARE; + mcp->out_mb = MBX_0; + mcp->in_mb = MBX_0; + mcp->tov = 5; + mcp->flags = 0; + rval = qla2x00_mailbox_command(ha, mcp); + + if (rval != QLA_SUCCESS) { + DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, + ha->host_no, rval)); + } else { + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); + } + + return rval; +} diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index af9b4e77cbf..8982978c42f 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -79,7 +79,7 @@ module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR); MODULE_PARM_DESC(ql2xloginretrycount, "Specify an alternate value for the NVRAM login retry count."); -int ql2xfwloadbin; +int ql2xfwloadbin=1; module_param(ql2xfwloadbin, int, S_IRUGO|S_IRUSR); MODULE_PARM_DESC(ql2xfwloadbin, "Load ISP2xxx firmware image via hotplug."); @@ -1626,10 +1626,6 @@ qla2x00_free_device(scsi_qla_host_t *ha) if (!IS_QLA2100(ha) && !IS_QLA2200(ha)) qla2x00_cancel_io_descriptors(ha); - /* turn-off interrupts on the card */ - if (ha->interrupts_on) - ha->isp_ops.disable_intrs(ha); - /* Disable timer */ if (ha->timer_active) qla2x00_stop_timer(ha); @@ -1649,8 +1645,14 @@ qla2x00_free_device(scsi_qla_host_t *ha) } } - qla2x00_mem_free(ha); + /* Stop currently executing firmware. */ + qla2x00_stop_firmware(ha); + /* turn-off interrupts on the card */ + if (ha->interrupts_on) + ha->isp_ops.disable_intrs(ha); + + qla2x00_mem_free(ha); ha->flags.online = 0; -- cgit v1.2.3-18-g5258 From 1aab60c25e9a500b9f15c1dfd775e70e7bde555c Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 26 Aug 2005 19:10:30 -0700 Subject: [SCSI] qla2xxx: Update version number to 8.01.00-k. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h index e3cd3618bc5..eae7d6edd53 100644 --- a/drivers/scsi/qla2xxx/qla_version.h +++ b/drivers/scsi/qla2xxx/qla_version.h @@ -19,9 +19,9 @@ /* * Driver version */ -#define QLA2XXX_VERSION "8.01.00b5-k" +#define QLA2XXX_VERSION "8.01.00-k" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 1 #define QLA_DRIVER_PATCH_VER 0 -#define QLA_DRIVER_BETA_VER 5 +#define QLA_DRIVER_BETA_VER 0 -- cgit v1.2.3-18-g5258 From e770e8506110a57c868bbef9706d132285c2090f Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Sat, 3 Sep 2005 15:54:18 -0700 Subject: [PATCH] dvb: saa7134-dvb must select tda1004x Please apply this to 2.6.14, and also to 2.6.13.1 -stable. Without this patch, users will have to EXPLICITLY select tda1004x in Kconfig. This SHOULD be done automatically when saa7134-dvb is selected. This patch corrects this problem. Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 3f574239609..16c85c081e6 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -254,6 +254,7 @@ config VIDEO_SAA7134_DVB select VIDEO_BUF_DVB select DVB_MT352 select DVB_CX22702 + select DVB_TDA1004X ---help--- This adds support for DVB cards based on the Philips saa7134 chip. -- cgit v1.2.3-18-g5258 From e8a650150b1001bc34d506e4c44538463d368890 Mon Sep 17 00:00:00 2001 From: Marcel Selhorst Date: Sat, 3 Sep 2005 15:54:20 -0700 Subject: [PATCH] tpm_infineon: Bugfix in PNPACPI-handling This patch corrects the PNP-handling inside the tpm-driver and some minor coding style bugs. Note: the pci-device and pnp-device mixture is currently necessary, since the used "tpm"-interface requires a pci-dev in order to register the driver. This will be fixed within the next iterations. Signed-off-by: Marcel Selhorst Cc: Kylene Hall Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/tpm/tpm_infineon.c | 76 ++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 31 deletions(-) (limited to 'drivers') diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c index dc8c540391f..939e51e119e 100644 --- a/drivers/char/tpm/tpm_infineon.c +++ b/drivers/char/tpm/tpm_infineon.c @@ -14,7 +14,6 @@ * License. */ -#include #include #include "tpm.h" @@ -29,9 +28,10 @@ #define TPM_MAX_TRIES 5000 #define TPM_INFINEON_DEV_VEN_VALUE 0x15D1 -/* These values will be filled after ACPI-call */ +/* These values will be filled after PnP-call */ static int TPM_INF_DATA = 0; static int TPM_INF_ADDR = 0; +static int pnp_registered = 0; /* TPM header definitions */ enum infineon_tpm_header { @@ -356,24 +356,26 @@ static const struct pnp_device_id tpm_pnp_tbl[] = { {"IFX0102", 0}, {"", 0} }; +MODULE_DEVICE_TABLE(pnp, tpm_pnp_tbl); -static int __devinit tpm_inf_acpi_probe(struct pnp_dev *dev, +static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) { - TPM_INF_ADDR = (pnp_port_start(dev, 0) & 0xff); - TPM_INF_DATA = ((TPM_INF_ADDR + 1) & 0xff); - tpm_inf.base = pnp_port_start(dev, 1); - dev_info(&dev->dev, "Found %s with ID %s\n", - dev->name, dev_id->id); - if (!((tpm_inf.base >> 8) & 0xff)) - tpm_inf.base = 0; - return 0; + if (pnp_port_valid(dev, 0)) { + TPM_INF_ADDR = (pnp_port_start(dev, 0) & 0xff); + TPM_INF_DATA = ((TPM_INF_ADDR + 1) & 0xff); + tpm_inf.base = pnp_port_start(dev, 1); + dev_info(&dev->dev, "Found %s with ID %s\n", + dev->name, dev_id->id); + return 0; + } + return -ENODEV; } static struct pnp_driver tpm_inf_pnp = { .name = "tpm_inf_pnp", .id_table = tpm_pnp_tbl, - .probe = tpm_inf_acpi_probe, + .probe = tpm_inf_pnp_probe, }; static int __devinit tpm_inf_probe(struct pci_dev *pci_dev, @@ -386,19 +388,30 @@ static int __devinit tpm_inf_probe(struct pci_dev *pci_dev, int productid[2]; char chipname[20]; - if (pci_enable_device(pci_dev)) - return -EIO; + rc = pci_enable_device(pci_dev); + if (rc) + return rc; dev_info(&pci_dev->dev, "LPC-bus found at 0x%x\n", pci_id->device); - /* read IO-ports from ACPI */ - pnp_register_driver(&tpm_inf_pnp); - pnp_unregister_driver(&tpm_inf_pnp); + /* read IO-ports from PnP */ + rc = pnp_register_driver(&tpm_inf_pnp); + if (rc < 0) { + dev_err(&pci_dev->dev, + "Error %x from pnp_register_driver!\n",rc); + goto error2; + } + if (!rc) { + dev_info(&pci_dev->dev, "No Infineon TPM found!\n"); + goto error; + } else { + pnp_registered = 1; + } /* Make sure, we have received valid config ports */ if (!TPM_INF_ADDR) { - pci_disable_device(pci_dev); - return -EIO; + dev_err(&pci_dev->dev, "No valid IO-ports received!\n"); + goto error; } /* query chip for its vendor, its version number a.s.o. */ @@ -418,23 +431,21 @@ static int __devinit tpm_inf_probe(struct pci_dev *pci_dev, switch ((productid[0] << 8) | productid[1]) { case 6: - sprintf(chipname, " (SLD 9630 TT 1.1)"); + snprintf(chipname, sizeof(chipname), " (SLD 9630 TT 1.1)"); break; case 11: - sprintf(chipname, " (SLB 9635 TT 1.2)"); + snprintf(chipname, sizeof(chipname), " (SLB 9635 TT 1.2)"); break; default: - sprintf(chipname, " (unknown chip)"); + snprintf(chipname, sizeof(chipname), " (unknown chip)"); break; } - chipname[19] = 0; if ((vendorid[0] << 8 | vendorid[1]) == (TPM_INFINEON_DEV_VEN_VALUE)) { if (tpm_inf.base == 0) { dev_err(&pci_dev->dev, "No IO-ports found!\n"); - pci_disable_device(pci_dev); - return -EIO; + goto error; } /* configure TPM with IO-ports */ outb(IOLIMH, TPM_INF_ADDR); @@ -452,8 +463,7 @@ static int __devinit tpm_inf_probe(struct pci_dev *pci_dev, dev_err(&pci_dev->dev, "Could not set IO-ports to %04x\n", tpm_inf.base); - pci_disable_device(pci_dev); - return -EIO; + goto error; } /* activate register */ @@ -479,14 +489,16 @@ static int __devinit tpm_inf_probe(struct pci_dev *pci_dev, productid[0], productid[1], chipname); rc = tpm_register_hardware(pci_dev, &tpm_inf); - if (rc < 0) { - pci_disable_device(pci_dev); - return -ENODEV; - } + if (rc < 0) + goto error; return 0; } else { dev_info(&pci_dev->dev, "No Infineon TPM found!\n"); +error: + pnp_unregister_driver(&tpm_inf_pnp); +error2: pci_disable_device(pci_dev); + pnp_registered = 0; return -ENODEV; } } @@ -521,6 +533,8 @@ static int __init init_inf(void) static void __exit cleanup_inf(void) { + if (pnp_registered) + pnp_unregister_driver(&tpm_inf_pnp); pci_unregister_driver(&inf_pci_driver); } -- cgit v1.2.3-18-g5258 From c07e02db76940c75fc92f2f2c9adcdbb09ed70d0 Mon Sep 17 00:00:00 2001 From: Martin Hicks Date: Sat, 3 Sep 2005 15:55:11 -0700 Subject: [PATCH] VM: add page_state info to per-node meminfo Add page_state info to the per-node meminfo file in sysfs. This is mostly just for informational purposes. The lack of this information was brought up recently during a discussion regarding pagecache clearing, and I put this patch together to test out one of the suggestions. It seems like interesting info to have, so I'm submitting the patch. Signed-off-by: Martin Hicks Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/base/node.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/base/node.c b/drivers/base/node.c index 904b27caf69..16c513aa4d4 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -39,13 +39,25 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) int n; int nid = dev->id; struct sysinfo i; + struct page_state ps; unsigned long inactive; unsigned long active; unsigned long free; si_meminfo_node(&i, nid); + get_page_state_node(&ps, nid); __get_zone_counts(&active, &inactive, &free, NODE_DATA(nid)); + /* Check for negative values in these approximate counters */ + if ((long)ps.nr_dirty < 0) + ps.nr_dirty = 0; + if ((long)ps.nr_writeback < 0) + ps.nr_writeback = 0; + if ((long)ps.nr_mapped < 0) + ps.nr_mapped = 0; + if ((long)ps.nr_slab < 0) + ps.nr_slab = 0; + n = sprintf(buf, "\n" "Node %d MemTotal: %8lu kB\n" "Node %d MemFree: %8lu kB\n" @@ -55,7 +67,11 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) "Node %d HighTotal: %8lu kB\n" "Node %d HighFree: %8lu kB\n" "Node %d LowTotal: %8lu kB\n" - "Node %d LowFree: %8lu kB\n", + "Node %d LowFree: %8lu kB\n" + "Node %d Dirty: %8lu kB\n" + "Node %d Writeback: %8lu kB\n" + "Node %d Mapped: %8lu kB\n" + "Node %d Slab: %8lu kB\n", nid, K(i.totalram), nid, K(i.freeram), nid, K(i.totalram - i.freeram), @@ -64,7 +80,11 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) nid, K(i.totalhigh), nid, K(i.freehigh), nid, K(i.totalram - i.totalhigh), - nid, K(i.freeram - i.freehigh)); + nid, K(i.freeram - i.freehigh), + nid, K(ps.nr_dirty), + nid, K(ps.nr_writeback), + nid, K(ps.nr_mapped), + nid, K(ps.nr_slab)); n += hugetlb_report_node_meminfo(nid, buf + n); return n; } -- cgit v1.2.3-18-g5258 From a2f40ccd294d14e5aca464c1913e8e0d8de35fca Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Sat, 3 Sep 2005 15:55:33 -0700 Subject: [PATCH] ppc32: Added support for the Book-E style Watchdog Timer PowerPC 40x and Book-E processors support a watchdog timer at the processor core level. The timer has implementation dependent timeout frequencies that can be configured by software. One the first Watchdog timeout we get a critical exception. It is left to board specific code to determine what should happen at this point. If nothing is done and another timeout period expires the processor may attempt to reset the machine. Command line parameters: wdt=0 : disable watchdog (default) wdt=1 : enable watchdog wdt_period=N : N sets the value of the Watchdog Timer Period. The Watchdog Timer Period meaning is implementation specific. Check User Manual for the processor for more details. This patch is based off of work done by Takeharu Kato. Signed-off-by: Matt McClintock Signed-off-by: Kumar Gala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/watchdog/Kconfig | 4 + drivers/char/watchdog/Makefile | 1 + drivers/char/watchdog/booke_wdt.c | 191 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 196 insertions(+) create mode 100644 drivers/char/watchdog/booke_wdt.c (limited to 'drivers') diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index b53e2e2b5ae..95335b443a8 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig @@ -346,6 +346,10 @@ config 8xx_WDT tristate "MPC8xx Watchdog Timer" depends on WATCHDOG && 8xx +config BOOKE_WDT + tristate "PowerPC Book-E Watchdog Timer" + depends on WATCHDOG && (BOOKE || 4xx) + # MIPS Architecture config INDYDOG diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index c1838834ea7..b16dfea2813 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o +obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o # Only one watchdog can succeed. We probe the hardware watchdog # drivers first, then the softdog driver. This means if your hardware diff --git a/drivers/char/watchdog/booke_wdt.c b/drivers/char/watchdog/booke_wdt.c new file mode 100644 index 00000000000..7281f394f68 --- /dev/null +++ b/drivers/char/watchdog/booke_wdt.c @@ -0,0 +1,191 @@ +/* + * drivers/char/watchdog/booke_wdt.c + * + * Watchdog timer for PowerPC Book-E systems + * + * Author: Matthew McClintock + * Maintainer: Kumar Gala + * + * Copyright 2005 Freescale Semiconductor 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. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +/* If the kernel parameter wdt_enable=1, the watchdog will be enabled at boot. + * Also, the wdt_period sets the watchdog timer period timeout. + * For E500 cpus the wdt_period sets which bit changing from 0->1 will + * trigger a watchog timeout. This watchdog timeout will occur 3 times, the + * first time nothing will happen, the second time a watchdog exception will + * occur, and the final time the board will reset. + */ + +#ifdef CONFIG_FSL_BOOKE +#define WDT_PERIOD_DEFAULT 63 /* Ex. wdt_period=28 bus=333Mhz , reset=~40sec */ +#else +#define WDT_PERIOD_DEFAULT 4 /* Refer to the PPC40x and PPC4xx manuals */ +#endif /* for timing information */ + +u32 wdt_enable = 0; +u32 wdt_period = WDT_PERIOD_DEFAULT; + +#ifdef CONFIG_FSL_BOOKE +#define WDTP(x) ((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15)) +#else +#define WDTP(x) (TCR_WP(x)) +#endif + +/* + * booke_wdt_enable: + */ +static __inline__ void booke_wdt_enable(void) +{ + u32 val; + + val = mfspr(SPRN_TCR); + val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(wdt_period)); + + mtspr(SPRN_TCR, val); +} + +/* + * booke_wdt_ping: + */ +static __inline__ void booke_wdt_ping(void) +{ + mtspr(SPRN_TSR, TSR_ENW|TSR_WIS); +} + +/* + * booke_wdt_write: + */ +static ssize_t booke_wdt_write (struct file *file, const char *buf, + size_t count, loff_t *ppos) +{ + booke_wdt_ping(); + return count; +} + +static struct watchdog_info ident = { + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, + .firmware_version = 0, + .identity = "PowerPC Book-E Watchdog", +}; + +/* + * booke_wdt_ioctl: + */ +static int booke_wdt_ioctl (struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + u32 tmp = 0; + + switch (cmd) { + case WDIOC_GETSUPPORT: + if (copy_to_user ((struct watchdog_info *) arg, &ident, + sizeof(struct watchdog_info))) + return -EFAULT; + case WDIOC_GETSTATUS: + return put_user(ident.options, (u32 *) arg); + case WDIOC_GETBOOTSTATUS: + /* XXX: something is clearing TSR */ + tmp = mfspr(SPRN_TSR) & TSR_WRS(3); + /* returns 1 if last reset was caused by the WDT */ + return (tmp ? 1 : 0); + case WDIOC_KEEPALIVE: + booke_wdt_ping(); + return 0; + case WDIOC_SETTIMEOUT: + if (get_user(wdt_period, (u32 *) arg)) + return -EFAULT; + mtspr(SPRN_TCR, (mfspr(SPRN_TCR)&~WDTP(0))|WDTP(wdt_period)); + return 0; + case WDIOC_GETTIMEOUT: + return put_user(wdt_period, (u32 *) arg); + case WDIOC_SETOPTIONS: + if (get_user(tmp, (u32 *) arg)) + return -EINVAL; + if (tmp == WDIOS_ENABLECARD) { + booke_wdt_ping(); + break; + } else + return -EINVAL; + return 0; + default: + return -ENOIOCTLCMD; + } + + return 0; +} +/* + * booke_wdt_open: + */ +static int booke_wdt_open (struct inode *inode, struct file *file) +{ + if (wdt_enable == 0) { + wdt_enable = 1; + booke_wdt_enable(); + printk (KERN_INFO "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n", + wdt_period); + } + + return 0; +} + +static struct file_operations booke_wdt_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = booke_wdt_write, + .ioctl = booke_wdt_ioctl, + .open = booke_wdt_open, +}; + +static struct miscdevice booke_wdt_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &booke_wdt_fops, +}; + +static void __exit booke_wdt_exit(void) +{ + misc_deregister(&booke_wdt_miscdev); +} + +/* + * booke_wdt_init: + */ +static int __init booke_wdt_init(void) +{ + int ret = 0; + + printk (KERN_INFO "PowerPC Book-E Watchdog Timer Loaded\n"); + ident.firmware_version = cpu_specs[0].pvr_value; + + ret = misc_register(&booke_wdt_miscdev); + if (ret) { + printk (KERN_CRIT "Cannot register miscdev on minor=%d (err=%d)\n", + WATCHDOG_MINOR, ret); + return ret; + } + + if (wdt_enable == 1) { + printk (KERN_INFO "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n", + wdt_period); + booke_wdt_enable(); + } + + return ret; +} +device_initcall(booke_wdt_init); -- cgit v1.2.3-18-g5258 From 0d8ba1a9793302fdcee3d6d4133c455023ca8ce9 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Sat, 3 Sep 2005 15:55:36 -0700 Subject: [PATCH] cpm_uart: Fix 2nd serial port on MPC8560 ADS The 2nd serial port on the MPC8560 ADS was not being configured correctly and thus could not be used as a console. Updated the defconfig for the board to configure the proper SCC channel for the 2nd serial port. Signed-off-by: Roy Zang Signed-off-by: Kumar Gala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/serial/cpm_uart/cpm_uart_cpm2.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c index c4c8f4b44f5..bcf4c99678c 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c @@ -142,12 +142,21 @@ void scc2_lineif(struct uart_cpm_port *pinfo) * be supported in a sane fashion. */ #ifndef CONFIG_STX_GP3 +#ifdef CONFIG_MPC8560_ADS + volatile iop_cpm2_t *io = &cpm2_immr->im_ioport; + io->iop_ppard |= 0x00000018; + io->iop_psord &= ~0x00000008; /* Rx */ + io->iop_psord &= ~0x00000010; /* Tx */ + io->iop_pdird &= ~0x00000008; /* Rx */ + io->iop_pdird |= 0x00000010; /* Tx */ +#else volatile iop_cpm2_t *io = &cpm2_immr->im_ioport; io->iop_pparb |= 0x008b0000; io->iop_pdirb |= 0x00880000; io->iop_psorb |= 0x00880000; io->iop_pdirb &= ~0x00030000; io->iop_psorb &= ~0x00030000; +#endif #endif cpm2_immr->im_cpmux.cmx_scr &= 0xff00ffff; cpm2_immr->im_cpmux.cmx_scr |= 0x00090000; -- cgit v1.2.3-18-g5258 From 638861d54eec6b04a88d5d8df8b790d87de80b8d Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Sat, 3 Sep 2005 15:55:37 -0700 Subject: [PATCH] cpm_uart: use schedule_timeout instead of direct call to schedule use schedule_timeout instead of direct call to schedule Signed-off-by: Marcelo Tosatti Signed-off-by: Kumar Gala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/serial/cpm_uart/cpm_uart_core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c index 282b32351d8..25825f2aba2 100644 --- a/drivers/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/serial/cpm_uart/cpm_uart_core.c @@ -403,10 +403,8 @@ static int cpm_uart_startup(struct uart_port *port) inline void cpm_uart_wait_until_send(struct uart_cpm_port *pinfo) { - unsigned long target_jiffies = jiffies + pinfo->wait_closing; - - while (!time_after(jiffies, target_jiffies)) - schedule(); + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(pinfo->wait_closing); } /* @@ -425,9 +423,12 @@ static void cpm_uart_shutdown(struct uart_port *port) /* If the port is not the console, disable Rx and Tx. */ if (!(pinfo->flags & FLAG_CONSOLE)) { /* Wait for all the BDs marked sent */ - while(!cpm_uart_tx_empty(port)) + while(!cpm_uart_tx_empty(port)) { + set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(2); - if(pinfo->wait_closing) + } + + if (pinfo->wait_closing) cpm_uart_wait_until_send(pinfo); /* Stop uarts */ -- cgit v1.2.3-18-g5258 From b0531b9b3299f3066b1db78f1693edabbba08b5c Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Sat, 3 Sep 2005 15:55:38 -0700 Subject: [PATCH] cpm_uart: Fix baseaddress for SMC 1 and 2 Base addess register for SMC 1 and 2 are never initialized. This means that they will not work unless a bootloader already configured them. The DPRAM already have space reserved, this patch just makes sure the base addess register is updated correctly on initialization. Signed-off-by: Rune Torgersen Signed-off-by: Kumar Gala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/serial/cpm_uart/cpm_uart_cpm2.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c index bcf4c99678c..15ad58d9488 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c @@ -266,6 +266,7 @@ int cpm_uart_init_portdesc(void) cpm_uart_ports[UART_SMC1].smcp = (smc_t *) & cpm2_immr->im_smc[0]; cpm_uart_ports[UART_SMC1].smcup = (smc_uart_t *) & cpm2_immr->im_dprambase[PROFF_SMC1]; + *(u16 *)(&cpm2_immr->im_dprambase[PROFF_SMC1_BASE]) = PROFF_SMC1; cpm_uart_ports[UART_SMC1].port.mapbase = (unsigned long)&cpm2_immr->im_smc[0]; cpm_uart_ports[UART_SMC1].smcp->smc_smcm |= (SMCM_RX | SMCM_TX); @@ -278,6 +279,7 @@ int cpm_uart_init_portdesc(void) cpm_uart_ports[UART_SMC2].smcp = (smc_t *) & cpm2_immr->im_smc[1]; cpm_uart_ports[UART_SMC2].smcup = (smc_uart_t *) & cpm2_immr->im_dprambase[PROFF_SMC2]; + *(u16 *)(&cpm2_immr->im_dprambase[PROFF_SMC2_BASE]) = PROFF_SMC2; cpm_uart_ports[UART_SMC2].port.mapbase = (unsigned long)&cpm2_immr->im_smc[1]; cpm_uart_ports[UART_SMC2].smcp->smc_smcm |= (SMCM_RX | SMCM_TX); -- cgit v1.2.3-18-g5258 From 39cdc4bfb5c587c617ab6a28083c19101154e149 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Sat, 3 Sep 2005 15:55:39 -0700 Subject: [PATCH] ppc32: Cleaned up global namespace of Book-E watchdog variables Renamed global variables used to convey if the watchdog is enabled and periodicity of the timer and moved the declarations into a header for these variables Signed-off-by: Matt McClintock Signed-off-by: Kumar Gala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/watchdog/Kconfig | 3 +++ drivers/char/watchdog/booke_wdt.c | 23 ++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index 95335b443a8..c3898afce3a 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig @@ -349,6 +349,9 @@ config 8xx_WDT config BOOKE_WDT tristate "PowerPC Book-E Watchdog Timer" depends on WATCHDOG && (BOOKE || 4xx) + ---help--- + Please see Documentation/watchdog/watchdog-api.txt for + more information. # MIPS Architecture diff --git a/drivers/char/watchdog/booke_wdt.c b/drivers/char/watchdog/booke_wdt.c index 7281f394f68..abc30cca664 100644 --- a/drivers/char/watchdog/booke_wdt.c +++ b/drivers/char/watchdog/booke_wdt.c @@ -23,6 +23,7 @@ #include #include +#include /* If the kernel parameter wdt_enable=1, the watchdog will be enabled at boot. * Also, the wdt_period sets the watchdog timer period timeout. @@ -38,8 +39,8 @@ #define WDT_PERIOD_DEFAULT 4 /* Refer to the PPC40x and PPC4xx manuals */ #endif /* for timing information */ -u32 wdt_enable = 0; -u32 wdt_period = WDT_PERIOD_DEFAULT; +u32 booke_wdt_enabled = 0; +u32 booke_wdt_period = WDT_PERIOD_DEFAULT; #ifdef CONFIG_FSL_BOOKE #define WDTP(x) ((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15)) @@ -55,7 +56,7 @@ static __inline__ void booke_wdt_enable(void) u32 val; val = mfspr(SPRN_TCR); - val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(wdt_period)); + val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period)); mtspr(SPRN_TCR, val); } @@ -108,12 +109,12 @@ static int booke_wdt_ioctl (struct inode *inode, struct file *file, booke_wdt_ping(); return 0; case WDIOC_SETTIMEOUT: - if (get_user(wdt_period, (u32 *) arg)) + if (get_user(booke_wdt_period, (u32 *) arg)) return -EFAULT; - mtspr(SPRN_TCR, (mfspr(SPRN_TCR)&~WDTP(0))|WDTP(wdt_period)); + mtspr(SPRN_TCR, (mfspr(SPRN_TCR)&~WDTP(0))|WDTP(booke_wdt_period)); return 0; case WDIOC_GETTIMEOUT: - return put_user(wdt_period, (u32 *) arg); + return put_user(booke_wdt_period, (u32 *) arg); case WDIOC_SETOPTIONS: if (get_user(tmp, (u32 *) arg)) return -EINVAL; @@ -134,11 +135,11 @@ static int booke_wdt_ioctl (struct inode *inode, struct file *file, */ static int booke_wdt_open (struct inode *inode, struct file *file) { - if (wdt_enable == 0) { - wdt_enable = 1; + if (booke_wdt_enabled == 0) { + booke_wdt_enabled = 1; booke_wdt_enable(); printk (KERN_INFO "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n", - wdt_period); + booke_wdt_period); } return 0; @@ -180,9 +181,9 @@ static int __init booke_wdt_init(void) return ret; } - if (wdt_enable == 1) { + if (booke_wdt_enabled == 1) { printk (KERN_INFO "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n", - wdt_period); + booke_wdt_period); booke_wdt_enable(); } -- cgit v1.2.3-18-g5258 From 61838ffeee8296de8bfee751e9ad67bf6c61d0b4 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Sat, 3 Sep 2005 15:56:09 -0700 Subject: [PATCH] DEC PMAG AA framebuffer update Get it working again. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/pmag-aa-fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/video/pmag-aa-fb.c b/drivers/video/pmag-aa-fb.c index 3e00ad7f2e3..28d1fe5fe34 100644 --- a/drivers/video/pmag-aa-fb.c +++ b/drivers/video/pmag-aa-fb.c @@ -413,7 +413,7 @@ static struct fb_ops aafb_ops = { static int __init init_one(int slot) { - unsigned long base_addr = get_tc_base_addr(slot); + unsigned long base_addr = CKSEG1ADDR(get_tc_base_addr(slot)); struct aafb_info *ip = &my_fb_info[slot]; memset(ip, 0, sizeof(struct aafb_info)); -- cgit v1.2.3-18-g5258 From af690a948cc545d1eca19acab23016b96e178dcf Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Sat, 3 Sep 2005 15:56:09 -0700 Subject: [PATCH] DEC PMAG BA frame buffer update Rewrite PMAG BA frame buffer driver for 2.6. Acked-by: Antonino Daplas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/pmag-ba-fb.c | 285 +++++++++++++++++++++++++++++---------------- 1 file changed, 183 insertions(+), 102 deletions(-) (limited to 'drivers') diff --git a/drivers/video/pmag-ba-fb.c b/drivers/video/pmag-ba-fb.c index f8095588e99..c98f1c8d7dc 100644 --- a/drivers/video/pmag-ba-fb.c +++ b/drivers/video/pmag-ba-fb.c @@ -1,57 +1,55 @@ /* - * linux/drivers/video/pmag-ba-fb.c + * linux/drivers/video/pmag-ba-fb.c * - * PMAG-BA TurboChannel framebuffer card support ... derived from: + * PMAG-BA TURBOchannel Color Frame Buffer (CFB) card support, + * derived from: * "HP300 Topcat framebuffer support (derived from macfb of all things) * Phil Blundell 1998", the original code can be - * found in the file hpfb.c in the same directory. + * found in the file hpfb.c in the same directory. * * Based on digital document: * "PMAG-BA TURBOchannel Color Frame Buffer * Functional Specification", Revision 1.2, August 27, 1990 * - * DECstation related code Copyright (C) 1999, 2000, 2001 by - * Michael Engel , - * Karsten Merker and + * DECstation related code Copyright (C) 1999, 2000, 2001 by + * Michael Engel , + * Karsten Merker and * Harald Koerfgen. - * 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 Maciej W. Rozycki * + * 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 +#include +#include +#include +#include + +#include +#include +#include + #include + #include