clk: mediatek: mux: Reverse check for existing clk to reduce nesting level
authorChen-Yu Tsai <wenst@chromium.org>
Tue, 8 Feb 2022 12:40:26 +0000 (20:40 +0800)
committerStephen Boyd <sboyd@kernel.org>
Thu, 17 Feb 2022 20:12:24 +0000 (12:12 -0800)
The clk registration code here currently does:

    if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) {
            ... do clk registration ...
    }

This extra level of nesting wastes screen real estate.

Reduce the nesting level by reversing the conditional shown above.
Other than that, functionality is not changed.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220208124034.414635-24-wenst@chromium.org
Reviewed-by: Chun-Jie Chen <chun-jie.chen@mediatek.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/mediatek/clk-mux.c

index 01af6a5..70aa421 100644 (file)
@@ -208,16 +208,17 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes,
        for (i = 0; i < num; i++) {
                const struct mtk_mux *mux = &muxes[i];
 
-               if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) {
-                       clk = mtk_clk_register_mux(mux, regmap, lock);
+               if (!IS_ERR_OR_NULL(clk_data->clks[mux->id]))
+                       continue;
 
-                       if (IS_ERR(clk)) {
-                               pr_err("Failed to register clk %s: %pe\n", mux->name, clk);
-                               continue;
-                       }
+               clk = mtk_clk_register_mux(mux, regmap, lock);
 
-                       clk_data->clks[mux->id] = clk;
+               if (IS_ERR(clk)) {
+                       pr_err("Failed to register clk %s: %pe\n", mux->name, clk);
+                       continue;
                }
+
+               clk_data->clks[mux->id] = clk;
        }
 
        return 0;