Re: New kernel/resource.c

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Tue, 20 Jul 1999 09:56:20 +0200 (MEST)


Linus Torvalds wrote:
> > (1) We need a way how to search for free region to assign to a new
> > device (for example when a new card is inserted or when the BIOS
> > forgets to assign an address to a PCI device).
>
> Yes. Note that this is actually a fairly hard problem, exactly because we
> don't know the requirements for the region, and a complete description of
> the requirements for different things (not just PCI) is hard to do. You
> may have only a subset of the regions being acceptable.

Right.

> I have a version of resource.c that allows you to "walk" the holes, and
> for each hole you encounter the caller itself can determine whether a part
> of that hole would be acceptable. I'll make my pre-6 patch with this
> functionality available..

Linus, the way I'd do this is to pass a function argument to the "find
me a hole" function, that can do "postprocessing".

Like so:

find_resource (struct resource *root,
int start, int len, (int ()(int start, int len)))
^^^^^^^^^
forgive me. I always forget
the syntax of this.

A function "true" should be provided by the resource file (in case all
suggestions are acceptable).

I've been thinking about why I'd want it like this and not like how
you suggested it. The answer is that with your suggestion we'll end up
with the loop-code everywhere where we'd need this. With my suggestion
you'd just call "find_resource", check for error, and get on with
it. Your suggested code would require the caller to encapsulate it in
a loop...

Roger.

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
------ Microsoft SELLS you Windows, Linux GIVES you the whole house ------

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/