All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [RFC PATCH] Allow the configuration register to be
@ 2010-09-13 14:19 Shubhrajyoti D
  2010-09-13 14:27 ` Jean Delvare
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Shubhrajyoti D @ 2010-09-13 14:19 UTC (permalink / raw)
  To: lm-sensors

The patch intends to allow the configuration of resolution
polarity etc.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/hwmon/lm75.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 2a5b12a..abf3135 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -111,7 +111,41 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
 	mutex_unlock(&data->update_lock);
 	return count;
 }
+static ssize_t set_configuration(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t count)
+{
+	s32 status;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm75_data *data = i2c_get_clientdata(client);
+	unsigned long temp;
+	int error;
+	error = strict_strtol(buf, 10, &temp);
+	if (error)
+		return error;
+
+	data->orig_conf = (u8)temp;
+	/* I2C write to the configuration register */
+	status = lm75_write_value(client, LM75_REG_CONF,
+			data->orig_conf);
+	return count;
+}
+
+static ssize_t show_configuration(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	int status = lm75_read_value(client, LM75_REG_CONF);
+	if (status < 0) {
+		dev_dbg(&client->dev, "Can't read config? %d\n", status);
+		return status;
+	}
+
+	return sprintf(buf, "%u\n", status);
+}
 
+static SENSOR_DEVICE_ATTR(configuration, S_IWUSR | S_IRUGO,
+			show_configuration, set_configuration, 0);
 static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO,
 			show_temp, set_temp, 1);
 static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO,
@@ -122,6 +156,7 @@ static struct attribute *lm75_attributes[] = {
 	&sensor_dev_attr_temp1_input.dev_attr.attr,
 	&sensor_dev_attr_temp1_max.dev_attr.attr,
 	&sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
+	&sensor_dev_attr_configuration.dev_attr.attr,
 
 	NULL
 };
-- 
1.7.0.4


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

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

end of thread, other threads:[~2010-09-14 16:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-13 14:19 [lm-sensors] [RFC PATCH] Allow the configuration register to be Shubhrajyoti D
2010-09-13 14:27 ` Jean Delvare
2010-09-13 14:55 ` Datta, Shubhrajyoti
2010-09-13 15:33 ` Jean Delvare
2010-09-13 16:51 ` Guenter Roeck
2010-09-13 17:41 ` Jean Delvare
2010-09-13 18:09 ` Guenter Roeck
2010-09-14  8:08 ` Jean Delvare
2010-09-14 12:01 ` Guenter Roeck
2010-09-14 14:57 ` Jean Delvare
2010-09-14 16:04 ` Guenter Roeck

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.