linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (ads7828) Make sample interval configurable
@ 2015-01-16 12:05 Robert Rosengren
  2015-01-16 14:52 ` Guenter Roeck
  2015-01-16 20:30 ` Guenter Roeck
  0 siblings, 2 replies; 25+ messages in thread
From: Robert Rosengren @ 2015-01-16 12:05 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, lm-sensors
  Cc: linux-kernel, Robert Rosengren, Johan Adolfsson

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


^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2015-02-02 16:21 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-16 12:05 [PATCH] hwmon: (ads7828) Make sample interval configurable Robert Rosengren
2015-01-16 14:52 ` 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

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).