From: David Lechner Date: Wed, 14 Jan 2026 22:58:57 +0000 (-0600) Subject: clk: mtk: use IS_ERR_VALUE() to check rate return values X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80cb8a0e895d5ec835dda0ebaf14e293b4039c60;p=thirdparty%2Fu-boot.git clk: mtk: use IS_ERR_VALUE() to check rate return values Replace casting with long to IS_ERR_VALUE() macro to check for error return values from rate calculation functions. This is the recommended way to check the return value from clock rate functions. Signed-off-by: David Lechner --- diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index acc28d1da1a..b4de38719e1 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "clk-mtk.h" @@ -236,10 +237,10 @@ static void mtk_clk_print_rate(struct udevice *dev, int mapped_id) .dev = dev, .id = mapped_id, }; - long rate = clk_get_rate(&clk); + ulong rate = clk_get_rate(&clk); - if (rate < 0) - printf(", error! clk_get_rate() failed: %ld", rate); + if (IS_ERR_VALUE(rate)) + printf(", error! clk_get_rate() failed: %d", (int)rate); else printf(", Rate: %lu Hz", rate); } @@ -650,7 +651,7 @@ static ulong mtk_topckgen_get_factor_rate(struct clk *clk, u32 off) rate = priv->tree->xtal_rate; } - if (((long)rate) < 0) + if (IS_ERR_VALUE(rate)) return rate; return mtk_factor_recalc_rate(fdiv, rate); @@ -974,7 +975,7 @@ static ulong mtk_infrasys_get_factor_rate(struct clk *clk, u32 off) rate = mtk_clk_find_parent_rate(clk, fdiv->parent, NULL); } - if (((long)rate) < 0) + if (IS_ERR_VALUE(rate)) return rate; return mtk_factor_recalc_rate(fdiv, rate);