diff options
author | Sergei Shtylyov <sshtylyov@ru.mvista.com> | 2008-04-26 11:36:31 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-26 11:36:31 -0400 |
commit | 1baccff8a5823b51d7bf2740ef3ef17e06bfa7e2 (patch) | |
tree | bae9585842faf07f8c5f05f19df43a0d79241f51 /drivers/ide/setup-pci.c | |
parent | 938da770c205989945ba4cc5f0b4e255702061a1 (diff) |
ide: make ide_pci_check_iomem() actually work
This function didn't actually check if a given BAR is in I/O space because of
using the bogus PCI_BASE_ADDRESS_IO_MASK (which equals ~3) to test the resource
flags instead of IORESOURCE_IO -- fix this, make ide_hwif_configure() check the
results failing if necessary, and move the printk() call to the failure path.
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/setup-pci.c')
-rw-r--r-- | drivers/ide/setup-pci.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index f7ede0e42881..2dc3835478ec 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -301,11 +301,12 @@ static int ide_pci_configure(struct pci_dev *dev, const struct ide_port_info *d) | |||
301 | * @d: IDE port info | 301 | * @d: IDE port info |
302 | * @bar: BAR number | 302 | * @bar: BAR number |
303 | * | 303 | * |
304 | * Checks if a BAR is configured and points to MMIO space. If so | 304 | * Checks if a BAR is configured and points to MMIO space. If so, |
305 | * print an error and return an error code. Otherwise return 0 | 305 | * return an error code. Otherwise return 0 |
306 | */ | 306 | */ |
307 | 307 | ||
308 | static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *d, int bar) | 308 | static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *d, |
309 | int bar) | ||
309 | { | 310 | { |
310 | ulong flags = pci_resource_flags(dev, bar); | 311 | ulong flags = pci_resource_flags(dev, bar); |
311 | 312 | ||
@@ -313,14 +314,11 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info * | |||
313 | if (!flags || pci_resource_len(dev, bar) == 0) | 314 | if (!flags || pci_resource_len(dev, bar) == 0) |
314 | return 0; | 315 | return 0; |
315 | 316 | ||
316 | /* I/O space */ | 317 | /* I/O space */ |
317 | if(flags & PCI_BASE_ADDRESS_IO_MASK) | 318 | if (flags & IORESOURCE_IO) |
318 | return 0; | 319 | return 0; |
319 | 320 | ||
320 | /* Bad */ | 321 | /* Bad */ |
321 | printk(KERN_ERR "%s: IO baseregs (BIOS) are reported " | ||
322 | "as MEM, report to " | ||
323 | "<andre@linux-ide.org>.\n", d->name); | ||
324 | return -EINVAL; | 322 | return -EINVAL; |
325 | } | 323 | } |
326 | 324 | ||
@@ -348,9 +346,12 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
348 | struct hw_regs_s hw; | 346 | struct hw_regs_s hw; |
349 | 347 | ||
350 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { | 348 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { |
351 | /* Possibly we should fail if these checks report true */ | 349 | if (ide_pci_check_iomem(dev, d, 2 * port) || |
352 | ide_pci_check_iomem(dev, d, 2*port); | 350 | ide_pci_check_iomem(dev, d, 2 * port + 1)) { |
353 | ide_pci_check_iomem(dev, d, 2*port+1); | 351 | printk(KERN_ERR "%s: I/O baseregs (BIOS) are reported " |
352 | "as MEM for port %d!\n", d->name, port); | ||
353 | return NULL; | ||
354 | } | ||
354 | 355 | ||
355 | ctl = pci_resource_start(dev, 2*port+1); | 356 | ctl = pci_resource_start(dev, 2*port+1); |
356 | base = pci_resource_start(dev, 2*port); | 357 | base = pci_resource_start(dev, 2*port); |