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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F6BFC433EF for ; Tue, 10 May 2022 12:25:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241684AbiEJM3W (ORCPT ); Tue, 10 May 2022 08:29:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237699AbiEJM3U (ORCPT ); Tue, 10 May 2022 08:29:20 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A232224685; Tue, 10 May 2022 05:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=0SOHdnZm/qIXaafuGPsWb+8y+0cZMBYOdPMCj5bdxFs=; b=ssUW9aQmsIjXI3QzluEQbxRQ+M cC6kGQGCJDuXvSHWxXW8y1iNfTI+j8Pr2dCPhNVjmV4BapCvHOFAt32KVk6l1fFnJGmLp22dM2BFj 8xqPnxzRt9SBMspCfijipgoFeOVo7+KZNQoQVXdxHYgyfhW0FWgkssAKHOFIPiBlpPGQ=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1noOvO-0028E6-3y; Tue, 10 May 2022 14:25:10 +0200 Date: Tue, 10 May 2022 14:25:10 +0200 From: Andrew Lunn To: Wan Jiabing Cc: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Antoine Tenart , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kael_w@yeah.net Subject: Re: [PATCH net] net: phy: mscc: Add error check when __phy_read() failed Message-ID: References: <20220510035458.9804-1-wanjiabing@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220510035458.9804-1-wanjiabing@vivo.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 10, 2022 at 11:54:56AM +0800, Wan Jiabing wrote: > Calling __phy_read() might return a negative error code. Use 'int' > to declare variables which call __phy_read() and also add error check > for them. It would be good to add a comment here: The numerous callers of vsc8584_macsec_phy_read() don't expect it to fail. So don't return the error code from __phy_read(), but also don't return random values if it does fail. The commit message should try to answer any questions to reviewer has. And when i first looked at the change, i thought this is wrong, the error code is thrown away. But then i remembers our discussion. So it is good to mention that in the commit message. > Fixes: fa164e40c53b ("net: phy: mscc: split the driver into separate files") > Signed-off-by: Wan Jiabing > --- > drivers/net/phy/mscc/mscc_macsec.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/phy/mscc/mscc_macsec.c b/drivers/net/phy/mscc/mscc_macsec.c > index b7b2521c73fb..8a63e32fafa0 100644 > --- a/drivers/net/phy/mscc/mscc_macsec.c > +++ b/drivers/net/phy/mscc/mscc_macsec.c > @@ -22,9 +22,9 @@ > static u32 vsc8584_macsec_phy_read(struct phy_device *phydev, > enum macsec_bank bank, u32 reg) > { > - u32 val, val_l = 0, val_h = 0; > unsigned long deadline; > - int rc; > + int rc, val, val_l, val_h; > + u32 ret = 0; Networking code uses "reverse christmas tree", meaning these lines should be sorted, longest first, shortest last. So deadline needs to come after val_h. Andrew