Message ID | 20250217-03-k1-gpio-v5-1-2863ec3e7b67@gentoo.org (mailing list archive) |
---|---|
State | Handled Elsewhere |
Headers | show |
Series | riscv: spacemit: add gpio support for K1 SoC | expand |
Context | Check | Description |
---|---|---|
bjorn/pre-ci_am | success | Success |
bjorn/build-rv32-defconfig | success | build-rv32-defconfig |
bjorn/build-rv64-clang-allmodconfig | success | build-rv64-clang-allmodconfig |
bjorn/build-rv64-gcc-allmodconfig | success | build-rv64-gcc-allmodconfig |
bjorn/build-rv64-nommu-k210-defconfig | success | build-rv64-nommu-k210-defconfig |
bjorn/build-rv64-nommu-k210-virt | success | build-rv64-nommu-k210-virt |
bjorn/checkpatch | success | checkpatch |
bjorn/dtb-warn-rv64 | success | dtb-warn-rv64 |
bjorn/header-inline | success | header-inline |
bjorn/kdoc | success | kdoc |
bjorn/module-param | success | module-param |
bjorn/verify-fixes | success | verify-fixes |
bjorn/verify-signedoff | success | verify-signedoff |
On Mon, Feb 17, 2025 at 1:58 PM Yixun Lan <dlan@gentoo.org> wrote: > > Export custom function to add gpio pin range from pinctrl > subsystem. This would make it possible to add pins to multi > gpio chips. > > Signed-off-by: Yixun Lan <dlan@gentoo.org> > --- > drivers/gpio/gpiolib-of.c | 5 ++++- > include/linux/gpio/driver.h | 7 +++++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c > index 2e537ee979f3e2b6e8d5f86f3e121a66f2a8e083..64c8a153b823d65faebed9c4cd87952359b42765 100644 > --- a/drivers/gpio/gpiolib-of.c > +++ b/drivers/gpio/gpiolib-of.c > @@ -1170,7 +1170,10 @@ int of_gpiochip_add(struct gpio_chip *chip) > if (chip->of_gpio_n_cells > MAX_PHANDLE_ARGS) > return -EINVAL; > > - ret = of_gpiochip_add_pin_range(chip); > + if (!chip->of_add_pin_range) > + chip->of_add_pin_range = of_gpiochip_add_pin_range; > + > + ret = chip->of_add_pin_range(chip); > if (ret) > return ret; > > diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h > index 2dd7cb9cc270a68ddedbcdd5d44e0d0f88dfa785..a7b966c78a2f62075fb7804f6e96028564dda161 100644 > --- a/include/linux/gpio/driver.h > +++ b/include/linux/gpio/driver.h > @@ -528,6 +528,13 @@ struct gpio_chip { > */ > int (*of_xlate)(struct gpio_chip *gc, > const struct of_phandle_args *gpiospec, u32 *flags); > + > + /** > + * @of_add_pin_range: > + * > + * Callback to add pin ranges from pinctrl > + */ Please, make the API contract more specific: describe the return value and check it in the call place if it can return errors. Also: is this even OF-specific if it doesn't take any OF argument? Why not just add_pin_range()? Bart > + int (*of_add_pin_range)(struct gpio_chip *chip); > #endif /* CONFIG_OF_GPIO */ > }; > > > -- > 2.48.1 >
Hi Bartosz Golaszewski: On 11:22 Thu 20 Feb , Bartosz Golaszewski wrote: > On Mon, Feb 17, 2025 at 1:58 PM Yixun Lan <dlan@gentoo.org> wrote: > > > > Export custom function to add gpio pin range from pinctrl > > subsystem. This would make it possible to add pins to multi > > gpio chips. > > > > Signed-off-by: Yixun Lan <dlan@gentoo.org> > > --- > > drivers/gpio/gpiolib-of.c | 5 ++++- > > include/linux/gpio/driver.h | 7 +++++++ > > 2 files changed, 11 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c > > index 2e537ee979f3e2b6e8d5f86f3e121a66f2a8e083..64c8a153b823d65faebed9c4cd87952359b42765 100644 > > --- a/drivers/gpio/gpiolib-of.c > > +++ b/drivers/gpio/gpiolib-of.c > > @@ -1170,7 +1170,10 @@ int of_gpiochip_add(struct gpio_chip *chip) > > if (chip->of_gpio_n_cells > MAX_PHANDLE_ARGS) > > return -EINVAL; > > > > - ret = of_gpiochip_add_pin_range(chip); > > + if (!chip->of_add_pin_range) > > + chip->of_add_pin_range = of_gpiochip_add_pin_range; > > + > > + ret = chip->of_add_pin_range(chip); > > if (ret) > > return ret; > > > > diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h > > index 2dd7cb9cc270a68ddedbcdd5d44e0d0f88dfa785..a7b966c78a2f62075fb7804f6e96028564dda161 100644 > > --- a/include/linux/gpio/driver.h > > +++ b/include/linux/gpio/driver.h > > @@ -528,6 +528,13 @@ struct gpio_chip { > > */ > > int (*of_xlate)(struct gpio_chip *gc, > > const struct of_phandle_args *gpiospec, u32 *flags); > > + > > + /** > > + * @of_add_pin_range: > > + * > > + * Callback to add pin ranges from pinctrl > > + */ > > Please, make the API contract more specific: describe the return value > and check it in the call place if it can return errors. > > Also: is this even OF-specific if it doesn't take any OF argument? Why > not just add_pin_range()? > now, this patch is obsolete, please ignore it will be replaced by the one sent by LinusW https://lore.kernel.org/all/20250218-gpio-ranges-fourcell-v1-0-b1f3db6c8036@linaro.org/ > Bart > > > > + int (*of_add_pin_range)(struct gpio_chip *chip); > > #endif /* CONFIG_OF_GPIO */ > > }; > > > > > > -- > > 2.48.1 > > >
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 2e537ee979f3e2b6e8d5f86f3e121a66f2a8e083..64c8a153b823d65faebed9c4cd87952359b42765 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -1170,7 +1170,10 @@ int of_gpiochip_add(struct gpio_chip *chip) if (chip->of_gpio_n_cells > MAX_PHANDLE_ARGS) return -EINVAL; - ret = of_gpiochip_add_pin_range(chip); + if (!chip->of_add_pin_range) + chip->of_add_pin_range = of_gpiochip_add_pin_range; + + ret = chip->of_add_pin_range(chip); if (ret) return ret; diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 2dd7cb9cc270a68ddedbcdd5d44e0d0f88dfa785..a7b966c78a2f62075fb7804f6e96028564dda161 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -528,6 +528,13 @@ struct gpio_chip { */ int (*of_xlate)(struct gpio_chip *gc, const struct of_phandle_args *gpiospec, u32 *flags); + + /** + * @of_add_pin_range: + * + * Callback to add pin ranges from pinctrl + */ + int (*of_add_pin_range)(struct gpio_chip *chip); #endif /* CONFIG_OF_GPIO */ };
Export custom function to add gpio pin range from pinctrl subsystem. This would make it possible to add pins to multi gpio chips. Signed-off-by: Yixun Lan <dlan@gentoo.org> --- drivers/gpio/gpiolib-of.c | 5 ++++- include/linux/gpio/driver.h | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-)