lkml.org 
[lkml]   [2021]   [Sep]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 08/16] iio: adc: max1027: Simplify the _set_trigger_state() helper
Date
The call to max1027_enable_trigger() is the same in both cases thanks to
the 'state' variable, so factorize a little bit to simplify the code and
explain why we call this helper.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/iio/adc/max1027.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c
index 7611d96fc901..9269931ca09d 100644
--- a/drivers/iio/adc/max1027.c
+++ b/drivers/iio/adc/max1027.c
@@ -395,11 +395,17 @@ static int max1027_set_cnvst_trigger_state(struct iio_trigger *trig, bool state)
struct max1027_state *st = iio_priv(indio_dev);
int ret;

+ /*
+ * In order to disable the convst trigger, start acquisition on
+ * conversion register write, which basically disables triggering
+ * conversions upon cnvst changes and thus has the effect of disabling
+ * the external hardware trigger.
+ */
+ ret = max1027_enable_trigger(indio_dev, state);
+ if (ret)
+ return ret;
+
if (state) {
- ret = max1027_enable_trigger(indio_dev, state);
- if (ret)
- return ret;
-
/*
* Scan from chan 0 to the highest requested channel.
* Include temperature on demand.
@@ -412,11 +418,6 @@ static int max1027_set_cnvst_trigger_state(struct iio_trigger *trig, bool state)
ret = spi_write(st->spi, &st->reg, 1);
if (ret < 0)
return ret;
- } else {
- /* Start acquisition on conversion register write */
- ret = max1027_enable_trigger(indio_dev, state);
- if (ret)
- return ret;
}

return 0;
--
2.27.0
\
 
 \ /
  Last update: 2021-09-02 23:15    [W:0.150 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site