]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[legacy] Rename the global legacy NIC to "legacy_nic"
authorMichael Brown <mcb30@ipxe.org>
Tue, 24 Jun 2025 12:10:53 +0000 (13:10 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 24 Jun 2025 12:41:51 +0000 (13:41 +0100)
We currently have contexts in which the local variable "nic" is a
pointer to the global variable also called "nic".  This complicates
the creation of macros.

Rename the global variable to "legacy_nic" to reduce pollution of the
global namespace and to allow for the creation of macros referring to
fields within this global variable.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/net/legacy.c
src/include/nic.h

index cde8c02d589a1b9c7df9ce52d5192b3078ad1ffe..3b208a28bf4c33af893f350f49da41e291983379 100644 (file)
@@ -19,7 +19,7 @@
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
-struct nic nic;
+struct nic legacy_nic;
 
 static int legacy_registered = 0;
 
@@ -86,6 +86,7 @@ int legacy_probe ( void *hwdev,
                   int ( * probe ) ( struct nic *nic, void *hwdev ),
                   void ( * disable ) ( struct nic *nic, void *hwdev ) ) {
        struct net_device *netdev;
+       struct nic *nic;
        int rc;
 
        if ( legacy_registered )
@@ -95,15 +96,16 @@ int legacy_probe ( void *hwdev,
        if ( ! netdev )
                return -ENOMEM;
        netdev_init ( netdev, &legacy_operations );
-       netdev->priv = &nic;
-       memset ( &nic, 0, sizeof ( nic ) );
+       nic = &legacy_nic;
+       netdev->priv = nic;
+       memset ( nic, 0, sizeof ( *nic ) );
        set_drvdata ( hwdev, netdev );
        netdev->dev = dev;
 
-       nic.node_addr = netdev->hw_addr;
-       nic.irqno = dev->desc.irq;
+       nic->node_addr = netdev->hw_addr;
+       nic->irqno = dev->desc.irq;
 
-       if ( ! probe ( &nic, hwdev ) ) {
+       if ( ! probe ( nic, hwdev ) ) {
                rc = -ENODEV;
                goto err_probe;
        }
@@ -113,7 +115,7 @@ int legacy_probe ( void *hwdev,
         * don't support interrupts; doing this allows the timer
         * interrupt to be used instead.
         */
-       dev->desc.irq = nic.irqno;
+       dev->desc.irq = nic->irqno;
 
        if ( ( rc = register_netdev ( netdev ) ) != 0 )
                goto err_register;
@@ -123,13 +125,13 @@ int legacy_probe ( void *hwdev,
 
        /* Do not remove this message */
        printf ( "WARNING: Using legacy NIC wrapper on %s\n",
-                netdev->ll_protocol->ntoa ( nic.node_addr ) );
+                netdev->ll_protocol->ntoa ( nic->node_addr ) );
 
        legacy_registered = 1;
        return 0;
 
  err_register:
-       disable ( &nic, hwdev );
+       disable ( nic, hwdev );
  err_probe:
        netdev_nullify ( netdev );
        netdev_put ( netdev );
index 8e928beb41b27e7f26707ed5ca9ac944252d9fcb..678e23075a8017e79a8e17d29a28fd8085de1fd4 100644 (file)
@@ -67,15 +67,17 @@ struct nic_operations {
        void ( *irq ) ( struct nic *, irq_action_t );
 };
 
-extern struct nic nic;
+extern struct nic legacy_nic;
 
 static inline int eth_poll ( int retrieve ) {
-       return nic.nic_op->poll ( &nic, retrieve );
+       struct nic *nic = &legacy_nic;
+       return nic->nic_op->poll ( nic, retrieve );
 }
 
 static inline void eth_transmit ( const char *dest, unsigned int type,
                                  unsigned int size, const void *packet ) {
-       nic.nic_op->transmit ( &nic, dest, type, size, packet );
+       struct nic *nic = &legacy_nic;
+       nic->nic_op->transmit ( nic, dest, type, size, packet );
 }
 
 /*