From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762044AbcLSAJt (ORCPT ); Sun, 18 Dec 2016 19:09:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37526 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757498AbcLSAHu (ORCPT ); Sun, 18 Dec 2016 19:07:50 -0500 From: Hans de Goede To: Sebastian Reichel , Chen-Yu Tsai , MyungJoo Ham , Chanwoo Choi Cc: "russianneuromancer @ ya . ru" , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Hans de Goede Subject: [PATCH 08/14] power: supply: axp288_charger: Actually get and use the USB_HOST extcon device Date: Mon, 19 Dec 2016 01:07:25 +0100 Message-Id: <20161219000731.10188-9-hdegoede@redhat.com> In-Reply-To: <20161219000731.10188-1-hdegoede@redhat.com> References: <20161219000731.10188-1-hdegoede@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 19 Dec 2016 00:07:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Nothing was setting info->otg.cable, so the extcon_get_cable_state_ calls on it would always return -EINVAL. This commit fixes this by actually setting info->otg.cable using the new extcon_get_extcon_dev_by_cable_id function. This commit also makes failing to register the extcon notifier for the USB_HOST cable an error rather then a warning, because we MUST have this notfier to properly disable the VBUS path when in host mode so that we're not drawing current from the 5V boost converter which is supplying power to the otg port when in host mode. Signed-off-by: Hans de Goede --- drivers/power/supply/axp288_charger.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c index 08a5dba..2b95db2 100644 --- a/drivers/power/supply/axp288_charger.c +++ b/drivers/power/supply/axp288_charger.c @@ -833,6 +833,12 @@ static int axp288_charger_probe(struct platform_device *pdev) return -EPROBE_DEFER; } + info->otg.cable = extcon_get_extcon_dev_by_cable_id(EXTCON_USB_HOST); + if (info->otg.cable == NULL) { + dev_dbg(dev, "EXTCON_USB_HOST is not ready, probe deferred\n"); + return -EPROBE_DEFER; + } + platform_set_drvdata(pdev, info); mutex_init(&info->lock); @@ -867,12 +873,12 @@ static int axp288_charger_probe(struct platform_device *pdev) info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt; ret = devm_extcon_register_notifier(dev, info->otg.cable, EXTCON_USB_HOST, &info->otg.id_nb); - if (ret) - dev_warn(&pdev->dev, "failed to register otg notifier\n"); - - if (info->otg.cable) - info->otg.id_short = extcon_get_cable_state_( - info->otg.cable, EXTCON_USB_HOST); + if (ret) { + dev_err(dev, "failed to register EXTCON_USB_HOST notifier\n"); + return ret; + } + info->otg.id_short = extcon_get_cable_state_(info->otg.cable, + EXTCON_USB_HOST); /* Register charger interrupts */ for (i = 0; i < CHRG_INTR_END; i++) { -- 2.9.3