]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[undi] Clean up driver and device name information
authorMichael Brown <mcb30@ipxe.org>
Mon, 5 Dec 2016 15:45:17 +0000 (15:45 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 5 Dec 2016 15:48:37 +0000 (15:48 +0000)
Fix the <NULL> driver name reported by "ifstat" when using the undipci
driver (due to the unnecessary extra device node inserted as a child
of the PCI device).

Remove the "UNDI-" prefix from device names since the driver name is
also now visible via "ifstat", and tidy up the device name to match
the format used by standard PCI devices.

The output from "ifstat" now resembles:

  iPXE> ifstat
  net0: 52:54:00:12:34:56 using undipci on 0000:00:03.0

  iPXE> ifstat
  net0: 52:54:00:12:34:56 using undionly on 0000:00:03.0

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/drivers/net/undi.c
src/arch/x86/drivers/net/undinet.c
src/arch/x86/drivers/net/undionly.c
src/arch/x86/include/undi.h
src/arch/x86/include/undinet.h

index 9820cf629b86fcf753094f45d87ef0d47fce23b6..87c93c3b438467cf06178bc094fd7be8657d8094 100644 (file)
@@ -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 );
 }
index 091ef9254c47dab57aa7a5d57e41ed9ef237ddd8..2afffa251bb8861a084de9aa9dc57f48028d58c8 100644 (file)
@@ -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;
index 70dbe4bfd560164d56c8e0c32d585145f18b3741..9c9ca1274ebc4e6a8d61138c68fea1f3aa6eaaac 100644 (file)
@@ -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 */
index 7a5624f938ade14f696f7e37814fb98d420f51ac..adf0c01e0d845a9a2afbbb63d5e710fb97e3e70f 100644 (file)
@@ -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
index 2798c446662502b340c134c26f5c2ddcebc1bf4a..04fdd6000edea63d9985bdb01b35004349557f2d 100644 (file)
@@ -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 */