diff mbox

[RESEND] staging: iio: adc: ad7192: disable burnout currents on misconfig

Message ID 20180116100437.10220-1-alexandru.ardelean@analog.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alexandru Ardelean Jan. 16, 2018, 10:04 a.m. UTC
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(+)

Comments

Jonathan Cameron Jan. 16, 2018, 10:46 a.m. UTC | #1
On Tue, 16 Jan 2018 12:04:37 +0200
<alexandru.ardelean@analog.com> wrote:

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

Firstly, even a change to a description makes this a V2 patch
not a resend.  Resends should be identical and only occur if
either:
1) Someone asks you to resend for some reason (wrong cc's perhaps)
2) It has been a long time since anyone responded and looks like
your series has been forgotten.

> 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>
Thanks, much better description. I'll pick this up when I'm next
on the correct PC (possibly not until the weekend).

Jonathan

> ---
>  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;
>  

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexandru Ardelean Jan. 16, 2018, 11:09 a.m. UTC | #2
T24gVHVlLCAyMDE4LTAxLTE2IGF0IDEwOjQ2ICswMDAwLCBKb25hdGhhbiBDYW1lcm9uIHdyb3Rl
Og0KPiBPbiBUdWUsIDE2IEphbiAyMDE4IDEyOjA0OjM3ICswMjAwDQo+IDxhbGV4YW5kcnUuYXJk
ZWxlYW5AYW5hbG9nLmNvbT4gd3JvdGU6DQo+IA0KPiA+IEZyb206IEFsZXhhbmRydSBBcmRlbGVh
biA8YWxleGFuZHJ1LmFyZGVsZWFuQGFuYWxvZy5jb20+DQo+ID4gDQo+IA0KPiBGaXJzdGx5LCBl
dmVuIGEgY2hhbmdlIHRvIGEgZGVzY3JpcHRpb24gbWFrZXMgdGhpcyBhIFYyIHBhdGNoDQo+IG5v
dCBhIHJlc2VuZC4gIFJlc2VuZHMgc2hvdWxkIGJlIGlkZW50aWNhbCBhbmQgb25seSBvY2N1ciBp
Zg0KPiBlaXRoZXI6DQo+IDEpIFNvbWVvbmUgYXNrcyB5b3UgdG8gcmVzZW5kIGZ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GF0aWMg
aW50IGFkNzE5Ml9zZXR1cChzdHJ1Y3QgYWQ3MTkyX3N0YXRlDQo+ID4gKnN0LA0KPiA+ICANCj4g
PiAgCXN0LT5jb25mID0gQUQ3MTkyX0NPTkZfR0FJTigwKTsNCj4gPiAgDQo+ID4gKwlpZiAocGRh
dGEtPmJ1cm5vdXRfY3Vycl9lbiAmJiAoIXBkYXRhLT5idWZfZW4gfHwgcGRhdGEtDQo+ID4gPmNo
b3BfZW4pKSB7DQo+ID4gKwkJcGRhdGEtPmJ1cm5vdXRfY3Vycl9lbiA9IGZhbHNlOw0KPiA+ICsJ
CWRldl93YXJuKGRldiwNCj4gPiArCQkJICJDYW4ndCBlbmFibGUgYnVybm91dCBjdXJyZW50czog
c2VlIENIT1ANCj4gPiBvciBidWZmZXJcbiIpOw0KPiA+ICsJfQ0KPiA+ICsNCj4gPiAgCWlmIChw
ZGF0YS0+cmVqNjBfZW4pDQo+ID4gIAkJc3QtPm1vZGUgfD0gQUQ3MTkyX01PREVfUkVKNjA7DQo+
ID4gIA0KPiANCj4g
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;