diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2007-07-10 12:05:16 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-07-10 12:29:24 -0400 |
commit | f49343a54864b98333b98706accba66aa75a0c16 (patch) | |
tree | e8656c82986674842ef0154988e7df7aeb817d13 /drivers/net/ioc3-eth.c | |
parent | 44e4925e4601961b9bd1982008a55fce865d318c (diff) |
IOC3: Switch to pci refcounting safe APIs
Convert the IOC3 driver to use ref counting pci interfaces so that we can
obsolete the (usually unsafe) pci_find_{slot/device} interfaces and avoid
future authors writing hotplug-unsafe device drivers.
Signed-off-by: Alan Cox <alan@redhat.com>
Build fixes:
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/ioc3-eth.c')
-rw-r--r-- | drivers/net/ioc3-eth.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c index f749e07c6425..3ca1e8ece548 100644 --- a/drivers/net/ioc3-eth.c +++ b/drivers/net/ioc3-eth.c | |||
@@ -352,13 +352,12 @@ static u64 nic_find(struct ioc3 *ioc3, int *last) | |||
352 | 352 | ||
353 | static int nic_init(struct ioc3 *ioc3) | 353 | static int nic_init(struct ioc3 *ioc3) |
354 | { | 354 | { |
355 | const char *type; | 355 | const char *unknown = "unknown"; |
356 | const char *type = unknown; | ||
356 | u8 crc; | 357 | u8 crc; |
357 | u8 serial[6]; | 358 | u8 serial[6]; |
358 | int save = 0, i; | 359 | int save = 0, i; |
359 | 360 | ||
360 | type = "unknown"; | ||
361 | |||
362 | while (1) { | 361 | while (1) { |
363 | u64 reg; | 362 | u64 reg; |
364 | reg = nic_find(ioc3, &save); | 363 | reg = nic_find(ioc3, &save); |
@@ -392,7 +391,7 @@ static int nic_init(struct ioc3 *ioc3) | |||
392 | } | 391 | } |
393 | 392 | ||
394 | printk("Found %s NIC", type); | 393 | printk("Found %s NIC", type); |
395 | if (type != "unknown") { | 394 | if (type != unknown) { |
396 | printk (" registration number %02x:%02x:%02x:%02x:%02x:%02x," | 395 | printk (" registration number %02x:%02x:%02x:%02x:%02x:%02x," |
397 | " CRC %02x", serial[0], serial[1], serial[2], | 396 | " CRC %02x", serial[0], serial[1], serial[2], |
398 | serial[3], serial[4], serial[5], crc); | 397 | serial[3], serial[4], serial[5], crc); |
@@ -1103,20 +1102,28 @@ static int ioc3_close(struct net_device *dev) | |||
1103 | * MiniDINs; all other subdevices are left swinging in the wind, leave | 1102 | * MiniDINs; all other subdevices are left swinging in the wind, leave |
1104 | * them disabled. | 1103 | * them disabled. |
1105 | */ | 1104 | */ |
1106 | static inline int ioc3_is_menet(struct pci_dev *pdev) | 1105 | |
1106 | static int ioc3_adjacent_is_ioc3(struct pci_dev *pdev, int slot) | ||
1107 | { | ||
1108 | struct pci_dev *dev = pci_get_slot(pdev->bus, PCI_DEVFN(slot, 0)); | ||
1109 | int ret = 0; | ||
1110 | |||
1111 | if (dev) { | ||
1112 | if (dev->vendor == PCI_VENDOR_ID_SGI && | ||
1113 | dev->device == PCI_DEVICE_ID_SGI_IOC3) | ||
1114 | ret = 1; | ||
1115 | pci_dev_put(dev); | ||
1116 | } | ||
1117 | |||
1118 | return ret; | ||
1119 | } | ||
1120 | |||
1121 | static int ioc3_is_menet(struct pci_dev *pdev) | ||
1107 | { | 1122 | { |
1108 | struct pci_dev *dev; | 1123 | return pdev->bus->parent == NULL && |
1109 | 1124 | ioc3_adjacent_is_ioc3(pdev, 0) && | |
1110 | return pdev->bus->parent == NULL | 1125 | ioc3_adjacent_is_ioc3(pdev, 1) && |
1111 | && (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(0, 0))) | 1126 | ioc3_adjacent_is_ioc3(pdev, 2); |
1112 | && dev->vendor == PCI_VENDOR_ID_SGI | ||
1113 | && dev->device == PCI_DEVICE_ID_SGI_IOC3 | ||
1114 | && (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(1, 0))) | ||
1115 | && dev->vendor == PCI_VENDOR_ID_SGI | ||
1116 | && dev->device == PCI_DEVICE_ID_SGI_IOC3 | ||
1117 | && (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(2, 0))) | ||
1118 | && dev->vendor == PCI_VENDOR_ID_SGI | ||
1119 | && dev->device == PCI_DEVICE_ID_SGI_IOC3; | ||
1120 | } | 1127 | } |
1121 | 1128 | ||
1122 | #ifdef CONFIG_SERIAL_8250 | 1129 | #ifdef CONFIG_SERIAL_8250 |