mirror of
https://github.com/ipxe/ipxe
synced 2026-01-27 18:46:05 +03:00
[legacy] Rename the global legacy NIC to "legacy_nic"
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>
This commit is contained in:
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user