From patchwork Fri Jun 10 08:54:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 69747 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp184522qgf; Fri, 10 Jun 2016 01:55:04 -0700 (PDT) X-Received: by 10.66.159.163 with SMTP id xd3mr1156316pab.23.1465548904785; Fri, 10 Jun 2016 01:55:04 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l187si12262983pfc.167.2016.06.10.01.54.58; Fri, 10 Jun 2016 01:55:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752953AbcFJIys (ORCPT + 30 others); Fri, 10 Jun 2016 04:54:48 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:43006 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752101AbcFJIyp (ORCPT ); Fri, 10 Jun 2016 04:54:45 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id u5A8sQbV019040; Fri, 10 Jun 2016 03:54:26 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5A8sgs7007998; Fri, 10 Jun 2016 03:54:42 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Fri, 10 Jun 2016 03:54:41 -0500 Received: from lta0400828d.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5A8seRH029423; Fri, 10 Jun 2016 03:54:40 -0500 From: Roger Quadros To: , CC: , , Roger Quadros Subject: [PATCH] usb: dwc3: fix runtime PM in error path Date: Fri, 10 Jun 2016 11:54:38 +0300 Message-ID: <1465548878-30085-1-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If there is a failure after pm_runtime_enable/get_sync() we need to call pm_runtime_disable/put_sync(). Otherwise it will lead to an unbalanced pm_runtime_enable() on the subsequent probe if the earlier probe bailed out due to -EPROBE_DEFER. Signed-off-by: Roger Quadros --- drivers/usb/dwc3/core.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 5bf38f8..222d2c9 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1419,7 +1419,7 @@ static int dwc3_probe(struct platform_device *pdev) if (ret) { dev_err(dwc->dev, "failed to allocate event buffers\n"); ret = -ENOMEM; - goto err0; + goto err1; } if (IS_ENABLED(CONFIG_USB_DWC3_HOST) && @@ -1436,12 +1436,12 @@ static int dwc3_probe(struct platform_device *pdev) ret = dwc3_alloc_scratch_buffers(dwc); if (ret) - goto err1; + goto err2; ret = dwc3_core_init(dwc); if (ret) { dev_err(dev, "failed to initialize core\n"); - goto err2; + goto err3; } /* Check the maximum_speed parameter */ @@ -1473,23 +1473,28 @@ static int dwc3_probe(struct platform_device *pdev) ret = dwc3_core_init_mode(dwc); if (ret) - goto err3; + goto err4; dwc3_debugfs_init(dwc); pm_runtime_put(dev); return 0; -err3: +err4: dwc3_event_buffers_cleanup(dwc); -err2: +err3: dwc3_free_scratch_buffers(dwc); -err1: +err2: dwc3_free_event_buffers(dwc); dwc3_ulpi_exit(dwc); +err1: + pm_runtime_allow(&pdev->dev); + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); + err0: /* * restore res->start back to its original value so that, in case the