From 361fff778b7c4d2c78f28833415335148d86a1aa Mon Sep 17 00:00:00 2001 From: merge Date: Fri, 5 Dec 2008 09:59:34 +0000 Subject: MERGE-via-pending-tracking-hist-MERGE-via-stable-tracking-build-fix-path-to-toolchain-on-1228470136 pending-tracking-hist top was MERGE-via-stable-tracking-build-fix-path-to-toolchain-on-1228470136 / 21b67ab8e79998b0a534263282dab1dda0f11b00 ... parent commitmessage: From: merge MERGE-via-stable-tracking-hist-build-fix-path-to-toolchain-on stable-tracking-hist top was build-fix-path-to-toolchain-on / ca14ba894df9b28822066c578dde48d7dbe931de ... parent commitmessage: From: Andy Green build-fix-path-to-toolchain-one-at-last.patch Signed-off-by: Andy Green --- drivers/mfd/pcf50633-adc.c | 23 ++++++++++++++++------- drivers/mfd/pcf50633-core.c | 39 +++++++++++++++++++-------------------- drivers/mfd/pcf50633-gpio.c | 9 +++++---- 3 files changed, 40 insertions(+), 31 deletions(-) (limited to 'drivers/mfd') diff --git a/drivers/mfd/pcf50633-adc.c b/drivers/mfd/pcf50633-adc.c index ebd3792e778..e3d4eb1c03f 100644 --- a/drivers/mfd/pcf50633-adc.c +++ b/drivers/mfd/pcf50633-adc.c @@ -23,6 +23,11 @@ * MA 02111-1307 USA */ +/* + * NOTE: This driver does not yet support subtractive ADC mode, which means + * you can do only one measurement per read request. + */ + #include #include @@ -115,7 +120,7 @@ int pcf50633_adc_sync_read(struct pcf50633 *pcf, int mux, int avg) struct pcf50633_adc_request *req; int result; - /* req is freed when the result is ready, in pcf50633_work*/ + /* req is freed when the result is ready, in interrupt handler */ req = kzalloc(sizeof(*req), GFP_KERNEL); if (!req) return -ENOMEM; @@ -141,7 +146,7 @@ int pcf50633_adc_async_read(struct pcf50633 *pcf, int mux, int avg, { struct pcf50633_adc_request *req; - /* req is freed when the result is ready, in pcf50633_work*/ + /* req is freed when the result is ready, in interrupt handler */ req = kmalloc(sizeof(*req), GFP_KERNEL); if (!req) return -ENOMEM; @@ -159,12 +164,16 @@ EXPORT_SYMBOL_GPL(pcf50633_adc_async_read); static int adc_result(struct pcf50633 *pcf) { - u16 ret = (pcf50633_reg_read(pcf, PCF50633_REG_ADCS1) << 2) | - (pcf50633_reg_read(pcf, PCF50633_REG_ADCS3) & - PCF50633_ADCS3_ADCDAT1L_MASK); - dev_info(pcf->dev, "adc result = %d\n", ret); + u8 adcs1, adcs3; + u16 result; + + adcs1 = pcf50633_reg_read(pcf, PCF50633_REG_ADCS1); + adcs3 = pcf50633_reg_read(pcf, PCF50633_REG_ADCS3); + result = (adcs1 << 2) | (adcs3 & PCF50633_ADCS3_ADCDAT1L_MASK); - return ret; + dev_info(pcf->dev, "adc result = %d\n", result); + + return result; } static void pcf50633_adc_irq(struct pcf50633 *pcf, int irq, void *unused) diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index 891f7623377..6634558ea91 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c @@ -28,12 +28,8 @@ #include #include #include + #include -#include -#include -#include -#include -#include /* Read a block of upto 32 regs */ int pcf50633_read_block(struct pcf50633 *pcf , u8 reg, @@ -303,7 +299,7 @@ static void pcf50633_irq_worker(struct work_struct *work) /* Some revisions of the chip don't have a 8s standby mode on * ONKEY1S press. We try to manually do it in such cases. */ - if (pcf_int[0] & PCF50633_INT1_SECOND && pcf->onkey1s_held) { + if ((pcf_int[0] & PCF50633_INT1_SECOND) && pcf->onkey1s_held) { dev_info(pcf->dev, "ONKEY1S held for %d secs\n", pcf->onkey1s_held); if (pcf->onkey1s_held++ == PCF50633_ONKEY1S_TIMEOUT) @@ -320,11 +316,11 @@ static void pcf50633_irq_worker(struct work_struct *work) PCF50633_INT1_SECOND); /* Unmask IRQ_ONKEYR */ - pcf50633_reg_clear_bits(pcf, PCF50633_REG_INT1M, - PCF50633_INT1_SECOND); + pcf50633_reg_clear_bits(pcf, PCF50633_REG_INT2M, + PCF50633_INT2_ONKEYR); } - if (pcf_int[1] & PCF50633_INT2_ONKEYR & pcf->onkey1s_held) { + if ((pcf_int[1] & PCF50633_INT2_ONKEYR) && pcf->onkey1s_held) { pcf->onkey1s_held = 0; /* Mask SECOND and ONKEYR interrupts */ @@ -351,19 +347,18 @@ static void pcf50633_irq_worker(struct work_struct *work) pcf->resume_reason[i] = pcf_int[i] & pcf->pdata->resumers[i]; - /* Make sure we don't pass on any input events to + /* Make sure we don't pass on any ONKEY events to * userspace now */ - pcf_int[1] = 0; + pcf_int[1] &= ~ (PCF50633_INT2_ONKEYR | PCF50633_INT2_ONKEYF); } /* Unset masked interrupts */ - for (i = 0; i < 5; i++) + for (i = 0; i < ARRAY_SIZE(pcf_int); i++) { pcf_int[i] &= ~pcf->mask_regs[i]; - - for (i = 0; i < ARRAY_SIZE(pcf_int); i++) for (j = 0; j < 8 ; j++) if (pcf_int[i] & (1 << j)) pcf50633_irq_call_handler(pcf, (i * 8) + j); + } put_device(pcf->dev); @@ -434,7 +429,8 @@ static int pcf50633_suspend(struct device *dev, pm_message_t state) cancel_work_sync(&pcf->irq_work); /* Save the masks */ - ret = pcf50633_read_block(pcf, PCF50633_REG_INT1M, 5, + ret = pcf50633_read_block(pcf, PCF50633_REG_INT1M, + ARRAY_SIZE(pcf->suspend_irq_masks), pcf->suspend_irq_masks); if (ret < 0) dev_err(pcf->dev, "error saving irq masks\n"); @@ -442,10 +438,10 @@ static int pcf50633_suspend(struct device *dev, pm_message_t state) /* Set interrupt masks. So that only those sources we want to wake * us up can */ - for (i = 0; i < 5; i++) + for (i = 0; i < ARRAY_SIZE(res); i++) res[i] = ~pcf->pdata->resumers[i]; - pcf50633_write_block(pcf, PCF50633_REG_INT1M, 5, &res[0]); + pcf50633_write_block(pcf, PCF50633_REG_INT1M, ARRAY_SIZE(res), &res[0]); pcf->is_suspended = 1; @@ -459,13 +455,16 @@ static int pcf50633_resume(struct device *dev) pcf = dev_get_drvdata(dev); /* Write the saved mask registers */ - pcf50633_write_block(pcf, PCF50633_REG_INT1M, 5, + pcf50633_write_block(pcf, PCF50633_REG_INT1M, + ARRAY_SIZE(pcf->suspend_irq_masks), pcf->suspend_irq_masks); get_device(pcf->dev); - /* Clear any pending interrupts and set resume reason if any */ - /* this will leave with enable_irq() */ + /* + * Clear any pending interrupts and set resume reason if any. + * This will leave with enable_irq() + */ pcf50633_irq_worker(&pcf->irq_work); return 0; diff --git a/drivers/mfd/pcf50633-gpio.c b/drivers/mfd/pcf50633-gpio.c index a7117fa6282..55139071d22 100644 --- a/drivers/mfd/pcf50633-gpio.c +++ b/drivers/mfd/pcf50633-gpio.c @@ -42,7 +42,7 @@ int pcf50633_gpio_get(struct pcf50633 *pcf, int gpio) u8 reg, val; reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG; - val = pcf50633_reg_read(pcf, reg); + val = pcf50633_reg_read(pcf, reg) & 0x07; return val; } @@ -55,7 +55,7 @@ void pcf50633_gpio_invert_set(struct pcf50633 *pcf, int gpio, int invert) reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG; val = !!invert << 3; - pcf50633_reg_set_bit_mask(pcf, reg, val, val); + pcf50633_reg_set_bit_mask(pcf, reg, 1 << 3, val); } EXPORT_SYMBOL_GPL(pcf50633_gpio_invert_set); @@ -87,13 +87,14 @@ static const u8 pcf50633_regulator_registers[PCF50633_NUM_REGULATORS] = { void pcf50633_gpio_power_supply_set(struct pcf50633 *pcf, int gpio, int regulator, int on) { - u8 reg, val; + u8 reg, val, mask; /* the *ENA register is always one after the *OUT register */ reg = pcf50633_regulator_registers[regulator] + 1; val = (!!on << (gpio - PCF50633_GPIO1)); + mask = (1 << (gpio - PCF50633_GPIO1)); - pcf50633_reg_set_bit_mask(pcf, reg, val, val); + pcf50633_reg_set_bit_mask(pcf, reg, mask, val); } EXPORT_SYMBOL_GPL(pcf50633_gpio_power_supply_set); -- cgit v1.2.3