Commit b4586715 authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by Bartlomiej Zolnierkiewicz

hpt366: switch to using pci_get_slot

Switch to using pci_get_slot() to get to the function 1 of HPT36x/374 chips --
there's no need for the driver itself to walk the list of the PCI devices, and
it also forgets to check the bus number of the device found.
Signed-off-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 90778574
/* /*
* linux/drivers/ide/pci/hpt366.c Version 0.44 May 20, 2006 * linux/drivers/ide/pci/hpt366.c Version 0.45 May 27, 2006
* *
* Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
* Portions Copyright (C) 2001 Sun Microsystems, Inc. * Portions Copyright (C) 2001 Sun Microsystems, Inc.
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
* - prefix the driver startup messages with the real chip name * - prefix the driver startup messages with the real chip name
* - claim the extra 240 bytes of I/O space for all chips * - claim the extra 240 bytes of I/O space for all chips
* - optimize the rate masking/filtering and the drive list lookup code * - optimize the rate masking/filtering and the drive list lookup code
* - use pci_get_slot() to get to the function 1 of HPT36x/374
* <source@mvista.com> * <source@mvista.com>
* *
*/ */
...@@ -1416,24 +1417,24 @@ static void __devinit init_iops_hpt366(ide_hwif_t *hwif) ...@@ -1416,24 +1417,24 @@ static void __devinit init_iops_hpt366(ide_hwif_t *hwif)
static int __devinit init_setup_hpt374(struct pci_dev *dev, ide_pci_device_t *d) static int __devinit init_setup_hpt374(struct pci_dev *dev, ide_pci_device_t *d)
{ {
struct pci_dev *findev = NULL; struct pci_dev *dev2;
if (PCI_FUNC(dev->devfn) & 1) if (PCI_FUNC(dev->devfn) & 1)
return -ENODEV; return -ENODEV;
while ((findev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) { if ((dev2 = pci_get_slot(dev->bus, dev->devfn + 1)) != NULL) {
if ((findev->vendor == dev->vendor) && int ret;
(findev->device == dev->device) &&
((findev->devfn - dev->devfn) == 1) && if (dev2->irq != dev->irq) {
(PCI_FUNC(findev->devfn) & 1)) { /* FIXME: we need a core pci_set_interrupt() */
if (findev->irq != dev->irq) { dev2->irq = dev->irq;
/* FIXME: we need a core pci_set_interrupt() */ printk(KERN_WARNING "%s: PCI config space interrupt "
findev->irq = dev->irq; "fixed.\n", d->name);
printk(KERN_WARNING "%s: pci-config space interrupt "
"fixed.\n", d->name);
}
return ide_setup_pci_devices(dev, findev, d);
} }
ret = ide_setup_pci_devices(dev, dev2, d);
if (ret < 0)
pci_dev_put(dev2);
return ret;
} }
return ide_setup_pci_device(dev, d); return ide_setup_pci_device(dev, d);
} }
...@@ -1491,8 +1492,8 @@ static int __devinit init_setup_hpt302(struct pci_dev *dev, ide_pci_device_t *d) ...@@ -1491,8 +1492,8 @@ static int __devinit init_setup_hpt302(struct pci_dev *dev, ide_pci_device_t *d)
static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d) static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d)
{ {
struct pci_dev *findev = NULL; struct pci_dev *dev2;
u8 rev = 0, pin1 = 0, pin2 = 0; u8 rev = 0;
static char *chipset_names[] = { "HPT366", "HPT366", "HPT368", static char *chipset_names[] = { "HPT366", "HPT366", "HPT368",
"HPT370", "HPT370A", "HPT372", "HPT370", "HPT370A", "HPT372",
"HPT372N" }; "HPT372N" };
...@@ -1512,21 +1513,21 @@ static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d) ...@@ -1512,21 +1513,21 @@ static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d)
d->channels = 1; d->channels = 1;
pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin1); if ((dev2 = pci_get_slot(dev->bus, dev->devfn + 1)) != NULL) {
while ((findev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) { u8 pin1 = 0, pin2 = 0;
if ((findev->vendor == dev->vendor) && int ret;
(findev->device == dev->device) &&
((findev->devfn - dev->devfn) == 1) && pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin1);
(PCI_FUNC(findev->devfn) & 1)) { pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin2);
pci_read_config_byte(findev, PCI_INTERRUPT_PIN, &pin2); if (pin1 != pin2 && dev->irq == dev2->irq) {
if ((pin1 != pin2) && (dev->irq == findev->irq)) { d->bootable = ON_BOARD;
d->bootable = ON_BOARD; printk("%s: onboard version of chipset, pin1=%d pin2=%d\n",
printk("%s: onboard version of chipset, " d->name, pin1, pin2);
"pin1=%d pin2=%d\n", d->name,
pin1, pin2);
}
return ide_setup_pci_devices(dev, findev, d);
} }
ret = ide_setup_pci_devices(dev, dev2, d);
if (ret < 0)
pci_dev_put(dev2);
return ret;
} }
init_single: init_single:
return ide_setup_pci_device(dev, d); return ide_setup_pci_device(dev, d);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment