Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1102446rwl; Wed, 29 Mar 2023 12:44:30 -0700 (PDT) X-Google-Smtp-Source: AKy350ZKYvJFioEbth97nkF97crqwy8YQFi1gtp8r18ueykiYwAWml/041M/Js/qMasSF4ZFphaC X-Received: by 2002:a05:6402:68e:b0:500:3a14:82c1 with SMTP id f14-20020a056402068e00b005003a1482c1mr18814684edy.41.1680119069964; Wed, 29 Mar 2023 12:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680119069; cv=none; d=google.com; s=arc-20160816; b=f2CPLbsDEXZMVNJFNLLuidP4qUOeKcHbULbZnOSOR5AAo7XEikUEczxsyTw4h3SbRf zOPv28ZPXFIrvqrVkWNxkjgq9R7Gt58osqPYQONLkMYssIfv13hd7pM6YNa8Lr4xYtqW g0Soy6vHhaTGeef7gGheVM7PMFfUlwpEMLy3ifSAqVBpyA8YjRakVpKpHIFNbOnsSjCt cI07Xc1VNSx7YSY3pH6e2Gv0rr0TgKED4xHIf2186caFi99ltrpqYvntJDPJxBB9MbNp 7HhuJ6BEne7cS1ltZLjhIT38sy5L4w5Mqeb+zpCUmDuBDOACdZ05F2J5f7NPfA6xaylo LABw== 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:dkim-signature; bh=9Ip60VxQO8vIEjsVQuk6WZlBLCQN328zDAYmxQho2Uk=; b=ORAC0b7OVjbWfFQlXzZU3KLURHKIMRgIoiNR1s399bl13p1v+kg2VNMDozeFdGKHgb 34bB1vN8zkEyaUKPHEgKLMn46ZEj7i+hqTRe55YRf80n6ravflzlzCVreEgg7crTJau4 Yj1wEluAoiBZdKpOa3JgPq1oUbPbIRfIIdWw6AIGtRhckxGAiiYoBVxk6rm0KhnyBqiV 3vThfsc9cLCZZplT2X5SfFWpgvHV1xiOXD4rKRbU89wmjK1XPt7rCJ+rZfHsNiIi5Ahp Z3tSFlJQxzXVbKrNKTPURkQaG9/TkQ9owKPWWaTMWvbrj3QGjr5s6wMhhPBc8xqdv7Je LBxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=oNr9cPXY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q4-20020a056402032400b004fd26753f3esi35043918edw.129.2023.03.29.12.44.01; Wed, 29 Mar 2023 12:44:29 -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; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=oNr9cPXY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229783AbjC2Tfe (ORCPT + 99 others); Wed, 29 Mar 2023 15:35:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjC2Tfc (ORCPT ); Wed, 29 Mar 2023 15:35:32 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B565C469C; Wed, 29 Mar 2023 12:35:31 -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=9Ip60VxQO8vIEjsVQuk6WZlBLCQN328zDAYmxQho2Uk=; b=oNr9cPXYVHQF9aWQrgtHuUbaL4 rrNePszDIqfOYFfGJC50qIve5P6TNCg56eDFOWxZFl5EU4a6rvy6hSSeNXqQEUrqJjaeXThOcY7sP yHibUzHcsx5RDU3sLn98Kg1qzVw5h5E6OXiPoAvByexD169ZM+yrl2MQni+L90RuZtF4=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1phbZl-008nTP-Sg; Wed, 29 Mar 2023 21:35:17 +0200 Date: Wed, 29 Mar 2023 21:35:17 +0200 From: Andrew Lunn To: Daniel Golle 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: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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 07:33:17PM +0100, Daniel Golle wrote: > 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. O.K. At least i would not return the negative error code. Return 0, or 0xdeadbeef or something. And consider adding a WARN_ON_ONCE() so it is very loud when it goes wrong. > 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. Yes, that is what mv88e6xxx does. > However, I was hestitating to convert all the calls (they are many) to > follow that improved paradigm. Yes, leave that for another time. Andrew