[RFT PATCH v2] spi: bcm2835: reduce the abuse of the GPIO API
Linus Walleij
linus.walleij at linaro.org
Fri Sep 1 05:15:39 PDT 2023
On Fri, Sep 1, 2023 at 1:15 PM Bartosz Golaszewski <brgl at bgdev.pl> wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski at linaro.org>
>
> Currently the bcm2835 SPI driver uses functions that are available
> exclusively to GPIO providers as a way to handle a platform quirk. Let's
> use a slightly better alternative that avoids poking around in GPIOLIB's
> internals and use GPIO lookup tables.
>
> Link: https://www.spinics.net/lists/linux-gpio/msg36218.html
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski at linaro.org>
> +#include <linux/cleanup.h>
(...)
> - struct gpio_chip *chip;
> + struct gpiod_lookup_table *lookup __free(kfree) = NULL;
Whoa!
This is really neat.
As noted, it will confuse static checkers at no end, but they just have
to adopt. (CC to Dan C if he now runs into this.)
> + gpiod_add_lookup_table(lookup);
Maybe we should mention the obvious advantage to the previous
hack: if there is a "cs-gpios" in the device tree, it will take precedence,
because gpiod_find_and_request() will try gpiod_find_by_fwnode()
*first* and only if this fails it will fall back to gpiod_find().
Hm, maybe we should go and fix these device trees? :P
Reviewed-by: Linus Walleij <linus.walleij at linaro.org>
Yours,
Linus Walleij
More information about the linux-arm-kernel
mailing list