Re: [PATCH net-next 4/6] net: stmmac: rk: use stmmac_set_tx_clk_gmii()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 14, 2023 at 02:51:35PM +0100, Russell King (Oracle) wrote:
> Use stmmac_set_tx_clk_gmii().
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@xxxxxxxxxxxxxxx>
> ---
>  .../net/ethernet/stmicro/stmmac/dwmac-rk.c    | 60 +++++--------------
>  1 file changed, 16 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index d920a50dd16c..5731a73466eb 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -1081,28 +1081,14 @@ static void rk3568_set_gmac_speed(struct rk_priv_data *bsp_priv, int speed)
>  {
>  	struct clk *clk_mac_speed = bsp_priv->clks[RK_CLK_MAC_SPEED].clk;
>  	struct device *dev = &bsp_priv->pdev->dev;
> -	unsigned long rate;
> -	int ret;
> -
> -	switch (speed) {
> -	case 10:
> -		rate = 2500000;
> -		break;
> -	case 100:
> -		rate = 25000000;
> -		break;
> -	case 1000:
> -		rate = 125000000;
> -		break;
> -	default:
> -		dev_err(dev, "unknown speed value for GMAC speed=%d", speed);
> -		return;
> -	}
> -
> -	ret = clk_set_rate(clk_mac_speed, rate);
> -	if (ret)
> -		dev_err(dev, "%s: set clk_mac_speed rate %ld failed %d\n",
> -			__func__, rate, ret);
> +	int err;
> +
> +	err = stmmac_set_tx_clk_gmii(clk_mac_speed, speed);
> +	if (err == -ENOTSUPP)

> +		dev_err(dev, "invalid speed %uMbps\n", speed);
> +	else if (err)
> +		dev_err(dev, "failed to set tx rate for speed %uMbps: %pe\n",

These type specifiers should have been '%d' since the speed variable
is of the signed integer type here.

-Serge(y)

> +			speed, ERR_PTR(err));
>  }
>  
>  static const struct rk_gmac_ops rk3568_ops = {
> @@ -1387,28 +1373,14 @@ static void rv1126_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed)
>  {
>  	struct clk *clk_mac_speed = bsp_priv->clks[RK_CLK_MAC_SPEED].clk;
>  	struct device *dev = &bsp_priv->pdev->dev;
> -	unsigned long rate;
> -	int ret;
> -
> -	switch (speed) {
> -	case 10:
> -		rate = 2500000;
> -		break;
> -	case 100:
> -		rate = 25000000;
> -		break;
> -	case 1000:
> -		rate = 125000000;
> -		break;
> -	default:
> -		dev_err(dev, "unknown speed value for RGMII speed=%d", speed);
> -		return;
> -	}
> -
> -	ret = clk_set_rate(clk_mac_speed, rate);
> -	if (ret)
> -		dev_err(dev, "%s: set clk_mac_speed rate %ld failed %d\n",
> -			__func__, rate, ret);
> +	int err;
> +
> +	err = stmmac_set_tx_clk_gmii(clk_mac_speed, speed);
> +	if (err == -ENOTSUPP)
> +		dev_err(dev, "invalid speed %dMbps\n", speed);
> +	else if (err)
> +		dev_err(dev, "failed to set tx rate for speed %dMbps: %pe\n",
> +			speed, ERR_PTR(err));
>  }
>  
>  static void rv1126_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)
> -- 
> 2.30.2
> 
> 




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux