mirror of
https://github.com/ipxe/ipxe
synced 2026-02-14 02:31:26 +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 );
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
struct nic nic;
|
struct nic legacy_nic;
|
||||||
|
|
||||||
static int legacy_registered = 0;
|
static int legacy_registered = 0;
|
||||||
|
|
||||||
@@ -86,6 +86,7 @@ int legacy_probe ( void *hwdev,
|
|||||||
int ( * probe ) ( struct nic *nic, void *hwdev ),
|
int ( * probe ) ( struct nic *nic, void *hwdev ),
|
||||||
void ( * disable ) ( struct nic *nic, void *hwdev ) ) {
|
void ( * disable ) ( struct nic *nic, void *hwdev ) ) {
|
||||||
struct net_device *netdev;
|
struct net_device *netdev;
|
||||||
|
struct nic *nic;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if ( legacy_registered )
|
if ( legacy_registered )
|
||||||
@@ -95,15 +96,16 @@ int legacy_probe ( void *hwdev,
|
|||||||
if ( ! netdev )
|
if ( ! netdev )
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
netdev_init ( netdev, &legacy_operations );
|
netdev_init ( netdev, &legacy_operations );
|
||||||
netdev->priv = &nic;
|
nic = &legacy_nic;
|
||||||
memset ( &nic, 0, sizeof ( nic ) );
|
netdev->priv = nic;
|
||||||
|
memset ( nic, 0, sizeof ( *nic ) );
|
||||||
set_drvdata ( hwdev, netdev );
|
set_drvdata ( hwdev, netdev );
|
||||||
netdev->dev = dev;
|
netdev->dev = dev;
|
||||||
|
|
||||||
nic.node_addr = netdev->hw_addr;
|
nic->node_addr = netdev->hw_addr;
|
||||||
nic.irqno = dev->desc.irq;
|
nic->irqno = dev->desc.irq;
|
||||||
|
|
||||||
if ( ! probe ( &nic, hwdev ) ) {
|
if ( ! probe ( nic, hwdev ) ) {
|
||||||
rc = -ENODEV;
|
rc = -ENODEV;
|
||||||
goto err_probe;
|
goto err_probe;
|
||||||
}
|
}
|
||||||
@@ -113,7 +115,7 @@ int legacy_probe ( void *hwdev,
|
|||||||
* don't support interrupts; doing this allows the timer
|
* don't support interrupts; doing this allows the timer
|
||||||
* interrupt to be used instead.
|
* interrupt to be used instead.
|
||||||
*/
|
*/
|
||||||
dev->desc.irq = nic.irqno;
|
dev->desc.irq = nic->irqno;
|
||||||
|
|
||||||
if ( ( rc = register_netdev ( netdev ) ) != 0 )
|
if ( ( rc = register_netdev ( netdev ) ) != 0 )
|
||||||
goto err_register;
|
goto err_register;
|
||||||
@@ -123,13 +125,13 @@ int legacy_probe ( void *hwdev,
|
|||||||
|
|
||||||
/* Do not remove this message */
|
/* Do not remove this message */
|
||||||
printf ( "WARNING: Using legacy NIC wrapper on %s\n",
|
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;
|
legacy_registered = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_register:
|
err_register:
|
||||||
disable ( &nic, hwdev );
|
disable ( nic, hwdev );
|
||||||
err_probe:
|
err_probe:
|
||||||
netdev_nullify ( netdev );
|
netdev_nullify ( netdev );
|
||||||
netdev_put ( netdev );
|
netdev_put ( netdev );
|
||||||
|
|||||||
@@ -67,15 +67,17 @@ struct nic_operations {
|
|||||||
void ( *irq ) ( struct nic *, irq_action_t );
|
void ( *irq ) ( struct nic *, irq_action_t );
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct nic nic;
|
extern struct nic legacy_nic;
|
||||||
|
|
||||||
static inline int eth_poll ( int retrieve ) {
|
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,
|
static inline void eth_transmit ( const char *dest, unsigned int type,
|
||||||
unsigned int size, const void *packet ) {
|
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