]> git.baikalelectronics.ru Git - kernel.git/commit
gpiolib: rework the locking mechanism for lineevent kfifo
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Wed, 27 Nov 2019 11:19:21 +0000 (12:19 +0100)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Wed, 12 Feb 2020 11:05:47 +0000 (12:05 +0100)
commita7d84ffd984723e800debe4bc0e2b7975a1a9424
treea6cf687b8d2ec038e0c0bd0aabe628a7c9aa7ef3
parent31335406c620c8bea99d8dbd4579b35e90524ef5
gpiolib: rework the locking mechanism for lineevent kfifo

The read_lock mutex is supposed to prevent collisions between reading
and writing to the line event kfifo but it's actually only taken when
the events are being read from it.

Drop the mutex entirely and reuse the spinlock made available to us in
the waitqueue struct. Take the lock whenever the fifo is modified or
inspected. Drop the call to kfifo_to_user() and instead first extract
the new element from kfifo when the lock is taken and only then pass
it on to the user after the spinlock is released.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
drivers/gpio/gpiolib.c