From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1039571AbdDUNB7 (ORCPT ); Fri, 21 Apr 2017 09:01:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34436 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1038246AbdDUNB0 (ORCPT ); Fri, 21 Apr 2017 09:01:26 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9CEC4C0467CB Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=hdegoede@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9CEC4C0467CB From: Hans de Goede To: MyungJoo Ham , Chanwoo Choi Cc: Hans de Goede , linux-kernel@vger.kernel.org Subject: [PATCH 3/5] extcon: intel-cht-wc: Default to SDP on regmap io errors Date: Fri, 21 Apr 2017 15:01:17 +0200 Message-Id: <20170421130119.6187-3-hdegoede@redhat.com> In-Reply-To: <20170421130119.6187-1-hdegoede@redhat.com> References: <20170421130119.6187-1-hdegoede@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 21 Apr 2017 13:01:25 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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