From: Michael Walle Date: Wed, 22 Jun 2022 12:35:42 +0000 (+0200) Subject: net: sfp: use hwmon_sanitize_name() X-Git-Tag: v6.1-rc5~731^2~301^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f118c449c8ef7713e9acdebe333d947ab46933b;p=platform%2Fkernel%2Flinux-starfive.git net: sfp: use hwmon_sanitize_name() Instead of open-coding the bad characters replacement in the hwmon name, use the new hwmon_sanitize_name(). Signed-off-by: Michael Walle Acked-by: Russell King (Oracle) Acked-by: Guenter Roeck Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 9a5d5a1..81a529c 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -1290,7 +1290,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 @@ -1318,16 +1318,12 @@ static void sfp_hwmon_probe(struct work_struct *work) return; } - sfp->hwmon_name = kstrdup(dev_name(sfp->dev), GFP_KERNEL); - if (!sfp->hwmon_name) { + sfp->hwmon_name = hwmon_sanitize_name(dev_name(sfp->dev)); + if (IS_ERR(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,