Re: [PATCH v3 04/16] net: phy: Add helper for mapping RGMII link speed to clock rate

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

 



On Sun, Oct 13, 2024 at 11:27:39PM +0200, Jan Petrous via B4 Relay wrote:
> From: "Jan Petrous (OSS)" <jan.petrous@xxxxxxxxxxx>
> 
> The helper rgmii_clock() implemented Russel's hint during stmmac
> glue driver review:
> 
>   > We seem to have multiple cases of very similar logic in lots of stmmac
>   > platform drivers, and I think it's about time we said no more to this.
>   > So, what I think we should do is as follows:
>   >
>   > add the following helper - either in stmmac, or more generically
>   > (phylib? - in which case its name will need changing.)
>   >
>   > static long stmmac_get_rgmii_clock(int speed)
>   > {
>   >        switch (speed) {
>   >        case SPEED_10:
>   >                return 2500000;
>   >
>   >        case SPEED_100:
>   >                return 25000000;
>   >
>   >        case SPEED_1000:
>   >                return 125000000;
>   >
>   >        default:
>   >                return -ENVAL;
>   >        }
>   > }
>   >
>   > Then, this can become:
>   >
>   >        long tx_clk_rate;
>   >
>   >        ...
>   >
>   >        tx_clk_rate = stmmac_get_rgmii_clock(speed);
>   >        if (tx_clk_rate < 0) {
>   >                dev_err(gmac->dev, "Unsupported/Invalid speed: %d\n", speed);
>   >                return;
>   >        }
>   >
>   >        ret = clk_set_rate(gmac->tx_clk, tx_clk_rate);
> 
> Suggested-by: Russell King (Oracle) <rmk+kernel@xxxxxxxxxxxxxxx>
> Signed-off-by: Jan Petrous (OSS) <jan.petrous@xxxxxxxxxxx>

But of an unusual commit message, but it does explain the "Why?".

Reviewed-by: Andrew Lunn <andrew@xxxxxxx>

>  
> +/**
> + * rgmii_clock - map link speed to the clock rate
> + * @speed: link speed value
> + *
> + * Description: maps RGMII supported link speeds
> + * into the clock rates.
> + */

A Returns: line would be nice. 

	Andrew




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux