aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm80.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 22:15:38 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 22:15:38 -0500
commitd7511ec8115487ccea2ce93bf58d5e5cd2c1c0a3 (patch)
treee428f9438a563f1fa77479e9c9c4ef8b2e451a8b /drivers/hwmon/lm80.c
parent0b61a2ba5dfd1620731e717d686e6ade657fd975 (diff)
parente84542f5db655d1ce7b4890832f0e5d19aae965d (diff)
Merge branch 'release' of git://lm-sensors.org/kernel/mhoffman/hwmon-2.6
* 'release' of git://lm-sensors.org/kernel/mhoffman/hwmon-2.6: (59 commits) hwmon: (lm80) Add individual alarm files hwmon: (lm80) De-macro the sysfs callbacks hwmon: (lm80) Various cleanups hwmon: (w83627hf) Refactor beep enable handling hwmon: (w83627hf) Add individual alarm and beep files hwmon: (w83627hf) Enable VBAT monitoring hwmon: (w83627ehf) The W83627DHG has 8 VID pins hwmon: (asb100) Add individual alarm files hwmon: (asb100) De-macro the sysfs callbacks hwmon: (asb100) Various cleanups hwmon: VRM is not written to registers hwmon: (dme1737) fix Super-IO device ID override hwmon: (dme1737) fix divide-by-0 hwmon: (abituguru3) Add AUX4 fan input for Abit IP35 Pro hwmon: Add support for Texas Instruments/Burr-Brown ADS7828 hwmon: (adm9240) Add individual alarm files hwmon: (lm77) Add individual alarm files hwmon: Discard useless I2C driver IDs hwmon: (lm85) Make the pwmN_enable files writable hwmon: (lm85) Return standard values in pwmN_enable ...
Diffstat (limited to 'drivers/hwmon/lm80.c')
-rw-r--r--drivers/hwmon/lm80.c328
1 files changed, 166 insertions, 162 deletions
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index 063cdba00a88..a2ca055f3922 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -27,6 +27,7 @@
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/hwmon.h> 29#include <linux/hwmon.h>
30#include <linux/hwmon-sysfs.h>
30#include <linux/err.h> 31#include <linux/err.h>
31#include <linux/mutex.h> 32#include <linux/mutex.h>
32 33
@@ -127,7 +128,7 @@ struct lm80_data {
127 u16 alarms; /* Register encoding, combined */ 128 u16 alarms; /* Register encoding, combined */
128}; 129};
129 130
130/* 131/*
131 * Functions declaration 132 * Functions declaration
132 */ 133 */
133 134
@@ -147,7 +148,6 @@ static struct i2c_driver lm80_driver = {
147 .driver = { 148 .driver = {
148 .name = "lm80", 149 .name = "lm80",
149 }, 150 },
150 .id = I2C_DRIVERID_LM80,
151 .attach_adapter = lm80_attach_adapter, 151 .attach_adapter = lm80_attach_adapter,
152 .detach_client = lm80_detach_client, 152 .detach_client = lm80_detach_client,
153}; 153};
@@ -159,105 +159,74 @@ static struct i2c_driver lm80_driver = {
159#define show_in(suffix, value) \ 159#define show_in(suffix, value) \
160static ssize_t show_in_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ 160static ssize_t show_in_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \
161{ \ 161{ \
162 int nr = to_sensor_dev_attr(attr)->index; \
162 struct lm80_data *data = lm80_update_device(dev); \ 163 struct lm80_data *data = lm80_update_device(dev); \
163 return sprintf(buf, "%d\n", IN_FROM_REG(data->value)); \ 164 return sprintf(buf, "%d\n", IN_FROM_REG(data->value[nr])); \
164} 165}
165show_in(min0, in_min[0]); 166show_in(min, in_min)
166show_in(min1, in_min[1]); 167show_in(max, in_max)
167show_in(min2, in_min[2]); 168show_in(input, in)
168show_in(min3, in_min[3]);
169show_in(min4, in_min[4]);
170show_in(min5, in_min[5]);
171show_in(min6, in_min[6]);
172show_in(max0, in_max[0]);
173show_in(max1, in_max[1]);
174show_in(max2, in_max[2]);
175show_in(max3, in_max[3]);
176show_in(max4, in_max[4]);
177show_in(max5, in_max[5]);
178show_in(max6, in_max[6]);
179show_in(input0, in[0]);
180show_in(input1, in[1]);
181show_in(input2, in[2]);
182show_in(input3, in[3]);
183show_in(input4, in[4]);
184show_in(input5, in[5]);
185show_in(input6, in[6]);
186 169
187#define set_in(suffix, value, reg) \ 170#define set_in(suffix, value, reg) \
188static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ 171static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \
189 size_t count) \ 172 size_t count) \
190{ \ 173{ \
174 int nr = to_sensor_dev_attr(attr)->index; \
191 struct i2c_client *client = to_i2c_client(dev); \ 175 struct i2c_client *client = to_i2c_client(dev); \
192 struct lm80_data *data = i2c_get_clientdata(client); \ 176 struct lm80_data *data = i2c_get_clientdata(client); \
193 long val = simple_strtol(buf, NULL, 10); \ 177 long val = simple_strtol(buf, NULL, 10); \
194 \ 178 \
195 mutex_lock(&data->update_lock);\ 179 mutex_lock(&data->update_lock);\
196 data->value = IN_TO_REG(val); \ 180 data->value[nr] = IN_TO_REG(val); \
197 lm80_write_value(client, reg, data->value); \ 181 lm80_write_value(client, reg(nr), data->value[nr]); \
198 mutex_unlock(&data->update_lock);\ 182 mutex_unlock(&data->update_lock);\
199 return count; \ 183 return count; \
200} 184}
201set_in(min0, in_min[0], LM80_REG_IN_MIN(0)); 185set_in(min, in_min, LM80_REG_IN_MIN)
202set_in(min1, in_min[1], LM80_REG_IN_MIN(1)); 186set_in(max, in_max, LM80_REG_IN_MAX)
203set_in(min2, in_min[2], LM80_REG_IN_MIN(2)); 187
204set_in(min3, in_min[3], LM80_REG_IN_MIN(3)); 188#define show_fan(suffix, value) \
205set_in(min4, in_min[4], LM80_REG_IN_MIN(4));
206set_in(min5, in_min[5], LM80_REG_IN_MIN(5));
207set_in(min6, in_min[6], LM80_REG_IN_MIN(6));
208set_in(max0, in_max[0], LM80_REG_IN_MAX(0));
209set_in(max1, in_max[1], LM80_REG_IN_MAX(1));
210set_in(max2, in_max[2], LM80_REG_IN_MAX(2));
211set_in(max3, in_max[3], LM80_REG_IN_MAX(3));
212set_in(max4, in_max[4], LM80_REG_IN_MAX(4));
213set_in(max5, in_max[5], LM80_REG_IN_MAX(5));
214set_in(max6, in_max[6], LM80_REG_IN_MAX(6));
215
216#define show_fan(suffix, value, div) \
217static ssize_t show_fan_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ 189static ssize_t show_fan_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \
218{ \ 190{ \
191 int nr = to_sensor_dev_attr(attr)->index; \
219 struct lm80_data *data = lm80_update_device(dev); \ 192 struct lm80_data *data = lm80_update_device(dev); \
220 return sprintf(buf, "%d\n", FAN_FROM_REG(data->value, \ 193 return sprintf(buf, "%d\n", FAN_FROM_REG(data->value[nr], \
221 DIV_FROM_REG(data->div))); \ 194 DIV_FROM_REG(data->fan_div[nr]))); \
222} 195}
223show_fan(min1, fan_min[0], fan_div[0]); 196show_fan(min, fan_min)
224show_fan(min2, fan_min[1], fan_div[1]); 197show_fan(input, fan)
225show_fan(input1, fan[0], fan_div[0]);
226show_fan(input2, fan[1], fan_div[1]);
227 198
228#define show_fan_div(suffix, value) \ 199static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr,
229static ssize_t show_fan_div##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ 200 char *buf)
230{ \ 201{
231 struct lm80_data *data = lm80_update_device(dev); \ 202 int nr = to_sensor_dev_attr(attr)->index;
232 return sprintf(buf, "%d\n", DIV_FROM_REG(data->value)); \ 203 struct lm80_data *data = lm80_update_device(dev);
204 return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]));
233} 205}
234show_fan_div(1, fan_div[0]);
235show_fan_div(2, fan_div[1]);
236 206
237#define set_fan(suffix, value, reg, div) \ 207static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
238static ssize_t set_fan_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ 208 const char *buf, size_t count)
239 size_t count) \ 209{
240{ \ 210 int nr = to_sensor_dev_attr(attr)->index;
241 struct i2c_client *client = to_i2c_client(dev); \ 211 struct i2c_client *client = to_i2c_client(dev);
242 struct lm80_data *data = i2c_get_clientdata(client); \ 212 struct lm80_data *data = i2c_get_clientdata(client);
243 long val = simple_strtoul(buf, NULL, 10); \ 213 long val = simple_strtoul(buf, NULL, 10);
244 \ 214
245 mutex_lock(&data->update_lock);\ 215 mutex_lock(&data->update_lock);
246 data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \ 216 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
247 lm80_write_value(client, reg, data->value); \ 217 lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]);
248 mutex_unlock(&data->update_lock);\ 218 mutex_unlock(&data->update_lock);
249 return count; \ 219 return count;
250} 220}
251set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]);
252set_fan(min2, fan_min[1], LM80_REG_FAN_MIN(2), fan_div[1]);
253 221
254/* Note: we save and restore the fan minimum here, because its value is 222/* Note: we save and restore the fan minimum here, because its value is
255 determined in part by the fan divisor. This follows the principle of 223 determined in part by the fan divisor. This follows the principle of
256 least surprise; the user doesn't expect the fan minimum to change just 224 least surprise; the user doesn't expect the fan minimum to change just
257 because the divisor changed. */ 225 because the divisor changed. */
258static ssize_t set_fan_div(struct device *dev, const char *buf, 226static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
259 size_t count, int nr) 227 const char *buf, size_t count)
260{ 228{
229 int nr = to_sensor_dev_attr(attr)->index;
261 struct i2c_client *client = to_i2c_client(dev); 230 struct i2c_client *client = to_i2c_client(dev);
262 struct lm80_data *data = i2c_get_clientdata(client); 231 struct lm80_data *data = i2c_get_clientdata(client);
263 unsigned long min, val = simple_strtoul(buf, NULL, 10); 232 unsigned long min, val = simple_strtoul(buf, NULL, 10);
@@ -292,15 +261,6 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
292 return count; 261 return count;
293} 262}
294 263
295#define set_fan_div(number) \
296static ssize_t set_fan_div##number(struct device *dev, struct device_attribute *attr, const char *buf, \
297 size_t count) \
298{ \
299 return set_fan_div(dev, buf, count, number - 1); \
300}
301set_fan_div(1);
302set_fan_div(2);
303
304static ssize_t show_temp_input1(struct device *dev, struct device_attribute *attr, char *buf) 264static ssize_t show_temp_input1(struct device *dev, struct device_attribute *attr, char *buf)
305{ 265{
306 struct lm80_data *data = lm80_update_device(dev); 266 struct lm80_data *data = lm80_update_device(dev);
@@ -337,41 +297,66 @@ set_temp(hot_hyst, temp_hot_hyst, LM80_REG_TEMP_HOT_HYST);
337set_temp(os_max, temp_os_max, LM80_REG_TEMP_OS_MAX); 297set_temp(os_max, temp_os_max, LM80_REG_TEMP_OS_MAX);
338set_temp(os_hyst, temp_os_hyst, LM80_REG_TEMP_OS_HYST); 298set_temp(os_hyst, temp_os_hyst, LM80_REG_TEMP_OS_HYST);
339 299
340static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 300static ssize_t show_alarms(struct device *dev, struct device_attribute *attr,
301 char *buf)
341{ 302{
342 struct lm80_data *data = lm80_update_device(dev); 303 struct lm80_data *data = lm80_update_device(dev);
343 return sprintf(buf, "%u\n", data->alarms); 304 return sprintf(buf, "%u\n", data->alarms);
344} 305}
345 306
346static DEVICE_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min0, set_in_min0); 307static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
347static DEVICE_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min1, set_in_min1); 308 char *buf)
348static DEVICE_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min2, set_in_min2); 309{
349static DEVICE_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min3, set_in_min3); 310 int bitnr = to_sensor_dev_attr(attr)->index;
350static DEVICE_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min4, set_in_min4); 311 struct lm80_data *data = lm80_update_device(dev);
351static DEVICE_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min5, set_in_min5); 312 return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1);
352static DEVICE_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min6, set_in_min6); 313}
353static DEVICE_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max0, set_in_max0); 314
354static DEVICE_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max1, set_in_max1); 315static SENSOR_DEVICE_ATTR(in0_min, S_IWUSR | S_IRUGO,
355static DEVICE_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max2, set_in_max2); 316 show_in_min, set_in_min, 0);
356static DEVICE_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max3, set_in_max3); 317static SENSOR_DEVICE_ATTR(in1_min, S_IWUSR | S_IRUGO,
357static DEVICE_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max4, set_in_max4); 318 show_in_min, set_in_min, 1);
358static DEVICE_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max5, set_in_max5); 319static SENSOR_DEVICE_ATTR(in2_min, S_IWUSR | S_IRUGO,
359static DEVICE_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max6, set_in_max6); 320 show_in_min, set_in_min, 2);
360static DEVICE_ATTR(in0_input, S_IRUGO, show_in_input0, NULL); 321static SENSOR_DEVICE_ATTR(in3_min, S_IWUSR | S_IRUGO,
361static DEVICE_ATTR(in1_input, S_IRUGO, show_in_input1, NULL); 322 show_in_min, set_in_min, 3);
362static DEVICE_ATTR(in2_input, S_IRUGO, show_in_input2, NULL); 323static SENSOR_DEVICE_ATTR(in4_min, S_IWUSR | S_IRUGO,
363static DEVICE_ATTR(in3_input, S_IRUGO, show_in_input3, NULL); 324 show_in_min, set_in_min, 4);
364static DEVICE_ATTR(in4_input, S_IRUGO, show_in_input4, NULL); 325static SENSOR_DEVICE_ATTR(in5_min, S_IWUSR | S_IRUGO,
365static DEVICE_ATTR(in5_input, S_IRUGO, show_in_input5, NULL); 326 show_in_min, set_in_min, 5);
366static DEVICE_ATTR(in6_input, S_IRUGO, show_in_input6, NULL); 327static SENSOR_DEVICE_ATTR(in6_min, S_IWUSR | S_IRUGO,
367static DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min1, 328 show_in_min, set_in_min, 6);
368 set_fan_min1); 329static SENSOR_DEVICE_ATTR(in0_max, S_IWUSR | S_IRUGO,
369static DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min2, 330 show_in_max, set_in_max, 0);
370 set_fan_min2); 331static SENSOR_DEVICE_ATTR(in1_max, S_IWUSR | S_IRUGO,
371static DEVICE_ATTR(fan1_input, S_IRUGO, show_fan_input1, NULL); 332 show_in_max, set_in_max, 1);
372static DEVICE_ATTR(fan2_input, S_IRUGO, show_fan_input2, NULL); 333static SENSOR_DEVICE_ATTR(in2_max, S_IWUSR | S_IRUGO,
373static DEVICE_ATTR(fan1_div, S_IWUSR | S_IRUGO, show_fan_div1, set_fan_div1); 334 show_in_max, set_in_max, 2);
374static DEVICE_ATTR(fan2_div, S_IWUSR | S_IRUGO, show_fan_div2, set_fan_div2); 335static SENSOR_DEVICE_ATTR(in3_max, S_IWUSR | S_IRUGO,
336 show_in_max, set_in_max, 3);
337static SENSOR_DEVICE_ATTR(in4_max, S_IWUSR | S_IRUGO,
338 show_in_max, set_in_max, 4);
339static SENSOR_DEVICE_ATTR(in5_max, S_IWUSR | S_IRUGO,
340 show_in_max, set_in_max, 5);
341static SENSOR_DEVICE_ATTR(in6_max, S_IWUSR | S_IRUGO,
342 show_in_max, set_in_max, 6);
343static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in_input, NULL, 0);
344static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in_input, NULL, 1);
345static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_in_input, NULL, 2);
346static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_in_input, NULL, 3);
347static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_in_input, NULL, 4);
348static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_in_input, NULL, 5);
349static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_in_input, NULL, 6);
350static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO,
351 show_fan_min, set_fan_min, 0);
352static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO,
353 show_fan_min, set_fan_min, 1);
354static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0);
355static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1);
356static SENSOR_DEVICE_ATTR(fan1_div, S_IWUSR | S_IRUGO,
357 show_fan_div, set_fan_div, 0);
358static SENSOR_DEVICE_ATTR(fan2_div, S_IWUSR | S_IRUGO,
359 show_fan_div, set_fan_div, 1);
375static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); 360static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL);
376static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_hot_max, 361static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_hot_max,
377 set_temp_hot_max); 362 set_temp_hot_max);
@@ -382,6 +367,17 @@ static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_os_max,
382static DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_os_hyst, 367static DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_os_hyst,
383 set_temp_os_hyst); 368 set_temp_os_hyst);
384static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 369static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
370static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
371static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
372static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
373static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
374static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 4);
375static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 5);
376static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6);
377static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 10);
378static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 11);
379static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 8);
380static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 13);
385 381
386/* 382/*
387 * Real code 383 * Real code
@@ -395,40 +391,50 @@ static int lm80_attach_adapter(struct i2c_adapter *adapter)
395} 391}
396 392
397static struct attribute *lm80_attributes[] = { 393static struct attribute *lm80_attributes[] = {
398 &dev_attr_in0_min.attr, 394 &sensor_dev_attr_in0_min.dev_attr.attr,
399 &dev_attr_in1_min.attr, 395 &sensor_dev_attr_in1_min.dev_attr.attr,
400 &dev_attr_in2_min.attr, 396 &sensor_dev_attr_in2_min.dev_attr.attr,
401 &dev_attr_in3_min.attr, 397 &sensor_dev_attr_in3_min.dev_attr.attr,
402 &dev_attr_in4_min.attr, 398 &sensor_dev_attr_in4_min.dev_attr.attr,
403 &dev_attr_in5_min.attr, 399 &sensor_dev_attr_in5_min.dev_attr.attr,
404 &dev_attr_in6_min.attr, 400 &sensor_dev_attr_in6_min.dev_attr.attr,
405 &dev_attr_in0_max.attr, 401 &sensor_dev_attr_in0_max.dev_attr.attr,
406 &dev_attr_in1_max.attr, 402 &sensor_dev_attr_in1_max.dev_attr.attr,
407 &dev_attr_in2_max.attr, 403 &sensor_dev_attr_in2_max.dev_attr.attr,
408 &dev_attr_in3_max.attr, 404 &sensor_dev_attr_in3_max.dev_attr.attr,
409 &dev_attr_in4_max.attr, 405 &sensor_dev_attr_in4_max.dev_attr.attr,
410 &dev_attr_in5_max.attr, 406 &sensor_dev_attr_in5_max.dev_attr.attr,
411 &dev_attr_in6_max.attr, 407 &sensor_dev_attr_in6_max.dev_attr.attr,
412 &dev_attr_in0_input.attr, 408 &sensor_dev_attr_in0_input.dev_attr.attr,
413 &dev_attr_in1_input.attr, 409 &sensor_dev_attr_in1_input.dev_attr.attr,
414 &dev_attr_in2_input.attr, 410 &sensor_dev_attr_in2_input.dev_attr.attr,
415 &dev_attr_in3_input.attr, 411 &sensor_dev_attr_in3_input.dev_attr.attr,
416 &dev_attr_in4_input.attr, 412 &sensor_dev_attr_in4_input.dev_attr.attr,
417 &dev_attr_in5_input.attr, 413 &sensor_dev_attr_in5_input.dev_attr.attr,
418 &dev_attr_in6_input.attr, 414 &sensor_dev_attr_in6_input.dev_attr.attr,
419 &dev_attr_fan1_min.attr, 415 &sensor_dev_attr_fan1_min.dev_attr.attr,
420 &dev_attr_fan2_min.attr, 416 &sensor_dev_attr_fan2_min.dev_attr.attr,
421 &dev_attr_fan1_input.attr, 417 &sensor_dev_attr_fan1_input.dev_attr.attr,
422 &dev_attr_fan2_input.attr, 418 &sensor_dev_attr_fan2_input.dev_attr.attr,
423 &dev_attr_fan1_div.attr, 419 &sensor_dev_attr_fan1_div.dev_attr.attr,
424 &dev_attr_fan2_div.attr, 420 &sensor_dev_attr_fan2_div.dev_attr.attr,
425 &dev_attr_temp1_input.attr, 421 &dev_attr_temp1_input.attr,
426 &dev_attr_temp1_max.attr, 422 &dev_attr_temp1_max.attr,
427 &dev_attr_temp1_max_hyst.attr, 423 &dev_attr_temp1_max_hyst.attr,
428 &dev_attr_temp1_crit.attr, 424 &dev_attr_temp1_crit.attr,
429 &dev_attr_temp1_crit_hyst.attr, 425 &dev_attr_temp1_crit_hyst.attr,
430 &dev_attr_alarms.attr, 426 &dev_attr_alarms.attr,
431 427 &sensor_dev_attr_in0_alarm.dev_attr.attr,
428 &sensor_dev_attr_in1_alarm.dev_attr.attr,
429 &sensor_dev_attr_in2_alarm.dev_attr.attr,
430 &sensor_dev_attr_in3_alarm.dev_attr.attr,
431 &sensor_dev_attr_in4_alarm.dev_attr.attr,
432 &sensor_dev_attr_in5_alarm.dev_attr.attr,
433 &sensor_dev_attr_in6_alarm.dev_attr.attr,
434 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
435 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
436 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
437 &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr,
432 NULL 438 NULL
433}; 439};
434 440
@@ -439,7 +445,7 @@ static const struct attribute_group lm80_group = {
439static int lm80_detect(struct i2c_adapter *adapter, int address, int kind) 445static int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
440{ 446{
441 int i, cur; 447 int i, cur;
442 struct i2c_client *new_client; 448 struct i2c_client *client;
443 struct lm80_data *data; 449 struct lm80_data *data;
444 int err = 0; 450 int err = 0;
445 const char *name; 451 const char *name;
@@ -455,21 +461,20 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
455 goto exit; 461 goto exit;
456 } 462 }
457 463
458 new_client = &data->client; 464 client = &data->client;
459 i2c_set_clientdata(new_client, data); 465 i2c_set_clientdata(client, data);
460 new_client->addr = address; 466 client->addr = address;
461 new_client->adapter = adapter; 467 client->adapter = adapter;
462 new_client->driver = &lm80_driver; 468 client->driver = &lm80_driver;
463 new_client->flags = 0;
464 469
465 /* Now, we do the remaining detection. It is lousy. */ 470 /* Now, we do the remaining detection. It is lousy. */
466 if (lm80_read_value(new_client, LM80_REG_ALARM2) & 0xc0) 471 if (lm80_read_value(client, LM80_REG_ALARM2) & 0xc0)
467 goto error_free; 472 goto error_free;
468 for (i = 0x2a; i <= 0x3d; i++) { 473 for (i = 0x2a; i <= 0x3d; i++) {
469 cur = i2c_smbus_read_byte_data(new_client, i); 474 cur = i2c_smbus_read_byte_data(client, i);
470 if ((i2c_smbus_read_byte_data(new_client, i + 0x40) != cur) 475 if ((i2c_smbus_read_byte_data(client, i + 0x40) != cur)
471 || (i2c_smbus_read_byte_data(new_client, i + 0x80) != cur) 476 || (i2c_smbus_read_byte_data(client, i + 0x80) != cur)
472 || (i2c_smbus_read_byte_data(new_client, i + 0xc0) != cur)) 477 || (i2c_smbus_read_byte_data(client, i + 0xc0) != cur))
473 goto error_free; 478 goto error_free;
474 } 479 }
475 480
@@ -477,27 +482,26 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
477 kind = lm80; 482 kind = lm80;
478 name = "lm80"; 483 name = "lm80";
479 484
480 /* Fill in the remaining client fields and put it into the global list */ 485 /* Fill in the remaining client fields */
481 strlcpy(new_client->name, name, I2C_NAME_SIZE); 486 strlcpy(client->name, name, I2C_NAME_SIZE);
482 data->valid = 0;
483 mutex_init(&data->update_lock); 487 mutex_init(&data->update_lock);
484 488
485 /* Tell the I2C layer a new client has arrived */ 489 /* Tell the I2C layer a new client has arrived */
486 if ((err = i2c_attach_client(new_client))) 490 if ((err = i2c_attach_client(client)))
487 goto error_free; 491 goto error_free;
488 492
489 /* Initialize the LM80 chip */ 493 /* Initialize the LM80 chip */
490 lm80_init_client(new_client); 494 lm80_init_client(client);
491 495
492 /* A few vars need to be filled upon startup */ 496 /* A few vars need to be filled upon startup */
493 data->fan_min[0] = lm80_read_value(new_client, LM80_REG_FAN_MIN(1)); 497 data->fan_min[0] = lm80_read_value(client, LM80_REG_FAN_MIN(1));
494 data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2)); 498 data->fan_min[1] = lm80_read_value(client, LM80_REG_FAN_MIN(2));
495 499
496 /* Register sysfs hooks */ 500 /* Register sysfs hooks */
497 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm80_group))) 501 if ((err = sysfs_create_group(&client->dev.kobj, &lm80_group)))
498 goto error_detach; 502 goto error_detach;
499 503
500 data->hwmon_dev = hwmon_device_register(&new_client->dev); 504 data->hwmon_dev = hwmon_device_register(&client->dev);
501 if (IS_ERR(data->hwmon_dev)) { 505 if (IS_ERR(data->hwmon_dev)) {
502 err = PTR_ERR(data->hwmon_dev); 506 err = PTR_ERR(data->hwmon_dev);
503 goto error_remove; 507 goto error_remove;
@@ -506,9 +510,9 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
506 return 0; 510 return 0;
507 511
508error_remove: 512error_remove:
509 sysfs_remove_group(&new_client->dev.kobj, &lm80_group); 513 sysfs_remove_group(&client->dev.kobj, &lm80_group);
510error_detach: 514error_detach:
511 i2c_detach_client(new_client); 515 i2c_detach_client(client);
512error_free: 516error_free:
513 kfree(data); 517 kfree(data);
514exit: 518exit: