lkml.org 
[lkml]   [2010]   [Feb]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 2/3] cs5535-gpio: Use set_direction
    Date
    The CS5535 GPIO has independant controls for input and output enable.
    Use the set_direction method instead of direction_input and direction_output
    to enable use of the bidirectional mode.

    Signed-off-by: Ben Gardner <gardner.ben@gmail.com>
    CC: Andres Salomon <dilinger@collabora.co.uk>
    CC: Andrew Morton <akpm@linux-foundation.org>
    CC: David Brownell <dbrownell@users.sourceforge.net>
    CC: Jani Nikula <ext-jani.1.nikula@nokia.com>
    ---
    drivers/gpio/cs5535-gpio.c | 34 +++++++++++++++-------------------
    1 files changed, 15 insertions(+), 19 deletions(-)

    diff --git a/drivers/gpio/cs5535-gpio.c b/drivers/gpio/cs5535-gpio.c
    index 0fdbe94..0cb1462 100644
    --- a/drivers/gpio/cs5535-gpio.c
    +++ b/drivers/gpio/cs5535-gpio.c
    @@ -165,30 +165,27 @@ static void chip_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
    cs5535_gpio_clear(offset, GPIO_OUTPUT_VAL);
    }

    -static int chip_direction_input(struct gpio_chip *c, unsigned offset)
    -{
    - struct cs5535_gpio_chip *chip = (struct cs5535_gpio_chip *) c;
    - unsigned long flags;
    -
    - spin_lock_irqsave(&chip->lock, flags);
    - __cs5535_gpio_set(chip, offset, GPIO_INPUT_ENABLE);
    - spin_unlock_irqrestore(&chip->lock, flags);
    -
    - return 0;
    -}
    -
    -static int chip_direction_output(struct gpio_chip *c, unsigned offset, int val)
    +static int chip_set_direction(struct gpio_chip *c, unsigned offset,
    + int direction, int value)
    {
    struct cs5535_gpio_chip *chip = (struct cs5535_gpio_chip *) c;
    unsigned long flags;

    spin_lock_irqsave(&chip->lock, flags);

    - __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_ENABLE);
    - if (val)
    - __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_VAL);
    + if (direction & 1)
    + __cs5535_gpio_set(chip, offset, GPIO_INPUT_ENABLE);
    else
    - __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_VAL);
    + __cs5535_gpio_clear(chip, offset, GPIO_INPUT_ENABLE);
    +
    + if (direction & 2) {
    + if (value)
    + __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_VAL);
    + else
    + __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_VAL);
    + __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_ENABLE);
    + } else
    + __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_ENABLE);

    spin_unlock_irqrestore(&chip->lock, flags);

    @@ -219,8 +216,7 @@ static struct cs5535_gpio_chip cs5535_gpio_chip = {
    .get = chip_gpio_get,
    .set = chip_gpio_set,

    - .direction_input = chip_direction_input,
    - .direction_output = chip_direction_output,
    + .set_direction = chip_set_direction,
    },
    };

    --
    1.7.0


    \
     
     \ /
      Last update: 2010-02-27 00:29    [W:0.043 / U:0.464 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site