Re: [PATCH v3 2/2] iio: adc: ti-ads1298: Add driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx
W: www.topic.nl








[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux