aboutsummaryrefslogtreecommitdiffstats
path: root/tools/gpio/gpio-event-mon.c
Commit message (Collapse)AuthorAgeFilesLines
* tools: gpio: Fix several incorrect format specifiersLuo Yifan2024-11-131-4/+4
| | | | | | | | | | Make a minor change to eliminate static checker warnings. The variable lines[] is unsigned, so the correct format specifier should be %u instead of %d. Signed-off-by: Luo Yifan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
* tools: gpio: fix -c option of gpio-event-monIvo Borisov Shopov2023-01-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Following line should listen for a rising edge and exit after the first one since '-c 1' is provided. # gpio-event-mon -n gpiochip1 -o 0 -r -c 1 It works with kernel 4.19 but it doesn't work with 5.10. In 5.10 the above command doesn't exit after the first rising edge it keep listening for an event forever. The '-c 1' is not taken into an account. The problem is in commit 62757c32d5db ("tools: gpio: add multi-line monitoring to gpio-event-mon"). Before this commit the iterator 'i' in monitor_device() is used for counting of the events (loops). In the case of the above command (-c 1) we should start from 0 and increment 'i' only ones and hit the 'break' statement and exit the process. But after the above commit counting doesn't start from 0, it start from 1 when we listen on one line. It is because 'i' is used from one more purpose, counting of lines (num_lines) and it isn't restore to 0 after following code for (i = 0; i < num_lines; i++) gpiotools_set_bit(&values.mask, i); Restore the initial value of the iterator to 0 in order to allow counting of loops to work for any cases. Fixes: 62757c32d5db ("tools: gpio: add multi-line monitoring to gpio-event-mon") Signed-off-by: Ivo Borisov Shopov <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> [Bartosz: tweak the commit message] Signed-off-by: Bartosz Golaszewski <[email protected]>
* tools: gpio: Add new hardware clock typeDipen Patel2022-05-041-1/+5
| | | | | | | | | gpiolib-cdev is extended to support hardware clock type, this patch reflects that fact. Signed-off-by: Dipen Patel <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
* tools: gpio: fix %llu warning in gpio-event-mon.cKent Gibson2021-01-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | Some platforms, such as mips64, don't map __u64 to long long unsigned int so using %llu produces a warning: gpio-event-mon.c:110:37: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=] 110 | fprintf(stdout, "GPIO EVENT at %llu on line %d (%d|%d) ", | ~~~^ | | | long long unsigned int | %lu 111 | event.timestamp_ns, event.offset, event.line_seqno, | ~~~~~~~~~~~~~~~~~~ | | | __u64 {aka long unsigned int} Replace the %llu with PRIu64 and cast the argument to uint64_t. Fixes: 03fd11b03362 ("tools/gpio/gpio-event-mon: fix warning") Signed-off-by: Kent Gibson <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* tools: gpio: add option to report wall-clock time to gpio-event-monKent Gibson2020-12-051-1/+5
| | | | | | | | Add support for selecting the realtime clock for events. Signed-off-by: Kent Gibson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
* tools: gpio: add debounce support to gpio-event-monKent Gibson2020-09-301-3/+17
| | | | | | | | Add support for debouncing monitored lines to gpio-event-mon. Signed-off-by: Kent Gibson <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* tools: gpio: add multi-line monitoring to gpio-event-monKent Gibson2020-09-301-11/+34
| | | | | | | | | | Extend gpio-event-mon to support monitoring multiple lines. This would require multiple lineevent requests to implement using uAPI v1, but can be performed with a single line request using uAPI v2. Signed-off-by: Kent Gibson <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* tools: gpio: port gpio-event-mon to v2 uAPIKent Gibson2020-09-301-44/+47
| | | | | | | | Port the gpio-event-mon tool to the latest GPIO uAPI. Signed-off-by: Kent Gibson <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* tools: gpio: fix spurious close warning in gpio-event-monKent Gibson2020-07-121-1/+2
| | | | | | | | Fix bogus close warning that occurs when opening the character device fails. Signed-off-by: Kent Gibson <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500Thomas Gleixner2019-06-191-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Based on 2 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation # extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 4122 file(s). Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Enrico Weigelt <[email protected]> Reviewed-by: Kate Stewart <[email protected]> Reviewed-by: Allison Randal <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
* tools/gpio/gpio-event-mon: fix warningAnders Roxell2018-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Tested-by: Daniel Díaz <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* tools/gpio: Fix build error with musl libcJoel Stanley2017-12-211-0/+1
| | | | | | | | | | | | | | | | | | | | | 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: 97f69747d8b1 ("tools/gpio: add the gpio-event-mon tool") Cc: [email protected] Signed-off-by: Joel Stanley <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* tools/gpio: Don't use u_int32_tJonathan Neuschäfer2017-12-201-4/+5
| | | | | | | | 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 <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* tools/gpio: fix gpio-event-mon header commentBaruch Siach2016-08-081-1/+1
| | | | | | Fixes: 97f69747d8b1 ('tools/gpio: add the gpio-event-mon tool') Signed-off-by: Baruch Siach <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* tools/gpio: add the gpio-event-mon toolLinus Walleij2016-06-151-0/+192
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 <[email protected]>