On 07/06/2026 17:41, Naveen Kumar Chaudhary wrote:
> get_clk_cfg() and get_clk_div_rate() return 'int' but operate on
> 'unsigned long' clock frequencies. If a supported frequency exceeds
> INT_MAX, the return value gets silently truncated or sign-extended,
> causing the caller to misinterpret valid clock rates.
>
> Change both functions to return 'unsigned long' to match the data type
> they actually operate on. This matches the callers accepted data types
> as well.
>
> Signed-off-by: Naveen Kumar Chaudhary <[email protected]>
Reviewed-by: Casey Connolly <[email protected]>
> ---
> drivers/serial/serial_msm_geni.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/serial/serial_msm_geni.c
> b/drivers/serial/serial_msm_geni.c
> index 3dca581f68f..9de193355e4 100644
> --- a/drivers/serial/serial_msm_geni.c
> +++ b/drivers/serial/serial_msm_geni.c
> @@ -109,7 +109,7 @@ unsigned long root_freq[] = {7372800, 14745600,
> 19200000, 29491200,
> *
> * Return: frequency, supported by clock supplier, multiple of clk_freq.
> */
> -static int get_clk_cfg(unsigned long clk_freq)
> +static unsigned long get_clk_cfg(unsigned long clk_freq)
> {
> for (int i = 0; i < ARRAY_SIZE(root_freq); i++) {
> if (!(root_freq[i] % clk_freq))
> @@ -130,7 +130,7 @@ static int get_clk_cfg(unsigned long clk_freq)
> *
> * Return: frequency, supported by clock supplier, multiple of clk_freq.
> */
> -static int get_clk_div_rate(u32 baud, u64 sampling_rate, u32 *clk_div)
> +static unsigned long get_clk_div_rate(u32 baud, u64 sampling_rate, u32
> *clk_div)
> {
> unsigned long ser_clk;
> unsigned long desired_clk;
--
// Casey (she/her)