Skip to content

Commit

Permalink
bnx2x: Remove config_init_t function casts
Browse files Browse the repository at this point in the history
No callers of .config_init check return values. Remove the casting and
change all callbacks to have the correct function prototype.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kees Cook authored and David S. Miller committed Nov 16, 2019
1 parent 2c855d7 commit 3e19d1f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 61 deletions.
105 changes: 46 additions & 59 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -7364,9 +7364,9 @@ static void bnx2x_8073_specific_func(struct bnx2x_phy *phy,
}
}

static int bnx2x_8073_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
static void bnx2x_8073_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
{
struct bnx2x *bp = params->bp;
u16 val = 0, tmp1;
Expand Down Expand Up @@ -7427,7 +7427,7 @@ static int bnx2x_8073_config_init(struct bnx2x_phy *phy,
if (params->loopback_mode == LOOPBACK_EXT) {
bnx2x_807x_force_10G(bp, phy);
DP(NETIF_MSG_LINK, "Forced speed 10G on 807X\n");
return 0;
return;
} else {
bnx2x_cl45_write(bp, phy,
MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0002);
Expand Down Expand Up @@ -7509,7 +7509,6 @@ static int bnx2x_8073_config_init(struct bnx2x_phy *phy,
bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200);
DP(NETIF_MSG_LINK, "807x Autoneg Restart: Advertise 1G=%x, 10G=%x\n",
((val & (1<<5)) > 0), ((val & (1<<7)) > 0));
return 0;
}

static u8 bnx2x_8073_read_status(struct bnx2x_phy *phy,
Expand Down Expand Up @@ -7676,9 +7675,9 @@ static void bnx2x_8073_link_reset(struct bnx2x_phy *phy,
/******************************************************************/
/* BCM8705 PHY SECTION */
/******************************************************************/
static int bnx2x_8705_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
static void bnx2x_8705_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
{
struct bnx2x *bp = params->bp;
DP(NETIF_MSG_LINK, "init 8705\n");
Expand All @@ -7700,7 +7699,6 @@ static int bnx2x_8705_config_init(struct bnx2x_phy *phy,
MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_CNTL, 0x1);
/* BCM8705 doesn't have microcode, hence the 0 */
bnx2x_save_spirom_version(bp, params->port, params->shmem_base, 0);
return 0;
}

static u8 bnx2x_8705_read_status(struct bnx2x_phy *phy,
Expand Down Expand Up @@ -8887,9 +8885,9 @@ static u8 bnx2x_8706_8726_read_status(struct bnx2x_phy *phy,
/******************************************************************/
/* BCM8706 PHY SECTION */
/******************************************************************/
static u8 bnx2x_8706_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
static void bnx2x_8706_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
{
u32 tx_en_mode;
u16 cnt, val, tmp1;
Expand Down Expand Up @@ -8989,8 +8987,6 @@ static u8 bnx2x_8706_config_init(struct bnx2x_phy *phy,
bnx2x_cl45_write(bp, phy,
MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, tmp1);
}

return 0;
}

static u8 bnx2x_8706_read_status(struct bnx2x_phy *phy,
Expand Down Expand Up @@ -9070,9 +9066,9 @@ static u8 bnx2x_8726_read_status(struct bnx2x_phy *phy,
}


static int bnx2x_8726_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
static void bnx2x_8726_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
{
struct bnx2x *bp = params->bp;
DP(NETIF_MSG_LINK, "Initializing BCM8726\n");
Expand Down Expand Up @@ -9150,9 +9146,6 @@ static int bnx2x_8726_config_init(struct bnx2x_phy *phy,
MDIO_PMA_REG_8726_TX_CTRL2,
phy->tx_preemphasis[1]);
}

return 0;

}

static void bnx2x_8726_link_reset(struct bnx2x_phy *phy,
Expand Down Expand Up @@ -9288,9 +9281,9 @@ static void bnx2x_8727_config_speed(struct bnx2x_phy *phy,
}
}

static int bnx2x_8727_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
static void bnx2x_8727_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
{
u32 tx_en_mode;
u16 tmp1, mod_abs, tmp2;
Expand Down Expand Up @@ -9370,8 +9363,6 @@ static int bnx2x_8727_config_init(struct bnx2x_phy *phy,
MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER,
(tmp2 & 0x7fff));
}

return 0;
}

static void bnx2x_8727_handle_mod_abs(struct bnx2x_phy *phy,
Expand Down Expand Up @@ -9946,9 +9937,9 @@ static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy,
return 0;
}

static int bnx2x_8481_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
static void bnx2x_8481_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
{
struct bnx2x *bp = params->bp;
/* Restore normal power mode*/
Expand All @@ -9960,7 +9951,7 @@ static int bnx2x_8481_config_init(struct bnx2x_phy *phy,
bnx2x_wait_reset_complete(bp, phy, params);

bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15);
return bnx2x_848xx_cmn_config_init(phy, params, vars);
bnx2x_848xx_cmn_config_init(phy, params, vars);
}

#define PHY848xx_CMDHDLR_WAIT 300
Expand Down Expand Up @@ -10283,9 +10274,9 @@ static int bnx2x_8483x_enable_eee(struct bnx2x_phy *phy,
}

#define PHY84833_CONSTANT_LATENCY 1193
static int bnx2x_848x3_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
static void bnx2x_848x3_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
{
struct bnx2x *bp = params->bp;
u8 port, initialize = 1;
Expand Down Expand Up @@ -10430,7 +10421,7 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy,
if (rc) {
DP(NETIF_MSG_LINK, "Failed to configure EEE timers\n");
bnx2x_8483x_disable_eee(phy, params, vars);
return rc;
return;
}

if ((phy->req_duplex == DUPLEX_FULL) &&
Expand All @@ -10442,7 +10433,7 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy,
rc = bnx2x_8483x_disable_eee(phy, params, vars);
if (rc) {
DP(NETIF_MSG_LINK, "Failed to set EEE advertisement\n");
return rc;
return;
}
} else {
vars->eee_status &= ~SHMEM_EEE_SUPPORTED_MASK;
Expand Down Expand Up @@ -10481,7 +10472,6 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy,
MDIO_84833_TOP_CFG_XGPHY_STRAP1,
(u16)~MDIO_84833_SUPER_ISOLATE);
}
return rc;
}

static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy,
Expand Down Expand Up @@ -11038,9 +11028,9 @@ static void bnx2x_54618se_specific_func(struct bnx2x_phy *phy,
}
}

static int bnx2x_54618se_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
static void bnx2x_54618se_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
{
struct bnx2x *bp = params->bp;
u8 port;
Expand Down Expand Up @@ -11240,8 +11230,6 @@ static int bnx2x_54618se_config_init(struct bnx2x_phy *phy,

bnx2x_cl22_write(bp, phy,
MDIO_PMA_REG_CTRL, autoneg_val);

return 0;
}


Expand Down Expand Up @@ -11465,9 +11453,9 @@ static void bnx2x_7101_config_loopback(struct bnx2x_phy *phy,
MDIO_XS_DEVAD, MDIO_XS_SFX7101_XGXS_TEST1, 0x100);
}

static int bnx2x_7101_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
static void bnx2x_7101_config_init(struct bnx2x_phy *phy,
struct link_params *params,
struct link_vars *vars)
{
u16 fw_ver1, fw_ver2, val;
struct bnx2x *bp = params->bp;
Expand Down Expand Up @@ -11502,7 +11490,6 @@ static int bnx2x_7101_config_init(struct bnx2x_phy *phy,
MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER2, &fw_ver2);
bnx2x_save_spirom_version(bp, params->port,
(u32)(fw_ver1<<16 | fw_ver2), phy->ver_addr);
return 0;
}

static u8 bnx2x_7101_read_status(struct bnx2x_phy *phy,
Expand Down Expand Up @@ -11671,7 +11658,7 @@ static const struct bnx2x_phy phy_serdes = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_xgxs_config_init,
.config_init = bnx2x_xgxs_config_init,
.read_status = bnx2x_link_settings_status,
.link_reset = bnx2x_int_link_reset,
.config_loopback = NULL,
Expand Down Expand Up @@ -11707,7 +11694,7 @@ static const struct bnx2x_phy phy_xgxs = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_xgxs_config_init,
.config_init = bnx2x_xgxs_config_init,
.read_status = bnx2x_link_settings_status,
.link_reset = bnx2x_int_link_reset,
.config_loopback = bnx2x_set_xgxs_loopback,
Expand Down Expand Up @@ -11745,7 +11732,7 @@ static const struct bnx2x_phy phy_warpcore = {
.speed_cap_mask = 0,
/* req_duplex = */0,
/* rsrv = */0,
.config_init = (config_init_t)bnx2x_warpcore_config_init,
.config_init = bnx2x_warpcore_config_init,
.read_status = bnx2x_warpcore_read_status,
.link_reset = bnx2x_warpcore_link_reset,
.config_loopback = bnx2x_set_warpcore_loopback,
Expand Down Expand Up @@ -11776,7 +11763,7 @@ static const struct bnx2x_phy phy_7101 = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_7101_config_init,
.config_init = bnx2x_7101_config_init,
.read_status = bnx2x_7101_read_status,
.link_reset = bnx2x_common_ext_link_reset,
.config_loopback = bnx2x_7101_config_loopback,
Expand Down Expand Up @@ -11807,7 +11794,7 @@ static const struct bnx2x_phy phy_8073 = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_8073_config_init,
.config_init = bnx2x_8073_config_init,
.read_status = bnx2x_8073_read_status,
.link_reset = bnx2x_8073_link_reset,
.config_loopback = NULL,
Expand Down Expand Up @@ -11835,7 +11822,7 @@ static const struct bnx2x_phy phy_8705 = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_8705_config_init,
.config_init = bnx2x_8705_config_init,
.read_status = bnx2x_8705_read_status,
.link_reset = bnx2x_common_ext_link_reset,
.config_loopback = NULL,
Expand Down Expand Up @@ -11864,7 +11851,7 @@ static const struct bnx2x_phy phy_8706 = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_8706_config_init,
.config_init = bnx2x_8706_config_init,
.read_status = bnx2x_8706_read_status,
.link_reset = bnx2x_common_ext_link_reset,
.config_loopback = NULL,
Expand Down Expand Up @@ -11896,7 +11883,7 @@ static const struct bnx2x_phy phy_8726 = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_8726_config_init,
.config_init = bnx2x_8726_config_init,
.read_status = bnx2x_8726_read_status,
.link_reset = bnx2x_8726_link_reset,
.config_loopback = bnx2x_8726_config_loopback,
Expand Down Expand Up @@ -11927,7 +11914,7 @@ static const struct bnx2x_phy phy_8727 = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_8727_config_init,
.config_init = bnx2x_8727_config_init,
.read_status = bnx2x_8727_read_status,
.link_reset = bnx2x_8727_link_reset,
.config_loopback = NULL,
Expand Down Expand Up @@ -11962,7 +11949,7 @@ static const struct bnx2x_phy phy_8481 = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_8481_config_init,
.config_init = bnx2x_8481_config_init,
.read_status = bnx2x_848xx_read_status,
.link_reset = bnx2x_8481_link_reset,
.config_loopback = NULL,
Expand Down Expand Up @@ -11999,7 +11986,7 @@ static const struct bnx2x_phy phy_84823 = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_848x3_config_init,
.config_init = bnx2x_848x3_config_init,
.read_status = bnx2x_848xx_read_status,
.link_reset = bnx2x_848x3_link_reset,
.config_loopback = NULL,
Expand Down Expand Up @@ -12034,7 +12021,7 @@ static const struct bnx2x_phy phy_84833 = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_848x3_config_init,
.config_init = bnx2x_848x3_config_init,
.read_status = bnx2x_848xx_read_status,
.link_reset = bnx2x_848x3_link_reset,
.config_loopback = NULL,
Expand Down Expand Up @@ -12068,7 +12055,7 @@ static const struct bnx2x_phy phy_84834 = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_848x3_config_init,
.config_init = bnx2x_848x3_config_init,
.read_status = bnx2x_848xx_read_status,
.link_reset = bnx2x_848x3_link_reset,
.config_loopback = NULL,
Expand Down Expand Up @@ -12102,7 +12089,7 @@ static const struct bnx2x_phy phy_84858 = {
.speed_cap_mask = 0,
.req_duplex = 0,
.rsrv = 0,
.config_init = (config_init_t)bnx2x_848x3_config_init,
.config_init = bnx2x_848x3_config_init,
.read_status = bnx2x_848xx_read_status,
.link_reset = bnx2x_848x3_link_reset,
.config_loopback = NULL,
Expand Down Expand Up @@ -12136,7 +12123,7 @@ static const struct bnx2x_phy phy_54618se = {
.speed_cap_mask = 0,
/* req_duplex = */0,
/* rsrv = */0,
.config_init = (config_init_t)bnx2x_54618se_config_init,
.config_init = bnx2x_54618se_config_init,
.read_status = bnx2x_54618se_read_status,
.link_reset = bnx2x_54618se_link_reset,
.config_loopback = bnx2x_54618se_config_loopback,
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ struct link_vars;
struct link_params;
struct bnx2x_phy;

typedef u8 (*config_init_t)(struct bnx2x_phy *phy, struct link_params *params,
struct link_vars *vars);
typedef void (*config_init_t)(struct bnx2x_phy *phy, struct link_params *params,
struct link_vars *vars);
typedef u8 (*read_status_t)(struct bnx2x_phy *phy, struct link_params *params,
struct link_vars *vars);
typedef void (*link_reset_t)(struct bnx2x_phy *phy,
Expand Down

0 comments on commit 3e19d1f

Please sign in to comment.