aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lm77.c33
-rw-r--r--drivers/hwmon/lm80.c85
-rw-r--r--drivers/hwmon/lm85.c173
-rw-r--r--drivers/hwmon/lm87.c191
-rw-r--r--drivers/hwmon/lm92.c34
5 files changed, 338 insertions, 178 deletions
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c
index 459cc977380a..dd969f1e8415 100644
--- a/drivers/hwmon/lm77.c
+++ b/drivers/hwmon/lm77.c
@@ -212,6 +212,23 @@ static int lm77_attach_adapter(struct i2c_adapter *adapter)
212 return i2c_probe(adapter, &addr_data, lm77_detect); 212 return i2c_probe(adapter, &addr_data, lm77_detect);
213} 213}
214 214
215static struct attribute *lm77_attributes[] = {
216 &dev_attr_temp1_input.attr,
217 &dev_attr_temp1_crit.attr,
218 &dev_attr_temp1_min.attr,
219 &dev_attr_temp1_max.attr,
220 &dev_attr_temp1_crit_hyst.attr,
221 &dev_attr_temp1_min_hyst.attr,
222 &dev_attr_temp1_max_hyst.attr,
223 &dev_attr_alarms.attr,
224
225 NULL
226};
227
228static const struct attribute_group lm77_group = {
229 .attrs = lm77_attributes,
230};
231
215/* This function is called by i2c_probe */ 232/* This function is called by i2c_probe */
216static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) 233static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
217{ 234{
@@ -317,22 +334,19 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
317 lm77_init_client(new_client); 334 lm77_init_client(new_client);
318 335
319 /* Register sysfs hooks */ 336 /* Register sysfs hooks */
337 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm77_group)))
338 goto exit_detach;
339
320 data->class_dev = hwmon_device_register(&new_client->dev); 340 data->class_dev = hwmon_device_register(&new_client->dev);
321 if (IS_ERR(data->class_dev)) { 341 if (IS_ERR(data->class_dev)) {
322 err = PTR_ERR(data->class_dev); 342 err = PTR_ERR(data->class_dev);
323 goto exit_detach; 343 goto exit_remove;
324 } 344 }
325 345
326 device_create_file(&new_client->dev, &dev_attr_temp1_input);
327 device_create_file(&new_client->dev, &dev_attr_temp1_crit);
328 device_create_file(&new_client->dev, &dev_attr_temp1_min);
329 device_create_file(&new_client->dev, &dev_attr_temp1_max);
330 device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst);
331 device_create_file(&new_client->dev, &dev_attr_temp1_min_hyst);
332 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
333 device_create_file(&new_client->dev, &dev_attr_alarms);
334 return 0; 346 return 0;
335 347
348exit_remove:
349 sysfs_remove_group(&new_client->dev.kobj, &lm77_group);
336exit_detach: 350exit_detach:
337 i2c_detach_client(new_client); 351 i2c_detach_client(new_client);
338exit_free: 352exit_free:
@@ -345,6 +359,7 @@ static int lm77_detach_client(struct i2c_client *client)
345{ 359{
346 struct lm77_data *data = i2c_get_clientdata(client); 360 struct lm77_data *data = i2c_get_clientdata(client);
347 hwmon_device_unregister(data->class_dev); 361 hwmon_device_unregister(data->class_dev);
362 sysfs_remove_group(&client->dev.kobj, &lm77_group);
348 i2c_detach_client(client); 363 i2c_detach_client(client);
349 kfree(data); 364 kfree(data);
350 return 0; 365 return 0;
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index b4ccdfc01203..064516d824ad 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -394,6 +394,48 @@ static int lm80_attach_adapter(struct i2c_adapter *adapter)
394 return i2c_probe(adapter, &addr_data, lm80_detect); 394 return i2c_probe(adapter, &addr_data, lm80_detect);
395} 395}
396 396
397static struct attribute *lm80_attributes[] = {
398 &dev_attr_in0_min.attr,
399 &dev_attr_in1_min.attr,
400 &dev_attr_in2_min.attr,
401 &dev_attr_in3_min.attr,
402 &dev_attr_in4_min.attr,
403 &dev_attr_in5_min.attr,
404 &dev_attr_in6_min.attr,
405 &dev_attr_in0_max.attr,
406 &dev_attr_in1_max.attr,
407 &dev_attr_in2_max.attr,
408 &dev_attr_in3_max.attr,
409 &dev_attr_in4_max.attr,
410 &dev_attr_in5_max.attr,
411 &dev_attr_in6_max.attr,
412 &dev_attr_in0_input.attr,
413 &dev_attr_in1_input.attr,
414 &dev_attr_in2_input.attr,
415 &dev_attr_in3_input.attr,
416 &dev_attr_in4_input.attr,
417 &dev_attr_in5_input.attr,
418 &dev_attr_in6_input.attr,
419 &dev_attr_fan1_min.attr,
420 &dev_attr_fan2_min.attr,
421 &dev_attr_fan1_input.attr,
422 &dev_attr_fan2_input.attr,
423 &dev_attr_fan1_div.attr,
424 &dev_attr_fan2_div.attr,
425 &dev_attr_temp1_input.attr,
426 &dev_attr_temp1_max.attr,
427 &dev_attr_temp1_max_hyst.attr,
428 &dev_attr_temp1_crit.attr,
429 &dev_attr_temp1_crit_hyst.attr,
430 &dev_attr_alarms.attr,
431
432 NULL
433};
434
435static const struct attribute_group lm80_group = {
436 .attrs = lm80_attributes,
437};
438
397static int lm80_detect(struct i2c_adapter *adapter, int address, int kind) 439static int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
398{ 440{
399 int i, cur; 441 int i, cur;
@@ -452,48 +494,19 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
452 data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2)); 494 data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2));
453 495
454 /* Register sysfs hooks */ 496 /* Register sysfs hooks */
497 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm80_group)))
498 goto error_detach;
499
455 data->class_dev = hwmon_device_register(&new_client->dev); 500 data->class_dev = hwmon_device_register(&new_client->dev);
456 if (IS_ERR(data->class_dev)) { 501 if (IS_ERR(data->class_dev)) {
457 err = PTR_ERR(data->class_dev); 502 err = PTR_ERR(data->class_dev);
458 goto error_detach; 503 goto error_remove;
459 } 504 }
460 505
461 device_create_file(&new_client->dev, &dev_attr_in0_min);
462 device_create_file(&new_client->dev, &dev_attr_in1_min);
463 device_create_file(&new_client->dev, &dev_attr_in2_min);
464 device_create_file(&new_client->dev, &dev_attr_in3_min);
465 device_create_file(&new_client->dev, &dev_attr_in4_min);
466 device_create_file(&new_client->dev, &dev_attr_in5_min);
467 device_create_file(&new_client->dev, &dev_attr_in6_min);
468 device_create_file(&new_client->dev, &dev_attr_in0_max);
469 device_create_file(&new_client->dev, &dev_attr_in1_max);
470 device_create_file(&new_client->dev, &dev_attr_in2_max);
471 device_create_file(&new_client->dev, &dev_attr_in3_max);
472 device_create_file(&new_client->dev, &dev_attr_in4_max);
473 device_create_file(&new_client->dev, &dev_attr_in5_max);
474 device_create_file(&new_client->dev, &dev_attr_in6_max);
475 device_create_file(&new_client->dev, &dev_attr_in0_input);
476 device_create_file(&new_client->dev, &dev_attr_in1_input);
477 device_create_file(&new_client->dev, &dev_attr_in2_input);
478 device_create_file(&new_client->dev, &dev_attr_in3_input);
479 device_create_file(&new_client->dev, &dev_attr_in4_input);
480 device_create_file(&new_client->dev, &dev_attr_in5_input);
481 device_create_file(&new_client->dev, &dev_attr_in6_input);
482 device_create_file(&new_client->dev, &dev_attr_fan1_min);
483 device_create_file(&new_client->dev, &dev_attr_fan2_min);
484 device_create_file(&new_client->dev, &dev_attr_fan1_input);
485 device_create_file(&new_client->dev, &dev_attr_fan2_input);
486 device_create_file(&new_client->dev, &dev_attr_fan1_div);
487 device_create_file(&new_client->dev, &dev_attr_fan2_div);
488 device_create_file(&new_client->dev, &dev_attr_temp1_input);
489 device_create_file(&new_client->dev, &dev_attr_temp1_max);
490 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
491 device_create_file(&new_client->dev, &dev_attr_temp1_crit);
492 device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst);
493 device_create_file(&new_client->dev, &dev_attr_alarms);
494
495 return 0; 506 return 0;
496 507
508error_remove:
509 sysfs_remove_group(&new_client->dev.kobj, &lm80_group);
497error_detach: 510error_detach:
498 i2c_detach_client(new_client); 511 i2c_detach_client(new_client);
499error_free: 512error_free:
@@ -508,7 +521,7 @@ static int lm80_detach_client(struct i2c_client *client)
508 int err; 521 int err;
509 522
510 hwmon_device_unregister(data->class_dev); 523 hwmon_device_unregister(data->class_dev);
511 524 sysfs_remove_group(&client->dev.kobj, &lm80_group);
512 if ((err = i2c_detach_client(client))) 525 if ((err = i2c_detach_client(client)))
513 return err; 526 return err;
514 527
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index 342e9663119d..2c3293cf69d1 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -1025,6 +1025,89 @@ static int lm85_attach_adapter(struct i2c_adapter *adapter)
1025 return i2c_probe(adapter, &addr_data, lm85_detect); 1025 return i2c_probe(adapter, &addr_data, lm85_detect);
1026} 1026}
1027 1027
1028static struct attribute *lm85_attributes[] = {
1029 &dev_attr_fan1_input.attr,
1030 &dev_attr_fan2_input.attr,
1031 &dev_attr_fan3_input.attr,
1032 &dev_attr_fan4_input.attr,
1033 &dev_attr_fan1_min.attr,
1034 &dev_attr_fan2_min.attr,
1035 &dev_attr_fan3_min.attr,
1036 &dev_attr_fan4_min.attr,
1037 &dev_attr_pwm1.attr,
1038 &dev_attr_pwm2.attr,
1039 &dev_attr_pwm3.attr,
1040 &dev_attr_pwm1_enable.attr,
1041 &dev_attr_pwm2_enable.attr,
1042 &dev_attr_pwm3_enable.attr,
1043 &dev_attr_in0_input.attr,
1044 &dev_attr_in1_input.attr,
1045 &dev_attr_in2_input.attr,
1046 &dev_attr_in3_input.attr,
1047 &dev_attr_in0_min.attr,
1048 &dev_attr_in1_min.attr,
1049 &dev_attr_in2_min.attr,
1050 &dev_attr_in3_min.attr,
1051 &dev_attr_in0_max.attr,
1052 &dev_attr_in1_max.attr,
1053 &dev_attr_in2_max.attr,
1054 &dev_attr_in3_max.attr,
1055 &dev_attr_temp1_input.attr,
1056 &dev_attr_temp2_input.attr,
1057 &dev_attr_temp3_input.attr,
1058 &dev_attr_temp1_min.attr,
1059 &dev_attr_temp2_min.attr,
1060 &dev_attr_temp3_min.attr,
1061 &dev_attr_temp1_max.attr,
1062 &dev_attr_temp2_max.attr,
1063 &dev_attr_temp3_max.attr,
1064 &dev_attr_vrm.attr,
1065 &dev_attr_cpu0_vid.attr,
1066 &dev_attr_alarms.attr,
1067 &dev_attr_pwm1_auto_channels.attr,
1068 &dev_attr_pwm2_auto_channels.attr,
1069 &dev_attr_pwm3_auto_channels.attr,
1070 &dev_attr_pwm1_auto_pwm_min.attr,
1071 &dev_attr_pwm2_auto_pwm_min.attr,
1072 &dev_attr_pwm3_auto_pwm_min.attr,
1073 &dev_attr_pwm1_auto_pwm_minctl.attr,
1074 &dev_attr_pwm2_auto_pwm_minctl.attr,
1075 &dev_attr_pwm3_auto_pwm_minctl.attr,
1076 &dev_attr_pwm1_auto_pwm_freq.attr,
1077 &dev_attr_pwm2_auto_pwm_freq.attr,
1078 &dev_attr_pwm3_auto_pwm_freq.attr,
1079 &dev_attr_temp1_auto_temp_off.attr,
1080 &dev_attr_temp2_auto_temp_off.attr,
1081 &dev_attr_temp3_auto_temp_off.attr,
1082 &dev_attr_temp1_auto_temp_min.attr,
1083 &dev_attr_temp2_auto_temp_min.attr,
1084 &dev_attr_temp3_auto_temp_min.attr,
1085 &dev_attr_temp1_auto_temp_max.attr,
1086 &dev_attr_temp2_auto_temp_max.attr,
1087 &dev_attr_temp3_auto_temp_max.attr,
1088 &dev_attr_temp1_auto_temp_crit.attr,
1089 &dev_attr_temp2_auto_temp_crit.attr,
1090 &dev_attr_temp3_auto_temp_crit.attr,
1091
1092 NULL
1093};
1094
1095static const struct attribute_group lm85_group = {
1096 .attrs = lm85_attributes,
1097};
1098
1099static struct attribute *lm85_attributes_opt[] = {
1100 &dev_attr_in4_input.attr,
1101 &dev_attr_in4_min.attr,
1102 &dev_attr_in4_max.attr,
1103
1104 NULL
1105};
1106
1107static const struct attribute_group lm85_group_opt = {
1108 .attrs = lm85_attributes_opt,
1109};
1110
1028static int lm85_detect(struct i2c_adapter *adapter, int address, 1111static int lm85_detect(struct i2c_adapter *adapter, int address,
1029 int kind) 1112 int kind)
1030{ 1113{
@@ -1163,87 +1246,33 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
1163 lm85_init_client(new_client); 1246 lm85_init_client(new_client);
1164 1247
1165 /* Register sysfs hooks */ 1248 /* Register sysfs hooks */
1166 data->class_dev = hwmon_device_register(&new_client->dev); 1249 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm85_group)))
1167 if (IS_ERR(data->class_dev)) {
1168 err = PTR_ERR(data->class_dev);
1169 goto ERROR2; 1250 goto ERROR2;
1170 }
1171
1172 device_create_file(&new_client->dev, &dev_attr_fan1_input);
1173 device_create_file(&new_client->dev, &dev_attr_fan2_input);
1174 device_create_file(&new_client->dev, &dev_attr_fan3_input);
1175 device_create_file(&new_client->dev, &dev_attr_fan4_input);
1176 device_create_file(&new_client->dev, &dev_attr_fan1_min);
1177 device_create_file(&new_client->dev, &dev_attr_fan2_min);
1178 device_create_file(&new_client->dev, &dev_attr_fan3_min);
1179 device_create_file(&new_client->dev, &dev_attr_fan4_min);
1180 device_create_file(&new_client->dev, &dev_attr_pwm1);
1181 device_create_file(&new_client->dev, &dev_attr_pwm2);
1182 device_create_file(&new_client->dev, &dev_attr_pwm3);
1183 device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
1184 device_create_file(&new_client->dev, &dev_attr_pwm2_enable);
1185 device_create_file(&new_client->dev, &dev_attr_pwm3_enable);
1186 device_create_file(&new_client->dev, &dev_attr_in0_input);
1187 device_create_file(&new_client->dev, &dev_attr_in1_input);
1188 device_create_file(&new_client->dev, &dev_attr_in2_input);
1189 device_create_file(&new_client->dev, &dev_attr_in3_input);
1190 device_create_file(&new_client->dev, &dev_attr_in0_min);
1191 device_create_file(&new_client->dev, &dev_attr_in1_min);
1192 device_create_file(&new_client->dev, &dev_attr_in2_min);
1193 device_create_file(&new_client->dev, &dev_attr_in3_min);
1194 device_create_file(&new_client->dev, &dev_attr_in0_max);
1195 device_create_file(&new_client->dev, &dev_attr_in1_max);
1196 device_create_file(&new_client->dev, &dev_attr_in2_max);
1197 device_create_file(&new_client->dev, &dev_attr_in3_max);
1198 device_create_file(&new_client->dev, &dev_attr_temp1_input);
1199 device_create_file(&new_client->dev, &dev_attr_temp2_input);
1200 device_create_file(&new_client->dev, &dev_attr_temp3_input);
1201 device_create_file(&new_client->dev, &dev_attr_temp1_min);
1202 device_create_file(&new_client->dev, &dev_attr_temp2_min);
1203 device_create_file(&new_client->dev, &dev_attr_temp3_min);
1204 device_create_file(&new_client->dev, &dev_attr_temp1_max);
1205 device_create_file(&new_client->dev, &dev_attr_temp2_max);
1206 device_create_file(&new_client->dev, &dev_attr_temp3_max);
1207 device_create_file(&new_client->dev, &dev_attr_vrm);
1208 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
1209 device_create_file(&new_client->dev, &dev_attr_alarms);
1210 device_create_file(&new_client->dev, &dev_attr_pwm1_auto_channels);
1211 device_create_file(&new_client->dev, &dev_attr_pwm2_auto_channels);
1212 device_create_file(&new_client->dev, &dev_attr_pwm3_auto_channels);
1213 device_create_file(&new_client->dev, &dev_attr_pwm1_auto_pwm_min);
1214 device_create_file(&new_client->dev, &dev_attr_pwm2_auto_pwm_min);
1215 device_create_file(&new_client->dev, &dev_attr_pwm3_auto_pwm_min);
1216 device_create_file(&new_client->dev, &dev_attr_pwm1_auto_pwm_minctl);
1217 device_create_file(&new_client->dev, &dev_attr_pwm2_auto_pwm_minctl);
1218 device_create_file(&new_client->dev, &dev_attr_pwm3_auto_pwm_minctl);
1219 device_create_file(&new_client->dev, &dev_attr_pwm1_auto_pwm_freq);
1220 device_create_file(&new_client->dev, &dev_attr_pwm2_auto_pwm_freq);
1221 device_create_file(&new_client->dev, &dev_attr_pwm3_auto_pwm_freq);
1222 device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_off);
1223 device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_off);
1224 device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_off);
1225 device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_min);
1226 device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_min);
1227 device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_min);
1228 device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_max);
1229 device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_max);
1230 device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_max);
1231 device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_crit);
1232 device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_crit);
1233 device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_crit);
1234 1251
1235 /* The ADT7463 has an optional VRM 10 mode where pin 21 is used 1252 /* The ADT7463 has an optional VRM 10 mode where pin 21 is used
1236 as a sixth digital VID input rather than an analog input. */ 1253 as a sixth digital VID input rather than an analog input. */
1237 data->vid = lm85_read_value(new_client, LM85_REG_VID); 1254 data->vid = lm85_read_value(new_client, LM85_REG_VID);
1238 if (!(kind == adt7463 && (data->vid & 0x80))) { 1255 if (!(kind == adt7463 && (data->vid & 0x80)))
1239 device_create_file(&new_client->dev, &dev_attr_in4_input); 1256 if ((err = device_create_file(&new_client->dev,
1240 device_create_file(&new_client->dev, &dev_attr_in4_min); 1257 &dev_attr_in4_input))
1241 device_create_file(&new_client->dev, &dev_attr_in4_max); 1258 || (err = device_create_file(&new_client->dev,
1259 &dev_attr_in4_min))
1260 || (err = device_create_file(&new_client->dev,
1261 &dev_attr_in4_max)))
1262 goto ERROR3;
1263
1264 data->class_dev = hwmon_device_register(&new_client->dev);
1265 if (IS_ERR(data->class_dev)) {
1266 err = PTR_ERR(data->class_dev);
1267 goto ERROR3;
1242 } 1268 }
1243 1269
1244 return 0; 1270 return 0;
1245 1271
1246 /* Error out and cleanup code */ 1272 /* Error out and cleanup code */
1273 ERROR3:
1274 sysfs_remove_group(&new_client->dev.kobj, &lm85_group);
1275 sysfs_remove_group(&new_client->dev.kobj, &lm85_group_opt);
1247 ERROR2: 1276 ERROR2:
1248 i2c_detach_client(new_client); 1277 i2c_detach_client(new_client);
1249 ERROR1: 1278 ERROR1:
@@ -1256,6 +1285,8 @@ static int lm85_detach_client(struct i2c_client *client)
1256{ 1285{
1257 struct lm85_data *data = i2c_get_clientdata(client); 1286 struct lm85_data *data = i2c_get_clientdata(client);
1258 hwmon_device_unregister(data->class_dev); 1287 hwmon_device_unregister(data->class_dev);
1288 sysfs_remove_group(&client->dev.kobj, &lm85_group);
1289 sysfs_remove_group(&client->dev.kobj, &lm85_group_opt);
1259 i2c_detach_client(client); 1290 i2c_detach_client(client);
1260 kfree(data); 1291 kfree(data);
1261 return 0; 1292 return 0;
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index e6c1b638c971..3ce825489e34 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -542,6 +542,78 @@ static int lm87_attach_adapter(struct i2c_adapter *adapter)
542 return i2c_probe(adapter, &addr_data, lm87_detect); 542 return i2c_probe(adapter, &addr_data, lm87_detect);
543} 543}
544 544
545static struct attribute *lm87_attributes[] = {
546 &dev_attr_in1_input.attr,
547 &dev_attr_in1_min.attr,
548 &dev_attr_in1_max.attr,
549 &dev_attr_in2_input.attr,
550 &dev_attr_in2_min.attr,
551 &dev_attr_in2_max.attr,
552 &dev_attr_in3_input.attr,
553 &dev_attr_in3_min.attr,
554 &dev_attr_in3_max.attr,
555 &dev_attr_in4_input.attr,
556 &dev_attr_in4_min.attr,
557 &dev_attr_in4_max.attr,
558
559 &dev_attr_temp1_input.attr,
560 &dev_attr_temp1_max.attr,
561 &dev_attr_temp1_min.attr,
562 &dev_attr_temp1_crit.attr,
563 &dev_attr_temp2_input.attr,
564 &dev_attr_temp2_max.attr,
565 &dev_attr_temp2_min.attr,
566 &dev_attr_temp2_crit.attr,
567
568 &dev_attr_alarms.attr,
569 &dev_attr_aout_output.attr,
570
571 NULL
572};
573
574static const struct attribute_group lm87_group = {
575 .attrs = lm87_attributes,
576};
577
578static struct attribute *lm87_attributes_opt[] = {
579 &dev_attr_in6_input.attr,
580 &dev_attr_in6_min.attr,
581 &dev_attr_in6_max.attr,
582
583 &dev_attr_fan1_input.attr,
584 &dev_attr_fan1_min.attr,
585 &dev_attr_fan1_div.attr,
586
587 &dev_attr_in7_input.attr,
588 &dev_attr_in7_min.attr,
589 &dev_attr_in7_max.attr,
590
591 &dev_attr_fan2_input.attr,
592 &dev_attr_fan2_min.attr,
593 &dev_attr_fan2_div.attr,
594
595 &dev_attr_temp3_input.attr,
596 &dev_attr_temp3_max.attr,
597 &dev_attr_temp3_min.attr,
598 &dev_attr_temp3_crit.attr,
599
600 &dev_attr_in0_input.attr,
601 &dev_attr_in0_min.attr,
602 &dev_attr_in0_max.attr,
603 &dev_attr_in5_input.attr,
604 &dev_attr_in5_min.attr,
605 &dev_attr_in5_max.attr,
606
607 &dev_attr_cpu0_vid.attr,
608 &dev_attr_vrm.attr,
609
610 NULL
611};
612
613static const struct attribute_group lm87_group_opt = {
614 .attrs = lm87_attributes_opt,
615};
616
545/* 617/*
546 * The following function does more than just detection. If detection 618 * The following function does more than just detection. If detection
547 * succeeds, it also registers the new chip. 619 * succeeds, it also registers the new chip.
@@ -609,77 +681,90 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
609 data->in_scale[7] = 1875; 681 data->in_scale[7] = 1875;
610 682
611 /* Register sysfs hooks */ 683 /* Register sysfs hooks */
612 data->class_dev = hwmon_device_register(&new_client->dev); 684 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm87_group)))
613 if (IS_ERR(data->class_dev)) {
614 err = PTR_ERR(data->class_dev);
615 goto exit_detach; 685 goto exit_detach;
616 }
617
618 device_create_file(&new_client->dev, &dev_attr_in1_input);
619 device_create_file(&new_client->dev, &dev_attr_in1_min);
620 device_create_file(&new_client->dev, &dev_attr_in1_max);
621 device_create_file(&new_client->dev, &dev_attr_in2_input);
622 device_create_file(&new_client->dev, &dev_attr_in2_min);
623 device_create_file(&new_client->dev, &dev_attr_in2_max);
624 device_create_file(&new_client->dev, &dev_attr_in3_input);
625 device_create_file(&new_client->dev, &dev_attr_in3_min);
626 device_create_file(&new_client->dev, &dev_attr_in3_max);
627 device_create_file(&new_client->dev, &dev_attr_in4_input);
628 device_create_file(&new_client->dev, &dev_attr_in4_min);
629 device_create_file(&new_client->dev, &dev_attr_in4_max);
630 686
631 if (data->channel & CHAN_NO_FAN(0)) { 687 if (data->channel & CHAN_NO_FAN(0)) {
632 device_create_file(&new_client->dev, &dev_attr_in6_input); 688 if ((err = device_create_file(&new_client->dev,
633 device_create_file(&new_client->dev, &dev_attr_in6_min); 689 &dev_attr_in6_input))
634 device_create_file(&new_client->dev, &dev_attr_in6_max); 690 || (err = device_create_file(&new_client->dev,
691 &dev_attr_in6_min))
692 || (err = device_create_file(&new_client->dev,
693 &dev_attr_in6_max)))
694 goto exit_remove;
635 } else { 695 } else {
636 device_create_file(&new_client->dev, &dev_attr_fan1_input); 696 if ((err = device_create_file(&new_client->dev,
637 device_create_file(&new_client->dev, &dev_attr_fan1_min); 697 &dev_attr_fan1_input))
638 device_create_file(&new_client->dev, &dev_attr_fan1_div); 698 || (err = device_create_file(&new_client->dev,
699 &dev_attr_fan1_min))
700 || (err = device_create_file(&new_client->dev,
701 &dev_attr_fan1_div)))
702 goto exit_remove;
639 } 703 }
704
640 if (data->channel & CHAN_NO_FAN(1)) { 705 if (data->channel & CHAN_NO_FAN(1)) {
641 device_create_file(&new_client->dev, &dev_attr_in7_input); 706 if ((err = device_create_file(&new_client->dev,
642 device_create_file(&new_client->dev, &dev_attr_in7_min); 707 &dev_attr_in7_input))
643 device_create_file(&new_client->dev, &dev_attr_in7_max); 708 || (err = device_create_file(&new_client->dev,
709 &dev_attr_in7_min))
710 || (err = device_create_file(&new_client->dev,
711 &dev_attr_in7_max)))
712 goto exit_remove;
644 } else { 713 } else {
645 device_create_file(&new_client->dev, &dev_attr_fan2_input); 714 if ((err = device_create_file(&new_client->dev,
646 device_create_file(&new_client->dev, &dev_attr_fan2_min); 715 &dev_attr_fan2_input))
647 device_create_file(&new_client->dev, &dev_attr_fan2_div); 716 || (err = device_create_file(&new_client->dev,
717 &dev_attr_fan2_min))
718 || (err = device_create_file(&new_client->dev,
719 &dev_attr_fan2_div)))
720 goto exit_remove;
648 } 721 }
649 722
650 device_create_file(&new_client->dev, &dev_attr_temp1_input);
651 device_create_file(&new_client->dev, &dev_attr_temp1_max);
652 device_create_file(&new_client->dev, &dev_attr_temp1_min);
653 device_create_file(&new_client->dev, &dev_attr_temp1_crit);
654 device_create_file(&new_client->dev, &dev_attr_temp2_input);
655 device_create_file(&new_client->dev, &dev_attr_temp2_max);
656 device_create_file(&new_client->dev, &dev_attr_temp2_min);
657 device_create_file(&new_client->dev, &dev_attr_temp2_crit);
658
659 if (data->channel & CHAN_TEMP3) { 723 if (data->channel & CHAN_TEMP3) {
660 device_create_file(&new_client->dev, &dev_attr_temp3_input); 724 if ((err = device_create_file(&new_client->dev,
661 device_create_file(&new_client->dev, &dev_attr_temp3_max); 725 &dev_attr_temp3_input))
662 device_create_file(&new_client->dev, &dev_attr_temp3_min); 726 || (err = device_create_file(&new_client->dev,
663 device_create_file(&new_client->dev, &dev_attr_temp3_crit); 727 &dev_attr_temp3_max))
728 || (err = device_create_file(&new_client->dev,
729 &dev_attr_temp3_min))
730 || (err = device_create_file(&new_client->dev,
731 &dev_attr_temp3_crit)))
732 goto exit_remove;
664 } else { 733 } else {
665 device_create_file(&new_client->dev, &dev_attr_in0_input); 734 if ((err = device_create_file(&new_client->dev,
666 device_create_file(&new_client->dev, &dev_attr_in0_min); 735 &dev_attr_in0_input))
667 device_create_file(&new_client->dev, &dev_attr_in0_max); 736 || (err = device_create_file(&new_client->dev,
668 device_create_file(&new_client->dev, &dev_attr_in5_input); 737 &dev_attr_in0_min))
669 device_create_file(&new_client->dev, &dev_attr_in5_min); 738 || (err = device_create_file(&new_client->dev,
670 device_create_file(&new_client->dev, &dev_attr_in5_max); 739 &dev_attr_in0_max))
740 || (err = device_create_file(&new_client->dev,
741 &dev_attr_in5_input))
742 || (err = device_create_file(&new_client->dev,
743 &dev_attr_in5_min))
744 || (err = device_create_file(&new_client->dev,
745 &dev_attr_in5_max)))
746 goto exit_remove;
671 } 747 }
672 748
673 if (!(data->channel & CHAN_NO_VID)) { 749 if (!(data->channel & CHAN_NO_VID)) {
674 device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 750 if ((err = device_create_file(&new_client->dev,
675 device_create_file(&new_client->dev, &dev_attr_vrm); 751 &dev_attr_cpu0_vid))
752 || (err = device_create_file(&new_client->dev,
753 &dev_attr_vrm)))
754 goto exit_remove;
676 } 755 }
677 756
678 device_create_file(&new_client->dev, &dev_attr_alarms); 757 data->class_dev = hwmon_device_register(&new_client->dev);
679 device_create_file(&new_client->dev, &dev_attr_aout_output); 758 if (IS_ERR(data->class_dev)) {
759 err = PTR_ERR(data->class_dev);
760 goto exit_remove;
761 }
680 762
681 return 0; 763 return 0;
682 764
765exit_remove:
766 sysfs_remove_group(&new_client->dev.kobj, &lm87_group);
767 sysfs_remove_group(&new_client->dev.kobj, &lm87_group_opt);
683exit_detach: 768exit_detach:
684 i2c_detach_client(new_client); 769 i2c_detach_client(new_client);
685exit_free: 770exit_free:
@@ -732,6 +817,8 @@ static int lm87_detach_client(struct i2c_client *client)
732 int err; 817 int err;
733 818
734 hwmon_device_unregister(data->class_dev); 819 hwmon_device_unregister(data->class_dev);
820 sysfs_remove_group(&client->dev.kobj, &lm87_group);
821 sysfs_remove_group(&client->dev.kobj, &lm87_group_opt);
735 822
736 if ((err = i2c_detach_client(client))) 823 if ((err = i2c_detach_client(client)))
737 return err; 824 return err;
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index 197f77226dc4..30b536333f14 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -288,6 +288,23 @@ static int max6635_check(struct i2c_client *client)
288 return 1; 288 return 1;
289} 289}
290 290
291static struct attribute *lm92_attributes[] = {
292 &dev_attr_temp1_input.attr,
293 &dev_attr_temp1_crit.attr,
294 &dev_attr_temp1_crit_hyst.attr,
295 &dev_attr_temp1_min.attr,
296 &dev_attr_temp1_min_hyst.attr,
297 &dev_attr_temp1_max.attr,
298 &dev_attr_temp1_max_hyst.attr,
299 &dev_attr_alarms.attr,
300
301 NULL
302};
303
304static const struct attribute_group lm92_group = {
305 .attrs = lm92_attributes,
306};
307
291/* The following function does more than just detection. If detection 308/* The following function does more than just detection. If detection
292 succeeds, it also registers the new chip. */ 309 succeeds, it also registers the new chip. */
293static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) 310static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -359,23 +376,19 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
359 lm92_init_client(new_client); 376 lm92_init_client(new_client);
360 377
361 /* Register sysfs hooks */ 378 /* Register sysfs hooks */
379 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm92_group)))
380 goto exit_detach;
381
362 data->class_dev = hwmon_device_register(&new_client->dev); 382 data->class_dev = hwmon_device_register(&new_client->dev);
363 if (IS_ERR(data->class_dev)) { 383 if (IS_ERR(data->class_dev)) {
364 err = PTR_ERR(data->class_dev); 384 err = PTR_ERR(data->class_dev);
365 goto exit_detach; 385 goto exit_remove;
366 } 386 }
367 387
368 device_create_file(&new_client->dev, &dev_attr_temp1_input);
369 device_create_file(&new_client->dev, &dev_attr_temp1_crit);
370 device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst);
371 device_create_file(&new_client->dev, &dev_attr_temp1_min);
372 device_create_file(&new_client->dev, &dev_attr_temp1_min_hyst);
373 device_create_file(&new_client->dev, &dev_attr_temp1_max);
374 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
375 device_create_file(&new_client->dev, &dev_attr_alarms);
376
377 return 0; 388 return 0;
378 389
390exit_remove:
391 sysfs_remove_group(&new_client->dev.kobj, &lm92_group);
379exit_detach: 392exit_detach:
380 i2c_detach_client(new_client); 393 i2c_detach_client(new_client);
381exit_free: 394exit_free:
@@ -397,6 +410,7 @@ static int lm92_detach_client(struct i2c_client *client)
397 int err; 410 int err;
398 411
399 hwmon_device_unregister(data->class_dev); 412 hwmon_device_unregister(data->class_dev);
413 sysfs_remove_group(&client->dev.kobj, &lm92_group);
400 414
401 if ((err = i2c_detach_client(client))) 415 if ((err = i2c_detach_client(client)))
402 return err; 416 return err;