Subject: Re: [PATCHv2 1/2] net: ethernet: stmmac: dwmac-rk: rework optional clock handling

From: Simon Horman <[email-masked]>
Date: Wed, 5 Apr 2023 19:42:05 +0200

On Wed, Apr 05, 2023 at 06:10:42PM +0200, Sebastian Reichel wrote:
> The clock requesting code is quite repetitive. Fix this by requesting
> the clocks in a loop. Also use devm_clk_get_optional instead of
> devm_clk_get, since the old code effectively handles them as optional
> clocks. This removes error messages about missing clocks for platforms
> not using them and correct -EPROBE_DEFER handling.
> 
> The new code also tries to get "clk_mac_ref" and "clk_mac_refout" when
> the PHY is not configured as PHY_INTERFACE_MODE_RMII to keep the code
> simple. This is possible since we use devm_clk_get_optional() for the
> clock lookup anyways.
> 
> Suggested-by: Jakub Kicinski <[email-masked]>
> Fixes: 7ad269ea1a2b7 ("GMAC: add driver for Rockchip RK3288 SoCs integrated GMAC")
> Signed-off-by: Sebastian Reichel <[email-masked]>

Reviewed-by: Simon Horman <[email-masked]>

> +	for (i=0; i < ARRAY_SIZE(clocks); i++) {

nit: spaces around '='. i.e. 'i = 0;'

> +		*clocks[i].ptr = devm_clk_get_optional(dev, clocks[i].name);
> +		if (IS_ERR(*clocks[i].ptr))
> +			return dev_err_probe(dev, PTR_ERR(*clocks[i].ptr),
> +					     "cannot get clock %s\n",
> +					     clocks[i].name);
>  	}

...