[PATCH net-next v3 08/10] net: macb: clean up tsu clk rate acquisition

Conor Dooley
2026-03-10T17:19:40Z

tsu_clk is grabbed during probe, so doesn't need to be re-grabbed here.
pclk is mandatory, probe will fail if it is err/NULL, so there's no need
to check it here or have a !pclk 3rd arm. Simplify gem_get_tsu_rate() to
account for these facts.

Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
---
drivers/net/ethernet/cadence/macb_main.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 6b37598ac57cd..38e75c2e097bf 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3527,16 +3527,14 @@ static unsigned int gem_get_tsu_rate(struct macb *bp)
struct clk *tsu_clk;
unsigned int tsu_rate;

- tsu_clk = devm_clk_get(&bp->pdev->dev, "tsu_clk");
- if (!IS_ERR(tsu_clk))
- tsu_rate = clk_get_rate(tsu_clk);
- /* try pclk instead */
- else if (!IS_ERR(bp->pclk)) {
+ if (!IS_ERR_OR_NULL(bp->tsu_clk)) {
+ tsu_rate = clk_get_rate(bp->tsu_clk);
+ } else {
tsu_clk = bp->pclk;
tsu_rate = clk_get_rate(tsu_clk);
dev_warn(&bp->pdev->dev, "devicetree missing tsu_clk, using pclk as fallback\n");
- } else
- return -ENOTSUPP;
+ }
+
return tsu_rate;
}