Commit Graph

5 Commits

Author SHA1 Message Date
Anders Roxell 03fd11b033 tools/gpio/gpio-event-mon: fix warning
PRIu64 is defined in user space to match libc's uint64_t definition.
However, gpioevent_data structure in the kernel is defined using the
kernel's own __u64 type.

gpio-event-mon.c: In function ‘monitor_device’:
gpio-event-mon.c:102:19: warning: format ‘%lu’ expects argument of type
    ‘long unsigned int’, but argument 3 has type ‘__u64 {aka long long
    unsigned int}’ [-Wformat=]
   fprintf(stdout, "GPIO EVENT %" PRIu64 ": ", event.timestamp);
                   ^~~~~~~~~~~~~~
  LD       /tmp/kselftest/gpiogpio-event-mon-in.o
  LINK     /tmp/kselftest/gpiogpio-event-mon

Fix is to replace PRIu64 with llu, which we know is what the kernel uses
for __u64.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Tested-by: Daniel Díaz <daniel.diaz@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-03-01 15:26:58 +01:00
Joel Stanley 1696784eb7 tools/gpio: Fix build error with musl libc
The GPIO tools build fails when using a buildroot toolchain that uses musl
as it's C library:

arm-broomstick-linux-musleabi-gcc -Wp,-MD,./.gpio-event-mon.o.d \
 -Wp,-MT,gpio-event-mon.o -O2 -Wall -g -D_GNU_SOURCE \
 -Iinclude -D"BUILD_STR(s)=#s" -c -o gpio-event-mon.o gpio-event-mon.c
gpio-event-mon.c:30:6: error: unknown type name ‘u_int32_t’; did you mean ‘uint32_t’?
      u_int32_t handleflags,
      ^~~~~~~~~
      uint32_t

The glibc headers installed on my laptop include sys/types.h in
unistd.h, but it appears that musl does not.

Fixes: 97f69747d8 ("tools/gpio: add the gpio-event-mon tool")
Cc: stable@vger.kernel.org
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-21 13:51:01 +01:00
Jonathan Neuschäfer 92e70b83c0 tools/gpio: Don't use u_int32_t
u_int32_t is a non-standard version of uint32_t, that was apparently
introduced by BSD. Use uint32_t from stdint.h instead.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-20 10:36:30 +01:00
Baruch Siach 925baf394b tools/gpio: fix gpio-event-mon header comment
Fixes: 97f69747d8 ('tools/gpio: add the gpio-event-mon tool')
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-08-08 09:50:22 +02:00
Linus Walleij 97f69747d8 tools/gpio: add the gpio-event-mon tool
The gpio-event-mon is used from userspace as an example of how
to monitor GPIO line events. It will latch on to a certain
GPIO line on a certain gpiochip and print timestamped events
as they arrive.

Example output:
$ gpio-event-mon -n gpiochip2 -o 0 -r -f
Monitoring line 0 on gpiochip2
Initial line value: 1
GPIO EVENT 946685798487609863: falling edge
GPIO EVENT 946685798732482910: rising edge
GPIO EVENT 946685799115997314: falling edge
GPIO EVENT 946685799381469726: rising edge

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-06-15 09:29:29 +02:00