[RFC] serial: mxc: get the clock frequency from the used clock for the device
Michael Walle
michael at walle.cc
Thu Mar 17 15:47:11 CET 2022
>> + struct clk clk;
>> + if(!clk_get_by_name(dev, "ipg", &clk))
>> + rate = clk_get_rate(&clk);
>> + }
>> +
>> + /* as fallback we try to get the clk rate that way */
>> + if (rate == 0)
>
> !rate || IS_ERR_VALUE(rate)
This looked so weird I had to actually look at clk_get_rate()
in u-boot.
/**
* clk_get_rate() - Get current clock rate.
* @clk: A clock struct that was previously successfully requested by
* clk_request/get_by_*().
*
* Return: clock rate in Hz on success, 0 for invalid clock, or -ve
error code
* for other errors.
*/
ulong clk_get_rate(struct clk *clk);
How can an ulong return a negative error value? What if the clock speed
happens to be the same as -errno?
-michael
More information about the U-Boot
mailing list