[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 3/5] gpio: Add GPIO Aggregator
From: |
Geert Uytterhoeven |
Subject: |
Re: [PATCH v5 3/5] gpio: Add GPIO Aggregator |
Date: |
Tue, 17 Mar 2020 12:32:31 +0100 |
On Tue, Feb 18, 2020 at 4:18 PM Geert Uytterhoeven
<address@hidden> 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 <address@hidden>
> --- /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 -- address@hidden
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