Received: by 10.213.65.68 with SMTP id h4csp684631imn; Thu, 22 Mar 2018 06:27:50 -0700 (PDT) X-Google-Smtp-Source: AG47ELv6Iwn7kA4oWuIIM/hshseSPZreognKITgYMkAP0YgNpEdLd5VYXHV0eiQf1edte6VihGwS X-Received: by 2002:a17:902:d886:: with SMTP id b6-v6mr19602015plz.254.1521725269982; Thu, 22 Mar 2018 06:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521725269; cv=none; d=google.com; s=arc-20160816; b=GbAjtUYu6xyi+8Sbx7Wr3jwQEcTXfzZfNstxcQVR6UlWuQxQaHJXS0N3d9BNMoRWcL AEGvnEOjxH/B7CSw98fKDLkAG1JybSRn2PXR3f6rP6S8XxYuHZvgq0nhzypwnHPQjL+F XoEWXFbAkhboSgzIM819BrCEVaqqLbXjsv1xyYB4RQB6e2/2isMfnVGrNiyC0NVHBVdx 5QoQgd4IDkLjh0Kmi5cenao8ug/b9Cz3S941jiapqncxHQQBr1FIYHFi3X+6lwHZudLE M3kycnfRu5pB5oK7V7uUcxiYqZZr1bvYts06RsQhISLdipxlsSgDTMQoSoLmM53/eSa3 1/VQ== 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 :arc-authentication-results; bh=sqp/9vQgStoTErhNqNXPIdLEJdOfrmpoPj+jx0HY+U8=; b=IjKToiUsWaAIKgMRIfS7vTUZ5JLy7dlcFaGSO+z2zdPhfkNQP/UmZbg66w07jP72hi 72Cs7IgXVbyuMczLOvN9FPSnG+6nSwezWHiw0s+9PivM9qrzJSZebqLN/g1YXXhZOYP3 jgF71cz6x254b8TcBIZlOkAXhgO3kQtFiF/eDV6DzA1w6ADUJbwSPIW+svip1ypgLjVA EsZFeESPflWUTmT5aTM2JfISY4b8ql7lntc9n5ASqVBah+h20FOY+GWaaS6mlYt9yref s698yo3KgLqjgJ3+Ktnr7Q98fwBpLaxfgNGfIcRwAe0nyBm1PXHN7p6vUa0ixIshqXFZ QaYQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10-v6si6789877plt.533.2018.03.22.06.27.35; Thu, 22 Mar 2018 06:27:49 -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 S1753902AbeCVN0n convert rfc822-to-8bit (ORCPT + 99 others); Thu, 22 Mar 2018 09:26:43 -0400 Received: from gloria.sntech.de ([95.129.55.99]:57092 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750992AbeCVN0l (ORCPT ); Thu, 22 Mar 2018 09:26:41 -0400 Received: from ip9234b5ec.dynamic.kabel-deutschland.de ([146.52.181.236] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.1:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1ez0Ek-0002KI-OW; Thu, 22 Mar 2018 14:26:34 +0100 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Tomeu Vizoso Cc: linux-kernel@vger.kernel.org, Felipe Balbi , Amelie Delaunay , Minas Harutyunyan , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: Re: [PATCH v3] usb: dwc2: dwc2_vbus_supply_init: fix error check Date: Thu, 22 Mar 2018 14:26:34 +0100 Message-ID: <1794463.c121CNJ3R4@diego> In-Reply-To: <20180322131451.12631-1-tomeu.vizoso@collabora.com> References: <20180322093943.49717-1-tomeu.vizoso@collabora.com> <20180322131451.12631-1-tomeu.vizoso@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="iso-8859-1" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Donnerstag, 22. M?rz 2018, 14:14:51 CET schrieb Tomeu Vizoso: > 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(-) > > 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); > + } my personal cluelessnes, but can you use PTR_ERR without checking for IS_ERR first? I would've expected something along the line of if (IS_ERR(hsotg->vbus_supply)) { if (PTR_ERR(hsotg->vbus_supply) == -ENODEV) { hsotg->vbus_supply = NULL; return 0; } else { return PTR_ERR(hsotg->vbus_supply); } }