From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 643B3C52D7C for ; Wed, 21 Aug 2024 19:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:Message-ID:References:In-Reply-To:Subject:Cc:To:From:Date: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mKSCf7a1pjPZutaNKEDeex+tWawArQ1fVCpJ8GpdO5c=; b=hqB+N/Houl814FswNe3XdMiMnY VmuB38z1zPiLVhqrYSqUKD/+BT7/C/GaPtwgYoAevvYiz1KzmH7I4RXh9unAQ/+xzSkPvHb3lcUJS o/d/LrX6Aa78BtNYTTvoZcDvo9TMokxeWLnvvl3NmY1+p1yrs3/vzjJiBuJc31O8epQYWH576j5d4 pXYZDOweYKudTI4PNULVyvc7K2uDkl6fBe8FE9bdv9PRrl24yA+KWdhvLImwZCeUpFuVizsYcVIrc 5urJ2Bc8VcuSMRSey3I74fDnho/X4wiRoTGB5Trxlc58WPlLk6YodLibjzUlhHKbJ9X3OpaSk5Op6 2gz3fwFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgqea-0000000A8QG-42KI; Wed, 21 Aug 2024 19:05:57 +0000 Received: from mail.manjaro.org ([2a01:4f8:c0c:51f3::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgqdq-0000000A8Ju-2Trv; Wed, 21 Aug 2024 19:05:13 +0000 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1724267108; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mKSCf7a1pjPZutaNKEDeex+tWawArQ1fVCpJ8GpdO5c=; b=YWXy+QCMpMEFx0P3L66BqRsZjm6Zvn+Xqi2JiPcoG20IZ9QINVwEabt7H2RJ2vDuIsw1K+ zNYpHHLzei4kBJMM/D1almKvdK1wFXsJUDBBIT+/MR3EZW8zu1rx3adfyn38Z2NaHyHcWh Xmp3Q8bOF3i+AMBm1z9McQAtXV9If4JCn2Lxd1lHz6OzMaXQGt/iFlFoY5Pt19asQeMjV8 iMC7zOWzkrmG0F5opQWdv1xqHVxyP8T/sVqLRmkq5DD43H71CrLOnmMaNGYL1uO0dnmgmE AQZer28W7DwNyquxjWIPepKajMtIHABe1kIP+1rOC/TRVIriT1F2UEazLvtIlA== Date: Wed, 21 Aug 2024 21:05:07 +0200 From: Dragan Simic To: Christophe JAILLET Cc: linux-rockchip@lists.infradead.org, linux-phy@lists.infradead.org, vkoul@kernel.org, kishon@kernel.org, heiko@sntech.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] phy: phy-rockchip-inno-usb2: Handle failed extcon allocation better In-Reply-To: <816aa82c-1f50-4dfe-a41f-e396e0bdf219@wanadoo.fr> References: <96200baf794a0c451f3bbc3f5530b8cf0e359dfc.1724225528.git.dsimic@manjaro.org> <816aa82c-1f50-4dfe-a41f-e396e0bdf219@wanadoo.fr> Message-ID: X-Sender: dsimic@manjaro.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_120511_266613_01204D19 X-CRM114-Status: GOOD ( 19.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello Christophe, On 2024-08-21 13:17, Christophe JAILLET wrote: > Le 21/08/2024 à 09:37, Dragan Simic a écrit : >> Return the actual error code upon failure to allocate extcon device, >> instead >> of hardcoding -ENOMEM. Use dev_err_probe() to also log appropriate >> messages, >> which is fine because the containing function is used in the probe >> path. >> >> Helped-by: Heiko Stubner >> Signed-off-by: Dragan Simic >> --- >> drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c >> b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c >> index 113bfc717ff0..05af46dda11d 100644 >> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c >> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c >> @@ -435,7 +435,8 @@ static int rockchip_usb2phy_extcon_register(struct >> rockchip_usb2phy *rphy) >> rockchip_usb2phy_extcon_cable); >> if (IS_ERR(edev)) >> - return -ENOMEM; >> + return dev_err_probe(rphy->dev, PTR_ERR(edev), >> + "failed to allocate extcon device\n"); > > Returning PTR_ERR(edev) may make sense, but I don't think that adding > a dev_err_probe() really helps. > > devm_extcon_dev_allocate() can only return -EINVAL if it 2nd argument > is NULL. It is trivial to see that it can't happen here, > rockchip_usb2phy_extcon_cable is a global variable. > > in all other cases, it returns -ENOMEM because of a failed memory > allocation. In this case, usually it is not needed to log anything > because it is already loud enough. True, using dev_err_probe() in this case is somewhat redundant, but it falls under the "still fine to use" category, [1] because the error code passed to dev_err_probe() is received from another function that was invoked. On the other hand, another patch in this series tries to be strict in another direction, by not using dev_err_probe() where the error code passed to it is basically hardcoded. [2] I hope this makes sense. [1] https://lore.kernel.org/linux-phy/cover.1724225528.git.dsimic@manjaro.org/T/#mc3af7d24e31ed885732e6f26ca0d107b157d478b [2] https://lore.kernel.org/linux-phy/cover.1724225528.git.dsimic@manjaro.org/T/#ma26b614412787814dab7923987b8c814f7e86beb >> ret = devm_extcon_dev_register(rphy->dev, edev); >> if (ret) { >> >>