Skip to contentSkip to conversation

net: phy: remove calls to devm_hwmon_sanitize_name

PATCH Applied Heiner Kallweit 3 participants 10 messages Mar 13, 2025 – Mar 21, 2025

Subsystems (5)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

cover net: phy: remove calls to devm_hwmon_sanitize_name

Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument.

Heiner Kallweit (4):
net: phy: realtek: remove call to devm_hwmon_sanitize_name
net: phy: tja11xx: remove call to devm_hwmon_sanitize_name
net: phy: mxl-gpy: remove call to devm_hwmon_sanitize_name
net: phy: marvell-88q2xxx: remove call to devm_hwmon_sanitize_name

 drivers/net/phy/marvell-88q2xxx.c       |  8 +-------
 drivers/net/phy/mxl-gpy.c               |  8 +-------
 drivers/net/phy/nxp-tja11xx.c           | 19 +++++--------------
 drivers/net/phy/realtek/realtek_hwmon.c |  7 +------
 4 files changed, 8 insertions(+), 34 deletions(-)
Signature · 1 line
2.48.1
author maintainer
#1 lore raw

PATCH 1/4 net: phy: realtek: remove call to devm_hwmon_sanitize_name

Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument.

---
 drivers/net/phy/realtek/realtek_hwmon.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/net/phy/realtek/realtek_hwmon.c +1 -6
index 1ecb410bb..ac96e2d1e 100644
@@ -63,16 +63,11 @@ static const struct hwmon_chip_info rtl822x_hwmon_chip_info = {
 int rtl822x_hwmon_init(struct phy_device *phydev)
 {
 	struct device *hwdev, *dev = &phydev->mdio.dev;
-	const char *name;
 
 	/* Ensure over-temp alarm is reset. */
 	phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_TSALRM, 3);
 
-	name = devm_hwmon_sanitize_name(dev, dev_name(dev));
-	if (IS_ERR(name))
-		return PTR_ERR(name);
-
-	hwdev = devm_hwmon_device_register_with_info(dev, name, phydev,
+	hwdev = devm_hwmon_device_register_with_info(dev, NULL, phydev,
 						     &rtl822x_hwmon_chip_info,
 						     NULL);
 	return PTR_ERR_OR_ZERO(hwdev);
Signature · 1 line
2.48.1
author maintainer
#2 lore raw

PATCH 2/4 net: phy: tja11xx: remove call to devm_hwmon_sanitize_name

In reply to Heiner Kallweit

Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument.

Note that neither priv->hwmon_name nor priv->hwmon_dev are used outside tja11xx_hwmon_register.

---
 drivers/net/phy/nxp-tja11xx.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/net/phy/nxp-tja11xx.c +5 -14
index 601094fe2..07e94a247 100644
@@ -87,8 +87,6 @@
 #define TJA110X_RMII_MODE_REFCLK_IN       BIT(0)
 
 struct tja11xx_priv {
-	char		*hwmon_name;
-	struct device	*hwmon_dev;
 	struct phy_device *phydev;
 	struct work_struct phy_register_work;
 	u32 flags;
@@ -508,19 +506,12 @@ static const struct hwmon_chip_info tja11xx_hwmon_chip_info = {
 static int tja11xx_hwmon_register(struct phy_device *phydev,
 				  struct tja11xx_priv *priv)
 {
-	struct device *dev = &phydev->mdio.dev;
-
-	priv->hwmon_name = devm_hwmon_sanitize_name(dev, dev_name(dev));
-	if (IS_ERR(priv->hwmon_name))
-		return PTR_ERR(priv->hwmon_name);
-
-	priv->hwmon_dev =
-		devm_hwmon_device_register_with_info(dev, priv->hwmon_name,
-						     phydev,
-						     &tja11xx_hwmon_chip_info,
-						     NULL);
+	struct device *hdev, *dev = &phydev->mdio.dev;
 
-	return PTR_ERR_OR_ZERO(priv->hwmon_dev);
+	hdev = devm_hwmon_device_register_with_info(dev, NULL, phydev,
+						    &tja11xx_hwmon_chip_info,
+						    NULL);
+	return PTR_ERR_OR_ZERO(hdev);
 }
 
 static int tja11xx_parse_dt(struct phy_device *phydev)
Signature · 1 line
2.48.1
#3 lore raw

Re: [PATCH net-next 2/4] net: phy: tja11xx: remove call to devm_hwmon_sanitize_name

Hello Heiner,

Quoted 38 lines · On Thu, 13 Mar 2025 20:45:06 +0100 Heiner Kallweit <[email protected]> wrote:

Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument.

Note that neither priv->hwmon_name nor priv->hwmon_dev are used outside tja11xx_hwmon_register.

---
 drivers/net/phy/nxp-tja11xx.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/net/phy/nxp-tja11xx.c +0 -11
index 601094fe2..07e94a247 100644
@@ -87,8 +87,6 @@
 #define TJA110X_RMII_MODE_REFCLK_IN       BIT(0)
 
 struct tja11xx_priv {
-	char		*hwmon_name;
-	struct device	*hwmon_dev;
 	struct phy_device *phydev;
 	struct work_struct phy_register_work;
 	u32 flags;
@@ -508,19 +506,12 @@ static const struct hwmon_chip_info tja11xx_hwmon_chip_info = {
 static int tja11xx_hwmon_register(struct phy_device *phydev,
 				  struct tja11xx_priv *priv)
 {
-	struct device *dev = &phydev->mdio.dev;
-
-	priv->hwmon_name = devm_hwmon_sanitize_name(dev, dev_name(dev));
-	if (IS_ERR(priv->hwmon_name))
-		return PTR_ERR(priv->hwmon_name);
-
-	priv->hwmon_dev =
-		devm_hwmon_device_register_with_info(dev, priv->hwmon_name,
-						     phydev,

drivers/net/phy/nxp-tja11xx.c static const struct hwmon_chip_info tja11xx_hwmon_chip_info = { · line 515

Quoted 10 lines
drivers/net/phy/nxp-tja11xx.c +5 -3
-						     &tja11xx_hwmon_chip_info,
-						     NULL);
+	struct device *hdev, *dev = &phydev->mdio.dev;
 
-	return PTR_ERR_OR_ZERO(priv->hwmon_dev);
+	hdev = devm_hwmon_device_register_with_info(dev, NULL, phydev,
+						    &tja11xx_hwmon_chip_info,
+						    NULL);
+	return PTR_ERR_OR_ZERO(hdev);
 }

The change look correct to me, however I think you can go one step further and remove the field tja11xx_priv.hwmon_name as well as hwmon_dev.

One could argue that we can even remove tja11xx_hwmon_register() entirely

Thanks,

Maxime

author maintainer
#4 lore raw

Re: [PATCH net-next 2/4] net: phy: tja11xx: remove call to devm_hwmon_sanitize_name

Quoted 47 lines · Maxime Chevallier

Hello Heiner,

Quoted 42 lines · On Thu, 13 Mar 2025 20:45:06 +0100 Heiner Kallweit <[email protected]> wrote:

Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument.

Note that neither priv->hwmon_name nor priv->hwmon_dev are used outside tja11xx_hwmon_register.

---
 drivers/net/phy/nxp-tja11xx.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/net/phy/nxp-tja11xx.c +1 -13
index 601094fe2..07e94a247 100644
@@ -87,8 +87,6 @@
 #define TJA110X_RMII_MODE_REFCLK_IN       BIT(0)
 
 struct tja11xx_priv {
-	char		*hwmon_name;
-	struct device	*hwmon_dev;
 	struct phy_device *phydev;
 	struct work_struct phy_register_work;
 	u32 flags;
@@ -508,19 +506,12 @@ static const struct hwmon_chip_info tja11xx_hwmon_chip_info = {
 static int tja11xx_hwmon_register(struct phy_device *phydev,
 				  struct tja11xx_priv *priv)
 {
-	struct device *dev = &phydev->mdio.dev;
-
-	priv->hwmon_name = devm_hwmon_sanitize_name(dev, dev_name(dev));
-	if (IS_ERR(priv->hwmon_name))
-		return PTR_ERR(priv->hwmon_name);
-
-	priv->hwmon_dev =
-		devm_hwmon_device_register_with_info(dev, priv->hwmon_name,
-						     phydev,
-						     &tja11xx_hwmon_chip_info,
-						     NULL);
+	struct device *hdev, *dev = &phydev->mdio.dev;
 
Quoted 11 lines

drivers/net/phy/nxp-tja11xx.c static const struct hwmon_chip_info tja11xx_hwmon_chip_info = { · line 515

Quoted 6 lines
drivers/net/phy/nxp-tja11xx.c +4 -1
-	return PTR_ERR_OR_ZERO(priv->hwmon_dev);
+	hdev = devm_hwmon_device_register_with_info(dev, NULL, phydev,
+						    &tja11xx_hwmon_chip_info,
+						    NULL);
+	return PTR_ERR_OR_ZERO(hdev);
 }

The change look correct to me, however I think you can go one step further and remove the field tja11xx_priv.hwmon_name as well as hwmon_dev.

This is part of the patch. Or what do you mean?

Quoted 3 lines

One could argue that we can even remove tja11xx_hwmon_register() entirely

It's called from two places, and we would have to duplicate some things like IS_ERR(). I think it's ok to leave this function in.

Quoted 3 lines

Thanks,

Maxime

Heiner

#5 lore raw

Re: [PATCH net-next 2/4] net: phy: tja11xx: remove call to devm_hwmon_sanitize_name

Quoted 59 lines · On Fri, 14 Mar 2025 12:26:33 +0100 Heiner Kallweit <[email protected]> wrote:
Quoted 47 lines · Maxime Chevallier

Hello Heiner,

Quoted 42 lines · On Thu, 13 Mar 2025 20:45:06 +0100 Heiner Kallweit <[email protected]> wrote:

Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument.

Note that neither priv->hwmon_name nor priv->hwmon_dev are used outside tja11xx_hwmon_register.

---
 drivers/net/phy/nxp-tja11xx.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/net/phy/nxp-tja11xx.c +1 -13
index 601094fe2..07e94a247 100644
@@ -87,8 +87,6 @@
 #define TJA110X_RMII_MODE_REFCLK_IN       BIT(0)
 
 struct tja11xx_priv {
-	char		*hwmon_name;
-	struct device	*hwmon_dev;
 	struct phy_device *phydev;
 	struct work_struct phy_register_work;
 	u32 flags;
@@ -508,19 +506,12 @@ static const struct hwmon_chip_info tja11xx_hwmon_chip_info = {
 static int tja11xx_hwmon_register(struct phy_device *phydev,
 				  struct tja11xx_priv *priv)
 {
-	struct device *dev = &phydev->mdio.dev;
-
-	priv->hwmon_name = devm_hwmon_sanitize_name(dev, dev_name(dev));
-	if (IS_ERR(priv->hwmon_name))
-		return PTR_ERR(priv->hwmon_name);
-
-	priv->hwmon_dev =
-		devm_hwmon_device_register_with_info(dev, priv->hwmon_name,
-						     phydev,
-						     &tja11xx_hwmon_chip_info,
-						     NULL);
+	struct device *hdev, *dev = &phydev->mdio.dev;
 
Quoted 11 lines

drivers/net/phy/nxp-tja11xx.c static const struct hwmon_chip_info tja11xx_hwmon_chip_info = { · line 515

Quoted 6 lines
drivers/net/phy/nxp-tja11xx.c +4 -1
-	return PTR_ERR_OR_ZERO(priv->hwmon_dev);
+	hdev = devm_hwmon_device_register_with_info(dev, NULL, phydev,
+						    &tja11xx_hwmon_chip_info,
+						    NULL);
+	return PTR_ERR_OR_ZERO(hdev);
 }  

The change look correct to me, however I think you can go one step further and remove the field tja11xx_priv.hwmon_name as well as hwmon_dev.

Quoted 1 line

This is part of the patch. Or what do you mean?

Uh you are correct :( meh OK sory for the noise then, morning coffee didn't go through entirely this morning it seems.

Maxime

author maintainer
#6 lore raw

PATCH 3/4 net: phy: mxl-gpy: remove call to devm_hwmon_sanitize_name

In reply to Heiner Kallweit

Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument.

---
 drivers/net/phy/mxl-gpy.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/net/phy/mxl-gpy.c +1 -7
index 94d9cb727..cc531cc92 100644
@@ -225,14 +225,8 @@ static int gpy_hwmon_register(struct phy_device *phydev)
 {
 	struct device *dev = &phydev->mdio.dev;
 	struct device *hwmon_dev;
-	char *hwmon_name;
 
-	hwmon_name = devm_hwmon_sanitize_name(dev, dev_name(dev));
-	if (IS_ERR(hwmon_name))
-		return PTR_ERR(hwmon_name);
-
-	hwmon_dev = devm_hwmon_device_register_with_info(dev, hwmon_name,
-							 phydev,
+	hwmon_dev = devm_hwmon_device_register_with_info(dev, NULL, phydev,
 							 &gpy_hwmon_chip_info,
 							 NULL);
 
Signature · 1 line
2.48.1
author maintainer
#7 lore raw

PATCH 4/4 net: phy: marvell-88q2xxx: remove call to devm_hwmon_sanitize_name

In reply to Heiner Kallweit

Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument.

---
 drivers/net/phy/marvell-88q2xxx.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/net/phy/marvell-88q2xxx.c +1 -7
index 15c0f8adc..23e1f0521 100644
@@ -765,16 +765,10 @@ static int mv88q2xxx_hwmon_probe(struct phy_device *phydev)
 	struct mv88q2xxx_priv *priv = phydev->priv;
 	struct device *dev = &phydev->mdio.dev;
 	struct device *hwmon;
-	char *hwmon_name;
 
 	priv->enable_temp = true;
-	hwmon_name = devm_hwmon_sanitize_name(dev, dev_name(dev));
-	if (IS_ERR(hwmon_name))
-		return PTR_ERR(hwmon_name);
 
-	hwmon = devm_hwmon_device_register_with_info(dev,
-						     hwmon_name,
-						     phydev,
+	hwmon = devm_hwmon_device_register_with_info(dev, NULL, phydev,
 						     &mv88q2xxx_hwmon_chip_info,
 						     NULL);
 
Signature · 1 line
2.48.1
Reviewed-by on the v1 series
#8 lore raw
In reply to Heiner Kallweit

Hi Heiner,

Quoted 10 lines · On Thu, 13 Mar 2025 20:43:44 +0100 Heiner Kallweit <[email protected]> wrote:

Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument.

Heiner Kallweit (4):
net: phy: realtek: remove call to devm_hwmon_sanitize_name
net: phy: tja11xx: remove call to devm_hwmon_sanitize_name
net: phy: mxl-gpy: remove call to devm_hwmon_sanitize_name
net: phy: marvell-88q2xxx: remove call to devm_hwmon_sanitize_name

Quoted 6 lines
 drivers/net/phy/marvell-88q2xxx.c       |  8 +-------
 drivers/net/phy/mxl-gpy.c               |  8 +-------
 drivers/net/phy/nxp-tja11xx.c           | 19 +++++--------------
 drivers/net/phy/realtek/realtek_hwmon.c |  7 +------
 4 files changed, 8 insertions(+), 34 deletions(-)

With more coffee in my system, I took a better look and it indeed looks good to me.

Sorry about the noisy comments,

Maxime

#9 lore raw
In reply to Heiner Kallweit
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 11 lines · On Thu, 13 Mar 2025 20:43:44 +0100 you wrote:

Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument.

Heiner Kallweit (4):
net: phy: realtek: remove call to devm_hwmon_sanitize_name
net: phy: tja11xx: remove call to devm_hwmon_sanitize_name
net: phy: mxl-gpy: remove call to devm_hwmon_sanitize_name
net: phy: marvell-88q2xxx: remove call to devm_hwmon_sanitize_name

[...]

Here is the summary with links:
- [net-next,1/4] net: phy: realtek: remove call to devm_hwmon_sanitize_name

    https://git.kernel.org/netdev/net-next/c/62e36b244135
  - [net-next,2/4] net: phy: tja11xx: remove call to devm_hwmon_sanitize_name
    https://git.kernel.org/netdev/net-next/c/91ee21962430
  - [net-next,3/4] net: phy: mxl-gpy: remove call to devm_hwmon_sanitize_name
    https://git.kernel.org/netdev/net-next/c/0426bd18af92
  - [net-next,4/4] net: phy: marvell-88q2xxx: remove call to devm_hwmon_sanitize_name
    https://git.kernel.org/netdev/net-next/c/345be5cd6e1d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html