Re: [patch 22/53] PNP: factor pnp_init_resource_table() and pnp_clean_resource_table()

Bjorn Helgaas
2008-04-19T04:02:59Z

On Friday 18 April 2008 4:29:15 pm Rene Herman wrote:
> On 18-04-08 22:50, Bjorn Helgaas wrote:
> > Move the common part of pnp_init_resource_table() and
> > pnp_clean_resource_table() into a new pnp_init_resource().
> > This reduces a little code duplication and will be
> > useful later to initialize an individual resource.
>
> This can't be right, can it? :
> > +void pnp_init_resource(struct resource *res)
> > +{
> > + unsigned long type;
> > +
> > + type = res->flags & (IORESOURCE_IO | IORESOURCE_MEM |
> > + IORESOURCE_IRQ | IORESOURCE_DMA);
> > +
> > + res->name = NULL;
> > + res->flags = type | IORESOURCE_AUTO | IORESOURCE_UNSET;
> > + if (type == IORESOURCE_IRQ || type == IORESOURCE_DMA) {
> > + res->start = -1;
> > + res->end = -1;
> > + } else {
> > + res->start = 0;
> > + res->end = 0;
> > + }
> > +}
>
> This depends on the type already being set in res->flags, yet:

Yep, you're right. I fixed it, but it requires changes to a couple
other patches down the line, so I'll wait to repost the series until
next week in case you find more problems.

I think this is only a problem for bisection. By the time you
apply the whole series, we start with an empty resource list, and
every time we add one, we set the type in pnp_new_resource().

That makes me wonder whether pnp_init_resources() should just
free the whole list, so we just start again with an empty list.

Bjorn