]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
clk: mtk: use IS_ERR_VALUE() to check rate return values
authorDavid Lechner <dlechner@baylibre.com>
Wed, 14 Jan 2026 22:58:57 +0000 (16:58 -0600)
committerTom Rini <trini@konsulko.com>
Wed, 21 Jan 2026 19:30:58 +0000 (13:30 -0600)
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 <dlechner@baylibre.com>
drivers/clk/mediatek/clk-mtk.c

index acc28d1da1a09a3afe3af6b7813bc6919f01c5fa..b4de38719e1cc6229e19155b230c5fff931d939e 100644 (file)
@@ -12,6 +12,7 @@
 #include <asm/io.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
+#include <linux/err.h>
 
 #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);