Re: [PATCH v3 4/6] bus: add driver for the Technologic Systems NBUS

From: Linus Walleij
Date: Thu May 11 2017 - 09:58:44 EST


On Fri, May 5, 2017 at 9:32 PM, Sebastien Bourdelin
<sebastien.bourdelin@xxxxxxxxxxxxxxxxxxxx> wrote:

> This driver implements a GPIOs bit-banged bus, called the NBUS by
> Technologic Systems. It is used to communicate with the peripherals in
> the FPGA on the TS-4600 SoM.
>
> Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@xxxxxxxxxxxxxxxxxxxx>
> ---
> Changes v2 -> v3:

This driver is pretty.
Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

For future development (that is not about this patch, please
merge this):

> +static int ts_nbus_read_byte(struct ts_nbus *ts_nbus, u8 *val)
> +{
> + struct gpio_descs *gpios = ts_nbus->data;
> + int ret, i;
> +
> + *val = 0;
> + for (i = 0; i < 8; i++) {
> + ret = gpiod_get_value_cansleep(gpios->desc[i]);
> + if (ret < 0)
> + return ret;
> + if (ret)
> + *val |= BIT(i);
> + }
> +
> + return 0;
> +}

That makes it pretty obvious that we really need gpiod_get_array_cansleep()
does it not. That would just become some single register read in
this case.

If you get some time one of these days and wand to have a go at adding
it to gpiolib using this driver as a testbed, do not hesitate.

Yours,
Linus Walleij