• Romain Izard's avatar
    power: supply: register HWMON devices with valid names · f1b937cc
    Romain Izard authored
    With the introduction of the HWMON compatibility layer to the power
    supply framework in Linux 5.3, all power supply devices' names can be
    used directly to create HWMON devices with the same names.
    
    But HWMON has rules on allowable names that are different from those
    used in the power supply framework. The dash character is forbidden, as
    it is used by the libsensors library in userspace as a separator,
    whereas this character is used in the device names in more than half of
    the existing power supply drivers. This last case is consistent with the
    typical naming usage with MFD and Device Tree.
    
    This leads to warnings in the kernel log, with the format:
    
    power_supply gpio-charger: hwmon: \
    	'gpio-charger' is not a valid name attribute, please fix
    
    Add a protection to power_supply_add_hwmon_sysfs() that replaces any
    dash in the device name with an underscore when registering with the
    HWMON framework. Other forbidden characters (star, slash, space, tab,
    newline) are not replaced, as they are not in common use.
    
    Fixes: e67d4dfc ("power: supply: Add HWMON compatibility layer")
    Signed-off-by: default avatarRomain Izard <romain.izard.pro@gmail.com>
    Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
    Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
    f1b937cc
power_supply_hwmon.c 8.31 KB