Commit f06947f2 authored by Marco Felsch's avatar Marco Felsch Committed by Greg Kroah-Hartman

usb: usb251xb: fix regulator probe and error handling

Commit 4d7201cd ("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: 4d7201cd ("usb: usb251xb: add vdd supply support")
Signed-off-by: default avatarMarco Felsch <m.felsch@pengutronix.de>
Cc: stable <stable@vger.kernel.org>
Acked-by: default avatarRichard Leitner <richard.leitner@skidata.com>
Link: https://lore.kernel.org/r/20200226072644.18490-1-m.felsch@pengutronix.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 96b4ea32
...@@ -424,10 +424,6 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, ...@@ -424,10 +424,6 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
return err; 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)) if (of_property_read_u16_array(np, "vendor-id", &hub->vendor_id, 1))
hub->vendor_id = USB251XB_DEF_VENDOR_ID; hub->vendor_id = USB251XB_DEF_VENDOR_ID;
...@@ -640,6 +636,13 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, ...@@ -640,6 +636,13 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
} }
#endif /* CONFIG_OF */ #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) static int usb251xb_probe(struct usb251xb *hub)
{ {
struct device *dev = hub->dev; struct device *dev = hub->dev;
...@@ -676,10 +679,19 @@ static int usb251xb_probe(struct usb251xb *hub) ...@@ -676,10 +679,19 @@ static int usb251xb_probe(struct usb251xb *hub)
if (err) if (err)
return 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); err = regulator_enable(hub->vdd);
if (err) if (err)
return err; return err;
err = devm_add_action_or_reset(dev,
usb251xb_regulator_disable_action, hub);
if (err)
return err;
err = usb251xb_connect(hub); err = usb251xb_connect(hub);
if (err) { if (err) {
dev_err(dev, "Failed to connect hub (%d)\n", err); dev_err(dev, "Failed to connect hub (%d)\n", err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment