Thread (46 messages) 46 messages, 4 authors, 2025-08-04

Re: [PATCH v3 05/27] clk: mediatek: clk-mux: Add ops for mux gates with HW voter and FENC

From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Date: 2025-08-04 14:33:23
Also in: linux-arm-kernel, linux-clk, linux-devicetree, linux-mediatek, lkml

Il 04/08/25 16:05, Krzysztof Kozlowski ha scritto:
On 30/07/2025 12:56, Laura Nao wrote:
quoted
  
  	clk_mux->regmap = regmap;
+	clk_mux->regmap_hwv = regmap_hwv;
  	clk_mux->data = mux;
  	clk_mux->lock = lock;
  	clk_mux->hw.init = &init;
@@ -268,6 +329,7 @@ int mtk_clk_register_muxes(struct device *dev,
  			   struct clk_hw_onecell_data *clk_data)
  {
  	struct regmap *regmap;
+	struct regmap *regmap_hwv;
  	struct clk_hw *hw;
  	int i;
  
@@ -277,6 +339,13 @@ int mtk_clk_register_muxes(struct device *dev,
  		return PTR_ERR(regmap);
  	}
  
+	regmap_hwv = mtk_clk_get_hwv_regmap(node);
+	if (IS_ERR(regmap_hwv)) {
This is either buggy or fragile. mtk_clk_get_hwv_regmap() returns NULL
or valid pointer... or error? IS_ERR_OR_NULL is not the wait to go.

Choose one - IS_ERR or NULL, preferrably the first, since you must
handle deferred probe.
if regmap_hwv == NULL -> there is no HWV for *this* clock
if regmap_hwv == -ERROR -> there is a HWV for *this* clock, but something
                            went wrong, we have to return the error.
quoted
+		pr_err("Cannot find hardware voter regmap for %pOF: %pe\n",
+		       node, regmap_hwv);
+		return PTR_ERR(regmap_hwv);
+	}
+
  	for (i = 0; i < num; i++) {
  		const struct mtk_mux *mux = &muxes[i];
  
@@ -286,7 +355,7 @@ int mtk_clk_register_muxes(struct device *dev,
  			continue;
  		}
  
-		hw = mtk_clk_register_mux(dev, mux, regmap, lock);
+		hw = mtk_clk_register_mux(dev, mux, regmap, regmap_hwv, lock);
So NULL is passed and stored... are you sure this is 100% backwards
compatible?
Yes, it is. This got tested on multiple legacy SoCs in our lab.

Best regards,
Krzysztof
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help