Re: cciss updates for 2.6 [1 of 11]

From: Christoph Hellwig
Date: Thu Feb 05 2004 - 06:11:33 EST


On Wed, Feb 04, 2004 at 06:04:46PM -0600, mikem@xxxxxxxxxxxxxxxxxxxxxxx wrote:
> +static int find_PCI_BAR_index(struct pci_dev *pdev,
> + unsigned long pci_bar_addr)
> +{
> + int i, offset, mem_type, bar_type;
> + if (pci_bar_addr == PCI_BASE_ADDRESS_0) /* looking for BAR zero? */
> + return 0;
> + offset = 0;
> + for (i=0; i<DEVICE_COUNT_RESOURCE; i++) {
> + bar_type = pci_resource_flags(pdev, i) &
> + PCI_BASE_ADDRESS_SPACE;
> + if (bar_type == PCI_BASE_ADDRESS_SPACE_IO)
> + offset += 4;
> + else {
> + mem_type = pci_resource_flags(pdev, i) &
> + PCI_BASE_ADDRESS_MEM_TYPE_MASK;
> + switch (mem_type) {
> + case PCI_BASE_ADDRESS_MEM_TYPE_32:
> + case PCI_BASE_ADDRESS_MEM_TYPE_1M:
> + offset += 4; /* 32 bit */
> + break;
> + case PCI_BASE_ADDRESS_MEM_TYPE_64:
> + offset += 8;
> + break;
> + default: /* reserved in PCI 2.2 */
> + printk(KERN_WARNING "Base address is invalid\n");
> + return -1;
> + break;
> + }
> + }
> + if (offset == pci_bar_addr - PCI_BASE_ADDRESS_0)
> + return i+1;
> + }
> + return -1;
> +}

Urgg, this stuff looks extremly kludgy. What's missing from pci_request_regions
for you?

-
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/