]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Remove unsafe disable function wrapper from legacy NIC drivers
authorMichael Brown <mcb30@ipxe.org>
Sun, 27 Apr 2025 16:37:44 +0000 (17:37 +0100)
committerMichael Brown <mcb30@ipxe.org>
Sun, 27 Apr 2025 17:40:52 +0000 (18:40 +0100)
The legacy NIC drivers do not consistently take a second parameter in
their disable function.  We currently use an unsafe function wrapper
that declares no parameters, and rely on the ABI allowing a second
parameter to be silently ignored if not expected by the caller.  As of
GCC 15, this hack results in an incompatible pointer type warning.

Fix by removing the hack, and instead updating all relevant legacy NIC
drivers to take an unused second parameter in their disable function.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
16 files changed:
src/drivers/net/3c595.c
src/drivers/net/amd8111e.c
src/drivers/net/bnx2.c
src/drivers/net/davicom.c
src/drivers/net/depca.c
src/drivers/net/dmfe.c
src/drivers/net/epic100.c
src/drivers/net/ns8390.c
src/drivers/net/prism2_pci.c
src/drivers/net/prism2_plx.c
src/drivers/net/sis900.c
src/drivers/net/sundance.c
src/drivers/net/tlan.c
src/drivers/net/tulip.c
src/drivers/net/w89c840.c
src/include/nic.h

index 1fab56aa98713369ec17ab85fee339facf6623df..7792c17d64fb9f37b1e582dc605e496fb0f393b9 100644 (file)
@@ -443,7 +443,7 @@ vxsetlink(void)
     GO_WINDOW(1); 
 }
 
-static void t595_disable ( struct nic *nic ) {
+static void t595_disable ( struct nic *nic, void *hwdev __unused ) {
 
        t595_reset(nic);
 
index babd12d3c8a10e4f66d2d946a754b9e013bff8df..213c4f44b2d36d97df53aec2b8aca3d2c713b123 100644 (file)
@@ -609,7 +609,7 @@ static int amd8111e_poll(struct nic *nic, int retrieve)
        return pkt_ok;
 }
 
-static void amd8111e_disable(struct nic *nic)
+static void amd8111e_disable(struct nic *nic, void *hwdev __unused)
 {
        struct amd8111e_priv *lp = nic->priv_data;
 
index d5783ff993f65154cb8fda0c8a46831ba4fb8ac0..186cc17d4201d3d92fede3a2b7683738be28b478 100644 (file)
@@ -2671,6 +2671,12 @@ err_out_disable:
        return 0;
 }
 
+static void
+bnx2_remove(struct nic *nic, void *hwdev __unused)
+{
+       bnx2_disable(nic);
+}
+
 static struct pci_device_id bnx2_nics[] = {
        PCI_ROM(0x14e4, 0x164a, "bnx2-5706",        "Broadcom NetXtreme II BCM5706", 0),
        PCI_ROM(0x14e4, 0x164c, "bnx2-5708",        "Broadcom NetXtreme II BCM5708", 0),
@@ -2680,7 +2686,7 @@ static struct pci_device_id bnx2_nics[] = {
 
 PCI_DRIVER ( bnx2_driver, bnx2_nics, PCI_NO_CLASS );
 
-DRIVER ( "BNX2", nic_driver, pci_driver, bnx2_driver, bnx2_probe, bnx2_disable );
+DRIVER ( "BNX2", nic_driver, pci_driver, bnx2_driver, bnx2_probe, bnx2_remove );
 
 /*
 static struct pci_driver bnx2_driver __pci_driver = {
index 0c96796df397b235dd201cdcf971f0e8480c362f..307ae98116e27ab90f4640a3c5c84335db6e3830 100644 (file)
@@ -159,7 +159,7 @@ static void davicom_reset(struct nic *nic);
 static void davicom_transmit(struct nic *nic, const char *d, unsigned int t,
                           unsigned int s, const char *p);
 static int davicom_poll(struct nic *nic, int retrieve);
-static void davicom_disable(struct nic *nic);
+static void davicom_disable(struct nic *nic, void *hwdev);
 static void davicom_wait(unsigned int nticks);
 static int phy_read(int);
 static void phy_write(int, u16);
@@ -601,7 +601,7 @@ static int davicom_poll(struct nic *nic, int retrieve)
 /*********************************************************************/
 /* eth_disable - Disable the interface                               */
 /*********************************************************************/
-static void davicom_disable ( struct nic *nic ) {
+static void davicom_disable ( struct nic *nic, void *hwdev __unused ) {
 
   whereami("davicom_disable\n");
 
index 016f28bb2db51938b008ee1fcfef1bc0188c2172..30e2fcb0a02072bdea76a7e74acd2d5e0647173b 100644 (file)
@@ -644,7 +644,7 @@ static void depca_transmit(
 /**************************************************************************
 DISABLE - Turn off ethernet interface
 ***************************************************************************/
-static void depca_disable ( struct nic *nic ) {
+static void depca_disable ( struct nic *nic, void *hwdev __unused ) {
        depca_reset(nic);
 
        STOP_DEPCA(nic->ioaddr);
index 53b05815b86c3b20b629c3197c1c76a28bf5c23d..a76dd792d776c980602a432efdc1ea275c8687fb 100644 (file)
@@ -435,7 +435,7 @@ static void dmfe_transmit(struct nic *nic,
 /**************************************************************************
 DISABLE - Turn off ethernet interface
 ***************************************************************************/
-static void dmfe_disable ( struct nic *nic __unused ) {
+static void dmfe_disable ( struct nic *nic __unused, void *hwdev __unused ) {
        /* Reset & stop DM910X board */
        outl(DM910X_RESET, BASE + DCR0);
        udelay(5);
index 8e31a3bfa3bf79dcf4e5a6ca4bb72215921f42c0..01c0c43c91c574e33b4f0cc0dd1579bf798e3f9e 100644 (file)
@@ -51,7 +51,7 @@ struct epic_tx_desc {
 
 static void    epic100_open(void);
 static void    epic100_init_ring(void);
-static void    epic100_disable(struct nic *nic);
+static void    epic100_disable(struct nic *nic, void *hwdev);
 static int     epic100_poll(struct nic *nic, int retrieve);
 static void    epic100_transmit(struct nic *nic, const char *destaddr,
                                 unsigned int type, unsigned int len, const char *data);
@@ -419,7 +419,7 @@ epic100_poll(struct nic *nic, int retrieve)
 }
 
 
-static void epic100_disable ( struct nic *nic __unused ) {
+static void epic100_disable ( struct nic *nic __unused, void *hwdev __unused ) {
        /* Soft reset the chip. */
        outl(GC_SOFT_RESET, genctl);
 }
index 8e8d8500f6dc1db0416cb1ec87d2f0c9baf2fa41..a81ec6eeabd9c822603ed1effa1e4849ee9ffd8f 100644 (file)
@@ -597,7 +597,7 @@ static int ns8390_poll(struct nic *nic, int retrieve)
 /**************************************************************************
 NS8390_DISABLE - Turn off adapter
 **************************************************************************/
-static void ns8390_disable ( struct nic *nic ) {
+static void ns8390_disable ( struct nic *nic, void *hwdev __unused ) {
        ns8390_reset(nic);
 }
 
index 2feb695224ad22559d53b75438bcc8b8996d11df..9940f76a77b01b4f02490cb39d184c52bcdc810b 100644 (file)
@@ -44,7 +44,7 @@ static int prism2_pci_probe ( struct nic *nic, struct pci_device *pci ) {
   return prism2_probe ( nic, hw );
 }
 
-static void prism2_pci_disable ( struct nic *nic ) {
+static void prism2_pci_disable ( struct nic *nic, void *hwdev __unused ) {
   prism2_disable ( nic );
 }
 
index 770cf32881aa76cde522e04ea9eebbde3bc04743..f3200e89c3da247a0835292420b02b910eb95bd0 100644 (file)
@@ -99,7 +99,7 @@ static int prism2_plx_probe ( struct nic *nic, struct pci_device *pci ) {
   return prism2_probe ( nic, hw );
 }
 
-static void prism2_plx_disable ( struct nic *nic ) {
+static void prism2_plx_disable ( struct nic *nic, void *hwdev __unused ) {
   prism2_disable ( nic );
 }
 
index 8a3ac01bc407285157ff5c27b686f2ab52596bad..c8fd3e9b56c0bdd940922d593641cee9a0b41e68 100644 (file)
@@ -164,7 +164,7 @@ static void sis900_transmit(struct nic *nic, const char *d,
                             unsigned int t, unsigned int s, const char *p);
 static int  sis900_poll(struct nic *nic, int retrieve);
 
-static void sis900_disable(struct nic *nic);
+static void sis900_disable(struct nic *nic, void *hwdev);
 
 static void sis900_irq(struct nic *nic, irq_action_t action);
 
@@ -1238,7 +1238,7 @@ sis900_poll(struct nic *nic, int retrieve)
  */
 
 static void
-sis900_disable ( struct nic *nic ) {
+sis900_disable ( struct nic *nic, void *hwdev __unused ) {
 
     sis900_init(nic);
 
index 8eb09b98887704c1605ed8c4642e191231f3fdc2..0439c983fd6f412dbce6e9f9c2e89f8fab6efdb6 100644 (file)
@@ -536,7 +536,7 @@ static void sundance_transmit(struct nic *nic, const char *d,       /* Destination */
 /**************************************************************************
 DISABLE - Turn off ethernet interface
 ***************************************************************************/
-static void sundance_disable ( struct nic *nic __unused ) {
+static void sundance_disable ( struct nic *nic __unused, void *hwdev __unused) {
        /* put the card in its initial state */
        /* This function serves 3 purposes.
         * This disables DMA and interrupts so we don't receive
index 93533b4382bdd2614f97a3856c38a6e700b5e3d0..245766a877c2186f161e49bf4d1a35ca458b44be 100644 (file)
@@ -717,7 +717,7 @@ static void tlan_transmit(struct nic *nic, const char *d,   /* Destination */
 /**************************************************************************
 DISABLE - Turn off ethernet interface
 ***************************************************************************/
-static void tlan_disable ( struct nic *nic __unused ) {
+static void tlan_disable ( struct nic *nic __unused, void *hwdev __unused ) {
        /* put the card in its initial state */
        /* This function serves 3 purposes.
         * This disables DMA and interrupts so we don't receive
index fddebfe5b9afa84733c7c5672c7caacd7cabf395..c01bc208eebfd93c9ed39a2817d6e47e8b8439d7 100644 (file)
@@ -494,7 +494,7 @@ static void tulip_reset(struct nic *nic);
 static void tulip_transmit(struct nic *nic, const char *d, unsigned int t,
                            unsigned int s, const char *p);
 static int tulip_poll(struct nic *nic, int retrieve);
-static void tulip_disable(struct nic *nic);
+static void tulip_disable(struct nic *nic, void *hwdev);
 static void nway_start(struct nic *nic);
 static void pnic_do_nway(struct nic *nic);
 static void select_media(struct nic *nic, int startup);
@@ -1128,7 +1128,7 @@ static int tulip_poll(struct nic *nic, int retrieve)
 /*********************************************************************/
 /* eth_disable - Disable the interface                               */
 /*********************************************************************/
-static void tulip_disable ( struct nic *nic ) {
+static void tulip_disable ( struct nic *nic, void *hwdev __unused ) {
 
     whereami("tulip_disable\n");
 
index 72ccf3a28a314ffe755c9a4f943c6463e8e37720..0c222214e0c62ec587e0b5fc04fecfc1cc9fa665 100644 (file)
@@ -579,7 +579,7 @@ static void w89c840_transmit(
 /**************************************************************************
 w89c840_disable - Turn off ethernet interface
 ***************************************************************************/
-static void w89c840_disable ( struct nic *nic ) {
+static void w89c840_disable ( struct nic *nic, void *hwdev __unused ) {
 
     w89c840_reset(nic);
 
index 8b06e88f4837457252f4fb28ca83d5d20bec100d..8e928beb41b27e7f26707ed5ca9ac944252d9fcb 100644 (file)
@@ -217,8 +217,7 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) {
        }                                                                 \
        static inline void                                                \
        _name ## _disable ( struct nic *nic, void *hwdev ) {              \
-               void ( * _unsafe_disable ) () = _disable;                 \
-               _unsafe_disable ( nic, hwdev );                           \
+               _disable ( nic, hwdev );                                  \
        }                                                                 \
        static inline int                                                 \
        _name ## _pci_legacy_probe ( struct pci_device *pci ) {           \