All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: pinctrl-adi2: GPIO output value should be set after the GPIO interrupt is disabled.
@ 2013-10-08  7:31 Sonic Zhang
  2013-10-08  7:48 ` Axel Lin
  2013-10-09 11:09 ` Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Sonic Zhang @ 2013-10-08  7:31 UTC (permalink / raw)
  To: Linus Walleij, Axel Lin; +Cc: LKML, adi-buildroot-devel, Sonic Zhang

From: Sonic Zhang <sonic.zhang@analog.com>

Use BIT macro as well.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 drivers/pinctrl/pinctrl-adi2.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-adi2.c b/drivers/pinctrl/pinctrl-adi2.c
index a74e6f4..7a39562 100644
--- a/drivers/pinctrl/pinctrl-adi2.c
+++ b/drivers/pinctrl/pinctrl-adi2.c
@@ -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, &regs->data_set);
+		writew(BIT(offset), &regs->data_set);
 	else
-		writew(1 << offset, &regs->data_clear);
+		writew(BIT(offset), &regs->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(&regs->inen) & ~(1 << offset), &regs->inen);
-	writew(1 << offset, &regs->dir_set);
+	writew(readw(&regs->inen) & ~BIT(offset), &regs->inen);
+	if (value)
+		writew(BIT(offset), &regs->data_set);
+	else
+		writew(BIT(offset), &regs->data_clear);
+	writew(BIT(offset), &regs->dir_set);
 
 	spin_unlock_irqrestore(&port->lock, flags);
 
-- 
1.8.2.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] pinctrl: pinctrl-adi2: GPIO output value should be set after the GPIO interrupt is disabled.
  2013-10-08  7:31 [PATCH] pinctrl: pinctrl-adi2: GPIO output value should be set after the GPIO interrupt is disabled Sonic Zhang
@ 2013-10-08  7:48 ` Axel Lin
  2013-10-08  7:59   ` Sonic Zhang
  2013-10-09 11:09 ` Linus Walleij
  1 sibling, 1 reply; 4+ messages in thread
From: Axel Lin @ 2013-10-08  7:48 UTC (permalink / raw)
  To: Sonic Zhang; +Cc: Linus Walleij, LKML, adi-buildroot-devel, Sonic Zhang

2013/10/8 Sonic Zhang <sonic.adi@gmail.com>:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> Use BIT macro as well.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> ---
>  drivers/pinctrl/pinctrl-adi2.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-adi2.c b/drivers/pinctrl/pinctrl-adi2.c
> index a74e6f4..7a39562 100644
> --- a/drivers/pinctrl/pinctrl-adi2.c
> +++ b/drivers/pinctrl/pinctrl-adi2.c
> @@ -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, &regs->data_set);
> +               writew(BIT(offset), &regs->data_set);
>         else
> -               writew(1 << offset, &regs->data_clear);
> +               writew(BIT(offset), &regs->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(&regs->inen) & ~(1 << offset), &regs->inen);
> -       writew(1 << offset, &regs->dir_set);
> +       writew(readw(&regs->inen) & ~BIT(offset), &regs->inen);
> +       if (value)
> +               writew(BIT(offset), &regs->data_set);
> +       else
> +               writew(BIT(offset), &regs->data_clear);

I think we can add an unlocked version of adi_gpio_set_value() to
avoid duplicated code.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pinctrl: pinctrl-adi2: GPIO output value should be set after the GPIO interrupt is disabled.
  2013-10-08  7:48 ` Axel Lin
@ 2013-10-08  7:59   ` Sonic Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: Sonic Zhang @ 2013-10-08  7:59 UTC (permalink / raw)
  To: Axel Lin; +Cc: Linus Walleij, LKML, adi-buildroot-devel, Sonic Zhang

Hi Axel,

On Tue, Oct 8, 2013 at 3:48 PM, Axel Lin <axel.lin@ingics.com> wrote:
> 2013/10/8 Sonic Zhang <sonic.adi@gmail.com>:
>> From: Sonic Zhang <sonic.zhang@analog.com>
>>
>> Use BIT macro as well.
>>
>> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
>> ---
>>  drivers/pinctrl/pinctrl-adi2.c | 14 ++++++++------
>>  1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/pinctrl/pinctrl-adi2.c b/drivers/pinctrl/pinctrl-adi2.c
>> index a74e6f4..7a39562 100644
>> --- a/drivers/pinctrl/pinctrl-adi2.c
>> +++ b/drivers/pinctrl/pinctrl-adi2.c
>> @@ -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, &regs->data_set);
>> +               writew(BIT(offset), &regs->data_set);
>>         else
>> -               writew(1 << offset, &regs->data_clear);
>> +               writew(BIT(offset), &regs->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(&regs->inen) & ~(1 << offset), &regs->inen);
>> -       writew(1 << offset, &regs->dir_set);
>> +       writew(readw(&regs->inen) & ~BIT(offset), &regs->inen);
>> +       if (value)
>> +               writew(BIT(offset), &regs->data_set);
>> +       else
>> +               writew(BIT(offset), &regs->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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pinctrl: pinctrl-adi2: GPIO output value should be set after the GPIO interrupt is disabled.
  2013-10-08  7:31 [PATCH] pinctrl: pinctrl-adi2: GPIO output value should be set after the GPIO interrupt is disabled Sonic Zhang
  2013-10-08  7:48 ` Axel Lin
@ 2013-10-09 11:09 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2013-10-09 11:09 UTC (permalink / raw)
  To: Sonic Zhang; +Cc: Axel Lin, LKML, adi-buildroot-devel, Sonic Zhang

On Tue, Oct 8, 2013 at 9:31 AM, Sonic Zhang <sonic.adi@gmail.com> wrote:

> From: Sonic Zhang <sonic.zhang@analog.com>
>
> Use BIT macro as well.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>

Patch applied.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-09 11:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-08  7:31 [PATCH] pinctrl: pinctrl-adi2: GPIO output value should be set after the GPIO interrupt is disabled Sonic Zhang
2013-10-08  7:48 ` Axel Lin
2013-10-08  7:59   ` Sonic Zhang
2013-10-09 11:09 ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.