diff --git a/src/arch/x86/drivers/net/undi.c b/src/arch/x86/drivers/net/undi.c index 9820cf62..87c93c3b 100644 --- a/src/arch/x86/drivers/net/undi.c +++ b/src/arch/x86/drivers/net/undi.c @@ -94,23 +94,14 @@ static int undipci_probe ( struct pci_device *pci ) { } } - /* Add to device hierarchy */ - snprintf ( undi->dev.name, sizeof ( undi->dev.name ), - "UNDI-%s", pci->dev.name ); - memcpy ( &undi->dev.desc, &pci->dev.desc, sizeof ( undi->dev.desc ) ); - undi->dev.parent = &pci->dev; - INIT_LIST_HEAD ( &undi->dev.children ); - list_add ( &undi->dev.siblings, &pci->dev.children ); - /* Create network device */ - if ( ( rc = undinet_probe ( undi ) ) != 0 ) + if ( ( rc = undinet_probe ( undi, &pci->dev ) ) != 0 ) goto err_undinet_probe; return 0; err_undinet_probe: undi_unload ( undi ); - list_del ( &undi->dev.siblings ); err_find_rom: err_load_pci: free ( undi ); @@ -128,7 +119,6 @@ static void undipci_remove ( struct pci_device *pci ) { undinet_remove ( undi ); undi_unload ( undi ); - list_del ( &undi->dev.siblings ); free ( undi ); pci_set_drvdata ( pci, NULL ); } diff --git a/src/arch/x86/drivers/net/undinet.c b/src/arch/x86/drivers/net/undinet.c index 091ef925..2afffa25 100644 --- a/src/arch/x86/drivers/net/undinet.c +++ b/src/arch/x86/drivers/net/undinet.c @@ -598,19 +598,19 @@ static const struct undinet_irq_broken undinet_irq_broken_list[] = { /** * Check for devices with broken support for generating interrupts * - * @v undi UNDI device + * @v desc Device description * @ret irq_is_broken Interrupt support is broken; no interrupts are generated */ -static int undinet_irq_is_broken ( struct undi_device *undi ) { +static int undinet_irq_is_broken ( struct device_description *desc ) { const struct undinet_irq_broken *broken; unsigned int i; for ( i = 0 ; i < ( sizeof ( undinet_irq_broken_list ) / sizeof ( undinet_irq_broken_list[0] ) ) ; i++ ) { broken = &undinet_irq_broken_list[i]; - if ( ( undi->dev.desc.bus_type == BUS_TYPE_PCI ) && - ( undi->dev.desc.vendor == broken->pci_vendor ) && - ( undi->dev.desc.device == broken->pci_device ) ) { + if ( ( desc->bus_type == BUS_TYPE_PCI ) && + ( desc->vendor == broken->pci_vendor ) && + ( desc->device == broken->pci_device ) ) { return 1; } } @@ -621,9 +621,10 @@ static int undinet_irq_is_broken ( struct undi_device *undi ) { * Probe UNDI device * * @v undi UNDI device + * @v dev Underlying generic device * @ret rc Return status code */ -int undinet_probe ( struct undi_device *undi ) { +int undinet_probe ( struct undi_device *undi, struct device *dev ) { struct net_device *netdev; struct undi_nic *undinic; struct s_PXENV_START_UNDI start_undi; @@ -644,7 +645,7 @@ int undinet_probe ( struct undi_device *undi ) { netdev_init ( netdev, &undinet_operations ); undinic = netdev->priv; undi_set_drvdata ( undi, netdev ); - netdev->dev = &undi->dev; + netdev->dev = dev; memset ( undinic, 0, sizeof ( *undinic ) ); undinet_entry = undi->entry; DBGC ( undinic, "UNDINIC %p using UNDI %p\n", undinic, undi ); @@ -733,7 +734,7 @@ int undinet_probe ( struct undi_device *undi ) { undinic ); undinic->hacks |= UNDI_HACK_EB54; } - if ( undinet_irq_is_broken ( undi ) ) { + if ( undinet_irq_is_broken ( &dev->desc ) ) { DBGC ( undinic, "UNDINIC %p forcing polling mode due to " "broken interrupts\n", undinic ); undinic->irq_supported = 0; diff --git a/src/arch/x86/drivers/net/undionly.c b/src/arch/x86/drivers/net/undionly.c index 70dbe4bf..9c9ca127 100644 --- a/src/arch/x86/drivers/net/undionly.c +++ b/src/arch/x86/drivers/net/undionly.c @@ -50,6 +50,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * addition to the UNDI driver, build e.g. "bin/undi.dsk". */ +/** UNDI root bus device */ +static struct device undibus_dev; + /** * Probe UNDI root bus * @@ -60,6 +63,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ static int undibus_probe ( struct root_device *rootdev ) { struct undi_device *undi = &preloaded_undi; + struct device *dev = &undibus_dev; int rc; /* Check for a valie preloaded UNDI device */ @@ -69,34 +73,32 @@ static int undibus_probe ( struct root_device *rootdev ) { } /* Add to device hierarchy */ - undi->dev.driver_name = "undionly"; + dev->driver_name = "undionly"; if ( undi->pci_busdevfn != UNDI_NO_PCI_BUSDEVFN ) { - undi->dev.desc.bus_type = BUS_TYPE_PCI; - undi->dev.desc.location = undi->pci_busdevfn; - undi->dev.desc.vendor = undi->pci_vendor; - undi->dev.desc.device = undi->pci_device; - snprintf ( undi->dev.name, sizeof ( undi->dev.name ), - "UNDI-PCI%02x:%02x.%x", - PCI_BUS ( undi->pci_busdevfn ), + dev->desc.bus_type = BUS_TYPE_PCI; + dev->desc.location = undi->pci_busdevfn; + dev->desc.vendor = undi->pci_vendor; + dev->desc.device = undi->pci_device; + snprintf ( dev->name, sizeof ( dev->name ), + "0000:%02x:%02x.%x", PCI_BUS ( undi->pci_busdevfn ), PCI_SLOT ( undi->pci_busdevfn ), PCI_FUNC ( undi->pci_busdevfn ) ); } else if ( undi->isapnp_csn != UNDI_NO_ISAPNP_CSN ) { - undi->dev.desc.bus_type = BUS_TYPE_ISAPNP; - snprintf ( undi->dev.name, sizeof ( undi->dev.name ), - "UNDI-ISAPNP" ); + dev->desc.bus_type = BUS_TYPE_ISAPNP; + snprintf ( dev->name, sizeof ( dev->name ), "ISAPNP" ); } - undi->dev.parent = &rootdev->dev; - list_add ( &undi->dev.siblings, &rootdev->dev.children); - INIT_LIST_HEAD ( &undi->dev.children ); + dev->parent = &rootdev->dev; + list_add ( &dev->siblings, &rootdev->dev.children); + INIT_LIST_HEAD ( &dev->children ); /* Create network device */ - if ( ( rc = undinet_probe ( undi ) ) != 0 ) + if ( ( rc = undinet_probe ( undi, dev ) ) != 0 ) goto err; return 0; err: - list_del ( &undi->dev.siblings ); + list_del ( &dev->siblings ); return rc; } @@ -107,9 +109,10 @@ static int undibus_probe ( struct root_device *rootdev ) { */ static void undibus_remove ( struct root_device *rootdev __unused ) { struct undi_device *undi = &preloaded_undi; + struct device *dev = &undibus_dev; undinet_remove ( undi ); - list_del ( &undi->dev.siblings ); + list_del ( &dev->siblings ); } /** UNDI bus root device driver */ diff --git a/src/arch/x86/include/undi.h b/src/arch/x86/include/undi.h index 7a5624f9..adf0c01e 100644 --- a/src/arch/x86/include/undi.h +++ b/src/arch/x86/include/undi.h @@ -53,8 +53,6 @@ struct undi_device { */ UINT16_t flags; - /** Generic device */ - struct device dev; /** Driver-private data * * Use undi_set_drvdata() and undi_get_drvdata() to access this diff --git a/src/arch/x86/include/undinet.h b/src/arch/x86/include/undinet.h index 2798c446..04fdd600 100644 --- a/src/arch/x86/include/undinet.h +++ b/src/arch/x86/include/undinet.h @@ -10,8 +10,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); struct undi_device; +struct device; -extern int undinet_probe ( struct undi_device *undi ); +extern int undinet_probe ( struct undi_device *undi, struct device *dev ); extern void undinet_remove ( struct undi_device *undi ); #endif /* _UNDINET_H */