mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-22 10:31:08 +00:00
iio: adc: max1027: Simplify the _set_trigger_state() helper
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> Link: https://lore.kernel.org/r/20210921115408.66711-8-miquel.raynal@bootlin.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
eaf57d50c6
commit
c5a3962982
1 changed files with 10 additions and 9 deletions
|
@ -410,11 +410,17 @@ static int max1027_set_cnvst_trigger_state(struct iio_trigger *trig, bool state)
|
||||||
struct max1027_state *st = iio_priv(indio_dev);
|
struct max1027_state *st = iio_priv(indio_dev);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (state) {
|
/*
|
||||||
ret = max1027_enable_trigger(indio_dev, state);
|
* In order to disable the convst trigger, start acquisition on
|
||||||
if (ret)
|
* conversion register write, which basically disables triggering
|
||||||
return ret;
|
* 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) {
|
||||||
/*
|
/*
|
||||||
* Scan from chan 0 to the highest requested channel.
|
* Scan from chan 0 to the highest requested channel.
|
||||||
* Include temperature on demand.
|
* Include temperature on demand.
|
||||||
|
@ -427,11 +433,6 @@ static int max1027_set_cnvst_trigger_state(struct iio_trigger *trig, bool state)
|
||||||
ret = spi_write(st->spi, &st->reg, 1);
|
ret = spi_write(st->spi, &st->reg, 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
|
||||||
/* Start acquisition on conversion register write */
|
|
||||||
ret = max1027_enable_trigger(indio_dev, state);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue