Skip to content

Commit

Permalink
net: stmmac: "speed" passed to fix_mac_speed is an int
Browse files Browse the repository at this point in the history
priv->plat->fix_mac_speed() is called from stmmac_mac_link_up(), which
is passed the speed as an "int". However, fix_mac_speed() implicitly
casts this to an unsigned int. Some platform glue code print this value
using %u, others with %d. Some implicitly cast it back to an int, and
others to u32.

Good practice is to use one type and only one type to represent a value
being passed around a driver.

Switch all of these over to consistently use "int" when dealing with a
speed passed from stmmac_mac_link_up(), even though the speed will
always be positive.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Link: https://patch.msgid.link/E1tkKmN-004ObM-Ge@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Russell King (Oracle) authored and Jakub Kicinski committed Feb 20, 2025
1 parent bc9d75b commit ac9a858
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 32 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int dwc_qos_probe(struct platform_device *pdev,
#define AUTO_CAL_STATUS 0x880c
#define AUTO_CAL_STATUS_ACTIVE BIT(31)

static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mode)
static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
{
struct tegra_eqos *eqos = priv;
bool needs_calibration = false;
Expand All @@ -160,7 +160,7 @@ static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mo
break;

default:
dev_err(eqos->dev, "invalid speed %u\n", speed);
dev_err(eqos->dev, "invalid speed %d\n", speed);
break;
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct imx_dwmac_ops {

int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
int (*set_intf_mode)(struct plat_stmmacenet_data *plat_dat);
void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode);
void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);
};

struct imx_priv_data {
Expand Down Expand Up @@ -192,7 +192,7 @@ static void imx_dwmac_exit(struct platform_device *pdev, void *priv)
/* nothing to do now */
}

static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode)
static void imx_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
{
struct plat_stmmacenet_data *plat_dat;
struct imx_priv_data *dwmac = priv;
Expand All @@ -208,7 +208,7 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mod

rate = rgmii_clock(speed);
if (rate < 0) {
dev_err(dwmac->dev, "invalid speed %u\n", speed);
dev_err(dwmac->dev, "invalid speed %d\n", speed);
return;
}

Expand All @@ -217,7 +217,7 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mod
dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate);
}

static void imx93_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode)
static void imx93_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
{
struct imx_priv_data *dwmac = priv;
unsigned int iface;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ struct intel_dwmac {
};

struct intel_dwmac_data {
void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode);
void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);
unsigned long ptp_ref_clk_rate;
unsigned long tx_clk_rate;
bool tx_clk_en;
};

static void kmb_eth_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
static void kmb_eth_fix_mac_speed(void *priv, int speed, unsigned int mode)
{
struct intel_dwmac *dwmac = priv;
long rate;
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct ipq806x_gmac {
phy_interface_t phy_mode;
};

static int get_clk_div_sgmii(struct ipq806x_gmac *gmac, unsigned int speed)
static int get_clk_div_sgmii(struct ipq806x_gmac *gmac, int speed)
{
struct device *dev = &gmac->pdev->dev;
int div;
Expand All @@ -138,7 +138,7 @@ static int get_clk_div_sgmii(struct ipq806x_gmac *gmac, unsigned int speed)
return div;
}

static int get_clk_div_rgmii(struct ipq806x_gmac *gmac, unsigned int speed)
static int get_clk_div_rgmii(struct ipq806x_gmac *gmac, int speed)
{
struct device *dev = &gmac->pdev->dev;
int div;
Expand All @@ -164,7 +164,7 @@ static int get_clk_div_rgmii(struct ipq806x_gmac *gmac, unsigned int speed)
return div;
}

static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, unsigned int speed)
static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, int speed)
{
uint32_t clk_bits, val;
int div;
Expand Down Expand Up @@ -260,7 +260,7 @@ static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac)
return PTR_ERR_OR_ZERO(gmac->qsgmii_csr);
}

static void ipq806x_gmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
static void ipq806x_gmac_fix_mac_speed(void *priv, int speed, unsigned int mode)
{
struct ipq806x_gmac *gmac = priv;

Expand Down
3 changes: 1 addition & 2 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ static struct stmmac_pci_info loongson_gmac_pci_info = {
.setup = loongson_gmac_data,
};

static void loongson_gnet_fix_speed(void *priv, unsigned int speed,
unsigned int mode)
static void loongson_gnet_fix_speed(void *priv, int speed, unsigned int mode)
{
struct loongson_data *ld = (struct loongson_data *)priv;
struct net_device *ndev = dev_get_drvdata(ld->dev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct meson_dwmac {
void __iomem *reg;
};

static void meson6_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
static void meson6_dwmac_fix_mac_speed(void *priv, int speed, unsigned int mode)
{
struct meson_dwmac *dwmac = priv;
unsigned int val;
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct qcom_ethqos {
unsigned int link_clk_rate;
struct clk *link_clk;
struct phy *serdes_phy;
unsigned int speed;
int speed;
int serdes_speed;
phy_interface_t phy_mode;

Expand Down Expand Up @@ -175,7 +175,7 @@ static void rgmii_dump(void *priv)
#define RGMII_ID_MODE_10_LOW_SVS_CLK_FREQ (5 * 1000 * 1000UL)

static void
ethqos_update_link_clk(struct qcom_ethqos *ethqos, unsigned int speed)
ethqos_update_link_clk(struct qcom_ethqos *ethqos, int speed)
{
if (!phy_interface_mode_is_rgmii(ethqos->phy_mode))
return;
Expand Down Expand Up @@ -699,7 +699,7 @@ static int ethqos_configure(struct qcom_ethqos *ethqos)
return ethqos->configure_func(ethqos);
}

static void ethqos_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
static void ethqos_fix_mac_speed(void *priv, int speed, unsigned int mode)
{
struct qcom_ethqos *ethqos = priv;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1920,7 +1920,7 @@ static void rk_gmac_powerdown(struct rk_priv_data *gmac)
gmac_clk_enable(gmac, false);
}

static void rk_fix_speed(void *priv, unsigned int speed, unsigned int mode)
static void rk_fix_speed(void *priv, int speed, unsigned int mode)
{
struct rk_priv_data *bsp_priv = priv;
struct device *dev = &bsp_priv->pdev->dev;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void s32_gmac_exit(struct platform_device *pdev, void *priv)
clk_disable_unprepare(gmac->rx_clk);
}

static void s32_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
static void s32_fix_mac_speed(void *priv, int speed, unsigned int mode)
{
struct s32_priv_data *gmac = priv;
long tx_clk_rate;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct socfpga_dwmac {
struct mdio_device *pcs_mdiodev;
};

static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
static void socfpga_dwmac_fix_mac_speed(void *priv, int speed, unsigned int mode)
{
struct socfpga_dwmac *dwmac = (struct socfpga_dwmac *)priv;
void __iomem *splitter_base = dwmac->splitter_base;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ struct starfive_dwmac {
const struct starfive_dwmac_data *data;
};

static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
static void starfive_dwmac_fix_mac_speed(void *priv, int speed, unsigned int mode)
{
struct starfive_dwmac *dwmac = priv;
long rate;
int err;

rate = rgmii_clock(speed);
if (rate < 0) {
dev_err(dwmac->dev, "invalid speed %u\n", speed);
dev_err(dwmac->dev, "invalid speed %d\n", speed);
return;
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ struct sti_dwmac {
int clk_sel_reg; /* GMAC ext clk selection register */
struct regmap *regmap;
bool gmac_en;
u32 speed;
void (*fix_retime_src)(void *priv, unsigned int speed, unsigned int mode);
int speed;
void (*fix_retime_src)(void *priv, int speed, unsigned int mode);
};

struct sti_dwmac_of_data {
void (*fix_retime_src)(void *priv, unsigned int speed, unsigned int mode);
void (*fix_retime_src)(void *priv, int speed, unsigned int mode);
};

static u32 phy_intf_sels[] = {
Expand Down Expand Up @@ -132,7 +132,7 @@ static u32 stih4xx_tx_retime_val[] = {
| STIH4XX_ETH_SEL_INTERNAL_NOTEXT_PHYCLK,
};

static void stih4xx_fix_retime_src(void *priv, u32 spd, unsigned int mode)
static void stih4xx_fix_retime_src(void *priv, int spd, unsigned int mode)
{
struct sti_dwmac *dwmac = priv;
u32 src = dwmac->tx_retime_src;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void sun7i_gmac_exit(struct platform_device *pdev, void *priv)
regulator_disable(gmac->regulator);
}

static void sun7i_fix_speed(void *priv, unsigned int speed, unsigned int mode)
static void sun7i_fix_speed(void *priv, int speed, unsigned int mode)
{
struct sunxi_priv_data *gmac = priv;

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static int thead_dwmac_set_txclk_dir(struct plat_stmmacenet_data *plat)
return 0;
}

static void thead_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode)
static void thead_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
{
struct plat_stmmacenet_data *plat;
struct thead_dwmac *dwmac = priv;
Expand Down Expand Up @@ -142,7 +142,7 @@ static void thead_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int m
div = rate * 10 / GMAC_MII_RATE;
break;
default:
dev_err(dwmac->dev, "invalid speed %u\n", speed);
dev_err(dwmac->dev, "invalid speed %d\n", speed);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct visconti_eth {
spinlock_t lock; /* lock to protect register update */
};

static void visconti_eth_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
static void visconti_eth_fix_mac_speed(void *priv, int speed, unsigned int mode)
{
struct visconti_eth *dwmac = priv;
struct net_device *netdev = dev_get_drvdata(dwmac->dev);
Expand Down
2 changes: 1 addition & 1 deletion include/linux/stmmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct plat_stmmacenet_data {
u8 tx_sched_algorithm;
struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];
struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES];
void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode);
void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);
int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
int (*serdes_powerup)(struct net_device *ndev, void *priv);
void (*serdes_powerdown)(struct net_device *ndev, void *priv);
Expand Down

0 comments on commit ac9a858

Please sign in to comment.