On 3/6/25 11:56, Cheick Traore wrote:
> It was possible to provide a duty_ns greater than period_ns to
> "pwm config" command. The framework must check the values before
> providing them to drivers.
> 
> Signed-off-by: Cheick Traore <cheick.tra...@foss.st.com>
> ---
> 
>  drivers/pwm/pwm-uclass.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/pwm/pwm-uclass.c b/drivers/pwm/pwm-uclass.c
> index 6543db1d623..b4491f7dcd4 100644
> --- a/drivers/pwm/pwm-uclass.c
> +++ b/drivers/pwm/pwm-uclass.c
> @@ -27,6 +27,9 @@ int pwm_set_config(struct udevice *dev, uint channel, uint 
> period_ns,
>       if (!ops->set_config)
>               return -ENOSYS;
>  
> +     if (duty_ns > period_ns)
> +             return -EINVAL;
> +
>       return ops->set_config(dev, channel, period_ns, duty_ns);
>  }
>  
Reviewed-by: Patrice Chotard <patrice.chot...@foss.st.com>

Thanks
Patrice

Reply via email to