lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZcJLnOiFoaABami1@smile.fi.intel.com>
Date: Tue, 6 Feb 2024 17:09:16 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Mike Looijmans <mike.looijmans@...ic.nl>
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 Tue, Feb 06, 2024 at 03:47:45PM +0100, Mike Looijmans wrote:
> 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;
>     }
> }

Yep and it looks like you reinvented atomics :-)

	atomic_t rdata_xfer_busy;
	...

But it's up to you what to do with that.
Maybe Jonathan can advice something different.

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ