Re: [PATCH] clk: mux: let clk_mux_val_to_index return U8_MAX in the error case

Heiner Kallweit
2023-04-13T19:27:36Z

On 13.04.2023 21:10, Stephen Boyd wrote:
> Quoting Heiner Kallweit (2023-04-11 23:19:04)
>> Currently this function may return a negative errno, but almost no
>> user checks for the error case. Only imx_clk_gpr_mux_get_parent()
>> does, but mentions in a comment that they'd prefer a dummy value.
>> Other users cast the negative errno to u8 instead, what may result
>> in unwanted results.
>> Let's deal with this by returning u8 and U8_MAX in the error case.
>> Then clk_core_get_parent_by_index() can detect that the index is
>> out of range.
>
> Is this causing problems for you?

I'm not directly impacted. I came across this when working on a driver
with the following scenario:

I have a clock muxer where I want to exclude one of the mux parents
by using clk_mux.table. If by chance the boot loader used this mux
parent, then clk_mux_val_to_index() would return an errno.
Also within clk core the return value isn't checked in
clk_mux_get_parent().