[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMpxmJUWW6Ku7edG1WWz67sBiAj7Fxf_C=XWA3eNO=B75X7oOw@mail.gmail.com>
Date: Thu, 2 Jan 2020 18:40:12 +0100
From: Bartosz Golaszewski <bgolaszewski@...libre.com>
To: Srinivas Neeli <srinivas.neeli@...inx.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Michal Simek <michal.simek@...inx.com>,
shubhrajyoti.datta@...inx.com,
linux-gpio <linux-gpio@...r.kernel.org>,
arm-soc <linux-arm-kernel@...ts.infradead.org>,
LKML <linux-kernel@...r.kernel.org>, git@...inx.com
Subject: Re: [PATCH 2/8] gpio: zynq: protect direction in/out with a spinlock
czw., 26 gru 2019 o 13:12 Srinivas Neeli <srinivas.neeli@...inx.com> napisaĆ(a):
>
> From: Glenn Langedock <Glenn.Langedock@...co.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@...co.com>
> Signed-off-by: Michal Simek <michal.simek@...inx.com>
> Signed-off-by: Srinivas Neeli <srinivas.neeli@...inx.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
Powered by blists - more mailing lists