linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Rosengren <robert.rosengren@axis.com>
To: Jean Delvare <jdelvare@suse.de>,
	Guenter Roeck <linux@roeck-us.net>, <lm-sensors@lm-sensors.org>
Cc: <linux-kernel@vger.kernel.org>,
	Robert Rosengren <robertr@axis.com>,
	Johan Adolfsson <johana@axis.com>
Subject: [PATCH] hwmon: (ads7828) Make sample interval configurable
Date: Fri, 16 Jan 2015 13:05:22 +0100	[thread overview]
Message-ID: <1421409922-28299-1-git-send-email-robert.rosengren@axis.com> (raw)

The default sample interval may be too slow for certain clients. This
patch makes it configurable via the platform_data.

Signed-off-by: Robert Rosengren <robert.rosengren@axis.com>
Signed-off-by: Johan Adolfsson <johan.adolfsson@axis.com>
---
 drivers/hwmon/ads7828.c               | 11 ++++++++++-
 include/linux/platform_data/ads7828.h |  2 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
index a622d40..fd5eabf7 100644
--- a/drivers/hwmon/ads7828.c
+++ b/drivers/hwmon/ads7828.c
@@ -45,6 +45,9 @@
 #define ADS7828_EXT_VREF_MV_MIN	50	/* External vref min value 0.05V */
 #define ADS7828_EXT_VREF_MV_MAX	5250	/* External vref max value 5.25V */
 
+/* Default sample interval */
+#define ADS7828_SAMPLE_INTERVAL (HZ + HZ / 2)
+
 /* List of supported devices */
 enum ads7828_chips { ads7828, ads7830 };
 
@@ -58,6 +61,7 @@ struct ads7828_data {
 	bool diff_input;		/* Differential input */
 	bool ext_vref;			/* External voltage reference */
 	unsigned int vref_mv;		/* voltage reference value */
+	unsigned int sample_interval;   /* sample interval */
 	u8 cmd_byte;			/* Command byte without channel bits */
 	unsigned int lsb_resol;		/* Resolution of the ADC sample LSB */
 	s32 (*read_channel)(const struct i2c_client *client, u8 command);
@@ -77,7 +81,7 @@ static struct ads7828_data *ads7828_update_device(struct device *dev)
 
 	mutex_lock(&data->update_lock);
 
-	if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
+	if (time_after(jiffies, data->last_updated + data->sample_interval)
 			|| !data->valid) {
 		unsigned int ch;
 		dev_dbg(&client->dev, "Starting ads7828 update\n");
@@ -147,6 +151,8 @@ static int ads7828_probe(struct i2c_client *client,
 		data->ext_vref = pdata->ext_vref;
 		if (data->ext_vref)
 			data->vref_mv = pdata->vref_mv;
+		if (pdata->sample_interval)
+			data->sample_interval = pdata->sample_interval;
 	}
 
 	/* Bound Vref with min/max values if it was provided */
@@ -157,6 +163,9 @@ static int ads7828_probe(struct i2c_client *client,
 	else
 		data->vref_mv = ADS7828_INT_VREF_MV;
 
+	if (!data->sample_interval)
+		data->sample_interval = ADS7828_SAMPLE_INTERVAL;
+
 	/* ADS7828 uses 12-bit samples, while ADS7830 is 8-bit */
 	if (id->driver_data == ads7828) {
 		data->lsb_resol = DIV_ROUND_CLOSEST(data->vref_mv * 1000, 4096);
diff --git a/include/linux/platform_data/ads7828.h b/include/linux/platform_data/ads7828.h
index 3245f45..bdae0bb 100644
--- a/include/linux/platform_data/ads7828.h
+++ b/include/linux/platform_data/ads7828.h
@@ -19,11 +19,13 @@
  * @diff_input:		Differential input mode.
  * @ext_vref:		Use an external voltage reference.
  * @vref_mv:		Voltage reference value, if external.
+ * @sample_interval:	Sample interval.
  */
 struct ads7828_platform_data {
 	bool diff_input;
 	bool ext_vref;
 	unsigned int vref_mv;
+	unsigned int sample_interval;
 };
 
 #endif /* _PDATA_ADS7828_H */
-- 
2.1.4


             reply	other threads:[~2015-01-16 12:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-16 12:05 Robert Rosengren [this message]
2015-01-16 14:52 ` [PATCH] hwmon: (ads7828) Make sample interval configurable Guenter Roeck
2015-01-16 18:30   ` [lm-sensors] " Guenter Roeck
2015-01-19 11:14     ` SV: " Robert Rosengren
2015-01-27  7:59     ` Robert Rosengren
2015-01-27 10:37       ` Jean Delvare
2015-01-27 14:23         ` Guenter Roeck
2015-01-27 14:07       ` Guenter Roeck
2015-01-27 19:54         ` Robert Rosengren
2015-01-27 20:05           ` Guenter Roeck
2015-01-27 22:34             ` Jean Delvare
2015-01-28  4:06               ` Guenter Roeck
     [not found]                 ` <54C87F3C.2020105@axis.com>
2015-01-28  6:28                   ` Robert Rosengren
2015-01-28 14:50                   ` Guenter Roeck
2015-01-29  7:00                     ` Robert Rosengren
2015-01-29  7:05                       ` Guenter Roeck
2015-01-29 12:07                         ` Robert Rosengren
2015-01-29 14:10                           ` Guenter Roeck
2015-01-29 19:30                           ` Guenter Roeck
2015-01-31 20:11                             ` Guenter Roeck
2015-02-02  8:12                               ` Robert Rosengren
2015-02-02 16:21                                 ` Guenter Roeck
2015-01-27 14:26       ` Guenter Roeck
2015-01-27 16:37       ` Guenter Roeck
2015-01-16 20:30 ` Guenter Roeck

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=1421409922-28299-1-git-send-email-robert.rosengren@axis.com \
    --to=robert.rosengren@axis.com \
    --cc=jdelvare@suse.de \
    --cc=johana@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lm-sensors@lm-sensors.org \
    --cc=robertr@axis.com \
    /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).