From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from saturn.retrosnub.co.uk ([178.18.118.26]:42152 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753549AbeATP06 (ORCPT ); Sat, 20 Jan 2018 10:26:58 -0500 Date: Sat, 20 Jan 2018 15:26:55 +0000 From: Jonathan Cameron To: Cc: , Subject: Re: [PATCH v4] staging: iio: adc: ad7192: disable burnout currents on misconfig Message-ID: <20180120152655.57ccd31f@archlinux> In-Reply-To: <20180118145740.5113-1-alexandru.ardelean@analog.com> References: <20180110111411.18505-1-alexandru.ardelean@analog.com> <20180118145740.5113-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-iio-owner@vger.kernel.org List-Id: linux-iio@vger.kernel.org On Thu, 18 Jan 2018 16:57:40 +0200 wrote: > From: Alexandru Ardelean > > 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. > > Signed-off-by: Alexandru Ardelean Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > > Changes v3 -> v4: > * need to check if `pdata->burnout_curr_en` is positive on the > else path, otherwise a false warning may be thrown > > drivers/staging/iio/adc/ad7192.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c > index d11c6de9c777..9287b50b7870 100644 > --- a/drivers/staging/iio/adc/ad7192.c > +++ b/drivers/staging/iio/adc/ad7192.c > @@ -291,8 +291,12 @@ static int ad7192_setup(struct ad7192_state *st, > if (pdata->unipolar_en) > st->conf |= AD7192_CONF_UNIPOLAR; > > - if (pdata->burnout_curr_en) > + if (pdata->burnout_curr_en && pdata->buf_en && !pdata->chop_en) { > st->conf |= AD7192_CONF_BURN; > + } else if (pdata->burnout_curr_en) { > + dev_warn(&st->sd.spi->dev, > + "Can't enable burnout currents: see CHOP or buffer\n"); > + } > > ret = ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode); > if (ret)