All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] iio: adc: max1027: Use the EOC IRQ when populated for single reads
@ 2021-10-04 10:17 Dan Carpenter
  2021-10-04 10:35 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-10-04 10:17 UTC (permalink / raw)
  To: miquel.raynal; +Cc: linux-iio

Hello Miquel Raynal,

The patch 54f14be01e17: "iio: adc: max1027: Use the EOC IRQ when
populated for single reads" from Sep 21, 2021, leads to the following
Smatch static checker warning:

	drivers/iio/adc/max1027.c:289 max1027_wait_eoc()
	info: return a literal instead of 'ret'

drivers/iio/adc/max1027.c
    278 static int max1027_wait_eoc(struct iio_dev *indio_dev)
    279 {
    280         struct max1027_state *st = iio_priv(indio_dev);
    281         unsigned int conversion_time = MAX1027_CONVERSION_UDELAY;
    282         int ret;
    283 
    284         if (st->spi->irq) {
    285                 ret = wait_for_completion_timeout(&st->complete,
    286                                                   msecs_to_jiffies(1000));
    287                 reinit_completion(&st->complete);
    288                 if (!ret)
--> 289                         return ret;

wait_for_completion_timeout() returns zero if it times out.  Should this
be return an error code?  Otherwise we could just delete the "ret"
variable and return 0 below.

    290         } else {
    291                 if (indio_dev->active_scan_mask)
    292                         conversion_time *= hweight32(*indio_dev->active_scan_mask);
    293 
    294                 usleep_range(conversion_time, conversion_time * 2);
    295         }
    296 
    297         return 0;
    298 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] iio: adc: max1027: Use the EOC IRQ when populated for single reads
  2021-10-04 10:17 [bug report] iio: adc: max1027: Use the EOC IRQ when populated for single reads Dan Carpenter
@ 2021-10-04 10:35 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2021-10-04 10:35 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-iio, Jonathan Cameron

Hi Jonathan,

dan.carpenter@oracle.com wrote on Mon, 4 Oct 2021 13:17:01 +0300:

> Hello Miquel Raynal,
> 
> The patch 54f14be01e17: "iio: adc: max1027: Use the EOC IRQ when
> populated for single reads" from Sep 21, 2021, leads to the following
> Smatch static checker warning:
> 
> 	drivers/iio/adc/max1027.c:289 max1027_wait_eoc()
> 	info: return a literal instead of 'ret'
> 
> drivers/iio/adc/max1027.c
>     278 static int max1027_wait_eoc(struct iio_dev *indio_dev)
>     279 {
>     280         struct max1027_state *st = iio_priv(indio_dev);
>     281         unsigned int conversion_time = MAX1027_CONVERSION_UDELAY;
>     282         int ret;
>     283 
>     284         if (st->spi->irq) {
>     285                 ret = wait_for_completion_timeout(&st->complete,
>     286                                                   msecs_to_jiffies(1000));
>     287                 reinit_completion(&st->complete);
>     288                 if (!ret)
> --> 289                         return ret;  
> 
> wait_for_completion_timeout() returns zero if it times out.  Should this
> be return an error code?  Otherwise we could just delete the "ret"
> variable and return 0 below.

I received this bug report, indeed this should use

			if (!ret)
				return -ETIMEDOUT;

Can you fix it directly? Do you want a fixup! patch to apply and
squash? Or a perhaps a regular patch?

> 
>     290         } else {
>     291                 if (indio_dev->active_scan_mask)
>     292                         conversion_time *= hweight32(*indio_dev->active_scan_mask);
>     293 
>     294                 usleep_range(conversion_time, conversion_time * 2);
>     295         }
>     296 
>     297         return 0;
>     298 }
> 
> regards,
> dan carpenter


Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-04 10:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04 10:17 [bug report] iio: adc: max1027: Use the EOC IRQ when populated for single reads Dan Carpenter
2021-10-04 10:35 ` Miquel Raynal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.