[PATCH v3 05/27] clk: mediatek: clk-mux: Add ops for mux gates with HW voter and FENC
AngeloGioacchino Del Regno
angelogioacchino.delregno at collabora.com
Mon Aug 4 07:33:20 PDT 2025
Il 04/08/25 16:05, Krzysztof Kozlowski ha scritto:
> 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.
>
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.
>> + 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
More information about the Linux-mediatek
mailing list