All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] misc: apds990x: Use sysfs_match_string() helper
@ 2017-06-09 12:07 Andy Shevchenko
  2017-06-10  7:09 ` kbuild test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andy Shevchenko @ 2017-06-09 12:07 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andy Shevchenko, Arnd Bergmann, Greg Kroah-Hartman

Use sysfs_match_string() helper instead of open coded variant.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/misc/apds990x.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c
index c341164edaad..e9298f9d1588 100644
--- a/drivers/misc/apds990x.c
+++ b/drivers/misc/apds990x.c
@@ -856,13 +856,13 @@ static ssize_t apds990x_prox_reporting_mode_store(struct device *dev,
 				  const char *buf, size_t len)
 {
 	struct apds990x_chip *chip =  dev_get_drvdata(dev);
+	int ret;
 
-	if (sysfs_streq(buf, reporting_modes[0]))
-		chip->prox_continuous_mode = 0;
-	else if (sysfs_streq(buf, reporting_modes[1]))
-		chip->prox_continuous_mode = 1;
-	else
-		return -EINVAL;
+	ret = sysfs_match_string(reporting_modes, buf);
+	if (ret < 0)
+		return ret;
+
+	chip->prox_continuous_mode = ret;
 	return len;
 }
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] misc: apds990x: Use sysfs_match_string() helper
  2017-06-09 12:07 [PATCH v1] misc: apds990x: Use sysfs_match_string() helper Andy Shevchenko
@ 2017-06-10  7:09 ` kbuild test robot
  2017-06-10  7:17 ` kbuild test robot
  2017-06-11  7:47 ` Greg Kroah-Hartman
  2 siblings, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2017-06-10  7:09 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: kbuild-all, linux-kernel, Andy Shevchenko, Arnd Bergmann,
	Greg Kroah-Hartman

[-- Attachment #1: Type: text/plain, Size: 3839 bytes --]

Hi Andy,

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on v4.12-rc4 next-20170609]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/misc-apds990x-Use-sysfs_match_string-helper/20170610-131929
config: m68k-allyesconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=m68k 

All warnings (new ones prefixed by >>):

   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//misc/apds990x.c:26:
   drivers//misc/apds990x.c: In function 'apds990x_prox_reporting_mode_store':
>> include/linux/string.h:155:36: warning: passing argument 1 of '__sysfs_match_string' from incompatible pointer type
    #define sysfs_match_string(_a, _s) __sysfs_match_string(_a, ARRAY_SIZE(_a), _s)
                                       ^
>> drivers//misc/apds990x.c:861:8: note: in expansion of macro 'sysfs_match_string'
     ret = sysfs_match_string(reporting_modes, buf);
           ^
   include/linux/string.h:146:5: note: expected 'const char * const*' but argument is of type 'const char (*)[9]'
    int __sysfs_match_string(const char * const *array, size_t n, const char *s);
        ^
--
   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/misc/apds990x.c:26:
   drivers/misc/apds990x.c: In function 'apds990x_prox_reporting_mode_store':
>> include/linux/string.h:155:36: warning: passing argument 1 of '__sysfs_match_string' from incompatible pointer type
    #define sysfs_match_string(_a, _s) __sysfs_match_string(_a, ARRAY_SIZE(_a), _s)
                                       ^
   drivers/misc/apds990x.c:861:8: note: in expansion of macro 'sysfs_match_string'
     ret = sysfs_match_string(reporting_modes, buf);
           ^
   include/linux/string.h:146:5: note: expected 'const char * const*' but argument is of type 'const char (*)[9]'
    int __sysfs_match_string(const char * const *array, size_t n, const char *s);
        ^

vim +/sysfs_match_string +861 drivers//misc/apds990x.c

   845	
   846	static ssize_t apds990x_prox_reporting_mode_show(struct device *dev,
   847					   struct device_attribute *attr, char *buf)
   848	{
   849		struct apds990x_chip *chip =  dev_get_drvdata(dev);
   850		return sprintf(buf, "%s\n",
   851			reporting_modes[!!chip->prox_continuous_mode]);
   852	}
   853	
   854	static ssize_t apds990x_prox_reporting_mode_store(struct device *dev,
   855					  struct device_attribute *attr,
   856					  const char *buf, size_t len)
   857	{
   858		struct apds990x_chip *chip =  dev_get_drvdata(dev);
   859		int ret;
   860	
 > 861		ret = sysfs_match_string(reporting_modes, buf);
   862		if (ret < 0)
   863			return ret;
   864	
   865		chip->prox_continuous_mode = ret;
   866		return len;
   867	}
   868	
   869	static DEVICE_ATTR(prox0_reporting_mode, S_IRUGO | S_IWUSR,

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 41175 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] misc: apds990x: Use sysfs_match_string() helper
  2017-06-09 12:07 [PATCH v1] misc: apds990x: Use sysfs_match_string() helper Andy Shevchenko
  2017-06-10  7:09 ` kbuild test robot
@ 2017-06-10  7:17 ` kbuild test robot
  2017-06-11  7:47 ` Greg Kroah-Hartman
  2 siblings, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2017-06-10  7:17 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: kbuild-all, linux-kernel, Andy Shevchenko, Arnd Bergmann,
	Greg Kroah-Hartman

[-- Attachment #1: Type: text/plain, Size: 2778 bytes --]

Hi Andy,

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v4.12-rc4 next-20170609]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/misc-apds990x-Use-sysfs_match_string-helper/20170610-131929
config: x86_64-rhel (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   In file included from include/linux/bitmap.h:8:0,
                    from include/linux/cpumask.h:11,
                    from arch/x86/include/asm/cpumask.h:4,
                    from arch/x86/include/asm/msr.h:10,
                    from arch/x86/include/asm/processor.h:20,
                    from arch/x86/include/asm/cpufeature.h:4,
                    from arch/x86/include/asm/thread_info.h:52,
                    from include/linux/thread_info.h:37,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:80,
                    from include/linux/spinlock.h:50,
                    from include/linux/seqlock.h:35,
                    from include/linux/time.h:5,
                    from include/linux/stat.h:18,
                    from include/linux/module.h:10,
                    from drivers/misc/apds990x.c:26:
   drivers/misc/apds990x.c: In function 'apds990x_prox_reporting_mode_store':
>> drivers/misc/apds990x.c:861:27: error: passing argument 1 of '__sysfs_match_string' from incompatible pointer type [-Werror=incompatible-pointer-types]
     ret = sysfs_match_string(reporting_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 'const char (*)[9]'
    int __sysfs_match_string(const char * const *array, size_t n, const char *s);
        ^~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/__sysfs_match_string +861 drivers/misc/apds990x.c

   855					  struct device_attribute *attr,
   856					  const char *buf, size_t len)
   857	{
   858		struct apds990x_chip *chip =  dev_get_drvdata(dev);
   859		int ret;
   860	
 > 861		ret = sysfs_match_string(reporting_modes, buf);
   862		if (ret < 0)
   863			return ret;
   864	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 39191 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] misc: apds990x: Use sysfs_match_string() helper
  2017-06-09 12:07 [PATCH v1] misc: apds990x: Use sysfs_match_string() helper Andy Shevchenko
  2017-06-10  7:09 ` kbuild test robot
  2017-06-10  7:17 ` kbuild test robot
@ 2017-06-11  7:47 ` Greg Kroah-Hartman
  2017-06-11  8:57   ` Geert Uytterhoeven
  2 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2017-06-11  7:47 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel, Arnd Bergmann

On Fri, Jun 09, 2017 at 03:07:58PM +0300, Andy Shevchenko wrote:
> Use sysfs_match_string() helper instead of open coded variant.
> 
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/misc/apds990x.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

kbuild is failing :(

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] misc: apds990x: Use sysfs_match_string() helper
  2017-06-11  7:47 ` Greg Kroah-Hartman
@ 2017-06-11  8:57   ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2017-06-11  8:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Andy Shevchenko, linux-kernel@vger.kernel.org, Arnd Bergmann

On Sun, Jun 11, 2017 at 9:47 AM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Fri, Jun 09, 2017 at 03:07:58PM +0300, Andy Shevchenko wrote:
>> Use sysfs_match_string() helper instead of open coded variant.
>>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> ---
>>  drivers/misc/apds990x.c | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> kbuild is failing :(

reporting_modes[] is not an array of string pointers, but an array of
9-byte arrays. Converting it to an array of pointers should fix this.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-06-11  8:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-09 12:07 [PATCH v1] misc: apds990x: Use sysfs_match_string() helper Andy Shevchenko
2017-06-10  7:09 ` kbuild test robot
2017-06-10  7:17 ` kbuild test robot
2017-06-11  7:47 ` Greg Kroah-Hartman
2017-06-11  8:57   ` Geert Uytterhoeven

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.