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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux