Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1034086rwl; Wed, 29 Mar 2023 11:37:41 -0700 (PDT) X-Google-Smtp-Source: AKy350YNKvTIcuLUls5wfzgyNXgvAwEclToGLpPlNcloyXVisotl491AJ1EPy1cAOCLUGurceUvW X-Received: by 2002:a17:90a:348:b0:237:b702:4990 with SMTP id 8-20020a17090a034800b00237b7024990mr21261688pjf.26.1680115061629; Wed, 29 Mar 2023 11:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680115061; cv=none; d=google.com; s=arc-20160816; b=yLCT4FGSyO40+T7NVHE5m5fJ4UFsiSdngdWJQPyUhV5IEeTBvG/m3GJ0ulyWrGAPmc 9l6/ZOUejLDDbbRgUzY0fn01HFsV9DwUbUGd3Jef7tozkvAkS0iBrexB+Vrw1ED3+Te7 1AACOMci9u2IGUAJo5/t2qgonHxwhwt8rNFceW38LHerVAynzbcrC5hy3bNTMTBuJbkJ 0Oj2QAxyL+ocq+jrhjHfcefPkAWDSbkmi3CY4ur6JUa0gIN1IDX2UO4k78uGceWENYdu 7Iflz1cEwGejC2aeSa4pPyGtCYc182mWLkaqogySAbDM6y9PgPkGlBXI2dLjCPOpU9n4 lE8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=cy2q+ft8CWmc/ApbDiy2CQxwBS77iZbrmWNYZinhU4Q=; b=nNemn3sCu3QNFgO4CCcgz7I01L8lTG/fLnT6jFkyKPQefcmEV9NE5BrgFDv8xeGH+R ppZyeU/JFW1yNl2P6jgMzzG4+nBi4jV9TVaGUWoPdk1eCT5obzWl039BzkxJHG5E+c33 4uLvVYmL+ucsZGKgG1UcftaiVpFVSruPpzlN/jXODIcXhoeLtVuN7X9nCECuMK6j0PF/ L/AP2noRtPFohiY97XrjuYMTLtu8A9h95xbxibQjjI1SXMTqRyErMVbHLq1Bl24gdoaI wTnWFLEWFyv407OWvJNDoqLklCtL4BbR3Ixe63XHO5gapAv5BQRO2sB13v4JtpZ/t3o/ 4yiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020a17090a86c700b0023b4158aaf1si1845926pjv.62.2023.03.29.11.37.26; Wed, 29 Mar 2023 11:37:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbjC2Sde (ORCPT + 99 others); Wed, 29 Mar 2023 14:33:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjC2Sdd (ORCPT ); Wed, 29 Mar 2023 14:33:33 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D7241FDA; Wed, 29 Mar 2023 11:33:30 -0700 (PDT) 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7eb07ed2-2b1c-44fa-b029-0ecad7872fd2@lunn.ch> X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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?