[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aLWNbm5rNf8GRxwt@smile.fi.intel.com>
Date: Mon, 1 Sep 2025 15:11:26 +0300
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Mohammad Amin Hosseini <moahmmad.hosseinii@...il.com>
Cc: linux-iio@...r.kernel.org, linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org, gregkh@...uxfoundation.org,
jic23@...nel.org, lars@...afoo.de, Michael.Hennerich@...log.com,
dlechner@...libre.com, nuno.sa@...log.com, andy@...nel.org
Subject: Re: [PATCH v3] staging: iio: adc: ad7816: add mutex to serialize
SPI/GPIO operations
On Mon, Sep 01, 2025 at 11:07:50AM +0330, Mohammad Amin Hosseini wrote:
> The ad7816 driver was accessing SPI and GPIO lines without
> synchronization, which could lead to race conditions when accessed
> concurrently from multiple contexts. This might result in corrupted
> readings or inconsistent GPIO states.
>
> Introduce an io_lock mutex in the driver structure to serialize:
> - SPI transactions in ad7816_spi_read() and ad7816_spi_write()
> - GPIO pin toggling sequences
> - Updates to device state via sysfs store functions (mode, channel, oti)
>
> The mutex ensures proper mutual exclusion and prevents race
> conditions under concurrent access.
Why not using cleanup.h and guard()() / scoped_guard()?
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists