Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp45152pxj; Fri, 7 May 2021 03:23:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfTC6RZ1dIudZbdSdREQlV0vo6MRQ6QL5OUckqiH33vjzmGDa9xbJFxdyarnO300sQo+2o X-Received: by 2002:a63:9e02:: with SMTP id s2mr9564643pgd.134.1620383021904; Fri, 07 May 2021 03:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620383021; cv=none; d=google.com; s=arc-20160816; b=p78IImleIR1MKfvlP+HGnTVu2po3sN6TocsRGHSjmKKjv8RK4PvWJmQLUv8eyZNdLS JMEh0V5kIy/Y1MvgFg6bm/+UIts5eSnCUUedcU7JRcCqoJmDoDYl+O1J56EPyU8UI+wO zavO6GrOhQOPKm8yN/6c1CR4hjTgU7y67tlMZTGzs2HO5v3Zwuuw09RnPGfCDUqrczwZ f1fVlEZ7Ao/1+SSOIvzYsizDKyz9FjY2yam63L2tG+qMFOMiWB4bT6N+5f2gmWhcwaAC NeBa04yMu/yuSmo1pn+52vfEQ37CSRFQFBDnIrdmApYj4nnQ4tyxVAuwRhXCEDlKzKlL 60rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=XBnCBUlvllwUH01EeOvRx1g7o0OCdlPpiWvaUiW8Ew0=; b=OWndhyKOc7Ys1lPSSE39lnpvzc+yhzIA07E0eXXfEqJbYq6PmWR3nucv36+qhR8jkC bCkaMEHAKv2y+VETjY6++Cem3KHRBdq67T+a4ZVA+B6ks1W4JG45AWNgMbmWKW7Uqt/Q Bm8fYjFgBjlkBsqoq/+7Bucl2MhEhw/neOEBlIMThzKykOCwjv8bzHIXP8c1eZbu6KdW 3UOZxFDFLxmfR2fsU4/uvSw+Z75HtjfbzKtJIX/pjiPiy08O9AsSghZzT8OjOes9Aok5 5zBvXuWpOFNz83pLbNPvWe55ug2844OZ94La4fs+sH+8uvdltffmIyih9mDwebvdVruj Dn6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k1si6179797pgq.470.2021.05.07.03.23.28; Fri, 07 May 2021 03:23:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234454AbhEGHID (ORCPT + 99 others); Fri, 7 May 2021 03:08:03 -0400 Received: from smtp04.smtpout.orange.fr ([80.12.242.126]:48936 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233730AbhEGHID (ORCPT ); Fri, 7 May 2021 03:08:03 -0400 Received: from [192.168.1.18] ([86.243.172.93]) by mwinf5d51 with ME id 1j6x2500721Fzsu03j6xMG; Fri, 07 May 2021 09:07:02 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 07 May 2021 09:07:02 +0200 X-ME-IP: 86.243.172.93 Subject: Re: [PATCH] usb: fotg210-hcd: Fix an error message To: Chunfeng Yun Cc: gregkh@linuxfoundation.org, shubhankarvk@gmail.com, lee.jones@linaro.org, gustavoars@kernel.org, vulab@iscas.ac.cn, john453@faraday-tech.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <94531bcff98e46d4f9c20183a90b7f47f699126c.1620333419.git.christophe.jaillet@wanadoo.fr> <1620354030.10796.6.camel@mhfsdcap03> From: Christophe JAILLET Message-ID: <75002e1a-bca7-8726-de2e-56905f255693@wanadoo.fr> Date: Fri, 7 May 2021 09:06:57 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <1620354030.10796.6.camel@mhfsdcap03> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 07/05/2021 à 04:20, Chunfeng Yun a écrit : > On Thu, 2021-05-06 at 22:39 +0200, Christophe JAILLET wrote: >> 'retval' is known to be -ENODEV here. >> This is a hard-coded default error code which is not useful in the error >> message. Moreover, another error message is printed at the end of the >> error handling path. The corresponding error code (-ENOMEM) is more >> informative. >> >> So remove simplify the first error message. >> >> While at it, also remove the useless initialization of 'retval'. >> >> Fixes: 7d50195f6c50 ("usb: host: Faraday fotg210-hcd driver") >> Signed-off-by: Christophe JAILLET >> --- >> drivers/usb/host/fotg210-hcd.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c >> index 6cac642520fc..9c2eda0918e1 100644 >> --- a/drivers/usb/host/fotg210-hcd.c >> +++ b/drivers/usb/host/fotg210-hcd.c >> @@ -5568,7 +5568,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev) >> struct usb_hcd *hcd; >> struct resource *res; >> int irq; >> - int retval = -ENODEV; >> + int retval; >> struct fotg210_hcd *fotg210; >> >> if (usb_disabled()) >> @@ -5588,7 +5588,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev) >> hcd = usb_create_hcd(&fotg210_fotg210_hc_driver, dev, >> dev_name(dev)); >> if (!hcd) { >> - dev_err(dev, "failed to create hcd with err %d\n", retval); >> + dev_err(dev, "failed to create hcd\n"); >> retval = -ENOMEM; > How about moving this line before dev_err()? then could keep error log > unchanged. > Mostly a matter of taste. I don't think it add any useful information (this is not something coming from a call chain or that can have different values, it is just a hard-coded constant) and the line after we will already have: dev_err(dev, "init %s fail, %d\n", dev_name(dev), retval); where retval = -ENOMEM So the -ENOMEM error code is already reported. Moreover, having error code reported or not is already not consistent in the function. For example "failed to enable PCLK\n" where 'retval' could be reported as well. BTW, is it useful to have 'dev_name(dev)' in a dev_err? CJ >> goto fail_create_hcd; >> } >