Hi Benjamin,

Benjamin Herrenschmidt <[EMAIL PROTECTED]> writes:

> --- linux-work.orig/drivers/pci/pci.c 2007-12-18 09:37:56.000000000 +1100
> +++ linux-work/drivers/pci/pci.c      2007-12-18 09:38:25.000000000 +1100
> [...]
> +int pci_enable_device_io(struct pci_dev *dev)
> +{
> +     int err;
> +     int i, bars = 0;
> +
> +     if (atomic_add_return(1, &dev->enable_cnt) > 1)
> +             return 0;               /* already enabled */
> +
> +     for (i = 0; i < DEVICE_COUNT_RESOURCE; i++)
> +             if (dev->resource[i].flags & IORESOURCE_IO)
> +                     bars |= (1 << i);
> +
> +     err = do_pci_enable_device(dev, bars);
> +     if (err < 0)
> +             atomic_dec(&dev->enable_cnt);
> +     return err;
> +}
> [...]
> +int pci_enable_device_mem(struct pci_dev *dev)
> +{
> +     int err;
> +     int i, bars = 0;
> +
> +     if (atomic_add_return(1, &dev->enable_cnt) > 1)
> +             return 0;               /* already enabled */
> +
> +     for (i = 0; i < DEVICE_COUNT_RESOURCE; i++)
> +             if (dev->resource[i].flags & IORESOURCE_MEM)
> +                     bars |= (1 << i);
> +
> +     err = do_pci_enable_device(dev, bars);
> +     if (err < 0)
> +             atomic_dec(&dev->enable_cnt);
> +     return err;
> +}

These two functions should be refactored, the only difference is the
flag checking.

        Hannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to