[SeaBIOS] [PATCH v3 1/6] pci: add two-pass pci initialization code

Kevin O'Connor kevin at koconnor.net
Fri Jul 8 01:44:20 CEST 2011


On Thu, Jul 07, 2011 at 07:14:11PM +0300, Michael S. Tsirkin wrote:
> > +static u32 pci_size_roundup(u32 size)
> > +{
> > +    int index = __fls(size);
> > +    return 1 << index;
> > +}
> > +
> 
> This actually gives a bigger value than
> necessary if the input is a power of 2 already.

A roundup should look like:  1 << (__fls(size - 1) + 1)  Assuming size
is never less than 2.

[...]
> > +static void pci_bios_check_device(struct pci_bus *bus, struct pci_device *dev)
> > +{
> > +    u16 bdf = dev->bdf;
> > +    u32 limit;
> > +    int i,type;
> > +
> > +    if (dev->class == PCI_CLASS_BRIDGE_PCI) {
> > +        if (dev->secondary_bus >= busses_count) {
> > +            /* should never trigger */
> > +            dprintf(1, "PCI: bus count too small (%d), skipping bus #%d\n",
> > +                    busses_count, dev->secondary_bus);
> > +            return;
> > +        }
> > +        struct pci_bus *s = busses + dev->secondary_bus;
> 
> would be nice to move to top of the scope.

SeaBIOS uses C99 heavily - I'd actually prefer to move all these
definitions closer to their first usage.

-Kevin



More information about the SeaBIOS mailing list