lkml.org 
[lkml]   [2004]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: cciss updates for 2.6 [1 of 11]
On Wed, Feb 04, 2004 at 06:04:46PM -0600, mikem@beardog.cca.cpqcorp.net 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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:00    [W:2.010 / U:0.724 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site