All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Eric Miao <eric.y.miao@gmail.com>, Jaya Kumar <jayakumar.lkml@gmail.com>
Cc: linux-fbdev-devel@lists.sourceforge.net,
	Haavard Skinnemoen <hskinnemoen@atmel.com>,
	Greg KH <greg@kroah.com>,
	linux-kernel@vger.kernel.org, Ben Gardner <bgardner@wabtec.com>,
	Paulius Zaleckas <paulius.zaleckas@teltonika.lt>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Philipp Zabel <philipp.zabel@gmail.com>,
	Eric Miao <eric.miao@marvell.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	linux-arm-kernel@lists.arm.linux.org.uk,
	Russell King <rmk@arm.linux.org.uk>
Subject: Re: [RFC 2.6.27 1/1] gpiolib: add batch set/get
Date: Mon, 29 Dec 2008 12:33:38 -0800	[thread overview]
Message-ID: <200812291233.39258.david-b@pacbell.net> (raw)
In-Reply-To: <f17812d70812281938h1b8ad9ecq49a460ac7786ae76@mail.gmail.com>

I'm a bit surprised to see patches against 2.6.27, rather
than a 2.6.28 (or 2.6.28-rc) kernel.  ;)


On Sunday 28 December 2008, Eric Miao wrote:
> > @@ -200,8 +203,12 @@ static void am300_set_hdb(struct broadsheetfb_par *par, u16 data)
> >  {
> >        int i;
> >
> > +#ifdef CONFIG_GPIOLIB_BATCH
> > +       gpio_set_batch(DB0_GPIO_PIN, data, 0xFFFF, 16);
> > +#else
> >        for (i = 0; i <= (DB15_GPIO_PIN - DB0_GPIO_PIN) ; i++)
> >                gpio_set_value(DB0_GPIO_PIN + i, (data >> i) & 0x01);
> > +#endif
> 
> Well, if AM300 selects GPIOLIB_BATCH, I don't think we need the
> gpio_set_value() stuffs, and get rid of this #ifdef completely.

Right ... although we don't *have* a GPIOLIB_BATCH,
so that's not (yet?) an option.


> > @@ -1056,6 +1056,128 @@ void __gpio_set_value(unsigned gpio, int value)
> >  }
> >  EXPORT_SYMBOL_GPL(__gpio_set_value);
> >
> > +#ifdef CONFIG_GPIOLIB_BATCH
> > +/**
> > + * __gpio_set_batch() - assign a batch of gpio pins together
> > + * @gpio: starting gpio pin
> > + * @values: values to assign, sequential and including masked bits
> > + * @bitmask: bitmask to be applied to values
> > + * @bitwidth: width inclusive of masked-off bits
> > + * Context: any
> > + *
> > + * This is used directly or indirectly to implement gpio_set_value().
> > + * It invokes the associated gpio_chip.set_batch() method. If that
> > + * method does not exist for any segment that is involved, then it drops
> > + * back down to standard gpio_chip.set()
> > + */
> > +void __gpio_set_batch(unsigned gpio, u32 values, u32 bitmask, int bitwidth)
> > +{
> > +       struct gpio_chip *chip;
> > +       int i = 0;
> > +       int value, width, remwidth;
> > +       u32 mask;
> > +
> > +       do {
> > +               chip = gpio_to_chip(gpio + i);
> > +               WARN_ON(extra_checks && chip->can_sleep);
> > +
> > +               if (!chip->set_batch) {
> > +                       while (((gpio + i) < (chip->base + chip->ngpio))
> > +                               && bitwidth) {
> > +                               mask = 1 << i;
> > +                               value = values & mask;
> > +                               if (bitmask & mask)
> > +                                       chip->set(chip, gpio + i - chip->base,
> > +                                                       value);
> > +                               i++;
> > +                               bitwidth--;
> 
> I recommend this being put into something like 'default_gpio_set_batch', and
> assign this to 'chip->set_batch' when the gpio chip is being registered and
> found 'chip->set_batch == NULL', so to keep this block consistent.
> 
> Same comment to the 'get_batch' implementation below.

Right ... this is something I had suggested earlier:  make
sure that the (renamed) "batch" interfaces don't depend on
some TBD extension to gpio_chip.

Those extensions should be just an optimization.


------------------------------------------------------------------------------

WARNING: multiple messages have this Message-ID (diff)
From: David Brownell <david-b@pacbell.net>
To: "Eric Miao" <eric.y.miao@gmail.com>,
	"Jaya Kumar" <jayakumar.lkml@gmail.com>
Cc: "Eric Miao" <eric.miao@marvell.com>,
	"Paulius Zaleckas" <paulius.zaleckas@teltonika.lt>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Sam Ravnborg" <sam@ravnborg.org>,
	"Haavard Skinnemoen" <hskinnemoen@atmel.com>,
	"Philipp Zabel" <philipp.zabel@gmail.com>,
	"Russell King" <rmk@arm.linux.org.uk>,
	"Ben Gardner" <bgardner@wabtec.com>, "Greg KH" <greg@kroah.com>,
	linux-arm-kernel@lists.arm.linux.org.uk,
	linux-fbdev-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC 2.6.27 1/1] gpiolib: add batch set/get
Date: Mon, 29 Dec 2008 12:33:38 -0800	[thread overview]
Message-ID: <200812291233.39258.david-b@pacbell.net> (raw)
In-Reply-To: <f17812d70812281938h1b8ad9ecq49a460ac7786ae76@mail.gmail.com>

I'm a bit surprised to see patches against 2.6.27, rather
than a 2.6.28 (or 2.6.28-rc) kernel.  ;)


On Sunday 28 December 2008, Eric Miao wrote:
> > @@ -200,8 +203,12 @@ static void am300_set_hdb(struct broadsheetfb_par *par, u16 data)
> >  {
> >        int i;
> >
> > +#ifdef CONFIG_GPIOLIB_BATCH
> > +       gpio_set_batch(DB0_GPIO_PIN, data, 0xFFFF, 16);
> > +#else
> >        for (i = 0; i <= (DB15_GPIO_PIN - DB0_GPIO_PIN) ; i++)
> >                gpio_set_value(DB0_GPIO_PIN + i, (data >> i) & 0x01);
> > +#endif
> 
> Well, if AM300 selects GPIOLIB_BATCH, I don't think we need the
> gpio_set_value() stuffs, and get rid of this #ifdef completely.

Right ... although we don't *have* a GPIOLIB_BATCH,
so that's not (yet?) an option.


> > @@ -1056,6 +1056,128 @@ void __gpio_set_value(unsigned gpio, int value)
> >  }
> >  EXPORT_SYMBOL_GPL(__gpio_set_value);
> >
> > +#ifdef CONFIG_GPIOLIB_BATCH
> > +/**
> > + * __gpio_set_batch() - assign a batch of gpio pins together
> > + * @gpio: starting gpio pin
> > + * @values: values to assign, sequential and including masked bits
> > + * @bitmask: bitmask to be applied to values
> > + * @bitwidth: width inclusive of masked-off bits
> > + * Context: any
> > + *
> > + * This is used directly or indirectly to implement gpio_set_value().
> > + * It invokes the associated gpio_chip.set_batch() method. If that
> > + * method does not exist for any segment that is involved, then it drops
> > + * back down to standard gpio_chip.set()
> > + */
> > +void __gpio_set_batch(unsigned gpio, u32 values, u32 bitmask, int bitwidth)
> > +{
> > +       struct gpio_chip *chip;
> > +       int i = 0;
> > +       int value, width, remwidth;
> > +       u32 mask;
> > +
> > +       do {
> > +               chip = gpio_to_chip(gpio + i);
> > +               WARN_ON(extra_checks && chip->can_sleep);
> > +
> > +               if (!chip->set_batch) {
> > +                       while (((gpio + i) < (chip->base + chip->ngpio))
> > +                               && bitwidth) {
> > +                               mask = 1 << i;
> > +                               value = values & mask;
> > +                               if (bitmask & mask)
> > +                                       chip->set(chip, gpio + i - chip->base,
> > +                                                       value);
> > +                               i++;
> > +                               bitwidth--;
> 
> I recommend this being put into something like 'default_gpio_set_batch', and
> assign this to 'chip->set_batch' when the gpio chip is being registered and
> found 'chip->set_batch == NULL', so to keep this block consistent.
> 
> Same comment to the 'get_batch' implementation below.

Right ... this is something I had suggested earlier:  make
sure that the (renamed) "batch" interfaces don't depend on
some TBD extension to gpio_chip.

Those extensions should be just an optimization.


  parent reply	other threads:[~2008-12-29 20:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-27 16:24 [RFC 2.6.27 1/1] gpiolib: add batch set/get Jaya Kumar
2008-12-27 16:24 ` Jaya Kumar
2008-12-29  3:38 ` Eric Miao
2008-12-29  4:12   ` Jaya Kumar
2008-12-29 20:33   ` David Brownell [this message]
2008-12-29 20:33     ` David Brownell

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=200812291233.39258.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=bgardner@wabtec.com \
    --cc=eric.miao@marvell.com \
    --cc=eric.y.miao@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=greg@kroah.com \
    --cc=hskinnemoen@atmel.com \
    --cc=jayakumar.lkml@gmail.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulius.zaleckas@teltonika.lt \
    --cc=philipp.zabel@gmail.com \
    --cc=rmk@arm.linux.org.uk \
    --cc=sam@ravnborg.org \
    /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 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.