Re: [PATCH 1/4] pwm: bcm-iproc: Remove impossible comparison when validating duty cycle

From: Uwe Kleine-KÃnig
Date: Mon Jun 29 2020 - 15:46:02 EST


On Mon, Jun 29, 2020 at 01:47:49PM +0100, Lee Jones wrote:
> 'duty' here is an unsigned int, thus checking for <0 will always
> evaluate to false.
>
> Fixes the following W=1 warning:
>
> drivers/pwm/pwm-bcm-iproc.c:147:12: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
>
> Cc: Ray Jui <rjui@xxxxxxxxxxxx>
> Cc: Scott Branden <sbranden@xxxxxxxxxxxx>
> Cc: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@xxxxxxxxxxxx>
> Cc: bcm-kernel-feedback-list@xxxxxxxxxxxx
> Cc: linux-pwm@xxxxxxxxxxxxxxx
> Signed-off-by: Lee Jones <lee.jones@xxxxxxxxxx>
> ---
> drivers/pwm/pwm-bcm-iproc.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/pwm/pwm-bcm-iproc.c b/drivers/pwm/pwm-bcm-iproc.c
> index 1f829edd8ee70..46f0a45e9049c 100644
> --- a/drivers/pwm/pwm-bcm-iproc.c
> +++ b/drivers/pwm/pwm-bcm-iproc.c
> @@ -143,8 +143,7 @@ static int iproc_pwmc_apply(struct pwm_chip *chip, struct pwm_device *pwm,
> value = rate * state->duty_cycle;
> duty = div64_u64(value, div);
>
> - if (period < IPROC_PWM_PERIOD_MIN ||
> - duty < IPROC_PWM_DUTY_CYCLE_MIN)
> + if (period < IPROC_PWM_PERIOD_MIN)
> return -EINVAL;
>
> if (period <= IPROC_PWM_PERIOD_MAX &&

Acked-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>

Thanks
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |

Attachment: signature.asc
Description: PGP signature