LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2] selftests/gpio: Fix gpio compiling error
@ 2021-09-03  1:22 Li Zhijian
  2021-09-29  4:17 ` lizhijian
  2021-09-30 22:39 ` Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Li Zhijian @ 2021-09-03  1:22 UTC (permalink / raw)
  To: shuah, linux-gpio, linux-kselftest
  Cc: linux-kernel, Li Zhijian, Philip Li, kernel test robot

[root@iaas-rpma gpio]# make
gcc     gpio-mockup-cdev.c  -o /home/lizhijian/linux/tools/testing/selftests/gpio/gpio-mockup-cdev
gpio-mockup-cdev.c: In function ‘request_line_v2’:
gpio-mockup-cdev.c:24:30: error: storage size of ‘req’ isn’t known
   24 |  struct gpio_v2_line_request req;
      |                              ^~~
gpio-mockup-cdev.c:32:14: error: ‘GPIO_V2_LINE_FLAG_OUTPUT’ undeclared (first use in this function); did you mean ‘GPIOLINE_FLAG_IS_OUT’?
   32 |  if (flags & GPIO_V2_LINE_FLAG_OUTPUT) {
      |              ^~~~~~~~~~~~~~~~~~~~~~~~

gpio-mockup-cdev.c includes <linux/gpio.h> which could be provided by
kernel-headers package, and where it's expected to declare
GPIO_V2_LINE_FLAG_OUTPUT. However distros or developers will not always
install the same kernel-header as we are compiling.

So we can tell compiler to search headers from linux tree simply like others,
such as sched.

CC: Philip Li <philip.li@intel.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>

---
V2: add more details about the fix
---
 tools/testing/selftests/gpio/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
index 39f2bbe8dd3d..42ea7d2aa844 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -3,5 +3,6 @@
 TEST_PROGS := gpio-mockup.sh
 TEST_FILES := gpio-mockup-sysfs.sh
 TEST_GEN_PROGS_EXTENDED := gpio-mockup-cdev
+CFLAGS += -I../../../../usr/include
 
 include ../lib.mk
-- 
2.31.1




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

* Re: [PATCH v2] selftests/gpio: Fix gpio compiling error
  2021-09-03  1:22 [PATCH v2] selftests/gpio: Fix gpio compiling error Li Zhijian
@ 2021-09-29  4:17 ` lizhijian
  2021-09-30 22:39 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: lizhijian @ 2021-09-29  4:17 UTC (permalink / raw)
  To: shuah, linux-gpio, linux-kselftest
  Cc: linux-kernel, Philip Li, kernel test robot, lizhijian

ping


On 03/09/2021 09:22, Li Zhijian wrote:
> [root@iaas-rpma gpio]# make
> gcc     gpio-mockup-cdev.c  -o /home/lizhijian/linux/tools/testing/selftests/gpio/gpio-mockup-cdev
> gpio-mockup-cdev.c: In function ‘request_line_v2’:
> gpio-mockup-cdev.c:24:30: error: storage size of ‘req’ isn’t known
>     24 |  struct gpio_v2_line_request req;
>        |                              ^~~
> gpio-mockup-cdev.c:32:14: error: ‘GPIO_V2_LINE_FLAG_OUTPUT’ undeclared (first use in this function); did you mean ‘GPIOLINE_FLAG_IS_OUT’?
>     32 |  if (flags & GPIO_V2_LINE_FLAG_OUTPUT) {
>        |              ^~~~~~~~~~~~~~~~~~~~~~~~
>
> gpio-mockup-cdev.c includes <linux/gpio.h> which could be provided by
> kernel-headers package, and where it's expected to declare
> GPIO_V2_LINE_FLAG_OUTPUT. However distros or developers will not always
> install the same kernel-header as we are compiling.
>
> So we can tell compiler to search headers from linux tree simply like others,
> such as sched.
>
> CC: Philip Li <philip.li@intel.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
>
> ---
> V2: add more details about the fix
> ---
>   tools/testing/selftests/gpio/Makefile | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
> index 39f2bbe8dd3d..42ea7d2aa844 100644
> --- a/tools/testing/selftests/gpio/Makefile
> +++ b/tools/testing/selftests/gpio/Makefile
> @@ -3,5 +3,6 @@
>   TEST_PROGS := gpio-mockup.sh
>   TEST_FILES := gpio-mockup-sysfs.sh
>   TEST_GEN_PROGS_EXTENDED := gpio-mockup-cdev
> +CFLAGS += -I../../../../usr/include
>   
>   include ../lib.mk

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

* Re: [PATCH v2] selftests/gpio: Fix gpio compiling error
  2021-09-03  1:22 [PATCH v2] selftests/gpio: Fix gpio compiling error Li Zhijian
  2021-09-29  4:17 ` lizhijian
@ 2021-09-30 22:39 ` Linus Walleij
  2021-10-06  0:38   ` Kent Gibson
  1 sibling, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2021-09-30 22:39 UTC (permalink / raw)
  To: Li Zhijian, Bartosz Golaszewski
  Cc: Shuah Khan, open list:GPIO SUBSYSTEM, linux-kselftest,
	linux-kernel, Philip Li, kernel test robot

Hi Li,

thanks for your patch!

It needs to be sent directly to Bartosz Golaszewski so he can apply
it to the GPIO tree.

Thanks!
Linus Walleij

On Fri, Sep 3, 2021 at 3:18 AM Li Zhijian <lizhijian@cn.fujitsu.com> wrote:
>
> [root@iaas-rpma gpio]# make
> gcc     gpio-mockup-cdev.c  -o /home/lizhijian/linux/tools/testing/selftests/gpio/gpio-mockup-cdev
> gpio-mockup-cdev.c: In function ‘request_line_v2’:
> gpio-mockup-cdev.c:24:30: error: storage size of ‘req’ isn’t known
>    24 |  struct gpio_v2_line_request req;
>       |                              ^~~
> gpio-mockup-cdev.c:32:14: error: ‘GPIO_V2_LINE_FLAG_OUTPUT’ undeclared (first use in this function); did you mean ‘GPIOLINE_FLAG_IS_OUT’?
>    32 |  if (flags & GPIO_V2_LINE_FLAG_OUTPUT) {
>       |              ^~~~~~~~~~~~~~~~~~~~~~~~
>
> gpio-mockup-cdev.c includes <linux/gpio.h> which could be provided by
> kernel-headers package, and where it's expected to declare
> GPIO_V2_LINE_FLAG_OUTPUT. However distros or developers will not always
> install the same kernel-header as we are compiling.
>
> So we can tell compiler to search headers from linux tree simply like others,
> such as sched.
>
> CC: Philip Li <philip.li@intel.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
>
> ---
> V2: add more details about the fix
> ---
>  tools/testing/selftests/gpio/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
> index 39f2bbe8dd3d..42ea7d2aa844 100644
> --- a/tools/testing/selftests/gpio/Makefile
> +++ b/tools/testing/selftests/gpio/Makefile
> @@ -3,5 +3,6 @@
>  TEST_PROGS := gpio-mockup.sh
>  TEST_FILES := gpio-mockup-sysfs.sh
>  TEST_GEN_PROGS_EXTENDED := gpio-mockup-cdev
> +CFLAGS += -I../../../../usr/include
>
>  include ../lib.mk
> --
> 2.31.1
>
>
>

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

* Re: [PATCH v2] selftests/gpio: Fix gpio compiling error
  2021-09-30 22:39 ` Linus Walleij
@ 2021-10-06  0:38   ` Kent Gibson
  0 siblings, 0 replies; 4+ messages in thread
From: Kent Gibson @ 2021-10-06  0:38 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Li Zhijian, Bartosz Golaszewski, Shuah Khan,
	open list:GPIO SUBSYSTEM, linux-kselftest, linux-kernel,
	Philip Li, kernel test robot

On Fri, Oct 01, 2021 at 12:39:42AM +0200, Linus Walleij wrote:
> Hi Li,
> 
> thanks for your patch!
> 
> It needs to be sent directly to Bartosz Golaszewski so he can apply
> it to the GPIO tree.
> 
> Thanks!
> Linus Walleij
> 
> On Fri, Sep 3, 2021 at 3:18 AM Li Zhijian <lizhijian@cn.fujitsu.com> wrote:
> >
> > [root@iaas-rpma gpio]# make
> > gcc     gpio-mockup-cdev.c  -o /home/lizhijian/linux/tools/testing/selftests/gpio/gpio-mockup-cdev
> > gpio-mockup-cdev.c: In function ‘request_line_v2’:
> > gpio-mockup-cdev.c:24:30: error: storage size of ‘req’ isn’t known
> >    24 |  struct gpio_v2_line_request req;
> >       |                              ^~~
> > gpio-mockup-cdev.c:32:14: error: ‘GPIO_V2_LINE_FLAG_OUTPUT’ undeclared (first use in this function); did you mean ‘GPIOLINE_FLAG_IS_OUT’?
> >    32 |  if (flags & GPIO_V2_LINE_FLAG_OUTPUT) {
> >       |              ^~~~~~~~~~~~~~~~~~~~~~~~
> >
> > gpio-mockup-cdev.c includes <linux/gpio.h> which could be provided by
> > kernel-headers package, and where it's expected to declare
> > GPIO_V2_LINE_FLAG_OUTPUT. However distros or developers will not always
> > install the same kernel-header as we are compiling.
> >
> > So we can tell compiler to search headers from linux tree simply like others,
> > such as sched.
> >
> > CC: Philip Li <philip.li@intel.com>
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> >
> > ---
> > V2: add more details about the fix
> > ---
> >  tools/testing/selftests/gpio/Makefile | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
> > index 39f2bbe8dd3d..42ea7d2aa844 100644
> > --- a/tools/testing/selftests/gpio/Makefile
> > +++ b/tools/testing/selftests/gpio/Makefile
> > @@ -3,5 +3,6 @@
> >  TEST_PROGS := gpio-mockup.sh
> >  TEST_FILES := gpio-mockup-sysfs.sh
> >  TEST_GEN_PROGS_EXTENDED := gpio-mockup-cdev
> > +CFLAGS += -I../../../../usr/include
> >

While this fixes the bug at hand, I think the root cause is that I
removed all the CFLAGS, assuming they were only relevant for the old
code and that lib.mk set sensible defaults (it doesn't), when in
fact most of it should've been retained, specifically:

CFLAGS += -O2 -g -Wall -I../../../../usr/include/

The -Wall turns up an uninitialised variable warning.
It is a false positive, but should be fixed regardless.

Any problems with me creating a series to do that, with the first patch
fixing the uninitialised variable and the second being this patch,
though with the full CFLAGS restored?

Cheers,
Kent.

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

end of thread, other threads:[~2021-10-06  0:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03  1:22 [PATCH v2] selftests/gpio: Fix gpio compiling error Li Zhijian
2021-09-29  4:17 ` lizhijian
2021-09-30 22:39 ` Linus Walleij
2021-10-06  0:38   ` Kent Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).