staging: axis-fifo: replace spinlock with mutex
authorQuentin Deslandes <quentin.deslandes@itdev.co.uk>
Tue, 21 Jan 2020 10:40:24 +0000 (10:40 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Jan 2020 08:58:01 +0000 (09:58 +0100)
commit0443b3f4436321e1098fdf74432c8867016339da
tree805eded80a44606f661ffe8b4ec57ef3c0097754
parentb17028d289d37e828a66a6cfd614cd4723334ace
staging: axis-fifo: replace spinlock with mutex

Following the device's documentation guidance, reading a packet from the
device or writing a packet to it must be atomic. Previously, only
reading device's vacancy (before writing on it) or occupancy (before
reading from it) was locked. Hence, effectively reading the packet or
writing the packet wasn't locked at all. However, reading a packet (and
writing one, to a lesser extent) requires to read 3 different registers
in a specific order, without missing one or else we should reset the
device.

This patch fixes the device's locking mechanism on the FIFO character
device. As the device was using copy_from_user() and copy_to_user(), we
need to replace spinlocks with mutexes.

Signed-off-by: Quentin Deslandes <quentin.deslandes@itdev.co.uk>
Link: https://lore.kernel.org/r/20200121103958.12941-1-quentin.deslandes@itdev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/axis-fifo/axis-fifo.c