czw., 26 gru 2019 o 13:12 Srinivas Neeli <srinivas.neeli@xxxxxxxxxx> napisał(a): > > From: Glenn Langedock <Glenn.Langedock@xxxxxxxxx> > > 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@xxxxxxxxx> > Signed-off-by: Michal Simek <michal.simek@xxxxxxxxxx> > Signed-off-by: Srinivas Neeli <srinivas.neeli@xxxxxxxxxx> > --- > 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