lkml.org 
[lkml]   [2020]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v5 3/5] gpio: Add GPIO Aggregator
On Tue, Feb 18, 2020 at 4:18 PM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> GPIO controllers are exported to userspace using /dev/gpiochip*
> character devices. Access control to these devices is provided by
> standard UNIX file system permissions, on an all-or-nothing basis:
> either a GPIO controller is accessible for a user, or it is not.
> Currently no mechanism exists to control access to individual GPIOs.
>
> Hence add a GPIO driver to aggregate existing GPIOs, and expose them as
> a new gpiochip.
>
> This supports the following use cases:
> - Aggregating GPIOs using Sysfs
> This is useful for implementing access control, and assigning a set
> of GPIOs to a specific user or virtual machine.
> - Generic GPIO Driver
> This is useful for industrial control, where it can provide
> userspace access to a simple GPIO-operated device described in DT,
> cfr. e.g. spidev for SPI-operated devices.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

> --- /dev/null
> +++ b/drivers/gpio/gpio-aggregator.c

> +static int gpio_fwd_set_config(struct gpio_chip *chip, unsigned int offset,
> + unsigned long config)
> +{
> + struct gpiochip_fwd *fwd = gpiochip_get_data(chip);
> +
> + chip = fwd->descs[offset]->gdev->chip;
> + if (chip->set_config)

- chip = fwd->descs[offset]->gdev->chip;
- if (chip->set_config)
+ chip = gpiod_to_chip(fwd->descs[offset]);
+ if (chip && chip->set_config)

> + return chip->set_config(chip, offset, config);

This is not correct: offset should be translated, too, i.e.

offset = gpio_chip_hwgpio(fwd->descs[offset]);

Which adds a new dependency on "gpiolib.h"...

Is there a better alternative, than providing a public gpiod_set_config()
helper?
Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

\
 
 \ /
  Last update: 2020-03-17 12:33    [W:1.037 / U:0.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site