linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][RESEND] staging: iio: adc: ad7192: disable burnout currents on misconfig
@ 2018-01-16 10:04 alexandru.ardelean
  2018-01-16 10:46 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: alexandru.ardelean @ 2018-01-16 10:04 UTC (permalink / raw)
  To: linux-iio; +Cc: michael.hennerich, Alexandru Ardelean

From: Alexandru Ardelean <alexandru.ardelean@analog.com>

According to the datasheet for all ad719x ADCs,
the burnout currents can be enabled only if buffer is enabled
and CHOP is disabled.

So, if neither of these conditions are met, then
we should disable the burnout currents in the driver as well,
and warn the user.

This change doesn't fix anything.
The burnout currents simply won't work if CHOP is enabled
or buffer is disabled.
The intent is to provide the user with some feedback
instead of silently not working inside the chip.

This is especially useful when considering device-tree
support (and/or device-tree overlays) at a later point,
which will allow for a quicker/simpler reconfiguration
of the chip settings.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/staging/iio/adc/ad7192.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index d11c6de9c777..7f204013d6d4 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -266,6 +266,12 @@ static int ad7192_setup(struct ad7192_state *st,
 
 	st->conf = AD7192_CONF_GAIN(0);
 
+	if (pdata->burnout_curr_en && (!pdata->buf_en || pdata->chop_en)) {
+		pdata->burnout_curr_en = false;
+		dev_warn(dev,
+			 "Can't enable burnout currents: see CHOP or buffer\n");
+	}
+
 	if (pdata->rej60_en)
 		st->mode |= AD7192_MODE_REJ60;
 
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-16 11:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-16 10:04 [PATCH][RESEND] staging: iio: adc: ad7192: disable burnout currents on misconfig alexandru.ardelean
2018-01-16 10:46 ` Jonathan Cameron
2018-01-16 11:09   ` Ardelean, Alexandru

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).