* [PATCH] usb: usb251xb: fix regulator probe and error handling
@ 2020-02-26 7:26 Marco Felsch
2020-02-26 8:01 ` Richard Leitner
0 siblings, 1 reply; 2+ messages in thread
From: Marco Felsch @ 2020-02-26 7:26 UTC (permalink / raw)
To: richard.leitner, fancer.lancer, gregkh; +Cc: linux-usb, kernel
Commit 4d7201cda226 ("usb: usb251xb: add vdd supply support") didn't
covered the non-DT use-case and so the regualtor_enable() call during
probe will fail on those platforms. Also the commit didn't handled the
error case correctly.
Move devm_regulator_get() out of usb251xb_get_ofdata() to address the
1st issue. This can be done without worries because devm_regulator_get()
handles the non-DT use-case too. Add devm_add_action_or_reset() to
address the 2nd bug.
Fixes: 4d7201cda226 ("usb: usb251xb: add vdd supply support")
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
Hi,
unfortunately I didn't covered the non-DT use case during the devel of
commit 4d7201cda226 and I was a bit to optimistic so I also missed the
error handling.
Regards,
Marco
drivers/usb/misc/usb251xb.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 10c9e7f6273e..29fe5771c21b 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -424,10 +424,6 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
return err;
}
- hub->vdd = devm_regulator_get(dev, "vdd");
- if (IS_ERR(hub->vdd))
- return PTR_ERR(hub->vdd);
-
if (of_property_read_u16_array(np, "vendor-id", &hub->vendor_id, 1))
hub->vendor_id = USB251XB_DEF_VENDOR_ID;
@@ -640,6 +636,13 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
}
#endif /* CONFIG_OF */
+static void usb251xb_regulator_disable_action(void *data)
+{
+ struct usb251xb *hub = data;
+
+ regulator_disable(hub->vdd);
+}
+
static int usb251xb_probe(struct usb251xb *hub)
{
struct device *dev = hub->dev;
@@ -676,10 +679,19 @@ static int usb251xb_probe(struct usb251xb *hub)
if (err)
return err;
+ hub->vdd = devm_regulator_get(dev, "vdd");
+ if (IS_ERR(hub->vdd))
+ return PTR_ERR(hub->vdd);
+
err = regulator_enable(hub->vdd);
if (err)
return err;
+ err = devm_add_action_or_reset(dev,
+ usb251xb_regulator_disable_action, hub);
+ if (err)
+ return err;
+
err = usb251xb_connect(hub);
if (err) {
dev_err(dev, "Failed to connect hub (%d)\n", err);
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: usb251xb: fix regulator probe and error handling
2020-02-26 7:26 [PATCH] usb: usb251xb: fix regulator probe and error handling Marco Felsch
@ 2020-02-26 8:01 ` Richard Leitner
0 siblings, 0 replies; 2+ messages in thread
From: Richard Leitner @ 2020-02-26 8:01 UTC (permalink / raw)
To: Marco Felsch; +Cc: fancer.lancer, gregkh, linux-usb, kernel
On Wed, Feb 26, 2020 at 08:26:44AM +0100, Marco Felsch wrote:
> Commit 4d7201cda226 ("usb: usb251xb: add vdd supply support") didn't
> covered the non-DT use-case and so the regualtor_enable() call during
> probe will fail on those platforms. Also the commit didn't handled the
> error case correctly.
>
> Move devm_regulator_get() out of usb251xb_get_ofdata() to address the
> 1st issue. This can be done without worries because devm_regulator_get()
> handles the non-DT use-case too. Add devm_add_action_or_reset() to
> address the 2nd bug.
>
> Fixes: 4d7201cda226 ("usb: usb251xb: add vdd supply support")
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
Looks fine to me.
Acked-by: Richard Leitner <richard.leitner@skidata.com>
> Hi,
>
> unfortunately I didn't covered the non-DT use case during the devel of
> commit 4d7201cda226 and I was a bit to optimistic so I also missed the
> error handling.
>
> Regards,
> Marco
>
> drivers/usb/misc/usb251xb.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
regards;rl
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-26 8:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-26 7:26 [PATCH] usb: usb251xb: fix regulator probe and error handling Marco Felsch
2020-02-26 8:01 ` Richard Leitner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).