aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Cromie <jim.cromie@gmail.com>2006-09-24 15:22:52 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-28 18:31:18 -0400
commit311ce2efb1b640584676fc1b0b7f16c5baf85eb8 (patch)
tree8f3cb7fdf3513a36390411d19610a00a7adbc0d8
parentcbeeb5b7c91b23967162185d7580048559db8d58 (diff)
w83781d: Fix unchecked return status
w83781d: Fix unchecked return status Add 2 attr-file groups (for base and model-specific attrs respectively), create the base group with single call to sysfs_create_group, check the return code on individual calls to device_create_file for each of the model-specific attr-files. Signed-off-by: Jim Cromie <jim.cromie@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/hwmon/w83781d.c277
1 files changed, 143 insertions, 134 deletions
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 95221b14e13a..a4584ec69842 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -41,6 +41,7 @@
41#include <linux/i2c-isa.h> 41#include <linux/i2c-isa.h>
42#include <linux/hwmon.h> 42#include <linux/hwmon.h>
43#include <linux/hwmon-vid.h> 43#include <linux/hwmon-vid.h>
44#include <linux/sysfs.h>
44#include <linux/err.h> 45#include <linux/err.h>
45#include <linux/mutex.h> 46#include <linux/mutex.h>
46#include <asm/io.h> 47#include <asm/io.h>
@@ -360,13 +361,6 @@ sysfs_in_offsets(6);
360sysfs_in_offsets(7); 361sysfs_in_offsets(7);
361sysfs_in_offsets(8); 362sysfs_in_offsets(8);
362 363
363#define device_create_file_in(client, offset) \
364do { \
365device_create_file(&client->dev, &dev_attr_in##offset##_input); \
366device_create_file(&client->dev, &dev_attr_in##offset##_min); \
367device_create_file(&client->dev, &dev_attr_in##offset##_max); \
368} while (0)
369
370#define show_fan_reg(reg) \ 364#define show_fan_reg(reg) \
371static ssize_t show_##reg (struct device *dev, char *buf, int nr) \ 365static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
372{ \ 366{ \
@@ -421,12 +415,6 @@ sysfs_fan_min_offset(2);
421sysfs_fan_offset(3); 415sysfs_fan_offset(3);
422sysfs_fan_min_offset(3); 416sysfs_fan_min_offset(3);
423 417
424#define device_create_file_fan(client, offset) \
425do { \
426device_create_file(&client->dev, &dev_attr_fan##offset##_input); \
427device_create_file(&client->dev, &dev_attr_fan##offset##_min); \
428} while (0)
429
430#define show_temp_reg(reg) \ 418#define show_temp_reg(reg) \
431static ssize_t show_##reg (struct device *dev, char *buf, int nr) \ 419static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
432{ \ 420{ \
@@ -497,13 +485,6 @@ sysfs_temp_offsets(1);
497sysfs_temp_offsets(2); 485sysfs_temp_offsets(2);
498sysfs_temp_offsets(3); 486sysfs_temp_offsets(3);
499 487
500#define device_create_file_temp(client, offset) \
501do { \
502device_create_file(&client->dev, &dev_attr_temp##offset##_input); \
503device_create_file(&client->dev, &dev_attr_temp##offset##_max); \
504device_create_file(&client->dev, &dev_attr_temp##offset##_max_hyst); \
505} while (0)
506
507static ssize_t 488static ssize_t
508show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) 489show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
509{ 490{
@@ -511,10 +492,8 @@ show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
511 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); 492 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm));
512} 493}
513 494
514static 495static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
515DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); 496
516#define device_create_file_vid(client) \
517device_create_file(&client->dev, &dev_attr_cpu0_vid);
518static ssize_t 497static ssize_t
519show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) 498show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
520{ 499{
@@ -535,10 +514,8 @@ store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf
535 return count; 514 return count;
536} 515}
537 516
538static 517static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
539DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); 518
540#define device_create_file_vrm(client) \
541device_create_file(&client->dev, &dev_attr_vrm);
542static ssize_t 519static ssize_t
543show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) 520show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
544{ 521{
@@ -546,10 +523,8 @@ show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
546 return sprintf(buf, "%u\n", data->alarms); 523 return sprintf(buf, "%u\n", data->alarms);
547} 524}
548 525
549static 526static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
550DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); 527
551#define device_create_file_alarms(client) \
552device_create_file(&client->dev, &dev_attr_alarms);
553static ssize_t show_beep_mask (struct device *dev, struct device_attribute *attr, char *buf) 528static ssize_t show_beep_mask (struct device *dev, struct device_attribute *attr, char *buf)
554{ 529{
555 struct w83781d_data *data = w83781d_update_device(dev); 530 struct w83781d_data *data = w83781d_update_device(dev);
@@ -615,12 +590,6 @@ static DEVICE_ATTR(beep_##reg, S_IRUGO | S_IWUSR, show_regs_beep_##reg, store_re
615sysfs_beep(ENABLE, enable); 590sysfs_beep(ENABLE, enable);
616sysfs_beep(MASK, mask); 591sysfs_beep(MASK, mask);
617 592
618#define device_create_file_beep(client) \
619do { \
620device_create_file(&client->dev, &dev_attr_beep_enable); \
621device_create_file(&client->dev, &dev_attr_beep_mask); \
622} while (0)
623
624static ssize_t 593static ssize_t
625show_fan_div_reg(struct device *dev, char *buf, int nr) 594show_fan_div_reg(struct device *dev, char *buf, int nr)
626{ 595{
@@ -686,11 +655,6 @@ sysfs_fan_div(1);
686sysfs_fan_div(2); 655sysfs_fan_div(2);
687sysfs_fan_div(3); 656sysfs_fan_div(3);
688 657
689#define device_create_file_fan_div(client, offset) \
690do { \
691device_create_file(&client->dev, &dev_attr_fan##offset##_div); \
692} while (0)
693
694static ssize_t 658static ssize_t
695show_pwm_reg(struct device *dev, char *buf, int nr) 659show_pwm_reg(struct device *dev, char *buf, int nr)
696{ 660{
@@ -787,16 +751,6 @@ sysfs_pwmenable(2); /* only PWM2 can be enabled/disabled */
787sysfs_pwm(3); 751sysfs_pwm(3);
788sysfs_pwm(4); 752sysfs_pwm(4);
789 753
790#define device_create_file_pwm(client, offset) \
791do { \
792device_create_file(&client->dev, &dev_attr_pwm##offset); \
793} while (0)
794
795#define device_create_file_pwmenable(client, offset) \
796do { \
797device_create_file(&client->dev, &dev_attr_pwm##offset##_enable); \
798} while (0)
799
800static ssize_t 754static ssize_t
801show_sensor_reg(struct device *dev, char *buf, int nr) 755show_sensor_reg(struct device *dev, char *buf, int nr)
802{ 756{
@@ -865,11 +819,6 @@ sysfs_sensor(1);
865sysfs_sensor(2); 819sysfs_sensor(2);
866sysfs_sensor(3); 820sysfs_sensor(3);
867 821
868#define device_create_file_sensor(client, offset) \
869do { \
870device_create_file(&client->dev, &dev_attr_temp##offset##_type); \
871} while (0)
872
873/* This function is called when: 822/* This function is called when:
874 * w83781d_driver is inserted (when this module is loaded), for each 823 * w83781d_driver is inserted (when this module is loaded), for each
875 available adapter 824 available adapter
@@ -994,11 +943,69 @@ ERROR_SC_0:
994 return err; 943 return err;
995} 944}
996 945
946#define IN_UNIT_ATTRS(X) \
947 &dev_attr_in##X##_input.attr, \
948 &dev_attr_in##X##_min.attr, \
949 &dev_attr_in##X##_max.attr
950
951#define FAN_UNIT_ATTRS(X) \
952 &dev_attr_fan##X##_input.attr, \
953 &dev_attr_fan##X##_min.attr, \
954 &dev_attr_fan##X##_div.attr
955
956#define TEMP_UNIT_ATTRS(X) \
957 &dev_attr_temp##X##_input.attr, \
958 &dev_attr_temp##X##_max.attr, \
959 &dev_attr_temp##X##_max_hyst.attr
960
961static struct attribute* w83781d_attributes[] = {
962 IN_UNIT_ATTRS(0),
963 IN_UNIT_ATTRS(2),
964 IN_UNIT_ATTRS(3),
965 IN_UNIT_ATTRS(4),
966 IN_UNIT_ATTRS(5),
967 IN_UNIT_ATTRS(6),
968 FAN_UNIT_ATTRS(1),
969 FAN_UNIT_ATTRS(2),
970 FAN_UNIT_ATTRS(3),
971 TEMP_UNIT_ATTRS(1),
972 TEMP_UNIT_ATTRS(2),
973 &dev_attr_cpu0_vid.attr,
974 &dev_attr_vrm.attr,
975 &dev_attr_alarms.attr,
976 &dev_attr_beep_mask.attr,
977 &dev_attr_beep_enable.attr,
978 NULL
979};
980static const struct attribute_group w83781d_group = {
981 .attrs = w83781d_attributes,
982};
983
984static struct attribute *w83781d_attributes_opt[] = {
985 IN_UNIT_ATTRS(1),
986 IN_UNIT_ATTRS(7),
987 IN_UNIT_ATTRS(8),
988 TEMP_UNIT_ATTRS(3),
989 &dev_attr_pwm1.attr,
990 &dev_attr_pwm2.attr,
991 &dev_attr_pwm2_enable.attr,
992 &dev_attr_pwm3.attr,
993 &dev_attr_pwm4.attr,
994 &dev_attr_temp1_type.attr,
995 &dev_attr_temp2_type.attr,
996 &dev_attr_temp3_type.attr,
997 NULL
998};
999static const struct attribute_group w83781d_group_opt = {
1000 .attrs = w83781d_attributes_opt,
1001};
1002
997static int 1003static int
998w83781d_detect(struct i2c_adapter *adapter, int address, int kind) 1004w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
999{ 1005{
1000 int i = 0, val1 = 0, val2; 1006 int i = 0, val1 = 0, val2;
1001 struct i2c_client *new_client; 1007 struct i2c_client *client;
1008 struct device *dev;
1002 struct w83781d_data *data; 1009 struct w83781d_data *data;
1003 int err; 1010 int err;
1004 const char *client_name = ""; 1011 const char *client_name = "";
@@ -1075,13 +1082,14 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1075 goto ERROR1; 1082 goto ERROR1;
1076 } 1083 }
1077 1084
1078 new_client = &data->client; 1085 client = &data->client;
1079 i2c_set_clientdata(new_client, data); 1086 i2c_set_clientdata(client, data);
1080 new_client->addr = address; 1087 client->addr = address;
1081 mutex_init(&data->lock); 1088 mutex_init(&data->lock);
1082 new_client->adapter = adapter; 1089 client->adapter = adapter;
1083 new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver; 1090 client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver;
1084 new_client->flags = 0; 1091 client->flags = 0;
1092 dev = &client->dev;
1085 1093
1086 /* Now, we do the remaining detection. */ 1094 /* Now, we do the remaining detection. */
1087 1095
@@ -1090,20 +1098,18 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1090 force_*=... parameter, and the Winbond will be reset to the right 1098 force_*=... parameter, and the Winbond will be reset to the right
1091 bank. */ 1099 bank. */
1092 if (kind < 0) { 1100 if (kind < 0) {
1093 if (w83781d_read_value(new_client, W83781D_REG_CONFIG) & 0x80) { 1101 if (w83781d_read_value(client, W83781D_REG_CONFIG) & 0x80) {
1094 dev_dbg(&new_client->dev, "Detection failed at step " 1102 dev_dbg(dev, "Detection failed at step 3\n");
1095 "3\n");
1096 err = -ENODEV; 1103 err = -ENODEV;
1097 goto ERROR2; 1104 goto ERROR2;
1098 } 1105 }
1099 val1 = w83781d_read_value(new_client, W83781D_REG_BANK); 1106 val1 = w83781d_read_value(client, W83781D_REG_BANK);
1100 val2 = w83781d_read_value(new_client, W83781D_REG_CHIPMAN); 1107 val2 = w83781d_read_value(client, W83781D_REG_CHIPMAN);
1101 /* Check for Winbond or Asus ID if in bank 0 */ 1108 /* Check for Winbond or Asus ID if in bank 0 */
1102 if ((!(val1 & 0x07)) && 1109 if ((!(val1 & 0x07)) &&
1103 (((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3)) 1110 (((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3))
1104 || ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12)))) { 1111 || ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12)))) {
1105 dev_dbg(&new_client->dev, "Detection failed at step " 1112 dev_dbg(dev, "Detection failed at step 4\n");
1106 "4\n");
1107 err = -ENODEV; 1113 err = -ENODEV;
1108 goto ERROR2; 1114 goto ERROR2;
1109 } 1115 }
@@ -1112,9 +1118,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1112 if ((!is_isa) && (((!(val1 & 0x80)) && (val2 == 0xa3)) || 1118 if ((!is_isa) && (((!(val1 & 0x80)) && (val2 == 0xa3)) ||
1113 ((val1 & 0x80) && (val2 == 0x5c)))) { 1119 ((val1 & 0x80) && (val2 == 0x5c)))) {
1114 if (w83781d_read_value 1120 if (w83781d_read_value
1115 (new_client, W83781D_REG_I2C_ADDR) != address) { 1121 (client, W83781D_REG_I2C_ADDR) != address) {
1116 dev_dbg(&new_client->dev, "Detection failed " 1122 dev_dbg(dev, "Detection failed at step 5\n");
1117 "at step 5\n");
1118 err = -ENODEV; 1123 err = -ENODEV;
1119 goto ERROR2; 1124 goto ERROR2;
1120 } 1125 }
@@ -1123,27 +1128,26 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1123 1128
1124 /* We have either had a force parameter, or we have already detected the 1129 /* We have either had a force parameter, or we have already detected the
1125 Winbond. Put it now into bank 0 and Vendor ID High Byte */ 1130 Winbond. Put it now into bank 0 and Vendor ID High Byte */
1126 w83781d_write_value(new_client, W83781D_REG_BANK, 1131 w83781d_write_value(client, W83781D_REG_BANK,
1127 (w83781d_read_value(new_client, 1132 (w83781d_read_value(client, W83781D_REG_BANK)
1128 W83781D_REG_BANK) & 0x78) | 1133 & 0x78) | 0x80);
1129 0x80);
1130 1134
1131 /* Determine the chip type. */ 1135 /* Determine the chip type. */
1132 if (kind <= 0) { 1136 if (kind <= 0) {
1133 /* get vendor ID */ 1137 /* get vendor ID */
1134 val2 = w83781d_read_value(new_client, W83781D_REG_CHIPMAN); 1138 val2 = w83781d_read_value(client, W83781D_REG_CHIPMAN);
1135 if (val2 == 0x5c) 1139 if (val2 == 0x5c)
1136 vendid = winbond; 1140 vendid = winbond;
1137 else if (val2 == 0x12) 1141 else if (val2 == 0x12)
1138 vendid = asus; 1142 vendid = asus;
1139 else { 1143 else {
1140 dev_dbg(&new_client->dev, "Chip was made by neither " 1144 dev_dbg(dev, "Chip was made by neither "
1141 "Winbond nor Asus?\n"); 1145 "Winbond nor Asus?\n");
1142 err = -ENODEV; 1146 err = -ENODEV;
1143 goto ERROR2; 1147 goto ERROR2;
1144 } 1148 }
1145 1149
1146 val1 = w83781d_read_value(new_client, W83781D_REG_WCHIPID); 1150 val1 = w83781d_read_value(client, W83781D_REG_WCHIPID);
1147 if ((val1 == 0x10 || val1 == 0x11) && vendid == winbond) 1151 if ((val1 == 0x10 || val1 == 0x11) && vendid == winbond)
1148 kind = w83781d; 1152 kind = w83781d;
1149 else if (val1 == 0x30 && vendid == winbond) 1153 else if (val1 == 0x30 && vendid == winbond)
@@ -1157,7 +1161,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1157 kind = as99127f; 1161 kind = as99127f;
1158 else { 1162 else {
1159 if (kind == 0) 1163 if (kind == 0)
1160 dev_warn(&new_client->dev, "Ignoring 'force' " 1164 dev_warn(dev, "Ignoring 'force' "
1161 "parameter for unknown chip at " 1165 "parameter for unknown chip at "
1162 "adapter %d, address 0x%02x\n", 1166 "adapter %d, address 0x%02x\n",
1163 i2c_adapter_id(adapter), address); 1167 i2c_adapter_id(adapter), address);
@@ -1179,20 +1183,20 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1179 } 1183 }
1180 1184
1181 /* Fill in the remaining client fields and put into the global list */ 1185 /* Fill in the remaining client fields and put into the global list */
1182 strlcpy(new_client->name, client_name, I2C_NAME_SIZE); 1186 strlcpy(client->name, client_name, I2C_NAME_SIZE);
1183 data->type = kind; 1187 data->type = kind;
1184 1188
1185 data->valid = 0; 1189 data->valid = 0;
1186 mutex_init(&data->update_lock); 1190 mutex_init(&data->update_lock);
1187 1191
1188 /* Tell the I2C layer a new client has arrived */ 1192 /* Tell the I2C layer a new client has arrived */
1189 if ((err = i2c_attach_client(new_client))) 1193 if ((err = i2c_attach_client(client)))
1190 goto ERROR2; 1194 goto ERROR2;
1191 1195
1192 /* attach secondary i2c lm75-like clients */ 1196 /* attach secondary i2c lm75-like clients */
1193 if (!is_isa) { 1197 if (!is_isa) {
1194 if ((err = w83781d_detect_subclients(adapter, address, 1198 if ((err = w83781d_detect_subclients(adapter, address,
1195 kind, new_client))) 1199 kind, client)))
1196 goto ERROR3; 1200 goto ERROR3;
1197 } else { 1201 } else {
1198 data->lm75[0] = NULL; 1202 data->lm75[0] = NULL;
@@ -1200,11 +1204,11 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1200 } 1204 }
1201 1205
1202 /* Initialize the chip */ 1206 /* Initialize the chip */
1203 w83781d_init_client(new_client); 1207 w83781d_init_client(client);
1204 1208
1205 /* A few vars need to be filled upon startup */ 1209 /* A few vars need to be filled upon startup */
1206 for (i = 1; i <= 3; i++) { 1210 for (i = 1; i <= 3; i++) {
1207 data->fan_min[i - 1] = w83781d_read_value(new_client, 1211 data->fan_min[i - 1] = w83781d_read_value(client,
1208 W83781D_REG_FAN_MIN(i)); 1212 W83781D_REG_FAN_MIN(i));
1209 } 1213 }
1210 if (kind != w83781d && kind != as99127f) 1214 if (kind != w83781d && kind != as99127f)
@@ -1212,65 +1216,68 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1212 data->pwmenable[i] = 1; 1216 data->pwmenable[i] = 1;
1213 1217
1214 /* Register sysfs hooks */ 1218 /* Register sysfs hooks */
1215 data->class_dev = hwmon_device_register(&new_client->dev); 1219 if ((err = sysfs_create_group(&dev->kobj, &w83781d_group)))
1216 if (IS_ERR(data->class_dev)) {
1217 err = PTR_ERR(data->class_dev);
1218 goto ERROR4; 1220 goto ERROR4;
1219 }
1220 1221
1221 device_create_file_in(new_client, 0); 1222 if (kind != w83783s) {
1222 if (kind != w83783s) 1223 if ((err = device_create_file(dev, &dev_attr_in1_input))
1223 device_create_file_in(new_client, 1); 1224 || (err = device_create_file(dev, &dev_attr_in1_min))
1224 device_create_file_in(new_client, 2); 1225 || (err = device_create_file(dev, &dev_attr_in1_max)))
1225 device_create_file_in(new_client, 3); 1226 goto ERROR4;
1226 device_create_file_in(new_client, 4); 1227 }
1227 device_create_file_in(new_client, 5);
1228 device_create_file_in(new_client, 6);
1229 if (kind != as99127f && kind != w83781d && kind != w83783s) { 1228 if (kind != as99127f && kind != w83781d && kind != w83783s) {
1230 device_create_file_in(new_client, 7); 1229 if ((err = device_create_file(dev, &dev_attr_in7_input))
1231 device_create_file_in(new_client, 8); 1230 || (err = device_create_file(dev, &dev_attr_in7_min))
1231 || (err = device_create_file(dev, &dev_attr_in7_max))
1232 || (err = device_create_file(dev, &dev_attr_in8_input))
1233 || (err = device_create_file(dev, &dev_attr_in8_min))
1234 || (err = device_create_file(dev, &dev_attr_in8_max)))
1235 goto ERROR4;
1236 }
1237 if (kind != w83783s) {
1238 if ((err = device_create_file(dev, &dev_attr_temp3_input))
1239 || (err = device_create_file(dev, &dev_attr_temp3_max))
1240 || (err = device_create_file(dev,
1241 &dev_attr_temp3_max_hyst)))
1242 goto ERROR4;
1232 } 1243 }
1233
1234 device_create_file_fan(new_client, 1);
1235 device_create_file_fan(new_client, 2);
1236 device_create_file_fan(new_client, 3);
1237
1238 device_create_file_temp(new_client, 1);
1239 device_create_file_temp(new_client, 2);
1240 if (kind != w83783s)
1241 device_create_file_temp(new_client, 3);
1242
1243 device_create_file_vid(new_client);
1244 device_create_file_vrm(new_client);
1245
1246 device_create_file_fan_div(new_client, 1);
1247 device_create_file_fan_div(new_client, 2);
1248 device_create_file_fan_div(new_client, 3);
1249
1250 device_create_file_alarms(new_client);
1251
1252 device_create_file_beep(new_client);
1253 1244
1254 if (kind != w83781d && kind != as99127f) { 1245 if (kind != w83781d && kind != as99127f) {
1255 device_create_file_pwm(new_client, 1); 1246 if ((err = device_create_file(dev, &dev_attr_pwm1))
1256 device_create_file_pwm(new_client, 2); 1247 || (err = device_create_file(dev, &dev_attr_pwm2))
1257 device_create_file_pwmenable(new_client, 2); 1248 || (err = device_create_file(dev, &dev_attr_pwm2_enable)))
1249 goto ERROR4;
1258 } 1250 }
1259 if (kind == w83782d && !is_isa) { 1251 if (kind == w83782d && !is_isa) {
1260 device_create_file_pwm(new_client, 3); 1252 if ((err = device_create_file(dev, &dev_attr_pwm3))
1261 device_create_file_pwm(new_client, 4); 1253 || (err = device_create_file(dev, &dev_attr_pwm4)))
1254 goto ERROR4;
1262 } 1255 }
1263 1256
1264 if (kind != as99127f && kind != w83781d) { 1257 if (kind != as99127f && kind != w83781d) {
1265 device_create_file_sensor(new_client, 1); 1258 if ((err = device_create_file(dev, &dev_attr_temp1_type))
1266 device_create_file_sensor(new_client, 2); 1259 || (err = device_create_file(dev,
1267 if (kind != w83783s) 1260 &dev_attr_temp2_type)))
1268 device_create_file_sensor(new_client, 3); 1261 goto ERROR4;
1262 if (kind != w83783s) {
1263 if ((err = device_create_file(dev,
1264 &dev_attr_temp3_type)))
1265 goto ERROR4;
1266 }
1267 }
1268
1269 data->class_dev = hwmon_device_register(dev);
1270 if (IS_ERR(data->class_dev)) {
1271 err = PTR_ERR(data->class_dev);
1272 goto ERROR4;
1269 } 1273 }
1270 1274
1271 return 0; 1275 return 0;
1272 1276
1273ERROR4: 1277ERROR4:
1278 sysfs_remove_group(&dev->kobj, &w83781d_group);
1279 sysfs_remove_group(&dev->kobj, &w83781d_group_opt);
1280
1274 if (data->lm75[1]) { 1281 if (data->lm75[1]) {
1275 i2c_detach_client(data->lm75[1]); 1282 i2c_detach_client(data->lm75[1]);
1276 kfree(data->lm75[1]); 1283 kfree(data->lm75[1]);
@@ -1280,7 +1287,7 @@ ERROR4:
1280 kfree(data->lm75[0]); 1287 kfree(data->lm75[0]);
1281 } 1288 }
1282ERROR3: 1289ERROR3:
1283 i2c_detach_client(new_client); 1290 i2c_detach_client(client);
1284ERROR2: 1291ERROR2:
1285 kfree(data); 1292 kfree(data);
1286ERROR1: 1293ERROR1:
@@ -1297,9 +1304,11 @@ w83781d_detach_client(struct i2c_client *client)
1297 int err; 1304 int err;
1298 1305
1299 /* main client */ 1306 /* main client */
1300 if (data) 1307 if (data) {
1301 hwmon_device_unregister(data->class_dev); 1308 hwmon_device_unregister(data->class_dev);
1302 1309 sysfs_remove_group(&client->dev.kobj, &w83781d_group);
1310 sysfs_remove_group(&client->dev.kobj, &w83781d_group_opt);
1311 }
1303 if (i2c_is_isa_client(client)) 1312 if (i2c_is_isa_client(client))
1304 release_region(client->addr, W83781D_EXTENT); 1313 release_region(client->addr, W83781D_EXTENT);
1305 1314