diff mbox series

[v2,3/5] net: sfp: use hwmon_sanitize_name()

Message ID 20220329160730.3265481-4-michael@walle.cc (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series hwmon: introduce hwmon_sanitize() | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
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 7 of 7 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
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Michael Walle March 29, 2022, 4:07 p.m. UTC
Instead of open-coding the bad characters replacement in the hwmon name,
use the new hwmon_sanitize_name().

Signed-off-by: Michael Walle <michael@walle.cc>
---
 drivers/net/phy/sfp.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Russell King (Oracle) March 30, 2022, 7:40 p.m. UTC | #1
On Tue, Mar 29, 2022 at 06:07:28PM +0200, Michael Walle wrote:
> Instead of open-coding the bad characters replacement in the hwmon name,
> use the new hwmon_sanitize_name().
> 
> Signed-off-by: Michael Walle <michael@walle.cc>

Assuming hwmon_sanitize_name() gets settled, then:

Acked-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

> ---
>  drivers/net/phy/sfp.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 4dfb79807823..0d5dba30444d 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -1289,7 +1289,7 @@ static const struct hwmon_chip_info sfp_hwmon_chip_info = {
>  static void sfp_hwmon_probe(struct work_struct *work)
>  {
>  	struct sfp *sfp = container_of(work, struct sfp, hwmon_probe.work);
> -	int err, i;
> +	int err;
>  
>  	/* hwmon interface needs to access 16bit registers in atomic way to
>  	 * guarantee coherency of the diagnostic monitoring data. If it is not
> @@ -1317,16 +1317,12 @@ static void sfp_hwmon_probe(struct work_struct *work)
>  		return;
>  	}
>  
> -	sfp->hwmon_name = kstrdup(dev_name(sfp->dev), GFP_KERNEL);
> +	sfp->hwmon_name = hwmon_sanitize_name(dev_name(sfp->dev));
>  	if (!sfp->hwmon_name) {
>  		dev_err(sfp->dev, "out of memory for hwmon name\n");
>  		return;
>  	}
>  
> -	for (i = 0; sfp->hwmon_name[i]; i++)
> -		if (hwmon_is_bad_char(sfp->hwmon_name[i]))
> -			sfp->hwmon_name[i] = '_';
> -
>  	sfp->hwmon_dev = hwmon_device_register_with_info(sfp->dev,
>  							 sfp->hwmon_name, sfp,
>  							 &sfp_hwmon_chip_info,
> -- 
> 2.30.2
> 
>
Russell King (Oracle) March 31, 2022, 2:46 p.m. UTC | #2
On Tue, Mar 29, 2022 at 06:07:28PM +0200, Michael Walle wrote:
> Instead of open-coding the bad characters replacement in the hwmon name,
> use the new hwmon_sanitize_name().
> 
> Signed-off-by: Michael Walle <michael@walle.cc>

Acked-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
diff mbox series

Patch

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 4dfb79807823..0d5dba30444d 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -1289,7 +1289,7 @@  static const struct hwmon_chip_info sfp_hwmon_chip_info = {
 static void sfp_hwmon_probe(struct work_struct *work)
 {
 	struct sfp *sfp = container_of(work, struct sfp, hwmon_probe.work);
-	int err, i;
+	int err;
 
 	/* hwmon interface needs to access 16bit registers in atomic way to
 	 * guarantee coherency of the diagnostic monitoring data. If it is not
@@ -1317,16 +1317,12 @@  static void sfp_hwmon_probe(struct work_struct *work)
 		return;
 	}
 
-	sfp->hwmon_name = kstrdup(dev_name(sfp->dev), GFP_KERNEL);
+	sfp->hwmon_name = hwmon_sanitize_name(dev_name(sfp->dev));
 	if (!sfp->hwmon_name) {
 		dev_err(sfp->dev, "out of memory for hwmon name\n");
 		return;
 	}
 
-	for (i = 0; sfp->hwmon_name[i]; i++)
-		if (hwmon_is_bad_char(sfp->hwmon_name[i]))
-			sfp->hwmon_name[i] = '_';
-
 	sfp->hwmon_dev = hwmon_device_register_with_info(sfp->dev,
 							 sfp->hwmon_name, sfp,
 							 &sfp_hwmon_chip_info,