pinctrl: pinctrl-adi2: GPIO output value should be set after the GPIO interrupt is disabled.
PATCH 1/1 pinctrl: pinctrl-adi2: GPIO output value should be set after the GPIO interrupt is disabled.
From: Sonic Zhang <[email protected]>
Use BIT macro as well.
--- drivers/pinctrl/pinctrl-adi2.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/pinctrl/pinctrl-adi2.c +8 -6
@@ -766,9 +766,9 @@ static void adi_gpio_set_value(struct gpio_chip *chip, unsigned offset,spin_lock_irqsave (&port->lock, flags);if (value) -writew (1 << offset, ®s->data_set); +writew (BIT (offset), ®s->data_set);else -writew (1 << offset, ®s->data_clear); +writew (BIT (offset), ®s->data_clear);spin_unlock_irqrestore (&port->lock, flags); }
@@ -780,12 +780,14 @@ static int adi_gpio_direction_output(struct gpio_chip *chip, unsigned offset,struct gpio_port_t *regs = port->regs;unsigned long flags; -adi_gpio_set_value (chip, offset, value); -spin_lock_irqsave (&port->lock, flags); -writew (readw (®s->inen) & ~(1 << offset), ®s->inen); -writew (1 << offset, ®s->dir_set); +writew (readw (®s->inen) & ~BIT (offset), ®s->inen); +if (value) +writew (BIT (offset), ®s->data_set); +else +writew (BIT (offset), ®s->data_clear); +writew (BIT (offset), ®s->dir_set);spin_unlock_irqrestore (&port->lock, flags);
Signature · 1 line
1.8.2.3
2013/10/8 Sonic Zhang <[email protected]>:
Quoted 30 lines
From: Sonic Zhang <[email protected]>
Use BIT macro as well.
Signed-off-by Sonic Zhang <[email protected]>--- drivers/pinctrl/pinctrl-adi2.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/pinctrl/pinctrl-adi2.c +2
-3@@ -766,9 +766,9 @@ static void adi_gpio_set_value(struct gpio_chip *chip, unsigned offset,spin_lock_irqsave (&port->lock, flags);if (value) -writew (1 << offset, ®s->data_set); +writew (BIT (offset), ®s->data_set);else -writew (1 << offset, ®s->data_clear); +writew (BIT (offset), ®s->data_clear);spin_unlock_irqrestore (&port->lock, flags); }@@ -780,12 +780,14 @@ static int adi_gpio_direction_output(struct gpio_chip *chip, unsigned offset,struct gpio_port_t *regs = port->regs;unsigned long flags; -adi_gpio_set_value (chip, offset, value);
drivers/pinctrl/pinctrl-adi2.c static int adi_gpio_direction_output(struct gpio_chip *chip, unsigned offset, · line 789
Quoted 10 lines
drivers/pinctrl/pinctrl-adi2.c +5
-3-spin_lock_irqsave (&port->lock, flags); -writew (readw (®s->inen) & ~(1 << offset), ®s->inen); -writew (1 << offset, ®s->dir_set); +writew (readw (®s->inen) & ~BIT (offset), ®s->inen); +if (value) +writew (BIT (offset), ®s->data_set); +else +writew (BIT (offset), ®s->data_clear);
I think we can add an unlocked version of adi_gpio_set_value() to avoid duplicated code.
Hi Axel,
Quoted 34 lines · Axel Lin
2013/10/8 Sonic Zhang <[email protected]>:
Quoted 33 lines
From: Sonic Zhang <[email protected]>
Use BIT macro as well.
Signed-off-by Sonic Zhang <[email protected]>--- drivers/pinctrl/pinctrl-adi2.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/pinctrl/pinctrl-adi2.c +2
-4@@ -766,9 +766,9 @@ static void adi_gpio_set_value(struct gpio_chip *chip, unsigned offset,spin_lock_irqsave (&port->lock, flags);if (value) -writew (1 << offset, ®s->data_set); +writew (BIT (offset), ®s->data_set);else -writew (1 << offset, ®s->data_clear); +writew (BIT (offset), ®s->data_clear);spin_unlock_irqrestore (&port->lock, flags); }@@ -780,12 +780,14 @@ static int adi_gpio_direction_output(struct gpio_chip *chip, unsigned offset,struct gpio_port_t *regs = port->regs;unsigned long flags; -adi_gpio_set_value (chip, offset, value); -spin_lock_irqsave (&port->lock, flags);
Quoted 10 lines
drivers/pinctrl/pinctrl-adi2.c static int adi_gpio_direction_output(struct gpio_chip *chip, unsigned offset, · line 789
Quoted 7 lines
drivers/pinctrl/pinctrl-adi2.c +5
-2-writew (readw (®s->inen) & ~(1 << offset), ®s->inen); -writew (1 << offset, ®s->dir_set); +writew (readw (®s->inen) & ~BIT (offset), ®s->inen); +if (value) +writew (BIT (offset), ®s->data_set); +else +writew (BIT (offset), ®s->data_clear);I think we can add an unlocked version of
adi_gpio_set_value()to avoid duplicated code.
That may be over engineering for such a simple code.
Regards,
Sonic
Quoted 5 lines · Sonic Zhang
From: Sonic Zhang <[email protected]>
Use BIT macro as well.
Signed-off-by Sonic Zhang <[email protected]>
Patch applied.
Yours,
Linus Walleij