lkml.org 
[lkml]   [2017]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/5] extcon: intel-cht-wc: Default to SDP on regmap io errors
Date
In the theoretical case of regmap_read failing get_charger would return
an error and we would continue with EXTCON_NONE.

Since we've already seen Vbus at this point, we should really set
some other cable value to avoid other drivers enabling the 5V boost
converter on the OTG port, even though there is an external Vbus.

This commit modifies cht_wc_extcon_get_charger() to always return a
valid cable, falling back to EXTCON_CHG_USB_SDP in case of regmap_read
errors. This also removes the need for error-checking from callers of
cht_wc_extcon_get_charger().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/extcon/extcon-intel-cht-wc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c
index 91a0023..8806427e 100644
--- a/drivers/extcon/extcon-intel-cht-wc.c
+++ b/drivers/extcon/extcon-intel-cht-wc.c
@@ -125,7 +125,7 @@ static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext,
ret = regmap_read(ext->regmap, CHT_WC_USBSRC, &usbsrc);
if (ret) {
dev_err(ext->dev, "Error reading usbsrc: %d\n", ret);
- return ret;
+ return EXTCON_CHG_USB_SDP; /* Save fallback */
}

status = usbsrc & CHT_WC_USBSRC_STS_MASK;
@@ -230,9 +230,7 @@ static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
goto set_state;
}

- ret = cht_wc_extcon_get_charger(ext, ignore_get_charger_errors);
- if (ret >= 0)
- cable = ret;
+ cable = cht_wc_extcon_get_charger(ext, ignore_get_charger_errors);

charger_det_done:
/* Route D+ and D- to SoC for the host or gadget controller */
--
2.9.3
\
 
 \ /
  Last update: 2017-04-21 15:02    [W:1.042 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site