aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/phy/phy.c
diff options
context:
space:
mode:
authorBaolin Wang <baolin.wang@linaro.org>2017-12-07 00:26:14 -0500
committerFelipe Balbi <felipe.balbi@linux.intel.com>2017-12-12 06:04:03 -0500
commit655283a7f5e047f2541cbcd60eecada705931b1a (patch)
tree91384ae2de17a8f829f5f5eaac1d579a06304669 /drivers/usb/phy/phy.c
parent42bf02ec6e420e541af9a47437d0bdf961ca2972 (diff)
usb: phy: Factor out the usb charger initialization
Factor out the guts of usb charger initialization into usb_charger_init() function, to make the usb_add_extcon() only do the extcon related things. Meanwhile we also should initialize the USB charger before registering the extcon device, in case the extcon notification was issued earlier than usb charger initialization. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/phy/phy.c')
-rw-r--r--drivers/usb/phy/phy.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index f97cb47577fc..bceb2c9988dd 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -323,6 +323,14 @@ static int devm_usb_phy_match(struct device *dev, void *res, void *match_data)
323 return *phy == match_data; 323 return *phy == match_data;
324} 324}
325 325
326static void usb_charger_init(struct usb_phy *usb_phy)
327{
328 usb_phy->chg_type = UNKNOWN_TYPE;
329 usb_phy->chg_state = USB_CHARGER_DEFAULT;
330 usb_phy_set_default_current(usb_phy);
331 INIT_WORK(&usb_phy->chg_work, usb_phy_notify_charger_work);
332}
333
326static int usb_add_extcon(struct usb_phy *x) 334static int usb_add_extcon(struct usb_phy *x)
327{ 335{
328 int ret; 336 int ret;
@@ -406,10 +414,6 @@ static int usb_add_extcon(struct usb_phy *x)
406 } 414 }
407 } 415 }
408 416
409 usb_phy_set_default_current(x);
410 INIT_WORK(&x->chg_work, usb_phy_notify_charger_work);
411 x->chg_type = UNKNOWN_TYPE;
412 x->chg_state = USB_CHARGER_DEFAULT;
413 if (x->type_nb.notifier_call) 417 if (x->type_nb.notifier_call)
414 __usb_phy_get_charger_type(x); 418 __usb_phy_get_charger_type(x);
415 419
@@ -704,6 +708,7 @@ int usb_add_phy(struct usb_phy *x, enum usb_phy_type type)
704 return -EINVAL; 708 return -EINVAL;
705 } 709 }
706 710
711 usb_charger_init(x);
707 ret = usb_add_extcon(x); 712 ret = usb_add_extcon(x);
708 if (ret) 713 if (ret)
709 return ret; 714 return ret;
@@ -749,6 +754,7 @@ int usb_add_phy_dev(struct usb_phy *x)
749 return -EINVAL; 754 return -EINVAL;
750 } 755 }
751 756
757 usb_charger_init(x);
752 ret = usb_add_extcon(x); 758 ret = usb_add_extcon(x);
753 if (ret) 759 if (ret)
754 return ret; 760 return ret;