From patchwork Thu Mar 22 13:14:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 132277 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp831295ljb; Thu, 22 Mar 2018 06:15:12 -0700 (PDT) X-Google-Smtp-Source: AG47ELuY7+Uab0c3CHT7eC2ywFpUTsh0/+Hd0rzkxAjaqgNs1ekMTVMXkqfZ6GgxE/Ui/kTBOxsA X-Received: by 10.98.38.133 with SMTP id m127mr20513259pfm.122.1521724512346; Thu, 22 Mar 2018 06:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521724512; cv=none; d=google.com; s=arc-20160816; b=a8O9WPY2WhHU8Xen6e9j8yetVq//EiBWJyl14rfnOtCHt3Pvh2oBTEPfCL/zQ1R8Da XkHf9cZI1EcV6n48oEzdncLPKOLZzwfYiW1XVwyR82sS7SVwu29jzyjjv1vF01gtBqqg mzjwp4ovikCsCTJox0Wm5P0EIhScjh/SsD8XKrCXiqRnvVDEnjVvBwkMkqf+8UBA2duL rgeeui1qjdtFWQcoww3/mn08h3+/6idRAvMj2e0bSfcpKDLeleSp6kJommQd5GOEja2y /2FWSchk67cv+pDre3oIokm/hrlL5zFBMTNNAfTXej8e0RbTLwI1fy+21ukNuGqBWCot iWMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Rr7zjOtYRYsx9052jL36vo2iXs/WDJRDBH0bJmJWQ24=; b=j/g1ZmJcrD9SGahTQKAKSXGFdTHR04VNM9aruysxn9zg+oPCO8zO4gYPlOEbYdhm07 nOYVYcRqY13Kr+x92YCbYe+N90fYygljktVy+FmTUnWnIaj2IROIPGgqeyhSRUzdRo3z UAMNkcRo58k3MWq9ADZlVLuvS0x4rUjRQpSaq7AS0yEM8rr2XAcZyfAtVWiZ046FrBxN fPmlBCMkzhug7dIlY+itUPN5UyuMdS54OnGez7S53LQsZSbSXfGwl8+NP0DhXVizM+q4 r5dQ082rBxZrGUqyfGWDsZLEeCUddJ1gf/+4gb2E1sHCatmdsmdTcJPzfXzQZmveyjnK n4HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=O8jZnGRn; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 70-v6si6303925ple.639.2018.03.22.06.15.12; Thu, 22 Mar 2018 06:15:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=O8jZnGRn; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753181AbeCVNPI (ORCPT + 3 others); Thu, 22 Mar 2018 09:15:08 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:46783 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752265AbeCVNPH (ORCPT ); Thu, 22 Mar 2018 09:15:07 -0400 Received: by mail-wr0-f193.google.com with SMTP id s10so8636023wra.13; Thu, 22 Mar 2018 06:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OTN5fcY4D05x2aLJsFXenKBgUlvWaaZhkND8ovWTlfE=; b=O8jZnGRneYmdYD4WWD8NY89s3+yEP1/7WkA66JJQcjm2nVflnnPGOLrGkwy+80URcz pNrxd2Tx/nZpMI6eCAe1DXo596lJAxKLBe3ZC0FyoxzMWfDLAh7Jr+sLjEe+Z+DErPSr Z7b6pf1Dzk3TizWthGkxxvMDULKYDWMeo/HBayQ/DJirBM0nVzg3gg1GVLMcb7TfMwhZ zLZU/C+1k/IQzBc+2CMzHsrNoHcc9M08Ov8aygbDgF9CBtOXjcAFvwXVaO0C6hwVNkEz fw8ZBtEyblb293V8f5QEIODOIXTbV0banxjvlM+vuJv6P0TwzkbNP3fW43HoY8wp9kfD nBLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=OTN5fcY4D05x2aLJsFXenKBgUlvWaaZhkND8ovWTlfE=; b=FiIDt7nhg6szg/EnGE9lwvcJ2Iob/EkkP5Yv0URobY6hIARnGGKUPeDS3SrzsyebHa i7xgAU3AWUe1DgOTFpCxfBPglSRYQW9HKH/K/GkX9qTEpI4GrlZ6hTIttwBzSCYMpEbM gHdXTJ3PxmZb3htBO2LTmuMPBgxlOWpiCHkPN6APxbSrKiaWpBuR7c4iEcibNBkAU55c kPu657cyXFdll+14p5VjdT/hK0rm9UFtdd02fM7UNcZs2Woo4fZOM4D7anqP/gJtPFP8 EmsiH4a3kkh7fSwu8huLvyQEOXud3kdgjwjGZbcd4Vpz6ItgEOkpfBoo6FzG6gNkh6WJ oP+w== X-Gm-Message-State: AElRT7F/6j5ROgg425bpmAcjf761RDds/Oin8V1NLsK4QGbESURtZeYm ARZNCQAhH6ER8QwU8/iDrZDmWtqD X-Received: by 10.223.145.135 with SMTP id 7mr10312025wri.7.1521724505887; Thu, 22 Mar 2018 06:15:05 -0700 (PDT) Received: from cizrna.lan ([109.72.12.73]) by smtp.gmail.com with ESMTPSA id e53sm7412429wrg.34.2018.03.22.06.15.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Mar 2018 06:15:05 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Cc: Felipe Balbi , Heiko Stuebner , Tomeu Vizoso , Amelie Delaunay , Minas Harutyunyan , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [PATCH v3] usb: dwc2: dwc2_vbus_supply_init: fix error check Date: Thu, 22 Mar 2018 14:14:51 +0100 Message-Id: <20180322131451.12631-1-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180322093943.49717-1-tomeu.vizoso@collabora.com> References: <20180322093943.49717-1-tomeu.vizoso@collabora.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org devm_regulator_get_optional returns -ENODEV if the regulator isn't there, so if that's the case we have to make sure not to leave -ENODEV in the regulator pointer. Also, make sure we return 0 in that case, but correctly propagate any other errors. Also propagate the error from _dwc2_hcd_start. Fixes: 531ef5ebea96 ("usb: dwc2: add support for host mode external vbus supply") Cc: Amelie Delaunay Signed-off-by: Tomeu Vizoso --- v2: Only overwrite the error in the pointer after checking it (Heiko Stübner ) v3: Remove hunks that shouldn't be in this patch --- drivers/usb/dwc2/hcd.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index dcfda5eb4cac..863aed20517f 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -359,8 +359,13 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg *hsotg) static int dwc2_vbus_supply_init(struct dwc2_hsotg *hsotg) { hsotg->vbus_supply = devm_regulator_get_optional(hsotg->dev, "vbus"); - if (IS_ERR(hsotg->vbus_supply)) + if (PTR_ERR(hsotg->vbus_supply) == -ENODEV) { + hsotg->vbus_supply = NULL; return 0; + } else if (IS_ERR(hsotg->vbus_supply)) { + hsotg->vbus_supply = NULL; + return PTR_ERR(hsotg->vbus_supply); + } return regulator_enable(hsotg->vbus_supply); } @@ -4342,9 +4347,7 @@ static int _dwc2_hcd_start(struct usb_hcd *hcd) spin_unlock_irqrestore(&hsotg->lock, flags); - dwc2_vbus_supply_init(hsotg); - - return 0; + return dwc2_vbus_supply_init(hsotg); } /*