2021-03-31 15:57:47

by Vinod Koul

[permalink] [raw]
Subject: [PATCH V2] soundwire: qcom: use signed variable for error return

We get warning of using a unsigned variable being compared to less than
zero. The comparison is correct as it checks for errors from previous
call to qcom_swrm_get_alert_slave_dev_num(), so we should use a signed
variable here.

While at it, drop the superfluous initialization as well

drivers/soundwire/qcom.c: qcom_swrm_irq_handler() warn: impossible
condition '(devnum < 0) => (0-255 < 0)'

Reported-by: kernel test robot <[email protected]>
Signed-off-by: Vinod Koul <[email protected]>
---
drivers/soundwire/qcom.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index b08ecb9b418c..ec86c4e53fdb 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -428,7 +428,7 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id)
struct qcom_swrm_ctrl *swrm = dev_id;
u32 value, intr_sts, intr_sts_masked, slave_status;
u32 i;
- u8 devnum = 0;
+ int devnum;
int ret = IRQ_HANDLED;

swrm->reg_read(swrm, SWRM_INTERRUPT_STATUS, &intr_sts);
--
2.26.3


2021-03-31 16:20:33

by Pierre-Louis Bossart

[permalink] [raw]
Subject: Re: [PATCH V2] soundwire: qcom: use signed variable for error return



On 3/31/21 10:55 AM, Vinod Koul wrote:
> We get warning of using a unsigned variable being compared to less than
> zero. The comparison is correct as it checks for errors from previous
> call to qcom_swrm_get_alert_slave_dev_num(), so we should use a signed
> variable here.
>
> While at it, drop the superfluous initialization as well
>
> drivers/soundwire/qcom.c: qcom_swrm_irq_handler() warn: impossible
> condition '(devnum < 0) => (0-255 < 0)'
>
> Reported-by: kernel test robot <[email protected]>
> Signed-off-by: Vinod Koul <[email protected]>

Reviewed-by: Pierre-Louis Bossart <[email protected]>

> ---
> drivers/soundwire/qcom.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index b08ecb9b418c..ec86c4e53fdb 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
> @@ -428,7 +428,7 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id)
> struct qcom_swrm_ctrl *swrm = dev_id;
> u32 value, intr_sts, intr_sts_masked, slave_status;
> u32 i;
> - u8 devnum = 0;
> + int devnum;
> int ret = IRQ_HANDLED;
>
> swrm->reg_read(swrm, SWRM_INTERRUPT_STATUS, &intr_sts);
>

2021-03-31 16:30:02

by Bjorn Andersson

[permalink] [raw]
Subject: Re: [PATCH V2] soundwire: qcom: use signed variable for error return

On Wed 31 Mar 10:55 CDT 2021, Vinod Koul wrote:

> We get warning of using a unsigned variable being compared to less than
> zero. The comparison is correct as it checks for errors from previous
> call to qcom_swrm_get_alert_slave_dev_num(), so we should use a signed
> variable here.
>
> While at it, drop the superfluous initialization as well
>
> drivers/soundwire/qcom.c: qcom_swrm_irq_handler() warn: impossible
> condition '(devnum < 0) => (0-255 < 0)'
>
> Reported-by: kernel test robot <[email protected]>
> Signed-off-by: Vinod Koul <[email protected]>

Reviewed-by: Bjorn Andersson <[email protected]>

> ---
> drivers/soundwire/qcom.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index b08ecb9b418c..ec86c4e53fdb 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
> @@ -428,7 +428,7 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id)
> struct qcom_swrm_ctrl *swrm = dev_id;
> u32 value, intr_sts, intr_sts_masked, slave_status;
> u32 i;
> - u8 devnum = 0;
> + int devnum;
> int ret = IRQ_HANDLED;
>
> swrm->reg_read(swrm, SWRM_INTERRUPT_STATUS, &intr_sts);
> --
> 2.26.3
>