OpenCloudOS-Kernel/tools/gpio
Ivo Borisov Shopov 677d85e1a1 tools: gpio: fix -c option of gpio-event-mon
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 62757c32d5 ("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: 62757c32d5 ("tools: gpio: add multi-line monitoring to gpio-event-mon")
Signed-off-by: Ivo Borisov Shopov <ivoshopov@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
[Bartosz: tweak the commit message]
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-01-27 14:05:46 +01:00
..
.gitignore This is the bulk of GPIO development for the v5.7 kernel cycle. 2020-04-04 10:27:00 -07:00
Build tools: gpio: implement gpio-watch 2020-02-12 12:05:47 +01:00
Makefile kbuild: replace $(if A,A,B) with $(or A,B) 2022-02-15 12:25:56 +09:00
gpio-event-mon.c tools: gpio: fix -c option of gpio-event-mon 2023-01-27 14:05:46 +01:00
gpio-hammer.c tools: gpio: port gpio-hammer to v2 uAPI 2020-09-30 10:57:20 +02:00
gpio-utils.c tools: gpio-utils: fix various kernel-doc warnings 2021-03-26 14:56:19 +01:00
gpio-utils.h tools: gpio: remove uAPI v1 code no longer used by selftests 2021-02-15 11:43:28 +01:00
gpio-watch.c tools: gpio: fix %llu warning in gpio-watch.c 2021-01-18 10:05:35 +01:00
lsgpio.c tools: gpio: add support for reporting realtime event clock to lsgpio 2020-12-05 23:22:47 +01:00