mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: mikem@beardog.cca.cpqcorp.net
Cc: axboe@suse.de, akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: cciss updates for 2.6 [1 of 11]
Date: Thu, 5 Feb 2004 11:10:22 +0000	[thread overview]
Message-ID: <20040205111022.A31248@infradead.org> (raw)
In-Reply-To: <Pine.LNX.4.58.0402041737080.18320@beardog.cca.cpqcorp.net>; from mikem@beardog.cca.cpqcorp.net on Wed, Feb 04, 2004 at 06:04:46PM -0600

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?


  parent reply	other threads:[~2004-02-05 11:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-05  0:04 mikem
2004-02-05  4:30 ` Andrew Morton
2004-02-05 11:10 ` Christoph Hellwig [this message]
2004-02-06  1:09 ` Greg KH
2004-02-06  1:54   ` mikem

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040205111022.A31248@infradead.org \
    --to=hch@infradead.org \
    --cc=akpm@osdl.org \
    --cc=axboe@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikem@beardog.cca.cpqcorp.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®