Thread (13 messages) 13 messages, 3 authors, 2020-01-07

Re: [PATCH 2/8] gpio: zynq: protect direction in/out with a spinlock

From: Bartosz Golaszewski <hidden>
Date: 2020-01-02 17:40:25
Also in: linux-gpio, lkml

czw., 26 gru 2019 o 13:12 Srinivas Neeli [off-list ref] napisał(a):
quoted hunk ↗ jump to hunk
From: Glenn Langedock <redacted>

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 <redacted>
Signed-off-by: Michal Simek <redacted>
Signed-off-by: Srinivas Neeli <redacted>
---
 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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help