[PATCH net-next] net: stmmac: dwmac-rk: split gmac_clk_enable into enable/disable

Maxime Chevallier maxime.chevallier at bootlin.com
Thu Nov 19 00:37:08 PST 2026


Hi,

I missed that one, please make sure to run get_maintainers :)

On 11/17/26 19:25, Coia Prant wrote:
> As the great Linus Torvalds once said in
> Documentation/process/coding-style.rst:
> 
>   "If you need more than 3 levels of indentation, you're screwed anyway,
>    and should fix your program."
> 
> The gmac_clk_enable() function previously used a 'bool enable' parameter
> to handle both clock enabling and disabling. This resulted in deeply
> nested if/else blocks, which made the error handling and rollback paths
> cumbersome and prone to bugs.
> 
> This complexity has led to bugs, such as the bulk clock leak fixed by
> commit 8db67bb6a1ff ("net: ethernet: stmmac: dwmac-rk: fix bulk clock leak when the PHY clock fails").
> 
> Split the function into two distinct helpers: gmac_clk_enable() and
> gmac_clk_disable(). This flattens the code, removes the boolean flag,
> makes the caller's intent much clearer, and simplifies the error
> unwinding logic.
> 
> Additionally, this refactoring aids compiler inlining and CPU branch
> prediction (trust me). The reason is simple: no branch, no prediction.
> While the compiler might optimize it, there's no guarantee it will :P
> 
> Signed-off-by: Coia Prant <coiaprant at gmail.com>

Reviewed-by: Maxime Chevallier <maxime.chevallier at bootlin.com>

Maxime




More information about the Linux-rockchip mailing list