On Mon, Sep 03, 2012 at 01:03:47PM +0200, Steffen Trumtrar wrote:
> Signed-off-by: Steffen Trumtrar <[email protected]>
> ---
> +static int stmpe_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
> +{
> +     struct stmpe_gpio_chip *stmpegpio = container_of(chip, struct 
> stmpe_gpio_chip, chip);
> +     struct stmpe_client_info *ci = (struct stmpe_client_info 
> *)stmpegpio->ci;
> +     int ret;
> +     u8 val;
> +
> +     ci->read_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), &val);
> +     val &= ~(1 << (gpio % 8));
> +     ret = ci->write_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), val);
> +
> +     if (ret)
> +             dev_err(chip->dev, "couldn't change direction. Write 
> failed!\n");
> +
> +     return 0;

Please propagate the error value.

> +}
> +
> +static int stmpe_gpio_direction_output(struct gpio_chip *chip, unsigned 
> gpio, int value)
> +{
> +     struct stmpe_gpio_chip *stmpegpio = container_of(chip, struct 
> stmpe_gpio_chip, chip);
> +     struct stmpe_client_info *ci = (struct stmpe_client_info 
> *)stmpegpio->ci;
> +     int ret;
> +     u8 val;
> +
> +     ci->read_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), &val);
> +     val |= 1 << (gpio % 8);
> +     ret = ci->write_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), val);
> +
> +     stmpe_gpio_set_value(chip, gpio, value);
> +
> +     if (ret)
> +             dev_err(chip->dev, "couldn't change direction. Write 
> failed!\n");
> +
> +     return 0;

ditto

> +
> +static int stmpe_gpio_probe(struct device_d *dev)
> +{
> +     struct stmpe_gpio_chip *stmpegpio;
> +     struct stmpe_client_info *ci;
> +
> +     stmpegpio = xzalloc(sizeof(*stmpegpio));
> +
> +     stmpegpio->base = dev_request_mem_region(dev, 0);
> +     stmpegpio->chip.ops = &stmpe_gpio_ops;
> +     stmpegpio->ci = dev->platform_data;
> +
> +     ci = (struct stmpe_client_info *)stmpegpio->ci;
> +
> +     if (ci->stmpe->pdata->gpio_base)
> +             stmpegpio->chip.base = ci->stmpe->pdata->gpio_base;
> +     else
> +             stmpegpio->chip.base = -1;
> +
> +     stmpegpio->chip.ngpio = 16;
> +     stmpegpio->chip.dev = dev;
> +
> +     gpiochip_add(&stmpegpio->chip);

It's worth checking the return value of gpiochip_add. It could indicate
that the selected chip.base is busy.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to