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

Krzysztof Kozlowski krzk at kernel.org
Mon Aug 4 07:05:35 PDT 2025


On 30/07/2025 12:56, Laura Nao wrote:
>  
>  	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.

> +		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?



Best regards,
Krzysztof



More information about the Linux-mediatek mailing list