[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240524071034.4441-3-francesco@dolcini.it>
Date: Fri, 24 May 2024 09:10:34 +0200
From: Francesco Dolcini <francesco@...cini.it>
To: Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Francesco Dolcini <francesco.dolcini@...adex.com>,
linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org,
Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Bjorn Andersson <andersson@...nel.org>
Subject: [PATCH v1 2/2] usb: typec: mux: gpio-sbu: Make enable gpio optional
From: Francesco Dolcini <francesco.dolcini@...adex.com>
The enable gpio is not required when the SBU mux is used only for
orientation, make it optional.
Signed-off-by: Francesco Dolcini <francesco.dolcini@...adex.com>
---
drivers/usb/typec/mux/gpio-sbu-mux.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/typec/mux/gpio-sbu-mux.c b/drivers/usb/typec/mux/gpio-sbu-mux.c
index 374168482d36..cf44259980a1 100644
--- a/drivers/usb/typec/mux/gpio-sbu-mux.c
+++ b/drivers/usb/typec/mux/gpio-sbu-mux.c
@@ -47,7 +47,7 @@ static int gpio_sbu_switch_set(struct typec_switch_dev *sw,
break;
}
- if (enabled != sbu_mux->enabled)
+ if (sbu_mux->enable_gpio && enabled != sbu_mux->enabled)
gpiod_set_value_cansleep(sbu_mux->enable_gpio, enabled);
if (swapped != sbu_mux->swapped)
@@ -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");
@@ -141,7 +145,8 @@ static void gpio_sbu_mux_remove(struct platform_device *pdev)
{
struct gpio_sbu_mux *sbu_mux = platform_get_drvdata(pdev);
- gpiod_set_value_cansleep(sbu_mux->enable_gpio, 0);
+ if (sbu_mux->enable_gpio)
+ gpiod_set_value_cansleep(sbu_mux->enable_gpio, 0);
typec_mux_unregister(sbu_mux->mux);
typec_switch_unregister(sbu_mux->sw);
--
2.39.2
Powered by blists - more mailing lists