Message ID | 42f2e064-181c-087e-68b1-64d2d6f13e0e@gmail.com |
---|---|
State | Deferred |
Delegated to: | David Miller |
Headers | show |
Series | lib: string: add strreplace_nonalnum | expand |
On Sun, Mar 03, 2019 at 06:21:53PM +0100, Heiner Kallweit wrote:
> Use new function strreplace_nonalnum to simplify the code.
Hi Heiner
Both Marvell PHY drivers could use this.
sfp.c has a variant of this as well.
Andrew
On 03.03.2019 18:31, Andrew Lunn wrote: > On Sun, Mar 03, 2019 at 06:21:53PM +0100, Heiner Kallweit wrote: >> Use new function strreplace_nonalnum to simplify the code. > > Hi Heiner > > Both Marvell PHY drivers could use this. > > sfp.c has a variant of this as well. > Thanks! My plan was to provide a first user so that the new function gets accepted, and then look for more places where it could be used. Most likely there are few HWMON drivers also open-coding this functionality. > Andrew > Heiner
diff --git a/drivers/net/phy/aquantia_hwmon.c b/drivers/net/phy/aquantia_hwmon.c index 19c4c280a..d47b3ed16 100644 --- a/drivers/net/phy/aquantia_hwmon.c +++ b/drivers/net/phy/aquantia_hwmon.c @@ -226,20 +226,12 @@ int aqr_hwmon_probe(struct phy_device *phydev) struct device *dev = &phydev->mdio.dev; struct device *hwmon_dev; char *hwmon_name; - int i, j; hwmon_name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL); if (!hwmon_name) return -ENOMEM; - for (i = j = 0; hwmon_name[i]; i++) { - if (isalnum(hwmon_name[i])) { - if (i != j) - hwmon_name[j] = hwmon_name[i]; - j++; - } - } - hwmon_name[j] = '\0'; + strreplace_nonalnum(hwmon_name, 0); hwmon_dev = devm_hwmon_device_register_with_info(dev, hwmon_name, phydev, &aqr_hwmon_chip_info, NULL);
Use new function strreplace_nonalnum to simplify the code. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> --- drivers/net/phy/aquantia_hwmon.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)