Re: [PATCH 2/6] clk: divider: add error code propagation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Jules,

On 07.11.24 15:57, Jules Maselbas wrote:
> divider_get_val can return a negative error code and should not be used
> as a valid divider.
> 
> Signed-off-by: Jules Maselbas <jmaselbas@xxxxxxxx>
> ---
>  drivers/clk/clk-divider.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
> index ccab70aecc..b05b042da5 100644
> --- a/drivers/clk/clk-divider.c
> +++ b/drivers/clk/clk-divider.c
> @@ -308,6 +308,7 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
>  	struct clk *clk = clk_hw_to_clk(hw);
>  	struct clk_divider *divider = to_clk_divider(hw);
>  	unsigned int value;
> +	int ret;
>  	u32 val;
>  
>  	if (divider->flags & CLK_DIVIDER_READ_ONLY)
> @@ -320,8 +321,10 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
>  		clk_set_rate(clk_get_parent(clk), parent_rate);
>  	}
>  
> -	value = divider_get_val(rate, parent_rate, divider->table,
> +	value = ret = divider_get_val(rate, parent_rate, divider->table,
>  				divider->width, divider->flags);
> +	if (ret < 0)
> +		return ret;

Can't we just make value an int? This tidies up the code a bit at no
change of behavior.

Thanks,
Ahmad

>  
>  	val = readl(divider->reg);
>  	val &= ~(clk_div_mask(divider->width) << divider->shift);


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux