lkml.org 
[lkml]   [2020]   [Jan]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 2/8] gpio: zynq: protect direction in/out with a spinlock
czw., 26 gru 2019 o 13:12 Srinivas Neeli <srinivas.neeli@xilinx.com> napisał(a):
>
> From: Glenn Langedock <Glenn.Langedock@barco.com>
>
> Fix race condition when changing the direction (in/out) of the GPIO pin.
> The read-modify-write sequence (as coded in the driver) isn't atomic and
> requires synchronization (spinlock).
>
> Signed-off-by: Glenn Langedock <Glenn.Langedock@barco.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
> ---
> drivers/gpio/gpio-zynq.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index 05ba16fffdad..9c8b8a397a26 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -10,6 +10,7 @@
> #include <linux/gpio/driver.h>
> #include <linux/init.h>
> #include <linux/interrupt.h>
> +#include <linux/spinlock.h>
> #include <linux/io.h>
> #include <linux/module.h>
> #include <linux/platform_device.h>
> @@ -116,6 +117,7 @@ struct gpio_regs {
> * @irq: interrupt for the GPIO device
> * @p_data: pointer to platform data
> * @context: context registers
> + * @dirlock: lock used for direction in/out synchronization
> */
> struct zynq_gpio {
> struct gpio_chip chip;
> @@ -124,6 +126,7 @@ struct zynq_gpio {
> int irq;
> const struct zynq_platform_data *p_data;
> struct gpio_regs context;
> + spinlock_t dirlock; /*lock used for direction in/out synchronization */

Maybe just call it 'lock' in case it turns out other operations need
locking as well?

Bart

\
 
 \ /
  Last update: 2020-01-02 18:41    [W:0.072 / U:0.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site