Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp784983rdb; Sun, 18 Feb 2024 11:33:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUb/KbhyDNsuIAmKjtnVQnWNd7CXLBQXI1oPEjzvabLFL/YQJ4ZNGrnibE4GxJz6GA5U/B1W8C8lcb5ol621Ka0I0O1y85nhM/K5F3KKw== X-Google-Smtp-Source: AGHT+IEpx83d6Oy0tqce/yAscr0o4HZU6DsDoS6tRm6UkafKpB9rDVjSXMkX+p3wfTlUcJNipcn+ X-Received: by 2002:a05:6902:541:b0:dc7:1ab6:6aca with SMTP id z1-20020a056902054100b00dc71ab66acamr7548780ybs.63.1708284827618; Sun, 18 Feb 2024 11:33:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708284827; cv=pass; d=google.com; s=arc-20160816; b=bIyZh0mOTRNLD5HMD+WKTvPjAdtRB1JmrdrvibjoeNHSOUn+OHfa2Pn/A4VOVC5xn/ xUdJJNZyffJ0yVuo1OFGsG84zofhPgkMB5DJnF2hR4R4nYw9JcQJvyeUsyAdXKlAirUM zg5YHN1uWa82ji3FDhUc4mxcY1TgrtK8ZqZteNaSbvXm14rWoF8gJmvy09uizd1wovlP fEm0BbauTWMUT2K10c0tCj/jcYPHYvx/jKj0TPy9qERsWn+s0cVYkUP6SAOY1Xewj9u0 /UvbVZnkibwcjWRjkKiNk2YlQqN5j8ssw2aPlQJ2x+km79Iy+WB0341O42VKAdOkf1We rWLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=FlX/3S5lEmqhQMAXnL/TVCuNUd13KReMyckuk67tlEY=; fh=WShH+suyGbda4YO6qJqxEouz6obFAAWUE7m5ZpSuZOw=; b=UOIhmIV1S7zOaQA9uiTMQGn4579Ww4+cBjzkAxJkMJc3uQ+0fCVA8TsMlwUuABr3R8 jv3E2W2OnfOYCw0wYGmNSO7OsXK/dZqOxlA5w86Pkr5ygBy3NOhdSNGwNdnHmi0vrsqr cY8sKvrBrgVS2wbP7FXtTz+ZKvHWmld05uZ/GvkqmUkdKpycEfAOV5aMHq9l/UxxDjma GNk8jYFmIhthRHUidmNy9KPPlX6rlA1OATz+MCaLDV6tPZ7+2OXlEBdyxdFDtIOTAjw1 HY9pQgY+i2tjK+WMrPNfv4Q5nPryOXq8HPRpE8e74zLv6QbBK16/6/oq9xojW6Hb8ZwG gRKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=wPKgVFV1; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-70550-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70550-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h6-20020a05620a244600b00785d37680cdsi5266945qkn.733.2024.02.18.11.33.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 11:33:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70550-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=wPKgVFV1; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-70550-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70550-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 605CB1C20D54 for ; Sun, 18 Feb 2024 19:33:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F99471B38; Sun, 18 Feb 2024 19:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="wPKgVFV1" Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D38D1E86F; Sun, 18 Feb 2024 19:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708284818; cv=none; b=Qn8jklqRDSruox2tTJ67Xr3ZHmmo81Vz7I2c+OTmLDNJYceegsWVO8MdnK8TJ+Bm+geXIMPlML+HvxQXiGxOLygPWO5pobujGBYX3zgy+UAoWYjBIkYAgn2n3KB4vydCHjP2wZARGV3Hk083HYNVeGo8monCr5GCvrTKF2GbnFM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708284818; c=relaxed/simple; bh=7Ghd5hY5Zy9MQ5coy0TWaYNTyXdVwzw9c3pyJIdHTFo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Czj2S4rhu21iZrBJYXrSOxiKAwNYCRiE31/ogM0bAuZLjmV6efKUCjCgDIQaH/LpBfcqItwrdQNOtSICsnQu67lGWM6r0IXUgzrzO0ldkUkzep/2Soc8mbAQ+Q/nnhwtlax5JRR0Iv2yqZtlbvtN1+Dcqg0Ry1SmHsq8fqtuCbY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=wPKgVFV1; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FlX/3S5lEmqhQMAXnL/TVCuNUd13KReMyckuk67tlEY=; b=wPKgVFV1sdcnrsUaZQ+Laj8Uzi yIyEgf7BmnGsvBub/q1CaOXjdq9ssi2dYVAH423kmijFCbZWzWbyVD/5KHePX8Kno1l91s17U5Bh6 Fo/NZhXHdJAgusMwuz5RBPjqm21UsRdQ2nSee58hDqhoAFKdNFLe9+tDtkrMBZFETcg5MZBZdB8Fp IBqt+9TvvzJAhl2ZUG8rGexfN0+38bPqHJGwdei1ZN/wxllkPrWGh9YcKl0woY6VokOlugqt8Eq8r jojRcmqCtDMG0KB81WlZQbBZHb3RO2zw1CuoImdeEVxJvlrfON4VhBHU9ozxHxUS401N0avFWzKja 4O/JhpIA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:46298) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rbmuW-0003SU-1N; Sun, 18 Feb 2024 19:33:12 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rbmuQ-0007eV-QR; Sun, 18 Feb 2024 19:33:06 +0000 Date: Sun, 18 Feb 2024 19:33:06 +0000 From: "Russell King (Oracle)" To: Christian Marangi Cc: Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Broadcom internal kernel review list , Robert Marko , Greg Kroah-Hartman , Pieter Jansen van Vuuren , Nipun Gupta , Andy Shevchenko , Puneet Gupta , Abhijit Gangurde , Umang Jain , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [net-next RFC PATCH 1/6] net: phy: add support for defining multiple PHY IDs in PHY driver Message-ID: References: <20240218190034.15447-1-ansuelsmth@gmail.com> <20240218190034.15447-2-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240218190034.15447-2-ansuelsmth@gmail.com> Sender: Russell King (Oracle) On Sun, Feb 18, 2024 at 08:00:27PM +0100, Christian Marangi wrote: > Some PHY driver might implement the same OPs for different PHY ID and > using a mask is not enough to match similar PHYs. > > To reduce code duplication, add support for defining multiple PHY IDs in > PHY driver struct. > > Introduce a new variable in phy_driver struct, .ids, where a table array of > mdio_device_id can be defined to reference multiple PHY IDs (with their > own masks) supporting the same group of OPs and flags. > > Introduce a new variable in phy_device, .dev_id, where the matching > mdio_device_id is stored. PHYs supporting multiple PHYs for one PHY > driver struct, should use this instead of matching for phy_id. > > Single PHY ID implementation is still supported and dev_id is filled > with the data from phy_driver in this case. This looks like it's been reworked somewhat with my suggestion, or maybe we just came across a similar structure for comparing the IDs? > + phy_dev_id = (struct mdio_device_id *)&phydev->dev_id; Why this cast? Try to write code that doesn't need casts. > + /* Fill the mdio_device_id for the PHY istance. > + * If PHY driver provide an array of PHYs, search the right one, > + * in the other case fill it with the phy_driver data. > + */ > + if (phy_driver_match(phydrv, phydev, &dev_id) && dev_id) { > + memcpy(phy_dev_id, dev_id, sizeof(*dev_id)); > + } else { > + phy_dev_id->phy_id = phydrv->phy_id; > + phy_dev_id->phy_id_mask = phydrv->phy_id_mask; So this is the _driver_ phy_id. > static inline bool phydev_id_compare(struct phy_device *phydev, u32 id) > { > - return phy_id_compare(id, phydev->phy_id, phydev->drv->phy_id_mask); > + return phy_id_compare(id, phydev->dev_id.phy_id, > + phydev->dev_id.phy_id_mask); And thus this code is now different (since it _was_ comparing the phydev phy_id, and you've changed it to effectively the driver's phy_id. While that should be the same for a matched driver, that is still a change that probably is't intentional. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!