Message ID | 20241015162043.254517-1-prabhakar.mahadev-lad.rj@bp.renesas.com |
---|---|
State | Superseded |
Headers | show |
Series | [RFC] pinctrl: pinmux: Introduce API to check if a pin is requested | expand |
Hi Linus, Thank you for the review. On Tue, Oct 15, 2024 at 10:43 PM Linus Walleij <linus.walleij@linaro.org> wrote: > > Hi Prabhakar, > > thanks for your patch! > > On Tue, Oct 15, 2024 at 6:21 PM Prabhakar <prabhakar.csengg@gmail.com> wrote: > > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > Introduce `pin_requestesd` API to check if a pin is currently requested. > > What kind of function name is this? > > Do you mean > > pin_requested()? > Ouch, I will fix that. > > This API allows pinctrl drivers to verify whether a pin is requested or > > not by checking if the pin is owned by either `gpio_owner` or `mux_owner`. > > There is nothing wrong with the patch as such, but it needs to be > illustrated by submitting it together with the first intended user > and show how it is used, we don't add upfront APIs. > Sure, I will post the patches. Cheers, Prabhakar
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 02033ea1c643..19c68e174c36 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -99,6 +99,20 @@ bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned int pin) return !(ops->strict && !!desc->gpio_owner); } +bool pin_requestesd(struct pinctrl_dev *pctldev, int pin) +{ + struct pin_desc *desc; + + desc = pin_desc_get(pctldev, pin); + if (!desc) + return false; + + if (!desc->gpio_owner && !desc->mux_owner) + return false; + + return true; +} + /** * pin_request() - request a single pin to be muxed in, typically for GPIO * @pctldev: the associated pin controller device diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h index 2965ec20b77f..550cb3b4c068 100644 --- a/drivers/pinctrl/pinmux.h +++ b/drivers/pinctrl/pinmux.h @@ -42,6 +42,7 @@ int pinmux_map_to_setting(const struct pinctrl_map *map, void pinmux_free_setting(const struct pinctrl_setting *setting); int pinmux_enable_setting(const struct pinctrl_setting *setting); void pinmux_disable_setting(const struct pinctrl_setting *setting); +bool pin_requestesd(struct pinctrl_dev *pctldev, int pin); #else @@ -100,6 +101,10 @@ static inline void pinmux_disable_setting(const struct pinctrl_setting *setting) { } +bool pin_requestesd(struct pinctrl_dev *pctldev, int pin) +{ + return false; +} #endif #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)