All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mahoda Ratnayaka <mahoda.ratnayaka@alliedtelesis.co.nz>
To: Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>,
	linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org,
	Rob Herring <robh+dt@kernel.org>
Cc: Mahoda Ratnayaka <mahoda.ratnayaka@alliedtelesis.co.nz>,
	Chris Packham <chris.packham@alliedtelesis.co.nz>
Subject: [PATCH v2] lm87: Allow channel data to be set from dts file.
Date: Tue, 20 Sep 2016 17:22:40 +1200	[thread overview]
Message-ID: <20160920052240.10242-1-mahoda.ratnayaka@alliedtelesis.co.nz> (raw)

Currently there is no method for setting the channel
value from the DTS file. When, the driver uses a dts
file to initialize the driver platform_data is not set.
As a the result channel variable may not be set correctly.

Without the channel variable set correctly, some of the
sensors will not be initialized correctly. For example
temp3 sensor sysfs entries.

This adds the required functionality to set the channel
variable from the DTS file. This is done via reading the
reading a property named "channel" from the lm87 driver.

Signed-off-by: Mahoda Ratnayaka <mahoda.ratnayaka@alliedtelesis.co.nz>
---

Notes:
     changes since v1:
     Removed unncessary variables channel and np.
     Update the code as per review comments.

 Documentation/devicetree/bindings/hwmon/lm87.txt | 9 +++++++++
 drivers/hwmon/lm87.c                             | 7 ++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/hwmon/lm87.txt b/Documentation/devicetree/bindings/hwmon/lm87.txt
index fefcb48..1906e08 100644
--- a/Documentation/devicetree/bindings/hwmon/lm87.txt
+++ b/Documentation/devicetree/bindings/hwmon/lm87.txt
@@ -6,9 +6,18 @@ Required properties:
 
 - reg: I2C address
 
+optional properties:
+- channels: Value for the channel mode register.
+            This allows configuration of pins with
+            selectable uses on the LM87 device (e.g.
+            choosing between voltage and temperature
+            inputs).
+            See hwmon/lm87 for further information
+
 Example:
 
 lm87@2e {
 	compatible = "ti,lm87";
 	reg = <0x2e>;
+	channels=<0x4>;
 };
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index a5e2958..358c1d4 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -858,8 +858,13 @@ static void lm87_remove_files(struct i2c_client *client)
 static void lm87_init_client(struct i2c_client *client)
 {
 	struct lm87_data *data = i2c_get_clientdata(client);
+	u8 val = 0;
 
-	if (dev_get_platdata(&client->dev)) {
+	if (!of_property_read_u8(client->dev.of_node, "channels", &val)) {
+		data->channel = val;
+		lm87_write_value(client,
+				 LM87_REG_CHANNEL_MODE, data->channel);
+	} else if (dev_get_platdata(&client->dev)) {
 		data->channel = *(u8 *)dev_get_platdata(&client->dev);
 		lm87_write_value(client,
 				 LM87_REG_CHANNEL_MODE, data->channel);
-- 
2.9.3

             reply	other threads:[~2016-09-20  5:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20  5:22 Mahoda Ratnayaka [this message]
2016-09-20  9:55 ` [PATCH v2] lm87: Allow channel data to be set from dts file Guenter Roeck
2016-09-20  9:55   ` Guenter Roeck
2016-09-21 21:58   ` Mahoda Ratnayaka
2016-09-23 18:10   ` Rob Herring
2016-09-23 18:10     ` Rob Herring
2016-09-20 17:24 ` Frank Rowand
2016-09-20 17:24   ` Frank Rowand

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=20160920052240.10242-1-mahoda.ratnayaka@alliedtelesis.co.nz \
    --to=mahoda.ratnayaka@alliedtelesis.co.nz \
    --cc=chris.packham@alliedtelesis.co.nz \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.