2024-06-03 08:36:55

by Francesco Dolcini

[permalink] [raw]
Subject: [PATCH v2 0/2] usb: typec: mux: gpio-sbu: Make enable gpio optional

From: Francesco Dolcini <[email protected]>

The enable gpio is not required when the SBU mux is used only for orientation,
make it optional.

v2:
- add Acked-by: Conor Dooley
- remove useless NULL checks for the optional enable GPIO
v1:
- https://lore.kernel.org/all/[email protected]/

Francesco Dolcini (2):
dt-bindings: usb: gpio-sbu-mux: Make 'enable-gpios' optional
usb: typec: mux: gpio-sbu: Make enable gpio optional

Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml | 7 ++++++-
drivers/usb/typec/mux/gpio-sbu-mux.c | 6 +++++-
2 files changed, 11 insertions(+), 2 deletions(-)

--
2.39.2



2024-06-03 08:40:48

by Francesco Dolcini

[permalink] [raw]
Subject: [PATCH v2 2/2] usb: typec: mux: gpio-sbu: Make enable gpio optional

From: Francesco Dolcini <[email protected]>

The enable gpio is not required when the SBU mux is used only for
orientation, make it optional.

Signed-off-by: Francesco Dolcini <[email protected]>
---
v2:
- removed useless NULL check for optional enable gpio
---
drivers/usb/typec/mux/gpio-sbu-mux.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/mux/gpio-sbu-mux.c b/drivers/usb/typec/mux/gpio-sbu-mux.c
index 374168482d36..8902102c05a8 100644
--- a/drivers/usb/typec/mux/gpio-sbu-mux.c
+++ b/drivers/usb/typec/mux/gpio-sbu-mux.c
@@ -66,6 +66,9 @@ static int gpio_sbu_mux_set(struct typec_mux_dev *mux,
{
struct gpio_sbu_mux *sbu_mux = typec_mux_get_drvdata(mux);

+ if (!sbu_mux->enable_gpio)
+ return -EOPNOTSUPP;
+
mutex_lock(&sbu_mux->lock);

switch (state->mode) {
@@ -102,7 +105,8 @@ static int gpio_sbu_mux_probe(struct platform_device *pdev)

mutex_init(&sbu_mux->lock);

- sbu_mux->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
+ sbu_mux->enable_gpio = devm_gpiod_get_optional(dev, "enable",
+ GPIOD_OUT_LOW);
if (IS_ERR(sbu_mux->enable_gpio))
return dev_err_probe(dev, PTR_ERR(sbu_mux->enable_gpio),
"unable to acquire enable gpio\n");
--
2.39.2


2024-06-03 10:12:34

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] usb: typec: mux: gpio-sbu: Make enable gpio optional

On Mon, Jun 03, 2024 at 10:35:58AM +0200, Francesco Dolcini wrote:
> From: Francesco Dolcini <[email protected]>
>
> The enable gpio is not required when the SBU mux is used only for
> orientation, make it optional.
>
> Signed-off-by: Francesco Dolcini <[email protected]>
> ---
> v2:
> - removed useless NULL check for optional enable gpio
> ---
> drivers/usb/typec/mux/gpio-sbu-mux.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>

Reviewed-by: Dmitry Baryshkov <[email protected]>


--
With best wishes
Dmitry

2024-06-03 11:56:12

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] usb: typec: mux: gpio-sbu: Make enable gpio optional

On Mon, Jun 03, 2024 at 10:35:58AM +0200, Francesco Dolcini wrote:
> From: Francesco Dolcini <[email protected]>
>
> The enable gpio is not required when the SBU mux is used only for
> orientation, make it optional.
>
> Signed-off-by: Francesco Dolcini <[email protected]>

Reviewed-by: Heikki Krogerus <[email protected]>

> ---
> v2:
> - removed useless NULL check for optional enable gpio
> ---
> drivers/usb/typec/mux/gpio-sbu-mux.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/mux/gpio-sbu-mux.c b/drivers/usb/typec/mux/gpio-sbu-mux.c
> index 374168482d36..8902102c05a8 100644
> --- a/drivers/usb/typec/mux/gpio-sbu-mux.c
> +++ b/drivers/usb/typec/mux/gpio-sbu-mux.c
> @@ -66,6 +66,9 @@ static int gpio_sbu_mux_set(struct typec_mux_dev *mux,
> {
> struct gpio_sbu_mux *sbu_mux = typec_mux_get_drvdata(mux);
>
> + if (!sbu_mux->enable_gpio)
> + return -EOPNOTSUPP;
> +
> mutex_lock(&sbu_mux->lock);
>
> switch (state->mode) {
> @@ -102,7 +105,8 @@ static int gpio_sbu_mux_probe(struct platform_device *pdev)
>
> mutex_init(&sbu_mux->lock);
>
> - sbu_mux->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
> + sbu_mux->enable_gpio = devm_gpiod_get_optional(dev, "enable",
> + GPIOD_OUT_LOW);
> if (IS_ERR(sbu_mux->enable_gpio))
> return dev_err_probe(dev, PTR_ERR(sbu_mux->enable_gpio),
> "unable to acquire enable gpio\n");
> --
> 2.39.2

--
heikki