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>
This commit is contained in:
Родитель
44e4925e46
Коммит
f49343a548
|
@ -352,13 +352,12 @@ static u64 nic_find(struct ioc3 *ioc3, int *last)
|
||||||
|
|
||||||
static int nic_init(struct ioc3 *ioc3)
|
static int nic_init(struct ioc3 *ioc3)
|
||||||
{
|
{
|
||||||
const char *type;
|
const char *unknown = "unknown";
|
||||||
|
const char *type = unknown;
|
||||||
u8 crc;
|
u8 crc;
|
||||||
u8 serial[6];
|
u8 serial[6];
|
||||||
int save = 0, i;
|
int save = 0, i;
|
||||||
|
|
||||||
type = "unknown";
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
u64 reg;
|
u64 reg;
|
||||||
reg = nic_find(ioc3, &save);
|
reg = nic_find(ioc3, &save);
|
||||||
|
@ -392,7 +391,7 @@ static int nic_init(struct ioc3 *ioc3)
|
||||||
}
|
}
|
||||||
|
|
||||||
printk("Found %s NIC", type);
|
printk("Found %s NIC", type);
|
||||||
if (type != "unknown") {
|
if (type != unknown) {
|
||||||
printk (" registration number %02x:%02x:%02x:%02x:%02x:%02x,"
|
printk (" registration number %02x:%02x:%02x:%02x:%02x:%02x,"
|
||||||
" CRC %02x", serial[0], serial[1], serial[2],
|
" CRC %02x", serial[0], serial[1], serial[2],
|
||||||
serial[3], serial[4], serial[5], crc);
|
serial[3], serial[4], serial[5], crc);
|
||||||
|
@ -1103,20 +1102,28 @@ static int ioc3_close(struct net_device *dev)
|
||||||
* MiniDINs; all other subdevices are left swinging in the wind, leave
|
* MiniDINs; all other subdevices are left swinging in the wind, leave
|
||||||
* them disabled.
|
* them disabled.
|
||||||
*/
|
*/
|
||||||
static inline int ioc3_is_menet(struct pci_dev *pdev)
|
|
||||||
{
|
|
||||||
struct pci_dev *dev;
|
|
||||||
|
|
||||||
return pdev->bus->parent == NULL
|
static int ioc3_adjacent_is_ioc3(struct pci_dev *pdev, int slot)
|
||||||
&& (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(0, 0)))
|
{
|
||||||
&& dev->vendor == PCI_VENDOR_ID_SGI
|
struct pci_dev *dev = pci_get_slot(pdev->bus, PCI_DEVFN(slot, 0));
|
||||||
&& dev->device == PCI_DEVICE_ID_SGI_IOC3
|
int ret = 0;
|
||||||
&& (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(1, 0)))
|
|
||||||
&& dev->vendor == PCI_VENDOR_ID_SGI
|
if (dev) {
|
||||||
&& dev->device == PCI_DEVICE_ID_SGI_IOC3
|
if (dev->vendor == PCI_VENDOR_ID_SGI &&
|
||||||
&& (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(2, 0)))
|
dev->device == PCI_DEVICE_ID_SGI_IOC3)
|
||||||
&& dev->vendor == PCI_VENDOR_ID_SGI
|
ret = 1;
|
||||||
&& dev->device == PCI_DEVICE_ID_SGI_IOC3;
|
pci_dev_put(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ioc3_is_menet(struct pci_dev *pdev)
|
||||||
|
{
|
||||||
|
return pdev->bus->parent == NULL &&
|
||||||
|
ioc3_adjacent_is_ioc3(pdev, 0) &&
|
||||||
|
ioc3_adjacent_is_ioc3(pdev, 1) &&
|
||||||
|
ioc3_adjacent_is_ioc3(pdev, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_8250
|
#ifdef CONFIG_SERIAL_8250
|
||||||
|
|
Загрузка…
Ссылка в новой задаче