Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1049025rwl; Fri, 31 Mar 2023 06:09:07 -0700 (PDT) X-Google-Smtp-Source: AKy350bi9ZnySkNB7y3FKh2hBNo5OzCmqULIZUJS8ILEZE4Pq1E+exf11queo7wVbrO1ZmiZD3Cq X-Received: by 2002:a17:906:1ce:b0:92e:f520:7762 with SMTP id 14-20020a17090601ce00b0092ef5207762mr5108970ejj.6.1680268147721; Fri, 31 Mar 2023 06:09:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680268147; cv=none; d=google.com; s=arc-20160816; b=OcGEz1RI1wva1oMDK3BU7pT6oPkNjPr7HDcWY0BrVcE/BWtMVMH4QBdjOa6vk8fwHL AoGYaGAoQ9fqBBQT+/tWs9CEcoIfff/SWLNm5FTn3a3V3AYQuByPsOXBU1j6jO3zr+MM JnydmRxmcW6TYhyzeXmGPCpvbFiGCzHPNpmEbPmiCbNqaSZTqJ2mWHBqLNwxBhbCHjt+ aEQjkf4dje07yHZX3BIT7zEEye1VB7e9xMSxyXfbve2kBO1fn5ow2Qd62Mm//AfmKPtI 7x2GVEGutTSiACsP2/igwE8qhAlEh1mrf8qY4KP3/dknSuQsxzBU9WkFM4VssnA+5pTS 7BFw== 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=dX3+b7a2mtO46tzZW0WpCYT+JGnzFjdHoWuKzr8mDGc=; b=pwFSWXO8aX6Ps50tk+RCZ9G7sgCZfiNogZ+LB6kDhgSjZELW+nawNWNFSjl0ys+1+B /n5B2zipucKRBK4KYrhfI+lnXDlLmEo+Tk0HZuzkTOrAvDpxELa4XyPB+kZUp9P8F+s2 oskK4xTKhm4CE6tDzkjsrNvU6jbBYzbXVmbVpPWGE3jQ3xiAIopeaCA1j/DJQ47arf5b QTG4Hb3d7jvDgb4Q7a3iNyLq+fJu+kzU0gSUEMY9xRd33WoWXlOiIkBwrswPlE7gVTog 2TB6U3oyOSW6Aw8myNh8mPNQ35ZssI6jJ74LusbkbWlmIcRAsl6iNrRTNrLIIepU4nl9 6D5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=rrGuzRFY; 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 lz11-20020a170906fb0b00b00933a8c2308dsi1211326ejb.255.2023.03.31.06.08.41; Fri, 31 Mar 2023 06:09:07 -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=rrGuzRFY; 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 S232741AbjCaNHz (ORCPT + 99 others); Fri, 31 Mar 2023 09:07:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232690AbjCaNHy (ORCPT ); Fri, 31 Mar 2023 09:07:54 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FB625B9D; Fri, 31 Mar 2023 06:07:53 -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=dX3+b7a2mtO46tzZW0WpCYT+JGnzFjdHoWuKzr8mDGc=; b=rrGuzRFYsnrsLy+qaZsXgGfv9I YdG+uYn89vS8lLaeuGQvA+TjsJT2/y9E//EL1HDO0GIqmFestJaIOK9bzCeFepIffW/DoB8vUuN+d qGplyBpGd2QUPPcI7KpTJi5s9TYC3g8Y1WVumgh7j+GTob3iT9CGWOC0NGMkWkowRudQ=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1piETm-0091tW-Gq; Fri, 31 Mar 2023 15:07:42 +0200 Date: Fri, 31 Mar 2023 15:07:42 +0200 From: Andrew Lunn To: "Radu Pirea (OSS)" Cc: hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC net-next] net: phy: introduce phy_reg_field interface Message-ID: References: <20230331123259.567627-1-radu-nicolae.pirea@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230331123259.567627-1-radu-nicolae.pirea@oss.nxp.com> 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 Fri, Mar 31, 2023 at 03:32:59PM +0300, Radu Pirea (OSS) wrote: > Some PHYs can be heavily modified between revisions, and the addresses of > the registers are changed and the register fields are moved from one > register to another. > > To integrate more PHYs in the same driver with the same register fields, > but these register fields were located in different registers at > different offsets, I introduced the phy_reg_fied structure. Maybe you are solving the wrong problem. Maybe you should be telling the hardware/firmware engineers not to do this! How many drivers can actually use this? I don't really want to encourage vendors to make such a mess of their hardware, so i'm wondering if this should be hidden away in the driver, if there is only one driver which needs it. If there are multiple drivers which can use this, please do modify at least one other driver to use it, hence showing it is generic. > +int phy_read_reg_field(struct phy_device *phydev, > + const struct phy_reg_field *reg_field) > +{ > + u16 mask; > + int ret; > + > + if (reg_field->size == 0) { > + phydev_warn(phydev, "Trying to read a reg field of size 0."); > + return -EINVAL; > + } > + > + phy_lock_mdio_bus(phydev); > + if (reg_field->mmd) > + ret = __phy_read_mmd(phydev, reg_field->devad, > + reg_field->reg); > + else > + ret = __phy_read(phydev, reg_field->reg); > + phy_unlock_mdio_bus(phydev); > + Could you please explain the locking. It appears you are trying to protect reg_field->mmd? Does that really change? Especially since you have _const_ struct phy_reg_field * Andrew