aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83l785ts.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2005-09-25 10:41:18 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 17:02:06 -0400
commit709439a284bc5b7d42a70fee7119feb186c1ca99 (patch)
tree12b41b5091cac96e2cff9d3ee878944689642616 /drivers/hwmon/w83l785ts.c
parentd6072f842a77014220683ee5b781b7cee8f020d1 (diff)
[PATCH] hwmon: w83l785ts converted to dynamic sysfs callbacks
Convert the w83l785ts driver to use dynamic sysfs callbacks. This is a small driver so the benefit is thin, but still worth it. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> drivers/hwmon/w83l785ts.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
Diffstat (limited to 'drivers/hwmon/w83l785ts.c')
-rw-r--r--drivers/hwmon/w83l785ts.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index 133e34ab1d0..fcb2c39b04f 100644
--- a/drivers/hwmon/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
@@ -37,6 +37,7 @@
37#include <linux/jiffies.h> 37#include <linux/jiffies.h>
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/hwmon.h> 39#include <linux/hwmon.h>
40#include <linux/hwmon-sysfs.h>
40#include <linux/err.h> 41#include <linux/err.h>
41 42
42/* How many retries on register read error */ 43/* How many retries on register read error */
@@ -111,27 +112,24 @@ struct w83l785ts_data {
111 unsigned long last_updated; /* in jiffies */ 112 unsigned long last_updated; /* in jiffies */
112 113
113 /* registers values */ 114 /* registers values */
114 u8 temp, temp_over; 115 u8 temp[2]; /* 0: input
116 1: critical limit */
115}; 117};
116 118
117/* 119/*
118 * Sysfs stuff 120 * Sysfs stuff
119 */ 121 */
120 122
121static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf) 123static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
124 char *buf)
122{ 125{
126 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
123 struct w83l785ts_data *data = w83l785ts_update_device(dev); 127 struct w83l785ts_data *data = w83l785ts_update_device(dev);
124 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); 128 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index]));
125} 129}
126 130
127static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf) 131static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
128{ 132static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp, NULL, 1);
129 struct w83l785ts_data *data = w83l785ts_update_device(dev);
130 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over));
131}
132
133static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
134static DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_over, NULL);
135 133
136/* 134/*
137 * Real code 135 * Real code
@@ -228,7 +226,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
228 init_MUTEX(&data->update_lock); 226 init_MUTEX(&data->update_lock);
229 227
230 /* Default values in case the first read fails (unlikely). */ 228 /* Default values in case the first read fails (unlikely). */
231 data->temp_over = data->temp = 0; 229 data->temp[1] = data->temp[0] = 0;
232 230
233 /* Tell the I2C layer a new client has arrived. */ 231 /* Tell the I2C layer a new client has arrived. */
234 if ((err = i2c_attach_client(new_client))) 232 if ((err = i2c_attach_client(new_client)))
@@ -246,8 +244,10 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
246 goto exit_detach; 244 goto exit_detach;
247 } 245 }
248 246
249 device_create_file(&new_client->dev, &dev_attr_temp1_input); 247 device_create_file(&new_client->dev,
250 device_create_file(&new_client->dev, &dev_attr_temp1_max); 248 &sensor_dev_attr_temp1_input.dev_attr);
249 device_create_file(&new_client->dev,
250 &sensor_dev_attr_temp1_max.dev_attr);
251 251
252 return 0; 252 return 0;
253 253
@@ -305,10 +305,10 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev)
305 305
306 if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { 306 if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) {
307 dev_dbg(&client->dev, "Updating w83l785ts data.\n"); 307 dev_dbg(&client->dev, "Updating w83l785ts data.\n");
308 data->temp = w83l785ts_read_value(client, 308 data->temp[0] = w83l785ts_read_value(client,
309 W83L785TS_REG_TEMP, data->temp); 309 W83L785TS_REG_TEMP, data->temp[0]);
310 data->temp_over = w83l785ts_read_value(client, 310 data->temp[1] = w83l785ts_read_value(client,
311 W83L785TS_REG_TEMP_OVER, data->temp_over); 311 W83L785TS_REG_TEMP_OVER, data->temp[1]);
312 312
313 data->last_updated = jiffies; 313 data->last_updated = jiffies;
314 data->valid = 1; 314 data->valid = 1;