Skip to content

Commit f49343a

Browse files
Alan-CoxJeff Garzik
authored andcommitted
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>
1 parent 44e4925 commit f49343a

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

drivers/net/ioc3-eth.c

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,12 @@ static u64 nic_find(struct ioc3 *ioc3, int *last)
352352

353353
static int nic_init(struct ioc3 *ioc3)
354354
{
355-
const char *type;
355+
const char *unknown = "unknown";
356+
const char *type = unknown;
356357
u8 crc;
357358
u8 serial[6];
358359
int save = 0, i;
359360

360-
type = "unknown";
361-
362361
while (1) {
363362
u64 reg;
364363
reg = nic_find(ioc3, &save);
@@ -392,7 +391,7 @@ static int nic_init(struct ioc3 *ioc3)
392391
}
393392

394393
printk("Found %s NIC", type);
395-
if (type != "unknown") {
394+
if (type != unknown) {
396395
printk (" registration number %02x:%02x:%02x:%02x:%02x:%02x,"
397396
" CRC %02x", serial[0], serial[1], serial[2],
398397
serial[3], serial[4], serial[5], crc);
@@ -1103,20 +1102,28 @@ static int ioc3_close(struct net_device *dev)
11031102
* MiniDINs; all other subdevices are left swinging in the wind, leave
11041103
* them disabled.
11051104
*/
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)
11071122
{
1108-
struct pci_dev *dev;
1109-
1110-
return pdev->bus->parent == NULL
1111-
&& (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(0, 0)))
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;
1123+
return pdev->bus->parent == NULL &&
1124+
ioc3_adjacent_is_ioc3(pdev, 0) &&
1125+
ioc3_adjacent_is_ioc3(pdev, 1) &&
1126+
ioc3_adjacent_is_ioc3(pdev, 2);
11201127
}
11211128

11221129
#ifdef CONFIG_SERIAL_8250

0 commit comments

Comments
 (0)