diff mbox series

[v2,2/2] net: mdio: fixup ethernet phy module auto-load function

Message ID 1637919957-21635-2-git-send-email-zhuyinbo@loongson.cn (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [v2,1/2] modpost: file2alias: fixup mdio alias garbled code in modules.alias | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 25 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yinbo Zhu Nov. 26, 2021, 9:45 a.m. UTC
the phy_id is only phy identifier, that phy module auto-load function
should according the phy_id event rather than other information, this
patch is remove other unnecessary information and add phy_id event in
mdio_uevent function and ethernet phy module auto-load function will
work well.

Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
---
 drivers/net/phy/mdio_bus.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Russell King (Oracle) Nov. 26, 2021, 10:13 a.m. UTC | #1
On Fri, Nov 26, 2021 at 05:45:57PM +0800, Yinbo Zhu wrote:
> the phy_id is only phy identifier, that phy module auto-load function
> should according the phy_id event rather than other information, this
> patch is remove other unnecessary information and add phy_id event in
> mdio_uevent function and ethernet phy module auto-load function will
> work well.
> 
> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
> ---
>  drivers/net/phy/mdio_bus.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index 6865d93..999f0d4 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -962,12 +962,12 @@ static int mdio_bus_match(struct device *dev, struct device_driver *drv)
>  
>  static int mdio_uevent(struct device *dev, struct kobj_uevent_env *env)
>  {
> -	int rc;
> +	struct phy_device *pdev;
>  
> -	/* Some devices have extra OF data and an OF-style MODALIAS */
> -	rc = of_device_uevent_modalias(dev, env);
> -	if (rc != -ENODEV)
> -		return rc;
> +	pdev = to_phy_device(dev);
> +
> +	if (add_uevent_var(env, "MODALIAS=mdio:p%08X", pdev->phy_id))
> +		return -ENOMEM;
>  
>  	return 0;
>  }

No. I think we've been over the reasons already. It _will_ break
existing module loading.

If I look at the PHY IDs on my Clearfog board:

/sys/bus/mdio_bus/devices/f1072004.mdio-mii:00/phy_id:0x01410dd1
/sys/bus/mdio_bus/devices/mv88e6xxx-0:00/phy_id:0x01410eb1
/sys/bus/mdio_bus/devices/mv88e6xxx-0:01/phy_id:0x01410eb1
/sys/bus/mdio_bus/devices/mv88e6xxx-0:02/phy_id:0x01410eb1
/sys/bus/mdio_bus/devices/mv88e6xxx-0:03/phy_id:0x01410eb1
/sys/bus/mdio_bus/devices/mv88e6xxx-0:04/phy_id:0x01410eb1
/sys/bus/mdio_bus/devices/mv88e6xxx-0:0f/phy_id:0x01410ea1

and then look at the PHY IDs that the kernel uses in the drivers, and
thus will be used in the module's alias tables.

#define MARVELL_PHY_ID_88E1510          0x01410dd0
#define MARVELL_PHY_ID_88E1540          0x01410eb0
#define MARVELL_PHY_ID_88E1545          0x01410ea0

These numbers are different. This is not just one board. The last nibble
of the PHY ID is generally the PHY revision, but that is not universal.
See Atheros PHYs, where we match the entire ID except bit 4.

You can not "simplify" the "ugly" matching like this. It's the way it is
for good reason. Using the whole ID will _not_ cause a match, and your
change will cause a regression.

> @@ -991,7 +991,7 @@ static int mdio_uevent(struct device *dev, struct kobj_uevent_env *env)
>  };
>  
>  struct bus_type mdio_bus_type = {
> -	.name		= "mdio_bus",
> +	.name		= "mdio",
>  	.dev_groups	= mdio_bus_dev_groups,
>  	.match		= mdio_bus_match,
>  	.uevent		= mdio_uevent,

Definitely no, this won't be accepted, and is in any case a separate
change that is unrelated to the first hunk of the patch.
diff mbox series

Patch

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 6865d93..999f0d4 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -962,12 +962,12 @@  static int mdio_bus_match(struct device *dev, struct device_driver *drv)
 
 static int mdio_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
-	int rc;
+	struct phy_device *pdev;
 
-	/* Some devices have extra OF data and an OF-style MODALIAS */
-	rc = of_device_uevent_modalias(dev, env);
-	if (rc != -ENODEV)
-		return rc;
+	pdev = to_phy_device(dev);
+
+	if (add_uevent_var(env, "MODALIAS=mdio:p%08X", pdev->phy_id))
+		return -ENOMEM;
 
 	return 0;
 }
@@ -991,7 +991,7 @@  static int mdio_uevent(struct device *dev, struct kobj_uevent_env *env)
 };
 
 struct bus_type mdio_bus_type = {
-	.name		= "mdio_bus",
+	.name		= "mdio",
 	.dev_groups	= mdio_bus_dev_groups,
 	.match		= mdio_bus_match,
 	.uevent		= mdio_uevent,