linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Stein <alexanders83@web.de>
To: Ludovic Desroches <ludovic.desroches@atmel.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org
Subject: Re: Re: [PATCH 1/2] pinctrl: at91: Add set_multiple GPIO chip feature
Date: Fri, 27 Mar 2015 12:54:23 +0100	[thread overview]
Message-ID: <4728260.M5jZylgLPj@kongar> (raw)
In-Reply-To: <20150327101152.GB16851@odux.rfo.atmel.com>

Hello Ludovic,

On Friday 27 March 2015, 11:11:52 wrote Ludovic Desroches:
> On Fri, Mar 20, 2015 at 08:12:00PM +0100, Alexander Stein wrote:
> > This adds the callback for set_multiple.
> > As this controller has a separate set and clear register, we can't write
> > directly to PIO_ODSR as this would required a cached variable and would
> > race with at91_gpio_set.
> > So build masks for the PIO_SODR and PIO_CODR registers and write them
> > together.
> 
> Sure seems safer and easier to use SODR and CODR.
> 
> > 
> > Signed-off-by: Alexander Stein <alexanders83@web.de>
> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> A question below.
> 
> > ---
> > This was tested by using an own test driver which uses
> > gpiod_set_array_cansleep to set multiple GPIOs at once.
> > 
> >  drivers/pinctrl/pinctrl-at91.c | 28 ++++++++++++++++++++++++++++
> >  1 file changed, 28 insertions(+)
> > 
> > diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> > index f4cd0b9..a882523 100644
> > --- a/drivers/pinctrl/pinctrl-at91.c
> > +++ b/drivers/pinctrl/pinctrl-at91.c
> > @@ -1330,6 +1330,33 @@ static void at91_gpio_set(struct gpio_chip *chip, unsigned offset,
> >  	writel_relaxed(mask, pio + (val ? PIO_SODR : PIO_CODR));
> >  }
> >  
> > +static void at91_gpio_set_multiple(struct gpio_chip *chip,
> > +				      unsigned long *mask, unsigned long *bits)
> > +{
> > +	struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
> > +	void __iomem *pio = at91_gpio->regbase;
> > +	unsigned long set_mask;
> > +	unsigned long clear_mask;
> > +	size_t i;
> > +
> > +	set_mask = 0;
> > +	clear_mask = 0;
> > +
> > +	for (i = 0; i < chip->ngpio; i++) {
> > +		if (*mask == 0)
> > +			break;
> > +		if (__test_and_clear_bit(i, mask)) {
> 
> For my knowledge, why do you need to clear the mask?

I tried to do the same as mpc8xxx_gpio_set_multiple. I think the reason is that an empty mask will quit that loop potentially earlier.

Best regards,
Alexander


  reply	other threads:[~2015-03-27 11:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20 19:12 [PATCH 1/2] pinctrl: at91: Add set_multiple GPIO chip feature Alexander Stein
2015-03-20 19:12 ` [PATCH 2/2] pinctrl: at91: Add missing include Alexander Stein
2015-04-02  8:19   ` Jean-Christophe PLAGNIOL-VILLARD
2015-04-02  9:39     ` Alexander Stein
2015-03-27  9:07 ` [PATCH 1/2] pinctrl: at91: Add set_multiple GPIO chip feature Linus Walleij
2015-04-01  7:45   ` Jean-Christophe PLAGNIOL-VILLARD
2015-03-27 10:11 ` Ludovic Desroches
2015-03-27 11:54   ` Alexander Stein [this message]
2015-04-02  8:30 ` Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4728260.M5jZylgLPj@kongar \
    --to=alexanders83@web.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=ludovic.desroches@atmel.com \
    --cc=plagnioj@jcrosoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).