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

From: Linus Walleij
Date: Fri Aug 12 2016 - 09:54:20 EST


On Thu, Aug 11, 2016 at 10:32 PM, Lucile Quirion
<lucile.quirion@xxxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxx>

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