* [PATCH v1] power: supply: twl4030_charger: Use sysfs_match_string() helper
@ 2017-06-09 12:07 Andy Shevchenko
2017-06-09 12:27 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2017-06-09 12:07 UTC (permalink / raw)
To: linux-pm; +Cc: Andy Shevchenko, Sebastian Reichel
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>
---
drivers/power/supply/twl4030_charger.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
index 785a07bc4f39..2c2d1f457487 100644
--- a/drivers/power/supply/twl4030_charger.c
+++ b/drivers/power/supply/twl4030_charger.c
@@ -669,14 +669,10 @@ twl4030_bci_mode_store(struct device *dev, struct device_attribute *attr,
int mode;
int status;
- if (sysfs_streq(buf, modes[0]))
- mode = 0;
- else if (sysfs_streq(buf, modes[1]))
- mode = 1;
- else if (sysfs_streq(buf, modes[2]))
- mode = 2;
- else
- return -EINVAL;
+ mode = sysfs_match_string(modes, buf);
+ if (mode < 0)
+ return mode;
+
if (dev == &bci->ac->dev) {
if (mode == 2)
return -EINVAL;
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] power: supply: twl4030_charger: Use sysfs_match_string() helper
2017-06-09 12:07 [PATCH v1] power: supply: twl4030_charger: Use sysfs_match_string() helper Andy Shevchenko
@ 2017-06-09 12:27 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2017-06-09 12:27 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-pm
[-- Attachment #1: Type: text/plain, Size: 2353 bytes --]
Hi,
On Fri, Jun 09, 2017 at 03:07:27PM +0300, Andy Shevchenko wrote:
> 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>
In file included from ./include/linux/bitmap.h:8:0,
from ./include/linux/nodemask.h:94,
from ./include/linux/mmzone.h:16,
from ./include/linux/gfp.h:5,
from ./include/linux/kmod.h:22,
from ./include/linux/module.h:13,
from drivers/power/supply/twl4030_charger.c:16:
drivers/power/supply/twl4030_charger.c: In function ‘twl4030_bci_mode_store’:
drivers/power/supply/twl4030_charger.c:672:28: error: passing argument 1 of ‘__sysfs_match_string’ from incompatible pointer type [-Werror=incompatible-pointer-types]
mode = sysfs_match_string(modes, buf);
^
./include/linux/string.h:155:57: note: in definition of macro ‘sysfs_match_string’
#define sysfs_match_string(_a, _s) __sysfs_match_string(_a, ARRAY_SIZE(_a), _s)
^~
./include/linux/string.h:146:5: note: expected ‘const char * const*’ but argument is of type ‘char **’
int __sysfs_match_string(const char * const *array, size_t n, const char *s);
^~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
-- Sebastian
> ---
> drivers/power/supply/twl4030_charger.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
> index 785a07bc4f39..2c2d1f457487 100644
> --- a/drivers/power/supply/twl4030_charger.c
> +++ b/drivers/power/supply/twl4030_charger.c
> @@ -669,14 +669,10 @@ twl4030_bci_mode_store(struct device *dev, struct device_attribute *attr,
> int mode;
> int status;
>
> - if (sysfs_streq(buf, modes[0]))
> - mode = 0;
> - else if (sysfs_streq(buf, modes[1]))
> - mode = 1;
> - else if (sysfs_streq(buf, modes[2]))
> - mode = 2;
> - else
> - return -EINVAL;
> + mode = sysfs_match_string(modes, buf);
> + if (mode < 0)
> + return mode;
> +
> if (dev == &bci->ac->dev) {
> if (mode == 2)
> return -EINVAL;
> --
> 2.11.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-09 12:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-09 12:07 [PATCH v1] power: supply: twl4030_charger: Use sysfs_match_string() helper Andy Shevchenko
2017-06-09 12:27 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox