power: supply: twl4030_charger: Use sysfs_match_string() helper
Use sysfs_match_string() helper instead of open coded variant. Cc: Sebastian Reichel <sre@kernel.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>hifive-unleashed-5.1
parent
153e9e90ff
commit
37853952b9
|
@ -153,7 +153,7 @@ struct twl4030_bci {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* strings for 'usb_mode' values */
|
/* strings for 'usb_mode' values */
|
||||||
static char *modes[] = { "off", "auto", "continuous" };
|
static const char *modes[] = { "off", "auto", "continuous" };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* clear and set bits on an given register on a given module
|
* clear and set bits on an given register on a given module
|
||||||
|
@ -669,14 +669,10 @@ twl4030_bci_mode_store(struct device *dev, struct device_attribute *attr,
|
||||||
int mode;
|
int mode;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
if (sysfs_streq(buf, modes[0]))
|
mode = sysfs_match_string(modes, buf);
|
||||||
mode = 0;
|
if (mode < 0)
|
||||||
else if (sysfs_streq(buf, modes[1]))
|
return mode;
|
||||||
mode = 1;
|
|
||||||
else if (sysfs_streq(buf, modes[2]))
|
|
||||||
mode = 2;
|
|
||||||
else
|
|
||||||
return -EINVAL;
|
|
||||||
if (dev == &bci->ac->dev) {
|
if (dev == &bci->ac->dev) {
|
||||||
if (mode == 2)
|
if (mode == 2)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
Loading…
Reference in New Issue