From: Alexander Koch <mail@alexanderkoch.net>
To: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Michael Hornung <mhornung.linux@gmail.com>,
devicetree@vger.kernel.org,
Alexander Koch <mail@alexanderkoch.net>
Subject: [PATCH v3 4/4] hwmon: adc128d818: Preserve operation mode
Date: Fri, 6 Jan 2017 11:38:17 +0100 [thread overview]
Message-ID: <20170106103817.11588-5-mail@alexanderkoch.net> (raw)
In-Reply-To: <20170106103817.11588-1-mail@alexanderkoch.net>
Preserve chip operation mode if no mode is specified via devicetree. This
enables operation when chip configuration is done by BIOS/ROMMON.
Signed-off-by: Alexander Koch <mail@alexanderkoch.net>
Acked-by: Michael Hornung <mhornung.linux@gmail.com>
---
drivers/hwmon/adc128d818.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/adc128d818.c b/drivers/hwmon/adc128d818.c
index 0502af963f73..bbe3a5c5b3f5 100644
--- a/drivers/hwmon/adc128d818.c
+++ b/drivers/hwmon/adc128d818.c
@@ -491,7 +491,7 @@ static int adc128_probe(struct i2c_client *client,
data->vref = 2560; /* 2.56V, in mV */
}
- /* Operation mode is optional and defaults to mode 0 */
+ /* Operation mode is optional. If unspecified, keep current mode */
if (of_property_read_u8(dev->of_node, "ti,mode", &data->mode) == 0) {
if (data->mode > 3) {
dev_err(dev, "invalid operation mode %d\n",
@@ -500,7 +500,10 @@ static int adc128_probe(struct i2c_client *client,
goto error;
}
} else {
- data->mode = 0;
+ err = i2c_smbus_read_byte_data(client, ADC128_REG_CONFIG_ADV);
+ if (err < 0)
+ goto error;
+ data->mode = (err >> 1) & ADC128_REG_MASK;
}
data->client = client;
--
2.11.0
prev parent reply other threads:[~2017-01-06 10:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-06 10:38 [PATCH v3 0/4] hwmon: adc128d818: Support missing operation modes Alexander Koch
[not found] ` <20170106103817.11588-1-mail-y2PnNNZjvYd4VEKF+Mn3m16hYfS7NtTn@public.gmane.org>
2017-01-06 10:38 ` [PATCH v3 1/4] devicetree: hwmon: Add bindings for ADC128D818 Alexander Koch
2017-01-10 5:35 ` Rob Herring
2017-01-06 10:38 ` [PATCH v3 2/4] hwmon: adc128d818: Implement mode selection via dt Alexander Koch
2017-01-10 17:17 ` [PATCH v3 0/4] hwmon: adc128d818: Support missing operation modes Guenter Roeck
2017-01-06 10:38 ` [PATCH v3 3/4] hwmon: adc128d818: Support operation modes 1-3 Alexander Koch
2017-01-06 10:38 ` Alexander Koch [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170106103817.11588-5-mail@alexanderkoch.net \
--to=mail@alexanderkoch.net \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mark.rutland@arm.com \
--cc=mhornung.linux@gmail.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).