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 92EF4C6FD18 for ; Wed, 29 Mar 2023 18:34:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/XMXP7xGgHxHUQUxuKvumcsYxdRlREEM9cpaM4RboYs=; b=P8kOR4iZ7hC55f wBV5Nql9Ryr6wNgwlDN1Az4tswqxZgaw5nZZzSCSJpIJ2nBnJfaVVqYTZ1mR6ACLDqKuSE1cpI7R0 GBRJyNUzUH9A4dZJ6T/uT61G2y9/1uoFD0OcXvWZpJTSuoYw1F4JxpM/AyZC4tTwW+XrgodzyF3i/ 99VSt+R822MI95e10haIkYOHQA0fp4UxDcwhu17Fpa94rMJ67r01Coi5XO6lZc3BvuotvBv5vmvba jqGucVXJZCZa+UbnqXBV25KakR5YJCIO+hfzqX6wOuVUCaSt3CkX6KpaOfw0Q+s2Hgdh0/hIjZcD3 NVn5eCxbcC/6m237miZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1phac6-001Tiq-1L; Wed, 29 Mar 2023 18:33:38 +0000 Received: from fudo.makrotopia.org ([2a07:2ec0:3002::71]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1phac3-001Th4-0F; Wed, 29 Mar 2023 18:33:36 +0000 Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1phabr-0005LO-05; Wed, 29 Mar 2023 20:33:23 +0200 Date: Wed, 29 Mar 2023 19:33:17 +0100 From: Daniel Golle To: Andrew Lunn Cc: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Sean Wang , Landen Chao , DENG Qingfang , Philipp Zabel , Sam Shih , Lorenzo Bianconi , John Crispin , Felix Fietkau Subject: Re: [RFC PATCH net-next v3 03/15] net: dsa: mt7530: use regmap to access switch register space Message-ID: References: <754322262cd754aee5916954b8e651989b229a09.1680105013.git.daniel@makrotopia.org> <7eb07ed2-2b1c-44fa-b029-0ecad7872fd2@lunn.ch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <7eb07ed2-2b1c-44fa-b029-0ecad7872fd2@lunn.ch> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230329_113335_109121_80F299C5 X-CRM114-Status: GOOD ( 15.02 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Mar 29, 2023 at 06:24:21PM +0200, Andrew Lunn wrote: > Thanks for splitting this patchset up. This is much easier to review. > > > +static u32 > > +mt7530_mii_read(struct mt7530_priv *priv, u32 reg) > > +{ > > + int ret; > > + u32 val; > > + > > + ret = regmap_read(priv->regmap, reg, &val); > > + if (ret) { > > + dev_err(priv->dev, > > + "failed to read mt7530 register\n"); > > + return ret; > > This is a u32 function. ret should be negative on error, which is > going to be turned positive in order to return a u32. So you probably > want to make this an int function. This is a pre-existing flaw in the code. As we are accessing 32-bit registers there has just never been any meaningful error handling. I guess the correct solution would be to not use the return value only to indicate success or error, and use an additional u32* parameter for the read value. However, I was hestitating to convert all the calls (they are many) to follow that improved paradigm. Should I? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel