Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1461185

Re: [PATCH v3 2/2] gpio: add Technologic I2C-FPGA gpio support

From Linus Walleij <linus.walleij@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH v3 2/2] gpio: add Technologic I2C-FPGA gpio support
Date 2016-08-12 16:00 +0200
Message-ID <s5laa-2oe-5@gated-at.bofh.it> (permalink)
References <s54VI-jh-5@gated-at.bofh.it> <s54VI-jh-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Aug 11, 2016 at 10:32 PM, Lucile Quirion
<lucile.quirion@savoirfairelinux.com> wrote:

> This driver is generic and aims to support all Technologic Systems's
> boards embedding FPGA GPIOs with an I2C interface.
>
> This driver supports TS-4900, TS-7970, TS-7990 and TS-4100 series.
>
> Signed-off-by: Lucile Quirion <lucile.quirion@savoirfairelinux.com>

Much smaller and nicer now :)

> +config GPIO_TS4900
> +       tristate "Technologic Systems FPGA I2C GPIO"

select REGMAP_I2C

Here.

> +#include <linux/gpio.h>

Drop that. You should not use this header in drivers.

> +static int ts4900_gpio_get_direction(struct gpio_chip *chip,
> +                                    unsigned int offset)
> +{
> +       struct ts4900_gpio_priv *priv = gpiochip_get_data(chip);
> +       unsigned int reg;
> +
> +       regmap_read(priv->regmap, offset, &reg);
> +
> +       return (reg & TS4900_GPIO_OE) ? GPIOF_DIR_OUT : GPIOF_DIR_IN;

Do not use GPIOF_DIR_OUT/GPIOF_DIR_IN. These are for the
machine descriptions, not drivers. Just return 0/1.

You can even:

return !(reg & TS4900_GPIO_OE);

I think that returns 0 on output and 1 on input.

After these fixes I will be happy I think.

Yours,
Linus Walleij

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v3 2/2] gpio: add Technologic I2C-FPGA gpio support Lucile Quirion <lucile.quirion@savoirfairelinux.com> - 2016-08-11 22:40 +0200
  Re: [PATCH v3 2/2] gpio: add Technologic I2C-FPGA gpio support Linus Walleij <linus.walleij@linaro.org> - 2016-08-12 16:00 +0200

csiph-web