mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
usb: dwc2: get optional vbus-supply regulator once
Move devm_regulator_get_optional() call to probe routine. This avoids
'vbus-supply' regulator to be requested lots of times, upon each call
to dwc2_vbus_supply_init(), e.g. like with runtime pm.
Fixes: 531ef5ebea
("usb: dwc2: add support for host mode external
vbus supply")
Tested-by: Artur Petrosyan <arturp@synopsys.com>
Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
parent
3def4031b3
commit
e0f681c2c1
2 changed files with 11 additions and 9 deletions
|
@ -358,16 +358,10 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg *hsotg)
|
|||
|
||||
static int dwc2_vbus_supply_init(struct dwc2_hsotg *hsotg)
|
||||
{
|
||||
int ret;
|
||||
if (hsotg->vbus_supply)
|
||||
return regulator_enable(hsotg->vbus_supply);
|
||||
|
||||
hsotg->vbus_supply = devm_regulator_get_optional(hsotg->dev, "vbus");
|
||||
if (IS_ERR(hsotg->vbus_supply)) {
|
||||
ret = PTR_ERR(hsotg->vbus_supply);
|
||||
hsotg->vbus_supply = NULL;
|
||||
return ret == -ENODEV ? 0 : ret;
|
||||
}
|
||||
|
||||
return regulator_enable(hsotg->vbus_supply);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dwc2_vbus_supply_exit(struct dwc2_hsotg *hsotg)
|
||||
|
|
|
@ -432,6 +432,14 @@ static int dwc2_driver_probe(struct platform_device *dev)
|
|||
if (retval)
|
||||
return retval;
|
||||
|
||||
hsotg->vbus_supply = devm_regulator_get_optional(hsotg->dev, "vbus");
|
||||
if (IS_ERR(hsotg->vbus_supply)) {
|
||||
retval = PTR_ERR(hsotg->vbus_supply);
|
||||
hsotg->vbus_supply = NULL;
|
||||
if (retval != -ENODEV)
|
||||
return retval;
|
||||
}
|
||||
|
||||
retval = dwc2_lowlevel_hw_enable(hsotg);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
|
Loading…
Reference in a new issue