aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSergei Shtylyov <sshtylyov@ru.mvista.com>2007-02-07 12:17:54 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-02-07 12:17:54 -0500
commitb4586715d7944dfbcb2b6b76a0098413cf3222e4 (patch)
tree07e8f44df4ea741ab90beaffcc0f66deef8ee80b /drivers
parent90778574c9257ea2d11c433626e1b12ac4135e0a (diff)
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: Sergei Shtylyov <sshtylyov@ru.mvista.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/pci/hpt366.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 32a40710e73e..577aef94d7bf 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/hpt366.c Version 0.44 May 20, 2006 2 * linux/drivers/ide/pci/hpt366.c Version 0.45 May 27, 2006
3 * 3 *
4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
5 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 5 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
@@ -79,6 +79,7 @@
79 * - prefix the driver startup messages with the real chip name 79 * - prefix the driver startup messages with the real chip name
80 * - claim the extra 240 bytes of I/O space for all chips 80 * - claim the extra 240 bytes of I/O space for all chips
81 * - optimize the rate masking/filtering and the drive list lookup code 81 * - optimize the rate masking/filtering and the drive list lookup code
82 * - use pci_get_slot() to get to the function 1 of HPT36x/374
82 * <source@mvista.com> 83 * <source@mvista.com>
83 * 84 *
84 */ 85 */
@@ -1416,24 +1417,24 @@ static void __devinit init_iops_hpt366(ide_hwif_t *hwif)
1416 1417
1417static int __devinit init_setup_hpt374(struct pci_dev *dev, ide_pci_device_t *d) 1418static int __devinit init_setup_hpt374(struct pci_dev *dev, ide_pci_device_t *d)
1418{ 1419{
1419 struct pci_dev *findev = NULL; 1420 struct pci_dev *dev2;
1420 1421
1421 if (PCI_FUNC(dev->devfn) & 1) 1422 if (PCI_FUNC(dev->devfn) & 1)
1422 return -ENODEV; 1423 return -ENODEV;
1423 1424
1424 while ((findev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) { 1425 if ((dev2 = pci_get_slot(dev->bus, dev->devfn + 1)) != NULL) {
1425 if ((findev->vendor == dev->vendor) && 1426 int ret;
1426 (findev->device == dev->device) && 1427
1427 ((findev->devfn - dev->devfn) == 1) && 1428 if (dev2->irq != dev->irq) {
1428 (PCI_FUNC(findev->devfn) & 1)) { 1429 /* FIXME: we need a core pci_set_interrupt() */
1429 if (findev->irq != dev->irq) { 1430 dev2->irq = dev->irq;
1430 /* FIXME: we need a core pci_set_interrupt() */ 1431 printk(KERN_WARNING "%s: PCI config space interrupt "
1431 findev->irq = dev->irq; 1432 "fixed.\n", d->name);
1432 printk(KERN_WARNING "%s: pci-config space interrupt "
1433 "fixed.\n", d->name);
1434 }
1435 return ide_setup_pci_devices(dev, findev, d);
1436 } 1433 }
1434 ret = ide_setup_pci_devices(dev, dev2, d);
1435 if (ret < 0)
1436 pci_dev_put(dev2);
1437 return ret;
1437 } 1438 }
1438 return ide_setup_pci_device(dev, d); 1439 return ide_setup_pci_device(dev, d);
1439} 1440}
@@ -1491,8 +1492,8 @@ static int __devinit init_setup_hpt302(struct pci_dev *dev, ide_pci_device_t *d)
1491 1492
1492static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d) 1493static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d)
1493{ 1494{
1494 struct pci_dev *findev = NULL; 1495 struct pci_dev *dev2;
1495 u8 rev = 0, pin1 = 0, pin2 = 0; 1496 u8 rev = 0;
1496 static char *chipset_names[] = { "HPT366", "HPT366", "HPT368", 1497 static char *chipset_names[] = { "HPT366", "HPT366", "HPT368",
1497 "HPT370", "HPT370A", "HPT372", 1498 "HPT370", "HPT370A", "HPT372",
1498 "HPT372N" }; 1499 "HPT372N" };
@@ -1512,21 +1513,21 @@ static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d)
1512 1513
1513 d->channels = 1; 1514 d->channels = 1;
1514 1515
1515 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin1); 1516 if ((dev2 = pci_get_slot(dev->bus, dev->devfn + 1)) != NULL) {
1516 while ((findev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) { 1517 u8 pin1 = 0, pin2 = 0;
1517 if ((findev->vendor == dev->vendor) && 1518 int ret;
1518 (findev->device == dev->device) && 1519
1519 ((findev->devfn - dev->devfn) == 1) && 1520 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin1);
1520 (PCI_FUNC(findev->devfn) & 1)) { 1521 pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin2);
1521 pci_read_config_byte(findev, PCI_INTERRUPT_PIN, &pin2); 1522 if (pin1 != pin2 && dev->irq == dev2->irq) {
1522 if ((pin1 != pin2) && (dev->irq == findev->irq)) { 1523 d->bootable = ON_BOARD;
1523 d->bootable = ON_BOARD; 1524 printk("%s: onboard version of chipset, pin1=%d pin2=%d\n",
1524 printk("%s: onboard version of chipset, " 1525 d->name, pin1, pin2);
1525 "pin1=%d pin2=%d\n", d->name,
1526 pin1, pin2);
1527 }
1528 return ide_setup_pci_devices(dev, findev, d);
1529 } 1526 }
1527 ret = ide_setup_pci_devices(dev, dev2, d);
1528 if (ret < 0)
1529 pci_dev_put(dev2);
1530 return ret;
1530 } 1531 }
1531init_single: 1532init_single:
1532 return ide_setup_pci_device(dev, d); 1533 return ide_setup_pci_device(dev, d);