Re: [PATCH] gpiolib: implement dynamic base allocation

From: Anton Vorontsov
Date: Wed Mar 05 2008 - 20:25:04 EST


On Wed, Mar 05, 2008 at 03:40:57PM -0800, David Brownell wrote:
> On Wednesday 05 March 2008, Andrew Morton wrote:
> > On Tue, 4 Mar 2008 20:03:07 +0300
> > Anton Vorontsov <avorontsov@xxxxxxxxxxxxx> wrote:
> >
> > > If gpio_chip->base is negative during registration, gpiolib requests
> > > dynamic base allocation. This is useful for devices being registered
> > > at run-time (in contrast to platform devices).
> > >
> > > Signed-off-by: Anton Vorontsov <avorontsov@xxxxxxxxxxxxx>
> > > ---
> > > drivers/gpio/gpiolib.c | 42 ++++++++++++++++++++++++++++++++++++------
> > > 1 files changed, 36 insertions(+), 6 deletions(-)
> > >
> >
> > This conflicts in non-trivial ways with gpio-define-gpio_is_valid.patch.
> > Could you please redo and retest against 2.6.25-rc3-mm1?

No problem, will rebase.

> And when you do that, could you make it assign GPIO numbers from
> the biggest number on down, instead of from the smallest on up?
>
> Platforms normally assign those numbers from the bottom up ... so
> dynamic assignment should try to avoid reusing any numbers that may
> have been explicitly assigned, but not yet registered. (Of course,
> if you can come up with a cleaner solution than that, it'd be great.
> Maybe platforms should also be able to mark ranges as "in use" as
> they start up, or something.)

Well, it is also trivial to implement gpiochip_reserve(start, end)
function that will mark reserved gpio->chip as ERR_PTR(-EACCESS),
and these ranges will be unavailable for the dynamic allocation.

Then, platforms could do gpiochip_reserve(0, GPIO_ARCH_END).
I think This is good solution from all and every POV, but this
needs a bit of platform code assistance.

What would you choice?

> And please add a pr_debug level message reporting dynamically
> assigned ranges. That way, when problems crop up it'll be that
> much easier to notice what went wrong.

Will do.

Thanks,

--
Anton Vorontsov
email: cbouatmailru@xxxxxxxxx
irc://irc.freenode.net/bd2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/