[PATCH] net: phy: Add sysfs attribute for PHY c45 identifiers.

Jianhui Zhao posted 1 patch 2 years, 8 months ago
There is a newer version of this series
[PATCH] net: phy: Add sysfs attribute for PHY c45 identifiers.
Posted by Jianhui Zhao 2 years, 8 months ago
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 17d0d0555a79..81a4bc043ee2 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -541,8 +541,10 @@ static int phy_bus_match(struct device *dev, struct device_driver *drv)
 
 			if ((phydrv->phy_id & phydrv->phy_id_mask) ==
 			    (phydev->c45_ids.device_ids[i] &
-			     phydrv->phy_id_mask))
+			     phydrv->phy_id_mask)) {
+				phydev->phy_id = phydev->c45_ids.device_ids[i];
 				return 1;
+			}
 		}
 		return 0;
 	} else {

How about modifying it like this?
Re: [PATCH] net: phy: Add sysfs attribute for PHY c45 identifiers.
Posted by Russell King (Oracle) 2 years, 8 months ago
On Mon, Jun 12, 2023 at 10:04:26PM +0800, Jianhui Zhao wrote:
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 17d0d0555a79..81a4bc043ee2 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -541,8 +541,10 @@ static int phy_bus_match(struct device *dev, struct device_driver *drv)
>  
>  			if ((phydrv->phy_id & phydrv->phy_id_mask) ==
>  			    (phydev->c45_ids.device_ids[i] &
> -			     phydrv->phy_id_mask))
> +			     phydrv->phy_id_mask)) {
> +				phydev->phy_id = phydev->c45_ids.device_ids[i];
>  				return 1;
> +			}
>  		}
>  		return 0;
>  	} else {
> 
> How about modifying it like this?

No - there are C45 PHYs where the ID in each MMD are different. 88x3310
is one such example. If we're going to report any of them, we should
report all of them.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH] net: phy: Add sysfs attribute for PHY c45 identifiers.
Posted by Russell King (Oracle) 2 years, 8 months ago
On Mon, Jun 12, 2023 at 04:06:32PM +0100, Russell King (Oracle) wrote:
> On Mon, Jun 12, 2023 at 10:04:26PM +0800, Jianhui Zhao wrote:
> > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> > index 17d0d0555a79..81a4bc043ee2 100644
> > --- a/drivers/net/phy/phy_device.c
> > +++ b/drivers/net/phy/phy_device.c
> > @@ -541,8 +541,10 @@ static int phy_bus_match(struct device *dev, struct device_driver *drv)
> >  
> >  			if ((phydrv->phy_id & phydrv->phy_id_mask) ==
> >  			    (phydev->c45_ids.device_ids[i] &
> > -			     phydrv->phy_id_mask))
> > +			     phydrv->phy_id_mask)) {
> > +				phydev->phy_id = phydev->c45_ids.device_ids[i];
> >  				return 1;
> > +			}
> >  		}
> >  		return 0;
> >  	} else {
> > 
> > How about modifying it like this?
> 
> No - there are C45 PHYs where the ID in each MMD are different. 88x3310
> is one such example. If we're going to report any of them, we should
> report all of them.

The other issue is, this will remain as zero until a driver has
successfully matched the device, which means as far as userspace
knowing what type of PHY it is (to find a driver) this doesn't
improve the situation.

I don't think this is a very good solution.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH] net: phy: Add sysfs attribute for PHY c45 identifiers.
Posted by Andrew Lunn 2 years, 8 months ago
On Mon, Jun 12, 2023 at 10:04:26PM +0800, Jianhui Zhao wrote:
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 17d0d0555a79..81a4bc043ee2 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -541,8 +541,10 @@ static int phy_bus_match(struct device *dev, struct device_driver *drv)
>  
>  			if ((phydrv->phy_id & phydrv->phy_id_mask) ==
>  			    (phydev->c45_ids.device_ids[i] &
> -			     phydrv->phy_id_mask))
> +			     phydrv->phy_id_mask)) {
> +				phydev->phy_id = phydev->c45_ids.device_ids[i];
>  				return 1;
> +			}
>  		}
>  		return 0;
>  	} else {
> 
> How about modifying it like this?

O.K.

Please update the sysfs documentation as well.

       Andrew