[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <40a3a47b-1388-4ed0-a24b-2c0bcef3be3d@topic.nl>
Date: Tue, 6 Feb 2024 15:47:45 +0100
From: Mike Looijmans <mike.looijmans@...ic.nl>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
CC: devicetree@...r.kernel.org, linux-iio@...r.kernel.org,
Jonathan Cameron <jic23@...nel.org>, Lars-Peter Clausen <lars@...afoo.de>,
Liam Beguin <liambeguin@...il.com>, Liam Girdwood <lgirdwood@...il.com>,
Maksim Kiselev <bigunclemax@...il.com>,
Marcus Folkesson <marcus.folkesson@...il.com>,
Marius Cristea <marius.cristea@...rochip.com>,
Mark Brown <broonie@...nel.org>, Niklas Schnelle <schnelle@...ux.ibm.com>,
Okan Sahin <okan.sahin@...log.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/2] iio: adc: ti-ads1298: Add driver
On 06-02-2024 15:25, Mike Looijmans wrote:
> On 06-02-2024 14:50, Andy Shevchenko wrote:
>> On Tue, Feb 06, 2024 at 02:33:47PM +0100, Mike Looijmans wrote:
>>> On 06-02-2024 13:57, Andy Shevchenko wrote:
>>>> On Tue, Feb 06, 2024 at 07:58:18AM +0100, Mike Looijmans wrote:
>>
>> ...
>>
>>>>> + wasbusy = --priv->rdata_xfer_busy;
>>>> Why preincrement? How would it be different from postincrement?
>>> Maybe better write this as:
>>>
>>> --priv->rdata_xfer_busy;
>>>
>>> wasbusy = priv->rdata_xfer_busy;
>>>
>>> I want the value after decrementing it.
>> Yes, looks more obvious.
>
> Having done that, and looking at it again, it's better to just
> eliminate the local "wasbusy" altogether. More concise.
This removes the decrement operator, so the method now looks like this:
static void ads1298_rdata_release_busy_or_restart(struct ads1298_private
*priv)
{
guard(spinlock_irqsave)(&priv->irq_busy_lock);
if (priv->rdata_xfer_busy > 1) {
/*
* DRDY interrupt occurred before SPI completion. Start a new
* SPI transaction now to retrieve the data that wasn't latched
* into the ADS1298 chip's transfer buffer yet.
*/
spi_async(priv->spi, &priv->rdata_msg);
/*
* If more than one DRDY took place, there was an overrun. Since
* the sample is already lost, reset the counter to 1 so that
* we will wait for a DRDY interrupt after this SPI transaction.
*/
priv->rdata_xfer_busy = 1;
} else {
/* No pending data, wait for DRDY */
priv->rdata_xfer_busy = 0;
}
}
--
Mike Looijmans
System Expert
TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands
T: +31 (0) 499 33 69 69
E: mike.looijmans@...ic.nl
W: www.topic.nl
Powered by blists - more mailing lists