From: Jaya Kumar <jayakumar.lkml@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: David Brownell <david-b@pacbell.net>,
Eric Miao <eric.miao@marvell.com>,
Paulius Zaleckas <paulius.zaleckas@teltonika.lt>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Sam Ravnborg <sam@ravnborg.org>,
linux-arm-kernel@lists.arm.linux.org.uk,
linux-fbdev-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, linux-embedded@vger.kernel.org
Subject: Re: [RFC 2.6.28 1/2] gpiolib: add set/get batch v4
Date: Mon, 19 Jan 2009 22:19:40 +0800 [thread overview]
Message-ID: <45a44e480901190619i18749c75jaa2d4606da251921@mail.gmail.com> (raw)
In-Reply-To: <20090119100342.GA16400@pengutronix.de>
On Mon, Jan 19, 2009 at 6:03 PM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> Hi Jaya,
>
> On Sat, Jan 17, 2009 at 05:57:17PM +0800, Jaya Kumar wrote:
>> Hi friends,
>>
>> This is v4 of batch support for gpiolib. Thanks to David Brownell, Eric Miao,
>> David Hylands, Robin, Ben, Jamie and others for prior feedback. The post for
>> v3 summarized the previous discussion. Since then the changes I've made are:
>> - split the patches into generic and arch specific
> IMHO this should be three patches: "gpiolib", "pxa" and "am300epd".
> Well, ...
Hi Uwe,
Ok, will do.
>
>> +[OPTIONAL] Spinlock-Safe GPIO Batch access
> Is it really spinlock safe in general? Or only if gpio_cansleep(gpio)
> if false for each gpio to get or set?
You are correct to raise this issue. It is only spinlock safe if
chip->cansleep is false. Initially, I wasn't sure what to do. The
original gpio set/get_value() just does;
WARN_ON(extra_checks && chip->can_sleep);
and it is documented as:
"
Spinlock-Safe GPIO access
-------------------------
<snip>
return zero. Also, using these calls for GPIOs that can't safely be accessed
without sleeping (see below) is an error.
"
I will change this in the batch code to return an error if can_sleep
is detected on any involved gpio_chip.
>
>> +static int __generic_gpio_set_batch(struct gpio_chip *chip, unsigned offset,
>> + u32 values, u32 bitmask, int width)
> IMHO a better name is __gpio_set_batch_generic (or
> __gpiolib_set_batch_generic?), YMMV.
Agreed. Will change.
>
>> +int __gpio_set_batch(unsigned gpio, u32 values, u32 bitmask, int bitwidth)
> Sometimes your width parameter is called bitwidth, sometimes width. I'd
> like to have that consistant.
Ok, you're right. I'll fix this.
>
> While talking about this parameter. I don't really like it, because you
> can calculate it from bitmask. In an earlier mail you write:
Agreed.
>
> bitwidth (needed to iterate and map to chip ngpios) could be
> calculated from bitmask, but that involves iteratively counting
> bits from the mask, so we would have to do 800*600 bit counts.
> Unless, we do ugly things like cache the previous bitwidth/mask
> and compare against the current caller arguments. Given that the
> bitwidth would typically be a fixed value, I believe it is more
> intuitive for the caller to provide it, ...
>
> I think it's easier than that. bitwidth is just fls(bitmask) which
> should be efficient enough not to bother the programmer. If bitmask is
> constant it's even the compiler that does the work here.
>
That is a good point. I agree that width is ugly in the main API. It
is just fls(mask) and I now realize that this is an inline so you're
right it would get taken care of by the compiler. fls is checked with
__constant_fls first. Beauty! Thanks Uwe! I'll make these changes.
Thanks,
jaya
next prev parent reply other threads:[~2009-01-19 14:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-17 9:57 [RFC 2.6.28 1/2] gpiolib: add set/get batch v4 Jaya Kumar
2009-01-17 9:57 ` [RFC 2.6.28 2/2] mach-pxa: add and use batch set/get gpio Jaya Kumar
2009-01-18 20:05 ` [RFC 2.6.28 1/2] gpiolib: add set/get batch v4 Ryan Mallon
2009-01-18 23:46 ` Jaya Kumar
2009-01-18 23:48 ` Jaya Kumar
2009-01-19 0:15 ` Ryan Mallon
2009-01-19 10:03 ` Uwe Kleine-König
2009-01-19 14:19 ` Jaya Kumar [this message]
2009-01-19 17:25 ` Uwe Kleine-König
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=45a44e480901190619i18749c75jaa2d4606da251921@mail.gmail.com \
--to=jayakumar.lkml@gmail.com \
--cc=david-b@pacbell.net \
--cc=eric.miao@marvell.com \
--cc=geert@linux-m68k.org \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-embedded@vger.kernel.org \
--cc=linux-fbdev-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=paulius.zaleckas@teltonika.lt \
--cc=sam@ravnborg.org \
--cc=u.kleine-koenig@pengutronix.de \
/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).