From patchwork Sat Nov 10 18:10:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 10677389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3217F1709 for ; Sat, 10 Nov 2018 18:11:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25DA92C911 for ; Sat, 10 Nov 2018 18:11:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 170592C918; Sat, 10 Nov 2018 18:11:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A1432C911 for ; Sat, 10 Nov 2018 18:11:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727169AbeKKD5B (ORCPT ); Sat, 10 Nov 2018 22:57:01 -0500 Received: from mga12.intel.com ([192.55.52.136]:15025 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbeKKD5B (ORCPT ); Sat, 10 Nov 2018 22:57:01 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Nov 2018 10:11:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,488,1534834800"; d="scan'208";a="90126921" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 10 Nov 2018 10:11:03 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id C77791AC; Sat, 10 Nov 2018 20:11:02 +0200 (EET) From: Andy Shevchenko To: MyungJoo Ham , Chanwoo Choi , linux-usb@vger.kernel.org, Felipe Balbi , Guenter Roeck , Heikki Krogerus , Roger Quadros , linux-pm@vger.kernel.org, "Rafael J. Wysocki" , Sebastian Reichel , linux-omap@vger.kernel.org, Darren Hart , platform-driver-x86@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Chen-Yu Tsai , Hans de Goede Cc: Andy Shevchenko , Grant Likely , Peter Ujfalusi , Mark Brown , Andrzej Hajda Subject: [PATCH v1 1/5] drivercore: Revert "deferral race condition fix" Date: Sat, 10 Nov 2018 20:10:57 +0200 Message-Id: <20181110181101.24557-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Consider the following scenario. There are two independent devices coupled together by functional dependencies: - USB OTG (dwc3-pci) - extcon (tested with extcon-intel-mrfld, not yet in upstream) Each of the driver services a corresponding device is built as a module. In the Buildroot environment the modules are probed by alphabetical ordering of their modaliases. The latter comes to the case when USB OTG driver will be probed first followed by extcon one. So, if the platform anticipates extcon device to be appeared, in the above case we will get deferred probe of USB OTG, because of ordering. Now, a cherry on top of the cake, the deferred probing list contains the only two modules, i.e. USB OTG and extcon. Due to above circumstances, values in the local_trigger_count and deferred_trigger_count are not the same, and thus provokes deferred probe triggering again and again. ... [ 20.678332] platform dwc3.0.auto: Retrying from deferred list [ 20.694743] platform dwc3.0.auto: Driver dwc3 requests probe deferral [ 20.701254] platform dwc3.0.auto: Added to deferred list [ 20.706620] platform dwc3.0.auto: driver_deferred_probe_add_trigger 1 2 [ 20.713732] platform dwc3.0.auto: Retrying from deferred list [ 20.730035] platform dwc3.0.auto: Driver dwc3 requests probe deferral [ 20.736540] platform dwc3.0.auto: Added to deferred list [ 20.741889] platform dwc3.0.auto: driver_deferred_probe_add_trigger 3 4 [ 20.748991] platform dwc3.0.auto: Retrying from deferred list [ 20.765416] platform dwc3.0.auto: Driver dwc3 requests probe deferral [ 20.771914] platform dwc3.0.auto: Added to deferred list [ 20.777279] platform dwc3.0.auto: driver_deferred_probe_add_trigger 5 6 ... Deeper investigation shows the culprit commit 58b116bce136 ("drivercore: deferral race condition fix") which was dedicated to fix some other issue while bringing a regression. This reverts commit 58b116bce13612e5aa6fcd49ecbd4cf8bb59e835 for good until we will have better solution. Cc: Grant Likely Cc: Peter Ujfalusi Cc: Greg Kroah-Hartman Cc: Mark Brown Cc: Felipe Balbi Cc: Andrzej Hajda Signed-off-by: Andy Shevchenko --- drivers/base/dd.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 169412ee4ae8..9a966e45fda5 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -53,7 +53,6 @@ static DEFINE_MUTEX(deferred_probe_mutex); static LIST_HEAD(deferred_probe_pending_list); static LIST_HEAD(deferred_probe_active_list); -static atomic_t deferred_trigger_count = ATOMIC_INIT(0); static struct dentry *deferred_devices; static bool initcalls_done; @@ -143,17 +142,6 @@ static bool driver_deferred_probe_enable = false; * This functions moves all devices from the pending list to the active * list and schedules the deferred probe workqueue to process them. It * should be called anytime a driver is successfully bound to a device. - * - * Note, there is a race condition in multi-threaded probe. In the case where - * more than one device is probing at the same time, it is possible for one - * probe to complete successfully while another is about to defer. If the second - * depends on the first, then it will get put on the pending list after the - * trigger event has already occurred and will be stuck there. - * - * The atomic 'deferred_trigger_count' is used to determine if a successful - * trigger has occurred in the midst of probing a driver. If the trigger count - * changes in the midst of a probe, then deferred processing should be triggered - * again. */ static void driver_deferred_probe_trigger(void) { @@ -166,7 +154,6 @@ static void driver_deferred_probe_trigger(void) * into the active list so they can be retried by the workqueue */ mutex_lock(&deferred_probe_mutex); - atomic_inc(&deferred_trigger_count); list_splice_tail_init(&deferred_probe_pending_list, &deferred_probe_active_list); mutex_unlock(&deferred_probe_mutex); @@ -434,19 +421,9 @@ EXPORT_SYMBOL_GPL(device_bind_driver); static atomic_t probe_count = ATOMIC_INIT(0); static DECLARE_WAIT_QUEUE_HEAD(probe_waitqueue); -static void driver_deferred_probe_add_trigger(struct device *dev, - int local_trigger_count) -{ - driver_deferred_probe_add(dev); - /* Did a trigger occur while probing? Need to re-trigger if yes */ - if (local_trigger_count != atomic_read(&deferred_trigger_count)) - driver_deferred_probe_trigger(); -} - static int really_probe(struct device *dev, struct device_driver *drv) { int ret = -EPROBE_DEFER; - int local_trigger_count = atomic_read(&deferred_trigger_count); bool test_remove = IS_ENABLED(CONFIG_DEBUG_TEST_DRIVER_REMOVE) && !drv->suppress_bind_attrs; @@ -463,7 +440,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) ret = device_links_check_suppliers(dev); if (ret == -EPROBE_DEFER) - driver_deferred_probe_add_trigger(dev, local_trigger_count); + driver_deferred_probe_add(dev); if (ret) return ret; @@ -559,7 +536,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) case -EPROBE_DEFER: /* Driver requested deferred probing */ dev_dbg(dev, "Driver %s requests probe deferral\n", drv->name); - driver_deferred_probe_add_trigger(dev, local_trigger_count); + driver_deferred_probe_add(dev); break; case -ENODEV: case -ENXIO: From patchwork Sat Nov 10 18:10:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 10677377 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A3D81709 for ; Sat, 10 Nov 2018 18:11:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F9C82C911 for ; Sat, 10 Nov 2018 18:11:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 043322C91A; Sat, 10 Nov 2018 18:11:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 968042C911 for ; Sat, 10 Nov 2018 18:11:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727287AbeKKD5I (ORCPT ); Sat, 10 Nov 2018 22:57:08 -0500 Received: from mga17.intel.com ([192.55.52.151]:59727 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727072AbeKKD5B (ORCPT ); Sat, 10 Nov 2018 22:57:01 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Nov 2018 10:11:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,488,1534834800"; d="scan'208";a="91052701" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 10 Nov 2018 10:11:03 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id D6A3465; Sat, 10 Nov 2018 20:11:02 +0200 (EET) From: Andy Shevchenko To: MyungJoo Ham , Chanwoo Choi , linux-usb@vger.kernel.org, Felipe Balbi , Guenter Roeck , Heikki Krogerus , Roger Quadros , linux-pm@vger.kernel.org, "Rafael J. Wysocki" , Sebastian Reichel , linux-omap@vger.kernel.org, Darren Hart , platform-driver-x86@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Chen-Yu Tsai , Hans de Goede Cc: Andy Shevchenko Subject: [PATCH v1 2/5] extcon: Return -EPROBE_DEFER when extcon device is not found Date: Sat, 10 Nov 2018 20:10:58 +0200 Message-Id: <20181110181101.24557-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110181101.24557-1-andriy.shevchenko@linux.intel.com> References: <20181110181101.24557-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All current users of extcon_get_extcon_dev() API considers an extcon device a mandatory to appear. Thus, they all convert NULL pointer to -EPROBE_DEFER error code. There is one more caller anticipated with the same requirements. To decrease a code duplication and a burden to the callers, return -EPROBE_DEFER directly from extcon_get_extcon_dev(). Signed-off-by: Andy Shevchenko Acked-by: Guenter Roeck Acked-by: Sebastian Reichel Acked-by: Chanwoo Choi Reviewed-by: Heikki Krogerus --- drivers/extcon/extcon-axp288.c | 4 ++-- drivers/extcon/extcon.c | 2 +- drivers/power/supply/axp288_charger.c | 8 ++++---- drivers/usb/phy/phy-omap-otg.c | 6 +++--- drivers/usb/typec/tcpm/fusb302.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c index a983708b77a6..3472d3b756ed 100644 --- a/drivers/extcon/extcon-axp288.c +++ b/drivers/extcon/extcon-axp288.c @@ -360,8 +360,8 @@ static int axp288_extcon_probe(struct platform_device *pdev) name = acpi_dev_get_first_match_name("INT3496", NULL, -1); if (name) { info->id_extcon = extcon_get_extcon_dev(name); - if (!info->id_extcon) - return -EPROBE_DEFER; + if (IS_ERR(info->id_extcon)) + return PTR_ERR(info->id_extcon); dev_info(dev, "controlling USB role\n"); } else { diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 5ab0498be652..2bd0f2f33f05 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -884,7 +884,7 @@ struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name) if (!strcmp(sd->name, extcon_name)) goto out; } - sd = NULL; + sd = ERR_PTR(-EPROBE_DEFER); out: mutex_unlock(&extcon_dev_list_lock); return sd; diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c index 735658ee1c60..8558577fccf5 100644 --- a/drivers/power/supply/axp288_charger.c +++ b/drivers/power/supply/axp288_charger.c @@ -768,17 +768,17 @@ static int axp288_charger_probe(struct platform_device *pdev) info->regmap_irqc = axp20x->regmap_irqc; info->cable.edev = extcon_get_extcon_dev(AXP288_EXTCON_DEV_NAME); - if (info->cable.edev == NULL) { + if (IS_ERR(info->cable.edev)) { dev_dbg(&pdev->dev, "%s is not ready, probe deferred\n", AXP288_EXTCON_DEV_NAME); - return -EPROBE_DEFER; + return PTR_ERR(info->cable.edev); } if (acpi_dev_present(USB_HOST_EXTCON_HID, NULL, -1)) { info->otg.cable = extcon_get_extcon_dev(USB_HOST_EXTCON_NAME); - if (info->otg.cable == NULL) { + if (IS_ERR(info->otg.cable)) { dev_dbg(dev, "EXTCON_USB_HOST is not ready, probe deferred\n"); - return -EPROBE_DEFER; + return PTR_ERR(info->otg.cable); } dev_info(&pdev->dev, "Using " USB_HOST_EXTCON_HID " extcon for usb-id\n"); diff --git a/drivers/usb/phy/phy-omap-otg.c b/drivers/usb/phy/phy-omap-otg.c index ee0863c6553e..605314ddcd3d 100644 --- a/drivers/usb/phy/phy-omap-otg.c +++ b/drivers/usb/phy/phy-omap-otg.c @@ -91,12 +91,12 @@ static int omap_otg_probe(struct platform_device *pdev) int ret; u32 rev; - if (!config || !config->extcon) + if (!config) return -ENODEV; extcon = extcon_get_extcon_dev(config->extcon); - if (!extcon) - return -EPROBE_DEFER; + if (IS_ERR(extcon)) + return PTR_ERR(extcon); otg_dev = devm_kzalloc(&pdev->dev, sizeof(*otg_dev), GFP_KERNEL); if (!otg_dev) diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c index 43b64d9309d0..6d332066202b 100644 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -1767,8 +1767,8 @@ static int fusb302_probe(struct i2c_client *client, */ if (device_property_read_string(dev, "fcs,extcon-name", &name) == 0) { chip->extcon = extcon_get_extcon_dev(name); - if (!chip->extcon) - return -EPROBE_DEFER; + if (IS_ERR(chip->extcon)) + return PTR_ERR(chip->extcon); } chip->vbus = devm_regulator_get(chip->dev, "vbus"); From patchwork Sat Nov 10 18:10:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 10677369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0995F15E9 for ; Sat, 10 Nov 2018 18:11:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1FAF2C911 for ; Sat, 10 Nov 2018 18:11:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5E8A2C918; Sat, 10 Nov 2018 18:11:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,URIBL_SBL autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 997562C911 for ; Sat, 10 Nov 2018 18:11:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727086AbeKKD5A (ORCPT ); Sat, 10 Nov 2018 22:57:00 -0500 Received: from mga03.intel.com ([134.134.136.65]:24372 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726292AbeKKD5A (ORCPT ); Sat, 10 Nov 2018 22:57:00 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Nov 2018 10:11:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,488,1534834800"; d="scan'208";a="272991893" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 10 Nov 2018 10:11:03 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id E6BD86BB; Sat, 10 Nov 2018 20:11:02 +0200 (EET) From: Andy Shevchenko To: MyungJoo Ham , Chanwoo Choi , linux-usb@vger.kernel.org, Felipe Balbi , Guenter Roeck , Heikki Krogerus , Roger Quadros , linux-pm@vger.kernel.org, "Rafael J. Wysocki" , Sebastian Reichel , linux-omap@vger.kernel.org, Darren Hart , platform-driver-x86@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Chen-Yu Tsai , Hans de Goede Cc: Andy Shevchenko Subject: [PATCH v1 3/5] staging: typec: fusb302: Rename fcs,extcon-name to linux,extcon-name Date: Sat, 10 Nov 2018 20:10:59 +0200 Message-Id: <20181110181101.24557-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110181101.24557-1-andriy.shevchenko@linux.intel.com> References: <20181110181101.24557-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since we are going to use the same in Designware USB 3 driver, rename the property to be consistent across the drivers. No functional change intended. Cc: Hans de Goede Cc: Guenter Roeck Signed-off-by: Andy Shevchenko Acked-by: Guenter Roeck --- drivers/platform/x86/intel_cht_int33fe.c | 2 +- drivers/usb/typec/tcpm/fusb302.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c index 464fe93657b5..87cbf18d0305 100644 --- a/drivers/platform/x86/intel_cht_int33fe.c +++ b/drivers/platform/x86/intel_cht_int33fe.c @@ -79,7 +79,7 @@ static const struct property_entry max17047_props[] = { }; static const struct property_entry fusb302_props[] = { - PROPERTY_ENTRY_STRING("fcs,extcon-name", "cht_wcove_pwrsrc"), + PROPERTY_ENTRY_STRING("linux,extcon-name", "cht_wcove_pwrsrc"), PROPERTY_ENTRY_U32("fcs,max-sink-microvolt", 12000000), PROPERTY_ENTRY_U32("fcs,max-sink-microamp", 3000000), PROPERTY_ENTRY_U32("fcs,max-sink-microwatt", 36000000), diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c index 6d332066202b..62816ac571a0 100644 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -1765,7 +1765,7 @@ static int fusb302_probe(struct i2c_client *client, * to be set by the platform code which also registers the i2c client * for the fusb302. */ - if (device_property_read_string(dev, "fcs,extcon-name", &name) == 0) { + if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) { chip->extcon = extcon_get_extcon_dev(name); if (IS_ERR(chip->extcon)) return PTR_ERR(chip->extcon); From patchwork Sat Nov 10 18:11:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 10677397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E9261709 for ; Sat, 10 Nov 2018 18:11:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 432222C911 for ; Sat, 10 Nov 2018 18:11:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 353222C91B; Sat, 10 Nov 2018 18:11:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D65A12C911 for ; Sat, 10 Nov 2018 18:11:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726876AbeKKD5A (ORCPT ); Sat, 10 Nov 2018 22:57:00 -0500 Received: from mga07.intel.com ([134.134.136.100]:20276 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726244AbeKKD5A (ORCPT ); Sat, 10 Nov 2018 22:57:00 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Nov 2018 10:11:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,488,1534834800"; d="scan'208";a="95270625" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 10 Nov 2018 10:11:03 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 044D87A8; Sat, 10 Nov 2018 20:11:02 +0200 (EET) From: Andy Shevchenko To: MyungJoo Ham , Chanwoo Choi , linux-usb@vger.kernel.org, Felipe Balbi , Guenter Roeck , Heikki Krogerus , Roger Quadros , linux-pm@vger.kernel.org, "Rafael J. Wysocki" , Sebastian Reichel , linux-omap@vger.kernel.org, Darren Hart , platform-driver-x86@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Chen-Yu Tsai , Hans de Goede Cc: Andy Shevchenko Subject: [PATCH v1 4/5] usb: dwc3: drd: Switch to device property for 'extcon' handling Date: Sat, 10 Nov 2018 20:11:00 +0200 Message-Id: <20181110181101.24557-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110181101.24557-1-andriy.shevchenko@linux.intel.com> References: <20181110181101.24557-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch to device property for 'extcon' handling. No functional change intended. Signed-off-by: Andy Shevchenko --- drivers/usb/dwc3/drd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index e7e421521a34..5dc4cddd5b68 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "debug.h" #include "core.h" @@ -485,8 +486,8 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) struct device_node *np_phy, *np_conn; struct extcon_dev *edev; - if (of_property_read_bool(dev->of_node, "extcon")) - return extcon_get_edev_by_phandle(dwc->dev, 0); + if (device_property_read_bool(dev, "extcon")) + return extcon_get_edev_by_phandle(dev, 0); np_phy = of_parse_phandle(dev->of_node, "phys", 0); np_conn = of_graph_get_remote_node(np_phy, -1, -1); From patchwork Sat Nov 10 18:11:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 10677381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA25915E9 for ; Sat, 10 Nov 2018 18:11:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF6362C918 for ; Sat, 10 Nov 2018 18:11:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2B1B2C91A; Sat, 10 Nov 2018 18:11:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EC2C2C916 for ; Sat, 10 Nov 2018 18:11:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727214AbeKKD5B (ORCPT ); Sat, 10 Nov 2018 22:57:01 -0500 Received: from mga02.intel.com ([134.134.136.20]:37029 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727068AbeKKD5B (ORCPT ); Sat, 10 Nov 2018 22:57:01 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Nov 2018 10:11:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,488,1534834800"; d="scan'208";a="107537164" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 10 Nov 2018 10:11:03 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 117037C6; Sat, 10 Nov 2018 20:11:03 +0200 (EET) From: Andy Shevchenko To: MyungJoo Ham , Chanwoo Choi , linux-usb@vger.kernel.org, Felipe Balbi , Guenter Roeck , Heikki Krogerus , Roger Quadros , linux-pm@vger.kernel.org, "Rafael J. Wysocki" , Sebastian Reichel , linux-omap@vger.kernel.org, Darren Hart , platform-driver-x86@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Chen-Yu Tsai , Hans de Goede Cc: Andy Shevchenko Subject: [PATCH v1 5/5] usb: dwc3: drd: Add support for DR detection through extcon Date: Sat, 10 Nov 2018 20:11:01 +0200 Message-Id: <20181110181101.24557-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110181101.24557-1-andriy.shevchenko@linux.intel.com> References: <20181110181101.24557-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow extcon device, found by name, to provide DR status for USB. This is needed, for example, in case of Intel Merrifield platform, where the Intel Basin Cove PMIC provides an extcon device to communicate the detected role. Note, that the "linux,extcon-name" property name is only for kernel internal use by X86/ACPI platform code and as such is not documented in the device tree bindings. Signed-off-by: Andy Shevchenko --- drivers/usb/dwc3/drd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 5dc4cddd5b68..d6b47829fdca 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -485,10 +485,20 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) struct device *dev = dwc->dev; struct device_node *np_phy, *np_conn; struct extcon_dev *edev; + const char *name; if (device_property_read_bool(dev, "extcon")) return extcon_get_edev_by_phandle(dev, 0); + /* + * Device tree platforms should get extcon via phandle. + * On ACPI platforms, we get the name from a device property. + * This device property is for kernel internal use only and + * is expected to be set by the glue code. + */ + if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) + return extcon_get_extcon_dev(name); + np_phy = of_parse_phandle(dev->of_node, "phys", 0); np_conn = of_graph_get_remote_node(np_phy, -1, -1);