* [PATCH 0/2] iio: adc: ti-ads1298 & Kconfig @ 2025-04-23 18:46 Arthur-Prince 2025-04-23 18:46 ` [PATCH 1/2] iio: adc: ti-ads1298: Add safe usage guarantee for device communication Arthur-Prince 2025-04-23 18:46 ` [PATCH 2/2] iio: adc: Kconfig: add kfifo dependency to fix module build Arthur-Prince 0 siblings, 2 replies; 5+ messages in thread From: Arthur-Prince @ 2025-04-23 18:46 UTC (permalink / raw) To: linux-iio, arthur.prince These patches improve the ti-ads1298 driver in two ways: 1- Safe usage guarantee for device communication Wrap calls to ads1298_reg_access() and ads1298_write_raw() with iio_device_claim_direct() / iio_device_release_direct() so that configuration operations cannot interrupt an ongoing buffered capture. 2- Add kfifo dependency for module compilation The driver now selects CONFIG_IIO_KFIFO_BUFFER in its Kconfig, just like other IIO ADC drivers, to ensure the kfifo buffer API is available when building ti-ads1298 as a module. Arthur-Prince (2): iio: adc: ti-ads1298 iio: adc: Kconfig drivers/iio/adc/Kconfig | 1 + drivers/iio/adc/ti-ads1298.c | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) -- 2.45.2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] iio: adc: ti-ads1298: Add safe usage guarantee for device communication 2025-04-23 18:46 [PATCH 0/2] iio: adc: ti-ads1298 & Kconfig Arthur-Prince @ 2025-04-23 18:46 ` Arthur-Prince 2025-04-26 15:30 ` Jonathan Cameron 2025-04-23 18:46 ` [PATCH 2/2] iio: adc: Kconfig: add kfifo dependency to fix module build Arthur-Prince 1 sibling, 1 reply; 5+ messages in thread From: Arthur-Prince @ 2025-04-23 18:46 UTC (permalink / raw) To: linux-iio, arthur.prince; +Cc: Mariana Valério Add safe usage guarantee for device communication in ads1298_reg_access/ ads1298_write_raw (ti-ads1298) that prevent simultaneous read/write operations. Signed-off-by: Arthur-Prince <r2.arthur.prince@gmail.com> Co-developed-by: Mariana Valério <mariana.valerio2@hotmail.com> Signed-off-by: Mariana Valério <mariana.valerio2@hotmail.com> --- drivers/iio/adc/ti-ads1298.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti-ads1298.c b/drivers/iio/adc/ti-ads1298.c index 03f762415fa5..438bcc3c74da 100644 --- a/drivers/iio/adc/ti-ads1298.c +++ b/drivers/iio/adc/ti-ads1298.c @@ -355,9 +355,19 @@ static int ads1298_write_raw(struct iio_dev *indio_dev, { struct ads1298_private *priv = iio_priv(indio_dev); + int ret; + switch (mask) { case IIO_CHAN_INFO_SAMP_FREQ: - return ads1298_set_samp_freq(priv, val); + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + + ret = ads1298_set_samp_freq(priv, val); + + iio_device_release_direct_mode(indio_dev); + + return ret; default: return -EINVAL; } @@ -417,10 +427,17 @@ static int ads1298_reg_access(struct iio_dev *indio_dev, unsigned int reg, { struct ads1298_private *priv = iio_priv(indio_dev); + int ret; + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; if (readval) - return regmap_read(priv->regmap, reg, readval); - - return regmap_write(priv->regmap, reg, writeval); + ret = regmap_read(priv->regmap, reg, readval); + else + ret = regmap_write(priv->regmap, reg, writeval); + + iio_device_release_direct_mode(indio_dev); + return ret; } static void ads1298_rdata_unmark_busy(struct ads1298_private *priv) -- 2.45.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] iio: adc: ti-ads1298: Add safe usage guarantee for device communication 2025-04-23 18:46 ` [PATCH 1/2] iio: adc: ti-ads1298: Add safe usage guarantee for device communication Arthur-Prince @ 2025-04-26 15:30 ` Jonathan Cameron 0 siblings, 0 replies; 5+ messages in thread From: Jonathan Cameron @ 2025-04-26 15:30 UTC (permalink / raw) To: Arthur-Prince; +Cc: linux-iio, arthur.prince, Mariana Valério On Wed, 23 Apr 2025 15:46:25 -0300 Arthur-Prince <r2.arthur.prince@gmail.com> wrote: > Add safe usage guarantee for device communication in > ads1298_reg_access/ ads1298_write_raw (ti-ads1298) that > prevent simultaneous read/write operations. > > Signed-off-by: Arthur-Prince <r2.arthur.prince@gmail.com> > Co-developed-by: Mariana Valério <mariana.valerio2@hotmail.com> > Signed-off-by: Mariana Valério <mariana.valerio2@hotmail.com> Two different things seem to be going on in here... > --- > drivers/iio/adc/ti-ads1298.c | 25 +++++++++++++++++++++---- > 1 file changed, 21 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/adc/ti-ads1298.c b/drivers/iio/adc/ti-ads1298.c > index 03f762415fa5..438bcc3c74da 100644 > --- a/drivers/iio/adc/ti-ads1298.c > +++ b/drivers/iio/adc/ti-ads1298.c > @@ -355,9 +355,19 @@ static int ads1298_write_raw(struct iio_dev *indio_dev, > { > struct ads1298_private *priv = iio_priv(indio_dev); > > + int ret; > + > switch (mask) { > case IIO_CHAN_INFO_SAMP_FREQ: > - return ads1298_set_samp_freq(priv, val); > + ret = iio_device_claim_direct_mode(indio_dev); > + if (ret) > + return ret; > + > + ret = ads1298_set_samp_freq(priv, val); > + > + iio_device_release_direct_mode(indio_dev); This prevents changing the sampling frequency. Some drivers prevent this whilst in buffered mode, but why is that necessary here? > + > + return ret; > default: > return -EINVAL; > } > @@ -417,10 +427,17 @@ static int ads1298_reg_access(struct iio_dev *indio_dev, unsigned int reg, > { > struct ads1298_private *priv = iio_priv(indio_dev); > > + int ret; > + ret = iio_device_claim_direct_mode(indio_dev); For this one it's a debug interface. If the issue is people shooting themselves in the foot then we don't normally prevent that for these. If there is something fundamental about regmap implementation that makes these accesses have side effects unconnected to what is being written then that needs calling out. > + if (ret) > + return ret; > if (readval) > - return regmap_read(priv->regmap, reg, readval); > - > - return regmap_write(priv->regmap, reg, writeval); > + ret = regmap_read(priv->regmap, reg, readval); > + else > + ret = regmap_write(priv->regmap, reg, writeval); > + > + iio_device_release_direct_mode(indio_dev); > + return ret; > } > > static void ads1298_rdata_unmark_busy(struct ads1298_private *priv) ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] iio: adc: Kconfig: add kfifo dependency to fix module build 2025-04-23 18:46 [PATCH 0/2] iio: adc: ti-ads1298 & Kconfig Arthur-Prince 2025-04-23 18:46 ` [PATCH 1/2] iio: adc: ti-ads1298: Add safe usage guarantee for device communication Arthur-Prince @ 2025-04-23 18:46 ` Arthur-Prince 2025-04-26 15:32 ` Jonathan Cameron 1 sibling, 1 reply; 5+ messages in thread From: Arthur-Prince @ 2025-04-23 18:46 UTC (permalink / raw) To: linux-iio, arthur.prince; +Cc: Mariana Valério Add dependency to Kconfig’s ti-ads1298 because compiling it as a module failed with an undefined kfifo symbol. Building the full kernel passed since kfifo was enabled globally. Selecting IIO_KFIFO_BUFFER in ti-ads1298’s Kconfig, as done by other IIO ADC drivers, now ensures kfifo buffer support is included for module builds. Signed-off-by: Arthur-Prince <r2.arthur.prince@gmail.com> Co-developed-by: Mariana Valério <mariana.valerio2@hotmail.com> Signed-off-by: Mariana Valério <mariana.valerio2@hotmail.com> --- drivers/iio/adc/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 849c90203071..513f2238fdee 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -1492,6 +1492,7 @@ config TI_ADS1298 tristate "Texas Instruments ADS1298" depends on SPI select IIO_BUFFER + select IIO_KFIFO_BUF help If you say yes here you get support for Texas Instruments ADS1298 medical ADC chips -- 2.45.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] iio: adc: Kconfig: add kfifo dependency to fix module build 2025-04-23 18:46 ` [PATCH 2/2] iio: adc: Kconfig: add kfifo dependency to fix module build Arthur-Prince @ 2025-04-26 15:32 ` Jonathan Cameron 0 siblings, 0 replies; 5+ messages in thread From: Jonathan Cameron @ 2025-04-26 15:32 UTC (permalink / raw) To: Arthur-Prince; +Cc: linux-iio, arthur.prince, Mariana Valério On Wed, 23 Apr 2025 15:46:26 -0300 Arthur-Prince <r2.arthur.prince@gmail.com> wrote: > Add dependency to Kconfig’s ti-ads1298 because compiling it as a module > failed with an undefined kfifo symbol. Building the full kernel passed > since kfifo was enabled globally. Selecting IIO_KFIFO_BUFFER in > ti-ads1298’s Kconfig, as done by other IIO ADC drivers, now ensures kfifo > buffer support is included for module builds. > > Signed-off-by: Arthur-Prince <r2.arthur.prince@gmail.com> > Co-developed-by: Mariana Valério <mariana.valerio2@hotmail.com> > Signed-off-by: Mariana Valério <mariana.valerio2@hotmail.com> Fixes tag? Otherwise looks good. > --- > drivers/iio/adc/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig > index 849c90203071..513f2238fdee 100644 > --- a/drivers/iio/adc/Kconfig > +++ b/drivers/iio/adc/Kconfig > @@ -1492,6 +1492,7 @@ config TI_ADS1298 > tristate "Texas Instruments ADS1298" > depends on SPI > select IIO_BUFFER > + select IIO_KFIFO_BUF > help > If you say yes here you get support for Texas Instruments ADS1298 > medical ADC chips ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-04-26 15:32 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-04-23 18:46 [PATCH 0/2] iio: adc: ti-ads1298 & Kconfig Arthur-Prince 2025-04-23 18:46 ` [PATCH 1/2] iio: adc: ti-ads1298: Add safe usage guarantee for device communication Arthur-Prince 2025-04-26 15:30 ` Jonathan Cameron 2025-04-23 18:46 ` [PATCH 2/2] iio: adc: Kconfig: add kfifo dependency to fix module build Arthur-Prince 2025-04-26 15:32 ` Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox